@project-ajax/cli 0.0.7 → 0.0.9

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.
@@ -90,7 +90,7 @@ export declare class ApiClient {
90
90
  */
91
91
  fetchAndSaveCapabilities(workerId: string): Promise<Result<{
92
92
  capabilities: ReadonlyArray<{
93
- _tag: "sync" | "tool";
93
+ _tag: "sync" | "tool" | "oauth" | "automation" | "slashCommand" | "handleSearch" | "handleSelect";
94
94
  spaceId: string;
95
95
  workerId: string;
96
96
  key: string;
@@ -134,29 +134,16 @@ export declare class ApiClient {
134
134
  value: string;
135
135
  }>;
136
136
  }, ApiError>>;
137
- listOauthProviders(): Promise<Result<{
138
- providers: Array<{
139
- key: string;
140
- displayName: string;
141
- }>;
142
- }, ApiError>>;
143
137
  /**
144
138
  * Start the OAuth flow for a provider
145
139
  */
146
140
  startOauth(args: {
147
141
  workerId: string;
148
- provider: string;
142
+ capabilityKey: string;
149
143
  }): Promise<Result<{
150
144
  authorizationUrl: string;
151
145
  state: string;
152
146
  }, ApiError>>;
153
- /**
154
- * Remove an OAuth connection for a worker
155
- */
156
- deleteOauthConnection(args: {
157
- workerId: string;
158
- provider: string;
159
- }): Promise<Result<Record<string, never>, ApiError>>;
160
147
  /**
161
148
  * Delete a secret
162
149
  */
@@ -166,10 +153,20 @@ export declare class ApiClient {
166
153
  */
167
154
  listCapabilities(workerId: string): Promise<Result<{
168
155
  capabilities: Array<{
169
- _tag: "sync" | "tool";
156
+ _tag: "sync" | "tool" | "oauth" | "automation" | "slashCommand" | "handleSearch" | "handleSelect";
170
157
  key: string;
171
158
  }>;
172
159
  }, ApiError>>;
160
+ /**
161
+ * Update the disabled status of a sync capability
162
+ */
163
+ updateSyncCapabilityDisabled(workerId: string, capabilityKey: string, disabled: boolean): Promise<Result<{
164
+ capability: {
165
+ _tag: "sync";
166
+ key: string;
167
+ disabled?: boolean;
168
+ };
169
+ }, ApiError>>;
173
170
  /**
174
171
  * Run a capability
175
172
  */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;AAE/D,UAAU,eAAe;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,EAAE,CAAC;CACX;AAID,MAAM,WAAW,QAAQ;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC;CACF;AAED;;GAEG;AACH,qBAAa,SAAS;;gBAMT,MAAM,EAAE,eAAe;IAWnC;;OAEG;YACW,KAAK;IAoEnB;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CACxC,MAAM,CACL;QACC,MAAM,EAAE;YACP,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC;YAClB,SAAS,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE,OAAO,CAAC;SACf,CAAC;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/B,EACD,QAAQ,C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IA0CjD;;OAEG;IACG,oBAAoB,CACzB,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAazE;;OAEG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CACjD,MAAM,CACL;QACC,IAAI,EAAE,KAAK,CAAC;YACX,QAAQ,EAAE,MAAM,CAAC;YACjB,OAAO,EAAE,MAAM,CAAC;YAChB,KAAK,EAAE,MAAM,CAAC;YACd,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;YACxB,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;SACvB,CAAC,CAAC;KACH,EACD,QAAQ,CACR,CACD;IASD;;OAEG;IACG,UAAU,CACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACX,OAAO,CACT,MAAM,CACL;QACC,IAAI,EAAE,MAAM,CAAC;KACb,EACD,QAAQ,CACR,CACD;CASD"}
@@ -154,12 +154,6 @@ class ApiClient {
154
154
  }
155
155
  });
156
156
  }
157
- async listOauthProviders() {
158
- return this.fetch("/workersListOauthProviders", {
159
- method: "POST",
160
- body: {}
161
- });
162
- }
163
157
  /**
164
158
  * Start the OAuth flow for a provider
165
159
  */
