@inversifyjs/class-validation 2.0.2 → 3.0.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/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { ClassValidationPipe } from './pipes/ClassValidationPipe.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,2 +1,2 @@
1
- export { ClassValidationPipe } from './pipes/ClassValidationPipe';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export { ClassValidationPipe } from './pipes/ClassValidationPipe.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Pipe, PipeMetadata } from '@inversifyjs/framework-core';
1
+ import { type Pipe, type PipeMetadata } from '@inversifyjs/framework-core';
2
2
  export declare class ClassValidationPipe implements Pipe {
3
3
  execute(input: unknown, metadata: PipeMetadata): Promise<unknown>;
4
4
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassValidationPipe.d.ts","sourceRoot":"","sources":["../../src/pipes/ClassValidationPipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA4B3E,qBAAa,mBAAoB,YAAW,IAAI;IACjC,OAAO,CAClB,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,OAAO,CAAC;CAyDpB"}
@@ -0,0 +1,58 @@
1
+ import { getOwnReflectMetadata } from '@inversifyjs/reflect-metadata-utils';
2
+ import { InversifyValidationError, InversifyValidationErrorKind, } from '@inversifyjs/validation-common';
3
+ import { plainToInstance } from 'class-transformer';
4
+ import { validate } from 'class-validator';
5
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
6
+ const ALLOW_NULLISH_VALUE_TYPES_LIST = [
7
+ Object,
8
+ undefined,
9
+ ];
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
11
+ const NON_VALIDATED_TYPES_LIST = [
12
+ Array,
13
+ BigInt,
14
+ Boolean,
15
+ Buffer,
16
+ Function,
17
+ Number,
18
+ Object,
19
+ String,
20
+ Symbol,
21
+ ];
22
+ export class ClassValidationPipe {
23
+ async execute(input, metadata) {
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
25
+ const inputType = getOwnReflectMetadata(
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
27
+ metadata.targetClass.prototype, 'design:paramtypes', metadata.methodName)?.[metadata.parameterIndex];
28
+ if (input == undefined) {
29
+ if (ALLOW_NULLISH_VALUE_TYPES_LIST.includes(inputType)) {
30
+ return input;
31
+ }
32
+ throw new InversifyValidationError(InversifyValidationErrorKind.validationFailed, `Validation failed. Found nullish value but expected type "${inputType?.name ?? 'undefined'}" at ${metadata.targetClass.name}.${metadata.methodName.toString()}[${metadata.parameterIndex.toString()}].`);
33
+ }
34
+ if (inputType === undefined) {
35
+ throw new InversifyValidationError(InversifyValidationErrorKind.invalidConfiguration, `Param type metadata for ${metadata.targetClass.name}.${metadata.methodName.toString()}[${metadata.parameterIndex.toString()}] is not defined. Are you enabling "emitDecoratorMetadata" and "experimentalDecorators" Typescript compiler options?`);
36
+ }
37
+ if (NON_VALIDATED_TYPES_LIST.includes(inputType)) {
38
+ return input;
39
+ }
40
+ const instance = plainToInstance(inputType, input);
41
+ const validationResult = await validate(instance, {
42
+ forbidNonWhitelisted: true,
43
+ forbidUnknownValues: true,
44
+ skipMissingProperties: false,
45
+ skipNullProperties: false,
46
+ skipUndefinedProperties: false,
47
+ stopAtFirstError: false,
48
+ whitelist: true,
49
+ });
50
+ if (validationResult.length > 0) {
51
+ throw new InversifyValidationError(InversifyValidationErrorKind.validationFailed, validationResult
52
+ .map((error) => error.toString(false, false))
53
+ .join('\n'));
54
+ }
55
+ return instance;
56
+ }
57
+ }
58
+ //# sourceMappingURL=ClassValidationPipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassValidationPipe.js","sourceRoot":"","sources":["../../src/pipes/ClassValidationPipe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAyB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAwB,MAAM,iBAAiB,CAAC;AAEjE,sEAAsE;AACtE,MAAM,8BAA8B,GAA6B;IAC/D,MAAM;IACN,SAAS;CACV,CAAC;AAEF,sEAAsE;AACtE,MAAM,wBAAwB,GAAe;IAC3C,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACP,CAAC;AAEF,MAAM,OAAO,mBAAmB;IACvB,KAAK,CAAC,OAAO,CAClB,KAAc,EACd,QAAsB;QAEtB,sEAAsE;QACtE,MAAM,SAAS,GAAyB,qBAAqB;QAC3D,iEAAiE;QACjE,QAAQ,CAAC,WAAW,CAAC,SAAS,EAC9B,mBAAmB,EACnB,QAAQ,CAAC,UAAU,CACpB,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAE7B,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;YACvB,IAAI,8BAA8B,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBACvD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,IAAI,wBAAwB,CAChC,4BAA4B,CAAC,g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}
package/package.json CHANGED
@@ -5,28 +5,27 @@
5
5
  },
