@thisisagile/easy 17.11.24 → 17.11.26
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/README.md +1 -1
- package/dist/{chunk-P3IR2KG5.mjs → chunk-GPSPH4NX.mjs} +2 -2
- package/dist/chunk-GPSPH4NX.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/Req.d.ts +1 -1
- package/dist/services/MappedRouteGateway.mjs +1 -1
- package/dist/sql/Table.mjs +1 -1
- package/dist/utils/Mapper.mjs +1 -1
- package/package.json +1 -1
- package/src/utils/Mapper.ts +1 -1
- package/dist/chunk-P3IR2KG5.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<a href="https://www.npmjs.com/package/@thisisagile/easy" target="_blank"><img src="https://img.shields.io/npm/v/@thisisagile/easy.svg" alt="npm version" /></a>
|
|
5
5
|
<a href="https://www.npmjs.com/package/@thisisagile/easy" target="_blank"><img src="https://img.shields.io/npm/dm/@thisisagile/easy.svg" alt="npm downloads" /></a>
|
|
6
|
-
<a href="https://github.com/thisisagile/easy/actions?query=
|
|
6
|
+
<a href="https://github.com/thisisagile/easy/actions/workflows/main.yml?query=branch%3Amain"><img src="https://github.com/thisisagile/easy/actions/workflows/main.yml/badge.svg" alt="pipeline status" /></a>
|
|
7
7
|
<a href="https://sonarcloud.io/dashboard?id=thisisagile_easy" target="_blank"><img src="https://sonarcloud.io/api/project_badges/measure?project=thisisagile_easy&metric=alert_status" alt="quality gate" /></a>
|
|
8
8
|
<a href="https://github.com/semantic-release/semantic-release" target="_blank"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /></a>
|
|
9
9
|
<a href="https://sonarcloud.io/dashboard?id=thisisagile_easy" target="_blank"><img src="https://sonarcloud.io/api/project_badges/measure?project=thisisagile_easy&metric=coverage" alt="coverage" /></a>
|
|
@@ -59,7 +59,7 @@ var Mapper = class extends State {
|
|
|
59
59
|
}
|
|
60
60
|
// All names op properties (in target) that are NOT properties in source
|
|
61
61
|
get droppedOut() {
|
|
62
|
-
return this.get("droppedOut", () => this.properties.filter(([, p]) => !this.keys.some((k) => k === p.property)).map(([k]) => k));
|
|
62
|
+
return this.get("droppedOut", () => this.properties.filter(([, p]) => !this.keys.some((k) => k === (p.property ?? ""))).map(([k]) => k));
|
|
63
63
|
}
|
|
64
64
|
in(from = {}) {
|
|
65
65
|
return json.omit(
|
|
@@ -133,4 +133,4 @@ export {
|
|
|
133
133
|
Mapper,
|
|
134
134
|
mappings
|
|
135
135
|
};
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
136
|
+
//# sourceMappingURL=chunk-GPSPH4NX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/Mapper.ts"],"sourcesContent":["import { Property, PropertyOptions } from './Property';\nimport { State } from './State';\nimport { ifNotEmpty } from './If';\nimport { json, Json, JsonValue } from '../types/Json';\nimport { Optional } from '../types/Types';\nimport { TypeGuard } from '../types/TypeGuard';\nimport { isA } from '../types/IsA';\nimport { List, toList } from '../types/List';\nimport { meta } from '../types/Meta';\nimport { isEmpty } from '../types/Is';\nimport { Get, ofGet } from '../types/Get';\nimport { Construct, ofConstruct } from '../types/Constructor';\n\nexport type Mapping = {\n property: string;\n in: (source?: Json, key?: string) => Optional<JsonValue>;\n out: (source?: Json, key?: string) => Optional<JsonValue>;\n};\nexport const isMapping: TypeGuard<Mapping> = (m?: unknown): m is Mapping => isA<Mapping>(m, 'in', 'out');\n\nexport type MapStartFrom = 'scratch' | 'source';\nexport type MapOptions = { startFrom: MapStartFrom };\n\nexport class Mapper extends State implements Mapping {\n protected readonly map = mappings;\n\n constructor(\n readonly options: MapOptions = { startFrom: 'scratch' },\n readonly property = ''\n ) {\n super();\n }\n\n // All properties that are a mapping\n get properties(): List<[string, Mapping]> {\n return this.get('props', () =>\n meta(this)\n .entries<Mapping>()\n .filter(([, v]) => isMapping(v))\n );\n }\n\n // All names of properties (in target) that have a Mapping\n get keys(): List<string> {\n return this.get('keys', () => this.properties.map(([k]) => k));\n }\n\n // All names of properties (in source) that are named in a Mapping\n get columns(): List<string> {\n return this.get('columns', () => this.properties.mapDefined(([, p]) => ifNotEmpty(p.property, p.property))).distinct();\n }\n\n // All names of properties (in source) that are NOT properties in target\n private get droppedIn(): List<string> {\n return this.get('droppedIn', () => this.columns.filter(c => !this.keys.some(k => k === c)));\n }\n\n // All names op properties (in target) that are NOT properties in source\n private get droppedOut(): List<string> {\n return this.get('droppedOut', () => this.properties.filter(([, p]) => !this.keys.some(k => k === (p.property ?? ''))).map(([k]) => k));\n }\n\n public in(from: Json = {}): Json {\n return json.omit(\n this.properties.reduce((a, [k, p]) => json.merge(a, { [k]: p.in({ ...a, ...from }) }), this.options.startFrom === 'source' ? from : {}),\n ...this.droppedIn\n );\n }\n\n public out(to: Json = {}): Json {\n return json.omit(\n this.properties.reduce(\n (a, [k, p]) => json.merge(a, isEmpty(p.property) ? p.out(to, k) : { [p.property ?? '']: p.out({ ...a, ...to }, k) }),\n this.options.startFrom === 'source' ? to : {}\n ),\n ...this.droppedOut\n );\n }\n\n toString(): string {\n return this.constructor.name;\n }\n}\n\nexport const mappings = {\n item: (property: string, options?: PropertyOptions): Property => new Property(property, options),\n ignore: (property = ''): Mapping => ({\n property,\n in: (): Optional<JsonValue> => undefined,\n out: (): Optional<JsonValue> => undefined,\n }),\n skipIn: (property: string): Mapping => ({\n property,\n in: (): Optional<JsonValue> => undefined,\n out: (source: Json = {}): JsonValue => source[property],\n }),\n skipOut: (property: string): Mapping => ({\n property,\n in: (source: Json = {}): JsonValue => source[property],\n out: (): Optional<JsonValue> => undefined,\n }),\n func: (property: string, funcIn: Get<Optional<JsonValue>, Json>, funcOut: Get<Optional<JsonValue>, Json>): Mapping => ({\n property,\n in: (source: Json = {}): Optional<JsonValue> => ofGet(funcIn, source),\n out: (source: Json = {}): Optional<JsonValue> => ofGet(funcOut, source),\n }),\n add: (funcIn: Get<JsonValue, Json>): Mapping => ({\n property: '',\n in: (source: Json = {}): JsonValue => ofGet(funcIn, source),\n out: (): Optional<JsonValue> => undefined,\n }),\n map: (mapper: Construct<Mapper>, property = ''): Mapping => ({\n property,\n in: (source: Json = {}): JsonValue => ofConstruct(mapper).in(isEmpty(property) ? source : (source[property] as Json)),\n out: (source: Json = {}, key = ''): JsonValue => ofConstruct(mapper).out(isEmpty(key) ? source : (source[key] as Json)),\n }),\n propsToList: (...maps: Mapping[]): Mapping => ({\n property: '',\n in: (source: Json = {}): JsonValue => toList(maps.map(m => ofConstruct(m).in(source))).toJSON(),\n out: (source: Json = {}, key = ''): JsonValue =>\n maps.reduce((a: Json, m, i) => {\n const res = toList(source[key])[i];\n const out = m.out(res as Json);\n return { ...a, [m.property]: out ?? {} };\n }, {}),\n }),\n list: (mapper: Mapping, property: string): Mapping => ({\n property: property,\n in: (source: Json = {}): JsonValue =>\n toList(source[property])\n .map((v: any) => mapper.in(v))\n .toJSON(),\n out: (source: Json = {}, key = ''): JsonValue =>\n toList(isEmpty(key) ? source : (source[key] as Json))\n .map((v: any) => mapper.out(v))\n .toJSON(),\n }),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,YAAgC,CAAC,MAA8B,IAAa,GAAG,MAAM,KAAK;AAKhG,IAAM,SAAN,cAAqB,MAAyB;AAAA,EAGnD,YACW,UAAsB,EAAE,WAAW,UAAU,GAC7C,WAAW,IACpB;AACA,UAAM;AAHG;AACA;AAAA,EAGX;AAAA,EAPmB,MAAM;AAAA;AAAA,EAUzB,IAAI,aAAsC;AACxC,WAAO,KAAK;AAAA,MAAI;AAAA,MAAS,MACvB,KAAK,IAAI,EACN,QAAiB,EACjB,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,UAAU,CAAC,CAAC;AAAA,IACnC;AAAA,EAC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AAO,QAAQ,CAAU;AAAA,IACpH,KAAK,CAAC,SAAe,CAAC,GAAG,MAAM,OAAkB,YAAY,MAAM,EAAE,IAAI,QAAQ,GAAG,IAAI,SAAU,OAAO,GAAG,CAAU;AAAA,EACxH;AAAA,EACA,aAAa,IAAI,UAA8B;AAAA,IAC7C,UAAU;AAAA,IACV,IAAI,CAAC,SAAe,CAAC,MAAiB,OAAO,KAAK,IAAI,OAAK,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO;AAAA,IAC9F,KAAK,CAAC,SAAe,CAAC,GAAG,MAAM,OAC7B,KAAK,OAAO,CAAC,GAAS,GAAG,MAAM;AAC7B,YAAM,MAAM,OAAO,OAAO,GAAG,CAAC,EAAE,CAAC;AACjC,YAAM,MAAM,EAAE,IAAI,GAAW;AAC7B,aAAO,EAAE,GAAG,GAAG,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,EAAE;AAAA,IACzC,GAAG,CAAC,CAAC;AAAA,EACT;AAAA,EACA,MAAM,CAAC,QAAiB,cAA+B;AAAA,IACrD;AAAA,IACA,IAAI,CAAC,SAAe,CAAC,MACnB,OAAO,OAAO,QAAQ,CAAC,EACpB,IAAI,CAAC,MAAW,OAAO,GAAG,CAAC,CAAC,EAC5B,OAAO;AAAA,IACZ,KAAK,CAAC,SAAe,CAAC,GAAG,MAAM,OAC7B,OAAO,QAAQ,GAAG,IAAI,SAAU,OAAO,GAAG,CAAU,EACjD,IAAI,CAAC,MAAW,OAAO,IAAI,CAAC,CAAC,EAC7B,OAAO;AAAA,EACd;AACF;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -2653,7 +2653,7 @@ var Mapper = class extends State {
|
|
|
2653
2653
|
}
|
|
2654
2654
|
// All names op properties (in target) that are NOT properties in source
|
|
2655
2655
|
get droppedOut() {
|
|
2656
|
-
return this.get("droppedOut", () => this.properties.filter(([, p]) => !this.keys.some((k) => k === p.property)).map(([k]) => k));
|
|
2656
|
+
return this.get("droppedOut", () => this.properties.filter(([, p]) => !this.keys.some((k) => k === (p.property ?? ""))).map(([k]) => k));
|
|
2657
2657
|
}
|
|
2658
2658
|
in(from = {}) {
|
|
2659
2659
|
return json.omit(
|