@mesh-tech/mesh-cli 0.1.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.
- package/dist/bin/mesh.d.ts +16 -0
- package/dist/bin/mesh.d.ts.map +1 -0
- package/dist/bin/mesh.js +40 -0
- package/dist/bin/mesh.js.map +1 -0
- package/dist/src/commands/create-app.d.ts +10 -0
- package/dist/src/commands/create-app.d.ts.map +1 -0
- package/dist/src/commands/create-app.js +176 -0
- package/dist/src/commands/create-app.js.map +1 -0
- package/dist/src/commands/db/connect.d.ts +13 -0
- package/dist/src/commands/db/connect.d.ts.map +1 -0
- package/dist/src/commands/db/connect.js +68 -0
- package/dist/src/commands/db/connect.js.map +1 -0
- package/dist/src/commands/db/credentials.d.ts +16 -0
- package/dist/src/commands/db/credentials.d.ts.map +1 -0
- package/dist/src/commands/db/credentials.js +56 -0
- package/dist/src/commands/db/credentials.js.map +1 -0
- package/dist/src/commands/db/env.d.ts +15 -0
- package/dist/src/commands/db/env.d.ts.map +1 -0
- package/dist/src/commands/db/env.js +50 -0
- package/dist/src/commands/db/env.js.map +1 -0
- package/dist/src/commands/db/exec.d.ts +54 -0
- package/dist/src/commands/db/exec.d.ts.map +1 -0
- package/dist/src/commands/db/exec.js +331 -0
- package/dist/src/commands/db/exec.js.map +1 -0
- package/dist/src/commands/db/index.d.ts +12 -0
- package/dist/src/commands/db/index.d.ts.map +1 -0
- package/dist/src/commands/db/index.js +62 -0
- package/dist/src/commands/db/index.js.map +1 -0
- package/dist/src/commands/db/psql.d.ts +16 -0
- package/dist/src/commands/db/psql.d.ts.map +1 -0
- package/dist/src/commands/db/psql.js +133 -0
- package/dist/src/commands/db/psql.js.map +1 -0
- package/dist/src/commands/deploy.d.ts +24 -0
- package/dist/src/commands/deploy.d.ts.map +1 -0
- package/dist/src/commands/deploy.js +228 -0
- package/dist/src/commands/deploy.js.map +1 -0
- package/dist/src/commands/dev.d.ts +17 -0
- package/dist/src/commands/dev.d.ts.map +1 -0
- package/dist/src/commands/dev.js +1248 -0
- package/dist/src/commands/dev.js.map +1 -0
- package/dist/src/commands/devbox.d.ts +22 -0
- package/dist/src/commands/devbox.d.ts.map +1 -0
- package/dist/src/commands/devbox.js +463 -0
- package/dist/src/commands/devbox.js.map +1 -0
- package/dist/src/commands/login.d.ts +47 -0
- package/dist/src/commands/login.d.ts.map +1 -0
- package/dist/src/commands/login.js +344 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/registry.d.ts +20 -0
- package/dist/src/commands/registry.d.ts.map +1 -0
- package/dist/src/commands/registry.js +336 -0
- package/dist/src/commands/registry.js.map +1 -0
- package/dist/src/commands/secrets/exec.d.ts +17 -0
- package/dist/src/commands/secrets/exec.d.ts.map +1 -0
- package/dist/src/commands/secrets/exec.js +132 -0
- package/dist/src/commands/secrets/exec.js.map +1 -0
- package/dist/src/commands/secrets/index.d.ts +10 -0
- package/dist/src/commands/secrets/index.d.ts.map +1 -0
- package/dist/src/commands/secrets/index.js +35 -0
- package/dist/src/commands/secrets/index.js.map +1 -0
- package/dist/src/commands/secrets/set.d.ts +22 -0
- package/dist/src/commands/secrets/set.d.ts.map +1 -0
- package/dist/src/commands/secrets/set.js +234 -0
- package/dist/src/commands/secrets/set.js.map +1 -0
- package/dist/src/commands/stack.d.ts +17 -0
- package/dist/src/commands/stack.d.ts.map +1 -0
- package/dist/src/commands/stack.js +175 -0
- package/dist/src/commands/stack.js.map +1 -0
- package/dist/src/commands/tunnel/index.d.ts +14 -0
- package/dist/src/commands/tunnel/index.d.ts.map +1 -0
- package/dist/src/commands/tunnel/index.js +217 -0
- package/dist/src/commands/tunnel/index.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/utils/bastion.d.ts +43 -0
- package/dist/src/utils/bastion.d.ts.map +1 -0
- package/dist/src/utils/bastion.js +77 -0
- package/dist/src/utils/bastion.js.map +1 -0
- package/dist/src/utils/context.d.ts +29 -0
- package/dist/src/utils/context.d.ts.map +1 -0
- package/dist/src/utils/context.js +132 -0
- package/dist/src/utils/context.js.map +1 -0
- package/dist/src/utils/credentials.d.ts +61 -0
- package/dist/src/utils/credentials.d.ts.map +1 -0
- package/dist/src/utils/credentials.js +145 -0
- package/dist/src/utils/credentials.js.map +1 -0
- package/dist/src/utils/index.d.ts +9 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +9 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/log.d.ts +8 -0
- package/dist/src/utils/log.d.ts.map +1 -0
- package/dist/src/utils/log.js +17 -0
- package/dist/src/utils/log.js.map +1 -0
- package/dist/src/utils/pulumi.d.ts +24 -0
- package/dist/src/utils/pulumi.d.ts.map +1 -0
- package/dist/src/utils/pulumi.js +63 -0
- package/dist/src/utils/pulumi.js.map +1 -0
- package/package.json +50 -0
- package/templates/api-web-db/api/.dockerignore +2 -0
- package/templates/api-web-db/api/Dockerfile +16 -0
- package/templates/api-web-db/api/package.json.hbs +21 -0
- package/templates/api-web-db/api/src/index.ts.hbs +123 -0
- package/templates/api-web-db/api/tsconfig.json +13 -0
- package/templates/api-web-db/package.json.hbs +27 -0
- package/templates/api-web-db/sst.config.ts.hbs +151 -0
- package/templates/api-web-db/tsconfig.json +11 -0
- package/templates/api-web-db/web/.dockerignore +3 -0
- package/templates/api-web-db/web/Dockerfile +17 -0
- package/templates/api-web-db/web/app/lib/db.server.ts +36 -0
- package/templates/api-web-db/web/app/root.tsx +29 -0
- package/templates/api-web-db/web/app/routes/home.tsx.hbs +114 -0
- package/templates/api-web-db/web/app/routes.ts +3 -0
- package/templates/api-web-db/web/package.json.hbs +30 -0
- package/templates/api-web-db/web/prisma/schema.prisma +25 -0
- package/templates/api-web-db/web/prisma.config.ts +18 -0
- package/templates/api-web-db/web/react-router.config.ts +5 -0
- package/templates/api-web-db/web/tsconfig.json +19 -0
- package/templates/api-web-db/web/vite.config.ts +9 -0
- package/templates/temporal-api-worker/README.md.hbs +133 -0
- package/templates/temporal-api-worker/api/.dockerignore +4 -0
- package/templates/temporal-api-worker/api/Dockerfile +13 -0
- package/templates/temporal-api-worker/api/package.json.hbs +23 -0
- package/templates/temporal-api-worker/api/src/encryption-codec.ts +133 -0
- package/templates/temporal-api-worker/api/src/index.ts.hbs +145 -0
- package/templates/temporal-api-worker/api/tsconfig.json +14 -0
- package/templates/temporal-api-worker/package.json.hbs +29 -0
- package/templates/temporal-api-worker/sst.config.ts.hbs +161 -0
- package/templates/temporal-api-worker/tsconfig.json +10 -0
- package/templates/temporal-api-worker/worker/.dockerignore +4 -0
- package/templates/temporal-api-worker/worker/Dockerfile +11 -0
- package/templates/temporal-api-worker/worker/package.json.hbs +25 -0
- package/templates/temporal-api-worker/worker/src/activities.ts.hbs +49 -0
- package/templates/temporal-api-worker/worker/src/bundle-workflows.ts +38 -0
- package/templates/temporal-api-worker/worker/src/encryption-codec.ts +156 -0
- package/templates/temporal-api-worker/worker/src/worker.ts.hbs +93 -0
- package/templates/temporal-api-worker/worker/src/workflows.ts.hbs +60 -0
- package/templates/temporal-api-worker/worker/tsconfig.json +14 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mesh tunnel - SSM tunneling to platform services
|
|
3
|
+
*
|
|
4
|
+
* Commands:
|
|
5
|
+
* mesh tunnel dev Start all dev tunnels (temporal + db)
|
|
6
|
+
* mesh tunnel --services Start specific services
|
|
7
|
+
* mesh tunnel --list List available services
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "child_process";
|
|
10
|
+
import { getPlatformBastionInfo, logInfo, logError, } from "../../utils/index.js";
|
|
11
|
+
/**
|
|
12
|
+
* Service definitions with their local ports and display names
|
|
13
|
+
*/
|
|
14
|
+
const SERVICE_CONFIG = {
|
|
15
|
+
"temporal-frontend": {
|
|
16
|
+
bastionKey: "temporal-frontend",
|
|
17
|
+
localPort: 7233,
|
|
18
|
+
displayName: "Temporal Frontend (gRPC)",
|
|
19
|
+
},
|
|
20
|
+
"temporal-ui": {
|
|
21
|
+
bastionKey: "temporal-ui",
|
|
22
|
+
localPort: 8080,
|
|
23
|
+
displayName: "Temporal Web UI",
|
|
24
|
+
},
|
|
25
|
+
db: {
|
|
26
|
+
bastionKey: "rds",
|
|
27
|
+
localPort: 5432,
|
|
28
|
+
displayName: "Database (PostgreSQL)",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Service groups for convenience commands
|
|
33
|
+
*/
|
|
34
|
+
const SERVICE_GROUPS = {
|
|
35
|
+
dev: ["temporal-frontend", "temporal-ui", "db"],
|
|
36
|
+
temporal: ["temporal-frontend", "temporal-ui"],
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get the effective local port for a service, using custom port if provided
|
|
40
|
+
*/
|
|
41
|
+
function getEffectivePort(serviceName, options) {
|
|
42
|
+
const config = SERVICE_CONFIG[serviceName];
|
|
43
|
+
if (!config)
|
|
44
|
+
return 0;
|
|
45
|
+
switch (serviceName) {
|
|
46
|
+
case "db":
|
|
47
|
+
return options.dbPort ? parseInt(options.dbPort, 10) : config.localPort;
|
|
48
|
+
case "temporal-ui":
|
|
49
|
+
return options.temporalUiPort
|
|
50
|
+
? parseInt(options.temporalUiPort, 10)
|
|
51
|
+
: config.localPort;
|
|
52
|
+
case "temporal-frontend":
|
|
53
|
+
return options.temporalFrontendPort
|
|
54
|
+
? parseInt(options.temporalFrontendPort, 10)
|
|
55
|
+
: config.localPort;
|
|
56
|
+
default:
|
|
57
|
+
return config.localPort;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parse services from --services flag or group name
|
|
62
|
+
*/
|
|
63
|
+
function parseServices(input) {
|
|
64
|
+
// Check if it's a group name
|
|
65
|
+
if (SERVICE_GROUPS[input]) {
|
|
66
|
+
return SERVICE_GROUPS[input];
|
|
67
|
+
}
|
|
68
|
+
// Otherwise parse as comma-separated list
|
|
69
|
+
return input.split(",").map((s) => s.trim());
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Spawn an SSM tunnel to a service endpoint
|
|
73
|
+
*/
|
|
74
|
+
function spawnSsmTunnel(instanceId, service, localPort) {
|
|
75
|
+
return spawn("aws", [
|
|
76
|
+
"ssm",
|
|
77
|
+
"start-session",
|
|
78
|
+
"--target",
|
|
79
|
+
instanceId,
|
|
80
|
+
"--document-name",
|
|
81
|
+
"AWS-StartPortForwardingSessionToRemoteHost",
|
|
82
|
+
"--parameters",
|
|
83
|
+
JSON.stringify({
|
|
84
|
+
host: [service.host],
|
|
85
|
+
portNumber: [String(service.port)],
|
|
86
|
+
localPortNumber: [String(localPort)],
|
|
87
|
+
}),
|
|
88
|
+
], { stdio: "inherit" });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* List available services
|
|
92
|
+
*/
|
|
93
|
+
async function listServices(options) {
|
|
94
|
+
const { tenant, env } = options;
|
|
95
|
+
const bastion = await getPlatformBastionInfo(tenant, env);
|
|
96
|
+
console.log("");
|
|
97
|
+
logInfo(`Tenant: ${tenant}, Platform Env: ${env}`);
|
|
98
|
+
console.log("");
|
|
99
|
+
console.log("Available services:");
|
|
100
|
+
console.log("");
|
|
101
|
+
for (const [name, config] of Object.entries(SERVICE_CONFIG)) {
|
|
102
|
+
const endpoint = bastion.services[config.bastionKey];
|
|
103
|
+
const status = endpoint ? "✓" : "✗";
|
|
104
|
+
const localPort = getEffectivePort(name, options);
|
|
105
|
+
console.log(` ${status} ${name.padEnd(20)} localhost:${localPort} → ${endpoint?.host ?? "not available"}:${endpoint?.port ?? ""}`);
|
|
106
|
+
}
|
|
107
|
+
console.log("");
|
|
108
|
+
console.log("Service groups:");
|
|
109
|
+
for (const [group, services] of Object.entries(SERVICE_GROUPS)) {
|
|
110
|
+
console.log(` ${group.padEnd(20)} ${services.join(", ")}`);
|
|
111
|
+
}
|
|
112
|
+
console.log("");
|
|
113
|
+
logInfo("Usage:");
|
|
114
|
+
console.log(" mesh tunnel dev # All dev services");
|
|
115
|
+
console.log(" mesh tunnel --services temporal # Just temporal services");
|
|
116
|
+
console.log(" mesh tunnel --services db # Just database");
|
|
117
|
+
console.log("");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Start tunnels to multiple services
|
|
121
|
+
*/
|
|
122
|
+
async function tunnelServices(serviceNames, options) {
|
|
123
|
+
const { tenant, env } = options;
|
|
124
|
+
const bastion = await getPlatformBastionInfo(tenant, env);
|
|
125
|
+
// Resolve service names to configs and endpoints
|
|
126
|
+
const servicesToStart = [];
|
|
127
|
+
for (const name of serviceNames) {
|
|
128
|
+
const config = SERVICE_CONFIG[name];
|
|
129
|
+
if (!config) {
|
|
130
|
+
logError(`Unknown service: ${name}`);
|
|
131
|
+
logInfo(`Available services: ${Object.keys(SERVICE_CONFIG).join(", ")}`);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
const endpoint = bastion.services[config.bastionKey];
|
|
135
|
+
if (!endpoint) {
|
|
136
|
+
logError(`Service '${name}' not available in platform bastion.`);
|
|
137
|
+
logInfo("Make sure the service is enabled and deployed.");
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
servicesToStart.push({ name, config, endpoint });
|
|
141
|
+
}
|
|
142
|
+
if (servicesToStart.length === 0) {
|
|
143
|
+
logError("No services specified.");
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
console.log("");
|
|
147
|
+
logInfo(`Tenant: ${tenant}, Platform Env: ${env}`);
|
|
148
|
+
console.log("");
|
|
149
|
+
logInfo("Starting tunnels...");
|
|
150
|
+
for (const { name, config, endpoint } of servicesToStart) {
|
|
151
|
+
const localPort = getEffectivePort(name, options);
|
|
152
|
+
console.log(` ${config.displayName.padEnd(25)} localhost:${localPort} → ${endpoint.host}:${endpoint.port}`);
|
|
153
|
+
}
|
|
154
|
+
console.log("");
|
|
155
|
+
logInfo("Press Ctrl+C to stop the tunnels");
|
|
156
|
+
console.log("");
|
|
157
|
+
const processes = [];
|
|
158
|
+
for (const { name, endpoint } of servicesToStart) {
|
|
159
|
+
const localPort = getEffectivePort(name, options);
|
|
160
|
+
processes.push(spawnSsmTunnel(bastion.instanceId, endpoint, localPort));
|
|
161
|
+
}
|
|
162
|
+
// Handle cleanup on exit
|
|
163
|
+
const cleanup = () => {
|
|
164
|
+
for (const proc of processes) {
|
|
165
|
+
proc.kill();
|
|
166
|
+
}
|
|
167
|
+
process.exit(0);
|
|
168
|
+
};
|
|
169
|
+
process.on("SIGINT", cleanup);
|
|
170
|
+
process.on("SIGTERM", cleanup);
|
|
171
|
+
// Wait for any process to exit
|
|
172
|
+
await Promise.race(processes.map((proc) => new Promise((resolve) => {
|
|
173
|
+
proc.on("exit", () => resolve());
|
|
174
|
+
proc.on("error", () => resolve());
|
|
175
|
+
})));
|
|
176
|
+
cleanup();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Register tunnel commands with the CLI
|
|
180
|
+
*/
|
|
181
|
+
export function registerTunnelCommands(program) {
|
|
182
|
+
program
|
|
183
|
+
.command("tunnel")
|
|
184
|
+
.description("Start SSM tunnel to platform services")
|
|
185
|
+
.requiredOption("-t, --tenant <tenant>", "Platform tenant (e.g., mesh)")
|
|
186
|
+
.requiredOption("-e, --env <env>", "Platform environment (e.g., dev)")
|
|
187
|
+
.option("-l, --list", "List available services")
|
|
188
|
+
.option("-s, --services <services>", "Services to tunnel (comma-separated or group name)")
|
|
189
|
+
.option("--db-port <port>", "Custom local port for database (default: 5432)")
|
|
190
|
+
.option("--temporal-ui-port <port>", "Custom local port for Temporal UI (default: 8080)")
|
|
191
|
+
.option("--temporal-frontend-port <port>", "Custom local port for Temporal Frontend (default: 7233)")
|
|
192
|
+
.argument("[group]", "Service group to tunnel (e.g., dev, temporal)")
|
|
193
|
+
.action(async (group, options) => {
|
|
194
|
+
// Handle --list
|
|
195
|
+
if (options.list) {
|
|
196
|
+
await listServices(options);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
// Determine which services to start
|
|
200
|
+
let services;
|
|
201
|
+
if (options.services) {
|
|
202
|
+
// Explicit --services flag
|
|
203
|
+
services = parseServices(options.services);
|
|
204
|
+
}
|
|
205
|
+
else if (group) {
|
|
206
|
+
// Positional group argument
|
|
207
|
+
services = parseServices(group);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// No services specified - show help
|
|
211
|
+
await listServices(options);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
await tunnelServices(services, options);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/tunnel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,sBAAsB,EACtB,OAAO,EACP,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAa9B;;GAEG;AACH,MAAM,cAAc,GAGhB;IACF,mBAAmB,EAAE;QACnB,UAAU,EAAE,mBAAmB;QAC/B,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,0BAA0B;KACxC;IACD,aAAa,EAAE;QACb,UAAU,EAAE,aAAa;QACzB,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,iBAAiB;KAC/B;IACD,EAAE,EAAE;QACF,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,uBAAuB;KACrC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAA6B;IAC/C,GAAG,EAAE,CAAC,mBAAmB,EAAE,aAAa,EAAE,IAAI,CAAC;IAC/C,QAAQ,EAAE,CAAC,mBAAmB,EAAE,aAAa,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH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AAC;SACrE,MAAM,CAAC,YAAY,EAAE,yBAAyB,CAAC;SAC/C,MAAM,CAAC,2BAA2B,EAAE,oDAAoD,CAAC;SACzF,MAAM,CAAC,kBAAkB,EAAE,gDAAgD,CAAC;SAC5E,MAAM,CAAC,2BAA2B,EAAE,mDAAmD,CAAC;SACxF,MAAM,CAAC,iCAAiC,EAAE,yDAAyD,CAAC;SACpG,QAAQ,CAAC,SAAS,EAAE,+CAA+C,CAAC;SACpE,MAAM,CAAC,KAAK,EAAE,KAAyB,EAAE,OAAsB,EAAE,EAAE;QAClE,gBAAgB;QAChB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,oCAAoC;QACpC,IAAI,QAAkB,CAAC;QAEvB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,2BAA2B;YAC3B,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,4BAA4B;YAC5B,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,oCAAoC;YACpC,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,MAAM,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bastion utilities for SSM tunneling to platform services
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Service endpoint info
|
|
6
|
+
*/
|
|
7
|
+
export interface ServiceEndpoint {
|
|
8
|
+
host: string;
|
|
9
|
+
port: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Platform bastion info from SSM
|
|
13
|
+
*/
|
|
14
|
+
export interface PlatformBastionInfo {
|
|
15
|
+
instanceId: string;
|
|
16
|
+
securityGroupId: string;
|
|
17
|
+
services: Record<string, ServiceEndpoint>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Legacy bastion info (for backward compatibility with db commands)
|
|
21
|
+
*/
|
|
22
|
+
export interface BastionInfo {
|
|
23
|
+
instanceId: string;
|
|
24
|
+
rdsEndpoint: string;
|
|
25
|
+
rdsPort: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get platform bastion info from SSM parameter store.
|
|
29
|
+
*
|
|
30
|
+
* Reads the platformBastion key from the platform export at
|
|
31
|
+
* /mesh-platform/{tenant}/{platformEnv}/platform. Falls back to the legacy
|
|
32
|
+
* separate parameter at /mesh-platform/{tenant}/{platformEnv}/platform-bastion
|
|
33
|
+
* for backward compatibility.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getPlatformBastionInfo(tenant: string, platformEnv: string): Promise<PlatformBastionInfo>;
|
|
36
|
+
/**
|
|
37
|
+
* Get bastion info from SSM parameter store (legacy format).
|
|
38
|
+
* Reads from /mesh/{tenant}/{platformEnv}/platform-bastion and extracts RDS info.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Use getPlatformBastionInfo instead
|
|
41
|
+
*/
|
|
42
|
+
export declare function getBastionInfo(tenant: string, platformEnv: string): Promise<BastionInfo>;
|
|
43
|
+
//# sourceMappingURL=bastion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bastion.d.ts","sourceRoot":"","sources":["../../../src/utils/bastion.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAyD9B;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,WAAW,CAAC,CAatB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bastion utilities for SSM tunneling to platform services
|
|
3
|
+
*/
|
|
4
|
+
import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
|
|
5
|
+
import { logInfo, logSuccess, logError } from "./log.js";
|
|
6
|
+
/**
|
|
7
|
+
* Get platform bastion info from SSM parameter store.
|
|
8
|
+
*
|
|
9
|
+
* Reads the platformBastion key from the platform export at
|
|
10
|
+
* /mesh-platform/{tenant}/{platformEnv}/platform. Falls back to the legacy
|
|
11
|
+
* separate parameter at /mesh-platform/{tenant}/{platformEnv}/platform-bastion
|
|
12
|
+
* for backward compatibility.
|
|
13
|
+
*/
|
|
14
|
+
export async function getPlatformBastionInfo(tenant, platformEnv) {
|
|
15
|
+
const ssm = new SSMClient({});
|
|
16
|
+
// Primary: read from the platform export (platformBastion is a nested key)
|
|
17
|
+
const platformPath = `/mesh-platform/${tenant}/${platformEnv}/platform`;
|
|
18
|
+
logInfo(`Looking up platform bastion from ${platformPath}...`);
|
|
19
|
+
try {
|
|
20
|
+
const response = await ssm.send(new GetParameterCommand({ Name: platformPath }));
|
|
21
|
+
if (response.Parameter?.Value) {
|
|
22
|
+
const platform = JSON.parse(response.Parameter.Value);
|
|
23
|
+
if (platform.platformBastion) {
|
|
24
|
+
const info = platform.platformBastion;
|
|
25
|
+
logSuccess(`Found bastion: ${info.instanceId}`);
|
|
26
|
+
const serviceNames = Object.keys(info.services);
|
|
27
|
+
if (serviceNames.length > 0) {
|
|
28
|
+
logInfo(`Available services: ${serviceNames.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
return info;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Platform param not found or unreadable, try legacy path
|
|
36
|
+
}
|
|
37
|
+
// Fallback: legacy separate parameter
|
|
38
|
+
const legacyPath = `/mesh-platform/${tenant}/${platformEnv}/platform-bastion`;
|
|
39
|
+
logInfo(`Trying legacy path ${legacyPath}...`);
|
|
40
|
+
try {
|
|
41
|
+
const response = await ssm.send(new GetParameterCommand({ Name: legacyPath }));
|
|
42
|
+
if (!response.Parameter?.Value) {
|
|
43
|
+
throw new Error(`Platform bastion not found`);
|
|
44
|
+
}
|
|
45
|
+
const info = JSON.parse(response.Parameter.Value);
|
|
46
|
+
logSuccess(`Found bastion: ${info.instanceId}`);
|
|
47
|
+
const serviceNames = Object.keys(info.services);
|
|
48
|
+
if (serviceNames.length > 0) {
|
|
49
|
+
logInfo(`Available services: ${serviceNames.join(", ")}`);
|
|
50
|
+
}
|
|
51
|
+
return info;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
logError(`Platform bastion not found in ${platformPath} or ${legacyPath}`);
|
|
55
|
+
logInfo("Make sure platformBastion is enabled in your platform config and deployed.");
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get bastion info from SSM parameter store (legacy format).
|
|
61
|
+
* Reads from /mesh/{tenant}/{platformEnv}/platform-bastion and extracts RDS info.
|
|
62
|
+
*
|
|
63
|
+
* @deprecated Use getPlatformBastionInfo instead
|
|
64
|
+
*/
|
|
65
|
+
export async function getBastionInfo(tenant, platformEnv) {
|
|
66
|
+
const info = await getPlatformBastionInfo(tenant, platformEnv);
|
|
67
|
+
const rdsService = info.services["rds"];
|
|
68
|
+
if (!rdsService) {
|
|
69
|
+
throw new Error("RDS service not available in platform bastion. Is RDS enabled?");
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
instanceId: info.instanceId,
|
|
73
|
+
rdsEndpoint: rdsService.host,
|
|
74
|
+
rdsPort: rdsService.port,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=bastion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bastion.js","sourceRoot":"","sources":["../../../src/utils/bastion.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA4BzD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAc,EACd,WAAmB;IAEnB,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC;IAE9B,2EAA2E;IAC3E,MAAM,YAAY,GAAG,kBAAkB,MAAM,IAAI,WAAW,WAAW,CAAC;IACxE,OAAO,CAAC,oCAAoC,YAAY,KAAK,CAAC,CAAC;IAE/D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,CAC7B,IAAI,mBAAmB,CAAC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AAE,CAAC,CAAC;QAEhD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,uBAAuB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,iCAAiC,YAAY,OAAO,UAAU,EAAE,CAAC,CAAC;QAC3E,OAAO,CAAC,4EAA4E,CAAC,CAAC;QACtF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,WAAmB;IAEnB,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAE/D,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;IACpF,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,UAAU,CAAC,IAAI;QAC5B,OAAO,EAAE,UAAU,CAAC,IAAI;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context detection - determines tenant, stage, and platform environment
|
|
3
|
+
* from the current directory and environment variables.
|
|
4
|
+
*/
|
|
5
|
+
export interface MeshContext {
|
|
6
|
+
tenant: string;
|
|
7
|
+
stage: string;
|
|
8
|
+
platformEnv: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Detect tenant and stage from current directory and environment.
|
|
12
|
+
*
|
|
13
|
+
* Priority for stage:
|
|
14
|
+
* 1. --stage flag (passed as stageArg)
|
|
15
|
+
* 2. MESH_STAGE env var
|
|
16
|
+
* 3. SST_STAGE env var
|
|
17
|
+
* 4. .sst/stage file
|
|
18
|
+
* 5. Pulumi config file name
|
|
19
|
+
* 6. Default: "dev"
|
|
20
|
+
*
|
|
21
|
+
* Priority for tenant:
|
|
22
|
+
* 1. MESH_TENANT env var
|
|
23
|
+
* 2. config.ts tenant field
|
|
24
|
+
* 3. Pulumi config mesh:tenant
|
|
25
|
+
* 4. Directory path (tenants/{tenant}/...)
|
|
26
|
+
* 5. Default: "mesh"
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectContext(stageArg?: string): MeshContext;
|
|
29
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAoBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CA8G5D"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context detection - determines tenant, stage, and platform environment
|
|
3
|
+
* from the current directory and environment variables.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import { logInfo } from "./log.js";
|
|
8
|
+
/**
|
|
9
|
+
* Find a file by walking up directories from the starting directory.
|
|
10
|
+
* Returns the full path to the file if found, undefined otherwise.
|
|
11
|
+
*/
|
|
12
|
+
function findFileUpward(filename, startDir = process.cwd()) {
|
|
13
|
+
let currentDir = startDir;
|
|
14
|
+
const root = path.parse(currentDir).root;
|
|
15
|
+
while (currentDir !== root) {
|
|
16
|
+
const filePath = path.join(currentDir, filename);
|
|
17
|
+
if (fs.existsSync(filePath)) {
|
|
18
|
+
return filePath;
|
|
19
|
+
}
|
|
20
|
+
currentDir = path.dirname(currentDir);
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Detect tenant and stage from current directory and environment.
|
|
26
|
+
*
|
|
27
|
+
* Priority for stage:
|
|
28
|
+
* 1. --stage flag (passed as stageArg)
|
|
29
|
+
* 2. MESH_STAGE env var
|
|
30
|
+
* 3. SST_STAGE env var
|
|
31
|
+
* 4. .sst/stage file
|
|
32
|
+
* 5. Pulumi config file name
|
|
33
|
+
* 6. Default: "dev"
|
|
34
|
+
*
|
|
35
|
+
* Priority for tenant:
|
|
36
|
+
* 1. MESH_TENANT env var
|
|
37
|
+
* 2. config.ts tenant field
|
|
38
|
+
* 3. Pulumi config mesh:tenant
|
|
39
|
+
* 4. Directory path (tenants/{tenant}/...)
|
|
40
|
+
* 5. Default: "mesh"
|
|
41
|
+
*/
|
|
42
|
+
export function detectContext(stageArg) {
|
|
43
|
+
let tenant;
|
|
44
|
+
let stage;
|
|
45
|
+
const cwd = process.cwd();
|
|
46
|
+
// Try to detect from Pulumi.yaml
|
|
47
|
+
if (fs.existsSync("Pulumi.yaml")) {
|
|
48
|
+
// Look for Pulumi.*.yaml config files
|
|
49
|
+
const files = fs.readdirSync(".").filter((f) => f.startsWith("Pulumi.") && f.endsWith(".yaml") && f !== "Pulumi.yaml");
|
|
50
|
+
const configFile = files[0];
|
|
51
|
+
if (configFile) {
|
|
52
|
+
const content = fs.readFileSync(configFile, "utf-8");
|
|
53
|
+
// Extract tenant from mesh:tenant config
|
|
54
|
+
const tenantMatch = content.match(/^\s*mesh:tenant:\s*["']?([^"'\n]+)["']?/m);
|
|
55
|
+
if (tenantMatch?.[1]) {
|
|
56
|
+
tenant = tenantMatch[1].trim();
|
|
57
|
+
}
|
|
58
|
+
// Extract stage from filename: Pulumi.<stage>.yaml
|
|
59
|
+
const stageMatch = configFile.match(/Pulumi\.(.+)\.yaml/);
|
|
60
|
+
if (stageMatch?.[1]) {
|
|
61
|
+
stage = stageMatch[1];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Try to detect from SST config (walk up directories to find it)
|
|
66
|
+
const sstConfigPath = findFileUpward("sst.config.ts");
|
|
67
|
+
let sstDir;
|
|
68
|
+
if (sstConfigPath) {
|
|
69
|
+
sstDir = path.dirname(sstConfigPath);
|
|
70
|
+
// Check parent config.ts for tenant (relative to sst.config.ts location)
|
|
71
|
+
const parentConfigPath = path.join(sstDir, "..", "config.ts");
|
|
72
|
+
if (fs.existsSync(parentConfigPath)) {
|
|
73
|
+
const configContent = fs.readFileSync(parentConfigPath, "utf-8");
|
|
74
|
+
const tenantMatch = configContent.match(/tenant:\s*["']([^"']+)["']/);
|
|
75
|
+
if (tenantMatch) {
|
|
76
|
+
tenant = tenantMatch[1];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Check .sst/stage for current stage (relative to sst.config.ts location)
|
|
80
|
+
const sstStagePath = path.join(sstDir, ".sst", "stage");
|
|
81
|
+
if (fs.existsSync(sstStagePath)) {
|
|
82
|
+
stage = fs.readFileSync(sstStagePath, "utf-8").trim();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Fallback: infer tenant from directory path
|
|
86
|
+
if (!tenant) {
|
|
87
|
+
const pathMatch = cwd.match(/tenants\/([^/]+)/);
|
|
88
|
+
if (pathMatch) {
|
|
89
|
+
tenant = pathMatch[1];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Apply priority: stageArg > MESH_STAGE > SST_STAGE > detected > default
|
|
93
|
+
stage = stageArg || process.env.MESH_STAGE || process.env.SST_STAGE || stage || "dev";
|
|
94
|
+
tenant = process.env.MESH_TENANT || tenant || "mesh";
|
|
95
|
+
// Resolve platform environment from config.ts if available
|
|
96
|
+
let platformEnv = stage;
|
|
97
|
+
let platformEnvMap = {};
|
|
98
|
+
let defaultPlatformEnv;
|
|
99
|
+
// Try to read platformEnvMap and defaultPlatformEnv from config.ts (relative to sst.config.ts location)
|
|
100
|
+
const configPath = sstDir ? path.join(sstDir, "..", "config.ts") : "../config.ts";
|
|
101
|
+
if (fs.existsSync(configPath)) {
|
|
102
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
103
|
+
// Parse platformEnvMap object
|
|
104
|
+
const mapMatch = configContent.match(/platformEnvMap:\s*\{([^}]+)\}/);
|
|
105
|
+
if (mapMatch?.[1]) {
|
|
106
|
+
const entries = mapMatch[1].matchAll(/(\w+):\s*["']([^"']+)["']/g);
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
const key = entry[1];
|
|
109
|
+
const value = entry[2];
|
|
110
|
+
if (key && value) {
|
|
111
|
+
platformEnvMap[key] = value;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Parse defaultPlatformEnv
|
|
116
|
+
const defaultMatch = configContent.match(/defaultPlatformEnv:\s*["']([^"']+)["']/);
|
|
117
|
+
if (defaultMatch?.[1]) {
|
|
118
|
+
defaultPlatformEnv = defaultMatch[1];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Parse env from stage by stripping tenant prefix (matches Pulumi pattern)
|
|
122
|
+
// e.g., "mesh-dev-temporal" → env "dev-temporal"
|
|
123
|
+
const tenantPrefix = `${tenant}-`;
|
|
124
|
+
const parsedEnv = stage.startsWith(tenantPrefix)
|
|
125
|
+
? stage.slice(tenantPrefix.length)
|
|
126
|
+
: stage;
|
|
127
|
+
// Use config mapping if available, then defaultPlatformEnv, otherwise use parsed env directly
|
|
128
|
+
platformEnv = platformEnvMap[parsedEnv] ?? platformEnvMap[stage] ?? defaultPlatformEnv ?? parsedEnv;
|
|
129
|
+
logInfo(`Stage: ${stage}, Platform: ${platformEnv}, Tenant: ${tenant}`);
|
|
130
|
+
return { tenant, stage, platformEnv };
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/utils/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAQnC;;;GAGG;AACH,SAAS,cAAc,CAAC,QAAgB,EAAE,WAAmB,OAAO,CAAC,GAAG,EAAE;IACxE,IAAI,UAAU,GAAG,QAAQ,CAAC;IAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;IAEzC,OAAO,UAAU,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACjD,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa,CAAC,QAAiB;IAC7C,IAAI,MAA0B,CAAC;IAC/B,IAAI,KAAyB,CAAC;IAE9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1B,iCAAiC;IACjC,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACjC,sCAAsC;QACtC,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,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1
|
+
/**
|
|
2
|
+
* Database credential utilities
|
|
3
|
+
*/
|
|
4
|
+
export interface DatabaseCredentials {
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
database: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Options for credential lookup
|
|
13
|
+
*/
|
|
14
|
+
export interface CredentialLookupOptions {
|
|
15
|
+
/** App name (e.g., "rdc") - if provided, uses path mesh/{tenant}/{stage}/{app}/db-credentials */
|
|
16
|
+
app?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get DATABASE_URL from Secrets Manager.
|
|
20
|
+
*
|
|
21
|
+
* Credential path patterns:
|
|
22
|
+
* - With app: mesh/{tenant}/{stage}/{app}/db-credentials
|
|
23
|
+
* - Without app: mesh/{tenant}/{stage}/db-credentials
|
|
24
|
+
*
|
|
25
|
+
* Returns the DATABASE_URL string directly. Use rewriteDatabaseUrl() to
|
|
26
|
+
* modify host/port for tunnel usage.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDatabaseUrl(tenant: string, stage: string, options?: CredentialLookupOptions): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use getDatabaseUrl instead - returns DATABASE_URL directly
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDbCredentials(tenant: string, stage: string, _platformEnv: string, rdsHost: string, rdsPort: number, options?: CredentialLookupOptions): Promise<DatabaseCredentials>;
|
|
33
|
+
/**
|
|
34
|
+
* Options for rewriting DATABASE_URL
|
|
35
|
+
*/
|
|
36
|
+
export interface DatabaseUrlRewriteOptions {
|
|
37
|
+
/** New host:port endpoint (e.g., "localhost:5432") */
|
|
38
|
+
endpoint?: string;
|
|
39
|
+
/** SSL mode (require, no-verify, disable) */
|
|
40
|
+
sslMode?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Rewrite DATABASE_URL with new endpoint and/or SSL mode.
|
|
44
|
+
* Preserves username, password, database name, and other query params.
|
|
45
|
+
*
|
|
46
|
+
* Used by both mesh-env-exec (for sst dev) and mesh db exec (for ad-hoc commands).
|
|
47
|
+
*/
|
|
48
|
+
export declare function rewriteDatabaseUrl(url: string, options: DatabaseUrlRewriteOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Build a DATABASE_URL from credentials.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildDatabaseUrl(creds: DatabaseCredentials, options?: DatabaseUrlRewriteOptions): string;
|
|
53
|
+
/**
|
|
54
|
+
* Try to read database info from SST outputs (when sst dev has run).
|
|
55
|
+
*/
|
|
56
|
+
export declare function readSstOutputs(): Promise<{
|
|
57
|
+
databaseUrl?: string;
|
|
58
|
+
databaseName?: string;
|
|
59
|
+
secretArn?: string;
|
|
60
|
+
} | null>;
|
|
61
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/utils/credentials.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,iGAAiG;IACjG,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,MAAM,CAAC,CAyCjB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM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