open-index/open-npm huggingface dataset:
npm package: @stratasync/client
Description: Offline-first sync orchestration: identity maps, outbox batching, delta reconciliation, conflict resolution, undo/redo, and query execution.
Latest version: 0.2.4

# @stratasync/client

Offline-first sync orchestration: identity maps, outbox batching, delta reconciliation, conflict resolution, undo/redo, and query execution.

## Overview

sync-client coordinates the client-side sync lifecycle:

- **SyncClient**: Main orchestrator for the sync lifecycle
- **Outbox manager**: Batches mutations for offline-first support
- **Identity map**: Canonical in-memory object instances (deduplication via MobX reactivity)
- **Sync orchestrator**: State machine for bootstrap, delta subscription, and conflict resolution
- **History manager**: Undo/redo with inverse operation tracking
- **Query execution**: Predicate builders, sorting, and pagination against identity maps

## Installation

```bash
npm install @stratasync/client
```

Dependencies: `@stratasync/core`, `@stratasync/y-doc`

## Usage

```typescript
import { createSyncClient } from "@stratasync/client";

const client = createSyncClient({
  storage, // StorageAdapter (e.g. sync-storage-idb)
  transport, // TransportAdapter (e.g. sync-transport-graphql)
  reactivity, // ReactivityAdapter (e.g. sync-mobx)
  schema: ModelRegistry.snapshot(),
  userId,
  groups,
});

await client.start();

// Create (optimistic by default)
await client.create("Task", {
  id: crypto.randomUUID(),
  title: "New task",
  workspaceId,
  createdAt: Date.now(),
});

// Update
await client.update("Task", taskId, {
  title: "Updated title",
});

// Delete
await client.delete("Task", taskId);

// Query
const result = await client.query("Task", {
  where: (i) => i.workspaceId === workspaceId,
  limit: 50,
});
```

## Package Structure

```
src/
  index.ts             public API barrel export
  client.ts            SyncClient factory and mutation coordination
  sync-orchestrator.ts state machine: bootstrap, delta application, rebase
  outbox-manager.ts    offline mutation queue with batching and retry
  identity-map.ts      per-model ObservableMap with MobX reactivity
  history-manager.ts   undo/redo stack with inverse operation tracking
  query.ts             predicate builders and executeQuery
  types.ts             StorageAdapter, TransportAdapter, SyncClientOptions
  utils.ts             getModelKey, getModelData, pickOriginal helpers
```
npm package: @stratasync/core
Description: Core model runtime, schema metadata, sync primitives, and transaction system for the stratasync stack.
Latest version: 0.2.4

# @stratasync/core

Core model runtime, schema metadata, sync primitives, and transaction system for the stratasync stack.

## Overview

sync-core provides the foundation for the stratasync stack:

- **Model system** with decorator-based schema definitions
- **Delta application** with last-writer-wins conflict resolution (field-level)
- **Transaction creation and serialization** for client-server sync
- **Archive/unarchive** soft-delete support
- **Reactivity adapter** abstraction (implemented by sync-mobx)
- **Schema registry** with deterministic hashing for bootstrap validation
- **Identity map** and change tracking

Zero external dependencies. Pure TypeScript.

## Installation

```bash
npm install @stratasync/core
```

## Model Definitions

Models use TypeScript decorators for schema metadata:

```typescript
import { ClientModel, Property, ManyToOne, OneToMany } from "@stratasync/core";

@ClientModel("Task", {
  loadStrategy: "instant",
  tableName: "task",
  groupKey: "teamId",
})
class Task {
  @Property({ type: "string" })
  title: string;

  @Property({ type: "number" })
  createdAt: number;

  @ManyToOne("Team", { fk: "teamId" })
  team: LazyReference<Team>;

  @OneToMany("TaskChecklistItem", { fk: "taskId" })
  checklistItems: LazyCollection<TaskChecklistItem>;
}
```

## Schema System

The schema registry normalizes decorator metadata into a queryable format:

