@madewithremy/admin 0.1.21 → 0.1.23

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.d.ts CHANGED
@@ -1009,6 +1009,17 @@ interface DataLiftFromLiveResult {
1009
1009
  * Ops are pure: (ctx, params) → typed result. No printing, no process coupling.
1010
1010
  */
1011
1011
 
1012
+ interface LiftFromDevParams {
1013
+ /**
1014
+ * Which dev session to lift from, by dev release id. An app has a dev session per workspace — one
1015
+ * per person's box, one per person's CLI — so this is required once more than one is open. The
1016
+ * server refuses rather than picking: promoting the wrong workspace's data over live is not
1017
+ * recoverable, and nothing in the request would show it had happened.
1018
+ *
1019
+ * The ids are on the dashboard's `devSessions`, and the `ambiguous_dev_session` error lists them.
1020
+ */
1021
+ releaseId?: string;
1022
+ }
1012
1023
  /**
1013
1024
  * Destructively copy every dev-release database over the live-release databases.
1014
1025
  *
@@ -1019,18 +1030,27 @@ interface DataLiftFromLiveResult {
1019
1030
  * AND `--confirm` as a double-gate; the op always sends `{ confirm: true }`.
1020
1031
  *
1021
1032
  * @throws AdminApiError `no_dev_session` (404) — no dev release exists (start a dev session first);
1022
- * `no_live_release` (404) — app has never been published (publish first, then lift).
1033
+ * `no_live_release` (404) — app has never been published (publish first, then lift);
1034
+ * `ambiguous_dev_session` (400) — the app has several dev sessions open, so `releaseId` is
1035
+ * required; the error message lists the open ones.
1023
1036
  * @example
1024
1037
  * const result = await admin.data.liftFromDev();
1025
1038
  * console.log(`Lifted ${result.databasesAffected.length} databases to live`);
1039
+ * // With more than one dev session open, name the one you mean:
1040
+ * await admin.data.liftFromDev({ releaseId: '8f2c1e04-...' });
1026
1041
  */
1027
- declare function liftFromDev(ctx: AdminContext): Promise<DataLiftFromDevResult>;
1042
+ declare function liftFromDev(ctx: AdminContext, params?: LiftFromDevParams): Promise<DataLiftFromDevResult>;
1028
1043
  interface LiftFromLiveParams {
1029
1044
  /**
1030
1045
  * Empty dev databases in place — clears all rows, keeps schema and IDs,
1031
1046
  * no data read from live. Defaults to false (full copy from live).
1032
1047
  */
1033
1048
  truncate?: boolean;
1049
+ /**
1050
+ * Which dev session to overwrite, by dev release id. Required once the app has more than one
1051
+ * open — see `LiftFromDevParams.releaseId`.
1052
+ */
1053
+ releaseId?: string;
1034
1054
  }
1035
1055
  /**
1036
1056
  * Destructively replace dev-release databases with the live-release databases,
@@ -1043,7 +1063,8 @@ interface LiftFromLiveParams {
1043
1063
  * `lift-live-to-dev`.
1044
1064
  *
1045
1065
  * @throws AdminApiError `no_dev_session` (404) — no dev release exists (start a dev session first);
1046
- * `no_live_release` (404) — no live release (copy mode only; not thrown when `truncate` is true).
1066
+ * `no_live_release` (404) — no live release (copy mode only; not thrown when `truncate` is true);
1067
+ * `ambiguous_dev_session` (400) — several dev sessions are open, so `releaseId` is required.
1047
1068
  * @example
1048
1069
  * // Pull live data into dev for debugging:
1049
1070
  * await admin.data.liftFromLive();
@@ -1052,11 +1073,12 @@ interface LiftFromLiveParams {
1052
1073
  */
1053
1074
  declare function liftFromLive(ctx: AdminContext, params?: LiftFromLiveParams): Promise<DataLiftFromLiveResult>;
1054
1075
 
1076
+ type data_LiftFromDevParams = LiftFromDevParams;
1055
1077
  type data_LiftFromLiveParams = LiftFromLiveParams;
1056
1078
  declare const data_liftFromDev: typeof liftFromDev;
1057
1079
  declare const data_liftFromLive: typeof liftFromLive;
1058
1080
  declare namespace data {
1059
- export { type data_LiftFromLiveParams as LiftFromLiveParams, data_liftFromDev as liftFromDev, data_liftFromLive as liftFromLive };
1081
+ export { type data_LiftFromDevParams as LiftFromDevParams, type data_LiftFromLiveParams as LiftFromLiveParams, data_liftFromDev as liftFromDev, data_liftFromLive as liftFromLive };
1060
1082
  }
1061
1083
 
1062
1084
  /**
@@ -6094,7 +6116,7 @@ interface DashboardLiveRelease {
6094
6116
  /**
6095
6117
  * Response from GET /_internal/v2/apps/:appId/dashboard.
6096
6118
  * Only the fields used by this CLI are typed; the full shape
6097
- * (interfaces detail, previewReleases, devSession) is wider.
6119
+ * (interfaces detail, previewReleases, devSessions) is wider.
6098
6120
  */
6099
6121
  interface DashboardResult {
6100
6122
  appId: string;
@@ -6105,7 +6127,12 @@ interface DashboardResult {
6105
6127
  releases: ReleaseFragment[];
6106
6128
  interfaces: Record<string, unknown>;
6107
6129
  previewReleases: unknown[];
6108
- devSession: Record<string, unknown>;
6130
+ /**
6131
+ * One per workspace with a dev session open — a person's box, a person's CLI — and empty when
6132
+ * none is. Each carries the `releaseId` that names it, which is what the destructive data ops
6133
+ * take to say which session they mean.
6134
+ */
6135
+ devSessions: Array<Record<string, unknown>>;
6109
6136
  }
6110
6137
 
6111
6138
  /**
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import fs from "fs";
9
9
  import path from "path";
10
10
 
11
11
  // src/config.ts
12
- var WORKSPACE_DIR = process.env["WORKSPACE_DIR"] || "/home/vercel-sandbox/workspace";
12
+ var WORKSPACE_DIR = process.env["WORKSPACE_DIR"] || "/home/remy/workspace";
13
13
 
14
14
  // src/parseJsonConfig.ts
15
15
  import JSON5 from "json5";
@@ -339,12 +339,15 @@ __export(data_exports, {
339
339
  liftFromDev: () => liftFromDev,
340
340
  liftFromLive: () => liftFromLive
341
341
  });
342
- function liftFromDev(ctx) {
342
+ function liftFromDev(ctx, params = {}) {
343
343
  return call(
344
344
  ctx,
345
345
  "POST",
346
346
  `/_internal/v2/apps/${ctx.appId}/manage/lift-dev-to-live`,
347
- { confirm: true }
347
+ {
348
+ confirm: true,
349
+ ...params.releaseId ? { releaseId: params.releaseId } : {}
350
+ }
348
351
  );
349
352
  }
350
353
  function liftFromLive(ctx, params = {}) {
@@ -352,7 +355,11 @@ function liftFromLive(ctx, params = {}) {
352
355
  ctx,
353
356
  "POST",
354
357
  `/_internal/v2/apps/${ctx.appId}/manage/lift-live-to-dev`,
355
- { confirm: true, ...params.truncate ? { mode: "truncate" } : {} }
358
+ {
359
+ confirm: true,
360
+ ...params.truncate ? { mode: "truncate" } : {},
361
+ ...params.releaseId ? { releaseId: params.releaseId } : {}
362
+ }
356
363
  );
357
364
  }
358
365