powersync 0.2.4 → 0.4.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.
@@ -1,139 +1,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));
1
+ import { homedir } from 'node:os';
2
+ import path from 'node:path';
137
3
 
138
4
  var author = "JourneyApps";
139
5
  var bin = {
@@ -152,7 +18,7 @@ var files = [
152
18
  "/dist",
153
19
  "/oclif.manifest.json"
154
20
  ];
155
- var version = "0.2.4";
21
+ var version = "0.4.0";
156
22
  var bugs = "https://github.com/powersync-ja/cli/issues";
157
23
  var types = "dist/index.d.ts";
158
24
  var exports = "./lib/index.js";
@@ -188,12 +54,12 @@ var scripts = {
188
54
  postpack: "shx rm -f oclif.manifest.json",
189
55
  posttest: "pnpm run lint",
190
56
  prepack: "pnpm run build && oclif manifest && oclif readme",
191
- readme: "oclif readme",
57
+ readme: "oclif readme && ./update-readme.sh",
192
58
  prepare: "pnpm run build",
193
59
  test: "vitest",
194
60
  release: "pnpm build && pnpm changeset publish",
195
61
  prettier: "prettier --write .",
196
- version: "oclif readme && git add README.md",
62
+ version: "pnpm run readme && git add README.md",
197
63
  "pack:tarballs": "oclif pack tarballs --parallel"
198
64
  };
199
65
  var dependencies = {
@@ -214,7 +80,6 @@ var devDependencies = {
214
80
  "@journeyapps-platform/sdk-common": "^5.5.0",
215
81
  "@journeyapps-platform/sdk-powersync": "^0.16.7",
216
82
  "@journeyapps-platform/types-accounts-hub": "^5.1.0",
217
- "@journeyapps-platform/types-flight-log": "^0.3.0",
218
83
  "@rollup/plugin-commonjs": "^25.0.7",
219
84
  "@rollup/plugin-json": "^6.1.0",
220
85
  "@rollup/plugin-node-resolve": "^15.2.3",
@@ -259,24 +124,20 @@ var packageJSON = {
259
124
  devDependencies: devDependencies
260
125
  };
261
126
 
262
- const generateHeader = (bearerToken, shouldApplyAdditionalHeaders = true) => {
263
- const defaultHeaders = {
127
+ const APP_NAME = "POWERSYNC_CLI";
128
+ path.join(homedir(), "/.powersync");
129
+
130
+ const generateHeader = (bearerToken) => {
131
+ return {
264
132
  Accept: "application/json",
265
133
  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
134
+ ContentType: "application/json",
135
+ "user-agent": `${APP_NAME}/${packageJSON.version}`
275
136
  };
276
137
  };
277
- const checkAppId = (appId) => {
278
- if (!appId)
279
- throw new Error("No app id found");
138
+ const checkProjectId = (projectId) => {
139
+ if (!projectId)
140
+ throw new Error("No project id found");
280
141
  };
281
142
  const checkOrgId = (orgId) => {
282
143
  if (!orgId)
@@ -287,4 +148,4 @@ const checkInstanceId = (instanceId) => {
287
148
  throw new Error("No instance id found");
288
149
  };
289
150
 
290
- export { checkAppId, checkInstanceId, checkOrgId, generateHeader };
151
+ export { checkInstanceId, checkOrgId, checkProjectId, generateHeader };
package/dist/utils.js CHANGED
@@ -4,7 +4,7 @@ import { ENV_FILE_PATH } from './constants.js';
4
4
  import { ENV_VARIABLES } from './service/powersync.client.js';
5
5
  // Add cliName as argument because we don't have access to this.config.bin in this file
6
6
  export const checkForValidEnvFile = (cliName, requiresInstanceId = false) => {
7
- const requiredProperties = [ENV_VARIABLES.APP_ID, ENV_VARIABLES.AUTH_TOKEN, ENV_VARIABLES.ORG_ID];
7
+ const requiredProperties = [ENV_VARIABLES.PROJECT_ID, ENV_VARIABLES.AUTH_TOKEN, ENV_VARIABLES.ORG_ID];
8
8
  const missingProperties = requiredProperties.filter((prop) => !process.env[prop]);
9
9
  if (!fs.existsSync(ENV_FILE_PATH) || missingProperties.length > 0) {
10
10
  ux.error(`CLI has not been initialized. Please run ${green(`"${cliName} init"`)}.`, { exit: 1 });
@@ -324,23 +324,15 @@
324
324
  "instance:status": {
325
325
  "aliases": [],
326
326
  "args": {},
327
- "description": "View the status of the current instance.",
327
+ "description": "View the status of the current instance. View the status of a different instance by using flags.",
328
328
  "examples": [
329
329
  "<%= config.bin %> <%= command.id %>",
330
- "<%= config.bin %> <%= command.id %> --orgId=1234 --appId=1234 --instanceId=1234 --authToken=1234"
330
+ "<%= config.bin %> <%= command.id %> --orgId=1234 --projectId=1234 --instanceId=1234 --authToken=1234"
331
331
  ],
332
332
  "flags": {
333
- "appId": {
334
- "char": "a",
335
- "description": "app id to use",
336
- "name": "appId",
337
- "hasDynamicHelp": false,
338
- "multiple": false,
339
- "type": "option"
340
- },
341
333
  "authToken": {
342
334
  "char": "t",
343
- "description": "auth token to use",
335
+ "description": "Override current auth token.",
344
336
  "name": "authToken",
345
337
  "hasDynamicHelp": false,
346
338
  "multiple": false,
@@ -348,7 +340,7 @@
348
340
  },
349
341
  "instanceId": {
350
342
  "char": "i",
351
- "description": "instance id to use",
343
+ "description": "Override current instance by providing the ID of a different instance.",
352
344
  "name": "instanceId",
353
345
  "hasDynamicHelp": false,
354
346
  "multiple": false,
@@ -356,11 +348,19 @@
356
348
  },
357
349
  "orgId": {
358
350
  "char": "o",
359
- "description": "org id to use",
351
+ "description": "Override current organization by providing the ID of a different organization.",
360
352
  "name": "orgId",
361
353
  "hasDynamicHelp": false,
362
354
  "multiple": false,
363
355
  "type": "option"
356
+ },
357
+ "projectId": {
358
+ "char": "p",
359
+ "description": "Override current project by providing the ID of a different project.",
360
+ "name": "projectId",
361
+ "hasDynamicHelp": false,
362
+ "multiple": false,
363
+ "type": "option"
364
364
  }
365
365
  },
366
366
  "hasDynamicHelp": false,
@@ -414,7 +414,7 @@
414
414
  "instance:sync-rules:deploy": {
415
415
  "aliases": [],
416
416
  "args": {},
417
- "description": "Deploy sync rules from a local sync rules file to the current instance.",
417
+ "description": "Deploy sync rules from a local sync rules config file to the current instance.",
418
418
  "examples": [
419
419
  "<%= config.bin %> <%= command.id %>",
420
420
  "<%= config.bin %> <%= command.id %> --filePath path/to/file",
@@ -458,7 +458,7 @@
458
458
  "instance:sync-rules:generate-schema": {
459
459
  "aliases": [],
460
460
  "args": {},
461
- "description": "Generate schema in your language from your sync rules file.",
461
+ "description": "Generate schema in your language from your sync rules config file.",
462
462
  "examples": [
463
463
  "<%= config.bin %> <%= command.id %>",
464
464
  "<%= config.bin %> <%= command.id %> --filePath path/to/file",
@@ -507,7 +507,7 @@
507
507
  "instance:sync-rules:validate": {
508
508
  "aliases": [],
509
509
  "args": {},
510
- "description": "Validate sync rules from a local sync rules file.",
510
+ "description": "Validate sync rules from a local sync rules config file.",
511
511
  "examples": [
512
512
  "<%= config.bin %> <%= command.id %>",
513
513
  "<%= config.bin %> <%= command.id %> --filePath path/to/file",
@@ -542,5 +542,5 @@
542
542
  ]
543
543
  }
544
544
  },
545
- "version": "0.2.4"
545
+ "version": "0.4.0"
546
546
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "/dist",
17
17
  "/oclif.manifest.json"
18
18
  ],
19
- "version": "0.2.4",
19
+ "version": "0.4.0",
20
20
  "bugs": "https://github.com/powersync-ja/cli/issues",
21
21
  "types": "dist/index.d.ts",
22
22
  "exports": "./lib/index.js",
@@ -62,7 +62,6 @@
62
62
  "@journeyapps-platform/sdk-common": "^5.5.0",
63
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",
66
65
  "@rollup/plugin-commonjs": "^25.0.7",
67
66
  "@rollup/plugin-json": "^6.1.0",
68
67
  "@rollup/plugin-node-resolve": "^15.2.3",
@@ -91,11 +90,11 @@
91
90
  "bundle:powersync-deps": "shx rm -rf lib && rollup -c rollup.config.mjs",
92
91
  "lint": "eslint . --ext .ts",
93
92
  "posttest": "pnpm run lint",
94
- "readme": "oclif readme",
93
+ "readme": "oclif readme && ./update-readme.sh",
95
94
  "test": "vitest",
96
95
  "release": "pnpm build && pnpm changeset publish",
97
96
  "prettier": "prettier --write .",
98
- "version": "oclif readme && git add README.md",
97
+ "version": "pnpm run readme && git add README.md",
99
98
  "pack:tarballs": "oclif pack tarballs --parallel"
100
99
  }
101
100
  }