powersync 0.8.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/LICENSE +67 -0
  2. package/README.md +1376 -173
  3. package/bin/dev.cmd +3 -3
  4. package/bin/dev.js +20 -7
  5. package/bin/run.cmd +3 -3
  6. package/bin/run.js +9 -5
  7. package/dist/api/cloud/create-cloud-instance.d.ts +15 -0
  8. package/dist/api/cloud/create-cloud-instance.js +19 -0
  9. package/dist/api/cloud/fetch-cloud-config.d.ts +12 -0
  10. package/dist/api/cloud/fetch-cloud-config.js +18 -0
  11. package/dist/api/cloud/fetch-cloud-sync-rules-content.d.ts +7 -0
  12. package/dist/api/cloud/fetch-cloud-sync-rules-content.js +26 -0
  13. package/dist/api/cloud/test-connection.d.ts +16 -0
  14. package/dist/api/cloud/test-connection.js +36 -0
  15. package/dist/api/cloud/validate-cloud-link-config.d.ts +17 -0
  16. package/dist/api/cloud/validate-cloud-link-config.js +47 -0
  17. package/dist/api/cloud/wait-for-operation.d.ts +16 -0
  18. package/dist/api/cloud/wait-for-operation.js +33 -0
  19. package/dist/api/cloud/write-cloud-link.d.ts +10 -0
  20. package/dist/api/cloud/write-cloud-link.js +21 -0
  21. package/dist/api/display-status.d.ts +4 -0
  22. package/dist/api/display-status.js +80 -0
  23. package/dist/api/ide/configure-vscode-ide.d.ts +14 -0
  24. package/dist/api/ide/configure-vscode-ide.js +62 -0
  25. package/dist/api/login-server.d.ts +26 -0
  26. package/dist/api/login-server.js +137 -0
  27. package/dist/api/run-validation-tests.d.ts +63 -0
  28. package/dist/api/run-validation-tests.js +202 -0
  29. package/dist/api/self-hosted/fetch-self-hosted-sync-rules-content.d.ts +7 -0
  30. package/dist/api/self-hosted/fetch-self-hosted-sync-rules-content.js +26 -0
  31. package/dist/commands/configure/ide.d.ts +8 -0
  32. package/dist/commands/configure/ide.js +58 -0
  33. package/dist/commands/configure/index.d.ts +8 -0
  34. package/dist/commands/configure/index.js +11 -0
  35. package/dist/commands/deploy/index.d.ts +48 -0
  36. package/dist/commands/deploy/index.js +333 -0
  37. package/dist/commands/deploy/service-config.d.ts +14 -0
  38. package/dist/commands/deploy/service-config.js +30 -0
  39. package/dist/commands/deploy/sync-config.d.ts +24 -0
  40. package/dist/commands/deploy/sync-config.js +103 -0
  41. package/dist/commands/destroy.d.ts +14 -0
  42. package/dist/commands/destroy.js +62 -0
  43. package/dist/commands/fetch/config.d.ts +14 -0
  44. package/dist/commands/fetch/config.js +33 -0
  45. package/dist/commands/fetch/index.d.ts +13 -0
  46. package/dist/commands/fetch/index.js +16 -0
  47. package/dist/commands/fetch/instances.d.ts +47 -0
  48. package/dist/commands/fetch/instances.js +177 -0
  49. package/dist/commands/fetch/status.d.ts +18 -0
  50. package/dist/commands/fetch/status.js +60 -0
  51. package/dist/commands/{instance/schema.d.ts → generate/index.d.ts} +3 -1
  52. package/dist/commands/generate/index.js +11 -0
  53. package/dist/commands/generate/schema.d.ts +19 -0
  54. package/dist/commands/generate/schema.js +72 -0
  55. package/dist/commands/generate/token.d.ts +25 -0
  56. package/dist/commands/generate/token.js +124 -0
  57. package/dist/commands/init/cloud.d.ts +11 -0
  58. package/dist/commands/init/cloud.js +64 -0
  59. package/dist/commands/{init.d.ts → init/index.d.ts} +2 -1
  60. package/dist/commands/init/index.js +11 -0
  61. package/dist/commands/init/self-hosted.d.ts +11 -0
  62. package/dist/commands/init/self-hosted.js +60 -0
  63. package/dist/commands/link/cloud.d.ts +15 -0
  64. package/dist/commands/link/cloud.js +111 -0
  65. package/dist/commands/{instance/config.d.ts → link/index.d.ts} +3 -1
  66. package/dist/commands/link/index.js +11 -0
  67. package/dist/commands/link/self-hosted.d.ts +12 -0
  68. package/dist/commands/link/self-hosted.js +54 -0
  69. package/dist/commands/login.d.ts +8 -0
  70. package/dist/commands/login.js +107 -0
  71. package/dist/commands/logout.d.ts +8 -0
  72. package/dist/commands/logout.js +19 -0
  73. package/dist/commands/migrate/index.d.ts +7 -0
  74. package/dist/commands/migrate/index.js +10 -0
  75. package/dist/commands/migrate/sync-rules.d.ts +15 -0
  76. package/dist/commands/migrate/sync-rules.js +51 -0
  77. package/dist/commands/{instances.d.ts → pull/index.d.ts} +3 -1
  78. package/dist/commands/pull/index.js +11 -0
  79. package/dist/commands/pull/instance.d.ts +14 -0
  80. package/dist/commands/pull/instance.js +108 -0
  81. package/dist/commands/status.d.ts +1 -0
  82. package/dist/commands/status.js +2 -0
  83. package/dist/commands/stop.d.ts +14 -0
  84. package/dist/commands/stop.js +62 -0
  85. package/dist/commands/validate.d.ts +16 -0
  86. package/dist/commands/validate.js +165 -0
  87. package/dist/help.d.ts +31 -0
  88. package/dist/help.js +123 -0
  89. package/oclif.manifest.json +1259 -330
  90. package/package.json +104 -75
  91. package/templates/cloud/powersync/cli.yaml +3 -0
  92. package/templates/cloud/powersync/service.yaml +174 -0
  93. package/templates/cloud/powersync/sync-config.yaml +22 -0
  94. package/templates/self-hosted/base/powersync/cli.yaml +3 -0
  95. package/templates/self-hosted/base/powersync/service.yaml +243 -0
  96. package/templates/self-hosted/base/powersync/sync-config.yaml +22 -0
  97. package/templates/vscode/settings.json +3 -0
  98. package/dist/commands/init.js +0 -66
  99. package/dist/commands/instance/config.js +0 -23
  100. package/dist/commands/instance/create.d.ts +0 -36
  101. package/dist/commands/instance/create.js +0 -137
  102. package/dist/commands/instance/deploy.d.ts +0 -21
  103. package/dist/commands/instance/deploy.js +0 -91
  104. package/dist/commands/instance/destroy.d.ts +0 -9
  105. package/dist/commands/instance/destroy.js +0 -46
  106. package/dist/commands/instance/generate-dev-token.d.ts +0 -10
  107. package/dist/commands/instance/generate-dev-token.js +0 -54
  108. package/dist/commands/instance/schema.js +0 -20
  109. package/dist/commands/instance/set.d.ts +0 -9
  110. package/dist/commands/instance/set.js +0 -31
  111. package/dist/commands/instance/status.d.ts +0 -12
  112. package/dist/commands/instance/status.js +0 -50
  113. package/dist/commands/instance/stop.d.ts +0 -9
  114. package/dist/commands/instance/stop.js +0 -42
  115. package/dist/commands/instance/sync-rules/deploy.d.ts +0 -10
  116. package/dist/commands/instance/sync-rules/deploy.js +0 -49
  117. package/dist/commands/instance/sync-rules/generate-schema.d.ts +0 -10
  118. package/dist/commands/instance/sync-rules/generate-schema.js +0 -56
  119. package/dist/commands/instance/sync-rules/validate.d.ts +0 -9
  120. package/dist/commands/instance/sync-rules/validate.js +0 -29
  121. package/dist/commands/instances.js +0 -29
  122. package/dist/commands.utils.d.ts +0 -2
  123. package/dist/commands.utils.js +0 -131
  124. package/dist/connection.utils.d.ts +0 -56
  125. package/dist/connection.utils.js +0 -76
  126. package/dist/constants.d.ts +0 -8
  127. package/dist/constants.js +0 -10
  128. package/dist/instance-command-flags.d.ts +0 -13
  129. package/dist/instance-command-flags.js +0 -22
  130. package/dist/service/accounts.client.js +0 -11307
  131. package/dist/service/powersync.client.js +0 -75510
  132. package/dist/service/types.js +0 -1
  133. package/dist/service/utils.js +0 -153
  134. package/dist/utils.d.ts +0 -14
  135. package/dist/utils.js +0 -68
