@geekmidas/cloud 0.0.1 → 0.0.2

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.
@@ -0,0 +1,55 @@
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
+ //#endregion
54
+ export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
55
+ //# sourceMappingURL=index-DiEIrMTf.d.mts.map
@@ -0,0 +1,55 @@
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
+ //#endregion
54
+ export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
55
+ //# sourceMappingURL=index-QvprWg8v.d.cts.map
package/dist/index.cjs CHANGED
@@ -0,0 +1,3 @@
1
+ const require_utils = require('./utils-BtXDcUV8.cjs');
2
+
3
+ exports.buildResourceEnv = require_utils.buildResourceEnv;
package/dist/index.d.cts CHANGED
@@ -1 +1,2 @@
1
- export { };
1
+ import { buildResourceEnv } from "./index-QvprWg8v.cjs";
2
+ export { buildResourceEnv };
package/dist/index.d.mts CHANGED
@@ -1 +1,2 @@
1
- export { };
1
+ import { buildResourceEnv } from "./index-DiEIrMTf.mjs";
2
+ export { buildResourceEnv };
package/dist/index.mjs CHANGED
@@ -0,0 +1,3 @@
1
+ import { buildResourceEnv } from "./utils-CsvKEy-e.mjs";
2
+
3
+ export { buildResourceEnv };
@@ -1,109 +1,6 @@
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));
1
+ const require_utils = require('../utils-BtXDcUV8.cjs');
22
2
 
23
- //#endregion
24
- const lodash_snakecase = __toESM(require("lodash.snakecase"));
25
- const os = __toESM(require("os"));
26
-
27
- //#region src/utils/index.ts
28
- function getLocalIpAddress() {
29
- const networkInterfaces = 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
- else console.warn(`No processor found for resource type: `, { value });
101
- }
102
- return env;
103
- }
104
-
105
- //#endregion
106
- exports.ResourceType = ResourceType;
107
- exports.buildResourceEnv = buildResourceEnv;
108
- exports.environmentCase = environmentCase;
109
- exports.getLocalIpAddress = getLocalIpAddress;
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,54 +1,2 @@
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
- //#endregion
1
+ import { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress } from "../index-QvprWg8v.cjs";
54
2
  export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
@@ -1,54 +1,2 @@
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
- //#endregion
1
+ import { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress } from "../index-DiEIrMTf.mjs";
54
2
  export { ApiGatewayV2, Bucket, Function, Postgres, Resource, ResourceProcessor, ResourceType, Secret, SnsTopic, Vpc, buildResourceEnv, environmentCase, getLocalIpAddress };
@@ -1,83 +1,3 @@
1
- import snakecase from "lodash.snakecase";
2
- import os from "os";
1
+ import { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress } from "../utils-CsvKEy-e.mjs";
3
2
 
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
- else console.warn(`No processor found for resource type: `, { value });
78
- }
79
- return env;
80
- }
81
-
82
- //#endregion
83
3
  export { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress };
