prisma-guard 1.14.0 → 1.15.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.
- package/dist/generator/index.js +1 -0
- package/dist/generator/index.js.map +1 -1
- package/dist/runtime/index.cjs +19 -28
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +4 -1
- package/dist/runtime/index.d.ts +4 -1
- package/dist/runtime/index.js +17 -27
- package/dist/runtime/index.js.map +1 -1
- package/package.json +1 -1
package/dist/runtime/index.d.cts
CHANGED
|
@@ -187,5 +187,8 @@ declare class CallerError extends Error {
|
|
|
187
187
|
declare function force<T>(value: T): {
|
|
188
188
|
value: T;
|
|
189
189
|
};
|
|
190
|
+
declare function unsupported(): {
|
|
191
|
+
__brand: 'unsupported';
|
|
192
|
+
};
|
|
190
193
|
|
|
191
|
-
export { CallerError, type EnumMap, type FieldMeta, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NestedIncludeArgs, type NestedSelectArgs, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, ShapeError, type ShapeOrFn, type TypeMap, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force };
|
|
194
|
+
export { CallerError, type EnumMap, type FieldMeta, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NestedIncludeArgs, type NestedSelectArgs, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, ShapeError, type ShapeOrFn, type TypeMap, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force, unsupported };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -187,5 +187,8 @@ declare class CallerError extends Error {
|
|
|
187
187
|
declare function force<T>(value: T): {
|
|
188
188
|
value: T;
|
|
189
189
|
};
|
|
190
|
+
declare function unsupported(): {
|
|
191
|
+
__brand: 'unsupported';
|
|
192
|
+
};
|
|
190
193
|
|
|
191
|
-
export { CallerError, type EnumMap, type FieldMeta, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NestedIncludeArgs, type NestedSelectArgs, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, ShapeError, type ShapeOrFn, type TypeMap, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force };
|
|
194
|
+
export { CallerError, type EnumMap, type FieldMeta, type GuardConfig, type GuardGeneratedConfig, type GuardInput, type GuardLogger, type GuardShape, type GuardShapeOrFn, type GuardedModel, type InputOpts, type InputSchema, type MissingScopeContextMode, type ModelOpts, type MutationMethod, type NestedIncludeArgs, type NestedSelectArgs, PolicyError, type QueryMethod, type QuerySchema, type ScopeEntry, type ScopeMap, type ShapeConfig, ShapeError, type ShapeOrFn, type TypeMap, type UniqueConstraint, type UniqueMap, type ZodChains, type ZodDefaults, createGuard, force, unsupported };
|
package/dist/runtime/index.js
CHANGED
|
@@ -573,6 +573,15 @@ function force(value) {
|
|
|
573
573
|
wrapper[FORCED_MARKER] = true;
|
|
574
574
|
return wrapper;
|
|
575
575
|
}
|
|
576
|
+
var UNSUPPORTED_MARKER = Symbol.for("prisma-guard.unsupported");
|
|
577
|
+
function isUnsupportedMarker(v) {
|
|
578
|
+
return v !== null && typeof v === "object" && v[UNSUPPORTED_MARKER] === true;
|
|
579
|
+
}
|
|
580
|
+
function unsupported() {
|
|
581
|
+
const marker = {};
|
|
582
|
+
marker[UNSUPPORTED_MARKER] = true;
|
|
583
|
+
return marker;
|
|
584
|
+
}
|
|
576
585
|
|
|
577
586
|
// src/shared/match-caller.ts
|
|
578
587
|
function matchCallerPattern(patterns, caller) {
|
|
@@ -3159,31 +3168,6 @@ function buildRelationWriteSchema(model, fieldName, relatedModelName, isList, co
|
|
|
3159
3168
|
);
|
|
3160
3169
|
}
|
|
3161
3170
|
}
|
|
3162
|
-
if (config.delete !== void 0) {
|
|
3163
|
-
if (config.delete === true) {
|
|
3164
|
-
if (isList) {
|
|
3165
|
-
throw new ShapeError(
|
|
3166
|
-
`delete on to-many relation "${model}.${fieldName}" requires field config, not true`
|
|
3167
|
-
);
|
|
3168
|
-
}
|
|
3169
|
-
opSchemas["delete"] = z8.literal(true).optional();
|
|
3170
|
-
} else if (isPlainObject(config.delete)) {
|
|
3171
|
-
const deleteSchema = buildWhereFieldsSchema(
|
|
3172
|
-
relatedModelName,
|
|
3173
|
-
config.delete,
|
|
3174
|
-
typeMap,
|
|
3175
|
-
schemaBuilder
|
|
3176
|
-
);
|
|
3177
|
-
opSchemas["delete"] = isList ? z8.union([
|
|
3178
|
-
deleteSchema,
|
|
3179
|
-
z8.preprocess(coerceToArray, z8.array(deleteSchema))
|
|
3180
|
-
]).optional() : deleteSchema.optional();
|
|
3181
|
-
} else {
|
|
3182
|
-
throw new ShapeError(
|
|
3183
|
-
`delete config on "${model}.${fieldName}" must be true (to-one) or an object of field names`
|
|
3184
|
-
);
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
3171
|
if (config.set !== void 0) {
|
|
3188
3172
|
if (!isList) {
|
|
3189
3173
|
throw new ShapeError(
|
|
@@ -3390,8 +3374,13 @@ function buildDataSchema(model, dataConfig, mode, typeMap, schemaBuilder, zodDef
|
|
|
3390
3374
|
const forced = {};
|
|
3391
3375
|
for (const [fieldName, value] of Object.entries(dataConfig)) {
|
|
3392
3376
|
const fieldMeta = modelFields[fieldName];
|
|
3393
|
-
if (!fieldMeta)
|
|
3377
|
+
if (!fieldMeta) {
|
|
3378
|
+
if (isUnsupportedMarker(value)) {
|
|
3379
|
+
schemaMap[fieldName] = z8.unknown().optional();
|
|
3380
|
+
continue;
|
|
3381
|
+
}
|
|
3394
3382
|
throw new ShapeError(`Unknown field "${fieldName}" on model "${model}"`);
|
|
3383
|
+
}
|
|
3395
3384
|
if (fieldMeta.isRelation) {
|
|
3396
3385
|
if (!isPlainObject(value)) {
|
|
3397
3386
|
throw new ShapeError(
|
|
@@ -4599,6 +4588,7 @@ export {
|
|
|
4599
4588
|
PolicyError,
|
|
4600
4589
|
ShapeError,
|
|
4601
4590
|
createGuard,
|
|
4602
|
-
force
|
|
4591
|
+
force,
|
|
4592
|
+
unsupported
|
|
4603
4593
|
};
|
|
4604
4594
|
//# sourceMappingURL=index.js.map
|