6
6
  "description": "InversifyJs class-validator validation package",
7
7
  "dependencies": {
8
- "@inversifyjs/framework-core": "1.0.1",
9
- "@inversifyjs/reflect-metadata-utils": "1.4.1",
10
- "@inversifyjs/validation-common": "2.0.2"
8
+ "@inversifyjs/reflect-metadata-utils": "1.5.0",
9
+ "@inversifyjs/validation-common": "3.0.0"
11
10
  },
12
11
  "devDependencies": {
13
- "@stryker-mutator/core": "9.4.0",
14
- "@stryker-mutator/typescript-checker": "9.4.0",
15
- "@stryker-mutator/vitest-runner": "9.4.0",
12
+ "@stryker-mutator/core": "9.6.0",
13
+ "@stryker-mutator/typescript-checker": "9.6.0",
14
+ "@stryker-mutator/vitest-runner": "9.6.0",
16
15
  "@types/express": "5.0.6",
17
- "@types/node": "24.10.9",
18
- "@vitest/coverage-v8": "4.0.18",
19
- "eslint": "9.39.2",
20
- "inversify": "^7.11.0",
16
+ "@types/node": "24.12.0",
17
+ "@vitest/coverage-v8": "4.1.0",
18
+ "eslint": "10.0.3",
19
+ "inversify": "8.0.0",
21
20
  "prettier": "3.8.1",
22
- "rimraf": "6.1.2",
23
- "rollup": "4.56.0",
24
- "ts-loader": "9.5.4",
21
+ "rimraf": "6.1.3",
25
22
  "tslib": "2.8.1",
26
23
  "typescript": "5.9.3",
27
- "vitest": "4.0.18",
28
- "@inversifyjs/http-core": "4.10.2",
29
- "@inversifyjs/http-express": "4.10.2"
24
+ "vitest": "4.1.0",
25
+ "@inversifyjs/eslint-plugin-require-extensions": "0.2.0",
26
+ "@inversifyjs/framework-core": "2.0.0",
27
+ "@inversifyjs/http-core": "5.0.0",
28
+ "@inversifyjs/http-express": "5.0.0"
30
29
  },
31
30
  "devEngines": {
32
31
  "node": "^24.10.0",
@@ -44,18 +43,13 @@
44
43
  "typescript"
45
44
  ],
46
45
  "license": "MIT",
47
- "main": "lib/cjs/index.js",
48
- "module": "lib/esm/index.js",
49
46
  "exports": {
50
- ".": {
51
- "import": "./lib/esm/index.js",
52
- "require": "./lib/cjs/index.js"
53
- }
47
+ ".": "./lib/index.js"
54
48
  },
55
49
  "name": "@inversifyjs/class-validation",
56
50
  "peerDependencies": {
57
51
  "class-transformer": "~0.5.1",
58
- "class-validator": "~0.14.3"
52
+ "class-validator": "~0.15.1"
59
53
  },
60
54
  "publishConfig": {
61
55
  "access": "public"
@@ -64,11 +58,10 @@
64
58
  "type": "git",
65
59
  "url": "git+https://github.com/inversify/monorepo.git"
66
60
  },
