@dreamlake/dreamlake-cli 0.106.0 → 0.107.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.
@@ -1,3 +1,4 @@
1
+ export * from './lakeshore-connections.js';
1
2
  export * from "./open-resources.js";
2
3
  export * from "./library-manifest.js";
3
4
  export * from "./library-edit.js";
@@ -1115,6 +1116,23 @@ export declare function createApi(transport: Transport): {
1115
1116
  operation: (id: string) => Promise<unknown>;
1116
1117
  findOperation: (requestId: string) => Promise<unknown>;
1117
1118
  };
1119
+ lakeshores: (namespace: string) => {
1120
+ capabilities: () => Promise<{
1121
+ modelVersion: number;
1122
+ accessModes: string[];
1123
+ }>;
1124
+ create: (input: import("./lakeshore-connections.js").LakeshoreConnectionInput) => Promise<unknown>;
1125
+ list: (query?: {
1126
+ page?: number;
1127
+ pageSize?: number;
1128
+ }) => Promise<unknown>;
1129
+ get: (id: string) => Promise<unknown>;
1130
+ test: (id: string) => Promise<unknown>;
1131
+ update: (id: string, input: Partial<Omit<import("./lakeshore-connections.js").LakeshoreConnectionInput, "accessMode" | "token">> & {
1132
+ token?: string | null;
1133
+ }) => Promise<unknown>;
1134
+ disconnect: (id: string) => Promise<unknown>;
1135
+ };
1118
1136
  queues: (namespace: string) => {
1119
1137
  mounts: (query?: import("./common.js").Query) => Promise<unknown>;
1120
1138
  mount: (input: {
@@ -2311,6 +2329,23 @@ export declare function createClient(options: ClientOptions): {
2311
2329
  operation: (id: string) => Promise<unknown>;
2312
2330
  findOperation: (requestId: string) => Promise<unknown>;
2313
2331
  };
2332
+ lakeshores: (namespace: string) => {
2333
+ capabilities: () => Promise<{
2334
+ modelVersion: number;
2335
+ accessModes: string[];
2336
+ }>;
2337
+ create: (input: import("./lakeshore-connections.js").LakeshoreConnectionInput) => Promise<unknown>;
2338
+ list: (query?: {
2339
+ page?: number;
2340
+ pageSize?: number;
2341
+ }) => Promise<unknown>;
2342
+ get: (id: string) => Promise<unknown>;
2343
+ test: (id: string) => Promise<unknown>;
2344
+ update: (id: string, input: Partial<Omit<import("./lakeshore-connections.js").LakeshoreConnectionInput, "accessMode" | "token">> & {
2345
+ token?: string | null;
2346
+ }) => Promise<unknown>;
2347
+ disconnect: (id: string) => Promise<unknown>;
2348
+ };
2314
2349
  queues: (namespace: string) => {
2315
2350
  mounts: (query?: import("./common.js").Query) => Promise<unknown>;
2316
2351
  mount: (input: {
package/dist/api/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { lakeshoreConnectionsApi } from './lakeshore-connections.js';
2
+ export * from './lakeshore-connections.js';
1
3
  import { openResourcesApi } from "./open-resources.js";
2
4
  export * from "./open-resources.js";
3
5
  export * from "./library-manifest.js";
@@ -95,6 +97,7 @@ export function createApi(transport) {
95
97
  sources: (namespace) => sourcesApi(transport, namespace),
96
98
  runs: (namespace) => runsApi(transport, namespace),
97
99
  providers: (namespace) => providersApi(transport, namespace),
100
+ lakeshores: (namespace) => lakeshoreConnectionsApi(transport, namespace),
98
101
  queues: (namespace) => queuesApi(transport, namespace),
99
102
  ownership: (namespace) => ownershipApi(transport, namespace),
100
103
  runConfigs: (namespace) => resourceApi(transport, namespacePath(namespace) + "/run-configs"),
@@ -0,0 +1,30 @@
1
+ import { type Transport } from "./client.js";
2
+ export interface LakeshoreConnectionInput {
3
+ name: string;
4
+ baseUrl: string;
5
+ lakeshoreNs: string;
6
+ slug?: string;
7
+ description?: string;
8
+ accessMode?: "management" | "queues";
9
+ token?: string;
10
+ skipValidation?: boolean;
11
+ }
12
+ /** The unified service-connection API. The caller supplies credentials explicitly;
13
+ * no saved login, Vault download or control-plane credential is read locally. */
14
+ export declare function lakeshoreConnectionsApi(t: Transport, namespace: string): {
15
+ capabilities: () => Promise<{
16
+ modelVersion: number;
17
+ accessModes: string[];
18
+ }>;
19
+ create: (input: LakeshoreConnectionInput) => Promise<unknown>;
20
+ list: (query?: {
21
+ page?: number;
22
+ pageSize?: number;
23
+ }) => Promise<unknown>;
24
+ get: (id: string) => Promise<unknown>;
25
+ test: (id: string) => Promise<unknown>;
26
+ update: (id: string, input: Partial<Omit<LakeshoreConnectionInput, "accessMode" | "token">> & {
27
+ token?: string | null;
28
+ }) => Promise<unknown>;
29
+ disconnect: (id: string) => Promise<unknown>;
30
+ };
@@ -0,0 +1,29 @@
1
+ import { seg } from "./client.js";
2
+ import { namespacePath, call } from "./common.js";
3
+ /** The unified service-connection API. The caller supplies credentials explicitly;
4
+ * no saved login, Vault download or control-plane credential is read locally. */
5
+ export function lakeshoreConnectionsApi(t, namespace) {
6
+ const ns = namespacePath(namespace), base = ns + "/lakeshores";
7
+ const capabilities = () => call(t, "GET", ns + "/lakeshore-connection-capabilities");
8
+ return {
9
+ capabilities,
10
+ create: async (input) => {
11
+ input = { ...input };
12
+ if (input.accessMode === "queues") {
13
+ const supported = await capabilities();
14
+ if (supported.modelVersion !== 1 ||
15
+ !supported.accessModes?.includes("queues"))
16
+ throw new Error("Server does not support unified queue connections");
17
+ }
18
+ return t.request("POST", base + (input.accessMode === "queues" ? "/connect-v1" : ""), { json: input, redirect: "error" });
19
+ },
20
+ list: (query = {}) => call(t, "GET", base, undefined, query),
21
+ get: (id) => call(t, "GET", base + "/" + seg(id)),
22
+ test: (id) => call(t, "POST", base + "/" + seg(id) + "/test"),
23
+ update: (id, input) => t.request("PATCH", base + "/" + seg(id), {
24
+ json: input,
25
+ redirect: "error",
26
+ }),
27
+ disconnect: (id) => call(t, "DELETE", base + "/" + seg(id)),
28
+ };
29
+ }
@@ -1,5 +1,5 @@
1
1
  import { registerArtifactRenameCommand } from "./rename.js";
2
- import { readSiteConfig } from './siteConfig.js';
2
+ import { readSiteConfiguration } from './siteConfig.js';
3
3
  import { collectionList } from "../collection-list.js";
4
4
  import { registerShareCommands } from "../share.js";
5
5
  // `dreamlake artifact push|list|delete|restore`.
@@ -91,6 +91,7 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
91
91
  let content;
92
92
  let site;
93
93
  let directory = false;
94
+ let siteConfig;
94
95
  try {
95
96
  const stat = statSync(args.file);
96
97
  directory = stat.isDirectory();
@@ -110,7 +111,8 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
110
111
  fail("incremental artifacts are limited to 512 MiB");
111
112
  return 1;
112
113
  }
113
- site = args.site ? collectSite(args.file, args.entry, args.spa, readSiteConfig(args.siteConfig)) : undefined;
114
+ siteConfig = args.site ? readSiteConfiguration(args.siteConfig) : undefined;
115
+ site = args.site ? collectSite(args.file, args.entry, args.spa, siteConfig.publicDataOrigins) : undefined;
114
116
  content = site ? site.content : directory ? packPages(args.file, args.entry) : readFileSync(args.file);
115
117
  }
116
118
  catch (error) {
@@ -156,7 +158,7 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
156
158
  const capability = await jsonRequest('GET', `${ctx.remote}/artifacts/site-capabilities`, token);
157
159
  const caps = capability.body;
158
160
  const needsPublicData = site.manifest.schema === 'dreamlake-artifact-files/2';
159
- if (capability.status !== 200 || caps?.schema !== 'dreamlake-artifact-files/1' || (needsPublicData && (!caps.supportedSchemas?.includes('dreamlake-artifact-files/2') || caps.features?.publicDataOrigins !== true))) {
161
+ if (capability.status !== 200 || caps?.schema !== 'dreamlake-artifact-files/1' || (siteConfig?.privateData && caps.features?.privateSourceCapabilities !== true) || (needsPublicData && (!caps.supportedSchemas?.includes('dreamlake-artifact-files/2') || caps.features?.publicDataOrigins !== true))) {
160
162
  fail('Static artifact hosting is unavailable on this server; no files were uploaded.');
161
163
  return 1;
162
164
  }
@@ -238,6 +240,20 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
238
240
  if (grant.status !== 200 || binding?.manifest !== site.hash || JSON.stringify(binding.origins) !== JSON.stringify(site.manifest.network?.publicDataOrigins))
239
241
  throw new Error('Public data authorization failed; no artifact version was published. Owner or Project ADMIN access is required.');
240
242
  }
243
+ if (siteConfig?.privateData) {
244
+ const request = { manifest: site.hash, ...siteConfig.privateData };
245
+ const grant = await jsonRequest('POST', `${ctx.remote}/namespaces/${encodeURIComponent(namespace)}/artifacts/${encodeURIComponent(artifactId)}/site-private-data-grants`, token, request);
246
+ const binding = grant.body;
247
+ let originValid = false;
248
+ try {
249
+ const origin = new URL(binding?.origin ?? '');
250
+ originValid = origin.protocol === 'https:' && origin.origin === binding.origin && !origin.username && !origin.password;
251
+ }
252
+ catch { }
253
+ if (grant.status !== 200 || binding?.manifest !== site.hash || binding.alias !== request.alias || binding.sourceId !== request.sourceId || binding.prefix !== request.prefix || !originValid) {
254
+ throw new Error('Private data authorization failed; no artifact version was published. Artifact administrator and Source administrator access are required.');
255
+ }
256
+ }
241
257
  process.stdout.write(` site: ${site.manifest.files.length} files, ${result.uploadedFiles} new files, ${result.uploadedBytes} bytes uploaded\n`);
242
258
  }
243
259
  else if (incremental) {
@@ -1 +1,13 @@
1
+ export interface PrivateDataBinding {
2
+ alias: string;
3
+ sourceId: string;
4
+ namespaceId: string;
5
+ prefix: string;
6
+ }
7
+ export interface ArtifactSiteConfig {
8
+ publicDataOrigins: string[];
9
+ privateData?: PrivateDataBinding;
10
+ }
11
+ export declare function readSiteConfiguration(file?: string): ArtifactSiteConfig;
12
+ /** Backward-compatible public-origin reader for existing consumers. */
1
13
  export declare function readSiteConfig(file?: string): string[];
@@ -1,15 +1,28 @@
1
1
  import { existsSync, lstatSync, readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { validatePublicDataOrigins } from './siteFormat.js';
4
- export function readSiteConfig(file) {
4
+ export function readSiteConfiguration(file) {
5
5
  const target = file ?? path.resolve('artifact.config.json');
6
6
  if (!file && !existsSync(target))
7
- return [];
7
+ return { publicDataOrigins: [] };
8
8
  const stat = lstatSync(target);
9
9
  if (!stat.isFile() || stat.size > 16 * 1024)
10
10
  throw new Error('Site configuration must be a regular file of at most 16 KiB');
11
11
  const config = JSON.parse(readFileSync(target, 'utf8'));
12
- if (config?.schema !== 'dreamlake-artifact-config/1' || Object.keys(config).some(key => !['schema', 'network'].includes(key)) || !config.network || Object.keys(config.network).some(key => key !== 'publicDataOrigins'))
12
+ if (config?.schema !== 'dreamlake-artifact-config/1' || Object.keys(config).some(key => !['schema', 'network', 'privateData'].includes(key)) ||
13
+ (!config.network && !config.privateData) || (config.network && Object.keys(config.network).some(key => key !== 'publicDataOrigins')))
13
14
  throw new Error('Invalid artifact site configuration');
14
- return validatePublicDataOrigins(config.network.publicDataOrigins);
15
+ const result = { publicDataOrigins: validatePublicDataOrigins(config.network?.publicDataOrigins ?? []) };
16
+ if (config.privateData !== undefined) {
17
+ const binding = config.privateData;
18
+ if (!binding || typeof binding !== 'object' || Object.keys(binding).sort().join(',') !== 'alias,namespaceId,prefix,sourceId' ||
19
+ !/^[a-z][a-z0-9-]{0,47}$/.test(binding.alias) || !/^[a-f0-9]{24}$/.test(binding.sourceId) || !/^[a-f0-9]{24}$/.test(binding.namespaceId) ||
20
+ typeof binding.prefix !== 'string' || !binding.prefix || binding.prefix.length > 2048 || /[\\%?#\x00-\x20\x7f]/.test(binding.prefix) || binding.prefix.startsWith('/') ||
21
+ binding.prefix.split('/').some((part) => !part || part === '.' || part === '..'))
22
+ throw new Error('Invalid private data binding');
23
+ result.privateData = { alias: binding.alias, sourceId: binding.sourceId, namespaceId: binding.namespaceId, prefix: binding.prefix };
24
+ }
25
+ return result;
15
26
  }
27
+ /** Backward-compatible public-origin reader for existing consumers. */
28
+ export function readSiteConfig(file) { return readSiteConfiguration(file).publicDataOrigins; }
@@ -84,6 +84,8 @@ export const helpExamples = {
84
84
  "jobs report": "dreamlake jobs report 89abcdef0123456789abcdef --namespace geyang --state running\ndreamlake jobs report 89abcdef0123456789abcdef --namespace geyang \\\n --state succeeded --exit-code 0\ndreamlake jobs report fedcba9876543210fedcba98 --namespace geyang \\\n --state failed --exit-code 7 --message 'Training process exited with an error'",
85
85
  "jobs list": "dreamlake jobs list --namespace geyang\ndreamlake jobs list --namespace geyang --host 0123456789abcdef01234567 --state running\ndreamlake jobs list --namespace geyang --page 2 --page-size 50 --json",
86
86
  "jobs status": "dreamlake jobs status 89abcdef0123456789abcdef --namespace geyang\ndreamlake jobs status 89abcdef0123456789abcdef --namespace geyang --json",
87
+ "lakeshore connect": "# Prompts for a Lakeshore token without displaying it.\ndreamlake lakeshore connect --name lab --server https://lakeshore.example.com \\\n --namespace my-team --lakeshore-namespace training --access management",
88
+ "lakeshore": "dreamlake lakeshore list --namespace my-team\ndreamlake lakeshore show lab --namespace my-team\ndreamlake lakeshore test lab --namespace my-team\ndreamlake queues list lab --namespace my-team",
87
89
  "layout pages": "# Use the endpoint of your explicitly enabled local debugging session.\ndreamlake layout pages --cdp http://127.0.0.1:9222",
88
90
  "layout list": "dreamlake layout list --cdp http://127.0.0.1:9222 --page PAGE_ID",
89
91
  "layout inspect": "dreamlake layout inspect --cdp http://127.0.0.1:9222 --page PAGE_ID --layout LAYOUT_ID",
package/dist/cli/index.js CHANGED
@@ -13,6 +13,7 @@ import { helpExamples } from "./help-examples.generated.js";
13
13
  // CLI), implemented in lakeshore's TypeScript conventions.
14
14
  import { Command } from "commander";
15
15
  import { registerJobsCommand } from "./jobs/index.js";
16
+ import { registerLakeshoreCommand } from "./lakeshore/connections.js";
16
17
  import { registerQueuesCommand } from "./queues/index.js";
17
18
  import { registerServiceAccountsCommand } from "./service-accounts/index.js";
18
19
  import { registerExperimentsCommand } from "./experiments/index.js";
@@ -247,6 +248,7 @@ async function main(argv) {
247
248
  registerProvidersCommand(program);
248
249
  registerServiceAccountsCommand(program);
249
250
  registerQueuesCommand(program);
251
+ registerLakeshoreCommand(program);
250
252
  registerExperimentsCommand(program);
251
253
  registerStorageCommand(program);
252
254
  registerQueueDefCommand(program);
@@ -0,0 +1,27 @@
1
+ import { Command } from "commander";
2
+ type Mode = "queues" | "management";
3
+ interface Options {
4
+ namespace?: string;
5
+ json?: boolean;
6
+ server?: string;
7
+ lakeshoreNamespace?: string;
8
+ access?: Mode;
9
+ name?: string;
10
+ description?: string;
11
+ tokenStdin?: boolean;
12
+ open?: boolean;
13
+ skipValidation?: boolean;
14
+ clearToken?: boolean;
15
+ yes?: boolean;
16
+ page?: string;
17
+ pageSize?: string;
18
+ }
19
+ export interface ConnectionInput {
20
+ interactive: boolean;
21
+ token(): Promise<string>;
22
+ stdin(): Promise<string>;
23
+ }
24
+ export declare function runLakeshoreConnect(opts: Options, io?: ConnectionInput): Promise<number>;
25
+ export declare function runLakeshoreConnection(action: "list" | "show" | "test" | "update" | "disconnect", id: string | undefined, opts: Options, io?: ConnectionInput): Promise<number>;
26
+ export declare function registerLakeshoreCommand(program: Command): void;
27
+ export {};
@@ -0,0 +1,268 @@
1
+ import { Option } from "commander";
2
+ import { password } from "@inquirer/prompts";
3
+ import { HttpError, requestJson } from "../client.js";
4
+ import { resolveNamespace, resolveRemote, resolveToken } from "../config.js";
5
+ import { emitJson, fail, renderTable } from "../helpers.js";
6
+ import { confirm } from "../prompt.js";
7
+ const input = {
8
+ get interactive() {
9
+ return !!process.stdin.isTTY;
10
+ },
11
+ token: () => password({ message: "Lakeshore token (stored encrypted; never printed):" }),
12
+ stdin: async () => {
13
+ let value = "";
14
+ for await (const chunk of process.stdin) {
15
+ value += chunk.toString();
16
+ if (value.length > 16384)
17
+ throw new Error("Token input is too long");
18
+ }
19
+ return value;
20
+ },
21
+ };
22
+ async function context(opts) {
23
+ const token = resolveToken();
24
+ if (!token)
25
+ throw new Error("not authenticated — run 'dreamlake login' first");
26
+ const remote = resolveRemote();
27
+ const ns = await resolveNamespace(opts.namespace, { remote, token });
28
+ if (!ns)
29
+ throw new Error("Choose a DreamLake namespace with --namespace");
30
+ return {
31
+ remote,
32
+ token,
33
+ ns,
34
+ path: `/namespaces/${encodeURIComponent(ns)}/lakeshores`,
35
+ };
36
+ }
37
+ async function credential(opts, io) {
38
+ if (!opts.tokenStdin && !io.interactive)
39
+ throw new Error("Pass --token-stdin, or --open for an unauthenticated management connection");
40
+ const token = (opts.tokenStdin ? await io.stdin() : await io.token()).trim();
41
+ if (!token || /\s/.test(token) || token.length > 16384)
42
+ throw new Error("Supply one nonempty Lakeshore token");
43
+ return token;
44
+ }
45
+ function publicConnection(value) {
46
+ if (!value ||
47
+ typeof value.id !== "string" ||
48
+ typeof value.slug !== "string" ||
49
+ typeof value.baseUrl !== "string" ||
50
+ typeof value.lakeshoreNs !== "string") {
51
+ throw new Error("Server did not confirm the connection; inspect the list before retrying");
52
+ }
53
+ return {
54
+ id: value.id,
55
+ name: value.name,
56
+ slug: value.slug,
57
+ baseUrl: value.baseUrl,
58
+ lakeshoreNs: value.lakeshoreNs,
59
+ accessMode: value.connectionType === "mount" ||
60
+ (value.accessMode != null && value.accessMode !== "management")
61
+ ? "queues"
62
+ : "management",
63
+ status: value.status,
64
+ hasToken: value.hasToken,
65
+ };
66
+ }
67
+ function report(value, opts) {
68
+ if (opts.json)
69
+ emitJson(value);
70
+ else
71
+ process.stdout.write(renderTable([value], ["slug", "accessMode", "baseUrl", "lakeshoreNs", "status"]) + "\n");
72
+ }
73
+ function error(err, secret) {
74
+ // Credential-bearing errors may echo even a truncated token. Never render HTTP bodies.
75
+ if (err instanceof HttpError)
76
+ fail(`Lakeshore connection request failed (HTTP ${err.status}). Check namespace permissions, connection details and server support.`);
77
+ else {
78
+ const message = err instanceof Error ? err.message : String(err);
79
+ fail(secret ? message.split(secret).join("[redacted]") : message);
80
+ }
81
+ return 1;
82
+ }
83
+ export async function runLakeshoreConnect(opts, io = input) {
84
+ let secret;
85
+ try {
86
+ const mode = opts.access ?? "management";
87
+ if (!["queues", "management"].includes(mode))
88
+ throw new Error("--access must be queues or management");
89
+ if (!opts.server)
90
+ throw new Error("Supply --server");
91
+ const url = new URL(opts.server);
92
+ if (!["http:", "https:"].includes(url.protocol) ||
93
+ url.username ||
94
+ url.password ||
95
+ url.search ||
96
+ url.hash)
97
+ throw new Error("Supply an HTTP(S) server URL without credentials, query or fragment");
98
+ if (opts.open && opts.tokenStdin)
99
+ throw new Error("Choose --open or --token-stdin");
100
+ if (mode === "queues" &&
101
+ (opts.open ||
102
+ opts.skipValidation ||
103
+ url.protocol !== "https:" ||
104
+ url.pathname !== "/"))
105
+ throw new Error("Queue connections require a public HTTPS origin, a namespace token and identity verification");
106
+ const c = await context(opts);
107
+ if (mode === "queues") {
108
+ const capabilities = await requestJson(c.remote, `/namespaces/${encodeURIComponent(c.ns)}/lakeshore-connection-capabilities`, { token: c.token });
109
+ if (capabilities.modelVersion !== 1 ||
110
+ !capabilities.accessModes?.includes("queues"))
111
+ throw new Error("Server does not support unified queue connections; upgrade it or use the compatibility queues mount command");
112
+ }
113
+ if (!opts.open)
114
+ secret = await credential(opts, io);
115
+ const row = publicConnection(await requestJson(c.remote, c.path + (mode === "queues" ? "/connect-v1" : ""), {
116
+ token: c.token,
117
+ method: "POST",
118
+ redirect: "error",
119
+ json: {
120
+ name: opts.name?.trim() || url.hostname,
121
+ baseUrl: opts.server,
122
+ lakeshoreNs: opts.lakeshoreNamespace ?? "default",
123
+ accessMode: mode,
124
+ description: opts.description,
125
+ skipValidation: !!opts.skipValidation,
126
+ ...(secret ? { token: secret } : {}),
127
+ },
128
+ }));
129
+ if (row.accessMode !== mode)
130
+ throw new Error("Server did not confirm the requested access mode; inspect the connection before using it");
131
+ report(row, opts);
132
+ return 0;
133
+ }
134
+ catch (err) {
135
+ return error(err, secret);
136
+ }
137
+ }
138
+ export async function runLakeshoreConnection(action, id, opts, io = input) {
139
+ let secret;
140
+ try {
141
+ const c = await context(opts);
142
+ const path = id ? `${c.path}/${encodeURIComponent(id)}` : c.path;
143
+ if (action === "list") {
144
+ const r = await requestJson(c.remote, path, {
145
+ token: c.token,
146
+ query: { page: opts.page, pageSize: opts.pageSize },
147
+ });
148
+ const rows = r.lakeshores.map(publicConnection);
149
+ if (opts.json)
150
+ emitJson({
151
+ lakeshores: rows,
152
+ page: r.page,
153
+ pageSize: r.pageSize,
154
+ total: r.total,
155
+ totalPages: r.totalPages,
156
+ });
157
+ else
158
+ process.stdout.write(renderTable(rows, [
159
+ "slug",
160
+ "accessMode",
161
+ "baseUrl",
162
+ "lakeshoreNs",
163
+ "status",
164
+ ]) + `\n${r.total} connection(s)\n`);
165
+ }
166
+ else if (action === "test") {
167
+ const r = await requestJson(c.remote, `${path}/test`, { token: c.token, method: "POST" });
168
+ if (opts.json)
169
+ emitJson({ ok: r.ok, status: r.status });
170
+ else
171
+ process.stdout.write(`Connection: ${r.ok ? "online" : "failed"}\n`);
172
+ return r.ok ? 0 : 1;
173
+ }
174
+ else if (action === "disconnect") {
175
+ if (!opts.yes &&
176
+ !(await confirm(`Disconnect ${id} from ${c.ns}? Hosts and the remote server are not deleted.`, false)))
177
+ return 0;
178
+ const r = await requestJson(c.remote, path, {
179
+ token: c.token,
180
+ method: "DELETE",
181
+ });
182
+ if (!r.success)
183
+ throw new Error("Server did not confirm disconnection");
184
+ if (opts.json)
185
+ emitJson({ success: true });
186
+ else
187
+ process.stdout.write("Disconnected. Remote tokens and existing Vault entries are retained.\n");
188
+ }
189
+ else if (action === "update") {
190
+ if (opts.clearToken && opts.tokenStdin)
191
+ throw new Error("Choose --clear-token or --token-stdin");
192
+ const body = {};
193
+ for (const [key, value] of Object.entries({
194
+ name: opts.name,
195
+ baseUrl: opts.server,
196
+ lakeshoreNs: opts.lakeshoreNamespace,
197
+ description: opts.description,
198
+ skipValidation: opts.skipValidation,
199
+ }))
200
+ if (value !== undefined)
201
+ body[key] = value;
202
+ if (opts.tokenStdin) {
203
+ secret = await credential(opts, io);
204
+ body.token = secret;
205
+ }
206
+ if (opts.clearToken)
207
+ body.token = null;
208
+ if (!Object.keys(body).length)
209
+ throw new Error("Supply fields to update or --token-stdin to replace the token");
210
+ report(publicConnection(await requestJson(c.remote, path, {
211
+ token: c.token,
212
+ method: "PATCH",
213
+ redirect: "error",
214
+ json: body,
215
+ })), opts);
216
+ }
217
+ else
218
+ report(publicConnection(await requestJson(c.remote, path, { token: c.token })), opts);
219
+ return 0;
220
+ }
221
+ catch (err) {
222
+ return error(err, secret);
223
+ }
224
+ }
225
+ export function registerLakeshoreCommand(program) {
226
+ const group = program
227
+ .command("lakeshore")
228
+ .description("Connect and manage Lakeshore services through DreamLake");
229
+ const common = (command) => command
230
+ .option("--namespace <slug>", "DreamLake namespace")
231
+ .option("--json", "JSON output");
232
+ common(group
233
+ .command("connect")
234
+ .description("Create the same connection as the web Connect form"))
235
+ .option("--name <name>", "Defaults to the server hostname")
236
+ .requiredOption("--server <url>")
237
+ .option("--lakeshore-namespace <name>", "Remote Lakeshore namespace", "default")
238
+ .addOption(new Option("--access <mode>", "Allowed uses; does not grant token permissions")
239
+ .choices(["management", "queues"])
240
+ .default("management"))
241
+ .option("--description <text>")
242
+ .option("--token-stdin", "Read Lakeshore token from stdin")
243
+ .option("--open", "No token (management only)")
244
+ .option("--skip-validation", "Skip probe (management only)")
245
+ .action(async (opts) => {
246
+ process.exitCode = await runLakeshoreConnect(opts);
247
+ });
248
+ common(group.command("list").option("--page <n>").option("--page-size <n>")).action(async (opts) => {
249
+ process.exitCode = await runLakeshoreConnection("list", undefined, opts);
250
+ });
251
+ for (const action of ["show", "test", "update", "disconnect"]) {
252
+ const command = common(group.command(`${action} <connection>`));
253
+ if (action === "update")
254
+ command
255
+ .option("--name <name>")
256
+ .option("--server <url>")
257
+ .option("--lakeshore-namespace <name>")
258
+ .option("--description <text>")
259
+ .option("--token-stdin")
260
+ .option("--clear-token", "Clear token (management only)")
261
+ .option("--skip-validation");
262
+ if (action === "disconnect")
263
+ command.option("--yes", "Skip confirmation");
264
+ command.action(async (id, opts) => {
265
+ process.exitCode = await runLakeshoreConnection(action, id, opts);
266
+ });
267
+ }
268
+ }
@@ -1 +1 @@
1
- export declare const VERSION = "0.106.0";
1
+ export declare const VERSION = "0.107.0";
@@ -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.106.0";
9
+ export const VERSION = "0.107.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.106.0",
3
+ "version": "0.107.0",
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.106.0",
40
- "@dreamlake/dreamlake-cli-darwin-x64": "0.106.0",
41
- "@dreamlake/dreamlake-cli-linux-x64": "0.106.0",
42
- "@dreamlake/dreamlake-cli-linux-arm64": "0.106.0",
43
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.106.0",
44
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.106.0",
45
- "@dreamlake/dreamlake-cli-win32-x64": "0.106.0",
46
- "@dreamlake/dreamlake-cli-win32-arm64": "0.106.0"
39
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.107.0",
40
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.107.0",
41
+ "@dreamlake/dreamlake-cli-linux-x64": "0.107.0",
42
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.107.0",
43
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.107.0",
44
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.107.0",
45
+ "@dreamlake/dreamlake-cli-win32-x64": "0.107.0",
46
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.107.0"
47
47
  }
48
48
  }