@project-ajax/cli 0.0.17 → 0.0.19

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.
Files changed (51) hide show
  1. package/dist/commands/auth.d.ts.map +1 -1
  2. package/dist/commands/auth.impl.d.ts +12 -2
  3. package/dist/commands/auth.impl.d.ts.map +1 -1
  4. package/dist/commands/auth.impl.js +73 -6
  5. package/dist/commands/auth.js +39 -2
  6. package/dist/commands/capabilities.impl.d.ts +1 -1
  7. package/dist/commands/capabilities.impl.d.ts.map +1 -1
  8. package/dist/commands/capabilities.impl.js +7 -1
  9. package/dist/commands/delete.d.ts +3 -0
  10. package/dist/commands/delete.d.ts.map +1 -0
  11. package/dist/commands/delete.impl.d.ts +7 -0
  12. package/dist/commands/delete.impl.d.ts.map +1 -0
  13. package/dist/commands/delete.impl.js +26 -0
  14. package/dist/commands/delete.impl.test.d.ts +2 -0
  15. package/dist/commands/delete.impl.test.d.ts.map +1 -0
  16. package/dist/commands/delete.js +31 -0
  17. package/dist/commands/deploy.js +1 -1
  18. package/dist/commands/list.d.ts +3 -0
  19. package/dist/commands/list.d.ts.map +1 -0
  20. package/dist/commands/list.impl.d.ts +3 -0
  21. package/dist/commands/list.impl.d.ts.map +1 -0
  22. package/dist/commands/list.impl.js +41 -0
  23. package/dist/commands/list.impl.test.d.ts +2 -0
  24. package/dist/commands/list.impl.test.d.ts.map +1 -0
  25. package/dist/commands/list.js +17 -0
  26. package/dist/commands/oauth.impl.d.ts +1 -1
  27. package/dist/commands/oauth.impl.d.ts.map +1 -1
  28. package/dist/commands/oauth.impl.js +11 -3
  29. package/dist/commands/runs.impl.d.ts +1 -1
  30. package/dist/commands/runs.impl.d.ts.map +1 -1
  31. package/dist/commands/runs.impl.js +7 -1
  32. package/dist/commands/secrets.impl.d.ts +1 -1
  33. package/dist/commands/secrets.impl.d.ts.map +1 -1
  34. package/dist/commands/secrets.impl.js +7 -1
  35. package/dist/commands/utils/testing.d.ts +4 -2
  36. package/dist/commands/utils/testing.d.ts.map +1 -1
  37. package/dist/commands/utils/testing.js +23 -10
  38. package/dist/config.d.ts +126 -7
  39. package/dist/config.d.ts.map +1 -1
  40. package/dist/config.js +206 -37
  41. package/dist/flags.d.ts +5 -0
  42. package/dist/flags.d.ts.map +1 -1
  43. package/dist/flags.js +34 -1
  44. package/dist/handler.d.ts.map +1 -1
  45. package/dist/handler.js +9 -3
  46. package/dist/routes.d.ts.map +1 -1
  47. package/dist/routes.js +39 -5
  48. package/dist/token.d.ts +7 -0
  49. package/dist/token.d.ts.map +1 -1
  50. package/dist/token.js +10 -1
  51. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,wEAmCvB,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,wEA0EvB,CAAC"}
@@ -1,6 +1,16 @@
1
1
  import type { GlobalFlags } from "../flags.js";
2
2
  import { type HandlerContext } from "../handler.js";
3
- export declare function runLogin(context: HandlerContext): Promise<void>;
4
- export declare const login: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
3
+ export declare function runLogin(context: HandlerContext, options?: {
4
+ noSetDefault?: boolean;
5
+ }): Promise<void>;
6
+ interface LoginFlags {
7
+ "no-set-default": boolean;
8
+ }
9
+ export declare const login: (this: import("../context.js").LocalContext, flags: GlobalFlags & LoginFlags) => Promise<void>;
5
10
  export declare const show: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
