@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
@@ -0,0 +1,129 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const node_os = __toESM(require("node:os"));
25
+ const lodash_snakecase = __toESM(require("lodash.snakecase"));
26
+
27
+ //#region src/utils/index.ts
28
+ function getLocalIpAddress() {
29
+ const networkInterfaces = node_os.default.networkInterfaces();
30
+ for (const interfaceName in networkInterfaces) {
31
+ const addresses = networkInterfaces[interfaceName] || [];
32
+ for (const addressInfo of addresses) if (addressInfo.family === "IPv4" && !addressInfo.internal) return addressInfo.address;
33
+ }
34
+ return null;
35
+ }
36
+ function environmentCase(name) {
37
+ return (0, lodash_snakecase.default)(name).toUpperCase().replace(/_\d+/g, (r) => {
38
+ return r.replace("_", "");
39
+ });
40
+ }
41
+ let ResourceType = /* @__PURE__ */ function(ResourceType$1) {
42
+ ResourceType$1["ApiGatewayV2"] = "sst.aws.ApiGatewayV2";
43
+ ResourceType$1["Postgres"] = "sst.aws.Postgres";
44
+ ResourceType$1["Function"] = "sst.aws.Function";
45
+ ResourceType$1["Bucket"] = "sst.aws.Bucket";
46
+ ResourceType$1["Vpc"] = "sst.aws.Vpc";
47
+ ResourceType$1["Secret"] = "sst.sst.Secret";
48
+ ResourceType$1["SSTSecret"] = "sst:sst:Secret";
49
+ ResourceType$1["SSTFunction"] = "sst:sst:Function";
50
+ ResourceType$1["SSTApiGatewayV2"] = "sst:aws:ApiGatewayV2";
51
+ ResourceType$1["SSTPostgres"] = "sst:aws:Postgres";
52
+ ResourceType$1["SSTBucket"] = "sst:aws:Bucket";
53
+ ResourceType$1["SnsTopic"] = "sst:aws:SnsTopic";
54
+ return ResourceType$1;
55
+ }({});
56
+ const secret = (name, value) => ({ [environmentCase(name)]: value.value });
57
+ const postgres = (key, value) => {
58
+ const prefix = `${environmentCase(key)}`;
59
+ return {
60
+ [`${prefix}_NAME`]: value.database,
61
+ [`${prefix}_HOST`]: value.host,
62
+ [`${prefix}_PASSWORD`]: value.password,
63
+ [`${prefix}_PORT`]: value.port,
64
+ [`${prefix}_USERNAME`]: value.username
65
+ };
66
+ };
67
+ const bucket = (name, value) => {
68
+ const prefix = `${environmentCase(name)}`;
69
+ return { [`${prefix}_NAME`]: value.name };
70
+ };
71
+ const topic = (name, value) => {
72
+ const prefix = `${environmentCase(name)}`;
73
+ const key = `${prefix}_ARN`;
74
+ return { [key]: value.arn };
75
+ };
76
+ const noop = (_name, _value) => ({});
77
+ const processors = {
78
+ [ResourceType.ApiGatewayV2]: noop,
79
+ [ResourceType.Function]: noop,
80
+ [ResourceType.Vpc]: noop,
81
+ [ResourceType.Secret]: secret,
82
+ [ResourceType.Postgres]: postgres,
83
+ [ResourceType.Bucket]: bucket,
84
+ [ResourceType.SSTSecret]: secret,
85
+ [ResourceType.SSTBucket]: bucket,
86
+ [ResourceType.SSTFunction]: noop,
87
+ [ResourceType.SSTPostgres]: postgres,
88
+ [ResourceType.SSTApiGatewayV2]: noop,
89
+ [ResourceType.SnsTopic]: topic
90
+ };
91
+ function buildResourceEnv(record) {
92
+ const env = {};
93
+ for (const [k, value] of Object.entries(record)) {
94
+ if (typeof value === "string") {
95
+ env[environmentCase(k)] = value;
96
+ continue;
97
+ }
98
+ const processor = processors[value.type];
99
+ if (processor) Object.assign(env, processor(k, value));
100
+ }
101
+ return env;
102
+ }
103
+
104
+ //#endregion
105
+ Object.defineProperty(exports, 'ResourceType', {
106
+ enumerable: true,
107
+ get: function () {
108
+ return ResourceType;
109
+ }
110
+ });
111
+ Object.defineProperty(exports, 'buildResourceEnv', {
112
+ enumerable: true,
113
+ get: function () {
114
+ return buildResourceEnv;
115
+ }
116
+ });
117
+ Object.defineProperty(exports, 'environmentCase', {
118
+ enumerable: true,
119
+ get: function () {
120
+ return environmentCase;
121
+ }
122
+ });
123
+ Object.defineProperty(exports, 'getLocalIpAddress', {
124
+ enumerable: true,
125
+ get: function () {
126
+ return getLocalIpAddress;
127
+ }
128
+ });
129
+ //# sourceMappingURL=utils-CtMjuIMR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-CtMjuIMR.cjs","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,gBAAG,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,8BAAU,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"}
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@geekmidas/cloud",
3
- "version": "10.0.0-alpha.98",
3
+ "version": "10.0.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
7
- "src/sst",
8
- "src/dokploy"
7
+ "src/sst"
9
8
  ],
