@postman/sdk-config 0.0.4 → 0.1.1

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