@project-ajax/sdk 0.0.60 → 0.0.62

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 (150) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -2
  4. package/package.json +4 -16
  5. package/src/index.ts +0 -1
  6. package/dist/capabilities/slashCommand.d.ts +0 -56
  7. package/dist/capabilities/slashCommand.d.ts.map +0 -1
  8. package/dist/capabilities/slashCommand.js +0 -32
  9. package/dist/cli/api/client.d.ts +0 -212
  10. package/dist/cli/api/client.d.ts.map +0 -1
  11. package/dist/cli/api/client.js +0 -330
  12. package/dist/cli/api/result.d.ts +0 -43
  13. package/dist/cli/api/result.d.ts.map +0 -1
  14. package/dist/cli/api/result.js +0 -43
  15. package/dist/cli/bin/cli.d.ts +0 -3
  16. package/dist/cli/bin/cli.d.ts.map +0 -1
  17. package/dist/cli/bin/cli.js +0 -5
  18. package/dist/cli/commands/auth.d.ts +0 -2
  19. package/dist/cli/commands/auth.d.ts.map +0 -1
  20. package/dist/cli/commands/auth.impl.d.ts +0 -5
  21. package/dist/cli/commands/auth.impl.d.ts.map +0 -1
  22. package/dist/cli/commands/auth.impl.js +0 -45
  23. package/dist/cli/commands/auth.impl.test.d.ts +0 -2
  24. package/dist/cli/commands/auth.impl.test.d.ts.map +0 -1
  25. package/dist/cli/commands/auth.js +0 -56
  26. package/dist/cli/commands/bundle.d.ts +0 -2
  27. package/dist/cli/commands/bundle.d.ts.map +0 -1
  28. package/dist/cli/commands/bundle.impl.d.ts +0 -2
  29. package/dist/cli/commands/bundle.impl.d.ts.map +0 -1
  30. package/dist/cli/commands/bundle.impl.js +0 -21
  31. package/dist/cli/commands/bundle.impl.test.d.ts +0 -2
  32. package/dist/cli/commands/bundle.impl.test.d.ts.map +0 -1
  33. package/dist/cli/commands/bundle.js +0 -23
  34. package/dist/cli/commands/capabilities.d.ts +0 -2
  35. package/dist/cli/commands/capabilities.d.ts.map +0 -1
  36. package/dist/cli/commands/capabilities.impl.d.ts +0 -3
  37. package/dist/cli/commands/capabilities.impl.d.ts.map +0 -1
  38. package/dist/cli/commands/capabilities.impl.js +0 -40
  39. package/dist/cli/commands/capabilities.js +0 -24
  40. package/dist/cli/commands/connect.d.ts +0 -2
  41. package/dist/cli/commands/connect.d.ts.map +0 -1
  42. package/dist/cli/commands/connect.impl.d.ts +0 -6
  43. package/dist/cli/commands/connect.impl.d.ts.map +0 -1
  44. package/dist/cli/commands/connect.impl.js +0 -116
  45. package/dist/cli/commands/connect.js +0 -78
  46. package/dist/cli/commands/deploy.d.ts +0 -3
  47. package/dist/cli/commands/deploy.d.ts.map +0 -1
  48. package/dist/cli/commands/deploy.impl.d.ts +0 -6
  49. package/dist/cli/commands/deploy.impl.d.ts.map +0 -1
  50. package/dist/cli/commands/deploy.impl.js +0 -60
  51. package/dist/cli/commands/deploy.impl.test.d.ts +0 -2
  52. package/dist/cli/commands/deploy.impl.test.d.ts.map +0 -1
  53. package/dist/cli/commands/deploy.js +0 -22
  54. package/dist/cli/commands/env.d.ts +0 -2
  55. package/dist/cli/commands/env.d.ts.map +0 -1
  56. package/dist/cli/commands/env.impl.d.ts +0 -11
  57. package/dist/cli/commands/env.impl.d.ts.map +0 -1
  58. package/dist/cli/commands/env.impl.js +0 -62
  59. package/dist/cli/commands/env.js +0 -39
  60. package/dist/cli/commands/exec.d.ts +0 -3
  61. package/dist/cli/commands/exec.d.ts.map +0 -1
  62. package/dist/cli/commands/exec.impl.d.ts +0 -7
  63. package/dist/cli/commands/exec.impl.d.ts.map +0 -1
  64. package/dist/cli/commands/exec.impl.js +0 -123
  65. package/dist/cli/commands/exec.js +0 -30
  66. package/dist/cli/commands/runs.d.ts +0 -2
  67. package/dist/cli/commands/runs.d.ts.map +0 -1
  68. package/dist/cli/commands/runs.impl.d.ts +0 -4
  69. package/dist/cli/commands/runs.impl.d.ts.map +0 -1
  70. package/dist/cli/commands/runs.impl.js +0 -71
  71. package/dist/cli/commands/runs.js +0 -45
  72. package/dist/cli/commands/secrets.d.ts +0 -2
  73. package/dist/cli/commands/secrets.d.ts.map +0 -1
  74. package/dist/cli/commands/secrets.impl.d.ts +0 -5
  75. package/dist/cli/commands/secrets.impl.d.ts.map +0 -1
  76. package/dist/cli/commands/secrets.impl.js +0 -99
  77. package/dist/cli/commands/secrets.js +0 -64
  78. package/dist/cli/commands/utils/testing.d.ts +0 -13
  79. package/dist/cli/commands/utils/testing.d.ts.map +0 -1
  80. package/dist/cli/commands/utils/testing.js +0 -58
  81. package/dist/cli/config.d.ts +0 -63
  82. package/dist/cli/config.d.ts.map +0 -1
  83. package/dist/cli/config.js +0 -194
  84. package/dist/cli/config.test.d.ts +0 -2
  85. package/dist/cli/config.test.d.ts.map +0 -1
  86. package/dist/cli/context.d.ts +0 -15
  87. package/dist/cli/context.d.ts.map +0 -1
  88. package/dist/cli/context.js +0 -16
  89. package/dist/cli/deploy.d.ts +0 -37
  90. package/dist/cli/deploy.d.ts.map +0 -1
  91. package/dist/cli/deploy.js +0 -100
  92. package/dist/cli/flags.d.ts +0 -21
  93. package/dist/cli/flags.d.ts.map +0 -1
  94. package/dist/cli/flags.js +0 -49
  95. package/dist/cli/handler.d.ts +0 -14
  96. package/dist/cli/handler.d.ts.map +0 -1
  97. package/dist/cli/handler.js +0 -32
  98. package/dist/cli/io.d.ts +0 -55
  99. package/dist/cli/io.d.ts.map +0 -1
  100. package/dist/cli/io.js +0 -96
  101. package/dist/cli/routes.d.ts +0 -2
  102. package/dist/cli/routes.d.ts.map +0 -1
  103. package/dist/cli/routes.js +0 -62
  104. package/dist/cli/utils/array.d.ts +0 -2
  105. package/dist/cli/utils/array.d.ts.map +0 -1
  106. package/dist/cli/utils/array.js +0 -10
  107. package/dist/cli/utils/openUrl.d.ts +0 -4
  108. package/dist/cli/utils/openUrl.d.ts.map +0 -1
  109. package/dist/cli/utils/openUrl.js +0 -43
  110. package/dist/cli/utils/string.d.ts +0 -2
  111. package/dist/cli/utils/string.d.ts.map +0 -1
  112. package/dist/cli/utils/string.js +0 -12
  113. package/src/capabilities/slashCommand.ts +0 -71
  114. package/src/cli/api/client.ts +0 -628
  115. package/src/cli/api/result.ts +0 -71
  116. package/src/cli/bin/cli.ts +0 -7
  117. package/src/cli/commands/.cursor/rules/testing-commands.mdc +0 -212
  118. package/src/cli/commands/auth.impl.test.ts +0 -228
  119. package/src/cli/commands/auth.impl.ts +0 -56
  120. package/src/cli/commands/auth.ts +0 -63
  121. package/src/cli/commands/bundle.impl.test.ts +0 -143
  122. package/src/cli/commands/bundle.impl.ts +0 -21
  123. package/src/cli/commands/bundle.ts +0 -23
  124. package/src/cli/commands/capabilities.impl.ts +0 -47
  125. package/src/cli/commands/capabilities.ts +0 -25
  126. package/src/cli/commands/connect.impl.ts +0 -149
  127. package/src/cli/commands/connect.ts +0 -80
  128. package/src/cli/commands/deploy.impl.test.ts +0 -254
  129. package/src/cli/commands/deploy.impl.ts +0 -73
  130. package/src/cli/commands/deploy.ts +0 -22
  131. package/src/cli/commands/env.impl.ts +0 -88
  132. package/src/cli/commands/env.ts +0 -38
  133. package/src/cli/commands/exec.impl.ts +0 -171
  134. package/src/cli/commands/exec.ts +0 -32
  135. package/src/cli/commands/runs.impl.ts +0 -87
  136. package/src/cli/commands/runs.ts +0 -49
  137. package/src/cli/commands/secrets.impl.ts +0 -130
  138. package/src/cli/commands/secrets.ts +0 -73
  139. package/src/cli/commands/utils/testing.ts +0 -66
  140. package/src/cli/config.test.ts +0 -108
  141. package/src/cli/config.ts +0 -265
  142. package/src/cli/context.ts +0 -26
  143. package/src/cli/deploy.ts +0 -190
  144. package/src/cli/flags.ts +0 -72
  145. package/src/cli/handler.ts +0 -68
  146. package/src/cli/io.ts +0 -132
  147. package/src/cli/routes.ts +0 -61
  148. package/src/cli/utils/array.ts +0 -7
  149. package/src/cli/utils/openUrl.ts +0 -53
  150. package/src/cli/utils/string.ts +0 -9
