From 2bfc6dd6daadd43e353784a2a7cb359a4d9e9f64 Mon Sep 17 00:00:00 2001 From: Grant Forrest Date: Fri, 19 Jul 2024 12:16:56 -0400 Subject: [PATCH] update test snapshot --- .../test/__snapshots__/generated.test.ts.snap | 54 +++++++++---------- packages/store/src/sync/Sync.ts | 7 ++- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/packages/cli/test/__snapshots__/generated.test.ts.snap b/packages/cli/test/__snapshots__/generated.test.ts.snap index 5875b10e..70e19a88 100644 --- a/packages/cli/test/__snapshots__/generated.test.ts.snap +++ b/packages/cli/test/__snapshots__/generated.test.ts.snap @@ -105,8 +105,11 @@ import { export type Todo = ObjectEntity; export type TodoId = string; +/** The content of the todo item */ export type TodoContent = string; +/** Whether the todo item is done */ export type TodoDone = boolean; +/** Attach tags to an item to categorize it */ export type TodoTags = ListEntity< TodoTagsInit, TodoTagsDestructured, @@ -433,43 +436,34 @@ var todo = schema.collection({ name: "todo", primaryKey: "id", fields: { - id: { - type: "string", - default: () => Math.random().toString(36).slice(2, 9) - }, - content: { - type: "string", - default: "" - }, - done: { - type: "boolean" - }, - tags: { - type: "array", + id: schema.fields.id(), + content: schema.fields.string({ + default: "", + documentation: "The content of the todo item" + }), + done: schema.fields.boolean({ + documentation: "Whether the todo item is done" + }), + tags: schema.fields.array({ items: { type: "string", options: ["work", "home", "other"] - } - }, - category: { - type: "string", + }, + documentation: "Attach tags to an item to categorize it" + }), + category: schema.fields.string({ nullable: true - }, - attachments: { - type: "array", - items: { - type: "object", + }), + attachments: schema.fields.array({ + items: schema.fields.object({ properties: { - name: { - type: "string" - }, - test: { - type: "number", + name: schema.fields.string(), + test: schema.fields.number({ default: 1 - } + }) } - } - } + }) + }) }, indexes: { example: { diff --git a/packages/store/src/sync/Sync.ts b/packages/store/src/sync/Sync.ts index e3e4a94a..9eef6706 100644 --- a/packages/store/src/sync/Sync.ts +++ b/packages/store/src/sync/Sync.ts @@ -185,6 +185,8 @@ export interface ServerSyncOptions * Not sure why you want to do this, but be careful. */ onOutgoingMessage?: (message: ClientMessage) => void; + + EXPERIMENTAL_backgroundSync?: boolean; } export class ServerSync @@ -226,6 +228,7 @@ export class ServerSync defaultProfile, useBroadcastChannel, onOutgoingMessage, + EXPERIMENTAL_backgroundSync, }: ServerSyncOptions, { meta, @@ -334,7 +337,9 @@ export class ServerSync this.start(); } - attemptToRegisterBackgroundSync(); + if (EXPERIMENTAL_backgroundSync) { + attemptToRegisterBackgroundSync(); + } } get canDoRealtime() {