@thorprovider/adapters 5.0.11 → 5.0.12
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/index.d.mts +29 -6
- package/dist/index.d.ts +29 -6
- package/dist/index.js +294 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +294 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/providers/medusa/auth.test.ts +148 -25
- package/src/providers/medusa/auth.ts +129 -16
- package/src/providers/medusa/customer-orders.test.ts +142 -0
- package/src/providers/medusa/index.ts +108 -26
- package/src/providers/medusa/transforms.test.ts +45 -0
- package/src/providers/medusa/transforms.ts +7 -0
- package/src/providers/mock/catalog-query.test.ts +153 -17
- package/src/providers/mock/index.test.ts +19 -0
- package/src/providers/mock/mock.ts +189 -1
- package/.turbo/turbo-build.log +0 -18
- package/.turbo/turbo-test.log +0 -897
- package/.turbo/turbo-type-check.log +0 -0
- package/dist/.tsbuildinfo +0 -1
- package/publish.log +0 -93
|
@@ -179,7 +179,7 @@ const categoryFixtures: MockCategoryFixture[] = [
|
|
|
179
179
|
},
|
|
180
180
|
];
|
|
181
181
|
|
|
182
|
-
const
|
|
182
|
+
const heroProductFixtures: MockProductFixture[] = [
|
|
183
183
|
{
|
|
184
184
|
id: 'mock-product-aurora-jacket',
|
|
185
185
|
handle: 'aurora-jacket',
|
|
@@ -312,6 +312,180 @@ const productFixtures: MockProductFixture[] = [
|
|
|
312
312
|
},
|
|
313
313
|
];
|
|
314
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Deterministic blueprint for a generated demo category.
|
|
317
|
+
*
|
|
318
|
+
* Every field is a fixed literal so the factory below produces the same ids,
|
|
319
|
+
* handles, titles, prices, and ordering on every load (no `Math.random`, no
|
|
320
|
+
* clock reads). `names` are unique within the category and the `noun`
|
|
321
|
+
* distinguishes categories, so `${name} ${noun}` yields globally distinct
|
|
322
|
+
* titles and `${name}-${noun}` yields globally unique handles.
|
|
323
|
+
*/
|
|
324
|
+
interface MockProductBlueprint {
|
|
325
|
+
categoryHandle: string;
|
|
326
|
+
noun: string;
|
|
327
|
+
productType: string;
|
|
328
|
+
vendor: string;
|
|
329
|
+
tags: string[];
|
|
330
|
+
variantName: string;
|
|
331
|
+
variantValues: string[];
|
|
332
|
+
names: string[];
|
|
333
|
+
description: string;
|
|
334
|
+
basePrice: number;
|
|
335
|
+
baseHue: number;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Fixed per-category pools for the generated demo products.
|
|
340
|
+
*
|
|
341
|
+
* Copy deliberately avoids the substrings "light" and "helios" so the existing
|
|
342
|
+
* CU-09 text-search assertions (which pin the only "light"/"HELIOS" matches to
|
|
343
|
+
* the fixture heroes) keep holding.
|
|
344
|
+
*/
|
|
345
|
+
const generatedBlueprints: MockProductBlueprint[] = [
|
|
346
|
+
{
|
|
347
|
+
categoryHandle: 'jackets',
|
|
348
|
+
noun: 'Jacket',
|
|
349
|
+
productType: 'outerwear',
|
|
350
|
+
vendor: 'Thor Atelier',
|
|
351
|
+
tags: ['outerwear', 'layer'],
|
|
352
|
+
variantName: 'Size',
|
|
353
|
+
variantValues: ['S', 'M'],
|
|
354
|
+
names: ['Alpine', 'Boreal', 'Cinder', 'Drift', 'Ember', 'Fjord', 'Harbor', 'Meridian', 'Nomad', 'Tundra', 'Vantage'],
|
|
355
|
+
description: 'A considered layering piece in a brushed weave.',
|
|
356
|
+
basePrice: 118,
|
|
357
|
+
baseHue: 210,
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
categoryHandle: 'dresses',
|
|
361
|
+
noun: 'Dress',
|
|
362
|
+
productType: 'dress',
|
|
363
|
+
vendor: 'Thor Atelier',
|
|
364
|
+
tags: ['dress', 'editorial'],
|
|
365
|
+
variantName: 'Size',
|
|
366
|
+
variantValues: ['S', 'M'],
|
|
367
|
+
names: ['Amber', 'Camille', 'Dahlia', 'Elara', 'Iris', 'Lumen', 'Nova', 'Rosalind', 'Vera'],
|
|
368
|
+
description: 'Cut from a fluid cloth for editorial styling.',
|
|
369
|
+
basePrice: 142,
|
|
370
|
+
baseHue: 330,
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
categoryHandle: 'home',
|
|
374
|
+
noun: 'Lamp',
|
|
375
|
+
productType: 'decor',
|
|
376
|
+
vendor: 'Thor Home',
|
|
377
|
+
tags: ['home', 'decor', 'interior'],
|
|
378
|
+
variantName: 'Finish',
|
|
379
|
+
variantValues: ['Brass'],
|
|
380
|
+
names: ['Atlas', 'Copper', 'Dune', 'Onyx', 'Quill', 'Slate', 'Terra', 'Verdant'],
|
|
381
|
+
description: 'A calm sculptural accent for modern interiors.',
|
|
382
|
+
basePrice: 74,
|
|
383
|
+
baseHue: 40,
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
categoryHandle: 'accessories',
|
|
387
|
+
noun: 'Bag',
|
|
388
|
+
productType: 'bag',
|
|
389
|
+
vendor: 'Thor Atelier',
|
|
390
|
+
tags: ['accessory', 'everyday'],
|
|
391
|
+
variantName: 'Color',
|
|
392
|
+
variantValues: ['Juniper'],
|
|
393
|
+
names: ['Cove', 'Fable', 'Juniper', 'Kestrel', 'Marlowe', 'Piper', 'Rune'],
|
|
394
|
+
description: 'An everyday carry with a textured finish.',
|
|
395
|
+
basePrice: 68,
|
|
396
|
+
baseHue: 280,
|
|
397
|
+
},
|
|
398
|
+
];
|
|
399
|
+
|
|
400
|
+
/** Oldest anchor for generated `createdAt` values; all stay before the heroes. */
|
|
401
|
+
const GENERATED_CREATED_AT_BASE = Date.parse('2025-12-30T00:00:00.000Z');
|
|
402
|
+
|
|
403
|
+
/** Deterministic collection order the generated products are assigned across. */
|
|
404
|
+
const GENERATED_COLLECTION_POOL = ['new-arrivals', 'best-sellers', 'studio-essentials'];
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Build the generated demo products, one pool per seeded category.
|
|
408
|
+
*
|
|
409
|
+
* Deterministic by construction: the trailing `globalIndex` drives collection
|
|
410
|
+
* membership, pricing step, stock, hue, and `createdAt` so the whole seed is a
|
|
411
|
+
* pure function of fixed literals.
|
|
412
|
+
*/
|
|
413
|
+
function buildGeneratedProductFixtures(): MockProductFixture[] {
|
|
414
|
+
const fixtures: MockProductFixture[] = [];
|
|
415
|
+
let globalIndex = 0;
|
|
416
|
+
|
|
417
|
+
for (const blueprint of generatedBlueprints) {
|
|
418
|
+
const noun = blueprint.noun.toLowerCase();
|
|
419
|
+
|
|
420
|
+
blueprint.names.forEach((name, localIndex) => {
|
|
421
|
+
const handle = `${name.toLowerCase()}-${noun}`;
|
|
422
|
+
const title = `${name} ${blueprint.noun}`;
|
|
423
|
+
const price = blueprint.basePrice + localIndex * 7 + (localIndex % 3) * 0.5;
|
|
424
|
+
const quantityAvailable = (globalIndex * 5) % 17;
|
|
425
|
+
|
|
426
|
+
const primaryCollection =
|
|
427
|
+
GENERATED_COLLECTION_POOL[globalIndex % GENERATED_COLLECTION_POOL.length];
|
|
428
|
+
const collectionHandles = [primaryCollection];
|
|
429
|
+
if (globalIndex % 5 === 0) {
|
|
430
|
+
const secondary =
|
|
431
|
+
GENERATED_COLLECTION_POOL[(globalIndex + 1) % GENERATED_COLLECTION_POOL.length];
|
|
432
|
+
if (secondary !== primaryCollection) {
|
|
433
|
+
collectionHandles.push(secondary);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const createdAt = new Date(GENERATED_CREATED_AT_BASE - globalIndex * 86_400_000).toISOString();
|
|
438
|
+
|
|
439
|
+
const variants: MockVariantFixture[] = blueprint.variantValues.map((value, variantIndex) => ({
|
|
440
|
+
id: `mock-variant-${handle}-${value.toLowerCase()}`,
|
|
441
|
+
title: value,
|
|
442
|
+
price,
|
|
443
|
+
quantityAvailable: Math.max(0, quantityAvailable - variantIndex),
|
|
444
|
+
selectedOptions: [{ name: blueprint.variantName, value }],
|
|
445
|
+
}));
|
|
446
|
+
|
|
447
|
+
fixtures.push({
|
|
448
|
+
id: `mock-product-${handle}`,
|
|
449
|
+
handle,
|
|
450
|
+
title,
|
|
451
|
+
description: `${title} - ${blueprint.description}`,
|
|
452
|
+
imageLabel: title,
|
|
453
|
+
imageHue: (blueprint.baseHue + localIndex * 13) % 360,
|
|
454
|
+
collectionHandles,
|
|
455
|
+
categoryHandle: blueprint.categoryHandle,
|
|
456
|
+
productType: blueprint.productType,
|
|
457
|
+
vendor: blueprint.vendor,
|
|
458
|
+
tags: [...blueprint.tags],
|
|
459
|
+
options: [
|
|
460
|
+
{
|
|
461
|
+
id: `${handle}-${blueprint.variantName.toLowerCase()}`,
|
|
462
|
+
name: blueprint.variantName,
|
|
463
|
+
values: [...blueprint.variantValues],
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
variants,
|
|
467
|
+
createdAt,
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
globalIndex += 1;
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return fixtures;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* The full mock product seed.
|
|
479
|
+
*
|
|
480
|
+
* The four fixture heroes stay first so the canonical `featured` order and the
|
|
481
|
+
* home hero (`slice(0, 4)`) remain representative; the generated demo products
|
|
482
|
+
* follow and populate every category with a credible multi-item grid.
|
|
483
|
+
*/
|
|
484
|
+
const productFixtures: MockProductFixture[] = [
|
|
485
|
+
...heroProductFixtures,
|
|
486
|
+
...buildGeneratedProductFixtures(),
|
|
487
|
+
];
|
|
488
|
+
|
|
315
489
|
const stockLocationFixture: StockLocation = {
|
|
316
490
|
id: 'mock-stock-primary',
|
|
317
491
|
name: 'Mock Main Warehouse',
|
|
@@ -449,6 +623,20 @@ function buildProducts(currencyCode: string): Product[] {
|
|
|
449
623
|
title: collection.title,
|
|
450
624
|
handle: collection.handle,
|
|
451
625
|
})),
|
|
626
|
+
categories: (() => {
|
|
627
|
+
const category = categoryFixtures.find(
|
|
628
|
+
(item) => item.handle === product.categoryHandle,
|
|
629
|
+
);
|
|
630
|
+
if (!category) return undefined;
|
|
631
|
+
return [
|
|
632
|
+
{
|
|
633
|
+
id: category.id,
|
|
634
|
+
name: category.name,
|
|
635
|
+
handle: category.handle,
|
|
636
|
+
parentCategoryId: category.parentCategoryId,
|
|
637
|
+
},
|
|
638
|
+
];
|
|
639
|
+
})(),
|
|
452
640
|
productType: product.productType,
|
|
453
641
|
vendor: product.vendor,
|
|
454
642
|
tags: product.tags,
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
CLI Building entry: {"index":"src/index.ts"}
|
|
2
|
-
CLI Using tsconfig: tsconfig.json
|
|
3
|
-
CLI tsup v8.5.1
|
|
4
|
-
CLI Using tsup config: /home/nelson/dev/active/thorprovider/repos/thorcommerce/packages/adapters/tsup.config.ts
|
|
5
|
-
CLI Target: esnext
|
|
6
|
-
CLI Cleaning output folder
|
|
7
|
-
CJS Build start
|
|
8
|
-
ESM Build start
|
|
9
|
-
CJS dist/index.js 381.21 KB
|
|
10
|
-
CJS dist/index.js.map 779.32 KB
|
|
11
|
-
CJS ⚡️ Build success in 398ms
|
|
12
|
-
ESM dist/index.mjs 376.07 KB
|
|
13
|
-
ESM dist/index.mjs.map 773.56 KB
|
|
14
|
-
ESM ⚡️ Build success in 429ms
|
|
15
|
-
DTS Build start
|
|
16
|
-
DTS ⚡️ Build success in 7687ms
|
|
17
|
-
DTS dist/index.d.ts 113.93 KB
|
|
18
|
-
DTS dist/index.d.mts 113.93 KB
|