Skip to content

Commit 50d641a

Browse files
committed
feat(api): generate AIP TypeScript SDK
1 parent f443a24 commit 50d641a

145 files changed

Lines changed: 20216 additions & 810 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,20 @@ jobs:
699699
run: |
700700
nix develop --impure .#ci -c go test -v -count=1 ./quickstart/
701701
702+
- name: Run TypeScript SDK example
703+
env:
704+
OPENMETER_URL: http://localhost:48888/api/v3
705+
working-directory: api/spec
706+
run: |
707+
# Build dist/ from src/, then run the quickstart example against it.
708+
nix develop --impure ../../.#ci -c bash -c '
709+
set -euo pipefail
710+
corepack enable >/dev/null 2>&1 || true
711+
pnpm install --frozen-lockfile 2>&1 | tail -5
712+
pnpm --filter @openmeter/sdk run build
713+
node --experimental-strip-types packages/aip-client-javascript/examples/quickstart/main.ts
714+
'
715+
702716
- name: Cleanup Docker Compose
703717
run: docker compose -f docker-compose.yaml -f docker-compose.override.yaml down -v
704718
working-directory: quickstart

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ All generated files have `// Code generated by X, DO NOT EDIT.` headers — neve
9090
2. Run `make gen-api` to regenerate OpenAPI spec and SDKs
9191
3. Run `make generate` to regenerate Go server/client code
9292

93+
The TypeSpec JS client emitted from `api/spec/packages/aip` now lands in `api/spec/packages/aip-client-javascript/`. Treat `api/spec/packages/aip-client-javascript/src/` and its generated `package.json` as emitter output: keep hand-written Playwright config, tests, and helpers outside `src/`, and put test runner dependencies/scripts in the stable `api/spec/package.json` workspace root instead of the generated client package manifest.
94+
95+
The emitted `api/spec/packages/aip-client-javascript/src/openMeterClient.ts` exposes aggregated sub-client getters on `OpenMeterClient` (e.g. `meters`, `customers`, `features`, `productCatalog`, `subscriptions`, `billing`, `entitlements`). Access operations through those getters, e.g. `sdk.meters.list()`, `sdk.customers.create(...)`, `sdk.productCatalog.createPlan(...)`. Note that resources are grouped by tag, so some operations live under a grouped client rather than a same-named top-level getter (for example plan operations are `sdk.productCatalog.createPlan`, not `sdk.plans.create`).
96+
9397
When adding query decorators (for example `@query`) to a TypeSpec file that does not already use HTTP decorators, import `@typespec/http` and add `using TypeSpec.Http;` in that file; otherwise compilation fails with `Unknown decorator @query`.
9498

9599
**Workflow for changing Go types/DI:**

api/spec/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# TypeSpec output (all packages)
22
**/output/
3+
**/dist/
34

45
# Dependency directories
56
node_modules/
7+
tsconfig.tsbuildinfo

api/spec/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.npmrc
22
pnpm-lock.yaml
33
packages/**/output/
4+
packages/**/dist/
5+
packages/typespec-typescript/src/static-helpers/lib-files-data.gen.ts

api/spec/AGENTS.md

Lines changed: 431 additions & 0 deletions
Large diffs are not rendered by default.

