@fayz-ai/core 0.39.0 → 0.43.0

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 (39) hide show
  1. package/dist/chunk-FRLSCYUI.js +146 -0
  2. package/dist/chunk-FRLSCYUI.js.map +1 -0
  3. package/dist/{chunk-X3GYBLGO.js → chunk-GRNICWPS.js} +4 -4
  4. package/dist/{chunk-X3GYBLGO.js.map → chunk-GRNICWPS.js.map} +1 -1
  5. package/dist/{chunk-FTQOB7HF.js → chunk-KPJ4I4UF.js} +15 -3
  6. package/dist/chunk-KPJ4I4UF.js.map +1 -0
  7. package/dist/{chunk-U2K7ZEDA.js → chunk-LARVDWGE.js} +5 -125
  8. package/dist/chunk-LARVDWGE.js.map +1 -0
  9. package/dist/{chunk-EFMUJACX.js → chunk-QBQNHNLG.js} +3 -3
  10. package/dist/{chunk-EFMUJACX.js.map → chunk-QBQNHNLG.js.map} +1 -1
  11. package/dist/{chunk-QZ22VPRZ.js → chunk-SKSCC4RQ.js} +4 -4
  12. package/dist/{chunk-QZ22VPRZ.js.map → chunk-SKSCC4RQ.js.map} +1 -1
  13. package/dist/{chunk-MFFT663T.js → chunk-ZO6FBMUZ.js} +3 -3
  14. package/dist/{chunk-MFFT663T.js.map → chunk-ZO6FBMUZ.js.map} +1 -1
  15. package/dist/data/index.js +4 -3
  16. package/dist/i18n/index.js +1 -1
  17. package/dist/i18n/shell-translations.en.d.ts.map +1 -1
  18. package/dist/i18n/shell-translations.pt-br.d.ts.map +1 -1
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +102 -23
  22. package/dist/index.js.map +1 -1
  23. package/dist/integrations/index.js +4 -3
  24. package/dist/lib/connectivity.d.ts +17 -0
  25. package/dist/lib/connectivity.d.ts.map +1 -0
  26. package/dist/lib/error-message.d.ts +7 -0
  27. package/dist/lib/error-message.d.ts.map +1 -1
  28. package/dist/plugin/index.js +3 -2
  29. package/dist/{shell-translations.pt-br-CBHOC37X.js → shell-translations.pt-br-CPAZDDTQ.js} +14 -2
  30. package/dist/shell-translations.pt-br-CPAZDDTQ.js.map +1 -0
  31. package/dist/telemetry/errors.d.ts +3 -0
  32. package/dist/telemetry/errors.d.ts.map +1 -1
  33. package/dist/testing/index.js +5 -4
  34. package/package.json +1 -1
  35. package/dist/chunk-6TVRNKWW.js +0 -17
  36. package/dist/chunk-6TVRNKWW.js.map +0 -1
  37. package/dist/chunk-FTQOB7HF.js.map +0 -1
  38. package/dist/chunk-U2K7ZEDA.js.map +0 -1
  39. package/dist/shell-translations.pt-br-CBHOC37X.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { globalCache, getActiveTenantId, getSupabaseClientOptional, parseRangeFilter, matchesRange, assertWrote, stableKey, DEFAULT_CACHE_TTL, getScopedResource, createSupabaseProvider, resolveUnitScope, applyUnitScope, applyRangeToQuery, isFilterObject, clearGlobalCache } from './chunk-MFFT663T.js';
1
+ import { globalCache, getActiveTenantId, getSupabaseClientOptional, parseRangeFilter, matchesRange, assertWrote, stableKey, DEFAULT_CACHE_TTL, getScopedResource, createSupabaseProvider, resolveUnitScope, applyUnitScope, applyRangeToQuery, isFilterObject, clearGlobalCache } from './chunk-ZO6FBMUZ.js';
2
2
  import { declaredCustomFields, validateEntityRecordData } from './chunk-EWKX4VUM.js';
3
- import { errorMessage } from './chunk-6TVRNKWW.js';
3
+ import { toDataError, DataError, errorMessage } from './chunk-FRLSCYUI.js';
4
4
  import * as React from 'react';