67
- "version": "2.0.2",
61
+ "version": "3.0.0",
62
+ "type": "module",
68
63
  "scripts": {
69
- "build": "pnpm run build:cjs && pnpm run build:esm",
70
- "build:cjs": "tsc --build tsconfig.cjs.json && pnpm exec foundation-ts-package-cjs ./lib/cjs",
71
- "build:esm": "rollup -c ./rollup.config.mjs && pnpm exec foundation-ts-package-esm ./lib/esm",
64
+ "build": "tsc",
72
65
  "build:clean": "rimraf lib",
73
66
  "format": "prettier --write ./src",
74
67
  "lint": "eslint ./src",
package/CHANGELOG.md DELETED
@@ -1,30 +0,0 @@
1
- # @inversifyjs/class-validation
2
-
3
- ## 2.0.2
4
-
5
- ### Patch Changes
6
-
7
- - Updated `ClassValidationPipe` to properly handle nullish and primitive values
8
- - Updated dependencies
9
- - @inversifyjs/validation-common@2.0.2
10
-
11
- ## 2.0.1
12
-
13
- ### Patch Changes
14
-
15
- - Updated dependencies
16
- - @inversifyjs/reflect-metadata-utils@1.4.1
17
- - @inversifyjs/framework-core@1.0.1
18
- - @inversifyjs/validation-common@2.0.1
19
-
20
- ## 2.0.0
21
-
22
- ### Minor Changes
23
-
24
- - Added `ClassValidationPipe`
25
-
26
- ### Patch Changes
27
-
28
- - Updated dependencies
29
- - @inversifyjs/framework-core@1.0.0
30
- - @inversifyjs/validation-common@2.0.0
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
package/lib/cjs/index.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClassValidationPipe = void 0;
4
- var ClassValidationPipe_1 = require("./pipes/ClassValidationPipe");
5
- Object.defineProperty(exports, "ClassValidationPipe", { enumerable: true, get: function () { return ClassValidationPipe_1.ClassValidationPipe; } });
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassValidationPipe.d.ts","sourceRoot":"","sources":["../../../src/pipes/ClassValidationPipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA4BjE,qBAAa,mBAAoB,YAAW,IAAI;IACjC,OAAO,CAClB,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,OAAO,CAAC;CAyDpB"}
@@ -1,9 +0,0 @@
1
- import { ErrorFilter, Pipe } from '@inversifyjs/framework-core';
2
- import { Container, Newable } from 'inversify';
3
- export interface Server {
4
- host: string;
5
- port: number;
6
- shutdown: () => Promise<void>;
7
- }
8
- export declare function buildExpressServer(container: Container, errorFilterList: Newable<ErrorFilter>[], pipeList: (Newable<Pipe> | Pipe)[]): Promise<Server>;
9
- //# sourceMappingURL=ClassValidationPipe.int.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassValidationPipe.int.spec.d.ts","sourceRoot":"","sources":["../../../src/pipes/ClassValidationPipe.int.spec.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,WAAW,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAW5E,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI/C,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EACvC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,GACjC,OAAO,CAAC,MAAM,CAAC,CAoDjB"}
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClassValidationPipe = void 0;
4
- const reflect_metadata_utils_1 = require("@inversifyjs/reflect-metadata-utils");
5
- const validation_common_1 = require("@inversifyjs/validation-common");
6
- const class_transformer_1 = require("class-transformer");
7
- const class_validator_1 = require("class-validator");
8
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
9
- const ALLOW_NULLISH_VALUE_TYPES_LIST = [
10
- Object,
11
- undefined,
12
- ];
13
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
14
- const NON_VALIDATED_TYPES_LIST = [
15
- Array,
16
- BigInt,
17
- Boolean,
18
- Buffer,
19
- Function,
20
- Number,
21
- Object,
22
- String,
23
- Symbol,
24
- ];
25
- class ClassValidationPipe {
26
- async execute(input, metadata) {
27
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
28
- const inputType = (0, reflect_metadata_utils_1.getOwnReflectMetadata)(
29
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
30
- metadata.targetClass.prototype, 'design:paramtypes', metadata.methodName)?.[metadata.parameterIndex];
31
- if (input == undefined) {
32
- if (ALLOW_NULLISH_VALUE_TYPES_LIST.includes(inputType)) {
33
- return input;
34
- }
35
- throw new validation_common_1.InversifyValidationError(validation_common_1.InversifyValidationErrorKind.validationFailed, `Validation failed. Found nullish value but expected type "${inputType?.name ?? 'undefined'}" at ${metadata.targetClass.name}.${metadata.methodName.toString()}[${metadata.parameterIndex.toString()}].`);
36
- }
37
- if (inputType === undefined) {
38
- throw new validation_common_1.InversifyValidationError(validation_common_1.InversifyValidationErrorKind.invalidConfiguration, `Param type metadata for ${metadata.targetClass.name}.${metadata.methodName.toString()}[${metadata.parameterIndex.toString()}] is not defined. Are you enabling "emitDecoratorMetadata" and "experimentalDecorators" Typescript compiler options?`);
39
- }
40
- if (NON_VALIDATED_TYPES_LIST.includes(inputType)) {
41
- return input;
42
- }
43
- const instance = (0, class_transformer_1.plainToInstance)(inputType, input);
44
- const validationResult = await (0, class_validator_1.validate)(instance, {
45
- forbidNonWhitelisted: true,
46
- forbidUnknownValues: true,
47
- skipMissingProperties: false,
48
- skipNullProperties: false,
49
- skipUndefinedProperties: false,
50
- stopAtFirstError: false,
51
- whitelist: true,
52
- });
53
- if (validationResult.length > 0) {
54
- throw new validation_common_1.InversifyValidationError(validation_common_1.InversifyValidationErrorKind.validationFailed, validationResult
55
- .map((error) => error.toString(false, false))
56
- .join('\n'));
57
- }
58
- return instance;
59
- }
60
- }
61
- exports.ClassValidationPipe = ClassValidationPipe;
62
- //# sourceMappingURL=ClassValidationPipe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassValidationPipe.js","sourceRoot":"","sources":["../../../src/pipes/ClassValidationPipe.ts"],"names":[],"mappings":";;;AACA,gFAA4E;AAC5E,sEAGwC;AACxC,yDAAsE;AACtE,qDAA4D;AAE5D,sEAAsE;AACtE,MAAM,8BAA8B,GAA6B;IAC/D,MAAM;IACN,SAAS;CACV,CAAC;AAEF,sEAAsE;AACtE,MAAM,wBAAwB,GAAe;IAC3C,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;CACP,CAAC;AAEF,MAAa,mBAAmB;IACvB,KAAK,CAAC,OA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KAAK;YACzB,uBAAuB,EAAE,KAAK;YAC9B,gBAAgB,EAAE,KAAK;YACvB,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,4CAAwB,CAChC,gDAA4B,CAAC,gBAAgB,EAC7C,gBAAgB;iBACb,GAAG,CAAC,CAAC,KAAsB,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;iBAC7D,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA7DD,kDA6DC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ClassValidationPipe.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClassValidationPipe.spec.d.ts","sourceRoot":"","sources":["../../../src/pipes/ClassValidationPipe.spec.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { Pipe, PipeMetadata } from '@inversifyjs/framework-core';
2
-
3
- declare class ClassValidationPipe implements Pipe {
4
- execute(input: unknown, metadata: PipeMetadata): Promise<unknown>;
5
- }
6
-
7
- export { ClassValidationPipe };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
package/lib/esm/index.js DELETED
@@ -1,2 +0,0 @@
1
- import{getOwnReflectMetadata as e}from"@inversifyjs/reflect-metadata-utils";import{InversifyValidationError as t,InversifyValidationErrorKind as i}from"@inversifyjs/validation-common";import{plainToInstance as r}from"class-transformer";import{validate as a}from"class-validator";const n=[Object,void 0],o=[Array,BigInt,Boolean,Buffer,Function,Number,Object,String,Symbol];class s{async execute(s,d){const l=e(d.targetClass.prototype,"design:paramtypes",d.methodName)?.[d.parameterIndex];if(null==s){if(n.includes(l))return s;throw new t(i.validationFailed,`Validation failed. Found nullish value but expected type "${l?.name??"undefined"}" at ${d.targetClass.name}.${d.methodName.toString()}[${d.parameterIndex.toString()}].`)}if(void 0===l)throw new t(i.invalidConfiguration,`Param type metadata for ${d.targetClass.name}.${d.methodName.toString()}[${d.parameterIndex.toString()}] is not defined. Are you enabling "emitDecoratorMetadata" and "experimentalDecorators" Typescript compiler options?`);if(o.includes(l))return s;const m=r(l,s),p=await a(m,{forbidNonWhitelisted:!0,forbidUnknownValues:!0,skipMissingProperties:!1,skipNullProperties:!1,skipUndefinedProperties:!1,stopAtFirstError:!1,whitelist:!0});if(p.length>0)throw new t(i.validationFailed,p.map(e=>e.toString(!1,!1)).join("\n"));return m}}export{s as ClassValidationPipe};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/pipes/ClassValidationPipe.ts"],"sourcesContent":[null],"names":["ALLOW_NULLISH_VALUE_TYPES_LIST","Object","undefined","NON_VALIDATED_TYPES_LIST","Array","BigInt","Boolean","Buffer","Function","Number","String","Symbol","ClassValidationPipe","execute","input","metadata","inputType","getOwnReflectMetadata","targetClass","prototype","methodName","parameterIndex","includes","InversifyValidationError","InversifyValidationErrorKind","validationFailed","name","toString","invalidConfiguration","instance","plainToInstance","validationResult","validate","forbidNonWhitelisted","forbidUnknownValues","skipMissingProperties","skipNullProperties","skipUndefinedProperties","stopAtFirstError","whitelist","length","map","error","join"],"mappings":"uRAUA,MAAMA,EAA2D,CAC/DC,YACAC,GAIIC,EAAuC,CAC3CC,MACAC,OACAC,QACAC,OACAC,SACAC,OACAR,OACAS,OACAC,cAGWC,EACJ,aAAMC,CACXC,EACAC,GAGA,MAAMC,EAAkCC,EAEtCF,EAASG,YAAYC,UACrB,oBACAJ,EAASK,cACPL,EAASM,gBAEb,GAAanB,MAATY,EAAoB,CACtB,GAAId,EAA+BsB,SAASN,GAC1C,OAAOF,EAGT,MAAM,IAAIS,EACRC,EAA6BC,iBAC7B,6DAA6DT,GAAWU,MAAQ,mBAAmBX,EAASG,YAAYQ,QAAQX,EAASK,WAAWO,cAAcZ,EAASM,eAAeM,eAE9L,CAEA,QAAkBzB,IAAdc,EACF,MAAM,IAAIO,EACRC,EAA6BI,qBAC7B,2BAA2Bb,EAASG,YAAYQ,QAAQX,EAASK,WAAWO,cAAcZ,EAASM,eAAeM,kIAItH,GAAIxB,EAAyBmB,SAASN,GACpC,OAAOF,EAGT,MAAMe,EAAmBC,EACvBd,EACAF,GAGIiB,QAA4CC,EAASH,EAAU,CACnEI,sBAAsB,EACtBC,qBAAqB,EACrBC,uBAAuB,EACvBC,oBAAoB,EACpBC,yBAAyB,EACzBC,kBAAkB,EAClBC,WAAW,IAGb,GAAIR,EAAiBS,OAAS,EAC5B,MAAM,IAAIjB,EACRC,EAA6BC,iBAC7BM,EACGU,IAAKC,GAA2BA,EAAMf,UAAS,GAAO,IACtDgB,KAAK,OAIZ,OAAOd,CACT"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }