@arki/env 0.0.9 → 0.2.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/CHANGELOG.md +196 -0
- package/README.md +231 -62
- package/dist/api.json +597 -0
- package/dist/core/define-env.d.ts +29 -4
- package/dist/core/define-env.d.ts.map +1 -1
- package/dist/core/define-env.js +85 -15
- package/dist/core/define-env.js.map +1 -1
- package/dist/core/describe.d.ts +29 -0
- package/dist/core/describe.d.ts.map +1 -0
- package/dist/core/describe.js +25 -0
- package/dist/core/describe.js.map +1 -0
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +13 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +7 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/secret.d.ts +56 -0
- package/dist/core/secret.d.ts.map +1 -0
- package/dist/core/secret.js +85 -0
- package/dist/core/secret.js.map +1 -0
- package/dist/errors.json +128 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/node/codec.d.ts +63 -0
- package/dist/node/codec.d.ts.map +1 -0
- package/dist/node/codec.js +182 -0
- package/dist/node/codec.js.map +1 -0
- package/dist/node/edit.d.ts +112 -0
- package/dist/node/edit.d.ts.map +1 -0
- package/dist/node/edit.js +268 -0
- package/dist/node/edit.js.map +1 -0
- package/dist/node/errors.d.ts +119 -0
- package/dist/node/errors.d.ts.map +1 -0
- package/dist/node/errors.js +144 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/files.d.ts +9 -0
- package/dist/node/files.d.ts.map +1 -0
- package/dist/node/files.js +35 -0
- package/dist/node/files.js.map +1 -0
- package/dist/node/index.d.ts +20 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +13 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/key-schemas.d.ts +25 -0
- package/dist/node/key-schemas.d.ts.map +1 -0
- package/dist/node/key-schemas.js +38 -0
- package/dist/node/key-schemas.js.map +1 -0
- package/dist/node/keys.d.ts +54 -0
- package/dist/node/keys.d.ts.map +1 -0
- package/dist/node/keys.js +76 -0
- package/dist/node/keys.js.map +1 -0
- package/dist/node/load.d.ts +103 -0
- package/dist/node/load.d.ts.map +1 -0
- package/dist/node/load.js +306 -0
- package/dist/node/load.js.map +1 -0
- package/dist/node/operation-telemetry.d.ts +3 -0
- package/dist/node/operation-telemetry.d.ts.map +1 -0
- package/dist/node/operation-telemetry.js +53 -0
- package/dist/node/operation-telemetry.js.map +1 -0
- package/dist/node/references.d.ts +16 -0
- package/dist/node/references.d.ts.map +1 -0
- package/dist/node/references.js +72 -0
- package/dist/node/references.js.map +1 -0
- package/dist/node/register.d.ts +2 -0
- package/dist/node/register.d.ts.map +1 -0
- package/dist/node/register.js +19 -0
- package/dist/node/register.js.map +1 -0
- package/dist/{contracts → presets}/common.d.ts +1 -1
- package/dist/presets/common.d.ts.map +1 -0
- package/dist/{contracts → presets}/common.js +4 -8
- package/dist/presets/common.js.map +1 -0
- package/dist/{contracts → presets}/index.d.ts +5 -5
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +15 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/{contracts → presets}/parsing.d.ts +2 -2
- package/dist/presets/parsing.d.ts.map +1 -0
- package/dist/{contracts → presets}/parsing.js +13 -5
- package/dist/presets/parsing.js.map +1 -0
- package/dist/{contracts → presets}/urls.d.ts +1 -1
- package/dist/presets/urls.d.ts.map +1 -0
- package/dist/{contracts → presets}/urls.js +1 -1
- package/dist/presets/urls.js.map +1 -0
- package/docs/agent-guide.md +121 -0
- package/docs/upgrades/0.0.11-to-0.1.0.md +62 -0
- package/docs/upgrades/0.1.0-to-0.2.0.md +73 -0
- package/docs/upgrades/typed-node-outcomes.md +13 -0
- package/llms.txt +30 -0
- package/package.json +27 -20
- package/src/core/define-env.ts +101 -20
- package/src/core/describe.ts +52 -0
- package/src/core/errors.ts +14 -0
- package/src/core/index.ts +7 -2
- package/src/core/secret.ts +127 -0
- package/src/index.ts +3 -2
- package/src/node/codec.ts +220 -0
- package/src/node/edit.ts +279 -0
- package/src/node/errors.ts +147 -0
- package/src/node/files.ts +41 -0
- package/src/node/index.ts +48 -0
- package/src/node/key-schemas.ts +44 -0
- package/src/node/keys.ts +93 -0
- package/src/node/load.ts +386 -0
- package/src/node/operation-telemetry.ts +56 -0
- package/src/node/references.ts +90 -0
- package/src/node/register.ts +18 -0
- package/src/{contracts → presets}/common.ts +4 -8
- package/src/presets/index.ts +18 -0
- package/src/{contracts → presets}/parsing.ts +12 -5
- package/src/{contracts → presets}/urls.ts +1 -1
- package/dist/contracts/common.d.ts.map +0 -1
- package/dist/contracts/common.js.map +0 -1
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -14
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/parsing.d.ts.map +0 -1
- package/dist/contracts/parsing.js.map +0 -1
- package/dist/contracts/urls.d.ts.map +0 -1
- package/dist/contracts/urls.js.map +0 -1
- package/dist/dot.d.ts +0 -67
- package/dist/dot.d.ts.map +0 -1
- package/dist/dot.js +0 -65
- package/dist/dot.js.map +0 -1
- package/src/contracts/index.ts +0 -17
- package/src/dot.ts +0 -94
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** Secret-manager reads use argv, a bounded subprocess and caller-owned provider authentication. */
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { isFailure } from '@arki/failure';
|
|
6
|
+
import { ensure, parse } from '@arki/schema';
|
|
7
|
+
|
|
8
|
+
import { EnvCancelled, EnvDeadline, ReferenceFailed } from './errors.js';
|
|
9
|
+
import { nodeOperation } from './operation-telemetry.js';
|
|
10
|
+
|
|
11
|
+
/** The remaining aggregate budget and cooperative cancellation for a synchronous provider read. */
|
|
12
|
+
export type ReferenceOptions = { readonly timeoutMs?: number; readonly signal?: AbortSignal };
|
|
13
|
+
/** A provider returns its value or the exact owned provider/cancellation/deadline outcomes. */
|
|
14
|
+
export type ReferenceResolver = (reference: string, options?: ReferenceOptions) => ReturnType<typeof runProvider>;
|
|
15
|
+
|
|
16
|
+
const segment = z.string().regex(/^\w[\w.-]*$/);
|
|
17
|
+
const referencePath = z.array(segment);
|
|
18
|
+
const timeoutSchema = z.number().int().min(1).max(30_000);
|
|
19
|
+
const execFailure = z.object({ code: z.string().optional() });
|
|
20
|
+
|
|
21
|
+
/** The resolvers used unless the caller supplies an explicit registry. */
|
|
22
|
+
export const DEFAULT_RESOLVERS: Readonly<Record<string, ReferenceResolver>> = {
|
|
23
|
+
op: (reference, options) => runProvider('op', ['read', '--no-newline', reference], options),
|
|
24
|
+
infisical: (reference, options) => {
|
|
25
|
+
const parts = pathOf(reference);
|
|
26
|
+
if (isFailure(parts)) return ReferenceFailed({ scheme: 'infisical' }, { cause: parts });
|
|
27
|
+
const [environment, ...rest] = parts;
|
|
28
|
+
const name = rest.pop();
|
|
29
|
+
if (environment === undefined || name === undefined) return ReferenceFailed({ scheme: 'infisical' });
|
|
30
|
+
return runProvider(
|
|
31
|
+
'infisical',
|
|
32
|
+
['secrets', 'get', '--plain', '--silent', `--env=${environment}`, `--path=/${rest.join('/')}`, '--', name],
|
|
33
|
+
options,
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
doppler: (reference, options) => {
|
|
37
|
+
const parts = pathOf(reference);
|
|
38
|
+
if (isFailure(parts)) return ReferenceFailed({ scheme: 'doppler' }, { cause: parts });
|
|
39
|
+
const [project, config, name, ...extra] = parts;
|
|
40
|
+
if (project === undefined || config === undefined || name === undefined || extra.length > 0)
|
|
41
|
+
return ReferenceFailed({ scheme: 'doppler' });
|
|
42
|
+
return runProvider(
|
|
43
|
+
'doppler',
|
|
44
|
+
['secrets', 'get', '--plain', `--project=${project}`, `--config=${config}`, '--', name],
|
|
45
|
+
options,
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Registered schemes are references; unknown URLs remain plain values. */
|
|
51
|
+
export function referenceScheme(
|
|
52
|
+
value: string,
|
|
53
|
+
resolvers: Readonly<Record<string, ReferenceResolver>>,
|
|
54
|
+
): string | undefined {
|
|
55
|
+
const scheme = /^([a-z][a-z0-9+.-]*):\/\/./.exec(value)?.[1];
|
|
56
|
+
return scheme !== undefined && Object.hasOwn(resolvers, scheme) ? scheme : undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function runProvider(command: string, args: readonly string[], options: ReferenceOptions = {}) {
|
|
60
|
+
const timeout = ensure(options.timeoutMs ?? 30_000, timeoutSchema);
|
|
61
|
+
return nodeOperation(`reference.${command}`, () => {
|
|
62
|
+
if (options.signal?.aborted) return EnvCancelled({ cause: options.signal.reason });
|
|
63
|
+
try {
|
|
64
|
+
const value = execFileSync(command, args, {
|
|
65
|
+
encoding: 'utf8',
|
|
66
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
67
|
+
timeout,
|
|
68
|
+
// These are bounded reads: a provider must not evade the deadline by ignoring SIGTERM.
|
|
69
|
+
killSignal: 'SIGKILL',
|
|
70
|
+
}).replace(/\r?\n$/, '');
|
|
71
|
+
return options.signal?.aborted ? EnvCancelled({ cause: options.signal.reason }) : value;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
const detail = execFailure.safeParse(error);
|
|
74
|
+
if (options.signal?.aborted) return EnvCancelled({ cause: error });
|
|
75
|
+
if (detail.success && detail.data.code === 'ETIMEDOUT') return EnvDeadline({ cause: error });
|
|
76
|
+
// CLI stderr may contain a credential. Keep the complete original error only in the private cause.
|
|
77
|
+
return ReferenceFailed({ scheme: command }, { cause: error });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function pathOf(reference: string) {
|
|
83
|
+
return parse(
|
|
84
|
+
referencePath,
|
|
85
|
+
reference
|
|
86
|
+
.slice(reference.indexOf('://') + 3)
|
|
87
|
+
.split('/')
|
|
88
|
+
.filter(part => part !== ''),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effect entry: load the env files into `process.env` as this module is imported. Import it
|
|
3
|
+
* first in a process entry, before any module that reads the environment:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import '@arki/env/node/register';
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* Fails the import with every problem listed (names only, never values).
|
|
10
|
+
*/
|
|
11
|
+
import { isFailure, orThrow } from '@arki/failure';
|
|
12
|
+
|
|
13
|
+
import { EnvFilesFailed } from './errors.js';
|
|
14
|
+
import { formatEnvFilesErrors, loadEnvFiles } from './load.js';
|
|
15
|
+
|
|
16
|
+
const report = loadEnvFiles();
|
|
17
|
+
if (EnvFilesFailed.is(report)) throw new Error(formatEnvFilesErrors(report), { cause: report });
|
|
18
|
+
if (isFailure(report)) orThrow(report);
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const commonPresets = {
|
|
4
4
|
string: (defaultValue?: string) => {
|
|
5
5
|
const schema = z.string();
|
|
6
|
-
return defaultValue ? schema.default(defaultValue)
|
|
6
|
+
return defaultValue === undefined ? schema : schema.default(defaultValue);
|
|
7
7
|
},
|
|
8
8
|
|
|
9
9
|
number: (defaultValue?: number) => {
|
|
10
10
|
const schema = z.coerce.number();
|
|
11
|
-
return defaultValue ? schema.default(defaultValue)
|
|
11
|
+
return defaultValue === undefined ? schema : schema.default(defaultValue);
|
|
12
12
|
},
|
|
13
13
|
|
|
14
14
|
port: (defaultValue = 3000) =>
|
|
15
|
-
z
|
|
16
|
-
.coerce.number()
|
|
17
|
-
.min(1, 'Port must be at least 1')
|
|
18
|
-
.max(65_535, 'Port must be at most 65535')
|
|
19
|
-
.default(defaultValue),
|
|
15
|
+
z.coerce.number().min(1, 'Port must be at least 1').max(65_535, 'Port must be at most 65535').default(defaultValue),
|
|
20
16
|
|
|
21
17
|
nodeEnv: () => z.enum(['development', 'production', 'test']).default('development'),
|
|
22
18
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Ready-made Zod presets for ports, URLs, lists, JSON and other common variable shapes. */
|
|
2
|
+
import { commonPresets } from './common.js';
|
|
3
|
+
import { parsePresets } from './parsing.js';
|
|
4
|
+
import { urlPresets } from './urls.js';
|
|
5
|
+
|
|
6
|
+
// Unified presets export
|
|
7
|
+
export const presets = {
|
|
8
|
+
...commonPresets,
|
|
9
|
+
...urlPresets,
|
|
10
|
+
...parsePresets,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Individual category exports
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export {commonPresets} from './common.js';
|
|
17
|
+
export {urlPresets} from './urls.js';
|
|
18
|
+
export {parsePresets} from './parsing.js';
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const parsePresets = {
|
|
4
4
|
json: <T extends z.ZodType>(schema: T) =>
|
|
5
|
-
z
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
z
|
|
6
|
+
.string()
|
|
7
|
+
.transform((str, context) => {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(str) as unknown;
|
|
10
|
+
} catch {
|
|
11
|
+
context.issues.push({ code: 'custom', message: 'Invalid JSON', input: str });
|
|
12
|
+
return z.NEVER;
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
.pipe(schema),
|
|
9
16
|
|
|
10
17
|
csvArray: <T extends z.ZodType>(itemSchema: T) =>
|
|
11
18
|
z.preprocess(val => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/contracts/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe;IAC1B,MAAM,kBAAkB,MAAM;IAK9B,MAAM,kBAAkB,MAAM;IAK9B,IAAI;IAOJ,OAAO;;;;;IAEP,OAAO;;;;;;IAMP,QAAQ,kBAAiB,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;;;;;;CAE7D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/contracts/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,CAAC,YAAqB,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,CAAC;IAED,MAAM,EAAE,CAAC,YAAqB,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,CAAC;IAED,IAAI,EAAE,CAAC,YAAY,GAAG,IAAI,EAAE,EAAE,CAC5B,CAAC;SACE,MAAM,CAAC,MAAM,EAAE;SACf,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;SACjC,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC;SACzC,OAAO,CAAC,YAAY,CAAC;IAE1B,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAEnF,OAAO,EAAE,CAAC,YAAY,GAAG,KAAK,EAAE,EAAE,CAChC,CAAC;SACE,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;SACjC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;SACxC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC;IAEpD,QAAQ,EAAE,CAAC,YAAY,GAAwC,MAAM,EAAE,EAAE,CACvE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;CACnE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIrB,CAAC;AAKF,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/contracts/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { commonContracts } from './common.js';
|
|
2
|
-
import { parseContracts } from './parsing.js';
|
|
3
|
-
import { urlContracts } from './urls.js';
|
|
4
|
-
// Unified contracts export
|
|
5
|
-
export const contracts = {
|
|
6
|
-
...commonContracts,
|
|
7
|
-
...urlContracts,
|
|
8
|
-
...parseContracts,
|
|
9
|
-
};
|
|
10
|
-
// Individual category exports
|
|
11
|
-
export { commonContracts } from './common.js';
|
|
12
|
-
export { urlContracts } from './urls.js';
|
|
13
|
-
export { parseContracts } from './parsing.js';
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,2BAA2B;AAC3B,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,eAAe;IAClB,GAAG,YAAY;IACf,GAAG,cAAc;CAClB,CAAC;AAEF,8BAA8B;AAG9B,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/contracts/parsing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;IACzB,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,UAAU,CAAC;IAMrC,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,cAAc,CAAC;IAM7C,MAAM,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,cAAc,CAAC;CAK5C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parsing.js","sourceRoot":"","sources":["../../src/contracts/parsing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,CAAsB,MAAS,EAAE,EAAE,CACvC,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEJ,QAAQ,EAAE,CAAsB,UAAa,EAAE,EAAE,CAC/C,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACjB,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC;QACxC,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAEzB,MAAM,EAAE,CAAsB,UAAa,EAAE,EAAE,CAC7C,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACjB,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC;QACxC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;CAC1B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/contracts/urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY;IACvB,GAAG,kBAAkB,MAAM;IAK3B,WAAW;IAQX,QAAQ;CAOT,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/contracts/urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,CAAC,YAAqB,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QACvB,OAAO,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,CAAC;IAED,WAAW,EAAE,GAAG,EAAE,CAChB,CAAC;SACE,GAAG,EAAE;SACL,MAAM,CACL,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,EACvE,2DAA2D,CAC5D;IAEL,QAAQ,EAAE,GAAG,EAAE,CACb,CAAC;SACE,GAAG,EAAE;SACL,MAAM,CACL,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAChE,iDAAiD,CAClD;CACN,CAAC"}
|
package/dist/dot.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOT adapter for `@arki/env`.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `defineEnv()` as a DOT plugin so a DOT app can validate its
|
|
5
|
-
* environment alongside any other services. The plugin is sync (env
|
|
6
|
-
* validation is sync), so the `boot` hook returns the validated env
|
|
7
|
-
* object synchronously through the standard provides channel.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { defineApp } from '@arki/dot';
|
|
12
|
-
* import { env } from '@arki/env/dot';
|
|
13
|
-
* import { z } from 'zod';
|
|
14
|
-
*
|
|
15
|
-
* const app = await defineApp('my-app')
|
|
16
|
-
* .use(env({ schema: { PORT: z.coerce.number().default(3000) } }))
|
|
17
|
-
* .boot();
|
|
18
|
-
*
|
|
19
|
-
* console.log(app.services.env.PORT); // number, typed.
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* To mount a second env scope in the same app, rename the published wire
|
|
23
|
-
* key at the mount site:
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { rename } from '@arki/dot';
|
|
27
|
-
*
|
|
28
|
-
* .use(env({ schema: appSchema }))
|
|
29
|
-
* .use(rename(env({ schema: publicSchema }), { env: 'publicEnv' }, 'public-env'))
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* The `@arki/dot` package is an OPTIONAL peer of `@arki/env`. Importing
|
|
33
|
-
* this adapter without `@arki/dot` installed will fail at module load —
|
|
34
|
-
* that is intentional: the adapter only makes sense in a DOT app.
|
|
35
|
-
*/
|
|
36
|
-
import type { ZodType } from 'zod';
|
|
37
|
-
import type { EmptyShape, Plugin } from '@arki/dot/plugin';
|
|
38
|
-
/**
|
|
39
|
-
* Options for the env DOT adapter.
|
|
40
|
-
*
|
|
41
|
-
* @typeParam TSchema - The shape of the `server` schema record. The
|
|
42
|
-
* resulting `app.services.env` is typed from this.
|
|
43
|
-
*/
|
|
44
|
-
export type EnvDotOptions<TSchema extends Record<string, ZodType>> = {
|
|
45
|
-
/** Zod schemas for each env var the plugin validates. */
|
|
46
|
-
readonly schema: TSchema;
|
|
47
|
-
/**
|
|
48
|
-
* Forwarded to `defineEnv`. If `true`, the validator is skipped
|
|
49
|
-
* entirely. By default, validation is skipped when `CI` is set or
|
|
50
|
-
* `NODE_ENV !== 'development'`.
|
|
51
|
-
*/
|
|
52
|
-
readonly skipValidation?: boolean;
|
|
53
|
-
};
|
|
54
|
-
/** The shape of services published by the env adapter. */
|
|
55
|
-
export type EnvServices<TSchema extends Record<string, ZodType>> = {
|
|
56
|
-
readonly env: {
|
|
57
|
-
readonly [K in keyof TSchema]: TSchema[K] extends ZodType<infer U> ? U : never;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Build a DOT plugin that validates and publishes a typed `env` service.
|
|
62
|
-
*
|
|
63
|
-
* @param options - Schema + optional config.
|
|
64
|
-
* @returns A plugin that publishes `services.env`.
|
|
65
|
-
*/
|
|
66
|
-
export declare function env<TSchema extends Record<string, ZodType>>(options: EnvDotOptions<TSchema>): Plugin<EmptyShape, EnvServices<TSchema>>;
|
|
67
|
-
//# sourceMappingURL=dot.d.ts.map
|
package/dist/dot.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dot.d.ts","sourceRoot":"","sources":["../src/dot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAK3D;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACnE,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,MAAM,WAAW,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACjE,QAAQ,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;KAAE,CAAC;CAClG,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,GAC9B,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAoB1C"}
|
package/dist/dot.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOT adapter for `@arki/env`.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `defineEnv()` as a DOT plugin so a DOT app can validate its
|
|
5
|
-
* environment alongside any other services. The plugin is sync (env
|
|
6
|
-
* validation is sync), so the `boot` hook returns the validated env
|
|
7
|
-
* object synchronously through the standard provides channel.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { defineApp } from '@arki/dot';
|
|
12
|
-
* import { env } from '@arki/env/dot';
|
|
13
|
-
* import { z } from 'zod';
|
|
14
|
-
*
|
|
15
|
-
* const app = await defineApp('my-app')
|
|
16
|
-
* .use(env({ schema: { PORT: z.coerce.number().default(3000) } }))
|
|
17
|
-
* .boot();
|
|
18
|
-
*
|
|
19
|
-
* console.log(app.services.env.PORT); // number, typed.
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* To mount a second env scope in the same app, rename the published wire
|
|
23
|
-
* key at the mount site:
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { rename } from '@arki/dot';
|
|
27
|
-
*
|
|
28
|
-
* .use(env({ schema: appSchema }))
|
|
29
|
-
* .use(rename(env({ schema: publicSchema }), { env: 'publicEnv' }, 'public-env'))
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* The `@arki/dot` package is an OPTIONAL peer of `@arki/env`. Importing
|
|
33
|
-
* this adapter without `@arki/dot` installed will fail at module load —
|
|
34
|
-
* that is intentional: the adapter only makes sense in a DOT app.
|
|
35
|
-
*/
|
|
36
|
-
import { plugin } from '@arki/dot/plugin';
|
|
37
|
-
import { defineEnv } from './core/define-env.js';
|
|
38
|
-
/**
|
|
39
|
-
* Build a DOT plugin that validates and publishes a typed `env` service.
|
|
40
|
-
*
|
|
41
|
-
* @param options - Schema + optional config.
|
|
42
|
-
* @returns A plugin that publishes `services.env`.
|
|
43
|
-
*/
|
|
44
|
-
export function env(options) {
|
|
45
|
-
return plugin({
|
|
46
|
-
name: 'env',
|
|
47
|
-
version: '0.1.0',
|
|
48
|
-
configure(ctx) {
|
|
49
|
-
ctx.registerService('env', 'env');
|
|
50
|
-
},
|
|
51
|
-
boot() {
|
|
52
|
-
const validated = defineEnv({
|
|
53
|
-
server: options.schema,
|
|
54
|
-
options: options.skipValidation === undefined ? undefined : { skipValidation: options.skipValidation },
|
|
55
|
-
});
|
|
56
|
-
// `defineEnv` returns a Proxy from `@t3-oss/env-core`; we narrow it
|
|
57
|
-
// to the schema-derived shape so downstream typing flows through.
|
|
58
|
-
// The runtime guarantee comes from Zod-side validation inside
|
|
59
|
-
// `defineEnv`. No `any` involved — the cast is type-only.
|
|
60
|
-
const envObject = validated;
|
|
61
|
-
return { env: envObject };
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=dot.js.map
|
package/dist/dot.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dot.js","sourceRoot":"","sources":["../src/dot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAwBjD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CACjB,OAA+B;IAE/B,OAAO,MAAM,CAAC;QACZ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,OAAO;QAChB,SAAS,CAAC,GAAG;YACX,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,IAAI;YACF,MAAM,SAAS,GAAG,SAAS,CAAC;gBAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE,OAAO,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE;aACvG,CAAC,CAAC;YACH,oEAAoE;YACpE,kEAAkE;YAClE,8DAA8D;YAC9D,0DAA0D;YAC1D,MAAM,SAAS,GAAG,SAAmD,CAAC;YACtE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/src/contracts/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { commonContracts } from './common.js';
|
|
2
|
-
import { parseContracts } from './parsing.js';
|
|
3
|
-
import { urlContracts } from './urls.js';
|
|
4
|
-
|
|
5
|
-
// Unified contracts export
|
|
6
|
-
export const contracts = {
|
|
7
|
-
...commonContracts,
|
|
8
|
-
...urlContracts,
|
|
9
|
-
...parseContracts,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// Individual category exports
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export {commonContracts} from './common.js';
|
|
16
|
-
export {urlContracts} from './urls.js';
|
|
17
|
-
export {parseContracts} from './parsing.js';
|
package/src/dot.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOT adapter for `@arki/env`.
|
|
3
|
-
*
|
|
4
|
-
* Wraps `defineEnv()` as a DOT plugin so a DOT app can validate its
|
|
5
|
-
* environment alongside any other services. The plugin is sync (env
|
|
6
|
-
* validation is sync), so the `boot` hook returns the validated env
|
|
7
|
-
* object synchronously through the standard provides channel.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { defineApp } from '@arki/dot';
|
|
12
|
-
* import { env } from '@arki/env/dot';
|
|
13
|
-
* import { z } from 'zod';
|
|
14
|
-
*
|
|
15
|
-
* const app = await defineApp('my-app')
|
|
16
|
-
* .use(env({ schema: { PORT: z.coerce.number().default(3000) } }))
|
|
17
|
-
* .boot();
|
|
18
|
-
*
|
|
19
|
-
* console.log(app.services.env.PORT); // number, typed.
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* To mount a second env scope in the same app, rename the published wire
|
|
23
|
-
* key at the mount site:
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { rename } from '@arki/dot';
|
|
27
|
-
*
|
|
28
|
-
* .use(env({ schema: appSchema }))
|
|
29
|
-
* .use(rename(env({ schema: publicSchema }), { env: 'publicEnv' }, 'public-env'))
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* The `@arki/dot` package is an OPTIONAL peer of `@arki/env`. Importing
|
|
33
|
-
* this adapter without `@arki/dot` installed will fail at module load —
|
|
34
|
-
* that is intentional: the adapter only makes sense in a DOT app.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
import type { ZodType } from 'zod';
|
|
38
|
-
|
|
39
|
-
import type { EmptyShape, Plugin } from '@arki/dot/plugin';
|
|
40
|
-
import { plugin } from '@arki/dot/plugin';
|
|
41
|
-
|
|
42
|
-
import { defineEnv } from './core/define-env.js';
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Options for the env DOT adapter.
|
|
46
|
-
*
|
|
47
|
-
* @typeParam TSchema - The shape of the `server` schema record. The
|
|
48
|
-
* resulting `app.services.env` is typed from this.
|
|
49
|
-
*/
|
|
50
|
-
export type EnvDotOptions<TSchema extends Record<string, ZodType>> = {
|
|
51
|
-
/** Zod schemas for each env var the plugin validates. */
|
|
52
|
-
readonly schema: TSchema;
|
|
53
|
-
/**
|
|
54
|
-
* Forwarded to `defineEnv`. If `true`, the validator is skipped
|
|
55
|
-
* entirely. By default, validation is skipped when `CI` is set or
|
|
56
|
-
* `NODE_ENV !== 'development'`.
|
|
57
|
-
*/
|
|
58
|
-
readonly skipValidation?: boolean;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/** The shape of services published by the env adapter. */
|
|
62
|
-
export type EnvServices<TSchema extends Record<string, ZodType>> = {
|
|
63
|
-
readonly env: { readonly [K in keyof TSchema]: TSchema[K] extends ZodType<infer U> ? U : never };
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Build a DOT plugin that validates and publishes a typed `env` service.
|
|
68
|
-
*
|
|
69
|
-
* @param options - Schema + optional config.
|
|
70
|
-
* @returns A plugin that publishes `services.env`.
|
|
71
|
-
*/
|
|
72
|
-
export function env<TSchema extends Record<string, ZodType>>(
|
|
73
|
-
options: EnvDotOptions<TSchema>,
|
|
74
|
-
): Plugin<EmptyShape, EnvServices<TSchema>> {
|
|
75
|
-
return plugin({
|
|
76
|
-
name: 'env',
|
|
77
|
-
version: '0.1.0',
|
|
78
|
-
configure(ctx) {
|
|
79
|
-
ctx.registerService('env', 'env');
|
|
80
|
-
},
|
|
81
|
-
boot() {
|
|
82
|
-
const validated = defineEnv({
|
|
83
|
-
server: options.schema,
|
|
84
|
-
options: options.skipValidation === undefined ? undefined : { skipValidation: options.skipValidation },
|
|
85
|
-
});
|
|
86
|
-
// `defineEnv` returns a Proxy from `@t3-oss/env-core`; we narrow it
|
|
87
|
-
// to the schema-derived shape so downstream typing flows through.
|
|
88
|
-
// The runtime guarantee comes from Zod-side validation inside
|
|
89
|
-
// `defineEnv`. No `any` involved — the cast is type-only.
|
|
90
|
-
const envObject = validated as unknown as EnvServices<TSchema>['env'];
|
|
91
|
-
return { env: envObject };
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
}
|