@postman-cse/onboarding-bootstrap 0.9.1 → 0.10.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/.github/workflows/contract-smoke.yml +155 -0
- package/.omc/sessions/b36ac16d-ce26-4e94-ae7e-dd817f2430a3.json +8 -0
- package/CLAUDE.md +57 -0
- package/README.md +124 -12
- package/action.yml +17 -18
- package/dist/cli.cjs +231 -489
- package/dist/index.cjs +226 -480
- package/package.json +3 -2
- package/src/cli.ts +5 -11
- package/src/contracts.ts +24 -24
- package/src/index.ts +253 -323
- package/src/lib/postman/postman-assets-client.ts +27 -4
- package/tests/bootstrap-action.test.ts +565 -79
- package/tests/cli.test.ts +12 -6
- package/tests/contract.test.ts +20 -3
- package/tests/postman-assets-client.test.ts +153 -0
|
@@ -110,6 +110,21 @@ export class PostmanAssetsClient {
|
|
|
110
110
|
return undefined;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
async getTeams(): Promise<Array<{ id: number; name: string; handle: string; organizationId?: number }>> {
|
|
114
|
+
const data = await this.request('/teams');
|
|
115
|
+
const teams = data?.data ?? [];
|
|
116
|
+
return Array.isArray(teams)
|
|
117
|
+
? teams
|
|
118
|
+
.filter((t: any) => t?.id && t?.name)
|
|
119
|
+
.map((t: any) => ({
|
|
120
|
+
id: Number(t.id),
|
|
121
|
+
name: String(t.name),
|
|
122
|
+
handle: String(t.handle || ''),
|
|
123
|
+
...(t.organizationId != null ? { organizationId: Number(t.organizationId) } : {})
|
|
124
|
+
}))
|
|
125
|
+
: [];
|
|
126
|
+
}
|
|
127
|
+
|
|
113
128
|
private async request(
|
|
114
129
|
path: string,
|
|
115
130
|
init: RequestInit = {}
|
|
@@ -144,13 +159,14 @@ export class PostmanAssetsClient {
|
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
161
|
|
|
147
|
-
async createWorkspace(name: string, about: string): Promise<{ id: string }> {
|
|
162
|
+
async createWorkspace(name: string, about: string, targetTeamId?: number): Promise<{ id: string }> {
|
|
148
163
|
return retry(async () => {
|
|
149
164
|
const payload = {
|
|
150
165
|
workspace: {
|
|
151
166
|
about,
|
|
152
167
|
name,
|
|
153
|
-
type: 'team'
|
|
168
|
+
type: 'team',
|
|
169
|
+
...(targetTeamId != null && !Number.isNaN(targetTeamId) ? { teamId: targetTeamId } : {})
|
|
154
170
|
}
|
|
155
171
|
};
|
|
156
172
|
let created: FetchResult;
|
|
@@ -162,7 +178,9 @@ export class PostmanAssetsClient {
|
|
|
162
178
|
} catch (err) {
|
|
163
179
|
if (err instanceof Error && err.message.includes('Only personal workspaces')) {
|
|
164
180
|
throw new Error(
|
|
165
|
-
'Workspace creation failed:
|
|
181
|
+
'Workspace creation failed: This may be an Org-mode account that requires a workspace-team-id input. ' +
|
|
182
|
+
'The Postman API does not allow creating team workspaces at the organization level. ' +
|
|
183
|
+
'Use the workspace-team-id input to specify which sub-team should own this workspace.'
|
|
166
184
|
);
|
|
167
185
|
}
|
|
168
186
|
throw err;
|
|
@@ -184,7 +202,12 @@ export class PostmanAssetsClient {
|
|
|
184
202
|
return {
|
|
185
203
|
id: workspaceId
|
|
186
204
|
};
|
|
187
|
-
}, {
|
|
205
|
+
}, {
|
|
206
|
+
maxAttempts: 3,
|
|
207
|
+
delayMs: 2000,
|
|
208
|
+
shouldRetry: (err) =>
|
|
209
|
+
!(err instanceof Error && err.message.includes('workspace-team-id'))
|
|
210
|
+
});
|
|
188
211
|
}
|
|
189
212
|
|
|
190
213
|
async listWorkspaces(): Promise<Array<{ id: string; name: string; type: string }>> {
|