@beyondplusmm/doehpos-sdk 0.2.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -4,6 +4,30 @@ All notable changes to `@beyondplusmm/doehpos-sdk` are documented here. This pro
4
4
  [Semantic Versioning](https://semver.org/). The stable surface is `delivery`;
5
5
  `@experimental` modules may change in a minor release until they graduate.
6
6
 
7
+ ## 0.3.0
8
+
9
+ ### Removed (breaking)
10
+
11
+ - **kitchen** capability — `client.kitchen`, `KitchenModule`, and the
12
+ `TicketCreate` / `TicketResponse` types are removed. Kitchen is an
13
+ operator-facing subsystem (KDS, printers, prep queues, staff workflows), not a
14
+ third-party developer capability, so it no longer ships in the developer SDK or
15
+ the Merchant API docs. Pre-1.0 breaking change per SemVer (a `0.x` minor may
16
+ break). Apps that used `client.kitchen` must remove those calls; `0.2.0`
17
+ remains available on npm with kitchen if needed during migration. The stable
18
+ surface is now `delivery` and `loyalty`.
19
+
20
+ ### Added (experimental)
21
+
22
+ - **orders** capability (`client.orders.submit` / `.get`, `POST /v1/orders`) —
23
+ `@experimental`. A server-priced **sales submission**: the client sends a
24
+ basket of `{ sku, qty }`; the server resolves prices/tax/inventory/totals.
25
+ Clients never send prices, a grand total, or a currency. Additive to and
26
+ independent of the legacy money-total `delivery.create`. New typed errors:
27
+ `EmptyOrderError`, `UnknownSkuError`, `UnpricedSkuError`,
28
+ `InsufficientStockError`. **Not live** until the edge façade over the POS sale
29
+ aggregate exists — stays `@experimental` until exercised end to end.
30
+
7
31
  ## 0.2.0
8
32
 
9
33
  ### Changed
package/README.md CHANGED
@@ -69,12 +69,19 @@ const result = await queue.flush(); // reuses the same key — exactly one order
69
69
 
70
70
  ## Stability
71
71
 
72
- `delivery`, `kitchen`, and `loyalty` are the **stable** surface — all exercised
73
- by the Expo reference app (`kitchen`/`loyalty` graduated in 0.2.0). `marketplace`
72
+ `delivery` and `loyalty` are the **stable** surface — both exercised by the Expo
73
+ reference app (`loyalty` graduated in 0.2.0). `marketplace`
74
74
  and `rider` remain **`@experimental`** — generated from their OpenAPI specs and
75
- the golden client, but not yet exercised by the reference app. Modules graduate
76
- experimental → reference-app-exercised stable. Evidence promotes an API;
77
- a schema only permits it.
75
+ the golden client, but not yet exercised by the reference app. The **`orders`**
76
+ capability (server-priced sales submission, `POST /v1/orders`) is also
77
+ **`@experimental`** and **not yet live** — its edge façade over the POS sale
78
+ aggregate is not built; the typed surface ships ahead of the backend.
79
+
80
+ **Promotion rule.** A module graduates to stable when its contract has been
81
+ **observed live in sandbox by at least one authoritative client** (the golden
82
+ client and/or the Phase G synthetic probe) **and** is **exercised by the
83
+ reference app**. The phone is not the verifier — it is another consumer of an
84
+ already-proven contract. Evidence promotes an API; a schema only permits it.
78
85
 
79
86
  ## Sandbox boundary
80
87
 
package/dist/client.d.ts CHANGED
@@ -12,10 +12,10 @@
12
12
  import { type Environment } from "./config.js";
13
13
  import { Transport, type FetchLike } from "./transport.js";
14
14
  import { DeliveryModule } from "./modules/delivery.js";
15
- import { KitchenModule } from "./modules/kitchen.js";
16
15
  import { LoyaltyModule } from "./modules/loyalty.js";
17
16
  import { MarketplaceModule } from "./modules/experimental/marketplace.js";
18
17
  import { RiderModule } from "./modules/experimental/rider.js";
18
+ import { OrdersModule } from "./modules/experimental/orders.js";
19
19
  export interface DoehClientOptions {
20
20
  apiKey: string;
21
21
  /** "sandbox" (default) or "production". Ignored if baseUrl is given. */
@@ -38,13 +38,17 @@ export interface DoehClientOptions {
38
38
  export declare class DoehClient {
39
39
  readonly delivery: DeliveryModule;
40
40
  /** Stable since 0.2.0 (reference-app exercised). */
41
- readonly kitchen: KitchenModule;
42
- /** Stable since 0.2.0 (reference-app exercised). */
43
41
  readonly loyalty: LoyaltyModule;
44
42
  /** @experimental Not yet exercised by the reference app. */
45
43
  readonly marketplace: MarketplaceModule;
46
44
  /** @experimental Not yet exercised by the reference app. */
47
45
  readonly rider: RiderModule;
46
+ /**
47
+ * @experimental Server-priced sales submission (`POST /v1/orders`). Additive
48
+ * to `delivery`; the edge façade over the POS sale aggregate is not yet built,
49
+ * so this is not live. See openapi/orders.yaml.
50
+ */
51
+ readonly orders: OrdersModule;
48
52
  private readonly transport;
49
53
  constructor(opts: DoehClientOptions);
50
54
  /** Internal: the configured transport (used by OfflineQueue wiring/tests). */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,qBAAa,UAAU;IACrB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,oDAAoD;I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O,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,qBAAa,UAAU;IACrB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAEhC,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,IAAI,EAAE,iBAAiB;IAkCnC,8EAA8E;IAC9E,IAAI,UAAU,IAAI,SAAS,CAE1B;CACF"}
package/dist/client.js CHANGED
@@ -12,10 +12,10 @@
12
12
  import { BASE_URLS, DEFAULTS, SDK_VERSION } from "./config.js";
13
13
  import { Transport } from "./transport.js";
14
14
  import { DeliveryModule } from "./modules/delivery.js";
15
- import { KitchenModule } from "./modules/kitchen.js";
16
15
  import { LoyaltyModule } from "./modules/loyalty.js";
17
16
  import { MarketplaceModule } from "./modules/experimental/marketplace.js";
18
17
  import { RiderModule } from "./modules/experimental/rider.js";
18
+ import { OrdersModule } from "./modules/experimental/orders.js";
19
19
  export class DoehClient {
20
20
  constructor(opts) {
21
21
  if (!opts.apiKey)
@@ -41,10 +41,10 @@ export class DoehClient {
41
41
  sleep: opts.sleep,
42
42
  });
43
43
  this.delivery = new DeliveryModule(this.transport);
44
- this.kitchen = new KitchenModule(this.transport);
45
44
  this.loyalty = new LoyaltyModule(this.transport);
46
45
  this.marketplace = new MarketplaceModule(this.transport);
47
46
  this.rider = new RiderModule(this.transport);
47
+ this.orders = new OrdersModule(this.transport);
48
48
  }
49
49
  /** Internal: the configured transport (used by OfflineQueue wiring/tests). */
50
50
  get _transport() {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;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jD,CAAC;IAED,8EAA8E;IAC9E,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
package/dist/errors.d.ts CHANGED
@@ -50,6 +50,16 @@ export declare class UnsupportedCurrencyError extends DoehApiError {
50
50
  }
51
51
  export declare class BadBodyError extends DoehApiError {
52
52
  }
53
+ export declare class EmptyOrderError extends DoehApiError {
54
+ }
55
+ export declare class UnknownSkuError extends DoehApiError {
56
+ }
57
+ export declare class UnpricedSkuError extends DoehApiError {
58
+ }
59
+ export declare class InsufficientStockError extends DoehApiError {
60
+ }
61
+ export declare class FulfillmentNotAvailableError extends DoehApiError {
62
+ }
53
63
  export declare class RateLimitedError extends DoehApiError {
54
64
  }
55
65
  /** Build the right typed error from an HTTP status + parsed body. */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAcA,6CAA6C;AAC7C,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAM5B;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBACd,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO;CAK/E;AAED,iFAAiF;AACjF,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAErB,MAAM,EAAE,M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qEAAqE;AACrE,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,MAAM,GACf,YAAY,CAOd;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjD"}
package/dist/errors.js CHANGED
@@ -54,6 +54,17 @@ export class UnsupportedCurrencyError extends DoehApiError {
54
54
  } // EDGE_UNSUPPORTED_CURRENCY
55
55
  export class BadBodyError extends DoehApiError {
56
56
  } // EDGE_BAD_BODY
57
+ // ── 422 — sales submission / catalog (Orders capability, @experimental) ───────
58
+ export class EmptyOrderError extends DoehApiError {
59
+ } // EDGE_EMPTY_ORDER
60
+ export class UnknownSkuError extends DoehApiError {
61
+ } // EDGE_UNKNOWN_SKU
62
+ export class UnpricedSkuError extends DoehApiError {
63
+ } // EDGE_UNPRICED_SKU
64
+ export class InsufficientStockError extends DoehApiError {
65
+ } // EDGE_INSUFFICIENT_STOCK
66
+ export class FulfillmentNotAvailableError extends DoehApiError {
67
+ } // EDGE_FULFILLMENT_NOT_AVAILABLE (V1: delivery not yet served)
57
68
  // ── 429 — rate limited (retried internally; only surfaced when retries exhaust)
58
69
  export class RateLimitedError extends DoehApiError {
59
70
  }
@@ -70,6 +81,11 @@ const CODE_TO_CLASS = {
70
81
  EDGE_INVALID_AMOUNT: InvalidAmountError,
71
82
  EDGE_UNSUPPORTED_CURRENCY: UnsupportedCurrencyError,
72
83
  EDGE_BAD_BODY: BadBodyError,
84
+ EDGE_EMPTY_ORDER: EmptyOrderError,
85
+ EDGE_UNKNOWN_SKU: UnknownSkuError,
86
+ EDGE_UNPRICED_SKU: UnpricedSkuError,
87
+ EDGE_INSUFFICIENT_STOCK: InsufficientStockError,
88
+ EDGE_FULFILLMENT_NOT_AVAILABLE: FulfillmentNotAvailableError,
73
89
  };
74
90
  /** Build the right typed error from an HTTP status + parsed body. */
75
91
  export function mapApiError(status, body, traceId) {
@@ -1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C;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,kBAAkB;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,GAAG,YAAY,gBAAgB;QAAE,OAAO,IAAI,CAAC;IACjD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @beyondplusmm/doehpos-sdk — official TypeScript SDK for the Doeh POS public API.
3
3
  *
4
- * A typed port of the validated golden client. The stable surface is `delivery`,
5
- * `kitchen`, and `loyalty` (all reference-app exercised); `marketplace`/`rider`
6
- * remain @experimental until exercised by the reference app.
4
+ * A typed port of the validated golden client. The stable surface is `delivery`
5
+ * and `loyalty` (reference-app exercised); `marketplace`/`rider` remain
6
+ * @experimental until exercised by the reference app.
7
7
  */
8
8
  export { DoehClient } from "./client.js";
9
9
  export type { DoehClientOptions } from "./client.js";
@@ -11,10 +11,11 @@ export { BASE_URLS, SDK_VERSION, type Environment } from "./config.js";
11
11
  export { generateIdempotencyKey, type UuidFn } from "./idempotency.js";
12
12
  export { OfflineQueue, MemoryStorage, type QueueStorage, type QueuedMutation, type DeadLetter, type FlushResult, } from "./queue.js";
13
13
  export type { Currency, OrderStatus, OrderCreate, Order, OrderResponse, ErrorBody, CallOptions, } from "./types.js";
14
- export { DoehError, DoehTransportError, DoehApiError, ApiKeyInvalidError, ApiKeyExpiredError, ApiKeyRevokedError, EnvMismatchError, ScopeDeniedError, TransportDisabledError, OrderNotFoundError, ReplayError, InvalidAmountError, UnsupportedCurrencyError, BadBodyError, RateLimitedError, isRetryable, mapApiError, } from "./errors.js";
14
+ export type { FulfillmentType, PaymentStatus, OrderLineInput, Customer, Fulfillment, SalesSubmission, OrderLine, OrderTotals, SubmittedOrder, SubmissionResponse, } from "./types.js";
15
+ export { DoehError, DoehTransportError, DoehApiError, ApiKeyInvalidError, ApiKeyExpiredError, ApiKeyRevokedError, EnvMismatchError, ScopeDeniedError, TransportDisabledError, OrderNotFoundError, ReplayError, InvalidAmountError, UnsupportedCurrencyError, BadBodyError, EmptyOrderError, UnknownSkuError, UnpricedSkuError, InsufficientStockError, FulfillmentNotAvailableError, RateLimitedError, isRetryable, mapApiError, } from "./errors.js";
15
16
  export { DeliveryModule } from "./modules/delivery.js";
16
- export { KitchenModule, type TicketCreate, type TicketResponse } from "./modules/kitchen.js";
17
17
  export { LoyaltyModule, type EarnInput, type AccountResponse } from "./modules/loyalty.js";
18
18
  export { MarketplaceModule, type ListingCreate, type ListingResponse, } from "./modules/experimental/marketplace.js";
19
19
  export { RiderModule, type JobCreate, type JobResponse } from "./modules/experimental/rider.js";
20
+ export { OrdersModule } from "./modules/experimental/orders.js";
20
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,sBAAsB,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,KAAK,EACL,aAAa,EACb,SAAS,EACT,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,kBA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AM,YAAY,CAAC;AAGpB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EACL,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /**
2
2
  * @beyondplusmm/doehpos-sdk — official TypeScript SDK for the Doeh POS public API.
3
3
  *
4
- * A typed port of the validated golden client. The stable surface is `delivery`,
5
- * `kitchen`, and `loyalty` (all reference-app exercised); `marketplace`/`rider`
6
- * remain @experimental until exercised by the reference app.
4
+ * A typed port of the validated golden client. The stable surface is `delivery`
5
+ * and `loyalty` (reference-app exercised); `marketplace`/`rider` remain
6
+ * @experimental until exercised by the reference app.
7
7
  */
8
8
  export { DoehClient } from "./client.js";
9
9
  export { BASE_URLS, SDK_VERSION } from "./config.js";
10
10
  export { generateIdempotencyKey } from "./idempotency.js";
11
11
  export { OfflineQueue, MemoryStorage, } from "./queue.js";
12
12
  // Error ABI — consumers catch these classes, never parse `code` strings.
13
- export { DoehError, DoehTransportError, DoehApiError, ApiKeyInvalidError, ApiKeyExpiredError, ApiKeyRevokedError, EnvMismatchError, ScopeDeniedError, TransportDisabledError, OrderNotFoundError, ReplayError, InvalidAmountError, UnsupportedCurrencyError, BadBodyError, RateLimitedError, isRetryable, mapApiError, } from "./errors.js";
13
+ export { DoehError, DoehTransportError, DoehApiError, ApiKeyInvalidError, ApiKeyExpiredError, ApiKeyRevokedError, EnvMismatchError, ScopeDeniedError, TransportDisabledError, OrderNotFoundError, ReplayError, InvalidAmountError, UnsupportedCurrencyError, BadBodyError, EmptyOrderError, UnknownSkuError, UnpricedSkuError, InsufficientStockError, FulfillmentNotAvailableError, RateLimitedError, isRetryable, mapApiError, } from "./errors.js";
14
14
  // Module classes + their types (handy for typing app code).
15
15
  export { DeliveryModule } from "./modules/delivery.js";
16
- export { KitchenModule } from "./modules/kitchen.js";
17
16
  export { LoyaltyModule } from "./modules/loyalty.js";
18
17
  export { MarketplaceModule, } from "./modules/experimental/marketplace.js";
19
18
  export { RiderModule } from "./modules/experimental/rider.js";
19
+ export { OrdersModule } from "./modules/experimental/orders.js";
20
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAoB,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,sBAAsB,EAAe,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,aAAa,GAKd,MAAM,YAAY,CAAC;AAYpB,yEAAyE;AACzE,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,kBAAkB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AiC,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Orders (Sales Submission) — EXPERIMENTAL.
3
+ *
4
+ * @experimental The server-priced sales-submission capability. A submission is a
5
+ * basket of {sku, qty}; the server resolves prices from the catalog, applies
6
+ * tax/discounts/promotions/loyalty, deducts inventory, records COGS, and computes
7
+ * all totals. Clients NEVER send prices or a grand total, and never a currency
8
+ * (it is branch-native, derived from the token). This is the typed surface for
9
+ * `POST /v1/orders` (see openapi/orders.yaml).
10
+ *
11
+ * Additive to and independent of the legacy money-total `delivery.create`. Stays
12
+ * @experimental until the edge façade over the POS sale aggregate exists and the
13
+ * capability is exercised live (promotion rule: observed-live + reference-app).
14
+ */
15
+ import type { Transport } from "../../transport.js";
16
+ import type { CallOptions, SalesSubmission, SubmissionResponse } from "../../types.js";
17
+ export declare class OrdersModule {
18
+ private readonly transport;
19
+ constructor(transport: Transport);
20
+ /**
21
+ * Submit a sale by line items. Returns 201 on first write, or 200 with
22
+ * `idempotent: true` when an Idempotency-Key replays an existing order.
23
+ *
24
+ * Client-side validation is intentionally minimal — it mirrors only the
25
+ * obvious structural rules (non-empty basket, positive integer quantities)
26
+ * so mistakes fail without burning a request. The server remains the source
27
+ * of truth for SKUs, pricing, stock, and totals.
28
+ */
29
+ submit(input: SalesSubmission, opts?: CallOptions): Promise<SubmissionResponse>;
30
+ /** Read a submitted order (resolved lines + totals) by id. */
31
+ get(id: string, opts?: CallOptions): Promise<SubmissionResponse>;
32
+ }
33
+ //# sourceMappingURL=orders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../src/modules/experimental/orders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMvF,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuBzF,8DAA8D;IACxD,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAY3E"}
@@ -0,0 +1,53 @@
1
+ import { generateIdempotencyKey } from "../../idempotency.js";
2
+ /** Path ids must match this server-side pattern; we fail fast client-side. */
3
+ const PATH_ID = /^[A-Za-z0-9_]+$/;
4
+ export class OrdersModule {
5
+ constructor(transport) {
6
+ this.transport = transport;
7
+ }
8
+ /**
9
+ * Submit a sale by line items. Returns 201 on first write, or 200 with
10
+ * `idempotent: true` when an Idempotency-Key replays an existing order.
11
+ *
12
+ * Client-side validation is intentionally minimal — it mirrors only the
13
+ * obvious structural rules (non-empty basket, positive integer quantities)
14
+ * so mistakes fail without burning a request. The server remains the source
15
+ * of truth for SKUs, pricing, stock, and totals.
16
+ */
17
+ async submit(input, opts = {}) {
18
+ if (!Array.isArray(input.lines) || input.lines.length === 0) {
19
+ throw new RangeError("a submission requires at least one line");
20
+ }
21
+ for (const line of input.lines) {
22
+ if (!line || typeof line.sku !== "string" || line.sku.length === 0) {
23
+ throw new RangeError("each line requires a non-empty sku");
24
+ }
25
+ if (!Number.isInteger(line.qty) || line.qty < 1) {
26
+ throw new RangeError(`line ${JSON.stringify(line.sku)} qty must be an integer >= 1`);
27
+ }
28
+ }
29
+ const { body } = await this.transport.request({
30
+ method: "POST",
31
+ path: "/v1/orders",
32
+ body: input,
33
+ idempotencyKey: opts.idempotencyKey ?? generateIdempotencyKey("orders"),
34
+ traceId: opts.traceId,
35
+ signal: opts.signal,
36
+ });
37
+ return body;
38
+ }
39
+ /** Read a submitted order (resolved lines + totals) by id. */
40
+ async get(id, opts = {}) {
41
+ if (!PATH_ID.test(id)) {
42
+ throw new RangeError(`invalid order id ${JSON.stringify(id)} (must match ${PATH_ID})`);
43
+ }
44
+ const { body } = await this.transport.request({
45
+ method: "GET",
46
+ path: `/v1/orders/${id}`,
47
+ traceId: opts.traceId,
48
+ signal: opts.signal,
49
+ });
50
+ return body;
51
+ }
52
+ }
53
+ //# sourceMappingURL=orders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.js","sourceRoot":"","sources":["../../../src/modules/experimental/orders.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,8EAA8E;AAC9E,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAElC,MAAM,OAAO,YAAY;IACvB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB,EAAE,OAAoB,EAAE;QACzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,UAAU,CAAC,yCAAyC,CAAC,CAAC;QAClE,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnE,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;YAC7D,CAAC;YACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;gBAChD,MAAM,IAAI,UAAU,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAqB;YAChE,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,KAAK;YACX,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,sBAAsB,CAAC,QAAQ,CAAC;YACvE,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8DAA8D;IAC9D,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,OAAoB,EAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,UAAU,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,gBAAgB,OAAO,GAAG,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAqB;YAChE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc,EAAE,EAAE;YACxB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -37,6 +37,68 @@ export interface ErrorBody {
37
37
  /** Internal verification step (diagnostic only). */
38
38
  step?: string;
39
39
  }
40
+ export type FulfillmentType = "pickup" | "delivery" | "dine_in";
41
+ /** One requested line: WHAT and HOW MANY only — never a price, name, or station. */
42
+ export interface OrderLineInput {
43
+ sku: string;
44
+ /** Integer >= 1. */
45
+ qty: number;
46
+ /** Optional catalog modifier ids; priced server-side. */
47
+ modifier_ids?: string[];
48
+ }
49
+ export interface Customer {
50
+ /** E.164, e.g. +95912345678. */
51
+ phone?: string;
52
+ }
53
+ export interface Fulfillment {
54
+ type?: FulfillmentType;
55
+ }
56
+ /** Request body for POST /v1/orders. No currency, no prices, no total. */
57
+ export interface SalesSubmission {
58
+ lines: OrderLineInput[];
59
+ customer?: Customer;
60
+ fulfillment?: Fulfillment;
61
+ }
62
+ /** A line as resolved and priced by the server. */
63
+ export interface OrderLine {
64
+ sku: string;
65
+ name?: string;
66
+ qty: number;
67
+ unit_price_minor: number;
68
+ line_total_minor: number;
69
+ tax_minor?: number;
70
+ }
71
+ export interface OrderTotals {
72
+ currency: Currency;
73
+ subtotal_minor: number;
74
+ discount_minor: number;
75
+ tax_minor: number;
76
+ grand_total_minor: number;
77
+ }
78
+ /** Settlement state of a submitted order. V1 is always "unpaid" (pay_later). */
79
+ export type PaymentStatus = "unpaid" | "paid";
80
+ export interface SubmittedOrder {
81
+ id: string;
82
+ status: OrderStatus;
83
+ /** V1: always "unpaid" — a submission is purchase intent, not settlement. */
84
+ payment_status: PaymentStatus;
85
+ shop_id: number;
86
+ branch_id: number;
87
+ lines: OrderLine[];
88
+ totals: OrderTotals;
89
+ customer?: Customer;
90
+ fulfillment?: Fulfillment;
91
+ created_at_utc: string;
92
+ /** created_at rendered in the branch's native timezone. */
93
+ created_at_local: string;
94
+ idempotency_key?: string;
95
+ }
96
+ export interface SubmissionResponse {
97
+ ok: boolean;
98
+ /** true if this was an idempotent replay (HTTP 200 instead of 201). */
99
+ idempotent?: boolean;
100
+ order: SubmittedOrder;
101
+ }
40
102
  /** Per-call options that map onto request headers. */
41
103
  export interface CallOptions {
42
104
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK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AAO,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beyondplusmm/doehpos-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Official TypeScript SDK for the Doeh POS public API — a typed port of the validated golden client.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/client.ts CHANGED
@@ -12,10 +12,10 @@
12
12
  import { BASE_URLS, DEFAULTS, SDK_VERSION, type Environment } from "./config.js";
13
13
  import { Transport, type FetchLike } from "./transport.js";
14
14
  import { DeliveryModule } from "./modules/delivery.js";
15
- import { KitchenModule } from "./modules/kitchen.js";
16
15
  import { LoyaltyModule } from "./modules/loyalty.js";
17
16
  import { MarketplaceModule } from "./modules/experimental/marketplace.js";
18
17
  import { RiderModule } from "./modules/experimental/rider.js";
18
+ import { OrdersModule } from "./modules/experimental/orders.js";
19
19
 
20
20
  export interface DoehClientOptions {
21
21
  apiKey: string;
@@ -40,14 +40,18 @@ export interface DoehClientOptions {
40
40
  export class DoehClient {
41
41
  readonly delivery: DeliveryModule;
42
42
  /** Stable since 0.2.0 (reference-app exercised). */
43
- readonly kitchen: KitchenModule;
44
- /** Stable since 0.2.0 (reference-app exercised). */
45
43
  readonly loyalty: LoyaltyModule;
46
44
 
47
45
  /** @experimental Not yet exercised by the reference app. */
48
46
  readonly marketplace: MarketplaceModule;
49
47
  /** @experimental Not yet exercised by the reference app. */
50
48
  readonly rider: RiderModule;
49
+ /**
50
+ * @experimental Server-priced sales submission (`POST /v1/orders`). Additive
51
+ * to `delivery`; the edge façade over the POS sale aggregate is not yet built,
52
+ * so this is not live. See openapi/orders.yaml.
53
+ */
54
+ readonly orders: OrdersModule;
51
55
 
52
56
  private readonly transport: Transport;
53
57
 
@@ -79,10 +83,10 @@ export class DoehClient {
79
83
  });
80
84
 
81
85
  this.delivery = new DeliveryModule(this.transport);
82
- this.kitchen = new KitchenModule(this.transport);
83
86
  this.loyalty = new LoyaltyModule(this.transport);
84
87
  this.marketplace = new MarketplaceModule(this.transport);
85
88
  this.rider = new RiderModule(this.transport);
89
+ this.orders = new OrdersModule(this.transport);
86
90
  }
87
91
 
88
92
  /** Internal: the configured transport (used by OfflineQueue wiring/tests). */
package/src/errors.ts CHANGED
@@ -75,6 +75,13 @@ export class InvalidAmountError extends DoehApiError {} // EDGE_INVALID_AMOUNT
75
75
  export class UnsupportedCurrencyError extends DoehApiError {} // EDGE_UNSUPPORTED_CURRENCY
76
76
  export class BadBodyError extends DoehApiError {} // EDGE_BAD_BODY
77
77
 
78
+ // ── 422 — sales submission / catalog (Orders capability, @experimental) ───────
79
+ export class EmptyOrderError extends DoehApiError {} // EDGE_EMPTY_ORDER
80
+ export class UnknownSkuError extends DoehApiError {} // EDGE_UNKNOWN_SKU
81
+ export class UnpricedSkuError extends DoehApiError {} // EDGE_UNPRICED_SKU
82
+ export class InsufficientStockError extends DoehApiError {} // EDGE_INSUFFICIENT_STOCK
83
+ export class FulfillmentNotAvailableError extends DoehApiError {} // EDGE_FULFILLMENT_NOT_AVAILABLE (V1: delivery not yet served)
84
+
78
85
  // ── 429 — rate limited (retried internally; only surfaced when retries exhaust)
79
86
  export class RateLimitedError extends DoehApiError {}
80
87
 
@@ -91,6 +98,11 @@ const CODE_TO_CLASS: Record<string, typeof DoehApiError> = {
91
98
  EDGE_INVALID_AMOUNT: InvalidAmountError,
92
99
  EDGE_UNSUPPORTED_CURRENCY: UnsupportedCurrencyError,
93
100
  EDGE_BAD_BODY: BadBodyError,
101
+ EDGE_EMPTY_ORDER: EmptyOrderError,
102
+ EDGE_UNKNOWN_SKU: UnknownSkuError,
103
+ EDGE_UNPRICED_SKU: UnpricedSkuError,
104
+ EDGE_INSUFFICIENT_STOCK: InsufficientStockError,
105
+ EDGE_FULFILLMENT_NOT_AVAILABLE: FulfillmentNotAvailableError,
94
106
  };
95
107
 
96
108
  /** Build the right typed error from an HTTP status + parsed body. */
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @beyondplusmm/doehpos-sdk — official TypeScript SDK for the Doeh POS public API.
3
3
  *
4
- * A typed port of the validated golden client. The stable surface is `delivery`,
5
- * `kitchen`, and `loyalty` (all reference-app exercised); `marketplace`/`rider`
6
- * remain @experimental until exercised by the reference app.
4
+ * A typed port of the validated golden client. The stable surface is `delivery`
5
+ * and `loyalty` (reference-app exercised); `marketplace`/`rider` remain
6
+ * @experimental until exercised by the reference app.
7
7
  */
8
8
  export { DoehClient } from "./client.js";
9
9
  export type { DoehClientOptions } from "./client.js";
@@ -31,6 +31,20 @@ export type {
31
31
  CallOptions,
32
32
  } from "./types.js";
33
33
 
34
+ // Orders (Sales Submission) capability types — @experimental.
35
+ export type {
36
+ FulfillmentType,
37
+ PaymentStatus,
38
+ OrderLineInput,
39
+ Customer,
40
+ Fulfillment,
41
+ SalesSubmission,
42
+ OrderLine,
43
+ OrderTotals,
44
+ SubmittedOrder,
45
+ SubmissionResponse,
46
+ } from "./types.js";
47
+
34
48
  // Error ABI — consumers catch these classes, never parse `code` strings.
35
49
  export {
36
50
  DoehError,
@@ -47,6 +61,11 @@ export {
47
61
  InvalidAmountError,
48
62
  UnsupportedCurrencyError,
49
63
  BadBodyError,
64
+ EmptyOrderError,
65
+ UnknownSkuError,
66
+ UnpricedSkuError,
67
+ InsufficientStockError,
68
+ FulfillmentNotAvailableError,
50
69
  RateLimitedError,
51
70
  isRetryable,
52
71
  mapApiError,
@@ -54,7 +73,6 @@ export {
54
73
 
55
74
  // Module classes + their types (handy for typing app code).
56
75
  export { DeliveryModule } from "./modules/delivery.js";
57
- export { KitchenModule, type TicketCreate, type TicketResponse } from "./modules/kitchen.js";
58
76
  export { LoyaltyModule, type EarnInput, type AccountResponse } from "./modules/loyalty.js";
59
77
  export {
60
78
  MarketplaceModule,
@@ -62,3 +80,4 @@ export {
62
80
  type ListingResponse,
63
81
  } from "./modules/experimental/marketplace.js";
64
82
  export { RiderModule, type JobCreate, type JobResponse } from "./modules/experimental/rider.js";
83
+ export { OrdersModule } from "./modules/experimental/orders.js";
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Orders (Sales Submission) — EXPERIMENTAL.
3
+ *
4
+ * @experimental The server-priced sales-submission capability. A submission is a
5
+ * basket of {sku, qty}; the server resolves prices from the catalog, applies
6
+ * tax/discounts/promotions/loyalty, deducts inventory, records COGS, and computes
7
+ * all totals. Clients NEVER send prices or a grand total, and never a currency
8
+ * (it is branch-native, derived from the token). This is the typed surface for
9
+ * `POST /v1/orders` (see openapi/orders.yaml).
10
+ *
11
+ * Additive to and independent of the legacy money-total `delivery.create`. Stays
12
+ * @experimental until the edge façade over the POS sale aggregate exists and the
13
+ * capability is exercised live (promotion rule: observed-live + reference-app).
14
+ */
15
+ import type { Transport } from "../../transport.js";
16
+ import type { CallOptions, SalesSubmission, SubmissionResponse } from "../../types.js";
17
+ import { generateIdempotencyKey } from "../../idempotency.js";
18
+
19
+ /** Path ids must match this server-side pattern; we fail fast client-side. */
20
+ const PATH_ID = /^[A-Za-z0-9_]+$/;
21
+
22
+ export class OrdersModule {
23
+ constructor(private readonly transport: Transport) {}
24
+
25
+ /**
26
+ * Submit a sale by line items. Returns 201 on first write, or 200 with
27
+ * `idempotent: true` when an Idempotency-Key replays an existing order.
28
+ *
29
+ * Client-side validation is intentionally minimal — it mirrors only the
30
+ * obvious structural rules (non-empty basket, positive integer quantities)
31
+ * so mistakes fail without burning a request. The server remains the source
32
+ * of truth for SKUs, pricing, stock, and totals.
33
+ */
34
+ async submit(input: SalesSubmission, opts: CallOptions = {}): Promise<SubmissionResponse> {
35
+ if (!Array.isArray(input.lines) || input.lines.length === 0) {
36
+ throw new RangeError("a submission requires at least one line");
37
+ }
38
+ for (const line of input.lines) {
39
+ if (!line || typeof line.sku !== "string" || line.sku.length === 0) {
40
+ throw new RangeError("each line requires a non-empty sku");
41
+ }
42
+ if (!Number.isInteger(line.qty) || line.qty < 1) {
43
+ throw new RangeError(`line ${JSON.stringify(line.sku)} qty must be an integer >= 1`);
44
+ }
45
+ }
46
+ const { body } = await this.transport.request<SubmissionResponse>({
47
+ method: "POST",
48
+ path: "/v1/orders",
49
+ body: input,
50
+ idempotencyKey: opts.idempotencyKey ?? generateIdempotencyKey("orders"),
51
+ traceId: opts.traceId,
52
+ signal: opts.signal,
53
+ });
54
+ return body;
55
+ }
56
+
57
+ /** Read a submitted order (resolved lines + totals) by id. */
58
+ async get(id: string, opts: CallOptions = {}): Promise<SubmissionResponse> {
59
+ if (!PATH_ID.test(id)) {
60
+ throw new RangeError(`invalid order id ${JSON.stringify(id)} (must match ${PATH_ID})`);
61
+ }
62
+ const { body } = await this.transport.request<SubmissionResponse>({
63
+ method: "GET",
64
+ path: `/v1/orders/${id}`,
65
+ traceId: opts.traceId,
66
+ signal: opts.signal,
67
+ });
68
+ return body;
69
+ }
70
+ }
package/src/types.ts CHANGED
@@ -49,6 +49,83 @@ export interface ErrorBody {
49
49
  step?: string;
50
50
  }
51
51
 
52
+ // ── Orders (Sales Submission) capability — @experimental ─────────────────────
53
+ // A submission is a basket of {sku, qty}; the server owns pricing/tax/inventory/
54
+ // totals. Clients NEVER send prices or a grand total. Currency is branch-native
55
+ // (token-derived) and returned in the response. See openapi/orders.yaml.
56
+
57
+ export type FulfillmentType = "pickup" | "delivery" | "dine_in";
58
+
59
+ /** One requested line: WHAT and HOW MANY only — never a price, name, or station. */
60
+ export interface OrderLineInput {
61
+ sku: string;
62
+ /** Integer >= 1. */
63
+ qty: number;
64
+ /** Optional catalog modifier ids; priced server-side. */
65
+ modifier_ids?: string[];
66
+ }
67
+
68
+ export interface Customer {
69
+ /** E.164, e.g. +95912345678. */
70
+ phone?: string;
71
+ }
72
+
73
+ export interface Fulfillment {
74
+ type?: FulfillmentType;
75
+ }
76
+
77
+ /** Request body for POST /v1/orders. No currency, no prices, no total. */
78
+ export interface SalesSubmission {
79
+ lines: OrderLineInput[];
80
+ customer?: Customer;
81
+ fulfillment?: Fulfillment;
82
+ }
83
+
84
+ /** A line as resolved and priced by the server. */
85
+ export interface OrderLine {
86
+ sku: string;
87
+ name?: string;
88
+ qty: number;
89
+ unit_price_minor: number;
90
+ line_total_minor: number;
91
+ tax_minor?: number;
92
+ }
93
+
94
+ export interface OrderTotals {
95
+ currency: Currency;
96
+ subtotal_minor: number;
97
+ discount_minor: number;
98
+ tax_minor: number;
99
+ grand_total_minor: number;
100
+ }
101
+
102
+ /** Settlement state of a submitted order. V1 is always "unpaid" (pay_later). */
103
+ export type PaymentStatus = "unpaid" | "paid";
104
+
105
+ export interface SubmittedOrder {
106
+ id: string;
107
+ status: OrderStatus;
108
+ /** V1: always "unpaid" — a submission is purchase intent, not settlement. */
109
+ payment_status: PaymentStatus;
110
+ shop_id: number;
111
+ branch_id: number;
112
+ lines: OrderLine[];
113
+ totals: OrderTotals;
114
+ customer?: Customer;
115
+ fulfillment?: Fulfillment;
116
+ created_at_utc: string;
117
+ /** created_at rendered in the branch's native timezone. */
118
+ created_at_local: string;
119
+ idempotency_key?: string;
120
+ }
121
+
122
+ export interface SubmissionResponse {
123
+ ok: boolean;
124
+ /** true if this was an idempotent replay (HTTP 200 instead of 201). */
125
+ idempotent?: boolean;
126
+ order: SubmittedOrder;
127
+ }
128
+
52
129
  /** Per-call options that map onto request headers. */
53
130
  export interface CallOptions {
54
131
  /**
@@ -1,32 +0,0 @@
1
- /**
2
- * Kitchen — stable.
3
- *
4
- * POST /v1/kitchen/tickets create a ticket (idempotent with an Idempotency-Key)
5
- * GET /v1/kitchen/tickets/{id} read back
6
- *
7
- * Scope is derived from the key server-side; there is no shop/branch argument.
8
- * Graduated from @experimental in 0.2.0 once exercised by the Expo reference app.
9
- */
10
- import type { Transport } from "../transport.js";
11
- import type { CallOptions } from "../types.js";
12
- export interface TicketCreate {
13
- station: string;
14
- items: string[];
15
- }
16
- export interface TicketResponse {
17
- ok: boolean;
18
- idempotent?: boolean;
19
- ticket: {
20
- id: string;
21
- [k: string]: unknown;
22
- };
23
- }
24
- export declare class KitchenModule {
25
- private readonly transport;
26
- constructor(transport: Transport);
27
- /** Create a kitchen ticket. Idempotent with an Idempotency-Key. */
28
- createTicket(input: TicketCreate, opts?: CallOptions): Promise<TicketResponse>;
29
- /** Read a kitchen ticket back by id. */
30
- getTicket(id: string, opts?: CallOptions): Promise<TicketResponse>;
31
- }
32
- //# sourceMappingURL=kitchen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kitchen.d.ts","sourceRoot":"","sources":["../../src/modules/kitchen.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AACD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAC9C;AAID,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD,mEAAmE;IAC7D,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAYxF,wCAAwC;IAClC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;CAU7E"}
@@ -1,32 +0,0 @@
1
- import { generateIdempotencyKey } from "../idempotency.js";
2
- const PATH_ID = /^[A-Za-z0-9_]+$/;
3
- export class KitchenModule {
4
- constructor(transport) {
5
- this.transport = transport;
6
- }
7
- /** Create a kitchen ticket. Idempotent with an Idempotency-Key. */
8
- async createTicket(input, opts = {}) {
9
- const { body } = await this.transport.request({
10
- method: "POST",
11
- path: "/v1/kitchen/tickets",
12
- body: input,
13
- idempotencyKey: opts.idempotencyKey ?? generateIdempotencyKey("kitchen"),
14
- traceId: opts.traceId,
15
- signal: opts.signal,
16
- });
17
- return body;
18
- }
19
- /** Read a kitchen ticket back by id. */
20
- async getTicket(id, opts = {}) {
21
- if (!PATH_ID.test(id))
22
- throw new RangeError(`invalid ticket id ${JSON.stringify(id)}`);
23
- const { body } = await this.transport.request({
24
- method: "GET",
25
- path: `/v1/kitchen/tickets/${id}`,
26
- traceId: opts.traceId,
27
- signal: opts.signal,
28
- });
29
- return body;
30
- }
31
- }
32
- //# sourceMappingURL=kitchen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kitchen.js","sourceRoot":"","sources":["../../src/modules/kitchen.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAY3D,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAElC,MAAM,OAAO,aAAa;IACxB,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAErD,mEAAmE;IACnE,KAAK,CAAC,YAAY,CAAC,KAAmB,EAAE,OAAoB,EAAE;QAC5D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAiB;YAC5D,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,KAAK;YACX,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,sBAAsB,CAAC,SAAS,CAAC;YACxE,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,SAAS,CAAC,EAAU,EAAE,OAAoB,EAAE;QAChD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,UAAU,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACvF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAiB;YAC5D,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB,EAAE,EAAE;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -1,53 +0,0 @@
1
- /**
2
- * Kitchen — stable.
3
- *
4
- * POST /v1/kitchen/tickets create a ticket (idempotent with an Idempotency-Key)
5
- * GET /v1/kitchen/tickets/{id} read back
6
- *
7
- * Scope is derived from the key server-side; there is no shop/branch argument.
8
- * Graduated from @experimental in 0.2.0 once exercised by the Expo reference app.
9
- */
10
- import type { Transport } from "../transport.js";
11
- import type { CallOptions } from "../types.js";
12
- import { generateIdempotencyKey } from "../idempotency.js";
13
-
14
- export interface TicketCreate {
15
- station: string;
16
- items: string[];
17
- }
18
- export interface TicketResponse {
19
- ok: boolean;
20
- idempotent?: boolean;
21
- ticket: { id: string; [k: string]: unknown };
22
- }
23
-
24
- const PATH_ID = /^[A-Za-z0-9_]+$/;
25
-
26
- export class KitchenModule {
27
- constructor(private readonly transport: Transport) {}
28
-
29
- /** Create a kitchen ticket. Idempotent with an Idempotency-Key. */
30
- async createTicket(input: TicketCreate, opts: CallOptions = {}): Promise<TicketResponse> {
31
- const { body } = await this.transport.request<TicketResponse>({
32
- method: "POST",
33
- path: "/v1/kitchen/tickets",
34
- body: input,
35
- idempotencyKey: opts.idempotencyKey ?? generateIdempotencyKey("kitchen"),
36
- traceId: opts.traceId,
37
- signal: opts.signal,
38
- });
39
- return body;
40
- }
41
-
42
- /** Read a kitchen ticket back by id. */
43
- async getTicket(id: string, opts: CallOptions = {}): Promise<TicketResponse> {
44
- if (!PATH_ID.test(id)) throw new RangeError(`invalid ticket id ${JSON.stringify(id)}`);
45
- const { body } = await this.transport.request<TicketResponse>({
46
- method: "GET",
47
- path: `/v1/kitchen/tickets/${id}`,
48
- traceId: opts.traceId,
49
- signal: opts.signal,
50
- });
51
- return body;
52
- }
53
- }