5
5
 
6
6
  // src/data/count.ts
@@ -602,126 +602,6 @@ function withCache(provider, options) {
602
602
  };
603
603
  }
604
604
 
605
- // src/data/errors.ts
606
- var RETRYABLE_KINDS = ["offline", "server"];
607
- var DataError = class extends Error {
608
- constructor(kind, message, options = {}) {
609
- super(message);
610
- this.name = "DataError";
611
- this.kind = kind;
612
- this.retryable = RETRYABLE_KINDS.includes(kind);
613
- this.cause = options.cause;
614
- this.status = options.status;
615
- this.code = options.code;
616
- this.details = options.details;
617
- this.hint = options.hint;
618
- }
619
- };
620
- var CODE_KINDS = {
621
- // PostgREST
622
- PGRST100: "invalid",
623
- // parse error in the query string
624
- PGRST106: "missing-object",
625
- // schema not exposed
626
- PGRST116: "not-found",
627
- // zero rows where exactly one was requested
628
- PGRST202: "missing-object",
629
- // function not found in schema cache
630
- PGRST204: "missing-object",
631
- // column not found in schema cache
632
- PGRST205: "missing-object",
633
- // table not found in schema cache
634
- PGRST301: "unauthorized",
635
- // JWT invalid or expired
636
- PGRST302: "unauthorized",
637
- // anonymous access disabled
638
- // Postgres
639
- "22007": "invalid",
640
- // invalid datetime format
641
- "22P02": "invalid",
642
- // invalid input syntax
643
- "23502": "invalid",
644
- // not-null violation
645
- "23505": "conflict",
646
- // unique violation
647
- "23514": "invalid",
648
- // check violation
649
- "42501": "forbidden",
650
- // insufficient privilege / permission denied
651
- "42883": "missing-object",
652
- // undefined function
653
- "42P01": "missing-object",
654
- // undefined table
655
- "53300": "server",
656
- // too many connections
657
- "57014": "server"
658
- // statement timeout, server side
659
- };
660
- var OFFLINE_CODES = /* @__PURE__ */ new Set(["ECONNREFUSED", "ECONNRESET", "ENOTFOUND", "ETIMEDOUT", "EAI_AGAIN"]);
661
- var OFFLINE_TEXT = /failed to fetch|fetch failed|network ?error|networkrequestfailed|load failed|connection (refused|reset|closed)|err_internet_disconnected|aborted|signal is aborted|the operation was aborted|timed out|timeout/i;
662
- function statusKind(status) {
663
- if (status === 401) return "unauthorized";
664
- if (status === 403) return "forbidden";
665
- if (status === 404 || status === 406) return "not-found";
666
- if (status === 408) return "offline";
667
- if (status === 409) return "conflict";
668
- if (status === 400 || status === 422) return "invalid";
669
- if (status >= 500) return "server";
670
- return "server";
671
- }
672
- function textKind(message) {
673
- const m = message.toLowerCase();
674
- if (/permission denied|row-level security|row level security|insufficient privilege/.test(m)) return "forbidden";
675
- if (/does not exist|undefined table|undefined function|schema cache|could not find the (table|function)/.test(m)) return "missing-object";
676
- if (/jwt|not authenticated|invalid token|unauthorized|no api key/.test(m)) return "unauthorized";
677
- if (/duplicate key|already exists|conflict/.test(m)) return "conflict";
678
- if (/invalid input (syntax|value)|violates (not-null|check) constraint|invalid request/.test(m)) return "invalid";
679
- if (/no rows|not found/.test(m)) return "not-found";
680
- return void 0;
681
- }
682
- function pick(source, key) {
683
- const value = source[key];
684
- return value === null ? void 0 : value;
685
- }
686
- function readStatus(source) {
687
- for (const key of ["status", "statusCode", "httpStatus"]) {
688
- const value = pick(source, key);
689
- if (typeof value === "number") return value;
690
- if (typeof value === "string" && /^\d{3}$/.test(value)) return Number(value);
691
- }
692
- const response = pick(source, "response");
693
- if (response && typeof response === "object") {
694
- const status = response.status;
695
- if (typeof status === "number") return status;
696
- }
697
- return void 0;
698
- }
699
- function isOffline(name, message, code, status) {
700
- if (name === "AbortError" || name === "TimeoutError") return true;
701
- if (code && OFFLINE_CODES.has(code)) return true;
702
- if (status !== void 0) return false;
703
- const nav = globalThis.navigator;
704
- if (nav && nav.onLine === false) return true;
705
- return OFFLINE_TEXT.test(message);
706
- }
707
- function toDataError(err) {
708
- if (err instanceof DataError) return err;
709
- const source = err && typeof err === "object" ? err : {};
710
- const name = typeof source.name === "string" ? source.name : "";
711
- const rawMessage = typeof source.message === "string" ? source.message : "";
712
- const message = rawMessage || (typeof err === "string" ? err : "") || "data request failed";
713
- const codeValue = pick(source, "code");
714
- const code = typeof codeValue === "string" ? codeValue : typeof codeValue === "number" ? String(codeValue) : void 0;
715
- const status = readStatus(source);
716
- const details = typeof source.details === "string" ? source.details : void 0;
717
- const hint = typeof source.hint === "string" ? source.hint : void 0;
718
- let kind = code ? CODE_KINDS[code] : void 0;
719
- if (!kind && isOffline(name, message, code, status)) kind = "offline";
720
- if (!kind && status !== void 0) kind = statusKind(status);
721
- if (!kind) kind = textKind(message);
722
- return new DataError(kind ?? "server", message, { cause: err, status, code, details, hint });
723
- }
724
-
725
605
  // src/events/bus.ts
