@reventlessdev/online-shop-hybrid-seed 1.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/CHANGELOG.md +10 -0
  2. package/LICENSE +202 -0
  3. package/lib/bs/.compiler.log +2 -0
  4. package/lib/bs/OnlineShopHybridSeed.cmi +0 -0
  5. package/lib/bs/OnlineShopHybridSeed.cmj +0 -0
  6. package/lib/bs/OnlineShopHybridSeed.cmt +0 -0
  7. package/lib/bs/OnlineShopHybridSeed.mlmap +4 -0
  8. package/lib/bs/build.ninja +0 -0
  9. package/lib/bs/compiler-info.json +8 -0
  10. package/lib/bs/src/DemoCommands-OnlineShopHybridSeed.cmi +0 -0
  11. package/lib/bs/src/DemoCommands-OnlineShopHybridSeed.cmj +0 -0
  12. package/lib/bs/src/DemoCommands-OnlineShopHybridSeed.cmt +0 -0
  13. package/lib/bs/src/DemoCommands.ast +0 -0
  14. package/lib/bs/src/DemoCommands.res +154 -0
  15. package/lib/bs/src/DemoCommands.res.mjs +388 -0
  16. package/lib/bs/src/DemoData-OnlineShopHybridSeed.cmi +0 -0
  17. package/lib/bs/src/DemoData-OnlineShopHybridSeed.cmj +0 -0
  18. package/lib/bs/src/DemoData-OnlineShopHybridSeed.cmt +0 -0
  19. package/lib/bs/src/DemoData.ast +0 -0
  20. package/lib/bs/src/DemoData.res +307 -0
  21. package/lib/bs/src/DemoData.res.mjs +481 -0
  22. package/lib/bs/src/HybridSeedData-OnlineShopHybridSeed.cmi +0 -0
  23. package/lib/bs/src/HybridSeedData-OnlineShopHybridSeed.cmj +0 -0
  24. package/lib/bs/src/HybridSeedData-OnlineShopHybridSeed.cmt +0 -0
  25. package/lib/bs/src/HybridSeedData.ast +0 -0
  26. package/lib/bs/src/HybridSeedData.res +418 -0
  27. package/lib/bs/src/HybridSeedData.res.mjs +317 -0
  28. package/lib/ocaml/.compiler.log +2 -0
  29. package/lib/ocaml/DemoCommands-OnlineShopHybridSeed.cmi +0 -0
  30. package/lib/ocaml/DemoCommands-OnlineShopHybridSeed.cmj +0 -0
  31. package/lib/ocaml/DemoCommands-OnlineShopHybridSeed.cmt +0 -0
  32. package/lib/ocaml/DemoCommands.ast +0 -0
  33. package/lib/ocaml/DemoCommands.res +154 -0
  34. package/lib/ocaml/DemoData-OnlineShopHybridSeed.cmi +0 -0
  35. package/lib/ocaml/DemoData-OnlineShopHybridSeed.cmj +0 -0
  36. package/lib/ocaml/DemoData-OnlineShopHybridSeed.cmt +0 -0
  37. package/lib/ocaml/DemoData.ast +0 -0
  38. package/lib/ocaml/DemoData.res +307 -0
  39. package/lib/ocaml/HybridSeedData-OnlineShopHybridSeed.cmi +0 -0
  40. package/lib/ocaml/HybridSeedData-OnlineShopHybridSeed.cmj +0 -0
  41. package/lib/ocaml/HybridSeedData-OnlineShopHybridSeed.cmt +0 -0
  42. package/lib/ocaml/HybridSeedData.ast +0 -0
  43. package/lib/ocaml/HybridSeedData.res +418 -0
  44. package/lib/ocaml/OnlineShopHybridSeed.cmi +0 -0
  45. package/lib/ocaml/OnlineShopHybridSeed.cmj +0 -0
  46. package/lib/ocaml/OnlineShopHybridSeed.cmt +0 -0
  47. package/lib/ocaml/OnlineShopHybridSeed.mlmap +4 -0
  48. package/package.json +34 -0
  49. package/rescript.json +27 -0
  50. package/src/DemoCommands.res +154 -0
  51. package/src/DemoCommands.res.mjs +388 -0
  52. package/src/DemoData.res +307 -0
  53. package/src/DemoData.res.mjs +481 -0
  54. package/src/HybridSeedData.res +418 -0
  55. package/src/HybridSeedData.res.mjs +317 -0
