@aglyn/plugins-commerce 1.26.6 → 1.28.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 (34) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/console/pos-hardware-card.component.js +70 -67
  3. package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
  4. package/src/lib/components/console/pos-hardware-waiting-card.component.js +19 -17
  5. package/src/lib/components/console/pos-hardware-waiting-card.component.js.map +1 -1
  6. package/src/lib/components/console/product-editor-dialog.component.js +4 -43
  7. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  8. package/src/lib/contracts.d.ts +7 -0
  9. package/src/lib/contracts.js.map +1 -1
  10. package/src/lib/model/pos-hardware-shop.d.ts +152 -0
  11. package/src/lib/model/pos-hardware-shop.js +152 -0
  12. package/src/lib/model/pos-hardware-shop.js.map +1 -0
  13. package/src/lib/model/product-write.d.ts +29 -8
  14. package/src/lib/model/product-write.js +64 -2
  15. package/src/lib/model/product-write.js.map +1 -1
  16. package/src/lib/native-nav.js +13 -1
  17. package/src/lib/native-nav.js.map +1 -1
  18. package/src/lib/server/api-v1/openapi.d.ts +6 -6
  19. package/src/lib/server/api-v1/openapi.js +203 -16
  20. package/src/lib/server/api-v1/openapi.js.map +1 -1
  21. package/src/lib/server/api-v1/order-view.d.ts +8 -0
  22. package/src/lib/server/api-v1/order-view.js +21 -4
  23. package/src/lib/server/api-v1/order-view.js.map +1 -1
  24. package/src/lib/server/api-v1/orders-and-products.js +46 -59
  25. package/src/lib/server/api-v1/orders-and-products.js.map +1 -1
  26. package/src/lib/server/api-v1/product-view.d.ts +76 -0
  27. package/src/lib/server/api-v1/product-view.js +86 -0
  28. package/src/lib/server/api-v1/product-view.js.map +1 -0
  29. package/src/lib/server/api-v1/product-writes.d.ts +149 -0
  30. package/src/lib/server/api-v1/product-writes.js +673 -0
  31. package/src/lib/server/api-v1/product-writes.js.map +1 -0
  32. package/src/lib/server/products-write.d.ts +94 -2
  33. package/src/lib/server/products-write.js +171 -112
  34. package/src/lib/server/products-write.js.map +1 -1
