@aglyn/plugins-commerce 1.34.1 → 1.35.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 (40) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/console/woo-connections-card.component.d.ts +52 -0
  3. package/src/lib/components/console/woo-connections-card.component.js +189 -0
  4. package/src/lib/components/console/woo-connections-card.component.js.map +1 -0
  5. package/src/lib/plugin.js +13 -1
  6. package/src/lib/plugin.js.map +1 -1
  7. package/src/lib/server/order-event-triggers.js +9 -0
  8. package/src/lib/server/order-event-triggers.js.map +1 -1
  9. package/src/lib/server/woo/woo-connections.d.ts +23 -0
  10. package/src/lib/server/woo/woo-connections.js +109 -0
  11. package/src/lib/server/woo/woo-connections.js.map +1 -0
  12. package/src/lib/server/woo/woo-context.d.ts +45 -0
  13. package/src/lib/server/woo/woo-context.js +36 -0
  14. package/src/lib/server/woo/woo-context.js.map +1 -0
  15. package/src/lib/server/woo/woo-ids.d.ts +45 -0
  16. package/src/lib/server/woo/woo-ids.js +141 -0
  17. package/src/lib/server/woo/woo-ids.js.map +1 -0
  18. package/src/lib/server/woo/woo-meta.d.ts +68 -0
  19. package/src/lib/server/woo/woo-meta.js +127 -0
  20. package/src/lib/server/woo/woo-meta.js.map +1 -0
  21. package/src/lib/server/woo/woo-orders.d.ts +136 -0
  22. package/src/lib/server/woo/woo-orders.js +378 -0
  23. package/src/lib/server/woo/woo-orders.js.map +1 -0
  24. package/src/lib/server/woo/woo-products.d.ts +19 -0
  25. package/src/lib/server/woo/woo-products.js +662 -0
  26. package/src/lib/server/woo/woo-products.js.map +1 -0
  27. package/src/lib/server/woo/woo-route.d.ts +49 -0
  28. package/src/lib/server/woo/woo-route.js +333 -0
  29. package/src/lib/server/woo/woo-route.js.map +1 -0
  30. package/src/lib/server/woo/woo-shapes.d.ts +421 -0
  31. package/src/lib/server/woo/woo-shapes.js +835 -0
  32. package/src/lib/server/woo/woo-shapes.js.map +1 -0
  33. package/src/lib/server/woo/woo-system.d.ts +35 -0
  34. package/src/lib/server/woo/woo-system.js +339 -0
  35. package/src/lib/server/woo/woo-system.js.map +1 -0
  36. package/src/lib/server/woo/woo-webhooks.d.ts +53 -0
  37. package/src/lib/server/woo/woo-webhooks.js +204 -0
  38. package/src/lib/server/woo/woo-webhooks.js.map +1 -0
  39. package/src/lib/server.js +15 -0
  40. package/src/lib/server.js.map +1 -1
