|
1
|
/** |
|
2
|
* Test fixtures for entity discovery integration tests. |
|
3
|
* These joiner configs simulate real Product and Order modules |
|
4
|
* with simplified schemas for testing purposes. |
|
5
|
*/ |
|
6
|
|
|
7
|
/** |
|
8
|
* Simplified Product schema based on the real Product module schema. |
|
9
|
* Includes common field types: ID, String, Boolean, DateTime, JSON, enums, and relationships. |
|
10
|
*/ |
|
11
|
export const productSchema = ` |
|
12
|
enum ProductStatus { |
|
13
|
draft |
|
14
|
proposed |
|
15
|
published |
|
16
|
rejected |
|
17
|
} |
|
18
|
|
|
19
|
type SalesChannel { |
|
20
|
id: ID! |
|
21
|
name: String! |
|
22
|
description: String |
|
23
|
is_disabled: Boolean! |
|
24
|
metadata: JSON |
|
25
|
created_at: DateTime! |
|
26
|
updated_at: DateTime! |
|
27
|
deleted_at: DateTime |
|
28
|
} |
|
29
|
|
|
30
|
type Product { |
|
31
|
id: ID! |
|
32
|
title: String! |
|
33
|
handle: String! |
|
34
|
subtitle: String |
|
35
|
description: String |
|
36
|
is_giftcard: Boolean! |
|
37
|
status: ProductStatus! |
|
38
|
thumbnail: String |
|
39
|
width: Float |
|
40
|
weight: Float |
|
41
|
length: Float |
|
42
|
height: Float |
|
43
|
origin_country: String |
|
44
|
hs_code: String |
|
45
|
mid_code: String |
|
46
|
material: String |
|
47
|
collection: ProductCollection |
|
48
|
collection_id: String |
|
49
|
type: ProductType |
|
50
|
type_id: String |
|
51
|
tags: [ProductTag!]! |
|
52
|
sales_channels: [SalesChannel] |
|
53
|
variants: [ProductVariant!]! |
|
54
|
options: [ProductOption!]! |
|
55
|
images: [ProductImage!]! |
|
56
|
discountable: Boolean |
|
57
|
external_id: String |
|
58
|
created_at: DateTime! |
|
59
|
updated_at: DateTime! |
|
60
|
deleted_at: DateTime |
|
61
|
metadata: JSON |
|
62
|
raw_price: JSON |
|
63
|
raw_compare_at_price: JSON |
|
64
|
category_link: String |
|
65
|
} |
|
66
|
|
|
67
|
type ProductVariant { |
|
68
|
id: ID! |
|
69
|
title: String! |
|
70
|
sku: String |
|
71
|
barcode: String |
|
72
|
ean: String |
|
73
|
upc: String |
|
74
|
allow_backorder: Boolean! |
|
75
|
manage_inventory: Boolean! |
|
76
|
requires_shipping: Boolean! |
|
77
|
hs_code: String |
|
78
|
origin_country: String |
|
79
|
mid_code: String |
|
80
|
material: String |
|
81
|
weight: Float |
|
82
|
length: Float |
|
83
|
height: Float |
|
84
|
width: Float |
|
85
|
options: [ProductOptionValue!]! |
|
86
|
images: [ProductImage!]! |
|
87
|
thumbnail: String |
|
88
|
metadata: JSON |
|
89
|
product: Product |
|
90
|
product_id: String |
|
91
|
variant_rank: Int |
|
92
|
created_at: DateTime! |
|
93
|
updated_at: DateTime! |
|
94
|
deleted_at: DateTime |
|
95
|
} |
|
96
|
|
|
97
|
type ProductCategory { |
|
98
|
id: ID! |
|
99
|
name: String! |
|
100
|
description: String! |
|
101
|
handle: String! |
|
102
|
is_active: Boolean! |
|
103
|
is_internal: Boolean! |
|
104
|
rank: Int! |
|
105
|
metadata: JSON |
|
106
|
parent_category: ProductCategory |
|
107
|
parent_category_id: String |
|
108
|
category_children: [ProductCategory!]! |
|
109
|
products: [Product!]! |
|
110
|
created_at: DateTime! |
|
111
|
updated_at: DateTime! |
|
112
|
deleted_at: DateTime |
|
113
|
} |
|
114
|
|
|
115
|
type ProductTag { |
|
116
|
id: ID! |
|
117
|
value: String! |
|
118
|
metadata: JSON |
|
119
|
products: [Product] |
|
120
|
} |
|
121
|
|
|
122
|
type ProductCollection { |
|
123
|
id: ID! |
|
124
|
title: String! |
|
125
|
handle: String! |
|
126
|
metadata: JSON |
|
127
|
created_at: DateTime! |
|
128
|
updated_at: DateTime! |
|
129
|
deleted_at: DateTime |
|
130
|
products: [Product] |
|
131
|
} |
|
132
|
|
|
133
|
type ProductType { |
|
134
|
id: ID! |
|
135
|
value: String! |
|
136
|
metadata: JSON |
|
137
|
created_at: DateTime! |
|
138
|
updated_at: DateTime! |
|
139
|
deleted_at: DateTime |
|
140
|
} |
|
141
|
|
|
142
|
type ProductOption { |
|
143
|
id: ID! |
|
144
|
title: String! |
|
145
|
product: Product |
|
146
|
product_id: String |
|
147
|
values: [ProductOptionValue!]! |
|
148
|
metadata: JSON |
|
149
|
created_at: DateTime! |
|
150
|
updated_at: DateTime! |
|
151
|
deleted_at: DateTime |
|
152
|
} |
|
153
|
|
|
154
|
type ProductImage { |
|
155
|
id: ID! |
|
156
|
url: String! |
|
157
|
rank: Int! |
|
158
|
metadata: JSON |
|
159
|
created_at: DateTime! |
|
160
|
updated_at: DateTime! |
|
161
|
deleted_at: DateTime |
|
162
|
} |
|
163
|
|
|
164
|
type ProductOptionValue { |
|
165
|
id: ID! |
|
166
|
value: String! |
|
167
|
option: ProductOption |
|
168
|
option_id: String |
|
169
|
metadata: JSON |
|
170
|
created_at: DateTime! |
|
171
|
updated_at: DateTime! |
|
172
|
deleted_at: DateTime |
|
173
|
} |
|
174
|
` |
|
175
|
|
|
176
|
/** |
|
177
|
* Simplified Order schema based on the real Order module schema. |
|
178
|
* Includes common patterns: enums, status fields, totals, addresses, and relationships. |
|
179
|
*/ |
|
180
|
export const orderSchema = ` |
|
181
|
enum OrderStatus { |
|
182
|
pending |
|
183
|
completed |
|
184
|
draft |
|
185
|
archived |
|
186
|
canceled |
|
187
|
requires_action |
|
188
|
} |
|
189
|
|
|
190
|
enum PaymentStatus { |
|
191
|
not_paid |
|
192
|
awaiting |
|
193
|
authorized |
|
194
|
partially_authorized |
|
195
|
captured |
|
196
|
partially_captured |
|
197
|
partially_refunded |
|
198
|
refunded |
|
199
|
canceled |
|
200
|
requires_action |
|
201
|
} |
|
202
|
|
|
203
|
enum FulfillmentStatus { |
|
204
|
not_fulfilled |
|
205
|
partially_fulfilled |
|
206
|
fulfilled |
|
207
|
partially_shipped |
|
208
|
shipped |
|
209
|
partially_delivered |
|
210
|
delivered |
|
211
|
canceled |
|
212
|
} |
|
213
|
|
|
214
|
type OrderSummary { |
|
215
|
pending_difference: Float |
|
216
|
current_order_total: Float |
|
217
|
original_order_total: Float |
|
218
|
transaction_total: Float |
|
219
|
paid_total: Float |
|
220
|
refunded_total: Float |
|
221
|
} |
|
222
|
|
|
223
|
type OrderAddress { |
|
224
|
id: ID! |
|
225
|
customer_id: String |
|
226
|
first_name: String |
|
227
|
last_name: String |
|
228
|
phone: String |
|
229
|
company: String |
|
230
|
address_1: String |
|
231
|
address_2: String |
|
232
|
city: String |
|
233
|
country_code: String |
|
234
|
province: String |
|
235
|
postal_code: String |
|
236
|
metadata: JSON |
|
237
|
created_at: DateTime |
|
238
|
updated_at: DateTime |
|
239
|
} |
|
240
|
|
|
241
|
type OrderLineItem { |
|
242
|
id: ID! |
|
243
|
title: String! |
|
244
|
subtitle: String |
|
245
|
thumbnail: String |
|
246
|
variant_id: String |
|
247
|
product_id: String |
|
248
|
product_title: String |
|
249
|
variant_sku: String |
|
250
|
variant_barcode: String |
|
251
|
variant_title: String |
|
252
|
requires_shipping: Boolean! |
|
253
|
is_discountable: Boolean! |
|
254
|
is_tax_inclusive: Boolean! |
|
255
|
unit_price: Float! |
|
256
|
quantity: Int! |
|
257
|
total: Float |
|
258
|
subtotal: Float |
|
259
|
tax_total: Float |
|
260
|
discount_total: Float |
|
261
|
created_at: DateTime! |
|
262
|
updated_at: DateTime! |
|
263
|
metadata: JSON |
|
264
|
} |
|
265
|
|
|
266
|
type OrderShippingMethod { |
|
267
|
id: ID! |
|
268
|
order_id: String! |
|
269
|
name: String! |
|
270
|
description: String |
|
271
|
amount: Float |
|
272
|
is_tax_inclusive: Boolean |
|
273
|
shipping_option_id: String |
|
274
|
data: JSON |
|
275
|
metadata: JSON |
|
276
|
created_at: DateTime |
|
277
|
updated_at: DateTime |
|
278
|
total: Float |
|
279
|
subtotal: Float |
|
280
|
tax_total: Float |
|
281
|
} |
|
282
|
|
|
283
|
type OrderTransaction { |
|
284
|
id: ID! |
|
285
|
order_id: String! |
|
286
|
amount: Float! |
|
287
|
currency_code: String! |
|
288
|
reference: String! |
|
289
|
reference_id: String! |
|
290
|
metadata: JSON |
|
291
|
created_at: DateTime! |
|
292
|
updated_at: DateTime! |
|
293
|
} |
|
294
|
|
|
295
|
type Region { |
|
296
|
id: ID! |
|
297
|
name: String! |
|
298
|
currency_code: String! |
|
299
|
metadata: JSON |
|
300
|
created_at: DateTime! |
|
301
|
updated_at: DateTime! |
|
302
|
deleted_at: DateTime |
|
303
|
} |
|
304
|
|
|
305
|
type Order { |
|
306
|
id: ID! |
|
307
|
version: Int! |
|
308
|
status: OrderStatus! |
|
309
|
region_id: String |
|
310
|
region: Region |
|
311
|
customer_id: String |
|
312
|
display_id: String |
|
313
|
sales_channel_id: String |
|
314
|
email: String |
|
315
|
currency_code: String! |
|
316
|
shipping_address: OrderAddress |
|
317
|
billing_address: OrderAddress |
|
318
|
items: [OrderLineItem] |
|
319
|
shipping_methods: [OrderShippingMethod] |
|
320
|
transactions: [OrderTransaction] |
|
321
|
summary: OrderSummary |
|
322
|
metadata: JSON |
|
323
|
canceled_at: DateTime |
|
324
|
created_at: DateTime! |
|
325
|
updated_at: DateTime! |
|
326
|
total: Float! |
|
327
|
subtotal: Float! |
|
328
|
tax_total: Float! |
|
329
|
discount_total: Float! |
|
330
|
shipping_total: Float! |
|
331
|
payment_status: PaymentStatus! |
|
332
|
fulfillment_status: FulfillmentStatus! |
|
333
|
raw_total: JSON |
|
334
|
raw_subtotal: JSON |
|
335
|
order_change: String |
|
336
|
customer_link: String |
|
337
|
} |
|
338
|
` |
|
339
|
|
|
340
|
/** |
|
341
|
* Minimal Customer schema for testing entity discovery with simple types. |
|
342
|
*/ |
|
343
|
export const customerSchema = ` |
|
344
|
type CustomerGroup { |
|
345
|
id: ID! |
|
346
|
name: String! |
|
347
|
metadata: JSON |
|
348
|
created_at: DateTime! |
|
349
|
updated_at: DateTime! |
|
350
|
} |
|
351
|
|
|
352
|
type Customer { |
|
353
|
id: ID! |
|
354
|
email: String! |
|
355
|
first_name: String |
|
356
|
last_name: String |
|
357
|
phone: String |
|
358
|
company_name: String |
|
359
|
has_account: Boolean! |
|
360
|
groups: [CustomerGroup] |
|
361
|
metadata: JSON |
|
362
|
created_at: DateTime! |
|
363
|
updated_at: DateTime! |
|
364
|
deleted_at: DateTime |
|
365
|
address_link: String |
|
366
|
raw_metadata: JSON |
|
367
|
} |
|
368
|
` |
|
369
|
|
|
370
|
// Entity model stubs |
|
371
|
export const Product = { name: "Product" } |
|
372
|
export const ProductVariant = { name: "ProductVariant" } |
|
373
|
export const ProductOption = { name: "ProductOption" } |
|
374
|
export const ProductOptionValue = { name: "ProductOptionValue" } |
|
375
|
export const ProductType = { name: "ProductType" } |
|
376
|
export const ProductTag = { name: "ProductTag" } |
|
377
|
export const ProductCollection = { name: "ProductCollection" } |
|
378
|
export const ProductCategory = { name: "ProductCategory" } |
|
379
|
export const ProductImage = { name: "ProductImage" } |
|
380
|
export const SalesChannel = { name: "SalesChannel" } |
|
381
|
|
|
382
|
export const Order = { name: "Order" } |
|
383
|
export const OrderAddress = { name: "OrderAddress" } |
|
384
|
export const OrderLineItem = { name: "OrderLineItem" } |
|
385
|
export const OrderShippingMethod = { name: "OrderShippingMethod" } |
|
386
|
export const OrderTransaction = { name: "OrderTransaction" } |
|
387
|
export const Region = { name: "Region" } |
|
388
|
|
|
389
|
export const Customer = { name: "Customer" } |
|
390
|
export const CustomerGroup = { name: "CustomerGroup" } |
|
391
|
|
|
392
|
/** |
|
393
|
* Creates joiner configs for the test Product module. |
|
394
|
*/ |
|
395
|
export function createProductJoinerConfig() { |
|
396
|
return { |
|
397
|
serviceName: "productModuleService", |
|
398
|
primaryKeys: ["id", "handle"], |
|
399
|
linkableKeys: { |
|
400
|
product_id: "Product", |
|
401
|
variant_id: "ProductVariant", |
|
402
|
product_option_id: "ProductOption", |
|
403
|
product_type_id: "ProductType", |
|
404
|
product_tag_id: "ProductTag", |
|
405
|
product_collection_id: "ProductCollection", |
|
406
|
product_category_id: "ProductCategory", |
|
407
|
}, |
|
408
|
alias: [ |
|
409
|
{ |
|
410
|
name: ["product", "products"], |
|
411
|
entity: "Product", |
|
412
|
args: { methodSuffix: "Products" }, |
|
413
|
}, |
|
414
|
{ |
|
415
|
name: ["product_variant", "product_variants", "variant", "variants"], |
|
416
|
entity: "ProductVariant", |
|
417
|
args: { methodSuffix: "ProductVariants" }, |
|
418
|
}, |
|
419
|
], |
|
420
|
schema: productSchema, |
|
421
|
} |
|
422
|
} |
|
423
|
|
|
424
|
/** |
|
425
|
* Creates joiner configs for the test Order module. |
|
426
|
*/ |
|
427
|
export function createOrderJoinerConfig() { |
|
428
|
return { |
|
429
|
serviceName: "orderModuleService", |
|
430
|
primaryKeys: ["id"], |
|
431
|
linkableKeys: { |
|
432
|
order_id: "Order", |
|
433
|
order_address_id: "OrderAddress", |
|
434
|
order_line_item_id: "OrderLineItem", |
|
435
|
}, |
|
436
|
alias: [ |
|
437
|
{ |
|
438
|
name: ["order", "orders"], |
|
439
|
entity: "Order", |
|
440
|
args: { methodSuffix: "Orders" }, |
|
441
|
}, |
|
442
|
], |
|
443
|
schema: orderSchema, |
|
444
|
} |
|
445
|
} |
|
446
|
|
|
447
|
/** |
|
448
|
* Creates joiner configs for the test Customer module. |
|
449
|
*/ |
|
450
|
export function createCustomerJoinerConfig() { |
|
451
|
return { |
|
452
|
serviceName: "customerModuleService", |
|
453
|
primaryKeys: ["id"], |
|
454
|
linkableKeys: { |
|
455
|
customer_id: "Customer", |
|
456
|
customer_group_id: "CustomerGroup", |
|
457
|
}, |
|
458
|
alias: [ |
|
459
|
{ |
|
460
|
name: ["customer", "customers"], |
|
461
|
entity: "Customer", |
|
462
|
args: { methodSuffix: "Customers" }, |
|
463
|
}, |
|
464
|
], |
|
465
|
schema: customerSchema, |
|
466
|
} |
|
467
|
} |
|
468
|
|
|
469
|
/** |
|
470
|
* Get all test joiner configs. |
|
471
|
*/ |
|
472
|
export function getTestJoinerConfigs() { |
|
473
|
return [ |
|
474
|
createProductJoinerConfig(), |
|
475
|
createOrderJoinerConfig(), |
|
476
|
createCustomerJoinerConfig(), |
|
477
|
] |
|
478
|
} |