@powersync/cli-core 0.9.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 (49) hide show
  1. package/LICENSE +67 -0
  2. package/README.md +24 -0
  3. package/dist/api/validate-sync-config.d.ts +63 -0
  4. package/dist/api/validate-sync-config.js +103 -0
  5. package/dist/clients/AccountsHubClientSDKClient.d.ts +67 -0
  6. package/dist/clients/AccountsHubClientSDKClient.js +66 -0
  7. package/dist/clients/cli-client-headers.d.ts +10 -0
  8. package/dist/clients/cli-client-headers.js +28 -0
  9. package/dist/clients/create-cloud-client.d.ts +6 -0
  10. package/dist/clients/create-cloud-client.js +36 -0
  11. package/dist/clients/create-self-hosted-client.d.ts +10 -0
  12. package/dist/clients/create-self-hosted-client.js +21 -0
  13. package/dist/command-types/CloudInstanceCommand.d.ts +62 -0
  14. package/dist/command-types/CloudInstanceCommand.js +190 -0
  15. package/dist/command-types/HelpGroup.d.ts +23 -0
  16. package/dist/command-types/HelpGroup.js +25 -0
  17. package/dist/command-types/InstanceCommand.d.ts +15 -0
  18. package/dist/command-types/InstanceCommand.js +42 -0
  19. package/dist/command-types/PowerSyncCommand.d.ts +29 -0
  20. package/dist/command-types/PowerSyncCommand.js +37 -0
  21. package/dist/command-types/SelfHostedInstanceCommand.d.ts +25 -0
  22. package/dist/command-types/SelfHostedInstanceCommand.js +97 -0
  23. package/dist/command-types/SharedInstanceCommand.d.ts +51 -0
  24. package/dist/command-types/SharedInstanceCommand.js +217 -0
  25. package/dist/index.d.ts +25 -0
  26. package/dist/index.js +25 -0
  27. package/dist/services/Services.d.ts +6 -0
  28. package/dist/services/Services.js +8 -0
  29. package/dist/services/authentication/AuthenticationService.d.ts +5 -0
  30. package/dist/services/authentication/AuthenticationService.js +1 -0
  31. package/dist/services/authentication/AuthenticationServiceImpl.d.ts +12 -0
  32. package/dist/services/authentication/AuthenticationServiceImpl.js +41 -0
  33. package/dist/services/storage/KeychainSecureStorage.d.ts +2 -0
  34. package/dist/services/storage/KeychainSecureStorage.js +58 -0
  35. package/dist/services/storage/StorageImp.d.ts +18 -0
  36. package/dist/services/storage/StorageImp.js +85 -0
  37. package/dist/services/storage/StorageService.d.ts +24 -0
  38. package/dist/services/storage/StorageService.js +1 -0
  39. package/dist/utils/ensure-service-type.d.ts +16 -0
  40. package/dist/utils/ensure-service-type.js +37 -0
  41. package/dist/utils/env.d.ts +11 -0
  42. package/dist/utils/env.js +13 -0
  43. package/dist/utils/object-id.d.ts +1 -0
  44. package/dist/utils/object-id.js +1 -0
  45. package/dist/utils/project-config.d.ts +12 -0
  46. package/dist/utils/project-config.js +12 -0
  47. package/dist/utils/yaml.d.ts +23 -0
  48. package/dist/utils/yaml.js +76 -0
  49. package/package.json +53 -0
