@postman-cse/onboarding-bootstrap 0.11.0 → 0.12.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/LICENSE +21 -0
- package/README.md +101 -10
- package/action.yml +18 -2
- package/dist/cli.cjs +34450 -2318
- package/dist/index.cjs +34330 -2276
- package/package.json +22 -3
- package/.github/actionlint.yaml +0 -2
- package/.github/workflows/ci.yml +0 -36
- package/.github/workflows/contract-smoke.yml +0 -155
- package/.github/workflows/release.yml +0 -62
- package/.omc/sessions/b36ac16d-ce26-4e94-ae7e-dd817f2430a3.json +0 -8
- package/CLAUDE.md +0 -57
- package/src/cli.ts +0 -281
- package/src/contracts.ts +0 -172
- package/src/index.ts +0 -1150
- package/src/lib/github/github-api-client.ts +0 -262
- package/src/lib/http-error.ts +0 -80
- package/src/lib/postman/internal-integration-adapter.ts +0 -358
- package/src/lib/postman/postman-assets-client.ts +0 -786
- package/src/lib/postman/workspace-selection.ts +0 -121
- package/src/lib/repo/context.ts +0 -119
- package/src/lib/retry.ts +0 -79
- package/src/lib/secrets.ts +0 -104
- package/tests/bootstrap-action.test.ts +0 -1301
- package/tests/cli.test.ts +0 -153
- package/tests/contract.test.ts +0 -131
- package/tests/github-api-client.test.ts +0 -91
- package/tests/internal-integration-adapter.test.ts +0 -313
- package/tests/postman-assets-client.test.ts +0 -268
- package/tests/retry.test.ts +0 -54
- package/tests/secrets.test.ts +0 -66
- package/tests/workspace-selection.test.ts +0 -301
- package/tmp/cli-run-result.json +0 -11
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Postman, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -32,6 +32,21 @@ Lifecycle behavior remains backward-compatible except for collection default mod
|
|
|
32
32
|
|
|
33
33
|
If you do not set those inputs, the action refreshes collection pointers from the resolved spec and keeps one canonical spec update path.
|
|
34
34
|
|
|
35
|
+
### Bootstrap phase independence
|
|
36
|
+
|
|
37
|
+
**Bootstrap succeeds independently** — it creates or updates Postman workspace and collections even if a later stage (repo sync, Insights onboarding) fails. This is intentional:
|
|
38
|
+
|
|
39
|
+
- **Postman side is self-contained:** Workspace creation, spec upload, and collection generation do not depend on repository access or merge status.
|
|
40
|
+
- **Repository side is async:** Later stages may fail due to repo permissions, branch protection, or pending approval. Bootstrap completion is not blocked by these downstream concerns.
|
|
41
|
+
- **Idempotent reruns:** If a later stage fails, subsequent reruns of the action will reuse existing Postman assets (via `workspace-id`, `spec-id`, collection IDs) and focus on the failed stage without recreating everything.
|
|
42
|
+
|
|
43
|
+
**When bootstrap fails:** The action stops and does not proceed to repo sync. Postman assets are left in the state they reached before the failure. Clear error messages identify which required bootstrap step failed (for example, spec lint or collection generation). Optional workspace enrichment steps, such as governance assignment and requester invitation, warn and continue so created workspaces and collections remain usable.
|
|
44
|
+
|
|
45
|
+
This layered design means customers can:
|
|
46
|
+
1. Verify Postman workspace health independently.
|
|
47
|
+
2. Debug repository issues (branch protection, permissions) separately from Postman provisioning.
|
|
48
|
+
3. Reuse existing Postman assets when fixing downstream failures.
|
|
49
|
+
|
|
35
50
|
### Team ID derivation
|
|
36
51
|
|
|
37
52
|
The action automatically derives the Postman Team ID from your `postman-api-key` via the `/me` API. There is no need to supply a separate team ID input. If the environment variable `POSTMAN_TEAM_ID` is set, that value takes precedence.
|
|
@@ -81,6 +96,10 @@ Before upload to Spec Hub, the action parses JSON or YAML OpenAPI documents and
|
|
|
81
96
|
|
|
82
97
|
This runs in `src/index.ts` before upload. If nothing under `paths` needs changing, the original document bytes are preserved. When normalization runs, the spec is re-serialized (JSON stays JSON; YAML stays YAML). Each fix emits a **warning** in the Actions log so you can improve the source spec over time. Invalid documents that cannot be parsed are left unchanged and a warning is logged.
|
|
83
98
|
|
|
99
|
+
### OpenAPI spec URL fetch safety
|
|
100
|
+
|
|
101
|
+
The root `spec-url` must be HTTPS and is fetched with pinned DNS resolution. The action blocks credential-bearing URLs, localhost/private/link-local/internal destinations, unsafe redirects, DNS rebinding attempts, and oversized OpenAPI resources before uploading content to Spec Hub. Root fetches are capped at 25 MiB, and fetch errors redact URL credentials, query strings, and fragments before logging.
|
|
102
|
+
|
|
84
103
|
## Usage
|
|
85
104
|
|
|
86
105
|
```yaml
|
|
@@ -122,6 +141,76 @@ jobs:
|
|
|
122
141
|
|
|
123
142
|
If you want the action to discover prior bootstrap state automatically on reruns, commit `.postman/resources.yaml` and run the action on the ref whose state you want to reuse.
|
|
124
143
|
|
|
144
|
+
## Dynamic contract tests
|
|
145
|
+
|
|
146
|
+
Dynamic contract tests harden the generated `[Contract]` collection against the resolved OpenAPI 3.0/3.1 document before any durable contract collection is overwritten.
|
|
147
|
+
|
|
148
|
+
Scope:
|
|
149
|
+
|
|
150
|
+
- Safely fetch and bundle HTTPS OpenAPI specs and HTTPS external refs.
|
|
151
|
+
- Validate the bundled OpenAPI document with external and file resolution disabled during validation.
|
|
152
|
+
- Match generated collection requests by method and canonical server/path candidates only; suffix path matching is not used.
|
|
153
|
+
- Require one generated request for every eligible `paths` operation.
|
|
154
|
+
- Validate response status codes, body presence, `Content-Type`, JSON response schemas, text/string schemas, and simple response header schemas.
|
|
155
|
+
- Perform static checks for required non-security query/header parameters and required request bodies.
|
|
156
|
+
|
|
157
|
+
Non-goals and limitations:
|
|
158
|
+
|
|
159
|
+
- Swagger 2.0, OAS webhooks, callbacks, and arbitrary user-authored collection requests are not fully validated.
|
|
160
|
+
- Security/auth requirements are not proven at runtime. API-key parameters derived from `securitySchemes` are warned as `CONTRACT_SECURITY_NOT_VALIDATED`.
|
|
161
|
+
- Complex non-JSON object schemas, header `content`, unsupported schema dialects, unsupported keywords, and discriminator-heavy schemas fail closed instead of generating weak tests.
|
|
162
|
+
- Generated scripts target Newman/Postman runtime support for ES2020-compatible JavaScript and use compiled schemasafe IIFE validators. They do not use `pm.response.to.have.jsonSchema`, `eval`, or `new Function`.
|
|
163
|
+
|
|
164
|
+
OpenAPI semantics:
|
|
165
|
+
|
|
166
|
+
- OAS 3.0 `$ref` siblings are ignored, `nullable` is converted to JSON Schema unions, boolean exclusive min/max is converted, and response `writeOnly` properties are removed from response validation.
|
|
167
|
+
- OAS 3.1 `$ref` siblings are applied, the default dialect is JSON Schema 2020-12, supported `$schema` values are preserved, and unsupported custom dialects fail closed.
|
|
168
|
+
|
|
169
|
+
Security and size limits:
|
|
170
|
+
|
|
171
|
+
- Only HTTPS spec URLs and external refs are allowed.
|
|
172
|
+
- Localhost, loopback, link-local, RFC1918, RFC6598, IANA special-use IPv4/IPv6 ranges, IPv4-mapped IPv6, `.local`, and `.internal` destinations are blocked.
|
|
173
|
+
- DNS results are vetted and pinned into the HTTPS socket; redirects are fully revalidated.
|
|
174
|
+
- Limits: 5 redirects, 100 external refs, ref depth 20, 25 MiB per fetched resource, and 25 MiB total fetched bytes.
|
|
175
|
+
- Generated request scripts warn above 256 KiB and fail above 900 KiB; instrumented contract collection uploads fail above 4 MiB before upload. The bundled action is also reviewed for dependency-driven size growth.
|
|
176
|
+
|
|
177
|
+
Rollback behavior:
|
|
178
|
+
|
|
179
|
+
- Spec preflight runs before Postman mutations.
|
|
180
|
+
- For existing spec updates, the previous normalized spec content is fetched and hashed before update.
|
|
181
|
+
- If linting, collection generation, instrumentation, tagging, or linking fails after an existing spec update, the action best-effort restores the previous spec content.
|
|
182
|
+
- If rollback fails, the action emits `CONTRACT_SPEC_ROLLBACK_FAILED` with the previous content SHA-256 for manual restoration.
|
|
183
|
+
- Refresh mode stages generated baseline, smoke, and contract collections and instruments the temporary contract collection before updating any durable tracked collection. If a durable refresh update fails after another durable collection was updated, the action best-effort restores previously updated collection snapshots. Collection mutations after the refresh stage, such as later tagging/linking side effects, are not automatically rolled back; rerun the action after resolving the failure to reconcile generated collections with the restored spec.
|
|
184
|
+
|
|
185
|
+
| Error code | Meaning | Remediation |
|
|
186
|
+
| --- | --- | --- |
|
|
187
|
+
| `CONTRACT_SPEC_FETCH_BLOCKED` | Spec URL, ref URL, DNS result, redirect, or socket destination was not allowed. | Use public HTTPS spec/ref URLs that do not resolve to private or local networks. |
|
|
188
|
+
| `CONTRACT_SPEC_FETCH_FAILED` | Allowed HTTPS fetch failed or redirected too many times. | Check availability, status codes, and redirect chains. |
|
|
189
|
+
| `CONTRACT_REF_LIMIT_EXCEEDED` | External ref count exceeded the configured limit. | Reduce external ref fan-out or bundle the spec upstream. |
|
|
190
|
+
| `CONTRACT_REF_DEPTH_EXCEEDED` | Ref nesting exceeded the configured limit. | Flatten recursive/deep ref chains. |
|
|
191
|
+
| `CONTRACT_REF_SIZE_EXCEEDED` | A fetched resource or total fetched bytes exceeded limits. | Reduce spec/ref size or pre-bundle the document. |
|
|
192
|
+
| `CONTRACT_SPEC_PARSE_FAILED` | The fetched document was not valid JSON/YAML object content. | Fix the source document syntax. |
|
|
193
|
+
| `CONTRACT_SPEC_VALIDATION_FAILED` | The bundled document failed OpenAPI validation. | Fix OpenAPI validation errors. |
|
|
194
|
+
| `CONTRACT_UNSUPPORTED_OPENAPI_VERSION` | The document was not OpenAPI 3.0 or 3.1. | Provide an OpenAPI 3.0/3.1 document. |
|
|
195
|
+
| `CONTRACT_NO_ELIGIBLE_OPERATIONS` | No eligible `paths` operations with responses were found. | Add path operations with responses. |
|
|
196
|
+
| `CONTRACT_OPERATION_NO_RESPONSES` | A `paths` operation had no response definitions. | Add at least one OpenAPI response to each path operation. |
|
|
197
|
+
| `CONTRACT_UNRESOLVED_REF` | A ref remained unresolved after secure bundling. | Fix the ref target or make the external ref HTTPS-accessible. |
|
|
198
|
+
| `CONTRACT_UNSUPPORTED_SCHEMA_DIALECT` | A schema declared an unsupported JSON Schema dialect. | Use draft-07 or 2020-12-compatible schemas. |
|
|
199
|
+
| `CONTRACT_SCHEMA_COMPILE_FAILED` | schemasafe could not compile a response/header schema. | Simplify or correct the unsupported schema. |
|
|
200
|
+
| `CONTRACT_STATIC_REQUEST_CHECK_FAILED` | Generated request missed a required non-security parameter or body. | Adjust generation options or the spec so generated requests include required shape. |
|
|
201
|
+
| `CONTRACT_SECURITY_NOT_VALIDATED` | Security requirements were detected but dynamic tests cannot prove auth at runtime. | Run dedicated auth tests and review generated requests for required credentials. |
|
|
202
|
+
| `CONTRACT_WEBHOOKS_NOT_VALIDATED` | OpenAPI webhooks were present but are not included in dynamic contract coverage. | Validate webhook behavior separately or model required behavior under `paths`. |
|
|
203
|
+
| `CONTRACT_CALLBACKS_NOT_VALIDATED` | Operation callbacks were present but are not included in dynamic contract coverage. | Validate callback behavior separately or add dedicated tests. |
|
|
204
|
+
| `CONTRACT_DUPLICATE_OPERATION_MATCH` | Multiple OpenAPI operations share the same canonical request mapping candidate. | Disambiguate paths, server prefixes, or templated routes. |
|
|
205
|
+
| `CONTRACT_DUPLICATE_OPERATION_REQUEST` | More than one generated request mapped to the same contract operation. | Disambiguate paths/operations or generated requests. |
|
|
206
|
+
| `CONTRACT_OPERATION_COVERAGE_FAILED` | Generated contract collection did not cover every eligible operation. | Regenerate the collection or fix operation paths. |
|
|
207
|
+
| `CONTRACT_FORBIDDEN_SCRIPT_CONSTRUCT` | Generated script included a forbidden dynamic validation construct. | Report the schema that triggered unsafe generation. |
|
|
208
|
+
| `CONTRACT_SCRIPT_SIZE_EXCEEDED` | A generated request test script exceeded the per-script size gate. | Reduce schema complexity or split the API. |
|
|
209
|
+
| `CONTRACT_COLLECTION_SIZE_EXCEEDED` | Instrumented contract collection exceeded the size gate. | Reduce schema/operation count or split the API. |
|
|
210
|
+
| `CONTRACT_COLLECTION_ID_COLLISION` | Baseline, smoke, and contract IDs were not pairwise distinct. | Pass distinct collection IDs or clear stale IDs. |
|
|
211
|
+
| `CONTRACT_PLAN_MISSING` | Contract instrumentation ran without a preflight-generated contract plan. | Rerun with dynamic contract preflight enabled and report the failure if it persists. |
|
|
212
|
+
| `CONTRACT_SPEC_ROLLBACK_FAILED` | Best-effort previous spec restoration failed after a later error. | Restore the previous spec content manually using the emitted SHA-256. |
|
|
213
|
+
|
|
125
214
|
## CLI Usage (Non-GitHub CI)
|
|
126
215
|
|
|
127
216
|
The CLI is available for GitLab CI, Bitbucket Pipelines, Azure DevOps, and other CI systems.
|
|
@@ -130,9 +219,11 @@ GitHub Actions users should continue using the `action.yml` interface.
|
|
|
130
219
|
Install globally:
|
|
131
220
|
|
|
132
221
|
```bash
|
|
133
|
-
npm install -g postman-bootstrap
|
|
222
|
+
npm install -g @postman-cse/onboarding-bootstrap
|
|
134
223
|
```
|
|
135
224
|
|
|
225
|
+
The CLI package supports Node.js 20+. The examples below use Node.js 24 to match the GitHub Action runtime.
|
|
226
|
+
|
|
136
227
|
Basic usage:
|
|
137
228
|
|
|
138
229
|
```bash
|
|
@@ -153,9 +244,9 @@ Example GitLab CI job:
|
|
|
153
244
|
|
|
154
245
|
```yaml
|
|
155
246
|
bootstrap:
|
|
156
|
-
image: node:
|
|
247
|
+
image: node:24
|
|
157
248
|
script:
|
|
158
|
-
- npm install -g postman-bootstrap
|
|
249
|
+
- npm install -g @postman-cse/onboarding-bootstrap
|
|
159
250
|
- postman-bootstrap --project-name core-payments --spec-url "$SPEC_URL" --postman-api-key "$POSTMAN_API_KEY" --postman-access-token "$POSTMAN_ACCESS_TOKEN" --result-json bootstrap-result.json --dotenv-path bootstrap.env
|
|
160
251
|
artifacts:
|
|
161
252
|
paths:
|
|
@@ -169,9 +260,9 @@ Example Bitbucket Pipelines step:
|
|
|
169
260
|
pipelines:
|
|
170
261
|
default:
|
|
171
262
|
- step:
|
|
172
|
-
image: node:
|
|
263
|
+
image: node:24
|
|
173
264
|
script:
|
|
174
|
-
- npm install -g postman-bootstrap
|
|
265
|
+
- npm install -g @postman-cse/onboarding-bootstrap
|
|
175
266
|
- postman-bootstrap --project-name core-payments --spec-url "$SPEC_URL" --postman-api-key "$POSTMAN_API_KEY" --postman-access-token "$POSTMAN_ACCESS_TOKEN" --result-json bootstrap-result.json --dotenv-path bootstrap.env
|
|
176
267
|
artifacts:
|
|
177
268
|
- bootstrap-result.json
|
|
@@ -184,9 +275,9 @@ Example Azure DevOps job:
|
|
|
184
275
|
steps:
|
|
185
276
|
- task: NodeTool@0
|
|
186
277
|
inputs:
|
|
187
|
-
versionSpec: '
|
|
278
|
+
versionSpec: '24.x'
|
|
188
279
|
- script: |
|
|
189
|
-
npm install -g postman-bootstrap
|
|
280
|
+
npm install -g @postman-cse/onboarding-bootstrap
|
|
190
281
|
postman-bootstrap --project-name core-payments --spec-url "$(SPEC_URL)" --postman-api-key "$(POSTMAN_API_KEY)" --postman-access-token "$(POSTMAN_ACCESS_TOKEN)" --result-json bootstrap-result.json --dotenv-path bootstrap.env
|
|
191
282
|
displayName: Bootstrap Postman assets
|
|
192
283
|
- publish: bootstrap-result.json
|
|
@@ -203,7 +294,7 @@ steps:
|
|
|
203
294
|
| `smoke-collection-id` | | Reuse an existing smoke collection. |
|
|
204
295
|
| `contract-collection-id` | | Reuse an existing contract collection. |
|
|
205
296
|
| `sync-examples` | `true` | Whether linked spec/collection relations should enable example syncing during cloud linkage. |
|
|
206
|
-
| `collection-sync-mode` | `refresh` | Collection lifecycle policy. `
|
|
297
|
+
| `collection-sync-mode` | `refresh` | Collection lifecycle policy. `refresh` keeps the tracked collection IDs while updating them from the latest spec, and `version` creates or reuses release-scoped collections. |
|
|
207
298
|
| `spec-sync-mode` | `update` | Spec lifecycle policy. `update` keeps one canonical spec current in Spec Hub, while `version` creates or reuses a release-scoped spec asset. |
|
|
208
299
|
| `release-label` | | Optional release label used for versioned specs and collections. When omitted for versioned sync, the action derives one from GitHub tag or branch metadata. |
|
|
209
300
|
| `project-name` | | Service name used in workspace and asset naming. |
|
|
@@ -222,7 +313,7 @@ steps:
|
|
|
222
313
|
|
|
223
314
|
### Collection sync
|
|
224
315
|
|
|
225
|
-
- `reuse`: existing collection IDs are reused when available.
|
|
316
|
+
- `reuse`: legacy alias for `refresh`; existing collection IDs are reused when available and updated from the resolved spec.
|
|
226
317
|
- `refresh`: baseline, smoke, and contract collections are regenerated from the resolved spec and become the current/default collection pointers.
|
|
227
318
|
- `version`: a release-scoped collection set is created or reused from the checked-out ref's state when available.
|
|
228
319
|
|
|
@@ -245,7 +336,7 @@ If versioned sync is requested and no usable label can be derived, the run fails
|
|
|
245
336
|
|
|
246
337
|
Current Postman asset state lives in `.postman/resources.yaml`.
|
|
247
338
|
|
|
248
|
-
- `update` and `reuse` modes resolve current-state mappings from the checked-out ref.
|
|
339
|
+
- `update`, `refresh`, and legacy `reuse` modes resolve current-state mappings from the checked-out ref.
|
|
249
340
|
- `version` mode reuses only the checked-out ref's mappings; release history lives in git history and tags, not in a separate manifest file or repository variables.
|
|
250
341
|
|
|
251
342
|
### Cloud spec-to-collection syncing
|
package/action.yml
CHANGED
|
@@ -22,7 +22,7 @@ inputs:
|
|
|
22
22
|
required: false
|
|
23
23
|
default: 'true'
|
|
24
24
|
collection-sync-mode:
|
|
25
|
-
description: Collection lifecycle policy (
|
|
25
|
+
description: Collection lifecycle policy (refresh or version)
|
|
26
26
|
required: false
|
|
27
27
|
default: refresh
|
|
28
28
|
spec-sync-mode:
|
|
@@ -56,6 +56,10 @@ inputs:
|
|
|
56
56
|
spec-url:
|
|
57
57
|
description: URL to the OpenAPI document to bootstrap
|
|
58
58
|
required: true
|
|
59
|
+
openapi-version:
|
|
60
|
+
description: OpenAPI specification version override (3.0 or 3.1). When not set, the version is auto-detected from the spec content.
|
|
61
|
+
required: false
|
|
62
|
+
default: ''
|
|
59
63
|
governance-mapping-json:
|
|
60
64
|
description: JSON map of business domain to governance group name
|
|
61
65
|
required: false
|
|
@@ -70,6 +74,18 @@ inputs:
|
|
|
70
74
|
description: Integration backend for downstream workspace connectivity
|
|
71
75
|
required: false
|
|
72
76
|
default: bifrost
|
|
77
|
+
folder-strategy:
|
|
78
|
+
description: Folder organization strategy for generated collections (Paths or Tags)
|
|
79
|
+
required: false
|
|
80
|
+
default: Paths
|
|
81
|
+
nested-folder-hierarchy:
|
|
82
|
+
description: When folder-strategy is Tags, enables nested folder hierarchy
|
|
83
|
+
required: false
|
|
84
|
+
default: 'false'
|
|
85
|
+
request-name-source:
|
|
86
|
+
description: Determines how requests are named in generated collections (Fallback or URL)
|
|
87
|
+
required: false
|
|
88
|
+
default: Fallback
|
|
73
89
|
outputs:
|
|
74
90
|
workspace-id:
|
|
75
91
|
description: Postman workspace ID
|
|
@@ -90,5 +106,5 @@ outputs:
|
|
|
90
106
|
lint-summary-json:
|
|
91
107
|
description: JSON summary of lint errors and warnings
|
|
92
108
|
runs:
|
|
93
|
-
using:
|
|
109
|
+
using: node24
|
|
94
110
|
main: dist/index.cjs
|