@dreamlake/dreamlake-cli 0.102.2 → 0.102.3

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.
@@ -1,5 +1,30 @@
1
1
  import { type Transport } from "./client.js";
2
2
  import { type JsonObject, type Query } from "./common.js";
3
+ /** Review one existing stack registration; this never runs Terraform. */
4
+ export type InfrastructureStackMovePreviewInput = {
5
+ destinationNamespaceSlug: string;
6
+ destinationProjectSlug: string;
7
+ destinationName?: string;
8
+ /** Omit to preserve the current project-relative path. */
9
+ destinationPath?: string;
10
+ };
11
+ /** Execute the exact request returned by move preview, retaining its concurrency pins. */
12
+ export type InfrastructureStackMoveRequest = InfrastructureStackMovePreviewInput & {
13
+ expectedSourceNamespaceId: string;
14
+ expectedSourceProjectId: string;
15
+ expectedSourceName: string;
16
+ expectedVersion: number;
17
+ expectedDigest: string | null;
18
+ expectedDestinationNamespaceId: string;
19
+ expectedDestinationProjectId: string;
20
+ idempotencyKey: string;
21
+ } & ({
22
+ destinationPath: string;
23
+ expectedSourcePath: string | null;
24
+ } | {
25
+ destinationPath?: never;
26
+ expectedSourcePath?: never;
27
+ });
3
28
  export declare function platformApi(t: Transport, namespace: string): {
4
29
  providerDeclarations: {
5
30
  list: (query?: Query) => Promise<{
@@ -61,7 +61,7 @@ export const helpExamples = {
61
61
  "infra history": "dreamlake infra history da8e49cf-1b37-446f-9494-9620faf3192d --json",
62
62
  "infra events": "dreamlake infra events da8e49cf-1b37-446f-9494-9620faf3192d --after 0 --json",
63
63
  "infra create": "dreamlake infra create analytics --namespace fortyfive --project dreamlake-infra \\\n --environment production --repository https://github.com/example/repo \\\n --directory infra/analytics --path infra/analytics/production --json",
64
- "infra move": "# Save one reviewed move; no location changes occur during preview.\ndreamlake infra move da8e49cf-1b37-446f-9494-9620faf3192d \\\n --namespace fortyfive --project dreamlake-infra --dry-run --out stack-move.json\n# Execute the exact saved intent and optimistic concurrency checks.\ndreamlake infra move da8e49cf-1b37-446f-9494-9620faf3192d \\\n --request-file stack-move.json --confirm --json\n# Path-only move: same namespace/project, new place in its resource tree.\ndreamlake infra move da8e49cf-1b37-446f-9494-9620faf3192d \\\n --namespace fortyfive --project dreamlake-infra \\\n --destination-path platform/aws/analytics --dry-run --out stack-path.json",
64
+ "infra move": "# Save one reviewed move; no location changes occur during preview.\ndreamlake infra move da8e49cf-1b37-446f-9494-9620faf3192d \\\n --namespace fortyfive --project dreamlake-infra --dry-run --out stack-move.json\n# Execute the exact saved intent and optimistic concurrency checks.\ndreamlake infra move da8e49cf-1b37-446f-9494-9620faf3192d \\\n --request-file stack-move.json --confirm --json\n# Path-only move: same namespace/project, new place in its resource tree.\ndreamlake infra move da8e49cf-1b37-446f-9494-9620faf3192d \\\n --namespace fortyfive --project dreamlake-infra \\\n --destination-path platform/aws/analytics --dry-run --out stack-path.json\n# Archive a registration in another Project, preserving its current relative path.\ndreamlake infra move 28609d8d-4dce-42a3-afd2-faa13a45b958 \\\n --namespace fortyfive --project infrastructure-archive \\\n --dry-run --out stack-archive.json\ndreamlake infra move 28609d8d-4dce-42a3-afd2-faa13a45b958 \\\n --request-file stack-archive.json --confirm --json",
65
65
  "infra transfer plan": "dreamlake infra transfer plan 616658fd-531c-4bb9-8f52-7ebcbaa350b9 \\\n --namespace fortyfive --project dreamlake-infra \\\n --out stack-transfer.json",
66
66
  "infra transfer create": "dreamlake infra transfer create 616658fd-531c-4bb9-8f52-7ebcbaa350b9 \\\n --request-file stack-transfer.json --confirm --accept-if-authorized",
67
67
  "infra transfer status": "dreamlake infra transfer status 616658fd-531c-4bb9-8f52-7ebcbaa350b1 \\\n --out stack-transfer-acceptance.json",
@@ -26,6 +26,7 @@ function preview(value, id) {
26
26
  const stack = validateStack(value?.stack), intent = request(value?.request);
27
27
  const source = value?.source, destination = value?.destination;
28
28
  if (value.apiVersion !== 1 || value.semantics !== 'admission-linearized' || stack.id.toLowerCase() !== id.toLowerCase()
29
+ || (intent.destinationPath !== undefined && (stack.path ?? null) !== intent.expectedSourcePath)
29
30
  || stack.name !== intent.expectedSourceName || stack.version !== intent.expectedVersion || stack.namespaceId !== intent.expectedSourceNamespaceId || stack.projectId !== intent.expectedSourceProjectId
30
31
  || source?.namespaceId !== stack.namespaceId || source?.projectId !== stack.projectId
31
32
  || !opaqueId(destination?.namespaceId) || !opaqueId(destination?.projectId)
@@ -40,6 +41,7 @@ function preview(value, id) {
40
41
  }
41
42
  export async function runInfraMove(id, opts) {
42
43
  let executing = false;
44
+ let operationId;
43
45
  try {
44
46
  stackId(id);
45
47
  if (opts.dryRun === opts.confirm || (!opts.dryRun && !opts.confirm))
@@ -72,7 +74,11 @@ export async function runInfraMove(id, opts) {
72
74
  }
73
75
  if (opts.dryRun) {
74
76
  const result = preview(await post('/preview', { destinationNamespaceSlug: opts.namespace, destinationProjectSlug: opts.project, ...(opts.destinationName !== undefined ? { destinationName: opts.destinationName } : {}), ...(opts.destinationPath !== undefined ? { destinationPath: opts.destinationPath } : {}) }), id);
75
- if (result.request.destinationName !== opts.destinationName || result.request.destinationPath !== opts.destinationPath || result.destination.destinationNamespaceSlug !== opts.namespace || result.destination.destinationProjectSlug !== opts.project)
77
+ // A cross-project preview pins a preserved path even when the caller omitted
78
+ // --destination-path. Only the reviewed source path is an acceptable default.
79
+ const crossProject = result.destination.namespaceId !== result.source.namespaceId || result.destination.projectId !== result.source.projectId;
80
+ const expectedPath = opts.destinationPath ?? (crossProject ? result.stack.path ?? undefined : undefined);
81
+ if (result.request.destinationName !== opts.destinationName || result.request.destinationPath !== expectedPath || result.destination.destinationNamespaceSlug !== opts.namespace || result.destination.destinationProjectSlug !== opts.project)
76
82
  throw new Error('Move preview changed the requested destination');
77
83
  if (opts.out)
78
84
  writeFileSync(opts.out, JSON.stringify(result, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
@@ -82,17 +88,21 @@ export async function runInfraMove(id, opts) {
82
88
  const saved = preview(JSON.parse(readFileSync(opts.requestFile, 'utf8')), id);
83
89
  if (!saved.executable)
84
90
  throw new Error('Saved move preview is blocked; resolve blockers and obtain a new preview');
91
+ operationId = saved.request.idempotencyKey;
85
92
  executing = true;
86
93
  const result = await post('', saved.request);
87
94
  let stack;
88
95
  try {
89
96
  stack = validateStack(result?.stack);
90
97
  stackId(result.operationId);
91
- if (result.apiVersion !== 1 || typeof result.moved !== 'boolean' || typeof result.replayed !== 'boolean' || result.operationId !== saved.request.idempotencyKey
98
+ const changesPlacement = saved.stack.namespaceId !== saved.destination.namespaceId || saved.stack.projectId !== saved.destination.projectId
99
+ || (saved.request.destinationName ?? saved.stack.name) !== saved.stack.name
100
+ || (saved.request.destinationPath ?? saved.stack.path) !== saved.stack.path;
101
+ if ((!result.moved && !result.replayed && changesPlacement) || result.apiVersion !== 1 || typeof result.moved !== 'boolean' || typeof result.replayed !== 'boolean' || result.operationId !== saved.request.idempotencyKey
92
102
  || stack.id.toLowerCase() !== id.toLowerCase() || stack.namespaceId !== saved.destination.namespaceId || stack.projectId !== saved.destination.projectId
93
103
  || stack.version !== saved.stack.version || stack.locked
94
104
  || stack.name !== (saved.request.destinationName ?? saved.stack.name)
95
- || (saved.request.destinationPath !== undefined && stack.path !== saved.request.destinationPath)
105
+ || stack.path !== (saved.request.destinationPath ?? saved.stack.path)
96
106
  || ['environment', 'repository', 'directory', 'createdAt'].some(k => stack[k] !== saved.stack[k]))
97
107
  throw new Error();
98
108
  }
@@ -105,7 +115,7 @@ export async function runInfraMove(id, opts) {
105
115
  catch (error) {
106
116
  const message = error instanceof Error ? error.message : 'Stack move failed';
107
117
  if (opts.json)
108
- console.log(JSON.stringify({ error: message, ...(executing ? { outcome: 'reconcile-required' } : {}) }));
118
+ console.log(JSON.stringify({ error: message, ...(executing ? { outcome: 'reconcile-required', stackId: id, operationId } : {}) }));
109
119
  else
110
120
  console.error(message);
111
121
  return 1;
@@ -115,7 +125,7 @@ export function registerInfraMove(infra) {
115
125
  infra.command('move <stack-id>').description('Move one existing stack registration with a saved review')
116
126
  .option('--namespace <slug>', 'Destination namespace').option('--project <slug>', 'Destination project')
117
127
  .option('--destination-name <name>', 'Explicit destination stack name (preview only)')
118
- .option('--destination-path <path>', 'Destination place in the project resource tree, e.g. infra/k3s/prod; same project for a path-only move (preview only)')
128
+ .option('--destination-path <path>', 'Destination place in the destination project tree; omit to preserve the current path (preview only)')
119
129
  .option('--dry-run', 'Preview without moving').option('--out <path>', 'Save preview to a new file')
120
130
  .option('--request-file <path>', 'Exact saved preview').option('--confirm', 'Execute the saved review')
121
131
  .option('--remote <url>', 'API remote').option('--token <token>', 'API credential (never printed)').option('--json', 'JSON output')
@@ -1 +1 @@
1
- export declare const VERSION = "0.102.2";
1
+ export declare const VERSION = "0.102.3";
@@ -6,4 +6,4 @@
6
6
  // value means a binary that re-installs the same version forever.
7
7
  //
8
8
  // Editing this by hand does nothing for a release; bump package.json.
9
- export const VERSION = "0.102.2";
9
+ export const VERSION = "0.102.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.102.2",
3
+ "version": "0.102.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -36,13 +36,13 @@
36
36
  "node": ">=18"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.102.2",
40
- "@dreamlake/dreamlake-cli-darwin-x64": "0.102.2",
41
- "@dreamlake/dreamlake-cli-linux-x64": "0.102.2",
42
- "@dreamlake/dreamlake-cli-linux-arm64": "0.102.2",
43
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.102.2",
44
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.102.2",
45
- "@dreamlake/dreamlake-cli-win32-x64": "0.102.2",
46
- "@dreamlake/dreamlake-cli-win32-arm64": "0.102.2"
39
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.102.3",
40
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.102.3",
41
+ "@dreamlake/dreamlake-cli-linux-x64": "0.102.3",
42
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.102.3",
43
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.102.3",
44
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.102.3",
45
+ "@dreamlake/dreamlake-cli-win32-x64": "0.102.3",
46
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.102.3"
47
47
  }
48
48
  }