@isoftdata/ebay-utility 1.4.0 → 1.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.
Files changed (95) hide show
  1. package/Readme.md +30 -45
  2. package/lib/adapters/ebay/EbayAdapter.d.ts +6 -1
  3. package/lib/adapters/ebay/EbayAdapter.d.ts.map +1 -1
  4. package/lib/adapters/ebay/EbayAdapter.js +4 -0
  5. package/lib/adapters/ebay/EbayAdapter.js.map +1 -1
  6. package/lib/adapters/ebay/WebEbayAdapter.d.ts +2 -1
  7. package/lib/adapters/ebay/WebEbayAdapter.d.ts.map +1 -1
  8. package/lib/adapters/ebay/WebEbayAdapter.js +4 -0
  9. package/lib/adapters/ebay/WebEbayAdapter.js.map +1 -1
  10. package/lib/adapters/itrack/ItrackAdapter.d.ts +18 -3
  11. package/lib/adapters/itrack/ItrackAdapter.d.ts.map +1 -1
  12. package/lib/adapters/itrack/ItrackAdapter.js +86 -26
  13. package/lib/adapters/itrack/ItrackAdapter.js.map +1 -1
  14. package/lib/entities/ebay/Address.d.ts +2 -0
  15. package/lib/entities/ebay/Address.d.ts.map +1 -1
  16. package/lib/entities/ebay/Address.js +11 -0
  17. package/lib/entities/ebay/Address.js.map +1 -1
  18. package/lib/entities/ebay/EbayInventoryLocationDTO.d.ts +9 -0
  19. package/lib/entities/ebay/EbayInventoryLocationDTO.d.ts.map +1 -0
  20. package/lib/entities/ebay/EbayInventoryLocationDTO.js +24 -0
  21. package/lib/entities/ebay/EbayInventoryLocationDTO.js.map +1 -0
  22. package/lib/entities/ebay/InventoryItem.d.ts +3 -3
  23. package/lib/entities/ebay/InventoryItem.d.ts.map +1 -1
  24. package/lib/entities/ebay/InventoryItem.js +1 -3
  25. package/lib/entities/ebay/InventoryItem.js.map +1 -1
  26. package/lib/entities/ebay/InventoryLocationStoreInput.d.ts +12 -0
  27. package/lib/entities/ebay/InventoryLocationStoreInput.d.ts.map +1 -0
  28. package/lib/entities/ebay/InventoryLocationStoreInput.js +2 -0
  29. package/lib/entities/ebay/InventoryLocationStoreInput.js.map +1 -0
  30. package/lib/entities/ebay/MerchantLocationKey.d.ts +1 -0
  31. package/lib/entities/ebay/MerchantLocationKey.d.ts.map +1 -1
  32. package/lib/entities/ebay/MerchantLocationKey.js +1 -0
  33. package/lib/entities/ebay/MerchantLocationKey.js.map +1 -1
  34. package/lib/entities/itrack/EcommercePartner.d.ts +46 -0
  35. package/lib/entities/itrack/EcommercePartner.d.ts.map +1 -0
  36. package/lib/entities/itrack/EcommercePartner.js +19 -0
  37. package/lib/entities/itrack/EcommercePartner.js.map +1 -0
  38. package/lib/index.d.ts +5 -4
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/index.js +5 -3
  41. package/lib/index.js.map +1 -1
  42. package/lib/infrastructure/HttpToRepoConverter.d.ts.map +1 -1
  43. package/lib/infrastructure/HttpToRepoConverter.js +10 -3
  44. package/lib/infrastructure/HttpToRepoConverter.js.map +1 -1
  45. package/lib/ports/EbayInterface.d.ts +2 -1
  46. package/lib/ports/EbayInterface.d.ts.map +1 -1
  47. package/lib/ports/ItrackInterface.d.ts +2 -2
  48. package/lib/ports/ItrackInterface.d.ts.map +1 -1
  49. package/lib/repositories/ebay/ImageUploadRepo.js +1 -1
  50. package/lib/repositories/ebay/ImageUploadRepo.js.map +1 -1
  51. package/lib/repositories/ebay/InventoryItemRepo.js +1 -1
  52. package/lib/repositories/ebay/InventoryItemRepo.js.map +1 -1
  53. package/lib/repositories/ebay/InventoryLocationRepo.d.ts +3 -1
  54. package/lib/repositories/ebay/InventoryLocationRepo.d.ts.map +1 -1
  55. package/lib/repositories/ebay/InventoryLocationRepo.js +15 -0
  56. package/lib/repositories/ebay/InventoryLocationRepo.js.map +1 -1
  57. package/lib/repositories/ebay/ListingRepo.js +1 -1
  58. package/lib/repositories/ebay/ListingRepo.js.map +1 -1
  59. package/lib/repositories/itrack/EbayLocationRepo.d.ts +16 -0
  60. package/lib/repositories/itrack/EbayLocationRepo.d.ts.map +1 -0
  61. package/lib/repositories/itrack/EbayLocationRepo.js +32 -0
  62. package/lib/repositories/itrack/EbayLocationRepo.js.map +1 -0
  63. package/lib/repositories/itrack/EcommercePartnerRepo.d.ts +9 -0
  64. package/lib/repositories/itrack/EcommercePartnerRepo.d.ts.map +1 -0
  65. package/lib/repositories/itrack/EcommercePartnerRepo.js +26 -0
  66. package/lib/repositories/itrack/EcommercePartnerRepo.js.map +1 -0
  67. package/lib/repositories/itrack/StoreRepo.d.ts +2 -2
  68. package/lib/repositories/itrack/StoreRepo.d.ts.map +1 -1
  69. package/lib/usecases/Agg_StoreEvent.d.ts +1 -10
  70. package/lib/usecases/Agg_StoreEvent.d.ts.map +1 -1
  71. package/lib/usecases/Agg_StoreEvent.js +3 -6
  72. package/lib/usecases/Agg_StoreEvent.js.map +1 -1
  73. package/lib/usecases/Location/PushInventoryLocationToEbay.d.ts +2 -2
  74. package/lib/usecases/Location/PushInventoryLocationToEbay.d.ts.map +1 -1
  75. package/lib/usecases/Location/PushInventoryLocations.d.ts +16 -0
  76. package/lib/usecases/Location/PushInventoryLocations.d.ts.map +1 -0
  77. package/lib/usecases/Location/PushInventoryLocations.js +56 -0
  78. package/lib/usecases/Location/PushInventoryLocations.js.map +1 -0
  79. package/lib/usecases/Location/ReconcileLocationToEbay.d.ts +18 -0
  80. package/lib/usecases/Location/ReconcileLocationToEbay.d.ts.map +1 -0
  81. package/lib/usecases/Location/ReconcileLocationToEbay.js +50 -0
  82. package/lib/usecases/Location/ReconcileLocationToEbay.js.map +1 -0
  83. package/lib/usecases/Location/SyncInventoryLocationToEbay.d.ts +19 -0
  84. package/lib/usecases/Location/SyncInventoryLocationToEbay.d.ts.map +1 -0
  85. package/lib/usecases/Location/SyncInventoryLocationToEbay.js +79 -0
  86. package/lib/usecases/Location/SyncInventoryLocationToEbay.js.map +1 -0
  87. package/lib/usecases/Location/SyncInventoryLocationsToEbay.d.ts +17 -0
  88. package/lib/usecases/Location/SyncInventoryLocationsToEbay.d.ts.map +1 -0
  89. package/lib/usecases/Location/SyncInventoryLocationsToEbay.js +69 -0
  90. package/lib/usecases/Location/SyncInventoryLocationsToEbay.js.map +1 -0
  91. package/lib/usecases/Location/SyncInventoryLocations_TODO.d.ts +13 -0
  92. package/lib/usecases/Location/SyncInventoryLocations_TODO.d.ts.map +1 -0
  93. package/lib/usecases/Location/SyncInventoryLocations_TODO.js +10 -0
  94. package/lib/usecases/Location/SyncInventoryLocations_TODO.js.map +1 -0
  95. package/package.json +5 -5