10
9
  "exports": {
11
10
  ".": {
@@ -28,8 +27,7 @@
28
27
  "default": "./dist/utils/index.cjs"
29
28
  }
30
29
  },
31
- "./sst": "./src/sst/index.ts",
32
- "./dokploy": "./src/dokploy/index.ts"
30
+ "./sst": "./src/sst/index.ts"
33
31
  },
34
32
  "repository": {
35
33
  "type": "git",
@@ -41,57 +39,21 @@
41
39
  },
42
40
  "dependencies": {
43
41
  "lodash.snakecase": "~4.1.1",
44
- "@geekmidas/envkit": "10.0.0-alpha.98",
45
- "@geekmidas/manifest": "10.0.0-alpha.98"
42
+ "@geekmidas/envkit": "10.0.0",
43
+ "@geekmidas/manifest": "10.0.0"
46
44
  },
47
45
  "devDependencies": {
48
46
  "@types/lodash.get": "~4.4.9",
49
47
  "@types/lodash.set": "~4.3.9",
50
48
  "@types/lodash.snakecase": "~4.1.9",
51
49
  "@types/node": "~24.9.1",
52
- "@types/pg": "~8.23.1",
53
- "sst": "~4.17.1"
50
+ "sst": "4.15.2"
54
51
  },
55
52
  "peerDependencies": {
56
- "sst": ">=4.17.1",
57
- "pg": ">=8.23.0",
58
- "@pulumi/aws": ">=7.47.0",
59
- "@pulumi/random": ">=4.21.2",
60
- "@pulumi/pulumi": ">=3.263.0",
61
- "@geekmidas/manifest": "^10.0.0-alpha.98",
62
- "@geekmidas/storage": "^10.0.0-alpha.98",
63
- "@geekmidas/events": "^10.0.0-alpha.98",
64
- "@geekmidas/db": "^10.0.0-alpha.98"
65
- },
66
- "peerDependenciesMeta": {
67
- "@geekmidas/manifest": {
68
- "optional": true
69
- },
70
- "@geekmidas/storage": {
71
- "optional": true
72
- },
73
- "@geekmidas/events": {
74
- "optional": true
75
- },
76
- "@geekmidas/db": {
77
- "optional": true
78
- },
79
- "pg": {
80
- "optional": true
81
- },
82
- "@pulumi/aws": {
83
- "optional": true
84
- },
85
- "@pulumi/random": {
86
- "optional": true
87
- },
88
- "@pulumi/pulumi": {
89
- "optional": true
90
- }
53
+ "sst": "^4.15.2"
91
54
  },
