@fayz-ai/core 0.9.0 → 0.11.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 (218) hide show
  1. package/README.md +2 -2
  2. package/dist/access/index.js.map +1 -1
  3. package/dist/chunk-BEGXYHS4.js +566 -0
  4. package/dist/chunk-BEGXYHS4.js.map +1 -0
  5. package/dist/chunk-ED6NBH6U.js +348 -0
  6. package/dist/chunk-ED6NBH6U.js.map +1 -0
  7. package/dist/chunk-EWKX4VUM.js +429 -0
  8. package/dist/chunk-EWKX4VUM.js.map +1 -0
  9. package/dist/chunk-LARZWDHA.js +319 -0
  10. package/dist/chunk-LARZWDHA.js.map +1 -0
  11. package/dist/chunk-OXQGRJZT.js +125 -0
  12. package/dist/chunk-OXQGRJZT.js.map +1 -0
  13. package/dist/chunk-RRYFXUQX.js +1247 -0
  14. package/dist/chunk-RRYFXUQX.js.map +1 -0
  15. package/dist/{chunk-5RJVUC6J.js → chunk-TDI6F6PT.js} +373 -25
  16. package/dist/chunk-TDI6F6PT.js.map +1 -0
  17. package/dist/{chunk-V2MSAUHO.js → chunk-UVKH6RDX.js} +211 -335
  18. package/dist/chunk-UVKH6RDX.js.map +1 -0
  19. package/dist/chunk-V53GR4UT.js +289 -0
  20. package/dist/chunk-V53GR4UT.js.map +1 -0
  21. package/dist/connector-runtime/index.d.ts +15 -0
  22. package/dist/connector-runtime/index.d.ts.map +1 -0
  23. package/dist/connector-runtime/index.js +3 -0
  24. package/dist/connector-runtime/index.js.map +1 -0
  25. package/dist/data/archetype.d.ts.map +1 -1
  26. package/dist/data/backend-env.d.ts +38 -0
  27. package/dist/data/backend-env.d.ts.map +1 -0
  28. package/dist/data/bulk.d.ts +24 -0
  29. package/dist/data/bulk.d.ts.map +1 -1
  30. package/dist/data/cached.d.ts.map +1 -1
  31. package/dist/data/custom-fields.d.ts +5 -0
  32. package/dist/data/custom-fields.d.ts.map +1 -0
  33. package/dist/data/index.d.ts +2 -1
  34. package/dist/data/index.d.ts.map +1 -1
  35. package/dist/data/index.js +3 -1
  36. package/dist/data/mock.d.ts.map +1 -1
  37. package/dist/data/platform-api.d.ts.map +1 -1
  38. package/dist/data/resolve.d.ts.map +1 -1
  39. package/dist/data/supabase.d.ts.map +1 -1
  40. package/dist/data/types.d.ts +8 -0
  41. package/dist/data/types.d.ts.map +1 -1
  42. package/dist/entity/events.d.ts +14 -0
  43. package/dist/entity/events.d.ts.map +1 -0
  44. package/dist/events/envelope.d.ts +31 -0
  45. package/dist/events/envelope.d.ts.map +1 -0
  46. package/dist/events/index.d.ts +4 -0
  47. package/dist/events/index.d.ts.map +1 -1
  48. package/dist/events/log.d.ts +44 -0
  49. package/dist/events/log.d.ts.map +1 -0
  50. package/dist/events/types.d.ts +40 -0
  51. package/dist/events/types.d.ts.map +1 -0
  52. package/dist/fields/store.d.ts +45 -0
  53. package/dist/fields/store.d.ts.map +1 -0
  54. package/dist/i18n/index.d.ts +10 -0
  55. package/dist/i18n/index.d.ts.map +1 -1
  56. package/dist/i18n/index.js +1 -1
  57. package/dist/i18n/shell-translations.en.d.ts.map +1 -1
  58. package/dist/i18n/shell-translations.pt-br.d.ts.map +1 -1
  59. package/dist/index.d.ts +45 -21
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +543 -56
  62. package/dist/index.js.map +1 -1
  63. package/dist/integrations/events.d.ts +7 -0
  64. package/dist/integrations/events.d.ts.map +1 -0
  65. package/dist/integrations/index.d.ts +533 -29
  66. package/dist/integrations/index.d.ts.map +1 -1
  67. package/dist/integrations/index.js +3 -1
  68. package/dist/integrations/permissions.d.ts +132 -0
  69. package/dist/integrations/permissions.d.ts.map +1 -0
  70. package/dist/integrations/request.d.ts +170 -0
  71. package/dist/integrations/request.d.ts.map +1 -0
  72. package/dist/integrations/runtime-token.d.ts +33 -0
  73. package/dist/integrations/runtime-token.d.ts.map +1 -0
  74. package/dist/integrations/runtime.d.ts +398 -0
  75. package/dist/integrations/runtime.d.ts.map +1 -0
  76. package/dist/integrations/settings.d.ts +102 -0
  77. package/dist/integrations/settings.d.ts.map +1 -0
  78. package/dist/integrations/store.d.ts +145 -0
  79. package/dist/integrations/store.d.ts.map +1 -0
  80. package/dist/{address/index.d.ts → lib/address.d.ts} +1 -1
  81. package/dist/{address/index.d.ts.map → lib/address.d.ts.map} +1 -1
  82. package/dist/{phone/index.d.ts → lib/phone.d.ts} +1 -1
  83. package/dist/lib/phone.d.ts.map +1 -0
  84. package/dist/{seo/index.d.ts → lib/seo.d.ts} +18 -1
  85. package/dist/lib/seo.d.ts.map +1 -0
  86. package/dist/{tenant/index.d.ts → lib/tenant.d.ts} +1 -1
  87. package/dist/lib/tenant.d.ts.map +1 -0
  88. package/dist/manifest/index.d.ts +1 -1
  89. package/dist/manifest/index.d.ts.map +1 -1
  90. package/dist/messaging/index.d.ts +3 -0
  91. package/dist/messaging/index.d.ts.map +1 -0
  92. package/dist/messaging/registry.d.ts +35 -0
  93. package/dist/messaging/registry.d.ts.map +1 -0
  94. package/dist/messaging/types.d.ts +67 -0
  95. package/dist/messaging/types.d.ts.map +1 -0
  96. package/dist/plugin/index.js +3 -1
  97. package/dist/plugin/runtime.d.ts +17 -0
  98. package/dist/plugin/runtime.d.ts.map +1 -1
  99. package/dist/registry/block-catalog.d.ts +78 -0
  100. package/dist/registry/block-catalog.d.ts.map +1 -0
  101. package/dist/registry/block-constraints.d.ts +64 -0
  102. package/dist/registry/block-constraints.d.ts.map +1 -0
  103. package/dist/registry/block-schema.d.ts +69 -0
  104. package/dist/registry/block-schema.d.ts.map +1 -0
  105. package/dist/registry/blocks.d.ts +84 -0
  106. package/dist/registry/blocks.d.ts.map +1 -0
  107. package/dist/registry/entities.d.ts +179 -0
  108. package/dist/registry/entities.d.ts.map +1 -0
  109. package/dist/registry/extension-points.d.ts +117 -0
  110. package/dist/registry/extension-points.d.ts.map +1 -0
  111. package/dist/registry/handles.d.ts +41 -0
  112. package/dist/registry/handles.d.ts.map +1 -0
  113. package/dist/registry/index.d.ts +41 -41
  114. package/dist/registry/index.d.ts.map +1 -1
  115. package/dist/registry/loaders.d.ts +55 -0
  116. package/dist/registry/loaders.d.ts.map +1 -0
  117. package/dist/registry/registry-class.d.ts +157 -0
  118. package/dist/registry/registry-class.d.ts.map +1 -0
  119. package/dist/registry/schema-check.d.ts +14 -0
  120. package/dist/registry/schema-check.d.ts.map +1 -0
  121. package/dist/router/index.d.ts +78 -1
  122. package/dist/router/index.d.ts.map +1 -1
  123. package/dist/router/index.js +1 -1
  124. package/dist/{shell-translations.pt-br-2GWRQRRP.js → shell-translations.pt-br-BM5ZFSKJ.js} +72 -3
  125. package/dist/shell-translations.pt-br-BM5ZFSKJ.js.map +1 -0
  126. package/dist/telemetry/errors.d.ts +87 -0
  127. package/dist/telemetry/errors.d.ts.map +1 -0
  128. package/dist/testing/index.js +4 -1
  129. package/dist/{testing/index.d.ts → testing.d.ts} +5 -3
  130. package/dist/testing.d.ts.map +1 -0
  131. package/dist/types/analytics.d.ts +213 -0
  132. package/dist/types/analytics.d.ts.map +1 -0
  133. package/dist/types/crud.d.ts +37 -3
  134. package/dist/types/crud.d.ts.map +1 -1
  135. package/dist/types/plugins.d.ts +138 -1
  136. package/dist/types/plugins.d.ts.map +1 -1
  137. package/package.json +9 -17
  138. package/dist/blocks/index.d.ts +0 -25
  139. package/dist/blocks/index.d.ts.map +0 -1
  140. package/dist/chunk-5RJVUC6J.js.map +0 -1
  141. package/dist/chunk-L4TLMYGC.js +0 -42
  142. package/dist/chunk-L4TLMYGC.js.map +0 -1
  143. package/dist/chunk-V2MSAUHO.js.map +0 -1
  144. package/dist/chunk-X5THHG6T.js +0 -77
  145. package/dist/chunk-X5THHG6T.js.map +0 -1
  146. package/dist/chunk-Y2C2FBQP.js +0 -35
  147. package/dist/chunk-Y2C2FBQP.js.map +0 -1
  148. package/dist/chunk-YH25Y4FW.js +0 -311
  149. package/dist/chunk-YH25Y4FW.js.map +0 -1
  150. package/dist/phone/index.d.ts.map +0 -1
  151. package/dist/seo/index.d.ts.map +0 -1
  152. package/dist/shell-translations.pt-br-2GWRQRRP.js.map +0 -1
  153. package/dist/tenant/index.d.ts.map +0 -1
  154. package/dist/testing/index.d.ts.map +0 -1
  155. package/src/access/denial.ts +0 -33
  156. package/src/access/engine.test.ts +0 -48
  157. package/src/access/engine.ts +0 -136
  158. package/src/access/index.ts +0 -14
  159. package/src/access/limits.ts +0 -18
  160. package/src/address/index.ts +0 -188
  161. package/src/app/render.tsx +0 -69
  162. package/src/blocks/index.tsx +0 -68
  163. package/src/data/archetype.ts +0 -255
  164. package/src/data/bulk.ts +0 -35
  165. package/src/data/cached.ts +0 -55
  166. package/src/data/count.test.ts +0 -152
  167. package/src/data/count.ts +0 -131
  168. package/src/data/filters.test.ts +0 -70
  169. package/src/data/filters.ts +0 -90
  170. package/src/data/index.ts +0 -11
  171. package/src/data/mock.ts +0 -90
  172. package/src/data/platform-api.ts +0 -209
  173. package/src/data/refresh.ts +0 -115
  174. package/src/data/resolve.ts +0 -126
  175. package/src/data/supabase.ts +0 -230
  176. package/src/data/types.ts +0 -50
  177. package/src/entity/index.ts +0 -2
  178. package/src/entity/registry.ts +0 -49
  179. package/src/events/index.tsx +0 -82
  180. package/src/i18n/index.ts +0 -476
  181. package/src/i18n/shell-translations.en.ts +0 -875
  182. package/src/i18n/shell-translations.pt-br.ts +0 -873
  183. package/src/index.ts +0 -217
  184. package/src/integrations/index.ts +0 -237
  185. package/src/lib/cache.ts +0 -118
  186. package/src/lib/csv.ts +0 -54
  187. package/src/lib/format.ts +0 -58
  188. package/src/manifest/app-manifest.schema.json +0 -676
  189. package/src/manifest/index.ts +0 -518
  190. package/src/manifest/serialize.ts +0 -52
  191. package/src/phone/index.ts +0 -85
  192. package/src/plugin/createSafeDataProvider.ts +0 -30
  193. package/src/plugin/index.ts +0 -1
  194. package/src/plugin/runtime.ts +0 -331
  195. package/src/registry/index.ts +0 -163
  196. package/src/router/history.ts +0 -86
  197. package/src/router/index.ts +0 -29
  198. package/src/runtime/index.ts +0 -15
  199. package/src/runtime/oauth.ts +0 -219
  200. package/src/search/engine.ts +0 -559
  201. package/src/search/index.ts +0 -25
  202. package/src/search/text.ts +0 -206
  203. package/src/search/types.ts +0 -75
  204. package/src/seo/index.ts +0 -128
  205. package/src/tenant/index.ts +0 -38
  206. package/src/testing/index.ts +0 -116
  207. package/src/types/auth.ts +0 -41
  208. package/src/types/billing.ts +0 -39
  209. package/src/types/crud.ts +0 -184
  210. package/src/types/entities.ts +0 -142
  211. package/src/types/entitlements.ts +0 -45
  212. package/src/types/i18n.ts +0 -7
  213. package/src/types/index.ts +0 -11
  214. package/src/types/org.ts +0 -137
  215. package/src/types/payment.ts +0 -44
  216. package/src/types/permissions.ts +0 -32
  217. package/src/types/plugins.ts +0 -480
  218. package/src/types/theme.ts +0 -8
