@feltdb/core 0.7.1 → 0.7.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.
Files changed (41) hide show
  1. package/README.md +22 -0
  2. package/dist/cli/commands.js +163 -33
  3. package/dist/cli/index.js +1 -1
  4. package/dist/collection.d.ts.map +1 -1
  5. package/dist/collection.js +2 -1
  6. package/dist/create/package-versions.js +1 -1
  7. package/dist/create/server-source/crates/feltdb/src/authority_failover.rs +769 -0
  8. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +305 -0
  9. package/dist/create/server-source/crates/feltdb/src/lib.rs +9 -0
  10. package/dist/create/server-source/crates/feltdb/src/state_facade.rs +292 -0
  11. package/dist/create/server-source/crates/feltdb/src/state_model.rs +1856 -0
  12. package/dist/create/server-source/crates/feltdb/tests/feltdb_state_boundary_tests.rs +634 -0
  13. package/dist/create/server-source/crates/feltdb/tests/state_model_integration.rs +366 -0
  14. package/dist/create/server-source/crates/feltdb/tests/state_persistence_integration.rs +270 -0
  15. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +13 -0
  16. package/dist/create/server-source/crates/feltdb-server/src/main.rs +184 -1
  17. package/dist/db.d.ts +7 -0
  18. package/dist/db.d.ts.map +1 -1
  19. package/dist/db.js +12 -1
  20. package/dist/feltdb.d.ts +2 -0
  21. package/dist/feltdb.d.ts.map +1 -1
  22. package/dist/http-db.d.ts +24 -0
  23. package/dist/http-db.d.ts.map +1 -1
  24. package/dist/http-db.js +13 -0
  25. package/dist/index-core.d.ts +1 -0
  26. package/dist/index-core.d.ts.map +1 -1
  27. package/dist/studio/app.d.ts +3 -1
  28. package/dist/studio/app.d.ts.map +1 -1
  29. package/dist/studio/components/ApplicationDesigner.d.ts +9 -1
  30. package/dist/studio/components/ApplicationDesigner.d.ts.map +1 -1
  31. package/dist/studio/components/index.js +1 -1
  32. package/dist/studio/{components-C5p2TfIU.js → components-Dxuhrv8_.js} +196 -187
  33. package/dist/studio/index.js +66 -65
  34. package/dist/studio-app/assets/{feltdb_wasm-C9xpYtna.js → feltdb_wasm-DVKsw75S.js} +1 -1
  35. package/dist/studio-app/assets/feltdb_wasm_bg-DNyNf0yy.wasm +0 -0
  36. package/dist/studio-app/assets/index-B5tnmvSD.js +28 -0
  37. package/dist/studio-app/index.html +1 -1
  38. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  39. package/package.json +1 -1
  40. package/dist/studio-app/assets/feltdb_wasm_bg-BsXHw7eX.wasm +0 -0
  41. package/dist/studio-app/assets/index-sQyf4Ewl.js +0 -28
