@postman/sdk-config 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +139 -124
  2. package/dist/index.cjs +301 -149
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +3 -3
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.js +292 -150
  7. package/dist/index.js.map +1 -1
  8. package/dist/sdk-config/index.cjs +290 -113
  9. package/dist/sdk-config/index.cjs.map +1 -1
  10. package/dist/sdk-config/index.d.cts +2 -2
  11. package/dist/sdk-config/index.d.ts +2 -2
  12. package/dist/sdk-config/index.js +284 -114
  13. package/dist/sdk-config/index.js.map +1 -1
  14. package/dist/sdk-config/v1/index.cjs +290 -113
  15. package/dist/sdk-config/v1/index.cjs.map +1 -1
  16. package/dist/sdk-config/v1/index.d.cts +6903 -289
  17. package/dist/sdk-config/v1/index.d.ts +6903 -289
  18. package/dist/sdk-config/v1/index.js +284 -114
  19. package/dist/sdk-config/v1/index.js.map +1 -1
  20. package/dist/sdk-config-ir/index.cjs +71 -31
  21. package/dist/sdk-config-ir/index.cjs.map +1 -1
  22. package/dist/sdk-config-ir/index.d.cts +2 -2
  23. package/dist/sdk-config-ir/index.d.ts +2 -2
  24. package/dist/sdk-config-ir/index.js +69 -32
  25. package/dist/sdk-config-ir/index.js.map +1 -1
  26. package/dist/sdk-config-ir/v1/index.cjs +71 -31
  27. package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
  28. package/dist/sdk-config-ir/v1/index.d.cts +130 -43
  29. package/dist/sdk-config-ir/v1/index.d.ts +130 -43
  30. package/dist/sdk-config-ir/v1/index.js +69 -32
  31. package/dist/sdk-config-ir/v1/index.js.map +1 -1
  32. package/dist/{typescript-ByDbin_v.d.cts → typescript-DNqK3T3v.d.cts} +5 -1
  33. package/dist/{typescript-ByDbin_v.d.ts → typescript-DNqK3T3v.d.ts} +5 -1
  34. package/docs/releasing.md +114 -0
  35. package/package.json +2 -2
  36. package/src/sdk-config/v1/README.md +91 -23
  37. package/src/sdk-config-ir/v1/README.md +3 -2
package/README.md CHANGED
@@ -1,164 +1,179 @@
1
1
  # @postman/sdk-config
2
2
 
3
- Shared, runtime-validated public and internal configuration contracts for Postman's SDK generation
4
- pipeline.
3
+ Build and validate SDK Config documents for SDK Generation API requests.
5
4
 
6
- This package is the source of truth for the customer-facing `SdkConfig` and internal `SdkConfigIr`.
7
- It is intended for sdk-gen-core, sdk-gen-api, Postman and Fern CLIs, and translators that normalize
8
- producer-specific configuration before generation.
5
+ SDK Config describes what to generate: API source provenance, SDK identity, API behavior, client
6
+ behavior, package metadata, documentation, output, shared generation options, and one or more
7
+ language targets. The materialized API source bytes, authentication, idempotency, and transport
8
+ metadata belong to the SDK Generation API request rather than the SDK Config document.
9
9
 
10
10
  ## Install
11
11
 
12
- The package is configured as a restricted package in the `@postman` npm scope.
13
-
14
12
  ```sh
15
13
  npm install @postman/sdk-config
16
14
  ```
17
15
 
18
- ## Use
19
-
20
- Use `SdkConfigV1` for customer-authored, potentially multi-target generation configuration:
16
+ Node.js 24 or newer is required. Both ESM and CommonJS are supported.
21
17
 
22
- ```ts
23
- import { parseSdkConfigV1, type SdkConfigV1 } from '@postman/sdk-config/sdk-config/v1';
24
-
25
- const sdkConfig: SdkConfigV1 = parseSdkConfigV1(untrustedInput);
26
- ```
18
+ ## Create and validate an SDK Config
27
19
 
28
- Use `SdkConfigIrV1` only for the normalized, single-target internal generator contract:
20
+ Use `validateSdkConfigV1` for a customer-authored document. Validation preserves omitted properties
21
+ so persisted configuration is not populated with runtime defaults.
29
22
 
