@aventara/prisma7-adapter 0.1.0-pilot.4 → 1.0.0-rc.1

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 (68) hide show
  1. package/CHANGELOG.md +597 -0
  2. package/README.md +363 -317
  3. package/dist/discovery/artifact.loader.d.ts +4 -4
  4. package/dist/discovery/artifact.loader.js +17 -19
  5. package/dist/discovery/capability-surface.interface.d.ts +8 -1
  6. package/dist/discovery/capability.deriver.d.ts +6 -6
  7. package/dist/discovery/capability.deriver.js +6 -3
  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 -43
  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 +11 -11
  15. package/dist/discovery/identifier.mapper.d.ts +7 -7
  16. package/dist/discovery/model.discoverer.d.ts +4 -4
  17. package/dist/discovery/model.discoverer.js +51 -20
  18. package/dist/discovery/operations.deriver.d.ts +6 -5
  19. package/dist/discovery/schema-facts.interface.d.ts +3 -3
  20. package/dist/discovery/schema.reader.d.ts +2 -2
  21. package/dist/discovery/schema.reader.js +5 -5
  22. package/dist/discovery/types.reader.d.ts +2 -2
  23. package/dist/discovery/types.reader.js +33 -22
  24. package/dist/discovery/vocabulary.dictionary.d.ts +14 -13
  25. package/dist/discovery/vocabulary.dictionary.js +1 -1
  26. package/dist/errors/error.normalizer.d.ts +11 -5
  27. package/dist/errors/error.normalizer.js +27 -5
  28. package/dist/errors/prisma-error.reader.d.ts +2 -0
  29. package/dist/errors/prisma-error.reader.js +1 -0
  30. package/dist/execution/first-variant.emulator.d.ts +4 -4
  31. package/dist/execution/first-variant.emulator.js +13 -9
  32. package/dist/execution/operation.executor.d.ts +9 -8
  33. package/dist/execution/operation.executor.js +17 -13
  34. package/dist/execution/result.shaper.d.ts +3 -3
  35. package/dist/execution/result.shaper.js +7 -7
  36. package/dist/execution/sql-statement.executor.d.ts +9 -0
  37. package/dist/execution/sql-statement.executor.js +58 -0
  38. package/dist/execution/transaction.executor.d.ts +8 -7
  39. package/dist/execution/transaction.executor.js +9 -5
  40. package/dist/generate/artifact.emitter.d.ts +5 -7
  41. package/dist/generate/artifact.emitter.js +11 -22
  42. package/dist/generate/discovery.cli.d.ts +3 -3
  43. package/dist/generate/discovery.cli.js +11 -11
  44. package/dist/generate/existence.gate.d.ts +4 -4
  45. package/dist/generate/existence.gate.js +4 -4
  46. package/dist/generate/index.d.ts +5 -5
  47. package/dist/generate/index.js +2 -2
  48. package/dist/generate/prisma.generate.d.ts +7 -8
  49. package/dist/generate/prisma.generate.js +11 -12
  50. package/dist/index.d.ts +4 -4
  51. package/dist/prisma-client.interface.d.ts +22 -8
  52. package/dist/prisma-client.interface.js +7 -0
  53. package/dist/prisma.adapter.d.ts +12 -12
  54. package/dist/prisma.adapter.js +12 -3
  55. package/dist/provider/provider-profile.d.ts +11 -11
  56. package/dist/translation/mutation.translator.d.ts +8 -8
  57. package/dist/translation/mutation.translator.js +31 -31
  58. package/dist/translation/operation.translator.d.ts +7 -6
  59. package/dist/translation/operation.translator.js +12 -12
  60. package/dist/translation/order-pagination.translator.d.ts +5 -5
  61. package/dist/translation/order-pagination.translator.js +16 -16
  62. package/dist/translation/projection.translator.d.ts +4 -4
  63. package/dist/translation/projection.translator.js +11 -11
  64. package/dist/translation/scalar.conversion.d.ts +9 -8
  65. package/dist/translation/scalar.conversion.js +11 -11
  66. package/dist/translation/where.translator.d.ts +5 -5
  67. package/dist/translation/where.translator.js +15 -15
  68. package/package.json +5 -4