@@ -0,0 +1,149 @@
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 ApiV1Context } from '@aglyn/tenant-data-admin/server/api-v1-kit';
18
+ import { type ProductOption, type ProductStatus, type ProductType, type ProductVariant } from '../../model/commerce';
19
+ import { type EditedProduct } from '../../model/product-write';
20
+ import { type ProductBuildRefusal, type ProductSaveInput } from '../products-write';
21
+ /** The members a product write may carry, in the order the description lists them. */
22
+ export declare const PRODUCT_WRITABLE_KEYS: readonly ["name", "description", "status", "type", "slug", "tags", "categoryIds", "mediaUrls", "options", "variants", "seo"];
23
+ /** The members a variant write may carry. */
24
+ export declare const VARIANT_WRITABLE_KEYS: readonly ["priceUsd", "compareAtPriceUsd", "sku", "barcode", "weightGrams", "inventory"];
25
+ /**
26
+ * The kinds of product a caller may make. A digital product delivers files a
27
+ * person uploads in the editor, so it is made there.
28
+ */
29
+ export declare const PRODUCT_API_TYPES: readonly ProductType[];
30
+ export declare const PRODUCT_DIGITAL_REFUSAL = "A digital product delivers files uploaded in the console, so it is created and changed to digital there.";
31
+ export declare const PRODUCT_STATUSES: readonly ProductStatus[];
32
+ /** The stock a digital or service subscription cannot keep (AGL-1744), as the editor says it. */
33
+ export declare const PRODUCT_STOCK_NOT_TRACKED = "Stock is not tracked on a digital or service subscription. Send `null` to clear it.";
34
+ /** One variant's writable fields, as parsed. `null` clears a field; absent leaves it. */
35
+ export interface VariantWrite {
36
+ priceUsd?: number | null;
37
+ compareAtPriceUsd?: number | null;
38
+ sku?: string | null;
39
+ barcode?: string | null;
40
+ weightGrams?: number | null;
41
+ inventory?: number | null;
42
+ }
43
+ /** One entry of a product write's `variants`: the variant it names, and what changes on it. */
44
+ export interface VariantTargetWrite extends VariantWrite {
45
+ id?: string;
46
+ options?: Record<string, string>;
47
+ }
48
+ export interface ProductWriteValues {
49
+ name?: string;
50
+ description?: string;
51
+ status?: ProductStatus;
52
+ type?: ProductType;
53
+ slug?: string;
54
+ tags?: string[];
55
+ categoryIds?: string[];
56
+ mediaUrls?: string[];
57
+ options?: ProductOption[];
58
+ variants?: VariantTargetWrite[];
59
+ seo?: {
60
+ title?: string | null;
61
+ description?: string | null;
62
+ };
63
+ }
64
+ type Parsed<T> = {
65
+ values: T;
66
+ } | {
67
+ errors: Record<string, string>;
68
+ };
69
+ /**
70
+ * One variant's writable fields from a body (`VariantWrite`). With `target`,
71
+ * also the `id` or `options` that name which variant it is — an entry of a
72
+ * product write's `variants`.
73
+ */
74
+ export declare function readVariantWrite(body: unknown, options?: {
75
+ target?: boolean;
76
+ prefix?: string;
77
+ }): Parsed<VariantTargetWrite>;
78
+ /**
79
+ * A product write's body (`ProductWrite`): the members the editor lets a
80
+ * person set without a further plan feature. Every member it does not name
81
+ * is a 400 that names it. `create` requires `name`.
82
+ */
83
+ export declare function readProductWrite(body: Record<string, unknown>, options: {
84
+ create: boolean;
85
+ }): Parsed<ProductWriteValues>;
86
+ /** A variant with a variant write applied, as the editor's grid applies a typed cell. */
87
+ export declare function applyVariantWrite(variant: ProductVariant, write: VariantWrite): ProductVariant;
88
+ /**
89
+ * The product a write makes of `base`: only the members it carries change,
90
+ * so every field it does not name — the ones this API does not expose
91
+ * included — stays as stored.
92
+ */
93
+ export declare function mergeProductWrite(base: EditedProduct, values: ProductWriteValues, nowMs: number): EditedProduct | ProductBuildRefusal;
94
+ /** Seams for the specs; production passes none. */
95
+ export interface ProductApiDeps {
96
+ now?: () => number;
97
+ dropCache?: ProductSaveInput['dropCache'];
98
+ }
99
+ /**
100
+ * The product a create starts from: the editor's blank draft, unpriced.
101
+ *
102
+ * The editor opens a new product at its default price for the person looking
103
+ * at it to change or clear. A caller sees no such field: one that sent no
104
+ * price asked for none, so its variant is saved unpriced — "Price coming
105
+ * soon", not for sale (`variantHasPrice`) — rather than at a price nobody
106
+ * chose. A grid rebuilt from options takes the first variant's values, as the
107
+ * editor's does, so its new combinations are unpriced too until a variant
108
+ * write prices them.
109
+ */
110
+ export declare function unpricedProductDraft(): EditedProduct;
111
+ /**
112
+ * `POST /v1/sites/{siteId}/products` — the editor's Add product.
113
+ *
114
+ * A draft unless `status` says otherwise, as the editor starts one, so a new
115
+ * product is not on sale until someone means it to be. The id is minted
116
+ * here. The slug is claimed from the name when none is sent, as Duplicate
117
+ * claims one (`claimProductSlug`), and a sent slug another product holds —
118
+ * a deleted one's included, because a deleted product still answers its
119
+ * slug on the storefront — is a 409.
120
+ *
121
+ * Replay-safe on an `Idempotency-Key`, as `createContact` is and for its
122
+ * reasons: validation above the claim, every refusal after it releasing the
123
+ * key, the plan and the allowance counted inside the save's transaction.
124
+ */
125
+ export declare function createProduct(request: Request, ctx: ApiV1Context, hostId: string, deps?: ProductApiDeps): Promise<Response>;
126
+ /**
127
+ * `PATCH /v1/sites/{siteId}/products/{productId}` — the editor's save, for
128
+ * the fields sent. The editor's save is a full replace, so the stored product
129
+ * is read in the save's transaction and only the members sent change on it:
130
+ * subscription terms, add-ons, stock holds, stored timestamps and every other
131
+ * field this API does not expose stay as stored. A slug another product
132
+ * holds is a 409. An empty body changes nothing and answers the product.
133
+ */
134
+ export declare function updateProduct(request: Request, ctx: ApiV1Context, hostId: string, productId: string, deps?: ProductApiDeps): Promise<Response>;
135
+ /**
136
+ * `PATCH /v1/sites/{siteId}/products/{productId}/variants/{variantId}` —
137
+ * one row of the editor's variant grid: its price, compare-at price, SKU,
138
+ * barcode, weight and stock, through the same save, so every check runs.
139
+ * Answers the whole product.
140
+ */
141
+ export declare function updateProductVariant(request: Request, ctx: ApiV1Context, hostId: string, productId: string, variantId: string, deps?: ProductApiDeps): Promise<Response>;
142
+ /**
143
+ * `DELETE /v1/sites/{siteId}/products/{productId}` — the products list's
144
+ * Delete: `deletedAt` on the product, which takes it off sale, and the
145
+ * site's cache drop. Asked again, it answers the same receipt; a product
146
+ * that never existed is a 404.
147
+ */
148
+ export declare function deleteProductOverApi(ctx: ApiV1Context, hostId: string, productId: string, deps?: ProductApiDeps): Promise<Response>;
149
+ export {};