@lunora/codegen 1.0.0-alpha.247 → 1.0.0-alpha.249
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/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{DEFAULT_TARGET-DbC2AqGy.mjs → DEFAULT_TARGET-DmGPe3Uk.mjs} +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-CyA07RIr.mjs → SCHEMA_SNAPSHOT_FILENAME-OKuFxV4v.mjs} +1 -1
- package/dist/packem_shared/{emitAgents-D_xvTOJU.mjs → emitAgents-DVgdbmYK.mjs} +1 -1
- package/dist/packem_shared/{emitApp-DsMk4tpo.mjs → emitApp-D7U-51na.mjs} +2 -2
- package/dist/packem_shared/{emitServer-BpNuS8Pn.mjs → emitServer-CptcZOTQ.mjs} +11 -11
- package/dist/packem_shared/{emitShard-DYvEfiTo.mjs → emitShard-Bo9uyTJF.mjs} +1 -1
- package/dist/packem_shared/loadProjectConfig-nNIDOrlR.mjs +1 -0
- package/dist/packem_shared/{readServiceBindings-D9Wi_qGU.mjs → readServiceBindings-CeQvSswr.mjs} +1 -1
- package/dist/packem_shared/{shard-B7t6dut5.mjs → shard-C0OSxk7u.mjs} +2 -2
- package/dist/packem_shared/{shard-runtime-CT_oddIR.mjs → shard-runtime-DvqfDuYO.mjs} +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/loadProjectConfig-6Zk3abcc.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -990,7 +990,7 @@ interface ModuleIR {
|
|
|
990
990
|
interface ServiceBindingIR {
|
|
991
991
|
/** The `services[].binding` Lunora writes, e.g. `SERVICE_DOCUMENT_PARSER`. */
|
|
992
992
|
binding: string;
|
|
993
|
-
/** The exported `WorkerEntrypoint` class
|
|
993
|
+
/** The exported `WorkerEntrypoint` class the binding targets; absent for the Worker's default export. */
|
|
994
994
|
entrypoint?: string;
|
|
995
995
|
/**
|
|
996
996
|
* The Worker name per `env.<name>` block the service's own wrangler config
|
|
@@ -1007,6 +1007,14 @@ interface ServiceBindingIR {
|
|
|
1007
1007
|
* route of its own: `""` for the top level, else the environment name.
|
|
1008
1008
|
*/
|
|
1009
1009
|
publicScopes: ReadonlyArray<string>;
|
|
1010
|
+
/**
|
|
1011
|
+
* The `WorkerEntrypoint` class the service is typed — and wired — as an RPC
|
|
1012
|
+
* stub of. Equal to {@link ServiceBindingIR.entrypoint} for an RPC service;
|
|
1013
|
+
* absent for a fetch service, including a named entrypoint declared
|
|
1014
|
+
* `rpc: false`, which is called with plain `fetch` and so needs no import of
|
|
1015
|
+
* the service's sources.
|
|
1016
|
+
*/
|
|
1017
|
+
rpcEntrypoint?: string;
|
|
1010
1018
|
/** The Worker's own `name` from its wrangler config — the `services[].service` target. */
|
|
1011
1019
|
worker: string;
|
|
1012
1020
|
/** Absolute path of the service's wrangler config. */
|
|
@@ -3855,6 +3863,8 @@ interface ProjectConfigLiterals {
|
|
|
3855
3863
|
interface ServiceLiteral {
|
|
3856
3864
|
dir: string;
|
|
3857
3865
|
entrypoint?: string;
|
|
3866
|
+
/** `false` binds a named `entrypoint` as a plain fetcher, without RPC types (so without importing the service's sources). */
|
|
3867
|
+
rpc?: false;
|
|
3858
3868
|
}
|
|
3859
3869
|
/** The structural slice of `lunora.config.*` Lunora reads. Unvalidated on purpose — see {@link loadProjectConfig}. */
|
|
3860
3870
|
interface LunoraProjectConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -990,7 +990,7 @@ interface ModuleIR {
|
|
|
990
990
|
interface ServiceBindingIR {
|
|
991
991
|
/** The `services[].binding` Lunora writes, e.g. `SERVICE_DOCUMENT_PARSER`. */
|
|
992
992
|
binding: string;
|
|
993
|
-
/** The exported `WorkerEntrypoint` class
|
|
993
|
+
/** The exported `WorkerEntrypoint` class the binding targets; absent for the Worker's default export. */
|
|
994
994
|
entrypoint?: string;
|
|
995
995
|
/**
|
|
996
996
|
* The Worker name per `env.<name>` block the service's own wrangler config
|
|
@@ -1007,6 +1007,14 @@ interface ServiceBindingIR {
|
|
|
1007
1007
|
* route of its own: `""` for the top level, else the environment name.
|
|
1008
1008
|
*/
|
|
1009
1009
|
publicScopes: ReadonlyArray<string>;
|
|
1010
|
+
/**
|
|
1011
|
+
* The `WorkerEntrypoint` class the service is typed — and wired — as an RPC
|
|
1012
|
+
* stub of. Equal to {@link ServiceBindingIR.entrypoint} for an RPC service;
|
|
1013
|
+
* absent for a fetch service, including a named entrypoint declared
|
|
1014
|
+
* `rpc: false`, which is called with plain `fetch` and so needs no import of
|
|
1015
|
+
* the service's sources.
|
|
1016
|
+
*/
|
|
1017
|
+
rpcEntrypoint?: string;
|
|
1010
1018
|
/** The Worker's own `name` from its wrangler config — the `services[].service` target. */
|
|
1011
1019
|
worker: string;
|
|
1012
1020
|
/** Absolute path of the service's wrangler config. */
|
|
@@ -3855,6 +3863,8 @@ interface ProjectConfigLiterals {
|
|
|
3855
3863
|
interface ServiceLiteral {
|
|
3856
3864
|
dir: string;
|
|
3857
3865
|
entrypoint?: string;
|
|
3866
|
+
/** `false` binds a named `entrypoint` as a plain fetcher, without RPC types (so without importing the service's sources). */
|
|
3867
|
+
rpc?: false;
|
|
3858
3868
|
}
|
|
3859
3869
|
/** The structural slice of `lunora.config.*` Lunora reads. Unvalidated on purpose — see {@link loadProjectConfig}. */
|
|
3860
3870
|
interface LunoraProjectConfig {
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CodegenDiagnosticError as E,diagnosticAt as u}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as v,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-D8SgT3OR.mjs";import{listLunoraSourceFiles as C}from"./packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs";import{default as R}from"./packem_shared/discoverAuthApiCalls-DoSN_yc3.mjs";import{CONTAINERS_FILENAME as T,discoverContainers as _}from"./packem_shared/CONTAINERS_FILENAME-C13yKxas.mjs";import{default as L}from"./packem_shared/discoverCrons-BEALHx1S.mjs";import{FLAGS_FILENAME as I,discoverFlags as P}from"./packem_shared/FLAGS_FILENAME-W5XQz_Po.mjs";import{default as G}from"./packem_shared/discoverFunctions-BcBzcG5x.mjs";import{default as b}from"./packem_shared/discoverHttpRoutes-CJHS4llq.mjs";import{default as y}from"./packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs";import{default as k}from"./packem_shared/discoverInserts-DpuLYPPd.mjs";import{d as B}from"./packem_shared/index-D7dKfGPh.mjs";import{default as V}from"./packem_shared/discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as Q,discoverMutators as q}from"./packem_shared/MUTATORS_FILENAME-DqWOgC5Z.mjs";import{default as J}from"./packem_shared/discoverNondeterministicCalls-CNJV2BiP.mjs";import{NOTIFY_FILENAME as X,discoverNotifyCalls as Z,discoverNotifyConfig as $}from"./packem_shared/NOTIFY_FILENAME-C1J_47et.mjs";import{default as re}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as te}from"./packem_shared/discoverQueries-BcdqjYky.mjs";import{QUEUES_FILENAME as ae,discoverQueues as ie}from"./packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs";import{default as fe}from"./packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs";import{default as pe}from"./packem_shared/discoverRlsProcedures-F4Cy-kSi.mjs";import{default as ne}from"./packem_shared/discoverRlsMetadata-mXBmPOGj.mjs";import{discoverSandboxUsage as xe}from"./packem_shared/discoverSandboxUsage-BnsPld5I.mjs";import{default as Ee}from"./packem_shared/discoverSchema-D5R60b4F.mjs";import{readServiceBindings as Ae,resolveServiceBindings as ve}from"./packem_shared/readServiceBindings-
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as s,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{formatAdvisories as m,lintSchema as f,toAdvisorContext as d}from"./packem_shared/formatAdvisories-DwmUKYuc.mjs";import{describeErrorLevelFindings as c,errorAdvisoryNames as n,errorPlatformDiagnosticNames as l,sortedUniqueNames as x}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CodegenDiagnosticError as E,diagnosticAt as u}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as v,discoverAgents as N}from"./packem_shared/AGENTS_FILENAME-D8SgT3OR.mjs";import{listLunoraSourceFiles as C}from"./packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs";import{default as R}from"./packem_shared/discoverAuthApiCalls-DoSN_yc3.mjs";import{CONTAINERS_FILENAME as T,discoverContainers as _}from"./packem_shared/CONTAINERS_FILENAME-C13yKxas.mjs";import{default as L}from"./packem_shared/discoverCrons-BEALHx1S.mjs";import{FLAGS_FILENAME as I,discoverFlags as P}from"./packem_shared/FLAGS_FILENAME-W5XQz_Po.mjs";import{default as G}from"./packem_shared/discoverFunctions-BcBzcG5x.mjs";import{default as b}from"./packem_shared/discoverHttpRoutes-CJHS4llq.mjs";import{default as y}from"./packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs";import{default as k}from"./packem_shared/discoverInserts-DpuLYPPd.mjs";import{d as B}from"./packem_shared/index-D7dKfGPh.mjs";import{default as V}from"./packem_shared/discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as Q,discoverMutators as q}from"./packem_shared/MUTATORS_FILENAME-DqWOgC5Z.mjs";import{default as J}from"./packem_shared/discoverNondeterministicCalls-CNJV2BiP.mjs";import{NOTIFY_FILENAME as X,discoverNotifyCalls as Z,discoverNotifyConfig as $}from"./packem_shared/NOTIFY_FILENAME-C1J_47et.mjs";import{default as re}from"./packem_shared/readPackageDependencies-C6h6FZuP.mjs";import{default as te}from"./packem_shared/discoverQueries-BcdqjYky.mjs";import{QUEUES_FILENAME as ae,discoverQueues as ie}from"./packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs";import{default as fe}from"./packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs";import{default as pe}from"./packem_shared/discoverRlsProcedures-F4Cy-kSi.mjs";import{default as ne}from"./packem_shared/discoverRlsMetadata-mXBmPOGj.mjs";import{discoverSandboxUsage as xe}from"./packem_shared/discoverSandboxUsage-BnsPld5I.mjs";import{default as Ee}from"./packem_shared/discoverSchema-D5R60b4F.mjs";import{readServiceBindings as Ae,resolveServiceBindings as ve}from"./packem_shared/readServiceBindings-CeQvSswr.mjs";import{SHAPES_FILENAME as ge,discoverShapes as Ce}from"./packem_shared/SHAPES_FILENAME-DRUFomCj.mjs";import{default as Re}from"./packem_shared/discoverStorageRulesMetadata-D3Ot9g5f.mjs";import{WORKFLOWS_FILENAME as Te,discoverWorkflows as _e}from"./packem_shared/WORKFLOWS_FILENAME-4-ib4HH-.mjs";import{emitApp as Le}from"./packem_shared/emitApp-D7U-51na.mjs";import{isD1GlobalTable as Ie,isHyperdriveGlobalTable as Pe}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ge,emitOpenApi as Ue,emitOpenApiModule as be}from"./packem_shared/buildOpenApiDocument-SxfElVzK.mjs";import{OPENRPC_VERSION as ye,buildOpenRpcDocument as je,emitOpenRpc as ke,emitOpenRpcModule as We}from"./packem_shared/OPENRPC_VERSION-Cr7Zzp6s.mjs";import{DEFAULT_TARGET as Ke,platformMatrixIds as Ve,readProjectTarget as ze,resolveCodegenTarget as Qe}from"./packem_shared/DEFAULT_TARGET-DmGPe3Uk.mjs";import{loadProjectConfig as we,readProjectConfigLiterals as Je}from"./packem_shared/loadProjectConfig-nNIDOrlR.mjs";import{SCHEMA_SNAPSHOT_FILENAME as Xe,createCodegenProject as Ze,findTsconfig as $e,refreshCodegenProject as er,runCodegen as rr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-OKuFxV4v.mjs";import{SchemaSnapshotParseError as tr,buildSchemaSnapshot as sr,evaluateSchemaDrift as ar,parseSchemaSnapshot as ir}from"./packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs";import{default as fr}from"./packem_shared/fingerprintSchemaSources-Cl1CJFeh.mjs";import{schemaFromIr as pr}from"./packem_shared/schemaFromIr-BWFnvCVg.mjs";import{LUNORA_ERROR_CODES as nr,validatorIrToJsonSchema as lr}from"./packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs";import{SDK_LANGUAGES as Sr,SDK_TARGETS as Er,generateSdk as ur}from"./packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs";import{redact as vr,secretKindOf as Nr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Cr}from"./packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs";import{default as Rr}from"./packem_shared/emitFunctions-BgNeOZt_.mjs";import{default as Tr}from"./packem_shared/emitServer-CptcZOTQ.mjs";import{e as hr}from"./packem_shared/shard-C0OSxk7u.mjs";import{G as Fr}from"./packem_shared/shared-DjUziztz.mjs";import{MESSAGE_SOLUTIONS as Pr,findSolutionByMessage as Dr}from"@lunora/errors";import{PROJECT_CONFIG_FILENAMES as Ur,findProjectConfigFile as br}from"./packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{B as yr,C as jr,D as kr}from"./packem_shared/shard-runtime-DvqfDuYO.mjs";import{emitApi as Br,emitCollections as Kr}from"./packem_shared/emitApi-DdW9RyGG.mjs";import{emitCrons as zr,emitScheduler as Qr,emitVectors as qr,emitWranglerCronTriggers as wr}from"./packem_shared/emitCrons-BRKXFGFu.mjs";import{emitDataModel as Yr}from"./packem_shared/emitDataModel-D3WuEZ4b.mjs";import{isTypedSchema as Zr}from"./packem_shared/isTypedSchema-CKzc3ioR.mjs";const e="0.0.0";export{v as AGENTS_FILENAME,T as CONTAINERS_FILENAME,E as CodegenDiagnosticError,Ke as DEFAULT_TARGET,I as FLAGS_FILENAME,Fr as GENERATED_HEADER,nr as LUNORA_ERROR_CODES,Pr as LUNORA_SOLUTION_RULES,Q as MUTATORS_FILENAME,X as NOTIFY_FILENAME,ye as OPENRPC_VERSION,Ur as PROJECT_CONFIG_FILENAMES,ae as QUEUES_FILENAME,Xe as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,Sr as SDK_LANGUAGES,Er as SDK_TARGETS,ge as SHAPES_FILENAME,tr as SchemaSnapshotParseError,e as VERSION,Te as WORKFLOWS_FILENAME,Ge as buildOpenApiDocument,je as buildOpenRpcDocument,sr as buildSchemaSnapshot,Ze as createCodegenProject,c as describeErrorLevelFindings,u as diagnosticAt,s as diffSchemaSnapshots,N as discoverAgents,R as discoverAuthApiCalls,_ as discoverContainers,L as discoverCrons,P as discoverFlags,G as discoverFunctions,b as discoverHttpRoutes,y as discoverHyperdriveCalls,k as discoverInserts,B as discoverMaskProcedures,V as discoverMigrations,q as discoverMutators,J as discoverNondeterministicCalls,Z as discoverNotifyCalls,$ as discoverNotifyConfig,te as discoverQueries,ie as discoverQueues,fe as discoverR2sqlCalls,ne as discoverRlsMetadata,pe as discoverRlsProcedures,xe as discoverSandboxUsage,Ee as discoverSchema,Ce as discoverShapes,Re as discoverStorageRulesMetadata,_e as discoverWorkflows,yr as emitAgents,Br as emitApi,Le as emitApp,Kr as emitCollections,jr as emitContainers,zr as emitCrons,Yr as emitDataModel,Cr as emitDrizzleSchema,Rr as emitFunctions,Ue as emitOpenApi,be as emitOpenApiModule,ke as emitOpenRpc,We as emitOpenRpcModule,Qr as emitScheduler,Tr as emitServer,hr as emitShard,qr as emitVectors,kr as emitWorkflows,wr as emitWranglerCronTriggers,n as errorAdvisoryNames,l as errorPlatformDiagnosticNames,ar as evaluateSchemaDrift,Dr as findLunoraSolution,br as findProjectConfigFile,$e as findTsconfig,fr as fingerprintSchemaSources,m as formatAdvisories,ur as generateSdk,Ie as isD1GlobalTable,Pe as isHyperdriveGlobalTable,Zr as isTypedSchema,f as lintSchema,C as listLunoraSourceFiles,we as loadProjectConfig,ir as parseSchemaSnapshot,Ve as platformMatrixIds,re as readPackageDependencies,Je as readProjectConfigLiterals,ze as readProjectTarget,Ae as readServiceBindings,vr as redact,er as refreshCodegenProject,Qe as resolveCodegenTarget,ve as resolveServiceBindings,rr as runCodegen,pr as schemaFromIr,Nr as secretKindOf,a as serializeSchemaSnapshot,x as sortedUniqueNames,d as toAdvisorContext,lr as validatorIrToJsonSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h,CELLD_CAPABILITIES as b}from"@lunora/platform";import{readProjectConfigLiterals as g}from"./loadProjectConfig-
|
|
1
|
+
import{NODE_CAPABILITIES as f,CLOUDFLARE_CAPABILITIES as h,CELLD_CAPABILITIES as b}from"@lunora/platform";import{readProjectConfigLiterals as g}from"./loadProjectConfig-nNIDOrlR.mjs";const c="cloudflare",v=t=>{const{target:e}=g(t);return e!==void 0&&e.length>0?e:void 0},A=(t,e)=>e??v(t)??c,L=(t,e)=>{if(e!==void 0)return[];const{target:a,unreadable:r}=g(t);return r!==!0||a!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${c}" surface was emitted. \`runCodegen\` resolves the target synchronously, which means it reads literals only.`,name:"platform_unreadable_target",remediation:`Write \`target\` as a string literal on the config's default export (\`export default { target: "${c}" }\`), or pass \`--target\`.`,target:c}]},u={celld:b,cloudflare:h,node:f},C=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),w={access:null,ai:"ai",analytics:"analytics",browser:"browser",container:"containers",flags:null,hyperdrive:"hyperdrive",images:"images",kv:"keyValueStore",mail:"mail",notify:null,payments:null,pipelines:"pipelines",r2sql:null,scheduler:"scheduler",storage:"objectStorage",vectors:"vectorStore",workflows:"workflows",x402:null},S=["agents","commitOrderedTables","containerEgressPolicy","containerRuntimeScheduling","containerSandboxTools","cronTriggers","crossShardFanout","durableStreams","globalTables","queues","relationGraph","secrets","services","topics","vectorStore","workerLoaders","workflowRollback","workflowSchedules"],m={agents:"durable agents (`defineAgent`)",commitOrderedTables:"commit-ordered tables (`.commitOrdered()`)",containerEgressPolicy:"container egress policies (`defineContainer({ allowedHosts | deniedHosts | interceptHttps })`)",containerRuntimeScheduling:'per-instance container images and snapshots (`defineContainer({ schedulingPolicy: "durable_object" })`)',containerSandboxTools:"container sandbox helpers — files, directory backups, bucket mounts (`defineContainer({ sandbox: true })`)",cronTriggers:"declared cron triggers (`cronJobs()`)",crossShardFanout:"cross-shard fan-out queries (a `.shardBy(...)` schema)",durableStreams:"durable streams (`.stream(handler, { durable: true })`)",globalTables:"global tables (`.global()`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",services:"service bindings to sibling Workers (`lunora.config` `services`)",topics:"pub/sub topics (`defineTopic` / `defineSubscription`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)",workflowSchedules:"scheduled workflow instances (`defineWorkflow({ schedules })`)"},y=(t,e,a)=>({level:"error",message:`${e.name} does not support ${m[t]}, which this app declares.`,name:"platform_unsupported_feature",remediation:`Remove the declaration, or deploy to a target whose capability matrix marks "${t}" as native or emulated.`,target:a}),T=(t,e,a)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${m[t]}, which this app declares. Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${t}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than letting the app deploy onto a primitive the host may not provide.`,target:a}),k=t=>{const{diagnostics:e,gatedSignals:a,matrix:r,reported:n,signals:d,target:i}=t;for(const s of S){if(d[s]!==!0)continue;const o=r.features[s]?.level;o!=="unsupported"&&o!==void 0||(a[s]=!1,!n.has(s)&&e.push(o==="unsupported"?y(s,r,i):T(s,r,i)))}},_=(t,e,a,r={})=>{const n={...t},d={...r},i=[],s=new Set;for(const[o,l]of Object.entries(w)){if(l===null||!t[o])continue;const p=e.features[l]?.level;p==="unsupported"?(n[o]=!1,s.add(l),i.push({feature:o,level:"error",message:`${e.name} does not support "${o}" (ctx.${o}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${o} usage, or deploy to a target whose capability matrix marks "${l}" as native or emulated.`,target:a})):p===void 0&&(n[o]=!1,s.add(l),i.push({feature:o,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${o}" (ctx.${o}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${l}" in the ${e.name} capability matrix as "native", "emulated", or "unsupported" — an undeclared feature fails closed rather than shipping a surface the host may not provide.`,target:a}))}return k({diagnostics:i,gatedSignals:d,matrix:e,reported:s,signals:r,target:a}),{diagnostics:i,signals:d,usage:n}},E=(t,e,a={})=>{const r=u[e];return r===void 0?{diagnostics:[{level:"error",message:`Unknown deploy target "${e}" — no capability matrix is registered for it. Codegen emitted the full Cloudflare surface un-gated.`,name:"platform_unknown_target",remediation:`Use a registered target (${Object.keys(u).join(", ")}) or install the target's @lunora/platform-${e} package.`,target:e}],signals:{...a},usage:{...t}}:_(t,r,e,a)},I=t=>{const e=u[t];if(e===void 0)return;const a=Object.entries(e.features).filter(([,r])=>r.level==="unsupported").map(([r])=>r).toSorted((r,n)=>r.localeCompare(n));return{id:e.id,name:e.name,unsupported:a}};export{w as CAPABILITY_TO_FEATURE,c as DEFAULT_TARGET,_ as gateAgainstMatrix,E as gatePlatformFeatures,C as platformMatrixIds,v as readProjectTarget,L as readTargetDiagnostics,A as resolveCodegenTarget,I as studioPlatformFor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as w,mkdirSync as an,readFileSync as ls,writeFileSync as cn,rmSync as ln}from"node:fs";import{join as x,dirname as he}from"node:path";import{performance as _e}from"node:perf_hooks";import{runAdvisor as un}from"@lunora/advisor";import{LunoraError as j}from"@lunora/errors";import{SyntaxKind as l,Node as i,VariableDeclarationKind as dn,Project as Ot}from"ts-morph";import{serializeSchemaSnapshot as fn}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{toAdvisorContext as pn}from"./formatAdvisories-DwmUKYuc.mjs";import{readProjectConfigLiterals as gn}from"./loadProjectConfig-
|
|
1
|
+
import{existsSync as w,mkdirSync as an,readFileSync as ls,writeFileSync as cn,rmSync as ln}from"node:fs";import{join as x,dirname as he}from"node:path";import{performance as _e}from"node:perf_hooks";import{runAdvisor as un}from"@lunora/advisor";import{LunoraError as j}from"@lunora/errors";import{SyntaxKind as l,Node as i,VariableDeclarationKind as dn,Project as Ot}from"ts-morph";import{serializeSchemaSnapshot as fn}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{toAdvisorContext as pn}from"./formatAdvisories-DwmUKYuc.mjs";import{readProjectConfigLiterals as gn}from"./loadProjectConfig-nNIDOrlR.mjs";import{a as Rt,d as mn,r as hn}from"./modules-DyCocr1e.mjs";import{QUEUES_FILENAME as vn,discoverQueueDeclarations as xn}from"./QUEUES_FILENAME-RGwht3Xu.mjs";import{WORKFLOWS_FILENAME as En,discoverWorkflows as Sn}from"./WORKFLOWS_FILENAME-4-ib4HH-.mjs";import{r as yn}from"./json-data-Chfs2Cz5.mjs";import{s as Ne}from"./paths-C-9fwEgQ.mjs";import{G as An}from"./shared-DjUziztz.mjs";import{C as ve}from"./capabilities-DJJWVEtk.mjs";import{isD1GlobalTable as us,isHyperdriveGlobalTable as ds}from"./isD1GlobalTable-udvHAAzD.mjs";import{discoverAgents as bn}from"./AGENTS_FILENAME-D8SgT3OR.mjs";import{discoverContainers as Nn}from"./CONTAINERS_FILENAME-C13yKxas.mjs";import Pn from"./discoverCrons-BEALHx1S.mjs";import{diagnosticAt as ae}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as Pe}from"./module-specifiers-WF8iAydP.mjs";import{listLunoraSourceFiles as g,bindingKeyName as X,propertyKeyName as E,unwrapExpression as ne,listSecurityScanFiles as we,objectLiteralFromCallbackBody as fs,propertyInitializer as N,lunoraRelativePath as v,enclosingExportName as re,collectCallRows as O,findObjectProperty as F,collectSecurityCallRows as wn,RUN_METHODS as ps,functionReferenceSegments as gs,limitNameOf as ms,optionsObjectLiteral as hs,isContextIdentifier as Ve,handlerOf as In,isDatabaseAccessor as M,readTargetOf as vs}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import Tn from"./readPackageDependencies-C6h6FZuP.mjs";import{discoverSandboxUsage as Cn}from"./discoverSandboxUsage-BnsPld5I.mjs";import{resolveServiceBindings as Fn}from"./readServiceBindings-CeQvSswr.mjs";import On from"./discoverStorageRulesMetadata-D3Ot9g5f.mjs";import{a as y,c as B,d as xs,e as Rn}from"./classify-procedure-call-CmcShAze.mjs";import{i as kn}from"./ir-DBSvhNa-.mjs";import{gatePlatformFeatures as Ln,resolveCodegenTarget as Es,readTargetDiagnostics as Dn,studioPlatformFor as Mn}from"./DEFAULT_TARGET-DmGPe3Uk.mjs";import{b as Ss,e as Kn}from"./shard-C0OSxk7u.mjs";import _n from"./emitServer-CptcZOTQ.mjs";import{emitDataModel as $n}from"./emitDataModel-D3WuEZ4b.mjs";import{r as Ie,s as zn}from"./parse-validator-C6fHL7OS.mjs";import Un from"./discoverAuthApiCalls-DoSN_yc3.mjs";import{i as Bn,a as qn,e as jn,b as Wn,d as Vn,c as Hn}from"./unwrap-handler-return-DVY_kFF7.mjs";import Gn from"./discoverFunctions-BcBzcG5x.mjs";import Yn from"./discoverHttpRoutes-CJHS4llq.mjs";import Qn from"./discoverHyperdriveCalls-Bkbh4tG7.mjs";import Xn from"./discoverInserts-DpuLYPPd.mjs";import{m as Ze,a as Se,s as ys,d as Jn}from"./index-D7dKfGPh.mjs";import{e as As}from"./exported-procedure-chains-D48EXUVQ.mjs";import Zn from"./discoverMigrations-Dt7ywfZv.mjs";import{MUTATORS_FILENAME as er,isDefineMutatorCallee as tr,discoverMutators as sr}from"./MUTATORS_FILENAME-DqWOgC5Z.mjs";import nr from"./discoverNondeterministicCalls-CNJV2BiP.mjs";import{discoverNotifyConfig as rr,discoverNotifyCalls as or}from"./NOTIFY_FILENAME-C1J_47et.mjs";import ir from"./discoverQueries-BcdqjYky.mjs";import ar from"./discoverR2sqlCalls-30Wtbc0P.mjs";import cr from"./discoverRlsProcedures-F4Cy-kSi.mjs";import lr from"./discoverRlsMetadata-mXBmPOGj.mjs";import ur from"./discoverSchema-D5R60b4F.mjs";import{secretKindOf as dr,redact as fr,isHeuristicSecretKind as pr,isSecretishName as gr}from"./redact-Cy14LEnc.mjs";import{discoverShapes as mr}from"./SHAPES_FILENAME-DRUFomCj.mjs";import{emitApp as hr}from"./emitApp-D7U-51na.mjs";import{buildOpenApiDocument as vr,emitOpenApiModule as xr}from"./buildOpenApiDocument-SxfElVzK.mjs";import{buildOpenRpcDocument as Er,emitOpenRpcModule as Sr}from"./OPENRPC_VERSION-Cr7Zzp6s.mjs";import{buildSchemaSnapshot as yr}from"./SchemaSnapshotParseError-CPOXlFhI.mjs";import{emitCollections as Ar,emitSeed as br,emitApi as Nr}from"./emitApi-DdW9RyGG.mjs";import{C as Pr,D as wr,B as Ir,E as Tr}from"./shard-runtime-DvqfDuYO.mjs";import{emitCrons as Cr,emitScheduler as Fr,emitShardRegistry as Or,emitVectors as Rr,emitWranglerCronTriggers as kr}from"./emitCrons-BRKXFGFu.mjs";import Lr from"./emitDrizzleSchema-Cv0HtLR3.mjs";import Dr from"./emitFunctions-BgNeOZt_.mjs";const kt={error:"ERROR",info:"INFO",warn:"WARN"},Lt={ERROR:2,INFO:0,WARN:1},Mr=e=>({cacheKey:"advisor_min_severity_invalid",categories:["SCHEMA"],description:"`advisor.minSeverity` in `lunora.config.*` sets the lowest advisory level codegen reports and writes into `_generated/shard.ts`. Codegen reads it by parsing the file, so it has to be a string literal.",detail:e,facing:"INTERNAL",level:"WARN",metadata:{},name:"advisor_min_severity_invalid",remediation:'Set `advisor: { minSeverity: "info" | "warn" | "error" }` as a literal on the config\'s default export.',title:"`advisor.minSeverity` is not a level codegen can read, so every advisory was reported"}),Kr=(e,t)=>{const{advisor:s}=gn(e);if(s===void 0||s.minSeverity===void 0&&s.unreadable!==!0)return[...t];const{minSeverity:n}=s,o=n!==void 0&&Object.hasOwn(kt,n)?kt[n]:void 0;return o===void 0?[...t,Mr(n===void 0?"`advisor.minSeverity` is not a string literal codegen can read without evaluating the config: a computed value or key, or a spread that could set or override it.":`\`advisor.minSeverity\` is "${n}", which is not one of "info", "warn" or "error".`)]:t.filter(r=>Lt[r.level]>=Lt[o])},_r={call:"function",enqueue:"queue",invoke:"service",publish:"topic",schedule:"function"},bs=vn.replace(/\.ts$/u,""),$r="crons",zr=En.replace(/\.ts$/u,""),te=(e,t)=>`${Ne(e)}:${t}`,$e=(e,t,s)=>t===""?{reason:`the ${s} is not a string literal`}:{to:`${e}:${t}`},Ur=e=>[...e.callEdges.map(t=>{const s=t.target===void 0?{reason:t.reason??"unreadable target"}:{to:`${_r[t.kind]}:${t.target}`};return{exportName:t.exportName,file:t.file,kind:t.kind,line:t.line,...s}}),...e.queries.map(t=>({exportName:t.exportName,file:t.file,kind:"read",line:t.line,...$e("table",t.table,"table name")})),...[...e.inserts,...e.tableWrites].map(t=>({exportName:t.exportName,file:t.file,kind:"write",line:t.line,...$e("table",t.table,"written table")})),...e.workflowCalls.map(t=>({exportName:t.exportName,file:t.file,kind:"start",line:t.line,...$e("workflow",t.workflow,"workflow name")}))],Br=e=>[...e.queues.flatMap(t=>t.topic===void 0?[]:[{exportName:t.exportName,file:bs,from:`topic:${t.topic}`,kind:"subscribe",line:0,to:`queue:${t.exportName}`}]),...e.crons.map(t=>{const s=t.workflow===void 0?void 0:`workflow:${t.workflow.exportName}`,n=t.functionPath===void 0?void 0:`function:${t.functionPath}`,o=s??n;return{exportName:t.name,file:$r,from:`cron:${t.name}`,kind:"trigger",line:0,...o===void 0?{reason:"the cron has no target"}:{to:o}}})],qr=e=>new Map(e.flatMap(t=>t.tables.map(s=>[s,t.name]))),ze=(e,t)=>t===void 0?e:{...e,module:t},jr=e=>{const t=new Map,s=new Map,n=qr(e.modules),o=(r,a)=>{t.set(r.id,r),a!==void 0&&s.set(a,r.id)};for(const r of e.functions){const a=te(r.filePath,r.exportName),c=`${Ne(r.filePath)}.${r.exportName}`;o(ze({detail:r.kind,id:`function:${a}`,kind:"function",name:c},Rt(e.modules,r.filePath)),a)}for(const r of e.httpRoutes){const a=te(r.filePath,r.exportName);o(ze({id:`http:${a}`,kind:"http",name:`${r.method} ${r.path}`},Rt(e.modules,r.filePath)),a)}for(const r of e.schema.tables)o(ze({id:`table:${r.name}`,kind:"table",name:r.name},n.get(r.name)));for(const r of e.queues){const a=r.topic===void 0?{}:{detail:"subscription"};o({...a,id:`queue:${r.exportName}`,kind:"queue",name:r.exportName},te(bs,r.exportName))}for(const r of e.topics)o({id:`topic:${r.exportName}`,kind:"topic",name:r.exportName});for(const r of e.workflows)o({id:`workflow:${r.exportName}`,kind:"workflow",name:r.exportName},te(zr,r.exportName));for(const r of e.crons)o({detail:r.cron,id:`cron:${r.name}`,kind:"cron",name:r.name});for(const r of e.services){const a=r.rpcEntrypoint===void 0?"fetch":"rpc";o({detail:r.entrypoint===void 0?a:`${a} · ${r.entrypoint}`,id:`service:${r.name}`,kind:"service",name:r.worker})}return{nodes:t,sites:s}},Wr=e=>e===""?"inside a non-exported helper":e==="default"?"the default export is not a registered function":`"${e}" is not a registered function`,Vr=(e,t,s)=>{if("reason"in e)return{reason:e.reason};const n=e.from??t.get(te(e.file,e.exportName));return n===void 0?{reason:Wr(e.exportName)}:s.has(e.to)?{drawn:{from:n,kind:e.kind,to:e.to}}:{reason:`${e.to} is not declared`}},Ue=e=>`${e.from}|${e.kind}|${e.to}`,Hr=e=>`${e.file}|${String(e.line)}|${e.kind}|${e.reason}`,Gr=e=>{const{nodes:t,sites:s}=jr(e),n=new Map,o=new Map;for(const r of[...Br(e),...Ur(e)]){const a=Vr(r,s,t);if("drawn"in a)n.set(Ue(a.drawn),a.drawn);else{const c={file:r.file,kind:r.kind,line:r.line,reason:a.reason};o.set(Hr(c),c)}}return{edges:[...n.values()].toSorted((r,a)=>Ue(r).localeCompare(Ue(a))),nodes:[...t.values()].toSorted((r,a)=>r.id.localeCompare(a.id)),modules:e.modules.map(r=>({...r.description===void 0?{}:{description:r.description},...r.installed===!0?{installed:!0}:{},...r.ownsFolder===!1?{ownsFolder:!1}:{},name:r.name,tables:[...r.tables]})),unresolved:[...o.values()].toSorted((r,a)=>r.file.localeCompare(a.file)||r.line-a.line),version:1}},Yr=e=>`${An}export const architecture = ${yn(e,"Record<string, unknown>")};
|
|
2
2
|
`,Dt=(e,t="api")=>{const s=new Map;for(const n of e){const o=Ne(n),r=s.get(o);if(r===void 0){s.set(o,n);continue}if(r!==n){const a=t==="api"?`the generated api.ts would declare "${o}" twice and the dispatch key "${o}:<fn>" would be ambiguous`:`the generated api.ts would declare "${o}" twice in HttpStreamsRef and again in the httpStreams object literal`;throw new j("INTERNAL",`@lunora/codegen: "${r}" and "${n}" both map to the ${t} namespace "${o}" — ${a}. Rename one file so the two differ by more than a non-identifier character (\`-\`, \`.\`, \`/\` and \`_\` all sanitize to \`_\`).`,{status:500})}}},Qr=(e,t={})=>{const{hasVectors:s=!0,scheduler:n=!1,storage:o=!1,usage:r}=t,a=[];e.tables.some(c=>us(c))&&a.push({name:"@lunora/d1",reason:"`.global()` tables are D1-backed, so `_generated/app.ts` imports the D1 `ctx.db` adapter"}),e.tables.some(c=>ds(c))&&a.push({name:"@lunora/hyperdrive",reason:'`.global({ backend: "hyperdrive" })` tables route through `@lunora/hyperdrive/global`'},{name:"@lunora/sql-store",reason:'`.global({ backend: "hyperdrive" })` makes `_generated/app.ts` import the `SqlCtxDbOptions` / `SqlExec` types'}),n&&a.push({name:"@lunora/scheduler",reason:"a declared cron (or `ctx.scheduler` use) makes `_generated/app.ts` import `createScheduler`"}),o&&a.push({name:"@lunora/storage",reason:"a `v.storage()` column, a storage access rule (or `ctx.storage` use) makes `_generated/app.ts` import `createStorage`"}),e.vectorIndexes.length>0&&s&&a.push({name:"@lunora/bindings",reason:"`.vectorize()` indexes make `_generated/shard.ts` import `@lunora/bindings/vectors`"});for(const c of r===void 0?[]:ve)c.requiredPackage!==void 0&&r?.[c.key]===!0&&a.push({name:c.requiredPackage,reason:`\`ctx.${c.contextProperty??c.key}\` usage makes \`_generated/\` import \`${c.moduleSpecifier}\``});return a.filter((c,u)=>a.findIndex(d=>d.name===c.name)===u)},Xr=(e,t,s={})=>{if(t===void 0)return;const n=Qr(e,s).filter(r=>!t.has(r.name));if(n.length===0)return;const o=n.map(r=>` - ${r.name} — ${r.reason}`).join(`
|
|
3
3
|
`);throw new j("INTERNAL",`@lunora/codegen: this schema's generated code imports packages the project does not declare:
|
|
4
4
|
${o}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{x as i,q as r,B as n,o,C as g,s as F,l as p,E as u,v as l,n as f,m as d,p as k,D as w,u as C,t as Q}from"./shard-runtime-
|
|
1
|
+
import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{x as i,q as r,B as n,o,C as g,s as F,l as p,E as u,v as l,n as f,m as d,p as k,D as w,u as C,t as Q}from"./shard-runtime-DvqfDuYO.mjs";import"./shared-DjUziztz.mjs";export{i as buildDoTypeImports,r as emitAgentFragments,n as emitAgents,o as emitContainerFragments,g as emitContainers,F as emitPaymentFragments,p as emitQueueFragments,u as emitQueues,l as emitQueuesMetadataFragments,f as emitServiceFragments,d as emitTopicFragments,k as emitWorkflowFragments,w as emitWorkflows,C as emitWorkflowsMetadataFragments,Q as emitX402Fragments};
|
|
@@ -823,8 +823,8 @@ interface LunoraConfig<Env extends object = object> {
|
|
|
823
823
|
app?: (app: AppBuilder<Env>) => AppBuilder<Env>;
|
|
824
824
|
/** Opt into remote-binding dev without \`--remote\` or \`LUNORA_REMOTE\` on every run. A literal, for the same reason as \`target\`. */
|
|
825
825
|
remote?: boolean;
|
|
826
|
-
/** Sibling Workers the app calls through service bindings — key → its folder and, for RPC, the exported \`WorkerEntrypoint\` class. Becomes \`ctx.services.<key>\` in actions, a wrangler \`services[]\` entry, one \`lunora dev\` session and a services-first \`lunora deploy\`. Literals, for the same reason as \`target\`. */
|
|
827
|
-
services?: Record<string, { dir: string; entrypoint?: string }>;
|
|
826
|
+
/** Sibling Workers the app calls through service bindings — key → its folder and, for RPC, the exported \`WorkerEntrypoint\` class (\`rpc: false\` binds that class but calls it with plain \`fetch\`, without importing the service's sources). Becomes \`ctx.services.<key>\` in actions, a wrangler \`services[]\` entry, one \`lunora dev\` session and a services-first \`lunora deploy\`. Literals, for the same reason as \`target\`. */
|
|
827
|
+
services?: Record<string, { dir: string; entrypoint?: string; rpc?: false }>;
|
|
828
828
|
/** Deploy target id — \`lunora deploy\`/\`verify\` read it when no \`--target\` is passed. Must be a literal: \`runCodegen\` resolves it synchronously by PARSING this file, so a computed value is not seen — \`lunora verify\` reports \`platform_unreadable_target\` rather than defaulting in silence. */
|
|
829
829
|
target?: string;
|
|
830
830
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{relative as Ve,isAbsolute as Ge,sep as He}from"node:path";import{LunoraError as D}from"@lunora/errors";import{S as ze}from"./capabilities-DJJWVEtk.mjs";import{p as Ue}from"./ir-DBSvhNa-.mjs";import{a as h,G as Xe,u as Je,d as Ke}from"./shared-DjUziztz.mjs";const Ye=/\.([cm]?)tsx?$/u,Ze=(u,n=[])=>{const t=new Set;for(const a of u.tables)for(const s of Object.values(a.shape)){const d=Je(s);d.kind==="storage"&&typeof d.bucket=="string"&&d.bucket!==""&&t.add(d.bucket)}for(const a of n)a!==""&&a!=="default"&&t.add(a);return["default",...[...t].toSorted((a,s)=>a.localeCompare(s))]},st=({agents:u=[],containers:n=[],env:t,hasAccessFacade:a=!1,hasAi:s=!1,hasAnalytics:d=!1,hasBrowser:J=!1,hasVectors:K=!0,hasFlags:Y=!1,hasHyperdrive:Z=!1,hasImages:ee=!1,hasKv:te=!1,hasNotify:ae=!1,hasPayments:M=!1,hasPipelines:re=!1,hasR2sql:oe=!1,hasX402:S=!1,identity:l,queues:F=[],schema:W,generatedDirectory:Q="",services:b=[],storageRuleBuckets:ne=[],topics:
|
|
1
|
+
import{relative as Ve,isAbsolute as Ge,sep as He}from"node:path";import{LunoraError as D}from"@lunora/errors";import{S as ze}from"./capabilities-DJJWVEtk.mjs";import{p as Ue}from"./ir-DBSvhNa-.mjs";import{a as h,G as Xe,u as Je,d as Ke}from"./shared-DjUziztz.mjs";const Ye=/\.([cm]?)tsx?$/u,Ze=(u,n=[])=>{const t=new Set;for(const a of u.tables)for(const s of Object.values(a.shape)){const d=Je(s);d.kind==="storage"&&typeof d.bucket=="string"&&d.bucket!==""&&t.add(d.bucket)}for(const a of n)a!==""&&a!=="default"&&t.add(a);return["default",...[...t].toSorted((a,s)=>a.localeCompare(s))]},st=({agents:u=[],containers:n=[],env:t,hasAccessFacade:a=!1,hasAi:s=!1,hasAnalytics:d=!1,hasBrowser:J=!1,hasVectors:K=!0,hasFlags:Y=!1,hasHyperdrive:Z=!1,hasImages:ee=!1,hasKv:te=!1,hasNotify:ae=!1,hasPayments:M=!1,hasPipelines:re=!1,hasR2sql:oe=!1,hasX402:S=!1,identity:l,queues:F=[],schema:W,generatedDirectory:Q="",services:b=[],storageRuleBuckets:ne=[],topics:E=[],useUmbrella:se=!1,workflows:j=[]}={})=>{const r=Ke(se),ie=Ze(W??{tables:[]},ne).map(e=>JSON.stringify(e)).join(" | "),de=s?`import type { LunoraAi } from "@lunora/ai";
|
|
2
2
|
`:"",le=s?`
|
|
3
3
|
readonly ai: LunoraAi;`:"",ce=M?`import type { LunoraPayment } from "@lunora/payment";
|
|
4
4
|
`:"",ue=M?`
|
|
@@ -41,7 +41,7 @@ import type { VectorIndexName } from "./dataModel.js";
|
|
|
41
41
|
/** Multi-channel notifications (@lunora/notify): send / chat / inApp / webhook plus the push device sub-facade. Sends are external I/O — confine them to action handlers. */
|
|
42
42
|
readonly notify: import("@lunora/notify").LunoraNotify;
|
|
43
43
|
/** Device push sub-facade — the same object as ctx.notify.push (register / send / broadcast). Sends belong in action handlers. */
|
|
44
|
-
readonly push: import("@lunora/notify").LunoraPush;`:"",y=
|
|
44
|
+
readonly push: import("@lunora/notify").LunoraPush;`:"",y=j.length>0,Ie=y?`import type { WorkflowHandle } from "@lunora/workflow";
|
|
45
45
|
import type * as lunoraWorkflowDefinitions from "../workflows.js";
|
|
46
46
|
`:"",Re=y?`
|
|
47
47
|
|
|
@@ -54,10 +54,10 @@ type WorkflowParamsOf<Definition> = Definition extends { __params?: infer Params
|
|
|
54
54
|
|
|
55
55
|
/** This project's declared workflows, addressable from \`ctx.workflows\` by their \`lunora/workflows.ts\` export name. */
|
|
56
56
|
export interface LunoraWorkflows {
|
|
57
|
-
${
|
|
57
|
+
${j.map(e=>` get(name: ${JSON.stringify(e.exportName)}): WorkflowHandle<WorkflowParamsOf<typeof lunoraWorkflowDefinitions.${e.exportName}>>;`).join(`
|
|
58
58
|
`)}
|
|
59
59
|
}`:"",_=y?' | "workflows"':"",V=y?`
|
|
60
|
-
readonly workflows: LunoraWorkflows;`:"",G=Ue(F),$=G.length>0,k=
|
|
60
|
+
readonly workflows: LunoraWorkflows;`:"",G=Ue(F),$=G.length>0,k=E.length>0,I=[...$?["QueueProducer"]:[],...k?["TopicPublisher"]:[]],Be=I.length>0?`import type { ${I.join(", ")} } from "@lunora/queue";
|
|
61
61
|
import type * as lunoraQueueDefinitions from "../queues.js";
|
|
62
62
|
`:"",Oe=I.length>0?"\n\n/** Message body type carried by a `defineQueue` / `defineTopic` definition (its phantom `__lunoraBody`). */\ntype QueueBodyOf<Definition> = Definition extends { __lunoraBody?: infer Body } ? (unknown extends Body ? unknown : NonNullable<Body>) : unknown;":"",Ae=$?`
|
|
63
63
|
|
|
@@ -69,28 +69,28 @@ ${G.map(e=>` readonly ${e.exportName}: QueueProducer<QueueBodyOf<typeof lunor
|
|
|
69
69
|
|
|
70
70
|
/** This project's declared topics, addressable from \`ctx.topics\` by their \`lunora/queues.ts\` export name. */
|
|
71
71
|
export interface LunoraTopics {
|
|
72
|
-
${
|
|
72
|
+
${E.map(e=>` readonly ${e.exportName}: TopicPublisher<QueueBodyOf<typeof lunoraQueueDefinitions.${e.exportName}>>;`).join(`
|
|
73
73
|
`)}
|
|
74
74
|
}`:"",Ce=`${Oe}${Ae}${Ne}`,H=$?`
|
|
75
75
|
readonly queues: LunoraQueues;`:"",z=k?`
|
|
76
|
-
readonly topics: LunoraTopics;`:"",R=b.length>0,De=e=>{if(Q==="")throw new D("INTERNAL","@lunora/codegen: emitServer needs `generatedDirectory` to import an RPC service's types");const o=Ve(Q,e);if(Ge(o))throw new D("INTERNAL",`@lunora/codegen: an RPC service's entry (${e}) must be on the same drive as the app`);const c=o.split(He).join("/").replace(Ye,".$1js");return c.startsWith(".")?c:`./${c}`},U=b.filter(e=>e.
|
|
76
|
+
readonly topics: LunoraTopics;`:"",R=b.length>0,De=e=>{if(Q==="")throw new D("INTERNAL","@lunora/codegen: emitServer needs `generatedDirectory` to import an RPC service's types");const o=Ve(Q,e);if(Ge(o))throw new D("INTERNAL",`@lunora/codegen: an RPC service's entry (${e}) must be on the same drive as the app`);const c=o.split(He).join("/").replace(Ye,".$1js");return c.startsWith(".")?c:`./${c}`},U=b.filter(e=>e.rpcEntrypoint!==void 0),Me=U.length>0?"ServiceFetcher, ServiceRpc":"ServiceFetcher",Se=R?`import type { ${Me} } from "${r.server}";
|
|
77
77
|
${U.map(e=>`import type * as lunoraService_${e.name} from ${JSON.stringify(De(e.main))};
|
|
78
78
|
`).join("")}`:"",Fe=R?`
|
|
79
79
|
|
|
80
80
|
/** This project's service bindings (\`lunora.config\` \`services\`), addressable from \`ctx.services\` in actions. */
|
|
81
81
|
export interface LunoraServices {
|
|
82
|
-
${b.map(e=>{h(e.name,`service "${e.name}"`);const o=e.
|
|
82
|
+
${b.map(e=>{h(e.name,`service "${e.name}"`);const o=e.rpcEntrypoint===void 0?"ServiceFetcher":`ServiceRpc<typeof lunoraService_${e.name}.${e.rpcEntrypoint}>`;return` readonly ${e.name}: ${o};`}).join(`
|
|
83
83
|
`)}
|
|
84
84
|
}`:"",We=R?`
|
|
85
85
|
readonly services: LunoraServices;`:"",B=u.length>0,Qe=B?`import type { AgentHandle } from "@lunora/agent";
|
|
86
|
-
`:"",
|
|
86
|
+
`:"",Ee=B?`
|
|
87
87
|
|
|
88
88
|
/** This project's declared agents, addressable from \`ctx.agents\` by their \`lunora/agents.ts\` export name. */
|
|
89
89
|
export interface LunoraAgents {
|
|
90
90
|
${u.map(e=>(h(e.exportName,`agent export "${e.exportName}"`),` readonly ${e.exportName}: AgentHandle;`)).join(`
|
|
91
91
|
`)}
|
|
92
92
|
}`:"",X=B?`
|
|
93
|
-
readonly agents: LunoraAgents;`:"",
|
|
93
|
+
readonly agents: LunoraAgents;`:"",je=l?`import type { InferIdentity } from "${r.server}";
|
|
94
94
|
import type * as lunoraIdentityContract from "../identity.js";
|
|
95
95
|
`:"",Pe=l?`
|
|
96
96
|
|
|
@@ -160,7 +160,7 @@ export type {
|
|
|
160
160
|
} from "${r.serverDataModel}";
|
|
161
161
|
|
|
162
162
|
import type { DataModel, Doc, GeoIndexNamesByTable, Id as IdOfTable, IndexNamesByTable, Insert, InsertModel, RankIndexNamesByTable, Relations, SearchIndexNamesByTable, TableName } from "./dataModel.js";
|
|
163
|
-
${ke}${de}${ce}${pe}${he}${Ie}${Be}${Se}${Qe}${
|
|
163
|
+
${ke}${de}${ce}${pe}${he}${Ie}${Be}${Se}${Qe}${je}${qe}
|
|
164
164
|
export type { AppTableName, DataModel, Doc, Id, TableName } from "./dataModel.js";
|
|
165
165
|
|
|
166
166
|
/**
|
|
@@ -220,7 +220,7 @@ export interface OrmWriter extends OrmReader {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
/** Storage buckets this schema declares (\`v.storage("name")\`), narrowing \`ctx.storage.bucket(name)\`. */
|
|
223
|
-
export type StorageBucketName = ${ie};${fe}${Re}${Ce}${Fe}${
|
|
223
|
+
export type StorageBucketName = ${ie};${fe}${Re}${Ce}${Fe}${Ee}${Pe}${_e}
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* Project-typed contexts. The base contexts from \`@lunora/server\` are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-
|
|
1
|
+
import"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import"./isD1GlobalTable-udvHAAzD.mjs";import"./ir-DBSvhNa-.mjs";import"./json-data-Chfs2Cz5.mjs";import{e as f}from"./shard-C0OSxk7u.mjs";import"./shard-runtime-DvqfDuYO.mjs";import"./shared-DjUziztz.mjs";export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{statSync as E,readFileSync as y}from"node:fs";import{basename as P}from"node:path";import{createJiti as x}from"jiti";import{Project as S,Node as t}from"ts-morph";import{propertyKeyName as l}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import{findProjectConfigFile as v}from"./PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{PROJECT_CONFIG_FILENAMES as T}from"./PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";const f=new Map,F=async i=>{const r=v(i);if(r===void 0)return{};let e;try{const n=E(r);e=`${String(n.mtimeMs)}:${String(n.size)}`}catch{return{}}const s=f.get(r);if(s?.key===e)return s.value;const a=(async()=>{try{const u=(await x(r,{interopDefault:!1,moduleCache:!1}).import(r))?.default;return{config:u!==null&&typeof u=="object"?u:void 0}}catch(n){return{error:n instanceof Error?n.message:String(n)}}})();return f.set(r,{key:e,value:a}),a},L=i=>{let e=i.getExportAssignments().find(s=>!s.isExportEquals())?.getExpression();for(;e!==void 0&&(t.isSatisfiesExpression(e)||t.isAsExpression(e)||t.isParenthesizedExpression(e));)e=e.getExpression();if(e!==void 0&&t.isIdentifier(e))for(e=i.getVariableDeclaration(e.getText())?.getInitializer();e!==void 0&&(t.isSatisfiesExpression(e)||t.isAsExpression(e));)e=e.getExpression();return e!==void 0&&t.isObjectLiteralExpression(e)?e:void 0},c=(i,r)=>t.isPropertyAssignment(i)?i.getInitializer():r.getVariableDeclaration(l(i))?.getInitializer(),g=i=>{let r=i;for(;r!==void 0&&(t.isSatisfiesExpression(r)||t.isAsExpression(r)||t.isParenthesizedExpression(r));)r=r.getExpression();return r},h=(i,r)=>{const e=g(i);if(e===void 0||!t.isObjectLiteralExpression(e))return{advisor:{unreadable:!0}};const s=e.getProperties(),a=s.filter(o=>t.isPropertyAssignment(o)&&!t.isComputedPropertyName(o.getNameNode())||t.isShorthandPropertyAssignment(o));if(a.length!==s.length)return{advisor:{unreadable:!0}};const n=a.find(o=>l(o)==="minSeverity");if(n===void 0)return{advisor:{}};const u=c(n,r);return u!==void 0&&t.isStringLiteral(u)?{advisor:{minSeverity:u.getLiteralValue()}}:{advisor:{unreadable:!0}}},A=new Map([["advisor",{advisor:{unreadable:!0}}],["remote",{unreadable:!0}],["target",{unreadable:!0}]]),b=(i,r)=>{const e=i.getProperty(r);if(e!==void 0)return(t.isPropertyAssignment(e)?e.getInitializer():void 0)??"unreadable"},m=(i,r)=>{const e=b(i,r);if(e!==void 0)return e!=="unreadable"&&(t.isStringLiteral(e)||t.isNoSubstitutionTemplateLiteral(e))?e.getLiteralValue():!1},j=i=>{const r=b(i,"rpc");if(r!==void 0)return r!=="unreadable"&&t.isFalseLiteral(r)?!1:"unreadable"},N=i=>{const r=g(i);if(r===void 0||!t.isObjectLiteralExpression(r))return{services:{unreadable:!0}};const e={};for(const s of r.getProperties()){if(!t.isPropertyAssignment(s)||t.isComputedPropertyName(s.getNameNode()))return{services:{unreadable:!0}};const a=g(s.getInitializer());if(a===void 0||!t.isObjectLiteralExpression(a)||a.getProperties().some(d=>!t.isPropertyAssignment(d)))return{services:{unreadable:!0}};const n=m(a,"dir"),u=m(a,"entrypoint"),o=j(a);if(typeof n!="string"||u===!1||o==="unreadable")return{services:{unreadable:!0}};e[l(s)]={dir:n,...u===void 0?{}:{entrypoint:u},...o===void 0?{}:{rpc:o}}}return{services:{declared:e}}},w=(i,r)=>{if(t.isGetAccessorDeclaration(i)||t.isMethodDeclaration(i))return A.get(l(i))??{};if(!t.isPropertyAssignment(i)&&!t.isShorthandPropertyAssignment(i))return{};const e=l(i);if(e==="advisor")return h(c(i,r),r);if(e==="services")return N(c(i,r));if(e!=="target"&&e!=="remote")return{};const s=c(i,r);return s===void 0?{unreadable:!0}:e==="target"?t.isStringLiteral(s)?{target:s.getLiteralValue()}:{unreadable:!0}:t.isTrueLiteral(s)||t.isFalseLiteral(s)?{remote:s.getLiteralValue()}:t.isObjectLiteralExpression(s)?{remote:!0}:{unreadable:!0}},V=i=>{const r=v(i);if(r===void 0)return{};let e;try{e=y(r,"utf8")}catch{return{unreadable:!0}}const a=new S({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(P(r),e,{overwrite:!0}),n=L(a);if(n===void 0)return{unreadable:!0};if(n.getProperties().some(o=>t.isSpreadAssignment(o))){const o=d=>n.getProperties().some(p=>!t.isSpreadAssignment(p)&&l(p)===d);return{...o("advisor")?{advisor:{unreadable:!0}}:{},...o("services")?{services:{unreadable:!0}}:{},unreadable:!0}}let u={};for(const o of n.getProperties())u={...u,...w(o,a)};return u};export{T as PROJECT_CONFIG_FILENAMES,v as findProjectConfigFile,F as loadProjectConfig,V as readProjectConfigLiterals};
|
package/dist/packem_shared/{readServiceBindings-D9Wi_qGU.mjs → readServiceBindings-CeQvSswr.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as g,readFileSync as p}from"node:fs";import{isAbsolute as w,resolve as m,join as u}from"node:path";import{ts as h}from"ts-morph";import{readProjectConfigLiterals as
|
|
1
|
+
import{existsSync as g,readFileSync as p}from"node:fs";import{isAbsolute as w,resolve as m,join as u}from"node:path";import{ts as h}from"ts-morph";import{readProjectConfigLiterals as E}from"./loadProjectConfig-nNIDOrlR.mjs";const f=/^[A-Za-z_$][\w$]*$/u,$=["wrangler.jsonc","wrangler.json"],b=t=>`SERVICE_${t.replaceAll(/(?<=[a-z0-9])(?=[A-Z])/gu,"_").toUpperCase()}`,y=(t,e)=>{const r=$.map(n=>u(e,n)).find(n=>g(n));if(r===void 0){const n=g(u(e,"wrangler.toml"))?" (its wrangler.toml is not read — Lunora reads a service's config as JSON(C) only)":"";throw new Error(`@lunora/codegen: service "${t}" points at ${e}, which has no wrangler.jsonc / wrangler.json${n}`)}const o=h.parseConfigFileTextToJson(r,p(r,"utf8"));if(o.error!==void 0||typeof o.config!="object"||o.config===null)throw new Error(`@lunora/codegen: service "${t}": ${r} is not valid JSON(C)`);return{config:o.config,path:r}},v=(t,e)=>{const r=t.route??e.route,o=t.routes??e.routes;return!(r!==void 0||Array.isArray(o)&&o.length>0)&&(t.workers_dev??e.workers_dev)!==!1},S=(t,e,r)=>{if(!f.test(e))throw new Error(`@lunora/codegen: service key "${e}" must be an identifier — it becomes ctx.services.${e}`);if(r.entrypoint!==void 0&&!f.test(r.entrypoint))throw new Error(`@lunora/codegen: service "${e}": entrypoint "${r.entrypoint}" must name an exported WorkerEntrypoint class`);const o=w(r.dir)?r.dir:m(t,r.dir),{config:n,path:s}=y(e,o),{main:c,name:l}=n;if(typeof l!="string"||l==="")throw new Error(`@lunora/codegen: service "${e}": ${s} declares no Worker "name"`);if(typeof c!="string"||c==="")throw new Error(`@lunora/codegen: service "${e}": ${s} declares no "main" entry module`);const d=Object.entries(n.env??{}).map(([i,a])=>[i,a??{}]);return{binding:b(e),...r.entrypoint===void 0?{}:{entrypoint:r.entrypoint},envWorkers:Object.fromEntries(d.flatMap(([i,a])=>typeof a.name=="string"&&a.name!==""?[[i,a.name]]:[])),main:m(o,c),name:e,publicScopes:[...v(n,n)?[""]:[],...d.filter(([,i])=>v(i,n)).map(([i])=>i)],...r.entrypoint===void 0||r.rpc===!1?{}:{rpcEntrypoint:r.entrypoint},worker:l,wranglerPath:s}},j=t=>{const{services:e}=E(t);if(e?.unreadable===!0)throw new Error('@lunora/codegen: lunora.config `services` must be an inline object of { dir: "…", entrypoint?: "…", rpc?: false } literals — codegen reads it without running the file');const r=Object.entries(e?.declared??{}).map(([o,n])=>S(t,o,n)).toSorted((o,n)=>o.name.localeCompare(n.name));for(const[o,n]of r.entries()){const s=r.slice(o+1).find(c=>c.binding===n.binding);if(s!==void 0)throw new Error(`@lunora/codegen: services "${n.name}" and "${s.name}" both map to the binding ${n.binding} — rename one`)}return r},A=t=>{try{return{services:j(t)}}catch(e){return{error:e instanceof Error?e.message:String(e),services:[]}}};export{A as readServiceBindings,j as resolveServiceBindings};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as jt}from"@lunora/errors";import{serializeSchemaSnapshot as Ht,hashSchemaSnapshot as Vt}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Kt,isD1GlobalTable as Gt}from"./isD1GlobalTable-udvHAAzD.mjs";import{p as Qt,i as zt}from"./ir-DBSvhNa-.mjs";import{r as l}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as Xt,a as Jt,b as Yt,c as Zt,d as er,f as tr,g as rr,h as ar,i as nr,j as sr,k as or,l as ir,m as dr,n as cr,o as lr,p as hr,q as ur,s as pr,t as mr,u as gr,v as br,w as fr,x as wr,y as yr,z as vr,A as kr}from"./shard-runtime-
|
|
1
|
+
import{LunoraError as jt}from"@lunora/errors";import{serializeSchemaSnapshot as Ht,hashSchemaSnapshot as Vt}from"./SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs";import{isHyperdriveGlobalTable as Kt,isD1GlobalTable as Gt}from"./isD1GlobalTable-udvHAAzD.mjs";import{p as Qt,i as zt}from"./ir-DBSvhNa-.mjs";import{r as l}from"./json-data-Chfs2Cz5.mjs";import{r as q,e as Xt,a as Jt,b as Yt,c as Zt,d as er,f as tr,g as rr,h as ar,i as nr,j as sr,k as or,l as ir,m as dr,n as cr,o as lr,p as hr,q as ur,s as pr,t as mr,u as gr,v as br,w as fr,x as wr,y as yr,z as vr,A as kr}from"./shard-runtime-DvqfDuYO.mjs";import{u as re,i as Sr,G as Rr,d as xr}from"./shared-DjUziztz.mjs";const Ar=` /**
|
|
2
2
|
* The bare writer every admin/maintenance entry point writes through.
|
|
3
3
|
*
|
|
4
4
|
* Admin and maintenance writes go through the SAME reactive-cache hooks as a
|
|
@@ -229,7 +229,7 @@ ${m()}
|
|
|
229
229
|
// ActionCtx-only helpers (external, non-deterministic I/O): constructed
|
|
230
230
|
// and attached only for an \`action\` so query/mutation ctx never carry them.
|
|
231
231
|
if (isAction) {
|
|
232
|
-
${a}${r.map(v=>` ctx.${v} = ${v};`).join(`
|
|
232
|
+
${a.replaceAll(/^(?=.)/gmu," ")}${r.map(v=>` ctx.${v} = ${v};`).join(`
|
|
233
233
|
`)}
|
|
234
234
|
}
|
|
235
235
|
`:"";return` private buildCtx(options: { bookmarks?: DispatchBookmark; functionPath?: string; headroom?: TransactionHeadroomTracker; identity?: SubscriptionIdentity; kind?: "query"; onRead?: (table: string, idOrScan?: string) => void; onReadRange?: (range: KeyRange) => void; scope?: QueryReadScope; trusted?: boolean } = {}): unknown {
|
|
@@ -304,7 +304,7 @@ ${t}
|
|
|
304
304
|
const LUNORA_TOPICS: ReadonlyArray<TopicBindingSpec> = [
|
|
305
305
|
${n}
|
|
306
306
|
];
|
|
307
|
-
`}},K=(e,t)=>{if(e.length===0)return{build:"",importLines:[],specs:""};const n=e.map(r=>(a(r.name,`service "${r.name}"`),a(r.binding,`service binding "${r.binding}"`),` { binding: "${r.binding}", name: "${r.name}"${r.
|
|
307
|
+
`}},K=(e,t)=>{if(e.length===0)return{build:"",importLines:[],specs:""};const n=e.map(r=>(a(r.name,`service "${r.name}"`),a(r.binding,`service binding "${r.binding}"`),` { binding: "${r.binding}", name: "${r.name}"${r.rpcEntrypoint===void 0?"":", rpc: true"} },`)).join(`
|
|
308
308
|
`);return{build:`
|
|
309
309
|
const services = createServices(env, LUNORA_SERVICES);
|
|
310
310
|
`,importLines:[`import type { ServiceBindingSpec } from "${t}";`,`import { createServices } from "${t}";`],specs:`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/codegen",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.249",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
50
|
-
"@lunora/agent": "1.0.0-alpha.
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.180",
|
|
50
|
+
"@lunora/agent": "1.0.0-alpha.162",
|
|
51
51
|
"@lunora/container": "1.0.0-alpha.65",
|
|
52
52
|
"@lunora/errors": "1.0.0-alpha.48",
|
|
53
53
|
"@lunora/platform": "1.0.0-alpha.49",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{statSync as b,readFileSync as E}from"node:fs";import{basename as y}from"node:path";import{createJiti as P}from"jiti";import{Project as x,Node as t}from"ts-morph";import{propertyKeyName as l}from"./listLunoraSourceFiles-CSlcBYlo.mjs";import{findProjectConfigFile as m}from"./PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";import{PROJECT_CONFIG_FILENAMES as k}from"./PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs";const p=new Map,D=async i=>{const r=m(i);if(r===void 0)return{};let e;try{const n=b(r);e=`${String(n.mtimeMs)}:${String(n.size)}`}catch{return{}}const s=p.get(r);if(s?.key===e)return s.value;const a=(async()=>{try{const o=(await P(r,{interopDefault:!1,moduleCache:!1}).import(r))?.default;return{config:o!==null&&typeof o=="object"?o:void 0}}catch(n){return{error:n instanceof Error?n.message:String(n)}}})();return p.set(r,{key:e,value:a}),a},S=i=>{let e=i.getExportAssignments().find(s=>!s.isExportEquals())?.getExpression();for(;e!==void 0&&(t.isSatisfiesExpression(e)||t.isAsExpression(e)||t.isParenthesizedExpression(e));)e=e.getExpression();if(e!==void 0&&t.isIdentifier(e))for(e=i.getVariableDeclaration(e.getText())?.getInitializer();e!==void 0&&(t.isSatisfiesExpression(e)||t.isAsExpression(e));)e=e.getExpression();return e!==void 0&&t.isObjectLiteralExpression(e)?e:void 0},c=(i,r)=>t.isPropertyAssignment(i)?i.getInitializer():r.getVariableDeclaration(l(i))?.getInitializer(),d=i=>{let r=i;for(;r!==void 0&&(t.isSatisfiesExpression(r)||t.isAsExpression(r)||t.isParenthesizedExpression(r));)r=r.getExpression();return r},L=(i,r)=>{const e=d(i);if(e===void 0||!t.isObjectLiteralExpression(e))return{advisor:{unreadable:!0}};const s=e.getProperties(),a=s.filter(u=>t.isPropertyAssignment(u)&&!t.isComputedPropertyName(u.getNameNode())||t.isShorthandPropertyAssignment(u));if(a.length!==s.length)return{advisor:{unreadable:!0}};const n=a.find(u=>l(u)==="minSeverity");if(n===void 0)return{advisor:{}};const o=c(n,r);return o!==void 0&&t.isStringLiteral(o)?{advisor:{minSeverity:o.getLiteralValue()}}:{advisor:{unreadable:!0}}},h=new Map([["advisor",{advisor:{unreadable:!0}}],["remote",{unreadable:!0}],["target",{unreadable:!0}]]),f=(i,r)=>{const e=i.getProperty(r);if(e===void 0)return;const s=t.isPropertyAssignment(e)?e.getInitializer():void 0;return s!==void 0&&(t.isStringLiteral(s)||t.isNoSubstitutionTemplateLiteral(s))?s.getLiteralValue():!1},A=i=>{const r=d(i);if(r===void 0||!t.isObjectLiteralExpression(r))return{services:{unreadable:!0}};const e={};for(const s of r.getProperties()){if(!t.isPropertyAssignment(s)||t.isComputedPropertyName(s.getNameNode()))return{services:{unreadable:!0}};const a=d(s.getInitializer());if(a===void 0||!t.isObjectLiteralExpression(a)||a.getProperties().some(u=>!t.isPropertyAssignment(u)))return{services:{unreadable:!0}};const n=f(a,"dir"),o=f(a,"entrypoint");if(typeof n!="string"||o===!1)return{services:{unreadable:!0}};e[l(s)]=o===void 0?{dir:n}:{dir:n,entrypoint:o}}return{services:{declared:e}}},j=(i,r)=>{if(t.isGetAccessorDeclaration(i)||t.isMethodDeclaration(i))return h.get(l(i))??{};if(!t.isPropertyAssignment(i)&&!t.isShorthandPropertyAssignment(i))return{};const e=l(i);if(e==="advisor")return L(c(i,r),r);if(e==="services")return A(c(i,r));if(e!=="target"&&e!=="remote")return{};const s=c(i,r);return s===void 0?{unreadable:!0}:e==="target"?t.isStringLiteral(s)?{target:s.getLiteralValue()}:{unreadable:!0}:t.isTrueLiteral(s)||t.isFalseLiteral(s)?{remote:s.getLiteralValue()}:t.isObjectLiteralExpression(s)?{remote:!0}:{unreadable:!0}},M=i=>{const r=m(i);if(r===void 0)return{};let e;try{e=E(r,"utf8")}catch{return{unreadable:!0}}const a=new x({compilerOptions:{allowJs:!0},skipFileDependencyResolution:!0,skipLoadingLibFiles:!0,useInMemoryFileSystem:!0}).createSourceFile(y(r),e,{overwrite:!0}),n=S(a);if(n===void 0)return{unreadable:!0};if(n.getProperties().some(u=>t.isSpreadAssignment(u))){const u=v=>n.getProperties().some(g=>!t.isSpreadAssignment(g)&&l(g)===v);return{...u("advisor")?{advisor:{unreadable:!0}}:{},...u("services")?{services:{unreadable:!0}}:{},unreadable:!0}}let o={};for(const u of n.getProperties())o={...o,...j(u,a)};return o};export{k as PROJECT_CONFIG_FILENAMES,m as findProjectConfigFile,D as loadProjectConfig,M as readProjectConfigLiterals};
|