Skip to content

Releases: crossplane/function-sdk-typescript

v0.5.0

05 Mar 21:46
9b69c9f

Choose a tag to compare

v0.5.0 - Required Resources, Schemas, and Capability Support

This release adds major new features for working with required resources and schemas, bringing the TypeScript SDK to feature parity with the Python SDK. Functions can now request Crossplane fetch additional resources and OpenAPI schemas, and check Crossplane's capabilities before using advanced features.

Installation

npm install @crossplane-org/function-sdk-typescript@0.5.0

What's New

Required Resources Support

Dynamically Fetch Additional Resources: Functions can now request that Crossplane fetch specific Kubernetes resources and include them in subsequent requests. This enables functions to read ConfigMaps, Secrets, and other cluster resources to inform composition logic.

Response: Request Resources

Use requireResource() to tell Crossplane which resources to fetch:

import { requireResource } from '@crossplane-org/function-sdk-typescript';

// Match a specific ConfigMap by name
rsp = requireResource(rsp, "app-config", {
  apiVersion: "v1",
  kind: "ConfigMap",
  matchName: "my-app-config",
  namespace: "production"
});

// Match all Secrets with specific labels
rsp = requireResource(rsp, "db-secrets", {
  apiVersion: "v1",
  kind: "Secret",
  matchLabels: {
    labels: {
      app: "database",
      tier: "backend"
    }
  },
  namespace: "production"
});

Request: Retrieve Required Resources

In the next function invocation, retrieve the fetched resources:

import { getRequiredResource } from '@crossplane-org/function-sdk-typescript';

const [resources, resolved] = getRequiredResource(req, "app-config");
if (!resolved) {
  console.log("Resource requirement not yet resolved by Crossplane");
} else if (resources.length === 0) {
  console.log("Resource requirement resolved but no resources found");
} else {
  console.log("Found resources:", resources);
  resources.forEach(r => console.log(r.resource));
}

The selector supports:

  • Match by name: Fetch a specific resource with matchName
  • Match by labels: Fetch all resources matching label selectors with matchLabels
  • Namespace scoping: Specify namespace for namespaced resources, or omit for cluster-scoped resources
  • Cross-namespace: Omit namespace when matching by labels to search all namespaces

Required Schemas Support

Access OpenAPI Schemas: Functions can now request OpenAPI v3 schemas for resource kinds. This enables validation, default value application, and schema-aware composition logic.

Response: Request Schemas

Use requireSchema() to tell Crossplane which schemas to fetch:

import { requireSchema } from '@crossplane-org/function-sdk-typescript';

// Request the OpenAPI schema for an XR type
rsp = requireSchema(rsp, "xr-schema", "example.org/v1", "MyResource");

// Request schema for a composed resource type
rsp = requireSchema(rsp, "bucket-schema", "s3.aws.upbound.io/v1beta1", "Bucket");

Request: Retrieve Required Schemas

In the next function invocation, access the schemas:

import { getRequiredSchema, getRequiredSchemas } from '@crossplane-org/function-sdk-typescript';

// Get a specific schema
const [schema, resolved] = getRequiredSchema(req, "xr-schema");
if (!resolved) {
  console.log("Schema not yet resolved by Crossplane");
} else if (!schema) {
  console.log("Schema resolved but not found (kind may not exist)");
} else {
  console.log("Schema properties:", schema.properties);
  console.log("Required fields:", schema.required);
}

// Get all required schemas
const schemas = getRequiredSchemas(req);
for (const [name, schema] of Object.entries(schemas)) {
  if (schema) {
    console.log(`Schema ${name}:`, schema);
  } else {
    console.log(`Schema ${name} was requested but not found`);
  }
}

For CRDs, Crossplane returns the spec.versions[].schema.openAPIV3Schema field. If Crossplane cannot find a schema for the requested kind, the schema will be undefined (with resolved returning true).

Capability Detection

Check Crossplane Features: Functions can now detect which capabilities Crossplane supports, enabling graceful degradation and conditional feature usage.