92
55
  "scripts": {
93
- "sst:install": "node -e \"process.exit(require('fs').existsSync('sst.config.ts')?0:1)\" && sst install || true",
94
- "ts:check:sst": "tsc --noEmit -p src/sst/tsconfig.json 2>&1 | grep -E 'src/sst/.*error TS' && exit 1 || exit 0",
95
- "build": "tsdown --config ../../tsdown.config.ts --filter ."
56
+ "sst:install": "sst install",
57
+ "ts:check:sst": "tsc --noEmit -p src/sst/tsconfig.json 2>&1 | grep -E 'src/sst/.*error TS' && exit 1 || exit 0"
96
58
  }
97
59
  }
@@ -1,9 +1,14 @@
1
1
  import path from 'node:path';
2
2
  import { EnvValidationError } from '@geekmidas/envkit/sst';
3
- import { type GkmLinkable, ResourceType } from '../Linkable';
4
- import { LinkedEnvironment } from '../LinkedEnvironment';
5
- import type { StackType } from '../Stack';
3
+ import {
4
+ flattenManifestField,
5
+ type ManifestField,
6
+ type RouteInfo,
7
+ } from '@geekmidas/manifest';
6
8
  import type { Function } from './Function';
9
+ import { type GkmLinkable, ResourceType } from './Linkable';
10
+ import { LinkedEnvironment } from './LinkedEnvironment';
11
+ import type { StackType } from './Stack';
7
12
 
8
13
  /**
9
14
  * `Api` — wraps SST's `sst.aws.ApiGatewayV2` (HTTP API) with a typed route
@@ -148,10 +153,48 @@ export class Api<
148
153
  // Fail the whole synth if any route is misconfigured, with one actionable
149
154
  // message per offending route.
150
155
  if (failures.length) {
151
- throw new RoutesMissingEnvironment(id, failures);
156
+ throw new Error(failures.map((f) => f.message).join('\n\n'));
152
157
  }
153
158
  }
154
159
 
160
+ /**
161
+ * Build an `Api` from a `gkm build` manifest's `routes` field (flat or
162
+ * partitioned): each `RouteInfo` becomes a route (env vars, authorizer,
163
+ * timeout/memory mapped). Supply `authorizers` (JWT/Lambda settings),
164
+ * `links`, and any native args via `props`.
165
+ *
166
+ * ```ts
167
+ * import { manifest } from './.gkm/manifest/aws';
168
+ * Api.fromManifest(stack, 'Api', manifest.routes, { links: [db] });
169
+ * ```
170
+ */
171
+ static fromManifest<
172
+ TAuthorizers extends Record<string, unknown> = {},
173
+ TStage extends string = string,
174
+ TDomain extends string = string,
175
+ >(
176
+ stack: StackType<TStage, TDomain>,
177
+ id: string,
178
+ routes: ManifestField<RouteInfo>,
179
+ props: Omit<ApiProps<TAuthorizers>, 'routes'> = {},
180
+ ): Api<TAuthorizers, TStage, TDomain> {
181
+ const routeTable = flattenManifestField(routes).map(
182
+ (route): Route<AuthorizerName<TAuthorizers>> => ({
183
+ method: route.method as Route['method'],
184
+ path: route.path,
185
+ handler: route.handler,
186
+ environment: route.environment,
187
+ authorizer: route.authorizer as AuthorizerName<TAuthorizers>,
188
+ timeout: route.timeout ? `${route.timeout} seconds` : undefined,
189
+ memory: route.memorySize ? `${route.memorySize} MB` : undefined,
190
+ }),
191
+ );
192
+ return new Api(stack, id, {
193
+ ...props,
194
+ routes: routeTable,
195
+ } as ApiProps<TAuthorizers>);
196
+ }
197
+
155
198
  /** Resolves a route's `authorizer` name to the SST `auth` option. */
