@flowselections/floriday-voorraad 1.0.127 → 1.0.131
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/ArtikelWizard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ArtikelWizard.js +102 -19
- package/dist-lib/components/voorraad/NieuwArtikelPage.d.ts.map +1 -1
- package/dist-lib/components/voorraad/NieuwArtikelPage.js +2 -0
- package/dist-lib/components/voorraad/PriceStatusBadge.d.ts.map +1 -1
- package/dist-lib/components/voorraad/PriceStatusBadge.js +21 -45
- package/dist-lib/components/voorraad/ProductStructureCard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ProductStructureCard.js +6 -2
- package/dist-lib/hooks/useLocalTradeItems.d.ts.map +1 -1
- package/dist-lib/hooks/useLocalTradeItems.js +4 -0
- package/dist-lib/integrations/supabase/types.d.ts +801 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/__tests__/article-code.test.d.ts +2 -0
- package/dist-lib/lib/__tests__/article-code.test.d.ts.map +1 -0
- package/dist-lib/lib/__tests__/article-code.test.js +11 -0
- package/dist-lib/lib/__tests__/release-130.test.d.ts +2 -0
- package/dist-lib/lib/__tests__/release-130.test.d.ts.map +1 -0
- package/dist-lib/lib/__tests__/release-130.test.js +103 -0
- package/dist-lib/lib/article-code.d.ts +12 -0
- package/dist-lib/lib/article-code.d.ts.map +1 -0
- package/dist-lib/lib/article-code.js +29 -0
- package/dist-lib/lib/floriday-2026v1.server.d.ts +1 -8
- package/dist-lib/lib/floriday-2026v1.server.d.ts.map +1 -1
- package/dist-lib/lib/floriday-2026v1.server.js +0 -10
- package/dist-lib/lib/floriday-gateway.functions.d.ts +6 -0
- package/dist-lib/lib/floriday-gateway.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-gateway.functions.js +7 -0
- package/dist-lib/lib/floriday-gateway.server.d.ts +17 -4
- package/dist-lib/lib/floriday-gateway.server.d.ts.map +1 -1
- package/dist-lib/lib/floriday-gateway.server.js +80 -2
- package/dist-lib/lib/floriday-payload.d.ts.map +1 -1
- package/dist-lib/lib/floriday-payload.js +11 -3
- package/dist-lib/lib/floriday-read-contract.d.ts +49 -0
- package/dist-lib/lib/floriday-read-contract.d.ts.map +1 -0
- package/dist-lib/lib/floriday-read-contract.js +92 -0
- package/dist-lib/lib/price-status.d.ts +14 -0
- package/dist-lib/lib/price-status.d.ts.map +1 -0
- package/dist-lib/lib/price-status.js +16 -0
- package/dist-lib/lib/publish-pipeline.d.ts.map +1 -1
- package/dist-lib/lib/publish-pipeline.js +2 -7
- package/dist-lib/lib/publish-status.d.ts +26 -0
- package/dist-lib/lib/publish-status.d.ts.map +1 -0
- package/dist-lib/lib/publish-status.js +30 -0
- package/dist-lib/server-hooks/floriday-continuous-stock-pull.d.ts.map +1 -1
- package/dist-lib/server-hooks/floriday-continuous-stock-pull.js +37 -50
- package/package.json +1 -1
- package/sql/floriday-voorraad-schema.sql +88 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract van de leesroute van Floriday-authenticatie (1.0.130):
|
|
3
|
+
* POST /api/public/gateway/floriday-get
|
|
4
|
+
* { requests: [{ method: "GET", path, query }] } (1–10 items)
|
|
5
|
+
* → { ok, environment, results: [{ ok, status, path, data } |
|
|
6
|
+
* { ok:false, status, path, error, retryAfterMs? }] }
|
|
7
|
+
* Paden ZONDER het voorvoegsel /suppliers-api-2026v1.
|
|
8
|
+
*
|
|
9
|
+
* Puur (geen netwerk), zodat het in tests zonder Floriday te controleren is.
|
|
10
|
+
*/
|
|
11
|
+
export const FLORIDAY_READ_ROUTE = "/api/public/gateway/floriday-get";
|
|
12
|
+
export const FLORIDAY_READ_MAX_BATCH = 10;
|
|
13
|
+
/** Alle gateway-routes die Voorraad aanroept (voor de install-check). */
|
|
14
|
+
export const VOORRAAD_GATEWAY_ROUTES = [
|
|
15
|
+
"/api/public/gateway/write",
|
|
16
|
+
FLORIDAY_READ_ROUTE,
|
|
17
|
+
];
|
|
18
|
+
export const READ_ROUTE_MISSING = "Leesroute ontbreekt in de shell: /gateway/floriday-get is niet bereikbaar. " +
|
|
19
|
+
"Installeer Floriday-authenticatie 1.0.130 of hoger.";
|
|
20
|
+
const PREFIX = /^\/suppliers-api-[^/]+/;
|
|
21
|
+
/** Haalt het API-voorvoegsel weg en verplaatst een querystring naar `query`. */
|
|
22
|
+
export function toReadRequest(fullPath) {
|
|
23
|
+
let p = fullPath.trim().replace(PREFIX, "");
|
|
24
|
+
if (!p.startsWith("/"))
|
|
25
|
+
p = `/${p}`;
|
|
26
|
+
const [path, qs] = p.split("?");
|
|
27
|
+
const req = { method: "GET", path };
|
|
28
|
+
if (qs) {
|
|
29
|
+
const query = {};
|
|
30
|
+
for (const [k, v] of new URLSearchParams(qs))
|
|
31
|
+
query[k] = v;
|
|
32
|
+
req.query = query;
|
|
33
|
+
}
|
|
34
|
+
return req;
|
|
35
|
+
}
|
|
36
|
+
export function chunk(items, size = FLORIDAY_READ_MAX_BATCH) {
|
|
37
|
+
const out = [];
|
|
38
|
+
for (let i = 0; i < items.length; i += size)
|
|
39
|
+
out.push(items.slice(i, i + size));
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Beoordeelt het HTTP-antwoord van de route zelf. Een HTML- of 404-antwoord
|
|
44
|
+
* betekent dat de route in de shell ontbreekt — nooit de ruwe HTML tonen.
|
|
45
|
+
*/
|
|
46
|
+
export function parseReadResponse(httpStatus, contentType, text, expected) {
|
|
47
|
+
const isJson = contentType.toLowerCase().includes("application/json");
|
|
48
|
+
if (!isJson) {
|
|
49
|
+
if (httpStatus === 404 || /<html/i.test(text))
|
|
50
|
+
throw new Error(READ_ROUTE_MISSING);
|
|
51
|
+
throw new Error(`Leesroute gaf geen geldig antwoord (status ${httpStatus}).`);
|
|
52
|
+
}
|
|
53
|
+
let body;
|
|
54
|
+
try {
|
|
55
|
+
body = text ? JSON.parse(text) : null;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error(`Leesroute gaf onleesbaar antwoord (status ${httpStatus}).`);
|
|
59
|
+
}
|
|
60
|
+
if (!body)
|
|
61
|
+
throw new Error(`Leesroute gaf een leeg antwoord (status ${httpStatus}).`);
|
|
62
|
+
if (!Array.isArray(body.results)) {
|
|
63
|
+
if (httpStatus === 404)
|
|
64
|
+
throw new Error(READ_ROUTE_MISSING);
|
|
65
|
+
throw new Error(body.error || body.message || `Leesroute weigerde het verzoek (status ${httpStatus}).`);
|
|
66
|
+
}
|
|
67
|
+
const results = body.results.map((r) => ({
|
|
68
|
+
ok: r?.ok === true,
|
|
69
|
+
status: typeof r?.status === "number" ? r.status : 0,
|
|
70
|
+
path: String(r?.path ?? ""),
|
|
71
|
+
data: r?.ok === true ? (r.data ?? null) : null,
|
|
72
|
+
error: r?.ok === true ? undefined : String(r?.error ?? `HTTP ${r?.status ?? "?"}`),
|
|
73
|
+
retryAfterMs: typeof r?.retryAfterMs === "number" ? r.retryAfterMs : undefined,
|
|
74
|
+
}));
|
|
75
|
+
if (results.length !== expected) {
|
|
76
|
+
throw new Error(`Leesroute gaf ${results.length} resultaten terug voor ${expected} verzoeken.`);
|
|
77
|
+
}
|
|
78
|
+
return results;
|
|
79
|
+
}
|
|
80
|
+
export function interpretContinuousStock(r) {
|
|
81
|
+
if (r.ok) {
|
|
82
|
+
const d = r.data ?? {};
|
|
83
|
+
const pieces = typeof d.numberOfPieces === "number" ? d.numberOfPieces : d.available === true ? 1 : 0;
|
|
84
|
+
return { kind: "pieces", pieces };
|
|
85
|
+
}
|
|
86
|
+
// 404 per artikel = geen beschikbaarheid ingesteld.
|
|
87
|
+
if (r.status === 404)
|
|
88
|
+
return { kind: "pieces", pieces: 0 };
|
|
89
|
+
if (r.status === 429)
|
|
90
|
+
return { kind: "retry", waitMs: Math.max(0, r.retryAfterMs ?? 1000) };
|
|
91
|
+
return { kind: "fail", error: r.error ?? `HTTP ${r.status}` };
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prijsstatus van een artikel: één bron, één label (1.0.130).
|
|
3
|
+
* Bron: de prijsregel (supply line) van het Floriday-artikel. De schakelaar
|
|
4
|
+
* "Te koop aanbieden" en de wachtrij veranderen het label niet; ze komen
|
|
5
|
+
* alleen in de toelichting, zodat hetzelfde artikel overal hetzelfde toont.
|
|
6
|
+
*/
|
|
7
|
+
export type PriceStatusVariant = "live" | "expired" | "drained" | "none";
|
|
8
|
+
export interface PriceSupplyLine {
|
|
9
|
+
available_quantity: number | null;
|
|
10
|
+
period_end: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const PRICE_STATUS_LABELS: Record<PriceStatusVariant, string>;
|
|
13
|
+
export declare function priceStatus(supplyLine: PriceSupplyLine | null | undefined, now?: number): PriceStatusVariant;
|
|
14
|
+
//# sourceMappingURL=price-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price-status.d.ts","sourceRoot":"","sources":["../../src/lib/price-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzE,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAKlE,CAAC;AAEF,wBAAgB,WAAW,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,SAAa,GAAG,kBAAkB,CAMhH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const PRICE_STATUS_LABELS = {
|
|
2
|
+
live: "Prijs live in catalogus",
|
|
3
|
+
expired: "Prijs verlopen",
|
|
4
|
+
drained: "Voorraad op",
|
|
5
|
+
none: "Geen prijs actief",
|
|
6
|
+
};
|
|
7
|
+
export function priceStatus(supplyLine, now = Date.now()) {
|
|
8
|
+
if (!supplyLine)
|
|
9
|
+
return "none";
|
|
10
|
+
const endMs = supplyLine.period_end ? new Date(supplyLine.period_end).getTime() : null;
|
|
11
|
+
if (endMs !== null && endMs < now)
|
|
12
|
+
return "expired";
|
|
13
|
+
if ((supplyLine.available_quantity ?? 0) <= 0)
|
|
14
|
+
return "drained";
|
|
15
|
+
return "live";
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-pipeline.d.ts","sourceRoot":"","sources":["../../src/lib/publish-pipeline.ts"],"names":[],"mappings":"AAQA,OAAO,EAAyB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEpF,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,OAAO,GACP,OAAO,GACP,aAAa,GACb,QAAQ,GACR,QAAQ,CAAC;AAEb,eAAO,MAAM,aAAa,EAAE;IAAE,GAAG,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAOjE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,GAAG,CAAC;IAC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AAE,MAAM,CAAC;IAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC7E,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAsD3B;AAeD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GACzD,OAAO,CAAC,gBAAgB,CAAC,CAc3B;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,KAAK,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAClC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BhB;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACjC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAOjD"}
|
|
@@ -145,13 +145,8 @@ function sanitizeResult(value) {
|
|
|
145
145
|
export async function finishPublishJob(jobId, patch) {
|
|
146
146
|
const { data } = await steps().select("status, step_key").eq("job_id", jobId);
|
|
147
147
|
const rows = (data ?? []);
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const status = coreFailed
|
|
151
|
-
? "failed"
|
|
152
|
-
: failed.length > 0
|
|
153
|
-
? "succeeded_with_warnings"
|
|
154
|
-
: "succeeded";
|
|
148
|
+
const { publishOutcome } = await import("./publish-status.js");
|
|
149
|
+
const status = publishOutcome(rows);
|
|
155
150
|
await jobs()
|
|
156
151
|
.update({
|
|
157
152
|
status,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regels voor de publicatiestatus van een artikel (1.0.130).
|
|
3
|
+
* - Een artikel met een Floriday-id telt als gepubliceerd.
|
|
4
|
+
* - Een mislukte controle is een waarschuwing, geen mislukte publicatie.
|
|
5
|
+
* - Wijzigingen gaan naar Floriday als er een Floriday-id is, tenzij er een
|
|
6
|
+
* reden is waarom dat niet kan; die reden wordt dan getoond.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isPublishedToFloriday(...ids: Array<string | null | undefined>): boolean;
|
|
9
|
+
export type StepOutcome = {
|
|
10
|
+
step_key: string;
|
|
11
|
+
status: string;
|
|
12
|
+
};
|
|
13
|
+
export type PublishOutcome = "failed" | "succeeded_with_warnings" | "succeeded";
|
|
14
|
+
/** Alleen de artikelstap bepaalt of de publicatie mislukt is. */
|
|
15
|
+
export declare function publishOutcome(steps: StepOutcome[]): PublishOutcome;
|
|
16
|
+
export interface EditTarget {
|
|
17
|
+
sendsToFloriday: boolean;
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
/** Wat het bewerkscherm belooft over het versturen van wijzigingen. */
|
|
21
|
+
export declare function editTargetText(input: {
|
|
22
|
+
floridayId: string | null | undefined;
|
|
23
|
+
writeReadOnly: boolean | null | undefined;
|
|
24
|
+
writeReason?: string | null;
|
|
25
|
+
}): EditTarget;
|
|
26
|
+
//# sourceMappingURL=publish-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-status.d.ts","sourceRoot":"","sources":["../../src/lib/publish-status.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,qBAAqB,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAEvF;AAED,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/D,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,yBAAyB,GAAG,WAAW,CAAC;AAEhF,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,cAAc,CAInE;AAED,MAAM,WAAW,UAAU;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACtC,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GAAG,UAAU,CAWb"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regels voor de publicatiestatus van een artikel (1.0.130).
|
|
3
|
+
* - Een artikel met een Floriday-id telt als gepubliceerd.
|
|
4
|
+
* - Een mislukte controle is een waarschuwing, geen mislukte publicatie.
|
|
5
|
+
* - Wijzigingen gaan naar Floriday als er een Floriday-id is, tenzij er een
|
|
6
|
+
* reden is waarom dat niet kan; die reden wordt dan getoond.
|
|
7
|
+
*/
|
|
8
|
+
export function isPublishedToFloriday(...ids) {
|
|
9
|
+
return ids.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
10
|
+
}
|
|
11
|
+
/** Alleen de artikelstap bepaalt of de publicatie mislukt is. */
|
|
12
|
+
export function publishOutcome(steps) {
|
|
13
|
+
const failed = steps.filter((s) => s.status === "failed");
|
|
14
|
+
if (failed.some((s) => s.step_key === "trade-item"))
|
|
15
|
+
return "failed";
|
|
16
|
+
return failed.length ? "succeeded_with_warnings" : "succeeded";
|
|
17
|
+
}
|
|
18
|
+
/** Wat het bewerkscherm belooft over het versturen van wijzigingen. */
|
|
19
|
+
export function editTargetText(input) {
|
|
20
|
+
if (!isPublishedToFloriday(input.floridayId)) {
|
|
21
|
+
return { sendsToFloriday: false, text: "Dit artikel staat nog niet in Floriday; wijzigingen blijven in dit systeem." };
|
|
22
|
+
}
|
|
23
|
+
if (input.writeReadOnly) {
|
|
24
|
+
return {
|
|
25
|
+
sendsToFloriday: false,
|
|
26
|
+
text: `Wijzigingen worden nu níet naar Floriday verstuurd: ${input.writeReason ?? "Floriday staat op alleen lezen (oorzaak onbekend)"}.`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return { sendsToFloriday: true, text: "Wijzigingen worden direct naar Floriday verstuurd." };
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floriday-continuous-stock-pull.d.ts","sourceRoot":"","sources":["../../src/server-hooks/floriday-continuous-stock-pull.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"floriday-continuous-stock-pull.d.ts","sourceRoot":"","sources":["../../src/server-hooks/floriday-continuous-stock-pull.ts"],"names":[],"mappings":"AA0LA,oIAAoI;AACpI,wBAAsB,iCAAiC,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE3F"}
|
|
@@ -8,23 +8,10 @@
|
|
|
8
8
|
* bestaande push-hook).
|
|
9
9
|
*
|
|
10
10
|
* Rate limits en CPU-tijd op Cloudflare Workers: max 200 items per run,
|
|
11
|
-
* oudste `fetched_at` eerst;
|
|
11
|
+
* oudste `fetched_at` eerst; 10 artikelen per aanroep van floriday-get.
|
|
12
12
|
*/
|
|
13
13
|
import { runGuardedHook } from "./guard.js";
|
|
14
14
|
const MAX_ITEMS_PER_RUN = 200;
|
|
15
|
-
const PARALLEL = 5;
|
|
16
|
-
async function pMapLimited(items, limit, worker) {
|
|
17
|
-
const results = new Array(items.length);
|
|
18
|
-
let i = 0;
|
|
19
|
-
const runners = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
20
|
-
while (i < items.length) {
|
|
21
|
-
const idx = i++;
|
|
22
|
-
results[idx] = await worker(items[idx]);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
await Promise.all(runners);
|
|
26
|
-
return results;
|
|
27
|
-
}
|
|
28
15
|
async function handle(request) {
|
|
29
16
|
{
|
|
30
17
|
void 0;
|
|
@@ -39,7 +26,7 @@ async function handle(request) {
|
|
|
39
26
|
}
|
|
40
27
|
const { getAdminClient } = await import("../lib/supabase-admin.server.js");
|
|
41
28
|
const supabaseAdmin = getAdminClient();
|
|
42
|
-
const {
|
|
29
|
+
const { gatewayReadMany } = await import("../lib/floriday-gateway.server.js");
|
|
43
30
|
const { resolveActiveFloridayConnection } = await import("../lib/floriday-env.server.js");
|
|
44
31
|
const activeConnection = await resolveActiveFloridayConnection(supabaseAdmin);
|
|
45
32
|
const connections = [activeConnection];
|
|
@@ -92,50 +79,50 @@ async function handle(request) {
|
|
|
92
79
|
let ok = 0;
|
|
93
80
|
let fail = 0;
|
|
94
81
|
const upserts = [];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
// Bundel 10 artikelen per aanroep van floriday-get; de limiet per pad
|
|
83
|
+
// bewaakt Floriday-authenticatie. 429 → wachten volgens retryAfterMs
|
|
84
|
+
// en die artikelen één keer opnieuw vragen.
|
|
85
|
+
const { chunk, interpretContinuousStock } = await import("../lib/floriday-read-contract.js");
|
|
86
|
+
let pending = batch.slice();
|
|
87
|
+
for (let round = 0; round < 2 && pending.length; round++) {
|
|
88
|
+
const retry = [];
|
|
89
|
+
let waitMs = 0;
|
|
90
|
+
for (const group of chunk(pending)) {
|
|
91
|
+
let results;
|
|
92
|
+
try {
|
|
93
|
+
results = await gatewayReadMany(environment, group.map((id) => `/trade-items/${id}/continuous-stock`));
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
console.error(`[continuous-stock-pull] batch:`, e?.message ?? e);
|
|
97
|
+
fail += group.length;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
results.forEach((r, i) => {
|
|
101
|
+
const tradeItemId = group[i];
|
|
102
|
+
const o = interpretContinuousStock(r);
|
|
103
|
+
if (o.kind === "pieces") {
|
|
104
104
|
upserts.push({
|
|
105
105
|
connection_id: conn.id,
|
|
106
106
|
trade_item_id: tradeItemId,
|
|
107
|
-
number_of_pieces:
|
|
107
|
+
number_of_pieces: o.pieces,
|
|
108
108
|
fetched_at: new Date().toISOString(),
|
|
109
109
|
});
|
|
110
110
|
ok++;
|
|
111
|
-
return;
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const pieces = typeof data.numberOfPieces === "number"
|
|
122
|
-
? data.numberOfPieces
|
|
123
|
-
: data.available === true
|
|
124
|
-
? 1
|
|
125
|
-
: 0;
|
|
126
|
-
upserts.push({
|
|
127
|
-
connection_id: conn.id,
|
|
128
|
-
trade_item_id: tradeItemId,
|
|
129
|
-
number_of_pieces: pieces,
|
|
130
|
-
fetched_at: new Date().toISOString(),
|
|
112
|
+
else if (o.kind === "retry" && round === 0) {
|
|
113
|
+
retry.push(tradeItemId);
|
|
114
|
+
waitMs = Math.max(waitMs, o.waitMs);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
console.error(`[continuous-stock-pull] ${tradeItemId}: ${o.kind === "fail" ? o.error : "429"}`);
|
|
118
|
+
fail++;
|
|
119
|
+
}
|
|
131
120
|
});
|
|
132
|
-
ok++;
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
console.error(`[continuous-stock-pull] ${tradeItemId}:`, e?.message ?? e);
|
|
136
|
-
fail++;
|
|
137
121
|
}
|
|
138
|
-
|
|
122
|
+
pending = retry;
|
|
123
|
+
if (pending.length)
|
|
124
|
+
await new Promise((r) => setTimeout(r, Math.min(waitMs, 10000)));
|
|
125
|
+
}
|
|
139
126
|
if (upserts.length) {
|
|
140
127
|
const { error: upErr } = await supabaseAdmin
|
|
141
128
|
.from("floriday_continuous_stock_cache")
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
-- @flowselections/floriday-voorraad 1.0.
|
|
1
|
+
-- @flowselections/floriday-voorraad 1.0.130 – volledig schema (idempotent, geen gegevens).
|
|
2
2
|
-- Gegenereerd uit de database met scripts/generate-voorraad-schema.py. Niet met de hand wijzigen.
|
|
3
3
|
-- Volgorde 20. Ontbrekende tabellen van andere modules worden overgeslagen met een NOTICE; draai opnieuw na die module.
|
|
4
4
|
-- De statuscontrole van floriday_continuous_stock_queue is van Voorraad en wordt hier opnieuw gemaakt.
|
|
@@ -574,6 +574,11 @@ ALTER TABLE public.voorraad_media_upload_failures ADD COLUMN IF NOT EXISTS respo
|
|
|
574
574
|
ALTER TABLE public.voorraad_media_upload_failures ADD COLUMN IF NOT EXISTS error_message text;
|
|
575
575
|
ALTER TABLE public.voorraad_media_upload_failures ADD COLUMN IF NOT EXISTS client_user_id uuid;
|
|
576
576
|
|
|
577
|
+
-- voorraad_placeholder_codes
|
|
578
|
+
CREATE TABLE IF NOT EXISTS public.voorraad_placeholder_codes ();
|
|
579
|
+
ALTER TABLE public.voorraad_placeholder_codes ADD COLUMN IF NOT EXISTS code text NOT NULL;
|
|
580
|
+
ALTER TABLE public.voorraad_placeholder_codes ADD COLUMN IF NOT EXISTS created_at timestamp with time zone DEFAULT now() NOT NULL;
|
|
581
|
+
|
|
577
582
|
-- voorraad_publish_attempts
|
|
578
583
|
CREATE TABLE IF NOT EXISTS public.voorraad_publish_attempts ();
|
|
579
584
|
ALTER TABLE public.voorraad_publish_attempts ADD COLUMN IF NOT EXISTS id uuid DEFAULT gen_random_uuid() NOT NULL;
|
|
@@ -7136,6 +7141,27 @@ END $function$
|
|
|
7136
7141
|
REVOKE ALL ON FUNCTION trg_products_floriday_link_enqueue() FROM PUBLIC;
|
|
7137
7142
|
REVOKE ALL ON FUNCTION trg_products_floriday_link_enqueue() FROM anon;
|
|
7138
7143
|
GRANT EXECUTE ON FUNCTION trg_products_floriday_link_enqueue() TO service_role;
|
|
7144
|
+
CREATE OR REPLACE FUNCTION public.trg_products_placeholder_code()
|
|
7145
|
+
RETURNS trigger
|
|
7146
|
+
LANGUAGE plpgsql
|
|
7147
|
+
SECURITY DEFINER
|
|
7148
|
+
SET search_path TO 'public'
|
|
7149
|
+
AS $function$
|
|
7150
|
+
DECLARE v text := lower(btrim(coalesce(NEW.article_number, '')));
|
|
7151
|
+
BEGIN
|
|
7152
|
+
IF TG_OP = 'UPDATE' AND NEW.article_number IS NOT DISTINCT FROM OLD.article_number THEN RETURN NEW; END IF;
|
|
7153
|
+
IF v = '' OR NOT EXISTS (SELECT 1 FROM public.voorraad_placeholder_codes c WHERE c.code = v) THEN RETURN NEW; END IF;
|
|
7154
|
+
IF public.voorraad_is_server() THEN
|
|
7155
|
+
RAISE WARNING 'Artikel %: "%" is een invultekst als artikelcode (gemeld, niet geweigerd).', NEW.id, NEW.article_number;
|
|
7156
|
+
RETURN NEW;
|
|
7157
|
+
END IF;
|
|
7158
|
+
RAISE EXCEPTION '"%" is een invultekst, geen artikelcode. Vul de echte artikelcode in.', btrim(NEW.article_number)
|
|
7159
|
+
USING ERRCODE = 'P0001';
|
|
7160
|
+
END $function$
|
|
7161
|
+
;
|
|
7162
|
+
REVOKE ALL ON FUNCTION trg_products_placeholder_code() FROM PUBLIC;
|
|
7163
|
+
REVOKE ALL ON FUNCTION trg_products_placeholder_code() FROM anon;
|
|
7164
|
+
GRANT EXECUTE ON FUNCTION trg_products_placeholder_code() TO service_role;
|
|
7139
7165
|
CREATE OR REPLACE FUNCTION public.trg_products_seed_stock_fn()
|
|
7140
7166
|
RETURNS trigger
|
|
7141
7167
|
LANGUAGE plpgsql
|
|
@@ -8804,6 +8830,34 @@ REVOKE ALL ON FUNCTION voorraad_fust_juist(uuid) FROM PUBLIC;
|
|
|
8804
8830
|
REVOKE ALL ON FUNCTION voorraad_fust_juist(uuid) FROM anon;
|
|
8805
8831
|
GRANT EXECUTE ON FUNCTION voorraad_fust_juist(uuid) TO authenticated;
|
|
8806
8832
|
GRANT EXECUTE ON FUNCTION voorraad_fust_juist(uuid) TO service_role;
|
|
8833
|
+
CREATE OR REPLACE FUNCTION public.voorraad_gateway_routes_check()
|
|
8834
|
+
RETURNS jsonb
|
|
8835
|
+
LANGUAGE plpgsql
|
|
8836
|
+
STABLE SECURITY DEFINER
|
|
8837
|
+
SET search_path TO 'public'
|
|
8838
|
+
AS $function$
|
|
8839
|
+
DECLARE
|
|
8840
|
+
v_req text[] := ARRAY['/api/public/gateway/write','/api/public/gateway/floriday-get'];
|
|
8841
|
+
v_raw text; v_cfg jsonb := '{}'::jsonb; v_out jsonb;
|
|
8842
|
+
BEGIN
|
|
8843
|
+
PERFORM public.voorraad_vereis('server', 'voorraad_gateway_routes_check');
|
|
8844
|
+
SELECT value INTO v_raw FROM public.module_runtime_config WHERE key = 'voorraad_gateway_routes';
|
|
8845
|
+
BEGIN v_cfg := COALESCE(v_raw::jsonb, '{}'::jsonb); EXCEPTION WHEN others THEN v_cfg := '{}'::jsonb; END;
|
|
8846
|
+
SELECT jsonb_agg(jsonb_build_object(
|
|
8847
|
+
'route', r,
|
|
8848
|
+
'status', COALESCE(v_cfg->r->>'status', 'niet_gecontroleerd'),
|
|
8849
|
+
'gecontroleerd_op', v_cfg->r->>'checked_at',
|
|
8850
|
+
'melding', CASE COALESCE(v_cfg->r->>'status','')
|
|
8851
|
+
WHEN 'aanwezig' THEN NULL
|
|
8852
|
+
WHEN 'ontbreekt' THEN 'Route ontbreekt in de shell: ' || r
|
|
8853
|
+
ELSE 'Nog niet gecontroleerd; draai de routecontrole of wacht op de eerste Floriday-aanroep' END)
|
|
8854
|
+
ORDER BY r) INTO v_out FROM unnest(v_req) r;
|
|
8855
|
+
RETURN v_out;
|
|
8856
|
+
END $function$
|
|
8857
|
+
;
|
|
8858
|
+
REVOKE ALL ON FUNCTION voorraad_gateway_routes_check() FROM PUBLIC;
|
|
8859
|
+
REVOKE ALL ON FUNCTION voorraad_gateway_routes_check() FROM anon;
|
|
8860
|
+
GRANT EXECUTE ON FUNCTION voorraad_gateway_routes_check() TO service_role;
|
|
8807
8861
|
CREATE OR REPLACE FUNCTION public.voorraad_hook_base_url()
|
|
8808
8862
|
RETURNS text
|
|
8809
8863
|
LANGUAGE plpgsql
|
|
@@ -8921,7 +8975,7 @@ CREATE OR REPLACE FUNCTION public.voorraad_install_check()
|
|
|
8921
8975
|
STABLE SECURITY DEFINER
|
|
8922
8976
|
SET search_path TO 'public'
|
|
8923
8977
|
AS $function$
|
|
8924
|
-
DECLARE v_f text[] := ARRAY['voorraad_fust_juist','voorraad_correctie_1121','voorraad_correctie_1121_regels','voorraad_correctie_1123','voorraad_correctie_1124','voorraad_load_carriers','voorraad_packing_from_floriday','voorraad_packing_missing','voorraad_correctie_1126','voorraad_correctie_1127','trg_voorraad_link_primary_packing','voorraad_order_geannuleerd','voorraad_article_vbn','voorraad_correctie_1112','voorraad_reverse_order_mutations','voorraad_withdraw_stock_row','ensure_voorraad_local_context','get_stock_context','voorraad_stock_context_status','voorraad_fcsq_local_guard','_floriday_queue_cleanup_batch','_migrate_rewrite_stock_key','_stock_import_caller','apply_fust_stock_mutation','apply_stock_consumption','apply_stock_reservation','autolink_product_to_floriday','backfill_open_order_reservations','calculate_floriday_desired_stock','calculate_structure_available','canonicalize_trade_item_stock_key','check_product_structure','claim_floriday_base_supply','claim_floriday_stock_queue','cleanup_floriday_stock_queue','cleanup_voorraad_module_history','complete_floriday_base_supply','complete_floriday_stock_queue','complete_floriday_stock_queue_outcome','consume_bom_for_production','consume_order_item','drain_inventory_recompute_queue','enqueue_floriday_continuous_stock','enqueue_floriday_continuous_stock_after_warehouse_preference','enqueue_structure_recompute','ensure_inventory_recompute_drain','ensure_trade_item_stock_row','ensure_trade_item_stock_row_key','fcsq_block_disabled','fcsq_fallback_supersede','fcsq_wake_base_supply','find_trade_item_key','floriday_adopt_connection','floriday_autoheal_connections','floriday_capture_stock_snapshot','floriday_cleanup_stock_queue_v2','floriday_compact_stock_snapshots','floriday_default_owner','floriday_desired_stock_regression_check','floriday_ensure_inventory_settings','floriday_erp_leading_preview','floriday_fill_publish_horizon','floriday_follow_apply','floriday_ingest_sales_orders','floriday_leading_summary','floriday_make_erp_leading','floriday_norm_offer_forms','floriday_orphan_settings_count','floriday_publish_horizon_weeks','floriday_queue_erp_guard','floriday_queue_first_positive','floriday_recompute_inventory','floriday_relink_products','floriday_requeue_dead_letters','floriday_settings_change_recompute','floriday_settings_change_recompute_stmt','floriday_stock_change_recompute','floriday_stock_queue_supersede','floriday_takeover_apply','floriday_takeover_fetch_state','floriday_takeover_store_forms','floriday_takeover_undo','fust_negative_stock_report','fust_types_duplicate_guard','get_active_floriday_context','get_group_allocation_keys','get_group_head_key','get_product_stock','get_product_structure_totals','get_product_structure_totals_batch','inventory_inline_budget_ok','merge_products','normalize_order_source','process_inventory_recompute_queue','produce_designed_product','product_active_group_id','product_id_from_ref','product_is_set','product_label','product_member_group_ids','product_own_available','product_packings_derive','product_packings_replace','product_packings_sync_from_floriday','product_primary_pieces','product_set_depth_above','product_set_depth_below','product_structure_ancestors','product_structure_max_depth','product_structure_path','product_tray_stickers_touch','product_type','promote_trade_item_key','recompute_all_reserved_stock','recompute_order_status','recompute_reserved_for_order','recompute_reserved_stock','requeue_skipped_stock_rows','reset_stalled_floriday_stock_queue','resolve_group_allocation','resolve_group_member_stock_key','resolve_product_id_for_item','resolve_stock_trade_item_key','reverse_production','run_floriday_base_supply_process','run_floriday_continuous_stock_sync','run_floriday_follow','run_floriday_stock_queue_process','run_floriday_stock_reconcile','run_logistics_tasks_dispatch','self_heal_floriday_links','set_module_runtime_config_updated_at','set_product_bom_tenant','set_product_stock','set_updated_at_order_fust_bookings','stock_import_cleanup','stock_import_create','stock_import_process_chunk','stock_import_stop','stock_import_undo_chunk','sync_order_item_fusten','sync_products_quantity_from_stock','touch_fust_types_updated_at','trade_item_drafts_readonly','trade_item_prices_touch_updated_at','trade_item_stock_duplicates','trg_cart_numbers_sync_order_status_fn','trg_cart_session_consume_fn','trg_check_product_structure','trg_floriday_cache_relink_fn','trg_floriday_trade_items_autolink_fn','trg_order_items_autolink_fn','trg_order_items_fusten','trg_order_items_reserve_fn','trg_orders_cancel_release_fn','trg_orders_consume_on_complete_fn','trg_orders_default_phase_fn','trg_orders_external_fulfilled_fn','trg_orders_recompute_reserved_fn','trg_pgi_assign_sort_order','trg_pgi_order_taken_check','trg_process_recompute_on_commit','trg_product_packings_derive_fn','trg_products_autolink_fn','trg_products_floriday_link_enqueue','trg_products_seed_stock_fn','trg_requeue_no_warehouse_cache','trg_requeue_no_warehouse_connection','trg_requeue_no_warehouse_item_pref','trg_requeue_skipped_no_price','trg_stock_structure_recompute_ins','trg_stock_structure_recompute_upd','trg_structure_change_recompute','trg_trade_item_drafts_autolink_fn','trg_trade_item_stock_auto_bom','trg_trade_item_stock_auto_bom_reverse','trg_trade_item_stock_log_change','trg_trade_item_stock_reserve_fn','trg_trade_item_stock_zero_watch','trg_trade_items_cache_autolink_fn','update_updated_at_column','voorraad_alert_floriday_not_updated','voorraad_can_write','voorraad_cleanup_old_rows','voorraad_consume_external_fulfilled','voorraad_correctie_1098','voorraad_correctie_status','voorraad_external_fulfilled_ids','voorraad_floriday_leads_key','voorraad_fust_dimensions','voorraad_hook_base_url','voorraad_hook_on','voorraad_hook_post','voorraad_hook_switch_jobs','voorraad_install_check','voorraad_is_server','voorraad_mark_floriday_sold_before_switch','voorraad_production_enabled','voorraad_schema_ddl','voorraad_touch_updated_at','voorraad_vereis','voorraad_week_is_past'];
|
|
8978
|
+
DECLARE v_f text[] := ARRAY['voorraad_gateway_routes_check','voorraad_placeholder_code_reason','trg_products_placeholder_code','voorraad_fust_juist','voorraad_correctie_1121','voorraad_correctie_1121_regels','voorraad_correctie_1123','voorraad_correctie_1124','voorraad_load_carriers','voorraad_packing_from_floriday','voorraad_packing_missing','voorraad_correctie_1126','voorraad_correctie_1127','trg_voorraad_link_primary_packing','voorraad_order_geannuleerd','voorraad_article_vbn','voorraad_correctie_1112','voorraad_reverse_order_mutations','voorraad_withdraw_stock_row','ensure_voorraad_local_context','get_stock_context','voorraad_stock_context_status','voorraad_fcsq_local_guard','_floriday_queue_cleanup_batch','_migrate_rewrite_stock_key','_stock_import_caller','apply_fust_stock_mutation','apply_stock_consumption','apply_stock_reservation','autolink_product_to_floriday','backfill_open_order_reservations','calculate_floriday_desired_stock','calculate_structure_available','canonicalize_trade_item_stock_key','check_product_structure','claim_floriday_base_supply','claim_floriday_stock_queue','cleanup_floriday_stock_queue','cleanup_voorraad_module_history','complete_floriday_base_supply','complete_floriday_stock_queue','complete_floriday_stock_queue_outcome','consume_bom_for_production','consume_order_item','drain_inventory_recompute_queue','enqueue_floriday_continuous_stock','enqueue_floriday_continuous_stock_after_warehouse_preference','enqueue_structure_recompute','ensure_inventory_recompute_drain','ensure_trade_item_stock_row','ensure_trade_item_stock_row_key','fcsq_block_disabled','fcsq_fallback_supersede','fcsq_wake_base_supply','find_trade_item_key','floriday_adopt_connection','floriday_autoheal_connections','floriday_capture_stock_snapshot','floriday_cleanup_stock_queue_v2','floriday_compact_stock_snapshots','floriday_default_owner','floriday_desired_stock_regression_check','floriday_ensure_inventory_settings','floriday_erp_leading_preview','floriday_fill_publish_horizon','floriday_follow_apply','floriday_ingest_sales_orders','floriday_leading_summary','floriday_make_erp_leading','floriday_norm_offer_forms','floriday_orphan_settings_count','floriday_publish_horizon_weeks','floriday_queue_erp_guard','floriday_queue_first_positive','floriday_recompute_inventory','floriday_relink_products','floriday_requeue_dead_letters','floriday_settings_change_recompute','floriday_settings_change_recompute_stmt','floriday_stock_change_recompute','floriday_stock_queue_supersede','floriday_takeover_apply','floriday_takeover_fetch_state','floriday_takeover_store_forms','floriday_takeover_undo','fust_negative_stock_report','fust_types_duplicate_guard','get_active_floriday_context','get_group_allocation_keys','get_group_head_key','get_product_stock','get_product_structure_totals','get_product_structure_totals_batch','inventory_inline_budget_ok','merge_products','normalize_order_source','process_inventory_recompute_queue','produce_designed_product','product_active_group_id','product_id_from_ref','product_is_set','product_label','product_member_group_ids','product_own_available','product_packings_derive','product_packings_replace','product_packings_sync_from_floriday','product_primary_pieces','product_set_depth_above','product_set_depth_below','product_structure_ancestors','product_structure_max_depth','product_structure_path','product_tray_stickers_touch','product_type','promote_trade_item_key','recompute_all_reserved_stock','recompute_order_status','recompute_reserved_for_order','recompute_reserved_stock','requeue_skipped_stock_rows','reset_stalled_floriday_stock_queue','resolve_group_allocation','resolve_group_member_stock_key','resolve_product_id_for_item','resolve_stock_trade_item_key','reverse_production','run_floriday_base_supply_process','run_floriday_continuous_stock_sync','run_floriday_follow','run_floriday_stock_queue_process','run_floriday_stock_reconcile','run_logistics_tasks_dispatch','self_heal_floriday_links','set_module_runtime_config_updated_at','set_product_bom_tenant','set_product_stock','set_updated_at_order_fust_bookings','stock_import_cleanup','stock_import_create','stock_import_process_chunk','stock_import_stop','stock_import_undo_chunk','sync_order_item_fusten','sync_products_quantity_from_stock','touch_fust_types_updated_at','trade_item_drafts_readonly','trade_item_prices_touch_updated_at','trade_item_stock_duplicates','trg_cart_numbers_sync_order_status_fn','trg_cart_session_consume_fn','trg_check_product_structure','trg_floriday_cache_relink_fn','trg_floriday_trade_items_autolink_fn','trg_order_items_autolink_fn','trg_order_items_fusten','trg_order_items_reserve_fn','trg_orders_cancel_release_fn','trg_orders_consume_on_complete_fn','trg_orders_default_phase_fn','trg_orders_external_fulfilled_fn','trg_orders_recompute_reserved_fn','trg_pgi_assign_sort_order','trg_pgi_order_taken_check','trg_process_recompute_on_commit','trg_product_packings_derive_fn','trg_products_autolink_fn','trg_products_floriday_link_enqueue','trg_products_seed_stock_fn','trg_requeue_no_warehouse_cache','trg_requeue_no_warehouse_connection','trg_requeue_no_warehouse_item_pref','trg_requeue_skipped_no_price','trg_stock_structure_recompute_ins','trg_stock_structure_recompute_upd','trg_structure_change_recompute','trg_trade_item_drafts_autolink_fn','trg_trade_item_stock_auto_bom','trg_trade_item_stock_auto_bom_reverse','trg_trade_item_stock_log_change','trg_trade_item_stock_reserve_fn','trg_trade_item_stock_zero_watch','trg_trade_items_cache_autolink_fn','update_updated_at_column','voorraad_alert_floriday_not_updated','voorraad_can_write','voorraad_cleanup_old_rows','voorraad_consume_external_fulfilled','voorraad_correctie_1098','voorraad_correctie_status','voorraad_external_fulfilled_ids','voorraad_floriday_leads_key','voorraad_fust_dimensions','voorraad_hook_base_url','voorraad_hook_on','voorraad_hook_post','voorraad_hook_switch_jobs','voorraad_install_check','voorraad_is_server','voorraad_mark_floriday_sold_before_switch','voorraad_production_enabled','voorraad_schema_ddl','voorraad_touch_updated_at','voorraad_vereis','voorraad_week_is_past'];
|
|
8925
8979
|
v_t text[] := ARRAY['trg_voorraad_link_primary_packing@products','aa0_fcsq_local_context_guard@floriday_continuous_stock_queue','aa_fcsq_erp_leading_guard@floriday_continuous_stock_queue','aa_fis_norm_offer_forms@floriday_inventory_settings','aa_pgi_assign_sort_order@product_group_items','fcsq_block_disabled@floriday_continuous_stock_queue','fcsq_wake_base_supply_ins@floriday_continuous_stock_queue','fcsq_wake_base_supply_upd@floriday_continuous_stock_queue','fust_stock_mutations_apply@fust_stock_mutations','fust_types_duplicate_guard@fust_types','fust_types_touch@fust_types','product_packings_derive_trg@product_packings','product_packings_updated_at@product_packings','set_product_bom_tenant_trigger@product_bom_items','trade_item_prices_set_updated_at@trade_item_prices','trg_cart_numbers_sync_order_status@cart_numbers','trg_cart_session_consume@cart_control_sessions','trg_check_product_structure@product_bom_items','trg_check_product_structure@product_group_items','trg_check_product_structure@product_groups','trg_fcs_queue_updated_at@floriday_continuous_stock_queue','trg_fcsq_fallback_supersede@floriday_continuous_stock_queue','trg_fcsq_supersede@floriday_continuous_stock_queue','trg_floriday_cache_relink@floriday_trade_items_cache','trg_floriday_ensure_inventory_settings@products','trg_floriday_gate_stock_queue@floriday_continuous_stock_queue','trg_floriday_settings_change_recompute_ins@floriday_inventory_settings','trg_floriday_settings_change_recompute_upd@floriday_inventory_settings','trg_floriday_stock_change_recompute@trade_item_stock','trg_floriday_takeover_runs_updated_at@floriday_takeover_runs','trg_floriday_trade_items_autolink@floriday_trade_items_cache','trg_fust_types_requeue_blocked@fust_types','trg_module_runtime_config_updated_at@module_runtime_config','trg_order_fust_bookings_updated_at@order_fust_bookings','trg_order_items_autolink@order_items','trg_order_items_fusten_aiud@order_items','trg_order_items_reserve@order_items','trg_orders_cancel_release@orders','trg_orders_consume_on_complete@orders','trg_orders_default_phase@orders','trg_orders_external_fulfilled@orders','trg_orders_recompute_reserved@orders','trg_prevent_duplicate_product_draft@trade_item_drafts','trg_product_tray_stickers_touch@product_tray_stickers','trg_products_autolink@products','trg_products_floriday_link_enqueue@products','trg_products_seed_stock@products','trg_requeue_no_warehouse_cache@floriday_trade_items_cache','trg_requeue_no_warehouse_connection@floriday_connections','trg_requeue_no_warehouse_item_pref@trade_item_warehouse_preferences','trg_requeue_skipped_no_price@products','trg_stock_mutation_alert@stock_mutation_log','trg_stock_structure_recompute_ins@trade_item_stock','trg_stock_structure_recompute_upd@trade_item_stock','trg_structure_change_recompute@product_bom_items','trg_structure_change_recompute@product_group_items','trg_structure_change_recompute@product_groups','trg_sync_layer_stock_from_trade_stock@trade_item_stock','trg_sync_products_quantity_from_stock_del@trade_item_stock','trg_sync_products_quantity_from_stock_iu@trade_item_stock','trg_trade_item_drafts_autolink@trade_item_drafts','trg_trade_item_drafts_readonly@trade_item_drafts','trg_trade_item_stock_canonical_key@trade_item_stock','trg_trade_item_stock_publish@trade_item_stock','trg_trade_item_stock_reserve@trade_item_stock','trg_trade_item_stock_updated_at@trade_item_stock','trg_trade_item_stock_zero_watch@trade_item_stock','trg_trade_item_supply_lines_touch@trade_item_supply_lines','trg_trade_item_warehouse_preference_enqueue_stock@trade_item_warehouse_preferences','trg_trade_items_cache_autolink@floriday_trade_items_cache','trg_voorraad_buffer_state_updated_at@voorraad_buffer_state','trg_voorraad_event_log_updated_at@voorraad_logistics_event_log','update_trade_item_drafts_updated_at@trade_item_drafts','update_trade_item_warehouse_preferences_updated_at@trade_item_warehouse_preferences','update_voorraad_custom_fields_updated_at@voorraad_custom_fields','update_voorraad_publish_jobs_updated_at@voorraad_publish_jobs','update_voorraad_publish_learnings_updated_at@voorraad_publish_learnings','update_voorraad_publish_steps_updated_at@voorraad_publish_steps','voorraad_hook_switch_jobs@module_runtime_config','zz_fcsq_first_positive@floriday_continuous_stock_queue'];
|
|
8926
8980
|
v_p text[] := ARRAY['Authenticated can add learnings@voorraad_publish_learnings','Authenticated can delete voorraad custom fields@voorraad_custom_fields','Authenticated can insert vbn required characteristics@floriday_vbn_required_characteristics','Authenticated can insert voorraad custom fields@voorraad_custom_fields','Authenticated can read continuous stock cache@floriday_continuous_stock_cache','Authenticated can read learnings@voorraad_publish_learnings','Authenticated can read vbn required characteristics@floriday_vbn_required_characteristics','Authenticated can read voorraad custom fields@voorraad_custom_fields','Authenticated can update learnings@voorraad_publish_learnings','Authenticated can update vbn required characteristics@floriday_vbn_required_characteristics','Authenticated can update voorraad custom fields@voorraad_custom_fields','Authenticated delete trade_item_warehouse_preferences@trade_item_warehouse_preferences','Authenticated insert trade_item_warehouse_preferences@trade_item_warehouse_preferences','Authenticated select trade_item_warehouse_preferences@trade_item_warehouse_preferences','Authenticated update trade_item_warehouse_preferences@trade_item_warehouse_preferences','Eigen momentopnamen lezen@inventory_stock_snapshots','Eigen voorraadinstellingen beheren@floriday_inventory_settings','Eigenaar leest importporties@stock_import_chunks','Eigenaar leest importregels@stock_import_rows','Fust mutations delete@fust_stock_mutations','Fust mutations insert@fust_stock_mutations','Fust mutations read@fust_stock_mutations','Fust mutations update@fust_stock_mutations','Fust types delete@fust_types','Fust types insert@fust_types','Fust types read@fust_types','Fust types update@fust_types','Ingelogde gebruikers kunnen bufferstatus lezen@voorraad_buffer_state','Ingelogde gebruikers kunnen de eventlog lezen@voorraad_logistics_event_log','Ingelogde gebruikers kunnen fustboekingen lezen@order_fust_bookings','Ingelogde gebruikers lezen drempels@inventory_recompute_limits','Ingelogde gebruikers lezen opruimlogboek@structure_cleanup_log','Ingelogde gebruikers lezen opruimruns@floriday_queue_cleanup_runs','Ingelogden beheren traystickers@product_tray_stickers','Ingelogden lezen herberekenwachtrij@inventory_recompute_queue','Ingelogden lezen voorraadmeldingen@stock_integrity_alerts','Ingelogden markeren voorraadmeldingen als gezien@stock_integrity_alerts','Own queue rows select@floriday_continuous_stock_queue','Owner delete trade_item_drafts@trade_item_drafts','Owner insert trade_item_drafts@trade_item_drafts','Owner select trade_item_drafts@trade_item_drafts','Owner update trade_item_drafts@trade_item_drafts','Signed-in users read reconcile runs@floriday_reconcile_runs','Stock delete@trade_item_stock','Stock insert@trade_item_stock','Stock read@trade_item_stock','Stock update@trade_item_stock','Synchronisatieposities lezen@floriday_sync_cursors','Users can insert own publish attempts@voorraad_publish_attempts','Users can read own publish attempts@voorraad_publish_attempts','Users can read own stock mutations@stock_mutation_log','Users manage own import runs@stock_import_runs','Users manage own supply lines@trade_item_supply_lines','Users manage own trade item prices@trade_item_prices','Users manage their own publish jobs@voorraad_publish_jobs','Users manage their own publish steps@voorraad_publish_steps','Verwerkte orders lezen@floriday_sales_order_ingest','Voorraadschrijvers lezen overnameregels@floriday_takeover_items','Voorraadschrijvers lezen overnames@floriday_takeover_runs','authenticated can insert merge log@product_merge_log','authenticated can read merge log@product_merge_log','service role only@voorraad_media_upload_failures','product_packings_read@product_packings','product_packings_write@product_packings'];
|
|
8927
8981
|
v_open text[] := ARRAY['voorraad_is_server','voorraad_vereis'];
|
|
@@ -8949,7 +9003,7 @@ BEGIN
|
|
|
8949
9003
|
SELECT jsonb_agg(jsonb_build_object('policy', split_part(t, '@', 1), 'tabel', split_part(t, '@', 2),
|
|
8950
9004
|
'aanwezig', EXISTS (SELECT 1 FROM pg_policies x WHERE x.schemaname = 'public' AND x.policyname = split_part(t, '@', 1)
|
|
8951
9005
|
AND x.tablename = split_part(t, '@', 2))) ORDER BY t) INTO v_pol FROM unnest(v_p) t;
|
|
8952
|
-
RETURN jsonb_build_object(
|
|
9006
|
+
RETURN jsonb_build_object('gateway_routes', public.voorraad_gateway_routes_check(),
|
|
8953
9007
|
'samenvatting', jsonb_build_object(
|
|
8954
9008
|
'functies', jsonb_array_length(v_func),
|
|
8955
9009
|
'functies_ontbrekend', (SELECT count(*) FROM jsonb_array_elements(v_func) e WHERE NOT (e->>'aanwezig')::boolean),
|
|
@@ -9110,6 +9164,29 @@ REVOKE ALL ON FUNCTION voorraad_packing_missing(jsonb) FROM PUBLIC;
|
|
|
9110
9164
|
REVOKE ALL ON FUNCTION voorraad_packing_missing(jsonb) FROM anon;
|
|
9111
9165
|
GRANT EXECUTE ON FUNCTION voorraad_packing_missing(jsonb) TO authenticated;
|
|
9112
9166
|
GRANT EXECUTE ON FUNCTION voorraad_packing_missing(jsonb) TO service_role;
|
|
9167
|
+
CREATE OR REPLACE FUNCTION public.voorraad_placeholder_code_reason(p_code text, p_name text)
|
|
9168
|
+
RETURNS text
|
|
9169
|
+
LANGUAGE plpgsql
|
|
9170
|
+
STABLE
|
|
9171
|
+
SET search_path TO 'public'
|
|
9172
|
+
AS $function$
|
|
9173
|
+
DECLARE v text := lower(btrim(coalesce(p_code, '')));
|
|
9174
|
+
BEGIN
|
|
9175
|
+
PERFORM public.voorraad_vereis('ingelogd', 'voorraad_placeholder_code_reason');
|
|
9176
|
+
IF v = '' THEN RETURN 'De artikelcode is leeg.'; END IF;
|
|
9177
|
+
IF EXISTS (SELECT 1 FROM public.voorraad_placeholder_codes c WHERE c.code = v) THEN
|
|
9178
|
+
RETURN format('"%s" is een invultekst, geen artikelcode.', btrim(p_code));
|
|
9179
|
+
END IF;
|
|
9180
|
+
IF p_name IS NOT NULL AND v = lower(btrim(p_name)) THEN
|
|
9181
|
+
RETURN 'De artikelcode is gelijk aan de artikelnaam.';
|
|
9182
|
+
END IF;
|
|
9183
|
+
RETURN NULL;
|
|
9184
|
+
END $function$
|
|
9185
|
+
;
|
|
9186
|
+
REVOKE ALL ON FUNCTION voorraad_placeholder_code_reason(text,text) FROM PUBLIC;
|
|
9187
|
+
REVOKE ALL ON FUNCTION voorraad_placeholder_code_reason(text,text) FROM anon;
|
|
9188
|
+
GRANT EXECUTE ON FUNCTION voorraad_placeholder_code_reason(text,text) TO authenticated;
|
|
9189
|
+
GRANT EXECUTE ON FUNCTION voorraad_placeholder_code_reason(text,text) TO service_role;
|
|
9113
9190
|
CREATE OR REPLACE FUNCTION public.voorraad_production_enabled()
|
|
9114
9191
|
RETURNS boolean
|
|
9115
9192
|
LANGUAGE sql
|
|
@@ -9506,6 +9583,7 @@ DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraa
|
|
|
9506
9583
|
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_local_context_pkey' AND conrelid = 'public.voorraad_local_context'::regclass) THEN ALTER TABLE public.voorraad_local_context ADD CONSTRAINT voorraad_local_context_pkey PRIMARY KEY (id); END IF; END $c$;
|
|
9507
9584
|
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_logistics_event_log_pkey' AND conrelid = 'public.voorraad_logistics_event_log'::regclass) THEN ALTER TABLE public.voorraad_logistics_event_log ADD CONSTRAINT voorraad_logistics_event_log_pkey PRIMARY KEY (event_id); END IF; END $c$;
|
|
9508
9585
|
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_media_upload_failures_pkey' AND conrelid = 'public.voorraad_media_upload_failures'::regclass) THEN ALTER TABLE public.voorraad_media_upload_failures ADD CONSTRAINT voorraad_media_upload_failures_pkey PRIMARY KEY (id); END IF; END $c$;
|
|
9586
|
+
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_placeholder_codes_pkey' AND conrelid = 'public.voorraad_placeholder_codes'::regclass) THEN ALTER TABLE public.voorraad_placeholder_codes ADD CONSTRAINT voorraad_placeholder_codes_pkey PRIMARY KEY (code); END IF; END $c$;
|
|
9509
9587
|
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_publish_attempts_pkey' AND conrelid = 'public.voorraad_publish_attempts'::regclass) THEN ALTER TABLE public.voorraad_publish_attempts ADD CONSTRAINT voorraad_publish_attempts_pkey PRIMARY KEY (id); END IF; END $c$;
|
|
9510
9588
|
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_publish_jobs_pkey' AND conrelid = 'public.voorraad_publish_jobs'::regclass) THEN ALTER TABLE public.voorraad_publish_jobs ADD CONSTRAINT voorraad_publish_jobs_pkey PRIMARY KEY (id); END IF; END $c$;
|
|
9511
9589
|
DO $c$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'voorraad_publish_learnings_pkey' AND conrelid = 'public.voorraad_publish_learnings'::regclass) THEN ALTER TABLE public.voorraad_publish_learnings ADD CONSTRAINT voorraad_publish_learnings_pkey PRIMARY KEY (id); END IF; END $c$;
|
|
@@ -9772,6 +9850,10 @@ ALTER TABLE public.voorraad_media_upload_failures ENABLE ROW LEVEL SECURITY;
|
|
|
9772
9850
|
REVOKE ALL ON public.voorraad_media_upload_failures FROM anon;
|
|
9773
9851
|
GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON public.voorraad_media_upload_failures TO authenticated;
|
|
9774
9852
|
GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON public.voorraad_media_upload_failures TO service_role;
|
|
9853
|
+
ALTER TABLE public.voorraad_placeholder_codes ENABLE ROW LEVEL SECURITY;
|
|
9854
|
+
REVOKE ALL ON public.voorraad_placeholder_codes FROM anon;
|
|
9855
|
+
GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON public.voorraad_placeholder_codes TO authenticated;
|
|
9856
|
+
GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON public.voorraad_placeholder_codes TO service_role;
|
|
9775
9857
|
ALTER TABLE public.voorraad_publish_attempts ENABLE ROW LEVEL SECURITY;
|
|
9776
9858
|
REVOKE ALL ON public.voorraad_publish_attempts FROM anon;
|
|
9777
9859
|
GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON public.voorraad_publish_attempts TO authenticated;
|
|
@@ -9912,6 +9994,8 @@ DROP POLICY IF EXISTS "Ingelogde gebruikers kunnen de eventlog lezen" ON public.
|
|
|
9912
9994
|
CREATE POLICY "Ingelogde gebruikers kunnen de eventlog lezen" ON public.voorraad_logistics_event_log AS PERMISSIVE FOR SELECT TO authenticated USING (true);
|
|
9913
9995
|
DROP POLICY IF EXISTS "service role only" ON public.voorraad_media_upload_failures;
|
|
9914
9996
|
CREATE POLICY "service role only" ON public.voorraad_media_upload_failures AS PERMISSIVE FOR ALL TO service_role USING (true) WITH CHECK (true);
|
|
9997
|
+
DROP POLICY IF EXISTS "Ingelogd mag invulteksten lezen" ON public.voorraad_placeholder_codes;
|
|
9998
|
+
CREATE POLICY "Ingelogd mag invulteksten lezen" ON public.voorraad_placeholder_codes AS PERMISSIVE FOR SELECT TO authenticated USING (true);
|
|
9915
9999
|
DROP POLICY IF EXISTS "Users can insert own publish attempts" ON public.voorraad_publish_attempts;
|
|
9916
10000
|
CREATE POLICY "Users can insert own publish attempts" ON public.voorraad_publish_attempts AS PERMISSIVE FOR INSERT TO authenticated WITH CHECK ((auth.uid() = user_id));
|
|
9917
10001
|
DROP POLICY IF EXISTS "Users can read own publish attempts" ON public.voorraad_publish_attempts;
|
|
@@ -10004,6 +10088,7 @@ CREATE TRIGGER trg_product_tray_stickers_touch BEFORE UPDATE ON public.product_t
|
|
|
10004
10088
|
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_floriday_ensure_inventory_settings AFTER INSERT ON public.products FOR EACH ROW EXECUTE FUNCTION floriday_ensure_inventory_settings()$q$; END IF; END $g$;
|
|
10005
10089
|
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_products_autolink BEFORE INSERT OR UPDATE OF product, trade_item_key ON public.products FOR EACH ROW EXECUTE FUNCTION trg_products_autolink_fn()$q$; END IF; END $g$;
|
|
10006
10090
|
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_products_floriday_link_enqueue AFTER UPDATE ON public.products REFERENCING OLD TABLE AS old_rows NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION trg_products_floriday_link_enqueue()$q$; END IF; END $g$;
|
|
10091
|
+
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_products_placeholder_code BEFORE INSERT OR UPDATE OF article_number ON public.products FOR EACH ROW EXECUTE FUNCTION trg_products_placeholder_code()$q$; END IF; END $g$;
|
|
10007
10092
|
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_products_seed_stock AFTER INSERT OR UPDATE OF trade_item_key ON public.products FOR EACH ROW EXECUTE FUNCTION trg_products_seed_stock_fn()$q$; END IF; END $g$;
|
|
10008
10093
|
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_requeue_skipped_no_price AFTER UPDATE OF sale_price, unit ON public.products FOR EACH ROW EXECUTE FUNCTION trg_requeue_skipped_no_price()$q$; END IF; END $g$;
|
|
10009
10094
|
DO $g$ BEGIN IF to_regclass('public.products') IS NULL THEN RAISE NOTICE 'Voorraad: products (core) ontbreekt, triggers overgeslagen; draai de schema-update opnieuw na die module'; ELSE EXECUTE $q$CREATE TRIGGER trg_voorraad_link_primary_packing AFTER INSERT OR UPDATE OF floriday_trade_item_id ON public.products FOR EACH ROW EXECUTE FUNCTION trg_voorraad_link_primary_packing()$q$; END IF; END $g$;
|