@project-ajax/sdk 0.0.60 → 0.0.61
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.
- package/package.json +3 -11
- package/dist/cli/api/client.d.ts +0 -212
- package/dist/cli/api/client.d.ts.map +0 -1
- package/dist/cli/api/client.js +0 -330
- package/dist/cli/api/result.d.ts +0 -43
- package/dist/cli/api/result.d.ts.map +0 -1
- package/dist/cli/api/result.js +0 -43
- package/dist/cli/bin/cli.d.ts +0 -3
- package/dist/cli/bin/cli.d.ts.map +0 -1
- package/dist/cli/bin/cli.js +0 -5
- package/dist/cli/commands/auth.d.ts +0 -2
- package/dist/cli/commands/auth.d.ts.map +0 -1
- package/dist/cli/commands/auth.impl.d.ts +0 -5
- package/dist/cli/commands/auth.impl.d.ts.map +0 -1
- package/dist/cli/commands/auth.impl.js +0 -45
- package/dist/cli/commands/auth.impl.test.d.ts +0 -2
- package/dist/cli/commands/auth.impl.test.d.ts.map +0 -1
- package/dist/cli/commands/auth.js +0 -56
- package/dist/cli/commands/bundle.d.ts +0 -2
- package/dist/cli/commands/bundle.d.ts.map +0 -1
- package/dist/cli/commands/bundle.impl.d.ts +0 -2
- package/dist/cli/commands/bundle.impl.d.ts.map +0 -1
- package/dist/cli/commands/bundle.impl.js +0 -21
- package/dist/cli/commands/bundle.impl.test.d.ts +0 -2
- package/dist/cli/commands/bundle.impl.test.d.ts.map +0 -1
- package/dist/cli/commands/bundle.js +0 -23
- package/dist/cli/commands/capabilities.d.ts +0 -2
- package/dist/cli/commands/capabilities.d.ts.map +0 -1
- package/dist/cli/commands/capabilities.impl.d.ts +0 -3
- package/dist/cli/commands/capabilities.impl.d.ts.map +0 -1
- package/dist/cli/commands/capabilities.impl.js +0 -40
- package/dist/cli/commands/capabilities.js +0 -24
- package/dist/cli/commands/connect.d.ts +0 -2
- package/dist/cli/commands/connect.d.ts.map +0 -1
- package/dist/cli/commands/connect.impl.d.ts +0 -6
- package/dist/cli/commands/connect.impl.d.ts.map +0 -1
- package/dist/cli/commands/connect.impl.js +0 -116
- package/dist/cli/commands/connect.js +0 -78
- package/dist/cli/commands/deploy.d.ts +0 -3
- package/dist/cli/commands/deploy.d.ts.map +0 -1
- package/dist/cli/commands/deploy.impl.d.ts +0 -6
- package/dist/cli/commands/deploy.impl.d.ts.map +0 -1
- package/dist/cli/commands/deploy.impl.js +0 -60
- package/dist/cli/commands/deploy.impl.test.d.ts +0 -2
- package/dist/cli/commands/deploy.impl.test.d.ts.map +0 -1
- package/dist/cli/commands/deploy.js +0 -22
- package/dist/cli/commands/env.d.ts +0 -2
- package/dist/cli/commands/env.d.ts.map +0 -1
- package/dist/cli/commands/env.impl.d.ts +0 -11
- package/dist/cli/commands/env.impl.d.ts.map +0 -1
- package/dist/cli/commands/env.impl.js +0 -62
- package/dist/cli/commands/env.js +0 -39
- package/dist/cli/commands/exec.d.ts +0 -3
- package/dist/cli/commands/exec.d.ts.map +0 -1
- package/dist/cli/commands/exec.impl.d.ts +0 -7
- package/dist/cli/commands/exec.impl.d.ts.map +0 -1
- package/dist/cli/commands/exec.impl.js +0 -123
- package/dist/cli/commands/exec.js +0 -30
- package/dist/cli/commands/runs.d.ts +0 -2
- package/dist/cli/commands/runs.d.ts.map +0 -1
- package/dist/cli/commands/runs.impl.d.ts +0 -4
- package/dist/cli/commands/runs.impl.d.ts.map +0 -1
- package/dist/cli/commands/runs.impl.js +0 -71
- package/dist/cli/commands/runs.js +0 -45
- package/dist/cli/commands/secrets.d.ts +0 -2
- package/dist/cli/commands/secrets.d.ts.map +0 -1
- package/dist/cli/commands/secrets.impl.d.ts +0 -5
- package/dist/cli/commands/secrets.impl.d.ts.map +0 -1
- package/dist/cli/commands/secrets.impl.js +0 -99
- package/dist/cli/commands/secrets.js +0 -64
- package/dist/cli/commands/utils/testing.d.ts +0 -13
- package/dist/cli/commands/utils/testing.d.ts.map +0 -1
- package/dist/cli/commands/utils/testing.js +0 -58
- package/dist/cli/config.d.ts +0 -63
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -194
- package/dist/cli/config.test.d.ts +0 -2
- package/dist/cli/config.test.d.ts.map +0 -1
- package/dist/cli/context.d.ts +0 -15
- package/dist/cli/context.d.ts.map +0 -1
- package/dist/cli/context.js +0 -16
- package/dist/cli/deploy.d.ts +0 -37
- package/dist/cli/deploy.d.ts.map +0 -1
- package/dist/cli/deploy.js +0 -100
- package/dist/cli/flags.d.ts +0 -21
- package/dist/cli/flags.d.ts.map +0 -1
- package/dist/cli/flags.js +0 -49
- package/dist/cli/handler.d.ts +0 -14
- package/dist/cli/handler.d.ts.map +0 -1
- package/dist/cli/handler.js +0 -32
- package/dist/cli/io.d.ts +0 -55
- package/dist/cli/io.d.ts.map +0 -1
- package/dist/cli/io.js +0 -96
- package/dist/cli/routes.d.ts +0 -2
- package/dist/cli/routes.d.ts.map +0 -1
- package/dist/cli/routes.js +0 -62
- package/dist/cli/utils/array.d.ts +0 -2
- package/dist/cli/utils/array.d.ts.map +0 -1
- package/dist/cli/utils/array.js +0 -10
- package/dist/cli/utils/openUrl.d.ts +0 -4
- package/dist/cli/utils/openUrl.d.ts.map +0 -1
- package/dist/cli/utils/openUrl.js +0 -43
- package/dist/cli/utils/string.d.ts +0 -2
- package/dist/cli/utils/string.d.ts.map +0 -1
- package/dist/cli/utils/string.js +0 -12
- package/src/cli/api/client.ts +0 -628
- package/src/cli/api/result.ts +0 -71
- package/src/cli/bin/cli.ts +0 -7
- package/src/cli/commands/.cursor/rules/testing-commands.mdc +0 -212
- package/src/cli/commands/auth.impl.test.ts +0 -228
- package/src/cli/commands/auth.impl.ts +0 -56
- package/src/cli/commands/auth.ts +0 -63
- package/src/cli/commands/bundle.impl.test.ts +0 -143
- package/src/cli/commands/bundle.impl.ts +0 -21
- package/src/cli/commands/bundle.ts +0 -23
- package/src/cli/commands/capabilities.impl.ts +0 -47
- package/src/cli/commands/capabilities.ts +0 -25
- package/src/cli/commands/connect.impl.ts +0 -149
- package/src/cli/commands/connect.ts +0 -80
- package/src/cli/commands/deploy.impl.test.ts +0 -254
- package/src/cli/commands/deploy.impl.ts +0 -73
- package/src/cli/commands/deploy.ts +0 -22
- package/src/cli/commands/env.impl.ts +0 -88
- package/src/cli/commands/env.ts +0 -38
- package/src/cli/commands/exec.impl.ts +0 -171
- package/src/cli/commands/exec.ts +0 -32
- package/src/cli/commands/runs.impl.ts +0 -87
- package/src/cli/commands/runs.ts +0 -49
- package/src/cli/commands/secrets.impl.ts +0 -130
- package/src/cli/commands/secrets.ts +0 -73
- package/src/cli/commands/utils/testing.ts +0 -66
- package/src/cli/config.test.ts +0 -108
- package/src/cli/config.ts +0 -265
- package/src/cli/context.ts +0 -26
- package/src/cli/deploy.ts +0 -190
- package/src/cli/flags.ts +0 -72
- package/src/cli/handler.ts +0 -68
- package/src/cli/io.ts +0 -132
- package/src/cli/routes.ts +0 -61
- package/src/cli/utils/array.ts +0 -7
- package/src/cli/utils/openUrl.ts +0 -53
- package/src/cli/utils/string.ts +0 -9
|
@@ -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 +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 +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 +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 +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 +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 +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"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Result } from "../api/result.js";
|
|
2
|
-
import { buildAuthedHandler } from "../handler.js";
|
|
3
|
-
const listCapabilities = buildAuthedHandler(async function(flags) {
|
|
4
|
-
const { workerId } = this.config;
|
|
5
|
-
if (!workerId) {
|
|
6
|
-
throw new Error(
|
|
7
|
-
"No worker configured. Run 'workers deploy' first to create a worker."
|
|
8
|
-
);
|
|
9
|
-
}
|
|
10
|
-
this.process.stderr.write(`Fetching capabilities...`);
|
|
11
|
-
const result = await this.apiClient.listCapabilities(workerId);
|
|
12
|
-
if (Result.isSuccess(result)) {
|
|
13
|
-
this.process.stderr.write("OK\n\n");
|
|
14
|
-
const data = Result.unwrap(result);
|
|
15
|
-
if (data.capabilities.length === 0) {
|
|
16
|
-
this.io.writeErr("No capabilities found for this worker.");
|
|
17
|
-
} else {
|
|
18
|
-
this.io.writeTableOut({
|
|
19
|
-
headers: ["Key", "Tag"],
|
|
20
|
-
rows: data.capabilities.map((capability) => [
|
|
21
|
-
capability.key,
|
|
22
|
-
capability._tag
|
|
23
|
-
]),
|
|
24
|
-
plain: flags.plain
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
this.process.stderr.write("ERROR\n\n");
|
|
29
|
-
if (result.error.validationError) {
|
|
30
|
-
this.io.writeErr(`\u2717 ${result.error.validationError.debugMessage}`);
|
|
31
|
-
throw new Error(result.error.validationError.debugMessage);
|
|
32
|
-
} else {
|
|
33
|
-
this.io.writeErr(`\u2717 ${result.error.message}`);
|
|
34
|
-
throw new Error(result.error.message);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
export {
|
|
39
|
-
listCapabilities
|
|
40
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { buildCommand, buildRouteMap } from "@stricli/core";
|
|
2
|
-
import { formatFlags, globalFlags } from "../flags.js";
|
|
3
|
-
const capabilitiesCommands = buildRouteMap({
|
|
4
|
-
docs: {
|
|
5
|
-
brief: "Commands for managing worker capabilities"
|
|
6
|
-
},
|
|
7
|
-
routes: {
|
|
8
|
-
list: buildCommand({
|
|
9
|
-
docs: {
|
|
10
|
-
brief: "List all capabilities for a worker"
|
|
11
|
-
},
|
|
12
|
-
parameters: {
|
|
13
|
-
flags: {
|
|
14
|
-
...globalFlags,
|
|
15
|
-
...formatFlags
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
loader: () => import("./capabilities.impl.js").then((m) => m.listCapabilities)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
export {
|
|
23
|
-
capabilitiesCommands
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../src/cli/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/cli/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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/deploy.ts"],"names":[],"mappings":";AAGA,wBAkBG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/deploy.impl.ts"],"names":[],"mappings":"AAKA,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,MAAM,uHA+DjB,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Result } from "../api/result.js";
|
|
2
|
-
import { deployWorker } from "../deploy.js";
|
|
3
|
-
import { buildAuthedHandler } from "../handler.js";
|
|
4
|
-
const deploy = buildAuthedHandler(async function(flags) {
|
|
5
|
-
const { token } = this.config.tokenInfo;
|
|
6
|
-
const workerId = this.config.workerId;
|
|
7
|
-
const environment = this.config.environment;
|
|
8
|
-
if (!environment) {
|
|
9
|
-
throw new Error("Unexpected error: Environment not set");
|
|
10
|
-
}
|
|
11
|
-
const workerPath = this.process.cwd();
|
|
12
|
-
this.io.writeErr("Deploying worker...");
|
|
13
|
-
const name = flags.name;
|
|
14
|
-
if (workerId && name) {
|
|
15
|
-
throw new Error("Cannot specify a name when updating an existing worker");
|
|
16
|
-
}
|
|
17
|
-
let result;
|
|
18
|
-
if (workerId) {
|
|
19
|
-
result = await deployWorker(this, {
|
|
20
|
-
workerPath,
|
|
21
|
-
workerId,
|
|
22
|
-
token,
|
|
23
|
-
environment
|
|
24
|
-
});
|
|
25
|
-
} else {
|
|
26
|
-
let validatedName;
|
|
27
|
-
if (name) {
|
|
28
|
-
validatedName = name;
|
|
29
|
-
} else {
|
|
30
|
-
const nameInput = await this.io.input({
|
|
31
|
-
message: "Enter a name for the worker",
|
|
32
|
-
required: true,
|
|
33
|
-
noTTY: "Provide a name for the worker with --name"
|
|
34
|
-
});
|
|
35
|
-
const trimmedName = nameInput?.trim();
|
|
36
|
-
if (!trimmedName) {
|
|
37
|
-
throw new Error("Name is required");
|
|
38
|
-
}
|
|
39
|
-
validatedName = trimmedName;
|
|
40
|
-
}
|
|
41
|
-
result = await deployWorker(this, {
|
|
42
|
-
name: validatedName,
|
|
43
|
-
workerPath,
|
|
44
|
-
token,
|
|
45
|
-
environment
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (Result.isSuccess(result)) {
|
|
49
|
-
const { workerId: workerId2 } = Result.unwrap(result);
|
|
50
|
-
await this.config.update({ workerId: workerId2 });
|
|
51
|
-
this.io.writeErr("\u2713 Successfully deployed worker");
|
|
52
|
-
} else {
|
|
53
|
-
this.io.writeErr("\u2717 Failed to deploy worker");
|
|
54
|
-
this.io.writeErr(result.error.message);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
export {
|
|
59
|
-
deploy
|
|
60
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.impl.test.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/deploy.impl.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { buildCommand } from "@stricli/core";
|
|
2
|
-
import { globalFlags } from "../flags.js";
|
|
3
|
-
var deploy_default = buildCommand({
|
|
4
|
-
docs: {
|
|
5
|
-
brief: "Deploy a worker to the Project Ajax platform"
|
|
6
|
-
},
|
|
7
|
-
parameters: {
|
|
8
|
-
flags: {
|
|
9
|
-
...globalFlags,
|
|
10
|
-
name: {
|
|
11
|
-
kind: "parsed",
|
|
12
|
-
parse: String,
|
|
13
|
-
brief: "The name of the worker (if it has not yet been created)",
|
|
14
|
-
optional: true
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
loader: () => import("./deploy.impl.js").then((m) => m.deploy)
|
|
19
|
-
});
|
|
20
|
-
export {
|
|
21
|
-
deploy_default as default
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/env.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,wEAiCtB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface PullEnvFlags {
|
|
2
|
-
yes: boolean;
|
|
3
|
-
}
|
|
4
|
-
export declare const DEFAULT_ENV_FILE = ".env";
|
|
5
|
-
export declare const pullEnv: (this: import("../context.js").LocalContext, flags: import("../flags.js").GlobalFlags & PullEnvFlags, filePath?: string | undefined) => Promise<void>;
|
|
6
|
-
export declare function serializeEnvFile(envEntries: Array<{
|
|
7
|
-
key: string;
|
|
8
|
-
value: string;
|
|
9
|
-
}>): string;
|
|
10
|
-
export declare function formatEnvValue(value: string): string;
|
|
11
|
-
//# sourceMappingURL=env.impl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env.impl.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/env.impl.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,OAAO,CAAC;CACb;AAED,eAAO,MAAM,gBAAgB,SAAS,CAAC;AAEvC,eAAO,MAAM,OAAO,uJAiDlB,CAAC;AAEH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/C,MAAM,CASR;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAapD"}
|