@prisma-next/framework-components 0.3.0-dev.158 → 0.3.0-dev.160
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/authoring.d.mts +1 -1
- package/dist/{codec-types-D9ixsdxw.d.mts → codec-types-B58nCJiu.d.mts} +1 -1
- package/dist/{codec-types-D9ixsdxw.d.mts.map → codec-types-B58nCJiu.d.mts.map} +1 -1
- package/dist/codec.d.mts +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs +1 -1
- package/dist/control.d.mts +5 -5
- package/dist/{emission-types-Dt9_NXRb.d.mts → emission-types-B3UblxTu.d.mts} +2 -2
- package/dist/{emission-types-Dt9_NXRb.d.mts.map → emission-types-B3UblxTu.d.mts.map} +1 -1
- package/dist/emission.d.mts +2 -2
- package/dist/execution.d.mts +1 -1
- package/dist/execution.mjs +1 -1
- package/dist/{framework-authoring-Dt-7rbX9.d.mts → framework-authoring-D1-JZ37B.d.mts} +1 -1
- package/dist/{framework-authoring-Dt-7rbX9.d.mts.map → framework-authoring-D1-JZ37B.d.mts.map} +1 -1
- package/dist/{framework-components-Bl3SLyGG.mjs → framework-components-C8ZhSwXe.mjs} +1 -1
- package/dist/{framework-components-Bl3SLyGG.mjs.map → framework-components-C8ZhSwXe.mjs.map} +1 -1
- package/dist/{framework-components-BGmbAKyD.d.mts → framework-components-DoWmh6GH.d.mts} +4 -4
- package/dist/{framework-components-BGmbAKyD.d.mts.map → framework-components-DoWmh6GH.d.mts.map} +1 -1
- package/dist/runtime.d.mts +76 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +95 -0
- package/dist/runtime.mjs.map +1 -0
- package/dist/{types-import-spec-BupmVNbx.d.mts → types-import-spec-Ddp4fNmt.d.mts} +1 -1
- package/dist/types-import-spec-Ddp4fNmt.d.mts.map +1 -0
- package/package.json +5 -4
- package/src/async-iterable-result.ts +86 -0
- package/src/exports/runtime.ts +11 -0
- package/src/runtime-error.ts +39 -0
- package/src/runtime-middleware.ts +82 -0
- package/dist/types-import-spec-BupmVNbx.d.mts.map +0 -1
package/dist/authoring.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as resolveAuthoringTemplateValue, a as AuthoringFieldNamespace, c as AuthoringStorageTypeTemplate, d as AuthoringTypeNamespace, f as instantiateAuthoringFieldPreset, g as isAuthoringTypeConstructorDescriptor, h as isAuthoringFieldPresetDescriptor, i as AuthoringContributions, l as AuthoringTemplateValue, m as isAuthoringArgRef, n as AuthoringArgumentDescriptor, o as AuthoringFieldPresetDescriptor, p as instantiateAuthoringTypeConstructor, r as AuthoringColumnDefaultTemplate, s as AuthoringFieldPresetOutput, t as AuthoringArgRef, u as AuthoringTypeConstructorDescriptor, v as validateAuthoringHelperArguments } from "./framework-authoring-
|
|
1
|
+
import { _ as resolveAuthoringTemplateValue, a as AuthoringFieldNamespace, c as AuthoringStorageTypeTemplate, d as AuthoringTypeNamespace, f as instantiateAuthoringFieldPreset, g as isAuthoringTypeConstructorDescriptor, h as isAuthoringFieldPresetDescriptor, i as AuthoringContributions, l as AuthoringTemplateValue, m as isAuthoringArgRef, n as AuthoringArgumentDescriptor, o as AuthoringFieldPresetDescriptor, p as instantiateAuthoringTypeConstructor, r as AuthoringColumnDefaultTemplate, s as AuthoringFieldPresetOutput, t as AuthoringArgRef, u as AuthoringTypeConstructorDescriptor, v as validateAuthoringHelperArguments } from "./framework-authoring-D1-JZ37B.mjs";
|
|
2
2
|
export { type AuthoringArgRef, type AuthoringArgumentDescriptor, type AuthoringColumnDefaultTemplate, type AuthoringContributions, type AuthoringFieldNamespace, type AuthoringFieldPresetDescriptor, type AuthoringFieldPresetOutput, type AuthoringStorageTypeTemplate, type AuthoringTemplateValue, type AuthoringTypeConstructorDescriptor, type AuthoringTypeNamespace, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringFieldPresetDescriptor, isAuthoringTypeConstructorDescriptor, resolveAuthoringTemplateValue, validateAuthoringHelperArguments };
|
|
@@ -37,4 +37,4 @@ interface CodecLookup {
|
|
|
37
37
|
declare const emptyCodecLookup: CodecLookup;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { emptyCodecLookup as i, CodecLookup as n, CodecTrait as r, Codec as t };
|
|
40
|
-
//# sourceMappingURL=codec-types-
|
|
40
|
+
//# sourceMappingURL=codec-types-B58nCJiu.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec-types-
|
|
1
|
+
{"version":3,"file":"codec-types-B58nCJiu.d.mts","names":[],"sources":["../src/codec-types.ts"],"sourcesContent":[],"mappings":";;;KAEY,UAAA;;AAAZ;AAaA;;;;;;;;;AAiBoB,UAjBH,KAiBG,CAAA,WAAA,MAAA,GAAA,MAAA,EAAA,gBAAA,SAfO,UAeP,EAAA,GAAA,SAf+B,UAe/B,EAAA,EAAA,QAAA,OAAA,EAAA,MAAA,OAAA,CAAA,CAAA;EAAM;EAEP,SAAA,EAAA,EAZJ,EAYI;EAAY;EAEC,SAAA,WAAA,EAAA,SAAA,MAAA,EAAA;EAAM;EAGrB,SAAA,MAAW,CAAA,EAbR,OAaQ;EAIf;iBAfI,MAAM;;eAER,QAAQ;;oBAEH,MAAM;;mBAEP,YAAY;;gCAEC;;UAGf,WAAA;mBACE;;cAGN,kBAAkB"}
|
package/dist/codec.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as emptyCodecLookup, n as CodecLookup, r as CodecTrait, t as Codec } from "./codec-types-
|
|
1
|
+
import { i as emptyCodecLookup, n as CodecLookup, r as CodecTrait, t as Codec } from "./codec-types-B58nCJiu.mjs";
|
|
2
2
|
export { type Codec, type CodecLookup, type CodecTrait, emptyCodecLookup };
|
package/dist/components.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-
|
|
1
|
+
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-DoWmh6GH.mjs";
|
|
2
2
|
export { type AdapterDescriptor, type AdapterInstance, type AdapterPackRef, type ComponentDescriptor, type ComponentMetadata, type ContractComponentRequirementsCheckInput, type ContractComponentRequirementsCheckResult, type DriverDescriptor, type DriverInstance, type DriverPackRef, type ExtensionDescriptor, type ExtensionInstance, type ExtensionPackRef, type FamilyDescriptor, type FamilyInstance, type FamilyPackRef, type PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, checkContractComponentRequirements };
|
package/dist/components.mjs
CHANGED
package/dist/control.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as AuthoringFieldNamespace, d as AuthoringTypeNamespace, i as AuthoringContributions } from "./framework-authoring-
|
|
2
|
-
import { n as CodecLookup } from "./codec-types-
|
|
3
|
-
import { t as TypesImportSpec } from "./types-import-spec-
|
|
4
|
-
import { a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, y as TargetDescriptor } from "./framework-components-
|
|
5
|
-
import { t as EmissionSpi } from "./emission-types-
|
|
1
|
+
import { a as AuthoringFieldNamespace, d as AuthoringTypeNamespace, i as AuthoringContributions } from "./framework-authoring-D1-JZ37B.mjs";
|
|
2
|
+
import { n as CodecLookup } from "./codec-types-B58nCJiu.mjs";
|
|
3
|
+
import { t as TypesImportSpec } from "./types-import-spec-Ddp4fNmt.mjs";
|
|
4
|
+
import { a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, v as TargetBoundComponentDescriptor, y as TargetDescriptor } from "./framework-components-DoWmh6GH.mjs";
|
|
5
|
+
import { t as EmissionSpi } from "./emission-types-B3UblxTu.mjs";
|
|
6
6
|
import { Contract, ContractMarkerRecord } from "@prisma-next/contract/types";
|
|
7
7
|
import { Result } from "@prisma-next/utils/result";
|
|
8
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as TypesImportSpec } from "./types-import-spec-
|
|
1
|
+
import { t as TypesImportSpec } from "./types-import-spec-Ddp4fNmt.mjs";
|
|
2
2
|
import { Contract, ContractModel } from "@prisma-next/contract/types";
|
|
3
3
|
|
|
4
4
|
//#region src/emission-types.d.ts
|
|
@@ -21,4 +21,4 @@ interface EmissionSpi {
|
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { GenerateContractTypesOptions as n, ValidationContext as r, EmissionSpi as t };
|
|
24
|
-
//# sourceMappingURL=emission-types-
|
|
24
|
+
//# sourceMappingURL=emission-types-B3UblxTu.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emission-types-
|
|
1
|
+
{"version":3,"file":"emission-types-B3UblxTu.d.mts","names":[],"sources":["../src/emission-types.ts"],"sourcesContent":[],"mappings":";;;;UAGiB,4BAAA;uCACsB,cAAc;AADrD;AAIiB,UAAA,iBAAA,CAAiB;EACU,SAAA,gBAAA,CAAA,EAAd,aAAc,CAAA,eAAA,CAAA;EAAd,SAAA,oBAAA,CAAA,EACI,aADJ,CACkB,eADlB,CAAA;EACkB,SAAA,YAAA,CAAA,EACtB,aADsB,CAAA,MAAA,CAAA;;AACtB,UAGT,WAAA,CAHS;EAAa,SAAA,EAAA,EAAA,MAAA;EAGtB,mBAAW,CAAA,QAAA,EAGI,QAHJ,EAAA,mBAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAGI,wBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,EAEqB,aAFrB,CAAA,EAAA,MAAA;EAEqB,gBAAA,EAAA,EAAA,MAAA,EAAA;EAIpB,oBAAA,CAAA,OAAA,CAAA,EAAA,4BAAA,CAAA,EAAA,MAAA;EAA4B,qBAAA,EAAA,EAAA,MAAA"}
|
package/dist/emission.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as TypesImportSpec } from "./types-import-spec-
|
|
2
|
-
import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-
|
|
1
|
+
import { t as TypesImportSpec } from "./types-import-spec-Ddp4fNmt.mjs";
|
|
2
|
+
import { n as GenerateContractTypesOptions, r as ValidationContext, t as EmissionSpi } from "./emission-types-B3UblxTu.mjs";
|
|
3
3
|
export { type EmissionSpi, type GenerateContractTypesOptions, type TypesImportSpec, type ValidationContext };
|
package/dist/execution.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, y as TargetDescriptor } from "./framework-components-
|
|
1
|
+
import { b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, h as FamilyInstance, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, t as AdapterDescriptor, y as TargetDescriptor } from "./framework-components-DoWmh6GH.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/execution-instances.d.ts
|
|
4
4
|
interface RuntimeFamilyInstance<TFamilyId extends string> extends FamilyInstance<TFamilyId> {}
|
package/dist/execution.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as checkContractComponentRequirements } from "./framework-components-
|
|
1
|
+
import { t as checkContractComponentRequirements } from "./framework-components-C8ZhSwXe.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/execution-requirements.ts
|
|
4
4
|
function assertRuntimeContractRequirementsSatisfied({ contract, family, target, adapter, extensionPacks }) {
|
|
@@ -96,4 +96,4 @@ declare function instantiateAuthoringFieldPreset(descriptor: AuthoringFieldPrese
|
|
|
96
96
|
};
|
|
97
97
|
//#endregion
|
|
98
98
|
export { resolveAuthoringTemplateValue as _, AuthoringFieldNamespace as a, AuthoringStorageTypeTemplate as c, AuthoringTypeNamespace as d, instantiateAuthoringFieldPreset as f, isAuthoringTypeConstructorDescriptor as g, isAuthoringFieldPresetDescriptor as h, AuthoringContributions as i, AuthoringTemplateValue as l, isAuthoringArgRef as m, AuthoringArgumentDescriptor as n, AuthoringFieldPresetDescriptor as o, instantiateAuthoringTypeConstructor as p, AuthoringColumnDefaultTemplate as r, AuthoringFieldPresetOutput as s, AuthoringArgRef as t, AuthoringTypeConstructorDescriptor as u, validateAuthoringHelperArguments as v };
|
|
99
|
-
//# sourceMappingURL=framework-authoring-
|
|
99
|
+
//# sourceMappingURL=framework-authoring-D1-JZ37B.d.mts.map
|
package/dist/{framework-authoring-Dt-7rbX9.d.mts.map → framework-authoring-D1-JZ37B.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-authoring-
|
|
1
|
+
{"version":3,"file":"framework-authoring-D1-JZ37B.d.m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AuFgB,UAtRC,qCAAA,CAuRH;EAUE,SAAA,IAAA,EAAA,SAAA;kBA/RE;;UAGD,sCAAA;;uBAEM;;KAGX,8BAAA,GACR,wCACA;UAEa,0BAAA,SAAmC;;qBAE/B;8BACS;;;;UAKb,8BAAA;;2BAEU;mBACR;;KAGP,sBAAA;2BACe,qCAAqC;;KAGpD,uBAAA;2BACe,iCAAiC;;UAG3C,sBAAA;kBACC;mBACC;;iBAGH,iBAAA,2BAA4C;iBAkB5C,oCAAA,2BAEJ;iBAUI,gCAAA,2BAEJ;iBAUI,6BAAA,WACJ;iBA2GI,gCAAA,2CAEQ;iBAqFR,mCAAA,aACF;;;wBAKU;;iBAKR,+BAAA,aACF;;;;0BAMY"}
|
package/dist/{framework-components-Bl3SLyGG.mjs.map → framework-components-C8ZhSwXe.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-components-Bl3SLyGG.mjs","names":[],"sources":["../src/framework-components.ts"],"sourcesContent":["import type { Codec } from './codec-types';\nimport type { AuthoringContributions } from './framework-authoring';\nimport type { TypesImportSpec } from './types-import-spec';\n\n/**\n * Declarative fields that describe component metadata.\n */\nexport interface ComponentMetadata {\n /** Component version (semver) */\n readonly version: string;\n\n /**\n * Capabilities this component provides.\n *\n * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into\n * the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);\n * keep these declarations in sync. Targets are identifiers/descriptors and typically do not\n * declare capabilities.\n */\n readonly capabilities?: Record<string, unknown>;\n\n /** Type imports for contract.d.ts generation */\n readonly types?: {\n readonly codecTypes?: {\n /**\n * Base codec types import spec.\n * Optional: adapters typically provide this, extensions usually don't.\n */\n readonly import?: TypesImportSpec;\n /**\n * Additional type-only imports for parameterized codec branded types.\n *\n * These imports are included in generated `contract.d.ts` but are NOT treated as\n * codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).\n *\n * Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`\n */\n readonly typeImports?: ReadonlyArray<TypesImportSpec>;\n /**\n * Optional control-plane hooks keyed by codecId.\n * Used by family-specific planners/verifiers to handle storage types.\n */\n readonly controlPlaneHooks?: Record<string, unknown>;\n /**\n * Codec instances contributed by this component.\n * Used to build a CodecLookup for codec-dispatched type rendering during emission.\n */\n readonly codecInstances?: ReadonlyArray<Codec>;\n };\n readonly operationTypes?: { readonly import: TypesImportSpec };\n readonly queryOperationTypes?: { readonly import: TypesImportSpec };\n readonly storage?: ReadonlyArray<{\n readonly typeId: string;\n readonly familyId: string;\n readonly targetId: string;\n readonly nativeType?: string;\n }>;\n };\n\n /**\n * Optional pure-data authoring contributions exposed by this component.\n *\n * These contributions are safe to include on pack refs and descriptors because\n * they contain only declarative metadata. Higher-level authoring packages may\n * project them into concrete helper functions for TS-first workflows.\n */\n readonly authoring?: AuthoringContributions;\n}\n\n/**\n * Base descriptor for any framework component.\n *\n * All component descriptors share these fundamental properties that identify\n * the component and provide its metadata. This interface is extended by\n * specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).\n *\n * @template Kind - Discriminator literal identifying the component type.\n * Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',\n * but the type accepts any string to allow ecosystem extensions.\n *\n * @example\n * ```ts\n * // All descriptors have these properties\n * descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)\n * descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')\n * descriptor.version // Component version (semver)\n * ```\n */\nexport interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {\n /** Discriminator identifying the component type */\n readonly kind: Kind;\n\n /** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */\n readonly id: string;\n}\n\nexport interface ContractComponentRequirementsCheckInput {\n readonly contract: {\n readonly target: string;\n readonly targetFamily?: string | undefined;\n readonly extensionPacks?: Record<string, unknown> | undefined;\n };\n readonly expectedTargetFamily?: string | undefined;\n readonly expectedTargetId?: string | undefined;\n readonly providedComponentIds: Iterable<string>;\n}\n\nexport interface ContractComponentRequirementsCheckResult {\n readonly familyMismatch?: { readonly expected: string; readonly actual: string } | undefined;\n readonly targetMismatch?: { readonly expected: string; readonly actual: string } | undefined;\n readonly missingExtensionPackIds: readonly string[];\n}\n\nexport function checkContractComponentRequirements(\n input: ContractComponentRequirementsCheckInput,\n): ContractComponentRequirementsCheckResult {\n const providedIds = new Set<string>();\n for (const id of input.providedComponentIds) {\n providedIds.add(id);\n }\n\n const requiredExtensionPackIds = input.contract.extensionPacks\n ? Object.keys(input.contract.extensionPacks)\n : [];\n const missingExtensionPackIds = requiredExtensionPackIds.filter((id) => !providedIds.has(id));\n\n const expectedTargetFamily = input.expectedTargetFamily;\n const contractTargetFamily = input.contract.targetFamily;\n const familyMismatch =\n expectedTargetFamily !== undefined &&\n contractTargetFamily !== undefined &&\n contractTargetFamily !== expectedTargetFamily\n ? { expected: expectedTargetFamily, actual: contractTargetFamily }\n : undefined;\n\n const expectedTargetId = input.expectedTargetId;\n const contractTargetId = input.contract.target;\n const targetMismatch =\n expectedTargetId !== undefined && contractTargetId !== expectedTargetId\n ? { expected: expectedTargetId, actual: contractTargetId }\n : undefined;\n\n return {\n ...(familyMismatch ? { familyMismatch } : {}),\n ...(targetMismatch ? { targetMismatch } : {}),\n missingExtensionPackIds,\n };\n}\n\n/**\n * Descriptor for a family component.\n *\n * A \"family\" represents a category of data sources with shared semantics\n * (e.g., SQL databases, document stores). Families define:\n * - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)\n * - Contract structure (tables vs collections, columns vs fields)\n * - Type system and codecs\n *\n * Families are the top-level grouping. Each family contains multiple targets\n * (e.g., SQL family contains Postgres, MySQL, SQLite targets).\n *\n * Extended by plane-specific descriptors:\n * - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations\n * - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods\n *\n * @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')\n *\n * @example\n * ```ts\n * import sql from '@prisma-next/family-sql/control';\n *\n * sql.kind // 'family'\n * sql.familyId // 'sql'\n * sql.id // 'sql'\n * ```\n */\nexport interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {\n /** The family identifier (e.g., 'sql', 'document') */\n readonly familyId: TFamilyId;\n}\n\n/**\n * Descriptor for a target component.\n *\n * A \"target\" represents a specific database or data store within a family\n * (e.g., Postgres, MySQL, MongoDB). Targets define:\n * - Native type mappings (e.g., Postgres int4 → TypeScript number)\n * - Target-specific capabilities (e.g., RETURNING, LATERAL joins)\n *\n * Targets are bound to a family and provide the target-specific implementation\n * details that adapters and drivers use.\n *\n * Extended by plane-specific descriptors:\n * - `ControlTargetDescriptor` - adds optional `migrations` capability\n * - `RuntimeTargetDescriptor` - adds runtime factory method\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')\n *\n * @example\n * ```ts\n * import postgres from '@prisma-next/target-postgres/control';\n *\n * postgres.kind // 'target'\n * postgres.familyId // 'sql'\n * postgres.targetId // 'postgres'\n * ```\n */\nexport interface TargetDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'target'> {\n /** The family this target belongs to */\n readonly familyId: TFamilyId;\n\n /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */\n readonly targetId: TTargetId;\n}\n\n/**\n * Base shape for any pack reference.\n * Pack refs are pure JSON-friendly objects safe to import in authoring flows.\n */\nexport interface PackRefBase<Kind extends string, TFamilyId extends string>\n extends ComponentMetadata {\n readonly kind: Kind;\n readonly id: string;\n readonly familyId: TFamilyId;\n readonly targetId?: string;\n readonly authoring?: AuthoringContributions;\n}\n\nexport type FamilyPackRef<TFamilyId extends string = string> = PackRefBase<'family', TFamilyId>;\n\nexport type TargetPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'target', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type AdapterPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'adapter', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type ExtensionPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'extension', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type DriverPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'driver', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\n/**\n * Descriptor for an adapter component.\n *\n * An \"adapter\" provides the protocol and dialect implementation for a target.\n * Adapters handle:\n * - SQL/query generation (lowering AST to target-specific syntax)\n * - Codec registration (encoding/decoding between JS and wire types)\n * - Type mappings and coercions\n *\n * Adapters are bound to a specific family+target combination and work with\n * any compatible driver for that target.\n *\n * Extended by plane-specific descriptors:\n * - `ControlAdapterDescriptor` - control-plane factory\n * - `RuntimeAdapterDescriptor` - runtime factory\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import postgresAdapter from '@prisma-next/adapter-postgres/control';\n *\n * postgresAdapter.kind // 'adapter'\n * postgresAdapter.familyId // 'sql'\n * postgresAdapter.targetId // 'postgres'\n * ```\n */\nexport interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'adapter'> {\n /** The family this adapter belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this adapter is designed for */\n readonly targetId: TTargetId;\n}\n\n/**\n * Descriptor for a driver component.\n *\n * A \"driver\" provides the connection and execution layer for a target.\n * Drivers handle:\n * - Connection management (pooling, timeouts, retries)\n * - Query execution (sending SQL/commands, receiving results)\n * - Transaction management\n * - Wire protocol communication\n *\n * Drivers are bound to a specific family+target and work with any compatible\n * adapter. Multiple drivers can exist for the same target (e.g., node-postgres\n * vs postgres.js for Postgres).\n *\n * Extended by plane-specific descriptors:\n * - `ControlDriverDescriptor` - creates driver from connection URL\n * - `RuntimeDriverDescriptor` - creates driver with runtime options\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import postgresDriver from '@prisma-next/driver-postgres/control';\n *\n * postgresDriver.kind // 'driver'\n * postgresDriver.familyId // 'sql'\n * postgresDriver.targetId // 'postgres'\n * ```\n */\nexport interface DriverDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'driver'> {\n /** The family this driver belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this driver connects to */\n readonly targetId: TTargetId;\n}\n\n/**\n * Descriptor for an extension component.\n *\n * An \"extension\" adds optional capabilities to a target. Extensions can provide:\n * - Additional operations (e.g., vector similarity search with pgvector)\n * - Custom types and codecs (e.g., vector type)\n * - Extended query capabilities\n *\n * Extensions are bound to a specific family+target and are registered in the\n * config alongside the core components. Multiple extensions can be used together.\n *\n * Extended by plane-specific descriptors:\n * - `ControlExtensionDescriptor` - control-plane extension factory\n * - `RuntimeExtensionDescriptor` - runtime extension factory\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import pgvector from '@prisma-next/extension-pgvector/control';\n *\n * pgvector.kind // 'extension'\n * pgvector.familyId // 'sql'\n * pgvector.targetId // 'postgres'\n * ```\n */\nexport interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'extension'> {\n /** The family this extension belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this extension is designed for */\n readonly targetId: TTargetId;\n}\n\n/** Components bound to a specific family+target combination. */\nexport type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> =\n | TargetDescriptor<TFamilyId, TTargetId>\n | AdapterDescriptor<TFamilyId, TTargetId>\n | DriverDescriptor<TFamilyId, TTargetId>\n | ExtensionDescriptor<TFamilyId, TTargetId>;\n\nexport interface FamilyInstance<TFamilyId extends string> {\n readonly familyId: TFamilyId;\n}\n\nexport interface TargetInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface DriverInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n"],"mappings":";AAiHA,SAAgB,mCACd,OAC0C;CAC1C,MAAM,8BAAc,IAAI,KAAa;AACrC,MAAK,MAAM,MAAM,MAAM,qBACrB,aAAY,IAAI,GAAG;CAMrB,MAAM,2BAH2B,MAAM,SAAS,iBAC5C,OAAO,KAAK,MAAM,SAAS,eAAe,GAC1C,EAAE,EACmD,QAAQ,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;CAE7F,MAAM,uBAAuB,MAAM;CACnC,MAAM,uBAAuB,MAAM,SAAS;CAC5C,MAAM,iBACJ,yBAAyB,UACzB,yBAAyB,UACzB,yBAAyB,uBACrB;EAAE,UAAU;EAAsB,QAAQ;EAAsB,GAChE;CAEN,MAAM,mBAAmB,MAAM;CAC/B,MAAM,mBAAmB,MAAM,SAAS;CACxC,MAAM,iBACJ,qBAAqB,UAAa,qBAAqB,mBACnD;EAAE,UAAU;EAAkB,QAAQ;EAAkB,GACxD;AAEN,QAAO;EACL,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C;EACD"}
|
|
1
|
+
{"version":3,"file":"framework-components-C8ZhSwXe.mjs","names":[],"sources":["../src/framework-components.ts"],"sourcesContent":["import type { Codec } from './codec-types';\nimport type { AuthoringContributions } from './framework-authoring';\nimport type { TypesImportSpec } from './types-import-spec';\n\n/**\n * Declarative fields that describe component metadata.\n */\nexport interface ComponentMetadata {\n /** Component version (semver) */\n readonly version: string;\n\n /**\n * Capabilities this component provides.\n *\n * For adapters, capabilities must be declared on the adapter descriptor (so they are emitted into\n * the contract) and also exposed in runtime adapter code (e.g. `adapter.profile.capabilities`);\n * keep these declarations in sync. Targets are identifiers/descriptors and typically do not\n * declare capabilities.\n */\n readonly capabilities?: Record<string, unknown>;\n\n /** Type imports for contract.d.ts generation */\n readonly types?: {\n readonly codecTypes?: {\n /**\n * Base codec types import spec.\n * Optional: adapters typically provide this, extensions usually don't.\n */\n readonly import?: TypesImportSpec;\n /**\n * Additional type-only imports for parameterized codec branded types.\n *\n * These imports are included in generated `contract.d.ts` but are NOT treated as\n * codec type maps (i.e., they should not be intersected into `export type CodecTypes = ...`).\n *\n * Example: `Vector<N>` for pgvector codecs that emit `Vector<1536>`\n */\n readonly typeImports?: ReadonlyArray<TypesImportSpec>;\n /**\n * Optional control-plane hooks keyed by codecId.\n * Used by family-specific planners/verifiers to handle storage types.\n */\n readonly controlPlaneHooks?: Record<string, unknown>;\n /**\n * Codec instances contributed by this component.\n * Used to build a CodecLookup for codec-dispatched type rendering during emission.\n */\n readonly codecInstances?: ReadonlyArray<Codec>;\n };\n readonly operationTypes?: { readonly import: TypesImportSpec };\n readonly queryOperationTypes?: { readonly import: TypesImportSpec };\n readonly storage?: ReadonlyArray<{\n readonly typeId: string;\n readonly familyId: string;\n readonly targetId: string;\n readonly nativeType?: string;\n }>;\n };\n\n /**\n * Optional pure-data authoring contributions exposed by this component.\n *\n * These contributions are safe to include on pack refs and descriptors because\n * they contain only declarative metadata. Higher-level authoring packages may\n * project them into concrete helper functions for TS-first workflows.\n */\n readonly authoring?: AuthoringContributions;\n}\n\n/**\n * Base descriptor for any framework component.\n *\n * All component descriptors share these fundamental properties that identify\n * the component and provide its metadata. This interface is extended by\n * specific descriptor types (FamilyDescriptor, TargetDescriptor, etc.).\n *\n * @template Kind - Discriminator literal identifying the component type.\n * Built-in kinds are 'family', 'target', 'adapter', 'driver', 'extension',\n * but the type accepts any string to allow ecosystem extensions.\n *\n * @example\n * ```ts\n * // All descriptors have these properties\n * descriptor.kind // The Kind type parameter (e.g., 'family', 'target', or custom kinds)\n * descriptor.id // Unique string identifier (e.g., 'sql', 'postgres')\n * descriptor.version // Component version (semver)\n * ```\n */\nexport interface ComponentDescriptor<Kind extends string> extends ComponentMetadata {\n /** Discriminator identifying the component type */\n readonly kind: Kind;\n\n /** Unique identifier for this component (e.g., 'sql', 'postgres', 'pgvector') */\n readonly id: string;\n}\n\nexport interface ContractComponentRequirementsCheckInput {\n readonly contract: {\n readonly target: string;\n readonly targetFamily?: string | undefined;\n readonly extensionPacks?: Record<string, unknown> | undefined;\n };\n readonly expectedTargetFamily?: string | undefined;\n readonly expectedTargetId?: string | undefined;\n readonly providedComponentIds: Iterable<string>;\n}\n\nexport interface ContractComponentRequirementsCheckResult {\n readonly familyMismatch?: { readonly expected: string; readonly actual: string } | undefined;\n readonly targetMismatch?: { readonly expected: string; readonly actual: string } | undefined;\n readonly missingExtensionPackIds: readonly string[];\n}\n\nexport function checkContractComponentRequirements(\n input: ContractComponentRequirementsCheckInput,\n): ContractComponentRequirementsCheckResult {\n const providedIds = new Set<string>();\n for (const id of input.providedComponentIds) {\n providedIds.add(id);\n }\n\n const requiredExtensionPackIds = input.contract.extensionPacks\n ? Object.keys(input.contract.extensionPacks)\n : [];\n const missingExtensionPackIds = requiredExtensionPackIds.filter((id) => !providedIds.has(id));\n\n const expectedTargetFamily = input.expectedTargetFamily;\n const contractTargetFamily = input.contract.targetFamily;\n const familyMismatch =\n expectedTargetFamily !== undefined &&\n contractTargetFamily !== undefined &&\n contractTargetFamily !== expectedTargetFamily\n ? { expected: expectedTargetFamily, actual: contractTargetFamily }\n : undefined;\n\n const expectedTargetId = input.expectedTargetId;\n const contractTargetId = input.contract.target;\n const targetMismatch =\n expectedTargetId !== undefined && contractTargetId !== expectedTargetId\n ? { expected: expectedTargetId, actual: contractTargetId }\n : undefined;\n\n return {\n ...(familyMismatch ? { familyMismatch } : {}),\n ...(targetMismatch ? { targetMismatch } : {}),\n missingExtensionPackIds,\n };\n}\n\n/**\n * Descriptor for a family component.\n *\n * A \"family\" represents a category of data sources with shared semantics\n * (e.g., SQL databases, document stores). Families define:\n * - Query semantics and operations (SELECT, INSERT, find, aggregate, etc.)\n * - Contract structure (tables vs collections, columns vs fields)\n * - Type system and codecs\n *\n * Families are the top-level grouping. Each family contains multiple targets\n * (e.g., SQL family contains Postgres, MySQL, SQLite targets).\n *\n * Extended by plane-specific descriptors:\n * - `ControlFamilyDescriptor` - adds `emission` for CLI/tooling operations\n * - `RuntimeFamilyDescriptor` - adds runtime-specific factory methods\n *\n * @template TFamilyId - Literal type for the family identifier (e.g., 'sql', 'document')\n *\n * @example\n * ```ts\n * import sql from '@prisma-next/family-sql/control';\n *\n * sql.kind // 'family'\n * sql.familyId // 'sql'\n * sql.id // 'sql'\n * ```\n */\nexport interface FamilyDescriptor<TFamilyId extends string> extends ComponentDescriptor<'family'> {\n /** The family identifier (e.g., 'sql', 'document') */\n readonly familyId: TFamilyId;\n}\n\n/**\n * Descriptor for a target component.\n *\n * A \"target\" represents a specific database or data store within a family\n * (e.g., Postgres, MySQL, MongoDB). Targets define:\n * - Native type mappings (e.g., Postgres int4 → TypeScript number)\n * - Target-specific capabilities (e.g., RETURNING, LATERAL joins)\n *\n * Targets are bound to a family and provide the target-specific implementation\n * details that adapters and drivers use.\n *\n * Extended by plane-specific descriptors:\n * - `ControlTargetDescriptor` - adds optional `migrations` capability\n * - `RuntimeTargetDescriptor` - adds runtime factory method\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier (e.g., 'postgres', 'mysql')\n *\n * @example\n * ```ts\n * import postgres from '@prisma-next/target-postgres/control';\n *\n * postgres.kind // 'target'\n * postgres.familyId // 'sql'\n * postgres.targetId // 'postgres'\n * ```\n */\nexport interface TargetDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'target'> {\n /** The family this target belongs to */\n readonly familyId: TFamilyId;\n\n /** The target identifier (e.g., 'postgres', 'mysql', 'mongodb') */\n readonly targetId: TTargetId;\n}\n\n/**\n * Base shape for any pack reference.\n * Pack refs are pure JSON-friendly objects safe to import in authoring flows.\n */\nexport interface PackRefBase<Kind extends string, TFamilyId extends string>\n extends ComponentMetadata {\n readonly kind: Kind;\n readonly id: string;\n readonly familyId: TFamilyId;\n readonly targetId?: string;\n readonly authoring?: AuthoringContributions;\n}\n\nexport type FamilyPackRef<TFamilyId extends string = string> = PackRefBase<'family', TFamilyId>;\n\nexport type TargetPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'target', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type AdapterPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'adapter', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type ExtensionPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'extension', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\nexport type DriverPackRef<\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> = PackRefBase<'driver', TFamilyId> & {\n readonly targetId: TTargetId;\n};\n\n/**\n * Descriptor for an adapter component.\n *\n * An \"adapter\" provides the protocol and dialect implementation for a target.\n * Adapters handle:\n * - SQL/query generation (lowering AST to target-specific syntax)\n * - Codec registration (encoding/decoding between JS and wire types)\n * - Type mappings and coercions\n *\n * Adapters are bound to a specific family+target combination and work with\n * any compatible driver for that target.\n *\n * Extended by plane-specific descriptors:\n * - `ControlAdapterDescriptor` - control-plane factory\n * - `RuntimeAdapterDescriptor` - runtime factory\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import postgresAdapter from '@prisma-next/adapter-postgres/control';\n *\n * postgresAdapter.kind // 'adapter'\n * postgresAdapter.familyId // 'sql'\n * postgresAdapter.targetId // 'postgres'\n * ```\n */\nexport interface AdapterDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'adapter'> {\n /** The family this adapter belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this adapter is designed for */\n readonly targetId: TTargetId;\n}\n\n/**\n * Descriptor for a driver component.\n *\n * A \"driver\" provides the connection and execution layer for a target.\n * Drivers handle:\n * - Connection management (pooling, timeouts, retries)\n * - Query execution (sending SQL/commands, receiving results)\n * - Transaction management\n * - Wire protocol communication\n *\n * Drivers are bound to a specific family+target and work with any compatible\n * adapter. Multiple drivers can exist for the same target (e.g., node-postgres\n * vs postgres.js for Postgres).\n *\n * Extended by plane-specific descriptors:\n * - `ControlDriverDescriptor` - creates driver from connection URL\n * - `RuntimeDriverDescriptor` - creates driver with runtime options\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import postgresDriver from '@prisma-next/driver-postgres/control';\n *\n * postgresDriver.kind // 'driver'\n * postgresDriver.familyId // 'sql'\n * postgresDriver.targetId // 'postgres'\n * ```\n */\nexport interface DriverDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'driver'> {\n /** The family this driver belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this driver connects to */\n readonly targetId: TTargetId;\n}\n\n/**\n * Descriptor for an extension component.\n *\n * An \"extension\" adds optional capabilities to a target. Extensions can provide:\n * - Additional operations (e.g., vector similarity search with pgvector)\n * - Custom types and codecs (e.g., vector type)\n * - Extended query capabilities\n *\n * Extensions are bound to a specific family+target and are registered in the\n * config alongside the core components. Multiple extensions can be used together.\n *\n * Extended by plane-specific descriptors:\n * - `ControlExtensionDescriptor` - control-plane extension factory\n * - `RuntimeExtensionDescriptor` - runtime extension factory\n *\n * @template TFamilyId - Literal type for the family identifier\n * @template TTargetId - Literal type for the target identifier\n *\n * @example\n * ```ts\n * import pgvector from '@prisma-next/extension-pgvector/control';\n *\n * pgvector.kind // 'extension'\n * pgvector.familyId // 'sql'\n * pgvector.targetId // 'postgres'\n * ```\n */\nexport interface ExtensionDescriptor<TFamilyId extends string, TTargetId extends string>\n extends ComponentDescriptor<'extension'> {\n /** The family this extension belongs to */\n readonly familyId: TFamilyId;\n\n /** The target this extension is designed for */\n readonly targetId: TTargetId;\n}\n\n/** Components bound to a specific family+target combination. */\nexport type TargetBoundComponentDescriptor<TFamilyId extends string, TTargetId extends string> =\n | TargetDescriptor<TFamilyId, TTargetId>\n | AdapterDescriptor<TFamilyId, TTargetId>\n | DriverDescriptor<TFamilyId, TTargetId>\n | ExtensionDescriptor<TFamilyId, TTargetId>;\n\nexport interface FamilyInstance<TFamilyId extends string> {\n readonly familyId: TFamilyId;\n}\n\nexport interface TargetInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface AdapterInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface DriverInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n\nexport interface ExtensionInstance<TFamilyId extends string, TTargetId extends string> {\n readonly familyId: TFamilyId;\n readonly targetId: TTargetId;\n}\n"],"mappings":";AAiHA,SAAgB,mCACd,OAC0C;CAC1C,MAAM,8BAAc,IAAI,KAAa;AACrC,MAAK,MAAM,MAAM,MAAM,qBACrB,aAAY,IAAI,GAAG;CAMrB,MAAM,2BAH2B,MAAM,SAAS,iBAC5C,OAAO,KAAK,MAAM,SAAS,eAAe,GAC1C,EAAE,EACmD,QAAQ,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;CAE7F,MAAM,uBAAuB,MAAM;CACnC,MAAM,uBAAuB,MAAM,SAAS;CAC5C,MAAM,iBACJ,yBAAyB,UACzB,yBAAyB,UACzB,yBAAyB,uBACrB;EAAE,UAAU;EAAsB,QAAQ;EAAsB,GAChE;CAEN,MAAM,mBAAmB,MAAM;CAC/B,MAAM,mBAAmB,MAAM,SAAS;CACxC,MAAM,iBACJ,qBAAqB,UAAa,qBAAqB,mBACnD;EAAE,UAAU;EAAkB,QAAQ;EAAkB,GACxD;AAEN,QAAO;EACL,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C,GAAI,iBAAiB,EAAE,gBAAgB,GAAG,EAAE;EAC5C;EACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as AuthoringContributions } from "./framework-authoring-
|
|
2
|
-
import { t as Codec } from "./codec-types-
|
|
3
|
-
import { t as TypesImportSpec } from "./types-import-spec-
|
|
1
|
+
import { i as AuthoringContributions } from "./framework-authoring-D1-JZ37B.mjs";
|
|
2
|
+
import { t as Codec } from "./codec-types-B58nCJiu.mjs";
|
|
3
|
+
import { t as TypesImportSpec } from "./types-import-spec-Ddp4fNmt.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/framework-components.d.ts
|
|
6
6
|
|
|
@@ -330,4 +330,4 @@ interface ExtensionInstance<TFamilyId extends string, TTargetId extends string>
|
|
|
330
330
|
}
|
|
331
331
|
//#endregion
|
|
332
332
|
export { checkContractComponentRequirements as S, PackRefBase as _, ComponentMetadata as a, TargetInstance as b, DriverDescriptor as c, ExtensionDescriptor as d, ExtensionInstance as f, FamilyPackRef as g, FamilyInstance as h, ComponentDescriptor as i, DriverInstance as l, FamilyDescriptor as m, AdapterInstance as n, ContractComponentRequirementsCheckInput as o, ExtensionPackRef as p, AdapterPackRef as r, ContractComponentRequirementsCheckResult as s, AdapterDescriptor as t, DriverPackRef as u, TargetBoundComponentDescriptor as v, TargetPackRef as x, TargetDescriptor as y };
|
|
333
|
-
//# sourceMappingURL=framework-components-
|
|
333
|
+
//# sourceMappingURL=framework-components-DoWmh6GH.d.mts.map
|
package/dist/{framework-components-BGmbAKyD.d.mts.map → framework-components-DoWmh6GH.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-components-
|
|
1
|
+
{"version":3,"file":"framework-components-DoWmh6GH.d.mts","names":[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;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6Dc,mDAAmD;;qBAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,6EACP;;qBAEW;;qBAGA;;;;;;UAOJ,mEACP;iBACO;;qBAEI;;uBAEE;;KAGX,mDAAmD,sBAAsB;KAEzE,sFAGR,sBAAsB;qBACL;;KAGT,uFAGR,uBAAuB;qBACN;;KAGT,yFAGR,yBAAyB;qBACR;;KAGT,sFAGR,sBAAsB;qBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BJ,8EACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiCJ,6EACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,gFACP;;qBAEW;;qBAGA;;;KAIT,qFACR,iBAAiB,WAAW,aAC5B,kBAAkB,WAAW,aAC7B,iBAAiB,WAAW,aAC5B,oBAAoB,WAAW;UAElB;qBACI;;UAGJ;qBACI;qBACA;;UAGJ;qBACI;qBACA;;UAGJ;qBACI;qBACA;;UAGJ;qBACI;qBACA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PlanMeta } from "@prisma-next/contract/types";
|
|
2
|
+
|
|
3
|
+
//#region src/async-iterable-result.d.ts
|
|
4
|
+
declare class AsyncIterableResult<Row> implements AsyncIterable<Row>, PromiseLike<Row[]> {
|
|
5
|
+
private readonly generator;
|
|
6
|
+
private consumed;
|
|
7
|
+
private consumedBy;
|
|
8
|
+
private bufferedArrayPromise;
|
|
9
|
+
constructor(generator: AsyncGenerator<Row, void, unknown>);
|
|
10
|
+
[Symbol.asyncIterator](): AsyncIterator<Row>;
|
|
11
|
+
toArray(): Promise<Row[]>;
|
|
12
|
+
first(): Promise<Row | null>;
|
|
13
|
+
firstOrThrow(): Promise<Row>;
|
|
14
|
+
then<TResult1 = Row[], TResult2 = never>(onfulfilled?: ((value: Row[]) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/runtime-error.d.ts
|
|
18
|
+
interface RuntimeErrorEnvelope extends Error {
|
|
19
|
+
readonly code: string;
|
|
20
|
+
readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME';
|
|
21
|
+
readonly severity: 'error';
|
|
22
|
+
readonly details?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
declare function runtimeError(code: string, message: string, details?: Record<string, unknown>): RuntimeErrorEnvelope;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/runtime-middleware.d.ts
|
|
27
|
+
interface RuntimeLog {
|
|
28
|
+
info(event: unknown): void;
|
|
29
|
+
warn(event: unknown): void;
|
|
30
|
+
error(event: unknown): void;
|
|
31
|
+
}
|
|
32
|
+
interface RuntimeMiddlewareContext {
|
|
33
|
+
readonly contract: unknown;
|
|
34
|
+
readonly mode: 'strict' | 'permissive';
|
|
35
|
+
readonly now: () => number;
|
|
36
|
+
readonly log: RuntimeLog;
|
|
37
|
+
}
|
|
38
|
+
interface AfterExecuteResult {
|
|
39
|
+
readonly rowCount: number;
|
|
40
|
+
readonly latencyMs: number;
|
|
41
|
+
readonly completed: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface RuntimeMiddleware {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly familyId?: string;
|
|
46
|
+
readonly targetId?: string;
|
|
47
|
+
beforeExecute?(plan: {
|
|
48
|
+
readonly meta: PlanMeta;
|
|
49
|
+
}, ctx: RuntimeMiddlewareContext): Promise<void>;
|
|
50
|
+
onRow?(row: Record<string, unknown>, plan: {
|
|
51
|
+
readonly meta: PlanMeta;
|
|
52
|
+
}, ctx: RuntimeMiddlewareContext): Promise<void>;
|
|
53
|
+
afterExecute?(plan: {
|
|
54
|
+
readonly meta: PlanMeta;
|
|
55
|
+
}, result: AfterExecuteResult, ctx: RuntimeMiddlewareContext): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Cross-family SPI for any runtime that can execute plans and be shut down.
|
|
59
|
+
* Each family runtime (SQL, Mongo) satisfies this interface — SQL nominally,
|
|
60
|
+
* Mongo structurally (due to its phantom Row parameter using a unique symbol).
|
|
61
|
+
*
|
|
62
|
+
* The `_row` intersection on `execute` connects the `Row` type parameter to the
|
|
63
|
+
* plan, mirroring how `ExecutionPlan<Row>` carries a phantom `_row?: Row`.
|
|
64
|
+
*/
|
|
65
|
+
interface RuntimeExecutor<TPlan extends {
|
|
66
|
+
readonly meta: PlanMeta;
|
|
67
|
+
}> {
|
|
68
|
+
execute<Row>(plan: TPlan & {
|
|
69
|
+
readonly _row?: Row;
|
|
70
|
+
}): AsyncIterableResult<Row>;
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
declare function checkMiddlewareCompatibility(middleware: RuntimeMiddleware, runtimeFamilyId: string, runtimeTargetId: string): void;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { type AfterExecuteResult, AsyncIterableResult, type RuntimeErrorEnvelope, type RuntimeExecutor, type RuntimeLog, type RuntimeMiddleware, type RuntimeMiddlewareContext, checkMiddlewareCompatibility, runtimeError };
|
|
76
|
+
//# sourceMappingURL=runtime.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.mts","names":[],"sources":["../src/async-iterable-result.ts","../src/runtime-error.ts","../src/runtime-middleware.ts"],"sourcesContent":[],"mappings":";;;cAEa,oCAAoC,cAAc,MAAM,YAAY;;;EAApE,QAAA,UAAA;EAAkD,QAAA,oBAAA;EAAkB,WAAA,CAAA,SAAA,EAMxD,cANwD,CAMzC,GANyC,EAAA,IAAA,EAAA,OAAA,CAAA;EAMzC,CAIrC,MAAA,CAAO,aAAA,GAJ8B,EAIZ,aAJY,CAIE,GAJF,CAAA;EAA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AAA,EAAA,MAAA,CAAA,EAAA,IAAA"}
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region src/runtime-error.ts
|
|
2
|
+
function runtimeError(code, message, details) {
|
|
3
|
+
const error = new Error(message);
|
|
4
|
+
Object.defineProperty(error, "name", {
|
|
5
|
+
value: "RuntimeError",
|
|
6
|
+
configurable: true
|
|
7
|
+
});
|
|
8
|
+
return Object.assign(error, {
|
|
9
|
+
code,
|
|
10
|
+
category: resolveCategory(code),
|
|
11
|
+
severity: "error",
|
|
12
|
+
message,
|
|
13
|
+
details
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function resolveCategory(code) {
|
|
17
|
+
const prefix = code.split(".")[0] ?? "RUNTIME";
|
|
18
|
+
switch (prefix) {
|
|
19
|
+
case "PLAN":
|
|
20
|
+
case "CONTRACT":
|
|
21
|
+
case "LINT":
|
|
22
|
+
case "BUDGET": return prefix;
|
|
23
|
+
default: return "RUNTIME";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/async-iterable-result.ts
|
|
29
|
+
var AsyncIterableResult = class {
|
|
30
|
+
generator;
|
|
31
|
+
consumed = false;
|
|
32
|
+
consumedBy;
|
|
33
|
+
bufferedArrayPromise;
|
|
34
|
+
constructor(generator) {
|
|
35
|
+
this.generator = generator;
|
|
36
|
+
}
|
|
37
|
+
[Symbol.asyncIterator]() {
|
|
38
|
+
if (this.consumed) throw runtimeError("RUNTIME.ITERATOR_CONSUMED", `AsyncIterableResult iterator has already been consumed via ${this.consumedBy === "bufferedArray" ? "toArray()/then()" : "for-await loop"}. Each AsyncIterableResult can only be iterated once.`, {
|
|
39
|
+
consumedBy: this.consumedBy,
|
|
40
|
+
suggestion: this.consumedBy === "bufferedArray" ? "If you need to iterate multiple times, store the results from toArray() in a variable and reuse that." : "If you need to iterate multiple times, use toArray() to collect all results first."
|
|
41
|
+
});
|
|
42
|
+
this.consumed = true;
|
|
43
|
+
this.consumedBy = "iterator";
|
|
44
|
+
return this.generator;
|
|
45
|
+
}
|
|
46
|
+
toArray() {
|
|
47
|
+
if (this.consumedBy === "iterator") return Promise.reject(runtimeError("RUNTIME.ITERATOR_CONSUMED", "AsyncIterableResult iterator has already been consumed via for-await loop. Each AsyncIterableResult can only be iterated once.", {
|
|
48
|
+
consumedBy: this.consumedBy,
|
|
49
|
+
suggestion: "The iterator was already consumed by a for-await loop. Use toArray() or await the result before iterating."
|
|
50
|
+
}));
|
|
51
|
+
if (this.bufferedArrayPromise) return this.bufferedArrayPromise;
|
|
52
|
+
this.consumed = true;
|
|
53
|
+
this.consumedBy = "bufferedArray";
|
|
54
|
+
this.bufferedArrayPromise = (async () => {
|
|
55
|
+
const out = [];
|
|
56
|
+
for await (const item of this.generator) out.push(item);
|
|
57
|
+
return out;
|
|
58
|
+
})();
|
|
59
|
+
return this.bufferedArrayPromise;
|
|
60
|
+
}
|
|
61
|
+
async first() {
|
|
62
|
+
return (await this.toArray())[0] ?? null;
|
|
63
|
+
}
|
|
64
|
+
async firstOrThrow() {
|
|
65
|
+
const row = await this.first();
|
|
66
|
+
if (row === null) throw runtimeError("RUNTIME.NO_ROWS", "Expected at least one row, but none were returned", {});
|
|
67
|
+
return row;
|
|
68
|
+
}
|
|
69
|
+
then(onfulfilled, onrejected) {
|
|
70
|
+
return this.toArray().then(onfulfilled, onrejected);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/runtime-middleware.ts
|
|
76
|
+
function checkMiddlewareCompatibility(middleware, runtimeFamilyId, runtimeTargetId) {
|
|
77
|
+
if (middleware.targetId !== void 0 && middleware.familyId === void 0) throw runtimeError("RUNTIME.MIDDLEWARE_INCOMPATIBLE", `Middleware '${middleware.name}' specifies targetId '${middleware.targetId}' without familyId`, {
|
|
78
|
+
middleware: middleware.name,
|
|
79
|
+
targetId: middleware.targetId
|
|
80
|
+
});
|
|
81
|
+
if (middleware.familyId !== void 0 && middleware.familyId !== runtimeFamilyId) throw runtimeError("RUNTIME.MIDDLEWARE_FAMILY_MISMATCH", `Middleware '${middleware.name}' requires family '${middleware.familyId}' but the runtime is configured for family '${runtimeFamilyId}'`, {
|
|
82
|
+
middleware: middleware.name,
|
|
83
|
+
middlewareFamilyId: middleware.familyId,
|
|
84
|
+
runtimeFamilyId
|
|
85
|
+
});
|
|
86
|
+
if (middleware.targetId !== void 0 && middleware.targetId !== runtimeTargetId) throw runtimeError("RUNTIME.MIDDLEWARE_TARGET_MISMATCH", `Middleware '${middleware.name}' requires target '${middleware.targetId}' but the runtime is configured for target '${runtimeTargetId}'`, {
|
|
87
|
+
middleware: middleware.name,
|
|
88
|
+
middlewareTargetId: middleware.targetId,
|
|
89
|
+
runtimeTargetId
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { AsyncIterableResult, checkMiddlewareCompatibility, runtimeError };
|
|
95
|
+
//# sourceMappingURL=runtime.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":["out: Row[]"],"sources":["../src/runtime-error.ts","../src/async-iterable-result.ts","../src/runtime-middleware.ts"],"sourcesContent":["export interface RuntimeErrorEnvelope extends Error {\n readonly code: string;\n readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME';\n readonly severity: 'error';\n readonly details?: Record<string, unknown>;\n}\n\nexport function runtimeError(\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): RuntimeErrorEnvelope {\n const error = new Error(message) as RuntimeErrorEnvelope;\n Object.defineProperty(error, 'name', {\n value: 'RuntimeError',\n configurable: true,\n });\n\n return Object.assign(error, {\n code,\n category: resolveCategory(code),\n severity: 'error' as const,\n message,\n details,\n });\n}\n\nfunction resolveCategory(code: string): RuntimeErrorEnvelope['category'] {\n const prefix = code.split('.')[0] ?? 'RUNTIME';\n switch (prefix) {\n case 'PLAN':\n case 'CONTRACT':\n case 'LINT':\n case 'BUDGET':\n return prefix;\n default:\n return 'RUNTIME';\n }\n}\n","import { runtimeError } from './runtime-error';\n\nexport class AsyncIterableResult<Row> implements AsyncIterable<Row>, PromiseLike<Row[]> {\n private readonly generator: AsyncGenerator<Row, void, unknown>;\n private consumed = false;\n private consumedBy: 'bufferedArray' | 'iterator' | undefined;\n private bufferedArrayPromise: Promise<Row[]> | undefined;\n\n constructor(generator: AsyncGenerator<Row, void, unknown>) {\n this.generator = generator;\n }\n\n [Symbol.asyncIterator](): AsyncIterator<Row> {\n if (this.consumed) {\n throw runtimeError(\n 'RUNTIME.ITERATOR_CONSUMED',\n `AsyncIterableResult iterator has already been consumed via ${this.consumedBy === 'bufferedArray' ? 'toArray()/then()' : 'for-await loop'}. Each AsyncIterableResult can only be iterated once.`,\n {\n consumedBy: this.consumedBy,\n suggestion:\n this.consumedBy === 'bufferedArray'\n ? 'If you need to iterate multiple times, store the results from toArray() in a variable and reuse that.'\n : 'If you need to iterate multiple times, use toArray() to collect all results first.',\n },\n );\n }\n this.consumed = true;\n this.consumedBy = 'iterator';\n return this.generator;\n }\n\n toArray(): Promise<Row[]> {\n if (this.consumedBy === 'iterator') {\n return Promise.reject(\n runtimeError(\n 'RUNTIME.ITERATOR_CONSUMED',\n 'AsyncIterableResult iterator has already been consumed via for-await loop. Each AsyncIterableResult can only be iterated once.',\n {\n consumedBy: this.consumedBy,\n suggestion:\n 'The iterator was already consumed by a for-await loop. Use toArray() or await the result before iterating.',\n },\n ),\n );\n }\n\n if (this.bufferedArrayPromise) {\n return this.bufferedArrayPromise;\n }\n\n this.consumed = true;\n this.consumedBy = 'bufferedArray';\n this.bufferedArrayPromise = (async () => {\n const out: Row[] = [];\n for await (const item of this.generator) {\n out.push(item);\n }\n return out;\n })();\n return this.bufferedArrayPromise;\n }\n\n async first(): Promise<Row | null> {\n const rows = await this.toArray();\n return rows[0] ?? null;\n }\n\n async firstOrThrow(): Promise<Row> {\n const row = await this.first();\n if (row === null)\n throw runtimeError(\n 'RUNTIME.NO_ROWS',\n 'Expected at least one row, but none were returned',\n {},\n );\n return row;\n }\n\n // biome-ignore lint/suspicious/noThenProperty: PromiseLike implementation is intentional for await support.\n then<TResult1 = Row[], TResult2 = never>(\n onfulfilled?: ((value: Row[]) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.toArray().then(onfulfilled, onrejected);\n }\n}\n","import type { PlanMeta } from '@prisma-next/contract/types';\nimport type { AsyncIterableResult } from './async-iterable-result';\nimport { runtimeError } from './runtime-error';\n\nexport interface RuntimeLog {\n info(event: unknown): void;\n warn(event: unknown): void;\n error(event: unknown): void;\n}\n\nexport interface RuntimeMiddlewareContext {\n readonly contract: unknown;\n readonly mode: 'strict' | 'permissive';\n readonly now: () => number;\n readonly log: RuntimeLog;\n}\n\nexport interface AfterExecuteResult {\n readonly rowCount: number;\n readonly latencyMs: number;\n readonly completed: boolean;\n}\n\nexport interface RuntimeMiddleware {\n readonly name: string;\n readonly familyId?: string;\n readonly targetId?: string;\n beforeExecute?(plan: { readonly meta: PlanMeta }, ctx: RuntimeMiddlewareContext): Promise<void>;\n onRow?(\n row: Record<string, unknown>,\n plan: { readonly meta: PlanMeta },\n ctx: RuntimeMiddlewareContext,\n ): Promise<void>;\n afterExecute?(\n plan: { readonly meta: PlanMeta },\n result: AfterExecuteResult,\n ctx: RuntimeMiddlewareContext,\n ): Promise<void>;\n}\n\n/**\n * Cross-family SPI for any runtime that can execute plans and be shut down.\n * Each family runtime (SQL, Mongo) satisfies this interface — SQL nominally,\n * Mongo structurally (due to its phantom Row parameter using a unique symbol).\n *\n * The `_row` intersection on `execute` connects the `Row` type parameter to the\n * plan, mirroring how `ExecutionPlan<Row>` carries a phantom `_row?: Row`.\n */\nexport interface RuntimeExecutor<TPlan extends { readonly meta: PlanMeta }> {\n execute<Row>(plan: TPlan & { readonly _row?: Row }): AsyncIterableResult<Row>;\n close(): Promise<void>;\n}\n\nexport function checkMiddlewareCompatibility(\n middleware: RuntimeMiddleware,\n runtimeFamilyId: string,\n runtimeTargetId: string,\n): void {\n if (middleware.targetId !== undefined && middleware.familyId === undefined) {\n throw runtimeError(\n 'RUNTIME.MIDDLEWARE_INCOMPATIBLE',\n `Middleware '${middleware.name}' specifies targetId '${middleware.targetId}' without familyId`,\n { middleware: middleware.name, targetId: middleware.targetId },\n );\n }\n\n if (middleware.familyId !== undefined && middleware.familyId !== runtimeFamilyId) {\n throw runtimeError(\n 'RUNTIME.MIDDLEWARE_FAMILY_MISMATCH',\n `Middleware '${middleware.name}' requires family '${middleware.familyId}' but the runtime is configured for family '${runtimeFamilyId}'`,\n { middleware: middleware.name, middlewareFamilyId: middleware.familyId, runtimeFamilyId },\n );\n }\n\n if (middleware.targetId !== undefined && middleware.targetId !== runtimeTargetId) {\n throw runtimeError(\n 'RUNTIME.MIDDLEWARE_TARGET_MISMATCH',\n `Middleware '${middleware.name}' requires target '${middleware.targetId}' but the runtime is configured for target '${runtimeTargetId}'`,\n { middleware: middleware.name, middlewareTargetId: middleware.targetId, runtimeTargetId },\n );\n }\n}\n"],"mappings":";AAOA,SAAgB,aACd,MACA,SACA,SACsB;CACtB,MAAM,QAAQ,IAAI,MAAM,QAAQ;AAChC,QAAO,eAAe,OAAO,QAAQ;EACnC,OAAO;EACP,cAAc;EACf,CAAC;AAEF,QAAO,OAAO,OAAO,OAAO;EAC1B;EACA,UAAU,gBAAgB,KAAK;EAC/B,UAAU;EACV;EACA;EACD,CAAC;;AAGJ,SAAS,gBAAgB,MAAgD;CACvE,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM;AACrC,SAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,SACH,QAAO;EACT,QACE,QAAO;;;;;;AClCb,IAAa,sBAAb,MAAwF;CACtF,AA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AW,SAAS,8CAA8C,gBAAgB,IACtI;EAAE,YAAY,WAAW;EAAM,oBAAoB,WAAW;EAAU;EAAiB,CAC1F;AAGH,KAAI,WAAW,aAAa,UAAa,WAAW,aAAa,gBAC/D,OAAM,aACJ,sCACA,eAAe,WAAW,KAAK,qBAAqB,WAAW,SAAS,8CAA8C,gBAAgB,IACtI;EAAE,YAAY,WAAW;EAAM,oBAAoB,WAAW;EAAU;EAAiB,CAC1F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-import-spec-Ddp4fNmt.d.mts","names":[],"sources":["../src/types-import-spec.ts"],"sourcesContent":[],"mappings":";;AAIA;;;UAAiB,eAAA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/framework-components",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.160",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Framework component types, assembly logic, and stack creation for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/contract": "0.3.0-dev.
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
8
|
+
"@prisma-next/contract": "0.3.0-dev.160",
|
|
9
|
+
"@prisma-next/utils": "0.3.0-dev.160",
|
|
10
|
+
"@prisma-next/operations": "0.3.0-dev.160"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"tsdown": "0.18.4",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./control": "./dist/control.mjs",
|
|
28
28
|
"./emission": "./dist/emission.mjs",
|
|
29
29
|
"./execution": "./dist/execution.mjs",
|
|
30
|
+
"./runtime": "./dist/runtime.mjs",
|
|
30
31
|
"./package.json": "./package.json"
|
|
31
32
|
},
|
|
32
33
|
"repository": {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { runtimeError } from './runtime-error';
|
|
2
|
+
|
|
3
|
+
export class AsyncIterableResult<Row> implements AsyncIterable<Row>, PromiseLike<Row[]> {
|
|
4
|
+
private readonly generator: AsyncGenerator<Row, void, unknown>;
|
|
5
|
+
private consumed = false;
|
|
6
|
+
private consumedBy: 'bufferedArray' | 'iterator' | undefined;
|
|
7
|
+
private bufferedArrayPromise: Promise<Row[]> | undefined;
|
|
8
|
+
|
|
9
|
+
constructor(generator: AsyncGenerator<Row, void, unknown>) {
|
|
10
|
+
this.generator = generator;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[Symbol.asyncIterator](): AsyncIterator<Row> {
|
|
14
|
+
if (this.consumed) {
|
|
15
|
+
throw runtimeError(
|
|
16
|
+
'RUNTIME.ITERATOR_CONSUMED',
|
|
17
|
+
`AsyncIterableResult iterator has already been consumed via ${this.consumedBy === 'bufferedArray' ? 'toArray()/then()' : 'for-await loop'}. Each AsyncIterableResult can only be iterated once.`,
|
|
18
|
+
{
|
|
19
|
+
consumedBy: this.consumedBy,
|
|
20
|
+
suggestion:
|
|
21
|
+
this.consumedBy === 'bufferedArray'
|
|
22
|
+
? 'If you need to iterate multiple times, store the results from toArray() in a variable and reuse that.'
|
|
23
|
+
: 'If you need to iterate multiple times, use toArray() to collect all results first.',
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
this.consumed = true;
|
|
28
|
+
this.consumedBy = 'iterator';
|
|
29
|
+
return this.generator;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
toArray(): Promise<Row[]> {
|
|
33
|
+
if (this.consumedBy === 'iterator') {
|
|
34
|
+
return Promise.reject(
|
|
35
|
+
runtimeError(
|
|
36
|
+
'RUNTIME.ITERATOR_CONSUMED',
|
|
37
|
+
'AsyncIterableResult iterator has already been consumed via for-await loop. Each AsyncIterableResult can only be iterated once.',
|
|
38
|
+
{
|
|
39
|
+
consumedBy: this.consumedBy,
|
|
40
|
+
suggestion:
|
|
41
|
+
'The iterator was already consumed by a for-await loop. Use toArray() or await the result before iterating.',
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (this.bufferedArrayPromise) {
|
|
48
|
+
return this.bufferedArrayPromise;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.consumed = true;
|
|
52
|
+
this.consumedBy = 'bufferedArray';
|
|
53
|
+
this.bufferedArrayPromise = (async () => {
|
|
54
|
+
const out: Row[] = [];
|
|
55
|
+
for await (const item of this.generator) {
|
|
56
|
+
out.push(item);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
})();
|
|
60
|
+
return this.bufferedArrayPromise;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async first(): Promise<Row | null> {
|
|
64
|
+
const rows = await this.toArray();
|
|
65
|
+
return rows[0] ?? null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async firstOrThrow(): Promise<Row> {
|
|
69
|
+
const row = await this.first();
|
|
70
|
+
if (row === null)
|
|
71
|
+
throw runtimeError(
|
|
72
|
+
'RUNTIME.NO_ROWS',
|
|
73
|
+
'Expected at least one row, but none were returned',
|
|
74
|
+
{},
|
|
75
|
+
);
|
|
76
|
+
return row;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// biome-ignore lint/suspicious/noThenProperty: PromiseLike implementation is intentional for await support.
|
|
80
|
+
then<TResult1 = Row[], TResult2 = never>(
|
|
81
|
+
onfulfilled?: ((value: Row[]) => TResult1 | PromiseLike<TResult1>) | undefined | null,
|
|
82
|
+
onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,
|
|
83
|
+
): PromiseLike<TResult1 | TResult2> {
|
|
84
|
+
return this.toArray().then(onfulfilled, onrejected);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { AsyncIterableResult } from '../async-iterable-result';
|
|
2
|
+
export type { RuntimeErrorEnvelope } from '../runtime-error';
|
|
3
|
+
export { runtimeError } from '../runtime-error';
|
|
4
|
+
export type {
|
|
5
|
+
AfterExecuteResult,
|
|
6
|
+
RuntimeExecutor,
|
|
7
|
+
RuntimeLog,
|
|
8
|
+
RuntimeMiddleware,
|
|
9
|
+
RuntimeMiddlewareContext,
|
|
10
|
+
} from '../runtime-middleware';
|
|
11
|
+
export { checkMiddlewareCompatibility } from '../runtime-middleware';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface RuntimeErrorEnvelope extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME';
|
|
4
|
+
readonly severity: 'error';
|
|
5
|
+
readonly details?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function runtimeError(
|
|
9
|
+
code: string,
|
|
10
|
+
message: string,
|
|
11
|
+
details?: Record<string, unknown>,
|
|
12
|
+
): RuntimeErrorEnvelope {
|
|
13
|
+
const error = new Error(message) as RuntimeErrorEnvelope;
|
|
14
|
+
Object.defineProperty(error, 'name', {
|
|
15
|
+
value: 'RuntimeError',
|
|
16
|
+
configurable: true,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return Object.assign(error, {
|
|
20
|
+
code,
|
|
21
|
+
category: resolveCategory(code),
|
|
22
|
+
severity: 'error' as const,
|
|
23
|
+
message,
|
|
24
|
+
details,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolveCategory(code: string): RuntimeErrorEnvelope['category'] {
|
|
29
|
+
const prefix = code.split('.')[0] ?? 'RUNTIME';
|
|
30
|
+
switch (prefix) {
|
|
31
|
+
case 'PLAN':
|
|
32
|
+
case 'CONTRACT':
|
|
33
|
+
case 'LINT':
|
|
34
|
+
case 'BUDGET':
|
|
35
|
+
return prefix;
|
|
36
|
+
default:
|
|
37
|
+
return 'RUNTIME';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { PlanMeta } from '@prisma-next/contract/types';
|
|
2
|
+
import type { AsyncIterableResult } from './async-iterable-result';
|
|
3
|
+
import { runtimeError } from './runtime-error';
|
|
4
|
+
|
|
5
|
+
export interface RuntimeLog {
|
|
6
|
+
info(event: unknown): void;
|
|
7
|
+
warn(event: unknown): void;
|
|
8
|
+
error(event: unknown): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RuntimeMiddlewareContext {
|
|
12
|
+
readonly contract: unknown;
|
|
13
|
+
readonly mode: 'strict' | 'permissive';
|
|
14
|
+
readonly now: () => number;
|
|
15
|
+
readonly log: RuntimeLog;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AfterExecuteResult {
|
|
19
|
+
readonly rowCount: number;
|
|
20
|
+
readonly latencyMs: number;
|
|
21
|
+
readonly completed: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RuntimeMiddleware {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly familyId?: string;
|
|
27
|
+
readonly targetId?: string;
|
|
28
|
+
beforeExecute?(plan: { readonly meta: PlanMeta }, ctx: RuntimeMiddlewareContext): Promise<void>;
|
|
29
|
+
onRow?(
|
|
30
|
+
row: Record<string, unknown>,
|
|
31
|
+
plan: { readonly meta: PlanMeta },
|
|
32
|
+
ctx: RuntimeMiddlewareContext,
|
|
33
|
+
): Promise<void>;
|
|
34
|
+
afterExecute?(
|
|
35
|
+
plan: { readonly meta: PlanMeta },
|
|
36
|
+
result: AfterExecuteResult,
|
|
37
|
+
ctx: RuntimeMiddlewareContext,
|
|
38
|
+
): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Cross-family SPI for any runtime that can execute plans and be shut down.
|
|
43
|
+
* Each family runtime (SQL, Mongo) satisfies this interface — SQL nominally,
|
|
44
|
+
* Mongo structurally (due to its phantom Row parameter using a unique symbol).
|
|
45
|
+
*
|
|
46
|
+
* The `_row` intersection on `execute` connects the `Row` type parameter to the
|
|
47
|
+
* plan, mirroring how `ExecutionPlan<Row>` carries a phantom `_row?: Row`.
|
|
48
|
+
*/
|
|
49
|
+
export interface RuntimeExecutor<TPlan extends { readonly meta: PlanMeta }> {
|
|
50
|
+
execute<Row>(plan: TPlan & { readonly _row?: Row }): AsyncIterableResult<Row>;
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function checkMiddlewareCompatibility(
|
|
55
|
+
middleware: RuntimeMiddleware,
|
|
56
|
+
runtimeFamilyId: string,
|
|
57
|
+
runtimeTargetId: string,
|
|
58
|
+
): void {
|
|
59
|
+
if (middleware.targetId !== undefined && middleware.familyId === undefined) {
|
|
60
|
+
throw runtimeError(
|
|
61
|
+
'RUNTIME.MIDDLEWARE_INCOMPATIBLE',
|
|
62
|
+
`Middleware '${middleware.name}' specifies targetId '${middleware.targetId}' without familyId`,
|
|
63
|
+
{ middleware: middleware.name, targetId: middleware.targetId },
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (middleware.familyId !== undefined && middleware.familyId !== runtimeFamilyId) {
|
|
68
|
+
throw runtimeError(
|
|
69
|
+
'RUNTIME.MIDDLEWARE_FAMILY_MISMATCH',
|
|
70
|
+
`Middleware '${middleware.name}' requires family '${middleware.familyId}' but the runtime is configured for family '${runtimeFamilyId}'`,
|
|
71
|
+
{ middleware: middleware.name, middlewareFamilyId: middleware.familyId, runtimeFamilyId },
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (middleware.targetId !== undefined && middleware.targetId !== runtimeTargetId) {
|
|
76
|
+
throw runtimeError(
|
|
77
|
+
'RUNTIME.MIDDLEWARE_TARGET_MISMATCH',
|
|
78
|
+
`Middleware '${middleware.name}' requires target '${middleware.targetId}' but the runtime is configured for target '${runtimeTargetId}'`,
|
|
79
|
+
{ middleware: middleware.name, middlewareTargetId: middleware.targetId, runtimeTargetId },
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-import-spec-BupmVNbx.d.mts","names":[],"sources":["../src/types-import-spec.ts"],"sourcesContent":[],"mappings":";;AAIA;;;UAAiB,eAAA"}
|