@@ -1,330 +0,0 @@
1
- import { Result } from "./result.js";
2
- class ApiClient {
3
- #token;
4
- #baseUrl;
5
- #cellId;
6
- #writer;
7
- constructor(config) {
8
- this.#token = config.token;
9
- this.#baseUrl = config.baseUrl;
10
- this.#cellId = config.cellId;
11
- this.#writer = config.writer;
12
- }
13
- #baseApiUrl() {
14
- return `${this.#baseUrl}/api/v3`;
15
- }
16
- async fetch(endpoint, requestOptions = {}, options) {
17
- if (!endpoint.startsWith("/")) {
18
- throw new Error("Endpoint must start with a slash (/)");
19
- }
20
- const url = `${this.#baseApiUrl()}${endpoint}`;
21
- this.#writer.debug(`Fetching ${url}`);
22
- this.#writer.debug(
23
- `Options: ${JSON.stringify(requestOptions, null, " ")}`
24
- );
25
- const headers = new Headers({
26
- Authorization: `Bearer ${this.#token}`,
27
- "Content-Type": "application/json",
28
- "X-Notion-Cell": this.#cellId
29
- });
30
- const addlHeaders = headersInitToEntries(requestOptions.headers);
31
- for (const [key, value] of addlHeaders) {
32
- headers.append(key, value);
33
- }
34
- const response = await fetch(url, {
35
- method: requestOptions.method ?? "GET",
36
- headers,
37
- body: requestOptions.body ? JSON.stringify(requestOptions.body) : null
38
- });
39
- this.#writer.debug(`Response: ${response.status} ${response.statusText}`);
40
- if (!response.ok) {
41
- const error = await parseApiError(response);
42
- return Result.fail(error);
43
- }
44
- if (options?.stream) {
45
- if (!response.body) {
46
- return Result.fail({
47
- status: response.status,
48
- statusText: response.statusText,
49
- message: "No body in response"
50
- });
51
- }
52
- return Result.success(response.body);
53
- } else {
54
- const data = await response.json();
55
- return Result.success(data);
56
- }
57
- }
58
- /**
59
- * Create a new worker
60
- */
61
- async createWorker(name) {
62
- return this.fetch("/workersCreateWorker", {
63
- method: "POST",
64
- body: {
65
- name
66
- }
67
- });
68
- }
69
- /**
70
- * Update an existing worker's bundle
71
- */
72
- async updateWorkerBundle(workerId) {
73
- return this.fetch("/workersUpdateWorker", {
74
- method: "POST",
75
- body: {
76
- workerId
77
- }
78
- });
79
- }
80
- /**
81
- * Get a worker by ID
82
- */
83
- async getWorker(workerId) {
84
- return this.fetch("/workersGetWorker", {
85
- method: "POST",
86
- body: {
87
- workerId
88
- }
89
- });
90
- }
91
- /**
92
- * List all workers in the space
93
- */
94
- async listWorkers() {
95
- return this.fetch("/workersListWorkers", {
96
- method: "POST",
97
- body: {}
98
- });
99
- }
100
- /**
101
- * Delete a worker
102
- */
103
- async deleteWorker(workerId) {
104
- return this.fetch("/workersDeleteWorker", {
105
- method: "POST",
106
- body: {
107
- workerId
108
- }
109
- });
110
- }
111
- /**
112
- * Fetch and save worker capabilities
113
- */
114
- async fetchAndSaveCapabilities(workerId) {
115
- return this.fetch("/workersFetchAndSaveCapabilities", {
116
- method: "POST",
117
- body: {
118
- workerId
119
- }
120
- });
121
- }
122
- /**
123
- * Upsert secrets (create or update multiple secrets)
124
- */
125
- async upsertSecrets(workerId, secrets) {
126
- return this.fetch("/workersUpsertSecrets", {
127
- method: "POST",
128
- body: {
129
- workerId,
130
- secrets
131
- }
132
- });
133
- }
134
- /**
135
- * List all secrets for a worker (keys only, not values)
136
- */
137
- async listSecrets(workerId, options) {
138
- return this.fetch("/workersListSecrets", {
139
- method: "POST",
140
- body: {
141
- workerId,
142
- secretKinds: options?.secretKinds
143
- }
144
- });
145
- }
146
- /**
147
- * Pull decrypted env vars for a worker
148
- */
149
- async pullEnv(workerId) {
150
- return this.fetch("/workersPullEnv", {
151
- method: "POST",
152
- body: {
153
- workerId
154
- }
155
- });
156
- }
157
- async listOauthProviders() {
158
- return this.fetch("/workersListOauthProviders", {
159
- method: "POST",
160
- body: {}
161
- });
162
- }
163
- /**
164
- * Start the OAuth flow for a provider
165
- */
166
- async startOauth(args) {
167
- return this.fetch("/workersStartOauth", {
168
- method: "POST",
169
- body: {
170
- 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
184
- }
185
- });
186
- }
187
- /**
188
- * Delete a secret
189
- */
190
- async deleteSecret(workerId, key) {
191
- return this.fetch("/workersDeleteSecret", {
192
- method: "POST",
193
- body: {
194
- workerId,
195
- key
196
- }
197
- });
198
- }
199
- /**
200
- * List all capabilities for a worker
201
- */
202
- async listCapabilities(workerId) {
203
- return this.fetch("/workersListCapabilities", {
204
- method: "POST",
205
- body: {
206
- workerId
207
- }
208
- });
209
- }
210
- async runCapability(workerId, capabilityKey, functionName, args, stream) {
211
- if (stream) {
212
- return this.fetch(
213
- "/workersRunCapability",
214
- {
215
- method: "POST",
216
- body: {
217
- workerId,
218
- capabilityKey,
219
- functionName,
220
- args,
221
- stream
222
- }
223
- },
224
- { stream }
225
- );
226
- } else {
227
- return this.fetch("/workersRunCapability", {
228
- method: "POST",
229
- body: {
230
- workerId,
231
- capabilityKey,
232
- functionName,
233
- args,
234
- stream
235
- }
236
- });
237
- }
238
- }
239
- /**
240
- * Download the bundle for a worker
241
- */
242
- async downloadWorkerBundle(workerId) {
243
- return this.fetch(
244
- "/workersGetBundle",
245
- {
246
- method: "POST",
247
- body: {
248
- workerId
249
- }
250
- },
251
- { stream: true }
252
- );
253
- }
254
- /**
255
- * List all runs for a worker
256
- */
257
- async listRunsForWorker(workerId) {
258
- return this.fetch("/workersListRunsForWorker", {
259
- method: "POST",
260
- body: {
261
- workerId
262
- }
263
- });
264
- }
265
- /**
266
- * Get logs for a specific run
267
- */
268
- async getRunLogs(workerId, runId) {
269
- return this.fetch("/workersGetRunLogs", {
270
- method: "POST",
271
- body: {
272
- workerId,
273
- runId
274
- }
275
- });
276
- }
277
- }
278
- function headersInitToEntries(headersInit) {
279
- if (headersInit instanceof Headers) {
280
- return Array.from(headersInit.entries());
281
- }
282
- if (Array.isArray(headersInit)) {
283
- return headersInit;
284
- }
285
- if (headersInit === void 0) {
286
- return [];
287
- }
288
- const entries = [];
289
- for (const [key, value] of Object.entries(headersInit)) {
290
- if (value === void 0) {
291
- continue;
292
- }
293
- entries.push([key, value]);
294
- }
295
- return entries;
296
- }
297
- async function parseApiError(response) {
298
- const errorText = await response.text();
299
- const message = `[${response.status}] ${response.statusText}: ${errorText}`;
300
- const error = {
301
- status: response.status,
302
- statusText: response.statusText,
303
- message
304
- };
305
- if (response.status === 400) {
306
- const validationError = parseValidationError(errorText);
307
- if (validationError) {
308
- error.validationError = validationError;
309
- }
310
- }
311
- return error;
312
- }
313
- function parseValidationError(errorText) {
314
- try {
315
- const errorJson = JSON.parse(errorText);
316
- if (errorJson.name === "ValidationError" && errorJson.debugMessage && errorJson.errorId) {
317
- return {
318
- errorId: errorJson.errorId,
319
- name: errorJson.name,
320
- debugMessage: errorJson.debugMessage,
321
- message: errorJson.message
322
- };
323
- }
324
- } catch {
325
- }
326
- return void 0;
327
- }
328
- export {
329
- ApiClient
330
- };
@@ -1,43 +0,0 @@
1
- /**
2
- * Represents the union of *either* the value returned
3
- * from some function *or* an arbitrary error emitted during computation.
4
- */
5
- /**
6
- * The left side of the Result type, the value.
7
- */
8
- export interface Success<T> {
9
- _tag: "success";
10
- value: T;
11
- }
12
- /**
13
- * The right side of the Result type, the error.
14
- */
15
- export interface Fail<E> {
16
- _tag: "fail";
17
- error: E;
18
- }
19
- export type Result<S, E> = Success<S> | Fail<E>;
20
- /**
21
- * Type predicates and helpers for the Result type.
22
- */
23
- export declare const Result: {
24
- success<S>(value: S): Success<S>;
25
- fail<E>(error: E): Fail<E>;
26
- /**
27
- * Success (left side) type predicate for the Result type.
28
- */
29
- isSuccess<S, E>(result: Result<S, E>): result is Success<S>;
30
- /**
31
- * Fail (right side) type predicate for the Result type.
32
- */
33
- isFail<S, E>(result: Result<S, E>): result is Fail<E>;
34
- /**
35
- * Unwrap a Result value, throwing the error if it's set.
36
- */
37
- unwrap<S, E>(result: Result<S, E>): S;
38
- /**
39
- * Unwrap a Result value, or return a default value if an error is set.
40
- */
41
- unwrapOr<S, E>(result: Result<S, E>, defaultValue: S): S;
42
- };
43
- //# sourceMappingURL=result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../src/cli/api/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,CAAC,CAAC;CACT;AAED;;GAEG;AACH,MAAM,WAAW,IAAI,CAAC,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;CACT;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,MAAM;YACV,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;SAI3B,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAI1B;;OAEG;cACO,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC;IAI3D;;OAEG;WACI,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC;IAIrD;;OAEG;WACI,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;IAQrC;;OAEG;aACM,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC;CAOxD,CAAC"}
@@ -1,43 +0,0 @@
1
- const Result = {
2
- success(value) {
3
- return { _tag: "success", value };
4
- },
5
- fail(error) {
6
- return { _tag: "fail", error };
7
- },
8
- /**
9
- * Success (left side) type predicate for the Result type.
10
- */
11
- isSuccess(result) {
12
- return result._tag === "success";
13
- },
14
- /**
15
- * Fail (right side) type predicate for the Result type.
16
- */
17
- isFail(result) {
18
- return result._tag === "fail";
19
- },
20
- /**
21
- * Unwrap a Result value, throwing the error if it's set.
22
- */
23
- unwrap(result) {
24
- if (Result.isFail(result)) {
25
- throw result.error;
26
- } else {
27
- return result.value;
28
- }
29
- },
30
- /**
31
- * Unwrap a Result value, or return a default value if an error is set.
32
- */
33
- unwrapOr(result, defaultValue) {
34
- if (Result.isFail(result)) {
35
- return defaultValue;
36
- } else {
37
- return result.value;
38
- }
39
- }
40
- };
41
- export {
42
- Result
43
- };
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli/bin/cli.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- import { run } from "@stricli/core";
3
- import { buildContext } from "../context.js";
4
- import { app } from "../routes.js";
5
- await run(app, process.argv.slice(2), buildContext(process));
@@ -1,2 +0,0 @@
1
- export declare const authCommands: import("@stricli/core").RouteMap<import("../context.js").LocalContext>;
2
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,wEA2DvB,CAAC"}
@@ -1,5 +0,0 @@
1
- import type { GlobalFlags } from "../flags.js";
2
- export declare const login: (this: import("../context.js").LocalContext, flags: GlobalFlags, token?: string | undefined) => Promise<void>;
3
- export declare const show: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
4
- export declare const logout: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
5
- //# sourceMappingURL=auth.impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/auth.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,KAAK,+GAwChB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAEf,CAAC;AAEH,eAAO,MAAM,MAAM,mFAIjB,CAAC"}
@@ -1,45 +0,0 @@
1
- import { buildHandler } from "../handler.js";
2
- import { openNotionUrl } from "../utils/openUrl.js";
3
- const login = buildHandler(async function(_, token) {
4
- const environment = this.config.environment;
5
- if (!token) {
6
- const url = `${this.config.baseUrl}/__workers__?createToken=true`;
7
- this.io.writeErr(`Opening browser to create a token...
8
- ${url}
9
- `);
10
- this.io.writeErr("After creating a token, run:");
11
- this.io.writeErr(" npx workers auth login <token>");
12
- try {
13
- await openNotionUrl(environment, url);
14
- } catch (_error) {
15
- this.io.writeErr(
16
- `Failed to open browser automatically. Please visit:
17
- ${url}`
18
- );
19
- }
20
- return;
21
- }
22
- const update = {
23
- token,
24
- workerId: null
25
- };
26
- console.log("environment", environment);
27
- if (environment !== "prod") {
28
- update.environment = environment;
29
- }
30
- await this.config.update(update);
31
- this.io.writeErr("Successfully logged in!");
32
- });
33
- const show = buildHandler(function() {
34
- this.io.writeOut(`${this.config.token ?? ""}`);
35
- });
36
- const logout = buildHandler(async function() {
37
- await this.config.update({
38
- token: null
39
- });
40
- });
41
- export {
42
- login,
43
- logout,
44
- show
45
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=auth.impl.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.impl.test.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/auth.impl.test.ts"],"names":[],"mappings":""}
@@ -1,56 +0,0 @@
1
- import { buildCommand, buildRouteMap } from "@stricli/core";
2
- import { globalFlags } from "../flags.js";
3
- const authCommands = buildRouteMap({
4
- docs: {
5
- brief: "Commands for managing the CLI context"
6
- },
7
- routes: {
8
- login: buildCommand({
9
- docs: {
10
- brief: "Login to the Project Ajax platform using a Workers API token; will clear existing token, environment, and worker ID"
11
- },
12
- parameters: {
13
- positional: {
14
- kind: "tuple",
15
- parameters: [
16
- {
17
- brief: "A Workers API token",
18
- parse: String,
19
- placeholder: "api-token",
20
- optional: true
21
- }
22
- ]
23
- },
24
- flags: {
25
- ...globalFlags
26
- }
27
- },
28
- loader: () => import("./auth.impl.js").then((m) => m.login)
29
- }),
30
- show: buildCommand({
31
- docs: {
32
- brief: "Get the token for the CLI"
33
- },
34
- parameters: {
35
- flags: {
36
- ...globalFlags
37
- }
38
- },
39
- loader: () => import("./auth.impl.js").then((m) => m.show)
40
- }),
41
- logout: buildCommand({
42
- docs: {
43
- brief: "Unset the token for the CLI"
44
- },
45
- parameters: {
46
- flags: {
47
- ...globalFlags
48
- }
49
- },
50
- loader: () => import("./auth.impl.js").then((m) => m.logout)
51
- })
52
- }
53
- });
54
- export {
55
- authCommands
56
- };
@@ -1,2 +0,0 @@
1
- export declare const bundleCommands: import("@stricli/core").RouteMap<import("../context.js").LocalContext>;
2
- //# sourceMappingURL=bundle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/bundle.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,wEAmBzB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const downloadBundle: (this: import("../context.js").LocalContext, flags: import("../flags.js").GlobalFlags) => Promise<void>;
2
- //# sourceMappingURL=bundle.impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/bundle.impl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,yGAgBzB,CAAC"}
@@ -1,21 +0,0 @@
1
- import { Readable } from "node:stream";
2
- import { Result } from "../api/result.js";
3
- import { buildAuthedHandler } from "../handler.js";
4
- const downloadBundle = buildAuthedHandler(async function() {
5
- const { workerId } = this.config;
6
- if (!workerId) {
7
- throw new Error(
8
- "No worker configured. Run 'workers deploy' first to create a worker."
9
- );
10
- }
11
- const result = await this.apiClient.downloadWorkerBundle(workerId);
12
- if (Result.isFail(result)) {
13
- this.io.writeErr(`\u2717 Failed to download bundle`);
14
- this.io.writeErr(`\u2717 ${result.error.message}`);
15
- return;
16
- }
17
- Readable.fromWeb(result.value).pipe(this.process.stdout);
18
- });
19
- export {
20
- downloadBundle
21
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=bundle.impl.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.impl.test.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/bundle.impl.test.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- import { buildCommand, buildRouteMap } from "@stricli/core";
2
- import { globalFlags } from "../flags.js";
3
- const bundleCommands = buildRouteMap({
4
- docs: {
5
- brief: "Commands for managing worker bundles"
6
- },
7
- routes: {
8
- download: buildCommand({
9
- docs: {
10
- brief: "Download the bundle for the worker"
11
- },
12
- parameters: {
13
- flags: {
14
- ...globalFlags
15
- }
16
- },
17
- loader: () => import("./bundle.impl.js").then((m) => m.downloadBundle)
18
- })
19
- }
20
- });
21
- export {
22
- bundleCommands
23
- };
@@ -1,2 +0,0 @@
1
- export declare const capabilitiesCommands: import("@stricli/core").RouteMap<import("../context.js").LocalContext>;
2
- //# sourceMappingURL=capabilities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/capabilities.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB,wEAqB/B,CAAC"}
@@ -1,3 +0,0 @@
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>;
3
- //# sourceMappingURL=capabilities.impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilities.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/capabilities.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,gBAAgB,uHA0C3B,CAAC"}