DocSync: pluggable server provider + docs overhaul#19
Merged
GermanJablo merged 22 commits intomainfrom Apr 20, 2026
Merged
Conversation
- Replaced class-based `PostgresProvider` and `InMemoryServerProvider` with function-based exports (`postgresProvider` and `inMemoryServerProvider`). - Updated documentation and examples to reflect the new provider usage. - Removed unused `drizzle-kit` dependency and related configurations. - Cleaned up `pnpm-lock.yaml` by removing obsolete entries. - Adjusted tests to utilize the new provider implementations. This change simplifies the provider instantiation and enhances the overall code structure.
- Modified the `dev` script in `package.json` to target the `examples` filter for database pushing. - Added new `db:push` and `db:studio` scripts in the `examples/package.json` for managing the database with `drizzle-kit`. - Introduced `drizzle.config.ts` and `postgres-schema.ts` in the `examples` directory to define database schema and configuration. - Updated `pnpm-lock.yaml` to include new dependencies for `drizzle-orm`, `postgres`, and `drizzle-kit`. - Removed obsolete Postgres provider implementation and related files from the `packages/docsync` directory. These changes streamline the development process and enhance database management capabilities.
- Removed specific files from the ignore list in `knip.ts` and added a new pattern for collab-server. - Consolidated the `ignoreDependencies` list in `knip.ts` for clarity. - Introduced a new documentation file for DocSync providers, detailing the implementation of a Postgres provider and its usage. - Updated the server documentation to reference the new providers and their configurations. - Added example files for a collab-server setup, including database schema and provider implementations. These changes enhance the configuration management and provide comprehensive documentation for users implementing custom storage backends.
- Changed the schema path in `drizzle.config.ts` to point to the collab-server directory. - Refactored `ServerProvider` and related types in `types.ts` to use `NoInfer` for better type safety. - Updated `inMemoryServerProvider` in `memory.ts` to utilize generic types more effectively, replacing specific types with `unknown` for flexibility. These changes improve the configuration management and enhance type safety across the DocSync implementation.
- Updated the Postgres provider to use generic types for better type inference with `JsonDoc` and `Operations`. - Changed the schema definitions in `postgres-schema.ts` to use `text` instead of `jsonb` for `doc` and `operations` fields, ensuring compatibility with the new provider structure. - Added a new compile-time check for `ServerProvider<S, O>` to validate type consistency in the server configuration. These changes enhance type safety and ensure the Postgres provider aligns with the updated schema structure.
…ty and functionality - Updated the `local.provider` type in `types.ts` to use a factory function instead of a constructor, enhancing flexibility. - Refactored the `IndexedDBProvider` to be a function-based export, simplifying instantiation and improving type safety. - Adjusted the `transaction` method in `IndexedDBProvider` to utilize a more streamlined context management approach. - Modified tests to align with the new provider structure, ensuring compatibility and correctness. These changes enhance the overall architecture of the DocSync client and its providers, promoting better type safety and usability.
…ntion - Updated all instances of `IndexedDBProvider` to `indexedDBProvider` across documentation, examples, and tests for consistency. - Adjusted related comments and documentation to reflect the new naming convention. These changes enhance clarity and maintain uniformity in the codebase.
- Updated the documentation for the `ServerProvider` and introduced the `ClientProvider`, clarifying their roles and usage. - Changed the schema definitions in the Postgres provider to use `text` instead of `jsonb` for `doc` and `operations` fields, ensuring compatibility with the new provider structure. - Improved type safety by utilizing generic types for `JsonDoc` and `Operations` in the Postgres provider implementation. - Added detailed explanations for CRUD methods and their context management in the provider examples. These changes improve clarity and type safety in the documentation and provider implementations.
…viders - Updated the `getSerializedDoc` method in various provider contexts to accept an object argument instead of a single string parameter, enhancing clarity and consistency in the API. - Adjusted related documentation and examples to reflect the new method signature. These changes improve the usability and maintainability of the DocSync provider interfaces.
- Revised the description for the storage provider to enhance clarity. - Improved the explanation of the Postgres provider, emphasizing its adaptability for custom implementations. - Clarified the context of type casts in the Postgres provider to better inform users about type handling. These changes aim to improve the overall clarity and usability of the documentation for users implementing custom storage solutions.
- Removed the `collab-server` example from the ignore list in `knip.ts` and added a new workspace configuration for `collab-server` entry points. - Updated the `applyServerOperations` function signature for consistency and clarity. - Renamed `replaceDocInCache` to `_replaceDocInCache` and added a TODO comment for future improvements. - Deleted the obsolete `_variance-check.ts` file and introduced a new `variance.test.ts` file to validate type checks for `ServerProvider`. These changes improve the configuration management, enhance type safety, and streamline testing for the DocSync implementation.
- Added "shiki" to the Knip configuration for ESLint TypeScript syntax highlighting. - Removed "ts-morph" and "drizzle-kit" from the package dependencies in `pnpm-lock.yaml` and `docs/package.json` to streamline the project. - Updated the `vitest` entry in `docnode-lexical/package.json` to support both `.ts` and `.tsx` files. These changes improve the configuration and maintainability of the project.
…ports in DocNodePlugin
- Introduced a new documentation page titled "How It Works" to explain the DocSync sync model, including key concepts like snapshots, operations, and the client-server interaction. - Updated the Postgres schema to use `bigint` and `bigserial` for clock fields, ensuring better compatibility and performance. - Enhanced the provider implementation to reflect these schema changes, improving overall type safety and consistency. These changes aim to improve user understanding of the sync model and enhance the robustness of the Postgres provider.
…tions - Added a section in the "How It Works" documentation to explain the rationale behind using both a snapshot and an operation log, detailing the benefits for single and multiple writer scenarios. - Updated the providers documentation to reference the new "How It Works" section, guiding users to understand the schema design better. These changes aim to improve user comprehension of the DocSync architecture and its implementation strategies.
- Added the `saveSerializedDoc` method to the PostgresProvider implementation in both the main and example files, allowing for document serialization and conflict resolution during inserts. - Updated the implementation checklist in the documentation to reflect the completion of the sync method in the postgres example. - Removed obsolete test file for provider testing, streamlining the test suite. These changes enhance the functionality of the PostgresProvider and improve the overall example implementations.
…stamp handling - Modified the `updatedAt` field in the Postgres schema to automatically update its value on record modification. - Removed manual setting of `updatedAt` in the `saveSerializedDoc` method within the PostgresProvider examples, ensuring consistency with the schema changes. - Simplified the database connection setup in the example by removing unnecessary options. These changes enhance the functionality and maintainability of the Postgres provider and its examples.
- Modified assertions in the `index.browser.test.ts` file to include a `clock` parameter in the `assertIDBDoc` method, ensuring accurate state representation during tests. - Updated the `assertIDBDoc` method signature in `utils.ts` to accept the `clock` parameter, enhancing type safety and consistency across the testing utilities. - Adjusted the `emptyIDB` export to include a default clock value, aligning with the new method signature. These changes improve the accuracy and reliability of the Local-First test suite.
- Updated the `assertIDBDoc` method in `index.browser.test.ts` to eliminate the `clock` parameter, simplifying the assertions for document state. - Modified the `assertIDBDoc` method signature in `utils.ts` to reflect the removal of the `clock` parameter, enhancing type consistency. - Adjusted the `emptyIDB` export to align with the new method signature. These changes streamline the testing process and improve the clarity of IDB assertions.
- Updated the `deleteOperations` method in the Postgres provider to utilize `inArray` for batch deletion of operations, improving efficiency and readability. - Enhanced the database connection setup in the example to provide a default URL if the environment variable is not set. - Clarified the documentation regarding the `Clock` concept by simplifying its description in the "How It Works" section. These changes enhance the performance of the Postgres provider and improve the clarity of the documentation.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Updated type definitions for `LocalResolved`, `ClientProvider`, `ClientProviderContext`, `ServerProvider`, and `ServerProviderContext` to enforce generic constraints, improving type safety across the codebase. - Added a new section in the documentation to outline TypeScript rules, emphasizing the importance of avoiding the use of `any` without explicit approval. These changes aim to strengthen type safety and provide clearer guidelines for TypeScript usage in the project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@docukit/docsyncand reshapes both server and client providers into pluggable factory functions, so users bring their own storage. The IndexedDB client provider is rewritten against this model.examples/collab-server/reference (Drizzle schema, Postgres provider, server entry, drizzle config) demonstrating BYO Postgres end-to-end.variancetest.Test plan
pnpm check(prettier, eslint, tsc)pnpm check:deps(knip)pnpm test:once🤖 Generated with Claude Code