@art-md/constructs 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +2 -2
  2. package/package.json +8 -3
  3. package/src/factories/constructs/Document/factory/createDocument.test.ts +2 -2
  4. package/src/factories/constructs/Document/factory/createDocument.ts +1 -1
  5. package/src/factories/constructs/Document/factory/types.ts +1 -1
  6. package/src/factories/constructs/Document/index.ts +2 -2
  7. package/src/factories/constructs/FieldBlock/factory/createFieldBlock.test.ts +2 -2
  8. package/src/factories/constructs/FieldBlock/factory/createFieldBlock.ts +2 -2
  9. package/src/factories/constructs/FieldBlock/factory/types.ts +2 -2
  10. package/src/factories/constructs/FieldBlock/index.ts +3 -3
  11. package/src/factories/constructs/FieldBlock/types.ts +2 -2
  12. package/src/factories/constructs/FieldInline/factory/createFieldInline.test.ts +2 -2
  13. package/src/factories/constructs/FieldInline/factory/createFieldInline.ts +2 -2
  14. package/src/factories/constructs/FieldInline/factory/types.ts +2 -2
  15. package/src/factories/constructs/FieldInline/index.ts +3 -3
  16. package/src/factories/constructs/FieldInline/types.ts +2 -2
  17. package/src/factories/constructs/NaturalBlock/factory/createNaturalBlock.test.ts +2 -2
  18. package/src/factories/constructs/NaturalBlock/factory/createNaturalBlock.ts +2 -2
  19. package/src/factories/constructs/NaturalBlock/factory/types.ts +1 -1
  20. package/src/factories/constructs/NaturalBlock/index.ts +3 -3
  21. package/src/factories/constructs/NaturalBlock/types.ts +1 -1
  22. package/src/factories/constructs/NaturalExpression/factory/createNaturalExpression.test.ts +2 -2
  23. package/src/factories/constructs/NaturalExpression/factory/createNaturalExpression.ts +2 -2
  24. package/src/factories/constructs/NaturalExpression/factory/types.ts +1 -1
  25. package/src/factories/constructs/NaturalExpression/index.ts +3 -3
  26. package/src/factories/constructs/SectionBlock/factory/createSectionBlock.test.ts +2 -4
  27. package/src/factories/constructs/SectionBlock/factory/createSectionBlock.ts +2 -3
  28. package/src/factories/constructs/SectionBlock/factory/types.ts +1 -2
  29. package/src/factories/constructs/SectionBlock/index.ts +3 -3
  30. package/src/factories/constructs/SectionBlock/types.ts +1 -2
  31. package/src/factories/constructs/Tag/factory/createTag.test.ts +1 -1
  32. package/src/factories/constructs/Tag/factory/createTag.ts +2 -2
  33. package/src/factories/constructs/Tag/index.ts +3 -3
  34. package/src/factories/index.ts +8 -8
  35. package/src/factories/public.ts +14 -14
  36. package/src/factories/types.ts +6 -6
  37. package/src/index.ts +3 -3
  38. package/src/parser/constructs/FieldBlock/createFieldBlockParser.test.ts +1 -1
  39. package/src/parser/constructs/FieldBlock/createFieldBlockParser.ts +2 -2
  40. package/src/parser/constructs/FieldBlock/index.ts +1 -1
  41. package/src/parser/constructs/FieldBlock/private/helpers/createFieldBlockFromNode.test.ts +4 -4
  42. package/src/parser/constructs/FieldBlock/private/helpers/createFieldBlockFromNode.ts +4 -4
  43. package/src/parser/constructs/FieldBlock/private/helpers/onBeforeConstruct.test.ts +1 -1
  44. package/src/parser/constructs/FieldBlock/private/index.ts +2 -2
  45. package/src/parser/constructs/FieldBlock/private/integrator/createFieldBlockIntegrator.test.ts +4 -4
  46. package/src/parser/constructs/FieldBlock/private/integrator/createFieldBlockIntegrator.ts +3 -3
  47. package/src/parser/constructs/FieldBlock/private/processor/createFieldBlockProcessor.test.ts +4 -4
  48. package/src/parser/constructs/FieldBlock/private/processor/createFieldBlockProcessor.ts +3 -3
  49. package/src/parser/constructs/FieldInline/createFieldInlineParser.test.ts +1 -1
  50. package/src/parser/constructs/FieldInline/createFieldInlineParser.ts +2 -2
  51. package/src/parser/constructs/FieldInline/index.ts +1 -1
  52. package/src/parser/constructs/FieldInline/private/helpers/createFieldInlineFromNode.test.ts +4 -4
  53. package/src/parser/constructs/FieldInline/private/helpers/createFieldInlineFromNode.ts +6 -6
  54. package/src/parser/constructs/FieldInline/private/helpers/trimFieldEdges.test.ts +2 -2
  55. package/src/parser/constructs/FieldInline/private/helpers/trimFieldEdges.ts +1 -1
  56. package/src/parser/constructs/FieldInline/private/index.ts +1 -1
  57. package/src/parser/constructs/FieldInline/private/processor/createFieldInlineProcessor.test.ts +4 -4
  58. package/src/parser/constructs/FieldInline/private/processor/createFieldInlineProcessor.ts +3 -3
  59. package/src/parser/constructs/NaturalBlock/createNaturalBlockParser.test.ts +1 -1
  60. package/src/parser/constructs/NaturalBlock/createNaturalBlockParser.ts +2 -2
  61. package/src/parser/constructs/NaturalBlock/index.ts +1 -1
  62. package/src/parser/constructs/NaturalBlock/private/helpers/createNaturalBlockFromNode.test.ts +4 -4
  63. package/src/parser/constructs/NaturalBlock/private/helpers/createNaturalBlockFromNode.ts +4 -4
  64. package/src/parser/constructs/NaturalBlock/private/index.ts +1 -1
  65. package/src/parser/constructs/NaturalBlock/private/processor/createNaturalBlockProcessor.test.ts +4 -4
  66. package/src/parser/constructs/NaturalBlock/private/processor/createNaturalBlockProcessor.ts +2 -2
  67. package/src/parser/constructs/SectionBlock/createSectionBlockParser.test.ts +1 -1
  68. package/src/parser/constructs/SectionBlock/createSectionBlockParser.ts +2 -2
  69. package/src/parser/constructs/SectionBlock/index.ts +1 -1
  70. package/src/parser/constructs/SectionBlock/private/helpers/createSectionBlockFromNode.test.ts +6 -6
  71. package/src/parser/constructs/SectionBlock/private/helpers/createSectionBlockFromNode.ts +4 -7
  72. package/src/parser/constructs/SectionBlock/private/helpers/findParentSection.test.ts +9 -3
  73. package/src/parser/constructs/SectionBlock/private/helpers/findParentSection.ts +1 -1
  74. package/src/parser/constructs/SectionBlock/private/index.ts +2 -2
  75. package/src/parser/constructs/SectionBlock/private/integrator/createSectionBlockIntegrator.test.ts +6 -3
  76. package/src/parser/constructs/SectionBlock/private/integrator/createSectionBlockIntegrator.ts +3 -3
  77. package/src/parser/constructs/SectionBlock/private/processor/createSectionBlockProcessor.test.ts +4 -4
  78. package/src/parser/constructs/SectionBlock/private/processor/createSectionBlockProcessor.ts +2 -2
  79. package/src/parser/document/createArtDocumentFromNode.test.ts +2 -2
  80. package/src/parser/document/createArtDocumentFromNode.ts +1 -1
  81. package/src/parser/document/index.ts +1 -1
  82. package/src/parser/fields/constants.test.ts +1 -1
  83. package/src/parser/fields/index.ts +3 -3
  84. package/src/parser/fields/isFieldStrong.test.ts +2 -2
  85. package/src/parser/fields/isFieldStrong.ts +2 -2
  86. package/src/parser/fields/stripStrong.test.ts +3 -3
  87. package/src/parser/fields/stripStrong.ts +1 -1
  88. package/src/parser/index.ts +6 -6
  89. package/src/parser/mdast/index.ts +1 -1
  90. package/src/parser/mdast/rawSlice.test.ts +1 -1
  91. package/src/parser/naturalExpression/createNaturalExpressionFromNode.test.ts +2 -2
  92. package/src/parser/naturalExpression/createNaturalExpressionFromNode.ts +2 -3
  93. package/src/parser/naturalExpression/index.ts +1 -1
  94. package/src/parser/public.ts +7 -7
  95. package/src/parser/tags/extractTags.test.ts +1 -1
  96. package/src/parser/tags/extractTags.ts +1 -1
  97. package/src/parser/tags/index.ts +1 -1
  98. package/src/parser/types.ts +1 -1
  99. package/src/serializer/constructs/Document/createDocumentToMdast.test.ts +1 -1
  100. package/src/serializer/constructs/Document/createDocumentToMdast.ts +1 -1
  101. package/src/serializer/constructs/Document/index.ts +1 -1
  102. package/src/serializer/constructs/FieldBlock/createFieldBlockToMdast.test.ts +2 -2
  103. package/src/serializer/constructs/FieldBlock/createFieldBlockToMdast.ts +3 -3
  104. package/src/serializer/constructs/FieldBlock/index.ts +1 -1
  105. package/src/serializer/constructs/FieldInline/createFieldInlineToMdast.test.ts +2 -2
  106. package/src/serializer/constructs/FieldInline/createFieldInlineToMdast.ts +3 -3
  107. package/src/serializer/constructs/FieldInline/index.ts +1 -1
  108. package/src/serializer/constructs/NaturalBlock/createNaturalBlockToMdast.test.ts +2 -2
  109. package/src/serializer/constructs/NaturalBlock/createNaturalBlockToMdast.ts +3 -3
  110. package/src/serializer/constructs/NaturalBlock/index.ts +1 -1
  111. package/src/serializer/constructs/NaturalExpression/createNaturalExpressionToMdast.test.ts +2 -2
  112. package/src/serializer/constructs/NaturalExpression/createNaturalExpressionToMdast.ts +2 -2
  113. package/src/serializer/constructs/NaturalExpression/index.ts +1 -1
  114. package/src/serializer/constructs/SectionBlock/createSectionBlockToMdast.test.ts +2 -2
  115. package/src/serializer/constructs/SectionBlock/createSectionBlockToMdast.ts +3 -3
  116. package/src/serializer/constructs/SectionBlock/index.ts +1 -1
  117. package/src/serializer/index.ts +7 -7
  118. package/src/serializer/public.ts +8 -8
  119. package/src/serializer/tags/index.ts +2 -2
  120. package/src/serializer/tags/tagToMdast.test.ts +1 -1
  121. package/src/serializer/tags/tagToMdast.ts +1 -1
  122. package/src/serializer/tags/tagsToMdast.test.ts +2 -2
  123. package/src/serializer/tags/tagsToMdast.ts +2 -2
  124. package/src/serializer/types.ts +1 -1
  125. package/src/test/helpers/constructs/FieldBlock/makeFieldBlockFixture.ts +1 -1
  126. package/src/test/helpers/constructs/FieldBlock/makeFieldBlockMock.ts +1 -1
  127. package/src/test/helpers/constructs/FieldInline/makeFieldInlineFixture.ts +1 -1
  128. package/src/test/helpers/constructs/FieldInline/makeFieldInlineMock.ts +1 -1
  129. package/src/test/helpers/constructs/NaturalBlock/makeNaturalBlockFixture.ts +1 -1
  130. package/src/test/helpers/constructs/NaturalBlock/makeNaturalBlockMock.ts +1 -1
  131. package/src/test/helpers/constructs/NaturalExpression/makeNaturalExpressionFixture.ts +1 -1
  132. package/src/test/helpers/constructs/NaturalExpression/makeNaturalExpressionMock.ts +1 -1
  133. package/src/test/helpers/constructs/SectionBlock/makeSectionBlockFixture.ts +1 -3
  134. package/src/test/helpers/constructs/Tag/makeTagFixture.ts +1 -1
  135. package/src/test/helpers/constructs/index.ts +14 -14
  136. package/src/test/helpers/index.ts +2 -2
  137. package/src/test/helpers/parsers/index.ts +5 -5
  138. package/src/parser/constructs/SectionBlock/private/constants.test.ts +0 -17
  139. package/src/parser/constructs/SectionBlock/private/constants.ts +0 -1
