@xyd-js/uniform 0.1.0-xyd.6 → 0.1.0-xyd.68

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.
@@ -0,0 +1,180 @@
1
+ import React from 'react';
2
+ import { HighlightedCode } from 'codehike/code';
3
+
4
+ interface Reference<C = ReferenceContext, M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
5
+ title: string;
6
+ description: string | React.ReactNode;
7
+ canonical: string;
8
+ definitions: Definition<M, VM>[];
9
+ examples: ExampleRoot;
10
+ category?: ReferenceCategory;
11
+ type?: ReferenceType;
12
+ context?: C;
13
+ /**
14
+ * TODO: !!!! BETTER !!!!
15
+ * @internal
16
+ */
17
+ __UNSAFE_selector?: (selector: string) => any;
18
+ }
19
+ type DefinitionOpenAPIMeta = Meta<"contentType" | "required" | "definitionDescription">;
20
+ type DefinitionTypeDocMeta = Meta<"type">;
21
+ type DefinitionGraphqlMeta = Meta<"type" | "graphqlName">;
22
+ type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta;
23
+ type SymbolDef = {
24
+ id?: string | string[];
25
+ canonical?: string | string[];
26
+ };
27
+ interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
28
+ title: string;
29
+ properties: DefinitionProperty[];
30
+ rootProperty?: DefinitionProperty;
31
+ variants?: DefinitionVariant<VM>[];
32
+ description?: string | React.ReactNode;
33
+ meta?: M[];
34
+ /**
35
+ * @internal
36
+ */
37
+ symbolDef?: SymbolDef;
38
+ /**
39
+ * @internal
40
+ */
41
+ id?: string;
42
+ /**
43
+ * @internal
44
+ */
45
+ type?: string;
46
+ }
47
+ type DefinitionVariantOpenAPIMeta = Meta<"status" | "contentType" | "definitionDescription" | "required">;
48
+ type CommonDefinitionVariantMeta = Meta<"symbolName">;
49
+ type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta;
50
+ interface DefinitionVariant<M extends DefinitionVariantMeta = DefinitionVariantMeta> {
51
+ title: string;
52
+ properties: DefinitionProperty[];
53
+ rootProperty?: DefinitionProperty;
54
+ description?: string | React.ReactNode;
55
+ symbolDef?: SymbolDef;
56
+ meta?: M[];
57
+ }
58
+ interface Meta<T = string> {
59
+ name: T;
60
+ value?: unknown;
61
+ }
62
+ type DefinitionPropertyMeta = Meta<"required" | "deprecated" | "internal" | "defaults" | "nullable" | "example" | "examples" | "minimum" | "maximum" | "enum-type">;
63
+ declare enum DEFINED_DEFINITION_PROPERTY_TYPE {
64
+ UNION = "$$union",
65
+ XOR = "$$xor",
66
+ ARRAY = "$$array",
67
+ ENUM = "$$enum"
68
+ }
69
+ interface DefinitionProperty {
70
+ name: string;
71
+ type: string | DEFINED_DEFINITION_PROPERTY_TYPE;
72
+ description: string | React.ReactNode;
73
+ examples?: string | string[];
74
+ symbolDef?: SymbolDef;
75
+ meta?: DefinitionPropertyMeta[];
76
+ context?: any;
77
+ properties?: DefinitionProperty[];
78
+ ofProperty?: DefinitionProperty;
79
+ }
80
+ interface ExampleRoot {
81
+ groups: ExampleGroup[];
82
+ }
83
+ interface ExampleGroup {
84
+ description?: string;
85
+ examples: Example[];
86
+ }
87
+ interface Example {
88
+ description?: string;
89
+ codeblock: CodeBlock;
90
+ }
91
+ interface CodeBlock {
92
+ title?: string;
93
+ tabs: CodeBlockTab[];
94
+ }
95
+ interface CodeBlockTab {
96
+ title: string;
97
+ code: string;
98
+ language: string;
99
+ context?: ExampleContext;
100
+ highlighted?: HighlightedCode;
101
+ }
102
+ type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;
103
+ declare enum ReferenceCategory {
104
+ COMPONENTS = "components",
105
+ HOOKS = "hooks",
106
+ REST = "rest",
107
+ GRAPHQL = "graphql",
108
+ FUNCTIONS = "functions"
109
+ }
110
+ declare enum ReferenceType {
111
+ COMPONENT = "component",
112
+ HOOK = "hook",
113
+ REST_HTTP_GET = "rest_get",
114
+ REST_HTTP_POST = "rest_post",
115
+ REST_HTTP_PUT = "rest_put",
116
+ REST_HTTP_PATCH = "rest_patch",
117
+ REST_HTTP_DELETE = "rest_delete",
118
+ REST_HTTP_OPTIONS = "rest_options",
119
+ REST_HTTP_HEAD = "rest_head",
120
+ REST_HTTP_TRACE = "rest_trace",
121
+ REST_COMPONENT_SCHEMA = "rest_component_schema",
122
+ GRAPHQL_QUERY = "graphql_query",
123
+ GRAPHQL_MUTATION = "graphql_mutation",
124
+ GRAPHQL_SUBSCRIPTION = "graphql_subscription",
125
+ GRAPHQL_SCALAR = "graphql_scalar",
126
+ GRAPHQL_OBJECT = "graphql_object",
127
+ GRAPHQL_INTERFACE = "graphql_interface",
128
+ GRAPHQL_UNION = "graphql_union",
129
+ GRAPHQL_ENUM = "graphql_enum",
130
+ GRAPHQL_INPUT = "graphql_input",
131
+ FUNCTION_JS = "function_js"
132
+ }
133
+ interface BaseReferenceContext {
134
+ group?: string[];
135
+ scopes?: string[];
136
+ }
137
+ interface GraphQLReferenceContext extends BaseReferenceContext {
138
+ /**
139
+ * @internal
140
+ */
141
+ graphqlTypeShort: string;
142
+ graphqlName: string;
143
+ }
144
+ interface OpenAPIReferenceContext extends BaseReferenceContext {
145
+ method?: string;
146
+ path?: string;
147
+ fullPath?: string;
148
+ componentSchema?: string;
149
+ }
150
+ type TypeDocReferenceContextMeta = Meta<"internal">;
151
+ interface TypeDocReferenceContext extends BaseReferenceContext {
152
+ symbolId: string;
153
+ symbolName: string;
154
+ symbolKind: number;
155
+ packageName: string;
156
+ fileName: string;
157
+ fileFullPath: string;
158
+ line: number;
159
+ col: number;
160
+ signatureText: {
161
+ code: string;
162
+ lang: string;
163
+ };
164
+ sourcecode: {
165
+ code: string;
166
+ lang: string;
167
+ };
168
+ category?: string;
169
+ meta?: TypeDocReferenceContextMeta[];
170
+ }
171
+ type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext;
172
+ interface GraphQLExampleContext {
173
+ schema?: any;
174
+ }
175
+ interface OpenAPIExampleContext {
176
+ status?: number;
177
+ content?: string;
178
+ }
179
+
180
+ export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type Definition as d, type DefinitionVariantOpenAPIMeta as e, type DefinitionVariantMeta as f, type DefinitionVariant as g, type DefinitionPropertyMeta as h, DEFINED_DEFINITION_PROPERTY_TYPE as i, type DefinitionProperty as j, type ExampleGroup as k, type Example as l, type CodeBlock as m, type CodeBlockTab as n, type ExampleContext as o, ReferenceCategory as p, ReferenceType as q, type TypeDocReferenceContext as r, type ReferenceContext as s, type GraphQLExampleContext as t, type OpenAPIExampleContext as u };
@@ -0,0 +1,180 @@
1
+ import React from 'react';
2
+ import { HighlightedCode } from 'codehike/code';
3
+
4
+ interface Reference<C = ReferenceContext, M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
5
+ title: string;
6
+ description: string | React.ReactNode;
7
+ canonical: string;
8
+ definitions: Definition<M, VM>[];
9
+ examples: ExampleRoot;
10
+ category?: ReferenceCategory;
11
+ type?: ReferenceType;
12
+ context?: C;
13
+ /**
14
+ * TODO: !!!! BETTER !!!!
15
+ * @internal
16
+ */
17
+ __UNSAFE_selector?: (selector: string) => any;
18
+ }
19
+ type DefinitionOpenAPIMeta = Meta<"contentType" | "required" | "definitionDescription">;
20
+ type DefinitionTypeDocMeta = Meta<"type">;
21
+ type DefinitionGraphqlMeta = Meta<"type" | "graphqlName">;
22
+ type DefinitionMeta = DefinitionOpenAPIMeta | DefinitionTypeDocMeta | DefinitionGraphqlMeta;
23
+ type SymbolDef = {
24
+ id?: string | string[];
25
+ canonical?: string | string[];
26
+ };
27
+ interface Definition<M extends DefinitionMeta = DefinitionMeta, VM extends DefinitionVariantMeta = DefinitionVariantMeta> {
28
+ title: string;
29
+ properties: DefinitionProperty[];
30
+ rootProperty?: DefinitionProperty;
31
+ variants?: DefinitionVariant<VM>[];
32
+ description?: string | React.ReactNode;
33
+ meta?: M[];
34
+ /**
35
+ * @internal
36
+ */
37
+ symbolDef?: SymbolDef;
38
+ /**
39
+ * @internal
40
+ */
41
+ id?: string;
42
+ /**
43
+ * @internal
44
+ */
45
+ type?: string;
46
+ }
47
+ type DefinitionVariantOpenAPIMeta = Meta<"status" | "contentType" | "definitionDescription" | "required">;
48
+ type CommonDefinitionVariantMeta = Meta<"symbolName">;
49
+ type DefinitionVariantMeta = CommonDefinitionVariantMeta | DefinitionVariantOpenAPIMeta;
50
+ interface DefinitionVariant<M extends DefinitionVariantMeta = DefinitionVariantMeta> {
51
+ title: string;
52
+ properties: DefinitionProperty[];
53
+ rootProperty?: DefinitionProperty;
54
+ description?: string | React.ReactNode;
55
+ symbolDef?: SymbolDef;
56
+ meta?: M[];
57
+ }
58
+ interface Meta<T = string> {
59
+ name: T;
60
+ value?: unknown;
61
+ }
62
+ type DefinitionPropertyMeta = Meta<"required" | "deprecated" | "internal" | "defaults" | "nullable" | "example" | "examples" | "minimum" | "maximum" | "enum-type">;
63
+ declare enum DEFINED_DEFINITION_PROPERTY_TYPE {
64
+ UNION = "$$union",
65
+ XOR = "$$xor",
66
+ ARRAY = "$$array",
67
+ ENUM = "$$enum"
68
+ }
69
+ interface DefinitionProperty {
70
+ name: string;
71
+ type: string | DEFINED_DEFINITION_PROPERTY_TYPE;
72
+ description: string | React.ReactNode;
73
+ examples?: string | string[];
74
+ symbolDef?: SymbolDef;
75
+ meta?: DefinitionPropertyMeta[];
76
+ context?: any;
77
+ properties?: DefinitionProperty[];
78
+ ofProperty?: DefinitionProperty;
79
+ }
80
+ interface ExampleRoot {
81
+ groups: ExampleGroup[];
82
+ }
83
+ interface ExampleGroup {
84
+ description?: string;
85
+ examples: Example[];
86
+ }
87
+ interface Example {
88
+ description?: string;
89
+ codeblock: CodeBlock;
90
+ }
91
+ interface CodeBlock {
92
+ title?: string;
93
+ tabs: CodeBlockTab[];
94
+ }
95
+ interface CodeBlockTab {
96
+ title: string;
97
+ code: string;
98
+ language: string;
99
+ context?: ExampleContext;
100
+ highlighted?: HighlightedCode;
101
+ }
102
+ type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;
103
+ declare enum ReferenceCategory {
104
+ COMPONENTS = "components",
105
+ HOOKS = "hooks",
106
+ REST = "rest",
107
+ GRAPHQL = "graphql",
108
+ FUNCTIONS = "functions"
109
+ }
110
+ declare enum ReferenceType {
111
+ COMPONENT = "component",
112
+ HOOK = "hook",
113
+ REST_HTTP_GET = "rest_get",
114
+ REST_HTTP_POST = "rest_post",
115
+ REST_HTTP_PUT = "rest_put",
116
+ REST_HTTP_PATCH = "rest_patch",
117
+ REST_HTTP_DELETE = "rest_delete",
118
+ REST_HTTP_OPTIONS = "rest_options",
119
+ REST_HTTP_HEAD = "rest_head",
120
+ REST_HTTP_TRACE = "rest_trace",
121
+ REST_COMPONENT_SCHEMA = "rest_component_schema",
122
+ GRAPHQL_QUERY = "graphql_query",
123
+ GRAPHQL_MUTATION = "graphql_mutation",
124
+ GRAPHQL_SUBSCRIPTION = "graphql_subscription",
125
+ GRAPHQL_SCALAR = "graphql_scalar",
126
+ GRAPHQL_OBJECT = "graphql_object",
127
+ GRAPHQL_INTERFACE = "graphql_interface",
128
+ GRAPHQL_UNION = "graphql_union",
129
+ GRAPHQL_ENUM = "graphql_enum",
130
+ GRAPHQL_INPUT = "graphql_input",
131
+ FUNCTION_JS = "function_js"
132
+ }
133
+ interface BaseReferenceContext {
134
+ group?: string[];
135
+ scopes?: string[];
136
+ }
137
+ interface GraphQLReferenceContext extends BaseReferenceContext {
138
+ /**
139
+ * @internal
140
+ */
141
+ graphqlTypeShort: string;
142
+ graphqlName: string;
143
+ }
144
+ interface OpenAPIReferenceContext extends BaseReferenceContext {
145
+ method?: string;
146
+ path?: string;
147
+ fullPath?: string;
148
+ componentSchema?: string;
149
+ }
150
+ type TypeDocReferenceContextMeta = Meta<"internal">;
151
+ interface TypeDocReferenceContext extends BaseReferenceContext {
152
+ symbolId: string;
153
+ symbolName: string;
154
+ symbolKind: number;
155
+ packageName: string;
156
+ fileName: string;
157
+ fileFullPath: string;
158
+ line: number;
159
+ col: number;
160
+ signatureText: {
161
+ code: string;
162
+ lang: string;
163
+ };
164
+ sourcecode: {
165
+ code: string;
166
+ lang: string;
167
+ };
168
+ category?: string;
169
+ meta?: TypeDocReferenceContextMeta[];
170
+ }
171
+ type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext | TypeDocReferenceContext;
172
+ interface GraphQLExampleContext {
173
+ schema?: any;
174
+ }
175
+ interface OpenAPIExampleContext {
176
+ status?: number;
177
+ content?: string;
178
+ }
179
+
180
+ export { type BaseReferenceContext as B, type CommonDefinitionVariantMeta as C, type DefinitionOpenAPIMeta as D, type ExampleRoot as E, type GraphQLReferenceContext as G, type Meta as M, type OpenAPIReferenceContext as O, type Reference as R, type SymbolDef as S, type TypeDocReferenceContextMeta as T, type DefinitionTypeDocMeta as a, type DefinitionGraphqlMeta as b, type DefinitionMeta as c, type Definition as d, type DefinitionVariantOpenAPIMeta as e, type DefinitionVariantMeta as f, type DefinitionVariant as g, type DefinitionPropertyMeta as h, DEFINED_DEFINITION_PROPERTY_TYPE as i, type DefinitionProperty as j, type ExampleGroup as k, type Example as l, type CodeBlock as m, type CodeBlockTab as n, type ExampleContext as o, ReferenceCategory as p, ReferenceType as q, type TypeDocReferenceContext as r, type ReferenceContext as s, type GraphQLExampleContext as t, type OpenAPIExampleContext as u };
package/index.ts CHANGED
@@ -1,8 +1,14 @@
1
- export {default} from "./src/index"
1
+ export * from "./src/types"
2
+ export type {
3
+ UniformPlugin,
4
+ UniformPluginArgs
5
+ } from "./src/index"
6
+
7
+ export { default } from "./src/index"
2
8
 
3
9
  export {
4
- pluginNavigation
5
- } from "./src/utils"
10
+ pluginJsonView,
11
+ pluginNavigation,
12
+ } from "./src/plugins"
6
13
 
7
- export * from "./src/types"
8
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyd-js/uniform",
3
- "version": "0.1.0-xyd.6",
3
+ "version": "0.1.0-xyd.68",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -12,27 +12,29 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "codehike": "^1.0.3",
15
- "gray-matter": "^4.0.3",
16
15
  "mdast-util-from-markdown": "^2.0.2",
17
- "mdast-util-to-markdown": "^2.1.2",
18
16
  "remark": "^15.0.1",
19
17
  "remark-stringify": "^11.0.0",
20
18
  "unist-builder": "^4.0.0",
21
19
  "unist-util-visit": "^5.0.0",
22
- "@xyd-js/core": "0.1.0-xyd.4"
20
+ "@xyd-js/core": "0.1.0-xyd.66"
23
21
  },
24
22
  "peerDependencies": {
25
23
  "@mdx-js/mdx": "^3.1.0"
26
24
  },
27
25
  "devDependencies": {
26
+ "@vitest/coverage-v8": "^1.3.1",
28
27
  "@types/node": "^22.10.5",
29
28
  "rimraf": "^3.0.2",
30
29
  "tsup": "^8.3.0",
31
- "typescript": "^4.5.5"
30
+ "typescript": "^4.5.5",
31
+ "vitest": "^1.3.1"
32
32
  },
