@use-stall/types 0.3.18 → 0.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.
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./src/billing-payments";
2
+ export * from "./src/catalog";
2
3
  export * from "./src/components";
3
4
  export * from "./src/customers";
4
5
  export * from "./src/device";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@use-stall/types",
3
- "version": "0.3.18",
3
+ "version": "0.5.0",
4
4
  "description": "Type declarations for Stall SDKs",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
@@ -0,0 +1,58 @@
1
+ import {
2
+ UnifiedAttributeType,
3
+ UnifiedVariantsAttributeType,
4
+ UnifiedProductImagesType,
5
+ } from "./product";
6
+
7
+ /**
8
+ * The sellable projection of a product variant — a product/variant/inventory join, already
9
+ * scoped to one location and one sales channel. Computed server-side (stall-database) so
10
+ * every consumer (Terminal, any other channel) gets the same answer for "what can I sell,
11
+ * at what price, and how much is there" without doing any of that joining itself.
12
+ */
13
+ export interface UnifiedCatalogVariantType {
14
+ id: string; // variant id
15
+ title: string;
16
+ description: string;
17
+ thumbnail: string;
18
+ sku: string;
19
+ barcode: string;
20
+ price: number;
21
+ sale_price: number;
22
+ price_currency: string;
23
+ on_sale: boolean;
24
+ default: boolean;
25
+ attributes: UnifiedVariantsAttributeType[]; // this variant's selected options, e.g. [{ name: "Size", option: "M" }]
26
+ inventory: {
27
+ unavailable: number; // at this location
28
+ committed: number; // at this location
29
+ in_stock: number; // at this location — available for new orders
30
+ on_hand: number; // at this location
31
+ };
32
+ }
33
+
34
+ /**
35
+ * A sellable product — the entity Terminal (and any other selling channel) should fetch
36
+ * instead of raw products. Only published products/variants that are assigned to the
37
+ * requested location and sales channel are ever included; nothing here needs client-side
38
+ * filtering or computation.
39
+ */
40
+ export interface UnifiedCatalogType {
41
+ id: string; // product id
42
+ title: string;
43
+ handle: string;
44
+ description: string;
45
+ body_html: string;
46
+ thumbnail: string;
47
+ images: UnifiedProductImagesType[];
48
+ tax_class: string;
49
+ taxable: boolean;
50
+ categories: string[];
51
+ collections: string[];
52
+ brand: string;
53
+ tags: string[];
54
+ track_inventory: boolean; // from this product's default (or first) sellable variant
55
+ attributes: UnifiedAttributeType[]; // the axes of variation, e.g. [{ name: "Size", options: ["S","M","L"] }]
56
+ variants: CatalogVariantType[]; // already filtered to this location + sales channel
57
+ stock: number; // combined in_stock across variants, at this location
58
+ }
package/src/payments.d.ts CHANGED
@@ -33,6 +33,22 @@ export interface UnifiedPaymentMethodType {
33
33
  instant_clear: boolean; // whether the payment is cleared instantly like cash or custom
34
34
  }
35
35
 
36
+ // The method actually used to collect one specific payment — richer than
37
+ // UnifiedPaymentMethodType (which just describes what a provider supports), since it
38
+ // captures the named device config and this collection's own details. No optional fields —
39
+ // original_amount/cash always carry real (possibly zero) values so callers never need to
40
+ // null-check them.
41
+ export interface UnifiedChargedPaymentMethodType extends UnifiedPaymentMethodType {
42
+ name: string;
43
+ method_id: string; // the device's payment-method serial/reference; distinct from the
44
+ // top-level UnifiedPaymentCollectionType.external_id (an external provider's own reference)
45
+ original_amount: number;
46
+ cash: {
47
+ tendered: number;
48
+ change: number;
49
+ };
50
+ }
51
+
36
52
  export interface UnifiedPaymentProviderConfigType {
37
53
  id: string;
38
54
  provider: string; // provider id
@@ -53,7 +69,8 @@ export interface UnifiedPaymentProviderConfigType {
53
69
 
54
70
  export interface FrontendPaymentMethodType {
55
71
  id: string;
56
- provider: {
72
+ // Absent for methods with no payment gateway to resolve, e.g. cash.
73
+ provider?: {
57
74
  id: string; // provider id
58
75
  name: string;
59
76
  logo: string;
@@ -98,7 +115,7 @@ export interface UnifiedPaymentCollectionType {
98
115
  };
99
116
  provider_id: string;
100
117
  external_id: string;
101
- payment_method: UnifiedPaymentMethodType;
118
+ payment_method: UnifiedChargedPaymentMethodType;
102
119
  note: string;
103
120
  device: {
104
121
  id: string;