@@ -1,13 +1,13 @@
1
- import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
1
+ import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import { fromMarkdown } from 'mdast-util-from-markdown';
3
3
  import { describe, expect, it, vi } from 'vitest';
4
4
 
5
- import { createFieldInline } from '../../../../../factories';
5
+ import { createFieldInline } from '../../../../../factories/index.js';
6
6
 
7
- import { createFieldInlineFromNode } from './createFieldInlineFromNode';
7
+ import { createFieldInlineFromNode } from './createFieldInlineFromNode.js';
8
8
 
9
9
  vi.mock('../../../../../factories/constructs/FieldInline/factory/createFieldInline', async () => {
10
- const { createFieldInlineMock } = await import('../../../../../test/helpers');
10
+ const { createFieldInlineMock } = await import('../../../../../test/helpers/index.js');
11
11
  return createFieldInlineMock();
12
12
  });
13
13
 
@@ -2,13 +2,13 @@ import type { ParserVisitContext } from '@art-md/primitives';
2
2
  import { nodePosition } from '@art-md/primitives';
3
3
  import type { Paragraph, Strong } from 'mdast';
4
4
 
5
- import { type FieldInline, type Tag, createFieldInline } from '../../../../../factories';
6
- import { stripStrong } from '../../../../fields';
7
- import { rawSlice } from '../../../../mdast';
8
- import { createNaturalExpressionFromNode } from '../../../../naturalExpression';
9
- import { extractTags } from '../../../../tags';
5
+ import { type FieldInline, type Tag, createFieldInline } from '../../../../../factories/index.js';
6
+ import { stripStrong } from '../../../../fields/index.js';
7
+ import { rawSlice } from '../../../../mdast/index.js';
8
+ import { createNaturalExpressionFromNode } from '../../../../naturalExpression/index.js';
9
+ import { extractTags } from '../../../../tags/index.js';
10
10
 
