powersync 0.4.2 → 0.5.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.
package/README.md CHANGED
@@ -44,6 +44,7 @@ Example:
44
44
  * [`powersync instance create`](#powersync-instance-create)
45
45
  * [`powersync instance deploy`](#powersync-instance-deploy)
46
46
  * [`powersync instance destroy`](#powersync-instance-destroy)
47
+ * [`powersync instance generate-dev-token`](#powersync-instance-generate-dev-token)
47
48
  * [`powersync instance schema`](#powersync-instance-schema)
48
49
  * [`powersync instance set`](#powersync-instance-set)
49
50
  * [`powersync instance status`](#powersync-instance-status)
@@ -89,7 +90,7 @@ EXAMPLES
89
90
  $ npx powersync init
90
91
  ```
91
92
 
92
- _See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/init.ts)_
93
+ _See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/init.ts)_
93
94
 
94
95
  ## `powersync instance config`
95
96
 
@@ -106,7 +107,7 @@ EXAMPLES
106
107
  $ npx powersync instance config
107
108
  ```
108
109
 
109
- _See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/config.ts)_
110
+ _See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/config.ts)_
110
111
 
111
112
  ## `powersync instance create`
112
113
 
@@ -114,16 +115,19 @@ Create a new instance.
114
115
 
115
116
  ```
116
117
  USAGE
117
- $ npx powersync instance create [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
118
- [--region <value>] [--useSupabaseAuth]
118
+ $ npx powersync instance create [-n <value>] [-h <value>] [-a <value>] [-w <value>] [-i <value>] [-o <value>] [-r
119
+ <value>] [-s] [-a]
119
120
 
120
121
  FLAGS
121
- --databaseName=<value> Name of the database.
122
- --hostname=<value> Hostname to connect to database.
123
- --name=<value> Name of the instance.
124
- --port=<value> Port number to connect to database.
125
- --region=<value> Region to deploy instance to.
126
- --useSupabaseAuth Use Supabase for auth.
122
+ -a, --jwksAudiences=<value> JWKS audiences (comma separated).
123
+ -a, --[no-]useSupabaseAuth Use Supabase auth.
124
+ -h, --hostname=<value> Hostname to connect to database.
125
+ -i, --name=<value> Name of the instance.
126
+ -n, --databaseName=<value> Name of the database.
127
+ -o, --port=<value> Port number to connect to database.
128
+ -r, --region=<value> Region to deploy instance to.
129
+ -s, --skipInteraction Skip interactivity.
130
+ -w, --jwksUri=<value> JWKS URL (must include https://).
127
131
 
128
132
  DESCRIPTION
129
133
  Create a new instance.
@@ -132,7 +136,7 @@ EXAMPLES
132
136
  $ npx powersync instance create
133
137
  ```
134
138
 
135
- _See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/create.ts)_
139
+ _See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/create.ts)_
136
140
 
137
141
  ## `powersync instance deploy`
138
142
 
@@ -140,15 +144,16 @@ Deploy changes to an existing instance.
140
144
 
141
145
  ```
142
146
  USAGE
143
- $ npx powersync instance deploy [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
144
- [--useSupabaseAuth]
147
+ $ npx powersync instance deploy [-n <value>] [-h <value>] [-a <value>] [-w <value>] [-o <value>] [-s] [-a]
145
148
 
146
149
  FLAGS
147
- --databaseName=<value> Name of the database.
148
- --hostname=<value> Hostname to connect to database.
149
- --name=<value> Name of the instance.
150
- --port=<value> Port number to connect to database.
151
- --useSupabaseAuth Use Supabase auth.
150
+ -a, --jwksAudiences=<value> JWKS audiences (comma separated).
151
+ -a, --[no-]useSupabaseAuth Use Supabase auth.
152
+ -h, --hostname=<value> Hostname to connect to database.
153
+ -n, --databaseName=<value> Name of the database.
154
+ -o, --port=<value> Port number to connect to database.
155
+ -s, --skipInteraction Skip interactivity.
156
+ -w, --jwksUri=<value> JWKS URL (must include https://).
152
157
 
153
158
  DESCRIPTION
154
159
  Deploy changes to an existing instance.
@@ -157,7 +162,7 @@ EXAMPLES
157
162
  $ npx powersync instance deploy
158
163
  ```
159
164
 
160
- _See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/deploy.ts)_
165
+ _See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/deploy.ts)_
161
166
 
162
167
  ## `powersync instance destroy`
163
168
 
@@ -177,7 +182,28 @@ EXAMPLES
177
182
  $ npx powersync instance destroy
178
183
  ```
179
184
 
180
- _See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/destroy.ts)_
185
+ _See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/destroy.ts)_
186
+
187
+ ## `powersync instance generate-dev-token`
188
+
189
+ Generate a developer token using the Token subject/ User ID.
190
+
191
+ ```
192
+ USAGE
193
+ $ npx powersync instance generate-dev-token [-e <value>] [-u <value>]
194
+
195
+ FLAGS
196
+ -e, --expiresInSeconds=<value> The token expiry in seconds.
197
+ -u, --userId=<value> The Token subject/User ID for the developer token
198
+
199
+ DESCRIPTION
200
+ Generate a developer token using the Token subject/ User ID.
201
+
202
+ EXAMPLES
203
+ $ npx powersync instance generate-dev-token
204
+ ```
205
+
206
+ _See code: [src/commands/instance/generate-dev-token.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/generate-dev-token.ts)_
181
207
 
182
208
  ## `powersync instance schema`
183
209
 
@@ -194,7 +220,7 @@ EXAMPLES
194
220
  $ npx powersync instance schema
195
221
  ```
196
222
 
197
- _See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/schema.ts)_
223
+ _See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/schema.ts)_
198
224
 
199
225
  ## `powersync instance set`
200
226
 
@@ -216,7 +242,7 @@ EXAMPLES
216
242
  $ npx powersync instance set --instanceId=1234
217
243
  ```
218
244
 
219
- _See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/set.ts)_
245
+ _See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/set.ts)_
220
246
 
221
247
  ## `powersync instance status`
222
248
 
@@ -241,7 +267,7 @@ EXAMPLES
241
267
  $ npx powersync instance status --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234
242
268
  ```
243
269
 
244
- _See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/status.ts)_
270
+ _See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/status.ts)_
245
271
 
246
272
  ## `powersync instance stop`
247
273
 
@@ -261,7 +287,7 @@ EXAMPLES
261
287
  $ npx powersync instance stop
