@barekey/sdk 0.5.0 → 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/handle.d.ts +1 -1
- package/dist/handle.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/public-runtime.d.ts.map +1 -1
- package/dist/internal/public-runtime.js +1 -25
- package/dist/internal/runtime.d.ts +2 -1
- package/dist/internal/runtime.d.ts.map +1 -1
- package/dist/internal/runtime.js +1 -25
- package/dist/internal/typegen.js +5 -5
- package/dist/key-types.typecheck.d.ts +5 -5
- package/dist/key-types.typecheck.d.ts.map +1 -1
- package/dist/types.d.ts +28 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/handle.ts +1 -1
- package/src/internal/config.ts +34 -0
- package/src/internal/public-runtime.ts +2 -38
- package/src/internal/runtime.ts +2 -34
- package/src/internal/typegen.ts +6 -6
- package/src/key-types.typecheck.ts +20 -4
- package/src/types.ts +74 -8
package/README.md
CHANGED
|
@@ -1,27 +1,104 @@
|
|
|
1
1
|
# @barekey/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript SDK for Barekey.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
npm install @barekey/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Entrypoints
|
|
12
|
+
|
|
13
|
+
- `@barekey/sdk/server`: server reads, CLI-session auth, standalone `.env` mode, and typegen
|
|
14
|
+
- `@barekey/sdk/public`: public-variable reads
|
|
15
|
+
- `@barekey/sdk`: root export
|
|
16
|
+
|
|
17
|
+
## Server quickstart
|
|
18
|
+
|
|
19
|
+
Create `barekey.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"organization": "acme",
|
|
24
|
+
"project": "web",
|
|
25
|
+
"environment": "development"
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Log in locally:
|
|
12
30
|
|
|
13
31
|
```bash
|
|
14
|
-
|
|
32
|
+
barekey auth login
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use the SDK:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { BarekeyClient } from "@barekey/sdk/server";
|
|
39
|
+
|
|
40
|
+
const barekey = new BarekeyClient();
|
|
41
|
+
|
|
42
|
+
const databaseUrl = await barekey.get("DATABASE_URL");
|
|
43
|
+
const details = await barekey.get("DATABASE_URL").inspect();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Auth resolution
|
|
47
|
+
|
|
48
|
+
In centralized mode the server client uses:
|
|
49
|
+
|
|
50
|
+
1. `BAREKEY_ACCESS_TOKEN`
|
|
51
|
+
2. a stored CLI session from `barekey auth login`
|
|
52
|
+
|
|
53
|
+
Optional:
|
|
54
|
+
|
|
55
|
+
- `BAREKEY_API_URL` overrides the API base URL
|
|
56
|
+
|
|
57
|
+
## `barekey.json`
|
|
58
|
+
|
|
59
|
+
Supported keys:
|
|
60
|
+
|
|
61
|
+
- `organization` or `org`
|
|
62
|
+
- `project`
|
|
63
|
+
- `environment` or `stage`
|
|
64
|
+
- `config.mode`: `"centralized"` or `"standalone"`
|
|
65
|
+
- `config.typegen`: `"semantic"` or `"minimal"`
|
|
66
|
+
|
|
67
|
+
## Typegen
|
|
68
|
+
|
|
69
|
+
Generate SDK types into the installed package:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
barekey typegen
|
|
15
73
|
```
|
|
16
74
|
|
|
17
|
-
|
|
75
|
+
Watch mode:
|
|
18
76
|
|
|
19
77
|
```bash
|
|
20
|
-
|
|
78
|
+
barekey typegen --watch
|
|
21
79
|
```
|
|
22
80
|
|
|
23
|
-
|
|
81
|
+
`semantic` typegen keeps Barekey metadata in the generated `Env<...>` wrapper, including `Kind`, `Visibility`, and `Rollout`. `minimal` only emits the resolved value type.
|
|
82
|
+
|
|
83
|
+
## Public client
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { PublicBarekeyClient } from "@barekey/sdk/public";
|
|
87
|
+
|
|
88
|
+
const publicBarekey = new PublicBarekeyClient({
|
|
89
|
+
organization: "acme",
|
|
90
|
+
project: "web",
|
|
91
|
+
environment: "production",
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const title = await publicBarekey.get("PUBLIC_TITLE");
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Development
|
|
24
98
|
|
|
25
99
|
```bash
|
|
100
|
+
bun install
|
|
101
|
+
bun run build
|
|
102
|
+
bun run typecheck
|
|
26
103
|
bun test
|
|
27
104
|
```
|
package/dist/handle.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BarekeyCoerceTarget, BarekeyEvaluatedValue, BarekeyResolvedRecord, BarekeyResolvedRecords } from "./types.js";
|
|
2
2
|
type BarekeyCoercibleEnvMarker = {
|
|
3
3
|
readonly __barekey?: {
|
|
4
|
-
readonly
|
|
4
|
+
readonly kind: "ab_roll" | "rollout";
|
|
5
5
|
};
|
|
6
6
|
};
|
|
7
7
|
export declare class BarekeyEnvHandle<TValue = unknown> implements PromiseLike<TValue> {
|
package/dist/handle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAEpB,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.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,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,GACxE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAI7B,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;CAG3D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BarekeyMode, BarekeyTypegenMode } from "../types.js";
|
|
2
|
+
export declare function readConfigString(value: unknown): string | undefined;
|
|
3
|
+
export declare function normalizeTypegenMode(value: unknown, source: string): BarekeyTypegenMode;
|
|
4
|
+
export declare function normalizeMode(value: unknown, source: string): BarekeyMode;
|
|
5
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAYvF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAYzE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InvalidConfigurationProvidedError } from "../errors.js";
|
|
2
|
+
export function readConfigString(value) {
|
|
3
|
+
return typeof value === "string" ? value.trim() : undefined;
|
|
4
|
+
}
|
|
5
|
+
export function normalizeTypegenMode(value, source) {
|
|
6
|
+
if (value === undefined) {
|
|
7
|
+
return "semantic";
|
|
8
|
+
}
|
|
9
|
+
if (value === "semantic" || value === "minimal") {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
throw new InvalidConfigurationProvidedError({
|
|
13
|
+
message: `${source} must provide config.typegen as "semantic" or "minimal" when set.`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function normalizeMode(value, source) {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
return "centralized";
|
|
19
|
+
}
|
|
20
|
+
if (value === "centralized" || value === "standalone") {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
throw new InvalidConfigurationProvidedError({
|
|
24
|
+
message: `${source} must provide config.mode as "centralized" or "standalone" when set.`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-runtime.d.ts","sourceRoot":"","sources":["../../src/internal/public-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"public-runtime.d.ts","sourceRoot":"","sources":["../../src/internal/public-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAqB,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAO9E,KAAK,oBAAoB,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACxC,CAAC;AAyHF,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC,CAOtC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { FsNotAvailableError, InvalidConfigurationProvidedError, NoConfigurationProvidedError, } from "../errors.js";
|
|
2
|
+
import { normalizeMode, normalizeTypegenMode, readConfigString } from "./config.js";
|
|
2
3
|
import { normalizeBaseUrl } from "./http.js";
|
|
3
4
|
import { isFilesystemAvailable, loadBarekeyJsonConfig } from "./node-runtime.js";
|
|
4
5
|
const DEFAULT_BAREKEY_API_URL = "https://api.barekey.dev";
|
|
5
|
-
function readConfigString(value) {
|
|
6
|
-
return typeof value === "string" ? value.trim() : undefined;
|
|
7
|
-
}
|
|
8
6
|
function normalizeScope(input) {
|
|
9
7
|
const organization = readConfigString(input.organization) ?? "";
|
|
10
8
|
const project = readConfigString(input.project) ?? "";
|
|
@@ -20,28 +18,6 @@ function normalizeScope(input) {
|
|
|
20
18
|
environment,
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
function normalizeTypegenMode(value, source) {
|
|
24
|
-
if (value === undefined) {
|
|
25
|
-
return "semantic";
|
|
26
|
-
}
|
|
27
|
-
if (value === "semantic" || value === "minimal") {
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
throw new InvalidConfigurationProvidedError({
|
|
31
|
-
message: `${source} must provide config.typegen as "semantic" or "minimal" when set.`,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function normalizeMode(value, source) {
|
|
35
|
-
if (value === undefined) {
|
|
36
|
-
return "centralized";
|
|
37
|
-
}
|
|
38
|
-
if (value === "centralized" || value === "standalone") {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
throw new InvalidConfigurationProvidedError({
|
|
42
|
-
message: `${source} must provide config.mode as "centralized" or "standalone" when set.`,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
21
|
function createStandaloneUnsupportedError(source) {
|
|
46
22
|
return new InvalidConfigurationProvidedError({
|
|
47
23
|
message: [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { BarekeyClientOptions,
|
|
1
|
+
import type { BarekeyClientOptions, BarekeyStandardSchemaV1 } from "../types.js";
|
|
2
|
+
import type { BarekeyMode, BarekeyTypegenMode } from "../types.js";
|
|
2
3
|
import { type InternalAuthResolver } from "./http.js";
|
|
3
4
|
type BarekeyResolvedScope = {
|
|
4
5
|
organization: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/internal/runtime.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,oBAAoB,EAEpB,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/internal/runtime.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,oBAAoB,EAEpB,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,KAAK,oBAAoB,EAAoB,MAAM,WAAW,CAAC;AASxE,KAAK,oBAAoB,GAAG;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,kBAAkB,CAAC;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,KAAK,gCAAgC,GAAG,oBAAoB,GAAG;IAC7D,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EAAE,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACxC,CAAC;AAEF,KAAK,+BAA+B,GAAG,oBAAoB,GAAG;IAC5D,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,gCAAgC,GAChC,+BAA+B,CAAC;AAuMpC,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,OAAO,UAAU,CAAC,KAAK,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CA4BhC"}
|
package/dist/internal/runtime.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FsNotAvailableError, InvalidConfigurationProvidedError, InvalidCredentialsProvidedError, InvalidRefreshTokenError, NoConfigurationProvidedError, NoCredentialsProvidedError, UnauthorizedError, } from "../errors.js";
|
|
2
|
+
import { normalizeMode, normalizeTypegenMode, readConfigString } from "./config.js";
|
|
2
3
|
import { normalizeBaseUrl } from "./http.js";
|
|
3
4
|
import { isFilesystemAvailable, loadBarekeyJsonConfig, loadCliSessionAuthResolver, } from "./node-runtime.js";
|
|
4
5
|
const DEFAULT_BAREKEY_API_URL = "https://api.barekey.dev";
|
|
@@ -9,37 +10,12 @@ function readProcessEnv(key) {
|
|
|
9
10
|
const value = process.env[key];
|
|
10
11
|
return typeof value === "string" ? value : undefined;
|
|
11
12
|
}
|
|
12
|
-
function readConfigString(value) {
|
|
13
|
-
return typeof value === "string" ? value.trim() : undefined;
|
|
14
|
-
}
|
|
15
13
|
function safeCurrentWorkingDirectory() {
|
|
16
14
|
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
17
15
|
return null;
|
|
18
16
|
}
|
|
19
17
|
return process.cwd();
|
|
20
18
|
}
|
|
21
|
-
function normalizeTypegenMode(value, source) {
|
|
22
|
-
if (value === undefined) {
|
|
23
|
-
return "semantic";
|
|
24
|
-
}
|
|
25
|
-
if (value === "semantic" || value === "minimal") {
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
throw new InvalidConfigurationProvidedError({
|
|
29
|
-
message: `${source} must provide config.typegen as "semantic" or "minimal" when set.`,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function normalizeMode(value, source) {
|
|
33
|
-
if (value === undefined) {
|
|
34
|
-
return "centralized";
|
|
35
|
-
}
|
|
36
|
-
if (value === "centralized" || value === "standalone") {
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
throw new InvalidConfigurationProvidedError({
|
|
40
|
-
message: `${source} must provide config.mode as "centralized" or "standalone" when set.`,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
19
|
function normalizeScope(input) {
|
|
44
20
|
const mode = input.mode ?? "centralized";
|
|
45
21
|
const organization = readConfigString(input.organization) ?? "";
|
package/dist/internal/typegen.js
CHANGED
|
@@ -23,15 +23,15 @@ function renderVariableType(row, mode) {
|
|
|
23
23
|
if (mode === "minimal") {
|
|
24
24
|
return row.typeScriptType;
|
|
25
25
|
}
|
|
26
|
-
const renderEnvDescriptor = (input) => `{
|
|
26
|
+
const renderEnvDescriptor = (input) => `{ Type: ${row.typeScriptType}; Kind: ${JSON.stringify(input.kind)}; Visibility: ${JSON.stringify(row.visibility)}; Rollout: ${input.rollout} }`;
|
|
27
27
|
if (row.kind === "secret") {
|
|
28
|
-
return `Env<${renderEnvDescriptor({
|
|
28
|
+
return `Env<${renderEnvDescriptor({ kind: "secret", rollout: "never" })}>`;
|
|
29
29
|
}
|
|
30
30
|
if (row.kind === "ab_roll") {
|
|
31
|
-
return `Env<${renderEnvDescriptor({
|
|
31
|
+
return `Env<${renderEnvDescriptor({ kind: "ab_roll", rollout: "never" })}>`;
|
|
32
32
|
}
|
|
33
33
|
return `Env<${renderEnvDescriptor({
|
|
34
|
-
|
|
34
|
+
kind: "rollout",
|
|
35
35
|
rollout: renderRolloutMetadataType(row),
|
|
36
36
|
})}>`;
|
|
37
37
|
}
|
|
@@ -43,7 +43,7 @@ function buildGeneratedTypesContents(manifest, input) {
|
|
|
43
43
|
.map((row) => ` ${JSON.stringify(row.name)}: ${renderVariableType(row, input.mode)};`)
|
|
44
44
|
.join("\n");
|
|
45
45
|
const importLine = input.mode === "semantic"
|
|
46
|
-
? `import type {
|
|
46
|
+
? `import type { EaseInOut, Env, Linear, Step } from "${input.typeModulePath}";\n\n`
|
|
47
47
|
: "";
|
|
48
48
|
return `/* eslint-disable */
|
|
49
49
|
/* This file is generated by barekey typegen. */
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { Env
|
|
1
|
+
import type { Env } from "./types.js";
|
|
2
2
|
declare module "./types.js" {
|
|
3
3
|
interface BarekeyGeneratedTypeMap {
|
|
4
4
|
PRIVATE_TOKEN: Env<{
|
|
5
|
-
|
|
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
|
-
|
|
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,
|
|
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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type BarekeyTemporalInstantLike = {
|
|
|
14
14
|
export type BarekeyTtlInput = number | Date | BarekeyTemporalInstantLike;
|
|
15
15
|
export type Secret = "secret";
|
|
16
16
|
export type AB = "ab";
|
|
17
|
+
type BarekeyLegacyEnvMode = Secret | AB;
|
|
17
18
|
export type Linear<TMilestones extends ReadonlyArray<readonly [string, number]> = ReadonlyArray<readonly [string, number]>> = {
|
|
18
19
|
readonly kind: "linear";
|
|
19
20
|
readonly milestones: TMilestones;
|
|
@@ -26,21 +27,43 @@ export type EaseInOut<TMilestones extends ReadonlyArray<readonly [string, number
|
|
|
26
27
|
readonly kind: "ease_in_out";
|
|
27
28
|
readonly milestones: TMilestones;
|
|
28
29
|
};
|
|
29
|
-
|
|
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> = {
|
|
30
38
|
Mode: TMode;
|
|
31
39
|
Visibility: TVisibility;
|
|
32
40
|
Rollout: TRollout;
|
|
33
41
|
Type: TType;
|
|
34
42
|
};
|
|
35
|
-
type BarekeyAnyEnvDescriptor =
|
|
36
|
-
type
|
|
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> = {
|
|
37
60
|
readonly __barekey?: {
|
|
38
|
-
readonly
|
|
61
|
+
readonly kind: TKind;
|
|
39
62
|
readonly visibility: TVisibility;
|
|
40
63
|
readonly rollout: TRollout;
|
|
41
64
|
};
|
|
42
65
|
};
|
|
43
|
-
export type Env<TDescriptorOrMode, TValue = never, TRollout = never, TVisibility = never> = [TValue] extends [never] ? TDescriptorOrMode extends BarekeyAnyEnvDescriptor ? TDescriptorOrMode
|
|
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>;
|
|
44
67
|
export type BarekeyCoerceTarget = "string" | "boolean" | "int64" | "float" | "date" | "json";
|
|
45
68
|
export interface BarekeyGeneratedTypeMap {
|
|
46
69
|
}
|
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,kBAAkB,GAAG,UAAU,GAAG,SAAS,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,YAAY,CAAC;AAEvD,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;A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AC1B,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;AAEP,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,2BAA2B,GAC3B,gCAAgC,GAChC,yBAAyB,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/handle.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -4,12 +4,8 @@ import {
|
|
|
4
4
|
NoConfigurationProvidedError,
|
|
5
5
|
} from "../errors.js";
|
|
6
6
|
import type { PublicBarekeyClientOptions } from "../public-types.js";
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
BarekeyMode,
|
|
10
|
-
BarekeyStandardSchemaV1,
|
|
11
|
-
BarekeyTypegenMode,
|
|
12
|
-
} from "../types.js";
|
|
7
|
+
import type { BarekeyJsonConfig, BarekeyStandardSchemaV1 } from "../types.js";
|
|
8
|
+
import { normalizeMode, normalizeTypegenMode, readConfigString } from "./config.js";
|
|
13
9
|
import { normalizeBaseUrl } from "./http.js";
|
|
14
10
|
import { isFilesystemAvailable, loadBarekeyJsonConfig } from "./node-runtime.js";
|
|
15
11
|
|
|
@@ -26,10 +22,6 @@ export type BarekeyPublicRuntimeContext = BarekeyResolvedScope & {
|
|
|
26
22
|
requirements?: BarekeyStandardSchemaV1;
|
|
27
23
|
};
|
|
28
24
|
|
|
29
|
-
function readConfigString(value: unknown): string | undefined {
|
|
30
|
-
return typeof value === "string" ? value.trim() : undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
25
|
function normalizeScope(input: {
|
|
34
26
|
organization?: unknown;
|
|
35
27
|
project?: unknown;
|
|
@@ -52,34 +44,6 @@ function normalizeScope(input: {
|
|
|
52
44
|
};
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
function normalizeTypegenMode(value: unknown, source: string): BarekeyTypegenMode {
|
|
56
|
-
if (value === undefined) {
|
|
57
|
-
return "semantic";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (value === "semantic" || value === "minimal") {
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
throw new InvalidConfigurationProvidedError({
|
|
65
|
-
message: `${source} must provide config.typegen as "semantic" or "minimal" when set.`,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function normalizeMode(value: unknown, source: string): BarekeyMode {
|
|
70
|
-
if (value === undefined) {
|
|
71
|
-
return "centralized";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (value === "centralized" || value === "standalone") {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
throw new InvalidConfigurationProvidedError({
|
|
79
|
-
message: `${source} must provide config.mode as "centralized" or "standalone" when set.`,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
47
|
function createStandaloneUnsupportedError(source: string): Error {
|
|
84
48
|
return new InvalidConfigurationProvidedError({
|
|
85
49
|
message: [
|
package/src/internal/runtime.ts
CHANGED
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
import type {
|
|
11
11
|
BarekeyClientOptions,
|
|
12
12
|
BarekeyJsonConfig,
|
|
13
|
-
BarekeyMode,
|
|
14
13
|
BarekeyStandardSchemaV1,
|
|
15
|
-
BarekeyTypegenMode,
|
|
16
14
|
} from "../types.js";
|
|
15
|
+
import type { BarekeyMode, BarekeyTypegenMode } from "../types.js";
|
|
16
|
+
import { normalizeMode, normalizeTypegenMode, readConfigString } from "./config.js";
|
|
17
17
|
import { type InternalAuthResolver, normalizeBaseUrl } from "./http.js";
|
|
18
18
|
import {
|
|
19
19
|
isFilesystemAvailable,
|
|
@@ -61,10 +61,6 @@ function readProcessEnv(key: string): string | undefined {
|
|
|
61
61
|
return typeof value === "string" ? value : undefined;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function readConfigString(value: unknown): string | undefined {
|
|
65
|
-
return typeof value === "string" ? value.trim() : undefined;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
64
|
function safeCurrentWorkingDirectory(): string | null {
|
|
69
65
|
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
70
66
|
return null;
|
|
@@ -73,34 +69,6 @@ function safeCurrentWorkingDirectory(): string | null {
|
|
|
73
69
|
return process.cwd();
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
function normalizeTypegenMode(value: unknown, source: string): BarekeyTypegenMode {
|
|
77
|
-
if (value === undefined) {
|
|
78
|
-
return "semantic";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (value === "semantic" || value === "minimal") {
|
|
82
|
-
return value;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
throw new InvalidConfigurationProvidedError({
|
|
86
|
-
message: `${source} must provide config.typegen as "semantic" or "minimal" when set.`,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function normalizeMode(value: unknown, source: string): BarekeyMode {
|
|
91
|
-
if (value === undefined) {
|
|
92
|
-
return "centralized";
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (value === "centralized" || value === "standalone") {
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
throw new InvalidConfigurationProvidedError({
|
|
100
|
-
message: `${source} must provide config.mode as "centralized" or "standalone" when set.`,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
72
|
function normalizeScope(input: {
|
|
105
73
|
organization?: unknown;
|
|
106
74
|
project?: unknown;
|
package/src/internal/typegen.ts
CHANGED
|
@@ -93,21 +93,21 @@ function renderVariableType(
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const renderEnvDescriptor = (input: {
|
|
96
|
-
|
|
96
|
+
kind: TypegenManifestVariable["kind"];
|
|
97
97
|
rollout: string;
|
|
98
98
|
}): string =>
|
|
99
|
-
`{
|
|
99
|
+
`{ Type: ${row.typeScriptType}; Kind: ${JSON.stringify(input.kind)}; Visibility: ${JSON.stringify(row.visibility)}; Rollout: ${input.rollout} }`;
|
|
100
100
|
|
|
101
101
|
if (row.kind === "secret") {
|
|
102
|
-
return `Env<${renderEnvDescriptor({
|
|
102
|
+
return `Env<${renderEnvDescriptor({ kind: "secret", rollout: "never" })}>`;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (row.kind === "ab_roll") {
|
|
106
|
-
return `Env<${renderEnvDescriptor({
|
|
106
|
+
return `Env<${renderEnvDescriptor({ kind: "ab_roll", rollout: "never" })}>`;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
return `Env<${renderEnvDescriptor({
|
|
110
|
-
|
|
110
|
+
kind: "rollout",
|
|
111
111
|
rollout: renderRolloutMetadataType(row),
|
|
112
112
|
})}>`;
|
|
113
113
|
}
|
|
@@ -131,7 +131,7 @@ function buildGeneratedTypesContents(
|
|
|
131
131
|
|
|
132
132
|
const importLine =
|
|
133
133
|
input.mode === "semantic"
|
|
134
|
-
? `import type {
|
|
134
|
+
? `import type { EaseInOut, Env, Linear, Step } from "${input.typeModulePath}";\n\n`
|
|
135
135
|
: "";
|
|
136
136
|
|
|
137
137
|
return `/* eslint-disable */
|
|
@@ -17,10 +17,10 @@ import type {
|
|
|
17
17
|
declare module "./types.js" {
|
|
18
18
|
interface BarekeyGeneratedTypeMap {
|
|
19
19
|
PRIVATE_TOKEN: Env<{
|
|
20
|
-
|
|
20
|
+
Type: string;
|
|
21
|
+
Kind: "secret";
|
|
21
22
|
Visibility: "private";
|
|
22
23
|
Rollout: never;
|
|
23
|
-
Type: string;
|
|
24
24
|
}>;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -28,10 +28,10 @@ declare module "./types.js" {
|
|
|
28
28
|
declare module "./public-types.js" {
|
|
29
29
|
interface BarekeyPublicGeneratedTypeMap {
|
|
30
30
|
PUBLIC_THEME: Env<{
|
|
31
|
-
|
|
31
|
+
Type: "light" | "dark";
|
|
32
|
+
Kind: "secret";
|
|
32
33
|
Visibility: "public";
|
|
33
34
|
Rollout: never;
|
|
34
|
-
Type: "light" | "dark";
|
|
35
35
|
}>;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -69,6 +69,22 @@ type _barekeyKeyAllowsStrings = Assert<
|
|
|
69
69
|
type _barekeyPublicKeyAllowsStrings = Assert<
|
|
70
70
|
IsEqual<BarekeyPublicKey, BarekeyPublicKnownKey | BarekeyLiteralString>
|
|
71
71
|
>;
|
|
72
|
+
type _legacyModeDescriptorStillWorks = Assert<
|
|
73
|
+
IsEqual<
|
|
74
|
+
Env<{
|
|
75
|
+
Mode: Secret;
|
|
76
|
+
Visibility: "public";
|
|
77
|
+
Rollout: never;
|
|
78
|
+
Type: string;
|
|
79
|
+
}>,
|
|
80
|
+
Env<{
|
|
81
|
+
Type: string;
|
|
82
|
+
Kind: "secret";
|
|
83
|
+
Visibility: "public";
|
|
84
|
+
Rollout: never;
|
|
85
|
+
}>
|
|
86
|
+
>
|
|
87
|
+
>;
|
|
72
88
|
type _privateKnownHandleKeepsGeneratedValue = Assert<
|
|
73
89
|
IsEqual<UnwrapHandle<typeof privateKnownHandle>, BarekeyGeneratedTypeMap["PRIVATE_TOKEN"]>
|
|
74
90
|
>;
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,8 @@ export type Secret = "secret";
|
|
|
22
22
|
|
|
23
23
|
export type AB = "ab";
|
|
24
24
|
|
|
25
|
+
type BarekeyLegacyEnvMode = Secret | AB;
|
|
26
|
+
|
|
25
27
|
export type Linear<
|
|
26
28
|
TMilestones extends ReadonlyArray<readonly [string, number]> = ReadonlyArray<
|
|
27
29
|
readonly [string, number]
|
|
@@ -49,7 +51,28 @@ export type EaseInOut<
|
|
|
49
51
|
readonly milestones: TMilestones;
|
|
50
52
|
};
|
|
51
53
|
|
|
54
|
+
type BarekeySemanticEnvDescriptor<
|
|
55
|
+
TKind = never,
|
|
56
|
+
TVisibility = never,
|
|
57
|
+
TRollout = never,
|
|
58
|
+
TType = unknown,
|
|
59
|
+
> = {
|
|
60
|
+
Kind: TKind;
|
|
61
|
+
Visibility: TVisibility;
|
|
62
|
+
Rollout: TRollout;
|
|
63
|
+
Type: TType;
|
|
64
|
+
};
|
|
65
|
+
|
|
52
66
|
export type BarekeyEnvDescriptor<
|
|
67
|
+
TKindOrMode = never,
|
|
68
|
+
TVisibility = never,
|
|
69
|
+
TRollout = never,
|
|
70
|
+
TType = unknown,
|
|
71
|
+
> = TKindOrMode extends BarekeyLegacyEnvMode
|
|
72
|
+
? BarekeyLegacyEnvDescriptor<TKindOrMode, TVisibility, TRollout, TType>
|
|
73
|
+
: BarekeySemanticEnvDescriptor<TKindOrMode, TVisibility, TRollout, TType>;
|
|
74
|
+
|
|
75
|
+
export type BarekeyLegacyEnvDescriptor<
|
|
53
76
|
TMode = never,
|
|
54
77
|
TVisibility = never,
|
|
55
78
|
TRollout = never,
|
|
@@ -61,11 +84,47 @@ export type BarekeyEnvDescriptor<
|
|
|
61
84
|
Type: TType;
|
|
62
85
|
};
|
|
63
86
|
|
|
64
|
-
type BarekeyAnyEnvDescriptor =
|
|
87
|
+
type BarekeyAnyEnvDescriptor =
|
|
88
|
+
| BarekeySemanticEnvDescriptor<unknown, unknown, unknown, unknown>
|
|
89
|
+
| BarekeyLegacyEnvDescriptor<unknown, unknown, unknown, unknown>;
|
|
90
|
+
|
|
91
|
+
type BarekeyKindFromLegacyMode<TMode> = TMode extends Secret
|
|
92
|
+
? "secret"
|
|
93
|
+
: TMode extends AB
|
|
94
|
+
? "ab_roll" | "rollout"
|
|
95
|
+
: never;
|
|
96
|
+
|
|
97
|
+
type BarekeyDescriptorKind<TDescriptor> = TDescriptor extends {
|
|
98
|
+
Kind: infer TKind;
|
|
99
|
+
}
|
|
100
|
+
? TKind
|
|
101
|
+
: TDescriptor extends {
|
|
102
|
+
Mode: infer TMode;
|
|
103
|
+
}
|
|
104
|
+
? BarekeyKindFromLegacyMode<TMode>
|
|
105
|
+
: never;
|
|
65
106
|
|
|
66
|
-
type
|
|
107
|
+
type BarekeyDescriptorVisibility<TDescriptor> = TDescriptor extends {
|
|
108
|
+
Visibility: infer TVisibility;
|
|
109
|
+
}
|
|
110
|
+
? TVisibility
|
|
111
|
+
: never;
|
|
112
|
+
|
|
113
|
+
type BarekeyDescriptorRollout<TDescriptor> = TDescriptor extends {
|
|
114
|
+
Rollout: infer TRollout;
|
|
115
|
+
}
|
|
116
|
+
? TRollout
|
|
117
|
+
: never;
|
|
118
|
+
|
|
119
|
+
type BarekeyDescriptorValue<TDescriptor> = TDescriptor extends {
|
|
120
|
+
Type: infer TValue;
|
|
121
|
+
}
|
|
122
|
+
? TValue
|
|
123
|
+
: never;
|
|
124
|
+
|
|
125
|
+
type BarekeyEnvMarker<TKind, TVisibility, TRollout> = {
|
|
67
126
|
readonly __barekey?: {
|
|
68
|
-
readonly
|
|
127
|
+
readonly kind: TKind;
|
|
69
128
|
readonly visibility: TVisibility;
|
|
70
129
|
readonly rollout: TRollout;
|
|
71
130
|
};
|
|
@@ -78,14 +137,21 @@ export type Env<
|
|
|
78
137
|
TVisibility = never,
|
|
79
138
|
> = [TValue] extends [never]
|
|
80
139
|
? TDescriptorOrMode extends BarekeyAnyEnvDescriptor
|
|
81
|
-
? TDescriptorOrMode
|
|
140
|
+
? BarekeyDescriptorValue<TDescriptorOrMode> &
|
|
82
141
|
BarekeyEnvMarker<
|
|
83
|
-
TDescriptorOrMode
|
|
84
|
-
TDescriptorOrMode
|
|
85
|
-
TDescriptorOrMode
|
|
142
|
+
BarekeyDescriptorKind<TDescriptorOrMode>,
|
|
143
|
+
BarekeyDescriptorVisibility<TDescriptorOrMode>,
|
|
144
|
+
BarekeyDescriptorRollout<TDescriptorOrMode>
|
|
86
145
|
>
|
|
87
146
|
: never
|
|
88
|
-
: TValue &
|
|
147
|
+
: TValue &
|
|
148
|
+
BarekeyEnvMarker<
|
|
149
|
+
TDescriptorOrMode extends BarekeyLegacyEnvMode
|
|
150
|
+
? BarekeyKindFromLegacyMode<TDescriptorOrMode>
|
|
151
|
+
: TDescriptorOrMode,
|
|
152
|
+
TVisibility,
|
|
153
|
+
TRollout
|
|
154
|
+
>;
|
|
89
155
|
|
|
90
156
|
export type BarekeyCoerceTarget = "string" | "boolean" | "int64" | "float" | "date" | "json";
|
|
91
157
|
|