@lunora/config 1.0.0-alpha.46 → 1.0.0-alpha.461
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/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 +1492 -0
- package/dist/cloudflare/index.d.ts +1492 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +1076 -975
- package/dist/index.d.ts +1076 -975
- package/dist/index.mjs +1 -23
- 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/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-CAJl2nEI.mjs +1 -0
- package/dist/packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs +1 -0
- package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.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-DfNG44Lm.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-D66_hwjD.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BPxR2Ht_.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-CN5_FXGg.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-C1fhrehH.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-o75cnR4-.mjs +1 -0
- package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-Zw1oiigQ.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-tkKAa5zl.mjs +1 -0
- package/dist/packem_shared/assertWranglerSatisfiesSchema-CZWQnfly.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/bindingsNeedingDatabase-3KyGflIq.mjs +3 -0
- package/dist/packem_shared/blockingFindingsMessage-CRbg1sla.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-CpvLkAEg.mjs +3 -0
- package/dist/packem_shared/checkDevEnv-egiW2lSF.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-BYo3bcXi.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-CbyzZjZF.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-6iinmRWE.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/guards-CoCtgpeR.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-Biq1OW9V.mjs +1 -0
- package/dist/packem_shared/is-plain-object-CWxHeOY1.mjs +1 -0
- package/dist/packem_shared/materializeServiceDevConfigs-CI1HXv7f.mjs +1 -0
- package/dist/packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs +1 -0
- package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
- package/dist/packem_shared/pendingBindingChanges-5fPhwxMt.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-D7mXDfAe.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/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
- package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
- package/dist/packem_shared/scanWranglerVariablesForSecrets-BQIPpHpH.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/startCelldDevSession-DQ7YylR_.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
- package/dist/packem_shared/validate-bindings-CQbR23li.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-CKXL6P6s.mjs +1 -0
- package/dist/packem_shared/worker-entry-checks-DH-ApvvX.mjs +1 -0
- package/dist/packem_shared/wranglerCodegenInputs-Cty6-8es.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
- package/dist/packem_shared/write-atomic-C_tVwH0p.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 +35 -9
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- 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-Br-BcPBq.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
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
export { AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, LUNORA_SKILL_NAMES, ROOT_SKILL_NAME, claimAgentRulesHint, detectAgentRules } from './packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs';
|
|
2
|
-
export { discoverContainerInfo } from './packem_shared/discoverContainerInfo-BXFs6Wav.mjs';
|
|
3
|
-
export { streamContainerLogs } from './packem_shared/streamContainerLogs-BZ4cOZwH.mjs';
|
|
4
|
-
export { detectFramework } from './packem_shared/detectFramework-Br-BcPBq.mjs';
|
|
5
|
-
export { DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, parseDevVariableEntries } from './packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
|
|
6
|
-
export { inferLunoraBindings, packageNamesFromBindings } from './packem_shared/inferLunoraBindings-ByMwG-gH.mjs';
|
|
7
|
-
export { LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, readLinkedProject, writeLinkedProject } from './packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs';
|
|
8
|
-
export { LUNORA_EVENT_SOURCE, formatLunoraEvent } from './packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs';
|
|
9
|
-
export { default as LunoraReporter } from './packem_shared/LunoraReporter-Ci-bDCK9.mjs';
|
|
10
|
-
export { PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs';
|
|
11
|
-
export { LUNORA_CONFIG_FILE, interpretRemote, readProjectRemotePreference } from './packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs';
|
|
12
|
-
export { createConfirm, isInteractive, promptMultiSelect, promptSelect, promptYesNo } from './packem_shared/createConfirm-fvpdgJ9s.mjs';
|
|
13
|
-
export { reconcileWranglerBindings } from './packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs';
|
|
14
|
-
export { REMOTE_ELIGIBLE_KEYS, injectRemoteFlags, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, resolveRemoteEnabled } from './packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs';
|
|
15
|
-
export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVarsExample, fillDevSecrets, generateSecretValue, isMintableSecretKey, isPlaceholderValue, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, requiredSecrets } from './packem_shared/buildPackageSecretsBlock-B8iSX1Zo.mjs';
|
|
16
|
-
export { applyAdditiveEdit, classifyEdit } from './packem_shared/applyAdditiveEdit-C-snTFEV.mjs';
|
|
17
|
-
export { parseSchema } from './packem_shared/parseSchema-DSeyktvG.mjs';
|
|
18
|
-
export { classifyPolicyEdit, scaffoldPolicyFile, wireRlsIntoProcedure } from './packem_shared/classifyPolicyEdit-BHeAqF8P.mjs';
|
|
19
|
-
export { discoverSchemaInfo } from './packem_shared/discoverSchemaInfo-BB-CKlTK.mjs';
|
|
20
|
-
export { ACCENT, BADGES, BADGE_COLUMN_WIDTH, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, STEP_BADGE_NAMES, badgeLead, badgeWidth, padBadge, paintAnswer, paintBadge } from './packem_shared/ACCENT-DW1XJn8i.mjs';
|
|
21
|
-
export { discoverWorkflowInfo } from './packem_shared/discoverWorkflowInfo-CedvR0mn.mjs';
|
|
22
|
-
export { WRANGLER_FILES, findWranglerFile, readWranglerJsonc } from './packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs';
|
|
23
|
-
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer } from './packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs';
|
|
1
|
+
import{AGENT_MODE_ENV as o,detectAiAgent as t}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-pqFMJBtJ.mjs";import{AGENT_RULES_DIR as s,AGENT_RULES_HINT as n,AGENT_RULES_HINT_ENV as _,LUNORA_SKILL_NAMES as c,ROOT_SKILL_NAME as l,claimAgentRulesHint as p,detectAgentRules as D}from"./packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs";import{clearApiSpecMarker as A,readApiSpecMarker as m,writeApiSpecMarker as f}from"./packem_shared/clearApiSpecMarker-DMGpP41V.mjs";import{MissingBuildOutputError as L}from"./packem_shared/MissingBuildOutputError-BAyekzof.mjs";import{default as N}from"./packem_shared/canonicalPath-DrfMiT3U.mjs";import{probeCelldToolchain as T}from"./packem_shared/probeCelldToolchain-DxDttfHy.mjs";import{startCelldDevSession as g,writeCelldDevProjection as V}from"./packem_shared/startCelldDevSession-DQ7YylR_.mjs";import{D1_PLACEHOLDER_ID as u}from"./packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{BUILD_ROOT_ENV as P,BUILD_TARGET_ENV as C,BUNDLE_META_PATH_ENV as F,CODEGEN_ENV as M,DEFAULT_BUNDLE_META_PATH as U,LAZY_FUNCTIONS_ENV as B,STRICT_ADVISORIES_ENV as G,isCodegenDisabled as b,isLazyFunctionsEnabled as y,resolveLazyFunctions as k}from"./packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{discoverContainerInfo as w}from"./packem_shared/discoverContainerInfo-DzXr7Vm3.mjs";import{streamContainerLogs as H}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as W,projectUsesUmbrella as Y}from"./packem_shared/detectFramework-Dfpvu6rD.mjs";import{checkDevEnv as z,describeDevEnvCheck as q}from"./packem_shared/checkDevEnv-egiW2lSF.mjs";import{acceptsConnection as Z,startDevProcess as Q}from"./packem_shared/acceptsConnection-DHhUYGjT.mjs";import{DEV_BINDINGS_FILE as ee,DEV_DAEMON_ENV as re,DEV_HANDOFF_ENV as oe,DEV_LOG_FILE as te,DEV_LOG_FILE_ENV as ae,DEV_STATE_DIR as Ee,DEV_STATE_FILE as ie,claimDevServerState as se,clearDevServerState as ne,isDevServerReady as _e,isProcessAlive as ce,isRecordedProcessCurrent as le,readDevServerState as pe,readLiveDevServerState as De,updateDevServerState as de,writeDevServerState as Ae}from"./packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs";import{devTriggerHints as fe,formatDevBannerRow as Se}from"./packem_shared/devTriggerHints-CN_RJxWW.mjs";import{DEV_VARS_EXAMPLE_FILE as ve,DEV_VARS_FILE as Ne,DEV_VARS_KEY_PATTERN as Re,escapeRegExp as Te,parseDevVariableEntries as xe,readDevVariablesRecord as ge,removeDevVariableLine as Ve,upsertDevVariableLine as Ie,wranglerDotenvFiles as ue}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import{DEV_WORKER_ENV_VALUE as Pe,DEV_WORKER_ENV_VAR as Ce,ensureDevWorkerEnv as Fe}from"./packem_shared/DEV_WORKER_ENV_VALUE-FoysLtF0.mjs";import{createDiscoveryCache as Ue}from"./packem_shared/createDiscoveryCache-npJI4uej.mjs";import{DEFAULT_DEPLOY_TARGET as Ge,deployTargetIds as be,isRunnableTarget as ye,planToolchainInvocation as ke,resolveDeployDriver as he,runnableTargetIds as we,targetRunsOwnDevServer as je}from"./packem_shared/DEFAULT_DEPLOY_TARGET-CAJl2nEI.mjs";import{default as Ke}from"./packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs";import{inferLunoraBindings as Ye,secretSourcesFromBindings as Je}from"./packem_shared/inferLunoraBindings-Biq1OW9V.mjs";import{LINKED_PROJECT_DIR as qe,LINKED_PROJECT_FILE as Xe,readLinkedProject as Ze,writeLinkedProject as Qe}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as er,applyLintIgnores as rr,detectLintTools as or}from"./packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs";import{blockingFindingsMessage as ar,reportCodegenFindings as Er}from"./packem_shared/blockingFindingsMessage-CRbg1sla.mjs";import{LUNORA_EVENT_SOURCE as sr,formatLunoraEvent as nr}from"./packem_shared/LUNORA_EVENT_SOURCE-Cq0oj0_9.mjs";import{LUNORA_TAG as cr,advisoryLine as lr,lunoraLine as pr}from"./packem_shared/LUNORA_TAG-DQTGPqcJ.mjs";import{default as dr}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{addArgsFor as mr,detectInstalledManagers as fr,detectPackageManager as Sr,execArgsFor as Lr,installArgsFor as vr,runScriptArgsFor as Nr,runScriptCommand as Rr,toolchainExecArgs as Tr}from"./packem_shared/addArgsFor-CYZKhNIo.mjs";import{PACKAGE_SECRETS_REGISTRY as gr,mintableSecretKeysFor as Vr,secretsForPackages as Ir}from"./packem_shared/PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs";import{runPostCodegenHook as Or}from"./packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs";import{assertBuildTargetMatches as Cr,interpretRemote as Fr,readProjectRemotePreference as Mr,readProjectTarget as Ur,resolveProjectTarget as Br,resolveTargetOrThrow as Gr}from"./packem_shared/assertBuildTargetMatches-tkKAa5zl.mjs";import{readProjectDependencies as yr,readProjectDependencyNames as kr,readProjectManifest as hr}from"./packem_shared/readProjectDependencies-l3uhUKjo.mjs";import{createConfirm as jr,isInteractive as Hr,promptMultiSelect as Kr,promptSelect as Wr,promptText as Yr,promptYesNo as Jr}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{default as qr}from"./packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs";import{buildPackageSecretsBlock as Zr,ensureDevVariables as Qr,ensureDevVarsExample as $r,fillDevSecrets as eo,generateSecretValue as ro,isMintableSecretKey as oo,isPlaceholderValue as to,planDevSecretsFill as ao,planDevVariablesAugment as Eo,planDevVariablesScaffold as io,requiredSecrets as so,writeDevVariablesFileAtomically as no}from"./packem_shared/buildPackageSecretsBlock-DrSD60vH.mjs";import{applyAdditiveEdit as co,classifyEdit as lo}from"./packem_shared/applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as Do}from"./packem_shared/parseSchema-D1Wbr1qv.mjs";import{classifyPolicyEdit as mo,resolveServerModule as fo,scaffoldPolicyFile as So,wireRlsIntoProcedure as Lo}from"./packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs";import{discoverSchemaInfo as No}from"./packem_shared/discoverSchemaInfo-DRPnqgif.mjs";import{ACCENT as To,BADGES as xo,BADGE_COLUMN_WIDTH as go,LUNA_ART as Vo,LUNA_BUNNY as Io,LUNA_NAME as uo,LUNA_SIGNOFF as Oo,STEP_BADGE_NAMES as Po,badgeLead as Co,badgeWidth as Fo,padBadge as Mo,paintAnswer as Uo,paintBadge as Bo}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{COMPOSED_WORKER_ENTRY as bo,DURABLE_OBJECT_BINDINGS as yo,GENERATED_CLASS_MODULES as ko,GENERATED_MODULE_DURABLE_OBJECTS as ho,MERGED_DURABLE_OBJECTS_MODULE as wo,isMergedProject as jo,isMergedRoleModule as Ho}from"./packem_shared/COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{discoverWorkflowInfo as Wo}from"./packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs";import{ENV_FILENAME as Jo}from"@lunora/codegen";export{To as ACCENT,o as AGENT_MODE_ENV,s as AGENT_RULES_DIR,n as AGENT_RULES_HINT,_ as AGENT_RULES_HINT_ENV,xo as BADGES,go as BADGE_COLUMN_WIDTH,P as BUILD_ROOT_ENV,C as BUILD_TARGET_ENV,F as BUNDLE_META_PATH_ENV,M as CODEGEN_ENV,bo as COMPOSED_WORKER_ENTRY,u as D1_PLACEHOLDER_ID,U as DEFAULT_BUNDLE_META_PATH,Ge as DEFAULT_DEPLOY_TARGET,ee as DEV_BINDINGS_FILE,re as DEV_DAEMON_ENV,oe as DEV_HANDOFF_ENV,te as DEV_LOG_FILE,ae as DEV_LOG_FILE_ENV,Ee as DEV_STATE_DIR,ie as DEV_STATE_FILE,ve as DEV_VARS_EXAMPLE_FILE,Ne as DEV_VARS_FILE,Re as DEV_VARS_KEY_PATTERN,Pe as DEV_WORKER_ENV_VALUE,Ce as DEV_WORKER_ENV_VAR,yo as DURABLE_OBJECT_BINDINGS,Jo as ENV_FILENAME,ko as GENERATED_CLASS_MODULES,ho as GENERATED_MODULE_DURABLE_OBJECTS,B as LAZY_FUNCTIONS_ENV,qe as LINKED_PROJECT_DIR,Xe as LINKED_PROJECT_FILE,Vo as LUNA_ART,Io as LUNA_BUNNY,uo as LUNA_NAME,Oo as LUNA_SIGNOFF,sr as LUNORA_EVENT_SOURCE,er as LUNORA_IGNORED_PATHS,c as LUNORA_SKILL_NAMES,cr as LUNORA_TAG,dr as LunoraReporter,wo as MERGED_DURABLE_OBJECTS_MODULE,L as MissingBuildOutputError,gr as PACKAGE_SECRETS_REGISTRY,l as ROOT_SKILL_NAME,Po as STEP_BADGE_NAMES,G as STRICT_ADVISORIES_ENV,Z as acceptsConnection,mr as addArgsFor,lr as advisoryLine,co as applyAdditiveEdit,rr as applyLintIgnores,Cr as assertBuildTargetMatches,Co as badgeLead,Fo as badgeWidth,ar as blockingFindingsMessage,Zr as buildPackageSecretsBlock,N as canonicalPath,z as checkDevEnv,p as claimAgentRulesHint,se as claimDevServerState,lo as classifyEdit,mo as classifyPolicyEdit,A as clearApiSpecMarker,ne as clearDevServerState,jr as createConfirm,Ue as createDiscoveryCache,be as deployTargetIds,q as describeDevEnvCheck,D as detectAgentRules,t as detectAiAgent,W as detectFramework,fr as detectInstalledManagers,or as detectLintTools,Sr as detectPackageManager,fe as devTriggerHints,E as discoverAgentInfo,w as discoverContainerInfo,No as discoverSchemaInfo,Wo as discoverWorkflowInfo,Qr as ensureDevVariables,$r as ensureDevVarsExample,Fe as ensureDevWorkerEnv,Ke as ensureGitignoreEntries,Te as escapeRegExp,Lr as execArgsFor,eo as fillDevSecrets,Se as formatDevBannerRow,nr as formatLunoraEvent,ro as generateSecretValue,Ye as inferLunoraBindings,vr as installArgsFor,Fr as interpretRemote,b as isCodegenDisabled,_e as isDevServerReady,Hr as isInteractive,y as isLazyFunctionsEnabled,jo as isMergedProject,Ho as isMergedRoleModule,oo as isMintableSecretKey,to as isPlaceholderValue,ce as isProcessAlive,le as isRecordedProcessCurrent,ye as isRunnableTarget,pr as lunoraLine,Vr as mintableSecretKeysFor,Mo as padBadge,Uo as paintAnswer,Bo as paintBadge,xe as parseDevVariableEntries,Do as parseSchema,ao as planDevSecretsFill,Eo as planDevVariablesAugment,io as planDevVariablesScaffold,ke as planToolchainInvocation,T as probeCelldToolchain,Y as projectUsesUmbrella,Kr as promptMultiSelect,Wr as promptSelect,Yr as promptText,Jr as promptYesNo,m as readApiSpecMarker,pe as readDevServerState,ge as readDevVariablesRecord,Ze as readLinkedProject,De as readLiveDevServerState,yr as readProjectDependencies,kr as readProjectDependencyNames,hr as readProjectManifest,Mr as readProjectRemotePreference,Ur as readProjectTarget,Ve as removeDevVariableLine,Er as reportCodegenFindings,so as requiredSecrets,he as resolveDeployDriver,k as resolveLazyFunctions,Br as resolveProjectTarget,qr as resolveSchemaDirectory,fo as resolveServerModule,Gr as resolveTargetOrThrow,Or as runPostCodegenHook,Nr as runScriptArgsFor,Rr as runScriptCommand,we as runnableTargetIds,So as scaffoldPolicyFile,Je as secretSourcesFromBindings,Ir as secretsForPackages,g as startCelldDevSession,Q as startDevProcess,H as streamContainerLogs,je as targetRunsOwnDevServer,Tr as toolchainExecArgs,de as updateDevServerState,Ie as upsertDevVariableLine,Lo as wireRlsIntoProcedure,ue as wranglerDotenvFiles,f as writeApiSpecMarker,V as writeCelldDevProjection,Ae as writeDevServerState,no as writeDevVariablesFileAtomically,Qe as writeLinkedProject};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import o from"@visulima/colorize";const g="#a855f7",e="#0b0b0b",s=["lunora","dir","tmpl","add","deps","git","next"],x={add:{bg:g,fg:e,text:"add"},debug:{bg:"#6b7280",fg:"#f3f4f6",text:"debug"},deps:{bg:g,fg:e,text:"deps"},dir:{bg:g,fg:e,text:"dir"},error:{bg:"#ef4444",fg:e,text:"error"},git:{bg:"#f59e0b",fg:e,text:"git"},info:{bg:"#3b82f6",fg:e,text:"info"},lunora:{bg:"#22c55e",fg:e,text:"lunora"},next:{bg:"#06b6d4",fg:e,text:"next"},success:{bg:"#22c55e",fg:e,text:"ok"},tmpl:{bg:g,fg:e,text:"tmpl"},warn:{bg:"#f59e0b",fg:e,text:"warn"}},c="Luna",i="Safe travels, voyager.",n=String.raw`
|
|
2
|
+
.-"""""-.
|
|
3
|
+
/ (\(\ \
|
|
4
|
+
| ( -.-) |
|
|
5
|
+
\ o(")(") /
|
|
6
|
+
'-._____.-'`,_=n.startsWith(`
|
|
7
|
+
`)?n.slice(1):n,b=6,a=t=>` ${t} `,f=t=>" ".repeat(Math.max(0,b-t.length)),r=b+2,A=t=>r,N=t=>f(t.text)+o.bgHex(t.bg).hex(t.fg).bold(a(t.text)),l=t=>o.dim(t);export{g as ACCENT,x as BADGES,r as BADGE_COLUMN_WIDTH,_ as LUNA_ART,n as LUNA_BUNNY,c as LUNA_NAME,i as LUNA_SIGNOFF,s as STEP_BADGE_NAMES,f as badgeLead,A as badgeWidth,a as padBadge,l as paintAnswer,N as paintBadge};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as a}from"node:fs/promises";import{join as u}from"node:path";const f="/__lunora/advisor-procedures",d="advisor-procedures.json",c=new Set(["action","mutation","query"]),i=new Set(["internal","public"]),l=e=>{if(typeof e!="object"||e===null)return!1;const r=e;return typeof r.exportName=="string"&&typeof r.file=="string"&&c.has(r.kind)&&i.has(r.visibility)&&["usesCaptcha","usesEmailGate","usesMask","usesRateLimit","usesRls"].every(s=>typeof r[s]=="boolean")},E=async e=>{if(e.method!=="GET")return{body:{error:"GET only"},status:405};const r=u(e.projectRoot,e.schemaDirectory??"lunora","_generated",d);let s;try{s=await a(r,"utf8")}catch(t){return t.code==="ENOENT"?{body:{error:"advisor-procedures.json is not generated yet; run `lunora codegen`."},status:404}:(console.error(`@lunora/config: could not read ${r}`,t),{body:{error:"advisor-procedures.json could not be read; see the dev server log."},status:500})}let o;try{o=JSON.parse(s)}catch{return{body:{error:"advisor-procedures.json is not valid JSON; re-run `lunora codegen`."},status:500}}const n=typeof o=="object"&&o!==null?o.procedures:void 0;return Array.isArray(n)?n.every(t=>l(t))?{body:o,status:200}:{body:{error:"advisor-procedures.json has a malformed procedure entry; re-run `lunora codegen`."},status:500}:{body:{error:"advisor-procedures.json has no procedures array; re-run `lunora codegen`."},status:500}};export{f as ADVISOR_PROCEDURES_ENDPOINT,E as handleAdvisorProceduresRequest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{detectAiSession as n}from"@visulima/find-ai-runner";const i="LUNORA_AGENT_MODE",r=o=>{const e=o.trim().toLowerCase();return e==="0"||e==="false"},a=(o=process.env)=>{const e=o[i];if(e!==void 0&&e!=="")return r(e)?void 0:{name:"agent (forced)",variable:i};const t=n(o);return t===void 0?void 0:{name:t.agent,variable:t.signal}};export{i as AGENT_MODE_ENV,a as detectAiAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as s}from"node:fs";import{join as t}from"node:path";import{c as a}from"./process-tree-once-Ou4SfxKM.mjs";const u=".agents/skills",i="LUNORA_RULES_HINT_SHOWN",c=["lunora","lunora-quickstart","lunora-functions","lunora-realtime","lunora-setup-auth","lunora-setup-hyperdrive","lunora-setup-hyperdrive-global","lunora-setup-mail","lunora-setup-scheduler","lunora-setup-storage","lunora-create-package","lunora-migration-helper","lunora-deploy","lunora-performance-audit","lunora-cloudflare-audit"],p="lunora",d="Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.",N=()=>a(i),l=(n,o)=>t(n,u,o,"SKILL.md"),g=n=>{const o=[],r=[];for(const e of c)s(l(n,e))?o.push(e):r.push(e);return{installed:s(l(n,p)),missing:r,present:o}};export{u as AGENT_RULES_DIR,d as AGENT_RULES_HINT,i as AGENT_RULES_HINT_ENV,c as LUNORA_SKILL_NAMES,p as ROOT_SKILL_NAME,N as claimAgentRulesHint,g as detectAgentRules};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const i=e=>{const o=Array.isArray(e)?e[0]:e;return typeof o=="string"?o.trim().toLowerCase():void 0},d=e=>{if(e===void 0||e==="")return!0;const o=e.toLowerCase(),r=o.startsWith("::ffff:")?o.slice(7):o;return r==="::1"?!0:r.startsWith("127.")},a=e=>{if(e===void 0)return;if(e.startsWith("[")){const r=e.indexOf("]");return r===-1?e.slice(1):e.slice(1,r)}const o=e.indexOf(":");return o===-1?e:e.slice(0,o)},c=new Set(["0.0.0.0","127.0.0.1","::1","localhost"]),u=["x-forwarded-for","x-forwarded-host","x-forwarded-proto","forwarded"],n="LUNORA_STUDIO_ALLOW_FORWARDED",l=()=>process.env[n]==="1",f=(e,o)=>{if(!d(e.socket?.remoteAddress??void 0))return"Lunora studio is only available on loopback connections in dev.";const r=a(i(e.headers?.host));if(r!==void 0&&!c.has(r))return"Lunora studio rejects a non-localhost Host header in dev.";const t=u.find(s=>e.headers?.[s]!==void 0);if(t!==void 0&&!l())return o?.warnOnce?.(`[lunora] studio: refusing a request carrying the "${t}" header — this dev server is being reached through a proxy/tunnel (Codespaces, devcontainers, Gitpod, Cloud Workstations, ngrok, and Docker reverse proxies all add this). If this is YOUR trusted dev tunnel, set ${n}=1 to allow it.`),`Lunora studio refuses a proxied request in dev (saw the "${t}" header). If you're intentionally running behind a trusted dev tunnel/proxy (e.g. Codespaces, devcontainers, Gitpod, ngrok), set ${n}=1 to allow it.`};export{n as ALLOW_FORWARDED_ENV,i as headerValue,d as isLoopbackAddress,f as transportRejectionReason};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const B=1,N=new Set(["$schema","account_id","compatibility_date","compatibility_flags","keep_vars","main","migrations","minify","name","observability","placement","routes","rules","secrets","triggers","upload_source_maps","vars","workers_dev"]),q=e=>Object.fromEntries(Object.entries(e).filter(([,i])=>i!==void 0)),K=[{bindingKey:"binding",field:"ai_search",resourceKey:"instance_name",type:"ai_search"},{bindingKey:"binding",field:"ai_search_namespaces",resourceKey:"namespace",type:"ai_search_namespace"},{bindingKey:"binding",field:"analytics_engine_datasets",resourceKey:"dataset",type:"analytics_engine"},{bindingKey:"binding",field:"artifacts",resourceKey:"namespace",type:"artifacts"},{bindingKey:"class_name",field:"containers",resourceKey:"image",type:"container"},{bindingKey:"binding",field:"d1_databases",resourceIdKey:"database_id",resourceKey:"database_name",type:"d1"},{bindingKey:"binding",field:"hyperdrive",resourceIdKey:"id",type:"hyperdrive"},{bindingKey:"binding",field:"kv_namespaces",resourceIdKey:"id",type:"kv"},{bindingKey:"binding",field:"pipelines",resourceKey:["stream","pipeline"],type:"pipeline"},{bindingKey:"binding",field:"r2_buckets",resourceKey:"bucket_name",type:"r2"},{bindingKey:"binding",field:"services",resourceKey:"service",type:"service"},{bindingKey:"binding",field:"vectorize",resourceKey:"index_name",type:"vectorize"},{bindingKey:"binding",field:"vpc_networks",resourceIdKey:["tunnel_id","network_id"],type:"vpc_network"},{bindingKey:"binding",field:"vpc_services",resourceIdKey:"service_id",type:"vpc_service"},{bindingKey:"binding",field:"workflows",resourceKey:"name",type:"workflow"}],w=[{field:"ai",type:"ai"},{field:"analytics",type:"analytics_sql"},{field:"assets",type:"assets"},{field:"browser",type:"browser"},{field:"images",type:"images"},{field:"media",type:"media"},{field:"stream",type:"stream"}],S=new Set([...K.map(e=>e.field),...w.map(e=>e.field),"durable_objects","exports","queues"]),u=(e,i)=>(typeof i=="string"?[i]:i??[]).map(n=>e[n]).find(n=>typeof n=="string"&&n!==""),b=(e,i,t,n)=>{const s=u(e,i);if(s!==void 0)return{name:s,wrongType:!1};const o=(typeof i=="string"?[i]:i??[]).find(r=>{const c=e[r];return c!=null&&typeof c!="string"});return o!==void 0&&n.add(`${t}.${o}`),{wrongType:o!==void 0}},_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),g=(e,i,t)=>{if(e==null)return[];if(!Array.isArray(e))return t.add(i),[];const n=e.filter(s=>_(s));return n.length!==e.length&&t.add(i),n},f=(e,i,t)=>{if(e==null)return[];if(!Array.isArray(e))return t.add(i),[];const n=e.filter(s=>typeof s=="string");return n.length!==e.length&&t.add(i),n},p=(e,i,t)=>_(e)?e:(e!=null&&t.add(i),{}),v=(e,i,t)=>{if(typeof e=="string")return e;e!=null&&t.add(i)},O=(e,i,t)=>{const n=[];for(const s of K)for(const o of g(e[s.field],s.field,t)){const{name:r,wrongType:c}=b(o,s.bindingKey,s.field,t);if(!c){if(r===void 0){i.push(s.field);continue}n.push({binding:r,className:u(o,"class_name"),resource:u(o,s.resourceKey),resourceId:u(o,s.resourceIdKey),type:s.type})}}return n},j=(e,i,t)=>{const n=new Set(g(e.migrations,"migrations",t).flatMap(r=>f(r.new_sqlite_classes,"migrations.new_sqlite_classes",t))),s=p(e.durable_objects,"durable_objects",t),o=[];for(const r of g(s.bindings,"durable_objects.bindings",t)){const{name:c,wrongType:y}=b(r,"name","durable_objects.bindings",t);if(y)continue;if(c===void 0){i.push("durable_objects");continue}const l=u(r,"class_name");o.push({binding:c,className:l,sqlite:r.script_name===void 0&&l!==void 0?n.has(l):void 0,type:"durable_object"})}return o},T=(e,i,t)=>{const n=p(e.queues,"queues",t),s=[];for(const o of g(n.producers,"queues.producers",t)){const{name:r,wrongType:c}=b(o,"binding","queues.producers",t);if(!c){if(r===void 0){i.push("queues.producers");continue}s.push({binding:r,resource:u(o,"queue"),type:"queue_producer"})}}for(const o of g(n.consumers,"queues.consumers",t)){const{name:r,wrongType:c}=b(o,"queue","queues.consumers",t);if(!c){if(r===void 0){i.push("queues.consumers");continue}s.push({binding:r,resource:r,type:"queue_consumer"})}}return s},A=(e,i,t)=>Object.entries(p(e.exports,"exports",t)).flatMap(([n,s])=>!_(s)||s.type!=="workflow"?(i.push(`exports.${n}`),[]):[{binding:n,className:n,resource:u(s,"name"),type:"workflow"}]),E=(e,i)=>w.flatMap(t=>{const{binding:n}=p(e[t.field],t.field,i);return n===void 0?[]:typeof n!="string"?(i.add(`${t.field}.binding`),[]):[{binding:n,type:t.type}]}),k=(e,i,t,n)=>[...A(e,t,n),...O(e,i,n),...j(e,i,n),...T(e,i,n),...E(e,n)],D=e=>{const i=[],t=[],n=new Set,s=p(e,"(wrangler config)",n),o=k(s,i,t,n).map(d=>q(d)).toSorted((d,a)=>d.type.localeCompare(a.type)||d.binding.localeCompare(a.binding)),r=[...Object.keys(s).filter(d=>!N.has(d)&&!S.has(d)),...i.map(d=>`${d} (entry with no binding name)`),...t].toSorted((d,a)=>d.localeCompare(a)),c=v(s.compatibility_date,"compatibility_date",n),y=s.compatibility_flags,l=y==null?void 0:f(y,"compatibility_flags",n),h=f(p(s.triggers,"triggers",n).crons,"triggers.crons",n),m=v(s.name,"name",n),I=Object.keys(p(s.vars,"vars",n)).toSorted((d,a)=>d.localeCompare(a));return{bindings:o,...c===void 0?{}:{compatibilityDate:c},...l===void 0?{}:{compatibilityFlags:l},crons:h,malformed:[...n].toSorted((d,a)=>d.localeCompare(a)),...m===void 0?{}:{name:m},unknown:r,vars:I,version:1}};export{B as BINDING_MANIFEST_VERSION,D as buildBindingManifest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join as _}from"node:path";const E="LUNORA_CODEGEN",N="LUNORA_STRICT_ADVISORIES",t="LUNORA_LAZY_FUNCTIONS",L="LUNORA_BUILD_ROOT",A="LUNORA_BUILD_TARGET",T="LUNORA_BUNDLE_META_PATH",r=_(".lunora","vite-bundle-meta.json"),O=o=>{const n=o?.trim().toLowerCase();return n==="0"||n==="false"},s=o=>{const n=o?.trim().toLowerCase();return n==="1"||n==="true"},U=o=>o===!0||s(process.env[t]);export{L as BUILD_ROOT_ENV,A as BUILD_TARGET_ENV,T as BUNDLE_META_PATH_ENV,E as CODEGEN_ENV,r as DEFAULT_BUNDLE_META_PATH,t as LAZY_FUNCTIONS_ENV,N as STRICT_ADVISORIES_ENV,O as isCodegenDisabled,s as isLazyFunctionsEnabled,U as resolveLazyFunctions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as c}from"node:fs";import{join as t,basename as f}from"node:path";import{i as l,c as d}from"./process-tree-once-Ou4SfxKM.mjs";import{findWranglerFile as u}from"./WRANGLER_FILES-BF8PUjuo.mjs";const m=["cloudflare.config.ts","cloudflare.config.mts","cloudflare.config.js","cloudflare.config.mjs"],g="https://github.com/anolilab/lunora/issues/964",s="LUNORA_CF_CONFIG_WARNING_SHOWN",C=o=>{const n=m.find(a=>c(t(o,a)));if(n===void 0)return;const e=u(o),r=e===void 0?void 0:f(e),i=r===void 0?"in the project root":`next to ${r}`;return{fix:`\`cf\` resource commands (zones, DNS, KV, …) are fine. Don't use \`cf dev\` / \`cf build\` / \`cf deploy\` on a Lunora project until Lunora supports \`cf\` — see ${g}.`,message:`${n} found ${i}. Lunora manages ${r??"the wrangler config"} and never updates a Cloudflare CLI (\`cf\`) config, so \`cf dev\` / \`cf build\` / \`cf deploy\` would run from a stale config, silently missing the bindings, Durable Object classes and migrations Lunora adds.`}},I=(o,n)=>{if(l(s))return!1;const e=C(o);return e===void 0||!d(s)?!1:(n(`${e.message} ${e.fix}`),!0)};export{s as CLOUDFLARE_CLI_CONFIG_WARNING_ENV,C as detectCloudflareCliConfig,I as warnCloudflareCliConfigOnce};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const i={devServer:"workerd",prebuildsContainerImages:!0,deploy:o=>{if(o.preview===!0)throw new Error("the Cloudflare driver cannot build a preview upload; deploy an isolated preview with `lunora preview deploy`");const r=["deploy"];return o.entry!==void 0&&r.push(o.entry),o.configPath!==void 0&&r.push("--config",o.configPath),o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),o.dryRun===!0&&r.push("--dry-run"),o.secretsFile!==void 0&&r.push("--secrets-file",o.secretsFile),o.outDir!==void 0&&r.push("--outdir",o.outDir,"--metafile"),o.outFile!==void 0&&r.push("--outfile",o.outFile),{args:r,tool:"wrangler"}},dev:o=>{const r=["dev"];return o.configPath!==void 0&&r.push("--config",o.configPath),o.environment!==void 0&&r.push("--env",o.environment),r.push(...o.extraArgs??[]),{args:r,tool:"wrangler"}},secretList:o=>{const r=["secret","list","--format","json"];return o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretBulk:o=>{const r=["secret","bulk"];return o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretPut:o=>{const r=["secret","put",o.key??""];return o.environment!==void 0&&r.push("--env",o.environment),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},tail:o=>{const r=["tail"];return o.worker!==void 0&&r.push(o.worker),o.environment!==void 0&&r.push("--env",o.environment),o.format!==void 0&&r.push("--format",o.format),o.status!==void 0&&r.push("--status",o.status),o.search!==void 0&&r.push("--search",o.search),o.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}}},n={id:"cloudflare",name:"Cloudflare",toolchain:i};export{n as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"@cloudflare/vite-plugin":"^1.63.1","@cloudflare/workers-types":"^5.20261004.1",wrangler:"^4.156.1"};export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as E,readFileSync as O}from"node:fs";import{parse as u}from"es-module-lexer";import{WRANGLER_FILES as b,readWranglerJsonc as f}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{escapeRegExp as S}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import{join as c}from"node:path";const g="_generated",x=["src/server.ts","src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],h=new Set(["build","coverage","dist",g,"node_modules","out","target"]),w=new Set([".client",".server"]),A=/[/\\]/u,T=t=>{const e=[];for(const r of t.split(A))r===""||r==="."||(r===".."&&e.length>0&&e.at(-1)!==".."?e.pop():e.push(r));return e},L=t=>T(t).slice(0,-1).some(e=>h.has(e)||e.startsWith(".")&&!w.has(e)),i={AdminRevocationDO:"ADMIN_REVOCATIONS",LunoraDO:"SHARD",SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD",ShardRegistryDO:"SHARD_REGISTRY"},l=Object.keys(i),$=t=>Object.hasOwn(i,t),C="virtual:lunora/worker",d=["ShardDO"],J=["adminRevocations","agents","containers","scheduler","shardRegistry","workflows"],R={adminRevocations:"AdminRevocationDO",scheduler:"SchedulerDO",shardRegistry:"ShardRegistryDO"},D="LunoraDO",I=new Set([...d,...Object.values(R)]),N="durableObjects",y=t=>E(c(t,`${N}.ts`)),W=t=>Object.hasOwn(R,t),F=t=>y(t)?[D]:[...d,...Object.entries(R).filter(([e])=>E(c(t,`${e}.ts`))).map(([,e])=>e)],B=t=>t.includes(D)?t.filter(e=>!I.has(e)):[...t],U="src/worker.ts",Y=t=>{for(const e of b){const r=c(t,e);if(!E(r))continue;const{parsed:s}=f(r),o=s?.main;if(o===C)return{composed:!0};const a=c(t,U);if(E(a))return{composed:!1,path:a};if(typeof o=="string"&&!L(o)&&E(c(t,o)))return{composed:!1,path:c(t,o)};break}for(const e of x){const r=c(t,e);if(E(r))return{composed:!1,path:r}}return{composed:!1}},v=/(?:^|[\s,{])type$/u,m=(t,e)=>{const r=e.ls>=0?e.ls:e.s;return v.test(t.slice(0,r).trimEnd())},_=(t,e)=>{const r=S(e);return new RegExp(String.raw`\bexport\s+type\s+${r}\b`,"u").test(t)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${r}\b`,"u").test(t)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${r}\b`,"u").test(t)},H=t=>{const e=O(t,"utf8");let r;try{const[,s]=u(e);r=new Set(s.filter(o=>!m(e,o)).map(o=>o.n))}catch{r=new Set(l.filter(s=>new RegExp(String.raw`\bexport\b[^\n;]*\b${s}\b`,"u").test(e)&&!_(e,s)))}return B(l.filter(s=>r.has(s))).map(s=>({binding:i[s],className:s}))},K=(t,e,r)=>{if(e.length===0)return[];if(t.composed)return e.map(n=>({...n,exported:!0}));if(t.path===void 0)return e.map(n=>({...n,exported:!1}));const s=O(t.path,"utf8"),o=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${r}(?:\.js)?["']`).test(s);let a;try{const[,n]=u(s);a=new Set(n.filter(p=>!m(s,p)).map(p=>p.n))}catch{a=new Set(e.map(n=>n.className).filter(n=>new RegExp(String.raw`\bexport\b[^\n;]*\b${S(n)}\b`,"u").test(s)&&!_(s,n)))}return e.map(n=>{const p=o||a.has(n.className);return{...n,exported:p}})};export{d as COMPOSED_ENTRY_DURABLE_OBJECTS,U as COMPOSED_WORKER_ENTRY,i as DURABLE_OBJECT_BINDINGS,J as GENERATED_CLASS_MODULES,g as GENERATED_DIRECTORY,R as GENERATED_MODULE_DURABLE_OBJECTS,C as LUNORA_WORKER_VIRTUAL_ID,D as MERGED_DURABLE_OBJECT,N as MERGED_DURABLE_OBJECTS_MODULE,I as MERGED_ROLE_DURABLE_OBJECTS,h as NON_SOURCE_DIRECTORIES,w as SOURCE_DOT_DIRECTORIES,x as WORKER_ENTRY_FALLBACKS,B as collapseMergedDurableObjects,F as composedEntryDurableObjects,K as detectClassExports,H as detectExportedDurableObjects,$ as isFrameworkDurableObject,L as isGeneratedOutput,y as isMergedProject,W as isMergedRoleModule,Y as resolveWorkerEntry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="<replace-with-d1-create-id>",r="<replace-with-hyperdrive-create-id>";export{e as D1_PLACEHOLDER_ID,r as HYPERDRIVE_PLACEHOLDER_ID};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as a}from"./celld-config-CpvLkAEg.mjs";import s from"./CLOUDFLARE_DRIVER-DbmpoIcg.mjs";const p=[["entry","`celld deploy` deploys the config's `main`; a composed framework entry has no celld equivalent yet"],["environment","celld has no Wrangler environments — deploy a separate config per environment"],["outDir","`celld deploy` does not write its bundle to disk"],["secretsFile","celld has no secret store — a value the app reads from env is a `vars` entry in the deployed config"],["outFile","`celld deploy` does not write its upload artifact to disk"],["preview","celld has no preview versions — a deploy replaces the fleet's current deployment"],["temporary","celld has no short-lived accounts — it deploys to the fleet bucket in CELLD_BUCKET"]],l=e=>{if(e===void 0)throw new Error("the celld driver runs the projected wrangler config — pass `configPath` from `projectConfig`");return e},v={deploy:e=>{const o=p.find(([r])=>e[r]!==void 0&&e[r]!==!1);if(o!==void 0)throw new Error(o[1]);return{args:["deploy",l(e.configPath),...e.dryRun===!0?["--dry-run"]:[]],onPath:!0,tool:"celld"}},devServer:"own",prebuildsContainerImages:!1,dev:e=>{if(e.environment!==void 0)throw new Error("celld has no Wrangler environments — `celld dev` runs the top-level config");return{args:["dev",l(e.configPath),...e.extraArgs??[]],onPath:!0,tool:"celld"}}},f={id:"celld",name:"celld",projectConfig:a,toolchain:v},h={id:"node",name:"Node"},m="cloudflare",t={celld:f,cloudflare:s,node:h},d=()=>Object.keys(t).toSorted((e,o)=>e.localeCompare(o)),i=(e=m)=>{const o=t[e];if(o===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${d().join(", ")}`);return o},g=e=>Object.hasOwn(t,e)&&i(e).toolchain!==void 0,E=()=>d().filter(e=>g(e)),D=e=>i(e).toolchain?.devServer==="own",O=(e,o,r,c)=>{const n=e.projectConfig?.(o,r);return{command:c(n?.configPath),commit:()=>n?.write(),projection:n===void 0?void 0:{configPath:n.configPath,dropped:n.dropped}}};export{m as DEFAULT_DEPLOY_TARGET,d as deployTargetIds,g as isRunnableTarget,O as planToolchainInvocation,i as resolveDeployDriver,E as runnableTargetIds,D as targetRunsOwnDevServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=Object.freeze({enabled:!0,head_sampling_rate:1,redact_query_string:!0}),t=1,l=n=>{const e=n??a;return{logs:{enabled:e.logs?.enabled??e.enabled??a.enabled,headSamplingRate:e.logs?.head_sampling_rate??e.head_sampling_rate??t},traces:{enabled:e.traces?.enabled===!0,headSamplingRate:e.traces?.head_sampling_rate??t}}};export{a as DEFAULT_OBSERVABILITY,l as resolveObservabilitySampling};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{mkdirSync as _,writeFileSync as E,rmSync as N,existsSync as D,readFileSync as a}from"node:fs";import{join as n}from"node:path";const u=".lunora",v=n(u,"dev.json"),h=n(u,"dev.log"),k=n(u,"dev-bindings.json"),T="LUNORA_DEV_DAEMON",U="LUNORA_DEV_LOG_FILE",x="LUNORA_DEV_HANDOFF_PID",m=r=>r!==null&&typeof r=="object",o=(r,e)=>{const t=r[e];return typeof t=="string"&&t.length>0?t:void 0},p=r=>{if(!Number.isInteger(r)||r<=0)return!1;try{return process.kill(r,0),!0}catch{return!1}},y=1e4,g=100,A=r=>{if(process.platform==="linux")try{const e=a(`/proc/${String(r)}/stat`,"utf8"),t=e.slice(e.lastIndexOf(")")+2).split(" "),i=Number(t[19]),s=a("/proc/stat","utf8").split(`
|
|
2
|
+
`).find(l=>l.startsWith("btime ")),d=Number(s?.slice(6));return!Number.isFinite(i)||!Number.isFinite(d)?void 0:d*1e3+i/g*1e3}catch{return}},b=r=>{if(!p(r.pid))return!1;const e=r.startedAt===void 0?Number.NaN:Date.parse(r.startedAt);if(Number.isNaN(e))return!0;const t=A(r.pid);return t===void 0||t<=e+y},f=r=>{const e=n(r,v);if(!D(e))return;let t;try{t=JSON.parse(a(e,"utf8"))}catch{return}if(!m(t)||typeof t.pid!="number")return;const i=o(t,"url");if(i!==void 0)return{background:t.background===!0,logFile:o(t,"logFile"),mode:t.mode==="vite"?"vite":"cli",pid:t.pid,readyAt:o(t,"readyAt"),startedAt:o(t,"startedAt"),studioUrl:o(t,"studioUrl"),tunnelUrl:o(t,"tunnelUrl"),url:i}},c=(r,e)=>{try{_(n(r,u),{recursive:!0});const t=n(r,v);return E(t,`${JSON.stringify(e,void 0,2)}
|
|
3
|
+
`,"utf8"),t}catch{return}},C=(r,e,t)=>{const i=f(r);if(i===void 0||t?.expectedPid!==void 0&&i.pid!==t.expectedPid)return;const s={...i,...e};return c(r,s),s},M=r=>r?.readyAt!==void 0,O=(r,e)=>{try{if(e!==void 0){const t=f(r);if(t!==void 0&&t.pid!==e)return}N(n(r,v),{force:!0})}catch{}},F=r=>{const e=f(r);if(e!==void 0){if(b(e))return e;O(r,e.pid)}},I=(r,e,t)=>{const i=F(r);if(i!==void 0)return t!==void 0&&i.pid===t?{ok:c(r,e)!==void 0}:i.pid!==e.pid?{existing:i,ok:!1}:{ok:c(r,{...e,tunnelUrl:e.tunnelUrl??i.tunnelUrl})!==void 0}},P=(r,e,t)=>{const i=n(r,v),s=`${JSON.stringify(e,void 0,2)}
|
|
4
|
+
`;for(let d=0;d<2;d+=1)try{return _(n(r,u),{recursive:!0}),E(i,s,{encoding:"utf8",flag:"wx"}),{ok:!0}}catch(l){if(l.code!=="EEXIST")return{ok:c(r,e)!==void 0};const S=I(r,e,t?.supersedePid);if(S!==void 0)return S}return{ok:c(r,e)!==void 0}};export{k as DEV_BINDINGS_FILE,T as DEV_DAEMON_ENV,x as DEV_HANDOFF_ENV,h as DEV_LOG_FILE,U as DEV_LOG_FILE_ENV,u as DEV_STATE_DIR,v as DEV_STATE_FILE,P as claimDevServerState,O as clearDevServerState,M as isDevServerReady,p as isProcessAlive,b as isRecordedProcessCurrent,f as readDevServerState,F as readLiveDevServerState,C as updateDevServerState,c as writeDevServerState};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{readFileSync as p}from"node:fs";import{parse as u}from"dotenv";const $=".dev.vars",f=".dev.vars.example",m=/^[A-Za-z_]\w*$/u,A=/\r?\n/u,l=e=>Object.entries(u(e)).map(([r,t])=>({key:r,value:t})),h=e=>{let r;try{r=p(e,"utf8")}catch(t){if(t.code==="ENOENT")return;throw t}return Object.fromEntries(l(r).map(({key:t,value:n})=>[t,n]))},L=e=>e===void 0?[".env",".env.local"]:[".env",".env.local",`.env.${e}`,`.env.${e}.local`],d=e=>l(e)[0],R=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`),V=/(\r?\n)/u,v=(e,r,t)=>{const n=e.split(V),o=[];let a=!1;for(let s=0;s<n.length;s+=2){const c=n[s]??"",i=n[s+1]??"";if(d(c)?.key!==r){o.push(c,i);continue}const E=!a;a=!0,t!==void 0&&E&&o.push(t,i)}return{content:o.join(""),matched:a}},b=(e,r,t)=>{const n=`${r}="${t}"`,o=v(e,r,n);return o.matched?o.content:e===""?`${n}
|
|
2
|
+
`:e.endsWith(`
|
|
3
|
+
`)?`${e}${n}
|
|
4
|
+
`:`${e}
|
|
5
|
+
${n}
|
|
6
|
+
`},N=(e,r)=>v(e,r,void 0).content;export{f as DEV_VARS_EXAMPLE_FILE,$ as DEV_VARS_FILE,m as DEV_VARS_KEY_PATTERN,A as DEV_VARS_NEWLINE,R as escapeRegExp,l as parseDevVariableEntries,d as parseDevVariableLine,h as readDevVariablesRecord,N as removeDevVariableLine,b as upsertDevVariableLine,L as wranglerDotenvFiles};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as l}from"node:fs";import{findWranglerFile as m,readWranglerJsonc as E}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{DEV_VARS_FILE as i,parseDevVariableEntries as V,upsertDevVariableLine as c}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import{writeDevVariablesFileAtomically as p}from"./buildPackageSecretsBlock-DrSD60vH.mjs";import{join as v}from"node:path";const n="WORKER_ENV",a="development",d=e=>{const r=m(e);return r===void 0?{}:E(r).parsed?.vars??{}},W=(e,r)=>{const o=v(e,i);let t;try{t=l(o,"utf8")}catch{return}V(t).some(s=>s.key===n)||n in d(e)||(p(o,c(t,n,a)),r(`set ${n}=${a} in ${i} so the dev worker runs in development mode`))};export{a as DEV_WORKER_ENV_VALUE,n as DEV_WORKER_ENV_VAR,W as ensureDevWorkerEnv};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _="global_fetch_strictly_public";export{_ as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{existsSync as u,readFileSync as f,mkdirSync as k,writeFileSync as m}from"node:fs";import{parse as p}from"jsonc-parser";import{join as i}from"node:path";const l=".lunora",d=i(l,"project.json"),v=r=>r!==null&&typeof r=="object",c=(r,o)=>{const e=r[o];return typeof e=="string"&&e.length>0?e:void 0},j=r=>{const o=i(r,d);if(!u(o))return;let e;try{e=f(o,"utf8")}catch{return}const n=[],t=p(e,n,{allowTrailingComma:!0});if(!(n.length>0||!v(t)))return{account:c(t,"account"),env:c(t,"env"),linkedAt:c(t,"linkedAt"),workerName:c(t,"workerName"),workerUrl:c(t,"workerUrl")}},E=(r,o)=>{const e=i(r,l);k(e,{recursive:!0});const n={};for(const a of["account","env","linkedAt","workerName","workerUrl"]){const s=o[a];s!==void 0&&s!==""&&(n[a]=s)}const t=i(r,d);return m(t,`${JSON.stringify(n,void 0,2)}
|
|
2
|
+
`,"utf8"),t};export{l as LINKED_PROJECT_DIR,d as LINKED_PROJECT_FILE,j as readLinkedProject,E as writeLinkedProject};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const R=t=>{const r=String(t.name),s=String(t.message);return s===""?r:`${r}: ${s}`},u=t=>{if(typeof t=="string")return t;if(t instanceof Error)return R(t);try{return JSON.stringify(t)??String(t)}catch{return String(t)}};const E=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),$=t=>E(t)&&typeof t.name=="string"&&typeof t.message=="string"?t:void 0,m=t=>{let r=t;if(typeof t=="string"){if(!t.startsWith("{")||!t.endsWith("}"))return;try{r=JSON.parse(t)}catch{return}}const s=$(r);return s!==void 0&&(typeof s.stack=="string"||s.cause!==void 0||Array.isArray(s.errors))?s:void 0},d=t=>t.message===""?t.name:`${t.name}: ${t.message}`,A=/^[\w$.]+$/u,_=t=>{if(typeof t.stack!="string")return[];let r=t.stack;const s=t.message===""?-1:r.indexOf(t.message),n=s===-1?"":r.slice(0,s);return s>0&&n.endsWith(": ")&&!n.includes(`
|
|
2
|
+
`)?r=r.slice(s+t.message.length):t.message===""&&A.test(r.split(`
|
|
3
|
+
`,1)[0]??"")&&(r=r.slice((r.split(`
|
|
4
|
+
`,1)[0]??"").length)),r.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(e=>e!=="")},h=(t,r,s=0)=>{const n=`${r} `,e=[d(t),..._(t).map(o=>`${n}${o}`)],i=(o,a)=>{const f=$(a);return f===void 0?`${r}${o}: ${u(a)}`:`${r}${o}: ${s>=4?d(f):h(f,n,s+1).join(`
|
|
6
|
+
`)}`};return Array.isArray(t.errors)&&t.errors.slice(0,10).forEach((o,a)=>{e.push(i(`errors[${String(a)}]`,o))}),t.cause!==void 0&&e.push(i("caused by",t.cause)),e},l=(t,r="")=>t.map(([s,n])=>`${r}${s}: ${h(n,`${r} `).join(`
|
|
7
|
+
`)}`).join(`
|
|
8
|
+
`);const S=t=>{if(typeof t!="string")return t;if(!(!(t.startsWith("{")&&t.endsWith("}"))&&!(t.startsWith("[")&&t.endsWith("]"))))try{return JSON.parse(t)}catch{return}},g=(t,r,s,n)=>{if(n.length>=10||s>=8||typeof t!="object"||t===null)return;const e=m(t);if(e!==void 0){n.push([r,e]);return}if(Array.isArray(t)){t.forEach((i,o)=>{g(i,`${r}[${String(o)}]`,s+1,n)});return}for(const[i,o]of Object.entries(t))g(o,`${r}.${i}`,s+1,n)},O=t=>{if(!E(t))return{errors:[],text:""};const r=[],s=[];for(const[n,e]of Object.entries(t)){const i=m(e);if(i===void 0){s.push(`${n}=${u(e)}`);const o=[];g(S(e),n,0,o),r.push(...o)}else r.push([n,i]),s.push(`${n}=${d(i)}`)}return{errors:r,text:s.join(" ")}},j="lunora",N="__root__",c=t=>typeof t=="string"?t:"",p=t=>Array.isArray(t)?t.filter(r=>typeof r=="string"):[],k=t=>typeof t=="number"&&Number.isFinite(t)?`${String(Math.round(t))}ms`:"?ms",M=t=>t==="error"||t==="fatal"?"error":t==="warn"?"warn":"info",b=t=>{const r=t.trim();if(!r.startsWith("{")||!r.endsWith("}"))return;let s;try{s=JSON.parse(r)}catch{return}if(typeof s!="object"||s===null)return;const n=s;return n.source===j?n:void 0},y=(t,r)=>{const s=c(r.shard);return s===""||s===N?t:`${t}@${s}`},D=(t,r)=>{const s=t.outcome==="error",n=[y(r,t),s?"error":"ok",k(t.durationMs)],e=p(t.tablesRead),i=p(t.tablesWritten);e.length>0&&n.push(`read[${e.join(",")}]`),i.length>0&&n.push(`write[${i.join(",")}]`),t.cacheHit===!0&&n.push("cached");const o=c(t.error);return s&&o!==""&&n.push(o),{kind:"rpc",level:s?"error":"info",text:n.join(" ")}},G=t=>{const r=c(t.container)||"<unknown>",s=c(t.instance),n=c(t.event)||"event",e=s===""||s==="unknown"?"":`#${s.slice(0,8)}`,i=c(t.message),o=[`container:${r}${e}`,n];return i!==""&&o.push(i),{kind:"log",level:t.event==="error"?"error":"info",text:o.join(" ")}},T=t=>{const r=b(t);if(!r)return;const s=c(r.function)||"<unknown>";if(r.type==="log"){const n=[`${y(s,r)} ${c(r.message)}`.trimEnd()],e=O(r.fields);e.text!==""&&n.push(e.text);const i=c(r.traceId);i!==""&&n.push(`trace=${i.slice(0,8)}`);const o=e.errors.length===0?"":`
|
|
9
|
+
${l(e.errors," ")}`;return{kind:"log",level:M(c(r.level)),text:n.join(" ")+o}}if(r.type==="request")return D(r,s);if(r.type==="container")return G(r)};export{j as LUNORA_EVENT_SOURCE,T as formatLunoraEvent};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{existsSync as g,readFileSync as h,writeFileSync as d}from"node:fs";import{join as p,dirname as x}from"node:path";import{parse as v}from"jsonc-parser";import{applyModify as $}from"./applyModify-DKP2l6S9.mjs";import{readProjectDependencyNames as S,readProjectManifest as w}from"./readProjectDependencies-l3uhUKjo.mjs";const c=["lunora/_generated/","lunora/.lunora-schema.json","lunora.advisor.map.json",".lunora/",".wrangler/"],f={biome:{configFiles:["biome.json","biome.jsonc"],packages:["@biomejs/biome"],shadowable:!0},eslint:{configFiles:["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts"],packages:["eslint"],shadowable:!0},oxlint:{configFiles:[".oxlintrc.json"],packages:["oxlint"],shadowable:!0},prettier:{configFiles:[".prettierrc",".prettierrc.json",".prettierrc.js",".prettierrc.mjs",".prettierrc.cjs","prettier.config.js","prettier.config.mjs","prettier.config.cjs"],packages:["prettier"],shadowable:!1}},L=Object.keys(f),y=(e,n)=>f[n].configFiles.map(t=>p(e,t)).find(t=>g(t)),k=(e,n)=>{let t=e;for(;;){const i=y(t,n);if(i!==void 0)return i;if(g(p(t,".git")))return;const s=x(t);if(s===t)return;t=s}},j=(e,n)=>{const t=y(e,n);if(t!==void 0)return{action:"extend",path:t};const i=g(p(e,".git")),s=f[n].shadowable&&!i?k(x(e),n):void 0,[a=""]=f[n].configFiles;return s===void 0?{action:"create",path:p(e,a)}:{action:"report",path:s}},U=e=>{const n=S(e),t=()=>w(e)?.prettier!==void 0;return L.filter(i=>f[i].packages.some(s=>n.has(s))||y(e,i)!==void 0||i==="prettier"&&t())},O="# Lunora generated + derived artifacts",I=e=>{const n=p(e,".prettierignore"),t=g(n)?h(n,"utf8"):void 0,i=t===void 0?[]:t.split(`
|
|
2
|
+
`).map(o=>o.trim()),s=c.filter(o=>!i.includes(o));if(s.length===0)return{path:n,status:t===void 0?"created":"unchanged",tool:"prettier"};const a=`${O}
|
|
3
|
+
${s.join(`
|
|
4
|
+
`)}
|
|
5
|
+
`;return t===void 0?(d(n,a,"utf8"),{path:n,status:"created",tool:"prettier"}):(d(n,`${t.endsWith(`
|
|
6
|
+
`)?t:`${t}
|
|
7
|
+
`}
|
|
8
|
+
${a}`,"utf8"),{path:n,status:"updated",tool:"prettier"})},A=(e,n,t,i)=>{const s=g(e),a=s?h(e,"utf8"):`{}
|
|
9
|
+
`;let r=v(a)??{};for(const l of n)r=r!==null&&typeof r=="object"?r[l]:void 0;const m=Array.isArray(r)?r:[],b=t.filter(l=>!m.includes(l));return b.length===0&&s?{path:e,status:"unchanged",tool:i}:(d(e,$(a,n,[...m,...b]),"utf8"),{path:e,status:s?"updated":"created",tool:i})},F=(e,n)=>`"${e}": [${n.map(t=>`"${t}"`).join(", ")}]`,P=()=>F("files.includes",c.map(e=>`!${e.endsWith("/")?`${e}**`:e}`)),E=e=>{const{action:n,path:t}=j(e,"oxlint");return n==="report"?{path:t,snippet:F("ignorePatterns",c),status:"manual",tool:"oxlint"}:A(t,["ignorePatterns"],c,"oxlint")},T=e=>{const{action:n,path:t}=j(e,"biome");if(n==="report")return{path:t,snippet:P(),status:"manual",tool:"biome"};const i=n==="extend",s=i?h(t,"utf8"):`{}
|
|
10
|
+
`,o=(v(s)??{}).files??{};if(Array.isArray(o.ignore))return A(t,["files","ignore"],c,"biome");const r=Array.isArray(o.includes)?o.includes:[],m=r.length===0?["**"]:r,l=c.map(u=>`!${u.endsWith("/")?`${u}**`:u}`).filter(u=>!r.includes(u));return l.length===0&&i?{path:t,status:"unchanged",tool:"biome"}:(d(t,$(s,["files","includes"],[...m,...l]),"utf8"),{path:t,status:i?"updated":"created",tool:"biome"})},W=()=>`{
|
|
11
|
+
// Lunora generated + derived artifacts.
|
|
12
|
+
ignores: [${c.map(e=>`"${e.endsWith("/")?`${e}**`:e}"`).join(", ")}],
|
|
13
|
+
}`,_=e=>{const{action:n,path:t}=j(e,"eslint"),i=W();if(n!=="create"){const a=h(t,"utf8"),o=c.every(r=>a.includes(r))?"unchanged":"manual";return{path:t,...o==="manual"?{snippet:i}:{},status:o,tool:"eslint"}}const s=p(e,"eslint.config.mjs");return d(s,`// Flat config. Add your own entries alongside the ignores below.
|
|
14
|
+
export default [
|
|
15
|
+
${i.replaceAll(`
|
|
16
|
+
`,`
|
|
17
|
+
`)},
|
|
18
|
+
];
|
|
19
|
+
`,"utf8"),{path:s,status:"created",tool:"eslint"}},C={biome:T,eslint:_,oxlint:E,prettier:I},G=(e,n)=>n.map(t=>{try{return C[t](e)}catch(i){return{message:i instanceof Error?i.message:String(i),path:e,status:"failed",tool:t}}});export{c as LUNORA_IGNORED_PATHS,G as applyLintIgnores,U as detectLintTools};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{paintBadge as r,BADGES as o}from"./ACCENT-CotPTfv7.mjs";const A=r(o.lunora),e=n=>`${A} ${n}`,R={ERROR:o.error,INFO:o.info,WARN:o.warn},s=(n,t,a,i)=>`${r(R[n])} ${t}: ${a} — ${i}`;export{A as LUNORA_TAG,s as advisoryLine,e as lunoraLine};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{paintBadge as d,badgeWidth as g,BADGES as s}from"./ACCENT-CotPTfv7.mjs";const p={informational:"info",warning:"warn"},f=new Set(["alert","critical","emergency","error","warn","warning"]),l=t=>{if(t in s)return s[t];const e=p[t];return e===void 0?void 0:s[e]},m=t=>{if(t instanceof Error)return`
|
|
2
|
+
${t.stack??t.message}`;if(typeof t=="object"&&t!==null)try{return` ${JSON.stringify(t)}`}catch{return" [unserializable]"}return` ${String(t)}`},S=t=>{const e=typeof t.message=="string"?t.message:String(t.message),r=t.context??[];return r.length===0?e:e+r.map(n=>m(n)).join("")};class i{#t=process.stdout;#e=process.stderr;setStdout(e){this.#t=e}setStderr(e){this.#e=e}log(e){const r=e,n=l(r.type.name);(f.has(r.type.level??r.type.name)?this.#e:this.#t).write(i.#r(n,S(r)))}static#r(e,r){if(e===void 0)return`${r}
|
|
3
|
+
`;const[n="",...o]=r.split(`
|
|
4
|
+
`),c=" ".repeat(g()+1);return`${[`${d(e)} ${n}`,...o.map(a=>`${c}${a}`)].join(`
|
|
5
|
+
`)}
|
|
6
|
+
`}}export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class s extends Error{}export{s as MissingBuildOutputError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i}from"./secret-key-xi4VK8Jw.mjs";const p=[{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",docsUrl:"https://lunora.sh/docs/packages/studio",key:"LUNORA_ADMIN_TOKEN",placeholderValue:"replace-with-openssl-rand-hex-32"}],o="LUNORA_RELAY_SECRET",r="replace-with-openssl-rand-hex-32",d=new Set(["@lunora/do:shardRegistry","@lunora/replica:eventLog"]),h="@lunora/replica:eventLogClient",u=["BETTER_AUTH_SECRET","STORAGE_SIGNING_SECRET"],l={"@lunora/auth":[{description:"32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_SECRET",placeholderValue:"replace-with-openssl-rand-hex-32"},{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",docsUrl:"https://lunora.sh/docs/packages/auth#secrets",key:"AUTH_URL",placeholderValue:"http://localhost:8787"}],"@lunora/agent:requestSecretTool":[{description:"AES-256 key that seals secret values held for one agent step, base64 of 32 bytes. Generate with: openssl rand -base64 32. Rotate by moving the old value to LUNORA_SECRET_VALUE_KEY_PREVIOUS first.",docsUrl:"https://lunora.sh/docs/packages/agent#secret-values",key:"LUNORA_SECRET_VALUE_KEY",placeholderValue:"<your-base64-32-byte-key>"}],"@lunora/do:shardRegistry":[{description:"Signs every request to ShardRegistryDO, which refuses unsigned ones, and the shard-to-shard control channel. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/concepts/sharding#the-shard-registry",key:o,placeholderValue:r}],"@lunora/bindings/r2sql":[{description:"Cloudflare API token with R2 SQL read access, for `ctx.r2sql`. Create at https://dash.cloudflare.com/profile/api-tokens with the R2 SQL permission.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_TOKEN",placeholderValue:"<your-r2-sql-api-token>"},{description:"Cloudflare account id the R2 SQL queries run against. Falls back to CLOUDFLARE_ACCOUNT_ID when unset.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_ACCOUNT_ID",placeholderValue:"<your-cloudflare-account-id>"},{description:"Name of the R2 bucket holding the Iceberg tables `ctx.r2sql` queries.",docsUrl:"https://lunora.sh/docs/packages/bindings#r2-sql",key:"R2_SQL_BUCKET",placeholderValue:"<your-r2-sql-bucket>"}],"@lunora/mail":[{description:"Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",docsUrl:"https://lunora.sh/docs/packages/mail#secrets",key:"RESEND_API_KEY",placeholderValue:"<your-resend-api-key>"}],"@lunora/replica:eventLog":[{description:"Signs every request to EventLogDO, which refuses unsigned ones, and the calls from the worker that reads or appends the log. Set the same value on the worker and every Durable Object. Generate with: openssl rand -hex 32",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:o,placeholderValue:r}],"@lunora/replica:eventLogClient":[{description:"The LUNORA_RELAY_SECRET of the worker that hosts EventLogDO. EventLogDOClient throws at construction without it, and the log refuses every request signed with another value.",docsUrl:"https://lunora.sh/docs/packages/replica#eventlogdo",key:o,placeholderValue:"<your-eventlogdo-host-relay-secret>"}],"@lunora/notify:fcm":[{description:"Google service-account key file for FCM HTTP v1, base64-encoded on one line for .dev.vars (.dev.vars cannot hold its JSON quotes); in production use: wrangler secret put FCM_SERVICE_ACCOUNT < key.json. fcmFromEnv mints access tokens from it and reads the project id from it. Download it from the Firebase console (Project settings → Service accounts).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_SERVICE_ACCOUNT",placeholderValue:"<base64-of-your-service-account-key-json>"}],"@lunora/notify:fcmTokenSource":[{description:"Firebase project id for FCM HTTP v1. Your fcm channel supplies its own getAccessToken, so only the project id comes from env. Find it in the Firebase console (Project settings).",docsUrl:"https://lunora.sh/docs/packages/notify#fcm",key:"FCM_PROJECT_ID",placeholderValue:"<your-firebase-project-id>"}],"@lunora/notify:webPush":[{description:"Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PUBLIC_KEY",placeholderValue:"<your-vapid-public-key>"},{description:"Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_PRIVATE_KEY",placeholderValue:"<your-vapid-private-key>"},{description:"VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",docsUrl:"https://lunora.sh/docs/packages/notify#web-push",key:"VAPID_SUBJECT",placeholderValue:"mailto:you@example.com"}],"@lunora/payment/autumn":[{description:"Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_SECRET_KEY",placeholderValue:"<your-autumn-secret-key>"},{description:"Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#autumn",key:"AUTUMN_WEBHOOK_SECRET",placeholderValue:"<your-autumn-webhook-secret>"}],"@lunora/payment/creem":[{description:"Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_API_KEY",placeholderValue:"<your-creem-api-key>"},{description:"Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",docsUrl:"https://lunora.sh/docs/packages/payment#creem",key:"CREEM_WEBHOOK_SECRET",placeholderValue:"<your-creem-webhook-secret>"}],"@lunora/payment/dodopayments":[{description:"Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_API_KEY",placeholderValue:"<your-dodo-payments-api-key>"},{description:"Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#dodo-payments",key:"DODO_PAYMENTS_WEBHOOK_KEY",placeholderValue:"<your-dodo-payments-webhook-secret>"}],"@lunora/payment/polar":[{description:"Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_ACCESS_TOKEN",placeholderValue:"<your-polar-access-token>"},{description:"Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#polar",key:"POLAR_WEBHOOK_SECRET",placeholderValue:"<your-polar-webhook-secret>"}],"@lunora/payment/stripe":[{description:"Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_SECRET_KEY",placeholderValue:"<your-stripe-secret-key>"},{description:"Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",docsUrl:"https://lunora.sh/docs/packages/payment#stripe",key:"STRIPE_WEBHOOK_SECRET",placeholderValue:"<your-stripe-webhook-secret>"}]},n=new Set([...u,...[...p,...Object.values(l).flat()].filter(e=>i(e.key)&&!e.placeholderValue.startsWith("<")&&e.key!==o).map(e=>e.key)]),k=e=>e.includes(h)&&!e.some(t=>d.has(t))?n:new Set([...n,o]),E=e=>{const s=[];for(const t of e)for(const a of l[t]??[])s.some(c=>c.key===a.key)||s.push(a);return s};export{p as CORE_SECRETS,n as MINTABLE_SECRET_KEYS,l as PACKAGE_SECRETS_REGISTRY,r as SHARD_RELAY_HOST_PLACEHOLDER,o as SHARD_RELAY_SECRET_KEY,k as mintableSecretKeysFor,E as secretsForPackages};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as d,readFileSync as y}from"node:fs";import{join as s,isAbsolute as a,relative as m}from"node:path";import{LunoraError as p}from"@lunora/errors";import{classifyPolicyEdit as k,scaffoldPolicyFile as h,resolveServerModule as l,wireRlsIntoProcedure as v}from"./classifyPolicyEdit-DJi9Fk8G.mjs";import{w as c,r as b}from"./write-atomic-C_tVwH0p.mjs";const D="/__lunora/policy-scaffold",u=r=>r==="unknown-procedure"?404:r==="already-wired"||r==="destructive"?409:422,f=(r,o,e)=>{let t;try{t=b(r,o)}catch(n){return{body:{error:n instanceof Error?n.message:String(n),ok:!1},status:500}}return{body:{...e,diagnostics:t,ok:!0},status:200}},g=r=>({body:{edit:r,message:"Rewriting an existing policy predicate changes evaluation semantics and must be done by hand. The scaffolder only adds new, deny-by-default rules.",needsManualEdit:!0,ok:!1},status:409}),w=(r,o)=>{const e=h(o,l(r.projectRoot));if(!e.ok)return{body:{error:e.reason,ok:!1},status:u(e.reason)};const t=r.schemaDirectory??"lunora",n=s(r.projectRoot,t,e.fileName);return d(n)?{body:{error:"file-exists",fileName:e.fileName,ok:!1},status:409}:(c(n,e.source),f(r,{path:n,text:e.source},{fileName:e.fileName}))},R=(r,o,e)=>{if(typeof e!="string"||e.length===0||a(e)||e.includes("\\"))return;const t=s(r,o),n=s(t,`${e}.ts`),i=m(t,n);if(!(i.startsWith("..")||a(i)))return n},N=(r,o)=>{const e=R(r.projectRoot,r.schemaDirectory??"lunora",o.filePath);if(e===void 0||!d(e))return{body:{error:"unknown-procedure",ok:!1},status:404};const t=v(y(e,"utf8"),o,l(r.projectRoot));return t.ok?(c(e,t.text),f(r,{path:e,text:t.text},{exportName:o.exportName})):{body:{error:t.reason,ok:!1},status:u(t.reason)}},E=r=>{if(r.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:o}=r;if(o==null||typeof o!="object"||typeof o.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};const e=o;if(k(e)==="destructive")return g(e);if(e.kind==="scaffoldPolicy")return w(r,e);if(e.kind==="wireRls")return N(r,e);throw new p("INTERNAL",`unhandled additive policy edit kind: ${String(e.kind)}`)};export{D as POLICY_SCAFFOLD_ENDPOINT,E as handlePolicyScaffoldRequest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyModify as g}from"./applyModify-DKP2l6S9.mjs";import{hasCloudflareCredentials as v}from"./hasCloudflareCredentials-ByCrwaLT.mjs";import{withheldBindings as y,writeDevConfig as E,noopCleanup as R}from"./describeWithheld-CbyzZjZF.mjs";import{readManifest as w}from"./readManifest-Cighz3WC.mjs";import{o as S}from"./reconcile-services-CjgIJKim.mjs";import{findWranglerFile as _,readWranglerJsonc as j}from"./WRANGLER_FILES-BF8PUjuo.mjs";const h={ai:{label:"AI",shape:"object"},ai_search:{label:"AI Search",shape:"array"},ai_search_namespaces:{label:"AI Search namespace",shape:"array"},analytics:{label:"Analytics SQL",shape:"object"},d1_databases:{label:"D1",shape:"array"},kv_namespaces:{label:"KV",shape:"array"},queues:{label:"Queue",shape:"producers"},r2_buckets:{label:"R2",shape:"array"},services:{label:"Service",shape:"array"},vectorize:{label:"Vectorize",shape:"array"}},B=Object.keys(h),m=(e,n)=>typeof e.binding=="string"?e.binding:n,f=(e,n,r,t)=>{const i=[];for(const[s,o]of n.entries())o!=null&&(e==="kv_namespaces"&&(typeof o.id!="string"||o.id==="")||i.push({binding:m(o,`#${String(s)}`),kind:r,path:[...t,s],section:e}));return i},u=(e,n)=>h[e].shape===n,C=(e,n)=>{const{label:r}=h[e];if(u(e,"array"))return f(e,n[e]??[],r,[]);if(u(e,"object")){const t=n[e];return t==null?[]:[{binding:m(t,e),kind:r,path:[],section:e}]}return f(e,n.queues?.producers??[],r,["producers"])},I=e=>B.flatMap(n=>C(n,e)),k=(e,n)=>{let r=e;for(const t of n)r=g(r,[t.section,...t.path,"remote"],!0);return r},W=(e,n)=>({bindings:e.remoteBindings.map(r=>`${r.binding} (${r.kind})`),cleanup:e.cleanup,configPath:e.configPath,enabled:n,reason:e.reason,withheld:e.withheld}),$=e=>{const n=a=>({cleanup:R,reason:a,remoteBindings:[],withheld:[]}),r=_(e.projectRoot);if(!r)return n("wrangler.jsonc not found");const{parsed:t,text:i}=j(r);if(t===void 0)return n(`failed to parse ${r} as JSONC`);const s=S(w(e.projectRoot)),o=e.remote?I(t).filter(a=>a.section!=="services"||!s.has(a.binding)):[],l=y(t,e.hasCredentials??(()=>v({projectRoot:e.projectRoot}))),c=l.some(({kind:a})=>a==="ai")?o.filter(a=>a.section!=="ai"):o;if(c.length===0&&l.length===0)return n(e.remote?"no remote-eligible bindings to proxy":void 0);let d=i;for(const{kind:a}of l)d=g(d,[a],void 0);const b=c.length>0?k(d,c):d,p=E(e.projectRoot,"dev",b);return{cleanup:p.cleanup,configPath:p.configPath,remoteBindings:c,withheld:l}},L=e=>{if(e===void 0)return!1;const n=e.trim().toLowerCase();return n==="1"||n==="true"},D=e=>e.flag===!0||L(e.envValue)?!0:e.configPreference??!1;export{h as REMOTE_ELIGIBLE_KEYS,k as injectRemoteFlags,L as isRemoteEnvEnabled,$ as materializeDevWranglerConfig,I as planRemoteBindings,D as resolveRemoteEnabled,W as toRemotePlan};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{MERGED_DURABLE_OBJECT as m}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{o as R,v as S,a as I,b as j,c as A,d as L,e as f,g as k,h as B,H as C,i as N,R as T,S as w,j as q,k as U,W as G,l as P}from"./validate-bindings-CQbR23li.mjs";import{i as u,p as g,a as _}from"./guards-CoCtgpeR.mjs";import{validateTailConsumers as W,validateSendEmail as K,validateSecretsRequired as M,validateLogpush as V,validateLimits as x,validatePlacement as H,validateObservability as Q,validateAssets as F,validateCache as Y,validateExports as J,validateCorsVariables as z,validateSchedulerOrigin as X}from"./withTailConsumer-CKXL6P6s.mjs";import{isCacheEnabled as Z,WORKERS_CACHE_MIN_DATE as E}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{mergeWranglerEnvironment as ee}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";const v=t=>u(t)?new Set([...g(t.producers).map(i=>i.queue),...g(t.consumers).flatMap(i=>[i.queue,i.dead_letter_queue])].filter(i=>_(i))):new Set,b=(t,i,n)=>{const e=u(t)?t.account_id:void 0;return _(e)?e:_(i.account_id)?i.account_id:_(n)?n:void 0},te=(t,i,n,e=process.env.CLOUDFLARE_ACCOUNT_ID)=>{if(i===void 0||!u(t.env))return;const s=t.env[i],r=v(u(s)?s.queues:void 0);if(r.size===0)return;const a=b(s,t,e),p=[{account:b(void 0,t,e),names:v(t.queues),scope:"the top level"},...Object.entries(t.env).filter(([c])=>c!==i).map(([c,o])=>({account:b(o,t,e),names:v(u(o)?o.queues:void 0),scope:`env.${c}`}))].filter(c=>a===void 0||c.account===void 0||c.account===a);for(const c of r){const o=p.filter(({names:l})=>l.has(c)).map(({scope:l})=>l);o.length>0&&n.push(`env.${i}.queues names queue "${c}", which ${o.join(" and ")} also ${o.length===1?"names":"name"}. Queue names are unique per Cloudflare account, so deployed to one account the environments share that queue: messages produced in one are consumed by the other. Give env.${i} its own name (e.g. "${c}-${i}") unless the sharing is intended — the renamed queue starts empty, and messages already in "${c}" stay there.`)}},ie=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),O=t=>Array.isArray(t)?t.flatMap((i,n)=>ie(i)?[[n,i]]:[]):[],y=t=>typeof t.binding=="string"?t.binding:"",ae=(t,i,n)=>{for(const[e,s]of O(t.kv_namespaces))typeof s.id=="string"&&s.id!==""||n.push(`kv_namespaces[${String(e)}] ("${y(s)}") is not created yet and the schema pins data to "${i}" — create it with \`wrangler kv namespace create <name> --jurisdiction=${i}\`; a namespace's jurisdiction cannot be changed afterwards`)},se=(t,i,n)=>{for(const[e,s]of O(t.r2_buckets)){const r=s.jurisdiction;if(r===i)continue;const a=typeof r=="string"?`names the "${r}" jurisdiction`:"names no jurisdiction";n.push(`r2_buckets[${String(e)}] ("${y(s)}") ${a}, but the schema pins data to "${i}" — create the bucket with \`wrangler r2 bucket create <name> --jurisdiction=${i}\` and set "jurisdiction": "${i}" on the binding`)}},ne=(t,i,n)=>{const e=i?.jurisdiction;e!==void 0&&(ae(t,e,n),se(t,e,n))},D="2026-04-07",pe="web_socket_auto_reply_to_close",h="2026-10-01",$="durable_object_io_tasks_prevent_eviction",oe="durable_object_io_tasks_do_not_prevent_eviction",re=/^\d{4}-\d{2}-\d{2}$/,ce=(t,i,n)=>{t>=h||i.includes($)||i.includes(oe)||n.push(`compatibility_date "${t}" predates "${h}", so pending I/O (waitUntil, cross-Durable-Object RPC, service-binding calls, timers) does not keep a Durable Object alive once its last client disconnects — live-query refreshes and durable streams can be cut off mid-flight. Set compatibility_date >= "${h}" or add the "${$}" compatibility flag`)},de=(t,i,n)=>{const{error:e,merged:s,unverifiedKeys:r}=ee(t,i);return e!==void 0?{error:e,wrangler:s}:(r.length>0&&n.push(`env.${String(i)} overrides ${r.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${r.length===1?"it":"them"} by hand for "${String(i)}".`),{wrangler:s})},le=(t,i,n)=>{const e=[],s=[];if(!t||typeof t!="object")return e.push("wrangler config is not a valid object"),{errors:e,valid:!1,warnings:s};const{error:r,wrangler:a}=de(t,n,s);if(r!==void 0)return e.push(r),{errors:e,valid:!1,warnings:s};R(a.durable_objects?.bindings).find(d=>d.name==="SHARD"&&(d.class_name==="ShardDO"||d.class_name===m))||e.push(`durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } (or "${m}" when the app merges its Durable Objects) — your dev server auto-reconciles this on startup, or add the binding manually`),S(a,e);const o=a.compatibility_date??"",l=re.test(o);o&&!l?e.push(`compatibility_date must be in YYYY-MM-DD format (got "${o}")`):o<D&&e.push(`compatibility_date must be >= "${D}" (got "${o||"<missing>"}")`),Z(a)&&l&&o<E&&e.push(`cache.enabled requires compatibility_date >= "${E}" (got "${o||"<missing>"}")`),l&&ce(o,a.compatibility_flags??[],s),I(a,i,e),ne(a,i,s),j(a,e),A(a,i?.vectorIndexNames??[],e),W(a,e),L(a,e,s),f(a.workflows,"workflows",G,e),k(a,e),B(a,e),te(t,n,s),f(a.secrets_store_secrets,"secrets_store_secrets",P,e);for(const d of C)N(a,d,e,s);for(const d of T)f(a[d.key],d.key,d,e);for(const d of w)q(a,d,e);return U(a,e),K(a,e,s),M(a,e),V(a,e),x(a,e),H(a,e),Q(a,e,s),F(a,e),Y(a,e),J(a,e),z(a,e),X(a,n,s),{errors:e,valid:e.length===0,warnings:s}},me=le;export{D as REQUIRED_COMPATIBILITY_DATE,pe as REQUIRED_FLAG,me as validateWrangler,le as validateWranglerConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as a,readFileSync as d}from"node:fs";import{classifyEdit as l,applyAdditiveEdit as c}from"./applyAdditiveEdit-DEwPKcJg.mjs";import{parseSchema as u}from"./parseSchema-D1Wbr1qv.mjs";import{w as f,r as p}from"./write-atomic-C_tVwH0p.mjs";import{join as m}from"node:path";const F="/__lunora/schema-edit",b=t=>t==="destructive"||t==="duplicate-table"||t==="duplicate-column"||t==="duplicate-index"?409:t==="unknown-table"?404:t==="invalid-identifier"||t==="invalid-validator"?400:422,y=t=>({body:{error:t.reason,ok:!1},status:422}),k=t=>{if(!a(t))return{response:{body:{error:"no-schema-file",ok:!1},status:404}};const e=u(d(t,"utf8"));return e.ok?{tables:e.tables}:{response:y(e)}},g=t=>({body:{edit:t,message:"This edit changes stored data and must go through a migration. Review the migration before applying.",needsMigration:!0,ok:!1},status:409}),h=(t,e)=>{const r=t.body;if(r==null||typeof r!="object"||typeof r.kind!="string")return{body:{error:"invalid-edit",ok:!1},status:400};if(l(r)==="destructive")return g(r);if(!a(e))return{body:{error:"no-schema-file",ok:!1},status:404};const o=c(d(e,"utf8"),r);if(!o.ok)return{body:{error:o.reason,ok:!1},status:b(o.reason)};f(e,o.text);let i;try{i=p(t,{path:e,text:o.text})}catch(s){return{body:{error:s instanceof Error?s.message:String(s),ok:!1},status:500}}const n=u(o.text);return{body:{diagnostics:i,ok:!0,tables:n.ok?n.tables:[]},status:200}},R=t=>{const e=m(t.projectRoot,t.schemaDirectory??"lunora","schema.ts");if(t.method==="GET"){const r=k(e);return"response"in r?r.response:{body:{ok:!0,tables:r.tables},status:200}}return t.method==="POST"?h(t,e):{body:{error:"method-not-allowed",ok:!1},status:405}};export{F as SCHEMA_EDIT_ENDPOINT,R as handleSchemaEditRequest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as p}from"node:fs";import{discoverSchema as h,schemaFromIr as g}from"@lunora/codegen";import{LunoraError as k}from"@lunora/errors";import{Project as S}from"ts-morph";import{join as w}from"node:path";const P="/__lunora/seed",j=1e3,E=(r,t)=>typeof t=="bigint"?Number(t):t instanceof ArrayBuffer?[...new Uint8Array(t)]:t,R=r=>typeof r!="number"||!Number.isFinite(r)?10:Math.min(Math.max(1,Math.floor(r)),j),F=async r=>{if(r.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:t}=r;if(t==null||typeof t!="object")return{body:{error:"invalid-request",ok:!1},status:400};const{count:f,existingIds:c,seed:m,table:o}=t;if(typeof o!="string"||o.length===0)return{body:{error:"missing-table",ok:!1},status:400};const d=r.schemaDirectory??"lunora",n=w(r.projectRoot,d,"schema.ts");if(!p(n))return{body:{error:"schema-not-found",ok:!1},status:404};const l=new S({skipAddingFilesFromTsConfig:!0}),a=h(l,n);if(!a.tables.some(e=>e.name===o))return{body:{error:"unknown-table",ok:!1,table:o},status:404};const u=g(a),{seedPlan:y}=await import("@lunora/seed");let s;try{s=y(u,{existingIds:c??{},defaultCount:R(f),only:[o],seed:m??0})}catch(e){if(e instanceof k&&e.code==="BAD_REQUEST")return{body:{error:"seed-refused",message:e.message,ok:!1},status:409};throw e}const i=s.filter(e=>e.table!==o).map(e=>e.table);if(i.length>0)return{body:{error:"fk-parents-empty",ok:!1,tables:i},status:409};const b=s.find(e=>e.table===o)?.rows??[];return{body:{ok:!0,rows:JSON.parse(JSON.stringify(b,E))},status:200}};export{P as SEED_ENDPOINT,F as handleSeedRequest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveAdminToken as A}from"./devVariablesStamp-BQkGEn9d.mjs";import{handleAdvisorProceduresRequest as I,ADVISOR_PROCEDURES_ENDPOINT as O}from"./ADVISOR_PROCEDURES_ENDPOINT-BPnqzAgT.mjs";import{sendStudioDocument as _,sendStudioAsset as h}from"./sendStudioAsset-B81Pex91.mjs";import{isStandaloneModulePath as y,studioAssetsStamp as N,loadStudioAssets as E,readStandaloneAsset as H,assetContentType as R}from"./assetContentType-CUb5bpbI.mjs";import v from"./createStudioDocumentCache-XBG1aWbl.mjs";import{detectAgentRules as C}from"./AGENT_RULES_DIR-Bd6JPtNa.mjs";import{handlePolicyScaffoldRequest as L,POLICY_SCAFFOLD_ENDPOINT as b}from"./POLICY_SCAFFOLD_ENDPOINT-DfNG44Lm.mjs";import x from"./renderStudioHtml-CRDTNivi.mjs";import{handleSchemaEditRequest as $,SCHEMA_EDIT_ENDPOINT as k}from"./SCHEMA_EDIT_ENDPOINT-CN5_FXGg.mjs";import{handleSeedRequest as U,SEED_ENDPOINT as g}from"./SEED_ENDPOINT-C1fhrehH.mjs";import{serveJsonHandler as j}from"./serveJsonHandler-B8_GE6QC.mjs";import{transportRejectionReason as F}from"./ALLOW_FORWARDED_ENV-BUndghJx.mjs";import"./STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs";const i="/__lunora",M=`${i}/studio.js`,m=`${i}/styles.css`,P=/\/$/,q={[b]:L,[k]:$,[g]:U,[O]:I},w=new Set(["127.0.0.1","::1","localhost"]),st=t=>t!==void 0&&t!==!1&&!w.has(t),T=t=>t===void 0||t==="/"?"":t.replace(P,""),nt=t=>`${T(t)}${i}`,B=t=>{try{return new URL(t,"http://localhost").pathname}catch{const d=t.indexOf("?");return d===-1?t:t.slice(0,d)}},at=t=>{const{logger:d,projectRoot:c}=t,u=T(t.base);let l,S;const p=v(c,()=>x({adminToken:A(c),advisorProcedures:!0,basePath:i,dataEditable:!0,rulesInstalled:C(c).installed,runAsIdentity:!0,schemaEditable:!0,scriptSrc:M,styleHref:m})),D=(s,o,e)=>{const n=N();if((l===void 0||n!==S)&&(l=E(d),S=n),l===void 0){e.statusCode=501,e.setHeader("Content-Type","text/plain"),e.end("Lunora studio assets not found — install and build @lunora/studio.");return}const a=s===m,r=s.slice(s.lastIndexOf("/")+1);if(a){h(o,e,l.styles,"text/css; charset=utf-8",r,n);return}const f=H(r);if(f===void 0){e.statusCode=404,e.setHeader("Content-Type","text/plain"),e.end("Not found");return}h(o,e,f,R(r),r,n)};return(s,o,e)=>{const n=B(s.url??"").replace(P,""),a=u!==""&&n.startsWith(u)?n.slice(u.length):n;if(a!==i&&!a.startsWith(`${i}/`)){e();return}if(t.isNonLoopbackBind||F(s,d)!==void 0){o.statusCode=403,o.setHeader("Content-Type","text/plain"),o.end("Lunora studio is only available on loopback hosts in dev.");return}const r=q[a];if(r!==void 0){j(s,o,r,c,{apiSpec:t.apiSpec,lazyFunctions:t.lazyFunctions,schemaDirectory:t.schemaDirectory});return}if(a===m||y(a)){D(a,s,o);return}_(o,p())}};export{i as STUDIO_PATH,M as STUDIO_SCRIPT_PATH,m as STUDIO_STYLE_PATH,at as createStudioMiddleware,st as isNonLoopbackHost,B as requestPathname,nt as studioMountPath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as c}from"node:fs";import{resolve as i}from"node:path";const f=5e3,r=new Map,u=".lunora-tmp",d=(o,n,e=Date.now())=>{for(const[t,s]of r)s.expiresAt<e&&r.delete(t);r.set(i(o),{expiresAt:e+f,text:n})},l=(o,n=Date.now())=>{const e=i(o),t=r.get(e);if(t===void 0||(r.delete(e),t.expiresAt<n))return!1;try{return c(e,"utf8")===t.text}catch{return!1}};export{u as STUDIO_WRITE_TEMP_SUFFIX,l as consumeStudioWrite,d as recordStudioWrite};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as h}from"node:fs";import{dirname as y,join as p}from"node:path";import{discoverSchemaInfo as w}from"./discoverSchemaInfo-DRPnqgif.mjs";import{MERGED_DURABLE_OBJECT as i,GENERATED_DIRECTORY as E,MERGED_ROLE_DURABLE_OBJECTS as u,COMPOSED_ENTRY_DURABLE_OBJECTS as $,GENERATED_CLASS_MODULES as k,isFrameworkDurableObject as D}from"./COMPOSED_WORKER_ENTRY-LpLlp-aF.mjs";import{o as R,f as j}from"./validate-bindings-CQbR23li.mjs";import{validateSchedulerOrigin as x}from"./withTailConsumer-CKXL6P6s.mjs";import{l as O,r as _,s as A}from"./worker-entry-checks-DH-ApvvX.mjs";import{mergeWranglerEnvironment as S}from"./mergeWranglerEnvironment-D5ekKj5x.mjs";import{findWranglerFile as W,readWranglerJsonc as C}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{validateWranglerConfig as T}from"./REQUIRED_COMPATIBILITY_DATE-BPxR2Ht_.mjs";const v=r=>Array.isArray(r)?r:[],L=(r,t,o)=>Object.entries(r?.images??{}).flatMap(([s,n])=>{const e=n?.dockerfile;return typeof e!="string"||h(e.startsWith("/")?e:p(t,e))?[]:[`containers images["${s}"] dockerfile "${e}" does not exist (resolved relative to ${o}); create the Dockerfile`]}),I=(r,t,o)=>{const s=[];for(const n of v(r)){const e=n?.image;typeof e=="string"&&(e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"))&&!h(e.startsWith("/")?e:p(t,e))&&s.push(`containers image "${e}" does not exist (resolved relative to ${o}); create the Dockerfile or point image at a registry reference`),s.push(...L(n,t,o))}return s},P=(r,t)=>{const o=r?.vectorIndexNames??[],s=[];if(o.length>0&&s.push({message:e=>`schema declares vector index(es) ${o.map(l=>`"${l}"`).join(", ")} but nothing chains .vectors(...) onto defineApp() (composed in: ${e}) — \`ctx.vectors\` is then a throwing stub and buildWorkerOptions rejects EVERY request, /_lunora/health included. Add \`.vectors((env) => ({ ${String(o[0])}: env.<BINDING> }))\` to the chain.`,method:"vectors"}),r?.hasD1GlobalTable&&s.push({message:e=>`schema declares .global() table(s) but nothing chains .global(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of a global table throws INTERNAL ("requires a globalDb writer"). Add \`.global({ d1: (env) => env.DB })\` to the chain.`,method:"global"}),r?.hasHyperdriveGlobalTable&&s.push({message:e=>`schema declares .global({ backend: "hyperdrive" }) table(s) but nothing chains .hyperdriveGlobal(...) onto defineApp() (composed in: ${e}) — the shard then has no global writer, so every read or write of those tables throws INTERNAL. Add \`.hyperdriveGlobal({ engine: "postgres", exec: (env) => buildPgExec(fromPostgresJs(async () => (await import("postgres")).default(env.HYPERDRIVE.connectionString, { fetch_types: false, max: 5 }))) })\` to the chain (\`buildPgExec\` from \`@lunora/hyperdrive/global\`, \`fromPostgresJs\` from \`@lunora/hyperdrive\`).`,method:"hyperdriveGlobal"}),s.length===0)return[];const n=A(t,new Set(s.map(e=>e.method)));return n===void 0?[]:s.filter(e=>!n.chained.has(e.method)).map(e=>e.message(n.site))},G="does not export it",B=(r,t)=>{if(t.exports?.has(i)===!0&&u.has(r))return`This app merges its Durable Objects (\`durableObjects.merge\` in lunora.config), so ${i} hosts ${r}: bind only \`SHARD\` to "${i}" and drop the SCHEDULER / SHARD_REGISTRY bindings. Do that only if this Worker has never been deployed — a deployed ${r} namespace keeps its data, which the merged class cannot reach; turn \`durableObjects.merge\` off to keep it.`;if(r===i)return`${i} is the merged class (\`durableObjects.merge\` in lunora.config), and merging cannot be undone once deployed: the shard data lives in ${i}. Turn \`durableObjects.merge\` back on. Only a Worker that has never been deployed may rebind SHARD to "ShardDO".`;if(t.kind!=="composed")return`Re-export it from the module that defines it (\`export { ${r} } from "./…";\`), or add it to the app builder's own export (\`export const { ${r} } = app;\`).`;const o=`it exports ${$.join(", ")}, SchedulerDO when its binding is declared, and every class codegen emits from your ${k.map(s=>`${s}.ts`).join(" / ")} declarations`;return D(r)?`\`@lunora/vite\` generates that entry — ${o}, and ${r} is not among them. Class-A composition does not carry ${r}, so drop the binding; a project that needs it has to own its worker entry (add \`src/worker.ts\`, which \`lunora deploy\` bundles in place of \`main\`, and compose \`defineApp()\` there).`:`\`@lunora/vite\` generates that entry, so there is no file to add a re-export to: ${o}. Declare "${r}" in one of those and re-run \`lunora codegen\`, or drop the binding.`},M=(r,t)=>{const o=t.exports;if(o===void 0)return[];const s=[];for(const e of R(r.durable_objects?.bindings))typeof e.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"durable_objects.bindings"});for(const e of v(r.workflows))typeof e?.class_name=="string"&&e.class_name.length>0&&e.script_name===void 0&&s.push({className:e.class_name,label:"workflows"});for(const[e,l]of Object.entries(r.exports??{}))l?.type==="workflow"&&s.push({className:e,label:"workflows"});return s.filter(e=>!o.has(e.className)).map(e=>`${e.label} declares class "${e.className}" but the ${t.kind==="composed"?"composed class-A worker entry":"worker entry"} (${t.path}) ${G} — wrangler refuses to bundle a Worker whose ${e.label==="workflows"?"Workflow":"Durable Object"} classes are not exported. ${B(e.className,t)}`)},N=r=>[...j(r.migrations)].filter(t=>u.has(t)).map(t=>`migrations create class "${t}", which this app hosts in ${i} because it merges its Durable Objects (\`durableObjects.merge\`). Before the first deploy, replace "${t}" with "${i}" in new_sqlite_classes; a Worker already deployed with "${t}" keeps its data there and cannot merge — turn \`durableObjects.merge\` off.`),U=r=>r?.origin!=="absent"?[]:[`main is set but no readable file is there (looked in ${r.path}) — wrangler cannot resolve the worker entry, so a deploy will fail there. Point main at the entry that composes your app, or remove it to fall back to the conventional locations.`],Z=r=>{const t=r.schemaDir??"lunora",o=W(r.projectRoot);if(!o){const c=`wrangler.jsonc not found in ${r.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:s}=C(o);if(s===void 0){const c=`failed to parse ${o} as JSONC.`;return{problems:[c],report:{errors:[c],valid:!1,warnings:[]},wranglerPath:o}}const{error:n,merged:e}=S(s,r.environment);if(n!==void 0)return{problems:[n],report:{errors:[n],valid:!1,warnings:[]},wranglerPath:o};const{error:l,info:f}=w(r.projectRoot,t,r.cache),a=T(s,f,r.environment);l!==void 0&&a.warnings.push(`schema parse failed in ${t}/schema.ts: ${l}`);const g=y(o),b=O(e.main,r.projectRoot,o),m=_(b,r.projectRoot,t);a.errors.push(...I(e.containers??[],g,o)),a.warnings.push(...U(b)),m!==void 0&&a.errors.push(...M(e,m)),m?.exports?.has(i)===!0&&(a.errors.push(...N(e)),h(p(r.projectRoot,t,E,"scheduler.ts"))&&x(e,r.environment,a.warnings,"the merged LunoraDO hosts the scheduler")),a.errors.push(...P(f,r.projectRoot));const d=e.assets?.directory;if(typeof d=="string"&&d.length>0){const c=d.startsWith("/")?d:p(g,d);h(c)||a.warnings.push(`assets.directory "${d}" does not exist yet — it is created by the client build; run the build before deploy`)}return a.valid=a.errors.length===0,{problems:a.errors,report:a,wranglerPath:o}};export{G as UNEXPORTED_CLASS_MARKER,Z as validateWranglerProject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l="2026-05-01",n=e=>{if(!e)return!1;const c=typeof e.cache=="object"&&e.cache!==null&&e.cache.enabled===!0,o=typeof e.exports=="object"&&e.exports!==null&&Object.values(e.exports).some(t=>typeof t=="object"&&t!==null&&t.cache?.enabled===!0);return c||o};export{l as WORKERS_CACHE_MIN_DATE,n as isCacheEnabled};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as n,readFileSync as a}from"node:fs";import{parse as s}from"jsonc-parser";import{join as c}from"node:path";const i=["wrangler.jsonc","wrangler.json"],d=t=>{for(const r of i){const e=c(t,r);if(n(e))return e}},l=t=>{const r=a(t,"utf8"),e=[],o=s(r,e,{allowTrailingComma:!0});return e.length>0||o===null||typeof o!="object"?{parsed:void 0,text:r}:{parsed:o,text:r}},m=t=>{const r=d(t);if(r!==void 0)try{return{parsed:l(r).parsed,path:r}}catch{return{parsed:void 0,path:r}}};export{i as WRANGLER_FILES,d as findWranglerFile,m as readProjectWrangler,l as readWranglerJsonc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{spawn as f}from"node:child_process";import{connect as h}from"node:net";const m=150,p=5e3,E=(e,t,r)=>f(e,[...t],{cwd:r.cwd,shell:r.shell,stdio:["ignore","pipe","pipe"]}),x=async e=>new Promise(t=>{const r=h({host:"127.0.0.1",port:e}),o=s=>{r.destroy(),t(s)};r.once("connect",()=>{o(!0)}),r.once("error",()=>{o(!1)})}),d=(e,t)=>{let r="";e?.setEncoding("utf8"),e?.on("data",o=>{r+=o;const s=r.split(`
|
|
2
|
+
`);r=s.pop()??"";for(const a of s)t(a)}),e?.once("end",()=>{r!==""&&(t(r),r="")})},w=e=>e.exitCode!==null||e.signalCode!==null,L=async e=>{const t=(e.spawn??E)(e.command,e.args,{cwd:e.cwd,shell:e.shell===!0});let r=!1,o,s;d(t.stdout,n=>{e.onLine(n,"stdout")}),d(t.stderr,n=>{e.onLine(n,"stderr")}),t.once("error",n=>{o=n.code==="ENOENT"?new Error(e.notFound):n}),t.once("exit",n=>{s??=new Error(`${e.label} exited with code ${String(n)} before it was ready`)});const a=new Promise(n=>{t.once("exit",i=>{r||n(i??1)})}),l=()=>{t.kill("SIGKILL")};process.once("exit",l);const c=async()=>{r=!0,process.removeListener("exit",l),!w(t)&&await new Promise(n=>{const i=setTimeout(()=>{t.kill("SIGKILL")},p);t.once("exit",()=>{clearTimeout(i),n()}),t.kill("SIGTERM")})},u=Date.now()+e.readyTimeoutMs;for(;Date.now()<u;){const n=o??s;if(n!==void 0)throw process.removeListener("exit",l),n;if(e.signal?.aborted===!0)throw await c(),new Error(`${e.label} was stopped before it was ready`);if(await x(e.port)){if(w(t))throw await c(),new Error(`the server on port ${String(e.port)} is not the ${e.label} started here — it exited while something else took the port`);return{crashed:a,stop:c}}await new Promise(i=>{setTimeout(i,m)})}throw await c(),new Error(`${e.label} did not accept connections on port ${String(e.port)} within ${String(e.readyTimeoutMs/1e3)}s`)};export{x as acceptsConnection,L as startDevProcess};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawnSync as o}from"node:child_process";import{LunoraError as s}from"@lunora/errors";import{findPackageManagerSync as i,identifyInitiatingPackageManager as c}from"@visulima/package/package-manager";const a=["pnpm","bun","yarn","npm"],u=new Set(a),d=r=>u.has(r),l=r=>{try{return o(r,["--version"],{shell:process.platform==="win32",stdio:"ignore",timeout:5e3}).status===0}catch{return!1}},m=(r=l)=>a.filter(n=>r(n)),y=r=>({args:["install"],command:r}),E=(r,n,t={})=>{const e=t.dev===!0;return r==="npm"?{args:["install",...e?["--save-dev"]:[],...n],command:"npm"}:r==="bun"?{args:["add",...e?["-d"]:[],...n],command:"bun"}:{args:["add",...e?["-D"]:[],...n],command:r}},M=r=>{try{return i(r).packageManager}catch{}const n=c();if(n!==void 0){const e=n.name==="cnpm"?"npm":n.name;if(d(e))return e}const[t]=m();if(t!==void 0)return t;throw new s("INTERNAL","Could not detect a package manager: no lock file or `packageManager` field was found, and none (pnpm, bun, yarn, npm) is installed on PATH.")},g=(r,n,t)=>r==="yarn"?{args:[n,...t],command:"yarn"}:r==="bun"?{args:["x",n,...t],command:"bun"}:r==="npm"?{args:["--",n,...t],command:"npx"}:{args:["exec",n,...t],command:"pnpm"},b=(r,n)=>n.onPath===!0?{args:[...n.args],command:n.tool}:g(r,n.tool,n.args),P=(r,n)=>({args:["run",n],command:r}),h=(r,n)=>r==="npm"?`npm run ${n}`:r==="bun"?`bun run ${n}`:`${r} ${n}`;export{E as addArgsFor,m as detectInstalledManagers,M as detectPackageManager,g as execArgsFor,y as installArgsFor,P as runScriptArgsFor,h as runScriptCommand,b as toolchainExecArgs};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{Project as p,SyntaxKind as i}from"ts-morph";import{collectCalls as m}from"./parseSchema-D1Wbr1qv.mjs";const b=/^[A-Za-z_$][\w$]*$/u,v=new Set(["any","array","bigint","boolean","bytes","date","id","literal","null","number","object","optional","record","storage","string","timestamp","union"]),u=e=>{if(e.getKind()===i.ParenthesizedExpression)return u(e.asKindOrThrow(i.ParenthesizedExpression).getExpression());if(e.getKind()!==i.CallExpression)return!1;const t=e.asKindOrThrow(i.CallExpression),r=t.getExpression();if(r.getKind()!==i.PropertyAccessExpression)return!1;const n=r.asKindOrThrow(i.PropertyAccessExpression);return n.getExpression().getKind()!==i.Identifier||n.getExpression().getText()!=="v"||!v.has(n.getName())?!1:t.getArguments().every(s=>c(s))},c=e=>{const t=e.getKind();return t===i.ParenthesizedExpression?c(e.asKindOrThrow(i.ParenthesizedExpression).getExpression()):t===i.StringLiteral||t===i.NumericLiteral||t===i.TrueKeyword||t===i.FalseKeyword||t===i.NullKeyword?!0:t===i.PrefixUnaryExpression?e.asKindOrThrow(i.PrefixUnaryExpression).getOperand().getKind()===i.NumericLiteral:t===i.ObjectLiteralExpression?e.asKindOrThrow(i.ObjectLiteralExpression).getProperties().every(r=>{if(r.getKind()!==i.PropertyAssignment)return!1;const n=r.getInitializer();return n!==void 0&&c(n)}):t===i.ArrayLiteralExpression?e.asKindOrThrow(i.ArrayLiteralExpression).getElements().every(r=>c(r)):u(e)},y=e=>{if(typeof e!="string"||e.trim().length===0)return!1;const t=new p({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}),r=t.createSourceFile("validator.ts",`const __v = (${e});`,{overwrite:!0});if(t.getProgram().getSyntacticDiagnostics(r).length>0||r.getStatements().length!==1)return!1;const s=r.getVariableDeclaration("__v")?.getInitializer();return s!==void 0&&u(s)},E=new Set(["addIndex","addOptionalColumn","addTable"]),A=new Set(["d1","hyperdrive"]),T=e=>E.has(e.kind)?"additive":"destructive",d=e=>typeof e=="string"&&b.test(e),h=e=>{if(!d(e.table)||e.kind==="addTable"&&e.global?.backend!==void 0&&!A.has(e.global.backend))return"invalid-identifier";if(e.kind==="addOptionalColumn"){if(!d(e.column))return"invalid-identifier";if(!y(e.validator))return"invalid-validator"}if(e.kind==="addIndex"&&(!d(e.name)||!Array.isArray(e.fields)||!e.fields.every(t=>d(t))))return"invalid-identifier"},O=e=>{const r=new p({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}).createSourceFile("schema.ts",e,{overwrite:!0});let n;for(const o of r.getDescendantsOfKind(i.CallExpression))if(o.getExpression().getText()==="defineSchema"){n=o;break}if(n===void 0)return{reason:r.getImportDeclarations().some(l=>l.getNamedImports().some(a=>a.getName()==="defineSchema"&&a.getAliasNode()!==void 0))?"aliased-define-schema":"no-define-schema"};const s=n.getArguments()[0];return s?.getKind()!==i.ObjectLiteralExpression?{reason:"non-object-argument"}:{object:s.asKindOrThrow(i.ObjectLiteralExpression),sourceFile:r}},g=(e,t)=>{for(const r of e.getProperties())if(r.getKind()===i.PropertyAssignment&&r.getNameNode().getText().replaceAll(/["']/gu,"")===t)return r},K=e=>{const t=e.getInitializer(),n=(t===void 0?void 0:m(t).find(s=>s.getExpression().getText()==="defineTable"))?.getArguments()[0];return n?.getKind()===i.ObjectLiteralExpression?n.asKindOrThrow(i.ObjectLiteralExpression):void 0},w=(e,t)=>{if(g(e,t.table)!==void 0)return"duplicate-table";const r=t.global?.backend,n=r===void 0?"":`{ backend: ${JSON.stringify(r)} }`,s=t.global===void 0?"":`.global(${n})`;e.addPropertyAssignment({initializer:`defineTable({
|
|
2
|
+
// Add your column validators here.
|
|
3
|
+
// Example:
|
|
4
|
+
// text: v.string(),
|
|
5
|
+
// createdAt: v.number(),
|
|
6
|
+
})${s}`,name:t.table})},k=(e,t)=>{const r=g(e,t.table);if(r===void 0)return"unknown-table";const n=K(r);if(n===void 0)return"unknown-table";if(n.getProperties().some(o=>o.getKind()===i.PropertyAssignment&&o.getNameNode().getText().replaceAll(/["']/gu,"")===t.column))return"duplicate-column";n.addPropertyAssignment({initializer:`v.optional(${t.validator})`,name:t.column})},S=(e,t)=>{if(e===void 0)return"unknown-table";const r=e.getInitializer();if(r===void 0)return"unknown-table";if(m(r).some(l=>{const a=l.getExpression();if(a.getKind()!==i.PropertyAccessExpression)return!1;const x=a.asKindOrThrow(i.PropertyAccessExpression),[f]=l.getArguments();return x.getName()==="index"&&f?.getKind()===i.StringLiteral&&f.asKindOrThrow(i.StringLiteral).getLiteralText()===t.name}))return"duplicate-index";const s=t.fields.map(l=>JSON.stringify(l)).join(", "),o=t.unique===!0?", { unique: true }":"";e.setInitializer(`${r.getText()}.index(${JSON.stringify(t.name)}, [${s}]${o})`)},L=(e,t)=>{if(T(t)==="destructive")return{ok:!1,reason:"destructive"};const r=t,n=h(r);if(n!==void 0)return{ok:!1,reason:n};const s=O(e);if("reason"in s)return{ok:!1,reason:s.reason};const{object:o,sourceFile:l}=s;let a;return r.kind==="addTable"?a=w(o,r):r.kind==="addOptionalColumn"?a=k(o,r):a=S(g(o,r.table),r),a!==void 0?{ok:!1,reason:a}:{ok:!0,text:l.getFullText()}};export{L as applyAdditiveEdit,T as classifyEdit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{modify as p,applyEdits as r}from"jsonc-parser";const s={formattingOptions:{insertSpaces:!0,tabSize:4}},a=(t,i,n)=>{const o=p(t,[...i],n,s);return o.length>0?r(t,o):t};export{s as FORMATTING,a as applyModify};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readProjectConfigLiterals as s,readProjectTarget as c}from"@lunora/codegen";import n from"./canonicalPath-DrfMiT3U.mjs";import{BUILD_TARGET_ENV as i,BUILD_ROOT_ENV as a}from"./BUILD_ROOT_ENV-Dg4MV3wY.mjs";import{DEFAULT_DEPLOY_TARGET as p,resolveDeployDriver as f}from"./DEFAULT_DEPLOY_TARGET-CAJl2nEI.mjs";const d=e=>{if(typeof e=="boolean")return e;if(e!==null&&typeof e=="object")return!0},P=e=>d(s(e).remote),T=e=>c(e),g=(e,t)=>t??T(e)??p,j=(e,t)=>{const r=g(e,t);return f(r),r},v=(e,t)=>{const r=process.env[i],o=process.env[a];if(!(o===void 0||o===""||n(o)!==n(t))&&r!==void 0&&r!==""&&r!==e)throw new Error(`the plugin resolves target "${e}" but the CLI resolved "${r}" for this run; set the same target in the plugin options and the project config`)};export{v as assertBuildTargetMatches,d as interpretRemote,P as readProjectRemotePreference,T as readProjectTarget,g as resolveProjectTarget,j as resolveTargetOrThrow};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{LunoraError as n}from"@lunora/errors";import{lunoraLine as i}from"./LUNORA_TAG-DQTGPqcJ.mjs";import{validateWranglerProject as c}from"./UNEXPORTED_CLASS_MARKER-Zw1oiigQ.mjs";const m=(e,o,t)=>{const r=c({cache:e.cache,projectRoot:e.projectRoot,schemaDir:e.schemaDir});if(!r.wranglerPath)throw new n("INTERNAL",["[lunora] wrangler.jsonc not found.",` searched in: ${e.projectRoot}`," create a wrangler.jsonc declaring at least the SHARD durable object binding."].join(`
|
|
2
|
+
`));for(const a of r.report.warnings)o(i(`wrangler validator: ${a}`));if(r.problems.length>0)throw new n("INTERNAL",["[lunora] wrangler configuration is missing bindings required by your schema.",` file: ${r.wranglerPath}`,"",...r.problems.map(a=>` - ${a}`),"",` ${t}`].join(`
|
|
3
|
+
`))};export{m as assertWranglerSatisfiesSchema};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{existsSync as D,readFileSync as k,rmSync as x,writeFileSync as L}from"node:fs";import{LunoraError as E}from"@lunora/errors";import{a as C}from"./env-flag-u4B05gLp.mjs";import{i as w}from"./is-plain-object-CWxHeOY1.mjs";import{join as I}from"node:path";const R="default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'",j="accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()",H=31536e3,F={coop:void 0,csp:void 0,enabled:!1,frameOptions:void 0,hsts:void 0,permissionsPolicy:void 0,referrerPolicy:void 0},M=s=>{if(s===!1)return;const e=s===void 0||s===!0?{}:s,r=e.maxAge??H,t=e.includeSubDomains??!0;return`max-age=${String(r)}${t?"; includeSubDomains":""}${e.preload===!0?"; preload":""}`},T=(s,e)=>e!==void 0?["frame-ancestors 'self'",...e].join(" "):s==="DENY"?"frame-ancestors 'none'":s==="SAMEORIGIN"?"frame-ancestors 'self'":void 0,U=/^[a-z][\d+.a-z-]*:\/\/(?:\*\.)?[\d.a-z-]+(?::\d{1,5})?$/iu,$=s=>[...s].every(e=>e===" "||e>=" "&&e!==""&&e<="ÿ"),G=["same-origin","same-origin-allow-popups","unsafe-none"],Y=["DENY","SAMEORIGIN"],S=["includeSubDomains","maxAge","preload"],_=["csp","permissionsPolicy","referrerPolicy"],b=[..._,"crossOriginOpenerPolicy","frameAncestors","frameOptions","hsts"],p=s=>s.map(e=>JSON.stringify(e)).join(", "),W=(s,e)=>{if(typeof s=="boolean")return s;if(!w(s)){e.push("security.headers.hsts must be a boolean or an object { maxAge?, includeSubDomains?, preload? }");return}for(const n of Object.keys(s).filter(i=>!S.includes(i)))e.push(`security.headers.hsts.${n} is not an option (expected ${p(S)})`);const{includeSubDomains:r,maxAge:t,preload:o}=s;t!==void 0&&!(typeof t=="number"&&Number.isSafeInteger(t)&&t>=0)&&e.push(`security.headers.hsts.maxAge must be a whole number of seconds (got ${JSON.stringify(t)})`);for(const[n,i]of[["includeSubDomains",r],["preload",o]])i!==void 0&&typeof i!="boolean"&&e.push(`security.headers.hsts.${n} must be a boolean`);return{...r===void 0?{}:{includeSubDomains:r},...t===void 0?{}:{maxAge:t},...o===void 0?{}:{preload:o}}},v=(s,e,r,t)=>{if(e===void 0||e===!1||r.includes(e))return e;t.push(`security.headers.${s} must be one of ${p(r)} or false (got ${JSON.stringify(e)})`)},B=(s,e)=>{if(s!==void 0){if(!Array.isArray(s)){e.push('security.headers.frameAncestors must be an array of origins like ["https://partner.example"]');return}for(const r of s)(typeof r!="string"||!U.test(r)||!$(r))&&e.push(`security.headers.frameAncestors entry ${JSON.stringify(r)} is not an origin like "https://partner.example"`);return[...s]}},X=s=>{if(s===void 0||typeof s=="boolean")return{ok:!0,value:s};if(!w(s))return{ok:!1,problems:[`security.headers must be a boolean or an object (got ${Array.isArray(s)?"an array":JSON.stringify(s)})`]};const e=Object.keys(s).filter(t=>!b.includes(t)).map(t=>`security.headers.${t} is not an option (expected ${p(b)})`),r={};for(const t of _){const o=s[t];o===void 0||o===!1?r[t]=o:typeof o!="string"?e.push(`security.headers.${t} must be a string or false`):$(o)?r[t]=o:e.push(`security.headers.${t} contains a line break or control character`)}return r.crossOriginOpenerPolicy=v("crossOriginOpenerPolicy",s.crossOriginOpenerPolicy,G,e),r.frameOptions=v("frameOptions",s.frameOptions,Y,e),r.frameAncestors=B(s.frameAncestors,e),r.hsts=s.hsts===void 0?void 0:W(s.hsts,e),r.frameAncestors!==void 0&&typeof r.csp=="string"&&e.push("security.headers.frameAncestors cannot be combined with a csp string: put the frame-ancestors directive in the csp"),r.frameAncestors!==void 0&&r.frameOptions==="DENY"&&e.push('security.headers.frameAncestors cannot be combined with frameOptions: "DENY"'),r.frameAncestors!==void 0&&r.csp===!1&&e.push("security.headers.frameAncestors needs the Content-Security-Policy that carries it; it cannot be combined with csp: false"),e.length>0?{ok:!1,problems:e}:{ok:!0,value:Object.fromEntries(Object.entries(r).filter(([,t])=>t!==void 0))}},ge=(s,e)=>s??(C(e)?!1:void 0),V=s=>{if(s===!1)return F;const e=s===void 0||s===!0?{}:s,r=e.frameAncestors!==void 0||e.frameOptions===!1?void 0:e.frameOptions??"SAMEORIGIN",t=["base-uri 'none'","object-src 'none'",T(r,e.frameAncestors)].filter(n=>n!==void 0).join("; ");let o;return typeof e.csp=="string"?o={htmlValue:e.csp,value:e.csp}:e.csp!==!1&&(o={htmlValue:t,value:R}),{coop:e.crossOriginOpenerPolicy===!1?void 0:e.crossOriginOpenerPolicy??"same-origin-allow-popups",csp:o,enabled:!0,frameOptions:r,hsts:M(e.hsts),permissionsPolicy:e.permissionsPolicy===!1?void 0:e.permissionsPolicy??j,referrerPolicy:e.referrerPolicy===!1?void 0:e.referrerPolicy??"strict-origin-when-cross-origin"}},J="_headers",h="# BEGIN lunora-managed: rewritten on every build. Put your own rules outside this block.",m="# END lunora-managed",d=100,O=2e3,K=s=>{const e=X(s);if(!e.ok)throw new E("CONFIG_INVALID",`[lunora] cannot write _headers: ${e.problems.join("; ")}`);const r=V(e.value);return r.enabled?[["Strict-Transport-Security",r.hsts],["X-Content-Type-Options","nosniff"],["X-Frame-Options",r.frameOptions],["Referrer-Policy",r.referrerPolicy],["Permissions-Policy",r.permissionsPolicy],["Cross-Origin-Opener-Policy",r.coop],["Content-Security-Policy",r.csp?.htmlValue]].filter(o=>o[1]!==void 0):[]},z="public, max-age=31536000, immutable",q=s=>s.split(`
|
|
2
|
+
`).map(e=>e.endsWith("\r")?e.slice(0,-1):e),A=s=>{let e=0,r=s.length;for(;e<r&&s[e]?.trim()==="";)e+=1;for(;r>e&&s[r-1]?.trim()==="";)r-=1;return s.slice(e,r)},Q=s=>{const e=q(s),r=e.indexOf(h);if(r===-1)return A(e);const t=e.indexOf(m,r);return t===-1?void 0:A([...e.slice(0,r),...e.slice(t+1)])},P=s=>s.startsWith(" ")||s.startsWith(" "),Z=s=>s!==""&&!P(s)&&!s.startsWith("#"),ee=s=>{if(!s.startsWith("https://"))return s;const e=s.indexOf("/",8);return e===-1?"/":s.slice(e)},se=s=>{const e=[];let r=new Set;for(const t of s){if(Z(t)){e.push({rule:t.trim(),sets:[]}),r=new Set;continue}const o=e.at(-1),n=t.trim();if(o===void 0||!P(t)||n.startsWith("#"))continue;if(n.startsWith("!")){r.add(n.slice(1).trim().toLowerCase());continue}const i=n.indexOf(":");if(i>0){const a=n.slice(0,i).trim().toLowerCase();o.sets.push({detached:r.has(a),name:a})}}return e},re=s=>{const e=new Set,r=[];for(const{rule:t,sets:o}of s)for(const{detached:n,name:i}of o)t==="/*"?e.add(i):n||r.push({name:i,rule:t});return{stacked:r,taken:e}},te=(s,e)=>{const r=ee(s).split("/").slice(1),t=e.split("/");for(const[o,n]of r.entries()){const i=t[o];if(n.includes("*")||i===void 0)return!0;if(!n.startsWith(":")&&n!==i)return!1}return!1},oe=(s,e)=>s.some(({rule:r,sets:t})=>t.some(({name:o})=>o==="cache-control")&&te(r,e)),ne=s=>[h,...s.flatMap(e=>[e.path,...e.headers.map(([r,t])=>` ${r}: ${t}`)]),m],N=/^frame-ancestors(?:\s|$)/iu,ie=s=>s.split(";").map(e=>e.trim()).filter(e=>e!==""&&!N.test(e)).join("; "),ae=(s,e,r)=>e?ie(s):(s.split(";").some(t=>N.test(t.trim()))&&r.push("your _headers rule for /* sets X-Frame-Options, but the csp in lunora.config carries a frame-ancestors directive, which browsers apply instead of X-Frame-Options; make the two agree"),s),ce=(s,e)=>{const r=` ${s}: ${e}`;if(r.length>O)throw new E("INTERNAL",`[lunora] the _headers line for ${s} would be ${String(r.length)} characters; Cloudflare ignores a line longer than ${String(O)}, which would leave every static page without it. Shorten security.headers in lunora.config: list fewer frameAncestors origins (one *.example.com entry covers its subdomains), or a shorter csp.`)},le=(s,e,r)=>{const t=[],o=[],n=[];for(const[i,a]of s){for(const l of e.stacked.filter(f=>f.name===i.toLowerCase()))o.push(`_headers rule "${l.rule}" sets ${i} on top of Lunora's default, so both values are sent; add "! ${i}" above it in that rule to replace the default`);if(e.taken.has(i.toLowerCase())){t.push(i);continue}const c=i==="Content-Security-Policy"&&e.taken.has("x-frame-options")?ae(a,r,o):a;ce(i,c),n.push([i,c])}return{deferred:t,rule:n.length===0?void 0:{headers:n,path:"/*"},warnings:o}},fe=(s,e,r)=>{const t=Math.max(0,d-e),o=s.slice(0,t),n=s.slice(t);return n.length>0&&r.push(`_headers already has ${String(e)} of your rules, and Cloudflare applies at most ${String(d)}; Lunora left out its ${n.map(i=>i.path).join(", ")} rule so yours still apply. Merge some of your rules to make room`),e>d&&r.push(`_headers has ${String(e)} rules of your own; Cloudflare ignores every rule past the ${String(d)}th`),o},de=(s,e)=>{const r=Q(s??"");if(r===void 0)return{deferred:[],text:s,warnings:[`_headers has "${h}" but no "${m}" line, so Lunora cannot tell its rules from yours and left the file as it is; put the END line back after the managed rules, or delete the managed block`]};const t=se(r),o=[],n=[],i=[],a=typeof e.headers!="object"||typeof e.headers.csp!="string",c=le(K(e.headers),re(t),a);o.push(...c.deferred),n.push(...c.warnings),c.rule!==void 0&&i.push(c.rule);const l=e.immutableDirectory?.replaceAll("\\","/").split("/").filter(g=>g!==""&&g!==".").join("/");l!==void 0&&l!==""&&(oe(t,l)?o.push("Cache-Control"):i.push({headers:[["Cache-Control",z]],path:`/${l}/*`}));const f=fe(i,t.length,n),u=f.length===0?[]:ne(f),y=r.length>0&&u.length>0?[...u,"",...r]:[...u,...r];return{deferred:o,text:y.length===0?void 0:`${y.join(`
|
|
3
|
+
`)}
|
|
4
|
+
`,warnings:n}},Se=(s,e)=>{const r=I(s,J),t=D(r)?k(r,"utf8"):void 0,o=de(t,e);return o.text===void 0?(t!==void 0&&x(r,{force:!0}),{deferred:o.deferred,path:void 0,warnings:o.warnings}):(o.text!==t&&L(r,o.text,"utf8"),{deferred:o.deferred,path:r,warnings:o.warnings})};export{ge as e,de as m,Se as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as o,statSync as i}from"node:fs";import{createRequire as n}from"node:module";import{normalize as u,join as a,relative as c,isAbsolute as d,dirname as l}from"node:path";const j=(t,s=import.meta.url)=>{try{const r=n(s);return{script:o(r.resolve("@lunora/studio/standalone/studio.js")),styles:o(r.resolve("@lunora/studio/styles.css"))}}catch(r){const e=r instanceof Error?r.message:String(r);t?.warnOnce?.(`[lunora] studio assets unavailable (build @lunora/studio?): ${e}`);return}},S=(t=import.meta.url)=>{try{const s=n(t),r=i(s.resolve("@lunora/studio/standalone/studio.js")).mtimeMs,e=i(s.resolve("@lunora/studio/styles.css")).mtimeMs;return Math.max(r,e)}catch{return}},v=(t=import.meta.url)=>{try{return l(n(t).resolve("@lunora/studio/standalone/studio.js"))}catch{return}},m=(t,s)=>{if(s===""||s==="."||s===".."||s.includes("/")||s.includes("\\")||s.includes("\0"))return;const r=u(a(t,s)),e=c(t,r);if(!(e===""||e.startsWith("..")||d(e)||e.includes("/")||e.includes("\\")))return r},f=(t,s=import.meta.url)=>{const r=v(s);if(r===void 0)return;const e=m(r,t);if(e!==void 0)try{return o(e)}catch{return}},M=t=>t.endsWith(".js")||t.endsWith(".js.map"),W=t=>t.endsWith(".css")?"text/css; charset=utf-8":t.endsWith(".map")?"application/json; charset=utf-8":"text/javascript; charset=utf-8";export{W as assetContentType,M as isStandaloneModulePath,j as loadStudioAssets,f as readStandaloneAsset,m as resolveContainedFile,v as resolveStandaloneDirectory,S as studioAssetsStamp};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createHash as O,randomUUID as v}from"node:crypto";import{mkdirSync as _,rmSync as y,readFileSync as N,writeFileSync as I,linkSync as w,renameSync as R}from"node:fs";import{findWranglerFile as C,readWranglerJsonc as k}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{join as $}from"node:path";const E=["CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_","WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_"],p=e=>`${E[0]}${e}`,D="pnpm add -D @electric-sql/pglite @electric-sql/pglite-socket",m="postgres://postgres:postgres@127.0.0.1:1/postgres",A=(e,t,r)=>typeof t.localConnectionString=="string"&&t.localConnectionString!==""||E.some(o=>{const n=r[`${o}${e}`]??"";return n!==""&&n!==m}),H=(e,t,r=t.CLOUDFLARE_ENV,o)=>{const n=o??C(e),i=n===void 0?void 0:k(n).parsed,c=r===void 0||r===""?void 0:i?.env?.[r];return((c===void 0?i?.hyperdrive:c.hyperdrive)??[]).flatMap(a=>typeof a?.binding=="string"&&a.binding!==""&&!A(a.binding,a,t)?[a.binding]:[])},T=async({PGlite:e,PGLiteSocketServer:t,vector:r},o)=>{const n=await e.create({dataDir:o,...r===void 0?{}:{extensions:{vector:r}}});let i;try{i=new t({db:n,host:"127.0.0.1",maxConnections:16,port:0}),await i.start()}catch(a){throw await Promise.allSettled([i?.stop(),n.close()]),a}const[c="127.0.0.1",g="5432"]=i.getServerConn().split(":");return{connectionString:`postgres://postgres:postgres@${c}:${g}/postgres`,stop:async()=>{try{await i.stop()}finally{await n.close()}}}},P=/[^\w-]/gu,F=e=>{const t=e.replaceAll(P,"_");return t===e?e:`${t}-${O("sha256").update(e).digest("hex").slice(0,8)}`},q=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},x=e=>{try{const t=JSON.parse(N($(e,"package.json"),"utf8")),r=new Set([...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{})]);return r.has("mysql2")&&!r.has("pg")&&!r.has("postgres")}catch{return!1}},f=new Set,G=()=>{for(const e of f)y(e,{force:!0});f.clear()};let h=!1;const U=()=>{h||(h=!0,process.once("exit",G))},S=e=>{try{const[t="",r=""]=N(e,"utf8").split(`
|
|
2
|
+
`),o=Number.parseInt(t,10);return Number.isInteger(o)?{kind:"pid",pid:o,token:r}:{kind:"garbage",pid:-1,token:""}}catch(t){return{kind:t.code==="ENOENT"?"gone":"unreadable",pid:-1,token:""}}},L=e=>e.kind==="pid"&&e.pid!==process.pid&&q(e.pid),j=(e,t)=>{try{w(e,t)}catch(r){if(r.code!=="EEXIST")throw r;return}return f.add(t),U(),{release:()=>{f.delete(t)&&y(t,{force:!0})}}},W=(e,t)=>{const r=`${e}.stale.${v()}`;try{R(e,r)}catch{return}const o=S(r);try{if(o.token!==t.token&&L(o)){try{w(r,e)}catch{}return{holder:o.pid}}return}finally{y(r,{force:!0})}},M=e=>{const t=`${e}.${String(process.pid)}.${v()}`;I(t,`${String(process.pid)}
|
|
3
|
+
${v()}`,"utf8");try{for(let r=0;r<3;r+=1){const o=j(t,e);if(o!==void 0)return o;if(f.has(e))return{holder:process.pid};const n=S(e);if(n.kind==="unreadable"||L(n))return{holder:n.pid};const i=n.kind==="gone"?void 0:W(e,n);if(i!==void 0)return i}return{holder:S(e).pid}}finally{y(t,{force:!0})}},V=/@electric-sql\/pglite/u,B=async()=>{try{const[{PGlite:e},{PGLiteSocketServer:t}]=await Promise.all([import("@electric-sql/pglite"),import("@electric-sql/pglite-socket")]),r=await import("@electric-sql/pglite-pgvector").then(o=>o.vector,()=>{});return{createServer:async o=>T({PGlite:e,PGLiteSocketServer:t,vector:r},o)}}catch(e){const{code:t,message:r}=e;if((t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND")&&V.test(r??""))return;throw e}},Q=async e=>{try{return{runtime:await e()}}catch(t){return{failure:t instanceof Error?t.message:String(t)}}},J=async(e,t,r)=>{try{const o=await e.createServer(t);return{connectionString:o.connectionString,stop:async()=>{try{await o.stop()}finally{r.release()}}}}catch(o){throw r.release(),o}},X=(e,t)=>`Hyperdrive binding ${e.map(r=>`"${r}"`).join(", ")}: the embedded Postgres is installed but failed to load (${t}), so \`ctx.sql\` will fail to connect in dev. Set ${p(e[0]??"<BINDING>")} to use a database of your own.`,Y=(e,t)=>{const r=e.map(n=>`"${n}"`).join(", "),o=p(e[0]??"<BINDING>");return t?`Hyperdrive binding ${r}: this project's SQL driver is mysql2, and the embedded database speaks PostgreSQL, so \`ctx.sql\` will fail to connect in dev. Set ${o} to a local MySQL connection string.`:`Hyperdrive binding ${r} has no local database, so \`ctx.sql\` will fail to connect in dev. Run \`${D}\` for an embedded Postgres, or set ${o}.`},te=async e=>{const t=e.env??process.env,r=H(e.projectRoot,t,void 0,e.wranglerConfigPath);if(r.length===0)return;const o=new Map,n=s=>{t[p(s)]=m,o.set(s,m)},i=[],c=async()=>{const s=i.splice(0),l=[...o];o.clear();for(const[d,u]of l)t[p(d)]===u&&Reflect.deleteProperty(t,p(d));await Promise.allSettled(s.map(async d=>d.stop()))},g=x(e.projectRoot),{failure:a,runtime:b}=g?{failure:void 0,runtime:void 0}:await Q(e.load??B);if(b===void 0){e.onWarning?.(a===void 0?Y(r,g):X(r,a));for(const s of r)n(s);return{bindings:[],stop:c}}try{for(const s of r){const l=$(e.projectRoot,".wrangler","state","lunora-pglite",F(s));_(l,{recursive:!0});const d=M(`${l}.lock`);if("holder"in d){e.onWarning?.(`Hyperdrive binding "${s}": another process (pid ${String(d.holder)}) has its embedded Postgres open, so \`ctx.sql\` will fail to connect here. Stop it, or set ${p(s)} to use a database of your own.`),n(s);continue}const u=await J(b,l,d);i.push({binding:s,stop:u.stop}),t[p(s)]=u.connectionString,o.set(s,u.connectionString)}}catch(s){e.onWarning?.(`Could not start the embedded Postgres for Hyperdrive: ${s instanceof Error?s.message:String(s)}`),await c();for(const l of r)n(l);return{bindings:[],stop:c}}return{bindings:i.map(({binding:s})=>s),stop:c}};export{H as bindingsNeedingDatabase,G as releaseHeldLocks,T as serveDatabase,te as startLocalHyperdrive};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{describeErrorLevelFindings as a,sortedUniqueNames as l}from"@lunora/codegen";import{LUNORA_TAG as d,advisoryLine as n}from"./LUNORA_TAG-DQTGPqcJ.mjs";const f=(r,i)=>{for(const e of r.advisories){const o=n(e.level,e.name,e.detail,e.remediation);e.level==="ERROR"?i.error(o):i.warn(o)}for(const e of r.platformDiagnostics){const o=n(e.level==="error"?"ERROR":"WARN",e.name,e.message,e.remediation);e.level==="error"?i.error(o):i.warn(o)}},v=(r,i={})=>{const{advisoryNames:e,platformDiagnosticNames:o}=a(r),s=l([...i.strictAdvisories===!1?[]:e,...o]);if(s.length===0)return;const t=s.length===1?"advisory/platform diagnostic":"advisories/platform diagnostics";return`${d} ${String(s.length)} ERROR-level ${t} (${s.join(", ")}) — see the log above for detail.`};export{v as blockingFindingsMessage,f as reportCodegenFindings};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{randomBytes as V}from"node:crypto";import{existsSync as j,readFileSync as x,writeFileSync as h,linkSync as B,rmSync as m,renameSync as L,statSync as O}from"node:fs";import{join as g}from"node:path";import{LunoraError as z}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as f,parseDevVariableLine as K,parseDevVariableEntries as E,DEV_VARS_NEWLINE as b}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import{MINTABLE_SECRET_KEYS as W,SHARD_RELAY_SECRET_KEY as y,CORE_SECRETS as P,mintableSecretKeysFor as U,SHARD_RELAY_HOST_PLACEHOLDER as Y,secretsForPackages as X}from"./PACKAGE_SECRETS_REGISTRY-CPWkw-qE.mjs";const H=e=>[...P,...X(e)],k=32,G=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],q=/[.*+?^${}()|[\]\\]/gu,J=/[a-z0-9]$/u,T=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:G.some(n=>{const r=n.replaceAll(q,String.raw`\$&`),s=J.test(n)?`(^|[^a-z0-9])${r}([^a-z0-9]|$)`:`(^|[^a-z0-9])${r}`;return new RegExp(s,"u").test(t)})},p=e=>V(e).toString("hex"),w=new Set([...W,y]),Q=(e,t,n=w)=>e===y?n.has(e)&&(t.trim()===""||t===Y):n.has(e),F=(e,t,n,r)=>Q(e,t,r)&&T(t)?n(k):void 0,me=(e=p)=>e(k),M=(e,t,n,r=w)=>e.split(b).map(o=>{const s=K(o),i=s?F(s.key,s.value,t,r):void 0;return!s||i===void 0?o:(n.push(s.key),`${s.key}="${i}"`)}),Z=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:M(e.exampleContent,e.randomHex??p,t).join(`
|
|
2
|
+
`),generatedKeys:t,status:"generate"}},ee=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
|
|
3
|
+
`,String.raw`\n`),A=e=>{const t=e.randomHex??p,n=new Set(E(e.existingContent).map(i=>i.key)),r=[],o=[],s=[];for(const i of e.exampleContent.split(b)){const a=K(i);if(!a||n.has(a.key))continue;const l=F(a.key,a.value,t,w);s.push(a.key),l===void 0?r.push(`${a.key}="${ee(a.value)}"`):(o.push(a.key),r.push(`${a.key}="${l}"`))}return{additions:r,generatedKeys:o,missingKeys:s}},R=e=>e.length>0?` (generated ${e.join(", ")})`:"",I=e=>`${e}.tmp-${String(process.pid)}`,v=(e,t,n={})=>{const r=I(e);try{h(r,t,{encoding:"utf8",...n}),L(r,e)}catch(o){throw m(r,{force:!0}),o}},te=(e,t)=>{try{return h(e,t,{encoding:"utf8",flag:"wx",mode:384}),!0}catch(n){if(n.code==="EEXIST")return!1;throw n}},N=(e,t)=>{const n=I(e);try{h(n,t,{encoding:"utf8",flag:"wx",mode:384});try{return B(n,e),!0}catch(r){const{code:o}=r;if(o==="EEXIST")return!1;if(o==="EPERM"||o==="ENOTSUP")return te(e,t);throw r}}finally{m(n,{force:!0})}},ge=(e,t)=>{v(e,t,{mode:384})},D=5,C=e=>{try{const t=O(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},ne=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,re=(e,t)=>{for(let n=0;n<D;n+=1){const r=C(e),o=x(e,"utf8"),s=t(o);if(s.length===0)return[];const i=o.length>0&&!o.endsWith(`
|
|
4
|
+
`)?`
|
|
5
|
+
`:"",a=`${o}${i}${s.join(`
|
|
6
|
+
`)}
|
|
7
|
+
`,l=`${e}.tmp-${String(process.pid)}-${V(6).toString("hex")}`;try{h(l,a,{encoding:"utf8",mode:384});const c=C(e);if(!ne(r,c)){m(l,{force:!0});continue}return L(l,e),s}catch(c){throw m(l,{force:!0}),c}}throw new z("INTERNAL",`Failed to append to ${e} after ${String(D)} attempts — a concurrent writer kept winning the race.`)},se=new Set(["EACCES","EISDIR","EPERM"]),$=e=>{try{return{content:x(e,"utf8"),kind:"read"}}catch(t){const{code:n}=t;if(n==="ENOENT")return{kind:"missing"};if(n!==void 0&&se.has(n))return{code:n,kind:"unreadable"};throw t}},he=async e=>{const t=g(e.cwd,u),n=$(t),r=$(g(e.cwd,f));for(const[d,S]of[[u,n],[f,r]])if(S.kind==="unreadable")return(e.warn??e.info)(`skipped the ${u} scaffold: ${d} is not a readable file (${S.code})`),{addedKeys:[],generatedKeys:[],status:"unreadable"};if(r.kind!=="read")return{addedKeys:[],generatedKeys:[],status:"no-example"};const o=r.content;if(n.kind!=="read"){const d=Z({devVarsExists:!1,exampleContent:o,randomHex:e.randomHex});return d.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${f} (secrets auto-filled)?`)?N(t,d.content)?(e.info(`Created ${u}${R(d.generatedKeys)}.`),{addedKeys:[],generatedKeys:d.generatedKeys,status:"generated"}):{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(e.info(`Skipped — copy ${f} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const s=A({existingContent:n.content,exampleContent:o,randomHex:e.randomHex});if(s.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const i=s.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(s.missingKeys.length)} key(s) from ${f} (${i}). Add them?`)))return e.info(`Skipped — add ${i} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const c=re(t,d=>A({existingContent:d,exampleContent:o,randomHex:e.randomHex}).additions).map(d=>K(d)?.key).filter(d=>d!==void 0);if(c.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const _=s.generatedKeys.filter(d=>c.includes(d));return e.info(`Updated ${u} — added ${c.join(", ")}${R(_)}.`),{addedKeys:c,generatedKeys:_,status:"augmented"}},oe=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
|
|
8
|
+
`),ie=(e,t)=>{const n=H(e).filter(r=>!t.has(r.key));return n.length===0?"":n.map(r=>oe(r)).join(`
|
|
9
|
+
|
|
10
|
+
`)},Ee=(e,t)=>{const n=g(e,f),r=j(n)?x(n,"utf8"):"",o=new Set(E(r).map(a=>a.key)),s=ie(t,o);if(s==="")return[];const i=r.length>0&&!r.endsWith(`
|
|
11
|
+
`)?`
|
|
12
|
+
`:"";return v(n,`${r}${i}
|
|
13
|
+
${s}
|
|
14
|
+
`),H(t).filter(a=>!o.has(a.key)).map(a=>a.key)},ae=e=>{const t=e.randomHex??p,n=[],r=M(e.existingContent,t,n,e.mintable),o=new Set(E(e.existingContent).map(c=>c.key)),s=[],i=[];for(const c of P)o.has(c.key)||(s.push(c.key),i.push(`# ${c.description}`,`${c.key}="${t(k)}"`));const a=r.join(`
|
|
15
|
+
`);if(i.length===0)return{addedKeys:s,content:a,filledKeys:n};const l=a===""||a.endsWith(`
|
|
16
|
+
`)?"":`
|
|
17
|
+
`;return{addedKeys:s,content:`${a}${l}${i.join(`
|
|
18
|
+
`)}
|
|
19
|
+
`,filledKeys:n}},pe=e=>{const t=g(e.cwd,u),n=$(t);if(n.kind==="unreadable")return{addedKeys:[],filledKeys:[],status:"unchanged"};const r=n.kind==="read",o=r?n.content:"",s=e.secretSources===void 0?void 0:U(e.secretSources),i=ae({existingContent:o,mintable:s,randomHex:e.randomHex}),a=E(i.content).find(c=>c.key===y)?.value;if(s!==void 0&&!s.has(y)&&a!==void 0&&T(a)&&e.info?.(`${y} is still a placeholder. This worker only calls an event log hosted elsewhere, so set it to the ${y} of the worker that hosts EventLogDO.`),i.filledKeys.length===0&&i.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};if(r)v(t,i.content,{mode:384});else if(!N(t,i.content))return{addedKeys:[],filledKeys:[],status:"unchanged"};const l=[...i.filledKeys,...i.addedKeys];return e.info?.(`Generated ${String(l.length)} dev secret(s) in ${u}: ${l.join(", ")}`),{addedKeys:i.addedKeys,filledKeys:i.filledKeys,status:r?"filled":"created"}};export{ie as buildPackageSecretsBlock,he as ensureDevVariables,Ee as ensureDevVarsExample,pe as fillDevSecrets,me as generateSecretValue,Q as isMintableSecretKey,T as isPlaceholderValue,ae as planDevSecretsFill,A as planDevVariablesAugment,Z as planDevVariablesScaffold,H as requiredSecrets,ge as writeDevVariablesFileAtomically};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{realpathSync as e}from"node:fs";import{resolve as n,dirname as o,join as c,basename as s}from"node:path";const i=r=>{const t=n(r);try{return e.native(t)}catch{const a=o(t);return a===t?t:c(i(a),s(t))}};export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as t}from"@lunora/errors";const i=(e,n)=>{if(typeof e!="string"||e.length===0)throw new t("BAD_REQUEST",`the celld projection needs the Worker's \`name\` to give the id-less binding "${n}" a fleet-wide id; set \`name\` in wrangler.jsonc`);return`${e}-${n}`};export{i as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{writeFileSync as $,rmSync as W,existsSync as w,readFileSync as A}from"node:fs";import{dirname as E,resolve as h,join as v,sep as y,relative as _,isAbsolute as B}from"node:path";import{MissingBuildOutputError as x}from"./MissingBuildOutputError-BAyekzof.mjs";import{D1_PLACEHOLDER_ID as F}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{findWranglerFile as K,readWranglerJsonc as Y}from"./WRANGLER_FILES-BF8PUjuo.mjs";import{DEV_VARS_FILE as G,parseDevVariableEntries as J}from"./DEV_VARS_EXAMPLE_FILE-hBT89IXh.mjs";import D from"./ensureGitignoreEntries-Tsk8Qkw7.mjs";import{c as k}from"./celld-binding-id-9MiUoteo.mjs";const q=".celld.wrangler.json",C=[".celld/",".celld.wrangler.json",".celld.service.*.wrangler.json"],M=v(".wrangler","deploy","config.json"),U=new Set(["$schema","assets","compatibility_date","compatibility_flags","containers","d1_databases","define","durable_objects","kv_namespaces","main","migrations","name","no_bundle","queues","r2_buckets","rules","services","triggers","vars","worker_loaders","workflows"]),H=new Set(["class_name","image","instance_type","max_instances","name","runtime"]),X=new Set(["CompiledWasm","Data","Text"]),z=/\r?\n/u,Q=/[!*?[]/u,Z=/[.[]/u,ee=["deleted_classes","new_classes","renamed_classes","transferred_classes"],c=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),I=e=>Array.isArray(e)&&e.length===0||c(e)&&Object.values(e).every(s=>I(s)),re=e=>Array.isArray(e)?e.map(s=>{if(!c(s))return s;const r=ee.find(t=>s[t]!==void 0);if(r!==void 0)throw new Error(`migration "${String(s.tag)}" uses \`${r}\`, which celld refuses — celld accepts only \`new_sqlite_classes\` migrations`);return{new_sqlite_classes:s.new_sqlite_classes,tag:s.tag}}):e,se=(e,s)=>Array.isArray(e)?e.map((r,t)=>c(r)?Object.fromEntries(Object.entries(r).filter(([n])=>{const i=H.has(n);return i||s.push(`containers[${String(t)}].${n}`),i})):r):e,te=(e,s)=>Array.isArray(e)?e.filter((r,t)=>{const n=c(r)&&typeof r.type=="string"&&X.has(r.type);return n||s.push(`rules[${String(t)}]`),n}):e,ne=e=>{const s=[],r={};for(const[t,n]of Object.entries(c(e)?e:{}))c(n)&&n.type==="workflow"?s.push({binding:t,class_name:t,name:n.name}):r[t]=n;return{bindings:s,rest:r}},ie=(e,s)=>Array.isArray(e)?e.map(r=>!c(r)||r.database_id!==F?r:typeof r.database_name=="string"?{...r,database_id:r.database_name}:typeof r.binding=="string"?{...r,database_id:k(s,r.binding)}:r):e,oe=(e,s)=>Array.isArray(e)?e.map(r=>c(r)&&r.id===void 0&&typeof r.binding=="string"?{...r,id:k(s,r.binding)}:r):e,N=e=>{const s=[],r={},t=ne(e.exports),n={...e,exports:t.rest};for(const[i,o]of Object.entries(n)){if(!U.has(i)){I(o)||s.push(i);continue}switch(i){case"containers":{r[i]=se(o,s);break}case"d1_databases":{r[i]=ie(o,e.name);break}case"kv_namespaces":{r[i]=oe(o,e.name);break}case"migrations":{r[i]=re(o);break}case"rules":{r[i]=te(o,s);break}default:r[i]=o}}if(t.bindings.length>0){const i=Array.isArray(r.workflows)?r.workflows:[];r.workflows=[...i,...t.bindings]}return{config:r,dropped:s}},ae=e=>{const[s=[],...r]=e.map(n=>h(n).split(y));let t=0;for(;t<s.length&&r.every(n=>n[t]===s[t]);)t+=1;return s.slice(0,t).join(y)||y},P=(e,s,r)=>{const t=i=>_(r,h(s,i)).split(y).join("/"),n={...e};return typeof e.main=="string"&&(n.main=t(e.main)),c(e.assets)&&typeof e.assets.directory=="string"&&(n.assets={...e.assets,directory:t(e.assets.directory)}),n},ce=e=>{const s=v(e,".assetsignore");if(!w(s))return;const r=A(s,"utf8").split(z).map(t=>t.trim()).filter(t=>t!==""&&!t.startsWith("#")).filter(t=>Q.test(t)||w(v(e,t)));if(r.length>0)throw new Error(`${s} hides ${r.join(", ")} from the assets, and celld has no .assetsignore — remove those files from ${e} first`);return s},le=(e,s)=>{const r=v(e,M);if(!w(r))throw new x(`wrangler \`main\` is the Vite virtual module "${s}", so celld deploys the Vite build output — and there is none yet. Run the project's build (\`vite build\`) first`);const{configPath:t}=JSON.parse(A(r,"utf8"));if(typeof t!="string")throw new TypeError(`${r} names no configPath`);return h(E(r),t)},S=e=>{const{parsed:s}=Y(e);if(s===void 0)throw new Error(`${e} is not valid JSONC`);return s},T=(e,s,r,t)=>{const{d1_databases:n}=e;if(!Array.isArray(n)||t===r)return e;const i=Array.isArray(s.d1_databases)?s.d1_databases.filter(o=>c(o)):[];return{...e,d1_databases:n.map(o=>{if(!c(o))return o;const a=i.find(m=>m.binding===o.binding),l=a?.migrations_dir,p=h(r,typeof l=="string"?l:"migrations"),d=w(p)?{...o,migrations_dir:_(t,p).split(y).join("/")}:o,f=a?.migrations_pattern;return typeof f=="string"?{...d,migrations_pattern:_(t,h(r,f)).split(y).join("/")}:d})}},de=(e,s,r,t)=>{const{main:n}=r;if(typeof n!="string"||!n.startsWith("virtual:"))return{fromBuild:!1,source:r,sourcePath:s};if(t==="dev")throw new Error(`wrangler \`main\` is the Vite virtual module "${n}", which only a Vite build can resolve — \`celld dev\` rebuilds from a source file. Use \`vite dev\` for the dev loop and \`lunora deploy\` to ship the build to celld, or point \`main\` at a worker file`);const i=le(e,n);return{fromBuild:!0,source:S(i),sourcePath:i}},fe=(e,s,r,t,n)=>{const i=s.filter(l=>Object.hasOwn(r,l.split(Z)[0]??l));let o=e;e.no_bundle!==void 0&&(o=Object.fromEntries(Object.entries(e).filter(([l])=>l!=="no_bundle")),i.push("no_bundle (celld re-bundles the build output)"));const a=t===void 0?void 0:ce(t);return a!==void 0&&i.push(`${_(n,a)} (matched no files)`),{assetsIgnore:a,projected:o,reported:i}},R=(e,s={})=>{const r=c(e.vars)?e.vars:{};return{...e,vars:{...r,WORKER_ENV:"development",...s}}},_e=(e,s)=>{const r=K(e);if(r===void 0)throw new Error(`no wrangler.jsonc or wrangler.json in ${e} — celld deploys from the project's Wrangler config`);const t=S(r),{fromBuild:n,source:i,sourcePath:o}=de(e,r,t,s),a=E(o),{config:l,dropped:p}=N(i),{assets:d}=i,f=c(d)&&typeof d.directory=="string"?h(a,d.directory):void 0,m=typeof i.main=="string"?E(h(a,i.main)):void 0,u=ae([a,m,f].filter(L=>L!==void 0));if(!n&&u!==a)throw new Error(`wrangler \`main\` and \`assets.directory\` must sit inside ${a} — celld resolves everything against the config's directory`);const b=T(P(l,a,u),t,e,u),g=n?fe(b,p,t,f,u):{assetsIgnore:void 0,projected:b,reported:p},j=s==="dev"?R(g.projected):g.projected,O=v(u,q),V=`${JSON.stringify(j,void 0,4)}
|
|
2
|
+
`;return{configPath:O,dropped:g.reported,vars:c(j.vars)?j.vars:{},write:()=>{if(!n)try{D(u,C)}catch{}$(O,V),g.assetsIgnore!==void 0&&W(g.assetsIgnore)}}},be=(e,s)=>{const r=S(s),t=E(s),{config:n,dropped:i}=N(r),o=typeof r.name=="string"?r.name:"service",a=_(e,t);if(a===".."||a.startsWith(`..${y}`)||B(a))throw new Error(`service ${o} (${t}) must sit inside ${e} — celld dev runs it from a config beside the app's`);const l=v(t,G),p=w(l)?Object.fromEntries(J(A(l,"utf8")).map(({key:b,value:g})=>[b,g])):{},d=T(P(n,t,e),r,t,e),f=v(e,`.celld.service.${o.replaceAll(/[^\w.-]/gu,"-")}.wrangler.json`),m=R(d,p),u=`${JSON.stringify(m,void 0,4)}
|
|
3
|
+
`;return{configPath:f,dropped:i,vars:c(m.vars)?m.vars:{},write:()=>{D(e,C),$(f,u)}}};export{be as a,_e as p};
|