@@ -1 +0,0 @@
1
-
@@ -1,153 +0,0 @@
1
- import { homedir } from 'node:os';
2
- import path from 'node:path';
3
-
4
- var author = "JourneyApps";
5
- var bin = {
6
- powersync: "./bin/run.js"
7
- };
8
- var publishConfig = {
9
- registry: "https://registry.npmjs.org/",
10
- access: "public"
11
- };
12
- var description = "PowerSync CLI";
13
- var engines = {
14
- node: ">=20.0.0"
15
- };
16
- var files = [
17
- "/bin",
18
- "/dist",
19
- "/oclif.manifest.json"
20
- ];
21
- var version = "0.8.0";
22
- var bugs = "https://github.com/powersync-ja/cli/issues";
23
- var types = "dist/index.d.ts";
24
- var exports = "./lib/index.js";
25
- var type = "module";
26
- var homepage = "https://github.com/powersync-ja/cli";
27
- var license = "UNLICENSED";
28
- var name = "powersync";
29
- var oclif = {
30
- bin: "powersync",
31
- dirname: "powersync",
32
- commands: "./dist/commands",
33
- plugins: [
34
- "@oclif/plugin-help",
35
- "@oclif/plugin-not-found",
36
- "@oclif/plugin-warn-if-update-available"
37
- ],
38
- topics: {
39
- "instance:sync-rules": {
40
- description: "run \"powersync instance sync-rules\" to see a list of subcommands"
41
- },
42
- instance: {
43
- description: "run \"powersync instance\" to see a list of subcommands"
44
- }
45
- },
46
- topicSeparator: " "
47
- };
48
- var repository = "powersync-ja/cli";
49
- var scripts = {
50
- build: "pnpm build:oclif-commands && pnpm bundle:powersync-deps && ./combine-bundle-and-build.sh && pnpm readme",
51
- "build:oclif-commands": "shx rm -rf dist && tsc -b",
52
- "bundle:powersync-deps": "shx rm -rf lib && rollup -c rollup.config.mjs",
53
- lint: "eslint . --ext .ts",
54
- postpack: "shx rm -f oclif.manifest.json",
55
- posttest: "pnpm run lint",
56
- prepack: "pnpm run build && oclif manifest && oclif readme",
57
- readme: "oclif readme && ./update-readme.sh",
58
- prepare: "pnpm run build",
59
- test: "vitest",
60
- release: "pnpm build && pnpm changeset publish",
61
- prettier: "prettier --write \"**/*.ts\"",
62
- version: "pnpm run readme && git add README.md",
63
- "pack:tarballs": "oclif pack tarballs --parallel",
64
- "changeset:version": "pnpm changeset version && pnpm readme"
65
- };
66
- var dependencies = {
67
- "@oclif/core": "^3.27.0",
68
- "@oclif/plugin-help": "^6.2.8",
69
- "@oclif/plugin-not-found": "^3.1.4",
70
- "@oclif/plugin-warn-if-update-available": "^3.1.11",
71
- "@rollup/plugin-typescript": "^11.1.6",
72
- clipboardy: "^4.0.0",
73
- dotenv: "^16.4.5",
74
- inquirer: "^9.3.6",
75
- ora: "^8.0.1"
76
- };
77
- var devDependencies = {
78
- "@changesets/cli": "^2.27.7",
79
- "@journeyapps-platform/types-powersync": "^1.12.1",
80
- "@journeyapps-platform/sdk-accounts-hub": "^7.0.1",
81
- "@journeyapps-platform/sdk-common": "^5.5.0",
82
- "@journeyapps-platform/sdk-powersync": "^2.5.1",
83
- "@journeyapps-platform/types-accounts-hub": "^7.0.1",
84
- "@powersync/service-sync-rules": "^0.27.0",
85
- "@rollup/plugin-commonjs": "^26.0.1",
86
- "@rollup/plugin-json": "^6.1.0",
87
- "@rollup/plugin-node-resolve": "^15.2.3",
88
- "@types/inquirer": "^9.0.7",
89
- "@types/node": "^20.16.1",
90
- esbuild: "^0.23.1",
91
- eslint: "^8.57.0",
92
- "eslint-config-oclif": "^5",
93
- "eslint-config-oclif-typescript": "^3.1.9",
94
- "eslint-config-prettier": "^9.1.0",
95
- "eslint-plugin-prettier": "^5.2.1",
96
- glob: "^11.0.0",
97
- oclif: "^4.14.29",
98
- prettier: "^3.3.3",
99
- rollup: "^4.21.2",
100
- "rollup-plugin-esbuild": "^6.1.1",
101
- shx: "^0.3.4",
102
- "strip-ansi": "^7.1.0",
103
- "ts-node": "^10.9.2",
104
- typescript: "^5.5.4",
105
- vitest: "^2.0.5"
106
- };
107
- var packageJSON = {
108
- author: author,
109
- bin: bin,
110
- publishConfig: publishConfig,
111
- description: description,
112
- engines: engines,
113
- files: files,
114
- version: version,
115
- bugs: bugs,
116
- types: types,
117
- exports: exports,
118
- type: type,
119
- homepage: homepage,
120
- license: license,
121
- name: name,
122
- oclif: oclif,
123
- repository: repository,
124
- scripts: scripts,
125
- dependencies: dependencies,
126
- devDependencies: devDependencies
127
- };
128
-
129
- const APP_NAME = "POWERSYNC_CLI";
130
- path.join(homedir(), "/.powersync");
131
-
132
- const generateHeader = (bearerToken) => {
133
- return {
134
- Accept: "application/json",
135
- Authorization: `Bearer ${bearerToken}`,
136
- ContentType: "application/json",
137
- "user-agent": `${APP_NAME}/${packageJSON.version}`
138
- };
139
- };
140
- const checkProjectId = (projectId) => {
141
- if (!projectId)
142
- throw new Error("No project id found");
143
- };
144
- const checkOrgId = (orgId) => {
145
- if (!orgId)
146
- throw new Error("No org id found");
147
- };
148
- const checkInstanceId = (instanceId) => {
149
- if (!instanceId)
150
- throw new Error("No instance id found");
151
- };
152
-
153
- export { checkInstanceId, checkOrgId, checkProjectId, generateHeader };
package/dist/utils.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { FlagInput } from '@oclif/core/lib/interfaces/parser.js';
2
- /**
3
- * Oclif flags include {[flag: string]: any} which allows for any additional flag members.
4
- * This makes using flags vulnerable to typos and errors.
5
- * This helper type only exposes the declared flag members in the type.
6
- */
7
- export type StrictFlags<T> = T extends FlagInput<infer U> ? U : never;
8
- export declare const checkThatEnvVariablesAreSet: (cliName: string, requiresInstanceId?: boolean) => undefined;
9
- export declare const updateEnvFileVariableValue: (variableName: string, newValue: string) => void;
10
- export declare const bold: (text: string) => string;
11
- export declare const green: (text: string) => string;
12
- export declare const yellow: (text: string) => string;
13
- export declare const red: (text: string) => string;
14
- export declare const convertSeconds: (seconds: number) => string;
package/dist/utils.js DELETED
@@ -1,68 +0,0 @@
1
- import { ux } from '@oclif/core';
2
- import fs from 'node:fs';
3
- import { ENV_FILE_PATH } from './constants.js';
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
6
- export const checkThatEnvVariablesAreSet = (cliName, requiresInstanceId = false) => {
7
- const requiredProperties = [ENV_VARIABLES.PROJECT_ID, ENV_VARIABLES.AUTH_TOKEN, ENV_VARIABLES.ORG_ID];
8
- const missingProperties = requiredProperties.filter((prop) => !process.env[prop]);
9
- const envFileExists = fs.existsSync(ENV_FILE_PATH);
10
- if (missingProperties.length > 0 && envFileExists) {
11
- ux.error(red(`CLI has not been initialized correctly. Please run ${green(`"${cliName} init"`)}.`), { exit: 1 });
12
- }
13
- if (missingProperties.length > 0 && !envFileExists) {
14
- ux.error(red(`Please include ${green(missingProperties.join(', '))} when you run the command or run ${green(`"${cliName} init"`)}.`), { exit: 1 });
15
- }
16
- const isInstanceIdRequired = requiresInstanceId && !process.env[ENV_VARIABLES.INSTANCE_ID];
17
- if (isInstanceIdRequired) {
18
- return ux.error(red(`This command requires a configured instance. Please set one by running ${green('"powersync instance set"')} or include it when you run the command ${green('"INSTANCE_ID=your_instance_id"')}.`), {
19
- exit: 1
20
- });
21
- }
22
- };
23
- export const updateEnvFileVariableValue = (variableName, newValue) => {
24
- if (!fs.existsSync(ENV_FILE_PATH)) {
25
- // We assume they are either using flags or exporting the variables themselves
26
- return;
27
- }
28
- try {
29
- const data = fs.readFileSync(ENV_FILE_PATH, 'utf8');
30
- const lines = data.split('\n');
31
- let variableFound = false;
32
- // Find and update the desired variable
33
- for (let i = 0; i < lines.length; i++) {
34
- const line = lines[i];
35
- if (line.startsWith(variableName + '=')) {
36
- lines[i] = variableName + '=' + newValue;
37
- variableFound = true;
38
- break;
39
- }
40
- }
41
- // Variable not found, add it to the end of the file
42
- if (!variableFound) {
43
- lines.push(variableName + '=' + newValue);
44
- }
45
- const updatedContent = lines.join('\n');
46
- fs.writeFileSync(ENV_FILE_PATH, updatedContent, 'utf8');
47
- }
48
- catch (error) {
49
- throw new Error('Error updating environment file: ' + error);
50
- }
51
- };
52
- export const bold = (text) => ux.colorize('bold', text);
53
- export const green = (text) => ux.colorize('green', text);
54
- export const yellow = (text) => ux.colorize('yellow', text);
55
- export const red = (text) => ux.colorize('red', text);
56
- const formatUnit = (value, unit) => `${value} ${unit}${value === 1 ? '' : 's'}`;
57
- export const convertSeconds = (seconds) => {
58
- if (seconds < 60)
59
- return formatUnit(seconds, 'second');
60
- const minutes = Math.floor(seconds / 60);
61
- if (minutes < 60)
62
- return formatUnit(minutes, 'minute');
63
- const hours = Math.floor(minutes / 60);
64
- const remainingMinutes = minutes % 60;
65
- if (remainingMinutes === 0)
66
- return formatUnit(hours, 'hour');
67
- return `${formatUnit(hours, 'hour')} ${formatUnit(remainingMinutes, 'minute')}`;
68
- };