@geekmidas/envkit 9.0.2 → 10.0.0-alpha.1

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.
Files changed (50) hide show
  1. package/README.md +2 -2
  2. package/dist/{EnvironmentBuilder-DDgLJAAo.cjs → EnvironmentBuilder-15SdFJdK.cjs} +2 -2
  3. package/dist/EnvironmentBuilder-15SdFJdK.cjs.map +1 -0
  4. package/dist/{EnvironmentBuilder-CFen3oIg.mjs → EnvironmentBuilder-C-2fViCT.mjs} +2 -2
  5. package/dist/EnvironmentBuilder-C-2fViCT.mjs.map +1 -0
  6. package/dist/{EnvironmentBuilder-DHfDXJUm.d.mts → EnvironmentBuilder-CoBQ9Xp2.d.mts} +2 -2
  7. package/dist/{EnvironmentBuilder-CNgcdzSR.d.cts.map → EnvironmentBuilder-CoBQ9Xp2.d.mts.map} +1 -1
  8. package/dist/{EnvironmentBuilder-CNgcdzSR.d.cts → EnvironmentBuilder-DeIle4QN.d.cts} +2 -2
  9. package/dist/{EnvironmentBuilder-DHfDXJUm.d.mts.map → EnvironmentBuilder-DeIle4QN.d.cts.map} +1 -1
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +1 -1
  14. package/dist/sst.cjs +13 -6
  15. package/dist/sst.cjs.map +1 -1
  16. package/dist/sst.d.cts +15 -4
  17. package/dist/sst.d.cts.map +1 -1
  18. package/dist/sst.d.mts +15 -4
  19. package/dist/sst.d.mts.map +1 -1
  20. package/dist/sst.mjs +13 -6
  21. package/dist/sst.mjs.map +1 -1
  22. package/package.json +6 -2
  23. package/CHANGELOG.md +0 -115
  24. package/dist/EnvironmentBuilder-CFen3oIg.mjs.map +0 -1
  25. package/dist/EnvironmentBuilder-DDgLJAAo.cjs.map +0 -1
  26. package/docs/api-reference.md +0 -302
  27. package/docs/async-secrets-design.md +0 -355
  28. package/examples/basic-usage.ts +0 -386
  29. package/src/EnvironmentBuilder.ts +0 -192
  30. package/src/EnvironmentParser.ts +0 -330
  31. package/src/SnifferEnvironmentParser.ts +0 -334
  32. package/src/SstEnvValidator.ts +0 -369
  33. package/src/SstEnvironmentBuilder.ts +0 -343
  34. package/src/__tests__/ConfigParser.spec.ts +0 -394
  35. package/src/__tests__/EnvironmentBuilder.spec.ts +0 -254
  36. package/src/__tests__/EnvironmentParser.spec.ts +0 -839
  37. package/src/__tests__/SnifferEnvironmentParser.spec.ts +0 -644
  38. package/src/__tests__/SstEnvValidator.spec.ts +0 -236
  39. package/src/__tests__/SstEnvironmentBuilder.spec.ts +0 -397
  40. package/src/__tests__/credentials.integration.spec.ts +0 -239
  41. package/src/__tests__/credentials.spec.ts +0 -136
  42. package/src/__tests__/formatter.spec.ts +0 -268
  43. package/src/__tests__/sst.spec.ts +0 -437
  44. package/src/credentials.ts +0 -112
  45. package/src/formatter.ts +0 -146
  46. package/src/index.ts +0 -24
  47. package/src/sst.ts +0 -76
  48. package/sst-env.d.ts +0 -8
  49. package/tsconfig.json +0 -9
  50. package/tsdown.config.ts +0 -18
