@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.
- package/README.md +2 -2
- package/dist/access/index.js.map +1 -1
- package/dist/{chunk-L4TLMYGC.js → chunk-6RBW2Y5K.js} +3 -3
- package/dist/chunk-6RBW2Y5K.js.map +1 -0
- package/dist/chunk-732GZEUI.js +1592 -0
- package/dist/chunk-732GZEUI.js.map +1 -0
- package/dist/{chunk-X5THHG6T.js → chunk-CPMHCTX3.js} +3 -3
- package/dist/chunk-CPMHCTX3.js.map +1 -0
- package/dist/{chunk-V2MSAUHO.js → chunk-JO7Z2AOE.js} +2 -2
- package/dist/chunk-JO7Z2AOE.js.map +1 -0
- package/dist/{chunk-5RJVUC6J.js → chunk-M27JPX3K.js} +12 -3
- package/dist/chunk-M27JPX3K.js.map +1 -0
- package/dist/chunk-OXQGRJZT.js +125 -0
- package/dist/chunk-OXQGRJZT.js.map +1 -0
- package/dist/data/backend-env.d.ts +38 -0
- package/dist/data/backend-env.d.ts.map +1 -0
- package/dist/data/index.js +1 -1
- package/dist/entity/events.d.ts +14 -0
- package/dist/entity/events.d.ts.map +1 -0
- package/dist/events/envelope.d.ts +31 -0
- package/dist/events/envelope.d.ts.map +1 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/log.d.ts +44 -0
- package/dist/events/log.d.ts.map +1 -0
- package/dist/events/types.d.ts +40 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +10 -0
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +27 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +388 -52
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/{integrations/index.d.ts → integrations.d.ts} +2 -2
- package/dist/integrations.d.ts.map +1 -0
- package/dist/{address/index.d.ts → lib/address.d.ts} +1 -1
- package/dist/{address/index.d.ts.map → lib/address.d.ts.map} +1 -1
- package/dist/{phone/index.d.ts → lib/phone.d.ts} +1 -1
- package/dist/lib/phone.d.ts.map +1 -0
- package/dist/{seo/index.d.ts → lib/seo.d.ts} +18 -1
- package/dist/lib/seo.d.ts.map +1 -0
- package/dist/{tenant/index.d.ts → lib/tenant.d.ts} +1 -1
- package/dist/lib/tenant.d.ts.map +1 -0
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/messaging/index.d.ts +3 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/registry.d.ts +35 -0
- package/dist/messaging/registry.d.ts.map +1 -0
- package/dist/messaging/types.d.ts +67 -0
- package/dist/messaging/types.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -1
- package/dist/plugin/runtime.d.ts +17 -0
- package/dist/plugin/runtime.d.ts.map +1 -1
- package/dist/registry/block-catalog.d.ts +78 -0
- package/dist/registry/block-catalog.d.ts.map +1 -0
- package/dist/registry/block-constraints.d.ts +64 -0
- package/dist/registry/block-constraints.d.ts.map +1 -0
- package/dist/registry/block-schema.d.ts +69 -0
- package/dist/registry/block-schema.d.ts.map +1 -0
- package/dist/registry/blocks.d.ts +84 -0
- package/dist/registry/blocks.d.ts.map +1 -0
- package/dist/registry/entities.d.ts +153 -0
- package/dist/registry/entities.d.ts.map +1 -0
- package/dist/registry/extension-points.d.ts +117 -0
- package/dist/registry/extension-points.d.ts.map +1 -0
- package/dist/registry/handles.d.ts +41 -0
- package/dist/registry/handles.d.ts.map +1 -0
- package/dist/registry/index.d.ts +41 -41
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/loaders.d.ts +55 -0
- package/dist/registry/loaders.d.ts.map +1 -0
- package/dist/registry/registry-class.d.ts +157 -0
- package/dist/registry/registry-class.d.ts.map +1 -0
- package/dist/registry/schema-check.d.ts +14 -0
- package/dist/registry/schema-check.d.ts.map +1 -0
- package/dist/router/index.d.ts +78 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{testing/index.d.ts → testing.d.ts} +3 -3
- package/dist/testing.d.ts.map +1 -0
- package/dist/types/analytics.d.ts +196 -0
- package/dist/types/analytics.d.ts.map +1 -0
- package/dist/types/crud.d.ts +22 -2
- package/dist/types/crud.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +55 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +6 -18
- package/dist/blocks/index.d.ts +0 -25
- package/dist/blocks/index.d.ts.map +0 -1
- package/dist/chunk-5RJVUC6J.js.map +0 -1
- package/dist/chunk-L4TLMYGC.js.map +0 -1
- package/dist/chunk-V2MSAUHO.js.map +0 -1
- package/dist/chunk-X5THHG6T.js.map +0 -1
- package/dist/chunk-Y2C2FBQP.js +0 -35
- package/dist/chunk-Y2C2FBQP.js.map +0 -1
- package/dist/chunk-YH25Y4FW.js +0 -311
- package/dist/chunk-YH25Y4FW.js.map +0 -1
- package/dist/integrations/index.d.ts.map +0 -1
- package/dist/phone/index.d.ts.map +0 -1
- package/dist/seo/index.d.ts.map +0 -1
- package/dist/tenant/index.d.ts.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/src/access/denial.ts +0 -33
- package/src/access/engine.test.ts +0 -48
- package/src/access/engine.ts +0 -136
- package/src/access/index.ts +0 -14
- package/src/access/limits.ts +0 -18
- package/src/address/index.ts +0 -188
- package/src/app/render.tsx +0 -69
- package/src/blocks/index.tsx +0 -68
- package/src/data/archetype.ts +0 -255
- package/src/data/bulk.ts +0 -35
- package/src/data/cached.ts +0 -55
- package/src/data/count.test.ts +0 -152
- package/src/data/count.ts +0 -131
- package/src/data/filters.test.ts +0 -70
- package/src/data/filters.ts +0 -90
- package/src/data/index.ts +0 -11
- package/src/data/mock.ts +0 -90
- package/src/data/platform-api.ts +0 -209
- package/src/data/refresh.ts +0 -115
- package/src/data/resolve.ts +0 -126
- package/src/data/supabase.ts +0 -230
- package/src/data/types.ts +0 -50
- package/src/entity/index.ts +0 -2
- package/src/entity/registry.ts +0 -49
- package/src/events/index.tsx +0 -82
- package/src/i18n/index.ts +0 -476
- package/src/i18n/shell-translations.en.ts +0 -875
- package/src/i18n/shell-translations.pt-br.ts +0 -873
- package/src/index.ts +0 -217
- package/src/integrations/index.ts +0 -237
- package/src/lib/cache.ts +0 -118
- package/src/lib/csv.ts +0 -54
- package/src/lib/format.ts +0 -58
- package/src/manifest/app-manifest.schema.json +0 -676
- package/src/manifest/index.ts +0 -518
- package/src/manifest/serialize.ts +0 -52
- package/src/phone/index.ts +0 -85
- package/src/plugin/createSafeDataProvider.ts +0 -30
- package/src/plugin/index.ts +0 -1
- package/src/plugin/runtime.ts +0 -331
- package/src/registry/index.ts +0 -163
- package/src/router/history.ts +0 -86
- package/src/router/index.ts +0 -29
- package/src/runtime/index.ts +0 -15
- package/src/runtime/oauth.ts +0 -219
- package/src/search/engine.ts +0 -559
- package/src/search/index.ts +0 -25
- package/src/search/text.ts +0 -206
- package/src/search/types.ts +0 -75
- package/src/seo/index.ts +0 -128
- package/src/tenant/index.ts +0 -38
- package/src/testing/index.ts +0 -116
- package/src/types/auth.ts +0 -41
- package/src/types/billing.ts +0 -39
- package/src/types/crud.ts +0 -184
- package/src/types/entities.ts +0 -142
- package/src/types/entitlements.ts +0 -45
- package/src/types/i18n.ts +0 -7
- package/src/types/index.ts +0 -11
- package/src/types/org.ts +0 -137
- package/src/types/payment.ts +0 -44
- package/src/types/permissions.ts +0 -32
- package/src/types/plugins.ts +0 -480
- package/src/types/theme.ts +0 -8
package/src/runtime/oauth.ts
DELETED
|
@@ -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
|
-
}
|