@fayz-ai/core 0.9.0 → 0.10.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 (170) hide show
  1. package/README.md +2 -2
  2. package/dist/access/index.js.map +1 -1
  3. package/dist/{chunk-L4TLMYGC.js → chunk-6RBW2Y5K.js} +3 -3
  4. package/dist/chunk-6RBW2Y5K.js.map +1 -0
  5. package/dist/chunk-732GZEUI.js +1592 -0
  6. package/dist/chunk-732GZEUI.js.map +1 -0
  7. package/dist/{chunk-X5THHG6T.js → chunk-CPMHCTX3.js} +3 -3
  8. package/dist/chunk-CPMHCTX3.js.map +1 -0
  9. package/dist/{chunk-V2MSAUHO.js → chunk-JO7Z2AOE.js} +2 -2
  10. package/dist/chunk-JO7Z2AOE.js.map +1 -0
  11. package/dist/{chunk-5RJVUC6J.js → chunk-M27JPX3K.js} +12 -3
  12. package/dist/chunk-M27JPX3K.js.map +1 -0
  13. package/dist/chunk-OXQGRJZT.js +125 -0
  14. package/dist/chunk-OXQGRJZT.js.map +1 -0
  15. package/dist/data/backend-env.d.ts +38 -0
  16. package/dist/data/backend-env.d.ts.map +1 -0
  17. package/dist/data/index.js +1 -1
  18. package/dist/entity/events.d.ts +14 -0
  19. package/dist/entity/events.d.ts.map +1 -0
  20. package/dist/events/envelope.d.ts +31 -0
  21. package/dist/events/envelope.d.ts.map +1 -0
  22. package/dist/events/index.d.ts +4 -0
  23. package/dist/events/index.d.ts.map +1 -1
  24. package/dist/events/log.d.ts +44 -0
  25. package/dist/events/log.d.ts.map +1 -0
  26. package/dist/events/types.d.ts +40 -0
  27. package/dist/events/types.d.ts.map +1 -0
  28. package/dist/i18n/index.d.ts +10 -0
  29. package/dist/i18n/index.d.ts.map +1 -1
  30. package/dist/i18n/index.js +1 -1
  31. package/dist/index.d.ts +27 -17
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +388 -52
  34. package/dist/index.js.map +1 -1
  35. package/dist/integrations/index.js +1 -1
  36. package/dist/{integrations/index.d.ts → integrations.d.ts} +2 -2
  37. package/dist/integrations.d.ts.map +1 -0
  38. package/dist/{address/index.d.ts → lib/address.d.ts} +1 -1
  39. package/dist/{address/index.d.ts.map → lib/address.d.ts.map} +1 -1
  40. package/dist/{phone/index.d.ts → lib/phone.d.ts} +1 -1
  41. package/dist/lib/phone.d.ts.map +1 -0
  42. package/dist/{seo/index.d.ts → lib/seo.d.ts} +18 -1
  43. package/dist/lib/seo.d.ts.map +1 -0
  44. package/dist/{tenant/index.d.ts → lib/tenant.d.ts} +1 -1
  45. package/dist/lib/tenant.d.ts.map +1 -0
  46. package/dist/manifest/index.d.ts +1 -1
  47. package/dist/manifest/index.d.ts.map +1 -1
  48. package/dist/messaging/index.d.ts +3 -0
  49. package/dist/messaging/index.d.ts.map +1 -0
  50. package/dist/messaging/registry.d.ts +35 -0
  51. package/dist/messaging/registry.d.ts.map +1 -0
  52. package/dist/messaging/types.d.ts +67 -0
  53. package/dist/messaging/types.d.ts.map +1 -0
  54. package/dist/plugin/index.js +2 -1
  55. package/dist/plugin/runtime.d.ts +17 -0
  56. package/dist/plugin/runtime.d.ts.map +1 -1
  57. package/dist/registry/block-catalog.d.ts +78 -0
  58. package/dist/registry/block-catalog.d.ts.map +1 -0
  59. package/dist/registry/block-constraints.d.ts +64 -0
  60. package/dist/registry/block-constraints.d.ts.map +1 -0
  61. package/dist/registry/block-schema.d.ts +69 -0
  62. package/dist/registry/block-schema.d.ts.map +1 -0
  63. package/dist/registry/blocks.d.ts +84 -0
  64. package/dist/registry/blocks.d.ts.map +1 -0
  65. package/dist/registry/entities.d.ts +153 -0
  66. package/dist/registry/entities.d.ts.map +1 -0
  67. package/dist/registry/extension-points.d.ts +117 -0
  68. package/dist/registry/extension-points.d.ts.map +1 -0
  69. package/dist/registry/handles.d.ts +41 -0
  70. package/dist/registry/handles.d.ts.map +1 -0
  71. package/dist/registry/index.d.ts +41 -41
  72. package/dist/registry/index.d.ts.map +1 -1
  73. package/dist/registry/loaders.d.ts +55 -0
  74. package/dist/registry/loaders.d.ts.map +1 -0
  75. package/dist/registry/registry-class.d.ts +157 -0
  76. package/dist/registry/registry-class.d.ts.map +1 -0
  77. package/dist/registry/schema-check.d.ts +14 -0
  78. package/dist/registry/schema-check.d.ts.map +1 -0
  79. package/dist/router/index.d.ts +78 -1
  80. package/dist/router/index.d.ts.map +1 -1
  81. package/dist/router/index.js +1 -1
  82. package/dist/testing/index.js +1 -1
  83. package/dist/{testing/index.d.ts → testing.d.ts} +3 -3
  84. package/dist/testing.d.ts.map +1 -0
  85. package/dist/types/analytics.d.ts +196 -0
  86. package/dist/types/analytics.d.ts.map +1 -0
  87. package/dist/types/crud.d.ts +22 -2
  88. package/dist/types/crud.d.ts.map +1 -1
  89. package/dist/types/plugins.d.ts +55 -1
  90. package/dist/types/plugins.d.ts.map +1 -1
  91. package/package.json +6 -18
  92. package/dist/blocks/index.d.ts +0 -25
  93. package/dist/blocks/index.d.ts.map +0 -1
  94. package/dist/chunk-5RJVUC6J.js.map +0 -1
  95. package/dist/chunk-L4TLMYGC.js.map +0 -1
  96. package/dist/chunk-V2MSAUHO.js.map +0 -1
  97. package/dist/chunk-X5THHG6T.js.map +0 -1
  98. package/dist/chunk-Y2C2FBQP.js +0 -35
  99. package/dist/chunk-Y2C2FBQP.js.map +0 -1
  100. package/dist/chunk-YH25Y4FW.js +0 -311
  101. package/dist/chunk-YH25Y4FW.js.map +0 -1
  102. package/dist/integrations/index.d.ts.map +0 -1
  103. package/dist/phone/index.d.ts.map +0 -1
  104. package/dist/seo/index.d.ts.map +0 -1
  105. package/dist/tenant/index.d.ts.map +0 -1
  106. package/dist/testing/index.d.ts.map +0 -1
  107. package/src/access/denial.ts +0 -33
  108. package/src/access/engine.test.ts +0 -48
  109. package/src/access/engine.ts +0 -136
  110. package/src/access/index.ts +0 -14
  111. package/src/access/limits.ts +0 -18
  112. package/src/address/index.ts +0 -188
  113. package/src/app/render.tsx +0 -69
  114. package/src/blocks/index.tsx +0 -68
  115. package/src/data/archetype.ts +0 -255
  116. package/src/data/bulk.ts +0 -35
  117. package/src/data/cached.ts +0 -55
  118. package/src/data/count.test.ts +0 -152
  119. package/src/data/count.ts +0 -131
  120. package/src/data/filters.test.ts +0 -70
  121. package/src/data/filters.ts +0 -90
  122. package/src/data/index.ts +0 -11
  123. package/src/data/mock.ts +0 -90
  124. package/src/data/platform-api.ts +0 -209
  125. package/src/data/refresh.ts +0 -115
  126. package/src/data/resolve.ts +0 -126
  127. package/src/data/supabase.ts +0 -230
  128. package/src/data/types.ts +0 -50
  129. package/src/entity/index.ts +0 -2
  130. package/src/entity/registry.ts +0 -49
  131. package/src/events/index.tsx +0 -82
  132. package/src/i18n/index.ts +0 -476
  133. package/src/i18n/shell-translations.en.ts +0 -875
  134. package/src/i18n/shell-translations.pt-br.ts +0 -873
  135. package/src/index.ts +0 -217
  136. package/src/integrations/index.ts +0 -237
  137. package/src/lib/cache.ts +0 -118
  138. package/src/lib/csv.ts +0 -54
  139. package/src/lib/format.ts +0 -58
  140. package/src/manifest/app-manifest.schema.json +0 -676
  141. package/src/manifest/index.ts +0 -518
  142. package/src/manifest/serialize.ts +0 -52
  143. package/src/phone/index.ts +0 -85
  144. package/src/plugin/createSafeDataProvider.ts +0 -30
  145. package/src/plugin/index.ts +0 -1
  146. package/src/plugin/runtime.ts +0 -331
  147. package/src/registry/index.ts +0 -163
  148. package/src/router/history.ts +0 -86
  149. package/src/router/index.ts +0 -29
  150. package/src/runtime/index.ts +0 -15
  151. package/src/runtime/oauth.ts +0 -219
  152. package/src/search/engine.ts +0 -559
  153. package/src/search/index.ts +0 -25
  154. package/src/search/text.ts +0 -206
  155. package/src/search/types.ts +0 -75
  156. package/src/seo/index.ts +0 -128
  157. package/src/tenant/index.ts +0 -38
  158. package/src/testing/index.ts +0 -116
  159. package/src/types/auth.ts +0 -41
  160. package/src/types/billing.ts +0 -39
  161. package/src/types/crud.ts +0 -184
  162. package/src/types/entities.ts +0 -142
  163. package/src/types/entitlements.ts +0 -45
  164. package/src/types/i18n.ts +0 -7
  165. package/src/types/index.ts +0 -11
  166. package/src/types/org.ts +0 -137
  167. package/src/types/payment.ts +0 -44
  168. package/src/types/permissions.ts +0 -32
  169. package/src/types/plugins.ts +0 -480
  170. package/src/types/theme.ts +0 -8
