@aventara/prisma7-adapter 1.0.0-rc.0 → 1.0.0-rc.2

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +552 -0
  2. package/README.md +407 -329
  3. package/dist/discovery/artifact.loader.d.ts +10 -6
  4. package/dist/discovery/artifact.loader.js +20 -20
  5. package/dist/discovery/capability-surface.interface.d.ts +1 -1
  6. package/dist/discovery/capability.deriver.d.ts +9 -6
  7. package/dist/discovery/capability.deriver.js +41 -6
  8. package/dist/discovery/client-shape.verifier.d.ts +1 -1
  9. package/dist/discovery/client-shape.verifier.js +2 -2
  10. package/dist/discovery/discovery-artifact.interface.d.ts +38 -47
  11. package/dist/discovery/discovery-artifact.interface.js +1 -1
  12. package/dist/discovery/enum.mapper.d.ts +2 -2
  13. package/dist/discovery/field.mapper.d.ts +13 -13
  14. package/dist/discovery/field.mapper.js +10 -10
  15. package/dist/discovery/identifier.mapper.d.ts +7 -7
  16. package/dist/discovery/installed-client.locator.d.ts +13 -0
  17. package/dist/discovery/installed-client.locator.js +43 -0
  18. package/dist/discovery/model.discoverer.d.ts +7 -4
  19. package/dist/discovery/model.discoverer.js +61 -19
  20. package/dist/discovery/operations.deriver.d.ts +6 -6
  21. package/dist/discovery/schema-facts.interface.d.ts +3 -3
  22. package/dist/discovery/schema.reader.d.ts +2 -2
  23. package/dist/discovery/schema.reader.js +5 -5
  24. package/dist/discovery/types.reader.d.ts +2 -2
  25. package/dist/discovery/types.reader.js +22 -22
  26. package/dist/discovery/vocabulary.dictionary.d.ts +14 -14
  27. package/dist/discovery/vocabulary.dictionary.js +1 -1
  28. package/dist/errors/back-reference.locator.d.ts +25 -0
  29. package/dist/errors/back-reference.locator.js +100 -0
  30. package/dist/errors/bigint-binding.locator.d.ts +7 -0
  31. package/dist/errors/bigint-binding.locator.js +27 -0
  32. package/dist/errors/error.normalizer.d.ts +44 -6
  33. package/dist/errors/error.normalizer.js +96 -7
  34. package/dist/errors/prisma-error.reader.d.ts +6 -0
  35. package/dist/errors/prisma-error.reader.js +3 -0
  36. package/dist/execution/first-variant.emulator.d.ts +4 -4
  37. package/dist/execution/first-variant.emulator.js +13 -9
  38. package/dist/execution/operation.executor.d.ts +15 -9
  39. package/dist/execution/operation.executor.js +34 -17
  40. package/dist/execution/result.shaper.d.ts +3 -3
  41. package/dist/execution/result.shaper.js +7 -7
  42. package/dist/execution/sql-statement.executor.d.ts +9 -0
  43. package/dist/execution/sql-statement.executor.js +58 -0
  44. package/dist/execution/transaction.executor.d.ts +12 -8
  45. package/dist/execution/transaction.executor.js +11 -5
  46. package/dist/generate/artifact.emitter.d.ts +11 -7
  47. package/dist/generate/artifact.emitter.js +60 -18
  48. package/dist/generate/computed-fields.reader.d.ts +19 -0
  49. package/dist/generate/computed-fields.reader.js +210 -0
  50. package/dist/generate/declared-support.reader.d.ts +1 -1
  51. package/dist/generate/discovery.cli.d.ts +4 -3
  52. package/dist/generate/discovery.cli.js +31 -15
  53. package/dist/generate/existence.gate.d.ts +4 -4
  54. package/dist/generate/existence.gate.js +4 -4
  55. package/dist/generate/index.d.ts +13 -5
  56. package/dist/generate/index.js +5 -2
  57. package/dist/generate/prisma.generate.d.ts +24 -8
  58. package/dist/generate/prisma.generate.js +52 -15
  59. package/dist/index.d.ts +4 -4
  60. package/dist/prisma-client.interface.d.ts +22 -8
  61. package/dist/prisma-client.interface.js +7 -0
  62. package/dist/prisma.adapter.d.ts +16 -16
  63. package/dist/prisma.adapter.js +48 -5
  64. package/dist/provider/provider-profile.d.ts +29 -13
  65. package/dist/provider/provider-profile.js +21 -0
  66. package/dist/translation/json-null.sentinel.d.ts +7 -0
  67. package/dist/translation/json-null.sentinel.js +17 -0
  68. package/dist/translation/mutation.translator.d.ts +8 -8
  69. package/dist/translation/mutation.translator.js +37 -30
  70. package/dist/translation/operation.translator.d.ts +7 -7
  71. package/dist/translation/operation.translator.js +12 -12
  72. package/dist/translation/order-pagination.translator.d.ts +5 -5
  73. package/dist/translation/order-pagination.translator.js +16 -16
  74. package/dist/translation/projection.translator.d.ts +4 -4
  75. package/dist/translation/projection.translator.js +11 -11
  76. package/dist/translation/scalar.conversion.d.ts +9 -9
  77. package/dist/translation/scalar.conversion.js +11 -11
  78. package/dist/translation/where.translator.d.ts +5 -5
  79. package/dist/translation/where.translator.js +114 -31
  80. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
- import { type PrismaAdapterModel } from "./discovery-artifact.interface.js";
1
+ import { type AvPrismaAdapterModel } from "./discovery-artifact.interface.js";
2
2
  /** Every artifact failure is this class, and every one of them says how to fix it. */
