From abf043b9590dab177c23b998a7b14f1aaff59b16 Mon Sep 17 00:00:00 2001 From: Arie Trouw Date: Thu, 1 Aug 2024 15:33:01 -0700 Subject: [PATCH] warn if unsupported schema is attempted to be registered --- .../src/CreatableModule/CreatableModuleRegistry.ts | 13 +++++++++++++ .../spec/MemoryNode/WithArchivistAndDiviner.spec.ts | 2 +- .../schema-cache/src/spec/SchemaCache.Proxy.spec.ts | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/modules/packages/module/packages/model/src/CreatableModule/CreatableModuleRegistry.ts b/packages/modules/packages/module/packages/model/src/CreatableModule/CreatableModuleRegistry.ts index 36eb8135a44..98d123d5b7a 100644 --- a/packages/modules/packages/module/packages/model/src/CreatableModule/CreatableModuleRegistry.ts +++ b/packages/modules/packages/module/packages/model/src/CreatableModule/CreatableModuleRegistry.ts @@ -35,6 +35,19 @@ export const registerCreatableModuleFactory = { + 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': { diff --git a/packages/modules/packages/node/src/spec/MemoryNode/WithArchivistAndDiviner.spec.ts b/packages/modules/packages/node/src/spec/MemoryNode/WithArchivistAndDiviner.spec.ts index 536cc764046..cce1290a1ab 100644 --- a/packages/modules/packages/node/src/spec/MemoryNode/WithArchivistAndDiviner.spec.ts +++ b/packages/modules/packages/node/src/spec/MemoryNode/WithArchivistAndDiviner.spec.ts @@ -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 diff --git a/packages/sdk-utils/packages/schema-cache/src/spec/SchemaCache.Proxy.spec.ts b/packages/sdk-utils/packages/schema-cache/src/spec/SchemaCache.Proxy.spec.ts index ecb65f175dc..e3ad79ff659 100644 --- a/packages/sdk-utils/packages/schema-cache/src/spec/SchemaCache.Proxy.spec.ts +++ b/packages/sdk-utils/packages/schema-cache/src/spec/SchemaCache.Proxy.spec.ts @@ -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'