@fayz-ai/core 0.8.1 → 0.8.3

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 (123) hide show
  1. package/dist/access/denial.d.ts +21 -0
  2. package/dist/access/denial.d.ts.map +1 -0
  3. package/dist/access/engine.d.ts +63 -0
  4. package/dist/access/engine.d.ts.map +1 -0
  5. package/dist/access/index.cjs +60 -0
  6. package/dist/access/index.cjs.map +1 -0
  7. package/dist/access/index.d.ts +6 -0
  8. package/dist/access/index.d.ts.map +1 -0
  9. package/dist/access/index.js +51 -0
  10. package/dist/access/index.js.map +1 -0
  11. package/dist/access/limits.d.ts +10 -0
  12. package/dist/access/limits.d.ts.map +1 -0
  13. package/dist/address/index.d.ts +52 -0
  14. package/dist/address/index.d.ts.map +1 -0
  15. package/dist/{chunk-QR7U2URY.cjs → chunk-CATASHPK.cjs} +345 -4
  16. package/dist/chunk-CATASHPK.cjs.map +1 -0
  17. package/dist/{chunk-WKZVSKEU.js → chunk-CU64QI4A.js} +2 -2
  18. package/dist/chunk-CU64QI4A.js.map +1 -0
  19. package/dist/{chunk-KNIVT6XZ.js → chunk-DZALZ6Q6.js} +345 -4
  20. package/dist/chunk-DZALZ6Q6.js.map +1 -0
  21. package/dist/{chunk-54SRL7AJ.cjs → chunk-KSI2L3E4.cjs} +145 -86
  22. package/dist/chunk-KSI2L3E4.cjs.map +1 -0
  23. package/dist/{chunk-ZBIWYDAR.js → chunk-TYPVSWLG.js} +144 -87
  24. package/dist/chunk-TYPVSWLG.js.map +1 -0
  25. package/dist/{chunk-2NTHNWEH.cjs → chunk-UKU4RIWM.cjs} +2 -2
  26. package/dist/chunk-UKU4RIWM.cjs.map +1 -0
  27. package/dist/{chunk-CHGX6UYR.js → chunk-YH25Y4FW.js} +6 -3
  28. package/dist/chunk-YH25Y4FW.js.map +1 -0
  29. package/dist/{chunk-5X2VX3RQ.cjs → chunk-ZOPJB5FN.cjs} +6 -3
  30. package/dist/chunk-ZOPJB5FN.cjs.map +1 -0
  31. package/dist/data/archetype.d.ts.map +1 -1
  32. package/dist/data/count.d.ts +34 -0
  33. package/dist/data/count.d.ts.map +1 -0
  34. package/dist/data/index.cjs +18 -10
  35. package/dist/data/index.d.ts +2 -0
  36. package/dist/data/index.d.ts.map +1 -1
  37. package/dist/data/index.js +1 -1
  38. package/dist/data/refresh.d.ts +36 -0
  39. package/dist/data/refresh.d.ts.map +1 -0
  40. package/dist/data/resolve.d.ts.map +1 -1
  41. package/dist/data/supabase.d.ts.map +1 -1
  42. package/dist/data/types.d.ts +6 -0
  43. package/dist/data/types.d.ts.map +1 -1
  44. package/dist/entity/index.cjs +6 -6
  45. package/dist/entity/index.js +1 -1
  46. package/dist/entity/registry.d.ts +9 -0
  47. package/dist/entity/registry.d.ts.map +1 -1
  48. package/dist/i18n/index.cjs +10 -10
  49. package/dist/i18n/index.js +1 -1
  50. package/dist/i18n/shell-translations.d.ts.map +1 -1
  51. package/dist/index.cjs +1517 -180
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.ts +15 -5
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +1412 -110
  56. package/dist/index.js.map +1 -1
  57. package/dist/manifest/index.d.ts +109 -3
  58. package/dist/manifest/index.d.ts.map +1 -1
  59. package/dist/manifest/serialize.d.ts +14 -0
  60. package/dist/manifest/serialize.d.ts.map +1 -0
  61. package/dist/plugin/index.cjs +7 -7
  62. package/dist/plugin/index.js +1 -1
  63. package/dist/plugin/runtime.d.ts.map +1 -1
  64. package/dist/search/engine.d.ts +12 -0
  65. package/dist/search/engine.d.ts.map +1 -0
  66. package/dist/search/index.d.ts +5 -0
  67. package/dist/search/index.d.ts.map +1 -0
  68. package/dist/search/text.d.ts +37 -0
  69. package/dist/search/text.d.ts.map +1 -0
  70. package/dist/search/types.d.ts +72 -0
  71. package/dist/search/types.d.ts.map +1 -0
  72. package/dist/types/billing.d.ts +20 -0
  73. package/dist/types/billing.d.ts.map +1 -1
  74. package/dist/types/crud.d.ts +47 -1
  75. package/dist/types/crud.d.ts.map +1 -1
  76. package/dist/types/entitlements.d.ts +45 -0
  77. package/dist/types/entitlements.d.ts.map +1 -0
  78. package/dist/types/index.d.ts +4 -3
  79. package/dist/types/index.d.ts.map +1 -1
  80. package/dist/types/org.d.ts +28 -0
  81. package/dist/types/org.d.ts.map +1 -1
  82. package/dist/types/plugins.d.ts +88 -0
  83. package/dist/types/plugins.d.ts.map +1 -1
  84. package/package.json +14 -4
  85. package/src/access/denial.ts +33 -0
  86. package/src/access/engine.test.ts +48 -0
  87. package/src/access/engine.ts +121 -0
  88. package/src/access/index.ts +13 -0
  89. package/src/access/limits.ts +18 -0
  90. package/src/address/index.ts +188 -0
  91. package/src/data/archetype.ts +4 -2
  92. package/src/data/count.test.ts +152 -0
  93. package/src/data/count.ts +131 -0
  94. package/src/data/index.ts +2 -0
  95. package/src/data/refresh.ts +105 -0
  96. package/src/data/resolve.ts +7 -1
  97. package/src/data/supabase.ts +3 -1
  98. package/src/data/types.ts +6 -0
  99. package/src/entity/registry.ts +7 -0
  100. package/src/i18n/shell-translations.ts +345 -2
  101. package/src/index.ts +37 -4
  102. package/src/manifest/app-manifest.schema.json +618 -45
  103. package/src/manifest/index.ts +127 -3
  104. package/src/manifest/serialize.ts +52 -0
  105. package/src/plugin/runtime.ts +5 -1
  106. package/src/search/engine.ts +551 -0
  107. package/src/search/index.ts +25 -0
  108. package/src/search/text.ts +206 -0
  109. package/src/search/types.ts +75 -0
  110. package/src/types/billing.ts +22 -0
  111. package/src/types/crud.ts +48 -1
  112. package/src/types/entitlements.ts +45 -0
  113. package/src/types/index.ts +4 -3
  114. package/src/types/org.ts +29 -0
  115. package/src/types/plugins.ts +83 -0
  116. package/dist/chunk-2NTHNWEH.cjs.map +0 -1
  117. package/dist/chunk-54SRL7AJ.cjs.map +0 -1
  118. package/dist/chunk-5X2VX3RQ.cjs.map +0 -1
  119. package/dist/chunk-CHGX6UYR.js.map +0 -1
  120. package/dist/chunk-KNIVT6XZ.js.map +0 -1
  121. package/dist/chunk-QR7U2URY.cjs.map +0 -1
  122. package/dist/chunk-WKZVSKEU.js.map +0 -1
  123. package/dist/chunk-ZBIWYDAR.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  var chunk56GH3WC2_cjs = require('./chunk-56GH3WC2.cjs');
4
4
  var chunkP5OJUH25_cjs = require('./chunk-P5OJUH25.cjs');
5
- var chunk54SRL7AJ_cjs = require('./chunk-54SRL7AJ.cjs');
6
- var chunk2NTHNWEH_cjs = require('./chunk-2NTHNWEH.cjs');
7
- var chunk5X2VX3RQ_cjs = require('./chunk-5X2VX3RQ.cjs');
8
- var chunkQR7U2URY_cjs = require('./chunk-QR7U2URY.cjs');
5
+ var chunkKSI2L3E4_cjs = require('./chunk-KSI2L3E4.cjs');
6
+ var chunkUKU4RIWM_cjs = require('./chunk-UKU4RIWM.cjs');
7
+ var chunkZOPJB5FN_cjs = require('./chunk-ZOPJB5FN.cjs');
8
+ var chunkCATASHPK_cjs = require('./chunk-CATASHPK.cjs');
9
9
  var chunkAXTWKF5X_cjs = require('./chunk-AXTWKF5X.cjs');
10
10
  var chunk5TKIZVVJ_cjs = require('./chunk-5TKIZVVJ.cjs');
11
- var React2 = require('react');
11
+ var React3 = require('react');
12
12
  var zustand = require('zustand');
13
13
 
14
14
  function _interopNamespace(e) {
@@ -29,7 +29,7 @@ function _interopNamespace(e) {
29
29
  return Object.freeze(n);
30
30
  }
31
31
 
32
- var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
32
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
33
33
 
34
34
  // src/types/plugins.ts
35
35
  var WidgetZone = {
@@ -43,13 +43,104 @@ var WidgetZone = {
43
43
  SETTINGS_AFTER: "settings.after",
44
44
  FLOATING: "shell.floating"
45
45
  };
46
+ function createEventBus() {
47
+ const handlers = /* @__PURE__ */ new Map();
48
+ const bus = {
49
+ emit(event, payload) {
50
+ const set = handlers.get(event);
51
+ if (!set) return;
52
+ for (const handler of Array.from(set)) {
53
+ try {
54
+ handler(payload);
55
+ } catch (err) {
56
+ console.error(`[fayz] event handler for "${event}" threw:`, err);
57
+ }
58
+ }
59
+ },
60
+ on(event, handler) {
61
+ let set = handlers.get(event);
62
+ if (!set) {
63
+ set = /* @__PURE__ */ new Set();
64
+ handlers.set(event, set);
65
+ }
66
+ set.add(handler);
67
+ return () => bus.off(event, handler);
68
+ },
69
+ once(event, handler) {
70
+ const wrapped = (payload) => {
71
+ bus.off(event, wrapped);
72
+ handler(payload);
73
+ };
74
+ return bus.on(event, wrapped);
75
+ },
76
+ off(event, handler) {
77
+ handlers.get(event)?.delete(handler);
78
+ },
79
+ clear(event) {
80
+ if (event) handlers.delete(event);
81
+ else handlers.clear();
82
+ }
83
+ };
84
+ return bus;
85
+ }
86
+ var eventBus = createEventBus();
87
+ function useOnEvent(event, handler, deps = []) {
88
+ const ref = React3__namespace.useRef(handler);
89
+ ref.current = handler;
90
+ React3__namespace.useEffect(
91
+ () => eventBus.on(event, (payload) => ref.current(payload)),
92
+ // eslint-disable-next-line react-hooks/exhaustive-deps
93
+ [event, ...deps]
94
+ );
95
+ }
96
+
97
+ // src/data/refresh.ts
98
+ var DATA_CHANGED_EVENT = "data:changed";
99
+ function matchesDataChange(match, payload) {
100
+ const attributed = payload.table ?? payload.entityKey ?? payload.archetype;
101
+ if (!attributed) return true;
102
+ if (match.table && payload.table && match.table === payload.table) return true;
103
+ if (match.entityKey && payload.entityKey && match.entityKey === payload.entityKey) return true;
104
+ if (match.archetype && payload.archetype && match.archetype === payload.archetype) return true;
105
+ return !match.table && !match.entityKey && !match.archetype;
106
+ }
107
+ var pending = [];
108
+ var flushTimer = null;
109
+ function flush() {
110
+ const batch = pending;
111
+ pending = [];
112
+ flushTimer = null;
113
+ for (const payload of batch) eventBus.emit(DATA_CHANGED_EVENT, payload);
114
+ }
115
+ function emitDataChanged(payload = {}) {
116
+ if (payload.table) {
117
+ chunkKSI2L3E4_cjs.globalCache.invalidate(`${chunkKSI2L3E4_cjs.getActiveTenantId() ?? "_"}:${payload.table}`);
118
+ } else {
119
+ chunkKSI2L3E4_cjs.globalCache.clear();
120
+ }
121
+ pending.push({ op: "unknown", source: "agent", ...payload });
122
+ if (flushTimer) return;
123
+ flushTimer = setTimeout(flush, 120);
124
+ }
125
+ function useDataChanged(match, handler, deps = []) {
126
+ const handlerRef = React3__namespace.useRef(handler);
127
+ handlerRef.current = handler;
128
+ const { table, entityKey, archetype } = match;
129
+ React3__namespace.useEffect(
130
+ () => eventBus.on(DATA_CHANGED_EVENT, (payload) => {
131
+ if (matchesDataChange({ table, entityKey, archetype }, payload)) handlerRef.current(payload);
132
+ }),
133
+ // eslint-disable-next-line react-hooks/exhaustive-deps
134
+ [table, entityKey, archetype, ...deps]
135
+ );
136
+ }
46
137
 
47
138
  // src/plugin/createSafeDataProvider.ts
48
139
  function createSafeDataProvider(makeSupabase, makeMock) {
49
140
  let resolved = null;
50
141
  const get = () => {
51
142
  if (!resolved) {
52
- resolved = chunk54SRL7AJ_cjs.getSupabaseClientOptional() ? makeSupabase() : makeMock();
143
+ resolved = chunkKSI2L3E4_cjs.getSupabaseClientOptional() ? makeSupabase() : makeMock();
53
144
  }
54
145
  return resolved;
55
146
  };
@@ -102,6 +193,92 @@ function maskDigitCount(mask) {
102
193
  for (const ch of mask) if (ch === "#") n++;
103
194
  return n;
104
195
  }
196
+
197
+ // src/address/index.ts
198
+ function normalizePostalCode(value) {
199
+ return (value || "").replace(/\D/g, "");
200
+ }
201
+ function formatPostalCode(value) {
202
+ const digits = normalizePostalCode(value).slice(0, 8);
203
+ return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;
204
+ }
205
+ function isValidPostalCode(value) {
206
+ return normalizePostalCode(value).length === 8;
207
+ }
208
+ var CACHE_KEY = "fayz.postal.cache.v1";
209
+ var memoryCache = /* @__PURE__ */ new Map();
210
+ function readCache(code) {
211
+ const hit = memoryCache.get(code);
212
+ if (hit) return hit;
213
+ try {
214
+ const raw = globalThis.localStorage?.getItem(CACHE_KEY);
215
+ if (!raw) return void 0;
216
+ const all = JSON.parse(raw);
217
+ const stored = all[code];
218
+ if (stored) memoryCache.set(code, stored);
219
+ return stored;
220
+ } catch {
221
+ return void 0;
222
+ }
223
+ }
224
+ function writeCache(code, address) {
225
+ memoryCache.set(code, address);
226
+ try {
227
+ const store = globalThis.localStorage;
228
+ if (!store) return;
229
+ const raw = store.getItem(CACHE_KEY);
230
+ const all = raw ? JSON.parse(raw) : {};
231
+ all[code] = address;
232
+ store.setItem(CACHE_KEY, JSON.stringify(all));
233
+ } catch {
234
+ }
235
+ }
236
+ function clearPostalCache() {
237
+ memoryCache.clear();
238
+ try {
239
+ globalThis.localStorage?.removeItem(CACHE_KEY);
240
+ } catch {
241
+ }
242
+ }
243
+ function createViaCepProvider(options) {
244
+ const fetcher = options?.fetcher ?? globalThis.fetch;
245
+ return {
246
+ async lookup(postalCode) {
247
+ const code = normalizePostalCode(postalCode);
248
+ if (code.length !== 8) return null;
249
+ const response = await fetcher(`https://viacep.com.br/ws/${code}/json/`);
250
+ if (!response.ok) throw new Error(`Consulta de CEP falhou (${response.status})`);
251
+ const data = await response.json();
252
+ if (data.erro === true || data.erro === "true" || !data.localidade) return null;
253
+ return {
254
+ postalCode: code,
255
+ street: data.logradouro ?? "",
256
+ district: data.bairro ?? "",
257
+ city: data.localidade,
258
+ state: (data.uf ?? "").toUpperCase(),
259
+ country: "BR",
260
+ cityCode: data.ibge || void 0
261
+ };
262
+ }
263
+ };
264
+ }
265
+ var _provider = null;
266
+ function setPostalLookupProvider(provider) {
267
+ _provider = provider;
268
+ }
269
+ function getPostalLookupProvider() {
270
+ if (!_provider) _provider = createViaCepProvider();
271
+ return _provider;
272
+ }
273
+ async function lookupPostalCode(postalCode) {
274
+ const code = normalizePostalCode(postalCode);
275
+ if (code.length !== 8) return null;
276
+ const cached = readCache(code);
277
+ if (cached) return cached;
278
+ const address = await getPostalLookupProvider().lookup(code);
279
+ if (address) writeCache(code, address);
280
+ return address;
281
+ }
105
282
  var MANAGED = "data-fayz-seo";
106
283
  function seoOrigin() {
107
284
  return typeof window !== "undefined" ? window.location.origin : "";
@@ -160,7 +337,7 @@ function applySeo(config) {
160
337
  }
161
338
  function useSeo(config) {
162
339
  const key = JSON.stringify(config);
163
- React2.useEffect(() => {
340
+ React3.useEffect(() => {
164
341
  applySeo(config);
165
342
  return () => clearManaged();
166
343
  }, [key]);
@@ -196,7 +373,7 @@ function setDefaultCurrency(code) {
196
373
  }
197
374
  function getActiveLocale() {
198
375
  try {
199
- return chunkQR7U2URY_cjs.getCurrentLocale() || "en";
376
+ return chunkCATASHPK_cjs.getCurrentLocale() || "en";
200
377
  } catch {
201
378
  return "en";
202
379
  }
@@ -263,58 +440,560 @@ function downloadCSV(csv, filename) {
263
440
  function exportCSV(columns, rows, filename) {
264
441
  downloadCSV(buildCSV(columns, rows), filename);
265
442
  }
266
- function createEventBus() {
267
- const handlers = /* @__PURE__ */ new Map();
268
- const bus = {
269
- emit(event, payload) {
270
- const set = handlers.get(event);
271
- if (!set) return;
272
- for (const handler of Array.from(set)) {
273
- try {
274
- handler(payload);
275
- } catch (err) {
276
- console.error(`[fayz] event handler for "${event}" threw:`, err);
277
- }
443
+
444
+ // src/search/text.ts
445
+ var COMBINING_MARKS = /[\u0300-\u036f]/g;
446
+ function foldText(value) {
447
+ if (typeof value !== "string" || value === "") return "";
448
+ return value.normalize("NFD").replace(COMBINING_MARKS, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
449
+ }
450
+ function foldWithMap(value) {
451
+ const out = [];
452
+ const map = [];
453
+ let pendingSpace = false;
454
+ for (let i = 0; i < value.length; i++) {
455
+ const ch = value[i];
456
+ const folded = ch.normalize("NFD").replace(COMBINING_MARKS, "").toLowerCase();
457
+ for (const f of folded) {
458
+ const alnum = f >= "a" && f <= "z" || f >= "0" && f <= "9";
459
+ if (!alnum) {
460
+ pendingSpace = out.length > 0;
461
+ continue;
278
462
  }
279
- },
280
- on(event, handler) {
281
- let set = handlers.get(event);
282
- if (!set) {
283
- set = /* @__PURE__ */ new Set();
284
- handlers.set(event, set);
463
+ if (pendingSpace) {
464
+ out.push(" ");
465
+ map.push(i);
466
+ pendingSpace = false;
285
467
  }
286
- set.add(handler);
287
- return () => bus.off(event, handler);
288
- },
289
- once(event, handler) {
290
- const wrapped = (payload) => {
291
- bus.off(event, wrapped);
292
- handler(payload);
293
- };
294
- return bus.on(event, wrapped);
295
- },
296
- off(event, handler) {
297
- handlers.get(event)?.delete(handler);
298
- },
299
- clear(event) {
300
- if (event) handlers.delete(event);
301
- else handlers.clear();
468
+ out.push(f);
469
+ map.push(i);
302
470
  }
471
+ }
472
+ return { folded: out.join(""), map };
473
+ }
474
+ function digitsOf(value) {
475
+ return typeof value === "string" ? value.replace(/\D+/g, "") : "";
476
+ }
477
+ var MIN_DIGIT_QUERY = 4;
478
+ function normalizeQuery(raw) {
479
+ const folded = foldText(raw);
480
+ const tokens = folded ? folded.split(" ").filter(Boolean) : [];
481
+ const digits = raw.replace(/\D+/g, "");
482
+ let anchor = "";
483
+ for (const token of tokens) if (token.length > anchor.length) anchor = token;
484
+ return {
485
+ raw,
486
+ folded,
487
+ tokens,
488
+ digits: digits.length >= MIN_DIGIT_QUERY ? digits : "",
489
+ anchor
303
490
  };
304
- return bus;
305
491
  }
306
- var eventBus = createEventBus();
307
- function useOnEvent(event, handler, deps = []) {
308
- const ref = React2__namespace.useRef(handler);
309
- ref.current = handler;
310
- React2__namespace.useEffect(
311
- () => eventBus.on(event, (payload) => ref.current(payload)),
312
- // eslint-disable-next-line react-hooks/exhaustive-deps
313
- [event, ...deps]
314
- );
492
+ function bigrams(value) {
493
+ if (value.length < 2) return value ? [value] : [];
494
+ const out = [];
495
+ for (let i = 0; i < value.length - 1; i++) out.push(value.slice(i, i + 2));
496
+ return out;
497
+ }
498
+ function similarity(a, b) {
499
+ if (!a || !b) return 0;
500
+ if (a === b) return 1;
501
+ const left = bigrams(a);
502
+ const right = bigrams(b);
503
+ if (left.length === 0 || right.length === 0) return 0;
504
+ const pool = /* @__PURE__ */ new Map();
505
+ for (const g of left) pool.set(g, (pool.get(g) ?? 0) + 1);
506
+ let shared = 0;
507
+ for (const g of right) {
508
+ const count = pool.get(g);
509
+ if (count) {
510
+ shared++;
511
+ pool.set(g, count - 1);
512
+ }
513
+ }
514
+ return 2 * shared / (left.length + right.length);
515
+ }
516
+ function wordSimilarity(text, token) {
517
+ let best = similarity(text, token);
518
+ for (const word of text.split(" ")) {
519
+ if (!word) continue;
520
+ const s = similarity(word, token);
521
+ if (s > best) best = s;
522
+ }
523
+ return best;
524
+ }
525
+ var FUZZY_FLOOR = 0.62;
526
+ function scoreCandidate(query, candidate) {
527
+ const { folded, tokens } = query;
528
+ if (!folded || tokens.length === 0) return 0;
529
+ const title = candidate.title;
530
+ const haystack = candidate.haystack || title;
531
+ let phrase = 0;
532
+ if (title === folded) phrase = 1;
533
+ else if (title.startsWith(folded)) phrase = 0.94;
534
+ else if (title.includes(" " + folded)) phrase = 0.88;
535
+ else if (title.includes(folded)) phrase = 0.76;
536
+ else if (haystack.startsWith(folded) || haystack.includes(" " + folded)) phrase = 0.7;
537
+ else if (haystack.includes(folded)) phrase = 0.62;
538
+ let tokenTotal = 0;
539
+ let fuzzyUsed = false;
540
+ for (const token of tokens) {
541
+ let best = 0;
542
+ if (title.startsWith(token)) best = 0.95;
543
+ else if (title.includes(" " + token)) best = 0.85;
544
+ else if (title.includes(token)) best = 0.7;
545
+ else if (haystack.startsWith(token) || haystack.includes(" " + token)) best = 0.6;
546
+ else if (haystack.includes(token)) best = 0.5;
547
+ else {
548
+ const sim = wordSimilarity(title, token);
549
+ if (sim >= FUZZY_FLOOR) {
550
+ best = 0.45 * sim;
551
+ fuzzyUsed = true;
552
+ }
553
+ }
554
+ if (best === 0) return phrase > 0 ? phrase : 0;
555
+ tokenTotal += best;
556
+ }
557
+ let tokenScore = tokenTotal / tokens.length;
558
+ if (fuzzyUsed) tokenScore *= 0.8;
559
+ let score = Math.max(phrase, tokenScore);
560
+ if (query.digits && candidate.digits && candidate.digits.includes(query.digits)) {
561
+ score = Math.max(score, 0.72 + Math.min(0.2, query.digits.length / 50));
562
+ }
563
+ if (score === 0) return 0;
564
+ const brevity = 1 / (1 + Math.max(0, title.length - folded.length) / 40);
565
+ return score * 0.97 + brevity * 0.03;
566
+ }
567
+ function highlightRanges(text, query) {
568
+ if (!text || query.tokens.length === 0) return [];
569
+ const { folded, map } = foldWithMap(text);
570
+ if (!folded) return [];
571
+ const spans = [];
572
+ const needles = query.tokens.length > 1 ? [query.folded, ...query.tokens] : [query.folded];
573
+ for (const needle of needles) {
574
+ if (!needle) continue;
575
+ let from = 0;
576
+ for (; ; ) {
577
+ const at = folded.indexOf(needle, from);
578
+ if (at === -1) break;
579
+ const start = map[at];
580
+ const endChar = map[at + needle.length - 1];
581
+ if (start !== void 0 && endChar !== void 0) spans.push([start, endChar + 1]);
582
+ from = at + needle.length;
583
+ }
584
+ }
585
+ if (spans.length === 0) return [];
586
+ spans.sort((a, b) => a[0] - b[0]);
587
+ const merged = [spans[0]];
588
+ for (const span of spans.slice(1)) {
589
+ const last = merged[merged.length - 1];
590
+ if (span[0] <= last[1]) last[1] = Math.max(last[1], span[1]);
591
+ else merged.push(span);
592
+ }
593
+ return merged;
594
+ }
595
+
596
+ // src/search/engine.ts
597
+ var MIN_QUERY_LENGTH = 2;
598
+ var DEFAULT_LIMIT = 30;
599
+ var DEFAULT_PER_TARGET = 5;
600
+ var SCAN_CONCURRENCY = 16;
601
+ var TARGET_TIMEOUT_MS = 3e3;
602
+ var CACHE_TTL_MS = 3e4;
603
+ var CACHE_MAX_ENTRIES = 40;
604
+ var RPC_NAME = "fayz_global_search";
605
+ var indexAvailable = null;
606
+ function setSearchIndexAvailable(value) {
607
+ indexAvailable = value;
608
+ }
609
+ function isSearchIndexAvailable() {
610
+ return indexAvailable;
611
+ }
612
+ function camelOf(key) {
613
+ return key.replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
614
+ }
615
+ function snakeOf(key) {
616
+ return key.replace(/[A-Z]/g, (c) => "_" + c.toLowerCase());
617
+ }
618
+ function readField(row, key) {
619
+ if (key in row) return row[key];
620
+ const camel = camelOf(key);
621
+ if (camel in row) return row[camel];
622
+ const snake = snakeOf(key);
623
+ if (snake in row) return row[snake];
624
+ return void 0;
625
+ }
626
+ function asText(value) {
627
+ if (typeof value === "string") return value;
628
+ if (typeof value === "number") return String(value);
629
+ if (Array.isArray(value)) return value.filter((v) => typeof v === "string").join(" ");
630
+ return "";
631
+ }
632
+ function searchableKeys(entity) {
633
+ const declared = entity.data?.searchColumns ?? entity.fields.filter((f) => f.searchable).map((f) => f.key);
634
+ const keys = [...declared];
635
+ const display = entity.displayField ?? "name";
636
+ if (!keys.includes(display)) keys.unshift(display);
637
+ const subtitle = entity.subtitleField;
638
+ if (subtitle && !keys.includes(subtitle)) keys.push(subtitle);
639
+ return keys;
640
+ }
641
+ var DIGIT_FIELD_TYPES = /* @__PURE__ */ new Set(["phone", "number"]);
642
+ function digitKeys(entity) {
643
+ const keys = entity.fields.filter((f) => DIGIT_FIELD_TYPES.has(f.type) || /phone|document|cpf|cnpj|zip|postal|sku|code|reference/i.test(f.key)).map((f) => f.key);
644
+ for (const extra of ["phone", "document_number", "sku", "reference_number", "postal_code"]) {
645
+ if (!keys.includes(extra)) keys.push(extra);
646
+ }
647
+ return keys;
648
+ }
649
+ function titleOf(entity, row) {
650
+ const display = entity.displayField ?? "name";
651
+ const primary = asText(readField(row, display));
652
+ if (primary) return primary;
653
+ for (const field of entity.fields) {
654
+ if (field.type === "text" || field.type === "email") {
655
+ const value = asText(readField(row, field.key));
656
+ if (value) return value;
657
+ }
658
+ }
659
+ return asText(row.id) || "\u2014";
660
+ }
661
+ function subtitleOf(entity, row, title) {
662
+ const distinct = (value) => {
663
+ if (!value || foldText(value) === foldText(title)) return void 0;
664
+ return value.length > 90 ? value.slice(0, 89) + "\u2026" : value;
665
+ };
666
+ const declared = entity.subtitleField;
667
+ if (declared) {
668
+ const value = distinct(asText(readField(row, declared)));
669
+ if (value) return value;
670
+ }
671
+ for (const key of ["email", "phone", "sku", "reference_number", "document_number", "description"]) {
672
+ const value = distinct(asText(readField(row, key)));
673
+ if (value) return value;
674
+ }
675
+ return void 0;
676
+ }
677
+ function hitFromRow(target, row, query) {
678
+ const id = asText(row.id);
679
+ if (!id) return null;
680
+ const entity = target.entity;
681
+ const title = titleOf(entity, row);
682
+ const parts = [title];
683
+ for (const key of searchableKeys(entity)) {
684
+ const value = asText(readField(row, key));
685
+ if (value) parts.push(value);
686
+ }
687
+ let digits = "";
688
+ for (const key of digitKeys(entity)) {
689
+ const value = readField(row, key);
690
+ if (typeof value === "string" || typeof value === "number") digits += digitsOf(String(value));
691
+ }
692
+ const score = scoreCandidate(query, {
693
+ title: foldText(title),
694
+ haystack: foldText(parts.join(" ")),
695
+ digits
696
+ });
697
+ if (score === 0) return null;
698
+ return {
699
+ uid: `${target.key}:${id}`,
700
+ id,
701
+ key: target.key,
702
+ group: target.label,
703
+ icon: target.icon ?? entity.icon,
704
+ title,
705
+ subtitle: subtitleOf(entity, row, title),
706
+ score: score * (target.boost ?? 1),
707
+ archetype: entity.data?.archetype,
708
+ archetypeKind: entity.data?.archetypeKind,
709
+ table: entity.data?.table,
710
+ record: row
711
+ };
712
+ }
713
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
714
+ function recordIdentity(hit) {
715
+ if (UUID.test(hit.id)) return hit.id;
716
+ return `${hit.table ?? hit.key}#${hit.id}`;
717
+ }
718
+ function assemble(query, hits, targets, opts) {
719
+ const seen = /* @__PURE__ */ new Set();
720
+ const unique = [];
721
+ for (const hit of hits.slice().sort((a, b) => b.score - a.score || a.title.localeCompare(b.title))) {
722
+ const identity = recordIdentity(hit);
723
+ if (seen.has(identity)) continue;
724
+ seen.add(identity);
725
+ unique.push(hit);
726
+ }
727
+ const byKey = /* @__PURE__ */ new Map();
728
+ const kept = [];
729
+ const capped = /* @__PURE__ */ new Set();
730
+ for (const hit of unique) {
731
+ const bucket = byKey.get(hit.key) ?? [];
732
+ if (bucket.length >= opts.perTarget) {
733
+ capped.add(hit.key);
734
+ continue;
735
+ }
736
+ bucket.push(hit);
737
+ byKey.set(hit.key, bucket);
738
+ kept.push(hit);
739
+ }
740
+ const limited = kept.slice(0, opts.limit);
741
+ const order = new Map(targets.map((t, i) => [t.key, i]));
742
+ const groups = [];
743
+ for (const hit of limited) {
744
+ let group = groups.find((g) => g.key === hit.key);
745
+ if (!group) {
746
+ group = { key: hit.key, label: hit.group, icon: hit.icon, hits: [], hasMore: capped.has(hit.key) };
747
+ groups.push(group);
748
+ }
749
+ group.hits.push(hit);
750
+ }
751
+ groups.sort((a, b) => (b.hits[0]?.score ?? 0) - (a.hits[0]?.score ?? 0) || (order.get(a.key) ?? 99) - (order.get(b.key) ?? 99));
752
+ return {
753
+ query,
754
+ hits: limited,
755
+ groups,
756
+ via: opts.via,
757
+ failed: opts.failed,
758
+ elapsedMs: opts.elapsedMs,
759
+ partial: opts.partial ?? false
760
+ };
761
+ }
762
+ var cache = [];
763
+ function scopeKey(targets) {
764
+ return `${chunkKSI2L3E4_cjs.getActiveTenantId() ?? "_"}|${targets.map((t) => t.key).sort().join(",")}`;
765
+ }
766
+ function cacheGet(scope, folded) {
767
+ const now = Date.now();
768
+ return cache.find((e) => e.scope === scope && e.folded === folded && now - e.at < CACHE_TTL_MS);
769
+ }
770
+ function cachePrefix(scope, folded) {
771
+ const now = Date.now();
772
+ let best;
773
+ for (const entry of cache) {
774
+ if (entry.scope !== scope || !entry.complete) continue;
775
+ if (now - entry.at >= CACHE_TTL_MS) continue;
776
+ if (!folded.startsWith(entry.folded)) continue;
777
+ if (!best || entry.folded.length > best.folded.length) best = entry;
778
+ }
779
+ return best;
780
+ }
781
+ function cacheSet(entry) {
782
+ const at = cache.findIndex((e) => e.scope === entry.scope && e.folded === entry.folded);
783
+ if (at >= 0) cache.splice(at, 1);
784
+ cache.unshift(entry);
785
+ if (cache.length > CACHE_MAX_ENTRIES) cache.length = CACHE_MAX_ENTRIES;
786
+ }
787
+ function clearSearchCache() {
788
+ cache.length = 0;
789
+ }
790
+ function isMissingFunction(error) {
791
+ if (!error) return false;
792
+ if (error.code === "PGRST202") return true;
793
+ const message = (error.message ?? "").toLowerCase();
794
+ return message.includes(RPC_NAME) && (message.includes("does not exist") || message.includes("not find"));
795
+ }
796
+ async function searchViaIndex(query, targets, perTarget, limit) {
797
+ const client = chunkKSI2L3E4_cjs.getSupabaseClientOptional();
798
+ const tenantId = chunkKSI2L3E4_cjs.getActiveTenantId();
799
+ if (!client || !tenantId) return { hits: [], ok: false };
800
+ const byKey = new Map(targets.map((t) => [t.key, t]));
801
+ const { data, error } = await client.rpc(RPC_NAME, {
802
+ p_query: query.raw,
803
+ p_tenant_id: tenantId,
804
+ p_entity_keys: targets.map((t) => t.key),
805
+ p_per_source: perTarget * 3,
806
+ p_limit: limit * 3
807
+ });
808
+ if (error) {
809
+ if (isMissingFunction(error)) {
810
+ indexAvailable = false;
811
+ return { hits: [], ok: false };
812
+ }
813
+ throw error;
814
+ }
815
+ indexAvailable = true;
816
+ const rows = Array.isArray(data) ? data : [];
817
+ const hits = [];
818
+ for (const row of rows) {
819
+ const target = byKey.get(row.entity_key);
820
+ if (!target || !row.record_id) continue;
821
+ const title = row.title ?? "";
822
+ const local = scoreCandidate(query, {
823
+ title: foldText(title),
824
+ haystack: foldText(`${title} ${row.subtitle ?? ""}`),
825
+ digits: digitsOf(row.subtitle ?? "") + digitsOf(title)
826
+ });
827
+ const score = local > 0 ? local : Math.min(0.55, row.score ?? 0.4);
828
+ hits.push({
829
+ uid: `${target.key}:${row.record_id}`,
830
+ id: row.record_id,
831
+ key: target.key,
832
+ group: target.label,
833
+ icon: target.icon ?? target.entity.icon,
834
+ title: title || "\u2014",
835
+ subtitle: row.subtitle ?? void 0,
836
+ score: score * (target.boost ?? 1),
837
+ archetype: target.entity.data?.archetype,
838
+ archetypeKind: target.entity.data?.archetypeKind,
839
+ table: target.entity.data?.table
840
+ });
841
+ }
842
+ return { hits, ok: true };
843
+ }
844
+ async function withTimeout(promise, ms) {
845
+ let timer;
846
+ try {
847
+ return await Promise.race([
848
+ promise,
849
+ new Promise((_, reject) => {
850
+ timer = setTimeout(() => reject(new Error("search target timed out")), ms);
851
+ })
852
+ ]);
853
+ } finally {
854
+ if (timer) clearTimeout(timer);
855
+ }
856
+ }
857
+ async function mapLimited(items, limit, fn) {
858
+ const results = new Array(items.length);
859
+ let cursor = 0;
860
+ const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
861
+ for (; ; ) {
862
+ const index = cursor++;
863
+ if (index >= items.length) return;
864
+ const item = items[index];
865
+ try {
866
+ results[index] = { ok: true, value: await fn(item) };
867
+ } catch {
868
+ results[index] = { ok: false, item };
869
+ }
870
+ }
871
+ });
872
+ await Promise.all(workers);
873
+ return results;
874
+ }
875
+ async function searchViaScan(query, targets, perTarget, onProgress) {
876
+ const multiWord = query.tokens.length > 1;
877
+ const phrase = query.folded;
878
+ const token = query.anchor.length >= MIN_QUERY_LENGTH ? query.anchor : phrase;
879
+ const pageSize = Math.min(perTarget * 3, 24);
880
+ const widePageSize = Math.min(perTarget * 6, 40);
881
+ const searchable = targets.filter((t) => searchableKeys(t.entity).length > 0);
882
+ const running = [];
883
+ const round = (search, size) => mapLimited(searchable, SCAN_CONCURRENCY, async (target) => {
884
+ const provider = chunkKSI2L3E4_cjs.resolveDataProvider(target.entity, target.mockData);
885
+ const result = await withTimeout(
886
+ provider.list({ search, pageSize: size, countMode: "none" }),
887
+ TARGET_TIMEOUT_MS
888
+ );
889
+ const rows = result.data;
890
+ const hits = rows.map((row) => hitFromRow(target, row, query)).filter((h) => h !== null);
891
+ if (hits.length && onProgress) {
892
+ running.push(...hits);
893
+ onProgress(running.slice());
894
+ }
895
+ return { target, hits };
896
+ });
897
+ const collect = (settled) => {
898
+ const hits = [];
899
+ const failed = [];
900
+ for (const outcome of settled) {
901
+ if (outcome.ok) hits.push(...outcome.value.hits);
902
+ else failed.push(outcome.item.key);
903
+ }
904
+ return { hits, failed };
905
+ };
906
+ const first = collect(await round(phrase, pageSize));
907
+ if (first.hits.length > 0 || !multiWord || token === phrase) return first;
908
+ const second = collect(await round(token, widePageSize));
909
+ return { hits: second.hits, failed: [.../* @__PURE__ */ new Set([...first.failed, ...second.failed])] };
910
+ }
911
+ async function searchEverything(rawQuery, options) {
912
+ const started = Date.now();
913
+ const query = normalizeQuery(rawQuery);
914
+ const targets = options.targets;
915
+ const limit = options.limit ?? DEFAULT_LIMIT;
916
+ const perTarget = options.perTarget ?? DEFAULT_PER_TARGET;
917
+ const empty = (via2) => assemble(rawQuery, [], targets, { via: via2, failed: [], elapsedMs: Date.now() - started, perTarget, limit });
918
+ if (query.folded.length < MIN_QUERY_LENGTH || targets.length === 0) return empty("cache");
919
+ const scope = scopeKey(targets);
920
+ const exact = cacheGet(scope, query.folded);
921
+ if (exact) {
922
+ return assemble(rawQuery, exact.hits, targets, {
923
+ via: "cache",
924
+ failed: [],
925
+ elapsedMs: Date.now() - started,
926
+ perTarget,
927
+ limit
928
+ });
929
+ }
930
+ if (options.onPartial) {
931
+ const prefix = cachePrefix(scope, query.folded);
932
+ if (prefix) {
933
+ const rescored = prefix.hits.map((hit) => {
934
+ const score = scoreCandidate(query, {
935
+ title: foldText(hit.title),
936
+ haystack: foldText(`${hit.title} ${hit.subtitle ?? ""}`),
937
+ digits: digitsOf(hit.subtitle ?? "")
938
+ });
939
+ return score > 0 ? { ...hit, score } : null;
940
+ }).filter((h) => h !== null);
941
+ options.onPartial(assemble(rawQuery, rescored, targets, {
942
+ via: "cache",
943
+ failed: [],
944
+ elapsedMs: Date.now() - started,
945
+ perTarget,
946
+ limit,
947
+ partial: true
948
+ }));
949
+ }
950
+ }
951
+ let hits = [];
952
+ let failed = [];
953
+ let via = "scan";
954
+ if (!options.forceScan && indexAvailable !== false) {
955
+ try {
956
+ const indexed = await searchViaIndex(query, targets, perTarget, limit);
957
+ if (indexed.ok) {
958
+ hits = indexed.hits;
959
+ via = "index";
960
+ }
961
+ } catch {
962
+ }
963
+ }
964
+ if (via !== "index") {
965
+ const emit = options.onPartial;
966
+ const scanned = await searchViaScan(query, targets, perTarget, emit ? (running) => emit(assemble(rawQuery, running, targets, {
967
+ via: "scan",
968
+ failed: [],
969
+ elapsedMs: Date.now() - started,
970
+ perTarget,
971
+ limit,
972
+ partial: true
973
+ })) : void 0);
974
+ hits = scanned.hits;
975
+ failed = scanned.failed;
976
+ }
977
+ if (options.signal?.aborted) return empty(via);
978
+ const result = assemble(rawQuery, hits, targets, {
979
+ via,
980
+ failed,
981
+ elapsedMs: Date.now() - started,
982
+ perTarget,
983
+ limit
984
+ });
985
+ cacheSet({
986
+ scope,
987
+ folded: query.folded,
988
+ at: Date.now(),
989
+ // Only an uncapped answer is a sound superset for longer queries.
990
+ complete: failed.length === 0 && !result.groups.some((g) => g.hasMore),
991
+ hits
992
+ });
993
+ return result;
315
994
  }
316
995
  function UnknownBlock({ type }) {
317
- return React2__namespace.createElement(
996
+ return React3__namespace.createElement(
318
997
  "div",
319
998
  {
320
999
  style: {
@@ -329,16 +1008,16 @@ function UnknownBlock({ type }) {
329
1008
  );
330
1009
  }
331
1010
  function BlockRenderer({ node }) {
332
- const Comp = chunk5X2VX3RQ_cjs.getBlock(node.type);
1011
+ const Comp = chunkZOPJB5FN_cjs.getBlock(node.type);
333
1012
  const childEls = node.children?.length ? node.children.map(
334
- (child, i) => React2__namespace.createElement(BlockRenderer, { key: child.id ?? `${child.type}-${i}`, node: child })
1013
+ (child, i) => React3__namespace.createElement(BlockRenderer, { key: child.id ?? `${child.type}-${i}`, node: child })
335
1014
  ) : null;
336
- if (!Comp) return React2__namespace.createElement(UnknownBlock, { type: node.type });
337
- return React2__namespace.createElement(Comp, { ...node.props ?? {}, node }, childEls);
1015
+ if (!Comp) return React3__namespace.createElement(UnknownBlock, { type: node.type });
1016
+ return React3__namespace.createElement(Comp, { ...node.props ?? {}, node }, childEls);
338
1017
  }
339
1018
  function renderBlocks(nodes) {
340
1019
  return nodes.map(
341
- (node, i) => React2__namespace.createElement(BlockRenderer, { key: node.id ?? `${node.type}-${i}`, node })
1020
+ (node, i) => React3__namespace.createElement(BlockRenderer, { key: node.id ?? `${node.type}-${i}`, node })
342
1021
  );
343
1022
  }
344
1023
  function BlockChildren({ node }) {
@@ -347,7 +1026,7 @@ function BlockChildren({ node }) {
347
1026
  }
348
1027
 
349
1028
  // src/manifest/index.ts
350
- var CURRENT_MANIFEST_VERSION = 2;
1029
+ var CURRENT_MANIFEST_VERSION = 3;
351
1030
  var migrations = /* @__PURE__ */ new Map();
352
1031
  var supportedBackendProviders = ["supabase", "fayz-api", "fayz-shop", "mock", "custom"];
353
1032
  var supportedPageSections = /* @__PURE__ */ new Set(["main", "secondary", "settings"]);
@@ -361,7 +1040,10 @@ var allowedManifestKeys = /* @__PURE__ */ new Set([
361
1040
  "permissions",
362
1041
  "billing",
363
1042
  "entities",
364
- "surfaces"
1043
+ "surfaces",
1044
+ "limitDeclarations",
1045
+ "agent",
1046
+ "contractHash"
365
1047
  ]);
366
1048
  var allowedBackendKeys = /* @__PURE__ */ new Set(["provider", "projectRef", "url", "adapterId", "options"]);
367
1049
  var allowedSurfaceKeys = /* @__PURE__ */ new Set(["scaffold", "options", "plugins", "pages"]);
@@ -373,6 +1055,7 @@ var manifestIdPattern = /^[a-z0-9][a-z0-9-]*$/;
373
1055
  function registerManifestMigration(fromVersion, fn) {
374
1056
  migrations.set(fromVersion, fn);
375
1057
  }
1058
+ registerManifestMigration(2, (m) => m);
376
1059
  function migrateManifest(input) {
377
1060
  let m = { ...input };
378
1061
  let version = typeof m.manifestVersion === "number" ? m.manifestVersion : 1;
@@ -410,6 +1093,21 @@ function validateManifest(m) {
410
1093
  validateLooseObject(manifest.theme, "manifest.theme", problems);
411
1094
  validateLooseObject(manifest.permissions, "manifest.permissions", problems);
412
1095
  validateLooseObject(manifest.billing, "manifest.billing", problems);
1096
+ validateLooseObject(manifest.agent, "manifest.agent", problems);
1097
+ if (manifest.contractHash !== void 0 && !isNonEmptyString(manifest.contractHash)) {
1098
+ problems.push("manifest.contractHash must be a non-empty string");
1099
+ }
1100
+ if (manifest.limitDeclarations !== void 0) {
1101
+ if (!Array.isArray(manifest.limitDeclarations)) {
1102
+ problems.push("manifest.limitDeclarations must be an array");
1103
+ } else {
1104
+ manifest.limitDeclarations.forEach((decl, index) => {
1105
+ if (!isRecord(decl) || !isNonEmptyString(decl.key) || !isNonEmptyString(decl.table)) {
1106
+ problems.push(`manifest.limitDeclarations[${index}] must declare key and table`);
1107
+ }
1108
+ });
1109
+ }
1110
+ }
413
1111
  if (manifest.entities !== void 0) {
414
1112
  if (!Array.isArray(manifest.entities)) {
415
1113
  problems.push("manifest.entities must be an array");
@@ -570,7 +1268,7 @@ function validateBlockManifest(block, path, problems) {
570
1268
  function addUnsupportedKeys(value, allowedKeys, path, problems) {
571
1269
  for (const key of Object.keys(value)) {
572
1270
  if (!allowedKeys.has(key)) {
573
- problems.push(`${path}.${key} is not part of AppManifest v2`);
1271
+ problems.push(`${path}.${key} is not part of AppManifest v${CURRENT_MANIFEST_VERSION}`);
574
1272
  }
575
1273
  }
576
1274
  }
@@ -591,113 +1289,717 @@ function isNonEmptyString(value) {
591
1289
  return typeof value === "string" && value.trim().length > 0;
592
1290
  }
593
1291
 
1292
+ // src/manifest/serialize.ts
1293
+ function sortValue(value) {
1294
+ if (Array.isArray(value)) return value.map(sortValue);
1295
+ if (value !== null && typeof value === "object") {
1296
+ const record = value;
1297
+ const out = {};
1298
+ for (const key of Object.keys(record).sort()) {
1299
+ const v = record[key];
1300
+ if (v !== void 0) out[key] = sortValue(v);
1301
+ }
1302
+ return out;
1303
+ }
1304
+ return value;
1305
+ }
1306
+ function serializeManifest(manifest) {
1307
+ const { contractHash: _omit, ...rest } = manifest;
1308
+ return `${JSON.stringify(sortValue(rest), null, 2)}
1309
+ `;
1310
+ }
1311
+ async function computeContractHash(manifest) {
1312
+ const bytes = new TextEncoder().encode(serializeManifest(manifest));
1313
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
1314
+ return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
1315
+ }
1316
+ async function serializeManifestWithHash(manifest) {
1317
+ const contractHash = await computeContractHash(manifest);
1318
+ const { contractHash: _omit, ...rest } = manifest;
1319
+ return `${JSON.stringify(sortValue({ ...rest, contractHash }), null, 2)}
1320
+ `;
1321
+ }
1322
+
594
1323
  // src/manifest/app-manifest.schema.json
595
1324
  var app_manifest_schema_default = {
596
1325
  $schema: "https://json-schema.org/draft/2020-12/schema",
597
- $id: "https://fayz.ai/schemas/app-manifest/v2.json",
1326
+ $id: "https://fayz.ai/schemas/app-manifest/v3.json",
598
1327
  title: "Fayz AppManifest",
599
1328
  description: "The canonical, JSON-serializable definition of a Fayz app. Code is referenced by registry id; never inlined.",
600
1329
  type: "object",
601
- required: ["manifestVersion", "id", "name", "surfaces"],
1330
+ required: [
1331
+ "manifestVersion",
1332
+ "id",
1333
+ "name",
1334
+ "surfaces"
1335
+ ],
602
1336
  additionalProperties: false,
603
1337
  properties: {
604
1338
  manifestVersion: {
605
1339
  type: "integer",
606
- const: 2,
1340
+ const: 3,
607
1341
  description: "Current AppManifest schema version. Older or newer versions require an explicit SDK migration before validation."
608
1342
  },
609
- id: { type: "string", minLength: 1, pattern: "^[a-z0-9][a-z0-9-]*$" },
610
- name: { type: "string", minLength: 1 },
1343
+ id: {
1344
+ type: "string",
1345
+ minLength: 1,
1346
+ pattern: "^[a-z0-9][a-z0-9-]*$"
1347
+ },
1348
+ name: {
1349
+ type: "string",
1350
+ minLength: 1
1351
+ },
611
1352
  backend: {
612
1353
  type: "object",
613
1354
  additionalProperties: false,
614
- required: ["provider"],
1355
+ required: [
1356
+ "provider"
1357
+ ],
615
1358
  properties: {
616
- provider: { enum: ["supabase", "fayz-api", "fayz-shop", "mock", "custom"] },
617
- projectRef: { type: "string", minLength: 1 },
618
- url: { type: "string", minLength: 1 },
619
- adapterId: { type: "string", minLength: 1 },
620
- options: { type: "object" }
1359
+ provider: {
1360
+ enum: [
1361
+ "supabase",
1362
+ "fayz-api",
1363
+ "fayz-shop",
1364
+ "mock",
1365
+ "custom"
1366
+ ]
1367
+ },
1368
+ projectRef: {
1369
+ type: "string",
1370
+ minLength: 1
1371
+ },
1372
+ url: {
1373
+ type: "string",
1374
+ minLength: 1
1375
+ },
1376
+ adapterId: {
1377
+ type: "string",
1378
+ minLength: 1
1379
+ },
1380
+ options: {
1381
+ type: "object"
1382
+ }
1383
+ }
1384
+ },
1385
+ locale: {
1386
+ type: "object"
1387
+ },
1388
+ theme: {
1389
+ type: "object"
1390
+ },
1391
+ permissions: {
1392
+ type: "object"
1393
+ },
1394
+ billing: {
1395
+ type: "object"
1396
+ },
1397
+ entities: {
1398
+ type: "array",
1399
+ items: {
1400
+ type: "object"
621
1401
  }
622
1402
  },
623
- locale: { type: "object" },
624
- theme: { type: "object" },
625
- permissions: { type: "object" },
626
- billing: { type: "object" },
627
- entities: { type: "array", items: { type: "object" } },
628
1403
  surfaces: {
629
1404
  type: "object",
630
1405
  minProperties: 1,
631
- additionalProperties: { $ref: "#/$defs/surface" }
1406
+ additionalProperties: {
1407
+ $ref: "#/$defs/surface"
1408
+ }
1409
+ },
1410
+ limitDeclarations: {
1411
+ type: "array",
1412
+ description: "Resolved 4-layer limit-declaration merge (core < entity-derived < plugin < app) so server runtimes count exactly what the client counts.",
1413
+ items: {
1414
+ type: "object",
1415
+ required: [
1416
+ "key",
1417
+ "table"
1418
+ ],
1419
+ additionalProperties: false,
1420
+ properties: {
1421
+ key: {
1422
+ type: "string",
1423
+ minLength: 1
1424
+ },
1425
+ label: {
1426
+ type: "string"
1427
+ },
1428
+ table: {
1429
+ type: "string",
1430
+ minLength: 1
1431
+ },
1432
+ kindFilter: {
1433
+ type: "string"
1434
+ },
1435
+ period: {
1436
+ enum: [
1437
+ "month",
1438
+ "total"
1439
+ ]
1440
+ }
1441
+ }
1442
+ }
1443
+ },
1444
+ agent: {
1445
+ $ref: "#/$defs/agentContract"
1446
+ },
1447
+ contractHash: {
1448
+ type: "string",
1449
+ minLength: 1,
1450
+ description: "sha256 of the canonical serialization (excluding this field)."
632
1451
  }
633
1452
  },
634
1453
  $defs: {
635
1454
  surface: {
636
1455
  type: "object",
637
- required: ["scaffold"],
1456
+ required: [
1457
+ "scaffold"
1458
+ ],
638
1459
  additionalProperties: false,
639
1460
  properties: {
640
- scaffold: { type: "string", minLength: 1 },
641
- options: { type: "object" },
642
- plugins: { type: "array", items: { $ref: "#/$defs/pluginRef" } },
643
- pages: { type: "array", items: { $ref: "#/$defs/page" } }
1461
+ scaffold: {
1462
+ type: "string",
1463
+ minLength: 1
1464
+ },
1465
+ options: {
1466
+ type: "object"
1467
+ },
1468
+ plugins: {
1469
+ type: "array",
1470
+ items: {
1471
+ $ref: "#/$defs/pluginRef"
1472
+ }
1473
+ },
1474
+ pages: {
1475
+ type: "array",
1476
+ items: {
1477
+ $ref: "#/$defs/page"
1478
+ }
1479
+ }
644
1480
  }
645
1481
  },
646
1482
  pluginRef: {
647
1483
  type: "object",
648
- required: ["id"],
1484
+ required: [
1485
+ "id"
1486
+ ],
649
1487
  additionalProperties: false,
650
1488
  properties: {
651
- id: { type: "string", minLength: 1 },
652
- config: { type: "object" },
653
- enabled: { type: "boolean" }
1489
+ id: {
1490
+ type: "string",
1491
+ minLength: 1
1492
+ },
1493
+ config: {
1494
+ type: "object"
1495
+ },
1496
+ enabled: {
1497
+ type: "boolean"
1498
+ }
654
1499
  }
655
1500
  },
656
1501
  page: {
657
1502
  type: "object",
658
- required: ["path"],
1503
+ required: [
1504
+ "path"
1505
+ ],
659
1506
  additionalProperties: false,
660
1507
  description: "Exactly one of blocks/entity/component must be set.",
661
1508
  properties: {
662
- path: { type: "string", minLength: 1 },
663
- label: { type: "string" },
664
- icon: { type: "string" },
665
- section: { enum: ["main", "secondary", "settings"] },
666
- blocks: { type: "array", items: { $ref: "#/$defs/block" } },
667
- entity: { type: "string", minLength: 1 },
668
- component: { type: "string", minLength: 1 },
1509
+ path: {
1510
+ type: "string",
1511
+ minLength: 1
1512
+ },
1513
+ label: {
1514
+ type: "string"
1515
+ },
1516
+ icon: {
1517
+ type: "string"
1518
+ },
1519
+ section: {
1520
+ enum: [
1521
+ "main",
1522
+ "secondary",
1523
+ "settings"
1524
+ ]
1525
+ },
1526
+ blocks: {
1527
+ type: "array",
1528
+ items: {
1529
+ $ref: "#/$defs/block"
1530
+ }
1531
+ },
1532
+ entity: {
1533
+ type: "string",
1534
+ minLength: 1
1535
+ },
1536
+ component: {
1537
+ type: "string",
1538
+ minLength: 1
1539
+ },
669
1540
  permission: {
670
1541
  type: "object",
671
- required: ["feature", "action"],
1542
+ required: [
1543
+ "feature",
1544
+ "action"
1545
+ ],
672
1546
  additionalProperties: false,
673
1547
  properties: {
674
- feature: { type: "string", minLength: 1 },
675
- action: { type: "string", minLength: 1 }
1548
+ feature: {
1549
+ type: "string",
1550
+ minLength: 1
1551
+ },
1552
+ action: {
1553
+ type: "string",
1554
+ minLength: 1
1555
+ }
676
1556
  }
677
1557
  }
678
1558
  },
679
1559
  oneOf: [
680
- { required: ["blocks"] },
681
- { required: ["entity"] },
682
- { required: ["component"] }
1560
+ {
1561
+ required: [
1562
+ "blocks"
1563
+ ]
1564
+ },
1565
+ {
1566
+ required: [
1567
+ "entity"
1568
+ ]
1569
+ },
1570
+ {
1571
+ required: [
1572
+ "component"
1573
+ ]
1574
+ }
683
1575
  ]
684
1576
  },
685
1577
  block: {
686
1578
  type: "object",
687
- required: ["type"],
1579
+ required: [
1580
+ "type"
1581
+ ],
688
1582
  additionalProperties: false,
689
1583
  properties: {
690
- type: { type: "string", minLength: 1 },
691
- id: { type: "string" },
692
- props: { type: "object" },
693
- children: { type: "array", items: { $ref: "#/$defs/block" } }
1584
+ type: {
1585
+ type: "string",
1586
+ minLength: 1
1587
+ },
1588
+ id: {
1589
+ type: "string"
1590
+ },
1591
+ props: {
1592
+ type: "object"
1593
+ },
1594
+ children: {
1595
+ type: "array",
1596
+ items: {
1597
+ $ref: "#/$defs/block"
1598
+ }
1599
+ }
1600
+ }
1601
+ },
1602
+ agentContract: {
1603
+ type: "object",
1604
+ additionalProperties: false,
1605
+ description: "Everything a server-side agent runtime needs to operate the app without a browser. Derived from code at publish; synced to Fayz as the versioned AgentContract.",
1606
+ properties: {
1607
+ persona: {
1608
+ type: "object",
1609
+ additionalProperties: false,
1610
+ properties: {
1611
+ name: {
1612
+ type: "string"
1613
+ },
1614
+ systemPrompt: {
1615
+ type: "string"
1616
+ },
1617
+ icon: {
1618
+ type: "string"
1619
+ }
1620
+ }
1621
+ },
1622
+ executionPlane: {
1623
+ enum: [
1624
+ "client",
1625
+ "server"
1626
+ ]
1627
+ },
1628
+ entities: {
1629
+ type: "array",
1630
+ items: {
1631
+ $ref: "#/$defs/entityContract"
1632
+ }
1633
+ },
1634
+ tools: {
1635
+ type: "array",
1636
+ items: {
1637
+ $ref: "#/$defs/aiToolContract"
1638
+ }
1639
+ },
1640
+ registries: {
1641
+ type: "array",
1642
+ items: {
1643
+ type: "object",
1644
+ required: [
1645
+ "pluginId",
1646
+ "id"
1647
+ ],
1648
+ additionalProperties: false,
1649
+ properties: {
1650
+ pluginId: {
1651
+ type: "string",
1652
+ minLength: 1
1653
+ },
1654
+ id: {
1655
+ type: "string",
1656
+ minLength: 1
1657
+ },
1658
+ entityKey: {
1659
+ type: "string"
1660
+ },
1661
+ readOnly: {
1662
+ type: "boolean"
1663
+ }
1664
+ }
1665
+ }
1666
+ },
1667
+ declaredFeatures: {
1668
+ type: "array",
1669
+ items: {
1670
+ type: "object"
1671
+ }
1672
+ },
1673
+ rpcs: {
1674
+ type: "array",
1675
+ items: {
1676
+ $ref: "#/$defs/rpcContract"
1677
+ }
1678
+ },
1679
+ domainKnowledge: {
1680
+ type: "object",
1681
+ additionalProperties: false,
1682
+ properties: {
1683
+ statuses: {
1684
+ type: "object"
1685
+ },
1686
+ scheduleDefaults: {
1687
+ type: "object"
1688
+ },
1689
+ businessRules: {
1690
+ type: "array",
1691
+ items: {
1692
+ type: "object",
1693
+ required: [
1694
+ "id",
1695
+ "description"
1696
+ ],
1697
+ additionalProperties: false,
1698
+ properties: {
1699
+ id: {
1700
+ type: "string",
1701
+ minLength: 1
1702
+ },
1703
+ description: {
1704
+ type: "string",
1705
+ minLength: 1
1706
+ }
1707
+ }
1708
+ }
1709
+ }
1710
+ }
1711
+ }
1712
+ }
1713
+ },
1714
+ entityContract: {
1715
+ type: "object",
1716
+ required: [
1717
+ "key",
1718
+ "label",
1719
+ "data",
1720
+ "fields"
1721
+ ],
1722
+ additionalProperties: false,
1723
+ properties: {
1724
+ key: {
1725
+ type: "string",
1726
+ minLength: 1
1727
+ },
1728
+ label: {
1729
+ type: "string",
1730
+ minLength: 1
1731
+ },
1732
+ labelPlural: {
1733
+ type: "string"
1734
+ },
1735
+ limitKey: {
1736
+ type: "string"
1737
+ },
1738
+ data: {
1739
+ type: "object",
1740
+ required: [
1741
+ "table"
1742
+ ],
1743
+ additionalProperties: false,
1744
+ properties: {
1745
+ table: {
1746
+ type: "string",
1747
+ minLength: 1
1748
+ },
1749
+ schema: {
1750
+ type: "string"
1751
+ },
1752
+ tenantScoped: {
1753
+ type: "boolean"
1754
+ },
1755
+ tenantIdColumn: {
1756
+ type: "string"
1757
+ },
1758
+ searchColumns: {
1759
+ type: "array",
1760
+ items: {
1761
+ type: "string"
1762
+ }
1763
+ },
1764
+ selectColumns: {
1765
+ type: "string"
1766
+ },
1767
+ columnMap: {
1768
+ type: "object"
1769
+ },
1770
+ archetype: {
1771
+ type: "string"
1772
+ },
1773
+ archetypeKind: {
1774
+ type: "string"
1775
+ },
1776
+ filters: {
1777
+ type: "object"
1778
+ }
1779
+ }
1780
+ },
1781
+ fields: {
1782
+ type: "array",
1783
+ items: {
1784
+ type: "object",
1785
+ required: [
1786
+ "key",
1787
+ "label",
1788
+ "type"
1789
+ ],
1790
+ additionalProperties: false,
1791
+ properties: {
1792
+ key: {
1793
+ type: "string",
1794
+ minLength: 1
1795
+ },
1796
+ label: {
1797
+ type: "string"
1798
+ },
1799
+ type: {
1800
+ type: "string",
1801
+ minLength: 1
1802
+ },
1803
+ required: {
1804
+ type: "boolean"
1805
+ },
1806
+ searchable: {
1807
+ type: "boolean"
1808
+ },
1809
+ hint: {
1810
+ type: "string"
1811
+ },
1812
+ options: {
1813
+ type: "array",
1814
+ items: {
1815
+ type: "string"
1816
+ }
1817
+ },
1818
+ relationTable: {
1819
+ type: "string"
1820
+ }
1821
+ }
1822
+ }
1823
+ },
1824
+ permission: {
1825
+ type: "object",
1826
+ required: [
1827
+ "feature",
1828
+ "action"
1829
+ ],
1830
+ additionalProperties: false,
1831
+ properties: {
1832
+ feature: {
1833
+ type: "string",
1834
+ minLength: 1
1835
+ },
1836
+ action: {
1837
+ type: "string",
1838
+ minLength: 1
1839
+ }
1840
+ }
1841
+ }
1842
+ }
1843
+ },
1844
+ aiToolContract: {
1845
+ type: "object",
1846
+ required: [
1847
+ "id",
1848
+ "name",
1849
+ "description",
1850
+ "mode"
1851
+ ],
1852
+ additionalProperties: false,
1853
+ properties: {
1854
+ id: {
1855
+ type: "string",
1856
+ minLength: 1
1857
+ },
1858
+ name: {
1859
+ type: "string",
1860
+ minLength: 1,
1861
+ pattern: "^[a-zA-Z0-9_-]{1,64}$"
1862
+ },
1863
+ description: {
1864
+ type: "string",
1865
+ minLength: 1
1866
+ },
1867
+ mode: {
1868
+ enum: [
1869
+ "read",
1870
+ "persist"
1871
+ ]
1872
+ },
1873
+ parameters: {
1874
+ type: "object"
1875
+ },
1876
+ permission: {
1877
+ type: "object",
1878
+ required: [
1879
+ "feature",
1880
+ "action"
1881
+ ],
1882
+ additionalProperties: false,
1883
+ properties: {
1884
+ feature: {
1885
+ type: "string",
1886
+ minLength: 1
1887
+ },
1888
+ action: {
1889
+ type: "string",
1890
+ minLength: 1
1891
+ }
1892
+ }
1893
+ },
1894
+ limitKey: {
1895
+ type: "string"
1896
+ },
1897
+ execution: {
1898
+ oneOf: [
1899
+ {
1900
+ type: "object",
1901
+ required: [
1902
+ "plane",
1903
+ "kind",
1904
+ "rpc"
1905
+ ],
1906
+ additionalProperties: false,
1907
+ properties: {
1908
+ plane: {
1909
+ const: "server"
1910
+ },
1911
+ kind: {
1912
+ const: "rpc"
1913
+ },
1914
+ rpc: {
1915
+ type: "string",
1916
+ minLength: 1
1917
+ }
1918
+ }
1919
+ },
1920
+ {
1921
+ type: "object",
1922
+ required: [
1923
+ "plane",
1924
+ "kind",
1925
+ "entity"
1926
+ ],
1927
+ additionalProperties: false,
1928
+ properties: {
1929
+ plane: {
1930
+ const: "server"
1931
+ },
1932
+ kind: {
1933
+ const: "entity_read"
1934
+ },
1935
+ entity: {
1936
+ type: "string",
1937
+ minLength: 1
1938
+ }
1939
+ }
1940
+ },
1941
+ {
1942
+ type: "object",
1943
+ required: [
1944
+ "plane"
1945
+ ],
1946
+ additionalProperties: false,
1947
+ properties: {
1948
+ plane: {
1949
+ const: "client"
1950
+ }
1951
+ }
1952
+ }
1953
+ ]
1954
+ },
1955
+ requiresConfirmation: {
1956
+ type: "boolean"
1957
+ },
1958
+ pluginId: {
1959
+ type: "string"
1960
+ },
1961
+ category: {
1962
+ type: "string"
1963
+ }
1964
+ }
1965
+ },
1966
+ rpcContract: {
1967
+ type: "object",
1968
+ required: [
1969
+ "name",
1970
+ "kind",
1971
+ "description"
1972
+ ],
1973
+ additionalProperties: false,
1974
+ properties: {
1975
+ name: {
1976
+ type: "string",
1977
+ minLength: 1,
1978
+ pattern: "^agent_[a-z0-9_]+$"
1979
+ },
1980
+ kind: {
1981
+ enum: [
1982
+ "read",
1983
+ "write"
1984
+ ]
1985
+ },
1986
+ description: {
1987
+ type: "string",
1988
+ minLength: 1
1989
+ },
1990
+ payloadSchema: {
1991
+ type: "object"
1992
+ },
1993
+ audits: {
1994
+ type: "boolean"
1995
+ }
694
1996
  }
695
1997
  }
696
1998
  }
697
1999
  };
698
- var ManifestContext = React2__namespace.createContext(null);
2000
+ var ManifestContext = React3__namespace.createContext(null);
699
2001
  function useManifest() {
700
- return React2__namespace.useContext(ManifestContext);
2002
+ return React3__namespace.useContext(ManifestContext);
701
2003
  }
702
2004
  function defineApp(manifest) {
703
2005
  const full = {
@@ -723,16 +2025,16 @@ function renderApp(input, opts = {}) {
723
2025
  if (!surface) {
724
2026
  throw new Error(`Surface "${surfaceName}" not found in manifest.`);
725
2027
  }
726
- const Scaffold = chunk5X2VX3RQ_cjs.getScaffold(surface.scaffold);
2028
+ const Scaffold = chunkZOPJB5FN_cjs.getScaffold(surface.scaffold);
727
2029
  if (!Scaffold) {
728
2030
  throw new Error(
729
2031
  `Scaffold "${surface.scaffold}" is not registered. Import the package that provides it (e.g. @fayz-ai/saas or @fayz-ai/shop) before calling renderApp.`
730
2032
  );
731
2033
  }
732
- return React2__namespace.createElement(
2034
+ return React3__namespace.createElement(
733
2035
  ManifestContext.Provider,
734
2036
  { value: manifest },
735
- React2__namespace.createElement(Scaffold, { manifest, surface: surfaceName })
2037
+ React3__namespace.createElement(Scaffold, { manifest, surface: surfaceName })
736
2038
  );
737
2039
  }
738
2040
  var MAX_ENTRIES = 20;
@@ -793,275 +2095,283 @@ Object.defineProperty(exports, "assertPluginManifestContract", {
793
2095
  });
794
2096
  Object.defineProperty(exports, "FAYZ_CLOUD_PUBLISHABLE_KEY", {
795
2097
  enumerable: true,
796
- get: function () { return chunk54SRL7AJ_cjs.FAYZ_CLOUD_PUBLISHABLE_KEY; }
2098
+ get: function () { return chunkKSI2L3E4_cjs.FAYZ_CLOUD_PUBLISHABLE_KEY; }
797
2099
  });
798
2100
  Object.defineProperty(exports, "FAYZ_CLOUD_URL", {
799
2101
  enumerable: true,
800
- get: function () { return chunk54SRL7AJ_cjs.FAYZ_CLOUD_URL; }
2102
+ get: function () { return chunkKSI2L3E4_cjs.FAYZ_CLOUD_URL; }
801
2103
  });
802
2104
  Object.defineProperty(exports, "clearGlobalCache", {
803
2105
  enumerable: true,
804
- get: function () { return chunk54SRL7AJ_cjs.clearGlobalCache; }
2106
+ get: function () { return chunkKSI2L3E4_cjs.clearGlobalCache; }
2107
+ });
2108
+ Object.defineProperty(exports, "countByTenant", {
2109
+ enumerable: true,
2110
+ get: function () { return chunkKSI2L3E4_cjs.countByTenant; }
805
2111
  });
806
2112
  Object.defineProperty(exports, "createArchetypeProvider", {
807
2113
  enumerable: true,
808
- get: function () { return chunk54SRL7AJ_cjs.createArchetypeProvider; }
2114
+ get: function () { return chunkKSI2L3E4_cjs.createArchetypeProvider; }
809
2115
  });
810
2116
  Object.defineProperty(exports, "createCacheStore", {
811
2117
  enumerable: true,
812
- get: function () { return chunk54SRL7AJ_cjs.createCacheStore; }
2118
+ get: function () { return chunkKSI2L3E4_cjs.createCacheStore; }
813
2119
  });
814
2120
  Object.defineProperty(exports, "createFayzApiProvider", {
815
2121
  enumerable: true,
816
- get: function () { return chunk54SRL7AJ_cjs.createFayzApiProvider; }
2122
+ get: function () { return chunkKSI2L3E4_cjs.createFayzApiProvider; }
817
2123
  });
818
2124
  Object.defineProperty(exports, "createMockProvider", {
819
2125
  enumerable: true,
820
- get: function () { return chunk54SRL7AJ_cjs.createMockProvider; }
2126
+ get: function () { return chunkKSI2L3E4_cjs.createMockProvider; }
821
2127
  });
822
2128
  Object.defineProperty(exports, "createSupabaseProvider", {
823
2129
  enumerable: true,
824
- get: function () { return chunk54SRL7AJ_cjs.createSupabaseProvider; }
2130
+ get: function () { return chunkKSI2L3E4_cjs.createSupabaseProvider; }
825
2131
  });
826
2132
  Object.defineProperty(exports, "getActiveTenantId", {
827
2133
  enumerable: true,
828
- get: function () { return chunk54SRL7AJ_cjs.getActiveTenantId; }
2134
+ get: function () { return chunkKSI2L3E4_cjs.getActiveTenantId; }
829
2135
  });
830
2136
  Object.defineProperty(exports, "getFayzCloudClient", {
831
2137
  enumerable: true,
832
- get: function () { return chunk54SRL7AJ_cjs.getFayzCloudClient; }
2138
+ get: function () { return chunkKSI2L3E4_cjs.getFayzCloudClient; }
833
2139
  });
834
2140
  Object.defineProperty(exports, "getSupabaseClientOptional", {
835
2141
  enumerable: true,
836
- get: function () { return chunk54SRL7AJ_cjs.getSupabaseClientOptional; }
2142
+ get: function () { return chunkKSI2L3E4_cjs.getSupabaseClientOptional; }
837
2143
  });
838
2144
  Object.defineProperty(exports, "globalCache", {
839
2145
  enumerable: true,
840
- get: function () { return chunk54SRL7AJ_cjs.globalCache; }
2146
+ get: function () { return chunkKSI2L3E4_cjs.globalCache; }
2147
+ });
2148
+ Object.defineProperty(exports, "invalidateCount", {
2149
+ enumerable: true,
2150
+ get: function () { return chunkKSI2L3E4_cjs.invalidateCount; }
841
2151
  });
842
2152
  Object.defineProperty(exports, "resolveDataProvider", {
843
2153
  enumerable: true,
844
- get: function () { return chunk54SRL7AJ_cjs.resolveDataProvider; }
2154
+ get: function () { return chunkKSI2L3E4_cjs.resolveDataProvider; }
845
2155
  });
846
2156
  Object.defineProperty(exports, "setActiveTenantId", {
847
2157
  enumerable: true,
848
- get: function () { return chunk54SRL7AJ_cjs.setActiveTenantId; }
2158
+ get: function () { return chunkKSI2L3E4_cjs.setActiveTenantId; }
849
2159
  });
850
2160
  Object.defineProperty(exports, "setGlobalSupabaseClient", {
851
2161
  enumerable: true,
852
- get: function () { return chunk54SRL7AJ_cjs.setGlobalSupabaseClient; }
2162
+ get: function () { return chunkKSI2L3E4_cjs.setGlobalSupabaseClient; }
853
2163
  });
854
2164
  Object.defineProperty(exports, "stableKey", {
855
2165
  enumerable: true,
856
- get: function () { return chunk54SRL7AJ_cjs.stableKey; }
2166
+ get: function () { return chunkKSI2L3E4_cjs.stableKey; }
857
2167
  });
858
2168
  Object.defineProperty(exports, "withCache", {
859
2169
  enumerable: true,
860
- get: function () { return chunk54SRL7AJ_cjs.withCache; }
2170
+ get: function () { return chunkKSI2L3E4_cjs.withCache; }
861
2171
  });
862
2172
  Object.defineProperty(exports, "clearEntityRegistry", {
863
2173
  enumerable: true,
864
- get: function () { return chunk2NTHNWEH_cjs.clearEntityRegistry; }
2174
+ get: function () { return chunkUKU4RIWM_cjs.clearEntityRegistry; }
865
2175
  });
866
2176
  Object.defineProperty(exports, "deriveEntityKey", {
867
2177
  enumerable: true,
868
- get: function () { return chunk2NTHNWEH_cjs.deriveEntityKey; }
2178
+ get: function () { return chunkUKU4RIWM_cjs.deriveEntityKey; }
869
2179
  });
870
2180
  Object.defineProperty(exports, "getAllEntities", {
871
2181
  enumerable: true,
872
- get: function () { return chunk2NTHNWEH_cjs.getAllEntities; }
2182
+ get: function () { return chunkUKU4RIWM_cjs.getAllEntities; }
873
2183
  });
874
2184
  Object.defineProperty(exports, "getEntityByKey", {
875
2185
  enumerable: true,
876
- get: function () { return chunk2NTHNWEH_cjs.getEntityByKey; }
2186
+ get: function () { return chunkUKU4RIWM_cjs.getEntityByKey; }
877
2187
  });
878
2188
  Object.defineProperty(exports, "registerEntity", {
879
2189
  enumerable: true,
880
- get: function () { return chunk2NTHNWEH_cjs.registerEntity; }
2190
+ get: function () { return chunkUKU4RIWM_cjs.registerEntity; }
881
2191
  });
882
2192
  Object.defineProperty(exports, "PLUGIN_API_VERSION", {
883
2193
  enumerable: true,
884
- get: function () { return chunk5X2VX3RQ_cjs.PLUGIN_API_VERSION; }
2194
+ get: function () { return chunkZOPJB5FN_cjs.PLUGIN_API_VERSION; }
885
2195
  });
886
2196
  Object.defineProperty(exports, "PluginRuntimeProvider", {
887
2197
  enumerable: true,
888
- get: function () { return chunk5X2VX3RQ_cjs.PluginRuntimeProvider; }
2198
+ get: function () { return chunkZOPJB5FN_cjs.PluginRuntimeProvider; }
889
2199
  });
890
2200
  Object.defineProperty(exports, "Registry", {
891
2201
  enumerable: true,
892
- get: function () { return chunk5X2VX3RQ_cjs.Registry; }
2202
+ get: function () { return chunkZOPJB5FN_cjs.Registry; }
893
2203
  });
894
2204
  Object.defineProperty(exports, "blockRegistry", {
895
2205
  enumerable: true,
896
- get: function () { return chunk5X2VX3RQ_cjs.blockRegistry; }
2206
+ get: function () { return chunkZOPJB5FN_cjs.blockRegistry; }
897
2207
  });
898
2208
  Object.defineProperty(exports, "componentRegistry", {
899
2209
  enumerable: true,
900
- get: function () { return chunk5X2VX3RQ_cjs.componentRegistry; }
2210
+ get: function () { return chunkZOPJB5FN_cjs.componentRegistry; }
901
2211
  });
902
2212
  Object.defineProperty(exports, "definePlugin", {
903
2213
  enumerable: true,
904
- get: function () { return chunk5X2VX3RQ_cjs.definePlugin; }
2214
+ get: function () { return chunkZOPJB5FN_cjs.definePlugin; }
905
2215
  });
906
2216
  Object.defineProperty(exports, "getBlock", {
907
2217
  enumerable: true,
908
- get: function () { return chunk5X2VX3RQ_cjs.getBlock; }
2218
+ get: function () { return chunkZOPJB5FN_cjs.getBlock; }
909
2219
  });
910
2220
  Object.defineProperty(exports, "getComponent", {
911
2221
  enumerable: true,
912
- get: function () { return chunk5X2VX3RQ_cjs.getComponent; }
2222
+ get: function () { return chunkZOPJB5FN_cjs.getComponent; }
913
2223
  });
914
2224
  Object.defineProperty(exports, "getDashboardWidgets", {
915
2225
  enumerable: true,
916
- get: function () { return chunk5X2VX3RQ_cjs.getDashboardWidgets; }
2226
+ get: function () { return chunkZOPJB5FN_cjs.getDashboardWidgets; }
917
2227
  });
918
2228
  Object.defineProperty(exports, "getMetric", {
919
2229
  enumerable: true,
920
- get: function () { return chunk5X2VX3RQ_cjs.getMetric; }
2230
+ get: function () { return chunkZOPJB5FN_cjs.getMetric; }
921
2231
  });
922
2232
  Object.defineProperty(exports, "getPage", {
923
2233
  enumerable: true,
924
- get: function () { return chunk5X2VX3RQ_cjs.getPage; }
2234
+ get: function () { return chunkZOPJB5FN_cjs.getPage; }
925
2235
  });
926
2236
  Object.defineProperty(exports, "getPlugin", {
927
2237
  enumerable: true,
928
- get: function () { return chunk5X2VX3RQ_cjs.getPlugin; }
2238
+ get: function () { return chunkZOPJB5FN_cjs.getPlugin; }
929
2239
  });
930
2240
  Object.defineProperty(exports, "getPluginFactory", {
931
2241
  enumerable: true,
932
- get: function () { return chunk5X2VX3RQ_cjs.getPluginFactory; }
2242
+ get: function () { return chunkZOPJB5FN_cjs.getPluginFactory; }
933
2243
  });
934
2244
  Object.defineProperty(exports, "getScaffold", {
935
2245
  enumerable: true,
936
- get: function () { return chunk5X2VX3RQ_cjs.getScaffold; }
2246
+ get: function () { return chunkZOPJB5FN_cjs.getScaffold; }
937
2247
  });
938
2248
  Object.defineProperty(exports, "getWidgetsForZone", {
939
2249
  enumerable: true,
940
- get: function () { return chunk5X2VX3RQ_cjs.getWidgetsForZone; }
2250
+ get: function () { return chunkZOPJB5FN_cjs.getWidgetsForZone; }
941
2251
  });
942
2252
  Object.defineProperty(exports, "isCustomId", {
943
2253
  enumerable: true,
944
- get: function () { return chunk5X2VX3RQ_cjs.isCustomId; }
2254
+ get: function () { return chunkZOPJB5FN_cjs.isCustomId; }
945
2255
  });
946
2256
  Object.defineProperty(exports, "listBlocks", {
947
2257
  enumerable: true,
948
- get: function () { return chunk5X2VX3RQ_cjs.listBlocks; }
2258
+ get: function () { return chunkZOPJB5FN_cjs.listBlocks; }
949
2259
  });
950
2260
  Object.defineProperty(exports, "listMetrics", {
951
2261
  enumerable: true,
952
- get: function () { return chunk5X2VX3RQ_cjs.listMetrics; }
2262
+ get: function () { return chunkZOPJB5FN_cjs.listMetrics; }
953
2263
  });
954
2264
  Object.defineProperty(exports, "listPluginFactories", {
955
2265
  enumerable: true,
956
- get: function () { return chunk5X2VX3RQ_cjs.listPluginFactories; }
2266
+ get: function () { return chunkZOPJB5FN_cjs.listPluginFactories; }
957
2267
  });
958
2268
  Object.defineProperty(exports, "listPlugins", {
959
2269
  enumerable: true,
960
- get: function () { return chunk5X2VX3RQ_cjs.listPlugins; }
2270
+ get: function () { return chunkZOPJB5FN_cjs.listPlugins; }
961
2271
  });
962
2272
  Object.defineProperty(exports, "metricRegistry", {
963
2273
  enumerable: true,
964
- get: function () { return chunk5X2VX3RQ_cjs.metricRegistry; }
2274
+ get: function () { return chunkZOPJB5FN_cjs.metricRegistry; }
965
2275
  });
966
2276
  Object.defineProperty(exports, "pageRegistry", {
967
2277
  enumerable: true,
968
- get: function () { return chunk5X2VX3RQ_cjs.pageRegistry; }
2278
+ get: function () { return chunkZOPJB5FN_cjs.pageRegistry; }
969
2279
  });
970
2280
  Object.defineProperty(exports, "pluginFactoryRegistry", {
971
2281
  enumerable: true,
972
- get: function () { return chunk5X2VX3RQ_cjs.pluginFactoryRegistry; }
2282
+ get: function () { return chunkZOPJB5FN_cjs.pluginFactoryRegistry; }
973
2283
  });
974
2284
  Object.defineProperty(exports, "pluginRegistry", {
975
2285
  enumerable: true,
976
- get: function () { return chunk5X2VX3RQ_cjs.pluginRegistry; }
2286
+ get: function () { return chunkZOPJB5FN_cjs.pluginRegistry; }
977
2287
  });
978
2288
  Object.defineProperty(exports, "registerBlock", {
979
2289
  enumerable: true,
980
- get: function () { return chunk5X2VX3RQ_cjs.registerBlock; }
2290
+ get: function () { return chunkZOPJB5FN_cjs.registerBlock; }
981
2291
  });
982
2292
  Object.defineProperty(exports, "registerComponent", {
983
2293
  enumerable: true,
984
- get: function () { return chunk5X2VX3RQ_cjs.registerComponent; }
2294
+ get: function () { return chunkZOPJB5FN_cjs.registerComponent; }
985
2295
  });
986
2296
  Object.defineProperty(exports, "registerMetric", {
987
2297
  enumerable: true,
988
- get: function () { return chunk5X2VX3RQ_cjs.registerMetric; }
2298
+ get: function () { return chunkZOPJB5FN_cjs.registerMetric; }
989
2299
  });
990
2300
  Object.defineProperty(exports, "registerPage", {
991
2301
  enumerable: true,
992
- get: function () { return chunk5X2VX3RQ_cjs.registerPage; }
2302
+ get: function () { return chunkZOPJB5FN_cjs.registerPage; }
993
2303
  });
994
2304
  Object.defineProperty(exports, "registerPlugin", {
995
2305
  enumerable: true,
996
- get: function () { return chunk5X2VX3RQ_cjs.registerPlugin; }
2306
+ get: function () { return chunkZOPJB5FN_cjs.registerPlugin; }
997
2307
  });
998
2308
  Object.defineProperty(exports, "registerPluginFactory", {
999
2309
  enumerable: true,
1000
- get: function () { return chunk5X2VX3RQ_cjs.registerPluginFactory; }
2310
+ get: function () { return chunkZOPJB5FN_cjs.registerPluginFactory; }
1001
2311
  });
1002
2312
  Object.defineProperty(exports, "registerScaffold", {
1003
2313
  enumerable: true,
1004
- get: function () { return chunk5X2VX3RQ_cjs.registerScaffold; }
2314
+ get: function () { return chunkZOPJB5FN_cjs.registerScaffold; }
1005
2315
  });
1006
2316
  Object.defineProperty(exports, "resolvePluginComponent", {
1007
2317
  enumerable: true,
1008
- get: function () { return chunk5X2VX3RQ_cjs.resolvePluginComponent; }
2318
+ get: function () { return chunkZOPJB5FN_cjs.resolvePluginComponent; }
1009
2319
  });
1010
2320
  Object.defineProperty(exports, "resolvePluginRuntime", {
1011
2321
  enumerable: true,
1012
- get: function () { return chunk5X2VX3RQ_cjs.resolvePluginRuntime; }
2322
+ get: function () { return chunkZOPJB5FN_cjs.resolvePluginRuntime; }
1013
2323
  });
1014
2324
  Object.defineProperty(exports, "scaffoldRegistry", {
1015
2325
  enumerable: true,
1016
- get: function () { return chunk5X2VX3RQ_cjs.scaffoldRegistry; }
2326
+ get: function () { return chunkZOPJB5FN_cjs.scaffoldRegistry; }
1017
2327
  });
1018
2328
  Object.defineProperty(exports, "useConnectorsForPlugin", {
1019
2329
  enumerable: true,
1020
- get: function () { return chunk5X2VX3RQ_cjs.useConnectorsForPlugin; }
2330
+ get: function () { return chunkZOPJB5FN_cjs.useConnectorsForPlugin; }
1021
2331
  });
1022
2332
  Object.defineProperty(exports, "usePluginRuntime", {
1023
2333
  enumerable: true,
1024
- get: function () { return chunk5X2VX3RQ_cjs.usePluginRuntime; }
2334
+ get: function () { return chunkZOPJB5FN_cjs.usePluginRuntime; }
1025
2335
  });
1026
2336
  Object.defineProperty(exports, "usePluginRuntimeOptional", {
1027
2337
  enumerable: true,
1028
- get: function () { return chunk5X2VX3RQ_cjs.usePluginRuntimeOptional; }
2338
+ get: function () { return chunkZOPJB5FN_cjs.usePluginRuntimeOptional; }
1029
2339
  });
1030
2340
  Object.defineProperty(exports, "I18nProvider", {
1031
2341
  enumerable: true,
1032
- get: function () { return chunkQR7U2URY_cjs.I18nProvider; }
2342
+ get: function () { return chunkCATASHPK_cjs.I18nProvider; }
1033
2343
  });
1034
2344
  Object.defineProperty(exports, "coreTranslations", {
1035
2345
  enumerable: true,
1036
- get: function () { return chunkQR7U2URY_cjs.coreTranslations; }
2346
+ get: function () { return chunkCATASHPK_cjs.coreTranslations; }
1037
2347
  });
1038
2348
  Object.defineProperty(exports, "getCurrentLocale", {
1039
2349
  enumerable: true,
1040
- get: function () { return chunkQR7U2URY_cjs.getCurrentLocale; }
2350
+ get: function () { return chunkCATASHPK_cjs.getCurrentLocale; }
1041
2351
  });
1042
2352
  Object.defineProperty(exports, "mergeTranslations", {
1043
2353
  enumerable: true,
1044
- get: function () { return chunkQR7U2URY_cjs.mergeTranslations; }
2354
+ get: function () { return chunkCATASHPK_cjs.mergeTranslations; }
1045
2355
  });
1046
2356
  Object.defineProperty(exports, "registerTranslations", {
1047
2357
  enumerable: true,
1048
- get: function () { return chunkQR7U2URY_cjs.registerTranslations; }
2358
+ get: function () { return chunkCATASHPK_cjs.registerTranslations; }
1049
2359
  });
1050
2360
  Object.defineProperty(exports, "setCurrentLocale", {
1051
2361
  enumerable: true,
1052
- get: function () { return chunkQR7U2URY_cjs.setCurrentLocale; }
2362
+ get: function () { return chunkCATASHPK_cjs.setCurrentLocale; }
1053
2363
  });
1054
2364
  Object.defineProperty(exports, "setLocaleStore", {
1055
2365
  enumerable: true,
1056
- get: function () { return chunkQR7U2URY_cjs.setLocaleStore; }
2366
+ get: function () { return chunkCATASHPK_cjs.setLocaleStore; }
1057
2367
  });
1058
2368
  Object.defineProperty(exports, "useI18nConfig", {
1059
2369
  enumerable: true,
1060
- get: function () { return chunkQR7U2URY_cjs.useI18nConfig; }
2370
+ get: function () { return chunkCATASHPK_cjs.useI18nConfig; }
1061
2371
  });
1062
2372
  Object.defineProperty(exports, "useTranslation", {
1063
2373
  enumerable: true,
1064
- get: function () { return chunkQR7U2URY_cjs.useTranslation; }
2374
+ get: function () { return chunkCATASHPK_cjs.useTranslation; }
1065
2375
  });
1066
2376
  Object.defineProperty(exports, "hashRouterAdapter", {
1067
2377
  enumerable: true,
@@ -1083,38 +2393,65 @@ exports.BlockChildren = BlockChildren;
1083
2393
  exports.BlockRenderer = BlockRenderer;
1084
2394
  exports.COUNTRIES = COUNTRIES;
1085
2395
  exports.CURRENT_MANIFEST_VERSION = CURRENT_MANIFEST_VERSION;
2396
+ exports.DATA_CHANGED_EVENT = DATA_CHANGED_EVENT;
1086
2397
  exports.DEFAULT_COUNTRY = DEFAULT_COUNTRY;
2398
+ exports.MIN_QUERY_LENGTH = MIN_QUERY_LENGTH;
1087
2399
  exports.WidgetZone = WidgetZone;
1088
2400
  exports.absoluteUrl = absoluteUrl;
1089
2401
  exports.appManifestSchema = app_manifest_schema_default;
1090
2402
  exports.applySeo = applySeo;
1091
2403
  exports.breadcrumbJsonLd = breadcrumbJsonLd;
1092
2404
  exports.buildCSV = buildCSV;
2405
+ exports.clearPostalCache = clearPostalCache;
2406
+ exports.clearSearchCache = clearSearchCache;
2407
+ exports.computeContractHash = computeContractHash;
1093
2408
  exports.createEventBus = createEventBus;
1094
2409
  exports.createSafeDataProvider = createSafeDataProvider;
2410
+ exports.createViaCepProvider = createViaCepProvider;
1095
2411
  exports.defineApp = defineApp;
2412
+ exports.digitsOf = digitsOf;
1096
2413
  exports.downloadCSV = downloadCSV;
2414
+ exports.emitDataChanged = emitDataChanged;
1097
2415
  exports.eventBus = eventBus;
1098
2416
  exports.exportCSV = exportCSV;
2417
+ exports.foldText = foldText;
2418
+ exports.foldWithMap = foldWithMap;
1099
2419
  exports.formatCurrency = formatCurrency;
1100
2420
  exports.formatDate = formatDate;
1101
2421
  exports.formatDateTime = formatDateTime;
2422
+ exports.formatPostalCode = formatPostalCode;
1102
2423
  exports.getActiveLocale = getActiveLocale;
1103
2424
  exports.getCountry = getCountry;
1104
2425
  exports.getDefaultCurrency = getDefaultCurrency;
2426
+ exports.getPostalLookupProvider = getPostalLookupProvider;
2427
+ exports.highlightRanges = highlightRanges;
2428
+ exports.isSearchIndexAvailable = isSearchIndexAvailable;
2429
+ exports.isValidPostalCode = isValidPostalCode;
2430
+ exports.lookupPostalCode = lookupPostalCode;
1105
2431
  exports.maskDigitCount = maskDigitCount;
1106
2432
  exports.maskPhone = maskPhone;
2433
+ exports.matchesDataChange = matchesDataChange;
1107
2434
  exports.migrateManifest = migrateManifest;
1108
2435
  exports.navHistoryBack = navHistoryBack;
2436
+ exports.normalizePostalCode = normalizePostalCode;
2437
+ exports.normalizeQuery = normalizeQuery;
1109
2438
  exports.organizationJsonLd = organizationJsonLd;
1110
2439
  exports.recordNavigation = recordNavigation;
1111
2440
  exports.registerManifestMigration = registerManifestMigration;
1112
2441
  exports.renderApp = renderApp;
1113
2442
  exports.renderBlocks = renderBlocks;
1114
2443
  exports.routeModule = routeModule;
2444
+ exports.scoreCandidate = scoreCandidate;
2445
+ exports.searchEverything = searchEverything;
1115
2446
  exports.seoOrigin = seoOrigin;
2447
+ exports.serializeManifest = serializeManifest;
2448
+ exports.serializeManifestWithHash = serializeManifestWithHash;
1116
2449
  exports.setDefaultCurrency = setDefaultCurrency;
2450
+ exports.setPostalLookupProvider = setPostalLookupProvider;
2451
+ exports.setSearchIndexAvailable = setSearchIndexAvailable;
2452
+ exports.similarity = similarity;
1117
2453
  exports.unmaskPhone = unmaskPhone;
2454
+ exports.useDataChanged = useDataChanged;
1118
2455
  exports.useManifest = useManifest;
1119
2456
  exports.useNavHistoryStore = useNavHistoryStore;
1120
2457
  exports.useNavReferrer = useNavReferrer;