@geekmidas/cloud 10.0.0-alpha.98 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +6 -14
  2. package/dist/index-ByEJy40r.d.cts +56 -0
  3. package/dist/index-ByEJy40r.d.cts.map +1 -0
  4. package/dist/index-DZ0QrJQr.d.mts +56 -0
  5. package/dist/index-DZ0QrJQr.d.mts.map +1 -0
  6. package/dist/index.cjs +3 -3
  7. package/dist/index.d.cts +1 -1
  8. package/dist/index.d.mts +1 -1
  9. package/dist/index.mjs +3 -2
  10. package/dist/utils/index.cjs +5 -106
  11. package/dist/utils/index.d.cts +2 -62
  12. package/dist/utils/index.d.mts +2 -62
  13. package/dist/utils/index.mjs +2 -78
  14. package/dist/utils-BdKG20_m.mjs +83 -0
  15. package/dist/utils-BdKG20_m.mjs.map +1 -0
  16. package/dist/utils-CtMjuIMR.cjs +129 -0
  17. package/dist/utils-CtMjuIMR.cjs.map +1 -0
  18. package/package.json +9 -47
  19. package/src/sst/{aws/Api.ts → Api.ts} +47 -19
  20. package/src/sst/{aws/Cron.ts → Cron.ts} +46 -6
  21. package/src/sst/{aws/Function.ts → Function.ts} +41 -12
  22. package/src/sst/Queue.ts +46 -0
  23. package/src/sst/{aws/Storage.ts → Storage.ts} +3 -3
  24. package/src/sst/Topic.ts +37 -0
  25. package/src/sst/__tests__/LinkedEnvironment.spec.ts +1 -4
  26. package/src/sst/__type-tests__/authorizers.type-test.ts +2 -2
  27. package/src/sst/__type-tests__/manifest.type-test.ts +77 -0
  28. package/src/sst/__type-tests__/messaging.type-test.ts +3 -3
  29. package/src/sst/__type-tests__/storage.type-test.ts +2 -2
  30. package/src/sst/index.ts +7 -67
  31. package/src/sst/naming.ts +16 -37
  32. package/src/sst/tsconfig.json +2 -2
  33. package/dist/utils/index.cjs.map +0 -1
  34. package/dist/utils/index.d.cts.map +0 -1
  35. package/dist/utils/index.d.mts.map +0 -1
  36. package/dist/utils/index.mjs.map +0 -1
  37. package/src/dokploy/Application.ts +0 -306
  38. package/src/dokploy/__tests__/Application.provider.spec.ts +0 -206
  39. package/src/dokploy/__tests__/Application.spec.ts +0 -69
  40. package/src/dokploy/index.ts +0 -18
  41. package/src/sst/__tests__/api.spec.ts +0 -185
  42. package/src/sst/__tests__/backends.spec.ts +0 -249
  43. package/src/sst/__tests__/bootstrap.spec.ts +0 -140
  44. package/src/sst/__tests__/database.spec.ts +0 -119
  45. package/src/sst/__tests__/encryption.spec.ts +0 -90
  46. package/src/sst/__tests__/fromManifest.integration.spec.ts +0 -427
  47. package/src/sst/__tests__/fromManifest.spec.ts +0 -567
  48. package/src/sst/__tests__/function.spec.ts +0 -121
  49. package/src/sst/__tests__/links.spec.ts +0 -209
  50. package/src/sst/__tests__/provides.spec.ts +0 -107
  51. package/src/sst/__tests__/ses.spec.ts +0 -93
  52. package/src/sst/__tests__/surfaces.spec.ts +0 -149
  53. package/src/sst/__type-tests__/overrides.type-test.ts +0 -152
  54. package/src/sst/aws/Cache.ts +0 -259
  55. package/src/sst/aws/Credential.ts +0 -61
  56. package/src/sst/aws/Database.ts +0 -204
  57. package/src/sst/aws/DatabaseBootstrap.ts +0 -312
  58. package/src/sst/aws/DerivedDatabase.ts +0 -117
  59. package/src/sst/aws/Email.ts +0 -181
  60. package/src/sst/aws/Encryption.ts +0 -91
  61. package/src/sst/aws/ExternalApi.ts +0 -58
  62. package/src/sst/aws/FileServer.ts +0 -82
  63. package/src/sst/aws/ObjectStorage.ts +0 -76
  64. package/src/sst/aws/Queue.ts +0 -149
  65. package/src/sst/aws/RestApiSurface.ts +0 -114
  66. package/src/sst/aws/Secret.ts +0 -76
  67. package/src/sst/aws/StaticSite.ts +0 -92
  68. package/src/sst/aws/Topic.ts +0 -68
  69. package/src/sst/aws/bootstrap/handler.ts +0 -119
  70. package/src/sst/aws/ses.ts +0 -132
  71. package/src/sst/errors.ts +0 -65
  72. package/src/sst/fromManifest.ts +0 -1116
  73. package/src/sst/overrides.ts +0 -133
  74. package/src/sst/upstash.d.ts +0 -38
