powersync 0.6.1 → 0.7.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/README.md +36 -34
- package/dist/commands/instance/create.d.ts +3 -2
- package/dist/commands/instance/create.js +17 -17
- package/dist/commands/instance/deploy.d.ts +2 -1
- package/dist/commands/instance/deploy.js +16 -17
- package/dist/commands/instance/sync-rules/generate-schema.js +1 -0
- package/dist/commands.utils.js +7 -1
- package/dist/instance-command-flags.d.ts +12 -0
- package/dist/instance-command-flags.js +13 -0
- package/dist/service/accounts.client.js +4 -4
- package/dist/service/powersync.client.js +57312 -25766
- package/dist/service/utils.js +4 -4
- package/dist/utils.d.ts +7 -0
- package/oclif.manifest.json +34 -17
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ USAGE
|
|
|
26
26
|
|
|
27
27
|
The following environment variables can be injected:
|
|
28
28
|
|
|
29
|
-
* `AUTH_TOKEN` - The access token used to authenticate with the PowerSync service. [Learn more](https://docs.powersync.com/usage/tools/cli
|
|
29
|
+
* `AUTH_TOKEN` - The access token used to authenticate with the PowerSync service. [Learn more](https://docs.powersync.com/usage/tools/cli#personal-access-token).
|
|
30
30
|
* `ORG_ID` - The PowerSync organization ID. This is the first UUID in your project's dashboard URL. `123` in this example: `https://powersync.journeyapps.com/org/123/app/456`.
|
|
31
31
|
* `PROJECT_ID` - The PowerSync project ID. This is the second UUID in your project's dashboard URL. `456` in this example: `https://powersync.journeyapps.com/org/123/app/456`.
|
|
32
32
|
* `INSTANCE_ID` - The PowerSync instance ID. Get this by running `npx powersync instances`.
|
|
@@ -90,7 +90,7 @@ EXAMPLES
|
|
|
90
90
|
$ npx powersync init
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
_See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
93
|
+
_See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/init.ts)_
|
|
94
94
|
|
|
95
95
|
## `powersync instance config`
|
|
96
96
|
|
|
@@ -107,7 +107,7 @@ EXAMPLES
|
|
|
107
107
|
$ npx powersync instance config
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
_See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
110
|
+
_See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/config.ts)_
|
|
111
111
|
|
|
112
112
|
## `powersync instance create`
|
|
113
113
|
|
|
@@ -115,19 +115,20 @@ Create a new instance.
|
|
|
115
115
|
|
|
116
116
|
```
|
|
117
117
|
USAGE
|
|
118
|
-
$ npx powersync instance create [-
|
|
119
|
-
<value>] [-s] [-b]
|
|
118
|
+
$ npx powersync instance create [-i <value>] [-r <value>] [-n <value>] [-h <value>] [-w <value>] [-a <value>] [-o
|
|
119
|
+
<value>] [-s] [-j <value>] [-b]
|
|
120
120
|
|
|
121
121
|
FLAGS
|
|
122
|
-
-a, --jwtAudiences=<value>
|
|
123
|
-
-b, --[no-]useSupabaseAuth
|
|
124
|
-
-h, --hostname=<value>
|
|
125
|
-
-i, --name=<value>
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
122
|
+
-a, --jwtAudiences=<value> JWT audiences (comma separated).
|
|
123
|
+
-b, --[no-]useSupabaseAuth Use Supabase auth.
|
|
124
|
+
-h, --hostname=<value> Hostname to connect to database.
|
|
125
|
+
-i, --name=<value> Name of the instance.
|
|
126
|
+
-j, --supabaseJWTSecret=<value> Supabase JWT secret
|
|
127
|
+
-n, --databaseName=<value> Name of the database.
|
|
128
|
+
-o, --port=<value> Port number to connect to database.
|
|
129
|
+
-r, --region=<value> Region to deploy instance to.
|
|
130
|
+
-s, --skipInteraction Skip interactivity.
|
|
131
|
+
-w, --jwksUri=<value> JWKS URI (must include https://).
|
|
131
132
|
|
|
132
133
|
DESCRIPTION
|
|
133
134
|
Create a new instance.
|
|
@@ -136,7 +137,7 @@ EXAMPLES
|
|
|
136
137
|
$ npx powersync instance create
|
|
137
138
|
```
|
|
138
139
|
|
|
139
|
-
_See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
140
|
+
_See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/create.ts)_
|
|
140
141
|
|
|
141
142
|
## `powersync instance deploy`
|
|
142
143
|
|
|
@@ -144,16 +145,17 @@ Deploy changes to an existing instance.
|
|
|
144
145
|
|
|
145
146
|
```
|
|
146
147
|
USAGE
|
|
147
|
-
$ npx powersync instance deploy [-n <value>] [-h <value>] [-w <value>] [-a <value>] [-o <value>] [-s] [-b]
|
|
148
|
+
$ npx powersync instance deploy [-n <value>] [-h <value>] [-w <value>] [-a <value>] [-o <value>] [-s] [-j <value>] [-b]
|
|
148
149
|
|
|
149
150
|
FLAGS
|
|
150
|
-
-a, --jwtAudiences=<value>
|
|
151
|
-
-b, --[no-]useSupabaseAuth
|
|
152
|
-
-h, --hostname=<value>
|
|
153
|
-
-
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
151
|
+
-a, --jwtAudiences=<value> JWT audiences (comma separated).
|
|
152
|
+
-b, --[no-]useSupabaseAuth Use Supabase auth.
|
|
153
|
+
-h, --hostname=<value> Hostname to connect to database.
|
|
154
|
+
-j, --supabaseJWTSecret=<value> Supabase JWT secret
|
|
155
|
+
-n, --databaseName=<value> Name of the database.
|
|
156
|
+
-o, --port=<value> Port number to connect to database.
|
|
157
|
+
-s, --skipInteraction Skip interactivity.
|
|
158
|
+
-w, --jwksUri=<value> JWKS URI (must include https://).
|
|
157
159
|
|
|
158
160
|
DESCRIPTION
|
|
159
161
|
Deploy changes to an existing instance.
|
|
@@ -162,7 +164,7 @@ EXAMPLES
|
|
|
162
164
|
$ npx powersync instance deploy
|
|
163
165
|
```
|
|
164
166
|
|
|
165
|
-
_See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
167
|
+
_See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/deploy.ts)_
|
|
166
168
|
|
|
167
169
|
## `powersync instance destroy`
|
|
168
170
|
|
|
@@ -182,7 +184,7 @@ EXAMPLES
|
|
|
182
184
|
$ npx powersync instance destroy
|
|
183
185
|
```
|
|
184
186
|
|
|
185
|
-
_See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
187
|
+
_See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/destroy.ts)_
|
|
186
188
|
|
|
187
189
|
## `powersync instance generate-dev-token`
|
|
188
190
|
|
|
@@ -203,7 +205,7 @@ EXAMPLES
|
|
|
203
205
|
$ npx powersync instance generate-dev-token
|
|
204
206
|
```
|
|
205
207
|
|
|
206
|
-
_See code: [src/commands/instance/generate-dev-token.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
208
|
+
_See code: [src/commands/instance/generate-dev-token.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/generate-dev-token.ts)_
|
|
207
209
|
|
|
208
210
|
## `powersync instance schema`
|
|
209
211
|
|
|
@@ -220,7 +222,7 @@ EXAMPLES
|
|
|
220
222
|
$ npx powersync instance schema
|
|
221
223
|
```
|
|
222
224
|
|
|
223
|
-
_See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
225
|
+
_See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/schema.ts)_
|
|
224
226
|
|
|
225
227
|
## `powersync instance set`
|
|
226
228
|
|
|
@@ -242,7 +244,7 @@ EXAMPLES
|
|
|
242
244
|
$ npx powersync instance set --instanceId=1234
|
|
243
245
|
```
|
|
244
246
|
|
|
245
|
-
_See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
247
|
+
_See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/set.ts)_
|
|
246
248
|
|
|
247
249
|
## `powersync instance status`
|
|
248
250
|
|
|
@@ -267,7 +269,7 @@ EXAMPLES
|
|
|
267
269
|
$ npx powersync instance status --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234
|
|
268
270
|
```
|
|
269
271
|
|
|
270
|
-
_See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
272
|
+
_See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/status.ts)_
|
|
271
273
|
|
|
272
274
|
## `powersync instance stop`
|
|
273
275
|
|
|
@@ -287,7 +289,7 @@ EXAMPLES
|
|
|
287
289
|
$ npx powersync instance stop
|
|
288
290
|
```
|
|
289
291
|
|
|
290
|
-
_See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
292
|
+
_See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/stop.ts)_
|
|
291
293
|
|
|
292
294
|
## `powersync instance sync-rules deploy`
|
|
293
295
|
|
|
@@ -312,7 +314,7 @@ EXAMPLES
|
|
|
312
314
|
$ npx powersync instance sync-rules deploy -f path/to/file
|
|
313
315
|
```
|
|
314
316
|
|
|
315
|
-
_See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
317
|
+
_See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/sync-rules/deploy.ts)_
|
|
316
318
|
|
|
317
319
|
## `powersync instance sync-rules generate-schema`
|
|
318
320
|
|
|
@@ -338,7 +340,7 @@ EXAMPLES
|
|
|
338
340
|
$ npx powersync instance sync-rules generate-schema -f path/to/file
|
|
339
341
|
```
|
|
340
342
|
|
|
341
|
-
_See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
343
|
+
_See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/sync-rules/generate-schema.ts)_
|
|
342
344
|
|
|
343
345
|
## `powersync instance sync-rules validate`
|
|
344
346
|
|
|
@@ -362,7 +364,7 @@ EXAMPLES
|
|
|
362
364
|
$ npx powersync instance sync-rules validate -f path/to/file
|
|
363
365
|
```
|
|
364
366
|
|
|
365
|
-
_See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
367
|
+
_See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instance/sync-rules/validate.ts)_
|
|
366
368
|
|
|
367
369
|
## `powersync instances`
|
|
368
370
|
|
|
@@ -379,5 +381,5 @@ EXAMPLES
|
|
|
379
381
|
$ npx powersync instances
|
|
380
382
|
```
|
|
381
383
|
|
|
382
|
-
_See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.
|
|
384
|
+
_See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.7.1/src/commands/instances.ts)_
|
|
383
385
|
<!-- commandsstop -->
|
|
@@ -9,11 +9,12 @@ export default class InstanceCreate extends Command {
|
|
|
9
9
|
hostname: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
10
|
jwksUri: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
11
|
jwtAudiences: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
-
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
12
|
port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
|
-
region: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
13
|
skipInteraction: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
|
+
supabaseJWTSecret: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
15
|
useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
16
|
+
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
|
+
region: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
18
|
};
|
|
18
19
|
run(): Promise<void>;
|
|
19
20
|
}
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
1
|
import { Command, Flags, ux } from '@oclif/core';
|
|
3
2
|
import inquirer from 'inquirer';
|
|
4
3
|
import ora from 'ora';
|
|
5
4
|
import { generateCommonDeployQuestions } from '../../commands.utils.js';
|
|
5
|
+
import { generateCommonInstanceConfigFlags } from '../../instance-command-flags.js';
|
|
6
6
|
import * as PowerSyncClient from '../../service/powersync.client.js';
|
|
7
7
|
import { bold, checkThatEnvVariablesAreSet, green, red, updateEnvFileVariableValue } from '../../utils.js';
|
|
8
8
|
export default class InstanceCreate extends Command {
|
|
9
9
|
static description = 'Create a new instance.';
|
|
10
10
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
11
11
|
static flags = {
|
|
12
|
-
databaseName: Flags.string({ char: 'n', description: 'Name of the database.' }),
|
|
13
|
-
databasePassword: Flags.string({ char: 'p', description: 'Password of the database.', hidden: true }),
|
|
14
|
-
databaseUsername: Flags.string({ char: 'u', description: 'Username of the database.', hidden: true }),
|
|
15
|
-
hostname: Flags.string({ char: 'h', description: 'Hostname to connect to database.' }),
|
|
16
|
-
jwksUri: Flags.string({ char: 'w', description: 'JWKS URI (must include https://).' }),
|
|
17
|
-
jwtAudiences: Flags.string({ char: 'a', default: '', description: 'JWT audiences (comma separated).' }),
|
|
18
12
|
name: Flags.string({ char: 'i', description: 'Name of the instance.' }),
|
|
19
|
-
port: Flags.integer({ char: 'o', description: 'Port number to connect to database.' }),
|
|
20
13
|
region: Flags.string({ char: 'r', description: 'Region to deploy instance to.' }),
|
|
21
|
-
|
|
22
|
-
useSupabaseAuth: Flags.boolean({ allowNo: true, char: 'b', description: 'Use Supabase auth.' })
|
|
14
|
+
...generateCommonInstanceConfigFlags()
|
|
23
15
|
};
|
|
24
16
|
async run() {
|
|
25
17
|
checkThatEnvVariablesAreSet(this.config.bin);
|
|
26
|
-
const
|
|
18
|
+
const parsed = await this.parse(InstanceCreate);
|
|
19
|
+
const flags = parsed.flags;
|
|
27
20
|
const regions = await PowerSyncClient.getRegions();
|
|
28
21
|
let answers = {
|
|
29
22
|
databaseName: undefined,
|
|
30
23
|
databasePassword: undefined,
|
|
31
24
|
databaseUsername: undefined,
|
|
32
25
|
hostname: undefined,
|
|
33
|
-
jwksAudiences: undefined,
|
|
34
26
|
jwksUri: undefined,
|
|
27
|
+
jwtAudiences: undefined,
|
|
35
28
|
name: undefined,
|
|
36
29
|
port: undefined,
|
|
37
30
|
region: undefined,
|
|
@@ -68,9 +61,11 @@ export default class InstanceCreate extends Command {
|
|
|
68
61
|
const region = flags.region?.toLowerCase() || answers.region?.toLowerCase();
|
|
69
62
|
const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
|
|
70
63
|
const jwksUri = flags.jwksUri || answers.jwksUri;
|
|
71
|
-
const answerAudiences = answers.
|
|
72
|
-
const flagsAudiences = flags.
|
|
73
|
-
const audiences = flagsAudiences
|
|
64
|
+
const answerAudiences = answers.jwtAudiences ? answers.jwtAudiences.split(',') : [];
|
|
65
|
+
const flagsAudiences = flags.jwtAudiences ? flags.jwtAudiences.split(',') : [];
|
|
66
|
+
const audiences = [...new Set([...flagsAudiences, ...answerAudiences])];
|
|
67
|
+
const supabaseJWTSecret = flags.supabaseJWTSecret ?? answers.supabaseJWTSecret;
|
|
68
|
+
// TODO, support other connection types
|
|
74
69
|
const connection = {
|
|
75
70
|
database: databaseName,
|
|
76
71
|
debug_api: false,
|
|
@@ -89,9 +84,14 @@ export default class InstanceCreate extends Command {
|
|
|
89
84
|
client_auth: {
|
|
90
85
|
additional_audiences: audiences || undefined,
|
|
91
86
|
jwks_uri: jwksUri || undefined,
|
|
92
|
-
supabase: useSupabaseAuth
|
|
87
|
+
supabase: useSupabaseAuth,
|
|
88
|
+
supabase_jwt_secret: supabaseJWTSecret
|
|
89
|
+
? {
|
|
90
|
+
secret: supabaseJWTSecret
|
|
91
|
+
}
|
|
92
|
+
: undefined
|
|
93
93
|
},
|
|
94
|
-
region,
|
|
94
|
+
region: region,
|
|
95
95
|
replication: {
|
|
96
96
|
connections: [connection]
|
|
97
97
|
}
|
|
@@ -8,9 +8,10 @@ export default class InstanceDeploy extends Command {
|
|
|
8
8
|
databaseUsername: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
9
|
hostname: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
10
|
jwksUri: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
-
jwtAudiences: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string
|
|
11
|
+
jwtAudiences: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
12
|
port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
13
|
skipInteraction: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
|
+
supabaseJWTSecret: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
14
15
|
useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
16
|
};
|
|
16
17
|
run(): Promise<void>;
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import { Command, Flags, ux } from '@oclif/core';
|
|
1
|
+
import { Command, ux } from '@oclif/core';
|
|
3
2
|
import inquirer from 'inquirer';
|
|
4
3
|
import ora from 'ora';
|
|
5
4
|
import { generateCommonDeployQuestions } from '../../commands.utils.js';
|
|
5
|
+
import { generateCommonInstanceConfigFlags } from '../../instance-command-flags.js';
|
|
6
6
|
import * as PowerSyncClient from '../../service/powersync.client.js';
|
|
7
7
|
import { bold, checkThatEnvVariablesAreSet, green, red } from '../../utils.js';
|
|
8
8
|
export default class InstanceDeploy extends Command {
|
|
9
9
|
static description = 'Deploy changes to an existing instance.';
|
|
10
10
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
11
11
|
static flags = {
|
|
12
|
-
|
|
13
|
-
databasePassword: Flags.string({ char: 'p', description: 'Password of the database.', hidden: true }),
|
|
14
|
-
databaseUsername: Flags.string({ char: 'u', description: 'Username of the database.', hidden: true }),
|
|
15
|
-
hostname: Flags.string({ char: 'h', description: 'Hostname to connect to database.' }),
|
|
16
|
-
jwksUri: Flags.string({ char: 'w', description: 'JWKS URI (must include https://).' }),
|
|
17
|
-
jwtAudiences: Flags.string({ char: 'a', description: 'JWT audiences (comma separated).' }),
|
|
18
|
-
port: Flags.integer({ char: 'o', description: 'Port number to connect to database.' }),
|
|
19
|
-
skipInteraction: Flags.boolean({ char: 's', description: 'Skip interactivity.' }),
|
|
20
|
-
useSupabaseAuth: Flags.boolean({ allowNo: true, char: 'b', description: 'Use Supabase auth.' })
|
|
12
|
+
...generateCommonInstanceConfigFlags()
|
|
21
13
|
};
|
|
22
14
|
async run() {
|
|
23
15
|
checkThatEnvVariablesAreSet(this.config.bin, true);
|
|
24
|
-
const
|
|
16
|
+
const parsed = await this.parse(InstanceDeploy);
|
|
17
|
+
const flags = parsed.flags;
|
|
25
18
|
let answers = {
|
|
26
19
|
databaseName: undefined,
|
|
27
20
|
databasePassword: undefined,
|
|
28
21
|
databaseUsername: undefined,
|
|
29
22
|
hostname: undefined,
|
|
30
|
-
jwksAudiences: undefined,
|
|
31
23
|
jwksUri: undefined,
|
|
24
|
+
jwtAudiences: undefined,
|
|
32
25
|
port: undefined,
|
|
33
26
|
useSupabaseAuth: undefined
|
|
34
27
|
};
|
|
@@ -43,16 +36,22 @@ export default class InstanceDeploy extends Command {
|
|
|
43
36
|
const databaseUsername = flags.databaseUsername || answers.databaseUsername;
|
|
44
37
|
const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
|
|
45
38
|
const jwksUri = flags.jwksUri || answers.jwksUri;
|
|
46
|
-
const answerAudiences = answers.
|
|
47
|
-
const flagsAudiences = flags.
|
|
48
|
-
const audiences = flagsAudiences
|
|
39
|
+
const answerAudiences = answers.jwtAudiences ? answers.jwtAudiences.split(',') : [];
|
|
40
|
+
const flagsAudiences = flags.jwtAudiences ? flags.jwtAudiences.split(',') : [];
|
|
41
|
+
const audiences = [...new Set([...flagsAudiences, ...answerAudiences])];
|
|
42
|
+
const supabaseJWTSecret = flags.supabaseJWTSecret ?? answers.supabaseJWTSecret;
|
|
49
43
|
const instanceConfig = await PowerSyncClient.getInstanceConfig();
|
|
50
44
|
const { region } = instanceConfig.config;
|
|
51
45
|
const config = {
|
|
52
46
|
client_auth: {
|
|
53
47
|
additional_audiences: audiences || undefined,
|
|
54
48
|
jwks_uri: jwksUri || undefined,
|
|
55
|
-
supabase: useSupabaseAuth
|
|
49
|
+
supabase: useSupabaseAuth,
|
|
50
|
+
supabase_jwt_secret: supabaseJWTSecret
|
|
51
|
+
? {
|
|
52
|
+
secret: supabaseJWTSecret
|
|
53
|
+
}
|
|
54
|
+
: undefined
|
|
56
55
|
},
|
|
57
56
|
region,
|
|
58
57
|
replication: {
|
|
@@ -36,6 +36,7 @@ export default class SyncRulesGenerateSchema extends Command {
|
|
|
36
36
|
const parsedSchema = new PowerSyncClient.StaticSchema(schema.connections);
|
|
37
37
|
const syncRulesFromFile = fs.readFileSync(flags.filePath, 'utf8');
|
|
38
38
|
const syncRules = PowerSyncClient.SqlSyncRules.fromYaml(syncRulesFromFile, {
|
|
39
|
+
defaultSchema: 'public',
|
|
39
40
|
schema: parsedSchema,
|
|
40
41
|
throwOnError: false
|
|
41
42
|
});
|
package/dist/commands.utils.js
CHANGED
|
@@ -60,6 +60,12 @@ export const generateCommonDeployQuestions = (flags) => [
|
|
|
60
60
|
// eslint-disable-next-line eqeqeq,no-eq-null
|
|
61
61
|
when: flags.useSupabaseAuth == null && !flags.jwksUri
|
|
62
62
|
},
|
|
63
|
+
{
|
|
64
|
+
message: 'Enter the Supabase JWT secret (see https://docs.powersync.com/installation/authentication-setup/supabase-auth#supabase-auth)',
|
|
65
|
+
name: 'supabaseJWTSecret',
|
|
66
|
+
type: 'password',
|
|
67
|
+
when: (answers) => (flags.useSupabaseAuth || answers.useSupabaseAuth) && !flags.supabaseJWTSecret
|
|
68
|
+
},
|
|
63
69
|
{
|
|
64
70
|
message: 'Enter your JWKS URI (must include https://)?',
|
|
65
71
|
name: 'jwksUri',
|
|
@@ -79,7 +85,7 @@ export const generateCommonDeployQuestions = (flags) => [
|
|
|
79
85
|
},
|
|
80
86
|
{
|
|
81
87
|
message: 'Enter your JWT Audiences? (comma separated)',
|
|
82
|
-
name: '
|
|
88
|
+
name: 'jwtAudiences',
|
|
83
89
|
type: 'input',
|
|
84
90
|
when: (answers) => answers.useAudiences
|
|
85
91
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const generateCommonInstanceConfigFlags: () => {
|
|
2
|
+
databaseName: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
3
|
+
databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
4
|
+
databaseUsername: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
5
|
+
hostname: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
6
|
+
jwksUri: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
+
jwtAudiences: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
+
skipInteraction: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
10
|
+
supabaseJWTSecret: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
export const generateCommonInstanceConfigFlags = () => ({
|
|
3
|
+
databaseName: Flags.string({ char: 'n', description: 'Name of the database.' }),
|
|
4
|
+
databasePassword: Flags.string({ char: 'p', description: 'Password of the database.', hidden: true }),
|
|
5
|
+
databaseUsername: Flags.string({ char: 'u', description: 'Username of the database.', hidden: true }),
|
|
6
|
+
hostname: Flags.string({ char: 'h', description: 'Hostname to connect to database.' }),
|
|
7
|
+
jwksUri: Flags.string({ char: 'w', description: 'JWKS URI (must include https://).' }),
|
|
8
|
+
jwtAudiences: Flags.string({ char: 'a', default: '', description: 'JWT audiences (comma separated).' }),
|
|
9
|
+
port: Flags.integer({ char: 'o', description: 'Port number to connect to database.' }),
|
|
10
|
+
skipInteraction: Flags.boolean({ char: 's', description: 'Skip interactivity.' }),
|
|
11
|
+
supabaseJWTSecret: Flags.string({ allowNo: true, char: 'j', description: 'Supabase JWT secret' }),
|
|
12
|
+
useSupabaseAuth: Flags.boolean({ allowNo: true, char: 'b', description: 'Use Supabase auth.' })
|
|
13
|
+
});
|
|
@@ -11157,7 +11157,7 @@ var files = [
|
|
|
11157
11157
|
"/dist",
|
|
11158
11158
|
"/oclif.manifest.json"
|
|
11159
11159
|
];
|
|
11160
|
-
var version = "0.
|
|
11160
|
+
var version = "0.7.1";
|
|
11161
11161
|
var bugs = "https://github.com/powersync-ja/cli/issues";
|
|
11162
11162
|
var types = "dist/index.d.ts";
|
|
11163
11163
|
var exports = "./lib/index.js";
|
|
@@ -11215,12 +11215,12 @@ var dependencies = {
|
|
|
11215
11215
|
};
|
|
11216
11216
|
var devDependencies = {
|
|
11217
11217
|
"@changesets/cli": "^2.27.7",
|
|
11218
|
-
"@journeyapps-platform/powersync
|
|
11218
|
+
"@journeyapps-platform/types-powersync": "^1.12.1",
|
|
11219
11219
|
"@journeyapps-platform/sdk-accounts-hub": "^7.0.1",
|
|
11220
11220
|
"@journeyapps-platform/sdk-common": "^5.5.0",
|
|
11221
|
-
"@journeyapps-platform/sdk-powersync": "^
|
|
11221
|
+
"@journeyapps-platform/sdk-powersync": "^2.5.1",
|
|
11222
11222
|
"@journeyapps-platform/types-accounts-hub": "^7.0.1",
|
|
11223
|
-
"@powersync/service-sync-rules": "^0.
|
|
11223
|
+
"@powersync/service-sync-rules": "^0.27.0",
|
|
11224
11224
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
11225
11225
|
"@rollup/plugin-json": "^6.1.0",
|
|
11226
11226
|
"@rollup/plugin-node-resolve": "^15.2.3",
|