@flowselections/floriday-authenticatie-module 1.0.21 → 1.0.23

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 (41) hide show
  1. package/dist-lib/integrations/supabase/auth-middleware.d.ts +385 -3
  2. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  3. package/dist-lib/integrations/supabase/client.d.ts +385 -3
  4. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  5. package/dist-lib/integrations/supabase/client.server.d.ts +385 -3
  6. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  7. package/dist-lib/integrations/supabase/types.d.ts +389 -3
  8. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  9. package/dist-lib/lib/central-auth.server.d.ts +17 -0
  10. package/dist-lib/lib/central-auth.server.d.ts.map +1 -0
  11. package/dist-lib/lib/central-auth.server.js +65 -0
  12. package/dist-lib/lib/floricode.functions.d.ts +2757 -83
  13. package/dist-lib/lib/floricode.functions.d.ts.map +1 -1
  14. package/dist-lib/lib/floriday-auction-letters.functions.d.ts +385 -3
  15. package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
  16. package/dist-lib/lib/floriday-labels.functions.d.ts +385 -3
  17. package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
  18. package/dist-lib/lib/floriday-public.functions.d.ts +2310 -18
  19. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  20. package/dist-lib/lib/floriday-stickers.functions.d.ts +385 -3
  21. package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
  22. package/dist-lib/lib/floriday-sync.functions.d.ts +12493 -651
  23. package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
  24. package/dist-lib/lib/floriday-writes.functions.d.ts +2310 -18
  25. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/floriday.functions.d.ts +7178 -302
  27. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/floriday.functions.js +9 -21
  29. package/dist-lib/lib/gateway/cache-tables.d.ts +2 -0
  30. package/dist-lib/lib/gateway/cache-tables.d.ts.map +1 -0
  31. package/dist-lib/lib/gateway/cache-tables.js +27 -0
  32. package/dist-lib/lib/gateway/cached-list.d.ts +15 -0
  33. package/dist-lib/lib/gateway/cached-list.d.ts.map +1 -0
  34. package/dist-lib/lib/gateway/cached-list.js +35 -0
  35. package/dist-lib/lib/gateway/index.d.ts +4 -0
  36. package/dist-lib/lib/gateway/index.d.ts.map +1 -0
  37. package/dist-lib/lib/gateway/index.js +3 -0
  38. package/dist-lib/lib/gateway/shared.d.ts +2 -0
  39. package/dist-lib/lib/gateway/shared.d.ts.map +1 -0
  40. package/dist-lib/lib/gateway/shared.js +3 -0
  41. package/package.json +7 -3
@@ -127,32 +127,20 @@ export async function getFlorydayAccessToken(supabase, env, options = {}) {
127
127
  return fresh.access_token;
128
128
  }
129
129
  }
130
- let json;
130
+ let accessToken;
131
131
  let newExpiresAt;
132
132
  try {
133
- const tokenRes = await fetch(FLORYDAY_ENDPOINTS[env].tokenUrl, {
134
- method: "POST",
135
- headers: {
136
- "Content-Type": "application/x-www-form-urlencoded",
137
- Accept: "application/json",
138
- },
139
- body: new URLSearchParams({
140
- grant_type: "client_credentials",
141
- client_id: deepSanitizeCredential(row.client_id),
142
- client_secret: deepSanitizeCredential(row.client_secret),
143
- scope: requestedScope,
144
- }).toString(),
145
- });
146
- const text = await tokenRes.text();
147
- if (!tokenRes.ok) {
148
- throw createFlorydayTokenError(tokenRes.status, text, requestedScope);
133
+ const { getFlorydayTokenFromCentral } = await import("./central-auth.server");
134
+ const result = await getFlorydayTokenFromCentral(env, requestedScope);
135
+ if (!result.ok) {
136
+ throw createFlorydayTokenError(result.raw.status, result.raw.body, requestedScope);
149
137
  }
150
- json = JSON.parse(text);
151
- newExpiresAt = new Date(now + json.expires_in * 1000).toISOString();
138
+ accessToken = result.access_token;
139
+ newExpiresAt = result.expires_at;
152
140
  if (canReuseStoredToken) {
153
141
  await supabase
154
142
  .from("floriday_connections")
155
- .update({ access_token: json.access_token, token_expires_at: newExpiresAt })
143
+ .update({ access_token: accessToken, token_expires_at: newExpiresAt })
156
144
  .eq("id", row.id);
157
145
  }
158
146
  // Best-effort logging (faalt nooit hard).
@@ -172,7 +160,7 @@ export async function getFlorydayAccessToken(supabase, env, options = {}) {
172
160
  }).then(() => undefined, () => undefined);
173
161
  throw e;
174
162
  }
175
- return json.access_token;
163
+ return accessToken;
176
164
  }
