@flowselections/logistiek-engine 1.0.13 → 1.0.14

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.
Files changed (37) hide show
  1. package/dist-lib/components/FloridayPushCard.d.ts.map +1 -1
  2. package/dist-lib/components/FloridayPushCard.js +7 -2
  3. package/dist-lib/components/PrintjobsCard.d.ts.map +1 -1
  4. package/dist-lib/components/PrintjobsCard.js +3 -1
  5. package/dist-lib/hooks/useFloridayPushes.d.ts +7 -0
  6. package/dist-lib/hooks/useFloridayPushes.d.ts.map +1 -1
  7. package/dist-lib/hooks/useFloridayPushes.js +11 -0
  8. package/dist-lib/hooks/usePrintjobs.d.ts +1 -0
  9. package/dist-lib/hooks/usePrintjobs.d.ts.map +1 -1
  10. package/dist-lib/hooks/usePrintjobs.js +17 -1
  11. package/dist-lib/integrations/supabase/auth-middleware.d.ts +283 -0
  12. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  13. package/dist-lib/integrations/supabase/client.server.d.ts +283 -0
  14. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  15. package/dist-lib/integrations/supabase/moduleClient.d.ts +283 -0
  16. package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
  17. package/dist-lib/integrations/supabase/previewAuthStorage.d.ts +6 -0
  18. package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -0
  19. package/dist-lib/integrations/supabase/previewAuthStorage.js +92 -0
  20. package/dist-lib/integrations/supabase/types.d.ts +290 -0
  21. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  22. package/dist-lib/lib/floridayDocuments.functions.d.ts +849 -0
  23. package/dist-lib/lib/floridayDocuments.functions.d.ts.map +1 -1
  24. package/dist-lib/lib/floridayPush.functions.d.ts +283 -0
  25. package/dist-lib/lib/floridayPush.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/floridayPush.server.d.ts +12 -0
  27. package/dist-lib/lib/floridayPush.server.d.ts.map +1 -1
  28. package/dist-lib/lib/floridayPush.server.js +41 -9
  29. package/dist-lib/lib/loadCarrierPlanning.functions.d.ts +1415 -0
  30. package/dist-lib/lib/loadCarrierPlanning.functions.d.ts.map +1 -1
  31. package/dist-lib/lib/logisticsRecalcJob.functions.d.ts +566 -0
  32. package/dist-lib/lib/logisticsRecalcJob.functions.d.ts.map +1 -1
  33. package/dist-lib/lib/logisticsRecalculate.functions.d.ts +283 -0
  34. package/dist-lib/lib/logisticsRecalculate.functions.d.ts.map +1 -1
  35. package/dist-lib/lib/modulePrompts.d.ts.map +1 -1
  36. package/dist-lib/lib/modulePrompts.js +39 -0
  37. package/package.json +1 -1
