@objectstack/client 5.2.0 → 6.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/dist/index.js CHANGED
@@ -685,12 +685,12 @@ var ObjectStackClient = class {
685
685
  * through this API.
686
686
  *
687
687
  * Endpoints:
688
- * - GET /api/v1/cloud/projects → list environments
689
- * - GET /api/v1/cloud/projects/:id → get one (with database info)
690
- * - POST /api/v1/cloud/projects → provision a new project
691
- * - PATCH /api/v1/cloud/projects/:id → update (displayName, plan, status, …)
692
- * - POST /api/v1/cloud/projects/:id/activate → set as session's active project
693
- * - POST /api/v1/cloud/projects/:id/credentials/rotate → rotate credential
688
+ * - GET /api/v1/cloud/environments → list environments
689
+ * - GET /api/v1/cloud/environments/:id → get one (with database info)
690
+ * - POST /api/v1/cloud/environments → provision a new project
691
+ * - PATCH /api/v1/cloud/environments/:id → update (displayName, plan, status, …)
692
+ * - POST /api/v1/cloud/environments/:id/activate → set as session's active project
693
+ * - POST /api/v1/cloud/environments/:id/credentials/rotate → rotate credential
694
694
  *
695
695
  * @see docs/adr/0002-project-database-isolation.md
696
696
  */
@@ -705,7 +705,7 @@ var ObjectStackClient = class {
705
705
  if (filters?.env_type) params.set("envType", filters.env_type);
706
706
  if (filters?.status) params.set("status", filters.status);
707
707
  const qs = params.toString();
708
- const url = `${this.baseUrl}/api/v1/cloud/projects${qs ? "?" + qs : ""}`;
708
+ const url = `${this.baseUrl}/api/v1/cloud/environments${qs ? "?" + qs : ""}`;
709
709
  const res = await this.fetch(url);
710
710
  return this.unwrapResponse(res);
711
711
  },
@@ -713,7 +713,7 @@ var ObjectStackClient = class {
713
713
  * Get a single project (joined with its database and membership row).
714
714
  */
715
715
  get: async (id) => {
716
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}`);
716
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}`);
717
717
  return this.unwrapResponse(res);
718
718
  },
719
719
  /**
@@ -721,7 +721,7 @@ var ObjectStackClient = class {
721
721
  * `ProjectProvisioningService.provisionProject` on the server.
722
722
  */
723
723
  create: async (req) => {
724
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects`, {
724
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments`, {
725
725
  method: "POST",
726
726
  body: JSON.stringify(req)
727
727
  });
@@ -731,7 +731,7 @@ var ObjectStackClient = class {
731
731
  * Update a project (display_name, plan, status, is_default, metadata).
732
732
  */
733
733
  update: async (id, patch) => {
734
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}`, {
734
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}`, {
735
735
  method: "PATCH",
736
736
  body: JSON.stringify(patch)
737
737
  });
