@juo/blocks 1.8.2 → 1.9.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/dist/core.js +31 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/orders/adapter.d.ts +7 -0
- package/dist/services/orders/adapter.d.ts.map +1 -0
- package/dist/services/orders/index.d.ts +4 -0
- package/dist/services/orders/index.d.ts.map +1 -0
- package/dist/services/orders/ordersService.d.ts +6 -0
- package/dist/services/orders/ordersService.d.ts.map +1 -0
- package/dist/services/orders/ordersService.test.d.ts +2 -0
- package/dist/services/orders/ordersService.test.d.ts.map +1 -0
- package/dist/services/orders/types.d.ts +52 -0
- package/dist/services/orders/types.d.ts.map +1 -0
- package/dist/vue/context.d.ts.map +1 -1
- package/dist/vue/context.test.d.ts +2 -0
- package/dist/vue/context.test.d.ts.map +1 -0
- package/dist/vue.js +17 -16
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -513,6 +513,34 @@ function createLoginService(init) {
|
|
|
513
513
|
return service;
|
|
514
514
|
}
|
|
515
515
|
const LoginServiceContext = createContext("services/login");
|
|
516
|
+
function createMockOrdersAdapter() {
|
|
517
|
+
return {
|
|
518
|
+
async getOrders() {
|
|
519
|
+
return {
|
|
520
|
+
items: [],
|
|
521
|
+
pageInfo: {
|
|
522
|
+
hasNextPage: false,
|
|
523
|
+
hasPrevPage: false,
|
|
524
|
+
startCursor: null,
|
|
525
|
+
endCursor: null
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function createOrdersService(adapter) {
|
|
532
|
+
return {
|
|
533
|
+
async getOrders(params) {
|
|
534
|
+
try {
|
|
535
|
+
const data = await adapter.getOrders(params);
|
|
536
|
+
return { _tag: "Success", data };
|
|
537
|
+
} catch (error) {
|
|
538
|
+
return { _tag: "Failure", error };
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
const OrdersServiceContext = createContext("services/orders");
|
|
516
544
|
function createMockProductAdapter() {
|
|
517
545
|
const products = [
|
|
518
546
|
{
|
|
@@ -1378,6 +1406,7 @@ export {
|
|
|
1378
1406
|
D as DEFAULT_GLOBAL_STYLES,
|
|
1379
1407
|
DISCOUNT_REJECTION_REASONS,
|
|
1380
1408
|
LoginServiceContext,
|
|
1409
|
+
OrdersServiceContext,
|
|
1381
1410
|
ProductServiceContext,
|
|
1382
1411
|
RouterServiceContext,
|
|
1383
1412
|
S as SelectedBlockContext,
|
|
@@ -1396,10 +1425,12 @@ export {
|
|
|
1396
1425
|
i as createCeRenderer,
|
|
1397
1426
|
createContext,
|
|
1398
1427
|
createCustomerService,
|
|
1428
|
+
createMockOrdersAdapter,
|
|
1399
1429
|
createMockProductAdapter,
|
|
1400
1430
|
createMockRouterService,
|
|
1401
1431
|
createMockSubscriptionAdapter,
|
|
1402
1432
|
createMockWorkflowApiAdapter,
|
|
1433
|
+
createOrdersService,
|
|
1403
1434
|
createProductService,
|
|
1404
1435
|
createRouterService,
|
|
1405
1436
|
j as createSelectedBlock,
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OrdersAdapter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an empty `OrdersAdapter` shape. Hosts override the methods to seed real fixtures.
|
|
4
|
+
* Used as a starting point by storybook helpers (`createMockOrdersService`) and theme preview.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createMockOrdersAdapter(): OrdersAdapter;
|
|
7
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/orders/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CAcvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/orders/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,KAAK,EACL,SAAS,EACT,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordersService.d.ts","sourceRoot":"","sources":["../../../src/services/orders/ordersService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE5D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAWzE;AAED,eAAO,MAAM,oBAAoB;;CACgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordersService.test.d.ts","sourceRoot":"","sources":["../../../src/services/orders/ordersService.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Image, PaginatedList, Result } from '../../utils';
|
|
2
|
+
export interface OrderLine {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
quantity: number;
|
|
6
|
+
variantImage: Image | null;
|
|
7
|
+
}
|
|
8
|
+
export interface Order {
|
|
9
|
+
/** Numeric Shopify order id (the trailing segment of the order GID). The block prepends `#` for display. */
|
|
10
|
+
id: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
placedAt: string | null;
|
|
13
|
+
currencyCode: string;
|
|
14
|
+
totalPrice: number | null;
|
|
15
|
+
/** Raw Shopify financial-status token (e.g. `PAID`, `PARTIALLY_REFUNDED`); the block humanizes it for display. `null` = unknown. */
|
|
16
|
+
financialStatus: string | null;
|
|
17
|
+
/** Raw Shopify fulfillment-status token (e.g. `FULFILLED`, `PARTIALLY_FULFILLED`); the block humanizes it for display. `null` = unknown. */
|
|
18
|
+
fulfillmentStatus: string | null;
|
|
19
|
+
lines: OrderLine[];
|
|
20
|
+
}
|
|
21
|
+
export interface GetOrdersParams {
|
|
22
|
+
limit?: number;
|
|
23
|
+
after?: string;
|
|
24
|
+
before?: string;
|
|
25
|
+
/**
|
|
26
|
+
* DEPRECATED: previously used for free-text / per-subscriptionId server-side
|
|
27
|
+
* search. The backend proxy implementation ignores this parameter; accepted
|
|
28
|
+
* for SDK backward compatibility only. Use `includeOneTime` to control
|
|
29
|
+
* which order types are returned.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated
|
|
32
|
+
*/
|
|
33
|
+
query?: string;
|
|
34
|
+
/**
|
|
35
|
+
* When `false` (default), only subscription-driven orders are returned.
|
|
36
|
+
* When `true`, one-time orders are included alongside subscription orders.
|
|
37
|
+
*/
|
|
38
|
+
includeOneTime?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Sort order. When set to `"placedAt"`, orders are sorted by placement
|
|
41
|
+
* date (newest first). When omitted, the endpoint's default sort is used.
|
|
42
|
+
*/
|
|
43
|
+
sort?: "placedAt";
|
|
44
|
+
}
|
|
45
|
+
/** Adapter consumed by `createOrdersService`. Hosts (customer portal, theme, storybook) implement this. */
|
|
46
|
+
export interface OrdersAdapter {
|
|
47
|
+
getOrders(params?: GetOrdersParams): Promise<PaginatedList<Order>>;
|
|
48
|
+
}
|
|
49
|
+
export interface OrdersService {
|
|
50
|
+
getOrders(params?: GetOrdersParams): Promise<Result<PaginatedList<Order>>>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/orders/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,KAAK,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,KAAK;IACpB,4GAA4G;IAC5G,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oIAAoI;IACpI,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,4IAA4I;IAC5I,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,2GAA2G;AAC3G,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CACP,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/vue/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAgB,GAAG,EAAE,MAAM,KAAK,CAAC;AAC7C,OAAO,EACL,WAAW,EAGX,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,eAAO,MAAM,eAAe,wHAyB1B,CAAC;AAEH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAE7E;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/vue/context.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAgB,GAAG,EAAE,MAAM,KAAK,CAAC;AAC7C,OAAO,EACL,WAAW,EAGX,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,eAAO,MAAM,eAAe,wHAyB1B,CAAC;AAEH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAE7E;AA+BD,wBAAgB,UAAU,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAI/C;AAED,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAIjD;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,CAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACzB,IAAI,CAeR;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,cAAc,EACjD,OAAO,EAAE,CAAC,GACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOtB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACxD,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,IAAI,CAON;AAED,KAAK,IAAI,CAAC,CAAC,IACT,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GACrB,GAAG,CAAC,CAAC,CAAC,GACN,CAAC,SAAS,QAAQ,GAChB,CAAC,GACD,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GACxB;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3B,GAAG;IAAE,CAAC,EAAE,CAAC,CAAA;CAAE,GACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../src/vue/context.test.ts"],"names":[],"mappings":""}
|
package/dist/vue.js
CHANGED
|
@@ -67,27 +67,28 @@ const ContextProvider = defineComponent((_, { slots }) => {
|
|
|
67
67
|
function useProvideContextProvider(root) {
|
|
68
68
|
provide(key, root);
|
|
69
69
|
}
|
|
70
|
+
function findBlockAttr(el, attr) {
|
|
71
|
+
var _a;
|
|
72
|
+
if (!el) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const direct = el.closest(`[${attr}]`);
|
|
76
|
+
if (direct) {
|
|
77
|
+
return direct.getAttribute(attr);
|
|
78
|
+
}
|
|
79
|
+
const rootNode = el.getRootNode();
|
|
80
|
+
if (rootNode instanceof ShadowRoot && rootNode.host instanceof HTMLElement) {
|
|
81
|
+
return ((_a = rootNode.host.closest(`[${attr}]`)) == null ? void 0 : _a.getAttribute(attr)) ?? null;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
70
85
|
function useBlockId() {
|
|
71
86
|
const root = inject(key);
|
|
72
|
-
return computed(() =>
|
|
73
|
-
var _a;
|
|
74
|
-
if (!((_a = root == null ? void 0 : root.value) == null ? void 0 : _a.parentElement)) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
const parent = root.value.parentElement;
|
|
78
|
-
return parent.getAttribute("data-block-id");
|
|
79
|
-
});
|
|
87
|
+
return computed(() => findBlockAttr((root == null ? void 0 : root.value) ?? null, "data-block-id"));
|
|
80
88
|
}
|
|
81
89
|
function useBlockType() {
|
|
82
90
|
const root = inject(key);
|
|
83
|
-
return computed(() =>
|
|
84
|
-
var _a;
|
|
85
|
-
if (!((_a = root == null ? void 0 : root.value) == null ? void 0 : _a.parentElement)) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
const parent = root.value.parentElement;
|
|
89
|
-
return parent.getAttribute("data-block-type");
|
|
90
|
-
});
|
|
91
|
+
return computed(() => findBlockAttr((root == null ? void 0 : root.value) ?? null, "data-block-type"));
|
|
91
92
|
}
|
|
92
93
|
function useRegisterTranslationKeys() {
|
|
93
94
|
const blockId = useBlockId();
|