Skip to content

Commit

Permalink
fix: fix type issues after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Nov 28, 2024
1 parent 8d71f7e commit 0f4c0f5
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 42 deletions.
16 changes: 0 additions & 16 deletions src/_unstable_machine.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
export {type Insert} from './encoders/sanity'
export * from './machine'
export type * from './mendozaTypes'
export {
type SanityCreateIfNotExistsMutation,
type SanityCreateMutation,
type SanityCreateOrReplaceMutation,
type SanityDeleteMutation,
type SanityDiffMatchPatch,
type SanityInsertPatch,
type SanityMutation,
type SanityMutationEvent,
type SanityPatchMutation,
type SanitySetIfMissingPatch,
type SanitySetPatch,
type SanityUnsetPatch,
} from './store/sanityApiTypes'
1 change: 0 additions & 1 deletion src/_unstable_store.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './store'
export type * from './mendozaTypes'
3 changes: 2 additions & 1 deletion src/machine/__tests__/documentMutatorMachine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const createFakeClient = (
| Promise<Record<string, unknown> | undefined> = undefined,
observer: Observable<ListenEvent<Record<string, unknown>>> = of({
type: 'welcome',
listenerName: 'xyz',
}),
) => {
const client = {
Expand Down Expand Up @@ -64,7 +65,7 @@ describe('observing documents', () => {
const client = createFakeClient(
undefined,
concat(
of({type: 'welcome' as const}),
of({type: 'welcome' as const, listenerName: 'xyz'}),
of({
type: 'mutation' as const,
eventId: `tc4gfghO54pOTXYCOfNgyx#${id}`,
Expand Down
14 changes: 7 additions & 7 deletions src/machine/documentMutatorMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
type SanityDocumentBase,
type Transaction,
} from '../store'
import {applyMutations} from '../store/datasets/applyMutations'
import {commit} from '../store/datasets/commit'
import {applyMutations} from '../store/documentMap/applyMutations'
import {commit} from '../store/documentMap/commit'
import {squashDMPStrings} from '../store/optimizations/squashDMPStrings'
import {squashMutationGroups} from '../store/optimizations/squashMutations'
import {rebase} from '../store/rebase'
Expand All @@ -38,7 +38,7 @@ export interface DocumentMutatorMachineInput {
/** A shared listener can be provided, if not it'll be created using `client.listen()` */
sharedListener?: ReturnType<typeof createSharedListener>
/* Preferrably a LRU cache map that is compatible with an ES6 Map, and have documents that allow unique ids to a particular dataset */
cache?: Map<string, SanityDocument<DocumentType> | null>
cache?: Map<string, SanityDocument | null>
}

export type DocumentMutatorMachineParentEvent =
Expand Down Expand Up @@ -68,11 +68,11 @@ export const documentMutatorMachine = setup({
/** The document id */
id: string
/* Preferrably a LRU cache map that is compatible with an ES6 Map, and have documents that allow unique ids to a particular dataset */
cache?: Map<string, SanityDocument<DocumentType> | null>
cache?: Map<string, SanityDocument | null>
/* The remote snapshot of what the document looks like in Content Lake, kept in sync by applying Mendoza patches in real time. undefined means it's unknown if it exists yet, null means its known that it doesn't exist. */
remote: SanityDocument<DocumentType> | null | undefined
remote: SanityDocument | null | undefined
/* Local snapshot, that is rebased to the remote snapshot whenever that snapshot changes, and allows optimistic local mutations. undefined means it's unknown if the document exists in content lake yet, if both `remote` and `local` is `null` it means it's known that it doesn't exist. If `remote` is defined, and `local` is `null` it means it's optimistically deleted. If `remote` is `null` and `local` defined then it's optimistically created. */
local: SanityDocument<DocumentType> | null | undefined
local: SanityDocument | null | undefined
/* Remote mendoza mutation events, needs a better name to differentiate from optimistic mutations */
mutationEvents: MutationEvent[]
/* Track staged mutations that can be submitted */
Expand All @@ -97,7 +97,7 @@ export const documentMutatorMachine = setup({
| {type: 'submit'}
| {
type: 'xstate.done.actor.getDocument'
output: SanityDocument<DocumentType>
output: SanityDocument
}
| {
type: 'xstate.done.actor.submitTransactions'
Expand Down
26 changes: 13 additions & 13 deletions src/machine/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export {
applyMutations,
type UpdateResult,
} from '../store/datasets/applyMutations'
export {commit} from '../store/datasets/commit'
export {
type DataStore,
squashDMPStrings,
} from '../store/optimizations/squashDMPStrings'
export {squashMutationGroups} from '../store/optimizations/squashMutations'
export {rebase} from '../store/rebase'
export {toTransactions} from '../store/toTransactions'
export {type UpdateResult} from '../store/documentMap/applyMutations'
export {type DataStore} from '../store/optimizations/squashDMPStrings'
export type {
Dataset,
Conflict,
DocumentMap,
LocalDataset,
MutationGroup,
MutationResult,
NonTransactionalMutationGroup,
OptimisticDocumentEvent,
RawOperation,
RawPatch,
RemoteDocumentEvent,
RemoteMutationEvent,
RemoteSyncEvent,
SubmitResult,
TransactionalMutationGroup,
} from '../store/types'
export * from './documentMutatorMachine'
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/store/toTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Transaction} from '../_unstable_store'
import type {MutationGroup} from './types'
import {type Transaction} from '../mutations/types'
import {type MutationGroup} from './types'

export function toTransactions(groups: MutationGroup[]): Transaction[] {
return groups.map(group => {
Expand Down
3 changes: 2 additions & 1 deletion src/store/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {type RawPatch} from 'mendoza'
import {type RawOperation, type RawPatch} from 'mendoza'
import {type Observable} from 'rxjs'

import {type Mutation, type SanityDocumentBase} from '../mutations/types'
import {type Path} from '../path'
import {type SanityMutation} from './sanityMutationTypes'

export {type RawOperation, type RawPatch}
export interface ListenerSyncEvent<
Doc extends SanityDocumentBase = SanityDocumentBase,
> {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"lib": ["es2023"],
"lib": ["es2023", "esnext.promise"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
Expand Down

0 comments on commit 0f4c0f5

Please sign in to comment.