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
5 changes: 5 additions & 0 deletions .changeset/shiny-bees-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/service-sync-rules': patch
---

Change TableV2 to Table in schema generator
4 changes: 2 additions & 2 deletions packages/sync-rules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"yaml": "^2.3.1"
},
"devDependencies": {
"@types/node": "18.11.11",
"vitest": "^0.34.6"
"@types/node": "18.19.50",
"vitest": "^2.0.5"
}
}
10 changes: 5 additions & 5 deletions packages/sync-rules/src/TsSchemaGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ ${this.generateTypeExports()}`;
private generateImports() {
const importStyle = this.options.imports ?? 'auto';
if (importStyle == TsSchemaImports.web) {
return `import { column, Schema, TableV2 } from '@powersync/web';`;
return `import { column, Schema, Table } from '@powersync/web';`;
} else if (importStyle == TsSchemaImports.reactNative) {
return `import { column, Schema, TableV2 } from '@powersync/react-native';`;
return `import { column, Schema, Table } from '@powersync/react-native';`;
} else {
return `import { column, Schema, TableV2 } from '@powersync/web';
// OR: import { column, Schema, TableV2 } from '@powersync/react-native';`;
return `import { column, Schema, Table } from '@powersync/web';
// OR: import { column, Schema, Table } from '@powersync/react-native';`;
}
}

private generateTable(name: string, columns: ColumnDefinition[]): string {
return `const ${name} = new TableV2(
return `const ${name} = new Table(
{
// id column (text) is automatically included
${columns.map((c) => this.generateColumn(c)).join(',\n ')}
Expand Down
8 changes: 4 additions & 4 deletions packages/sync-rules/test/src/sync_rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,10 @@ bucket_definitions:
`);

expect(new TsSchemaGenerator().generate(rules, schema)).toEqual(
`import { column, Schema, TableV2 } from '@powersync/web';
// OR: import { column, Schema, TableV2 } from '@powersync/react-native';
`import { column, Schema, Table } from '@powersync/web';
// OR: import { column, Schema, Table } from '@powersync/react-native';

const assets1 = new TableV2(
const assets1 = new Table(
{
// id column (text) is automatically included
name: column.text,
Expand All @@ -798,7 +798,7 @@ const assets1 = new TableV2(
{ indexes: {} }
);

const assets2 = new TableV2(
const assets2 = new Table(
{
// id column (text) is automatically included
name: column.text,
Expand Down
Loading