@postman-cse/onboarding-bootstrap 2.9.9 → 2.9.10

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/dist/action.cjs CHANGED
@@ -258936,6 +258936,87 @@ var BifrostInternalIntegrationAdapter = class _BifrostInternalIntegrationAdapter
258936
258936
  const advised = adviseFromHttpError(httpErr, this.adviceContext("workspace repository linking"));
258937
258937
  throw advised ?? httpErr;
258938
258938
  }
258939
+ async findWorkspaceForRepo(repoUrl, path10 = "/") {
258940
+ const encodedRepo = encodeURIComponent(repoUrl);
258941
+ const encodedPath = encodeURIComponent(path10);
258942
+ const requestPath2 = `/workspaces/filesystem?repo=${encodedRepo}&path=${encodedPath}`;
258943
+ let response;
258944
+ try {
258945
+ response = await this.proxyRequest("workspaces", "GET", requestPath2);
258946
+ } catch (error2) {
258947
+ return {
258948
+ state: "unknown",
258949
+ reason: error2 instanceof Error ? error2.message : String(error2)
258950
+ };
258951
+ }
258952
+ let bodyText;
258953
+ try {
258954
+ bodyText = await response.text();
258955
+ } catch (error2) {
258956
+ return {
258957
+ state: "unknown",
258958
+ reason: error2 instanceof Error ? error2.message : String(error2)
258959
+ };
258960
+ }
258961
+ let parsed = null;
258962
+ if (bodyText.trim()) {
258963
+ try {
258964
+ parsed = JSON.parse(bodyText);
258965
+ } catch (error2) {
258966
+ return {
258967
+ state: "unknown",
258968
+ reason: error2 instanceof Error ? error2.message : String(error2)
258969
+ };
258970
+ }
258971
+ }
258972
+ const wrappedInvisibleWorkspaceIdRaw = parsed?.error?.meta?.workspaceId;
258973
+ const wrappedInvisibleWorkspaceId = typeof wrappedInvisibleWorkspaceIdRaw === "string" ? wrappedInvisibleWorkspaceIdRaw.trim() : "";
258974
+ if (wrappedInvisibleWorkspaceId) {
258975
+ return { state: "linked-invisible", workspaceId: wrappedInvisibleWorkspaceId };
258976
+ }
258977
+ if (response.status === 200) {
258978
+ if (!parsed || !Object.prototype.hasOwnProperty.call(parsed, "data")) {
258979
+ return {
258980
+ state: "unknown",
258981
+ reason: "Filesystem probe returned 200 without a data payload"
258982
+ };
258983
+ }
258984
+ const data = parsed?.data ?? null;
258985
+ if (data == null) {
258986
+ return { state: "free" };
258987
+ }
258988
+ if (typeof data === "object" && !Array.isArray(data)) {
258989
+ const workspace = data;
258990
+ const id = typeof workspace.id === "string" ? workspace.id.trim() : "";
258991
+ if (id) {
258992
+ const name = typeof workspace.name === "string" ? workspace.name : "";
258993
+ return {
258994
+ state: "linked-visible",
258995
+ workspace: { ...workspace, id, name }
258996
+ };
258997
+ }
258998
+ }
258999
+ return {
259000
+ state: "unknown",
259001
+ reason: "Filesystem probe returned 200 with unrecognized workspace payload"
259002
+ };
259003
+ }
259004
+ if (response.status === 403) {
259005
+ const workspaceIdRaw = parsed?.error?.meta?.workspaceId ?? parsed?.meta?.workspaceId;
259006
+ const workspaceId = typeof workspaceIdRaw === "string" ? workspaceIdRaw.trim() : "";
259007
+ if (workspaceId) {
259008
+ return { state: "linked-invisible", workspaceId };
259009
+ }
259010
+ return {
259011
+ state: "unknown",
259012
+ reason: "Filesystem probe returned 403 without error.meta.workspaceId"
259013
+ };
259014
+ }
259015
+ return {
259016
+ state: "unknown",
259017
+ reason: `Filesystem probe returned HTTP ${response.status}`
259018
+ };
259019
+ }
258939
259020
  async linkCollectionsToSpecification(specificationId, collections) {
258940
259021
  if (collections.length === 0) {
258941
259022
  return;
@@ -312653,7 +312734,28 @@ async function provisionWorkspace(inputs, dependencies, telemetry, outputs, reso
312653
312734
  }
312654
312735
  telemetry.setTeamId(teamId);
312655
312736
  const repoUrl = inputs.repoUrl || "";
312656
- if (!explicitWorkspaceId && repoUrl && inputs.postmanAccessToken && teamId) {
312737
+ if (repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
312738
+ const probe = await dependencies.internalIntegration.findWorkspaceForRepo(repoUrl);
312739
+ if (probe.state === "linked-invisible") {
312740
+ const orgTail = inputs.workspaceTeamId ? " Verify workspace-team-id; if the owner is in another sub-team, ask that sub-team's admin to disconnect it." : "";
312741
+ throw new Error(
312742
+ `REPOSITORY_LINK_CONFLICT_INVISIBLE: Repository ${repoUrl} at path / is linked to workspace ${probe.workspaceId}, but these credentials cannot view it. No Postman assets were changed. Ask its owner or a team admin to disconnect it.${orgTail}`
312743
+ );
312744
+ }
312745
+ if (probe.state === "linked-visible") {
312746
+ workspaceId = probe.workspace.id;
312747
+ workspaceMutationOwned = true;
312748
+ const nameSuffix = probe.workspace.name ? ` ("${probe.workspace.name}")` : "";
312749
+ dependencies.core.info(
312750
+ `Repository ${repoUrl} at path / is already linked to workspace ${probe.workspace.id}${nameSuffix}; adopting it as the canonical workspace.`
312751
+ );
312752
+ } else if (probe.state === "unknown") {
312753
+ dependencies.core.warning(
312754
+ `Repository link preflight could not determine ownership for ${repoUrl}: ${probe.reason}. Continuing with normal workspace selection.`
312755
+ );
312756
+ }
312757
+ }
312758
+ if (!workspaceId && repoUrl && inputs.postmanAccessToken && teamId) {
312657
312759
  const selection = await runGroup(
312658
312760
  dependencies.core,
312659
312761
  "Resolve Canonical Workspace",
package/dist/cli.cjs CHANGED
@@ -257254,6 +257254,87 @@ var BifrostInternalIntegrationAdapter = class _BifrostInternalIntegrationAdapter
257254
257254
  const advised = adviseFromHttpError(httpErr, this.adviceContext("workspace repository linking"));
257255
257255
  throw advised ?? httpErr;
257256
257256
  }
257257
+ async findWorkspaceForRepo(repoUrl, path8 = "/") {
257258
+ const encodedRepo = encodeURIComponent(repoUrl);
257259
+ const encodedPath = encodeURIComponent(path8);
257260
+ const requestPath2 = `/workspaces/filesystem?repo=${encodedRepo}&path=${encodedPath}`;
257261
+ let response;
257262
+ try {
257263
+ response = await this.proxyRequest("workspaces", "GET", requestPath2);
257264
+ } catch (error) {
257265
+ return {
257266
+ state: "unknown",
257267
+ reason: error instanceof Error ? error.message : String(error)
257268
+ };
257269
+ }
257270
+ let bodyText;
257271
+ try {
257272
+ bodyText = await response.text();
257273
+ } catch (error) {
257274
+ return {
257275
+ state: "unknown",
257276
+ reason: error instanceof Error ? error.message : String(error)
257277
+ };
257278
+ }
257279
+ let parsed = null;
257280
+ if (bodyText.trim()) {
257281
+ try {
257282
+ parsed = JSON.parse(bodyText);
257283
+ } catch (error) {
257284
+ return {
257285
+ state: "unknown",
257286
+ reason: error instanceof Error ? error.message : String(error)
257287
+ };
257288
+ }
257289
+ }
257290
+ const wrappedInvisibleWorkspaceIdRaw = parsed?.error?.meta?.workspaceId;
257291
+ const wrappedInvisibleWorkspaceId = typeof wrappedInvisibleWorkspaceIdRaw === "string" ? wrappedInvisibleWorkspaceIdRaw.trim() : "";
257292
+ if (wrappedInvisibleWorkspaceId) {
257293
+ return { state: "linked-invisible", workspaceId: wrappedInvisibleWorkspaceId };
257294
+ }
257295
+ if (response.status === 200) {
257296
+ if (!parsed || !Object.prototype.hasOwnProperty.call(parsed, "data")) {
257297
+ return {
257298
+ state: "unknown",
257299
+ reason: "Filesystem probe returned 200 without a data payload"
257300
+ };
257301
+ }
257302
+ const data = parsed?.data ?? null;
257303
+ if (data == null) {
257304
+ return { state: "free" };
257305
+ }
257306
+ if (typeof data === "object" && !Array.isArray(data)) {
257307
+ const workspace = data;
257308
+ const id = typeof workspace.id === "string" ? workspace.id.trim() : "";
257309
+ if (id) {
257310
+ const name = typeof workspace.name === "string" ? workspace.name : "";
257311
+ return {
257312
+ state: "linked-visible",
257313
+ workspace: { ...workspace, id, name }
257314
+ };
257315
+ }
257316
+ }
257317
+ return {
257318
+ state: "unknown",
257319
+ reason: "Filesystem probe returned 200 with unrecognized workspace payload"
257320
+ };
257321
+ }
257322
+ if (response.status === 403) {
257323
+ const workspaceIdRaw = parsed?.error?.meta?.workspaceId ?? parsed?.meta?.workspaceId;
257324
+ const workspaceId = typeof workspaceIdRaw === "string" ? workspaceIdRaw.trim() : "";
257325
+ if (workspaceId) {
257326
+ return { state: "linked-invisible", workspaceId };
257327
+ }
257328
+ return {
257329
+ state: "unknown",
257330
+ reason: "Filesystem probe returned 403 without error.meta.workspaceId"
257331
+ };
257332
+ }
257333
+ return {
257334
+ state: "unknown",
257335
+ reason: `Filesystem probe returned HTTP ${response.status}`
257336
+ };
257337
+ }
257257
257338
  async linkCollectionsToSpecification(specificationId, collections) {
257258
257339
  if (collections.length === 0) {
257259
257340
  return;
@@ -310879,7 +310960,28 @@ async function provisionWorkspace(inputs, dependencies, telemetry, outputs, reso
310879
310960
  }
310880
310961
  telemetry.setTeamId(teamId);
310881
310962
  const repoUrl = inputs.repoUrl || "";
310882
- if (!explicitWorkspaceId && repoUrl && inputs.postmanAccessToken && teamId) {
310963
+ if (repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
310964
+ const probe = await dependencies.internalIntegration.findWorkspaceForRepo(repoUrl);
310965
+ if (probe.state === "linked-invisible") {
310966
+ const orgTail = inputs.workspaceTeamId ? " Verify workspace-team-id; if the owner is in another sub-team, ask that sub-team's admin to disconnect it." : "";
310967
+ throw new Error(
310968
+ `REPOSITORY_LINK_CONFLICT_INVISIBLE: Repository ${repoUrl} at path / is linked to workspace ${probe.workspaceId}, but these credentials cannot view it. No Postman assets were changed. Ask its owner or a team admin to disconnect it.${orgTail}`
310969
+ );
310970
+ }
310971
+ if (probe.state === "linked-visible") {
310972
+ workspaceId = probe.workspace.id;
310973
+ workspaceMutationOwned = true;
310974
+ const nameSuffix = probe.workspace.name ? ` ("${probe.workspace.name}")` : "";
310975
+ dependencies.core.info(
310976
+ `Repository ${repoUrl} at path / is already linked to workspace ${probe.workspace.id}${nameSuffix}; adopting it as the canonical workspace.`
310977
+ );
310978
+ } else if (probe.state === "unknown") {
310979
+ dependencies.core.warning(
310980
+ `Repository link preflight could not determine ownership for ${repoUrl}: ${probe.reason}. Continuing with normal workspace selection.`
310981
+ );
310982
+ }
310983
+ }
310984
+ if (!workspaceId && repoUrl && inputs.postmanAccessToken && teamId) {
310883
310985
  const selection = await runGroup(
310884
310986
  dependencies.core,
310885
310987
  "Resolve Canonical Workspace",
package/dist/index.cjs CHANGED
@@ -258961,6 +258961,87 @@ var BifrostInternalIntegrationAdapter = class _BifrostInternalIntegrationAdapter
258961
258961
  const advised = adviseFromHttpError(httpErr, this.adviceContext("workspace repository linking"));
258962
258962
  throw advised ?? httpErr;
258963
258963
  }
258964
+ async findWorkspaceForRepo(repoUrl, path10 = "/") {
258965
+ const encodedRepo = encodeURIComponent(repoUrl);
258966
+ const encodedPath = encodeURIComponent(path10);
258967
+ const requestPath2 = `/workspaces/filesystem?repo=${encodedRepo}&path=${encodedPath}`;
258968
+ let response;
258969
+ try {
258970
+ response = await this.proxyRequest("workspaces", "GET", requestPath2);
258971
+ } catch (error2) {
258972
+ return {
258973
+ state: "unknown",
258974
+ reason: error2 instanceof Error ? error2.message : String(error2)
258975
+ };
258976
+ }
258977
+ let bodyText;
258978
+ try {
258979
+ bodyText = await response.text();
258980
+ } catch (error2) {
258981
+ return {
258982
+ state: "unknown",
258983
+ reason: error2 instanceof Error ? error2.message : String(error2)
258984
+ };
258985
+ }
258986
+ let parsed = null;
258987
+ if (bodyText.trim()) {
258988
+ try {
258989
+ parsed = JSON.parse(bodyText);
258990
+ } catch (error2) {
258991
+ return {
258992
+ state: "unknown",
258993
+ reason: error2 instanceof Error ? error2.message : String(error2)
258994
+ };
258995
+ }
258996
+ }
258997
+ const wrappedInvisibleWorkspaceIdRaw = parsed?.error?.meta?.workspaceId;
258998
+ const wrappedInvisibleWorkspaceId = typeof wrappedInvisibleWorkspaceIdRaw === "string" ? wrappedInvisibleWorkspaceIdRaw.trim() : "";
258999
+ if (wrappedInvisibleWorkspaceId) {
259000
+ return { state: "linked-invisible", workspaceId: wrappedInvisibleWorkspaceId };
259001
+ }
259002
+ if (response.status === 200) {
259003
+ if (!parsed || !Object.prototype.hasOwnProperty.call(parsed, "data")) {
259004
+ return {
259005
+ state: "unknown",
259006
+ reason: "Filesystem probe returned 200 without a data payload"
259007
+ };
259008
+ }
259009
+ const data = parsed?.data ?? null;
259010
+ if (data == null) {
259011
+ return { state: "free" };
259012
+ }
259013
+ if (typeof data === "object" && !Array.isArray(data)) {
259014
+ const workspace = data;
259015
+ const id = typeof workspace.id === "string" ? workspace.id.trim() : "";
259016
+ if (id) {
259017
+ const name = typeof workspace.name === "string" ? workspace.name : "";
259018
+ return {
259019
+ state: "linked-visible",
259020
+ workspace: { ...workspace, id, name }
259021
+ };
259022
+ }
259023
+ }
259024
+ return {
259025
+ state: "unknown",
259026
+ reason: "Filesystem probe returned 200 with unrecognized workspace payload"
259027
+ };
259028
+ }
259029
+ if (response.status === 403) {
259030
+ const workspaceIdRaw = parsed?.error?.meta?.workspaceId ?? parsed?.meta?.workspaceId;
259031
+ const workspaceId = typeof workspaceIdRaw === "string" ? workspaceIdRaw.trim() : "";
259032
+ if (workspaceId) {
259033
+ return { state: "linked-invisible", workspaceId };
259034
+ }
259035
+ return {
259036
+ state: "unknown",
259037
+ reason: "Filesystem probe returned 403 without error.meta.workspaceId"
259038
+ };
259039
+ }
259040
+ return {
259041
+ state: "unknown",
259042
+ reason: `Filesystem probe returned HTTP ${response.status}`
259043
+ };
259044
+ }
258964
259045
  async linkCollectionsToSpecification(specificationId, collections) {
258965
259046
  if (collections.length === 0) {
258966
259047
  return;
@@ -312681,7 +312762,28 @@ async function provisionWorkspace(inputs, dependencies, telemetry, outputs, reso
312681
312762
  }
312682
312763
  telemetry.setTeamId(teamId);
312683
312764
  const repoUrl = inputs.repoUrl || "";
312684
- if (!explicitWorkspaceId && repoUrl && inputs.postmanAccessToken && teamId) {
312765
+ if (repoUrl && dependencies.internalIntegration?.findWorkspaceForRepo) {
312766
+ const probe = await dependencies.internalIntegration.findWorkspaceForRepo(repoUrl);
312767
+ if (probe.state === "linked-invisible") {
312768
+ const orgTail = inputs.workspaceTeamId ? " Verify workspace-team-id; if the owner is in another sub-team, ask that sub-team's admin to disconnect it." : "";
312769
+ throw new Error(
312770
+ `REPOSITORY_LINK_CONFLICT_INVISIBLE: Repository ${repoUrl} at path / is linked to workspace ${probe.workspaceId}, but these credentials cannot view it. No Postman assets were changed. Ask its owner or a team admin to disconnect it.${orgTail}`
312771
+ );
312772
+ }
312773
+ if (probe.state === "linked-visible") {
312774
+ workspaceId = probe.workspace.id;
312775
+ workspaceMutationOwned = true;
312776
+ const nameSuffix = probe.workspace.name ? ` ("${probe.workspace.name}")` : "";
312777
+ dependencies.core.info(
312778
+ `Repository ${repoUrl} at path / is already linked to workspace ${probe.workspace.id}${nameSuffix}; adopting it as the canonical workspace.`
312779
+ );
312780
+ } else if (probe.state === "unknown") {
312781
+ dependencies.core.warning(
312782
+ `Repository link preflight could not determine ownership for ${repoUrl}: ${probe.reason}. Continuing with normal workspace selection.`
312783
+ );
312784
+ }
312785
+ }
312786
+ if (!workspaceId && repoUrl && inputs.postmanAccessToken && teamId) {
312685
312787
  const selection = await runGroup(
312686
312788
  dependencies.core,
312687
312789
  "Resolve Canonical Workspace",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cse/onboarding-bootstrap",
3
- "version": "2.9.9",
3
+ "version": "2.9.10",
4
4
  "description": "Bootstrap Postman workspaces, specs, and collections from OpenAPI.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",