import { advertiseCapabilities, hasCapability, Capability } from '@crossplane-org/function-sdk-typescript';

// Check if Crossplane advertises capabilities (v2.2+)
if (!advertiseCapabilities(req)) {
  console.log("Crossplane version predates capability advertisement");
} else {
  // Check for specific capabilities
  if (hasCapability(req, Capability.CAPABILITY_REQUIRED_SCHEMAS)) {
    requireSchema(rsp, "xr", xrApiVersion, xrKind);
  }

  if (hasCapability(req, Capability.CAPABILITY_REQUIRED_RESOURCES)) {
    requireResource(rsp, "config", configSelector);
  }
}

Available capabilities:

  • CAPABILITY_CAPABILITIES - Crossplane advertises its capabilities
  • CAPABILITY_REQUIRED_RESOURCES - Support for required resources
  • CAPABILITY_REQUIRED_SCHEMAS - Support for required schemas
  • CAPABILITY_WATCHED_RESOURCES - Support for watched resources (deprecated)

Crossplane v2.2 and later advertise their capabilities in the request metadata. For older versions, advertiseCapabilities() returns false and hasCapability() will always return false, even for features the older Crossplane may support.

Enhanced Resource Utilities

Merge and Update Resources: New helper functions for working with resource conditions and updates.

Update Resources with Merge

The update() function performs deep merges of resource data:

import { update } from '@crossplane-org/function-sdk-typescript';

const bucket = getDesiredComposedResources(req)["my-bucket"];
if (bucket) {
  // Update specific fields while preserving others
  // Arrays are replaced by default (matches Python SDK behavior)
  update(bucket, {
    resource: {
      spec: {
        forProvider: {
          region: "us-west-2",
          tags: ["env:prod", "team:platform"]  // Replaces existing tags
        }
      }
    }
  });
}

// Optionally concatenate arrays instead of replacing them
update(bucket, {
  resource: {
    spec: {
      forProvider: {
        tags: ["new-tag"]  // Will be appended to existing tags
      }
    }
  }
}, { mergeArrays: true });

By default, arrays are replaced (matching Python SDK semantics). Set mergeArrays: true to concatenate arrays instead.

Get Status Conditions

The getCondition() function extracts Kubernetes status conditions:

import { getCondition } from '@crossplane-org/function-sdk-typescript';

const oxr = getObservedCompositeResource(req);
if (oxr?.resource) {
  const readyCondition = getCondition(oxr.resource, "Ready");
  if (readyCondition.status === "True") {
    console.log("Resource is ready");
  } else if (readyCondition.status === "False") {
    console.log("Resource not ready:", readyCondition.message);
  } else {
    console.log("Ready status unknown");
  }
}

// Check if a composed resource is synced
const bucket = observedResources["my-bucket"];
if (bucket?.resource) {
  const synced = getCondition(bucket.resource, "Synced");
  console.log("Sync status:", synced.status, synced.reason);
}

Returns a condition with status "Unknown" if the requested condition type is not found.

New Types and Exports

This release adds several new TypeScript types and exports:

Request helpers:

  • getRequiredResource() - Get a required resource by name
  • getRequiredResources() - Get all required resources
  • getRequiredSchema() - Get a required schema by name
  • getRequiredSchemas() - Get all required schemas
  • advertiseCapabilities() - Check if Crossplane advertises capabilities
  • hasCapability() - Check for a specific capability

Response helpers:

  • requireResource() - Request Crossplane fetch resources
  • requireSchema() - Request Crossplane fetch schemas

Resource utilities:

  • update() - Deep merge resource data with configurable array handling
  • getCondition() - Extract status conditions from resources
  • Condition - TypeScript interface for status conditions
  • MergeOptions - Options for controlling merge behavior

Protocol buffer types:

  • Capability - Enum of Crossplane capabilities
  • ResourceSelector - Selector for matching required resources
  • SchemaSelector - Selector for matching required schemas
  • Requirements - Protocol buffer message for requirements

Protobuf Updates