@@ -1094,22 +1094,24 @@ function R({ db: e, model: t, onSearch: r }) {
1094
1094
  //#endregion
1095
1095
  //#region src/components/ApplicationDesigner.tsx
1096
1096
  var z = f(d("Application"));
1097
- function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g }) {
1098
- let _ = `feltdb:studio:draft:${t}`, v = i((() => {
1097
+ function B({ db: e, namespace: t = "default", projectSpec: o, managedPublish: g, onSpecChange: _ }) {
1098
+ let v = `feltdb:studio:draft:${t}`, y = i((() => {
1099
1099
  if (typeof window > "u") return z;
1100
- let e = window.localStorage.getItem(_);
1100
+ let e = window.localStorage.getItem(v);
1101
1101
  if (!e) return z;
1102
1102
  try {
1103
1103
  return p(e), e;
1104
1104
  } catch {
1105
1105
  return z;
1106
1106
  }
1107
- })()), y = i(v.current !== z), [b, x] = a(v.current), [S, C] = a(() => p(v.current)), [w, T] = a([]), [E, D] = a([]), [O, k] = a("Draft is valid"), [A, j] = a(0), [M, N] = a(null), [P, F] = a(null), [I, L] = a(!1), [R, B] = a(!1), [V, H] = a({
1108
- url: "",
1109
- namespace: t,
1110
- token: "",
1107
+ })()), b = i(y.current !== z), [x, S] = a(y.current), [C, w] = a(() => p(y.current)), [T, E] = a([]), [D, O] = a([]), [k, A] = a("Draft is valid"), [j, M] = a(0), [N, P] = a(null), [F, I] = a(null), [L, R] = a(!1), [B, V] = a(!1), [H, U] = a(() => ({
1108
+ url: g?.url || "",
1109
+ namespace: g?.namespace || t,
1110
+ token: g?.token || "",
1111
+ environment: g?.environment,
1112
+ applicationId: g?.applicationId,
1111
1113
  allowDestructive: !1
1112
- }), U = i(null), W = E.length ? E[E.length - 1].source : f(d(S.app)), G = r(() => u(p(W), S), [W, S]), K = r(() => m(p(W), S), [W, S]);
1114
+ })), W = i(null), G = D.length ? D[D.length - 1].source : f(d(C.app)), K = r(() => u(p(G), C), [G, C]), q = r(() => m(p(G), C), [G, C]);
1113
1115
  n(() => {
1114
1116
  if (!e || o) return;
1115
1117
  let t = !1;
@@ -1118,76 +1120,76 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1118
1120
  let n = await e.collection("_flow_apps").all(), r = n.find((e) => e.status === "active") ?? n[0];
1119
1121
  if (!r || t) return;
1120
1122
  let i = f(r.spec);
1121
- y.current || (C(r.spec), x(i)), j(r.version ?? 0);
1123
+ b.current || (w(r.spec), S(i)), M(r.version ?? 0);
1122
1124
  let a = (await e.collection("_flow_app_versions").all()).filter((e) => e.app === r.app).sort((e, t) => e.version - t.version);
1123
- t || (D(a.map((e) => ({
1125
+ t || (O(a.map((e) => ({
1124
1126
  version: e.version,
1125
1127
  source: f(e.spec),
1126
1128
  savedAt: e.deployed_at
1127
- }))), k(`Loaded ${r.app} v${r.version}`));
1129
+ }))), A(`Loaded ${r.app} v${r.version}`));
1128
1130
  } catch (e) {
1129
- t || k(`Could not load deployed model: ${e instanceof Error ? e.message : String(e)}`);
1131
+ t || A(`Could not load deployed model: ${e instanceof Error ? e.message : String(e)}`);
1130
1132
  }
1131
1133
  })(), () => {
1132
1134
  t = !0;
1133
1135
  };
1134
1136
  }, [e, o]), n(() => {
1135
- let e = window.setTimeout(() => window.localStorage.setItem(_, b), 200);
1137
+ let e = window.setTimeout(() => window.localStorage.setItem(v, x), 200);
1136
1138
  return () => window.clearTimeout(e);
1137
- }, [_, b]);
1138
- let q = (e) => {
1139
- x(e);
1139
+ }, [v, x]);
1140
+ let J = (e) => {
1141
+ S(e);
1140
1142
  try {
1141
1143
  let t = p(e), n = h(t);
1142
- C(t), g?.(t), T(n), k(n.some((e) => e.severity === "error") ? "Model has validation errors" : "Draft is valid");
1144
+ w(t), _?.(t), E(n), A(n.some((e) => e.severity === "error") ? "Model has validation errors" : "Draft is valid");
1143
1145
  } catch (e) {
1144
- T([{
1146
+ E([{
1145
1147
  severity: "error",
1146
1148
  message: e instanceof Error ? e.message : String(e)
1147
- }]), k("DSL parse failed");
1149
+ }]), A("DSL parse failed");
1148
1150
  }
1149
1151
  };
1150
1152
  n(() => {
1151
1153
  if (!o) return;
1152
1154
  let e = f(o);
1153
- x(e), C(o), T(h(o)), k(`Loaded ${o.app} project model`);
1155
+ S(e), w(o), E(h(o)), A(`Loaded ${o.app} project model`);
1154
1156
  }, [o]);
