@aventara/prisma7-adapter 1.0.0-rc.10 → 1.0.0-rc.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @aventara/prisma7-adapter
2
2
 
3
+ ## 1.0.0-rc.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d8b589: Internal: the object and plain-object checks the translators, executors and error locators share now live in one module.
8
+ No behaviour changes.
9
+ - Updated dependencies [6197c08]
10
+ - Updated dependencies [e0e89c1]
11
+ - Updated dependencies [186bc29]
12
+ - Updated dependencies [33b5f83]
13
+ - Updated dependencies [6d8b589]
14
+ - Updated dependencies [11ece49]
15
+ - Updated dependencies [92fd093]
16
+ - Updated dependencies [e5e98e6]
17
+ - Updated dependencies [a05d970]
18
+ - @aventara/core@1.0.0-rc.11
19
+
3
20
  ## 1.0.0-rc.10
4
21
 
5
22
  ### Patch Changes
@@ -22,6 +39,7 @@
22
39
 
23
40
  The compare-and-swap takes its fields from what the adapter compares, so an exemption that hides `equals` from callers
24
41
  no longer takes a field out of it.
42
+
25
43
  - 4f0fd29: The Prisma 7 adapter's peer floor is now `^7.10.1` (`prisma`, `@prisma/client`, `@prisma/adapter-pg`,
26
44
  `@prisma/adapter-better-sqlite3`). `prisma` 7.10.0 pins `mysql2` 3.15.3 (GHSA-3f6p-5ww8-9rcr, GHSA-rgwj-5xj2-c3m3)
27
45
  and, through `@prisma/config`, `deepmerge-ts` 7.1.5 (GHSA-ggr8-5vv4-36mx); 7.10.1 pins `mysql2` 3.24.4 and
@@ -1,4 +1,5 @@
1
1
  import { canonicalizeJson } from "@aventara/core/internal";
2
+ import { isRecord } from "../record.guard.js";
2
3
  import { DISCOVERY_ARTIFACT_FORMAT, } from "./discovery-artifact.interface.js";
3
4
  const HASH_PREFIX = "sha256:";
4
5
  const REGENERATION_INSTRUCTION = "Regenerate the discovery artifact — `npm run aventara:prepare` in a project " +