- `@ClientModel`: Registers the model class with load strategy and table mapping
- `@Property`: Defines a field with its type (`string`, `number`, `boolean`, `json`)
- `@ManyToOne` / `@Reference`: Defines a foreign key relation with lazy loading
- `@OneToMany` / `@ReferenceCollection`: Defines a reverse relation as a lazy collection
- `@BackReference`: Back-reference without storage
- `@ReferenceArray`: Many-to-many via through model
- `@EphemeralProperty`: Non-persisted property

## Sync Primitives

- **Delta applier**: Applies server deltas to local model instances using last-writer-wins
- **Rebase logic**: Reconciles local optimistic changes with server-confirmed state
- **Transaction helpers**: `createInsertTransaction`, `createUpdateTransaction`, `createDeleteTransaction`, `createArchiveTransaction`, `createUnarchiveTransaction`, `createUndoTransaction`
- **Serialization**: Compact format with abbreviated field names for storage and transport
- **Schema hash**: Deterministic, order-independent hash for detecting schema changes

## Package Structure

```
src/
├── model/       Model base class, hydration, cached promises, collections
├── schema/      Decorators, type definitions, normalization, registry, hashing
├── transaction/ Creation helpers, serialization, archive utilities, types
├── sync/        Delta applier, rebase logic, sync IDs, sync types
├── store/       SyncStore interface (implemented by sync-client)
├── reactivity/  ReactivityAdapter interface (implemented by sync-mobx)
└── utils/       ID generation, assignment helpers
```
npm package: @stratasync/mobx
Description: MobX reactivity adapter for the sync engine.
Latest version: 0.2.3

# @stratasync/mobx

MobX reactivity adapter for the sync engine.

## Overview

sync-mobx implements the reactivity adapter interface defined in `@stratasync/core` using MobX observables:

- **Observable model instances**: Model properties become MobX observables
- **Computed values**: Derived state from observable model properties
- **Reaction-based updates**: Automatic re-rendering when synced data changes

## Installation

```bash
npm install @stratasync/mobx mobx
```

Peer dependency: `mobx` ^6.0.0

## Usage

Register the MobX adapter when initializing the sync client:

```typescript
import { createSyncClient } from "@stratasync/client";
import { createMobXReactivity } from "@stratasync/mobx";

const client = createSyncClient({
  reactivity: createMobXReactivity(),
  // ...storage, transport
});
```

The adapter makes model instances observable, so MobX `observer()` components and `autorun` / `reaction` will automatically track and respond to sync updates.

## How It Works

1. When models are hydrated from sync deltas, the adapter wraps properties with MobX observables
2. React components wrapped with `observer()` automatically re-render when observed properties change
3. Computed values can derive state from multiple observable model properties
npm package: @stratasync/next
Description: Next.js App Router integration helpers.
Latest version: 0.2.3

# @stratasync/next

Next.js App Router integration helpers.

## Overview

`@stratasync/next` bridges the sync engine with Next.js App Router patterns:

- **Server utilities**: Bootstrap snapshot fetch/serialize/seed helpers
- **Client utilities**: The `NextSyncProvider` client component
- **Shared types**: Bootstrap and provider type exports

## Installation

```bash
npm install @stratasync/next
```

Peer dependencies: `next` ^14.0.0 || ^15.0.0 || ^16.0.0, `react` ^18.0.0 || ^19.0.0

## Exports

Use explicit subpaths for predictable behavior:

```typescript
// Client components
import {
  NextSyncProvider,
  type NextSyncProviderProps,
} from "@stratasync/next/client";

// Server components / route handlers
import {
  decodeBootstrapSnapshot,
  deserializeBootstrapSnapshot,
  encodeBootstrapSnapshot,
  isBootstrapSnapshotStale,
  prefetchBootstrap,
  seedStorageFromBootstrap,
  serializeBootstrapSnapshot,
  type BootstrapSnapshot,
  type BootstrapSnapshotPayload,
  type PrefetchBootstrapOptions,
  type SeedStorageOptions,
  type SeedStorageResult,
  type SerializeBootstrapOptions,
} from "@stratasync/next/server";

// Root import aliases the client entrypoint.
import { NextSyncProvider } from "@stratasync/next";
```

## Usage

