powersync 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/README.md +339 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +9 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +8 -0
  6. package/dist/commands/init.d.ts +7 -0
  7. package/dist/commands/init.js +49 -0
  8. package/dist/commands/instance/config.d.ts +6 -0
  9. package/dist/commands/instance/config.js +23 -0
  10. package/dist/commands/instance/create.d.ts +16 -0
  11. package/dist/commands/instance/create.js +163 -0
  12. package/dist/commands/instance/deploy.d.ts +15 -0
  13. package/dist/commands/instance/deploy.js +142 -0
  14. package/dist/commands/instance/destroy.d.ts +9 -0
  15. package/dist/commands/instance/destroy.js +42 -0
  16. package/dist/commands/instance/schema.d.ts +6 -0
  17. package/dist/commands/instance/schema.js +20 -0
  18. package/dist/commands/instance/set.d.ts +9 -0
  19. package/dist/commands/instance/set.js +31 -0
  20. package/dist/commands/instance/status.d.ts +6 -0
  21. package/dist/commands/instance/status.js +21 -0
  22. package/dist/commands/instance/stop.d.ts +9 -0
  23. package/dist/commands/instance/stop.js +42 -0
  24. package/dist/commands/instance/sync-rules/deploy.d.ts +10 -0
  25. package/dist/commands/instance/sync-rules/deploy.js +49 -0
  26. package/dist/commands/instance/sync-rules/generate-schema.d.ts +10 -0
  27. package/dist/commands/instance/sync-rules/generate-schema.js +55 -0
  28. package/dist/commands/instance/sync-rules/validate.d.ts +9 -0
  29. package/dist/commands/instance/sync-rules/validate.js +29 -0
  30. package/dist/commands/instances.d.ts +6 -0
  31. package/dist/commands/instances.js +20 -0
  32. package/dist/constants.d.ts +11 -0
  33. package/dist/constants.js +8 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +1 -0
  36. package/dist/powersync-sdk/accounts/api.d.ts +717 -0
  37. package/dist/powersync-sdk/accounts/api.js +182 -0
  38. package/dist/powersync-sdk/accounts/client.d.ts +1096 -0
  39. package/dist/powersync-sdk/accounts/client.js +124 -0
  40. package/dist/powersync-sdk/accounts/codecs.d.ts +32 -0
  41. package/dist/powersync-sdk/accounts/codecs.js +93 -0
  42. package/dist/powersync-sdk/accounts/index.d.ts +4 -0
  43. package/dist/powersync-sdk/accounts/index.js +4 -0
  44. package/dist/powersync-sdk/accounts/models.d.ts +260 -0
  45. package/dist/powersync-sdk/accounts/models.js +96 -0
  46. package/dist/powersync-sdk/accounts/routes.d.ts +44 -0
  47. package/dist/powersync-sdk/accounts/routes.js +45 -0
  48. package/dist/powersync-sdk/accounts/source.d.ts +76 -0
  49. package/dist/powersync-sdk/accounts/source.js +32 -0
  50. package/dist/powersync-sdk/errors/errors.d.ts +62 -0
  51. package/dist/powersync-sdk/errors/errors.js +115 -0
  52. package/dist/powersync-sdk/errors/index.d.ts +2 -0
  53. package/dist/powersync-sdk/errors/index.js +2 -0
  54. package/dist/powersync-sdk/errors/utils.d.ts +4 -0
  55. package/dist/powersync-sdk/errors/utils.js +18 -0
  56. package/dist/powersync-sdk/fetch-clients/codecs.d.ts +4 -0
  57. package/dist/powersync-sdk/fetch-clients/codecs.js +34 -0
  58. package/dist/powersync-sdk/fetch-clients/decoders.d.ts +3 -0
  59. package/dist/powersync-sdk/fetch-clients/decoders.js +35 -0
  60. package/dist/powersync-sdk/fetch-clients/definitions.d.ts +97 -0
  61. package/dist/powersync-sdk/fetch-clients/definitions.js +22 -0
  62. package/dist/powersync-sdk/fetch-clients/errors.d.ts +7 -0
  63. package/dist/powersync-sdk/fetch-clients/errors.js +19 -0
  64. package/dist/powersync-sdk/fetch-clients/index.d.ts +5 -0
  65. package/dist/powersync-sdk/fetch-clients/index.js +5 -0
  66. package/dist/powersync-sdk/fetch-clients/node-client.d.ts +9 -0
  67. package/dist/powersync-sdk/fetch-clients/node-client.js +107 -0
  68. package/dist/powersync-sdk/fetch-clients/request.d.ts +11 -0
  69. package/dist/powersync-sdk/fetch-clients/request.js +138 -0
  70. package/dist/powersync-sdk/fetch-clients/streaming.d.ts +65 -0
  71. package/dist/powersync-sdk/fetch-clients/streaming.js +99 -0
  72. package/dist/powersync-sdk/fetch-clients/utils.d.ts +13 -0
  73. package/dist/powersync-sdk/fetch-clients/utils.js +43 -0
  74. package/dist/powersync-sdk/fetch-clients/web-client.d.ts +14 -0
  75. package/dist/powersync-sdk/fetch-clients/web-client.js +56 -0
  76. package/dist/powersync-sdk/json/index.d.ts +4 -0
  77. package/dist/powersync-sdk/json/index.js +3 -0
  78. package/dist/powersync-sdk/json/json.d.ts +5 -0
  79. package/dist/powersync-sdk/json/json.js +35 -0
  80. package/dist/powersync-sdk/json/json_container.d.ts +18 -0
  81. package/dist/powersync-sdk/json/json_container.js +28 -0
  82. package/dist/powersync-sdk/json/json_stringify.d.ts +36 -0
  83. package/dist/powersync-sdk/json/json_stringify.js +162 -0
  84. package/dist/powersync-sdk/powersync/client.d.ts +449 -0
  85. package/dist/powersync-sdk/powersync/client.js +53 -0
  86. package/dist/powersync-sdk/powersync/config/HostedConfig.d.ts +327 -0
  87. package/dist/powersync-sdk/powersync/config/HostedConfig.js +92 -0
  88. package/dist/powersync-sdk/powersync/config/PowerSyncConfig.d.ts +211 -0
  89. package/dist/powersync-sdk/powersync/config/PowerSyncConfig.js +97 -0
  90. package/dist/powersync-sdk/powersync/config/normalize.d.ts +32 -0
  91. package/dist/powersync-sdk/powersync/config/normalize.js +85 -0
  92. package/dist/powersync-sdk/powersync/definitions.d.ts +149 -0
  93. package/dist/powersync-sdk/powersync/definitions.js +97 -0
  94. package/dist/powersync-sdk/powersync/index.d.ts +8 -0
  95. package/dist/powersync-sdk/powersync/index.js +8 -0
  96. package/dist/powersync-sdk/powersync/internal_routes.d.ts +247 -0
  97. package/dist/powersync-sdk/powersync/internal_routes.js +69 -0
  98. package/dist/powersync-sdk/powersync/routes.d.ts +779 -0
  99. package/dist/powersync-sdk/powersync/routes.js +191 -0
  100. package/dist/powersync-sdk/sdk-clients/endpoints.d.ts +31 -0
  101. package/dist/powersync-sdk/sdk-clients/endpoints.js +48 -0
  102. package/dist/powersync-sdk/sdk-clients/index.d.ts +3 -0
  103. package/dist/powersync-sdk/sdk-clients/index.js +3 -0
  104. package/dist/powersync-sdk/sdk-clients/pagination.d.ts +14 -0
  105. package/dist/powersync-sdk/sdk-clients/pagination.js +21 -0
  106. package/dist/powersync-sdk/sdk-clients/sdk-client.d.ts +17 -0
  107. package/dist/powersync-sdk/sdk-clients/sdk-client.js +30 -0
  108. package/dist/powersync-sdk/streaming/bson/buffer-array.d.ts +31 -0
  109. package/dist/powersync-sdk/streaming/bson/buffer-array.js +79 -0
  110. package/dist/powersync-sdk/streaming/bson/constants.d.ts +2 -0
  111. package/dist/powersync-sdk/streaming/bson/constants.js +1 -0
  112. package/dist/powersync-sdk/streaming/bson/decoder.d.ts +10 -0
  113. package/dist/powersync-sdk/streaming/bson/decoder.js +62 -0
  114. package/dist/powersync-sdk/streaming/bson/encoder.d.ts +10 -0
  115. package/dist/powersync-sdk/streaming/bson/encoder.js +23 -0
  116. package/dist/powersync-sdk/streaming/bson/header.d.ts +11 -0
  117. package/dist/powersync-sdk/streaming/bson/header.js +52 -0
  118. package/dist/powersync-sdk/streaming/bson/index.d.ts +5 -0
  119. package/dist/powersync-sdk/streaming/bson/index.js +5 -0
  120. package/dist/powersync-sdk/streaming/core/backpressure.d.ts +15 -0
  121. package/dist/powersync-sdk/streaming/core/backpressure.js +34 -0
  122. package/dist/powersync-sdk/streaming/core/cross-stream.d.ts +6 -0
  123. package/dist/powersync-sdk/streaming/core/cross-stream.js +17 -0
  124. package/dist/powersync-sdk/streaming/core/index.d.ts +4 -0
  125. package/dist/powersync-sdk/streaming/core/index.js +4 -0
  126. package/dist/powersync-sdk/streaming/core/node-utils.d.ts +7 -0
  127. package/dist/powersync-sdk/streaming/core/node-utils.js +11 -0
  128. package/dist/powersync-sdk/streaming/core/transformers.d.ts +41 -0
  129. package/dist/powersync-sdk/streaming/core/transformers.js +70 -0
  130. package/dist/powersync-sdk/streaming/core/utils.d.ts +36 -0
  131. package/dist/powersync-sdk/streaming/core/utils.js +66 -0
  132. package/dist/powersync-sdk/streaming/index.d.ts +3 -0
  133. package/dist/powersync-sdk/streaming/index.js +3 -0
  134. package/dist/powersync-sdk/streaming/web.d.ts +4 -0
  135. package/dist/powersync-sdk/streaming/web.js +4 -0
  136. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.d.ts +2 -0
  137. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.js +36 -0
  138. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.d.ts +2 -0
  139. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.js +58 -0
  140. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.d.ts +18 -0
  141. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.js +348 -0
  142. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.d.ts +11 -0
  143. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.js +118 -0
  144. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.d.ts +11 -0
  145. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.js +131 -0
  146. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.d.ts +11 -0
  147. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.js +134 -0
  148. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.d.ts +11 -0
  149. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.js +122 -0
  150. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.d.ts +11 -0
  151. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.js +158 -0
  152. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.d.ts +14 -0
  153. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.js +165 -0
  154. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.d.ts +11 -0
  155. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.js +207 -0
  156. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.d.ts +30 -0
  157. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.js +29 -0
  158. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.d.ts +2 -0
  159. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.js +111 -0
  160. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.d.ts +9 -0
  161. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.js +9 -0
  162. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.d.ts +5 -0
  163. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.js +9 -0
  164. package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.d.ts +12 -0
  165. package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.js +35 -0
  166. package/dist/powersync-sdk/sync-rules/ExpressionType.d.ts +33 -0
  167. package/dist/powersync-sdk/sync-rules/ExpressionType.js +62 -0
  168. package/dist/powersync-sdk/sync-rules/IdSequence.d.ts +4 -0
  169. package/dist/powersync-sdk/sync-rules/IdSequence.js +7 -0
  170. package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.d.ts +12 -0
  171. package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.js +38 -0
  172. package/dist/powersync-sdk/sync-rules/SchemaGenerator.d.ts +14 -0
  173. package/dist/powersync-sdk/sync-rules/SchemaGenerator.js +24 -0
  174. package/dist/powersync-sdk/sync-rules/SourceTableInterface.d.ts +5 -0
  175. package/dist/powersync-sdk/sync-rules/SourceTableInterface.js +1 -0
  176. package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.d.ts +37 -0
  177. package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.js +116 -0
  178. package/dist/powersync-sdk/sync-rules/SqlDataQuery.d.ts +39 -0
  179. package/dist/powersync-sdk/sync-rules/SqlDataQuery.js +245 -0
  180. package/dist/powersync-sdk/sync-rules/SqlParameterQuery.d.ts +43 -0
  181. package/dist/powersync-sdk/sync-rules/SqlParameterQuery.js +254 -0
  182. package/dist/powersync-sdk/sync-rules/SqlSyncRules.d.ts +52 -0
  183. package/dist/powersync-sdk/sync-rules/SqlSyncRules.js +252 -0
  184. package/dist/powersync-sdk/sync-rules/StaticSchema.d.ts +26 -0
  185. package/dist/powersync-sdk/sync-rules/StaticSchema.js +71 -0
  186. package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.d.ts +24 -0
  187. package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.js +71 -0
  188. package/dist/powersync-sdk/sync-rules/TablePattern.d.ts +17 -0
  189. package/dist/powersync-sdk/sync-rules/TablePattern.js +56 -0
  190. package/dist/powersync-sdk/sync-rules/TableQuerySchema.d.ts +9 -0
  191. package/dist/powersync-sdk/sync-rules/TableQuerySchema.js +41 -0
  192. package/dist/powersync-sdk/sync-rules/errors.d.ts +22 -0
  193. package/dist/powersync-sdk/sync-rules/errors.js +60 -0
  194. package/dist/powersync-sdk/sync-rules/generators.d.ts +6 -0
  195. package/dist/powersync-sdk/sync-rules/generators.js +6 -0
  196. package/dist/powersync-sdk/sync-rules/index.d.ts +17 -0
  197. package/dist/powersync-sdk/sync-rules/index.js +17 -0
  198. package/dist/powersync-sdk/sync-rules/json_schema.d.ts +3 -0
  199. package/dist/powersync-sdk/sync-rules/json_schema.js +50 -0
  200. package/dist/powersync-sdk/sync-rules/sql_filters.d.ts +91 -0
  201. package/dist/powersync-sdk/sync-rules/sql_filters.js +491 -0
  202. package/dist/powersync-sdk/sync-rules/sql_functions.d.ts +53 -0
  203. package/dist/powersync-sdk/sync-rules/sql_functions.js +755 -0
  204. package/dist/powersync-sdk/sync-rules/sql_support.d.ts +22 -0
  205. package/dist/powersync-sdk/sync-rules/sql_support.js +208 -0
  206. package/dist/powersync-sdk/sync-rules/types.d.ts +174 -0
  207. package/dist/powersync-sdk/sync-rules/types.js +9 -0
  208. package/dist/powersync-sdk/sync-rules/utils.d.ts +45 -0
  209. package/dist/powersync-sdk/sync-rules/utils.js +163 -0
  210. package/dist/service/accounts.client.d.ts +26 -0
  211. package/dist/service/accounts.client.js +26 -0
  212. package/dist/service/powersync.client.d.ts +269 -0
  213. package/dist/service/powersync.client.js +135 -0
  214. package/dist/service/types.d.ts +69 -0
  215. package/dist/service/types.js +1 -0
  216. package/dist/service/utils.d.ts +5 -0
  217. package/dist/service/utils.js +7 -0
  218. package/dist/utils.d.ts +6 -0
  219. package/dist/utils.js +52 -0
  220. package/oclif.manifest.json +514 -0
  221. package/package.json +81 -0
