@fayz-ai/core 0.8.3 → 0.8.5

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 (116) hide show
  1. package/dist/access/engine.d.ts +8 -1
  2. package/dist/access/engine.d.ts.map +1 -1
  3. package/dist/access/index.d.ts +1 -1
  4. package/dist/access/index.d.ts.map +1 -1
  5. package/dist/access/index.js +6 -1
  6. package/dist/access/index.js.map +1 -1
  7. package/dist/chunk-HN7PTOSH.js +1149 -0
  8. package/dist/chunk-HN7PTOSH.js.map +1 -0
  9. package/dist/{chunk-KSI2L3E4.cjs → chunk-V2MSAUHO.js} +165 -40
  10. package/dist/chunk-V2MSAUHO.js.map +1 -0
  11. package/dist/data/archetype.d.ts.map +1 -1
  12. package/dist/data/bulk.d.ts +17 -0
  13. package/dist/data/bulk.d.ts.map +1 -0
  14. package/dist/data/filters.d.ts +29 -0
  15. package/dist/data/filters.d.ts.map +1 -0
  16. package/dist/data/index.d.ts +2 -2
  17. package/dist/data/index.d.ts.map +1 -1
  18. package/dist/data/index.js +1 -1
  19. package/dist/data/mock.d.ts.map +1 -1
  20. package/dist/data/platform-api.d.ts.map +1 -1
  21. package/dist/data/refresh.d.ts.map +1 -1
  22. package/dist/data/resolve.d.ts +10 -0
  23. package/dist/data/resolve.d.ts.map +1 -1
  24. package/dist/data/supabase.d.ts.map +1 -1
  25. package/dist/data/types.d.ts +22 -0
  26. package/dist/data/types.d.ts.map +1 -1
  27. package/dist/i18n/index.d.ts +7 -0
  28. package/dist/i18n/index.d.ts.map +1 -1
  29. package/dist/i18n/index.js +1 -1
  30. package/dist/i18n/shell-translations.en.d.ts +2 -0
  31. package/dist/i18n/shell-translations.en.d.ts.map +1 -0
  32. package/dist/i18n/shell-translations.pt-br.d.ts +2 -0
  33. package/dist/i18n/shell-translations.pt-br.d.ts.map +1 -0
  34. package/dist/index.d.ts +6 -3
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +10 -6
  37. package/dist/index.js.map +1 -1
  38. package/dist/search/engine.d.ts.map +1 -1
  39. package/dist/shell-translations.pt-br-2GWRQRRP.js +875 -0
  40. package/dist/shell-translations.pt-br-2GWRQRRP.js.map +1 -0
  41. package/dist/tenant/index.d.ts +10 -0
  42. package/dist/tenant/index.d.ts.map +1 -1
  43. package/dist/types/org.d.ts +9 -3
  44. package/dist/types/org.d.ts.map +1 -1
  45. package/dist/types/plugins.d.ts +8 -0
  46. package/dist/types/plugins.d.ts.map +1 -1
  47. package/package.json +21 -29
  48. package/src/access/engine.ts +16 -1
  49. package/src/access/index.ts +1 -0
  50. package/src/app/render.tsx +1 -1
  51. package/src/data/archetype.ts +23 -0
  52. package/src/data/bulk.ts +35 -0
  53. package/src/data/filters.test.ts +70 -0
  54. package/src/data/filters.ts +90 -0
  55. package/src/data/index.ts +2 -2
  56. package/src/data/mock.ts +8 -2
  57. package/src/data/platform-api.ts +12 -3
  58. package/src/data/refresh.ts +11 -1
  59. package/src/data/resolve.ts +16 -4
  60. package/src/data/supabase.ts +60 -1
  61. package/src/data/types.ts +24 -0
  62. package/src/i18n/index.ts +58 -6
  63. package/src/i18n/shell-translations.en.ts +875 -0
  64. package/src/i18n/shell-translations.pt-br.ts +873 -0
  65. package/src/index.ts +11 -3
  66. package/src/search/engine.ts +8 -0
  67. package/src/tenant/index.ts +20 -0
  68. package/src/types/org.ts +9 -3
  69. package/src/types/plugins.ts +8 -0
  70. package/dist/access/index.cjs +0 -60
  71. package/dist/access/index.cjs.map +0 -1
  72. package/dist/chunk-56GH3WC2.cjs +0 -35
  73. package/dist/chunk-56GH3WC2.cjs.map +0 -1
  74. package/dist/chunk-5TKIZVVJ.cjs +0 -16
  75. package/dist/chunk-5TKIZVVJ.cjs.map +0 -1
  76. package/dist/chunk-AXTWKF5X.cjs +0 -38
  77. package/dist/chunk-AXTWKF5X.cjs.map +0 -1
  78. package/dist/chunk-CATASHPK.cjs +0 -2018
  79. package/dist/chunk-CATASHPK.cjs.map +0 -1
  80. package/dist/chunk-DZALZ6Q6.js +0 -1988
  81. package/dist/chunk-DZALZ6Q6.js.map +0 -1
  82. package/dist/chunk-KSI2L3E4.cjs.map +0 -1
  83. package/dist/chunk-P5OJUH25.cjs +0 -81
  84. package/dist/chunk-P5OJUH25.cjs.map +0 -1
  85. package/dist/chunk-TYPVSWLG.js +0 -718
  86. package/dist/chunk-TYPVSWLG.js.map +0 -1
  87. package/dist/chunk-UKU4RIWM.cjs +0 -32
  88. package/dist/chunk-UKU4RIWM.cjs.map +0 -1
  89. package/dist/chunk-ZOPJB5FN.cjs +0 -369
  90. package/dist/chunk-ZOPJB5FN.cjs.map +0 -1
  91. package/dist/data/cloud.d.ts +0 -5
  92. package/dist/data/cloud.d.ts.map +0 -1
  93. package/dist/data/index.cjs +0 -52
  94. package/dist/data/index.cjs.map +0 -1
  95. package/dist/entity/index.cjs +0 -28
  96. package/dist/entity/index.cjs.map +0 -1
  97. package/dist/i18n/index.cjs +0 -44
  98. package/dist/i18n/index.cjs.map +0 -1
  99. package/dist/i18n/shell-translations.d.ts +0 -2
  100. package/dist/i18n/shell-translations.d.ts.map +0 -1
  101. package/dist/index.cjs +0 -2462
  102. package/dist/index.cjs.map +0 -1
  103. package/dist/integrations/index.cjs +0 -12
  104. package/dist/integrations/index.cjs.map +0 -1
  105. package/dist/plugin/index.cjs +0 -32
  106. package/dist/plugin/index.cjs.map +0 -1
  107. package/dist/router/index.cjs +0 -16
  108. package/dist/router/index.cjs.map +0 -1
  109. package/dist/runtime/index.cjs +0 -16
  110. package/dist/runtime/index.cjs.map +0 -1
  111. package/dist/testing/index.cjs +0 -20
  112. package/dist/testing/index.cjs.map +0 -1
  113. package/dist/types/index.cjs +0 -4
  114. package/dist/types/index.cjs.map +0 -1
  115. package/src/data/cloud.ts +0 -28
  116. package/src/i18n/shell-translations.ts +0 -1748