Updated Function Runtime API: Regenerated protobuf TypeScript files from the latest Crossplane Function Runtime API, adding support for:

  • Required resources (requiredResources field)
  • Required schemas (requiredSchemas field)
  • Capability advertisement (meta.capabilities field)
  • Resource requirements (requirements.resources field)
  • Schema requirements (requirements.schemas field)

The protobuf updates add 572 lines of new types and message handling code for these features.

Feature Parity with Python SDK

This release brings the TypeScript SDK to feature parity with the Python SDK (v0.8+) for:

  • ✅ Required resources with selectors (name and label-based)
  • ✅ Required schemas with OpenAPI v3 support
  • ✅ Capability detection and advertisement
  • ✅ Resource update with configurable merge semantics
  • ✅ Status condition extraction
  • ✅ Comprehensive test coverage for all new features

Testing

All new features include comprehensive test coverage:

  • ✅ Required resource fetching and resolution
  • ✅ Required schema fetching and resolution
  • ✅ Capability detection and checking
  • ✅ Resource update and merge operations (with and without array merging)
  • ✅ Status condition extraction
  • ✅ Ed...
Read more

v0.4.0 release

03 Mar 10:18
290e340

Choose a tag to compare

v0.4.0 - New Helper Function and Dependency Updates

This release adds a new convenience helper function for working with Kubernetes models and includes dependency updates for security and automation improvements.

Installation

npm install @crossplane-org/function-sdk-typescript@0.4.0

What's New

New fromModel Helper Function

Simplified Resource Creation from Kubernetes Models: A new fromModel helper function streamlines the pattern of converting Kubernetes models to Resources.

Before:

desiredResources["my-pod"] = Resource.fromJSON({
  resource: pod.toJSON()
});

After:

desiredResources["my-pod"] = fromModel(pod);

This helper function:

  • Accepts any object with a toJSON() method (compatible with kubernetes-models)
  • Optionally accepts connectionDetails and ready parameters
  • Reduces boilerplate code when working with Kubernetes resource models
  • Maintains full type safety with TypeScript generics

The function signature:

export function fromModel<T extends Record<string, unknown>>(
  obj: { toJSON: () => T },
  connectionDetails?: ConnectionDetails,
  ready?: Ready,
): Resource

Renovate Integration

Automated Dependency Management: Added Renovate configuration for automated dependency updates:

  • Groups non-major updates together for easier review
  • Schedules updates for Sunday nights to minimize disruption
  • Adds security labels for vulnerability alerts
  • Groups GitHub Actions updates separately
  • Pins GitHub Action digests for improved security
  • Limits concurrent PRs to prevent overwhelming the review queue

CI/CD Improvements

Version Validation: The CI workflow now ensures tagged versions match the version in package.json, preventing version mismatch issues during releases.

Protobuf Compiler Update: Updated the GitHub Actions protobuf generation check to use protoc version 33.4, matching the version used by ts-proto. This ensures consistency between local development and CI environments.

Protobuf Regeneration: Regenerated all protobuf TypeScript files with the updated protoc version, resulting in improved type definitions and better code generation for:

  • src/proto/google/protobuf/duration.ts
  • src/proto/google/protobuf/struct.ts
  • src/proto/run_function.ts

Security Updates

npm audit fixes: Updated dependencies to address security vulnerabilities:

  • minimatch vulnerability (GHSA-7r86-cg39-jmmj, GHSA-23c5-xmqv-rm74): Fixed ReDoS vulnerabilities in minimatch 10.0.0 - 10.2.2, including:
    • ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments
    • ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions
  • ESLint vulnerability: Updated ESLint development dependencies from ^9.39.2 to ^10.0.2 to address security issues in the linting toolchain
  • typescript-eslint: Updated from ^8.52.0 to ^8.56.1 for improved type checking and security
  • Rollup vulnerability (GHSA-mw96-cpmx-2vgc): Updated transitive dependencies to address Arbitrary File Write via Path Traversal vulnerability in Rollup 4.0.0 - 4.58.0

After these updates, npm audit reports 0 vulnerabilities. All vulnerabilities were in development dependencies only and did not affect production code.

Documentation Updates

