@orion-js/typed-model 3.11.15 → 4.0.0-alpha.2

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.
Files changed (55) hide show
  1. package/dist/index.cjs +6776 -0
  2. package/dist/index.d.ts +495 -0
  3. package/dist/index.js +6748 -0
  4. package/package.json +24 -21
  5. package/LICENSE +0 -21
  6. package/lib/decorators/index.d.ts +0 -4
  7. package/lib/decorators/index.js +0 -16
  8. package/lib/decorators/prop.d.ts +0 -8
  9. package/lib/decorators/prop.js +0 -30
  10. package/lib/decorators/prop.test.d.ts +0 -1
  11. package/lib/decorators/prop.test.js +0 -26
  12. package/lib/decorators/resolver.d.ts +0 -5
  13. package/lib/decorators/resolver.js +0 -14
  14. package/lib/decorators/typedModel.d.ts +0 -5
  15. package/lib/decorators/typedModel.js +0 -16
  16. package/lib/decorators/typedSchema.d.ts +0 -2
  17. package/lib/decorators/typedSchema.js +0 -13
  18. package/lib/enum.test.d.ts +0 -1
  19. package/lib/enum.test.js +0 -29
  20. package/lib/errors/CannotDetermineType.d.ts +0 -3
  21. package/lib/errors/CannotDetermineType.js +0 -9
  22. package/lib/errors/CannotUseArray.d.ts +0 -3
  23. package/lib/errors/CannotUseArray.js +0 -9
  24. package/lib/errors/PropertyAlreadyExists.d.ts +0 -3
  25. package/lib/errors/PropertyAlreadyExists.js +0 -9
  26. package/lib/errors/SchemaAlreadyExists.d.ts +0 -3
  27. package/lib/errors/SchemaAlreadyExists.js +0 -9
  28. package/lib/errors/index.d.ts +0 -4
  29. package/lib/errors/index.js +0 -16
  30. package/lib/factories/cloneSchemaClass.d.ts +0 -23
  31. package/lib/factories/cloneSchemaClass.js +0 -28
  32. package/lib/factories/cloneSchemaClass.test.d.ts +0 -1
  33. package/lib/factories/cloneSchemaClass.test.js +0 -38
  34. package/lib/factories/getModelForClass.d.ts +0 -3
  35. package/lib/factories/getModelForClass.js +0 -62
  36. package/lib/factories/getModelForClass.test.d.ts +0 -1
  37. package/lib/factories/getModelForClass.test.js +0 -59
  38. package/lib/factories/getSchemaForClass.d.ts +0 -3
  39. package/lib/factories/getSchemaForClass.js +0 -8
  40. package/lib/factories/helpers/processSchemaForProp.d.ts +0 -4
  41. package/lib/factories/helpers/processSchemaForProp.js +0 -65
  42. package/lib/factories/index.d.ts +0 -3
  43. package/lib/factories/index.js +0 -15
  44. package/lib/index.d.ts +0 -2
  45. package/lib/index.js +0 -14
  46. package/lib/index.test.d.ts +0 -1
  47. package/lib/index.test.js +0 -682
  48. package/lib/schema.test.d.ts +0 -1
  49. package/lib/schema.test.js +0 -94
  50. package/lib/storage/metadataStorage.d.ts +0 -28
  51. package/lib/storage/metadataStorage.js +0 -55
  52. package/lib/utils/interfaces.d.ts +0 -3
  53. package/lib/utils/interfaces.js +0 -2
  54. package/lib/utils/isClass.d.ts +0 -1
  55. package/lib/utils/isClass.js +0 -6
