@koala-ts/framework 2.11.1 → 2.13.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/dist/index.d.ts CHANGED
@@ -6,6 +6,4 @@ export * from './Routing/index.js';
6
6
  export * from './Security/index.js';
7
7
  export * from './Testing/index.js';
8
8
  export * from './serializer/index.js';
9
- export * from './validator/index.js';
10
- export * from './validator/constraints/index.js';
11
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,4 @@ export * from './Routing/index.js';
6
6
  export * from './Security/index.js';
7
7
  export * from './Testing/index.js';
8
8
  export * from './serializer/index.js';
9
- export * from './validator/index.js';
10
- export * from './validator/constraints/index.js';
11
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
@@ -1,5 +1,5 @@
1
- import { notBlank } from '../../validator/constraints/basic/not-blank.js';
2
- import { email } from '../../validator/constraints/string/email.js';
1
+ import { notBlank } from './basic/not-blank.js';
2
+ import { email } from './string/email.js';
3
3
  export declare const builtInConstraints: {
4
4
  notBlank: typeof notBlank;
5
5
  email: typeof email;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validator/constraints/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAE7D,eAAO,MAAM,kBAAkB;;;CAM9B,CAAC;AAEF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/validator/constraints/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,eAAO,MAAM,kBAAkB;;;CAM9B,CAAC;AAEF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -1,5 +1,5 @@
1
- import { notBlank } from '../../validator/constraints/basic/not-blank.js';
2
- import { email } from '../../validator/constraints/string/email.js';
1
+ import { notBlank } from './basic/not-blank.js';
2
+ import { email } from './string/email.js';
3
3
  export const builtInConstraints = {
4
4
  // Basic
5
5
  notBlank,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validator/constraints/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAE7D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ;IACR,QAAQ;IAER,SAAS;IACT,KAAK;CACN,CAAC;AAEF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validator/constraints/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ;IACR,QAAQ;IAER,SAAS;IACT,KAAK;CACN,CAAC;AAEF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Violation } from '../validator/types.js';
2
+ export declare function flattenViolations(violations: Violation[]): Record<string, string[]>;
3
+ //# sourceMappingURL=flatten-violations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten-violations.d.ts","sourceRoot":"","sources":["../../src/validator/flatten-violations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAQnF"}
@@ -0,0 +1,6 @@
1
+ export function flattenViolations(violations) {
2
+ const groupedViolations = Object.groupBy(violations, violation => violation.path);
3
+ const violationEntries = Object.entries(groupedViolations).map(([field, violations]) => [field, violations.map(v => v.message)]);
4
+ return Object.fromEntries(violationEntries);
5
+ }
6
+ //# sourceMappingURL=flatten-violations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten-violations.js","sourceRoot":"","sources":["../../src/validator/flatten-violations.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,UAAuB;IACvD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAgC,CAAC;IAEjH,MAAM,gBAAgB,GAA+C,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CACxG,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CACjE,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=flatten-violations.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten-violations.test.d.ts","sourceRoot":"","sources":["../../src/validator/flatten-violations.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { flattenViolations } from '../validator/flatten-violations.js';
2
+ import { describe, expect, test } from 'vitest';
3
+ describe('Flatten violations', () => {
4
+ test('it should flatten violations into JSON API format', () => {
5
+ const violations = [
6
+ {
7
+ path: 'username',
8
+ message: 'The username is required.',
9
+ constraint: 'notBlank',
10
+ value: undefined,
11
+ },
12
+ {
13
+ path: 'username',
14
+ message: 'The username must be unique.',
15
+ constraint: 'uniqueUsername',
16
+ value: 'existing_user',
17
+ },
18
+ ];
19
+ const actual = flattenViolations(violations);
20
+ expect(actual).toEqual({
21
+ username: ['The username is required.', 'The username must be unique.'],
22
+ });
23
+ });
24
+ });
25
+ //# sourceMappingURL=flatten-violations.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten-violations.test.js","sourceRoot":"","sources":["../../src/validator/flatten-violations.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEhD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC7D,MAAM,UAAU,GAAgB;YAC9B;gBACE,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,2BAA2B;gBACpC,UAAU,EAAE,UAAU;gBACtB,KAAK,EAAE,SAAS;aACjB;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,8BAA8B;gBACvC,UAAU,EAAE,gBAAgB;gBAC5B,KAAK,EAAE,eAAe;aACvB;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAE7C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,QAAQ,EAAE,CAAC,2BAA2B,EAAE,8BAA8B,CAAC;SACxE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './validator.js';
2
2
  export * from './types.js';
3
3
  export * from './constraints/index.js';
4
+ export * from './flatten-violations.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './validator.js';
2
2
  export * from './types.js';
3
3
  export * from './constraints/index.js';
4
+ export * from './flatten-violations.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,24 @@
1
1
  {
2
2
  "name": "@koala-ts/framework",
3
3
  "main": "dist/index.js",
4
+ "types": "dist/index.d.ts",
4
5
  "type": "module",
5
- "version": "2.11.1",
6
+ "exports": {
7
+ ".": "./dist/index.js",
8
+ "./validator": "./dist/validator/index.js",
9
+ "./validator/constraints": "./dist/validator/constraints/index.js"
10
+ },
11
+ "typesVersions": {
12
+ "*": {
13
+ "validator": [
14
+ "dist/validator/index.d.ts"
15
+ ],
16
+ "validator/constraints": [
17
+ "dist/validator/constraints/index.d.ts"
18
+ ]
19
+ }
20
+ },
21
+ "version": "2.13.0",
6
22
  "description": "A NodeJS framework for lazy developers",
7
23
  "keywords": [
8
24
  "koala",