@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.
- package/README.md +139 -124
- package/dist/index.cjs +301 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +292 -150
- package/dist/index.js.map +1 -1
- package/dist/sdk-config/index.cjs +290 -113
- package/dist/sdk-config/index.cjs.map +1 -1
- package/dist/sdk-config/index.d.cts +2 -2
- package/dist/sdk-config/index.d.ts +2 -2
- package/dist/sdk-config/index.js +284 -114
- package/dist/sdk-config/index.js.map +1 -1
- package/dist/sdk-config/v1/index.cjs +290 -113
- package/dist/sdk-config/v1/index.cjs.map +1 -1
- package/dist/sdk-config/v1/index.d.cts +6903 -289
- package/dist/sdk-config/v1/index.d.ts +6903 -289
- package/dist/sdk-config/v1/index.js +284 -114
- package/dist/sdk-config/v1/index.js.map +1 -1
- package/dist/sdk-config-ir/index.cjs +71 -31
- package/dist/sdk-config-ir/index.cjs.map +1 -1
- package/dist/sdk-config-ir/index.d.cts +2 -2
- package/dist/sdk-config-ir/index.d.ts +2 -2
- package/dist/sdk-config-ir/index.js +69 -32
- package/dist/sdk-config-ir/index.js.map +1 -1
- package/dist/sdk-config-ir/v1/index.cjs +71 -31
- package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
- package/dist/sdk-config-ir/v1/index.d.cts +130 -43
- package/dist/sdk-config-ir/v1/index.d.ts +130 -43
- package/dist/sdk-config-ir/v1/index.js +69 -32
- package/dist/sdk-config-ir/v1/index.js.map +1 -1
- package/dist/{typescript-ByDbin_v.d.cts → typescript-DNqK3T3v.d.cts} +5 -1
- package/dist/{typescript-ByDbin_v.d.ts → typescript-DNqK3T3v.d.ts} +5 -1
- package/docs/releasing.md +114 -0
- package/package.json +2 -2
- package/src/sdk-config/v1/README.md +91 -23
- 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
|
-
|
|
4
|
-
pipeline.
|
|
3
|
+
Build and validate SDK Config documents for SDK Generation API requests.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 `
|
|
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 {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
+
```ts
|
|
63
|
+
import { sdkConfigV1Schema } from '@postman/sdk-config/sdk-config/v1';
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
const result = sdkConfigV1Schema.safeParse(input);
|
|
66
|
+
if (!result.success) {
|
|
67
|
+
console.error(result.error.issues);
|
|
68
|
+
}
|
|
74
69
|
```
|
|
75
70
|
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
+
An SDK Generation API request combines three kinds of data:
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
87
|
+
The payload filename must match its target ID: `<targetId>.json`.
|
|
96
88
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
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
|
-
|
|
136
|
-
`package.json` contains the version you are about to tag:
|
|
152
|
+
## Generation file paths
|
|
137
153
|
|
|
138
|
-
|
|
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
|
-
|
|
145
|
-
|
|
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
|
-
|
|
148
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
160
|
-
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
|
-
|
|
178
|
+
Supported target languages are `typescript`, `python`, `java`, `kotlin`, `go`, `csharp`, `php`,
|
|
179
|
+
`ruby`, `rust`, `swift`, `cli`, `mcp`, and `terraform`.
|