@project-ajax/cli 0.0.15 → 0.0.16

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.
@@ -3,10 +3,8 @@
3
3
  */
4
4
  import type { IO } from "../io.js";
5
5
  import { Result } from "./result.js";
6
- export type Environment = "local" | "staging" | "dev" | "prod";
7
6
  interface ApiClientConfig {
8
7
  token: string;
9
- environment: Environment;
10
8
  baseUrl?: string | undefined;
11
9
  cellId: string;
12
10
  writer: IO;
@@ -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,CACjB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EA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A;KAAE,EAAE,QAAQ,CAAC,CAAC;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"}
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,wEAkEvB,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,wEAmCvB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import type { GlobalFlags } from "../flags.js";
2
2
  import { type HandlerContext } from "../handler.js";
3
- export declare function runLogin(context: HandlerContext, token?: string): Promise<void>;
4
- export declare const login: (this: import("../context.js").LocalContext, flags: GlobalFlags, token?: string | undefined) => Promise<void>;
3
+ export declare function runLogin(context: HandlerContext): Promise<void>;
4
+ export declare const login: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
5
5
  export declare const show: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
6
- export declare const logout: (this: import("../context.js").LocalContext, flags: GlobalFlags) => Promise<void>;
7
6
  //# sourceMappingURL=auth.impl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAwElE,wBAAsB,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,iBAyFrE;AAED,eAAO,MAAM,KAAK,+GAMhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAEf,CAAC;AAEH,eAAO,MAAM,MAAM,mFAIjB,CAAC"}
1
+ {"version":3,"file":"auth.impl.d.ts","sourceRoot":"","sources":["../../src/commands/auth.impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AA2ElE,wBAAsB,QAAQ,CAAC,OAAO,EAAE,cAAc,iBA2CrD;AA0ED,eAAO,MAAM,KAAK,mFAKhB,CAAC;AAEH,eAAO,MAAM,IAAI,mFAGf,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { buildHandler } from "../handler.js";
2
+ import { fetchToken, parseToken } from "../token.js";
2
3
  import { openNotionUrl } from "../utils/openUrl.js";
4
+ const NEW_SPACE_VALUE = "__new_space__";
3
5
  async function loginFetch(baseUrl, endpoint, body) {
4
6
  const url = `${baseUrl}/api/v3${endpoint}`;
5
7
  const response = await fetch(url, {
@@ -30,26 +32,48 @@ async function pollLoginRedeem(baseUrl, sessionId, timeoutMs = 3e5, intervalMs =
30
32
  }
31
33
  return { status: "expired" };
32
34
  }
33
- async function runLogin(context, token) {
34
- const environment = context.config.environment;
35
- const baseUrl = context.config.baseUrl;
36
- if (token) {
37
- const update2 = {
38
- token,
39
- workerId: null
40
- };
41
- if (environment !== "prod") {
42
- update2.environment = environment;
35
+ async function runLogin(context) {
36
+ const cachedSpaces = context.config.getCachedSpaces();
37
+ if (process.stdin.isTTY && cachedSpaces.length > 0) {
38
+ const choices = [
39
+ ...cachedSpaces.map((space) => ({
40
+ name: space.name,
41
+ value: space.id
42
+ })),
43
+ {
44
+ name: "Authenticate with new space",
45
+ value: NEW_SPACE_VALUE
46
+ }
47
+ ];
48
+ const selectedValue = await context.io.select({
49
+ message: "Select a space",
50
+ choices,
51
+ noTTY: "Run 'workers auth login' to authenticate, or set WORKERS_TOKEN."
52
+ });
53
+ if (selectedValue !== NEW_SPACE_VALUE) {
54
+ const spaceId = selectedValue;
55
+ const token = await fetchToken(spaceId);
56
+ if (token) {
57
+ context.config.switchToSpace(spaceId);
58
+ const space = cachedSpaces.find((s) => s.id === spaceId);
59
+ context.io.writeErr(`Switched to space: ${space?.name ?? spaceId}`);
60
+ return;
61
+ }
62
+ context.io.writeErr(
63
+ "Token not found for this space. Starting browser login..."
64
+ );
43
65
  }
44
- await context.config.update(update2);
45
- context.io.writeErr("Successfully logged in!");
46
- return;
47
66
  }
67
+ await runBrowserLogin(context);
68
+ }
69
+ async function runBrowserLogin(context) {
70
+ const environment = context.config.environment;
71
+ const baseURL = context.config.baseURL;
48
72
  context.io.writeErr("Starting browser login...\n");
49
73
  let initResponse;
50
74
  try {
51
75
  initResponse = await loginFetch(
52
- baseUrl,
76
+ baseURL,
53
77
  "/workersCliLoginInit",
54
78
  {}
55
79
  );
@@ -74,7 +98,7 @@ async function runLogin(context, token) {
74
98
  context.io.writeErr("(Press Ctrl+C to cancel)\n");
75
99
  let redeemResponse;
76
100
  try {
77
- redeemResponse = await pollLoginRedeem(baseUrl, sessionId);
101
+ redeemResponse = await pollLoginRedeem(baseURL, sessionId);
78
102
  } catch (error) {
79
103
  context.io.writeErr(
80
104
  `Login failed: ${error instanceof Error ? error.message : String(error)}`
@@ -89,30 +113,25 @@ async function runLogin(context, token) {
89
113
  context.io.writeErr("Login failed. Please try again.");
90
114
  process.exit(1);
91
115
  }
92
- const update = {
116
+ const tokenInfo = parseToken(redeemResponse.token);
117
+ await context.config.login({
118
+ environment,
93
119
  token: redeemResponse.token,
94
- workerId: null
95
- };
96
- if (environment !== "prod") {
97
- update.environment = environment;
98
- }
99
- await context.config.update(update);
100
- context.io.writeErr("\u2713 Successfully logged in!");
120
+ spaceId: tokenInfo.spaceId,
121
+ spaceName: redeemResponse.spaceName,
122
+ cellId: tokenInfo.cellId
123
+ });
124
+ context.io.writeErr("Logged in.");
101
125
  }
102
- const login = buildHandler(async function(_, token) {
103
- await runLogin(this, token);
126
+ const login = buildHandler(async function(_) {
127
+ await runLogin(this);
104
128
  });
105
- const show = buildHandler(function() {
106
- this.io.writeOut(`${this.config.token ?? ""}`);
107
- });
108
- const logout = buildHandler(async function() {
109
- await this.config.update({
110
- token: null
111
- });
129
+ const show = buildHandler(async function() {
130
+ const tokenAndInfo = await this.config.getToken();
131
+ this.io.writeOut(`${tokenAndInfo?.[0] ?? ""}`);
112
132
  });
113
133
  export {
114
134
  login,
115
- logout,
116
135
  runLogin,
117
136
  show
118
137
  };
@@ -10,25 +10,9 @@ const authCommands = buildRouteMap({
10
10
  brief: "Login to the Project Ajax platform via browser authentication",
11
11
  fullDescription: `
12
12
  Opens a browser window for you to authenticate and select a workspace.
13
- A verification code will be displayed in the terminal - make sure it matches
14
- what you see in your browser before confirming.
15
-
16
- Alternatively, you can pass a token directly (for automation or CI environments):
17
- workers auth login <token>
18
13
  `.trim()
19
14
  },
20
15
  parameters: {
21
- positional: {
22
- kind: "tuple",
23
- parameters: [
24
- {
25
- brief: "A Workers API token (optional, for CI/automation)",
26
- parse: String,
27
- placeholder: "api-token",
28
- optional: true
29
- }
30
- ]
31
- },
32
16
  flags: {
33
17
  ...globalFlags
34
18
  }
@@ -45,17 +29,6 @@ Alternatively, you can pass a token directly (for automation or CI environments)
45
29
  }
46
30
  },
47
31
  loader: () => import("./auth.impl.js").then((m) => m.show)
48
- }),
49
- logout: buildCommand({
50
- docs: {
51
- brief: "Unset the token for the CLI"
52
- },
53
- parameters: {
54
- flags: {
55
- ...globalFlags
56
- }
57
- },
58
- loader: () => import("./auth.impl.js").then((m) => m.logout)
59
32
  })
60
33
  }
61
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.impl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,MAAM,iGAoFjB,CAAC"}
1
+ {"version":3,"file":"deploy.impl.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.impl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,MAAM,iGAmFjB,CAAC"}
@@ -4,10 +4,10 @@ import { deployWorker } from "../deploy.js";
4
4
  import { buildHandler } from "../handler.js";
5
5
  import { runLogin } from "./auth.impl.js";
6
6
  const deploy = buildHandler(async function(flags) {
7
- if (!this.config.token) {
7
+ if (!await this.config.getToken()) {
8
8
  await runLogin(this);
9
9
  }
10
- const { token, cellId } = this.config.tokenInfo;
10
+ const [token, tokenInfo] = await this.config.mustGetToken();
11
11
  const workerId = this.config.workerId;
12
12
  const environment = this.config.environment;
13
13
  if (!environment) {
@@ -16,9 +16,8 @@ const deploy = buildHandler(async function(flags) {
16
16
  const workerPath = this.process.cwd();
17
17
  const apiClient = new ApiClient({
18
18
  token,
19
- environment,
20
- baseUrl: this.config.baseUrl,
21
- cellId,
19
+ baseUrl: this.config.baseURL,
20
+ cellId: tokenInfo.cellId,
22
21
  writer: this.io
23
22
  });
24
23
  const authedContext = { ...this, apiClient };
@@ -60,9 +59,9 @@ const deploy = buildHandler(async function(flags) {
60
59
  }
61
60
  if (Result.isSuccess(result)) {
62
61
  const { workerId: workerId2 } = Result.unwrap(result);
63
- await this.config.update({ workerId: workerId2 });
62
+ this.config.setWorker(workerId2);
64
63
  this.io.writeErr("\u2713 Successfully deployed worker");
65
- const workerUrl = `${this.config.baseUrl}/__workers__/${workerId2}`;
64
+ const workerUrl = `${this.config.baseURL}/__workers__/${workerId2}`;
66
65
  this.io.writeErr("");
67
66
  this.io.writeErr(`Worker Dashboard: ${workerUrl}`);
68
67
  } else {
@@ -129,7 +129,7 @@ ${usageHint}`);
129
129
  }
130
130
  });
131
131
  function showUrls(context, workerId, collectionId) {
132
- const baseUrl = context.config.baseUrl;
132
+ const baseUrl = context.config.baseURL;
133
133
  context.io.writeErr("");
134
134
  const workerUrl = `${baseUrl}/__workers__/${workerId}`;
135
135
  context.io.writeErr(`Worker Dashboard: ${workerUrl}`);
@@ -1,13 +1,28 @@
1
- import { Config, type ConfigMap } from "../../config.js";
1
+ import { Config, type LocalConfig, type SpaceCache } from "../../config.js";
2
2
  import type { LocalContext } from "../../context.js";
3
3
  import type { GlobalFlags } from "../../flags.js";
4
- export declare const tmpDirectories: string[];
4
+ import type { TokenInfo } from "../../token.js";
5
5
  export declare const baseFlags: GlobalFlags;
6
- export declare function createAndLoadConfig({ configFile, env, flags, }: {
7
- configFile: Partial<ConfigMap>;
6
+ export declare function preventConfigResolution(): void;
7
+ export declare function createAndLoadConfig(args?: {
8
+ globalConfig?: SpaceCache;
9
+ localConfig?: LocalConfig;
8
10
  env?: Partial<NodeJS.ProcessEnv>;
9
11
  flags?: Partial<GlobalFlags>;
10
- }): Promise<[config: Config, path: string]>;
12
+ }): Promise<Config>;
11
13
  export declare function createBaseContext(): LocalContext;
12
14
  export declare function cleanupTmpDirectories(): Promise<void>;
15
+ /**
16
+ * Generates a v1 token string with the given token info. The token is not valid
17
+ * due to an invalid signature.
18
+ *
19
+ * @param args Optional token info to use for the token
20
+ * @returns A v1 token string
21
+ */
22
+ export declare function generateV1Token(args?: {
23
+ spaceId?: string;
24
+ cellId?: string;
25
+ }, opts?: {
26
+ mock?: boolean;
27
+ }): [string, TokenInfo];
13
28
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/testing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,eAAO,MAAM,cAAc,EAAE,MAAM,EAAO,CAAC;AAE3C,eAAO,MAAM,SAAS,EAAE,WAEvB,CAAC;AAEF,wBAAsB,mBAAmB,CAAC,EACzC,UAAU,EACV,GAAG,EACH,KAAK,GACL,EAAE;IACF,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC7B,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAa1C;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD;AAED,wBAAsB,qBAAqB,kBAO1C"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/testing.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,WAEvB,CAAC;AAEF,wBAAgB,uBAAuB,SAGtC;AAED,wBAAsB,mBAAmB,CACxC,IAAI,GAAE;IACL,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACxB,GACJ,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD;AAID,wBAAsB,qBAAqB,kBAU1C;AA2BD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,EAChD,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAoB,GACxC,CAAC,MAAM,EAAE,SAAS,CAAC,CAuBrB"}
@@ -1,29 +1,36 @@
1
1
  import * as fs from "node:fs";
2
- import { mkdtemp, rm, writeFile } from "node:fs/promises";
2
+ import * as fsp from "node:fs/promises";
3
3
  import * as os from "node:os";
4
4
  import { tmpdir } from "node:os";
5
5
  import * as path from "node:path";
6
+ import { getPassword } from "cross-keychain";
7
+ import { vi } from "vitest";
6
8
  import { Config } from "../../config.js";
7
9
  import { IO } from "../../io.js";
8
- const tmpDirectories = [];
9
10
  const baseFlags = {
10
11
  debug: false
11
12
  };
12
- async function createAndLoadConfig({
13
- configFile,
14
- env,
15
- flags
16
- }) {
17
- const configFilePath = await createConfigFile(configFile);
18
- const map = await Config.load({
19
- configFilePath,
20
- processEnv: env ?? {},
13
+ function preventConfigResolution() {
14
+ vi.spyOn(Config, "resolveSpaceCachePath").mockImplementation(() => "");
15
+ vi.spyOn(Config, "resolveLocalConfigPath").mockImplementation(() => "");
16
+ }
17
+ async function createAndLoadConfig(args = {}) {
18
+ const globalConfig = args.globalConfig ?? Config.emptySpaceCache;
19
+ const localConfig = args.localConfig ?? Config.emptyLocalConfig;
20
+ const { globalPath, localPath } = await createConfigFiles({
21
+ globalConfig,
22
+ localConfig
23
+ });
24
+ const config = Config.load({
25
+ spaceCachePath: globalPath,
26
+ localPath,
27
+ env: args.env ?? {},
21
28
  flags: {
22
29
  ...baseFlags,
23
- ...flags ?? {}
30
+ ...args.flags ?? {}
24
31
  }
25
32
  });
26
- return [map, configFilePath];
33
+ return config;
27
34
  }
28
35
  function createBaseContext() {
29
36
  return {
@@ -34,25 +41,59 @@ function createBaseContext() {
34
41
  process
35
42
  };
36
43
  }
44
+ let tmpDirectories = [];
37
45
  async function cleanupTmpDirectories() {
38
- while (tmpDirectories.length > 0) {
39
- const dir = tmpDirectories.pop();
40
- if (dir) {
41
- await rm(dir, { recursive: true, force: true });
42
- }
43
- }
46
+ await Promise.all(
47
+ tmpDirectories.map(
48
+ (dir) => fsp.rm(dir, { recursive: true, force: true }).catch((error) => {
49
+ console.error(`Error removing temporary directory ${dir}:`, error);
50
+ })
51
+ )
52
+ );
53
+ tmpDirectories = [];
44
54
  }
45
- async function createConfigFile(contents) {
46
- const dir = await mkdtemp(path.join(tmpdir(), "cmd-test-"));
55
+ async function createConfigFiles(args) {
56
+ const dir = await fsp.mkdtemp(path.join(tmpdir(), "cmd-test-"));
47
57
  tmpDirectories.push(dir);
48
- const configFilePath = path.join(dir, "config.json");
49
- await writeFile(configFilePath, JSON.stringify(contents, null, 2), "utf-8");
50
- return configFilePath;
58
+ const globalPath = path.join(dir, "global.json");
59
+ const localPath = path.join(dir, "local.json");
60
+ await fsp.writeFile(
61
+ globalPath,
62
+ JSON.stringify(args.globalConfig, null, 2),
63
+ "utf-8"
64
+ );
65
+ await fsp.writeFile(
66
+ localPath,
67
+ JSON.stringify(args.localConfig, null, 2),
68
+ "utf-8"
69
+ );
70
+ return { globalPath, localPath };
71
+ }
72
+ function generateV1Token(args = {}, opts = { mock: false }) {
73
+ const payload = {
74
+ spaceId: args.spaceId ?? "space-1",
75
+ cellId: args.cellId ?? "cell-1"
76
+ };
77
+ const encodedPayload = Buffer.from(JSON.stringify(payload)).toString(
78
+ "base64url"
79
+ );
80
+ const token = `v1.user.${encodedPayload}.signature`;
81
+ if (opts.mock) {
82
+ vi.mocked(getPassword).mockResolvedValue(token);
83
+ }
84
+ return [
85
+ token,
86
+ {
87
+ spaceId: payload.spaceId,
88
+ cellId: payload.cellId
89
+ }
90
+ ];
51
91
  }
52
92
  export {
53
93
  baseFlags,
54
94
  cleanupTmpDirectories,
55
95
  createAndLoadConfig,
56
96
  createBaseContext,
57
- tmpDirectories
97
+ generateV1Token,
98
+ preventConfigResolution
58
99
  };
package/dist/config.d.ts CHANGED
@@ -1,63 +1,165 @@
1
+ import z from "zod";
1
2
  import type { GlobalFlags } from "./flags.js";
2
- export declare const Environments: readonly ["local", "staging", "dev", "prod"];
3
- export type Environment = (typeof Environments)[number];
4
- export interface ConfigMap {
5
- environment: Environment;
6
- baseUrl: string;
7
- token: string | null;
8
- workerId: string | null;
9
- }
10
- export declare function parseEnvironment(name: string): Environment;
11
- export declare class TokenNotSetError extends Error {
12
- constructor(message?: string);
3
+ import { type TokenInfo } from "./token.js";
4
+ export declare const Environment: z.ZodLiteral<"local" | "dev" | "stg" | "prod">;
5
+ export type Environment = z.infer<typeof Environment>;
6
+ declare const SpaceCache: z.ZodObject<{
7
+ version: z.ZodLiteral<"1">;
8
+ spaces: z.ZodRecord<z.ZodString, z.ZodObject<{
9
+ id: z.ZodString;
10
+ name: z.ZodString;
11
+ cellId: z.ZodString;
12
+ }, z.z.core.$strip>>;
13
+ }, z.z.core.$strip>;
14
+ export type SpaceCache = z.infer<typeof SpaceCache>;
15
+ declare const LocalConfig: z.ZodObject<{
16
+ version: z.ZodLiteral<"1">;
17
+ environment: z.ZodLiteral<"local" | "dev" | "stg" | "prod">;
18
+ baseURL: z.ZodOptional<z.ZodString>;
19
+ spaceId: z.ZodNullable<z.ZodString>;
20
+ workerId: z.ZodNullable<z.ZodString>;
21
+ }, z.z.core.$strip>;
22
+ export type LocalConfig = z.infer<typeof LocalConfig>;
23
+ export declare class NoSuitableConfigFileError extends Error {
24
+ constructor();
13
25
  }
14
26
  /**
15
- * Manages configuration for the CLI.
16
- *
17
- * Environment variables take precedence over the config file.
27
+ * Manages configuration for the command line interface.
18
28
  *
19
- * | Environment Variable | Config File | Description |
20
- * |----------------------|-------------|-------------|
21
- * | WORKERS_TOKEN | token | The token to use for authentication |
22
- * | WORKERS_ENVIRONMENT | environment | The environment to use |
23
- * | WORKERS_WORKER_ID | workerId | The worker ID to use |
24
- * | WORKERS_BASE_URL | baseUrl | The base URL to use |
29
+ * Order of precedence: Command-line flags, environment variables, local config
30
+ * files, where appropriate.
25
31
  */
26
32
  export declare class Config {
27
33
  #private;
28
34
  constructor(opts: {
29
- configMap: ConfigMap;
30
- configFilePath: string;
35
+ spaceCachePath: string;
36
+ spaceCache: SpaceCache;
37
+ localConfigPath: string;
38
+ localConfig: LocalConfig;
39
+ environment: Environment;
40
+ baseURL: string;
41
+ spaceId: string | null;
42
+ workerId: string | null;
43
+ token: string | null;
31
44
  });
32
- get baseUrl(): string;
33
- get token(): string | null;
34
- get environment(): "local" | "staging" | "dev" | "prod";
45
+ get environment(): Environment;
46
+ get baseURL(): string;
47
+ get spaceId(): string | null;
35
48
  get workerId(): string | null;
36
- get tokenInfo(): {
49
+ /**
50
+ * Get the list of cached spaces.
51
+ *
52
+ * @returns An array of cached spaces with id, name, and cellId.
53
+ */
54
+ getCachedSpaces(): Array<{
55
+ id: string;
56
+ name: string;
57
+ cellId: string;
58
+ }>;
59
+ /**
60
+ * Get the token and token information from the keychain.
61
+ *
62
+ * @returns The token and token information, or null if no token is found.
63
+ */
64
+ getToken(): Promise<[token: string, tokenInfo: TokenInfo] | null>;
65
+ /**
66
+ * Get the token and token information from the keychain.
67
+ *
68
+ * Throws an error if no token is found.
69
+ *
70
+ * @returns The token and token information.
71
+ */
72
+ mustGetToken(): Promise<[token: string, tokenInfo: TokenInfo]>;
73
+ /**
74
+ * Log in by updating the local configuration and the space cache, and
75
+ * storing the token in the keychain.
76
+ *
77
+ * @param args The arguments to login.
78
+ * @param args.environment The environment to login to.
79
+ * @param args.token The token to login with.
80
+ * @param args.spaceId The space ID to login to.
81
+ * @param args.spaceName The space name to login to.
82
+ * @param args.cellId The cell ID to login to.
83
+ */
84
+ login(args: {
85
+ environment: Environment;
37
86
  token: string;
38
87
  spaceId: string;
88
+ spaceName: string;
39
89
  cellId: string;
40
- };
90
+ }): Promise<void>;
41
91
  /**
42
- * Update the config with a partial config map.
92
+ * Set the worker ID.
43
93
  *
44
- * This will write only the updated keys in the config file on disk. Not all
45
- * keys are written, since some current keys in the Config object may have
46
- * come from e.g. environment variables, rather than the original config
47
- * file.
94
+ * @param workerId The worker ID to set.
95
+ */
96
+ setWorker(workerId: string): void;
97
+ /**
98
+ * Switch to an existing cached space.
48
99
  *
49
- * @param config The config update.
100
+ * This updates the local configuration to use the specified space.
101
+ * The token for this space should already exist in the keychain.
102
+ *
103
+ * @param spaceId The space ID to switch to.
104
+ * @throws Error if the space is not in the cache.
105
+ */
106
+ switchToSpace(spaceId: string): void;
107
+ /**
108
+ * Resolve the space cache path.
109
+ *
110
+ * @param opts Options for resolving the space cache path.
111
+ * @param opts.filePath The path to the space cache file.
112
+ * @param opts.env The environment variables.
113
+ * @returns The path to the space cache file.
114
+ */
115
+ static resolveSpaceCachePath(opts: {
116
+ filePath?: string;
117
+ env: NodeJS.ProcessEnv;
118
+ }): string;
119
+ /**
120
+ * Resolve the local config path.
121
+ *
122
+ * @param opts Options for resolving the local config path.
123
+ * @param opts.filePath The path to the local config file.
124
+ * @returns
125
+ */
126
+ static resolveLocalConfigPath(opts?: {
127
+ filePath?: string;
128
+ }): string;
129
+ /**
130
+ * Load config from space cache and local config files, then resolve them to
131
+ * a final config for this execution of the command line interface.
132
+ *
133
+ * If the local config is v0, it will be upgraded to v1.
134
+ *
135
+ * Overrides:
136
+ *
137
+ * - Environment: WORKERS_ENVIRONMENT or --env flag
138
+ * - Token: WORKERS_TOKEN or --token flag
139
+ * - Base URL: WORKERS_BASE_URL or --base-url flag
140
+ *
141
+ * @param opts The options to load the config from.
142
+ * @param opts.spaceCachePath The path to the space cache file.
143
+ * @param opts.localPath The path to the local config file.
144
+ * @param opts.env The process environment.
145
+ * @param opts.processEnv The process environment.
146
+ * @param opts.flags The global flags.
147
+ * @returns The resolved config.
50
148
  */
51
- update(config: Partial<ConfigMap>): Promise<void>;
52
149
  static load(opts: {
53
- configFilePath: string;
54
- processEnv: NodeJS.ProcessEnv;
150
+ spaceCachePath: string;
151
+ localPath: string;
152
+ env: NodeJS.ProcessEnv;
55
153
  flags: GlobalFlags;
56
- }): Promise<Config>;
154
+ }): Config;
155
+ /**
156
+ * The empty local config.
157
+ */
158
+ static get emptyLocalConfig(): LocalConfig;
159
+ /**
160
+ * The empty space cache.
161
+ */
162
+ static get emptySpaceCache(): SpaceCache;
57
163
  }
58
- export declare function extractPayloadFromToken(token: string): {
59
- spaceId: string;
60
- userId: string;
61
- cellId: string;
62
- };
164
+ export {};
63
165
  //# sourceMappingURL=config.d.ts.map