@barekey/sdk 0.4.4 → 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.
Files changed (56) hide show
  1. package/README.md +84 -7
  2. package/dist/client.d.ts +4 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +61 -15
  5. package/dist/handle.d.ts +1 -1
  6. package/dist/handle.d.ts.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/internal/config.d.ts +5 -0
  10. package/dist/internal/config.d.ts.map +1 -0
  11. package/dist/internal/config.js +26 -0
  12. package/dist/internal/node-runtime.d.ts +11 -0
  13. package/dist/internal/node-runtime.d.ts.map +1 -1
  14. package/dist/internal/node-runtime.js +2 -1
  15. package/dist/internal/public-runtime.d.ts.map +1 -1
  16. package/dist/internal/public-runtime.js +17 -3
  17. package/dist/internal/runtime.d.ts +15 -1
  18. package/dist/internal/runtime.d.ts.map +1 -1
  19. package/dist/internal/runtime.js +49 -7
  20. package/dist/internal/singleton.d.ts.map +1 -1
  21. package/dist/internal/singleton.js +14 -0
  22. package/dist/internal/standalone.d.ts +10 -0
  23. package/dist/internal/standalone.d.ts.map +1 -0
  24. package/dist/internal/standalone.js +246 -0
  25. package/dist/internal/typegen.d.ts +6 -3
  26. package/dist/internal/typegen.d.ts.map +1 -1
  27. package/dist/internal/typegen.js +45 -13
  28. package/dist/key-types.typecheck.d.ts +5 -5
  29. package/dist/key-types.typecheck.d.ts.map +1 -1
  30. package/dist/public-client.d.ts +4 -0
  31. package/dist/public-client.d.ts.map +1 -1
  32. package/dist/public-types.d.ts +1 -1
  33. package/dist/public-types.d.ts.map +1 -1
  34. package/dist/public.d.ts +1 -1
  35. package/dist/public.d.ts.map +1 -1
  36. package/dist/server.d.ts +1 -1
  37. package/dist/server.d.ts.map +1 -1
  38. package/dist/types.d.ts +34 -5
  39. package/dist/types.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/client.ts +86 -15
  42. package/src/handle.ts +1 -1
  43. package/src/index.ts +2 -0
  44. package/src/internal/config.ts +34 -0
  45. package/src/internal/node-runtime.ts +4 -2
  46. package/src/internal/public-runtime.ts +25 -4
  47. package/src/internal/runtime.ts +91 -7
  48. package/src/internal/singleton.ts +37 -4
  49. package/src/internal/standalone.ts +309 -0
  50. package/src/internal/typegen.ts +68 -15
  51. package/src/key-types.typecheck.ts +20 -4
  52. package/src/public-client.ts +4 -0
  53. package/src/public-types.ts +1 -0
  54. package/src/public.ts +2 -0
  55. package/src/server.ts +2 -0
  56. package/src/types.ts +81 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/internal/standalone.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,cAAc,CAAC;AAyP7E,wBAAsB,yBAAyB,CAC7C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAS3C;AAED,wBAAsB,8BAA8B,CAAC,KAAK,EAAE;IAC1D,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,eAAe,CAAC,CA4B3B"}
