powersync 0.2.1 → 0.2.3

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.
@@ -1,8 +1,279 @@
1
- const generateHeader = (bearerToken) => ({
2
- Accept: "application/json",
3
- Authorization: `Bearer ${bearerToken}`,
4
- ContentType: "application/json"
5
- });
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ var dist = {};
4
+
5
+ var definitions = {};
6
+
7
+ var signupActions = {};
8
+
9
+ Object.defineProperty(signupActions, "__esModule", { value: true });
10
+ signupActions.SignupActionSource = void 0;
11
+ var SignupActionSource;
12
+ (function (SignupActionSource) {
13
+ SignupActionSource["CLICK"] = "click";
14
+ SignupActionSource["INPUT"] = "input";
15
+ SignupActionSource["KEYPRESS"] = "keypress";
16
+ SignupActionSource["SYSTEM"] = "system";
17
+ })(SignupActionSource || (signupActions.SignupActionSource = SignupActionSource = {}));
18
+
19
+ var userActions = {};
20
+
21
+ Object.defineProperty(userActions, "__esModule", { value: true });
22
+ userActions.ACTION_STATUS = void 0;
23
+ var ACTION_STATUS;
24
+ (function (ACTION_STATUS) {
25
+ ACTION_STATUS["SUCCESS"] = "SUCCESS";
26
+ ACTION_STATUS["FAILURE"] = "FAILURE";
27
+ })(ACTION_STATUS || (userActions.ACTION_STATUS = ACTION_STATUS = {}));
28
+
29
+ var serviceActions = {};
30
+
31
+ Object.defineProperty(serviceActions, "__esModule", { value: true });
32
+ serviceActions.UserActionSource = void 0;
33
+ /**
34
+ * The source application that triggered the service user action
35
+ */
36
+ var UserActionSource;
37
+ (function (UserActionSource) {
38
+ UserActionSource["POWERSYNC_CLI"] = "POWERSYNC_CLI";
39
+ })(UserActionSource || (serviceActions.UserActionSource = UserActionSource = {}));
40
+
41
+ var generics = {};
42
+
43
+ Object.defineProperty(generics, "__esModule", { value: true });
44
+
45
+ var events = {};
46
+
47
+ Object.defineProperty(events, "__esModule", { value: true });
48
+ events.FLIGHT_LOG_EVENT = events.FLIGHT_LOG_EVENT_VERSION = void 0;
49
+ var FLIGHT_LOG_EVENT_VERSION;
50
+ (function (FLIGHT_LOG_EVENT_VERSION) {
51
+ FLIGHT_LOG_EVENT_VERSION["V1"] = "V1";
52
+ })(FLIGHT_LOG_EVENT_VERSION || (events.FLIGHT_LOG_EVENT_VERSION = FLIGHT_LOG_EVENT_VERSION = {}));
53
+ var FLIGHT_LOG_EVENT;
54
+ (function (FLIGHT_LOG_EVENT) {
55
+ FLIGHT_LOG_EVENT["USER_ACTION"] = "USER_METRICS.ACTION";
56
+ FLIGHT_LOG_EVENT["SIGNUP_ACTION"] = "USER_METRICS.SIGNUP_ACTION";
57
+ FLIGHT_LOG_EVENT["SERVICE_ACTION"] = "USER_METRICS.SERVICE_ACTION";
58
+ })(FLIGHT_LOG_EVENT || (events.FLIGHT_LOG_EVENT = FLIGHT_LOG_EVENT = {}));
59
+
60
+ var routes = {};
61
+
62
+ Object.defineProperty(routes, "__esModule", { value: true });
63
+ routes.Routes = void 0;
64
+ var Routes;
65
+ (function (Routes) {
66
+ Routes["LOG_ACTIONS"] = "/api/v1/collection/log-actions";
67
+ Routes["LOG_SIGNUP_ACTIONS"] = "/api/v1/collection/log-signup-actions";
68
+ Routes["LOG_SERVICE_USER_ACTIONS"] = "/api/v1/collection/log-service-user-actions";
69
+ })(Routes || (routes.Routes = Routes = {}));
70
+
71
+ var headers = {};
72
+
73
+ Object.defineProperty(headers, "__esModule", { value: true });
74
+ headers.MetricSourceVersionHeader = headers.MetricSourceHeader = void 0;
75
+ // Note these are lowercase since https headers are converted to lowercase anyway
76
+ headers.MetricSourceHeader = 'x-journey-metric-source';
77
+ headers.MetricSourceVersionHeader = 'x-journey-metric-source-version';
78
+
79
+ (function (exports) {
80
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
81
+ if (k2 === undefined) k2 = k;
82
+ var desc = Object.getOwnPropertyDescriptor(m, k);
83
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
84
+ desc = { enumerable: true, get: function() { return m[k]; } };
85
+ }
86
+ Object.defineProperty(o, k2, desc);
87
+ }) : (function(o, m, k, k2) {
88
+ if (k2 === undefined) k2 = k;
89
+ o[k2] = m[k];
90
+ }));
91
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
92
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
93
+ };
94
+ Object.defineProperty(exports, "__esModule", { value: true });
95
+ __exportStar(signupActions, exports);
96
+ __exportStar(userActions, exports);
97
+ __exportStar(serviceActions, exports);
98
+ __exportStar(generics, exports);
99
+ __exportStar(events, exports);
100
+ __exportStar(routes, exports);
101
+ __exportStar(headers, exports);
102
+ } (definitions));
103
+
104
+ var v1 = {};
105
+
106
+ Object.defineProperty(v1, "__esModule", { value: true });
107
+
108
+ var kafka = {};
109
+
110
+ Object.defineProperty(kafka, "__esModule", { value: true });
111
+ kafka.KAFKA_TOPIC = void 0;
112
+ var KAFKA_TOPIC;
113
+ (function (KAFKA_TOPIC) {
114
+ KAFKA_TOPIC["USER_METRICS"] = "user-metrics";
115
+ })(KAFKA_TOPIC || (kafka.KAFKA_TOPIC = KAFKA_TOPIC = {}));
116
+
117
+ (function (exports) {
118
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
119
+ if (k2 === undefined) k2 = k;
120
+ var desc = Object.getOwnPropertyDescriptor(m, k);
121
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
122
+ desc = { enumerable: true, get: function() { return m[k]; } };
123
+ }
124
+ Object.defineProperty(o, k2, desc);
125
+ }) : (function(o, m, k, k2) {
126
+ if (k2 === undefined) k2 = k;
127
+ o[k2] = m[k];
128
+ }));
129
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
130
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
131
+ };
132
+ Object.defineProperty(exports, "__esModule", { value: true });
133
+ __exportStar(definitions, exports);
134
+ __exportStar(v1, exports);
135
+ __exportStar(kafka, exports);
136
+ } (dist));
137
+
138
+ var author = "JourneyApps";
139
+ var bin = {
140
+ cli: "./bin/run.js"
141
+ };
142
+ var publishConfig = {
143
+ registry: "https://registry.npmjs.org/",
144
+ access: "public"
145
+ };
146
+ var description = "PowerSync CLI";
147
+ var engines = {
148
+ node: ">=20.0.0"
149
+ };
150
+ var files = [
151
+ "/bin",
152
+ "/dist",
153
+ "/oclif.manifest.json"
154
+ ];
155
+ var version = "0.2.3";
156
+ var bugs = "https://github.com/powersync-ja/cli/issues";
157
+ var types = "dist/index.d.ts";
158
+ var exports = "./lib/index.js";
159
+ var type = "module";
160
+ var homepage = "https://github.com/powersync-ja/cli";
161
+ var license = "UNLICENSED";
162
+ var name = "powersync";
163
+ var oclif = {
164
+ bin: "powersync",
165
+ dirname: "powersync",
166
+ commands: "./dist/commands",
167
+ plugins: [
168
+ "@oclif/plugin-help",
169
+ "@oclif/plugin-not-found",
170
+ "@oclif/plugin-warn-if-update-available"
171
+ ],
172
+ topics: {
173
+ "instance:sync-rules": {
174
+ description: "run \"powersync instance sync-rules\" to see a list of subcommands"
175
+ },
176
+ instance: {
177
+ description: "run \"powersync instance\" to see a list of subcommands"
178
+ }
179
+ },
180
+ topicSeparator: " "
181
+ };
182
+ var repository = "powersync-ja/cli";
183
+ var scripts = {
184
+ build: "pnpm build:oclif-commands && pnpm bundle:powersync-deps && ./combine-bundle-and-build.sh && pnpm readme",
185
+ "build:oclif-commands": "shx rm -rf dist && tsc -b",
186
+ "bundle:powersync-deps": "shx rm -rf lib && rollup -c rollup.config.mjs",
187
+ lint: "eslint . --ext .ts",
188
+ postpack: "shx rm -f oclif.manifest.json",
189
+ posttest: "pnpm run lint",
190
+ prepack: "pnpm run build && oclif manifest && oclif readme",
191
+ readme: "oclif readme",
192
+ prepare: "pnpm run build",
193
+ test: "vitest",
194
+ release: "pnpm build && pnpm changeset publish",
195
+ prettier: "prettier --write .",
196
+ version: "oclif readme && git add README.md",
197
+ "pack:tarballs": "oclif pack tarballs --parallel"
198
+ };
199
+ var dependencies = {
200
+ "@oclif/core": "^3.19.2",
201
+ "@oclif/plugin-help": "^6.0.13",
202
+ "@oclif/plugin-not-found": "^3.0.10",
203
+ "@oclif/plugin-warn-if-update-available": "^3.0.11",
204
+ "@rollup/plugin-typescript": "^11.1.6",
205
+ dotenv: "^16.4.4",
206
+ inquirer: "^9.2.14",
207
+ ora: "^8.0.1"
208
+ };
209
+ var devDependencies = {
210
+ "@changesets/cli": "^2.27.1",
211
+ "@journeyapps-platform/powersync-sync-rules": "^0.16.7",
212
+ "@journeyapps-platform/powersync-types": "^0.16.7",
213
+ "@journeyapps-platform/sdk-accounts-hub": "^5.1.0",
214
+ "@journeyapps-platform/sdk-common": "^5.5.0",
215
+ "@journeyapps-platform/sdk-powersync": "^0.16.7",
216
+ "@journeyapps-platform/types-accounts-hub": "^5.1.0",
217
+ "@journeyapps-platform/types-flight-log": "^0.3.0",
218
+ "@rollup/plugin-commonjs": "^25.0.7",
219
+ "@rollup/plugin-json": "^6.1.0",
220
+ "@rollup/plugin-node-resolve": "^15.2.3",
221
+ "@types/inquirer": "^9.0.7",
222
+ "@types/node": "^20.11.19",
223
+ esbuild: "^0.20.1",
224
+ eslint: "^8.56.0",
225
+ "eslint-config-oclif": "^5",
226
+ "eslint-config-oclif-typescript": "^3.0.48",
227
+ "eslint-config-prettier": "^9.1.0",
228
+ "eslint-plugin-prettier": "^5.1.3",
229
+ glob: "^10.3.10",
230
+ oclif: "^4.4.16",
231
+ prettier: "^3.2.5",
232
+ rollup: "^4.12.0",
233
+ "rollup-plugin-esbuild": "^6.1.1",
234
+ shx: "^0.3.4",
235
+ "strip-ansi": "^7.1.0",
236
+ "ts-node": "^10.9.2",
237
+ typescript: "^5.3.3",
238
+ vitest: "^1.3.0"
239
+ };
240
+ var packageJSON = {
241
+ author: author,
242
+ bin: bin,
243
+ publishConfig: publishConfig,
244
+ description: description,
245
+ engines: engines,
246
+ files: files,
247
+ version: version,
248
+ bugs: bugs,
249
+ types: types,
250
+ exports: exports,
251
+ type: type,
252
+ homepage: homepage,
253
+ license: license,
254
+ name: name,
255
+ oclif: oclif,
256
+ repository: repository,
257
+ scripts: scripts,
258
+ dependencies: dependencies,
259
+ devDependencies: devDependencies
260
+ };
261
+
262
+ const generateHeader = (bearerToken, shouldApplyAdditionalHeaders = true) => {
263
+ const defaultHeaders = {
264
+ Accept: "application/json",
265
+ Authorization: `Bearer ${bearerToken}`,
266
+ ContentType: "application/json"
267
+ };
268
+ if (!shouldApplyAdditionalHeaders) {
269
+ return defaultHeaders;
270
+ }
271
+ return {
272
+ ...defaultHeaders,
273
+ [dist.MetricSourceHeader]: dist.UserActionSource.POWERSYNC_CLI,
274
+ [dist.MetricSourceVersionHeader]: packageJSON.version
275
+ };
276
+ };
6
277
  const checkAppId = (appId) => {
7
278
  if (!appId)
8
279
  throw new Error("No app id found");
package/dist/utils.js CHANGED
@@ -2,20 +2,15 @@ import { ux } from '@oclif/core';
2
2
  import fs from 'node:fs';
3
3
  import { ENV_FILE_PATH } from './constants.js';
4
4
  import { ENV_VARIABLES } from './service/powersync.client.js';
5
+ // Add cliName as argument because we don't have access to this.config.bin in this file
5
6
  export const checkForValidEnvFile = (cliName, requiresInstanceId = false) => {
6
- const { APP_ID, AUTH_TOKEN, INSTANCE_ID, ORG_ID } = process.env;
7
- const allEnvVariablesSet = APP_ID && AUTH_TOKEN && ORG_ID && (INSTANCE_ID || !requiresInstanceId);
8
- if (!allEnvVariablesSet && !fs.existsSync(ENV_FILE_PATH)) {
9
- ux.error(`CLI has not been initialized. Please run ${green(`"${cliName} init"`)}.`, { exit: 1 });
10
- }
11
7
  const requiredProperties = [ENV_VARIABLES.APP_ID, ENV_VARIABLES.AUTH_TOKEN, ENV_VARIABLES.ORG_ID];
12
8
  const missingProperties = requiredProperties.filter((prop) => !process.env[prop]);
13
- if (missingProperties.length > 0) {
14
- return ux.error(`It appears you have not initialized the CLI. Please run ${green(`"${cliName} init"`)}.`, {
15
- exit: 1
16
- });
9
+ if (!fs.existsSync(ENV_FILE_PATH) || missingProperties.length > 0) {
10
+ ux.error(`CLI has not been initialized. Please run ${green(`"${cliName} init"`)}.`, { exit: 1 });
17
11
  }
18
- if (requiresInstanceId && !process.env[ENV_VARIABLES.INSTANCE_ID]) {
12
+ const isInstanceIdRequired = requiresInstanceId && !process.env[ENV_VARIABLES.INSTANCE_ID];
13
+ if (isInstanceIdRequired) {
19
14
  return ux.error(`This command requires a configured instance. Please set one by running ${green('"powersync instance set"')}.`, {
20
15
  exit: 1
21
16
  });
@@ -542,5 +542,5 @@
542
542
  ]
543
543
  }
544
544
  },
545
- "version": "0.2.1"
545
+ "version": "0.2.3"
546
546
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "/dist",
17
17
  "/oclif.manifest.json"
18
18
  ],
19
- "version": "0.2.1",
19
+ "version": "0.2.3",
20
20
  "bugs": "https://github.com/powersync-ja/cli/issues",
21
21
  "types": "dist/index.d.ts",
22
22
  "exports": "./lib/index.js",
@@ -45,51 +45,53 @@
45
45
  },