package/README.md CHANGED
@@ -105,25 +105,17 @@ const cron = new Cron(stack, 'Nightly', { processor: fn, schedule: 'rate(1 day)'
105
105
 
106
106
  ### From a `gkm build` manifest
107
107
 
108
- The root `gkm build` writes the application's manifest to
109
- `.gkm/manifest/aws.ts` (types in `@geekmidas/manifest`), and `fromManifest`
110
- maps it straight into infra:
108
+ `gkm build` emits a deployment manifest (types in `@geekmidas/manifest`). Each
109
+ construct has a static `fromManifest` factory that maps it straight into infra:
111
110
 
112
111
  ```ts
113
- // sst.config.ts
114
- const { App, fromManifest, Stack } = await import('@geekmidas/cloud/sst');
115
- const { backends, constructs } = await import('./.gkm/manifest/aws.js');
112
+ import routes from './.gkm/routes-manifest.json';
116
113
 
117
- fromManifest(new Stack(app, 'Shop'), constructs, { Database: { vpc } }, backends);
114
+ const api = Api.fromManifest(stack, 'Api', routes, { links: [db], authorizers });
115
+ const workers = Function.fromManifest(stack, functionsManifest, { links: [db] });
116
+ const crons = Cron.fromManifest(stack, cronsManifest, { links: [db] });
118
117
  ```
119
118
 
120
- `constructs` is every declared construct keyed by id; the overrides are keyed
121
- by the same ids. One call provisions the resources, each `RestApi`'s endpoints
122
- (each a Lambda linked only to its own dependencies, placed in the database's
123
- VPC when it reaches one, with the `iam` authorizer enforced by the gateway),
124
- queue consumers, every function (a Lambda with an IAM-authorized URL) and every
125
- cron (a Lambda on its schedule).
126
-
127
119
  ## `@geekmidas/cloud/utils` (runtime)
128
120
 
129
121
  ```ts
@@ -0,0 +1,56 @@
1
+ //#region src/utils/index.d.ts
2
+ declare function getLocalIpAddress(): string | null;
3
+ declare function environmentCase(name: string): string;
4
+ declare enum ResourceType {
5
+ ApiGatewayV2 = "sst.aws.ApiGatewayV2",
6
+ Postgres = "sst.aws.Postgres",
7
+ Function = "sst.aws.Function",
8
+ Bucket = "sst.aws.Bucket",
9
+ Vpc = "sst.aws.Vpc",
10
+ Secret = "sst.sst.Secret",
11
+ SSTSecret = "sst:sst:Secret",
12
+ SSTFunction = "sst:sst:Function",
13
+ SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
14
+ SSTPostgres = "sst:aws:Postgres",
15
+ SSTBucket = "sst:aws:Bucket",
16
+ SnsTopic = "sst:aws:SnsTopic",
17
+ }
18
+ declare function buildResourceEnv(record: Record<string, Resource | string>): Record<string, string>;
19
+ type ApiGatewayV2 = {
20
+ type: ResourceType.ApiGatewayV2;
21
+ url: string;
22
+ };
23
+ type Postgres = {
24
+ database: string;
25
+ host: string;
26
+ password: string;
27
+ port: number;
28
+ type: ResourceType.Postgres;
29
+ username: string;
30
+ };
31
+ type Function = {
32
+ name: string;
33
+ type: ResourceType.Function;
34
+ };
35
+ type Bucket = {
36
+ name: string;
37
+ type: ResourceType.Bucket;
38
+ };
39
+ type SnsTopic = {
40
+ arn: string;
41
+ type: ResourceType.SnsTopic;
42
+ };
43
+ type Vpc = {
44
+ bastion: string;
45
+ type: ResourceType.Vpc;
46
+ };
47
+ type Secret = {
48
+ type: ResourceType.Secret;
49
+ value: string;
50
+ };
51
+ type Resource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret;
52
+ type ResourceProcessor<K extends Resource> = (name: string, value: K) => Record<string, string | number>;
53
+ //# sourceMappingURL=index.d.ts.map
54
+ //#endregion
55
+ export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
56
+ //# sourceMappingURL=index-ByEJy40r.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ByEJy40r.d.cts","names":[],"sources":["../src/utils/index.ts"],"sourcesContent":[],"mappings":";iBAGgB,iBAAA,CAAA;AAAA,iBAcA,eAAA,CAdiB,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAcjB,aAOJ,YAAA;EAAA,YAAA,GAAY,sBAAA;EA+DR,QAAA,GAAA,kBAAgB;EAAA,QAAA,GAAA,kBAAA;EAAA,MACR,GAAA,gBAAA;EAAQ,GAAvB,GAAA,aAAA;EAAM,MACZ,GAAA,gBAAA;EAAM,SAAA,GAAA,gBAAA;EAkBG,WAAA,GAAA,kBACL;EAIK,eAAQ,GAAA,sBAKA;EAIR,WAAQ,GAAA,kBAEb;EAGK,SAAM,GAAA,gBAEX;EAGK,QAAA,GAAQ,kBAEb;AAGP;AAKY,iBAtDI,gBAAA,CAuDI,MAAM,EAtDjB,MAsDiB,CAAA,MAAA,EAtDF,QAsDE,GAAA,MAAA,CAAA,CAAA,EArDvB,MAqDuB,CAAA,MAAA,EAAA,MAAA,CAAA;AAId,KAvCA,YAAA,GAuCQ;EAAA,IAAA,EAtCb,YAAA,CAAa,YAsCA;EAAA,GACjB,EAAA,MAAA;CAAY;AAEZ,KArCS,QAAA,GAqCT;EAAQ,QACR,EAAA,MAAA;EAAM,IACN,EAAA,MAAA;EAAG,QACH,EAAA,MAAA;EAAM,IAAA,EAAA,MAAA;EAEG,IAAA,EArCL,YAAA,CAAa,QAqCS;EAAA,QAAA,EAAA,MAAA;CAAA;AAErB,KAnCI,QAAA,GAmCJ;EAAC,IACJ,EAAA,MAAA;EAAM,IAAA,EAlCJ,YAAA,CAAa,QAkCT;;KA/BC,MAAA;;QAEL,YAAA,CAAa;;KAGR,QAAA;;QAEL,YAAA,CAAa;;KAGR,GAAA;;QAEL,YAAA,CAAa;;KAGR,MAAA;QACL,YAAA,CAAa;;;KAIR,QAAA,GACT,eACA,WACA,WACA,SACA,MACA;KAES,4BAA4B,kCAEhC,MACH"}
@@ -0,0 +1,56 @@
1
+ //#region src/utils/index.d.ts
2
+ declare function getLocalIpAddress(): string | null;
3
+ declare function environmentCase(name: string): string;
4
+ declare enum ResourceType {
5
+ ApiGatewayV2 = "sst.aws.ApiGatewayV2",
6
+ Postgres = "sst.aws.Postgres",
7
+ Function = "sst.aws.Function",
8
+ Bucket = "sst.aws.Bucket",
9
+ Vpc = "sst.aws.Vpc",
10
+ Secret = "sst.sst.Secret",
11
+ SSTSecret = "sst:sst:Secret",
12
+ SSTFunction = "sst:sst:Function",
13
+ SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
14
+ SSTPostgres = "sst:aws:Postgres",
15
+ SSTBucket = "sst:aws:Bucket",
16
+ SnsTopic = "sst:aws:SnsTopic",
17
+ }
18
+ declare function buildResourceEnv(record: Record<string, Resource | string>): Record<string, string>;
19
+ type ApiGatewayV2 = {
20
+ type: ResourceType.ApiGatewayV2;
21
+ url: string;
22
+ };
23
+ type Postgres = {
24
+ database: string;
25
+ host: string;
26
+ password: string;
27
+ port: number;
28
+ type: ResourceType.Postgres;
29
+ username: string;
30
+ };
31
+ type Function = {
32
+ name: string;
33
+ type: ResourceType.Function;
34
+ };
35
+ type Bucket = {
36
+ name: string;
37
+ type: ResourceType.Bucket;
38
+ };
39
+ type SnsTopic = {
40
+ arn: string;
41
+ type: ResourceType.SnsTopic;
42
+ };
43
+ type Vpc = {
44
+ bastion: string;
45
+ type: ResourceType.Vpc;
46
+ };
47
+ type Secret = {
48
+ type: ResourceType.Secret;
49
+ value: string;
50
+ };
51
+ type Resource = ApiGatewayV2 | Postgres | Function | Bucket | Vpc | Secret;
52
+ type ResourceProcessor<K extends Resource> = (name: string, value: K) => Record<string, string | number>;
53
+ //# sourceMappingURL=index.d.ts.map
54
+ //#endregion
55
+ export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
56
+ //# sourceMappingURL=index-DZ0QrJQr.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DZ0QrJQr.d.mts","names":[],"sources":["../src/utils/index.ts"],"sourcesContent":[],"mappings":";iBAGgB,iBAAA,CAAA;AAAA,iBAcA,eAAA,CAdiB,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AAcjB,aAOJ,YAAA;EAAA,YAAA,GAAY,sBAAA;EA+DR,QAAA,GAAA,kBAAgB;EAAA,QAAA,GAAA,kBAAA;EAAA,MACR,GAAA,gBAAA;EAAQ,GAAvB,GAAA,aAAA;EAAM,MACZ,GAAA,gBAAA;EAAM,SAAA,GAAA,gBAAA;EAkBG,WAAA,GAAA,kBACL;EAIK,eAAQ,GAAA,sBAKA;EAIR,WAAQ,GAAA,kBAEb;EAGK,SAAM,GAAA,gBAEX;EAGK,QAAA,GAAQ,kBAEb;AAGP;AAKY,iBAtDI,gBAAA,CAuDI,MAAM,EAtDjB,MAsDiB,CAAA,MAAA,EAtDF,QAsDE,GAAA,MAAA,CAAA,CAAA,EArDvB,MAqDuB,CAAA,MAAA,EAAA,MAAA,CAAA;AAId,KAvCA,YAAA,GAuCQ;EAAA,IAAA,EAtCb,YAAA,CAAa,YAsCA;EAAA,GACjB,EAAA,MAAA;CAAY;AAEZ,KArCS,QAAA,GAqCT;EAAQ,QACR,EAAA,MAAA;EAAM,IACN,EAAA,MAAA;EAAG,QACH,EAAA,MAAA;EAAM,IAAA,EAAA,MAAA;EAEG,IAAA,EArCL,YAAA,CAAa,QAqCS;EAAA,QAAA,EAAA,MAAA;CAAA;AAErB,KAnCI,QAAA,GAmCJ;EAAC,IACJ,EAAA,MAAA;EAAM,IAAA,EAlCJ,YAAA,CAAa,QAkCT;;KA/BC,MAAA;;QAEL,YAAA,CAAa;;KAGR,QAAA;;QAEL,YAAA,CAAa;;KAGR,GAAA;;QAEL,YAAA,CAAa;;KAGR,MAAA;QACL,YAAA,CAAa;;;KAIR,QAAA,GACT,eACA,WACA,WACA,SACA,MACA;KAES,4BAA4B,kCAEhC,MACH"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils_index = require("./utils/index.cjs");
3
- exports.buildResourceEnv = require_utils_index.buildResourceEnv;
1
+ const require_utils = require('./utils-CtMjuIMR.cjs');
2
+
3
+ exports.buildResourceEnv = require_utils.buildResourceEnv;
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { buildResourceEnv } from "./utils/index.cjs";
1
+ import { buildResourceEnv } from "./index-ByEJy40r.cjs";
2
2
  export { buildResourceEnv };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { buildResourceEnv } from "./utils/index.mjs";
1
+ import { buildResourceEnv } from "./index-DZ0QrJQr.mjs";
2
2
  export { buildResourceEnv };
package/dist/index.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import { buildResourceEnv } from "./utils/index.mjs";
2
- export { buildResourceEnv };
1
+ import { buildResourceEnv } from "./utils-BdKG20_m.mjs";
2
+
3
+ export { buildResourceEnv };
@@ -1,107 +1,6 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- //#endregion
24
- let node_os = require("node:os");
25
- node_os = __toESM(node_os, 1);
26
- let lodash_snakecase = require("lodash.snakecase");
27
- lodash_snakecase = __toESM(lodash_snakecase, 1);
28
- //#region src/utils/index.ts
29
- function getLocalIpAddress() {
30
- const networkInterfaces = node_os.default.networkInterfaces();
31
- for (const interfaceName in networkInterfaces) {
32
- const addresses = networkInterfaces[interfaceName] || [];
33
- for (const addressInfo of addresses) if (addressInfo.family === "IPv4" && !addressInfo.internal) return addressInfo.address;
34
- }
35
- return null;
36
- }
37
- function environmentCase(name) {
38
- return (0, lodash_snakecase.default)(name).toUpperCase().replace(/_\d+/g, (r) => {
39
- return r.replace("_", "");
40
- });
41
- }
42
- let ResourceType = /* @__PURE__ */ function(ResourceType) {
43
- ResourceType["ApiGatewayV2"] = "sst.aws.ApiGatewayV2";
44
- ResourceType["Postgres"] = "sst.aws.Postgres";
45
- ResourceType["Function"] = "sst.aws.Function";
46
- ResourceType["ObjectStorage"] = "sst.aws.Bucket";
47
- ResourceType["Vpc"] = "sst.aws.Vpc";
48
- ResourceType["Secret"] = "sst.sst.Secret";
49
- ResourceType["SSTSecret"] = "sst:sst:Secret";
50
- ResourceType["SSTFunction"] = "sst:sst:Function";
51
- ResourceType["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
52
- ResourceType["SSTPostgres"] = "sst:aws:Postgres";
53
- ResourceType["SSTObjectStorage"] = "sst:aws:Bucket";
54
- ResourceType["SnsTopic"] = "sst:aws:SnsTopic";
55
- return ResourceType;
56
- }({});
57
- const secret = (name, value) => ({ [environmentCase(name)]: value.value });
58
- const postgres = (key, value) => {
59
- const prefix = `${environmentCase(key)}`;
60
- return {
61
- [`${prefix}_NAME`]: value.database,
62
- [`${prefix}_HOST`]: value.host,
63
- [`${prefix}_PASSWORD`]: value.password,
64
- [`${prefix}_PORT`]: value.port,
65
- [`${prefix}_USERNAME`]: value.username
66
- };
67
- };
68
- const bucket = (name, value) => {
69
- return { [`${`${environmentCase(name)}`}_NAME`]: value.name };
70
- };
71
- const topic = (name, value) => {
72
- return { [`${`${environmentCase(name)}`}_ARN`]: value.arn };
73
- };
74
- const noop = (_name, _value) => ({});
75
- const processors = {
76
- ["sst.aws.ApiGatewayV2"]: noop,
77
- ["sst.aws.Function"]: noop,
78
- ["sst.aws.Vpc"]: noop,
79
- ["sst.sst.Secret"]: secret,
80
- ["sst.aws.Postgres"]: postgres,
81
- ["sst.aws.Bucket"]: bucket,
82
- ["sst:sst:Secret"]: secret,
83
- ["sst:aws:Bucket"]: bucket,
84
- ["sst:sst:Function"]: noop,
85
- ["sst:aws:Postgres"]: postgres,
86
- ["sst:aws:ApiGatewayV2"]: noop,
87
- ["sst:aws:SnsTopic"]: topic
88
- };
89
- function buildResourceEnv(record) {
90
- const env = {};
91
- for (const [k, value] of Object.entries(record)) {
92
- if (typeof value === "string") {
93
- env[environmentCase(k)] = value;
94
- continue;
95
- }
96
- const processor = processors[value.type];
97
- if (processor) Object.assign(env, processor(k, value));
98
- }
99
- return env;
100
- }
101
- //#endregion
102
- exports.ResourceType = ResourceType;
103
- exports.buildResourceEnv = buildResourceEnv;
104
- exports.environmentCase = environmentCase;
105
- exports.getLocalIpAddress = getLocalIpAddress;
1
+ const require_utils = require('../utils-CtMjuIMR.cjs');
106
2
 
107
- //# sourceMappingURL=index.cjs.map
3
+ exports.ResourceType = require_utils.ResourceType;
4
+ exports.buildResourceEnv = require_utils.buildResourceEnv;
5
+ exports.environmentCase = require_utils.environmentCase;
6
+ exports.getLocalIpAddress = require_utils.getLocalIpAddress;
@@ -1,62 +1,2 @@
1
- //#region src/utils/index.d.ts
2
- export declare function getLocalIpAddress(): string | null;
3
- export declare function environmentCase(name: string): string;
4
- export declare enum ResourceType {
5
- ApiGatewayV2 = "sst.aws.ApiGatewayV2",
6
- Postgres = "sst.aws.Postgres",
7
- Function = "sst.aws.Function",
8
- ObjectStorage = "sst.aws.Bucket",
9
- Vpc = "sst.aws.Vpc",
10
- Secret = "sst.sst.Secret",
11
- SSTSecret = "sst:sst:Secret",
12
- SSTFunction = "sst:sst:Function",
13
- SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
14
- SSTPostgres = "sst:aws:Postgres",
15
- SSTObjectStorage = "sst:aws:Bucket",
16
- SnsTopic = "sst:aws:SnsTopic"
17
- }
18
- export declare function buildResourceEnv(record: Record<string, Resource | string>): Record<string, string>;
19
- /**
20
- * SST links a resource under one of two spellings — `sst.aws.Bucket` when it
21
- * comes from the state file, `sst:aws:Bucket` when it comes from the runtime —
22
- * and `processors` has always handled both. Only the dotted half was admitted
23
- * here, so the colon half could not be passed to `buildResourceEnv` without a
24
- * cast, and `SnsTopic` was missing from `Resource` altogether despite being the
25
- * only thing that produces `*_ARN`.
26
- */
27
- export type ApiGatewayV2 = {
28
- type: ResourceType.ApiGatewayV2 | ResourceType.SSTApiGatewayV2;
29
- url: string;
30
- };
31
- export type Postgres = {
32
- database: string;
33
- host: string;
34
- password: string;
35
- port: number;
36
- type: ResourceType.Postgres | ResourceType.SSTPostgres;
37
- username: string;
38
- };
39
- export type Function = {
40
- name: string;
41
- type: ResourceType.Function | ResourceType.SSTFunction;
42
- };
43
- export type Bucket = {
44
- name: string;
45
- type: ResourceType.ObjectStorage | ResourceType.SSTObjectStorage;
46
- };
47
- export type SnsTopic = {
48
- arn: string;
49
- type: ResourceType.SnsTopic;
50
- };
51
- export type Vpc = {
52
- bastion: string;
53
- type: ResourceType.Vpc;
54
- };
55
- export type Secret = {
56
- type: ResourceType.Secret | ResourceType.SSTSecret;
57
- value: string;
58
- };
59
- export type Resource = ApiGatewayV2 | Postgres | Function | Bucket | SnsTopic | Vpc | Secret;
60
- export type ResourceProcessor<K extends Resource> = (name: string, value: K) => Record<string, string | number>;
61
- //#endregion
62
- //# sourceMappingURL=index.d.cts.map
1
+ import { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress } from "../index-ByEJy40r.cjs";
2
+ export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
@@ -1,62 +1,2 @@
1
- //#region src/utils/index.d.ts
2
- export declare function getLocalIpAddress(): string | null;
3
- export declare function environmentCase(name: string): string;
4
- export declare enum ResourceType {
5
- ApiGatewayV2 = "sst.aws.ApiGatewayV2",
6
- Postgres = "sst.aws.Postgres",
7
- Function = "sst.aws.Function",
8
- ObjectStorage = "sst.aws.Bucket",
9
- Vpc = "sst.aws.Vpc",
10
- Secret = "sst.sst.Secret",
11
- SSTSecret = "sst:sst:Secret",
12
- SSTFunction = "sst:sst:Function",
13
- SSTApiGatewayV2 = "sst:aws:ApiGatewayV2",
14
- SSTPostgres = "sst:aws:Postgres",
15
- SSTObjectStorage = "sst:aws:Bucket",
16
- SnsTopic = "sst:aws:SnsTopic"
17
- }
18
- export declare function buildResourceEnv(record: Record<string, Resource | string>): Record<string, string>;
19
- /**
20
- * SST links a resource under one of two spellings — `sst.aws.Bucket` when it
21
- * comes from the state file, `sst:aws:Bucket` when it comes from the runtime —
22
- * and `processors` has always handled both. Only the dotted half was admitted
23
- * here, so the colon half could not be passed to `buildResourceEnv` without a
24
- * cast, and `SnsTopic` was missing from `Resource` altogether despite being the
25
- * only thing that produces `*_ARN`.
26
- */
27
- export type ApiGatewayV2 = {
28
- type: ResourceType.ApiGatewayV2 | ResourceType.SSTApiGatewayV2;
29
- url: string;
30
- };
31
- export type Postgres = {
32
- database: string;
33
- host: string;
34
- password: string;
35
- port: number;
36
- type: ResourceType.Postgres | ResourceType.SSTPostgres;
37
- username: string;
38
- };
39
- export type Function = {
40
- name: string;
41
- type: ResourceType.Function | ResourceType.SSTFunction;
42
- };
43
- export type Bucket = {
44
- name: string;
45
- type: ResourceType.ObjectStorage | ResourceType.SSTObjectStorage;
46
- };
47
- export type SnsTopic = {
48
- arn: string;
49
- type: ResourceType.SnsTopic;
50
- };
51
- export type Vpc = {
52
- bastion: string;
53
- type: ResourceType.Vpc;
54
- };
55
- export type Secret = {
56
- type: ResourceType.Secret | ResourceType.SSTSecret;
57
- value: string;
58
- };
59
- export type Resource = ApiGatewayV2 | Postgres | Function | Bucket | SnsTopic | Vpc | Secret;
60
- export type ResourceProcessor<K extends Resource> = (name: string, value: K) => Record<string, string | number>;
61
- //#endregion
62
- //# sourceMappingURL=index.d.mts.map
1
+ import { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress } from "../index-DZ0QrJQr.mjs";
2
+ export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
@@ -1,79 +1,3 @@
1
- import os from "node:os";
2
- import snakecase from "lodash.snakecase";
3
- //#region src/utils/index.ts
4
- function getLocalIpAddress() {
5
- const networkInterfaces = os.networkInterfaces();
6
- for (const interfaceName in networkInterfaces) {
7
- const addresses = networkInterfaces[interfaceName] || [];
8
- for (const addressInfo of addresses) if (addressInfo.family === "IPv4" && !addressInfo.internal) return addressInfo.address;
9
- }
10
- return null;
11
- }
12
- function environmentCase(name) {
13
- return snakecase(name).toUpperCase().replace(/_\d+/g, (r) => {
14
- return r.replace("_", "");
15
- });
16
- }
17
- let ResourceType = /* @__PURE__ */ function(ResourceType) {
18
- ResourceType["ApiGatewayV2"] = "sst.aws.ApiGatewayV2";
19
- ResourceType["Postgres"] = "sst.aws.Postgres";
20
- ResourceType["Function"] = "sst.aws.Function";
21
- ResourceType["ObjectStorage"] = "sst.aws.Bucket";
22
- ResourceType["Vpc"] = "sst.aws.Vpc";
23
- ResourceType["Secret"] = "sst.sst.Secret";
24
- ResourceType["SSTSecret"] = "sst:sst:Secret";
25
- ResourceType["SSTFunction"] = "sst:sst:Function";
26
- ResourceType["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
27
- ResourceType["SSTPostgres"] = "sst:aws:Postgres";
28
- ResourceType["SSTObjectStorage"] = "sst:aws:Bucket";
29
- ResourceType["SnsTopic"] = "sst:aws:SnsTopic";
30
- return ResourceType;
31
- }({});
32
- const secret = (name, value) => ({ [environmentCase(name)]: value.value });
33
- const postgres = (key, value) => {
34
- const prefix = `${environmentCase(key)}`;
35
- return {
36
- [`${prefix}_NAME`]: value.database,
37
- [`${prefix}_HOST`]: value.host,
38
- [`${prefix}_PASSWORD`]: value.password,
39
- [`${prefix}_PORT`]: value.port,
40
- [`${prefix}_USERNAME`]: value.username
41
- };
42
- };
43
- const bucket = (name, value) => {
44
- return { [`${`${environmentCase(name)}`}_NAME`]: value.name };
45
- };
46
- const topic = (name, value) => {
47
- return { [`${`${environmentCase(name)}`}_ARN`]: value.arn };
48
- };
49
- const noop = (_name, _value) => ({});
50
- const processors = {
51
- ["sst.aws.ApiGatewayV2"]: noop,
52
- ["sst.aws.Function"]: noop,
53
- ["sst.aws.Vpc"]: noop,
54
- ["sst.sst.Secret"]: secret,
55
- ["sst.aws.Postgres"]: postgres,
56
- ["sst.aws.Bucket"]: bucket,
57
- ["sst:sst:Secret"]: secret,
58
- ["sst:aws:Bucket"]: bucket,
59
- ["sst:sst:Function"]: noop,
60
- ["sst:aws:Postgres"]: postgres,
61
- ["sst:aws:ApiGatewayV2"]: noop,
62
- ["sst:aws:SnsTopic"]: topic
63
- };
64
- function buildResourceEnv(record) {
65
- const env = {};
66
- for (const [k, value] of Object.entries(record)) {
67
- if (typeof value === "string") {
68
- env[environmentCase(k)] = value;
69
- continue;
70
- }
71
- const processor = processors[value.type];
72
- if (processor) Object.assign(env, processor(k, value));
73
- }
74
- return env;
75
- }
76
- //#endregion
77
- export { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress };
1
+ import { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress } from "../utils-BdKG20_m.mjs";
78
2
 
79
- //# sourceMappingURL=index.mjs.map
3
+ export { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress };
@@ -0,0 +1,83 @@
1
+ import os from "node:os";
2
+ import snakecase from "lodash.snakecase";
3
+
4
+ //#region src/utils/index.ts
5
+ function getLocalIpAddress() {
6
+ const networkInterfaces = os.networkInterfaces();
7
+ for (const interfaceName in networkInterfaces) {
8
+ const addresses = networkInterfaces[interfaceName] || [];
9
+ for (const addressInfo of addresses) if (addressInfo.family === "IPv4" && !addressInfo.internal) return addressInfo.address;
10
+ }
11
+ return null;
12
+ }
13
+ function environmentCase(name) {
14
+ return snakecase(name).toUpperCase().replace(/_\d+/g, (r) => {
15
+ return r.replace("_", "");
16
+ });
17
+ }
18
+ let ResourceType = /* @__PURE__ */ function(ResourceType$1) {
19
+ ResourceType$1["ApiGatewayV2"] = "sst.aws.ApiGatewayV2";
20
+ ResourceType$1["Postgres"] = "sst.aws.Postgres";
21
+ ResourceType$1["Function"] = "sst.aws.Function";
22
+ ResourceType$1["Bucket"] = "sst.aws.Bucket";
23
+ ResourceType$1["Vpc"] = "sst.aws.Vpc";
24
+ ResourceType$1["Secret"] = "sst.sst.Secret";
25
+ ResourceType$1["SSTSecret"] = "sst:sst:Secret";
26
+ ResourceType$1["SSTFunction"] = "sst:sst:Function";
27
+ ResourceType$1["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
28
+ ResourceType$1["SSTPostgres"] = "sst:aws:Postgres";
29
+ ResourceType$1["SSTBucket"] = "sst:aws:Bucket";
30
+ ResourceType$1["SnsTopic"] = "sst:aws:SnsTopic";
31
+ return ResourceType$1;
32
+ }({});
33
+ const secret = (name, value) => ({ [environmentCase(name)]: value.value });
34
+ const postgres = (key, value) => {
35
+ const prefix = `${environmentCase(key)}`;
36
+ return {
37
+ [`${prefix}_NAME`]: value.database,
38
+ [`${prefix}_HOST`]: value.host,
39
+ [`${prefix}_PASSWORD`]: value.password,
40
+ [`${prefix}_PORT`]: value.port,
41
+ [`${prefix}_USERNAME`]: value.username
42
+ };
43
+ };
44
+ const bucket = (name, value) => {
45
+ const prefix = `${environmentCase(name)}`;
46
+ return { [`${prefix}_NAME`]: value.name };
47
+ };
48
+ const topic = (name, value) => {
49
+ const prefix = `${environmentCase(name)}`;
50
+ const key = `${prefix}_ARN`;
51
+ return { [key]: value.arn };
52
+ };
53
+ const noop = (_name, _value) => ({});
54
+ const processors = {
55
+ [ResourceType.ApiGatewayV2]: noop,
56
+ [ResourceType.Function]: noop,
57
+ [ResourceType.Vpc]: noop,
58
+ [ResourceType.Secret]: secret,
59
+ [ResourceType.Postgres]: postgres,
60
+ [ResourceType.Bucket]: bucket,
61
+ [ResourceType.SSTSecret]: secret,
62
+ [ResourceType.SSTBucket]: bucket,
63
+ [ResourceType.SSTFunction]: noop,
64
+ [ResourceType.SSTPostgres]: postgres,
65
+ [ResourceType.SSTApiGatewayV2]: noop,
66
+ [ResourceType.SnsTopic]: topic
67
+ };
68
+ function buildResourceEnv(record) {
69
+ const env = {};
70
+ for (const [k, value] of Object.entries(record)) {
71
+ if (typeof value === "string") {
72
+ env[environmentCase(k)] = value;
73
+ continue;
74
+ }
75
+ const processor = processors[value.type];
76
+ if (processor) Object.assign(env, processor(k, value));
77
+ }
78
+ return env;
79
+ }
80
+
81
+ //#endregion
82
+ export { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress };
83
+ //# sourceMappingURL=utils-BdKG20_m.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BdKG20_m.mjs","names":["name: string","value: Secret","key: string","value: Postgres","value: Bucket","value: SnsTopic","_name: string","_value: any","processors: Record<ResourceType, ResourceProcessor<any>>","record: Record<string, Resource | string>","env: Record<string, string>"],"sources":["../src/utils/index.ts"],"sourcesContent":["import os from 'node:os';\nimport snakecase from 'lodash.snakecase';\n\nexport function getLocalIpAddress() {\n\tconst networkInterfaces = os.networkInterfaces();\n\tfor (const interfaceName in networkInterfaces) {\n\t\tconst addresses = networkInterfaces[interfaceName] || [];\n\t\tfor (const addressInfo of addresses) {\n\t\t\t// Look for an IPv4 address that is not internal (loopback)\n\t\t\tif (addressInfo.family === 'IPv4' && !addressInfo.internal) {\n\t\t\t\treturn addressInfo.address;\n\t\t\t}\n\t\t}\n\t}\n\treturn null; // No suitable IP address found\n}\n\nexport function environmentCase(name: string) {\n\treturn snakecase(name)\n\t\t.toUpperCase()\n\t\t.replace(/_\\d+/g, (r) => {\n\t\t\treturn r.replace('_', '');\n\t\t});\n}\nexport enum ResourceType {\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\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\nconst secret = (name: string, value: Secret) => ({\n\t[environmentCase(name)]: value.value,\n});\nconst postgres = (key: string, value: Postgres) => {\n\tconst prefix = `${environmentCase(key)}`;\n\treturn {\n\t\t[`${prefix}_NAME`]: value.database,\n\t\t[`${prefix}_HOST`]: value.host,\n\t\t[`${prefix}_PASSWORD`]: value.password,\n\t\t[`${prefix}_PORT`]: value.port,\n\t\t[`${prefix}_USERNAME`]: value.username,\n\t};\n};\n\nconst bucket = (name: string, value: Bucket) => {\n\tconst prefix = `${environmentCase(name)}`;\n\treturn {\n\t\t[`${prefix}_NAME`]: value.name,\n\t};\n};\n\nconst topic = (name: string, value: SnsTopic) => {\n\tconst prefix = `${environmentCase(name)}`;\n\tconst key = `${prefix}_ARN`;\n\n\treturn {\n\t\t[key]: value.arn,\n\t};\n};\n\nconst noop = (_name: string, _value: any) => ({});\n\nconst processors: Record<ResourceType, ResourceProcessor<any>> = {\n\t[ResourceType.ApiGatewayV2]: noop,\n\t[ResourceType.Function]: noop,\n\t[ResourceType.Vpc]: noop,\n\t[ResourceType.Secret]: secret,\n\t[ResourceType.Postgres]: postgres,\n\t[ResourceType.Bucket]: bucket,\n\n\t[ResourceType.SSTSecret]: secret,\n\t[ResourceType.SSTBucket]: bucket,\n\t[ResourceType.SSTFunction]: noop,\n\t[ResourceType.SSTPostgres]: postgres,\n\t[ResourceType.SSTApiGatewayV2]: noop,\n\t[ResourceType.SnsTopic]: topic,\n};\n\nexport function buildResourceEnv(\n\trecord: Record<string, Resource | string>,\n): Record<string, string> {\n\tconst env: Record<string, string> = {};\n\tfor (const [k, value] of Object.entries(record)) {\n\t\tif (typeof value === 'string') {\n\t\t\tenv[environmentCase(k)] = value;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst processor = processors[value.type];\n\t\tif (processor) {\n\t\t\tObject.assign(env, processor(k, value));\n\t\t} else {\n\t\t}\n\t}\n\n\treturn env;\n}\n\nexport type ApiGatewayV2 = {\n\ttype: ResourceType.ApiGatewayV2;\n\turl: string;\n};\n\nexport type Postgres = {\n\tdatabase: string;\n\thost: string;\n\tpassword: string;\n\tport: number;\n\ttype: ResourceType.Postgres;\n\tusername: string;\n};\n\nexport type Function = {\n\tname: string;\n\ttype: ResourceType.Function;\n};\n\nexport type Bucket = {\n\tname: string;\n\ttype: ResourceType.Bucket;\n};\n\nexport type SnsTopic = {\n\tarn: string;\n\ttype: ResourceType.SnsTopic;\n};\n\nexport type Vpc = {\n\tbastion: string;\n\ttype: ResourceType.Vpc;\n};\n\nexport type Secret = {\n\ttype: ResourceType.Secret;\n\tvalue: string;\n};\n\nexport type Resource =\n\t| ApiGatewayV2\n\t| Postgres\n\t| Function\n\t| Bucket\n\t| Vpc\n\t| Secret;\n\nexport type ResourceProcessor<K extends Resource> = (\n\tname: string,\n\tvalue: K,\n) => Record<string, string | number>;\n"],"mappings":";;;;AAGA,SAAgB,oBAAoB;CACnC,MAAM,oBAAoB,GAAG,mBAAmB;AAChD,MAAK,MAAM,iBAAiB,mBAAmB;EAC9C,MAAM,YAAY,kBAAkB,kBAAkB,CAAE;AACxD,OAAK,MAAM,eAAe,UAEzB,KAAI,YAAY,WAAW,WAAW,YAAY,SACjD,QAAO,YAAY;CAGrB;AACD,QAAO;AACP;AAED,SAAgB,gBAAgBA,MAAc;AAC7C,QAAO,UAAU,KAAK,CACpB,aAAa,CACb,QAAQ,SAAS,CAAC,MAAM;AACxB,SAAO,EAAE,QAAQ,KAAK,GAAG;CACzB,EAAC;AACH;AACD,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AAED,MAAM,SAAS,CAACA,MAAcC,WAAmB,GAC/C,gBAAgB,KAAK,GAAG,MAAM,MAC/B;AACD,MAAM,WAAW,CAACC,KAAaC,UAAoB;CAClD,MAAM,UAAU,EAAE,gBAAgB,IAAI,CAAC;AACvC,QAAO;IACJ,EAAE,OAAO,SAAS,MAAM;IACxB,EAAE,OAAO,SAAS,MAAM;IACxB,EAAE,OAAO,aAAa,MAAM;IAC5B,EAAE,OAAO,SAAS,MAAM;IACxB,EAAE,OAAO,aAAa,MAAM;CAC9B;AACD;AAED,MAAM,SAAS,CAACH,MAAcI,UAAkB;CAC/C,MAAM,UAAU,EAAE,gBAAgB,KAAK,CAAC;AACxC,QAAO,IACJ,EAAE,OAAO,SAAS,MAAM,KAC1B;AACD;AAED,MAAM,QAAQ,CAACJ,MAAcK,UAAoB;CAChD,MAAM,UAAU,EAAE,gBAAgB,KAAK,CAAC;CACxC,MAAM,OAAO,EAAE,OAAO;AAEtB,QAAO,GACL,MAAM,MAAM,IACb;AACD;AAED,MAAM,OAAO,CAACC,OAAeC,YAAiB,CAAE;AAEhD,MAAMC,aAA2D;EAC/D,aAAa,eAAe;EAC5B,aAAa,WAAW;EACxB,aAAa,MAAM;EACnB,aAAa,SAAS;EACtB,aAAa,WAAW;EACxB,aAAa,SAAS;EAEtB,aAAa,YAAY;EACzB,aAAa,YAAY;EACzB,aAAa,cAAc;EAC3B,aAAa,cAAc;EAC3B,aAAa,kBAAkB;EAC/B,aAAa,WAAW;AACzB;AAED,SAAgB,iBACfC,QACyB;CACzB,MAAMC,MAA8B,CAAE;AACtC,MAAK,MAAM,CAAC,GAAG,MAAM,IAAI,OAAO,QAAQ,OAAO,EAAE;AAChD,aAAW,UAAU,UAAU;AAC9B,OAAI,gBAAgB,EAAE,IAAI;AAC1B;EACA;EAED,MAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UACH,QAAO,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC;CAGxC;AAED,QAAO;AACP"}