@@ -0,0 +1,481 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
4
+ import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
5
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
+ import * as Seed_Random$ReventlessSeed from "@reventlessdev/reventless-seed/src/Seed_Random.res.mjs";
7
+
8
+ let random = Seed_Random$ReventlessSeed.make(24301);
9
+
10
+ let categories = [
11
+ {
12
+ id: "cat-01",
13
+ name: "Laptops",
14
+ weight: 9,
15
+ nouns: [
16
+ "Notebook",
17
+ "Ultrabook",
18
+ "Workstation"
19
+ ],
20
+ archive: false
21
+ },
22
+ {
23
+ id: "cat-02",
24
+ name: "Phones",
25
+ weight: 10,
26
+ nouns: [
27
+ "Handset",
28
+ "Smartphone",
29
+ "Phone"
30
+ ],
31
+ archive: false
32
+ },
33
+ {
34
+ id: "cat-03",
35
+ name: "Audio",
36
+ weight: 9,
37
+ nouns: [
38
+ "Headphones",
39
+ "Earbuds",
40
+ "Speaker"
41
+ ],
42
+ archive: false
43
+ },
44
+ {
45
+ id: "cat-04",
46
+ name: "Cameras",
47
+ weight: 7,
48
+ nouns: [
49
+ "Camera",
50
+ "Lens",
51
+ "Gimbal"
52
+ ],
53
+ archive: false
54
+ },
55
+ {
56
+ id: "cat-05",
57
+ name: "Wearables",
58
+ weight: 7,
59
+ nouns: [
60
+ "Watch",
61
+ "Tracker",
62
+ "Band"
63
+ ],
64
+ archive: false
65
+ },
66
+ {
67
+ id: "cat-06",
68
+ name: "Home Office",
69
+ weight: 8,
70
+ nouns: [
71
+ "Desk Lamp",
72
+ "Monitor",
73
+ "Keyboard"
74
+ ],
75
+ archive: false
76
+ },
77
+ {
78
+ id: "cat-07",
79
+ name: "Accessories",
80
+ weight: 6,
81
+ nouns: [
82
+ "Cable",
83
+ "Adapter",
84
+ "Case"
85
+ ],
86
+ archive: false
87
+ },
88
+ {
89
+ id: "cat-08",
90
+ name: "Clearance",
91
+ weight: 4,
92
+ nouns: [
93
+ "Bundle",
94
+ "Refurb Kit"
95
+ ],
96
+ archive: true
97
+ }
98
+ ];
99
+
100
+ let brands = [
101
+ "Aurora",
102
+ "Basalt",
103
+ "Cirrus",
104
+ "Dovetail",
105
+ "Ember",
106
+ "Fathom",
107
+ "Granite",
108
+ "Halcyon"
109
+ ];
110
+
111
+ let qualifiers = [
112
+ "Pro",
113
+ "Air",
114
+ "Max",
115
+ "Lite",
116
+ "Studio",
117
+ "Go",
118
+ "Plus",
119
+ ""
120
+ ];
121
+
122
+ let blurbs = [
123
+ "refreshed",
124
+ "best-selling",
125
+ "entry-level",
126
+ "flagship",
127
+ "compact"
128
+ ];
129
+
130
+ let firstNames = [
131
+ "Ada",
132
+ "Bruno",
133
+ "Chiara",
134
+ "Diego",
135
+ "Elif",
136
+ "Farid",
137
+ "Greta",
138
+ "Hugo",
139
+ "Iris",
140
+ "Jonas",
141
+ "Kaja",
142
+ "Luca",
143
+ "Maya",
144
+ "Noor",
145
+ "Olof",
146
+ "Pia",
147
+ "Rafael",
148
+ "Sana",
149
+ "Tomas",
150
+ "Vera"
151
+ ];
152
+
153
+ let lastNames = [
154
+ "Almeida",
155
+ "Beck",
156
+ "Costa",
157
+ "Duarte",
158
+ "Engel",
159
+ "Ferrer",
160
+ "Gruber",
161
+ "Haas",
162
+ "Ivanov",
163
+ "Jansen",
164
+ "Klein",
165
+ "Lindqvist",
166
+ "Moreau",
167
+ "Nagy",
168
+ "Olsen",
169
+ "Petrov",
170
+ "Rossi",
171
+ "Sandberg",
172
+ "Tamm",
173
+ "Vogel"
174
+ ];
175
+
176
+ let streets = [
177
+ "Bakergasse",
178
+ "Cedar Lane",
179
+ "Dockside Way",
180
+ "Elm Row",
181
+ "Foundry Street"
182
+ ];
183
+
184
+ let cities = [
185
+ "Bruges",
186
+ "Cortona",
187
+ "Delft",
188
+ "Espoo",
189
+ "Freiburg",
190
+ "Gdansk"
191
+ ];
192
+
193
+ let cityCoords = [
194
+ [
195
+ 51.2093,
196
+ 3.2247
197
+ ],
198
+ [
199
+ 43.2749,
200
+ 11.9853
201
+ ],
202
+ [
203
+ 52.0116,
204
+ 4.3571
205
+ ],
206
+ [
207
+ 60.2055,
208
+ 24.6559
209
+ ],
210
+ [
211
+ 47.999,
212
+ 7.8421
213
+ ],
214
+ [
215
+ 54.352,
216
+ 18.6466
217
+ ]
218
+ ];
219
+
220
+ let supplierFeed = [
221
+ {
222
+ sku: "SKU-4410",
223
+ title: "Fathom Dock 4-Port",
224
+ desc: "Supplier-fed docking station.",
225
+ unitPrice: 8990,
226
+ currency: "USD",
227
+ category: "cat-07"
228
+ },
229
+ {
230
+ sku: "SKU-4411",
231
+ title: "Cirrus Travel Charger",
232
+ desc: "Supplier-fed 65W charger.",
233
+ unitPrice: 4550,
234
+ currency: "USD",
235
+ category: "cat-07"
236
+ },
237
+ {
238
+ sku: "SKU-4412",
239
+ title: "Granite Laptop Sleeve",
240
+ desc: "Supplier-fed protective sleeve.",
241
+ unitPrice: 3200,
242
+ currency: "USD",
243
+ category: "cat-07"
244
+ },
245
+ {
246
+ sku: "SKU-4413",
247
+ title: "Halcyon Desk Riser",
248
+ desc: "Supplier-fed monitor riser.",
249
+ unitPrice: 12400,
250
+ currency: "USD",
251
+ category: "cat-06"
252
+ },
253
+ {
254
+ sku: "SKU-4414",
255
+ title: "Ember Cable Set",
256
+ desc: "Rejected: non-USD supplier row.",
257
+ unitPrice: 1900,
258
+ currency: "EUR",
259
+ category: "cat-07"
260
+ }
261
+ ];
262
+
263
+ let importedSkus = supplierFeed.filter(row => row.currency === "USD").map(row => row.sku);
264
+
265
+ let expectedImportSuccesses = importedSkus.length;
266
+
267
+ let expectedImportFailures = supplierFeed.length - expectedImportSuccesses | 0;
268
+
269
+ function pad(n, width) {
270
+ return n.toString().padStart(width, "0");
271
+ }
272
+
273
+ function pick(xs) {
274
+ return Seed_Random$ReventlessSeed.pickOr(random, "", xs);
275
+ }
276
+
277
+ function address() {
278
+ let number = Seed_Random$ReventlessSeed.int(random, 1, 180);
279
+ return number.toString() + ` ` + Seed_Random$ReventlessSeed.pickOr(random, "", streets) + `, ` + Seed_Random$ReventlessSeed.pickOr(random, "", cities);
280
+ }
281
+
282
+ function locatedAddress() {
283
+ let number = Seed_Random$ReventlessSeed.int(random, 1, 180);
284
+ let cityIndex = Seed_Random$ReventlessSeed.int(random, 0, cities.length - 1 | 0);
285
+ let city = Stdlib_Option.getOr(cities[cityIndex], "");
286
+ let match = Stdlib_Option.getOr(cityCoords[cityIndex], [
287
+ 0.0,
288
+ 0.0
289
+ ]);
290
+ return [
291
+ number.toString() + ` ` + Seed_Random$ReventlessSeed.pickOr(random, "", streets) + `, ` + city,
292
+ match[0],
293
+ match[1]
294
+ ];
295
+ }
296
+
297
+ function escapeXml(s) {
298
+ return s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
299
+ }
300
+
301
+ function productSvg(name, index) {
302
+ let hue = (index * 47 | 0) % 360;
303
+ let bg = `hsl(` + hue.toString() + `, 62%, 52%)`;
304
+ let label = escapeXml(name);
305
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="400" height="300" viewBox="0 0 400 300">` + (`<rect width="400" height="300" fill="` + bg + `"/>`) + (`<text x="200" y="160" fill="#ffffff" font-family="sans-serif" font-size="22" font-weight="600" text-anchor="middle">` + label + `</text>`) + `</svg>`;
306
+ }
307
+
308
+ function buildProducts(countOpt, param) {
309
+ let count = countOpt !== undefined ? countOpt : 60;
310
+ let totalWeight = Stdlib_Array.reduce(categories, 0, (sum, c) => sum + c.weight | 0);
311
+ let products = [];
312
+ let n = {
313
+ contents: 0
314
+ };
315
+ categories.forEach(category => {
316
+ let exact = category.weight / totalWeight * count;
317
+ let share = Math.round(exact) | 0;
318
+ let share$1 = share < 2 ? 2 : share;
319
+ for (let _for = 1; _for <= share$1; ++_for) {
320
+ if (products.length < count) {
321
+ n.contents = n.contents + 1 | 0;
322
+ let qualifier = Seed_Random$ReventlessSeed.pickOr(random, "", qualifiers);
323
+ let suffix = qualifier === "" ? "" : ` ` + qualifier;
324
+ let name = Seed_Random$ReventlessSeed.pickOr(random, "", brands) + ` ` + Seed_Random$ReventlessSeed.pickOr(random, "", category.nouns) + suffix;
325
+ let low = Math.log(5.0);
326
+ let high = Math.log(900.0);
327
+ let raw = Math.exp(low + Seed_Random$ReventlessSeed.float(random) * (high - low));
328
+ let price = Math.round(raw * 100.0) / 100.0;
329
+ products.push({
330
+ id: `prd-` + pad(n.contents, 3),
331
+ name: name,
332
+ description: name + ` — ` + Seed_Random$ReventlessSeed.pickOr(random, "", blurbs) + ` ` + category.name.toLowerCase() + ` pick.`,
333
+ price: price,
334
+ imageUrl: "",
335
+ categoryId: category.id
336
+ });
337
+ }
338
+ }
339
+ });
340
+ return products;
341
+ }
342
+
343
+ function repricedProducts(products) {
344
+ return products.filter((param, i) => i % 11 === 4);
345
+ }
346
+
347
+ function redescribedProducts(products) {
348
+ return products.filter((param, i) => i % 17 === 9);
349
+ }
350
+
351
+ function discountedPrice(p) {
352
+ return Math.round(p.price * 0.85 * 100.0) / 100.0;
353
+ }
354
+
355
+ function buildCustomers(countOpt, param) {
356
+ let count = countOpt !== undefined ? countOpt : 20;
357
+ return Stdlib_Array.fromInitializer(count, i => {
358
+ let first = Stdlib_Option.getOr(firstNames[Primitive_int.mod_(i, firstNames.length)], "Ada");
359
+ let last = Stdlib_Option.getOr(lastNames[Primitive_int.mod_((i * 7 | 0) + 3 | 0, lastNames.length)], "Beck");
360
+ let id = `cust-` + pad(i + 1 | 0, 2);
361
+ let match = locatedAddress();
362
+ return {
363
+ id: id,
364
+ email: (first + `.` + last + `@example.com`).toLowerCase(),
365
+ address: match[0],
366
+ lat: match[1],
367
+ lng: match[2]
368
+ };
369
+ });
370
+ }
371
+
372
+ function movedCustomers(customers) {
373
+ return customers.filter((param, i) => i % 6 === 2);
374
+ }
375
+
376
+ function deactivatedCustomers(customers) {
377
+ return customers.filter((param, i) => i % 9 === 5);
378
+ }
379
+
380
+ function newAddress() {
381
+ return address();
382
+ }
383
+
384
+ function buildOrders(products, customers, countOpt, param) {
385
+ let count = countOpt !== undefined ? countOpt : 150;
386
+ let shuffled = Seed_Random$ReventlessSeed.sampleWeighted(random, products.map(p => [
387
+ p,
388
+ 1.0
389
+ ]), products.length);
390
+ let productWeights = Seed_Random$ReventlessSeed.zipfWeights(shuffled, 1.1);
391
+ let customerWeights = Seed_Random$ReventlessSeed.zipfWeights(customers, 0.45);
392
+ return Stdlib_Array.fromInitializer(count, i => {
393
+ let sizeRoll = Seed_Random$ReventlessSeed.float(random);
394
+ let size = sizeRoll < 0.5 ? 1 : (
395
+ sizeRoll < 0.75 ? 2 : (
396
+ sizeRoll < 0.9 ? 3 : 4
397
+ )
398
+ );
399
+ let customerId = Stdlib_Option.mapOr(Seed_Random$ReventlessSeed.sampleWeighted(random, customerWeights, 1)[0], "cust-01", c => c.id);
400
+ let productIds = Seed_Random$ReventlessSeed.sampleWeighted(random, productWeights, size).map(p => p.id);
401
+ let methodRoll = Seed_Random$ReventlessSeed.float(random);
402
+ let shippingMethod = methodRoll < 0.35 ? "Express" : (
403
+ methodRoll < 0.8 ? "Standard" : "Pickup"
404
+ );
405
+ return {
406
+ id: `ord-` + pad(i + 1 | 0, 3),
407
+ customerId: customerId,
408
+ productIds: productIds,
409
+ shippingMethod: shippingMethod
410
+ };
411
+ });
412
+ }
413
+
414
+ function batchDispatched(orders) {
415
+ return orders.filter(o => o.shippingMethod === "Standard").filter((param, i) => i % 5 !== 0);
416
+ }
417
+
418
+ function cancellable(orders, dispatched) {
419
+ return orders.filter(o => {
420
+ if (o.shippingMethod !== "Express") {
421
+ return !dispatched.includes(o.id);
422
+ } else {
423
+ return false;
424
+ }
425
+ });
426
+ }
427
+
428
+ function cancelled(orders) {
429
+ return orders.filter((param, i) => i % 3 === 1);
430
+ }
431
+
432
+ let productCount = 60;
433
+
434
+ let customerCount = 20;
435
+
436
+ let orderCount = 150;
437
+
438
+ let renamedCategoryId = "cat-06";
439
+
440
+ let renamedCategoryName = "Home & Office";
441
+
442
+ export {
443
+ random,
444
+ productCount,
445
+ customerCount,
446
+ orderCount,
447
+ categories,
448
+ renamedCategoryId,
449
+ renamedCategoryName,
450
+ brands,
451
+ qualifiers,
452
+ blurbs,
453
+ firstNames,
454
+ lastNames,
455
+ streets,
456
+ cities,
457
+ cityCoords,
458
+ supplierFeed,
459
+ importedSkus,
460
+ expectedImportSuccesses,
461
+ expectedImportFailures,
462
+ pad,
463
+ pick,
464
+ address,
465
+ locatedAddress,
466
+ escapeXml,
467
+ productSvg,
468
+ buildProducts,
469
+ repricedProducts,
470
+ redescribedProducts,
471
+ discountedPrice,
472
+ buildCustomers,
473
+ movedCustomers,
474
+ deactivatedCustomers,
475
+ newAddress,
476
+ buildOrders,
477
+ batchDispatched,
478
+ cancellable,
479
+ cancelled,
480
+ }
481
+ /* random Not a pure module */
Binary file