@@ -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.
@@ -20,6 +20,6 @@ export type PrismaDiscoveryArtifactLoad = {
20
20
  * entrypoint, and hashing it would put a foreign-key action into the Contract
21
21
  * identity and into every generated client.
22
22
  */
23
- export declare function computeModelHash(model: PrismaAdapterModel): Promise<string>;
23
+ export declare function computeModelHash(model: AvPrismaAdapterModel): Promise<string>;
24
24
  /** Validates an artifact and hands back its model **unchanged**. */
25
- export declare function loadDiscoveryArtifact(load: PrismaDiscoveryArtifactLoad): Promise<PrismaAdapterModel>;
25
+ export declare function loadDiscoveryArtifact(load: PrismaDiscoveryArtifactLoad): Promise<AvPrismaAdapterModel>;
@@ -1,14 +1,14 @@
1
- import { canonicalizeJson } from "@aventara/core";
1
+ import { canonicalizeJson } from "@aventara/core/internal";
2
2
  import { DISCOVERY_ARTIFACT_FORMAT, } from "./discovery-artifact.interface.js";
3
3
  const HASH_PREFIX = "sha256:";
4
4
  const REGENERATION_INSTRUCTION = "Regenerate the discovery artifact — `npm run aventara:prepare` in a project " +
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,37 +31,35 @@ 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
  }
57
52
  for (const key of ["scalars", "enums", "resources"]) {
58
53
  if (!isRecord(artifact.model[key])) {
59
- throw new PrismaDiscoveryArtifactError(`The discovery artifact's \`model.${key}\` is not a JSON object.`);
54
+ throw new AvPrismaDiscoveryArtifactError(`The discovery artifact's \`model.${key}\` is not a JSON object.`);
60
55
  }
61
56
  }
62
57
  if (artifact.model.transactions !== "none" &&
63
58
  artifact.model.transactions !== "interactive") {
64
- throw new PrismaDiscoveryArtifactError("The discovery artifact's `model.transactions` is not a transaction capability.");
59
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `model.transactions` is not a transaction capability.");
60
+ }
61
+ if (artifact.model.referenceWrites !== "uniform") {
62
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `model.referenceWrites` is not `uniform`, which every Prisma model is.");
65
63
  }
66
64
  }
67
65
  export async function loadDiscoveryArtifact(load) {
@@ -70,14 +68,14 @@ export async function loadDiscoveryArtifact(load) {
70
68
  const artifactMajor = majorOf(artifact.prismaVersion);
71
69
  const installedMajor = majorOf(installedPrismaVersion);
72
70
  if (artifactMajor === undefined || installedMajor === undefined) {
73
- throw new PrismaDiscoveryArtifactError(`A Prisma version is not a major.minor.patch version: the artifact declares \`${artifact.prismaVersion}\` and the installed client reports \`${installedPrismaVersion}\`.`);
71
+ throw new AvPrismaDiscoveryArtifactError(`A Prisma version is not a major.minor.patch version: the artifact declares \`${artifact.prismaVersion}\` and the installed client reports \`${installedPrismaVersion}\`.`);
74
72
  }
75
73
  if (artifactMajor !== installedMajor) {
76
- 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.`);
74
+ 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.`);
77
75
  }
78
76
  const modelHash = await computeModelHash(artifact.model);
79
77
  if (modelHash !== artifact.modelHash) {
80
- throw new PrismaDiscoveryArtifactError("The discovery artifact's `modelHash` does not match its own `model`, so the artifact is corrupt or was edited by hand.");
78
+ throw new AvPrismaDiscoveryArtifactError("The discovery artifact's `modelHash` does not match its own `model`, so the artifact is corrupt or was edited by hand.");
81
79
  }
82
80
  return artifact.model;
83
81
  }
