@flowselections/floriday-verkoop-module 1.0.100 → 1.0.103
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-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +9 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +26 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts +6 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts.map +1 -0
- package/dist-lib/components/karindeling/AfmetingenTab.js +128 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts +2 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts.map +1 -0
- package/dist-lib/components/karindeling/KarindelingPage.js +102 -0
- package/dist-lib/components/ui/dropdown-menu.d.ts +9 -0
- package/dist-lib/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist-lib/components/ui/dropdown-menu.js +14 -0
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts +1 -1
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts.map +1 -1
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts +4 -0
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.js +95 -0
- package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts +1 -1
- package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CartLayersDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/CartLayersDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts +5 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts.map +1 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.js +33 -0
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +44 -4
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +11 -5
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts +1 -1
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts +2 -2
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts.map +1 -1
- package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/PlanCoverageBadge.d.ts +1 -1
- package/dist-lib/components/verkoop/PlanCoverageBadge.d.ts.map +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +6 -6
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +1 -2
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.d.ts +1 -1
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.js +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +956 -15
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +17 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +95 -8
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts +4 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts.map +1 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.js +23 -0
- package/dist-lib/lib/cron/push-order-statuses.d.ts +4 -0
- package/dist-lib/lib/cron/push-order-statuses.d.ts.map +1 -0
- package/dist-lib/lib/cron/push-order-statuses.js +23 -0
- package/dist-lib/lib/customer-stickers.check.d.ts +2 -0
- package/dist-lib/lib/customer-stickers.check.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.check.js +19 -0
- package/dist-lib/lib/customer-stickers.d.ts +14 -0
- package/dist-lib/lib/customer-stickers.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.js +19 -0
- package/dist-lib/lib/floriday/floriday.server.d.ts +14 -0
- package/dist-lib/lib/floriday/floriday.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday/floriday.server.js +92 -0
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts +4736 -0
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday/sales-orders.functions.js +193 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +77581 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.js +65 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts +21 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.js +352 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +54 -1
- package/dist-lib/lib/floriday-status-sync.server.d.ts +14 -0
- package/dist-lib/lib/floriday-status-sync.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-status-sync.server.js +130 -0
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.d.ts.map +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-item-packing.functions.d.ts +2 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-item-packing.functions.js +2 -1
- package/dist-lib/lib/tradeitems.functions.d.ts +12 -1117
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useBufferEvents.d.ts +2 -2
- package/dist-lib/lib/useBufferEvents.d.ts.map +1 -1
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts +2 -2
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/package.json +9 -4
- package/schema/verkoop.sql +1939 -0
- package/dist-lib/lib/order-cart-count.server.d.ts +0 -8
- package/dist-lib/lib/order-cart-count.server.d.ts.map +0 -1
- package/dist-lib/lib/order-cart-count.server.js +0 -69
|
@@ -140,6 +140,7 @@ export declare const createManualOrder: import("@tanstack/start-client-core").Op
|
|
|
140
140
|
crates_per_layer?: number | undefined;
|
|
141
141
|
layers_per_cart?: number | undefined;
|
|
142
142
|
article_code?: string | null | undefined;
|
|
143
|
+
needs_sticker?: boolean | undefined;
|
|
143
144
|
}[];
|
|
144
145
|
carrierId?: string | null | undefined;
|
|
145
146
|
deliveryDate?: string | null | undefined;
|
|
@@ -214,6 +215,7 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
|
|
|
214
215
|
quantity: number;
|
|
215
216
|
unit: string | null;
|
|
216
217
|
plantsPerCrate: number;
|
|
218
|
+
needsSticker: boolean;
|
|
217
219
|
shippedQuantity: number;
|
|
218
220
|
plannedQuantity: number;
|
|
219
221
|
minQuantity: number;
|
|
@@ -241,6 +243,11 @@ export declare const updateLocalOrder: import("@tanstack/start-client-core").Opt
|
|
|
241
243
|
plantsPerCrate?: number | null | undefined;
|
|
242
244
|
cratesPerLayer?: number | null | undefined;
|
|
243
245
|
layersPerCart?: number | null | undefined;
|
|
246
|
+
needsSticker?: boolean | undefined;
|
|
247
|
+
}[] | undefined;
|
|
248
|
+
stickers?: {
|
|
249
|
+
itemId: string;
|
|
250
|
+
needsSticker: boolean;
|
|
244
251
|
}[] | undefined;
|
|
245
252
|
}, Promise<{
|
|
246
253
|
ok: true;
|
|
@@ -260,4 +267,14 @@ export declare const getEffectivePrices: import("@tanstack/start-client-core").O
|
|
|
260
267
|
price: number;
|
|
261
268
|
source: string | null;
|
|
262
269
|
} | null>>>;
|
|
270
|
+
export declare const listCustomerStickerProducts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
271
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
272
|
+
userId: string;
|
|
273
|
+
claims: import("@supabase/auth-js").User;
|
|
274
|
+
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
275
|
+
customerId: string;
|
|
276
|
+
productIds: string[];
|
|
277
|
+
}, Promise<{
|
|
278
|
+
productIds: string[];
|
|
279
|
+
}>>;
|
|
263
280
|
//# sourceMappingURL=create-order.functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM;0BACN,MAAM;yBACP,MAAM;wBACP,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA6RpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;YAoBI,MAAM;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;GAWnC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;;GA8C5G,CAAC;AAGL,eAAO,MAAM,kBAAkB;;;;;;GAU3B,CAAC;
|
|
1
|
+
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM;0BACN,MAAM;yBACP,MAAM;wBACP,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA6RpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;YAoBI,MAAM;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;GAWnC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;;GA8C5G,CAAC;AAGL,eAAO,MAAM,kBAAkB;;;;;;GAU3B,CAAC;AAiDL,eAAO,MAAM,iBAAiB;;;;8CAEJ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6PY,MAAM;GAE/C,CAAC;AAKL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;GAY7B,CAAC;AAQL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;GAoG7B,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;8CAER,OAAO;;;;GAyB7B,CAAC;AAgDL,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;aA0JG,MAAM;iBACQ,MAAM,GAAG,IAAI;kBACX,MAAM;;YAEnB,MAAM,GAAG,IAAI;;;;YAkB7B,MAAM;mBACS,MAAM,GAAG,IAAI;qBACT,MAAM;;cAErB,MAAM,GAAG,IAAI;;;;;;;GASpC,CAAC;AAIL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GAgR7B,CAAC;AAKL,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;WAUM,MAAM;YAAU,MAAM,GAAG,IAAI;WAahE,CAAC;AAOL,eAAO,MAAM,2BAA2B;;;;8CAEd,OAAO;;;;gBAIgC,MAAM,EAAE;GAwBrE,CAAC"}
|
|
@@ -643,6 +643,8 @@ const LineInput = z.object({
|
|
|
643
643
|
crates_per_layer: z.number().int().positive().optional(),
|
|
644
644
|
layers_per_cart: z.number().int().positive().optional(),
|
|
645
645
|
article_code: z.string().max(100).nullable().optional(),
|
|
646
|
+
// Sticker nodig op deze regel (alleen vastleggen; telt nergens mee).
|
|
647
|
+
needs_sticker: z.boolean().optional(),
|
|
646
648
|
});
|
|
647
649
|
const CreateManualOrderInput = z.object({
|
|
648
650
|
customerId: z.string().uuid(),
|
|
@@ -891,6 +893,7 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
891
893
|
crates_per_layer: l.crates_per_layer ?? null,
|
|
892
894
|
layers_per_cart: l.layers_per_cart ?? null,
|
|
893
895
|
unit_price: l.unit_price ?? undefined,
|
|
896
|
+
needs_sticker: l.needs_sticker === true,
|
|
894
897
|
};
|
|
895
898
|
});
|
|
896
899
|
const { error: itemsErr } = await supabaseAdmin.from("order_items").insert(items);
|
|
@@ -1090,8 +1093,14 @@ const UpdateLocalOrderInput = z.object({
|
|
|
1090
1093
|
plantsPerCrate: z.number().int().positive().nullish(),
|
|
1091
1094
|
cratesPerLayer: z.number().int().positive().nullish(),
|
|
1092
1095
|
layersPerCart: z.number().int().positive().nullish(),
|
|
1096
|
+
needsSticker: z.boolean().optional(),
|
|
1093
1097
|
}))
|
|
1094
1098
|
.optional(),
|
|
1099
|
+
// Stickervinkje per bestaande regel. Alleen gewijzigde waarden worden
|
|
1100
|
+
// opgeslagen; een wijziging van alleen het vinkje start niets anders.
|
|
1101
|
+
stickers: z
|
|
1102
|
+
.array(z.object({ itemId: z.string().uuid(), needsSticker: z.boolean() }))
|
|
1103
|
+
.optional(),
|
|
1095
1104
|
});
|
|
1096
1105
|
export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
1097
1106
|
.middleware([requireSupabaseAuth])
|
|
@@ -1113,7 +1122,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1113
1122
|
}
|
|
1114
1123
|
const { data: items, error: iErr } = await context.supabase
|
|
1115
1124
|
.from("order_items")
|
|
1116
|
-
.select("id, product_id, product_name, quantity, unit, products(plants_per_crate)")
|
|
1125
|
+
.select("id, product_id, product_name, quantity, unit, needs_sticker, products(plants_per_crate)")
|
|
1117
1126
|
.eq("order_id", data.orderId)
|
|
1118
1127
|
.is("quarantined_at", null)
|
|
1119
1128
|
.order("id");
|
|
@@ -1275,6 +1284,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1275
1284
|
quantity: Number(it.quantity ?? 0),
|
|
1276
1285
|
unit: it.unit,
|
|
1277
1286
|
plantsPerCrate: ppc,
|
|
1287
|
+
needsSticker: it.needs_sticker === true,
|
|
1278
1288
|
shippedQuantity: shipped,
|
|
1279
1289
|
plannedQuantity: planned,
|
|
1280
1290
|
minQuantity: shipped + planned,
|
|
@@ -1303,6 +1313,34 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1303
1313
|
}
|
|
1304
1314
|
const removeIds = data.removeItemIds ?? [];
|
|
1305
1315
|
const newItems = data.newItems ?? [];
|
|
1316
|
+
// Huidige regels: alleen echt gewijzigde aantallen en stickervinkjes
|
|
1317
|
+
// verwerken. Een wijziging van alleen het vinkje start geen
|
|
1318
|
+
// voorraadcontrole, herberekening of nieuwe planning.
|
|
1319
|
+
const { data: currentRows, error: cErr } = await supabaseAdmin
|
|
1320
|
+
.from("order_items")
|
|
1321
|
+
.select("id, quantity, needs_sticker")
|
|
1322
|
+
.eq("order_id", data.orderId);
|
|
1323
|
+
if (cErr)
|
|
1324
|
+
throw new Error(cErr.message);
|
|
1325
|
+
const currentById = new Map((currentRows ?? []).map((r) => [
|
|
1326
|
+
r.id,
|
|
1327
|
+
{ quantity: Number(r.quantity ?? 0), needsSticker: r.needs_sticker === true },
|
|
1328
|
+
]));
|
|
1329
|
+
const changedItems = (data.items ?? []).filter((i) => {
|
|
1330
|
+
const cur = currentById.get(i.itemId);
|
|
1331
|
+
return !cur || cur.quantity !== i.quantity;
|
|
1332
|
+
});
|
|
1333
|
+
data.items = changedItems;
|
|
1334
|
+
const stickerChanges = (data.stickers ?? []).filter((st) => {
|
|
1335
|
+
const cur = currentById.get(st.itemId);
|
|
1336
|
+
return !!cur && cur.needsSticker !== st.needsSticker && !removeIds.includes(st.itemId);
|
|
1337
|
+
});
|
|
1338
|
+
const dateChanged = !!data.deliveryDate &&
|
|
1339
|
+
!order.is_reservation &&
|
|
1340
|
+
String(data.deliveryDate).slice(0, 10) !== String(order.delivery_date ?? "").slice(0, 10);
|
|
1341
|
+
if (!dateChanged)
|
|
1342
|
+
data.deliveryDate = undefined;
|
|
1343
|
+
const realChange = changedItems.length > 0 || removeIds.length > 0 || newItems.length > 0 || dateChanged;
|
|
1306
1344
|
// Producten wijzigen mag alleen zolang er nog niets is geprint in het
|
|
1307
1345
|
// Pickstation (orders.plan_locked_at).
|
|
1308
1346
|
if ((removeIds.length > 0 || newItems.length > 0) && order.plan_locked_at) {
|
|
@@ -1404,6 +1442,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1404
1442
|
crates_per_layer: n.cratesPerLayer ?? null,
|
|
1405
1443
|
layers_per_cart: n.layersPerCart ?? null,
|
|
1406
1444
|
unit_price: n.unitPrice ?? undefined,
|
|
1445
|
+
needs_sticker: n.needsSticker === true,
|
|
1407
1446
|
};
|
|
1408
1447
|
});
|
|
1409
1448
|
const { error: nErr } = await supabaseAdmin.from("order_items").insert(rowsToInsert);
|
|
@@ -1481,14 +1520,25 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1481
1520
|
.update({ total: String(total.toFixed(2)), updated_at: new Date().toISOString() })
|
|
1482
1521
|
.eq("id", data.orderId);
|
|
1483
1522
|
}
|
|
1484
|
-
//
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1523
|
+
// Stickervinkjes: alleen deze kolom, alleen bij een echte wijziging.
|
|
1524
|
+
for (const st of stickerChanges) {
|
|
1525
|
+
const { error: sErr } = await supabaseAdmin.from("order_items")
|
|
1526
|
+
.update({ needs_sticker: st.needsSticker })
|
|
1527
|
+
.eq("id", st.itemId)
|
|
1528
|
+
.eq("order_id", data.orderId);
|
|
1529
|
+
if (sErr)
|
|
1530
|
+
throw new Error(`Sticker bijwerken faalde: ${sErr.message}`);
|
|
1489
1531
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1532
|
+
// Karindeling: de Logistiek Engine plant opnieuw in haar eigen ronde.
|
|
1533
|
+
// Alleen melden bij een echte wijziging (niet bij alleen het stickervinkje).
|
|
1534
|
+
if (realChange) {
|
|
1535
|
+
try {
|
|
1536
|
+
const { notifyEngineOrder } = await import("./logistics-engine.server.js");
|
|
1537
|
+
await notifyEngineOrder(data.orderId, "order.changed");
|
|
1538
|
+
}
|
|
1539
|
+
catch (err) {
|
|
1540
|
+
console.warn("[updateLocalOrder] engine-event faalde:", err);
|
|
1541
|
+
}
|
|
1492
1542
|
}
|
|
1493
1543
|
return { ok: true };
|
|
1494
1544
|
});
|
|
@@ -1519,3 +1569,40 @@ export const getEffectivePrices = createServerFn({ method: "POST" })
|
|
|
1519
1569
|
}
|
|
1520
1570
|
return out;
|
|
1521
1571
|
});
|
|
1572
|
+
// ─── Standaard stickervinkje bij een nieuwe bestelling ──────────────────────
|
|
1573
|
+
// Vinkje vooraf aan als er voor deze klant + dit product een vaste klantsticker
|
|
1574
|
+
// bestaat (customer_product_stickers). Alleen lezen; matcht op id/code, nooit
|
|
1575
|
+
// op naam. Lukt het lezen niet, dan staat het vinkje uit.
|
|
1576
|
+
export const listCustomerStickerProducts = createServerFn({ method: "POST" })
|
|
1577
|
+
.middleware([requireSupabaseAuth])
|
|
1578
|
+
.inputValidator((input) => z.object({ customerId: z.string().uuid(), productIds: z.array(z.string().uuid()).max(200) }).parse(input))
|
|
1579
|
+
.handler(async ({ data, context }) => {
|
|
1580
|
+
if (data.productIds.length === 0)
|
|
1581
|
+
return { productIds: [] };
|
|
1582
|
+
const sb = context.supabase;
|
|
1583
|
+
const { data: cust } = await sb
|
|
1584
|
+
.from("customers")
|
|
1585
|
+
.select("id, twinfield_code, floriday_organization_id")
|
|
1586
|
+
.eq("id", data.customerId)
|
|
1587
|
+
.maybeSingle();
|
|
1588
|
+
if (!cust)
|
|
1589
|
+
return { productIds: [] };
|
|
1590
|
+
const { stickerCustomerKeys, stickerProductIds } = await import("./customer-stickers.js");
|
|
1591
|
+
const customerKeys = stickerCustomerKeys(cust);
|
|
1592
|
+
const { data: prods } = await sb
|
|
1593
|
+
.from("products")
|
|
1594
|
+
.select("id, trade_item_key")
|
|
1595
|
+
.in("id", data.productIds);
|
|
1596
|
+
const productKeyRows = (prods ?? []).map((p) => ({ id: p.id, tradeItemKey: p.trade_item_key ?? null }));
|
|
1597
|
+
const keys = Array.from(new Set(productKeyRows.flatMap((p) => [p.id, p.tradeItemKey].filter(Boolean))));
|
|
1598
|
+
if (keys.length === 0)
|
|
1599
|
+
return { productIds: [] };
|
|
1600
|
+
const { data: rows, error } = await sb
|
|
1601
|
+
.from("customer_product_stickers")
|
|
1602
|
+
.select("customer_key, trade_item_key")
|
|
1603
|
+
.in("customer_key", customerKeys)
|
|
1604
|
+
.in("trade_item_key", keys);
|
|
1605
|
+
if (error)
|
|
1606
|
+
return { productIds: [] };
|
|
1607
|
+
return { productIds: stickerProductIds(productKeyRows, (rows ?? [])) };
|
|
1608
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
export declare function mirrorFloridayOrdersCron(request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
3
|
+
export declare function mirrorFloridayOrdersCronHint(_request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=mirror-floriday-orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mirror-floriday-orders.d.ts","sourceRoot":"","sources":["../../../src/lib/cron/mirror-floriday-orders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAmBnB;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAKnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { mirrorFloridayOrdersFromCron } from "../floriday-mirror.functions.js";
|
|
2
|
+
export async function mirrorFloridayOrdersCron(request, _supabase) {
|
|
3
|
+
const apikey = request.headers.get("apikey") ?? request.headers.get("x-api-key");
|
|
4
|
+
const expected = process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
5
|
+
if (!expected || !apikey || apikey !== expected) {
|
|
6
|
+
return new Response("Unauthorized", { status: 401 });
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(request.url);
|
|
10
|
+
const limit = Number(url.searchParams.get("limit") ?? "200");
|
|
11
|
+
const result = await mirrorFloridayOrdersFromCron(Number.isFinite(limit) && limit > 0 ? Math.min(1000, limit) : 200);
|
|
12
|
+
return Response.json(result);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return Response.json({ ok: false, error: err.message }, { status: 500 });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function mirrorFloridayOrdersCronHint(_request, _supabase) {
|
|
19
|
+
return Response.json({
|
|
20
|
+
ok: true,
|
|
21
|
+
hint: "POST to mirror recent Floriday sales orders into local orders",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
export declare function pushOrderStatusesCron(request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
3
|
+
export declare function pushOrderStatusesCronHint(_request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=push-order-statuses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-order-statuses.d.ts","sourceRoot":"","sources":["../../../src/lib/cron/push-order-statuses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAiBnB;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAKnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export async function pushOrderStatusesCron(request, _supabase) {
|
|
2
|
+
const apikey = request.headers.get("apikey") ?? request.headers.get("x-api-key");
|
|
3
|
+
const expected = process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
4
|
+
if (!expected || !apikey || apikey !== expected) {
|
|
5
|
+
return new Response("Unauthorized", { status: 401 });
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(request.url);
|
|
9
|
+
const limit = Number(url.searchParams.get("limit") ?? "100");
|
|
10
|
+
const { pushOrderStatusesToFloriday } = await import("../floriday-status-sync.server.js");
|
|
11
|
+
const result = await pushOrderStatusesToFloriday(Number.isFinite(limit) && limit > 0 ? Math.min(500, limit) : 100);
|
|
12
|
+
return Response.json(result);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return Response.json({ ok: false, error: err.message }, { status: 500 });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function pushOrderStatusesCronHint(_request, _supabase) {
|
|
19
|
+
return Response.json({
|
|
20
|
+
ok: true,
|
|
21
|
+
hint: "POST to push ERP order status changes to Floriday",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-stickers.check.d.ts","sourceRoot":"","sources":["../../src/lib/customer-stickers.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Draaien met: bun src/lib/customer-stickers.check.ts
|
|
2
|
+
import { stickerCustomerKeys, stickerProductIds } from "./customer-stickers.js";
|
|
3
|
+
let failed = 0;
|
|
4
|
+
const eq = (name, a, b) => {
|
|
5
|
+
const ok = JSON.stringify(a) === JSON.stringify(b);
|
|
6
|
+
if (!ok)
|
|
7
|
+
failed++;
|
|
8
|
+
console.log(`${ok ? "ok " : "FOUT"} ${name}`);
|
|
9
|
+
};
|
|
10
|
+
eq("klantsleutels met Twinfield-code", stickerCustomerKeys({ id: "c1", twinfield_code: "1015" }), ["c1", "tf:1015"]);
|
|
11
|
+
eq("klantsleutels zonder codes", stickerCustomerKeys({ id: "c1", twinfield_code: " " }), ["c1"]);
|
|
12
|
+
eq("product met vaste sticker op id staat aan", stickerProductIds([{ id: "p1", tradeItemKey: null }, { id: "p2", tradeItemKey: null }], [{ trade_item_key: "p1" }]), ["p1"]);
|
|
13
|
+
eq("product met vaste sticker op artikelsleutel staat aan", stickerProductIds([{ id: "p1", tradeItemKey: "t1" }], [{ trade_item_key: "t1" }]), ["p1"]);
|
|
14
|
+
eq("geen vaste sticker: uit", stickerProductIds([{ id: "p1", tradeItemKey: "t1" }], []), []);
|
|
15
|
+
if (failed) {
|
|
16
|
+
console.error(`${failed} controle(s) mislukt`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
console.log("alle controles geslaagd");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Sleutels waaronder een klant in customer_product_stickers kan staan. */
|
|
2
|
+
export declare function stickerCustomerKeys(c: {
|
|
3
|
+
id: string;
|
|
4
|
+
twinfield_code?: string | null;
|
|
5
|
+
floriday_organization_id?: string | null;
|
|
6
|
+
}): string[];
|
|
7
|
+
/** Product-id's waarvoor een vaste klantsticker bestaat (op id of artikelsleutel). */
|
|
8
|
+
export declare function stickerProductIds(products: {
|
|
9
|
+
id: string;
|
|
10
|
+
tradeItemKey: string | null;
|
|
11
|
+
}[], rows: {
|
|
12
|
+
trade_item_key: string | null;
|
|
13
|
+
}[]): string[];
|
|
14
|
+
//# sourceMappingURL=customer-stickers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-stickers.d.ts","sourceRoot":"","sources":["../../src/lib/customer-stickers.ts"],"names":[],"mappings":"AAIA,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,GAAG,MAAM,EAAE,CAOX;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,EACvD,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,GACxC,MAAM,EAAE,CAGV"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Vaste klantstickers (customer_product_stickers) koppelen aan een nieuwe
|
|
2
|
+
// bestelling. Alleen voor de standaardwaarde van het stickervinkje; matcht op
|
|
3
|
+
// id/code, nooit op naam.
|
|
4
|
+
/** Sleutels waaronder een klant in customer_product_stickers kan staan. */
|
|
5
|
+
export function stickerCustomerKeys(c) {
|
|
6
|
+
const keys = [c.id];
|
|
7
|
+
const tf = String(c.twinfield_code ?? "").trim();
|
|
8
|
+
if (tf)
|
|
9
|
+
keys.push(`tf:${tf}`);
|
|
10
|
+
const org = String(c.floriday_organization_id ?? "").trim();
|
|
11
|
+
if (org)
|
|
12
|
+
keys.push(org);
|
|
13
|
+
return keys;
|
|
14
|
+
}
|
|
15
|
+
/** Product-id's waarvoor een vaste klantsticker bestaat (op id of artikelsleutel). */
|
|
16
|
+
export function stickerProductIds(products, rows) {
|
|
17
|
+
const have = new Set(rows.map((r) => String(r.trade_item_key ?? "")).filter(Boolean));
|
|
18
|
+
return products.filter((p) => have.has(p.id) || (!!p.tradeItemKey && have.has(p.tradeItemKey))).map((p) => p.id);
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FlorIdayConn {
|
|
2
|
+
id: string;
|
|
3
|
+
environment: "staging" | "production" | string;
|
|
4
|
+
client_id: string;
|
|
5
|
+
client_secret: string;
|
|
6
|
+
api_key: string;
|
|
7
|
+
access_token: string | null;
|
|
8
|
+
token_expires_at: string | null;
|
|
9
|
+
organization_name: string | null;
|
|
10
|
+
gln_code: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function getActiveConnection(): Promise<FlorIdayConn>;
|
|
13
|
+
export declare function florIdayFetch<T = unknown>(path: string, init?: RequestInit): Promise<T>;
|
|
14
|
+
//# sourceMappingURL=floriday.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday.server.d.ts","sourceRoot":"","sources":["../../../src/lib/floriday/floriday.server.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAiBD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,YAAY,CAAC,CAsBjE;AAqCD,wBAAsB,aAAa,CAAC,CAAC,GAAG,OAAO,EAC7C,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Floriday Suppliers API client (server-only)
|
|
2
|
+
import { supabaseAdmin } from "../../integrations/supabase/client.server.js";
|
|
3
|
+
function endpoints(env) {
|
|
4
|
+
const isProd = env === "production" || env === "prod";
|
|
5
|
+
return {
|
|
6
|
+
auth: isProd
|
|
7
|
+
? "https://accounts.floriday.io/oauth/token"
|
|
8
|
+
: "https://accounts.staging.floriday.io/oauth/token",
|
|
9
|
+
audience: isProd
|
|
10
|
+
? "https://api.floriday.io"
|
|
11
|
+
: "https://api.staging.floriday.io",
|
|
12
|
+
api: isProd
|
|
13
|
+
? "https://api.floriday.io/suppliers-api-2026v1"
|
|
14
|
+
: "https://api.staging.floriday.io/suppliers-api-2026v1",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export async function getActiveConnection() {
|
|
18
|
+
const { data: settings } = await supabaseAdmin
|
|
19
|
+
.from("floriday_settings")
|
|
20
|
+
.select("active_environment")
|
|
21
|
+
.eq("id", 1)
|
|
22
|
+
.maybeSingle();
|
|
23
|
+
const env = settings?.active_environment ?? "staging";
|
|
24
|
+
const { data, error } = await supabaseAdmin
|
|
25
|
+
.from("floriday_connections")
|
|
26
|
+
.select("id,environment,client_id,client_secret,api_key,access_token,token_expires_at,organization_name,gln_code,is_active")
|
|
27
|
+
.eq("environment", env)
|
|
28
|
+
.eq("is_active", true)
|
|
29
|
+
.order("updated_at", { ascending: false })
|
|
30
|
+
.limit(1)
|
|
31
|
+
.maybeSingle();
|
|
32
|
+
if (error)
|
|
33
|
+
throw new Error(`Floriday connectie ophalen mislukt: ${error.message}`);
|
|
34
|
+
if (!data)
|
|
35
|
+
throw new Error(`Geen actieve Floriday connectie voor omgeving "${env}"`);
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
async function fetchToken(conn) {
|
|
39
|
+
const ep = endpoints(conn.environment);
|
|
40
|
+
const body = new URLSearchParams({
|
|
41
|
+
grant_type: "client_credentials",
|
|
42
|
+
client_id: conn.client_id,
|
|
43
|
+
client_secret: conn.client_secret,
|
|
44
|
+
audience: ep.audience,
|
|
45
|
+
});
|
|
46
|
+
const res = await fetch(ep.auth, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
49
|
+
body,
|
|
50
|
+
});
|
|
51
|
+
const text = await res.text();
|
|
52
|
+
if (!res.ok) {
|
|
53
|
+
throw new Error(`Floriday OAuth fout [${res.status}]: ${text.slice(0, 300)}`);
|
|
54
|
+
}
|
|
55
|
+
const json = JSON.parse(text);
|
|
56
|
+
const token = json.access_token;
|
|
57
|
+
const expiresIn = json.expires_in ?? 3600;
|
|
58
|
+
const expiresAt = new Date(Date.now() + (expiresIn - 60) * 1000).toISOString();
|
|
59
|
+
await supabaseAdmin
|
|
60
|
+
.from("floriday_connections")
|
|
61
|
+
.update({ access_token: token, token_expires_at: expiresAt })
|
|
62
|
+
.eq("id", conn.id);
|
|
63
|
+
return { token, expiresAt };
|
|
64
|
+
}
|
|
65
|
+
async function ensureToken(conn) {
|
|
66
|
+
const exp = conn.token_expires_at ? new Date(conn.token_expires_at).getTime() : 0;
|
|
67
|
+
if (conn.access_token && exp > Date.now() + 60000)
|
|
68
|
+
return conn.access_token;
|
|
69
|
+
const { token } = await fetchToken(conn);
|
|
70
|
+
return token;
|
|
71
|
+
}
|
|
72
|
+
export async function florIdayFetch(path, init = {}) {
|
|
73
|
+
const conn = await getActiveConnection();
|
|
74
|
+
const token = await ensureToken(conn);
|
|
75
|
+
const ep = endpoints(conn.environment);
|
|
76
|
+
const url = path.startsWith("http") ? path : `${ep.api}${path}`;
|
|
77
|
+
const res = await fetch(url, {
|
|
78
|
+
...init,
|
|
79
|
+
headers: {
|
|
80
|
+
Accept: "application/json",
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
Authorization: `Bearer ${token}`,
|
|
83
|
+
"x-api-key": conn.api_key,
|
|
84
|
+
...init.headers,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const text = await res.text();
|
|
88
|
+
if (!res.ok) {
|
|
89
|
+
throw new Error(`Floriday API ${res.status} ${path}: ${text.slice(0, 400)}`);
|
|
90
|
+
}
|
|
91
|
+
return (text ? JSON.parse(text) : null);
|
|
92
|
+
}
|