@pancake-pos/ui-extensions 2026.1.4 → 2026.1.5
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/types.d.ts +13 -9
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type Resource = 'order' | 'product' | 'purchase' | 'export' | 'warehouse_transfer';
|
|
2
|
+
/** Resource có danh sách và action: 5 resource có form chi tiết và khách hàng (`customer.*`). */
|
|
3
|
+
export type ListResource = Resource | 'customer';
|
|
2
4
|
export type OrderRef = {
|
|
3
5
|
/** Mã đơn hiển thị (mã tuỳ chỉnh nếu shop dùng, ngược lại là mã hệ thống). */
|
|
4
6
|
id: string | number;
|
|
@@ -104,7 +106,7 @@ export type WarehouseTransferDraft = {
|
|
|
104
106
|
quantity: number;
|
|
105
107
|
}[];
|
|
106
108
|
};
|
|
107
|
-
/** Khách hàng (`customer
|
|
109
|
+
/** Khách hàng (`customer.*`). `id` dùng với Open API: `/shops/{shop_id}/customers/{id}`. */
|
|
108
110
|
export type CustomerRef = {
|
|
109
111
|
id: string;
|
|
110
112
|
name: string;
|
|
@@ -120,6 +122,7 @@ interface Refs {
|
|
|
120
122
|
purchase: PurchaseRef;
|
|
121
123
|
export: ExportRef;
|
|
122
124
|
warehouse_transfer: WarehouseTransferRef;
|
|
125
|
+
customer: CustomerRef;
|
|
123
126
|
}
|
|
124
127
|
interface Drafts {
|
|
125
128
|
order: OrderDraft;
|
|
@@ -128,7 +131,7 @@ interface Drafts {
|
|
|
128
131
|
export: ExportDraft;
|
|
129
132
|
warehouse_transfer: WarehouseTransferDraft;
|
|
130
133
|
}
|
|
131
|
-
export type RefOf<R extends
|
|
134
|
+
export type RefOf<R extends ListResource> = Refs[R];
|
|
132
135
|
export type DraftOf<R extends Resource> = Drafts[R];
|
|
133
136
|
/** Form chi tiết: `*.details.action`, `*.details.block`, `*.before_submit`. */
|
|
134
137
|
export type DetailsData<R extends Resource = Resource> = {
|
|
@@ -140,12 +143,12 @@ export type DetailsData<R extends Resource = Resource> = {
|
|
|
140
143
|
draft: DraftOf<R>;
|
|
141
144
|
};
|
|
142
145
|
/** Một dòng của danh sách: `*.index.action`. */
|
|
143
|
-
export type IndexData<R extends
|
|
146
|
+
export type IndexData<R extends ListResource = ListResource> = {
|
|
144
147
|
resource: R;
|
|
145
148
|
record: RefOf<R>;
|
|
146
149
|
};
|
|
147
150
|
/** Thanh thao tác hàng loạt: `*.index.selection-action` (tối đa 500 bản ghi). */
|
|
148
|
-
export type SelectionData<R extends
|
|
151
|
+
export type SelectionData<R extends ListResource = ListResource> = {
|
|
149
152
|
resource: R;
|
|
150
153
|
records: RefOf<R>[];
|
|
151
154
|
};
|
|
@@ -171,7 +174,7 @@ export type BeforeSubmitResult = {
|
|
|
171
174
|
ok: false;
|
|
172
175
|
message: string;
|
|
173
176
|
};
|
|
174
|
-
/**
|
|
177
|
+
/** Hồ sơ khách hàng: `customer.details.block`, `customer.details.action` (cùng dạng `IndexData<'customer'>`). */
|
|
175
178
|
export type CustomerData = {
|
|
176
179
|
resource: 'customer';
|
|
177
180
|
record: CustomerRef;
|
|
@@ -189,7 +192,7 @@ export type PrintResult = {
|
|
|
189
192
|
title?: string;
|
|
190
193
|
};
|
|
191
194
|
/** Bản ghi đang hiển thị trên trang danh sách: `<resource>.index.column` (tối đa 500). */
|
|
192
|
-
export type ColumnData<R extends
|
|
195
|
+
export type ColumnData<R extends ListResource = ListResource> = {
|
|
193
196
|
resource: R;
|
|
194
197
|
records: RefOf<R>[];
|
|
195
198
|
};
|
|
@@ -210,10 +213,11 @@ export type PageData = {
|
|
|
210
213
|
query: Record<string, string>;
|
|
211
214
|
};
|
|
212
215
|
export type DetailsTarget<R extends Resource = Resource> = `${R}.details.action` | `${R}.details.block`;
|
|
213
|
-
export type Target = 'app.page' | DetailsTarget | `${
|
|
214
|
-
type ResourceOf<T extends string> = T extends `${infer R extends
|
|
216
|
+
export type Target = 'app.page' | DetailsTarget | `${ListResource}.index.action` | `${ListResource}.index.selection-action` | `${Resource}.before_submit` | `${Resource}.after_save` | `${ListResource}.index.column` | `${PrintResource}.print-action` | 'customer.details.block' | 'customer.details.action';
|
|
217
|
+
type ResourceOf<T extends string> = T extends `${infer R extends ListResource}.${string}` ? R : never;
|
|
218
|
+
type FormResourceOf<T extends string> = Extract<ResourceOf<T>, Resource>;
|
|
215
219
|
/** `pos.data` và tham số của module theo target. */
|
|
216
|
-
export type DataOf<T extends Target> = T extends 'app.page' ? PageData : T extends 'customer.details.block' ? CustomerData : T extends `${infer R extends PrintResource}.print-action` ? PrintData<R> : T extends `${string}.index.column` ? ColumnData<ResourceOf<T>> : T extends `${string}.index.selection-action` ? SelectionData<ResourceOf<T>> : T extends `${string}.index.action` ? IndexData<ResourceOf<T>> : T extends `${string}.after_save` ? AfterSaveInput<
|
|
220
|
+
export type DataOf<T extends Target> = T extends 'app.page' ? PageData : T extends 'customer.details.block' | 'customer.details.action' ? CustomerData : T extends `${infer R extends PrintResource}.print-action` ? PrintData<R> : T extends `${string}.index.column` ? ColumnData<ResourceOf<T>> : T extends `${string}.index.selection-action` ? SelectionData<ResourceOf<T>> : T extends `${string}.index.action` ? IndexData<ResourceOf<T>> : T extends `${string}.after_save` ? AfterSaveInput<FormResourceOf<T>> : DetailsData<FormResourceOf<T>>;
|
|
217
221
|
/** Giá trị module trả về theo target (action có giao diện và block tự render, không trả gì). */
|
|
218
222
|
export type ResultOf<T extends Target> = T extends `${string}.print-action` ? PrintResult : T extends `${string}.index.column` ? ColumnResult : T extends `${string}.before_submit` ? BeforeSubmitResult : T extends `${string}.after_save` | `${string}.details.block` | 'app.page' ? void : HeadlessActionResult;
|
|
219
223
|
export type ToastOptions = {
|
package/package.json
CHANGED