@fayz-ai/core 0.8.1 → 0.8.2

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 (98) hide show
  1. package/dist/access/denial.d.ts +21 -0
  2. package/dist/access/denial.d.ts.map +1 -0
  3. package/dist/access/engine.d.ts +63 -0
  4. package/dist/access/engine.d.ts.map +1 -0
  5. package/dist/access/index.cjs +60 -0
  6. package/dist/access/index.cjs.map +1 -0
  7. package/dist/access/index.d.ts +6 -0
  8. package/dist/access/index.d.ts.map +1 -0
  9. package/dist/access/index.js +51 -0
  10. package/dist/access/index.js.map +1 -0
  11. package/dist/access/limits.d.ts +10 -0
  12. package/dist/access/limits.d.ts.map +1 -0
  13. package/dist/address/index.d.ts +52 -0
  14. package/dist/address/index.d.ts.map +1 -0
  15. package/dist/{chunk-WKZVSKEU.js → chunk-CU64QI4A.js} +2 -2
  16. package/dist/chunk-CU64QI4A.js.map +1 -0
  17. package/dist/{chunk-54SRL7AJ.cjs → chunk-CYAWDW44.cjs} +141 -84
  18. package/dist/chunk-CYAWDW44.cjs.map +1 -0
  19. package/dist/{chunk-KNIVT6XZ.js → chunk-JHGXROKV.js} +230 -2
  20. package/dist/chunk-JHGXROKV.js.map +1 -0
  21. package/dist/{chunk-QR7U2URY.cjs → chunk-SO3VUKGZ.cjs} +230 -2
  22. package/dist/chunk-SO3VUKGZ.cjs.map +1 -0
  23. package/dist/{chunk-2NTHNWEH.cjs → chunk-UKU4RIWM.cjs} +2 -2
  24. package/dist/chunk-UKU4RIWM.cjs.map +1 -0
  25. package/dist/{chunk-ZBIWYDAR.js → chunk-XJKW2JRW.js} +140 -85
  26. package/dist/chunk-XJKW2JRW.js.map +1 -0
  27. package/dist/{chunk-CHGX6UYR.js → chunk-YH25Y4FW.js} +6 -3
  28. package/dist/chunk-YH25Y4FW.js.map +1 -0
  29. package/dist/{chunk-5X2VX3RQ.cjs → chunk-ZOPJB5FN.cjs} +6 -3
  30. package/dist/chunk-ZOPJB5FN.cjs.map +1 -0
  31. package/dist/data/count.d.ts +34 -0
  32. package/dist/data/count.d.ts.map +1 -0
  33. package/dist/data/index.cjs +18 -10
  34. package/dist/data/index.d.ts +2 -0
  35. package/dist/data/index.d.ts.map +1 -1
  36. package/dist/data/index.js +1 -1
  37. package/dist/data/resolve.d.ts.map +1 -1
  38. package/dist/entity/index.cjs +6 -6
  39. package/dist/entity/index.js +1 -1
  40. package/dist/entity/registry.d.ts +9 -0
  41. package/dist/entity/registry.d.ts.map +1 -1
  42. package/dist/i18n/index.cjs +10 -10
  43. package/dist/i18n/index.js +1 -1
  44. package/dist/i18n/shell-translations.d.ts.map +1 -1
  45. package/dist/index.cjs +852 -124
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.ts +10 -4
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +765 -56
  50. package/dist/index.js.map +1 -1
  51. package/dist/manifest/index.d.ts +109 -3
  52. package/dist/manifest/index.d.ts.map +1 -1
  53. package/dist/manifest/serialize.d.ts +14 -0
  54. package/dist/manifest/serialize.d.ts.map +1 -0
  55. package/dist/plugin/index.cjs +7 -7
  56. package/dist/plugin/index.js +1 -1
  57. package/dist/plugin/runtime.d.ts.map +1 -1
  58. package/dist/types/billing.d.ts +20 -0
  59. package/dist/types/billing.d.ts.map +1 -1
  60. package/dist/types/crud.d.ts +47 -1
  61. package/dist/types/crud.d.ts.map +1 -1
  62. package/dist/types/entitlements.d.ts +45 -0
  63. package/dist/types/entitlements.d.ts.map +1 -0
  64. package/dist/types/index.d.ts +4 -3
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/plugins.d.ts +84 -0
  67. package/dist/types/plugins.d.ts.map +1 -1
  68. package/package.json +14 -4
  69. package/src/access/denial.ts +33 -0
  70. package/src/access/engine.test.ts +48 -0
  71. package/src/access/engine.ts +121 -0
  72. package/src/access/index.ts +13 -0
  73. package/src/access/limits.ts +18 -0
  74. package/src/address/index.ts +188 -0
  75. package/src/data/count.test.ts +152 -0
  76. package/src/data/count.ts +131 -0
  77. package/src/data/index.ts +2 -0
  78. package/src/data/resolve.ts +7 -1
  79. package/src/entity/registry.ts +7 -0
  80. package/src/i18n/shell-translations.ts +230 -0
  81. package/src/index.ts +18 -3
  82. package/src/manifest/app-manifest.schema.json +618 -45
  83. package/src/manifest/index.ts +127 -3
  84. package/src/manifest/serialize.ts +52 -0
  85. package/src/plugin/runtime.ts +5 -1
  86. package/src/types/billing.ts +22 -0
  87. package/src/types/crud.ts +48 -1
  88. package/src/types/entitlements.ts +45 -0
  89. package/src/types/index.ts +4 -3
  90. package/src/types/plugins.ts +79 -0
  91. package/dist/chunk-2NTHNWEH.cjs.map +0 -1
  92. package/dist/chunk-54SRL7AJ.cjs.map +0 -1
  93. package/dist/chunk-5X2VX3RQ.cjs.map +0 -1
  94. package/dist/chunk-CHGX6UYR.js.map +0 -1
  95. package/dist/chunk-KNIVT6XZ.js.map +0 -1
  96. package/dist/chunk-QR7U2URY.cjs.map +0 -1
  97. package/dist/chunk-WKZVSKEU.js.map +0 -1
  98. package/dist/chunk-ZBIWYDAR.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  export { withAfterHooks } from './chunk-BBDNC3FP.js';
