@lunora/codegen 1.0.0-alpha.398 → 1.0.0-alpha.399
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 +49 -5
- package/dist/index.d.ts +49 -5
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{AGENTS_FILENAME-BxpEvZgW.mjs → AGENTS_FILENAME-Cli3X44r.mjs} +1 -1
- package/dist/packem_shared/COMPANION_BINDING-Da_v9XpC.mjs +1 -0
- package/dist/packem_shared/{CONTAINERS_FILENAME-CvPP3wR-.mjs → CONTAINERS_FILENAME-BX1_ALLp.mjs} +1 -1
- package/dist/packem_shared/{DEFAULT_TARGET-C0xI7Xqd.mjs → DEFAULT_TARGET-C-gcdslJ.mjs} +1 -1
- package/dist/packem_shared/{FLAGS_FILENAME-Ce1G6kZd.mjs → FLAGS_FILENAME-DY3yo1u_.mjs} +1 -1
- package/dist/packem_shared/{MUTATORS_FILENAME-JBFlT9aD.mjs → MUTATORS_FILENAME-Ck_l1lz7.mjs} +1 -1
- package/dist/packem_shared/{NOTIFY_FILENAME-DLGxunzB.mjs → NOTIFY_FILENAME-BIodzu3R.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-CLZ5Em9J.mjs → OPENRPC_VERSION-Dr6Xjldk.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-2K8DSvbt.mjs → QUEUES_FILENAME-C5xotY-M.mjs} +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-B1dOE0gb.mjs +52 -0
- package/dist/packem_shared/{SHAPES_FILENAME-DCqsIdQQ.mjs → SHAPES_FILENAME-DCtGHMEm.mjs} +1 -1
- package/dist/packem_shared/{WORKFLOWS_FILENAME-Cpx5Mg0z.mjs → WORKFLOWS_FILENAME-CyV1HQaP.mjs} +1 -1
- package/dist/packem_shared/{attribution-7Qs8xFmy.mjs → attribution-DjweYNgJ.mjs} +1 -1
- package/dist/packem_shared/{buildOpenApiDocument-KKQFkA_W.mjs → buildOpenApiDocument-BTp9vkHw.mjs} +1 -1
- package/dist/packem_shared/{capabilitiesUsedBy-CsqWN4ob.mjs → capabilitiesUsedBy-SSrieNZ1.mjs} +1 -1
- package/dist/packem_shared/chain-DWwd9wXd.mjs +1 -0
- package/dist/packem_shared/{classify-procedure-call-D7XTLd8w.mjs → classify-procedure-call-BuF5PNwV.mjs} +1 -1
- package/dist/packem_shared/companionServiceBinding-ChINWo8k.mjs +1 -0
- package/dist/packem_shared/{context-property-calls-Dh1E4-sW.mjs → context-property-calls-BcUYQ6ph.mjs} +1 -1
- package/dist/packem_shared/{context-root-DHXNIvVA.mjs → context-root-2wag3akK.mjs} +1 -1
- package/dist/packem_shared/{createCodegenProject-khHqIXPY.mjs → createCodegenProject-C8N4Zm8h.mjs} +1 -1
- package/dist/packem_shared/{database-calls-CxJgjC_X.mjs → database-calls-B_85LJIk.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-D-ZsZKvv.mjs → discoverAuthApiCalls-f8_WRQEA.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-BT_qyOt8.mjs → discoverCrons-DTqSuSDh.mjs} +1 -1
- package/dist/packem_shared/discoverFunctions-D4GIaVIP.mjs +1 -0
- package/dist/packem_shared/{discoverHttpRoutes-DOkHmHzy.mjs → discoverHttpRoutes-2gxHuLgt.mjs} +1 -1
- package/dist/packem_shared/discoverHyperdriveCalls-DaJLewG0.mjs +1 -0
- package/dist/packem_shared/{discoverInserts-d_zAWqc4.mjs → discoverInserts-CLh70kVu.mjs} +1 -1
- package/dist/packem_shared/discoverMaskProcedures-C0VcUGpb.mjs +1 -0
- package/dist/packem_shared/{discoverMigrations-Dq-7Od3H.mjs → discoverMigrations-e5_NQdf-.mjs} +1 -1
- package/dist/packem_shared/{discoverNondeterministicCalls-BnSxt5nN.mjs → discoverNondeterministicCalls-CrXAegUc.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-Bvh__ZjJ.mjs → discoverQueries-T8b_7ZZ-.mjs} +1 -1
- package/dist/packem_shared/discoverR2sqlCalls-CY0xmIWX.mjs +1 -0
- package/dist/packem_shared/{discoverRlsMetadata-CugyqoLu.mjs → discoverRlsMetadata-CnVvP2Ps.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsProcedures-CDbsnndn.mjs → discoverRlsProcedures-DttY0Jld.mjs} +1 -1
- package/dist/packem_shared/{discoverSandboxUsage-CSt29RbS.mjs → discoverSandboxUsage-X0SECo-x.mjs} +1 -1
- package/dist/packem_shared/{discoverSchema-DTgg8rAu.mjs → discoverSchema-DDvMQheA.mjs} +1 -1
- package/dist/packem_shared/{discoverStorageRulesMetadata-DTXC-pY3.mjs → discoverStorageRulesMetadata-t_oMSn0L.mjs} +1 -1
- package/dist/packem_shared/{emitAgents-C-Mfsx39.mjs → emitAgents-ChXyTTzS.mjs} +1 -1
- package/dist/packem_shared/{emitApp-D-fxbE34.mjs → emitApp-xunr1-_c.mjs} +6 -4
- package/dist/packem_shared/{emitShard-CVPnBS0Y.mjs → emitShard-CueduzG1.mjs} +1 -1
- package/dist/packem_shared/{exported-procedure-chains-D1wkgxKb.mjs → exported-procedure-chains-BaxQ8C-S.mjs} +1 -1
- package/dist/packem_shared/{fingerprintSchemaSources-Pmxw808S.mjs → fingerprintSchemaSources-PmhepCVj.mjs} +1 -1
- package/dist/packem_shared/{handler-reference-HsMWpHnr.mjs → handler-reference-D2EE2q-4.mjs} +1 -1
- package/dist/packem_shared/{index-VKPwR6Cj.mjs → index-Dd6T5nSP.mjs} +1 -1
- package/dist/packem_shared/{index-DuvSMZEy.mjs → index-fVYBrxkP.mjs} +1 -1
- package/dist/packem_shared/{ip-reads-CAzOWzOH.mjs → ip-reads-WFubgB1G.mjs} +1 -1
- package/dist/packem_shared/{isTestPath-DrszPMtU.mjs → isTestPath-ClgKgMYM.mjs} +1 -1
- package/dist/packem_shared/loadProjectConfig-CtcJHHKS.mjs +1 -0
- package/dist/packem_shared/{modules-CYf6V2w7.mjs → modules-DE0ksIeR.mjs} +1 -1
- package/dist/packem_shared/{shard-DKSPraAt.mjs → shard-DNpjvEod.mjs} +113 -120
- package/dist/packem_shared/{shard-runtime-BHljpfS5.mjs → shard-runtime-knn-ER8x.mjs} +1 -1
- package/dist/packem_shared/{unwrap-handler-return-X7HuBhd5.mjs → unwrap-handler-return-BpigsVD6.mjs} +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-5N9d9CIu.mjs +0 -31
- package/dist/packem_shared/chain-DIvP6mqw.mjs +0 -1
- package/dist/packem_shared/discoverFunctions-DgzPoKGf.mjs +0 -1
- package/dist/packem_shared/discoverHyperdriveCalls-BGhSZp00.mjs +0 -1
- package/dist/packem_shared/discoverMaskProcedures-CFcLOe-9.mjs +0 -1
- package/dist/packem_shared/discoverR2sqlCalls-CexxhDRt.mjs +0 -1
- package/dist/packem_shared/loadProjectConfig-Dbux4jI3.mjs +0 -1
- package/dist/packem_shared/readServiceBindings-rDIqDBSW.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdvisorCallSiteScope, AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext
|
|
1
|
+
import { AdvisorCallSiteScope, AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext } from '@lunora/advisor';
|
|
2
2
|
export type { Finding } from '@lunora/advisor';
|
|
3
3
|
import { Project, SourceFile, Node } from 'ts-morph';
|
|
4
4
|
import { LunoraError } from '@lunora/errors';
|
|
@@ -3621,6 +3621,11 @@ interface CodegenResult {
|
|
|
3621
3621
|
*/
|
|
3622
3622
|
cronTriggers: ReadonlyArray<string>;
|
|
3623
3623
|
generated: {
|
|
3624
|
+
/**
|
|
3625
|
+
* Studio-only advisor procedure document, written to `_generated/advisor-procedures.json`. A `lint: false`
|
|
3626
|
+
* run carries the `analysis: "disabled"` marker instead of an empty roster.
|
|
3627
|
+
*/
|
|
3628
|
+
advisorProceduresJson: string;
|
|
3624
3629
|
/** WorkflowEntrypoint classes for declared agents (`_generated/agents.ts`); `""` (and not written) when no agents are declared. */
|
|
3625
3630
|
agents: string;
|
|
3626
3631
|
api: string;
|
|
@@ -3817,6 +3822,14 @@ declare const describeErrorLevelFindings: (result: Pick<CodegenResult, "advisori
|
|
|
3817
3822
|
advisoryNames: ReadonlyArray<string>;
|
|
3818
3823
|
platformDiagnosticNames: ReadonlyArray<string>;
|
|
3819
3824
|
};
|
|
3825
|
+
/** The binding the app's Worker reaches the companion through; the runtime advisor route reads it. */
|
|
3826
|
+
declare const COMPANION_BINDING = "ADVISOR_COMPANION";
|
|
3827
|
+
/**
|
|
3828
|
+
* The companion's `services[].name` in the app's wrangler config: a stable key for the generated Worker, never
|
|
3829
|
+
* one of the app's own `lunora.config` services. Callers that must tell the companion apart from those services
|
|
3830
|
+
* (dev, deploy, binding inference) compare against this, not a copy of the literal.
|
|
3831
|
+
*/
|
|
3832
|
+
declare const COMPANION_SERVICE_NAME = "advisorCompanion";
|
|
3820
3833
|
/**
|
|
3821
3834
|
* An error thrown by codegen discovery when the user's schema or function
|
|
3822
3835
|
* source has a structural problem that can be pinpointed to a specific source
|
|
@@ -4108,6 +4121,31 @@ declare const readServiceBindings: (projectRoot: string) => {
|
|
|
4108
4121
|
error?: string;
|
|
4109
4122
|
services: ServiceBindingIR[];
|
|
4110
4123
|
};
|
|
4124
|
+
/**
|
|
4125
|
+
* The companion advisor Worker as a service binding, when `studio.companion` is on. Kept out of `resolveServiceBindings`: that list
|
|
4126
|
+
* types `ctx.services`, and the companion is Lunora's own Worker, not an app service. Only the callers that bind or deploy a Worker add it
|
|
4127
|
+
* (see `readBoundServiceBindings`). The folder need not exist yet: a refusal check or the reconcile can run before codegen writes it.
|
|
4128
|
+
* `lunoraDirectory` is the project's Lunora source folder (relative to `projectRoot`), where codegen writes `_generated/companion`.
|
|
4129
|
+
*/
|
|
4130
|
+
declare const companionServiceBinding: (projectRoot: string, lunoraDirectory?: string) => ServiceBindingIR | undefined;
|
|
4131
|
+
/**
|
|
4132
|
+
* `readServiceBindings` plus the companion, for the callers that must bind or run it: the reconcile into the app's `services[]`,
|
|
4133
|
+
* the deploy of services, and dev (the app's wrangler config carries the `ADVISOR_COMPANION` binding, so dev has to run that Worker too).
|
|
4134
|
+
* Callers that read the app's own services (the open-shard gate, `lunora preview`'s refusal, doctor) or RPC entrypoints (the companion
|
|
4135
|
+
* has none) keep `readServiceBindings`.
|
|
4136
|
+
*/
|
|
4137
|
+
declare const readBoundServiceBindings: (projectRoot: string, lunoraDirectory?: string) => {
|
|
4138
|
+
error?: string;
|
|
4139
|
+
services: ServiceBindingIR[];
|
|
4140
|
+
};
|
|
4141
|
+
/**
|
|
4142
|
+
* `readBoundServiceBindings` for a dev session, which can start before codegen writes `_generated/companion/`: the companion is left
|
|
4143
|
+
* out until its wrangler config exists, rather than failing the session on the missing file. The next start enrolls it.
|
|
4144
|
+
*/
|
|
4145
|
+
declare const readDevServiceBindings: (projectRoot: string, lunoraDirectory?: string) => {
|
|
4146
|
+
error?: string;
|
|
4147
|
+
services: ServiceBindingIR[];
|
|
4148
|
+
};
|
|
4111
4149
|
/** The only file shapes may be declared in — mirrors `lunora/queues.ts`. */
|
|
4112
4150
|
declare const SHAPES_FILENAME = "shapes.ts";
|
|
4113
4151
|
/**
|
|
@@ -4336,8 +4374,6 @@ interface EmitServerOptions {
|
|
|
4336
4374
|
declare const emitServer: ({ agents, capabilities, containers, env, hasVectors, hasFlags, hasNotify, identity, queues, schema, services, storageRuleBuckets, topics, useUmbrella, workflows }?: EmitServerOptions) => string;
|
|
4337
4375
|
interface EmitShardOptions {
|
|
4338
4376
|
advisories?: ReadonlyArray<Finding>;
|
|
4339
|
-
/** Every declared procedure — the health map's denominator, served via `getAdvisorProcedures`. */
|
|
4340
|
-
advisorProcedures?: ReadonlyArray<AdvisorProcedureProtection>;
|
|
4341
4377
|
/** Agents declared via `defineAgent` exports in `lunora/agents.ts` — wires the typed `ctx.agents` producers. */
|
|
4342
4378
|
agents?: ReadonlyArray<AgentIR>;
|
|
4343
4379
|
/** The package-backed capabilities the app uses (post platform gate) — each row of the `CAPABILITIES` table it names is wired per its `shardBinding` / `tier`. */
|
|
@@ -4419,7 +4455,7 @@ interface EmitShardOptions {
|
|
|
4419
4455
|
workflowEvents?: ReadonlyArray<WorkflowEventIR>;
|
|
4420
4456
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
4421
4457
|
}
|
|
4422
|
-
declare const emitShard: ({ advisories,
|
|
4458
|
+
declare const emitShard: ({ advisories, agents, capabilities, containers, env, flagKeys, hasFlags, hasNotify, hasRooms, hasSecretValues, hasSensitiveArgs, hasSockets, lazyFunctions, hasVectors, liveStreamDeclarations, liveStreams, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, hasIpReaders, services, topics, useUmbrella, workflowEvents, workflows }: EmitShardOptions) => string;
|
|
4423
4459
|
/**
|
|
4424
4460
|
* Emit `_generated/containers.ts` — one container-enabled Durable Object class
|
|
4425
4461
|
* per `defineContainer` export, each a thin subclass of `LunoraContainer`
|
|
@@ -4835,6 +4871,14 @@ interface ProjectConfigLiterals {
|
|
|
4835
4871
|
declared?: Record<string, ServiceLiteral>;
|
|
4836
4872
|
unreadable?: boolean;
|
|
4837
4873
|
};
|
|
4874
|
+
/**
|
|
4875
|
+
* `studio.companion`: deploy the companion Worker that serves the advisor procedure list to a hosted Studio.
|
|
4876
|
+
* `unreadable` when `studio` is declared but `companion` is not a boolean literal.
|
|
4877
|
+
*/
|
|
4878
|
+
studio?: {
|
|
4879
|
+
companion?: boolean;
|
|
4880
|
+
unreadable?: boolean;
|
|
4881
|
+
};
|
|
4838
4882
|
target?: string;
|
|
4839
4883
|
/**
|
|
4840
4884
|
* A config file exists, but its default export could not be read as an
|
|
@@ -4962,4 +5006,4 @@ declare const secretKindOf: (value: string) => string | undefined;
|
|
|
4962
5006
|
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
4963
5007
|
declare const redact: (value: string) => string;
|
|
4964
5008
|
declare const VERSION = "0.0.0";
|
|
4965
|
-
export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
|
|
5009
|
+
export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, COMPANION_BINDING, COMPANION_SERVICE_NAME, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, companionServiceBinding, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readBoundServiceBindings, readDevServiceBindings, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdvisorCallSiteScope, AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext
|
|
1
|
+
import { AdvisorCallSiteScope, AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding, LintContext } from '@lunora/advisor';
|
|
2
2
|
export type { Finding } from '@lunora/advisor';
|
|
3
3
|
import { Project, SourceFile, Node } from 'ts-morph';
|
|
4
4
|
import { LunoraError } from '@lunora/errors';
|
|
@@ -3621,6 +3621,11 @@ interface CodegenResult {
|
|
|
3621
3621
|
*/
|
|
3622
3622
|
cronTriggers: ReadonlyArray<string>;
|
|
3623
3623
|
generated: {
|
|
3624
|
+
/**
|
|
3625
|
+
* Studio-only advisor procedure document, written to `_generated/advisor-procedures.json`. A `lint: false`
|
|
3626
|
+
* run carries the `analysis: "disabled"` marker instead of an empty roster.
|
|
3627
|
+
*/
|
|
3628
|
+
advisorProceduresJson: string;
|
|
3624
3629
|
/** WorkflowEntrypoint classes for declared agents (`_generated/agents.ts`); `""` (and not written) when no agents are declared. */
|
|
3625
3630
|
agents: string;
|
|
3626
3631
|
api: string;
|
|
@@ -3817,6 +3822,14 @@ declare const describeErrorLevelFindings: (result: Pick<CodegenResult, "advisori
|
|
|
3817
3822
|
advisoryNames: ReadonlyArray<string>;
|
|
3818
3823
|
platformDiagnosticNames: ReadonlyArray<string>;
|
|
3819
3824
|
};
|
|
3825
|
+
/** The binding the app's Worker reaches the companion through; the runtime advisor route reads it. */
|
|
3826
|
+
declare const COMPANION_BINDING = "ADVISOR_COMPANION";
|
|
3827
|
+
/**
|
|
3828
|
+
* The companion's `services[].name` in the app's wrangler config: a stable key for the generated Worker, never
|
|
3829
|
+
* one of the app's own `lunora.config` services. Callers that must tell the companion apart from those services
|
|
3830
|
+
* (dev, deploy, binding inference) compare against this, not a copy of the literal.
|
|
3831
|
+
*/
|
|
3832
|
+
declare const COMPANION_SERVICE_NAME = "advisorCompanion";
|
|
3820
3833
|
/**
|
|
3821
3834
|
* An error thrown by codegen discovery when the user's schema or function
|
|
3822
3835
|
* source has a structural problem that can be pinpointed to a specific source
|
|
@@ -4108,6 +4121,31 @@ declare const readServiceBindings: (projectRoot: string) => {
|
|
|
4108
4121
|
error?: string;
|
|
4109
4122
|
services: ServiceBindingIR[];
|
|
4110
4123
|
};
|
|
4124
|
+
/**
|
|
4125
|
+
* The companion advisor Worker as a service binding, when `studio.companion` is on. Kept out of `resolveServiceBindings`: that list
|
|
4126
|
+
* types `ctx.services`, and the companion is Lunora's own Worker, not an app service. Only the callers that bind or deploy a Worker add it
|
|
4127
|
+
* (see `readBoundServiceBindings`). The folder need not exist yet: a refusal check or the reconcile can run before codegen writes it.
|
|
4128
|
+
* `lunoraDirectory` is the project's Lunora source folder (relative to `projectRoot`), where codegen writes `_generated/companion`.
|
|
4129
|
+
*/
|
|
4130
|
+
declare const companionServiceBinding: (projectRoot: string, lunoraDirectory?: string) => ServiceBindingIR | undefined;
|
|
4131
|
+
/**
|
|
4132
|
+
* `readServiceBindings` plus the companion, for the callers that must bind or run it: the reconcile into the app's `services[]`,
|
|
4133
|
+
* the deploy of services, and dev (the app's wrangler config carries the `ADVISOR_COMPANION` binding, so dev has to run that Worker too).
|
|
4134
|
+
* Callers that read the app's own services (the open-shard gate, `lunora preview`'s refusal, doctor) or RPC entrypoints (the companion
|
|
4135
|
+
* has none) keep `readServiceBindings`.
|
|
4136
|
+
*/
|
|
4137
|
+
declare const readBoundServiceBindings: (projectRoot: string, lunoraDirectory?: string) => {
|
|
4138
|
+
error?: string;
|
|
4139
|
+
services: ServiceBindingIR[];
|
|
4140
|
+
};
|
|
4141
|
+
/**
|
|
4142
|
+
* `readBoundServiceBindings` for a dev session, which can start before codegen writes `_generated/companion/`: the companion is left
|
|
4143
|
+
* out until its wrangler config exists, rather than failing the session on the missing file. The next start enrolls it.
|
|
4144
|
+
*/
|
|
4145
|
+
declare const readDevServiceBindings: (projectRoot: string, lunoraDirectory?: string) => {
|
|
4146
|
+
error?: string;
|
|
4147
|
+
services: ServiceBindingIR[];
|
|
4148
|
+
};
|
|
4111
4149
|
/** The only file shapes may be declared in — mirrors `lunora/queues.ts`. */
|
|
4112
4150
|
declare const SHAPES_FILENAME = "shapes.ts";
|
|
4113
4151
|
/**
|
|
@@ -4336,8 +4374,6 @@ interface EmitServerOptions {
|
|
|
4336
4374
|
declare const emitServer: ({ agents, capabilities, containers, env, hasVectors, hasFlags, hasNotify, identity, queues, schema, services, storageRuleBuckets, topics, useUmbrella, workflows }?: EmitServerOptions) => string;
|
|
4337
4375
|
interface EmitShardOptions {
|
|
4338
4376
|
advisories?: ReadonlyArray<Finding>;
|
|
4339
|
-
/** Every declared procedure — the health map's denominator, served via `getAdvisorProcedures`. */
|
|
4340
|
-
advisorProcedures?: ReadonlyArray<AdvisorProcedureProtection>;
|
|
4341
4377
|
/** Agents declared via `defineAgent` exports in `lunora/agents.ts` — wires the typed `ctx.agents` producers. */
|
|
4342
4378
|
agents?: ReadonlyArray<AgentIR>;
|
|
4343
4379
|
/** The package-backed capabilities the app uses (post platform gate) — each row of the `CAPABILITIES` table it names is wired per its `shardBinding` / `tier`. */
|
|
@@ -4419,7 +4455,7 @@ interface EmitShardOptions {
|
|
|
4419
4455
|
workflowEvents?: ReadonlyArray<WorkflowEventIR>;
|
|
4420
4456
|
workflows?: ReadonlyArray<WorkflowIR>;
|
|
4421
4457
|
}
|
|
4422
|
-
declare const emitShard: ({ advisories,
|
|
4458
|
+
declare const emitShard: ({ advisories, agents, capabilities, containers, env, flagKeys, hasFlags, hasNotify, hasRooms, hasSecretValues, hasSensitiveArgs, hasSockets, lazyFunctions, hasVectors, liveStreamDeclarations, liveStreams, maskMetadata, mutators, queues, rlsMetadata, schema, schemaSnapshot, shapes, storageRules, studioFeatures, hasIpReaders, services, topics, useUmbrella, workflowEvents, workflows }: EmitShardOptions) => string;
|
|
4423
4459
|
/**
|
|
4424
4460
|
* Emit `_generated/containers.ts` — one container-enabled Durable Object class
|
|
4425
4461
|
* per `defineContainer` export, each a thin subclass of `LunoraContainer`
|
|
@@ -4835,6 +4871,14 @@ interface ProjectConfigLiterals {
|
|
|
4835
4871
|
declared?: Record<string, ServiceLiteral>;
|
|
4836
4872
|
unreadable?: boolean;
|
|
4837
4873
|
};
|
|
4874
|
+
/**
|
|
4875
|
+
* `studio.companion`: deploy the companion Worker that serves the advisor procedure list to a hosted Studio.
|
|
4876
|
+
* `unreadable` when `studio` is declared but `companion` is not a boolean literal.
|
|
4877
|
+
*/
|
|
4878
|
+
studio?: {
|
|
4879
|
+
companion?: boolean;
|
|
4880
|
+
unreadable?: boolean;
|
|
4881
|
+
};
|
|
4838
4882
|
target?: string;
|
|
4839
4883
|
/**
|
|
4840
4884
|
* A config file exists, but its default export could not be read as an
|
|
@@ -4962,4 +5006,4 @@ declare const secretKindOf: (value: string) => string | undefined;
|
|
|
4962
5006
|
/** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
|
|
4963
5007
|
declare const redact: (value: string) => string;
|
|
4964
5008
|
declare const VERSION = "0.0.0";
|
|
4965
|
-
export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
|
|
5009
|
+
export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, COMPANION_BINDING, COMPANION_SERVICE_NAME, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, companionServiceBinding, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readBoundServiceBindings, readDevServiceBindings, readPackageDependencies, readProjectConfigLiterals, readProjectLazyFunctions, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as
|
|
1
|
+
import{SCHEMA_SNAPSHOT_VERSION as t,diffSchemaSnapshots as i,serializeSchemaSnapshot as a}from"./packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs";import{formatAdvisories as d,lintSchema as f,toAdvisorContext as m}from"./packem_shared/formatAdvisories-BCVASH7N.mjs";import{describeErrorLevelFindings as p,errorAdvisoryNames as c,errorPlatformDiagnosticNames as l,sortedUniqueNames as S}from"./packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs";import{CAPABILITY_PROBES as E}from"./packem_shared/CAPABILITY_PROBES-BuNEmlCO.mjs";import{COMPANION_BINDING as A,COMPANION_SERVICE_NAME as v}from"./packem_shared/COMPANION_BINDING-Da_v9XpC.mjs";import{CodegenDiagnosticError as C,diagnosticAt as N}from"./packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs";import{AGENTS_FILENAME as I,discoverAgents as R}from"./packem_shared/AGENTS_FILENAME-Cli3X44r.mjs";import{isTestPath as M,listLunoraSourceFiles as T}from"./packem_shared/isTestPath-ClgKgMYM.mjs";import{default as F}from"./packem_shared/discoverAuthApiCalls-f8_WRQEA.mjs";import{CONTAINERS_FILENAME as P,discoverContainers as D}from"./packem_shared/CONTAINERS_FILENAME-BX1_ALLp.mjs";import{default as b}from"./packem_shared/discoverCrons-DTqSuSDh.mjs";import{capabilitiesUsedBy as U,createTargetScope as B,foldCapabilitySignals as H,mayReadCapabilityContext as j,sourceCapabilitySignals as k}from"./packem_shared/capabilitiesUsedBy-SSrieNZ1.mjs";import{FLAGS_FILENAME as W,discoverFlags as z}from"./packem_shared/FLAGS_FILENAME-DY3yo1u_.mjs";import{d as Q}from"./packem_shared/index-fVYBrxkP.mjs";import{default as w}from"./packem_shared/discoverHttpRoutes-2gxHuLgt.mjs";import{default as Y}from"./packem_shared/discoverHyperdriveCalls-DaJLewG0.mjs";import{default as Z}from"./packem_shared/discoverInserts-CLh70kVu.mjs";import{d as ee}from"./packem_shared/index-Dd6T5nSP.mjs";import{default as oe}from"./packem_shared/discoverMigrations-e5_NQdf-.mjs";import{MUTATORS_FILENAME as ie,discoverMutators as ae}from"./packem_shared/MUTATORS_FILENAME-Ck_l1lz7.mjs";import{default as de}from"./packem_shared/discoverNondeterministicCalls-CrXAegUc.mjs";import{NOTIFY_FILENAME as me,discoverNotifyCalls as ne,discoverNotifyChannels as pe,discoverNotifyConfig as ce}from"./packem_shared/NOTIFY_FILENAME-BIodzu3R.mjs";import{default as Se}from"./packem_shared/readPackageDependencies-RHhGiz0k.mjs";import{default as Ee}from"./packem_shared/discoverQueries-T8b_7ZZ-.mjs";import{QUEUES_FILENAME as Ae,discoverQueues as ve}from"./packem_shared/QUEUES_FILENAME-C5xotY-M.mjs";import{default as Ce}from"./packem_shared/discoverR2sqlCalls-CY0xmIWX.mjs";import{default as Oe}from"./packem_shared/discoverRlsProcedures-DttY0Jld.mjs";import{default as Re}from"./packem_shared/discoverRlsMetadata-CnVvP2Ps.mjs";import{discoverSandboxUsage as Me}from"./packem_shared/discoverSandboxUsage-X0SECo-x.mjs";import{default as he}from"./packem_shared/discoverSchema-DDvMQheA.mjs";import{companionServiceBinding as Le,readBoundServiceBindings as Pe,readDevServiceBindings as De,readServiceBindings as ye,resolveServiceBindings as be}from"./packem_shared/companionServiceBinding-ChINWo8k.mjs";import{SHAPES_FILENAME as Ue,discoverShapes as Be}from"./packem_shared/SHAPES_FILENAME-DCtGHMEm.mjs";import{default as je}from"./packem_shared/discoverStorageRulesMetadata-t_oMSn0L.mjs";import{WORKFLOWS_FILENAME as Ve,discoverWorkflows as We}from"./packem_shared/WORKFLOWS_FILENAME-CyV1HQaP.mjs";import{emitApp as Ke}from"./packem_shared/emitApp-xunr1-_c.mjs";import{isD1GlobalTable as qe,isHyperdriveGlobalTable as we}from"./packem_shared/isD1GlobalTable-udvHAAzD.mjs";import{buildOpenApiDocument as Ye,emitOpenApi as Xe,emitOpenApiModule as Ze}from"./packem_shared/buildOpenApiDocument-BTp9vkHw.mjs";import{OPENRPC_VERSION as er,buildOpenRpcDocument as rr,emitOpenRpc as or,emitOpenRpcModule as tr}from"./packem_shared/OPENRPC_VERSION-Dr6Xjldk.mjs";import{DEFAULT_TARGET as ar,platformMatrixIds as sr,readProjectTarget as dr,resolveCodegenTarget as fr}from"./packem_shared/DEFAULT_TARGET-C-gcdslJ.mjs";import{loadProjectConfig as nr,readProjectConfigLiterals as pr,readProjectLazyFunctions as cr}from"./packem_shared/loadProjectConfig-CtcJHHKS.mjs";import{PROJECT_CONFIG_FILENAMES as Sr,findCodegenConfigFile as xr,findProjectConfigFile as Er,projectConfigCandidatePaths as ur}from"./packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs";import{SCHEMA_SNAPSHOT_FILENAME as vr,runCodegen as gr}from"./packem_shared/SCHEMA_SNAPSHOT_FILENAME-B1dOE0gb.mjs";import{SchemaSnapshotParseError as Nr,buildSchemaSnapshot as Or,evaluateSchemaDrift as Ir,indexReferencesOf as Rr,parseSchemaSnapshot as _r}from"./packem_shared/SchemaSnapshotParseError-DnAuFdpl.mjs";import{default as Tr}from"./packem_shared/fingerprintSchemaSources-PmhepCVj.mjs";import{schemaFromIr as Fr}from"./packem_shared/schemaFromIr-CByOxuZb.mjs";import{LUNORA_ERROR_CODES as Pr,validatorIrToJsonSchema as Dr}from"./packem_shared/LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{SDK_LANGUAGES as br,SDK_TARGETS as Gr,generateSdk as Ur}from"./sdk/index.mjs";import{redact as Hr,secretKindOf as jr}from"./packem_shared/redact-Cy14LEnc.mjs";import{default as Vr}from"./packem_shared/emitDrizzleSchema-Dszoyymv.mjs";import{e as zr}from"./packem_shared/server-C4h6-BZx.mjs";import{e as Qr}from"./packem_shared/shard-DNpjvEod.mjs";import{G as wr}from"./packem_shared/shared-DhqnD5R3.mjs";import{MESSAGE_SOLUTIONS as Yr,findSolutionByMessage as Xr}from"@lunora/errors";import{createCodegenProject as $r,findTsconfig as eo,refreshCodegenProject as ro,tsconfigFingerprint as oo}from"./packem_shared/createCodegenProject-C8N4Zm8h.mjs";import{t as io,u as ao,v as so}from"./packem_shared/shard-runtime-knn-ER8x.mjs";import{emitApi as mo,emitCollections as no,emitInternalApi as po}from"./packem_shared/emitApi-Cdc8MeNK.mjs";import{emitCrons as lo,emitScheduler as So,emitVectors as xo,emitWranglerCronTriggers as Eo}from"./packem_shared/emitCrons-BQjDleCe.mjs";import{emitDataModel as Ao}from"./packem_shared/emitDataModel-MjAOi3KM.mjs";import{emitFunctions as go}from"./packem_shared/emitFunctions-BIMKBLQ8.mjs";import{isTypedSchema as No}from"./packem_shared/isTypedSchema-CDv3pJB6.mjs";const e="0.0.0";export{I as AGENTS_FILENAME,E as CAPABILITY_PROBES,A as COMPANION_BINDING,v as COMPANION_SERVICE_NAME,P as CONTAINERS_FILENAME,C as CodegenDiagnosticError,ar as DEFAULT_TARGET,W as FLAGS_FILENAME,wr as GENERATED_HEADER,Pr as LUNORA_ERROR_CODES,Yr as LUNORA_SOLUTION_RULES,ie as MUTATORS_FILENAME,me as NOTIFY_FILENAME,er as OPENRPC_VERSION,Sr as PROJECT_CONFIG_FILENAMES,Ae as QUEUES_FILENAME,vr as SCHEMA_SNAPSHOT_FILENAME,t as SCHEMA_SNAPSHOT_VERSION,br as SDK_LANGUAGES,Gr as SDK_TARGETS,Ue as SHAPES_FILENAME,Nr as SchemaSnapshotParseError,e as VERSION,Ve as WORKFLOWS_FILENAME,Ye as buildOpenApiDocument,rr as buildOpenRpcDocument,Or as buildSchemaSnapshot,U as capabilitiesUsedBy,Le as companionServiceBinding,$r as createCodegenProject,B as createTargetScope,p as describeErrorLevelFindings,N as diagnosticAt,i as diffSchemaSnapshots,R as discoverAgents,F as discoverAuthApiCalls,D as discoverContainers,b as discoverCrons,z as discoverFlags,Q as discoverFunctions,w as discoverHttpRoutes,Y as discoverHyperdriveCalls,Z as discoverInserts,ee as discoverMaskProcedures,oe as discoverMigrations,ae as discoverMutators,de as discoverNondeterministicCalls,ne as discoverNotifyCalls,pe as discoverNotifyChannels,ce as discoverNotifyConfig,Ee as discoverQueries,ve as discoverQueues,Ce as discoverR2sqlCalls,Re as discoverRlsMetadata,Oe as discoverRlsProcedures,Me as discoverSandboxUsage,he as discoverSchema,Be as discoverShapes,je as discoverStorageRulesMetadata,We as discoverWorkflows,io as emitAgents,mo as emitApi,Ke as emitApp,no as emitCollections,ao as emitContainers,lo as emitCrons,Ao as emitDataModel,Vr as emitDrizzleSchema,go as emitFunctions,po as emitInternalApi,Xe as emitOpenApi,Ze as emitOpenApiModule,or as emitOpenRpc,tr as emitOpenRpcModule,So as emitScheduler,zr as emitServer,Qr as emitShard,xo as emitVectors,so as emitWorkflows,Eo as emitWranglerCronTriggers,c as errorAdvisoryNames,l as errorPlatformDiagnosticNames,Ir as evaluateSchemaDrift,xr as findCodegenConfigFile,Xr as findLunoraSolution,Er as findProjectConfigFile,eo as findTsconfig,Tr as fingerprintSchemaSources,H as foldCapabilitySignals,d as formatAdvisories,Ur as generateSdk,Rr as indexReferencesOf,qe as isD1GlobalTable,we as isHyperdriveGlobalTable,M as isTestPath,No as isTypedSchema,f as lintSchema,T as listLunoraSourceFiles,nr as loadProjectConfig,j as mayReadCapabilityContext,_r as parseSchemaSnapshot,sr as platformMatrixIds,ur as projectConfigCandidatePaths,Pe as readBoundServiceBindings,De as readDevServiceBindings,Se as readPackageDependencies,pr as readProjectConfigLiterals,cr as readProjectLazyFunctions,dr as readProjectTarget,ye as readServiceBindings,Hr as redact,ro as refreshCodegenProject,fr as resolveCodegenTarget,be as resolveServiceBindings,gr as runCodegen,Fr as schemaFromIr,jr as secretKindOf,a as serializeSchemaSnapshot,S as sortedUniqueNames,k as sourceCapabilitySignals,m as toAdvisorContext,oo as tsconfigFingerprint,Dr as validatorIrToJsonSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as E}from"./isTestPath-
|
|
1
|
+
import{existsSync as p}from"node:fs";import{join as f}from"node:path";import{agentDefaultName as d,agentClassName as b,voiceBindingName as N,voiceClassName as y}from"@lunora/agent/naming";import{LunoraError as g}from"@lunora/errors";import{Node as a,SyntaxKind as u}from"ts-morph";import{diagnosticAt as l}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{unwrapToCallExpression as A,findObjectProperty as c,stringPropertyFor as E}from"./isTestPath-ClgKgMYM.mjs";import{a as w}from"./attribution-DjweYNgJ.mjs";const h=new Set(["@lunora/agent","@lunora/agent/core"]),v="agents.ts",P=o=>{const n=o.getSymbol();if(!n)return o.getText()==="defineAgent";for(const e of n.getDeclarations())if(a.isImportSpecifier(e))return h.has(e.getImportDeclaration().getModuleSpecifierValue())?e.getNameNode().getText()==="defineAgent":!1;return!1},S=E("agent"),D=(o,n,e)=>{if(o.getKind()===u.TrueKeyword)return!0;if(o.getKind()===u.FalseKeyword)return!1;throw l(o,`agent "${n}": \`${e}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`)},I=(o,n)=>{const e=o.getArguments()[0];if(!e||!a.isObjectLiteralExpression(e))throw l(o,`agent "${n}": defineAgent must be passed an inline object literal`);const t={className:b(n),exportName:n,name:d(n)},r=c(e,"name");r&&a.isPropertyAssignment(r)&&(t.name=S(r.getInitializerOrThrow(),n,"name"));const i=c(e,"publicRun");i&&a.isPropertyAssignment(i)&&D(i.getInitializerOrThrow(),n,"publicRun")&&(t.publicRun=!0);const s=c(e,"voice");if(s&&a.isPropertyAssignment(s)){const m=s.getInitializerOrThrow();if(!a.isObjectLiteralExpression(m))throw l(m,`agent "${n}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`);t.voice=!0,t.voiceBindingName=N(n),t.voiceClassName=y(n)}return c(e,"onEmail")&&(t.onEmail=!0),t},T=o=>{const n=[];for(const e of o.getVariableDeclarations()){const t=A(e.getInitializer());if(!t)continue;const r=t.getExpression();if(!a.isIdentifier(r)||!P(r))continue;const i=e.getNameNode();if(!a.isIdentifier(i)){if(e.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw l(i,"defineAgent exports must be plain named exports (no destructuring)")}const s=w(e,"binding");s!==void 0&&n.push(I(t,s))}return n},x=o=>{const n=new Map,e=new Map;for(const t of o){const r=n.get(t.name);if(r!==void 0)throw new g("DUPLICATE_AGENT_NAME",`Duplicate agent name "${t.name}": produced by both "${r}" and "${t.exportName}". Deployed agent names must be unique across the project.`,{status:500});n.set(t.name,t.exportName);const i=e.get(t.className);if(i!==void 0)throw new g("DUPLICATE_AGENT_CLASS",`Duplicate agent class "${t.className}": produced by both "${i}" and "${t.exportName}". Agent export names must yield unique generated class names.`,{status:500});e.set(t.className,t.exportName)}},M=(o,n)=>{const e=f(n,v);if(!p(e))return[];const t=o.getSourceFile(e)??o.addSourceFileAtPath(e),r=T(t);return r.sort((i,s)=>i.exportName.localeCompare(s.exportName)),x(r),r};export{v as AGENTS_FILENAME,M as discoverAgents};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as i,readFileSync as s}from"node:fs";import{join as a,basename as c}from"node:path";import{ts as l}from"ts-morph";const p="ADVISOR_COMPANION",N="advisorCompanion",u=["advisor-procedures.json","src/worker.ts","wrangler.jsonc"],d=["wrangler.jsonc","wrangler.json"],t=o=>{for(const r of d){const n=a(o,r);if(i(n)){const e=l.parseConfigFileTextToJson(n,s(n,"utf8"));if(e.error!==void 0||typeof e.config!="object"||e.config===null)throw new Error(`@lunora/codegen: ${n} is not valid JSON(C), so the companion Worker's name cannot be derived`);return{config:e.config,path:n}}}if(i(a(o,"wrangler.toml")))throw new Error(`@lunora/codegen: ${a(o,"wrangler.toml")} is not read — the companion Worker needs wrangler.jsonc or wrangler.json to derive its name`)},g=(o,r)=>t(o)?.config[r],v=(o,r)=>{const n=g(o,r);return typeof n=="string"&&n!==""?n:void 0},h=o=>{const r=t(o);if(r===void 0)return`${c(o)}-advisor`;const{name:n}=r.config;if(typeof n!="string"||n==="")throw new Error(`@lunora/codegen: ${r.path} declares no top-level "name", which the companion Worker's name is derived from`);return`${n}-advisor`},E=(o,r="lunora")=>a(o,r,"_generated","companion");export{p as COMPANION_BINDING,u as COMPANION_FILES,N as COMPANION_SERVICE_NAME,E as companionDirectory,h as companionName,v as wranglerString,g as wranglerValue};
|
package/dist/packem_shared/{CONTAINERS_FILENAME-CvPP3wR-.mjs → CONTAINERS_FILENAME-BX1_ALLp.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as j}from"node:fs";import{join as I}from"node:path";import{containerClassName as A,containerBindingName as O,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as k,isManagedImage as C,isCloudflareRegistryDigest as _,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as $,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as D,findObjectProperty as p,symbolConstInitializer as M,descendantsOfKind as F,outermostValueWrapper as w,isWriteTarget as V}from"./isTestPath-
|
|
1
|
+
import{existsSync as j}from"node:fs";import{join as I}from"node:path";import{containerClassName as A,containerBindingName as O,DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS as k,isManagedImage as C,isCloudflareRegistryDigest as _,normalizeContainerImage as f}from"@lunora/container";import{SyntaxKind as $,Node as s}from"ts-morph";import{diagnosticAt as a}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{stringPropertyFor as D,findObjectProperty as p,symbolConstInitializer as M,descendantsOfKind as F,outermostValueWrapper as w,isWriteTarget as V}from"./isTestPath-ClgKgMYM.mjs";import{a as K}from"./attribution-DjweYNgJ.mjs";import{a as b}from"./property-name-7cBlgK_O.mjs";const B="containers.ts",R=t=>{const e=t.getSymbol();if(!e)return t.getText()==="defineContainer";for(const r of e.getDeclarations())if(s.isImportSpecifier(r))return r.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/container"?!1:r.getNameNode().getText()==="defineContainer";return!1},d=D("container"),y=(t,e,r)=>{if(s.isNumericLiteral(t))return t.getLiteralValue();throw a(t,`container "${e}": \`${r}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`)},E=(t,e)=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t))return f(t.getLiteralValue());if(s.isObjectLiteralExpression(t)){const r=p(t,"registry");if(r&&s.isPropertyAssignment(r)){const i=r.getInitializerOrThrow();return f({registry:d(i,e,"image.registry")})}const n=p(t,"build");if(n&&s.isPropertyAssignment(n)){const i=n.getInitializerOrThrow();return f({build:d(i,e,"image.build")})}}throw a(t,`container "${e}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`)},U=new Set(["buildArgs","image","images","instanceType","maxInstances","name","rollout","sandbox","schedulingPolicy"]),N=new Set(["gracePeriodSeconds","stepPercentage"]),L=t=>{let e=t;for(;s.isAsExpression(e)||s.isSatisfiesExpression(e)||s.isTypeAssertion(e)||s.isParenthesizedExpression(e);)e=e.getExpression();return e},Y=(t,e)=>F(e,$.Identifier).some(r=>{if(r.getSymbol()!==t)return!1;let n=w(r),i=n.getParent();if(s.isCallExpression(i)&&i.getExpression().getText()==="Object.assign")return i.getArguments()[0]===n;for(;(s.isPropertyAccessExpression(i)||s.isElementAccessExpression(i))&&i.getExpression()===n;){if(V(i))return!0;n=w(i),i=n.getParent()}return!1}),z=16,T=(t,e,r,n)=>{let i={name:r,symbol:t},o;for(let c=0;c<z;c+=1){const l=M(i.symbol);if(l===void 0||!s.isExpression(l))return o;if(o=L(l),s.isObjectLiteralExpression(o)&&i.symbol!==void 0&&Y(i.symbol,e.getSourceFile()))throw a(e,`${n}: \`${i.name}\` is a const object that is written to elsewhere in this file, so its initializer is not the value the container runs with. Declare the settings where they are final.`);if(!s.isIdentifier(o))return o;i={name:o.getText(),symbol:o.getSymbol()}}return o},P=(t,e)=>{const r=L(t);return s.isIdentifier(r)?T(r.getSymbol(),r,r.getText(),e)??r:r},W=t=>{const e=t.getNonNullableType();return(e.isUnion()?e.getUnionTypes():[e]).flatMap(n=>n.getApparentType().getProperties().map(i=>i.getName()))},q=(t,e,r)=>{const n=t.getExpression().getType(),i=e==="every"||n.isAny()||n.isUnknown()?["its keys"]:[...new Set(W(n))].filter(o=>e.has(o)).map(o=>`\`${o}\``);if(i.length>0)throw a(t,`${r}: this spread can set ${i.join(", ")}, which codegen writes into wrangler.jsonc and so must read statically. Spread a module-scope \`const\` object literal, or write the keys inline.`)},x=(t,e,r)=>{const n=b(t),i=s.isShorthandPropertyAssignment(t)?T(t.getValueSymbol(),t,n,r):void 0;if(i!==void 0)return[n,i];if(e==="every"||e.has(n))throw a(t,`${r}: \`${n}\` is deploy configuration codegen writes into wrangler.jsonc, so it must be a static literal — inline it, or name a module-scope \`const\` initialized with one.`)},m=(t,e,r,n=new Set)=>{const i=[],o=new Set(n).add(t);for(const c of t.getProperties())if(s.isPropertyAssignment(c))i.push([b(c),P(c.getInitializerOrThrow(),r)]);else if(s.isSpreadAssignment(c))i.push(...H(c,e,r,o));else{const l=x(c,e,r);l!==void 0&&i.push(l)}return i},H=(t,e,r,n)=>{const i=P(t.getExpression(),r);if(!s.isObjectLiteralExpression(i))return q(t,e,r),[];if(n.has(i))throw a(t,`${r}: this spread refers back to an object it is part of, so it has no static value.`);return m(i,e,r,n)},J=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`buildArgs\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" buildArgs`))r[n]=d(i,e,`buildArgs.${n}`);return Object.keys(r).length>0?r:void 0},X=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`rollout\` must be a static object literal — it is deploy configuration codegen writes into wrangler.jsonc`);const r={};for(const[n,i]of m(t,N,`container "${e}" rollout`))(n==="gracePeriodSeconds"||n==="stepPercentage")&&(r[n]=y(i,e,`rollout.${n}`));return r.gracePeriodSeconds===void 0&&r.stepPercentage===void 0?void 0:r},v=t=>{if(s.isTrueLiteral(t))return!0;if(s.isFalseLiteral(t))return!1},S=t=>{if(s.isStringLiteral(t)||s.isNoSubstitutionTemplateLiteral(t)||s.isNumericLiteral(t))return t.getLiteralValue()},G=(t,e)=>{if(s.isStringLiteral(t))return t.getLiteralValue();if(s.isObjectLiteralExpression(t)){const r={};for(const n of t.getProperties()){if(!s.isPropertyAssignment(n))throw a(n,`container "${e}": \`instanceType\` must be an object of static number literals`);const i=b(n);if(i!=="diskMb"&&i!=="memoryMib"&&i!=="vcpu")throw a(n,`container "${e}": unknown \`instanceType\` field "${i}" — expected vcpu, memoryMib, or diskMb`);r[i]=y(n.getInitializerOrThrow(),e,`instanceType.${i}`)}return r}throw a(t,`container "${e}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`)},Q=(t,e)=>{if(!s.isObjectLiteralExpression(t))throw a(t,`container "${e}": \`images\` must be a static object literal — codegen writes it into wrangler.jsonc`);const r={};for(const[n,i]of m(t,"every",`container "${e}" images`)){const o=E(i,e);if(o.kind==="build")throw a(i,`container "${e}": \`images["${n}"]\` cannot be a Railpack { build } source — use a Dockerfile path or a { registry } reference`);if(o.kind==="registry"&&!_(o.reference))throw a(i,`container "${e}": \`images["${n}"].registry\` must be a digest-pinned (@sha256) reference under registry.cloudflare.com — push other registries' images there first`);r[n]=o}return r},Z=(t,e)=>{const r=t.findLast(([i])=>i==="schedulingPolicy");if(r===void 0)return;const n=d(r[1],e,"schedulingPolicy");if(n!=="default"&&n!=="durable_object")throw a(r[1],`container "${e}": unknown \`schedulingPolicy\` "${n}" — use "default" or "durable_object"`);return n==="durable_object"?n:void 0},ee=(t,e,r,n)=>{if(r!==void 0&&k.includes(t))throw a(e,`container "${n}": \`${t}\` is not supported with schedulingPolicy "durable_object"`);if(r===void 0&&t==="images")throw a(e,`container "${n}": \`images\` needs schedulingPolicy "durable_object"`)},te=(t,e,r,n)=>{const{base:i,policy:o}=r;switch(t){case"buildArgs":{i.buildArgs=J(e,n);break}case"enableInternet":{i.enableInternet=v(e);break}case"hardTimeout":{i.hardTimeout=S(e);break}case"image":{r.scheduled||(o.image=E(e,n));break}case"images":{o.images=Q(e,n);break}case"instanceType":{i.instanceType=G(e,n);break}case"maxInstances":{o.maxInstances=y(e,n,"maxInstances");break}case"name":{i.name=d(e,n,"name");break}case"rollout":{o.rollout=X(e,n);break}case"sandbox":{const c=v(e);if(c===void 0)throw a(e,`container "${n}": \`sandbox\` must be a static true/false literal`);i.sandbox=c;break}case"sleepAfter":{i.sleepAfter=S(e);break}}},ne=(t,e,r)=>{const n=t.findLast(([o])=>o==="image")?.[1];if(n===void 0||!(s.isStringLiteral(n)||s.isNoSubstitutionTemplateLiteral(n)))return;const i=n.getLiteralValue();if(!Object.hasOwn(e??{},i)&&!C(i))throw a(n,`container "${r}": \`image\` "${i}" must name an entry of \`images\` or a Cloudflare-managed "cloudflare/…" image`)},ie=(t,e)=>{const r=t.getArguments()[0];if(!r||!s.isObjectLiteralExpression(r))throw a(t,`container "${e}": defineContainer must be passed an inline object literal`);const n=m(r,U,`container "${e}"`),i=Z(n,e),o={base:{bindingName:O(e),className:A(e),exportName:e},policy:{},scheduled:i!==void 0};for(const[g,u]of n)ee(g,u,i,e),te(g,u,o,e);const{base:c,policy:l}=o;if(i==="durable_object")return ne(n,l.images,e),{...c,...l.images===void 0?{}:{images:l.images},schedulingPolicy:i};if(l.image===void 0)throw a(r,`container "${e}": defineContainer requires a static \`image\` property`);return{...c,image:l.image,...l.maxInstances===void 0?{}:{maxInstances:l.maxInstances},...l.rollout===void 0?{}:{rollout:l.rollout}}},re=t=>{const e=[],r=new Map;for(const n of t.getVariableDeclarations()){const i=n.getInitializer();if(i?.getKind()!==$.CallExpression)continue;const o=i,c=o.getExpression();if(!s.isIdentifier(c)||!R(c))continue;const l=n.getNameNode();if(!s.isIdentifier(l)){if(n.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw a(l,"defineContainer exports must be plain named exports (no destructuring)")}const g=K(n,"binding");if(g===void 0)continue;const u=ie(o,g),h=r.get(u.bindingName);if(h!==void 0)throw a(l,`containers "${h}" and "${u.exportName}" both map to the binding ${u.bindingName} — rename one so each container gets its own Durable Object binding`);r.set(u.bindingName,u.exportName),e.push(u)}return e},me=(t,e)=>{const r=I(e,B);if(!j(r))return[];const n=t.getSourceFile(r)??t.addSourceFileAtPath(r),i=re(n);return i.sort((o,c)=>o.exportName.localeCompare(c.exportName)),i};export{B as CONTAINERS_FILENAME,me as discoverContainers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NODE_CAPABILITIES as g,CLOUDFLARE_CAPABILITIES as b,CELLD_CAPABILITIES as y}from"@lunora/platform";import{readProjectConfigLiterals as f}from"./loadProjectConfig-
|
|
1
|
+
import{NODE_CAPABILITIES as g,CLOUDFLARE_CAPABILITIES as b,CELLD_CAPABILITIES as y}from"@lunora/platform";import{readProjectConfigLiterals as f}from"./loadProjectConfig-CtcJHHKS.mjs";const m="cloudflare",S=t=>{const{target:e}=f(t);return e!==void 0&&e.length>0?e:void 0},I=(t,e)=>e??S(t)??m,z=(t,e)=>{if(e!==void 0)return[];const{target:r,unreadable:a}=f(t);return a!==!0||r!==void 0?[]:[{level:"warn",message:`lunora.config declares a \`target\` that codegen cannot read without evaluating it, so the "${m}" 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: "${m}" }\`), or pass \`--target\`.`,target:m}]},_={max:1536,min:32},E=(t,e)=>{if(t!=="cloudflare")return[];const{max:r,min:a}=_,i=`${String(a)}-${String(r)}`;return e.filter(({dimensions:o})=>o!==void 0&&(!Number.isInteger(o)||o<a||o>r)).map(({dimensions:o,name:s})=>({level:"warn",message:`Vector index "${s}" declares ${String(o)} dimensions; Cloudflare Vectorize accepts ${i}, so creating a Vectorize index for it fails at deploy.`,name:"platform_vector_dimensions_out_of_range",remediation:`If a Vectorize index backs "${s}", use ${i} dimensions (many embedding models can truncate output to fit). Ignore this if another store, such as pgvector, backs it.`,target:t}))},u={celld:y,cloudflare:b,node:g},O=(t,e)=>{const r=u[t];if(r===void 0)return!0;const a=r.features[e]?.level;return a==="native"||a==="emulated"},D=()=>Object.keys(u).toSorted((t,e)=>t.localeCompare(e)),k={access:null,ai:"ai",aiSearch:"aiSearch",analytics:"analytics",analyticsSql:"analyticsSql",artifacts:"artifacts",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:"secrets"},w=["agents","commitOrderedTables","containerEgressPolicy","containerRuntimeScheduling","containerSandboxTools","cronTriggers","crossShardFanout","deliveryAuthorization","durableStreams","globalTables","liveStreams","queues","relationGraph","secrets","secretValues","services","topics","typedWebSockets","vectorStore","workerLoaders","workflowRollback","workflowSchedules"],h={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 })`)",deliveryAuthorization:"delivery authorization (`.deliveryAuthorization(...)` on the app builder)",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()`)",liveContext:"the live publisher (`ctx.live`)",liveStreams:"live topic streams (`defineLiveStream`)",queues:"queues (`defineQueue`)",relationGraph:"relation-graph traversal (`ctx.db.related`, derived from `v.id(...)` columns)",secrets:"the secrets store (`ctx.secrets`)",secretValues:"human-supplied secret values (`requestSecretTool`, held for one agent step)",services:"service bindings to sibling Workers (`lunora.config` `services`)",topics:"pub/sub topics (`defineTopic` / `defineSubscription`)",typedWebSockets:"typed WebSocket routes and rooms (`defineWebSocket` / `defineRoom`)",vectorStore:"vector indexes (`.vectorize()`)",workerLoaders:"sandboxed agent scripts (`jsCodeTool`, on Worker Loaders)",workflowRollback:"workflow step rollback (`defineStep({ rollback })`)",workflowSchedules:"scheduled workflow instances (`defineWorkflow({ schedules })`)"},T=(t,e,r)=>({level:"error",message:`${e.name} does not support ${h[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:r}),x=(t,e)=>({level:"error",message:`${t.name} withholds live streams, so ctx.live is not available on the "${e}" target, but this app reads ctx.live.`,name:"platform_unsupported_feature",remediation:'Remove the ctx.live usage, or deploy to a target whose capability matrix marks "liveStreams" as native or emulated.',target:e}),P=t=>({level:"error",message:"This app declares defineLiveStream topics and enables delivery authorization. With delivery authorization on, the shard answers every /_lunora/live/* request with 501, so the live streams cannot be served.",name:"platform_live_stream_delivery_authorization",remediation:"Remove the defineLiveStream declarations, or remove the .deliveryAuthorization(...) call. Live streams and delivery authorization cannot be combined.",target:t}),W=t=>({level:"error",message:"This app declares defineWebSocket routes and enables delivery authorization. With delivery authorization on, the shard answers every route upgrade with 501, so the routes cannot be served.",name:"platform_socket_delivery_authorization",remediation:"Remove the defineWebSocket declarations, or remove the .deliveryAuthorization(...) call. Socket routes and delivery authorization cannot be combined.",target:t}),A=(t,e,r)=>({level:"error",message:`${e.name}'s capability matrix does not declare a support level for ${h[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:r}),$=t=>{const{diagnostics:e,gatedSignals:r,matrix:a,reported:i,signals:o,target:s}=t;for(const n of w){if(o[n]!==!0)continue;const d=a.features[n]?.level;d!=="unsupported"&&d!==void 0||(r[n]=!1,!i.has(n)&&e.push(d==="unsupported"?T(n,a,s):A(n,a,s)))}},R=(t,e,r,a={})=>{const i={...t},o={...a},s=[],n=new Set;for(const[l,c]of Object.entries(k)){if(c===null||!t[l])continue;const v=e.features[c]?.level;v==="unsupported"?(i[l]=!1,n.add(c),s.push({feature:l,level:"error",message:`${e.name} does not support "${l}" (ctx.${l}).`,name:"platform_unsupported_feature",remediation:`Remove the ctx.${l} usage, or deploy to a target whose capability matrix marks "${c}" as native or emulated.`,target:r})):v===void 0&&(i[l]=!1,n.add(c),s.push({feature:l,level:"error",message:`${e.name}'s capability matrix does not declare a support level for "${l}" (ctx.${l}). Treated as unsupported.`,name:"platform_undeclared_feature",remediation:`Rate "${c}" 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:r}))}$({diagnostics:s,gatedSignals:o,matrix:e,reported:n,signals:a,target:r});const d=e.features.liveStreams?.level,p=d===void 0||d==="unsupported";return a.liveContext===!0&&p&&s.push(x(e,r)),{diagnostics:s,liveStreamsWithheld:p,signals:o,usage:i}},F=(t,e,r={})=>{const a=u[e];return a===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}],liveStreamsWithheld:!1,signals:{...r},usage:{...t}}:R(t,a,e,r)},j=t=>{const e=u[t];if(e===void 0)return{supported:!0};const r=e.features.adminTokenRevocation?.level;return r!==void 0&&r!=="unsupported"?{supported:!0}:{diagnostic:{level:"warn",message:`${e.name} ${r===void 0?"does not declare a support level for":"does not support"} named admin tokens, so codegen omits the admin revocation store (\`_generated/adminRevocations.ts\` and the builder's \`.adminRevocations()\`). The root LUNORA_ADMIN_TOKEN is the only admin credential here.`,name:r===void 0?"platform_undeclared_feature":"platform_unsupported_feature",remediation:'Use the root admin token, or deploy to a target whose capability matrix marks "adminTokenRevocation" as native or emulated.',target:t},supported:!1}},N=t=>{const e=u[t];if(e===void 0)return;const r=Object.entries(e.features).filter(([,a])=>a.level==="unsupported").map(([a])=>a).toSorted((a,i)=>a.localeCompare(i));return{id:e.id,name:e.name,unsupported:r}};export{k as CAPABILITY_TO_FEATURE,m as DEFAULT_TARGET,j as gateAdminTokenRevocation,R as gateAgainstMatrix,F as gatePlatformFeatures,P as liveStreamsDeliveryAuthorizationDiagnostic,O as platformFeatureAvailable,D as platformMatrixIds,S as readProjectTarget,z as readTargetDiagnostics,I as resolveCodegenTarget,W as socketRoutesDeliveryAuthorizationDiagnostic,N as studioPlatformFor,E as vectorizeDimensionDiagnostics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as l}from"node:fs";import{join as p}from"node:path";import{Node as t}from"ts-morph";import{defaultExportExpression as g,propertyInitializer as f,findObjectProperty as c}from"./isTestPath-
|
|
1
|
+
import{existsSync as l}from"node:fs";import{join as p}from"node:path";import{Node as t}from"ts-morph";import{defaultExportExpression as g,propertyInitializer as f,findObjectProperty as c}from"./isTestPath-ClgKgMYM.mjs";const d="flags.ts",u=new Set(["@lunora/flags/providers/flagship","lunorash/flags/flagship"]),m=e=>{const i=e.getSymbol();if(!i)return e.getText()==="flagshipProvider";for(const r of i.getDeclarations())if(t.isImportSpecifier(r))return u.has(r.getImportDeclaration().getModuleSpecifierValue())?r.getNameNode().getText()==="flagshipProvider":!1;return!1},v=(e,i)=>{const r=c(e,i);if(!r||!t.isPropertyAssignment(r))return;const o=r.getInitializerOrThrow();if(t.isStringLiteral(o)||t.isNoSubstitutionTemplateLiteral(o))return o.getLiteralValue()},h=e=>{const i=e.getArguments()[0];if(i&&t.isObjectLiteralExpression(i)){const r=v(i,"binding");if(r!==void 0&&r.length>0)return{bindingName:r,mode:"binding",provider:"flagship"}}return{mode:"http",provider:"flagship"}},S=e=>f(e.getArguments()[0],"provider"),b=(e,i)=>{const r=p(i,d);if(!l(r))return;const o=e.getSourceFile(r)??e.addSourceFileAtPath(r),n=g(o);if(!n||!t.isCallExpression(n))return{provider:"custom"};const s=S(n);if(s&&t.isCallExpression(s)){const a=s.getExpression();if(t.isIdentifier(a)&&m(a))return h(s)}return{provider:"custom"}};export{d as FLAGS_FILENAME,b as discoverFlags};
|
package/dist/packem_shared/{MUTATORS_FILENAME-JBFlT9aD.mjs → MUTATORS_FILENAME-Ck_l1lz7.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-BisfC8bR.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-
|
|
1
|
+
import{existsSync as E}from"node:fs";import{join as y}from"node:path";import{Node as o,SyntaxKind as l}from"ts-morph";import{diagnosticAt as I}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{b as M}from"./module-specifiers-BctA0m_p.mjs";import{p as A}from"./parse-validator-BisfC8bR.mjs";import{findObjectProperty as c,unwrapExpression as d,isConstDeclaration as P}from"./isTestPath-ClgKgMYM.mjs";import{g as b,i as D,d as g,h as O}from"./attribution-DjweYNgJ.mjs";import{u as h}from"./unwrap-handler-return-BpigsVD6.mjs";const w="mutators.ts",x=M,z=r=>{const e=r.getSymbol();if(!e)return r.getText()==="defineMutator";for(const t of e.getDeclarations())if(o.isImportSpecifier(t))return x(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineMutator":!1;return!1},C=r=>{const e=r.getSymbol();if(!e)return!1;for(const t of e.getDeclarations()){if(!o.isNamespaceImport(t))continue;const i=t.getFirstAncestorByKind(l.ImportDeclaration);return i!==void 0&&x(i.getModuleSpecifierValue())}return!1},N=r=>{if(o.isIdentifier(r))return z(r);if(o.isPropertyAccessExpression(r)){const e=r.getExpression();return r.getName()==="defineMutator"&&o.isIdentifier(e)&&C(e)}return!1},S=r=>{const e=r.getArguments()[0];return e&&o.isObjectLiteralExpression(e)?e:void 0},m=new WeakMap,p=r=>{let e=m.get(r.compilerNode);if(e===void 0){const t=r.getNameNode(),i=t?.getText();e=r.getSourceFile().getDescendantsOfKind(l.Identifier).filter(s=>s!==t&&s.getText()===i&&g(s)?.compilerNode===r.compilerNode).length===1&&O(r)===void 0,m.set(r.compilerNode,e)}return e},f=r=>{const e=o.isIdentifier(r)?g(r):void 0,t=o.isSourceFile(e?.getParent())||o.isSourceFile(e?.getParent()?.getParent()?.getParent());if(e===void 0||e.getSourceFile()!==r?.getSourceFile()||!t)return;if(o.isFunctionDeclaration(e))return e.hasBody()&&p(e)?e:void 0;const i=P(e)?d(e.getInitializer()):void 0;return(o.isArrowFunction(i)||o.isFunctionExpression(i))&&o.isVariableDeclaration(e)&&p(e)?i:void 0},G=r=>{const e=r.getInitializer();if(!o.isCallExpression(e)||!N(e.getExpression()))return;const t=c(S(e),"server");if(o.isMethodDeclaration(t))return t;if(o.isShorthandPropertyAssignment(t))return f(t.getNameNode());const i=o.isPropertyAssignment(t)?d(t.getInitializer()):void 0;return o.isArrowFunction(i)||o.isFunctionExpression(i)?i:f(i)},T=r=>{const e=c(r,"args");if(!e||!o.isPropertyAssignment(e))return{};const t=e.getInitializer();return t&&o.isObjectLiteralExpression(t)?A(t):{}},L=r=>{const e=c(r,"server");if(!e||!o.isPropertyAssignment(e))return"unknown";const t=e.getInitializer();return!t||!(o.isArrowFunction(t)||o.isFunctionExpression(t))?"unknown":h(t)},j=r=>{const e=c(r,"owner");if(!e||!o.isPropertyAssignment(e))return;const t=e.getInitializer();return t&&o.isStringLiteral(t)?t.getLiteralValue():void 0},R=r=>{const e=[];for(const t of r.getVariableDeclarations()){if(!t.isExported())continue;const i=t.getInitializer();if(i?.getKind()!==l.CallExpression)continue;const n=i,s=n.getExpression();if(!N(s))continue;const a=t.getNameNode();if(!o.isIdentifier(a))throw I(a,"defineMutator exports must be plain named exports (no destructuring)");const u=S(n);for(const v of b(t).filter(F=>D(F)))e.push({args:T(u),exportName:v,filePath:"mutators",line:n.getStartLineNumber(),owner:j(u),returnType:L(u)})}return e},J=(r,e)=>{const t=y(e,w);if(!E(t))return[];const i=r.getSourceFile(t)??r.addSourceFileAtPath(t),n=R(i);return n.sort((s,a)=>s.exportName.localeCompare(a.exportName)),n};export{w as MUTATORS_FILENAME,J as discoverMutators,N as isDefineMutatorCallee,S as mutatorLiteral,G as mutatorServerImplOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as N}from"node:fs";import{join as F}from"node:path";import{SyntaxKind as u,Node as r,VariableDeclarationKind as O}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as A,descendantsOfKind as h,findObjectProperty as g,defaultExportExpression as D,handlerOf as I}from"./isTestPath-
|
|
1
|
+
import{existsSync as N}from"node:fs";import{join as F}from"node:path";import{SyntaxKind as u,Node as r,VariableDeclarationKind as O}from"ts-morph";import{listLunoraSourceFiles as m,lunoraRelativePath as A,descendantsOfKind as h,findObjectProperty as g,defaultExportExpression as D,handlerOf as I}from"./isTestPath-ClgKgMYM.mjs";import{j as T,h as C}from"./attribution-DjweYNgJ.mjs";import{a as l}from"./context-root-2wag3akK.mjs";import{c as k}from"./classify-procedure-call-BuF5PNwV.mjs";const L="notify.ts",M=new Set(["chat","inApp","send","webhook"]),x=new Set(["broadcast","send"]),w=e=>{const s=e.getInitializer();if(!s||!r.isCallExpression(s))return;const t=k(s);if(!t)return;const i=I(s,t.receiver);return i?{exportName:C(e)??e.getName(),handler:i,kind:t.kind}:void 0},y=e=>{const s=[];for(const t of T(e)){const i=w(t);i&&s.push(i)}return s},E=e=>l(e,["notify"])?"notify":l(e,["push"])||l(e,["notify","push"])?"push":void 0,_=e=>{if(!r.isPropertyAccessExpression(e))return;const s=e.getName(),t=E(e.getExpression());if(t==="notify"&&M.has(s))return`ctx.notify.${s}`;if(t==="push"&&x.has(s))return`ctx.push.${s}`},j=e=>r.isPropertyAccessExpression(e)?E(e.getExpression())==="push"&&x.has(e.getName()):!1,ee=(e,s)=>{const t=[];for(const i of m(s)){const o=e.getSourceFile(i)??e.addSourceFileAtPath(i),n=A(s,i);for(const c of y(o))if(!(c.kind!=="query"&&c.kind!=="mutation"))for(const a of h(c.handler,u.PropertyAccessExpression)){const f=_(a);f!==void 0&&t.push({callee:f,exportName:c.exportName,file:n,kind:c.kind,line:a.getStartLineNumber()})}}return t},R=(e,s)=>{for(const t of m(s)){const i=e.getSourceFile(t)??e.addSourceFileAtPath(t);for(const o of y(i))for(const n of h(o.handler,u.PropertyAccessExpression))if(j(n))return!0}return!1},U=new Set(["@lunora/notify"]),V=e=>{const s=e.getSymbol();if(!s)return e.getText()==="defineNotify";for(const t of s.getDeclarations())if(r.isImportSpecifier(t))return U.has(t.getImportDeclaration().getModuleSpecifierValue())?t.getNameNode().getText()==="defineNotify":!1;return!1},P=(e,s=new Set)=>{const t=D(e);if(!t)return;if(!r.isIdentifier(t))return t;const i=t.getSymbol();if(!i?.isAlias())return t;const o=i.getAliasedSymbol();if(!o)return t;const n=o.getDeclarations().find(a=>r.isExportAssignment(a));if(!n)return t;const c=n.getSourceFile();if(!s.has(c.getFilePath()))return P(c,s.add(c.getFilePath()))},z=new Set(["%=","&&=","&=","**=","+=","-=","/=","<<=","=",">>=",">>>=","??=","^=","|=","||="]),p=e=>{const s=e.getSymbol();return s?.getAliasedSymbol()?.getDeclarations()[0]??s?.getDeclarations()[0]},S=e=>{if(r.isIdentifier(e))return e;if(r.isPropertyAccessExpression(e)||r.isElementAccessExpression(e))return S(e.getExpression())},d=(e,s)=>{const t=S(e);return t!==void 0&&p(t)===s},H=(e,s)=>{const t=e.getExpression();if(!r.isPropertyAccessExpression(t))return!1;const i=t.getName(),o=t.getExpression(),n=r.isIdentifier(o)?o.getText():"";if(!((i==="assign"||i==="defineProperty"||i==="defineProperties")&&n==="Object"||i==="set"&&n==="Reflect"))return!1;const a=e.getArguments()[0];return a!==void 0&&r.isIdentifier(a)&&p(a)===s},K=(e,s)=>{if(r.isBinaryExpression(e))return z.has(e.getOperatorToken().getText())&&d(e.getLeft(),s);if(r.isDeleteExpression(e))return d(e.getExpression(),s);if(r.isPrefixUnaryExpression(e)||r.isPostfixUnaryExpression(e)){const t=e.getOperatorToken();return(t===u.PlusPlusToken||t===u.MinusMinusToken)&&d(e.getOperand(),s)}return r.isCallExpression(e)?H(e,s):!1},W=(e,s)=>{const t=p(e);return t===void 0?!0:s.some(i=>i.getDescendants().some(o=>K(o,t)))},Y=e=>{if(r.isObjectLiteralExpression(e))return e;if(!r.isIdentifier(e))return;const s=e.getSymbol(),t=s?.getAliasedSymbol()?.getDeclarations()??s?.getDeclarations()??[];for(const i of t){if(!r.isVariableDeclaration(i))continue;const o=i.getInitializer();if(!o||!r.isObjectLiteralExpression(o))continue;const n=i.getParent();if(!r.isVariableDeclarationList(n)||n.getDeclarationKind()!==O.Const)continue;const c=[i.getSourceFile(),e.getSourceFile()].filter((a,f,b)=>b.findIndex(v=>v.getFilePath()===a.getFilePath())===f);if(!W(e,c))return o}},B=(e,s)=>{const t=F(s,L);if(!N(t))return;const i=e.getSourceFile(t)??e.addSourceFileAtPath(t),o=P(i);if(!o||!r.isCallExpression(o))return{hasFcm:!0,hasWebPush:!0};const n=o.getExpression(),c=r.isIdentifier(n)&&V(n)?o.getArguments()[0]:void 0,a=c===void 0?void 0:Y(c);return!a||a.getProperties().some(f=>r.isSpreadAssignment(f))?{hasFcm:!0,hasWebPush:!0}:{hasFcm:g(a,"fcm")!==void 0,hasWebPush:g(a,"webPush")!==void 0}},te=(e,s)=>{const t=B(e,s);return t===void 0?void 0:{...t,usesPush:R(e,s)}};export{L as NOTIFY_FILENAME,ee as discoverNotifyCalls,B as discoverNotifyChannels,te as discoverNotifyConfig};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{m}from"./modules-
|
|
1
|
+
import{m}from"./modules-DE0ksIeR.mjs";import{r as u}from"./json-data-Chfs2Cz5.mjs";import{validatorIrToJsonSchema as p,objectSchema as l,LUNORA_ERROR_CODES as d}from"./LUNORA_ERROR_CODES-CjACC-MQ.mjs";import{G as h}from"./shared-DhqnD5R3.mjs";import{s as i}from"./dispatch-namespace-DwTjD7BU.mjs";const R="1.3.2",g={description:"Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON."},O=(e,r)=>e==="stream"?`Open the \`stream\` \`${r}\` over the Lunora WebSocket. It yields chunks rather than one result, so its \`result\` schema is a placeholder.`:`Invoke the \`${e}\` \`${r}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${r}", "args": { … } }\`).`,S=(e,r)=>{const o=`${i(e.filePath)}:${e.exportName}`;return{description:O(e.kind,o),errors:d.map((s,a)=>({code:-32e3-a,data:{code:s},message:s})),name:o,params:[{description:"The function's argument object (the RPC envelope's `args`).",name:"args",required:Object.keys(e.args).length>0,schema:l(e.args)}],result:{name:"result",schema:e.output&&e.kind!=="stream"?p(e.output):g},summary:`${e.kind}: ${o}`,"x-lunora-function-kind":e.kind,...e.description?{"x-lunora-description":e.description}:{},"x-tags":[{name:r}]}},v=e=>{const r=e.version??"0.0.0",n=e.functions.filter(t=>t.visibility!=="internal"),o=e.modules??[],s=n.map(t=>S(t,m(o,t.filePath))).toSorted((t,c)=>t.name.localeCompare(c.name));return{info:{description:"Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",title:"Lunora RPC",version:r},methods:s,openrpc:R}},E=e=>`${JSON.stringify(v(e),void 0,2)}
|
|
2
2
|
`,N=e=>`${h}export const openRpcSpec = ${u(e,"Record<string, unknown>")};
|
|
3
3
|
`;export{R as OPENRPC_VERSION,v as buildOpenRpcDocument,E as emitOpenRpc,N as emitOpenRpcModule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as x}from"node:fs";import{join as f}from"node:path";import{LunoraError as b}from"@lunora/errors";import{queueDefaultName as q,queueBindingName as y}from"@lunora/queue";import{SyntaxKind as S,Node as u}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{lunoraRelativePath as g,findObjectProperty as l,stringPropertyFor as w}from"./isTestPath-
|
|
1
|
+
import{existsSync as x}from"node:fs";import{join as f}from"node:path";import{LunoraError as b}from"@lunora/errors";import{queueDefaultName as q,queueBindingName as y}from"@lunora/queue";import{SyntaxKind as S,Node as u}from"ts-morph";import{diagnosticAt as c}from"./CodegenDiagnosticError-BUXlG3P-.mjs";import{lunoraRelativePath as g,findObjectProperty as l,stringPropertyFor as w}from"./isTestPath-ClgKgMYM.mjs";import{a as v}from"./attribution-DjweYNgJ.mjs";import{r as $}from"./handler-reference-D2EE2q-4.mjs";import{d as F}from"./modules-DE0ksIeR.mjs";const h="queues.ts",P=o=>{const e=t=>t==="defineQueue"||t==="defineSubscription"||t==="defineTopic",i=o.getSymbol();if(!i){const t=o.getText();return e(t)?t:void 0}for(const t of i.getDeclarations()){if(!u.isImportSpecifier(t))continue;if(t.getImportDeclaration().getModuleSpecifierValue()!=="@lunora/queue")return;const n=t.getNameNode().getText();return e(n)?n:void 0}},d=w("queue"),E=(o,e,i)=>{if(u.isNumericLiteral(o))return o.getLiteralValue();throw c(o,`queue "${e}": \`${i}\` must be a static numeric literal — it is deploy configuration codegen writes into wrangler.jsonc`)},I={maxBatchSize:{integer:!0,max:100,min:1},maxBatchTimeout:{integer:!1,max:60,min:0},maxConcurrency:{integer:!0,max:250,min:1},maxRetries:{integer:!0,max:100,min:0},retryDelay:{integer:!0,max:86400,min:0}},A=(o,e)=>{const i={};for(const[t,n]of Object.entries(I)){const r=l(o,t);if(r&&u.isPropertyAssignment(r)){const a=E(r.getInitializerOrThrow(),e,t);if(a<n.min||a>n.max||n.integer&&!Number.isInteger(a))throw c(r,`queue "${e}": \`${t}\` must be ${n.integer?"an integer":"a number"} from ${n.min.toString()} to ${n.max.toString()} (got ${a.toString()})`);i[t]=a}}return i},T=(o,e)=>{const i=l(o,"name");if(!i||!u.isPropertyAssignment(i))return;const t=d(i.getInitializerOrThrow(),e,"name");if(t.length===0)throw c(i,`queue "${e}": \`name\` must be a non-empty string when provided`);return t},N=(o,e,i,t)=>{const n=$(l(o,"handler"),t)?.site,r={bindingName:y(e),exportName:e,filePath:g(t,o.getSourceFile().getFilePath()),mode:"push",name:T(o,e)??q(e),...i===void 0?{}:{topic:i},...n===void 0?{}:{handlerSite:n},tuning:{}},a=l(o,"mode");if(a&&u.isPropertyAssignment(a)){if(i!==void 0)throw c(a,`subscription "${e}": \`mode\` is not allowed — a subscription is always a push consumer`);const m=d(a.getInitializerOrThrow(),e,"mode");if(m!=="push"&&m!=="pull")throw c(a,`queue "${e}": \`mode\` must be "push" or "pull" (got ${JSON.stringify(m)})`);r.mode=m}const s=l(o,"deadLetterQueue");return s&&u.isPropertyAssignment(s)&&(r.tuning.deadLetterQueue=d(s.getInitializerOrThrow(),e,"deadLetterQueue")),Object.assign(r.tuning,A(o,e)),r},O=(o,e,i)=>{const t=o.getArguments()[0];if(!t||!u.isObjectLiteralExpression(t))throw c(o,`queue "${e}": defineQueue must be passed an inline object literal`);return N(t,e,void 0,i)},p=(o,e)=>`${o}:${e}`,Q=o=>{const e=o.getSymbol(),i=(e?.isAlias()===!0?e.getAliasedSymbol():e)?.getDeclarations()[0];return i!==void 0&&u.isVariableDeclaration(i)?p(i.getSourceFile().getFilePath(),i.getName()):p(o.getSourceFile().getFilePath(),o.getText())},L=(o,e,i,t)=>{const[n,r]=o.getArguments(),a=n!==void 0&&u.isIdentifier(n)?i.get(Q(n)):void 0;if(a===void 0)throw c(n??o,`subscription "${e}": the first argument must name a \`defineTopic()\` export of lunora/queues.ts or a module's queues.ts`);if(!r||!u.isObjectLiteralExpression(r))throw c(o,`subscription "${e}": defineSubscription must be passed an inline object literal`);return N(r,e,a,t)},U=o=>{const e=[];for(const i of o.getVariableDeclarations()){const t=i.getInitializer();if(t?.getKind()!==S.CallExpression)continue;const n=t,r=n.getExpression(),a=u.isIdentifier(r)?P(r):void 0;if(a===void 0)continue;const s=i.getNameNode();if(!u.isIdentifier(s)){if(i.getVariableStatement()?.hasExportKeyword()!==!0)continue;throw c(s,`${a} exports must be plain named exports (no destructuring)`)}const m=v(i,"binding");m!==void 0&&e.push({call:n,exportName:m,factory:a,localName:s.getText()})}return e},C=(o,e)=>{const i=new Map;for(const t of o){const n=g(e,t.call.getSourceFile().getFilePath()),r=i.get(t.exportName);if(r!==void 0)throw c(t.call,`"${t.exportName}" is exported by both lunora/${r}.ts and lunora/${n}.ts — queue and topic export names must be unique across the app`);i.set(t.exportName,n)}},M=(o,e)=>{const i=o.flatMap(s=>U(s));C(i,e);const t=i.filter(s=>s.factory==="defineTopic"),n=new Map(t.map(s=>[p(s.call.getSourceFile().getFilePath(),s.localName),s.exportName])),r=[];for(const s of i)s.factory==="defineQueue"?r.push(O(s.call,s.exportName,e)):s.factory==="defineSubscription"&&r.push(L(s.call,s.exportName,n,e));const a=t.map(s=>({exportName:s.exportName,filePath:g(e,s.call.getSourceFile().getFilePath())}));return{queues:r,topics:a}},j=(o,e)=>[f(e,h),...F(o,e).map(i=>f(e,i.name,h))].filter(i=>x(i)),z=o=>{const e=new Map,i=new Map;for(const t of o){const n=e.get(t.name);if(n!==void 0)throw new b("DUPLICATE_QUEUE_NAME",`Duplicate queue name "${t.name}": produced by both "${n}" and "${t.exportName}". Deployed queue names must be unique across the project.`,{status:500});e.set(t.name,t.exportName);const r=i.get(t.bindingName);if(r!==void 0)throw new b("DUPLICATE_QUEUE_BINDING",`Duplicate queue binding "${t.bindingName}": produced by both "${r}" and "${t.exportName}". Queue export names must yield unique binding names.`,{status:500});i.set(t.bindingName,t.exportName)}},D=(o,e)=>{const i=j(o,e).map(a=>o.getSourceFile(a)??o.addSourceFileAtPath(a)),{queues:t,topics:n}=M(i,e),r=t.toSorted((a,s)=>a.exportName.localeCompare(s.exportName));return z(r),{queues:r,topics:n.toSorted((a,s)=>a.exportName.localeCompare(s.exportName))}},X=(o,e)=>D(o,e).queues;export{h as QUEUES_FILENAME,D as discoverQueueDeclarations,X as discoverQueues};
|