package/README.md ADDED
@@ -0,0 +1,339 @@
1
+ # PowerSync CLI
2
+
3
+ <!-- toc -->
4
+ * [PowerSync CLI](#powersync-cli)
5
+ * [Usage](#usage)
6
+ * [Commands](#commands)
7
+ <!-- tocstop -->
8
+
9
+ # Usage
10
+ <!-- usage -->
11
+ ```sh-session
12
+ $ npm install -g powersync
13
+ $ powersync COMMAND
14
+ running command...
15
+ $ powersync (--version)
16
+ powersync/0.1.0 linux-x64 node-v20.10.0
17
+ $ powersync --help [COMMAND]
18
+ USAGE
19
+ $ powersync COMMAND
20
+ ...
21
+ ```
22
+ <!-- usagestop -->
23
+
24
+ # Commands
25
+
26
+ <!-- commands -->
27
+ * [`powersync help [COMMANDS]`](#powersync-help-commands)
28
+ * [`powersync init`](#powersync-init)
29
+ * [`powersync instance config`](#powersync-instance-config)
30
+ * [`powersync instance create`](#powersync-instance-create)
31
+ * [`powersync instance deploy`](#powersync-instance-deploy)
32
+ * [`powersync instance destroy`](#powersync-instance-destroy)
33
+ * [`powersync instance schema`](#powersync-instance-schema)
34
+ * [`powersync instance set`](#powersync-instance-set)
35
+ * [`powersync instance status`](#powersync-instance-status)
36
+ * [`powersync instance stop`](#powersync-instance-stop)
37
+ * [`powersync instance sync-rules deploy`](#powersync-instance-sync-rules-deploy)
38
+ * [`powersync instance sync-rules generate-schema`](#powersync-instance-sync-rules-generate-schema)
39
+ * [`powersync instance sync-rules validate`](#powersync-instance-sync-rules-validate)
40
+ * [`powersync instances`](#powersync-instances)
41
+
42
+ ## `powersync help [COMMANDS]`
43
+
44
+ Display help for powersync.
45
+
46
+ ```
47
+ USAGE
48
+ $ powersync help [COMMANDS] [-n]
49
+
50
+ ARGUMENTS
51
+ COMMANDS Command to show help for.
52
+
53
+ FLAGS
54
+ -n, --nested-commands Include all nested commands in the output.
55
+
56
+ DESCRIPTION
57
+ Display help for powersync.
58
+ ```
59
+
60
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.12/src/commands/help.ts)_
61
+
62
+ ## `powersync init`
63
+
64
+ Initialize the CLI
65
+
66
+ ```
67
+ USAGE
68
+ $ powersync init
69
+
70
+ DESCRIPTION
71
+ Initialize the CLI
72
+
73
+ EXAMPLES
74
+ $ powersync init
75
+ ```
76
+
77
+ _See code: [src/commands/init.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/init.ts)_
78
+
79
+ ## `powersync instance config`
80
+
81
+ get the instance config
82
+
83
+ ```
84
+ USAGE
85
+ $ powersync instance config
86
+
87
+ DESCRIPTION
88
+ get the instance config
89
+
90
+ EXAMPLES
91
+ $ powersync instance config
92
+ ```
93
+
94
+ _See code: [src/commands/instance/config.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/config.ts)_
95
+
96
+ ## `powersync instance create`
97
+
98
+ create a new instance
99
+
100
+ ```
101
+ USAGE
102
+ $ powersync instance create [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
103
+ [--region US|EU] [--useSupabaseAuth]
104
+
105
+ FLAGS
106
+ --databaseName=<value> Name of the DB
107
+ --hostname=<value> Hostname to connect to DB
108
+ --name=<value> Name of the instance
109
+ --port=<value> Port number to connect to DB
110
+ --region=<option> Region to deploy instance to
111
+ <options: US|EU>
112
+ --useSupabaseAuth Use Supabase for auth
113
+
114
+ DESCRIPTION
115
+ create a new instance
116
+
117
+ EXAMPLES
118
+ $ powersync instance create
119
+ ```
120
+
121
+ _See code: [src/commands/instance/create.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/create.ts)_
122
+
123
+ ## `powersync instance deploy`
124
+
125
+ deploy changes to an existing instance
126
+
127
+ ```
128
+ USAGE
129
+ $ powersync instance deploy [--databaseName <value>] [--hostname <value>] [--name <value>] [--port <value>]
130
+ [--useSupabaseAuth]
131
+
132
+ FLAGS
133
+ --databaseName=<value> Name of the DB
134
+ --hostname=<value> Hostname to connect to DB
135
+ --name=<value> Name of the instance
136
+ --port=<value> Port number to connect to DB
137
+ --useSupabaseAuth Use Supabase auth
138
+
139
+ DESCRIPTION
140
+ deploy changes to an existing instance
141
+
142
+ EXAMPLES
143
+ $ powersync instance deploy
144
+ ```
145
+
146
+ _See code: [src/commands/instance/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/deploy.ts)_
147
+
148
+ ## `powersync instance destroy`
149
+
150
+ destroy the current instance - THIS CANNOT BE UNDONE
151
+
152
+ ```
153
+ USAGE
154
+ $ powersync instance destroy [-s]
155
+
156
+ FLAGS
157
+ -s, --skipConfirmation Ignore confirmation question
158
+
159
+ DESCRIPTION
160
+ destroy the current instance - THIS CANNOT BE UNDONE
161
+
162
+ EXAMPLES
163
+ $ powersync instance destroy
164
+
165
+ $ powersync instance destroy --instanceId=1234
166
+ ```
167
+
168
+ _See code: [src/commands/instance/destroy.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/destroy.ts)_
169
+
170
+ ## `powersync instance schema`
171
+
172
+ view the schema of the current instance
173
+
174
+ ```
175
+ USAGE
176
+ $ powersync instance schema
177
+
178
+ DESCRIPTION
179
+ view the schema of the current instance
180
+
181
+ EXAMPLES
182
+ $ powersync instance schema
183
+ ```
184
+
185
+ _See code: [src/commands/instance/schema.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/schema.ts)_
186
+
187
+ ## `powersync instance set`
188
+
189
+ set the current instance
190
+
191
+ ```
192
+ USAGE
193
+ $ powersync instance set [-n <value>]
194
+
195
+ FLAGS
196
+ -n, --instanceId=<value> instance id to change to
197
+
198
+ DESCRIPTION
199
+ set the current instance
200
+
201
+ EXAMPLES
202
+ $ powersync instance set
203
+
204
+ $ powersync instance set --instanceId=1234
205
+ ```
206
+
207
+ _See code: [src/commands/instance/set.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/set.ts)_
208
+
209
+ ## `powersync instance status`
210
+
211
+ view the status of the current instance
212
+
213
+ ```
214
+ USAGE
215
+ $ powersync instance status
216
+
217
+ DESCRIPTION
218
+ view the status of the current instance
219
+
220
+ EXAMPLES
221
+ $ powersync instance status
222
+ ```
223
+
224
+ _See code: [src/commands/instance/status.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/status.ts)_
225
+
226
+ ## `powersync instance stop`
227
+
228
+ stop the current instance
229
+
230
+ ```
231
+ USAGE
232
+ $ powersync instance stop [-s]
233
+
234
+ FLAGS
235
+ -s, --skipConfirmation Ignore confirmation question
236
+
237
+ DESCRIPTION
238
+ stop the current instance
239
+
240
+ EXAMPLES
241
+ $ powersync instance stop
242
+
243
+ $ powersync instance stop --instanceId=1234
244
+ ```
245
+
246
+ _See code: [src/commands/instance/stop.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/stop.ts)_
247
+
248
+ ## `powersync instance sync-rules deploy`
249
+
250
+ deploy sync rules from a local file to the current instance
251
+
252
+ ```
253
+ USAGE
254
+ $ powersync instance sync-rules deploy -f <value> [-s]
255
+
256
+ FLAGS
257
+ -f, --filePath=<value> (required) Path to the file
258
+ -s, --skipConfirmation Ignore confirmation question
259
+
260
+ DESCRIPTION
261
+ deploy sync rules from a local file to the current instance
262
+
263
+ EXAMPLES
264
+ $ powersync instance sync-rules deploy
265
+
266
+ $ powersync instance sync-rules deploy --filePath path/to/file
267
+
268
+ $ powersync instance sync-rules deploy -f path/to/file
269
+ ```
270
+
271
+ _See code: [src/commands/instance/sync-rules/deploy.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/sync-rules/deploy.ts)_
272
+
273
+ ## `powersync instance sync-rules generate-schema`
274
+
275
+ generate schema in your language from sync rules
276
+
277
+ ```
278
+ USAGE
279
+ $ powersync instance sync-rules generate-schema -f <value> [-l js|dart]
280
+
281
+ FLAGS
282
+ -f, --filePath=<value> (required) Path to the file
283
+ -l, --language=<option> Choose language for output
284
+ <options: js|dart>
285
+
286
+ DESCRIPTION
287
+ generate schema in your language from sync rules
288
+
289
+ EXAMPLES
290
+ $ powersync instance sync-rules generate-schema
291
+
292
+ $ powersync instance sync-rules generate-schema --filePath path/to/file
293
+
294
+ $ powersync instance sync-rules generate-schema -f path/to/file
295
+ ```
296
+
297
+ _See code: [src/commands/instance/sync-rules/generate-schema.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/sync-rules/generate-schema.ts)_
298
+
299
+ ## `powersync instance sync-rules validate`
300
+
301
+ validate sync rules from a local file
302
+
303
+ ```
304
+ USAGE
305
+ $ powersync instance sync-rules validate -f <value>
306
+
307
+ FLAGS
308
+ -f, --filePath=<value> (required) Path to the file
309
+
310
+ DESCRIPTION
311
+ validate sync rules from a local file
312
+
313
+ EXAMPLES
314
+ $ powersync instance sync-rules validate
315
+
316
+ $ powersync instance sync-rules validate --filePath path/to/file
317
+
318
+ $ powersync instance sync-rules validate -f path/to/file
319
+ ```
320
+
321
+ _See code: [src/commands/instance/sync-rules/validate.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instance/sync-rules/validate.ts)_
322
+
323
+ ## `powersync instances`
324
+
325
+ view list of instances
326
+
327
+ ```
328
+ USAGE
329
+ $ powersync instances
330
+
331
+ DESCRIPTION
332
+ view list of instances
333
+
334
+ EXAMPLES
335
+ $ powersync instances
336
+ ```
337
+
338
+ _See code: [src/commands/instances.ts](https://github.com/powersync-ja/cli/blob/v0.1.0/src/commands/instances.ts)_
339
+ <!-- commandsstop -->
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2
+
3
+ // eslint-disable-next-line node/shebang
4
+ async function main() {
5
+ const { execute } = await import('@oclif/core');
6
+ await execute({ development: true, dir: import.meta.url });
7
+ }
8
+
9
+ await main();
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ async function main() {
4
+ const { execute } = await import('@oclif/core');
5
+ await execute({ dir: import.meta.url });
6
+ }
7
+
8
+ await main();
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ import 'dotenv/config';
3
+ export default class Init extends Command {
4
+ static description: string;
5
+ static examples: string[];
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,49 @@
1
+ import { Command, ux } from '@oclif/core';
2
+ import 'dotenv/config';
3
+ import inquirer from 'inquirer';
4
+ import fs from 'node:fs';
5
+ import * as AccountsClient from '../service/accounts.client.js';
6
+ import { green, red } from '../utils.js';
7
+ export default class Init extends Command {
8
+ static description = 'Initialize the CLI';
9
+ static examples = ['<%= config.bin %> <%= command.id %>'];
10
+ async run() {
11
+ const cardinalTokenQuestions = [
12
+ {
13
+ message: 'What is your cardinal token? Contact support to get one.',
14
+ name: 'cardinalToken',
15
+ type: 'password',
16
+ validate(value) {
17
+ return value.length > 0 ? true : 'Please enter your application ID.';
18
+ }
19
+ }
20
+ ];
21
+ const cardinalTokenAnswers = await inquirer.prompt(cardinalTokenQuestions);
22
+ const organizations = await AccountsClient.getOrgs(cardinalTokenAnswers.cardinalToken);
23
+ if (organizations.count > 1) {
24
+ return ux.error(red('Multiple organizations found. Please contact support for assistance.'), { exit: 1 });
25
+ }
26
+ const apps = await AccountsClient.getPowerSyncApps(cardinalTokenAnswers.cardinalToken);
27
+ if (apps.length === 0) {
28
+ return ux.error(red('No apps found. Please contact support for assistance.'), { exit: 1 });
29
+ }
30
+ const appQuestions = [
31
+ {
32
+ choices: apps,
33
+ message: 'Which app would you like to use?',
34
+ name: 'appId',
35
+ type: 'list'
36
+ }
37
+ ];
38
+ const appAnswers = await inquirer.prompt(appQuestions);
39
+ const orgId = organizations.objects[0].id;
40
+ if (fs.existsSync('.env')) {
41
+ fs.unlinkSync('.env');
42
+ }
43
+ fs.writeFileSync('.env', `ORG_ID=${orgId}\nAPP_ID=${appAnswers.appId}\nCARDINAL_TOKEN=${cardinalTokenAnswers.cardinalToken}\n`);
44
+ ux.log(green('CLI has been initialized'));
45
+ ux.log(`run ${green(`"${this.config.bin} instances"`)} to view your instances or`);
46
+ ux.log(`run ${green(`"${this.config.bin} instance create"`)} to create an instance or`);
47
+ ux.log(`run ${green(`"${this.config.bin} instance set"`)} to use an already created instance`);
48
+ }
49
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class InstanceConfig extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,23 @@
1
+ import { Command, ux } from '@oclif/core';
2
+ import * as PowerSyncClient from '../../service/powersync.client.js';
3
+ import { checkForValidEnvFile, red } from '../../utils.js';
4
+ export default class InstanceConfig extends Command {
5
+ static description = 'get the instance config';
6
+ static examples = ['<%= config.bin %> <%= command.id %>'];
7
+ async run() {
8
+ checkForValidEnvFile(this.config.bin, true);
9
+ const config = await PowerSyncClient.getInstanceConfig();
10
+ if (!config) {
11
+ return this.log(red('No instance config found.'));
12
+ }
13
+ const formattedConfig = {
14
+ auth: config.config?.client_auth,
15
+ // Assume there is only a single connection
16
+ connection: config.config?.replication?.connections[0],
17
+ id: config.id,
18
+ name: config.name,
19
+ region: config.config?.region
20
+ };
21
+ ux.styledObject(formattedConfig, ['id', 'name', 'region', 'connection', 'auth']);
22
+ }
23
+ }
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class InstanceCreate extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ databaseName: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ databaseUsername: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
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>;
11
+ port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ region: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,163 @@
1
+ /* eslint-disable camelcase */
2
+ import { Command, Flags, ux } from '@oclif/core';
3
+ import inquirer from 'inquirer';
4
+ import ora from 'ora';
5
+ import { REGIONS } from '../../constants.js';
6
+ import * as PowerSyncClient from '../../service/powersync.client.js';
7
+ import { bold, checkForValidEnvFile, green, red, updateEnvFileVariableValue } from '../../utils.js';
8
+ export default class InstanceCreate extends Command {
9
+ static description = 'create a new instance';
10
+ static examples = ['<%= config.bin %> <%= command.id %>'];
11
+ static flags = {
12
+ databaseName: Flags.string({ description: 'Name of the DB' }),
13
+ databasePassword: Flags.string({ description: 'Password of the DB', hidden: true }),
14
+ databaseUsername: Flags.string({ description: 'Username of the DB', hidden: true }),
15
+ hostname: Flags.string({ description: 'Hostname to connect to DB' }),
16
+ name: Flags.string({ description: 'Name of the instance' }),
17
+ port: Flags.integer({ description: 'Port number to connect to DB' }),
18
+ region: Flags.string({ description: 'Region to deploy instance to', options: REGIONS }),
19
+ useSupabaseAuth: Flags.boolean({ description: 'Use Supabase for auth' })
20
+ };
21
+ async run() {
22
+ checkForValidEnvFile(this.config.bin, true);
23
+ const { flags } = await this.parse(InstanceCreate);
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,
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.';
90
+ },
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.';
107
+ },
108
+ when: (answers) => !answers.useSupabaseAuth
109
+ }
110
+ ];
111
+ const answers = await inquirer.prompt(questions);
112
+ const instanceName = flags.name || answers.name;
113
+ const port = flags.port || answers.port;
114
+ const password = flags.databasePassword || answers.databasePassword;
115
+ const hostname = flags.hostname || answers.hostname;
116
+ const databaseName = flags.databaseName || answers.databaseName;
117
+ const databaseUsername = flags.databaseUsername || answers.databaseUsername;
118
+ const region = flags.region || answers.region;
119
+ const useSupabaseAuth = flags.useSupabaseAuth || answers.useSupabaseAuth;
120
+ const config = {
121
+ client_auth: {
122
+ jwks_uri: answers.jwksUri || undefined,
123
+ supabase: useSupabaseAuth
124
+ },
125
+ region: region.toLowerCase(),
126
+ replication: {
127
+ connections: [
128
+ {
129
+ database: databaseName,
130
+ debug_api: false,
131
+ hostname,
132
+ name: 'Default',
133
+ password: {
134
+ secret: password
135
+ },
136
+ port: Number(port),
137
+ sslmode: 'verify-full',
138
+ tag: 'default',
139
+ type: 'postgresql',
140
+ username: databaseUsername
141
+ }
142
+ ]
143
+ }
144
+ };
145
+ const spinner = ora({
146
+ prefixText: 'Creating instance.\n',
147
+ spinner: 'moon',
148
+ suffixText: '\nThis may take a few minutes.\n'
149
+ });
150
+ spinner.start();
151
+ const instance = await PowerSyncClient.createInstance(instanceName);
152
+ await PowerSyncClient.deployInstance(config, instance.id);
153
+ let status = 'pending';
154
+ status = await PowerSyncClient.waitForStatusChange(instance.id);
155
+ spinner.stop();
156
+ if (status === 'failed') {
157
+ return ux.error(red(`There was an error creating the instance. Please try again.`), { exit: 1 });
158
+ }
159
+ updateEnvFileVariableValue(PowerSyncClient.ENV_VARIABLES.INSTANCE_ID, instance.id);
160
+ ux.log(green(`Instance with id ${bold(instance.id)} has been created successfully.`));
161
+ ux.log(green(`Current instance has been set to ${instance.id}`));
162
+ }
163
+ }
@@ -0,0 +1,15 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class InstanceDeploy extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ databaseName: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ databasePassword: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
+ databaseUsername: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
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>;
11
+ port: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ useSupabaseAuth: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
+ };
14
+ run(): Promise<void>;
15
+ }