How to use @sanity/uuid - 5 common examples

To help you get started, we’ve selected a few @sanity/uuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanity-io / sanity / packages / @sanity / presence-store / src / PresenceStore.js View on Github external
constructor(connection, channel) {
    this.connection = connection
    this.messageSubscription = this.connection.listen().subscribe(this.handleMessage)
    this.myState = {}
    this.states = new Map()
    this.timestamps = new Map()
    this.resendReportTimer = null
    this.changeReportDebounceTimer = null
    this.performPurgeTimer = setInterval(this.performPurge, 2000)
    this.sessionId = UUID()
    this.requestRollCall()

    // List of functions that will be called with presence change notifications
    this.subscriberCallbacks = []
  }
github sanity-io / sanity / packages / @sanity / desk-tool / src / tool.js View on Github external
function getIntentState(intentName, params, currentState, payload) {
  const paneSegments = (currentState && currentState.panes) || []
  const activePanes = state.activePanes || []
  const editDocumentId = params.id || UUID()
  const isTemplate = intentName === 'create' && params.template

  // Loop through open panes and see if any of them can handle the intent
  for (let i = activePanes.length - 1; i >= 0; i--) {
    const pane = activePanes[i]
    if (pane.canHandleIntent && pane.canHandleIntent(intentName, params, {pane, index: i})) {
      const paneParams = isTemplate ? {template: params.template} : EMPTY_PARAMS
      return {
        panes: paneSegments
          .slice(0, i)
          .concat([[{id: editDocumentId, params: paneParams, payload}]])
      }
    }
  }

  return {intent: intentName, params, payload}
github sanity-io / sanity / packages / @sanity / base / src / datastores / document / document-pair / operations / duplicate.ts View on Github external
execute: ({snapshots}: OperationArgs, prepare = id) => {
    const omitProps = ['_id', '_createdAt', '_updatedAt']
    const source = snapshots.draft || snapshots.published
    return client.create({_id: getDraftId(uuid()), ...omit(prepare(source), omitProps)})
  }
}
github sanity-io / sanity / packages / @sanity / desk-tool / src / components / IntentResolver.js View on Github external
function getNewRouterState({structure, documentType, params, payload, documentId, paneSegments}) {
  const lastChild = structure[structure.length - 1] || {}
  const lastGroup = paneSegments[paneSegments.length - 1]
  const lastSibling = lastGroup[lastGroup.length - 1]
  const terminatesInDocument = lastChild.type === 'document' && lastChild.options.id === documentId

  const isTemplateCreate = params.template
  const template = isTemplateCreate && getTemplateById(params.template)
  const type = (template && template.schemaType) || documentType
  const fallbackParameters = {type, template: params.template}
  const newDocumentId = documentId === FALLBACK_ID ? UUID() : documentId

  return terminatesInDocument
    ? paneSegments
        .slice(0, -1)
        .concat([lastGroup.slice(0, -1).concat({...lastSibling, id: newDocumentId})])
    : [[{id: `__edit__${newDocumentId}`, params: fallbackParameters, payload}]]
}
github sanity-io / sanity / packages / @sanity / desk-tool / src / components / IntentResolver.js View on Github external
const documentId = id || FALLBACK_ID
  const {documentType, isLoaded} = useDocumentType(documentId, specifiedSchemaType)
  const paneSegments = documentType
    ? [[{id: documentType, params: {}}], [{id: documentId, params: otherParams, payload}]]
    : undefined

  const {structure, error} = useStructure(paneSegments, {silent: true})

  if (error) {
    return 
  }

  if (!documentType) {
    return isLoaded ? (
      
    ) : (
      
    )
  }

  const isLoading = !structure || structure.some(item => item === LOADING_PANE)
  if (isLoading) {
    return 
  }

  const panes = getNewRouterState({
    structure,
    documentType,
    params: otherParams,
    payload,
    paneSegments,

@sanity/uuid

Simple generation of sanity document IDs

MIT
Latest version published 11 months ago

Package Health Score

64 / 100
Full package analysis

Popular @sanity/uuid functions