33
33
  "scripts": {
34
34
  "clean": "rimraf build",
35
35
  "prebuild": "pnpm clean",
36
- "build": "tsup"
36
+ "build": "tsup",
37
+ "test": "vitest",
38
+ "test:coverage": "vitest run --coverage"
37
39
  }
38
40
  }
package/src/index.ts CHANGED
@@ -1,8 +1,22 @@
1
1
  // Define the new PluginV type with a callback function that returns another function
2
2
  import {Reference} from "./types";
3
3
 
4
+ export * from "./types";
5
+
4
6
  // Define the new PluginV type with a callback function that returns another function
5
- export type UniformPlugin<T> = (cb: (cb: () => T) => void) => (ref: Reference) => void;
7
+ export type UniformPluginArgs = {
8
+ references: Reference[] | Reference,
9
+ defer: (defer: () => any) => void;
10
+
11
+ // TODO: maybe in the future
12
+ // visit: (selector: string | "[method] [path]", callback: (...args: any[]) => void) => void;
13
+ }
14
+
15
+
16
+ export type UniformPluginRestArgs = {
17
+ index: number;
18
+ }
19
+ export type UniformPlugin<T> = (args: UniformPluginArgs) => (ref: Reference, restArgs: UniformPluginRestArgs) => void;
6
20
 