package/lib/index.test.js DELETED
@@ -1,682 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const models_1 = require("@orion-js/models");
13
- const resolvers_1 = require("@orion-js/resolvers");
14
- const errors_1 = require("./errors");
15
- const index_1 = require("./index");
16
- describe('typed-schema e2e tests', () => {
17
- describe('getSchemaForClass', () => {
18
- it('works for a simple schema', () => {
19
- let Spec = class Spec {
20
- };
21
- __decorate([
22
- (0, index_1.Prop)({ optional: true }),
23
- __metadata("design:type", String)
24
- ], Spec.prototype, "name", void 0);
25
- __decorate([
26
- (0, index_1.Prop)({ optional: true }),
27
- __metadata("design:type", Date)
28
- ], Spec.prototype, "createdAt", void 0);
29
- __decorate([
30
- (0, index_1.Prop)({ optional: true }),
31
- __metadata("design:type", Boolean)
32
- ], Spec.prototype, "isDeleted", void 0);
33
- Spec = __decorate([
34
- (0, index_1.TypedModel)()
35
- ], Spec);
36
- const expected = {
37
- name: {
38
- type: String,
39
- optional: true
40
- },
41
- createdAt: {
42
- type: Date,
43
- optional: true
44
- },
45
- isDeleted: {
46
- type: Boolean,
47
- optional: true
48
- }
49
- };
50
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
51
- });
52
- it('works for a simple schema using alt data types', () => {
53
- let Spec = class Spec {
54
- };
55
- __decorate([
56
- (0, index_1.Prop)({ type: 'string' }),
57
- __metadata("design:type", String)
58
- ], Spec.prototype, "name", void 0);
59
- __decorate([
60
- (0, index_1.Prop)({ type: 'ID' }),
61
- __metadata("design:type", String)
62
- ], Spec.prototype, "_id", void 0);
63
- __decorate([
64
- (0, index_1.Prop)({ type: 'integer' }),
65
- __metadata("design:type", Number)
66
- ], Spec.prototype, "age", void 0);
67
- __decorate([
68
- (0, index_1.Prop)({ type: 'blackbox' }),
69
- __metadata("design:type", Object)
70
- ], Spec.prototype, "metadata", void 0);
71
- Spec = __decorate([
72
- (0, index_1.TypedModel)()
73
- ], Spec);
74
- const expected = {
75
- name: {
76
- type: 'string'
77
- },
78
- _id: {
79
- type: 'ID'
80
- },
81
- age: {
82
- type: 'integer'
83
- },
84
- metadata: {
85
- type: 'blackbox'
86
- }
87
- };
88
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
89
- });
90
- it('works for a derived schema', () => {
91
- let A = class A {
92
- };
93
- __decorate([
94
- (0, index_1.Prop)(),
95
- __metadata("design:type", String)
96
- ], A.prototype, "name", void 0);
97
- A = __decorate([
98
- (0, index_1.TypedModel)()
99
- ], A);
100
- class B extends A {
101
- }
102
- __decorate([
103
- (0, index_1.Prop)(),
104
- __metadata("design:type", String)
105
- ], B.prototype, "lastName", void 0);
106
- const expected = {
107
- name: {
108
- type: String
109
- },
110
- lastName: {
111
- type: String
112
- }
113
- };
114
- expect((0, index_1.getSchemaForClass)(B)).toEqual(expected);
115
- });
116
- it('works for multiple data types', () => {
117
- let Spec = class Spec {
118
- };
119
- __decorate([
120
- (0, index_1.Prop)(),
121
- __metadata("design:type", String)
122
- ], Spec.prototype, "name", void 0);
123
- __decorate([
124
- (0, index_1.Prop)(),
125
- __metadata("design:type", Number)
126
- ], Spec.prototype, "age", void 0);
127
- __decorate([
128
- (0, index_1.Prop)(),
129
- __metadata("design:type", Date)
130
- ], Spec.prototype, "createdAt", void 0);
131
- __decorate([
132
- (0, index_1.Prop)(),
133
- __metadata("design:type", Boolean)
134
- ], Spec.prototype, "isDeleted", void 0);
135
- Spec = __decorate([
136
- (0, index_1.TypedModel)()
137
- ], Spec);
138
- const expected = {
139
- name: {
140
- type: String
141
- },
142
- age: {
143
- type: Number
144
- },
145
- createdAt: {
146
- type: Date
147
- },
148
- isDeleted: {
149
- type: Boolean
150
- }
151
- };
152
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
153
- });
154
- describe('when using object types', () => {
155
- it('throws if the object type is not explicitly specified', () => {
156
- expect(() => {
157
- let Spec =
158
- // eslint-disable-next-line no-unused-vars
159
- class Spec {
160
- };
161
- __decorate([
162
- (0, index_1.Prop)(),
163
- __metadata("design:type", Object)
164
- ], Spec.prototype, "data", void 0);
165
- Spec = __decorate([
166
- (0, index_1.TypedModel)()
167
- // eslint-disable-next-line no-unused-vars
168
- ], Spec);
169
- }).toThrow(errors_1.CannotDetermineTypeError);
170
- });
171
- it('works for object types', () => {
172
- let Spec = class Spec {
173
- };
174
- __decorate([
175
- (0, index_1.Prop)({
176
- type: {
177
- name: { type: String }
178
- }
179
- }),
180
- __metadata("design:type", Object)
181
- ], Spec.prototype, "user", void 0);
182
- Spec = __decorate([
183
- (0, index_1.TypedModel)()
184
- ], Spec);
185
- const expected = {
186
- user: {
187
- type: {
188
- name: {
189
- type: String
190
- }
191
- }
192
- }
193
- };
194
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
195
- });
196
- it('works for object types using shorthands', () => {
197
- let Spec = class Spec {
198
- };
199
- __decorate([
200
- (0, index_1.Prop)({
201
- type: {
202
- name: String
203
- }
204
- }),
205
- __metadata("design:type", Object)
206
- ], Spec.prototype, "user", void 0);
207
- Spec = __decorate([
208
- (0, index_1.TypedModel)()
209
- ], Spec);
210
- const expected = {
211
- user: {
212
- type: {
213
- name: {
214
- type: String
215
- }
216
- }
217
- }
218
- };
219
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
220
- });
221
- });
222
- describe('when using array types', () => {
223
- it('throws if the array type is not explicitly specified', () => {
224
- expect(() => {
225
- let Spec =
226
- // eslint-disable-next-line no-unused-vars
227
- class Spec {
228
- };
229
- __decorate([
230
- (0, index_1.Prop)(),
231
- __metadata("design:type", Array)
232
- ], Spec.prototype, "names", void 0);
233
- Spec = __decorate([
234
- (0, index_1.TypedModel)()
235
- // eslint-disable-next-line no-unused-vars
236
- ], Spec);
237
- }).toThrow(errors_1.CannotUseArrayError);
238
- });
239
- it('works for array schemas', () => {
240
- const def = { type: [String] };
241
- let Spec = class Spec {
242
- };
243
- __decorate([
244
- (0, index_1.Prop)(def),
245
- __metadata("design:type", Array)
246
- ], Spec.prototype, "names", void 0);
247
- __decorate([
248
- (0, index_1.Prop)({ type: [Number] }),
249
- __metadata("design:type", Array)
250
- ], Spec.prototype, "ages", void 0);
251
- Spec = __decorate([
252
- (0, index_1.TypedModel)()
253
- ], Spec);
254
- const expected = {
255
- names: {
256
- type: [String]
257
- },
258
- ages: {
259
- type: [Number]
260
- }
261
- };
262
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
263
- });
264
- });
265
- describe('when using nested schemas', () => {
266
- it('throws if the class type is not explicitly specified', () => {
267
- let A = class A {
268
- };
269
- __decorate([
270
- (0, index_1.Prop)(),
271
- __metadata("design:type", String)
272
- ], A.prototype, "name", void 0);
273
- A = __decorate([
274
- (0, index_1.TypedModel)()
275
- ], A);
276
- expect(() => {
277
- let Spec =
278
- // eslint-disable-next-line no-unused-vars
279
- class Spec {
280
- };
281
- __decorate([
282
- (0, index_1.Prop)(),
283
- __metadata("design:type", A)
284
- ], Spec.prototype, "a", void 0);
285
- Spec = __decorate([
286
- (0, index_1.TypedModel)()
287
- // eslint-disable-next-line no-unused-vars
288
- ], Spec);
289
- }).toThrow(errors_1.CannotDetermineTypeError);
290
- });
291
- it('works for nested schemas', () => {
292
- let A = class A {
293
- };
294
- __decorate([
295
- (0, index_1.Prop)(),
296
- __metadata("design:type", String)
297
- ], A.prototype, "name", void 0);
298
- A = __decorate([
299
- (0, index_1.TypedModel)()
300
- ], A);
301
- let B = class B {
302
- };
303
- __decorate([
304
- (0, index_1.Prop)(),
305
- __metadata("design:type", String)
306
- ], B.prototype, "lastName", void 0);
307
- B = __decorate([
308
- (0, index_1.TypedModel)()
309
- ], B);
310
- let Spec = class Spec {
311
- };
312
- __decorate([
313
- (0, index_1.Prop)(),
314
- __metadata("design:type", String)
315
- ], Spec.prototype, "name", void 0);
316
- __decorate([
317
- (0, index_1.Prop)({
318
- type: A
319
- }),
320
- __metadata("design:type", A)
321
- ], Spec.prototype, "a", void 0);
322
- __decorate([
323
- (0, index_1.Prop)({
324
- type: B
325
- }),
326
- __metadata("design:type", B)
327
- ], Spec.prototype, "b", void 0);
328
- Spec = __decorate([
329
- (0, index_1.TypedModel)()
330
- ], Spec);
331
- const expected = {
332
- name: {
333
- type: String
334
- },
335
- a: {
336
- type: {
337
- name: {
338
- type: String
339
- }
340
- }
341
- },
342
- b: {
343
- type: {
344
- lastName: {
345
- type: String
346
- }
347
- }
348
- }
349
- };
350
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
351
- });
352
- it('works for nested schemas with objects inside', () => {
353
- let A = class A {
354
- };
355
- __decorate([
356
- (0, index_1.Prop)({
357
- type: {
358
- phoneNumber: { type: String }
359
- }
360
- }),
361
- __metadata("design:type", Object)
362
- ], A.prototype, "data", void 0);
363
- A = __decorate([
364
- (0, index_1.TypedModel)()
365
- ], A);
366
- let B = class B {
367
- };
368
- __decorate([
369
- (0, index_1.Prop)({ type: A, optional: true }),
370
- __metadata("design:type", A)
371
- ], B.prototype, "a", void 0);
372
- B = __decorate([
373
- (0, index_1.TypedModel)()
374
- ], B);
375
- let Spec = class Spec {
376
- };
377
- __decorate([
378
- (0, index_1.Prop)(),
379
- __metadata("design:type", String)
380
- ], Spec.prototype, "name", void 0);
381
- __decorate([
382
- (0, index_1.Prop)({
383
- type: B
384
- }),
385
- __metadata("design:type", B)
386
- ], Spec.prototype, "b", void 0);
387
- Spec = __decorate([
388
- (0, index_1.TypedModel)()
389
- ], Spec);
390
- const expected = {
391
- name: {
392
- type: String
393
- },
394
- b: {
395
- type: {
396
- a: {
397
- optional: true,
398
- type: {
399
- data: {
400
- type: {
401
- phoneNumber: {
402
- type: String
403
- }
404
- }
405
- }
406
- }
407
- }
408
- }
409
- }
410
- };
411
- expect((0, index_1.getSchemaForClass)(Spec)).toEqual(expected);
412
- });
413
- });
414
- });
415
- describe('getModelForClass', () => {
416
- it('works for flat classes', () => {
417
- let Spec = class Spec {
418
- };
419
- __decorate([
420
- (0, index_1.Prop)({ optional: true }),
421
- __metadata("design:type", String)
422
- ], Spec.prototype, "name", void 0);
423
- Spec = __decorate([
424
- (0, index_1.TypedModel)()
425
- ], Spec);
426
- const expected = (0, models_1.createModel)({
427
- name: 'Spec',
428
- schema: {
429
- name: {
430
- type: String,
431
- optional: true
432
- }
433
- }
434
- });
435
- expect((0, index_1.getModelForClass)(Spec).name).toEqual(expected.name);
436
- expect((0, index_1.getModelForClass)(Spec).getCleanSchema()).toEqual(expected.getCleanSchema());
437
- });
438
- it('works for nested models', () => {
439
- let A = class A {
440
- };
441
- __decorate([
442
- (0, index_1.Prop)({ optional: true }),
443
- __metadata("design:type", String)
444
- ], A.prototype, "name", void 0);
445
- A = __decorate([
446
- (0, index_1.TypedModel)()
447
- ], A);
448
- const AModel = (0, index_1.getModelForClass)(A);
449
- let Spec = class Spec {
450
- };
451
- __decorate([
452
- (0, index_1.Prop)({ type: AModel }),
453
- __metadata("design:type", A)
454
- ], Spec.prototype, "a", void 0);
455
- Spec = __decorate([
456
- (0, index_1.TypedModel)()
457
- ], Spec);
458
- const expected = (0, models_1.createModel)({
459
- name: 'Spec',
460
- schema: {
461
- a: {
462
- type: AModel
463
- }
464
- }
465
- });
466
- expect((0, index_1.getModelForClass)(Spec).name).toEqual(expected.name);
467
- expect((0, index_1.getModelForClass)(Spec).getCleanSchema()).toEqual(expected.getCleanSchema());
468
- });
469
- it('works for nested arrays of models', () => {
470
- let A = class A {
471
- };
472
- __decorate([
473
- (0, index_1.Prop)({ optional: true }),
474
- __metadata("design:type", String)
475
- ], A.prototype, "name", void 0);
476
- A = __decorate([
477
- (0, index_1.TypedModel)()
478
- ], A);
479
- const AModel = (0, index_1.getModelForClass)(A);
480
- let Spec = class Spec {
481
- };
482
- __decorate([
483
- (0, index_1.Prop)({ type: [AModel] }),
484
- __metadata("design:type", Array)
485
- ], Spec.prototype, "a", void 0);
486
- Spec = __decorate([
487
- (0, index_1.TypedModel)()
488
- ], Spec);
489
- const expected = (0, models_1.createModel)({
490
- name: 'Spec',
491
- schema: {
492
- a: {
493
- type: [AModel]
494
- }
495
- }
496
- });
497
- expect((0, index_1.getModelForClass)(Spec).name).toEqual(expected.name);
498
- expect((0, index_1.getModelForClass)(Spec).getCleanSchema()).toEqual(expected.getCleanSchema());
499
- });
500
- it('works for nested models together with nested classes', () => {
501
- let NestedModelClass = class NestedModelClass {
502
- };
503
- __decorate([
504
- (0, index_1.Prop)({ optional: true }),
505
- __metadata("design:type", String)
506
- ], NestedModelClass.prototype, "name", void 0);
507
- NestedModelClass = __decorate([
508
- (0, index_1.TypedModel)()
509
- ], NestedModelClass);
510
- class NestedClassClass {
511
- }
512
- __decorate([
513
- (0, index_1.Prop)({ type: { firstName: String, createdAt: Date } }),
514
- __metadata("design:type", Object)
515
- ], NestedClassClass.prototype, "data", void 0);
516
- const NestedModel = (0, index_1.getModelForClass)(NestedModelClass);
517
- let Spec = class Spec {
518
- };
519
- __decorate([
520
- (0, index_1.Prop)({ type: NestedModel }),
521
- __metadata("design:type", NestedModelClass)
522
- ], Spec.prototype, "a", void 0);
523
- __decorate([
524
- (0, index_1.Prop)({ type: NestedClassClass }),
525
- __metadata("design:type", NestedClassClass)
526
- ], Spec.prototype, "b", void 0);
527
- Spec = __decorate([
528
- (0, index_1.TypedModel)()
529
- ], Spec);
530
- const expected = (0, models_1.createModel)({
531
- name: 'Spec',
532
- schema: {
533
- a: {
534
- type: NestedModel
535
- },
536
- b: {
537
- type: {
538
- data: {
539
- type: {
540
- firstName: {
541
- type: String
542
- },
543
- createdAt: {
544
- type: Date
545
- }
546
- }
547
- }
548
- }
549
- }
550
- }
551
- });
552
- expect((0, index_1.getModelForClass)(Spec).name).toEqual(expected.name);
553
- expect((0, index_1.getModelForClass)(Spec).getCleanSchema()).toEqual(expected.getCleanSchema());
554
- });
555
- it('Should return the same object when calling getModelForClass multiple times', () => {
556
- let Spec = class Spec {
557
- };
558
- __decorate([
559
- (0, index_1.Prop)(),
560
- __metadata("design:type", String)
561
- ], Spec.prototype, "name", void 0);
562
- Spec = __decorate([
563
- (0, index_1.TypedModel)()
564
- ], Spec);
565
- const model = (0, index_1.getModelForClass)(Spec);
566
- expect((0, index_1.getModelForClass)(Spec)).toBe(model);
567
- });
568
- });
569
- describe('using resolvers', () => {
570
- it('allows passing resolvers to the model', () => {
571
- const exampleResolver = (0, resolvers_1.modelResolver)({
572
- returns: String,
573
- resolve: async (user, { title }) => {
574
- return `${title} ${user.firstName} ${user.lastName}`;
575
- }
576
- });
577
- let User = class User {
578
- };
579
- __decorate([
580
- (0, index_1.Prop)(),
581
- __metadata("design:type", String)
582
- ], User.prototype, "firstName", void 0);
583
- __decorate([
584
- (0, index_1.Prop)(),
585
- __metadata("design:type", String)
586
- ], User.prototype, "lastName", void 0);
587
- __decorate([
588
- (0, index_1.ResolverProp)(exampleResolver),
589
- __metadata("design:type", Object)
590
- ], User.prototype, "fullName", void 0);
591
- User = __decorate([
592
- (0, index_1.TypedModel)()
593
- ], User);
594
- const expected = (0, models_1.createModel)({
595
- name: 'User',
596
- schema: {
597
- firstName: {
598
- type: String
599
- },
600
- lastName: {
601
- type: String
602
- }
603
- },
604
- resolvers: {
605
- fullName: exampleResolver
606
- }
607
- });
608
- const model = (0, index_1.getModelForClass)(User);
609
- expect(model.name).toEqual(expected.name);
610
- expect(model.getCleanSchema()).toEqual(expected.getCleanSchema());
611
- expect(model.getResolvers()).toEqual(expected.getResolvers());
612
- });
613
- });
614
- describe('creating schemas', () => {
615
- it('allows creating multiple classes with the same name', () => {
616
- const create = () => {
617
- let Spec =
618
- // eslint-disable-next-line no-unused-vars
619
- class Spec {
620
- };
621
- __decorate([
622
- (0, index_1.Prop)(),
623
- __metadata("design:type", String)
624
- ], Spec.prototype, "name", void 0);
625
- Spec = __decorate([
626
- (0, index_1.TypedModel)()
627
- // eslint-disable-next-line no-unused-vars
628
- ], Spec);
629
- };
630
- create();
631
- create();
632
- });
633
- });
634
- describe('Typed model as arguments', () => {
635
- it('allows passing typed model as argument to resolvers', async () => {
636
- let ResolverParams = class ResolverParams {
637
- };
638
- __decorate([
639
- (0, index_1.Prop)(),
640
- __metadata("design:type", String)
641
- ], ResolverParams.prototype, "firstName", void 0);
642
- ResolverParams = __decorate([
643
- (0, index_1.TypedModel)()
644
- ], ResolverParams);
645
- let ResolverReturns = class ResolverReturns {
646
- };
647
- __decorate([
648
- (0, index_1.Prop)(),
649
- __metadata("design:type", String)
650
- ], ResolverReturns.prototype, "fullName", void 0);
651
- ResolverReturns = __decorate([
652
- (0, index_1.TypedModel)()
653
- ], ResolverReturns);
654
- const fullName = (0, resolvers_1.modelResolver)({
655
- params: ResolverParams,
656
- returns: ResolverReturns,
657
- async resolve(item, params) {
658
- return { fullName: `${params.firstName} ${item.lastName}` };
659
- }
660
- });
661
- let Person = class Person {
662
- };
663
- __decorate([
664
- (0, index_1.Prop)(),
665
- __metadata("design:type", String)
666
- ], Person.prototype, "lastName", void 0);
667
- __decorate([
668
- (0, index_1.ResolverProp)(fullName),
669
- __metadata("design:type", Object)
670
- ], Person.prototype, "fullName", void 0);
671
- Person = __decorate([
672
- (0, index_1.TypedModel)()
673
- ], Person);
674
- const model = (0, index_1.getModelForClass)(Person);
675
- const item = model.initItem({ lastName: 'Doe' });
676
- const result = await item.fullName({
677
- firstName: 'John'
678
- });
679
- expect(result.fullName).toBe('John Doe');
680
- });
681
- });
682
- });
@@ -1 +0,0 @@
1
- export {};