@barekey/cli 0.5.9 → 0.6.0

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.
@@ -14,6 +14,7 @@ async function runInit(options) {
14
14
  config: {
15
15
  mode: "centralized",
16
16
  typegen: "semantic",
17
+ strictGeneratedKeys: false,
17
18
  },
18
19
  }, null, 2)}\n`;
19
20
  await writeFile(configPath, contents, "utf8");
@@ -55,6 +55,7 @@ async function resolveTypegenContext(options) {
55
55
  environment: target.stageSlug.trim().length > 0 ? target.stageSlug : "local",
56
56
  runtimeMode: runtime?.config.config?.mode ?? "centralized",
57
57
  typegenMode: runtime?.config.config?.typegen ?? "semantic",
58
+ strictGeneratedKeys: runtime?.config.config?.strictGeneratedKeys ?? false,
58
59
  localEnvRoot: runtime?.path ?? null,
59
60
  };
60
61
  }
@@ -87,6 +88,7 @@ async function runTypegen(options) {
87
88
  projectSlug: context.project,
88
89
  stageSlug: context.environment,
89
90
  typegenMode: context.typegenMode,
91
+ strictGeneratedKeys: context.strictGeneratedKeys,
90
92
  runtimeMode: context.runtimeMode,
91
93
  localEnvRoot: context.localEnvRoot,
92
94
  });
@@ -117,6 +119,7 @@ async function runTypegenWatch(options) {
117
119
  projectSlug: nextContext.project,
118
120
  stageSlug: nextContext.environment,
119
121
  typegenMode: nextContext.typegenMode,
122
+ strictGeneratedKeys: nextContext.strictGeneratedKeys,
120
123
  runtimeMode: nextContext.runtimeMode,
121
124
  localEnvRoot: nextContext.localEnvRoot,
122
125
  });
@@ -13,6 +13,7 @@ export declare const RuntimeConfigSchema: Schema.Struct<{
13
13
  typegen: Schema.optional<Schema.NullOr<Schema.Literal<["semantic", "minimal"]>>>;
14
14
  config: Schema.optional<Schema.Struct<{
15
15
  typegen: Schema.optional<Schema.Literal<["semantic", "minimal"]>>;
16
+ strictGeneratedKeys: Schema.optional<typeof Schema.Boolean>;
16
17
  mode: Schema.optional<Schema.Literal<["centralized", "standalone"]>>;
17
18
  }>>;
18
19
  }>;
@@ -15,6 +15,7 @@ export const RuntimeConfigSchema = Schema.Struct({
15
15
  typegen: Schema.optional(Schema.NullOr(TypegenModeSchema)),
16
16
  config: Schema.optional(Schema.Struct({
17
17
  typegen: Schema.optional(TypegenModeSchema),
18
+ strictGeneratedKeys: Schema.optional(Schema.Boolean),
18
19
  mode: Schema.optional(RuntimeModeSchema),
19
20
  })),
20
21
  });
@@ -4,6 +4,7 @@ export type BarekeyRuntimeConfig = {
4
4
  environment?: string;
5
5
  config?: {
6
6
  typegen?: "semantic" | "minimal";
7
+ strictGeneratedKeys?: boolean;
7
8
  mode?: "centralized" | "standalone";
8
9
  };
9
10
  };
@@ -39,6 +39,7 @@ export async function loadRuntimeConfig() {
39
39
  const config = decoded.right.config;
40
40
  const mode = config?.mode ?? "centralized";
41
41
  const typegen = mode === "standalone" ? "minimal" : (config?.typegen ?? decoded.right.typegen ?? "semantic");
42
+ const strictGeneratedKeys = config?.strictGeneratedKeys ?? false;
42
43
  return {
43
44
  path: configPath,
44
45
  config: {
@@ -48,6 +49,7 @@ export async function loadRuntimeConfig() {
48
49
  config: {
49
50
  mode,
50
51
  typegen,
52
+ strictGeneratedKeys,
51
53
  },
52
54
  },
53
55
  };
@@ -1,6 +1,7 @@
1
1
  import { type TypegenManifest } from "../contracts/index.js";
2
2
  export type CliTypegenMode = "semantic" | "minimal";
3
3
  export type CliRuntimeMode = "centralized" | "standalone";
4
+ export type CliStrictGeneratedKeys = boolean;
4
5
  export type CliTypegenResult = {
5
6
  written: boolean;
6
7
  path: string;
@@ -14,6 +15,7 @@ type TypegenIdentity = {
14
15
  projectSlug: string;
15
16
  stageSlug: string;
16
17
  typegenMode: CliTypegenMode;
18
+ strictGeneratedKeys: CliStrictGeneratedKeys;
17
19
  runtimeMode: CliRuntimeMode;
18
20
  localEnvRoot: string | null;
19
21
  };
@@ -27,7 +29,7 @@ type TypegenIdentity = {
27
29
  * @lastModified 2026-03-19
28
30
  * @author GPT-5.4
29
31
  */
30
- export declare function renderGeneratedTypesForManifest(manifest: TypegenManifest, mode: CliTypegenMode): {
32
+ export declare function renderGeneratedTypesForManifest(manifest: TypegenManifest, mode: CliTypegenMode, strictGeneratedKeys?: boolean): {
31
33
  serverContents: string;
32
34
  publicContents: string;
33
35
  };
@@ -12,6 +12,7 @@ const TypegenMetadataSchema = Schema.Struct({
12
12
  projectSlug: Schema.NullOr(Schema.String),
13
13
  stageSlug: Schema.NullOr(Schema.String),
14
14
  typegenMode: Schema.NullOr(Schema.Literal("semantic", "minimal")),
15
+ strictGeneratedKeys: Schema.Boolean,
15
16
  runtimeMode: Schema.NullOr(Schema.Literal("centralized", "standalone")),
16
17
  localEnvRoot: Schema.NullOr(Schema.String),
17
18
  });
@@ -50,7 +51,7 @@ function buildGeneratedTypesContents(manifest, input) {
50
51
  const importLine = input.mode === "semantic"
51
52
  ? `import type { EaseInOut, Env, Linear, Step } from "${input.typeModulePath}";\n\n`
52
53
  : "";
53
- return `/* eslint-disable */\n/* This file is generated by barekey typegen. */\n/* barekey-manifest-version: ${manifest.manifestVersion} */\n\n${importLine}declare module "${input.declaredModulePath}" {\n interface ${input.interfaceName} {\n${mapLines.length > 0 ? mapLines : ""}\n }\n}\n\nexport {};\n`;
54
+ return `/* eslint-disable */\n/* This file is generated by barekey typegen. */\n/* barekey-manifest-version: ${manifest.manifestVersion} */\n\n${importLine}declare module "${input.declaredModulePath}" {\n interface ${input.interfaceName} {\n${mapLines.length > 0 ? mapLines : ""}\n }\n\n interface ${input.configInterfaceName} {\n allowUnknownKeys: ${input.strictGeneratedKeys ? "false" : "true"};\n }\n}\n\nexport {};\n`;
54
55
  }
55
56
  function readManifestVersion(contents) {
56
57
  return contents?.match(MANIFEST_VERSION_PATTERN)?.[1]?.trim() ?? null;
@@ -132,6 +133,7 @@ function buildTypegenMetadataContents(lastGeneratedAt, identity) {
132
133
  projectSlug: identity.projectSlug,
133
134
  stageSlug: identity.stageSlug,
134
135
  typegenMode: identity.typegenMode,
136
+ strictGeneratedKeys: identity.strictGeneratedKeys,
135
137
  runtimeMode: identity.runtimeMode,
136
138
  localEnvRoot: identity.localEnvRoot,
137
139
  }, null, 2)}\n`;