2
2
  export { PluginContractError, assertConnectorContract, assertPluginManifestContract } from './chunk-X5THHG6T.js';
3
- import { getSupabaseClientOptional } from './chunk-ZBIWYDAR.js';
4
- export { FAYZ_CLOUD_PUBLISHABLE_KEY, FAYZ_CLOUD_URL, clearGlobalCache, createArchetypeProvider, createCacheStore, createFayzApiProvider, createMockProvider, createSupabaseProvider, getActiveTenantId, getFayzCloudClient, getSupabaseClientOptional, globalCache, resolveDataProvider, setActiveTenantId, setGlobalSupabaseClient, stableKey, withCache } from './chunk-ZBIWYDAR.js';
5
- export { clearEntityRegistry, deriveEntityKey, getAllEntities, getEntityByKey, registerEntity } from './chunk-WKZVSKEU.js';
6
- import { getBlock, getScaffold } from './chunk-CHGX6UYR.js';
7
- export { PLUGIN_API_VERSION, PluginRuntimeProvider, Registry, blockRegistry, componentRegistry, definePlugin, getBlock, getComponent, getDashboardWidgets, getMetric, getPage, getPlugin, getPluginFactory, getScaffold, getWidgetsForZone, isCustomId, listBlocks, listMetrics, listPluginFactories, listPlugins, metricRegistry, pageRegistry, pluginFactoryRegistry, pluginRegistry, registerBlock, registerComponent, registerMetric, registerPage, registerPlugin, registerPluginFactory, registerScaffold, resolvePluginComponent, resolvePluginRuntime, scaffoldRegistry, useConnectorsForPlugin, usePluginRuntime, usePluginRuntimeOptional } from './chunk-CHGX6UYR.js';
8
- import { getCurrentLocale } from './chunk-KNIVT6XZ.js';
9
- export { I18nProvider, coreTranslations, getCurrentLocale, mergeTranslations, registerTranslations, setCurrentLocale, setLocaleStore, useI18nConfig, useTranslation } from './chunk-KNIVT6XZ.js';
3
+ import { getSupabaseClientOptional } from './chunk-XJKW2JRW.js';
4
+ export { FAYZ_CLOUD_PUBLISHABLE_KEY, FAYZ_CLOUD_URL, clearGlobalCache, countByTenant, createArchetypeProvider, createCacheStore, createFayzApiProvider, createMockProvider, createSupabaseProvider, getActiveTenantId, getFayzCloudClient, getSupabaseClientOptional, globalCache, invalidateCount, resolveDataProvider, setActiveTenantId, setGlobalSupabaseClient, stableKey, withCache } from './chunk-XJKW2JRW.js';
5
+ export { clearEntityRegistry, deriveEntityKey, getAllEntities, getEntityByKey, registerEntity } from './chunk-CU64QI4A.js';
6
+ import { getBlock, getScaffold } from './chunk-YH25Y4FW.js';
7
+ export { PLUGIN_API_VERSION, PluginRuntimeProvider, Registry, blockRegistry, componentRegistry, definePlugin, getBlock, getComponent, getDashboardWidgets, getMetric, getPage, getPlugin, getPluginFactory, getScaffold, getWidgetsForZone, isCustomId, listBlocks, listMetrics, listPluginFactories, listPlugins, metricRegistry, pageRegistry, pluginFactoryRegistry, pluginRegistry, registerBlock, registerComponent, registerMetric, registerPage, registerPlugin, registerPluginFactory, registerScaffold, resolvePluginComponent, resolvePluginRuntime, scaffoldRegistry, useConnectorsForPlugin, usePluginRuntime, usePluginRuntimeOptional } from './chunk-YH25Y4FW.js';
8
+ import { getCurrentLocale } from './chunk-JHGXROKV.js';
9
+ export { I18nProvider, coreTranslations, getCurrentLocale, mergeTranslations, registerTranslations, setCurrentLocale, setLocaleStore, useI18nConfig, useTranslation } from './chunk-JHGXROKV.js';
10
10
  export { hashRouterAdapter, windowRouterAdapter } from './chunk-Y2C2FBQP.js';