262
288
  ```
263
289
 
264
- _See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/stop.ts)_
290
+ _See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/stop.ts)_
265
291
 
266
292
  ## `powersync instance sync-rules deploy`
267
293
 
@@ -286,7 +312,7 @@ EXAMPLES
286
312
  $ npx powersync instance sync-rules deploy -f path/to/file
287
313
  ```
288
314
 
289
- _See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/sync-rules/deploy.ts)_
315
+ _See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/sync-rules/deploy.ts)_
290
316
 
291
317
  ## `powersync instance sync-rules generate-schema`
292
318
 
@@ -312,7 +338,7 @@ EXAMPLES
312
338
  $ npx powersync instance sync-rules generate-schema -f path/to/file
313
339
  ```
314
340
 
315
- _See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/sync-rules/generate-schema.ts)_
341
+ _See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/sync-rules/generate-schema.ts)_
316
342
 
317
343
  ## `powersync instance sync-rules validate`
318
344
 
@@ -336,7 +362,7 @@ EXAMPLES
336
362
  $ npx powersync instance sync-rules validate -f path/to/file
337
363
  ```
338
364
 
339
- _See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instance/sync-rules/validate.ts)_
365
+ _See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instance/sync-rules/validate.ts)_
340
366
 
341
367
  ## `powersync instances`
342
368
 
@@ -353,5 +379,5 @@ EXAMPLES
353
379
  $ npx powersync instances