156
199
  private static buildRouteAuth(
157
200
  route: Route<string>,
@@ -264,18 +307,3 @@ export interface ApiProps<TAuthorizers extends Record<string, unknown> = {}>
264
307
  * may override it. */
265
308
  runtime?: sst.aws.FunctionArgs['runtime'];
266
309
  }
267
-
268
- /**
269
- * Routes that read variables nothing links or whitelists. Collected across
270
- * every route so one synth reports all of them, each with its own suggestions,
271
- * rather than stopping at the first.
272
- */
273
- export class RoutesMissingEnvironment extends Error {
274
- constructor(
275
- readonly api: string,
276
- readonly failures: readonly EnvValidationError[],
277
- ) {
278
- super(failures.map((f) => f.message).join('\n\n'));
279
- this.name = 'RoutesMissingEnvironment';
280
- }
281
- }
@@ -1,5 +1,11 @@
1
- import type { StackType } from '../Stack';
2
- import type { Function } from './Function';
1
+ import {
2
+ type CronInfo,
3
+ flattenManifestField,
4
+ type ManifestField,
5
+ } from '@geekmidas/manifest';
6
+ import { Function } from './Function';
7
+ import type { GkmLinkable } from './Linkable';
8
+ import type { StackType } from './Stack';
3
9
 
4
10
  export type CronExpressionValue = number | '*' | '?' | `${number}/${number}`;
5
11
  export type CronExpressionDay =
@@ -46,9 +52,6 @@ export class Cron<
46
52
  TStage extends string = string,
47
53
  TDomain extends string = string,
48
54
  > extends sst.aws.CronV2 {
49
- /** The function it invokes. */
50
- readonly processor: CronProps['processor'];
51
-
52
55
  constructor(
53
56
  _stack: StackType<TStage, TDomain>,
54
57
  name: string,
@@ -60,7 +63,44 @@ export class Cron<
60
63
  schedule,
61
64
  function: processor.arn,
62
65
  });
63
- this.processor = processor;
66
+ }
67
+
68
+ /**
69
+ * Build one `Cron` per entry in a `gkm build` manifest's `crons` field (flat
70
+ * or partitioned). Each cron's handler becomes a validated `Function` (the
71
+ * cron's target), so pass `links` for that function's env validation;
72
+ * remaining `props` are CronV2 args.
73
+ *
74
+ * ```ts
75
+ * Cron.fromManifest(stack, manifest.crons, { links: [db] });
76
+ * ```
77
+ */
78
+ static fromManifest<
79
+ TStage extends string = string,
80
+ TDomain extends string = string,
81
+ >(
82
+ stack: StackType<TStage, TDomain>,
83
+ crons: ManifestField<CronInfo>,
84
+ props: Omit<CronProps, 'processor' | 'schedule'> & {
85
+ links?: GkmLinkable[];
86
+ } = {},
87
+ ): Cron<TStage, TDomain>[] {
88
+ const { links, ...cronArgs } = props;
89
+ return flattenManifestField(crons).map((cron) => {
90
+ const processor = new Function(stack, `${cron.name}Function`, {
91
+ name: stack.logicalPrefixedName(cron.name),
92
+ handler: cron.handler,
93
+ envVars: cron.environment,
94
+ links,
95
+ timeout: cron.timeout ? `${cron.timeout} seconds` : undefined,
96
+ memory: cron.memorySize ? `${cron.memorySize} MB` : undefined,
97
+ });
98
+ return new Cron(stack, cron.name, {
99
+ ...cronArgs,
100
+ processor,
101
+ schedule: cron.schedule as CronSchedule,
102
+ });
103
+ });
64
104
  }
65
105
  }
66
106
 
@@ -1,7 +1,12 @@
1
1
  import type { EnvValidator, ValidationResult } from '@geekmidas/envkit/sst';
