@zenstackhq/runtime 1.0.0-alpha.85 → 1.0.0-alpha.86

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zenstackhq/runtime",
3
3
  "displayName": "ZenStack Runtime Library",
4
- "version": "1.0.0-alpha.85",
4
+ "version": "1.0.0-alpha.86",
5
5
  "description": "Runtime of ZenStack for both client-side and server-side environments.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "tslib": "^2.4.1",
25
25
  "zod": "^3.19.1",
26
26
  "zod-validation-error": "^0.2.1",
27
- "@zenstackhq/sdk": "1.0.0-alpha.85"
27
+ "@zenstackhq/sdk": "1.0.0-alpha.86"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@prisma/client": "^4.0.0"
package/validation.d.ts CHANGED
@@ -10,3 +10,10 @@ export declare class ValidationError {
10
10
  * Validate the given data with the given zod schema (for field-level constraints)
11
11
  */
12
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;
package/validation.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validate = exports.ValidationError = void 0;
3
+ exports.hasAllFields = exports.validate = exports.ValidationError = void 0;
4
4
  const zod_validation_error_1 = require("zod-validation-error");
5
5
  /**
6
6
  * Error indicating violations of field-level constraints
@@ -23,4 +23,18 @@ function validate(validator, data) {
23
23
  }
24
24
  }
25
25
  exports.validate = validate;
26
+ /**
27
+ * Check if the given object has all the given fields, not null or undefined
28
+ * @param obj
29
+ * @param fields
30
+ * @returns
31
+ */
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ function hasAllFields(obj, fields) {
34
+ if (typeof obj !== 'object' || !obj) {
35
+ return false;
36
+ }
37
+ return fields.every((f) => obj[f] !== undefined && obj[f] !== null);
38
+ }
39
+ exports.hasAllFields = hasAllFields;
26
40
  //# sourceMappingURL=validation.js.map
package/validation.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;AACA,+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;QACA,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACzB;IAAC,OAAO,GAAG,EAAE;QACV,MAAM,IAAI,eAAe,CAAC,IAAA,mCAAY,EAAC,GAAiB,CAAC,CAAC,OAAO,CAAC,CAAC;KACtE;AACL,CAAC;AAND,4BAMC"}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;AACA,+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;QACA,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;KACzB;IAAC,OAAO,GAAG,EAAE;QACV,MAAM,IAAI,eAAe,CAAC,IAAA,mCAAY,EAAC,GAAiB,CAAC,CAAC,OAAO,CAAC,CAAC;KACtE;AACL,CAAC;AAND,4BAMC;AAED;;;;;GAKG;AACH,8DAA8D;AAC9D,SAAgB,YAAY,CAAC,GAAQ,EAAE,MAAgB;IACnD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,EAAE;QACjC,OAAO,KAAK,CAAC;KAChB;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;AALD,oCAKC"}