@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.
package/dist/index.js ADDED
@@ -0,0 +1,427 @@
1
+ import * as sdk from '@journeyapps-labs/common-sdk';
2
+ import { routes } from '@powersync/management-types';
3
+ const dev = routes.DEV_ROUTES;
4
+ const manage = routes.MANAGE_ROUTES;
5
+ const general = routes.GENERAL_ROUTES;
6
+ const report = routes.REPORT_ROUTES;
7
+ const dashboard = routes.SYNC_DASHBOARD_ROUTES;
8
+ export class PowerSyncManagementClient extends sdk.SDKClient {
9
+ /**
10
+ * Lists all PowerSync instances for a given organization and application.
11
+ *
12
+ * @returns Promise resolving to a list of instances with their IDs, names, config status, and deployability
13
+ * @example
14
+ * ```typescript
15
+ * const response = await client.listInstances({
16
+ * org_id: 'org-123',
17
+ * app_id: 'app-456'
18
+ * });
19
+ * console.log(response.instances); // Array of instance objects
20
+ * ```
21
+ */
22
+ listInstances = this.createEndpoint({
23
+ path: manage.LIST
24
+ });
25
+ /**
26
+ * Creates a new PowerSync instance.
27
+ *
28
+ * @returns Promise resolving to the created instance ID
29
+ * @example
30
+ * ```typescript
31
+ * const response = await client.createInstance({
32
+ * org_id: 'org-123',
33
+ * app_id: 'app-456',
34
+ * name: 'my-instance',
35
+ * region: 'us'
36
+ * });
37
+ * console.log(response.id); // The new instance ID
38
+ * ```
39
+ */
40
+ createInstance = this.createEndpoint({
41
+ path: manage.CREATE
42
+ });
43
+ /**
44
+ * Destroys a PowerSync instance. This is a permanent operation.
45
+ *
46
+ * @returns Promise resolving to the destroyed instance ID and optional operation ID
47
+ * @example
48
+ * ```typescript
49
+ * const response = await client.destroyInstance({
50
+ * org_id: 'org-123',
51
+ * app_id: 'app-456',
52
+ * id: 'instance-789'
53
+ * });
54
+ * console.log(response.id); // The destroyed instance ID
55
+ * ```
56
+ */
57
+ destroyInstance = this.createEndpoint({
58
+ path: manage.DESTROY
59
+ });
60
+ /**
61
+ * Deactivates a PowerSync instance without destroying it.
62
+ *
63
+ * @returns Promise resolving to the deactivated instance ID and optional operation ID
64
+ * @example
65
+ * ```typescript
66
+ * const response = await client.deactivateInstance({
67
+ * org_id: 'org-123',
68
+ * app_id: 'app-456',
69
+ * id: 'instance-789'
70
+ * });
71
+ * console.log(response.id); // The deactivated instance ID
72
+ * ```
73
+ */
74
+ deactivateInstance = this.createEndpoint({
75
+ path: manage.DEACTIVATE
76
+ });
77
+ /**
78
+ * Deploys a PowerSync instance with the specified configuration.
79
+ *
80
+ * @returns Promise resolving to the instance ID and operation ID for tracking deployment
81
+ * @example
82
+ * ```typescript
83
+ * const response = await client.deployInstance({
84
+ * org_id: 'org-123',
85
+ * app_id: 'app-456',
86
+ * id: 'instance-789',
87
+ * name: 'my-instance',
88
+ * config: {
89
+ * region: 'us',
90
+ * replication: {
91
+ * connections: [/* connection config *\/]
92
+ * }
93
+ * },
94
+ * sync_rules: 'SELECT * FROM users',
95
+ * program_version: {
96
+ * channel: 'stable',
97
+ * version_range: '^1.0.0'
98
+ * }
99
+ * });
100
+ * console.log(response.operation_id); // Track deployment progress
101
+ * ```
102
+ */
103
+ deployInstance = this.createEndpoint({
104
+ path: manage.DEPLOY
105
+ });
106
+ /**
107
+ * Retrieves the configuration for a PowerSync instance.
108
+ * This endpoint is retryable.
109
+ *
110
+ * @returns Promise resolving to the instance configuration including config, sync_rules, and program_version
111
+ * @example
112
+ * ```typescript
113
+ * const response = await client.getInstanceConfig({
114
+ * org_id: 'org-123',
115
+ * app_id: 'app-456',
116
+ * id: 'instance-789'
117
+ * });
118
+ * console.log(response.config); // The instance configuration
119
+ * console.log(response.sync_rules); // The sync rules
120
+ * ```
121
+ */
122
+ getInstanceConfig = this.createEndpoint({
123
+ path: manage.CONFIG,
124
+ retryable: true
125
+ });
126
+ /**
127
+ * Gets the provisioning status and deployment operations for a PowerSync instance.
128
+ * This endpoint is retryable.
129
+ *
130
+ * @returns Promise resolving to instance status including provisioned flag, operations array, and optional instance_url
131
+ * @example
132
+ * ```typescript
133
+ * const response = await client.getInstanceStatus({
134
+ * org_id: 'org-123',
135
+ * app_id: 'app-456',
136
+ * id: 'instance-789'
137
+ * });
138
+ * console.log(response.provisioned); // true if instance is provisioned
139
+ * console.log(response.operations); // Array of deployment operations
140
+ * ```
141
+ */
142
+ getInstanceStatus = this.createEndpoint({
143
+ path: manage.STATUS,
144
+ retryable: true
145
+ });
146
+ /**
147
+ * Gets diagnostic information for a PowerSync instance.
148
+ * Only works if the instance is already provisioned.
149
+ * This endpoint is retryable.
150
+ *
151
+ * @returns Promise resolving to diagnostic information
152
+ * @example
153
+ * ```typescript
154
+ * const response = await client.getInstanceDiagnostics({
155
+ * org_id: 'org-123',
156
+ * app_id: 'app-456',
157
+ * id: 'instance-789'
158
+ * });
159
+ * // Diagnostic information about the instance
160
+ * ```
161
+ */
162
+ getInstanceDiagnostics = this.createEndpoint({
163
+ path: manage.DIAGNOSTICS,
164
+ retryable: true
165
+ });
166
+ /**
167
+ * Triggers a compaction operation on a PowerSync instance.
168
+ *
169
+ * @returns Promise resolving to the instance ID and optional operation ID
170
+ * @example
171
+ * ```typescript
172
+ * const response = await client.compact({
173
+ * org_id: 'org-123',
174
+ * app_id: 'app-456',
175
+ * id: 'instance-789'
176
+ * });
177
+ * console.log(response.operation_id); // Track compaction progress
178
+ * ```
179
+ */
180
+ compact = this.createEndpoint({
181
+ path: manage.COMPACT
182
+ });
183
+ /**
184
+ * Tests a database connection without deploying an instance.
185
+ * Validates connectivity and configuration for the specified connection.
186
+ *
187
+ * @returns Promise resolving to connection test results including success status, connection details, and optional configuration details
188
+ * @example
189
+ * ```typescript
190
+ * const response = await client.testConnection({
191
+ * org_id: 'org-123',
192
+ * app_id: 'app-456',
193
+ * connection: {
194
+ * type: 'postgres',
195
+ * uri: 'postgresql://user:pass@host:5432/db'
196
+ * }
197
+ * });
198
+ * console.log(response.success); // true if connection test passed
199
+ * console.log(response.connection.reachable); // true if TCP connection works
200
+ * ```
201
+ */
202
+ testConnection = this.createEndpoint({
203
+ path: dev.TEST_CONNECTION
204
+ });
205
+ /**
206
+ * Gets the database schema for a PowerSync instance.
207
+ * Only works if the instance is already provisioned.
208
+ * This endpoint is retryable.
209
+ *
210
+ * @returns Promise resolving to the instance schema including connections, tables, and columns
211
+ * @example
212
+ * ```typescript
213
+ * const response = await client.getInstanceSchema({
214
+ * org_id: 'org-123',
215
+ * app_id: 'app-456',
216
+ * id: 'instance-789'
217
+ * });
218
+ * console.log(response.connections); // Array of connection schemas
219
+ * ```
220
+ */
221
+ getInstanceSchema = this.createEndpoint({
222
+ path: dev.GET_SCHEMA,
223
+ retryable: true
224
+ });
225
+ /**
226
+ * Executes SQL queries on a PowerSync instance.
227
+ * Only works if the instance is already provisioned.
228
+ *
229
+ * @returns Promise resolving to SQL execution results
230
+ * @example
231
+ * ```typescript
232
+ * const response = await client.executeSql({
233
+ * org_id: 'org-123',
234
+ * app_id: 'app-456',
235
+ * id: 'instance-789',
236
+ * sql: 'SELECT * FROM users WHERE id = ?',
237
+ * parameters: ['user-123']
238
+ * });
239
+ * // SQL query results
240
+ * ```
241
+ */
242
+ executeSql = this.createEndpoint({
243
+ path: dev.EXECUTE_SQL
244
+ });
245
+ /**
246
+ * Validates sync rules for a PowerSync instance.
247
+ * Only works if the instance is already provisioned.
248
+ *
249
+ * @returns Promise resolving to validation results
250
+ * @example
251
+ * ```typescript
252
+ * const response = await client.validateSyncRules({
253
+ * org_id: 'org-123',
254
+ * app_id: 'app-456',
255
+ * id: 'instance-789',
256
+ * sync_rules: 'SELECT * FROM users'
257
+ * });
258
+ * // Validation results
259
+ * ```
260
+ */
261
+ validateSyncRules = this.createEndpoint({
262
+ path: dev.VALIDATE_SYNC_RULES
263
+ });
264
+ /**
265
+ * Reprocesses sync rules for a PowerSync instance.
266
+ * Only works if the instance is already provisioned.
267
+ *
268
+ * @returns Promise resolving to reprocessing results
269
+ * @example
270
+ * ```typescript
271
+ * const response = await client.reprocessSyncRules({
272
+ * org_id: 'org-123',
273
+ * app_id: 'app-456',
274
+ * id: 'instance-789',
275
+ * sync_rules: 'SELECT * FROM users'
276
+ * });
277
+ * // Reprocessing results
278
+ * ```
279
+ */
280
+ reprocessSyncRules = this.createEndpoint({
281
+ path: dev.REPROCESS_SYNC_RULES
282
+ });
283
+ /**
284
+ * Generates a development token for a PowerSync instance.
285
+ *
286
+ * @returns Promise resolving to the generated JWT token
287
+ * @example
288
+ * ```typescript
289
+ * const response = await client.generateDevToken({
290
+ * org_id: 'org-123',
291
+ * app_id: 'app-456',
292
+ * id: 'instance-789',
293
+ * subject: 'user-123',
294
+ * expiresInSeconds: 3600
295
+ * });
296
+ * console.log(response.token); // The JWT token
297
+ * ```
298
+ */
299
+ generateDevToken = this.createEndpoint({
300
+ path: dev.GENERATE_DEV_TOKEN
301
+ });
302
+ /**
303
+ * Generates a dashboard token used for connecting to the Dashboard's dedicated PowerSync Service
304
+ *
305
+ * @returns Promise resolving to the generated dashboard JWT token
306
+ * @example
307
+ * ```typescript
308
+ * const response = await client.generateDashboardToken({
309
+ * org_id: 'org-123'
310
+ * });
311
+ * console.log(response.token); // The dashboard JWT token
312
+ * ```
313
+ */
314
+ generateDashboardToken = this.createEndpoint({
315
+ path: dashboard.GET_TOKEN
316
+ });
317
+ /**
318
+ * Lists available regions for PowerSync deployments.
319
+ * Returns region information including IP addresses for whitelisting.
320
+ *
321
+ * @returns Promise resolving to a list of regions with their names, deployability status, and IP addresses
322
+ * @example
323
+ * ```typescript
324
+ * const response = await client.listRegions({});
325
+ * console.log(response.regions); // Array of region objects with IPs for whitelisting
326
+ * ```
327
+ */
328
+ listRegions = this.createEndpoint({
329
+ path: general.LIST_REGIONS,
330
+ method: 'get'
331
+ });
332
+ /**
333
+ * Lists available PowerSync program versions for a channel.
334
+ *
335
+ * @returns Promise resolving to an array of versions with their status (current, available, or deprecated)
336
+ * @example
337
+ * ```typescript
338
+ * const response = await client.listVersionsV({
339
+ * channel: 'stable'
340
+ * });
341
+ * console.log(response); // Array of version objects with status
342
+ * ```
343
+ */
344
+ listVersions = this.createEndpoint({
345
+ path: general.LIST_VERSIONS_V2
346
+ });
347
+ /**
348
+ * Gets client connection reports for a PowerSync instance within a date range.
349
+ *
350
+ * @returns Promise resolving to connection report data including user counts and SDK breakdowns
351
+ * @example
352
+ * ```typescript
353
+ * const response = await client.getClientConnectionReports({
354
+ * org_id: 'org-123',
355
+ * app_id: 'app-456',
356
+ * id: 'instance-789',
357
+ * start: '2024-01-01T00:00:00Z',
358
+ * end: '2024-01-31T23:59:59Z'
359
+ * });
360
+ * console.log(response.users); // Total number of users
361
+ * console.log(response.sdks); // Array of SDK connection reports
362
+ * ```
363
+ */
364
+ getClientConnectionReports = this.createEndpoint({
365
+ path: report.GET_CLIENT_CONNECTION_DATA
366
+ });
367
+ /**
368
+ * Gets currently connected clients for a PowerSync instance.
369
+ *
370
+ * @returns Promise resolving to current connection data including user counts and SDK breakdowns
371
+ * @example
372
+ * ```typescript
373
+ * const response = await client.getConnectedClients({
374
+ * org_id: 'org-123',
375
+ * app_id: 'app-456',
376
+ * id: 'instance-789'
377
+ * });
378
+ * console.log(response.users); // Number of currently connected users
379
+ * console.log(response.sdks); // Array of current SDK connections
380
+ * ```
381
+ */
382
+ getConnectedClients = this.createEndpoint({
383
+ path: report.GET_CURRENT_CONNECTIONS
384
+ });
385
+ /**
386
+ * Gets paginated general client connection analytics for a PowerSync instance.
387
+ * Returns connection events including connect/disconnect times, user agents, and SDK information.
388
+ *
389
+ * @returns Promise resolving to paginated connection analytics events. Also includes a `paginate` method for iterating through all pages.
390
+ * @example
391
+ * ```typescript
392
+ * // Single page request
393
+ * const response = await client.getGeneralClientConnectionAnalytics({
394
+ * org_id: 'org-123',
395
+ * app_id: 'app-456',
396
+ * id: 'instance-789',
397
+ * date_range: {
398
+ * start: '2024-01-01T00:00:00Z',
399
+ * end: '2024-01-31T23:59:59Z'
400
+ * },
401
+ * limit: 100
402
+ * });
403
+ * console.log(response.items); // Array of connection events
404
+ * console.log(response.total); // Total number of events
405
+ * console.log(response.more); // true if there are more pages
406
+ * console.log(response.cursor); // cursor for the next page
407
+ *
408
+ * // Iterate through all pages
409
+ * for await (const page of client.getGeneralClientConnectionAnalytics.paginate({
410
+ * org_id: 'org-123',
411
+ * app_id: 'app-456',
412
+ * id: 'instance-789',
413
+ * date_range: {
414
+ * start: '2024-01-01T00:00:00Z',
415
+ * end: '2024-01-31T23:59:59Z'
416
+ * },
417
+ * limit: 100
418
+ * })) {
419
+ * console.log(page.items); // Process each page
420
+ * }
421
+ * ```
422
+ */
423
+ getGeneralClientConnectionAnalytics = sdk.createPaginatedEndpoint(this.createEndpoint({
424
+ path: report.GET_GENERAL_CLIENT_ANALYTICS
425
+ }));
426
+ }
427
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC;AAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;AACpC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;AACpC,MAAM,SAAS,GAAG,MAAM,CAAC,qBAAqB,CAAA;AAE9C,MAAM,OAAO,yBAA2E,SAAQ,GAAG,CAAC,SAAY;IAC9G;;;;;;;;;;;;OAYG;IACH,aAAa,GAAG,IAAI,CAAC,cAAc,CAA4D;QAC7F,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC,CAAC;IAEH;;;;;;;;;;;;;;OAcG;IACH,cAAc,GAAG,IAAI,CAAC,cAAc,CAA8D;QAChG,IAAI,EAAE,MAAM,CAAC,MAAM;KACpB,CAAC,CAAC;IAEH;;;;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AqCG;IACH,mCAAmC,GAAG,GAAG,CAAC,uBAAuB,CAC/D,IAAI,CAAC,cAAc,CAAyF;QAC1G,IAAI,EAAE,MAAM,CAAC,4BAA4B;KAC1C,CAAC,CACH,CAAC;CACH"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@powersync/management-client",
3
+ "version": "0.0.0-dev-20260225123311",
4
+ "description": "A TypeScript client for the PowerSync Management Service API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "license": "FSL-1.1-ALv2",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "files": [
13
+ "dist/**/*"
14
+ ],
15
+ "keywords": [],
16
+ "author": "POWERSYNC",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+ssh://git@github.com/journeyapps-platform/powersync.git",
20
+ "directory": "public-packages/client"
21
+ },
22
+ "dependencies": {
23
+ "@journeyapps-labs/common-sdk": "^1.0.2",
24
+ "@powersync/management-types": "^0.0.0-dev-20260225123311"
25
+ },
26
+ "devDependencies": {
27
+ "@types/json-schema": "^7.0.15"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc -b",
31
+ "clean": "rm -rf ./dist && tsc -b --clean"
32
+ }
33
+ }