@flowselections/floriday-authenticatie-module 1.0.17 → 1.0.19
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/FlorydayConnectionPage.d.ts.map +1 -1
- package/dist-lib/components/floriday/FlorydayConnectionPage.js +2 -1
- package/dist-lib/components/settings/FloricodeSettingsCard.d.ts +2 -0
- package/dist-lib/components/settings/FloricodeSettingsCard.d.ts.map +1 -0
- package/dist-lib/components/settings/FloricodeSettingsCard.js +235 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +2 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +524 -4
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +524 -4
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +524 -4
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +532 -4
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/floricode-credentials.server.d.ts +21 -0
- package/dist-lib/lib/floricode-credentials.server.d.ts.map +1 -0
- package/dist-lib/lib/floricode-credentials.server.js +158 -0
- package/dist-lib/lib/floricode-product-features.d.ts.map +1 -1
- package/dist-lib/lib/floricode-product-features.js +19 -33
- package/dist-lib/lib/floricode-regulatory-features.d.ts.map +1 -1
- package/dist-lib/lib/floricode-regulatory-features.js +51 -41
- package/dist-lib/lib/floricode-sync.server.d.ts +35 -0
- package/dist-lib/lib/floricode-sync.server.d.ts.map +1 -0
- package/dist-lib/lib/floricode-sync.server.js +211 -0
- package/dist-lib/lib/floricode.functions.d.ts +78828 -0
- package/dist-lib/lib/floricode.functions.d.ts.map +1 -0
- package/dist-lib/lib/floricode.functions.js +178 -0
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts +524 -4
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-auto-process.server.d.ts +34 -0
- package/dist-lib/lib/floriday-auto-process.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-process.server.js +365 -0
- package/dist-lib/lib/floriday-fulfillment-lookup.server.d.ts +19 -0
- package/dist-lib/lib/floriday-fulfillment-lookup.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-fulfillment-lookup.server.js +130 -0
- package/dist-lib/lib/floriday-gateway-auth.d.ts +24 -0
- package/dist-lib/lib/floriday-gateway-auth.d.ts.map +1 -0
- package/dist-lib/lib/floriday-gateway-auth.js +127 -0
- package/dist-lib/lib/floriday-labels.functions.d.ts +524 -4
- package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-labels.functions.js +3 -2
- package/dist-lib/lib/floriday-public.functions.d.ts +3144 -24
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-rate-limit.server.d.ts +21 -0
- package/dist-lib/lib/floriday-rate-limit.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-rate-limit.server.js +75 -0
- package/dist-lib/lib/floriday-stickers.functions.d.ts +524 -4
- package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.functions.d.ts +17292 -132
- package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +3192 -48
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.js +29 -4
- package/dist-lib/lib/floriday.functions.d.ts +9576 -198
- package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.js +39 -4
- package/dist-lib/lib/planning-helpers.d.ts +30 -0
- package/dist-lib/lib/planning-helpers.d.ts.map +1 -0
- package/dist-lib/lib/planning-helpers.js +62 -0
- package/package.json +3 -2
- package/public/flowselections-assets/floriday-authenticatie/floricode-logo.png +0 -0
|
@@ -305,7 +305,7 @@ export async function florydayFetch(supabase, pathOrEnv, pathOrInit, maybeInit =
|
|
|
305
305
|
}
|
|
306
306
|
throw new Error(`Floriday API 401 na vernieuwen van de verbinding. Body: ${body.slice(0, 300)}`);
|
|
307
307
|
}
|
|
308
|
-
|
|
308
|
+
return res;
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
return res;
|
|
@@ -1002,6 +1002,17 @@ export const reinstallFlorydayCrons = createServerFn({ method: "POST" })
|
|
|
1002
1002
|
const conn = await scheduleFlorydayConnectionsSyncInternal(context.supabase);
|
|
1003
1003
|
return { ok: true, token, connections: conn };
|
|
1004
1004
|
});
|
|
1005
|
+
function redactHeadersForWriteLog(headers) {
|
|
1006
|
+
const out = {};
|
|
1007
|
+
const entries = headers instanceof Headers ? Array.from(headers.entries()) : Object.entries(headers);
|
|
1008
|
+
for (const [key, value] of entries) {
|
|
1009
|
+
const lower = key.toLowerCase();
|
|
1010
|
+
out[key] = lower === "authorization" || lower === "x-api-key" || lower === "apikey"
|
|
1011
|
+
? (value ? `${value.slice(0, 10)}…${value.slice(-4)}` : "")
|
|
1012
|
+
: value;
|
|
1013
|
+
}
|
|
1014
|
+
return out;
|
|
1015
|
+
}
|
|
1005
1016
|
async function hashIdempotencyKey(input) {
|
|
1006
1017
|
// Web-Crypto is beschikbaar in de Worker-runtime; geen Node-crypto nodig.
|
|
1007
1018
|
const bytes = new TextEncoder().encode(input);
|
|
@@ -1045,10 +1056,13 @@ export async function florydayWrite(supabase, env, opts) {
|
|
|
1045
1056
|
.eq("idempotency_key", idemKey)
|
|
1046
1057
|
.maybeSingle();
|
|
1047
1058
|
if (existing) {
|
|
1059
|
+
const existingResponse = existing.response;
|
|
1048
1060
|
return {
|
|
1049
1061
|
ok: Boolean(existing.ok),
|
|
1050
1062
|
status: Number(existing.http_status ?? 0),
|
|
1051
|
-
data:
|
|
1063
|
+
data: existingResponse && typeof existingResponse === "object" && "body" in existingResponse
|
|
1064
|
+
? existingResponse.body
|
|
1065
|
+
: existingResponse ?? null,
|
|
1052
1066
|
attemptId: existing.id ?? null,
|
|
1053
1067
|
error: existing.error ?? undefined,
|
|
1054
1068
|
};
|
|
@@ -1090,8 +1104,28 @@ export async function florydayWrite(supabase, env, opts) {
|
|
|
1090
1104
|
"Content-Type": "application/json",
|
|
1091
1105
|
"Idempotency-Key": idemKey,
|
|
1092
1106
|
};
|
|
1107
|
+
const requestLog = {
|
|
1108
|
+
endpoint: `/${SUPPLIERS_API_VERSION}${opts.path.startsWith("/") ? "" : "/"}${opts.path}`,
|
|
1109
|
+
method: opts.method,
|
|
1110
|
+
path: opts.path,
|
|
1111
|
+
environment: env,
|
|
1112
|
+
connectionId: conn.id,
|
|
1113
|
+
tenant: {
|
|
1114
|
+
organizationName: conn.organization_name ?? null,
|
|
1115
|
+
gln: conn.gln_code ?? null,
|
|
1116
|
+
preferredWarehouseId: conn.preferred_warehouse_id ?? null,
|
|
1117
|
+
},
|
|
1118
|
+
scope: getFlorydayScopeForPath(opts.path, opts.method),
|
|
1119
|
+
headers: redactHeadersForWriteLog({
|
|
1120
|
+
...headers,
|
|
1121
|
+
Authorization: "Bearer <auth-module-managed>",
|
|
1122
|
+
"X-Api-Key": conn.api_key ? "<configured>" : "<missing>",
|
|
1123
|
+
}),
|
|
1124
|
+
body: opts.body ?? null,
|
|
1125
|
+
};
|
|
1093
1126
|
let status = 0;
|
|
1094
1127
|
let parsed = null;
|
|
1128
|
+
let responseLog = null;
|
|
1095
1129
|
let text = "";
|
|
1096
1130
|
let ok = false;
|
|
1097
1131
|
let errMsg;
|
|
@@ -1104,6 +1138,7 @@ export async function florydayWrite(supabase, env, opts) {
|
|
|
1104
1138
|
status = res.status;
|
|
1105
1139
|
text = await res.text().catch(() => "");
|
|
1106
1140
|
parsed = text ? safeJson(text) : null;
|
|
1141
|
+
responseLog = { body: parsed, headers: redactHeadersForWriteLog(res.headers) };
|
|
1107
1142
|
ok = res.ok;
|
|
1108
1143
|
if (!ok)
|
|
1109
1144
|
errMsg = `Floriday ${status}: ${text.slice(0, 300)}`;
|
|
@@ -1119,8 +1154,8 @@ export async function florydayWrite(supabase, env, opts) {
|
|
|
1119
1154
|
action: opts.action,
|
|
1120
1155
|
resource: opts.module,
|
|
1121
1156
|
floriday_id: opts.referenceId ?? null,
|
|
1122
|
-
request:
|
|
1123
|
-
response:
|
|
1157
|
+
request: requestLog,
|
|
1158
|
+
response: responseLog,
|
|
1124
1159
|
http_status: status,
|
|
1125
1160
|
ok,
|
|
1126
1161
|
error: errMsg ?? null,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface AutoProcessInput {
|
|
2
|
+
/** Delivery-date van de sales order (ISO of Date). */
|
|
3
|
+
deliveryDate: string | Date;
|
|
4
|
+
/** Aantal werkdagen vóór levering waarop uiterlijk gepickt moet zijn. */
|
|
5
|
+
maxWorkdaysEarlierPick: number;
|
|
6
|
+
/** Toegestane pickdagen (0=zo, 1=ma, ..., 6=za). */
|
|
7
|
+
pickWeekdays: number[];
|
|
8
|
+
/** Extra werkdagen als er stickers meegenomen moeten worden. */
|
|
9
|
+
extraStickerDaysWithStickers?: number;
|
|
10
|
+
/** Deze order heeft stickers nodig? */
|
|
11
|
+
requiresStickers?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Bereken het moment waarop een order door de auto-flow moet gaan.
|
|
15
|
+
*
|
|
16
|
+
* Regels:
|
|
17
|
+
* 1. Start bij deliveryDate.
|
|
18
|
+
* 2. Trek `maxWorkdaysEarlierPick` (+ extra sticker-dagen) werkdagen af.
|
|
19
|
+
* 3. Verschuif naar de dichtstbijzijnde eerdere toegestane pickdag.
|
|
20
|
+
*
|
|
21
|
+
* Als er geen enkele pickdag past vóór `deliveryDate` (bv. spoedorder), krijgt
|
|
22
|
+
* de caller `null` terug + `reason: "outside_pickday"`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function computeAutoProcessDate(input: AutoProcessInput): {
|
|
25
|
+
moment: Date | null;
|
|
26
|
+
reason?: "outside_pickday";
|
|
27
|
+
};
|
|
28
|
+
/** Handig voor cron-scan: is vandaag een toegestane pickdag? */
|
|
29
|
+
export declare function isPickdayToday(pickWeekdays: number[], now?: Date): boolean;
|
|
30
|
+
//# sourceMappingURL=planning-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/planning-helpers.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,yEAAyE;IACzE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,oDAAoD;IACpD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gEAAgE;IAChE,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,gBAAgB,GAAG;IAC/D,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B,CAyBA;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAGtF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Planning-helpers voor auto-fulfillment.
|
|
3
|
+
// ----------------------------------------------------------------------------
|
|
4
|
+
// Kopie van de logica uit de Afhandeling-module, zodat de Authenticatie-module
|
|
5
|
+
// server-side hetzelfde `autoProcessMoment` kan berekenen als de UI daar.
|
|
6
|
+
// ============================================================================
|
|
7
|
+
function toDate(d) {
|
|
8
|
+
return d instanceof Date ? new Date(d.getTime()) : new Date(d);
|
|
9
|
+
}
|
|
10
|
+
function isWorkday(d) {
|
|
11
|
+
const wd = d.getDay();
|
|
12
|
+
return wd !== 0 && wd !== 6;
|
|
13
|
+
}
|
|
14
|
+
function subtractWorkdays(from, workdays) {
|
|
15
|
+
const out = new Date(from.getTime());
|
|
16
|
+
let remaining = workdays;
|
|
17
|
+
while (remaining > 0) {
|
|
18
|
+
out.setDate(out.getDate() - 1);
|
|
19
|
+
if (isWorkday(out))
|
|
20
|
+
remaining--;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Bereken het moment waarop een order door de auto-flow moet gaan.
|
|
26
|
+
*
|
|
27
|
+
* Regels:
|
|
28
|
+
* 1. Start bij deliveryDate.
|
|
29
|
+
* 2. Trek `maxWorkdaysEarlierPick` (+ extra sticker-dagen) werkdagen af.
|
|
30
|
+
* 3. Verschuif naar de dichtstbijzijnde eerdere toegestane pickdag.
|
|
31
|
+
*
|
|
32
|
+
* Als er geen enkele pickdag past vóór `deliveryDate` (bv. spoedorder), krijgt
|
|
33
|
+
* de caller `null` terug + `reason: "outside_pickday"`.
|
|
34
|
+
*/
|
|
35
|
+
export function computeAutoProcessDate(input) {
|
|
36
|
+
const delivery = toDate(input.deliveryDate);
|
|
37
|
+
if (Number.isNaN(delivery.getTime()))
|
|
38
|
+
return { moment: null };
|
|
39
|
+
const extraDays = input.requiresStickers && input.extraStickerDaysWithStickers
|
|
40
|
+
? input.extraStickerDaysWithStickers
|
|
41
|
+
: 0;
|
|
42
|
+
let cursor = subtractWorkdays(delivery, input.maxWorkdaysEarlierPick + extraDays);
|
|
43
|
+
const allowed = new Set(input.pickWeekdays);
|
|
44
|
+
if (allowed.size === 0) {
|
|
45
|
+
// Geen pickdagen geconfigureerd → val terug op berekende datum.
|
|
46
|
+
return { moment: cursor };
|
|
47
|
+
}
|
|
48
|
+
// Zoek de dichtstbijzijnde eerdere pickdag (max 14 dagen terug).
|
|
49
|
+
for (let i = 0; i < 14; i++) {
|
|
50
|
+
if (allowed.has(cursor.getDay()))
|
|
51
|
+
return { moment: cursor };
|
|
52
|
+
cursor = new Date(cursor.getTime() - 24 * 60 * 60 * 1000);
|
|
53
|
+
}
|
|
54
|
+
// Geen pickdag gevonden binnen 2 weken → spoedorder, laat auto-flow toch draaien.
|
|
55
|
+
return { moment: new Date(), reason: "outside_pickday" };
|
|
56
|
+
}
|
|
57
|
+
/** Handig voor cron-scan: is vandaag een toegestane pickdag? */
|
|
58
|
+
export function isPickdayToday(pickWeekdays, now = new Date()) {
|
|
59
|
+
if (pickWeekdays.length === 0)
|
|
60
|
+
return true;
|
|
61
|
+
return pickWeekdays.includes(now.getDay());
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowselections/floriday-authenticatie-module",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-lib/index.js",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"@flowselections/core": "*"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@supabase/supabase-js": "^2.105.4"
|
|
36
|
+
"@supabase/supabase-js": "^2.105.4",
|
|
37
|
+
"pdf-lib": "^1.17.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@flowselections/core": "^1.0.11",
|