@dreamlake/dreamlake-cli 0.104.6 → 0.104.7

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.
@@ -17,6 +17,12 @@ export declare function artifactsApi(t: Transport, namespace: string): {
17
17
  deleted?: boolean;
18
18
  }) => Promise<unknown>;
19
19
  get: (id: string) => Promise<unknown>;
20
+ rename: (id: string, input: {
21
+ slug: string;
22
+ expectedResourceId: string;
23
+ expectedSlug: string;
24
+ expectedRevision: number;
25
+ }) => Promise<unknown>;
20
26
  uploadCredentials: (artifactId: string) => Promise<unknown>;
21
27
  register: (id: string, input: {
22
28
  kind: string;
@@ -23,6 +23,7 @@ export function artifactsApi(t, namespace) {
23
23
  }),
24
24
  list: (query = {}) => call(t, "GET", base, undefined, query),
25
25
  get: (id) => call(t, "GET", path(id)),
26
+ rename: (id, input) => call(t, "PATCH", path(id) + "/slug", input),
26
27
  uploadCredentials: (artifactId) => call(t, "POST", base + "/upload-credentials", { artifactId }),
27
28
  register: (id, input) => call(t, "POST", path(id), input),
28
29
  delete: (id, permanent = false) => call(t, "DELETE", path(id) + (permanent ? "/purge" : "")),
@@ -773,6 +773,12 @@ export declare function createApi(transport: Transport): {
773
773
  deleted?: boolean;
774
774
  }) => Promise<unknown>;
775
775
  get: (id: string) => Promise<unknown>;
776
+ rename: (id: string, input: {
777
+ slug: string;
778
+ expectedResourceId: string;
779
+ expectedSlug: string;
780
+ expectedRevision: number;
781
+ }) => Promise<unknown>;
776
782
  uploadCredentials: (artifactId: string) => Promise<unknown>;
