@geekmidas/envkit 1.0.1 → 1.0.3
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 +12 -0
- package/dist/{SstEnvironmentBuilder-BZngSQKQ.d.mts → SstEnvironmentBuilder-BRAcRQp2.d.mts} +12 -3
- package/dist/SstEnvironmentBuilder-BRAcRQp2.d.mts.map +1 -0
- package/dist/{SstEnvironmentBuilder-jsnqgtcW.cjs → SstEnvironmentBuilder-D-NGrp7U.cjs} +7 -2
- package/dist/SstEnvironmentBuilder-D-NGrp7U.cjs.map +1 -0
- package/dist/{SstEnvironmentBuilder-DVB7cJq4.mjs → SstEnvironmentBuilder-DOu4dVPL.mjs} +7 -2
- package/dist/SstEnvironmentBuilder-DOu4dVPL.mjs.map +1 -0
- package/dist/{SstEnvironmentBuilder-D4oSo_KX.d.cts → SstEnvironmentBuilder-Dc9nOuuK.d.cts} +12 -3
- package/dist/SstEnvironmentBuilder-Dc9nOuuK.d.cts.map +1 -0
- package/dist/SstEnvironmentBuilder.cjs +1 -1
- package/dist/SstEnvironmentBuilder.d.cts +2 -2
- package/dist/SstEnvironmentBuilder.d.mts +2 -2
- package/dist/SstEnvironmentBuilder.mjs +1 -1
- package/dist/sst.cjs +1 -1
- package/dist/sst.cjs.map +1 -1
- package/dist/sst.d.cts +2 -2
- package/dist/sst.d.cts.map +1 -1
- package/dist/sst.d.mts +2 -2
- package/dist/sst.d.mts.map +1 -1
- package/dist/sst.mjs +1 -1
- package/dist/sst.mjs.map +1 -1
- package/package.json +1 -1
- package/src/SstEnvironmentBuilder.ts +19 -1
- package/src/__tests__/SstEnvironmentBuilder.spec.ts +35 -0
- package/src/sst.ts +1 -0
- package/dist/SstEnvironmentBuilder-BZngSQKQ.d.mts.map +0 -1
- package/dist/SstEnvironmentBuilder-D4oSo_KX.d.cts.map +0 -1
- package/dist/SstEnvironmentBuilder-DVB7cJq4.mjs.map +0 -1
- package/dist/SstEnvironmentBuilder-jsnqgtcW.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @geekmidas/envkit
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ✨ [`bf094cd`](https://github.com/geekmidas/toolbox/commit/bf094cd29df2d18e75213f0976c0c9ff8047d14c) Thanks [@geekmidas](https://github.com/geekmidas)! - Add legacy dynamo resolution
|
|
8
|
+
|
|
9
|
+
## 1.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ✨ [`bfa41ad`](https://github.com/geekmidas/toolbox/commit/bfa41ad86c74c73a98e3922a536805fdf65d7607) Thanks [@geekmidas](https://github.com/geekmidas)! - Add support for dynamo links
|
|
14
|
+
|
|
3
15
|
## 1.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -13,12 +13,14 @@ declare enum ResourceType {
|
|
|
13
13
|
Bucket = "sst.aws.Bucket",
|
|
14
14
|
Vpc = "sst.aws.Vpc",
|
|
15
15
|
Secret = "sst.sst.Secret",
|
|
16
|
+
Dynamo = "sst.aws.Dynamo",
|
|
16
17
|
SSTSecret = "sst:sst:Secret",
|
|
17
18
|
SSTFunction = "sst:sst:Function",
|
|
18
19
|
SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
|
|
19
20
|
SSTPostgres = "sst:aws:Postgres",
|
|
20
21
|
SSTBucket = "sst:aws:Bucket",
|
|
21
22
|
SnsTopic = "sst:aws:SnsTopic",
|
|
23
|
+
SSTDynamo = "sst:aws:Dynamo",
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* AWS API Gateway V2 resource type.
|
|
@@ -75,10 +77,17 @@ type SnsTopic = {
|
|
|
75
77
|
type: ResourceType.SnsTopic;
|
|
76
78
|
arn: string;
|
|
77
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* AWS DynamoDB Table resource type.
|
|
82
|
+
*/
|
|
83
|
+
type Dynamo = {
|
|
84
|
+
type: ResourceType.Dynamo | ResourceType.SSTDynamo;
|
|
85
|
+
name: string;
|
|
86
|
+
};
|
|
78
87
|
/**
|
|
79
88
|
* Union type of all supported SST resource types.
|
|
80
89
|
*/
|
|
81
|
-
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic;
|
|
90
|
+
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic | Dynamo;
|
|
82
91
|
/**
|
|
83
92
|
* Function type for processing a specific resource type into environment variables.
|
|
84
93
|
*
|
|
@@ -173,5 +182,5 @@ declare class SstEnvironmentBuilder<TRecord extends Record<string, SstResource |
|
|
|
173
182
|
build(): EnvRecord;
|
|
174
183
|
}
|
|
175
184
|
//#endregion
|
|
176
|
-
export { ApiGatewayV2, Bucket, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers };
|
|
177
|
-
//# sourceMappingURL=SstEnvironmentBuilder-
|
|
185
|
+
export { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers };
|
|
186
|
+
//# sourceMappingURL=SstEnvironmentBuilder-BRAcRQp2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SstEnvironmentBuilder-BRAcRQp2.d.mts","names":[],"sources":["../src/SstEnvironmentBuilder.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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,cAAc;;;;;;;;;sBAepC,+BACc,gBAAgB,oBAC5B;;;;;;WAmBF"}
|
|
@@ -12,12 +12,14 @@ let ResourceType = /* @__PURE__ */ function(ResourceType$1) {
|
|
|
12
12
|
ResourceType$1["Bucket"] = "sst.aws.Bucket";
|
|
13
13
|
ResourceType$1["Vpc"] = "sst.aws.Vpc";
|
|
14
14
|
ResourceType$1["Secret"] = "sst.sst.Secret";
|
|
15
|
+
ResourceType$1["Dynamo"] = "sst.aws.Dynamo";
|
|
15
16
|
ResourceType$1["SSTSecret"] = "sst:sst:Secret";
|
|
16
17
|
ResourceType$1["SSTFunction"] = "sst:sst:Function";
|
|
17
18
|
ResourceType$1["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
|
|
18
19
|
ResourceType$1["SSTPostgres"] = "sst:aws:Postgres";
|
|
19
20
|
ResourceType$1["SSTBucket"] = "sst:aws:Bucket";
|
|
20
21
|
ResourceType$1["SnsTopic"] = "sst:aws:SnsTopic";
|
|
22
|
+
ResourceType$1["SSTDynamo"] = "sst:aws:Dynamo";
|
|
21
23
|
return ResourceType$1;
|
|
22
24
|
}({});
|
|
23
25
|
const secretResolver = (name, value) => ({ [name]: value.value });
|
|
@@ -30,6 +32,7 @@ const postgresResolver = (key, value) => ({
|
|
|
30
32
|
});
|
|
31
33
|
const bucketResolver = (name, value) => ({ [`${name}Name`]: value.name });
|
|
32
34
|
const topicResolver = (name, value) => ({ [`${name}Arn`]: value.arn });
|
|
35
|
+
const dynamoResolver = (name, value) => ({ [`${name}Name`]: value.name });
|
|
33
36
|
const noopResolver = () => ({});
|
|
34
37
|
/**
|
|
35
38
|
* Pre-configured resolvers for all SST resource types.
|
|
@@ -41,12 +44,14 @@ const sstResolvers = {
|
|
|
41
44
|
[ResourceType.Secret]: secretResolver,
|
|
42
45
|
[ResourceType.Postgres]: postgresResolver,
|
|
43
46
|
[ResourceType.Bucket]: bucketResolver,
|
|
47
|
+
[ResourceType.Dynamo]: dynamoResolver,
|
|
44
48
|
[ResourceType.SSTSecret]: secretResolver,
|
|
45
49
|
[ResourceType.SSTBucket]: bucketResolver,
|
|
46
50
|
[ResourceType.SSTFunction]: noopResolver,
|
|
47
51
|
[ResourceType.SSTPostgres]: postgresResolver,
|
|
48
52
|
[ResourceType.SSTApiGatewayV2]: noopResolver,
|
|
49
|
-
[ResourceType.SnsTopic]: topicResolver
|
|
53
|
+
[ResourceType.SnsTopic]: topicResolver,
|
|
54
|
+
[ResourceType.SSTDynamo]: dynamoResolver
|
|
50
55
|
};
|
|
51
56
|
/**
|
|
52
57
|
* SST-specific environment builder with built-in resolvers for all known
|
|
@@ -122,4 +127,4 @@ Object.defineProperty(exports, 'sstResolvers', {
|
|
|
122
127
|
return sstResolvers;
|
|
123
128
|
}
|
|
124
129
|
});
|
|
125
|
-
//# sourceMappingURL=SstEnvironmentBuilder-
|
|
130
|
+
//# sourceMappingURL=SstEnvironmentBuilder-D-NGrp7U.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SstEnvironmentBuilder-D-NGrp7U.cjs","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","EnvironmentBuilder"],"sources":["../src/SstEnvironmentBuilder.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"],"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,IAAIC,8CAClB,QACA,iBACA;CAED;;;;;;CAOD,QAAmB;AAClB,SAAO,KAAK,QAAQ,OAAO;CAC3B;AACD"}
|
|
@@ -12,12 +12,14 @@ let ResourceType = /* @__PURE__ */ function(ResourceType$1) {
|
|
|
12
12
|
ResourceType$1["Bucket"] = "sst.aws.Bucket";
|
|
13
13
|
ResourceType$1["Vpc"] = "sst.aws.Vpc";
|
|
14
14
|
ResourceType$1["Secret"] = "sst.sst.Secret";
|
|
15
|
+
ResourceType$1["Dynamo"] = "sst.aws.Dynamo";
|
|
15
16
|
ResourceType$1["SSTSecret"] = "sst:sst:Secret";
|
|
16
17
|
ResourceType$1["SSTFunction"] = "sst:sst:Function";
|
|
17
18
|
ResourceType$1["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
|
|
18
19
|
ResourceType$1["SSTPostgres"] = "sst:aws:Postgres";
|
|
19
20
|
ResourceType$1["SSTBucket"] = "sst:aws:Bucket";
|
|
20
21
|
ResourceType$1["SnsTopic"] = "sst:aws:SnsTopic";
|
|
22
|
+
ResourceType$1["SSTDynamo"] = "sst:aws:Dynamo";
|
|
21
23
|
return ResourceType$1;
|
|
22
24
|
}({});
|
|
23
25
|
const secretResolver = (name, value) => ({ [name]: value.value });
|
|
@@ -30,6 +32,7 @@ const postgresResolver = (key, value) => ({
|
|
|
30
32
|
});
|
|
31
33
|
const bucketResolver = (name, value) => ({ [`${name}Name`]: value.name });
|
|
32
34
|
const topicResolver = (name, value) => ({ [`${name}Arn`]: value.arn });
|
|
35
|
+
const dynamoResolver = (name, value) => ({ [`${name}Name`]: value.name });
|
|
33
36
|
const noopResolver = () => ({});
|
|
34
37
|
/**
|
|
35
38
|
* Pre-configured resolvers for all SST resource types.
|
|
@@ -41,12 +44,14 @@ const sstResolvers = {
|
|
|
41
44
|
[ResourceType.Secret]: secretResolver,
|
|
42
45
|
[ResourceType.Postgres]: postgresResolver,
|
|
43
46
|
[ResourceType.Bucket]: bucketResolver,
|
|
47
|
+
[ResourceType.Dynamo]: dynamoResolver,
|
|
44
48
|
[ResourceType.SSTSecret]: secretResolver,
|
|
45
49
|
[ResourceType.SSTBucket]: bucketResolver,
|
|
46
50
|
[ResourceType.SSTFunction]: noopResolver,
|
|
47
51
|
[ResourceType.SSTPostgres]: postgresResolver,
|
|
48
52
|
[ResourceType.SSTApiGatewayV2]: noopResolver,
|
|
49
|
-
[ResourceType.SnsTopic]: topicResolver
|
|
53
|
+
[ResourceType.SnsTopic]: topicResolver,
|
|
54
|
+
[ResourceType.SSTDynamo]: dynamoResolver
|
|
50
55
|
};
|
|
51
56
|
/**
|
|
52
57
|
* SST-specific environment builder with built-in resolvers for all known
|
|
@@ -105,4 +110,4 @@ var SstEnvironmentBuilder = class {
|
|
|
105
110
|
|
|
106
111
|
//#endregion
|
|
107
112
|
export { ResourceType, SstEnvironmentBuilder, sstResolvers };
|
|
108
|
-
//# sourceMappingURL=SstEnvironmentBuilder-
|
|
113
|
+
//# sourceMappingURL=SstEnvironmentBuilder-DOu4dVPL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SstEnvironmentBuilder-DOu4dVPL.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"],"sources":["../src/SstEnvironmentBuilder.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"],"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"}
|
|
@@ -13,12 +13,14 @@ declare enum ResourceType {
|
|
|
13
13
|
Bucket = "sst.aws.Bucket",
|
|
14
14
|
Vpc = "sst.aws.Vpc",
|
|
15
15
|
Secret = "sst.sst.Secret",
|
|
16
|
+
Dynamo = "sst.aws.Dynamo",
|
|
16
17
|
SSTSecret = "sst:sst:Secret",
|
|
17
18
|
SSTFunction = "sst:sst:Function",
|
|
18
19
|
SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
|
|
19
20
|
SSTPostgres = "sst:aws:Postgres",
|
|
20
21
|
SSTBucket = "sst:aws:Bucket",
|
|
21
22
|
SnsTopic = "sst:aws:SnsTopic",
|
|
23
|
+
SSTDynamo = "sst:aws:Dynamo",
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* AWS API Gateway V2 resource type.
|
|
@@ -75,10 +77,17 @@ type SnsTopic = {
|
|
|
75
77
|
type: ResourceType.SnsTopic;
|
|
76
78
|
arn: string;
|
|
77
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* AWS DynamoDB Table resource type.
|
|
82
|
+
*/
|
|
83
|
+
type Dynamo = {
|
|
84
|
+
type: ResourceType.Dynamo | ResourceType.SSTDynamo;
|
|
85
|
+
name: string;
|
|
86
|
+
};
|
|
78
87
|
/**
|
|
79
88
|
* Union type of all supported SST resource types.
|
|
80
89
|
*/
|
|
81
|
-
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic;
|
|
90
|
+
type SstResource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret | SnsTopic | Dynamo;
|
|
82
91
|
/**
|
|
83
92
|
* Function type for processing a specific resource type into environment variables.
|
|
84
93
|
*
|
|
@@ -173,5 +182,5 @@ declare class SstEnvironmentBuilder<TRecord extends Record<string, SstResource |
|
|
|
173
182
|
build(): EnvRecord;
|
|
174
183
|
}
|
|
175
184
|
//#endregion
|
|
176
|
-
export { ApiGatewayV2, Bucket, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers };
|
|
177
|
-
//# sourceMappingURL=SstEnvironmentBuilder-
|
|
185
|
+
export { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers };
|
|
186
|
+
//# sourceMappingURL=SstEnvironmentBuilder-Dc9nOuuK.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SstEnvironmentBuilder-Dc9nOuuK.d.cts","names":[],"sources":["../src/SstEnvironmentBuilder.ts"],"sourcesContent":[],"mappings":";;;;;;AAaA;AAw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;;KAMI,6BACY,eAAe,mDAGnB,UAAU,QAAQ;QAAmB;IAC9C,SAAS,QAAQ,oBAEb;;;;KAKH,gCAAgC,eAAe,eACnD,iBAAiB,yBACd,oCAEU,iBAAiB,WAAW,oBACrC,aAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCd,sCACI,eAAe,cAAc;;;;;;;;;sBAepC,+BACc,gBAAgB,oBAC5B;;;;;;WAmBF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_EnvironmentBuilder = require('./EnvironmentBuilder-Djr1VsWM.cjs');
|
|
2
|
-
const require_SstEnvironmentBuilder = require('./SstEnvironmentBuilder-
|
|
2
|
+
const require_SstEnvironmentBuilder = require('./SstEnvironmentBuilder-D-NGrp7U.cjs');
|
|
3
3
|
|
|
4
4
|
exports.ResourceType = require_SstEnvironmentBuilder.ResourceType;
|
|
5
5
|
exports.SstEnvironmentBuilder = require_SstEnvironmentBuilder.SstEnvironmentBuilder;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, environmentCase } from "./EnvironmentBuilder-Xuf2Dd9u.cjs";
|
|
2
|
-
import { ApiGatewayV2, Bucket, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-
|
|
3
|
-
export { ApiGatewayV2, Bucket, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, sstResolvers };
|
|
2
|
+
import { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-Dc9nOuuK.cjs";
|
|
3
|
+
export { ApiGatewayV2, Bucket, Dynamo, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, sstResolvers };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, environmentCase } from "./EnvironmentBuilder-jF-b7WQg.mjs";
|
|
2
|
-
import { ApiGatewayV2, Bucket, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-
|
|
3
|
-
export { ApiGatewayV2, Bucket, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, sstResolvers };
|
|
2
|
+
import { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-BRAcRQp2.mjs";
|
|
3
|
+
export { ApiGatewayV2, Bucket, Dynamo, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, sstResolvers };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { environmentCase } from "./EnvironmentBuilder-BSuHZm0y.mjs";
|
|
2
|
-
import { ResourceType, SstEnvironmentBuilder, sstResolvers } from "./SstEnvironmentBuilder-
|
|
2
|
+
import { ResourceType, SstEnvironmentBuilder, sstResolvers } from "./SstEnvironmentBuilder-DOu4dVPL.mjs";
|
|
3
3
|
|
|
4
4
|
export { ResourceType, SstEnvironmentBuilder, environmentCase, sstResolvers };
|
package/dist/sst.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_EnvironmentBuilder = require('./EnvironmentBuilder-Djr1VsWM.cjs');
|
|
2
|
-
const require_SstEnvironmentBuilder = require('./SstEnvironmentBuilder-
|
|
2
|
+
const require_SstEnvironmentBuilder = require('./SstEnvironmentBuilder-D-NGrp7U.cjs');
|
|
3
3
|
|
|
4
4
|
//#region src/sst.ts
|
|
5
5
|
/**
|
package/dist/sst.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sst.cjs","names":["record: Record<string, SstResource | string>","SstEnvironmentBuilder"],"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 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":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sst.cjs","names":["record: Record<string, SstResource | string>","SstEnvironmentBuilder"],"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,IAAIC,oDAAsB,QAAQ,OAAO;AAChD"}
|
package/dist/sst.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, environmentCase } from "./EnvironmentBuilder-Xuf2Dd9u.cjs";
|
|
2
|
-
import { ApiGatewayV2, Bucket, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-
|
|
2
|
+
import { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-Dc9nOuuK.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/sst.d.ts
|
|
5
5
|
|
|
@@ -26,5 +26,5 @@ declare function normalizeResourceEnv(record: Record<string, SstResource | strin
|
|
|
26
26
|
type Resource = SstResource;
|
|
27
27
|
//# sourceMappingURL=sst.d.ts.map
|
|
28
28
|
//#endregion
|
|
29
|
-
export { ApiGatewayV2, Bucket, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, normalizeResourceEnv, sstResolvers };
|
|
29
|
+
export { ApiGatewayV2, Bucket, Dynamo, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, normalizeResourceEnv, sstResolvers };
|
|
30
30
|
//# 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/sst.ts"],"sourcesContent":[],"mappings":";;;;;AAiDA;;;;;;AAES;AAQT;;;;;;;;;iBAVgB,oBAAA,SACP,eAAe,wBACrB,2CAA2C;;;;KAQlC,QAAA,GAAW"}
|
package/dist/sst.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnvRecord, EnvValue, EnvironmentBuilderOptions, environmentCase } from "./EnvironmentBuilder-jF-b7WQg.mjs";
|
|
2
|
-
import { ApiGatewayV2, Bucket, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-
|
|
2
|
+
import { ApiGatewayV2, Bucket, Dynamo, Function, Postgres, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, sstResolvers } from "./SstEnvironmentBuilder-BRAcRQp2.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/sst.d.ts
|
|
5
5
|
|
|
@@ -26,5 +26,5 @@ declare function normalizeResourceEnv(record: Record<string, SstResource | strin
|
|
|
26
26
|
type Resource = SstResource;
|
|
27
27
|
//# sourceMappingURL=sst.d.ts.map
|
|
28
28
|
//#endregion
|
|
29
|
-
export { ApiGatewayV2, Bucket, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, normalizeResourceEnv, sstResolvers };
|
|
29
|
+
export { ApiGatewayV2, Bucket, Dynamo, EnvRecord, EnvValue, EnvironmentBuilderOptions, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, SstEnvironmentBuilder, SstResource, Vpc, environmentCase, normalizeResourceEnv, sstResolvers };
|
|
30
30
|
//# 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/sst.ts"],"sourcesContent":[],"mappings":";;;;;AAiDA;;;;;;AAES;AAQT;;;;;;;;;iBAVgB,oBAAA,SACP,eAAe,wBACrB,2CAA2C;;;;KAQlC,QAAA,GAAW"}
|
package/dist/sst.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { environmentCase } from "./EnvironmentBuilder-BSuHZm0y.mjs";
|
|
2
|
-
import { ResourceType, SstEnvironmentBuilder, sstResolvers } from "./SstEnvironmentBuilder-
|
|
2
|
+
import { ResourceType, SstEnvironmentBuilder, sstResolvers } from "./SstEnvironmentBuilder-DOu4dVPL.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/sst.ts
|
|
5
5
|
/**
|
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 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":";;;;;;;;;;;;;;;;;;;;
|
|
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"}
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ export enum ResourceType {
|
|
|
19
19
|
Bucket = 'sst.aws.Bucket',
|
|
20
20
|
Vpc = 'sst.aws.Vpc',
|
|
21
21
|
Secret = 'sst.sst.Secret',
|
|
22
|
+
Dynamo = 'sst.aws.Dynamo',
|
|
22
23
|
|
|
23
24
|
// Modern format (colon notation)
|
|
24
25
|
SSTSecret = 'sst:sst:Secret',
|
|
@@ -27,6 +28,7 @@ export enum ResourceType {
|
|
|
27
28
|
SSTPostgres = 'sst:aws:Postgres',
|
|
28
29
|
SSTBucket = 'sst:aws:Bucket',
|
|
29
30
|
SnsTopic = 'sst:aws:SnsTopic',
|
|
31
|
+
SSTDynamo = 'sst:aws:Dynamo',
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -91,6 +93,14 @@ export type SnsTopic = {
|
|
|
91
93
|
arn: string;
|
|
92
94
|
};
|
|
93
95
|
|
|
96
|
+
/**
|
|
97
|
+
* AWS DynamoDB Table resource type.
|
|
98
|
+
*/
|
|
99
|
+
export type Dynamo = {
|
|
100
|
+
type: ResourceType.Dynamo | ResourceType.SSTDynamo;
|
|
101
|
+
name: string;
|
|
102
|
+
};
|
|
103
|
+
|
|
94
104
|
/**
|
|
95
105
|
* Union type of all supported SST resource types.
|
|
96
106
|
*/
|
|
@@ -101,13 +111,15 @@ export type SstResource =
|
|
|
101
111
|
| Bucket
|
|
102
112
|
| Vpc
|
|
103
113
|
| Secret
|
|
104
|
-
| SnsTopic
|
|
114
|
+
| SnsTopic
|
|
115
|
+
| Dynamo;
|
|
105
116
|
|
|
106
117
|
// Value types without the `type` key (for resolver parameters)
|
|
107
118
|
type SecretValue = Omit<Secret, 'type'>;
|
|
108
119
|
type PostgresValue = Omit<Postgres, 'type'>;
|
|
109
120
|
type BucketValue = Omit<Bucket, 'type'>;
|
|
110
121
|
type SnsTopicValue = Omit<SnsTopic, 'type'>;
|
|
122
|
+
type DynamoValue = Omit<Dynamo, 'type'>;
|
|
111
123
|
|
|
112
124
|
/**
|
|
113
125
|
* Function type for processing a specific resource type into environment variables.
|
|
@@ -141,6 +153,10 @@ const topicResolver = (name: string, value: SnsTopicValue) => ({
|
|
|
141
153
|
[`${name}Arn`]: value.arn,
|
|
142
154
|
});
|
|
143
155
|
|
|
156
|
+
const dynamoResolver = (name: string, value: DynamoValue) => ({
|
|
157
|
+
[`${name}Name`]: value.name,
|
|
158
|
+
});
|
|
159
|
+
|
|
144
160
|
const noopResolver = () => ({});
|
|
145
161
|
|
|
146
162
|
/**
|
|
@@ -154,6 +170,7 @@ export const sstResolvers: Resolvers = {
|
|
|
154
170
|
[ResourceType.Secret]: secretResolver,
|
|
155
171
|
[ResourceType.Postgres]: postgresResolver,
|
|
156
172
|
[ResourceType.Bucket]: bucketResolver,
|
|
173
|
+
[ResourceType.Dynamo]: dynamoResolver,
|
|
157
174
|
|
|
158
175
|
// Modern format
|
|
159
176
|
[ResourceType.SSTSecret]: secretResolver,
|
|
@@ -162,6 +179,7 @@ export const sstResolvers: Resolvers = {
|
|
|
162
179
|
[ResourceType.SSTPostgres]: postgresResolver,
|
|
163
180
|
[ResourceType.SSTApiGatewayV2]: noopResolver,
|
|
164
181
|
[ResourceType.SnsTopic]: topicResolver,
|
|
182
|
+
[ResourceType.SSTDynamo]: dynamoResolver,
|
|
165
183
|
};
|
|
166
184
|
|
|
167
185
|
/**
|
|
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type Bucket,
|
|
5
|
+
type Dynamo,
|
|
5
6
|
type Postgres,
|
|
6
7
|
ResourceType,
|
|
7
8
|
type Secret,
|
|
@@ -159,6 +160,38 @@ describe('SstEnvironmentBuilder', () => {
|
|
|
159
160
|
});
|
|
160
161
|
});
|
|
161
162
|
|
|
163
|
+
describe('Dynamo resource', () => {
|
|
164
|
+
it('should process legacy Dynamo resource correctly', () => {
|
|
165
|
+
const dynamo: Dynamo = {
|
|
166
|
+
type: ResourceType.Dynamo,
|
|
167
|
+
name: 'my-dynamo-table',
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const env = new SstEnvironmentBuilder({
|
|
171
|
+
usersTable: dynamo,
|
|
172
|
+
}).build();
|
|
173
|
+
|
|
174
|
+
expect(env).toEqual({
|
|
175
|
+
USERS_TABLE_NAME: 'my-dynamo-table',
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should process SSTDynamo resource correctly', () => {
|
|
180
|
+
const dynamo: Dynamo = {
|
|
181
|
+
type: ResourceType.SSTDynamo,
|
|
182
|
+
name: 'sessions-table-prod',
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const env = new SstEnvironmentBuilder({
|
|
186
|
+
sessionsTable: dynamo,
|
|
187
|
+
}).build();
|
|
188
|
+
|
|
189
|
+
expect(env).toEqual({
|
|
190
|
+
SESSIONS_TABLE_NAME: 'sessions-table-prod',
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
162
195
|
describe('noop resources', () => {
|
|
163
196
|
it('should not add environment variables for ApiGatewayV2', () => {
|
|
164
197
|
const env = new SstEnvironmentBuilder({
|
|
@@ -331,6 +364,7 @@ describe('SstEnvironmentBuilder', () => {
|
|
|
331
364
|
expect(typeof sstResolvers[ResourceType.Postgres]).toBe('function');
|
|
332
365
|
expect(typeof sstResolvers[ResourceType.Bucket]).toBe('function');
|
|
333
366
|
expect(typeof sstResolvers[ResourceType.SnsTopic]).toBe('function');
|
|
367
|
+
expect(typeof sstResolvers[ResourceType.SSTDynamo]).toBe('function');
|
|
334
368
|
});
|
|
335
369
|
});
|
|
336
370
|
|
|
@@ -348,6 +382,7 @@ describe('SstEnvironmentBuilder', () => {
|
|
|
348
382
|
expect(ResourceType.SSTPostgres).toBe('sst:aws:Postgres');
|
|
349
383
|
expect(ResourceType.SSTBucket).toBe('sst:aws:Bucket');
|
|
350
384
|
expect(ResourceType.SnsTopic).toBe('sst:aws:SnsTopic');
|
|
385
|
+
expect(ResourceType.SSTDynamo).toBe('sst:aws:Dynamo');
|
|
351
386
|
});
|
|
352
387
|
});
|
|
353
388
|
});
|
package/src/sst.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SstEnvironmentBuilder-BZngSQKQ.d.mts","names":[],"sources":["../src/SstEnvironmentBuilder.ts"],"sourcesContent":[],"mappings":";;;;;;AAaA;AAsBA;AAAwB,aAtBZ,YAAA;EAsBY,YACjB,GAAA,sBAAa;EAAY,QAAG,GAAA,kBAAa;EAAe,QAAA,GAAA,kBAAA;EAQnD,MAAA,GAAA,gBAAQ;EAAA,GAAA,GAAA,aAAA;EAAA,MACb,GAAA,gBAAa;EAAQ,SAAG,GAAA,gBAAa;EAAW,WAAA,GAAA,kBAAA;EAW3C,eAAQ,GAAA,sBAAA;EAAA,WAAA,GAAA,kBAAA;EAAA,SACb,GAAA,gBAAa;EAAQ,QAAG,GAAA,kBAAa;AAAW;AAOvD;;;;AACmD,KA9BvC,YAAA,GA8BuC;EAOvC,IAAA,EApCL,YAAA,CAAa,YAqCA,GArCe,YAAA,CAAa,eAqCzB;EAOX,GAAA,EAAA,MAAM;CAAA;;;AACiC;AAOnD;AAQY,KApDA,QAAA,GAoDW;EAAA,IAAA,EAnDhB,YAAA,CAAa,QAmDG,GAnDQ,YAAA,CAAa,WAmDrB;EAAA,QACpB,EAAA,MAAA;EAAY,IACZ,EAAA,MAAA;EAAQ,QACR,EAAA,MAAA;EAAQ,IACR,EAAA,MAAA;EAAM,QACN,EAAA,MAAA;CAAG;;AAEK;AAgBX;AAA6B,KA/DjB,QAAA,GA+DiB;EAAA,IAA4B,EA9DlD,YAAA,CAAa,QA8DqC,GA9D1B,YAAA,CAAa,WA8Da;EAAC,IAAK,EAAA,MAAA;AAAS,CAAA;AA6BxE;AAgBE;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ACZ,KAAA;;;;AAD2C,KApCxD,QAoCwD,CAAA,CAAA,CAAA,GApC1C,CAoC0C,SAAA;EAkChD,IAAA,EAAA,MAAA;CAAqB,GAtEc,IAsEd,CAtEmB,CAsEnB,EAAA,MAAA,CAAA,GAAA,KAAA;;;;KAjE7B,aAiFK,CAAA,gBAjFyB,MAiFzB,CAAA,MAAA,EAjFwC,UAiFxC,CAAA,CAAA,GAAA,QAC8B,MAjF3B,OAiF2B,GAjFjB,WAiFiB,CAjFL,OAiFK,CAjFG,CAiFH,CAAA,CAAA,EAAO,CAAA,MAhFvC,OAgFgB,CAAA;;;AAoBL;KA/Fd,iCAAiC,eAAe,eAAe,QACnE,cAAc,UACd;;;;KAMI,6BACY,eAAe,mDAGnB,UAAU,QAAQ;QAAmB;IAC9C,SAAS,QAAQ,oBAEb;;;;KAKH,gCAAgC,eAAe,eACnD,iBAAiB,yBACd,oCAEU,iBAAiB,WAAW,oBACrC,aAAa,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCd,sCACI,eAAe,cAAc;;;;;;;;;sBAepC,+BACc,gBAAgB,oBAC5B;;;;;;WAmBF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SstEnvironmentBuilder-DVB7cJq4.mjs","names":["name: string","value: SecretValue","key: string","value: PostgresValue","value: BucketValue","value: SnsTopicValue","sstResolvers: Resolvers","record: TRecord","additionalResolvers?: CustomResolvers<TRecord>","options?: EnvironmentBuilderOptions","mergedResolvers: Resolvers"],"sources":["../src/SstEnvironmentBuilder.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\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}\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 * 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\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'>;\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 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\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};\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"],"mappings":";;;;;;;AAaA,IAAY,wDAAL;AAEN;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA;AA8FD,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,eAAe,OAAO,CAAE;;;;AAK9B,MAAaC,eAA0B;EAErC,aAAa,eAAe;EAC5B,aAAa,WAAW;EACxB,aAAa,MAAM;EACnB,aAAa,SAAS;EACtB,aAAa,WAAW;EACxB,aAAa,SAAS;EAGtB,aAAa,YAAY;EACzB,aAAa,YAAY;EACzB,aAAa,cAAc;EAC3B,aAAa,cAAc;EAC3B,aAAa,kBAAkB;EAC/B,aAAa,WAAW;AACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SstEnvironmentBuilder-jsnqgtcW.cjs","names":["name: string","value: SecretValue","key: string","value: PostgresValue","value: BucketValue","value: SnsTopicValue","sstResolvers: Resolvers","record: TRecord","additionalResolvers?: CustomResolvers<TRecord>","options?: EnvironmentBuilderOptions","mergedResolvers: Resolvers","EnvironmentBuilder"],"sources":["../src/SstEnvironmentBuilder.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\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}\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 * 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\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'>;\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 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\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};\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"],"mappings":";;;;;;;AAaA,IAAY,wDAAL;AAEN;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;;AACA;AA8FD,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,eAAe,OAAO,CAAE;;;;AAK9B,MAAaC,eAA0B;EAErC,aAAa,eAAe;EAC5B,aAAa,WAAW;EACxB,aAAa,MAAM;EACnB,aAAa,SAAS;EACtB,aAAa,WAAW;EACxB,aAAa,SAAS;EAGtB,aAAa,YAAY;EACzB,aAAa,YAAY;EACzB,aAAa,cAAc;EAC3B,aAAa,cAAc;EAC3B,aAAa,kBAAkB;EAC/B,aAAa,WAAW;AACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFD,IAAa,wBAAb,MAEE;CACD,AAAiB;;;;;;;;CAYjB,YACCC,QACAC,qBACAC,SACC;EAED,MAAMC,kBAA6B,sBAChC;GAAE,GAAG;GAAc,GAAG;EAAqB,IAC3C;AAEH,OAAK,UAAU,IAAIC,8CAClB,QACA,iBACA;CAED;;;;;;CAOD,QAAmB;AAClB,SAAO,KAAK,QAAQ,OAAO;CAC3B;AACD"}
|