11
+ interface LogoutFlags {
12
+ all: boolean;
13
+ }
14
+ export declare const logout: (this: import("../context.js").LocalContext, flags: GlobalFlags & LogoutFlags, spaceId?: string | undefined) => Promise<void>;
15
+ export {};
6
16
  //# sourceMappingURL=auth.impl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AA2ElE,wBAAsB,QAAQ,CAAC,OAAO,EAAE,cAAc,iBA2CrD;AA0ED,eAAO,MAAM,KAAK,mFAKhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAGf,CAAC"}
1
+ {"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAiHlE,wBAAsB,QAAQ,CAC7B,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,iBA+CxC;AAiFD,UAAU,UAAU;IACnB,gBAAgB,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,KAAK,gGAKhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAGf,CAAC;AAEH,UAAU,WAAW;IACpB,GAAG,EAAE,OAAO,CAAC;CACb;AAED,eAAO,MAAM,MAAM,+HAuDjB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { buildHandler } from "../handler.js";
2
- import { fetchToken, parseToken } from "../token.js";
2
+ import { deleteToken, fetchToken, parseToken } from "../token.js";
3
3
  import { openNotionUrl } from "../utils/openUrl.js";
4
4
  const NEW_SPACE_VALUE = "__new_space__";
5
5
  async function loginFetch(baseUrl, endpoint, body) {
@@ -32,7 +32,27 @@ async function pollLoginRedeem(baseUrl, sessionId, timeoutMs = 3e5, intervalMs =
32
32
  }
33
33
  return { status: "expired" };
34
34
  }
35
- async function runLogin(context) {
35
+ async function maybeUpdateDefaultSpace(context, spaceId) {
36
+ const currentDefault = context.config.defaultSpaceId;
37
+ if (currentDefault === null) {
38
+ context.config.setDefaultSpaceId(spaceId);
39
+ return;
40
+ }
41
+ if (currentDefault === spaceId) {
42
+ return;
43
+ }
44
+ if (process.stdin.isTTY) {
45
+ const shouldUpdate = await context.io.confirm({
46
+ message: "Set this as your default space?",
47
+ default: false,
48
+ noTTY: "Cannot prompt to update default space in non-TTY mode."
49
+ });
50
+ if (shouldUpdate) {
51
+ context.config.setDefaultSpaceId(spaceId);
52
+ }
53
+ }
54
+ }
55
+ async function runLogin(context, options = {}) {
36
56
  const cachedSpaces = context.config.getCachedSpaces();
37
57
  if (process.stdin.isTTY && cachedSpaces.length > 0) {
38
58
  const choices = [
@@ -55,6 +75,9 @@ async function runLogin(context) {
55
75
  const token = await fetchToken(spaceId);
56
76
  if (token) {
57
77
  context.config.switchToSpace(spaceId);
78
+ if (!options.noSetDefault) {
79
+ await maybeUpdateDefaultSpace(context, spaceId);
80
+ }
58
81
  const space = cachedSpaces.find((s) => s.id === spaceId);
59
82
  context.io.writeErr(`Switched to space: ${space?.name ?? spaceId}`);
60
83
  return;
@@ -64,9 +87,9 @@ async function runLogin(context) {
64
87
  );
65
88
  }
66
89
  }
67
- await runBrowserLogin(context);
90
+ await runBrowserLogin(context, options);
68
91
  }
69
- async function runBrowserLogin(context) {
92
+ async function runBrowserLogin(context, options = {}) {
70
93
  const environment = context.config.environment;
71
94
  const baseURL = context.config.baseURL;
72
95
  context.io.writeErr("Starting browser login...\n");
@@ -121,17 +144,61 @@ async function runBrowserLogin(context) {
121
144
  spaceName: redeemResponse.spaceName,
122
145
  cellId: tokenInfo.cellId
123
146
  });
147
+ if (!options.noSetDefault) {
148
+ await maybeUpdateDefaultSpace(context, tokenInfo.spaceId);
149
+ }
124
150
  context.io.writeErr("Logged in.");
125
151
  }
126
- const login = buildHandler(async function(_) {
127
- await runLogin(this);
152
+ const login = buildHandler(async function(flags) {
153
+ await runLogin(this, { noSetDefault: flags["no-set-default"] });
128
154
  });
129
155
  const show = buildHandler(async function() {
130
156
  const tokenAndInfo = await this.config.getToken();
131
157
  this.io.writeOut(`${tokenAndInfo?.[0] ?? ""}`);
132
158
  });
159
+ const logout = buildHandler(async function(flags, spaceId) {
160
+ if (flags.all) {
161
+ const cachedSpaces2 = this.config.getCachedSpaces();
162
+ if (cachedSpaces2.length === 0) {
163
+ this.io.writeErr("No authenticated spaces found.");
164
+ return;
165
+ }
166
+ this.io.writeErr(`Logging out from ${cachedSpaces2.length} space(s)...`);
167
+ let deletedCount = 0;
168
+ for (const space2 of cachedSpaces2) {
169
+ const deleted2 = await deleteToken(space2.id);
170
+ if (deleted2) {
171
+ deletedCount++;
172
+ this.io.writeErr(` Logged out from "${space2.name}"`);
173
+ }
174
+ }
175
+ if (deletedCount > 0) {
176
+ this.io.writeErr(`Logged out from ${deletedCount} space(s).`);
177
+ } else {
178
+ this.io.writeErr("No tokens found to remove.");
179
+ }
180
+ return;
181
+ }
182
+ const targetSpaceId = spaceId ?? this.config.spaceId;
183
+ if (!targetSpaceId) {
184
+ this.io.writeErr(
185
+ "No space specified and no default space configured. Use 'workers auth logout <spaceId>' or 'workers auth logout --all'."
186
+ );
187
+ return;
188
+ }
189
+ const cachedSpaces = this.config.getCachedSpaces();
190
+ const space = cachedSpaces.find((s) => s.id === targetSpaceId);
191
+ const spaceName = space?.name ?? targetSpaceId;
192
+ const deleted = await deleteToken(targetSpaceId);
193
+ if (deleted) {
194
+ this.io.writeErr(`Logged out from "${spaceName}".`);
195
+ } else {
196
+ this.io.writeErr(`No token found for "${spaceName}".`);
197
+ }
198
+ });
133
199
  export {
134
200
  login,
201
+ logout,
135
202
  runLogin,
136
203
  show
137
204
  };
@@ -7,14 +7,19 @@ const authCommands = buildRouteMap({
7
7
  routes: {
8
8
  login: buildCommand({
9
9
  docs: {
10
- brief: "Login to the Project Ajax platform via browser authentication",
10
+ brief: "Login to the Notion Workers platform via browser authentication",
11
11
  fullDescription: `
12
12
  Opens a browser window for you to authenticate and select a workspace.
13
13
  `.trim()
14
14
  },
15
15
  parameters: {
16
16
  flags: {
17
- ...globalFlags
17
+ ...globalFlags,
18
+ "no-set-default": {
19
+ kind: "boolean",
20
+ brief: "Do not update the global default space",
21
+ default: false
22
+ }
18
23
  }
19
24
  },
20
25
  loader: () => import("./auth.impl.js").then((m) => m.login)
@@ -29,6 +34,38 @@ Opens a browser window for you to authenticate and select a workspace.
29
34
  }
30
35
  },
31
36
  loader: () => import("./auth.impl.js").then((m) => m.show)
37
+ }),
38
+ logout: buildCommand({
39
+ docs: {
40
+ brief: "Log out from a space",
41
+ fullDescription: `Removes authentication token from the system keychain.
42
+
43
+ By default, logs out from the current space (from local config or default space).
44
+ Use a space ID argument to log out from a specific space.
45
+ Use --all to log out from all authenticated spaces.`
46
+ },
47
+ parameters: {
48
+ positional: {
49
+ kind: "tuple",
50
+ parameters: [
51
+ {
52
+ brief: "The space ID to log out from (optional)",
53
+ parse: String,
54
+ placeholder: "spaceId",
55
+ optional: true
56
+ }
57
+ ]
58
+ },
59
+ flags: {
60
+ ...globalFlags,
61
+ all: {
62
+ kind: "boolean",
63
+ brief: "Log out from all spaces",
64
+ default: false
65
+ }
66
+ }
67
+ },
68
+ loader: () => import("./auth.impl.js").then((m) => m.logout)
32
69
  })
33
70
  }
34
71
  });
@@ -1,4 +1,4 @@
1
- import type { FormatFlags, GlobalFlags } from "../flags.js";
1
+ import { type FormatFlags, type GlobalFlags } from "../flags.js";
2
2
  export declare const listCapabilities: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
3
3
  export declare const enableCapability: (this: import("../context.js").LocalContext, flags: GlobalFlags, capabilityKey: string) => Promise<void>;
4
4
  export declare const disableCapability: (this: import("../context.js").LocalContext, flags: GlobalFlags, capabilityKey: string) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.impl.d.ts","sourceRoot":"","sources":["../../src/commands/capabilities.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG5D,eAAO,MAAM,gBAAgB,iGA0C3B,CAAC;AAEH,eAAO,MAAM,gBAAgB,0GAiC3B,CAAC;AAEH,eAAO,MAAM,iBAAiB,0GAiC5B,CAAC"}
1
+ {"version":3,"file":"capabilities.impl.d.ts","sourceRoot":"","sources":["../../src/commands/capabilities.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAGhF,eAAO,MAAM,gBAAgB,iGA+C3B,CAAC;AAEH,eAAO,MAAM,gBAAgB,0GAiC3B,CAAC;AAEH,eAAO,MAAM,iBAAiB,0GAiC5B,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { Result } from "../api/result.js";
2
+ import { resolveFormat } from "../flags.js";
2
3
  import { buildAuthedHandler } from "../handler.js";
3
4
  const listCapabilities = buildAuthedHandler(async function(flags) {
5
+ const format = resolveFormat(flags, this.process);
4
6
  const { workerId } = this.config;
5
7
  if (!workerId) {
6
8
  throw new Error(
@@ -12,6 +14,10 @@ const listCapabilities = buildAuthedHandler(async function(flags) {
12
14
  if (Result.isSuccess(result)) {
13
15
  this.process.stderr.write("OK\n\n");
14
16
  const data = Result.unwrap(result);
17
+ if (format === "json") {
18
+ this.io.writeOut(JSON.stringify(data.capabilities, null, 2));
19
+ return;
20
+ }
15
21
  if (data.capabilities.length === 0) {
16
22
  this.io.writeErr("No capabilities found for this worker.");
17
23
  } else {
@@ -21,7 +27,7 @@ const listCapabilities = buildAuthedHandler(async function(flags) {
21
27
  capability.key,
22
28
  capability._tag
23
29
  ]),
24
- plain: flags.plain
30
+ plain: format === "plain"
25
31
  });
26
32
  }
27
33
  } else {
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@stricli/core").Command<import("../context.js").LocalContext>;
2
+ export default _default;
3
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";AAGA,wBAyBG"}
@@ -0,0 +1,7 @@
1
+ import type { GlobalFlags } from "../flags.js";
2
+ interface DeleteFlags {
3
+ yes: boolean;
4
+ }
5
+ export declare const deleteWorker: (this: import("../context.js").LocalContext, flags: GlobalFlags & DeleteFlags, workerId: string) => Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=delete.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.impl.d.ts","sourceRoot":"","sources":["../../src/commands/delete.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,UAAU,WAAW;IACpB,GAAG,EAAE,OAAO,CAAC;CACb;AAED,eAAO,MAAM,YAAY,mHA2BvB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Result } from "../api/result.js";
2
+ import { buildAuthedHandler } from "../handler.js";
3
+ const deleteWorker = buildAuthedHandler(async function(flags, workerId) {
4
+ if (!flags.yes) {
5
+ const confirmed = await this.io.confirm({
6
+ message: `Are you sure you want to delete worker "${workerId}"?`,
7
+ noTTY: `Cannot delete worker "${workerId}" without confirmation. Use --yes to skip confirmation.`
8
+ });
9
+ if (!confirmed) {
10
+ this.io.writeErr("Aborted.");
11
+ return;
12
+ }
13
+ }
14
+ this.io.writeErr(`Deleting worker "${workerId}"...`);
15
+ const result = await this.apiClient.deleteWorker(workerId);
16
+ if (Result.isSuccess(result)) {
17
+ this.io.writeErr(`\u2713 Successfully deleted worker "${workerId}"`);
18
+ } else {
19
+ this.io.writeErr(`\u2717 Failed to delete worker "${workerId}"`);
20
+ this.io.writeErr(`\u2717 ${result.error.message}`);
21
+ throw new Error(result.error.message);
22
+ }
23
+ });
24
+ export {
25
+ deleteWorker
26
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=delete.impl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/delete.impl.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { buildCommand } from "@stricli/core";
2
+ import { globalFlags } from "../flags.js";
3
+ var delete_default = buildCommand({
4
+ docs: {
5
+ brief: "Delete a worker"
6
+ },
7
+ parameters: {
8
+ positional: {
9
+ kind: "tuple",
10
+ parameters: [
11
+ {
12
+ brief: "The worker ID to delete",
13
+ parse: String,
14
+ placeholder: "workerId"
15
+ }
16
+ ]
17
+ },
18
+ flags: {
19
+ ...globalFlags,
20
+ yes: {
21
+ kind: "boolean",
22
+ brief: "Skip confirmation prompt",
23
+ default: false
24
+ }
25
+ }
26
+ },
27
+ loader: () => import("./delete.impl.js").then((m) => m.deleteWorker)
28
+ });
29
+ export {
30
+ delete_default as default
31
+ };
@@ -2,7 +2,7 @@ import { buildCommand } from "@stricli/core";
2
2
  import { globalFlags } from "../flags.js";
3
3
  var deploy_default = buildCommand({
4
4
  docs: {
5
- brief: "Deploy a worker to the Project Ajax platform"
5
+ brief: "Deploy a worker to the Notion Workers platform"
6
6
  },
7
7
  parameters: {
8
8
  flags: {
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@stricli/core").Command<import("../context.js").LocalContext>;
2
+ export default _default;
3
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";AAGA,wBAaG"}
@@ -0,0 +1,3 @@
1
+ import { type FormatFlags } from "../flags.js";
2
+ export declare const listWorkers: (this: import("../context.js").LocalContext, flags: import("../flags.js").GlobalFlags & FormatFlags) => Promise<void>;
3
+ //# sourceMappingURL=list.impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.impl.d.ts","sourceRoot":"","sources":["../../src/commands/list.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAG9D,eAAO,MAAM,WAAW,uHA6CtB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { Result } from "../api/result.js";
2
+ import { resolveFormat } from "../flags.js";
3
+ import { buildAuthedHandler } from "../handler.js";
4
+ const listWorkers = buildAuthedHandler(async function(flags) {
5
+ const format = resolveFormat(flags, this.process);
6
+ this.process.stderr.write("Fetching workers...");
7
+ const result = await this.apiClient.listWorkers();
8
+ if (Result.isSuccess(result)) {
9
+ this.process.stderr.write("OK\n\n");
10
+ const data = Result.unwrap(result);
11
+ if (format === "json") {
12
+ this.io.writeOut(JSON.stringify(data.workers, null, 2));
13
+ return;
14
+ }
15
+ if (data.workers.length === 0) {
16
+ this.io.writeErr("No workers found for this space.");
17
+ return;
18
+ }
19
+ this.io.writeTableOut({
20
+ headers: ["Worker ID", "Name", "Created At", "Updated At"],
21
+ rows: data.workers.map((worker) => [
22
+ worker.workerId,
23
+ worker.name,
24
+ worker.createdAt,
25
+ worker.updatedAt
26
+ ]),
27
+ plain: format === "plain"
28
+ });
29
+ } else {
30
+ this.process.stderr.write("ERROR\n\n");
31
+ if (result.error.validationError) {
32
+ this.io.writeErr(`\u2717 ${result.error.validationError.debugMessage}`);
33
+ throw new Error(result.error.validationError.debugMessage);
34
+ }
35
+ this.io.writeErr(`\u2717 ${result.error.message}`);
36
+ throw new Error(result.error.message);
37
+ }
38
+ });
39
+ export {
40
+ listWorkers
41
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=list.impl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/list.impl.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { buildCommand } from "@stricli/core";
2
+ import { formatFlags, globalFlags } from "../flags.js";
3
+ var list_default = buildCommand({
4
+ docs: {
5
+ brief: "List all workers in the current space"
6
+ },
7
+ parameters: {
8
+ flags: {
9
+ ...globalFlags,
10
+ ...formatFlags
11
+ }
12
+ },
13
+ loader: () => import("./list.impl.js").then((m) => m.listWorkers)
14
+ });
15
+ export {
16
+ list_default as default
17
+ };
@@ -1,3 +1,3 @@
1
- import type { FormatFlags, GlobalFlags } from "../flags.js";
1
+ import { type FormatFlags, type GlobalFlags } from "../flags.js";
2
2
  export declare const startOauth: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags, capabilityKey: string | undefined) => Promise<void>;
3
3
  //# sourceMappingURL=oauth.impl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/oauth.impl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI5D,eAAO,MAAM,UAAU,oIA+ErB,CAAC"}
1
+ {"version":3,"file":"oauth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/oauth.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,WAAW,EAGhB,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,UAAU,oIAgFrB,CAAC"}
@@ -1,13 +1,17 @@
1
1
  import { Result } from "../api/result.js";
2
+ import {
3
+ resolveFormat
4
+ } from "../flags.js";
2
5
  import { buildAuthedHandler } from "../handler.js";
3
6
  import { openBrowserUrl } from "../utils/openUrl.js";
4
7
  const startOauth = buildAuthedHandler(async function(flags, capabilityKey) {
5
8
  const workerId = requireWorkerId(this);
9
+ const format = resolveFormat(flags, this.process);
6
10
  if (!capabilityKey) {
7
11
  const oauthCapabilityKeys = await fetchOauthCapabilityKeys(
8
12
  this,
9
13
  workerId,
10
- flags.plain
14
+ format
11
15
  );
12
16
  if (oauthCapabilityKeys.length === 0) {
13
17
  this.process.exitCode = 1;
@@ -78,7 +82,7 @@ function reportApiError(context, error, action) {
78
82
  context.io.writeErr(`\u2717 ${error.message}`);
79
83
  throw new Error(error.message);
80
84
  }
81
- async function fetchOauthCapabilityKeys(context, workerId, plain) {
85
+ async function fetchOauthCapabilityKeys(context, workerId, format) {
82
86
  context.process.stderr.write("Fetching OAuth capabilities...");
83
87
  const capabilitiesResult = await context.apiClient.listCapabilities(workerId);
84
88
  if (Result.isFail(capabilitiesResult)) {
@@ -96,11 +100,15 @@ async function fetchOauthCapabilityKeys(context, workerId, plain) {
96
100
  );
97
101
  return [];
98
102
  }
103
+ if (format === "json") {
104
+ context.io.writeOut(JSON.stringify(oauthCaps, null, 2));
105
+ return oauthCaps.map((cap) => cap.key);
106
+ }
99
107
  context.io.writeErr("OAuth capabilities:");
100
108
  context.io.writeTableErr({
101
109
  headers: ["Key"],
102
110
  rows: oauthCaps.map((cap) => [cap.key]),
103
- plain
111
+ plain: format === "plain"
104
112
  });
105
113
  context.io.writeErr("");
106
114
  return oauthCaps.map((cap) => cap.key);
@@ -1,4 +1,4 @@
1
- import type { FormatFlags, GlobalFlags } from "../flags.js";
1
+ import { type FormatFlags, type GlobalFlags } from "../flags.js";
2
2
  export declare const listRuns: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
3
3
  export declare const getRunLogs: (this: import("../context.js").LocalContext, flags: GlobalFlags, runId: string) => Promise<void>;
4
4
  //# sourceMappingURL=runs.impl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runs.impl.d.ts","sourceRoot":"","sources":["../../src/commands/runs.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG5D,eAAO,MAAM,QAAQ,iGA2CnB,CAAC;AAEH,eAAO,MAAM,UAAU,kGAqCrB,CAAC"}
1
+ {"version":3,"file":"runs.impl.d.ts","sourceRoot":"","sources":["../../src/commands/runs.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAGhF,eAAO,MAAM,QAAQ,iGAgDnB,CAAC;AAEH,eAAO,MAAM,UAAU,kGAqCrB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { Result } from "../api/result.js";
2
+ import { resolveFormat } from "../flags.js";
2
3
  import { buildAuthedHandler } from "../handler.js";
3
4
  const listRuns = buildAuthedHandler(async function(flags) {
5
+ const format = resolveFormat(flags, this.process);
4
6
  const { workerId } = this.config;
5
7
  if (!workerId) {
6
8
  throw new Error(
@@ -12,6 +14,10 @@ const listRuns = buildAuthedHandler(async function(flags) {
12
14
  if (Result.isSuccess(result)) {
13
15
  this.process.stderr.write("OK\n\n");
14
16
  const data = Result.unwrap(result);
17
+ if (format === "json") {
18
+ this.io.writeOut(JSON.stringify(data.runs, null, 2));
19
+ return;
20
+ }
15
21
  if (data.runs.length === 0) {
16
22
  this.io.writeErr("No runs found for this worker.");
17
23
  } else {
@@ -24,7 +30,7 @@ const listRuns = buildAuthedHandler(async function(flags) {
24
30
  run.endedAt,
25
31
  run.exitCode
26
32
  ]),
27
- plain: flags.plain
33
+ plain: format === "plain"
28
34
  });
29
35
  }
30
36
  } else {
@@ -1,4 +1,4 @@
1
- import type { FormatFlags, GlobalFlags } from "../flags.js";
1
+ import { type FormatFlags, type GlobalFlags } from "../flags.js";
2
2
  export declare const setSecrets: (this: import("../context.js").LocalContext, flags: GlobalFlags, ...args: string[]) => Promise<void>;
3
3
  export declare const listSecrets: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
4
4
  export declare const removeSecret: (this: import("../context.js").LocalContext, flags: GlobalFlags, key: string) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.impl.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI5D,eAAO,MAAM,UAAU,sGA0BrB,CAAC;AAEH,eAAO,MAAM,WAAW,iGAkCtB,CAAC;AAEH,eAAO,MAAM,YAAY,gGAwBvB,CAAC;AAQH;;GAEG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACrB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAoBvC"}
1
+ {"version":3,"file":"secrets.impl.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAiB,MAAM,aAAa,CAAC;AAIhF,eAAO,MAAM,UAAU,sGA0BrB,CAAC;AAEH,eAAO,MAAM,WAAW,iGAuCtB,CAAC;AAEH,eAAO,MAAM,YAAY,gGAwBvB,CAAC;AAQH;;GAEG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACrB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAoBvC"}
@@ -1,4 +1,5 @@
1
1
  import { Result } from "../api/result.js";
2
+ import { resolveFormat } from "../flags.js";
2
3
  import { buildAuthedHandler } from "../handler.js";
3
4
  import { pluralize } from "../utils/string.js";
4
5
  const setSecrets = buildAuthedHandler(async function(_flags, ...args) {
@@ -22,6 +23,7 @@ const setSecrets = buildAuthedHandler(async function(_flags, ...args) {
22
23
  }
23
24
  });
24
25
  const listSecrets = buildAuthedHandler(async function(flags) {
26
+ const format = resolveFormat(flags, this.process);
25
27
  const { workerId } = this.config;
26
28
  if (!workerId) {
27
29
  throw new Error(
@@ -33,13 +35,17 @@ const listSecrets = buildAuthedHandler(async function(flags) {
33
35
  if (Result.isSuccess(result)) {
34
36
  this.process.stderr.write("OK\n\n");
35
37
  const data = Result.unwrap(result);
38
+ if (format === "json") {
39
+ this.io.writeOut(JSON.stringify(data.secrets, null, 2));
40
+ return;
41
+ }
36
42
  if (data.secrets.length === 0) {
37
43
  this.io.writeErr("No secrets for this worker.");
38
44
  } else {
39
45
  this.io.writeTableOut({
40
46
  headers: ["Key", "Created At"],
41
47
  rows: data.secrets.map((secret) => [secret.key, secret.createdAt]),
42
- plain: flags.plain
48
+ plain: format === "plain"
43
49
  });
44
50
  }
45
51
  } else {
@@ -1,14 +1,16 @@
1
- import { Config, type LocalConfig, type SpaceCache } from "../../config.js";
1
+ import { Config, type GlobalConfig, type LocalConfig, type SpaceCache } from "../../config.js";
2
2
  import type { LocalContext } from "../../context.js";
3
3
  import type { GlobalFlags } from "../../flags.js";
4
4
  import type { TokenInfo } from "../../token.js";
5
5
  export declare const baseFlags: GlobalFlags;
6
6
  export declare function preventConfigResolution(): void;
7
7
  export declare function createAndLoadConfig(args?: {
8
- globalConfig?: SpaceCache;
8
+ userConfig?: GlobalConfig;
9
+ spaceCache?: SpaceCache;
9
10
  localConfig?: LocalConfig;
10
11
  env?: Partial<NodeJS.ProcessEnv>;
11
12
  flags?: Partial<GlobalFlags>;
13
+ spaceOverride?: string | null;
12
14
  }): Promise<Config>;
13
15
  export declare function createBaseContext(): LocalContext;
14
16
  export declare function cleanupTmpDirectories(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/testing.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,WAEvB,CAAC;AAEF,wBAAgB,uBAAuB,SAGtC;AAED,wBAAsB,mBAAmB,CACxC,IAAI,GAAE;IACL,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACxB,GACJ,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD;AAID,wBAAsB,qBAAqB,kBAU1C;AA2BD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,EAChD,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAoB,GACxC,CAAC,MAAM,EAAE,SAAS,CAAC,CAuBrB"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/testing.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,MAAM,EACN,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,WAEvB,CAAC;AAEF,wBAAgB,uBAAuB,SAItC;AAED,wBAAsB,mBAAmB,CACxC,IAAI,GAAE;IACL,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,GACJ,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD;AAID,wBAAsB,qBAAqB,kBAU1C;AAmCD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,EAChD,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAoB,GACxC,CAAC,MAAM,EAAE,SAAS,CAAC,CAuBrB"}