30
23
  ```ts
31
- import { parseSdkConfigIrV1, type SdkConfigIrV1 } from '@postman/sdk-config/sdk-config-ir/v1';
32
-
33
- const sdkConfigIr: SdkConfigIrV1 = parseSdkConfigIrV1(untrustedInput);
34
- ```
35
-
36
- The package also exposes `@postman/sdk-config`, `@postman/sdk-config/sdk-config`, and
37
- `@postman/sdk-config/sdk-config-ir` as convenient current-version entry points. Persisted payloads
38
- must still include the appropriate `schemaVersion`.
39
-
40
- `SdkConfigV1` does not accept source selection, server-owned fields, `SdkConfigIrV1`, or legacy
41
- Postman `BuildParameters`. See the [SDK Config v1 reference](src/sdk-config/v1/README.md) for the
42
- boundaries and target precedence rules.
43
-
44
- Both ESM `import` and CommonJS `require` consumers are supported.
45
-
46
- ## Project layout
47
-
48
- ```text
49
- src/
50
- sdk-config-domain/
51
- v1/ # Portable field schemas shared by public config and internal IR
52
- sdk-config/
53
- v1/ # Customer-facing multi-target schema and contract reference
54
- sdk-config-ir/
55
- v1/ # Versioned schema, inferred types, and contract reference
56
- tests/
57
- fixtures/
58
- sdk-config/v1/ # Canonical public configuration payloads
59
- sdk-config-ir/v1/ # Canonical portable payloads
60
- sdk-config/v1/ # Public contract and export tests
61
- sdk-config-ir/v1/ # Contract behavior tests
62
- docs/
63
- migration.md # sdk-gen-core adoption sequence
24
+ import {
25
+ parseSdkConfigV1,
26
+ validateSdkConfigV1,
27
+ type SdkConfigV1,
28
+ type SdkConfigV1Document,
29
+ type SdkConfigV1Input,
30
+ } from '@postman/sdk-config/sdk-config/v1';
31
+
32
+ const input: SdkConfigV1Input = {
33
+ schemaVersion: 'sdk-config/v1',
34
+ sdkName: 'Example SDK',
35
+ sdkVersion: '1.0.0',
36
+ source: {
37
+ specs: [{ id: 'example', type: 'openapi', path: './openapi.yml' }],
38
+ },
39
+ api: {},
40
+ client: { timeoutMs: 30_000 },
41
+ package: {},
42
+ output: { delivery: 'zip', fileName: 'example-typescript.zip' },
43
+ docs: { includeApiReference: true },
44
+ generation: { includeWatermark: true },
45
+ targets: [
46
+ {
47
+ language: 'typescript',
48
+ generatorVersion: '1.2.3',
49
+ package: { packageName: '@example/sdk' },
50
+ generation: { packageManager: 'pnpm', testFramework: 'vitest' },
51
+ },
52
+ ],
53
+ };
54
+
55
+ const document: SdkConfigV1Document = validateSdkConfigV1(input);
56
+ const sdkConfig: SdkConfigV1 = parseSdkConfigV1(document);
64
57
  ```
65
58
 
66
- ## Develop
59
+ Use `parseSdkConfigV1` when entering the runtime boundary and materializing the shared domain
60
+ defaults. For validation without throwing, use the exported schema:
67
61
 
