@theatrical/sdk 0.1.0 → 0.1.1
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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +41 -13
- package/dist/index.mjs +41 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2231,6 +2231,8 @@ declare class MockHTTPAdapter {
|
|
|
2231
2231
|
post<T>(path: string, options?: {
|
|
2232
2232
|
body?: unknown;
|
|
2233
2233
|
}): Promise<T>;
|
|
2234
|
+
/** Build an order response that satisfies `orderSchema` from a create-order request body. */
|
|
2235
|
+
private buildMockOrder;
|
|
2234
2236
|
put<T>(path: string, options?: {
|
|
2235
2237
|
body?: unknown;
|
|
2236
2238
|
}): Promise<T>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2231,6 +2231,8 @@ declare class MockHTTPAdapter {
|
|
|
2231
2231
|
post<T>(path: string, options?: {
|
|
2232
2232
|
body?: unknown;
|
|
2233
2233
|
}): Promise<T>;
|
|
2234
|
+
/** Build an order response that satisfies `orderSchema` from a create-order request body. */
|
|
2235
|
+
private buildMockOrder;
|
|
2234
2236
|
put<T>(path: string, options?: {
|
|
2235
2237
|
body?: unknown;
|
|
2236
2238
|
}): Promise<T>;
|
package/dist/index.js
CHANGED
|
@@ -1806,11 +1806,14 @@ var DEFAULT_MOCK_RESPONSES = {
|
|
|
1806
1806
|
"/ocapi/v1/orders": {
|
|
1807
1807
|
id: "ord_mock_001",
|
|
1808
1808
|
status: "draft",
|
|
1809
|
-
siteId: "site_roxy_wellington",
|
|
1810
1809
|
sessionId: "ses_roxy_holdovers_20260427_1915",
|
|
1811
1810
|
tickets: [],
|
|
1812
1811
|
items: [],
|
|
1813
|
-
|
|
1812
|
+
subtotal: 0,
|
|
1813
|
+
tax: 0,
|
|
1814
|
+
discount: 0,
|
|
1815
|
+
total: 0,
|
|
1816
|
+
currency: "NZD",
|
|
1814
1817
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1815
1818
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1816
1819
|
},
|
|
@@ -1859,21 +1862,46 @@ var MockHTTPAdapter = class {
|
|
|
1859
1862
|
return data;
|
|
1860
1863
|
}
|
|
1861
1864
|
async post(path, options) {
|
|
1865
|
+
if (path.split("?")[0].endsWith("/orders")) {
|
|
1866
|
+
return this.buildMockOrder(options?.body);
|
|
1867
|
+
}
|
|
1862
1868
|
const data = this.lookup(path);
|
|
1863
1869
|
if (data !== void 0) return data;
|
|
1864
|
-
|
|
1870
|
+
return {};
|
|
1871
|
+
}
|
|
1872
|
+
/** Build an order response that satisfies `orderSchema` from a create-order request body. */
|
|
1873
|
+
buildMockOrder(body) {
|
|
1874
|
+
const input = body && typeof body === "object" ? body : {};
|
|
1875
|
+
const prices = { adult: 18.5, child: 12.5, senior: 14.5, concession: 14 };
|
|
1876
|
+
const tickets = (input.tickets ?? []).map((t, i) => {
|
|
1877
|
+
const type = t.type ?? "adult";
|
|
1878
|
+
const seatId = t.seatId ?? `seat_${i + 1}`;
|
|
1865
1879
|
return {
|
|
1866
|
-
id: `
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1872
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1873
|
-
...options?.body && typeof options.body === "object" ? options.body : {}
|
|
1880
|
+
id: `tkt_mock_${i + 1}`,
|
|
1881
|
+
type,
|
|
1882
|
+
seatId,
|
|
1883
|
+
seatLabel: seatId.replace(/^seat_/i, "").toUpperCase(),
|
|
1884
|
+
price: prices[type] ?? prices.adult
|
|
1874
1885
|
};
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1886
|
+
});
|
|
1887
|
+
const subtotal = tickets.reduce((sum, t) => sum + t.price, 0);
|
|
1888
|
+
const tax = Math.round(subtotal * 0.15 * 100) / 100;
|
|
1889
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1890
|
+
return {
|
|
1891
|
+
id: `ord_mock_${Date.now()}`,
|
|
1892
|
+
sessionId: input.sessionId ?? "ses_mock_001",
|
|
1893
|
+
status: "draft",
|
|
1894
|
+
tickets,
|
|
1895
|
+
items: [],
|
|
1896
|
+
subtotal,
|
|
1897
|
+
tax,
|
|
1898
|
+
discount: 0,
|
|
1899
|
+
total: Math.round((subtotal + tax) * 100) / 100,
|
|
1900
|
+
currency: "NZD",
|
|
1901
|
+
...input.loyaltyMemberId ? { loyaltyMemberId: input.loyaltyMemberId } : {},
|
|
1902
|
+
createdAt: now,
|
|
1903
|
+
updatedAt: now
|
|
1904
|
+
};
|
|
1877
1905
|
}
|
|
1878
1906
|
async put(path, options) {
|
|
1879
1907
|
const data = this.lookup(path);
|
package/dist/index.mjs
CHANGED
|
@@ -1771,11 +1771,14 @@ var DEFAULT_MOCK_RESPONSES = {
|
|
|
1771
1771
|
"/ocapi/v1/orders": {
|
|
1772
1772
|
id: "ord_mock_001",
|
|
1773
1773
|
status: "draft",
|
|
1774
|
-
siteId: "site_roxy_wellington",
|
|
1775
1774
|
sessionId: "ses_roxy_holdovers_20260427_1915",
|
|
1776
1775
|
tickets: [],
|
|
1777
1776
|
items: [],
|
|
1778
|
-
|
|
1777
|
+
subtotal: 0,
|
|
1778
|
+
tax: 0,
|
|
1779
|
+
discount: 0,
|
|
1780
|
+
total: 0,
|
|
1781
|
+
currency: "NZD",
|
|
1779
1782
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1780
1783
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1781
1784
|
},
|
|
@@ -1824,21 +1827,46 @@ var MockHTTPAdapter = class {
|
|
|
1824
1827
|
return data;
|
|
1825
1828
|
}
|
|
1826
1829
|
async post(path, options) {
|
|
1830
|
+
if (path.split("?")[0].endsWith("/orders")) {
|
|
1831
|
+
return this.buildMockOrder(options?.body);
|
|
1832
|
+
}
|
|
1827
1833
|
const data = this.lookup(path);
|
|
1828
1834
|
if (data !== void 0) return data;
|
|
1829
|
-
|
|
1835
|
+
return {};
|
|
1836
|
+
}
|
|
1837
|
+
/** Build an order response that satisfies `orderSchema` from a create-order request body. */
|
|
1838
|
+
buildMockOrder(body) {
|
|
1839
|
+
const input = body && typeof body === "object" ? body : {};
|
|
1840
|
+
const prices = { adult: 18.5, child: 12.5, senior: 14.5, concession: 14 };
|
|
1841
|
+
const tickets = (input.tickets ?? []).map((t, i) => {
|
|
1842
|
+
const type = t.type ?? "adult";
|
|
1843
|
+
const seatId = t.seatId ?? `seat_${i + 1}`;
|
|
1830
1844
|
return {
|
|
1831
|
-
id: `
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1837
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1838
|
-
...options?.body && typeof options.body === "object" ? options.body : {}
|
|
1845
|
+
id: `tkt_mock_${i + 1}`,
|
|
1846
|
+
type,
|
|
1847
|
+
seatId,
|
|
1848
|
+
seatLabel: seatId.replace(/^seat_/i, "").toUpperCase(),
|
|
1849
|
+
price: prices[type] ?? prices.adult
|
|
1839
1850
|
};
|
|
1840
|
-
}
|
|
1841
|
-
|
|
1851
|
+
});
|
|
1852
|
+
const subtotal = tickets.reduce((sum, t) => sum + t.price, 0);
|
|
1853
|
+
const tax = Math.round(subtotal * 0.15 * 100) / 100;
|
|
1854
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1855
|
+
return {
|
|
1856
|
+
id: `ord_mock_${Date.now()}`,
|
|
1857
|
+
sessionId: input.sessionId ?? "ses_mock_001",
|
|
1858
|
+
status: "draft",
|
|
1859
|
+
tickets,
|
|
1860
|
+
items: [],
|
|
1861
|
+
subtotal,
|
|
1862
|
+
tax,
|
|
1863
|
+
discount: 0,
|
|
1864
|
+
total: Math.round((subtotal + tax) * 100) / 100,
|
|
1865
|
+
currency: "NZD",
|
|
1866
|
+
...input.loyaltyMemberId ? { loyaltyMemberId: input.loyaltyMemberId } : {},
|
|
1867
|
+
createdAt: now,
|
|
1868
|
+
updatedAt: now
|
|
1869
|
+
};
|
|
1842
1870
|
}
|
|
1843
1871
|
async put(path, options) {
|
|
1844
1872
|
const data = this.lookup(path);
|