Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/sunny-sloths-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@powersync/cli-core': patch
'@powersync/cli-schemas': patch
'powersync': patch
---

Update YAML schema reference towards Sync Config definitions.
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@powersync/management-types": "catalog:",
"@powersync/service-sync-rules": "catalog:",
"@powersync/service-types": "catalog:",
"@powersync/sync-config-tools": "^0.1.2",
"@powersync/sync-config-tools": "^0.1.4",
"bson": "^7.2.0",
"diff": "^8.0.4",
"fastify": "^5.8.5",
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/migrate/sync-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class MigrateSyncRules extends SharedInstanceCommand {

case 'success': {
const outputContent = output.result;
await writeFile(syncOutputPath, YAML_SYNC_RULES_SCHEMA + outputContent);
await writeFile(syncOutputPath, `${YAML_SYNC_RULES_SCHEMA}\n${outputContent}`);
Comment thread
stevensJourney marked this conversation as resolved.
this.log(ux.colorize('green', `Wrote ${syncOutputPath} with migrated sync streams.`));
break;
}
Expand Down
5 changes: 2 additions & 3 deletions cli/test/commands/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ describe('migrate', () => {
const outputFile = join(testDirectory, 'output.yaml');
writeFileSync(
inputFile,
`
bucket_definitions:
`bucket_definitions:
user_lists:
parameters: SELECT request.user_id() as user_id
data:
Expand All @@ -32,7 +31,7 @@ bucket_definitions:
const transformed = readFileSync(outputFile).toString('utf8');
expect(transformed)
.toStrictEqual(`# Adds YAML Schema support for VSCode users with the YAML extension installed. This enables features like validation and autocompletion based on the provided schema.
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_rules.json
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_config.json
config:
edition: 3
streams:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_rules.json
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_config.json
#
# See Documentation for more information:
# https://docs.powersync.com/sync/overview
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_rules.json
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_config.json
#
# See Documentation for more information:
# https://docs.powersync.com/sync/overview
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_rules.json
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_config.json
#
# See Documentation for more information:
# https://docs.powersync.com/sync/overview
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-core/src/utils/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as yaml from 'yaml';

export const YAML_SYNC_RULES_SCHEMA = /* yaml */ `
# Adds YAML Schema support for VSCode users with the YAML extension installed. This enables features like validation and autocompletion based on the provided schema.
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_rules.json
# yaml-language-server: $schema=https://unpkg.com/@powersync/service-sync-rules@latest/schema/sync_config.json
`.trim();

export const YAML_SERVICE_SCHEMA = /* yaml */ `
Expand Down
10 changes: 3 additions & 7 deletions packages/schemas/src/scripts/create-schemas.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import _SyncSchema from '@powersync/service-sync-rules/schema/sync_config.json' with { type: 'json' };
import { mkdirSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import { CLIConfigSchema } from '../CLIConfig.js';
import { ServiceConfigSchema } from '../ServiceConfig.js';

// todo: Import '@powersync/service-sync-rules/schema/sync_config.json' after https://github.com/powersync-ja/powersync-service/pull/824.
const syncRulesIndex = import.meta.resolve('@powersync/service-sync-rules'); // resolves to dist/index.js
const schemaFile = fileURLToPath(new URL('../schema/sync_rules.json', syncRulesIndex));
const syncConfigSchema = JSON.parse(readFileSync(schemaFile, { encoding: 'utf8' }));

const __dirname = dirname(fileURLToPath(import.meta.url));
const schemaDir = join(__dirname, '..', '..', 'json-schema');

mkdirSync(schemaDir, { recursive: true });

writeFileSync(join(schemaDir, 'cli-config.json'), JSON.stringify(CLIConfigSchema, null, 2));
writeFileSync(join(schemaDir, 'service-config.json'), JSON.stringify(ServiceConfigSchema, null, 2));
writeFileSync(join(schemaDir, 'sync-config.json'), JSON.stringify(syncConfigSchema, null, 2));
writeFileSync(join(schemaDir, 'sync-config.json'), JSON.stringify(_SyncSchema, null, 2));
73 changes: 42 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ catalog:
'@oclif/core': ^4.10.6
'@powersync/management-client': ^0.1.7
'@powersync/management-types': ^0.3.0
'@powersync/service-client': ^0.0.10
'@powersync/service-schema': ^1.26.1
'@powersync/service-sync-rules': ^0.42.0
'@powersync/service-types': ^0.18.0
'@powersync/service-client': ^0.0.11
'@powersync/service-schema': ^1.27.0
'@powersync/service-sync-rules': ^0.43.0
'@powersync/service-types': ^0.19.0
oclif: ^6.0.2

patchedDependencies:
Expand Down
Loading