@docusaurus/utils-validation 3.3.2 → 3.5.0
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.
- package/lib/Joi.js +2 -1
- package/lib/Joi.js.map +1 -1
- package/lib/JoiFrontMatter.d.ts +1 -1
- package/lib/JoiFrontMatter.d.ts.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -2
- package/lib/index.js.map +1 -1
- package/lib/tagsFile.d.ts +17 -0
- package/lib/tagsFile.d.ts.map +1 -0
- package/lib/tagsFile.js +92 -0
- package/lib/tagsFile.js.map +1 -0
- package/lib/validationSchemas.d.ts +1 -0
- package/lib/validationSchemas.d.ts.map +1 -1
- package/lib/validationSchemas.js +6 -2
- package/lib/validationSchemas.js.map +1 -1
- package/lib/validationUtils.js +4 -5
- package/lib/validationUtils.js.map +1 -1
- package/package.json +10 -5
- package/src/index.ts +2 -0
- package/src/tagsFile.ts +131 -0
- package/src/validationSchemas.ts +9 -2
package/lib/Joi.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.default = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
10
11
|
var joi_1 = require("joi");
|
|
11
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(joi_1).default; } });
|
|
12
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(joi_1).default; } });
|
|
12
13
|
//# sourceMappingURL=Joi.js.map
|
package/lib/Joi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Joi.js","sourceRoot":"","sources":["../src/Joi.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"Joi.js","sourceRoot":"","sources":["../src/Joi.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,2BAA4B;AAApB,uHAAA,OAAO,OAAA"}
|
package/lib/JoiFrontMatter.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ import Joi from './Joi';
|
|
|
14
14
|
* @see https://github.com/facebook/docusaurus/issues/4642
|
|
15
15
|
* @see https://github.com/sideway/joi/issues/1442#issuecomment-823997884
|
|
16
16
|
*/
|
|
17
|
-
export declare const JoiFrontMatter: Joi
|
|
17
|
+
export declare const JoiFrontMatter: typeof Joi;
|
|
18
18
|
//# sourceMappingURL=JoiFrontMatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JoiFrontMatter.d.ts","sourceRoot":"","sources":["../src/JoiFrontMatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG,MAAM,OAAO,CAAC;AAcxB;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"JoiFrontMatter.d.ts","sourceRoot":"","sources":["../src/JoiFrontMatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG,MAAM,OAAO,CAAC;AAcxB;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAuC,OAAO,GAAG,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
export { default as Joi } from './Joi';
|
|
8
8
|
export { JoiFrontMatter } from './JoiFrontMatter';
|
|
9
9
|
export { printWarning, normalizePluginOptions, normalizeThemeConfig, validateFrontMatter, } from './validationUtils';
|
|
10
|
-
export { PluginIdSchema, RemarkPluginsSchema, RehypePluginsSchema, AdmonitionsSchema, RouteBasePathSchema, URISchema, PathnameSchema, FrontMatterTagsSchema, FrontMatterTOCHeadingLevels, ContentVisibilitySchema, FrontMatterLastUpdateErrorMessage, FrontMatterLastUpdateSchema, } from './validationSchemas';
|
|
10
|
+
export { PluginIdSchema, RemarkPluginsSchema, RehypePluginsSchema, RecmaPluginsSchema, AdmonitionsSchema, RouteBasePathSchema, URISchema, PathnameSchema, FrontMatterTagsSchema, FrontMatterTOCHeadingLevels, ContentVisibilitySchema, FrontMatterLastUpdateErrorMessage, FrontMatterLastUpdateSchema, } from './validationSchemas';
|
|
11
|
+
export { getTagsFilePathsToWatch, getTagsFile } from './tagsFile';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,OAAO,IAAI,GAAG,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,iCAAiC,EACjC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,OAAO,IAAI,GAAG,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,iCAAiC,EACjC,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,uBAAuB,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.FrontMatterLastUpdateSchema = exports.FrontMatterLastUpdateErrorMessage = exports.ContentVisibilitySchema = exports.FrontMatterTOCHeadingLevels = exports.FrontMatterTagsSchema = exports.PathnameSchema = exports.URISchema = exports.RouteBasePathSchema = exports.AdmonitionsSchema = exports.RehypePluginsSchema = exports.RemarkPluginsSchema = exports.PluginIdSchema = exports.validateFrontMatter = exports.normalizeThemeConfig = exports.normalizePluginOptions = exports.printWarning = exports.JoiFrontMatter = exports.Joi = void 0;
|
|
9
|
+
exports.getTagsFile = exports.getTagsFilePathsToWatch = exports.FrontMatterLastUpdateSchema = exports.FrontMatterLastUpdateErrorMessage = exports.ContentVisibilitySchema = exports.FrontMatterTOCHeadingLevels = exports.FrontMatterTagsSchema = exports.PathnameSchema = exports.URISchema = exports.RouteBasePathSchema = exports.AdmonitionsSchema = exports.RecmaPluginsSchema = exports.RehypePluginsSchema = exports.RemarkPluginsSchema = exports.PluginIdSchema = exports.validateFrontMatter = exports.normalizeThemeConfig = exports.normalizePluginOptions = exports.printWarning = exports.JoiFrontMatter = exports.Joi = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
10
11
|
// /!\ don't remove this export, as we recommend plugin authors to use it
|
|
11
12
|
var Joi_1 = require("./Joi");
|
|
12
|
-
Object.defineProperty(exports, "Joi", { enumerable: true, get: function () { return __importDefault(Joi_1).default; } });
|
|
13
|
+
Object.defineProperty(exports, "Joi", { enumerable: true, get: function () { return tslib_1.__importDefault(Joi_1).default; } });
|
|
13
14
|
var JoiFrontMatter_1 = require("./JoiFrontMatter");
|
|
14
15
|
Object.defineProperty(exports, "JoiFrontMatter", { enumerable: true, get: function () { return JoiFrontMatter_1.JoiFrontMatter; } });
|
|
15
16
|
var validationUtils_1 = require("./validationUtils");
|
|
@@ -21,6 +22,7 @@ var validationSchemas_1 = require("./validationSchemas");
|
|
|
21
22
|
Object.defineProperty(exports, "PluginIdSchema", { enumerable: true, get: function () { return validationSchemas_1.PluginIdSchema; } });
|
|
22
23
|
Object.defineProperty(exports, "RemarkPluginsSchema", { enumerable: true, get: function () { return validationSchemas_1.RemarkPluginsSchema; } });
|
|
23
24
|
Object.defineProperty(exports, "RehypePluginsSchema", { enumerable: true, get: function () { return validationSchemas_1.RehypePluginsSchema; } });
|
|
25
|
+
Object.defineProperty(exports, "RecmaPluginsSchema", { enumerable: true, get: function () { return validationSchemas_1.RecmaPluginsSchema; } });
|
|
24
26
|
Object.defineProperty(exports, "AdmonitionsSchema", { enumerable: true, get: function () { return validationSchemas_1.AdmonitionsSchema; } });
|
|
25
27
|
Object.defineProperty(exports, "RouteBasePathSchema", { enumerable: true, get: function () { return validationSchemas_1.RouteBasePathSchema; } });
|
|
26
28
|
Object.defineProperty(exports, "URISchema", { enumerable: true, get: function () { return validationSchemas_1.URISchema; } });
|
|
@@ -30,4 +32,7 @@ Object.defineProperty(exports, "FrontMatterTOCHeadingLevels", { enumerable: true
|
|
|
30
32
|
Object.defineProperty(exports, "ContentVisibilitySchema", { enumerable: true, get: function () { return validationSchemas_1.ContentVisibilitySchema; } });
|
|
31
33
|
Object.defineProperty(exports, "FrontMatterLastUpdateErrorMessage", { enumerable: true, get: function () { return validationSchemas_1.FrontMatterLastUpdateErrorMessage; } });
|
|
32
34
|
Object.defineProperty(exports, "FrontMatterLastUpdateSchema", { enumerable: true, get: function () { return validationSchemas_1.FrontMatterLastUpdateSchema; } });
|
|
35
|
+
var tagsFile_1 = require("./tagsFile");
|
|
36
|
+
Object.defineProperty(exports, "getTagsFilePathsToWatch", { enumerable: true, get: function () { return tagsFile_1.getTagsFilePathsToWatch; } });
|
|
37
|
+
Object.defineProperty(exports, "getTagsFile", { enumerable: true, get: function () { return tagsFile_1.getTagsFile; } });
|
|
33
38
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yEAAyE;AACzE,6BAAqC;AAA7B,mHAAA,OAAO,OAAO;AACtB,mDAAgD;AAAxC,gHAAA,cAAc,OAAA;AAEtB,qDAK2B;AAJzB,+GAAA,YAAY,OAAA;AACZ,yHAAA,sBAAsB,OAAA;AACtB,uHAAA,oBAAoB,OAAA;AACpB,sHAAA,mBAAmB,OAAA;AAErB,yDAc6B;AAb3B,mHAAA,cAAc,OAAA;AACd,wHAAA,mBAAmB,OAAA;AACnB,wHAAA,mBAAmB,OAAA;AACnB,uHAAA,kBAAkB,OAAA;AAClB,sHAAA,iBAAiB,OAAA;AACjB,wHAAA,mBAAmB,OAAA;AACnB,8GAAA,SAAS,OAAA;AACT,mHAAA,cAAc,OAAA;AACd,0HAAA,qBAAqB,OAAA;AACrB,gIAAA,2BAA2B,OAAA;AAC3B,4HAAA,uBAAuB,OAAA;AACvB,sIAAA,iCAAiC,OAAA;AACjC,gIAAA,2BAA2B,OAAA;AAE7B,uCAAgE;AAAxD,mHAAA,uBAAuB,OAAA;AAAE,uGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { ContentPaths, TagsFile, TagsFileInput, TagsPluginOptions } from '@docusaurus/utils';
|
|
8
|
+
export declare function ensureUniquePermalinks(tags: TagsFile): void;
|
|
9
|
+
export declare function normalizeTagsFile(data: TagsFileInput): TagsFile;
|
|
10
|
+
type GetTagsFileParams = {
|
|
11
|
+
tags: TagsPluginOptions['tags'];
|
|
12
|
+
contentPaths: ContentPaths;
|
|
13
|
+
};
|
|
14
|
+
export declare function getTagsFilePathsToWatch({ tags, contentPaths, }: GetTagsFileParams): string[];
|
|
15
|
+
export declare function getTagsFile({ tags, contentPaths, }: GetTagsFileParams): Promise<TagsFile | null>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=tagsFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagsFile.d.ts","sourceRoot":"","sources":["../src/tagsFile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAW3B,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAqB3D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,QAAQ,CAQ/D;AAED,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,YAAY,GACb,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAS9B;AAED,wBAAsB,WAAW,CAAC,EAChC,IAAI,EACJ,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA4C9C"}
|
package/lib/tagsFile.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ensureUniquePermalinks = ensureUniquePermalinks;
|
|
10
|
+
exports.normalizeTagsFile = normalizeTagsFile;
|
|
11
|
+
exports.getTagsFilePathsToWatch = getTagsFilePathsToWatch;
|
|
12
|
+
exports.getTagsFile = getTagsFile;
|
|
13
|
+
const tslib_1 = require("tslib");
|
|
14
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
16
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
17
|
+
const joi_1 = tslib_1.__importDefault(require("joi"));
|
|
18
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
19
|
+
const utils_1 = require("@docusaurus/utils");
|
|
20
|
+
const TagsFileInputSchema = joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.object({
|
|
21
|
+
label: joi_1.default.string(),
|
|
22
|
+
description: joi_1.default.string(),
|
|
23
|
+
permalink: joi_1.default.string(),
|
|
24
|
+
}).allow(null));
|
|
25
|
+
function ensureUniquePermalinks(tags) {
|
|
26
|
+
const permalinks = new Set();
|
|
27
|
+
const duplicates = new Set();
|
|
28
|
+
for (const [, tag] of Object.entries(tags)) {
|
|
29
|
+
const { permalink } = tag;
|
|
30
|
+
if (permalinks.has(permalink)) {
|
|
31
|
+
duplicates.add(permalink);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
permalinks.add(permalink);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (duplicates.size > 0) {
|
|
38
|
+
const duplicateList = Array.from(duplicates)
|
|
39
|
+
.map((permalink) => ` - ${permalink}`)
|
|
40
|
+
.join('\n');
|
|
41
|
+
throw new Error(`Duplicate permalinks found in tags file:\n${duplicateList}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function normalizeTagsFile(data) {
|
|
45
|
+
return lodash_1.default.mapValues(data, (tag, key) => {
|
|
46
|
+
return {
|
|
47
|
+
label: tag?.label || lodash_1.default.capitalize(key),
|
|
48
|
+
description: tag?.description,
|
|
49
|
+
permalink: tag?.permalink || `/${lodash_1.default.kebabCase(key)}`,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const DefaultTagsFileName = 'tags.yml';
|
|
54
|
+
function getTagsFilePathsToWatch({ tags, contentPaths, }) {
|
|
55
|
+
if (tags === false || tags === null) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const relativeFilePath = tags ?? DefaultTagsFileName;
|
|
59
|
+
return (0, utils_1.getContentPathList)(contentPaths).map((contentPath) => node_path_1.default.posix.join(contentPath, relativeFilePath));
|
|
60
|
+
}
|
|
61
|
+
async function getTagsFile({ tags, contentPaths, }) {
|
|
62
|
+
if (tags === false || tags === null) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const relativeFilePath = tags ?? DefaultTagsFileName;
|
|
66
|
+
// if returned path is defined, the file exists (localized or not)
|
|
67
|
+
const yamlFilePath = await (0, utils_1.getDataFilePath)({
|
|
68
|
+
contentPaths,
|
|
69
|
+
filePath: relativeFilePath,
|
|
70
|
+
});
|
|
71
|
+
// If the tags option is undefined, don't throw when the file does not exist
|
|
72
|
+
// Retro-compatible behavior: existing sites do not yet have tags.yml
|
|
73
|
+
if (tags === undefined && !yamlFilePath) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (!yamlFilePath) {
|
|
77
|
+
throw new Error(`No tags file '${relativeFilePath}' could be found in any of those directories:\n- ${(0, utils_1.getContentPathList)(contentPaths).join('\n- ')}`);
|
|
78
|
+
}
|
|
79
|
+
const tagDefinitionContent = await fs_extra_1.default.readFile(yamlFilePath, 'utf-8');
|
|
80
|
+
if (!tagDefinitionContent.trim()) {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
const yamlContent = js_yaml_1.default.load(tagDefinitionContent);
|
|
84
|
+
const tagsFileInputResult = TagsFileInputSchema.validate(yamlContent);
|
|
85
|
+
if (tagsFileInputResult.error) {
|
|
86
|
+
throw new Error(`There was an error extracting tags from file: ${tagsFileInputResult.error.message}`, { cause: tagsFileInputResult });
|
|
87
|
+
}
|
|
88
|
+
const tagsFile = normalizeTagsFile(tagsFileInputResult.value);
|
|
89
|
+
ensureUniquePermalinks(tagsFile);
|
|
90
|
+
return tagsFile;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=tagsFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagsFile.js","sourceRoot":"","sources":["../src/tagsFile.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAwBH,wDAqBC;AAED,8CAQC;AASD,0DAYC;AAED,kCA+CC;;AA3HD,gEAA0B;AAC1B,kEAA6B;AAC7B,4DAAuB;AACvB,sDAAsB;AACtB,8DAA2B;AAC3B,6CAAsE;AAQtE,MAAM,mBAAmB,GAAG,aAAG,CAAC,MAAM,EAAiB,CAAC,OAAO,CAC7D,aAAG,CAAC,MAAM,EAAE,EACZ,aAAG,CAAC,MAAM,CAAC;IACT,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE;IACzB,SAAS,EAAE,aAAG,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CACf,CAAC;AAEF,SAAgB,sBAAsB,CAAC,IAAc;IACnD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM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AK,EAAE,mBAAmB,EAAC,CAC7B,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC9D,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEjC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -8,6 +8,7 @@ import Joi from './Joi';
|
|
|
8
8
|
export declare const PluginIdSchema: Joi.StringSchema<string>;
|
|
9
9
|
export declare const RemarkPluginsSchema: Joi.ArraySchema<any[]>;
|
|
10
10
|
export declare const RehypePluginsSchema: Joi.ArraySchema<any[]>;
|
|
11
|
+
export declare const RecmaPluginsSchema: Joi.ArraySchema<any[]>;
|
|
11
12
|
export declare const AdmonitionsSchema: Joi.AlternativesSchema<any>;
|
|
12
13
|
export declare const URISchema: Joi.AlternativesSchema<any>;
|
|
13
14
|
export declare const PathnameSchema: Joi.StringSchema<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationSchemas.d.ts","sourceRoot":"","sources":["../src/validationSchemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"validationSchemas.d.ts","sourceRoot":"","sources":["../src/validationSchemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,GAAG,MAAM,OAAO,CAAC;AAGxB,eAAO,MAAM,cAAc,0BAKE,CAAC;AAe9B,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AAExD,eAAO,MAAM,iBAAiB,6BAqB1B,CAAC;AAIL,eAAO,MAAM,SAAS,6BAmBpB,CAAC;AAEH,eAAO,MAAM,cAAc,0BASxB,CAAC;AAaJ,eAAO,MAAM,mBAAmB,6BAO7B,CAAC;AAiBJ,eAAO,MAAM,qBAAqB,wBAK9B,CAAC;AAEL,eAAO,MAAM,2BAA2B;;;CASvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,uBAAuB,qCAgBxB,CAAC;AAEb,eAAO,MAAM,iCAAiC,sIACuF,CAAC;AAEtI,eAAO,MAAM,2BAA2B,uBAQpC,CAAC"}
|
package/lib/validationSchemas.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.FrontMatterLastUpdateSchema = exports.FrontMatterLastUpdateErrorMessage = exports.ContentVisibilitySchema = exports.FrontMatterTOCHeadingLevels = exports.FrontMatterTagsSchema = exports.RouteBasePathSchema = exports.PathnameSchema = exports.URISchema = exports.AdmonitionsSchema = exports.RehypePluginsSchema = exports.RemarkPluginsSchema = exports.PluginIdSchema = void 0;
|
|
9
|
+
exports.FrontMatterLastUpdateSchema = exports.FrontMatterLastUpdateErrorMessage = exports.ContentVisibilitySchema = exports.FrontMatterTOCHeadingLevels = exports.FrontMatterTagsSchema = exports.RouteBasePathSchema = exports.PathnameSchema = exports.URISchema = exports.AdmonitionsSchema = exports.RecmaPluginsSchema = exports.RehypePluginsSchema = exports.RemarkPluginsSchema = exports.PluginIdSchema = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
@@ -26,6 +26,7 @@ const MarkdownPluginsSchema = Joi_1.default.array()
|
|
|
26
26
|
.default([]);
|
|
27
27
|
exports.RemarkPluginsSchema = MarkdownPluginsSchema;
|
|
28
28
|
exports.RehypePluginsSchema = MarkdownPluginsSchema;
|
|
29
|
+
exports.RecmaPluginsSchema = MarkdownPluginsSchema;
|
|
29
30
|
exports.AdmonitionsSchema = JoiFrontMatter_1.JoiFrontMatter.alternatives()
|
|
30
31
|
.try(JoiFrontMatter_1.JoiFrontMatter.boolean().required(), JoiFrontMatter_1.JoiFrontMatter.object({
|
|
31
32
|
keywords: JoiFrontMatter_1.JoiFrontMatter.array().items(JoiFrontMatter_1.JoiFrontMatter.string()),
|
|
@@ -86,7 +87,10 @@ exports.RouteBasePathSchema = Joi_1.default
|
|
|
86
87
|
// /!\ do not add trailing slash here
|
|
87
88
|
(0, utils_common_1.addLeadingSlash)(value));
|
|
88
89
|
const FrontMatterTagSchema = JoiFrontMatter_1.JoiFrontMatter.alternatives()
|
|
89
|
-
.try(JoiFrontMatter_1.JoiFrontMatter.string().required(),
|
|
90
|
+
.try(JoiFrontMatter_1.JoiFrontMatter.string().required(),
|
|
91
|
+
// TODO Docusaurus v4 remove this legacy front matter tag object form
|
|
92
|
+
// users should use tags.yml instead
|
|
93
|
+
JoiFrontMatter_1.JoiFrontMatter.object({
|
|
90
94
|
label: JoiFrontMatter_1.JoiFrontMatter.string().required(),
|
|
91
95
|
permalink: JoiFrontMatter_1.JoiFrontMatter.string().required(),
|
|
92
96
|
}).required())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationSchemas.js","sourceRoot":"","sources":["../src/validationSchemas.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"validationSchemas.js","sourceRoot":"","sources":["../src/validationSchemas.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,6CAI2B;AAC3B,2DAAyD;AACzD,wDAAwB;AACxB,qDAAgD;AAEnC,QAAA,cAAc,GAAG,aAAG,CAAC,MAAM,EAAE;KACvC,KAAK,CAAC,UAAU,CAAC;KACjB,OAAO,CACN,oGAAoG,CACrG;KACA,OAAO,CAAC,yBAAiB,CAAC,CAAC;AAE9B,MAAM,qBAAqB,GAAG,aAAG,CAAC,KAAK,EAAE;KACtC,KAAK,CACJ,aAAG,CAAC,KAAK,EAAE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,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;KACD,QAAQ,CAAC;IACR,mCAAmC,EACjC,+CAA+C;CAClD,CAAC;KACD,OAAO,EAAE,CAAC;AAEA,QAAA,iCAAiC,GAC5C,mIAAmI,CAAC;AAEzH,QAAA,2BAA2B,GAAG,aAAG,CAAC,MAAM,CAAC;IACpD,MAAM,EAAE,aAAG,CAAC,MAAM,EAAE;IACpB,IAAI,EAAE,aAAG,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE;CACvB,CAAC;KACC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;KACpB,QAAQ,CAAC;IACR,gBAAgB,EAAE,yCAAiC;IACnD,aAAa,EAAE,yCAAiC;CACjD,CAAC,CAAC"}
|
package/lib/validationUtils.js
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.printWarning = printWarning;
|
|
10
|
+
exports.normalizePluginOptions = normalizePluginOptions;
|
|
11
|
+
exports.normalizeThemeConfig = normalizeThemeConfig;
|
|
12
|
+
exports.validateFrontMatter = validateFrontMatter;
|
|
10
13
|
const tslib_1 = require("tslib");
|
|
11
14
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
15
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
@@ -20,7 +23,6 @@ function printWarning(warning) {
|
|
|
20
23
|
logger_1.default.warn(warningMessages);
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
|
-
exports.printWarning = printWarning;
|
|
24
26
|
/**
|
|
25
27
|
* The callback that should be used to validate plugin options. Handles plugin
|
|
26
28
|
* IDs on a generic level: no matter what the schema declares, this callback
|
|
@@ -43,7 +45,6 @@ options = {}) {
|
|
|
43
45
|
}
|
|
44
46
|
return value;
|
|
45
47
|
}
|
|
46
|
-
exports.normalizePluginOptions = normalizePluginOptions;
|
|
47
48
|
/**
|
|
48
49
|
* The callback that should be used to validate theme config. No matter what the
|
|
49
50
|
* schema declares, this callback would allow unknown attributes.
|
|
@@ -62,7 +63,6 @@ function normalizeThemeConfig(schema, themeConfig) {
|
|
|
62
63
|
}
|
|
63
64
|
return value;
|
|
64
65
|
}
|
|
65
|
-
exports.normalizeThemeConfig = normalizeThemeConfig;
|
|
66
66
|
/**
|
|
67
67
|
* Validate front matter with better error message
|
|
68
68
|
*/
|
|
@@ -87,5 +87,4 @@ ${errorDetails.map(({ message }) => message)}
|
|
|
87
87
|
}
|
|
88
88
|
return value;
|
|
89
89
|
}
|
|
90
|
-
exports.validateFrontMatter = validateFrontMatter;
|
|
91
90
|
//# sourceMappingURL=validationUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationUtils.js","sourceRoot":"","sources":["../src/validationUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"validationUtils.js","sourceRoot":"","sources":["../src/validationUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AASH,oCAOC;AAOD,wDAqBC;AAMD,oDAmBC;AAKD,kDA4BC;;AApGD,wEAAwC;AACxC,8DAA2B;AAC3B,2DAAmD;AAInD,mDAAmD;AACnD,SAAgB,YAAY,CAAC,OAA6B;IACxD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO;aACpC,GAAG,CAAC,CAAC,EAAC,OAAO,EAAC,EAAE,EAAE,CAAC,OAAO,CAAC;aAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,gBAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,MAA2B;AAC3B,2EAA2E;AAC3E,UA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ACnC,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEpE,gBAAM,CAAC,KAAK,CAAA;;EAEd,iBAAI,CAAC,IAAI,CAAC,WAAW,CAAC;6CACqB,aAAa;EACxD,YAAY,CAAC,GAAG,CAAC,CAAC,EAAC,OAAO,EAAC,EAAE,EAAE,CAAC,OAAO,CAAC;CACzC,CAAC;QACE,MAAM,KAAK,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils-validation",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Node validation utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,15 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "3.
|
|
22
|
-
"@docusaurus/utils": "3.
|
|
23
|
-
"@docusaurus/utils-common": "3.
|
|
21
|
+
"@docusaurus/logger": "3.5.0",
|
|
22
|
+
"@docusaurus/utils": "3.5.0",
|
|
23
|
+
"@docusaurus/utils-common": "3.5.0",
|
|
24
|
+
"fs-extra": "^11.2.0",
|
|
24
25
|
"joi": "^17.9.2",
|
|
25
26
|
"js-yaml": "^4.1.0",
|
|
27
|
+
"lodash": "^4.17.21",
|
|
26
28
|
"tslib": "^2.6.0"
|
|
27
29
|
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"tmp-promise": "^3.0.3"
|
|
32
|
+
},
|
|
28
33
|
"engines": {
|
|
29
34
|
"node": ">=18.0"
|
|
30
35
|
},
|
|
31
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "cb5829f3c34b26d798b869e38ee25073488140bd"
|
|
32
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export {
|
|
|
19
19
|
PluginIdSchema,
|
|
20
20
|
RemarkPluginsSchema,
|
|
21
21
|
RehypePluginsSchema,
|
|
22
|
+
RecmaPluginsSchema,
|
|
22
23
|
AdmonitionsSchema,
|
|
23
24
|
RouteBasePathSchema,
|
|
24
25
|
URISchema,
|
|
@@ -29,3 +30,4 @@ export {
|
|
|
29
30
|
FrontMatterLastUpdateErrorMessage,
|
|
30
31
|
FrontMatterLastUpdateSchema,
|
|
31
32
|
} from './validationSchemas';
|
|
33
|
+
export {getTagsFilePathsToWatch, getTagsFile} from './tagsFile';
|
package/src/tagsFile.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs-extra';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import _ from 'lodash';
|
|
11
|
+
import Joi from 'joi';
|
|
12
|
+
import YAML from 'js-yaml';
|
|
13
|
+
import {getContentPathList, getDataFilePath} from '@docusaurus/utils';
|
|
14
|
+
import type {
|
|
15
|
+
ContentPaths,
|
|
16
|
+
TagsFile,
|
|
17
|
+
TagsFileInput,
|
|
18
|
+
TagsPluginOptions,
|
|
19
|
+
} from '@docusaurus/utils';
|
|
20
|
+
|
|
21
|
+
const TagsFileInputSchema = Joi.object<TagsFileInput>().pattern(
|
|
22
|
+
Joi.string(),
|
|
23
|
+
Joi.object({
|
|
24
|
+
label: Joi.string(),
|
|
25
|
+
description: Joi.string(),
|
|
26
|
+
permalink: Joi.string(),
|
|
27
|
+
}).allow(null),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export function ensureUniquePermalinks(tags: TagsFile): void {
|
|
31
|
+
const permalinks = new Set<string>();
|
|
32
|
+
const duplicates = new Set<string>();
|
|
33
|
+
|
|
34
|
+
for (const [, tag] of Object.entries(tags)) {
|
|
35
|
+
const {permalink} = tag;
|
|
36
|
+
if (permalinks.has(permalink)) {
|
|
37
|
+
duplicates.add(permalink);
|
|
38
|
+
} else {
|
|
39
|
+
permalinks.add(permalink);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (duplicates.size > 0) {
|
|
44
|
+
const duplicateList = Array.from(duplicates)
|
|
45
|
+
.map((permalink) => ` - ${permalink}`)
|
|
46
|
+
.join('\n');
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Duplicate permalinks found in tags file:\n${duplicateList}`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function normalizeTagsFile(data: TagsFileInput): TagsFile {
|
|
54
|
+
return _.mapValues(data, (tag, key) => {
|
|
55
|
+
return {
|
|
56
|
+
label: tag?.label || _.capitalize(key),
|
|
57
|
+
description: tag?.description,
|
|
58
|
+
permalink: tag?.permalink || `/${_.kebabCase(key)}`,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type GetTagsFileParams = {
|
|
64
|
+
tags: TagsPluginOptions['tags'];
|
|
65
|
+
contentPaths: ContentPaths;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const DefaultTagsFileName = 'tags.yml';
|
|
69
|
+
|
|
70
|
+
export function getTagsFilePathsToWatch({
|
|
71
|
+
tags,
|
|
72
|
+
contentPaths,
|
|
73
|
+
}: GetTagsFileParams): string[] {
|
|
74
|
+
if (tags === false || tags === null) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
const relativeFilePath = tags ?? DefaultTagsFileName;
|
|
78
|
+
|
|
79
|
+
return getContentPathList(contentPaths).map((contentPath) =>
|
|
80
|
+
path.posix.join(contentPath, relativeFilePath),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function getTagsFile({
|
|
85
|
+
tags,
|
|
86
|
+
contentPaths,
|
|
87
|
+
}: GetTagsFileParams): Promise<TagsFile | null> {
|
|
88
|
+
if (tags === false || tags === null) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const relativeFilePath = tags ?? DefaultTagsFileName;
|
|
93
|
+
|
|
94
|
+
// if returned path is defined, the file exists (localized or not)
|
|
95
|
+
const yamlFilePath = await getDataFilePath({
|
|
96
|
+
contentPaths,
|
|
97
|
+
filePath: relativeFilePath,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// If the tags option is undefined, don't throw when the file does not exist
|
|
101
|
+
// Retro-compatible behavior: existing sites do not yet have tags.yml
|
|
102
|
+
if (tags === undefined && !yamlFilePath) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
if (!yamlFilePath) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
`No tags file '${relativeFilePath}' could be found in any of those directories:\n- ${getContentPathList(
|
|
108
|
+
contentPaths,
|
|
109
|
+
).join('\n- ')}`,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const tagDefinitionContent = await fs.readFile(yamlFilePath, 'utf-8');
|
|
114
|
+
if (!tagDefinitionContent.trim()) {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const yamlContent = YAML.load(tagDefinitionContent);
|
|
119
|
+
const tagsFileInputResult = TagsFileInputSchema.validate(yamlContent);
|
|
120
|
+
if (tagsFileInputResult.error) {
|
|
121
|
+
throw new Error(
|
|
122
|
+
`There was an error extracting tags from file: ${tagsFileInputResult.error.message}`,
|
|
123
|
+
{cause: tagsFileInputResult},
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const tagsFile = normalizeTagsFile(tagsFileInputResult.value);
|
|
128
|
+
ensureUniquePermalinks(tagsFile);
|
|
129
|
+
|
|
130
|
+
return tagsFile;
|
|
131
|
+
}
|
package/src/validationSchemas.ts
CHANGED
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
isValidPathname,
|
|
10
|
+
DEFAULT_PLUGIN_ID,
|
|
11
|
+
type FrontMatterTag,
|
|
12
|
+
} from '@docusaurus/utils';
|
|
9
13
|
import {addLeadingSlash} from '@docusaurus/utils-common';
|
|
10
14
|
import Joi from './Joi';
|
|
11
15
|
import {JoiFrontMatter} from './JoiFrontMatter';
|
|
@@ -32,6 +36,7 @@ const MarkdownPluginsSchema = Joi.array()
|
|
|
32
36
|
|
|
33
37
|
export const RemarkPluginsSchema = MarkdownPluginsSchema;
|
|
34
38
|
export const RehypePluginsSchema = MarkdownPluginsSchema;
|
|
39
|
+
export const RecmaPluginsSchema = MarkdownPluginsSchema;
|
|
35
40
|
|
|
36
41
|
export const AdmonitionsSchema = JoiFrontMatter.alternatives()
|
|
37
42
|
.try(
|
|
@@ -113,7 +118,9 @@ export const RouteBasePathSchema = Joi
|
|
|
113
118
|
const FrontMatterTagSchema = JoiFrontMatter.alternatives()
|
|
114
119
|
.try(
|
|
115
120
|
JoiFrontMatter.string().required(),
|
|
116
|
-
|
|
121
|
+
// TODO Docusaurus v4 remove this legacy front matter tag object form
|
|
122
|
+
// users should use tags.yml instead
|
|
123
|
+
JoiFrontMatter.object<FrontMatterTag>({
|
|
117
124
|
label: JoiFrontMatter.string().required(),
|
|
118
125
|
permalink: JoiFrontMatter.string().required(),
|
|
119
126
|
}).required(),
|