@@ -740,12 +740,12 @@ var ObjectStackClient = class {
740
740
  /**
741
741
  * Cascade-delete a project: cleans up credential/member/package_installation
742
742
  * rows, releases the physical database via the provisioning adapter, and
743
- * removes the `sys_project` row. Default projects require `force: true`.
743
+ * removes the `sys_environment` row. Default projects require `force: true`.
744
744
  */
745
745
  delete: async (id, opts) => {
746
746
  const qs = opts?.force ? "?force=1" : "";
747
747
  const res = await this.fetch(
748
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}${qs}`,
748
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}${qs}`,
749
749
  { method: "DELETE" }
750
750
  );
751
751
  return this.unwrapResponse(res);
@@ -756,7 +756,7 @@ var ObjectStackClient = class {
756
756
  * are routed to this project's database.
757
757
  */
758
758
  activate: async (id) => {
759
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/activate`, {
759
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/activate`, {
760
760
  method: "POST"
761
761
  });
762
762
  return this.unwrapResponse(res);
@@ -765,7 +765,7 @@ var ObjectStackClient = class {
765
765
  * Rotate the active database credential for this project.
766
766
  */
767
767
  rotateCredential: async (id, plaintext) => {
768
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/credentials/rotate`, {
768
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/credentials/rotate`, {
769
769
  method: "POST",
770
770
  body: JSON.stringify({ plaintext })
771
771
  });
@@ -776,7 +776,7 @@ var ObjectStackClient = class {
776
776
  * uniqueness server-side; invalidates the dispatcher's routing cache.
777
777
  */
778
778
  updateHostname: async (id, hostname) => {
779
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/hostname`, {
779
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/hostname`, {
780
780
  method: "POST",
781
781
  body: JSON.stringify({ hostname })
782
782
  });
@@ -790,7 +790,7 @@ var ObjectStackClient = class {
790
790
  * freely exposes all revisions.
791
791
  */
792
792
  updateVisibility: async (id, visibility) => {
793
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}`, {
793
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}`, {
794
794
  method: "PATCH",
795
795
  body: JSON.stringify({ visibility })
796
796
  });
@@ -809,7 +809,7 @@ var ObjectStackClient = class {
809
809
  if (opts?.branch) params.set("branch", opts.branch);
810
810
  const qs = params.toString();
811
811
  const res = await this.fetch(
812
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/revisions${qs ? `?${qs}` : ""}`
812
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/revisions${qs ? `?${qs}` : ""}`
813
813
  );
814
814
  return this.unwrapResponse(res);
815
815
  },
@@ -820,7 +820,7 @@ var ObjectStackClient = class {
820
820
  */
821
821
  listBranches: async (id) => {
822
822
  const res = await this.fetch(
823
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/branches`
823
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/branches`
824
824
  );
825
825
  return this.unwrapResponse(res);
826
826
  },
@@ -830,7 +830,7 @@ var ObjectStackClient = class {
830
830
  */
831
831
  renameBranch: async (id, from, to) => {
832
832
  const res = await this.fetch(
833
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/branches/${encodeURIComponent(from)}/rename`,
833
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/branches/${encodeURIComponent(from)}/rename`,
834
834
  {
835
835
  method: "POST",
836
836
  headers: { "content-type": "application/json" },
@@ -847,7 +847,7 @@ var ObjectStackClient = class {
847
847
  */
848
848
  deleteBranch: async (id, name) => {
849
849
  const res = await this.fetch(
850
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/branches/${encodeURIComponent(name)}`,
850
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/branches/${encodeURIComponent(name)}`,
851
851
  { method: "DELETE" }
852
852
  );
853
853
  return this.unwrapResponse(res);
@@ -858,7 +858,7 @@ var ObjectStackClient = class {
858
858
  */
859
859
  activateRevision: async (id, commitId) => {
860
860
  const res = await this.fetch(
861
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/revisions/${encodeURIComponent(commitId)}/activate`,
861
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/revisions/${encodeURIComponent(commitId)}/activate`,
862
862
  { method: "POST" }
863
863
  );
864
864
  return this.unwrapResponse(res);
@@ -870,7 +870,7 @@ var ObjectStackClient = class {
870
870
  * `failed` with `metadata.provisioningError` updated.
871
871
  */
872
872
  retryProvisioning: async (id) => {
873
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/retry`, {
873
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/retry`, {
874
874
  method: "POST"
875
875
  });
876
876
  return this.unwrapResponse(res);
@@ -879,7 +879,7 @@ var ObjectStackClient = class {
879
879
  * List members of a project (per-project RBAC).
880
880
  */
881
881
  listMembers: async (id) => {
882
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members`);
882
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/members`);
883
883
  return this.unwrapResponse(res);
884
884
  },
885
885
  /**
@@ -889,7 +889,7 @@ var ObjectStackClient = class {
889
889
  * row already existed; the call is idempotent.
890
890
  */
891
891
  addMember: async (id, payload) => {
892
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members`, {
892
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/members`, {
893
893
  method: "POST",
894
894
  headers: { "content-type": "application/json" },
895
895
  body: JSON.stringify(payload)
@@ -902,7 +902,7 @@ var ObjectStackClient = class {
902
902
  */
903
903
  updateMemberRole: async (id, memberId, role) => {
904
904
  const res = await this.fetch(
905
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members/${encodeURIComponent(memberId)}`,
905
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/members/${encodeURIComponent(memberId)}`,
906
906
  {
907
907
  method: "PATCH",
908
908
  headers: { "content-type": "application/json" },
@@ -917,7 +917,7 @@ var ObjectStackClient = class {
917
917
  */
918
918
  removeMember: async (id, memberId) => {
919
919
  const res = await this.fetch(
920
- `${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(id)}/members/${encodeURIComponent(memberId)}`,
920
+ `${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(id)}/members/${encodeURIComponent(memberId)}`,
921
921
  { method: "DELETE" }
922
922
  );
923
923
  return this.unwrapResponse(res);
@@ -947,12 +947,12 @@ var ObjectStackClient = class {
947
947
  packages: {
948
948
  /** List all packages installed in a specific project. */
949
949
  list: async (envId) => {
950
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages`);
950
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages`);
951
951
  return this.unwrapResponse(res);
952
952
  },
953
953
  /** Install a package into the project. */
954
954
  install: async (envId, body) => {
955
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages`, {
955
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages`, {
956
956
  method: "POST",
957
957
  body: JSON.stringify(body)
958
958
  });
@@ -960,33 +960,33 @@ var ObjectStackClient = class {
960
960
  },
961
961
  /** Get a single installation record. */
962
962
  get: async (envId, pkgId) => {
963
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}`);
963
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}`);
964
964
  return this.unwrapResponse(res);
965
965
  },
966
966
  /** Enable a previously disabled package. */
967
967
  enable: async (envId, pkgId) => {
968
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}/enable`, {
968
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}/enable`, {
969
969
  method: "PATCH"
970
970
  });
971
971
  return this.unwrapResponse(res);
972
972
  },
973
973
  /** Disable an installed package (metadata will not be loaded). */
974
974
  disable: async (envId, pkgId) => {
975
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}/disable`, {
975
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}/disable`, {
976
976
  method: "PATCH"
977
977
  });
978
978
  return this.unwrapResponse(res);
979
979
  },
980
980
  /** Uninstall a package from the project. Forbidden for scope=platform packages. */
981
981
  uninstall: async (envId, pkgId) => {
982
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}`, {
982
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}`, {
983
983
  method: "DELETE"
984
984
  });
985
985
  return this.unwrapResponse(res);
986
986
  },
987
987
  /** Upgrade an installed package to a newer version. */
988
988
  upgrade: async (envId, pkgId, targetVersion) => {
989
- const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/projects/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}/upgrade`, {
989
+ const res = await this.fetch(`${this.baseUrl}/api/v1/cloud/environments/${encodeURIComponent(envId)}/packages/${encodeURIComponent(pkgId)}/upgrade`, {
990
990
  method: "POST",
991
991
  body: JSON.stringify({ targetVersion })
992
992
  });
@@ -2736,7 +2736,7 @@ var ObjectStackClient = class {
2736
2736
  };
2737
2737
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
2738
2738
  this.token = config.token;
2739
- this.projectId = config.projectId;
2739
+ this.environmentId = config.environmentId;
2740
2740
  this.fetchImpl = config.fetch || globalThis.fetch.bind(globalThis);
2741
2741
  this.logger = config.logger || (0, import_logger.createLogger)({
2742
2742
  level: config.debug ? "debug" : "info",
@@ -2817,12 +2817,12 @@ var ObjectStackClient = class {
2817
2817
  * Project-scoped client factory.
2818
2818
  *
2819
2819
  * Returns a thin wrapper around the data / meta / packages namespaces that
2820
- * prefixes every request with `/api/v1/projects/:projectId/...`. Use this
2820
+ * prefixes every request with `/api/v1/environments/:environmentId/...`. Use this
2821
2821
  * when the server has `enableProjectScoping: true` in its REST API config.
2822
2822
  *
2823
2823
  * Backward compatibility: `client.data.*`, `client.meta.*`, and
2824
2824
  * `client.packages.*` continue to work unchanged; they hit unscoped routes
2825
- * and rely on hostname / `X-Project-Id` header / session resolution.
2825
+ * and rely on hostname / `X-Environment-Id` header / session resolution.
2826
2826
  *
2827
2827
  * @example
2828
2828
  * ```ts
@@ -2831,11 +2831,11 @@ var ObjectStackClient = class {
2831
2831
  * const objects = await scoped.meta.getItems('object');
2832
2832
  * ```
2833
2833
  */
2834
- project(projectId) {
2835
- if (!projectId) {
2836
- throw new Error("[ObjectStack] project(id): projectId is required");
2834
+ project(environmentId) {
2835
+ if (!environmentId) {
2836
+ throw new Error("[ObjectStack] project(id): environmentId is required");
2837
2837
  }
2838
- return new ScopedProjectClient(this, projectId);
2838
+ return new ScopedProjectClient(this, environmentId);
2839
2839
  }
2840
2840
  // ── Internal accessors exposed to ScopedProjectClient ────────────────
2841
2841
  // The scoped client lives in the same module so using module-level access
@@ -2861,15 +2861,15 @@ var ObjectStackClient = class {
2861
2861
  * Update the active project id used for subsequent requests.
2862
2862
  * Pass `undefined` to clear (falls back to the session default).
2863
2863
  */
2864
- setProjectId(projectId) {
2865
- this.projectId = projectId;
2866
- this.logger.debug("Active project changed", { projectId });
2864
+ setProjectId(environmentId) {
2865
+ this.environmentId = environmentId;
2866
+ this.logger.debug("Active project changed", { environmentId });
2867
2867
  }
2868
2868
  /**
2869
2869
  * Current active project id (if set).
2870
2870
  */
2871
2871
  getProjectId() {
2872
- return this.projectId;
2872
+ return this.environmentId;
2873
2873
  }
2874
2874
  /**
2875
2875
  * Event Subscription API
@@ -2911,8 +2911,8 @@ var ObjectStackClient = class {
2911
2911
  if (this.token) {
2912
2912
  headers["Authorization"] = `Bearer ${this.token}`;
2913
2913
  }
2914
- if (this.projectId) {
2915
- headers["X-Project-Id"] = this.projectId;
2914
+ if (this.environmentId) {
2915
+ headers["X-Environment-Id"] = this.environmentId;
2916
2916
  }
2917
2917
  const res = await this.fetchImpl(url, { ...options, headers });
2918
2918
  this.logger.debug("HTTP response", {
@@ -2981,7 +2981,7 @@ var ObjectStackClient = class {
2981
2981
  }
2982
2982
  };
2983
2983
  var ScopedProjectClient = class {
2984
- constructor(parent, projectId) {
2984
+ constructor(parent, environmentId) {
2985
2985
  /**
2986
2986
  * Metadata operations scoped to this project.
2987
2987
  */
@@ -3169,7 +3169,7 @@ var ScopedProjectClient = class {
3169
3169
  * Automation (Flow) operations scoped to this project.
3170
3170
  *
3171
3171
  * Thin wrapper around the dispatcher's automation routes, mounted under
3172
- * `/api/v1/projects/:projectId/automation/...`. Surface mirrors the methods
3172
+ * `/api/v1/environments/:environmentId/automation/...`. Surface mirrors the methods
3173
3173
  * needed by Studio's Flow viewer: read flow definition, execute (trigger),
3174
3174
  * list runs, fetch a single run.
3175
3175
  */
@@ -3210,15 +3210,15 @@ var ScopedProjectClient = class {
3210
3210
  }
3211
3211
  };
3212
3212
  this.parent = parent;
3213
- this.projectId = projectId;
3213
+ this.environmentId = environmentId;
3214
3214
  }
3215
- /** The projectId this client is scoped to. */
3215
+ /** The environmentId this client is scoped to. */
3216
3216
  getProjectId() {
3217
- return this.projectId;
3217
+ return this.environmentId;
3218
3218
  }
3219
3219
  /** Prefix segment inserted between the baseUrl and the resource path. */
3220
3220
  scope() {
3221
- return `/api/v1/projects/${encodeURIComponent(this.projectId)}`;
3221
+ return `/api/v1/environments/${encodeURIComponent(this.environmentId)}`;
3222
3222
  }
3223
3223
  url(suffix) {
3224
3224
  return `${this.parent._baseUrl()}${this.scope()}${suffix}`;