@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.
- package/README.md +84 -7
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +61 -15
- package/dist/handle.d.ts +1 -1
- package/dist/handle.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/config.d.ts +5 -0
- package/dist/internal/config.d.ts.map +1 -0
- package/dist/internal/config.js +26 -0
- package/dist/internal/node-runtime.d.ts +11 -0
- package/dist/internal/node-runtime.d.ts.map +1 -1
- package/dist/internal/node-runtime.js +2 -1
- package/dist/internal/public-runtime.d.ts.map +1 -1
- package/dist/internal/public-runtime.js +17 -3
- package/dist/internal/runtime.d.ts +15 -1
- package/dist/internal/runtime.d.ts.map +1 -1
- package/dist/internal/runtime.js +49 -7
- package/dist/internal/singleton.d.ts.map +1 -1
- package/dist/internal/singleton.js +14 -0
- package/dist/internal/standalone.d.ts +10 -0
- package/dist/internal/standalone.d.ts.map +1 -0
- package/dist/internal/standalone.js +246 -0
- package/dist/internal/typegen.d.ts +6 -3
- package/dist/internal/typegen.d.ts.map +1 -1
- package/dist/internal/typegen.js +45 -13
- package/dist/key-types.typecheck.d.ts +5 -5
- package/dist/key-types.typecheck.d.ts.map +1 -1
- package/dist/public-client.d.ts +4 -0
- package/dist/public-client.d.ts.map +1 -1
- package/dist/public-types.d.ts +1 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/public.d.ts +1 -1
- package/dist/public.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/types.d.ts +34 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +86 -15
- package/src/handle.ts +1 -1
- package/src/index.ts +2 -0
- package/src/internal/config.ts +34 -0
- package/src/internal/node-runtime.ts +4 -2
- package/src/internal/public-runtime.ts +25 -4
- package/src/internal/runtime.ts +91 -7
- package/src/internal/singleton.ts +37 -4
- package/src/internal/standalone.ts +309 -0
- package/src/internal/typegen.ts +68 -15
- package/src/key-types.typecheck.ts +20 -4
- package/src/public-client.ts +4 -0
- package/src/public-types.ts +1 -0
- package/src/public.ts +2 -0
- package/src/server.ts +2 -0
- package/src/types.ts +81 -8
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7F,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,MAAM,IAAI,MAAM,CAAC;IACjB,QAAQ,IAAI,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,0BAA0B,CAAC;AAEzE,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC;AAE9B,MAAM,MAAM,EAAE,GAAG,IAAI,CAAC;AAEtB,MAAM,MAAM,MAAM,CAChB,WAAW,SAAS,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,aAAa,CAC1E,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAC1B,IACC;IACF,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,WAAW,CA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GACzB,8BAA8B,GAC9B,yBAAyB,GACzB,gCAAgC,GAChC,eAAe,GACf,eAAe,GACf,wBAAwB,GACxB,sBAAsB,GACtB,yBAAyB,GACzB,qBAAqB,GACrB,sBAAsB,GACtB,cAAc,GACd,mBAAmB,GACnB,mBAAmB,GACnB,cAAc,GACd,iBAAiB,GACjB,oBAAoB,GACpB,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,uBAAuB,GACvB,qBAAqB,GACrB,mBAAmB,GACnB,uBAAuB,GACvB,eAAe,CAAC"}
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -15,6 +15,10 @@ import { getJson, postJson } from "./internal/http.js";
|
|
|
15
15
|
import { validateRequirements } from "./internal/requirements.js";
|
|
16
16
|
import { resolveRuntimeContext, type BarekeyRuntimeContext } from "./internal/runtime.js";
|
|
17
17
|
import { createBarekeyClientSingletonKey } from "./internal/singleton.js";
|
|
18
|
+
import {
|
|
19
|
+
buildStandaloneTypegenManifest,
|
|
20
|
+
loadStandaloneDefinitions,
|
|
21
|
+
} from "./internal/standalone.js";
|
|
18
22
|
import { MemoryCache } from "./internal/cache.js";
|
|
19
23
|
import { DEFAULT_TYPEGEN_TTL_MS, resolveTtlMilliseconds } from "./internal/ttl.js";
|
|
20
24
|
import {
|
|
@@ -118,6 +122,26 @@ function resolveEvaluatedResponse(evaluated: EvaluateResponse): BarekeyEvaluated
|
|
|
118
122
|
};
|
|
119
123
|
}
|
|
120
124
|
|
|
125
|
+
function createTypegenIdentity(context: BarekeyRuntimeContext): {
|
|
126
|
+
baseUrl: string | null;
|
|
127
|
+
orgSlug: string;
|
|
128
|
+
projectSlug: string;
|
|
129
|
+
stageSlug: string;
|
|
130
|
+
typegenMode: BarekeyRuntimeContext["typegenMode"];
|
|
131
|
+
runtimeMode: BarekeyRuntimeContext["mode"];
|
|
132
|
+
localEnvRoot: string | null;
|
|
133
|
+
} {
|
|
134
|
+
return {
|
|
135
|
+
baseUrl: context.baseUrl,
|
|
136
|
+
orgSlug: context.organization,
|
|
137
|
+
projectSlug: context.project,
|
|
138
|
+
stageSlug: context.environment,
|
|
139
|
+
typegenMode: context.typegenMode,
|
|
140
|
+
runtimeMode: context.mode,
|
|
141
|
+
localEnvRoot: context.localEnvRoot,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
121
145
|
export class BarekeyClient {
|
|
122
146
|
private readonly options!: BarekeyClientOptions;
|
|
123
147
|
private readonly fetchFn!: typeof globalThis.fetch;
|
|
@@ -128,6 +152,10 @@ export class BarekeyClient {
|
|
|
128
152
|
private typegenWatcherStarted = false;
|
|
129
153
|
|
|
130
154
|
constructor();
|
|
155
|
+
constructor(options: {
|
|
156
|
+
requirements?: BarekeyClientOptions["requirements"];
|
|
157
|
+
typegen?: BarekeyClientOptions["typegen"];
|
|
158
|
+
});
|
|
131
159
|
constructor(options: {
|
|
132
160
|
organization: string;
|
|
133
161
|
project: string;
|
|
@@ -184,13 +212,17 @@ export class BarekeyClient {
|
|
|
184
212
|
});
|
|
185
213
|
}
|
|
186
214
|
|
|
187
|
-
const manifest =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
215
|
+
const manifest =
|
|
216
|
+
context.mode === "standalone"
|
|
217
|
+
? await buildStandaloneTypegenManifest({
|
|
218
|
+
rootDirectory: context.localEnvRoot,
|
|
219
|
+
organization: context.organization,
|
|
220
|
+
project: context.project,
|
|
221
|
+
environment: context.environment,
|
|
222
|
+
})
|
|
223
|
+
: await this.fetchTypegenManifest(context);
|
|
224
|
+
|
|
225
|
+
return await writeInstalledSdkGeneratedTypes(manifest, createTypegenIdentity(context));
|
|
194
226
|
}
|
|
195
227
|
|
|
196
228
|
private async getRuntimeContext(): Promise<BarekeyRuntimeContext> {
|
|
@@ -208,6 +240,15 @@ export class BarekeyClient {
|
|
|
208
240
|
|
|
209
241
|
private async fetchTypegenManifest(context?: BarekeyRuntimeContext): Promise<TypegenManifest> {
|
|
210
242
|
const resolvedContext = context ?? (await this.getRuntimeContext());
|
|
243
|
+
if (resolvedContext.mode !== "centralized") {
|
|
244
|
+
return await buildStandaloneTypegenManifest({
|
|
245
|
+
rootDirectory: resolvedContext.localEnvRoot,
|
|
246
|
+
organization: resolvedContext.organization,
|
|
247
|
+
project: resolvedContext.project,
|
|
248
|
+
environment: resolvedContext.environment,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
211
252
|
return await getJson<TypegenManifest>({
|
|
212
253
|
fetchFn: this.fetchFn,
|
|
213
254
|
baseUrl: resolvedContext.baseUrl,
|
|
@@ -245,10 +286,13 @@ export class BarekeyClient {
|
|
|
245
286
|
|
|
246
287
|
const intervalMs = this.getTypegenIntervalMs();
|
|
247
288
|
const watcherKey = [
|
|
248
|
-
context.baseUrl,
|
|
289
|
+
context.baseUrl ?? "",
|
|
249
290
|
context.organization,
|
|
250
291
|
context.project,
|
|
251
292
|
context.environment,
|
|
293
|
+
context.mode,
|
|
294
|
+
context.localEnvRoot ?? "",
|
|
295
|
+
context.typegenMode,
|
|
252
296
|
generatedTypesPath,
|
|
253
297
|
].join("|");
|
|
254
298
|
|
|
@@ -298,10 +342,7 @@ export class BarekeyClient {
|
|
|
298
342
|
sharedTypegenWatchers.set(watcherKey, watcher);
|
|
299
343
|
if (
|
|
300
344
|
!(await hasFreshInstalledSdkTypegen(intervalMs, {
|
|
301
|
-
|
|
302
|
-
orgSlug: context.organization,
|
|
303
|
-
projectSlug: context.project,
|
|
304
|
-
stageSlug: context.environment,
|
|
345
|
+
...createTypegenIdentity(context),
|
|
305
346
|
}))
|
|
306
347
|
) {
|
|
307
348
|
void runWatcher(watcher);
|
|
@@ -320,7 +361,14 @@ export class BarekeyClient {
|
|
|
320
361
|
}
|
|
321
362
|
|
|
322
363
|
private buildDefinitionCacheKey(context: BarekeyRuntimeContext, name: string): string {
|
|
323
|
-
return [
|
|
364
|
+
return [
|
|
365
|
+
context.mode,
|
|
366
|
+
context.localEnvRoot ?? "",
|
|
367
|
+
context.organization,
|
|
368
|
+
context.project,
|
|
369
|
+
context.environment,
|
|
370
|
+
name,
|
|
371
|
+
].join("|");
|
|
324
372
|
}
|
|
325
373
|
|
|
326
374
|
private buildEvaluationCacheKey(
|
|
@@ -329,12 +377,14 @@ export class BarekeyClient {
|
|
|
329
377
|
options?: BarekeyGetOptions,
|
|
330
378
|
): string {
|
|
331
379
|
return [
|
|
380
|
+
context.mode,
|
|
381
|
+
context.localEnvRoot ?? "",
|
|
332
382
|
context.organization,
|
|
333
383
|
context.project,
|
|
334
384
|
context.environment,
|
|
335
385
|
name,
|
|
336
|
-
options?.seed ?? "",
|
|
337
|
-
options?.key ?? "",
|
|
386
|
+
context.mode === "standalone" ? "" : options?.seed ?? "",
|
|
387
|
+
context.mode === "standalone" ? "" : options?.key ?? "",
|
|
338
388
|
].join("|");
|
|
339
389
|
}
|
|
340
390
|
|
|
@@ -344,6 +394,19 @@ export class BarekeyClient {
|
|
|
344
394
|
}
|
|
345
395
|
|
|
346
396
|
const context = await this.getRuntimeContext();
|
|
397
|
+
if (context.mode === "standalone") {
|
|
398
|
+
const definitions = await loadStandaloneDefinitions(context.localEnvRoot);
|
|
399
|
+
for (const definition of definitions) {
|
|
400
|
+
this.definitionCache.set(this.buildDefinitionCacheKey(context, definition.name), definition);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (names === undefined) {
|
|
404
|
+
return definitions;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return mapValuesToRequestedOrder(names, definitions);
|
|
408
|
+
}
|
|
409
|
+
|
|
347
410
|
const response = await postJson<DefinitionsResponse>({
|
|
348
411
|
fetchFn: this.fetchFn,
|
|
349
412
|
baseUrl: context.baseUrl,
|
|
@@ -458,6 +521,14 @@ export class BarekeyClient {
|
|
|
458
521
|
context: BarekeyRuntimeContext,
|
|
459
522
|
options?: BarekeyGetOptions,
|
|
460
523
|
): Promise<Array<BarekeyEvaluatedValue>> {
|
|
524
|
+
if (context.mode === "standalone") {
|
|
525
|
+
const definitions = await loadStandaloneDefinitions(context.localEnvRoot);
|
|
526
|
+
const resolvedDefinitions = mapValuesToRequestedOrder(names, definitions);
|
|
527
|
+
return await Promise.all(
|
|
528
|
+
resolvedDefinitions.map(async (definition) => await evaluateDefinition(definition)),
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
461
532
|
try {
|
|
462
533
|
if (names.length === 1) {
|
|
463
534
|
const evaluated = await postJson<EvaluateResponse>({
|
package/src/handle.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ export type {
|
|
|
53
53
|
BarekeyJsonConfig,
|
|
54
54
|
BarekeyKey,
|
|
55
55
|
BarekeyLiteralString,
|
|
56
|
+
BarekeyMode,
|
|
56
57
|
BarekeyKnownKey,
|
|
57
58
|
BarekeyResolvedRecord,
|
|
58
59
|
BarekeyResolvedRecords,
|
|
@@ -61,6 +62,7 @@ export type {
|
|
|
61
62
|
BarekeyStandardSchemaV1,
|
|
62
63
|
BarekeyTemporalInstant,
|
|
63
64
|
BarekeyTemporalInstantLike,
|
|
65
|
+
BarekeyTypegenMode,
|
|
64
66
|
BarekeyTtlInput,
|
|
65
67
|
BarekeyTypegenResult,
|
|
66
68
|
BarekeyValueForGeneratedMap,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InvalidConfigurationProvidedError } from "../errors.js";
|
|
2
|
+
import type { BarekeyMode, BarekeyTypegenMode } from "../types.js";
|
|
3
|
+
|
|
4
|
+
export function readConfigString(value: unknown): string | undefined {
|
|
5
|
+
return typeof value === "string" ? value.trim() : undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function normalizeTypegenMode(value: unknown, source: string): BarekeyTypegenMode {
|
|
9
|
+
if (value === undefined) {
|
|
10
|
+
return "semantic";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (value === "semantic" || value === "minimal") {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
throw new InvalidConfigurationProvidedError({
|
|
18
|
+
message: `${source} must provide config.typegen as "semantic" or "minimal" when set.`,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function normalizeMode(value: unknown, source: string): BarekeyMode {
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
return "centralized";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (value === "centralized" || value === "standalone") {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new InvalidConfigurationProvidedError({
|
|
32
|
+
message: `${source} must provide config.mode as "centralized" or "standalone" when set.`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "../errors.js";
|
|
10
10
|
import { postJson } from "./http.js";
|
|
11
11
|
|
|
12
|
-
type NodeRuntimeModules = {
|
|
12
|
+
export type NodeRuntimeModules = {
|
|
13
13
|
childProcess: typeof import("node:child_process");
|
|
14
14
|
fs: typeof import("node:fs/promises");
|
|
15
15
|
moduleApi: {
|
|
@@ -57,7 +57,7 @@ function isNodeRuntime(): boolean {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
async function loadNodeRuntime(): Promise<NodeRuntimeModules | null> {
|
|
60
|
+
export async function loadNodeRuntime(): Promise<NodeRuntimeModules | null> {
|
|
61
61
|
if (!isNodeRuntime()) {
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
@@ -352,6 +352,7 @@ export async function isFilesystemAvailable(): Promise<boolean> {
|
|
|
352
352
|
|
|
353
353
|
export async function loadBarekeyJsonConfig(): Promise<{
|
|
354
354
|
path: string;
|
|
355
|
+
directory: string;
|
|
355
356
|
json: Record<string, unknown>;
|
|
356
357
|
} | null> {
|
|
357
358
|
const runtime = await loadNodeRuntime();
|
|
@@ -367,6 +368,7 @@ export async function loadBarekeyJsonConfig(): Promise<{
|
|
|
367
368
|
try {
|
|
368
369
|
return {
|
|
369
370
|
path: candidate,
|
|
371
|
+
directory: current,
|
|
370
372
|
json: JSON.parse(raw) as Record<string, unknown>,
|
|
371
373
|
};
|
|
372
374
|
} catch (error: unknown) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "../errors.js";
|
|
6
6
|
import type { PublicBarekeyClientOptions } from "../public-types.js";
|
|
7
7
|
import type { BarekeyJsonConfig, BarekeyStandardSchemaV1 } from "../types.js";
|
|
8
|
+
import { normalizeMode, normalizeTypegenMode, readConfigString } from "./config.js";
|
|
8
9
|
import { normalizeBaseUrl } from "./http.js";
|
|
9
10
|
import { isFilesystemAvailable, loadBarekeyJsonConfig } from "./node-runtime.js";
|
|
10
11
|
|
|
@@ -21,10 +22,6 @@ export type BarekeyPublicRuntimeContext = BarekeyResolvedScope & {
|
|
|
21
22
|
requirements?: BarekeyStandardSchemaV1;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
function readConfigString(value: unknown): string | undefined {
|
|
25
|
-
return typeof value === "string" ? value.trim() : undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
25
|
function normalizeScope(input: {
|
|
29
26
|
organization?: unknown;
|
|
30
27
|
project?: unknown;
|
|
@@ -47,10 +44,34 @@ function normalizeScope(input: {
|
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
46
|
|
|
47
|
+
function createStandaloneUnsupportedError(source: string): Error {
|
|
48
|
+
return new InvalidConfigurationProvidedError({
|
|
49
|
+
message: [
|
|
50
|
+
`${source} sets config.mode to "standalone".`,
|
|
51
|
+
"PublicBarekeyClient does not support standalone local env mode because it relies on a server filesystem to read .env files.",
|
|
52
|
+
"Use BarekeyClient on the server instead, or switch barekey.json config.mode back to \"centralized\" for browser/public usage.",
|
|
53
|
+
].join(" "),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
function normalizeJsonConfig(
|
|
51
58
|
input: BarekeyJsonConfig | Record<string, unknown>,
|
|
52
59
|
source: string,
|
|
53
60
|
): BarekeyResolvedScope {
|
|
61
|
+
const config =
|
|
62
|
+
"config" in input && typeof input.config === "object" && input.config !== null
|
|
63
|
+
? (input.config as Record<string, unknown>)
|
|
64
|
+
: undefined;
|
|
65
|
+
|
|
66
|
+
normalizeTypegenMode(
|
|
67
|
+
config?.typegen ?? ("typegen" in input ? input.typegen : undefined),
|
|
68
|
+
source,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (normalizeMode(config?.mode, source) === "standalone") {
|
|
72
|
+
throw createStandaloneUnsupportedError(source);
|
|
73
|
+
}
|
|
74
|
+
|
|
54
75
|
return normalizeScope({
|
|
55
76
|
organization: input.organization ?? input.org,
|
|
56
77
|
project: input.project,
|
package/src/internal/runtime.ts
CHANGED
|
@@ -7,7 +7,13 @@ import {
|
|
|
7
7
|
NoCredentialsProvidedError,
|
|
8
8
|
UnauthorizedError,
|
|
9
9
|
} from "../errors.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
BarekeyClientOptions,
|
|
12
|
+
BarekeyJsonConfig,
|
|
13
|
+
BarekeyStandardSchemaV1,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import type { BarekeyMode, BarekeyTypegenMode } from "../types.js";
|
|
16
|
+
import { normalizeMode, normalizeTypegenMode, readConfigString } from "./config.js";
|
|
11
17
|
import { type InternalAuthResolver, normalizeBaseUrl } from "./http.js";
|
|
12
18
|
import {
|
|
13
19
|
isFilesystemAvailable,
|
|
@@ -21,14 +27,31 @@ type BarekeyResolvedScope = {
|
|
|
21
27
|
organization: string;
|
|
22
28
|
project: string;
|
|
23
29
|
environment: string;
|
|
30
|
+
typegenMode: BarekeyTypegenMode;
|
|
31
|
+
mode: BarekeyMode;
|
|
32
|
+
localEnvRoot: string | null;
|
|
24
33
|
};
|
|
25
34
|
|
|
26
|
-
|
|
35
|
+
type BarekeyCentralizedRuntimeContext = BarekeyResolvedScope & {
|
|
36
|
+
mode: "centralized";
|
|
37
|
+
localEnvRoot: null;
|
|
27
38
|
baseUrl: string;
|
|
28
39
|
auth: InternalAuthResolver;
|
|
29
40
|
requirements?: BarekeyStandardSchemaV1;
|
|
30
41
|
};
|
|
31
42
|
|
|
43
|
+
type BarekeyStandaloneRuntimeContext = BarekeyResolvedScope & {
|
|
44
|
+
mode: "standalone";
|
|
45
|
+
localEnvRoot: string;
|
|
46
|
+
baseUrl: null;
|
|
47
|
+
auth: null;
|
|
48
|
+
requirements?: BarekeyStandardSchemaV1;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type BarekeyRuntimeContext =
|
|
52
|
+
| BarekeyCentralizedRuntimeContext
|
|
53
|
+
| BarekeyStandaloneRuntimeContext;
|
|
54
|
+
|
|
32
55
|
function readProcessEnv(key: string): string | undefined {
|
|
33
56
|
if (typeof process === "undefined" || typeof process.env !== "object" || process.env === null) {
|
|
34
57
|
return undefined;
|
|
@@ -38,40 +61,73 @@ function readProcessEnv(key: string): string | undefined {
|
|
|
38
61
|
return typeof value === "string" ? value : undefined;
|
|
39
62
|
}
|
|
40
63
|
|
|
41
|
-
function
|
|
42
|
-
|
|
64
|
+
function safeCurrentWorkingDirectory(): string | null {
|
|
65
|
+
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return process.cwd();
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
function normalizeScope(input: {
|
|
46
73
|
organization?: unknown;
|
|
47
74
|
project?: unknown;
|
|
48
75
|
environment?: unknown;
|
|
76
|
+
typegenMode?: BarekeyTypegenMode;
|
|
77
|
+
mode?: BarekeyMode;
|
|
78
|
+
localEnvRoot?: string | null;
|
|
49
79
|
source: string;
|
|
50
80
|
}): BarekeyResolvedScope {
|
|
81
|
+
const mode = input.mode ?? "centralized";
|
|
51
82
|
const organization = readConfigString(input.organization) ?? "";
|
|
52
83
|
const project = readConfigString(input.project) ?? "";
|
|
53
84
|
const environment = readConfigString(input.environment) ?? "";
|
|
54
|
-
if (
|
|
85
|
+
if (
|
|
86
|
+
mode !== "standalone" &&
|
|
87
|
+
(organization.length === 0 || project.length === 0 || environment.length === 0)
|
|
88
|
+
) {
|
|
55
89
|
throw new InvalidConfigurationProvidedError({
|
|
56
90
|
message: `${input.source} must provide organization, project, and environment.`,
|
|
57
91
|
});
|
|
58
92
|
}
|
|
59
93
|
|
|
94
|
+
const localEnvRoot = mode === "standalone" ? input.localEnvRoot ?? safeCurrentWorkingDirectory() : null;
|
|
95
|
+
if (mode === "standalone" && (!localEnvRoot || localEnvRoot.trim().length === 0)) {
|
|
96
|
+
throw new FsNotAvailableError({
|
|
97
|
+
message: "Barekey standalone mode requires filesystem access and a working directory.",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
60
101
|
return {
|
|
61
102
|
organization,
|
|
62
103
|
project,
|
|
63
104
|
environment,
|
|
105
|
+
typegenMode: mode === "standalone" ? "minimal" : (input.typegenMode ?? "semantic"),
|
|
106
|
+
mode,
|
|
107
|
+
localEnvRoot: mode === "standalone" ? localEnvRoot : null,
|
|
64
108
|
};
|
|
65
109
|
}
|
|
66
110
|
|
|
67
111
|
function normalizeJsonConfig(
|
|
68
112
|
input: BarekeyJsonConfig | Record<string, unknown>,
|
|
69
113
|
source: string,
|
|
114
|
+
localEnvRoot: string | null,
|
|
70
115
|
): BarekeyResolvedScope {
|
|
116
|
+
const config =
|
|
117
|
+
"config" in input && typeof input.config === "object" && input.config !== null
|
|
118
|
+
? (input.config as Record<string, unknown>)
|
|
119
|
+
: undefined;
|
|
120
|
+
|
|
71
121
|
return normalizeScope({
|
|
72
122
|
organization: input.organization ?? input.org,
|
|
73
123
|
project: input.project,
|
|
74
124
|
environment: input.environment ?? input.stage,
|
|
125
|
+
typegenMode: normalizeTypegenMode(
|
|
126
|
+
config?.typegen ?? ("typegen" in input ? input.typegen : undefined),
|
|
127
|
+
source,
|
|
128
|
+
),
|
|
129
|
+
mode: normalizeMode(config?.mode, source),
|
|
130
|
+
localEnvRoot,
|
|
75
131
|
source,
|
|
76
132
|
});
|
|
77
133
|
}
|
|
@@ -100,7 +156,11 @@ async function resolveScope(options: BarekeyClientOptions): Promise<BarekeyResol
|
|
|
100
156
|
}
|
|
101
157
|
|
|
102
158
|
if (explicitJson !== undefined) {
|
|
103
|
-
return normalizeJsonConfig(
|
|
159
|
+
return normalizeJsonConfig(
|
|
160
|
+
explicitJson,
|
|
161
|
+
"The provided json configuration",
|
|
162
|
+
safeCurrentWorkingDirectory(),
|
|
163
|
+
);
|
|
104
164
|
}
|
|
105
165
|
|
|
106
166
|
if (explicitCount === 3) {
|
|
@@ -108,6 +168,9 @@ async function resolveScope(options: BarekeyClientOptions): Promise<BarekeyResol
|
|
|
108
168
|
organization: explicitOrganization,
|
|
109
169
|
project: explicitProject,
|
|
110
170
|
environment: explicitEnvironment,
|
|
171
|
+
typegenMode: "semantic",
|
|
172
|
+
mode: "centralized",
|
|
173
|
+
localEnvRoot: null,
|
|
111
174
|
source: "The provided Barekey configuration",
|
|
112
175
|
});
|
|
113
176
|
}
|
|
@@ -125,6 +188,7 @@ async function resolveScope(options: BarekeyClientOptions): Promise<BarekeyResol
|
|
|
125
188
|
return normalizeJsonConfig(
|
|
126
189
|
loadedConfig.json,
|
|
127
190
|
`The barekey.json file at ${loadedConfig.path}`,
|
|
191
|
+
loadedConfig.directory,
|
|
128
192
|
);
|
|
129
193
|
}
|
|
130
194
|
|
|
@@ -189,9 +253,29 @@ export async function resolveRuntimeContext(
|
|
|
189
253
|
options: BarekeyClientOptions,
|
|
190
254
|
fetchFn: typeof globalThis.fetch,
|
|
191
255
|
): Promise<BarekeyRuntimeContext> {
|
|
192
|
-
const
|
|
256
|
+
const scope = await resolveScope(options);
|
|
257
|
+
if (scope.mode === "standalone") {
|
|
258
|
+
if (!(await isFilesystemAvailable())) {
|
|
259
|
+
throw new FsNotAvailableError({
|
|
260
|
+
message: "Barekey standalone mode requires a local filesystem to read .env files.",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return {
|
|
265
|
+
...scope,
|
|
266
|
+
mode: "standalone",
|
|
267
|
+
localEnvRoot: scope.localEnvRoot ?? safeCurrentWorkingDirectory() ?? "",
|
|
268
|
+
baseUrl: null,
|
|
269
|
+
auth: null,
|
|
270
|
+
requirements: options.requirements,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const auth = await resolveAuth(fetchFn);
|
|
193
275
|
return {
|
|
194
276
|
...scope,
|
|
277
|
+
mode: "centralized",
|
|
278
|
+
localEnvRoot: null,
|
|
195
279
|
baseUrl: auth.baseUrl,
|
|
196
280
|
auth: auth.auth,
|
|
197
281
|
requirements: options.requirements,
|
|
@@ -42,15 +42,36 @@ function safeCurrentWorkingDirectory(): string {
|
|
|
42
42
|
|
|
43
43
|
function normalizeJsonScope(
|
|
44
44
|
value: BarekeyJsonConfig | undefined,
|
|
45
|
-
): {
|
|
45
|
+
): {
|
|
46
|
+
organization: string | null;
|
|
47
|
+
project: string | null;
|
|
48
|
+
environment: string | null;
|
|
49
|
+
typegenMode: string | null;
|
|
50
|
+
runtimeMode: string | null;
|
|
51
|
+
localEnvRoot: string | null;
|
|
52
|
+
} | null {
|
|
46
53
|
if (value === undefined) {
|
|
47
54
|
return null;
|
|
48
55
|
}
|
|
49
56
|
|
|
57
|
+
const config =
|
|
58
|
+
typeof value.config === "object" && value.config !== null
|
|
59
|
+
? (value.config as { typegen?: unknown; mode?: unknown })
|
|
60
|
+
: undefined;
|
|
61
|
+
const runtimeMode = config?.mode === "standalone" ? "standalone" : "centralized";
|
|
62
|
+
|
|
50
63
|
return {
|
|
51
64
|
organization: readConfigString(value.organization ?? value.org),
|
|
52
65
|
project: readConfigString(value.project),
|
|
53
66
|
environment: readConfigString(value.environment ?? value.stage),
|
|
67
|
+
typegenMode:
|
|
68
|
+
runtimeMode === "standalone"
|
|
69
|
+
? "minimal"
|
|
70
|
+
: config?.typegen === "minimal"
|
|
71
|
+
? "minimal"
|
|
72
|
+
: "semantic",
|
|
73
|
+
runtimeMode,
|
|
74
|
+
localEnvRoot: runtimeMode === "standalone" ? safeCurrentWorkingDirectory() : null,
|
|
54
75
|
};
|
|
55
76
|
}
|
|
56
77
|
|
|
@@ -58,9 +79,18 @@ function normalizeScopeKey(
|
|
|
58
79
|
options:
|
|
59
80
|
| BarekeyClientOptions
|
|
60
81
|
| PublicBarekeyClientOptions,
|
|
61
|
-
):
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
):
|
|
83
|
+
| {
|
|
84
|
+
organization: string | null;
|
|
85
|
+
project: string | null;
|
|
86
|
+
environment: string | null;
|
|
87
|
+
typegenMode: string | null;
|
|
88
|
+
runtimeMode: string | null;
|
|
89
|
+
localEnvRoot: string | null;
|
|
90
|
+
}
|
|
91
|
+
| {
|
|
92
|
+
cwd: string;
|
|
93
|
+
} {
|
|
64
94
|
const jsonScope = normalizeJsonScope("json" in options ? options.json : undefined);
|
|
65
95
|
if (jsonScope !== null) {
|
|
66
96
|
return jsonScope;
|
|
@@ -74,6 +104,9 @@ function normalizeScopeKey(
|
|
|
74
104
|
organization,
|
|
75
105
|
project,
|
|
76
106
|
environment,
|
|
107
|
+
typegenMode: "semantic",
|
|
108
|
+
runtimeMode: "centralized",
|
|
109
|
+
localEnvRoot: null,
|
|
77
110
|
};
|
|
78
111
|
}
|
|
79
112
|
|