Add Typescript support for crossplane projects
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- docker, node.js, typescript
- Domain
- build-system, cli, tooling
Research direction
Start by tracing the crossplane project build and crossplane function init --language=typescript entry points, then review the schemas/typescript/ package layout and the function build requirements. Compare the existing project languages and templates before deciding how schema generation, dependency installation, and Docker packaging fit together. Done means the listed acceptance criteria pass, including a working template, generated dependency models, and a function that runs in Kubernetes.
Written by the indexing model from the issue text.
Description
What problem are you facing?
Add TypeScript Support for Composition Functions under Projects
Summary
Add first-class TypeScript support to the Crossplane CLI, enabling developers to write composition functions in TypeScript with full type safety for Crossplane resources.
Background
The TypeScript ecosystem for Crossplane composition functions is maturing and covers the Crossplane function SDK, model generation and template project:
- function-sdk-typescript- TypeScript SDK for writing composition functions, published as
@crossplane-org/function-sdk-typescripton npm - function-template-typescript - Typescript function template (will be updated with crossplane projects).
- typescript-models - Generate typescript models from Crossplane providers
- kubernetes-models - Generates TypeScript classes from CRDs with constructors, interfaces, and runtime validation via
@kubernetes-models/crd-generate
Proposed Features
1. TypeScript Function Builder
Add a TypeScript function builder that:
- Detects TypeScript functions by presence of
package.json+src/directory - Builds functions using a Node.js container (
node:25-slim) - Runs
npm installandnpm run build(typically invokingtsgo) - Packages the compiled JavaScript onto a distroless Node.js runtime (
gcr.io/distroless/nodejs24-debian12)
2. TypeScript Schema Generation
Generate TypeScript models from CRDs/XRDs using @kubernetes-models/crd-generate:
- Generates proper TypeScript classes with constructors (not just interfaces)
- Includes runtime validation via
@kubernetes-models/base - Produces a
crossplane-modelsnpm package that functions can import - Supports all project dependencies (providers, XRDs, etc.)
3. Function Template
Add a TypeScript function template for crossplane function init:
- Pre-configured
package.jsonwith SDK dependencies - TypeScript configuration (
tsconfig.json) - Example function implementation
- Integration with generated
crossplane-models
Example Usage
# crossplane-project.yaml
apiVersion: dev.crossplane.io/v1alpha1
kind: Project
metadata:
name: my-configuration
spec:
schemas:
languages:
- typescript
functions:
- source: Directory
directory:
name: my-function
dependencies:
- type: xpkg
xpkg:
package: xpkg.upbound.io/upbound/provider-aws-ec2
version: v2.6.0
// functions/my-function/src/function.ts
import { RunFunctionRequest, RunFunctionResponse } from '@crossplane-org/function-sdk-typescript';
import { VPC } from 'crossplane-models/ec2.aws.upbound.io/v1beta1';
export async function runFunction(req: RunFunctionRequest): Promise<RunFunctionResponse> {
const vpc = new VPC({
metadata: { name: 'my-vpc' },
spec: {
forProvider: {
region: 'us-west-2',
cidrBlock: '10.0.0.0/16',
},
},
});
// ... compose resources with full type safety
}
Implementation Details
Schema Generation
- Use
@kubernetes-models/crd-generateto generate TypeScript from CRDs - Merge all CRD sources (local XRDs + provider dependencies) before generation
- Output to
schemas/typescript/as an npm package namedcrossplane-models - Functions reference schemas via
file:dependency inpackage.json
Build Process
- Run builds in Docker container for reproducibility
- Install schema package dependencies before function dependencies (for symlinked
file:deps) - Dereference symlinks when copying to runtime image (
cp -rL) - Configure distroless runtime with Node.js entrypoint
Generated Package Structure
schemas/typescript/
├── package.json
├── index.js
├── index.d.ts
├── ec2.aws.upbound.io/
│ └── v1beta1/
│ ├── VPC.js
│ ├── VPC.d.ts
│ ├── Subnet.js
│ └── ...
└── my.custom.api/
└── v1alpha1/
└── ...
Related Work
- https://github.com/crossplane-contrib/function-sdk-typescript
- https://github.com/upbound/configuration-aws-network-ts - typescript port of configuration-aws-network
- https://github.com/tommy351/kubernetes-models-ts
Acceptance Criteria
-
crossplane project buildbuilds TypeScript functions -
crossplane function init --language=typescriptcreates a working template - TypeScript schemas are generated for all project dependencies
- Generated types include classes with constructors, interfaces, and validation
- Built functions run correctly in Kubernetes
- Dominant language
- Go
- Stars
- 19
- Forks
- 31
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 53
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crossplane/cli
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
crossplane/cli#282 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
crossplane/cli#384 ·
-
crossplane/cli#379 · 1 assignee ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
crossplane/cli#370 · 1 reaction ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 28/100
crossplane/cli#369 ·
Similar issues
-
bug github_actions
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
registrystack/registry-stack#1393 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
JakeChampion/lang#10213 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
oasisprotocol/oasis-sdk#2523 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100