@@ -0,0 +1,23 @@
1
+ import * as yaml from 'yaml';
2
+ export declare const YAML_SYNC_RULES_SCHEMA: string;
3
+ export declare const YAML_SERVICE_SCHEMA: string;
4
+ export declare const YAML_CLI_SCHEMA: string;
5
+ /**
6
+ * Custom YAML tag which performs string environment variable substitution
7
+ * Allows for type casting string environment variables to boolean or number
8
+ * by using the syntax !env PS_MONGO_PORT::number or !env PS_USE_SUPABASE::boolean
9
+ */
10
+ export declare const YamlEnvTag: yaml.ScalarTag;
11
+ /**
12
+ * Parses a YAML document, evaluating !env tags.
13
+ */
14
+ export declare function parseYamlFile(filePath: string): yaml.Document;
15
+ /**
16
+ * Parse a YAML string without resolving !env, so the output can preserve the tag for runtime substitution
17
+ * (e.g. when merging service snippets so the PowerSync container resolves !env from its env_file).
18
+ */
19
+ export declare function parseYamlDocumentPreserveTags(content: string): yaml.Document;
20
+ /**
21
+ * Stringify a value to YAML. Use for writing config files so all YAML I/O goes through cli-core.
22
+ */
23
+ export declare function stringifyYaml(value: unknown): string;
@@ -0,0 +1,76 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import * as yaml from 'yaml';
3
+ export const YAML_SYNC_RULES_SCHEMA = /* yaml */ `
4
+ # Adds YAML Schema support for VSCode users with the YAML extension installed. This enables features like validation and autocompletion based on the provided schema.
5
+ # yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_rules.json
6
+ `.trim();
7
+ export const YAML_SERVICE_SCHEMA = /* yaml */ `
8
+ # Adds YAML Schema support for VSCode users with the YAML extension installed. This enables features like validation and autocompletion based on the provided schema.
9
+ # yaml-language-server: $schema=https://unpkg.com/@powersync/cli-schemas@latest/json-schema/service-config.json
10
+ `.trim();
11
+ export const YAML_CLI_SCHEMA = /* yaml */ `
12
+ # Adds YAML Schema support for VSCode users with the YAML extension installed. This enables features like validation and autocompletion based on the provided schema.
13
+ # yaml-language-server: $schema=https://unpkg.com/@powersync/cli-schemas@latest/json-schema/cli-config.json
14
+ `.trim();
15
+ /**
16
+ * Custom YAML tag which performs string environment variable substitution
17
+ * Allows for type casting string environment variables to boolean or number
18
+ * by using the syntax !env PS_MONGO_PORT::number or !env PS_USE_SUPABASE::boolean
19
+ */
20
+ export const YamlEnvTag = {
21
+ resolve(envName, onError) {
22
+ const [name, type = 'string'] = envName.split('::');
23
+ const value = process.env[name];
24
+ if (value === undefined) {
25
+ onError(`Attempted to substitute environment variable "${envName}" which is undefined. Set this variable on the environment.`);
26
+ return envName;
27
+ }
28
+ switch (type) {
29
+ case 'boolean': {
30
+ if (value?.toLowerCase() === 'true')
31
+ return true;
32
+ if (value?.toLowerCase() === 'false')
33
+ return false;
34
+ onError(`Environment variable "${envName}" is not a boolean. Expected "true" or "false", got "${value}".`);
35
+ return envName;
36
+ }
37
+ case 'number': {
38
+ const numberValue = Number(value);
39
+ if (Number.isNaN(numberValue)) {
40
+ onError(`Environment variable "${envName}" is not a valid number. Got: "${value}".`);
41
+ return envName;
42
+ }
43
+ return numberValue;
44
+ }
45
+ case 'string': {
46
+ return value;
47
+ }
48
+ default: {
49
+ onError(`Environment variable "${envName}" has an invalid type suffix "${type}".`);
50
+ return envName;
51
+ }
52
+ }
53
+ },
54
+ tag: '!env'
55
+ };
56
+ const YAML_PARSE_OPTIONS = { customTags: [YamlEnvTag] };
57
+ /**
58
+ * Parses a YAML document, evaluating !env tags.
59
+ */
60
+ export function parseYamlFile(filePath) {
61
+ const content = readFileSync(filePath, 'utf8');
62
+ return yaml.parseDocument(content, YAML_PARSE_OPTIONS);
63
+ }
64
+ /**
65
+ * Parse a YAML string without resolving !env, so the output can preserve the tag for runtime substitution
66
+ * (e.g. when merging service snippets so the PowerSync container resolves !env from its env_file).
67
+ */
68
+ export function parseYamlDocumentPreserveTags(content) {
69
+ return yaml.parseDocument(content);
70
+ }
71
+ /**
72
+ * Stringify a value to YAML. Use for writing config files so all YAML I/O goes through cli-core.
73
+ */
74
+ export function stringifyYaml(value) {
75
+ return yaml.stringify(value);
76
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@powersync/cli-core",
3
+ "description": "Core types and base commands for PowerSync CLI and plugins (shared by CLI and plugin-docker).",
4
+ "version": "0.9.0",
5
+ "license": "FSL-1.1-ALv2",
6
+ "author": "POWERSYNC",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/powersync-ja/powersync-cli"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "bugs": "https://github.com/powersync-ja/powersync-cli/issues",
29
+ "dependencies": {
30
+ "@oclif/core": "^4",
31
+ "@journeyapps-labs/micro-errors": "^1.0.1",
32
+ "yaml": "^2",
33
+ "@journeyapps-labs/common-sdk": "1.0.2",
34
+ "@powersync/management-client": "^0.0.4",
35
+ "@powersync/management-types": "^0.0.3",
36
+ "@powersync/service-client": "^0.0.3",
37
+ "keychain": "^1.5.0",
38
+ "@powersync/cli-schemas": "0.9.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^24",
42
+ "typescript": "^5",
43
+ "@types/keychain": "^1.4.4"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "scripts": {
49
+ "build": "tsc -b",
50
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
51
+ "lint": "eslint ."
52
+ }
53
+ }