package/src/types/crud.ts DELETED
@@ -1,184 +0,0 @@
1
- import type React from 'react'
2
- import type { EntityArchetype } from './entities'
3
-
4
- export type FieldType =
5
- | 'text' | 'email' | 'phone' | 'url' | 'image'
6
- | 'number' | 'currency'
7
- | 'select' | 'multiselect' | 'segmented'
8
- | 'relation'
9
- | 'date' | 'datetime' | 'time'
10
- | 'boolean' | 'textarea' | 'markdown'
11
- | 'color' | 'computed'
12
-
13
- /** Foreign-key source for a `relation` field: the option list is loaded from a
14
- * table at runtime ({value→label}) so the stored value is a real id (e.g. a
15
- * uuid), not a static string. Use for FK columns the user must pick from a
16
- * seeded/managed table (e.g. payment_method_type_id → payment_method_types). */
17
- export interface FieldRelation {
18
- /** Table to read options from (e.g. 'payment_method_types'). */
19
- table: string
20
- /** Column stored as the field value. Default 'id'. */
21
- valueField?: string
22
- /** Column shown as the option label. Default 'name'. */
23
- labelField?: string
24
- /** Scope options to the active tenant via tenant_id. Default true. */
25
- tenantScoped?: boolean
26
- /** Schema the table lives in (rarely needed now core is in public). Default public. */
27
- schema?: string
28
- /** Extra equality filters applied to the option query. */
29
- filter?: Record<string, unknown>
30
- }
31
-
32
- /** Read-only display produced by a `computed` field's `compute()`. */
33
- export interface ComputedFieldValue {
34
- display: string
35
- /** Drives the value colour (green / red / muted). Default: neutral. */
36
- tone?: 'positive' | 'negative' | 'neutral'
37
- }
38
-
39
- export interface FieldDef {
40
- key: string
41
- label: string
42
- type: FieldType
43
- required?: boolean
44
- placeholder?: string
45
- /** Small helper text shown under the field input. */
46
- hint?: string
47
- /** Options for `select` / `multiselect` / `segmented`. The optional
48
- * `description` is shown under the label on `segmented` radio-cards. */
49
- options?: string[] | { label: string; value: string; description?: string }[]
50
- /** Required for `relation` fields — where to load the option list from. */
51
- relation?: FieldRelation
52
- min?: number
53
- max?: number
54
- /** ISO currency code for `currency` fields (e.g. 'BRL'). */
55
- currency?: string
56
- /** Symbol/locale for the `currency` field's CurrencyInput. Default 'R$' / 'pt-BR'. */
57
- currencySymbol?: string
58
- currencyLocale?: string
59
- showInTable?: boolean
60
- showInForm?: boolean
61
- showInDetail?: boolean
62
- sortable?: boolean
63
- searchable?: boolean
64
- /** Custom cell renderer (code escape hatch). For a serializable EntityDef in
65
- * an AppManifest, reference a registered cell renderer by id instead. */
66
- renderCell?: (value: unknown, row: unknown) => React.ReactNode
67
- renderCellId?: string
68
- /** Derives a read-only value from the other form values (for `computed`
69
- * fields, e.g. margin). Returns null to render an em-dash. */
70
- compute?: (values: Record<string, unknown>) => ComputedFieldValue | null
71
- defaultValue?: unknown
72
- group?: string
73
- span?: 1 | 2
74
- inlineToggle?: boolean
75
- }
76
-
77
- export interface FieldGroup {
78
- id: string
79
- label: string
80
- description?: string
81
- columns?: 1 | 2 | 3
82
- /** Renders an image slot to the left of the group's fields. Functional when
83
- * the EntityDef supplies `image`; a plain placeholder otherwise. */
84
- imageSlot?: boolean
85
- }
86
-
87
- export interface DetailTab {
88
- id: string
89
- label: string
90
- icon?: string
91
- /** Legacy or compatibility route ids that should resolve to this tab. */
92
- aliases?: string[]
93
- /** Hide an inherited/archetype tab while still allowing the app to override it by id. */
94
- hidden?: boolean
95
- /** Tab content component, or a registered component id (componentId) for a
96
- * serializable EntityDef. Exactly one is expected. */
97
- component?: React.ComponentType<{ item: unknown; entityDef: EntityDef; [key: string]: unknown }>
98
- componentId?: string
99
- visibleFor?: string[]
100
- props?: Record<string, unknown>
101
- /** Only show this tab when a plugin has contributed a widget to this zone (e.g. a
102
- * financial plugin enabling a per-person statement tab). Hidden when no widget. */
103
- requiresWidgetZone?: string
104
- }
105
-
106
- export type FormLayout = 'person' | 'product' | 'service' | 'location' | 'order' | 'subject' | 'generic'
107
-
108
- /**
109
- * Makes a field group's `imageSlot` functional. Without this the slot renders as
110
- * a decorative placeholder — it always did, which is why product forms showed an
111
- * empty thumbnail even for products that have images.
112
- *
113
- * Upload needs the record to exist (the file is attached to its id), so the slot
114
- * stays read-only in create mode and becomes editable after the first save.
115
- */
116
- export interface EntityImageConfig {
117
- // Rows are loosely typed here on purpose: EntityDef<T> is consumed as
118
- // EntityDef<Record<string, unknown>> by the generic CRUD machinery, and a
119
- // T-parameterised callback makes the whole EntityDef invariant in T.
120
- /** Current image URL for this record, if any. */
121
- get: (row: Record<string, any>) => string | undefined
122
- /** Persist a new image and return its URL. Omit to keep the slot read-only. */
123
- upload?: (file: File, row: Record<string, any>) => Promise<string>
124
- /** Remove the current image. Omit to hide the remove affordance. */
125
- remove?: (row: Record<string, any>) => Promise<void>
126
- /** Accepted mime types. Defaults to image/*. */
127
- accept?: string
128
- }
129
-
130
- export interface EntityDef<T = Record<string, unknown>> {
131
- name: string
132
- namePlural?: string
133
- icon: string
134
- layout?: FormLayout
135
- fields: FieldDef[]
136
- fieldGroups?: FieldGroup[]
137
- /** Wiring for the `imageSlot` of whichever field group declares one. */
138
- image?: EntityImageConfig
139
- detailTabs?: DetailTab[]
140
- data?: {
141
- table: string
142
- schema?: string
143
- tenantScoped?: boolean
144
- tenantIdColumn?: string
145
- searchColumns?: string[]
146
- selectColumns?: string
147
- columnMap?: Record<string, string>
148
- archetype?: EntityArchetype
149
- archetypeKind?: string
150
- filters?: Record<string, string>
151
- defaults?: Record<string, unknown>
152
- cacheTTL?: number
153
- }
154
- defaultSort?: string
155
- defaultSortDir?: 'asc' | 'desc'
156
- displayField?: string
157
- subtitleField?: string
158
- imageField?: string
159
- /** Faceted filters shown as pills below the list search box. Each references a
160
- * field whose `options` supply the pills; an "All" pill clears the filter. */
161
- facets?: { field: string; allLabel?: string }[]
162
- /**
163
- * Plan quantity-limit key gating creation of this entity (matches a
164
- * `PlanEntitlements.limits` key + a `LimitDeclaration`). When set, the CRUD
165
- * engine gates the "+ New" button (LimitGate), guards the create-form submit
166
- * and the CSV import (useLimitGuard) against the plan cap, and invalidates the
167
- * live count after a successful create. Absent ⇒ no plan gating (RBAC only).
168
- */
169
- limitKey?: string
170
- /**
171
- * Permission required to READ this entity through the agent's generic data
172
- * primitives (searchRecords/queryData) — checked per TARGET at execution
173
- * time, so one generic tool still honors per-user access. Absent ⇒ readable
174
- * by any signed-in member (same as the CRUD list today).
175
- */
176
- permission?: { feature: string; action: string }
177
- /**
178
- * Exclude this entity from the agent's data primitives. For entities whose
179
- * table is an extension/join shape the generic provider can't read usefully
180
- * (e.g. staff_members without a name column) — expose a queryEntities
181
- * read-model instead and hide the raw one here.
182
- */
183
- agentHidden?: boolean
184
- }
@@ -1,142 +0,0 @@
1
- export type EntityArchetype = 'person' | 'category' | 'product' | 'service' | 'order' | 'transaction' | 'schedule' | 'location'
2
-
3
- export interface BaseEntity {
4
- id: string
5
- tenantId: string
6
- createdAt: string
7
- updatedAt: string
8
- }
9
-
10
- export interface PersonEntity extends BaseEntity {
11
- archetype: 'person'
12
- kind: string
13
- name: string
14
- email?: string
15
- phone?: string
16
- documentNumber?: string
17
- avatarUrl?: string
18
- dateOfBirth?: string
19
- address?: string
20
- city?: string
21
- state?: string
22
- country: string
23
- postalCode?: string
24
- tags: string[]
25
- isActive: boolean
26
- notes?: string
27
- metadata: Record<string, unknown>
28
- }
29
-
30
- export interface CategoryEntity extends BaseEntity {
31
- archetype: 'category'
32
- kind: string
33
- name: string
34
- slug?: string
35
- parentId?: string
36
- icon?: string
37
- color?: string
38
- sortOrder: number
39
- isActive: boolean
40
- metadata: Record<string, unknown>
41
- }
42
-
43
- export interface ProductEntity extends BaseEntity {
44
- archetype: 'product'
45
- categoryId?: string
46
- name: string
47
- description?: string
48
- sku?: string
49
- price?: number
50
- cost?: number
51
- currency: string
52
- unit?: string
53
- imageUrl?: string
54
- stock?: number
55
- minStock?: number
56
- status: string
57
- isActive: boolean
58
- tags: string[]
59
- metadata: Record<string, unknown>
60
- }
61
-
62
- export interface ServiceEntity extends BaseEntity {
63
- archetype: 'service'
64
- categoryId?: string
65
- name: string
66
- description?: string
67
- price?: number
68
- cost?: number
69
- currency: string
70
- durationMinutes?: number
71
- imageUrl?: string
72
- status: string
73
- isActive: boolean
74
- tags: string[]
75
- metadata: Record<string, unknown>
76
- }
77
-
78
- export interface OrderEntity extends BaseEntity {
79
- archetype: 'order'
80
- kind: string
81
- referenceNumber?: string
82
- status: string
83
- partyId?: string
84
- assigneeId?: string
85
- locationId?: string
86
- subtotal: number
87
- discount: number
88
- tax: number
89
- total: number
90
- currency: string
91
- dueAt?: string
92
- completedAt?: string
93
- notes?: string
94
- tags: string[]
95
- metadata: Record<string, unknown>
96
- }
97
-
98
- export interface TransactionEntity extends BaseEntity {
99
- archetype: 'transaction'
100
- kind: string
101
- orderId?: string
102
- partyId?: string
103
- amount: number
104
- currency: string
105
- paymentMethod?: string
106
- reference?: string
107
- status: string
108
- transactedAt: string
109
- notes?: string
110
- metadata: Record<string, unknown>
111
- }
112
-
113
- export interface LocationEntity extends BaseEntity {
114
- archetype: 'location'
115
- kind: string
116
- name: string
117
- email?: string
118
- phone?: string
119
- address?: string
120
- city?: string
121
- state?: string
122
- country: string
123
- postalCode?: string
124
- isHeadquarters: boolean
125
- isActive: boolean
126
- tags: string[]
127
- notes?: string
128
- metadata: Record<string, unknown>
129
- }
130
-
131
- export interface ScheduleEntity extends BaseEntity {
132
- archetype: 'schedule'
133
- kind: string
134
- assigneeId?: string
135
- locationId?: string
136
- dayOfWeek?: number
137
- specificDate?: string
138
- startsAt: string
139
- endsAt: string
140
- isActive: boolean
141
- metadata: Record<string, unknown>
142
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Entitlements — the plan side of the access decision (the role side lives in
3
- * permissions.ts). A plan grants FEATURES (gate a page/module) and caps LIMITS
4
- * (quantity ceilings). Feature ids are the SAME id space as RBAC/nav
5
- * (`permission.feature`), so a single id threads role → nav → plan.
6
- */
7
- export interface PlanEntitlements {
8
- /**
9
- * feature id (same id as RBAC/nav) → whether the plan grants it. Absent = the
10
- * plan does not gate the feature (allowed). Only an explicit `false` denies —
11
- * this keeps plans additive: features unknown to a plan stay open.
12
- */
13
- features?: Record<string, boolean>
14
- /**
15
- * limitKey → cap. `-1` = unlimited. Keys are app/plugin-defined (e.g.
16
- * `clients`, `users`, `locations`, `bookings_month`). A key absent here means
17
- * "no cap on this plan" (unlimited). See {@link LimitDeclaration} for how a
18
- * key is bound to a countable table.
19
- */
20
- limits?: Record<string, number>
21
- }
22
-
23
- /**
24
- * Declares HOW a limit key is counted. Contributed by plugins via
25
- * `PluginManifest.declaredLimits` (aggregated by the plugin runtime) and/or
26
- * overridden per-app via `billing.limitDeclarations`. The access engine reads a
27
- * declaration to resolve a `limitKey` → a live `count(*)` against `table` for
28
- * the active tenant, with no per-entity code.
29
- */
30
- export interface LimitDeclaration {
31
- /** Limit key — matches a key in {@link PlanEntitlements.limits}. */
32
- key: string
33
- /** Human label for paywalls / usage banners (e.g. "Patients"). */
34
- label: string
35
- /** Table the count runs against (tenant-scoped via `tenant_id`). */
36
- table: string
37
- /** Optional `kind` column filter for tables that hold several entity kinds. */
38
- kindFilter?: string
39
- /**
40
- * Counting window. `'month'` counts rows created since the start of the
41
- * current month (recurring quotas like bookings/month); `'total'` (default)
42
- * counts every row (stock quantities like clients/users).
43
- */
44
- period?: 'month' | 'total'
45
- }
package/src/types/i18n.ts DELETED
@@ -1,7 +0,0 @@
1
- export interface LocaleConfig {
2
- default: string
3
- supported: string[]
4
- translations?: Record<string, Record<string, string>>
5
- /** ISO 4217 currency code for money formatting (e.g. 'BRL', 'USD'). */
6
- currency?: string
7
- }
@@ -1,11 +0,0 @@
1
- // Re-export all core types
2
- export type { EntityArchetype, BaseEntity, PersonEntity, ProductEntity, ServiceEntity, OrderEntity, TransactionEntity, LocationEntity, ScheduleEntity, CategoryEntity } from './entities'
3
- export type { EntityDef, FieldDef, FieldType, FieldRelation, FieldGroup, DetailTab, FormLayout, ComputedFieldValue } from './crud'
4
- export type { PluginManifest, PluginScope, PluginStatus, ResolvedPluginManifest, PluginRuntime, PluginRuntimeContext, PluginWidgetZone, PluginWidgetDefinition, PluginNavigationEntry, PluginSettingsTab, PluginRouteDefinition, PluginAITool, AIToolMode, AIToolExecution, AgentRpcDeclaration, AIToolParameterProperty, AIToolParameters, AIToolSuggestion, PluginRegistryDef, PluginMigration, PluginDiagnostic, VerticalId, ScaffoldType } from './plugins'
5
- export type { AuthAdapter, AuthUser, AuthSession } from './auth'
6
- export type { OrgAdapter, Organization, OrgMember } from './org'
7
- export type { PermissionsConfig, FeatureDeclaration, PermissionAction, PermissionProfile, SystemPermission } from './permissions'
8
- export type { Plan, BillingConfig, BillingCheckoutFn } from './billing'
9
- export type { PlanEntitlements, LimitDeclaration } from './entitlements'
10
- export type { ThemeBrand, ThemeRadius, ThemeMode } from './theme'
11
- export type { LocaleConfig } from './i18n'
package/src/types/org.ts DELETED
@@ -1,137 +0,0 @@
1
- import type { PermissionProfile } from './permissions'
2
-
3
- export interface Organization {
4
- id: string
5
- name: string
6
- slug: string
7
- logoUrl?: string
8
- verticalId?: string
9
- plan?: string
10
- settings?: Record<string, unknown>
11
- createdAt: string
12
- updatedAt: string
13
- }
14
-
15
- export interface OrgMember {
16
- id: string
17
- userId: string
18
- orgId: string
19
- profileId: string
20
- profileName: string
21
- user: {
22
- id: string
23
- email: string
24
- fullName: string
25
- avatarUrl?: string
26
- }
27
- joinedAt: string
28
- }
29
-
30
- export interface OrgMembership {
31
- orgId: string
32
- orgName: string
33
- orgSlug: string
34
- orgLogoUrl?: string
35
- profileId: string
36
- profileName: string
37
- }
38
-
39
- /**
40
- * A team member in the Person-first model: a person (of a configured team kind)
41
- * with an OPTIONAL access overlay. `membership` is present only when the person
42
- * has login + RBAC role (a `tenant_members` row linked by `person_id`).
43
- *
44
- * The inverse also exists: a membership with no person behind it (the owner who
45
- * created the workspace). Those rows carry `membership` and no `personId`/`kind`.
46
- */
47
- export interface TeamPerson {
48
- /** Absent on a login-only row: a member with no person record behind it. */
49
- personId?: string
50
- name: string
51
- /** Absent on a login-only row. */
52
- kind?: string
53
- email?: string
54
- avatarUrl?: string
55
- isActive: boolean
56
- membership?: {
57
- memberId: string
58
- userId: string
59
- /** RBAC role key (tenant_members.role). */
60
- profileId: string
61
- profileName?: string
62
- joinedAt?: string
63
- }
64
- }
65
-
66
- export interface Location {
67
- id: string
68
- tenantId: string
69
- name: string
70
- address?: string
71
- city?: string
72
- state?: string
73
- country?: string
74
- phone?: string
75
- isHeadquarters: boolean
76
- isActive: boolean
77
- createdAt: string
78
- updatedAt: string
79
- }
80
-
81
- export interface Invite {
82
- id: string
83
- orgId: string
84
- email: string
85
- profileId: string
86
- profileName: string
87
- invitedBy: string
88
- token: string
89
- status: 'pending' | 'accepted' | 'expired'
90
- createdAt: string
91
- expiresAt: string
92
- }
93
-
94
- export interface CreateOrgOptions {
95
- verticalId?: string
96
- timezone?: string
97
- currency?: string
98
- locale?: string
99
- teamSize?: string
100
- }
101
-
102
- export interface OrgAdapter {
103
- listUserOrgs(userId: string): Promise<OrgMembership[]>
104
- /**
105
- * Redeem any invite addressed to the signed-in user, turning it into a real
106
- * membership. Called once per sign-in, BEFORE `listUserOrgs` — without it an
107
- * invitee looks org-less and the auto-create path invents a personal org
108
- * instead of putting them in the org that invited them. Returns how many
109
- * invites were accepted. Optional so adapters can adopt it incrementally.
110
- */
111
- acceptPendingInvites?(): Promise<number>
112
- getOrg(orgId: string): Promise<Organization>
113
- createOrg(name: string, userId: string, options?: CreateOrgOptions): Promise<Organization>
114
- updateOrg(orgId: string, data: Partial<Organization>): Promise<Organization>
115
- listMembers(orgId: string): Promise<OrgMember[]>
116
- /**
117
- * Person-first team list: people whose `kind` is in `personKinds`, each with an
118
- * optional membership overlay (login + role) linked by `tenant_members.person_id`,
119
- * PLUS the memberships that match no such person (they'd otherwise be invisible).
120
- * Optional so adapters can adopt it incrementally; the Team screen falls back to
121
- * `listMembers` when absent or when no `personKinds` are configured.
122
- */
123
- listTeam?(orgId: string, personKinds: string[]): Promise<TeamPerson[]>
124
- updateMemberProfile(orgId: string, memberId: string, profileId: string): Promise<void>
125
- removeMember(orgId: string, memberId: string): Promise<void>
126
- listProfiles(orgId: string): Promise<PermissionProfile[]>
127
- createProfile(orgId: string, profile: Omit<PermissionProfile, 'id' | 'isSystem'>): Promise<PermissionProfile>
128
- updateProfile(orgId: string, profileId: string, data: Partial<PermissionProfile>): Promise<PermissionProfile>
129
- deleteProfile(orgId: string, profileId: string): Promise<void>
130
- listInvites(orgId: string): Promise<Invite[]>
131
- createInvite(orgId: string, email: string, profileId: string, invitedBy: string): Promise<Invite>
132
- bulkInvite(orgId: string, emails: string[], profileId: string, invitedBy: string): Promise<Invite[]>
133
- revokeInvite(orgId: string, inviteId: string): Promise<void>
134
- resendInvite(orgId: string, inviteId: string): Promise<Invite>
135
- listLocations(orgId: string): Promise<Location[]>
136
- createLocation(orgId: string, data: { name: string; address?: string; city?: string; state?: string; country?: string; phone?: string; isHeadquarters?: boolean }): Promise<Location>
137
- }
@@ -1,44 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Payment provider contract (SDK-level, gateway-agnostic). A booking/checkout
3
- // flow declares "collect X" and calls createCharge; the concrete provider (mock
4
- // Pix now, MercadoPago/Stripe later) decides HOW. Kept in core so any plugin can
5
- // depend on the interface without depending on a payments plugin.
6
- // ---------------------------------------------------------------------------
7
-
8
- export type PaymentMethod = 'pix' | (string & {})
9
-
10
- export type ChargeStatus = 'pending' | 'paid' | 'expired' | 'failed'
11
-
12
- export interface CreateChargeInput {
13
- /** Amount in the currency's major unit (e.g. 220.00 = R$ 220,00). */
14
- amount: number
15
- /** ISO 4217 currency code, e.g. 'BRL'. */
16
- currency: string
17
- method: PaymentMethod
18
- /** Human-readable description (statement/receipt). */
19
- description?: string
20
- /** The booking/order this charge settles, for reconciliation. */
21
- orderId?: string
22
- /** Payer contact, when known (name/email/phone). */
23
- customer?: { name?: string; email?: string; phone?: string }
24
- }
25
-
26
- export interface PixCharge {
27
- chargeId: string
28
- status: ChargeStatus
29
- amount: number
30
- currency: string
31
- /** QR image payload. For Pix this is the BR Code string encoded into the QR. */
32
- pixQrCode: string
33
- /** "Copia e cola" — the raw Pix BR Code the payer pastes into their bank app. */
34
- pixCopyPaste: string
35
- /** ISO datetime the charge/QR expires. */
36
- expiresAt: string
37
- }
38
-
39
- export interface PaymentProvider {
40
- /** Create a charge and return its payable artifacts (Pix QR + copia-e-cola). */
41
- createCharge(input: CreateChargeInput): Promise<PixCharge>
42
- /** Current status of a charge (polled by the UI, or driven by a webhook later). */
43
- getChargeStatus(chargeId: string): Promise<ChargeStatus>
44
- }
@@ -1,32 +0,0 @@
1
- export type PermissionAction = 'read' | 'create' | 'edit' | 'write' | 'delete' | 'manage' | (string & {})
2
-
3
- export type SystemPermission =
4
- | 'manage_team'
5
- | 'manage_billing'
6
- | 'manage_settings'
7
- | 'manage_permissions'
8
-
9
- export interface FeatureDeclaration {
10
- id: string
11
- label: string
12
- description?: string
13
- /** Settings group this feature appears under (matches saas-core runtime) */
14
- group?: string
15
- actions?: PermissionAction[]
16
- pluginId?: string
17
- }
18
-
19
- export interface PermissionProfile {
20
- id: string
21
- name: string
22
- description?: string
23
- isSystem?: boolean
24
- systemPermissions?: SystemPermission[]
25
- /** feature key → allowed actions. The canonical permission map (saas-core shell name). */
26
- grants: Record<string, PermissionAction[]>
27
- }
28
-
29
- export interface PermissionsConfig {
30
- features: FeatureDeclaration[]
31
- defaultProfiles?: PermissionProfile[]
32
- }