@quanticdigit/web-model 1.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/LICENSE.txt ADDED
@@ -0,0 +1,47 @@
1
+ COMMERCIAL SOFTWARE LICENSE AGREEMENT
2
+ Quantic Digit S.R.L. — Restricted Use License
3
+ Version 1.0 — © 2025 Quantic Digit S.R.L. All rights reserved.
4
+
5
+ IMPORTANT – READ CAREFULLY:
6
+ This Software (the “Software”) is provided under license, not sold.
7
+ By installing, copying or using the Software, you agree to the following terms.
8
+
9
+ 1. GRANT OF LICENSE
10
+ Quantic Digit S.R.L. (“the Author”) grants you a non-exclusive, non-transferable license to use the Software exclusively for:
11
+ - personal learning and experimentation,
12
+ - educational or training activities,
13
+ - software development, prototyping, or testing not intended for commercial release.
14
+
15
+ 2. PROHIBITED USES
16
+ Unless expressly authorized in writing by Quantic Digit S.R.L., it is strictly forbidden to:
17
+ - use the Software in any commercial activity;
18
+ - integrate the Software into products or services intended for end customers;
19
+ - deploy or distribute the Software within a company, organization, or enterprise environment;
20
+ - use the Software in applications, systems or processes with any revenue, profit, or commercial purpose;
21
+ - redistribute, sublicense, sell, rent, lease, or otherwise transfer the Software to third parties.
22
+
23
+ “Commercial use” includes, but is not limited to:
24
+ - internal business use by companies, organizations or professionals,
25
+ - inclusion in paid services or products,
26
+ - use within customer projects, consultancy, or software delivered to clients,
27
+ - any use that yields direct or indirect economic advantage.
28
+
29
+ 3. OWNERSHIP
30
+ The Software is licensed, not sold.
31
+ All intellectual property rights remain the sole property of Quantic Digit S.R.L.
32
+
33
+ 4. WARRANTY DISCLAIMER
34
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT ANY WARRANTY OF ANY KIND.
35
+ The Author disclaims all implied warranties, including merchantability, fitness for a particular purpose and non-infringement.
36
+
37
+ 5. LIMITATION OF LIABILITY
38
+ In no event shall Quantic Digit S.R.L. be liable for any damages, including direct, indirect, incidental, special or consequential damages arising from the use of the Software.
39
+
40
+ 6. TERMINATION
41
+ Any violation of this License immediately terminates your right to use the Software.
42
+ Upon termination, you must cease all use and destroy all copies of the Software.
43
+
44
+ 7. GOVERNING LAW
45
+ This Agreement is governed by the laws of Italy, unless otherwise agreed in a written contract with Quantic Digit S.R.L.
46
+
47
+ © 2025 Quantic Digit S.R.L. — All rights reserved.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # WebModel
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
12
+
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
+
15
+ ```bash
16
+ ng generate --help
17
+ ```
18
+
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build web-model
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+
35
+ ```bash
36
+ cd dist/web-model
37
+ ```
38
+
39
+ 2. Run the `npm publish` command to publish your library to the npm registry:
40
+ ```bash
41
+ npm publish
42
+ ```
43
+
44
+ ## Running unit tests
45
+
46
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
47
+
48
+ ```bash
49
+ ng test
50
+ ```
51
+
52
+ ## Running end-to-end tests
53
+
54
+ For end-to-end (e2e) testing, run:
55
+
56
+ ```bash
57
+ ng e2e
58
+ ```
59
+
60
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
61
+
62
+ ## Additional Resources
63
+
64
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -0,0 +1,343 @@
1
+ import { instanceToPlain, plainToInstance, Expose, Type, Transform } from 'class-transformer';
2
+
3
+ class BaseModel {
4
+ /**
5
+ * Costruttore effettivo dell istanza.
6
+ *
7
+ * E un getter e **non** un campo: memorizzarlo come proprieta di istanza lo rende una chiave
8
+ * enumerabile, e `instanceToPlain` durante la serializzazione fa `if (value[key] instanceof
9
+ * Function) subValue = value[key]()` — cioe invoca il costruttore senza `new`, che su una classe
10
+ * nativa ES2022 lancia. Con il getter la proprieta non esiste sull istanza e non viene iterata.
11
+ * Vedi F0-59.
12
+ */
13
+ get _ctor() {
14
+ return this.constructor;
15
+ }
16
+ constructor(source = null) {
17
+ this.init();
18
+ if (typeof source === 'string') {
19
+ const sourceAsString = source;
20
+ this.fromJson(sourceAsString);
21
+ }
22
+ else {
23
+ this.fromPlainObject(source);
24
+ }
25
+ }
26
+ init() { }
27
+ fromJson(source) {
28
+ const obj = JSON.parse(source);
29
+ this.fromPlainObject(obj);
30
+ }
31
+ toJson() {
32
+ const obj = this.toPlainObject();
33
+ const result = JSON.stringify(obj);
34
+ return result;
35
+ }
36
+ fromSessionStorage(key) {
37
+ const value = sessionStorage.getItem(key);
38
+ if (value != null) {
39
+ this.fromJson(value);
40
+ }
41
+ }
42
+ toSessionStorage(key) {
43
+ const value = this.toJson();
44
+ sessionStorage.setItem(key, value);
45
+ }
46
+ fromLocalStorage(key) {
47
+ const value = localStorage.getItem(key);
48
+ if (value != null) {
49
+ this.fromJson(value);
50
+ }
51
+ }
52
+ toLocalStorage(key) {
53
+ const value = this.toJson();
54
+ localStorage.setItem(key, value);
55
+ }
56
+ fromPlainObject(source) {
57
+ if (source instanceof BaseModel) {
58
+ const plainSource = instanceToPlain(source);
59
+ this.fromPlainObject(plainSource);
60
+ }
61
+ else if (source != null) {
62
+ const instanceSource = plainToInstance(this._ctor, source);
63
+ this.mergePreserveInit(this, instanceSource);
64
+ }
65
+ }
66
+ mergePreserveInit(target, source) {
67
+ for (const key in source) {
68
+ const s = source[key];
69
+ const t = target[key];
70
+ if (s === undefined) {
71
+ continue;
72
+ }
73
+ if (s === null) {
74
+ if (t === undefined) {
75
+ target[key] = null;
76
+ }
77
+ continue;
78
+ }
79
+ target[key] = s;
80
+ }
81
+ }
82
+ toPlainObject() {
83
+ const plainSource = instanceToPlain(this);
84
+ return plainSource;
85
+ }
86
+ clone() {
87
+ const result = new this._ctor();
88
+ Object.getOwnPropertyNames(this).forEach((key) => {
89
+ const value = this[key];
90
+ const clonedValue = this.deepClone(value);
91
+ result[key] = clonedValue;
92
+ });
93
+ return result;
94
+ }
95
+ deepClone(source) {
96
+ let result;
97
+ if (source === undefined) {
98
+ result = null;
99
+ }
100
+ else if (source instanceof BaseModel) {
101
+ result = source.clone();
102
+ }
103
+ else if (Array.isArray(source)) {
104
+ result = source.map((item) => this.deepClone(item));
105
+ }
106
+ else if (source instanceof Date) {
107
+ result = new Date(source.getTime());
108
+ }
109
+ else if (source instanceof RegExp) {
110
+ result = new RegExp(source.source, source.flags);
111
+ }
112
+ else if (source && typeof source === 'object') {
113
+ result = JSON.parse(JSON.stringify(source));
114
+ }
115
+ else {
116
+ result = source;
117
+ }
118
+ return result;
119
+ }
120
+ }
121
+
122
+ function ExposeModel(typeFunction, options) {
123
+ return function (target, propertyKey) {
124
+ Expose()(target, propertyKey);
125
+ Type(typeFunction, options)(target, propertyKey);
126
+ };
127
+ }
128
+ function ExposeDateTimeOffset() {
129
+ return function (target, propertyKey) {
130
+ Expose()(target, propertyKey);
131
+ Type(() => Date)(target, propertyKey);
132
+ };
133
+ }
134
+ function ExposeTimeOffset() {
135
+ return function (target, propertyKey) {
136
+ Expose()(target, propertyKey);
137
+ Transform(({ value }) => {
138
+ const fn = (value) => {
139
+ if (Array.isArray(value)) {
140
+ return value.map((item) => fn(item));
141
+ }
142
+ else if (typeof value === 'string') {
143
+ if (!value.includes('T')) {
144
+ const parsed = new Date(`1970-01-01T${value}`);
145
+ return parsed;
146
+ }
147
+ else {
148
+ const parsed = new Date(value);
149
+ parsed.setFullYear(1970, 0, 1);
150
+ return parsed;
151
+ }
152
+ }
153
+ return null;
154
+ };
155
+ const result = fn(value);
156
+ return result;
157
+ }, { toClassOnly: true })(target, propertyKey);
158
+ Transform(({ value }) => {
159
+ const fn = (value) => {
160
+ if (Array.isArray(value)) {
161
+ return value.map((item) => fn(item));
162
+ }
163
+ else if (value instanceof Date && !isNaN(value.getTime())) {
164
+ const iso = value.toISOString();
165
+ return iso.substring(iso.indexOf('T') + 1);
166
+ }
167
+ return null;
168
+ };
169
+ const result = fn(value);
170
+ return result;
171
+ }, { toPlainOnly: true })(target, propertyKey);
172
+ };
173
+ }
174
+ function ExposeDateTimeOnly() {
175
+ return function (target, propertyKey) {
176
+ Expose()(target, propertyKey);
177
+ Transform(({ value }) => {
178
+ const fn = (value) => {
179
+ if (Array.isArray(value)) {
180
+ return value.map((item) => fn(item));
181
+ }
182
+ else if (typeof value === 'string') {
183
+ const match = value.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.(\d{3}\d*))?$/);
184
+ if (!match) {
185
+ return null;
186
+ }
187
+ const y = Number(match[1]);
188
+ const mo = Number(match[2]);
189
+ const d = Number(match[3]);
190
+ const h = Number(match[4]);
191
+ const mi = Number(match[5]);
192
+ const s = Number(match[6]);
193
+ const ms = match[7] ? parseFloat(match[7]) * 1000 : 0;
194
+ if (isNaN(y) || isNaN(mo) || isNaN(d) || isNaN(h) || isNaN(mi) || isNaN(s) || mo < 1 || mo > 12 || d < 1 || d > 31 || h > 23 || mi > 59 || s > 59 || ms < 0 || ms > 999) {
195
+ return null;
196
+ }
197
+ const now = new Date(y, mo - 1, d, h, mi, s, ms);
198
+ return now;
199
+ }
200
+ return null;
201
+ };
202
+ const result = fn(value);
203
+ return result;
204
+ }, { toClassOnly: true })(target, propertyKey);
205
+ Transform(({ value }) => {
206
+ const fn = (value) => {
207
+ if (Array.isArray(value)) {
208
+ return value.map((item) => fn(item));
209
+ }
210
+ else if (value instanceof Date && !isNaN(value.getTime())) {
211
+ const y = value.getFullYear();
212
+ const mo = String(value.getMonth() + 1).padStart(2, '0');
213
+ const d = String(value.getDate()).padStart(2, '0');
214
+ const h = String(value.getHours()).padStart(2, '0');
215
+ const mi = String(value.getMinutes()).padStart(2, '0');
216
+ const s = String(value.getSeconds()).padStart(2, '0');
217
+ const ms = '.' + String(value.getMilliseconds()).padStart(3, '0');
218
+ const result = `${y}-${mo}-${d}T${h}:${mi}:${s}${ms}`;
219
+ return result;
220
+ }
221
+ return null;
222
+ };
223
+ const result = fn(value);
224
+ return result;
225
+ }, { toPlainOnly: true })(target, propertyKey);
226
+ };
227
+ }
228
+ function ExposeDateOnly() {
229
+ return function (target, propertyKey) {
230
+ Expose()(target, propertyKey);
231
+ Transform(({ value }) => {
232
+ const fn = (value) => {
233
+ if (Array.isArray(value)) {
234
+ return value.map((item) => fn(item));
235
+ }
236
+ else if (typeof value === 'string') {
237
+ const datePart = value.split('T')[0];
238
+ const match = datePart.match(/^(\d{4})-(\d{2})-(\d{2})$/);
239
+ if (!match) {
240
+ return null;
241
+ }
242
+ const y = Number(match[1]);
243
+ const m = Number(match[2]);
244
+ const d = Number(match[3]);
245
+ if (isNaN(y) || isNaN(m) || isNaN(d) || m < 1 || m > 12 || d < 1 || d > 31) {
246
+ return null;
247
+ }
248
+ const today = new Date(y, m - 1, d);
249
+ return today;
250
+ }
251
+ return null;
252
+ };
253
+ const result = fn(value);
254
+ return result;
255
+ }, { toClassOnly: true })(target, propertyKey);
256
+ Transform(({ value }) => {
257
+ const fn = (value) => {
258
+ if (Array.isArray(value)) {
259
+ return value.map((item) => fn(item));
260
+ }
261
+ else if (value instanceof Date && !isNaN(value.getTime())) {
262
+ const y = value.getFullYear();
263
+ const m = String(value.getMonth() + 1).padStart(2, '0');
264
+ const d = String(value.getDate()).padStart(2, '0');
265
+ const result = `${y}-${m}-${d}`;
266
+ return result;
267
+ }
268
+ return null;
269
+ };
270
+ const result = fn(value);
271
+ return result;
272
+ }, { toPlainOnly: true })(target, propertyKey);
273
+ };
274
+ }
275
+ function ExposeTimeOnly() {
276
+ return function (target, propertyKey) {
277
+ Expose()(target, propertyKey);
278
+ Transform(({ value }) => {
279
+ const fn = (value) => {
280
+ if (Array.isArray(value)) {
281
+ return value.map((item) => fn(item));
282
+ }
283
+ else if (typeof value === 'string') {
284
+ const timePart = value.includes('T') ? value.split('T')[1] : value;
285
+ const match = timePart.match(/^(\d{2}):(\d{2}):(\d{2})(\.(\d{3}\d*))?$/);
286
+ if (!match) {
287
+ return null;
288
+ }
289
+ const h = Number(match[1]);
290
+ const m = Number(match[2]);
291
+ const s = Number(match[3]);
292
+ const ms = match[4] ? parseFloat(match[4]) * 1000 : 0;
293
+ if (isNaN(h) || isNaN(m) || isNaN(s) || h > 23 || m > 59 || s > 59 || ms < 0 || ms > 999) {
294
+ return null;
295
+ }
296
+ const now = new Date();
297
+ now.setHours(h, m, s, isNaN(ms) ? 0 : ms);
298
+ return now;
299
+ }
300
+ return null;
301
+ };
302
+ const result = fn(value);
303
+ return result;
304
+ }, { toClassOnly: true })(target, propertyKey);
305
+ Transform(({ value }) => {
306
+ const fn = (value) => {
307
+ if (Array.isArray(value)) {
308
+ return value.map((item) => fn(item));
309
+ }
310
+ else if (value instanceof Date && !isNaN(value.getTime())) {
311
+ const h = String(value.getHours()).padStart(2, '0');
312
+ const min = String(value.getMinutes()).padStart(2, '0');
313
+ const sec = String(value.getSeconds()).padStart(2, '0');
314
+ const ms = value.getMilliseconds() ? '.' + String(value.getMilliseconds()).padStart(3, '0') : '';
315
+ const result = `${h}:${min}:${sec}${ms}`;
316
+ return result;
317
+ }
318
+ return null;
319
+ };
320
+ const result = fn(value);
321
+ return result;
322
+ }, { toPlainOnly: true })(target, propertyKey);
323
+ };
324
+ }
325
+
326
+ /**
327
+ * Superficie pubblica di `@quanticdigit/web-model`.
328
+ *
329
+ * E' l'unico punto da cui un prodotto importa: gli import profondi legherebbero i consumatori alla
330
+ * disposizione interna dei file, e ogni riorganizzazione diventerebbe un breaking change.
331
+ *
332
+ * Qui c'e' la MACCHINA della ricostruzione tipizzata, non i modelli: `BaseModel` e i decoratori di
333
+ * esposizione. Le gerarchie `Abstract<Nome>` restano nel prodotto, dove le genera il suo generatore
334
+ * a partire dai suoi DTO — sono le sue convenzioni di entita', e un pacchetto che le contenesse
335
+ * costringerebbe il secondo consumatore ad adottare quelle del primo.
336
+ */
337
+
338
+ /**
339
+ * Generated bundle index. Do not edit.
340
+ */
341
+
342
+ export { BaseModel, ExposeDateOnly, ExposeDateTimeOffset, ExposeDateTimeOnly, ExposeModel, ExposeTimeOffset, ExposeTimeOnly };
343
+ //# sourceMappingURL=quanticdigit-web-model.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quanticdigit-web-model.mjs","sources":["../../../projects/web-model/src/lib/base-model.ts","../../../projects/web-model/src/lib/expose-decorators.ts","../../../projects/web-model/src/public-api.ts","../../../projects/web-model/src/quanticdigit-web-model.ts"],"sourcesContent":["import { instanceToPlain, plainToInstance } from 'class-transformer';\nimport { IParamsConstructor } from './i-params-constructor';\n\nexport abstract class BaseModel {\n /**\n * Costruttore effettivo dell istanza.\n *\n * E un getter e **non** un campo: memorizzarlo come proprieta di istanza lo rende una chiave\n * enumerabile, e `instanceToPlain` durante la serializzazione fa `if (value[key] instanceof\n * Function) subValue = value[key]()` — cioe invoca il costruttore senza `new`, che su una classe\n * nativa ES2022 lancia. Con il getter la proprieta non esiste sull istanza e non viene iterata.\n * Vedi F0-59.\n */\n private get _ctor(): IParamsConstructor<this> {\n return this.constructor as IParamsConstructor<this>;\n }\n\n constructor(source: any = null) {\n this.init();\n if (typeof source === 'string') {\n const sourceAsString: string = source as string\n this.fromJson(sourceAsString);\n } else {\n this.fromPlainObject(source);\n }\n }\n\n init(): void {}\n\n fromJson(source: string): void {\n const obj = JSON.parse(source);\n this.fromPlainObject(obj);\n }\n\n toJson(): string {\n const obj = this.toPlainObject();\n const result = JSON.stringify(obj);\n return result;\n }\n\n fromSessionStorage(key: string): void {\n const value = sessionStorage.getItem(key);\n if (value != null) {\n this.fromJson(value);\n }\n }\n\n toSessionStorage(key: string): void {\n const value = this.toJson();\n sessionStorage.setItem(key, value);\n }\n\n\n fromLocalStorage(key: string): void {\n const value = localStorage.getItem(key);\n if (value != null) {\n this.fromJson(value);\n }\n }\n\n toLocalStorage(key: string): void {\n const value = this.toJson();\n localStorage.setItem(key, value);\n }\n\n fromPlainObject(source: any): void {\n if (source instanceof BaseModel) {\n const plainSource: any = instanceToPlain(source);\n this.fromPlainObject(plainSource);\n } else if (source != null) {\n const instanceSource = plainToInstance(this._ctor, source) as this;\n this.mergePreserveInit(this, instanceSource);\n }\n }\n\n private mergePreserveInit<T extends object>(target: T, source: Partial<T>): void {\n for (const key in source) {\n const s = (source as any)[key];\n const t = (target as any)[key];\n if (s === undefined) {\n continue;\n }\n if (s === null) {\n if (t === undefined) {\n (target as any)[key] = null;\n }\n continue;\n }\n (target as any)[key] = s;\n }\n }\n\n toPlainObject(): any {\n const plainSource: any = instanceToPlain(this);\n return plainSource;\n }\n\n clone(): this {\n const result: this = new this._ctor();\n Object.getOwnPropertyNames(this).forEach((key) => {\n const value = (this as any)[key];\n const clonedValue = this.deepClone(value);\n (result as any)[key] = clonedValue;\n });\n return result;\n }\n\n private deepClone(source: any): any {\n let result: any;\n if (source === undefined) {\n result = null;\n } else if (source instanceof BaseModel) {\n result = source.clone();\n } else if (Array.isArray(source)) {\n result = source.map((item) => this.deepClone(item));\n } else if (source instanceof Date) {\n result = new Date(source.getTime());\n } else if (source instanceof RegExp) {\n result = new RegExp(source.source, source.flags);\n } else if (source && typeof source === 'object') {\n result = JSON.parse(JSON.stringify(source));\n } else {\n result = source;\n }\n return result;\n }\n}\n","import { Expose, Transform, Type, TypeHelpOptions, TypeOptions } from 'class-transformer';\r\n\r\nexport function ExposeModel(typeFunction: (type?: TypeHelpOptions) => Function, options?: TypeOptions): PropertyDecorator {\r\n return function (target: Object, propertyKey: string | symbol) {\r\n Expose()(target, propertyKey);\r\n Type(typeFunction, options)(target, propertyKey);\r\n };\r\n}\r\n\r\nexport function ExposeDateTimeOffset(): PropertyDecorator {\r\n return function (target: Object, propertyKey: string | symbol) {\r\n Expose()(target, propertyKey);\r\n Type(() => Date)(target, propertyKey);\r\n };\r\n}\r\n\r\nexport function ExposeTimeOffset(): PropertyDecorator {\r\n return function (target: Object, propertyKey: string | symbol) {\r\n Expose()(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (typeof value === 'string') {\r\n if (!value.includes('T')) {\r\n const parsed: Date = new Date(`1970-01-01T${value}`);\r\n return parsed;\r\n } else {\r\n const parsed: Date = new Date(value);\r\n parsed.setFullYear(1970, 0, 1);\r\n return parsed;\r\n }\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toClassOnly: true }\r\n )(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (value instanceof Date && !isNaN(value.getTime())) {\r\n const iso = value.toISOString();\r\n return iso.substring(iso.indexOf('T') + 1);\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toPlainOnly: true }\r\n )(target, propertyKey);\r\n };\r\n}\r\n\r\nexport function ExposeDateTimeOnly(): PropertyDecorator {\r\n return function (target: Object, propertyKey: string | symbol) {\r\n Expose()(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (typeof value === 'string') {\r\n const match = value.match(/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{3}\\d*))?$/);\r\n if (!match) {\r\n return null;\r\n }\r\n const y = Number(match[1]);\r\n const mo = Number(match[2]);\r\n const d = Number(match[3]);\r\n const h = Number(match[4]);\r\n const mi = Number(match[5]);\r\n const s = Number(match[6]);\r\n const ms = match[7] ? parseFloat(match[7]) * 1000 : 0;\r\n if (isNaN(y) || isNaN(mo) || isNaN(d) || isNaN(h) || isNaN(mi) || isNaN(s) || mo < 1 || mo > 12 || d < 1 || d > 31 || h > 23 || mi > 59 || s > 59 || ms < 0 || ms > 999) {\r\n return null;\r\n }\r\n const now: Date = new Date(y, mo - 1, d, h, mi, s, ms);\r\n return now;\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toClassOnly: true }\r\n )(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (value instanceof Date && !isNaN(value.getTime())) {\r\n const y = value.getFullYear();\r\n const mo = String(value.getMonth() + 1).padStart(2, '0');\r\n const d = String(value.getDate()).padStart(2, '0');\r\n const h = String(value.getHours()).padStart(2, '0');\r\n const mi = String(value.getMinutes()).padStart(2, '0');\r\n const s = String(value.getSeconds()).padStart(2, '0');\r\n const ms = '.' + String(value.getMilliseconds()).padStart(3, '0');\r\n const result = `${y}-${mo}-${d}T${h}:${mi}:${s}${ms}`;\r\n return result;\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toPlainOnly: true }\r\n )(target, propertyKey);\r\n };\r\n}\r\n\r\nexport function ExposeDateOnly(): PropertyDecorator {\r\n return function (target: Object, propertyKey: string | symbol) {\r\n Expose()(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (typeof value === 'string') {\r\n const datePart = value.split('T')[0];\r\n const match = datePart.match(/^(\\d{4})-(\\d{2})-(\\d{2})$/);\r\n if (!match) {\r\n return null;\r\n }\r\n const y = Number(match[1]);\r\n const m = Number(match[2]);\r\n const d = Number(match[3]);\r\n if (isNaN(y) || isNaN(m) || isNaN(d) || m < 1 || m > 12 || d < 1 || d > 31) {\r\n return null;\r\n }\r\n const today: Date = new Date(y, m - 1, d);\r\n return today;\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toClassOnly: true }\r\n )(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (value instanceof Date && !isNaN(value.getTime())) {\r\n const y = value.getFullYear();\r\n const m = String(value.getMonth() + 1).padStart(2, '0');\r\n const d = String(value.getDate()).padStart(2, '0');\r\n const result = `${y}-${m}-${d}`;\r\n return result;\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toPlainOnly: true }\r\n )(target, propertyKey);\r\n };\r\n}\r\n\r\nexport function ExposeTimeOnly(): PropertyDecorator {\r\n return function (target: Object, propertyKey: string | symbol) {\r\n Expose()(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (typeof value === 'string') {\r\n const timePart = value.includes('T') ? value.split('T')[1] : value;\r\n const match = timePart.match(/^(\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{3}\\d*))?$/);\r\n if (!match) {\r\n return null;\r\n }\r\n const h = Number(match[1]);\r\n const m = Number(match[2]);\r\n const s = Number(match[3]);\r\n const ms = match[4] ? parseFloat(match[4]) * 1000 : 0;\r\n if (isNaN(h) || isNaN(m) || isNaN(s) || h > 23 || m > 59 || s > 59 || ms < 0 || ms > 999) {\r\n return null;\r\n }\r\n const now = new Date();\r\n now.setHours(h, m, s, isNaN(ms) ? 0 : ms);\r\n return now;\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toClassOnly: true }\r\n )(target, propertyKey);\r\n Transform(\r\n ({ value }) => {\r\n const fn: (v: any) => any = (value) => {\r\n if (Array.isArray(value)) {\r\n return value.map((item) => fn(item));\r\n } else if (value instanceof Date && !isNaN(value.getTime())) {\r\n const h = String(value.getHours()).padStart(2, '0');\r\n const min = String(value.getMinutes()).padStart(2, '0');\r\n const sec = String(value.getSeconds()).padStart(2, '0');\r\n const ms = value.getMilliseconds() ? '.' + String(value.getMilliseconds()).padStart(3, '0') : '';\r\n const result = `${h}:${min}:${sec}${ms}`;\r\n return result;\r\n }\r\n return null;\r\n };\r\n const result = fn(value);\r\n return result;\r\n },\r\n { toPlainOnly: true }\r\n )(target, propertyKey);\r\n };\r\n}\r\n","/**\n * Superficie pubblica di `@quanticdigit/web-model`.\n *\n * E' l'unico punto da cui un prodotto importa: gli import profondi legherebbero i consumatori alla\n * disposizione interna dei file, e ogni riorganizzazione diventerebbe un breaking change.\n *\n * Qui c'e' la MACCHINA della ricostruzione tipizzata, non i modelli: `BaseModel` e i decoratori di\n * esposizione. Le gerarchie `Abstract<Nome>` restano nel prodotto, dove le genera il suo generatore\n * a partire dai suoi DTO — sono le sue convenzioni di entita', e un pacchetto che le contenesse\n * costringerebbe il secondo consumatore ad adottare quelle del primo.\n */\n\nexport * from './lib/base-model';\nexport * from './lib/expose-decorators';\nexport * from './lib/i-params-constructor';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;MAGsB,SAAS,CAAA;AAC7B;;;;;;;;AAQG;AACH,IAAA,IAAY,KAAK,GAAA;QACf,OAAO,IAAI,CAAC,WAAuC;IACrD;AAEA,IAAA,WAAA,CAAY,SAAc,IAAI,EAAA;QAC5B,IAAI,CAAC,IAAI,EAAE;AACX,QAAA,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,MAAM,cAAc,GAAW,MAAgB;AAC/C,YAAA,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC/B;aAAO;AACL,YAAA,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;QAC9B;IACF;AAE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,CAAC,EAAE,GAAG,CAAC;AACnD,oBAAA,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;AACvD,oBAAA,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;AACvD,oBAAA,MAAM,EAAE,GAAG,KAAK,CAAC,eAAe,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE;oBAChG,MAAM,MAAM,GAAG,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,EAAI,GAAG,CAAA,EAAG,EAAE,CAAA,CAAE;AACxC,oBAAA,OAAO,MAAM;gBACf;AACA,gBAAA,OAAO,IAAI;AACb,YAAA,CAAC;AACD,YAAA,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC;AACxB,YAAA,OAAO,MAAM;AACf,QAAA,CAAC,EACD,EAAE,WAAW,EAAE,IAAI,EAAE,CACtB,CAAC,MAAM,EAAE,WAAW,CAAC;AACxB,IAAA,CAAC;AACH;;AChOA;;;;;;;;;;AAUG;;ACVH;;AAEG;;"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@quanticdigit/web-model",
3
+ "version": "1.0.0",
4
+ "description": "Ricostruzione dei modelli tipizzati dal JSON: BaseModel e i decoratori di esposizione.",
5
+ "author": "Quantic Digit S.R.L.",
6
+ "license": "SEE LICENSE IN LICENSE.txt",
7
+ "homepage": "https://www.quanticdigit.it/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://gitlab.com/quanticdigit/library.git"
11
+ },
12
+ "sideEffects": false,
13
+ "peerDependencies": {
14
+ "class-transformer": "^0.5.1",
15
+ "reflect-metadata": "^0.2.2"
16
+ },
17
+ "dependencies": {
18
+ "tslib": "^2.3.0"
19
+ },
20
+ "module": "fesm2022/quanticdigit-web-model.mjs",
21
+ "typings": "types/quanticdigit-web-model.d.ts",
22
+ "exports": {
23
+ "./package.json": {
24
+ "default": "./package.json"
25
+ },
26
+ ".": {
27
+ "types": "./types/quanticdigit-web-model.d.ts",
28
+ "default": "./fesm2022/quanticdigit-web-model.mjs"
29
+ }
30
+ },
31
+ "type": "module"
32
+ }
@@ -0,0 +1,41 @@
1
+ import { TypeHelpOptions, TypeOptions } from 'class-transformer';
2
+
3
+ declare abstract class BaseModel {
4
+ /**
5
+ * Costruttore effettivo dell istanza.
6
+ *
7
+ * E un getter e **non** un campo: memorizzarlo come proprieta di istanza lo rende una chiave
8
+ * enumerabile, e `instanceToPlain` durante la serializzazione fa `if (value[key] instanceof
9
+ * Function) subValue = value[key]()` — cioe invoca il costruttore senza `new`, che su una classe
10
+ * nativa ES2022 lancia. Con il getter la proprieta non esiste sull istanza e non viene iterata.
11
+ * Vedi F0-59.
12
+ */
13
+ private get _ctor();
14
+ constructor(source?: any);
15
+ init(): void;
16
+ fromJson(source: string): void;
17
+ toJson(): string;
18
+ fromSessionStorage(key: string): void;
19
+ toSessionStorage(key: string): void;
20
+ fromLocalStorage(key: string): void;
21
+ toLocalStorage(key: string): void;
22
+ fromPlainObject(source: any): void;
23
+ private mergePreserveInit;
24
+ toPlainObject(): any;
25
+ clone(): this;
26
+ private deepClone;
27
+ }
28
+
29
+ declare function ExposeModel(typeFunction: (type?: TypeHelpOptions) => Function, options?: TypeOptions): PropertyDecorator;
30
+ declare function ExposeDateTimeOffset(): PropertyDecorator;
31
+ declare function ExposeTimeOffset(): PropertyDecorator;
32
+ declare function ExposeDateTimeOnly(): PropertyDecorator;
33
+ declare function ExposeDateOnly(): PropertyDecorator;
34
+ declare function ExposeTimeOnly(): PropertyDecorator;
35
+
36
+ interface IParamsConstructor<T> {
37
+ new (...args: any[]): T;
38
+ }
39
+
40
+ export { BaseModel, ExposeDateOnly, ExposeDateTimeOffset, ExposeDateTimeOnly, ExposeModel, ExposeTimeOffset, ExposeTimeOnly };
41
+ export type { IParamsConstructor };