@powersync/management-client 0.0.0-dev-20260225123311

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,1295 @@
1
+ import * as sdk from '@journeyapps-labs/common-sdk';
2
+ import { routes } from '@powersync/management-types';
3
+ export declare class PowerSyncManagementClient<C extends sdk.NetworkClient = sdk.NetworkClient> extends sdk.SDKClient<C> {
4
+ /**
5
+ * Lists all PowerSync instances for a given organization and application.
6
+ *
7
+ * @returns Promise resolving to a list of instances with their IDs, names, config status, and deployability
8
+ * @example
9
+ * ```typescript
10
+ * const response = await client.listInstances({
11
+ * org_id: 'org-123',
12
+ * app_id: 'app-456'
13
+ * });
14
+ * console.log(response.instances); // Array of instance objects
15
+ * ```
16
+ */
17
+ listInstances: sdk.Endpoint<{
18
+ org_id: string;
19
+ app_id: string;
20
+ }, {
21
+ instances: {
22
+ id: string;
23
+ name: string;
24
+ has_config: boolean;
25
+ deployable: boolean;
26
+ }[];
27
+ }, C>;
28
+ /**
29
+ * Creates a new PowerSync instance.
30
+ *
31
+ * @returns Promise resolving to the created instance ID
32
+ * @example
33
+ * ```typescript
34
+ * const response = await client.createInstance({
35
+ * org_id: 'org-123',
36
+ * app_id: 'app-456',
37
+ * name: 'my-instance',
38
+ * region: 'us'
39
+ * });
40
+ * console.log(response.id); // The new instance ID
41
+ * ```
42
+ */
43
+ createInstance: sdk.Endpoint<{
44
+ org_id: string;
45
+ app_id: string;
46
+ name: string;
47
+ region?: string | undefined;
48
+ }, {
49
+ id: string;
50
+ }, C>;
51
+ /**
52
+ * Destroys a PowerSync instance. This is a permanent operation.
53
+ *
54
+ * @returns Promise resolving to the destroyed instance ID and optional operation ID
55
+ * @example
56
+ * ```typescript
57
+ * const response = await client.destroyInstance({
58
+ * org_id: 'org-123',
59
+ * app_id: 'app-456',
60
+ * id: 'instance-789'
61
+ * });
62
+ * console.log(response.id); // The destroyed instance ID
63
+ * ```
64
+ */
65
+ destroyInstance: sdk.Endpoint<{
66
+ org_id: string;
67
+ app_id: string;
68
+ id: string;
69
+ }, {
70
+ id: string;
71
+ operation_id?: string | undefined;
72
+ }, C>;
73
+ /**
74
+ * Deactivates a PowerSync instance without destroying it.
75
+ *
76
+ * @returns Promise resolving to the deactivated instance ID and optional operation ID
77
+ * @example
78
+ * ```typescript
79
+ * const response = await client.deactivateInstance({
80
+ * org_id: 'org-123',
81
+ * app_id: 'app-456',
82
+ * id: 'instance-789'
83
+ * });
84
+ * console.log(response.id); // The deactivated instance ID
85
+ * ```
86
+ */
87
+ deactivateInstance: sdk.Endpoint<{
88
+ org_id: string;
89
+ app_id: string;
90
+ id: string;
91
+ }, {
92
+ id: string;
93
+ operation_id?: string | undefined;
94
+ }, C>;
95
+ /**
96
+ * Deploys a PowerSync instance with the specified configuration.
97
+ *
98
+ * @returns Promise resolving to the instance ID and operation ID for tracking deployment
99
+ * @example
100
+ * ```typescript
101
+ * const response = await client.deployInstance({
102
+ * org_id: 'org-123',
103
+ * app_id: 'app-456',
104
+ * id: 'instance-789',
105
+ * name: 'my-instance',
106
+ * config: {
107
+ * region: 'us',
108
+ * replication: {
109
+ * connections: [/* connection config *\/]
110
+ * }
111
+ * },
112
+ * sync_rules: 'SELECT * FROM users',
113
+ * program_version: {
114
+ * channel: 'stable',
115
+ * version_range: '^1.0.0'
116
+ * }
117
+ * });
118
+ * console.log(response.operation_id); // Track deployment progress
119
+ * ```
120
+ */
121
+ deployInstance: sdk.Endpoint<{
122
+ id: string;
123
+ org_id: string;
124
+ app_id: string;
125
+ } & {
126
+ config: {
127
+ region: string;
128
+ replication?: {
129
+ connections?: (({
130
+ type: import("@powersync/management-types").ConnectionType;
131
+ name?: string | undefined;
132
+ id?: string | undefined;
133
+ tag?: string | undefined;
134
+ username?: string | undefined;
135
+ password?: {
136
+ secret: string;
137
+ } | {
138
+ secret_ref: string;
139
+ } | undefined;
140
+ database?: string | undefined;
141
+ } & {
142
+ type: import("@powersync/management-types").ConnectionType.MONGODB;
143
+ uri: string;
144
+ post_images?: "off" | "auto_configure" | "read_only" | undefined;
145
+ vpc_endpoint_hostname?: string | undefined;
146
+ }) | ({
147
+ type: import("@powersync/management-types").ConnectionType;
148
+ name?: string | undefined;
149
+ id?: string | undefined;
150
+ tag?: string | undefined;
151
+ username?: string | undefined;
152
+ password?: {
153
+ secret: string;
154
+ } | {
155
+ secret_ref: string;
156
+ } | undefined;
157
+ database?: string | undefined;
158
+ } & {
159
+ type: import("@powersync/management-types").ConnectionType.MSSQL;
160
+ uri?: string | undefined;
161
+ hostname?: string | undefined;
162
+ port?: number | undefined;
163
+ schema?: string | undefined;
164
+ authentication?: ({
165
+ type: "default";
166
+ options: {
167
+ password: string;
168
+ userName: string;
169
+ };
170
+ } & {
171
+ options: {
172
+ password: {
173
+ secret: string;
174
+ } | {
175
+ secret_ref: string;
176
+ };
177
+ };
178
+ }) | ({
179
+ type: "azure-active-directory-password";
180
+ options: {
181
+ password: string;
182
+ userName: string;
183
+ clientId: string;
184
+ tenantId: string;
185
+ };
186
+ } & {
187
+ options: {
188
+ password: {
189
+ secret: string;
190
+ } | {
191
+ secret_ref: string;
192
+ };
193
+ };
194
+ }) | ({
195
+ type: "azure-active-directory-service-principal-secret";
196
+ options: {
197
+ clientId: string;
198
+ tenantId: string;
199
+ clientSecret: string;
200
+ };
201
+ } & {
202
+ options: {
203
+ clientSecret: {
204
+ secret: string;
205
+ } | {
206
+ secret_ref: string;
207
+ };
208
+ };
209
+ }) | undefined;
210
+ additionalConfig?: {
211
+ pollingIntervalMs?: number | undefined;
212
+ pollingBatchSize?: number | undefined;
213
+ trustServerCertificate?: boolean | undefined;
214
+ } | undefined;
215
+ debug_api?: boolean | undefined;
216
+ }) | ({
217
+ type: import("@powersync/management-types").ConnectionType;
218
+ name?: string | undefined;
219
+ id?: string | undefined;
220
+ tag?: string | undefined;
221
+ username?: string | undefined;
222
+ password?: {
223
+ secret: string;
224
+ } | {
225
+ secret_ref: string;
226
+ } | undefined;
227
+ database?: string | undefined;
228
+ } & {
229
+ type: import("@powersync/management-types").ConnectionType.MYSQL;
230
+ uri?: string | undefined;
231
+ hostname?: string | undefined;
232
+ port?: number | undefined;
233
+ debug_api?: boolean | undefined;
234
+ client_certificate?: string | undefined;
235
+ client_private_key?: {
236
+ secret: string;
237
+ } | {
238
+ secret_ref: string;
239
+ } | undefined;
240
+ }) | ({
241
+ type: import("@powersync/management-types").ConnectionType;
242
+ name?: string | undefined;
243
+ id?: string | undefined;
244
+ tag?: string | undefined;
245
+ username?: string | undefined;
246
+ password?: {
247
+ secret: string;
248
+ } | {
249
+ secret_ref: string;
250
+ } | undefined;
251
+ database?: string | undefined;
252
+ } & {
253
+ type: import("@powersync/management-types").ConnectionType.POSTGRES;
254
+ uri?: string | undefined;
255
+ vpc_endpoint_hostname?: string | undefined;
256
+ hostname?: string | undefined;
257
+ port?: number | undefined;
258
+ debug_api?: boolean | undefined;
259
+ client_certificate?: string | undefined;
260
+ client_private_key?: {
261
+ secret: string;
262
+ } | {
263
+ secret_ref: string;
264
+ } | undefined;
265
+ sslmode?: "verify-full" | "verify-ca" | undefined;
266
+ cacert?: string | undefined;
267
+ }))[] | undefined;
268
+ } | undefined;
269
+ client_auth?: {
270
+ jwks_uri?: string | undefined;
271
+ jwks?: {
272
+ keys: ({
273
+ kty: "oct";
274
+ kid: string;
275
+ k: {
276
+ secret: string;
277
+ } | {
278
+ secret_ref: string;
279
+ };
280
+ alg: "HS256" | "HS384" | "HS512";
281
+ use?: string | undefined;
282
+ } | {
283
+ kty: "RSA";
284
+ kid: string;
285
+ n: string;
286
+ e: string;
287
+ alg?: "RS256" | "RS384" | "RS512" | undefined;
288
+ use?: string | undefined;
289
+ } | {
290
+ kty: "OKP";
291
+ alg: "EdDSA";
292
+ crv: "Ed25519" | "Ed448";
293
+ x: string;
294
+ kid?: string | undefined;
295
+ use?: string | undefined;
296
+ } | {
297
+ kty: "EC";
298
+ alg: "ES256" | "ES384" | "ES512";
299
+ crv: "P-256" | "P-384" | "P-512";
300
+ x: string;
301
+ y: string;
302
+ kid?: string | undefined;
303
+ use?: string | undefined;
304
+ })[];
305
+ } | undefined;
306
+ supabase?: boolean | undefined;
307
+ supabase_jwt_secret?: {
308
+ secret: string;
309
+ } | {
310
+ secret_ref: string;
311
+ } | undefined;
312
+ additional_audiences?: string[] | undefined;
313
+ allow_temporary_tokens?: boolean | undefined;
314
+ } | undefined;
315
+ };
316
+ name?: string | undefined;
317
+ sync_rules?: string | undefined;
318
+ program_version?: {
319
+ channel: string;
320
+ version_range?: string | undefined;
321
+ } | undefined;
322
+ }, {
323
+ id: string;
324
+ operation_id: string;
325
+ }, C>;
326
+ /**
327
+ * Retrieves the configuration for a PowerSync instance.
328
+ * This endpoint is retryable.
329
+ *
330
+ * @returns Promise resolving to the instance configuration including config, sync_rules, and program_version
331
+ * @example
332
+ * ```typescript
333
+ * const response = await client.getInstanceConfig({
334
+ * org_id: 'org-123',
335
+ * app_id: 'app-456',
336
+ * id: 'instance-789'
337
+ * });
338
+ * console.log(response.config); // The instance configuration
339
+ * console.log(response.sync_rules); // The sync rules
340
+ * ```
341
+ */
342
+ getInstanceConfig: sdk.Endpoint<{
343
+ org_id: string;
344
+ app_id: string;
345
+ id: string;
346
+ }, {
347
+ org_id: string;
348
+ id: string;
349
+ name: string;
350
+ program_version: {
351
+ channel: string;
352
+ version_range?: string | undefined;
353
+ };
354
+ project_id: string;
355
+ config?: {
356
+ region: string;
357
+ replication?: {
358
+ connections?: (({
359
+ type: import("@powersync/management-types").ConnectionType;
360
+ name?: string | undefined;
361
+ id?: string | undefined;
362
+ tag?: string | undefined;
363
+ username?: string | undefined;
364
+ password?: {
365
+ secret: string;
366
+ } | {
367
+ secret_ref: string;
368
+ } | undefined;
369
+ database?: string | undefined;
370
+ } & {
371
+ type: import("@powersync/management-types").ConnectionType.MONGODB;
372
+ uri: string;
373
+ post_images?: "off" | "auto_configure" | "read_only" | undefined;
374
+ vpc_endpoint_hostname?: string | undefined;
375
+ }) | ({
376
+ type: import("@powersync/management-types").ConnectionType;
377
+ name?: string | undefined;
378
+ id?: string | undefined;
379
+ tag?: string | undefined;
380
+ username?: string | undefined;
381
+ password?: {
382
+ secret: string;
383
+ } | {
384
+ secret_ref: string;
385
+ } | undefined;
386
+ database?: string | undefined;
387
+ } & {
388
+ type: import("@powersync/management-types").ConnectionType.MSSQL;
389
+ uri?: string | undefined;
390
+ hostname?: string | undefined;
391
+ port?: number | undefined;
392
+ schema?: string | undefined;
393
+ authentication?: ({
394
+ type: "default";
395
+ options: {
396
+ password: string;
397
+ userName: string;
398
+ };
399
+ } & {
400
+ options: {
401
+ password: {
402
+ secret: string;
403
+ } | {
404
+ secret_ref: string;
405
+ };
406
+ };
407
+ }) | ({
408
+ type: "azure-active-directory-password";
409
+ options: {
410
+ password: string;
411
+ userName: string;
412
+ clientId: string;
413
+ tenantId: string;
414
+ };
415
+ } & {
416
+ options: {
417
+ password: {
418
+ secret: string;
419
+ } | {
420
+ secret_ref: string;
421
+ };
422
+ };
423
+ }) | ({
424
+ type: "azure-active-directory-service-principal-secret";
425
+ options: {
426
+ clientId: string;
427
+ tenantId: string;
428
+ clientSecret: string;
429
+ };
430
+ } & {
431
+ options: {
432
+ clientSecret: {
433
+ secret: string;
434
+ } | {
435
+ secret_ref: string;
436
+ };
437
+ };
438
+ }) | undefined;
439
+ additionalConfig?: {
440
+ pollingIntervalMs?: number | undefined;
441
+ pollingBatchSize?: number | undefined;
442
+ trustServerCertificate?: boolean | undefined;
443
+ } | undefined;
444
+ debug_api?: boolean | undefined;
445
+ }) | ({
446
+ type: import("@powersync/management-types").ConnectionType;
447
+ name?: string | undefined;
448
+ id?: string | undefined;
449
+ tag?: string | undefined;
450
+ username?: string | undefined;
451
+ password?: {
452
+ secret: string;
453
+ } | {
454
+ secret_ref: string;
455
+ } | undefined;
456
+ database?: string | undefined;
457
+ } & {
458
+ type: import("@powersync/management-types").ConnectionType.MYSQL;
459
+ uri?: string | undefined;
460
+ hostname?: string | undefined;
461
+ port?: number | undefined;
462
+ debug_api?: boolean | undefined;
463
+ client_certificate?: string | undefined;
464
+ client_private_key?: {
465
+ secret: string;
466
+ } | {
467
+ secret_ref: string;
468
+ } | undefined;
469
+ }) | ({
470
+ type: import("@powersync/management-types").ConnectionType;
471
+ name?: string | undefined;
472
+ id?: string | undefined;
473
+ tag?: string | undefined;
474
+ username?: string | undefined;
475
+ password?: {
476
+ secret: string;
477
+ } | {
478
+ secret_ref: string;
479
+ } | undefined;
480
+ database?: string | undefined;
481
+ } & {
482
+ type: import("@powersync/management-types").ConnectionType.POSTGRES;
483
+ uri?: string | undefined;
484
+ vpc_endpoint_hostname?: string | undefined;
485
+ hostname?: string | undefined;
486
+ port?: number | undefined;
487
+ debug_api?: boolean | undefined;
488
+ client_certificate?: string | undefined;
489
+ client_private_key?: {
490
+ secret: string;
491
+ } | {
492
+ secret_ref: string;
493
+ } | undefined;
494
+ sslmode?: "verify-full" | "verify-ca" | undefined;
495
+ cacert?: string | undefined;
496
+ }))[] | undefined;
497
+ } | undefined;
498
+ client_auth?: {
499
+ jwks_uri?: string | undefined;
500
+ jwks?: {
501
+ keys: ({
502
+ kty: "oct";
503
+ kid: string;
504
+ k: {
505
+ secret: string;
506
+ } | {
507
+ secret_ref: string;
508
+ };
509
+ alg: "HS256" | "HS384" | "HS512";
510
+ use?: string | undefined;
511
+ } | {
512
+ kty: "RSA";
513
+ kid: string;
514
+ n: string;
515
+ e: string;
516
+ alg?: "RS256" | "RS384" | "RS512" | undefined;
517
+ use?: string | undefined;
518
+ } | {
519
+ kty: "OKP";
520
+ alg: "EdDSA";
521
+ crv: "Ed25519" | "Ed448";
522
+ x: string;
523
+ kid?: string | undefined;
524
+ use?: string | undefined;
525
+ } | {
526
+ kty: "EC";
527
+ alg: "ES256" | "ES384" | "ES512";
528
+ crv: "P-256" | "P-384" | "P-512";
529
+ x: string;
530
+ y: string;
531
+ kid?: string | undefined;
532
+ use?: string | undefined;
533
+ })[];
534
+ } | undefined;
535
+ supabase?: boolean | undefined;
536
+ supabase_jwt_secret?: {
537
+ secret: string;
538
+ } | {
539
+ secret_ref: string;
540
+ } | undefined;
541
+ additional_audiences?: string[] | undefined;
542
+ allow_temporary_tokens?: boolean | undefined;
543
+ } | undefined;
544
+ } | undefined;
545
+ sync_rules?: string | undefined;
546
+ }, C>;
547
+ /**
548
+ * Gets the provisioning status and deployment operations for a PowerSync instance.
549
+ * This endpoint is retryable.
550
+ *
551
+ * @returns Promise resolving to instance status including provisioned flag, operations array, and optional instance_url
552
+ * @example
553
+ * ```typescript
554
+ * const response = await client.getInstanceStatus({
555
+ * org_id: 'org-123',
556
+ * app_id: 'app-456',
557
+ * id: 'instance-789'
558
+ * });
559
+ * console.log(response.provisioned); // true if instance is provisioned
560
+ * console.log(response.operations); // Array of deployment operations
561
+ * ```
562
+ */
563
+ getInstanceStatus: sdk.Endpoint<{
564
+ org_id: string;
565
+ app_id: string;
566
+ id: string;
567
+ }, {
568
+ id: string;
569
+ provisioned: boolean;
570
+ operations: {
571
+ id: string;
572
+ type: "up" | "down";
573
+ status: "pending" | "running" | "failed" | "completed";
574
+ created_at: string;
575
+ version: string;
576
+ started_at?: string | undefined;
577
+ finished_at?: string | undefined;
578
+ system_upgrade?: boolean | undefined;
579
+ teardown?: boolean | undefined;
580
+ compact?: boolean | undefined;
581
+ user_id?: string | undefined;
582
+ }[];
583
+ instance_url?: string | undefined;
584
+ }, C>;
585
+ /**
586
+ * Gets diagnostic information for a PowerSync instance.
587
+ * Only works if the instance is already provisioned.
588
+ * This endpoint is retryable.
589
+ *
590
+ * @returns Promise resolving to diagnostic information
591
+ * @example
592
+ * ```typescript
593
+ * const response = await client.getInstanceDiagnostics({
594
+ * org_id: 'org-123',
595
+ * app_id: 'app-456',
596
+ * id: 'instance-789'
597
+ * });
598
+ * // Diagnostic information about the instance
599
+ * ```
600
+ */
601
+ getInstanceDiagnostics: sdk.Endpoint<{
602
+ id: string;
603
+ org_id: string;
604
+ app_id: string;
605
+ } & {
606
+ sync_rules_content?: boolean | undefined;
607
+ }, {
608
+ connections: {
609
+ id: string;
610
+ postgres_uri: string;
611
+ connected: boolean;
612
+ errors: {
613
+ level: "warning" | "fatal";
614
+ message: string;
615
+ ts?: string | undefined;
616
+ }[];
617
+ }[];
618
+ active_sync_rules?: {
619
+ errors: {
620
+ level: "warning" | "fatal";
621
+ message: string;
622
+ ts?: string | undefined;
623
+ }[];
624
+ connections: {
625
+ id: string;
626
+ tag: string;
627
+ slot_name: string;
628
+ initial_replication_done: boolean;
629
+ tables: {
630
+ schema: string;
631
+ name: string;
632
+ replication_id: string[];
633
+ data_queries: boolean;
634
+ parameter_queries: boolean;
635
+ errors: {
636
+ level: "warning" | "fatal";
637
+ message: string;
638
+ ts?: string | undefined;
639
+ }[];
640
+ pattern?: string | undefined;
641
+ }[];
642
+ last_lsn?: string | undefined;
643
+ last_keepalive_ts?: string | undefined;
644
+ last_checkpoint_ts?: string | undefined;
645
+ replication_lag_bytes?: number | undefined;
646
+ }[];
647
+ content?: string | undefined;
648
+ } | undefined;
649
+ deploying_sync_rules?: {
650
+ errors: {
651
+ level: "warning" | "fatal";
652
+ message: string;
653
+ ts?: string | undefined;
654
+ }[];
655
+ connections: {
656
+ id: string;
657
+ tag: string;
658
+ slot_name: string;
659
+ initial_replication_done: boolean;
660
+ tables: {
661
+ schema: string;
662
+ name: string;
663
+ replication_id: string[];
664
+ data_queries: boolean;
665
+ parameter_queries: boolean;
666
+ errors: {
667
+ level: "warning" | "fatal";
668
+ message: string;
669
+ ts?: string | undefined;
670
+ }[];
671
+ pattern?: string | undefined;
672
+ }[];
673
+ last_lsn?: string | undefined;
674
+ last_keepalive_ts?: string | undefined;
675
+ last_checkpoint_ts?: string | undefined;
676
+ replication_lag_bytes?: number | undefined;
677
+ }[];
678
+ content?: string | undefined;
679
+ } | undefined;
680
+ }, C>;
681
+ /**
682
+ * Triggers a compaction operation on a PowerSync instance.
683
+ *
684
+ * @returns Promise resolving to the instance ID and optional operation ID
685
+ * @example
686
+ * ```typescript
687
+ * const response = await client.compact({
688
+ * org_id: 'org-123',
689
+ * app_id: 'app-456',
690
+ * id: 'instance-789'
691
+ * });
692
+ * console.log(response.operation_id); // Track compaction progress
693
+ * ```
694
+ */
695
+ compact: sdk.Endpoint<{
696
+ org_id: string;
697
+ app_id: string;
698
+ id: string;
699
+ }, {
700
+ id: string;
701
+ operation_id?: string | undefined;
702
+ }, C>;
703
+ /**
704
+ * Tests a database connection without deploying an instance.
705
+ * Validates connectivity and configuration for the specified connection.
706
+ *
707
+ * @returns Promise resolving to connection test results including success status, connection details, and optional configuration details
708
+ * @example
709
+ * ```typescript
710
+ * const response = await client.testConnection({
711
+ * org_id: 'org-123',
712
+ * app_id: 'app-456',
713
+ * connection: {
714
+ * type: 'postgres',
715
+ * uri: 'postgresql://user:pass@host:5432/db'
716
+ * }
717
+ * });
718
+ * console.log(response.success); // true if connection test passed
719
+ * console.log(response.connection.reachable); // true if TCP connection works
720
+ * ```
721
+ */
722
+ testConnection: sdk.Endpoint<{
723
+ org_id: string;
724
+ app_id: string;
725
+ connection: ({
726
+ type: import("@powersync/management-types").ConnectionType;
727
+ name?: string | undefined;
728
+ id?: string | undefined;
729
+ tag?: string | undefined;
730
+ username?: string | undefined;
731
+ password?: {
732
+ secret: string;
733
+ } | {
734
+ secret_ref: string;
735
+ } | undefined;
736
+ database?: string | undefined;
737
+ } & {
738
+ type: import("@powersync/management-types").ConnectionType.MONGODB;
739
+ uri: string;
740
+ post_images?: "off" | "auto_configure" | "read_only" | undefined;
741
+ vpc_endpoint_hostname?: string | undefined;
742
+ }) | ({
743
+ type: import("@powersync/management-types").ConnectionType;
744
+ name?: string | undefined;
745
+ id?: string | undefined;
746
+ tag?: string | undefined;
747
+ username?: string | undefined;
748
+ password?: {
749
+ secret: string;
750
+ } | {
751
+ secret_ref: string;
752
+ } | undefined;
753
+ database?: string | undefined;
754
+ } & {
755
+ type: import("@powersync/management-types").ConnectionType.MYSQL;
756
+ uri?: string | undefined;
757
+ hostname?: string | undefined;
758
+ port?: number | undefined;
759
+ debug_api?: boolean | undefined;
760
+ client_certificate?: string | undefined;
761
+ client_private_key?: {
762
+ secret: string;
763
+ } | {
764
+ secret_ref: string;
765
+ } | undefined;
766
+ }) | ({
767
+ type: import("@powersync/management-types").ConnectionType;
768
+ name?: string | undefined;
769
+ id?: string | undefined;
770
+ tag?: string | undefined;
771
+ username?: string | undefined;
772
+ password?: {
773
+ secret: string;
774
+ } | {
775
+ secret_ref: string;
776
+ } | undefined;
777
+ database?: string | undefined;
778
+ } & {
779
+ type: import("@powersync/management-types").ConnectionType.POSTGRES;
780
+ uri?: string | undefined;
781
+ vpc_endpoint_hostname?: string | undefined;
782
+ hostname?: string | undefined;
783
+ port?: number | undefined;
784
+ debug_api?: boolean | undefined;
785
+ client_certificate?: string | undefined;
786
+ client_private_key?: {
787
+ secret: string;
788
+ } | {
789
+ secret_ref: string;
790
+ } | undefined;
791
+ sslmode?: "verify-full" | "verify-ca" | undefined;
792
+ cacert?: string | undefined;
793
+ }) | ({
794
+ type: import("@powersync/management-types").ConnectionType;
795
+ name?: string | undefined;
796
+ id?: string | undefined;
797
+ tag?: string | undefined;
798
+ username?: string | undefined;
799
+ password?: {
800
+ secret: string;
801
+ } | {
802
+ secret_ref: string;
803
+ } | undefined;
804
+ database?: string | undefined;
805
+ } & {
806
+ type: import("@powersync/management-types").ConnectionType.MSSQL;
807
+ uri?: string | undefined;
808
+ hostname?: string | undefined;
809
+ port?: number | undefined;
810
+ schema?: string | undefined;
811
+ authentication?: ({
812
+ type: "default";
813
+ options: {
814
+ password: string;
815
+ userName: string;
816
+ };
817
+ } & {
818
+ options: {
819
+ password: {
820
+ secret: string;
821
+ } | {
822
+ secret_ref: string;
823
+ };
824
+ };
825
+ }) | ({
826
+ type: "azure-active-directory-password";
827
+ options: {
828
+ password: string;
829
+ userName: string;
830
+ clientId: string;
831
+ tenantId: string;
832
+ };
833
+ } & {
834
+ options: {
835
+ password: {
836
+ secret: string;
837
+ } | {
838
+ secret_ref: string;
839
+ };
840
+ };
841
+ }) | ({
842
+ type: "azure-active-directory-service-principal-secret";
843
+ options: {
844
+ clientId: string;
845
+ tenantId: string;
846
+ clientSecret: string;
847
+ };
848
+ } & {
849
+ options: {
850
+ clientSecret: {
851
+ secret: string;
852
+ } | {
853
+ secret_ref: string;
854
+ };
855
+ };
856
+ }) | undefined;
857
+ additionalConfig?: {
858
+ pollingIntervalMs?: number | undefined;
859
+ pollingBatchSize?: number | undefined;
860
+ trustServerCertificate?: boolean | undefined;
861
+ } | undefined;
862
+ debug_api?: boolean | undefined;
863
+ });
864
+ id?: string | undefined;
865
+ }, {
866
+ connection: {
867
+ success: boolean;
868
+ reachable: boolean;
869
+ };
870
+ success: boolean;
871
+ configuration?: {
872
+ success: boolean;
873
+ } | undefined;
874
+ error?: string | undefined;
875
+ } | ({
876
+ connection: {
877
+ success: boolean;
878
+ reachable: boolean;
879
+ };
880
+ success: boolean;
881
+ configuration?: {
882
+ success: boolean;
883
+ } | undefined;
884
+ error?: string | undefined;
885
+ } & {
886
+ connection: {
887
+ success: boolean;
888
+ reachable: boolean;
889
+ } & {
890
+ tls_valid?: boolean | undefined;
891
+ suggested_cacert?: string | undefined;
892
+ suggested_sslmode?: string | undefined;
893
+ authenticated?: boolean | undefined;
894
+ };
895
+ configuration?: ({
896
+ success: boolean;
897
+ } & {
898
+ wal_valid?: boolean | undefined;
899
+ publication_valid?: boolean | undefined;
900
+ }) | undefined;
901
+ }), C>;
902
+ /**
903
+ * Gets the database schema for a PowerSync instance.
904
+ * Only works if the instance is already provisioned.
905
+ * This endpoint is retryable.
906
+ *
907
+ * @returns Promise resolving to the instance schema including connections, tables, and columns
908
+ * @example
909
+ * ```typescript
910
+ * const response = await client.getInstanceSchema({
911
+ * org_id: 'org-123',
912
+ * app_id: 'app-456',
913
+ * id: 'instance-789'
914
+ * });
915
+ * console.log(response.connections); // Array of connection schemas
916
+ * ```
917
+ */
918
+ getInstanceSchema: sdk.Endpoint<{
919
+ org_id: string;
920
+ app_id: string;
921
+ id: string;
922
+ }, {
923
+ connections: {
924
+ tag: string;
925
+ schemas: {
926
+ name: string;
927
+ tables: {
928
+ name: string;
929
+ columns: {
930
+ name: string;
931
+ type: string;
932
+ pg_type: string;
933
+ sqlite_type?: number | routes.SqliteSchemaTypeText | undefined;
934
+ internal_type?: string | undefined;
935
+ description?: string | undefined;
936
+ }[];
937
+ }[];
938
+ }[];
939
+ id?: string | undefined;
940
+ }[];
941
+ defaultConnectionTag?: string | undefined;
942
+ defaultSchema?: string | undefined;
943
+ }, C>;
944
+ /**
945
+ * Executes SQL queries on a PowerSync instance.
946
+ * Only works if the instance is already provisioned.
947
+ *
948
+ * @returns Promise resolving to SQL execution results
949
+ * @example
950
+ * ```typescript
951
+ * const response = await client.executeSql({
952
+ * org_id: 'org-123',
953
+ * app_id: 'app-456',
954
+ * id: 'instance-789',
955
+ * sql: 'SELECT * FROM users WHERE id = ?',
956
+ * parameters: ['user-123']
957
+ * });
958
+ * // SQL query results
959
+ * ```
960
+ */
961
+ executeSql: sdk.Endpoint<{
962
+ id: string;
963
+ org_id: string;
964
+ app_id: string;
965
+ } & {
966
+ sql: {
967
+ query: string;
968
+ args: (string | number | boolean)[];
969
+ };
970
+ connection_id?: string | undefined;
971
+ }, {
972
+ success: boolean;
973
+ results: {
974
+ columns: string[];
975
+ rows: (string | number | boolean | null)[][];
976
+ };
977
+ error?: string | undefined;
978
+ }, C>;
979
+ /**
980
+ * Validates sync rules for a PowerSync instance.
981
+ * Only works if the instance is already provisioned.
982
+ *
983
+ * @returns Promise resolving to validation results
984
+ * @example
985
+ * ```typescript
986
+ * const response = await client.validateSyncRules({
987
+ * org_id: 'org-123',
988
+ * app_id: 'app-456',
989
+ * id: 'instance-789',
990
+ * sync_rules: 'SELECT * FROM users'
991
+ * });
992
+ * // Validation results
993
+ * ```
994
+ */
995
+ validateSyncRules: sdk.Endpoint<{
996
+ id: string;
997
+ org_id: string;
998
+ app_id: string;
999
+ } & {
1000
+ sync_rules: string;
1001
+ }, {
1002
+ connections: {
1003
+ id: string;
1004
+ tag: string;
1005
+ tables: {
1006
+ name: string;
1007
+ errors: {
1008
+ level: "warning" | "fatal";
1009
+ message: string;
1010
+ ts?: string | undefined;
1011
+ }[];
1012
+ schema: string;
1013
+ replication_id: string[];
1014
+ data_queries: boolean;
1015
+ parameter_queries: boolean;
1016
+ pattern?: string | undefined;
1017
+ }[];
1018
+ slot_name: string;
1019
+ initial_replication_done: boolean;
1020
+ last_lsn?: string | undefined;
1021
+ last_keepalive_ts?: string | undefined;
1022
+ last_checkpoint_ts?: string | undefined;
1023
+ replication_lag_bytes?: number | undefined;
1024
+ }[];
1025
+ errors: {
1026
+ level: "warning" | "fatal";
1027
+ message: string;
1028
+ ts?: string | undefined;
1029
+ }[];
1030
+ content?: string | undefined;
1031
+ }, C>;
1032
+ /**
1033
+ * Reprocesses sync rules for a PowerSync instance.
1034
+ * Only works if the instance is already provisioned.
1035
+ *
1036
+ * @returns Promise resolving to reprocessing results
1037
+ * @example
1038
+ * ```typescript
1039
+ * const response = await client.reprocessSyncRules({
1040
+ * org_id: 'org-123',
1041
+ * app_id: 'app-456',
1042
+ * id: 'instance-789',
1043
+ * sync_rules: 'SELECT * FROM users'
1044
+ * });
1045
+ * // Reprocessing results
1046
+ * ```
1047
+ */
1048
+ reprocessSyncRules: sdk.Endpoint<{
1049
+ id: string;
1050
+ org_id: string;
1051
+ app_id: string;
1052
+ } & {}, {
1053
+ connections: {
1054
+ tag: string;
1055
+ slot_name: string;
1056
+ id?: string | undefined;
1057
+ }[];
1058
+ }, C>;
1059
+ /**
1060
+ * Generates a development token for a PowerSync instance.
1061
+ *
1062
+ * @returns Promise resolving to the generated JWT token
1063
+ * @example
1064
+ * ```typescript
1065
+ * const response = await client.generateDevToken({
1066
+ * org_id: 'org-123',
1067
+ * app_id: 'app-456',
1068
+ * id: 'instance-789',
1069
+ * subject: 'user-123',
1070
+ * expiresInSeconds: 3600
1071
+ * });
1072
+ * console.log(response.token); // The JWT token
1073
+ * ```
1074
+ */
1075
+ generateDevToken: sdk.Endpoint<{
1076
+ id: string;
1077
+ org_id: string;
1078
+ app_id: string;
1079
+ } & {
1080
+ subject: string;
1081
+ expiresInSeconds: number;
1082
+ }, {
1083
+ token: string;
1084
+ }, C>;
1085
+ /**
1086
+ * Generates a dashboard token used for connecting to the Dashboard's dedicated PowerSync Service
1087
+ *
1088
+ * @returns Promise resolving to the generated dashboard JWT token
1089
+ * @example
1090
+ * ```typescript
1091
+ * const response = await client.generateDashboardToken({
1092
+ * org_id: 'org-123'
1093
+ * });
1094
+ * console.log(response.token); // The dashboard JWT token
1095
+ * ```
1096
+ */
1097
+ generateDashboardToken: sdk.Endpoint<{
1098
+ org_id: string;
1099
+ }, {
1100
+ token: string;
1101
+ }, C>;
1102
+ /**
1103
+ * Lists available regions for PowerSync deployments.
1104
+ * Returns region information including IP addresses for whitelisting.
1105
+ *
1106
+ * @returns Promise resolving to a list of regions with their names, deployability status, and IP addresses
1107
+ * @example
1108
+ * ```typescript
1109
+ * const response = await client.listRegions({});
1110
+ * console.log(response.regions); // Array of region objects with IPs for whitelisting
1111
+ * ```
1112
+ */
1113
+ listRegions: sdk.Endpoint<void, {
1114
+ regions: {
1115
+ name: string;
1116
+ deployable: boolean;
1117
+ ips: string[];
1118
+ }[];
1119
+ }, C>;
1120
+ /**
1121
+ * Lists available PowerSync program versions for a channel.
1122
+ *
1123
+ * @returns Promise resolving to an array of versions with their status (current, available, or deprecated)
1124
+ * @example
1125
+ * ```typescript
1126
+ * const response = await client.listVersionsV({
1127
+ * channel: 'stable'
1128
+ * });
1129
+ * console.log(response); // Array of version objects with status
1130
+ * ```
1131
+ */
1132
+ listVersions: sdk.Endpoint<{
1133
+ channel: string;
1134
+ }, {
1135
+ status: routes.VersionStatus;
1136
+ version: string;
1137
+ }[], C>;
1138
+ /**
1139
+ * Gets client connection reports for a PowerSync instance within a date range.
1140
+ *
1141
+ * @returns Promise resolving to connection report data including user counts and SDK breakdowns
1142
+ * @example
1143
+ * ```typescript
1144
+ * const response = await client.getClientConnectionReports({
1145
+ * org_id: 'org-123',
1146
+ * app_id: 'app-456',
1147
+ * id: 'instance-789',
1148
+ * start: '2024-01-01T00:00:00Z',
1149
+ * end: '2024-01-31T23:59:59Z'
1150
+ * });
1151
+ * console.log(response.users); // Total number of users
1152
+ * console.log(response.sdks); // Array of SDK connection reports
1153
+ * ```
1154
+ */
1155
+ getClientConnectionReports: sdk.Endpoint<{
1156
+ start: string;
1157
+ end: string;
1158
+ scrape_ttl?: {
1159
+ date: string;
1160
+ } | undefined;
1161
+ } & {
1162
+ org_id: string;
1163
+ app_id: string;
1164
+ id: string;
1165
+ }, {
1166
+ users: number;
1167
+ sdks: {
1168
+ users: number;
1169
+ sdk: string;
1170
+ clients: number;
1171
+ }[];
1172
+ }, C>;
1173
+ /**
1174
+ * Gets currently connected clients for a PowerSync instance.
1175
+ *
1176
+ * @returns Promise resolving to current connection data including user counts and SDK breakdowns
1177
+ * @example
1178
+ * ```typescript
1179
+ * const response = await client.getConnectedClients({
1180
+ * org_id: 'org-123',
1181
+ * app_id: 'app-456',
1182
+ * id: 'instance-789'
1183
+ * });
1184
+ * console.log(response.users); // Number of currently connected users
1185
+ * console.log(response.sdks); // Array of current SDK connections
1186
+ * ```
1187
+ */
1188
+ getConnectedClients: sdk.Endpoint<{
1189
+ org_id: string;
1190
+ app_id: string;
1191
+ id: string;
1192
+ }, {
1193
+ users: number;
1194
+ sdks: {
1195
+ users: number;
1196
+ sdk: string;
1197
+ clients: number;
1198
+ }[];
1199
+ }, C>;
1200
+ /**
1201
+ * Gets paginated general client connection analytics for a PowerSync instance.
1202
+ * Returns connection events including connect/disconnect times, user agents, and SDK information.
1203
+ *
1204
+ * @returns Promise resolving to paginated connection analytics events. Also includes a `paginate` method for iterating through all pages.
1205
+ * @example
1206
+ * ```typescript
1207
+ * // Single page request
1208
+ * const response = await client.getGeneralClientConnectionAnalytics({
1209
+ * org_id: 'org-123',
1210
+ * app_id: 'app-456',
1211
+ * id: 'instance-789',
1212
+ * date_range: {
1213
+ * start: '2024-01-01T00:00:00Z',
1214
+ * end: '2024-01-31T23:59:59Z'
1215
+ * },
1216
+ * limit: 100
1217
+ * });
1218
+ * console.log(response.items); // Array of connection events
1219
+ * console.log(response.total); // Total number of events
1220
+ * console.log(response.more); // true if there are more pages
1221
+ * console.log(response.cursor); // cursor for the next page
1222
+ *
1223
+ * // Iterate through all pages
1224
+ * for await (const page of client.getGeneralClientConnectionAnalytics.paginate({
1225
+ * org_id: 'org-123',
1226
+ * app_id: 'app-456',
1227
+ * id: 'instance-789',
1228
+ * date_range: {
1229
+ * start: '2024-01-01T00:00:00Z',
1230
+ * end: '2024-01-31T23:59:59Z'
1231
+ * },
1232
+ * limit: 100
1233
+ * })) {
1234
+ * console.log(page.items); // Process each page
1235
+ * }
1236
+ * ```
1237
+ */
1238
+ getGeneralClientConnectionAnalytics: ((params: {
1239
+ id: string;
1240
+ org_id: string;
1241
+ app_id: string;
1242
+ user_id?: string | undefined;
1243
+ client_id?: string | undefined;
1244
+ date_range?: {
1245
+ start: string;
1246
+ end: string;
1247
+ } | undefined;
1248
+ } & {
1249
+ cursor?: string | undefined;
1250
+ limit?: number | undefined;
1251
+ }) => Promise<{
1252
+ total: number;
1253
+ count: number;
1254
+ more: boolean;
1255
+ items: {
1256
+ user_id: string;
1257
+ sdk: string;
1258
+ client_id: string;
1259
+ connected_at: string;
1260
+ user_agent: string;
1261
+ disconnected_at?: string | undefined;
1262
+ jwt_exp?: string | undefined;
1263
+ }[];
1264
+ cursor?: string | undefined;
1265
+ }>) & {
1266
+ paginate: (params: {
1267
+ id: string;
1268
+ org_id: string;
1269
+ app_id: string;
1270
+ user_id?: string | undefined;
1271
+ client_id?: string | undefined;
1272
+ date_range?: {
1273
+ start: string;
1274
+ end: string;
1275
+ } | undefined;
1276
+ } & {
1277
+ cursor?: string | undefined;
1278
+ limit?: number | undefined;
1279
+ }) => AsyncGenerator<{
1280
+ total: number;
1281
+ count: number;
1282
+ more: boolean;
1283
+ items: {
1284
+ user_id: string;
1285
+ sdk: string;
1286
+ client_id: string;
1287
+ connected_at: string;
1288
+ user_agent: string;
1289
+ disconnected_at?: string | undefined;
1290
+ jwt_exp?: string | undefined;
1291
+ }[];
1292
+ cursor?: string | undefined;
1293
+ }, void, unknown>;
1294
+ };
1295
+ }