Skip to content

Commit

Permalink
warn if unsupported schema is attempted to be registered
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Aug 1, 2024
1 parent ebed2c8 commit abf043b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ export const registerCreatableModuleFactory = <TModule extends AttachableModuleI
/** register this as the primary factory for every schema it supports */
primary: boolean | Schema | Schema[] = false,
) => {
const primarySchemas =
primary !== true && primary ?
Array.isArray(primary) ?
primary
: [primary]
: []

for (const primarySchema of primarySchemas) {
if (!factory.configSchemas.includes(primarySchema)) {
console.warn(`Primary schema ${primary} not found in factory configSchemas`)
}
}

const isPrimaryForSchema = (schema: Schema) => {
switch (typeof primary) {
case 'boolean': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'
import { asDivinerInstance } from '@xyo-network/diviner-model'
import { Payload, PayloadBuilder, PayloadSchema } from '@xyo-network/payload'

import { MemoryNode } from '../../index.js'
import { MemoryNode } from '../../index.ts'

/**
* @group node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PayloadBuilder } from '@xyo-network/payload-builder'
import { Payload, PayloadSchema } from '@xyo-network/payload-model'
import { SchemaSchema } from '@xyo-network/schema-payload-plugin'

import { SchemaCache } from '../SchemaCache'
import { SchemaCache } from '../SchemaCache.ts'

const proxy = 'https://beta.api.archivist.xyo.network/domain'

Expand Down

0 comments on commit abf043b

Please sign in to comment.