@porulle/adapter-shopify 0.63.0 → 0.65.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/adapter-shopify",
3
- "version": "0.63.0",
3
+ "version": "0.65.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,15 +10,15 @@
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "@porulle/core": "0.63.0"
13
+ "@porulle/core": "0.65.0"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@types/node": "^24.5.2",
17
17
  "eslint": "^9.39.1",
18
18
  "typescript": "5.9.2",
19
19
  "vitest": "^3.2.4",
20
- "@porulle/typescript-config": "0.1.0",
21
- "@porulle/eslint-config": "0.1.0"
20
+ "@porulle/eslint-config": "0.1.0",
21
+ "@porulle/typescript-config": "0.1.0"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineChannelConnector, Err, Ok } from "@porulle/core";
1
+ import { defineChannelConnector, Err, Ok, toMinorUnits } from "@porulle/core";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
3
  import type {
4
4
  ChannelCatalogPage,
@@ -104,46 +104,19 @@ type ShopifyProduct = {
104
104
  }>;
105
105
  };
106
106
 
107
- const zeroDecimalCurrencies = new Set([
108
- "BIF",
109
- "CLP",
110
- "DJF",
111
- "GNF",
112
- "ISK",
113
- "JPY",
114
- "KMF",
115
- "KRW",
116
- "PYG",
117
- "RWF",
118
- "UGX",
119
- "VND",
120
- "VUV",
121
- "XAF",
122
- "XOF",
123
- "XPF",
124
- ]);
125
-
126
107
  function normalizeCurrency(value: unknown): string | undefined {
127
108
  if (typeof value !== "string" || value.trim() === "") return undefined;
128
109
  return value.trim().toUpperCase();
129
110
  }
130
111
 
131
- function parseMoney(value: string | null | undefined, currency: string): number | undefined {
132
- if (value == null || value.trim() === "") return undefined;
133
- const parsed = Number(value);
134
- if (!Number.isFinite(parsed)) return undefined;
135
- const exponent = zeroDecimalCurrencies.has(currency) ? 0 : 2;
136
- return Math.round(parsed * (10 ** exponent));
137
- }
138
-
139
112
  function pricesForVariant(
140
113
  variant: NonNullable<ShopifyProduct["variants"]>[number],
141
114
  currency: string | undefined,
142
115
  ): ChannelCatalogPrice[] | undefined {
143
116
  if (!currency) return undefined;
144
- const amount = parseMoney(variant.price, currency);
117
+ const amount = toMinorUnits(variant.price, currency);
145
118
  if (amount === undefined) return undefined;
146
- const compareAtAmount = parseMoney(variant.compare_at_price, currency);
119
+ const compareAtAmount = toMinorUnits(variant.compare_at_price, currency);
147
120
  return [{
148
121
  currency,
149
122
  amount,