agora-foundation 3.4.2 → 3.4.4

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.
@@ -0,0 +1,4 @@
1
+ import { ZodError, ZodType } from 'zod';
2
+ type ZodParam<T> = ZodType<T, any, T>;
3
+ declare function validateParams(handlerError: (error: ZodError<any>) => any): <Params extends any[]>(...schemas: { [K in keyof Params]: ZodParam<Params[K]>; }) => (originalMethod: (...args: Params) => any, context: ClassMethodDecoratorContext) => (this: any, ...args: Params) => any;
4
+ export { validateParams };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.validateParams = validateParams;
8
+ require("core-js/modules/es.error.cause.js");
9
+ require("core-js/modules/es.error.to-string.js");
10
+ require("core-js/modules/es.array.concat.js");
11
+ require("core-js/modules/es.array.for-each.js");
12
+ require("core-js/modules/es.function.name.js");
13
+ require("core-js/modules/es.object.to-string.js");
14
+ require("core-js/modules/esnext.async-iterator.for-each.js");
15
+ require("core-js/modules/esnext.iterator.constructor.js");
16
+ require("core-js/modules/esnext.iterator.for-each.js");
17
+ require("core-js/modules/web.dom-collections.for-each.js");
18
+ function validateParams(handlerError) {
19
+ return function () {
20
+ for (var _len = arguments.length, schemas = new Array(_len), _key = 0; _key < _len; _key++) {
21
+ schemas[_key] = arguments[_key];
22
+ }
23
+ return function (originalMethod, context) {
24
+ return function () {
25
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
26
+ args[_key2] = arguments[_key2];
27
+ }
28
+ schemas.forEach(function (schema, index) {
29
+ var result = schema.safeParse(args[index]);
30
+ if (!result.success) {
31
+ var message = "invalid params: ".concat(result.error.message, " Method:").concat(originalMethod.name);
32
+ throw handlerError && handlerError(result.error) || Error(message);
33
+ }
34
+ });
35
+ return originalMethod.apply(this, args);
36
+ };
37
+ };
38
+ };
39
+ }
@@ -0,0 +1,12 @@
1
+ import { z, ZodArray, ZodTypeAny } from 'zod';
2
+ export declare const stringSchema: z.ZodString;
3
+ export declare const booleanSchema: z.ZodBoolean;
4
+ export declare const numberSchema: z.ZodNumber;
5
+ export declare const unknownSchema: z.ZodUnknown;
6
+ export declare const objectSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
7
+ export declare const anySchema: z.ZodAny;
8
+ export declare const createUnionSchema: (schemas: readonly ZodTypeAny[]) => ZodTypeAny;
9
+ export declare function createArraySchema<ElementType extends ZodTypeAny>(elementSchema: ElementType): ZodArray<ElementType>;
10
+ export declare function createRecordSchemaWithKey<K extends z.ZodTypeAny, V extends z.ZodTypeAny>(keySchema: K, valueSchema: V): z.ZodRecord<K, V>;
11
+ export declare const fcrRenderViewSchema: z.ZodEffects<z.ZodType<HTMLElement, z.ZodTypeDef, HTMLElement>, HTMLElement, HTMLElement>;
12
+ export { z, ZodError } from 'zod';
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "ZodError", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _zod.ZodError;
11
+ }
12
+ });
13
+ exports.booleanSchema = exports.anySchema = void 0;
14
+ exports.createArraySchema = createArraySchema;
15
+ exports.createRecordSchemaWithKey = createRecordSchemaWithKey;
16
+ exports.unknownSchema = exports.stringSchema = exports.objectSchema = exports.numberSchema = exports.fcrRenderViewSchema = exports.createUnionSchema = void 0;
17
+ Object.defineProperty(exports, "z", {
18
+ enumerable: true,
19
+ get: function get() {
20
+ return _zod.z;
21
+ }
22
+ });
23
+ require("core-js/modules/es.error.cause.js");
24
+ require("core-js/modules/es.error.to-string.js");
25
+ var _zod = require("zod");
26
+ // 基础类型 Schema
27
+ var stringSchema = exports.stringSchema = _zod.z.string();
28
+ var booleanSchema = exports.booleanSchema = _zod.z["boolean"]();
29
+ var numberSchema = exports.numberSchema = _zod.z.number();
30
+ var unknownSchema = exports.unknownSchema = _zod.z.unknown();
31
+ var objectSchema = exports.objectSchema = _zod.z.object({});
32
+ var anySchema = exports.anySchema = _zod.z.any();
33
+ var createUnionSchema = exports.createUnionSchema = function createUnionSchema(schemas) {
34
+ if (schemas.length <= 1) {
35
+ throw new Error('[createUnionSchema] At least two Zod Schemas are required to be provided');
36
+ }
37
+ return _zod.z.union(schemas);
38
+ };
39
+ function createArraySchema(elementSchema) {
40
+ return _zod.z.array(elementSchema);
41
+ }
42
+ function createRecordSchemaWithKey(keySchema, valueSchema) {
43
+ return _zod.z.record(keySchema, valueSchema);
44
+ }
45
+
46
+ // 自定义校验 Schema
47
+ var fcrRenderViewSchema = exports.fcrRenderViewSchema = _zod.z.custom().refine(function (element) {
48
+ return element instanceof HTMLElement;
49
+ }, {
50
+ message: 'Element must be a valid DOM HTMLElement'
51
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-foundation",
3
- "version": "3.4.2",
3
+ "version": "3.4.4",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "agora-tc-transpile",
@@ -19,7 +19,7 @@
19
19
  "@types/jasmine": "^5.1.4",
20
20
  "@types/lodash": "^4.14.168",
21
21
  "@types/node": "^20.11.30",
22
- "agora-toolchain": "^3.4.2",
22
+ "agora-toolchain": "^3.4.4",
23
23
  "core-js": "^3.33.3",
24
24
  "tslib": "^2.6.2",
25
25
  "winston": "^3.16.0"