@oneclient/sdk 0.1.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.
@@ -0,0 +1,846 @@
1
+ import { type AiRunRequest, type AnalyticsEvent, type ApiErrorCode, type CreateProjectRequest, type CreateProjectResponse, type CreatePreviewEnvironmentRequest, type CreatePreviewEnvironmentResponse, type Domain, type EmailSendRequest, type CreateOrganizationRequest, type CreateDeploymentRequest, type Deployment, type Organization, type Project, type QueryAst, type WalletSummary } from "@oneclient/contracts";
2
+ import type { components, operations } from "@oneclient/contracts/openapi-types";
3
+ export interface OneClientConfig {
4
+ baseUrl: string;
5
+ organizationId?: string;
6
+ publishableKey?: string;
7
+ serverKey?: string;
8
+ deployToken?: string;
9
+ session?: boolean;
10
+ fetch?: typeof globalThis.fetch;
11
+ headers?: Record<string, string>;
12
+ }
13
+ export interface OneClientRuntimeEnv {
14
+ ONECLIENT_API_URL: string;
15
+ ONECLIENT_SERVER_KEY: string;
16
+ ONECLIENT_ENVIRONMENT_ID?: string;
17
+ ONECLIENT_PROJECT_ID?: string;
18
+ ONECLIENT_DEPLOYMENT_ID?: string;
19
+ }
20
+ export interface ProjectAuthUser {
21
+ id: string;
22
+ name: string;
23
+ email: string;
24
+ emailVerified: boolean;
25
+ image: string | null;
26
+ createdAt: string;
27
+ updatedAt: string;
28
+ }
29
+ export interface ProjectAuthSession {
30
+ id: string;
31
+ userId: string;
32
+ token: string;
33
+ expiresAt: string;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ ipAddress: string | null;
37
+ userAgent: string | null;
38
+ }
39
+ export interface ProjectAuthSignIn {
40
+ token: string;
41
+ user: ProjectAuthUser;
42
+ session?: ProjectAuthSession;
43
+ }
44
+ export interface ProjectAuthSessionResult {
45
+ session: ProjectAuthSession;
46
+ user: ProjectAuthUser;
47
+ needsRefresh?: boolean;
48
+ }
49
+ export interface IdempotentRequestOptions {
50
+ idempotencyKey?: string;
51
+ }
52
+ export declare class OneClientError extends Error {
53
+ readonly code: ApiErrorCode;
54
+ readonly requestId: string;
55
+ readonly status: number;
56
+ readonly details?: Record<string, unknown> | undefined;
57
+ constructor(code: ApiErrorCode, message: string, requestId: string, status: number, details?: Record<string, unknown> | undefined);
58
+ }
59
+ type RequestOptions = {
60
+ body?: unknown;
61
+ headers?: Record<string, string>;
62
+ idempotent?: boolean;
63
+ method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
64
+ rawBody?: BodyInit;
65
+ };
66
+ export type ServerKeyScope = "data:*" | "storage:*" | "kv:*" | "jobs:*" | "email:*" | "ai:*" | "analytics:*";
67
+ export interface EnvironmentKey {
68
+ id: string;
69
+ prefix: "pk" | "sk" | "dp";
70
+ name: string;
71
+ scopes: string[];
72
+ lastFour: string;
73
+ createdAt: string;
74
+ lastUsedAt?: string | null;
75
+ expiresAt?: string | null;
76
+ revokedAt?: string | null;
77
+ }
78
+ export interface EnvironmentSecret {
79
+ id: string;
80
+ name: string;
81
+ version: number;
82
+ createdAt: string;
83
+ effectiveOnNextDeployment: boolean;
84
+ }
85
+ export type DataPolicyDocument = components["schemas"]["DataPolicyDocument"];
86
+ export type DataPolicyMutation = components["schemas"]["DataPolicyMutation"];
87
+ export type SqlExecuteInput = operations["executeSql"]["requestBody"]["content"]["application/json"];
88
+ export type SqlExecuteResult = components["schemas"]["SqlResult"];
89
+ export type DevelopmentInbox = components["schemas"]["DevelopmentInbox"];
90
+ export type EnvironmentAuthOrigin = components["schemas"]["EnvironmentAuthOrigin"];
91
+ export interface DeployTokenMutation {
92
+ id: string;
93
+ token: string;
94
+ shownOnce: true;
95
+ }
96
+ export interface GithubInstallation {
97
+ id: string;
98
+ accountLogin: string;
99
+ accountType: string;
100
+ repositorySelection: string;
101
+ status: "active" | "suspended" | "deleted";
102
+ updatedAt: string;
103
+ }
104
+ export interface GithubRepository {
105
+ id: string;
106
+ owner: string;
107
+ name: string;
108
+ fullName: string;
109
+ defaultBranch: string;
110
+ private: boolean;
111
+ }
112
+ export interface GithubLink {
113
+ id: string;
114
+ projectId: string;
115
+ installationId: string;
116
+ repositoryId: string;
117
+ repository: string;
118
+ productionEnvironmentId: string | null;
119
+ previewEnvironmentId: string;
120
+ productionBranch: string;
121
+ framework: "static" | "vite" | "next-opennext" | "worker";
122
+ rootDirectory: string | null;
123
+ entrypoint: string | null;
124
+ buildCommand: string | null;
125
+ outputDirectory: string | null;
126
+ lockfile: "pnpm" | "npm" | "yarn" | "bun" | null;
127
+ autoPromote: boolean;
128
+ previewsEnabled: boolean;
129
+ active: boolean;
130
+ createdAt: string;
131
+ updatedAt: string;
132
+ }
133
+ export interface RegistrarContact {
134
+ email: string;
135
+ phone: string;
136
+ postal_info: {
137
+ name: string;
138
+ organization?: string;
139
+ address: {
140
+ street: string;
141
+ city: string;
142
+ state?: string;
143
+ postal_code: string;
144
+ country_code: string;
145
+ };
146
+ };
147
+ }
148
+ export interface RegistrarAttestation {
149
+ contactAccuracyConfirmed: true;
150
+ registrantAuthorityConfirmed: true;
151
+ registrationAgreementAccepted: true;
152
+ nonRefundableAcknowledged: true;
153
+ termsVersion: string;
154
+ }
155
+ export interface RegistrarQuote {
156
+ id: string;
157
+ domainName: string;
158
+ registrable: boolean;
159
+ reason?: string;
160
+ tier?: string;
161
+ currency?: string;
162
+ registrationCents?: number;
163
+ renewalEstimateCents?: number;
164
+ expiresAt?: string;
165
+ termsVersion: string;
166
+ replayed?: boolean;
167
+ }
168
+ export interface RegistrarOrder {
169
+ id: string;
170
+ domainName: string;
171
+ mode: "sandbox" | "live";
172
+ currency: string;
173
+ amountCents: number;
174
+ status: string;
175
+ providerState: string | null;
176
+ error: string | null;
177
+ createdAt: string;
178
+ updatedAt: string;
179
+ registeredAt: string | null;
180
+ refundedAt: string | null;
181
+ }
182
+ export interface RegistrarRegistration {
183
+ domainName: string;
184
+ orderId: string;
185
+ source: "provider" | "stored";
186
+ orderStatus: string;
187
+ providerStatus: string | null;
188
+ autoRenew: boolean | null;
189
+ locked: boolean | null;
190
+ privacyMode: "off" | "redaction" | null;
191
+ createdAt: string;
192
+ expiresAt: string | null;
193
+ registeredAt: string | null;
194
+ synchronizedAt: string | null;
195
+ capabilities: {
196
+ liveStatus: boolean;
197
+ autoRenewUpdate: false;
198
+ manualRenewal: false;
199
+ contactUpdate: false;
200
+ transferOut: false;
201
+ };
202
+ }
203
+ export type OrganizationRole = "owner" | "admin" | "developer" | "viewer";
204
+ export interface OrganizationMember {
205
+ id: string;
206
+ role: OrganizationRole;
207
+ createdAt: string;
208
+ user: {
209
+ id: string;
210
+ name: string;
211
+ email: string;
212
+ image: string | null;
213
+ };
214
+ }
215
+ export interface OrganizationInvitation {
216
+ id: string;
217
+ email: string;
218
+ role: Exclude<OrganizationRole, "owner">;
219
+ status: string;
220
+ expiresAt: string;
221
+ createdAt: string;
222
+ }
223
+ export interface BillingSession {
224
+ id: string;
225
+ url: string;
226
+ }
227
+ export interface DeploymentUploadSession {
228
+ deploymentId: string;
229
+ status: "uploading" | "queued" | "building" | "ready" | "failed" | "promoted" | "superseded";
230
+ uploadUrl: string;
231
+ maximumBuildSeconds: number;
232
+ maximumBuildAttempts: number;
233
+ replayed?: boolean;
234
+ }
235
+ export interface RetentionExportComponent {
236
+ component: "d1" | "r2" | "kv";
237
+ status: "available" | "preparing" | "ready" | "downloaded" | "failed";
238
+ reservedMicros: string;
239
+ filename: string | null;
240
+ downloadExpiresAt: string | null;
241
+ downloadedAt: string | null;
242
+ errorCode: string | null;
243
+ }
244
+ export interface RetentionExportSession {
245
+ id: string;
246
+ organizationId: string;
247
+ projectId: string;
248
+ environmentId: string;
249
+ status: "available" | "complete" | "expired";
250
+ expiresAt: string;
251
+ createdAt: string;
252
+ replayed: boolean;
253
+ components: RetentionExportComponent[];
254
+ }
255
+ export interface D1RetentionExportResult {
256
+ id?: string;
257
+ component: "d1";
258
+ status: "preparing" | "ready";
259
+ filename?: string;
260
+ downloadUrl?: string;
261
+ downloadExpiresAt?: string;
262
+ }
263
+ export interface S3ObjectSummary {
264
+ key: string;
265
+ etag: string;
266
+ size: number;
267
+ lastModified: string;
268
+ storageClass: string;
269
+ }
270
+ export interface S3ObjectList {
271
+ name: string;
272
+ prefix: string;
273
+ keyCount: number;
274
+ maxKeys: number;
275
+ isTruncated: boolean;
276
+ nextContinuationToken: string | null;
277
+ commonPrefixes: string[];
278
+ contents: S3ObjectSummary[];
279
+ }
280
+ export interface S3ObjectMetadata {
281
+ etag: string;
282
+ contentLength: number;
283
+ lastModified: string;
284
+ storageClass: string;
285
+ contentType: string | null;
286
+ }
287
+ export interface S3MultipartUpload {
288
+ bucket: string;
289
+ key: string;
290
+ uploadId: string;
291
+ }
292
+ export interface S3UploadedPart {
293
+ partNumber: number;
294
+ etag: string;
295
+ }
296
+ export interface S3CompletedMultipartUpload extends S3MultipartUpload {
297
+ etag: string;
298
+ }
299
+ export interface S3BodyOptions extends IdempotentRequestOptions {
300
+ contentLength?: number;
301
+ contentType?: string;
302
+ }
303
+ export declare class OneClient {
304
+ private readonly baseUrl;
305
+ private readonly fetcher;
306
+ private readonly baseHeaders;
307
+ private readonly organizationId;
308
+ readonly auth: {
309
+ sendMagicLink: (input: {
310
+ email: string;
311
+ callbackURL?: string;
312
+ newUserCallbackURL?: string;
313
+ }, options?: IdempotentRequestOptions) => Promise<{
314
+ status: true;
315
+ }>;
316
+ sendOtp: (input: {
317
+ email: string;
318
+ type?: "sign-in";
319
+ }, options?: IdempotentRequestOptions) => Promise<{
320
+ success: true;
321
+ }>;
322
+ verifyOtp: (input: {
323
+ email: string;
324
+ otp: string;
325
+ }, options?: IdempotentRequestOptions) => Promise<ProjectAuthSignIn>;
326
+ getSession: () => Promise<ProjectAuthSessionResult | null>;
327
+ signOut: (options?: IdempotentRequestOptions) => Promise<{
328
+ success: true;
329
+ }>;
330
+ };
331
+ readonly account: {
332
+ me: () => Promise<{
333
+ user: {
334
+ id: string;
335
+ name: string;
336
+ email: string;
337
+ image: string | null;
338
+ };
339
+ }>;
340
+ };
341
+ readonly organizations: {
342
+ list: () => Promise<Organization[]>;
343
+ create: (input: CreateOrganizationRequest) => Promise<Organization>;
344
+ update: (organizationId: string, input: {
345
+ name: string;
346
+ slug: string;
347
+ }) => Promise<{
348
+ id: string;
349
+ name: string;
350
+ slug: string;
351
+ updated: true;
352
+ }>;
353
+ members: (organizationId: string) => Promise<{
354
+ members: OrganizationMember[];
355
+ }>;
356
+ updateMember: (organizationId: string, memberId: string, role: OrganizationRole) => Promise<{
357
+ id: string;
358
+ role: OrganizationRole;
359
+ replayed: boolean;
360
+ }>;
361
+ removeMember: (organizationId: string, memberId: string) => Promise<{
362
+ id: string;
363
+ removed: true;
364
+ }>;
365
+ invitations: (organizationId: string) => Promise<{
366
+ invitations: OrganizationInvitation[];
367
+ }>;
368
+ invite: (organizationId: string, email: string, role: OrganizationInvitation["role"]) => Promise<{
369
+ invitation: OrganizationInvitation;
370
+ replayed: boolean;
371
+ }>;
372
+ cancelInvitation: (organizationId: string, invitationId: string) => Promise<{
373
+ id: string;
374
+ status: "canceled";
375
+ }>;
376
+ acceptInvitation: (invitationId: string) => Promise<{
377
+ organizationId: string;
378
+ organizationName: string;
379
+ role: OrganizationInvitation["role"];
380
+ replayed: boolean;
381
+ }>;
382
+ };
383
+ readonly projects: {
384
+ list: () => Promise<Project[]>;
385
+ create: (input: CreateProjectRequest) => Promise<CreateProjectResponse>;
386
+ get: (projectId: string) => Promise<Project>;
387
+ createPreview: (projectId: string, input: CreatePreviewEnvironmentRequest) => Promise<CreatePreviewEnvironmentResponse>;
388
+ deletePreview: (environmentId: string) => Promise<{
389
+ environmentId: string;
390
+ operationId: string | null;
391
+ status: "deleting" | "deleted";
392
+ deletionDueAt: string;
393
+ replayed: boolean;
394
+ }>;
395
+ upgrade: (environmentId: string) => Promise<{
396
+ operationId: string;
397
+ status: string;
398
+ replayed: boolean;
399
+ }>;
400
+ retryProvisioning: (environmentId: string) => Promise<{
401
+ operationId: string;
402
+ status: string;
403
+ replayed: boolean;
404
+ }>;
405
+ cleanupOrphans: (environmentId: string) => Promise<{
406
+ operationId: string | null;
407
+ status: string;
408
+ replayed: boolean;
409
+ }>;
410
+ };
411
+ readonly authOrigins: {
412
+ list: (environmentId: string) => Promise<{
413
+ origins: EnvironmentAuthOrigin[];
414
+ }>;
415
+ create: (environmentId: string, origin: string) => Promise<{
416
+ origin: EnvironmentAuthOrigin;
417
+ replayed: boolean;
418
+ }>;
419
+ delete: (environmentId: string, originId: string) => Promise<{
420
+ id: string;
421
+ deletedAt: string;
422
+ }>;
423
+ };
424
+ readonly data: {
425
+ publishPolicy: (table: string, policy: DataPolicyDocument) => Promise<{
426
+ table: string;
427
+ version: number;
428
+ idempotencyKey: string;
429
+ }>;
430
+ };
431
+ readonly sql: {
432
+ execute: (input: SqlExecuteInput) => Promise<{
433
+ success: boolean;
434
+ meta: {
435
+ [key: string]: unknown;
436
+ };
437
+ }>;
438
+ };
439
+ readonly credentials: {
440
+ list: (environmentId: string) => Promise<{
441
+ keys: EnvironmentKey[];
442
+ }>;
443
+ create: (environmentId: string, input: {
444
+ prefix: "pk" | "sk";
445
+ name: string;
446
+ scopes?: ServerKeyScope[];
447
+ expiresAt?: string;
448
+ }) => Promise<{
449
+ key: EnvironmentKey;
450
+ token: string | null;
451
+ shownOnce: boolean;
452
+ replayed: boolean;
453
+ }>;
454
+ revoke: (environmentId: string, keyId: string) => Promise<{
455
+ id: string;
456
+ revokedAt: string;
457
+ }>;
458
+ };
459
+ readonly secrets: {
460
+ list: (environmentId: string) => Promise<{
461
+ secrets: EnvironmentSecret[];
462
+ }>;
463
+ put: (environmentId: string, name: string, value: string) => Promise<{
464
+ secret: EnvironmentSecret;
465
+ replayed: boolean;
466
+ }>;
467
+ delete: (environmentId: string, name: string) => Promise<{
468
+ name: string;
469
+ retiredAt: string;
470
+ }>;
471
+ };
472
+ readonly integrations: {
473
+ github: {
474
+ setup: (organizationId: string) => Promise<{
475
+ installUrl: string;
476
+ expiresAt: string;
477
+ replayed: boolean;
478
+ }>;
479
+ installations: (organizationId: string) => Promise<{
480
+ configured: boolean;
481
+ installations: GithubInstallation[];
482
+ }>;
483
+ repositories: (organizationId: string, installationId: string) => Promise<{
484
+ repositories: GithubRepository[];
485
+ }>;
486
+ links: (organizationId: string) => Promise<{
487
+ links: GithubLink[];
488
+ }>;
489
+ link: (input: {
490
+ organizationId: string;
491
+ projectId: string;
492
+ installationId: string;
493
+ repositoryId: string;
494
+ productionEnvironmentId?: string;
495
+ previewEnvironmentId: string;
496
+ productionBranch?: string;
497
+ framework: GithubLink["framework"];
498
+ rootDirectory?: string;
499
+ entrypoint?: string;
500
+ buildCommand?: string;
501
+ outputDirectory?: string;
502
+ lockfile?: Exclude<GithubLink["lockfile"], null>;
503
+ autoPromote?: boolean;
504
+ previewsEnabled?: boolean;
505
+ }) => Promise<{
506
+ id: string;
507
+ repository?: string;
508
+ replayed: boolean;
509
+ }>;
510
+ unlink: (linkId: string) => Promise<{
511
+ id: string;
512
+ active: false;
513
+ replayed: boolean;
514
+ }>;
515
+ };
516
+ };
517
+ readonly deployments: {
518
+ list: (environmentId: string) => Promise<Deployment[]>;
519
+ get: (deploymentId: string) => Promise<Deployment>;
520
+ create: (input: CreateDeploymentRequest) => Promise<DeploymentUploadSession>;
521
+ upload: (deploymentId: string, archive: BodyInit, input: {
522
+ artifactDigest: string;
523
+ contentLength: number;
524
+ }) => Promise<{
525
+ deploymentId: string;
526
+ status: string;
527
+ replay?: boolean;
528
+ }>;
529
+ logs: (deploymentId: string) => Promise<string>;
530
+ promote: (deploymentId: string) => Promise<{
531
+ deploymentId: string;
532
+ status: "promoted";
533
+ }>;
534
+ };
535
+ readonly deployTokens: {
536
+ create: (input: {
537
+ environmentId: string;
538
+ name: string;
539
+ expiresAt?: string;
540
+ }) => Promise<DeployTokenMutation>;
541
+ };
542
+ readonly retentionExports: {
543
+ create: (environmentId: string) => Promise<RetentionExportSession>;
544
+ get: (sessionId: string) => Promise<RetentionExportSession>;
545
+ prepareD1: (sessionId: string) => Promise<D1RetentionExportResult>;
546
+ download: (sessionId: string, component: "r2" | "kv") => Promise<Response>;
547
+ };
548
+ readonly billing: {
549
+ subscriptionCheckout: () => Promise<BillingSession>;
550
+ topupCheckout: (amountMicros: string) => Promise<BillingSession>;
551
+ portal: () => Promise<BillingSession>;
552
+ };
553
+ readonly registrar: {
554
+ quote: (domainName: string) => Promise<RegistrarQuote>;
555
+ checkout: (input: {
556
+ quoteId: string;
557
+ confirmDomainName: string;
558
+ registrant: RegistrarContact;
559
+ attestation: RegistrarAttestation;
560
+ }) => Promise<{
561
+ id: string;
562
+ url: string;
563
+ orderId: string;
564
+ replayed: boolean;
565
+ }>;
566
+ orders: () => Promise<{
567
+ configured: boolean;
568
+ mode: "disabled" | "sandbox" | "live";
569
+ orders: RegistrarOrder[];
570
+ }>;
571
+ registration: (domainName: string) => Promise<RegistrarRegistration>;
572
+ };
573
+ readonly storage: {
574
+ get: (bucket: string, key: string) => Promise<Response>;
575
+ put: (bucket: string, key: string, body: BodyInit, contentType?: string) => Promise<Response>;
576
+ delete: (bucket: string, key: string) => Promise<Response>;
577
+ signedUrl: (input: {
578
+ bucket: string;
579
+ key: string;
580
+ operation: "get" | "put";
581
+ expiresInSeconds: number;
582
+ contentLength?: number;
583
+ }) => Promise<{
584
+ url: string;
585
+ expiresAt: string;
586
+ }>;
587
+ };
588
+ readonly s3: {
589
+ list: (bucket: string, options?: IdempotentRequestOptions & {
590
+ prefix?: string;
591
+ delimiter?: string;
592
+ continuationToken?: string;
593
+ maxKeys?: number;
594
+ }) => Promise<S3ObjectList>;
595
+ get: (bucket: string, key: string, options?: IdempotentRequestOptions & {
596
+ range?: string;
597
+ }) => Promise<Response>;
598
+ head: (bucket: string, key: string, options?: IdempotentRequestOptions) => Promise<S3ObjectMetadata>;
599
+ put: (bucket: string, key: string, body: BodyInit, options?: S3BodyOptions) => Promise<{
600
+ bucket: string;
601
+ key: string;
602
+ etag: string;
603
+ }>;
604
+ delete: (bucket: string, key: string, options?: IdempotentRequestOptions) => Promise<void>;
605
+ initiateMultipart: (bucket: string, key: string, options?: IdempotentRequestOptions & {
606
+ contentType?: string;
607
+ }) => Promise<S3MultipartUpload>;
608
+ uploadPart: (bucket: string, key: string, uploadId: string, partNumber: number, body: BodyInit, options?: S3BodyOptions) => Promise<S3UploadedPart>;
609
+ completeMultipart: (bucket: string, key: string, uploadId: string, parts: ReadonlyArray<S3UploadedPart>, options?: IdempotentRequestOptions) => Promise<S3CompletedMultipartUpload>;
610
+ abortMultipart: (bucket: string, key: string, uploadId: string, options?: IdempotentRequestOptions) => Promise<void>;
611
+ };
612
+ readonly kv: {
613
+ get: <T = unknown>(key: string) => Promise<{
614
+ value: T;
615
+ consistency: "eventual";
616
+ }>;
617
+ put: (key: string, value: unknown, expirationTtl?: number) => Promise<{
618
+ success: true;
619
+ consistency: "eventual";
620
+ }>;
621
+ delete: (key: string) => Promise<void>;
622
+ };
623
+ readonly jobs: {
624
+ enqueue: (queue: string, payload: unknown, delaySeconds?: number) => Promise<{
625
+ jobId: string;
626
+ }>;
627
+ list: () => Promise<{
628
+ jobs: unknown[];
629
+ }>;
630
+ deadLetter: () => Promise<{
631
+ jobs: unknown[];
632
+ }>;
633
+ retry: (jobId: string) => Promise<{
634
+ jobId: string;
635
+ retriedFrom: string;
636
+ }>;
637
+ schedules: () => Promise<{
638
+ schedules: unknown[];
639
+ }>;
640
+ schedule: (input: {
641
+ name: string;
642
+ cron: string;
643
+ queue: string;
644
+ payload: unknown;
645
+ }) => Promise<{
646
+ id: string;
647
+ nextRunAt: string;
648
+ }>;
649
+ deleteSchedule: (scheduleId: string) => Promise<void>;
650
+ };
651
+ readonly email: {
652
+ send: (input: EmailSendRequest) => Promise<{
653
+ messageId?: string;
654
+ status: "suppressed" | "captured" | "queued";
655
+ accepted: number;
656
+ suppressed: number;
657
+ inbox?: string;
658
+ reservationIds?: string[];
659
+ }>;
660
+ developmentInbox: () => Promise<{
661
+ messages: {
662
+ [key: string]: unknown;
663
+ }[];
664
+ }>;
665
+ templates: () => Promise<{
666
+ templates: unknown[];
667
+ }>;
668
+ saveTemplate: (input: {
669
+ name: string;
670
+ subject: string;
671
+ text?: string;
672
+ html?: string;
673
+ }) => Promise<{
674
+ id: string;
675
+ name: string;
676
+ version: number;
677
+ }>;
678
+ deleteTemplate: (templateId: string) => Promise<void>;
679
+ logs: () => Promise<{
680
+ logs: unknown[];
681
+ }>;
682
+ suppressions: () => Promise<{
683
+ suppressions: unknown[];
684
+ }>;
685
+ suppress: (email: string, reason?: string) => Promise<{
686
+ addressHash: string;
687
+ suppressed: true;
688
+ }>;
689
+ unsuppress: (addressHash: string) => Promise<void>;
690
+ webhooks: () => Promise<{
691
+ endpoints: unknown[];
692
+ }>;
693
+ createWebhook: (url: string, events?: string[]) => Promise<{
694
+ id: string;
695
+ url: string;
696
+ events: string[];
697
+ secret: string;
698
+ shownOnce: true;
699
+ }>;
700
+ deleteWebhook: (endpointId: string) => Promise<void>;
701
+ };
702
+ readonly ai: {
703
+ models: () => Promise<{
704
+ models: Array<{
705
+ id: string;
706
+ name: string;
707
+ task: string;
708
+ provider: string;
709
+ pricing: Record<string, unknown>;
710
+ capabilities: Record<string, unknown>;
711
+ }>;
712
+ }>;
713
+ run: <T = unknown>(input: Omit<AiRunRequest, "gateway"> & {
714
+ gateway?: AiRunRequest["gateway"];
715
+ }) => Promise<{
716
+ output: T;
717
+ gateway?: "byok";
718
+ usage?: {
719
+ inputTokens: number;
720
+ outputTokens: number;
721
+ neurons: number;
722
+ };
723
+ reservationId: string;
724
+ }>;
725
+ connections: () => Promise<{
726
+ connections: unknown[];
727
+ }>;
728
+ connect: (input: {
729
+ provider: "openai-compatible";
730
+ name: string;
731
+ baseUrl: string;
732
+ apiKey: string;
733
+ allowedModels: string[];
734
+ }) => Promise<unknown>;
735
+ disconnect: (connectionId: string) => Promise<void>;
736
+ };
737
+ readonly analytics: {
738
+ track: (events: AnalyticsEvent[]) => Promise<{
739
+ accepted: number;
740
+ duplicates: number;
741
+ }>;
742
+ timeseries: (input?: {
743
+ from?: string;
744
+ to?: string;
745
+ interval?: "hour" | "day";
746
+ event?: string;
747
+ }) => Promise<unknown>;
748
+ users: (input?: {
749
+ from?: string;
750
+ to?: string;
751
+ }) => Promise<unknown>;
752
+ sessions: (input?: {
753
+ from?: string;
754
+ to?: string;
755
+ }) => Promise<unknown>;
756
+ export: (input: {
757
+ from: string;
758
+ to: string;
759
+ format?: "ndjson" | "csv";
760
+ }) => Promise<unknown>;
761
+ downloadExport: (exportId: string) => Promise<Response>;
762
+ funnel: (input: {
763
+ events: string[];
764
+ from: string;
765
+ to: string;
766
+ windowSeconds?: number;
767
+ }) => Promise<unknown>;
768
+ retention: (input: {
769
+ startEvent: string;
770
+ returnEvent: string;
771
+ from: string;
772
+ to: string;
773
+ }) => Promise<unknown>;
774
+ };
775
+ readonly domains: {
776
+ list: () => Promise<Domain[]>;
777
+ add: (input: {
778
+ environmentId: string;
779
+ hostname: string;
780
+ purpose: "app" | "api" | "sending";
781
+ }) => Promise<Domain>;
782
+ refresh: (domainId: string) => Promise<unknown>;
783
+ remove: (domainId: string) => Promise<void>;
784
+ };
785
+ readonly usage: {
786
+ summary: () => Promise<WalletSummary>;
787
+ timeseries: (days?: number) => Promise<{
788
+ usage: Array<{
789
+ day: string;
790
+ amountMicros: string;
791
+ }>;
792
+ }>;
793
+ activity: (limit?: number) => Promise<{
794
+ events: Array<{
795
+ id: string;
796
+ title: string;
797
+ detail: string;
798
+ at: string;
799
+ tone: string;
800
+ }>;
801
+ }>;
802
+ };
803
+ constructor(config: OneClientConfig);
804
+ from(table: string): DataQueryBuilder;
805
+ private requireOrganizationId;
806
+ executeQuery(query: QueryAst): Promise<{
807
+ rows: Array<Record<string, unknown>>;
808
+ meta: {
809
+ rowsRead: number;
810
+ usageEventId: string;
811
+ };
812
+ }>;
813
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
814
+ rawRequest(path: string, options?: RequestOptions): Promise<Response>;
815
+ }
816
+ export declare class DataQueryBuilder {
817
+ private readonly client;
818
+ private readonly query;
819
+ constructor(client: OneClient, table: string, query?: QueryAst);
820
+ select(...fields: string[]): DataQueryBuilder;
821
+ eq(field: string, value: unknown): DataQueryBuilder;
822
+ in(field: string, values: unknown[]): DataQueryBuilder;
823
+ filter(field: string, op: QueryAst["filters"][number]["op"], value?: unknown): DataQueryBuilder;
824
+ order(field: string, direction?: "asc" | "desc"): DataQueryBuilder;
825
+ limit(limit: number): DataQueryBuilder;
826
+ range(offset: number, limit: number): DataQueryBuilder;
827
+ execute(): Promise<{
828
+ rows: Array<Record<string, unknown>>;
829
+ meta: {
830
+ rowsRead: number;
831
+ usageEventId: string;
832
+ };
833
+ }>;
834
+ insert(record: Record<string, unknown>, maxStorageDeltaBytes: number): Promise<unknown>;
835
+ update(values: Record<string, unknown>, options: {
836
+ maxRows: number;
837
+ maxStorageDeltaBytes: number;
838
+ }): Promise<unknown>;
839
+ delete(maxRows: number): Promise<unknown>;
840
+ toJSON(): QueryAst;
841
+ private with;
842
+ }
843
+ export declare function createClient(config: OneClientConfig): OneClient;
844
+ export declare function createServerClient(env: OneClientRuntimeEnv, config?: Omit<OneClientConfig, "baseUrl" | "publishableKey" | "serverKey">): OneClient;
845
+ export {};
846
+ //# sourceMappingURL=index.d.ts.map