@dropthis/cli 0.30.1 → 0.33.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.
@@ -34,11 +34,16 @@ __export(index_exports, {
34
34
  DeploymentsResource: () => DeploymentsResource,
35
35
  DomainsResource: () => DomainsResource,
36
36
  Dropthis: () => Dropthis,
37
+ InvitationsResource: () => InvitationsResource,
38
+ MembersResource: () => MembersResource,
37
39
  PublishInputError: () => PublishInputError,
38
40
  SHARED_POOL: () => SHARED_POOL,
39
41
  UploadsResource: () => UploadsResource,
40
42
  WorkspacesResource: () => WorkspacesResource,
41
43
  createErrorResult: () => createErrorResult,
44
+ isFeatureNotInPlan: () => isFeatureNotInPlan,
45
+ isPlanGate: () => isPlanGate,
46
+ isQuotaExceeded: () => isQuotaExceeded,
42
47
  redactSecrets: () => redactSecrets
43
48
  });
44
49
  module.exports = __toCommonJS(index_exports);
@@ -68,11 +73,27 @@ function createErrorResult(code, message, statusCode, extra = {}) {
68
73
  ...extra.requestId !== void 0 ? { requestId: extra.requestId } : {},
69
74
  ...extra.suggestion !== void 0 ? { suggestion: extra.suggestion } : {},
70
75
  ...extra.retryable !== void 0 ? { retryable: extra.retryable } : {},
76
+ ...extra.feature != null ? { feature: extra.feature } : {},
77
+ ...extra.currentPlan != null ? { currentPlan: extra.currentPlan } : {},
78
+ ...extra.requiredPlan != null ? { requiredPlan: extra.requiredPlan } : {},
79
+ ...extra.upgradeUrl != null ? { upgradeUrl: extra.upgradeUrl } : {},
80
+ ...extra.limit != null ? { limit: extra.limit } : {},
81
+ ...extra.used != null ? { used: extra.used } : {},
82
+ ...extra.requested != null ? { requested: extra.requested } : {},
71
83
  ...extra.body !== void 0 ? { body: extra.body } : {}
72
84
  },
73
85
  headers: extra.headers ?? {}
74
86
  };
75
87
  }
