@lunora/config 1.0.0-alpha.80 → 1.0.0-alpha.82

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 (81) hide show
  1. package/dist/index.mjs +1 -30
  2. package/dist/packem_shared/ACCENT-CLeV5v0K.mjs +7 -0
  3. package/dist/packem_shared/AGENT_MODE_ENV-B54hVQ_w.mjs +1 -0
  4. package/dist/packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs +1 -0
  5. package/dist/packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs +4 -0
  6. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-DX6xGbpr.mjs +1 -0
  7. package/dist/packem_shared/LINKED_PROJECT_DIR-CMzUvj-1.mjs +2 -0
  8. package/dist/packem_shared/LUNORA_CONFIG_FILE-3bpx6TZN.mjs +1 -0
  9. package/dist/packem_shared/LUNORA_EVENT_SOURCE-ZclWASXS.mjs +1 -0
  10. package/dist/packem_shared/LunoraReporter-BnXUqh8t.mjs +6 -0
  11. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs +1 -0
  12. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CUYWD0Mh.mjs +1 -0
  13. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-ws6iE0y-.mjs +1 -0
  14. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-DPcRuAhj.mjs +1 -0
  15. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-CZ8rSh2k.mjs +1 -0
  16. package/dist/packem_shared/SEED_ENDPOINT-BaYShU8q.mjs +1 -0
  17. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs +1 -0
  18. package/dist/packem_shared/WRANGLER_FILES-Bi_18Pj6.mjs +1 -0
  19. package/dist/packem_shared/applyAdditiveEdit-BdcnSa-j.mjs +6 -0
  20. package/dist/packem_shared/assetContentType-DNZyUOuF.mjs +1 -0
  21. package/dist/packem_shared/buildPackageSecretsBlock-BpvaZzQ8.mjs +18 -0
  22. package/dist/packem_shared/classifyPolicyEdit-BzC_MfYK.mjs +24 -0
  23. package/dist/packem_shared/collectWranglerSecretVariables-OacEwPmL.mjs +1 -0
  24. package/dist/packem_shared/createConfirm-7IL0kZyE.mjs +7 -0
  25. package/dist/packem_shared/detectFramework-VTQfCNXy.mjs +1 -0
  26. package/dist/packem_shared/discoverAgentInfo-BJm0QtoI.mjs +1 -0
  27. package/dist/packem_shared/discoverContainerInfo-CYG9j2LY.mjs +1 -0
  28. package/dist/packem_shared/discoverSchemaInfo-B2W3VrcT.mjs +1 -0
  29. package/dist/packem_shared/discoverWorkflowInfo-Bbc0u2gE.mjs +1 -0
  30. package/dist/packem_shared/inferLunoraBindings-DWSabh1j.mjs +1 -0
  31. package/dist/packem_shared/jsonc-edit-BZVpxVA0.mjs +1 -0
  32. package/dist/packem_shared/parseDevVariable-NAVJ8tgA.mjs +1 -0
  33. package/dist/packem_shared/parseSchema-BPmtMgmb.mjs +1 -0
  34. package/dist/packem_shared/reconcileWranglerBindings-Dd3tLauZ.mjs +1 -0
  35. package/dist/packem_shared/reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs +1 -0
  36. package/dist/packem_shared/reconcileWranglerCrons-BmQa_kGL.mjs +1 -0
  37. package/dist/packem_shared/renderStudioHtml-B2AkxcW1.mjs +15 -0
  38. package/dist/packem_shared/serveJsonHandler-C5GWlWJF.mjs +1 -0
  39. package/dist/packem_shared/streamContainerLogs-BPYBNrWS.mjs +2 -0
  40. package/dist/packem_shared/write-atomic-Cdr2oQb-.mjs +1 -0
  41. package/dist/studio-host/index.mjs +1 -7
  42. package/package.json +3 -3
  43. package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
  44. package/dist/packem_shared/AGENT_MODE_ENV-B5R7jpY7.mjs +0 -17
  45. package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
  46. package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +0 -163
  47. package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
  48. package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
  49. package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
  50. package/dist/packem_shared/LUNORA_EVENT_SOURCE-M1KM9_pR.mjs +0 -112
  51. package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
  52. package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-NCTSphDk.mjs +0 -138
  53. package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CvTZpaZF.mjs +0 -100
  54. package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-C-F_Flgy.mjs +0 -100
  55. package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-DP0SFVy9.mjs +0 -607
  56. package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Bt2SNkpV.mjs +0 -95
  57. package/dist/packem_shared/SEED_ENDPOINT-7izz_Jao.mjs +0 -61
  58. package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-CaXbS7CX.mjs +0 -11
  59. package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
  60. package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
  61. package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +0 -72
  62. package/dist/packem_shared/buildPackageSecretsBlock-BxOcyaAY.mjs +0 -281
  63. package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
  64. package/dist/packem_shared/collectWranglerSecretVariables-BRWIvT-e.mjs +0 -56
  65. package/dist/packem_shared/createConfirm-BMikeJC9.mjs +0 -117
  66. package/dist/packem_shared/detectFramework-U08038Yp.mjs +0 -41
  67. package/dist/packem_shared/discoverAgentInfo-eXA3hF4v.mjs +0 -19
  68. package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
  69. package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
  70. package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
  71. package/dist/packem_shared/inferLunoraBindings-BcvvtpSG.mjs +0 -397
  72. package/dist/packem_shared/jsonc-edit-SbcD7MAe.mjs +0 -9
  73. package/dist/packem_shared/parseDevVariable-B0FEvfHC.mjs +0 -21
  74. package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
  75. package/dist/packem_shared/reconcileWranglerBindings-2Cww5VLa.mjs +0 -362
  76. package/dist/packem_shared/reconcileWranglerCompatibilityDate-C8c497ag.mjs +0 -31
  77. package/dist/packem_shared/reconcileWranglerCrons-DvsceVFz.mjs +0 -29
  78. package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
  79. package/dist/packem_shared/serveJsonHandler-Cl2Wqkv8.mjs +0 -86
  80. package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
  81. package/dist/packem_shared/write-atomic-B2REqapi.mjs +0 -14