11
11
  export { FayzRuntimeError, createFayzRuntimeClient } from './chunk-7RTUHSKY.js';
12
12
  import * as React2 from 'react';
@@ -84,6 +84,92 @@ function maskDigitCount(mask) {
84
84
  for (const ch of mask) if (ch === "#") n++;
85
85
  return n;
86
86
  }
87
+
88
+ // src/address/index.ts
89
+ function normalizePostalCode(value) {
90
+ return (value || "").replace(/\D/g, "");
91
+ }
92
+ function formatPostalCode(value) {
93
+ const digits = normalizePostalCode(value).slice(0, 8);
94
+ return digits.length > 5 ? `${digits.slice(0, 5)}-${digits.slice(5)}` : digits;
95
+ }
96
+ function isValidPostalCode(value) {
97
+ return normalizePostalCode(value).length === 8;
98
+ }
99
+ var CACHE_KEY = "fayz.postal.cache.v1";
100
+ var memoryCache = /* @__PURE__ */ new Map();
101
+ function readCache(code) {
102
+ const hit = memoryCache.get(code);
103
+ if (hit) return hit;
104
+ try {
105
+ const raw = globalThis.localStorage?.getItem(CACHE_KEY);
106
+ if (!raw) return void 0;
107
+ const all = JSON.parse(raw);
108
+ const stored = all[code];
109
+ if (stored) memoryCache.set(code, stored);
110
+ return stored;
111
+ } catch {
112
+ return void 0;
113
+ }
114
+ }
115
+ function writeCache(code, address) {
116
+ memoryCache.set(code, address);
117
+ try {
118
+ const store = globalThis.localStorage;
119
+ if (!store) return;
120
+ const raw = store.getItem(CACHE_KEY);
121
+ const all = raw ? JSON.parse(raw) : {};
122
+ all[code] = address;
123
+ store.setItem(CACHE_KEY, JSON.stringify(all));
124
+ } catch {
125
+ }
126
+ }
127
+ function clearPostalCache() {
128
+ memoryCache.clear();
129
+ try {
130
+ globalThis.localStorage?.removeItem(CACHE_KEY);
131
+ } catch {
132
+ }
133
+ }
134
+ function createViaCepProvider(options) {
135
+ const fetcher = options?.fetcher ?? globalThis.fetch;
136
+ return {
137
+ async lookup(postalCode) {
138
+ const code = normalizePostalCode(postalCode);
139
+ if (code.length !== 8) return null;
140
+ const response = await fetcher(`https://viacep.com.br/ws/${code}/json/`);
141
+ if (!response.ok) throw new Error(`Consulta de CEP falhou (${response.status})`);
142
+ const data = await response.json();
143
+ if (data.erro === true || data.erro === "true" || !data.localidade) return null;
144
+ return {
145
+ postalCode: code,
146
+ street: data.logradouro ?? "",
147
+ district: data.bairro ?? "",
148
+ city: data.localidade,
149
+ state: (data.uf ?? "").toUpperCase(),
150
+ country: "BR",
151
+ cityCode: data.ibge || void 0
152
+ };
153
+ }
154
+ };
155
+ }
156
+ var _provider = null;
157
+ function setPostalLookupProvider(provider) {
158
+ _provider = provider;
159
+ }
160
+ function getPostalLookupProvider() {
161
+ if (!_provider) _provider = createViaCepProvider();
162
+ return _provider;
163
+ }
164
+ async function lookupPostalCode(postalCode) {
165
+ const code = normalizePostalCode(postalCode);
166
+ if (code.length !== 8) return null;
167
+ const cached = readCache(code);
168
+ if (cached) return cached;
169
+ const address = await getPostalLookupProvider().lookup(code);
170
+ if (address) writeCache(code, address);
171
+ return address;
172
+ }
87
173
  var MANAGED = "data-fayz-seo";
