@flowselections/floriday-voorraad 1.0.71 → 1.0.72
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/voorraad/FloridaySentCard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/FloridaySentCard.js +11 -3
- package/dist-lib/integrations/supabase/types.d.ts +105 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/base-supply-reader.server.d.ts +1 -0
- package/dist-lib/lib/base-supply-reader.server.d.ts.map +1 -1
- package/dist-lib/lib/base-supply-reader.server.js +4 -0
- package/dist-lib/lib/stock-sync.functions.d.ts +1 -1
- package/dist-lib/lib/stock-sync.functions.d.ts.map +1 -1
- package/dist-lib/lib/stock-sync.functions.js +17 -1
- package/dist-lib/server-hooks/floriday-base-supply.d.ts.map +1 -1
- package/dist-lib/server-hooks/floriday-base-supply.js +32 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-supply-reader.server.d.ts","sourceRoot":"","sources":["../../src/lib/base-supply-reader.server.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnE,IAAI,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"base-supply-reader.server.d.ts","sourceRoot":"","sources":["../../src/lib/base-supply-reader.server.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IA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,10 @@ function extractRows(data) {
|
|
|
31
31
|
tradeItemId: String(r.tradeItemId),
|
|
32
32
|
numberOfPieces: Number(r.numberOfPieces ?? 0) || 0,
|
|
33
33
|
isAvailable: r.isAvailable !== false,
|
|
34
|
+
// WeeklyBaseSupply.basePricePerPiece is een Price { currency, value } (Suppliers API 2026v1).
|
|
35
|
+
basePricePerPiece: r.basePricePerPiece && Number.isFinite(Number(r.basePricePerPiece.value))
|
|
36
|
+
? Number(r.basePricePerPiece.value)
|
|
37
|
+
: null,
|
|
34
38
|
}));
|
|
35
39
|
}
|
|
36
40
|
async function callOnce(endpoint, secret, year, week) {
|
|
@@ -17,7 +17,7 @@ export declare const enqueueTestStockPush: import("@tanstack/start-client-core")
|
|
|
17
17
|
}, undefined, undefined, undefined>], (data: unknown) => {
|
|
18
18
|
tradeItemId: string;
|
|
19
19
|
}, Promise<{
|
|
20
|
-
id:
|
|
20
|
+
id: string | null;
|
|
21
21
|
numberOfPieces: number;
|
|
22
22
|
}>>;
|
|
23
23
|
//# sourceMappingURL=stock-sync.functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stock-sync.functions.d.ts","sourceRoot":"","sources":["../../src/lib/stock-sync.functions.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,oBAAoB;;;;;;GA0B7B,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"stock-sync.functions.d.ts","sourceRoot":"","sources":["../../src/lib/stock-sync.functions.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,oBAAoB;;;;;;GA0B7B,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;GAuD7B,CAAC"}
|
|
@@ -69,5 +69,21 @@ export const enqueueTestStockPush = createServerFn({ method: "POST" })
|
|
|
69
69
|
.maybeSingle();
|
|
70
70
|
if (error)
|
|
71
71
|
throw new Error(error.message);
|
|
72
|
-
|
|
72
|
+
// M27: staat er al een open regel voor dit artikel en deze week, dan werkt de
|
|
73
|
+
// database die bij en komt er geen nieuwe rij terug; geef dan het id van die regel.
|
|
74
|
+
let id = inserted?.id ?? null;
|
|
75
|
+
if (!id) {
|
|
76
|
+
const { data: existing } = await admin
|
|
77
|
+
.from("floriday_continuous_stock_queue")
|
|
78
|
+
.select("id")
|
|
79
|
+
.eq("connection_id", stockRow.connection_id)
|
|
80
|
+
.eq("trade_item_id", data.tradeItemId)
|
|
81
|
+
.is("target_week", null)
|
|
82
|
+
.in("status", ["pending", "needs_base_supply", "skipped_no_price", "failed", "processing", "creating_base_supply"])
|
|
83
|
+
.order("updated_at", { ascending: false })
|
|
84
|
+
.limit(1)
|
|
85
|
+
.maybeSingle();
|
|
86
|
+
id = existing?.id ?? null;
|
|
87
|
+
}
|
|
88
|
+
return { id, numberOfPieces: pieces };
|
|
73
89
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floriday-base-supply.d.ts","sourceRoot":"","sources":["../../src/server-hooks/floriday-base-supply.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"floriday-base-supply.d.ts","sourceRoot":"","sources":["../../src/server-hooks/floriday-base-supply.ts"],"names":[],"mappings":"AAwGA,yHAAyH;AACzH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAElF"}
|
|
@@ -33,6 +33,27 @@ async function handle(request) {
|
|
|
33
33
|
if (error)
|
|
34
34
|
return json({ error: `claim: ${error.message}` }, 500);
|
|
35
35
|
const summary = { processed: 0, done: 0, retry: 0, stop: 0, week_past: 0, no_price: 0 };
|
|
36
|
+
// M27: bestaande prijs in Floriday per week (alleen lezen, 1 GET per week per ronde).
|
|
37
|
+
const { readBaseSupplyWeeks } = await import("../lib/base-supply-reader.server.js");
|
|
38
|
+
const weekCache = new Map();
|
|
39
|
+
async function floridayPrice(year, week, tradeItemId) {
|
|
40
|
+
if (!year || !week)
|
|
41
|
+
return null;
|
|
42
|
+
const k = `${year}-${week}`;
|
|
43
|
+
if (!weekCache.has(k)) {
|
|
44
|
+
const m = new Map();
|
|
45
|
+
try {
|
|
46
|
+
const out = await readBaseSupplyWeeks([{ year, week }]);
|
|
47
|
+
for (const r of out.results[0]?.rows ?? [])
|
|
48
|
+
m.set(r.tradeItemId, r.basePricePerPiece);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
/* lezen is optioneel; zonder antwoord geen melding over prijsaanpassing */
|
|
52
|
+
}
|
|
53
|
+
weekCache.set(k, m);
|
|
54
|
+
}
|
|
55
|
+
return weekCache.get(k).get(tradeItemId) ?? null;
|
|
56
|
+
}
|
|
36
57
|
let first = true;
|
|
37
58
|
for (const row of (rows ?? [])) {
|
|
38
59
|
summary.processed++;
|
|
@@ -45,6 +66,7 @@ async function handle(request) {
|
|
|
45
66
|
if (!first)
|
|
46
67
|
await sleep(1000); // max 1 aanvraag per seconde
|
|
47
68
|
first = false;
|
|
69
|
+
const previous = await floridayPrice(row.target_year, row.target_week, row.trade_item_id);
|
|
48
70
|
let d;
|
|
49
71
|
try {
|
|
50
72
|
const { httpStatus, body } = await gatewaySupplyLineWeek(buildRequest(row, price.price, conn.environment));
|
|
@@ -53,10 +75,19 @@ async function handle(request) {
|
|
|
53
75
|
catch (e) {
|
|
54
76
|
d = { kind: "retry", label: "Floriday tijdelijk niet bereikbaar", error: String(e?.message ?? e) };
|
|
55
77
|
}
|
|
78
|
+
let label = d.label;
|
|
79
|
+
const changed = d.kind === "done" &&
|
|
80
|
+
d.priceStatus === "sent" &&
|
|
81
|
+
previous != null &&
|
|
82
|
+
Math.abs(previous - price.price) > 0.0005;
|
|
83
|
+
if (changed) {
|
|
84
|
+
label = `Prijs in Floriday aangepast van € ${previous.toFixed(2)} naar € ${price.price.toFixed(2)}`;
|
|
85
|
+
await admin.from("floriday_continuous_stock_queue").update({ price_previous: previous }).eq("id", row.id);
|
|
86
|
+
}
|
|
56
87
|
await admin.rpc("complete_floriday_base_supply", {
|
|
57
88
|
p_id: row.id,
|
|
58
89
|
p_kind: d.kind,
|
|
59
|
-
p_label:
|
|
90
|
+
p_label: label,
|
|
60
91
|
p_error: d.error ?? null,
|
|
61
92
|
p_attempt_id: d.attemptId ?? null,
|
|
62
93
|
p_outcome: d.outcome ?? null,
|