68
- Requires Node.js 24 or newer. If you use nvm, run `nvm use` from the repository root.
62
+ ```ts
63
+ import { sdkConfigV1Schema } from '@postman/sdk-config/sdk-config/v1';
69
64
 
70
- ```sh
71
- npm install
72
- npm run check
73
- npm pack --dry-run
65
+ const result = sdkConfigV1Schema.safeParse(input);
66
+ if (!result.success) {
67
+ console.error(result.error.issues);
68
+ }
74
69
  ```
75
70
 
76
- `npm run check` verifies formatting, linting, TypeScript, tests, and the dual-format package build.
71
+ SDK Config objects are strict. Unknown fields, duplicate language targets, incompatible package
72
+ publication settings, and non-exact generator versions are rejected.
77
73
 
78
- ## Versioning and publishing
74
+ `SdkConfigV1` accepts customer-facing local source paths and HTTP(S) source URLs, but not
75
+ server-owned signed URLs or artifact metadata. See the
76
+ [SDK Config v1 reference](src/sdk-config/v1/README.md) for source materialization and target
77
+ precedence rules.
79
78
 
80
- - npm access is `restricted`; do not set package.json `private: true`, because npm would refuse to
81
- publish it.
82
- - Additive v1 fields require a package minor version and a consumer-first rollout because v1 uses
83
- strict runtime objects: an older consumer rejects fields it does not know.
84
- - Breaking wire changes get a new schema directory and discriminator such as `sdk-config/v2` or
85
- `sdk-config-ir/v2`.
86
- - Keep the previous version exported while consumers migrate.
79
+ ## Use SDK Config in an SDK Generation API request
87
80
 
88
- ### Manual release process
81
+ An SDK Generation API request combines three kinds of data:
89
82
 
90
- Release automation is intentionally deferred while the tagging and publishing process is reviewed
91
- with Postman's security team. Until that process is established, use the following manual release
92
- procedure. The commands use `1.1.0` as an example; replace it consistently with the version being
93
- released.
83
+ 1. Request metadata describing the API input and generation targets.
84
+ 2. A source archive containing the API definition files.
85
+ 3. One SDK Config JSON payload for each request target that uses `payloadKind: "sdk-config-v1"`.
94
86
 
95
- #### 1. Prepare a release branch from develop
87
+ The payload filename must match its target ID: `<targetId>.json`.
96
88
 
97
- Normal feature pull requests target `develop`. Start the release from an up-to-date `develop`
98
- branch, update the version without creating a tag, and run the complete check suite:
99
-
100
- ```sh
101
- git switch develop
102
- git pull --ff-only origin develop
103
- git switch -c release/v1.1.0
104
- npm version 1.1.0 --no-git-tag-version
105
- npm run check
106
- git add package.json package-lock.json
107
- git commit -m "release: v1.1.0"
108
- git push -u origin release/v1.1.0
89
+ ```ts
90
+ const targetId = 'typescript-sdk';
91
+ const request = {
92
+ protocolVersion: 2,
93
+ apiName: 'Example API',
94
+ idempotencyKey: crypto.randomUUID(),
95
+ apiInputs: [{ id: 'default', specIndexes: 'all' }],
96
+ targets: [
97
+ {
98
+ targetId,
99
+ apiInputId: 'default',
100
+ language: 'typescript',
101
+ sdk: {
102
+ name: sdkConfig.sdkName,
103
+ version: sdkConfig.sdkVersion,
104
+ ...(sdkConfig.apiVersion === undefined ? {} : { apiVersion: sdkConfig.apiVersion }),
105
+ },
106
+ fernGenerator: { id: 'typescript-generator', version: '1.2.3' },
107
+ payloadKind: 'sdk-config-v1',
108
+ package: sdkConfig.targets[0]?.package,
109
+ requestedOutput: { type: 'download' },
110
+ },
111
+ ],
112
+ };
113
+
114
+ const form = new FormData();
115
+ form.append('request', JSON.stringify(request));
116
+ form.append('sources', sourceArchive, 'sources.tar.gz');
117
+ form.append(
118
+ 'payloads',
119
+ new Blob([JSON.stringify(sdkConfig)], { type: 'application/json' }),
120
+ `${targetId}.json`,
121
+ );
122
+
123
+ const response = await fetch('https://api.example.com/sdk-generations', {
124
+ method: 'POST',
125
+ headers: { Authorization: `Bearer ${accessToken}` },
126
+ body: form,
127
+ });
109
128
  ```
110
129
 
111
- Open a pull request from `release/v1.1.0` into `main`. Review the version change, wait for required
112
- checks and approvals, and merge it. The release branch isolates the version bump and preserves the
113
- exact `develop` snapshot being reviewed, while work can continue independently on `develop`.
130
+ Before submitting the request, the client resolves every SDK Config source path or URL and places
131
+ the exact bytes in the source archive. The endpoint URL, authentication scheme, source archive
132
+ format, and response shape are defined by the SDK Generation API provider.
114
133
 
115
- #### 2. Merge main back into develop
134
+ This request form supports downloaded archives. Its effective SDK Config output must be
135
+ `{ "delivery": "zip" }` without publication settings, and `requestedOutput` must be
136
+ `{ "type": "download" }`.
116
137
 
