index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/authStore/providerLogos.tsx | import type {Theme} from '@sanity/ui'
import React from 'react'
import styled, {css} from 'styled-components'
import type {AuthProvider} from '../../../config'
const GithubRoot = styled.svg(({theme}: {theme: Theme}) => {
const {fg} = theme.sanity.color.base
return css`
fill: ${fg};
`
})
const CustomImage =... | 3,600 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/authStore/providerTitle.ts | /** @internal */
export function getProviderTitle(provider?: string): string | undefined {
if (provider === 'google') {
return 'Google'
}
if (provider === 'github') {
return 'GitHub'
}
if (provider === 'sanity') {
return 'Sanity'
}
if (provider?.startsWith('saml-')) {
return 'SAML/SSO'
... | 3,601 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/authStore/sessionId.ts | // Trailing '&' included so we can replace `#sid=foo&bar=baz` with `#bar=baz`
const sidPattern = /sid=([^&]{20,})&?/
function consumeSessionId(): string | null {
// Are we in a browser-like environment?
if (typeof window === 'undefined' || typeof window.location !== 'object') {
return null
}
// Does the h... | 3,602 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/authStore/storage.ts | const supportsLocalStorage = (() => {
const key = '__tmp_supports_local_storage'
try {
if (typeof localStorage === 'undefined') {
return false
}
localStorage.setItem(key, '---')
localStorage.removeItem(key)
return true
} catch (err) {
return false
}
})()
const memStore: Record<s... | 3,603 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/authStore/types.ts | import {SanityClient} from '@sanity/client'
import {CurrentUser} from '@sanity/types'
import {Observable} from 'rxjs'
import {WorkspaceSummary} from '../../../config'
/**
* The interface used by the Studio that produces a `SanityClient` and
* `CurrentUser` that gets passed to the resulting `Workspace`s and `Source`s... | 3,604 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/connection-status/connection-status-store.ts | import {BifurClient} from '@sanity/bifur-client'
import {observableCallback} from 'observable-callback'
import {map, mergeMapTo, startWith, take, takeUntil} from 'rxjs/operators'
import {concat, fromEvent, merge, NEVER, Observable, of, throwError, timer} from 'rxjs'
import {catchWithCount} from './utils/catchWithCount'... | 3,605 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/connection-status/index.ts | export * from './connection-status-store'
| 3,606 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/connection-status | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/connection-status/utils/catchWithCount.ts | import {Observable, OperatorFunction} from 'rxjs'
import {catchError, tap} from 'rxjs/operators'
type Selector<T, K> = (error: any, attemptNo: number, caught: Observable<T>) => Observable<K>
export function catchWithCount<T, K = T>(selector: Selector<T, K>): OperatorFunction<T, K>
export function catchWithCount<T, K... | 3,607 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/cors/CorsOriginError.ts | /** @internal */
export interface CorsOriginErrorOptions {
projectId?: string
}
/** @internal */
export class CorsOriginError extends Error {
projectId?: string
constructor({projectId}: CorsOriginErrorOptions) {
super('CorsOriginError')
this.projectId = projectId
}
}
| 3,608 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/cors/index.ts | export * from './CorsOriginError'
| 3,609 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/debugParams/debugParams.ts | import {concat, of, fromEvent} from 'rxjs'
import {distinctUntilChanged, map} from 'rxjs/operators'
const DEBUG_PREFIX = '_debug_'
const hashchange$ = typeof window === 'undefined' ? of({}) : fromEvent(window, 'hashchange')
export const debugParams$ = concat(of(0), hashchange$).pipe(
map(() => (typeof document ===... | 3,610 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/debugParams/index.ts | export * from './debugParams'
| 3,611 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-store.ts | import {SanityClient} from '@sanity/client'
import {InitialValueResolverContext, Schema} from '@sanity/types'
import {Observable} from 'rxjs'
import {filter, map} from 'rxjs/operators'
import {HistoryStore} from '../history'
import {DocumentPreviewStore} from '../../../preview'
import {getDraftId, isDraftId} from '../.... | 3,612 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/getPairListener.ts | /* eslint-disable @typescript-eslint/no-use-before-define */
import type {SanityDocument} from '@sanity/types'
import {defer, Observable, of as observableOf} from 'rxjs'
import {concatMap, map, mergeMap, scan} from 'rxjs/operators'
import {groupBy} from 'lodash'
import {SanityClient} from '@sanity/client'
import type {... | 3,613 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/index.ts | export * from './buffered-doc'
export * from './document-pair'
export * from './document-store'
export * from './getPairListener'
export * from './hooks'
export * from './initialValue'
export * from './listenQuery'
export * from './types'
export * from './useInitialValue'
export * from './useResolveInitialValueForType'... | 3,614 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/listenQuery.ts | import type {ClientPerspective, SanityClient} from '@sanity/client'
import {asyncScheduler, defer, merge, Observable, of, partition, throwError, timer} from 'rxjs'
import {filter, mergeMap, share, take, throttleTime} from 'rxjs/operators'
import {exhaustMapWithTrailing} from 'rxjs-exhaustmap-with-trailing'
import {Muta... | 3,615 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/resolveTypeForDocument.ts | import {SanityClient} from '@sanity/client'
import type {Observable} from 'rxjs'
import {of} from 'rxjs'
import {map} from 'rxjs/operators'
import {getDraftId, getPublishedId} from '../../../util'
export function resolveTypeForDocument(
client: SanityClient,
id: string,
specifiedType = '*',
): Observable<string>... | 3,616 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/types.ts | import {MutationPayload} from './buffered-doc/types'
/** @internal */
export interface WelcomeEvent {
type: 'welcome'
}
/** @internal */
export interface MutationEvent {
type: 'mutation'
documentId: string
transactionId: string
mutations: MutationPayload[]
effects: {apply: unknown; revert: unknown}
tra... | 3,617 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/useInitialValue.ts | import {InitialValueResolverContext, SanityDocumentLike} from '@sanity/types'
import {useEffect, useMemo, useState} from 'react'
import {useDataset, useProjectId, useSchema} from '../../../hooks'
import {useSource} from '../../../studio'
import {useUnique} from '../../../util'
import {useCurrentUser} from '../../user'
... | 3,618 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/useResolveInitialValueForType.ts | import {SchemaType} from '@sanity/types'
import {useCallback} from 'react'
import {DEFAULT_MAX_RECURSION_DEPTH, resolveInitialValueForType} from '../../../templates'
import {useInitialValueResolverContext} from './useInitialValue'
/** @internal */
export function useResolveInitialValueForType<Params extends Record<str... | 3,619 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/buffered-doc/createBufferedDocument.ts | import {SanityDocument} from '@sanity/types'
import {Observable} from 'rxjs'
import {ListenerEvent} from '../getPairListener'
import {CommitRequest, createObservableBufferedDocument} from './createObservableBufferedDocument'
import {
CommittedEvent,
DocumentMutationEvent,
DocumentRebaseEvent,
MutationPayload,
... | 3,620 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/buffered-doc/createObservableBufferedDocument.ts | import {BufferedDocument, Mutation} from '@sanity/mutator'
import {SanityDocument} from '@sanity/types'
import {BehaviorSubject, EMPTY, merge, Observable, Subject} from 'rxjs'
import {
distinctUntilChanged,
filter,
map,
mergeMapTo,
publishReplay,
refCount,
scan,
share,
take,
tap,
withLatestFrom,
}... | 3,621 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/buffered-doc/index.ts | export * from './createBufferedDocument'
export * from './createObservableBufferedDocument'
export * from './types'
| 3,622 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/buffered-doc/types.ts | import {Mutation} from '@sanity/mutator'
import {SanityDocument} from '@sanity/types'
/** @internal */
export type CommitFunction = (mutation: Mutation['params']) => Promise<unknown>
/**
* @hidden
* @beta */
export interface DocumentRebaseEvent {
type: 'rebase'
document: SanityDocument
remoteMutations: Mutati... | 3,623 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/checkoutPair.ts | import {SanityClient} from '@sanity/client'
import {EMPTY, from, merge, Observable} from 'rxjs'
import {filter, map, mergeMap, mergeMapTo, share, tap} from 'rxjs/operators'
import {SanityDocument} from '@sanity/types'
import {Mutation} from '@sanity/mutator'
import {getPairListener, ListenerEvent} from '../getPairListe... | 3,624 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/consistencyStatus.ts | import {SanityClient} from '@sanity/client'
import {Observable, combineLatest} from 'rxjs'
import {distinctUntilChanged, map, publishReplay, refCount, switchMap} from 'rxjs/operators'
import {memoize} from '../utils/createMemoizer'
import {IdPair} from '../types'
import {memoizedPair} from './memoizedPair'
// A stream... | 3,625 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/documentEvents.ts | import {SanityClient} from '@sanity/client'
import {merge, Observable} from 'rxjs'
import {switchMap} from 'rxjs/operators'
import {IdPair} from '../types'
import {memoize} from '../utils/createMemoizer'
import {DocumentVersionEvent} from './checkoutPair'
import {memoizedPair} from './memoizedPair'
import {memoizeKeyGe... | 3,626 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/editOperations.ts | import {SanityClient} from '@sanity/client'
import {Schema} from '@sanity/types'
import {concat, EMPTY, merge, Observable, of} from 'rxjs'
import {map, mergeMap, shareReplay} from 'rxjs/operators'
import {HistoryStore} from '../../history'
import {IdPair} from '../types'
import {memoize} from '../utils/createMemoizer'
... | 3,627 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/editState.ts | import {SanityDocument, Schema} from '@sanity/types'
import {combineLatest, Observable} from 'rxjs'
import {map, publishReplay, refCount, startWith, switchMap} from 'rxjs/operators'
import {SanityClient} from '@sanity/client'
import {IdPair, PendingMutationsEvent} from '../types'
import {memoize} from '../utils/createM... | 3,628 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/index.ts | export * from './checkoutPair'
export * from './editState'
export * from './operations'
export * from './operationEvents'
export * from './remoteSnapshots'
export * from './snapshotPair'
export * from './validation'
| 3,629 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/memoizeKeyGen.ts | import {SanityClient} from '@sanity/client'
import {IdPair} from '../types'
export function memoizeKeyGen(client: SanityClient, idPair: IdPair, typeName: string) {
const config = client.config()
return `${config.dataset ?? ''}-${config.projectId ?? ''}-${idPair.publishedId}-${typeName}`
}
| 3,630 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/memoizedPair.ts | import type {SanityClient} from '@sanity/client'
import {Observable} from 'rxjs'
import {publishReplay, refCount} from 'rxjs/operators'
import type {IdPair} from '../types'
import {memoize} from '../utils/createMemoizer'
import {checkoutPair, type Pair} from './checkoutPair'
import {memoizeKeyGen} from './memoizeKeyGen... | 3,631 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operationArgs.ts | /* eslint-disable @typescript-eslint/no-use-before-define */
import {SanityClient} from '@sanity/client'
import {Schema} from '@sanity/types'
import {combineLatest, Observable} from 'rxjs'
import {map, publishReplay, refCount, switchMap} from 'rxjs/operators'
import {HistoryStore} from '../../history'
import {IdPair} ... | 3,632 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operationEvents.ts | /* eslint-disable max-nested-callbacks */
import {SanityClient} from '@sanity/client'
import {asyncScheduler, defer, EMPTY, merge, Observable, of, Subject} from 'rxjs'
import {
catchError,
filter,
groupBy,
last,
map,
mergeMap,
mergeMapTo,
share,
switchMap,
take,
tap,
throttleTime,
} from 'rxjs/o... | 3,633 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/remoteSnapshots.ts | import type {SanityClient} from '@sanity/client'
import {merge, type Observable} from 'rxjs'
import {switchMap} from 'rxjs/operators'
import type {IdPair} from '../types'
import {memoize} from '../utils/createMemoizer'
import type {RemoteSnapshotVersionEvent} from './checkoutPair'
import {memoizedPair} from './memoized... | 3,634 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/snapshotPair.ts | import {SanityDocument} from '@sanity/types'
import {filter, map, publishReplay, refCount} from 'rxjs/operators'
import {Observable} from 'rxjs'
import {SanityClient} from '@sanity/client'
import {IdPair, PendingMutationsEvent, ReconnectEvent} from '../types'
import {BufferedDocumentEvent, MutationPayload, SnapshotEven... | 3,635 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts | import {SanityClient} from '@sanity/client'
import {
concat,
ConnectableObservable,
timer,
Observable,
Subject,
of,
EMPTY,
firstValueFrom,
lastValueFrom,
} from 'rxjs'
import {buffer, takeWhile, first, publish} from 'rxjs/operators'
import {DocumentAvailability, DraftsModelDocumentAvailability} from '... | 3,636 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/validation.ts | import type {SanityClient} from '@sanity/client'
import {
asyncScheduler,
combineLatest,
concat,
defer,
from,
lastValueFrom,
Observable,
of,
timer,
} from 'rxjs'
import {
distinct,
distinctUntilChanged,
first,
groupBy,
map,
mergeMap,
scan,
shareReplay,
skip,
throttleTime,
} from 'r... | 3,637 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/commit.ts | import {EMPTY} from 'rxjs'
import {OperationImpl} from './types'
export const commit: OperationImpl = {
disabled: (): false => false,
execute: ({draft, published}) => {
draft.commit()
published.commit()
// note: we might be able to connect with the outgoing commit request stream here
return EMPTY
... | 3,638 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/delete.ts | import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {OperationImpl} from './types'
export const del: OperationImpl<[], 'NOTHING_TO_DELETE'> = {
disabled: ({snapshots}) => (snapshots.draft || snapshots.published ? false : 'NOTHING_TO_DELETE'),
execute: ({client, schema, idPair, typeName}) => {
c... | 3,639 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/discardChanges.ts | import {OperationImpl} from './types'
type DisabledReason = 'NO_CHANGES' | 'NOT_PUBLISHED'
export const discardChanges: OperationImpl<[], DisabledReason> = {
disabled: ({snapshots}) => {
if (!snapshots.draft) {
return 'NO_CHANGES'
}
if (!snapshots.published) {
return 'NOT_PUBLISHED'
}
... | 3,640 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/duplicate.ts | import {omit} from 'lodash'
import {getDraftId} from '../../../../../util'
import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {OperationImpl} from './types'
const omitProps = ['_createdAt', '_updatedAt']
export const duplicate: OperationImpl<[baseDocumentId: string], 'NOTHING_TO_DUPLICATE'> = {
dis... | 3,641 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/helpers.ts | import {emitOperation} from '../operationEvents'
import {IdPair} from '../../types'
import {del} from './delete'
import {publish} from './publish'
import {patch} from './patch'
import {commit} from './commit'
import {discardChanges} from './discardChanges'
import {unpublish} from './unpublish'
import {duplicate} from '... | 3,642 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/index.ts | export * from './types'
| 3,643 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/patch.ts | import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {OperationImpl} from './types'
// todo: we could also consider exposing 'mutate' directly
export const patch: OperationImpl<[patches: any[], initialDocument?: Record<string, any>]> = {
disabled: (): false => false,
execute: (
{schema, snapshot... | 3,644 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/publish.test.ts | import type {SanityDocument} from '@sanity/types'
import {createMockSanityClient} from '../../../../../../../test/mocks/mockSanityClient'
import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {publish} from './publish'
import {OperationArgs} from './types'
jest.mock('../utils/isLiveEditEnabled', () => ({... | 3,645 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/publish.ts | import {omit} from 'lodash'
import {isReference} from '@sanity/types'
import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {OperationImpl} from './index'
function strengthenOnPublish<T = any>(obj: T): T {
if (isReference(obj)) {
if (obj._strengthenOnPublish) {
return omit(
obj,
... | 3,646 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/restore.ts | import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {OperationImpl} from './types'
export const restore: OperationImpl<[fromRevision: string]> = {
disabled: (): false => false,
execute: ({historyStore, schema, idPair, typeName}, fromRevision: string) => {
const targetId = isLiveEditEnabled(sche... | 3,647 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/types.ts | import {SanityDocument, Schema} from '@sanity/types'
import {SanityClient} from '@sanity/client'
import {IdPair} from '../../types'
import {DocumentVersionSnapshots} from '../snapshotPair'
import {HistoryStore} from '../../../history'
/** @internal */
export interface OperationImpl<
ExtraArgs extends any[] = [],
D... | 3,648 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/unpublish.ts | import {omit} from 'lodash'
import {isLiveEditEnabled} from '../utils/isLiveEditEnabled'
import {OperationImpl} from './types'
type DisabledReason = 'LIVE_EDIT_ENABLED' | 'NOT_PUBLISHED'
export const unpublish: OperationImpl<[], DisabledReason> = {
disabled: ({schema, snapshots, typeName}) => {
if (isLiveEditEn... | 3,649 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/operations/__snapshots__/publish.test.ts.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`publish execute calls createOrReplace with _revision_lock_pseudo_field_ if there is an already published document 1`] = `
Object {
"listen": Array [],
"observable": Object {
"fetch": Array [],
"getDocuments": Array [],
"listen": Array [],
"request... | 3,650 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/document-pair/utils/isLiveEditEnabled.ts | import {Schema} from '@sanity/types'
export const isLiveEditEnabled = (schema: Schema, typeName: string): boolean =>
schema.get(typeName)?.liveEdit === true
| 3,651 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/hooks/index.ts | export * from './useDocumentType'
export * from './useDocumentValues'
| 3,652 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/hooks/useDocumentType.ts | import {useEffect, useMemo, useState} from 'react'
import {getPublishedId} from '../../../../util'
import {useDocumentStore} from '../../datastores'
/** @internal */
export interface DocumentTypeResolveState {
isLoaded: boolean
documentType: string | undefined
}
const LOADING_STATE: DocumentTypeResolveState = {
... | 3,653 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/hooks/useDocumentValues.ts | import {useMemo} from 'react'
import {Observable, of} from 'rxjs'
import {LoadableState, useLoadable} from '../../../../util'
import {useDocumentPreviewStore} from '../../datastores'
/** @internal */
export function useDocumentValues<T = Record<string, unknown>>(
documentId: string,
paths: string[],
): LoadableSta... | 3,654 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/hooks | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/hooks/__tests__/useDocumentType.test.tsx | import type {SanityClient} from '@sanity/client'
import {renderHook, waitFor} from '@testing-library/react'
import {asyncScheduler, defer, of} from 'rxjs'
import {delay, observeOn, tap} from 'rxjs/operators'
import {createMockSanityClient} from '../../../../../../../test/mocks/mockSanityClient'
import {createTestProvid... | 3,655 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/initialValue/index.ts | export * from './initialValue'
export * from './types'
| 3,656 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/initialValue/initialValue.ts | import {InitialValueResolverContext, Schema} from '@sanity/types'
import {from, merge, Observable, of} from 'rxjs'
import {
map,
switchMap,
scan,
filter,
distinctUntilChanged,
catchError,
debounceTime,
startWith,
} from 'rxjs/operators'
import {DocumentPreviewStore} from '../../../../preview'
import {re... | 3,657 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/initialValue/types.ts | import {SanityDocumentLike} from '@sanity/types'
/**
* @hidden
* @beta */
export interface InitialValueLoadingMsg {
type: 'loading'
}
/**
* @hidden
* @beta */
export interface InitialValueSuccessMsg {
type: 'success'
value: SanityDocumentLike | null
}
/**
* @hidden
* @beta */
export interface InitialValu... | 3,658 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/document/utils/createMemoizer.ts | import {Observable} from 'rxjs'
export function memoize<T, Arg1>(
fn: (arg1: Arg1) => Observable<T>,
keyGen: (arg1: Arg1) => string,
): (arg1: Arg1) => Observable<T>
export function memoize<T, Arg1, Arg2>(
fn: (arg1: Arg1, arg2: Arg2) => Observable<T>,
keyGen: (arg1: Arg1, arg2: Arg2) => string,
): (arg1: Arg1... | 3,659 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/documentPairPermissions.ts | import {SanityClient} from '@sanity/client'
import {SanityDocument, Schema, SchemaType} from '@sanity/types'
import {Observable, combineLatest, of} from 'rxjs'
import {switchMap, map} from 'rxjs/operators'
import {
type PartialExcept,
createHookFromObservableFactory,
getDraftId,
getPublishedId,
} from '../../..... | 3,660 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/documentValuePermissions.ts | import {Observable} from 'rxjs'
import {createHookFromObservableFactory, PartialExcept} from '../../../util'
import {useGrantsStore} from '../datastores'
import {DocumentValuePermission, GrantsStore, PermissionCheckResult} from './types'
/** @internal */
export interface DocumentValuePermissionsOptions {
grantsStore... | 3,661 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/grantsStore.ts | import {SanityClient} from '@sanity/client'
import {CurrentUser, SanityDocument} from '@sanity/types'
import {evaluate, parse} from 'groq-js'
import {defer, of} from 'rxjs'
import {distinctUntilChanged, publishReplay, switchMap} from 'rxjs/operators'
import {refCountDelay} from 'rxjs-etc/operators'
import shallowEquals... | 3,662 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/index.ts | export * from './documentPairPermissions'
export * from './documentValuePermissions'
export * from './templatePermissions'
export * from './grantsStore'
export * from './types'
| 3,663 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/templatePermissions.ts | import {InitialValueResolverContext, Schema} from '@sanity/types'
import {combineLatest, from, Observable, of} from 'rxjs'
import {map, switchMap} from 'rxjs/operators'
import {useSchema, useTemplates} from '../../../hooks'
import {InitialValueTemplateItem, resolveInitialValue, Template} from '../../../templates'
impor... | 3,664 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/types.ts | import {SanityDocument} from '@sanity/types'
import type {Observable} from 'rxjs'
/**
* @hidden
* @beta */
export type DocumentValuePermission = 'read' | 'create' | 'update' | 'history' | 'editHistory'
/** @internal */
export interface Grant {
filter: string
permissions: DocumentValuePermission[]
}
/**
* @hid... | 3,665 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/__tests__/createGrantsStore.test.ts | import {SanityClient} from '@sanity/client'
import {first} from 'rxjs/operators'
import {firstValueFrom, lastValueFrom} from 'rxjs'
import {createGrantsStore} from '../grantsStore'
import {viewer} from '../debug/exampleGrants'
function createMockClient(data: {requests?: Record<string, any>} = {}): SanityClient {
con... | 3,666 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/__tests__/templatePermissions.test.ts | /* eslint-disable camelcase */
import {first} from 'rxjs/operators'
import {SanityClient} from '@sanity/client'
import {InitialValueResolverContext} from '@sanity/types'
import {firstValueFrom} from 'rxjs'
import {createMockSanityClient} from '../../../../../../test/mocks/mockSanityClient'
import {requiresApproval} fr... | 3,667 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/debug/exampleGrants.ts | // NOTE: these example grants are used in other test files.
// if you change this file, check to see if other files need to be updated too
import {Grant} from '../types'
export const administrator: Grant[] = [
{
filter: '_id in path("**")',
permissions: ['read', 'create', 'history', 'update'],
},
]
export... | 3,668 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/debug/exampleRoles.ts | import {Role} from '@sanity/types'
export const exampleRoles: Record<string, Role> = {
// basic
administrator: {name: 'administrator', title: 'Administrator'},
viewer: {name: 'Viewer', title: 'Viewer'},
editor: {name: 'editor', title: 'Editor'},
developer: {name: 'developer', title: 'Developer'},
contribut... | 3,669 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/debug/index.ts | export {getDebugRolesByNames} from './exampleRoles'
export {debugGrants$} from './roleGrants'
| 3,670 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/grants/debug/roleGrants.ts | import {map} from 'rxjs/operators'
import {debugRolesParam$} from '../../debugParams'
import {Grant} from '../types'
import * as grants from './exampleGrants'
import {ExampleRoleName} from './exampleRoles'
const DEBUG_ROLE_GRANTS_MAP: Record<ExampleRoleName, Grant[]> = {
// basic
administrator: grants.administrato... | 3,671 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/createHistoryStore.ts | import type {SanityClient} from '@sanity/client'
import {
isReference,
Reference,
SanityDocument,
TransactionLogEventWithMutations,
} from '@sanity/types'
import {reduce as jsonReduce} from 'json-reduce'
import {from, Observable} from 'rxjs'
import {map, mergeMap} from 'rxjs/operators'
import {isDev} from '../.... | 3,672 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history.test.ts | import {removeMissingReferences} from './createHistoryStore'
const testDoc = {
_id: 'foo',
_rev: 'foo',
_createdAt: '',
_updatedAt: '',
_type: 'test',
string: 'value',
number: 123,
bool: true,
subObject: {
_type: 'sub',
nested: {
prop: true,
array: [
'contents',
{_... | 3,673 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/index.ts | export * from './createHistoryStore'
export * from './history'
export * from './useTimelineStore'
export * from './useTimelineSelector'
| 3,674 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/useTimelineSelector.ts | import {useSyncExternalStoreWithSelector} from 'use-sync-external-store/with-selector'
import {TimelineState, TimelineStore} from './useTimelineStore'
/**
* Custom hook which wraps around `useSyncExternalStore`.
* Accepts a selector function which can be used to opt-in to specific timelineStore updates.
*
* @inter... | 3,675 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/useTimelineStore.ts | import {ObjectDiff} from '@sanity/diff'
import {useEffect, useMemo, useRef} from 'react'
import deepEquals from 'react-fast-compare'
import {BehaviorSubject, catchError, distinctUntilChanged, map, of, Subscription, tap} from 'rxjs'
import {Annotation, Chunk, SelectionState, TimelineController, useHistoryStore} from '..... | 3,676 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/__snapshots__/history.test.ts.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`removeMissingReferences removes references to missing docs, deeply 1`] = `
Object {
"_createdAt": "",
"_id": "foo",
"_rev": "foo",
"_type": "test",
"_updatedAt": "",
"arrayOfObjects": Array [
Object {
"_type": "foo",
"prop": "yes",
},
... | 3,677 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/Aligner.ts | import type {SanityDocument, TransactionLogEventWithEffects} from '@sanity/types'
import {applyPatch} from 'mendoza'
import {RemoteSnapshotVersionEvent} from '../../document/document-pair/checkoutPair'
import {Timeline} from './Timeline'
import type {DocumentRemoteMutationVersionEvent, CombinedDocument} from './types'
... | 3,678 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/Reconstruction.ts | import {Diff} from '@sanity/diff'
import {Annotation, Chunk} from '../../../../field'
import {Timeline} from './Timeline'
import {CombinedDocument} from './types'
/**
* A reconstruction represents a single reconstruction of a
*/
export class Reconstruction {
timeline: Timeline
start: Chunk | null
end: Chunk
... | 3,679 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/Timeline.ts | import type {TransactionLogEventWithEffects} from '@sanity/types'
import {Diff} from '@sanity/diff'
import {applyPatch, incremental} from 'mendoza'
import {Chunk, Annotation} from '../../../../field'
import {Transaction, DocumentRemoteMutationVersionEvent, CombinedDocument} from './types'
import {diffValue, Meta} from ... | 3,680 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/TimelineController.ts | import type {SanityClient} from '@sanity/client'
import {Diff, ObjectDiff} from '@sanity/diff'
import {Annotation, Chunk} from '../../../../field'
import {RemoteSnapshotVersionEvent} from '../../document/document-pair/checkoutPair'
import {Timeline, ParsedTimeRef} from './Timeline'
import {getJsonStream} from './getJso... | 3,681 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/TwoEndedArray.ts | export type Merger<T> = (left: T, right: T) => T | [T, T]
/**
* The two ended array supports pushing both at the beginning and
* at the end while preserving indicies.
*/
export class TwoEndedArray<T extends {index: number}> {
private _postive: T[] = []
private _negative: T[] = []
addToEnd(elem: T): void {
... | 3,682 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/chunker.ts | /* eslint-disable no-nested-ternary */
import type {MendozaEffectPair, MendozaPatch} from '@sanity/types'
import {Chunk, ChunkType} from '../../../../field'
import type {Transaction} from './types'
function canMergeEdit(type: ChunkType) {
return type === 'create' || type === 'editDraft'
}
const CHUNK_WINDOW = 5 * 6... | 3,683 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/constants.ts | export const CURRENT_REVISION_FLAG = '-'
| 3,684 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/diffValue.ts | import {incremental} from 'mendoza'
import {Input, ArrayInput, ObjectInput, StringInput, wrap, Diff, diffInput} from '@sanity/diff'
import {Annotation, Chunk} from '../../../../field'
import {Timeline} from './Timeline'
import {isSameAnnotation} from './utils'
export type Meta = {chunk: Chunk; transactionIndex: number... | 3,685 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/getJsonStream.ts | import type {TransactionLogEventWithEffects} from '@sanity/types'
type StreamResult = TransactionLogEventWithEffects | {error: {description?: string; type: string}}
export async function getJsonStream(
url: string,
token: string | undefined,
): Promise<ReadableStream<StreamResult>> {
const options: RequestInit ... | 3,686 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/index.ts | export * from './TimelineController'
export * from './Timeline'
export * from './types'
| 3,687 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/replay.ts | import type {TransactionLogEventWithEffects} from '@sanity/types'
import {DocumentRemoteMutationVersionEvent} from './types'
import {Timeline} from './Timeline'
export type TraceEvent =
| {
type: 'initial'
publishedId: string
}
| {type: 'addRemoteMutation'; event: DocumentRemoteMutationVersionEvent... | 3,688 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/types.ts | import type {MendozaEffectPair} from '@sanity/types'
import type {RemoteSnapshotVersionEvent} from '../../document/document-pair/checkoutPair'
/**
* @hidden
* @beta */
export type DocumentRemoteMutationVersionEvent = Exclude<
RemoteSnapshotVersionEvent,
{type: 'snapshot'}
>
/**
* @hidden
* @beta */
export int... | 3,689 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/history/history/utils.ts | import {Annotation} from '../../../../field'
import {CombinedDocument} from './types'
export function isSameAnnotation(a: Annotation, b: Annotation): boolean {
if (a && b) {
return a.author === b.author && a.chunk === b.chunk
}
if (!a && !b) {
return true
}
return false
}
export function getAttrs(... | 3,690 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/hooks.ts | export {useGlobalPresence} from './useGlobalPresence'
export {useDocumentPresence} from './useDocumentPresence'
| 3,691 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/index.ts | export * from './presence-store'
export * from './hooks'
export * from './types'
| 3,692 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/mock-events.ts | import {defer, timer} from 'rxjs'
import {map, mergeMapTo, shareReplay} from 'rxjs/operators'
import {sample} from 'lodash'
import {StateEvent} from './message-transports/transport'
const USERIDS = [
'pqSMwf6hH',
'pnLYqNfv5',
'priDVVmy8',
'p0NFOU0j8',
'pTDl2jw8d',
'pHMeQnTse',
'pDQYzJbyS',
'pZyoPHKUs',... | 3,693 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/presence-store.ts | /* eslint-disable camelcase */
import {BehaviorSubject, defer, EMPTY, from, fromEvent, merge, NEVER, Observable, timer} from 'rxjs'
import {
auditTime,
distinctUntilChanged,
filter,
flatMap,
map,
mergeMapTo,
scan,
share,
shareReplay,
switchMap,
switchMapTo,
takeUntil,
tap,
toArray,
withLa... | 3,694 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/types.ts | import {Path, User} from '@sanity/types'
/** @internal */
export type Status = 'online' | 'editing' | 'inactive'
/** @internal */
// Low level data/transport format
export interface Session {
sessionId: string
userId: string
lastActiveAt: string // iso date
locations: PresenceLocation[]
}
/** @internal */
//... | 3,695 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/useDocumentPresence.tsx | import {useState, useEffect} from 'react'
import {usePresenceStore} from '../datastores'
import {DocumentPresence} from './types'
/** @internal */
export function useDocumentPresence(documentId: string): DocumentPresence[] {
const presenceStore = usePresenceStore()
const [presence, setPresence] = useState<Document... | 3,696 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/useGlobalPresence.tsx | import {useState, useEffect} from 'react'
import {usePresenceStore} from '../datastores'
import {GlobalPresence} from './types'
/** @internal */
export function useGlobalPresence(): GlobalPresence[] {
const [presence, setPresence] = useState<GlobalPresence[]>([])
const presenceStore = usePresenceStore()
useEffe... | 3,697 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/message-transports/bifurTransport.ts | import {Observable, EMPTY} from 'rxjs'
import {map, share} from 'rxjs/operators'
import {BifurClient} from '@sanity/bifur-client'
import {PresenceLocation} from '../types'
import {Transport, TransportEvent, TransportMessage} from './transport'
type BifurStateMessage = {
type: 'state'
i: string
m: {
sessionId... | 3,698 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence | petrpan-code/sanity-io/sanity/packages/sanity/src/core/store/_legacy/presence/message-transports/transport.ts | import {Observable} from 'rxjs'
import {PresenceLocation} from '../types'
// Not sure if this is the best choice of words, but:
// Message: something you send
// Event: something you receive
export type Incoming<T> = T & {
userId: string
timestamp: string
sessionId: string
}
export interface StateMessage {
t... | 3,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.