@@ -168,19 +162,7 @@ class ApiClient {
168
162
  method: "POST",
169
163
  body: {
170
164
  workerId: args.workerId,
171
- provider: args.provider
172
- }
173
- });
174
- }
175
- /**
176
- * Remove an OAuth connection for a worker
177
- */
178
- async deleteOauthConnection(args) {
179
- return this.fetch("/workersDeleteOauthConnection", {
180
- method: "POST",
181
- body: {
182
- workerId: args.workerId,
183
- provider: args.provider
165
+ oauthCapabilityKey: args.capabilityKey
184
166
  }
185
167
  });
186
168
  }
@@ -207,6 +189,19 @@ class ApiClient {
207
189
  }
208
190
  });
209
191
  }
192
+ /**
193
+ * Update the disabled status of a sync capability
194
+ */
195
+ async updateSyncCapabilityDisabled(workerId, capabilityKey, disabled) {
196
+ return this.fetch("/workersUpdateSyncCapabilityDisabled", {
197
+ method: "POST",
198
+ body: {
199
+ workerId,
200
+ capabilityKey,
201
+ disabled
202
+ }
203
+ });
204
+ }
210
205
  async runCapability(workerId, capabilityKey, functionName, args, stream) {
211
206
  if (stream) {
212
207
  return this.fetch(
@@ -296,7 +291,14 @@ function headersInitToEntries(headersInit) {
296
291
  }
297
292
  async function parseApiError(response) {
298
293
  const errorText = await response.text();
299
- const message = `[${response.status}] ${response.statusText}: ${errorText}`;
294
+ let displayMessage;
295
+ try {
296
+ const errorJson = JSON.parse(errorText);
297
+ displayMessage = errorJson.debugMessage ?? errorJson.message ?? errorText;
298
+ } catch {
299
+ displayMessage = errorText;
300
+ }
301
+ const message = `[${response.status}] ${response.statusText}: ${displayMessage}`;
300
302
  const error = {
301
303
  status: response.status,
302
304
  statusText: response.statusText,
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/commands/capabilities.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,wEAqB/B,CAAC"}
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/commands/capabilities.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,wEAuE/B,CAAC"}
@@ -1,3 +1,5 @@
1
- import type { FormatFlags } from "../flags.js";
2
- export declare const listCapabilities: (this: import("../context.js").LocalContext, flags: import("../flags.js").GlobalFlags & FormatFlags) => Promise<void>;
1
+ import type { FormatFlags, GlobalFlags } from "../flags.js";
2
+ export declare const listCapabilities: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
3
+ export declare const enableCapability: (this: import("../context.js").LocalContext, flags: GlobalFlags, capabilityKey: string) => Promise<void>;
4
+ export declare const disableCapability: (this: import("../context.js").LocalContext, flags: GlobalFlags, capabilityKey: string) => Promise<void>;
3
5
  //# sourceMappingURL=capabilities.impl.d.ts.map
@@ -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,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,gBAAgB,uHA0C3B,CAAC"}
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"}
@@ -35,6 +35,62 @@ const listCapabilities = buildAuthedHandler(async function(flags) {
35
35
  }
36
36
  }
37
37
  });
38
+ const enableCapability = buildAuthedHandler(async function(_flags, capabilityKey) {
39
+ const { workerId } = this.config;
40
+ if (!workerId) {
41
+ throw new Error(
42
+ "No worker configured. Run 'workers deploy' first to create a worker."
43
+ );
44
+ }
45
+ this.process.stderr.write(`Enabling capability "${capabilityKey}"...`);
46
+ const result = await this.apiClient.updateSyncCapabilityDisabled(
47
+ workerId,
48
+ capabilityKey,
49
+ false
50
+ );
51
+ if (Result.isSuccess(result)) {
52
+ this.process.stderr.write("OK\n\n");
53
+ this.io.writeErr(`\u2713 Capability "${capabilityKey}" is now enabled`);
54
+ } else {
55
+ this.process.stderr.write("ERROR\n\n");
56
+ if (result.error.validationError) {
57
+ this.io.writeErr(`\u2717 ${result.error.validationError.debugMessage}`);
58
+ throw new Error(result.error.validationError.debugMessage);
59
+ } else {
60
+ this.io.writeErr(`\u2717 ${result.error.message}`);
61
+ throw new Error(result.error.message);
62
+ }
63
+ }
64
+ });
65
+ const disableCapability = buildAuthedHandler(async function(_flags, capabilityKey) {
66
+ const { workerId } = this.config;
67
+ if (!workerId) {
68
+ throw new Error(
69
+ "No worker configured. Run 'workers deploy' first to create a worker."
70
+ );
71
+ }
72
+ this.process.stderr.write(`Disabling capability "${capabilityKey}"...`);
73
+ const result = await this.apiClient.updateSyncCapabilityDisabled(
74
+ workerId,
75
+ capabilityKey,
76
+ true
77
+ );
78
+ if (Result.isSuccess(result)) {
79
+ this.process.stderr.write("OK\n\n");
80
+ this.io.writeErr(`\u2713 Capability "${capabilityKey}" is now disabled`);
81
+ } else {
82
+ this.process.stderr.write("ERROR\n\n");
83
+ if (result.error.validationError) {
84
+ this.io.writeErr(`\u2717 ${result.error.validationError.debugMessage}`);
85
+ throw new Error(result.error.validationError.debugMessage);
86
+ } else {
87
+ this.io.writeErr(`\u2717 ${result.error.message}`);
88
+ throw new Error(result.error.message);
89
+ }
90
+ }
91
+ });
38
92
  export {
93
+ disableCapability,
94
+ enableCapability,
39
95
  listCapabilities
40
96
  };
@@ -16,6 +16,48 @@ const capabilitiesCommands = buildRouteMap({
16
16
  }
17
17
  },
18
18
  loader: () => import("./capabilities.impl.js").then((m) => m.listCapabilities)
19
+ }),
20
+ enable: buildCommand({
21
+ docs: {
22
+ brief: "Enable a sync capability"
23
+ },
24
+ parameters: {
25
+ flags: {
26
+ ...globalFlags
27
+ },
28
+ positional: {
29
+ kind: "tuple",
30
+ parameters: [
31
+ {
32
+ placeholder: "capability-key",
33
+ brief: "The key of the sync capability to enable",
34
+ parse: String
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ loader: () => import("./capabilities.impl.js").then((m) => m.enableCapability)
40
+ }),
41
+ disable: buildCommand({
42
+ docs: {
43
+ brief: "Disable a sync capability"
44
+ },
45
+ parameters: {
46
+ flags: {
47
+ ...globalFlags
48
+ },
49
+ positional: {
50
+ kind: "tuple",
51
+ parameters: [
52
+ {
53
+ placeholder: "capability-key",
54
+ brief: "The key of the sync capability to disable",
55
+ parse: String
56
+ }
57
+ ]
58
+ }
59
+ },
60
+ loader: () => import("./capabilities.impl.js").then((m) => m.disableCapability)
19
61
  })
20
62
  }
21
63
  });
@@ -0,0 +1,2 @@
1
+ export declare const oauthCommands: import("@stricli/core").RouteMap<import("../context.js").LocalContext>;
2
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/commands/oauth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,wEA6BxB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FormatFlags, GlobalFlags } from "../flags.js";
2
+ export declare const startOauth: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags, capabilityKey: string | undefined) => Promise<void>;
3
+ //# sourceMappingURL=oauth.impl.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,110 @@
1
+ import { Result } from "../api/result.js";
2
+ import { buildAuthedHandler } from "../handler.js";
3
+ import { openBrowserUrl } from "../utils/openUrl.js";
4
+ const startOauth = buildAuthedHandler(async function(flags, capabilityKey) {
5
+ const workerId = requireWorkerId(this);
6
+ if (!capabilityKey) {
7
+ const oauthCapabilityKeys = await fetchOauthCapabilityKeys(
8
+ this,
9
+ workerId,
10
+ flags.plain
11
+ );
12
+ if (oauthCapabilityKeys.length === 0) {
13
+ this.process.exitCode = 1;
14
+ return;
15
+ }
16
+ if (!this.process.stdin.isTTY) {
17
+ this.io.writeErr("Expected argument for capabilityKey");
18
+ this.io.writeErr("Start OAuth with:");
19
+ this.io.writeErr(" npx workers oauth start <capabilityKey>");
20
+ this.process.exitCode = 1;
21
+ return;
22
+ }
23
+ const selected = await this.io.select({
24
+ message: "Select an OAuth capability",
25
+ choices: oauthCapabilityKeys.map((key) => ({ name: key, value: key })),
26
+ default: oauthCapabilityKeys[0],
27
+ noTTY: "Expected argument for capabilityKey. Run `npx workers oauth start <capabilityKey>`."
28
+ });
29
+ capabilityKey = selected;
30
+ if (!capabilityKey) {
31
+ this.process.exitCode = 1;
32
+ return;
33
+ }
34
+ }
35
+ this.process.stderr.write(
36
+ `Starting OAuth flow with capability "${capabilityKey}"...`
37
+ );
38
+ const startResult = await this.apiClient.startOauth({
39
+ workerId,
40
+ capabilityKey
41
+ });
42
+ if (Result.isFail(startResult)) {
43
+ this.process.stderr.write("ERROR\n\n");
44
+ reportApiError(this, startResult.error, "start OAuth flow");
45
+ return;
46
+ }
47
+ this.process.stderr.write("OK\n\n");
48
+ const { authorizationUrl } = startResult.value;
49
+ this.io.writeErr("Opening your browser to continue the OAuth flow...");
50
+ try {
51
+ await openBrowserUrl(authorizationUrl);
52
+ } catch (error) {
53
+ this.io.writeErr(
54
+ `Unable to open the browser automatically (${String(
55
+ error
56
+ )}). Please open the link below manually.`
57
+ );
58
+ }
59
+ this.io.writeErr("");
60
+ this.io.writeErr("If the browser did not open, visit:");
61
+ this.io.writeErr(` ${authorizationUrl}`);
62
+ this.io.writeErr("");
63
+ this.io.writeErr(
64
+ "After completing the flow in your browser, return to the CLI."
65
+ );
66
+ });
67
+ function requireWorkerId(context) {
68
+ const workerId = context.config.workerId;
69
+ if (!workerId) {
70
+ throw new Error(
71
+ "No worker configured. Run 'workers deploy' first to create a worker."
72
+ );
73
+ }
74
+ return workerId;
75
+ }
76
+ function reportApiError(context, error, action) {
77
+ context.io.writeErr(`\u2717 Failed to ${action}`);
78
+ context.io.writeErr(`\u2717 ${error.message}`);
79
+ throw new Error(error.message);
80
+ }
81
+ async function fetchOauthCapabilityKeys(context, workerId, plain) {
82
+ context.process.stderr.write("Fetching OAuth capabilities...");
83
+ const capabilitiesResult = await context.apiClient.listCapabilities(workerId);
84
+ if (Result.isFail(capabilitiesResult)) {
85
+ context.process.stderr.write("ERROR\n\n");
86
+ reportApiError(context, capabilitiesResult.error, "list capabilities");
87
+ }
88
+ const oauthCaps = capabilitiesResult.value.capabilities.filter(
89
+ (cap) => cap._tag === "oauth"
90
+ );
91
+ context.process.stderr.write("OK\n\n");
92
+ if (oauthCaps.length === 0) {
93
+ context.io.writeErr("No OAuth capabilities found for this worker.");
94
+ context.io.writeErr(
95
+ "Run `npx workers capabilities list` to see all capabilities."
96
+ );
97
+ return [];
98
+ }
99
+ context.io.writeErr("OAuth capabilities:");
100
+ context.io.writeTableErr({
101
+ headers: ["Key"],
102
+ rows: oauthCaps.map((cap) => [cap.key]),
103
+ plain
104
+ });
105
+ context.io.writeErr("");
106
+ return oauthCaps.map((cap) => cap.key);
107
+ }
108
+ export {
109
+ startOauth
110
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=oauth.impl.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.impl.test.d.ts","sourceRoot":"","sources":["../../src/commands/oauth.impl.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { buildCommand, buildRouteMap } from "@stricli/core";
2
+ import { formatFlags, globalFlags } from "../flags.js";
3
+ const oauthCommands = buildRouteMap({
4
+ docs: {
5
+ brief: "Manage OAuth connections for your worker"
6
+ },
7
+ routes: {
8
+ start: buildCommand({
9
+ docs: {
10
+ brief: "Start an OAuth flow for a capability"
11
+ },
12
+ parameters: {
13
+ positional: {
14
+ kind: "tuple",
15
+ parameters: [
16
+ {
17
+ brief: "OAuth capability key",
18
+ parse: String,
19
+ placeholder: "capabilityKey",
20
+ optional: true
21
+ }
22
+ ]
23
+ },
24
+ flags: {
25
+ ...globalFlags,
26
+ ...formatFlags
27
+ }
28
+ },
29
+ loader: () => import("./oauth.impl.js").then((m) => m.startOauth)
30
+ })
31
+ }
32
+ });
33
+ export {
34
+ oauthCommands
35
+ };
@@ -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;AAK5D,eAAO,MAAM,UAAU,sGA0BrB,CAAC;AAEH,eAAO,MAAM,WAAW,iGAwCtB,CAAC;AAEH,eAAO,MAAM,YAAY,gGAwBvB,CAAC"}
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;AAK5D,eAAO,MAAM,UAAU,sGA0BrB,CAAC;AAEH,eAAO,MAAM,WAAW,iGAkCtB,CAAC;AAEH,eAAO,MAAM,YAAY,gGAwBvB,CAAC"}
@@ -36,18 +36,12 @@ const listSecrets = buildAuthedHandler(async function(flags) {
36
36
  const data = Result.unwrap(result);
37
37
  if (data.secrets.length === 0) {
38
38
  this.io.writeErr("No secrets for this worker.");
39
- this.io.writeErr(
40
- "To list OAuth connect secrets, use `npx workers connect list`"
41
- );
42
39
  } else {
43
40
  this.io.writeTableOut({
44
41
  headers: ["Key", "Created At"],
45
42
  rows: data.secrets.map((secret) => [secret.key, secret.createdAt]),
46
43
  plain: flags.plain
47
44
  });
48
- this.io.writeErr(
49
- "To list OAuth connect secrets, use `npx workers connect list`"
50
- );
51
45
  }
52
46
  } else {
53
47
  this.process.stderr.write("ERROR\n\n");
package/dist/io.d.ts CHANGED
@@ -50,6 +50,7 @@ export declare class IO {
50
50
  writeTableErr(tableConfig: TableOptions): void;
51
51
  confirm(config: WithSafety<Parameters<typeof prompts.confirm>[0]>): Promise<boolean | void>;
52
52
  input(config: WithSafety<Parameters<typeof prompts.input>[0]>): Promise<string | void>;
53
+ select<Value>(config: WithSafety<Parameters<typeof prompts.select<Value>>[0]>): ReturnType<typeof prompts.select<Value>>;
53
54
  }
54
55
  export {};
55
56
  //# sourceMappingURL=io.d.ts.map
package/dist/io.d.ts.map C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UAAU,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAKjB,UAAU,CACvD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAC5B;CAqCF"}
package/dist/io.js CHANGED
@@ -61,6 +61,10 @@ class IO {
61
61
  this.#ensureTTY(config.noTTY);
62
62
  return prompts.input(config).catch(this.#handlePromptExit.bind(this));
63
63
  }
64
+ select(config) {
65
+ this.#ensureTTY(config.noTTY);
66
+ return prompts.select(config).catch(this.#handlePromptExit.bind(this));
67
+ }
64
68
  #ensureTTY(noTTY) {
65
69
  if (!process.stdin.isTTY) {
66
70
  this.writeErr(noTTY);
package/dist/routes.js CHANGED
@@ -3,10 +3,10 @@ import packageJson from "../package.json" with { type: "json" };
3
3
  import { authCommands } from "./commands/auth.js";
4
4
  import { bundleCommands } from "./commands/bundle.js";
5
5
  import { capabilitiesCommands } from "./commands/capabilities.js";
6
- import { connectCommands } from "./commands/connect.js";
7
6
  import deploy from "./commands/deploy.js";
8
7
  import { envCommands } from "./commands/env.js";
9
8
  import exec from "./commands/exec.js";
9
+ import { oauthCommands } from "./commands/oauth.js";
10
10
  import { runsCommands } from "./commands/runs.js";
11
11
  import { secretsCommands } from "./commands/secrets.js";
12
12
  import { TokenNotSetError } from "./config.js";
@@ -33,7 +33,7 @@ variables can also be provided:
33
33
  capabilities: capabilitiesCommands,
34
34
  deploy,
35
35
  exec,
36
- connect: connectCommands,
36
+ oauth: oauthCommands,
37
37
  env: envCommands,
38
38
  runs: runsCommands,
39
39
  secrets: secretsCommands,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-ajax/cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "A CLI for the Project Ajax platform",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- export declare const connectCommands: import("@stricli/core").RouteMap<import("../context.js").LocalContext>;
2
- //# sourceMappingURL=connect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,wEA2E1B,CAAC"}
@@ -1,6 +0,0 @@
1
- import type { FormatFlags, GlobalFlags } from "../flags.js";
2
- export declare const listProviders: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
3
- export declare const addConnection: (this: import("../context.js").LocalContext, flags: GlobalFlags, provider: string) => Promise<void>;
4
- export declare const listConnections: (this: import("../context.js").LocalContext, flags: GlobalFlags & FormatFlags) => Promise<void>;
5
- export declare const removeConnection: (this: import("../context.js").LocalContext, flags: GlobalFlags, provider: string) => Promise<void>;
6
- //# sourceMappingURL=connect.impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connect.impl.d.ts","sourceRoot":"","sources":["../../src/commands/connect.impl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI5D,eAAO,MAAM,aAAa,iGAuBxB,CAAC;AAEH,eAAO,MAAM,aAAa,qGAuCxB,CAAC;AAEH,eAAO,MAAM,eAAe,iGAiC1B,CAAC;AAEH,eAAO,MAAM,gBAAgB,qGAqB3B,CAAC"}
@@ -1,116 +0,0 @@
1
- import { Result } from "../api/result.js";
2
- import { buildAuthedHandler } from "../handler.js";
3
- import { openBrowserUrl } from "../utils/openUrl.js";
4
- const listProviders = buildAuthedHandler(async function(flags) {
5
- this.process.stderr.write("Fetching providers...");
6
- const providersResult = await this.apiClient.listOauthProviders();
7
- if (Result.isFail(providersResult)) {
8
- this.process.stderr.write("ERROR\n\n");
9
- reportApiError(this, providersResult.error, "list providers");
10
- } else {
11
- this.process.stderr.write("OK\n\n");
12
- const providers = providersResult.value.providers;
13
- if (providers.length === 0) {
14
- this.io.writeErr("No OAuth providers are currently available.");
15
- return;
16
- }
17
- this.io.writeTableOut({
18
- headers: ["Provider", "Description"],
19
- rows: providers.map((provider) => [provider.key, provider.displayName]),
20
- plain: flags.plain
21
- });
22
- }
23
- });
24
- const addConnection = buildAuthedHandler(async function(_flags, provider) {
25
- const workerId = requireWorkerId(this);
26
- this.process.stderr.write(
27
- `Starting OAuth flow with provider "${provider}"...`
28
- );
29
- const startResult = await this.apiClient.startOauth({ workerId, provider });
30
- if (Result.isFail(startResult)) {
31
- this.process.stderr.write("ERROR\n\n");
32
- reportApiError(this, startResult.error, "start OAuth flow");
33
- return;
34
- }
35
- this.process.stderr.write("OK\n\n");
36
- const { authorizationUrl } = startResult.value;
37
- this.io.writeErr("Opening your browser to continue the OAuth flow...");
38
- try {
39
- await openBrowserUrl(authorizationUrl);
40
- } catch (error) {
41
- this.io.writeErr(
42
- `Unable to open the browser automatically (${String(
43
- error
44
- )}). Please open the link below manually.`
45
- );
46
- }
47
- this.io.writeErr("");
48
- this.io.writeErr("If the browser did not open, visit:");
49
- this.io.writeErr(` ${authorizationUrl}`);
50
- this.io.writeErr("");
51
- this.io.writeErr(
52
- "After completing the flow in your browser, return to the CLI."
53
- );
54
- });
55
- const listConnections = buildAuthedHandler(async function(flags) {
56
- const workerId = requireWorkerId(this);
57
- this.process.stderr.write("Fetching OAuth connections...");
58
- const secretsResult = await this.apiClient.listSecrets(workerId, {
59
- secretKinds: ["oauth"]
60
- });
61
- if (Result.isFail(secretsResult)) {
62
- this.process.stderr.write("ERROR\n\n");
63
- reportApiError(this, secretsResult.error, "list OAuth connections");
64
- return;
65
- }
66
- this.process.stderr.write("OK\n\n");
67
- const secrets = secretsResult.value.secrets;
68
- if (secrets.length === 0) {
69
- this.io.writeErr("No OAuth connections found for this worker.");
70
- return;
71
- }
72
- this.io.writeTableOut({
73
- headers: ["Env Var", "Created At"],
74
- rows: secrets.map((secret) => [
75
- `process.env.${secret.key}`,
76
- secret.createdAt
77
- ]),
78
- plain: flags.plain
79
- });
80
- });
81
- const removeConnection = buildAuthedHandler(async function(_flags, provider) {
82
- const workerId = requireWorkerId(this);
83
- this.process.stderr.write(
84
- `Removing OAuth connection for provider "${provider}"...`
85
- );
86
- const result = await this.apiClient.deleteOauthConnection({
87
- workerId,
88
- provider
89
- });
90
- if (Result.isFail(result)) {
91
- this.process.stderr.write("ERROR\n\n");
92
- reportApiError(this, result.error, "remove connection");
93
- return;
94
- }
95
- this.process.stderr.write("OK\n");
96
- });
97
- function requireWorkerId(context) {
98
- const workerId = context.config.workerId;
99
- if (!workerId) {
100
- throw new Error(
101
- "No worker configured. Run 'workers deploy' first to create a worker."
102
- );
103
- }
104
- return workerId;
105
- }
106
- function reportApiError(context, error, action) {
107
- context.io.writeErr(`\u2717 Failed to ${action}`);
108
- context.io.writeErr(`\u2717 ${error.message}`);
109
- throw new Error(error.message);
110
- }
111
- export {
112
- addConnection,
113
- listConnections,
114
- listProviders,
115
- removeConnection
116
- };
@@ -1,78 +0,0 @@
1
- import { buildCommand, buildRouteMap } from "@stricli/core";
2
- import { formatFlags, globalFlags } from "../flags.js";
3
- const connectCommands = buildRouteMap({
4
- docs: {
5
- brief: "Manage OAuth connections for your worker"
6
- },
7
- routes: {
8
- providers: buildCommand({
9
- docs: {
10
- brief: "List available OAuth providers"
11
- },
12
- parameters: {
13
- flags: {
14
- ...globalFlags,
15
- ...formatFlags
16
- }
17
- },
18
- loader: () => import("./connect.impl.js").then((m) => m.listProviders)
19
- }),
20
- add: buildCommand({
21
- docs: {
22
- brief: "Start an OAuth flow for a provider"
23
- },
24
- parameters: {
25
- positional: {
26
- kind: "tuple",
27
- parameters: [
28
- {
29
- brief: "Provider name (see `providers` command)",
30
- parse: String,
31
- placeholder: "provider"
32
- }
33
- ]
34
- },
35
- flags: {
36
- ...globalFlags
37
- }
38
- },
39
- loader: () => import("./connect.impl.js").then((m) => m.addConnection)
40
- }),
41
- list: buildCommand({
42
- docs: {
43
- brief: "List active OAuth connections"
44
- },
45
- parameters: {
46
- flags: {
47
- ...globalFlags,
48
- ...formatFlags
49
- }
50
- },
51
- loader: () => import("./connect.impl.js").then((m) => m.listConnections)
52
- }),
53
- rm: buildCommand({
54
- docs: {
55
- brief: "Remove an OAuth connection"
56
- },
57
- parameters: {
58
- positional: {
59
- kind: "tuple",
60
- parameters: [
61
- {
62
- brief: "Provider name to remove",
63
- parse: String,
64
- placeholder: "provider"
65
- }
66
- ]
67
- },
68
- flags: {
69
- ...globalFlags
70
- }
71
- },
72
- loader: () => import("./connect.impl.js").then((m) => m.removeConnection)
73
- })
74
- }
75
- });
76
- export {
77
- connectCommands
78
- };