@lunora/config 1.0.0-alpha.47 → 1.0.0-alpha.471
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.md +336 -104
- package/README.md +6 -6
- package/dist/celld/index.d.mts +77 -0
- package/dist/celld/index.d.ts +77 -0
- package/dist/celld/index.mjs +1 -0
- package/dist/celld-names/index.d.mts +57 -0
- package/dist/celld-names/index.d.ts +57 -0
- package/dist/celld-names/index.mjs +1 -0
- package/dist/cli/index.d.mts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.mjs +1 -0
- package/dist/cloudflare/index.d.mts +941 -0
- package/dist/cloudflare/index.d.ts +941 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +1068 -1044
- package/dist/index.d.ts +1068 -1044
- package/dist/index.mjs +1 -25
- package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
- package/dist/packem_shared/ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs +1 -0
- package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
- package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
- package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-CR06-eW7.mjs +1 -0
- package/dist/packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs +1 -0
- package/dist/packem_shared/CELLD_RELEASE_ASSETS_DIRECTORY-YBhEotjs.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-75Y5zVF8.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_DRIVER-DbmpoIcg.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DWyZ_2QM.mjs +1 -0
- package/dist/packem_shared/COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs +1 -0
- package/dist/packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-BlvZ242-.mjs +1 -0
- package/dist/packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs +1 -0
- package/dist/packem_shared/DEV_BINDINGS_FILE-BUTedHwq.mjs +4 -0
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs +6 -0
- package/dist/packem_shared/DEV_WORKER_ENV_VALUE-FoysLtF0.mjs +1 -0
- package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
- package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-Cq0oj0_9.mjs +9 -0
- package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
- package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
- package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
- package/dist/packem_shared/MissingBuildOutputError-BAyekzof.mjs +1 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-BiQ1zNsR.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DgmXfSuu.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BqFeetpX.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-D296PlpV.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-C1fhrehH.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-CvVcvTbQ.mjs +1 -0
- package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-BZEXldUo.mjs +1 -0
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-BF8PUjuo.mjs +1 -0
- package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
- package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
- package/dist/packem_shared/applyAdditiveEdit-DEwPKcJg.mjs +6 -0
- package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
- package/dist/packem_shared/assertBuildTargetMatches-D11J7F38.mjs +1 -0
- package/dist/packem_shared/assertWranglerSatisfiesSchema-_70vhvqk.mjs +3 -0
- package/dist/packem_shared/asset-headers-CPuEX21i.mjs +4 -0
- package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
- package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.mts +593 -0
- package/dist/packem_shared/binding-manifest.d-BRdoMhGE.d.ts +593 -0
- package/dist/packem_shared/bindingsNeedingDatabase-3KyGflIq.mjs +3 -0
- package/dist/packem_shared/blockingFindingsMessage-BQ9z7cie.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-DrSD60vH.mjs +19 -0
- package/dist/packem_shared/canonicalPath-DrfMiT3U.mjs +1 -0
- package/dist/packem_shared/celld-binding-id-9MiUoteo.mjs +1 -0
- package/dist/packem_shared/celld-config-Ef1RZ02t.mjs +3 -0
- package/dist/packem_shared/checkDevEnv-BwZSVBbB.mjs +3 -0
- package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
- package/dist/packem_shared/clearApiSpecMarker-DMGpP41V.mjs +2 -0
- package/dist/packem_shared/collectExportGaps-DvirOIVB.mjs +2 -0
- package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
- package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
- package/dist/packem_shared/createStudioDocumentCache-XBG1aWbl.mjs +1 -0
- package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.mts +190 -0
- package/dist/packem_shared/deploy-driver.d-CHVNQFV2.d.ts +190 -0
- package/dist/packem_shared/describePreservedCrons-i5XT6rtl.mjs +1 -0
- package/dist/packem_shared/describeWithheld-CN3D-4pU.mjs +1 -0
- package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
- package/dist/packem_shared/devTriggerHints-CN_RJxWW.mjs +1 -0
- package/dist/packem_shared/devVariablesStamp-BQkGEn9d.mjs +1 -0
- package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
- package/dist/packem_shared/discoverSchemaInfo-DRPnqgif.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
- package/dist/packem_shared/emitProjectAssetHeaders-BdqdTVN3.mjs +1 -0
- package/dist/packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs +7 -0
- package/dist/packem_shared/env-flag-u4B05gLp.mjs +1 -0
- package/dist/packem_shared/hasCloudflareCredentials-ByCrwaLT.mjs +1 -0
- package/dist/packem_shared/index.d-BoUSSRrk.d.mts +270 -0
- package/dist/packem_shared/index.d-C1nVDcie.d.ts +270 -0
- package/dist/packem_shared/inferLunoraBindings-BUk28bSQ.mjs +1 -0
- package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
- package/dist/packem_shared/is-within-directory-DRMw89rK.mjs +1 -0
- package/dist/packem_shared/isOwnedStudioAssets-CHII-uIX.mjs +1 -0
- package/dist/packem_shared/materializeServiceDevConfigs-CdmKflBp.mjs +1 -0
- package/dist/packem_shared/mergeWranglerEnvironment-CxT2PV1N.mjs +1 -0
- package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
- package/dist/packem_shared/pendingBindingChanges-DkVojIQe.mjs +1 -0
- package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.mts +338 -0
- package/dist/packem_shared/placeholder-ids.d-DvGHP6bl.d.ts +338 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
- package/dist/packem_shared/probeCelldToolchain-DxDttfHy.mjs +1 -0
- package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
- package/dist/packem_shared/queue-info-D38n7YdX.mjs +1 -0
- package/dist/packem_shared/readManifest-Cighz3WC.mjs +6 -0
- package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
- package/dist/packem_shared/reconcile-services-CjgIJKim.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerBindings-D6B81UKU.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-Cj94osA-.mjs +1 -0
- package/dist/packem_shared/renderStudioHtml-CRDTNivi.mjs +15 -0
- package/dist/packem_shared/resolveLocalWorkerEnv-C1s-quRt.mjs +1 -0
- package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
- package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
- package/dist/packem_shared/scanWranglerVariablesForSecrets-DmdOBmwn.mjs +1 -0
- package/dist/packem_shared/secret-key-xi4VK8Jw.mjs +1 -0
- package/dist/packem_shared/sendStudioAsset-B81Pex91.mjs +1 -0
- package/dist/packem_shared/serveJsonHandler-B8_GE6QC.mjs +1 -0
- package/dist/packem_shared/spa-assets-wX8rTPEQ.mjs +1 -0
- package/dist/packem_shared/startCelldDevSession-DfuDVsha.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
- package/dist/packem_shared/studio-assets-BKWx838V.mjs +1 -0
- package/dist/packem_shared/validate-bindings-DSMH8bRQ.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-BXOIqXxv.mjs +1 -0
- package/dist/packem_shared/wranglerCodegenInputs-B8iRZZZw.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-ClIdvJFu.mjs +5 -0
- package/dist/packem_shared/write-atomic-9sY2z8DB.mjs +3 -0
- package/dist/packem_shared/writeAssetHeaders-C5igmezc.mjs +1 -0
- package/dist/studio-host/index.d.mts +371 -136
- package/dist/studio-host/index.d.ts +371 -136
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +43 -10
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_MODE_ENV-DM1Siczo.mjs +0 -17
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +0 -163
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
- package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
- package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-8bNMHGiu.mjs +0 -104
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
- package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
- package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
- package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
- package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +0 -72
- package/dist/packem_shared/buildPackageSecretsBlock-B8iSX1Zo.mjs +0 -281
- package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
- package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
- package/dist/packem_shared/detectFramework-U08038Yp.mjs +0 -41
- package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
- package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
- package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
- package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
- package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
- package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
- package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
- package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const CORE_SECRETS = [
|
|
2
|
-
{
|
|
3
|
-
description: "Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",
|
|
4
|
-
docsUrl: "https://lunora.sh/docs/packages/studio",
|
|
5
|
-
key: "LUNORA_ADMIN_TOKEN",
|
|
6
|
-
placeholderValue: "replace-with-openssl-rand-hex-32"
|
|
7
|
-
}
|
|
8
|
-
];
|
|
9
|
-
const PACKAGE_SECRETS_REGISTRY = {
|
|
10
|
-
"@lunora/auth": [
|
|
11
|
-
{
|
|
12
|
-
description: "32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",
|
|
13
|
-
docsUrl: "https://lunora.sh/docs/packages/auth#secrets",
|
|
14
|
-
key: "AUTH_SECRET",
|
|
15
|
-
placeholderValue: "replace-with-openssl-rand-hex-32"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
description: "Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",
|
|
19
|
-
docsUrl: "https://lunora.sh/docs/packages/auth#secrets",
|
|
20
|
-
key: "AUTH_URL",
|
|
21
|
-
placeholderValue: "http://localhost:8787"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"@lunora/mail": [
|
|
25
|
-
{
|
|
26
|
-
description: "Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",
|
|
27
|
-
docsUrl: "https://lunora.sh/docs/packages/mail#secrets",
|
|
28
|
-
key: "RESEND_API_KEY",
|
|
29
|
-
placeholderValue: "<your-resend-api-key>"
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"@lunora/payment": [
|
|
33
|
-
{
|
|
34
|
-
description: "Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",
|
|
35
|
-
docsUrl: "https://lunora.sh/docs/packages/payment#stripe",
|
|
36
|
-
key: "STRIPE_SECRET_KEY",
|
|
37
|
-
placeholderValue: "<your-stripe-secret-key>"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
description: "Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",
|
|
41
|
-
docsUrl: "https://lunora.sh/docs/packages/payment#stripe",
|
|
42
|
-
key: "STRIPE_WEBHOOK_SECRET",
|
|
43
|
-
placeholderValue: "<your-stripe-webhook-secret>"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
description: "Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",
|
|
47
|
-
docsUrl: "https://lunora.sh/docs/packages/payment#polar",
|
|
48
|
-
key: "POLAR_ACCESS_TOKEN",
|
|
49
|
-
placeholderValue: "<your-polar-access-token>"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
description: "Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",
|
|
53
|
-
docsUrl: "https://lunora.sh/docs/packages/payment#polar",
|
|
54
|
-
key: "POLAR_WEBHOOK_SECRET",
|
|
55
|
-
placeholderValue: "<your-polar-webhook-secret>"
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
};
|
|
59
|
-
const secretsForPackages = (packageNames) => {
|
|
60
|
-
const result = [];
|
|
61
|
-
for (const name of packageNames) {
|
|
62
|
-
const entries = PACKAGE_SECRETS_REGISTRY[name];
|
|
63
|
-
if (entries !== void 0) {
|
|
64
|
-
result.push(...entries);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export { CORE_SECRETS, PACKAGE_SECRETS_REGISTRY, secretsForPackages };
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync, renameSync } 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
|
-
|
|
7
|
-
const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
|
|
8
|
-
const statusForFailure = (reason) => {
|
|
9
|
-
if (reason === "unknown-procedure") {
|
|
10
|
-
return 404;
|
|
11
|
-
}
|
|
12
|
-
if (reason === "already-wired") {
|
|
13
|
-
return 409;
|
|
14
|
-
}
|
|
15
|
-
return reason === "destructive" ? 409 : 422;
|
|
16
|
-
};
|
|
17
|
-
const writeAtomic = (path, text) => {
|
|
18
|
-
const temporaryPath = `${path}.lunora-tmp`;
|
|
19
|
-
writeFileSync(temporaryPath, text, "utf8");
|
|
20
|
-
renameSync(temporaryPath, path);
|
|
21
|
-
};
|
|
22
|
-
const runCodegenForResponse = (request, okBody) => {
|
|
23
|
-
let diagnostics = [];
|
|
24
|
-
try {
|
|
25
|
-
runCodegen({ lunoraDirectory: request.schemaDirectory ?? "lunora", projectRoot: request.projectRoot });
|
|
26
|
-
} catch (error) {
|
|
27
|
-
if (error instanceof CodegenDiagnosticError) {
|
|
28
|
-
diagnostics = [error.message];
|
|
29
|
-
} else {
|
|
30
|
-
return { body: { error: error instanceof Error ? error.message : String(error), ok: false }, status: 500 };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return { body: { ...okBody, diagnostics, ok: true }, status: 200 };
|
|
34
|
-
};
|
|
35
|
-
const refuseDestructive = (edit) => {
|
|
36
|
-
return {
|
|
37
|
-
body: {
|
|
38
|
-
edit,
|
|
39
|
-
message: "Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",
|
|
40
|
-
needsManualEdit: true,
|
|
41
|
-
ok: false
|
|
42
|
-
},
|
|
43
|
-
status: 409
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const handleScaffoldPolicy = (request, edit) => {
|
|
47
|
-
const result = scaffoldPolicyFile(edit);
|
|
48
|
-
if (!result.ok) {
|
|
49
|
-
return { body: { error: result.reason, ok: false }, status: statusForFailure(result.reason) };
|
|
50
|
-
}
|
|
51
|
-
const lunoraDirectory = request.schemaDirectory ?? "lunora";
|
|
52
|
-
const targetPath = join(request.projectRoot, lunoraDirectory, result.fileName);
|
|
53
|
-
if (existsSync(targetPath)) {
|
|
54
|
-
return { body: { error: "file-exists", fileName: result.fileName, ok: false }, status: 409 };
|
|
55
|
-
}
|
|
56
|
-
writeAtomic(targetPath, result.source);
|
|
57
|
-
return runCodegenForResponse(request, { fileName: result.fileName });
|
|
58
|
-
};
|
|
59
|
-
const resolveProcedureFile = (projectRoot, lunoraDirectory, filePath) => {
|
|
60
|
-
if (typeof filePath !== "string" || filePath.length === 0 || isAbsolute(filePath) || filePath.includes("\\")) {
|
|
61
|
-
return void 0;
|
|
62
|
-
}
|
|
63
|
-
const lunoraRoot = join(projectRoot, lunoraDirectory);
|
|
64
|
-
const resolved = join(lunoraRoot, `${filePath}.ts`);
|
|
65
|
-
const relativePath = relative(lunoraRoot, resolved);
|
|
66
|
-
if (relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
67
|
-
return void 0;
|
|
68
|
-
}
|
|
69
|
-
return resolved;
|
|
70
|
-
};
|
|
71
|
-
const handleWireRls = (request, edit) => {
|
|
72
|
-
const procedurePath = resolveProcedureFile(request.projectRoot, request.schemaDirectory ?? "lunora", edit.filePath);
|
|
73
|
-
if (procedurePath === void 0 || !existsSync(procedurePath)) {
|
|
74
|
-
return { body: { error: "unknown-procedure", ok: false }, status: 404 };
|
|
75
|
-
}
|
|
76
|
-
const wired = wireRlsIntoProcedure(readFileSync(procedurePath, "utf8"), edit);
|
|
77
|
-
if (!wired.ok) {
|
|
78
|
-
return { body: { error: wired.reason, ok: false }, status: statusForFailure(wired.reason) };
|
|
79
|
-
}
|
|
80
|
-
writeAtomic(procedurePath, wired.text);
|
|
81
|
-
return runCodegenForResponse(request, { exportName: edit.exportName });
|
|
82
|
-
};
|
|
83
|
-
const handlePolicyScaffoldRequest = (request) => {
|
|
84
|
-
if (request.method !== "POST") {
|
|
85
|
-
return { body: { error: "method-not-allowed", ok: false }, status: 405 };
|
|
86
|
-
}
|
|
87
|
-
const { body } = request;
|
|
88
|
-
if (body === void 0 || typeof body !== "object" || typeof body.kind !== "string") {
|
|
89
|
-
return { body: { error: "invalid-edit", ok: false }, status: 400 };
|
|
90
|
-
}
|
|
91
|
-
const edit = body;
|
|
92
|
-
if (classifyPolicyEdit(edit) === "destructive") {
|
|
93
|
-
return refuseDestructive(edit);
|
|
94
|
-
}
|
|
95
|
-
if (edit.kind === "scaffoldPolicy") {
|
|
96
|
-
return handleScaffoldPolicy(request, edit);
|
|
97
|
-
}
|
|
98
|
-
if (edit.kind === "wireRls") {
|
|
99
|
-
return handleWireRls(request, edit);
|
|
100
|
-
}
|
|
101
|
-
throw new LunoraError("INTERNAL", `unhandled additive policy edit kind: ${String(edit.kind)}`);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { writeFileSync, rmSync } from 'node:fs';
|
|
2
|
-
import { modify, applyEdits } from 'jsonc-parser';
|
|
3
|
-
import { findWranglerFile, readWranglerJsonc } from './WRANGLER_FILES-DwSuC-Kn.mjs';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
|
|
6
|
-
const FORMATTING = { formattingOptions: { insertSpaces: true, tabSize: 4 } };
|
|
7
|
-
const REMOTE_ELIGIBLE_KEYS = {
|
|
8
|
-
ai: { label: "AI", shape: "object" },
|
|
9
|
-
d1_databases: { label: "D1", shape: "array" },
|
|
10
|
-
kv_namespaces: { label: "KV", shape: "array" },
|
|
11
|
-
queues: { label: "Queue", shape: "producers" },
|
|
12
|
-
r2_buckets: { label: "R2", shape: "array" },
|
|
13
|
-
services: { label: "Service", shape: "array" },
|
|
14
|
-
vectorize: { label: "Vectorize", shape: "array" }
|
|
15
|
-
};
|
|
16
|
-
const REMOTE_ELIGIBLE_KEY_LIST = Object.keys(REMOTE_ELIGIBLE_KEYS);
|
|
17
|
-
const entryName = (entry, fallback) => typeof entry.binding === "string" ? entry.binding : fallback;
|
|
18
|
-
const planArrayEntries = (section, entries, kind, pathPrefix) => {
|
|
19
|
-
const plans = [];
|
|
20
|
-
for (const [index, entry] of entries.entries()) {
|
|
21
|
-
if (entry === null || entry === void 0) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
plans.push({ binding: entryName(entry, `#${String(index)}`), kind, path: [...pathPrefix, index], section });
|
|
25
|
-
}
|
|
26
|
-
return plans;
|
|
27
|
-
};
|
|
28
|
-
const planSection = (section, parsed) => {
|
|
29
|
-
const { label, shape } = REMOTE_ELIGIBLE_KEYS[section];
|
|
30
|
-
if (shape === "array") {
|
|
31
|
-
const entries = parsed[section] ?? [];
|
|
32
|
-
return planArrayEntries(section, entries, label, []);
|
|
33
|
-
}
|
|
34
|
-
if (shape === "producers") {
|
|
35
|
-
return planArrayEntries(section, parsed.queues?.producers ?? [], label, ["producers"]);
|
|
36
|
-
}
|
|
37
|
-
const entry = parsed.ai;
|
|
38
|
-
return entry === null || entry === void 0 ? [] : [{ binding: entryName(entry, section), kind: label, path: [], section }];
|
|
39
|
-
};
|
|
40
|
-
const planRemoteBindings = (parsed) => REMOTE_ELIGIBLE_KEY_LIST.flatMap((section) => planSection(section, parsed));
|
|
41
|
-
const applyModify = (text, path, value) => {
|
|
42
|
-
const edits = modify(text, [...path], value, FORMATTING);
|
|
43
|
-
return edits.length > 0 ? applyEdits(text, edits) : text;
|
|
44
|
-
};
|
|
45
|
-
const injectRemoteFlags = (text, plans) => {
|
|
46
|
-
let next = text;
|
|
47
|
-
for (const plan of plans) {
|
|
48
|
-
next = applyModify(next, [plan.section, ...plan.path, "remote"], true);
|
|
49
|
-
}
|
|
50
|
-
return next;
|
|
51
|
-
};
|
|
52
|
-
const noopCleanup = () => {
|
|
53
|
-
};
|
|
54
|
-
const createCleanup = (path) => {
|
|
55
|
-
let done = false;
|
|
56
|
-
return () => {
|
|
57
|
-
if (done) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
done = true;
|
|
61
|
-
try {
|
|
62
|
-
rmSync(path, { force: true, recursive: true });
|
|
63
|
-
} catch {
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const remoteConfigBasename = () => `.wrangler.lunora-remote.${String(process.pid)}.jsonc`;
|
|
68
|
-
const materializeRemoteWranglerConfig = (options) => {
|
|
69
|
-
if (!options.enabled) {
|
|
70
|
-
return { cleanup: noopCleanup, enabled: false, remoteBindings: [] };
|
|
71
|
-
}
|
|
72
|
-
const wranglerPath = findWranglerFile(options.projectRoot);
|
|
73
|
-
if (!wranglerPath) {
|
|
74
|
-
return { cleanup: noopCleanup, enabled: true, reason: "wrangler.jsonc not found", remoteBindings: [] };
|
|
75
|
-
}
|
|
76
|
-
const { parsed, text } = readWranglerJsonc(wranglerPath);
|
|
77
|
-
if (parsed === void 0) {
|
|
78
|
-
return { cleanup: noopCleanup, enabled: true, reason: `failed to parse ${wranglerPath} as JSONC`, remoteBindings: [] };
|
|
79
|
-
}
|
|
80
|
-
const plans = planRemoteBindings(parsed);
|
|
81
|
-
if (plans.length === 0) {
|
|
82
|
-
return { cleanup: noopCleanup, enabled: true, reason: "no remote-eligible bindings to proxy", remoteBindings: [] };
|
|
83
|
-
}
|
|
84
|
-
const configPath = join(options.projectRoot, remoteConfigBasename());
|
|
85
|
-
writeFileSync(configPath, injectRemoteFlags(text, plans), "utf8");
|
|
86
|
-
return { cleanup: createCleanup(configPath), configPath, enabled: true, remoteBindings: plans };
|
|
87
|
-
};
|
|
88
|
-
const isRemoteEnvEnabled = (value) => {
|
|
89
|
-
if (value === void 0) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
const normalized = value.trim().toLowerCase();
|
|
93
|
-
return normalized === "1" || normalized === "true";
|
|
94
|
-
};
|
|
95
|
-
const resolveRemoteEnabled = (inputs) => {
|
|
96
|
-
if (inputs.flag === true) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
if (isRemoteEnvEnabled(inputs.envValue)) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
return inputs.configPreference ?? false;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { REMOTE_ELIGIBLE_KEYS, injectRemoteFlags, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, resolveRemoteEnabled };
|