prisma-guard 1.13.0 → 1.14.0

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.
@@ -12,6 +12,7 @@ interface FieldMeta {
12
12
  isUpdatedAt: boolean;
13
13
  isEnum?: boolean;
14
14
  isUnique?: boolean;
15
+ isUnsupported?: boolean;
15
16
  }
16
17
  interface GuardLogger {
17
18
  warn(message: string): void;
@@ -12,6 +12,7 @@ interface FieldMeta {
12
12
  isUpdatedAt: boolean;
13
13
  isEnum?: boolean;
14
14
  isUnique?: boolean;
15
+ isUnsupported?: boolean;
15
16
  }
16
17
  interface GuardLogger {
17
18
  warn(message: string): void;
@@ -198,7 +198,9 @@ function getSupportedOperators(fieldMeta) {
198
198
  }
199
199
  function createBaseType(fieldMeta, enumMap, scalarBase) {
200
200
  let base;
201
- if (fieldMeta.isEnum) {
201
+ if (fieldMeta.isUnsupported) {
202
+ base = z2.unknown();
203
+ } else if (fieldMeta.isEnum) {
202
204
  const values = enumMap[fieldMeta.type];
203
205
  if (!values || values.length === 0) {
204
206
  throw new ShapeError(`Unknown enum: ${fieldMeta.type}`);
@@ -3361,23 +3363,20 @@ function buildRelationWriteSchema(model, fieldName, relatedModelName, isList, co
3361
3363
  }
3362
3364
  if (!isPlainObject(config.deleteMany)) {
3363
3365
  throw new ShapeError(
3364
- `deleteMany config on "${model}.${fieldName}" must be an object`
3366
+ `deleteMany config on "${model}.${fieldName}" must be an object of allowed filter fields`
3365
3367
  );
3366
3368
  }
3367
- const dmConfig = config.deleteMany;
3368
- if (!dmConfig.where || !isPlainObject(dmConfig.where)) {
3369
- throw new ShapeError(
3370
- `deleteMany on "${model}.${fieldName}" requires "where" object`
3371
- );
3372
- }
3373
- const whereSchema = buildWhereFieldsSchema(
3369
+ const filterSchema = buildWhereFieldsSchema(
3374
3370
  relatedModelName,
3375
- dmConfig.where,
3371
+ config.deleteMany,
3376
3372
  typeMap,
3377
3373
  schemaBuilder
3378
3374
  );
3379
- const dmSchema = z8.object({ where: whereSchema }).strict();
3380
- opSchemas["deleteMany"] = z8.union([dmSchema, z8.preprocess(coerceToArray, z8.array(dmSchema))]).optional();
3375
+ opSchemas["deleteMany"] = z8.union([
3376
+ filterSchema,
3377
+ z8.preprocess(coerceToArray, z8.array(filterSchema)),
3378
+ z8.object({}).strict()
3379
+ ]).optional();
3381
3380
  }
3382
3381
  return z8.object(opSchemas).strict();
3383
3382
  }