@@ -146,21 +148,25 @@ function buildTypegenMetadataContents(lastGeneratedAt, identity) {
146
148
  * @lastModified 2026-03-19
147
149
  * @author GPT-5.4
148
150
  */
149
- export function renderGeneratedTypesForManifest(manifest, mode) {
151
+ export function renderGeneratedTypesForManifest(manifest, mode, strictGeneratedKeys = false) {
150
152
  const decodedManifest = Schema.decodeUnknownSync(TypegenManifestSchema)(manifest);
151
153
  return {
152
154
  serverContents: buildGeneratedTypesContents(decodedManifest, {
153
155
  mode,
156
+ strictGeneratedKeys,
154
157
  typeModulePath: "./dist/types.js",
155
158
  declaredModulePath: "./dist/types.js",
156
159
  interfaceName: "BarekeyGeneratedTypeMap",
160
+ configInterfaceName: "BarekeyGeneratedTypeConfig",
157
161
  include: () => true,
158
162
  }),
159
163
  publicContents: buildGeneratedTypesContents(decodedManifest, {
160
164
  mode,
165
+ strictGeneratedKeys,
161
166
  typeModulePath: "./dist/public-types.js",
162
167
  declaredModulePath: "./dist/public-types.js",
163
168
  interfaceName: "BarekeyPublicGeneratedTypeMap",
169
+ configInterfaceName: "BarekeyPublicGeneratedTypeConfig",
164
170
  include: (row) => row.visibility === "public",
165
171
  }),
166
172
  };
@@ -190,7 +196,7 @@ export async function writeInstalledSdkGeneratedTypes(manifest, identity) {
190
196
  readTextFile(target.serverGeneratedTypesPath),
191
197
  readTextFile(target.publicGeneratedTypesPath),
192
198
  ]);
193
- const rendered = renderGeneratedTypesForManifest(manifest, identity.typegenMode);
199
+ const rendered = renderGeneratedTypesForManifest(manifest, identity.typegenMode, identity.strictGeneratedKeys);
194
200
  if (existingServerContents === rendered.serverContents &&
195
201
  existingPublicContents === rendered.publicContents &&
196
202
  readManifestVersion(existingServerContents) === manifest.manifestVersion &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barekey/cli",
3
- "version": "0.5.9",
3
+ "version": "0.6.0",
4
4
  "description": "Barekey command line interface",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,10 +21,11 @@ async function runInit(options: EnvTargetOptions & { path?: string }) {
21
21
  organization: orgSlug,
22
22
  project: projectSlug,
23
23
  environment: stageSlug,
24
- config: {
25
- mode: "centralized",
26
- typegen: "semantic",
27
- },
24
+ config: {
25
+ mode: "centralized",
26
+ typegen: "semantic",
27
+ strictGeneratedKeys: false,
28
+ },
28
29
  },
29
30
  null,
30
31
  2,
@@ -74,6 +74,7 @@ async function resolveTypegenContext(options: EnvTargetOptions): Promise<{
74
74
  environment: string;
75
75
  runtimeMode: "centralized" | "standalone";
76
76
  typegenMode: "semantic" | "minimal";
77
+ strictGeneratedKeys: boolean;
77
78
  localEnvRoot: string | null;
78
79
  }> {
79
80
  const runtime = await loadRuntimeConfig();
@@ -89,6 +90,7 @@ async function resolveTypegenContext(options: EnvTargetOptions): Promise<{
89
90
  environment: target.stageSlug.trim().length > 0 ? target.stageSlug : "local",
90
91
  runtimeMode: runtime?.config.config?.mode ?? "centralized",
91
92
  typegenMode: runtime?.config.config?.typegen ?? "semantic",
93
+ strictGeneratedKeys: runtime?.config.config?.strictGeneratedKeys ?? false,
92
94
  localEnvRoot: runtime?.path ?? null,
93
95
  };
94
96
  }
@@ -126,6 +128,7 @@ async function runTypegen(options: EnvTargetOptions): Promise<void> {
126
128
  projectSlug: context.project,
127
129
  stageSlug: context.environment,
128
130
  typegenMode: context.typegenMode,
131
+ strictGeneratedKeys: context.strictGeneratedKeys,
129
132
  runtimeMode: context.runtimeMode,
130
133
  localEnvRoot: context.localEnvRoot,
131
134
  });
@@ -167,6 +170,7 @@ async function runTypegenWatch(
167
170
  projectSlug: nextContext.project,
168
171
  stageSlug: nextContext.environment,
169
172
  typegenMode: nextContext.typegenMode,
173
+ strictGeneratedKeys: nextContext.strictGeneratedKeys,
170
174
  runtimeMode: nextContext.runtimeMode,
171
175
  localEnvRoot: nextContext.localEnvRoot,
172
176
  });
@@ -26,6 +26,7 @@ export const RuntimeConfigSchema = Schema.Struct({
26
26
  config: Schema.optional(
27
27
  Schema.Struct({
28
28
  typegen: Schema.optional(TypegenModeSchema),
29
+ strictGeneratedKeys: Schema.optional(Schema.Boolean),
29
30
  mode: Schema.optional(RuntimeModeSchema),
30
31
  }),
31
32
  ),
@@ -10,6 +10,7 @@ export type BarekeyRuntimeConfig = {
10
10
  environment?: string;
11
11
  config?: {
12
12
  typegen?: "semantic" | "minimal";
13
+ strictGeneratedKeys?: boolean;
13
14
  mode?: "centralized" | "standalone";
14
15
  };
15
16
  };
@@ -61,6 +62,7 @@ export async function loadRuntimeConfig(): Promise<BarekeyRuntimeConfigResult |
61
62
  const mode = config?.mode ?? "centralized";
62
63
  const typegen =
63
64
  mode === "standalone" ? "minimal" : (config?.typegen ?? decoded.right.typegen ?? "semantic");
65
+ const strictGeneratedKeys = config?.strictGeneratedKeys ?? false;
64
66
 
65
67
  return {
66
68
  path: configPath,
@@ -71,6 +73,7 @@ export async function loadRuntimeConfig(): Promise<BarekeyRuntimeConfigResult |
71
73
  config: {
72
74
  mode,
73
75
  typegen,
76
+ strictGeneratedKeys,
74
77
  },
75
78
  },
76
79
  };
@@ -8,6 +8,7 @@ import { TypegenManifestSchema, type TypegenManifest } from "../contracts/index.
8
8
 
9
9
  export type CliTypegenMode = "semantic" | "minimal";
10
10
  export type CliRuntimeMode = "centralized" | "standalone";
11
+ export type CliStrictGeneratedKeys = boolean;
11
12
 
12
13
  export type CliTypegenResult = {
13
14
  written: boolean;
@@ -23,6 +24,7 @@ type TypegenIdentity = {
23
24
  projectSlug: string;
24
25
  stageSlug: string;
25
26
  typegenMode: CliTypegenMode;
27
+ strictGeneratedKeys: CliStrictGeneratedKeys;
26
28
  runtimeMode: CliRuntimeMode;
27
29
  localEnvRoot: string | null;
28
30
  };
@@ -37,6 +39,7 @@ const TypegenMetadataSchema = Schema.Struct({
37
39
  projectSlug: Schema.NullOr(Schema.String),
38
40
  stageSlug: Schema.NullOr(Schema.String),
39
41
  typegenMode: Schema.NullOr(Schema.Literal("semantic", "minimal")),
42
+ strictGeneratedKeys: Schema.Boolean,
40
43
  runtimeMode: Schema.NullOr(Schema.Literal("centralized", "standalone")),
41
44
  localEnvRoot: Schema.NullOr(Schema.String),
42
45
  });
@@ -93,9 +96,11 @@ function buildGeneratedTypesContents(
93
96
  manifest: TypegenManifest,
94
97
  input: {
95
98
  mode: CliTypegenMode;
99
+ strictGeneratedKeys: CliStrictGeneratedKeys;
96
100
  typeModulePath: "./dist/types.js" | "./dist/public-types.js";
97
101
  declaredModulePath: "./dist/types.js" | "./dist/public-types.js";
98
102
  interfaceName: "BarekeyGeneratedTypeMap" | "BarekeyPublicGeneratedTypeMap";
103
+ configInterfaceName: "BarekeyGeneratedTypeConfig" | "BarekeyPublicGeneratedTypeConfig";
99
104
  include: (row: TypegenManifest["variables"][number]) => boolean;
100
105
  },
101
106
  ): string {
@@ -111,7 +116,7 @@ function buildGeneratedTypesContents(
111
116
  ? `import type { EaseInOut, Env, Linear, Step } from "${input.typeModulePath}";\n\n`
112
117
  : "";
113
118
 
114
- return `/* eslint-disable */\n/* This file is generated by barekey typegen. */\n/* barekey-manifest-version: ${manifest.manifestVersion} */\n\n${importLine}declare module "${input.declaredModulePath}" {\n interface ${input.interfaceName} {\n${mapLines.length > 0 ? mapLines : ""}\n }\n}\n\nexport {};\n`;
119
+ return `/* eslint-disable */\n/* This file is generated by barekey typegen. */\n/* barekey-manifest-version: ${manifest.manifestVersion} */\n\n${importLine}declare module "${input.declaredModulePath}" {\n interface ${input.interfaceName} {\n${mapLines.length > 0 ? mapLines : ""}\n }\n\n interface ${input.configInterfaceName} {\n allowUnknownKeys: ${input.strictGeneratedKeys ? "false" : "true"};\n }\n}\n\nexport {};\n`;
115
120
  }
116
121
 
117
122
  function readManifestVersion(contents: string | null): string | null {
@@ -197,6 +202,7 @@ function buildTypegenMetadataContents(lastGeneratedAt: Date, identity: TypegenId
197
202
  projectSlug: identity.projectSlug,
198
203
  stageSlug: identity.stageSlug,
199
204
  typegenMode: identity.typegenMode,
205
+ strictGeneratedKeys: identity.strictGeneratedKeys,
200
206
  runtimeMode: identity.runtimeMode,
201
207
  localEnvRoot: identity.localEnvRoot,
202
208
  },
@@ -218,6 +224,7 @@ function buildTypegenMetadataContents(lastGeneratedAt: Date, identity: TypegenId
218
224
  export function renderGeneratedTypesForManifest(
219
225
  manifest: TypegenManifest,
220
226
  mode: CliTypegenMode,
227
+ strictGeneratedKeys = false,
221
228
  ): {
222
229
  serverContents: string;
223
230
  publicContents: string;
@@ -227,16 +234,20 @@ export function renderGeneratedTypesForManifest(
227
234
  return {
228
235
  serverContents: buildGeneratedTypesContents(decodedManifest, {
229
236
  mode,
237
+ strictGeneratedKeys,
230
238
  typeModulePath: "./dist/types.js",
231
239
  declaredModulePath: "./dist/types.js",
232
240
  interfaceName: "BarekeyGeneratedTypeMap",
241
+ configInterfaceName: "BarekeyGeneratedTypeConfig",
233
242
  include: () => true,
234
243
  }),
235
244
  publicContents: buildGeneratedTypesContents(decodedManifest, {
236
245
  mode,
246
+ strictGeneratedKeys,
237
247
  typeModulePath: "./dist/public-types.js",
238
248
  declaredModulePath: "./dist/public-types.js",
239
249
  interfaceName: "BarekeyPublicGeneratedTypeMap",
250
+ configInterfaceName: "BarekeyPublicGeneratedTypeConfig",
240
251
  include: (row) => row.visibility === "public",
241
252
  }),
242
253
  };
@@ -271,7 +282,11 @@ export async function writeInstalledSdkGeneratedTypes(
271
282
  readTextFile(target.serverGeneratedTypesPath),
272
283
  readTextFile(target.publicGeneratedTypesPath),
273
284
  ]);
274
- const rendered = renderGeneratedTypesForManifest(manifest, identity.typegenMode);
285
+ const rendered = renderGeneratedTypesForManifest(
286
+ manifest,
287
+ identity.typegenMode,
288
+ identity.strictGeneratedKeys,
289
+ );
275
290
 
276
291
  if (
277
292
  existingServerContents === rendered.serverContents &&
@@ -86,6 +86,37 @@ describe("loadRuntimeConfig", () => {
86
86
  config: {
87
87
  mode: "centralized",
88
88
  typegen: "semantic",
89
+ strictGeneratedKeys: false,
90
+ },
91
+ },
92
+ });
93
+ });
94
+ });
95
+
96
+ test("reads config.strictGeneratedKeys when present", async () => {
97
+ const tempDir = await createTempDir();
98
+ await writeFile(
99
+ path.join(tempDir, "barekey.json"),
100
+ JSON.stringify(
101
+ {
102
+ organization: "acme",
103
+ project: "api",
104
+ environment: "development",
105
+ config: {
106
+ strictGeneratedKeys: true,
107
+ },
108
+ },
109
+ null,
110
+ 2,
111
+ ),
112
+ "utf8",
113
+ );
114
+
115
+ await withWorkingDirectory(tempDir, async () => {
116
+ await expect(loadRuntimeConfig()).resolves.toMatchObject({
117
+ config: {
118
+ config: {
119
+ strictGeneratedKeys: true,
89
120
  },
90
121
  },
91
122
  });