@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
package/dist/flags.d.ts CHANGED
@@ -7,14 +7,19 @@ export interface GlobalFlags {
7
7
  env?: Environment;
8
8
  token?: string;
9
9
  "base-url"?: string;
10
+ space?: string;
10
11
  }
11
12
  export declare const globalFlags: {
12
13
  [K in keyof Required<GlobalFlags>]: TypedFlagParameter<GlobalFlags[K], LocalContext>;
13
14
  };
14
15
  export interface FormatFlags {
15
16
  plain: boolean;
17
+ human: boolean;
18
+ json: boolean;
16
19
  }
17
20
  export declare const formatFlags: {
18
21
  [K in keyof Required<FormatFlags>]: TypedFlagParameter<FormatFlags[K], LocalContext>;
19
22
  };
23
+ export type OutputFormat = "human" | "plain" | "json";
24
+ export declare function resolveFormat(flags: FormatFlags, process: NodeJS.Process): OutputFormat;
20
25
  //# sourceMappingURL=flags.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,C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;KACxB,CAAC,IAAI,MAAM,QAAQ,CAAC,WAAW,CAAC,GAAG,kBAAkB,CACrD,WAAW,CAAC,CAAC,CAAC,EACd,YAAY,CACZ;CAiBD,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAEtD,wBAAgB,aAAa,CAC5B,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,CAAC,OAAO,GACrB,YAAY,CAoBd"}
package/dist/flags.js CHANGED
@@ -28,6 +28,12 @@ const globalFlags = {
28
28
  parse: String,
29
29
  brief: "The base URL to use for all API requests",
30
30
  optional: true
31
+ },
32
+ space: {
33
+ kind: "parsed",
34
+ parse: String,
35
+ brief: "Space ID to use. Overrides local config and global default. Triggers login if not authenticated.",
36
+ optional: true
31
37
  }
32
38
  };
33
39
  const formatFlags = {
@@ -35,9 +41,36 @@ const formatFlags = {
35
41
  kind: "boolean",
36
42
  brief: "Output the results in plain text format",
37
43
  default: false
44
+ },
45
+ human: {
46
+ kind: "boolean",
47
+ brief: "Output the results in a human-friendly format",
48
+ default: false
49
+ },
50
+ json: {
51
+ kind: "boolean",
52
+ brief: "Output the results as JSON",
53
+ default: false
38
54
  }
39
55
  };