117
- The publishing workflow requires the tagged commit to be in the history of the repository's default
118
- branch, `develop`. After the release pull request is merged, create a synchronization branch from
119
- the latest `develop` and merge the released `main` into it:
138
+ ### Keep request targets consistent
120
139
 
121
- ```sh
122
- git fetch origin
123
- git switch -c chore/merge-main-after-v1.1.0 origin/develop
124
- git merge --no-ff origin/main -m "Merge main back to develop after v1.1.0"
125
- git push -u origin chore/merge-main-after-v1.1.0
126
- ```
140
+ For each request target, the API request and matching SDK Config target must agree on:
127
141
 
128
- Open a pull request from `chore/merge-main-after-v1.1.0` into `develop`, wait for its checks, and use
129
- **Create a merge commit** to merge it. Do not squash or rebase this pull request: the original
130
- `main` commit must remain in `develop`'s ancestry for the publishing workflow's validation. The
131
- temporary branch can then be deleted safely.
142
+ - `language`
143
+ - effective SDK name and version
144
+ - API version, when present
145
+ - generator version, when `generatorVersion` is present in SDK Config
146
+ - every package property included in the API request; the request may omit package properties
147
+ - ZIP output without publication settings, paired with a download request
132
148
 
133
- #### 3. Create the release tag from main
149
+ Root package properties are inherited by each target and overridden by target package properties.
150
+ A target output replaces the root output; it is not merged with it.
134
151
 
135
- After the synchronization pull request is merged, update your local `main` and verify that
136
- `package.json` contains the version you are about to tag:
152
+ ## Generation file paths
137
153
 
138
- ```sh
139
- git switch main
140
- git pull --ff-only origin main
141
- node -p "require('./package.json').version"
142
- ```
154
+ These SDK Config values are interpreted as file paths during generation:
143
155
 
144
- Create the signed tag and dispatch the **Package Release** workflow with the tag as its explicit
145
- input:
156
+ - `source.specs[].path`
157
+ - `source.specs[].overlays[]`
158
+ - `source.specs[].overrides[]`
159
+ - `generation.customQueryPaths[]`
160
+ - `generation.workflows[].path`
161
+ - `generation.hooks.source.location` when `source.type` is `path`
162
+ - `generation.customCode.source.location` when `source.type` is `path`
146
163
 
147
- ```sh
148
- npm run release -- v1.1.0
149
- ```
164
+ Each value must be a relative path and cannot contain a `..` path segment. Absolute POSIX paths,
165
+ Windows drive paths, UNC paths, and parent-directory traversal are rejected during validation. URL
166
+ source locations are not treated as file paths.
167
+
168
+ ## Multiple targets
150
169
 
151
- The release script requires a clean, up-to-date `main`, verifies that the package version matches
152
- the tag and that the commit is already contained in `main` and `develop`, creates and verifies a
153
- signed, annotated tag, pushes it, and dispatches `.github/workflows/npm-publish.yml` with
154
- `tag=v1.1.0`. The workflow independently rechecks `main` ancestry before calling the shared
155
- publisher, which verifies `develop` ancestry and the tag signature. Explicit dispatch avoids
156
- duplicate publish runs and keeps retries tied to the immutable tag. In GitHub, open **Actions** →
157
- **Package Release** and confirm the dispatched run succeeds.
170
+ An SDK Config can describe several language targets. Shared `api`, `client`, `docs`, and generation
171
+ settings apply to every target. SDK identity, client settings, documentation, package metadata,
172
+ output, common generation settings, and language-specific generation settings can be overridden per
173
+ target.
158
174
 
159
- If publishing fails after the tag has been created, do not delete, move, or recreate the tag. After
160
- the underlying problem is fixed, run the same command again. The script verifies and reuses the
161
- existing tag before dispatching another run. You can also use **Actions** → **Package Release** →
162
- **Run workflow** and enter the existing tag, such as `v1.1.0`.
175
+ Each language can appear only once. When sending a multi-target SDK Config to an SDK Generation API,
176
+ attach the config under each request target that should select its matching language configuration.
163
177
 
164
- See the [SDK Config IR v1 reference](src/sdk-config-ir/v1/README.md) for the complete contract.
178
+ Supported target languages are `typescript`, `python`, `java`, `kotlin`, `go`, `csharp`, `php`,
179
+ `ruby`, `rust`, `swift`, `cli`, `mcp`, and `terraform`.