@vicacha-devs/medusa-plugin-barcode 0.0.0-stage → 0.1.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 (176) hide show
  1. package/.medusa/server/src/admin/index.cjs +3960 -0
  2. package/.medusa/server/src/admin/index.js +3938 -0
  3. package/.medusa/server/src/api/admin/barcodes/[barcode]/route.js +43 -0
  4. package/.medusa/server/src/api/admin/barcodes/batch/route.js +9 -0
  5. package/.medusa/server/src/api/admin/barcodes/bulk-generate/route.js +9 -0
  6. package/.medusa/server/src/api/admin/barcodes/cache/route.js +25 -0
  7. package/.medusa/server/src/api/admin/barcodes/count-sessions/[id]/apply/route.js +13 -0
  8. package/.medusa/server/src/api/admin/barcodes/count-sessions/[id]/scan/route.js +13 -0
  9. package/.medusa/server/src/api/admin/barcodes/count-sessions/route.js +27 -0
  10. package/.medusa/server/src/api/admin/barcodes/create-from-barcode/route.js +9 -0
  11. package/.medusa/server/src/api/admin/barcodes/lookup/route.js +12 -0
  12. package/.medusa/server/src/api/admin/barcodes/print/route.js +11 -0
  13. package/.medusa/server/src/api/admin/barcodes/route.js +27 -0
  14. package/.medusa/server/src/api/admin/barcodes/scan/route.js +23 -0
  15. package/.medusa/server/src/api/admin/barcodes/tags/[id]/route.js +28 -0
  16. package/.medusa/server/src/api/admin/barcodes/tags/route.js +25 -0
  17. package/.medusa/server/src/api/admin/barcodes/templates/route.js +40 -0
  18. package/.medusa/server/src/api/admin/plugin/route.js +4 -0
  19. package/.medusa/server/src/api/admin/variants/barcode/[code]/route.js +28 -0
  20. package/.medusa/server/src/api/middlewares.js +73 -0
  21. package/.medusa/server/src/api/store/barcodes/[code]/route.js +28 -0
  22. package/.medusa/server/src/api/store/barcodes/[code]/verify/route.js +20 -0
  23. package/.medusa/server/src/api/store/plugin/route.js +4 -0
  24. package/.medusa/server/src/api/store/variants/barcode/[code]/route.js +28 -0
  25. package/.medusa/server/src/api/validators.js +173 -0
  26. package/.medusa/server/src/hooks/index.js +202 -0
  27. package/.medusa/server/src/index.js +5 -0
  28. package/.medusa/server/src/jobs/purge-expired-barcode-cache.js +10 -0
  29. package/.medusa/server/src/modules/barcode/index.js +16 -0
  30. package/.medusa/server/src/modules/barcode/migrations/Migration20260522000000.js +165 -0
  31. package/.medusa/server/src/modules/barcode/models/index.js +162 -0
  32. package/.medusa/server/src/modules/barcode/operations/context.js +2 -0
  33. package/.medusa/server/src/modules/barcode/operations/data-service.js +10 -0
  34. package/.medusa/server/src/modules/barcode/operations/generation.js +33 -0
  35. package/.medusa/server/src/modules/barcode/operations/index.js +9 -0
  36. package/.medusa/server/src/modules/barcode/operations/labels.js +57 -0
  37. package/.medusa/server/src/modules/barcode/operations/lookup.js +135 -0
  38. package/.medusa/server/src/modules/barcode/operations/maintenance.js +37 -0
  39. package/.medusa/server/src/modules/barcode/operations/stock-count.js +129 -0
  40. package/.medusa/server/src/modules/barcode/operations/tags.js +298 -0
  41. package/.medusa/server/src/modules/barcode/providers/index.js +721 -0
  42. package/.medusa/server/src/modules/barcode/service.js +161 -0
  43. package/.medusa/server/src/modules/barcode/types.js +21 -0
  44. package/.medusa/server/src/modules/barcode/utils/barcode-parser.js +399 -0
  45. package/.medusa/server/src/modules/barcode/utils/label-printer.js +533 -0
  46. package/.medusa/server/src/modules/barcode/utils/normalize-product.js +443 -0
  47. package/.medusa/server/src/modules/barcode/utils/security.js +114 -0
  48. package/.medusa/server/src/modules/barcode/utils/svg-renderer.js +492 -0
  49. package/.medusa/server/src/rbac.js +130 -0
  50. package/.medusa/server/src/sdk/index.js +164 -0
  51. package/.medusa/server/src/subscribers/product-created.js +34 -0
  52. package/.medusa/server/src/types/index.js +2 -0
  53. package/.medusa/server/src/ui/index.js +138 -0
  54. package/.medusa/server/src/workflows/apply-inventory-count.js +68 -0
  55. package/.medusa/server/src/workflows/batch-barcode-import.js +153 -0
  56. package/.medusa/server/src/workflows/bulk-generate-variant-barcodes.js +143 -0
  57. package/.medusa/server/src/workflows/generate-barcode-tag.js +44 -0
  58. package/.medusa/server/src/workflows/helpers.js +15 -0
  59. package/.medusa/server/src/workflows/index.js +7 -0
  60. package/.medusa/server/src/workflows/lookup-and-create-product.js +215 -0
  61. package/.medusa/server/src/workflows/scan-inventory-count.js +15 -0
  62. package/LICENSE +21 -0
  63. package/README.md +844 -2
  64. package/package.json +134 -3
  65. package/src/__tests__/barcode.spec.ts +836 -0
  66. package/src/__tests__/medusa-shim.mjs +331 -0
  67. package/src/__tests__/register-ts-resolver.mjs +135 -0
  68. package/src/admin/README.md +134 -0
  69. package/src/admin/components/barcode-studio-header.tsx +73 -0
  70. package/src/admin/components/batch-import-section.tsx +99 -0
  71. package/src/admin/components/dynamic-qr-tag-drawer-form.tsx +230 -0
  72. package/src/admin/components/dynamic-qr-tag-form.tsx +129 -0
  73. package/src/admin/components/dynamic-qr-tags-table.tsx +136 -0
  74. package/src/admin/components/gtin-lookup-section.tsx +155 -0
  75. package/src/admin/components/index.tsx +14 -0
  76. package/src/admin/components/label-designer-section.tsx +151 -0
  77. package/src/admin/components/label-output-section.tsx +63 -0
  78. package/src/admin/components/overview-cards.tsx +98 -0
  79. package/src/admin/components/product-barcode-card.tsx +127 -0
  80. package/src/admin/components/providers-cache-table.tsx +61 -0
  81. package/src/admin/components/providers-overview-section.tsx +49 -0
  82. package/src/admin/components/rbac-guard.tsx +153 -0
  83. package/src/admin/components/stock-take-scanner-section.tsx +116 -0
  84. package/src/admin/components/stock-take-sessions-section.tsx +109 -0
  85. package/src/admin/hooks/use-barcode-studio.ts +466 -0
  86. package/src/admin/hooks/use-product-barcodes.ts +139 -0
  87. package/src/admin/i18n/README.md +130 -0
  88. package/src/admin/i18n/index.ts +36 -0
  89. package/src/admin/i18n/json/ar.json +157 -0
  90. package/src/admin/i18n/json/de.json +157 -0
  91. package/src/admin/i18n/json/en.json +157 -0
  92. package/src/admin/i18n/json/es.json +157 -0
  93. package/src/admin/i18n/json/fr.json +157 -0
  94. package/src/admin/i18n/json/it.json +157 -0
  95. package/src/admin/i18n/json/nl.json +157 -0
  96. package/src/admin/i18n/json/pl.json +157 -0
  97. package/src/admin/i18n/json/pt.json +157 -0
  98. package/src/admin/i18n/json/tr.json +157 -0
  99. package/src/admin/routes/barcodes/lookup/page.tsx +75 -0
  100. package/src/admin/routes/barcodes/page.tsx +212 -0
  101. package/src/admin/routes/barcodes/print/page.tsx +67 -0
  102. package/src/admin/routes/barcodes/providers/page.tsx +66 -0
  103. package/src/admin/routes/barcodes/stock-take/page.tsx +74 -0
  104. package/src/admin/routes/barcodes/tags/@create/page.tsx +56 -0
  105. package/src/admin/routes/barcodes/tags/page.tsx +72 -0
  106. package/src/admin/tsconfig.json +20 -0
  107. package/src/admin/vite-env.d.ts +1 -0
  108. package/src/admin/widgets/product-barcode-widget.tsx +43 -0
  109. package/src/api/README.md +117 -0
  110. package/src/api/admin/barcodes/[barcode]/route.ts +64 -0
  111. package/src/api/admin/barcodes/batch/route.ts +12 -0
  112. package/src/api/admin/barcodes/bulk-generate/route.ts +12 -0
  113. package/src/api/admin/barcodes/cache/route.ts +35 -0
  114. package/src/api/admin/barcodes/count-sessions/[id]/apply/route.ts +17 -0
  115. package/src/api/admin/barcodes/count-sessions/[id]/scan/route.ts +17 -0
  116. package/src/api/admin/barcodes/count-sessions/route.ts +43 -0
  117. package/src/api/admin/barcodes/create-from-barcode/route.ts +16 -0
  118. package/src/api/admin/barcodes/lookup/route.ts +19 -0
  119. package/src/api/admin/barcodes/print/route.ts +18 -0
  120. package/src/api/admin/barcodes/route.ts +36 -0
  121. package/src/api/admin/barcodes/scan/route.ts +32 -0
  122. package/src/api/admin/barcodes/tags/[id]/route.ts +41 -0
  123. package/src/api/admin/barcodes/tags/route.ts +36 -0
  124. package/src/api/admin/barcodes/templates/route.ts +51 -0
  125. package/src/api/admin/plugin/route.ts +5 -0
  126. package/src/api/admin/variants/barcode/[code]/route.ts +36 -0
  127. package/src/api/middlewares.ts +91 -0
  128. package/src/api/store/barcodes/[code]/route.ts +43 -0
  129. package/src/api/store/barcodes/[code]/verify/route.ts +35 -0
  130. package/src/api/store/plugin/route.ts +5 -0
  131. package/src/api/store/variants/barcode/[code]/route.ts +36 -0
  132. package/src/api/validators.ts +217 -0
  133. package/src/hooks/index.ts +270 -0
  134. package/src/index.ts +4 -0
  135. package/src/jobs/README.md +54 -0
  136. package/src/jobs/purge-expired-barcode-cache.ts +18 -0
  137. package/src/links/README.md +44 -0
  138. package/src/modules/README.md +85 -0
  139. package/src/modules/barcode/index.ts +18 -0
  140. package/src/modules/barcode/migrations/Migration20260522000000.ts +225 -0
  141. package/src/modules/barcode/models/index.ts +168 -0
  142. package/src/modules/barcode/operations/context.ts +14 -0
  143. package/src/modules/barcode/operations/data-service.ts +10 -0
  144. package/src/modules/barcode/operations/generation.ts +57 -0
  145. package/src/modules/barcode/operations/index.ts +8 -0
  146. package/src/modules/barcode/operations/labels.ts +90 -0
  147. package/src/modules/barcode/operations/lookup.ts +202 -0
  148. package/src/modules/barcode/operations/maintenance.ts +53 -0
  149. package/src/modules/barcode/operations/stock-count.ts +217 -0
  150. package/src/modules/barcode/operations/tags.ts +425 -0
  151. package/src/modules/barcode/providers/index.ts +958 -0
  152. package/src/modules/barcode/service.ts +243 -0
  153. package/src/modules/barcode/types.ts +297 -0
  154. package/src/modules/barcode/utils/barcode-parser.ts +453 -0
  155. package/src/modules/barcode/utils/label-printer.ts +641 -0
  156. package/src/modules/barcode/utils/normalize-product.ts +524 -0
  157. package/src/modules/barcode/utils/security.ts +136 -0
  158. package/src/modules/barcode/utils/svg-renderer.ts +574 -0
  159. package/src/providers/README.md +105 -0
  160. package/src/rbac.ts +144 -0
  161. package/src/sdk/index.ts +253 -0
  162. package/src/subscribers/README.md +73 -0
  163. package/src/subscribers/product-created.ts +45 -0
  164. package/src/types/index.ts +1 -0
  165. package/src/types/medusa-ui.d.ts +118 -0
  166. package/src/ui/index.tsx +311 -0
  167. package/src/workflows/README.md +56 -0
  168. package/src/workflows/apply-inventory-count.ts +115 -0
  169. package/src/workflows/batch-barcode-import.ts +218 -0
  170. package/src/workflows/bulk-generate-variant-barcodes.ts +214 -0
  171. package/src/workflows/generate-barcode-tag.ts +85 -0
  172. package/src/workflows/helpers.ts +21 -0
  173. package/src/workflows/index.ts +6 -0
  174. package/src/workflows/lookup-and-create-product.ts +298 -0
  175. package/src/workflows/scan-inventory-count.ts +45 -0
  176. package/tsconfig.json +40 -0
