@isomorph.ai/app-sdk 1.2.1
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/dist/index.d.ts +367 -0
- package/dist/index.js +602 -0
- package/dist/integration-execute-input-rules.d.ts +187 -0
- package/dist/integration-execute-input-rules.js +114 -0
- package/dist/supabase-compat.d.ts +323 -0
- package/dist/supabase-compat.js +308 -0
- package/dist/supabase-compat.typecheck.d.ts +23 -0
- package/dist/supabase-compat.typecheck.js +92 -0
- package/package.json +15 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
export type IsomorphErrorCategory = 'AUTH_REQUIRED' | 'FORBIDDEN' | 'NOT_FOUND' | 'CONFLICT' | 'VALIDATION_FAILED' | 'RATE_LIMITED' | 'UNAVAILABLE' | 'INTERNAL';
|
|
2
|
+
export declare class IsomorphError extends Error {
|
|
3
|
+
readonly category: IsomorphErrorCategory;
|
|
4
|
+
readonly requestId?: string | undefined;
|
|
5
|
+
readonly details?: unknown | undefined;
|
|
6
|
+
/** The HTTP status the gateway answered, when the error came from a response. */
|
|
7
|
+
readonly status?: number | undefined;
|
|
8
|
+
constructor(category: IsomorphErrorCategory, message: string, requestId?: string | undefined, details?: unknown | undefined,
|
|
9
|
+
/** The HTTP status the gateway answered, when the error came from a response. */
|
|
10
|
+
status?: number | undefined);
|
|
11
|
+
}
|
|
12
|
+
export interface IsomorphUser {
|
|
13
|
+
id: string;
|
|
14
|
+
email: string;
|
|
15
|
+
appUser?: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface IsomorphResult<T> {
|
|
18
|
+
data: T;
|
|
19
|
+
count?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SlackChannelHistoryRequest {
|
|
22
|
+
operation: 'slack.channel.history';
|
|
23
|
+
resource: string;
|
|
24
|
+
input?: {
|
|
25
|
+
/** How many newest messages to read: an integer from 1 to 15 (the platform's ceiling); default 15. */
|
|
26
|
+
limit?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface SlackMessagePostRequest {
|
|
30
|
+
operation: 'slack.message.post';
|
|
31
|
+
resource: string;
|
|
32
|
+
input: {
|
|
33
|
+
/** Plain text, 1 to 4000 characters. Posted as the app (under the IT-approved per-app name) or as the signed-in person (their consent), the same text either way. */
|
|
34
|
+
text: string;
|
|
35
|
+
};
|
|
36
|
+
/** A fresh UUID per explicit Send press, reused only to retry that press. */
|
|
37
|
+
idempotencyKey: string;
|
|
38
|
+
/**
|
|
39
|
+
* Which of the modes IT approved for this app the post runs under: `app` (the company's Slack app, under the
|
|
40
|
+
* IT-approved per-app name and footer) or `user` (the signed-in person, after their consent). Leave it out when
|
|
41
|
+
* the app is approved for one mode; an app approved for both must say (MODE_REQUIRED), and a mode IT has not
|
|
42
|
+
* approved is refused with MODE_NOT_GRANTED — never served under the other mode.
|
|
43
|
+
*/
|
|
44
|
+
mode?: 'app' | 'user';
|
|
45
|
+
}
|
|
46
|
+
export interface WarehouseViewReadRequest {
|
|
47
|
+
operation: 'warehouse.view.read';
|
|
48
|
+
resource: string;
|
|
49
|
+
input: {
|
|
50
|
+
/** 1 to 32 approved column names, or `['*']` when IT exposes all current and future columns. */
|
|
51
|
+
columns: string[];
|
|
52
|
+
/** How many rows to read: an integer from 1 to 1000; default 100. */
|
|
53
|
+
limit?: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Gmail runs as the signed-in person after their consent. Resources are approved mailbox aliases. */
|
|
57
|
+
export interface GmailThreadListRequest {
|
|
58
|
+
operation: 'gmail.thread.list';
|
|
59
|
+
resource: string;
|
|
60
|
+
input?: {
|
|
61
|
+
limit?: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface GmailMessageReadRequest {
|
|
65
|
+
operation: 'gmail.message.read';
|
|
66
|
+
resource: string;
|
|
67
|
+
input: {
|
|
68
|
+
messageId: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface GmailMessageSendRequest {
|
|
72
|
+
operation: 'gmail.message.send';
|
|
73
|
+
resource: string;
|
|
74
|
+
input: {
|
|
75
|
+
/** 1 to 50 email addresses per recipient list. */
|
|
76
|
+
to: string[];
|
|
77
|
+
cc?: string[];
|
|
78
|
+
bcc?: string[];
|
|
79
|
+
/** 1 to 256 characters. */
|
|
80
|
+
subject: string;
|
|
81
|
+
/** Plain text, 1 to 4000 characters. Attachments and HTML are not supported. */
|
|
82
|
+
text: string;
|
|
83
|
+
replyToMessageId?: string;
|
|
84
|
+
};
|
|
85
|
+
/** A fresh UUID per authorized Send action, reused only to retry that action. */
|
|
86
|
+
idempotencyKey: string;
|
|
87
|
+
}
|
|
88
|
+
export type IntegrationRequest = SlackChannelHistoryRequest | SlackMessagePostRequest | WarehouseViewReadRequest | GmailThreadListRequest | GmailMessageReadRequest | GmailMessageSendRequest;
|
|
89
|
+
export type IntegrationOperation = IntegrationRequest['operation'];
|
|
90
|
+
export interface SlackMessage {
|
|
91
|
+
id: string;
|
|
92
|
+
text: string;
|
|
93
|
+
authorId: string;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
/** The per-app display name a post under a per-app name carries (an app can recognise its own posts); absent on a person's message and on a post under the bot's own name. */
|
|
96
|
+
authorName?: string;
|
|
97
|
+
/** The emoji shortcode such a post carries as its icon, e.g. `:green_salad:`, when it has one. */
|
|
98
|
+
authorIcon?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface SlackChannelHistoryResult {
|
|
101
|
+
messages: SlackMessage[];
|
|
102
|
+
hasMore: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface SlackMessagePostResult {
|
|
105
|
+
messageId: string;
|
|
106
|
+
}
|
|
107
|
+
export interface WarehouseViewReadResult {
|
|
108
|
+
rows: Array<Record<string, unknown>>;
|
|
109
|
+
}
|
|
110
|
+
export interface GmailThreadSummary {
|
|
111
|
+
id: string;
|
|
112
|
+
messageId: string;
|
|
113
|
+
subject: string;
|
|
114
|
+
from: string;
|
|
115
|
+
date: string;
|
|
116
|
+
snippet: string;
|
|
117
|
+
}
|
|
118
|
+
export interface GmailThreadListResult {
|
|
119
|
+
threads: GmailThreadSummary[];
|
|
120
|
+
hasMore: boolean;
|
|
121
|
+
}
|
|
122
|
+
export interface GmailMessageReadResult {
|
|
123
|
+
id: string;
|
|
124
|
+
threadId: string;
|
|
125
|
+
subject: string;
|
|
126
|
+
from: string;
|
|
127
|
+
to: string;
|
|
128
|
+
date: string;
|
|
129
|
+
text: string;
|
|
130
|
+
truncated: boolean;
|
|
131
|
+
}
|
|
132
|
+
export interface GmailMessageSendResult {
|
|
133
|
+
messageId: string;
|
|
134
|
+
threadId: string;
|
|
135
|
+
}
|
|
136
|
+
export type IntegrationResult<R extends IntegrationRequest> = R extends SlackChannelHistoryRequest ? SlackChannelHistoryResult : R extends SlackMessagePostRequest ? SlackMessagePostResult : R extends WarehouseViewReadRequest ? WarehouseViewReadResult : R extends GmailThreadListRequest ? GmailThreadListResult : R extends GmailMessageReadRequest ? GmailMessageReadResult : R extends GmailMessageSendRequest ? GmailMessageSendResult : never;
|
|
137
|
+
export type IntegrationConnectResult = {
|
|
138
|
+
status: 'connected';
|
|
139
|
+
accountLabel: string;
|
|
140
|
+
} | {
|
|
141
|
+
status: 'consent_required';
|
|
142
|
+
authorizationUrl: string;
|
|
143
|
+
};
|
|
144
|
+
export interface IntegrationDisconnectResult {
|
|
145
|
+
status: 'disconnected';
|
|
146
|
+
}
|
|
147
|
+
export type AiRole = 'system' | 'user' | 'assistant';
|
|
148
|
+
export interface AiMessage {
|
|
149
|
+
role: AiRole;
|
|
150
|
+
content: string;
|
|
151
|
+
}
|
|
152
|
+
export interface AiChatRequest {
|
|
153
|
+
messages: AiMessage[];
|
|
154
|
+
/** A governed model alias; omitted means the tenant's default generation route. */
|
|
155
|
+
model?: string;
|
|
156
|
+
maxTokens?: number;
|
|
157
|
+
temperature?: number;
|
|
158
|
+
}
|
|
159
|
+
export interface AiChatResult {
|
|
160
|
+
/** The assistant reply, plain text. */
|
|
161
|
+
content: string;
|
|
162
|
+
/** The governed model alias that answered. */
|
|
163
|
+
model: string;
|
|
164
|
+
finishReason: 'stop' | 'length' | 'content_filter' | 'other';
|
|
165
|
+
usage: {
|
|
166
|
+
inputTokens: number;
|
|
167
|
+
outputTokens: number;
|
|
168
|
+
};
|
|
169
|
+
/** The AI gateway trace id, for IT's activity view. */
|
|
170
|
+
traceId?: string;
|
|
171
|
+
}
|
|
172
|
+
export interface AiEmbedRequest {
|
|
173
|
+
input: string | string[];
|
|
174
|
+
model?: string;
|
|
175
|
+
}
|
|
176
|
+
export interface AiEmbedResult {
|
|
177
|
+
embeddings: number[][];
|
|
178
|
+
model: string;
|
|
179
|
+
usage: {
|
|
180
|
+
inputTokens: number;
|
|
181
|
+
};
|
|
182
|
+
traceId?: string;
|
|
183
|
+
}
|
|
184
|
+
/** Stable reason codes governed AI answers with in IsomorphError.details.code. */
|
|
185
|
+
export type AiErrorCode = 'AI_NOT_ENABLED' | 'AI_POLICY_DENIED' | 'AI_QUOTA_EXCEEDED' | 'AI_PROVIDER_ERROR' | 'AI_UNAVAILABLE' | 'REQUEST_TOO_LARGE' | 'VALIDATION_FAILED';
|
|
186
|
+
/** The AI reason code carried by an error, when it is a governed-AI refusal. */
|
|
187
|
+
export declare function aiErrorCode(error: unknown): AiErrorCode | undefined;
|
|
188
|
+
type Fetch = typeof globalThis.fetch;
|
|
189
|
+
type SocketFactory = (url: string) => WebSocket;
|
|
190
|
+
export interface ClientOptions {
|
|
191
|
+
baseUrl?: string;
|
|
192
|
+
fetch?: Fetch;
|
|
193
|
+
websocket?: SocketFactory;
|
|
194
|
+
/**
|
|
195
|
+
* Under the kit gate's runner (never in a browser): which of the two signed
|
|
196
|
+
* identities the runner minted this client acts as. The default is the
|
|
197
|
+
* first person; 'second-user' is the second, for a check that proves one
|
|
198
|
+
* person cannot reach another's rows. The runner supplies both; a check
|
|
199
|
+
* never reads a token name itself.
|
|
200
|
+
*/
|
|
201
|
+
identity?: 'second-user';
|
|
202
|
+
realtimeReconnectMs?: number;
|
|
203
|
+
identityRefreshMs?: number;
|
|
204
|
+
setTimeout?: typeof globalThis.setTimeout;
|
|
205
|
+
clearTimeout?: typeof globalThis.clearTimeout;
|
|
206
|
+
}
|
|
207
|
+
interface Filter {
|
|
208
|
+
column: string;
|
|
209
|
+
operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'is' | 'not' | 'in' | 'ilike' | 'or';
|
|
210
|
+
value: unknown;
|
|
211
|
+
secondaryOperator?: string;
|
|
212
|
+
}
|
|
213
|
+
interface Query {
|
|
214
|
+
operation: 'select' | 'insert' | 'update' | 'upsert' | 'delete';
|
|
215
|
+
columns?: string;
|
|
216
|
+
values?: unknown;
|
|
217
|
+
filters: Filter[];
|
|
218
|
+
orders: Array<{
|
|
219
|
+
column: string;
|
|
220
|
+
ascending: boolean;
|
|
221
|
+
nullsFirst?: boolean;
|
|
222
|
+
}>;
|
|
223
|
+
limit?: number;
|
|
224
|
+
range?: {
|
|
225
|
+
from: number;
|
|
226
|
+
to: number;
|
|
227
|
+
};
|
|
228
|
+
cardinality?: 'single' | 'maybeSingle';
|
|
229
|
+
count?: 'exact';
|
|
230
|
+
head?: boolean;
|
|
231
|
+
onConflict?: string[];
|
|
232
|
+
}
|
|
233
|
+
interface IdentityRenewal {
|
|
234
|
+
renewals(): number;
|
|
235
|
+
renew(sentAt: number): Promise<void>;
|
|
236
|
+
}
|
|
237
|
+
declare class Transport {
|
|
238
|
+
private readonly onUnauthorized?;
|
|
239
|
+
readonly baseUrl: string;
|
|
240
|
+
readonly fetch: Fetch;
|
|
241
|
+
private readonly identity;
|
|
242
|
+
renewal: IdentityRenewal | undefined;
|
|
243
|
+
constructor(options: ClientOptions, onUnauthorized?: (() => void) | undefined);
|
|
244
|
+
json<T>(path: string, init?: RequestInit): Promise<T>;
|
|
245
|
+
private request;
|
|
246
|
+
}
|
|
247
|
+
export declare class QueryBuilder<T = Record<string, unknown>, Result = T[]> implements PromiseLike<IsomorphResult<Result>> {
|
|
248
|
+
private readonly transport;
|
|
249
|
+
private readonly table;
|
|
250
|
+
private readonly query;
|
|
251
|
+
constructor(transport: Transport, table: string, query?: Query);
|
|
252
|
+
private next;
|
|
253
|
+
select(columns?: string, options?: {
|
|
254
|
+
count?: 'exact';
|
|
255
|
+
head?: boolean;
|
|
256
|
+
}): QueryBuilder<T, Result>;
|
|
257
|
+
insert(values: unknown): QueryBuilder<T, Result>;
|
|
258
|
+
update(values: unknown): QueryBuilder<T, Result>;
|
|
259
|
+
upsert(values: unknown, options?: {
|
|
260
|
+
onConflict?: string | string[];
|
|
261
|
+
}): QueryBuilder<T, Result>;
|
|
262
|
+
delete(): QueryBuilder<T, Result>;
|
|
263
|
+
eq(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
264
|
+
neq(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
265
|
+
gt(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
266
|
+
gte(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
267
|
+
lt(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
268
|
+
lte(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
269
|
+
is(column: string, value: unknown): QueryBuilder<T, Result>;
|
|
270
|
+
in(column: string, values: unknown[]): QueryBuilder<T, Result>;
|
|
271
|
+
ilike(column: string, value: string): QueryBuilder<T, Result>;
|
|
272
|
+
or(expression: string): QueryBuilder<T, Result>;
|
|
273
|
+
not(column: string, operator: string, value: unknown): QueryBuilder<T, Result>;
|
|
274
|
+
private filter;
|
|
275
|
+
order(column: string, options?: {
|
|
276
|
+
ascending?: boolean;
|
|
277
|
+
nullsFirst?: boolean;
|
|
278
|
+
}): QueryBuilder<T, Result>;
|
|
279
|
+
limit(value: number): QueryBuilder<T, Result>;
|
|
280
|
+
range(from: number, to: number): QueryBuilder<T, Result>;
|
|
281
|
+
single(): QueryBuilder<T, T>;
|
|
282
|
+
maybeSingle(): QueryBuilder<T, T | null>;
|
|
283
|
+
execute(): Promise<IsomorphResult<Result>>;
|
|
284
|
+
then<TResult1 = IsomorphResult<Result>, TResult2 = never>(onfulfilled?: ((value: IsomorphResult<Result>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
285
|
+
}
|
|
286
|
+
export interface RealtimeSubscription {
|
|
287
|
+
unsubscribe(): void;
|
|
288
|
+
track(state: Record<string, unknown>): void;
|
|
289
|
+
presenceState(): Record<string, unknown[]>;
|
|
290
|
+
}
|
|
291
|
+
type RealtimeHandler = (payload: unknown) => void;
|
|
292
|
+
type RealtimeStatus = 'SUBSCRIBED' | 'CLOSED' | 'CHANNEL_ERROR' | 'RECONNECTING' | 'REFETCH_REQUIRED';
|
|
293
|
+
declare class RealtimeChannelBuilder {
|
|
294
|
+
private readonly channel;
|
|
295
|
+
private readonly connect;
|
|
296
|
+
private handlers;
|
|
297
|
+
constructor(channel: string, connect: (channel: string, handlers: typeof this.handlers, status?: (value: RealtimeStatus) => void) => RealtimeSubscription);
|
|
298
|
+
on(event: 'postgres_changes' | 'presence' | 'broadcast', filter: unknown, handler: RealtimeHandler): this;
|
|
299
|
+
subscribe(callback?: (status: RealtimeStatus) => void): RealtimeSubscription;
|
|
300
|
+
}
|
|
301
|
+
export declare function createClient(options?: ClientOptions): {
|
|
302
|
+
identity: {
|
|
303
|
+
current: () => Promise<IsomorphUser | null>;
|
|
304
|
+
signIn: (returnTo?: string) => string;
|
|
305
|
+
signOut: (returnTo?: string) => string;
|
|
306
|
+
onChange: (listener: (user: IsomorphUser | null) => void) => () => void;
|
|
307
|
+
};
|
|
308
|
+
data: {
|
|
309
|
+
from: <T = Record<string, unknown>>(table: string) => QueryBuilder<T, T[]>;
|
|
310
|
+
rpc: <T = unknown>(name: string, args?: Record<string, unknown>) => Promise<T>;
|
|
311
|
+
};
|
|
312
|
+
files: {
|
|
313
|
+
createUpload: (input: {
|
|
314
|
+
path: string;
|
|
315
|
+
contentType: string;
|
|
316
|
+
size: number;
|
|
317
|
+
checksum?: string;
|
|
318
|
+
}) => Promise<unknown>;
|
|
319
|
+
upload: (path: string, body: Blob, checksum?: string) => Promise<unknown>;
|
|
320
|
+
list: (prefix?: string) => Promise<unknown[]>;
|
|
321
|
+
remove: (paths: string[]) => Promise<void>;
|
|
322
|
+
getPublicUrl: (path: string) => string;
|
|
323
|
+
createSignedUrl: (path: string, expiresIn?: number) => Promise<{
|
|
324
|
+
signedUrl: string;
|
|
325
|
+
}>;
|
|
326
|
+
createSignedUrls: (paths: string[], expiresIn?: number) => Promise<{
|
|
327
|
+
path: string;
|
|
328
|
+
signedUrl: string;
|
|
329
|
+
}[]>;
|
|
330
|
+
};
|
|
331
|
+
realtime: {
|
|
332
|
+
channel: (name: string) => RealtimeChannelBuilder;
|
|
333
|
+
};
|
|
334
|
+
actions: {
|
|
335
|
+
invoke: <T = unknown>(name: string, input: unknown) => Promise<T>;
|
|
336
|
+
};
|
|
337
|
+
telemetry: {
|
|
338
|
+
track: (name: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
339
|
+
page: (path?: string) => Promise<void>;
|
|
340
|
+
};
|
|
341
|
+
integrations: {
|
|
342
|
+
execute: <R extends IntegrationRequest>(connection: string, request: R) => Promise<IntegrationResult<R>>;
|
|
343
|
+
connect: (connection: string) => Promise<IntegrationConnectResult>;
|
|
344
|
+
disconnect: (connection: string) => Promise<IntegrationDisconnectResult>;
|
|
345
|
+
};
|
|
346
|
+
ai: {
|
|
347
|
+
chat: (request: AiChatRequest) => Promise<AiChatResult>;
|
|
348
|
+
embed: (request: AiEmbedRequest) => Promise<AiEmbedResult>;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
export type IsomorphClient = ReturnType<typeof createClient>;
|
|
352
|
+
export { IntegrationExecuteInputRules, integrationExecuteInputMaximum, validateIntegrationExecuteInput, type IntegrationExecuteInputFieldRule, type IntegrationExecuteInputProblem, type IntegrationExecuteInputValidation, type IntegrationExecuteOperationRule, type IntegrationExecuteOperation, } from './integration-execute-input-rules.js';
|
|
353
|
+
export { createSupabaseCompatClient, decodeSupabaseCompatResponse, SupabaseCompatQueryBuilder, type SupabaseCompatClient, type SupabaseCompatError, type SupabaseCompatResponse, type SupabaseCompatSession, type SupabaseCompatUser, type SupabaseCompatAuthEvent, type SupabaseCompatFunctionsInvokeOptions, type IsomorphCompatSource, type CompatQuerySource, type CompatChannel, } from './supabase-compat.js';
|
|
354
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphError. */
|
|
355
|
+
export declare const HarbourError: typeof IsomorphError;
|
|
356
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphError. */
|
|
357
|
+
export type HarbourError = IsomorphError;
|
|
358
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphErrorCategory. */
|
|
359
|
+
export type HarbourErrorCategory = IsomorphErrorCategory;
|
|
360
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphUser. */
|
|
361
|
+
export type HarbourUser = IsomorphUser;
|
|
362
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphResult. */
|
|
363
|
+
export type HarbourResult<T> = IsomorphResult<T>;
|
|
364
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphClient. */
|
|
365
|
+
export type HarbourClient = IsomorphClient;
|
|
366
|
+
/** @deprecated Internal transformation lane only; a kit app uses IsomorphCompatSource. */
|
|
367
|
+
export type HarbourCompatSource = import('./supabase-compat.js').IsomorphCompatSource;
|