@@ -0,0 +1,421 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { VariantWrite } from '../api-v1/product-writes';
18
+ /** Dollars as WooCommerce writes them: `"19.99"`, or `""` for none. */
19
+ export declare function wooMoney(value: number | null | undefined): string;
20
+ /** Integer cents as WooCommerce money. */
21
+ export declare const wooCents: (cents: number | null | undefined) => string;
22
+ /**
23
+ * A WooCommerce price string as dollars: `null` for blank, `undefined` when
24
+ * it is not a price at all (the caller refuses it).
25
+ */
26
+ export declare function readWooMoney(value: unknown): number | null | undefined;
27
+ /** A moment as WooCommerce dates it: no zone, seconds precision, UTC. */
28
+ export declare function wooDate(ms: number | null | undefined): string | null;
29
+ /** A WooCommerce `after`/`before` filter as epoch ms; a zoneless date is UTC, as this store's dates are. */
30
+ export declare function readWooDate(value: string | null): number | null;
31
+ /** WooCommerce's error envelope. */
32
+ export declare function wooError(status: number, code: string, message: string, headers?: Record<string, string>): Response;
33
+ export declare const wooNotFound: (message?: string) => Response;
34
+ export declare const wooInvalidId: (what: "product" | "variation" | "order" | "webhook" | "note") => Response;
35
+ /** A product or order refusal from the store's own checks, in WooCommerce's words. */
36
+ export declare function wooRefusalFrom(response: {
37
+ status: number;
38
+ body: unknown;
39
+ }): Response;
40
+ export interface WooPage {
41
+ page: number;
42
+ perPage: number;
43
+ offset: number;
44
+ }
45
+ /** `page`, `per_page` (1–100, default 10) and `offset`, as WooCommerce reads them. */
46
+ export declare function readWooPage(search: URLSearchParams): WooPage;
47
+ /** One page of a list, with the headers WordPress sets on every collection. */
48
+ export declare function wooPaged<T>(items: readonly T[], page: WooPage, extra?: Record<string, string>): Response;
49
+ /** An order's status as WooCommerce names it. */
50
+ export declare function wooOrderStatus(status: unknown): string;
51
+ /**
52
+ * The store statuses a WooCommerce `status` filter means. `any` (or none) is
53
+ * every status; `on-hold`, `failed`, `checkout-draft` and `trash` match none,
54
+ * because no order here is ever in them.
55
+ */
56
+ export declare function storeStatusesForWooFilter(filter: string | null): ReadonlySet<string> | null;
57
+ /** A product's status as WooCommerce names it. */
58
+ export declare const wooProductStatus: (status: unknown) => string;
59
+ /** A WooCommerce product status as the store's: only `publish` is on sale. */
60
+ export declare function storeProductStatus(status: unknown): 'active' | 'draft' | 'archived' | undefined;
61
+ export interface WooProductIds {
62
+ product: number;
63
+ /** Variant id → its WooCommerce variation id. */
64
+ variants: ReadonlyMap<string, number>;
65
+ }
66
+ interface StoreVariant {
67
+ id?: string;
68
+ options?: Record<string, string>;
69
+ sku?: string;
70
+ priceUsd?: number;
71
+ compareAtPriceUsd?: number;
72
+ weightGrams?: number;
73
+ inventory?: number | null;
74
+ imageUrl?: string;
75
+ }
76
+ /** A stable small integer for an image, from its address. */
77
+ export declare function wooImageId(src: string): number;
78
+ export interface WooProductContext {
79
+ /** The store's own address, for `permalink`. */
80
+ origin: string;
81
+ categories: ReadonlyMap<string, {
82
+ id: number;
83
+ name: string;
84
+ slug: string;
85
+ }>;
86
+ }
87
+ /** A product as `GET /wc/v3/products/{id}` answers it. */
88
+ export declare function wooProduct(data: Record<string, unknown>, ids: WooProductIds, context: WooProductContext): {
89
+ backorders: string;
90
+ backorders_allowed: boolean;
91
+ backordered: boolean;
92
+ sold_individually: boolean;
93
+ weight: string;
94
+ dimensions: {
95
+ length: string;
96
+ width: string;
97
+ height: string;
98
+ };
99
+ shipping_required: boolean;
100
+ shipping_taxable: boolean;
101
+ shipping_class: string;
102
+ shipping_class_id: number;
103
+ reviews_allowed: boolean;
104
+ average_rating: string;
105
+ rating_count: number;
106
+ related_ids: any[];
107
+ upsell_ids: any[];
108
+ cross_sell_ids: any[];
109
+ parent_id: number;
110
+ purchase_note: string;
111
+ categories: {
112
+ id: number;
113
+ name: string;
114
+ slug: string;
115
+ }[];
116
+ tags: {
117
+ id: number;
118
+ name: string;
119
+ slug: string;
120
+ }[];
121
+ images: {
122
+ id: number;
123
+ src: string;
124
+ name: string;
125
+ alt: string;
126
+ position: number;
127
+ date_created: any;
128
+ date_created_gmt: any;
129
+ }[];
130
+ attributes: {
131
+ id: number;
132
+ name: string;
133
+ position: number;
134
+ visible: boolean;
135
+ variation: boolean;
136
+ options: string[];
137
+ }[];
138
+ default_attributes: any[];
139
+ variations: number[];
140
+ grouped_products: any[];
141
+ menu_order: number;
142
+ meta_data: any[];
143
+ manage_stock: boolean;
144
+ stock_quantity: number;
145
+ stock_status: string;
146
+ total_sales: number;
147
+ virtual: boolean;
148
+ downloadable: boolean;
149
+ downloads: any[];
150
+ tax_status: string;
151
+ tax_class: string;
152
+ price: string;
153
+ regular_price: string;
154
+ sale_price: string;
155
+ on_sale: boolean;
156
+ purchasable: boolean;
157
+ id: number;
158
+ name: string;
159
+ slug: string;
160
+ permalink: string;
161
+ date_created: string;
162
+ date_created_gmt: string;
163
+ date_modified: string;
164
+ date_modified_gmt: string;
165
+ type: string;
166
+ status: string;
167
+ featured: boolean;
168
+ catalog_visibility: string;
169
+ description: string;
170
+ short_description: string;
171
+ sku: string;
172
+ };
173
+ /** One variant as `GET /wc/v3/products/{id}/variations/{vid}` answers it. */
174
+ export declare function wooVariation(data: Record<string, unknown>, variant: StoreVariant, variationId: number, context: WooProductContext): {
175
+ status: string;
176
+ virtual: boolean;
177
+ downloadable: boolean;
178
+ downloads: any[];
179
+ tax_status: string;
180
+ tax_class: string;
181
+ manage_stock: boolean;
182
+ stock_quantity: number;
183
+ stock_status: string;
184
+ backorders: string;
185
+ backorders_allowed: boolean;
186
+ backordered: boolean;
187
+ weight: string;
188
+ dimensions: {
189
+ length: string;
190
+ width: string;
191
+ height: string;
192
+ };
193
+ shipping_class: string;
194
+ shipping_class_id: number;
195
+ image: {
196
+ id: number;
197
+ src: string;
198
+ name: string;
199
+ alt: string;
200
+ position: number;
201
+ date_created: any;
202
+ date_created_gmt: any;
203
+ };
204
+ attributes: {
205
+ id: number;
206
+ name: string;
207
+ option: string;
208
+ }[];
209
+ menu_order: number;
210
+ meta_data: any[];
211
+ price: string;
212
+ regular_price: string;
213
+ sale_price: string;
214
+ on_sale: boolean;
215
+ purchasable: boolean;
216
+ id: number;
217
+ date_created: string;
218
+ date_created_gmt: string;
219
+ date_modified: string;
220
+ date_modified_gmt: string;
221
+ description: string;
222
+ permalink: string;
223
+ sku: string;
224
+ };
225
+ /** The prices of a WooCommerce write as the store's variant write. */
226
+ export declare function variantWriteFromWoo(body: Record<string, unknown>): {
227
+ write: VariantWrite;
228
+ } | {
229
+ error: string;
230
+ };
231
+ /** The images a WooCommerce write names, as addresses, in their order. */
232
+ export declare function imagesFromWoo(value: unknown): string[] | null;
233
+ export interface ProductWriteFromWoo {
234
+ values: Record<string, unknown>;
235
+ /** For a simple product: its one variant's prices, SKU, weight and stock. */
236
+ simpleVariant: VariantWrite | null;
237
+ /** WooCommerce category ids the write names, to map to the store's. */
238
+ categoryIds: number[];
239
+ }
240
+ /**
241
+ * A WooCommerce product create or update as the body of the store's own
242
+ * product write (`readProductWrite`), plus the one variant a simple product
243
+ * prices. Attributes marked for variations become the product's options, so
244
+ * its variant grid is every combination, as the editor builds it; the other
245
+ * attributes are descriptive in WooCommerce and are not kept.
246
+ */
247
+ export declare function productWriteFromWoo(body: Record<string, unknown>, create: boolean): ProductWriteFromWoo | {
248
+ error: string;
249
+ };
250
+ /**
251
+ * The options one WooCommerce variation names: `{ Color: 'Black', Size: 'M' }`.
252
+ * Attribute names are matched to the product's options without regard to
253
+ * case or a `pa_` prefix, and the product's spelling is kept.
254
+ */
255
+ export declare function variationOptionsFromWoo(attributes: unknown, productOptions: ReadonlyArray<{
256
+ name: string;
257
+ values: string[];
258
+ }>): Record<string, string>;
259
+ /**
260
+ * The product's options with every value a variation names added, so the
261
+ * variation exists in the grid. `null` when nothing is missing.
262
+ */
263
+ export declare function optionsWithVariation(productOptions: ReadonlyArray<{
264
+ name: string;
265
+ values: string[];
266
+ }>, selection: Record<string, string>): Array<{
267
+ name: string;
268
+ values: string[];
269
+ }> | null;
270
+ export interface WooOrderIds {
271
+ order: number;
272
+ /** `productId` → WooCommerce product id; `productId|variantId` → variation id. */
273
+ lines: ReadonlyMap<string, number>;
274
+ }
275
+ export declare const lineIdKey: (productId: string, variantId?: string) => string;
276
+ /** An order as `GET /wc/v3/orders/{id}` answers it. */
277
+ export declare function wooOrder(orderId: string, data: Record<string, unknown>, ids: WooOrderIds, extras: {
278
+ meta: Record<string, string>;
279
+ testMode: boolean;
280
+ }): {
281
+ id: number;
282
+ parent_id: number;
283
+ number: string;
284
+ order_key: string;
285
+ created_via: string;
286
+ version: string;
287
+ status: string;
288
+ currency: string;
289
+ currency_symbol: string;
290
+ date_created: string;
291
+ date_created_gmt: string;
292
+ date_modified: string;
293
+ date_modified_gmt: string;
294
+ discount_total: string;
295
+ discount_tax: string;
296
+ shipping_total: string;
297
+ shipping_tax: string;
298
+ cart_tax: string;
299
+ total: string;
300
+ total_tax: string;
301
+ prices_include_tax: boolean;
302
+ customer_id: number;
303
+ customer_ip_address: string;
304
+ customer_user_agent: string;
305
+ customer_note: string;
306
+ billing: {
307
+ email: string;
308
+ company: string;
309
+ address_1: string;
310
+ address_2: string;
311
+ city: string;
312
+ state: string;
313
+ postcode: string;
314
+ country: string;
315
+ phone: string;
316
+ first_name: string;
317
+ last_name: string;
318
+ };
319
+ shipping: {
320
+ company: string;
321
+ address_1: string;
322
+ address_2: string;
323
+ city: string;
324
+ state: string;
325
+ postcode: string;
326
+ country: string;
327
+ phone: string;
328
+ first_name: string;
329
+ last_name: string;
330
+ };
331
+ payment_method: string;
332
+ payment_method_title: string;
333
+ transaction_id: string;
334
+ date_paid: string;
335
+ date_paid_gmt: string;
336
+ date_completed: string;
337
+ date_completed_gmt: string;
338
+ cart_hash: string;
339
+ meta_data: {
340
+ id: number;
341
+ key: string;
342
+ value: string;
343
+ }[];
344
+ line_items: {
345
+ id: number;
346
+ name: string;
347
+ product_id: number;
348
+ variation_id: number;
349
+ quantity: number;
350
+ tax_class: string;
351
+ subtotal: string;
352
+ subtotal_tax: string;
353
+ total: string;
354
+ total_tax: string;
355
+ taxes: any[];
356
+ meta_data: any[];
357
+ sku: string;
358
+ price: number;
359
+ image: {
360
+ id: string;
361
+ src: string;
362
+ };
363
+ parent_name: string;
364
+ }[];
365
+ tax_lines: any[];
366
+ shipping_lines: {
367
+ id: number;
368
+ method_title: string;
369
+ method_id: string;
370
+ instance_id: string;
371
+ total: string;
372
+ total_tax: string;
373
+ taxes: any[];
374
+ meta_data: any[];
375
+ }[];
376
+ fee_lines: any[];
377
+ coupon_lines: {
378
+ id: number;
379
+ code: string;
380
+ discount: string;
381
+ discount_tax: string;
382
+ meta_data: any[];
383
+ }[];
384
+ refunds: any[];
385
+ set_paid: boolean;
386
+ needs_payment: boolean;
387
+ needs_processing: boolean;
388
+ is_editable: boolean;
389
+ };
390
+ export interface WooTracking {
391
+ trackingNumber: string;
392
+ carrier: string;
393
+ trackingUrl: string;
394
+ }
395
+ /**
396
+ * Tracking from a WooCommerce shipment-tracking entry or from an order's
397
+ * `meta_data`, in the forms the common tracking extensions write it:
398
+ * WooCommerce Shipment Tracking and Advanced Shipment Tracking
399
+ * (`_wc_shipment_tracking_items`), AfterShip, YITH and the bare
400
+ * `tracking_number` many apps set. `null` when none names a number.
401
+ */
402
+ export declare function trackingFromWooMeta(meta: Record<string, unknown>): WooTracking | null;
403
+ /** One shipment-tracking entry (`tracking_number`, `tracking_provider`, `tracking_link`, …). */
404
+ export declare function trackingFromShipmentEntry(entry: Record<string, unknown>): WooTracking | null;
405
+ /** `meta_data: [{ key, value }]` as a map; later entries win, as WooCommerce's update does. */
406
+ export declare function metaMap(value: unknown): Record<string, unknown>;
407
+ /**
408
+ * Tracking in an order note's text, as fulfillment apps write it:
409
+ * "Tracking number: 9400…", "tracking no. LX123…", or a link to a carrier's
410
+ * tracking page. `null` when the note names no number.
411
+ */
412
+ export declare function trackingFromNote(note: string): WooTracking | null;
413
+ /**
414
+ * The WooCommerce version this surface reports. Apps gate features on it;
415
+ * this is the line whose REST API v3 the surface follows.
416
+ */
417
+ export declare const WOO_REPORTED_VERSION = "9.4.0";
418
+ export declare const WP_REPORTED_VERSION = "6.7";
419
+ /** The REST namespaces the store's `/wp-json/` index lists. */
420
+ export declare const WOO_NAMESPACES: readonly ["wc/v3", "wc/v2", "wc-shipment-tracking/v3", "wc-auth/v1"];
421
+ export {};