@zenstackhq/runtime 2.15.1 → 2.16.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/cross/index.js +32 -12
- package/cross/index.js.map +1 -1
- package/cross/index.mjs +28 -8
- package/cross/index.mjs.map +1 -1
- package/enhancements/edge/delegate.js +5 -6
- package/enhancements/edge/delegate.js.map +1 -1
- package/enhancements/edge/policy/handler.js +5 -7
- package/enhancements/edge/policy/handler.js.map +1 -1
- package/enhancements/edge/policy/policy-utils.js +13 -14
- package/enhancements/edge/policy/policy-utils.js.map +1 -1
- package/enhancements/node/delegate.js +5 -6
- package/enhancements/node/delegate.js.map +1 -1
- package/enhancements/node/policy/handler.js +5 -7
- package/enhancements/node/policy/handler.js.map +1 -1
- package/enhancements/node/policy/policy-utils.js +13 -14
- package/enhancements/node/policy/policy-utils.js.map +1 -1
- package/local-helpers/index.d.ts +6 -0
- package/local-helpers/index.js +23 -0
- package/local-helpers/index.js.map +1 -0
- package/local-helpers/is-plain-object.d.ts +1 -0
- package/local-helpers/is-plain-object.js +25 -0
- package/local-helpers/is-plain-object.js.map +1 -0
- package/local-helpers/lower-case-first.d.ts +1 -0
- package/local-helpers/lower-case-first.js +7 -0
- package/local-helpers/lower-case-first.js.map +1 -0
- package/local-helpers/param-case.d.ts +1 -0
- package/local-helpers/param-case.js +20 -0
- package/local-helpers/param-case.js.map +1 -0
- package/local-helpers/sleep.d.ts +1 -0
- package/local-helpers/sleep.js +9 -0
- package/local-helpers/sleep.js.map +1 -0
- package/local-helpers/tiny-invariant.d.ts +1 -0
- package/local-helpers/tiny-invariant.js +15 -0
- package/local-helpers/tiny-invariant.js.map +1 -0
- package/local-helpers/upper-case-first.d.ts +1 -0
- package/local-helpers/upper-case-first.js +7 -0
- package/local-helpers/upper-case-first.js.map +1 -0
- package/package.json +10 -8
- package/types.d.ts +20 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./sleep"), exports);
|
|
18
|
+
__exportStar(require("./is-plain-object"), exports);
|
|
19
|
+
__exportStar(require("./lower-case-first"), exports);
|
|
20
|
+
__exportStar(require("./upper-case-first"), exports);
|
|
21
|
+
__exportStar(require("./param-case"), exports);
|
|
22
|
+
__exportStar(require("./tiny-invariant"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/local-helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,+CAA6B;AAC7B,mDAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPlainObject(o: unknown): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPlainObject = isPlainObject;
|
|
4
|
+
function isObject(o) {
|
|
5
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
6
|
+
}
|
|
7
|
+
function isPlainObject(o) {
|
|
8
|
+
if (isObject(o) === false)
|
|
9
|
+
return false;
|
|
10
|
+
// If has modified constructor
|
|
11
|
+
const ctor = o.constructor;
|
|
12
|
+
if (ctor === undefined)
|
|
13
|
+
return true;
|
|
14
|
+
// If has modified prototype
|
|
15
|
+
const prot = ctor.prototype;
|
|
16
|
+
if (isObject(prot) === false)
|
|
17
|
+
return false;
|
|
18
|
+
// If constructor does not have an Object-specific method
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
// Most likely a plain Object
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=is-plain-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-plain-object.js","sourceRoot":"","sources":["../../src/local-helpers/is-plain-object.ts"],"names":[],"mappings":";;AAIA,sCAkBC;AAtBD,SAAS,QAAQ,CAAC,CAAU;IACxB,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,CAAC;AACnE,CAAC;AAED,SAAgB,aAAa,CAAC,CAAU;IACpC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAExC,8BAA8B;IAC9B,MAAM,IAAI,GAAI,CAA8B,CAAC,WAAW,CAAC;IACzD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEpC,4BAA4B;IAC5B,MAAM,IAAI,GAAI,IAA+B,CAAC,SAAS,CAAC;IACxD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAE3C,yDAAyD;IACzD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,KAAK,KAAK,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,6BAA6B;IAC7B,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function lowerCaseFirst(input: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lower-case-first.js","sourceRoot":"","sources":["../../src/local-helpers/lower-case-first.ts"],"names":[],"mappings":";;AAAA,wCAEC;AAFD,SAAgB,cAAc,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function paramCase(input: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paramCase = paramCase;
|
|
4
|
+
const DEFAULT_SPLIT_REGEXP_1 = /([a-z0-9])([A-Z])/g;
|
|
5
|
+
const DEFAULT_SPLIT_REGEXP_2 = /([A-Z])([A-Z][a-z])/g;
|
|
6
|
+
const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
7
|
+
function paramCase(input) {
|
|
8
|
+
const result = input
|
|
9
|
+
.replace(DEFAULT_SPLIT_REGEXP_1, "$1\0$2")
|
|
10
|
+
.replace(DEFAULT_SPLIT_REGEXP_2, "$1\0$2")
|
|
11
|
+
.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
12
|
+
let start = 0;
|
|
13
|
+
let end = result.length;
|
|
14
|
+
while (result.charAt(start) === "\0")
|
|
15
|
+
start++;
|
|
16
|
+
while (result.charAt(end - 1) === "\0")
|
|
17
|
+
end--;
|
|
18
|
+
return result.slice(start, end).split("\0").map((str) => str.toLowerCase()).join("-");
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=param-case.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param-case.js","sourceRoot":"","sources":["../../src/local-helpers/param-case.ts"],"names":[],"mappings":";;AAIA,8BAaC;AAjBD,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AACpD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AACtD,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAE5C,SAAgB,SAAS,CAAC,KAAa;IACnC,MAAM,MAAM,GAAG,KAAK;SACf,OAAO,CAAC,sBAAsB,EAAE,QAAQ,CAAC;SACzC,OAAO,CAAC,sBAAsB,EAAE,QAAQ,CAAC;SACzC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAEzC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IAExB,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI;QAAE,KAAK,EAAE,CAAC;IAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI;QAAE,GAAG,EAAE,CAAC;IAE9C,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(timeout: number): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/local-helpers/sleep.ts"],"names":[],"mappings":";;AAAA,sBAIC;AAJD,SAAgB,KAAK,CAAC,OAAe;IACjC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACjC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function invariant(condition: unknown, message?: string): asserts condition;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invariant = invariant;
|
|
4
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
5
|
+
const prefix = 'Invariant failed';
|
|
6
|
+
function invariant(condition, message) {
|
|
7
|
+
if (condition) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (isProduction) {
|
|
11
|
+
throw new Error(prefix);
|
|
12
|
+
}
|
|
13
|
+
throw new Error(message ? `${prefix}: ${message}` : prefix);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=tiny-invariant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiny-invariant.js","sourceRoot":"","sources":["../../src/local-helpers/tiny-invariant.ts"],"names":[],"mappings":";;AAGA,8BAaC;AAhBD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAC3D,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAElC,SAAgB,SAAS,CACrB,SAAkB,EAClB,OAAgB;IAEhB,IAAI,SAAS,EAAE,CAAC;QACZ,OAAO;IACX,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function upperCaseFirst(input: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upper-case-first.js","sourceRoot":"","sources":["../../src/local-helpers/upper-case-first.ts"],"names":[],"mappings":";;AAAA,wCAEC;AAFD,SAAgB,cAAc,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/runtime",
|
|
3
3
|
"displayName": "ZenStack Runtime Library",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.16.0",
|
|
5
5
|
"description": "Runtime of ZenStack for both client-side and server-side environments.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"types": "./index.d.ts",
|
|
15
15
|
"default": "./index.js"
|
|
16
16
|
},
|
|
17
|
+
"./local-helpers": {
|
|
18
|
+
"types": "./local-helpers/index.d.ts",
|
|
19
|
+
"default": "./local-helpers/index.js"
|
|
20
|
+
},
|
|
17
21
|
"./edge": {
|
|
18
22
|
"types": "./edge.d.ts",
|
|
19
23
|
"default": "./edge.js"
|
|
@@ -89,27 +93,22 @@
|
|
|
89
93
|
"dependencies": {
|
|
90
94
|
"bcryptjs": "^2.4.3",
|
|
91
95
|
"buffer": "^6.0.3",
|
|
92
|
-
"change-case": "^4.1.2",
|
|
93
96
|
"decimal.js-light": "^2.5.1",
|
|
94
97
|
"deepmerge": "^4.3.1",
|
|
95
|
-
"is-plain-object": "^5.0.0",
|
|
96
98
|
"logic-solver": "^2.0.1",
|
|
97
|
-
"lower-case-first": "^2.0.2",
|
|
98
99
|
"pluralize": "^8.0.0",
|
|
99
100
|
"safe-json-stringify": "^1.2.0",
|
|
100
101
|
"semver": "^7.5.2",
|
|
101
102
|
"superjson": "^1.13.0",
|
|
102
|
-
"tiny-invariant": "^1.3.1",
|
|
103
103
|
"traverse": "^0.6.10",
|
|
104
104
|
"ts-pattern": "^4.3.0",
|
|
105
105
|
"tslib": "^2.4.1",
|
|
106
|
-
"upper-case-first": "^2.0.2",
|
|
107
106
|
"uuid": "^9.0.0",
|
|
108
107
|
"zod": "^3.22.4",
|
|
109
108
|
"zod-validation-error": "^1.5.0"
|
|
110
109
|
},
|
|
111
110
|
"peerDependencies": {
|
|
112
|
-
"@prisma/client": "5.0.0 - 6.
|
|
111
|
+
"@prisma/client": "5.0.0 - 6.10.x"
|
|
113
112
|
},
|
|
114
113
|
"author": {
|
|
115
114
|
"name": "ZenStack Team"
|
|
@@ -122,7 +121,10 @@
|
|
|
122
121
|
"@types/safe-json-stringify": "^1.1.5",
|
|
123
122
|
"@types/semver": "^7.3.13",
|
|
124
123
|
"@types/traverse": "^0.6.37",
|
|
125
|
-
"@types/uuid": "^8.3.4"
|
|
124
|
+
"@types/uuid": "^8.3.4",
|
|
125
|
+
"decimal.js-light": "^2.5.1",
|
|
126
|
+
"superjson": "^1.13.0",
|
|
127
|
+
"uuid": "^9.0.0"
|
|
126
128
|
},
|
|
127
129
|
"scripts": {
|
|
128
130
|
"clean": "rimraf dist",
|
package/types.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ export type EnhancementOptions = {
|
|
|
118
118
|
* The encryption options for using the `encrypted` enhancement.
|
|
119
119
|
*/
|
|
120
120
|
encryption?: SimpleEncryption | CustomEncryption;
|
|
121
|
+
/**
|
|
122
|
+
* Options for data validation.
|
|
123
|
+
*/
|
|
124
|
+
validation?: ValidationOptions;
|
|
121
125
|
};
|
|
122
126
|
/**
|
|
123
127
|
* Context for creating enhanced `PrismaClient`
|
|
@@ -178,3 +182,19 @@ export type CustomEncryption = {
|
|
|
178
182
|
*/
|
|
179
183
|
decrypt: (model: string, field: FieldInfo, cipher: string) => Promise<string>;
|
|
180
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Options for data validation.
|
|
187
|
+
*/
|
|
188
|
+
export type ValidationOptions = {
|
|
189
|
+
/**
|
|
190
|
+
* Whether to validate "update" operations based only on the input data. By default, ZenStack
|
|
191
|
+
* validates the entity after a update operation completes (inside a transaction), and rejects
|
|
192
|
+
* the operation if validation fails. This implies the entire entity needs to satisfy the
|
|
193
|
+
* validation rules, even for fields that are not part of the update input data.
|
|
194
|
+
*
|
|
195
|
+
* You can use this option to toggle the behavior to only validate the input data.
|
|
196
|
+
*
|
|
197
|
+
* Default is `false`.
|
|
198
|
+
*/
|
|
199
|
+
inputOnlyValidationForUpdate?: boolean;
|
|
200
|
+
};
|