@@ -209,7 +209,16 @@ function gatewayErrorCode(status, payloadOk) {
209
209
  export async function runFloridayPushQueue(sb, opts = {}) {
210
210
  const limit = opts.limit ?? FLORIDAY_PUSH_BATCH;
211
211
  const deadlineAt = opts.deadlineAt ?? Date.now() + 10000;
212
- const out = { claimed: 0, sent: 0, skipped: 0, failed: 0, retried: 0 };
212
+ const out = {
213
+ claimed: 0,
214
+ sent: 0,
215
+ skipped: 0,
216
+ failed: 0,
217
+ retried: 0,
218
+ alreadyFulfilled: 0,
219
+ notApplicable: 0,
220
+ unknown: 0,
221
+ };
213
222
  let claimed = [];
214
223
  try {
215
224
  const { data } = await sb.rpc("logistics_floriday_claim_pushes", {
@@ -233,7 +242,7 @@ export async function runFloridayPushQueue(sb, opts = {}) {
233
242
  const revision = Number(item["revision"] ?? 0);
234
243
  const orderRef = String(item["order_ref"] ?? "");
235
244
  const lastSentHash = item["last_sent_hash"] ?? null;
236
- let ok = false;
245
+ let outcome = "error";
237
246
  let permanent = false;
238
247
  let error = null;
239
248
  let sentHash = null;
@@ -246,14 +255,16 @@ export async function runFloridayPushQueue(sb, opts = {}) {
246
255
  if (!built.ok) {
247
256
  // Wachttoestand (delivery-order nog niet gesynchroniseerd) of een
248
257
  // databasefout; permanent alleen als de order zelf niet kan bestaan.
249
- ok = false;
258
+ // order_missing / sales_order_missing worden in de database vertaald
259
+ // naar de eindstatus not_applicable.
260
+ outcome = "error";
250
261
  permanent = built.permanent;
251
262
  error = built.error;
252
263
  errorCode = built.code;
253
264
  }
254
265
  else if (built.hash === lastSentHash) {
255
266
  // Identieke stand: niets versturen, wel als geslaagd afronden.
256
- ok = true;
267
+ outcome = "ok";
257
268
  sentHash = built.hash;
258
269
  out.skipped++;
259
270
  }
@@ -268,7 +279,16 @@ export async function runFloridayPushQueue(sb, opts = {}) {
268
279
  }
269
280
  const payloadOk = payload?.ok ?? res?.ok;
270
281
  const payloadError = payload?.error ?? res?.error;
271
- ok = payloadOk === true;
282
+ // TODO(already_fulfilled): zodra de auth-module (@flowselections/
283
+ // floriday-authenticatie-module) de uitkomst "al afgehandeld" publiceert,
284
+ // hier de herkenning inbouwen op basis van het gepubliceerde veld —
285
+ // NIET op tekstmatching van last_error. Zet dan:
286
+ // outcome = "already_fulfilled"; sentHash = built.hash;
287
+ // errorCode = "already_fulfilled";
288
+ // Het veld is nog niet vastgesteld: in de nu beschikbare gatewayversie
289
+ // bestaat de code "already_fulfilled" niet. Tot die tijd blijft dit pad
290
+ // ongebruikt; de statuswaarde is verder overal al doorgevoerd.
291
+ outcome = payloadOk === true ? "ok" : "error";
272
292
  sentHash = built.hash;
273
293
  fulfillmentOrderId = payload?.fulfillmentOrderId ?? null;
274
294
  response = {
@@ -276,7 +296,7 @@ export async function runFloridayPushQueue(sb, opts = {}) {
276
296
  error: payloadError ?? null,
277
297
  fulfillmentOrderId: payload?.fulfillmentOrderId ?? null,
278
298
  };
279
- if (!ok) {
299
+ if (outcome !== "ok") {
280
300
  error =
281
301
  payloadError && String(payloadError).length > 0
282
302
  ? String(payloadError)
@@ -287,15 +307,16 @@ export async function runFloridayPushQueue(sb, opts = {}) {
287
307
  }
288
308
  }
289
309
  catch (e) {
310
+ outcome = "error";
290
311
  error = String(e?.message ?? e);
291
312
  errorCode = errorCode ?? "unknown";
292
313
  permanent = isPermanent(null, error);
293
314
  }
294
315
  try {
295
- const { data: outcome } = await sb.rpc("logistics_floriday_finish_push_v2", {
316
+ const { data: finished } = await sb.rpc("logistics_floriday_finish_push_v3", {
296
317
  _id: id,
297
318
  _revision: revision,
298
- _ok: ok,
319
+ _outcome: outcome,
299
320
  _error: error,
300
321
  _fulfillment_order_id: fulfillmentOrderId,
301
322
  _sent_hash: sentHash,
@@ -304,13 +325,24 @@ export async function runFloridayPushQueue(sb, opts = {}) {
304
325
  _error_code: errorCode,
305
326
  _response: response,
306
327
  });
307
- const status = String(outcome ?? "");
328
+ const status = String(finished ?? "");
308
329
  if (status === "sent")
309
330
  out.sent++;
310
331
  else if (status === "failed")
311
332
  out.failed++;
312
333
  else if (status === "pending")
313
334
  out.retried++;
335
+ else if (status === "already_fulfilled")
336
+ out.alreadyFulfilled++;
337
+ else if (status === "not_applicable")
338
+ out.notApplicable++;
339
+ else if (status === "superseded" || status === "missing") {
340
+ // Rij is intussen opnieuw in de wachtrij gezet of verwijderd; geen teller.
341
+ }
342
+ else {
343
+ out.unknown++;
344
+ console.warn(`[floridayPush] onbekende afrondstatus '${status}' voor order ${orderRef}`);
345
+ }
314
346
  }
315
347
  catch {
316
348
  // Lease loopt vanzelf af; de volgende tick pakt de rij opnieuw op.