7
21
  // Utility type to infer if a type is an array and avoid wrapping it into an array twice
8
22
  type NormalizeArray<T> = T extends Array<infer U> ? U[] : T;
@@ -35,22 +49,28 @@ export default function uniform<T extends UniformPlugin<any>[]>(
35
49
  out: {} as { [K in keyof ResultType]: ResultType[K] }
36
50
  };
37
51
 
38
-
39
- const finishCallbacks = new Set();
40
-
41
52
  config.plugins.forEach((plugin) => {
42
- const call = plugin(cb => {
43
- finishCallbacks.add(cb);
53
+ let defer: any = undefined; // fix any
54
+
55
+ const call = plugin({
56
+ references: references,
57
+ defer: (cb) => {
58
+ if (typeof cb === "function") {
59
+ defer = cb
60
+ }
61
+ },
62
+ // visit: (pattern, callback) => {
63
+ // }
44
64
  })
45
65
 
46
- references.forEach((ref) => {
47
- call(ref)
66
+ references.map((ref, i) => {
67
+ call(ref, {
68
+ index: i,
69
+ })
48
70
  });
49
- })
50
71
 
51
- finishCallbacks.forEach(cb => {
52
- if (typeof cb === "function") {
53
- const resp = cb()
72
+ if (typeof defer === "function") {
73
+ const resp = defer()
54
74
  if (typeof resp !== "object") {
55
75
  throw new Error(`Invalid callback return type: ${typeof resp}`)
56
76
  }
@@ -59,10 +79,8 @@ export default function uniform<T extends UniformPlugin<any>[]>(
59
79
  ...response.out,
60
80
  ...resp
61
81
  }
62
- } else {
63
- throw new Error(`Invalid callback type: ${typeof cb}`)
64
82
  }
65
- });
83
+ })
66
84
 
67
85
  return response;
68
86
  }
@@ -72,8 +90,8 @@ export default function uniform<T extends UniformPlugin<any>[]>(
72
90
  // return (ref: Reference) => {
73
91
  // };
74
92
  // };
75
- // function examplePlugin(cb: (cb: () => { value: boolean }) => void) {
76
- // cb(() => ({
93
+ // function examplePlugin(defer: (defer: () => { value: boolean }) => void) {
94
+ // defer(() => ({
77
95
  // value: true,
78
96
  // }));
79
97
  //
@@ -29,7 +29,7 @@ export function referenceAST(ref: Reference) {
29
29
  const mdHeading = heading(
30
30
  ref.title,
31
31
  ref.canonical,
32
- ref.description,
32
+ typeof ref.description === "string" ? ref.description : "",
33
33
  ref.category,
34
34
  ref.type,
35
35
  ref.context
@@ -79,12 +79,24 @@ export function heading(
79
79
 
80
80
 
81
81
  for (const [key, value] of Object.entries(refContext)) {
82
- uContext.push(u(
83
- 'heading',
84
- {depth: uContext[0].depth + 1},
85
- [u('text', `!${key} ${value}`)]
86
- )
87
- )
82
+ if (typeof value === "object") {
83
+ // TODO: support ```<lang> ??
84
+ if (value.code) {
85
+ uContext.push(
86
+ u('heading', {depth: uContext[0].depth + 1}, [u('text', `!${key}`)])
87
+ );
88
+
89
+ uContext.push(
90
+ u('code', {lang: value.lang}, value.code)
91
+ );
92
+
93
+ continue;
94
+ }
95
+ }
96
+
97
+ uContext.push(
98
+ u('heading', {depth: uContext[0].depth + 1}, [u('text', `!${key} ${value.toString()}`)])
99
+ );
88
100
  }
89
101
  }
90
102
 
@@ -0,0 +1,132 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import fs from 'fs';
3
+ import { pluginJsonView } from '../pluginJsonView';
4
+ import type { Reference } from '../../types';
5
+ import uniform from '../../index'
6
+
7
+ describe('pluginJsonView', () => {
8
+ it('should handle properties without examples', () => {
9
+ const plugin = pluginJsonView();
10
+
11
+ const inputs: Reference[] = [
12
+ {
13
+ title: 'Test title',
14
+ description: 'Test description',
15
+ canonical: 'test-canonical',
16
+ examples: {
17
+ groups: []
18
+ },
19
+ "definitions": [
20
+ {
21
+ "title": "Properties",
22
+ "properties": [
23
+ {
24
+ "name": "charset",
25
+ "type": "string",
26
+ "description": "Character encoding for the document\n",
27
+ "examples": [
28
+ "\"UTF-8\""
29
+ ]
30
+ },
31
+ {
32
+ "name": "robots",
33
+ "type": "string",
34
+ "description": "Standard meta tag for controlling search engine crawling and indexing\n",
35
+ "examples": [
36
+ "\"index, follow\"",
37
+ "\"noindex, nofollow\""
38
+ ]
39
+ }
40
+ ]
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ title: 'Test title',
46
+ description: 'Test description',
47
+ canonical: 'test-canonical',
48
+ examples: {
49
+ groups: []
50
+ },
51
+ "definitions": [
52
+ {
53
+ "title": "Properties",
54
+ "properties": [
55
+ {
56
+ "name": "charset",
57
+ "type": "string",
58
+ "description": "Character encoding for the document\n",
59
+ "examples": [
60
+ "UTF-8"
61
+ ]
62
+ },
63
+ {
64
+ "name": "robots",
65
+ "type": "string",
66
+ "description": "Standard meta tag for controlling search engine crawling and indexing\n",
67
+ "examples": [
68
+ "index, follow",
69
+ "noindex, nofollow"
70
+ ]
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ title: 'Test title',
78
+ description: 'Test description',
79
+ canonical: 'test-canonical',
80
+ examples: {
81
+ groups: []
82
+ },
83
+ "definitions": [
84
+ {
85
+ "title": "Properties",
86
+ "properties": [
87
+ {
88
+ "name": "robots",
89
+ "type": "string",
90
+ "description": "Standard meta tag for controlling search engine crawling and indexing\n",
91
+ "examples": [
92
+ "index, follow",
93
+ "noindex, nofollow"
94
+ ]
95
+ },
96
+ {
97
+ "name": "charset",
98
+ "type": "string",
99
+ "description": "Character encoding for the document\n",
100
+ "examples": [
101
+ "UTF-8"
102
+ ]
103
+ },
104
+ ]
105
+ }
106
+ ]
107
+ }
108
+ ];
109
+
110
+ const outputs: string[] = [
111
+ '{\n' +
112
+ ' "charset": "UTF-8",\n' +
113
+ ' "robots": "index, follow" // or "noindex, nofollow"\n' +
114
+ '}',
115
+
116
+ '{\n' +
117
+ ' "charset": "UTF-8",\n' +
118
+ ' "robots": "index, follow" // or "noindex, nofollow"\n' +
119
+ '}',
120
+
121
+ '{\n' +
122
+ ' "robots": "index, follow", // or "noindex, nofollow"\n' +
123
+ ' "charset": "UTF-8"\n' +
124
+ '}',
125
+ ]
126
+ const result = uniform(inputs, {
127
+ plugins: [plugin]
128
+ });
129
+
130
+ expect(result.out.jsonViews).toStrictEqual(outputs);
131
+ });
132
+ });
@@ -0,0 +1,2 @@
1
+ export { pluginJsonView } from "./pluginJsonView"
2
+ export { pluginNavigation } from "./pluginNavigation"