@@ -0,0 +1,246 @@
1
+ import { FsNotAvailableError, InvalidConfigurationProvidedError, parseBigIntOrThrow, parseBooleanOrThrow, parseDateOrThrow, parseFloatOrThrow, } from "../errors.js";
2
+ import { loadNodeRuntime } from "./node-runtime.js";
3
+ function isStandaloneEnvFile(fileName) {
4
+ if (fileName === ".env") {
5
+ return true;
6
+ }
7
+ if (!fileName.startsWith(".env.")) {
8
+ return false;
9
+ }
10
+ const suffix = fileName.slice(".env.".length);
11
+ if (suffix.length === 0) {
12
+ return false;
13
+ }
14
+ return suffix.split(".")[0] !== "example";
15
+ }
16
+ function normalizeStandaloneKey(fileName, key) {
17
+ const normalizedKey = key.trim().toUpperCase();
18
+ if (fileName === ".env") {
19
+ return normalizedKey;
20
+ }
21
+ const suffix = fileName.slice(".env.".length);
22
+ const prefix = suffix
23
+ .split(".")
24
+ .filter((token) => token.length > 0)
25
+ .map((token) => token.toUpperCase())
26
+ .join("_");
27
+ return prefix.length === 0 ? normalizedKey : `${prefix}_${normalizedKey}`;
28
+ }
29
+ function parseQuotedValue(value, quote) {
30
+ let result = "";
31
+ let escaped = false;
32
+ for (let index = 1; index < value.length; index += 1) {
33
+ const character = value[index];
34
+ if (character === undefined) {
35
+ break;
36
+ }
37
+ if (quote === '"' && escaped) {
38
+ if (character === "n") {
39
+ result += "\n";
40
+ }
41
+ else if (character === "r") {
42
+ result += "\r";
43
+ }
44
+ else if (character === "t") {
45
+ result += "\t";
46
+ }
47
+ else {
48
+ result += character;
49
+ }
50
+ escaped = false;
51
+ continue;
52
+ }
53
+ if (quote === '"' && character === "\\") {
54
+ escaped = true;
55
+ continue;
56
+ }
57
+ if (character === quote) {
58
+ return result;
59
+ }
60
+ result += character;
61
+ }
62
+ return result;
63
+ }
64
+ function parseEnvValue(rawValue) {
65
+ const trimmed = rawValue.trim();
66
+ if (trimmed.length === 0) {
67
+ return "";
68
+ }
69
+ const firstCharacter = trimmed[0];
70
+ if (firstCharacter === '"' || firstCharacter === "'") {
71
+ return parseQuotedValue(trimmed, firstCharacter);
72
+ }
73
+ const commentStart = trimmed.search(/\s#/);
74
+ return (commentStart >= 0 ? trimmed.slice(0, commentStart) : trimmed).trim();
75
+ }
76
+ function parseStandaloneEnvContents(fileName, contents) {
77
+ const variables = [];
78
+ for (const rawLine of contents.split(/\r?\n/)) {
79
+ const trimmedLine = rawLine.trimStart();
80
+ if (trimmedLine.length === 0 || trimmedLine.startsWith("#")) {
81
+ continue;
82
+ }
83
+ const line = trimmedLine.startsWith("export ")
84
+ ? trimmedLine.slice("export ".length).trimStart()
85
+ : trimmedLine;
86
+ const delimiterIndex = line.indexOf("=");
87
+ if (delimiterIndex <= 0) {
88
+ continue;
89
+ }
90
+ const rawKey = line.slice(0, delimiterIndex).trim();
91
+ if (rawKey.length === 0) {
92
+ continue;
93
+ }
94
+ variables.push({
95
+ name: normalizeStandaloneKey(fileName, rawKey),
96
+ value: parseEnvValue(line.slice(delimiterIndex + 1)),
97
+ });
98
+ }
99
+ return variables;
100
+ }
101
+ async function hashString(value) {
102
+ if (globalThis.crypto?.subtle !== undefined) {
103
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
104
+ return [...new Uint8Array(digest)]
105
+ .map((part) => part.toString(16).padStart(2, "0"))
106
+ .join("");
107
+ }
108
+ let hash = 0;
109
+ for (let index = 0; index < value.length; index += 1) {
110
+ hash = (hash * 31 + value.charCodeAt(index)) >>> 0;
111
+ }
112
+ return hash.toString(16).padStart(8, "0");
113
+ }
114
+ function inferStandaloneDeclaredType(value) {
115
+ try {
116
+ parseBooleanOrThrow(value);
117
+ return "boolean";
118
+ }
119
+ catch { }
120
+ try {
121
+ parseBigIntOrThrow(value);
122
+ return "int64";
123
+ }
124
+ catch { }
125
+ try {
126
+ parseFloatOrThrow(value);
127
+ return "float";
128
+ }
129
+ catch { }
130
+ try {
131
+ parseDateOrThrow(value);
132
+ return "date";
133
+ }
134
+ catch { }
135
+ return "string";
136
+ }
137
+ function typeScriptTypeForDeclaredType(value) {
138
+ if (value === "boolean") {
139
+ return "boolean";
140
+ }
141
+ if (value === "int64") {
142
+ return "bigint";
143
+ }
144
+ if (value === "float") {
145
+ return "number";
146
+ }
147
+ if (value === "date") {
148
+ return "Date";
149
+ }
150
+ return "string";
151
+ }
152
+ async function loadStandaloneSnapshot(rootDirectory) {
153
+ const runtime = await loadNodeRuntime();
154
+ if (runtime === null) {
155
+ throw new FsNotAvailableError({
156
+ message: "Barekey standalone mode requires a local filesystem to read .env files.",
157
+ });
158
+ }
159
+ let fileNames;
160
+ try {
161
+ const entries = await runtime.fs.readdir(rootDirectory, {
162
+ withFileTypes: true,
163
+ });
164
+ fileNames = entries
165
+ .filter((entry) => entry.isFile() && isStandaloneEnvFile(entry.name))
166
+ .map((entry) => entry.name)
167
+ .sort((left, right) => {
168
+ if (left === ".env") {
169
+ return right === ".env" ? 0 : -1;
170
+ }
171
+ if (right === ".env") {
172
+ return 1;
173
+ }
174
+ return left.localeCompare(right);
175
+ });
176
+ }
177
+ catch (error) {
178
+ throw new InvalidConfigurationProvidedError({
179
+ message: `Barekey standalone mode could not read env files from ${rootDirectory}.`,
180
+ cause: error,
181
+ });
182
+ }
183
+ const mergedVariables = new Map();
184
+ const fingerprintParts = [];
185
+ for (const fileName of fileNames) {
186
+ const filePath = runtime.path.join(rootDirectory, fileName);
187
+ let contents;
188
+ try {
189
+ contents = await runtime.fs.readFile(filePath, "utf8");
190
+ }
191
+ catch (error) {
192
+ throw new InvalidConfigurationProvidedError({
193
+ message: `Barekey standalone mode could not read ${filePath}.`,
194
+ cause: error,
195
+ });
196
+ }
197
+ fingerprintParts.push(`${fileName}\n${contents}`);
198
+ for (const variable of parseStandaloneEnvContents(fileName, contents)) {
199
+ mergedVariables.set(variable.name, variable.value);
200
+ }
201
+ }
202
+ return {
203
+ variables: [...mergedVariables.entries()]
204
+ .sort(([left], [right]) => left.localeCompare(right))
205
+ .map(([name, value]) => ({ name, value })),
206
+ manifestVersion: `standalone-${await hashString(fingerprintParts.join("\n---\n"))}`,
207
+ };
208
+ }
209
+ export async function loadStandaloneDefinitions(rootDirectory) {
210
+ const snapshot = await loadStandaloneSnapshot(rootDirectory);
211
+ return snapshot.variables.map((variable) => ({
212
+ name: variable.name,
213
+ kind: "secret",
214
+ declaredType: inferStandaloneDeclaredType(variable.value),
215
+ visibility: "private",
216
+ value: variable.value,
217
+ }));
218
+ }
219
+ export async function buildStandaloneTypegenManifest(input) {
220
+ const snapshot = await loadStandaloneSnapshot(input.rootDirectory);
221
+ const variables = snapshot.variables.map((variable) => {
222
+ const declaredType = inferStandaloneDeclaredType(variable.value);
223
+ return {
224
+ name: variable.name,
225
+ visibility: "private",
226
+ kind: "secret",
227
+ declaredType,
228
+ required: true,
229
+ updatedAtMs: Date.now(),
230
+ typeScriptType: typeScriptTypeForDeclaredType(declaredType),
231
+ valueATypeScriptType: null,
232
+ valueBTypeScriptType: null,
233
+ rolloutFunction: null,
234
+ rolloutMilestones: null,
235
+ };
236
+ });
237
+ return {
238
+ orgId: `standalone:${input.organization}`,
239
+ orgSlug: input.organization,
240
+ projectSlug: input.project,
241
+ stageSlug: input.environment,
242
+ generatedAtMs: Date.now(),
243
+ manifestVersion: snapshot.manifestVersion,
244
+ variables,
245
+ };
246
+ }
@@ -1,4 +1,4 @@
1
- import type { BarekeyRolloutFunction, BarekeyRolloutMilestone, BarekeyTypegenResult } from "../types.js";
1
+ import type { BarekeyMode, BarekeyRolloutFunction, BarekeyRolloutMilestone, BarekeyTypegenMode, BarekeyTypegenResult } from "../types.js";
2
2
  export type TypegenManifestVariable = {
3
3
  name: string;
4
4
  visibility: "private" | "public";
@@ -22,13 +22,16 @@ export type TypegenManifest = {
22
22
  variables: Array<TypegenManifestVariable>;
23
23
  };
24
24
  type TypegenMetadataIdentity = {
25
- baseUrl: string;
25
+ baseUrl: string | null;
26
26
  orgSlug: string;
27
27
  projectSlug: string;
28
28
  stageSlug: string;
29
+ typegenMode: BarekeyTypegenMode;
30
+ runtimeMode: BarekeyMode;
31
+ localEnvRoot: string | null;
29
32
  };
30
33
  export declare function resolveInstalledSdkGeneratedTypesPath(): Promise<string | null>;
31
- export declare function renderGeneratedTypesForManifest(manifest: TypegenManifest): {
34
+ export declare function renderGeneratedTypesForManifest(manifest: TypegenManifest, mode?: BarekeyTypegenMode): {
32
35
  serverContents: string;
33
36
  publicContents: string;
34
37
  };
@@ -1 +1 @@
1
- {"version":3,"file":"typegen.d.ts","sourceRoot":"","sources":["../../src/internal/typegen.ts"],"names":[],"mappings":"AAKA,OA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,KAAK,CAAC,uBAAuB,CAAC,CAAC;CAC3C,CAAC;AAiBF,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAkMF,wBAAsB,qCAAqC,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGpF;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,eAAe,EACzB,IAAI,GAAE,kBAA+B,GACpC;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAiBA;AAED,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,uBAAuB,GAChC,OAAO,CAAC,OAAO,CAAC,CAwBlB;AAED,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,uBAAuB,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAyD/B"}
@@ -19,16 +19,19 @@ function renderRolloutMetadataType(row) {
19
19
  }
20
20
  return `Linear<${renderedMilestones}>`;
21
21
  }
22
- function renderVariableType(row) {
23
- const renderEnvDescriptor = (input) => `{ Mode: ${input.mode}; Visibility: ${JSON.stringify(row.visibility)}; Rollout: ${input.rollout}; Type: ${row.typeScriptType} }`;
22
+ function renderVariableType(row, mode) {
23
+ if (mode === "minimal") {
24
+ return row.typeScriptType;
25
+ }
26
+ const renderEnvDescriptor = (input) => `{ Type: ${row.typeScriptType}; Kind: ${JSON.stringify(input.kind)}; Visibility: ${JSON.stringify(row.visibility)}; Rollout: ${input.rollout} }`;
24
27
  if (row.kind === "secret") {
25
- return `Env<${renderEnvDescriptor({ mode: "Secret", rollout: "never" })}>`;
28
+ return `Env<${renderEnvDescriptor({ kind: "secret", rollout: "never" })}>`;
26
29
  }
27
30
  if (row.kind === "ab_roll") {
28
- return `Env<${renderEnvDescriptor({ mode: "AB", rollout: "never" })}>`;
31
+ return `Env<${renderEnvDescriptor({ kind: "ab_roll", rollout: "never" })}>`;
29
32
  }
30
33
  return `Env<${renderEnvDescriptor({
31
- mode: "AB",
34
+ kind: "rollout",
32
35
  rollout: renderRolloutMetadataType(row),
33
36
  })}>`;
34
37
  }
@@ -37,15 +40,16 @@ function buildGeneratedTypesContents(manifest, input) {
37
40
  .slice()
38
41
  .filter(input.include)
39
42
  .sort((left, right) => left.name.localeCompare(right.name))
40
- .map((row) => ` ${JSON.stringify(row.name)}: ${renderVariableType(row)};`)
43
+ .map((row) => ` ${JSON.stringify(row.name)}: ${renderVariableType(row, input.mode)};`)
41
44
  .join("\n");
45
+ const importLine = input.mode === "semantic"
46
+ ? `import type { EaseInOut, Env, Linear, Step } from "${input.typeModulePath}";\n\n`
47
+ : "";
42
48
  return `/* eslint-disable */
43
49
  /* This file is generated by barekey typegen. */
44
50
  /* barekey-manifest-version: ${manifest.manifestVersion} */
45
51
 
46
- import type { AB, EaseInOut, Env, Linear, Secret, Step } from "${input.typeModulePath}";
47
-
48
- declare module "${input.declaredModulePath}" {
52
+ ${importLine}declare module "${input.declaredModulePath}" {
49
53
  interface ${input.interfaceName} {
50
54
  ${mapLines.length > 0 ? mapLines : ""}
51
55
  }
@@ -85,6 +89,21 @@ function parseTypegenMetadata(contents) {
85
89
  (candidate.stageSlug !== undefined &&
86
90
  candidate.stageSlug !== null &&
87
91
  typeof candidate.stageSlug !== "string") ||
92
+ (candidate.typegenMode !== undefined &&
93
+ candidate.typegenMode !== null &&
94
+ candidate.typegenMode !== "semantic" &&
95
+ candidate.typegenMode !== "minimal") ||
96
+ (candidate.mode !== undefined &&
97
+ candidate.mode !== null &&
98
+ candidate.mode !== "semantic" &&
99
+ candidate.mode !== "minimal") ||
100
+ (candidate.runtimeMode !== undefined &&
101
+ candidate.runtimeMode !== null &&
102
+ candidate.runtimeMode !== "centralized" &&
103
+ candidate.runtimeMode !== "standalone") ||
104
+ (candidate.localEnvRoot !== undefined &&
105
+ candidate.localEnvRoot !== null &&
106
+ typeof candidate.localEnvRoot !== "string") ||
88
107
  !Number.isFinite(Date.parse(candidate.last))) {
89
108
  return null;
90
109
  }
@@ -95,6 +114,9 @@ function parseTypegenMetadata(contents) {
95
114
  orgSlug: candidate.orgSlug ?? null,
96
115
  projectSlug: candidate.projectSlug ?? null,
97
116
  stageSlug: candidate.stageSlug ?? null,
117
+ typegenMode: candidate.typegenMode ?? candidate.mode ?? null,
118
+ runtimeMode: candidate.runtimeMode ?? "centralized",
119
+ localEnvRoot: candidate.localEnvRoot ?? null,
98
120
  };
99
121
  }
100
122
  catch {
@@ -109,21 +131,26 @@ function buildTypegenMetadataContents(lastGeneratedAt, identity) {
109
131
  orgSlug: identity.orgSlug,
110
132
  projectSlug: identity.projectSlug,
111
133
  stageSlug: identity.stageSlug,
134
+ typegenMode: identity.typegenMode,
135
+ runtimeMode: identity.runtimeMode,
136
+ localEnvRoot: identity.localEnvRoot,
112
137
  }, null, 2)}\n`;
113
138
  }
114
139
  export async function resolveInstalledSdkGeneratedTypesPath() {
115
140
  const target = await resolveInstalledSdkTypegenTarget();
116
141
  return target?.serverGeneratedTypesPath ?? null;
117
142
  }
118
- export function renderGeneratedTypesForManifest(manifest) {
143
+ export function renderGeneratedTypesForManifest(manifest, mode = "semantic") {
119
144
  return {
120
145
  serverContents: buildGeneratedTypesContents(manifest, {
146
+ mode,
121
147
  typeModulePath: "./dist/types.js",
122
148
  declaredModulePath: "./dist/types.js",
123
149
  interfaceName: "BarekeyGeneratedTypeMap",
124
150
  include: () => true,
125
151
  }),
126
152
  publicContents: buildGeneratedTypesContents(manifest, {
153
+ mode,
127
154
  typeModulePath: "./dist/public-types.js",
128
155
  declaredModulePath: "./dist/public-types.js",
129
156
  interfaceName: "BarekeyPublicGeneratedTypeMap",
@@ -143,7 +170,10 @@ export async function hasFreshInstalledSdkTypegen(intervalMs, identity) {
143
170
  if (metadata.baseUrl !== identity.baseUrl ||
144
171
  metadata.orgSlug !== identity.orgSlug ||
145
172
  metadata.projectSlug !== identity.projectSlug ||
146
- metadata.stageSlug !== identity.stageSlug) {
173
+ metadata.stageSlug !== identity.stageSlug ||
174
+ metadata.typegenMode !== identity.typegenMode ||
175
+ metadata.runtimeMode !== identity.runtimeMode ||
176
+ metadata.localEnvRoot !== identity.localEnvRoot) {
147
177
  return false;
148
178
  }
149
179
  return Date.now() - Date.parse(metadata.last) < intervalMs;
@@ -163,7 +193,10 @@ export async function writeInstalledSdkGeneratedTypes(manifest, identity) {
163
193
  readTextFile(target.serverGeneratedTypesPath),
164
194
  readTextFile(target.publicGeneratedTypesPath),
165
195
  ]);
166
- if (readManifestVersion(existingServerContents) === manifest.manifestVersion &&
196
+ const rendered = renderGeneratedTypesForManifest(manifest, identity.typegenMode);
197
+ if (existingServerContents === rendered.serverContents &&
198
+ existingPublicContents === rendered.publicContents &&
199
+ readManifestVersion(existingServerContents) === manifest.manifestVersion &&
167
200
  readManifestVersion(existingPublicContents) === manifest.manifestVersion) {
168
201
  await writeTextFileAtomic(target.typegenMetadataPath, buildTypegenMetadataContents(new Date(), identity));
169
202
  return {
@@ -174,7 +207,6 @@ export async function writeInstalledSdkGeneratedTypes(manifest, identity) {
174
207
  manifestVersion: manifest.manifestVersion,
175
208
  };
176
209
  }
177
- const rendered = renderGeneratedTypesForManifest(manifest);
178
210
  await Promise.all([
179
211
  writeTextFileAtomic(target.serverGeneratedTypesPath, rendered.serverContents),
180
212
  writeTextFileAtomic(target.publicGeneratedTypesPath, rendered.publicContents),
@@ -1,21 +1,21 @@
1
- import type { Env, Secret } from "./types.js";
1
+ import type { Env } from "./types.js";
2
2
  declare module "./types.js" {
3
3
  interface BarekeyGeneratedTypeMap {
4
4
  PRIVATE_TOKEN: Env<{
5
- Mode: Secret;
5
+ Type: string;
6
+ Kind: "secret";
6
7
  Visibility: "private";
7
8
  Rollout: never;
8
- Type: string;
9
9
  }>;
10
10
  }
11
11
  }
12
12
  declare module "./public-types.js" {
13
13
  interface BarekeyPublicGeneratedTypeMap {
14
14
  PUBLIC_THEME: Env<{
15
- Mode: Secret;
15
+ Type: "light" | "dark";
16
+ Kind: "secret";
16
17
  Visibility: "public";
17
18
  Rollout: never;
18
- Type: "light" | "dark";
19
19
  }>;
20
20
  }
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"key-types.typecheck.d.ts","sourceRoot":"","sources":["../src/key-types.typecheck.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAa9C,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,uBAAuB;QAC/B,aAAa,EAAE,GAAG,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,SAAS,CAAC;YACtB,OAAO,EAAE,KAAK,CAAC;YACf,IAAI,EAAE,MAAM,CAAC;SACd,CAAC,CAAC;KACJ;CACF;AAED,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,6BAA6B;QACrC,YAAY,EAAE,GAAG,CAAC;YAChB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,QAAQ,CAAC;YACrB,OAAO,EAAE,KAAK,CAAC;YACf,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;SACxB,CAAC,CAAC;KACJ;CACF;AA4DD,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"key-types.typecheck.d.ts","sourceRoot":"","sources":["../src/key-types.typecheck.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAU,MAAM,YAAY,CAAC;AAa9C,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,uBAAuB;QAC/B,aAAa,EAAE,GAAG,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,QAAQ,CAAC;YACf,UAAU,EAAE,SAAS,CAAC;YACtB,OAAO,EAAE,KAAK,CAAC;SAChB,CAAC,CAAC;KACJ;CACF;AAED,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,6BAA6B;QACrC,YAAY,EAAE,GAAG,CAAC;YAChB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;YACvB,IAAI,EAAE,QAAQ,CAAC;YACf,UAAU,EAAE,QAAQ,CAAC;YACrB,OAAO,EAAE,KAAK,CAAC;SAChB,CAAC,CAAC;KACJ;CACF;AA4ED,OAAO,EAAE,CAAC"}
@@ -9,6 +9,10 @@ export declare class PublicBarekeyClient {
9
9
  private runtimeContextPromise;
10
10
  private requirementsPromise;
11
11
  constructor();
12
+ constructor(options: {
13
+ requirements?: PublicBarekeyClientOptions["requirements"];
14
+ baseUrl?: string;
15
+ });
12
16
  constructor(options: {
13
17
  organization: string;
14
18
  project: string;
@@ -1 +1 @@
1
- {"version":3,"file":"public-client.d.ts","sourceRoot":"","sources":["../src/public-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAetE,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAEV,iBAAiB,EACjB,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAoCpB,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgD;IAChF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4C;IAC5E,OAAO,CAAC,qBAAqB,CAAqD;IAClF,OAAO,CAAC,mBAAmB,CAA8B;;gBAG7C,OAAO,EAAE;QACnB,YAAY,EAAE,MAAM,CAAC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CpB,qBAAqB;YAWrB,sBAAsB;CAoBrC"}
@@ -1,4 +1,4 @@
1
- export type { AB, BarekeyCoerceTarget, BarekeyDeclaredType, BarekeyDecision, BarekeyErrorCode, BarekeyEnvDescriptor, BarekeyEvaluatedValue, BarekeyGetOptions, BarekeyJsonConfig, BarekeyResolvedKind, BarekeyRolloutFunction, BarekeyRolloutMatchedRule, BarekeyRolloutMilestone, BarekeyStandardSchemaPathSegment, BarekeyStandardSchemaResult, BarekeyStandardSchemaV1, BarekeyTemporalInstant, BarekeyTemporalInstantLike, BarekeyTtlInput, BarekeyTypegenResult, BarekeyVariableDefinition, EaseInOut, Env, Linear, Secret, Step, } from "./types.js";
1
+ export type { AB, BarekeyCoerceTarget, BarekeyDeclaredType, BarekeyDecision, BarekeyErrorCode, BarekeyEnvDescriptor, BarekeyEvaluatedValue, BarekeyGetOptions, BarekeyJsonConfig, BarekeyResolvedKind, BarekeyRolloutFunction, BarekeyRolloutMatchedRule, BarekeyRolloutMilestone, BarekeyStandardSchemaPathSegment, BarekeyStandardSchemaResult, BarekeyStandardSchemaV1, BarekeyTemporalInstant, BarekeyTemporalInstantLike, BarekeyTypegenMode, BarekeyTtlInput, BarekeyTypegenResult, BarekeyVariableDefinition, EaseInOut, Env, Linear, Secret, Step, } from "./types.js";
2
2
  import type { BarekeyJsonConfig, BarekeyLiteralString, BarekeyStandardSchemaV1, BarekeyValueForGeneratedMap, BarekeyValuesForGeneratedMap } from "./types.js";
3
3
  export interface BarekeyPublicGeneratedTypeMap {
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"public-types.d.ts","sourceRoot":"","sources":["../src/public-types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,EAAE,EACF,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,gCA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AK,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC,CAAC"}
1
+ {"version":3,"file":"public-types.d.ts","sourceRoot":"","sources":["../src/public-types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,EAAE,EACF,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,gCAAgC,EAChC,2BAA2B,EAC3B,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,SAAS,EACT,GAAG,EACH,MAAM,EACN,MAAM,EACN,IAAI,GACL,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,6BAA6B;CAAG;AAEjD,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,MAAM,6BAA6B,EAAE,MAAM,CAAC,CAAC;AAEzF,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,oBAAoB,CAAC;AAE5E,MAAM,MAAM,wBAAwB,CAAC,IAAI,SAAS,MAAM,IAAI,2BAA2B,CACrF,6BAA6B,EAC7B,IAAI,CACL,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,SAAS,MAAM,EAAE,IACpE,4BAA4B,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;AAErE,KAAK,8BAA8B,GAAG;IACpC,YAAY,CAAC,EAAE,uBAAuB,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAClC,CAAC,8BAA8B,GAAG;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC,GACF,CAAC,8BAA8B,GAAG;IAChC,IAAI,EAAE,iBAAiB,CAAC;IACxB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC,GACF,CAAC,8BAA8B,GAAG;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,CAAC,CAAC"}
package/dist/public.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { PublicBarekeyClient } from "./public-client.js";
2
2
  export { BarekeyEnvBatchHandle, BarekeyEnvHandle } from "./handle.js";
3
3
  export { BarekeyError, BillingUnavailableError, CoerceFailedError, DeviceCodeExpiredError, DeviceCodeNotFoundError, EvaluationFailedError, FsNotAvailableError, InvalidConfigurationProvidedError, InvalidCredentialsProvidedError, InvalidDynamicOptionsError, InvalidJsonError, InvalidOrgScopeError, InvalidRefreshTokenError, InvalidRequestError, NetworkError, NoConfigurationProvidedError, NoCredentialsProvidedError, OrgScopeInvalidError, RequirementsValidationFailedError, SdkModuleNotFoundError, TemporalNotAvailableError, TypegenReadFailedError, TypegenUnsupportedSdkError, TypegenWriteFailedError, UnauthorizedError, UnknownError, UsageLimitExceededError, UserCodeInvalidError, VariableNotFoundError, createBarekeyErrorFromCode, docsUrlForErrorCode, formatBarekeyErrorMessage, isBarekeyErrorCode, normalizeErrorCode, } from "./errors.js";
4
- export type { AB, BarekeyCoerceTarget, BarekeyDeclaredType, BarekeyDecision, BarekeyErrorCode, BarekeyEnvDescriptor, BarekeyEvaluatedValue, BarekeyGetOptions, BarekeyJsonConfig, BarekeyLiteralString, BarekeyResolvedRecord, BarekeyResolvedRecords, BarekeyResolvedKind, BarekeyRolloutFunction, BarekeyRolloutMatchedRule, BarekeyRolloutMilestone, BarekeyStandardSchemaV1, BarekeyTemporalInstant, BarekeyTemporalInstantLike, BarekeyTtlInput, BarekeyValueForGeneratedMap, BarekeyValuesForGeneratedMap, BarekeyVariableDefinition, BarekeyVisibility, EaseInOut, Env, Linear, Secret, Step, } from "./types.js";
4
+ export type { AB, BarekeyCoerceTarget, BarekeyDeclaredType, BarekeyDecision, BarekeyErrorCode, BarekeyEnvDescriptor, BarekeyEvaluatedValue, BarekeyGetOptions, BarekeyJsonConfig, BarekeyLiteralString, BarekeyMode, BarekeyResolvedRecord, BarekeyResolvedRecords, BarekeyResolvedKind, BarekeyRolloutFunction, BarekeyRolloutMatchedRule, BarekeyRolloutMilestone, BarekeyStandardSchemaV1, BarekeyTemporalInstant, BarekeyTemporalInstantLike, BarekeyTypegenMode, BarekeyTtlInput, BarekeyValueForGeneratedMap, BarekeyValuesForGeneratedMap, BarekeyVariableDefinition, BarekeyVisibility, EaseInOut, Env, Linear, Secret, Step, } from "./types.js";
5
5
  export type { BarekeyPublicGeneratedTypeMap, BarekeyPublicKey, BarekeyPublicKnownKey, BarekeyPublicValueForKey, BarekeyPublicValuesForKeys, PublicBarekeyClientOptions, } from "./public-types.js";
6
6
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,EACpB,iCAAiC,EACjC,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,EAAE,EACF,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,EACT,GAAG,EACH,MAAM,EACN,MAAM,EACN,IAAI,GACL,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../src/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,EACpB,iCAAiC,EACjC,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,EAAE,EACF,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,EACT,GAAG,EACH,MAAM,EACN,MAAM,EACN,IAAI,GACL,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { BarekeyClient } from "./client.js";
2
2
  export { BarekeyEnvBatchHandle, BarekeyEnvHandle } from "./handle.js";
3
3
  export { BarekeyError, BillingUnavailableError, CoerceFailedError, DeviceCodeExpiredError, DeviceCodeNotFoundError, EvaluationFailedError, FsNotAvailableError, InvalidConfigurationProvidedError, InvalidCredentialsProvidedError, InvalidDynamicOptionsError, InvalidJsonError, InvalidOrgScopeError, InvalidRefreshTokenError, InvalidRequestError, NetworkError, NoConfigurationProvidedError, NoCredentialsProvidedError, OrgScopeInvalidError, RequirementsValidationFailedError, SdkModuleNotFoundError, TemporalNotAvailableError, TypegenReadFailedError, TypegenUnsupportedSdkError, TypegenWriteFailedError, UnauthorizedError, UnknownError, UsageLimitExceededError, UserCodeInvalidError, VariableNotFoundError, createBarekeyErrorFromCode, docsUrlForErrorCode, formatBarekeyErrorMessage, isBarekeyErrorCode, normalizeErrorCode, } from "./errors.js";
4
- export type { AB, BarekeyClientOptions, BarekeyCoerceTarget, BarekeyDeclaredType, BarekeyErrorCode, BarekeyEnvDescriptor, BarekeyGeneratedTypeMap, BarekeyGeneratedValueForKey, BarekeyGeneratedValuesForKeys, BarekeyGetOptions, BarekeyJsonConfig, BarekeyKey, BarekeyLiteralString, BarekeyKnownKey, BarekeyResolvedRecord, BarekeyResolvedRecords, BarekeyResolvedKind, BarekeyRolloutMilestone, BarekeyStandardSchemaV1, BarekeyTemporalInstant, BarekeyTemporalInstantLike, BarekeyTtlInput, BarekeyTypegenResult, BarekeyValueForGeneratedMap, BarekeyValuesForGeneratedMap, BarekeyVisibility, Env, Linear, Secret, } from "./types.js";
4
+ export type { AB, BarekeyClientOptions, BarekeyCoerceTarget, BarekeyDeclaredType, BarekeyErrorCode, BarekeyEnvDescriptor, BarekeyGeneratedTypeMap, BarekeyGeneratedValueForKey, BarekeyGeneratedValuesForKeys, BarekeyGetOptions, BarekeyJsonConfig, BarekeyKey, BarekeyLiteralString, BarekeyMode, BarekeyKnownKey, BarekeyResolvedRecord, BarekeyResolvedRecords, BarekeyResolvedKind, BarekeyRolloutMilestone, BarekeyStandardSchemaV1, BarekeyTemporalInstant, BarekeyTemporalInstantLike, BarekeyTypegenMode, BarekeyTtlInput, BarekeyTypegenResult, BarekeyValueForGeneratedMap, BarekeyValuesForGeneratedMap, BarekeyVisibility, Env, Linear, Secret, } from "./types.js";
5
5
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,EACpB,iCAAiC,EACjC,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,EAAE,EACF,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,EAC5B,iBAAiB,EACjB,GAAG,EACH,MAAM,EACN,MAAM,GACP,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,iCAAiC,EACjC,+BAA+B,EAC/B,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,EACpB,iCAAiC,EACjC,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,EAAE,EACF,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,EAC5B,iBAAiB,EACjB,GAAG,EACH,MAAM,EACN,MAAM,GACP,MAAM,YAAY,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export type BarekeyResolvedKind = "secret" | "ab_roll" | "rollout";
2
2
  export type BarekeyVisibility = "private" | "public";
3
3
  export type BarekeyDeclaredType = "string" | "boolean" | "int64" | "float" | "date" | "json";
4
+ export type BarekeyTypegenMode = "semantic" | "minimal";
5
+ export type BarekeyMode = "centralized" | "standalone";
4
6
  export type BarekeyTemporalInstant = {
5
7
  readonly epochMilliseconds: number;
6
8
  toJSON(): string;
@@ -12,6 +14,7 @@ export type BarekeyTemporalInstantLike = {
12
14
  export type BarekeyTtlInput = number | Date | BarekeyTemporalInstantLike;
13
15
  export type Secret = "secret";
14
16
  export type AB = "ab";
17
+ type BarekeyLegacyEnvMode = Secret | AB;
15
18
  export type Linear<TMilestones extends ReadonlyArray<readonly [string, number]> = ReadonlyArray<readonly [string, number]>> = {
16
19
  readonly kind: "linear";
17
20
  readonly milestones: TMilestones;
@@ -24,21 +27,43 @@ export type EaseInOut<TMilestones extends ReadonlyArray<readonly [string, number
24
27
  readonly kind: "ease_in_out";
25
28
  readonly milestones: TMilestones;
26
29
  };
27
- export type BarekeyEnvDescriptor<TMode = never, TVisibility = never, TRollout = never, TType = unknown> = {
30
+ type BarekeySemanticEnvDescriptor<TKind = never, TVisibility = never, TRollout = never, TType = unknown> = {
31
+ Kind: TKind;
32
+ Visibility: TVisibility;
33
+ Rollout: TRollout;
34
+ Type: TType;
35
+ };
36
+ export type BarekeyEnvDescriptor<TKindOrMode = never, TVisibility = never, TRollout = never, TType = unknown> = TKindOrMode extends BarekeyLegacyEnvMode ? BarekeyLegacyEnvDescriptor<TKindOrMode, TVisibility, TRollout, TType> : BarekeySemanticEnvDescriptor<TKindOrMode, TVisibility, TRollout, TType>;
37
+ export type BarekeyLegacyEnvDescriptor<TMode = never, TVisibility = never, TRollout = never, TType = unknown> = {
28
38
  Mode: TMode;
29
39
  Visibility: TVisibility;
30
40
  Rollout: TRollout;
31
41
  Type: TType;
32
42
  };
33
- type BarekeyAnyEnvDescriptor = BarekeyEnvDescriptor<unknown, unknown, unknown, unknown>;
34
- type BarekeyEnvMarker<TMode, TVisibility, TRollout> = {
43
+ type BarekeyAnyEnvDescriptor = BarekeySemanticEnvDescriptor<unknown, unknown, unknown, unknown> | BarekeyLegacyEnvDescriptor<unknown, unknown, unknown, unknown>;
44
+ type BarekeyKindFromLegacyMode<TMode> = TMode extends Secret ? "secret" : TMode extends AB ? "ab_roll" | "rollout" : never;
45
+ type BarekeyDescriptorKind<TDescriptor> = TDescriptor extends {
46
+ Kind: infer TKind;
47
+ } ? TKind : TDescriptor extends {
48
+ Mode: infer TMode;
49
+ } ? BarekeyKindFromLegacyMode<TMode> : never;
50
+ type BarekeyDescriptorVisibility<TDescriptor> = TDescriptor extends {
51
+ Visibility: infer TVisibility;
52
+ } ? TVisibility : never;
53
+ type BarekeyDescriptorRollout<TDescriptor> = TDescriptor extends {
54
+ Rollout: infer TRollout;
55
+ } ? TRollout : never;
56
+ type BarekeyDescriptorValue<TDescriptor> = TDescriptor extends {
57
+ Type: infer TValue;
58
+ } ? TValue : never;
59
+ type BarekeyEnvMarker<TKind, TVisibility, TRollout> = {
35
60
  readonly __barekey?: {
36
- readonly mode: TMode;
61
+ readonly kind: TKind;
37
62
  readonly visibility: TVisibility;
38
63
  readonly rollout: TRollout;
39
64
  };
40
65
  };
41
- export type Env<TDescriptorOrMode, TValue = never, TRollout = never, TVisibility = never> = [TValue] extends [never] ? TDescriptorOrMode extends BarekeyAnyEnvDescriptor ? TDescriptorOrMode["Type"] & BarekeyEnvMarker<TDescriptorOrMode["Mode"], TDescriptorOrMode["Visibility"], TDescriptorOrMode["Rollout"]> : never : TValue & BarekeyEnvMarker<TDescriptorOrMode, TVisibility, TRollout>;
66
+ export type Env<TDescriptorOrMode, TValue = never, TRollout = never, TVisibility = never> = [TValue] extends [never] ? TDescriptorOrMode extends BarekeyAnyEnvDescriptor ? BarekeyDescriptorValue<TDescriptorOrMode> & BarekeyEnvMarker<BarekeyDescriptorKind<TDescriptorOrMode>, BarekeyDescriptorVisibility<TDescriptorOrMode>, BarekeyDescriptorRollout<TDescriptorOrMode>> : never : TValue & BarekeyEnvMarker<TDescriptorOrMode extends BarekeyLegacyEnvMode ? BarekeyKindFromLegacyMode<TDescriptorOrMode> : TDescriptorOrMode, TVisibility, TRollout>;
42
67
  export type BarekeyCoerceTarget = "string" | "boolean" | "int64" | "float" | "date" | "json";
43
68
  export interface BarekeyGeneratedTypeMap {
44
69
  }
@@ -117,6 +142,10 @@ export type BarekeyJsonConfig = {
117
142
  environment?: string;
118
143
  org?: string;
119
144
  stage?: string;
145
+ config?: {
146
+ typegen?: BarekeyTypegenMode;
147
+ mode?: BarekeyMode;
148
+ };
120
149
  };
121
150
  export type BarekeyStandardSchemaResult = {
122
151
  value: unknown;