@zenstackhq/runtime 2.15.1 → 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.
Files changed (215) hide show
  1. package/LICENSE +1 -1
  2. package/dist/client.cjs +6094 -0
  3. package/dist/client.cjs.map +1 -0
  4. package/dist/client.d.cts +19 -0
  5. package/dist/client.d.ts +19 -0
  6. package/dist/client.js +6060 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/contract-DguafRNB.d.cts +1272 -0
  9. package/dist/contract-DguafRNB.d.ts +1272 -0
  10. package/dist/index.cjs +6088 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +14 -0
  13. package/dist/index.d.ts +14 -0
  14. package/dist/index.js +6057 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/plugins/policy.cjs +2343 -0
  17. package/dist/plugins/policy.cjs.map +1 -0
  18. package/dist/plugins/policy.d.cts +24 -0
  19. package/dist/plugins/policy.d.ts +24 -0
  20. package/dist/plugins/policy.js +2307 -0
  21. package/dist/plugins/policy.js.map +1 -0
  22. package/dist/schema.cjs +110 -0
  23. package/dist/schema.cjs.map +1 -0
  24. package/dist/schema.d.cts +29 -0
  25. package/dist/schema.d.ts +29 -0
  26. package/dist/schema.js +85 -0
  27. package/dist/schema.js.map +1 -0
  28. package/dist/utils/pg-utils.cjs +39 -0
  29. package/dist/utils/pg-utils.cjs.map +1 -0
  30. package/dist/utils/pg-utils.d.cts +8 -0
  31. package/dist/utils/pg-utils.d.ts +8 -0
  32. package/dist/utils/pg-utils.js +16 -0
  33. package/dist/utils/pg-utils.js.map +1 -0
  34. package/{browser/index.js → dist/utils/sqlite-utils.cjs} +21 -37
  35. package/dist/utils/sqlite-utils.cjs.map +1 -0
  36. package/dist/utils/sqlite-utils.d.cts +8 -0
  37. package/dist/utils/sqlite-utils.d.ts +8 -0
  38. package/dist/utils/sqlite-utils.js +22 -0
  39. package/dist/utils/sqlite-utils.js.map +1 -0
  40. package/package.json +105 -114
  41. package/README.md +0 -5
  42. package/browser/index.d.mts +0 -13
  43. package/browser/index.d.ts +0 -13
  44. package/browser/index.js.map +0 -1
  45. package/browser/index.mjs +0 -33
  46. package/browser/index.mjs.map +0 -1
  47. package/constants.d.ts +0 -62
  48. package/constants.js +0 -76
  49. package/constants.js.map +0 -1
  50. package/cross/index.d.mts +0 -379
  51. package/cross/index.d.ts +0 -379
  52. package/cross/index.js +0 -903
  53. package/cross/index.js.map +0 -1
  54. package/cross/index.mjs +0 -861
  55. package/cross/index.mjs.map +0 -1
  56. package/edge.d.ts +0 -1
  57. package/edge.js +0 -18
  58. package/edge.js.map +0 -1
  59. package/encryption/index.d.ts +0 -25
  60. package/encryption/index.js +0 -74
  61. package/encryption/index.js.map +0 -1
  62. package/encryption/utils.d.ts +0 -9
  63. package/encryption/utils.js +0 -99
  64. package/encryption/utils.js.map +0 -1
  65. package/enhance-edge.d.ts +0 -1
  66. package/enhance-edge.js +0 -10
  67. package/enhance.d.ts +0 -1
  68. package/enhance.js +0 -10
  69. package/enhancements/edge/create-enhancement.d.ts +0 -42
  70. package/enhancements/edge/create-enhancement.js +0 -102
  71. package/enhancements/edge/create-enhancement.js.map +0 -1
  72. package/enhancements/edge/default-auth.d.ts +0 -8
  73. package/enhancements/edge/default-auth.js +0 -180
  74. package/enhancements/edge/default-auth.js.map +0 -1
  75. package/enhancements/edge/delegate.d.ts +0 -77
  76. package/enhancements/edge/delegate.js +0 -1294
  77. package/enhancements/edge/delegate.js.map +0 -1
  78. package/enhancements/edge/encryption.d.ts +0 -7
  79. package/enhancements/edge/encryption.js +0 -150
  80. package/enhancements/edge/encryption.js.map +0 -1
  81. package/enhancements/edge/index.d.ts +0 -4
  82. package/enhancements/edge/index.js +0 -21
  83. package/enhancements/edge/index.js.map +0 -1
  84. package/enhancements/edge/json-processor.d.ts +0 -7
  85. package/enhancements/edge/json-processor.js +0 -89
  86. package/enhancements/edge/json-processor.js.map +0 -1
  87. package/enhancements/edge/logger.d.ts +0 -29
  88. package/enhancements/edge/logger.js +0 -65
  89. package/enhancements/edge/logger.js.map +0 -1
  90. package/enhancements/edge/omit.d.ts +0 -7
  91. package/enhancements/edge/omit.js +0 -96
  92. package/enhancements/edge/omit.js.map +0 -1
  93. package/enhancements/edge/password.d.ts +0 -7
  94. package/enhancements/edge/password.js +0 -64
  95. package/enhancements/edge/password.js.map +0 -1
  96. package/enhancements/edge/policy/check-utils.d.ts +0 -5
  97. package/enhancements/edge/policy/check-utils.js +0 -20
  98. package/enhancements/edge/policy/check-utils.js.map +0 -1
  99. package/enhancements/edge/policy/handler.d.ts +0 -100
  100. package/enhancements/edge/policy/handler.js +0 -1442
  101. package/enhancements/edge/policy/handler.js.map +0 -1
  102. package/enhancements/edge/policy/index.d.ts +0 -19
  103. package/enhancements/edge/policy/index.js +0 -65
  104. package/enhancements/edge/policy/index.js.map +0 -1
  105. package/enhancements/edge/policy/policy-utils.d.ts +0 -181
  106. package/enhancements/edge/policy/policy-utils.js +0 -1357
  107. package/enhancements/edge/policy/policy-utils.js.map +0 -1
  108. package/enhancements/edge/promise.d.ts +0 -15
  109. package/enhancements/edge/promise.js +0 -99
  110. package/enhancements/edge/promise.js.map +0 -1
  111. package/enhancements/edge/proxy.d.ts +0 -120
  112. package/enhancements/edge/proxy.js +0 -287
  113. package/enhancements/edge/proxy.js.map +0 -1
  114. package/enhancements/edge/query-utils.d.ts +0 -53
  115. package/enhancements/edge/query-utils.js +0 -256
  116. package/enhancements/edge/query-utils.js.map +0 -1
  117. package/enhancements/edge/types.d.ts +0 -238
  118. package/enhancements/edge/types.js +0 -3
  119. package/enhancements/edge/types.js.map +0 -1
  120. package/enhancements/edge/utils.d.ts +0 -11
  121. package/enhancements/edge/utils.js +0 -49
  122. package/enhancements/edge/utils.js.map +0 -1
  123. package/enhancements/edge/where-visitor.d.ts +0 -32
  124. package/enhancements/edge/where-visitor.js +0 -86
  125. package/enhancements/edge/where-visitor.js.map +0 -1
  126. package/enhancements/node/create-enhancement.d.ts +0 -42
  127. package/enhancements/node/create-enhancement.js +0 -102
  128. package/enhancements/node/create-enhancement.js.map +0 -1
  129. package/enhancements/node/default-auth.d.ts +0 -8
  130. package/enhancements/node/default-auth.js +0 -180
  131. package/enhancements/node/default-auth.js.map +0 -1
  132. package/enhancements/node/delegate.d.ts +0 -77
  133. package/enhancements/node/delegate.js +0 -1294
  134. package/enhancements/node/delegate.js.map +0 -1
  135. package/enhancements/node/encryption.d.ts +0 -7
  136. package/enhancements/node/encryption.js +0 -150
  137. package/enhancements/node/encryption.js.map +0 -1
  138. package/enhancements/node/index.d.ts +0 -4
  139. package/enhancements/node/index.js +0 -21
  140. package/enhancements/node/index.js.map +0 -1
  141. package/enhancements/node/json-processor.d.ts +0 -7
  142. package/enhancements/node/json-processor.js +0 -89
  143. package/enhancements/node/json-processor.js.map +0 -1
  144. package/enhancements/node/logger.d.ts +0 -29
  145. package/enhancements/node/logger.js +0 -65
  146. package/enhancements/node/logger.js.map +0 -1
  147. package/enhancements/node/omit.d.ts +0 -7
  148. package/enhancements/node/omit.js +0 -96
  149. package/enhancements/node/omit.js.map +0 -1
  150. package/enhancements/node/password.d.ts +0 -7
  151. package/enhancements/node/password.js +0 -64
  152. package/enhancements/node/password.js.map +0 -1
  153. package/enhancements/node/policy/check-utils.d.ts +0 -5
  154. package/enhancements/node/policy/check-utils.js +0 -87
  155. package/enhancements/node/policy/check-utils.js.map +0 -1
  156. package/enhancements/node/policy/constraint-solver.d.ts +0 -27
  157. package/enhancements/node/policy/constraint-solver.js +0 -164
  158. package/enhancements/node/policy/constraint-solver.js.map +0 -1
  159. package/enhancements/node/policy/handler.d.ts +0 -100
  160. package/enhancements/node/policy/handler.js +0 -1442
  161. package/enhancements/node/policy/handler.js.map +0 -1
  162. package/enhancements/node/policy/index.d.ts +0 -19
  163. package/enhancements/node/policy/index.js +0 -65
  164. package/enhancements/node/policy/index.js.map +0 -1
  165. package/enhancements/node/policy/policy-utils.d.ts +0 -181
  166. package/enhancements/node/policy/policy-utils.js +0 -1357
  167. package/enhancements/node/policy/policy-utils.js.map +0 -1
  168. package/enhancements/node/promise.d.ts +0 -15
  169. package/enhancements/node/promise.js +0 -99
  170. package/enhancements/node/promise.js.map +0 -1
  171. package/enhancements/node/proxy.d.ts +0 -120
  172. package/enhancements/node/proxy.js +0 -287
  173. package/enhancements/node/proxy.js.map +0 -1
  174. package/enhancements/node/query-utils.d.ts +0 -53
  175. package/enhancements/node/query-utils.js +0 -256
  176. package/enhancements/node/query-utils.js.map +0 -1
  177. package/enhancements/node/types.d.ts +0 -238
  178. package/enhancements/node/types.js +0 -3
  179. package/enhancements/node/types.js.map +0 -1
  180. package/enhancements/node/utils.d.ts +0 -11
  181. package/enhancements/node/utils.js +0 -49
  182. package/enhancements/node/utils.js.map +0 -1
  183. package/enhancements/node/where-visitor.d.ts +0 -32
  184. package/enhancements/node/where-visitor.js +0 -86
  185. package/enhancements/node/where-visitor.js.map +0 -1
  186. package/error.d.ts +0 -11
  187. package/error.js +0 -22
  188. package/error.js.map +0 -1
  189. package/index.d.ts +0 -7
  190. package/index.js +0 -24
  191. package/index.js.map +0 -1
  192. package/model-meta.d.ts +0 -1
  193. package/model-meta.js +0 -10
  194. package/models.d.ts +0 -1
  195. package/models.js +0 -1
  196. package/types.d.ts +0 -180
  197. package/types.js +0 -4
  198. package/types.js.map +0 -1
  199. package/validation.d.ts +0 -24
  200. package/validation.js +0 -52
  201. package/validation.js.map +0 -1
  202. package/version.d.ts +0 -5
  203. package/version.js +0 -35
  204. package/version.js.map +0 -1
  205. package/zod/index.d.ts +0 -3
  206. package/zod/index.js +0 -5
  207. package/zod/input.d.ts +0 -1
  208. package/zod/input.js +0 -8
  209. package/zod/models.d.ts +0 -1
  210. package/zod/models.js +0 -8
  211. package/zod/objects.d.ts +0 -1
  212. package/zod/objects.js +0 -8
  213. package/zod-utils.d.ts +0 -12
  214. package/zod-utils.js +0 -97
  215. package/zod-utils.js.map +0 -1