@@ -0,0 +1,69 @@
1
+ import { reconcileLocationToEbay } from './ReconcileLocationToEbay.js';
2
+ // Loads all store/DTOs from itrack and current eBay locations, tries to match and update
3
+ export const syncInventoryLocationsToEbay = async (params) => {
4
+ const { ebayAdapter, itrackAdapter, production } = params;
5
+ const errors = [];
6
+ const dtos = await itrackAdapter.getInventoryLocations();
7
+ const liveResponse = await ebayAdapter.getInventoryLocations();
8
+ if (!liveResponse.success) {
9
+ return {
10
+ success: false,
11
+ errors: [{
12
+ storeId: null,
13
+ message: 'Failed to retrieve inventory locations from eBay',
14
+ details: liveResponse,
15
+ }],
16
+ };
17
+ }
18
+ const liveLocations = liveResponse.data;
19
+ for (const dto of dtos) {
20
+ const existing = liveLocations.find(l => l.merchantLocationKey === dto.key) ?? null;
21
+ const result = await reconcileLocationToEbay({ ebayAdapter, dto, existing });
22
+ if (!result.success) {
23
+ errors.push({
24
+ storeId: dto.storeId,
25
+ message: result.error?.message ?? 'Reconciliation failed',
26
+ details: result.error?.details,
27
+ });
28
+ continue;
29
+ }
30
+ if (result.action === 'noop' || result.action === 'skip') {
31
+ continue;
32
+ }
33
+ const ebayName = dto.location.name;
34
+ if (!ebayName) {
35
+ errors.push({
36
+ storeId: dto.storeId,
37
+ message: 'DTO missing location.name; cannot persist to ebay_location',
38
+ });
39
+ continue;
40
+ }
41
+ const upsertLocationResult = await itrackAdapter.upsertEbayLocation({
42
+ storeId: dto.storeId,
43
+ production,
44
+ ebayName,
45
+ details: dto.location,
46
+ });
47
+ if (!upsertLocationResult.success) {
48
+ errors.push({
49
+ storeId: dto.storeId,
50
+ message: upsertLocationResult.error?.message ?? 'Failed to upsert ebay_location',
51
+ details: upsertLocationResult,
52
+ });
53
+ }
54
+ const upsertSliceResult = await itrackAdapter.upsertEbayPartnerStoreSlice({
55
+ storeId: dto.storeId,
56
+ name: ebayName,
57
+ merchantLocationKey: dto.key,
58
+ });
59
+ if (!upsertSliceResult.success) {
60
+ errors.push({
61
+ storeId: dto.storeId,
62
+ message: upsertSliceResult.error?.message ?? 'Failed to upsert partner store slice',
63
+ details: upsertSliceResult,
64
+ });
65
+ }
66
+ }
67
+ return { success: errors.length === 0, errors };
68
+ };
69
+ //# sourceMappingURL=SyncInventoryLocationsToEbay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyncInventoryLocationsToEbay.js","sourceRoot":"","sources":["../../../src/usecases/Location/SyncInventoryLocationsToEbay.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAatE,yFAAyF;AACzF,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,EAC7C,MAAyC,EACE,EAAE;IAC7C,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,CAAA;IACzD,MAAM,MAAM,GAAiD,EAAE,CAAA;IAE/D,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,qBAAqB,EAAE,CAAA;IAExD,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,qBAAqB,EAAE,CAAA;IAC9D,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QACxB,OAAO;YACH,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,CAAC;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,kDAAkD;oBAC3D,OAAO,EAAE,YAAY;iBACxB,CAAC;SACL,CAAA;IACL,CAAC;IACD,MAAM,aAAa,GAAG,YAAY,CAAC,IA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oB,CAAC,KAAK,EAAE,OAAO,IAAI,gCAAgC;gBAChF,OAAO,EAAE,oBAAoB;aAChC,CAAC,CAAA;QACN,CAAC;QAED,MAAM,iBAAiB,GAAG,MAAM,aAAa,CAAC,2BAA2B,CAAC;YACtE,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,QAAQ;YACd,mBAAmB,EAAE,GAAG,CAAC,GAAG;SAC/B,CAAC,CAAA;QACF,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC;gBACR,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,OAAO,EAAE,iBAAiB,CAAC,KAAK,EAAE,OAAO,IAAI,sCAAsC;gBACnF,OAAO,EAAE,iBAAiB;aAC7B,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;AACnD,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { EbayAdapter } from '../../adapters/ebay/EbayAdapter.js';
2
+ import { ItrackAdapter } from '../../adapters/itrack/ItrackAdapter.js';
3
+ import { TokenManager } from '../../infrastructure/TokenManager.js';
4
+ import { InventoryLocationDTO } from './SyncInventoryLocations.js';
5
+ export interface SyncInventoryLocationsInput {
6
+ ebayAdapter: EbayAdapter;
7
+ itrackAdapter: ItrackAdapter;
8
+ tokenManager: TokenManager;
9
+ production: boolean;
10
+ data: InventoryLocationDTO[];
11
+ }
12
+ export declare const syncInventoryLocationsToEbay: (_params: SyncInventoryLocationsInput) => Promise<void>;
13
+ //# sourceMappingURL=SyncInventoryLocations_TODO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyncInventoryLocations_TODO.d.ts","sourceRoot":"","sources":["../../../src/usecases/Location/SyncInventoryLocations_TODO.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,MAAM,WAAW,2BAA2B;IAC3C,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,oBAAoB,EAAE,CAAA;CAC5B;AAED,eAAO,MAAM,4BAA4B,GAAU,SAAS,2BAA2B,KAAG,OAAO,CAAC,IAAI,CAErG,CAAA"}
@@ -0,0 +1,10 @@
1
+ // TODO: Server-side version of pushInventoryLocations for projects that have direct
2
+ // itrack DB access (e.g. not the web context). Should follow the SyncFulfillmentPolicies
3
+ // pattern: fetch from eBay, compare, create/update on eBay, then write the
4
+ // storeId → merchantLocationKey mapping back to itrack via itrackAdapter.
5
+ //
6
+ // Core eBay logic lives in PushInventoryLocations.ts — reuse or extract it.
7
+ export const syncInventoryLocationsToEbay = async (_params) => {
8
+ throw new Error('Not implemented');
9
+ };
10
+ //# sourceMappingURL=SyncInventoryLocations_TODO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyncInventoryLocations_TODO.js","sourceRoot":"","sources":["../../../src/usecases/Location/SyncInventoryLocations_TODO.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,yFAAyF;AACzF,2EAA2E;AAC3E,0EAA0E;AAC1E,EAAE;AACF,4EAA4E;AAe5E,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,EAAE,OAAoC,EAAiB,EAAE;IACzG,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;AACnC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/ebay-utility",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "type": "module",
@@ -12,10 +12,11 @@
12
12
  },