726
606
  function createEventBus() {
727
607
  const handlers = /* @__PURE__ */ new Map();
@@ -1989,6 +1869,6 @@ async function bulkRemove(provider, ids, options) {
1989
1869
  return { removed, failed };
1990
1870
  }
1991
1871
 
1992
- export { CustomFieldsError, DATA_CHANGED_EVENT, DataError, FIELDS_TABLE, attachPersistentCache, bulkCreate, bulkRemove, cacheKeyFor, cachePrefixFor, clearCustomFieldsCache, countByTenant, createArchetypeProvider, createEventBus, createFayzApiProvider, createMockProvider, dataCall, dataQuery, emitDataChanged, eventBus, getActiveUnitId, getPersistentCache, invalidateCount, isKnownMissing, isUnitMode, localList, matchesDataChange, mergeCustomFields, onDataChanged, registerDataTelemetry, rememberIfMissing, replicaKeyFor, resetActiveUnit, resetMissingObjects, resolveCustomFields, resolveDataProvider, setActiveUnitId, setUnitMode, subscribeActiveUnit, syncReplica, toDataError, useActiveUnitId, useDataChanged, useUnitMode, validateCustomFields, withCache, withOffline };
1993
- //# sourceMappingURL=chunk-U2K7ZEDA.js.map
1994
- //# sourceMappingURL=chunk-U2K7ZEDA.js.map
1872
+ export { CustomFieldsError, DATA_CHANGED_EVENT, FIELDS_TABLE, attachPersistentCache, bulkCreate, bulkRemove, cacheKeyFor, cachePrefixFor, clearCustomFieldsCache, countByTenant, createArchetypeProvider, createEventBus, createFayzApiProvider, createMockProvider, dataCall, dataQuery, emitDataChanged, eventBus, getActiveUnitId, getPersistentCache, invalidateCount, isKnownMissing, isUnitMode, localList, matchesDataChange, mergeCustomFields, onDataChanged, registerDataTelemetry, rememberIfMissing, replicaKeyFor, resetActiveUnit, resetMissingObjects, resolveCustomFields, resolveDataProvider, setActiveUnitId, setUnitMode, subscribeActiveUnit, syncReplica, useActiveUnitId, useDataChanged, useUnitMode, validateCustomFields, withCache, withOffline };
1873
+ //# sourceMappingURL=chunk-LARVDWGE.js.map
1874
+ //# sourceMappingURL=chunk-LARVDWGE.js.map