@@ -1,100 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { join, isAbsolute, relative } from 'node:path';
3
- import { runCodegen, CodegenDiagnosticError } from '@lunora/codegen';
4
- import { LunoraError } from '@lunora/errors';
5
- import { classifyPolicyEdit, scaffoldPolicyFile, wireRlsIntoProcedure } from './classifyPolicyEdit-BHeAqF8P.mjs';
6
- import { w as writeFileAtomic } from './write-atomic-B2REqapi.mjs';
7
-
8
- const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
9
- const statusForFailure = (reason) => {
10
- if (reason === "unknown-procedure") {
11
- return 404;
12
- }
13
- if (reason === "already-wired") {
14
- return 409;
15
- }
16
- return reason === "destructive" ? 409 : 422;
17
- };
18
- const runCodegenForResponse = (request, okBody) => {
19
- let diagnostics = [];
20
- try {
21
- runCodegen({ lunoraDirectory: request.schemaDirectory ?? "lunora", projectRoot: request.projectRoot });
22
- } catch (error) {
23
- if (error instanceof CodegenDiagnosticError) {
24
- diagnostics = [error.message];
25
- } else {
26
- return { body: { error: error instanceof Error ? error.message : String(error), ok: false }, status: 500 };
27
- }
28
- }
29
- return { body: { ...okBody, diagnostics, ok: true }, status: 200 };
30
- };
31
- const refuseDestructive = (edit) => {
32
- return {
33
- body: {
34
- edit,
35
- message: "Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",
36
- needsManualEdit: true,
37
- ok: false
38
- },
39
- status: 409
40
- };
41
- };
42
- const handleScaffoldPolicy = (request, edit) => {
43
- const result = scaffoldPolicyFile(edit);
44
- if (!result.ok) {
45
- return { body: { error: result.reason, ok: false }, status: statusForFailure(result.reason) };
46
- }
47
- const lunoraDirectory = request.schemaDirectory ?? "lunora";
48
- const targetPath = join(request.projectRoot, lunoraDirectory, result.fileName);
49
- if (existsSync(targetPath)) {
50
- return { body: { error: "file-exists", fileName: result.fileName, ok: false }, status: 409 };
51
- }
52
- writeFileAtomic(targetPath, result.source);
53
- return runCodegenForResponse(request, { fileName: result.fileName });
54
- };
55
- const resolveProcedureFile = (projectRoot, lunoraDirectory, filePath) => {
56
- if (typeof filePath !== "string" || filePath.length === 0 || isAbsolute(filePath) || filePath.includes("\\")) {
57
- return void 0;
58
- }
59
- const lunoraRoot = join(projectRoot, lunoraDirectory);
60
- const resolved = join(lunoraRoot, `${filePath}.ts`);
61
- const relativePath = relative(lunoraRoot, resolved);
62
- if (relativePath.startsWith("..") || isAbsolute(relativePath)) {
63
- return void 0;
64
- }
65
- return resolved;
66
- };
67
- const handleWireRls = (request, edit) => {
68
- const procedurePath = resolveProcedureFile(request.projectRoot, request.schemaDirectory ?? "lunora", edit.filePath);
69
- if (procedurePath === void 0 || !existsSync(procedurePath)) {
70
- return { body: { error: "unknown-procedure", ok: false }, status: 404 };
71
- }
72
- const wired = wireRlsIntoProcedure(readFileSync(procedurePath, "utf8"), edit);
73
- if (!wired.ok) {
74
- return { body: { error: wired.reason, ok: false }, status: statusForFailure(wired.reason) };
75
- }
76
- writeFileAtomic(procedurePath, wired.text);
77
- return runCodegenForResponse(request, { exportName: edit.exportName });
78
- };
79
- const handlePolicyScaffoldRequest = (request) => {
80
- if (request.method !== "POST") {
81
- return { body: { error: "method-not-allowed", ok: false }, status: 405 };
82
- }
83
- const { body } = request;
84
- if (body === void 0 || body === null || typeof body !== "object" || typeof body.kind !== "string") {
85
- return { body: { error: "invalid-edit", ok: false }, status: 400 };
86
- }
87
- const edit = body;
88
- if (classifyPolicyEdit(edit) === "destructive") {
89
- return refuseDestructive(edit);
90
- }
91
- if (edit.kind === "scaffoldPolicy") {
92
- return handleScaffoldPolicy(request, edit);
93
- }
94
- if (edit.kind === "wireRls") {
95
- return handleWireRls(request, edit);
96
- }
97
- throw new LunoraError("INTERNAL", `unhandled additive policy edit kind: ${String(edit.kind)}`);
98
- };
99
-
100
- export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest };
@@ -1,100 +0,0 @@
1
- import { writeFileSync, rmSync } from 'node:fs';
2
- import { a as applyModify } from './jsonc-edit-SbcD7MAe.mjs';
3
- import { findWranglerFile, readWranglerJsonc } from './WRANGLER_FILES-DwSuC-Kn.mjs';
4
- import { join } from 'node:path';
5
-
6
- const REMOTE_ELIGIBLE_KEYS = {
7
- ai: { label: "AI", shape: "object" },
8
- d1_databases: { label: "D1", shape: "array" },
9
- kv_namespaces: { label: "KV", shape: "array" },
10
- queues: { label: "Queue", shape: "producers" },
11
- r2_buckets: { label: "R2", shape: "array" },
12
- services: { label: "Service", shape: "array" },
13
- vectorize: { label: "Vectorize", shape: "array" }
14
- };
15
- const REMOTE_ELIGIBLE_KEY_LIST = Object.keys(REMOTE_ELIGIBLE_KEYS);
16
- const entryName = (entry, fallback) => typeof entry.binding === "string" ? entry.binding : fallback;
17
- const planArrayEntries = (section, entries, kind, pathPrefix) => {
18
- const plans = [];
19
- for (const [index, entry] of entries.entries()) {
20
- if (entry === null || entry === void 0) {
21
- continue;
22
- }
23
- plans.push({ binding: entryName(entry, `#${String(index)}`), kind, path: [...pathPrefix, index], section });
24
- }
25
- return plans;
26
- };
27
- const planSection = (section, parsed) => {
28
- const { label, shape } = REMOTE_ELIGIBLE_KEYS[section];
29
- if (shape === "array") {
30
- const entries = parsed[section] ?? [];
31
- return planArrayEntries(section, entries, label, []);
32
- }
33
- if (shape === "producers") {
34
- return planArrayEntries(section, parsed.queues?.producers ?? [], label, ["producers"]);
35
- }
36
- const entry = parsed.ai;
37
- return entry === null || entry === void 0 ? [] : [{ binding: entryName(entry, section), kind: label, path: [], section }];
38
- };
39
- const planRemoteBindings = (parsed) => REMOTE_ELIGIBLE_KEY_LIST.flatMap((section) => planSection(section, parsed));
40
- const injectRemoteFlags = (text, plans) => {
41
- let next = text;
42
- for (const plan of plans) {
43
- next = applyModify(next, [plan.section, ...plan.path, "remote"], true);
44
- }
45
- return next;
46
- };
47
- const noopCleanup = () => {
48
- };
49
- const createCleanup = (path) => {
50
- let done = false;
51
- return () => {
52
- if (done) {
53
- return;
54
- }
55
- done = true;
56
- try {
57
- rmSync(path, { force: true, recursive: true });
58
- } catch {
59
- }
60
- };
61
- };
62
- const remoteConfigBasename = () => `.wrangler.lunora-remote.${String(process.pid)}.jsonc`;
63
- const materializeRemoteWranglerConfig = (options) => {
64
- if (!options.enabled) {
65
- return { cleanup: noopCleanup, enabled: false, remoteBindings: [] };
66
- }
67
- const wranglerPath = findWranglerFile(options.projectRoot);
68
- if (!wranglerPath) {
69
- return { cleanup: noopCleanup, enabled: true, reason: "wrangler.jsonc not found", remoteBindings: [] };
70
- }
71
- const { parsed, text } = readWranglerJsonc(wranglerPath);
72
- if (parsed === void 0) {
73
- return { cleanup: noopCleanup, enabled: true, reason: `failed to parse ${wranglerPath} as JSONC`, remoteBindings: [] };
74
- }
75
- const plans = planRemoteBindings(parsed);
76
- if (plans.length === 0) {
77
- return { cleanup: noopCleanup, enabled: true, reason: "no remote-eligible bindings to proxy", remoteBindings: [] };
78
- }
79
- const configPath = join(options.projectRoot, remoteConfigBasename());
80
- writeFileSync(configPath, injectRemoteFlags(text, plans), "utf8");
81
- return { cleanup: createCleanup(configPath), configPath, enabled: true, remoteBindings: plans };
82
- };
83
- const isRemoteEnvEnabled = (value) => {
84
- if (value === void 0) {
85
- return false;
86
- }
87
- const normalized = value.trim().toLowerCase();
88
- return normalized === "1" || normalized === "true";
89
- };
90
- const resolveRemoteEnabled = (inputs) => {
91
- if (inputs.flag === true) {
92
- return true;
93
- }
94
- if (isRemoteEnvEnabled(inputs.envValue)) {
95
- return true;
96
- }
97
- return inputs.configPreference ?? false;
98
- };
99
-
100
- export { REMOTE_ELIGIBLE_KEYS, injectRemoteFlags, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, resolveRemoteEnabled };