@revenexx/cover 0.2.3 → 0.2.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revenexx/cover",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Cover — revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./nuxt.config.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@formkit/vue": "^1.6.0",
|
|
39
39
|
"@iconify-json/lucide": "^1.2.111",
|
|
40
40
|
"@internationalized/date": "^3.12.0",
|
|
41
|
-
"@revenexx/sdk": "^0.0.
|
|
41
|
+
"@revenexx/sdk": "^0.0.7",
|
|
42
42
|
"@revenexx/storage-model-viewer": "^0.3.0",
|
|
43
43
|
"@vueuse/core": "^14.3.0",
|
|
44
44
|
"typesense": "^3.0.5"
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { H3Event } from "h3";
|
|
2
|
+
import type { Models } from "@revenexx/sdk";
|
|
2
3
|
|
|
3
4
|
import type { OrderList, OrderListPosition } from "../../app/interfaces/account/order-lists";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Live order lists through the `orderlists` gateway app
|
|
7
|
-
* (revenexx-apps/orderlists)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* (revenexx-apps/orderlists), via the typed @revenexx/sdk `orderlists`
|
|
9
|
+
* service. Request params are camelCase (the SDK maps to the gateway's
|
|
10
|
+
* snake_case); responses come back snake_case.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* app
|
|
12
|
+
* Only the visibility-filtered LIST still uses the `sdk.call()` escape
|
|
13
|
+
* hatch: `orderlistsList()` declares no query parameters in the contract
|
|
14
|
+
* yet, so it cannot filter by owner/organization. Everything else is typed.
|
|
15
|
+
*
|
|
16
|
+
* Identity: the app stores `owner_id`/`organization_id` and `GET /orderlists`
|
|
17
|
+
* returns the owner's own lists ∪ the organization's shared lists. We supply
|
|
18
|
+
* both from the authenticated contact (auth/me). The cover OrderList keeps
|
|
19
|
+
* `public` UI-side; it maps to the app's `shared`.
|
|
16
20
|
*/
|
|
17
21
|
|
|
18
22
|
interface AppItem {
|
|
@@ -71,21 +75,31 @@ function toCoverPosition(item: AppItem): OrderListPosition {
|
|
|
71
75
|
};
|
|
72
76
|
}
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
/**
|
|
79
|
+
* cover position → the gateway's item payload. The typed methods declare
|
|
80
|
+
* `items: Models.OrderListItemInput[]` (camelCase), but the SDK passes the
|
|
81
|
+
* `items` array through RAW (no camelCase→snake_case conversion of nested
|
|
82
|
+
* objects — unlike top-level params). The orderlists app reads snake_case,
|
|
83
|
+
* so we build snake_case keys and cast to the typed shape; sending camelCase
|
|
84
|
+
* silently drops the multi-word fields (tax_rate, cost_center_id, …).
|
|
85
|
+
* TODO(sdk-generator): deep-convert nested object params so this cast can go.
|
|
86
|
+
*/
|
|
87
|
+
function toItemInput(position: OrderListPosition): Models.OrderListItemInput {
|
|
88
|
+
const item: Record<string, unknown> = {
|
|
77
89
|
name: position.name,
|
|
78
90
|
quantity: Number(position.quantity) || 1,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
...(position.sku ? { sku: position.sku } : {}),
|
|
92
|
+
...(position.image ? { image: position.image } : {}),
|
|
93
|
+
...(position.unit ? { unit: position.unit } : {}),
|
|
94
|
+
...(position.price != null ? { price: position.price } : {}),
|
|
95
|
+
...(position.taxRate != null ? { tax_rate: position.taxRate } : {}),
|
|
96
|
+
...(position.costCenterId ? { cost_center_id: position.costCenterId } : {}),
|
|
97
|
+
...(position.positionTexts ? { position_texts: position.positionTexts } : {}),
|
|
98
|
+
...(position.customSku ? { custom_sku: position.customSku } : {}),
|
|
99
|
+
...(position.categorySlug ? { category_slug: position.categorySlug } : {}),
|
|
100
|
+
...(position.subcategorySlug ? { subcategory_slug: position.subcategorySlug } : {}),
|
|
88
101
|
};
|
|
102
|
+
return item as Models.OrderListItemInput;
|
|
89
103
|
}
|
|
90
104
|
|
|
91
105
|
function toCoverList(row: AppList): OrderList {
|
|
@@ -101,21 +115,23 @@ function toCoverList(row: AppList): OrderList {
|
|
|
101
115
|
};
|
|
102
116
|
}
|
|
103
117
|
|
|
104
|
-
/** Own lists ∪ org-
|
|
118
|
+
/** Own lists ∪ org-shared, each with its positions (bounded fan-out). */
|
|
105
119
|
export async function listOrderLists(event: H3Event): Promise<OrderList[]> {
|
|
106
120
|
const me = await actor(event);
|
|
107
121
|
const sdk = useRevenexxSdk();
|
|
122
|
+
// Escape hatch: orderlistsList() declares no query params, so it cannot
|
|
123
|
+
// filter by owner/organization. The fan-out to full lists is typed.
|
|
108
124
|
const { items } = await sdk.call<{ items: AppList[] }>("GET", "/v1/orderlists", {
|
|
109
125
|
query: { owner_id: me.contactId, ...(me.organizationId ? { organization_id: me.organizationId } : {}) },
|
|
110
126
|
});
|
|
111
|
-
const full = await Promise.all(items.map(async row => sdk.
|
|
112
|
-
return full.map(toCoverList);
|
|
127
|
+
const full = await Promise.all(items.map(async row => sdk.orderlists.orderlistsGet({ id: row.id })));
|
|
128
|
+
return full.map(row => toCoverList(row as unknown as AppList));
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
export async function getOrderList(event: H3Event, id: string): Promise<OrderList> {
|
|
116
132
|
await actor(event);
|
|
117
|
-
const row = await useRevenexxSdk().
|
|
118
|
-
return toCoverList(row);
|
|
133
|
+
const row = await useRevenexxSdk().orderlists.orderlistsGet({ id });
|
|
134
|
+
return toCoverList(row as unknown as AppList);
|
|
119
135
|
}
|
|
120
136
|
|
|
121
137
|
export async function createOrderList(
|
|
@@ -123,18 +139,16 @@ export async function createOrderList(
|
|
|
123
139
|
body: { name: string; kind?: string; public?: boolean; positions?: OrderListPosition[] },
|
|
124
140
|
): Promise<OrderList> {
|
|
125
141
|
const me = await actor(event);
|
|
126
|
-
const row = await useRevenexxSdk().
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
items: Array.isArray(body.positions) ? body.positions.map(toAppItem) : [],
|
|
135
|
-
},
|
|
142
|
+
const row = await useRevenexxSdk().orderlists.orderlistsCreate({
|
|
143
|
+
name: body.name,
|
|
144
|
+
ownerId: me.contactId,
|
|
145
|
+
ownerName: me.name,
|
|
146
|
+
kind: body.kind === "label" ? "label" : "shopping",
|
|
147
|
+
shared: Boolean(body.public),
|
|
148
|
+
...(me.organizationId ? { organizationId: me.organizationId } : {}),
|
|
149
|
+
...(Array.isArray(body.positions) ? { items: body.positions.map(toItemInput) } : {}),
|
|
136
150
|
});
|
|
137
|
-
return toCoverList(row);
|
|
151
|
+
return toCoverList(row as unknown as AppList);
|
|
138
152
|
}
|
|
139
153
|
|
|
140
154
|
export async function updateOrderList(
|
|
@@ -145,24 +159,25 @@ export async function updateOrderList(
|
|
|
145
159
|
await actor(event);
|
|
146
160
|
const sdk = useRevenexxSdk();
|
|
147
161
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
if (typeof body.name === "string" && body.name.trim() || typeof body.public === "boolean") {
|
|
163
|
+
await sdk.orderlists.orderlistsUpdate({
|
|
164
|
+
id,
|
|
165
|
+
...(typeof body.name === "string" && body.name.trim() ? { name: body.name.trim() } : {}),
|
|
166
|
+
...(typeof body.public === "boolean" ? { shared: body.public } : {}),
|
|
167
|
+
});
|
|
153
168
|
}
|
|
154
169
|
|
|
155
170
|
if (Array.isArray(body.positions)) {
|
|
156
|
-
await sdk.
|
|
171
|
+
await sdk.orderlists.orderlistsItemsReplace({ listId: id, items: body.positions.map(toItemInput) });
|
|
157
172
|
}
|
|
158
173
|
for (const position of body.appendPositions ?? []) {
|
|
159
|
-
await sdk.
|
|
174
|
+
await sdk.orderlists.orderlistsItemsCreate({ listId: id, ...toItemInput(position) });
|
|
160
175
|
}
|
|
161
176
|
|
|
162
|
-
return toCoverList(await sdk.
|
|
177
|
+
return toCoverList(await sdk.orderlists.orderlistsGet({ id }) as unknown as AppList);
|
|
163
178
|
}
|
|
164
179
|
|
|
165
180
|
export async function deleteOrderList(event: H3Event, id: string): Promise<void> {
|
|
166
181
|
await actor(event);
|
|
167
|
-
await useRevenexxSdk().
|
|
182
|
+
await useRevenexxSdk().orderlists.orderlistsDelete({ id });
|
|
168
183
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Customers,
|
|
5
5
|
Inventories,
|
|
6
6
|
Markets,
|
|
7
|
+
Orderlists,
|
|
7
8
|
Orders,
|
|
8
9
|
Payments,
|
|
9
10
|
Prices,
|
|
@@ -39,6 +40,7 @@ export interface RevenexxSdk {
|
|
|
39
40
|
readonly customers: Customers;
|
|
40
41
|
readonly inventories: Inventories;
|
|
41
42
|
readonly markets: Markets;
|
|
43
|
+
readonly orderlists: Orderlists;
|
|
42
44
|
readonly orders: Orders;
|
|
43
45
|
readonly payments: Payments;
|
|
44
46
|
readonly prices: Prices;
|
|
@@ -202,6 +204,7 @@ export function useRevenexxSdk(): RevenexxSdk {
|
|
|
202
204
|
customers: new Customers(client),
|
|
203
205
|
inventories: new Inventories(client),
|
|
204
206
|
markets: new Markets(client),
|
|
207
|
+
orderlists: new Orderlists(client),
|
|
205
208
|
orders: new Orders(client),
|
|
206
209
|
payments: new Payments(client),
|
|
207
210
|
prices: new Prices(client),
|