@@ -76,6 +76,13 @@ export type PrismaRelationSurface = {
76
76
  */
77
77
  readonly createRequired: boolean;
78
78
  readonly updateMutations: readonly string[];
79
+ /**
80
+ * Whether the update stage's `deleteMany` takes a `<T>ScalarWhereInput` — a filter of
81
+ * the target's scalar fields only, which `updateMany`'s `where` shares. Read off the
82
+ * nested input's own member type; `false` where the input has no `deleteMany` (a
83
+ * to-one edge, whose `update`/`delete` take a full `<T>WhereInput`).
84
+ */
85
+ readonly scalarNestedWriteFilter: boolean;
79
86
  readonly edgeArguments: readonly string[];
80
87
  readonly pagination: readonly string[];
81
88
  /** The edge is admitted by `<M>OrderByWithRelationInput`. */
@@ -94,7 +101,7 @@ export type PrismaRelationSurface = {
94
101
  * presence question, asked of the reducer key rather than of the edge.
95
102
  *
96
103
  * A model-level fact carried on each edge because the capability it qualifies
97
- * is the edge's: `RelationFieldCapabilities.reducers` says which reducers *this
104
+ * is the edge's: `AvRelationFieldCapabilities.reducers` says which reducers *this
98
105
  * relation* admits, and `_count` is the one projection key all of them are
99
106
  * asked for through.
100
107
  */
@@ -1,8 +1,8 @@
1
- import type { RelationFieldCapabilities, ScalarFieldCapabilities, ScalarFilterOperator } from "@aventara/core";
1
+ import type { AvRelationFieldCapabilities, AvScalarFieldCapabilities, AvScalarFilterOperator } from "@aventara/core";
2
2
  import type { PrismaRelationSurface, PrismaScalarSurface } from "./capability-surface.interface.js";
3
3
  /** 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";
4
+ export declare class AvPrismaCapabilityDerivationError extends Error {
5
+ readonly name = "AvPrismaCapabilityDerivationError";
6
6
  }
7
7
  export type ScalarCapabilityInput = {
8
8
  readonly surface: PrismaScalarSurface;
@@ -11,7 +11,7 @@ export type ScalarCapabilityInput = {
11
11
  export type RelationCapabilityInput = {
12
12
  readonly surface: PrismaRelationSurface;
13
13
  };
14
- export declare function deriveScalarCapabilities(input: ScalarCapabilityInput): ScalarFieldCapabilities;
14
+ export declare function deriveScalarCapabilities(input: ScalarCapabilityInput): AvScalarFieldCapabilities;
15
15
  /** 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;
16
+ export declare function deriveScalarFilterOperands(input: ScalarCapabilityInput): Readonly<Partial<Record<AvScalarFilterOperator, string>>>;
17
+ 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",
@@ -157,11 +157,14 @@ export function deriveRelationCapabilities(input) {
157
157
  : {}),
158
158
  create: writableIn(directives(surface.createMutations), surface.bulkCreatable),
159
159
  update: writableIn(directives(surface.updateMutations), surface.bulkUpdatable),
160
+ ...(surface.scalarNestedWriteFilter
161
+ ? { nestedWriteFilter: "scalar" }
162
+ : {}),
160
163
  };
161
164
  }
162
165
  function look(table, key, what) {
163
166
  if (!(key in table)) {
164
- throw new PrismaCapabilityDerivationError(`the generated types offer "${key}" as ${what} and the dictionary has no row for it`);
167
+ throw new AvPrismaCapabilityDerivationError(`the generated types offer "${key}" as ${what} and the dictionary has no row for it`);
165
168
  }
166
169
  return table[key];
167
170
  }
@@ -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,19 +1,25 @@
1
- import type { Adapter, AdapterResource, EnumDefinition, ScalarRegistry, TransactionCapability } from "@aventara/core";
2
- import type { PrismaProvider } from "../provider/provider-profile.js";
1
+ import type { AvAdapterModel, AvEnumDefinition, AvScalarRegistry, AvTransactionCapability } from "@aventara/core";
2
+ import type { AvAdapterResource } from "@aventara/core/internal";
3
+ import type { AvPrismaProvider } from "../provider/provider-profile.js";
3
4
  /** The adapter model a discovery artifact carries, in Aventara's vocabulary. */
4
- export type PrismaAdapterModel = {
5
+ export type AvPrismaAdapterModel = {
5
6
  /** The scalar types the schema uses. */
6
- readonly scalars: ScalarRegistry;
7
+ readonly scalars: AvScalarRegistry;
7
8
  /** The schema's enums, by name. */
8
- readonly enums: Readonly<Record<string, EnumDefinition>>;
9
+ readonly enums: Readonly<Record<string, AvEnumDefinition>>;
9
10
  /** The schema's models, as Resources. */
10
- readonly resources: Readonly<Record<string, AdapterResource<PrismaAdapterModel>>>;
11
+ readonly resources: Readonly<Record<string, AvAdapterResource<AvPrismaAdapterModel>>>;
11
12
  /** Whether the driver supports interactive transactions. */
12
- readonly transactions: TransactionCapability;
13
+ readonly transactions: AvTransactionCapability;
14
+ /**
15
+ * Prisma takes one record's references one way at a time (its checked and
16
+ * unchecked write inputs), so every artifact states `"uniform"`.
17
+ */
18
+ readonly referenceWrites: NonNullable<AvAdapterModel["referenceWrites"]>;
13
19
  };
14
20
  /** One identifier, and the **Prisma addressing key** that reaches it. */
15
21
  export type PrismaIdentifierAddress = {
16
- readonly members: AdapterResource<PrismaAdapterModel>["identifiers"][number];
22
+ readonly members: AvAdapterResource<AvPrismaAdapterModel>["identifiers"][number];
17
23
  readonly key: string;
18
24
  };
19
25
  /** One Resource's Prisma addressing, in the order the identifiers were discovered. */
@@ -21,39 +27,44 @@ export type PrismaResourceTranslation = {
21
27
  readonly identifierKeys: readonly PrismaIdentifierAddress[];
22
28
  };
23
29
  /** The **translation table**: Prisma addressing for every discovered Resource. */
24
- export type PrismaTranslationTable<M extends PrismaAdapterModel = PrismaAdapterModel> = {
30
+ export type PrismaTranslationTable<M extends AvPrismaAdapterModel = AvPrismaAdapterModel> = {
25
31
  readonly [R in keyof M["resources"]]: PrismaResourceTranslation;
26
32
  };
27
33
  /** A referential action, as `onDelete`/`onUpdate` name it in the schema. */
28
- export type PrismaReferentialAction = "cascade" | "restrict" | "no-action" | "set-null" | "set-default";
29
- /** One **owning** relation edge's resolved referential actions. */
30
- 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 = {
31
37
  /** The edge's field name on the enclosing (child) resource. */
32
38
  readonly field: string;
33
- /** 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`. */
34
40
  readonly target: string;
35
41
  /** Whether the edge holds one related row or many. */
36
42
  readonly cardinality: "one" | "many";
37
- /** What deleting a `target` row does to rows of the ENCLOSING resource. */
38
- readonly onDelete: PrismaReferentialAction;
43
+ /**
44
+ * The scalar fields of the enclosing resource that hold the reference: the
45
+ * relation's `@relation(fields: […])`, in schema order.
46
+ */
47
+ readonly references: readonly string[];
48
+ /** What deleting a `target` row does to rows of the enclosing resource. */
49
+ readonly onDelete: AvPrismaReferentialAction;
39
50
  /** The same for an update of the referenced key. Read independently of `onDelete`. */
40
- readonly onUpdate: PrismaReferentialAction;
51
+ readonly onUpdate: AvPrismaReferentialAction;
41
52
  };
42
53
  /**
43
54
  * One Resource's owning edges, in schema field order: the relation fields that
44
55
  * declare `@relation(fields: …)`. An empty list means deleting rows elsewhere
45
56
  * leaves this Resource's rows alone.
46
57
  */
47
- export type PrismaResourceReferentialActions = {
58
+ export type AvPrismaResourceReferentialActions = {
48
59
  /** The Resource's owning edges, in schema order. */
49
- readonly owningEdges: readonly PrismaReferentialEdge[];
60
+ readonly owningEdges: readonly AvPrismaReferentialEdge[];
50
61
  };
51
62
  /**
52
- * The **referential-action table**: every discovered Resource's owning edges,
63
+ * The referential-action table: every discovered Resource's owning edges,
53
64
  * resolved.
54
65
  */
55
- export type PrismaReferentialActionTable<M extends PrismaAdapterModel = PrismaAdapterModel> = {
56
- readonly [R in keyof M["resources"]]: PrismaResourceReferentialActions;
66
+ export type AvPrismaReferentialActionTable<M extends AvPrismaAdapterModel = AvPrismaAdapterModel> = {
67
+ readonly [R in keyof M["resources"]]: AvPrismaResourceReferentialActions;
57
68
  };
58
69
  /**
59
70
  * What the generated Prisma client exposed when the artifact was generated: each
@@ -61,28 +72,14 @@ export type PrismaReferentialActionTable<M extends PrismaAdapterModel = PrismaAd
61
72
  * references (`prisma.<model>.fields`) in code-unit order.
62
73
  */
63
74
  export type PrismaClientShape = Readonly<Record<string, readonly string[]>>;
64
- /**
65
- * What a create of each Resource cannot do without, already in core's words
66
- * (`Adapter["createRequirements"]`): a column the client must write, or a
67
- * required relation that may instead be written through the scalar fields that
68
- * hold its reference — and the relation's other end, through which a nested
69
- * create supplies it.
70
- *
71
- * Read at generate time from the generated client's create inputs — the
72
- * question marks on `<M>UncheckedCreateInput` and `<M>CreateInput` — and from the
73
- * schema's `@relation(fields: …)` pairing. Beside the model and outside
74
- * `modelHash`: a requirement is a fact about the store, not about the semantic
75
- * model, and the Contract carries no foreign-key detail.
76
- */
77
- export type PrismaCreateRequirementTable = NonNullable<Adapter["createRequirements"]>;
78
75
  /** The current discovery artifact format. */
79
- export declare const DISCOVERY_ARTIFACT_FORMAT = 1;
76
+ export declare const DISCOVERY_ARTIFACT_FORMAT = 3;
80
77
  /**
81
78
  * The discovery artifact: the module `aventara-prisma7-generate` writes from
82
79
  * your schema and generated client. Import its `discovery` export and pass it
83
80
  * to `createPrismaAdapter({ discovery })`.
84
81
  */
85
- export type PrismaDiscoveryArtifact<M extends PrismaAdapterModel = PrismaAdapterModel> = {
82
+ export type AvPrismaDiscoveryArtifact<M extends AvPrismaAdapterModel = AvPrismaAdapterModel> = {
86
83
  /**
87
84
  * The artifact's format. A TypeScript error naming this property means the
88
85
  * artifact was written by another version of `@aventara/prisma7-adapter`:
@@ -92,8 +89,8 @@ export type PrismaDiscoveryArtifact<M extends PrismaAdapterModel = PrismaAdapter
92
89
  /** The Prisma version the artifact was generated with, such as `"7.10.0"`. */
93
90
  readonly prismaVersion: string;
94
91
  /** The database provider: `"sqlite"` or `"postgresql"`. */
95
- readonly provider: PrismaProvider;
96
- /** `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. */
97
94
  readonly modelHash: string;
98
95
  /** What the schema and the generated client agreed on. */
99
96
  readonly model: M;
@@ -101,14 +98,12 @@ export type PrismaDiscoveryArtifact<M extends PrismaAdapterModel = PrismaAdapter
101
98
  readonly translation: PrismaTranslationTable<M>;
102
99
  /**
103
100
  * The schema's referential actions; not part of `modelHash`. An entry under
104
- * 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`.
105
102
  */
106
- readonly referentialActions: PrismaReferentialActionTable<M>;
103
+ readonly referentialActions: AvPrismaReferentialActionTable<M>;
107
104
  /**
108
105
  * The models and field references of the client the artifact was generated
109
106
  * against; not part of `modelHash`.
110
107
  */
111
108
  readonly client: PrismaClientShape;
112
- /** What a create of each Resource cannot do without; not part of `modelHash`. */
113
- readonly createRequirements: PrismaCreateRequirementTable;
114
109
  };
@@ -1 +1 @@
1
- export const DISCOVERY_ARTIFACT_FORMAT = 1;
1
+ export const DISCOVERY_ARTIFACT_FORMAT = 3;
@@ -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";
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[];
@@ -1,9 +1,9 @@
1
- import { LIFECYCLE_TRAITS, } from "@aventara/core";
1
+ 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[];
@@ -1,15 +1,15 @@
1
- import { type TransactionCapability } from "@aventara/core";
1
+ import type { AvTransactionCapability } from "@aventara/core";
2
2
  import type { PrismaComposedArtifact, PrismaModelComposer } from "../generate/prisma.generate.js";
3
3
  import type { PrismaCapabilitySurface } from "./capability-surface.interface.js";
4
4
  import type { PrismaSchemaFacts } from "./schema-facts.interface.js";
5
5
  /** Thrown when the schema cannot be composed into a model; lists every problem. */
6
- export declare class PrismaModelCompositionError extends Error {
7
- readonly name = "PrismaModelCompositionError";
6
+ export declare class AvPrismaModelCompositionError extends Error {
7
+ readonly name = "AvPrismaModelCompositionError";
8
8
  readonly diagnostics: readonly string[];
9
9
  constructor(diagnostics: readonly string[]);
10
10
  }
11
11
  export type PrismaModelCompositionOptions = {
12
- readonly transactions: TransactionCapability;
12
+ readonly transactions: AvTransactionCapability;
13
13
  };
14
14
  export type PrismaModelDiscoveryInput = PrismaModelCompositionOptions & {
15
15
  /** PSL — what the schema says. */