177
165
  function createFlorydayTokenError(status, body, scope) {
178
166
  const normalized = body.toLowerCase();
@@ -0,0 +1,2 @@
1
+ export declare const CACHE_TABLES: Record<string, string>;
2
+ //# sourceMappingURL=cache-tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-tables.d.ts","sourceRoot":"","sources":["../../../src/lib/gateway/cache-tables.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyB/C,CAAC"}
@@ -0,0 +1,27 @@
1
+ // Letterlijke kopie uit src/routes/api/public/gateway/cached-list.ts (HEAD).
2
+ export const CACHE_TABLES = {
3
+ "sales-orders": "floriday_salesorders_cache",
4
+ "trade-items": "floriday_trade_items_cache",
5
+ "customer-organizations": "floriday_customers_cache",
6
+ "carriers": "floriday_carriers_cache",
7
+ "fulfillment-orders": "floriday_fulfillment_orders_cache",
8
+ "delivery-orders": "floriday_delivery_orders_cache",
9
+ "clock-supplies": "floriday_clock_supplies_cache",
10
+ "clock-presales": "floriday_clock_presales_cache",
11
+ "contracts": "floriday_contracts_cache",
12
+ "blanket-orders": "floriday_blanket_orders_cache",
13
+ "warehouses": "floriday_warehouses_cache",
14
+ "delivery-locations": "floriday_delivery_locations_cache",
15
+ "packings": "floriday_packings_cache",
16
+ "connections": "floriday_connections_cache",
17
+ "customer-stickers": "floriday_customer_stickers_cache",
18
+ "additional-services": "floriday_additional_services_cache",
19
+ "commercial-service-types": "floriday_commercial_service_types_cache",
20
+ "collections": "floriday_collections_cache",
21
+ "price-groups": "floriday_price_groups_cache",
22
+ "delivery-condition-sets": "floriday_delivery_condition_sets_cache",
23
+ "sales-strategies": "floriday_sales_strategies_cache",
24
+ "base-items": "floriday_base_items_cache",
25
+ "contract-trade-item-groups": "floriday_contract_trade_item_groups_cache",
26
+ "trade-item-classifications": "floriday_trade_item_classifications_cache",
27
+ };
@@ -0,0 +1,15 @@
1
+ import type { SupabaseClient } from "@supabase/supabase-js";
2
+ export interface CachedListInput {
3
+ environment: "staging" | "live";
4
+ entity: string;
5
+ limit?: number;
6
+ }
7
+ export type CachedListResult = {
8
+ ok: true;
9
+ rows: unknown[];
10
+ } | {
11
+ ok: false;
12
+ error: string;
13
+ };
14
+ export declare function runCachedList(supabase: SupabaseClient, parsed: CachedListInput): Promise<CachedListResult>;
15
+ //# sourceMappingURL=cached-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cached-list.d.ts","sourceRoot":"","sources":["../../../src/lib/gateway/cached-list.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wBAAsB,aAAa,CACjC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,gBAAgB,CAAC,CA8B3B"}
@@ -0,0 +1,35 @@
1
+ // Verplaatste business-logica voor de cached-list gateway-route.
2
+ // Behoud van gedrag: query, limit-clamp en ordering zijn letterlijk overgenomen
3
+ // uit src/routes/api/public/gateway/cached-list.ts (HEAD). Enige verschillen:
4
+ // (a) supabase is een parameter, (b) return data i.p.v. Response, (c) imports.
5
+ import { CACHE_TABLES } from "../../lib/gateway/cache-tables";
6
+ export async function runCachedList(supabase, parsed) {
7
+ if (parsed.environment !== "staging" && parsed.environment !== "live") {
8
+ return { ok: false, error: "Ongeldige environment" };
9
+ }
10
+ const table = CACHE_TABLES[parsed.entity];
11
+ if (!table) {
12
+ return { ok: false, error: `Onbekende entity: ${parsed.entity}` };
13
+ }
14
+ const limit = Math.min(Math.max(parsed.limit ?? 100, 1), 1000);
15
+ const { data: conn } = await supabase
16
+ .from("floriday_connections")
17
+ .select("id")
18
+ .eq("environment", parsed.environment)
19
+ .eq("is_active", true)
20
+ .order("updated_at", { ascending: false })
21
+ .limit(1)
22
+ .maybeSingle();
23
+ if (!conn) {
24
+ return { ok: false, error: `Geen actieve koppeling voor ${parsed.environment}` };
25
+ }
26
+ const { data: rows, error } = await supabase
27
+ .from(table)
28
+ .select("*")
29
+ .eq("connection_id", conn.id)
30
+ .order("updated_at", { ascending: false })
31
+ .limit(limit);
32
+ if (error)
33
+ return { ok: false, error: error.message };
34
+ return { ok: true, rows: rows ?? [] };
35
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./shared";
2
+ export * from "./cache-tables";
3
+ export * from "./cached-list";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/gateway/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./shared";
2
+ export * from "./cache-tables";
3
+ export * from "./cached-list";
@@ -0,0 +1,2 @@
1
+ export { verifyGatewayCaller, corsPreflight, withCors, GATEWAY_CORS_HEADERS, } from "../../lib/floriday-gateway-auth";
2
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/lib/gateway/shared.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,oBAAoB,GACrB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Gateway shared re-exports — subset used by cached-list (stap 1).
2
+ // Aanvullende exports (binary caller, types) volgen bij latere lifts.
3
+ export { verifyGatewayCaller, corsPreflight, withCors, GATEWAY_CORS_HEADERS, } from "../../lib/floriday-gateway-auth";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowselections/floriday-authenticatie-module",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "sideEffects": false,
5
5
  "type": "module",
6
6
  "main": "./dist-lib/index.js",
@@ -9,6 +9,10 @@
9
9
  ".": {
10
10
  "types": "./dist-lib/index.d.ts",
11
11
  "default": "./dist-lib/index.js"
12
+ },
13
+ "./gateway": {
14
+ "types": "./dist-lib/lib/gateway/index.d.ts",
15
+ "default": "./dist-lib/lib/gateway/index.js"
12
16
  }
13
17
  },
14
18
  "files": [
@@ -37,9 +41,9 @@
37
41
  "pdf-lib": "^1.17.1"
38
42
  },
39
43
  "devDependencies": {
40
- "@flowselections/core": "1.0.12",
44
+ "@flowselections/core": "1.0.16",
41
45
  "@eslint/js": "^9.32.0",
42
- "@lovable.dev/vite-tanstack-config": "2.7.1",
46
+ "@lovable.dev/vite-tanstack-config": "2.7.6",
43
47
  "@types/node": "^22.16.5",
44
48
  "@types/react": "^19.2.0",
45
49
  "@types/react-dom": "^19.2.0",