Sync / foldkit-sync

DefinedSync

interface · packages/sync/src/make.ts:206

interface DefinedSync<
  AppModel,
  Fields extends Schema.Struct.Fields,
  Message,
  Ms extends readonly unknown[],
  Principal = unknown,
  Authorized extends boolean = false,
> extends Sync<Message, Schema.Struct.Type<Fields>> {
  readonly surface: Surface<
    AppModel,
    Schema.Struct.Type<Fields>,
    MsgOf<Ms>,
    void
  >
  readonly projection: WritableProjection<AppModel, Fields>
  readonly replay: (
    shared: Schema.Struct.Type<Fields>,
    message: Message,
  ) => Schema.Struct.Type<Fields>
  readonly messages: Ms
  readonly contract: Contract
  readonly wiring: () => Wiring<AppModel, never>
  readonly journalContract: () => Authorized extends true
    ? PolicyJournalContract<Operation, Schema.Struct.Type<Fields>, Principal> &
        Required<
          Pick<
            PolicyJournalContract<
              Operation,
              Schema.Struct.Type<Fields>,
              Principal
            >,
            'authorize'
          >
        >
    : PolicyJournalContract<Operation, Schema.Struct.Type<Fields>, Principal>
}

The value make returns: the low-level Sync protocol plus the writable projection, the declared Messages, and a read-only Surface over the projection. Exported so a consumer can name the type.

Members

DefinedSync.surface

property · packages/sync/src/make.ts:215

readonly surface: Surface<
  AppModel,
  Schema.Struct.Type<Fields>,
  MsgOf<Ms>,
  void
>

DefinedSync.projection

property · packages/sync/src/make.ts:216

readonly projection: WritableProjection<AppModel, Fields>

DefinedSync.replay

property · packages/sync/src/make.ts:218

readonly replay: (
  shared: Schema.Struct.Type<Fields>,
  message: Message,
) => Schema.Struct.Type<Fields>

The reducer the replica replays durable Messages with: derived from update, or make's replay.

DefinedSync.messages

property · packages/sync/src/make.ts:222

readonly messages: Ms

DefinedSync.contract

property · packages/sync/src/make.ts:224

readonly contract: Contract

For Module: this contract owns the shared projection's paths and records the durable tags.

DefinedSync.wiring

property · packages/sync/src/make.ts:230

readonly wiring: () => Wiring<AppModel, never>

How this contract joins an assembly: contract-only, so the Module sees it. It routes nothing, runs nothing, and subscribes to nothing; Sync owns the runtime through mount rather than joining it.

DefinedSync.journalContract

property · packages/sync/src/make.ts:232

readonly journalContract: () => Authorized extends true
  ? PolicyJournalContract<Operation, Schema.Struct.Type<Fields>, Principal> &
      Required<
        Pick<
          PolicyJournalContract<
            Operation,
            Schema.Struct.Type<Fields>,
            Principal
          >,
          'authorize'
        >
      >
  : PolicyJournalContract<Operation, Schema.Struct.Type<Fields>, Principal>

The durable journal's codecs, reducer, and, when declared, authorization.