2
- import { type GkmLinkable, ResourceType } from '../Linkable';
3
- import { LinkedEnvironment } from '../LinkedEnvironment';
4
- import type { StackType } from '../Stack';
2
+ import {
3
+ type FunctionInfo,
4
+ flattenManifestField,
5
+ type ManifestField,
6
+ } from '@geekmidas/manifest';
7
+ import { type GkmLinkable, ResourceType } from './Linkable';
8
+ import { LinkedEnvironment } from './LinkedEnvironment';
9
+ import type { StackType } from './Stack';
5
10
 
6
11
  /**
7
12
  * `Function` — wraps SST's `sst.aws.Function` with standard env defaults and
@@ -61,10 +66,9 @@ export class Function<
61
66
  super(id, {
62
67
  ...fnArgs,
63
68
  environment: mergedEnvironment,
64
- // Resolved from `links` when `envVars` names what it needs; otherwise
65
- // the `link` it was given — the edges a manifest declared.
66
- link:
67
- envVars.length > 0 ? linked.resolveLink(envVars) : (fnArgs.link ?? []),
69
+ // Linking is managed via the `links`/`envVars` flow, so this overrides
70
+ // any native `link` passed through `fnArgs`.
71
+ link: linked.resolveLink(envVars),
68
72
  runtime: runtime ?? 'nodejs24.x',
69
73
  logging: logging ?? { format: 'json' },
70
74
  });
@@ -74,15 +78,40 @@ export class Function<
74
78
  this.envVars = envVars;
75
79
  }
76
80
 
77
- /** Its address, for whatever declared an edge to it. */
78
- provides(): Record<string, $util.Input<string>> {
79
- return { url: this.url };
80
- }
81
-
82
81
  /** Re-runs validation and returns the result (does not throw). */
83
82
  validate(): ValidationResult {
84
83
  return this.validator.validate(this.envVars);
85
84
  }
85
+
86
+ /**
87
+ * Build one `Function` per entry in a `gkm build` manifest's `functions`
88
+ * field (flat or partitioned). Shared `props` (e.g. `links`) apply to every
89
+ * function.
90
+ *
91
+ * ```ts
92
+ * Function.fromManifest(stack, manifest.functions, { links: [db] });
93
+ * ```
94
+ */
95
+ static fromManifest<
96
+ TStage extends string = string,
97
+ TDomain extends string = string,
98
+ >(
99
+ stack: StackType<TStage, TDomain>,
100
+ functions: ManifestField<FunctionInfo>,
101
+ props: Omit<FunctionProps, 'handler'> = {},
102
+ ): Function<TStage, TDomain>[] {
103
+ return flattenManifestField(functions).map(
104
+ (fn) =>
105
+ new Function(stack, fn.name, {
106
+ ...props,
107
+ name: stack.logicalPrefixedName(fn.name),
108
+ handler: fn.handler,
109
+ envVars: fn.environment,
110
+ timeout: fn.timeout ? `${fn.timeout} seconds` : undefined,
111
+ memory: fn.memorySize ? `${fn.memorySize} MB` : undefined,
112
+ }),
113
+ );
114
+ }
86
115
  }
87
116
 