@@ -0,0 +1,243 @@
1
+ import {
2
+ BarcodeCache,
3
+ BarcodeCountItem,
4
+ BarcodeCountSession,
5
+ BarcodeLabelTemplate,
6
+ BarcodeProduct,
7
+ BarcodeTag,
8
+ } from "./models"
9
+ import {
10
+ parseAndValidateBarcode,
11
+ lookupBarcode,
12
+ findBarcodeProduct,
13
+ removeBarcodeProduct,
14
+ upsertBarcodeProductLink,
15
+ } from "./operations/lookup"
16
+ import {
17
+ generateInternalVariantBarcode,
18
+ renderSvg,
19
+ } from "./operations/generation"
20
+ import {
21
+ createOrUpdateBarcodeTag,
22
+ resolveBarcodeScan,
23
+ verifyAuthenticityToken,
24
+ } from "./operations/tags"
25
+ import { listAllLabelTemplates, renderLabels } from "./operations/labels"
26
+ import {
27
+ createStockCountSession,
28
+ recordCountSessionScan,
29
+ completeCountSession,
30
+ } from "./operations/stock-count"
31
+ import {
32
+ purgeExpiredCache,
33
+ getAnalyticsOverview,
34
+ } from "./operations/maintenance"
35
+ import { type BarcodeOpsContext } from "./operations/context"
36
+ import { BarcodeDataService } from "./operations/data-service"
37
+ import { createDefaultProviderRegistry, ProviderRegistry } from "./providers"
38
+ import type { BarcodeModuleOptions } from "./types"
39
+ import { getBarcodeHmacSecret } from "./utils/security"
40
+
41
+ type InjectedDependencies = Record<string, unknown>
42
+
43
+ /** Drops the leading `ctx` parameter of an operation. */
44
+ type OpArgs<F> = F extends (ctx: BarcodeOpsContext, ...rest: infer R) => unknown
45
+ ? R
46
+ : never
47
+
48
+ /**
49
+ * Public module service. Generated CRUD methods come from `BarcodeDataService`;
50
+ * the business logic lives in `./operations/*` and is exposed here as thin
51
+ * delegating methods.
52
+ */
53
+ export class BarcodeModuleService extends BarcodeDataService {
54
+ protected readonly options_: BarcodeModuleOptions
55
+ protected readonly registry_: ProviderRegistry
56
+ protected readonly hmacSecret_: string
57
+
58
+ constructor(
59
+ container: InjectedDependencies = {},
60
+ options: BarcodeModuleOptions = {}
61
+ ) {
62
+ super(container, options)
63
+ this.options_ = {
64
+ cacheEnabled: true,
65
+ cacheTtlSeconds: 86400,
66
+ enrichmentStrategy: "first-hit",
67
+ autoGenerateVariantBarcode: true,
68
+ internalBarcodePrefix: "200",
69
+ defaultProductStatus: "draft",
70
+ downloadProductImages: false,
71
+ requestTimeoutMs: 5000,
72
+ storefrontBaseUrl:
73
+ process.env.STOREFRONT_URL ||
74
+ process.env.MEDUSA_STOREFRONT_URL ||
75
+ "https://store.example.com",
76
+ ...options,
77
+ }
78
+ this.registry_ = createDefaultProviderRegistry(this.options_)
79
+ this.hmacSecret_ = getBarcodeHmacSecret(this.options_.hmacSecret)
80
+ }
81
+
82
+ protected ctx_(): BarcodeOpsContext {
83
+ return {
84
+ svc: this,
85
+ options: this.options_,
86
+ registry: this.registry_,
87
+ hmacSecret: this.hmacSecret_,
88
+ }
89
+ }
90
+
91
+ async getModuleOptions(): Promise<BarcodeModuleOptions> {
92
+ return this.options_
93
+ }
94
+
95
+ async getProviderRegistry(): Promise<ProviderRegistry> {
96
+ return this.registry_
97
+ }
98
+
99
+ async parseAndValidateBarcode(
100
+ ...args: Parameters<typeof parseAndValidateBarcode>
101
+ ) {
102
+ return parseAndValidateBarcode(...args)
103
+ }
104
+
105
+ /**
106
+ * Looks up a barcode across the configured provider chain with caching.
107
+ */
108
+ async lookupBarcode(...args: OpArgs<typeof lookupBarcode>) {
109
+ return lookupBarcode(this.ctx_(), ...args)
110
+ }
111
+
112
+ /**
113
+ * Finds an existing `BarcodeProduct` mapping for a normalized barcode.
114
+ */
115
+ async findBarcodeProduct(...args: OpArgs<typeof findBarcodeProduct>) {
116
+ return findBarcodeProduct(this.ctx_(), ...args)
117
+ }
118
+
119
+ /**
120
+ * Removes `BarcodeProduct` mapping(s) for a normalized barcode.
121
+ */
122
+ async removeBarcodeProduct(...args: OpArgs<typeof removeBarcodeProduct>) {
123
+ return removeBarcodeProduct(this.ctx_(), ...args)
124
+ }
125
+
126
+ /**
127
+ * Creates or updates a `BarcodeProduct` mapping between a GTIN/barcode and a Medusa Product/Variant.
128
+ */
129
+ async upsertBarcodeProductLink(
130
+ ...args: OpArgs<typeof upsertBarcodeProductLink>
131
+ ) {
132
+ return upsertBarcodeProductLink(this.ctx_(), ...args)
133
+ }
134
+
135
+ /**
136
+ * Generates a valid GS1 in-store EAN-13 barcode (prefix 200-299).
137
+ */
138
+ async generateInternalVariantBarcode(
139
+ ...args: OpArgs<typeof generateInternalVariantBarcode>
140
+ ) {
141
+ return generateInternalVariantBarcode(this.ctx_(), ...args)
142
+ }
143
+
144
+ /**
145
+ * Renders any supported 1D/2D barcode symbology into a standalone SVG string.
146
+ */
147
+ async renderSvg(...args: OpArgs<typeof renderSvg>) {
148
+ return renderSvg(this.ctx_(), ...args)
149
+ }
150
+
151
+ /**
152
+ * Creates or updates a dynamic `BarcodeTag` (1D barcode or 2D QR/DataMatrix token)
153
+ * with storefront scan action, optional GS1 Digital Link, and HMAC-SHA256 anti-counterfeit signature.
154
+ */
155
+ async createOrUpdateBarcodeTag(
156
+ ...args: OpArgs<typeof createOrUpdateBarcodeTag>
157
+ ) {
158
+ return createOrUpdateBarcodeTag(this.ctx_(), ...args)
159
+ }
160
+
161
+ /**
162
+ * Resolves a storefront or admin scan against `BarcodeTag`, `BarcodeProduct`,
163
+ * and optionally Medusa's `ProductVariant` table (`barcode` / `ean` / `upc`),
164
+ * incrementing scan analytics when a tag is matched and optionally hydrating the variant and product.
165
+ */
166
+ async resolveBarcodeScan(...args: OpArgs<typeof resolveBarcodeScan>) {
167
+ return resolveBarcodeScan(this.ctx_(), ...args)
168
+ }
169
+
170
+ /**
171
+ * Verifies an anti-counterfeit HMAC-SHA256 signature for a `BarcodeTag`.
172
+ */
173
+ async verifyAuthenticityToken(
174
+ ...args: OpArgs<typeof verifyAuthenticityToken>
175
+ ) {
176
+ return verifyAuthenticityToken(this.ctx_(), ...args)
177
+ }
178
+
179
+ /**
180
+ * Lists all built-in + custom label templates.
181
+ */
182
+ async listAllLabelTemplates(...args: OpArgs<typeof listAllLabelTemplates>) {
183
+ return listAllLabelTemplates(this.ctx_(), ...args)
184
+ }
185
+
186
+ /**
187
+ * Renders printable HTML+SVG and Zebra ZPL II output for a list of label items.
188
+ */
189
+ async renderLabels(...args: OpArgs<typeof renderLabels>) {
190
+ return renderLabels(this.ctx_(), ...args)
191
+ }
192
+
193
+ /**
194
+ * Creates a new stock-take inventory count session (`BarcodeCountSession`).
195
+ */
196
+ async createStockCountSession(
197
+ ...args: OpArgs<typeof createStockCountSession>
198
+ ) {
199
+ return createStockCountSession(this.ctx_(), ...args)
200
+ }
201
+
202
+ /**
203
+ * Records a barcode scan inside a `BarcodeCountSession` and recalculates session variance totals.
204
+ */
205
+ async recordCountSessionScan(...args: OpArgs<typeof recordCountSessionScan>) {
206
+ return recordCountSessionScan(this.ctx_(), ...args)
207
+ }
208
+
209
+ /**
210
+ * Marks a count session as completed.
211
+ */
212
+ async completeCountSession(...args: OpArgs<typeof completeCountSession>) {
213
+ return completeCountSession(this.ctx_(), ...args)
214
+ }
215
+
216
+ /**
217
+ * Purges expired entries from `BarcodeCache`.
218
+ */
219
+ async purgeExpiredCache(...args: OpArgs<typeof purgeExpiredCache>) {
220
+ return purgeExpiredCache(this.ctx_(), ...args)
221
+ }
222
+
223
+ /**
224
+ * Returns a dashboard analytics overview across products, tags, cache, and stock-take sessions.
225
+ */
226
+ async getAnalyticsOverview(...args: OpArgs<typeof getAnalyticsOverview>) {
227
+ return getAnalyticsOverview(this.ctx_(), ...args)
228
+ }
229
+ }
230
+
231
+ export {
232
+ BarcodeCache,
233
+ BarcodeCountItem,
234
+ BarcodeCountSession,
235
+ BarcodeLabelTemplate,
236
+ BarcodeProduct,
237
+ BarcodeTag,
238
+ }
239
+
240
+ /**
241
+ * Alias for backward compatibility with `@bambiste/medusa-barcode`.
242
+ */
243
+ export const BarcodeService = BarcodeModuleService
@@ -0,0 +1,297 @@
1
+ export const BARCODE_MODULE = "barcode"
2
+
3
+ export const BARCODE_EVENTS = {
4
+ PRODUCT_CREATED: "barcode.product.created",
5
+ } as const
6
+
7
+ export const BARCODE_TYPES = {
8
+ EAN13: "ean13",
9
+ EAN8: "ean8",
10
+ UPCA: "upca",
11
+ UPC_A: "upca",
12
+ UPCE: "upce",
13
+ UPC_E: "upce",
14
+ GTIN14: "gtin14",
15
+ ISBN13: "isbn13",
16
+ CODE128: "code128",
17
+ GS1_128: "gs1-128",
18
+ CODE39: "code39",
19
+ QR: "qr",
20
+ DATAMATRIX: "datamatrix",
21
+ UNKNOWN: "unknown",
22
+ } as const
23
+
24
+ export type BarcodeSymbology =
25
+ | "ean13"
26
+ | "ean8"
27
+ | "upca"
28
+ | "upce"
29
+ | "gtin14"
30
+ | "isbn13"
31
+ | "code128"
32
+ | "gs1-128"
33
+ | "code39"
34
+ | "qr"
35
+ | "datamatrix"
36
+ | "unknown"
37
+
38
+ export type BarcodeType = BarcodeSymbology
39
+
40
+ export type EnrichmentStrategy = "first-hit" | "deep-merge"
41
+ export type BarcodeLookupStrategy = EnrichmentStrategy
42
+
43
+ export type BarcodeScanAction =
44
+ | "view"
45
+ | "add_to_cart"
46
+ | "verify"
47
+ | "gs1_digital_link"
48
+ | "custom"
49
+
50
+ export type BarcodeTagAction = BarcodeScanAction
51
+ export type BarcodeTagResourceType = "product" | "variant" | "order" | "custom"
52
+
53
+ export type LabelPresetId =
54
+ | "thermal_50x25"
55
+ | "thermal_57x32"
56
+ | "thermal_100x50"
57
+ | "jewelry_30x15"
58
+ | "a4_24up_70x37"
59
+ | "a4_40up_52x30"
60
+ | "a4_65up_38x21"
61
+ | "custom"
62
+
63
+ export interface Gs1ApplicationIdentifiers {
64
+ gtin?: string
65
+ ean13?: string
66
+ batchLot?: string
67
+ productionDate?: string
68
+ bestBeforeDate?: string
69
+ expiryDate?: string
70
+ serialNumber?: string
71
+ netWeightKg?: number
72
+ quantity?: number
73
+ rawAis: Record<string, string>
74
+ }
75
+
76
+ export type Gs1ParsedFields = Gs1ApplicationIdentifiers
77
+
78
+ export interface ParsedBarcode {
79
+ raw: string
80
+ normalized: string
81
+ type: BarcodeSymbology
82
+ isValid: boolean
83
+ isIsbn: boolean
84
+ checkDigit: number | null
85
+ expectedCheckDigit: number | null
86
+ ean13Equivalent: string | null
87
+ expandedUpcA?: string | null
88
+ gs1: Gs1ApplicationIdentifiers | null
89
+ error?: string
90
+ }
91
+
92
+ export interface NormalizedBarcodeProduct {
93
+ barcode: string
94
+ barcode_type: BarcodeSymbology
95
+ name: string
96
+ description: string | null
97
+ brand: string | null
98
+ manufacturer: string | null
99
+ categories: string[]
100
+ images: string[]
101
+ weight: number | null
102
+ weight_unit: "g" | "kg" | "oz" | "lb" | null
103
+ dimensions: string | null
104
+ length?: number | null
105
+ width?: number | null
106
+ height?: number | null
107
+ labels?: string[]
108
+ quantity_label: string | null
109
+ ingredients: string | null
110
+ nutrition: Record<string, unknown> | null
111
+ country_of_origin: string | null
112
+ suggested_price: number | null
113
+ currency_code: string | null
114
+ isbn: string | null
115
+ authors: string[]
116
+ publisher: string | null
117
+ published_date: string | null
118
+ page_count: number | null
119
+ provider: string
120
+ raw_data: Record<string, unknown>
121
+ }
122
+
123
+ export type NormalizedProduct = NormalizedBarcodeProduct
124
+
125
+ export interface ProviderConfig {
126
+ enabled?: boolean
127
+ priority?: number
128
+ timeout?: number
129
+ retries?: number
130
+ country?: string
131
+ apiKey?: string
132
+ baseUrl?: string
133
+ }
134
+
135
+ export type BarcodeProviderConfig = ProviderConfig
136
+
137
+ export interface BarcodeModuleOptions {
138
+ cacheEnabled?: boolean
139
+ cacheTtlSeconds?: number
140
+ enrichmentStrategy?: EnrichmentStrategy
141
+ autoGenerateVariantBarcode?: boolean
142
+ internalBarcodePrefix?: string
143
+ defaultProductStatus?: "draft" | "published"
144
+ downloadProductImages?: boolean
145
+ requestTimeoutMs?: number
146
+ storefrontBaseUrl?: string
147
+ hmacSecret?: string
148
+ providers?: {
149
+ openFoodFacts?: ProviderConfig
150
+ openBeautyFacts?: ProviderConfig
151
+ openPetFoodFacts?: ProviderConfig
152
+ openProductsFacts?: ProviderConfig
153
+ googleBooks?: ProviderConfig
154
+ openLibrary?: ProviderConfig
155
+ brocade?: ProviderConfig
156
+ upcItemDb?: ProviderConfig
157
+ eanSearch?: ProviderConfig
158
+ barcodeLookup?: ProviderConfig
159
+ }
160
+ }
161
+
162
+ export interface ProviderLookupOutcome {
163
+ provider: string
164
+ found: boolean
165
+ durationMs: number
166
+ product?: NormalizedBarcodeProduct | null
167
+ error?: string
168
+ }
169
+
170
+ export interface BarcodeLookupChainResult {
171
+ barcode: string
172
+ parsed: ParsedBarcode
173
+ found: boolean
174
+ cached: boolean
175
+ strategy: EnrichmentStrategy
176
+ product: NormalizedBarcodeProduct | null
177
+ outcomes: ProviderLookupOutcome[]
178
+ }
179
+
180
+ export interface RenderBarcodeSvgOptions {
181
+ code: string
182
+ symbology?: BarcodeSymbology
183
+ width?: number
184
+ height?: number
185
+ includeText?: boolean
186
+ darkColor?: string
187
+ lightColor?: string
188
+ quietZone?: number
189
+ title?: string
190
+ }
191
+
192
+ export interface LabelTemplateSpec {
193
+ id: string
194
+ name: string
195
+ preset_id: LabelPresetId
196
+ layout_type: "thermal_roll" | "a4_sheet"
197
+ width_mm: number
198
+ height_mm: number
199
+ columns: number
200
+ rows: number
201
+ margin_top_mm: number
202
+ margin_left_mm: number
203
+ gap_x_mm: number
204
+ gap_y_mm: number
205
+ symbology: BarcodeSymbology
206
+ show_title: boolean
207
+ show_variant_title: boolean
208
+ show_sku: boolean
209
+ show_price: boolean
210
+ show_compare_at_price: boolean
211
+ show_brand: boolean
212
+ show_qr: boolean
213
+ custom_header: string | null
214
+ custom_footer: string | null
215
+ dpi: 203 | 300
216
+ is_default: boolean
217
+ }
218
+
219
+ export interface LabelPrintItem {
220
+ barcode: string
221
+ symbology?: BarcodeSymbology
222
+ title: string
223
+ variant_title?: string | null
224
+ sku?: string | null
225
+ brand?: string | null
226
+ price?: number | null
227
+ compare_at_price?: number | null
228
+ currency_code?: string
229
+ qr_url?: string | null
230
+ quantity?: number
231
+ }
232
+
233
+ export interface LabelPrintOutput {
234
+ template: LabelTemplateSpec
235
+ total_labels: number
236
+ html: string
237
+ zpl: string
238
+ items: LabelPrintItem[]
239
+ }
240
+
241
+ export interface VariantPriceInput {
242
+ currency_code: string
243
+ amount: number
244
+ }
245
+
246
+ export interface LookupAndCreateProductInput {
247
+ barcode: string
248
+ status?: "draft" | "published"
249
+ publishImmediately?: boolean
250
+ strategy?: EnrichmentStrategy
251
+ skipCache?: boolean
252
+ skipExistingCheck?: boolean
253
+ downloadImages?: boolean
254
+ overrideTitle?: string
255
+ overrideDescription?: string
256
+ overridePrice?: number
257
+ currencyCode?: string
258
+ prices?: VariantPriceInput[]
259
+ salesChannelIds?: string[]
260
+ categoryIds?: string[]
261
+ collectionId?: string
262
+ skuPrefix?: string
263
+ }
264
+
265
+ export interface CreateProductPayload {
266
+ title: string
267
+ subtitle?: string | null
268
+ description?: string | null
269
+ handle: string
270
+ status: "draft" | "published"
271
+ thumbnail?: string | null
272
+ images: Array<{ url: string }>
273
+ weight?: number | null
274
+ length?: number | null
275
+ width?: number | null
276
+ height?: number | null
277
+ origin_country?: string | null
278
+ collection_id?: string | null
279
+ categories?: Array<{ id: string }>
280
+ sales_channels?: Array<{ id: string }>
281
+ options: Array<{ title: string; values: string[] }>
282
+ variants: Array<{
283
+ title: string
284
+ sku: string
285
+ barcode: string
286
+ ean: string | null
287
+ upc: string | null
288
+ weight?: number | null
289
+ length?: number | null
290
+ width?: number | null
291
+ height?: number | null
292
+ manage_inventory: boolean
293
+ options: Record<string, string>
294
+ prices: Array<{ amount: number; currency_code: string }>
295
+ }>
296
+ metadata: Record<string, unknown>
297
+ }