@flowselections/floriday-authenticatie-module 1.0.15 → 1.0.16
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.d.ts.map +1 -1
- package/dist-lib/components/settings/FlorydaySettingsCard.js +2 -2
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +1252 -32
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +1252 -32
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +1252 -32
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +1275 -33
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts +1252 -32
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-labels.functions.d.ts +1252 -32
- package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-public.functions.d.ts +7320 -0
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-scopes.d.ts +17 -1
- package/dist-lib/lib/floriday-scopes.d.ts.map +1 -1
- package/dist-lib/lib/floriday-scopes.js +66 -5
- package/dist-lib/lib/floriday-stickers.functions.d.ts +1252 -32
- package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.functions.d.ts +59357 -33
- package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.functions.js +92 -2
- package/dist-lib/lib/floriday-writes.functions.d.ts +7338 -6
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.d.ts +22086 -144
- package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.js +13 -2
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ============================================================================
|
|
8
8
|
import { createServerFn } from "@tanstack/react-start";
|
|
9
9
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
10
|
-
import {
|
|
10
|
+
import { FLORYDAY_AGREEMENT_PERMISSION_MESSAGE, FLORYDAY_CONTRACT_PERMISSION_MESSAGE, FLORYDAY_SALES_STRATEGY_PERMISSION_MESSAGE, } from "./floriday-scopes";
|
|
11
11
|
import { SUPPLIERS_API_VERSION, getActiveFlorydayCredentials, resolveFlorydayCronBaseUrl, syncFloridayEntityBySequence, } from "./floriday.functions";
|
|
12
12
|
const now = () => new Date().toISOString();
|
|
13
13
|
const RESOURCE_CONFIG = {
|
|
@@ -519,6 +519,75 @@ const RESOURCE_CONFIG = {
|
|
|
519
519
|
"sales-strategies": makeSimpleSeq("sales-strategies", "sales-strategies", "floriday_sales_strategies_cache", ["salesStrategyId"], { maxSequencePath: "/sales-strategies/sync/max-sequence-number" }),
|
|
520
520
|
"base-items": makeSimpleSeq("base-items", "base-items", "floriday_base_items_cache", ["baseItemId"]),
|
|
521
521
|
"contract-trade-item-groups": makeSimpleSeq("contract-trade-item-groups", "contract-trade-item-groups", "floriday_contract_trade_item_groups_cache", ["contractTradeItemGroupId"]),
|
|
522
|
+
// Agreements + agreement-calloffs (klantspecifieke contractprijzen).
|
|
523
|
+
// Vereist scope `agreement:read` — zie floriday-scopes.ts.
|
|
524
|
+
"agreements": {
|
|
525
|
+
kind: "sequence",
|
|
526
|
+
entityType: "agreements",
|
|
527
|
+
maxSequenceEndpoint: `/${SUPPLIERS_API_VERSION}/agreements/current-max-sequence`,
|
|
528
|
+
bySequenceEndpointBase: `/${SUPPLIERS_API_VERSION}/agreements/sync`,
|
|
529
|
+
upsert: async (supabase, connectionId, items) => {
|
|
530
|
+
const rows = items
|
|
531
|
+
.map((item) => {
|
|
532
|
+
const fid = item?.agreementId ?? item?.id ?? null;
|
|
533
|
+
if (!fid)
|
|
534
|
+
return null;
|
|
535
|
+
return {
|
|
536
|
+
connection_id: connectionId,
|
|
537
|
+
floriday_id: String(fid),
|
|
538
|
+
sequence_number: Number(item?.sequenceNumber ?? 0),
|
|
539
|
+
is_deleted: Boolean(item?.isDeleted),
|
|
540
|
+
buyer_organization_id: item?.buyerOrganizationId ?? null,
|
|
541
|
+
status: item?.status ?? null,
|
|
542
|
+
valid_from: item?.validFrom ?? item?.periodStart ?? null,
|
|
543
|
+
valid_until: item?.validUntil ?? item?.periodEnd ?? null,
|
|
544
|
+
data: item,
|
|
545
|
+
fetched_at: now(),
|
|
546
|
+
};
|
|
547
|
+
})
|
|
548
|
+
.filter(Boolean);
|
|
549
|
+
if (rows.length === 0)
|
|
550
|
+
return;
|
|
551
|
+
const { error } = await supabase
|
|
552
|
+
.from("floriday_agreements_cache")
|
|
553
|
+
.upsert(rows, { onConflict: "connection_id,floriday_id" });
|
|
554
|
+
if (error)
|
|
555
|
+
throw new Error(`agreements upsert: ${error.message}`);
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
"agreement-calloffs": {
|
|
559
|
+
kind: "sequence",
|
|
560
|
+
entityType: "agreement-calloffs",
|
|
561
|
+
maxSequenceEndpoint: `/${SUPPLIERS_API_VERSION}/agreement-calloffs/current-max-sequence`,
|
|
562
|
+
bySequenceEndpointBase: `/${SUPPLIERS_API_VERSION}/agreement-calloffs/sync`,
|
|
563
|
+
upsert: async (supabase, connectionId, items) => {
|
|
564
|
+
const rows = items
|
|
565
|
+
.map((item) => {
|
|
566
|
+
const fid = item?.agreementCalloffId ?? item?.id ?? null;
|
|
567
|
+
if (!fid)
|
|
568
|
+
return null;
|
|
569
|
+
return {
|
|
570
|
+
connection_id: connectionId,
|
|
571
|
+
floriday_id: String(fid),
|
|
572
|
+
sequence_number: Number(item?.sequenceNumber ?? 0),
|
|
573
|
+
is_deleted: Boolean(item?.isDeleted),
|
|
574
|
+
agreement_id: item?.agreementId ?? null,
|
|
575
|
+
delivery_date: item?.deliveryDate ?? null,
|
|
576
|
+
status: item?.status ?? null,
|
|
577
|
+
data: item,
|
|
578
|
+
fetched_at: now(),
|
|
579
|
+
};
|
|
580
|
+
})
|
|
581
|
+
.filter(Boolean);
|
|
582
|
+
if (rows.length === 0)
|
|
583
|
+
return;
|
|
584
|
+
const { error } = await supabase
|
|
585
|
+
.from("floriday_agreement_calloffs_cache")
|
|
586
|
+
.upsert(rows, { onConflict: "connection_id,floriday_id" });
|
|
587
|
+
if (error)
|
|
588
|
+
throw new Error(`agreement-calloffs upsert: ${error.message}`);
|
|
589
|
+
},
|
|
590
|
+
},
|
|
522
591
|
// NB: `trade-item-classifications` is GEEN Floriday Suppliers-resource (2026v1
|
|
523
592
|
// levert geen `/trade-item-classifications/*` endpoints — bevestigd met 404 op
|
|
524
593
|
// /current-max-sequence). VBN-productcodes en -karakteristieken komen uit
|
|
@@ -615,7 +684,10 @@ async function runSyncHandler(context, environment, resource) {
|
|
|
615
684
|
resource === "contract-trade-item-groups";
|
|
616
685
|
let message = rawMessage;
|
|
617
686
|
if (resource === "sales-strategies" && policyDenied) {
|
|
618
|
-
message =
|
|
687
|
+
message = FLORYDAY_SALES_STRATEGY_PERMISSION_MESSAGE;
|
|
688
|
+
}
|
|
689
|
+
else if ((resource === "agreements" || resource === "agreement-calloffs") && policyDenied) {
|
|
690
|
+
message = FLORYDAY_AGREEMENT_PERMISSION_MESSAGE;
|
|
619
691
|
}
|
|
620
692
|
else if (isContractResource && policyDenied) {
|
|
621
693
|
message = FLORYDAY_CONTRACT_PERMISSION_MESSAGE;
|
|
@@ -795,6 +867,16 @@ const SCHEDULER_SPECS = {
|
|
|
795
867
|
path: "/api/public/cron/sync-floriday-contract-trade-item-groups",
|
|
796
868
|
jobname: "floriday-contract-trade-item-groups-sync-hourly",
|
|
797
869
|
},
|
|
870
|
+
"agreements": {
|
|
871
|
+
rpc: "schedule_floriday_agreements_sync",
|
|
872
|
+
path: "/api/public/cron/sync-floriday-agreements",
|
|
873
|
+
jobname: "floriday-agreements-sync-hourly",
|
|
874
|
+
},
|
|
875
|
+
"agreement-calloffs": {
|
|
876
|
+
rpc: "schedule_floriday_agreement_calloffs_sync",
|
|
877
|
+
path: "/api/public/cron/sync-floriday-agreement-calloffs",
|
|
878
|
+
jobname: "floriday-agreement-calloffs-sync-hourly",
|
|
879
|
+
},
|
|
798
880
|
};
|
|
799
881
|
export async function scheduleFlorydayResourceSyncInternal(supabase, resource) {
|
|
800
882
|
const apikey = process.env.SUPABASE_PUBLISHABLE_KEY ??
|
|
@@ -901,6 +983,14 @@ export const syncFlorydayContractTradeItemGroups = createServerFn({ method: "POS
|
|
|
901
983
|
.middleware([requireSupabaseAuth])
|
|
902
984
|
.inputValidator(envValidator)
|
|
903
985
|
.handler(async ({ data, context }) => runSyncHandler(context, data.environment, "contract-trade-item-groups"));
|
|
986
|
+
export const syncFlorydayAgreements = createServerFn({ method: "POST" })
|
|
987
|
+
.middleware([requireSupabaseAuth])
|
|
988
|
+
.inputValidator(envValidator)
|
|
989
|
+
.handler(async ({ data, context }) => runSyncHandler(context, data.environment, "agreements"));
|
|
990
|
+
export const syncFlorydayAgreementCalloffs = createServerFn({ method: "POST" })
|
|
991
|
+
.middleware([requireSupabaseAuth])
|
|
992
|
+
.inputValidator(envValidator)
|
|
993
|
+
.handler(async ({ data, context }) => runSyncHandler(context, data.environment, "agreement-calloffs"));
|
|
904
994
|
// Opmerking: `trade-item-classifications` is verwijderd als sync-resource. De
|
|
905
995
|
// Floriday Suppliers API (2026v1) kent dit endpoint niet (404 op
|
|
906
996
|
// /current-max-sequence). Classificatie-data leeft in de Swagger-enums en
|