@@ -1,86 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
3
- /* eslint-disable @typescript-eslint/no-explicit-any */
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.WhereVisitor = void 0;
15
- const cross_1 = require("../../cross");
16
- const FILTER_OPERATORS = [
17
- 'equals',
18
- 'not',
19
- 'in',
20
- 'notIn',
21
- 'lt',
22
- 'lte',
23
- 'gt',
24
- 'gte',
25
- 'contains',
26
- 'search',
27
- 'startsWith',
28
- 'endsWith',
29
- ];
30
- const RELATION_FILTER_OPERATORS = ['is', 'isNot', 'some', 'every', 'none'];
31
- /**
32
- * Recursive visitor for where payload
33
- */
34
- class WhereVisitor {
35
- constructor(modelMeta, callback) {
36
- this.modelMeta = modelMeta;
37
- this.callback = callback;
38
- }
39
- /**
40
- * Start visiting
41
- */
42
- visit(model, where) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- var _a, _b, _c, _d;
45
- if (!where) {
46
- return;
47
- }
48
- for (const [k, v] of Object.entries(where)) {
49
- if (['AND', 'OR', 'NOT'].includes(k)) {
50
- for (const item of (0, cross_1.enumerate)(v)) {
51
- yield this.visit(model, item);
52
- }
53
- continue;
54
- }
55
- if (RELATION_FILTER_OPERATORS.includes(k)) {
56
- // visit into filter body
57
- yield this.visit(model, v);
58
- continue;
59
- }
60
- const field = (0, cross_1.resolveField)(this.modelMeta, model, k);
61
- if (!field) {
62
- continue;
63
- }
64
- if (typeof v === 'object') {
65
- const filterOp = Object.keys(v).find((f) => FILTER_OPERATORS.includes(f));
66
- if (filterOp) {
67
- // reach into filter value
68
- const newValue = yield ((_b = (_a = this.callback).field) === null || _b === void 0 ? void 0 : _b.call(_a, field, v[filterOp]));
69
- v[filterOp] = newValue;
70
- continue;
71
- }
72
- if (Object.keys(v).some((f) => RELATION_FILTER_OPERATORS.includes(f))) {
73
- // filter payload
74
- yield this.visit(field.type, v);
75
- continue;
76
- }
77
- }
78
- // scalar field
79
- const newValue = yield ((_d = (_c = this.callback).field) === null || _d === void 0 ? void 0 : _d.call(_c, field, v));
80
- where[k] = newValue;
81
- }
82
- });
83
- }
84
- }
85
- exports.WhereVisitor = WhereVisitor;
86
- //# sourceMappingURL=where-visitor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"where-visitor.js","sourceRoot":"","sources":["../../../src/enhancements/node/where-visitor.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,uDAAuD;;;;;;;;;;;;AAEvD,uCAAsF;AAwBtF,MAAM,gBAAgB,GAAG;IACrB,QAAQ;IACR,KAAK;IACL,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,UAAU;CACb,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAa,YAAY;IACrB,YAA6B,SAAoB,EAAmB,QAA8B;QAArE,cAAS,GAAT,SAAS,CAAW;QAAmB,aAAQ,GAAR,QAAQ,CAAsB;IAAG,CAAC;IAEtG;;OAEG;IACG,KAAK,CAAC,KAAa,EAAE,KAAU;;;YACjC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,OAAO;YACX,CAAC;YAED,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAM,KAAK,CAAC,EAAE,CAAC;gBAC9C,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;oBACnC,KAAK,MAAM,IAAI,IAAI,IAAA,iBAAS,EAAC,CAAC,CAAC,EAAE,CAAC;wBAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,CAAC;oBACD,SAAS;gBACb,CAAC;gBAED,IAAI,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;oBACxC,yBAAyB;oBACzB,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;oBAC3B,SAAS;gBACb,CAAC;gBAED,MAAM,KAAK,GAAG,IAAA,oBAAY,EAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;gBACrD,IAAI,CAAC,KAAK,EAAE,CAAC;oBACT,SAAS;gBACb,CAAC;gBAED,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;oBACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC1E,IAAI,QAAQ,EAAE,CAAC;wBACX,0BAA0B;wBAC1B,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,KAAK,mDAAG,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA,CAAC;wBACjE,CAAC,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;wBACvB,SAAS;oBACb,CAAC;oBAED,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wBACpE,iBAAiB;wBACjB,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;wBAChC,SAAS;oBACb,CAAC;gBACL,CAAC;gBAED,eAAe;gBACf,MAAM,QAAQ,GAAG,MAAM,CAAA,MAAA,MAAA,IAAI,CAAC,QAAQ,EAAC,KAAK,mDAAG,KAAK,EAAE,CAAC,CAAC,CAAA,CAAC;gBACvD,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;YACxB,CAAC;QACL,CAAC;KAAA;CACJ;AAnDD,oCAmDC"}
package/error.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export declare function isPrismaClientKnownRequestError(err: any): err is {
2
- code: string;
3
- message: string;
4
- meta?: Record<string, unknown>;
5
- };
6
- export declare function isPrismaClientUnknownRequestError(err: any): err is {
7
- message: string;
8
- };
9
- export declare function isPrismaClientValidationError(err: any): err is {
10
- message: string;
11
- };
package/error.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPrismaClientKnownRequestError = isPrismaClientKnownRequestError;
4
- exports.isPrismaClientUnknownRequestError = isPrismaClientUnknownRequestError;
5
- exports.isPrismaClientValidationError = isPrismaClientValidationError;
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- function isPrismaClientKnownRequestError(err) {
8
- return findConstructorName(err.__proto__, 'PrismaClientKnownRequestError');
9
- }
10
- function isPrismaClientUnknownRequestError(err) {
11
- return findConstructorName(err.__proto__, 'PrismaClientUnknownRequestError');
12
- }
13
- function isPrismaClientValidationError(err) {
14
- return findConstructorName(err.__proto__, 'PrismaClientValidationError');
15
- }
16
- function findConstructorName(proto, name) {
17
- if (!proto) {
18
- return false;
19
- }
20
- return proto.constructor.name === name || findConstructorName(proto.__proto__, name);
21
- }
22
- //# sourceMappingURL=error.js.map
package/error.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;AACA,0EAIC;AAED,8EAEC;AAED,sEAEC;AAbD,uDAAuD;AACvD,SAAgB,+BAA+B,CAC3C,GAAQ;IAER,OAAO,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC;AAC/E,CAAC;AAED,SAAgB,iCAAiC,CAAC,GAAQ;IACtD,OAAO,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAC;AACjF,CAAC;AAED,SAAgB,6BAA6B,CAAC,GAAQ;IAClD,OAAO,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAU,EAAE,IAAY;IACjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,IAAI,IAAI,mBAAmB,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACzF,CAAC"}
package/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from './constants';
2
- export * from './cross';
3
- export * from './enhance';
4
- export * from './error';
5
- export * from './types';
6
- export * from './validation';
7
- export * from './version';
package/index.js DELETED
@@ -1,24 +0,0 @@
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("./constants"), exports);
18
- __exportStar(require("./cross"), exports);
19
- __exportStar(require("./enhance"), exports);
20
- __exportStar(require("./error"), exports);
21
- __exportStar(require("./types"), exports);
22
- __exportStar(require("./validation"), exports);
23
- __exportStar(require("./version"), exports);
24
- //# sourceMappingURL=index.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0CAAwB;AACxB,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,+CAA6B;AAC7B,4CAA0B"}
package/model-meta.d.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from '.zenstack/model-meta';
package/model-meta.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
-
4
- try {
5
- exports.default = require('.zenstack/model-meta').default;
6
- } catch {
7
- exports.default = function () {
8
- throw new Error('Generated model meta not found. Please run `zenstack generate` first.');
9
- };
10
- }
package/models.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '.zenstack/models';
package/models.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('.zenstack/models');
package/types.d.ts DELETED
@@ -1,180 +0,0 @@
1
- import type { z } from 'zod';
2
- import { FieldInfo } from './cross';
3
- export type PrismaPromise<T> = Promise<T> & Record<string, (args?: any) => PrismaPromise<any>>;
4
- /**
5
- * Weakly-typed database access methods
6
- */
7
- export interface DbOperations {
8
- findMany(args?: unknown): Promise<any[]>;
9
- findFirst(args?: unknown): PrismaPromise<any>;
10
- findFirstOrThrow(args?: unknown): PrismaPromise<any>;
11
- findUnique(args: unknown): PrismaPromise<any>;
12
- findUniqueOrThrow(args: unknown): PrismaPromise<any>;
13
- create(args: unknown): Promise<any>;
14
- createMany(args: unknown): Promise<{
15
- count: number;
16
- }>;
17
- createManyAndReturn(args: unknown): Promise<unknown[]>;
18
- update(args: unknown): Promise<any>;
19
- updateMany(args: unknown): Promise<{
20
- count: number;
21
- }>;
22
- updateManyAndReturn(args: unknown): Promise<unknown[]>;
23
- upsert(args: unknown): Promise<any>;
24
- delete(args: unknown): Promise<any>;
25
- deleteMany(args?: unknown): Promise<{
26
- count: number;
27
- }>;
28
- aggregate(args: unknown): Promise<any>;
29
- groupBy(args: unknown): Promise<any>;
30
- count(args?: unknown): Promise<any>;
31
- subscribe(args?: unknown): Promise<any>;
32
- stream(args?: unknown): Promise<any>;
33
- check(args: unknown): Promise<boolean>;
34
- fields: Record<string, any>;
35
- }
36
- /**
37
- * Kinds of access policy
38
- */
39
- export type PolicyKind = 'allow' | 'deny';
40
- export type PolicyCrudKind = 'read' | 'create' | 'update' | 'delete';
41
- /**
42
- * Kinds of operations controlled by access policies
43
- */
44
- export type PolicyOperationKind = PolicyCrudKind | 'postUpdate';
45
- /**
46
- * Current login user info
47
- */
48
- export type AuthUser = Record<string, unknown>;
49
- /**
50
- * Context for database query
51
- */
52
- export type QueryContext = {
53
- /**
54
- * Current login user (provided by @see RequestHandlerOptions)
55
- */
56
- user?: AuthUser;
57
- /**
58
- * Pre-update value of the entity
59
- */
60
- preValue?: any;
61
- };
62
- /**
63
- * Context for checking operation allowability.
64
- */
65
- export type PermissionCheckerContext = {
66
- /**
67
- * Current user
68
- */
69
- user?: AuthUser;
70
- /**
71
- * Extra field value filters.
72
- */
73
- fieldValues?: Record<string, string | number | boolean>;
74
- };
75
- /**
76
- * Prisma contract for CRUD operations.
77
- */
78
- export type CrudContract = Record<string, DbOperations>;
79
- /**
80
- * Prisma contract for database client.
81
- */
82
- export type DbClientContract = CrudContract & {
83
- $transaction: <T>(action: (tx: CrudContract) => Promise<T>, options?: unknown) => Promise<T>;
84
- };
85
- /**
86
- * Transaction isolation levels: https://www.prisma.io/docs/orm/prisma-client/queries/transactions#transaction-isolation-level
87
- */
88
- export type TransactionIsolationLevel = 'ReadUncommitted' | 'ReadCommitted' | 'RepeatableRead' | 'Snapshot' | 'Serializable';
89
- /**
90
- * Options for enhancing a PrismaClient.
91
- */
92
- export type EnhancementOptions = {
93
- /**
94
- * The kinds of enhancements to apply. By default all enhancements are applied.
95
- */
96
- kinds?: EnhancementKind[];
97
- /**
98
- * Whether to log Prisma query
99
- */
100
- logPrismaQuery?: boolean;
101
- /**
102
- * Hook for transforming errors before they are thrown to the caller.
103
- */
104
- errorTransformer?: ErrorTransformer;
105
- /**
106
- * The `maxWait` option passed to `prisma.$transaction()` call for transactions initiated by ZenStack.
107
- */
108
- transactionMaxWait?: number;
109
- /**
110
- * The `timeout` option passed to `prisma.$transaction()` call for transactions initiated by ZenStack.
111
- */
112
- transactionTimeout?: number;
113
- /**
114
- * The `isolationLevel` option passed to `prisma.$transaction()` call for transactions initiated by ZenStack.
115
- */
116
- transactionIsolationLevel?: TransactionIsolationLevel;
117
- /**
118
- * The encryption options for using the `encrypted` enhancement.
119
- */
120
- encryption?: SimpleEncryption | CustomEncryption;
121
- };
122
- /**
123
- * Context for creating enhanced `PrismaClient`
124
- */
125
- export type EnhancementContext<User extends AuthUser = AuthUser> = {
126
- user?: User;
127
- };
128
- /**
129
- * Kinds of enhancements to `PrismaClient`
130
- */
131
- export type EnhancementKind = 'password' | 'omit' | 'policy' | 'validation' | 'delegate' | 'encryption';
132
- /**
133
- * Function for transforming errors.
134
- */
135
- export type ErrorTransformer = (error: unknown) => unknown;
136
- /**
137
- * Zod schemas for validation
138
- */
139
- export type ZodSchemas = {
140
- /**
141
- * Zod schema for each model
142
- */
143
- models: Record<string, z.ZodSchema>;
144
- /**
145
- * Zod schema for Prisma input types for each model
146
- */
147
- input?: Record<string, Record<string, z.ZodSchema>>;
148
- };
149
- /**
150
- * Simple encryption settings for processing fields marked with `@encrypted`.
151
- */
152
- export type SimpleEncryption = {
153
- /**
154
- * The encryption key.
155
- */
156
- encryptionKey: Uint8Array;
157
- /**
158
- * Optional list of all decryption keys that were previously used to encrypt the data
159
- * , for supporting key rotation. The `encryptionKey` field value is automatically
160
- * included for decryption.
161
- *
162
- * When the encrypted data is persisted, a metadata object containing the digest of the
163
- * encryption key is stored alongside the data. This digest is used to quickly determine
164
- * the correct decryption key to use when reading the data.
165
- */
166
- decryptionKeys?: Uint8Array[];
167
- };
168
- /**
169
- * Custom encryption settings for processing fields marked with `@encrypted`.
170
- */
171
- export type CustomEncryption = {
172
- /**
173
- * Encryption function.
174
- */
175
- encrypt: (model: string, field: FieldInfo, plain: string) => Promise<string>;
176
- /**
177
- * Decryption function
178
- */
179
- decrypt: (model: string, field: FieldInfo, cipher: string) => Promise<string>;
180
- };
package/types.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- //# sourceMappingURL=types.js.map
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
package/validation.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Error indicating violations of field-level constraints
4
- */
5
- export declare class ValidationError {
6
- readonly message: string;
7
- constructor(message: string);
8
- }
9
- /**
10
- * Validate the given data with the given zod schema (for field-level constraints)
11
- */
12
- export declare function validate(validator: z.ZodType, data: unknown): void;
13
- /**
14
- * Check if the given object has all the given fields, not null or undefined
15
- * @param obj
16
- * @param fields
17
- * @returns
18
- */
19
- export declare function hasAllFields(obj: any, fields: string[]): boolean;
20
- /**
21
- * Check if the given objects have equal values for the given fields. Returns
22
- * false if either object is nullish or is not an object.
23
- */
24
- export declare function allFieldsEqual(obj1: any, obj2: any, fields: string[]): boolean;
package/validation.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationError = void 0;
4
- exports.validate = validate;
5
- exports.hasAllFields = hasAllFields;
6
- exports.allFieldsEqual = allFieldsEqual;
7
- const zod_validation_error_1 = require("zod-validation-error");
8
- /**
9
- * Error indicating violations of field-level constraints
10
- */
11
- class ValidationError {
12
- constructor(message) {
13
- this.message = message;
14
- }
15
- }
16
- exports.ValidationError = ValidationError;
17
- /**
18
- * Validate the given data with the given zod schema (for field-level constraints)
19
- */
20
- function validate(validator, data) {
21
- try {
22
- validator.parse(data);
23
- }
24
- catch (err) {
25
- throw new ValidationError((0, zod_validation_error_1.fromZodError)(err).message);
26
- }
27
- }
28
- /**
29
- * Check if the given object has all the given fields, not null or undefined
30
- * @param obj
31
- * @param fields
32
- * @returns
33
- */
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- function hasAllFields(obj, fields) {
36
- if (typeof obj !== 'object' || !obj) {
37
- return false;
38
- }
39
- return fields.every((f) => obj[f] !== undefined && obj[f] !== null);
40
- }
41
- /**
42
- * Check if the given objects have equal values for the given fields. Returns
43
- * false if either object is nullish or is not an object.
44
- */
45
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
- function allFieldsEqual(obj1, obj2, fields) {
47
- if (!obj1 || !obj2 || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
48
- return false;
49
- }
50
- return fields.every((f) => obj1[f] === obj2[f]);
51
- }
52
- //# sourceMappingURL=validation.js.map
package/validation.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;AAaA,4BAMC;AASD,oCAKC;AAOD,wCAKC;AA5CD,+DAAoD;AAEpD;;GAEG;AACH,MAAa,eAAe;IACxB,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;CAClD;AAFD,0CAEC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,SAAoB,EAAE,IAAa;IACxD,IAAI,CAAC;QACD,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,IAAI,eAAe,CAAC,IAAA,mCAAY,EAAC,GAAiB,CAAC,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,8DAA8D;AAC9D,SAAgB,YAAY,CAAC,GAAQ,EAAE,MAAgB;IACnD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACxE,CAAC;AAED;;;GAGG;AACH,8DAA8D;AAC9D,SAAgB,cAAc,CAAC,IAAS,EAAE,IAAS,EAAE,MAAgB;IACjE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC"}
package/version.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Gets this package's version.
3
- * @returns
4
- */
5
- export declare function getVersion(): string;
package/version.js DELETED
@@ -1,35 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getVersion = getVersion;
27
- const pkgJson = __importStar(require("./package.json"));
28
- /**
29
- * Gets this package's version.
30
- * @returns
31
- */
32
- function getVersion() {
33
- return pkgJson.version;
34
- }
35
- //# sourceMappingURL=version.js.map
package/version.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,gCAEC;AARD,wDAA0C;AAE1C;;;GAGG;AACH,SAAgB,UAAU;IACtB,OAAO,OAAO,CAAC,OAAO,CAAC;AAC3B,CAAC"}
package/zod/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * as models from './models';
2
- export * as input from './input';
3
- export * as objects from './objects';
package/zod/index.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- models: require('./models'),
3
- input: require('./input'),
4
- objects: require('./objects')
5
- };
package/zod/input.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '.zenstack/zod/input';
package/zod/input.js DELETED
@@ -1,8 +0,0 @@
1
- let schemas;
2
- try {
3
- schemas = require('.zenstack/zod/input');
4
- } catch {}
5
-
6
- module.exports = schemas && {
7
- ...schemas,
8
- };
package/zod/models.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '.zenstack/zod/models';
package/zod/models.js DELETED
@@ -1,8 +0,0 @@
1
- let schemas;
2
- try {
3
- schemas = require('.zenstack/zod/models');
4
- } catch {}
5
-
6
- module.exports = schemas && {
7
- ...schemas,
8
- };
package/zod/objects.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '.zenstack/zod/objects';
package/zod/objects.js DELETED
@@ -1,8 +0,0 @@
1
- let schemas;
2
- try {
3
- schemas = require('.zenstack/zod/objects');
4
- } catch {}
5
-
6
- module.exports = schemas && {
7
- ...schemas,
8
- };
package/zod-utils.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * A smarter version of `z.union` that decide which candidate to use based on how few unrecognized keys it has.
3
- *
4
- * The helper is used to deal with ambiguity in union generated for Prisma inputs when the zod schemas are configured
5
- * to run in "strip" object parsing mode. Since "strip" automatically drops unrecognized keys, it may result in
6
- * accidentally matching a less-ideal schema candidate.
7
- *
8
- * The helper uses a custom schema to find the candidate that results in the fewest unrecognized keys when parsing the data.
9
- *
10
- * The function uses `any` for parameter and return type to be compatible with various zod versions.
11
- */
12
- export declare function smartUnion(z: any, candidates: any[]): any;