@flowselections/floriday-authenticatie-module 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.
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +20 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +35 -0
- package/dist-lib/components/settings/FlorydaySettingsCard.d.ts.map +1 -1
- package/dist-lib/components/settings/FlorydaySettingsCard.js +75 -53
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +6121 -2360
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +6121 -2360
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +6121 -2360
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +6259 -2382
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +10 -1
- package/dist-lib/lib/floricode-product-features.d.ts +50 -0
- package/dist-lib/lib/floricode-product-features.d.ts.map +1 -0
- package/dist-lib/lib/floricode-product-features.js +314 -0
- package/dist-lib/lib/floricode-regulatory-features.d.ts +41 -0
- package/dist-lib/lib/floricode-regulatory-features.d.ts.map +1 -0
- package/dist-lib/lib/floricode-regulatory-features.js +226 -0
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts +9307 -0
- package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auction-letters.functions.js +129 -0
- package/dist-lib/lib/floriday-gateway-hmac.d.ts +29 -0
- package/dist-lib/lib/floriday-gateway-hmac.d.ts.map +1 -0
- package/dist-lib/lib/floriday-gateway-hmac.js +119 -0
- package/dist-lib/lib/floriday-labels.functions.d.ts +9312 -0
- package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-labels.functions.js +141 -0
- package/dist-lib/lib/floriday-public.functions.d.ts +55883 -0
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-public.functions.js +241 -0
- package/dist-lib/lib/floriday-scopes.d.ts +20 -0
- package/dist-lib/lib/floriday-scopes.d.ts.map +1 -0
- package/dist-lib/lib/floriday-scopes.js +89 -0
- package/dist-lib/lib/floriday-stickers.functions.d.ts +9304 -0
- package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-stickers.functions.js +128 -0
- package/dist-lib/lib/floriday-sync.functions.d.ts +240368 -1916
- package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.functions.js +836 -35
- package/dist-lib/lib/floriday-writes.functions.d.ts +55812 -0
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-writes.functions.js +160 -0
- package/dist-lib/lib/floriday.functions.d.ts +125816 -46888
- package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.js +451 -58
- package/package.json +2 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floriday-leeszijde — publieke helpers voor andere modules.
|
|
3
|
+
*
|
|
4
|
+
* Andere modules (Verkoop, Magazijn, Catalogus, …) lezen Floriday-gegevens
|
|
5
|
+
* uit de lokale cache via deze helpers, nooit rechtstreeks van de API.
|
|
6
|
+
* Op die manier:
|
|
7
|
+
* - Blijft de cadans-richtlijn van Floriday gerespecteerd (sequence-sync).
|
|
8
|
+
* - Profiteren alle modules van dezelfde refresh-/token-keten.
|
|
9
|
+
* - Kunnen we per resource centraal stale-detectie inbouwen.
|
|
10
|
+
*/
|
|
11
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
12
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
13
|
+
import { getActiveFlorydayCredentials, } from "./floriday.functions";
|
|
14
|
+
const CACHE_TABLES = {
|
|
15
|
+
"sales-orders": "floriday_salesorders_cache",
|
|
16
|
+
"trade-items": "floriday_trade_items_cache",
|
|
17
|
+
"customer-organizations": "floriday_customers_cache",
|
|
18
|
+
"carriers": "floriday_carriers_cache",
|
|
19
|
+
"fulfillment-orders": "floriday_fulfillment_orders_cache",
|
|
20
|
+
"delivery-orders": "floriday_delivery_orders_cache",
|
|
21
|
+
"clock-supplies": "floriday_clock_supplies_cache",
|
|
22
|
+
"clock-presales": "floriday_clock_presales_cache",
|
|
23
|
+
"contracts": "floriday_contracts_cache",
|
|
24
|
+
"blanket-orders": "floriday_blanket_orders_cache",
|
|
25
|
+
"warehouses": "floriday_warehouses_cache",
|
|
26
|
+
"delivery-locations": "floriday_delivery_locations_cache",
|
|
27
|
+
"packings": "floriday_packings_cache",
|
|
28
|
+
"connections": "floriday_connections_cache",
|
|
29
|
+
"customer-stickers": "floriday_customer_stickers_cache",
|
|
30
|
+
"additional-services": "floriday_additional_services_cache",
|
|
31
|
+
"commercial-service-types": "floriday_commercial_service_types_cache",
|
|
32
|
+
"collections": "floriday_collections_cache",
|
|
33
|
+
"price-groups": "floriday_price_groups_cache",
|
|
34
|
+
"delivery-condition-sets": "floriday_delivery_condition_sets_cache",
|
|
35
|
+
"sales-strategies": "floriday_sales_strategies_cache",
|
|
36
|
+
"base-items": "floriday_base_items_cache",
|
|
37
|
+
"contract-trade-item-groups": "floriday_contract_trade_item_groups_cache",
|
|
38
|
+
"trade-item-classifications": "floriday_trade_item_classifications_cache",
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Generieke cache-lezer. Andere modules gebruiken dit i.p.v. zelf
|
|
42
|
+
* naar `floriday_*_cache` tabellen te queryen.
|
|
43
|
+
*/
|
|
44
|
+
export const getFlorydayCachedList = createServerFn({ method: "POST" })
|
|
45
|
+
.middleware([requireSupabaseAuth])
|
|
46
|
+
.inputValidator((input) => {
|
|
47
|
+
if (!["staging", "live"].includes(input.environment)) {
|
|
48
|
+
throw new Error("Ongeldige environment");
|
|
49
|
+
}
|
|
50
|
+
if (!(input.entity in CACHE_TABLES)) {
|
|
51
|
+
throw new Error(`Onbekende entity: ${input.entity}`);
|
|
52
|
+
}
|
|
53
|
+
return input;
|
|
54
|
+
})
|
|
55
|
+
.handler(async ({ data, context }) => {
|
|
56
|
+
const conn = await getActiveFlorydayCredentials(context.supabase, data.environment);
|
|
57
|
+
if (!conn) {
|
|
58
|
+
return { ok: false, error: `Geen actieve koppeling voor ${data.environment}` };
|
|
59
|
+
}
|
|
60
|
+
const table = CACHE_TABLES[data.entity];
|
|
61
|
+
const limit = Math.min(Math.max(data.limit ?? 100, 1), 1000);
|
|
62
|
+
const { data: rows, error } = await context.supabase
|
|
63
|
+
.from(table)
|
|
64
|
+
.select("*")
|
|
65
|
+
.eq("connection_id", conn.id)
|
|
66
|
+
.order("updated_at", { ascending: false })
|
|
67
|
+
.limit(limit);
|
|
68
|
+
if (error)
|
|
69
|
+
return { ok: false, error: error.message };
|
|
70
|
+
return { ok: true, rows: (rows ?? []) };
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Code-lijst lezen (enums, keuze-opties). Bron is een combinatie van de
|
|
74
|
+
* Floriday Swagger-enums en specifiek door Floriday gepubliceerde lijsten
|
|
75
|
+
* (landen, eenheden, kwaliteitsmerken). Andere modules gebruiken dit om
|
|
76
|
+
* dropdowns te vullen en input te valideren.
|
|
77
|
+
*/
|
|
78
|
+
export const getFlorydayCodeList = createServerFn({ method: "POST" })
|
|
79
|
+
.middleware([requireSupabaseAuth])
|
|
80
|
+
.inputValidator((input) => {
|
|
81
|
+
if (!["staging", "live"].includes(input.environment)) {
|
|
82
|
+
throw new Error("Ongeldige environment");
|
|
83
|
+
}
|
|
84
|
+
if (!input.listName || typeof input.listName !== "string") {
|
|
85
|
+
throw new Error("listName is verplicht");
|
|
86
|
+
}
|
|
87
|
+
return input;
|
|
88
|
+
})
|
|
89
|
+
.handler(async ({ data, context }) => {
|
|
90
|
+
const { data: rows, error } = await context.supabase
|
|
91
|
+
.from("floriday_code_lists_cache")
|
|
92
|
+
.select("code, label, payload")
|
|
93
|
+
.eq("environment", data.environment)
|
|
94
|
+
.eq("list_name", data.listName)
|
|
95
|
+
.order("code", { ascending: true });
|
|
96
|
+
if (error)
|
|
97
|
+
return { ok: false, error: error.message };
|
|
98
|
+
return {
|
|
99
|
+
ok: true,
|
|
100
|
+
values: (rows ?? []),
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* VBN-productlookup. Floriday publiceert VBN-bloem/plant-codes als
|
|
105
|
+
* referentiedata; we exposen ze via dezelfde code-lijst-tabel onder de
|
|
106
|
+
* vaste list-naam `vbn-products`. Resolved op exacte code óf zoekterm
|
|
107
|
+
* (ILIKE op label/payload->>'name').
|
|
108
|
+
*/
|
|
109
|
+
export const getFlorydayVbnProduct = createServerFn({ method: "POST" })
|
|
110
|
+
.middleware([requireSupabaseAuth])
|
|
111
|
+
.inputValidator((input) => {
|
|
112
|
+
if (!["staging", "live"].includes(input.environment)) {
|
|
113
|
+
throw new Error("Ongeldige environment");
|
|
114
|
+
}
|
|
115
|
+
if (!input.code && !input.search) {
|
|
116
|
+
throw new Error("code of search is verplicht");
|
|
117
|
+
}
|
|
118
|
+
return input;
|
|
119
|
+
})
|
|
120
|
+
.handler(async ({ data, context }) => {
|
|
121
|
+
const limit = Math.min(Math.max(data.limit ?? 25, 1), 200);
|
|
122
|
+
let query = context.supabase
|
|
123
|
+
.from("floriday_code_lists_cache")
|
|
124
|
+
.select("code, label, payload")
|
|
125
|
+
.eq("environment", data.environment)
|
|
126
|
+
.eq("list_name", "vbn-products");
|
|
127
|
+
if (data.code) {
|
|
128
|
+
query = query.eq("code", data.code);
|
|
129
|
+
}
|
|
130
|
+
else if (data.search) {
|
|
131
|
+
query = query.ilike("label", `%${data.search}%`);
|
|
132
|
+
}
|
|
133
|
+
const { data: rows, error } = await query.limit(limit);
|
|
134
|
+
if (error)
|
|
135
|
+
return { ok: false, error: error.message };
|
|
136
|
+
return {
|
|
137
|
+
ok: true,
|
|
138
|
+
products: (rows ?? []),
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* JSON-schema (incl. enums) voor een Floriday-resource ophalen — typisch
|
|
143
|
+
* `trade-item`. Bron is de Suppliers-API Swagger. Andere modules genereren
|
|
144
|
+
* hiermee formulieren en runtime-validatie zonder dat ze de Floriday-spec
|
|
145
|
+
* zelf hoeven te kennen.
|
|
146
|
+
*/
|
|
147
|
+
export const getFlorydayResourceSchema = createServerFn({ method: "POST" })
|
|
148
|
+
.middleware([requireSupabaseAuth])
|
|
149
|
+
.inputValidator((input) => {
|
|
150
|
+
if (!input.resource)
|
|
151
|
+
throw new Error("resource is verplicht");
|
|
152
|
+
return input;
|
|
153
|
+
})
|
|
154
|
+
.handler(async ({ data, context }) => {
|
|
155
|
+
let query = context.supabase
|
|
156
|
+
.from("floriday_resource_schemas")
|
|
157
|
+
.select("resource, version, schema, enums, fetched_at")
|
|
158
|
+
.eq("resource", data.resource);
|
|
159
|
+
if (data.version)
|
|
160
|
+
query = query.eq("version", data.version);
|
|
161
|
+
const { data: rows, error } = await query
|
|
162
|
+
.order("fetched_at", { ascending: false })
|
|
163
|
+
.limit(1);
|
|
164
|
+
if (error)
|
|
165
|
+
return { ok: false, error: error.message };
|
|
166
|
+
const row = (rows ?? [])[0];
|
|
167
|
+
if (!row)
|
|
168
|
+
return { ok: false, error: "Schema niet gevonden — draai eerst de referentiedata-refresh" };
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
resource: row.resource,
|
|
172
|
+
version: row.version,
|
|
173
|
+
schema: row.schema,
|
|
174
|
+
enums: (row.enums ?? {}),
|
|
175
|
+
fetched_at: row.fetched_at,
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
/**
|
|
179
|
+
* Toegestane waarden voor een veld uit een Floriday code-lijst ophalen.
|
|
180
|
+
* Gebruikt door andere modules om dropdowns te vullen en input vóór een
|
|
181
|
+
* write-call lokaal te valideren — zonder Floriday-roundtrip.
|
|
182
|
+
*
|
|
183
|
+
* `listName` is gelijk aan de enum-typenaam uit de Swagger
|
|
184
|
+
* (bv. `Currency`, `Incoterm`, `SalesUnit`, `AuctionLocation`, `PhotoType`).
|
|
185
|
+
*/
|
|
186
|
+
export const getFlorydayAllowedValues = createServerFn({ method: "POST" })
|
|
187
|
+
.middleware([requireSupabaseAuth])
|
|
188
|
+
.inputValidator((input) => {
|
|
189
|
+
if (!["staging", "live"].includes(input.environment)) {
|
|
190
|
+
throw new Error("Ongeldige environment");
|
|
191
|
+
}
|
|
192
|
+
if (!input.listName?.trim())
|
|
193
|
+
throw new Error("listName is verplicht");
|
|
194
|
+
return input;
|
|
195
|
+
})
|
|
196
|
+
.handler(async ({ data, context }) => {
|
|
197
|
+
const { data: rows, error } = await context.supabase
|
|
198
|
+
.from("floriday_code_lists_cache")
|
|
199
|
+
.select("code")
|
|
200
|
+
.eq("environment", data.environment)
|
|
201
|
+
.eq("list_name", data.listName)
|
|
202
|
+
.order("code", { ascending: true });
|
|
203
|
+
if (error)
|
|
204
|
+
return { ok: false, error: error.message };
|
|
205
|
+
return {
|
|
206
|
+
ok: true,
|
|
207
|
+
values: (rows ?? []).map((r) => r.code),
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* Snelle assertion-helper. Geeft `{ ok: true }` bij valide waarde,
|
|
212
|
+
* anders `{ ok: false, allowed }` zodat de UI direct kan tonen welke
|
|
213
|
+
* waarden wél geaccepteerd worden.
|
|
214
|
+
*/
|
|
215
|
+
export const assertFlorydayValue = createServerFn({ method: "POST" })
|
|
216
|
+
.middleware([requireSupabaseAuth])
|
|
217
|
+
.inputValidator((input) => {
|
|
218
|
+
if (!["staging", "live"].includes(input.environment)) {
|
|
219
|
+
throw new Error("Ongeldige environment");
|
|
220
|
+
}
|
|
221
|
+
if (!input.listName?.trim())
|
|
222
|
+
throw new Error("listName is verplicht");
|
|
223
|
+
return input;
|
|
224
|
+
})
|
|
225
|
+
.handler(async ({ data, context }) => {
|
|
226
|
+
const { data: rows, error } = await context.supabase
|
|
227
|
+
.from("floriday_code_lists_cache")
|
|
228
|
+
.select("code")
|
|
229
|
+
.eq("environment", data.environment)
|
|
230
|
+
.eq("list_name", data.listName);
|
|
231
|
+
if (error)
|
|
232
|
+
return { ok: false, error: error.message };
|
|
233
|
+
const allowed = (rows ?? []).map((r) => r.code);
|
|
234
|
+
if (allowed.length === 0) {
|
|
235
|
+
// Geen cache aanwezig → laat de write-call zelf valideren bij Floriday.
|
|
236
|
+
return { ok: true, skipped: true };
|
|
237
|
+
}
|
|
238
|
+
if (allowed.includes(data.value))
|
|
239
|
+
return { ok: true };
|
|
240
|
+
return { ok: false, error: "ongeldige waarde", allowed };
|
|
241
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const FLORYDAY_STANDARD_SCOPES: readonly ["role:app", "catalog:read", "catalog:write", "sales-order:write", "organization:read", "supply:read", "supply:write", "sales-order:read", "delivery-conditions:read", "fulfillment:write", "fulfillment:read", "network:read", "network:write", "sticker:read"];
|
|
2
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_SCOPES: readonly ["clock-supply:read", "clock-supply:write"];
|
|
3
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_READ_SCOPES: readonly ["clock-supply:read"];
|
|
4
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_WRITE_SCOPES: readonly ["clock-supply:write"];
|
|
5
|
+
export declare const FLORYDAY_CONTRACT_SCOPES: readonly ["contract:read", "contract:write"];
|
|
6
|
+
export declare const FLORYDAY_CONTRACT_READ_SCOPES: readonly ["contract:read"];
|
|
7
|
+
export declare const FLORYDAY_CONTRACT_WRITE_SCOPES: readonly ["contract:write"];
|
|
8
|
+
export declare const FLORYDAY_STANDARD_SCOPE: string;
|
|
9
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_SCOPE: string;
|
|
10
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_READ_SCOPE: string;
|
|
11
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_WRITE_SCOPE: string;
|
|
12
|
+
export declare const FLORYDAY_CONTRACT_SCOPE: string;
|
|
13
|
+
export declare const FLORYDAY_CONTRACT_READ_SCOPE: string;
|
|
14
|
+
export declare const FLORYDAY_CONTRACT_WRITE_SCOPE: string;
|
|
15
|
+
export declare function getFlorydayScopeForPath(path: string, method?: string): string;
|
|
16
|
+
export declare function isClockSupplyScope(scope: string): boolean;
|
|
17
|
+
export declare function isContractScope(scope: string): boolean;
|
|
18
|
+
export declare const FLORYDAY_CLOCK_SUPPLY_PERMISSION_MESSAGE = "Floriday heeft Verkoopstrategie\u00EBn/Klokaanvoer nog niet vrijgegeven voor deze koppeling. Laat deze rechten in Floriday activeren en vernieuw daarna de verbinding.";
|
|
19
|
+
export declare const FLORYDAY_CONTRACT_PERMISSION_MESSAGE = "Floriday heeft de Contracten-module nog niet vrijgegeven voor deze koppeling. Laat dit recht in Floriday activeren en vernieuw daarna de verbinding.";
|
|
20
|
+
//# sourceMappingURL=floriday-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-scopes.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-scopes.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,2QAe3B,CAAC;AAOX,eAAO,MAAM,4BAA4B,sDAG/B,CAAC;AACX,eAAO,MAAM,iCAAiC,gCAAiC,CAAC;AAChF,eAAO,MAAM,kCAAkC,iCAAkC,CAAC;AAElF,eAAO,MAAM,wBAAwB,8CAG3B,CAAC;AACX,eAAO,MAAM,6BAA6B,4BAA6B,CAAC;AACxE,eAAO,MAAM,8BAA8B,6BAA8B,CAAC;AAE1E,eAAO,MAAM,uBAAuB,QAAqC,CAAC;AAE1E,eAAO,MAAM,2BAA2B,QAG7B,CAAC;AACZ,eAAO,MAAM,gCAAgC,QAGlC,CAAC;AACZ,eAAO,MAAM,iCAAiC,QAGnC,CAAC;AAEZ,eAAO,MAAM,uBAAuB,QAGzB,CAAC;AACZ,eAAO,MAAM,4BAA4B,QAG9B,CAAC;AACZ,eAAO,MAAM,6BAA6B,QAG/B,CAAC;AAEZ,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAQ,GAAG,MAAM,CAyB5E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,eAAO,MAAM,wCAAwC,2KACgH,CAAC;AAEtK,eAAO,MAAM,oCAAoC,yJACuG,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Floriday OAuth scopes used by the shared authentication gateway.
|
|
2
|
+
// Keep this file free of server-only imports so cron routes and server functions
|
|
3
|
+
// can both use the exact same scope definitions.
|
|
4
|
+
export const FLORYDAY_STANDARD_SCOPES = [
|
|
5
|
+
"role:app",
|
|
6
|
+
"catalog:read",
|
|
7
|
+
"catalog:write",
|
|
8
|
+
"sales-order:write",
|
|
9
|
+
"organization:read",
|
|
10
|
+
"supply:read",
|
|
11
|
+
"supply:write",
|
|
12
|
+
"sales-order:read",
|
|
13
|
+
"delivery-conditions:read",
|
|
14
|
+
"fulfillment:write",
|
|
15
|
+
"fulfillment:read",
|
|
16
|
+
"network:read",
|
|
17
|
+
"network:write",
|
|
18
|
+
"sticker:read",
|
|
19
|
+
];
|
|
20
|
+
// ─── Optionele modules (alleen aanvragen wanneer endpoint dit nodig heeft) ──
|
|
21
|
+
// Floriday weigert het volledige token (401 "Policy evaluation failed" / 403)
|
|
22
|
+
// als één gevraagde scope niet voor de Client ID is vrijgegeven. Daarom worden
|
|
23
|
+
// module-specifieke scopes pas op endpoint-basis toegevoegd.
|
|
24
|
+
export const FLORYDAY_CLOCK_SUPPLY_SCOPES = [
|
|
25
|
+
"clock-supply:read",
|
|
26
|
+
"clock-supply:write",
|
|
27
|
+
];
|
|
28
|
+
export const FLORYDAY_CLOCK_SUPPLY_READ_SCOPES = ["clock-supply:read"];
|
|
29
|
+
export const FLORYDAY_CLOCK_SUPPLY_WRITE_SCOPES = ["clock-supply:write"];
|
|
30
|
+
export const FLORYDAY_CONTRACT_SCOPES = [
|
|
31
|
+
"contract:read",
|
|
32
|
+
"contract:write",
|
|
33
|
+
];
|
|
34
|
+
export const FLORYDAY_CONTRACT_READ_SCOPES = ["contract:read"];
|
|
35
|
+
export const FLORYDAY_CONTRACT_WRITE_SCOPES = ["contract:write"];
|
|
36
|
+
export const FLORYDAY_STANDARD_SCOPE = FLORYDAY_STANDARD_SCOPES.join(" ");
|
|
37
|
+
export const FLORYDAY_CLOCK_SUPPLY_SCOPE = [
|
|
38
|
+
...FLORYDAY_STANDARD_SCOPES,
|
|
39
|
+
...FLORYDAY_CLOCK_SUPPLY_SCOPES,
|
|
40
|
+
].join(" ");
|
|
41
|
+
export const FLORYDAY_CLOCK_SUPPLY_READ_SCOPE = [
|
|
42
|
+
...FLORYDAY_STANDARD_SCOPES,
|
|
43
|
+
...FLORYDAY_CLOCK_SUPPLY_READ_SCOPES,
|
|
44
|
+
].join(" ");
|
|
45
|
+
export const FLORYDAY_CLOCK_SUPPLY_WRITE_SCOPE = [
|
|
46
|
+
...FLORYDAY_STANDARD_SCOPES,
|
|
47
|
+
...FLORYDAY_CLOCK_SUPPLY_WRITE_SCOPES,
|
|
48
|
+
].join(" ");
|
|
49
|
+
export const FLORYDAY_CONTRACT_SCOPE = [
|
|
50
|
+
...FLORYDAY_STANDARD_SCOPES,
|
|
51
|
+
...FLORYDAY_CONTRACT_SCOPES,
|
|
52
|
+
].join(" ");
|
|
53
|
+
export const FLORYDAY_CONTRACT_READ_SCOPE = [
|
|
54
|
+
...FLORYDAY_STANDARD_SCOPES,
|
|
55
|
+
...FLORYDAY_CONTRACT_READ_SCOPES,
|
|
56
|
+
].join(" ");
|
|
57
|
+
export const FLORYDAY_CONTRACT_WRITE_SCOPE = [
|
|
58
|
+
...FLORYDAY_STANDARD_SCOPES,
|
|
59
|
+
...FLORYDAY_CONTRACT_WRITE_SCOPES,
|
|
60
|
+
].join(" ");
|
|
61
|
+
export function getFlorydayScopeForPath(path, method = "GET") {
|
|
62
|
+
const normalized = path.toLowerCase();
|
|
63
|
+
const upperMethod = method.toUpperCase();
|
|
64
|
+
// Let op: volgens Suppliers API 2026v1 gebruiken `clock-supply-lines` en
|
|
65
|
+
// `clock-presales-supply-lines` de algemene `supply:*` scopes. Alleen
|
|
66
|
+
// `sales-strategies` gebruikt de aparte `clock-supply:*` scopes.
|
|
67
|
+
if (normalized.includes("/sales-strategies")) {
|
|
68
|
+
return upperMethod === "GET"
|
|
69
|
+
? FLORYDAY_CLOCK_SUPPLY_READ_SCOPE
|
|
70
|
+
: FLORYDAY_CLOCK_SUPPLY_WRITE_SCOPE;
|
|
71
|
+
}
|
|
72
|
+
// Contracten + contract-trade-item-groups vereisen de `contract:*` scope.
|
|
73
|
+
if (normalized.includes("/contracts") ||
|
|
74
|
+
normalized.includes("/contract-trade-item-groups") ||
|
|
75
|
+
normalized.includes("/blanket-orders")) {
|
|
76
|
+
return upperMethod === "GET"
|
|
77
|
+
? FLORYDAY_CONTRACT_READ_SCOPE
|
|
78
|
+
: FLORYDAY_CONTRACT_WRITE_SCOPE;
|
|
79
|
+
}
|
|
80
|
+
return FLORYDAY_STANDARD_SCOPE;
|
|
81
|
+
}
|
|
82
|
+
export function isClockSupplyScope(scope) {
|
|
83
|
+
return FLORYDAY_CLOCK_SUPPLY_SCOPES.some((s) => scope.includes(s));
|
|
84
|
+
}
|
|
85
|
+
export function isContractScope(scope) {
|
|
86
|
+
return FLORYDAY_CONTRACT_SCOPES.some((s) => scope.includes(s));
|
|
87
|
+
}
|
|
88
|
+
export const FLORYDAY_CLOCK_SUPPLY_PERMISSION_MESSAGE = "Floriday heeft Verkoopstrategieën/Klokaanvoer nog niet vrijgegeven voor deze koppeling. Laat deze rechten in Floriday activeren en vernieuw daarna de verbinding.";
|
|
89
|
+
export const FLORYDAY_CONTRACT_PERMISSION_MESSAGE = "Floriday heeft de Contracten-module nog niet vrijgegeven voor deze koppeling. Laat dit recht in Floriday activeren en vernieuw daarna de verbinding.";
|