88
117
  export interface FunctionProps extends sst.aws.FunctionArgs {
@@ -0,0 +1,46 @@
1
+ import { type GkmLinkable, ResourceType } from './Linkable';
2
+ import type { StackType } from './Stack';
3
+
4
+ /**
5
+ * `Queue` — a linkable SQS queue (wraps `sst.aws.Queue`), the point-to-point
6
+ * work queue. Link it to a producer and the runtime resolves `<NAME>_URL`,
7
+ * `<NAME>_ARN`, and a `<NAME>_PUBLISHER_CONNECTION_STRING` (`sqs://?queueUrl=…`)
8
+ * that `@geekmidas/events`'s `Publisher.fromConnectionString` consumes. Its
9
+ * single consumer is wired by `QueueSubscriber`.
10
+ *
11
+ * SST's native `Queue` link exposes only `url`, so `getSSTLink` is overridden to
12
+ * also expose `arn` (what the resolver needs). `QueueProps` extends
13
+ * `sst.aws.QueueArgs`. Source-only (extends ambient `sst.aws.*`); see docs §2.
14
+ */
15
+ export class Queue<
16
+ TStage extends string = string,
17
+ TDomain extends string = string,
18
+ >
19
+ extends sst.aws.Queue
20
+ implements GkmLinkable
21
+ {
22
+ readonly _id!: string;
23
+
24
+ get _type() {
25
+ return ResourceType.Queue;
26
+ }
27
+
28
+ constructor(
29
+ _stack: StackType<TStage, TDomain>,
30
+ name: string,
31
+ props: QueueProps = {},
32
+ ) {
33
+ super(name, props);
34
+ this._id = name;
35
+ }
36
+
37
+ override getSSTLink() {
38
+ const link = super.getSSTLink();
39
+ return {
40
+ ...link,
41
+ properties: { ...link.properties, arn: this.arn },
42
+ };
43
+ }
44
+ }
45
+
46
+ export interface QueueProps extends sst.aws.QueueArgs {}
@@ -1,5 +1,5 @@
1
- import { type GkmLinkable, ResourceType } from '../Linkable';
2
- import type { StackType } from '../Stack';
1
+ import { type GkmLinkable, ResourceType } from './Linkable';
2
+ import type { StackType } from './Stack';
3
3
 
4
4
  /**
5
5
  * `Storage` — a linkable S3 bucket (wraps `sst.aws.Bucket`). Link it to a
@@ -39,7 +39,7 @@ export class Storage<
39
39
  readonly _id!: string;
40
40
 
41
41
  get _type() {
42
- return ResourceType.ObjectStorage;
42
+ return ResourceType.Bucket;
43
43
  }
44
44
 
45
45
  constructor(
@@ -0,0 +1,37 @@
1
+ import { type GkmLinkable, ResourceType } from './Linkable';
2
+ import type { StackType } from './Stack';
3
+
4
+ /**
5
+ * `Topic` — a linkable SNS topic (wraps `sst.aws.SnsTopic`), the pub/sub fan-out
6
+ * bus. Link it to a publisher and the runtime resolves `<NAME>_ARN` and a
7
+ * `<NAME>_PUBLISHER_CONNECTION_STRING` (`sns://?topicArn=…`) that
8
+ * `@geekmidas/events`'s `Publisher.fromConnectionString` consumes. Subscribers
9
+ * attach via `TopicSubscriber`/`Subscriber`.
10
+ *
11
+ * `StorageProps`-style: `TopicProps` extends `sst.aws.SnsTopicArgs`.
12
+ * Source-only (extends ambient `sst.aws.*`); see docs §2.
13
+ */
14
+ export class Topic<
15
+ TStage extends string = string,
16
+ TDomain extends string = string,
17
+ >
18
+ extends sst.aws.SnsTopic
19
+ implements GkmLinkable
20
+ {
21
+ readonly _id!: string;
22
+
23
+ get _type() {
24
+ return ResourceType.SnsTopic;
25
+ }
26
+
27
+ constructor(
28
+ _stack: StackType<TStage, TDomain>,
29
+ name: string,
30
+ props: TopicProps = {},
31
+ ) {
32
+ super(name, props);
33
+ this._id = name;
34
+ }
35
+ }
36
+
37
+ export interface TopicProps extends sst.aws.SnsTopicArgs {}
@@ -14,10 +14,7 @@ const stack = new App({
14
14
  }).stack('api');
15
15
 
16
16
  const db: GkmLinkable = { _id: 'db', _type: ResourceType.Postgres };
17
- const uploads: GkmLinkable = {
18
- _id: 'uploads',
19
- _type: ResourceType.ObjectStorage,
20
- };
17
+ const uploads: GkmLinkable = { _id: 'uploads', _type: ResourceType.Bucket };
21
18
 
22
19
  describe('LinkedEnvironment', () => {
23
20
  describe('createBaseEnvironment', () => {
@@ -3,9 +3,9 @@
3
3
  // ignores it). Each `@ts-expect-error` self-validates: if the enforcement
4
4
  // regresses, the now-unused directive becomes a TS error the gate catches.
5
5
 
6
+ import { Api } from '../Api';
6
7
  import { App } from '../App';
7
- import { Api } from '../aws/Api';
8
- import { Function } from '../aws/Function';
8
+ import { Function } from '../Function';
9
9
 
10
10
  const stack = new App({
11
11
  name: 'a',
@@ -0,0 +1,77 @@
1
+ // Type-level checks that the `fromManifest` integrators accept the unified
2
+ // `gkm build` manifest shape (`export const manifest = { … } as const`) — both
3
+ // the flat and the partitioned `ManifestField` forms. Checked by `ts:check:sst`.
4
+
5
+ import type { Manifest, ManifestField, RouteInfo } from '@geekmidas/manifest';
6
+ import { Api } from '../Api';
7
+ import { App } from '../App';
8
+ import { Cron } from '../Cron';
9
+ import { Function } from '../Function';
10
+ import { type GkmLinkable, ResourceType } from '../Linkable';
11
+
12
+ const stack = new App({
13
+ name: 'a',
14
+ stage: 'dev',
15
+ domain: 'example.com',
16
+ hostedZoneId: 'Z',
17
+ region: 'us-east-1',
18
+ }).stack('api');
19
+
20
+ const db: GkmLinkable = { _id: 'db', _type: ResourceType.Postgres };
21
+
22
+ // Mirrors a generated `manifest/aws.ts` — one object, `as const`.
23
+ const manifest = {
24
+ routes: [
25
+ {
26
+ path: '/users/{id}',
27
+ method: 'GET',
28
+ handler: 'users.handler',
29
+ authorizer: 'none',
30
+ environment: ['DB_HOST'],
31
+ timeout: 30,
32
+ memorySize: 1024,
33
+ },
34
+ ],
35
+ functions: [
36
+ { name: 'worker', handler: 'worker.handler', environment: ['DB_URL'] },
37
+ ],
38
+ crons: [
39
+ { name: 'nightly', handler: 'nightly.handler', schedule: 'rate(1 day)' },
40
+ ],
41
+ } as const satisfies Manifest;
42
+
43
+ // Each integrator takes the manifest *field*.
44
+ export const api = Api.fromManifest(stack, 'Api', manifest.routes, {
45
+ links: [db],
46
+ authorizers: { jwt: { issuer: 'https://i', audiences: ['a'] } },
47
+ });
48
+ export const workers = Function.fromManifest(stack, manifest.functions, {
49
+ links: [db],
50
+ });
51
+ export const crons = Cron.fromManifest(stack, manifest.crons, { links: [db] });
52
+
53
+ // The partitioned `ManifestField` form is also accepted.
54
+ const partitionedRoutes = {
55
+ admin: [
56
+ {
57
+ path: '/admin',
58
+ method: 'GET',
59
+ handler: 'admin.handler',
60
+ authorizer: 'iam',
61
+ },
62
+ ],
63
+ default: [
64
+ {
65
+ path: '/health',
66
+ method: 'GET',
67
+ handler: 'health.handler',
68
+ authorizer: 'none',
69
+ },
70
+ ],
71
+ } satisfies ManifestField<RouteInfo>;
72
+ export const partitionedApi = Api.fromManifest(
73
+ stack,
74
+ 'PartApi',
75
+ partitionedRoutes,
76
+ { links: [db] },
77
+ );
@@ -2,9 +2,9 @@
2
2
  // strings validate. Checked by `ts:check:sst`; vitest ignores it.
3
3
 
4
4
  import { App } from '../App';
5
- import { Function } from '../aws/Function';
6
- import { Queue } from '../aws/Queue';
7
- import { Topic } from '../aws/Topic';
5
+ import { Function } from '../Function';
6
+ import { Queue } from '../Queue';
7
+ import { Topic } from '../Topic';
8
8
 
9
9
  const stack = new App({
10
10
  name: 'shop',