@@ -1,236 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { ResourceType } from '../SstEnvironmentBuilder';
3
- import {
4
- EnvValidationError,
5
- EnvValidator,
6
- platformEnvVars,
7
- resolveEnvKeys,
8
- } from '../sst';
9
-
10
- describe('SstEnvValidator', () => {
11
- describe('resolveEnvKeys', () => {
12
- it('derives all keys a Postgres link produces', () => {
13
- expect(resolveEnvKeys({ db: { type: ResourceType.Postgres } })).toEqual([
14
- 'DB_NAME',
15
- 'DB_HOST',
16
- 'DB_PASSWORD',
17
- 'DB_PORT',
18
- 'DB_USERNAME',
19
- 'DB_URL',
20
- ]);
21
- });
22
-
23
- it('derives the bare key a Secret link produces', () => {
24
- expect(resolveEnvKeys({ apiKey: { type: ResourceType.Secret } })).toEqual(
25
- ['API_KEY'],
26
- );
27
- });
28
-
29
- it('derives the suffixed key a Bucket link produces', () => {
30
- expect(
31
- resolveEnvKeys({ uploads: { type: ResourceType.Bucket } }),
32
- ).toEqual(['UPLOADS_NAME']);
33
- });
34
-
35
- it('derives queue keys incl. the publisher connection string', () => {
36
- expect(resolveEnvKeys({ orders: { type: ResourceType.Queue } })).toEqual([
37
- 'ORDERS_URL',
38
- 'ORDERS_ARN',
39
- 'ORDERS_PUBLISHER_CONNECTION_STRING',
40
- ]);
41
- });
42
-
43
- it('derives topic keys incl. the publisher connection string', () => {
44
- expect(
45
- resolveEnvKeys({ events: { type: ResourceType.SnsTopic } }),
46
- ).toEqual(['EVENTS_ARN', 'EVENTS_PUBLISHER_CONNECTION_STRING']);
47
- });
48
-
49
- it('derives no keys for noop resource types', () => {
50
- expect(
51
- resolveEnvKeys({
52
- fn: { type: ResourceType.Function },
53
- api: { type: ResourceType.ApiGatewayV2 },
54
- net: { type: ResourceType.Vpc },
55
- }),
56
- ).toEqual([]);
57
- });
58
-
59
- it('passes plain string entries through as a single env-cased key', () => {
60
- expect(resolveEnvKeys({ logLevel: 'debug' })).toEqual(['LOG_LEVEL']);
61
- });
62
-
63
- it('does not read resource values (keys only)', () => {
64
- const withValues = resolveEnvKeys({
65
- db: {
66
- type: ResourceType.Postgres,
67
- database: 'app',
68
- host: 'localhost',
69
- password: 'secret',
70
- port: 5432,
71
- username: 'user',
72
- },
73
- });
74
- expect(withValues).toEqual(
75
- resolveEnvKeys({ db: { type: ResourceType.Postgres } }),
76
- );
77
- });
78
-
79
- it('merges keys across multiple links', () => {
80
- const keys = resolveEnvKeys({
81
- db: { type: ResourceType.Postgres },
82
- cache: { type: ResourceType.Bucket },
83
- });
84
- expect(keys).toContain('DB_HOST');
85
- expect(keys).toContain('CACHE_NAME');
86
- });
87
- });
88
-
89
- describe('platform whitelists', () => {
90
- it('exposes per-platform runtime vars that differ', () => {
91
- expect(platformEnvVars('aws')).toContain('AWS_REGION');
92
- expect(platformEnvVars('gcp')).toContain('GOOGLE_CLOUD_PROJECT');
93
- expect(platformEnvVars('gcp')).not.toContain('AWS_REGION');
94
- });
95
-
96
- it('assumes no platform whitelist by default', () => {
97
- const validator = new EnvValidator({
98
- db: { type: ResourceType.Postgres },
99
- });
100
- expect(validator.has('AWS_REGION')).toBe(false);
101
- });
102
-
103
- it('trusts the AWS runtime vars only when platform: aws is set', () => {
104
- const validator = new EnvValidator(
105
- { db: { type: ResourceType.Postgres } },
106
- { platform: 'aws' },
107
- );
108
- expect(validator.has('AWS_REGION')).toBe(true);
109
- expect(validator.validate(['DB_HOST', 'AWS_REGION']).valid).toBe(true);
110
- });
111
-
112
- it('does not trust AWS vars when targeting gcp', () => {
113
- const validator = new EnvValidator(
114
- { db: { type: ResourceType.Postgres } },
115
- { platform: 'gcp' },
116
- );
117
- expect(validator.has('AWS_REGION')).toBe(false);
118
- expect(validator.has('GOOGLE_CLOUD_PROJECT')).toBe(true);
119
- });
120
- });
121
-
122
- describe('EnvValidator', () => {
123
- const links = {
124
- db: { type: ResourceType.Postgres },
125
- apiKey: { type: ResourceType.Secret },
126
- } as const;
127
-
128
- it('exposes available vars from links', () => {
129
- const validator = new EnvValidator(links);
130
- expect(validator.has('DB_HOST')).toBe(true);
131
- expect(validator.has('API_KEY')).toBe(true);
132
- expect(validator.has('NOT_THERE')).toBe(false);
133
- });
134
-
135
- it('validate() reports missing variables', () => {
136
- const validator = new EnvValidator(links);
137
- const result = validator.validate(['DB_HOST', 'MISSING_ONE']);
138
- expect(result.valid).toBe(false);
139
- expect(result.invalidVars).toEqual(['MISSING_ONE']);
140
- });
141
-
142
- it('validate() passes when every required var is available', () => {
143
- const validator = new EnvValidator(links);
144
- expect(validator.validate(['DB_HOST', 'DB_URL', 'API_KEY']).valid).toBe(
145
- true,
146
- );
147
- });
148
-
149
- it('treats `?`-suffixed variables as optional', () => {
150
- const validator = new EnvValidator(links);
151
- expect(validator.validate(['DB_HOST', 'SENTRY_DSN?']).valid).toBe(true);
152
- });
153
-
154
- it('honours an additional whitelist (e.g. explicit environment keys)', () => {
155
- const validator = new EnvValidator(links, { whitelist: ['APP_NAME'] });
156
- expect(validator.validate(['DB_HOST', 'APP_NAME']).valid).toBe(true);
157
- });
158
- });
159
-
160
- describe('getProvidersForEnvVars (least-privilege filtering)', () => {
161
- const validator = new EnvValidator({
162
- db: { type: ResourceType.Postgres },
163
- uploads: { type: ResourceType.Bucket },
164
- apiKey: { type: ResourceType.Secret },
165
- });
166
-
167
- it('returns only the links that provide a requested var', () => {
168
- expect(validator.getProvidersForEnvVars(['DB_HOST'])).toEqual(['db']);
169
- });
170
-
171
- it('returns multiple providers when several match', () => {
172
- const providers = validator.getProvidersForEnvVars([
173
- 'DB_URL',
174
- 'UPLOADS_NAME',
175
- ]);
176
- expect(providers).toEqual(['db', 'uploads']);
177
- });
178
-
179
- it('ignores optional `?` markers', () => {
180
- expect(validator.getProvidersForEnvVars(['API_KEY?'])).toEqual([
181
- 'apiKey',
182
- ]);
183
- });
184
-
185
- it('returns nothing when no link provides the var', () => {
186
- expect(validator.getProvidersForEnvVars(['AWS_REGION'])).toEqual([]);
187
- });
188
- });
189
-
190
- describe('did-you-mean suggestions', () => {
191
- const validator = new EnvValidator({
192
- db: { type: ResourceType.Postgres },
193
- redis: { type: ResourceType.Secret },
194
- });
195
-
196
- it('suggests a renamed match (DATABASE_URL -> DB_URL)', () => {
197
- const { suggestions } = validator.validate(['DATABASE_URL']);
198
- expect(suggestions.DATABASE_URL).toContain('DB_URL');
199
- });
200
-
201
- it('suggests a near-typo match (DB_HSOT -> DB_HOST)', () => {
202
- const { suggestions } = validator.validate(['DB_HSOT']);
203
- expect(suggestions.DB_HSOT).toContain('DB_HOST');
204
- });
205
-
206
- it('offers no suggestion for an unrelated variable', () => {
207
- const { suggestions } = validator.validate(['STRIPE_SECRET_KEY']);
208
- expect(suggestions.STRIPE_SECRET_KEY).toBeUndefined();
209
- });
210
- });
211
-
212
- describe('EnvValidationError', () => {
213
- const links = { db: { type: ResourceType.Postgres } } as const;
214
-
215
- it('assert() throws an EnvValidationError with structured fields', () => {
216
- const validator = new EnvValidator(links, { context: 'orders-fn' });
217
- try {
218
- validator.assert(['DATABASE_URL', 'DB_HOST']);
219
- expect.unreachable('assert should have thrown');
220
- } catch (error) {
221
- expect(error).toBeInstanceOf(EnvValidationError);
222
- const e = error as EnvValidationError;
223
- expect(e.missing).toEqual(['DATABASE_URL']);
224
- expect(e.context).toBe('orders-fn');
225
- expect(e.suggestions.DATABASE_URL).toContain('DB_URL');
226
- expect(e.message).toContain("'orders-fn'");
227
- expect(e.message).toContain('did you mean DB_URL?');
228
- }
229
- });
230
-
231
- it('assert() does not throw when all required vars are available', () => {
232
- const validator = new EnvValidator(links);
233
- expect(() => validator.assert(['DB_HOST', 'DB_URL'])).not.toThrow();
234
- });
235
- });
236
- });
@@ -1,397 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import {
4
- type Bucket,
5
- type Dynamo,
6
- type Postgres,
7
- ResourceType,
8
- type Secret,
9
- type SnsTopic,
10
- SstEnvironmentBuilder,
11
- sstResolvers,
12
- } from '../SstEnvironmentBuilder';
13
-
14
- describe('SstEnvironmentBuilder', () => {
15
- describe('basic functionality', () => {
16
- it('should pass through plain string values with key transformation', () => {
17
- const env = new SstEnvironmentBuilder({
18
- appName: 'my-app',
19
- nodeEnv: 'production',
20
- }).build();
21
-
22
- expect(env).toEqual({
23
- APP_NAME: 'my-app',
24
- NODE_ENV: 'production',
25
- });
26
- });
27
-
28
- it('should handle empty input', () => {
29
- const env = new SstEnvironmentBuilder({}).build();
30
- expect(env).toEqual({});
31
- });
32
- });
33
-
34
- describe('Secret resource', () => {
35
- it('should process Secret resource correctly', () => {
36
- const secret: Secret = {
37
- type: ResourceType.Secret,
38
- value: 'super-secret-value',
39
- };
40
-
41
- const env = new SstEnvironmentBuilder({
42
- mySecret: secret,
43
- }).build();
44
-
45
- expect(env).toEqual({
46
- MY_SECRET: 'super-secret-value',
47
- });
48
- });
49
-
50
- it('should process SSTSecret resource correctly', () => {
51
- const secret: Secret = {
52
- type: ResourceType.SSTSecret,
53
- value: 'another-secret',
54
- };
55
-
56
- const env = new SstEnvironmentBuilder({
57
- appSecret: secret,
58
- }).build();
59
-
60
- expect(env).toEqual({
61
- APP_SECRET: 'another-secret',
62
- });
63
- });
64
- });
65
-
66
- describe('Postgres resource', () => {
67
- it('should process Postgres resource correctly', () => {
68
- const postgres: Postgres = {
69
- type: ResourceType.Postgres,
70
- database: 'myapp',
71
- host: 'localhost',
72
- password: 'password123',
73
- port: 5432,
74
- username: 'postgres',
75
- };
76
-
77
- const env = new SstEnvironmentBuilder({
78
- database: postgres,
79
- }).build();
80
-
81
- expect(env).toEqual({
82
- DATABASE_NAME: 'myapp',
83
- DATABASE_HOST: 'localhost',
84
- DATABASE_PASSWORD: 'password123',
85
- DATABASE_PORT: 5432,
86
- DATABASE_USERNAME: 'postgres',
87
- DATABASE_URL: 'postgresql://postgres:password123@localhost:5432/myapp',
88
- });
89
- });
90
-
91
- it('should process SSTPostgres resource correctly', () => {
92
- const postgres: Postgres = {
93
- type: ResourceType.SSTPostgres,
94
- database: 'prod_db',
95
- host: 'prod.example.com',
96
- password: 'prod-password',
97
- port: 5433,
98
- username: 'prod_user',
99
- };
100
-
101
- const env = new SstEnvironmentBuilder({
102
- mainDb: postgres,
103
- }).build();
104
-
105
- expect(env).toEqual({
106
- MAIN_DB_NAME: 'prod_db',
107
- MAIN_DB_HOST: 'prod.example.com',
108
- MAIN_DB_PASSWORD: 'prod-password',
109
- MAIN_DB_PORT: 5433,
110
- MAIN_DB_USERNAME: 'prod_user',
111
- MAIN_DB_URL:
112
- 'postgresql://prod_user:prod-password@prod.example.com:5433/prod_db',
113
- });
114
- });
115
- });
116
-
117
- describe('Bucket resource', () => {
118
- it('should process Bucket resource correctly', () => {
119
- const bucket: Bucket = {
120
- type: ResourceType.Bucket,
121
- name: 'my-s3-bucket',
122
- };
123
-
124
- const env = new SstEnvironmentBuilder({
125
- uploadBucket: bucket,
126
- }).build();
127
-
128
- expect(env).toEqual({
129
- UPLOAD_BUCKET_NAME: 'my-s3-bucket',
130
- });
131
- });
132
-
133
- it('should process SSTBucket resource correctly', () => {
134
- const bucket: Bucket = {
135
- type: ResourceType.SSTBucket,
136
- name: 'assets-bucket-prod',
137
- };
138
-
139
- const env = new SstEnvironmentBuilder({
140
- assetStorage: bucket,
141
- }).build();
142
-
143
- expect(env).toEqual({
144
- ASSET_STORAGE_NAME: 'assets-bucket-prod',
145
- });
146
- });
147
- });
148
-
149
- describe('SnsTopic resource', () => {
150
- it('should process SnsTopic resource correctly', () => {
151
- const topic: SnsTopic = {
152
- type: ResourceType.SnsTopic,
153
- arn: 'arn:aws:sns:us-east-1:123456789:my-topic',
154
- };
155
-
156
- const env = new SstEnvironmentBuilder({
157
- eventsTopic: topic,
158
- }).build();
159
-
160
- expect(env).toEqual({
161
- EVENTS_TOPIC_ARN: 'arn:aws:sns:us-east-1:123456789:my-topic',
162
- EVENTS_TOPIC_PUBLISHER_CONNECTION_STRING:
163
- 'sns://?topicArn=arn%3Aaws%3Asns%3Aus-east-1%3A123456789%3Amy-topic',
164
- });
165
- });
166
- });
167
-
168
- describe('Dynamo resource', () => {
169
- it('should process legacy Dynamo resource correctly', () => {
170
- const dynamo: Dynamo = {
171
- type: ResourceType.Dynamo,
172
- name: 'my-dynamo-table',
173
- };
174
-
175
- const env = new SstEnvironmentBuilder({
176
- usersTable: dynamo,
177
- }).build();
178
-
179
- expect(env).toEqual({
180
- USERS_TABLE_NAME: 'my-dynamo-table',
181
- });
182
- });
183
-
184
- it('should process SSTDynamo resource correctly', () => {
185
- const dynamo: Dynamo = {
186
- type: ResourceType.SSTDynamo,
187
- name: 'sessions-table-prod',
188
- };
189
-
190
- const env = new SstEnvironmentBuilder({
191
- sessionsTable: dynamo,
192
- }).build();
193
-
194
- expect(env).toEqual({
195
- SESSIONS_TABLE_NAME: 'sessions-table-prod',
196
- });
197
- });
198
- });
199
-
200
- describe('noop resources', () => {
201
- it('should not add environment variables for ApiGatewayV2', () => {
202
- const env = new SstEnvironmentBuilder({
203
- api: {
204
- type: ResourceType.ApiGatewayV2,
205
- url: 'https://api.example.com',
206
- },
207
- }).build();
208
-
209
- expect(env).toEqual({});
210
- });
211
-
212
- it('should not add environment variables for Function', () => {
213
- const env = new SstEnvironmentBuilder({
214
- handler: {
215
- type: ResourceType.Function,
216
- name: 'my-lambda',
217
- },
218
- }).build();
219
-
220
- expect(env).toEqual({});
221
- });
222
-
223
- it('should not add environment variables for Vpc', () => {
224
- const env = new SstEnvironmentBuilder({
225
- network: {
226
- type: ResourceType.Vpc,
227
- bastion: 'bastion-host',
228
- },
229
- }).build();
230
-
231
- expect(env).toEqual({});
232
- });
233
- });
234
-
235
- describe('mixed resources', () => {
236
- it('should handle mix of strings and resources', () => {
237
- const postgres: Postgres = {
238
- type: ResourceType.Postgres,
239
- database: 'app_db',
240
- host: 'db.example.com',
241
- password: 'db-pass',
242
- port: 5432,
243
- username: 'app_user',
244
- };
245
-
246
- const secret: Secret = {
247
- type: ResourceType.Secret,
248
- value: 'jwt-secret',
249
- };
250
-
251
- const bucket: Bucket = {
252
- type: ResourceType.Bucket,
253
- name: 'uploads-bucket',
254
- };
255
-
256
- const topic: SnsTopic = {
257
- type: ResourceType.SnsTopic,
258
- arn: 'arn:aws:sns:us-east-1:123456789:events',
259
- };
260
-
261
- const env = new SstEnvironmentBuilder({
262
- nodeEnv: 'production',
263
- appName: 'My App',
264
- database: postgres,
265
- jwtSecret: secret,
266
- uploads: bucket,
267
- events: topic,
268
- apiVersion: 'v2',
269
- }).build();
270
-
271
- expect(env).toEqual({
272
- NODE_ENV: 'production',
273
- APP_NAME: 'My App',
274
- DATABASE_NAME: 'app_db',
275
- DATABASE_HOST: 'db.example.com',
276
- DATABASE_PASSWORD: 'db-pass',
277
- DATABASE_PORT: 5432,
278
- DATABASE_USERNAME: 'app_user',
279
- DATABASE_URL:
280
- 'postgresql://app_user:db-pass@db.example.com:5432/app_db',
281
- JWT_SECRET: 'jwt-secret',
282
- UPLOADS_NAME: 'uploads-bucket',
283
- EVENTS_ARN: 'arn:aws:sns:us-east-1:123456789:events',
284
- EVENTS_PUBLISHER_CONNECTION_STRING:
285
- 'sns://?topicArn=arn%3Aaws%3Asns%3Aus-east-1%3A123456789%3Aevents',
286
- API_VERSION: 'v2',
287
- });
288
- });
289
- });
290
-
291
- describe('additional resolvers', () => {
292
- it('should allow custom resolvers', () => {
293
- const env = new SstEnvironmentBuilder(
294
- {
295
- custom: { type: 'my-custom-type' as const, data: 'custom-data' },
296
- secret: { type: ResourceType.Secret, value: 'secret-value' },
297
- },
298
- {
299
- 'my-custom-type': (key: string, value: { data: string }) => ({
300
- [`${key}Data`]: value.data,
301
- }),
302
- },
303
- ).build();
304
-
305
- expect(env).toEqual({
306
- CUSTOM_DATA: 'custom-data',
307
- SECRET: 'secret-value',
308
- });
309
- });
310
-
311
- it('should allow custom resolvers to override built-in resolvers', () => {
312
- const env = new SstEnvironmentBuilder(
313
- {
314
- mySecret: { type: ResourceType.Secret, value: 'original-value' },
315
- },
316
- {
317
- [ResourceType.Secret]: (
318
- key: string,
319
- value: { type: string; value: string },
320
- ) => ({
321
- [`${key}Custom`]: `modified-${value.value}`,
322
- }),
323
- },
324
- ).build();
325
-
326
- expect(env).toEqual({
327
- MY_SECRET_CUSTOM: 'modified-original-value',
328
- });
329
- });
330
- });
331
-
332
- describe('edge cases', () => {
333
- it('should handle resources with special characters in keys', () => {
334
- const secret: Secret = {
335
- type: ResourceType.Secret,
336
- value: 'value',
337
- };
338
-
339
- const env = new SstEnvironmentBuilder({
340
- 'my-secret-key': secret,
341
- 'another.secret': secret,
342
- }).build();
343
-
344
- expect(env).toEqual({
345
- MY_SECRET_KEY: 'value',
346
- ANOTHER_SECRET: 'value',
347
- });
348
- });
349
-
350
- it('should preserve numeric values for postgres port', () => {
351
- const postgres: Postgres = {
352
- type: ResourceType.Postgres,
353
- database: 'test',
354
- host: 'localhost',
355
- password: 'pass',
356
- port: 5432,
357
- username: 'user',
358
- };
359
-
360
- const env = new SstEnvironmentBuilder({
361
- db: postgres,
362
- }).build();
363
-
364
- expect(env.DB_PORT).toBe(5432);
365
- expect(typeof env.DB_PORT).toBe('number');
366
- });
367
- });
368
-
369
- describe('sstResolvers export', () => {
370
- it('should export pre-configured SST resolvers', () => {
371
- expect(sstResolvers).toBeDefined();
372
- expect(typeof sstResolvers[ResourceType.Secret]).toBe('function');
373
- expect(typeof sstResolvers[ResourceType.Postgres]).toBe('function');
374
- expect(typeof sstResolvers[ResourceType.Bucket]).toBe('function');
375
- expect(typeof sstResolvers[ResourceType.SnsTopic]).toBe('function');
376
- expect(typeof sstResolvers[ResourceType.SSTDynamo]).toBe('function');
377
- });
378
- });
379
-
380
- describe('ResourceType enum', () => {
381
- it('should have all expected resource types', () => {
382
- expect(ResourceType.ApiGatewayV2).toBe('sst.aws.ApiGatewayV2');
383
- expect(ResourceType.Postgres).toBe('sst.aws.Postgres');
384
- expect(ResourceType.Function).toBe('sst.aws.Function');
385
- expect(ResourceType.Bucket).toBe('sst.aws.Bucket');
386
- expect(ResourceType.Vpc).toBe('sst.aws.Vpc');
387
- expect(ResourceType.Secret).toBe('sst.sst.Secret');
388
- expect(ResourceType.SSTSecret).toBe('sst:sst:Secret');
389
- expect(ResourceType.SSTFunction).toBe('sst:sst:Function');
390
- expect(ResourceType.SSTApiGatewayV2).toBe('sst:aws:ApiGatewayV2');
391
- expect(ResourceType.SSTPostgres).toBe('sst:aws:Postgres');
392
- expect(ResourceType.SSTBucket).toBe('sst:aws:Bucket');
393
- expect(ResourceType.SnsTopic).toBe('sst:aws:SnsTopic');
394
- expect(ResourceType.SSTDynamo).toBe('sst:aws:Dynamo');
395
- });
396
- });
397
- });