Template Location: Updated README to point developers to the official function-template-typescript repository for getting started with creating Crossplane Functions.

Testing

The fromModel helper includes comprehensive test coverage:

  • ✅ Converting kubernetes-models to Resources
  • ✅ Handling optional connectionDetails and ready parameters
  • ✅ Type safety with TypeScript generics
  • ✅ Full test suite passing
  • ✅ 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.3.1...v0.4.0

Pull Requests

  • #13: 0.4.0 prep - Update dependencies and version
  • #12: npm audit fix to address minimatch vulnerability
  • #11: Add fromModel helper
  • #10: Update readme for template location
  • #9: Run npm audit fix to address Rollup vulnerability
  • #8: Simplify renovate configuration
  • #7: Add renovate configuration
  • #6: npm audit fix updates for ESLint vulnerabilities
  • #5: Ensure tagged version matches package.json

Commits

  • Merge pull request #13 from stevendborrelli/0.4.0 (290e340)
  • update gh action protoc (a856a5a)
  • regen files from updated protoc (b3ce8e3)
  • update dependencies (1c2cd53)
  • update for v0.4.0 and format files (9eacd0c)
  • Merge pull request #12 from stevendborrelli/2026-03-03-audit-fix (35d01f8)
  • npm audit fix to address vulns (0f6b980)
  • Merge pull request #11 from stevendborrelli/fromModel (6f6d9f9)
  • replace double quotes in import (3c4ccc2)
  • refactor based on copilot review (494ad75)
  • update fromModel type signature (affaca2)
  • add fromModel helper (75dd7f7)
  • Merge pull request #10 from stevendborrelli/use-template (8e33b4d)
  • update readme for template location (6ad34a2)
  • Merge pull request #9 from stevendborrelli/update-rollup (f6de83f)
  • run npm audit fix (0116a3e)
  • Merge pull request #8 from stevendborrelli/renovate-pt-2 (c8d4c62)
  • simplify configuration (1f96b3c)
  • Merge pull request #7 from stevendborrelli/renovate (cabdc5c)
  • update minimumReleaseAge (568200a)
  • update renovate settings (a22498c, f6d2977, 69a681b, ac1fc65, e8a6b2f)
  • add renovate settings (8a8ec19)
  • Merge pull request #6 from stevendborrelli/2026-02-npm-audit (443c52c)
  • npm audit fix updates (63909cc)
  • Merge pull request #5 from stevendborrelli/gh-action-check-version (61c5905)
  • ensure tagged version matches package.json (d060b7c)

v0.3.1

24 Feb 11:15
ef31d4b

Choose a tag to compare

v0.3.1 - CI/CD Improvements and Organization Updates

This release includes significant improvements to the CI/CD pipeline, GitHub templates, and organizational updates.

Installation

npm install @crossplane-org/function-sdk-typescript@0.3.1

What's New

Enhanced CI/CD Pipeline

Automated Publishing with Provenance: The CI workflow now supports automated npm publishing with sigstore provenance attestation:

  • Workflow Dispatch: Manually trigger builds with custom version numbers
  • Automated Publishing: Publish to npm on push to main branch or manual workflow dispatch
  • Provenance Support: Built-in support for npm provenance using GitHub OIDC tokens
  • Version Management: Automatic versioning with timestamp and commit SHA for development builds
  • Multi-tag Support: Publishes with appropriate npm tags (latest for releases, next for dev builds)

New Tag Workflow: Simplified release tagging process with tag.yml workflow for creating version tags directly from GitHub Actions.

GitHub Templates

Added comprehensive GitHub templates for better project management:

  • Bug Report Template: Structured format for reporting bugs with environment details
  • Feature Request Template: Template for proposing new features
  • Pull Request Template: Standardized PR format with checklist and testing requirements

Code Quality Improvements

Removed Example Code: Cleaned up example files that were not needed:

  • Removed src/example-function.ts (113 lines)
  • Removed src/main.ts (87 lines)

ESLint Fixes: Addressed various linting issues throughout the codebase for better code quality and consistency.

