@zenstackhq/runtime 2.16.0 → 3.0.0-alpha.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/LICENSE +1 -1
- package/dist/client.cjs +6094 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +19 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +6060 -0
- package/dist/client.js.map +1 -0
- package/dist/contract-DguafRNB.d.cts +1272 -0
- package/dist/contract-DguafRNB.d.ts +1272 -0
- package/dist/index.cjs +6088 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6057 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/policy.cjs +2343 -0
- package/dist/plugins/policy.cjs.map +1 -0
- package/dist/plugins/policy.d.cts +24 -0
- package/dist/plugins/policy.d.ts +24 -0
- package/dist/plugins/policy.js +2307 -0
- package/dist/plugins/policy.js.map +1 -0
- package/dist/schema.cjs +110 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +29 -0
- package/dist/schema.d.ts +29 -0
- package/dist/schema.js +85 -0
- package/dist/schema.js.map +1 -0
- package/dist/utils/pg-utils.cjs +39 -0
- package/dist/utils/pg-utils.cjs.map +1 -0
- package/dist/utils/pg-utils.d.cts +8 -0
- package/dist/utils/pg-utils.d.ts +8 -0
- package/dist/utils/pg-utils.js +16 -0
- package/dist/utils/pg-utils.js.map +1 -0
- package/{browser/index.js → dist/utils/sqlite-utils.cjs} +21 -37
- package/dist/utils/sqlite-utils.cjs.map +1 -0
- package/dist/utils/sqlite-utils.d.cts +8 -0
- package/dist/utils/sqlite-utils.d.ts +8 -0
- package/dist/utils/sqlite-utils.js +22 -0
- package/dist/utils/sqlite-utils.js.map +1 -0
- package/package.json +106 -117
- package/README.md +0 -5
- package/browser/index.d.mts +0 -13
- package/browser/index.d.ts +0 -13
- package/browser/index.js.map +0 -1
- package/browser/index.mjs +0 -33
- package/browser/index.mjs.map +0 -1
- package/constants.d.ts +0 -62
- package/constants.js +0 -76
- package/constants.js.map +0 -1
- package/cross/index.d.mts +0 -379
- package/cross/index.d.ts +0 -379
- package/cross/index.js +0 -923
- package/cross/index.js.map +0 -1
- package/cross/index.mjs +0 -881
- package/cross/index.mjs.map +0 -1
- package/edge.d.ts +0 -1
- package/edge.js +0 -18
- package/edge.js.map +0 -1
- package/encryption/index.d.ts +0 -25
- package/encryption/index.js +0 -74
- package/encryption/index.js.map +0 -1
- package/encryption/utils.d.ts +0 -9
- package/encryption/utils.js +0 -99
- package/encryption/utils.js.map +0 -1
- package/enhance-edge.d.ts +0 -1
- package/enhance-edge.js +0 -10
- package/enhance.d.ts +0 -1
- package/enhance.js +0 -10
- package/enhancements/edge/create-enhancement.d.ts +0 -42
- package/enhancements/edge/create-enhancement.js +0 -102
- package/enhancements/edge/create-enhancement.js.map +0 -1
- package/enhancements/edge/default-auth.d.ts +0 -8
- package/enhancements/edge/default-auth.js +0 -180
- package/enhancements/edge/default-auth.js.map +0 -1
- package/enhancements/edge/delegate.d.ts +0 -77
- package/enhancements/edge/delegate.js +0 -1293
- package/enhancements/edge/delegate.js.map +0 -1
- package/enhancements/edge/encryption.d.ts +0 -7
- package/enhancements/edge/encryption.js +0 -150
- package/enhancements/edge/encryption.js.map +0 -1
- package/enhancements/edge/index.d.ts +0 -4
- package/enhancements/edge/index.js +0 -21
- package/enhancements/edge/index.js.map +0 -1
- package/enhancements/edge/json-processor.d.ts +0 -7
- package/enhancements/edge/json-processor.js +0 -89
- package/enhancements/edge/json-processor.js.map +0 -1
- package/enhancements/edge/logger.d.ts +0 -29
- package/enhancements/edge/logger.js +0 -65
- package/enhancements/edge/logger.js.map +0 -1
- package/enhancements/edge/omit.d.ts +0 -7
- package/enhancements/edge/omit.js +0 -96
- package/enhancements/edge/omit.js.map +0 -1
- package/enhancements/edge/password.d.ts +0 -7
- package/enhancements/edge/password.js +0 -64
- package/enhancements/edge/password.js.map +0 -1
- package/enhancements/edge/policy/check-utils.d.ts +0 -5
- package/enhancements/edge/policy/check-utils.js +0 -20
- package/enhancements/edge/policy/check-utils.js.map +0 -1
- package/enhancements/edge/policy/handler.d.ts +0 -100
- package/enhancements/edge/policy/handler.js +0 -1440
- package/enhancements/edge/policy/handler.js.map +0 -1
- package/enhancements/edge/policy/index.d.ts +0 -19
- package/enhancements/edge/policy/index.js +0 -65
- package/enhancements/edge/policy/index.js.map +0 -1
- package/enhancements/edge/policy/policy-utils.d.ts +0 -181
- package/enhancements/edge/policy/policy-utils.js +0 -1356
- package/enhancements/edge/policy/policy-utils.js.map +0 -1
- package/enhancements/edge/promise.d.ts +0 -15
- package/enhancements/edge/promise.js +0 -99
- package/enhancements/edge/promise.js.map +0 -1
- package/enhancements/edge/proxy.d.ts +0 -120
- package/enhancements/edge/proxy.js +0 -287
- package/enhancements/edge/proxy.js.map +0 -1
- package/enhancements/edge/query-utils.d.ts +0 -53
- package/enhancements/edge/query-utils.js +0 -256
- package/enhancements/edge/query-utils.js.map +0 -1
- package/enhancements/edge/types.d.ts +0 -238
- package/enhancements/edge/types.js +0 -3
- package/enhancements/edge/types.js.map +0 -1
- package/enhancements/edge/utils.d.ts +0 -11
- package/enhancements/edge/utils.js +0 -49
- package/enhancements/edge/utils.js.map +0 -1
- package/enhancements/edge/where-visitor.d.ts +0 -32
- package/enhancements/edge/where-visitor.js +0 -86
- package/enhancements/edge/where-visitor.js.map +0 -1
- package/enhancements/node/create-enhancement.d.ts +0 -42
- package/enhancements/node/create-enhancement.js +0 -102
- package/enhancements/node/create-enhancement.js.map +0 -1
- package/enhancements/node/default-auth.d.ts +0 -8
- package/enhancements/node/default-auth.js +0 -180
- package/enhancements/node/default-auth.js.map +0 -1
- package/enhancements/node/delegate.d.ts +0 -77
- package/enhancements/node/delegate.js +0 -1293
- package/enhancements/node/delegate.js.map +0 -1
- package/enhancements/node/encryption.d.ts +0 -7
- package/enhancements/node/encryption.js +0 -150
- package/enhancements/node/encryption.js.map +0 -1
- package/enhancements/node/index.d.ts +0 -4
- package/enhancements/node/index.js +0 -21
- package/enhancements/node/index.js.map +0 -1
- package/enhancements/node/json-processor.d.ts +0 -7
- package/enhancements/node/json-processor.js +0 -89
- package/enhancements/node/json-processor.js.map +0 -1
- package/enhancements/node/logger.d.ts +0 -29
- package/enhancements/node/logger.js +0 -65
- package/enhancements/node/logger.js.map +0 -1
- package/enhancements/node/omit.d.ts +0 -7
- package/enhancements/node/omit.js +0 -96
- package/enhancements/node/omit.js.map +0 -1
- package/enhancements/node/password.d.ts +0 -7
- package/enhancements/node/password.js +0 -64
- package/enhancements/node/password.js.map +0 -1
- package/enhancements/node/policy/check-utils.d.ts +0 -5
- package/enhancements/node/policy/check-utils.js +0 -87
- package/enhancements/node/policy/check-utils.js.map +0 -1
- package/enhancements/node/policy/constraint-solver.d.ts +0 -27
- package/enhancements/node/policy/constraint-solver.js +0 -164
- package/enhancements/node/policy/constraint-solver.js.map +0 -1
- package/enhancements/node/policy/handler.d.ts +0 -100
- package/enhancements/node/policy/handler.js +0 -1440
- package/enhancements/node/policy/handler.js.map +0 -1
- package/enhancements/node/policy/index.d.ts +0 -19
- package/enhancements/node/policy/index.js +0 -65
- package/enhancements/node/policy/index.js.map +0 -1
- package/enhancements/node/policy/policy-utils.d.ts +0 -181
- package/enhancements/node/policy/policy-utils.js +0 -1356
- package/enhancements/node/policy/policy-utils.js.map +0 -1
- package/enhancements/node/promise.d.ts +0 -15
- package/enhancements/node/promise.js +0 -99
- package/enhancements/node/promise.js.map +0 -1
- package/enhancements/node/proxy.d.ts +0 -120
- package/enhancements/node/proxy.js +0 -287
- package/enhancements/node/proxy.js.map +0 -1
- package/enhancements/node/query-utils.d.ts +0 -53
- package/enhancements/node/query-utils.js +0 -256
- package/enhancements/node/query-utils.js.map +0 -1
- package/enhancements/node/types.d.ts +0 -238
- package/enhancements/node/types.js +0 -3
- package/enhancements/node/types.js.map +0 -1
- package/enhancements/node/utils.d.ts +0 -11
- package/enhancements/node/utils.js +0 -49
- package/enhancements/node/utils.js.map +0 -1
- package/enhancements/node/where-visitor.d.ts +0 -32
- package/enhancements/node/where-visitor.js +0 -86
- package/enhancements/node/where-visitor.js.map +0 -1
- package/error.d.ts +0 -11
- package/error.js +0 -22
- package/error.js.map +0 -1
- package/index.d.ts +0 -7
- package/index.js +0 -24
- package/index.js.map +0 -1
- package/local-helpers/index.d.ts +0 -6
- package/local-helpers/index.js +0 -23
- package/local-helpers/index.js.map +0 -1
- package/local-helpers/is-plain-object.d.ts +0 -1
- package/local-helpers/is-plain-object.js +0 -25
- package/local-helpers/is-plain-object.js.map +0 -1
- package/local-helpers/lower-case-first.d.ts +0 -1
- package/local-helpers/lower-case-first.js +0 -7
- package/local-helpers/lower-case-first.js.map +0 -1
- package/local-helpers/param-case.d.ts +0 -1
- package/local-helpers/param-case.js +0 -20
- package/local-helpers/param-case.js.map +0 -1
- package/local-helpers/sleep.d.ts +0 -1
- package/local-helpers/sleep.js +0 -9
- package/local-helpers/sleep.js.map +0 -1
- package/local-helpers/tiny-invariant.d.ts +0 -1
- package/local-helpers/tiny-invariant.js +0 -15
- package/local-helpers/tiny-invariant.js.map +0 -1
- package/local-helpers/upper-case-first.d.ts +0 -1
- package/local-helpers/upper-case-first.js +0 -7
- package/local-helpers/upper-case-first.js.map +0 -1
- package/model-meta.d.ts +0 -1
- package/model-meta.js +0 -10
- package/models.d.ts +0 -1
- package/models.js +0 -1
- package/types.d.ts +0 -200
- package/types.js +0 -4
- package/types.js.map +0 -1
- package/validation.d.ts +0 -24
- package/validation.js +0 -52
- package/validation.js.map +0 -1
- package/version.d.ts +0 -5
- package/version.js +0 -35
- package/version.js.map +0 -1
- package/zod/index.d.ts +0 -3
- package/zod/index.js +0 -5
- package/zod/input.d.ts +0 -1
- package/zod/input.js +0 -8
- package/zod/models.d.ts +0 -1
- package/zod/models.js +0 -8
- package/zod/objects.d.ts +0 -1
- package/zod/objects.js +0 -8
- package/zod-utils.d.ts +0 -12
- package/zod-utils.js +0 -97
- package/zod-utils.js.map +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { InternalEnhancementOptions } from './create-enhancement';
|
|
2
|
-
/**
|
|
3
|
-
* Gets an enhanced Prisma client that supports `@password` attribute.
|
|
4
|
-
*
|
|
5
|
-
* @private
|
|
6
|
-
*/
|
|
7
|
-
export declare function withPassword<DbClient extends object = any>(prisma: DbClient, options: InternalEnhancementOptions): DbClient;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.withPassword = withPassword;
|
|
15
|
-
const constants_1 = require("../../constants");
|
|
16
|
-
const cross_1 = require("../../cross");
|
|
17
|
-
const proxy_1 = require("./proxy");
|
|
18
|
-
/**
|
|
19
|
-
* Gets an enhanced Prisma client that supports `@password` attribute.
|
|
20
|
-
*
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
function withPassword(prisma, options) {
|
|
24
|
-
return (0, proxy_1.makeProxy)(prisma, options.modelMeta, (_prisma, model) => new PasswordHandler(_prisma, model, options), 'password');
|
|
25
|
-
}
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
27
|
-
const hashFunc = typeof EdgeRuntime === 'string' ? require('bcryptjs').hashSync : require('bcryptjs').hash;
|
|
28
|
-
class PasswordHandler extends proxy_1.DefaultPrismaProxyHandler {
|
|
29
|
-
constructor(prisma, model, options) {
|
|
30
|
-
super(prisma, model, options);
|
|
31
|
-
}
|
|
32
|
-
// base override
|
|
33
|
-
preprocessArgs(action, args) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
if (args && constants_1.ACTIONS_WITH_WRITE_PAYLOAD.includes(action)) {
|
|
36
|
-
yield this.preprocessWritePayload(this.model, action, args);
|
|
37
|
-
}
|
|
38
|
-
return args;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
preprocessWritePayload(model, action, args) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const visitor = new cross_1.NestedWriteVisitor(this.options.modelMeta, {
|
|
44
|
-
field: (field, _action, data, context) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
var _a, _b, _c;
|
|
46
|
-
const pwdAttr = (_a = field.attributes) === null || _a === void 0 ? void 0 : _a.find((attr) => attr.name === '@password');
|
|
47
|
-
if (pwdAttr && field.type === 'String') {
|
|
48
|
-
// hash password value
|
|
49
|
-
let salt = (_b = pwdAttr.args.find((arg) => arg.name === 'salt')) === null || _b === void 0 ? void 0 : _b.value;
|
|
50
|
-
if (!salt) {
|
|
51
|
-
salt = (_c = pwdAttr.args.find((arg) => arg.name === 'saltLength')) === null || _c === void 0 ? void 0 : _c.value;
|
|
52
|
-
}
|
|
53
|
-
if (!salt) {
|
|
54
|
-
salt = constants_1.DEFAULT_PASSWORD_SALT_LENGTH;
|
|
55
|
-
}
|
|
56
|
-
context.parent[field.name] = yield hashFunc(data, salt);
|
|
57
|
-
}
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
yield visitor.visit(model, action, args);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=password.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../../src/enhancements/edge/password.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,sDAAsD;;;;;;;;;;;AAatD,oCAUC;AArBD,+CAA2F;AAC3F,uCAA6E;AAG7E,mCAAmF;AAEnF;;;;GAIG;AACH,SAAgB,YAAY,CACxB,MAAgB,EAChB,OAAmC;IAEnC,OAAO,IAAA,iBAAS,EACZ,MAAM,EACN,OAAO,CAAC,SAAS,EACjB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,OAA2B,EAAE,KAAK,EAAE,OAAO,CAAC,EACpF,UAAU,CACb,CAAC;AACN,CAAC;AAOD,8DAA8D;AAC9D,MAAM,QAAQ,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;AAE3G,MAAM,eAAgB,SAAQ,iCAAyB;IACnD,YAAY,MAAwB,EAAE,KAAa,EAAE,OAAmC;QACpF,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,gBAAgB;IACA,cAAc,CAAC,MAA0B,EAAE,IAAS;;YAChE,IAAI,IAAI,IAAI,sCAA0B,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtD,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,MAA+B,EAAE,IAAI,CAAC,CAAC;YACzF,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;KAAA;IAEa,sBAAsB,CAAC,KAAa,EAAE,MAA6B,EAAE,IAAS;;YACxF,MAAM,OAAO,GAAG,IAAI,0BAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;gBAC3D,KAAK,EAAE,CAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;;oBAC3C,MAAM,OAAO,GAAG,MAAA,KAAK,CAAC,UAAU,0CAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;oBAC5E,IAAI,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;wBACrC,sBAAsB;wBACtB,IAAI,IAAI,GAAgC,MAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,0CACjF,KAAe,CAAC;wBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;4BACR,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,0CAAE,KAAe,CAAC;wBAClF,CAAC;wBACD,IAAI,CAAC,IAAI,EAAE,CAAC;4BACR,IAAI,GAAG,wCAA4B,CAAC;wBACxC,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBAC5D,CAAC;gBACL,CAAC,CAAA;aACJ,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;KAAA;CACJ"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ModelMeta } from '..';
|
|
2
|
-
import type { DbClientContract } from '../../../types';
|
|
3
|
-
import { PermissionCheckArgs } from '../types';
|
|
4
|
-
import { PolicyUtil } from './policy-utils';
|
|
5
|
-
export declare function checkPermission(_model: string, _args: PermissionCheckArgs, _modelMeta: ModelMeta, _policyUtils: PolicyUtil, _prisma: DbClientContract, _prismaModule: any): Promise<boolean>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.checkPermission = checkPermission;
|
|
13
|
-
function checkPermission(_model, _args, _modelMeta, _policyUtils, _prisma,
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
_prismaModule) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
throw new Error('`check()` API is not supported on edge runtime');
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=check-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check-utils.js","sourceRoot":"","sources":["../../../../src/enhancements/edge/policy/check-utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAKA,0CAUC;AAVD,SAAsB,eAAe,CACjC,MAAc,EACd,KAA0B,EAC1B,UAAqB,EACrB,YAAwB,EACxB,OAAyB;AACzB,8DAA8D;AAC9D,aAAkB;;QAElB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACtE,CAAC;CAAA"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { EnhancementContext, type DbClientContract } from '../../../types';
|
|
2
|
-
import type { InternalEnhancementOptions } from '../create-enhancement';
|
|
3
|
-
import { PrismaProxyHandler } from '../proxy';
|
|
4
|
-
import type { PermissionCheckArgs } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Prisma proxy handler for injecting access policy check.
|
|
7
|
-
*/
|
|
8
|
-
export declare class PolicyProxyHandler<DbClient extends DbClientContract> implements PrismaProxyHandler {
|
|
9
|
-
private readonly prisma;
|
|
10
|
-
private readonly options;
|
|
11
|
-
private readonly context?;
|
|
12
|
-
private readonly logger;
|
|
13
|
-
private readonly policyUtils;
|
|
14
|
-
private readonly model;
|
|
15
|
-
private readonly modelMeta;
|
|
16
|
-
private readonly prismaModule;
|
|
17
|
-
private readonly queryUtils;
|
|
18
|
-
constructor(prisma: DbClient, model: string, options: InternalEnhancementOptions, context?: EnhancementContext | undefined);
|
|
19
|
-
private get modelClient();
|
|
20
|
-
findUnique(args: any): Promise<any>;
|
|
21
|
-
findUniqueOrThrow(args: any): Promise<any>;
|
|
22
|
-
findFirst(args?: any): Promise<any>;
|
|
23
|
-
findFirstOrThrow(args: any): Promise<any>;
|
|
24
|
-
findMany(args?: any): Promise<unknown[]>;
|
|
25
|
-
private findWithFluent;
|
|
26
|
-
private doFind;
|
|
27
|
-
create(args: any): Promise<unknown>;
|
|
28
|
-
private doCreate;
|
|
29
|
-
private hasNestedCreateOrConnect;
|
|
30
|
-
private validateCreateInputSchema;
|
|
31
|
-
createMany(args: {
|
|
32
|
-
data: any;
|
|
33
|
-
skipDuplicates?: boolean;
|
|
34
|
-
}): Promise<{
|
|
35
|
-
count: number;
|
|
36
|
-
}>;
|
|
37
|
-
createManyAndReturn(args: {
|
|
38
|
-
data: any;
|
|
39
|
-
select?: any;
|
|
40
|
-
skipDuplicates?: boolean;
|
|
41
|
-
}): Promise<unknown[]>;
|
|
42
|
-
/**
|
|
43
|
-
* Preprocess the payload of `createMany` and `createManyAndReturn` and update in place if needed.
|
|
44
|
-
* @returns `true` if the operation should be converted to regular `create`s; false otherwise.
|
|
45
|
-
*/
|
|
46
|
-
private preprocessCreateManyPayload;
|
|
47
|
-
private hasRelationFieldsInPayload;
|
|
48
|
-
private validateCreateInput;
|
|
49
|
-
private doCreateMany;
|
|
50
|
-
private hasDuplicatedUniqueConstraint;
|
|
51
|
-
update(args: any): Promise<unknown>;
|
|
52
|
-
private doUpdate;
|
|
53
|
-
private calculatePostUpdateIds;
|
|
54
|
-
private overrideForeignKeyFields;
|
|
55
|
-
private validateUpdateInputSchema;
|
|
56
|
-
updateMany(args: any): Promise<any>;
|
|
57
|
-
updateManyAndReturn(args: any): Promise<unknown[]>;
|
|
58
|
-
private doUpdateMany;
|
|
59
|
-
upsert(args: any): Promise<unknown>;
|
|
60
|
-
delete(args: any): Promise<unknown>;
|
|
61
|
-
deleteMany(args: any): Promise<{
|
|
62
|
-
count: number;
|
|
63
|
-
}>;
|
|
64
|
-
aggregate(args: any): Promise<any>;
|
|
65
|
-
groupBy(args: any): Promise<any>;
|
|
66
|
-
count(args: any): Promise<any>;
|
|
67
|
-
subscribe(args: any): Promise<{
|
|
68
|
-
[Symbol.asyncIterator]: () => {
|
|
69
|
-
next: () => Promise<{
|
|
70
|
-
done: any;
|
|
71
|
-
value: any;
|
|
72
|
-
}>;
|
|
73
|
-
return: () => any;
|
|
74
|
-
throw: () => any;
|
|
75
|
-
};
|
|
76
|
-
}>;
|
|
77
|
-
stream(args: any): Promise<{
|
|
78
|
-
[Symbol.asyncIterator]: () => {
|
|
79
|
-
next: () => Promise<{
|
|
80
|
-
done: any;
|
|
81
|
-
value: any;
|
|
82
|
-
}>;
|
|
83
|
-
return: () => any;
|
|
84
|
-
throw: () => any;
|
|
85
|
-
};
|
|
86
|
-
}>;
|
|
87
|
-
private handleSubscribeStream;
|
|
88
|
-
/**
|
|
89
|
-
* Checks if the given operation is possibly allowed by the policy, without querying the database.
|
|
90
|
-
* @param operation The CRUD operation.
|
|
91
|
-
* @param fieldValues Extra field value filters to be combined with the policy constraints.
|
|
92
|
-
*/
|
|
93
|
-
check(args: PermissionCheckArgs): Promise<boolean>;
|
|
94
|
-
private get shouldLogQuery();
|
|
95
|
-
private runPostWriteChecks;
|
|
96
|
-
private requireBackLink;
|
|
97
|
-
private mergeToParent;
|
|
98
|
-
private removeFromParent;
|
|
99
|
-
private buildIdFilterWithEntityChecker;
|
|
100
|
-
}
|