Use Server Components for bootstrap loading and Client Components for interactive sync features:

```tsx
import {
  prefetchBootstrap,
  seedStorageFromBootstrap,
  type SeedStorageOptions,
} from "@stratasync/next/server";

declare const storage: SeedStorageOptions["storage"];

export default async function Page() {
  const snapshot = await prefetchBootstrap({ endpoint: "/sync" });
  await seedStorageFromBootstrap({ snapshot, storage });
  return <ClientApp>{/* render app */}</ClientApp>;
}
```

```tsx
"use client";

import { NextSyncProvider } from "@stratasync/next/client";
import type { SyncClient } from "@stratasync/client";
import type { ReactNode } from "react";

declare const client: SyncClient;

function ClientApp({ children }: { children: ReactNode }) {
  return <NextSyncProvider client={client}>{children}</NextSyncProvider>;
}
```
npm package: @stratasync/react
Description: React bindings and hooks for the sync engine.
Latest version: 0.2.4

# @stratasync/react

React bindings and hooks for the sync engine.

## Overview

sync-react provides React hooks for data fetching, real-time updates, and collaborative editing:

- **SyncProvider**: Context provider for the sync client
- **useModel / useQuery**: Data fetching with Suspense or loading states
- **useConnectionState**: Monitor sync connection status
- **useYjsDocument / useYjsPresence**: Collaborative editing and presence

## Installation

```bash
npm install @stratasync/react
```

Peer dependencies: `react` ^18.0.0 || ^19.0.0, `yjs` ^13.6.0 (for collaborative features)

## Setup

Wrap your app with `SyncProvider`:

```tsx
import { SyncProvider } from "@stratasync/react";
import { client } from "./sync-client";

function App() {
  return (
    <SyncProvider client={client}>
      <YourApp />
    </SyncProvider>
  );
}
```

## Hooks

### Data Fetching

```typescript
// Single model with Suspense (throws promise while loading)
const task = useModel("Task", taskId);

// Single model with loading state (no Suspense)
const { data: task, isLoading } = useModelState("Task", taskId);

// Filtered query
const { data: tasks, isLoading } = useQuery("Task", {
  where: (i) => i.workspaceId === workspaceId && !i.completedAt,
  limit: 50,
});

// Skip query conditionally
const { data } = useQuery("Task", { skip: !workspaceId });
```

### Connection State

```typescript
const { status, lastSyncId, backlog, error } = useConnectionState();
// status: "disconnected" | "connecting" | "bootstrapping" | "syncing" | "error"
```

### Collaborative Editing (Yjs)

```typescript
const { doc, isConnected, participants, content } = useYjsDocument(
  { entityType: "Task", entityId: taskId, fieldName: "description" },
  { autoConnect: true }
);
```

## Package Structure

```
src/
├── hooks/
│   ├── use-sync-client.ts       Access SyncClient instance
│   ├── use-model.ts             Single model (Suspense)
│   ├── use-query.ts             Filtered queries
│   ├── use-connection-state.ts  Connection monitoring
│   ├── use-yjs-document.ts      Collaborative editing
│   └── use-yjs-presence.ts      Presence tracking
├── provider.tsx                 SyncProvider component
├── context.ts                   React context
└── types.ts                     Type definitions
```
npm package: @stratasync/storage-idb
Description: IndexedDB storage adapter for client-side persistence.
Latest version: 0.2.3

# @stratasync/storage-idb

IndexedDB storage adapter for client-side persistence.

## Overview

sync-storage-idb provides offline-capable persistence using IndexedDB:

- **IndexedDB abstraction** via the `idb` library
- **Schema migrations** with versioned database upgrades
- **Transactional writes** for data consistency
- **Offline data persistence** for local-first architecture

## Installation

```bash
npm install @stratasync/storage-idb
```

Dependency: `idb` ^8.0.0

## Usage

```typescript
import { createIdbStorage } from "@stratasync/storage-idb";

const storage = createIdbStorage({
  dbName: "lse-sync",
  version: 1,
});

// Pass to SyncClient configuration
const client = new SyncClient({
  storage,
});
```