88
174
  function seoOrigin() {
89
175
  return typeof window !== "undefined" ? window.location.origin : "";
@@ -329,7 +415,7 @@ function BlockChildren({ node }) {
329
415
  }
330
416
 
331
417
  // src/manifest/index.ts
332
- var CURRENT_MANIFEST_VERSION = 2;
418
+ var CURRENT_MANIFEST_VERSION = 3;
333
419
  var migrations = /* @__PURE__ */ new Map();
334
420
  var supportedBackendProviders = ["supabase", "fayz-api", "fayz-shop", "mock", "custom"];
335
421
  var supportedPageSections = /* @__PURE__ */ new Set(["main", "secondary", "settings"]);
@@ -343,7 +429,10 @@ var allowedManifestKeys = /* @__PURE__ */ new Set([
343
429
  "permissions",
344
430
  "billing",
345
431
  "entities",
346
- "surfaces"
432
+ "surfaces",
433
+ "limitDeclarations",
434
+ "agent",
435
+ "contractHash"
347
436
  ]);
348
437
  var allowedBackendKeys = /* @__PURE__ */ new Set(["provider", "projectRef", "url", "adapterId", "options"]);
349
438
  var allowedSurfaceKeys = /* @__PURE__ */ new Set(["scaffold", "options", "plugins", "pages"]);
@@ -355,6 +444,7 @@ var manifestIdPattern = /^[a-z0-9][a-z0-9-]*$/;
355
444
  function registerManifestMigration(fromVersion, fn) {
356
445
  migrations.set(fromVersion, fn);
357
446
  }
447
+ registerManifestMigration(2, (m) => m);
358
448
  function migrateManifest(input) {
359
449
  let m = { ...input };
360
450
  let version = typeof m.manifestVersion === "number" ? m.manifestVersion : 1;
@@ -392,6 +482,21 @@ function validateManifest(m) {
392
482
  validateLooseObject(manifest.theme, "manifest.theme", problems);
393
483
  validateLooseObject(manifest.permissions, "manifest.permissions", problems);
394
484
  validateLooseObject(manifest.billing, "manifest.billing", problems);
485
+ validateLooseObject(manifest.agent, "manifest.agent", problems);
486
+ if (manifest.contractHash !== void 0 && !isNonEmptyString(manifest.contractHash)) {
487
+ problems.push("manifest.contractHash must be a non-empty string");
488
+ }
489
+ if (manifest.limitDeclarations !== void 0) {
490
+ if (!Array.isArray(manifest.limitDeclarations)) {
491
+ problems.push("manifest.limitDeclarations must be an array");
492
+ } else {
493
+ manifest.limitDeclarations.forEach((decl, index) => {
494
+ if (!isRecord(decl) || !isNonEmptyString(decl.key) || !isNonEmptyString(decl.table)) {
495
+ problems.push(`manifest.limitDeclarations[${index}] must declare key and table`);
496
+ }
497
+ });
498
+ }
499
+ }
395
500
  if (manifest.entities !== void 0) {
396
501
  if (!Array.isArray(manifest.entities)) {
397
502
  problems.push("manifest.entities must be an array");
@@ -552,7 +657,7 @@ function validateBlockManifest(block, path, problems) {
552
657
  function addUnsupportedKeys(value, allowedKeys, path, problems) {
553
658
  for (const key of Object.keys(value)) {
554
659
  if (!allowedKeys.has(key)) {
555
- problems.push(`${path}.${key} is not part of AppManifest v2`);
660
+ problems.push(`${path}.${key} is not part of AppManifest v${CURRENT_MANIFEST_VERSION}`);
556
661
  }
557
662
  }
558
663
  }
@@ -573,106 +678,710 @@ function isNonEmptyString(value) {
573
678
  return typeof value === "string" && value.trim().length > 0;
574
679
  }
575
680
 
681
+ // src/manifest/serialize.ts
682
+ function sortValue(value) {
683
+ if (Array.isArray(value)) return value.map(sortValue);
684
+ if (value !== null && typeof value === "object") {
685
+ const record = value;
686
+ const out = {};
687
+ for (const key of Object.keys(record).sort()) {
688
+ const v = record[key];
689
+ if (v !== void 0) out[key] = sortValue(v);
690
+ }
691
+ return out;
692
+ }
693
+ return value;
694
+ }
695
+ function serializeManifest(manifest) {
696
+ const { contractHash: _omit, ...rest } = manifest;
697
+ return `${JSON.stringify(sortValue(rest), null, 2)}
698
+ `;
699
+ }
700
+ async function computeContractHash(manifest) {
701
+ const bytes = new TextEncoder().encode(serializeManifest(manifest));
702
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
703
+ return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
704
+ }
705
+ async function serializeManifestWithHash(manifest) {
706
+ const contractHash = await computeContractHash(manifest);
707
+ const { contractHash: _omit, ...rest } = manifest;
708
+ return `${JSON.stringify(sortValue({ ...rest, contractHash }), null, 2)}
709
+ `;
710
+ }
711
+
576
712
  // src/manifest/app-manifest.schema.json
577
713
  var app_manifest_schema_default = {
578
714
  $schema: "https://json-schema.org/draft/2020-12/schema",
579
- $id: "https://fayz.ai/schemas/app-manifest/v2.json",
715
+ $id: "https://fayz.ai/schemas/app-manifest/v3.json",
580
716
  title: "Fayz AppManifest",
581
717
  description: "The canonical, JSON-serializable definition of a Fayz app. Code is referenced by registry id; never inlined.",
582
718
  type: "object",
583
- required: ["manifestVersion", "id", "name", "surfaces"],
719
+ required: [
720
+ "manifestVersion",
721
+ "id",
722
+ "name",
723
+ "surfaces"
724
+ ],
584
725
  additionalProperties: false,
585
726
  properties: {
586
727
  manifestVersion: {
587
728
  type: "integer",
588
- const: 2,
729
+ const: 3,
589
730
  description: "Current AppManifest schema version. Older or newer versions require an explicit SDK migration before validation."
590
731
  },
591
- id: { type: "string", minLength: 1, pattern: "^[a-z0-9][a-z0-9-]*$" },
592
- name: { type: "string", minLength: 1 },
732
+ id: {
733
+ type: "string",
734
+ minLength: 1,
735
+ pattern: "^[a-z0-9][a-z0-9-]*$"
736
+ },
737
+ name: {
738
+ type: "string",
739
+ minLength: 1
740
+ },
593
741
  backend: {
594
742
  type: "object",
595
743
  additionalProperties: false,
596
- required: ["provider"],
744
+ required: [
745
+ "provider"
746
+ ],
597
747
  properties: {
598
- provider: { enum: ["supabase", "fayz-api", "fayz-shop", "mock", "custom"] },
599
- projectRef: { type: "string", minLength: 1 },
600
- url: { type: "string", minLength: 1 },
601
- adapterId: { type: "string", minLength: 1 },
602
- options: { type: "object" }
748
+ provider: {
749
+ enum: [
750
+ "supabase",
751
+ "fayz-api",
752
+ "fayz-shop",
753
+ "mock",
754
+ "custom"
755
+ ]
756
+ },
757
+ projectRef: {
758
+ type: "string",
759
+ minLength: 1
760
+ },
761
+ url: {
762
+ type: "string",
763
+ minLength: 1
764
+ },
765
+ adapterId: {
766
+ type: "string",
767
+ minLength: 1
768
+ },
769
+ options: {
770
+ type: "object"
771
+ }
772
+ }
773
+ },
774
+ locale: {
775
+ type: "object"
776
+ },
777
+ theme: {
778
+ type: "object"
779
+ },
780
+ permissions: {
781
+ type: "object"
782
+ },
783
+ billing: {
784
+ type: "object"
785
+ },
786
+ entities: {
787
+ type: "array",
788
+ items: {
789
+ type: "object"
603
790
  }
604
791
  },
605
- locale: { type: "object" },
606
- theme: { type: "object" },
607
- permissions: { type: "object" },
608
- billing: { type: "object" },
609
- entities: { type: "array", items: { type: "object" } },
610
792
  surfaces: {
611
793
  type: "object",
612
794
  minProperties: 1,
613
- additionalProperties: { $ref: "#/$defs/surface" }
795
+ additionalProperties: {
796
+ $ref: "#/$defs/surface"
797
+ }
798
+ },
799
+ limitDeclarations: {
800
+ type: "array",
801
+ description: "Resolved 4-layer limit-declaration merge (core < entity-derived < plugin < app) so server runtimes count exactly what the client counts.",
802
+ items: {
803
+ type: "object",
804
+ required: [
805
+ "key",
806
+ "table"
807
+ ],
808
+ additionalProperties: false,
809
+ properties: {
810
+ key: {
811
+ type: "string",
812
+ minLength: 1
813
+ },
814
+ label: {
815
+ type: "string"
816
+ },
817
+ table: {
818
+ type: "string",
819
+ minLength: 1
820
+ },
821
+ kindFilter: {
822
+ type: "string"
823
+ },
824
+ period: {
825
+ enum: [
826
+ "month",
827
+ "total"
828
+ ]
829
+ }
830
+ }
831
+ }
832
+ },
833
+ agent: {
834
+ $ref: "#/$defs/agentContract"
835
+ },
836
+ contractHash: {
837
+ type: "string",
838
+ minLength: 1,
839
+ description: "sha256 of the canonical serialization (excluding this field)."
614
840
  }
615
841
  },
616
842
  $defs: {
617
843
  surface: {
618
844
  type: "object",
619
- required: ["scaffold"],
845
+ required: [
846
+ "scaffold"
847
+ ],
620
848
  additionalProperties: false,
621
849
  properties: {
622
- scaffold: { type: "string", minLength: 1 },
623
- options: { type: "object" },
624
- plugins: { type: "array", items: { $ref: "#/$defs/pluginRef" } },
625
- pages: { type: "array", items: { $ref: "#/$defs/page" } }
850
+ scaffold: {
851
+ type: "string",
852
+ minLength: 1
853
+ },
854
+ options: {
855
+ type: "object"
856
+ },
857
+ plugins: {
858
+ type: "array",
859
+ items: {
860
+ $ref: "#/$defs/pluginRef"
861
+ }
862
+ },
863
+ pages: {
864
+ type: "array",
865
+ items: {
866
+ $ref: "#/$defs/page"
867
+ }
868
+ }
626
869
  }
627
870
  },
628
871
  pluginRef: {
629
872
  type: "object",
630
- required: ["id"],
873
+ required: [
874
+ "id"
875
+ ],
631
876
  additionalProperties: false,
632
877
  properties: {
633
- id: { type: "string", minLength: 1 },
634
- config: { type: "object" },
635
- enabled: { type: "boolean" }
878
+ id: {
879
+ type: "string",
880
+ minLength: 1
881
+ },
882
+ config: {
883
+ type: "object"
884
+ },
885
+ enabled: {
886
+ type: "boolean"
887
+ }
636
888
  }
637
889
  },
638
890
  page: {
639
891
  type: "object",
640
- required: ["path"],
892
+ required: [
893
+ "path"
894
+ ],
641
895
  additionalProperties: false,
642
896
  description: "Exactly one of blocks/entity/component must be set.",
643
897
  properties: {
644
- path: { type: "string", minLength: 1 },
645
- label: { type: "string" },
646
- icon: { type: "string" },
647
- section: { enum: ["main", "secondary", "settings"] },
648
- blocks: { type: "array", items: { $ref: "#/$defs/block" } },
649
- entity: { type: "string", minLength: 1 },
650
- component: { type: "string", minLength: 1 },
898
+ path: {
899
+ type: "string",
900
+ minLength: 1
901
+ },
902
+ label: {
903
+ type: "string"
904
+ },
905
+ icon: {
906
+ type: "string"
907
+ },
908
+ section: {
909
+ enum: [
910
+ "main",
911
+ "secondary",
912
+ "settings"
913
+ ]
914
+ },
915
+ blocks: {
916
+ type: "array",
917
+ items: {
918
+ $ref: "#/$defs/block"
919
+ }
920
+ },
921
+ entity: {
922
+ type: "string",
923
+ minLength: 1
924
+ },
925
+ component: {
926
+ type: "string",
927
+ minLength: 1
928
+ },
651
929
  permission: {
652
930
  type: "object",
653
- required: ["feature", "action"],
931
+ required: [
932
+ "feature",
933
+ "action"
934
+ ],
654
935
  additionalProperties: false,
655
936
  properties: {
656
- feature: { type: "string", minLength: 1 },
657
- action: { type: "string", minLength: 1 }
937
+ feature: {
938
+ type: "string",
939
+ minLength: 1
940
+ },
941
+ action: {
942
+ type: "string",
943
+ minLength: 1
944
+ }
658
945
  }
659
946
  }
660
947
  },
661
948
  oneOf: [
662
- { required: ["blocks"] },
663
- { required: ["entity"] },
664
- { required: ["component"] }
949
+ {
950
+ required: [
951
+ "blocks"
952
+ ]
953
+ },
954
+ {
955
+ required: [
956
+ "entity"
957
+ ]
958
+ },
959
+ {
960
+ required: [
961
+ "component"
962
+ ]
963
+ }
665
964
  ]
666
965
  },
667
966
  block: {
668
967
  type: "object",
669
- required: ["type"],
968
+ required: [
969
+ "type"
970
+ ],
971
+ additionalProperties: false,
972
+ properties: {
973
+ type: {
974
+ type: "string",
975
+ minLength: 1
976
+ },
977
+ id: {
978
+ type: "string"
979
+ },
980
+ props: {
981
+ type: "object"
982
+ },
983
+ children: {
984
+ type: "array",
985
+ items: {
986
+ $ref: "#/$defs/block"
987
+ }
988
+ }
989
+ }
990
+ },
991
+ agentContract: {
992
+ type: "object",
993
+ additionalProperties: false,
994
+ 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.",
995
+ properties: {
996
+ persona: {
997
+ type: "object",
998
+ additionalProperties: false,
999
+ properties: {
1000
+ name: {
1001
+ type: "string"
1002
+ },
1003
+ systemPrompt: {
1004
+ type: "string"
1005
+ },
1006
+ icon: {
1007
+ type: "string"
1008
+ }
1009
+ }
1010
+ },
1011
+ executionPlane: {
1012
+ enum: [
1013
+ "client",
1014
+ "server"
1015
+ ]
1016
+ },
1017
+ entities: {
1018
+ type: "array",
1019
+ items: {
1020
+ $ref: "#/$defs/entityContract"
1021
+ }
1022
+ },
1023
+ tools: {
1024
+ type: "array",
1025
+ items: {
1026
+ $ref: "#/$defs/aiToolContract"
1027
+ }
1028
+ },
1029
+ registries: {
1030
+ type: "array",
1031
+ items: {
1032
+ type: "object",
1033
+ required: [
1034
+ "pluginId",
1035
+ "id"
1036
+ ],
1037
+ additionalProperties: false,
1038
+ properties: {
1039
+ pluginId: {
1040
+ type: "string",
1041
+ minLength: 1
1042
+ },
1043
+ id: {
1044
+ type: "string",
1045
+ minLength: 1
1046
+ },
1047
+ entityKey: {
1048
+ type: "string"
1049
+ },
1050
+ readOnly: {
1051
+ type: "boolean"
1052
+ }
1053
+ }
1054
+ }
1055
+ },
1056
+ declaredFeatures: {
1057
+ type: "array",
1058
+ items: {
1059
+ type: "object"
1060
+ }
1061
+ },
1062
+ rpcs: {
1063
+ type: "array",
1064
+ items: {
1065
+ $ref: "#/$defs/rpcContract"
1066
+ }
1067
+ },
1068
+ domainKnowledge: {
1069
+ type: "object",
1070
+ additionalProperties: false,
1071
+ properties: {
1072
+ statuses: {
1073
+ type: "object"
1074
+ },
1075
+ scheduleDefaults: {
1076
+ type: "object"
1077
+ },
1078
+ businessRules: {
1079
+ type: "array",
1080
+ items: {
1081
+ type: "object",
1082
+ required: [
1083
+ "id",
1084
+ "description"
1085
+ ],
1086
+ additionalProperties: false,
1087
+ properties: {
1088
+ id: {
1089
+ type: "string",
1090
+ minLength: 1
1091
+ },
1092
+ description: {
1093
+ type: "string",
1094
+ minLength: 1
1095
+ }
1096
+ }
1097
+ }
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+ },
1103
+ entityContract: {
1104
+ type: "object",
1105
+ required: [
1106
+ "key",
1107
+ "label",
1108
+ "data",
1109
+ "fields"
1110
+ ],
670
1111
  additionalProperties: false,
671
1112
  properties: {
672
- type: { type: "string", minLength: 1 },
673
- id: { type: "string" },
674
- props: { type: "object" },
675
- children: { type: "array", items: { $ref: "#/$defs/block" } }
1113
+ key: {
1114
+ type: "string",
1115
+ minLength: 1
1116
+ },
1117
+ label: {
1118
+ type: "string",
1119
+ minLength: 1
1120
+ },
1121
+ labelPlural: {
1122
+ type: "string"
1123
+ },
1124
+ limitKey: {
1125
+ type: "string"
1126
+ },
1127
+ data: {
1128
+ type: "object",
1129
+ required: [
1130
+ "table"
1131
+ ],
1132
+ additionalProperties: false,
1133
+ properties: {
1134
+ table: {
1135
+ type: "string",
1136
+ minLength: 1
1137
+ },
1138
+ schema: {
1139
+ type: "string"
1140
+ },
1141
+ tenantScoped: {
1142
+ type: "boolean"
1143
+ },
1144
+ tenantIdColumn: {
1145
+ type: "string"
1146
+ },
1147
+ searchColumns: {
1148
+ type: "array",
1149
+ items: {
1150
+ type: "string"
1151
+ }
1152
+ },
1153
+ selectColumns: {
1154
+ type: "string"
1155
+ },
1156
+ columnMap: {
1157
+ type: "object"
1158
+ },
1159
+ archetype: {
1160
+ type: "string"
1161
+ },
1162
+ archetypeKind: {
1163
+ type: "string"
1164
+ },
1165
+ filters: {
1166
+ type: "object"
1167
+ }
1168
+ }
1169
+ },
1170
+ fields: {
1171
+ type: "array",
1172
+ items: {
1173
+ type: "object",
1174
+ required: [
1175
+ "key",
1176
+ "label",
1177
+ "type"
1178
+ ],
1179
+ additionalProperties: false,
1180
+ properties: {
1181
+ key: {
1182
+ type: "string",
1183
+ minLength: 1
1184
+ },
1185
+ label: {
1186
+ type: "string"
1187
+ },
1188
+ type: {
1189
+ type: "string",
1190
+ minLength: 1
1191
+ },
1192
+ required: {
1193
+ type: "boolean"
1194
+ },
1195
+ searchable: {
1196
+ type: "boolean"
1197
+ },
1198
+ hint: {
1199
+ type: "string"
1200
+ },
1201
+ options: {
1202
+ type: "array",
1203
+ items: {
1204
+ type: "string"
1205
+ }
1206
+ },
1207
+ relationTable: {
1208
+ type: "string"
1209
+ }
1210
+ }
1211
+ }
1212
+ },
1213
+ permission: {
1214
+ type: "object",
1215
+ required: [
1216
+ "feature",
1217
+ "action"
1218
+ ],
1219
+ additionalProperties: false,
1220
+ properties: {
1221
+ feature: {
1222
+ type: "string",
1223
+ minLength: 1
1224
+ },
1225
+ action: {
1226
+ type: "string",
1227
+ minLength: 1
1228
+ }
1229
+ }
1230
+ }
1231
+ }
1232
+ },
1233
+ aiToolContract: {
1234
+ type: "object",
1235
+ required: [
1236
+ "id",
1237
+ "name",
1238
+ "description",
1239
+ "mode"
1240
+ ],
1241
+ additionalProperties: false,
1242
+ properties: {
1243
+ id: {
1244
+ type: "string",
1245
+ minLength: 1
1246
+ },
1247
+ name: {
1248
+ type: "string",
1249
+ minLength: 1,
1250
+ pattern: "^[a-zA-Z0-9_-]{1,64}$"
1251
+ },
1252
+ description: {
1253
+ type: "string",
1254
+ minLength: 1
1255
+ },
1256
+ mode: {
1257
+ enum: [
1258
+ "read",
1259
+ "persist"
1260
+ ]
1261
+ },
1262
+ parameters: {
1263
+ type: "object"
1264
+ },
1265
+ permission: {
1266
+ type: "object",
1267
+ required: [
1268
+ "feature",
1269
+ "action"
1270
+ ],
1271
+ additionalProperties: false,
1272
+ properties: {
1273
+ feature: {
1274
+ type: "string",
1275
+ minLength: 1
1276
+ },
1277
+ action: {
1278
+ type: "string",
1279
+ minLength: 1
1280
+ }
1281
+ }
1282
+ },
1283
+ limitKey: {
1284
+ type: "string"
1285
+ },
1286
+ execution: {
1287
+ oneOf: [
1288
+ {
1289
+ type: "object",
1290
+ required: [
1291
+ "plane",
1292
+ "kind",
1293
+ "rpc"
1294
+ ],
1295
+ additionalProperties: false,
1296
+ properties: {
1297
+ plane: {
1298
+ const: "server"
1299
+ },
1300
+ kind: {
1301
+ const: "rpc"
1302
+ },
1303
+ rpc: {
1304
+ type: "string",
1305
+ minLength: 1
1306
+ }
1307
+ }
1308
+ },
1309
+ {
1310
+ type: "object",
1311
+ required: [
1312
+ "plane",
1313
+ "kind",
1314
+ "entity"
1315
+ ],
1316
+ additionalProperties: false,
1317
+ properties: {
1318
+ plane: {
1319
+ const: "server"
1320
+ },
1321
+ kind: {
1322
+ const: "entity_read"
1323
+ },
1324
+ entity: {
1325
+ type: "string",
1326
+ minLength: 1
1327
+ }
1328
+ }
1329
+ },
1330
+ {
1331
+ type: "object",
1332
+ required: [
1333
+ "plane"
1334
+ ],
1335
+ additionalProperties: false,
1336
+ properties: {
1337
+ plane: {
1338
+ const: "client"
1339
+ }
1340
+ }
1341
+ }
1342
+ ]
1343
+ },
1344
+ requiresConfirmation: {
1345
+ type: "boolean"
1346
+ },
1347
+ pluginId: {
1348
+ type: "string"
1349
+ },
1350
+ category: {
1351
+ type: "string"
1352
+ }
1353
+ }
1354
+ },
1355
+ rpcContract: {
1356
+ type: "object",
1357
+ required: [
1358
+ "name",
1359
+ "kind",
1360
+ "description"
1361
+ ],
1362
+ additionalProperties: false,
1363
+ properties: {
1364
+ name: {
1365
+ type: "string",
1366
+ minLength: 1,
1367
+ pattern: "^agent_[a-z0-9_]+$"
1368
+ },
1369
+ kind: {
1370
+ enum: [
1371
+ "read",
1372
+ "write"
1373
+ ]
1374
+ },
1375
+ description: {
1376
+ type: "string",
1377
+ minLength: 1
1378
+ },
1379
+ payloadSchema: {
1380
+ type: "object"
1381
+ },
1382
+ audits: {
1383
+ type: "boolean"
1384
+ }
676
1385
  }
677
1386
  }
678
1387
  }
@@ -757,6 +1466,6 @@ function routeModule(path) {
757
1466
  return path.replace(/^\/+/, "").split("/")[0] ?? "";
758
1467
  }
759
1468
 
760
- export { BlockChildren, BlockRenderer, COUNTRIES, CURRENT_MANIFEST_VERSION, DEFAULT_COUNTRY, WidgetZone, absoluteUrl, app_manifest_schema_default as appManifestSchema, applySeo, breadcrumbJsonLd, buildCSV, createEventBus, createSafeDataProvider, defineApp, downloadCSV, eventBus, exportCSV, formatCurrency, formatDate, formatDateTime, getActiveLocale, getCountry, getDefaultCurrency, maskDigitCount, maskPhone, migrateManifest, navHistoryBack, organizationJsonLd, recordNavigation, registerManifestMigration, renderApp, renderBlocks, routeModule, seoOrigin, setDefaultCurrency, unmaskPhone, useManifest, useNavHistoryStore, useNavReferrer, useOnEvent, useSeo, validateManifest };
1469
+ export { BlockChildren, BlockRenderer, COUNTRIES, CURRENT_MANIFEST_VERSION, DEFAULT_COUNTRY, WidgetZone, absoluteUrl, app_manifest_schema_default as appManifestSchema, applySeo, breadcrumbJsonLd, buildCSV, clearPostalCache, computeContractHash, createEventBus, createSafeDataProvider, createViaCepProvider, defineApp, downloadCSV, eventBus, exportCSV, formatCurrency, formatDate, formatDateTime, formatPostalCode, getActiveLocale, getCountry, getDefaultCurrency, getPostalLookupProvider, isValidPostalCode, lookupPostalCode, maskDigitCount, maskPhone, migrateManifest, navHistoryBack, normalizePostalCode, organizationJsonLd, recordNavigation, registerManifestMigration, renderApp, renderBlocks, routeModule, seoOrigin, serializeManifest, serializeManifestWithHash, setDefaultCurrency, setPostalLookupProvider, unmaskPhone, useManifest, useNavHistoryStore, useNavReferrer, useOnEvent, useSeo, validateManifest };
761
1470
  //# sourceMappingURL=index.js.map
762
1471
  //# sourceMappingURL=index.js.map