@@ -0,0 +1,130 @@
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 lodash_snakecase = __toESM(require("lodash.snakecase"));
25
+ const os = __toESM(require("os"));
26
+
27
+ //#region src/utils/index.ts
28
+ function getLocalIpAddress() {
29
+ const networkInterfaces = 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
+ else console.warn(`No processor found for resource type: `, { value });
101
+ }
102
+ return env;
103
+ }
104
+
105
+ //#endregion
106
+ Object.defineProperty(exports, 'ResourceType', {
107
+ enumerable: true,
108
+ get: function () {
109
+ return ResourceType;
110
+ }
111
+ });
112
+ Object.defineProperty(exports, 'buildResourceEnv', {
113
+ enumerable: true,
114
+ get: function () {
115
+ return buildResourceEnv;
116
+ }
117
+ });
118
+ Object.defineProperty(exports, 'environmentCase', {
119
+ enumerable: true,
120
+ get: function () {
121
+ return environmentCase;
122
+ }
123
+ });
124
+ Object.defineProperty(exports, 'getLocalIpAddress', {
125
+ enumerable: true,
126
+ get: function () {
127
+ return getLocalIpAddress;
128
+ }
129
+ });
130
+ //# sourceMappingURL=utils-BtXDcUV8.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BtXDcUV8.cjs","names":["name: string","value: Secret","key: string","value: Postgres","value: Bucket","value: SnsTopic","value: any","processors: Record<ResourceType, ResourceProcessor<any>>","record: Record<string, Resource | string>","env: Record<string, string>"],"sources":["../src/utils/index.ts"],"sourcesContent":["import snakecase from 'lodash.snakecase';\n\nimport os from 'os';\n\nexport function getLocalIpAddress() {\n const networkInterfaces = os.networkInterfaces();\n for (const interfaceName in networkInterfaces) {\n const addresses = networkInterfaces[interfaceName] || [];\n for (const addressInfo of addresses) {\n // Look for an IPv4 address that is not internal (loopback)\n if (addressInfo.family === 'IPv4' && !addressInfo.internal) {\n return addressInfo.address;\n }\n }\n }\n return null; // No suitable IP address found\n}\n\nexport function environmentCase(name: string) {\n return snakecase(name)\n .toUpperCase()\n .replace(/_\\d+/g, (r) => {\n return r.replace('_', '');\n });\n}\nexport enum ResourceType {\n ApiGatewayV2 = 'sst.aws.ApiGatewayV2',\n Postgres = 'sst.aws.Postgres',\n Function = 'sst.aws.Function',\n Bucket = 'sst.aws.Bucket',\n Vpc = 'sst.aws.Vpc',\n Secret = 'sst.sst.Secret',\n SSTSecret = 'sst:sst:Secret',\n SSTFunction = 'sst:sst:Function',\n SSTApiGatewayV2 = 'sst:aws:ApiGatewayV2',\n SSTPostgres = 'sst:aws:Postgres',\n SSTBucket = 'sst:aws:Bucket',\n SnsTopic = 'sst:aws:SnsTopic',\n}\n\nconst secret = (name: string, value: Secret) => ({\n [environmentCase(name)]: value.value,\n});\nconst postgres = (key: string, value: Postgres) => {\n const prefix = `${environmentCase(key)}`;\n return {\n [`${prefix}_NAME`]: value.database,\n [`${prefix}_HOST`]: value.host,\n [`${prefix}_PASSWORD`]: value.password,\n [`${prefix}_PORT`]: value.port,\n [`${prefix}_USERNAME`]: value.username,\n };\n};\n\nconst bucket = (name: string, value: Bucket) => {\n const prefix = `${environmentCase(name)}`;\n return {\n [`${prefix}_NAME`]: value.name,\n };\n};\n\nconst topic = (name: string, value: SnsTopic) => {\n const prefix = `${environmentCase(name)}`;\n const key = `${prefix}_ARN`;\n\n return {\n [key]: value.arn,\n };\n};\n\nconst noop = (name: string, value: any) => ({});\n\nconst processors: Record<ResourceType, ResourceProcessor<any>> = {\n [ResourceType.ApiGatewayV2]: noop,\n [ResourceType.Function]: noop,\n [ResourceType.Vpc]: noop,\n [ResourceType.Secret]: secret,\n [ResourceType.Postgres]: postgres,\n [ResourceType.Bucket]: bucket,\n\n [ResourceType.SSTSecret]: secret,\n [ResourceType.SSTBucket]: bucket,\n [ResourceType.SSTFunction]: noop,\n [ResourceType.SSTPostgres]: postgres,\n [ResourceType.SSTApiGatewayV2]: noop,\n [ResourceType.SnsTopic]: topic,\n};\n\nexport function buildResourceEnv(\n record: Record<string, Resource | string>,\n): Record<string, string> {\n const env: Record<string, string> = {};\n for (const [k, value] of Object.entries(record)) {\n if (typeof value === 'string') {\n env[environmentCase(k)] = value;\n continue;\n }\n\n const processor = processors[value.type];\n if (processor) {\n Object.assign(env, processor(k, value));\n } else {\n console.warn(`No processor found for resource type: `, { value });\n }\n }\n\n return env;\n}\n\nexport type ApiGatewayV2 = {\n type: ResourceType.ApiGatewayV2;\n url: string;\n};\n\nexport type Postgres = {\n database: string;\n host: string;\n password: string;\n port: number;\n type: ResourceType.Postgres;\n username: string;\n};\n\nexport type Function = {\n name: string;\n type: ResourceType.Function;\n};\n\nexport type Bucket = {\n name: string;\n type: ResourceType.Bucket;\n};\n\nexport type SnsTopic = {\n arn: string;\n type: ResourceType.SnsTopic;\n};\n\nexport type Vpc = {\n bastion: string;\n type: ResourceType.Vpc;\n};\n\nexport type Secret = {\n type: ResourceType.Secret;\n value: string;\n};\n\nexport type Resource =\n | ApiGatewayV2\n | Postgres\n | Function\n | Bucket\n | Vpc\n | Secret;\n\nexport type ResourceProcessor<K extends Resource> = (\n name: string,\n value: K,\n) => Record<string, string | number>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAgB,oBAAoB;CAClC,MAAM,oBAAoB,WAAG,mBAAmB;AAChD,MAAK,MAAM,iBAAiB,mBAAmB;EAC7C,MAAM,YAAY,kBAAkB,kBAAkB,CAAE;AACxD,OAAK,MAAM,eAAe,UAExB,KAAI,YAAY,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dC,QACwB;CACxB,MAAMC,MAA8B,CAAE;AACtC,MAAK,MAAM,CAAC,GAAG,MAAM,IAAI,OAAO,QAAQ,OAAO,EAAE;AAC/C,aAAW,UAAU,UAAU;AAC7B,OAAI,gBAAgB,EAAE,IAAI;AAC1B;EACD;EAED,MAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UACF,QAAO,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC;MAEvC,SAAQ,MAAM,yCAAyC,EAAE,MAAO,EAAC;CAEpE;AAED,QAAO;AACR"}
@@ -0,0 +1,84 @@
1
+ import snakecase from "lodash.snakecase";
2
+ import os from "os";
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
+ else console.warn(`No processor found for resource type: `, { value });
78
+ }
79
+ return env;
80
+ }
81
+
82
+ //#endregion
83
+ export { ResourceType, buildResourceEnv, environmentCase, getLocalIpAddress };
84
+ //# sourceMappingURL=utils-CsvKEy-e.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-CsvKEy-e.mjs","names":["name: string","value: Secret","key: string","value: Postgres","value: Bucket","value: SnsTopic","value: any","processors: Record<ResourceType, ResourceProcessor<any>>","record: Record<string, Resource | string>","env: Record<string, string>"],"sources":["../src/utils/index.ts"],"sourcesContent":["import snakecase from 'lodash.snakecase';\n\nimport os from 'os';\n\nexport function getLocalIpAddress() {\n const networkInterfaces = os.networkInterfaces();\n for (const interfaceName in networkInterfaces) {\n const addresses = networkInterfaces[interfaceName] || [];\n for (const addressInfo of addresses) {\n // Look for an IPv4 address that is not internal (loopback)\n if (addressInfo.family === 'IPv4' && !addressInfo.internal) {\n return addressInfo.address;\n }\n }\n }\n return null; // No suitable IP address found\n}\n\nexport function environmentCase(name: string) {\n return snakecase(name)\n .toUpperCase()\n .replace(/_\\d+/g, (r) => {\n return r.replace('_', '');\n });\n}\nexport enum ResourceType {\n ApiGatewayV2 = 'sst.aws.ApiGatewayV2',\n Postgres = 'sst.aws.Postgres',\n Function = 'sst.aws.Function',\n Bucket = 'sst.aws.Bucket',\n Vpc = 'sst.aws.Vpc',\n Secret = 'sst.sst.Secret',\n SSTSecret = 'sst:sst:Secret',\n SSTFunction = 'sst:sst:Function',\n SSTApiGatewayV2 = 'sst:aws:ApiGatewayV2',\n SSTPostgres = 'sst:aws:Postgres',\n SSTBucket = 'sst:aws:Bucket',\n SnsTopic = 'sst:aws:SnsTopic',\n}\n\nconst secret = (name: string, value: Secret) => ({\n [environmentCase(name)]: value.value,\n});\nconst postgres = (key: string, value: Postgres) => {\n const prefix = `${environmentCase(key)}`;\n return {\n [`${prefix}_NAME`]: value.database,\n [`${prefix}_HOST`]: value.host,\n [`${prefix}_PASSWORD`]: value.password,\n [`${prefix}_PORT`]: value.port,\n [`${prefix}_USERNAME`]: value.username,\n };\n};\n\nconst bucket = (name: string, value: Bucket) => {\n const prefix = `${environmentCase(name)}`;\n return {\n [`${prefix}_NAME`]: value.name,\n };\n};\n\nconst topic = (name: string, value: SnsTopic) => {\n const prefix = `${environmentCase(name)}`;\n const key = `${prefix}_ARN`;\n\n return {\n [key]: value.arn,\n };\n};\n\nconst noop = (name: string, value: any) => ({});\n\nconst processors: Record<ResourceType, ResourceProcessor<any>> = {\n [ResourceType.ApiGatewayV2]: noop,\n [ResourceType.Function]: noop,\n [ResourceType.Vpc]: noop,\n [ResourceType.Secret]: secret,\n [ResourceType.Postgres]: postgres,\n [ResourceType.Bucket]: bucket,\n\n [ResourceType.SSTSecret]: secret,\n [ResourceType.SSTBucket]: bucket,\n [ResourceType.SSTFunction]: noop,\n [ResourceType.SSTPostgres]: postgres,\n [ResourceType.SSTApiGatewayV2]: noop,\n [ResourceType.SnsTopic]: topic,\n};\n\nexport function buildResourceEnv(\n record: Record<string, Resource | string>,\n): Record<string, string> {\n const env: Record<string, string> = {};\n for (const [k, value] of Object.entries(record)) {\n if (typeof value === 'string') {\n env[environmentCase(k)] = value;\n continue;\n }\n\n const processor = processors[value.type];\n if (processor) {\n Object.assign(env, processor(k, value));\n } else {\n console.warn(`No processor found for resource type: `, { value });\n }\n }\n\n return env;\n}\n\nexport type ApiGatewayV2 = {\n type: ResourceType.ApiGatewayV2;\n url: string;\n};\n\nexport type Postgres = {\n database: string;\n host: string;\n password: string;\n port: number;\n type: ResourceType.Postgres;\n username: string;\n};\n\nexport type Function = {\n name: string;\n type: ResourceType.Function;\n};\n\nexport type Bucket = {\n name: string;\n type: ResourceType.Bucket;\n};\n\nexport type SnsTopic = {\n arn: string;\n type: ResourceType.SnsTopic;\n};\n\nexport type Vpc = {\n bastion: string;\n type: ResourceType.Vpc;\n};\n\nexport type Secret = {\n type: ResourceType.Secret;\n value: string;\n};\n\nexport type Resource =\n | ApiGatewayV2\n | Postgres\n | Function\n | Bucket\n | Vpc\n | Secret;\n\nexport type ResourceProcessor<K extends Resource> = (\n name: string,\n value: K,\n) => Record<string, string | number>;\n"],"mappings":";;;;AAIA,SAAgB,oBAAoB;CAClC,MAAM,oBAAoB,GAAG,mBAAmB;AAChD,MAAK,MAAM,iBAAiB,mBAAmB;EAC7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B,aAAa,cAAc;EAC3B,aAAa,kBAAkB;EAC/B,aAAa,WAAW;AAC1B;AAED,SAAgB,iBACdC,QACwB;CACxB,MAAMC,MAA8B,CAAE;AACtC,MAAK,MAAM,CAAC,GAAG,MAAM,IAAI,OAAO,QAAQ,OAAO,EAAE;AAC/C,aAAW,UAAU,UAAU;AAC7B,OAAI,gBAAgB,EAAE,IAAI;AAC1B;EACD;EAED,MAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UACF,QAAO,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC;MAEvC,SAAQ,MAAM,yCAAyC,EAAE,MAAO,EAAC;CAEpE;AAED,QAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/cloud",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -19,8 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "lodash.snakecase": "~4.1.1",
23
- "@geekmidas/api": "0.0.52"
22
+ "lodash.snakecase": "~4.1.1"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@types/lodash.get": "~4.4.9",
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export { buildResourceEnv } from './utils';