1155
- let J = (e) => {
1156
- C(e), q(f(e));
1157
- }, Y = () => {
1158
- if (!P) return F({ name: "" });
1159
- let e = P.name.trim();
1160
- if (!/^[A-Z][A-Za-z0-9_]*$/.test(e)) return F({
1161
- ...P,
1157
+ let Y = (e) => {
1158
+ w(e), J(f(e));
1159
+ }, X = () => {
1160
+ if (!F) return I({ name: "" });
1161
+ let e = F.name.trim();
1162
+ if (!/^[A-Z][A-Za-z0-9_]*$/.test(e)) return I({
1163
+ ...F,
1162
1164
  error: "Use a capitalized name with no spaces."
1163
1165
  });
1164
- if (S.collections.some((t) => t.name === e)) return F({
1165
- ...P,
1166
+ if (C.collections.some((t) => t.name === e)) return I({
1167
+ ...F,
1166
1168
  error: "That collection already exists."
1167
1169
  });
1168
- J({
1169
- ...S,
1170
- collections: [...S.collections, {
1170
+ Y({
1171
+ ...C,
1172
+ collections: [...C.collections, {
1171
1173
  name: e,
1172
1174
  fields: [],
1173
1175
  indexes: []
1174
1176
  }]
1175
- }), F(null);
1176
- }, X = (e) => N({
1177
+ }), I(null);
1178
+ }, Z = (e) => P({
1177
1179
  collection: e,
1178
1180
  name: "",
1179
1181
  type: "text",
1180
1182
  reference: "",
1181
1183
  optional: !1
1182
- }), Z = () => {
1183
- if (!M) return;
1184
- let e = M.name.trim(), t = S.collections.find((e) => e.name === M.collection);
1185
- if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) return N({
1186
- ...M,
1184
+ }), Q = () => {
1185
+ if (!N) return;
1186
+ let e = N.name.trim(), t = C.collections.find((e) => e.name === N.collection);
1187
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)) return P({
1188
+ ...N,
1187
1189
  error: "Use a letter-led name with no spaces."
1188
1190
  });
1189
- if (t?.fields.some((t) => t.name === e)) return N({
1190
- ...M,
1191
+ if (t?.fields.some((t) => t.name === e)) return P({
1192
+ ...N,
1191
1193
  error: "That field already exists."
1192
1194
  });
1193
1195
  if ([
@@ -1196,101 +1198,100 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1196
1198
  "array",
1197
1199
  "map",
1198
1200
  "vector"
1199
- ].includes(M.type) && !M.reference.trim()) return N({
1200
- ...M,
1201
+ ].includes(N.type) && !N.reference.trim()) return P({
1202
+ ...N,
1201
1203
  error: "Configure this field type."
1202
1204
  });
1203
- let n = M.type === "ref" ? `ref ${M.reference}` : M.type === "enum" ? `enum(${M.reference.split(",").map((e) => e.trim()).filter(Boolean).join(",")})` : M.type === "array" ? `array<${M.reference.trim()}>` : M.type === "map" ? `map<${M.reference.trim()}>` : M.type === "vector" ? `vector<${M.reference.trim()}>` : M.type;
1204
- J({
1205
- ...S,
1206
- collections: S.collections.map((t) => t.name === M.collection ? {
1205
+ let n = N.type === "ref" ? `ref ${N.reference}` : N.type === "enum" ? `enum(${N.reference.split(",").map((e) => e.trim()).filter(Boolean).join(",")})` : N.type === "array" ? `array<${N.reference.trim()}>` : N.type === "map" ? `map<${N.reference.trim()}>` : N.type === "vector" ? `vector<${N.reference.trim()}>` : N.type;
1206
+ Y({
1207
+ ...C,
1208
+ collections: C.collections.map((t) => t.name === N.collection ? {
1207
1209
  ...t,
1208
1210
  fields: [...t.fields, {
1209
1211
  name: e,
1210
1212
  type: n,
1211
- optional: M.optional
1213
+ optional: N.optional
1212
1214
  }]
1213
1215
  } : t)
1214
- }), N(null);
1215
- }, Q = () => {
1216
- let e = [...E, {
1217
- version: E.length + 1,
1218
- source: b,
1216
+ }), P(null);
1217
+ }, $ = () => {
1218
+ let e = [...D, {
1219
+ version: D.length + 1,
1220
+ source: x,
1219
1221
  savedAt: Date.now()
1220
1222
  }];
1221
- D(e), k(`Saved local revision v${e.length}`);
1222
- }, $ = async () => {
1223
- if (!e) return k("Local embedded storage is unavailable");
1224
- if (w.some((e) => e.severity === "error")) return k("Resolve validation errors before deploying");
1225
- if (K.filter((e) => e.safety === "destructive").length && !I) return k("Review and approve destructive local changes before applying");
1223
+ O(e), A(`Saved local revision v${e.length}`);
1224
+ }, ee = async () => {
1225
+ if (!e) return A("Local embedded storage is unavailable");
1226
+ if (T.some((e) => e.severity === "error")) return A("Resolve validation errors before deploying");
1227
+ if (q.filter((e) => e.safety === "destructive").length && !L) return A("Review and approve destructive local changes before applying");
1226
1228
  try {
1227
- let t = await e.deployFlowSpec(S, A, I), n = [...E, {
1229
+ let t = await e.deployFlowSpec(C, j, L), n = [...D, {
1228
1230
  version: t.version,
1229
- source: b,
1231
+ source: x,
1230
1232
  savedAt: Date.now()
1231
1233
  }];
1232
- D(n), j(t.version), L(!1), k(`Applied locally as ${t.app} v${t.version}`);
1234
+ O(n), M(t.version), R(!1), A(`Applied locally as ${t.app} v${t.version}`);
1233
1235
  } catch (e) {
1234
- k(`Local apply failed: ${e instanceof Error ? e.message : String(e)}`);
1236
+ A(`Local apply failed: ${e instanceof Error ? e.message : String(e)}`);
1235
1237
  }
1236
- }, ee = async () => {
1237
- if (!V.url.trim() || !V.token.trim()) return H({
1238
- ...V,
1238
+ }, te = async () => {
1239
+ if (!H.url.trim() || !H.token.trim()) return U({
1240
+ ...H,
1239
1241
  error: "Cloud URL and API key are required."
1240
1242
  });
1241
- if (w.some((e) => e.severity === "error")) return H({
1242
- ...V,
1243
+ if (T.some((e) => e.severity === "error")) return U({
1244
+ ...H,
1243
1245
  error: "Resolve validation errors before publishing."
1244
1246
  });
1245
- H({
1246
- ...V,
1247
+ U({
1248
+ ...H,
1247
1249
  publishing: !0,
1248
1250
  error: void 0
1249
1251
  });
1250
1252
  let e = l({
1251
- namespace: V.namespace.trim() || t,
1253
+ namespace: H.namespace.trim() || t,
1252
1254
  server: {
1253
- url: V.url.trim().replace(/\/$/, ""),
1254
- token: V.token
1255
+ url: H.url.trim().replace(/\/$/, ""),
1256
+ token: H.token
1255
1257
  }
1256
1258
  });
1257
1259
  try {
1258
- let t = await e.collection("_flow_apps").get(S.app), n = m(t?.spec ?? d(S.app), S).filter((e) => e.safety === "destructive");
1259
- if (n.length && !V.allowDestructive) return H({
1260
- ...V,
1260
+ let t = await e.collection("_flow_apps").get(C.app), n = m(t?.spec ?? d(C.app), C).filter((e) => e.safety === "destructive");
1261
+ if (n.length && !H.allowDestructive) return U({
1262
+ ...H,
1261
1263
  publishing: !1,
1262
1264
  destructive: n.map((e) => e.target),
1263
1265
  error: `Review and approve destructive changes: ${n.map((e) => e.target).join(", ")}`
1264
1266
  });
1265
- let r = await e.deployFlowSpec(S, t?.version ?? 0, V.allowDestructive);
1266
- window.sessionStorage.setItem(`feltdb-token:${V.url.trim()}`, V.token), H({
1267
- ...V,
1267
+ let r = await e.deployFlowSpec(C, t?.version ?? 0, H.allowDestructive);
1268
+ window.sessionStorage.setItem(`feltdb-token:${H.url.trim()}`, H.token), U({
1269
+ ...H,
1268
1270
  publishing: !1,
1269
- token: "",
1270
1271
  error: void 0
1271
- }), B(!1), k(`Published ${r.app} v${r.version} to cloud`);
1272
+ }), V(!1), A(`Published ${r.app} v${r.version} to ${H.environment || "cloud"}`);
1272
1273
  } catch (e) {
1273
- H({
1274
- ...V,
1274
+ U({
1275
+ ...H,
1275
1276
  publishing: !1,
1276
1277
  error: e instanceof Error ? e.message : String(e)
1277
1278
  });
1278
1279
  } finally {
1279
1280
  await e.close();
1280
1281
  }
1281
- }, te = () => {
1282
- let e = URL.createObjectURL(new Blob([b], { type: "text/plain" })), t = document.createElement("a");
1282
+ }, ne = () => {
1283
+ let e = URL.createObjectURL(new Blob([x], { type: "text/plain" })), t = document.createElement("a");
1283
1284
  t.href = e, t.download = "feltdb.flow", t.click(), URL.revokeObjectURL(e);
1284
- }, ne = async (e) => {
1285
- e && q(await e.text());
1286
- }, re = [
1287
- ["Data", S.collections.map((e) => e.name)],
1288
- ["Capabilities", S.capabilities.map((e) => e.name)],
1289
- ["Agents", S.agents.map((e) => e.name)],
1290
- ["Workflows", S.workflows.map((e) => e.name)],
1291
- ["Triggers", S.triggers.map((e) => e.event)],
1292
- ["Policies", S.policies.map((e) => e.name)],
1293
- ["Schedules", S.schedules.map((e) => e.name)]
1285
+ }, re = async (e) => {
1286
+ e && J(await e.text());
1287
+ }, ie = [
1288
+ ["Data", C.collections.map((e) => e.name)],
1289
+ ["Capabilities", C.capabilities.map((e) => e.name)],
1290
+ ["Agents", C.agents.map((e) => e.name)],
1291
+ ["Workflows", C.workflows.map((e) => e.name)],
1292
+ ["Triggers", C.triggers.map((e) => e.event)],
1293
+ ["Policies", C.policies.map((e) => e.name)],
1294
+ ["Schedules", C.schedules.map((e) => e.name)]
1294
1295
  ];
1295
1296
  return /* @__PURE__ */ c("div", {
1296
1297
  className: "application-designer",
@@ -1302,58 +1303,58 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1302
1303
  className: "eyebrow",
1303
1304
  children: "Application fabric"
1304
1305
  }),
1305
- /* @__PURE__ */ s("h1", { children: S.app }),
1306
+ /* @__PURE__ */ s("h1", { children: C.app }),
1306
1307
  /* @__PURE__ */ s("p", { children: "One model for state, intelligence, automation, security, and placement." })
1307
1308
  ] }), /* @__PURE__ */ c("div", {
1308
1309
  className: "designer-actions",
1309
1310
  children: [
1310
1311
  /* @__PURE__ */ s("input", {
1311
- ref: U,
1312
+ ref: W,
1312
1313
  hidden: !0,
1313
1314
  type: "file",
1314
1315
  accept: ".flow,text/plain",
1315
- onChange: (e) => void ne(e.target.files?.[0])
1316
+ onChange: (e) => void re(e.target.files?.[0])
1316
1317
  }),
1317
1318
  /* @__PURE__ */ s("button", {
1318
1319
  className: "btn btn-ghost",
1319
- onClick: () => U.current?.click(),
1320
+ onClick: () => W.current?.click(),
1320
1321
  children: "Import"
1321
1322
  }),
1322
1323
  /* @__PURE__ */ s("button", {
1323
1324
  className: "btn btn-ghost",
1324
- onClick: te,
1325
+ onClick: ne,
1325
1326
  children: "Export"
1326
1327
  }),
1327
1328
  /* @__PURE__ */ s("button", {
1328
1329
  className: "btn btn-ghost",
1329
- onClick: Q,
1330
+ onClick: $,
1330
1331
  children: "Version"
1331
1332
  }),
1332
1333
  /* @__PURE__ */ s("button", {
1333
1334
  className: "btn btn-ghost",
1334
- onClick: () => void $(),
1335
+ onClick: () => void ee(),
1335
1336
  children: "Apply locally"
1336
1337
  }),
1337
1338
  /* @__PURE__ */ s("button", {
1338
1339
  className: "btn btn-primary",
1339
- onClick: () => B((e) => !e),
1340
+ onClick: () => V((e) => !e),
1340
1341
  children: "Publish to cloud"
1341
1342
  })
1342
1343
  ]
1343
1344
  })]
1344
1345
  }),
1345
- K.some((e) => e.safety === "destructive") && /* @__PURE__ */ c("label", {
1346
+ q.some((e) => e.safety === "destructive") && /* @__PURE__ */ c("label", {
1346
1347
  className: "local-destructive",
1347
1348
  children: [/* @__PURE__ */ s("input", {
1348
1349
  type: "checkbox",
1349
- checked: I,
1350
- onChange: (e) => L(e.target.checked)
1351
- }), /* @__PURE__ */ c("span", { children: ["Approve destructive local changes: ", K.filter((e) => e.safety === "destructive").map((e) => e.target).join(", ")] })]
1350
+ checked: L,
1351
+ onChange: (e) => R(e.target.checked)
1352
+ }), /* @__PURE__ */ c("span", { children: ["Approve destructive local changes: ", q.filter((e) => e.safety === "destructive").map((e) => e.target).join(", ")] })]
1352
1353
  }),
1353
- R && /* @__PURE__ */ c("form", {
1354
+ B && /* @__PURE__ */ c("form", {
1354
1355
  className: "cloud-publisher",
1355
1356
  onSubmit: (e) => {
1356
- e.preventDefault(), ee();
1357
+ e.preventDefault(), te();
1357
1358
  },
1358
1359
  children: [
1359
1360
  /* @__PURE__ */ c("div", {
@@ -1368,7 +1369,7 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1368
1369
  ] }), /* @__PURE__ */ s("button", {
1369
1370
  type: "button",
1370
1371
  "aria-label": "Close cloud publisher",
1371
- onClick: () => B(!1),
1372
+ onClick: () => V(!1),
1372
1373
  children: "×"
1373
1374
  })]
1374
1375
  }),
@@ -1378,9 +1379,9 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1378
1379
  /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "FeltDB Cloud URL" }), /* @__PURE__ */ s("input", {
1379
1380
  type: "url",
1380
1381
  placeholder: "https://your-instance.feltdb.cloud",
1381
- value: V.url,
1382
- onChange: (e) => H({
1383
- ...V,
1382
+ value: H.url,
1383
+ onChange: (e) => U({
1384
+ ...H,
1384
1385
  url: e.target.value,
1385
1386
  error: void 0,
1386
1387
  destructive: void 0,
@@ -1388,9 +1389,9 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1388
1389
  })
1389
1390
  })] }),
1390
1391
  /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Namespace" }), /* @__PURE__ */ s("input", {
1391
- value: V.namespace,
1392
- onChange: (e) => H({
1393
- ...V,
1392
+ value: H.namespace,
1393
+ onChange: (e) => U({
1394
+ ...H,
1394
1395
  namespace: e.target.value,
1395
1396
  error: void 0,
1396
1397
  destructive: void 0,
@@ -1400,56 +1401,64 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1400
1401
  /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "API key" }), /* @__PURE__ */ s("input", {
1401
1402
  type: "password",
1402
1403
  autoComplete: "off",
1403
- placeholder: "Stored for this browser session only",
1404
- value: V.token,
1405
- onChange: (e) => H({
1406
- ...V,
1404
+ placeholder: "Loaded securely from this project",
1405
+ value: H.token,
1406
+ onChange: (e) => U({
1407
+ ...H,
1407
1408
  token: e.target.value,
1408
1409
  error: void 0
1409
1410
  })
1411
+ })] }),
1412
+ H.environment && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Environment" }), /* @__PURE__ */ s("input", {
1413
+ value: H.environment,
1414
+ readOnly: !0
1415
+ })] }),
1416
+ H.applicationId && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Application" }), /* @__PURE__ */ s("input", {
1417
+ value: H.applicationId,
1418
+ readOnly: !0
1410
1419
  })] })
1411
1420
  ]
1412
1421
  }),
1413
- (V.destructive?.length || K.some((e) => e.safety === "destructive")) && /* @__PURE__ */ c("label", {
1422
+ (H.destructive?.length || q.some((e) => e.safety === "destructive")) && /* @__PURE__ */ c("label", {
1414
1423
  className: "cloud-destructive",
1415
1424
  children: [/* @__PURE__ */ s("input", {
1416
1425
  type: "checkbox",
1417
- checked: V.allowDestructive,
1418
- onChange: (e) => H({
1419
- ...V,
1426
+ checked: H.allowDestructive,
1427
+ onChange: (e) => U({
1428
+ ...H,
1420
1429
  allowDestructive: e.target.checked
1421
1430
  })
1422
- }), /* @__PURE__ */ c("span", { children: ["I reviewed and approve destructive model changes", V.destructive?.length ? `: ${V.destructive.join(", ")}` : "."] })]
1431
+ }), /* @__PURE__ */ c("span", { children: ["I reviewed and approve destructive model changes", H.destructive?.length ? `: ${H.destructive.join(", ")}` : "."] })]
1423
1432
  }),
1424
- V.error && /* @__PURE__ */ s("div", {
1433
+ H.error && /* @__PURE__ */ s("div", {
1425
1434
  className: "cloud-error",
1426
1435
  role: "alert",
1427
- children: V.error
1436
+ children: H.error
1428
1437
  }),
1429
1438
  /* @__PURE__ */ c("div", {
1430
1439
  className: "cloud-actions",
1431
1440
  children: [/* @__PURE__ */ s("button", {
1432
1441
  type: "button",
1433
1442
  className: "btn btn-ghost",
1434
- onClick: () => B(!1),
1443
+ onClick: () => V(!1),
1435
1444
  children: "Cancel"
1436
1445
  }), /* @__PURE__ */ s("button", {
1437
1446
  className: "btn btn-primary",
1438
- disabled: V.publishing,
1447
+ disabled: H.publishing,
1439
1448
  type: "submit",
1440
- children: V.publishing ? "Publishing…" : "Review and publish"
1449
+ children: H.publishing ? "Publishing…" : "Review and publish"
1441
1450
  })]
1442
1451
  })
1443
1452
  ]
1444
1453
  }),
1445
1454
  /* @__PURE__ */ c("div", {
1446
- className: `designer-status ${w.some((e) => e.severity === "error") ? "error" : ""}`,
1447
- children: [/* @__PURE__ */ s("span", { children: O }), /* @__PURE__ */ c("span", { children: [
1448
- S.collections.length,
1455
+ className: `designer-status ${T.some((e) => e.severity === "error") ? "error" : ""}`,
1456
+ children: [/* @__PURE__ */ s("span", { children: k }), /* @__PURE__ */ c("span", { children: [
1457
+ C.collections.length,
1449
1458
  " collections · ",
1450
- S.workflows.length,
1459
+ C.workflows.length,
1451
1460
  " workflows · ",
1452
- E.length ? `v${E.length}` : "draft"
1461
+ D.length ? `v${D.length}` : "draft"
1453
1462
  ] })]
1454
1463
  }),
1455
1464
  /* @__PURE__ */ c("div", {
@@ -1462,33 +1471,33 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1462
1471
  className: "panel-title",
1463
1472
  children: [/* @__PURE__ */ s("span", { children: "Application" }), /* @__PURE__ */ s("button", {
1464
1473
  "aria-label": "Add collection",
1465
- onClick: () => F({ name: "" }),
1474
+ onClick: () => I({ name: "" }),
1466
1475
  children: "+"
1467
1476
  })]
1468
1477
  }),
1469
- P && /* @__PURE__ */ c("form", {
1478
+ F && /* @__PURE__ */ c("form", {
1470
1479
  className: "collection-editor",
1471
1480
  onSubmit: (e) => {
1472
- e.preventDefault(), Y();
1481
+ e.preventDefault(), X();
1473
1482
  },
1474
1483
  onKeyDown: (e) => {
1475
- e.key === "Escape" && F(null);
1484
+ e.key === "Escape" && I(null);
1476
1485
  },
1477
1486
  children: [
1478
1487
  /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "New collection" }), /* @__PURE__ */ s("input", {
1479
1488
  autoFocus: !0,
1480
1489
  placeholder: "e.g. Customer",
1481
- value: P.name,
1482
- onChange: (e) => F({ name: e.target.value })
1490
+ value: F.name,
1491
+ onChange: (e) => I({ name: e.target.value })
1483
1492
  })] }),
1484
- P.error && /* @__PURE__ */ s("div", {
1493
+ F.error && /* @__PURE__ */ s("div", {
1485
1494
  className: "field-error",
1486
1495
  role: "alert",
1487
- children: P.error
1496
+ children: F.error
1488
1497
  }),
1489
1498
  /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("button", {
1490
1499
  type: "button",
1491
- onClick: () => F(null),
1500
+ onClick: () => I(null),
1492
1501
  children: "Cancel"
1493
1502
  }), /* @__PURE__ */ s("button", {
1494
1503
  className: "collection-save",
@@ -1497,7 +1506,7 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1497
1506
  })] })
1498
1507
  ]
1499
1508
  }),
1500
- re.map(([e, t]) => /* @__PURE__ */ c("section", { children: [/* @__PURE__ */ s("h3", { children: e }), t.length ? t.map((e) => /* @__PURE__ */ s("div", {
1509
+ ie.map(([e, t]) => /* @__PURE__ */ c("section", { children: [/* @__PURE__ */ s("h3", { children: e }), t.length ? t.map((e) => /* @__PURE__ */ s("div", {
1501
1510
  className: "tree-item",
1502
1511
  children: e
1503
1512
  }, e)) : /* @__PURE__ */ s("div", {
@@ -1519,7 +1528,7 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1519
1528
  /* @__PURE__ */ c("div", {
1520
1529
  className: "graph-board",
1521
1530
  children: [
1522
- S.collections.map((e) => /* @__PURE__ */ c("article", {
1531
+ C.collections.map((e) => /* @__PURE__ */ c("article", {
1523
1532
  className: "model-node",
1524
1533
  children: [
1525
1534
  /* @__PURE__ */ s("div", {
@@ -1531,21 +1540,21 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1531
1540
  className: "node-field",
1532
1541
  children: [/* @__PURE__ */ s("span", { children: e.name }), /* @__PURE__ */ c("code", { children: [e.type, e.optional ? "?" : ""] })]
1533
1542
  }, e.name)),
1534
- M?.collection === e.name ? /* @__PURE__ */ c("form", {
1543
+ N?.collection === e.name ? /* @__PURE__ */ c("form", {
1535
1544
  className: "field-editor",
1536
1545
  onSubmit: (e) => {
1537
- e.preventDefault(), Z();
1546
+ e.preventDefault(), Q();
1538
1547
  },
1539
1548
  onKeyDown: (e) => {
1540
- e.key === "Escape" && N(null);
1549
+ e.key === "Escape" && P(null);
1541
1550
  },
1542
1551
  children: [
1543
1552
  /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Field name" }), /* @__PURE__ */ s("input", {
1544
1553
  autoFocus: !0,
1545
- value: M.name,
1554
+ value: N.name,
1546
1555
  placeholder: "e.g. publishedAt",
1547
- onChange: (e) => N({
1548
- ...M,
1556
+ onChange: (e) => P({
1557
+ ...N,
1549
1558
  name: e.target.value,
1550
1559
  error: void 0
1551
1560
  })
@@ -1554,9 +1563,9 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1554
1563
  className: "field-editor-row",
1555
1564
  children: [
1556
1565
  /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Type" }), /* @__PURE__ */ c("select", {
1557
- value: M.type,
1558
- onChange: (e) => N({
1559
- ...M,
1566
+ value: N.type,
1567
+ onChange: (e) => P({
1568
+ ...N,
1560
1569
  type: e.target.value,
1561
1570
  error: void 0
1562
1571
  }),
@@ -1659,43 +1668,43 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1659
1668
  })
1660
1669
  ]
1661
1670
  })] }),
1662
- M.type === "ref" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Collection" }), /* @__PURE__ */ s("select", {
1663
- value: M.reference,
1664
- onChange: (e) => N({
1665
- ...M,
1671
+ N.type === "ref" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Collection" }), /* @__PURE__ */ s("select", {
1672
+ value: N.reference,
1673
+ onChange: (e) => P({
1674
+ ...N,
1666
1675
  reference: e.target.value,
1667
1676
  error: void 0
1668
1677
  }),
1669
- children: S.collections.filter((t) => t.name !== e.name).map((e) => /* @__PURE__ */ s("option", {
1678
+ children: C.collections.filter((t) => t.name !== e.name).map((e) => /* @__PURE__ */ s("option", {
1670
1679
  value: e.name,
1671
1680
  children: e.name
1672
1681
  }, e.name))
1673
1682
  })] }),
1674
- M.type === "enum" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Values" }), /* @__PURE__ */ s("input", {
1683
+ N.type === "enum" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Values" }), /* @__PURE__ */ s("input", {
1675
1684
  placeholder: "draft,active,done",
1676
- value: M.reference,
1677
- onChange: (e) => N({
1678
- ...M,
1685
+ value: N.reference,
1686
+ onChange: (e) => P({
1687
+ ...N,
1679
1688
  reference: e.target.value,
1680
1689
  error: void 0
1681
1690
  })
1682
1691
  })] }),
1683
- (M.type === "array" || M.type === "map") && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Item type" }), /* @__PURE__ */ s("input", {
1692
+ (N.type === "array" || N.type === "map") && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Item type" }), /* @__PURE__ */ s("input", {
1684
1693
  placeholder: "text, uuid, ref Project…",
1685
- value: M.reference,
1686
- onChange: (e) => N({
1687
- ...M,
1694
+ value: N.reference,
1695
+ onChange: (e) => P({
1696
+ ...N,
1688
1697
  reference: e.target.value,
1689
1698
  error: void 0
1690
1699
  })
1691
1700
  })] }),
1692
- M.type === "vector" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Dimensions" }), /* @__PURE__ */ s("input", {
1701
+ N.type === "vector" && /* @__PURE__ */ c("label", { children: [/* @__PURE__ */ s("span", { children: "Dimensions" }), /* @__PURE__ */ s("input", {
1693
1702
  type: "number",
1694
1703
  min: "1",
1695
1704
  placeholder: "1536",
1696
- value: M.reference,
1697
- onChange: (e) => N({
1698
- ...M,
1705
+ value: N.reference,
1706
+ onChange: (e) => P({
1707
+ ...N,
1699
1708
  reference: e.target.value,
1700
1709
  error: void 0
1701
1710
  })
@@ -1706,23 +1715,23 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1706
1715
  className: "field-optional",
1707
1716
  children: [/* @__PURE__ */ s("input", {
1708
1717
  type: "checkbox",
1709
- checked: M.optional,
1710
- onChange: (e) => N({
1711
- ...M,
1718
+ checked: N.optional,
1719
+ onChange: (e) => P({
1720
+ ...N,
1712
1721
  optional: e.target.checked
1713
1722
  })
1714
1723
  }), /* @__PURE__ */ s("span", { children: "Optional field" })]
1715
1724
  }),
1716
- M.error && /* @__PURE__ */ s("div", {
1725
+ N.error && /* @__PURE__ */ s("div", {
1717
1726
  className: "field-error",
1718
1727
  role: "alert",
1719
- children: M.error
1728
+ children: N.error
1720
1729
  }),
1721
1730
  /* @__PURE__ */ c("div", {
1722
1731
  className: "field-editor-actions",
1723
1732
  children: [/* @__PURE__ */ s("button", {
1724
1733
  type: "button",
1725
- onClick: () => N(null),
1734
+ onClick: () => P(null),
1726
1735
  children: "Cancel"
1727
1736
  }), /* @__PURE__ */ s("button", {
1728
1737
  className: "field-save",
@@ -1733,12 +1742,12 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1733
1742
  ]
1734
1743
  }) : /* @__PURE__ */ s("button", {
1735
1744
  className: "node-add",
1736
- onClick: () => X(e.name),
1745
+ onClick: () => Z(e.name),
1737
1746
  children: "+ field"
1738
1747
  })
1739
1748
  ]
1740
1749
  }, e.name)),
1741
- S.workflows.map((e) => /* @__PURE__ */ c("article", {
1750
+ C.workflows.map((e) => /* @__PURE__ */ c("article", {
1742
1751
  className: "model-node workflow-node",
1743
1752
  children: [
1744
1753
  /* @__PURE__ */ s("div", {
@@ -1752,7 +1761,7 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1752
1761
  }, e.name))
1753
1762
  ]
1754
1763
  }, e.name)),
1755
- S.agents.map((e) => /* @__PURE__ */ c("article", {
1764
+ C.agents.map((e) => /* @__PURE__ */ c("article", {
1756
1765
  className: "model-node agent-node",
1757
1766
  children: [
1758
1767
  /* @__PURE__ */ s("div", {
@@ -1774,15 +1783,15 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1774
1783
  /* @__PURE__ */ s("strong", { children: "Model diff" }),
1775
1784
  /* @__PURE__ */ c("span", {
1776
1785
  className: "added",
1777
- children: ["+ ", G.added.join(", ") || "none"]
1786
+ children: ["+ ", K.added.join(", ") || "none"]
1778
1787
  }),
1779
1788
  /* @__PURE__ */ c("span", {
1780
1789
  className: "changed",
1781
- children: ["~ ", G.changed.join(", ") || "none"]
1790
+ children: ["~ ", K.changed.join(", ") || "none"]
1782
1791
  }),
1783
1792
  /* @__PURE__ */ c("span", {
1784
1793
  className: "removed",
1785
- children: ["− ", G.removed.join(", ") || "none"]
1794
+ children: ["− ", K.removed.join(", ") || "none"]
1786
1795
  })
1787
1796
  ]
1788
1797
  })
@@ -1798,12 +1807,12 @@ function B({ db: e, namespace: t = "default", projectSpec: o, onSpecChange: g })
1798
1807
  /* @__PURE__ */ s("textarea", {
1799
1808
  "aria-label": "Flow DSL",
1800
1809
  spellCheck: !1,
1801
- value: b,
1802
- onChange: (e) => q(e.target.value)
1810
+ value: x,
1811
+ onChange: (e) => J(e.target.value)
1803
1812
  }),
1804
- w.length > 0 && /* @__PURE__ */ s("div", {
1813
+ T.length > 0 && /* @__PURE__ */ s("div", {
1805
1814
  className: "diagnostics",
1806
- children: w.map((e, t) => /* @__PURE__ */ c("div", {
1815
+ children: T.map((e, t) => /* @__PURE__ */ c("div", {
1807
1816
  className: e.severity,
1808
1817
  children: [
1809
1818
  e.severity,