@dropthis/cli 0.26.0 → 0.27.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.
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  PublishInputError: () => PublishInputError,
38
38
  SHARED_POOL: () => SHARED_POOL,
39
39
  UploadsResource: () => UploadsResource,
40
+ WorkspacesResource: () => WorkspacesResource,
40
41
  createErrorResult: () => createErrorResult,
41
42
  redactSecrets: () => redactSecrets
42
43
  });
@@ -295,7 +296,8 @@ function buildStagedRequest(files, options, entry) {
295
296
  const manifest = {
296
297
  schemaVersion: 1,
297
298
  files: manifestFiles,
298
- ...resolvedEntry ? { entry: resolvedEntry } : {}
299
+ ...resolvedEntry ? { entry: resolvedEntry } : {},
300
+ ...options.workspace !== void 0 ? { workspace: options.workspace } : {}
299
301
  };
300
302
  const prepared = {
301
303
  kind: "staged",
@@ -304,6 +306,7 @@ function buildStagedRequest(files, options, entry) {
304
306
  options: optionsBody(options)
305
307
  };
306
308
  if (options.metadata) prepared.metadata = options.metadata;
309
+ if (options.workspace !== void 0) prepared.workspace = options.workspace;
307
310
  return prepared;
308
311
  }
309
312
  function buildSourceRequest(sourceUrl, options) {
@@ -321,6 +324,7 @@ function buildSourceRequest(sourceUrl, options) {
321
324
  options: optionsBody(options)
322
325
  };
323
326
  if (options.metadata) prepared.metadata = options.metadata;
327
+ if (options.workspace !== void 0) prepared.workspace = options.workspace;
324
328
  return prepared;
325
329
  }
326
330
  function decodeBase64(value) {
@@ -545,6 +549,7 @@ async function publishSource(transport, prepared, finalPath, options = {}) {
545
549
  sourceUrl: prepared.sourceUrl,
546
550
  ...Object.keys(prepared.options).length > 0 ? { options: prepared.options } : {},
547
551
  ...prepared.metadata ? { metadata: prepared.metadata } : {},
552
+ ...prepared.workspace !== void 0 ? { workspace: prepared.workspace } : {},
548
553
  ...partialUpdateBody(options)
549
554
  },
550
555
  idempotencyKey: `${baseKey}:publish`,
@@ -731,7 +736,12 @@ var ApiKeysResource = class {
731
736
  return this.transport.request("GET", "/api-keys");
732
737
  }
733
738
  create(input) {
734
- return this.transport.request("POST", "/api-keys", { body: input });
739
+ const body = { label: input.label };
740
+ if (input.type !== void 0) body.key_type = input.type;
741
+ if (input.workspace !== void 0) body.workspace = input.workspace;
742
+ if (input.allowedWorkspaces !== void 0)
743
+ body.allowed_workspace_ids = input.allowedWorkspaces;
744
+ return this.transport.request("POST", "/api-keys", { body });
735
745
  }
736
746
  /** Revoke an API key. 204 No Content — data is null on success. */
737
747
  delete(keyId) {
@@ -909,12 +919,14 @@ var CursorPage = class {
909
919
 
910
920
  // src/resources/drops.ts
911
921
  var DropsResource = class {
912
- constructor(transport, resolveInput2) {
922
+ constructor(transport, resolveInput2, defaultWorkspace) {
913
923
  this.transport = transport;
914
924
  this.resolveInput = resolveInput2;
925
+ this.defaultWorkspace = defaultWorkspace;
915
926
  }
916
927
  transport;
917
928
  resolveInput;
929
+ defaultWorkspace;
918
930
  /**
919
931
  * Publish content to a NEW permanent public URL; returns the created drop (with its `drop_…` id).
920
932
  * Use to publish / share / post / put online / make public a report, dashboard, site, or file.
@@ -932,13 +944,14 @@ var DropsResource = class {
932
944
  * collections. To stream bytes through the SDK for any drop kind, use {@link getContent}.
933
945
  */
934
946
  async publish(input, options = {}) {
947
+ const merged = this.defaultWorkspace !== void 0 && options.workspace === void 0 ? { ...options, workspace: this.defaultWorkspace } : options;
935
948
  let prepared;
936
949
  try {
937
- prepared = await this.resolveInput(input, options);
950
+ prepared = await this.resolveInput(input, merged);
938
951
  } catch (e) {
939
952
  return toErrorResult(e);
940
953
  }
941
- return prepared.kind === "source" ? publishSource(this.transport, prepared, "/drops", options) : publishStaged(this.transport, prepared, "/drops", options);
954
+ return prepared.kind === "source" ? publishSource(this.transport, prepared, "/drops", merged) : publishStaged(this.transport, prepared, "/drops", merged);
942
955
  }
943
956
  /**
944
957
  * Replace the content of an EXISTING drop, keeping its URL (ships a new deployment). Requires the
@@ -1121,6 +1134,30 @@ var UploadsResource = class {
1121
1134
  }
1122
1135
  };
1123
1136
 
1137
+ // src/resources/workspaces.ts
1138
+ var WorkspacesResource = class {
1139
+ constructor(transport) {
1140
+ this.transport = transport;
1141
+ }
1142
+ transport;
1143
+ list() {
1144
+ return this.transport.request("GET", "/workspaces");
1145
+ }
1146
+ use(workspace) {
1147
+ return this.transport.request("PUT", "/account/active-workspace", {
1148
+ body: { workspace }
1149
+ });
1150
+ }
1151
+ async active() {
1152
+ const result = await this.list();
1153
+ if (result.error !== null) {
1154
+ return result;
1155
+ }
1156
+ const found = result.data.data.find((ws) => ws.isActive) ?? null;
1157
+ return { data: found, error: null, headers: result.headers };
1158
+ }
1159
+ };
1160
+
1124
1161
  // src/case.ts
1125
1162
  function toCamelKey(key) {
1126
1163
  return key.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
@@ -1156,7 +1193,7 @@ function toSnakeCase(value) {
1156
1193
 
1157
1194
  // src/transport.ts
1158
1195
  var DEFAULT_BASE_URL = "https://api.dropthis.app";
1159
- var SDK_VERSION = "0.23.0";
1196
+ var SDK_VERSION = "0.24.0";
1160
1197
  var Transport = class {
1161
1198
  apiKey;
1162
1199
  baseUrl;
@@ -1396,6 +1433,8 @@ function booleanValue(value) {
1396
1433
  // src/dropthis.ts
1397
1434
  var Dropthis = class {
1398
1435
  transport;
1436
+ /** Client-level workspace default; applied when a publish call omits `options.workspace`. */
1437
+ defaultWorkspace;
1399
1438
  authResource;
1400
1439
  apiKeysResource;
1401
1440
  accountResource;
@@ -1403,8 +1442,10 @@ var Dropthis = class {
1403
1442
  deploymentsResource;
1404
1443
  uploadsResource;
1405
1444
  domainsResource;
1445
+ workspacesResource;
1406
1446
  constructor(options = {}) {
1407
1447
  this.transport = new Transport(options);
1448
+ this.defaultWorkspace = typeof options === "string" ? void 0 : options.workspace;
1408
1449
  }
1409
1450
  get auth() {
1410
1451
  if (!this.authResource)
@@ -1422,8 +1463,13 @@ var Dropthis = class {
1422
1463
  return this.accountResource;
1423
1464
  }
1424
1465
  get drops() {
1425
- if (!this.dropsResource)
1426
- this.dropsResource = new DropsResource(this.transport, resolveInput);
1466
+ if (!this.dropsResource) {
1467
+ this.dropsResource = new DropsResource(
1468
+ this.transport,
1469
+ resolveInput,
1470
+ this.defaultWorkspace
1471
+ );
1472
+ }
1427
1473
  return this.dropsResource;
1428
1474
  }
1429
1475
  get deployments() {
@@ -1441,8 +1487,14 @@ var Dropthis = class {
1441
1487
  this.domainsResource = new DomainsResource(this.transport);
1442
1488
  return this.domainsResource;
1443
1489
  }
1490
+ get workspaces() {
1491
+ if (!this.workspacesResource)
1492
+ this.workspacesResource = new WorkspacesResource(this.transport);
1493
+ return this.workspacesResource;
1494
+ }
1444
1495
  async prepare(input, options = {}) {
1445
- return resolveInput(input, options);
1496
+ const merged = this.defaultWorkspace !== void 0 && options.workspace === void 0 ? { ...options, workspace: this.defaultWorkspace } : options;
1497
+ return resolveInput(input, merged);
1446
1498
  }
1447
1499
  };
1448
1500
 
@@ -1457,6 +1509,7 @@ var SHARED_POOL = "shared";
1457
1509
  PublishInputError,
1458
1510
  SHARED_POOL,
1459
1511
  UploadsResource,
1512
+ WorkspacesResource,
1460
1513
  createErrorResult,
1461
1514
  redactSecrets
1462
1515
  });