56
+ function resolveFormat(flags, process) {
57
+ const flagCount = Number(flags.plain) + Number(flags.human) + Number(flags.json);
58
+ if (flagCount > 1) {
59
+ throw new Error("Only one of --plain, --human, or --json can be used.");
60
+ }
61
+ if (flags.json) {
62
+ return "json";
63
+ }
64
+ if (flags.plain) {
65
+ return "plain";
66
+ }
67
+ if (flags.human) {
68
+ return "human";
69
+ }
70
+ return process.stdout.isTTY ? "human" : "plain";
71
+ }
40
72
  export {
41
73
  formatFlags,
42
- globalFlags
74
+ globalFlags,
75
+ resolveFormat
43
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eA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E,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,cAAe,SAAQ,YAAY;IACnD,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACpD,SAAS,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,SAAS,QAAQ,GAAG,EAAE,EACzE,OAAO,EAAE,CACR,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,KAAK,EACZ,GAAG,IAAI,EAAE,IAAI,KACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,IAGxB,MAAM,YAAY,EAClB,OAAO,WAAW,GAAG,KAAK,EAC1B,GAAG,MAAM,IAAI,mBA6Bd;AAED,wBAAgB,kBAAkB,CACjC,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,IAAI,SAAS,QAAQ,GAAG,EAAE,EAEhC,OAAO,EAAE,CACR,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,KAAK,EACZ,GAAG,IAAI,EAAE,IAAI,KACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,UAzClB,YAAY,8DAwDnB"}
package/dist/handler.js CHANGED
@@ -2,14 +2,20 @@ import { ApiClient } from "./api/client.js";
2
2
  import { Config } from "./config.js";
3
3
  function buildHandler(handler) {
4
4
  return async function(flags, ...args) {
5
- const globalConfigPath = Config.resolveSpaceCachePath({
6
- env: this.process.env
5
+ const globalConfigPath = Config.resolveGlobalConfigPath({
6
+ env: this.process.env,
7
+ create: true
8
+ });
9
+ const spaceCachePath = Config.resolveSpaceCachePath({
10
+ env: this.process.env,
11
+ create: true
7
12
  });
8
13
  const localConfigPath = Config.resolveLocalConfigPath({
9
14
  filePath: flags.config ?? this.process.env.WORKERS_CONFIG ?? "./workers.json"
10
15
  });
11
16
  const config = Config.load({
12
- spaceCachePath: globalConfigPath,
17
+ globalConfigPath,
18
+ spaceCachePath,
13
19
  localPath: localConfigPath,
14
20
  env: process.env,
15
21
  flags
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAgDA,eAAO,MAAM,GAAG,0EAgBd,CAAC"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAmFA,eAAO,MAAM,GAAG,0EAgBd,CAAC"}
package/dist/routes.js CHANGED
@@ -3,27 +3,59 @@ 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 deleteWorker from "./commands/delete.js";
6
7
  import deploy from "./commands/deploy.js";
7
8
  import { envCommands } from "./commands/env.js";
8
9
  import exec from "./commands/exec.js";
10
+ import list from "./commands/list.js";
9
11
  import { oauthCommands } from "./commands/oauth.js";
10
12
  import pack from "./commands/pack.js";
11
13
  import { runsCommands } from "./commands/runs.js";
12
14
  import { secretsCommands } from "./commands/secrets.js";
13
15
  import { TokenNotSetError } from "./token.js";
16
+ const workersBanner = [
17
+ "\u2566 \u2566\u2554\u2550\u2557\u2566\u2550\u2557\u2566\u2554\u2550\u2554\u2550\u2557\u2566\u2550\u2557\u2554\u2550\u2557",
18
+ "\u2551\u2551\u2551\u2551 \u2551\u2560\u2566\u255D\u2560\u2569\u2557\u2551\u2563 \u2560\u2566\u255D\u255A\u2550\u2557",
19
+ "\u255A\u2569\u255D\u255A\u2550\u255D\u2569\u255A\u2550\u2569 \u2569\u255A\u2550\u255D\u2569\u255A\u2550\u255A\u2550\u255D"
20
+ ].join("\n");
14
21
  const routes = buildRouteMap({
15
22
  docs: {
16
- brief: "A CLI for the Project Ajax platform",
17
- fullDescription: `
18
- The Project Ajax CLI is a tool for managing workers, which run code written by
19
- you, other developers, or AI agents to perform automation tasks, such as syncing
20
- data, providing tools to Custom Agents, or running automation tasks.
23
+ brief: "A CLI for the Notion Workers platform",
24
+ fullDescription: `${workersBanner}
25
+
26
+ The Notion Workers CLI is a tool for managing workers, which run code written by
27
+ you, other developers, or AI agents to perform tasks such as syncing data,
28
+ providing tools to Custom Agents, or running scheduled jobs.
29
+
30
+ \x1B[1mAUTHENTICATION\x1B[0m
31
+
32
+ Authentication is handled via \`workers auth login\`, which opens a browser flow.
33
+ Tokens are stored in the system keychain per space, so you can be logged into
34
+ multiple spaces at once. Authenticated spaces are cached in \`spaces.json\`, and
35
+ the global default space is stored in \`config.json\`.
36
+ Commands resolve the active space in this order: \`--space\`, \`WORKERS_SPACE_ID\`,
37
+ local \`workers.json\`, then \`config.json\`'s defaultSpaceId. Passing \`--space\`
38
+ will prompt a login if that space isn't authenticated yet.
39
+
40
+ \x1B[1mCONFIGURATION\x1B[0m
41
+
42
+ Configuration lives in two places:
43
+ - \`workers.json\` is the local project config (environment, base URL, spaceId,
44
+ workerId). By default it lives in the current directory and is only created
45
+ when the CLI detects a worker project. You can override the path with
46
+ \`--config\` or \`WORKERS_CONFIG\`.
47
+ - Global config files (\`config.json\` and \`spaces.json\`) live under
48
+ \`$NOTION_HOME\`, \`$XDG_CONFIG_HOME/notion\`, \`$HOME/.config/notion\`, or
49
+ \`$HOME/.notion\`.
50
+
51
+ \x1B[1mENVIRONMENT VARIABLES\x1B[0m
21
52
 
22
53
  Most flags are configured either with a config file or flags, but environment
23
54
  variables can also be provided:
24
55
 
25
56
  - WORKERS_CONFIG: The path to the config file to use (e.g. ./workers.dev.json)
26
57
  - WORKERS_TOKEN: The token to use for authentication
58
+ - WORKERS_SPACE_ID: The space ID to use (overrides local config and default space)
27
59
  - WORKERS_ENVIRONMENT: The environment to use
28
60
  - WORKERS_BASE_URL: The base API URL to use
29
61
  `.trim(),
@@ -34,8 +66,10 @@ variables can also be provided:
34
66
  routes: {
35
67
  auth: authCommands,
36
68
  capabilities: capabilitiesCommands,
69
+ delete: deleteWorker,
37
70
  deploy,
38
71
  exec,
72
+ list,
39
73
  oauth: oauthCommands,
40
74
  env: envCommands,
41
75
  runs: runsCommands,
package/dist/token.d.ts CHANGED
@@ -21,6 +21,13 @@ export declare function fetchToken(spaceId: string): Promise<string | null>;
21
21
  * @param token The token to store.
22
22
  */
23
23
  export declare function storeToken(spaceId: string, token: string): Promise<void>;
24
+ /**
25
+ * Delete a token from the keychain.
26
+ *
27
+ * @param spaceId The space ID to delete the token for.
28
+ * @returns True if the token was deleted, false if it didn't exist.
29
+ */
30
+ export declare function deleteToken(spaceId: string): Promise<boolean>;
24
31
  /**
25
32
  * Given a token string, parse its info and return the info.
26
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI3B;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAEzC,OAAO,GAAE,MAAiF;CAK3F;AAID;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAE9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAQnD"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI3B;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAEzC,OAAO,GAAE,MAAiF;CAK3F;AAID;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAE9D;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAQnD"}
package/dist/token.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getPassword, setPassword } from "cross-keychain";
1
+ import { deletePassword, getPassword, setPassword } from "cross-keychain";
2
2
  class InvalidTokenError extends Error {
3
3
  constructor(message) {
4
4
  super(message);
@@ -19,6 +19,14 @@ async function fetchToken(spaceId) {
19
19
  async function storeToken(spaceId, token) {
20
20
  await setPassword(SERVICE_NAME, spaceId, token);
21
21
  }
22
+ async function deleteToken(spaceId) {
23
+ try {
24
+ await deletePassword(SERVICE_NAME, spaceId);
25
+ return true;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
22
30
  function parseToken(token) {
23
31
  const parts = splitToken(token);
24
32
  if (parts[0] !== "v1") {
@@ -52,6 +60,7 @@ function decodeInfo(encodedInfo) {
52
60
  export {
53
61
  InvalidTokenError,
54
62
  TokenNotSetError,
63
+ deleteToken,
55
64
  fetchToken,
56
65
  parseToken,
57
66
  storeToken
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@project-ajax/cli",
3
- "version": "0.0.17",
4
- "description": "A CLI for the Project Ajax platform",
3
+ "version": "0.0.19",
4
+ "description": "A CLI for the Notion Workers platform",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
7
  "bin": {