package/dist/index.cjs DELETED
@@ -1,2462 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk56GH3WC2_cjs = require('./chunk-56GH3WC2.cjs');
4
- var chunkP5OJUH25_cjs = require('./chunk-P5OJUH25.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
- var chunkAXTWKF5X_cjs = require('./chunk-AXTWKF5X.cjs');
10
- var chunk5TKIZVVJ_cjs = require('./chunk-5TKIZVVJ.cjs');
11
- var React3 = require('react');
12
- var zustand = require('zustand');
13
-
14
- function _interopNamespace(e) {
15
- if (e && e.__esModule) return e;
16
- var n = Object.create(null);
17
- if (e) {
18
- Object.keys(e).forEach(function (k) {
19
- if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
24
- });
25
- }
26
- });
27
- }
28
- n.default = e;
29
- return Object.freeze(n);
30
- }
31
-
32
- var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
33
-
34
- // src/types/plugins.ts
35
- var WidgetZone = {
36
- SIDEBAR_BEFORE_NAV: "shell.sidebar.before-nav",
37
- SIDEBAR_FOOTER: "shell.sidebar.footer",
38
- TOPBAR_START: "shell.topbar.start",
39
- TOPBAR_END: "shell.topbar.end",
40
- PAGE_BEFORE: "page.before",
41
- PAGE_AFTER: "page.after",
42
- SETTINGS_BEFORE: "settings.before",
43
- SETTINGS_AFTER: "settings.after",
44
- FLOATING: "shell.floating"
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
- }
137
-
138
- // src/plugin/createSafeDataProvider.ts
139
- function createSafeDataProvider(makeSupabase, makeMock) {
140
- let resolved = null;
141
- const get = () => {
142
- if (!resolved) {
143
- resolved = chunkKSI2L3E4_cjs.getSupabaseClientOptional() ? makeSupabase() : makeMock();
144
- }
145
- return resolved;
146
- };
147
- return new Proxy({}, {
148
- get: (_target, prop) => (...args) => get()[prop](...args)
149
- });
150
- }
151
-
152
- // src/phone/index.ts
153
- function flagOf(iso2) {
154
- return iso2.toUpperCase().replace(/[^A-Z]/g, "").split("").map((c) => String.fromCodePoint(127462 + c.charCodeAt(0) - 65)).join("");
155
- }
156
- var RAW = [
157
- { iso2: "BR", name: "Brasil", dial: "+55", mask: "(##) #####-####" },
158
- { iso2: "US", name: "Estados Unidos", dial: "+1", mask: "(###) ###-####" },
159
- { iso2: "PT", name: "Portugal", dial: "+351", mask: "### ### ###" },
160
- { iso2: "AR", name: "Argentina", dial: "+54", mask: "(##) ####-####" },
161
- { iso2: "ES", name: "Espanha", dial: "+34", mask: "### ### ###" },
162
- { iso2: "MX", name: "M\xE9xico", dial: "+52", mask: "## #### ####" },
163
- { iso2: "GB", name: "Reino Unido", dial: "+44", mask: "##### ######" },
164
- { iso2: "FR", name: "Fran\xE7a", dial: "+33", mask: "# ## ## ## ##" },
165
- { iso2: "DE", name: "Alemanha", dial: "+49", mask: "#### #######" },
166
- { iso2: "IT", name: "It\xE1lia", dial: "+39", mask: "### #######" }
167
- ];
168
- var COUNTRIES = RAW.map((c) => ({ ...c, flag: flagOf(c.iso2) }));
169
- var DEFAULT_COUNTRY = "BR";
170
- var BY_ISO = new Map(COUNTRIES.map((c) => [c.iso2, c]));
171
- function getCountry(iso2) {
172
- return iso2 && BY_ISO.get(iso2.toUpperCase()) || BY_ISO.get(DEFAULT_COUNTRY);
173
- }
174
- function unmaskPhone(value) {
175
- return (value || "").replace(/\D/g, "");
176
- }
177
- function maskPhone(value, mask) {
178
- const digits = unmaskPhone(value);
179
- let out = "";
180
- let di = 0;
181
- for (const ch of mask) {
182
- if (di >= digits.length) break;
183
- if (ch === "#") {
184
- out += digits[di++];
185
- } else {
186
- out += ch;
187
- }
188
- }
189
- return out;
190
- }
191
- function maskDigitCount(mask) {
192
- let n = 0;
193
- for (const ch of mask) if (ch === "#") n++;
194
- return n;
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
- }
282
- var MANAGED = "data-fayz-seo";
283
- function seoOrigin() {
284
- return typeof window !== "undefined" ? window.location.origin : "";
285
- }
286
- function absoluteUrl(path) {
287
- return `${seoOrigin()}${path.startsWith("/") ? path : `/${path}`}`;
288
- }
289
- function upsertMeta(attr, key, content) {
290
- if (!content) return;
291
- let el = document.head.querySelector(`meta[${attr}="${key}"]`);
292
- if (!el) {
293
- el = document.createElement("meta");
294
- el.setAttribute(attr, key);
295
- el.setAttribute(MANAGED, "");
296
- document.head.appendChild(el);
297
- }
298
- el.setAttribute("content", content);
299
- }
300
- function upsertLink(rel, href) {
301
- if (!href) return;
302
- let el = document.head.querySelector(`link[rel="${rel}"]`);
303
- if (!el) {
304
- el = document.createElement("link");
305
- el.setAttribute("rel", rel);
306
- el.setAttribute(MANAGED, "");
307
- document.head.appendChild(el);
308
- }
309
- el.setAttribute("href", href);
310
- }
311
- function clearManaged() {
312
- document.head.querySelectorAll(`[${MANAGED}]`).forEach((el) => el.remove());
313
- }
314
- function applySeo(config) {
315
- if (typeof document === "undefined") return;
316
- clearManaged();
317
- document.title = config.title;
318
- upsertMeta("name", "description", config.description ?? "");
319
- if (config.canonical) upsertLink("canonical", config.canonical);
320
- upsertMeta("property", "og:title", config.title);
321
- upsertMeta("property", "og:description", config.description ?? "");
322
- upsertMeta("property", "og:type", config.type === "article" ? "article" : "website");
323
- if (config.canonical) upsertMeta("property", "og:url", config.canonical);
324
- if (config.image) upsertMeta("property", "og:image", config.image);
325
- if (config.siteName) upsertMeta("property", "og:site_name", config.siteName);
326
- upsertMeta("name", "twitter:card", config.image ? "summary_large_image" : "summary");
327
- upsertMeta("name", "twitter:title", config.title);
328
- upsertMeta("name", "twitter:description", config.description ?? "");
329
- if (config.image) upsertMeta("name", "twitter:image", config.image);
330
- for (const obj of config.jsonLd ?? []) {
331
- const script = document.createElement("script");
332
- script.type = "application/ld+json";
333
- script.setAttribute(MANAGED, "");
334
- script.text = JSON.stringify(obj);
335
- document.head.appendChild(script);
336
- }
337
- }
338
- function useSeo(config) {
339
- const key = JSON.stringify(config);
340
- React3.useEffect(() => {
341
- applySeo(config);
342
- return () => clearManaged();
343
- }, [key]);
344
- }
345
- function breadcrumbJsonLd(items) {
346
- return {
347
- "@context": "https://schema.org",
348
- "@type": "BreadcrumbList",
349
- itemListElement: items.map((c, i) => ({
350
- "@type": "ListItem",
351
- position: i + 1,
352
- name: c.name,
353
- item: c.url
354
- }))
355
- };
356
- }
357
- function organizationJsonLd(name, extra) {
358
- return { "@type": "Organization", name, ...extra };
359
- }
360
-
361
- // src/lib/format.ts
362
- var CURRENCY_BY_LOCALE = {
363
- "pt-BR": "BRL",
364
- "pt-PT": "EUR",
365
- en: "USD",
366
- "en-US": "USD",
367
- "en-GB": "GBP",
368
- es: "EUR"
369
- };
370
- var _defaultCurrency = null;
371
- function setDefaultCurrency(code) {
372
- _defaultCurrency = code ?? null;
373
- }
374
- function getActiveLocale() {
375
- try {
376
- return chunkCATASHPK_cjs.getCurrentLocale() || "en";
377
- } catch {
378
- return "en";
379
- }
380
- }
381
- function getDefaultCurrency() {
382
- if (_defaultCurrency) return _defaultCurrency;
383
- return CURRENCY_BY_LOCALE[getActiveLocale()] ?? "USD";
384
- }
385
- function formatCurrency(value, currency) {
386
- const num = typeof value === "number" ? value : parseFloat(String(value));
387
- if (isNaN(num)) return String(value ?? "");
388
- return new Intl.NumberFormat(getActiveLocale(), {
389
- style: "currency",
390
- currency: currency ?? getDefaultCurrency()
391
- }).format(num);
392
- }
393
- function formatDate(value) {
394
- if (!value) return "";
395
- try {
396
- return new Intl.DateTimeFormat(getActiveLocale(), { dateStyle: "medium" }).format(new Date(value));
397
- } catch {
398
- return String(value);
399
- }
400
- }
401
- function formatDateTime(value) {
402
- if (!value) return "";
403
- try {
404
- return new Intl.DateTimeFormat(getActiveLocale(), { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
405
- } catch {
406
- return String(value);
407
- }
408
- }
409
-
410
- // src/lib/csv.ts
411
- function escapeCSVField(value) {
412
- if (value == null) return "";
413
- const str = String(value);
414
- if (str.includes(",") || str.includes('"') || str.includes("\n")) {
415
- return `"${str.replace(/"/g, '""')}"`;
416
- }
417
- return str;
418
- }
419
- function buildCSV(columns, rows) {
420
- const header = columns.map((c) => escapeCSVField(c.label)).join(",");
421
- const body = rows.map(
422
- (row) => columns.map((col) => {
423
- const raw = row[col.key];
424
- const formatted = col.format ? col.format(raw, row) : raw;
425
- return escapeCSVField(formatted);
426
- }).join(",")
427
- );
428
- return [header, ...body].join("\n");
429
- }
430
- function downloadCSV(csv, filename) {
431
- const bom = "\uFEFF";
432
- const blob = new Blob([bom + csv], { type: "text/csv;charset=utf-8;" });
433
- const url = URL.createObjectURL(blob);
434
- const a = document.createElement("a");
435
- a.href = url;
436
- a.download = filename.endsWith(".csv") ? filename : `${filename}.csv`;
437
- a.click();
438
- URL.revokeObjectURL(url);
439
- }
440
- function exportCSV(columns, rows, filename) {
441
- downloadCSV(buildCSV(columns, rows), filename);
442
- }
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;
462
- }
463
- if (pendingSpace) {
464
- out.push(" ");
465
- map.push(i);
466
- pendingSpace = false;
467
- }
468
- out.push(f);
469
- map.push(i);
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
490
- };
491
- }
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;
994
- }
995
- function UnknownBlock({ type }) {
996
- return React3__namespace.createElement(
997
- "div",
998
- {
999
- style: {
1000
- border: "1px dashed #c026d3",
1001
- color: "#a21caf",
1002
- padding: "8px 12px",
1003
- font: "12px ui-monospace, monospace",
1004
- borderRadius: 6
1005
- }
1006
- },
1007
- `Unknown block: "${type}"`
1008
- );
1009
- }
1010
- function BlockRenderer({ node }) {
1011
- const Comp = chunkZOPJB5FN_cjs.getBlock(node.type);
1012
- const childEls = node.children?.length ? node.children.map(
1013
- (child, i) => React3__namespace.createElement(BlockRenderer, { key: child.id ?? `${child.type}-${i}`, node: child })
1014
- ) : null;
1015
- if (!Comp) return React3__namespace.createElement(UnknownBlock, { type: node.type });
1016
- return React3__namespace.createElement(Comp, { ...node.props ?? {}, node }, childEls);
1017
- }
1018
- function renderBlocks(nodes) {
1019
- return nodes.map(
1020
- (node, i) => React3__namespace.createElement(BlockRenderer, { key: node.id ?? `${node.type}-${i}`, node })
1021
- );
1022
- }
1023
- function BlockChildren({ node }) {
1024
- if (!node?.children?.length) return null;
1025
- return renderBlocks(node.children);
1026
- }
1027
-
1028
- // src/manifest/index.ts
1029
- var CURRENT_MANIFEST_VERSION = 3;
1030
- var migrations = /* @__PURE__ */ new Map();
1031
- var supportedBackendProviders = ["supabase", "fayz-api", "fayz-shop", "mock", "custom"];
1032
- var supportedPageSections = /* @__PURE__ */ new Set(["main", "secondary", "settings"]);
1033
- var allowedManifestKeys = /* @__PURE__ */ new Set([
1034
- "manifestVersion",
1035
- "id",
1036
- "name",
1037
- "backend",
1038
- "locale",
1039
- "theme",
1040
- "permissions",
1041
- "billing",
1042
- "entities",
1043
- "surfaces",
1044
- "limitDeclarations",
1045
- "agent",
1046
- "contractHash"
1047
- ]);
1048
- var allowedBackendKeys = /* @__PURE__ */ new Set(["provider", "projectRef", "url", "adapterId", "options"]);
1049
- var allowedSurfaceKeys = /* @__PURE__ */ new Set(["scaffold", "options", "plugins", "pages"]);
1050
- var allowedPluginRefKeys = /* @__PURE__ */ new Set(["id", "config", "enabled"]);
1051
- var allowedPageKeys = /* @__PURE__ */ new Set(["path", "label", "icon", "section", "blocks", "entity", "component", "permission"]);
1052
- var allowedPermissionKeys = /* @__PURE__ */ new Set(["feature", "action"]);
1053
- var allowedBlockKeys = /* @__PURE__ */ new Set(["type", "id", "props", "children"]);
1054
- var manifestIdPattern = /^[a-z0-9][a-z0-9-]*$/;
1055
- function registerManifestMigration(fromVersion, fn) {
1056
- migrations.set(fromVersion, fn);
1057
- }
1058
- registerManifestMigration(2, (m) => m);
1059
- function migrateManifest(input) {
1060
- let m = { ...input };
1061
- let version = typeof m.manifestVersion === "number" ? m.manifestVersion : 1;
1062
- if (version > CURRENT_MANIFEST_VERSION) {
1063
- throw new Error(
1064
- `Manifest version ${version} is newer than this SDK supports (${CURRENT_MANIFEST_VERSION}). Upgrade @fayz-ai/core.`
1065
- );
1066
- }
1067
- while (version < CURRENT_MANIFEST_VERSION) {
1068
- const migrate = migrations.get(version);
1069
- if (!migrate) {
1070
- throw new Error(`No manifest migration registered from version ${version}.`);
1071
- }
1072
- m = migrate(m);
1073
- version += 1;
1074
- m.manifestVersion = version;
1075
- }
1076
- return m;
1077
- }
1078
- function validateManifest(m) {
1079
- const problems = [];
1080
- const manifest = m;
1081
- addUnsupportedKeys(manifest, allowedManifestKeys, "manifest", problems);
1082
- if (!Number.isInteger(manifest.manifestVersion)) {
1083
- problems.push("manifest.manifestVersion must be an integer");
1084
- } else if (manifest.manifestVersion !== CURRENT_MANIFEST_VERSION) {
1085
- problems.push(`manifest.manifestVersion must be ${CURRENT_MANIFEST_VERSION}`);
1086
- }
1087
- if (typeof manifest.id !== "string" || !manifest.id.trim()) problems.push("manifest.id is required");
1088
- else if (!manifestIdPattern.test(manifest.id.trim())) {
1089
- problems.push("manifest.id must match /^[a-z0-9][a-z0-9-]*$/");
1090
- }
1091
- if (typeof manifest.name !== "string" || !manifest.name.trim()) problems.push("manifest.name is required");
1092
- validateLooseObject(manifest.locale, "manifest.locale", problems);
1093
- validateLooseObject(manifest.theme, "manifest.theme", problems);
1094
- validateLooseObject(manifest.permissions, "manifest.permissions", problems);
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
- }
1111
- if (manifest.entities !== void 0) {
1112
- if (!Array.isArray(manifest.entities)) {
1113
- problems.push("manifest.entities must be an array");
1114
- } else {
1115
- manifest.entities.forEach((entity, index) => {
1116
- if (!isRecord(entity)) problems.push(`manifest.entities[${index}] must be an object`);
1117
- });
1118
- }
1119
- }
1120
- if (manifest.backend !== void 0) {
1121
- if (!isRecord(manifest.backend)) {
1122
- problems.push("manifest.backend must be an object");
1123
- } else {
1124
- addUnsupportedKeys(manifest.backend, allowedBackendKeys, "manifest.backend", problems);
1125
- const provider = manifest.backend.provider;
1126
- if (typeof provider !== "string" || !supportedBackendProviders.includes(provider)) {
1127
- problems.push(`manifest.backend.provider "${String(provider)}" is not supported`);
1128
- }
1129
- validateOptionalNonEmptyString(manifest.backend.projectRef, "manifest.backend.projectRef", problems);
1130
- validateOptionalNonEmptyString(manifest.backend.url, "manifest.backend.url", problems);
1131
- if (provider === "custom" && !isNonEmptyString(manifest.backend.adapterId)) {
1132
- problems.push('manifest.backend.adapterId is required when provider is "custom"');
1133
- } else if (provider !== "custom") {
1134
- validateOptionalNonEmptyString(manifest.backend.adapterId, "manifest.backend.adapterId", problems);
1135
- }
1136
- validateLooseObject(manifest.backend.options, "manifest.backend.options", problems);
1137
- }
1138
- }
1139
- if (!isRecord(manifest.surfaces) || Object.keys(manifest.surfaces).length === 0) {
1140
- problems.push("manifest.surfaces must declare at least one surface");
1141
- } else {
1142
- for (const [name, surface] of Object.entries(manifest.surfaces)) {
1143
- validateSurfaceManifest(name, surface, problems);
1144
- }
1145
- }
1146
- return problems;
1147
- }
1148
- function validateSurfaceManifest(name, surface, problems) {
1149
- if (!isRecord(surface)) {
1150
- problems.push(`surface "${name}" must be an object`);
1151
- return;
1152
- }
1153
- addUnsupportedKeys(surface, allowedSurfaceKeys, `surface "${name}"`, problems);
1154
- if (!isNonEmptyString(surface.scaffold)) problems.push(`surface "${name}" is missing a scaffold id`);
1155
- validateLooseObject(surface.options, `surface "${name}".options`, problems);
1156
- if (surface.pages !== void 0) {
1157
- if (!Array.isArray(surface.pages)) {
1158
- problems.push(`surface "${name}".pages must be an array`);
1159
- } else {
1160
- const pagePaths = /* @__PURE__ */ new Set();
1161
- for (const [index, page] of surface.pages.entries()) {
1162
- validatePageManifest(name, index, page, pagePaths, problems);
1163
- }
1164
- }
1165
- }
1166
- if (surface.plugins !== void 0) {
1167
- if (!Array.isArray(surface.plugins)) {
1168
- problems.push(`surface "${name}".plugins must be an array`);
1169
- } else {
1170
- const pluginIds = /* @__PURE__ */ new Set();
1171
- for (const [index, plugin] of surface.plugins.entries()) {
1172
- validatePluginRef(name, index, plugin, pluginIds, problems);
1173
- }
1174
- }
1175
- }
1176
- }
1177
- function validatePageManifest(surfaceName, index, page, pagePaths, problems) {
1178
- const pageLabel = `surface "${surfaceName}" page #${index + 1}`;
1179
- if (!isRecord(page)) {
1180
- problems.push(`${pageLabel} must be an object`);
1181
- return;
1182
- }
1183
- addUnsupportedKeys(page, allowedPageKeys, pageLabel, problems);
1184
- if (!isNonEmptyString(page.path)) {
1185
- problems.push(`${pageLabel} has an empty path`);
1186
- } else {
1187
- const normalizedPath = page.path.trim();
1188
- if (pagePaths.has(normalizedPath)) {
1189
- problems.push(`surface "${surfaceName}" declares duplicate page path "${normalizedPath}"`);
1190
- } else {
1191
- pagePaths.add(normalizedPath);
1192
- }
1193
- }
1194
- if (page.label !== void 0 && typeof page.label !== "string") problems.push(`${pageLabel}.label must be a string`);
1195
- if (page.icon !== void 0 && typeof page.icon !== "string") problems.push(`${pageLabel}.icon must be a string`);
1196
- if (page.section !== void 0 && (typeof page.section !== "string" || !supportedPageSections.has(page.section))) {
1197
- problems.push(`${pageLabel}.section must be one of main, secondary, settings`);
1198
- }
1199
- if (page.entity !== void 0 && !isNonEmptyString(page.entity)) problems.push(`${pageLabel}.entity must be a non-empty string`);
1200
- if (page.component !== void 0 && !isNonEmptyString(page.component)) {
1201
- problems.push(`${pageLabel}.component must be a non-empty string`);
1202
- }
1203
- const kinds = [page.blocks, page.entity, page.component].filter((x) => x != null);
1204
- if (kinds.length !== 1) {
1205
- problems.push(`${pageLabel} must set exactly one of blocks/entity/component`);
1206
- }
1207
- if (page.permission !== void 0) {
1208
- validatePermission(page.permission, `${pageLabel}.permission`, problems);
1209
- }
1210
- if (page.blocks !== void 0) {
1211
- if (!Array.isArray(page.blocks)) {
1212
- problems.push(`${pageLabel}.blocks must be an array`);
1213
- } else {
1214
- page.blocks.forEach((block, blockIndex) => {
1215
- validateBlockManifest(block, `${pageLabel}.blocks[${blockIndex}]`, problems);
1216
- });
1217
- }
1218
- }
1219
- }
1220
- function validatePluginRef(surfaceName, index, plugin, pluginIds, problems) {
1221
- const pluginLabel = `surface "${surfaceName}" plugin #${index + 1}`;
1222
- if (!isRecord(plugin)) {
1223
- problems.push(`${pluginLabel} must be an object`);
1224
- return;
1225
- }
1226
- addUnsupportedKeys(plugin, allowedPluginRefKeys, pluginLabel, problems);
1227
- if (!isNonEmptyString(plugin.id)) {
1228
- problems.push(`${pluginLabel} has an empty id`);
1229
- } else {
1230
- const normalizedId = plugin.id.trim();
1231
- if (pluginIds.has(normalizedId)) {
1232
- problems.push(`surface "${surfaceName}" declares duplicate plugin id "${normalizedId}"`);
1233
- } else {
1234
- pluginIds.add(normalizedId);
1235
- }
1236
- }
1237
- validateLooseObject(plugin.config, `${pluginLabel}.config`, problems);
1238
- if (plugin.enabled !== void 0 && typeof plugin.enabled !== "boolean") {
1239
- problems.push(`${pluginLabel}.enabled must be a boolean`);
1240
- }
1241
- }
1242
- function validatePermission(permission, path, problems) {
1243
- if (!isRecord(permission)) {
1244
- problems.push(`${path} must be an object`);
1245
- return;
1246
- }
1247
- addUnsupportedKeys(permission, allowedPermissionKeys, path, problems);
1248
- if (!isNonEmptyString(permission.feature)) problems.push(`${path}.feature is required`);
1249
- if (!isNonEmptyString(permission.action)) problems.push(`${path}.action is required`);
1250
- }
1251
- function validateBlockManifest(block, path, problems) {
1252
- if (!isRecord(block)) {
1253
- problems.push(`${path} must be an object`);
1254
- return;
1255
- }
1256
- addUnsupportedKeys(block, allowedBlockKeys, path, problems);
1257
- if (!isNonEmptyString(block.type)) problems.push(`${path}.type is required`);
1258
- validateLooseObject(block.props, `${path}.props`, problems);
1259
- if (block.id !== void 0 && typeof block.id !== "string") problems.push(`${path}.id must be a string`);
1260
- if (block.children !== void 0) {
1261
- if (!Array.isArray(block.children)) {
1262
- problems.push(`${path}.children must be an array`);
1263
- } else {
1264
- block.children.forEach((child, index) => validateBlockManifest(child, `${path}.children[${index}]`, problems));
1265
- }
1266
- }
1267
- }
1268
- function addUnsupportedKeys(value, allowedKeys, path, problems) {
1269
- for (const key of Object.keys(value)) {
1270
- if (!allowedKeys.has(key)) {
1271
- problems.push(`${path}.${key} is not part of AppManifest v${CURRENT_MANIFEST_VERSION}`);
1272
- }
1273
- }
1274
- }
1275
- function validateLooseObject(value, path, problems) {
1276
- if (value !== void 0 && !isRecord(value)) {
1277
- problems.push(`${path} must be an object`);
1278
- }
1279
- }
1280
- function validateOptionalNonEmptyString(value, path, problems) {
1281
- if (value !== void 0 && !isNonEmptyString(value)) {
1282
- problems.push(`${path} must be a non-empty string`);
1283
- }
1284
- }
1285
- function isRecord(value) {
1286
- return typeof value === "object" && value !== null && !Array.isArray(value);
1287
- }
1288
- function isNonEmptyString(value) {
1289
- return typeof value === "string" && value.trim().length > 0;
1290
- }
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
-
1323
- // src/manifest/app-manifest.schema.json
1324
- var app_manifest_schema_default = {
1325
- $schema: "https://json-schema.org/draft/2020-12/schema",
1326
- $id: "https://fayz.ai/schemas/app-manifest/v3.json",
1327
- title: "Fayz AppManifest",
1328
- description: "The canonical, JSON-serializable definition of a Fayz app. Code is referenced by registry id; never inlined.",
1329
- type: "object",
1330
- required: [
1331
- "manifestVersion",
1332
- "id",
1333
- "name",
1334
- "surfaces"
1335
- ],
1336
- additionalProperties: false,
1337
- properties: {
1338
- manifestVersion: {
1339
- type: "integer",
1340
- const: 3,
1341
- description: "Current AppManifest schema version. Older or newer versions require an explicit SDK migration before validation."
1342
- },
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
- },
1352
- backend: {
1353
- type: "object",
1354
- additionalProperties: false,
1355
- required: [
1356
- "provider"
1357
- ],
1358
- properties: {
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"
1401
- }
1402
- },
1403
- surfaces: {
1404
- type: "object",
1405
- minProperties: 1,
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)."
1451
- }
1452
- },
1453
- $defs: {
1454
- surface: {
1455
- type: "object",
1456
- required: [
1457
- "scaffold"
1458
- ],
1459
- additionalProperties: false,
1460
- properties: {
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
- }
1480
- }
1481
- },
1482
- pluginRef: {
1483
- type: "object",
1484
- required: [
1485
- "id"
1486
- ],
1487
- additionalProperties: false,
1488
- properties: {
1489
- id: {
1490
- type: "string",
1491
- minLength: 1
1492
- },
1493
- config: {
1494
- type: "object"
1495
- },
1496
- enabled: {
1497
- type: "boolean"
1498
- }
1499
- }
1500
- },
1501
- page: {
1502
- type: "object",
1503
- required: [
1504
- "path"
1505
- ],
1506
- additionalProperties: false,
1507
- description: "Exactly one of blocks/entity/component must be set.",
1508
- properties: {
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
- },
1540
- permission: {
1541
- type: "object",
1542
- required: [
1543
- "feature",
1544
- "action"
1545
- ],
1546
- additionalProperties: false,
1547
- properties: {
1548
- feature: {
1549
- type: "string",
1550
- minLength: 1
1551
- },
1552
- action: {
1553
- type: "string",
1554
- minLength: 1
1555
- }
1556
- }
1557
- }
1558
- },
1559
- oneOf: [
1560
- {
1561
- required: [
1562
- "blocks"
1563
- ]
1564
- },
1565
- {
1566
- required: [
1567
- "entity"
1568
- ]
1569
- },
1570
- {
1571
- required: [
1572
- "component"
1573
- ]
1574
- }
1575
- ]
1576
- },
1577
- block: {
1578
- type: "object",
1579
- required: [
1580
- "type"
1581
- ],
1582
- additionalProperties: false,
1583
- properties: {
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
- }
1996
- }
1997
- }
1998
- }
1999
- };
2000
- var ManifestContext = React3__namespace.createContext(null);
2001
- function useManifest() {
2002
- return React3__namespace.useContext(ManifestContext);
2003
- }
2004
- function defineApp(manifest) {
2005
- const full = {
2006
- ...manifest,
2007
- manifestVersion: manifest.manifestVersion ?? CURRENT_MANIFEST_VERSION
2008
- };
2009
- const problems = validateManifest(full);
2010
- if (problems.length) {
2011
- throw new Error(`Invalid AppManifest:
2012
- - ${problems.join("\n - ")}`);
2013
- }
2014
- return full;
2015
- }
2016
- function renderApp(input, opts = {}) {
2017
- const manifest = migrateManifest(input);
2018
- const problems = validateManifest(manifest);
2019
- if (problems.length) {
2020
- throw new Error(`Invalid AppManifest:
2021
- - ${problems.join("\n - ")}`);
2022
- }
2023
- const surfaceName = opts.surface ?? Object.keys(manifest.surfaces)[0];
2024
- const surface = surfaceName ? manifest.surfaces[surfaceName] : void 0;
2025
- if (!surface) {
2026
- throw new Error(`Surface "${surfaceName}" not found in manifest.`);
2027
- }
2028
- const Scaffold = chunkZOPJB5FN_cjs.getScaffold(surface.scaffold);
2029
- if (!Scaffold) {
2030
- throw new Error(
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.`
2032
- );
2033
- }
2034
- return React3__namespace.createElement(
2035
- ManifestContext.Provider,
2036
- { value: manifest },
2037
- React3__namespace.createElement(Scaffold, { manifest, surface: surfaceName })
2038
- );
2039
- }
2040
- var MAX_ENTRIES = 20;
2041
- var useNavHistoryStore = zustand.create((set) => ({
2042
- stack: [],
2043
- record: (entry) => set((s) => {
2044
- const top = s.stack[s.stack.length - 1];
2045
- if (top && top.path === entry.path) {
2046
- if (top.label === entry.label) return s;
2047
- const next2 = s.stack.slice();
2048
- next2[next2.length - 1] = entry;
2049
- return { stack: next2 };
2050
- }
2051
- const next = [...s.stack, entry];
2052
- return { stack: next.length > MAX_ENTRIES ? next.slice(-MAX_ENTRIES) : next };
2053
- })
2054
- }));
2055
- function recordNavigation(path, label) {
2056
- useNavHistoryStore.getState().record({ path, label });
2057
- }
2058
- if (typeof window !== "undefined") {
2059
- window.__navHistory = useNavHistoryStore;
2060
- }
2061
- function useNavReferrer(currentPath) {
2062
- return useNavHistoryStore((s) => {
2063
- for (let i = s.stack.length - 1; i >= 0; i--) {
2064
- if (s.stack[i].path !== currentPath) return s.stack[i];
2065
- }
2066
- return null;
2067
- });
2068
- }
2069
- function navHistoryBack(fallback) {
2070
- if (useNavHistoryStore.getState().stack.length >= 2) {
2071
- window.history.back();
2072
- } else {
2073
- fallback?.();
2074
- }
2075
- }
2076
- function routeModule(path) {
2077
- return path.replace(/^\/+/, "").split("/")[0] ?? "";
2078
- }
2079
-
2080
- Object.defineProperty(exports, "withAfterHooks", {
2081
- enumerable: true,
2082
- get: function () { return chunk56GH3WC2_cjs.withAfterHooks; }
2083
- });
2084
- Object.defineProperty(exports, "PluginContractError", {
2085
- enumerable: true,
2086
- get: function () { return chunkP5OJUH25_cjs.PluginContractError; }
2087
- });
2088
- Object.defineProperty(exports, "assertConnectorContract", {
2089
- enumerable: true,
2090
- get: function () { return chunkP5OJUH25_cjs.assertConnectorContract; }
2091
- });
2092
- Object.defineProperty(exports, "assertPluginManifestContract", {
2093
- enumerable: true,
2094
- get: function () { return chunkP5OJUH25_cjs.assertPluginManifestContract; }
2095
- });
2096
- Object.defineProperty(exports, "FAYZ_CLOUD_PUBLISHABLE_KEY", {
2097
- enumerable: true,
2098
- get: function () { return chunkKSI2L3E4_cjs.FAYZ_CLOUD_PUBLISHABLE_KEY; }
2099
- });
2100
- Object.defineProperty(exports, "FAYZ_CLOUD_URL", {
2101
- enumerable: true,
2102
- get: function () { return chunkKSI2L3E4_cjs.FAYZ_CLOUD_URL; }
2103
- });
2104
- Object.defineProperty(exports, "clearGlobalCache", {
2105
- enumerable: true,
2106
- get: function () { return chunkKSI2L3E4_cjs.clearGlobalCache; }
2107
- });
2108
- Object.defineProperty(exports, "countByTenant", {
2109
- enumerable: true,
2110
- get: function () { return chunkKSI2L3E4_cjs.countByTenant; }
2111
- });
2112
- Object.defineProperty(exports, "createArchetypeProvider", {
2113
- enumerable: true,
2114
- get: function () { return chunkKSI2L3E4_cjs.createArchetypeProvider; }
2115
- });
2116
- Object.defineProperty(exports, "createCacheStore", {
2117
- enumerable: true,
2118
- get: function () { return chunkKSI2L3E4_cjs.createCacheStore; }
2119
- });
2120
- Object.defineProperty(exports, "createFayzApiProvider", {
2121
- enumerable: true,
2122
- get: function () { return chunkKSI2L3E4_cjs.createFayzApiProvider; }
2123
- });
2124
- Object.defineProperty(exports, "createMockProvider", {
2125
- enumerable: true,
2126
- get: function () { return chunkKSI2L3E4_cjs.createMockProvider; }
2127
- });
2128
- Object.defineProperty(exports, "createSupabaseProvider", {
2129
- enumerable: true,
2130
- get: function () { return chunkKSI2L3E4_cjs.createSupabaseProvider; }
2131
- });
2132
- Object.defineProperty(exports, "getActiveTenantId", {
2133
- enumerable: true,
2134
- get: function () { return chunkKSI2L3E4_cjs.getActiveTenantId; }
2135
- });
2136
- Object.defineProperty(exports, "getFayzCloudClient", {
2137
- enumerable: true,
2138
- get: function () { return chunkKSI2L3E4_cjs.getFayzCloudClient; }
2139
- });
2140
- Object.defineProperty(exports, "getSupabaseClientOptional", {
2141
- enumerable: true,
2142
- get: function () { return chunkKSI2L3E4_cjs.getSupabaseClientOptional; }
2143
- });
2144
- Object.defineProperty(exports, "globalCache", {
2145
- enumerable: true,
2146
- get: function () { return chunkKSI2L3E4_cjs.globalCache; }
2147
- });
2148
- Object.defineProperty(exports, "invalidateCount", {
2149
- enumerable: true,
2150
- get: function () { return chunkKSI2L3E4_cjs.invalidateCount; }
2151
- });
2152
- Object.defineProperty(exports, "resolveDataProvider", {
2153
- enumerable: true,
2154
- get: function () { return chunkKSI2L3E4_cjs.resolveDataProvider; }
2155
- });
2156
- Object.defineProperty(exports, "setActiveTenantId", {
2157
- enumerable: true,
2158
- get: function () { return chunkKSI2L3E4_cjs.setActiveTenantId; }
2159
- });
2160
- Object.defineProperty(exports, "setGlobalSupabaseClient", {
2161
- enumerable: true,
2162
- get: function () { return chunkKSI2L3E4_cjs.setGlobalSupabaseClient; }
2163
- });
2164
- Object.defineProperty(exports, "stableKey", {
2165
- enumerable: true,
2166
- get: function () { return chunkKSI2L3E4_cjs.stableKey; }
2167
- });
2168
- Object.defineProperty(exports, "withCache", {
2169
- enumerable: true,
2170
- get: function () { return chunkKSI2L3E4_cjs.withCache; }
2171
- });
2172
- Object.defineProperty(exports, "clearEntityRegistry", {
2173
- enumerable: true,
2174
- get: function () { return chunkUKU4RIWM_cjs.clearEntityRegistry; }
2175
- });
2176
- Object.defineProperty(exports, "deriveEntityKey", {
2177
- enumerable: true,
2178
- get: function () { return chunkUKU4RIWM_cjs.deriveEntityKey; }
2179
- });
2180
- Object.defineProperty(exports, "getAllEntities", {
2181
- enumerable: true,
2182
- get: function () { return chunkUKU4RIWM_cjs.getAllEntities; }
2183
- });
2184
- Object.defineProperty(exports, "getEntityByKey", {
2185
- enumerable: true,
2186
- get: function () { return chunkUKU4RIWM_cjs.getEntityByKey; }
2187
- });
2188
- Object.defineProperty(exports, "registerEntity", {
2189
- enumerable: true,
2190
- get: function () { return chunkUKU4RIWM_cjs.registerEntity; }
2191
- });
2192
- Object.defineProperty(exports, "PLUGIN_API_VERSION", {
2193
- enumerable: true,
2194
- get: function () { return chunkZOPJB5FN_cjs.PLUGIN_API_VERSION; }
2195
- });
2196
- Object.defineProperty(exports, "PluginRuntimeProvider", {
2197
- enumerable: true,
2198
- get: function () { return chunkZOPJB5FN_cjs.PluginRuntimeProvider; }
2199
- });
2200
- Object.defineProperty(exports, "Registry", {
2201
- enumerable: true,
2202
- get: function () { return chunkZOPJB5FN_cjs.Registry; }
2203
- });
2204
- Object.defineProperty(exports, "blockRegistry", {
2205
- enumerable: true,
2206
- get: function () { return chunkZOPJB5FN_cjs.blockRegistry; }
2207
- });
2208
- Object.defineProperty(exports, "componentRegistry", {
2209
- enumerable: true,
2210
- get: function () { return chunkZOPJB5FN_cjs.componentRegistry; }
2211
- });
2212
- Object.defineProperty(exports, "definePlugin", {
2213
- enumerable: true,
2214
- get: function () { return chunkZOPJB5FN_cjs.definePlugin; }
2215
- });
2216
- Object.defineProperty(exports, "getBlock", {
2217
- enumerable: true,
2218
- get: function () { return chunkZOPJB5FN_cjs.getBlock; }
2219
- });
2220
- Object.defineProperty(exports, "getComponent", {
2221
- enumerable: true,
2222
- get: function () { return chunkZOPJB5FN_cjs.getComponent; }
2223
- });
2224
- Object.defineProperty(exports, "getDashboardWidgets", {
2225
- enumerable: true,
2226
- get: function () { return chunkZOPJB5FN_cjs.getDashboardWidgets; }
2227
- });
2228
- Object.defineProperty(exports, "getMetric", {
2229
- enumerable: true,
2230
- get: function () { return chunkZOPJB5FN_cjs.getMetric; }
2231
- });
2232
- Object.defineProperty(exports, "getPage", {
2233
- enumerable: true,
2234
- get: function () { return chunkZOPJB5FN_cjs.getPage; }
2235
- });
2236
- Object.defineProperty(exports, "getPlugin", {
2237
- enumerable: true,
2238
- get: function () { return chunkZOPJB5FN_cjs.getPlugin; }
2239
- });
2240
- Object.defineProperty(exports, "getPluginFactory", {
2241
- enumerable: true,
2242
- get: function () { return chunkZOPJB5FN_cjs.getPluginFactory; }
2243
- });
2244
- Object.defineProperty(exports, "getScaffold", {
2245
- enumerable: true,
2246
- get: function () { return chunkZOPJB5FN_cjs.getScaffold; }
2247
- });
2248
- Object.defineProperty(exports, "getWidgetsForZone", {
2249
- enumerable: true,
2250
- get: function () { return chunkZOPJB5FN_cjs.getWidgetsForZone; }
2251
- });
2252
- Object.defineProperty(exports, "isCustomId", {
2253
- enumerable: true,
2254
- get: function () { return chunkZOPJB5FN_cjs.isCustomId; }
2255
- });
2256
- Object.defineProperty(exports, "listBlocks", {
2257
- enumerable: true,
2258
- get: function () { return chunkZOPJB5FN_cjs.listBlocks; }
2259
- });
2260
- Object.defineProperty(exports, "listMetrics", {
2261
- enumerable: true,
2262
- get: function () { return chunkZOPJB5FN_cjs.listMetrics; }
2263
- });
2264
- Object.defineProperty(exports, "listPluginFactories", {
2265
- enumerable: true,
2266
- get: function () { return chunkZOPJB5FN_cjs.listPluginFactories; }
2267
- });
2268
- Object.defineProperty(exports, "listPlugins", {
2269
- enumerable: true,
2270
- get: function () { return chunkZOPJB5FN_cjs.listPlugins; }
2271
- });
2272
- Object.defineProperty(exports, "metricRegistry", {
2273
- enumerable: true,
2274
- get: function () { return chunkZOPJB5FN_cjs.metricRegistry; }
2275
- });
2276
- Object.defineProperty(exports, "pageRegistry", {
2277
- enumerable: true,
2278
- get: function () { return chunkZOPJB5FN_cjs.pageRegistry; }
2279
- });
2280
- Object.defineProperty(exports, "pluginFactoryRegistry", {
2281
- enumerable: true,
2282
- get: function () { return chunkZOPJB5FN_cjs.pluginFactoryRegistry; }
2283
- });
2284
- Object.defineProperty(exports, "pluginRegistry", {
2285
- enumerable: true,
2286
- get: function () { return chunkZOPJB5FN_cjs.pluginRegistry; }
2287
- });
2288
- Object.defineProperty(exports, "registerBlock", {
2289
- enumerable: true,
2290
- get: function () { return chunkZOPJB5FN_cjs.registerBlock; }
2291
- });
2292
- Object.defineProperty(exports, "registerComponent", {
2293
- enumerable: true,
2294
- get: function () { return chunkZOPJB5FN_cjs.registerComponent; }
2295
- });
2296
- Object.defineProperty(exports, "registerMetric", {
2297
- enumerable: true,
2298
- get: function () { return chunkZOPJB5FN_cjs.registerMetric; }
2299
- });
2300
- Object.defineProperty(exports, "registerPage", {
2301
- enumerable: true,
2302
- get: function () { return chunkZOPJB5FN_cjs.registerPage; }
2303
- });
2304
- Object.defineProperty(exports, "registerPlugin", {
2305
- enumerable: true,
2306
- get: function () { return chunkZOPJB5FN_cjs.registerPlugin; }
2307
- });
2308
- Object.defineProperty(exports, "registerPluginFactory", {
2309
- enumerable: true,
2310
- get: function () { return chunkZOPJB5FN_cjs.registerPluginFactory; }
2311
- });
2312
- Object.defineProperty(exports, "registerScaffold", {
2313
- enumerable: true,
2314
- get: function () { return chunkZOPJB5FN_cjs.registerScaffold; }
2315
- });
2316
- Object.defineProperty(exports, "resolvePluginComponent", {
2317
- enumerable: true,
2318
- get: function () { return chunkZOPJB5FN_cjs.resolvePluginComponent; }
2319
- });
2320
- Object.defineProperty(exports, "resolvePluginRuntime", {
2321
- enumerable: true,
2322
- get: function () { return chunkZOPJB5FN_cjs.resolvePluginRuntime; }
2323
- });
2324
- Object.defineProperty(exports, "scaffoldRegistry", {
2325
- enumerable: true,
2326
- get: function () { return chunkZOPJB5FN_cjs.scaffoldRegistry; }
2327
- });
2328
- Object.defineProperty(exports, "useConnectorsForPlugin", {
2329
- enumerable: true,
2330
- get: function () { return chunkZOPJB5FN_cjs.useConnectorsForPlugin; }
2331
- });
2332
- Object.defineProperty(exports, "usePluginRuntime", {
2333
- enumerable: true,
2334
- get: function () { return chunkZOPJB5FN_cjs.usePluginRuntime; }
2335
- });
2336
- Object.defineProperty(exports, "usePluginRuntimeOptional", {
2337
- enumerable: true,
2338
- get: function () { return chunkZOPJB5FN_cjs.usePluginRuntimeOptional; }
2339
- });
2340
- Object.defineProperty(exports, "I18nProvider", {
2341
- enumerable: true,
2342
- get: function () { return chunkCATASHPK_cjs.I18nProvider; }
2343
- });
2344
- Object.defineProperty(exports, "coreTranslations", {
2345
- enumerable: true,
2346
- get: function () { return chunkCATASHPK_cjs.coreTranslations; }
2347
- });
2348
- Object.defineProperty(exports, "getCurrentLocale", {
2349
- enumerable: true,
2350
- get: function () { return chunkCATASHPK_cjs.getCurrentLocale; }
2351
- });
2352
- Object.defineProperty(exports, "mergeTranslations", {
2353
- enumerable: true,
2354
- get: function () { return chunkCATASHPK_cjs.mergeTranslations; }
2355
- });
2356
- Object.defineProperty(exports, "registerTranslations", {
2357
- enumerable: true,
2358
- get: function () { return chunkCATASHPK_cjs.registerTranslations; }
2359
- });
2360
- Object.defineProperty(exports, "setCurrentLocale", {
2361
- enumerable: true,
2362
- get: function () { return chunkCATASHPK_cjs.setCurrentLocale; }
2363
- });
2364
- Object.defineProperty(exports, "setLocaleStore", {
2365
- enumerable: true,
2366
- get: function () { return chunkCATASHPK_cjs.setLocaleStore; }
2367
- });
2368
- Object.defineProperty(exports, "useI18nConfig", {
2369
- enumerable: true,
2370
- get: function () { return chunkCATASHPK_cjs.useI18nConfig; }
2371
- });
2372
- Object.defineProperty(exports, "useTranslation", {
2373
- enumerable: true,
2374
- get: function () { return chunkCATASHPK_cjs.useTranslation; }
2375
- });
2376
- Object.defineProperty(exports, "hashRouterAdapter", {
2377
- enumerable: true,
2378
- get: function () { return chunkAXTWKF5X_cjs.hashRouterAdapter; }
2379
- });
2380
- Object.defineProperty(exports, "windowRouterAdapter", {
2381
- enumerable: true,
2382
- get: function () { return chunkAXTWKF5X_cjs.windowRouterAdapter; }
2383
- });
2384
- Object.defineProperty(exports, "FayzRuntimeError", {
2385
- enumerable: true,
2386
- get: function () { return chunk5TKIZVVJ_cjs.FayzRuntimeError; }
2387
- });
2388
- Object.defineProperty(exports, "createFayzRuntimeClient", {
2389
- enumerable: true,
2390
- get: function () { return chunk5TKIZVVJ_cjs.createFayzRuntimeClient; }
2391
- });
2392
- exports.BlockChildren = BlockChildren;
2393
- exports.BlockRenderer = BlockRenderer;
2394
- exports.COUNTRIES = COUNTRIES;
2395
- exports.CURRENT_MANIFEST_VERSION = CURRENT_MANIFEST_VERSION;
2396
- exports.DATA_CHANGED_EVENT = DATA_CHANGED_EVENT;
2397
- exports.DEFAULT_COUNTRY = DEFAULT_COUNTRY;
2398
- exports.MIN_QUERY_LENGTH = MIN_QUERY_LENGTH;
2399
- exports.WidgetZone = WidgetZone;
2400
- exports.absoluteUrl = absoluteUrl;
2401
- exports.appManifestSchema = app_manifest_schema_default;
2402
- exports.applySeo = applySeo;
2403
- exports.breadcrumbJsonLd = breadcrumbJsonLd;
2404
- exports.buildCSV = buildCSV;
2405
- exports.clearPostalCache = clearPostalCache;
2406
- exports.clearSearchCache = clearSearchCache;
2407
- exports.computeContractHash = computeContractHash;
2408
- exports.createEventBus = createEventBus;
2409
- exports.createSafeDataProvider = createSafeDataProvider;
2410
- exports.createViaCepProvider = createViaCepProvider;
2411
- exports.defineApp = defineApp;
2412
- exports.digitsOf = digitsOf;
2413
- exports.downloadCSV = downloadCSV;
2414
- exports.emitDataChanged = emitDataChanged;
2415
- exports.eventBus = eventBus;
2416
- exports.exportCSV = exportCSV;
2417
- exports.foldText = foldText;
2418
- exports.foldWithMap = foldWithMap;
2419
- exports.formatCurrency = formatCurrency;
2420
- exports.formatDate = formatDate;
2421
- exports.formatDateTime = formatDateTime;
2422
- exports.formatPostalCode = formatPostalCode;
2423
- exports.getActiveLocale = getActiveLocale;
2424
- exports.getCountry = getCountry;
2425
- exports.getDefaultCurrency = getDefaultCurrency;
2426
- exports.getPostalLookupProvider = getPostalLookupProvider;
2427
- exports.highlightRanges = highlightRanges;
2428
- exports.isSearchIndexAvailable = isSearchIndexAvailable;
2429
- exports.isValidPostalCode = isValidPostalCode;
2430
- exports.lookupPostalCode = lookupPostalCode;
2431
- exports.maskDigitCount = maskDigitCount;
2432
- exports.maskPhone = maskPhone;
2433
- exports.matchesDataChange = matchesDataChange;
2434
- exports.migrateManifest = migrateManifest;
2435
- exports.navHistoryBack = navHistoryBack;
2436
- exports.normalizePostalCode = normalizePostalCode;
2437
- exports.normalizeQuery = normalizeQuery;
2438
- exports.organizationJsonLd = organizationJsonLd;
2439
- exports.recordNavigation = recordNavigation;
2440
- exports.registerManifestMigration = registerManifestMigration;
2441
- exports.renderApp = renderApp;
2442
- exports.renderBlocks = renderBlocks;
2443
- exports.routeModule = routeModule;
2444
- exports.scoreCandidate = scoreCandidate;
2445
- exports.searchEverything = searchEverything;
2446
- exports.seoOrigin = seoOrigin;
2447
- exports.serializeManifest = serializeManifest;
2448
- exports.serializeManifestWithHash = serializeManifestWithHash;
2449
- exports.setDefaultCurrency = setDefaultCurrency;
2450
- exports.setPostalLookupProvider = setPostalLookupProvider;
2451
- exports.setSearchIndexAvailable = setSearchIndexAvailable;
2452
- exports.similarity = similarity;
2453
- exports.unmaskPhone = unmaskPhone;
2454
- exports.useDataChanged = useDataChanged;
2455
- exports.useManifest = useManifest;
2456
- exports.useNavHistoryStore = useNavHistoryStore;
2457
- exports.useNavReferrer = useNavReferrer;
2458
- exports.useOnEvent = useOnEvent;
2459
- exports.useSeo = useSeo;
2460
- exports.validateManifest = validateManifest;
2461
- //# sourceMappingURL=index.cjs.map
2462
- //# sourceMappingURL=index.cjs.map