@flowselections/floriday-authenticatie-module 1.0.20 → 1.0.21
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/settings/FlorydaySettingsCard.js +0 -3
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +976 -179
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +976 -179
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +976 -179
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +994 -170
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/floricode.functions.d.ts +6833 -1254
- package/dist-lib/lib/floricode.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts +976 -179
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-labels.functions.d.ts +976 -179
- package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-public.functions.d.ts +5852 -1070
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-scopes.d.ts +0 -8
- package/dist-lib/lib/floriday-scopes.d.ts.map +1 -1
- package/dist-lib/lib/floriday-scopes.js +4 -28
- package/dist-lib/lib/floriday-stickers.functions.d.ts +976 -179
- package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.functions.d.ts +30431 -28430
- package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.functions.js +62 -145
- package/dist-lib/lib/floriday-writes.functions.d.ts +5858 -1112
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.d.ts +17624 -3278
- package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.js +47 -21
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// ============================================================================
|
|
7
7
|
import { createServerFn } from "@tanstack/react-start";
|
|
8
8
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
9
|
-
import {
|
|
9
|
+
import { FLORYDAY_CLOCK_SUPPLY_PERMISSION_MESSAGE, FLORYDAY_CONTRACT_PERMISSION_MESSAGE, FLORYDAY_SALES_STRATEGY_PERMISSION_MESSAGE, FLORYDAY_STANDARD_SCOPE, getFlorydayScopeForPath, isClockSupplyScope, isContractScope, isSalesStrategyScope, } from "./floriday-scopes";
|
|
10
10
|
/**
|
|
11
11
|
* Valideert een GS1 GLN: exact 13 cijfers met geldige check digit.
|
|
12
12
|
* Retourneert null als geldig, anders een nl-foutmelding.
|
|
@@ -184,9 +184,6 @@ function createFlorydayTokenError(status, body, scope) {
|
|
|
184
184
|
if (isSalesStrategyScope(scope)) {
|
|
185
185
|
return new Error(FLORYDAY_SALES_STRATEGY_PERMISSION_MESSAGE);
|
|
186
186
|
}
|
|
187
|
-
if (isAgreementScope(scope)) {
|
|
188
|
-
return new Error(FLORYDAY_AGREEMENT_PERMISSION_MESSAGE);
|
|
189
|
-
}
|
|
190
187
|
if (isClockSupplyScope(scope)) {
|
|
191
188
|
return new Error(FLORYDAY_CLOCK_SUPPLY_PERMISSION_MESSAGE);
|
|
192
189
|
}
|
|
@@ -369,28 +366,56 @@ export const upsertFlorydayConnection = createServerFn({ method: "POST" })
|
|
|
369
366
|
return input;
|
|
370
367
|
})
|
|
371
368
|
.handler(async ({ data, context }) => {
|
|
372
|
-
//
|
|
373
|
-
//
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const { data: inserted, error } = await context.supabase
|
|
369
|
+
// Update-in-place op (environment, is_active=true) — geen DELETE meer,
|
|
370
|
+
// anders zou ON DELETE CASCADE alle cache-data voor deze connection wissen
|
|
371
|
+
// bij een gewone credential-wijziging. SELECT-filter matcht exact de
|
|
372
|
+
// partiële unieke index floriday_connections_env_active_uniq
|
|
373
|
+
// (environment) WHERE is_active = true.
|
|
374
|
+
const { data: existing, error: selectError } = await context.supabase
|
|
379
375
|
.from("floriday_connections")
|
|
380
|
-
.
|
|
381
|
-
environment
|
|
376
|
+
.select("id")
|
|
377
|
+
.eq("environment", data.environment)
|
|
378
|
+
.eq("is_active", true)
|
|
379
|
+
.limit(1)
|
|
380
|
+
.maybeSingle();
|
|
381
|
+
if (selectError)
|
|
382
|
+
throw new Error(selectError.message);
|
|
383
|
+
const payload = {
|
|
382
384
|
label: data.label ?? "",
|
|
383
385
|
client_id: deepSanitizeCredential(data.client_id),
|
|
384
386
|
client_secret: deepSanitizeCredential(data.client_secret),
|
|
385
387
|
api_key: deepSanitizeCredential(data.api_key),
|
|
386
388
|
is_active: true,
|
|
389
|
+
// Oud access_token is ongeldig zodra credentials wijzigen.
|
|
387
390
|
access_token: null,
|
|
388
391
|
token_expires_at: null,
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
};
|
|
393
|
+
let inserted;
|
|
394
|
+
if (existing?.id) {
|
|
395
|
+
const { data: updated, error } = await context.supabase
|
|
396
|
+
.from("floriday_connections")
|
|
397
|
+
.update(payload)
|
|
398
|
+
.eq("id", existing.id)
|
|
399
|
+
.select("*")
|
|
400
|
+
.single();
|
|
401
|
+
if (error)
|
|
402
|
+
throw new Error(error.message);
|
|
403
|
+
inserted = updated;
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
// Race: twee gelijktijdige opslag-acties kunnen beide hier belanden;
|
|
407
|
+
// de partiële unieke index vangt de tweede insert luid af met een
|
|
408
|
+
// constraint-error. Credentials opslaan is een handmatige, zeldzame
|
|
409
|
+
// actie — geen extra locking nodig.
|
|
410
|
+
const { data: created, error } = await context.supabase
|
|
411
|
+
.from("floriday_connections")
|
|
412
|
+
.insert({ environment: data.environment, ...payload })
|
|
413
|
+
.select("*")
|
|
414
|
+
.single();
|
|
415
|
+
if (error)
|
|
416
|
+
throw new Error(error.message);
|
|
417
|
+
inserted = created;
|
|
418
|
+
}
|
|
394
419
|
// Automatisch (her)plan de uurlijkse token-refresh cron. Niet-fataal
|
|
395
420
|
// bij falen — credentials zijn al opgeslagen.
|
|
396
421
|
try {
|
|
@@ -546,8 +571,6 @@ const MANAGED_FLORYDAY_CRON_JOB_NAMES = new Set([
|
|
|
546
571
|
"floriday-sales-strategies-sync-hourly",
|
|
547
572
|
"floriday-base-items-sync-hourly",
|
|
548
573
|
"floriday-contract-trade-item-groups-sync-hourly",
|
|
549
|
-
"floriday-agreements-sync-hourly",
|
|
550
|
-
"floriday-agreement-calloffs-sync-hourly",
|
|
551
574
|
// Referentiedata (schema + code-lijsten)
|
|
552
575
|
"floriday-reference-data-refresh-daily",
|
|
553
576
|
]);
|
|
@@ -699,7 +722,10 @@ async function fetchMaxSequence(supabase, env, maxSequenceEndpoint) {
|
|
|
699
722
|
const json = await res.json().catch(() => null);
|
|
700
723
|
if (typeof json === "number")
|
|
701
724
|
return json;
|
|
702
|
-
const n = json?.maxSequenceNumber ??
|
|
725
|
+
const n = json?.maxSequenceNumber ??
|
|
726
|
+
json?.maxSequence ??
|
|
727
|
+
json?.maximumSequenceNumber ??
|
|
728
|
+
json?.value;
|
|
703
729
|
if (typeof n !== "number") {
|
|
704
730
|
throw new Error(`Onbekende max-sequence response: ${JSON.stringify(json).slice(0, 200)}`);
|
|
705
731
|
}
|
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.21",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist-lib/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@flowselections/core": "1.0.12",
|
|
41
41
|
"@eslint/js": "^9.32.0",
|
|
42
|
-
"@lovable.dev/vite-tanstack-config": "2.
|
|
42
|
+
"@lovable.dev/vite-tanstack-config": "2.7.1",
|
|
43
43
|
"@types/node": "^22.16.5",
|
|
44
44
|
"@types/react": "^19.2.0",
|
|
45
45
|
"@types/react-dom": "^19.2.0",
|