The storage adapter handles:

- Persisting model instances to IndexedDB
- Loading cached data on startup for instant UI
- Managing schema migrations when the database version changes
- Transactional writes to prevent partial updates

## Testing

Tests use `fake-indexeddb` to mock the IndexedDB API in Node.js:

```bash
npm run test
# Runs: node --import tsx --test "tests/**/*.test.ts"
```
npm package: @stratasync/transport-graphql
Description: GraphQL transport adapter for sync communication and mutations.
Latest version: 0.2.4

# @stratasync/transport-graphql

GraphQL transport adapter for sync communication and mutations.

## Overview

sync-transport-graphql handles communication between the sync client and server:

- **GraphQL client initialization**: Sync endpoint configuration
- **Delta subscriptions**: GraphQL subscriptions over WebSocket
- **Mutation document generation**: Built from model metadata
- **Message serialization**: Sync payloads including Yjs binary deltas

## Installation

```bash
npm install @stratasync/transport-graphql
```

Dependencies: `@stratasync/core`, `@stratasync/y-doc`

## Usage

```typescript
import { createGraphQLTransport } from "@stratasync/transport-graphql";

const transport = createGraphQLTransport({
  endpoint: "https://api.example.com/graphql",
  syncEndpoint: "https://api.example.com/sync",
  wsEndpoint: "wss://api.example.com/sync/ws",
  auth: {
    getAccessToken: async () => "token",
  },
});

// Pass to SyncClient configuration
const client = new SyncClient({
  transport,
});
```

## How It Works

1. **Bootstrap**: Fetches initial state via GraphQL query
2. **Subscribe**: Opens a WebSocket subscription for real-time deltas
3. **Mutate**: Sends client mutations as GraphQL mutations
4. **Reconnect**: Handles connection drops with automatic retry and resubscription

Yjs collaborative editing deltas are encoded as binary (Uint8Array) within GraphQL payloads.
npm package: @stratasync/y-doc
Description: Yjs CRDT utilities and integration for collaborative editing.
Latest version: 0.2.3

# @stratasync/y-doc

Yjs CRDT utilities and integration for collaborative editing.

## Overview

`@stratasync/y-doc` provides Yjs document management and protocol utilities:

- **Document management**: Create and manage Yjs documents for collaborative fields
- **Awareness protocol**: Presence and cursor tracking across clients
- **Delta serialization**: Encode/decode Yjs updates for transport
- **Sync protocol**: State vector exchange and update application

## Installation

```bash
npm install @stratasync/y-doc yjs
```

`yjs` is a peer dependency, so install it alongside `@stratasync/y-doc`.

## Usage

```typescript
import { YjsDocumentManager } from "@stratasync/y-doc";
import type { DocumentKey } from "@stratasync/y-doc";
import * as Y from "yjs";

const documentManager = new YjsDocumentManager({
  clientId: "client-123",
  connId: "conn-456",
});

const taskId = "task-123";

const docKey: DocumentKey = {
  entityType: "Task",
  entityId: taskId,
  fieldName: "description",
};

const doc = documentManager.getDocument(docKey);
const fragment = doc.getXmlFragment("prosemirror");

const paragraph = new Y.XmlElement("paragraph");
const text = new Y.XmlText();
text.insert(0, "Hello");
paragraph.insert(0, [text]);
fragment.insert(0, [paragraph]);

// Encode state for transport
const update = Y.encodeStateAsUpdate(doc);

// In practice, this buffer comes from the server.
Y.applyUpdate(doc, update);
```

## Concepts

- **One Yjs document per collaborative field** (e.g., `Task.description` gets its own doc)
- **ProseMirror fragment**: `YjsDocumentManager` reads and seeds the `prosemirror` fragment
- **Awareness**: Separate protocol for presence (cursors, selections, user info)
- **Binary encoding**: Yjs uses efficient binary encoding, not JSON
- **Conflict-free**: CRDT guarantees eventual consistency without server coordination
npm package: @strategic-dot/tsa-lib
Description: This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
Author: Kingsley Ifijeh
Latest version: 0.1.16

This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.