@geekmidas/envkit 1.0.4 → 1.0.5
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 +6 -0
- package/dist/{EnvironmentBuilder-BSuHZm0y.mjs → EnvironmentBuilder-CFen3oIg.mjs} +1 -1
- package/dist/{EnvironmentBuilder-BSuHZm0y.mjs.map → EnvironmentBuilder-CFen3oIg.mjs.map} +1 -1
- package/dist/{EnvironmentBuilder-Xuf2Dd9u.d.cts → EnvironmentBuilder-CNgcdzSR.d.cts} +1 -1
- package/dist/{EnvironmentBuilder-Xuf2Dd9u.d.cts.map → EnvironmentBuilder-CNgcdzSR.d.cts.map} +1 -1
- package/dist/{EnvironmentBuilder-Djr1VsWM.cjs → EnvironmentBuilder-DDgLJAAo.cjs} +1 -1
- package/dist/{EnvironmentBuilder-Djr1VsWM.cjs.map → EnvironmentBuilder-DDgLJAAo.cjs.map} +1 -1
- package/dist/{EnvironmentBuilder-jF-b7WQg.d.mts → EnvironmentBuilder-DHfDXJUm.d.mts} +1 -1
- package/dist/{EnvironmentBuilder-jF-b7WQg.d.mts.map → EnvironmentBuilder-DHfDXJUm.d.mts.map} +1 -1
- package/dist/{EnvironmentParser-DtOL86NU.d.cts → EnvironmentParser-BY1oCUsc.d.mts} +3 -3
- package/dist/EnvironmentParser-BY1oCUsc.d.mts.map +1 -0
- package/dist/{EnvironmentParser-DJdW7vOL.cjs → EnvironmentParser-Bzg5yXG2.cjs} +124 -4
- package/dist/EnvironmentParser-Bzg5yXG2.cjs.map +1 -0
- package/dist/{EnvironmentParser-CkLfmn4Y.d.mts → EnvironmentParser-DoooZm8n.d.cts} +3 -3
- package/dist/EnvironmentParser-DoooZm8n.d.cts.map +1 -0
- package/dist/{EnvironmentParser-zMblItla.mjs → EnvironmentParser-taAKfzT7.mjs} +112 -4
- package/dist/EnvironmentParser-taAKfzT7.mjs.map +1 -0
- package/dist/SnifferEnvironmentParser.cjs +19 -4
- package/dist/SnifferEnvironmentParser.cjs.map +1 -1
- package/dist/SnifferEnvironmentParser.d.cts +20 -3
- package/dist/SnifferEnvironmentParser.d.cts.map +1 -1
- package/dist/SnifferEnvironmentParser.d.mts +20 -3
- package/dist/SnifferEnvironmentParser.d.mts.map +1 -1
- package/dist/SnifferEnvironmentParser.mjs +19 -4
- package/dist/SnifferEnvironmentParser.mjs.map +1 -1
- package/dist/index.cjs +4 -5
- package/dist/index.d.cts +52 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +52 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -3
- package/dist/sst.cjs +114 -6
- package/dist/sst.cjs.map +1 -1
- package/dist/sst.d.cts +184 -3
- package/dist/sst.d.cts.map +1 -1
- package/dist/sst.d.mts +184 -3
- package/dist/sst.d.mts.map +1 -1
- package/dist/sst.mjs +110 -2
- package/dist/sst.mjs.map +1 -1
- package/package.json +4 -3
- package/src/SnifferEnvironmentParser.ts +31 -3
- package/src/__tests__/SnifferEnvironmentParser.spec.ts +158 -0
- package/tsdown.config.ts +16 -1
- package/dist/EnvironmentBuilder.cjs +0 -4
- package/dist/EnvironmentBuilder.d.cts +0 -2
- package/dist/EnvironmentBuilder.d.mts +0 -2
- package/dist/EnvironmentBuilder.mjs +0 -3
- package/dist/EnvironmentParser-CkLfmn4Y.d.mts.map +0 -1
- package/dist/EnvironmentParser-DJdW7vOL.cjs.map +0 -1
- package/dist/EnvironmentParser-DtOL86NU.d.cts.map +0 -1
- package/dist/EnvironmentParser-zMblItla.mjs.map +0 -1
- package/dist/EnvironmentParser.cjs +0 -5
- package/dist/EnvironmentParser.d.cts +0 -2
- package/dist/EnvironmentParser.d.mts +0 -2
- package/dist/EnvironmentParser.mjs +0 -4
- package/dist/SstEnvironmentBuilder-BRAcRQp2.d.mts +0 -186
- package/dist/SstEnvironmentBuilder-BRAcRQp2.d.mts.map +0 -1
- package/dist/SstEnvironmentBuilder-D-NGrp7U.cjs +0 -130
- package/dist/SstEnvironmentBuilder-D-NGrp7U.cjs.map +0 -1
- package/dist/SstEnvironmentBuilder-DOu4dVPL.mjs +0 -113
- package/dist/SstEnvironmentBuilder-DOu4dVPL.mjs.map +0 -1
- package/dist/SstEnvironmentBuilder-Dc9nOuuK.d.cts +0 -186
- package/dist/SstEnvironmentBuilder-Dc9nOuuK.d.cts.map +0 -1
- package/dist/SstEnvironmentBuilder.cjs +0 -7
- package/dist/SstEnvironmentBuilder.d.cts +0 -3
- package/dist/SstEnvironmentBuilder.d.mts +0 -3
- package/dist/SstEnvironmentBuilder.mjs +0 -4
- package/dist/formatter-BRRrxQi3.mjs +0 -111
- package/dist/formatter-BRRrxQi3.mjs.map +0 -1
- package/dist/formatter-Cox0NGxT.d.mts +0 -51
- package/dist/formatter-Cox0NGxT.d.mts.map +0 -1
- package/dist/formatter-D85aIkpd.d.cts +0 -51
- package/dist/formatter-D85aIkpd.d.cts.map +0 -1
- package/dist/formatter-HxePpSy2.cjs +0 -123
- package/dist/formatter-HxePpSy2.cjs.map +0 -1
- package/dist/formatter.cjs +0 -4
- package/dist/formatter.d.cts +0 -2
- package/dist/formatter.d.mts +0 -2
- package/dist/formatter.mjs +0 -3
package/dist/sst.d.cts
CHANGED
|
@@ -1,8 +1,188 @@
|
|
|
1
|
-
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, environmentCase } from "./EnvironmentBuilder-
|
|
2
|
-
import { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-Dc9nOuuK.cjs";
|
|
1
|
+
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, environmentCase } from "./EnvironmentBuilder-CNgcdzSR.cjs";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/SstEnvironmentBuilder.d.ts
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Enumeration of supported SST (Serverless Stack Toolkit) resource types.
|
|
7
|
+
* Used to identify and process different AWS and SST resources.
|
|
8
|
+
*/
|
|
9
|
+
declare enum ResourceType {
|
|
10
|
+
ApiGatewayV2 = "sst.aws.ApiGatewayV2",
|
|
11
|
+
Postgres = "sst.aws.Postgres",
|
|
12
|
+
Function = "sst.aws.Function",
|
|
13
|
+
Bucket = "sst.aws.Bucket",
|
|
14
|
+
Vpc = "sst.aws.Vpc",
|
|
15
|
+
Secret = "sst.sst.Secret",
|
|
16
|
+
Dynamo = "sst.aws.Dynamo",
|
|
17
|
+
SSTSecret = "sst:sst:Secret",
|
|
18
|
+
SSTFunction = "sst:sst:Function",
|
|
19
|
+
SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
|
|
20
|
+
SSTPostgres = "sst:aws:Postgres",
|
|
21
|
+
SSTBucket = "sst:aws:Bucket",
|
|
22
|
+
SnsTopic = "sst:aws:SnsTopic",
|
|
23
|
+
SSTDynamo = "sst:aws:Dynamo",
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* AWS API Gateway V2 resource type.
|
|
27
|
+
* Represents an HTTP/WebSocket API.
|
|
28
|
+
*/
|
|
29
|
+
type ApiGatewayV2 = {
|
|
30
|
+
type: ResourceType.ApiGatewayV2 | ResourceType.SSTApiGatewayV2;
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* PostgreSQL database resource type.
|
|
35
|
+
* Contains all connection details needed to connect to the database.
|
|
36
|
+
*/
|
|
37
|
+
type Postgres = {
|
|
38
|
+
type: ResourceType.Postgres | ResourceType.SSTPostgres;
|
|
39
|
+
database: string;
|
|
40
|
+
host: string;
|
|
41
|
+
password: string;
|
|
42
|
+
port: number;
|
|
43
|
+
username: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* AWS Lambda Function resource type.
|
|
47
|
+
*/
|
|
48
|
+
type Function = {
|
|
49
|
+
type: ResourceType.Function | ResourceType.SSTFunction;
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* AWS S3 Bucket resource type.
|
|
54
|
+
*/
|
|
55
|
+
type Bucket = {
|
|
56
|
+
type: ResourceType.Bucket | ResourceType.SSTBucket;
|
|
57
|
+
name: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* AWS VPC (Virtual Private Cloud) resource type.
|
|
61
|
+
*/
|
|
62
|
+
type Vpc = {
|
|
63
|
+
type: ResourceType.Vpc;
|
|
64
|
+
bastion: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Secret resource type for storing sensitive values.
|
|
68
|
+
*/
|
|
69
|
+
type Secret = {
|
|
70
|
+
type: ResourceType.Secret | ResourceType.SSTSecret;
|
|
71
|
+
value: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* AWS SNS Topic resource type.
|
|
75
|
+
*/
|
|
76
|
+
type SnsTopic = {
|
|
77
|
+
type: ResourceType.SnsTopic;
|
|
78
|
+
arn: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* AWS DynamoDB Table resource type.
|
|
82
|
+
*/
|
|
83
|
+
type Dynamo = {
|
|
84
|
+
type: ResourceType.Dynamo | ResourceType.SSTDynamo;
|
|
85
|
+
name: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Union type of all supported SST resource types.
|
|
89
|
+
*/
|
|
90
|
+
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic | Dynamo;
|
|
91
|
+
/**
|
|
92
|
+
* Function type for processing a specific resource type into environment variables.
|
|
93
|
+
*
|
|
94
|
+
* @template K - The specific resource type (without `type` key)
|
|
95
|
+
* @param name - The resource name
|
|
96
|
+
* @param value - The resource value (without `type` key)
|
|
97
|
+
* @returns Object mapping environment variable names to values
|
|
98
|
+
*/
|
|
99
|
+
type ResourceProcessor<K> = (name: string, value: K) => EnvRecord;
|
|
100
|
+
/**
|
|
101
|
+
* Pre-configured resolvers for all SST resource types.
|
|
102
|
+
*/
|
|
103
|
+
declare const sstResolvers: Resolvers;
|
|
104
|
+
/**
|
|
105
|
+
* All known SST resource type strings.
|
|
106
|
+
*/
|
|
107
|
+
type SstResourceTypeString = `${ResourceType}`;
|
|
108
|
+
/**
|
|
109
|
+
* Extracts the `type` string value from an input value.
|
|
110
|
+
*/
|
|
111
|
+
type ExtractType<T> = T extends {
|
|
112
|
+
type: infer U extends string;
|
|
113
|
+
} ? U : never;
|
|
114
|
+
/**
|
|
115
|
+
* Removes the `type` key from an object type.
|
|
116
|
+
*/
|
|
117
|
+
type OmitType<T> = T extends {
|
|
118
|
+
type: string;
|
|
119
|
+
} ? Omit<T, 'type'> : never;
|
|
120
|
+
/**
|
|
121
|
+
* Extracts all unique `type` values from a record (excluding plain strings).
|
|
122
|
+
*/
|
|
123
|
+
type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]> }[keyof TRecord];
|
|
124
|
+
/**
|
|
125
|
+
* Extracts only the custom (non-SST) type values from a record.
|
|
126
|
+
*/
|
|
127
|
+
type CustomTypeValues<TRecord extends Record<string, InputValue>> = Exclude<AllTypeValues<TRecord>, SstResourceTypeString>;
|
|
128
|
+
/**
|
|
129
|
+
* For a given type value, finds the corresponding value type (without `type` key).
|
|
130
|
+
*/
|
|
131
|
+
type ValueForType<TRecord extends Record<string, InputValue>, TType extends string> = { [K in keyof TRecord]: TRecord[K] extends {
|
|
132
|
+
type: TType;
|
|
133
|
+
} ? OmitType<TRecord[K]> : never }[keyof TRecord];
|
|
134
|
+
/**
|
|
135
|
+
* Generates typed resolvers for custom (non-SST) types in the input record.
|
|
136
|
+
*/
|
|
137
|
+
type CustomResolvers<TRecord extends Record<string, InputValue>> = CustomTypeValues<TRecord> extends never ? Resolvers | undefined : { [TType in CustomTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>> };
|
|
138
|
+
/**
|
|
139
|
+
* SST-specific environment builder with built-in resolvers for all known
|
|
140
|
+
* SST resource types.
|
|
141
|
+
*
|
|
142
|
+
* Wraps the generic EnvironmentBuilder with pre-configured SST resolvers.
|
|
143
|
+
*
|
|
144
|
+
* @template TRecord - The input record type for type inference
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const env = new SstEnvironmentBuilder({
|
|
149
|
+
* database: { type: 'sst:aws:Postgres', host: '...', ... },
|
|
150
|
+
* apiKey: { type: 'sst:sst:Secret', value: 'secret' },
|
|
151
|
+
* appName: 'my-app',
|
|
152
|
+
* }).build();
|
|
153
|
+
*
|
|
154
|
+
* // With custom resolvers (typed based on input)
|
|
155
|
+
* const env = new SstEnvironmentBuilder(
|
|
156
|
+
* {
|
|
157
|
+
* database: postgresResource,
|
|
158
|
+
* custom: { type: 'my-custom' as const, data: 'foo' },
|
|
159
|
+
* },
|
|
160
|
+
* {
|
|
161
|
+
* // TypeScript requires 'my-custom' resolver with typed value
|
|
162
|
+
* 'my-custom': (key, value) => ({ [`${key}Data`]: value.data }),
|
|
163
|
+
* }
|
|
164
|
+
* ).build();
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare class SstEnvironmentBuilder<TRecord extends Record<string, SstResource | InputValue | string>> {
|
|
168
|
+
private readonly builder;
|
|
169
|
+
/**
|
|
170
|
+
* Create a new SST environment builder.
|
|
171
|
+
*
|
|
172
|
+
* @param record - Object containing SST resources, custom resources, and/or string values
|
|
173
|
+
* @param additionalResolvers - Optional custom resolvers (typed based on custom types in record)
|
|
174
|
+
* @param options - Optional configuration options
|
|
175
|
+
*/
|
|
176
|
+
constructor(record: TRecord, additionalResolvers?: CustomResolvers<TRecord>, options?: EnvironmentBuilderOptions);
|
|
177
|
+
/**
|
|
178
|
+
* Build environment variables from the input record.
|
|
179
|
+
*
|
|
180
|
+
* @returns A record of environment variables
|
|
181
|
+
*/
|
|
182
|
+
build(): EnvRecord;
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/sst.d.ts
|
|
6
186
|
/**
|
|
7
187
|
* @deprecated Use `new SstEnvironmentBuilder(record).build()` instead.
|
|
8
188
|
*
|
|
@@ -25,6 +205,7 @@ declare function normalizeResourceEnv(record: Record<string, SstResource | strin
|
|
|
25
205
|
*/
|
|
26
206
|
type Resource = SstResource;
|
|
27
207
|
//# sourceMappingURL=sst.d.ts.map
|
|
208
|
+
|
|
28
209
|
//#endregion
|
|
29
210
|
export { ApiGatewayV2, Bucket, Dynamo, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, normalizeResourceEnv, sstResolvers };
|
|
30
211
|
//# sourceMappingURL=sst.d.cts.map
|
package/dist/sst.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sst.d.cts","names":[],"sources":["../src/sst.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sst.d.cts","names":[],"sources":["../src/SstEnvironmentBuilder.ts","../src/sst.ts"],"sourcesContent":[],"mappings":";;;;;;AAaA;AAwBA;AAAwB,aAxBZ,YAAA;EAwBY,YACjB,GAAA,sBAAa;EAAY,QAAG,GAAA,kBAAa;EAAe,QAAA,GAAA,kBAAA;EAQnD,MAAA,GAAA,gBAAQ;EAAA,GAAA,GAAA,aAAA;EAAA,MACb,GAAA,gBAAa;EAAQ,MAAG,GAAA,gBAAa;EAAW,SAAA,GAAA,gBAAA;EAW3C,WAAQ,GAAA,kBAAA;EAAA,eAAA,GAAA,sBAAA;EAAA,WACb,GAAA,kBAAa;EAAQ,SAAG,GAAA,gBAAa;EAAW,QAAA,GAAA,kBAAA;EAO3C,SAAM,GAAA,gBAAA;;;;AACiC;AAOnD;AAQY,KA7CA,YAAA,GA6CM;EAAA,IAAA,EA5CX,YAAA,CAA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U,iBAAiB,WAAW,oBACrC,aAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCd,sCACI,eAAe,cAAc;;;;;;;;;sBAepC,+BACc,gBAAgB,oBAC5B;;;;;;WAmBF;;;;AA3QV;;;;AAC+D;AAQ/D;;;;AACuD;AAWvD;;;;AACuD;AAOvD;AAAkB,iBCjBF,oBAAA,CDiBE,MAAA,EChBT,MDgBS,CAAA,MAAA,EChBM,WDgBN,GAAA,MAAA,CAAA,CAAA,ECff,MDee,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GCf4B,MDe5B,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;;;AACiC;AAOvC,KCfA,QAAA,GAAW,WDgBH;AAOpB"}
|
package/dist/sst.d.mts
CHANGED
|
@@ -1,8 +1,188 @@
|
|
|
1
|
-
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, environmentCase } from "./EnvironmentBuilder-
|
|
2
|
-
import { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-BRAcRQp2.mjs";
|
|
1
|
+
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, EnvironmentResolver, InputValue, Resolvers, environmentCase } from "./EnvironmentBuilder-DHfDXJUm.mjs";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/SstEnvironmentBuilder.d.ts
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Enumeration of supported SST (Serverless Stack Toolkit) resource types.
|
|
7
|
+
* Used to identify and process different AWS and SST resources.
|
|
8
|
+
*/
|
|
9
|
+
declare enum ResourceType {
|
|
10
|
+
ApiGatewayV2 = "sst.aws.ApiGatewayV2",
|
|
11
|
+
Postgres = "sst.aws.Postgres",
|
|
12
|
+
Function = "sst.aws.Function",
|
|
13
|
+
Bucket = "sst.aws.Bucket",
|
|
14
|
+
Vpc = "sst.aws.Vpc",
|
|
15
|
+
Secret = "sst.sst.Secret",
|
|
16
|
+
Dynamo = "sst.aws.Dynamo",
|
|
17
|
+
SSTSecret = "sst:sst:Secret",
|
|
18
|
+
SSTFunction = "sst:sst:Function",
|
|
19
|
+
SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
|
|
20
|
+
SSTPostgres = "sst:aws:Postgres",
|
|
21
|
+
SSTBucket = "sst:aws:Bucket",
|
|
22
|
+
SnsTopic = "sst:aws:SnsTopic",
|
|
23
|
+
SSTDynamo = "sst:aws:Dynamo",
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* AWS API Gateway V2 resource type.
|
|
27
|
+
* Represents an HTTP/WebSocket API.
|
|
28
|
+
*/
|
|
29
|
+
type ApiGatewayV2 = {
|
|
30
|
+
type: ResourceType.ApiGatewayV2 | ResourceType.SSTApiGatewayV2;
|
|
31
|
+
url: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* PostgreSQL database resource type.
|
|
35
|
+
* Contains all connection details needed to connect to the database.
|
|
36
|
+
*/
|
|
37
|
+
type Postgres = {
|
|
38
|
+
type: ResourceType.Postgres | ResourceType.SSTPostgres;
|
|
39
|
+
database: string;
|
|
40
|
+
host: string;
|
|
41
|
+
password: string;
|
|
42
|
+
port: number;
|
|
43
|
+
username: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* AWS Lambda Function resource type.
|
|
47
|
+
*/
|
|
48
|
+
type Function = {
|
|
49
|
+
type: ResourceType.Function | ResourceType.SSTFunction;
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* AWS S3 Bucket resource type.
|
|
54
|
+
*/
|
|
55
|
+
type Bucket = {
|
|
56
|
+
type: ResourceType.Bucket | ResourceType.SSTBucket;
|
|
57
|
+
name: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* AWS VPC (Virtual Private Cloud) resource type.
|
|
61
|
+
*/
|
|
62
|
+
type Vpc = {
|
|
63
|
+
type: ResourceType.Vpc;
|
|
64
|
+
bastion: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Secret resource type for storing sensitive values.
|
|
68
|
+
*/
|
|
69
|
+
type Secret = {
|
|
70
|
+
type: ResourceType.Secret | ResourceType.SSTSecret;
|
|
71
|
+
value: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* AWS SNS Topic resource type.
|
|
75
|
+
*/
|
|
76
|
+
type SnsTopic = {
|
|
77
|
+
type: ResourceType.SnsTopic;
|
|
78
|
+
arn: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* AWS DynamoDB Table resource type.
|
|
82
|
+
*/
|
|
83
|
+
type Dynamo = {
|
|
84
|
+
type: ResourceType.Dynamo | ResourceType.SSTDynamo;
|
|
85
|
+
name: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Union type of all supported SST resource types.
|
|
89
|
+
*/
|
|
90
|
+
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic | Dynamo;
|
|
91
|
+
/**
|
|
92
|
+
* Function type for processing a specific resource type into environment variables.
|
|
93
|
+
*
|
|
94
|
+
* @template K - The specific resource type (without `type` key)
|
|
95
|
+
* @param name - The resource name
|
|
96
|
+
* @param value - The resource value (without `type` key)
|
|
97
|
+
* @returns Object mapping environment variable names to values
|
|
98
|
+
*/
|
|
99
|
+
type ResourceProcessor<K> = (name: string, value: K) => EnvRecord;
|
|
100
|
+
/**
|
|
101
|
+
* Pre-configured resolvers for all SST resource types.
|
|
102
|
+
*/
|
|
103
|
+
declare const sstResolvers: Resolvers;
|
|
104
|
+
/**
|
|
105
|
+
* All known SST resource type strings.
|
|
106
|
+
*/
|
|
107
|
+
type SstResourceTypeString = `${ResourceType}`;
|
|
108
|
+
/**
|
|
109
|
+
* Extracts the `type` string value from an input value.
|
|
110
|
+
*/
|
|
111
|
+
type ExtractType<T> = T extends {
|
|
112
|
+
type: infer U extends string;
|
|
113
|
+
} ? U : never;
|
|
114
|
+
/**
|
|
115
|
+
* Removes the `type` key from an object type.
|
|
116
|
+
*/
|
|
117
|
+
type OmitType<T> = T extends {
|
|
118
|
+
type: string;
|
|
119
|
+
} ? Omit<T, 'type'> : never;
|
|
120
|
+
/**
|
|
121
|
+
* Extracts all unique `type` values from a record (excluding plain strings).
|
|
122
|
+
*/
|
|
123
|
+
type AllTypeValues<TRecord extends Record<string, InputValue>> = { [K in keyof TRecord]: ExtractType<TRecord[K]> }[keyof TRecord];
|
|
124
|
+
/**
|
|
125
|
+
* Extracts only the custom (non-SST) type values from a record.
|
|
126
|
+
*/
|
|
127
|
+
type CustomTypeValues<TRecord extends Record<string, InputValue>> = Exclude<AllTypeValues<TRecord>, SstResourceTypeString>;
|
|
128
|
+
/**
|
|
129
|
+
* For a given type value, finds the corresponding value type (without `type` key).
|
|
130
|
+
*/
|
|
131
|
+
type ValueForType<TRecord extends Record<string, InputValue>, TType extends string> = { [K in keyof TRecord]: TRecord[K] extends {
|
|
132
|
+
type: TType;
|
|
133
|
+
} ? OmitType<TRecord[K]> : never }[keyof TRecord];
|
|
134
|
+
/**
|
|
135
|
+
* Generates typed resolvers for custom (non-SST) types in the input record.
|
|
136
|
+
*/
|
|
137
|
+
type CustomResolvers<TRecord extends Record<string, InputValue>> = CustomTypeValues<TRecord> extends never ? Resolvers | undefined : { [TType in CustomTypeValues<TRecord>]: EnvironmentResolver<ValueForType<TRecord, TType>> };
|
|
138
|
+
/**
|
|
139
|
+
* SST-specific environment builder with built-in resolvers for all known
|
|
140
|
+
* SST resource types.
|
|
141
|
+
*
|
|
142
|
+
* Wraps the generic EnvironmentBuilder with pre-configured SST resolvers.
|
|
143
|
+
*
|
|
144
|
+
* @template TRecord - The input record type for type inference
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const env = new SstEnvironmentBuilder({
|
|
149
|
+
* database: { type: 'sst:aws:Postgres', host: '...', ... },
|
|
150
|
+
* apiKey: { type: 'sst:sst:Secret', value: 'secret' },
|
|
151
|
+
* appName: 'my-app',
|
|
152
|
+
* }).build();
|
|
153
|
+
*
|
|
154
|
+
* // With custom resolvers (typed based on input)
|
|
155
|
+
* const env = new SstEnvironmentBuilder(
|
|
156
|
+
* {
|
|
157
|
+
* database: postgresResource,
|
|
158
|
+
* custom: { type: 'my-custom' as const, data: 'foo' },
|
|
159
|
+
* },
|
|
160
|
+
* {
|
|
161
|
+
* // TypeScript requires 'my-custom' resolver with typed value
|
|
162
|
+
* 'my-custom': (key, value) => ({ [`${key}Data`]: value.data }),
|
|
163
|
+
* }
|
|
164
|
+
* ).build();
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
declare class SstEnvironmentBuilder<TRecord extends Record<string, SstResource | InputValue | string>> {
|
|
168
|
+
private readonly builder;
|
|
169
|
+
/**
|
|
170
|
+
* Create a new SST environment builder.
|
|
171
|
+
*
|
|
172
|
+
* @param record - Object containing SST resources, custom resources, and/or string values
|
|
173
|
+
* @param additionalResolvers - Optional custom resolvers (typed based on custom types in record)
|
|
174
|
+
* @param options - Optional configuration options
|
|
175
|
+
*/
|
|
176
|
+
constructor(record: TRecord, additionalResolvers?: CustomResolvers<TRecord>, options?: EnvironmentBuilderOptions);
|
|
177
|
+
/**
|
|
178
|
+
* Build environment variables from the input record.
|
|
179
|
+
*
|
|
180
|
+
* @returns A record of environment variables
|
|
181
|
+
*/
|
|
182
|
+
build(): EnvRecord;
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/sst.d.ts
|
|
6
186
|
/**
|
|
7
187
|
* @deprecated Use `new SstEnvironmentBuilder(record).build()` instead.
|
|
8
188
|
*
|
|
@@ -25,6 +205,7 @@ declare function normalizeResourceEnv(record: Record<string, SstResource | strin
|
|
|
25
205
|
*/
|
|
26
206
|
type Resource = SstResource;
|
|
27
207
|
//# sourceMappingURL=sst.d.ts.map
|
|
208
|
+
|
|
28
209
|
//#endregion
|
|
29
210
|
export { ApiGatewayV2, Bucket, Dynamo, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, normalizeResourceEnv, sstResolvers };
|
|
30
211
|
//# sourceMappingURL=sst.d.mts.map
|
package/dist/sst.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sst.d.mts","names":[],"sources":["../src/sst.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sst.d.mts","names":[],"sources":["../src/SstEnvironmentBuilder.ts","../src/sst.ts"],"sourcesContent":[],"mappings":";;;;;;AAaA;AAwBA;AAAwB,aAxBZ,YAAA;EAwBY,YACjB,GAAA,sBAAa;EAAY,QAAG,GAAA,kBAAa;EAAe,QAAA,GAAA,kBAAA;EAQnD,MAAA,GAAA,gBAAQ;EAAA,GAAA,GAAA,aAAA;EAAA,MACb,GAAA,gBAAa;EAAQ,MAAG,GAAA,gBAAa;EAAW,SAAA,GAAA,gBAAA;EAW3C,WAAQ,GAAA,kBAAA;EAAA,eAAA,GAAA,sBAAA;EAAA,WACb,GAAA,kBAAa;EAAQ,SAAG,GAAA,gBAAa;EAAW,QAAA,GAAA,kBAAA;EAO3C,SAAM,GAAA,gBAAA;;;;AACiC;AAOnD;AAQY,KA7CA,YAAA,GA6CM;EAAA,IAAA,EA5CX,YAAA,CAAa,YA4CF,GA5CiB,YAAA,CAAa,eA4C9B;EAAA,GACX,EAAA,MAAA;CAAmB;AAAyB;AAOnD;AAQA;;AACO,KArDK,QAAA,GAqDQ;EAAM,IAAG,EApDtB,YAAA,CAAa,QAoDsB,GApDX,YAAA,CAAa,WAoDF;EAAS,QAAA,EAAA,MAAA;EAOvC,IAAA,EAAA,MAAA;EAAW,QAAA,EAAA,MAAA;EAAA,IACpB,EAA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AAA,EChBM,WDgBN,GAAA,MAAA,CAAA,CAAA,ECff,MDee,CAAA,MAAA,EAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GCf4B,MDe5B,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;;;AACiC;AAOvC,KCfA,QAAA,GAAW,WDgBH;AAOpB"}
|
package/dist/sst.mjs
CHANGED
|
@@ -1,6 +1,114 @@
|
|
|
1
|
-
import { environmentCase } from "./EnvironmentBuilder-
|
|
2
|
-
import { ResourceType, SstEnvironmentBuilder, sstResolvers } from "./SstEnvironmentBuilder-DOu4dVPL.mjs";
|
|
1
|
+
import { EnvironmentBuilder, environmentCase } from "./EnvironmentBuilder-CFen3oIg.mjs";
|
|
3
2
|
|
|
3
|
+
//#region src/SstEnvironmentBuilder.ts
|
|
4
|
+
/**
|
|
5
|
+
* Enumeration of supported SST (Serverless Stack Toolkit) resource types.
|
|
6
|
+
* Used to identify and process different AWS and SST resources.
|
|
7
|
+
*/
|
|
8
|
+
let ResourceType = /* @__PURE__ */ function(ResourceType$1) {
|
|
9
|
+
ResourceType$1["ApiGatewayV2"] = "sst.aws.ApiGatewayV2";
|
|
10
|
+
ResourceType$1["Postgres"] = "sst.aws.Postgres";
|
|
11
|
+
ResourceType$1["Function"] = "sst.aws.Function";
|
|
12
|
+
ResourceType$1["Bucket"] = "sst.aws.Bucket";
|
|
13
|
+
ResourceType$1["Vpc"] = "sst.aws.Vpc";
|
|
14
|
+
ResourceType$1["Secret"] = "sst.sst.Secret";
|
|
15
|
+
ResourceType$1["Dynamo"] = "sst.aws.Dynamo";
|
|
16
|
+
ResourceType$1["SSTSecret"] = "sst:sst:Secret";
|
|
17
|
+
ResourceType$1["SSTFunction"] = "sst:sst:Function";
|
|
18
|
+
ResourceType$1["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
|
|
19
|
+
ResourceType$1["SSTPostgres"] = "sst:aws:Postgres";
|
|
20
|
+
ResourceType$1["SSTBucket"] = "sst:aws:Bucket";
|
|
21
|
+
ResourceType$1["SnsTopic"] = "sst:aws:SnsTopic";
|
|
22
|
+
ResourceType$1["SSTDynamo"] = "sst:aws:Dynamo";
|
|
23
|
+
return ResourceType$1;
|
|
24
|
+
}({});
|
|
25
|
+
const secretResolver = (name, value) => ({ [name]: value.value });
|
|
26
|
+
const postgresResolver = (key, value) => ({
|
|
27
|
+
[`${key}Name`]: value.database,
|
|
28
|
+
[`${key}Host`]: value.host,
|
|
29
|
+
[`${key}Password`]: value.password,
|
|
30
|
+
[`${key}Port`]: value.port,
|
|
31
|
+
[`${key}Username`]: value.username
|
|
32
|
+
});
|
|
33
|
+
const bucketResolver = (name, value) => ({ [`${name}Name`]: value.name });
|
|
34
|
+
const topicResolver = (name, value) => ({ [`${name}Arn`]: value.arn });
|
|
35
|
+
const dynamoResolver = (name, value) => ({ [`${name}Name`]: value.name });
|
|
36
|
+
const noopResolver = () => ({});
|
|
37
|
+
/**
|
|
38
|
+
* Pre-configured resolvers for all SST resource types.
|
|
39
|
+
*/
|
|
40
|
+
const sstResolvers = {
|
|
41
|
+
[ResourceType.ApiGatewayV2]: noopResolver,
|
|
42
|
+
[ResourceType.Function]: noopResolver,
|
|
43
|
+
[ResourceType.Vpc]: noopResolver,
|
|
44
|
+
[ResourceType.Secret]: secretResolver,
|
|
45
|
+
[ResourceType.Postgres]: postgresResolver,
|
|
46
|
+
[ResourceType.Bucket]: bucketResolver,
|
|
47
|
+
[ResourceType.Dynamo]: dynamoResolver,
|
|
48
|
+
[ResourceType.SSTSecret]: secretResolver,
|
|
49
|
+
[ResourceType.SSTBucket]: bucketResolver,
|
|
50
|
+
[ResourceType.SSTFunction]: noopResolver,
|
|
51
|
+
[ResourceType.SSTPostgres]: postgresResolver,
|
|
52
|
+
[ResourceType.SSTApiGatewayV2]: noopResolver,
|
|
53
|
+
[ResourceType.SnsTopic]: topicResolver,
|
|
54
|
+
[ResourceType.SSTDynamo]: dynamoResolver
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* SST-specific environment builder with built-in resolvers for all known
|
|
58
|
+
* SST resource types.
|
|
59
|
+
*
|
|
60
|
+
* Wraps the generic EnvironmentBuilder with pre-configured SST resolvers.
|
|
61
|
+
*
|
|
62
|
+
* @template TRecord - The input record type for type inference
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const env = new SstEnvironmentBuilder({
|
|
67
|
+
* database: { type: 'sst:aws:Postgres', host: '...', ... },
|
|
68
|
+
* apiKey: { type: 'sst:sst:Secret', value: 'secret' },
|
|
69
|
+
* appName: 'my-app',
|
|
70
|
+
* }).build();
|
|
71
|
+
*
|
|
72
|
+
* // With custom resolvers (typed based on input)
|
|
73
|
+
* const env = new SstEnvironmentBuilder(
|
|
74
|
+
* {
|
|
75
|
+
* database: postgresResource,
|
|
76
|
+
* custom: { type: 'my-custom' as const, data: 'foo' },
|
|
77
|
+
* },
|
|
78
|
+
* {
|
|
79
|
+
* // TypeScript requires 'my-custom' resolver with typed value
|
|
80
|
+
* 'my-custom': (key, value) => ({ [`${key}Data`]: value.data }),
|
|
81
|
+
* }
|
|
82
|
+
* ).build();
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
var SstEnvironmentBuilder = class {
|
|
86
|
+
builder;
|
|
87
|
+
/**
|
|
88
|
+
* Create a new SST environment builder.
|
|
89
|
+
*
|
|
90
|
+
* @param record - Object containing SST resources, custom resources, and/or string values
|
|
91
|
+
* @param additionalResolvers - Optional custom resolvers (typed based on custom types in record)
|
|
92
|
+
* @param options - Optional configuration options
|
|
93
|
+
*/
|
|
94
|
+
constructor(record, additionalResolvers, options) {
|
|
95
|
+
const mergedResolvers = additionalResolvers ? {
|
|
96
|
+
...sstResolvers,
|
|
97
|
+
...additionalResolvers
|
|
98
|
+
} : sstResolvers;
|
|
99
|
+
this.builder = new EnvironmentBuilder(record, mergedResolvers, options);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Build environment variables from the input record.
|
|
103
|
+
*
|
|
104
|
+
* @returns A record of environment variables
|
|
105
|
+
*/
|
|
106
|
+
build() {
|
|
107
|
+
return this.builder.build();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
4
112
|
//#region src/sst.ts
|
|
5
113
|
/**
|
|
6
114
|
* @deprecated Use `new SstEnvironmentBuilder(record).build()` instead.
|
package/dist/sst.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sst.mjs","names":["record: Record<string, SstResource | string>"],"sources":["../src/sst.ts"],"sourcesContent":["// Re-export everything from SstEnvironmentBuilder\n\n// Re-export types from EnvironmentBuilder\nexport type {\n\tEnvironmentBuilderOptions,\n\tEnvRecord,\n\tEnvValue,\n} from './EnvironmentBuilder';\n\n// Re-export environmentCase from EnvironmentBuilder\nexport { environmentCase } from './EnvironmentBuilder';\nexport {\n\ttype ApiGatewayV2,\n\ttype Bucket,\n\ttype Dynamo,\n\ttype Function,\n\ttype Postgres,\n\ttype ResourceProcessor,\n\tResourceType,\n\ttype Secret,\n\ttype SnsTopic,\n\tSstEnvironmentBuilder,\n\ttype SstResource,\n\tsstResolvers,\n\ttype Vpc,\n} from './SstEnvironmentBuilder';\n\n// Import for deprecated function\nimport {\n\tSstEnvironmentBuilder,\n\ttype SstResource,\n} from './SstEnvironmentBuilder';\n\n/**\n * @deprecated Use `new SstEnvironmentBuilder(record).build()` instead.\n *\n * Normalizes SST resources and plain strings into environment variables.\n * Processes resources based on their type and converts names to environment case.\n *\n * @param record - Object containing resources and/or string values\n * @returns Normalized environment variables object\n *\n * @example\n * // Old usage (deprecated):\n * normalizeResourceEnv({ database: postgresResource })\n *\n * // New usage:\n * new SstEnvironmentBuilder({ database: postgresResource }).build()\n */\nexport function normalizeResourceEnv(\n\trecord: Record<string, SstResource | string>,\n): Record<string, string | number | boolean | Record<string, unknown>> {\n\treturn new SstEnvironmentBuilder(record).build();\n}\n\n// Keep Resource type as deprecated alias for backwards compatibility\n/**\n * @deprecated Use `SstResource` instead.\n */\nexport type Resource = SstResource;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,qBACfA,QACsE;AACtE,QAAO,IAAI,sBAAsB,QAAQ,OAAO;AAChD"}
|
|
1
|
+
{"version":3,"file":"sst.mjs","names":["name: string","value: SecretValue","key: string","value: PostgresValue","value: BucketValue","value: SnsTopicValue","value: DynamoValue","sstResolvers: Resolvers","record: TRecord","additionalResolvers?: CustomResolvers<TRecord>","options?: EnvironmentBuilderOptions","mergedResolvers: Resolvers","record: Record<string, SstResource | string>"],"sources":["../src/SstEnvironmentBuilder.ts","../src/sst.ts"],"sourcesContent":["import {\n\tEnvironmentBuilder,\n\ttype EnvironmentBuilderOptions,\n\ttype EnvironmentResolver,\n\ttype EnvRecord,\n\ttype InputValue,\n\ttype Resolvers,\n} from './EnvironmentBuilder';\n\n/**\n * Enumeration of supported SST (Serverless Stack Toolkit) resource types.\n * Used to identify and process different AWS and SST resources.\n */\nexport enum ResourceType {\n\t// Legacy format (dot notation)\n\tApiGatewayV2 = 'sst.aws.ApiGatewayV2',\n\tPostgres = 'sst.aws.Postgres',\n\tFunction = 'sst.aws.Function',\n\tBucket = 'sst.aws.Bucket',\n\tVpc = 'sst.aws.Vpc',\n\tSecret = 'sst.sst.Secret',\n\tDynamo = 'sst.aws.Dynamo',\n\n\t// Modern format (colon notation)\n\tSSTSecret = 'sst:sst:Secret',\n\tSSTFunction = 'sst:sst:Function',\n\tSSTApiGatewayV2 = 'sst:aws:ApiGatewayV2',\n\tSSTPostgres = 'sst:aws:Postgres',\n\tSSTBucket = 'sst:aws:Bucket',\n\tSnsTopic = 'sst:aws:SnsTopic',\n\tSSTDynamo = 'sst:aws:Dynamo',\n}\n\n/**\n * AWS API Gateway V2 resource type.\n * Represents an HTTP/WebSocket API.\n */\nexport type ApiGatewayV2 = {\n\ttype: ResourceType.ApiGatewayV2 | ResourceType.SSTApiGatewayV2;\n\turl: string;\n};\n\n/**\n * PostgreSQL database resource type.\n * Contains all connection details needed to connect to the database.\n */\nexport type Postgres = {\n\ttype: ResourceType.Postgres | ResourceType.SSTPostgres;\n\tdatabase: string;\n\thost: string;\n\tpassword: string;\n\tport: number;\n\tusername: string;\n};\n\n/**\n * AWS Lambda Function resource type.\n */\nexport type Function = {\n\ttype: ResourceType.Function | ResourceType.SSTFunction;\n\tname: string;\n};\n\n/**\n * AWS S3 Bucket resource type.\n */\nexport type Bucket = {\n\ttype: ResourceType.Bucket | ResourceType.SSTBucket;\n\tname: string;\n};\n\n/**\n * AWS VPC (Virtual Private Cloud) resource type.\n */\nexport type Vpc = {\n\ttype: ResourceType.Vpc;\n\tbastion: string;\n};\n\n/**\n * Secret resource type for storing sensitive values.\n */\nexport type Secret = {\n\ttype: ResourceType.Secret | ResourceType.SSTSecret;\n\tvalue: string;\n};\n\n/**\n * AWS SNS Topic resource type.\n */\nexport type SnsTopic = {\n\ttype: ResourceType.SnsTopic;\n\tarn: string;\n};\n\n/**\n * AWS DynamoDB Table resource type.\n */\nexport type Dynamo = {\n\ttype: ResourceType.Dynamo | ResourceType.SSTDynamo;\n\tname: string;\n};\n\n/**\n * Union type of all supported SST resource types.\n */\nexport type SstResource =\n\t| ApiGatewayV2\n\t| Postgres\n\t| Function\n\t| Bucket\n\t| Vpc\n\t| Secret\n\t| SnsTopic\n\t| Dynamo;\n\n// Value types without the `type` key (for resolver parameters)\ntype SecretValue = Omit<Secret, 'type'>;\ntype PostgresValue = Omit<Postgres, 'type'>;\ntype BucketValue = Omit<Bucket, 'type'>;\ntype SnsTopicValue = Omit<SnsTopic, 'type'>;\ntype DynamoValue = Omit<Dynamo, 'type'>;\n\n/**\n * Function type for processing a specific resource type into environment variables.\n *\n * @template K - The specific resource type (without `type` key)\n * @param name - The resource name\n * @param value - The resource value (without `type` key)\n * @returns Object mapping environment variable names to values\n */\nexport type ResourceProcessor<K> = (name: string, value: K) => EnvRecord;\n\n// SST Resource Resolvers (receive values without `type` key)\n\nconst secretResolver = (name: string, value: SecretValue) => ({\n\t[name]: value.value,\n});\n\nconst postgresResolver = (key: string, value: PostgresValue) => ({\n\t[`${key}Name`]: value.database,\n\t[`${key}Host`]: value.host,\n\t[`${key}Password`]: value.password,\n\t[`${key}Port`]: value.port,\n\t[`${key}Username`]: value.username,\n});\n\nconst bucketResolver = (name: string, value: BucketValue) => ({\n\t[`${name}Name`]: value.name,\n});\n\nconst topicResolver = (name: string, value: SnsTopicValue) => ({\n\t[`${name}Arn`]: value.arn,\n});\n\nconst dynamoResolver = (name: string, value: DynamoValue) => ({\n\t[`${name}Name`]: value.name,\n});\n\nconst noopResolver = () => ({});\n\n/**\n * Pre-configured resolvers for all SST resource types.\n */\nexport const sstResolvers: Resolvers = {\n\t// Legacy format\n\t[ResourceType.ApiGatewayV2]: noopResolver,\n\t[ResourceType.Function]: noopResolver,\n\t[ResourceType.Vpc]: noopResolver,\n\t[ResourceType.Secret]: secretResolver,\n\t[ResourceType.Postgres]: postgresResolver,\n\t[ResourceType.Bucket]: bucketResolver,\n\t[ResourceType.Dynamo]: dynamoResolver,\n\n\t// Modern format\n\t[ResourceType.SSTSecret]: secretResolver,\n\t[ResourceType.SSTBucket]: bucketResolver,\n\t[ResourceType.SSTFunction]: noopResolver,\n\t[ResourceType.SSTPostgres]: postgresResolver,\n\t[ResourceType.SSTApiGatewayV2]: noopResolver,\n\t[ResourceType.SnsTopic]: topicResolver,\n\t[ResourceType.SSTDynamo]: dynamoResolver,\n};\n\n/**\n * All known SST resource type strings.\n */\ntype SstResourceTypeString = `${ResourceType}`;\n\n/**\n * Extracts the `type` string value from an input value.\n */\ntype ExtractType<T> = T extends { type: infer U extends string } ? U : never;\n\n/**\n * Removes the `type` key from an object type.\n */\ntype OmitType<T> = T extends { type: string } ? Omit<T, 'type'> : never;\n\n/**\n * Extracts all unique `type` values from a record (excluding plain strings).\n */\ntype AllTypeValues<TRecord extends Record<string, InputValue>> = {\n\t[K in keyof TRecord]: ExtractType<TRecord[K]>;\n}[keyof TRecord];\n\n/**\n * Extracts only the custom (non-SST) type values from a record.\n */\ntype CustomTypeValues<TRecord extends Record<string, InputValue>> = Exclude<\n\tAllTypeValues<TRecord>,\n\tSstResourceTypeString\n>;\n\n/**\n * For a given type value, finds the corresponding value type (without `type` key).\n */\ntype ValueForType<\n\tTRecord extends Record<string, InputValue>,\n\tTType extends string,\n> = {\n\t[K in keyof TRecord]: TRecord[K] extends { type: TType }\n\t\t? OmitType<TRecord[K]>\n\t\t: never;\n}[keyof TRecord];\n\n/**\n * Generates typed resolvers for custom (non-SST) types in the input record.\n */\ntype CustomResolvers<TRecord extends Record<string, InputValue>> =\n\tCustomTypeValues<TRecord> extends never\n\t\t? Resolvers | undefined\n\t\t: {\n\t\t\t\t[TType in CustomTypeValues<TRecord>]: EnvironmentResolver<\n\t\t\t\t\tValueForType<TRecord, TType>\n\t\t\t\t>;\n\t\t\t};\n\n/**\n * SST-specific environment builder with built-in resolvers for all known\n * SST resource types.\n *\n * Wraps the generic EnvironmentBuilder with pre-configured SST resolvers.\n *\n * @template TRecord - The input record type for type inference\n *\n * @example\n * ```typescript\n * const env = new SstEnvironmentBuilder({\n * database: { type: 'sst:aws:Postgres', host: '...', ... },\n * apiKey: { type: 'sst:sst:Secret', value: 'secret' },\n * appName: 'my-app',\n * }).build();\n *\n * // With custom resolvers (typed based on input)\n * const env = new SstEnvironmentBuilder(\n * {\n * database: postgresResource,\n * custom: { type: 'my-custom' as const, data: 'foo' },\n * },\n * {\n * // TypeScript requires 'my-custom' resolver with typed value\n * 'my-custom': (key, value) => ({ [`${key}Data`]: value.data }),\n * }\n * ).build();\n * ```\n */\nexport class SstEnvironmentBuilder<\n\tTRecord extends Record<string, SstResource | InputValue | string>,\n> {\n\tprivate readonly builder: EnvironmentBuilder<\n\t\tRecord<string, InputValue>,\n\t\tResolvers\n\t>;\n\n\t/**\n\t * Create a new SST environment builder.\n\t *\n\t * @param record - Object containing SST resources, custom resources, and/or string values\n\t * @param additionalResolvers - Optional custom resolvers (typed based on custom types in record)\n\t * @param options - Optional configuration options\n\t */\n\tconstructor(\n\t\trecord: TRecord,\n\t\tadditionalResolvers?: CustomResolvers<TRecord>,\n\t\toptions?: EnvironmentBuilderOptions,\n\t) {\n\t\t// Merge resolvers with custom ones taking precedence\n\t\tconst mergedResolvers: Resolvers = additionalResolvers\n\t\t\t? { ...sstResolvers, ...additionalResolvers }\n\t\t\t: sstResolvers;\n\n\t\tthis.builder = new EnvironmentBuilder(\n\t\t\trecord as Record<string, InputValue>,\n\t\t\tmergedResolvers,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Build environment variables from the input record.\n\t *\n\t * @returns A record of environment variables\n\t */\n\tbuild(): EnvRecord {\n\t\treturn this.builder.build();\n\t}\n}\n\nexport type {\n\tEnvironmentBuilderOptions,\n\tEnvRecord,\n\tEnvValue,\n} from './EnvironmentBuilder';\n// Re-export useful types\nexport { environmentCase } from './EnvironmentBuilder';\n","// Re-export everything from SstEnvironmentBuilder\n\n// Re-export types from EnvironmentBuilder\nexport type {\n\tEnvironmentBuilderOptions,\n\tEnvRecord,\n\tEnvValue,\n} from './EnvironmentBuilder';\n\n// Re-export environmentCase from EnvironmentBuilder\nexport { environmentCase } from './EnvironmentBuilder';\nexport {\n\ttype ApiGatewayV2,\n\ttype Bucket,\n\ttype Dynamo,\n\ttype Function,\n\ttype Postgres,\n\ttype ResourceProcessor,\n\tResourceType,\n\ttype Secret,\n\ttype SnsTopic,\n\tSstEnvironmentBuilder,\n\ttype SstResource,\n\tsstResolvers,\n\ttype Vpc,\n} from './SstEnvironmentBuilder';\n\n// Import for deprecated function\nimport {\n\tSstEnvironmentBuilder,\n\ttype SstResource,\n} from './SstEnvironmentBuilder';\n\n/**\n * @deprecated Use `new SstEnvironmentBuilder(record).build()` instead.\n *\n * Normalizes SST resources and plain strings into environment variables.\n * Processes resources based on their type and converts names to environment case.\n *\n * @param record - Object containing resources and/or string values\n * @returns Normalized environment variables object\n *\n * @example\n * // Old usage (deprecated):\n * normalizeResourceEnv({ database: postgresResource })\n *\n * // New usage:\n * new SstEnvironmentBuilder({ database: postgresResource }).build()\n */\nexport function normalizeResourceEnv(\n\trecord: Record<string, SstResource | string>,\n): Record<string, string | number | boolean | Record<string, unknown>> {\n\treturn new SstEnvironmentBuilder(record).build();\n}\n\n// Keep Resource type as deprecated alias for backwards compatibility\n/**\n * @deprecated Use `SstResource` instead.\n */\nexport type Resource = SstResource;\n"],"mappings":";;;;;;;AAaA,IAAY,wDAAL;AAEN;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAwGD,MAAM,iBAAiB,CAACA,MAAcC,WAAwB,GAC5D,OAAO,MAAM,MACd;AAED,MAAM,mBAAmB,CAACC,KAAaC,WAA0B;GAC9D,EAAE,IAAI,QAAQ,MAAM;GACpB,EAAE,IAAI,QAAQ,MAAM;GACpB,EAAE,IAAI,YAAY,MAAM;GACxB,EAAE,IAAI,QAAQ,MAAM;GACpB,EAAE,IAAI,YAAY,MAAM;AAC1B;AAED,MAAM,iBAAiB,CAACH,MAAcI,WAAwB,IAC3D,EAAE,KAAK,QAAQ,MAAM,KACvB;AAED,MAAM,gBAAgB,CAACJ,MAAcK,WAA0B,IAC5D,EAAE,KAAK,OAAO,MAAM,IACtB;AAED,MAAM,iBAAiB,CAACL,MAAcM,WAAwB,IAC3D,EAAE,KAAK,QAAQ,MAAM,KACvB;AAED,MAAM,eAAe,OAAO,CAAE;;;;AAK9B,MAAaC,eAA0B;EAErC,aAAa,eAAe;EAC5B,aAAa,WAAW;EACxB,aAAa,MAAM;EACnB,aAAa,SAAS;EACtB,aAAa,WAAW;EACxB,aAAa,SAAS;EACtB,aAAa,SAAS;EAGtB,aAAa,YAAY;EACzB,aAAa,YAAY;EACzB,aAAa,cAAc;EAC3B,aAAa,cAAc;EAC3B,aAAa,kBAAkB;EAC/B,aAAa,WAAW;EACxB,aAAa,YAAY;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFD,IAAa,wBAAb,MAEE;CACD,AAAiB;;;;;;;;CAYjB,YACCC,QACAC,qBACAC,SACC;EAED,MAAMC,kBAA6B,sBAChC;GAAE,GAAG;GAAc,GAAG;EAAqB,IAC3C;AAEH,OAAK,UAAU,IAAI,mBAClB,QACA,iBACA;CAED;;;;;;CAOD,QAAmB;AAClB,SAAO,KAAK,QAAQ,OAAO;CAC3B;AACD;;;;;;;;;;;;;;;;;;;;AClQD,SAAgB,qBACfC,QACsE;AACtE,QAAO,IAAI,sBAAsB,QAAQ,OAAO;AAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/envkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
"zod": "~4.1.13"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/lodash.set": "~4.3.9",
|
|
46
45
|
"@types/lodash.get": "~4.4.9",
|
|
47
|
-
"@types/lodash.
|
|
46
|
+
"@types/lodash.set": "~4.3.9",
|
|
47
|
+
"@types/lodash.snakecase": "~4.1.9",
|
|
48
|
+
"@types/node": "~22.0.0"
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -26,10 +26,12 @@ import {
|
|
|
26
26
|
*/
|
|
27
27
|
export class SnifferEnvironmentParser<_T extends EmptyObject = EmptyObject> {
|
|
28
28
|
private readonly accessedVars: Set<string> = new Set();
|
|
29
|
+
private readonly optionalVars: Set<string> = new Set();
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Wraps a Zod schema to always return mock values.
|
|
32
33
|
* This ensures .parse() and .safeParse() never fail.
|
|
34
|
+
* Also detects when .optional() or .default() is called to track optional vars.
|
|
33
35
|
*/
|
|
34
36
|
private wrapSchema = (schema: z.ZodType, name: string): z.ZodType => {
|
|
35
37
|
return new Proxy(schema, {
|
|
@@ -45,6 +47,11 @@ export class SnifferEnvironmentParser<_T extends EmptyObject = EmptyObject> {
|
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
// Detect .optional() or .default() — mark the variable as optional
|
|
51
|
+
if (prop === 'optional' || prop === 'default') {
|
|
52
|
+
this.optionalVars.add(name);
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
const originalProp = target[prop as keyof typeof target];
|
|
49
56
|
if (typeof originalProp === 'function') {
|
|
50
57
|
return (...args: any[]) => {
|
|
@@ -141,9 +148,24 @@ export class SnifferEnvironmentParser<_T extends EmptyObject = EmptyObject> {
|
|
|
141
148
|
|
|
142
149
|
/**
|
|
143
150
|
* Returns all environment variable names that were accessed.
|
|
151
|
+
*
|
|
152
|
+
* @param opts.markOptional - When true, optional variables (those accessed
|
|
153
|
+
* via `.optional()` or `.default()`) are suffixed with `?` (e.g. `PORT?`).
|
|
144
154
|
*/
|
|
145
|
-
getEnvironmentVariables(): string[] {
|
|
146
|
-
|
|
155
|
+
getEnvironmentVariables(opts?: { markOptional?: boolean }): string[] {
|
|
156
|
+
const vars = Array.from(this.accessedVars).sort();
|
|
157
|
+
if (!opts?.markOptional) return vars;
|
|
158
|
+
return vars.map((name) =>
|
|
159
|
+
this.optionalVars.has(name) ? `${name}?` : name,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Returns all environment variable names that were accessed via
|
|
165
|
+
* `.optional()` or `.default()` — i.e. variables that are not required.
|
|
166
|
+
*/
|
|
167
|
+
getOptionalVariables(): string[] {
|
|
168
|
+
return Array.from(this.optionalVars).sort();
|
|
147
169
|
}
|
|
148
170
|
}
|
|
149
171
|
|
|
@@ -212,8 +234,13 @@ class SnifferConfigParser<
|
|
|
212
234
|
* Result of sniffing with fire-and-forget handling.
|
|
213
235
|
*/
|
|
214
236
|
export interface SniffResult {
|
|
215
|
-
/**
|
|
237
|
+
/** All environment variable names that were accessed during sniffing */
|
|
216
238
|
envVars: string[];
|
|
239
|
+
/**
|
|
240
|
+
* Subset of envVars that are optional (accessed via `.optional()` or
|
|
241
|
+
* `.default()`). These do not need to be present for the app to start.
|
|
242
|
+
*/
|
|
243
|
+
optionalEnvVars: string[];
|
|
217
244
|
/** Error thrown during sniffing (env vars may still be captured) */
|
|
218
245
|
error?: Error;
|
|
219
246
|
/** Unhandled promise rejections captured during sniffing */
|
|
@@ -300,6 +327,7 @@ export async function sniffWithFireAndForget(
|
|
|
300
327
|
|
|
301
328
|
return {
|
|
302
329
|
envVars: sniffer.getEnvironmentVariables(),
|
|
330
|
+
optionalEnvVars: sniffer.getOptionalVariables(),
|
|
303
331
|
error,
|
|
304
332
|
unhandledRejections,
|
|
305
333
|
};
|