Enhanced Resource Handling: Improved type safety and error handling in resource management:

  • Better validation in resource.ts
  • Enhanced response handling in response.ts and request.ts

Documentation Updates

Repository Organization: Updated repository references to point to the official Crossplane organization:

  • Repository URL: https://github.com/crossplane/function-sdk-typescript
  • Package published under @crossplane-org scope

README Improvements:

  • Fixed broken documentation links
  • Updated references from master to latest
  • Clarified concepts and usage patterns

Development Experience

Node.js 24 Support: Updated to use Node.js 24 in CI/CD workflows for the latest features and performance improvements.

Improved Clean Script: Enhanced scripts/clean.sh for better cleanup of generated files.

Bug Fixes

  • Fixed repository URL format in package.json to include https:// protocol for npm provenance verification
  • Fixed broken links in documentation
  • Addressed ESLint warnings and errors

Testing

All existing tests continue to pass:

  • ✅ 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.3.0...v0.3.1

Pull Requests

  • #3: Add standard Crossplane workflows
  • #2: Add GitHub Actions for automated publishing
  • #17: Update organization to crossplane-org
  • #16: Fix ESLint issues
  • #15: Remove main.ts example file
  • #14: Improve README concepts documentation
  • #13: Clean up clean.sh script

Commits

v0.3.0

10 Feb 19:18

Choose a tag to compare

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.0

What'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-gen produces different output than what's committed
    • Ensures consistency between proto definitions and generated code

The CI workflow runs on:

  • Pushes to main branch
  • Pushes to release-* branches
  • All pull requests

Code Quality Tools

ESLint Integration: Modern ESLint configuration with TypeScript support

  • Configured with @eslint/js and typescript-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.3
  • google-protobuf: ^4.0.0 → ^4.0.1
  • ts-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.4 for 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

v0.2.0

10 Feb 19:16

Choose a tag to compare

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.0

What'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 setDesiredCompositeStatus to 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

  • update version to v0.2.0 (be73cc6)
  • update sdk to always set status (cc6e79e)

v0.1.0

10 Feb 19:15
fcddf53

Choose a tag to compare

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-typescript

Features

Core Functionality

  • Type-Safe Function Interface - Implement the FunctionHandler interface 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-models for 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 XR
  • getDesiredCompositeResource(req) - Get desired XR
  • getDesiredComposedResources(req) - Get desired composed resources
  • getObservedComposedResources(req) - Get observed composed resources
  • getInput(req) - Get function input configuration
  • getContextKey(req, key) - Read context from previous function
  • getRequiredResources(req) - Get required resources
  • getCredentials(req, name) - Get credentials by name

Response Helpers

  • to(req, ttl?) - Initialize response from request
  • setDesiredComposedResources(rsp, resources) - Set composed resources
  • setDesiredCompositeResource(rsp, resource) - Set desired XR
  • setDesiredCompositeStatus({rsp, status}) - Update XR status
  • setContextKey(rsp, key, value) - Set context for next function
  • setOutput(rsp, output) - Set function output
  • normal(rsp, message) - Add info result
  • warning(rsp, message) - Add warning result
  • fatal(rsp, message) - Add fatal error result
  • update(source, target) - Deep merge resources

Resource Helpers

  • fromObject(obj) - Create Resource from plain object
  • toObject(resource) - Extract plain object from Resource
  • asStruct(obj) / asObject(struct) - Convert between formats
  • newDesiredComposed() - Create new empty DesiredComposed

Runtime

  • newGrpcServer(runner, logger) - Create gRPC server
  • startServer(server, opts, logger) - Start server
  • getServerCredentials(opts) - Create server credentials

🔧 Dependencies

Runtime

  • @grpc/grpc-js ^1.12.4
  • google-protobuf ^4.0.0
  • pino ^10.1.0
  • ts-deepmerge ^7.0.3
  • ts-proto ^2.8.3
  • kubernetes-models ^4.5.1

Development

  • typescript ^5.7.2
  • vitest ^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

New Contributors

Full Changelog: https://github.com/upbound/function-sdk-typescript/commits/v0.1.0