@@ -22,9 +23,6 @@ async function sha256(text) {
22
23
  export async function computeModelHash(model) {
23
24
  return sha256(canonicalizeJson(model));
24
25
  }
25
- function isRecord(value) {
26
- return typeof value === "object" && value !== null && !Array.isArray(value);
27
- }
28
26
  function majorOf(version) {
29
27
  const major = /^(\d+)\./.exec(version)?.[1];
30
28
  return major;
@@ -1,3 +1,4 @@
1
+ import { isPlainRecord } from "../record.guard.js";
1
2
  export function derivePrismaBackReferences(model) {
2
3
  const table = {};
3
4
  for (const [source, resource] of Object.entries(model.resources)) {
@@ -25,7 +26,7 @@ const DATA_KEYS = {
25
26
  };
26
27
  const TOP_DATA_KEYS = ["data", "create", "update"];
27
28
  export function locateBackReferenceWrite(table, model, resource, args) {
28
- if (!isRecord(args)) {
29
+ if (!isPlainRecord(args)) {
29
30
  return undefined;
30
31
  }
31
32
  for (const key of TOP_DATA_KEYS) {
@@ -44,7 +45,7 @@ function inRecord(table, model, resource, data, path, via) {
44
45
  return [...path, key];
45
46
  }
46
47
  const shape = fields?.[key];
47
- if (shape?.kind !== "relation" || !isRecord(value)) {
48
+ if (shape?.kind !== "relation" || !isPlainRecord(value)) {
48
49
  continue;
49
50
  }
50
51
  const back = table[resource]?.[key];
@@ -57,7 +58,7 @@ function inRecord(table, model, resource, data, path, via) {
57
58
  ? inRecord(table, model, shape.target, item, itemPath, back)
58
59
  : firstOf(dataKeys, (dataKey) => {
59
60
  const nested = item[dataKey];
60
- return isRecord(nested)
61
+ return isPlainRecord(nested)
61
62
  ? inRecord(table, model, shape.target, nested, [...itemPath, dataKey], back)
62
63
  : undefined;
63
64
  }));
@@ -71,7 +72,7 @@ function inRecord(table, model, resource, data, path, via) {
71
72
  function eachRecord(value, path, visit) {
72
73
  if (Array.isArray(value)) {
73
74
  for (const [index, entry] of value.entries()) {
74
- const found = isRecord(entry)
75
+ const found = isPlainRecord(entry)
75
76
  ? visit(entry, [...path, index])
76
77
  : undefined;
77
78
  if (found !== undefined) {
@@ -80,7 +81,7 @@ function eachRecord(value, path, visit) {
80
81
  }
81
82
  return undefined;
82
83
  }
83
- return isRecord(value) ? visit(value, path) : undefined;
84
+ return isPlainRecord(value) ? visit(value, path) : undefined;
84
85
  }
85
86
  function firstOf(keys, find) {
86
87
  for (const key of keys) {
@@ -91,10 +92,3 @@ function firstOf(keys, find) {
91
92
  }
92
93
  return undefined;
93
94
  }
94
- function isRecord(value) {
95
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
96
- return false;
97
- }
98
- const prototype = Object.getPrototypeOf(value);
99
- return prototype === Object.prototype || prototype === null;
100
- }
@@ -1,5 +1,6 @@
1
+ import { isPlainRecord } from "../record.guard.js";
1
2
  export function locateUnboundBigint(args) {
2
- return isRecord(args) ? inValue(args, []) : undefined;
3
+ return isPlainRecord(args) ? inValue(args, []) : undefined;
3
4
  }
4
5
  function inValue(value, path) {
5
6
  if (typeof value === "bigint") {
@@ -7,7 +8,7 @@ function inValue(value, path) {
7
8
  }
8
9
  const entries = Array.isArray(value)
9
10
  ? [...value.entries()]
10
- : isRecord(value)
11
+ : isPlainRecord(value)
11
12
  ? Object.entries(value)
12
13
  : [];
13
14
  for (const [key, member] of entries) {
@@ -18,10 +19,3 @@ function inValue(value, path) {
18
19
  }
19
20
  return undefined;
20
21
  }
21
- function isRecord(value) {
22
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
23
- return false;
24
- }
25
- const prototype = Object.getPrototypeOf(value);
26
- return prototype === Object.prototype || prototype === null;
27
- }
@@ -1,6 +1,4 @@
1
- function isRecord(value) {
2
- return value !== null && typeof value === "object" && !Array.isArray(value);
3
- }
1
+ import { isRecord } from "../record.guard.js";
4
2
  function relationOf(model, resource, name) {
5
3
  const fields = (Object.hasOwn(model.resources, resource)
6
4
  ? model.resources[resource]?.fields
@@ -1,5 +1,6 @@
1
1
  import { AvError } from "@aventara/core";
2
2
  import { readPrismaError } from "../errors/prisma-error.reader.js";
3
+ import { isRecord } from "../record.guard.js";
3
4
  import { addressIdentifier } from "../translation/identifier.addressing.js";
4
5
  const LOST_ROW_MESSAGE = "The state this operation had selected changed before its effect could be applied, so nothing was written.";
5
6
  export function lostRowConflict() {
@@ -62,6 +63,3 @@ function writeWhere(write) {
62
63
  }
63
64
  return where;
64
65
  }
65
- function isRecord(value) {
66
- return typeof value === "object" && value !== null && !Array.isArray(value);
67
- }
@@ -1,3 +1,4 @@
1
+ import { isRecord } from "../record.guard.js";
1
2
  import { receiveScalarValue } from "../translation/scalar.conversion.js";
2
3
  export class AvPrismaResultShapeError extends Error {
3
4
  constructor(reason) {
@@ -7,9 +8,6 @@ export class AvPrismaResultShapeError extends Error {
7
8
  }
8
9
  const PRISMA_COUNT_KEY = "_count";
9
10
  const NO_REDUCERS = { relations: [] };
10
- function isRecord(value) {
11
- return typeof value === "object" && value !== null && !Array.isArray(value);
12
- }
13
11
  function readCount(row, field) {
14
12
  const counts = row[PRISMA_COUNT_KEY];
15
13
  const count = isRecord(counts) ? counts[field] : undefined;
@@ -1,3 +1,4 @@
1
+ import { isRecord } from "../record.guard.js";
1
2
  export async function resolveScopedCursors(model, resource, args, lookup) {
2
3
  return (await resolveLevel(model, resource, args, lookup)) ?? args;
3
4
  }
@@ -42,6 +43,3 @@ async function resolveSelect(model, resource, select, lookup) {
42
43
  }
43
44
  return changed ? entries : undefined;
44
45
  }
45
- function isRecord(value) {
46
- return typeof value === "object" && value !== null && !Array.isArray(value);
47
- }
@@ -0,0 +1,9 @@
1
+ /** An object that is not a list. */
2
+ export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
3
+ /**
4
+ * A **plain** record (prototype `Object.prototype` or `null`). Core's
5
+ * discriminant between an argument object and a VALUE, mirrored
6
+ * **[CORE, runtime/record.guard.ts `isPlainRecord`]**: a class instance — a
7
+ * core `Decimal`, a `Date`, a `Uint8Array` — is a value, not a bag of operators.
8
+ */
9
+ export declare function isPlainRecord(value: unknown): value is Readonly<Record<string, unknown>>;
@@ -0,0 +1,10 @@
1
+ export function isRecord(value) {
2
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3
+ }
4
+ export function isPlainRecord(value) {
5
+ if (!isRecord(value)) {
6
+ return false;
7
+ }
8
+ const prototype = Object.getPrototypeOf(value);
9
+ return prototype === Object.prototype || prototype === null;
10
+ }
@@ -1,4 +1,5 @@
1
1
  import { advertisedDirectives, } from "@aventara/core/internal";
2
+ import { isRecord } from "../record.guard.js";
2
3
  import { addressIdentifier } from "./identifier.addressing.js";
3
4
  import { PRISMA_DB_NULL } from "./json-null.sentinel.js";
4
5
  import { emitScalarValue } from "./scalar.conversion.js";
@@ -383,9 +384,6 @@ function isScalarMutationDirective(key) {
383
384
  function isRelationMutationDirective(key) {
384
385
  return Object.hasOwn(RELATION_DIRECTIVE_EMISSIONS, key);
385
386
  }
386
- function isRecord(value) {
387
- return typeof value === "object" && value !== null && !Array.isArray(value);
388
- }
389
387
  function isJson(field) {
390
388
  return "scalar" in field.type && field.type.scalar === "json";
391
389
  }
@@ -1,3 +1,4 @@
1
+ import { isRecord } from "../record.guard.js";
1
2
  import { addressIdentifier } from "./identifier.addressing.js";
2
3
  import { translateMutationData } from "./mutation.translator.js";
3
4
  import { translateCursorLookup, translateOrderBy, translatePagination, } from "./order-pagination.translator.js";
@@ -368,6 +369,3 @@ function resolveRelationTarget(context, path) {
368
369
  }
369
370
  return resource;
370
371
  }
371
- function isRecord(value) {
372
- return typeof value === "object" && value !== null && !Array.isArray(value);
373
- }
@@ -1,4 +1,5 @@
1
1
  import { advertisedReducers, } from "@aventara/core/internal";
2
+ import { isRecord } from "../record.guard.js";
2
3
  import { addressIdentifier } from "./identifier.addressing.js";
3
4
  export class AvPrismaOrderTranslationError extends Error {
4
5
  name = "AvPrismaOrderTranslationError";
@@ -126,6 +127,3 @@ function translateRelationOrder(model, field, value, path) {
126
127
  function isReducer(key) {
127
128
  return Object.hasOwn(REDUCER_TOKENS, key);
128
129
  }
129
- function isRecord(value) {
130
- return typeof value === "object" && value !== null && !Array.isArray(value);
131
- }
@@ -1,3 +1,4 @@
1
+ import { isRecord } from "../record.guard.js";
1
2
  export class AvPrismaProjectionTranslationError extends Error {
2
3
  constructor(reason, path) {
3
4
  const where = path.length === 0 ? "the root projection" : path.join(".");
@@ -7,9 +8,6 @@ export class AvPrismaProjectionTranslationError extends Error {
7
8
  }
8
9
  const PRISMA_COUNT_KEY = "_count";
9
10
  const AVENTARA_COUNT_REDUCER = "$count";
10
- function isRecord(value) {
11
- return typeof value === "object" && value !== null && !Array.isArray(value);
12
- }
13
11
  function relationEntry(entry, path) {
14
12
  const keys = Object.keys(entry);
15
13
  const field = keys[0];
@@ -1,3 +1,4 @@
1
+ import { isPlainRecord, isRecord } from "../record.guard.js";
1
2
  import { PRISMA_ANY_NULL } from "./json-null.sentinel.js";
2
3
  import { emitScalarValue } from "./scalar.conversion.js";
3
4
  export class AvPrismaWhereTranslationError extends Error {
@@ -301,13 +302,3 @@ function isRelationFilterCapability(key) {
301
302
  function isJson(field) {
302
303
  return "scalar" in field.type && field.type.scalar === "json";
303
304
  }
304
- function isRecord(value) {
305
- return typeof value === "object" && value !== null && !Array.isArray(value);
306
- }
307
- function isPlainRecord(value) {
308
- if (!isRecord(value)) {
309
- return false;
310
- }
311
- const prototype = Object.getPrototypeOf(value);
312
- return prototype === Object.prototype || prototype === null;
313
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aventara/prisma7-adapter",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.11",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "The Prisma 7 adapter for Aventara.",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "CHANGELOG.md"
31
31
  ],
32
32
  "dependencies": {
33
- "@aventara/core": "1.0.0-rc.10"
33
+ "@aventara/core": "1.0.0-rc.11"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@prisma/adapter-better-sqlite3": "^7.10.1",