diff --git a/packages/document/.npmignore b/packages/document-core/.npmignore similarity index 100% rename from packages/document/.npmignore rename to packages/document-core/.npmignore diff --git a/packages/document/LICENSE b/packages/document-core/LICENSE similarity index 100% rename from packages/document/LICENSE rename to packages/document-core/LICENSE diff --git a/packages/document/README.md b/packages/document-core/README.md similarity index 100% rename from packages/document/README.md rename to packages/document-core/README.md diff --git a/packages/document/package-lock.json b/packages/document-core/package-lock.json similarity index 92% rename from packages/document/package-lock.json rename to packages/document-core/package-lock.json index 94a4a2a..2084bc5 100644 --- a/packages/document/package-lock.json +++ b/packages/document-core/package-lock.json @@ -1,12 +1,12 @@ { - "name": "@usewaypoint/document", - "version": "0.0.7", + "name": "@usewaypoint/document-core", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@usewaypoint/document", - "version": "0.0.7", + "name": "@usewaypoint/document-core", + "version": "0.0.1", "license": "MIT", "peerDependencies": { "react": "^16 || ^17 || ^18", diff --git a/packages/document/package.json b/packages/document-core/package.json similarity index 85% rename from packages/document/package.json rename to packages/document-core/package.json index 0ed2f93..20b3316 100644 --- a/packages/document/package.json +++ b/packages/document-core/package.json @@ -1,6 +1,6 @@ { - "name": "@usewaypoint/document", - "version": "0.0.7", + "name": "@usewaypoint/document-core", + "version": "0.0.1", "description": "Tools to render waypoint-style documents (core package)", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/document/src/builders/buildBlockComponent.ts b/packages/document-core/src/builders/buildBlockComponent.ts similarity index 100% rename from packages/document/src/builders/buildBlockComponent.ts rename to packages/document-core/src/builders/buildBlockComponent.ts diff --git a/packages/document/src/builders/buildBlockConfigurationSchema.ts b/packages/document-core/src/builders/buildBlockConfigurationSchema.ts similarity index 100% rename from packages/document/src/builders/buildBlockConfigurationSchema.ts rename to packages/document-core/src/builders/buildBlockConfigurationSchema.ts diff --git a/packages/document/src/index.ts b/packages/document-core/src/index.ts similarity index 74% rename from packages/document/src/index.ts rename to packages/document-core/src/index.ts index 4345b20..02801d2 100644 --- a/packages/document/src/index.ts +++ b/packages/document-core/src/index.ts @@ -1,4 +1,4 @@ export { default as buildBlockComponent } from './builders/buildBlockComponent'; export { default as buildBlockConfigurationSchema } from './builders/buildBlockConfigurationSchema'; -export { default as buildDocumentHandlers } from './builders/buildDocumentHandlers'; + export { BlockConfiguration, DocumentBlocksDictionary } from './utils'; diff --git a/packages/document/src/utils.ts b/packages/document-core/src/utils.ts similarity index 100% rename from packages/document/src/utils.ts rename to packages/document-core/src/utils.ts diff --git a/packages/document/tests/builder/__snapshots__/buildBlockComponent.spec.tsx.snap b/packages/document-core/tests/builder/__snapshots__/buildBlockComponent.spec.tsx.snap similarity index 100% rename from packages/document/tests/builder/__snapshots__/buildBlockComponent.spec.tsx.snap rename to packages/document-core/tests/builder/__snapshots__/buildBlockComponent.spec.tsx.snap diff --git a/packages/document/tests/builder/buildBlockComponent.spec.tsx b/packages/document-core/tests/builder/buildBlockComponent.spec.tsx similarity index 100% rename from packages/document/tests/builder/buildBlockComponent.spec.tsx rename to packages/document-core/tests/builder/buildBlockComponent.spec.tsx diff --git a/packages/document/tests/builder/buildBlockConfigurationSchema.spec.tsx b/packages/document-core/tests/builder/buildBlockConfigurationSchema.spec.tsx similarity index 100% rename from packages/document/tests/builder/buildBlockConfigurationSchema.spec.tsx rename to packages/document-core/tests/builder/buildBlockConfigurationSchema.spec.tsx diff --git a/packages/document/tsconfig.build.json b/packages/document-core/tsconfig.build.json similarity index 100% rename from packages/document/tsconfig.build.json rename to packages/document-core/tsconfig.build.json diff --git a/packages/document/tsconfig.json b/packages/document-core/tsconfig.json similarity index 100% rename from packages/document/tsconfig.json rename to packages/document-core/tsconfig.json diff --git a/packages/document/src/builders/buildDocumentHandlers.ts b/packages/document/src/builders/buildDocumentHandlers.ts deleted file mode 100644 index 810c3b9..0000000 --- a/packages/document/src/builders/buildDocumentHandlers.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { BaseZodDictionary, DocumentBlocksDictionary } from '../utils'; - -import buildBlockComponent from './buildBlockComponent'; -import buildBlockConfigurationSchema from './buildBlockConfigurationSchema'; - -/** - * @typedef {Object} DocumentHandlers - * @property Schema - zod schema for a Document block - * @property Block - React component that can render a BlockConfiguration that is compatible with blocks - */ - -/** - * Shorthand function to create a Block and Schema in a single call - * - * @param blocks Main DocumentBlocksDictionary - * @returns {DocumentHandlers} - */ -export default function buildDocumentHandlers(blocks: DocumentBlocksDictionary) { - return { - Block: buildBlockComponent(blocks), - Schema: buildBlockConfigurationSchema(blocks), - }; -} diff --git a/packages/document/tests/builder/buildDocumentHandlers.spec.tsx b/packages/document/tests/builder/buildDocumentHandlers.spec.tsx deleted file mode 100644 index e8659bf..0000000 --- a/packages/document/tests/builder/buildDocumentHandlers.spec.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react'; -import { z } from 'zod'; - -import { render } from '@testing-library/react'; - -import buildDocumentHandlers from '../../src/builders/buildDocumentHandlers'; - -describe('builders/buildDocumentHandlers', () => { - const { Schema, Block } = buildDocumentHandlers({ - SampleBlock: { - schema: z.object({ text: z.string() }), - Component: ({ text }) =>
{text.toUpperCase()}
, - }, - }); - - describe('#Block', () => { - it('renders the component from the BlocksConfiguration', () => { - expect( - render().queryAllByText('TEST TEXT!') - ).toHaveLength(1); - }); - }); - - describe('#Schema', () => { - it('builds a BlockConfiguration schema with an id, data, and type', () => { - const parsedData = Schema.safeParse({ - type: 'SampleBlock', - data: { text: 'Test text!' }, - }); - expect(parsedData).toEqual({ - success: true, - data: { - type: 'SampleBlock', - data: { text: 'Test text!' }, - }, - }); - }); - }); -});