api/spec/package.json

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
"version": "0.1.0",
44
"type": "module",
55
"scripts": {
6-
"generate": "pnpm --filter @openmeter/api-spec-legacy run generate && pnpm --filter @openmeter/api-spec-aip run generate",
6+
"build": "pnpm --filter @openmeter/typespec-typescript run build",
7+
"generate": "pnpm run build && pnpm --filter @openmeter/api-spec-legacy run generate && pnpm --filter @openmeter/api-spec-aip run generate",
78
"format": "prettier --list-different --find-config-path --write . && pnpm --filter @openmeter/api-spec-aip run format",
89
"lint": "prettier --check . && pnpm --filter @openmeter/api-spec-legacy run lint && pnpm --filter @openmeter/api-spec-aip run lint",
9-
"lint:fix": "prettier --write ."
10+
"lint:fix": "prettier --write .",
11+
"test:sdk": "vitest --run --root packages/aip-client-javascript",
12+
"test:client:e2e": "playwright test --config packages/client/playwright.config.ts"
1013
},
1114
"devDependencies": {
12-
"@typespec/prettier-plugin-typespec": "1.11.0",
13-
"prettier": "3.8.3"
15+
"@fetch-mock/vitest": "0.2.18",
16+
"@playwright/test": "1.60.0",
17+
"@typespec/prettier-plugin-typespec": "1.12.0",
18+
"prettier": "3.8.3",
19+
"vitest": "4.1.4"
1420
},
1521
"exports": {
1622
"./openapi.yaml": "./packages/legacy/output/openapi.OpenMeterCloud.yaml",
@@ -19,7 +25,7 @@
1925
"./v3/openapi.yaml": "./packages/aip/output/definitions/metering-and-billing/v3/openapi.MeteringAndBilling.yaml"
2026
},
2127
"private": true,
22-
"packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8",
28+
"packageManager": "pnpm@10.34.1+sha512.b58fbde6dca66a929538021581f648b4570b6ca19b18e7cbd7f2c07a7b24454155388dacdf08f2af3678e88a6d1fe04f9d609df24bf51735a060ea041b374ab7",
2329
"pnpm": {
2430
"onlyBuiltDependencies": [
2531
"@typespec/http-client-python"
@@ -29,10 +35,22 @@
2935
"@typespec/compiler": "patches/@typespec__compiler.patch",
3036
"@typespec/openapi": "patches/@typespec__openapi.patch",
3137
"@typespec/openapi3": "patches/@typespec__openapi3.patch",
32-
"@typespec/http-client-python": "patches/@typespec__http-client-python.patch"
38+
"@typespec/http-client": "patches/@typespec__http-client.patch",
39+
"@typespec/http-client-python": "patches/@typespec__http-client-python.patch",
40+
"@typespec/emitter-framework@0.17.0": "patches/@typespec__emitter-framework@0.17.0.patch"
3341
},
3442
"overrides": {
35-
"postcss@<8.5.10": ">=8.5.10"
43+
"postcss@<8.5.10": ">=8.5.10",
44+
"playwright@<1.55.1": ">=1.55.1",
45+
"fast-xml-builder@<=1.1.6": ">=1.1.7",
46+
"fast-xml-builder@=1.1.5": ">=1.1.6",
47+
"fast-uri@<=3.1.0": ">=3.1.1",
48+
"fast-uri@<=3.1.1": ">=3.1.2",
49+
"@protobufjs/utf8@<=1.1.0": ">=1.1.1",
50+
"protobufjs@<=7.5.5": ">=7.5.6",
51+
"semver@<7.7.4": ">=7.7.4",
52+
"@alloy-js/core": "0.23.1",
53+
"@alloy-js/typescript": "0.23.0"
3654
}
3755
}
3856
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Build output
2+
dist/
3+
tsconfig.tsbuildinfo
4+
5+
# Dependencies
6+
node_modules/
7+
8+
# Generated conformance guards (compile-time only, re-emitted by the generator)
9+
*.assert.ts
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# package.json "files": ["dist"] is the active publish allowlist and takes
2+
# precedence, so these patterns only take effect if that allowlist is removed.
3+
# They keep dev files and compile-time-only artifacts out of the published
4+
# package in that case.
5+
6+
# Generated conformance guards — compile-time only, no runtime value.
7+
*.assert.*
8+
9+
# Sources and dev tooling
10+
src/
11+
tests/
12+
tsconfig.json
13+
tsconfig.tsbuildinfo
14+
.gitignore
15+
16+
# Source maps
17+
*.map

0 commit comments

Comments
 (0)