Skip to content

Commit

Permalink
Add schema identity helpers & documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Sep 17, 2024
1 parent 61cfec6 commit db632fe
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions packages/core-payload-plugins/packages/schema/src/Payload.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
import type { Payload } from '@xyo-network/payload-model'
import {
isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources, type Payload,
} from '@xyo-network/payload-model'

import type { SchemaSchema } from './Schema.ts'
import { SchemaSchema } from './Schema.ts'

export type SchemaPayload = Payload<{
/**
* The schema definition
*/
definition: {
[key: string]: unknown
$id?: string
}
/**
* The schema this schema extends (if any)
*/
extends?: string

/** @deprecated use definition.$id instead */
name?: string

/**
* Identifies this payload as a Schema
*/
schema: SchemaSchema
}>

/**
* Identity function for determining if an object is an Schema
*/
export const isSchema = isPayloadOfSchemaType<SchemaPayload>(SchemaSchema)

/**
* Identity function for determining if an object is an Schema with sources
*/
export const isSchemaWithSources = isPayloadOfSchemaTypeWithSources<SchemaPayload>(SchemaSchema)

/**
* Identity function for determining if an object is an Schema with meta
*/
export const isSchemaWithMeta = isPayloadOfSchemaTypeWithMeta<SchemaPayload>(SchemaSchema)

0 comments on commit db632fe

Please sign in to comment.