@@ -1,219 +0,0 @@
1
- export type FayzRuntimeEnvironment = 'preview' | 'production'
2
-
3
- export interface FayzRuntimeClientOptions {
4
- baseUrl: string
5
- projectId: string
6
- runtimeToken: string | (() => string | Promise<string>)
7
- fetcher?: typeof fetch
8
- }
9
-
10
- export interface PluginOAuthExchangeInput {
11
- pluginId: string
12
- environment?: FayzRuntimeEnvironment
13
- scopes?: string[]
14
- }
15
-
16
- export interface RuntimePluginOAuthGrant {
17
- grantId: string
18
- provider: string
19
- scopes: string[]
20
- }
21
-
22
- export interface PluginOAuthExchangeResponse {
23
- token: string
24
- tokenType: 'Bearer'
25
- expiresIn: number
26
- projectId: string
27
- tenantKey: string
28
- environment: FayzRuntimeEnvironment
29
- pluginId: string
30
- grants: RuntimePluginOAuthGrant[]
31
- }
32
-
33
- export interface GoogleCalendarEventTime {
34
- dateTime: string
35
- timeZone?: string
36
- }
37
-
38
- export interface GoogleCalendarEventInput {
39
- summary: string
40
- description?: string
41
- location?: string
42
- start: GoogleCalendarEventTime
43
- end: GoogleCalendarEventTime
44
- attendees?: Array<{ email: string }>
45
- }
46
-
47
- export interface GoogleCalendarEvent {
48
- id: string
49
- summary?: string
50
- description?: string
51
- location?: string
52
- start: { dateTime?: string; date?: string; timeZone?: string }
53
- end: { dateTime?: string; date?: string; timeZone?: string }
54
- status?: string
55
- htmlLink?: string
56
- [key: string]: unknown
57
- }
58
-
59
- export interface ListGoogleCalendarEventsInput {
60
- calendarId: string
61
- timeMin?: string
62
- timeMax?: string
63
- maxResults?: number
64
- q?: string
65
- }
66
-
67
- export class FayzRuntimeError extends Error {
68
- constructor(
69
- message: string,
70
- readonly status: number,
71
- readonly responseBody?: unknown,
72
- ) {
73
- super(message)
74
- this.name = 'FayzRuntimeError'
75
- }
76
- }
77
-
78
- function normalizeBaseUrl(baseUrl: string): string {
79
- return baseUrl.replace(/\/+$/, '')
80
- }
81
-
82
- function assertRequired(value: string, field: string): string {
83
- const normalized = value.trim()
84
- if (!normalized) throw new Error(`[@fayz-ai/core] ${field} is required`)
85
- return normalized
86
- }
87
-
88
- async function resolveRuntimeToken(
89
- runtimeToken: FayzRuntimeClientOptions['runtimeToken'],
90
- ): Promise<string> {
91
- const value = typeof runtimeToken === 'function' ? await runtimeToken() : runtimeToken
92
- return assertRequired(value, 'runtimeToken')
93
- }
94
-
95
- function runtimePath(projectId: string, suffix: string): string {
96
- return `/api/v1/runtime/projects/${encodeURIComponent(projectId)}${suffix}`
97
- }
98
-
99
- function queryString(params: Record<string, string | number | undefined>): string {
100
- const search = new URLSearchParams()
101
- for (const [key, value] of Object.entries(params)) {
102
- if (value !== undefined && value !== '') search.set(key, String(value))
103
- }
104
- const value = search.toString()
105
- return value ? `?${value}` : ''
106
- }
107
-
108
- async function parseResponse<T>(response: Response): Promise<T> {
109
- if (response.status === 204) return undefined as T
110
-
111
- const text = await response.text()
112
- let body: unknown
113
- try {
114
- body = text ? JSON.parse(text) : undefined
115
- } catch {
116
- body = text
117
- }
118
-
119
- if (!response.ok) {
120
- const message = typeof body === 'object' && body && 'message' in body
121
- ? String((body as { message: unknown }).message)
122
- : `[@fayz-ai/core] Runtime request failed with status ${response.status}`
123
- throw new FayzRuntimeError(message, response.status, body)
124
- }
125
-
126
- return body as T
127
- }
128
-
129
- export function createFayzRuntimeClient(options: FayzRuntimeClientOptions) {
130
- const baseUrl = normalizeBaseUrl(assertRequired(options.baseUrl, 'baseUrl'))
131
- const projectId = assertRequired(options.projectId, 'projectId')
132
- const fetcher = options.fetcher ?? fetch
133
-
134
- async function request<T>(
135
- path: string,
136
- token: string,
137
- init: Omit<RequestInit, 'headers'> & { headers?: Record<string, string> } = {},
138
- ): Promise<T> {
139
- const response = await fetcher(`${baseUrl}${path}`, {
140
- ...init,
141
- headers: {
142
- ...(init.body ? { 'Content-Type': 'application/json' } : {}),
143
- ...init.headers,
144
- Authorization: `Bearer ${token}`,
145
- },
146
- })
147
- return parseResponse<T>(response)
148
- }
149
-
150
- async function exchangePluginOAuth(
151
- input: PluginOAuthExchangeInput,
152
- ): Promise<PluginOAuthExchangeResponse> {
153
- return request<PluginOAuthExchangeResponse>(
154
- runtimePath(projectId, '/oauth/exchange'),
155
- await resolveRuntimeToken(options.runtimeToken),
156
- {
157
- method: 'POST',
158
- body: JSON.stringify({
159
- pluginId: assertRequired(input.pluginId, 'pluginId'),
160
- environment: input.environment ?? 'preview',
161
- ...(input.scopes ? { scopes: input.scopes } : {}),
162
- }),
163
- },
164
- )
165
- }
166
-
167
- function googleCalendar(pluginOAuthToken: string) {
168
- const brokerToken = assertRequired(pluginOAuthToken, 'pluginOAuthToken')
169
- const eventsPath = runtimePath(projectId, '/oauth/google-calendar/events')
170
-
171
- return {
172
- listEvents(input: ListGoogleCalendarEventsInput) {
173
- const calendarId = assertRequired(input.calendarId, 'calendarId')
174
- return request<{
175
- provider: 'google-calendar'
176
- calendarId: string
177
- timeMin: string
178
- timeMax: string
179
- events: GoogleCalendarEvent[]
180
- }>(
181
- `${eventsPath}${queryString({
182
- calendarId,
183
- timeMin: input.timeMin,
184
- timeMax: input.timeMax,
185
- maxResults: input.maxResults,
186
- q: input.q,
187
- })}`,
188
- brokerToken,
189
- )
190
- },
191
- createEvent(calendarId: string, event: GoogleCalendarEventInput) {
192
- return request<{ provider: 'google-calendar'; calendarId: string; event: GoogleCalendarEvent }>(
193
- `${eventsPath}${queryString({ calendarId: assertRequired(calendarId, 'calendarId') })}`,
194
- brokerToken,
195
- { method: 'POST', body: JSON.stringify(event) },
196
- )
197
- },
198
- updateEvent(calendarId: string, eventId: string, updates: Partial<GoogleCalendarEventInput>) {
199
- return request<{ provider: 'google-calendar'; calendarId: string; event: GoogleCalendarEvent }>(
200
- `${eventsPath}/${encodeURIComponent(assertRequired(eventId, 'eventId'))}${queryString({ calendarId: assertRequired(calendarId, 'calendarId') })}`,
201
- brokerToken,
202
- { method: 'PATCH', body: JSON.stringify(updates) },
203
- )
204
- },
205
- deleteEvent(calendarId: string, eventId: string) {
206
- return request<void>(
207
- `${eventsPath}/${encodeURIComponent(assertRequired(eventId, 'eventId'))}${queryString({ calendarId: assertRequired(calendarId, 'calendarId') })}`,
208
- brokerToken,
209
- { method: 'DELETE' },
210
- )
211
- },
212
- }
213
- }
214
-
215
- return {
216
- exchangePluginOAuth,
217
- googleCalendar,
218
- }
219
- }