@fayz-ai/sdk 0.9.0-next.1 → 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/ai-builder.js +1 -1
- package/dist/{chunk-2YJXKDHO.js → chunk-6UZOXHGJ.js} +11 -6
- package/dist/chunk-6UZOXHGJ.js.map +1 -0
- package/dist/{chunk-V4GWI7WH.js → chunk-7UXTYT6I.js} +65 -4
- package/dist/chunk-7UXTYT6I.js.map +1 -0
- package/dist/{chunk-7XM4LONE.js → chunk-BJFMBVMP.js} +2 -2
- package/dist/chunk-BJFMBVMP.js.map +1 -0
- package/dist/chunk-HA5O3CW7.js +181 -0
- package/dist/chunk-HA5O3CW7.js.map +1 -0
- package/dist/chunk-VRUPJGFZ.js +135 -0
- package/dist/chunk-VRUPJGFZ.js.map +1 -0
- package/dist/deprecations.d.ts +98 -0
- package/dist/deprecations.d.ts.map +1 -0
- package/dist/deprecations.js +3 -0
- package/dist/deprecations.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/release-channels.js +1 -1
- package/dist/shop.d.ts +32 -0
- package/dist/shop.d.ts.map +1 -1
- package/dist/shop.js +2 -1
- package/dist/supported-surface.d.ts +8 -1
- package/dist/supported-surface.d.ts.map +1 -1
- package/dist/supported-surface.js +1 -1
- package/dist/vite.d.ts +30 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +10 -2
- package/dist/vite.js.map +1 -1
- package/package.json +7 -14
- package/dist/chunk-2YJXKDHO.js.map +0 -1
- package/dist/chunk-7XM4LONE.js.map +0 -1
- package/dist/chunk-V4GWI7WH.js.map +0 -1
- package/dist/chunk-YZQW3BJA.js +0 -135
- package/dist/chunk-YZQW3BJA.js.map +0 -1
- package/src/agent.test.ts +0 -114
- package/src/agent.ts +0 -335
- package/src/ai-builder.ts +0 -115
- package/src/app-params.ts +0 -69
- package/src/client.test.ts +0 -176
- package/src/client.ts +0 -229
- package/src/index.ts +0 -94
- package/src/release-channels.json +0 -103
- package/src/release-channels.test.ts +0 -41
- package/src/release-channels.ts +0 -41
- package/src/runtime.test.ts +0 -123
- package/src/runtime.ts +0 -211
- package/src/shop.test.ts +0 -114
- package/src/shop.ts +0 -1118
- package/src/supported-surface.json +0 -40
- package/src/supported-surface.ts +0 -33
- package/src/types.ts +0 -67
- package/src/vite.ts +0 -121
package/src/client.test.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
-
import { createFayzClient } from './client'
|
|
3
|
-
|
|
4
|
-
function jsonResponse(body: unknown, status = 200): Response {
|
|
5
|
-
return new Response(JSON.stringify(body), {
|
|
6
|
-
status,
|
|
7
|
-
headers: { 'Content-Type': 'application/json' },
|
|
8
|
-
})
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe('createFayzClient', () => {
|
|
12
|
-
it('normalizes Fayz API requests with app id and bearer token', async () => {
|
|
13
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ user: { id: 'user-1', email: 'vini@fayz.ai' } }))
|
|
14
|
-
const client = createFayzClient({
|
|
15
|
-
baseUrl: 'https://api.fayz.ai/',
|
|
16
|
-
appId: 'app-1',
|
|
17
|
-
token: 'session-token',
|
|
18
|
-
fetcher,
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const user = await client.auth.me()
|
|
22
|
-
|
|
23
|
-
expect(user.id).toBe('user-1')
|
|
24
|
-
expect(fetcher).toHaveBeenCalledWith(
|
|
25
|
-
'https://api.fayz.ai/api/auth/me',
|
|
26
|
-
expect.objectContaining({
|
|
27
|
-
headers: expect.objectContaining({
|
|
28
|
-
'X-App-Id': 'app-1',
|
|
29
|
-
Authorization: 'Bearer session-token',
|
|
30
|
-
}),
|
|
31
|
-
}),
|
|
32
|
-
)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('accepts direct user responses for public auth/me compatibility', async () => {
|
|
36
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ id: 'user-2' }))
|
|
37
|
-
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
38
|
-
|
|
39
|
-
await expect(client.auth.me()).resolves.toEqual({ id: 'user-2' })
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('lists project table rows through the Fayz data API', async () => {
|
|
43
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({
|
|
44
|
-
rows: [{ id: 'booking-1' }],
|
|
45
|
-
total: 12,
|
|
46
|
-
}))
|
|
47
|
-
const client = createFayzClient({
|
|
48
|
-
baseUrl: 'https://api.fayz.ai',
|
|
49
|
-
appId: 'app-1',
|
|
50
|
-
token: async () => 'runtime-token',
|
|
51
|
-
fetcher,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
const result = await client.data.listRows<{ id: string }>({
|
|
55
|
-
projectId: 'project 1',
|
|
56
|
-
table: 'v_appointments',
|
|
57
|
-
filters: [
|
|
58
|
-
{ column: 'starts_at', operator: 'gte', value: '2026-06-14T00:00:00.000Z' },
|
|
59
|
-
{ column: 'status', operator: 'neq', value: 'cancelled' },
|
|
60
|
-
],
|
|
61
|
-
sortColumn: 'starts_at',
|
|
62
|
-
sortDirection: 'asc',
|
|
63
|
-
limit: 20,
|
|
64
|
-
runtime: true,
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
expect(result.rows[0]?.id).toBe('booking-1')
|
|
68
|
-
expect(result.total).toBe(12)
|
|
69
|
-
|
|
70
|
-
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
71
|
-
expect(url).toContain('https://api.fayz.ai/api/v1/runtime/projects/project%201/database/tables/v_appointments/rows?')
|
|
72
|
-
expect(url).toContain('filters=')
|
|
73
|
-
expect(url).toContain('sortColumn=starts_at')
|
|
74
|
-
expect(url).toContain('sortDirection=asc')
|
|
75
|
-
expect(url).toContain('limit=20')
|
|
76
|
-
expect(init).toEqual(expect.objectContaining({
|
|
77
|
-
headers: expect.objectContaining({
|
|
78
|
-
'X-App-Id': 'app-1',
|
|
79
|
-
Authorization: 'Bearer runtime-token',
|
|
80
|
-
}),
|
|
81
|
-
}))
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('counts table rows using the Fayz data API total', async () => {
|
|
85
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({
|
|
86
|
-
rows: [],
|
|
87
|
-
total: 7,
|
|
88
|
-
}))
|
|
89
|
-
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
90
|
-
|
|
91
|
-
await expect(client.data.countRows({
|
|
92
|
-
projectId: 'project-1',
|
|
93
|
-
table: 'clients',
|
|
94
|
-
filters: [{ column: 'active', operator: 'eq', value: true }],
|
|
95
|
-
})).resolves.toBe(7)
|
|
96
|
-
|
|
97
|
-
const [url] = fetcher.mock.calls[0] ?? []
|
|
98
|
-
expect(url).toContain('/api/projects/project-1/database/tables/clients/rows?')
|
|
99
|
-
expect(url).toContain('page=1')
|
|
100
|
-
expect(url).toContain('limit=1')
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it('creates table rows through the Fayz data API', async () => {
|
|
104
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ id: 'menu-1', name: 'Burger' }, 201))
|
|
105
|
-
const client = createFayzClient({
|
|
106
|
-
baseUrl: 'https://api.fayz.ai',
|
|
107
|
-
appId: 'app-1',
|
|
108
|
-
token: 'runtime-token',
|
|
109
|
-
fetcher,
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
const row = await client.data.createRow<{ id: string; name: string }>({
|
|
113
|
-
projectId: 'project-1',
|
|
114
|
-
table: 'menu_items',
|
|
115
|
-
schema: 'public',
|
|
116
|
-
runtime: true,
|
|
117
|
-
row: { name: 'Burger' },
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
expect(row).toEqual({ id: 'menu-1', name: 'Burger' })
|
|
121
|
-
|
|
122
|
-
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
123
|
-
expect(url).toBe('https://api.fayz.ai/api/v1/runtime/projects/project-1/database/tables/menu_items/rows?schema=public')
|
|
124
|
-
expect(init).toEqual(expect.objectContaining({
|
|
125
|
-
method: 'POST',
|
|
126
|
-
body: JSON.stringify({ name: 'Burger' }),
|
|
127
|
-
headers: expect.objectContaining({
|
|
128
|
-
'Content-Type': 'application/json',
|
|
129
|
-
'X-App-Id': 'app-1',
|
|
130
|
-
Authorization: 'Bearer runtime-token',
|
|
131
|
-
}),
|
|
132
|
-
}))
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it('updates table rows by primary key through the Fayz data API', async () => {
|
|
136
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ id: 'table-1', status: 'occupied' }))
|
|
137
|
-
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
138
|
-
|
|
139
|
-
const row = await client.data.updateRow<{ id: string; status: string }>({
|
|
140
|
-
projectId: 'project-1',
|
|
141
|
-
table: 'restaurant_tables',
|
|
142
|
-
primaryKeys: { id: 'table-1' },
|
|
143
|
-
row: { status: 'occupied' },
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
expect(row.status).toBe('occupied')
|
|
147
|
-
|
|
148
|
-
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
149
|
-
expect(url).toBe('https://api.fayz.ai/api/projects/project-1/database/tables/restaurant_tables/rows')
|
|
150
|
-
expect(init).toEqual(expect.objectContaining({
|
|
151
|
-
method: 'PATCH',
|
|
152
|
-
body: JSON.stringify({
|
|
153
|
-
primaryKeys: { id: 'table-1' },
|
|
154
|
-
data: { status: 'occupied' },
|
|
155
|
-
}),
|
|
156
|
-
}))
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
it('deletes table rows through the Fayz data API', async () => {
|
|
160
|
-
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(jsonResponse({ deletedCount: 1 }))
|
|
161
|
-
const client = createFayzClient({ baseUrl: 'https://api.fayz.ai', fetcher })
|
|
162
|
-
|
|
163
|
-
await expect(client.data.deleteRows({
|
|
164
|
-
projectId: 'project-1',
|
|
165
|
-
table: 'restaurant_tables',
|
|
166
|
-
rows: [{ id: 'table-1' }],
|
|
167
|
-
})).resolves.toEqual({ deletedCount: 1 })
|
|
168
|
-
|
|
169
|
-
const [url, init] = fetcher.mock.calls[0] ?? []
|
|
170
|
-
expect(url).toBe('https://api.fayz.ai/api/projects/project-1/database/tables/restaurant_tables/rows')
|
|
171
|
-
expect(init).toEqual(expect.objectContaining({
|
|
172
|
-
method: 'DELETE',
|
|
173
|
-
body: JSON.stringify({ rows: [{ id: 'table-1' }] }),
|
|
174
|
-
}))
|
|
175
|
-
})
|
|
176
|
-
})
|
package/src/client.ts
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { appParams } from './app-params'
|
|
2
|
-
import { createFayzRuntimeClient } from './runtime'
|
|
3
|
-
import type { FayzAuthMeResponse, FayzUser } from './types'
|
|
4
|
-
|
|
5
|
-
export interface FayzClientOptions {
|
|
6
|
-
baseUrl?: string
|
|
7
|
-
token?: string | (() => string | undefined | Promise<string | undefined>)
|
|
8
|
-
appId?: string
|
|
9
|
-
fetcher?: typeof fetch
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FayzRequestOptions extends Omit<RequestInit, 'headers'> {
|
|
13
|
-
headers?: Record<string, string>
|
|
14
|
-
token?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type FayzTableFilterOperator =
|
|
18
|
-
| 'eq'
|
|
19
|
-
| 'neq'
|
|
20
|
-
| 'gt'
|
|
21
|
-
| 'lt'
|
|
22
|
-
| 'gte'
|
|
23
|
-
| 'lte'
|
|
24
|
-
| 'like'
|
|
25
|
-
| 'ilike'
|
|
26
|
-
| 'is_null'
|
|
27
|
-
| 'is_not_null'
|
|
28
|
-
|
|
29
|
-
export interface FayzTableFilter {
|
|
30
|
-
column: string
|
|
31
|
-
operator: FayzTableFilterOperator
|
|
32
|
-
value?: unknown
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface FayzTableListOptions {
|
|
36
|
-
projectId?: string
|
|
37
|
-
table: string
|
|
38
|
-
schema?: string
|
|
39
|
-
filters?: FayzTableFilter[]
|
|
40
|
-
sortColumn?: string
|
|
41
|
-
sortDirection?: 'asc' | 'desc'
|
|
42
|
-
page?: number
|
|
43
|
-
limit?: number
|
|
44
|
-
runtime?: boolean
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface FayzTableListResponse<T> {
|
|
48
|
-
rows: T[]
|
|
49
|
-
total: number
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface FayzTableMutationOptions {
|
|
53
|
-
projectId?: string
|
|
54
|
-
table: string
|
|
55
|
-
schema?: string
|
|
56
|
-
runtime?: boolean
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface FayzTableCreateOptions<T = Record<string, unknown>> extends FayzTableMutationOptions {
|
|
60
|
-
row: T
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface FayzTableUpdateOptions<T = Record<string, unknown>> extends FayzTableMutationOptions {
|
|
64
|
-
primaryKeys: Record<string, unknown>
|
|
65
|
-
row: Partial<T>
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface FayzTableDeleteOptions extends FayzTableMutationOptions {
|
|
69
|
-
rows: Record<string, unknown>[]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface FayzTableDeleteResponse {
|
|
73
|
-
deletedCount: number
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export class FayzApiError extends Error {
|
|
77
|
-
constructor(
|
|
78
|
-
message: string,
|
|
79
|
-
readonly status: number,
|
|
80
|
-
readonly responseBody?: unknown,
|
|
81
|
-
) {
|
|
82
|
-
super(message)
|
|
83
|
-
this.name = 'FayzApiError'
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function normalizeBaseUrl(baseUrl: string): string {
|
|
88
|
-
return baseUrl.replace(/\/+$/, '')
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function apiPath(path: string): string {
|
|
92
|
-
if (/^https?:\/\//.test(path)) return path
|
|
93
|
-
const normalized = path.startsWith('/') ? path : `/${path}`
|
|
94
|
-
return normalized.startsWith('/api/') ? normalized : `/api${normalized}`
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function parseResponse<T>(response: Response): Promise<T> {
|
|
98
|
-
if (response.status === 204) return undefined as T
|
|
99
|
-
|
|
100
|
-
const text = await response.text()
|
|
101
|
-
let body: unknown
|
|
102
|
-
try {
|
|
103
|
-
body = text ? JSON.parse(text) : undefined
|
|
104
|
-
} catch {
|
|
105
|
-
body = text
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (!response.ok) {
|
|
109
|
-
const message = typeof body === 'object' && body
|
|
110
|
-
? String((body as { message?: unknown; error?: unknown }).message ?? (body as { error?: unknown }).error ?? `Fayz API request failed with status ${response.status}`)
|
|
111
|
-
: `Fayz API request failed with status ${response.status}`
|
|
112
|
-
throw new FayzApiError(message, response.status, body)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return body as T
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function resolveToken(token: FayzClientOptions['token']): Promise<string | undefined> {
|
|
119
|
-
return typeof token === 'function' ? token() : token
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function unwrapUser(body: FayzUser | FayzAuthMeResponse): FayzUser {
|
|
123
|
-
return typeof body === 'object' && body && 'user' in body
|
|
124
|
-
? (body as FayzAuthMeResponse).user
|
|
125
|
-
: body as FayzUser
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function tableRowsPath(options: FayzTableListOptions): string {
|
|
129
|
-
const route = tableRowsRoute(options)
|
|
130
|
-
const params = new URLSearchParams()
|
|
131
|
-
|
|
132
|
-
if (options.schema) params.set('schema', options.schema)
|
|
133
|
-
if (options.filters?.length) params.set('filters', JSON.stringify(options.filters))
|
|
134
|
-
if (options.sortColumn) params.set('sortColumn', options.sortColumn)
|
|
135
|
-
if (options.sortDirection) params.set('sortDirection', options.sortDirection)
|
|
136
|
-
if (options.page != null) params.set('page', String(options.page))
|
|
137
|
-
if (options.limit != null) params.set('limit', String(options.limit))
|
|
138
|
-
|
|
139
|
-
const query = params.toString()
|
|
140
|
-
return query ? `${route}?${query}` : route
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function tableRowsRoute(options: FayzTableMutationOptions): string {
|
|
144
|
-
const projectId = encodeURIComponent(options.projectId ?? appParams.projectId ?? 'current')
|
|
145
|
-
const table = encodeURIComponent(options.table)
|
|
146
|
-
return options.runtime
|
|
147
|
-
? `/api/v1/runtime/projects/${projectId}/database/tables/${table}/rows`
|
|
148
|
-
: `/api/projects/${projectId}/database/tables/${table}/rows`
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function mutationRowsPath(options: FayzTableMutationOptions): string {
|
|
152
|
-
const route = tableRowsRoute(options)
|
|
153
|
-
const params = new URLSearchParams()
|
|
154
|
-
|
|
155
|
-
if (options.schema) params.set('schema', options.schema)
|
|
156
|
-
|
|
157
|
-
const query = params.toString()
|
|
158
|
-
return query ? `${route}?${query}` : route
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function createFayzClient(options: FayzClientOptions = {}) {
|
|
162
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl ?? appParams.apiBaseUrl)
|
|
163
|
-
const fetcher = options.fetcher ?? fetch
|
|
164
|
-
const appId = options.appId ?? appParams.appId
|
|
165
|
-
const token = options.token ?? appParams.token
|
|
166
|
-
|
|
167
|
-
async function request<T>(path: string, init: FayzRequestOptions = {}): Promise<T> {
|
|
168
|
-
const requestToken = init.token ?? await resolveToken(token)
|
|
169
|
-
const headers: Record<string, string> = {
|
|
170
|
-
...(init.body ? { 'Content-Type': 'application/json' } : {}),
|
|
171
|
-
...(appId ? { 'X-App-Id': appId } : {}),
|
|
172
|
-
...init.headers,
|
|
173
|
-
...(requestToken ? { Authorization: `Bearer ${requestToken}` } : {}),
|
|
174
|
-
}
|
|
175
|
-
const response = await fetcher(`${baseUrl}${apiPath(path)}`, {
|
|
176
|
-
...init,
|
|
177
|
-
headers,
|
|
178
|
-
})
|
|
179
|
-
return parseResponse<T>(response)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return {
|
|
183
|
-
request,
|
|
184
|
-
auth: {
|
|
185
|
-
async me(): Promise<FayzUser> {
|
|
186
|
-
return unwrapUser(await request<FayzUser | FayzAuthMeResponse>('/auth/me'))
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
data: {
|
|
190
|
-
async listRows<T = Record<string, unknown>>(options: FayzTableListOptions): Promise<FayzTableListResponse<T>> {
|
|
191
|
-
return request<FayzTableListResponse<T>>(tableRowsPath(options))
|
|
192
|
-
},
|
|
193
|
-
async countRows(options: FayzTableListOptions): Promise<number> {
|
|
194
|
-
const response = await request<FayzTableListResponse<unknown>>(tableRowsPath({
|
|
195
|
-
...options,
|
|
196
|
-
page: options.page ?? 1,
|
|
197
|
-
limit: 1,
|
|
198
|
-
}))
|
|
199
|
-
return response.total
|
|
200
|
-
},
|
|
201
|
-
async createRow<T = Record<string, unknown>>(options: FayzTableCreateOptions<Partial<T>>): Promise<T> {
|
|
202
|
-
return request<T>(mutationRowsPath(options), {
|
|
203
|
-
method: 'POST',
|
|
204
|
-
body: JSON.stringify(options.row),
|
|
205
|
-
})
|
|
206
|
-
},
|
|
207
|
-
async updateRow<T = Record<string, unknown>>(options: FayzTableUpdateOptions<T>): Promise<T> {
|
|
208
|
-
return request<T>(mutationRowsPath(options), {
|
|
209
|
-
method: 'PATCH',
|
|
210
|
-
body: JSON.stringify({
|
|
211
|
-
primaryKeys: options.primaryKeys,
|
|
212
|
-
data: options.row,
|
|
213
|
-
}),
|
|
214
|
-
})
|
|
215
|
-
},
|
|
216
|
-
async deleteRows(options: FayzTableDeleteOptions): Promise<FayzTableDeleteResponse> {
|
|
217
|
-
return request<FayzTableDeleteResponse>(mutationRowsPath(options), {
|
|
218
|
-
method: 'DELETE',
|
|
219
|
-
body: JSON.stringify({ rows: options.rows }),
|
|
220
|
-
})
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
runtime: {
|
|
224
|
-
createClient: createFayzRuntimeClient,
|
|
225
|
-
},
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export const fayz = createFayzClient()
|
package/src/index.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
export { appParams, resolveAppParams } from './app-params'
|
|
2
|
-
export { createFayzClient, fayz, FayzApiError } from './client'
|
|
3
|
-
export type {
|
|
4
|
-
FayzClientOptions,
|
|
5
|
-
FayzRequestOptions,
|
|
6
|
-
FayzTableFilter,
|
|
7
|
-
FayzTableFilterOperator,
|
|
8
|
-
FayzTableListOptions,
|
|
9
|
-
FayzTableListResponse,
|
|
10
|
-
FayzTableMutationOptions,
|
|
11
|
-
FayzTableCreateOptions,
|
|
12
|
-
FayzTableUpdateOptions,
|
|
13
|
-
FayzTableDeleteOptions,
|
|
14
|
-
FayzTableDeleteResponse,
|
|
15
|
-
} from './client'
|
|
16
|
-
export {
|
|
17
|
-
fayzPackageVersionSets,
|
|
18
|
-
resolveFayzPackageDependencies,
|
|
19
|
-
resolveFayzPackageVersion,
|
|
20
|
-
resolveFayzPackageVersions,
|
|
21
|
-
} from './release-channels'
|
|
22
|
-
export type { FayzPackageChannel, FayzPackageVersionSet } from './release-channels'
|
|
23
|
-
export {
|
|
24
|
-
getSupportedPackages,
|
|
25
|
-
getInternalPackages,
|
|
26
|
-
isSupportedPackage,
|
|
27
|
-
fayzSupportedSurface,
|
|
28
|
-
} from './supported-surface'
|
|
29
|
-
export type { FayzPackageTier, FayzSupportedSurface } from './supported-surface'
|
|
30
|
-
export {
|
|
31
|
-
AI_BUILDER_REQUEST_CLASSES,
|
|
32
|
-
AI_BUILDER_REQUEST_CLASS_IDS,
|
|
33
|
-
isAllowedRequestClass,
|
|
34
|
-
} from './ai-builder'
|
|
35
|
-
export type {
|
|
36
|
-
FayzLayer,
|
|
37
|
-
AiBuilderRequestClass,
|
|
38
|
-
AiBuilderRequestClassDef,
|
|
39
|
-
} from './ai-builder'
|
|
40
|
-
export {
|
|
41
|
-
createFayzRuntimeClient,
|
|
42
|
-
FayzRuntimeError,
|
|
43
|
-
} from './runtime'
|
|
44
|
-
export { createFayzAgentClient, FayzAgentError } from './agent'
|
|
45
|
-
export type {
|
|
46
|
-
AgentAttachmentColumn,
|
|
47
|
-
AgentAttachmentDigest,
|
|
48
|
-
AgentAttachmentSheet,
|
|
49
|
-
FayzAgentChatInput,
|
|
50
|
-
FayzAgentChatResponse,
|
|
51
|
-
FayzAgentClient,
|
|
52
|
-
FayzAgentClientOptions,
|
|
53
|
-
FayzAgentInfo,
|
|
54
|
-
FayzAgentTool,
|
|
55
|
-
FayzAgentToolCall,
|
|
56
|
-
FayzAgentToolResult,
|
|
57
|
-
} from './agent'
|
|
58
|
-
export {
|
|
59
|
-
createFayzShopProvider,
|
|
60
|
-
FayzShopError,
|
|
61
|
-
} from './shop'
|
|
62
|
-
export type {
|
|
63
|
-
FayzShopProviderOptions,
|
|
64
|
-
FayzShopProductMetadataOverlay,
|
|
65
|
-
FayzShopListProductsOptions,
|
|
66
|
-
FayzShopListOrdersOptions,
|
|
67
|
-
FayzShopListCustomersOptions,
|
|
68
|
-
FayzShopListDiscountsOptions,
|
|
69
|
-
FayzShopProductStatus,
|
|
70
|
-
FayzShopOrderStatus,
|
|
71
|
-
FayzShopFinancialStatus,
|
|
72
|
-
FayzShopFulfillmentStatus,
|
|
73
|
-
} from './shop'
|
|
74
|
-
export type {
|
|
75
|
-
FayzRuntimeClientOptions,
|
|
76
|
-
FayzRuntimeEnvironment,
|
|
77
|
-
GoogleCalendarEvent,
|
|
78
|
-
GoogleCalendarEventInput,
|
|
79
|
-
GoogleCalendarEventTime,
|
|
80
|
-
ListGoogleCalendarEventsInput,
|
|
81
|
-
PluginOAuthExchangeInput,
|
|
82
|
-
PluginOAuthExchangeResponse,
|
|
83
|
-
RuntimePluginOAuthGrant,
|
|
84
|
-
} from './runtime'
|
|
85
|
-
export type {
|
|
86
|
-
AppManifest,
|
|
87
|
-
FayzApiErrorBody,
|
|
88
|
-
FayzAppParams,
|
|
89
|
-
FayzAuthMeResponse,
|
|
90
|
-
FayzUser,
|
|
91
|
-
PageManifest,
|
|
92
|
-
PluginRef,
|
|
93
|
-
SurfaceManifest,
|
|
94
|
-
} from './types'
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"channels": {
|
|
3
|
-
"stable": {
|
|
4
|
-
"@fayz-ai/sdk": "^0.8.5",
|
|
5
|
-
"@fayz-ai/core": "^0.8.5",
|
|
6
|
-
"@fayz-ai/auth": "^0.8.5",
|
|
7
|
-
"@fayz-ai/ui": "^0.8.5",
|
|
8
|
-
"@fayz-ai/saas": "^0.8.5",
|
|
9
|
-
"@fayz-ai/shop": "^0.8.4",
|
|
10
|
-
"@fayz-ai/storefront": "^0.8.5",
|
|
11
|
-
"@fayz-ai/portal": "^0.8.0",
|
|
12
|
-
"@fayz-ai/courses": "^0.8.1",
|
|
13
|
-
"@fayz-ai/db": "^0.8.4",
|
|
14
|
-
"@fayz-ai/plugin-agenda": "^0.8.4",
|
|
15
|
-
"@fayz-ai/plugin-auth": "^0.8.0",
|
|
16
|
-
"@fayz-ai/plugin-automations": "^0.8.0",
|
|
17
|
-
"@fayz-ai/plugin-blog": "^0.8.1",
|
|
18
|
-
"@fayz-ai/plugin-conversations": "^0.8.3",
|
|
19
|
-
"@fayz-ai/plugin-courses": "^0.8.4",
|
|
20
|
-
"@fayz-ai/plugin-crm": "^0.8.5",
|
|
21
|
-
"@fayz-ai/plugin-dashboard": "^0.8.0",
|
|
22
|
-
"@fayz-ai/plugin-financial": "^0.8.4",
|
|
23
|
-
"@fayz-ai/plugin-forms": "^0.8.1",
|
|
24
|
-
"@fayz-ai/plugin-inventory": "^0.8.3",
|
|
25
|
-
"@fayz-ai/plugin-marketing": "^0.8.2",
|
|
26
|
-
"@fayz-ai/plugin-menu": "^0.8.0",
|
|
27
|
-
"@fayz-ai/plugin-orders": "^0.8.0",
|
|
28
|
-
"@fayz-ai/plugin-payments": "^0.8.0",
|
|
29
|
-
"@fayz-ai/plugin-reports": "^0.8.0",
|
|
30
|
-
"@fayz-ai/plugin-reputation": "^0.8.0",
|
|
31
|
-
"@fayz-ai/plugin-shop": "^0.8.4",
|
|
32
|
-
"@fayz-ai/plugin-sites": "^0.8.0",
|
|
33
|
-
"@fayz-ai/plugin-tables": "^0.8.0",
|
|
34
|
-
"@fayz-ai/plugin-tasks": "^0.8.3"
|
|
35
|
-
},
|
|
36
|
-
"latest": {
|
|
37
|
-
"@fayz-ai/sdk": "^0.8.5",
|
|
38
|
-
"@fayz-ai/core": "^0.8.5",
|
|
39
|
-
"@fayz-ai/auth": "^0.8.5",
|
|
40
|
-
"@fayz-ai/ui": "^0.8.5",
|
|
41
|
-
"@fayz-ai/saas": "^0.8.5",
|
|
42
|
-
"@fayz-ai/shop": "^0.8.4",
|
|
43
|
-
"@fayz-ai/storefront": "^0.8.5",
|
|
44
|
-
"@fayz-ai/portal": "^0.8.0",
|
|
45
|
-
"@fayz-ai/courses": "^0.8.1",
|
|
46
|
-
"@fayz-ai/db": "^0.8.4",
|
|
47
|
-
"@fayz-ai/plugin-agenda": "^0.8.4",
|
|
48
|
-
"@fayz-ai/plugin-auth": "^0.8.0",
|
|
49
|
-
"@fayz-ai/plugin-automations": "^0.8.0",
|
|
50
|
-
"@fayz-ai/plugin-blog": "^0.8.1",
|
|
51
|
-
"@fayz-ai/plugin-conversations": "^0.8.3",
|
|
52
|
-
"@fayz-ai/plugin-courses": "^0.8.4",
|
|
53
|
-
"@fayz-ai/plugin-crm": "^0.8.5",
|
|
54
|
-
"@fayz-ai/plugin-dashboard": "^0.8.0",
|
|
55
|
-
"@fayz-ai/plugin-financial": "^0.8.4",
|
|
56
|
-
"@fayz-ai/plugin-forms": "^0.8.1",
|
|
57
|
-
"@fayz-ai/plugin-inventory": "^0.8.3",
|
|
58
|
-
"@fayz-ai/plugin-marketing": "^0.8.2",
|
|
59
|
-
"@fayz-ai/plugin-menu": "^0.8.0",
|
|
60
|
-
"@fayz-ai/plugin-orders": "^0.8.0",
|
|
61
|
-
"@fayz-ai/plugin-payments": "^0.8.0",
|
|
62
|
-
"@fayz-ai/plugin-reports": "^0.8.0",
|
|
63
|
-
"@fayz-ai/plugin-reputation": "^0.8.0",
|
|
64
|
-
"@fayz-ai/plugin-shop": "^0.8.4",
|
|
65
|
-
"@fayz-ai/plugin-sites": "^0.8.0",
|
|
66
|
-
"@fayz-ai/plugin-tables": "^0.8.0",
|
|
67
|
-
"@fayz-ai/plugin-tasks": "^0.8.3"
|
|
68
|
-
},
|
|
69
|
-
"preview": {
|
|
70
|
-
"@fayz-ai/sdk": "^0.8.5",
|
|
71
|
-
"@fayz-ai/core": "^0.8.5",
|
|
72
|
-
"@fayz-ai/auth": "^0.8.5",
|
|
73
|
-
"@fayz-ai/ui": "^0.8.5",
|
|
74
|
-
"@fayz-ai/saas": "^0.8.5",
|
|
75
|
-
"@fayz-ai/shop": "^0.8.4",
|
|
76
|
-
"@fayz-ai/storefront": "^0.8.5",
|
|
77
|
-
"@fayz-ai/portal": "^0.8.0",
|
|
78
|
-
"@fayz-ai/courses": "^0.8.1",
|
|
79
|
-
"@fayz-ai/db": "^0.8.4",
|
|
80
|
-
"@fayz-ai/plugin-agenda": "^0.8.4",
|
|
81
|
-
"@fayz-ai/plugin-auth": "^0.8.0",
|
|
82
|
-
"@fayz-ai/plugin-automations": "^0.8.0",
|
|
83
|
-
"@fayz-ai/plugin-blog": "^0.8.1",
|
|
84
|
-
"@fayz-ai/plugin-conversations": "^0.8.3",
|
|
85
|
-
"@fayz-ai/plugin-courses": "^0.8.4",
|
|
86
|
-
"@fayz-ai/plugin-crm": "^0.8.5",
|
|
87
|
-
"@fayz-ai/plugin-dashboard": "^0.8.0",
|
|
88
|
-
"@fayz-ai/plugin-financial": "^0.8.4",
|
|
89
|
-
"@fayz-ai/plugin-forms": "^0.8.1",
|
|
90
|
-
"@fayz-ai/plugin-inventory": "^0.8.3",
|
|
91
|
-
"@fayz-ai/plugin-marketing": "^0.8.2",
|
|
92
|
-
"@fayz-ai/plugin-menu": "^0.8.0",
|
|
93
|
-
"@fayz-ai/plugin-orders": "^0.8.0",
|
|
94
|
-
"@fayz-ai/plugin-payments": "^0.8.0",
|
|
95
|
-
"@fayz-ai/plugin-reports": "^0.8.0",
|
|
96
|
-
"@fayz-ai/plugin-reputation": "^0.8.0",
|
|
97
|
-
"@fayz-ai/plugin-shop": "^0.8.4",
|
|
98
|
-
"@fayz-ai/plugin-sites": "^0.8.0",
|
|
99
|
-
"@fayz-ai/plugin-tables": "^0.8.0",
|
|
100
|
-
"@fayz-ai/plugin-tasks": "^0.8.3"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import releaseChannels from './release-channels.json' with { type: 'json' }
|
|
3
|
-
import {
|
|
4
|
-
resolveFayzPackageDependencies,
|
|
5
|
-
fayzPackageVersionSets,
|
|
6
|
-
resolveFayzPackageVersion,
|
|
7
|
-
resolveFayzPackageVersions,
|
|
8
|
-
} from './release-channels'
|
|
9
|
-
|
|
10
|
-
describe('release channels', () => {
|
|
11
|
-
it('keeps stable as the default channel', () => {
|
|
12
|
-
expect(resolveFayzPackageVersions()).toEqual({
|
|
13
|
-
channel: 'stable',
|
|
14
|
-
packages: releaseChannels.channels.stable,
|
|
15
|
-
})
|
|
16
|
-
expect(resolveFayzPackageVersions().packages['@fayz-ai/sdk']).toBe(releaseChannels.channels.stable['@fayz-ai/sdk'])
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('returns a copy of package dependencies', () => {
|
|
20
|
-
const dependencies = resolveFayzPackageDependencies()
|
|
21
|
-
dependencies['@fayz-ai/sdk'] = 'tampered'
|
|
22
|
-
|
|
23
|
-
expect(resolveFayzPackageDependencies()['@fayz-ai/sdk']).toBe(releaseChannels.channels.stable['@fayz-ai/sdk'])
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('throws when a package is not mapped for a channel', () => {
|
|
27
|
-
expect(() => resolveFayzPackageVersion('@fayz-ai/app-runtime')).toThrow(
|
|
28
|
-
'No Fayz package version configured for @fayz-ai/app-runtime in stable channel',
|
|
29
|
-
)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('keeps the machine-readable release-channel manifest aligned with the typed export', () => {
|
|
33
|
-
expect(releaseChannels).toEqual({
|
|
34
|
-
channels: {
|
|
35
|
-
stable: fayzPackageVersionSets.stable.packages,
|
|
36
|
-
latest: fayzPackageVersionSets.latest.packages,
|
|
37
|
-
preview: fayzPackageVersionSets.preview.packages,
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
})
|
package/src/release-channels.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import releaseChannels from './release-channels.json'
|
|
2
|
-
|
|
3
|
-
export type FayzPackageChannel = 'stable' | 'latest' | 'preview'
|
|
4
|
-
|
|
5
|
-
export interface FayzPackageVersionSet {
|
|
6
|
-
channel: FayzPackageChannel
|
|
7
|
-
packages: Record<string, string>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const releaseChannelPackages = releaseChannels.channels as Record<FayzPackageChannel, Record<string, string>>
|
|
11
|
-
|
|
12
|
-
function buildVersionSet(channel: FayzPackageChannel): FayzPackageVersionSet {
|
|
13
|
-
return {
|
|
14
|
-
channel,
|
|
15
|
-
packages: { ...releaseChannelPackages[channel] },
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const fayzPackageVersionSets: Record<FayzPackageChannel, FayzPackageVersionSet> = {
|
|
20
|
-
stable: buildVersionSet('stable'),
|
|
21
|
-
latest: buildVersionSet('latest'),
|
|
22
|
-
preview: buildVersionSet('preview'),
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function resolveFayzPackageVersions(channel: FayzPackageChannel = 'stable'): FayzPackageVersionSet {
|
|
26
|
-
return fayzPackageVersionSets[channel]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function resolveFayzPackageDependencies(channel: FayzPackageChannel = 'stable'): Record<string, string> {
|
|
30
|
-
return { ...resolveFayzPackageVersions(channel).packages }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function resolveFayzPackageVersion(packageName: string, channel: FayzPackageChannel = 'stable'): string {
|
|
34
|
-
const version = resolveFayzPackageVersions(channel).packages[packageName]
|
|
35
|
-
|
|
36
|
-
if (!version) {
|
|
37
|
-
throw new Error(`No Fayz package version configured for ${packageName} in ${channel} channel`)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return version
|
|
41
|
-
}
|