Releases: crossplane/function-sdk-typescript
v0.3.0
v0.3.0 - CI/CD, Linting, and Dependency Updates
This release adds continuous integration workflows, code quality tooling, and updates dependencies to their latest versions.
Installation
npm install @crossplane-org/function-sdk-typescript@0.3.0What's New
GitHub Actions CI/CD
Added comprehensive CI/CD pipeline with automated testing and validation:
- Automated Testing: Test suite runs on every push and pull request
- Build Validation: Ensures the project builds successfully
- Linting: Automatic code quality checks with ESLint
- Protobuf Generation Check: Validates that generated protobuf files are up-to-date and committed
- CI will fail if
npm run protoc-genproduces different output than what's committed - Ensures consistency between proto definitions and generated code
- CI will fail if
The CI workflow runs on:
- Pushes to
mainbranch - Pushes to
release-*branches - All pull requests
Code Quality Tools
ESLint Integration: Modern ESLint configuration with TypeScript support
- Configured with
@eslint/jsandtypescript-eslint - Flat config format (eslint.config.js)
- Lint command:
npm run lint - Auto-fix command:
npm run lint:fix
Prettier Integration: Consistent code formatting across the project
- Configured for TypeScript, JSON, and Markdown files
- Format command:
npm run format - Format check:
npm run format:check
VSCode Integration: Development experience improvements
- Recommended extensions (ESLint, Prettier)
- Auto-format on save
- Consistent settings across contributors
Dependency Updates
Production Dependencies:
@grpc/grpc-js: ^1.12.4 → ^1.14.3google-protobuf: ^4.0.0 → ^4.0.1ts-proto: ^2.8.3 → ^2.10.1
Development Dependencies:
@types/node: ^22.10.5 → ^25.0.3- Added ESLint toolchain:
eslint@^9.39.2,@eslint/js@^9.39.2,typescript-eslint@^8.52.0 - Added
prettier@^3.7.4for code formatting
Code Formatting
All source files have been formatted with Prettier to ensure consistency:
- Updated 23 files with consistent formatting
- Applied modern TypeScript formatting standards
- Improved code readability throughout the project
Testing
All existing tests continue to pass with the updated dependencies:
- ✅ Full test suite passing
- ✅ Coverage maintained
- ✅ CI/CD pipeline validates all changes
Documentation
📖 README.md - Complete documentation
📖 USAGE.md - Usage guide
Requirements
- Node.js 18+
- TypeScript 5.9+
- Compatible with Crossplane Function Runtime API v1
Full Changelog
Full Changelog: v0.2.0...v0.3.0
Pull Requests
- #11: Add protobuf generation check to GitHub Actions CI
- #10: Add GitHub Actions CI workflow
- #9: Add ESLint and Prettier for code quality
- #8: Update dependencies to latest versions
Commits
- update version to 0.3.0 (a2b528a)
- update generated protobuf files (0714c38)
- update protoc used in ci action (7c57fa7)
- add protoc to ci.yaml workflow (7d1cca8)
- remove unused noop (fcd0667)
- remove redundant checkout action (ada517b)
- add ci github workflow (1f7e790)
- update libs (b46406c)
- lint fixes (7c7cf94)
- update packages (44c1353)
v0.2.0
v0.2.0 - Fixes status updates when desired Composite is undefined
This release fixes an issue where the status was not updated if the XR is undefined.
Added in this release is the the setDesiredResources function, an alternative to setDesiredComposedResources.
Installation
npm install @crossplane-org/function-sdk-typescript@0.2.0What's New
Update Status When Composite is undefined.
Breaking Change Fix: setDesiredCompositeStatus now always sets the status field, even when the composite resource doesn't exist yet in the desired state. Previously, this function would silently fail if the composite resource wasn't already present.
This ensures that functions can reliably set status fields on composite resources without having to manually initialize the composite resource structure first.
New Helper Function
setDesiredResources: A simpler alternative to setDesiredComposedResources for common use cases.
// Before - more verbose
dcds["my-bucket"] = Resource.fromJSON({
resource: {
apiVersion: "s3.aws.upbound.io/v1beta1",
kind: "Bucket",
metadata: { name: "my-bucket" },
spec: { forProvider: { region: "us-west-2" } }
}
});
rsp = setDesiredComposedResources(rsp, dcds);
// After - simpler
rsp = setDesiredResources(rsp, {
"my-bucket": {
apiVersion: "s3.aws.upbound.io/v1beta1",
kind: "Bucket",
metadata: { name: "my-bucket" },
spec: { forProvider: { region: "us-west-2" } }
}
});This helper automatically converts unstructured Kubernetes objects to the protobuf Resource format, reducing boilerplate when you don't need to specify readiness or connection details.
Bug Fixes
- Fixed
setDesiredCompositeStatusto properly initialize the composite resource structure before setting status, preventing silent failures
Documentation
📖 README.md - Complete documentation
📖 USAGE.md - Usage guide
Requirements
- Node.js 18+
- TypeScript 5.7+
- Compatible with Crossplane Function Runtime API v1
Full Changelog
Full Changelog: v0.1.0...v0.2.0
Commits
v0.1.0
Release Notes - v0.1.0
Initial Release
This is the first official release of the Crossplane Function SDK for TypeScript! This SDK provides a type-safe, developer-friendly way to build Crossplane Composition Functions using TypeScript/JavaScript.
Installation
npm install @crossplane-org/function-sdk-typescriptFeatures
Core Functionality
- Type-Safe Function Interface - Implement the
FunctionHandlerinterface for building custom composition functions - Request Helpers - Easy access to observed and desired composite resources, composed resources, input configuration, and context
- Response Helpers - Utilities for setting desired resources, updating status, managing context, and reporting results
- Resource Management - Full support for creating, reading, and manipulating Kubernetes resources with Protocol Buffer conversion
- Credentials Support - Secure access to credentials passed from Crossplane
- Context Passing - Share data between functions in a pipeline
Developer Experience
- Full TypeScript Support - Comprehensive type definitions for all SDK interfaces and Protocol Buffer types
- Testing Framework - Built-in Vitest testing support with coverage reporting
- Kubernetes Integration - Seamless integration with
kubernetes-modelsfor type-safe resource creation - Runtime Utilities - gRPC server creation with TLS/mTLS support
- Structured Logging - Built on Pino for fast, structured JSON logging
API Reference
Request Helpers
getObservedCompositeResource(req)- Get observed XRgetDesiredCompositeResource(req)- Get desired XRgetDesiredComposedResources(req)- Get desired composed resourcesgetObservedComposedResources(req)- Get observed composed resourcesgetInput(req)- Get function input configurationgetContextKey(req, key)- Read context from previous functiongetRequiredResources(req)- Get required resourcesgetCredentials(req, name)- Get credentials by name
Response Helpers
to(req, ttl?)- Initialize response from requestsetDesiredComposedResources(rsp, resources)- Set composed resourcessetDesiredCompositeResource(rsp, resource)- Set desired XRsetDesiredCompositeStatus({rsp, status})- Update XR statussetContextKey(rsp, key, value)- Set context for next functionsetOutput(rsp, output)- Set function outputnormal(rsp, message)- Add info resultwarning(rsp, message)- Add warning resultfatal(rsp, message)- Add fatal error resultupdate(source, target)- Deep merge resources
Resource Helpers
fromObject(obj)- Create Resource from plain objecttoObject(resource)- Extract plain object from ResourceasStruct(obj)/asObject(struct)- Convert between formatsnewDesiredComposed()- Create new empty DesiredComposed
Runtime
newGrpcServer(runner, logger)- Create gRPC serverstartServer(server, opts, logger)- Start servergetServerCredentials(opts)- Create server credentials
🔧 Dependencies
Runtime
@grpc/grpc-js^1.12.4google-protobuf^4.0.0pino^10.1.0ts-deepmerge^7.0.3ts-proto^2.8.3kubernetes-models^4.5.1
Development
typescript^5.7.2vitest^2.1.8@vitest/coverage-v8^2.1.8@types/node^22.10.5
Documentation
- README.md - Complete SDK documentation with examples
- USAGE.md - Detailed usage guide and API reference
Testing
Run tests with:
npm test # Run tests once
npm run test:watch # Run in watch mode
npm run test:coverage # Run with coverage🏗️ Quick Start
import {
FunctionHandler,
RunFunctionRequest,
RunFunctionResponse,
to,
normal,
getDesiredComposedResources,
setDesiredComposedResources,
Resource,
} from "@crossplane-org/function-sdk-typescript";
import type { Logger } from "@crossplane-org/function-sdk-typescript";
export class MyFunction implements FunctionHandler {
async RunFunction(req: RunFunctionRequest, logger?: Logger): Promise<RunFunctionResponse> {
let rsp = to(req);
try {
let dcds = getDesiredComposedResources(req);
// Create resources
dcds["my-configmap"] = Resource.fromJSON({
resource: {
apiVersion: "v1",
kind: "ConfigMap",
metadata: { name: "my-config" },
data: { key: "value" }
}
});
rsp = setDesiredComposedResources(rsp, dcds);
normal(rsp, "Resources created successfully");
return rsp;
} catch (error) {
logger?.error({ error }, "Function failed");
fatal(rsp, error instanceof Error ? error.message : String(error));
return rsp;
}
}
}Resources
Full Changelog: Initial release v0.1.0
What's Changed
- update sdk, update comments, remove dist dir by @stevendborrelli in upbound/function-sdk-typescript#1
- Update Request libraries by @stevendborrelli in upbound/function-sdk-typescript#2
- update package manifest and readme for v0.1.0 release by @stevendborrelli in upbound/function-sdk-typescript#3
- readme updates by @stevendborrelli in upbound/function-sdk-typescript#4
New Contributors
- @stevendborrelli made their first contribution in upbound/function-sdk-typescript#1
Full Changelog: https://github.com/upbound/function-sdk-typescript/commits/v0.1.0