354
380
  ```
355
381
 
356
- _See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.4.2/src/commands/instances.ts)_
382
+ _See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.5.0/src/commands/instances.ts)_
357
383
  <!-- commandsstop -->
@@ -2,5 +2,6 @@ import { Command } from '@oclif/core';
2
2
  export default class Init extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
+ catch(error: any): Promise<never>;
5
6
  run(): Promise<void>;
6
7
  }
@@ -7,6 +7,13 @@ import { green, red } from '../utils.js';
7
7
  export default class Init extends Command {
8
8
  static description = 'Initialize the CLI.';
9
9
  static examples = ['<%= config.bin %> <%= command.id %>'];
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ async catch(error) {
12
+ if ('errorData' in error && error.errorData.status === 401) {
13
+ return ux.error(red(`You are using an invalid API token. Please double-check your token.`), { exit: 1 });
14
+ }
15
+ throw error;
16
+ }
10
17
  async run() {
11
18
  const authTokenQuestions = [
12
19
  {
@@ -7,9 +7,12 @@ export default class InstanceCreate extends Command {
7
7
  databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
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
+ jwksAudiences: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ jwksUri: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
12
  name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
13
  port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
14
  region: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
+ skipInteraction: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
16
  useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
17
  };
15
18
  run(): Promise<void>;
@@ -2,121 +2,75 @@
2
2
  import { Command, Flags, ux } from '@oclif/core';
3
3
  import inquirer from 'inquirer';
4
4
  import ora from 'ora';
5
+ import { generateCommonDeployQuestions } from '../../commands.utils.js';
5
6
  import * as PowerSyncClient from '../../service/powersync.client.js';
6
7
  import { bold, checkForValidEnvFile, green, red, updateEnvFileVariableValue } from '../../utils.js';
7
8
  export default class InstanceCreate extends Command {
8
9
  static description = 'Create a new instance.';
9
10
  static examples = ['<%= config.bin %> <%= command.id %>'];
10
11
  static flags = {
11
- databaseName: Flags.string({ description: 'Name of the database.' }),
12
- databasePassword: Flags.string({ description: 'Password of the database.', hidden: true }),
13
- databaseUsername: Flags.string({ description: 'Username of the database.', hidden: true }),
14
- hostname: Flags.string({ description: 'Hostname to connect to database.' }),
15
- name: Flags.string({ description: 'Name of the instance.' }),
16
- port: Flags.integer({ description: 'Port number to connect to database.' }),
17
- region: Flags.string({ description: 'Region to deploy instance to.' }),
18
- useSupabaseAuth: Flags.boolean({ description: 'Use Supabase for auth.' })
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
+ jwksAudiences: Flags.string({ char: 'a', default: '', description: 'JWKS audiences (comma separated).' }),
17
+ jwksUri: Flags.string({ char: 'w', description: 'JWKS URL (must include https://).' }),
18
+ name: Flags.string({ char: 'i', description: 'Name of the instance.' }),
19
+ port: Flags.integer({ char: 'o', description: 'Port number to connect to database.' }),
20
+ region: Flags.string({ char: 'r', description: 'Region to deploy instance to.' }),
21
+ skipInteraction: Flags.boolean({ char: 's', description: 'Skip interactivity.' }),
22
+ useSupabaseAuth: Flags.boolean({ allowNo: true, char: 'a', description: 'Use Supabase auth.' })
19
23
  };
20
24
  async run() {
21
25
  checkForValidEnvFile(this.config.bin);
22
26
  const { flags } = await this.parse(InstanceCreate);
23
27
  const regions = await PowerSyncClient.getRegions();
24
- const questions = [
25
- {
26
- message: 'What do you want to name your instance?',
27
- name: 'name',
28
- type: 'input',
29
- validate(value) {
30
- return value.length > 3 ? true : 'Please enter a name with at least 3 characters.';
31
- },
32
- when: !flags.name
33
- },
34
- {
35
- choices: regions.map((region) => region.toUpperCase()),
36
- message: 'What region do you want to use?',
37
- name: 'region',
38
- type: 'list',
39
- when: !flags.region
40
- },
41
- {
42
- message: 'What is your database hostname?',
43
- name: 'hostname',
44
- type: 'input',
45
- validate(value) {
46
- return value.length > 0 ? true : 'Please enter your hostname.';
47
- },
48
- when: !flags.hostname
49
- },
50
- {
51
- default: 5432,
52
- message: 'What is the port number of your database?',
53
- name: 'port',
54
- type: 'input',
55
- validate(value) {
56
- const number = Number.parseFloat(value);
57
- if (Number.isNaN(number)) {
58
- return 'Please enter a valid port number.';
59
- }
60
- return String(value).length > 0 ? true : 'Please enter your port number.';
61
- },
62
- when: !flags.port
63
- },
64
- {
65
- default: 'postgres',
66
- message: 'What is your database name?',
67
- name: 'databaseName',
68
- type: 'input',
69
- validate(value) {
70
- return value.length > 0 ? true : 'Please enter your database name.';
71
- },
72
- when: !flags.databaseName
73
- },
74
- {
75
- default: 'postgres',
76
- message: 'What is your database username?',
77
- name: 'databaseUsername',
78
- type: 'input',
79
- validate(value) {
80
- return value.length > 0 ? true : 'Please enter your database username.';
81
- },
82
- when: !flags.databaseUsername
83
- },
84
- {
85
- message: 'What is your database password?',
86
- name: 'databasePassword',
87
- type: 'password',
88
- validate(value) {
89
- return value.length > 0 ? true : 'Please enter your password.';
28
+ let answers = {
29
+ databaseName: undefined,
30
+ databasePassword: undefined,
31
+ databaseUsername: undefined,
32
+ hostname: undefined,
33
+ jwksAudiences: undefined,
34
+ jwksUri: undefined,
35
+ name: undefined,
36
+ port: undefined,
37
+ region: undefined,
38
+ useSupabaseAuth: undefined
39
+ };
40
+ if (!flags.skipInteraction) {
41
+ const questions = [
42
+ {
43
+ message: 'What do you want to name your instance?',
44
+ name: 'name',
45
+ type: 'input',
46
+ validate(value) {
47
+ return value.length > 3 ? true : 'Please enter a name with at least 3 characters.';
48
+ },
49
+ when: !flags.name
90
50
  },
91
- when: !flags.databasePassword
92
- },
93
- {
94
- default: false,
95
- message: 'Are you using Supabase auth?',
96
- name: 'useSupabaseAuth',
97
- type: 'confirm',
98
- when: !flags.useSupabaseAuth
99
- },
100
- {
101
- message: 'Enter your JWKS URL?',
102
- name: 'jwtServerUrl',
103
- type: 'input',
104
- validate(value) {
105
- const urlRegex = /^(https?|ftp):\/\/[^\s#$./?].\S*$/i;
106
- return urlRegex.test(value) ? true : 'Please enter a valid URL.';
51
+ {
52
+ choices: regions.map((region) => region.toUpperCase()),
53
+ message: 'What region do you want to use?',
54
+ name: 'region',
55
+ type: 'list',
56
+ when: !flags.region
107
57
  },
108
- when: (answers) => !answers.useSupabaseAuth
109
- }
110
- ];
111
- const answers = await inquirer.prompt(questions);
58
+ ...generateCommonDeployQuestions(flags)
59
+ ];
60
+ answers = await inquirer.prompt(questions);
61
+ }
112
62
  const instanceName = flags.name || answers.name;
113
63
  const port = flags.port || answers.port;
114
64
  const password = flags.databasePassword || answers.databasePassword;
115
65
  const hostname = flags.hostname || answers.hostname;
116
66
  const databaseName = flags.databaseName || answers.databaseName;
117
67
  const databaseUsername = flags.databaseUsername || answers.databaseUsername;
118
- const region = flags.region || answers.region;
68
+ const region = flags.region?.toLowerCase() || answers.region?.toLowerCase();
119
69
  const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
70
+ const jwksUri = flags.jwksUri || answers.jwksUri;
71
+ const answerAudiences = answers.jwksAudiences ? answers.jwksAudiences.split(',') : [];
72
+ const flagsAudiences = flags.jwksAudiences ? flags.jwksAudiences.split(',') : [];
73
+ const audiences = flagsAudiences || answerAudiences;
120
74
  const connection = {
121
75
  database: databaseName,
122
76
  debug_api: false,
@@ -133,10 +87,11 @@ export default class InstanceCreate extends Command {
133
87
  };
134
88
  const config = {
135
89
  client_auth: {
136
- jwks_uri: answers.jwksUri || undefined,
90
+ additional_audiences: audiences || undefined,
91
+ jwks_uri: jwksUri || undefined,
137
92
  supabase: useSupabaseAuth
138
93
  },
139
- region: region.toLowerCase(),
94
+ region,
140
95
  replication: {
141
96
  connections: [connection]
142
97
  }
@@ -7,8 +7,10 @@ export default class InstanceDeploy extends Command {
7
7
  databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
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
- name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ jwksAudiences: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ jwksUri: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
12
  port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ skipInteraction: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
12
14
  useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
15
  };
14
16
  run(): Promise<void>;
@@ -2,106 +2,56 @@
2
2
  import { Command, Flags, ux } from '@oclif/core';
3
3
  import inquirer from 'inquirer';
4
4
  import ora from 'ora';
5
+ import { generateCommonDeployQuestions } from '../../commands.utils.js';
5
6
  import * as PowerSyncClient from '../../service/powersync.client.js';
6
7
  import { bold, checkForValidEnvFile, green, red } from '../../utils.js';
7
8
  export default class InstanceDeploy extends Command {
8
9
  static description = 'Deploy changes to an existing instance.';
9
10
  static examples = ['<%= config.bin %> <%= command.id %>'];
10
11
  static flags = {
11
- databaseName: Flags.string({ description: 'Name of the database.' }),
12
- databasePassword: Flags.string({ description: 'Password of the database.', hidden: true }),
13
- databaseUsername: Flags.string({ description: 'Username of the database.', hidden: true }),
14
- hostname: Flags.string({ description: 'Hostname to connect to database.' }),
15
- name: Flags.string({ description: 'Name of the instance.' }),
16
- port: Flags.integer({ description: 'Port number to connect to database.' }),
17
- useSupabaseAuth: Flags.boolean({ description: 'Use Supabase auth.' })
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
+ jwksAudiences: Flags.string({ char: 'a', description: 'JWKS audiences (comma separated).' }),
17
+ jwksUri: Flags.string({ char: 'w', description: 'JWKS URL (must include https://).' }),
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: 'a', description: 'Use Supabase auth.' })
18
21
  };
19
22
  async run() {
20
23
  checkForValidEnvFile(this.config.bin, true);
21
24
  const { flags } = await this.parse(InstanceDeploy);
22
- const questions = [
23
- {
24
- message: 'What is your database hostname?',
25
- name: 'hostname',
26
- type: 'input',
27
- validate(value) {
28
- return value.length > 0 ? true : 'Please enter your hostname.';
29
- },
30
- when: !flags.hostname
31
- },
32
- {
33
- default: 5432,
34
- message: 'What is the port number of your database?',
35
- name: 'port',
36
- type: 'input',
37
- validate(value) {
38
- const number = Number.parseFloat(value);
39
- if (Number.isNaN(number)) {
40
- return 'Please enter a valid port number.';
41
- }
42
- return String(value).length > 0 ? true : 'Please enter your port number.';
43
- },
44
- when: !flags.port
45
- },
46
- {
47
- default: 'postgres',
48
- message: 'What is your database name?',
49
- name: 'databaseName',
50
- type: 'input',
51
- validate(value) {
52
- return value.length > 0 ? true : 'Please enter your database name.';
53
- },
54
- when: !flags.databaseName
55
- },
56
- {
57
- default: 'postgres',
58
- message: 'What is your database username?',
59
- name: 'databaseUsername',
60
- type: 'input',
61
- validate(value) {
62
- return value.length > 0 ? true : 'Please enter your database username.';
63
- },
64
- when: !flags.databaseUsername
65
- },
66
- {
67
- message: 'What is your database password?',
68
- name: 'databasePassword',
69
- type: 'password',
70
- validate(value) {
71
- return value.length > 0 ? true : 'Please enter your password.';
72
- },
73
- when: !flags.databasePassword
74
- },
75
- {
76
- default: false,
77
- message: 'Are you using Supabase auth?',
78
- name: 'useSupabaseAuth',
79
- type: 'confirm',
80
- when: !flags.useSupabaseAuth
81
- },
82
- {
83
- message: 'Enter your JWKS URL?',
84
- name: 'jwtServerUrl',
85
- type: 'input',
86
- validate(value) {
87
- const urlRegex = /^(https?|ftp):\/\/[^\s#$./?].\S*$/i;
88
- return urlRegex.test(value) ? true : 'Please enter a valid URL.';
89
- },
90
- when: (answers) => !answers.useSupabaseAuth
91
- }
92
- ];
93
- const answers = await inquirer.prompt(questions);
25
+ let answers = {
26
+ databaseName: undefined,
27
+ databasePassword: undefined,
28
+ databaseUsername: undefined,
29
+ hostname: undefined,
30
+ jwksAudiences: undefined,
31
+ jwksUri: undefined,
32
+ port: undefined,
33
+ useSupabaseAuth: undefined
34
+ };
35
+ if (!flags.skipInteraction) {
36
+ const questions = generateCommonDeployQuestions(flags);
37
+ answers = await inquirer.prompt(questions);
38
+ }
94
39
  const port = flags.port || answers.port;
95
40
  const password = flags.databasePassword || answers.databasePassword;
96
41
  const hostname = flags.hostname || answers.hostname;
97
42
  const databaseName = flags.databaseName || answers.databaseName;
98
43
  const databaseUsername = flags.databaseUsername || answers.databaseUsername;
99
44
  const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
45
+ const jwksUri = flags.jwksUri || answers.jwksUri;
46
+ const answerAudiences = answers.jwksAudiences ? answers.jwksAudiences.split(',') : [];
47
+ const flagsAudiences = flags.jwksAudiences ? flags.jwksAudiences.split(',') : [];
48
+ const audiences = flagsAudiences || answerAudiences;
100
49
  const instanceConfig = await PowerSyncClient.getInstanceConfig();
101
50
  const { region } = instanceConfig.config;
102
51
  const config = {
103
52
  client_auth: {
104
- jwks_uri: answers.jwksUri || undefined,
53
+ additional_audiences: audiences || undefined,
54
+ jwks_uri: jwksUri || undefined,
105
55
  supabase: useSupabaseAuth
106
56
  },
107
57
  region,
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class InstanceGenerateDevToken extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ expiresInSeconds: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ userId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,54 @@
1
+ import { Command, Flags, ux } from '@oclif/core';
2
+ import clipboard from 'clipboardy';
3
+ import inquirer from 'inquirer';
4
+ import * as PowerSyncClient from '../../service/powersync.client.js';
5
+ import { bold, checkForValidEnvFile, convertSeconds, green } from '../../utils.js';
6
+ export default class InstanceGenerateDevToken extends Command {
7
+ static description = 'Generate a developer token using the Token subject/ User ID.';
8
+ static examples = ['<%= config.bin %> <%= command.id %>'];
9
+ static flags = {
10
+ expiresInSeconds: Flags.string({
11
+ char: 'e',
12
+ description: 'The token expiry in seconds.'
13
+ }),
14
+ userId: Flags.string({ char: 'u', description: 'The Token subject/User ID for the developer token' })
15
+ };
16
+ async run() {
17
+ checkForValidEnvFile(this.config.bin, true);
18
+ const { flags } = await this.parse(InstanceGenerateDevToken);
19
+ const questions = [
20
+ {
21
+ message: 'Please enter the Token subject/ User ID to use for the developer token.',
22
+ name: 'userId',
23
+ type: 'input',
24
+ when: !flags.userId
25
+ },
26
+ {
27
+ default: 43_200,
28
+ message: 'Please enter the token expiry in seconds (Defaults to 12 hours).',
29
+ name: 'expiresInSeconds',
30
+ type: 'input',
31
+ validate(value) {
32
+ const number = Number.parseFloat(value);
33
+ if (Number.isNaN(number)) {
34
+ return 'Please enter a valid number.';
35
+ }
36
+ return String(value).length > 0 ? true : 'Please enter a valid number.';
37
+ },
38
+ when: !flags.expiresInSeconds
39
+ }
40
+ ];
41
+ const answers = await inquirer.prompt(questions);
42
+ const userId = flags.userId || answers.userId;
43
+ const expiresInSeconds = Number(flags.expiresInSeconds) || answers.expiresInSeconds;
44
+ const developerToken = await PowerSyncClient.generateDevToken(userId, expiresInSeconds);
45
+ clipboard.writeSync(developerToken);
46
+ clipboard.readSync();
47
+ ux.log(green(`Developer token generated successfully.
48
+ Token has been copied to your clipboard.
49
+ Token details:
50
+ Expires in: ${bold(convertSeconds(expiresInSeconds))}
51
+ JWT:
52
+ ${bold(developerToken)}`));
53
+ }
54
+ }
@@ -0,0 +1,2 @@
1
+ import type { Question } from 'inquirer';
2
+ export declare const generateCommonDeployQuestions: (flags: any) => Question[];
@@ -0,0 +1,86 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ export const generateCommonDeployQuestions = (flags) => [
3
+ {
4
+ message: 'What is your database hostname?',
5
+ name: 'hostname',
6
+ type: 'input',
7
+ validate(value) {
8
+ return value.length > 0 ? true : 'Please enter your hostname.';
9
+ },
10
+ when: !flags.hostname
11
+ },
12
+ {
13
+ default: 5432,
14
+ message: 'What is the port number of your database?',
15
+ name: 'port',
16
+ type: 'input',
17
+ validate(value) {
18
+ const number = Number.parseFloat(value);
19
+ if (Number.isNaN(number)) {
20
+ return 'Please enter a valid port number.';
21
+ }
22
+ return String(value).length > 0 ? true : 'Please enter your port number.';
23
+ },
24
+ when: !flags.port
25
+ },
26
+ {
27
+ default: 'postgres',
28
+ message: 'What is your database name?',
29
+ name: 'databaseName',
30
+ type: 'input',
31
+ validate(value) {
32
+ return value.length > 0 ? true : 'Please enter your database name.';
33
+ },
34
+ when: !flags.databaseName
35
+ },
36
+ {
37
+ default: 'postgres',
38
+ message: 'What is your database username?',
39
+ name: 'databaseUsername',
40
+ type: 'input',
41
+ validate(value) {
42
+ return value.length > 0 ? true : 'Please enter your database username.';
43
+ },
44
+ when: !flags.databaseUsername
45
+ },
46
+ {
47
+ message: 'What is your database password?',
48
+ name: 'databasePassword',
49
+ type: 'password',
50
+ validate(value) {
51
+ return value.length > 0 ? true : 'Please enter your password.';
52
+ },
53
+ when: !flags.databasePassword
54
+ },
55
+ {
56
+ default: false,
57
+ message: 'Are you using Supabase auth?',
58
+ name: 'useSupabaseAuth',
59
+ type: 'confirm',
60
+ // eslint-disable-next-line eqeqeq,no-eq-null
61
+ when: flags.useSupabaseAuth == null && !flags.jwksUri
62
+ },
63
+ {
64
+ message: 'Enter your JWKS URL (must include https://)?',
65
+ name: 'jwksUri',
66
+ type: 'input',
67
+ validate(value) {
68
+ const urlRegex = /^(https?|ftp):\/\/[^\s#$./?].\S*$/i;
69
+ return urlRegex.test(value) ? true : 'Please enter a valid URL.';
70
+ },
71
+ when: (answers) => !flags.jwksUri && !answers.useSupabaseAuth
72
+ },
73
+ {
74
+ default: false,
75
+ message: 'Do you want to add audiences?',
76
+ name: 'useAudiences',
77
+ type: 'confirm',
78
+ when: !flags.jwksUri
79
+ },
80
+ {
81
+ message: 'Enter your JWKS Audiences? (comma separated)',
82
+ name: 'jwksAudiences',
83
+ type: 'input',
84
+ when: (answers) => answers.useAudiences
85
+ }
86
+ ];
@@ -10394,7 +10394,7 @@ var ROUTES;
10394
10394
  ROUTES["ACCEPT_INVITE"] = "/api/accounts/v5/invites/accept";
10395
10395
  ROUTES["DECLINE_INVITE"] = "/api/accounts/v5/invites/decline";
10396
10396
  ROUTES["DOWNGRADE_APP_TO_TRIAL"] = "/api/accounts/v5/apps/downgrade-to-trial";
10397
- ROUTES["UPGRADE_APP_FROM_TRIAL"] = "/api/accounts/v5/apps/upgrade-to-trial";
10397
+ ROUTES["UPGRADE_APP_FROM_TRIAL"] = "/api/accounts/v5/apps/upgrade-from-trial";
10398
10398
  ROUTES["UPDATE_APP_LOCKS"] = "/api/accounts/v5/apps/update-locks";
10399
10399
  ROUTES["EXTEND_TRIAL"] = "/api/accounts/v5/apps/extend-trial";
10400
10400
  ROUTES["CREATE_APP"] = "/api/accounts/v5/apps/create";
@@ -11157,7 +11157,7 @@ var files = [
11157
11157
  "/dist",
11158
11158
  "/oclif.manifest.json"
11159
11159
  ];
11160
- var version = "0.4.2";
11160
+ var version = "0.5.0";
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";
@@ -11197,7 +11197,7 @@ var scripts = {
11197
11197
  prepare: "pnpm run build",
11198
11198
  test: "vitest",
11199
11199
  release: "pnpm build && pnpm changeset publish",
11200
- prettier: "prettier --write .",
11200
+ prettier: "prettier --write \"**/*.ts\"",
11201
11201
  version: "pnpm run readme && git add README.md",
11202
11202
  "pack:tarballs": "oclif pack tarballs --parallel"
11203
11203
  };
@@ -11207,17 +11207,18 @@ var dependencies = {
11207
11207
  "@oclif/plugin-not-found": "^3.1.4",
11208
11208
  "@oclif/plugin-warn-if-update-available": "^3.1.11",
11209
11209
  "@rollup/plugin-typescript": "^11.1.6",
11210
+ clipboardy: "^4.0.0",
11210
11211
  dotenv: "^16.4.5",
11211
11212
  inquirer: "^9.3.6",
11212
11213
  ora: "^8.0.1"
11213
11214
  };
11214
11215
  var devDependencies = {
11215
11216
  "@changesets/cli": "^2.27.7",
11216
- "@journeyapps-platform/sdk-accounts-hub": "^7.0.0",
11217
+ "@journeyapps-platform/powersync-types": "^0.22.0",
11218
+ "@journeyapps-platform/sdk-accounts-hub": "^7.0.1",
11217
11219
  "@journeyapps-platform/sdk-common": "^5.5.0",
11218
11220
  "@journeyapps-platform/sdk-powersync": "^0.22.1",
11219
- "@journeyapps-platform/types-accounts-hub": "^7.0.0",
11220
- "@journeyapps-platform/powersync-types": "^0.22.0",
11221
+ "@journeyapps-platform/types-accounts-hub": "^7.0.1",
11221
11222
  "@powersync/service-sync-rules": "^0.18.2",
11222
11223
  "@rollup/plugin-commonjs": "^26.0.1",
11223
11224
  "@rollup/plugin-json": "^6.1.0",
@@ -11231,9 +11232,9 @@ var devDependencies = {
11231
11232
  "eslint-config-prettier": "^9.1.0",
11232
11233
  "eslint-plugin-prettier": "^5.2.1",
11233
11234
  glob: "^11.0.0",
11234
- oclif: "^4.14.22",
11235
+ oclif: "^4.14.29",
11235
11236
  prettier: "^3.3.3",
11236
- rollup: "^4.21.0",
11237
+ rollup: "^4.21.2",
11237
11238
  "rollup-plugin-esbuild": "^6.1.1",
11238
11239
  shx: "^0.3.4",
11239
11240
  "strip-ansi": "^7.1.0",
@@ -17277,7 +17277,7 @@ var files = [
17277
17277
  "/dist",
17278
17278
  "/oclif.manifest.json"
17279
17279
  ];
17280
- var version = "0.4.2";
17280
+ var version = "0.5.0";
17281
17281
  var bugs = "https://github.com/powersync-ja/cli/issues";
17282
17282
  var types$2 = "dist/index.d.ts";
17283
17283
  var exports = "./lib/index.js";
@@ -17317,7 +17317,7 @@ var scripts = {
17317
17317
  prepare: "pnpm run build",
17318
17318
  test: "vitest",
17319
17319
  release: "pnpm build && pnpm changeset publish",
17320
- prettier: "prettier --write .",
17320
+ prettier: "prettier --write \"**/*.ts\"",
17321
17321
  version: "pnpm run readme && git add README.md",
17322
17322
  "pack:tarballs": "oclif pack tarballs --parallel"
17323
17323
  };
@@ -17327,17 +17327,18 @@ var dependencies$1 = {
17327
17327
  "@oclif/plugin-not-found": "^3.1.4",
17328
17328
  "@oclif/plugin-warn-if-update-available": "^3.1.11",
17329
17329
  "@rollup/plugin-typescript": "^11.1.6",
17330
+ clipboardy: "^4.0.0",
17330
17331
  dotenv: "^16.4.5",
17331
17332
  inquirer: "^9.3.6",
17332
17333
  ora: "^8.0.1"
17333
17334
  };
17334
17335
  var devDependencies = {
17335
17336
  "@changesets/cli": "^2.27.7",
17336
- "@journeyapps-platform/sdk-accounts-hub": "^7.0.0",
17337
+ "@journeyapps-platform/powersync-types": "^0.22.0",
17338
+ "@journeyapps-platform/sdk-accounts-hub": "^7.0.1",
17337
17339
  "@journeyapps-platform/sdk-common": "^5.5.0",
17338
17340
  "@journeyapps-platform/sdk-powersync": "^0.22.1",
17339
- "@journeyapps-platform/types-accounts-hub": "^7.0.0",
17340
- "@journeyapps-platform/powersync-types": "^0.22.0",
17341
+ "@journeyapps-platform/types-accounts-hub": "^7.0.1",
17341
17342
  "@powersync/service-sync-rules": "^0.18.2",
17342
17343
  "@rollup/plugin-commonjs": "^26.0.1",
17343
17344
  "@rollup/plugin-json": "^6.1.0",
@@ -17351,9 +17352,9 @@ var devDependencies = {
17351
17352
  "eslint-config-prettier": "^9.1.0",
17352
17353
  "eslint-plugin-prettier": "^5.2.1",
17353
17354
  glob: "^11.0.0",
17354
- oclif: "^4.14.22",
17355
+ oclif: "^4.14.29",
17355
17356
  prettier: "^3.3.3",
17356
- rollup: "^4.21.0",
17357
+ rollup: "^4.21.2",
17357
17358
  "rollup-plugin-esbuild": "^6.1.1",
17358
17359
  shx: "^0.3.4",
17359
17360
  "strip-ansi": "^7.1.0",
@@ -43928,6 +43929,19 @@ const processSyncRules = async () => {
43928
43929
  org_id: ORG_ID
43929
43930
  });
43930
43931
  };
43932
+ const generateDevToken = async (userId, expiresInSeconds = 43200) => {
43933
+ checkOrgId(ORG_ID);
43934
+ checkProjectId(PROJECT_ID);
43935
+ checkInstanceId(INSTANCE_ID);
43936
+ const result = await powerSyncClient().generateDevToken({
43937
+ app_id: PROJECT_ID,
43938
+ expiresInSeconds,
43939
+ id: INSTANCE_ID,
43940
+ org_id: ORG_ID,
43941
+ subject: userId
43942
+ });
43943
+ return result.token;
43944
+ };
43931
43945
  const waitForStatusChange = async (instanceId) => {
43932
43946
  const interval = 5e3;
43933
43947
  try {
@@ -43946,4 +43960,4 @@ const waitForStatusChange = async (instanceId) => {
43946
43960
  }
43947
43961
  };
43948
43962
 
43949
- export { ENV_VARIABLES, SqlSyncRules, StaticSchema, createInstance, deactivateInstance, deployInstance, deploySyncRules, destroyInstance, getInstanceConfig, getInstanceDiagnostics, getInstanceSchema, getInstanceStatus, getInstancesList, getRegions, powerSyncClient, processSyncRules, schemaGenerators, testConnection, validateSyncRules, waitForStatusChange };
43963
+ export { ENV_VARIABLES, SqlSyncRules, StaticSchema, createInstance, deactivateInstance, deployInstance, deploySyncRules, destroyInstance, generateDevToken, getInstanceConfig, getInstanceDiagnostics, getInstanceSchema, getInstanceStatus, getInstancesList, getRegions, powerSyncClient, processSyncRules, schemaGenerators, testConnection, validateSyncRules, waitForStatusChange };
@@ -18,7 +18,7 @@ var files = [
18
18
  "/dist",
19
19
  "/oclif.manifest.json"
20
20
  ];
21
- var version = "0.4.2";
21
+ var version = "0.5.0";
22
22
  var bugs = "https://github.com/powersync-ja/cli/issues";
23
23
  var types = "dist/index.d.ts";
24
24
  var exports = "./lib/index.js";
@@ -58,7 +58,7 @@ var scripts = {
58
58
  prepare: "pnpm run build",
59
59
  test: "vitest",
60
60
  release: "pnpm build && pnpm changeset publish",
61
- prettier: "prettier --write .",
61
+ prettier: "prettier --write \"**/*.ts\"",
62
62
  version: "pnpm run readme && git add README.md",
63
63
  "pack:tarballs": "oclif pack tarballs --parallel"
64
64
  };
@@ -68,17 +68,18 @@ var dependencies = {
68
68
  "@oclif/plugin-not-found": "^3.1.4",
69
69
  "@oclif/plugin-warn-if-update-available": "^3.1.11",
70
70
  "@rollup/plugin-typescript": "^11.1.6",
71
+ clipboardy: "^4.0.0",
71
72
  dotenv: "^16.4.5",
72
73
  inquirer: "^9.3.6",
73
74
  ora: "^8.0.1"
74
75
  };
75
76
  var devDependencies = {
76
77
  "@changesets/cli": "^2.27.7",
77
- "@journeyapps-platform/sdk-accounts-hub": "^7.0.0",
78
+ "@journeyapps-platform/powersync-types": "^0.22.0",
79
+ "@journeyapps-platform/sdk-accounts-hub": "^7.0.1",
78
80
  "@journeyapps-platform/sdk-common": "^5.5.0",
79
81
  "@journeyapps-platform/sdk-powersync": "^0.22.1",
80
- "@journeyapps-platform/types-accounts-hub": "^7.0.0",
81
- "@journeyapps-platform/powersync-types": "^0.22.0",
82
+ "@journeyapps-platform/types-accounts-hub": "^7.0.1",
82
83
  "@powersync/service-sync-rules": "^0.18.2",
83
84
  "@rollup/plugin-commonjs": "^26.0.1",
84
85
  "@rollup/plugin-json": "^6.1.0",
@@ -92,9 +93,9 @@ var devDependencies = {
92
93
  "eslint-config-prettier": "^9.1.0",
93
94
  "eslint-plugin-prettier": "^5.2.1",
94
95
  glob: "^11.0.0",
95
- oclif: "^4.14.22",
96
+ oclif: "^4.14.29",
96
97
  prettier: "^3.3.3",
97
- rollup: "^4.21.0",
98
+ rollup: "^4.21.2",
98
99
  "rollup-plugin-esbuild": "^6.1.1",
99
100
  shx: "^0.3.4",
100
101
  "strip-ansi": "^7.1.0",
package/dist/utils.d.ts CHANGED
@@ -4,3 +4,4 @@ export declare const bold: (text: string) => string;
4
4
  export declare const green: (text: string) => string;
5
5
  export declare const yellow: (text: string) => string;
6
6
  export declare const red: (text: string) => string;
7
+ export declare const convertSeconds: (seconds: number) => string;
package/dist/utils.js CHANGED
@@ -49,3 +49,16 @@ export const bold = (text) => ux.colorize('bold', text);
49
49
  export const green = (text) => ux.colorize('green', text);
50
50
  export const yellow = (text) => ux.colorize('yellow', text);
51
51
  export const red = (text) => ux.colorize('red', text);
52
+ const formatUnit = (value, unit) => `${value} ${unit}${value === 1 ? '' : 's'}`;
53
+ export const convertSeconds = (seconds) => {
54
+ if (seconds < 60)
55
+ return formatUnit(seconds, 'second');
56
+ const minutes = Math.floor(seconds / 60);
57
+ if (minutes < 60)
58
+ return formatUnit(minutes, 'minute');
59
+ const hours = Math.floor(minutes / 60);
60
+ const remainingMinutes = minutes % 60;
61
+ if (remainingMinutes === 0)
62
+ return formatUnit(hours, 'hour');
63
+ return `${formatUnit(hours, 'hour')} ${formatUnit(remainingMinutes, 'minute')}`;
64
+ };
@@ -79,6 +79,7 @@
79
79
  ],
80
80
  "flags": {
81
81
  "databaseName": {
82
+ "char": "n",
82
83
  "description": "Name of the database.",
83
84
  "name": "databaseName",
84
85
  "hasDynamicHelp": false,
@@ -86,6 +87,7 @@
86
87
  "type": "option"
87
88
  },
88
89
  "databasePassword": {
90
+ "char": "p",
89
91
  "description": "Password of the database.",
90
92
  "hidden": true,
91
93
  "name": "databasePassword",
@@ -94,6 +96,7 @@
94
96
  "type": "option"
95
97
  },
96
98
  "databaseUsername": {
99
+ "char": "u",
97
100
  "description": "Username of the database.",
98
101
  "hidden": true,
99
102
  "name": "databaseUsername",
@@ -102,13 +105,32 @@
102
105
  "type": "option"
103
106
  },
104
107
  "hostname": {
108
+ "char": "h",
105
109
  "description": "Hostname to connect to database.",
106
110
  "name": "hostname",
107
111
  "hasDynamicHelp": false,
108
112
  "multiple": false,
109
113
  "type": "option"
110
114
  },
115
+ "jwksAudiences": {
116
+ "char": "a",
117
+ "description": "JWKS audiences (comma separated).",
118
+ "name": "jwksAudiences",
119
+ "default": "",
120
+ "hasDynamicHelp": false,
121
+ "multiple": false,
122
+ "type": "option"
123
+ },
124
+ "jwksUri": {
125
+ "char": "w",
126
+ "description": "JWKS URL (must include https://).",
127
+ "name": "jwksUri",
128
+ "hasDynamicHelp": false,
129
+ "multiple": false,
130
+ "type": "option"
131
+ },
111
132
  "name": {
133
+ "char": "i",
112
134
  "description": "Name of the instance.",
113
135
  "name": "name",
114
136
  "hasDynamicHelp": false,
@@ -116,6 +138,7 @@
116
138
  "type": "option"
117
139
  },
118
140
  "port": {
141
+ "char": "o",
119
142
  "description": "Port number to connect to database.",
120
143
  "name": "port",
121
144
  "hasDynamicHelp": false,
@@ -123,16 +146,25 @@
123
146
  "type": "option"
124
147
  },
125
148
  "region": {
149
+ "char": "r",
126
150
  "description": "Region to deploy instance to.",
127
151
  "name": "region",
128
152
  "hasDynamicHelp": false,
129
153
  "multiple": false,
130
154
  "type": "option"
131
155
  },
156
+ "skipInteraction": {
157
+ "char": "s",
158
+ "description": "Skip interactivity.",
159
+ "name": "skipInteraction",
160
+ "allowNo": false,
161
+ "type": "boolean"
162
+ },
132
163
  "useSupabaseAuth": {
133
- "description": "Use Supabase for auth.",
164
+ "char": "a",
165
+ "description": "Use Supabase auth.",
134
166
  "name": "useSupabaseAuth",
135
- "allowNo": false,
167
+ "allowNo": true,
136
168
  "type": "boolean"
137
169
  }
138
170
  },
@@ -161,6 +193,7 @@
161
193
  ],
162
194
  "flags": {
163
195
  "databaseName": {
196
+ "char": "n",
164
197
  "description": "Name of the database.",
165
198
  "name": "databaseName",
166
199
  "hasDynamicHelp": false,
@@ -168,6 +201,7 @@
168
201
  "type": "option"
169
202
  },
170
203
  "databasePassword": {
204
+ "char": "p",
171
205
  "description": "Password of the database.",
172
206
  "hidden": true,
173
207
  "name": "databasePassword",
@@ -176,6 +210,7 @@
176
210
  "type": "option"
177
211
  },
178
212
  "databaseUsername": {
213
+ "char": "u",
179
214
  "description": "Username of the database.",
180
215
  "hidden": true,
181
216
  "name": "databaseUsername",
@@ -184,30 +219,49 @@
184
219
  "type": "option"
185
220
  },
186
221
  "hostname": {
222
+ "char": "h",
187
223
  "description": "Hostname to connect to database.",
188
224
  "name": "hostname",
189
225
  "hasDynamicHelp": false,
190
226
  "multiple": false,
191
227
  "type": "option"
192
228
  },
193
- "name": {
194
- "description": "Name of the instance.",
195
- "name": "name",
229
+ "jwksAudiences": {
230
+ "char": "a",
231
+ "description": "JWKS audiences (comma separated).",
232
+ "name": "jwksAudiences",
233
+ "hasDynamicHelp": false,
234
+ "multiple": false,
235
+ "type": "option"
236
+ },
237
+ "jwksUri": {
238
+ "char": "w",
239
+ "description": "JWKS URL (must include https://).",
240
+ "name": "jwksUri",
196
241
  "hasDynamicHelp": false,
197
242
  "multiple": false,
198
243
  "type": "option"
199
244
  },
200
245
  "port": {
246
+ "char": "o",
201
247
  "description": "Port number to connect to database.",
202
248
  "name": "port",
203
249
  "hasDynamicHelp": false,
204
250
  "multiple": false,
205
251
  "type": "option"
206
252
  },
253
+ "skipInteraction": {
254
+ "char": "s",
255
+ "description": "Skip interactivity.",
256
+ "name": "skipInteraction",
257
+ "allowNo": false,
258
+ "type": "boolean"
259
+ },
207
260
  "useSupabaseAuth": {
261
+ "char": "a",
208
262
  "description": "Use Supabase auth.",
209
263
  "name": "useSupabaseAuth",
210
- "allowNo": false,
264
+ "allowNo": true,
211
265
  "type": "boolean"
212
266
  }
213
267
  },
@@ -259,6 +313,47 @@
259
313
  "destroy.js"
260
314
  ]
261
315
  },
316
+ "instance:generate-dev-token": {
317
+ "aliases": [],
318
+ "args": {},
319
+ "description": "Generate a developer token using the Token subject/ User ID.",
320
+ "examples": [
321
+ "<%= config.bin %> <%= command.id %>"
322
+ ],
323
+ "flags": {
324
+ "expiresInSeconds": {
325
+ "char": "e",
326
+ "description": "The token expiry in seconds.",
327
+ "name": "expiresInSeconds",
328
+ "hasDynamicHelp": false,
329
+ "multiple": false,
330
+ "type": "option"
331
+ },
332
+ "userId": {
333
+ "char": "u",
334
+ "description": "The Token subject/User ID for the developer token",
335
+ "name": "userId",
336
+ "hasDynamicHelp": false,
337
+ "multiple": false,
338
+ "type": "option"
339
+ }
340
+ },
341
+ "hasDynamicHelp": false,
342
+ "hiddenAliases": [],
343
+ "id": "instance:generate-dev-token",
344
+ "pluginAlias": "powersync",
345
+ "pluginName": "powersync",
346
+ "pluginType": "core",
347
+ "strict": true,
348
+ "enableJsonFlag": false,
349
+ "isESM": true,
350
+ "relativePath": [
351
+ "dist",
352
+ "commands",
353
+ "instance",
354
+ "generate-dev-token.js"
355
+ ]
356
+ },
262
357
  "instance:schema": {
263
358
  "aliases": [],
264
359
  "args": {},
@@ -538,5 +633,5 @@
538
633
  ]
539
634
  }
540
635
  },
541
- "version": "0.4.2"
636
+ "version": "0.5.0"
542
637
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "/dist",
17
17
  "/oclif.manifest.json"
18
18
  ],
19
- "version": "0.4.2",
19
+ "version": "0.5.0",
20
20
  "bugs": "https://github.com/powersync-ja/cli/issues",
21
21
  "types": "dist/index.d.ts",
22
22
  "exports": "./lib/index.js",
@@ -50,17 +50,18 @@
50
50
  "@oclif/plugin-not-found": "^3.1.4",
51
51
  "@oclif/plugin-warn-if-update-available": "^3.1.11",
52
52
  "@rollup/plugin-typescript": "^11.1.6",
53
+ "clipboardy": "^4.0.0",
53
54
  "dotenv": "^16.4.5",
54
55
  "inquirer": "^9.3.6",
55
56
  "ora": "^8.0.1"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@changesets/cli": "^2.27.7",
59
- "@journeyapps-platform/sdk-accounts-hub": "^7.0.0",
60
+ "@journeyapps-platform/powersync-types": "^0.22.0",
61
+ "@journeyapps-platform/sdk-accounts-hub": "^7.0.1",
60
62
  "@journeyapps-platform/sdk-common": "^5.5.0",
61
63
  "@journeyapps-platform/sdk-powersync": "^0.22.1",
62
- "@journeyapps-platform/types-accounts-hub": "^7.0.0",
63
- "@journeyapps-platform/powersync-types": "^0.22.0",
64
+ "@journeyapps-platform/types-accounts-hub": "^7.0.1",
64
65
  "@powersync/service-sync-rules": "^0.18.2",
65
66
  "@rollup/plugin-commonjs": "^26.0.1",
66
67
  "@rollup/plugin-json": "^6.1.0",
@@ -74,9 +75,9 @@
74
75
  "eslint-config-prettier": "^9.1.0",
75
76
  "eslint-plugin-prettier": "^5.2.1",
76
77
  "glob": "^11.0.0",
77
- "oclif": "^4.14.22",
78
+ "oclif": "^4.14.29",
78
79
  "prettier": "^3.3.3",
79
- "rollup": "^4.21.0",
80
+ "rollup": "^4.21.2",
80
81
  "rollup-plugin-esbuild": "^6.1.1",
81
82
  "shx": "^0.3.4",
82
83
  "strip-ansi": "^7.1.0",
@@ -93,7 +94,7 @@
93
94
  "readme": "oclif readme && ./update-readme.sh",
94
95
  "test": "vitest",
95
96
  "release": "pnpm build && pnpm changeset publish",
96
- "prettier": "prettier --write .",
97
+ "prettier": "prettier --write \"**/*.ts\"",
97
98
  "version": "pnpm run readme && git add README.md",
98
99
  "pack:tarballs": "oclif pack tarballs --parallel"
99
100
  }