@prisma/client-engine-runtime 6.15.0-integration-fix-prisma-client-dirname-aws-lambda.2 → 6.15.0-integration-fix-prisma-client-dirname-aws-lambda.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -120,10 +120,13 @@ export declare type FieldRefTaggedValue = {
120
120
  };
121
121
 
122
122
  export declare type FieldScalarType = {
123
- type: 'string' | 'int' | 'bigint' | 'float' | 'boolean' | 'json' | 'object' | 'datetime' | 'decimal' | 'bytes' | 'unsupported';
123
+ type: 'string' | 'int' | 'bigint' | 'float' | 'boolean' | 'json' | 'object' | 'datetime' | 'decimal' | 'unsupported';
124
124
  } | {
125
125
  type: 'enum';
126
126
  name: string;
127
+ } | {
128
+ type: 'bytes';
129
+ encoding: 'array' | 'base64' | 'hex';
127
130
  };
128
131
 
129
132
  export declare type FieldType = {
package/dist/index.d.ts CHANGED
@@ -120,10 +120,13 @@ export declare type FieldRefTaggedValue = {
120
120
  };
121
121
 
122
122
  export declare type FieldScalarType = {
123
- type: 'string' | 'int' | 'bigint' | 'float' | 'boolean' | 'json' | 'object' | 'datetime' | 'decimal' | 'bytes' | 'unsupported';
123
+ type: 'string' | 'int' | 'bigint' | 'float' | 'boolean' | 'json' | 'object' | 'datetime' | 'decimal' | 'unsupported';
124
124
  } | {
125
125
  type: 'enum';
126
126
  name: string;
127
+ } | {
128
+ type: 'bytes';
129
+ encoding: 'array' | 'base64' | 'hex';
127
130
  };
128
131
 
129
132
  export declare type FieldType = {
package/dist/index.js CHANGED
@@ -170,7 +170,7 @@ function normalizeTaggedValue({ $type, value }) {
170
170
  case "BigInt":
171
171
  return { $type, value: String(value) };
172
172
  case "Bytes":
173
- return { $type, value };
173
+ return { $type, value: Buffer.from(value, "base64").toString("base64") };
174
174
  case "DateTime":
175
175
  return { $type, value: new Date(value).toISOString() };
176
176
  case "Decimal":
@@ -621,16 +621,33 @@ function mapValue(value, columnName, scalarType, enums) {
621
621
  return { $type: "Json", value: `${value}` };
622
622
  }
623
623
  case "bytes": {
624
- if (typeof value === "string" && value.startsWith("\\x")) {
625
- return { $type: "Bytes", value: Buffer.from(value.slice(2), "hex").toString("base64") };
626
- }
627
- if (Array.isArray(value)) {
628
- return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
629
- }
630
- if (value instanceof Uint8Array) {
631
- return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
624
+ switch (scalarType.encoding) {
625
+ case "base64":
626
+ if (typeof value !== "string") {
627
+ throw new DataMapperError(
628
+ `Expected a base64-encoded byte array in column '${columnName}', got ${typeof value}: ${value}`
629
+ );
630
+ }
631
+ return { $type: "Bytes", value };
632
+ case "hex":
633
+ if (typeof value !== "string" || !value.startsWith("\\x")) {
634
+ throw new DataMapperError(
635
+ `Expected a hex-encoded byte array in column '${columnName}', got ${typeof value}: ${value}`
636
+ );
637
+ }
638
+ return { $type: "Bytes", value: Buffer.from(value.slice(2), "hex").toString("base64") };
639
+ case "array":
640
+ if (Array.isArray(value)) {
641
+ return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
642
+ }
643
+ if (value instanceof Uint8Array) {
644
+ return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
645
+ }
646
+ throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
647
+ default:
648
+ assertNever(scalarType.encoding, `DataMapper: Unknown bytes encoding: ${scalarType.encoding}`);
632
649
  }
633
- throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
650
+ break;
634
651
  }
635
652
  case "enum": {
636
653
  const enumDef = enums[scalarType.name];
package/dist/index.mjs CHANGED
@@ -120,7 +120,7 @@ function normalizeTaggedValue({ $type, value }) {
120
120
  case "BigInt":
121
121
  return { $type, value: String(value) };
122
122
  case "Bytes":
123
- return { $type, value };
123
+ return { $type, value: Buffer.from(value, "base64").toString("base64") };
124
124
  case "DateTime":
125
125
  return { $type, value: new Date(value).toISOString() };
126
126
  case "Decimal":
@@ -571,16 +571,33 @@ function mapValue(value, columnName, scalarType, enums) {
571
571
  return { $type: "Json", value: `${value}` };
572
572
  }
573
573
  case "bytes": {
574
- if (typeof value === "string" && value.startsWith("\\x")) {
575
- return { $type: "Bytes", value: Buffer.from(value.slice(2), "hex").toString("base64") };
576
- }
577
- if (Array.isArray(value)) {
578
- return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
579
- }
580
- if (value instanceof Uint8Array) {
581
- return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
574
+ switch (scalarType.encoding) {
575
+ case "base64":
576
+ if (typeof value !== "string") {
577
+ throw new DataMapperError(
578
+ `Expected a base64-encoded byte array in column '${columnName}', got ${typeof value}: ${value}`
579
+ );
580
+ }
581
+ return { $type: "Bytes", value };
582
+ case "hex":
583
+ if (typeof value !== "string" || !value.startsWith("\\x")) {
584
+ throw new DataMapperError(
585
+ `Expected a hex-encoded byte array in column '${columnName}', got ${typeof value}: ${value}`
586
+ );
587
+ }
588
+ return { $type: "Bytes", value: Buffer.from(value.slice(2), "hex").toString("base64") };
589
+ case "array":
590
+ if (Array.isArray(value)) {
591
+ return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
592
+ }
593
+ if (value instanceof Uint8Array) {
594
+ return { $type: "Bytes", value: Buffer.from(value).toString("base64") };
595
+ }
596
+ throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
597
+ default:
598
+ assertNever(scalarType.encoding, `DataMapper: Unknown bytes encoding: ${scalarType.encoding}`);
582
599
  }
583
- throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
600
+ break;
584
601
  }
585
602
  case "enum": {
586
603
  const enumDef = enums[scalarType.name];
@@ -270,8 +270,11 @@ export type FieldType = {
270
270
  arity: Arity;
271
271
  } & FieldScalarType;
272
272
  export type FieldScalarType = {
273
- type: 'string' | 'int' | 'bigint' | 'float' | 'boolean' | 'json' | 'object' | 'datetime' | 'decimal' | 'bytes' | 'unsupported';
273
+ type: 'string' | 'int' | 'bigint' | 'float' | 'boolean' | 'json' | 'object' | 'datetime' | 'decimal' | 'unsupported';
274
274
  } | {
275
275
  type: 'enum';
276
276
  name: string;
277
+ } | {
278
+ type: 'bytes';
279
+ encoding: 'array' | 'base64' | 'hex';
277
280
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.15.0-integration-fix-prisma-client-dirname-aws-lambda.2",
3
+ "version": "6.15.0-integration-fix-prisma-client-dirname-aws-lambda.3",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,8 +31,8 @@
31
31
  "nanoid": "5.1.5",
32
32
  "ulid": "3.0.0",
33
33
  "uuid": "11.1.0",
34
- "@prisma/debug": "6.15.0-integration-fix-prisma-client-dirname-aws-lambda.2",
35
- "@prisma/driver-adapter-utils": "6.15.0-integration-fix-prisma-client-dirname-aws-lambda.2"
34
+ "@prisma/debug": "6.15.0-integration-fix-prisma-client-dirname-aws-lambda.3",
35
+ "@prisma/driver-adapter-utils": "6.15.0-integration-fix-prisma-client-dirname-aws-lambda.3"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",