13
13
  "files": [
14
14
  "lib/**/*",
15
+ "!lib/tests/**/*",
15
16
  "README.md"
16
17
  ],
17
18
  "scripts": {
18
- "test": "npm run build && uvu lib/tests",
19
+ "test": "node --import tsx --test src/tests/*.test.ts",
19
20
  "build": "tsc --version && tsc",
20
21
  "build-start": "tsc --version && tsc && node lib/tests",
21
22
  "prepublishOnly": "npm run build"
@@ -31,6 +32,7 @@
31
32
  "license": "ISC",
32
33
  "description": "A TypeScript utility library for eBay API operations including inventory management, listings, and policy handling",
33
34
  "dependencies": {
35
+ "@lukeed/uuid": "^2.0.1",
34
36
  "@types/xml2js": "^0.4.14",
35
37
  "csrf": "^3.1.0",
36
38
  "dataloader": "^2.2.2",
@@ -39,8 +41,6 @@
39
41
  "mysql2": "^3.16.0",
40
42
  "qs": "^6.13.0",
41
43
  "query-string": "^9.3.1",
42
- "uuid": "^10.0.0",
43
- "uvu": "^0.5.6",
44
44
  "validator": "^13.12.0",
45
45
  "xml2js": "^0.6.2",
46
46
  "yup": "^1.4.0",
@@ -49,9 +49,9 @@
49
49
  "devDependencies": {
50
50
  "@isoftdata/prettier-config-base": "^1.0.3",
51
51
  "@types/node": "^20.0.0",
52
- "@types/uuid": "^9.0.0",
53
52
  "@types/validator": "^13.0.0",
54
53
  "ts-node": "^10.9.2",
54
+ "tsx": "^4.21.0",
55
55
  "typescript": "^5.0.0"
56
56
  },
57
57
  "prettier": "@isoftdata/prettier-config-base"