46
46
  "repository": "powersync-ja/cli",
47
47
  "dependencies": {
48
- "@oclif/core": "^3.18.1",
49
- "@oclif/plugin-help": "^6.0.12",
50
- "@oclif/plugin-not-found": "^3.0.9",
51
- "@oclif/plugin-warn-if-update-available": "^3.0.10",
48
+ "@oclif/core": "^3.19.2",
49
+ "@oclif/plugin-help": "^6.0.13",
50
+ "@oclif/plugin-not-found": "^3.0.10",
51
+ "@oclif/plugin-warn-if-update-available": "^3.0.11",
52
52
  "@rollup/plugin-typescript": "^11.1.6",
53
- "dotenv": "^16.4.1",
54
- "inquirer": "^9.2.13",
53
+ "dotenv": "^16.4.4",
54
+ "inquirer": "^9.2.14",
55
55
  "ora": "^8.0.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@changesets/cli": "^2.27.1",
59
- "@journeyapps-platform/powersync-sync-rules": "^0.16.6",
60
- "@journeyapps-platform/powersync-types": "^0.16.6",
59
+ "@journeyapps-platform/powersync-sync-rules": "^0.16.7",
60
+ "@journeyapps-platform/powersync-types": "^0.16.7",
61
61
  "@journeyapps-platform/sdk-accounts-hub": "^5.1.0",
62
62
  "@journeyapps-platform/sdk-common": "^5.5.0",
63
- "@journeyapps-platform/sdk-powersync": "^0.16.6",
63
+ "@journeyapps-platform/sdk-powersync": "^0.16.7",
64
64
  "@journeyapps-platform/types-accounts-hub": "^5.1.0",
65
+ "@journeyapps-platform/types-flight-log": "^0.3.0",
65
66
  "@rollup/plugin-commonjs": "^25.0.7",
66
67
  "@rollup/plugin-json": "^6.1.0",
67
68
  "@rollup/plugin-node-resolve": "^15.2.3",
68
69
  "@types/inquirer": "^9.0.7",
69
- "@types/node": "^20.11.10",
70
- "esbuild": "^0.19.12",
70
+ "@types/node": "^20.11.19",
71
+ "esbuild": "^0.20.1",
71
72
  "eslint": "^8.56.0",
72
73
  "eslint-config-oclif": "^5",
73
- "eslint-config-oclif-typescript": "^3.0.41",
74
+ "eslint-config-oclif-typescript": "^3.0.48",
74
75
  "eslint-config-prettier": "^9.1.0",
75
76
  "eslint-plugin-prettier": "^5.1.3",
76
77
  "glob": "^10.3.10",
77
- "oclif": "^4.4.2",
78
- "prettier": "^3.2.4",
79
- "rollup": "^4.9.6",
78
+ "oclif": "^4.4.16",
79
+ "prettier": "^3.2.5",
80
+ "rollup": "^4.12.0",
80
81
  "rollup-plugin-esbuild": "^6.1.1",
81
82
  "shx": "^0.3.4",
82
83
  "strip-ansi": "^7.1.0",
83
84
  "ts-node": "^10.9.2",
84
85
  "typescript": "^5.3.3",
85
- "vitest": "^1.2.2"
86
+ "vitest": "^1.3.0"
86
87
  },
87
88
  "scripts": {
88
- "build": "pnpm build:oclif-commands && pnpm bundle:powersync-deps && ./combine-bundle-and-build.sh",
89
+ "build": "pnpm build:oclif-commands && pnpm bundle:powersync-deps && ./combine-bundle-and-build.sh && pnpm readme",
89
90
  "build:oclif-commands": "shx rm -rf dist && tsc -b",
90
91
  "bundle:powersync-deps": "shx rm -rf lib && rollup -c rollup.config.mjs",
91
92
  "lint": "eslint . --ext .ts",
92
93
  "posttest": "pnpm run lint",
94
+ "readme": "oclif readme",
93
95
  "test": "vitest",
94
96
  "release": "pnpm build && pnpm changeset publish",
95
97
  "prettier": "prettier --write .",