@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.
- package/README.md +124 -101
- package/dist/index.cjs +2119 -282
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2080 -283
- package/dist/index.js.map +1 -1
- package/dist/sdk-config/index.cjs +2238 -0
- package/dist/sdk-config/index.cjs.map +1 -0
- package/dist/sdk-config/index.d.cts +3 -0
- package/dist/sdk-config/index.d.ts +3 -0
- package/dist/sdk-config/index.js +2196 -0
- package/dist/sdk-config/index.js.map +1 -0
- package/dist/sdk-config/v1/index.cjs +2238 -0
- package/dist/sdk-config/v1/index.cjs.map +1 -0
- package/dist/sdk-config/v1/index.d.cts +8644 -0
- package/dist/sdk-config/v1/index.d.ts +8644 -0
- package/dist/sdk-config/v1/index.js +2196 -0
- package/dist/sdk-config/v1/index.js.map +1 -0
- package/dist/sdk-config-ir/index.cjs +160 -25
- package/dist/sdk-config-ir/index.cjs.map +1 -1
- package/dist/sdk-config-ir/index.d.cts +2 -1
- package/dist/sdk-config-ir/index.d.ts +2 -1
- package/dist/sdk-config-ir/index.js +158 -26
- package/dist/sdk-config-ir/index.js.map +1 -1
- package/dist/sdk-config-ir/v1/index.cjs +160 -25
- package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
- package/dist/sdk-config-ir/v1/index.d.cts +458 -428
- package/dist/sdk-config-ir/v1/index.d.ts +458 -428
- package/dist/sdk-config-ir/v1/index.js +158 -26
- package/dist/sdk-config-ir/v1/index.js.map +1 -1
- package/dist/typescript-DK97815_.d.cts +427 -0
- package/dist/typescript-DK97815_.d.ts +427 -0
- package/package.json +16 -3
- package/src/sdk-config/v1/README.md +135 -0
- 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
|
-
|
|
3
|
+
Build and validate SDK Config documents for SDK Generation API requests.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
28
|
-
current-version entry points. Persisted payloads must still include `schemaVersion`.
|
|
18
|
+
## Create and validate an SDK Config
|
|
29
19
|
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
53
|
+
For validation without throwing, use the exported schema:
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
```ts
|
|
56
|
+
import { sdkConfigV1Schema } from '@postman/sdk-config/sdk-config/v1';
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
const result = sdkConfigV1Schema.safeParse(input);
|
|
59
|
+
if (!result.success) {
|
|
60
|
+
console.error(result.error.issues);
|
|
61
|
+
}
|
|
54
62
|
```
|
|
55
63
|
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
+
An SDK Generation API request combines three kinds of data:
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
+
The payload filename must match its target ID: `<targetId>.json`.
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
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
|
-
|
|
115
|
-
`package.json` contains the version you are about to tag:
|
|
139
|
+
## Generation file paths
|
|
116
140
|
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
136
|
-
the
|
|
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
|
-
|
|
161
|
+
Supported target languages are `typescript`, `python`, `java`, `kotlin`, `go`, `csharp`, `php`,
|
|
162
|
+
`ruby`, `rust`, `swift`, `cli`, `mcp`, and `terraform`.
|