@wrkspace-co/env 0.1.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/dist/index.js ADDED
@@ -0,0 +1,123 @@
1
+ import {
2
+ DEFAULT_GENERATED_SCHEMA_FILE,
3
+ DEFAULT_MIGRATIONS_DIR,
4
+ DEFAULT_MIGRATION_STATE_FILE,
5
+ DEFAULT_MIGRATION_TARGET_FILES,
6
+ DEFAULT_SCHEMA_FILES,
7
+ EnvValidationError,
8
+ applyPendingMigrations,
9
+ boolean,
10
+ builders,
11
+ createAirlockProgram,
12
+ createEnv,
13
+ createEnvMigrationContext,
14
+ createMigrationFile,
15
+ defineSchema,
16
+ detectDrift,
17
+ discoverMigrations,
18
+ dotenvToObject,
19
+ enumBuilder,
20
+ finalizeFluentDefinitions,
21
+ formatDotenvValue,
22
+ formatValidationIssues,
23
+ generateArtifacts,
24
+ generateTargetEnvFile,
25
+ getMigrationStatus,
26
+ hasKeyInTargetDocuments,
27
+ json,
28
+ loadEnvTargetDocuments,
29
+ loadMigrationState,
30
+ loadOrBuildMigrationSchema,
31
+ loadSchema,
32
+ number,
33
+ parseDotenv,
34
+ plugin_default,
35
+ prefixPolicies,
36
+ register,
37
+ renderExport,
38
+ resolveSchemaPath,
39
+ rollbackMigrations,
40
+ runAuditCommand,
41
+ runCheckCommand,
42
+ runDeprecationsCommand,
43
+ runDiffCommand,
44
+ runDoctorCommand,
45
+ runExportCommand,
46
+ runExternalCommand,
47
+ runGenerateCommand,
48
+ runMigrateCommand,
49
+ runMigrateMakeCommand,
50
+ runMigrateRollbackCommand,
51
+ runMigrateStatusCommand,
52
+ runPullVercelCommand,
53
+ runPushHerokuCommand,
54
+ runReconcileCommand,
55
+ runSchemaBuildCommand,
56
+ saveMigrationState,
57
+ string,
58
+ url,
59
+ writeDotenv,
60
+ writeEnvTargetDocuments
61
+ } from "./chunk-32DQKIYR.js";
62
+ export {
63
+ DEFAULT_GENERATED_SCHEMA_FILE,
64
+ DEFAULT_MIGRATIONS_DIR,
65
+ DEFAULT_MIGRATION_STATE_FILE,
66
+ DEFAULT_MIGRATION_TARGET_FILES,
67
+ DEFAULT_SCHEMA_FILES,
68
+ EnvValidationError,
69
+ applyPendingMigrations,
70
+ boolean,
71
+ builders,
72
+ createAirlockProgram,
73
+ createEnv,
74
+ createEnvMigrationContext,
75
+ createMigrationFile,
76
+ defineSchema,
77
+ detectDrift,
78
+ discoverMigrations,
79
+ dotenvToObject,
80
+ enumBuilder as enum,
81
+ finalizeFluentDefinitions,
82
+ formatDotenvValue,
83
+ formatValidationIssues,
84
+ generateArtifacts,
85
+ generateTargetEnvFile,
86
+ getMigrationStatus,
87
+ hasKeyInTargetDocuments,
88
+ json,
89
+ loadEnvTargetDocuments,
90
+ loadMigrationState,
91
+ loadOrBuildMigrationSchema,
92
+ loadSchema,
93
+ number,
94
+ parseDotenv,
95
+ plugin_default as plugin,
96
+ prefixPolicies,
97
+ register,
98
+ renderExport,
99
+ resolveSchemaPath,
100
+ rollbackMigrations,
101
+ runAuditCommand,
102
+ runCheckCommand,
103
+ runDeprecationsCommand,
104
+ runDiffCommand,
105
+ runDoctorCommand,
106
+ runExportCommand,
107
+ runExternalCommand,
108
+ runGenerateCommand,
109
+ runMigrateCommand,
110
+ runMigrateMakeCommand,
111
+ runMigrateRollbackCommand,
112
+ runMigrateStatusCommand,
113
+ runPullVercelCommand,
114
+ runPushHerokuCommand,
115
+ runReconcileCommand,
116
+ runSchemaBuildCommand,
117
+ saveMigrationState,
118
+ string,
119
+ url,
120
+ writeDotenv,
121
+ writeEnvTargetDocuments
122
+ };
123
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,241 @@
1
+ import { Command } from 'commander';
2
+
3
+ type EnvTarget = "dev" | "preview" | "prod";
4
+ type EnvScope = "server" | "client";
5
+ type EnvKind = "string" | "url" | "number" | "boolean" | "enum" | "json";
6
+ type ValidationSeverity = "error" | "warning";
7
+ interface DeprecatedMetadata {
8
+ replacedBy?: string;
9
+ removeAfter?: string;
10
+ message?: string;
11
+ }
12
+ type ProviderMapping = {
13
+ vercel?: string;
14
+ heroku?: string;
15
+ } & Record<string, string | undefined>;
16
+ interface EnvVariableMetadata {
17
+ description?: string;
18
+ example?: string;
19
+ sensitive?: boolean;
20
+ owner?: string;
21
+ rotationDays?: number;
22
+ deprecated?: DeprecatedMetadata;
23
+ provider?: ProviderMapping;
24
+ tags?: string[];
25
+ }
26
+ interface EnvVariableConfig extends EnvVariableMetadata {
27
+ scope?: EnvScope;
28
+ requiredIn?: readonly EnvTarget[];
29
+ defaultValue?: unknown;
30
+ }
31
+ interface BaseVariableDefinition<TKind extends EnvKind> extends EnvVariableMetadata {
32
+ kind: TKind;
33
+ scope: EnvScope;
34
+ requiredIn: readonly EnvTarget[];
35
+ defaultValue?: unknown;
36
+ }
37
+ interface StringVariableDefinition extends BaseVariableDefinition<"string"> {
38
+ }
39
+ interface UrlVariableDefinition extends BaseVariableDefinition<"url"> {
40
+ }
41
+ interface NumberVariableDefinition extends BaseVariableDefinition<"number"> {
42
+ }
43
+ interface BooleanVariableDefinition extends BaseVariableDefinition<"boolean"> {
44
+ }
45
+ interface EnumVariableDefinition<TValue extends string = string> extends BaseVariableDefinition<"enum"> {
46
+ values: readonly TValue[];
47
+ }
48
+ interface JsonVariableDefinition<TValue = unknown> extends BaseVariableDefinition<"json"> {
49
+ readonly __valueType?: TValue;
50
+ }
51
+ type EnvVariableDefinition = StringVariableDefinition | UrlVariableDefinition | NumberVariableDefinition | BooleanVariableDefinition | EnumVariableDefinition | JsonVariableDefinition;
52
+ type EnvSchema = Record<string, EnvVariableDefinition>;
53
+ declare function string(config?: EnvVariableConfig): StringVariableDefinition;
54
+ declare function url(config?: EnvVariableConfig): UrlVariableDefinition;
55
+ declare function number(config?: EnvVariableConfig): NumberVariableDefinition;
56
+ declare function boolean(config?: EnvVariableConfig): BooleanVariableDefinition;
57
+ declare function enumBuilder<const TValue extends readonly [string, ...string[]]>(values: TValue, config?: EnvVariableConfig): EnumVariableDefinition<TValue[number]>;
58
+
59
+ declare function json<TValue = unknown>(config?: EnvVariableConfig): JsonVariableDefinition<TValue>;
60
+ declare const builders: {
61
+ string: typeof string;
62
+ url: typeof url;
63
+ number: typeof number;
64
+ boolean: typeof boolean;
65
+ enum: typeof enumBuilder;
66
+ json: typeof json;
67
+ };
68
+ declare function defineSchema<TSchema extends EnvSchema>(schema: TSchema): TSchema;
69
+ interface EnvValidationIssue {
70
+ key: string;
71
+ target: EnvTarget;
72
+ scope: EnvScope;
73
+ severity: ValidationSeverity;
74
+ code: string;
75
+ message: string;
76
+ fix?: string;
77
+ }
78
+ interface PrefixPolicyIssue {
79
+ severity: ValidationSeverity;
80
+ code: string;
81
+ message: string;
82
+ fix?: string;
83
+ }
84
+ interface PrefixPolicyContext {
85
+ key: string;
86
+ target: EnvTarget;
87
+ scope: EnvScope;
88
+ hasPublicPrefix: boolean;
89
+ publicPrefixes: readonly string[];
90
+ strict: boolean;
91
+ }
92
+ interface PrefixPolicy {
93
+ name?: string;
94
+ publicPrefixes: readonly string[];
95
+ validate?(context: PrefixPolicyContext): PrefixPolicyIssue[] | void;
96
+ }
97
+ declare const prefixPolicies: {
98
+ nextjs: PrefixPolicy;
99
+ vite: PrefixPolicy;
100
+ };
101
+ interface CreateEnvOptions {
102
+ target: EnvTarget;
103
+ values?: Record<string, string | undefined>;
104
+ strict?: boolean;
105
+ throwOnError?: boolean;
106
+ prefixPolicy?: PrefixPolicy;
107
+ now?: Date;
108
+ onWarning?: (issue: EnvValidationIssue) => void;
109
+ }
110
+ type InferVariableValue<TDefinition extends EnvVariableDefinition> = TDefinition extends StringVariableDefinition ? string : TDefinition extends UrlVariableDefinition ? URL : TDefinition extends NumberVariableDefinition ? number : TDefinition extends BooleanVariableDefinition ? boolean : TDefinition extends EnumVariableDefinition<infer TValue> ? TValue : TDefinition extends JsonVariableDefinition<infer TValue> ? TValue : never;
111
+ type EnvValueMap<TSchema extends EnvSchema> = {
112
+ [TKey in keyof TSchema]: InferVariableValue<TSchema[TKey]> | undefined;
113
+ };
114
+ type PickedEnvValueMap<TSchema extends EnvSchema, TKeys extends readonly (keyof TSchema)[]> = {
115
+ [TKey in TKeys[number]]: InferVariableValue<TSchema[TKey]> | undefined;
116
+ };
117
+ declare function formatValidationIssues(issues: readonly EnvValidationIssue[]): string;
118
+ declare class EnvValidationError extends Error {
119
+ readonly issues: readonly EnvValidationIssue[];
120
+ constructor(issues: readonly EnvValidationIssue[]);
121
+ }
122
+ interface RuntimeEnv<TSchema extends EnvSchema> {
123
+ get<TKey extends keyof TSchema>(key: TKey): InferVariableValue<TSchema[TKey]>;
124
+ optional<TKey extends keyof TSchema>(key: TKey): InferVariableValue<TSchema[TKey]> | undefined;
125
+ assert(): void;
126
+ pick<const TKeys extends readonly (keyof TSchema)[]>(keys: TKeys): PickedEnvValueMap<TSchema, TKeys>;
127
+ all(): EnvValueMap<TSchema>;
128
+ meta<TKey extends keyof TSchema>(key: TKey): TSchema[TKey];
129
+ meta(): TSchema;
130
+ }
131
+ declare function createEnv<TSchema extends EnvSchema>(schema: TSchema, options: CreateEnvOptions): RuntimeEnv<TSchema>;
132
+
133
+ type ProgramLike = Pick<Command, "command">;
134
+ interface GenerateCliOptions {
135
+ writeLocal?: boolean;
136
+ writeTargetFiles?: boolean;
137
+ schema?: string;
138
+ app?: string;
139
+ }
140
+ interface CheckCliOptions {
141
+ target: EnvTarget;
142
+ app?: string;
143
+ allowUnknown?: boolean;
144
+ json?: boolean;
145
+ schema?: string;
146
+ }
147
+ interface DoctorCliOptions {
148
+ schema?: string;
149
+ }
150
+ interface AuditCliOptions {
151
+ schema?: string;
152
+ json?: boolean;
153
+ }
154
+ interface PullVercelCliOptions {
155
+ env: EnvTarget;
156
+ }
157
+ interface DiffVercelCliOptions {
158
+ env: EnvTarget;
159
+ schema?: string;
160
+ json?: boolean;
161
+ allowUnknown?: boolean;
162
+ }
163
+ interface DiffHerokuCliOptions {
164
+ app: string;
165
+ schema?: string;
166
+ json?: boolean;
167
+ allowUnknown?: boolean;
168
+ }
169
+ interface PushHerokuCliOptions {
170
+ app: string;
171
+ target: EnvTarget;
172
+ from: string;
173
+ schema?: string;
174
+ }
175
+ interface ExportCliOptions {
176
+ schema?: string;
177
+ withValues?: boolean;
178
+ from?: string;
179
+ }
180
+ interface DeprecationsCliOptions {
181
+ schema?: string;
182
+ app?: string;
183
+ json?: boolean;
184
+ }
185
+ interface MigrateMakeCliOptions {
186
+ dir?: string;
187
+ }
188
+ interface MigrateCliOptions {
189
+ dir?: string;
190
+ state?: string;
191
+ schemaFile?: string;
192
+ }
193
+ interface MigrateStatusCliOptions {
194
+ dir?: string;
195
+ state?: string;
196
+ schemaFile?: string;
197
+ json?: boolean;
198
+ }
199
+ interface MigrateRollbackCliOptions {
200
+ dir?: string;
201
+ state?: string;
202
+ schemaFile?: string;
203
+ steps: number;
204
+ }
205
+ interface SchemaBuildCliOptions {
206
+ dir?: string;
207
+ state?: string;
208
+ schemaFile?: string;
209
+ force?: boolean;
210
+ }
211
+ interface ReconcileCliOptions {
212
+ schema?: string;
213
+ app?: string;
214
+ writeMigration?: boolean;
215
+ dir?: string;
216
+ }
217
+ declare function handleGenerateCommand(options: GenerateCliOptions): Promise<void>;
218
+ declare function handleCheckCommand(options: CheckCliOptions): Promise<number>;
219
+ declare function handleDeprecationsCommand(options: DeprecationsCliOptions): Promise<number>;
220
+ declare function handleDoctorCommand(options: DoctorCliOptions): Promise<number>;
221
+ declare function handleAuditCommand(options: AuditCliOptions): Promise<number>;
222
+ declare function handlePullVercelCommand(options: PullVercelCliOptions): Promise<number>;
223
+ declare function handleDiffVercelCommand(options: DiffVercelCliOptions): Promise<number>;
224
+ declare function handleDiffHerokuCommand(options: DiffHerokuCliOptions): Promise<number>;
225
+ declare function handlePushHerokuCommand(options: PushHerokuCliOptions): Promise<number>;
226
+ declare function handleExportDockerComposeCommand(options: ExportCliOptions): Promise<number>;
227
+ declare function handleExportK8sCommand(options: ExportCliOptions): Promise<number>;
228
+ declare function handleExportGithubActionsCommand(options: ExportCliOptions): Promise<number>;
229
+ declare function handleMigrateMakeCommand(name: string, options: MigrateMakeCliOptions): Promise<number>;
230
+ declare function handleMigrateCommand(options: MigrateCliOptions): Promise<number>;
231
+ declare function handleMigrateStatusCommand(options: MigrateStatusCliOptions): Promise<number>;
232
+ declare function handleMigrateRollbackCommand(options: MigrateRollbackCliOptions): Promise<number>;
233
+ declare function handleSchemaBuildCommand(options: SchemaBuildCliOptions): Promise<number>;
234
+ declare function handleReconcileCommand(options: ReconcileCliOptions): Promise<number>;
235
+ declare function createAirlockProgram(): Command;
236
+ declare function register(program: ProgramLike): void;
237
+ declare const plugin: {
238
+ register: typeof register;
239
+ };
240
+
241
+ export { type SchemaBuildCliOptions as $, type AuditCliOptions as A, type BooleanVariableDefinition as B, type CreateEnvOptions as C, type DeprecatedMetadata as D, type EnvValidationIssue as E, type CheckCliOptions as F, type DeprecationsCliOptions as G, type DiffHerokuCliOptions as H, type DiffVercelCliOptions as I, type JsonVariableDefinition as J, type DoctorCliOptions as K, type ExportCliOptions as L, type GenerateCliOptions as M, type NumberVariableDefinition as N, type MigrateCliOptions as O, type PrefixPolicy as P, type MigrateMakeCliOptions as Q, type RuntimeEnv as R, type StringVariableDefinition as S, type MigrateRollbackCliOptions as T, type UrlVariableDefinition as U, type ValidationSeverity as V, type MigrateStatusCliOptions as W, type ProgramLike as X, type PullVercelCliOptions as Y, type PushHerokuCliOptions as Z, type ReconcileCliOptions as _, type EnvTarget as a, handleAuditCommand as a0, handleCheckCommand as a1, handleDeprecationsCommand as a2, handleDiffHerokuCommand as a3, handleDiffVercelCommand as a4, handleDoctorCommand as a5, handleExportDockerComposeCommand as a6, handleExportGithubActionsCommand as a7, handleExportK8sCommand as a8, handleGenerateCommand as a9, handleMigrateCommand as aa, handleMigrateMakeCommand as ab, handleMigrateRollbackCommand as ac, handleMigrateStatusCommand as ad, handlePullVercelCommand as ae, handlePushHerokuCommand as af, handleReconcileCommand as ag, handleSchemaBuildCommand as ah, type EnvSchema as b, type EnvScope as c, type EnvVariableDefinition as d, type ProviderMapping as e, type EnumVariableDefinition as f, type EnvKind as g, EnvValidationError as h, type EnvVariableConfig as i, type EnvVariableMetadata as j, type PrefixPolicyContext as k, type PrefixPolicyIssue as l, boolean as m, builders as n, createAirlockProgram as o, createEnv as p, defineSchema as q, enumBuilder as r, formatValidationIssues as s, json as t, number as u, plugin as v, prefixPolicies as w, register as x, string as y, url as z };
@@ -0,0 +1,2 @@
1
+ import 'commander';
2
+ export { A as AuditCliOptions, F as CheckCliOptions, G as DeprecationsCliOptions, H as DiffHerokuCliOptions, I as DiffVercelCliOptions, K as DoctorCliOptions, L as ExportCliOptions, M as GenerateCliOptions, O as MigrateCliOptions, Q as MigrateMakeCliOptions, T as MigrateRollbackCliOptions, W as MigrateStatusCliOptions, X as ProgramLike, Y as PullVercelCliOptions, Z as PushHerokuCliOptions, _ as ReconcileCliOptions, $ as SchemaBuildCliOptions, o as createAirlockProgram, v as default, a0 as handleAuditCommand, a1 as handleCheckCommand, a2 as handleDeprecationsCommand, a3 as handleDiffHerokuCommand, a4 as handleDiffVercelCommand, a5 as handleDoctorCommand, a6 as handleExportDockerComposeCommand, a7 as handleExportGithubActionsCommand, a8 as handleExportK8sCommand, a9 as handleGenerateCommand, aa as handleMigrateCommand, ab as handleMigrateMakeCommand, ac as handleMigrateRollbackCommand, ad as handleMigrateStatusCommand, ae as handlePullVercelCommand, af as handlePushHerokuCommand, ag as handleReconcileCommand, ah as handleSchemaBuildCommand, x as register } from './plugin-Dj0BMNPC.js';
package/dist/plugin.js ADDED
@@ -0,0 +1,47 @@
1
+ import {
2
+ createAirlockProgram,
3
+ handleAuditCommand,
4
+ handleCheckCommand,
5
+ handleDeprecationsCommand,
6
+ handleDiffHerokuCommand,
7
+ handleDiffVercelCommand,
8
+ handleDoctorCommand,
9
+ handleExportDockerComposeCommand,
10
+ handleExportGithubActionsCommand,
11
+ handleExportK8sCommand,
12
+ handleGenerateCommand,
13
+ handleMigrateCommand,
14
+ handleMigrateMakeCommand,
15
+ handleMigrateRollbackCommand,
16
+ handleMigrateStatusCommand,
17
+ handlePullVercelCommand,
18
+ handlePushHerokuCommand,
19
+ handleReconcileCommand,
20
+ handleSchemaBuildCommand,
21
+ plugin_default,
22
+ register
23
+ } from "./chunk-32DQKIYR.js";
24
+ export {
25
+ createAirlockProgram,
26
+ plugin_default as default,
27
+ handleAuditCommand,
28
+ handleCheckCommand,
29
+ handleDeprecationsCommand,
30
+ handleDiffHerokuCommand,
31
+ handleDiffVercelCommand,
32
+ handleDoctorCommand,
33
+ handleExportDockerComposeCommand,
34
+ handleExportGithubActionsCommand,
35
+ handleExportK8sCommand,
36
+ handleGenerateCommand,
37
+ handleMigrateCommand,
38
+ handleMigrateMakeCommand,
39
+ handleMigrateRollbackCommand,
40
+ handleMigrateStatusCommand,
41
+ handlePullVercelCommand,
42
+ handlePushHerokuCommand,
43
+ handleReconcileCommand,
44
+ handleSchemaBuildCommand,
45
+ register
46
+ };
47
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@wrkspace-co/env",
3
+ "version": "0.1.0",
4
+ "description": "Migration-first environment contract system for Node.js.",
5
+ "keywords": [
6
+ "env",
7
+ "environment",
8
+ "dotenv",
9
+ "schema",
10
+ "migrations",
11
+ "validation",
12
+ "typescript",
13
+ "airlock",
14
+ "wrkspace"
15
+ ],
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/wrkspace-co/env.git"
20
+ },
21
+ "homepage": "https://github.com/wrkspace-co/env#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/wrkspace-co/env/issues"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "bin": {
29
+ "airlock": "./dist/cli.js"
30
+ },
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./plugin": {
37
+ "types": "./dist/plugin.d.ts",
38
+ "default": "./dist/plugin.js"
39
+ }
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
44
+ "dependencies": {
45
+ "commander": "^13.1.0",
46
+ "typescript": "^5.7.3"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "test": "vitest run",
51
+ "docs:dev": "vitepress dev docs",
52
+ "docs:build": "vitepress build docs",
53
+ "docs:preview": "vitepress preview docs"
54
+ },
55
+ "wrkspacePlugin": {
56
+ "id": "env",
57
+ "displayName": "Airlock",
58
+ "description": "Airlock-grade environment safety and tooling",
59
+ "command": "env",
60
+ "entry": "./dist/plugin.js"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^22.13.10",
64
+ "tsup": "^8.3.5",
65
+ "vitepress": "^1.5.0",
66
+ "vitest": "^3.0.6"
67
+ }
68
+ }