11
- import { trimFieldEdges } from './trimFieldEdges';
11
+ import { trimFieldEdges } from './trimFieldEdges.js';
12
12
 
13
13
  export function createFieldInlineFromNode(
14
14
  paragraph: Paragraph,
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { makeNaturalExpressionFixture } from '../../../../../test/helpers';
3
+ import { makeNaturalExpressionFixture } from '../../../../../test/helpers/index.js';
4
4
 
5
- import { trimFieldEdges } from './trimFieldEdges';
5
+ import { trimFieldEdges } from './trimFieldEdges.js';
6
6
 
7
7
  describe('trimFieldEdges', () => {
8
8
  it('WHEN the edge texts have surrounding whitespace trims them', () => {
@@ -1,4 +1,4 @@
1
- import type { NaturalExpression } from '../../../../../factories';
1
+ import type { NaturalExpression } from '../../../../../factories/index.js';
2
2
 
3
3
  export function trimFieldEdges(value: NaturalExpression[]): typeof value {
4
4
  const trimmed = [...value];
@@ -1 +1 @@
1
- export * from './processor/createFieldInlineProcessor';
1
+ export * from './processor/createFieldInlineProcessor.js';
@@ -1,11 +1,11 @@
1
- import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
1
+ import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import { fromMarkdown } from 'mdast-util-from-markdown';
3
3
  import { describe, expect, it, vi } from 'vitest';
4
4
 
5
- import { createFieldInlineFromNodeMock } from '../../../../../test/helpers';
6
- import { createFieldInlineFromNode } from '../helpers/createFieldInlineFromNode';
5
+ import { createFieldInlineFromNodeMock } from '../../../../../test/helpers/index.js';
6
+ import { createFieldInlineFromNode } from '../helpers/createFieldInlineFromNode.js';
7
7
 
8
- import { createFieldInlineProcessor } from './createFieldInlineProcessor';
8
+ import { createFieldInlineProcessor } from './createFieldInlineProcessor.js';
9
9
 
10
10
  vi.mock('../helpers/createFieldInlineFromNode', async () => {
11
11
  return createFieldInlineFromNodeMock();
@@ -1,8 +1,8 @@
1
1
  import type { Paragraph } from 'mdast';
2
2
 
3
- import { isFieldStrong } from '../../../../fields';
4
- import type { ConstructProcessor } from '../../../../types';
5
- import { createFieldInlineFromNode } from '../helpers/createFieldInlineFromNode';
3
+ import { isFieldStrong } from '../../../../fields/index.js';
4
+ import type { ConstructProcessor } from '../../../../types.js';
5
+ import { createFieldInlineFromNode } from '../helpers/createFieldInlineFromNode.js';
6
6
 
7
7
  export function createFieldInlineProcessor(): ConstructProcessor {
8
8
  return {
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { createNaturalBlockParser } from './createNaturalBlockParser';
3
+ import { createNaturalBlockParser } from './createNaturalBlockParser.js';
4
4
 
5
5
  describe('createNaturalBlockParser', () => {
6
6
  it('WHEN called returns a parser with NaturalBlock name, processor and factory', () => {
@@ -1,6 +1,6 @@
1
- import type { ConstructParserFactory } from '../../types';
1
+ import type { ConstructParserFactory } from '../../types.js';
2
2
 
3
- import { createNaturalBlockProcessor } from './private';
3
+ import { createNaturalBlockProcessor } from './private/index.js';
4
4
 
5
5
  export const createNaturalBlockParser: ConstructParserFactory = () => ({
6
6
  name: 'NaturalBlock',
@@ -1 +1 @@
1
- export { createNaturalBlockParser } from './createNaturalBlockParser';
1
+ export { createNaturalBlockParser } from './createNaturalBlockParser.js';
@@ -1,14 +1,14 @@
1
- import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
1
+ import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import type { Node } from 'mdast';
3
3
  import { fromMarkdown } from 'mdast-util-from-markdown';
4
4
  import { describe, expect, it, vi } from 'vitest';
5
5
 
6
- import { createNaturalBlock } from '../../../../../factories';
6
+ import { createNaturalBlock } from '../../../../../factories/index.js';
7
7
 
8
- import { createNaturalBlockFromNode } from './createNaturalBlockFromNode';
8
+ import { createNaturalBlockFromNode } from './createNaturalBlockFromNode.js';
9
9
 
10
10
  vi.mock('../../../../../factories/constructs/NaturalBlock/factory/createNaturalBlock', async () => {
11
- const { createNaturalBlockMock } = await import('../../../../../test/helpers');
11
+ const { createNaturalBlockMock } = await import('../../../../../test/helpers/index.js');
12
12
  return createNaturalBlockMock();
13
13
  });
14
14
 
@@ -8,10 +8,10 @@ import {
8
8
  type NaturalExpression,
9
9
  type Tag,
10
10
  createNaturalBlock,
11
- } from '../../../../../factories';
12
- import { rawSlice } from '../../../../mdast';
13
- import { createNaturalExpressionFromNode } from '../../../../naturalExpression';
14
- import { extractTags } from '../../../../tags';
11
+ } from '../../../../../factories/index.js';
12
+ import { rawSlice } from '../../../../mdast/index.js';
13
+ import { createNaturalExpressionFromNode } from '../../../../naturalExpression/index.js';
14
+ import { extractTags } from '../../../../tags/index.js';
15
15
 
16
16
  export function createNaturalBlockFromNode(node: Node, context: ParserVisitContext): NaturalBlock {
17
17
  let children: (NaturalBlock | NaturalExpression)[] = [];
@@ -1 +1 @@
1
- export * from './processor/createNaturalBlockProcessor';
1
+ export * from './processor/createNaturalBlockProcessor.js';
@@ -1,10 +1,10 @@
1
- import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
1
+ import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import { describe, expect, it, vi } from 'vitest';
3
3
 
4
- import { createNaturalBlockFromNodeMock } from '../../../../../test/helpers';
5
- import { createNaturalBlockFromNode } from '../helpers/createNaturalBlockFromNode';
4
+ import { createNaturalBlockFromNodeMock } from '../../../../../test/helpers/index.js';
5
+ import { createNaturalBlockFromNode } from '../helpers/createNaturalBlockFromNode.js';
6
6
 
7
- import { createNaturalBlockProcessor } from './createNaturalBlockProcessor';
7
+ import { createNaturalBlockProcessor } from './createNaturalBlockProcessor.js';
8
8
 
9
9
  vi.mock('../helpers/createNaturalBlockFromNode', async () => {
10
10
  return createNaturalBlockFromNodeMock();
@@ -1,5 +1,5 @@
1
- import type { ConstructProcessor } from '../../../../types';
2
- import { createNaturalBlockFromNode } from '../helpers/createNaturalBlockFromNode';
1
+ import type { ConstructProcessor } from '../../../../types.js';
2
+ import { createNaturalBlockFromNode } from '../helpers/createNaturalBlockFromNode.js';
3
3
 
4
4
  export function createNaturalBlockProcessor(): ConstructProcessor {
5
5
  return {
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { createSectionBlockParser } from './createSectionBlockParser';
3
+ import { createSectionBlockParser } from './createSectionBlockParser.js';
4
4
 
5
5
  describe('createSectionBlockParser', () => {
6
6
  it('WHEN called returns a parser with SectionBlock name, processor, integrator and factory', () => {
@@ -1,6 +1,6 @@
1
- import type { ConstructParserFactory } from '../../types';
1
+ import type { ConstructParserFactory } from '../../types.js';
2
2
 
3
- import { createSectionBlockIntegrator, createSectionBlockProcessor } from './private';
3
+ import { createSectionBlockIntegrator, createSectionBlockProcessor } from './private/index.js';
4
4
 
5
5
  export const createSectionBlockParser: ConstructParserFactory = () => ({
6
6
  name: 'SectionBlock',
@@ -1 +1 @@
1
- export { createSectionBlockParser } from './createSectionBlockParser';
1
+ export { createSectionBlockParser } from './createSectionBlockParser.js';
@@ -1,14 +1,14 @@
1
- import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
1
+ import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import type { Heading } from 'mdast';
3
3
  import { fromMarkdown } from 'mdast-util-from-markdown';
4
4
  import { describe, expect, it, vi } from 'vitest';
5
5
 
6
- import { createSectionBlock } from '../../../../../factories';
6
+ import { createSectionBlock } from '../../../../../factories/index.js';
7
7
 
8
- import { createSectionBlockFromNode } from './createSectionBlockFromNode';
8
+ import { createSectionBlockFromNode } from './createSectionBlockFromNode.js';
9
9
 
10
10
  vi.mock('../../../../../factories/constructs/SectionBlock/factory/createSectionBlock', async () => {
11
- const { createSectionBlockMock } = await import('../../../../../test/helpers');
11
+ const { createSectionBlockMock } = await import('../../../../../test/helpers/index.js');
12
12
  return createSectionBlockMock();
13
13
  });
14
14
 
@@ -27,7 +27,7 @@ describe('createSectionBlockFromNode', () => {
27
27
  expect(result).toBe(vi.mocked(createSectionBlock).mock.results[0]?.value);
28
28
  });
29
29
 
30
- it('WHEN the heading declares a kind extracts it', () => {
30
+ it('WHEN the heading contains a colon keeps the whole text as name', () => {
31
31
  const markdown = '# Module: Hello';
32
32
  const tree = fromMarkdown(markdown);
33
33
  const heading = tree.children[0] as Heading;
@@ -36,7 +36,7 @@ describe('createSectionBlockFromNode', () => {
36
36
  createSectionBlockFromNode(heading, context);
37
37
 
38
38
  expect(createSectionBlock).toHaveBeenCalledWith(
39
- expect.objectContaining({ kind: 'Module', name: 'Hello' }),
39
+ expect.objectContaining({ name: 'Module: Hello', depth: 1 }),
40
40
  );
41
41
  });
42
42
 
@@ -2,10 +2,9 @@ import { nodePosition } from '@art-md/primitives';
2
2
  import type { ParserVisitContext } from '@art-md/primitives';
3
3
  import type { Heading } from 'mdast';
4
4
 
5
- import { type SectionBlock, createSectionBlock } from '../../../../../factories';
6
- import { rawSlice } from '../../../../mdast';
7
- import { extractTags } from '../../../../tags';
8
- import { KIND_PATTERN } from '../constants';
5
+ import { type SectionBlock, createSectionBlock } from '../../../../../factories/index.js';
6
+ import { rawSlice } from '../../../../mdast/index.js';
7
+ import { extractTags } from '../../../../tags/index.js';
9
8
 
10
9
  export function createSectionBlockFromNode(
11
10
  node: Heading,
@@ -15,10 +14,8 @@ export function createSectionBlockFromNode(
15
14
  .replace(/^[ \t]*#+[ \t]*/, '')
16
15
  .trim();
17
16
  const { tags, stripped } = extractTags(text);
18
- const kindMatch = stripped.match(KIND_PATTERN);
19
17
  const section = createSectionBlock({
20
- name: kindMatch?.[2]?.trim() ?? stripped,
21
- kind: kindMatch?.[1],
18
+ name: stripped,
22
19
  depth: node.depth,
23
20
  children: [],
24
21
  tags,
@@ -1,10 +1,16 @@
1
1
  import type { ParserVisitContext } from '@art-md/primitives';
2
- import { makeDocumentMock, makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
2
+ import {
3
+ makeDocumentMock,
4
+ makeParserVisitContextMock,
5
+ } from '@art-md/primitives/src/test/helpers/index.js';
3
6
  import { describe, expect, it } from 'vitest';
4
7
 
5
- import { makeFieldBlockFixture, makeSectionBlockFixture } from '../../../../../test/helpers';
8
+ import {
9
+ makeFieldBlockFixture,
10
+ makeSectionBlockFixture,
11
+ } from '../../../../../test/helpers/index.js';
6
12
 
7
- import { findParentSection } from './findParentSection';
13
+ import { findParentSection } from './findParentSection.js';
8
14
 
9
15
  function makeContext(construct: ParserVisitContext['construct'], parent?: ParserVisitContext) {
10
16
  return {
@@ -1,6 +1,6 @@
1
1
  import type { ParserVisitContext } from '@art-md/primitives';
2
2
 
3
- import type { SectionBlock } from '../../../../../factories';
3
+ import type { SectionBlock } from '../../../../../factories/index.js';
4
4
 
5
5
  export function findParentSection(context: ParserVisitContext): SectionBlock | undefined {
6
6
  let current: ParserVisitContext | undefined = context;
@@ -1,2 +1,2 @@
1
- export * from './integrator/createSectionBlockIntegrator';
2
- export * from './processor/createSectionBlockProcessor';
1
+ export * from './integrator/createSectionBlockIntegrator.js';
2
+ export * from './processor/createSectionBlockProcessor.js';
@@ -1,12 +1,15 @@
1
1
  import { createParserVisitContext } from '@art-md/primitives';
2
- import { makeDocumentMock, makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
2
+ import {
3
+ makeDocumentMock,
4
+ makeParserVisitContextMock,
5
+ } from '@art-md/primitives/src/test/helpers/index.js';
3
6
  import type { Heading } from 'mdast';
4
7
  import { fromMarkdown } from 'mdast-util-from-markdown';
5
8
  import { describe, expect, it, vi } from 'vitest';
6
9
 
7
- import { makeSectionBlockFixture } from '../../../../../test/helpers';
10
+ import { makeSectionBlockFixture } from '../../../../../test/helpers/index.js';
8
11
 
9
- import { createSectionBlockIntegrator } from './createSectionBlockIntegrator';
12
+ import { createSectionBlockIntegrator } from './createSectionBlockIntegrator.js';
10
13
 
11
14
  function makeHeading(markdown: string): Heading {
12
15
  return fromMarkdown(markdown).children[0] as Heading;
@@ -1,9 +1,9 @@
1
1
  import { sectionDepth } from '@art-md/primitives';
2
2
  import type { Heading } from 'mdast';
3
3
 
4
- import type { SectionBlock } from '../../../../../factories';
5
- import type { ConstructIntegrator } from '../../../../types';
6
- import { findParentSection } from '../helpers/findParentSection';
4
+ import type { SectionBlock } from '../../../../../factories/index.js';
5
+ import type { ConstructIntegrator } from '../../../../types.js';
6
+ import { findParentSection } from '../helpers/findParentSection.js';
7
7
 
8
8
  export function createSectionBlockIntegrator(): ConstructIntegrator {
9
9
  return {
@@ -1,10 +1,10 @@
1
- import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers';
1
+ import { makeParserVisitContextMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import { describe, expect, it, vi } from 'vitest';
3
3
 
4
- import { createSectionBlockFromNodeMock } from '../../../../../test/helpers';
5
- import { createSectionBlockFromNode } from '../helpers/createSectionBlockFromNode';
4
+ import { createSectionBlockFromNodeMock } from '../../../../../test/helpers/index.js';
5
+ import { createSectionBlockFromNode } from '../helpers/createSectionBlockFromNode.js';
6
6
 
7
- import { createSectionBlockProcessor } from './createSectionBlockProcessor';
7
+ import { createSectionBlockProcessor } from './createSectionBlockProcessor.js';
8
8
 
9
9
  vi.mock('../helpers/createSectionBlockFromNode', async () => {
10
10
  return createSectionBlockFromNodeMock();
@@ -1,7 +1,7 @@
1
1
  import type { Heading } from 'mdast';
2
2
 
3
- import type { ConstructProcessor } from '../../../../types';
4
- import { createSectionBlockFromNode } from '../helpers/createSectionBlockFromNode';
3
+ import type { ConstructProcessor } from '../../../../types.js';
4
+ import { createSectionBlockFromNode } from '../helpers/createSectionBlockFromNode.js';
5
5
 
6
6
  export function createSectionBlockProcessor(): ConstructProcessor {
7
7
  return {
@@ -1,7 +1,7 @@
1
- import { nodePositionMock } from '@art-md/primitives/src/test/helpers';
1
+ import { nodePositionMock } from '@art-md/primitives/src/test/helpers/index.js';
2
2
  import { describe, expect, it, vi } from 'vitest';
3
3
 
4
- import { createArtDocumentFromNode } from './createArtDocumentFromNode';
4
+ import { createArtDocumentFromNode } from './createArtDocumentFromNode.js';
5
5
 
6
6
  vi.mock('@art-md/primitives', async () => {
7
7
  const actual = await import('@art-md/primitives');
@@ -1,7 +1,7 @@
1
1
  import { type ArtDocument, nodePosition } from '@art-md/primitives';
2
2
  import type { Node } from 'unist';
3
3
 
4
- import { createDocument } from '../../factories';
4
+ import { createDocument } from '../../factories/index.js';
5
5
 
6
6
  export function createArtDocumentFromNode(root: Node): ArtDocument {
7
7
  const document = createDocument({});
@@ -1 +1 @@
1
- export * from './createArtDocumentFromNode';
1
+ export * from './createArtDocumentFromNode.js';
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { FIELD_TEXT_PATTERN } from './constants';
3
+ import { FIELD_TEXT_PATTERN } from './constants.js';
4
4
 
5
5
  describe('FIELD_TEXT_PATTERN', () => {
6
6
  it('WHEN matching a field text pattern', () => {
@@ -1,3 +1,3 @@
1
- export { FIELD_TEXT_PATTERN } from './constants';
2
- export { isFieldStrong } from './isFieldStrong';
3
- export { stripStrong } from './stripStrong';
1
+ export { FIELD_TEXT_PATTERN } from './constants.js';
2
+ export { isFieldStrong } from './isFieldStrong.js';
3
+ export { stripStrong } from './stripStrong.js';
@@ -1,8 +1,8 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
2
 
3
- import { stripStrongMock } from '../../test/helpers';
3
+ import { stripStrongMock } from '../../test/helpers/index.js';
4
4
 
5
- import { isFieldStrong } from './isFieldStrong';
5
+ import { isFieldStrong } from './isFieldStrong.js';
6
6
 
7
7
  vi.mock('./stripStrong', () => {
8
8
  return stripStrongMock('Purpose:');
@@ -1,8 +1,8 @@
1
1
  import type { ParserVisitContext } from '@art-md/primitives';
2
2
  import type { Node, Strong } from 'mdast';
3
3
 
4
- import { FIELD_TEXT_PATTERN } from './constants';
5
- import { stripStrong } from './stripStrong';
4
+ import { FIELD_TEXT_PATTERN } from './constants.js';
5
+ import { stripStrong } from './stripStrong.js';
6
6
 
7
7
  export function isFieldStrong(node: Node, context: ParserVisitContext): node is Strong {
8
8
  return node.type === 'strong' && FIELD_TEXT_PATTERN.test(stripStrong(node as Strong, context));
@@ -1,11 +1,11 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
2
 
3
3
  // eslint-disable-next-line import/order
4
- import { rawSliceMock } from '../../test/helpers';
4
+ import { rawSliceMock } from '../../test/helpers/index.js';
5
5
  // eslint-disable-next-line import/order
6
- import { rawSlice } from '../mdast';
6
+ import { rawSlice } from '../mdast/index.js';
7
7
 
8
- import { stripStrong } from './stripStrong';
8
+ import { stripStrong } from './stripStrong.js';
9
9
 
10
10
  vi.mock('../mdast', () => {
11
11
  return rawSliceMock();
@@ -1,7 +1,7 @@
1
1
  import type { ParserVisitContext } from '@art-md/primitives';
2
2
  import type { Strong } from 'mdast';
3
3
 
4
- import { rawSlice } from '../mdast';
4
+ import { rawSlice } from '../mdast/index.js';
5
5
 
6
6
  export function stripStrong(node: Strong, context: ParserVisitContext): string {
7
7
  const raw = rawSlice(node, context);
@@ -1,8 +1,8 @@
1
- export { createArtDocumentFromNode } from './document';
1
+ export { createArtDocumentFromNode } from './document/index.js';
2
2
 
3
- export * from './constructs/FieldBlock';
4
- export * from './constructs/FieldInline';
5
- export * from './constructs/NaturalBlock';
6
- export * from './constructs/SectionBlock';
3
+ export * from './constructs/FieldBlock/index.js';
4
+ export * from './constructs/FieldInline/index.js';
5
+ export * from './constructs/NaturalBlock/index.js';
6
+ export * from './constructs/SectionBlock/index.js';
7
7
 
8
- export type * from './types';
8
+ export type * from './types.js';
@@ -1 +1 @@
1
- export { rawSlice } from './rawSlice';
1
+ export { rawSlice } from './rawSlice.js';
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { rawSlice } from './rawSlice';
3
+ import { rawSlice } from './rawSlice.js';
4
4
 
5
5
  describe('rawSlice', () => {
6
6
  it('FOR a node with position returns the raw slice', () => {
@@ -1,8 +1,8 @@
1
1
  import type { MdastNode } from '@art-md/primitives';
2
- import { nodePositionMock } from '@art-md/primitives/src/test/helpers';
2
+ import { nodePositionMock } from '@art-md/primitives/src/test/helpers/index.js';
3
3
  import { describe, expect, it, vi } from 'vitest';
4
4
 
5
- import { createNaturalExpressionFromNode } from './createNaturalExpressionFromNode';
5
+ import { createNaturalExpressionFromNode } from './createNaturalExpressionFromNode.js';
6
6
 
7
7
  vi.mock('@art-md/primitives/src/parser/helpers', () => {
8
8
  return nodePositionMock();
@@ -1,7 +1,6 @@
1
- import { type MdastNode } from '@art-md/primitives';
2
- import { nodePosition } from '@art-md/primitives/src/parser/helpers';
1
+ import { type MdastNode, nodePosition } from '@art-md/primitives';
3
2
 
4
- import type { NaturalExpression } from '../../factories';
3
+ import type { NaturalExpression } from '../../factories/index.js';
5
4
 
6
5
  export function createNaturalExpressionFromNode(node: MdastNode): NaturalExpression {
7
6
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1 +1 @@
1
- export { createNaturalExpressionFromNode } from './createNaturalExpressionFromNode';
1
+ export { createNaturalExpressionFromNode } from './createNaturalExpressionFromNode.js';
@@ -1,10 +1,10 @@
1
- import { createFieldBlockParser } from './constructs/FieldBlock';
2
- import { createFieldInlineParser } from './constructs/FieldInline';
3
- import { createNaturalBlockParser } from './constructs/NaturalBlock';
4
- import { createSectionBlockParser } from './constructs/SectionBlock';
5
- import type { ConstructParserFactory } from './types';
1
+ import { createFieldBlockParser } from './constructs/FieldBlock/index.js';
2
+ import { createFieldInlineParser } from './constructs/FieldInline/index.js';
3
+ import { createNaturalBlockParser } from './constructs/NaturalBlock/index.js';
4
+ import { createSectionBlockParser } from './constructs/SectionBlock/index.js';
5
+ import type { ConstructParserFactory } from './types.js';
6
6
 
7
- export { createArtDocumentFromNode } from './document/createArtDocumentFromNode';
7
+ export { createArtDocumentFromNode } from './document/createArtDocumentFromNode.js';
8
8
 
9
9
  export const CONSTRUCT_PARSERS: ConstructParserFactory[] = [
10
10
  createFieldBlockParser,
@@ -13,4 +13,4 @@ export const CONSTRUCT_PARSERS: ConstructParserFactory[] = [
13
13
  ];
14
14
  export const DEFAULT_CONSTRUCT_PARSER = createNaturalBlockParser;
15
15
 
16
- export type * from './types';
16
+ export type * from './types.js';
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
- import { extractTags } from './extractTags';
3
+ import { extractTags } from './extractTags.js';
4
4
 
5
5
  describe('extractTags', () => {
6
6
  it('WHEN there are no tags returns empty tags and unmodified text', () => {
@@ -1,4 +1,4 @@
1
- import { type Tag, createTag } from '../../factories';
1
+ import { type Tag, createTag } from '../../factories/index.js';
2
2
 
3
3
  const TRAILING_TAGS = /^(.*?)((?:\(#[\w-]+\)\s*)+)$/;
4
4
  const TAG = /\(#([\w-]+)\)/g;
@@ -1 +1 @@
1
- export { extractTags } from './extractTags';
1
+ export { extractTags } from './extractTags.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { MdastNode, ParserVisitContext } from '@art-md/primitives';
4
4
 
5
- import type { Construct } from '../factories';
5
+ import type { Construct } from '../factories/index.js';
6
6
 
7
7
  export type ConstructProcessor = {
8
8
  captureNode(context: ParserVisitContext, node: MdastNode): Construct | null;
@@ -1,7 +1,7 @@
1
1
  import type { Heading, Text } from 'mdast';
2
2
  import { describe, expect, it } from 'vitest';
3
3
 
4
- import { createDocumentToMdast } from './createDocumentToMdast';
4
+ import { createDocumentToMdast } from './createDocumentToMdast.js';
5
5
 
6
6
  describe('createDocumentToMdast', () => {
7
7
  it('WHEN wrapping children in a root node', () => {
@@ -1,6 +1,6 @@
1
1
  import type { Node } from 'mdast';
2
2
 
3
- import type { ConstructSerializer } from '../../types';
3
+ import type { ConstructSerializer } from '../../types.js';
4
4
 
5
5
  export function createDocumentToMdast(): ConstructSerializer {
6
6
  return {
@@ -1 +1 @@
1
- export { createDocumentToMdast } from './createDocumentToMdast';
1
+ export { createDocumentToMdast } from './createDocumentToMdast.js';