3
- export declare class PrismaDiscoveryArtifactError extends Error {
3
+ export declare class AvPrismaDiscoveryArtifactError extends Error {
4
4
  /**
5
5
  * `instruction` replaces the general regeneration sentence where the reason
6
6
  * reads as the first half of one sentence with it.
@@ -9,8 +9,12 @@ export declare class PrismaDiscoveryArtifactError extends Error {
9
9
  }
10
10
  export type PrismaDiscoveryArtifactLoad = {
11
11
  readonly artifact: unknown;
12
- /** The `version` of the `@prisma/client` actually installed beside the caller. */
13
- readonly installedPrismaVersion: string;
12
+ /**
13
+ * The `version` of the `@prisma/client` actually installed beside the caller;
14
+ * `undefined` when it could not be read, and the majors are then not compared
15
+ * (the adapter says so at startup).
16
+ */
17
+ readonly installedPrismaVersion: string | undefined;
14
18
  };
15
19
  /**
16
20
  * The identity of a discovered model: one canonicalization, one digest — over
@@ -20,6 +24,6 @@ export type PrismaDiscoveryArtifactLoad = {
20
24
  * entrypoint, and hashing it would put a foreign-key action into the Contract
21
25
  * identity and into every generated client.
22
26
  */
23
- export declare function computeModelHash(model: PrismaAdapterModel): Promise<string>;
27
+ export declare function computeModelHash(model: AvPrismaAdapterModel): Promise<string>;
24
28
  /** Validates an artifact and hands back its model **unchanged**. */
25
- export declare function loadDiscoveryArtifact(load: PrismaDiscoveryArtifactLoad): Promise<PrismaAdapterModel>;
29
+ export declare function loadDiscoveryArtifact(load: PrismaDiscoveryArtifactLoad): Promise<AvPrismaAdapterModel>;
@@ -5,10 +5,10 @@ const REGENERATION_INSTRUCTION = "Regenerate the discovery artifact — `npm run
5
5
  "set up by `aventara`, or the adapter's generate step " +
6
6
  "(`aventara-prisma7-generate`) — and redeploy it " +
7
7
  "alongside the schema and client it was generated from.";
8
- export class PrismaDiscoveryArtifactError extends Error {
8
+ export class AvPrismaDiscoveryArtifactError extends Error {
9
9
  constructor(reason, instruction = REGENERATION_INSTRUCTION) {
10
10
  super(`${reason} ${instruction}`);
11
- this.name = "PrismaDiscoveryArtifactError";
11
+ this.name = "AvPrismaDiscoveryArtifactError";
12
12
  }
13
13
  }
14
14
  function hex(digest) {
@@ -31,56 +31,56 @@ function majorOf(version) {
31
31
  }
32
32
  function assertArtifactShape(artifact) {
33
33
  if (!isRecord(artifact)) {
34
- throw new PrismaDiscoveryArtifactError("The discovery artifact is not a JSON object.");
34
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact is not a JSON object.");
35
35
  }
36
36
  if (artifact.regenerate_with_aventara_prepare !== DISCOVERY_ARTIFACT_FORMAT) {
37
- throw new PrismaDiscoveryArtifactError("The discovery artifact was written by another version of @aventara/prisma7-adapter.");
37
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact was written by another version of @aventara/prisma7-adapter.");
38
38
  }
39
39
  for (const key of ["prismaVersion", "provider", "modelHash"]) {
40
40
  if (typeof artifact[key] !== "string") {
41
- throw new PrismaDiscoveryArtifactError(`The discovery artifact's \`${key}\` is not a string.`);
41
+ throw new AvPrismaDiscoveryArtifactError(`The discovery artifact's \`${key}\` is not a string.`);
42
42
  }
43
43
  }
44
44
  if (!isRecord(artifact.model)) {
45
- throw new PrismaDiscoveryArtifactError("The discovery artifact's `model` is not a JSON object.");
45
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `model` is not a JSON object.");
46
46
  }
47
- for (const key of [
48
- "translation",
49
- "referentialActions",
50
- "client",
51
- "createRequirements",
52
- ]) {
47
+ for (const key of ["translation", "referentialActions", "client"]) {
53
48
  if (!isRecord(artifact[key])) {
54
- throw new PrismaDiscoveryArtifactError(`The discovery artifact's \`${key}\` is not a JSON object.`);
49
+ throw new AvPrismaDiscoveryArtifactError(`The discovery artifact's \`${key}\` is not a JSON object.`);
55
50
  }
56
51
  }
52
+ if (artifact.computedFields !== null && !isRecord(artifact.computedFields)) {
53
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `computedFields` is neither a JSON object nor null.");
54
+ }
57
55
  for (const key of ["scalars", "enums", "resources"]) {
58
56
  if (!isRecord(artifact.model[key])) {
59
- throw new PrismaDiscoveryArtifactError(`The discovery artifact's \`model.${key}\` is not a JSON object.`);
57
+ throw new AvPrismaDiscoveryArtifactError(`The discovery artifact's \`model.${key}\` is not a JSON object.`);
60
58
  }
61
59
  }
62
60
  if (artifact.model.transactions !== "none" &&
63
61
  artifact.model.transactions !== "interactive") {
64
- throw new PrismaDiscoveryArtifactError("The discovery artifact's `model.transactions` is not a transaction capability.");
62
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `model.transactions` is not a transaction capability.");
65
63
  }
66
64
  if (artifact.model.referenceWrites !== "uniform") {
67
- throw new PrismaDiscoveryArtifactError("The discovery artifact's `model.referenceWrites` is not `uniform`, which every Prisma model is.");
65
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `model.referenceWrites` is not `uniform`, which every Prisma model is.");
68
66
  }
69
67
  }
70
68
  export async function loadDiscoveryArtifact(load) {
71
69
  const { artifact, installedPrismaVersion } = load;
72
70
  assertArtifactShape(artifact);
73
71
  const artifactMajor = majorOf(artifact.prismaVersion);
74
- const installedMajor = majorOf(installedPrismaVersion);
72
+ const installedMajor = installedPrismaVersion === undefined
73
+ ? artifactMajor
74
+ : majorOf(installedPrismaVersion);
75
75
  if (artifactMajor === undefined || installedMajor === undefined) {
76
- throw new PrismaDiscoveryArtifactError(`A Prisma version is not a major.minor.patch version: the artifact declares \`${artifact.prismaVersion}\` and the installed client reports \`${installedPrismaVersion}\`.`);
76
+ throw new AvPrismaDiscoveryArtifactError(`A Prisma version is not a major.minor.patch version: the artifact declares \`${artifact.prismaVersion}\` and the installed client reports \`${installedPrismaVersion}\`.`);
77
77
  }
78
78
  if (artifactMajor !== installedMajor) {
79
- throw new PrismaDiscoveryArtifactError(`The discovery artifact was generated against Prisma major ${artifactMajor}, and the installed client is major ${installedMajor}. The P-code surface and the generated-client grammar are version-bound.`);
79
+ throw new AvPrismaDiscoveryArtifactError(`The discovery artifact was generated against Prisma major ${artifactMajor}, and the installed client is major ${installedMajor}. The P-code surface and the generated-client grammar are version-bound.`);
80
80
  }
81
81
  const modelHash = await computeModelHash(artifact.model);
82
82
  if (modelHash !== artifact.modelHash) {
83
- throw new PrismaDiscoveryArtifactError("The discovery artifact's `modelHash` does not match its own `model`, so the artifact is corrupt or was edited by hand.");
83
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `modelHash` does not match its own `model`, so the artifact is corrupt or was edited by hand.");
84
84
  }
85
85
  return artifact.model;
86
86
  }
@@ -101,7 +101,7 @@ export type PrismaRelationSurface = {
101
101
  * presence question, asked of the reducer key rather than of the edge.
102
102
  *
103
103
  * A model-level fact carried on each edge because the capability it qualifies
104
- * is the edge's: `RelationFieldCapabilities.reducers` says which reducers *this
104
+ * is the edge's: `AvRelationFieldCapabilities.reducers` says which reducers *this
105
105
  * relation* admits, and `_count` is the one projection key all of them are
106
106
  * asked for through.
107
107
  */
@@ -1,17 +1,20 @@
1
- import type { RelationFieldCapabilities, ScalarFieldCapabilities, ScalarFilterOperator } from "@aventara/core";
1
+ import type { AvRelationFieldCapabilities, AvScalarFieldCapabilities, AvScalarFilterOperator } from "@aventara/core";
2
+ import type { PrismaFilterModeFacts } from "../provider/provider-profile.js";
2
3
  import type { PrismaRelationSurface, PrismaScalarSurface } from "./capability-surface.interface.js";
3
4
  /** A Prisma spelling that no dictionary table recognises: a build stop, never a drop. */
4
- export declare class PrismaCapabilityDerivationError extends Error {
5
- readonly name = "PrismaCapabilityDerivationError";
5
+ export declare class AvPrismaCapabilityDerivationError extends Error {
6
+ readonly name = "AvPrismaCapabilityDerivationError";
6
7
  }
7
8
  export type ScalarCapabilityInput = {
8
9
  readonly surface: PrismaScalarSurface;
10
+ /** The `mode`s the engine honours (see this module's header). */
11
+ readonly filterModes: PrismaFilterModeFacts;
9
12
  };
10
13
  /** A relation's capabilities are answered for the field, not for an operation. */
11
14
  export type RelationCapabilityInput = {
12
15
  readonly surface: PrismaRelationSurface;
13
16
  };
14
- export declare function deriveScalarCapabilities(input: ScalarCapabilityInput): ScalarFieldCapabilities;
17
+ export declare function deriveScalarCapabilities(input: ScalarCapabilityInput): AvScalarFieldCapabilities;
15
18
  /** The Prisma operand for each ADVERTISED operator, keyed by the Aventara name. */
16
- export declare function deriveScalarFilterOperands(input: ScalarCapabilityInput): Readonly<Partial<Record<ScalarFilterOperator, string>>>;
17
- export declare function deriveRelationCapabilities(input: RelationCapabilityInput): RelationFieldCapabilities;
19
+ export declare function deriveScalarFilterOperands(input: Pick<ScalarCapabilityInput, "surface">): Readonly<Partial<Record<AvScalarFilterOperator, string>>>;
20
+ export declare function deriveRelationCapabilities(input: RelationCapabilityInput): AvRelationFieldCapabilities;
@@ -1,6 +1,6 @@
1
1
  import { PRISMA_EDGE_ARGUMENTS, PRISMA_FILTER_OPERATORS, PRISMA_REDUCERS, PRISMA_RELATION_DIRECTIVES, PRISMA_RELATION_FILTERS, PRISMA_SCALAR_DIRECTIVES, } from "./vocabulary.dictionary.js";
2
- export class PrismaCapabilityDerivationError extends Error {
3
- name = "PrismaCapabilityDerivationError";
2
+ export class AvPrismaCapabilityDerivationError extends Error {
3
+ name = "AvPrismaCapabilityDerivationError";
4
4
  }
5
5
  const FILTER_OPERATOR_ORDER = [
6
6
  "equals",
@@ -61,18 +61,50 @@ const PAGINATION_ORDER = [
61
61
  export function deriveScalarCapabilities(input) {
62
62
  const { surface } = input;
63
63
  const operands = deriveScalarFilterOperands(input);
64
- const filter = canonical(FILTER_OPERATOR_ORDER, surface.filters
64
+ const derived = surface.filters
65
65
  .map((key) => look(PRISMA_FILTER_OPERATORS, key, "a scalar filter operator"))
66
- .filter((operator) => translatable(operator, operands)));
66
+ .filter((operator) => translatable(operator, operands));
67
+ const modes = filterModes(derived, input.filterModes);
68
+ const filter = canonical(FILTER_OPERATOR_ORDER, [
69
+ ...derived,
70
+ ...(modes === undefined ? [] : ["mode"]),
71
+ ]);
67
72
  return {
68
73
  select: true,
69
74
  ...(filter.length > 0 ? { filter } : {}),
75
+ ...(modes ?? {}),
70
76
  order: surface.orderable,
71
77
  ...(surface.nullsOrderable ? { orderNulls: true } : {}),
72
78
  ...directives("create", surface.createOperations),
73
79
  ...directives("update", surface.updateOperations),
74
80
  };
75
81
  }
82
+ const TEXT_OPERATORS = [
83
+ "contains",
84
+ "startsWith",
85
+ "endsWith",
86
+ ];
87
+ const JSON_TEXT_OPERATORS = [
88
+ "stringContains",
89
+ "stringStartsWith",
90
+ "stringEndsWith",
91
+ ];
92
+ function filterModes(operators, facts) {
93
+ const admitted = (modes) => modes.filter((mode) => mode !== "insensitive" || operators.includes("mode"));
94
+ if (operators.some((operator) => JSON_TEXT_OPERATORS.includes(operator))) {
95
+ return {
96
+ filterModes: admitted(facts.jsonDocument),
97
+ ...(operators.includes("path")
98
+ ? { pathFilterModes: admitted(facts.jsonPath) }
99
+ : {}),
100
+ };
101
+ }
102
+ if (operators.includes("mode") ||
103
+ operators.some((operator) => TEXT_OPERATORS.includes(operator))) {
104
+ return { filterModes: admitted(facts.text) };
105
+ }
106
+ return undefined;
107
+ }
76
108
  export function deriveScalarFilterOperands(input) {
77
109
  const operands = {};
78
110
  for (const operator of FILTER_OPERATOR_ORDER) {
@@ -126,7 +158,10 @@ function reducersIn(reducers, bulk) {
126
158
  return bulk ? reducers : { reducers, scopes: ["record"] };
127
159
  }
128
160
  function writableIn(directives, bulk) {
129
- return bulk ? directives : { directives, scopes: ["nested"] };
161
+ return {
162
+ directives,
163
+ scopes: bulk ? ["nested", "bulkWrite"] : ["nested"],
164
+ };
130
165
  }
131
166
  export function deriveRelationCapabilities(input) {
132
167
  const { surface } = input;
@@ -164,7 +199,7 @@ export function deriveRelationCapabilities(input) {
164
199
  }
165
200
  function look(table, key, what) {
166
201
  if (!(key in table)) {
167
- throw new PrismaCapabilityDerivationError(`the generated types offer "${key}" as ${what} and the dictionary has no row for it`);
202
+ throw new AvPrismaCapabilityDerivationError(`the generated types offer "${key}" as ${what} and the dictionary has no row for it`);
168
203
  }
169
204
  return table[key];
170
205
  }
@@ -8,6 +8,6 @@ export declare function describeClientDrift(recorded: PrismaClientShape, client:
8
8
  * Throws when the client in hand is not the one the artifact was generated
9
9
  * against — one sentence, naming what differs and `aventara:prepare`.
10
10
  *
11
- * @throws PrismaDiscoveryArtifactError
11
+ * @throws AvPrismaDiscoveryArtifactError
12
12
  */
13
13
  export declare function assertClientMatchesArtifact(recorded: PrismaClientShape, client: unknown): void;
@@ -1,5 +1,5 @@
1
1
  import { delegateKeyOf } from "../execution/operation.executor.js";
2
- import { PrismaDiscoveryArtifactError } from "./artifact.loader.js";
2
+ import { AvPrismaDiscoveryArtifactError } from "./artifact.loader.js";
3
3
  const SHOWN = 3;
4
4
  function readMember(value, key) {
5
5
  if ((typeof value !== "object" && typeof value !== "function") ||
@@ -89,5 +89,5 @@ export function assertClientMatchesArtifact(recorded, client) {
89
89
  }
90
90
  const shown = drift.slice(0, SHOWN).join("; ");
91
91
  const more = drift.length > SHOWN ? `; and ${drift.length - SHOWN} more` : "";
92
- throw new PrismaDiscoveryArtifactError(`The Prisma client has changed since the discovery artifact was generated (${shown}${more}):`, "run `npm run aventara:prepare` (the adapter's `aventara-prisma7-generate`) to regenerate it, then restart.");
92
+ throw new AvPrismaDiscoveryArtifactError(`The Prisma client has changed since the discovery artifact was generated (${shown}${more}):`, "run `npm run aventara:prepare` (the adapter's `aventara-prisma7-generate`) to regenerate it, then restart.");
93
93
  }
@@ -1,25 +1,25 @@
1
- import type { Adapter, AdapterModel, EnumDefinition, ScalarRegistry, TransactionCapability } from "@aventara/core";
2
- import type { AdapterResource } from "@aventara/core/internal";
3
- import type { PrismaProvider } from "../provider/provider-profile.js";
1
+ import type { AvAdapterModel, AvConfigComputedFields, AvEnumDefinition, AvScalarRegistry, AvTransactionCapability } from "@aventara/core";
2
+ import type { AvAdapterResource } from "@aventara/core/internal";
3
+ import type { AvPrismaProvider } from "../provider/provider-profile.js";
4
4
  /** The adapter model a discovery artifact carries, in Aventara's vocabulary. */
5
- export type PrismaAdapterModel = {
5
+ export type AvPrismaAdapterModel = {
6
6
  /** The scalar types the schema uses. */
7
- readonly scalars: ScalarRegistry;
7
+ readonly scalars: AvScalarRegistry;
8
8
  /** The schema's enums, by name. */
9
- readonly enums: Readonly<Record<string, EnumDefinition>>;
9
+ readonly enums: Readonly<Record<string, AvEnumDefinition>>;
10
10
  /** The schema's models, as Resources. */
11
- readonly resources: Readonly<Record<string, AdapterResource<PrismaAdapterModel>>>;
11
+ readonly resources: Readonly<Record<string, AvAdapterResource<AvPrismaAdapterModel>>>;
12
12
  /** Whether the driver supports interactive transactions. */
13
- readonly transactions: TransactionCapability;
13
+ readonly transactions: AvTransactionCapability;
14
14
  /**
15
15
  * Prisma takes one record's references one way at a time (its checked and
16
16
  * unchecked write inputs), so every artifact states `"uniform"`.
17
17
  */
18
- readonly referenceWrites: NonNullable<AdapterModel["referenceWrites"]>;
18
+ readonly referenceWrites: NonNullable<AvAdapterModel["referenceWrites"]>;
19
19
  };
20
20
  /** One identifier, and the **Prisma addressing key** that reaches it. */
21
21
  export type PrismaIdentifierAddress = {
22
- readonly members: AdapterResource<PrismaAdapterModel>["identifiers"][number];
22
+ readonly members: AvAdapterResource<AvPrismaAdapterModel>["identifiers"][number];
23
23
  readonly key: string;
24
24
  };
25
25
  /** One Resource's Prisma addressing, in the order the identifiers were discovered. */
@@ -27,44 +27,44 @@ export type PrismaResourceTranslation = {
27
27
  readonly identifierKeys: readonly PrismaIdentifierAddress[];
28
28
  };
29
29
  /** The **translation table**: Prisma addressing for every discovered Resource. */
30
- export type PrismaTranslationTable<M extends PrismaAdapterModel = PrismaAdapterModel> = {
30
+ export type PrismaTranslationTable<M extends AvPrismaAdapterModel = AvPrismaAdapterModel> = {
31
31
  readonly [R in keyof M["resources"]]: PrismaResourceTranslation;
32
32
  };
33
33
  /** A referential action, as `onDelete`/`onUpdate` name it in the schema. */
34
- export type PrismaReferentialAction = "cascade" | "restrict" | "no-action" | "set-null" | "set-default";
35
- /** One **owning** relation edge's resolved referential actions. */
36
- export type PrismaReferentialEdge = {
34
+ export type AvPrismaReferentialAction = "cascade" | "restrict" | "no-action" | "set-null" | "set-default";
35
+ /** One owning relation edge's resolved referential actions. */
36
+ export type AvPrismaReferentialEdge = {
37
37
  /** The edge's field name on the enclosing (child) resource. */
38
38
  readonly field: string;
39
- /** The resource the edge points AT — the parent, whose deletion fires `onDelete`. */
39
+ /** The resource the edge points at: the parent, whose deletion fires `onDelete`. */
40
40
  readonly target: string;
41
41
  /** Whether the edge holds one related row or many. */
42
42
  readonly cardinality: "one" | "many";
43
43
  /**
44
- * The scalar fields of the ENCLOSING resource that hold the reference — the
44
+ * The scalar fields of the enclosing resource that hold the reference: the
45
45
  * relation's `@relation(fields: […])`, in schema order.
46
46
  */
47
47
  readonly references: readonly string[];
48
- /** What deleting a `target` row does to rows of the ENCLOSING resource. */
49
- readonly onDelete: PrismaReferentialAction;
48
+ /** What deleting a `target` row does to rows of the enclosing resource. */
49
+ readonly onDelete: AvPrismaReferentialAction;
50
50
  /** The same for an update of the referenced key. Read independently of `onDelete`. */
51
- readonly onUpdate: PrismaReferentialAction;
51
+ readonly onUpdate: AvPrismaReferentialAction;
52
52
  };
53
53
  /**
54
54
  * One Resource's owning edges, in schema field order: the relation fields that
55
55
  * declare `@relation(fields: …)`. An empty list means deleting rows elsewhere
56
56
  * leaves this Resource's rows alone.
57
57
  */
58
- export type PrismaResourceReferentialActions = {
58
+ export type AvPrismaResourceReferentialActions = {
59
59
  /** The Resource's owning edges, in schema order. */
60
- readonly owningEdges: readonly PrismaReferentialEdge[];
60
+ readonly owningEdges: readonly AvPrismaReferentialEdge[];
61
61
  };
62
62
  /**
63
- * The **referential-action table**: every discovered Resource's owning edges,
63
+ * The referential-action table: every discovered Resource's owning edges,
64
64
  * resolved.
65
65
  */
66
- export type PrismaReferentialActionTable<M extends PrismaAdapterModel = PrismaAdapterModel> = {
67
- readonly [R in keyof M["resources"]]: PrismaResourceReferentialActions;
66
+ export type AvPrismaReferentialActionTable<M extends AvPrismaAdapterModel = AvPrismaAdapterModel> = {
67
+ readonly [R in keyof M["resources"]]: AvPrismaResourceReferentialActions;
68
68
  };
69
69
  /**
70
70
  * What the generated Prisma client exposed when the artifact was generated: each
@@ -72,29 +72,14 @@ export type PrismaReferentialActionTable<M extends PrismaAdapterModel = PrismaAd
72
72
  * references (`prisma.<model>.fields`) in code-unit order.
73
73
  */
74
74
  export type PrismaClientShape = Readonly<Record<string, readonly string[]>>;
75
- /**
76
- * What a create of each Resource cannot do without, already in core's words
77
- * (`Adapter["createRequirements"]`): a column the client must write, or a
78
- * required relation — which may instead be written through the scalar fields
79
- * that hold its reference, read off the relation's referential edge
80
- * (`references`), never restated here — and the relation's other end, through
81
- * which a nested create supplies it.
82
- *
83
- * Read at generate time from the generated client's create inputs — the
84
- * question marks on `<M>UncheckedCreateInput` and `<M>CreateInput` — and from the
85
- * schema's `@relation(fields: …)` pairing. Beside the model and outside
86
- * `modelHash`: a requirement is a fact about the store, not about the semantic
87
- * model, and the Contract carries no foreign-key detail.
88
- */
89
- export type PrismaCreateRequirementTable = NonNullable<Adapter["createRequirements"]>;
90
75
  /** The current discovery artifact format. */
91
- export declare const DISCOVERY_ARTIFACT_FORMAT = 2;
76
+ export declare const DISCOVERY_ARTIFACT_FORMAT = 4;
92
77
  /**
93
78
  * The discovery artifact: the module `aventara-prisma7-generate` writes from
94
79
  * your schema and generated client. Import its `discovery` export and pass it
95
80
  * to `createPrismaAdapter({ discovery })`.
96
81
  */
97
- export type PrismaDiscoveryArtifact<M extends PrismaAdapterModel = PrismaAdapterModel> = {
82
+ export type AvPrismaDiscoveryArtifact<M extends AvPrismaAdapterModel = AvPrismaAdapterModel> = {
98
83
  /**
99
84
  * The artifact's format. A TypeScript error naming this property means the
100
85
  * artifact was written by another version of `@aventara/prisma7-adapter`:
@@ -104,8 +89,8 @@ export type PrismaDiscoveryArtifact<M extends PrismaAdapterModel = PrismaAdapter
104
89
  /** The Prisma version the artifact was generated with, such as `"7.10.0"`. */
105
90
  readonly prismaVersion: string;
106
91
  /** The database provider: `"sqlite"` or `"postgresql"`. */
107
- readonly provider: PrismaProvider;
108
- /** `sha256:<hex>` of the canonicalized `model` below — and of nothing else. */
92
+ readonly provider: AvPrismaProvider;
93
+ /** `sha256:<hex>` of the canonicalized `model` below, and of nothing else. */
109
94
  readonly modelHash: string;
110
95
  /** What the schema and the generated client agreed on. */
111
96
  readonly model: M;
@@ -113,14 +98,20 @@ export type PrismaDiscoveryArtifact<M extends PrismaAdapterModel = PrismaAdapter
113
98
  readonly translation: PrismaTranslationTable<M>;
114
99
  /**
115
100
  * The schema's referential actions; not part of `modelHash`. An entry under
116
- * resource `R` says **deleting a `target` row does `onDelete` to rows of `R`**.
101
+ * resource `R` says that deleting a `target` row does `onDelete` to rows of `R`.
117
102
  */
118
- readonly referentialActions: PrismaReferentialActionTable<M>;
103
+ readonly referentialActions: AvPrismaReferentialActionTable<M>;
119
104
  /**
120
105
  * The models and field references of the client the artifact was generated
121
106
  * against; not part of `modelHash`.
122
107
  */
123
108
  readonly client: PrismaClientShape;
124
- /** What a create of each Resource cannot do without; not part of `modelHash`. */
125
- readonly createRequirements: PrismaCreateRequirementTable;
109
+ /**
110
+ * Which fields the configuration's write compute fills, per layer, as the
111
+ * generate step read them off the configuration it was given (`--config`);
112
+ * `null` when it was given none. The model's type carries the same statement
113
+ * for the pipeline stages' types; this value is compared with the
114
+ * configuration when the framework starts. Not part of `modelHash`.
115
+ */
116
+ readonly computedFields: AvConfigComputedFields | null;
126
117
  };
@@ -1 +1 @@
1
- export const DISCOVERY_ARTIFACT_FORMAT = 2;
1
+ export const DISCOVERY_ARTIFACT_FORMAT = 4;
@@ -1,4 +1,4 @@
1
- import type { EnumDefinition } from "@aventara/core";
1
+ import type { AvEnumDefinition } from "@aventara/core";
2
2
  import type { PrismaSchemaEnum } from "./schema-facts.interface.js";
3
3
  import type { PrismaDiscoveryDiagnostic } from "./vocabulary.dictionary.js";
4
4
  export type EnumMappingInput = {
@@ -9,7 +9,7 @@ export type EnumMappingInput = {
9
9
  export type EnumMappingOutcome = {
10
10
  readonly outcome: "enum";
11
11
  readonly name: string;
12
- readonly definition: EnumDefinition;
12
+ readonly definition: AvEnumDefinition;
13
13
  } | {
14
14
  readonly outcome: "excluded";
15
15
  readonly diagnostic: PrismaDiscoveryDiagnostic;
@@ -1,14 +1,14 @@
1
- import { type AdapterLifecycleTrait, type AdapterRelationField, type AdapterScalarField } from "@aventara/core/internal";
1
+ import { type AvAdapterLifecycleTrait, type AvAdapterRelationField, type AvAdapterScalarField } from "@aventara/core/internal";
2
2
  import type { PrismaResourceSurface } from "./capability-surface.interface.js";
3
- import type { PrismaAdapterModel, PrismaReferentialAction } from "./discovery-artifact.interface.js";
3
+ import type { AvPrismaAdapterModel, AvPrismaReferentialAction } from "./discovery-artifact.interface.js";
4
4
  import type { PrismaSchemaField, PrismaSchemaUnknown } from "./schema-facts.interface.js";
5
5
  import { type PrismaDiscoveryDiagnostic, type PrismaEvidence } from "./vocabulary.dictionary.js";
6
6
  /** A reader-versus-reader disagreement: not a schema problem, and not recoverable. */
7
- export declare class PrismaFieldProjectionError extends Error {
8
- readonly name = "PrismaFieldProjectionError";
7
+ export declare class AvPrismaFieldProjectionError extends Error {
8
+ readonly name = "AvPrismaFieldProjectionError";
9
9
  }
10
- export type ProjectedScalarField = Omit<AdapterScalarField<PrismaAdapterModel>, "capabilities">;
11
- export type ProjectedRelationField = Omit<AdapterRelationField<PrismaAdapterModel>, "capabilities">;
10
+ export type ProjectedScalarField = Omit<AvAdapterScalarField<AvPrismaAdapterModel>, "capabilities">;
11
+ export type ProjectedRelationField = Omit<AvAdapterRelationField<AvPrismaAdapterModel>, "capabilities">;
12
12
  /**
13
13
  * One relation edge as PSL states it — the pairing evidence and the referential
14
14
  * actions, neither of which the projected field carries.
@@ -22,9 +22,9 @@ export type PrismaRelationEdge = {
22
22
  readonly cardinality: "one" | "many";
23
23
  /** `@relation("Name")`, or `null` where PSL wrote none. PSL-only. */
24
24
  readonly relationName: string | null;
25
- readonly onDelete: PrismaReferentialAction | null;
25
+ readonly onDelete: AvPrismaReferentialAction | null;
26
26
  /** The same for an update of the referenced key. `null` on a non-owning edge. */
27
- readonly onUpdate: PrismaReferentialAction | null;
27
+ readonly onUpdate: AvPrismaReferentialAction | null;
28
28
  };
29
29
  export type FieldProjectionInput = {
30
30
  readonly resource: string;
@@ -61,22 +61,22 @@ export type PrismaDefaultOutcome =
61
61
  /** A row of `PRISMA_DEFAULT_TABLE` matched, and its evidence travels with it. */
62
62
  {
63
63
  readonly form: "table";
64
- readonly traits: readonly AdapterLifecycleTrait[];
64
+ readonly traits: readonly AvAdapterLifecycleTrait[];
65
65
  readonly evidence: PrismaEvidence;
66
66
  }
67
67
  /** A static value — a literal, a number, a boolean, an enum member, a list. */
68
68
  | {
69
69
  readonly form: "static";
70
- readonly traits: readonly AdapterLifecycleTrait[];
70
+ readonly traits: readonly AvAdapterLifecycleTrait[];
71
71
  }
72
72
  /** A generator form the table does not carry: `DEFAULTED`, plus a recorded unknown. */
73
73
  | {
74
74
  readonly form: "unrecognised-generator";
75
- readonly traits: readonly AdapterLifecycleTrait[];
75
+ readonly traits: readonly AvAdapterLifecycleTrait[];
76
76
  };
77
77
  export declare function matchPrismaDefault(argument: string): PrismaDefaultOutcome;
78
78
  /** Why a field is legitimately optional in `<M>UncheckedCreateInput`. */
79
- export type CreateOptionalCause = AdapterLifecycleTrait | "nullable"
79
+ export type CreateOptionalCause = AvAdapterLifecycleTrait | "nullable"
80
80
  /** A scalar list needs no value: the empty list is one. */
81
81
  | "list";
82
82
  export type CreateOptionalCrossCheckInput = {
@@ -90,7 +90,7 @@ export type CreateOptionalCrossCheckInput = {
90
90
  readonly name: string;
91
91
  readonly nullable: boolean;
92
92
  readonly list: boolean;
93
- readonly lifecycle: readonly AdapterLifecycleTrait[];
93
+ readonly lifecycle: readonly AvAdapterLifecycleTrait[];
94
94
  }[];
95
95
  /** TYPE — `<M>UncheckedCreateInput`'s optional members. */
96
96
  readonly createOptional: readonly string[];
@@ -2,8 +2,8 @@ import { LIFECYCLE_TRAITS, } from "@aventara/core/internal";
2
2
  import { projectEnumBackedColumn } from "./enum.mapper.js";
3
3
  import { mapPrismaScalarField } from "./scalar.mapper.js";
4
4
  import { PRISMA_DEFAULT_TABLE, PRISMA_UNMATCHED_DEFAULT_TRAITS, } from "./vocabulary.dictionary.js";
5
- export class PrismaFieldProjectionError extends Error {
6
- name = "PrismaFieldProjectionError";
5
+ export class AvPrismaFieldProjectionError extends Error {
6
+ name = "AvPrismaFieldProjectionError";
7
7
  }
8
8
  export function projectPrismaField(input) {
9
9
  return input.models.has(input.field.type)
@@ -18,7 +18,7 @@ function projectScalarField(input) {
18
18
  }
19
19
  const exposed = surface.scalarFields[field.name];
20
20
  if (exposed === undefined) {
21
- throw new PrismaFieldProjectionError(`${resource}.${field.name} passed the existence gate and has no scalar surface`);
21
+ throw new AvPrismaFieldProjectionError(`${resource}.${field.name} passed the existence gate and has no scalar surface`);
22
22
  }
23
23
  assertTokenAgrees(resource, field, exposed.token);
24
24
  const lifecycle = projectLifecycle(resource, field);
@@ -44,10 +44,10 @@ function assertTokenAgrees(resource, field, token) {
44
44
  const listed = token.endsWith("[]");
45
45
  const base = listed ? token.slice(0, -2) : token;
46
46
  if (base !== field.type) {
47
- throw new PrismaFieldProjectionError(`${resource}.${field.name} is written \`${field.type}\` in schema.prisma and the generated client's types carry the FieldRef token \`${token}\`. The two readers describe one instant, so this is a stale generated client or a reader defect, not a schema the adapter can translate.`);
47
+ throw new AvPrismaFieldProjectionError(`${resource}.${field.name} is written \`${field.type}\` in schema.prisma and the generated client's types carry the FieldRef token \`${token}\`. The two readers describe one instant, so this is a stale generated client or a reader defect, not a schema the adapter can translate.`);
48
48
  }
49
49
  if (listed !== field.list) {
50
- throw new PrismaFieldProjectionError(`${resource}.${field.name} is ${field.list ? "a list" : "not a list"} in schema.prisma and the generated client's types carry the FieldRef token \`${token}\`, which says the opposite.`);
50
+ throw new AvPrismaFieldProjectionError(`${resource}.${field.name} is ${field.list ? "a list" : "not a list"} in schema.prisma and the generated client's types carry the FieldRef token \`${token}\`, which says the opposite.`);
51
51
  }
52
52
  }
53
53
  const ADAPTER_TRAIT_ORDER = LIFECYCLE_TRAITS.filter((trait) => trait === "DEFAULTED" ||
@@ -145,13 +145,13 @@ function projectRelationField(input) {
145
145
  const cardinality = field.list ? "many" : "one";
146
146
  const nullable = cardinality === "many" ? false : field.optional;
147
147
  if (exposed.many !== field.list) {
148
- throw new PrismaFieldProjectionError(`${column} is ${field.list ? "a list" : "a single edge"} in schema.prisma and the generated client's payload type says the opposite.`);
148
+ throw new AvPrismaFieldProjectionError(`${column} is ${field.list ? "a list" : "a single edge"} in schema.prisma and the generated client's payload type says the opposite.`);
149
149
  }
150
150
  if (exposed.nullable !== nullable) {
151
- throw new PrismaFieldProjectionError(`${column} is ${nullable ? "optional" : "required"} in schema.prisma and the generated client's payload type ${exposed.nullable ? "admits" : "refuses"} \`null\`.`);
151
+ throw new AvPrismaFieldProjectionError(`${column} is ${nullable ? "optional" : "required"} in schema.prisma and the generated client's payload type ${exposed.nullable ? "admits" : "refuses"} \`null\`.`);
152
152
  }
153
153
  if (exposed.target !== field.type) {
154
- throw new PrismaFieldProjectionError(`${column} targets \`${field.type}\` in schema.prisma and \`${exposed.target}\` in the generated client's payload type.`);
154
+ throw new AvPrismaFieldProjectionError(`${column} targets \`${field.type}\` in schema.prisma and \`${exposed.target}\` in the generated client's payload type.`);
155
155
  }
156
156
  assertForeignKeyAgrees(column, field, siblings, nullable);
157
157
  return {
@@ -178,10 +178,10 @@ function assertForeignKeyAgrees(column, field, siblings, nullable) {
178
178
  for (const name of field.relation?.fields ?? []) {
179
179
  const scalar = siblings.find((sibling) => sibling.name === name);
180
180
  if (scalar === undefined) {
181
- throw new PrismaFieldProjectionError(`${column} names \`${name}\` in \`@relation(fields: …)\` and the model declares no such column.`);
181
+ throw new AvPrismaFieldProjectionError(`${column} names \`${name}\` in \`@relation(fields: …)\` and the model declares no such column.`);
182
182
  }
183
183
  if (scalar.optional && !nullable) {
184
- throw new PrismaFieldProjectionError(`${column} is required and its foreign key \`${name}\` is optional. PSL forbids this combination, so the schema cannot have said it: one of the readers is wrong.`);
184
+ throw new AvPrismaFieldProjectionError(`${column} is required and its foreign key \`${name}\` is optional. PSL forbids this combination, so the schema cannot have said it: one of the readers is wrong.`);
185
185
  }
186
186
  }
187
187
  }
@@ -22,12 +22,12 @@ export type PrismaIdentifierOmission = PrismaUniquenessCriterion & ({
22
22
  * from the model, a relation field, a list, or `@ignore`d out of the
23
23
  * generated client. Valid PSL cannot produce the first three; `@ignore`
24
24
  * can, and keeping it would emit an identifier over a key no
25
- * `AdapterFieldMap` carries.
25
+ * `AvAdapterFieldMap` carries.
26
26
  */
27
27
  readonly reason: "unresolved-participant";
28
28
  readonly unresolvedMembers: readonly string[];
29
29
  } | {
30
- /** An empty member list: `AdapterIdentifier` is non-empty by type. */
30
+ /** An empty member list: `AvAdapterIdentifier` is non-empty by type. */
31
31
  readonly reason: "no-participants";
32
32
  });
33
33
  /**
@@ -36,18 +36,18 @@ export type PrismaIdentifierOmission = PrismaUniquenessCriterion & ({
36
36
  * rest are not usable.
37
37
  *
38
38
  * One list, two projections, which is the reason the pair is not split here:
39
- * the composer takes `.members` for `AdapterResource.identifiers` (model
39
+ * the composer takes `.members` for `AvAdapterResource.identifiers` (model
40
40
  * content, hashed, Contract-bound) and the whole address for the artifact's
41
41
  * translation table (adapter-private, unhashed). Two parallel lists would have
42
42
  * to be kept in step; these cannot drift because they are one.
43
43
  *
44
- * `PrismaIdentifierAddress.members` is derived from `AdapterResource`, so a
44
+ * `PrismaIdentifierAddress.members` is derived from `AvAdapterResource`, so a
45
45
  * change in core's identifier type reaches this mapper as a compile error.
46
46
  * Discovery is where the field map is being **built**, so the abstract form is
47
- * what applies — `AdapterScalarFieldKey` widens to `string` through
48
- * `AdapterFieldMap<M>`, making an identifier here a non-empty tuple of field
47
+ * what applies — `AvAdapterScalarFieldKey` widens to `string` through
48
+ * `AvAdapterFieldMap<M>`, making an identifier here a non-empty tuple of field
49
49
  * names. The concrete keys are pinned later, in the emitted artifact
50
- * (`PrismaDiscoveryArtifact<M>`).
50
+ * (`AvPrismaDiscoveryArtifact<M>`).
51
51
  */
52
52
  export type PrismaIdentifierMapping = {
53
53
  readonly identifiers: readonly PrismaIdentifierAddress[];