vyft 0.3.0-alpha → 0.4.1-alpha
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/LICENSE +191 -21
- package/README.md +3 -49
- package/dist/commands/context/add.d.ts +4 -0
- package/dist/commands/context/add.d.ts.map +1 -0
- package/dist/commands/context/add.js +98 -0
- package/dist/commands/context/add.js.map +1 -0
- package/dist/commands/context/index.d.ts +4 -0
- package/dist/commands/context/index.d.ts.map +1 -0
- package/dist/commands/context/index.js +12 -0
- package/dist/commands/context/index.js.map +1 -0
- package/dist/commands/context/list.d.ts +4 -0
- package/dist/commands/context/list.d.ts.map +1 -0
- package/dist/commands/context/list.js +25 -0
- package/dist/commands/context/list.js.map +1 -0
- package/dist/commands/context/remove.d.ts +4 -0
- package/dist/commands/context/remove.d.ts.map +1 -0
- package/dist/commands/context/remove.js +36 -0
- package/dist/commands/context/remove.js.map +1 -0
- package/dist/commands/context/use.d.ts +4 -0
- package/dist/commands/context/use.d.ts.map +1 -0
- package/dist/commands/context/use.js +32 -0
- package/dist/commands/context/use.js.map +1 -0
- package/dist/commands/deploy.d.ts +4 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +55 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +4 -0
- package/dist/commands/destroy.d.ts.map +1 -0
- package/dist/commands/destroy.js +70 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/diff.d.ts +4 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +52 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +92 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/local/detect.d.ts +7 -0
- package/dist/commands/local/detect.d.ts.map +1 -0
- package/dist/commands/local/detect.js +146 -0
- package/dist/commands/local/detect.js.map +1 -0
- package/dist/commands/local/dev.d.ts +4 -0
- package/dist/commands/local/dev.d.ts.map +1 -0
- package/dist/commands/local/dev.js +339 -0
- package/dist/commands/local/dev.js.map +1 -0
- package/dist/commands/local/down.d.ts +4 -0
- package/dist/commands/local/down.d.ts.map +1 -0
- package/dist/commands/local/down.js +61 -0
- package/dist/commands/local/down.js.map +1 -0
- package/dist/commands/local/index.d.ts +4 -0
- package/dist/commands/local/index.d.ts.map +1 -0
- package/dist/commands/local/index.js +12 -0
- package/dist/commands/local/index.js.map +1 -0
- package/dist/commands/local/reset.d.ts +4 -0
- package/dist/commands/local/reset.d.ts.map +1 -0
- package/dist/commands/local/reset.js +67 -0
- package/dist/commands/local/reset.js.map +1 -0
- package/dist/commands/local/up.d.ts +4 -0
- package/dist/commands/local/up.d.ts.map +1 -0
- package/dist/commands/local/up.js +58 -0
- package/dist/commands/local/up.js.map +1 -0
- package/dist/commands/refresh.d.ts +4 -0
- package/dist/commands/refresh.d.ts.map +1 -0
- package/dist/commands/refresh.js +39 -0
- package/dist/commands/refresh.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +69 -0
- package/dist/config.js.map +1 -0
- package/dist/contexts.d.ts +21 -0
- package/dist/contexts.d.ts.map +1 -0
- package/dist/contexts.js +72 -0
- package/dist/contexts.js.map +1 -0
- package/dist/index.d.ts +2 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +7 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +6 -0
- package/dist/lib.js.map +1 -0
- package/dist/providers.d.ts +9 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +41 -0
- package/dist/providers.js.map +1 -0
- package/dist/runtime.d.ts +18 -9
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +154 -0
- package/dist/runtime.js.map +1 -0
- package/dist/runtime.test.d.ts +2 -0
- package/dist/runtime.test.d.ts.map +1 -0
- package/dist/runtime.test.js +119 -0
- package/dist/runtime.test.js.map +1 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +33 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/pm.d.ts +3 -0
- package/dist/utils/pm.d.ts.map +1 -0
- package/dist/utils/pm.js +17 -0
- package/dist/utils/pm.js.map +1 -0
- package/dist/utils/prompts.d.ts +2 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +6 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/templates.d.ts +3 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +48 -0
- package/dist/utils/templates.js.map +1 -0
- package/package.json +31 -46
- package/templates/bun/index.ts +8 -0
- package/templates/bun/package.json +15 -0
- package/templates/bun/tsconfig.json +15 -0
- package/templates/bun/vyft.config.ts +3 -0
- package/dist/build.d.ts +0 -11
- package/dist/build.js +0 -39
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -398
- package/dist/context.d.ts +0 -39
- package/dist/context.js +0 -101
- package/dist/docker.d.ts +0 -62
- package/dist/docker.js +0 -876
- package/dist/exec.d.ts +0 -2
- package/dist/exec.js +0 -28
- package/dist/init.d.ts +0 -1
- package/dist/init.js +0 -117
- package/dist/interpolate.d.ts +0 -13
- package/dist/interpolate.js +0 -19
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -10
- package/dist/proxy.d.ts +0 -16
- package/dist/proxy.js +0 -0
- package/dist/resource.d.ts +0 -174
- package/dist/resource.js +0 -45
- package/dist/services/index.d.ts +0 -24
- package/dist/services/index.js +0 -20
- package/dist/services/minio.d.ts +0 -36
- package/dist/services/minio.js +0 -53
- package/dist/services/mongo.d.ts +0 -28
- package/dist/services/mongo.js +0 -45
- package/dist/services/mysql.d.ts +0 -28
- package/dist/services/mysql.js +0 -44
- package/dist/services/nats.d.ts +0 -26
- package/dist/services/nats.js +0 -38
- package/dist/services/postgres.d.ts +0 -28
- package/dist/services/postgres.js +0 -45
- package/dist/services/rabbitmq.d.ts +0 -28
- package/dist/services/rabbitmq.js +0 -44
- package/dist/services/redis.d.ts +0 -28
- package/dist/services/redis.js +0 -49
- package/dist/services/storage.d.ts +0 -39
- package/dist/services/storage.js +0 -94
- package/dist/swarm/factories.d.ts +0 -16
- package/dist/swarm/factories.js +0 -63
- package/dist/swarm/index.d.ts +0 -20
- package/dist/swarm/index.js +0 -5
- package/dist/swarm/proxy.d.ts +0 -24
- package/dist/swarm/proxy.js +0 -339
- package/dist/swarm/types.d.ts +0 -26
- package/dist/swarm/types.js +0 -0
- package/dist/symbols.d.ts +0 -13
- package/dist/symbols.js +0 -2
- package/templates/fullstack/apps/api/Dockerfile +0 -22
- package/templates/fullstack/apps/api/package.json +0 -26
- package/templates/fullstack/apps/api/src/auth.ts +0 -21
- package/templates/fullstack/apps/api/src/db.ts +0 -16
- package/templates/fullstack/apps/api/src/index.ts +0 -17
- package/templates/fullstack/apps/api/src/router.ts +0 -11
- package/templates/fullstack/apps/api/src/schema.ts +0 -11
- package/templates/fullstack/apps/api/tsconfig.json +0 -8
- package/templates/fullstack/apps/web/index.html +0 -12
- package/templates/fullstack/apps/web/package.json +0 -21
- package/templates/fullstack/apps/web/src/app.tsx +0 -8
- package/templates/fullstack/apps/web/src/main.tsx +0 -9
- package/templates/fullstack/apps/web/tsconfig.json +0 -7
- package/templates/fullstack/apps/web/vite.config.ts +0 -14
- package/templates/fullstack/compose.yaml +0 -14
- package/templates/fullstack/dockerignore +0 -7
- package/templates/fullstack/gitignore +0 -3
- package/templates/fullstack/package.json +0 -18
- package/templates/fullstack/pnpm-workspace.yaml +0 -2
- package/templates/fullstack/tsconfig.json +0 -11
- package/templates/fullstack/vyft.config.ts +0 -22
package/dist/exec.d.ts
DELETED
package/dist/exec.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
export async function exec(command, cwd, env, log) {
|
|
3
|
-
const start = performance.now();
|
|
4
|
-
log?.debug({ command, cwd }, "process spawning");
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const proc = spawn(command, {
|
|
7
|
-
cwd,
|
|
8
|
-
stdio: "inherit",
|
|
9
|
-
shell: true,
|
|
10
|
-
env: env ? { ...process.env, ...env } : undefined,
|
|
11
|
-
});
|
|
12
|
-
proc.on("close", (code) => {
|
|
13
|
-
const durationMs = Math.round(performance.now() - start);
|
|
14
|
-
if (code !== 0) {
|
|
15
|
-
log?.debug({ command, cwd, exitCode: code, durationMs }, "process exited with error");
|
|
16
|
-
reject(new Error(`Command failed with exit code ${code}`));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
log?.debug({ command, cwd, exitCode: 0, durationMs }, "process exited");
|
|
20
|
-
resolve();
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
proc.on("error", (err) => {
|
|
24
|
-
log?.debug({ err, command, cwd }, "process spawn failed");
|
|
25
|
-
reject(err);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
package/dist/init.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function init(directory?: string): Promise<void>;
|
package/dist/init.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { confirm, intro, isCancel, log, outro, text } from "@clack/prompts";
|
|
6
|
-
const TEMPLATES_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../templates/fullstack");
|
|
7
|
-
async function walkDir(dir) {
|
|
8
|
-
const files = [];
|
|
9
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
10
|
-
for (const entry of entries) {
|
|
11
|
-
const full = path.join(dir, entry.name);
|
|
12
|
-
if (entry.isDirectory()) {
|
|
13
|
-
files.push(...(await walkDir(full)));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
files.push(full);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return files;
|
|
20
|
-
}
|
|
21
|
-
async function dirExists(dir) {
|
|
22
|
-
try {
|
|
23
|
-
const s = await stat(dir);
|
|
24
|
-
return s.isDirectory();
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function dirIsNonEmpty(dir) {
|
|
31
|
-
try {
|
|
32
|
-
const entries = await readdir(dir);
|
|
33
|
-
return entries.length > 0;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export async function init(directory) {
|
|
40
|
-
intro("Create a new project");
|
|
41
|
-
const name = await text({
|
|
42
|
-
message: "Project name",
|
|
43
|
-
placeholder: "my-app",
|
|
44
|
-
defaultValue: directory || "my-app",
|
|
45
|
-
validate(value) {
|
|
46
|
-
if (!value)
|
|
47
|
-
return "Project name is required";
|
|
48
|
-
if (!/^[a-z0-9-]+$/.test(value))
|
|
49
|
-
return "Use lowercase letters, numbers, and hyphens only";
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
if (isCancel(name))
|
|
53
|
-
return;
|
|
54
|
-
const domain = await text({
|
|
55
|
-
message: "Domain",
|
|
56
|
-
placeholder: "example.com",
|
|
57
|
-
validate(value) {
|
|
58
|
-
if (!value)
|
|
59
|
-
return "Domain is required";
|
|
60
|
-
if (!/^[a-z0-9.-]+\.[a-z]{2,}$/.test(value))
|
|
61
|
-
return "Enter a valid domain (e.g. example.com)";
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
if (isCancel(domain))
|
|
65
|
-
return;
|
|
66
|
-
const targetDir = path.resolve(process.cwd(), directory || name);
|
|
67
|
-
if ((await dirExists(targetDir)) && (await dirIsNonEmpty(targetDir))) {
|
|
68
|
-
const ok = await confirm({
|
|
69
|
-
message: `Directory ${path.basename(targetDir)} is not empty. Continue?`,
|
|
70
|
-
});
|
|
71
|
-
if (isCancel(ok) || !ok)
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const templateFiles = await walkDir(TEMPLATES_DIR);
|
|
75
|
-
const replacements = {
|
|
76
|
-
"{{name}}": name,
|
|
77
|
-
"{{domain}}": domain,
|
|
78
|
-
};
|
|
79
|
-
for (const templateFile of templateFiles) {
|
|
80
|
-
let relativePath = path.relative(TEMPLATES_DIR, templateFile);
|
|
81
|
-
if (relativePath === "gitignore")
|
|
82
|
-
relativePath = ".gitignore";
|
|
83
|
-
if (relativePath === "dockerignore")
|
|
84
|
-
relativePath = ".dockerignore";
|
|
85
|
-
const destPath = path.join(targetDir, relativePath);
|
|
86
|
-
await mkdir(path.dirname(destPath), { recursive: true });
|
|
87
|
-
let content = await readFile(templateFile, "utf-8");
|
|
88
|
-
for (const [placeholder, value] of Object.entries(replacements)) {
|
|
89
|
-
content = content.replaceAll(placeholder, value);
|
|
90
|
-
}
|
|
91
|
-
await writeFile(destPath, content);
|
|
92
|
-
log.step(relativePath);
|
|
93
|
-
}
|
|
94
|
-
const ua = process.env.npm_config_user_agent ?? "";
|
|
95
|
-
const pm = ua.startsWith("pnpm")
|
|
96
|
-
? "pnpm"
|
|
97
|
-
: ua.startsWith("bun")
|
|
98
|
-
? "bun"
|
|
99
|
-
: "npm";
|
|
100
|
-
const install = await confirm({
|
|
101
|
-
message: `Install dependencies with ${pm}?`,
|
|
102
|
-
});
|
|
103
|
-
if (isCancel(install))
|
|
104
|
-
return;
|
|
105
|
-
if (install) {
|
|
106
|
-
log.step(`Running ${pm} install...`);
|
|
107
|
-
execSync(`${pm} install`, { cwd: targetDir, stdio: "inherit" });
|
|
108
|
-
}
|
|
109
|
-
outro("Project created");
|
|
110
|
-
console.log();
|
|
111
|
-
console.log("Next steps:");
|
|
112
|
-
console.log(` cd ${path.relative(process.cwd(), targetDir)}`);
|
|
113
|
-
if (!install)
|
|
114
|
-
console.log(` ${pm} install`);
|
|
115
|
-
console.log(` ${pm} dev`);
|
|
116
|
-
console.log();
|
|
117
|
-
}
|
package/dist/interpolate.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Interpolation, Reference } from "./resource.js";
|
|
2
|
-
/**
|
|
3
|
-
* Tagged template literal for building strings that contain {@link Reference} values
|
|
4
|
-
* (e.g. secrets) which are resolved at deploy time.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const connStr = interpolate`postgres://user:${dbPassword}@${db.host}:5432/app`;
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @throws If none of the interpolated values are a {@link Reference}.
|
|
12
|
-
*/
|
|
13
|
-
export declare function interpolate(strings: TemplateStringsArray, ...values: Array<Reference | string>): Interpolation;
|
package/dist/interpolate.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isReference } from "./resource.js";
|
|
2
|
-
/**
|
|
3
|
-
* Tagged template literal for building strings that contain {@link Reference} values
|
|
4
|
-
* (e.g. secrets) which are resolved at deploy time.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const connStr = interpolate`postgres://user:${dbPassword}@${db.host}:5432/app`;
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @throws If none of the interpolated values are a {@link Reference}.
|
|
12
|
-
*/
|
|
13
|
-
export function interpolate(strings, ...values) {
|
|
14
|
-
const hasRef = values.some(isReference);
|
|
15
|
-
if (!hasRef) {
|
|
16
|
-
throw new Error("interpolate() requires at least one Reference — use a plain string instead");
|
|
17
|
-
}
|
|
18
|
-
return { type: "interpolation", strings, values };
|
|
19
|
-
}
|
package/dist/logger.d.ts
DELETED
package/dist/logger.js
DELETED
package/dist/proxy.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface ReverseProxy {
|
|
2
|
-
/** Ensure the proxy service is running and configured. */
|
|
3
|
-
ensure(): Promise<void>;
|
|
4
|
-
/** Register or update a route for a resource. */
|
|
5
|
-
addRoute(resourceId: string, route: string, target: {
|
|
6
|
-
host: string;
|
|
7
|
-
port: number;
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
/** Remove a route for a resource. No-op if it doesn't exist. */
|
|
10
|
-
removeRoute(resourceId: string): Promise<void>;
|
|
11
|
-
/** Stream proxy access logs. */
|
|
12
|
-
logs(options: {
|
|
13
|
-
follow?: boolean;
|
|
14
|
-
tail?: number;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
}
|
package/dist/proxy.js
DELETED
|
File without changes
|
package/dist/resource.d.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import type { RuntimeRef } from "./symbols.js";
|
|
2
|
-
/** Discriminant for the four resource kinds. */
|
|
3
|
-
export type ResourceType = "volume" | "secret" | "service" | "site";
|
|
4
|
-
/** Configuration for a persistent volume. */
|
|
5
|
-
export interface VolumeConfig {
|
|
6
|
-
/** Human-readable size hint (e.g. `"10GB"`). Informational only. */
|
|
7
|
-
size?: string;
|
|
8
|
-
}
|
|
9
|
-
/** Configuration for an auto-generated secret. */
|
|
10
|
-
export interface SecretConfig {
|
|
11
|
-
/** Length of the generated random value in bytes. */
|
|
12
|
-
length?: number;
|
|
13
|
-
}
|
|
14
|
-
/** Container health-check configuration. */
|
|
15
|
-
export interface HealthCheckConfig {
|
|
16
|
-
/** Command to run inside the container (e.g. `["pg_isready", "-U", "postgres"]`). */
|
|
17
|
-
command: string[];
|
|
18
|
-
/** Time between checks (e.g. `"5s"`, `"1m"`). */
|
|
19
|
-
interval?: string;
|
|
20
|
-
/** Maximum time a single check may take. */
|
|
21
|
-
timeout?: string;
|
|
22
|
-
/** Consecutive failures required to mark unhealthy. */
|
|
23
|
-
retries?: number;
|
|
24
|
-
/** Grace period before the first check runs. */
|
|
25
|
-
startPeriod?: string;
|
|
26
|
-
}
|
|
27
|
-
/** CPU and memory limits for a service. */
|
|
28
|
-
export interface ResourceLimits {
|
|
29
|
-
/** Memory ceiling (e.g. `"512MB"`, `"2GB"`). */
|
|
30
|
-
memory?: string;
|
|
31
|
-
/** CPU core limit (e.g. `0.5`, `2`). */
|
|
32
|
-
cpus?: number;
|
|
33
|
-
}
|
|
34
|
-
/** A persistent storage volume. */
|
|
35
|
-
export interface Volume extends RuntimeRef {
|
|
36
|
-
type: "volume";
|
|
37
|
-
id: string;
|
|
38
|
-
config: VolumeConfig;
|
|
39
|
-
}
|
|
40
|
-
/** An auto-generated secret value, injected at deploy time. */
|
|
41
|
-
export interface Secret extends RuntimeRef {
|
|
42
|
-
type: "secret";
|
|
43
|
-
id: string;
|
|
44
|
-
config: SecretConfig;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* A long-running service (container).
|
|
48
|
-
*
|
|
49
|
-
* Use `host` and `port` to reference this service from other services
|
|
50
|
-
* in the same project, or `url` for the full address.
|
|
51
|
-
*/
|
|
52
|
-
export interface Service extends RuntimeRef {
|
|
53
|
-
type: "service";
|
|
54
|
-
id: string;
|
|
55
|
-
config: ServiceConfig;
|
|
56
|
-
/** Internal hostname reachable by other services. */
|
|
57
|
-
host: string;
|
|
58
|
-
/** Port the service listens on. */
|
|
59
|
-
port: number;
|
|
60
|
-
/** Full URL — `https://<route>` if routed, otherwise `http://<host>:<port>`. */
|
|
61
|
-
url: string;
|
|
62
|
-
}
|
|
63
|
-
/** A static site served via Caddy. */
|
|
64
|
-
export interface Site extends RuntimeRef {
|
|
65
|
-
type: "site";
|
|
66
|
-
id: string;
|
|
67
|
-
config: SiteConfig;
|
|
68
|
-
/** Public URL derived from the route (e.g. `https://example.com`). */
|
|
69
|
-
url: string;
|
|
70
|
-
}
|
|
71
|
-
/** Union of all deployable resource types. */
|
|
72
|
-
export type Resource = Volume | Secret | Service | Site;
|
|
73
|
-
/**
|
|
74
|
-
* A deferred reference to a value that isn't known until deploy time.
|
|
75
|
-
*
|
|
76
|
-
* Currently only {@link Secret} produces deferred values. Expand this
|
|
77
|
-
* union as more resources gain deferred outputs.
|
|
78
|
-
*/
|
|
79
|
-
export type Reference = Secret;
|
|
80
|
-
/**
|
|
81
|
-
* A tagged-template interpolation that mixes literal strings with
|
|
82
|
-
* {@link Reference} values. Created via {@link interpolate}.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* const connStr = interpolate`postgres://user:${dbPassword}@${db.host}:5432/app`;
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
export interface Interpolation {
|
|
90
|
-
type: "interpolation";
|
|
91
|
-
strings: TemplateStringsArray;
|
|
92
|
-
values: Array<Reference | string>;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* A value that can appear in a service's `env` map.
|
|
96
|
-
*
|
|
97
|
-
* - Plain `string` — set verbatim.
|
|
98
|
-
* - {@link Reference} — resolved at deploy time (e.g. a secret).
|
|
99
|
-
* - {@link Interpolation} — a template mixing strings and references.
|
|
100
|
-
*/
|
|
101
|
-
export type EnvValue = string | Reference | Interpolation;
|
|
102
|
-
/** Type-guard: returns `true` if `value` is a {@link Reference}. */
|
|
103
|
-
export declare function isReference(value: unknown): value is Reference;
|
|
104
|
-
/** Type-guard: returns `true` if `value` is a {@link Secret}. */
|
|
105
|
-
export declare function isSecret(value: unknown): value is Secret;
|
|
106
|
-
/** Type-guard: returns `true` if `value` is an {@link Interpolation}. */
|
|
107
|
-
export declare function isInterpolation(value: unknown): value is Interpolation;
|
|
108
|
-
/** Configuration for a long-running service. */
|
|
109
|
-
export interface ServiceConfig {
|
|
110
|
-
/**
|
|
111
|
-
* Container image to run.
|
|
112
|
-
*
|
|
113
|
-
* - `string` — a registry image (e.g. `"node:22"`).
|
|
114
|
-
* - `{ context, dockerfile }` — build from a local Dockerfile.
|
|
115
|
-
*/
|
|
116
|
-
image: string | {
|
|
117
|
-
context?: string;
|
|
118
|
-
dockerfile?: string;
|
|
119
|
-
};
|
|
120
|
-
/** Public route to expose (e.g. `"api.example.com"` or `"example.com/api"`). */
|
|
121
|
-
route?: string;
|
|
122
|
-
/** Port the container listens on. Defaults to `3000`. */
|
|
123
|
-
port?: number;
|
|
124
|
-
/** Environment variables injected into the container. */
|
|
125
|
-
env?: Record<string, EnvValue>;
|
|
126
|
-
/** Override the container's default command. */
|
|
127
|
-
command?: string[];
|
|
128
|
-
/** Volumes to mount into the container. */
|
|
129
|
-
volumes?: Array<{
|
|
130
|
-
volume: Volume;
|
|
131
|
-
mount: string;
|
|
132
|
-
}>;
|
|
133
|
-
/** Services that must be healthy before this one starts. */
|
|
134
|
-
dependsOn?: Service[];
|
|
135
|
-
/** Container health check. */
|
|
136
|
-
healthCheck?: HealthCheckConfig;
|
|
137
|
-
/**
|
|
138
|
-
* Restart behaviour on failure.
|
|
139
|
-
* @defaultValue `"any"`
|
|
140
|
-
*/
|
|
141
|
-
restartPolicy?: "none" | "on-failure" | "any";
|
|
142
|
-
}
|
|
143
|
-
/** Configuration for a static site. */
|
|
144
|
-
export interface SiteConfig {
|
|
145
|
-
/** Domain (and optional path) to serve the site on. */
|
|
146
|
-
route: string;
|
|
147
|
-
/**
|
|
148
|
-
* Enable single-page application mode. When `true`, all requests that
|
|
149
|
-
* don't match a static file are rewritten to `/index.html`.
|
|
150
|
-
* @defaultValue `true`
|
|
151
|
-
*/
|
|
152
|
-
spa?: boolean;
|
|
153
|
-
/** Build settings for the static site. */
|
|
154
|
-
build: {
|
|
155
|
-
/** Working directory containing the source (relative to project root). */
|
|
156
|
-
cwd: string;
|
|
157
|
-
/** Directory containing the built output (relative to `cwd`). Defaults to `"dist"`. */
|
|
158
|
-
output?: string;
|
|
159
|
-
/** Build command to run (e.g. `"npm run build"`). */
|
|
160
|
-
command?: string;
|
|
161
|
-
/** Environment variables passed to the build command. */
|
|
162
|
-
env?: Record<string, string>;
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Validates a resource ID.
|
|
167
|
-
* @throws If the ID is empty, too long, or contains invalid characters.
|
|
168
|
-
*/
|
|
169
|
-
export declare function validateId(id: string): void;
|
|
170
|
-
/**
|
|
171
|
-
* Validates a route string.
|
|
172
|
-
* @throws If the route is empty or not a valid domain with optional path.
|
|
173
|
-
*/
|
|
174
|
-
export declare function validateRoute(route: string): void;
|
package/dist/resource.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/** Type-guard: returns `true` if `value` is a {@link Reference}. */
|
|
2
|
-
export function isReference(value) {
|
|
3
|
-
return isSecret(value);
|
|
4
|
-
}
|
|
5
|
-
/** Type-guard: returns `true` if `value` is a {@link Secret}. */
|
|
6
|
-
export function isSecret(value) {
|
|
7
|
-
return (typeof value === "object" &&
|
|
8
|
-
value !== null &&
|
|
9
|
-
value.type === "secret");
|
|
10
|
-
}
|
|
11
|
-
/** Type-guard: returns `true` if `value` is an {@link Interpolation}. */
|
|
12
|
-
export function isInterpolation(value) {
|
|
13
|
-
return (typeof value === "object" &&
|
|
14
|
-
value !== null &&
|
|
15
|
-
value.type === "interpolation");
|
|
16
|
-
}
|
|
17
|
-
const ID_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/;
|
|
18
|
-
const ROUTE_PATTERN = /^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*(\/.+)?$/;
|
|
19
|
-
/**
|
|
20
|
-
* Validates a resource ID.
|
|
21
|
-
* @throws If the ID is empty, too long, or contains invalid characters.
|
|
22
|
-
*/
|
|
23
|
-
export function validateId(id) {
|
|
24
|
-
if (!id || id.length < 1) {
|
|
25
|
-
throw new Error("Resource ID cannot be empty");
|
|
26
|
-
}
|
|
27
|
-
if (id.length > 63) {
|
|
28
|
-
throw new Error("Resource ID cannot exceed 63 characters");
|
|
29
|
-
}
|
|
30
|
-
if (!ID_PATTERN.test(id)) {
|
|
31
|
-
throw new Error(`Invalid resource ID "${id}": must start with a letter, contain only lowercase letters, numbers, and hyphens, and end with a letter or number`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Validates a route string.
|
|
36
|
-
* @throws If the route is empty or not a valid domain with optional path.
|
|
37
|
-
*/
|
|
38
|
-
export function validateRoute(route) {
|
|
39
|
-
if (!route) {
|
|
40
|
-
throw new Error("Route cannot be empty");
|
|
41
|
-
}
|
|
42
|
-
if (!ROUTE_PATTERN.test(route)) {
|
|
43
|
-
throw new Error(`Invalid route "${route}": must be a valid domain with optional path`);
|
|
44
|
-
}
|
|
45
|
-
}
|
package/dist/services/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Secret, SecretConfig, Service, ServiceConfig, Volume, VolumeConfig } from "../resource.js";
|
|
2
|
-
export interface Primitives {
|
|
3
|
-
volume(id: string, config?: VolumeConfig): Volume;
|
|
4
|
-
service(id: string, config: ServiceConfig): Service;
|
|
5
|
-
secret(id: string, config?: SecretConfig): Secret;
|
|
6
|
-
}
|
|
7
|
-
export declare function createServices(p: Primitives): {
|
|
8
|
-
postgres: (id: string, config?: import("./postgres.js").PostgresConfig) => import("./postgres.js").Postgres;
|
|
9
|
-
redis: (id: string, config?: import("./redis.js").RedisConfig) => import("./redis.js").Redis;
|
|
10
|
-
rabbitmq: (id: string, config?: import("./rabbitmq.js").RabbitmqConfig) => import("./rabbitmq.js").Rabbitmq;
|
|
11
|
-
nats: (id: string, config?: import("./nats.js").NatsConfig) => import("./nats.js").Nats;
|
|
12
|
-
mysql: (id: string, config?: import("./mysql.js").MysqlConfig) => import("./mysql.js").Mysql;
|
|
13
|
-
mongo: (id: string, config?: import("./mongo.js").MongoConfig) => import("./mongo.js").Mongo;
|
|
14
|
-
minio: (id: string, config?: import("./minio.js").MinioConfig) => import("./minio.js").Minio;
|
|
15
|
-
storage: (id: string, config?: import("./storage.js").StorageConfig) => import("./storage.js").Storage;
|
|
16
|
-
};
|
|
17
|
-
export type { Bucket, Minio, MinioConfig } from "./minio.js";
|
|
18
|
-
export type { Mongo, MongoConfig } from "./mongo.js";
|
|
19
|
-
export type { Mysql, MysqlConfig } from "./mysql.js";
|
|
20
|
-
export type { Nats, NatsConfig } from "./nats.js";
|
|
21
|
-
export type { Postgres, PostgresConfig } from "./postgres.js";
|
|
22
|
-
export type { Rabbitmq, RabbitmqConfig } from "./rabbitmq.js";
|
|
23
|
-
export type { Redis, RedisConfig } from "./redis.js";
|
|
24
|
-
export type { BackupConfig, Storage, StorageConfig } from "./storage.js";
|
package/dist/services/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createMinio } from "./minio.js";
|
|
2
|
-
import { createMongo } from "./mongo.js";
|
|
3
|
-
import { createMysql } from "./mysql.js";
|
|
4
|
-
import { createNats } from "./nats.js";
|
|
5
|
-
import { createPostgres } from "./postgres.js";
|
|
6
|
-
import { createRabbitmq } from "./rabbitmq.js";
|
|
7
|
-
import { createRedis } from "./redis.js";
|
|
8
|
-
import { createStorage } from "./storage.js";
|
|
9
|
-
export function createServices(p) {
|
|
10
|
-
return {
|
|
11
|
-
postgres: createPostgres(p),
|
|
12
|
-
redis: createRedis(p),
|
|
13
|
-
rabbitmq: createRabbitmq(p),
|
|
14
|
-
nats: createNats(p),
|
|
15
|
-
mysql: createMysql(p),
|
|
16
|
-
mongo: createMongo(p),
|
|
17
|
-
minio: createMinio(p),
|
|
18
|
-
storage: createStorage(p),
|
|
19
|
-
};
|
|
20
|
-
}
|
package/dist/services/minio.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Secret, Service, Volume } from "../resource.js";
|
|
2
|
-
import type { Primitives } from "./index.js";
|
|
3
|
-
/** Configuration for a managed MinIO instance. */
|
|
4
|
-
export interface MinioConfig {
|
|
5
|
-
/** MinIO image tag. @defaultValue `"latest"` */
|
|
6
|
-
version?: string;
|
|
7
|
-
/** Volume size hint (e.g. `"50GB"`). */
|
|
8
|
-
size?: string;
|
|
9
|
-
}
|
|
10
|
-
/** A named S3-compatible bucket on this MinIO instance. */
|
|
11
|
-
export interface Bucket {
|
|
12
|
-
/** Bucket name. */
|
|
13
|
-
name: string;
|
|
14
|
-
/** Init service that creates the bucket on first deploy. */
|
|
15
|
-
service: Service;
|
|
16
|
-
}
|
|
17
|
-
/** A managed MinIO (S3-compatible) instance with its associated resources. */
|
|
18
|
-
export interface Minio {
|
|
19
|
-
/** The underlying service running MinIO. */
|
|
20
|
-
service: Service;
|
|
21
|
-
/** Persistent volume for object storage data. */
|
|
22
|
-
volume: Volume;
|
|
23
|
-
/** Auto-generated root access key. */
|
|
24
|
-
accessKey: Secret;
|
|
25
|
-
/** Auto-generated root secret key. */
|
|
26
|
-
secretKey: Secret;
|
|
27
|
-
/** Internal hostname reachable by other services. */
|
|
28
|
-
host: string;
|
|
29
|
-
/** Port the MinIO API listens on (`9000`). */
|
|
30
|
-
port: number;
|
|
31
|
-
/** Full internal endpoint URL (e.g. `http://<host>:9000`). */
|
|
32
|
-
endpoint: string;
|
|
33
|
-
/** Create a bucket that is provisioned automatically on deploy. */
|
|
34
|
-
bucket: (name: string) => Bucket;
|
|
35
|
-
}
|
|
36
|
-
export declare function createMinio(p: Primitives): (id: string, config?: MinioConfig) => Minio;
|
package/dist/services/minio.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { validateId } from "../resource.js";
|
|
2
|
-
export function createMinio(p) {
|
|
3
|
-
return function minio(id, config = {}) {
|
|
4
|
-
validateId(id);
|
|
5
|
-
const version = config.version ?? "latest";
|
|
6
|
-
const accessKey = p.secret(`${id}-access-key`, { length: 16 });
|
|
7
|
-
const secretKey = p.secret(`${id}-secret-key`, { length: 32 });
|
|
8
|
-
const vol = p.volume(`${id}-data`, { size: config.size });
|
|
9
|
-
const svc = p.service(id, {
|
|
10
|
-
image: `minio/minio:${version}`,
|
|
11
|
-
port: 9000,
|
|
12
|
-
command: ["server", "/data"],
|
|
13
|
-
volumes: [{ volume: vol, mount: "/data" }],
|
|
14
|
-
env: {
|
|
15
|
-
MINIO_ROOT_USER: accessKey,
|
|
16
|
-
MINIO_ROOT_PASSWORD: secretKey,
|
|
17
|
-
},
|
|
18
|
-
healthCheck: {
|
|
19
|
-
command: ["mc", "ready", "local"],
|
|
20
|
-
interval: "5s",
|
|
21
|
-
timeout: "5s",
|
|
22
|
-
retries: 5,
|
|
23
|
-
startPeriod: "5s",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
service: svc,
|
|
28
|
-
volume: vol,
|
|
29
|
-
accessKey,
|
|
30
|
-
secretKey,
|
|
31
|
-
host: svc.host,
|
|
32
|
-
port: 9000,
|
|
33
|
-
endpoint: `http://${svc.host}:9000`,
|
|
34
|
-
bucket(name) {
|
|
35
|
-
const initSvc = p.service(`${id}-bucket-${name}`, {
|
|
36
|
-
image: "minio/mc:latest",
|
|
37
|
-
command: [
|
|
38
|
-
"sh",
|
|
39
|
-
"-c",
|
|
40
|
-
`mc alias set minio http://${svc.host}:9000 $(cat $ACCESS_KEY_FILE) $(cat $SECRET_KEY_FILE) && mc mb --ignore-existing minio/${name}`,
|
|
41
|
-
],
|
|
42
|
-
env: {
|
|
43
|
-
ACCESS_KEY: accessKey,
|
|
44
|
-
SECRET_KEY: secretKey,
|
|
45
|
-
},
|
|
46
|
-
dependsOn: [svc],
|
|
47
|
-
restartPolicy: "none",
|
|
48
|
-
});
|
|
49
|
-
return { name, service: initSvc };
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
}
|
package/dist/services/mongo.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Interpolation, Secret, Service, Volume } from "../resource.js";
|
|
2
|
-
import type { Primitives } from "./index.js";
|
|
3
|
-
import { type BackupConfig } from "./storage.js";
|
|
4
|
-
/** Configuration for a managed MongoDB instance. */
|
|
5
|
-
export interface MongoConfig {
|
|
6
|
-
/** Major MongoDB version. @defaultValue `8` */
|
|
7
|
-
version?: number;
|
|
8
|
-
/** Volume size hint (e.g. `"10GB"`). */
|
|
9
|
-
size?: string;
|
|
10
|
-
/** Backup configuration. */
|
|
11
|
-
backup?: BackupConfig;
|
|
12
|
-
}
|
|
13
|
-
/** A managed MongoDB instance with its associated resources. */
|
|
14
|
-
export interface Mongo {
|
|
15
|
-
/** The underlying service running MongoDB. */
|
|
16
|
-
service: Service;
|
|
17
|
-
/** Persistent volume for MongoDB data. */
|
|
18
|
-
volume: Volume;
|
|
19
|
-
/** Auto-generated root password secret. */
|
|
20
|
-
password: Secret;
|
|
21
|
-
/** Internal hostname reachable by other services. */
|
|
22
|
-
host: string;
|
|
23
|
-
/** Port MongoDB listens on (`27017`). */
|
|
24
|
-
port: number;
|
|
25
|
-
/** Connection string with credentials injected at deploy time. */
|
|
26
|
-
url: Interpolation;
|
|
27
|
-
}
|
|
28
|
-
export declare function createMongo(p: Primitives): (id: string, config?: MongoConfig) => Mongo;
|
package/dist/services/mongo.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { interpolate } from "../interpolate.js";
|
|
2
|
-
import { validateId } from "../resource.js";
|
|
3
|
-
import { createBackupSidecar } from "./storage.js";
|
|
4
|
-
export function createMongo(p) {
|
|
5
|
-
return function mongo(id, config = {}) {
|
|
6
|
-
validateId(id);
|
|
7
|
-
const version = config.version ?? 8;
|
|
8
|
-
const password = p.secret(`${id}-password`, { length: 32 });
|
|
9
|
-
const vol = p.volume(`${id}-data`, { size: config.size });
|
|
10
|
-
const svc = p.service(id, {
|
|
11
|
-
image: `mongo:${version}`,
|
|
12
|
-
port: 27017,
|
|
13
|
-
volumes: [{ volume: vol, mount: "/data/db" }],
|
|
14
|
-
env: {
|
|
15
|
-
MONGO_INITDB_ROOT_USERNAME: "mongo",
|
|
16
|
-
MONGO_INITDB_ROOT_PASSWORD: password,
|
|
17
|
-
},
|
|
18
|
-
healthCheck: {
|
|
19
|
-
command: ["mongosh", "--eval", "db.runCommand('ping').ok", "--quiet"],
|
|
20
|
-
interval: "5s",
|
|
21
|
-
timeout: "5s",
|
|
22
|
-
retries: 5,
|
|
23
|
-
startPeriod: "10s",
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
if (config.backup) {
|
|
27
|
-
createBackupSidecar(p, {
|
|
28
|
-
id,
|
|
29
|
-
image: `mongo:${version}`,
|
|
30
|
-
svc,
|
|
31
|
-
backup: config.backup,
|
|
32
|
-
dumpScript: `TIMESTAMP=$(date +%Y%m%d-%H%M%S) && mongodump --uri="mongodb://mongo:$(cat $DB_PASSWORD_FILE)@${svc.host}:27017" --archive --gzip | mc pipe backup/${config.backup.storage.bucket}/${id}-$TIMESTAMP.gz`,
|
|
33
|
-
env: { DB_PASSWORD: password },
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
service: svc,
|
|
38
|
-
volume: vol,
|
|
39
|
-
password,
|
|
40
|
-
host: svc.host,
|
|
41
|
-
port: 27017,
|
|
42
|
-
url: interpolate `mongodb://mongo:${password}@${svc.host}:27017`,
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
}
|