@feltdb/feltkit 0.3.2 → 0.3.3
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/README.md +7 -0
- package/dist/cli/deploy.d.ts +11 -1
- package/dist/cli/deploy.js +279 -63
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +68 -17
- package/dist/cli/main.js.map +1 -1
- package/dist/dashboard/apple-touch-icon.png +0 -0
- package/dist/dashboard/assets/feltkit-mark-BygpVIiS.png +0 -0
- package/dist/dashboard/assets/index-B-ra0AY9.css +1 -0
- package/dist/dashboard/assets/index-DnJaSnzt.js +15 -0
- package/dist/dashboard/favicon.png +0 -0
- package/dist/dashboard/index.html +5 -3
- package/dist/dashboard/theme.js +6 -0
- package/dist/runtime/connect.d.ts +65 -0
- package/dist/runtime/connect.js +246 -0
- package/dist/runtime/connect.js.map +1 -0
- package/dist/runtime/contract.d.ts +15 -5
- package/dist/runtime/contract.js +36 -12
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/decisions.d.ts +32 -4
- package/dist/runtime/decisions.js +69 -0
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/environment.js +41 -0
- package/dist/runtime/environment.js.map +1 -1
- package/dist/runtime/readiness.js +5 -3
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +11 -0
- package/dist/runtime/runtime.js +32 -14
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +11 -2
- package/dist/runtime/services.js +5 -0
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/storage-check.d.ts +12 -0
- package/dist/runtime/storage-check.js +99 -0
- package/dist/runtime/storage-check.js.map +1 -0
- package/dist/runtime/targets.d.ts +57 -0
- package/dist/runtime/targets.js +106 -0
- package/dist/runtime/targets.js.map +1 -0
- package/dist/server/admin.js +153 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/brand.d.ts +5 -0
- package/dist/server/brand.js +6 -0
- package/dist/server/brand.js.map +1 -0
- package/dist/server/index.js +50 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/project.d.ts +8 -0
- package/dist/server/project.js +27 -3
- package/dist/server/project.js.map +1 -1
- package/package.json +5 -5
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-operations/SKILL.md +3 -1
- package/skills/feltkit-services/SKILL.md +3 -3
- package/dist/dashboard/assets/index-Bo2oHR18.css +0 -1
- package/dist/dashboard/assets/index-DK_Jda9P.js +0 -15
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rkendel1/feltkit/main/docs/assets/feltkit-logo-dark.png">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/rkendel1/feltkit/main/docs/assets/feltkit-logo.png" alt="FeltKit" width="160">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
1
8
|
# @feltdb/feltkit
|
|
2
9
|
|
|
3
10
|
The FeltKit SDK, runtime, server, CLI, React bindings, and dashboard.
|
package/dist/cli/deploy.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import { DEPLOY_TARGETS, type DeployTarget } from "../runtime/targets.js";
|
|
2
|
+
export { DEPLOY_TARGETS, type DeployTarget };
|
|
3
|
+
export declare const DEPLOY_DIR: string;
|
|
1
4
|
export declare function deploy(options: {
|
|
2
5
|
projectDir: string;
|
|
3
6
|
out?: string;
|
|
7
|
+
target?: DeployTarget;
|
|
4
8
|
}): Promise<{
|
|
5
9
|
dir: string;
|
|
6
10
|
application: string;
|
|
7
11
|
build: import("../server/project.js").BuildResult;
|
|
8
|
-
|
|
12
|
+
apiKeys: boolean;
|
|
13
|
+
target: DeployTarget;
|
|
14
|
+
services: string[];
|
|
15
|
+
credentialRefs: string[];
|
|
16
|
+
contract: boolean;
|
|
9
17
|
}>;
|
|
18
|
+
/** Sentence case to mid-sentence: only the first letter. */
|
|
19
|
+
export declare const lower: (text: string) => string;
|
package/dist/cli/deploy.js
CHANGED
|
@@ -1,36 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `feltkit deploy`: a verified, self-contained deployment artifact.
|
|
2
|
+
* `feltkit deploy`: a verified, self-contained deployment artifact, for the way you run it.
|
|
3
3
|
*
|
|
4
|
-
* FeltKit does not operate a hosting service. Deploy builds the application, proves
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* FeltKit does not operate a hosting service. Deploy builds the application, proves the
|
|
5
|
+
* production build boots and answers (against a throwaway state directory, so no real state
|
|
6
|
+
* is touched), and writes a directory for one target (runtime/targets.ts):
|
|
7
|
+
*
|
|
8
|
+
* container everything in one container: the app and its FeltDB state on a volume
|
|
9
|
+
* hosted a separate app container; its data in Managed FeltDB, with the app's
|
|
10
|
+
* complete contract (feltdb.contract.json) to create the application from
|
|
11
|
+
* self-hosted a separate app container; its data on a FeltDB server you operate
|
|
12
|
+
*
|
|
13
|
+
* Each artifact also runs with plain Node, and carries a Dockerfile, docker-compose.yml,
|
|
14
|
+
* fly.toml, .env.example with exactly the variables its target needs, and DEPLOY.md with the
|
|
15
|
+
* target's whole contract. The target is recorded in .feltkit/target.json and the image, and
|
|
16
|
+
* startup enforces it: the artifact never stores state anywhere but its target's place.
|
|
8
17
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
11
19
|
import { tmpdir } from "node:os";
|
|
12
20
|
import { join, resolve } from "node:path";
|
|
13
21
|
import { FeltKitError } from "../errors.js";
|
|
14
22
|
import { silentLogger } from "../runtime/runtime.js";
|
|
15
|
-
import { BUILD_DIR, SDK_VERSION, build, readPackageJson, startProduction } from "../server/project.js";
|
|
23
|
+
import { BUILD_DIR, DEPLOY_TARGET_FILE, SDK_VERSION, build, readPackageJson, startProduction } from "../server/project.js";
|
|
24
|
+
import { DEPLOY_TARGETS, TARGETS, isDeployTarget } from "../runtime/targets.js";
|
|
25
|
+
export { DEPLOY_TARGETS };
|
|
26
|
+
export const DEPLOY_DIR = join(".feltkit", "deploy");
|
|
27
|
+
/**
|
|
28
|
+
* Move a new artifact into place. A previous run of the artifact may keep production state
|
|
29
|
+
* and keys in its .feltkit/production: that is kept. Everything else, node_modules included
|
|
30
|
+
* (its dependencies may have changed), is replaced.
|
|
31
|
+
*/
|
|
32
|
+
function replaceArtifact(next, target) {
|
|
33
|
+
const kept = join(target, ".feltkit", "production");
|
|
34
|
+
if (existsSync(kept)) {
|
|
35
|
+
mkdirSync(join(next, ".feltkit"), { recursive: true });
|
|
36
|
+
renameSync(kept, join(next, ".feltkit", "production"));
|
|
37
|
+
}
|
|
38
|
+
rmSync(target, { recursive: true, force: true });
|
|
39
|
+
renameSync(next, target);
|
|
40
|
+
}
|
|
16
41
|
export async function deploy(options) {
|
|
42
|
+
const target_ = options.target ?? "container";
|
|
43
|
+
if (!isDeployTarget(target_))
|
|
44
|
+
throw new FeltKitError("INVALID_ARGUMENT", `Unknown deploy target "${target_}". Choose ${Object.keys(DEPLOY_TARGETS).join(", ")}.`);
|
|
17
45
|
const projectDir = resolve(options.projectDir);
|
|
18
46
|
const pkg = readPackageJson(projectDir);
|
|
19
47
|
const result = await build(projectDir);
|
|
20
48
|
// Verify the production build boots. Isolated state, random port, then stop.
|
|
21
49
|
const scratch = mkdtempSync(join(tmpdir(), "feltkit-deploy-check-"));
|
|
22
|
-
const previous = { state: process.env.FELTKIT_STATE_DIR, url: process.env.FELTDB_URL,
|
|
50
|
+
const previous = { state: process.env.FELTKIT_STATE_DIR, url: process.env.FELTDB_URL, storage: process.env.FELTKIT_STORAGE };
|
|
23
51
|
process.env.FELTKIT_STATE_DIR = join(scratch, "state");
|
|
24
52
|
delete process.env.FELTDB_URL;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const requiredSecrets = [];
|
|
53
|
+
delete process.env.FELTKIT_STORAGE;
|
|
54
|
+
let apiKeys = false;
|
|
55
|
+
let services = [];
|
|
56
|
+
let credentialRefs = [];
|
|
30
57
|
try {
|
|
31
58
|
const server = await startProduction({ projectDir, port: 0, host: "127.0.0.1", environment: "production", logger: silentLogger });
|
|
32
|
-
|
|
33
|
-
|
|
59
|
+
apiKeys = Boolean(server.runtime.app.options.services?.apiKeys);
|
|
60
|
+
services = Object.entries(server.runtime.app.options.services ?? {}).filter(([, on]) => on).map(([name]) => name);
|
|
61
|
+
// Credentials the code declares (integrations): production reads each from FELTKIT_CREDENTIAL_<ID>.
|
|
62
|
+
credentialRefs = [...new Set(server.runtime.integrations.definitions().map((i) => (typeof i.credential === "string" ? i.credential : i.credential?.ref)).filter((r) => Boolean(r)))];
|
|
34
63
|
try {
|
|
35
64
|
const health = await fetch(`${server.server.url}/_feltkit/health`);
|
|
36
65
|
if (!health.ok)
|
|
@@ -55,14 +84,16 @@ export async function deploy(options) {
|
|
|
55
84
|
process.env.FELTKIT_STATE_DIR = previous.state;
|
|
56
85
|
if (previous.url !== undefined)
|
|
57
86
|
process.env.FELTDB_URL = previous.url;
|
|
58
|
-
if (previous.
|
|
59
|
-
|
|
87
|
+
if (previous.storage !== undefined)
|
|
88
|
+
process.env.FELTKIT_STORAGE = previous.storage;
|
|
60
89
|
rmSync(scratch, { recursive: true, force: true });
|
|
61
90
|
}
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
if (existsSync(
|
|
65
|
-
throw new FeltKitError("CONFIGURATION", `${
|
|
91
|
+
// The default artifact is .feltkit/deploy, replaced on every deploy; --out never overwrites.
|
|
92
|
+
const target = resolve(options.out ?? join(projectDir, DEPLOY_DIR));
|
|
93
|
+
if (options.out && existsSync(target))
|
|
94
|
+
throw new FeltKitError("CONFIGURATION", `${target} already exists; choose another --out.`);
|
|
95
|
+
const dir = options.out ? target : `${target}.next`;
|
|
96
|
+
rmSync(dir, { recursive: true, force: true });
|
|
66
97
|
mkdirSync(dir, { recursive: true });
|
|
67
98
|
cpSync(join(projectDir, BUILD_DIR), join(dir, BUILD_DIR), { recursive: true });
|
|
68
99
|
if (result.client)
|
|
@@ -80,75 +111,260 @@ export async function deploy(options) {
|
|
|
80
111
|
}, null, 2)}\n`);
|
|
81
112
|
if (existsSync(join(projectDir, "package-lock.json")))
|
|
82
113
|
cpSync(join(projectDir, "package-lock.json"), join(dir, "package-lock.json"));
|
|
83
|
-
|
|
114
|
+
const files = artifactFiles({ target: target_, application: result.application, client: Boolean(result.client), apiKeys, services, credentialRefs, contract: null });
|
|
115
|
+
if (TARGETS[target_].storage === "managed") {
|
|
116
|
+
// Managed FeltDB stores only what the promoted contract declares: the app's whole contract,
|
|
117
|
+
// AppPort Services' collections included (runtime/contract.ts).
|
|
118
|
+
const { feltdbContract, formatContract } = await import("../runtime/contract.js");
|
|
119
|
+
const { loadBundle } = await import("../runtime/loader.js");
|
|
120
|
+
files["feltdb.contract.json"] = formatContract(feltdbContract((await loadBundle(join(projectDir, BUILD_DIR, "functions.mjs"))).app));
|
|
121
|
+
}
|
|
122
|
+
for (const [name, text] of Object.entries(files))
|
|
123
|
+
writeFileSync(join(dir, name), text);
|
|
124
|
+
writeFileSync(join(dir, DEPLOY_TARGET_FILE), `${JSON.stringify({ target: target_, application: result.application, feltkit: SDK_VERSION }, null, 2)}\n`);
|
|
125
|
+
if (!options.out)
|
|
126
|
+
replaceArtifact(dir, target);
|
|
127
|
+
return { dir: target, application: result.application, build: result, apiKeys, target: target_, services, credentialRefs, contract: Boolean(files["feltdb.contract.json"]) };
|
|
128
|
+
}
|
|
129
|
+
/** Sentence case to mid-sentence: only the first letter. */
|
|
130
|
+
export const lower = (text) => text.charAt(0).toLowerCase() + text.slice(1);
|
|
131
|
+
const variable = (ref) => `FELTKIT_CREDENTIAL_${ref.replace(/^credential-ref:/, "").replace(/[^A-Za-z0-9]/g, "_").toUpperCase()}`;
|
|
132
|
+
const flyName = (name) => name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
|
|
133
|
+
/** The files of an artifact for `target`, by name. */
|
|
134
|
+
function artifactFiles(o) {
|
|
135
|
+
const app = o.application;
|
|
136
|
+
const t = TARGETS[o.target];
|
|
137
|
+
const separate = t.storage !== "local";
|
|
138
|
+
const fly_ = flyName(app);
|
|
139
|
+
const volume = fly_.replace(/-/g, "_") + "_data";
|
|
140
|
+
const needed = t.variables.filter((v) => v.required === true || (v.required === "apiKeys" && o.apiKeys));
|
|
141
|
+
const health = `HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=3 \\
|
|
142
|
+
CMD ["node", "-e", "fetch('http://127.0.0.1:'+process.env.PORT+'/_feltkit/health').then(r=>process.exit(r.ok?0:1),()=>process.exit(1))"]`;
|
|
143
|
+
const dockerfile = separate
|
|
144
|
+
? `# ${app}: a stateless app container. Its data is in ${t.state}, reached with
|
|
145
|
+
# ${needed.map((v) => v.name).join(", ")} from the platform's configuration and secret store at run
|
|
146
|
+
# time. The image holds no state and no credentials.
|
|
147
|
+
FROM node:22-slim
|
|
84
148
|
WORKDIR /app
|
|
85
149
|
COPY package*.json ./
|
|
86
150
|
RUN npm install --omit=dev --no-audit --no-fund
|
|
87
151
|
COPY . .
|
|
88
|
-
|
|
152
|
+
# FELTKIT_STORAGE=${t.storage}: refuse to start without this target's FeltDB settings, rather than
|
|
153
|
+
# keep state on the container's own disk.
|
|
154
|
+
ENV NODE_ENV=production PORT=3000 FELTKIT_STORAGE=${t.storage}
|
|
155
|
+
RUN mkdir -p .feltkit/production && chown node:node .feltkit/production
|
|
156
|
+
EXPOSE 3000
|
|
157
|
+
USER node
|
|
158
|
+
${health}
|
|
159
|
+
# node directly (not npx), so SIGTERM reaches FeltKit and it shuts down cleanly.
|
|
160
|
+
CMD ["node", "node_modules/@feltdb/feltkit/bin/feltkit.js", "start", "--host", "0.0.0.0"]
|
|
161
|
+
`
|
|
162
|
+
: `# ${app}: everything in one container. FeltDB state, and the keys kept beside it, live on
|
|
163
|
+
# the /data volume: keep the volume, back it up, and run one container per volume.
|
|
164
|
+
FROM node:22-slim
|
|
165
|
+
WORKDIR /app
|
|
166
|
+
COPY package*.json ./
|
|
167
|
+
RUN npm install --omit=dev --no-audit --no-fund
|
|
168
|
+
COPY . .
|
|
169
|
+
# FELTKIT_STORAGE=local: state only on the volume; FELTDB_URL is refused, never followed.
|
|
170
|
+
ENV NODE_ENV=production PORT=3000 FELTKIT_STATE_DIR=/data/state FELTKIT_STORAGE=local
|
|
89
171
|
# The app runs as the node user: it writes state to /data (a new volume takes the image's
|
|
90
172
|
# ownership) and its runtime files (process record, keys) to .feltkit/production.
|
|
91
173
|
RUN mkdir -p /data .feltkit/production && chown node:node /data .feltkit/production
|
|
92
174
|
VOLUME ["/data"]
|
|
93
175
|
EXPOSE 3000
|
|
94
176
|
USER node
|
|
177
|
+
${health}
|
|
95
178
|
# node directly (not npx), so SIGTERM reaches FeltKit and it shuts down cleanly.
|
|
96
179
|
CMD ["node", "node_modules/@feltdb/feltkit/bin/feltkit.js", "start", "--host", "0.0.0.0"]
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
180
|
+
`;
|
|
181
|
+
const credentialLines = o.credentialRefs.map((ref) => `# ${ref}\n${variable(ref)}=`).join("\n");
|
|
182
|
+
const describe = (v) => `# ${v.name}: ${v.purpose}${v.secret ? " (secret)" : ""}`;
|
|
183
|
+
const env = separate
|
|
184
|
+
? `# Copy to .env (never commit it) or set these in your platform's configuration and secrets.
|
|
185
|
+
# ${app}'s data is in ${t.state}. Startup stops, naming the variable, if one is missing.
|
|
186
|
+
${needed.map((v) => `${describe(v)}\n${v.name}=`).join("\n")}
|
|
187
|
+
${credentialLines ? `# Credentials your integrations use:\n${credentialLines}\n` : ""}`
|
|
188
|
+
: `# Optional. Copy to .env (never commit it) for docker compose, or set them on your host.
|
|
189
|
+
# Data and keys live on the volume: nothing is required. FELTDB_* is refused here.
|
|
190
|
+
${t.variables.map((v) => `${describe(v)}\n# ${v.name}=`).join("\n")}
|
|
191
|
+
${credentialLines ? `# Credentials your integrations use:\n${credentialLines}\n` : ""}# FELTKIT_DASHBOARD=1 # serve Studio for operators (npx feltkit operator grant)
|
|
192
|
+
`;
|
|
193
|
+
const compose = separate
|
|
194
|
+
? `# docker compose up --build (reads FeltDB's settings from .env; see .env.example)
|
|
195
|
+
name: ${fly_}
|
|
196
|
+
services:
|
|
197
|
+
${fly_}:
|
|
198
|
+
build: .
|
|
199
|
+
image: ${fly_}
|
|
200
|
+
ports:
|
|
201
|
+
- "3000:3000"
|
|
202
|
+
env_file: .env
|
|
203
|
+
restart: unless-stopped
|
|
204
|
+
`
|
|
205
|
+
: `# docker compose up --build (data on the ${fly_}-data volume)
|
|
206
|
+
# The image and volume are named, so plain docker commands (DEPLOY.md) use the same ones.
|
|
207
|
+
name: ${fly_}
|
|
208
|
+
services:
|
|
209
|
+
${fly_}:
|
|
210
|
+
build: .
|
|
211
|
+
image: ${fly_}
|
|
212
|
+
ports:
|
|
213
|
+
- "3000:3000"
|
|
214
|
+
volumes:
|
|
215
|
+
- ${fly_}-data:/data
|
|
216
|
+
env_file:
|
|
217
|
+
- path: .env
|
|
218
|
+
required: false
|
|
219
|
+
restart: unless-stopped
|
|
220
|
+
volumes:
|
|
221
|
+
${fly_}-data:
|
|
222
|
+
name: ${fly_}-data
|
|
223
|
+
`;
|
|
224
|
+
const fly = `# fly launch --copy-config --no-deploy then fly deploy
|
|
225
|
+
app = "${fly_}"
|
|
100
226
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
answered /_feltkit/health${result.client ? " and served the frontend" : ""}.
|
|
227
|
+
[build]
|
|
228
|
+
dockerfile = "Dockerfile"
|
|
104
229
|
|
|
105
|
-
|
|
230
|
+
[env]
|
|
231
|
+
PORT = "3000"
|
|
232
|
+
${separate ? "" : `
|
|
233
|
+
# FeltDB state lives on this volume (fly volumes create ${volume} --size 1). One machine: the state is single-host.
|
|
234
|
+
[mounts]
|
|
235
|
+
source = "${volume}"
|
|
236
|
+
destination = "/data"
|
|
237
|
+
`}
|
|
238
|
+
[http_service]
|
|
239
|
+
internal_port = 3000
|
|
240
|
+
force_https = true
|
|
241
|
+
auto_stop_machines = "stop"
|
|
242
|
+
auto_start_machines = true
|
|
243
|
+
min_machines_running = ${separate ? 0 : 1}
|
|
106
244
|
|
|
107
|
-
|
|
108
|
-
|
|
245
|
+
[[http_service.checks]]
|
|
246
|
+
grace_period = "30s"
|
|
247
|
+
interval = "15s"
|
|
248
|
+
method = "GET"
|
|
249
|
+
path = "/_feltkit/health"
|
|
250
|
+
timeout = "5s"
|
|
251
|
+
`;
|
|
252
|
+
const others = Object.keys(TARGETS).filter((id) => id !== o.target);
|
|
253
|
+
const setVars = needed.map((v) => `${v.name}=…`).join(" ");
|
|
254
|
+
const provision = {
|
|
255
|
+
container: "Nothing to provision: the state is created on the volume on first start.\n",
|
|
256
|
+
hosted: `Create the application and its runtime key from this artifact's contract (it declares every
|
|
257
|
+
collection the app stores, AppPort Services' included), with the FeltDB CLI:
|
|
109
258
|
|
|
110
|
-
|
|
259
|
+
npx feltdb init-managed --contract feltdb.contract.json --runtime-scopes minimal
|
|
111
260
|
|
|
112
|
-
|
|
113
|
-
|
|
261
|
+
then set FELTDB_URL, FELTDB_APPLICATION_ID and FELTDB_TOKEN (the runtime key; never the control
|
|
262
|
+
key) as it prints them. When the app's collections change, deploy again and publish the new
|
|
263
|
+
contract before starting the new image:
|
|
114
264
|
|
|
115
|
-
|
|
265
|
+
npx feltdb publish --contract feltdb.contract.json
|
|
266
|
+
`,
|
|
267
|
+
"self-hosted": `On the machine that runs your FeltDB server, create a key for this app's namespace
|
|
268
|
+
(\`${app}\`) that may read and write state, and give it to the app as FELTDB_TOKEN:
|
|
116
269
|
|
|
117
|
-
|
|
270
|
+
feltdb-server keys create --keys <keys.json> --name ${app} --namespace ${app} --scope state:read,state:write
|
|
271
|
+
|
|
272
|
+
Set FELTDB_URL to the server's origin. A key for another namespace is refused, so several apps
|
|
273
|
+
can share one server.
|
|
274
|
+
`,
|
|
275
|
+
};
|
|
276
|
+
const contract = (c) => `| | |
|
|
118
277
|
|---|---|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
278
|
+
| App runtime | ${c.runtime} |
|
|
279
|
+
| Durable state | ${c.state} |
|
|
280
|
+
| Configuration and secrets | ${c.variables.filter((v) => v.required === true || (v.required === "apiKeys" && o.apiKeys)).map((v) => `\`${v.name}\`${v.secret ? " (secret)" : ""}`).join(", ") || "none required"} |
|
|
281
|
+
| Persistence | ${c.persistence} |
|
|
282
|
+
| Recovery | ${c.recovery} |
|
|
283
|
+
| Identity and authorization | ${c.identity} |
|
|
284
|
+
| Contract provisioning and validation | ${c.provisioning} |
|
|
285
|
+
| Health and diagnostics | ${c.health} |
|
|
286
|
+
| Upgrade | ${c.upgrade} |
|
|
287
|
+
| Rollback | ${c.rollback} |
|
|
122
288
|
|
|
123
|
-
|
|
289
|
+
Startup stops, with what to fix, when:
|
|
124
290
|
|
|
125
|
-
|
|
291
|
+
${c.startupFailures.map((f) => `- ${f}`).join("\n")}
|
|
292
|
+
`;
|
|
293
|
+
const signIn = `## Sign in
|
|
126
294
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
\`FELTKIT_CREDENTIAL_VAULT_KEY\` (32 random bytes, base64) and store each one on the host
|
|
132
|
-
with \`npx feltkit credential set <ref> --env production\`.
|
|
295
|
+
Production has no development sign-in. Add \`auth.authenticate\` to \`feltkit({ ... })\` to
|
|
296
|
+
verify requests with your identity provider, or issue a session token to a known principal
|
|
297
|
+
and paste it into the app's sign-in screen.${separate ? ` Run it where the app's variables are set
|
|
298
|
+
(sessions are stored in FeltDB, so every container accepts them):
|
|
133
299
|
|
|
134
|
-
|
|
300
|
+
${setVars} npx feltkit session create --env production --type user --id you --role <role>
|
|
301
|
+
` : ` Only one process may open the state, so do this with the
|
|
302
|
+
app stopped (in Docker: a one-off container on the same volume):
|
|
135
303
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
304
|
+
npx feltkit session create --env production --type user --id you --role <role>
|
|
305
|
+
docker run --rm -v ${fly_}-data:/data ${fly_} node node_modules/@feltdb/feltkit/bin/feltkit.js session create --env production --type user --id you --role <role>
|
|
306
|
+
`}
|
|
307
|
+
Studio is not served in production unless \`FELTKIT_DASHBOARD=1\`; operators then sign in
|
|
308
|
+
with a one-time grant (\`npx feltkit operator grant --id <you> --role <role>\`).
|
|
309
|
+
`;
|
|
310
|
+
const deployMd = `# Deploying ${app}: ${lower(t.title)}
|
|
311
|
+
|
|
312
|
+
Built with feltkit ${SDK_VERSION} on ${new Date().toISOString()}.
|
|
313
|
+
Verified: the production build booted against a temporary state directory and answered
|
|
314
|
+
/_feltkit/health${o.client ? " and served the frontend" : ""}. To build for another target:
|
|
315
|
+
${others.map((id) => `\`npx feltkit deploy --target ${id}\``).join(" or ")}.
|
|
316
|
+
|
|
317
|
+
## The deployment contract (${o.target})
|
|
318
|
+
|
|
319
|
+
${contract(t)}
|
|
320
|
+
This target never changes where state is stored: the image sets \`FELTKIT_STORAGE=${t.storage}\`
|
|
321
|
+
(and \`.feltkit/target.json\` does the same when it runs with Node).
|
|
322
|
+
|
|
323
|
+
## Provision the data
|
|
324
|
+
|
|
325
|
+
${provision[o.target]}
|
|
326
|
+
## Run it
|
|
140
327
|
|
|
141
|
-
|
|
328
|
+
With Docker Compose:
|
|
142
329
|
|
|
143
|
-
|
|
144
|
-
\`feltkit({ ... })\` to verify requests with your identity provider, or issue
|
|
145
|
-
session tokens to known principals:
|
|
330
|
+
${separate ? "cp .env.example .env # then fill it in\n " : ""}docker compose up --build
|
|
146
331
|
|
|
147
|
-
|
|
332
|
+
With Docker:
|
|
333
|
+
|
|
334
|
+
docker build -t ${fly_} .
|
|
335
|
+
docker run -p 3000:3000 ${separate ? "--env-file .env" : `-v ${fly_}-data:/data`} ${fly_}
|
|
336
|
+
|
|
337
|
+
With Node 20+:
|
|
338
|
+
|
|
339
|
+
npm ci --omit=dev
|
|
340
|
+
${separate ? `${setVars} ` : ""}npm start
|
|
341
|
+
|
|
342
|
+
On Fly.io (\`fly.toml\`):
|
|
343
|
+
|
|
344
|
+
fly launch --copy-config --no-deploy
|
|
345
|
+
${separate ? `fly secrets set ${setVars}` : `fly volumes create ${volume} --size 1`}
|
|
346
|
+
fly deploy
|
|
347
|
+
|
|
348
|
+
Any other container host works the same way: build the image, ${separate ? "set the variables in `.env.example`" : "mount a volume at /data"}, expose port 3000,
|
|
349
|
+
and check \`/_feltkit/health\`.
|
|
350
|
+
|
|
351
|
+
## Credentials (API keys for models and integrations)
|
|
148
352
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
353
|
+
Keys entered in Studio during development are not part of this artifact. In production each
|
|
354
|
+
\`credential-ref:<id>\` resolves from \`FELTKIT_CREDENTIAL_<ID>\`${o.credentialRefs.length ? ` (this app's integrations: ${o.credentialRefs.map(variable).join(", ")})` : ""}.
|
|
355
|
+
To keep them in an encrypted vault instead, set \`FELTKIT_CREDENTIAL_VAULT=1\` and
|
|
356
|
+
\`FELTKIT_CREDENTIAL_VAULT_KEY\` and store each with \`npx feltkit credential set <ref> --env production\`.
|
|
357
|
+
${o.apiKeys ? `
|
|
358
|
+
API keys (\`services.apiKeys\`): ${separate ? "set FELTKIT_API_KEY_VERIFIER_KEY, the same for every process" : "the verifier key is generated once beside the state; FELTKIT_API_KEY_VERIFIER_KEY overrides it"}. Changing or losing it invalidates every issued API key.
|
|
359
|
+
` : ""}
|
|
360
|
+
${signIn}`;
|
|
361
|
+
return {
|
|
362
|
+
Dockerfile: dockerfile,
|
|
363
|
+
".dockerignore": "node_modules\n.feltkit/production\n.env\n",
|
|
364
|
+
"docker-compose.yml": compose,
|
|
365
|
+
"fly.toml": fly,
|
|
366
|
+
".env.example": env,
|
|
367
|
+
"DEPLOY.md": deployMd,
|
|
368
|
+
};
|
|
153
369
|
}
|
|
154
370
|
//# sourceMappingURL=deploy.js.map
|
package/dist/cli/deploy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvG,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAA6C;IACxE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IAEvC,6EAA6E;IAC7E,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,GAAG,EAAE,OAAO,CAAC,G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
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
6
|
-
import { join, resolve } from "node:path";
|
|
6
|
+
import { join, relative, resolve } from "node:path";
|
|
7
7
|
import { FeltKitError, isFeltKitError } from "../errors.js";
|
|
8
8
|
import { resolveEnvironment } from "../runtime/environment.js";
|
|
9
9
|
import { loadSources } from "../runtime/loader.js";
|
|
@@ -15,9 +15,10 @@ import { EnvironmentCredentials, looksLikeSecret, toCredentialRef } from "../run
|
|
|
15
15
|
import { HOST_CUSTODY, credentialInventory, removeCredential, selectModel, storeCredential } from "../server/admin.js";
|
|
16
16
|
import { FeltKitRuntime, silentLogger } from "../runtime/runtime.js";
|
|
17
17
|
import { overviewPayload } from "../server/admin.js";
|
|
18
|
-
import { SDK_VERSION, build, codegen, doctor, startDev, startProduction } from "../server/project.js";
|
|
18
|
+
import { SDK_VERSION, artifactEnv, build, codegen, doctor, startDev, startProduction } from "../server/project.js";
|
|
19
19
|
import { scaffold, ScaffoldError } from "create-feltkit";
|
|
20
|
-
import { deploy } from "./deploy.js";
|
|
20
|
+
import { DEPLOY_TARGETS, deploy, lower } from "./deploy.js";
|
|
21
|
+
import { createInterface } from "node:readline/promises";
|
|
21
22
|
import { feltdbContract, formatContract } from "../runtime/contract.js";
|
|
22
23
|
import { checkSkills, installSkills, shippedSkills, skillsTarget } from "./skills.js";
|
|
23
24
|
import { c, line, printInspect, symbols } from "./output.js";
|
|
@@ -60,7 +61,7 @@ ${c.bold("Commands")}
|
|
|
60
61
|
start Run the production build (environment: production)
|
|
61
62
|
test Run the project's tests against an isolated test environment
|
|
62
63
|
inspect Show what the application is, where its state lives, and what it's doing
|
|
63
|
-
deploy Build a verified,
|
|
64
|
+
deploy Build a verified deployment: one container, or an app container + hosted FeltDB
|
|
64
65
|
session <action> Create, list, or revoke sessions (agents, service accounts)
|
|
65
66
|
operator grant Sign a one-time production Studio sign-in for an operator
|
|
66
67
|
readiness Check what this environment has and lacks before production
|
|
@@ -90,7 +91,12 @@ const COMMAND_HELP = {
|
|
|
90
91
|
" Writes the FeltDB application contract: this application's collections, FeltKit's own records, and FeltDB's\n" +
|
|
91
92
|
" agent state. Managed FeltDB stores only what the promoted contract declares; publish it with\n" +
|
|
92
93
|
" `feltdb publish --contract feltdb.contract.json`. --check exits 1 when the file is out of date.",
|
|
93
|
-
deploy: "feltkit deploy [--out <dir>]\n
|
|
94
|
+
deploy: "feltkit deploy [--target container|hosted|self-hosted] [--out <dir>] [--yes]\n" +
|
|
95
|
+
" Builds, verifies the build boots, and writes .feltkit/deploy for how you run it:\n" +
|
|
96
|
+
" container everything in one container: the app and its FeltDB state on a volume (default)\n" +
|
|
97
|
+
" hosted a separate app container; data in Managed FeltDB (with feltdb.contract.json)\n" +
|
|
98
|
+
" self-hosted a separate app container; data on a FeltDB server you operate\n" +
|
|
99
|
+
" Each has a Dockerfile, docker-compose.yml, fly.toml, .env.example and DEPLOY.md. Asks which in a terminal.",
|
|
94
100
|
skills: "feltkit skills install [--user] [--dir <path>] [--force]\n" +
|
|
95
101
|
" Copies the FeltKit skills into .claude/skills/ (or ~/.claude/skills/ with --user). Run again to update.\n" +
|
|
96
102
|
"feltkit skills check [--user] [--dir <path>] [--json]\n" +
|
|
@@ -140,6 +146,17 @@ async function adminRequest(record, token, path, init = {}) {
|
|
|
140
146
|
throw new FeltKitError(body?.error?.code ?? "INTERNAL", body?.error?.message ?? `Admin API answered ${response.status}`);
|
|
141
147
|
return body;
|
|
142
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* The application as an environment runs it: outside development and test, the production
|
|
151
|
+
* build when there is one (a deployed artifact has only the build); otherwise the sources.
|
|
152
|
+
*/
|
|
153
|
+
async function loadProjectFor(projectDir, envName) {
|
|
154
|
+
const bundle = join(projectDir, ".feltkit", "build", "functions.mjs");
|
|
155
|
+
const sources = existsSync(join(projectDir, "feltkit"));
|
|
156
|
+
if (existsSync(bundle) && (!sources || (envName !== "development" && envName !== "test")))
|
|
157
|
+
return loadBundle(bundle);
|
|
158
|
+
return loadSources(projectDir);
|
|
159
|
+
}
|
|
143
160
|
/** Use the running server for an environment if there is one; otherwise open the environment directly. */
|
|
144
161
|
async function withEnvironment(projectDir, envName, remote, local) {
|
|
145
162
|
const runtimeDir = join(projectDir, ".feltkit", envName);
|
|
@@ -155,8 +172,8 @@ async function withEnvironment(projectDir, envName, remote, local) {
|
|
|
155
172
|
throw new FeltKitError("CONFIGURATION", `A ${envName} server is running (pid ${record.pid}) but its admin token is missing.`);
|
|
156
173
|
return { value: await remote(record, token), source: `running server (pid ${record.pid}, ${record.url})` };
|
|
157
174
|
}
|
|
158
|
-
const project = await
|
|
159
|
-
const environment = resolveEnvironment({ projectDir, appName: project.app.name, name: envName });
|
|
175
|
+
const project = await loadProjectFor(projectDir, envName);
|
|
176
|
+
const environment = resolveEnvironment({ projectDir, appName: project.app.name, name: envName, env: artifactEnv(projectDir) });
|
|
160
177
|
const runtime = await FeltKitRuntime.start({ project, environment, logger: silentLogger });
|
|
161
178
|
try {
|
|
162
179
|
return { value: await local(runtime), source: "opened directly (no server running)" };
|
|
@@ -358,15 +375,50 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
358
375
|
return 0;
|
|
359
376
|
}
|
|
360
377
|
case "deploy": {
|
|
361
|
-
|
|
378
|
+
// How it will run: --target, else asked in a terminal, else one container.
|
|
379
|
+
let target = flags.target ? String(flags.target) : undefined;
|
|
380
|
+
if (!target && process.stdin.isTTY && process.stdout.isTTY && !flags.yes) {
|
|
381
|
+
const choices = Object.entries(DEPLOY_TARGETS);
|
|
382
|
+
line(c.bold("How do you want to run it?"));
|
|
383
|
+
choices.forEach(([name, text], i) => line(` ${i + 1}) ${text} ${c.dim(`(--target ${name})`)}`));
|
|
384
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
385
|
+
const answer = (await rl.question(`Choose 1-${choices.length} [1]: `)).trim();
|
|
386
|
+
rl.close();
|
|
387
|
+
target = choices[Math.max(0, Number(answer || 1) - 1)]?.[0];
|
|
388
|
+
if (!target)
|
|
389
|
+
throw new FeltKitError("INVALID_ARGUMENT", `Answer 1-${choices.length}.`);
|
|
390
|
+
}
|
|
391
|
+
const result = await deploy({ projectDir, ...(flags.out ? { out: String(flags.out) } : {}), ...(target ? { target: target } : {}) });
|
|
362
392
|
line(`${symbols.ok} Built and verified: the production build booted against a temporary state directory and answered health and capability checks.`);
|
|
363
|
-
line(`${symbols.ok} Artifact: ${c.bold(result.dir)}`);
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
393
|
+
line(`${symbols.ok} Artifact (${lower(DEPLOY_TARGETS[result.target])}): ${c.bold(result.dir)}${flags.out ? "" : c.dim(" (replaced on every deploy; its .feltkit/production state is kept)")}`);
|
|
394
|
+
// Paths relative to where the command ran, one command per line, so each can be pasted.
|
|
395
|
+
const at = relative(process.cwd(), result.dir) || ".";
|
|
396
|
+
if (result.target === "hosted") {
|
|
397
|
+
line(`\n${c.bold("1. Create the app in Managed FeltDB, and its runtime key")}`);
|
|
398
|
+
line(` cp ${join(at, ".env.example")} ${join(at, ".env")}`);
|
|
399
|
+
line(` npx feltdb init-managed --contract ${join(at, "feltdb.contract.json")} --runtime-scopes minimal`);
|
|
400
|
+
line(` ${c.dim(`then put FELTDB_URL, FELTDB_APPLICATION_ID and FELTDB_TOKEN${result.apiKeys ? " (and FELTKIT_API_KEY_VERIFIER_KEY)" : ""} in ${join(at, ".env")}`)}`);
|
|
401
|
+
line(`\n${c.bold("2. Run it")}`);
|
|
402
|
+
line(` docker compose -f ${join(at, "docker-compose.yml")} up --build`);
|
|
403
|
+
}
|
|
404
|
+
else if (result.target === "self-hosted") {
|
|
405
|
+
line(`\n${c.bold("1. Give the app a key for its namespace on your FeltDB server")}`);
|
|
406
|
+
line(` feltdb-server keys create --keys <keys.json> --name ${result.application} --namespace ${result.application} --scope state:read,state:write`);
|
|
407
|
+
line(` cp ${join(at, ".env.example")} ${join(at, ".env")}`);
|
|
408
|
+
line(` ${c.dim(`then put FELTDB_URL and FELTDB_TOKEN${result.apiKeys ? " (and FELTKIT_API_KEY_VERIFIER_KEY)" : ""} in ${join(at, ".env")}`)}`);
|
|
409
|
+
line(`\n${c.bold("2. Run it")}`);
|
|
410
|
+
line(` docker compose -f ${join(at, "docker-compose.yml")} up --build`);
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
line(`\n${c.bold("Run it with Docker")} ${c.dim("(data on a volume)")}`);
|
|
414
|
+
line(` docker compose -f ${join(at, "docker-compose.yml")} up --build`);
|
|
415
|
+
line(`\n${c.bold("Or with Node 20+")} ${c.dim("(data in its .feltkit/production)")}`);
|
|
416
|
+
line(` cd ${at}`);
|
|
417
|
+
line(" npm ci --omit=dev");
|
|
418
|
+
line(" npm start");
|
|
419
|
+
}
|
|
420
|
+
line(c.dim(`\nThen open http://localhost:3000. The target's contract (state, recovery, upgrades), Fly.io and other hosts: ${join(at, "DEPLOY.md")}.`));
|
|
421
|
+
line(c.dim(`Other ways to run it: ${Object.keys(DEPLOY_TARGETS).filter((id) => id !== result.target).map((id) => `npx feltkit deploy --target ${id}`).join(" | ")}`));
|
|
370
422
|
return 0;
|
|
371
423
|
}
|
|
372
424
|
case "session": {
|
|
@@ -581,8 +633,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
581
633
|
}
|
|
582
634
|
const env = String(flags.env ?? "production");
|
|
583
635
|
// The application's declared roles: from the production build when there is one, else the sources.
|
|
584
|
-
const
|
|
585
|
-
const project = existsSync(bundle) ? await loadBundle(bundle) : await loadSources(projectDir);
|
|
636
|
+
const project = await loadProjectFor(projectDir, env);
|
|
586
637
|
const roles = String(flags.role).split(",").map((r) => r.trim()).filter(Boolean);
|
|
587
638
|
const declared = project.app.options.roles ?? {};
|
|
588
639
|
const unknown = roles.filter((r) => !declared[r]);
|