88
+ function isFeatureNotInPlan(error) {
89
+ return error?.code === "feature_not_in_plan";
90
+ }
91
+ function isQuotaExceeded(error) {
92
+ return error?.code === "quota_exceeded";
93
+ }
94
+ function isPlanGate(error) {
95
+ return isFeatureNotInPlan(error) || isQuotaExceeded(error);
96
+ }
76
97
  var PublishInputError = class extends Error {
77
98
  constructor(code, message, param, suggestion) {
78
99
  super(message);
@@ -741,6 +762,7 @@ var ApiKeysResource = class {
741
762
  if (input.workspace !== void 0) body.workspace = input.workspace;
742
763
  if (input.allowedWorkspaces !== void 0)
743
764
  body.allowed_workspace_ids = input.allowedWorkspaces;
765
+ if (input.scopes !== void 0) body.scopes = input.scopes;
744
766
  return this.transport.request("POST", "/api-keys", { body });
745
767
  }
746
768
  /** Revoke an API key. 204 No Content — data is null on success. */
@@ -1094,6 +1116,69 @@ function updateBody(options) {
1094
1116
  };
1095
1117
  }
1096
1118
 
1119
+ // src/resources/invitations.ts
1120
+ var InvitationsResource = class {
1121
+ constructor(transport) {
1122
+ this.transport = transport;
1123
+ }
1124
+ transport;
1125
+ /** List the calling account's own pending invitations. */
1126
+ list() {
1127
+ return this.transport.request("GET", "/invitations");
1128
+ }
1129
+ /** Accept by the raw single-use token from the invite email. Joins + switches active workspace. */
1130
+ accept(input) {
1131
+ return this.transport.request("POST", "/invitations/accept", {
1132
+ body: input
1133
+ });
1134
+ }
1135
+ /** Accept by invitation id, once authenticated as the invited email — the agent path, no token. */
1136
+ acceptById(input) {
1137
+ return this.transport.request("POST", "/invitations/accept-by-id", {
1138
+ body: input
1139
+ });
1140
+ }
1141
+ };
1142
+
1143
+ // src/resources/members.ts
1144
+ var MembersResource = class {
1145
+ constructor(transport) {
1146
+ this.transport = transport;
1147
+ }
1148
+ transport;
1149
+ /** List a workspace's members (any member, `members:read`). */
1150
+ list(workspaceId) {
1151
+ return this.transport.request(
1152
+ "GET",
1153
+ `/workspaces/${encodeURIComponent(workspaceId)}/members`
1154
+ );
1155
+ }
1156
+ /** Invite an email to the workspace (owner/admin, `members:write`). */
1157
+ invite(workspaceId, input) {
1158
+ return this.transport.request(
1159
+ "POST",
1160
+ `/workspaces/${encodeURIComponent(workspaceId)}/invitations`,
1161
+ { body: input }
1162
+ );
1163
+ }
1164
+ /** Change a member's role (`members:admin`, owner-only-touches-owner enforced server-side). */
1165
+ updateRole(workspaceId, accountId, input) {
1166
+ return this.transport.request(
1167
+ "PATCH",
1168
+ `/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(accountId)}`,
1169
+ { body: input }
1170
+ );
1171
+ }
1172
+ /** Remove a member, or leave the workspace (your own id). Removing others needs `members:admin`;
1173
+ * leaving needs `members:write`. 204 — data is null. */
1174
+ remove(workspaceId, accountId) {
1175
+ return this.transport.request(
1176
+ "DELETE",
1177
+ `/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(accountId)}`
1178
+ );
1179
+ }
1180
+ };
1181
+
1097
1182
  // src/resources/uploads.ts
1098
1183
  var UploadsResource = class {
1099
1184
  constructor(transport) {
@@ -1146,6 +1231,25 @@ var WorkspacesResource = class {
1146
1231
  list() {
1147
1232
  return this.transport.request("GET", "/workspaces");
1148
1233
  }
1234
+ /** Create a team workspace (the caller becomes its sole owner). Needs `workspaces:write`. */
1235
+ create(input) {
1236
+ return this.transport.request("POST", "/workspaces", { body: input });
1237
+ }
1238
+ /** Rename a team workspace (owner/admin). Needs `workspaces:write`. */
1239
+ rename(workspaceId, input) {
1240
+ return this.transport.request(
1241
+ "PATCH",
1242
+ `/workspaces/${encodeURIComponent(workspaceId)}`,
1243
+ { body: input }
1244
+ );
1245
+ }
1246
+ /** Delete a team workspace (owner only). Needs `workspaces:admin`. 204 — data is null. */
1247
+ delete(workspaceId) {
1248
+ return this.transport.request(
1249
+ "DELETE",
1250
+ `/workspaces/${encodeURIComponent(workspaceId)}`
1251
+ );
1252
+ }
1149
1253
  use(workspace) {
1150
1254
  return this.transport.request("PUT", "/account/active-workspace", {
1151
1255
  body: { workspace }
@@ -1196,7 +1300,7 @@ function toSnakeCase(value) {
1196
1300
 
1197
1301
  // src/transport.ts
1198
1302
  var DEFAULT_BASE_URL = "https://api.dropthis.app";
1199
- var SDK_VERSION = "0.26.0";
1303
+ var SDK_VERSION = "0.29.0";
1200
1304
  var Transport = class {
1201
1305
  apiKey;
1202
1306
  baseUrl;
@@ -1405,6 +1509,15 @@ function problemResult(response, text, responseHeaders) {
1405
1509
  requestId: stringValue(body.request_id) ?? responseHeaders["x-request-id"] ?? null,
1406
1510
  suggestion: stringValue(body.suggestion),
1407
1511
  retryable: booleanValue(body.retryable),
1512
+ // Unified plan-gate contract (feature_not_in_plan / quota_exceeded). The
1513
+ // error body isn't camelCased like a success body, so map the snake keys here.
1514
+ feature: stringValue(body.feature),
1515
+ currentPlan: stringValue(body.current_plan),
1516
+ requiredPlan: stringValue(body.required_plan),
1517
+ upgradeUrl: stringValue(body.upgrade_url),
1518
+ limit: numberValue(body.limit) ?? null,
1519
+ used: numberValue(body.used) ?? null,
1520
+ requested: numberValue(body.requested) ?? null,
1408
1521
  headers: responseHeaders
1409
1522
  });
1410
1523
  }
@@ -1446,6 +1559,8 @@ var Dropthis = class {
1446
1559
  uploadsResource;
1447
1560
  domainsResource;
1448
1561
  workspacesResource;
1562
+ membersResource;
1563
+ invitationsResource;
1449
1564
  constructor(options = {}) {
1450
1565
  this.transport = new Transport(options);
1451
1566
  this.defaultWorkspace = typeof options === "string" ? void 0 : options.workspace;
@@ -1495,6 +1610,16 @@ var Dropthis = class {
1495
1610
  this.workspacesResource = new WorkspacesResource(this.transport);
1496
1611
  return this.workspacesResource;
1497
1612
  }
1613
+ get members() {
1614
+ if (!this.membersResource)
1615
+ this.membersResource = new MembersResource(this.transport);
1616
+ return this.membersResource;
1617
+ }
1618
+ get invitations() {
1619
+ if (!this.invitationsResource)
1620
+ this.invitationsResource = new InvitationsResource(this.transport);
1621
+ return this.invitationsResource;
1622
+ }
1498
1623
  async prepare(input, options = {}) {
1499
1624
  const merged = this.defaultWorkspace !== void 0 && options.workspace === void 0 ? { ...options, workspace: this.defaultWorkspace } : options;
1500
1625
  return resolveInput(input, merged);
@@ -1509,11 +1634,16 @@ var SHARED_POOL = "shared";
1509
1634
  DeploymentsResource,
1510
1635
  DomainsResource,
1511
1636
  Dropthis,
1637
+ InvitationsResource,
1638
+ MembersResource,
1512
1639
  PublishInputError,
1513
1640
  SHARED_POOL,
1514
1641
  UploadsResource,
1515
1642
  WorkspacesResource,
1516
1643
  createErrorResult,
1644
+ isFeatureNotInPlan,
1645
+ isPlanGate,
1646
+ isQuotaExceeded,
1517
1647
  redactSecrets
1518
1648
  });
1519
1649
  //# sourceMappingURL=index.cjs.map