777
783
  register: (id: string, input: {
778
784
  kind: string;
@@ -1858,6 +1864,12 @@ export declare function createClient(options: ClientOptions): {
1858
1864
  deleted?: boolean;
1859
1865
  }) => Promise<unknown>;
1860
1866
  get: (id: string) => Promise<unknown>;
1867
+ rename: (id: string, input: {
1868
+ slug: string;
1869
+ expectedResourceId: string;
1870
+ expectedSlug: string;
1871
+ expectedRevision: number;
1872
+ }) => Promise<unknown>;
1861
1873
  uploadCredentials: (artifactId: string) => Promise<unknown>;
1862
1874
  register: (id: string, input: {
1863
1875
  kind: string;
@@ -1,3 +1,4 @@
1
+ import { registerArtifactRenameCommand } from "./rename.js";
1
2
  import { readSiteConfig } from './siteConfig.js';
2
3
  import { collectionList } from "../collection-list.js";
3
4
  import { registerShareCommands } from "../share.js";
@@ -132,7 +133,7 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
132
133
  const defaultTitle = directory
133
134
  ? path.basename(path.resolve(args.file))
134
135
  : path.basename(args.file, path.extname(args.file));
135
- const artifactId = args.artifactId ?? slugify(args.title ?? defaultTitle);
136
+ let artifactId = args.artifactId ?? slugify(args.title ?? defaultTitle);
136
137
  // Read the cover before any network call so a bad file fails fast.
137
138
  let coverBytes = null;
138
139
  if (args.cover) {
@@ -187,12 +188,14 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
187
188
  }
188
189
  // 1) broker: short-lived, prefix-scoped credentials + this artifact's own
189
190
  // dataset backend. The content itself never goes through the server.
190
- const cred = await jsonRequest("POST", `${ctx.remote}/namespaces/${encodeURIComponent(namespace)}/artifacts/upload-credentials`, token, { artifactId });
191
+ const cred = await jsonRequest("POST", `${ctx.remote}/namespaces/${encodeURIComponent(namespace)}/artifacts/upload-credentials`, token, { artifactId, resolveSlug: true });
191
192
  if (cred.status < 200 || cred.status >= 300) {
192
193
  fail(`could not get upload credentials → ${cred.status}: ${errorMessage(cred)}`);
193
194
  return 1;
194
195
  }
195
196
  const broker = cred.body;
197
+ if (typeof cred.body?.artifactId === "string")
198
+ artifactId = cred.body.artifactId;
196
199
  if (!broker?.credentials?.accessKeyId || !broker.backendUrl) {
197
200
  fail("unexpected upload-credentials response (missing credentials or backendUrl)");
198
201
  return 1;
@@ -408,6 +411,7 @@ export function registerArtifactCommand(program) {
408
411
  .command("artifact")
409
412
  .description("renderable artifacts (HTML/React/Markdown/SVG/code)");
410
413
  registerShareCommands(artifact, "artifact");
414
+ registerArtifactRenameCommand(artifact);
411
415
  withConnFlags(artifact
412
416
  .command("push")
413
417
  .description("push a renderable artifact — a new version of --id (written straight to storage)")
@@ -0,0 +1,9 @@
1
+ import type { Command } from 'commander';
2
+ import { type DreamlakeOpts } from '../compat/ctx.js';
3
+ export declare function runArtifactRename(args: DreamlakeOpts & {
4
+ artifactId: string;
5
+ slug: string;
6
+ namespace?: string;
7
+ json?: boolean;
8
+ }): Promise<number>;
9
+ export declare function registerArtifactRenameCommand(artifact: Command): void;
@@ -0,0 +1,45 @@
1
+ import { emitJson, fail, ok } from '../helpers.js';
2
+ import { resolveCtx } from '../compat/ctx.js';
3
+ import { errorMessage, jsonRequest, requireNamespace, requireToken } from '../compat/http.js';
4
+ import { withConnFlags } from '../compat/flags.js';
5
+ export async function runArtifactRename(args) {
6
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(args.slug)) {
7
+ fail('Invalid slug: use 1–128 letters, digits, dots, underscores or hyphens, starting with a letter or digit.');
8
+ return 1;
9
+ }
10
+ const ctx = resolveCtx(args), token = requireToken(ctx);
11
+ if (!token)
12
+ return 1;
13
+ const namespace = await requireNamespace(ctx, args.namespace);
14
+ if (!namespace)
15
+ return 1;
16
+ const url = `${ctx.remote}/namespaces/${encodeURIComponent(namespace)}/artifacts/${encodeURIComponent(args.artifactId)}`;
17
+ const current = await jsonRequest('GET', url, token);
18
+ if (current.status !== 200) {
19
+ fail(`Could not read artifact → ${current.status}: ${errorMessage(current)}`);
20
+ return 1;
21
+ }
22
+ const row = current.body;
23
+ if (!row.resourceId || !row.slug || !Number.isSafeInteger(row.slugRevision)) {
24
+ fail('This server does not support native artifact slug rename. No changes made.');
25
+ return 1;
26
+ }
27
+ const response = await jsonRequest('PATCH', `${url}/slug`, token, {
28
+ slug: args.slug, expectedResourceId: row.resourceId, expectedSlug: row.slug, expectedRevision: row.slugRevision,
29
+ });
30
+ if (response.status !== 200) {
31
+ fail(`Rename failed → ${response.status}: ${errorMessage(response)}${response.status === 409 ? '. Re-read the artifact and resolve the conflict before retrying.' : ''}`);
32
+ return 1;
33
+ }
34
+ if (args.json)
35
+ emitJson(response.body);
36
+ else
37
+ ok(`artifact slug: ${args.slug} (existing links and all versions preserved)`);
38
+ return 0;
39
+ }
40
+ export function registerArtifactRenameCommand(artifact) {
41
+ withConnFlags(artifact.command('rename').description('change an artifact URL slug, preserving identity, versions and old links')
42
+ .argument('<artifact-id>', 'current slug, old slug or immutable artifact ID')
43
+ .argument('<slug>', 'new URL slug').option('--namespace <slug>', 'namespace').option('--json', 'JSON output'))
44
+ .action(async (artifactId, slug, opts) => { process.exit(await runArtifactRename({ ...opts, artifactId, slug })); });
45
+ }
@@ -9,6 +9,7 @@ export const helpExamples = {
9
9
  "artifact meta set": "# At push time:\ndreamlake artifact push ./report.html --id q1-dashboard \\\n --description \"Revenue, churn and pipeline for the quarter\" \\\n --cover ./cover.png\n\n# Or after the fact, for an artifact that already exists:\ndreamlake artifact meta set q1-dashboard --description \"Revenue, churn and pipeline\"\ndreamlake artifact meta set q1-dashboard --cover ./cover.png\ndreamlake artifact meta show q1-dashboard\n\n# Back to the automatic description / the generated cover:\ndreamlake artifact meta set q1-dashboard --clear-description --clear-cover",
10
10
  "artifact share": "# Find the dashboard you already uploaded; no new version is needed.\ndreamlake artifact list\nARTIFACT=\"q1-dashboard\" # Replace with the id from list.\ndreamlake artifact share get \"$ARTIFACT\"\n\n# Give signed-in recipients read access, then verify the returned link.\ndreamlake artifact share create \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"\n\n# When link access is no longer needed, revoke it and verify.\ndreamlake artifact share revoke \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"",
11
11
  "artifact visibility": "ARTIFACT=\"q1-dashboard\" # Your existing artifact id.\ndreamlake artifact visibility \"$ARTIFACT\" public\ndreamlake artifact visibility \"$ARTIFACT\" private",
12
+ "artifact rename": "dreamlake artifact rename session-work-map-20261014 session-work-map --namespace my-team",
12
13
  "runnable bind": "dreamlake runnable bind udf/acme/recipes.process@FULL_SHA256 \\\n --snapshot CODE_REPO_ID --project recipes \\\n --server \"$LAKESHORE_URL\" --cp-namespace acme --dry-run\ndreamlake runnable bind udf/acme/recipes.process@FULL_SHA256 \\\n --snapshot CODE_REPO_ID --project recipes --server \"$LAKESHORE_URL\" --cp-namespace acme",
13
14
  "runnable execute": "dreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --json\ndreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --attempt 2 --json",
14
15
  "runnable execution-receipt": "dreamlake runnable execution-receipt exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --wait-seconds 30",
@@ -1 +1 @@
1
- export declare const VERSION = "0.104.6";
1
+ export declare const VERSION = "0.104.7";
@@ -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.104.6";
9
+ export const VERSION = "0.104.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.104.6",
3
+ "version": "0.104.7",
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.104.6",
40
- "@dreamlake/dreamlake-cli-darwin-x64": "0.104.6",
41
- "@dreamlake/dreamlake-cli-linux-x64": "0.104.6",
42
- "@dreamlake/dreamlake-cli-linux-arm64": "0.104.6",
43
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.104.6",
44
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.104.6",
45
- "@dreamlake/dreamlake-cli-win32-x64": "0.104.6",
46
- "@dreamlake/dreamlake-cli-win32-arm64": "0.104.6"
39
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.104.7",
40
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.104.7",
41
+ "@dreamlake/dreamlake-cli-linux-x64": "0.104.7",
42
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.104.7",
43
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.104.7",
44
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.104.7",
45
+ "@dreamlake/dreamlake-cli-win32-x64": "0.104.7",
46
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.104.7"
47
47
  }
48
48
  }