@antelopejs/interface-data-api 0.4.0 → 0.5.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/components.d.ts +15 -7
- package/dist/components.js +98 -645
- package/dist/components.js.map +1 -1
- package/dist/index.d.ts +41 -36
- package/dist/index.js +94 -92
- package/dist/index.js.map +1 -1
- package/dist/internal/computed.d.ts +6 -0
- package/dist/internal/computed.js +43 -0
- package/dist/internal/computed.js.map +1 -0
- package/dist/internal/controller-types.d.ts +19 -0
- package/dist/internal/controller-types.js +4 -0
- package/dist/internal/controller-types.js.map +1 -0
- package/dist/internal/default-filter.d.ts +4 -0
- package/dist/internal/default-filter.js +19 -0
- package/dist/internal/default-filter.js.map +1 -0
- package/dist/internal/deferred-joined-stream.d.ts +11 -0
- package/dist/internal/deferred-joined-stream.js +112 -0
- package/dist/internal/deferred-joined-stream.js.map +1 -0
- package/dist/internal/field-types.d.ts +183 -0
- package/dist/internal/field-types.js +4 -0
- package/dist/internal/field-types.js.map +1 -0
- package/dist/internal/filters.d.ts +4 -0
- package/dist/internal/filters.js +15 -0
- package/dist/internal/filters.js.map +1 -0
- package/dist/internal/foreign.d.ts +6 -0
- package/dist/internal/foreign.js +116 -0
- package/dist/internal/foreign.js.map +1 -0
- package/dist/internal/guards.d.ts +20 -0
- package/dist/internal/guards.js +74 -0
- package/dist/internal/guards.js.map +1 -0
- package/dist/internal/joined.d.ts +28 -0
- package/dist/internal/joined.js +127 -0
- package/dist/internal/joined.js.map +1 -0
- package/dist/internal/list.d.ts +16 -0
- package/dist/internal/list.js +178 -0
- package/dist/internal/list.js.map +1 -0
- package/dist/internal/meta-records.d.ts +17 -0
- package/dist/internal/meta-records.js +73 -0
- package/dist/internal/meta-records.js.map +1 -0
- package/dist/internal/properties.d.ts +4 -0
- package/dist/internal/properties.js +43 -0
- package/dist/internal/properties.js.map +1 -0
- package/dist/internal/table-reference.d.ts +11 -0
- package/dist/internal/table-reference.js +46 -0
- package/dist/internal/table-reference.js.map +1 -0
- package/dist/internal/tables.d.ts +18 -0
- package/dist/internal/tables.js +37 -0
- package/dist/internal/tables.js.map +1 -0
- package/dist/internal/validation.d.ts +11 -0
- package/dist/internal/validation.js +88 -0
- package/dist/internal/validation.js.map +1 -0
- package/dist/metadata.d.ts +27 -228
- package/dist/metadata.js +61 -188
- package/dist/metadata.js.map +1 -1
- package/dist/tests/components/access_control.test.js +20 -20
- package/dist/tests/components/access_control.test.js.map +1 -1
- package/dist/tests/components/computed.test.js +28 -30
- package/dist/tests/components/computed.test.js.map +1 -1
- package/dist/tests/components/cross_instance.test.js +8 -6
- package/dist/tests/components/cross_instance.test.js.map +1 -1
- package/dist/tests/components/deferred_joined.test.js +56 -53
- package/dist/tests/components/deferred_joined.test.js.map +1 -1
- package/dist/tests/components/filter_options.test.js +8 -7
- package/dist/tests/components/filter_options.test.js.map +1 -1
- package/dist/tests/components/foreign_computed.test.js +14 -16
- package/dist/tests/components/foreign_computed.test.js.map +1 -1
- package/dist/tests/components/foreign_joined.test.js +19 -27
- package/dist/tests/components/foreign_joined.test.js.map +1 -1
- package/dist/tests/components/joined.test.js +41 -45
- package/dist/tests/components/joined.test.js.map +1 -1
- package/dist/tests/components/listable.test.js +59 -58
- package/dist/tests/components/listable.test.js.map +1 -1
- package/dist/tests/components/localized_sort.test.js +10 -11
- package/dist/tests/components/localized_sort.test.js.map +1 -1
- package/dist/tests/components/mandatory.test.js +25 -25
- package/dist/tests/components/mandatory.test.js.map +1 -1
- package/dist/tests/components/modifier_key.test.js +19 -18
- package/dist/tests/components/modifier_key.test.js.map +1 -1
- package/dist/tests/components/parse_body.test.d.ts +1 -0
- package/dist/tests/components/parse_body.test.js +75 -0
- package/dist/tests/components/parse_body.test.js.map +1 -0
- package/dist/tests/components/parsed_value.test.js +23 -21
- package/dist/tests/components/parsed_value.test.js.map +1 -1
- package/dist/tests/components/partial_edit.test.js +33 -32
- package/dist/tests/components/partial_edit.test.js.map +1 -1
- package/dist/tests/components/per_action_access.test.js +12 -12
- package/dist/tests/components/per_action_access.test.js.map +1 -1
- package/dist/tests/components/validator.test.js +45 -37
- package/dist/tests/components/validator.test.js.map +1 -1
- package/dist/tests/helpers/other-instance.d.ts +11 -1
- package/dist/tests/helpers/other-instance.js +27 -5
- package/dist/tests/helpers/other-instance.js.map +1 -1
- package/dist/tests/index/get_guard.test.js +6 -6
- package/dist/tests/index/get_guard.test.js.map +1 -1
- package/dist/tests/index/inheritance.test.js +10 -9
- package/dist/tests/index/inheritance.test.js.map +1 -1
- package/dist/tests/index/routes.test.js +40 -44
- package/dist/tests/index/routes.test.js.map +1 -1
- package/dist/tests/integration.test.d.ts +1 -1
- package/dist/tests/integration.test.js +53 -729
- package/dist/tests/integration.test.js.map +1 -1
- package/dist/tests/internal/http.d.ts +23 -0
- package/dist/tests/internal/http.js +35 -0
- package/dist/tests/internal/http.js.map +1 -0
- package/dist/tests/internal/shop-api.d.ts +1 -0
- package/dist/tests/internal/shop-api.js +331 -0
- package/dist/tests/internal/shop-api.js.map +1 -0
- package/dist/tests/internal/shop-schema.d.ts +154 -0
- package/dist/tests/internal/shop-schema.js +387 -0
- package/dist/tests/internal/shop-schema.js.map +1 -0
- package/dist/tests/utils.d.ts +5 -5
- package/dist/tests/utils.js +1 -3
- package/dist/tests/utils.js.map +1 -1
- package/dist/tests/utils.test.js +10 -11
- package/dist/tests/utils.test.js.map +1 -1
- package/docs/3.routes.md +8 -3
- package/docs/5.validators.md +12 -3
- package/docs/8.filters.md +7 -3
- package/package.json +14 -3
- package/skills/data-api-interface/SKILL.md +4 -0
- package/skills/data-api-interface/cases.json +99 -0
|
@@ -1,716 +1,31 @@
|
|
|
1
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
16
3
|
const chai_1 = require("chai");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
4
|
+
const common_1 = require("@antelopejs/interface-database-decorators/modifiers/common");
|
|
5
|
+
const http_1 = require("./internal/http");
|
|
6
|
+
require("./internal/shop-api");
|
|
7
|
+
const shop_schema_1 = require("./internal/shop-schema");
|
|
21
8
|
const utils_1 = require("./utils");
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
.replace(/\.test\.(ts|js)$/, "");
|
|
25
|
-
const customerTableName = `customers-${currentTestName}`;
|
|
26
|
-
const productTableName = `products-${currentTestName}`;
|
|
27
|
-
const orderTableName = `orders-${currentTestName}`;
|
|
28
|
-
const orderItemTableName = `order_items-${currentTestName}`;
|
|
29
|
-
const schemaName = "default";
|
|
30
|
-
let Customer = class Customer extends interface_database_decorators_1.Table {
|
|
31
|
-
};
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, interface_database_decorators_1.Index)(),
|
|
34
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], Customer.prototype, "email", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
39
|
-
__metadata("design:type", String)
|
|
40
|
-
], Customer.prototype, "firstName", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
43
|
-
__metadata("design:type", String)
|
|
44
|
-
], Customer.prototype, "lastName", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
47
|
-
__metadata("design:type", String)
|
|
48
|
-
], Customer.prototype, "phone", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
51
|
-
__metadata("design:type", String)
|
|
52
|
-
], Customer.prototype, "address", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
55
|
-
__metadata("design:type", String)
|
|
56
|
-
], Customer.prototype, "city", void 0);
|
|
57
|
-
__decorate([
|
|
58
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
59
|
-
__metadata("design:type", String)
|
|
60
|
-
], Customer.prototype, "postalCode", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
63
|
-
__metadata("design:type", String)
|
|
64
|
-
], Customer.prototype, "country", void 0);
|
|
65
|
-
__decorate([
|
|
66
|
-
(0, interface_database_decorators_1.Field)("date"),
|
|
67
|
-
__metadata("design:type", Date)
|
|
68
|
-
], Customer.prototype, "registrationDate", void 0);
|
|
69
|
-
__decorate([
|
|
70
|
-
(0, interface_database_decorators_1.Field)("boolean"),
|
|
71
|
-
__metadata("design:type", Boolean)
|
|
72
|
-
], Customer.prototype, "isActive", void 0);
|
|
73
|
-
__decorate([
|
|
74
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
75
|
-
__metadata("design:type", Number)
|
|
76
|
-
], Customer.prototype, "loyaltyPoints", void 0);
|
|
77
|
-
__decorate([
|
|
78
|
-
(0, interface_database_decorators_1.Field)(["string"]),
|
|
79
|
-
__metadata("design:type", Array)
|
|
80
|
-
], Customer.prototype, "preferences", void 0);
|
|
81
|
-
Customer = __decorate([
|
|
82
|
-
(0, interface_database_decorators_1.RegisterTable)(customerTableName, schemaName)
|
|
83
|
-
], Customer);
|
|
84
|
-
let Product = class Product extends interface_database_decorators_1.Table {
|
|
85
|
-
};
|
|
86
|
-
__decorate([
|
|
87
|
-
(0, interface_database_decorators_1.Index)(),
|
|
88
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
89
|
-
__metadata("design:type", String)
|
|
90
|
-
], Product.prototype, "sku", void 0);
|
|
91
|
-
__decorate([
|
|
92
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
93
|
-
__metadata("design:type", String)
|
|
94
|
-
], Product.prototype, "name", void 0);
|
|
95
|
-
__decorate([
|
|
96
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
97
|
-
__metadata("design:type", String)
|
|
98
|
-
], Product.prototype, "description", void 0);
|
|
99
|
-
__decorate([
|
|
100
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
101
|
-
__metadata("design:type", Number)
|
|
102
|
-
], Product.prototype, "price", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
105
|
-
__metadata("design:type", Number)
|
|
106
|
-
], Product.prototype, "costPrice", void 0);
|
|
107
|
-
__decorate([
|
|
108
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
109
|
-
__metadata("design:type", Number)
|
|
110
|
-
], Product.prototype, "stockQuantity", void 0);
|
|
111
|
-
__decorate([
|
|
112
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
113
|
-
__metadata("design:type", String)
|
|
114
|
-
], Product.prototype, "category", void 0);
|
|
115
|
-
__decorate([
|
|
116
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
117
|
-
__metadata("design:type", String)
|
|
118
|
-
], Product.prototype, "brand", void 0);
|
|
119
|
-
__decorate([
|
|
120
|
-
(0, interface_database_decorators_1.Field)(["string"]),
|
|
121
|
-
__metadata("design:type", Array)
|
|
122
|
-
], Product.prototype, "tags", void 0);
|
|
123
|
-
__decorate([
|
|
124
|
-
(0, interface_database_decorators_1.Field)(["string"]),
|
|
125
|
-
__metadata("design:type", Array)
|
|
126
|
-
], Product.prototype, "images", void 0);
|
|
127
|
-
__decorate([
|
|
128
|
-
(0, interface_database_decorators_1.Field)("boolean"),
|
|
129
|
-
__metadata("design:type", Boolean)
|
|
130
|
-
], Product.prototype, "isActive", void 0);
|
|
131
|
-
__decorate([
|
|
132
|
-
(0, interface_database_decorators_1.Field)("date"),
|
|
133
|
-
__metadata("design:type", Date)
|
|
134
|
-
], Product.prototype, "createdAt", void 0);
|
|
135
|
-
__decorate([
|
|
136
|
-
(0, interface_database_decorators_1.Field)("date"),
|
|
137
|
-
__metadata("design:type", Date)
|
|
138
|
-
], Product.prototype, "updatedAt", void 0);
|
|
139
|
-
Product = __decorate([
|
|
140
|
-
(0, interface_database_decorators_1.RegisterTable)(productTableName, schemaName)
|
|
141
|
-
], Product);
|
|
142
|
-
let Order = class Order extends interface_database_decorators_1.Table {
|
|
143
|
-
};
|
|
144
|
-
__decorate([
|
|
145
|
-
(0, interface_database_decorators_1.Index)(),
|
|
146
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
147
|
-
__metadata("design:type", String)
|
|
148
|
-
], Order.prototype, "orderNumber", void 0);
|
|
149
|
-
__decorate([
|
|
150
|
-
(0, interface_database_decorators_1.Index)(),
|
|
151
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
152
|
-
(0, interface_database_decorators_1.Relation)({ to: () => Customer }),
|
|
153
|
-
__metadata("design:type", String)
|
|
154
|
-
], Order.prototype, "customerId", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
157
|
-
__metadata("design:type", String)
|
|
158
|
-
], Order.prototype, "status", void 0);
|
|
159
|
-
__decorate([
|
|
160
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
161
|
-
__metadata("design:type", Number)
|
|
162
|
-
], Order.prototype, "totalAmount", void 0);
|
|
163
|
-
__decorate([
|
|
164
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
165
|
-
__metadata("design:type", Number)
|
|
166
|
-
], Order.prototype, "shippingCost", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
169
|
-
__metadata("design:type", Number)
|
|
170
|
-
], Order.prototype, "taxAmount", void 0);
|
|
171
|
-
__decorate([
|
|
172
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
173
|
-
__metadata("design:type", Number)
|
|
174
|
-
], Order.prototype, "discountAmount", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
177
|
-
__metadata("design:type", Number)
|
|
178
|
-
], Order.prototype, "finalAmount", void 0);
|
|
179
|
-
__decorate([
|
|
180
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
181
|
-
__metadata("design:type", String)
|
|
182
|
-
], Order.prototype, "shippingAddress", void 0);
|
|
183
|
-
__decorate([
|
|
184
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
185
|
-
__metadata("design:type", String)
|
|
186
|
-
], Order.prototype, "billingAddress", void 0);
|
|
187
|
-
__decorate([
|
|
188
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
189
|
-
__metadata("design:type", String)
|
|
190
|
-
], Order.prototype, "paymentMethod", void 0);
|
|
191
|
-
__decorate([
|
|
192
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
193
|
-
__metadata("design:type", String)
|
|
194
|
-
], Order.prototype, "notes", void 0);
|
|
195
|
-
__decorate([
|
|
196
|
-
(0, interface_database_decorators_1.Field)("date"),
|
|
197
|
-
__metadata("design:type", Date)
|
|
198
|
-
], Order.prototype, "createdAt", void 0);
|
|
199
|
-
__decorate([
|
|
200
|
-
(0, interface_database_decorators_1.Field)("date"),
|
|
201
|
-
__metadata("design:type", Date)
|
|
202
|
-
], Order.prototype, "updatedAt", void 0);
|
|
203
|
-
Order = __decorate([
|
|
204
|
-
(0, interface_database_decorators_1.RegisterTable)(orderTableName, schemaName)
|
|
205
|
-
], Order);
|
|
206
|
-
let OrderItem = class OrderItem extends interface_database_decorators_1.Table {
|
|
207
|
-
};
|
|
208
|
-
__decorate([
|
|
209
|
-
(0, interface_database_decorators_1.Index)(),
|
|
210
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
211
|
-
(0, interface_database_decorators_1.Relation)({ to: () => Order }),
|
|
212
|
-
__metadata("design:type", String)
|
|
213
|
-
], OrderItem.prototype, "orderId", void 0);
|
|
214
|
-
__decorate([
|
|
215
|
-
(0, interface_database_decorators_1.Index)(),
|
|
216
|
-
(0, interface_database_decorators_1.Field)("string"),
|
|
217
|
-
(0, interface_database_decorators_1.Relation)({ to: () => Product }),
|
|
218
|
-
__metadata("design:type", String)
|
|
219
|
-
], OrderItem.prototype, "productId", void 0);
|
|
220
|
-
__decorate([
|
|
221
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
222
|
-
__metadata("design:type", Number)
|
|
223
|
-
], OrderItem.prototype, "quantity", void 0);
|
|
224
|
-
__decorate([
|
|
225
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
226
|
-
__metadata("design:type", Number)
|
|
227
|
-
], OrderItem.prototype, "unitPrice", void 0);
|
|
228
|
-
__decorate([
|
|
229
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
230
|
-
__metadata("design:type", Number)
|
|
231
|
-
], OrderItem.prototype, "totalPrice", void 0);
|
|
232
|
-
__decorate([
|
|
233
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
234
|
-
__metadata("design:type", Number)
|
|
235
|
-
], OrderItem.prototype, "finalPrice", void 0);
|
|
236
|
-
__decorate([
|
|
237
|
-
(0, interface_database_decorators_1.Field)("number"),
|
|
238
|
-
__metadata("design:type", Number)
|
|
239
|
-
], OrderItem.prototype, "discount", void 0);
|
|
240
|
-
OrderItem = __decorate([
|
|
241
|
-
(0, interface_database_decorators_1.RegisterTable)(orderItemTableName, schemaName)
|
|
242
|
-
], OrderItem);
|
|
243
|
-
class CustomerModel extends (0, interface_database_decorators_1.BasicDataModel)(Customer, customerTableName) {
|
|
9
|
+
function plainRow(row) {
|
|
10
|
+
return row ? (0, common_1.toPlainData)(row) : {};
|
|
244
11
|
}
|
|
245
|
-
class ProductModel extends (0, interface_database_decorators_1.BasicDataModel)(Product, productTableName) {
|
|
246
|
-
}
|
|
247
|
-
class OrderModel extends (0, interface_database_decorators_1.BasicDataModel)(Order, orderTableName) {
|
|
248
|
-
}
|
|
249
|
-
class OrderItemModel extends (0, interface_database_decorators_1.BasicDataModel)(OrderItem, orderItemTableName) {
|
|
250
|
-
}
|
|
251
|
-
const testCustomers = [
|
|
252
|
-
{
|
|
253
|
-
firstName: "Bob",
|
|
254
|
-
lastName: "Bobberson",
|
|
255
|
-
email: "bob.bobberson@email.com",
|
|
256
|
-
phone: "+1234567890",
|
|
257
|
-
address: "123 Poutine Square",
|
|
258
|
-
city: "Quebec City",
|
|
259
|
-
postalCode: "G1K 1K1",
|
|
260
|
-
country: "Canada",
|
|
261
|
-
registrationDate: new Date("2023-01-15"),
|
|
262
|
-
isActive: true,
|
|
263
|
-
loyaltyPoints: 150,
|
|
264
|
-
preferences: ["electronics", "books"],
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
firstName: "Alice",
|
|
268
|
-
lastName: "Alison",
|
|
269
|
-
email: "alice.alison@email.com",
|
|
270
|
-
phone: "+33123456789",
|
|
271
|
-
address: "456 Baguette Street",
|
|
272
|
-
city: "Lyon",
|
|
273
|
-
postalCode: "69001",
|
|
274
|
-
country: "France",
|
|
275
|
-
registrationDate: new Date("2023-03-20"),
|
|
276
|
-
isActive: true,
|
|
277
|
-
loyaltyPoints: 75,
|
|
278
|
-
preferences: ["fashion", "home"],
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
firstName: "John",
|
|
282
|
-
lastName: "Doe",
|
|
283
|
-
email: "john.doe@email.com",
|
|
284
|
-
phone: "+32123456789",
|
|
285
|
-
address: "789 Fries Avenue",
|
|
286
|
-
city: "Brussels",
|
|
287
|
-
postalCode: "1000",
|
|
288
|
-
country: "Belgium",
|
|
289
|
-
registrationDate: new Date("2023-06-10"),
|
|
290
|
-
isActive: false,
|
|
291
|
-
loyaltyPoints: 0,
|
|
292
|
-
preferences: ["sports"],
|
|
293
|
-
},
|
|
294
|
-
];
|
|
295
|
-
const testProducts = [
|
|
296
|
-
{
|
|
297
|
-
sku: "LAPTOP-001",
|
|
298
|
-
name: "Gaming Laptop",
|
|
299
|
-
description: "High performance gaming laptop",
|
|
300
|
-
price: 1299.99,
|
|
301
|
-
costPrice: 899.99,
|
|
302
|
-
stockQuantity: 15,
|
|
303
|
-
category: "electronics",
|
|
304
|
-
brand: "TechCorp",
|
|
305
|
-
tags: ["gaming", "laptop", "high-performance"],
|
|
306
|
-
images: ["laptop1.jpg", "laptop2.jpg"],
|
|
307
|
-
isActive: true,
|
|
308
|
-
createdAt: new Date("2023-01-01"),
|
|
309
|
-
updatedAt: new Date("2023-12-01"),
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
sku: "PHONE-002",
|
|
313
|
-
name: "Premium Smartphone",
|
|
314
|
-
description: "Professional camera smartphone",
|
|
315
|
-
price: 899.99,
|
|
316
|
-
costPrice: 599.99,
|
|
317
|
-
stockQuantity: 25,
|
|
318
|
-
category: "electronics",
|
|
319
|
-
brand: "MobileTech",
|
|
320
|
-
tags: ["smartphone", "camera", "premium"],
|
|
321
|
-
images: ["phone1.jpg", "phone2.jpg"],
|
|
322
|
-
isActive: true,
|
|
323
|
-
createdAt: new Date("2023-02-15"),
|
|
324
|
-
updatedAt: new Date("2023-11-15"),
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
sku: "BOOK-003",
|
|
328
|
-
name: "The Soldering Bible",
|
|
329
|
-
description: "Complete guide to soldering components",
|
|
330
|
-
price: 49.99,
|
|
331
|
-
costPrice: 25.99,
|
|
332
|
-
stockQuantity: 50,
|
|
333
|
-
category: "books",
|
|
334
|
-
brand: "TechBooks",
|
|
335
|
-
tags: ["soldering", "electronics", "education"],
|
|
336
|
-
images: ["book1.jpg"],
|
|
337
|
-
isActive: true,
|
|
338
|
-
createdAt: new Date("2023-03-01"),
|
|
339
|
-
updatedAt: new Date("2023-10-01"),
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
sku: "SHIRT-004",
|
|
343
|
-
name: "Organic Cotton T-shirt",
|
|
344
|
-
description: "Comfortable organic cotton t-shirt",
|
|
345
|
-
price: 29.99,
|
|
346
|
-
costPrice: 15.99,
|
|
347
|
-
stockQuantity: 100,
|
|
348
|
-
category: "fashion",
|
|
349
|
-
brand: "EcoFashion",
|
|
350
|
-
tags: ["cotton", "organic", "comfortable"],
|
|
351
|
-
images: ["shirt1.jpg", "shirt2.jpg"],
|
|
352
|
-
isActive: true,
|
|
353
|
-
createdAt: new Date("2023-04-10"),
|
|
354
|
-
updatedAt: new Date("2023-09-10"),
|
|
355
|
-
},
|
|
356
|
-
];
|
|
357
12
|
describe("Integration tests", () => {
|
|
358
13
|
before(async () => {
|
|
359
|
-
await initializeDatabase();
|
|
14
|
+
await (0, shop_schema_1.initializeDatabase)();
|
|
360
15
|
});
|
|
361
16
|
beforeEach(async () => {
|
|
362
|
-
await cleanTables();
|
|
17
|
+
await (0, shop_schema_1.cleanTables)();
|
|
363
18
|
});
|
|
364
|
-
it("workflow complete of customer management", async () => await
|
|
365
|
-
it("workflow complete of product management", async () => await
|
|
366
|
-
it("workflow complete of order management", async () => await
|
|
367
|
-
it("stock management and automatic update", async () => await
|
|
368
|
-
it("advanced search and filtering", async () => await
|
|
369
|
-
it("client preferences management and recommendations", async () => await
|
|
370
|
-
it("error management and complex validation", async () => await
|
|
371
|
-
after(async () => { });
|
|
19
|
+
it("workflow complete of customer management", async () => await expectCustomerWorkflow());
|
|
20
|
+
it("workflow complete of product management", async () => await expectProductWorkflow());
|
|
21
|
+
it("workflow complete of order management", async () => await expectOrderWorkflow());
|
|
22
|
+
it("stock management and automatic update", async () => await expectStockUpdates());
|
|
23
|
+
it("advanced search and filtering", async () => await expectSearchAndFilters());
|
|
24
|
+
it("client preferences management and recommendations", async () => await expectClientPreferences());
|
|
25
|
+
it("error management and complex validation", async () => await expectErrorsAndValidation());
|
|
372
26
|
});
|
|
373
|
-
|
|
374
|
-
};
|
|
375
|
-
__decorate([
|
|
376
|
-
(0, metadata_1.ModelReference)(),
|
|
377
|
-
(0, interface_database_decorators_1.Model)(CustomerModel),
|
|
378
|
-
__metadata("design:type", CustomerModel)
|
|
379
|
-
], _CustomerAPI.prototype, "customerModel", void 0);
|
|
380
|
-
__decorate([
|
|
381
|
-
(0, metadata_1.Listable)(),
|
|
382
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
383
|
-
__metadata("design:type", String)
|
|
384
|
-
], _CustomerAPI.prototype, "_id", void 0);
|
|
385
|
-
__decorate([
|
|
386
|
-
(0, metadata_1.Listable)(),
|
|
387
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
388
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
389
|
-
(0, metadata_1.Validator)((value) => typeof value === "string" && value.length >= 2),
|
|
390
|
-
__metadata("design:type", String)
|
|
391
|
-
], _CustomerAPI.prototype, "firstName", void 0);
|
|
392
|
-
__decorate([
|
|
393
|
-
(0, metadata_1.Listable)(),
|
|
394
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
395
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
396
|
-
(0, metadata_1.Validator)((value) => typeof value === "string" && value.length >= 2),
|
|
397
|
-
__metadata("design:type", String)
|
|
398
|
-
], _CustomerAPI.prototype, "lastName", void 0);
|
|
399
|
-
__decorate([
|
|
400
|
-
(0, metadata_1.Listable)(),
|
|
401
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
402
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
403
|
-
(0, metadata_1.Validator)((value) => {
|
|
404
|
-
if (typeof value !== "string")
|
|
405
|
-
return false;
|
|
406
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
407
|
-
return emailRegex.test(value);
|
|
408
|
-
}),
|
|
409
|
-
__metadata("design:type", String)
|
|
410
|
-
], _CustomerAPI.prototype, "email", void 0);
|
|
411
|
-
__decorate([
|
|
412
|
-
(0, metadata_1.Listable)(),
|
|
413
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
414
|
-
(0, metadata_1.Validator)((value) => typeof value === "string" && value.length >= 10),
|
|
415
|
-
__metadata("design:type", String)
|
|
416
|
-
], _CustomerAPI.prototype, "phone", void 0);
|
|
417
|
-
__decorate([
|
|
418
|
-
(0, metadata_1.Listable)(),
|
|
419
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
420
|
-
__metadata("design:type", String)
|
|
421
|
-
], _CustomerAPI.prototype, "address", void 0);
|
|
422
|
-
__decorate([
|
|
423
|
-
(0, metadata_1.Listable)(),
|
|
424
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
425
|
-
__metadata("design:type", String)
|
|
426
|
-
], _CustomerAPI.prototype, "city", void 0);
|
|
427
|
-
__decorate([
|
|
428
|
-
(0, metadata_1.Listable)(),
|
|
429
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
430
|
-
__metadata("design:type", String)
|
|
431
|
-
], _CustomerAPI.prototype, "postalCode", void 0);
|
|
432
|
-
__decorate([
|
|
433
|
-
(0, metadata_1.Listable)(),
|
|
434
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
435
|
-
__metadata("design:type", String)
|
|
436
|
-
], _CustomerAPI.prototype, "country", void 0);
|
|
437
|
-
__decorate([
|
|
438
|
-
(0, metadata_1.Listable)(),
|
|
439
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
440
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
441
|
-
__metadata("design:type", Date)
|
|
442
|
-
], _CustomerAPI.prototype, "registrationDate", void 0);
|
|
443
|
-
__decorate([
|
|
444
|
-
(0, metadata_1.Listable)(),
|
|
445
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
446
|
-
__metadata("design:type", Boolean)
|
|
447
|
-
], _CustomerAPI.prototype, "isActive", void 0);
|
|
448
|
-
__decorate([
|
|
449
|
-
(0, metadata_1.Listable)(),
|
|
450
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
451
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
452
|
-
__metadata("design:type", Number)
|
|
453
|
-
], _CustomerAPI.prototype, "loyaltyPoints", void 0);
|
|
454
|
-
__decorate([
|
|
455
|
-
(0, metadata_1.Listable)(),
|
|
456
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
457
|
-
__metadata("design:type", Array)
|
|
458
|
-
], _CustomerAPI.prototype, "preferences", void 0);
|
|
459
|
-
_CustomerAPI = __decorate([
|
|
460
|
-
(0, interface_data_api_1.RegisterDataController)()
|
|
461
|
-
], _CustomerAPI);
|
|
462
|
-
let _ProductAPI = class _ProductAPI extends (0, interface_data_api_1.DataController)(Product, interface_data_api_1.DefaultRoutes.All, (0, interface_api_1.Controller)("/products")) {
|
|
463
|
-
};
|
|
464
|
-
__decorate([
|
|
465
|
-
(0, metadata_1.ModelReference)(),
|
|
466
|
-
(0, interface_database_decorators_1.Model)(ProductModel),
|
|
467
|
-
__metadata("design:type", ProductModel)
|
|
468
|
-
], _ProductAPI.prototype, "productModel", void 0);
|
|
469
|
-
__decorate([
|
|
470
|
-
(0, metadata_1.Listable)(),
|
|
471
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
472
|
-
__metadata("design:type", String)
|
|
473
|
-
], _ProductAPI.prototype, "_id", void 0);
|
|
474
|
-
__decorate([
|
|
475
|
-
(0, metadata_1.Listable)(),
|
|
476
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
477
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
478
|
-
(0, metadata_1.Validator)((value) => typeof value === "string" && value.length >= 3),
|
|
479
|
-
__metadata("design:type", String)
|
|
480
|
-
], _ProductAPI.prototype, "sku", void 0);
|
|
481
|
-
__decorate([
|
|
482
|
-
(0, metadata_1.Listable)(),
|
|
483
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
484
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
485
|
-
(0, metadata_1.Validator)((value) => typeof value === "string" && value.length >= 3),
|
|
486
|
-
__metadata("design:type", String)
|
|
487
|
-
], _ProductAPI.prototype, "name", void 0);
|
|
488
|
-
__decorate([
|
|
489
|
-
(0, metadata_1.Listable)(),
|
|
490
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
491
|
-
__metadata("design:type", String)
|
|
492
|
-
], _ProductAPI.prototype, "description", void 0);
|
|
493
|
-
__decorate([
|
|
494
|
-
(0, metadata_1.Listable)(),
|
|
495
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
496
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
497
|
-
(0, metadata_1.Validator)((value) => typeof value === "number" && value >= 0),
|
|
498
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
499
|
-
__metadata("design:type", Number)
|
|
500
|
-
], _ProductAPI.prototype, "price", void 0);
|
|
501
|
-
__decorate([
|
|
502
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.WriteOnly),
|
|
503
|
-
(0, metadata_1.Validator)((value) => typeof value === "number" && value >= 0),
|
|
504
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
505
|
-
__metadata("design:type", Number)
|
|
506
|
-
], _ProductAPI.prototype, "costPrice", void 0);
|
|
507
|
-
__decorate([
|
|
508
|
-
(0, metadata_1.Listable)(),
|
|
509
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
510
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
511
|
-
(0, metadata_1.Validator)((value) => typeof value === "number" && value >= 0),
|
|
512
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
513
|
-
__metadata("design:type", Number)
|
|
514
|
-
], _ProductAPI.prototype, "stockQuantity", void 0);
|
|
515
|
-
__decorate([
|
|
516
|
-
(0, metadata_1.Listable)(),
|
|
517
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
518
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
519
|
-
__metadata("design:type", String)
|
|
520
|
-
], _ProductAPI.prototype, "category", void 0);
|
|
521
|
-
__decorate([
|
|
522
|
-
(0, metadata_1.Listable)(),
|
|
523
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
524
|
-
__metadata("design:type", String)
|
|
525
|
-
], _ProductAPI.prototype, "brand", void 0);
|
|
526
|
-
__decorate([
|
|
527
|
-
(0, metadata_1.Listable)(),
|
|
528
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
529
|
-
__metadata("design:type", Array)
|
|
530
|
-
], _ProductAPI.prototype, "tags", void 0);
|
|
531
|
-
__decorate([
|
|
532
|
-
(0, metadata_1.Listable)(),
|
|
533
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
534
|
-
__metadata("design:type", Array)
|
|
535
|
-
], _ProductAPI.prototype, "images", void 0);
|
|
536
|
-
__decorate([
|
|
537
|
-
(0, metadata_1.Listable)(),
|
|
538
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
539
|
-
__metadata("design:type", Boolean)
|
|
540
|
-
], _ProductAPI.prototype, "isActive", void 0);
|
|
541
|
-
__decorate([
|
|
542
|
-
(0, metadata_1.Listable)(),
|
|
543
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
544
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
545
|
-
__metadata("design:type", Date)
|
|
546
|
-
], _ProductAPI.prototype, "createdAt", void 0);
|
|
547
|
-
__decorate([
|
|
548
|
-
(0, metadata_1.Listable)(),
|
|
549
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
550
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
551
|
-
__metadata("design:type", Date)
|
|
552
|
-
], _ProductAPI.prototype, "updatedAt", void 0);
|
|
553
|
-
_ProductAPI = __decorate([
|
|
554
|
-
(0, interface_data_api_1.RegisterDataController)()
|
|
555
|
-
], _ProductAPI);
|
|
556
|
-
let _OrderAPI = class _OrderAPI extends (0, interface_data_api_1.DataController)(Order, interface_data_api_1.DefaultRoutes.All, (0, interface_api_1.Controller)("/orders")) {
|
|
557
|
-
};
|
|
558
|
-
__decorate([
|
|
559
|
-
(0, metadata_1.ModelReference)(),
|
|
560
|
-
(0, interface_database_decorators_1.Model)(OrderModel),
|
|
561
|
-
__metadata("design:type", OrderModel)
|
|
562
|
-
], _OrderAPI.prototype, "orderModel", void 0);
|
|
563
|
-
__decorate([
|
|
564
|
-
(0, metadata_1.Listable)(),
|
|
565
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
566
|
-
__metadata("design:type", String)
|
|
567
|
-
], _OrderAPI.prototype, "_id", void 0);
|
|
568
|
-
__decorate([
|
|
569
|
-
(0, metadata_1.Listable)(),
|
|
570
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
571
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
572
|
-
__metadata("design:type", String)
|
|
573
|
-
], _OrderAPI.prototype, "orderNumber", void 0);
|
|
574
|
-
__decorate([
|
|
575
|
-
(0, metadata_1.Listable)(),
|
|
576
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
577
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
578
|
-
__metadata("design:type", String)
|
|
579
|
-
], _OrderAPI.prototype, "customerId", void 0);
|
|
580
|
-
__decorate([
|
|
581
|
-
(0, metadata_1.Listable)(),
|
|
582
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
583
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
584
|
-
(0, metadata_1.Validator)((value) => ["pending", "processing", "shipped", "delivered", "cancelled"].includes(value)),
|
|
585
|
-
__metadata("design:type", String)
|
|
586
|
-
], _OrderAPI.prototype, "status", void 0);
|
|
587
|
-
__decorate([
|
|
588
|
-
(0, metadata_1.Listable)(),
|
|
589
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
590
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
591
|
-
__metadata("design:type", Number)
|
|
592
|
-
], _OrderAPI.prototype, "totalAmount", void 0);
|
|
593
|
-
__decorate([
|
|
594
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
595
|
-
__metadata("design:type", Number)
|
|
596
|
-
], _OrderAPI.prototype, "shippingCost", void 0);
|
|
597
|
-
__decorate([
|
|
598
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
599
|
-
__metadata("design:type", Number)
|
|
600
|
-
], _OrderAPI.prototype, "taxAmount", void 0);
|
|
601
|
-
__decorate([
|
|
602
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
603
|
-
__metadata("design:type", Number)
|
|
604
|
-
], _OrderAPI.prototype, "discountAmount", void 0);
|
|
605
|
-
__decorate([
|
|
606
|
-
(0, metadata_1.Listable)(),
|
|
607
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
608
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
609
|
-
__metadata("design:type", Number)
|
|
610
|
-
], _OrderAPI.prototype, "finalAmount", void 0);
|
|
611
|
-
__decorate([
|
|
612
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
613
|
-
__metadata("design:type", String)
|
|
614
|
-
], _OrderAPI.prototype, "shippingAddress", void 0);
|
|
615
|
-
__decorate([
|
|
616
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
617
|
-
__metadata("design:type", String)
|
|
618
|
-
], _OrderAPI.prototype, "billingAddress", void 0);
|
|
619
|
-
__decorate([
|
|
620
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
621
|
-
__metadata("design:type", String)
|
|
622
|
-
], _OrderAPI.prototype, "paymentMethod", void 0);
|
|
623
|
-
__decorate([
|
|
624
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
625
|
-
__metadata("design:type", String)
|
|
626
|
-
], _OrderAPI.prototype, "notes", void 0);
|
|
627
|
-
__decorate([
|
|
628
|
-
(0, metadata_1.Listable)(),
|
|
629
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
630
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
631
|
-
__metadata("design:type", Date)
|
|
632
|
-
], _OrderAPI.prototype, "createdAt", void 0);
|
|
633
|
-
__decorate([
|
|
634
|
-
(0, metadata_1.Listable)(),
|
|
635
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
636
|
-
(0, metadata_1.Sortable)({ noIndex: true }),
|
|
637
|
-
__metadata("design:type", Date)
|
|
638
|
-
], _OrderAPI.prototype, "updatedAt", void 0);
|
|
639
|
-
_OrderAPI = __decorate([
|
|
640
|
-
(0, interface_data_api_1.RegisterDataController)()
|
|
641
|
-
], _OrderAPI);
|
|
642
|
-
let _OrderItemAPI = class _OrderItemAPI extends (0, interface_data_api_1.DataController)(OrderItem, interface_data_api_1.DefaultRoutes.All, (0, interface_api_1.Controller)("/order-items")) {
|
|
643
|
-
};
|
|
644
|
-
__decorate([
|
|
645
|
-
(0, metadata_1.ModelReference)(),
|
|
646
|
-
(0, interface_database_decorators_1.Model)(OrderItemModel),
|
|
647
|
-
__metadata("design:type", OrderItemModel)
|
|
648
|
-
], _OrderItemAPI.prototype, "orderItemModel", void 0);
|
|
649
|
-
__decorate([
|
|
650
|
-
(0, metadata_1.Listable)(),
|
|
651
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
652
|
-
__metadata("design:type", String)
|
|
653
|
-
], _OrderItemAPI.prototype, "_id", void 0);
|
|
654
|
-
__decorate([
|
|
655
|
-
(0, metadata_1.Listable)(),
|
|
656
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
657
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
658
|
-
__metadata("design:type", String)
|
|
659
|
-
], _OrderItemAPI.prototype, "orderId", void 0);
|
|
660
|
-
__decorate([
|
|
661
|
-
(0, metadata_1.Listable)(),
|
|
662
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
663
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
664
|
-
__metadata("design:type", String)
|
|
665
|
-
], _OrderItemAPI.prototype, "productId", void 0);
|
|
666
|
-
__decorate([
|
|
667
|
-
(0, metadata_1.Listable)(),
|
|
668
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
669
|
-
(0, metadata_1.Mandatory)("new", "edit"),
|
|
670
|
-
(0, metadata_1.Validator)((value) => typeof value === "number" && value > 0),
|
|
671
|
-
__metadata("design:type", Number)
|
|
672
|
-
], _OrderItemAPI.prototype, "quantity", void 0);
|
|
673
|
-
__decorate([
|
|
674
|
-
(0, metadata_1.Listable)(),
|
|
675
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadOnly),
|
|
676
|
-
__metadata("design:type", Number)
|
|
677
|
-
], _OrderItemAPI.prototype, "unitPrice", void 0);
|
|
678
|
-
__decorate([
|
|
679
|
-
(0, metadata_1.Access)(metadata_1.AccessMode.ReadWrite),
|
|
680
|
-
__metadata("design:type", Number)
|
|
681
|
-
], _OrderItemAPI.prototype, "discount", void 0);
|
|
682
|
-
_OrderItemAPI = __decorate([
|
|
683
|
-
(0, interface_data_api_1.RegisterDataController)()
|
|
684
|
-
], _OrderItemAPI);
|
|
685
|
-
async function initializeDatabase() {
|
|
686
|
-
await (0, interface_database_decorators_1.RegisterSchema)(schemaName);
|
|
687
|
-
}
|
|
688
|
-
async function cleanTables() {
|
|
689
|
-
const db = (0, utils_1.getSchemaInstance)(schemaName);
|
|
690
|
-
await Promise.all([
|
|
691
|
-
db.table(customerTableName).delete(),
|
|
692
|
-
db.table(productTableName).delete(),
|
|
693
|
-
db.table(orderTableName).delete(),
|
|
694
|
-
db.table(orderItemTableName).delete(),
|
|
695
|
-
]);
|
|
696
|
-
}
|
|
697
|
-
async function createTestData() {
|
|
698
|
-
const db = (0, utils_1.getSchemaInstance)(schemaName);
|
|
699
|
-
const customerModel = new CustomerModel(db);
|
|
700
|
-
const productModel = new ProductModel(db);
|
|
701
|
-
const orderModel = new OrderModel(db);
|
|
702
|
-
const customerResults = await customerModel.insert(testCustomers);
|
|
703
|
-
const productResults = await productModel.insert(testProducts);
|
|
704
|
-
return {
|
|
705
|
-
customerIds: customerResults,
|
|
706
|
-
productIds: productResults,
|
|
707
|
-
customerModel,
|
|
708
|
-
productModel,
|
|
709
|
-
orderModel,
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
async function workflowCustomerManagement() {
|
|
713
|
-
const { customerModel } = await createTestData();
|
|
27
|
+
async function expectCustomerWorkflow() {
|
|
28
|
+
const { customerModel } = await (0, shop_schema_1.createTestData)();
|
|
714
29
|
const newCustomer = {
|
|
715
30
|
firstName: "Sophie",
|
|
716
31
|
lastName: "Marrone",
|
|
@@ -726,12 +41,12 @@ async function workflowCustomerManagement() {
|
|
|
726
41
|
};
|
|
727
42
|
const createResponse = await (0, utils_1.newRequest)("customers", newCustomer);
|
|
728
43
|
(0, chai_1.expect)(createResponse.status).to.equal(200);
|
|
729
|
-
const created =
|
|
44
|
+
const created = await (0, http_1.readJson)(createResponse);
|
|
730
45
|
(0, chai_1.expect)(created._id).to.be.a("string");
|
|
731
46
|
const createdIds = [created._id];
|
|
732
47
|
const getResponse = await (0, utils_1.getRequest)("customers", { id: createdIds[0] });
|
|
733
48
|
(0, chai_1.expect)(getResponse.status).to.equal(200);
|
|
734
|
-
const customer =
|
|
49
|
+
const customer = await (0, http_1.readJson)(getResponse);
|
|
735
50
|
await (0, utils_1.validateObject)(customer, newCustomer, [
|
|
736
51
|
"firstName",
|
|
737
52
|
"lastName",
|
|
@@ -756,11 +71,11 @@ async function workflowCustomerManagement() {
|
|
|
756
71
|
limit: "2",
|
|
757
72
|
});
|
|
758
73
|
(0, chai_1.expect)(listResponse.status).to.equal(200);
|
|
759
|
-
const listData =
|
|
74
|
+
const listData = await (0, http_1.readJson)(listResponse);
|
|
760
75
|
(0, chai_1.expect)(listData.results).to.have.length(2);
|
|
761
76
|
}
|
|
762
|
-
async function
|
|
763
|
-
const { productModel } = await createTestData();
|
|
77
|
+
async function expectProductWorkflow() {
|
|
78
|
+
const { productModel } = await (0, shop_schema_1.createTestData)();
|
|
764
79
|
const newProduct = {
|
|
765
80
|
sku: "HEADPHONES-005",
|
|
766
81
|
name: "Casque audio sans fil",
|
|
@@ -776,7 +91,7 @@ async function workflowProductManagement() {
|
|
|
776
91
|
};
|
|
777
92
|
const createResponse = await (0, utils_1.newRequest)("products", newProduct);
|
|
778
93
|
(0, chai_1.expect)(createResponse.status).to.equal(200);
|
|
779
|
-
const createdIds = [(await
|
|
94
|
+
const createdIds = [(await (0, http_1.readJson)(createResponse))._id];
|
|
780
95
|
const stockUpdate = { ...newProduct, stockQuantity: 25 };
|
|
781
96
|
const updateResponse = await (0, utils_1.editRequest)("products", stockUpdate, {
|
|
782
97
|
id: createdIds[0],
|
|
@@ -790,17 +105,17 @@ async function workflowProductManagement() {
|
|
|
790
105
|
limit: "3",
|
|
791
106
|
});
|
|
792
107
|
(0, chai_1.expect)(listResponse.status).to.equal(200);
|
|
793
|
-
const listData =
|
|
108
|
+
const listData = await (0, http_1.readJson)(listResponse);
|
|
794
109
|
(0, chai_1.expect)(listData.results).to.have.length(3);
|
|
795
110
|
const categoryResponse = await (0, utils_1.listRequest)("products", {
|
|
796
111
|
category: "electronics",
|
|
797
112
|
});
|
|
798
113
|
(0, chai_1.expect)(categoryResponse.status).to.equal(200);
|
|
799
|
-
const categoryData =
|
|
114
|
+
const categoryData = await (0, http_1.readJson)(categoryResponse);
|
|
800
115
|
(0, chai_1.expect)(categoryData.results.length).to.be.greaterThan(0);
|
|
801
116
|
}
|
|
802
|
-
async function
|
|
803
|
-
const { customerIds, productIds, orderModel } = await createTestData();
|
|
117
|
+
async function expectOrderWorkflow() {
|
|
118
|
+
const { customerIds, productIds, orderModel } = await (0, shop_schema_1.createTestData)();
|
|
804
119
|
const orderData = {
|
|
805
120
|
orderNumber: "ORD-2024-001",
|
|
806
121
|
customerId: customerIds[0],
|
|
@@ -817,7 +132,7 @@ async function workflowOrderManagement() {
|
|
|
817
132
|
};
|
|
818
133
|
const orderResponse = await (0, utils_1.newRequest)("orders", orderData);
|
|
819
134
|
(0, chai_1.expect)(orderResponse.status).to.equal(200);
|
|
820
|
-
const orderIds = [(await
|
|
135
|
+
const orderIds = [(await (0, http_1.readJson)(orderResponse))._id];
|
|
821
136
|
const orderItem1 = {
|
|
822
137
|
orderId: orderIds[0],
|
|
823
138
|
productId: productIds[0],
|
|
@@ -862,11 +177,14 @@ async function workflowOrderManagement() {
|
|
|
862
177
|
const finalOrder = await orderModel.get(orderIds[0]);
|
|
863
178
|
(0, chai_1.expect)(finalOrder?.status).to.equal("processing");
|
|
864
179
|
}
|
|
865
|
-
async function
|
|
866
|
-
const { productIds, productModel } = await createTestData();
|
|
180
|
+
async function expectStockUpdates() {
|
|
181
|
+
const { productIds, productModel } = await (0, shop_schema_1.createTestData)();
|
|
867
182
|
const initialProduct = await productModel.get(productIds[0]);
|
|
868
183
|
const initialStock = initialProduct?.stockQuantity || 0;
|
|
869
|
-
const stockReduction = {
|
|
184
|
+
const stockReduction = {
|
|
185
|
+
...plainRow(initialProduct),
|
|
186
|
+
stockQuantity: initialStock - 3,
|
|
187
|
+
};
|
|
870
188
|
const updateResponse = await (0, utils_1.editRequest)("products", stockReduction, {
|
|
871
189
|
id: productIds[0],
|
|
872
190
|
});
|
|
@@ -878,7 +196,10 @@ async function stockManagementAndAutomaticUpdate() {
|
|
|
878
196
|
id: productIds[0],
|
|
879
197
|
});
|
|
880
198
|
(0, chai_1.expect)(invalidResponse.status).to.equal(400);
|
|
881
|
-
const restock = {
|
|
199
|
+
const restock = {
|
|
200
|
+
...plainRow(initialProduct),
|
|
201
|
+
stockQuantity: initialStock + 10,
|
|
202
|
+
};
|
|
882
203
|
const restockResponse = await (0, utils_1.editRequest)("products", restock, {
|
|
883
204
|
id: productIds[0],
|
|
884
205
|
});
|
|
@@ -886,15 +207,15 @@ async function stockManagementAndAutomaticUpdate() {
|
|
|
886
207
|
const restockedProduct = await productModel.get(productIds[0]);
|
|
887
208
|
(0, chai_1.expect)(restockedProduct?.stockQuantity).to.equal(initialStock + 10);
|
|
888
209
|
}
|
|
889
|
-
async function
|
|
890
|
-
await createTestData();
|
|
210
|
+
async function expectSearchAndFilters() {
|
|
211
|
+
await (0, shop_schema_1.createTestData)();
|
|
891
212
|
const categoryResponse = await (0, utils_1.listRequest)("products", {
|
|
892
213
|
category: "electronics",
|
|
893
214
|
sortKey: "price",
|
|
894
215
|
sortDirection: "desc",
|
|
895
216
|
});
|
|
896
217
|
(0, chai_1.expect)(categoryResponse.status).to.equal(200);
|
|
897
|
-
const categoryData =
|
|
218
|
+
const categoryData = await (0, http_1.readJson)(categoryResponse);
|
|
898
219
|
(0, chai_1.expect)(categoryData.results.length).to.be.greaterThan(0);
|
|
899
220
|
const activeCustomersResponse = await (0, utils_1.listRequest)("customers", {
|
|
900
221
|
isActive: "true",
|
|
@@ -902,14 +223,14 @@ async function advancedSearchAndFiltering() {
|
|
|
902
223
|
sortDirection: "desc",
|
|
903
224
|
});
|
|
904
225
|
(0, chai_1.expect)(activeCustomersResponse.status).to.equal(200);
|
|
905
|
-
const activeCustomersData =
|
|
226
|
+
const activeCustomersData = await (0, http_1.readJson)(activeCustomersResponse);
|
|
906
227
|
(0, chai_1.expect)(activeCustomersData.results.length).to.be.greaterThan(0);
|
|
907
228
|
const paginatedResponse = await (0, utils_1.listRequest)("products", {
|
|
908
229
|
limit: "2",
|
|
909
230
|
offset: "1",
|
|
910
231
|
});
|
|
911
232
|
(0, chai_1.expect)(paginatedResponse.status).to.equal(200);
|
|
912
|
-
const paginatedData =
|
|
233
|
+
const paginatedData = await (0, http_1.readJson)(paginatedResponse);
|
|
913
234
|
(0, chai_1.expect)(paginatedData.results).to.have.length(2);
|
|
914
235
|
(0, chai_1.expect)(paginatedData.total).to.be.greaterThan(2);
|
|
915
236
|
const pendingOrdersResponse = await (0, utils_1.listRequest)("orders", {
|
|
@@ -919,11 +240,14 @@ async function advancedSearchAndFiltering() {
|
|
|
919
240
|
});
|
|
920
241
|
(0, chai_1.expect)(pendingOrdersResponse.status).to.equal(200);
|
|
921
242
|
}
|
|
922
|
-
async function
|
|
923
|
-
const { customerIds, customerModel } = await createTestData();
|
|
243
|
+
async function expectClientPreferences() {
|
|
244
|
+
const { customerIds, customerModel } = await (0, shop_schema_1.createTestData)();
|
|
924
245
|
const customer = await customerModel.get(customerIds[0]);
|
|
925
246
|
const newPreferences = ["electronics", "gaming", "tech"];
|
|
926
|
-
const preferenceUpdate = {
|
|
247
|
+
const preferenceUpdate = {
|
|
248
|
+
...plainRow(customer),
|
|
249
|
+
preferences: newPreferences,
|
|
250
|
+
};
|
|
927
251
|
const updateResponse = await (0, utils_1.editRequest)("customers", preferenceUpdate, {
|
|
928
252
|
id: customerIds[0],
|
|
929
253
|
});
|
|
@@ -936,9 +260,9 @@ async function clientPreferencesManagement() {
|
|
|
936
260
|
sortDirection: "asc",
|
|
937
261
|
});
|
|
938
262
|
(0, chai_1.expect)(electronicsResponse.status).to.equal(200);
|
|
939
|
-
const electronicsData =
|
|
263
|
+
const electronicsData = await (0, http_1.readJson)(electronicsResponse);
|
|
940
264
|
(0, chai_1.expect)(electronicsData.results.length).to.be.greaterThan(0);
|
|
941
|
-
const loyaltyUpdate = { ...updatedCustomer, loyaltyPoints: 200 };
|
|
265
|
+
const loyaltyUpdate = { ...plainRow(updatedCustomer), loyaltyPoints: 200 };
|
|
942
266
|
const loyaltyResponse = await (0, utils_1.editRequest)("customers", loyaltyUpdate, {
|
|
943
267
|
id: customerIds[0],
|
|
944
268
|
});
|
|
@@ -946,7 +270,7 @@ async function clientPreferencesManagement() {
|
|
|
946
270
|
const customerWithLoyalty = await customerModel.get(customerIds[0]);
|
|
947
271
|
(0, chai_1.expect)(customerWithLoyalty?.loyaltyPoints).to.equal(200);
|
|
948
272
|
}
|
|
949
|
-
async function
|
|
273
|
+
async function expectErrorsAndValidation() {
|
|
950
274
|
const invalidCustomer = {
|
|
951
275
|
firstName: "Test",
|
|
952
276
|
lastName: "User",
|
|
@@ -984,7 +308,7 @@ async function errorManagementAndComplexValidation() {
|
|
|
984
308
|
(0, chai_1.expect)(invalidQuantityResponse.status).to.equal(400);
|
|
985
309
|
const quantityError = await invalidQuantityResponse.text();
|
|
986
310
|
(0, chai_1.expect)(quantityError).to.include("quantity");
|
|
987
|
-
const { customerIds } = await createTestData();
|
|
311
|
+
const { customerIds } = await (0, shop_schema_1.createTestData)();
|
|
988
312
|
const invalidStatusUpdate = { status: "invalid_status" };
|
|
989
313
|
const invalidStatusResponse = await (0, utils_1.editRequest)("orders", invalidStatusUpdate, { id: customerIds[0] });
|
|
990
314
|
(0, chai_1.expect)(invalidStatusResponse.status).to.equal(400);
|