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
6 changes: 6 additions & 0 deletions .changeset/yellow-knives-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@powersync/service-core': patch
'@powersync/service-image': patch
---

Protocol: Allow `null` as stream parameter.
4 changes: 2 additions & 2 deletions packages/service-core/src/util/protocol-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from 'ts-codec';
import { BucketDescription, BucketPriority, SqliteJsonRow } from '@powersync/service-sync-rules';
import { BucketPriority, SqliteJsonRow } from '@powersync/service-sync-rules';
import { JsonContainer } from '@powersync/service-jsonbig';

export const BucketRequest = t.object({
Expand All @@ -24,7 +24,7 @@ export const RequestedStreamSubscription = t.object({
/**
* An optional dictionary of parameters to pass to this specific stream.
*/
parameters: t.record(t.any).optional(),
parameters: t.union(t.record(t.any), t.Null),
/**
* Set when the client wishes to re-assign a different priority to this stream.
*
Expand Down
43 changes: 43 additions & 0 deletions packages/service-core/test/src/util/protocol_types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { StreamingSyncRequest } from '@/index.js';
import { schema } from '@powersync/lib-services-framework';
import { describe, test, expect, it } from 'vitest';

describe('protocol types', () => {
describe('StreamingSyncRequest', () => {
const validator = schema.createTsCodecValidator(StreamingSyncRequest, { allowAdditional: true });

test('with streams', () => {
expect(
validator.validate({
buckets: [],
include_checksum: true,
raw_data: true,
binary_data: true,
client_id: '0da33a94-c140-4b42-b3b3-a1df3b1352a3',
parameters: {},
streams: {
include_defaults: true,
subscriptions: [{ stream: 'does_not_exist', parameters: null, override_priority: null }]
}
} as any)
).toMatchObject({ valid: true });
});

test('does not allow missing parameters', () => {
expect(
validator.validate({
buckets: [],
include_checksum: true,
raw_data: true,
binary_data: true,
client_id: '0da33a94-c140-4b42-b3b3-a1df3b1352a3',
parameters: {},
streams: {
include_defaults: true,
subscriptions: [{ stream: 'a', override_priority: null }]
}
} as any)
).toMatchObject({ valid: false });
});
});
});
2 changes: 0 additions & 2 deletions packages/sync-rules/src/streams/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BucketInclusionReason, BucketPriority, DEFAULT_BUCKET_PRIORITY } from '
import { BucketParameterQuerier, PendingQueriers } from '../BucketParameterQuerier.js';
import { BucketSource, BucketSourceType, ResultSetDescription } from '../BucketSource.js';
import { ColumnDefinition } from '../ExpressionType.js';
import { CompatibilityContext } from '../compatibility.js';
import { SourceTableInterface } from '../SourceTableInterface.js';
import { GetQuerierOptions, RequestedStream } from '../SqlSyncRules.js';
import { TablePattern } from '../TablePattern.js';
Expand All @@ -17,7 +16,6 @@ import {
SqliteRow,
TableRow
} from '../types.js';
import { applyRowContext } from '../utils.js';
import { StreamVariant } from './variant.js';

export class SyncStream implements BucketSource {
Expand Down