@technicity/data-service-generator 0.13.25 → 0.14.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.
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const globals_1 = require("@jest/globals");
7
- const strict_1 = __importDefault(require("node:assert/strict"));
8
- const runTransforms_1 = require("./runTransforms");
9
- (0, globals_1.describe)("runTransforms", () => {
10
- (0, globals_1.test)("should work", () => {
11
- const fields = [
12
- "id",
13
- {
14
- name: "business",
15
- as: "mainBusiness",
16
- fields: ["id", "name"],
17
- transform: (x) => {
18
- x.name = `TRANSFORMED_BUSINESS_NAME ${x.id}`;
19
- return x;
20
- }
21
- },
22
- {
23
- name: "sessionList",
24
- as: "mainSession",
25
- fields: [
26
- "id",
27
- {
28
- name: "deepNestedList",
29
- fields: ["id"],
30
- transform: (xs) => {
31
- return xs.map((x) => (x == null ? x : { ...x, id: x.id + 100 }));
32
- }
33
- },
34
- {
35
- name: "deepNestedList2",
36
- fields: ["id"],
37
- transform: (xs) => {
38
- return xs[0] ?? null;
39
- }
40
- }
41
- ],
42
- args: {
43
- $where: { valid: true, archived: false },
44
- $orderBy: { id: "desc" }
45
- },
46
- transform: (x) => {
47
- return x[0] ?? null;
48
- }
49
- },
50
- "name"
51
- ];
52
- const data = [
53
- {
54
- id: 1,
55
- mainBusiness: { id: 1, name: "My Business Name 1" },
56
- mainSession: [
57
- {
58
- id: 1,
59
- deepNestedList: [{ id: 1 }, null, { id: 2 }],
60
- deepNestedList2: [{ id: 1 }, null, { id: 2 }]
61
- },
62
- {
63
- id: 2,
64
- deepNestedList: [{ id: 1 }, null, { id: 2 }],
65
- deepNestedList2: [{ id: 1 }, null, { id: 2 }]
66
- }
67
- ],
68
- name: "FOO"
69
- },
70
- {
71
- id: 2,
72
- mainBusiness: { id: 2, name: "My Business Name 2" },
73
- mainSession: [
74
- {
75
- id: 1,
76
- deepNestedList: [{ id: 1 }, null, { id: 2 }],
77
- deepNestedList2: [{ id: 1 }, null, { id: 2 }]
78
- },
79
- {
80
- id: 2,
81
- deepNestedList: [{ id: 1 }, null, { id: 2 }],
82
- deepNestedList2: [{ id: 1 }, null, { id: 2 }]
83
- }
84
- ],
85
- name: "BAR"
86
- }
87
- ];
88
- (0, runTransforms_1.runTransforms)(data, fields);
89
- strict_1.default.deepEqual(data, [
90
- {
91
- id: 1,
92
- mainBusiness: { id: 1, name: "TRANSFORMED_BUSINESS_NAME 1" },
93
- mainSession: {
94
- id: 1,
95
- deepNestedList: [{ id: 101 }, null, { id: 102 }],
96
- deepNestedList2: { id: 1 }
97
- },
98
- name: "FOO"
99
- },
100
- {
101
- id: 2,
102
- mainBusiness: { id: 2, name: "TRANSFORMED_BUSINESS_NAME 2" },
103
- mainSession: {
104
- id: 1,
105
- deepNestedList: [{ id: 101 }, null, { id: 102 }],
106
- deepNestedList2: { id: 1 }
107
- },
108
- name: "BAR"
109
- }
110
- ]);
111
- });
112
- });