@common-stack/rollup-vite-utils 6.0.6-alpha.5 → 6.0.6-alpha.52
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/config-schema.cjs +111 -0
- package/lib/config-schema.cjs.map +1 -0
- package/lib/config-schema.js +111 -0
- package/lib/config-schema.js.map +1 -0
- package/lib/default-config.json.cjs +2 -2
- package/lib/default-config.json.js +2 -2
- package/lib/index.cjs +1 -1
- package/lib/index.js +1 -1
- package/lib/interfaces/types.cjs +6 -0
- package/lib/interfaces/types.cjs.map +1 -0
- package/lib/interfaces/types.d.ts +41 -24
- package/lib/interfaces/types.js +6 -0
- package/lib/interfaces/types.js.map +1 -0
- package/lib/preStartup/configLoader/index.cjs +1 -1
- package/lib/preStartup/configLoader/index.cjs.map +1 -1
- package/lib/preStartup/configLoader/index.js +1 -1
- package/lib/preStartup/configLoader/index.js.map +1 -1
- package/lib/preStartup/copyIfVersionChanged.cjs +1 -1
- package/lib/preStartup/copyIfVersionChanged.cjs.map +1 -1
- package/lib/preStartup/copyIfVersionChanged.js +1 -1
- package/lib/preStartup/copyIfVersionChanged.js.map +1 -1
- package/lib/rollup/index.d.ts +1 -0
- package/lib/rollup/modifyLibFiles/extractGraphQLQueries.cjs +1 -1
- package/lib/rollup/modifyLibFiles/extractGraphQLQueries.cjs.map +1 -1
- package/lib/rollup/modifyLibFiles/extractGraphQLQueries.js +1 -1
- package/lib/rollup/modifyLibFiles/extractGraphQLQueries.js.map +1 -1
- package/lib/rollup/modifyLibFiles/handleComponentOrDialog.cjs +212 -110
- package/lib/rollup/modifyLibFiles/handleComponentOrDialog.cjs.map +1 -1
- package/lib/rollup/modifyLibFiles/handleComponentOrDialog.d.ts +41 -0
- package/lib/rollup/modifyLibFiles/handleComponentOrDialog.js +212 -110
- package/lib/rollup/modifyLibFiles/handleComponentOrDialog.js.map +1 -1
- package/lib/rollup/modifyLibFiles/handleImportPaths.cjs +4 -3
- package/lib/rollup/modifyLibFiles/handleImportPaths.cjs.map +1 -1
- package/lib/rollup/modifyLibFiles/handleImportPaths.js +4 -3
- package/lib/rollup/modifyLibFiles/handleImportPaths.js.map +1 -1
- package/lib/rollup/modifyLibFiles/utils.cjs +7 -7
- package/lib/rollup/modifyLibFiles/utils.cjs.map +1 -1
- package/lib/rollup/modifyLibFiles/utils.d.ts +1 -1
- package/lib/rollup/modifyLibFiles/utils.js +7 -7
- package/lib/rollup/modifyLibFiles/utils.js.map +1 -1
- package/lib/rollup/rollupPluginGenerateJson.cjs +2 -3
- package/lib/rollup/rollupPluginGenerateJson.cjs.map +1 -1
- package/lib/rollup/rollupPluginGenerateJson.js +2 -3
- package/lib/rollup/rollupPluginGenerateJson.js.map +1 -1
- package/lib/rollup/rollupPluginModifyLibFiles.cjs +25 -14
- package/lib/rollup/rollupPluginModifyLibFiles.cjs.map +1 -1
- package/lib/rollup/rollupPluginModifyLibFiles.js +25 -14
- package/lib/rollup/rollupPluginModifyLibFiles.js.map +1 -1
- package/lib/rollup/rollupPluginUpdateFromConfig.cjs +122 -0
- package/lib/rollup/rollupPluginUpdateFromConfig.cjs.map +1 -0
- package/lib/rollup/rollupPluginUpdateFromConfig.d.ts +1 -0
- package/lib/rollup/rollupPluginUpdateFromConfig.js +122 -0
- package/lib/rollup/rollupPluginUpdateFromConfig.js.map +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/parseUtility.d.ts +3 -0
- package/lib/utils/verifyConfig.cjs +13 -0
- package/lib/utils/verifyConfig.cjs.map +1 -0
- package/lib/utils/verifyConfig.d.ts +2 -0
- package/lib/utils/verifyConfig.js +13 -0
- package/lib/utils/verifyConfig.js.map +1 -0
- package/lib/utils/withErrorHandleUtil.cjs +3 -7
- package/lib/utils/withErrorHandleUtil.cjs.map +1 -1
- package/lib/utils/withErrorHandleUtil.js +3 -7
- package/lib/utils/withErrorHandleUtil.js.map +1 -1
- package/lib/vite-wrappers/custom-routes.cjs +43 -0
- package/lib/vite-wrappers/custom-routes.cjs.map +1 -0
- package/lib/vite-wrappers/custom-routes.d.ts +2 -0
- package/lib/vite-wrappers/custom-routes.js +43 -0
- package/lib/vite-wrappers/custom-routes.js.map +1 -0
- package/lib/vite-wrappers/generators/clientLoaderGenerator.cjs +149 -0
- package/lib/vite-wrappers/generators/clientLoaderGenerator.cjs.map +1 -0
- package/lib/vite-wrappers/generators/clientLoaderGenerator.d.ts +17 -0
- package/lib/vite-wrappers/generators/clientLoaderGenerator.js +149 -0
- package/lib/vite-wrappers/generators/clientLoaderGenerator.js.map +1 -0
- package/lib/vite-wrappers/generators/clientLoaderGenerator.test.d.ts +1 -0
- package/lib/vite-wrappers/generators/generateHasConfiguration.cjs +20 -0
- package/lib/vite-wrappers/generators/generateHasConfiguration.cjs.map +1 -0
- package/lib/vite-wrappers/generators/generateHasConfiguration.d.ts +10 -0
- package/lib/vite-wrappers/generators/generateHasConfiguration.js +20 -0
- package/lib/vite-wrappers/generators/generateHasConfiguration.js.map +1 -0
- package/lib/vite-wrappers/generators/generateHasPermission.cjs +29 -0
- package/lib/vite-wrappers/generators/generateHasPermission.cjs.map +1 -0
- package/lib/vite-wrappers/generators/generateHasPermission.d.ts +9 -0
- package/lib/vite-wrappers/generators/generateHasPermission.js +29 -0
- package/lib/vite-wrappers/generators/generateHasPermission.js.map +1 -0
- package/lib/vite-wrappers/generators/generateHasPermission.test.d.ts +1 -0
- package/lib/vite-wrappers/generators/loaderGenerator.cjs +197 -0
- package/lib/vite-wrappers/generators/loaderGenerator.cjs.map +1 -0
- package/lib/vite-wrappers/generators/loaderGenerator.d.ts +44 -0
- package/lib/vite-wrappers/{loaderGenerator.js → generators/loaderGenerator.js} +74 -122
- package/lib/vite-wrappers/generators/loaderGenerator.js.map +1 -0
- package/lib/vite-wrappers/generators/loaderGenerator.test.d.ts +1 -0
- package/lib/vite-wrappers/generators/utils/pickConfig.cjs +16 -0
- package/lib/vite-wrappers/generators/utils/pickConfig.cjs.map +1 -0
- package/lib/vite-wrappers/generators/utils/pickConfig.d.ts +10 -0
- package/lib/vite-wrappers/generators/utils/pickConfig.js +16 -0
- package/lib/vite-wrappers/generators/utils/pickConfig.js.map +1 -0
- package/lib/vite-wrappers/generators/utils/resourceParams.cjs +36 -0
- package/lib/vite-wrappers/generators/utils/resourceParams.cjs.map +1 -0
- package/lib/vite-wrappers/generators/utils/resourceParams.d.ts +11 -0
- package/lib/vite-wrappers/generators/utils/resourceParams.js +36 -0
- package/lib/vite-wrappers/generators/utils/resourceParams.js.map +1 -0
- package/lib/vite-wrappers/icon-switch.cjs +4 -4
- package/lib/vite-wrappers/icon-switch.cjs.map +1 -1
- package/lib/vite-wrappers/icon-switch.d.ts +1 -1
- package/lib/vite-wrappers/icon-switch.js +4 -4
- package/lib/vite-wrappers/icon-switch.js.map +1 -1
- package/lib/vite-wrappers/index.d.ts +3 -0
- package/lib/vite-wrappers/json-wrappers.cjs +103 -14
- package/lib/vite-wrappers/json-wrappers.cjs.map +1 -1
- package/lib/vite-wrappers/json-wrappers.d.ts +33 -0
- package/lib/vite-wrappers/json-wrappers.js +103 -14
- package/lib/vite-wrappers/json-wrappers.js.map +1 -1
- package/lib/vite-wrappers/wrapperComponent.cjs +190 -125
- package/lib/vite-wrappers/wrapperComponent.cjs.map +1 -1
- package/lib/vite-wrappers/wrapperComponent.d.ts +9 -0
- package/lib/vite-wrappers/wrapperComponent.js +190 -125
- package/lib/vite-wrappers/wrapperComponent.js.map +1 -1
- package/package.json +7 -5
- package/lib/vite-wrappers/loaderGenerator.cjs +0 -245
- package/lib/vite-wrappers/loaderGenerator.cjs.map +0 -1
- package/lib/vite-wrappers/loaderGenerator.d.ts +0 -18
- package/lib/vite-wrappers/loaderGenerator.js.map +0 -1
- /package/lib/{vite-wrappers/loaderGenerator.test.d.ts → rollup/modifyLibFiles/handleComponentOrDialog.test.d.ts} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively process the resourceParams object and replace any placeholder values starting with `$params.`.
|
|
3
|
+
* If the `path` is empty or matches `IConfigCollectionName.Organization`, ensure it provides a default query
|
|
4
|
+
* with `{ name: $params.orgName }`.
|
|
5
|
+
*
|
|
6
|
+
* @param resourceParams - The nested resourceParams object containing placeholders.
|
|
7
|
+
* @param params - The params object from which values are extracted.
|
|
8
|
+
* @param defaultPath - Optional default path to be assigned when `path` is empty or a specific condition is met.
|
|
9
|
+
* @returns The processed resourceParams object with replaced values.
|
|
10
|
+
*/
|
|
11
|
+
function resolveResourceParamsPlaceholders(resourceParams, params, defaultPath = 'IConfigCollectionName.Organization') {
|
|
12
|
+
if (!resourceParams || typeof resourceParams !== 'object')
|
|
13
|
+
return resourceParams;
|
|
14
|
+
const resolvedParams = {};
|
|
15
|
+
Object.entries(resourceParams).forEach(([key, value]) => {
|
|
16
|
+
if (typeof value === 'string' && value.startsWith('$params.')) {
|
|
17
|
+
// Replace placeholder with actual value from params
|
|
18
|
+
const paramKey = value.split('$params.')[1];
|
|
19
|
+
resolvedParams[key] = params[paramKey];
|
|
20
|
+
}
|
|
21
|
+
else if (typeof value === 'object' && value !== null) {
|
|
22
|
+
// Recursively resolve nested objects
|
|
23
|
+
resolvedParams[key] = resolveResourceParamsPlaceholders(value, params, defaultPath);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Direct assignment for other values
|
|
27
|
+
resolvedParams[key] = value;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
// If the path is missing or matches `IConfigCollectionName.Organization`, ensure query is set
|
|
31
|
+
if (!resolvedParams.path || resolvedParams.path === defaultPath) {
|
|
32
|
+
resolvedParams.path = defaultPath;
|
|
33
|
+
resolvedParams.query = { name: params.orgName }; // Assuming `orgName` exists in params
|
|
34
|
+
}
|
|
35
|
+
return resolvedParams;
|
|
36
|
+
}export{resolveResourceParamsPlaceholders};//# sourceMappingURL=resourceParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceParams.js","sources":["../../../../src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('path'),wrapperComponent=require('./wrapperComponent.cjs'),utils=require('../utils/utils.cjs');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var fs__namespace=/*#__PURE__*/_interopNamespaceDefault(fs);var path__namespace=/*#__PURE__*/_interopNamespaceDefault(path);function writeIconsSwitch(names, svgPaths, files,
|
|
1
|
+
'use strict';var fs=require('fs'),path=require('path'),wrapperComponent=require('./wrapperComponent.cjs'),utils=require('../utils/utils.cjs');require('ajv');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var fs__namespace=/*#__PURE__*/_interopNamespaceDefault(fs);var path__namespace=/*#__PURE__*/_interopNamespaceDefault(path);function writeIconsSwitch(names, svgPaths, files, iconsRepository) {
|
|
2
2
|
copySVGFiles(svgPaths);
|
|
3
3
|
let content = `
|
|
4
4
|
function __variableDynamicIcon(icon) {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
if (name.includes('.')) {
|
|
10
10
|
[prefix, iconName] = name.split('.');
|
|
11
11
|
}
|
|
12
|
-
if (prefix &&
|
|
13
|
-
const importPath =
|
|
14
|
-
prefix = prefix.charAt(0).toUpperCase() + prefix.slice(1).toLowerCase();
|
|
12
|
+
if (prefix && iconsRepository[prefix]) {
|
|
13
|
+
const importPath = iconsRepository[prefix].replace('{iconName}', iconName);
|
|
14
|
+
// prefix = prefix.charAt(0).toUpperCase() + prefix.slice(1).toLowerCase();
|
|
15
15
|
content += `
|
|
16
16
|
case '${prefix + "." + iconName}':
|
|
17
17
|
return import('${importPath}');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-switch.cjs","sources":["../../src/vite-wrappers/icon-switch.ts"],"sourcesContent":[null],"names":["path","fs","getRootPath","findPackageDir"],"mappings":"
|
|
1
|
+
{"version":3,"file":"icon-switch.cjs","sources":["../../src/vite-wrappers/icon-switch.ts"],"sourcesContent":[null],"names":["path","fs","getRootPath","findPackageDir"],"mappings":"ujBAKM,SAAU,gBAAgB,CAAC,KAAe,EAAE,QAAkB,EAAE,KAAe,EAAE,eAAmB,EAAA;IACxG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEvB,IAAA,IAAI,OAAO,GAAG,CAAA;;;CAGf,CAAC;AACA,IAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;QACrB,IAAI,MAAM,EAAE,QAAQ,CAAC;AACrB,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACpB,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACxC;AACD,QAAA,IAAI,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE;AACnC,YAAA,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;;AAE3E,YAAA,OAAO,IAAI,CAAA;YACP,MAAM,GAAC,GAAG,GAAC,QAAQ,CAAA;yBACN,UAAU,CAAA;KAC9B,CAAC;SACO;aAAM;AACH,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACnD,YAAA,OAAO,IAAI,CAAA;YACf,IAAI,CAAA;AACgC,8CAAA,EAAA,KAAK,IAAI,IAAI,CAAA;KACxD,CAAC;SACO;AACX,KAAC,CAAC,CAAC;AACH,IAAA,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;QAC3B,MAAM,WAAW,GAAGA,eAAI,CAAC,QAA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O,GAAGD,eAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,GAAG,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;qBAC5F;iBACF;gBACD,IAAI,CAACC,aAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;AAC3B,oBAAA,OAAO,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAA,CAAA,CAAG,CAAC,CAAC;iBACrD;qBAAM;oBACL,MAAM,WAAW,GAAGD,eAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBAC3C,MAAM,QAAQ,GAAGA,eAAI,CAAC,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACpD,oBAAAC,aAAE,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBACnC,OAAO,CAAC,GAAG,CAAC,CAAA,qBAAA,EAAwB,OAAO,CAAO,IAAA,EAAA,QAAQ,CAAG,CAAA,CAAA,CAAC,CAAC;iBAChE;aACF;SACF;AACH,KAAC,CAAC,CAAC;AACL"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function writeIconsSwitch(names: string[], svgPaths: string[], files: string[],
|
|
1
|
+
export declare function writeIconsSwitch(names: string[], svgPaths: string[], files: string[], iconsRepository: any): void;
|
|
2
2
|
export declare function getPackageName(filePath: any): any;
|
|
3
3
|
export declare function copySVGFiles(svgPaths: string[]): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as fs from'fs';import*as path from'path';import {getRootPath}from'./wrapperComponent.js';import {findPackageDir}from'../utils/utils.js';function writeIconsSwitch(names, svgPaths, files,
|
|
1
|
+
import*as fs from'fs';import*as path from'path';import {getRootPath}from'./wrapperComponent.js';import {findPackageDir}from'../utils/utils.js';import'ajv';function writeIconsSwitch(names, svgPaths, files, iconsRepository) {
|
|
2
2
|
copySVGFiles(svgPaths);
|
|
3
3
|
let content = `
|
|
4
4
|
function __variableDynamicIcon(icon) {
|
|
@@ -9,9 +9,9 @@ import*as fs from'fs';import*as path from'path';import {getRootPath}from'./wrapp
|
|
|
9
9
|
if (name.includes('.')) {
|
|
10
10
|
[prefix, iconName] = name.split('.');
|
|
11
11
|
}
|
|
12
|
-
if (prefix &&
|
|
13
|
-
const importPath =
|
|
14
|
-
prefix = prefix.charAt(0).toUpperCase() + prefix.slice(1).toLowerCase();
|
|
12
|
+
if (prefix && iconsRepository[prefix]) {
|
|
13
|
+
const importPath = iconsRepository[prefix].replace('{iconName}', iconName);
|
|
14
|
+
// prefix = prefix.charAt(0).toUpperCase() + prefix.slice(1).toLowerCase();
|
|
15
15
|
content += `
|
|
16
16
|
case '${prefix + "." + iconName}':
|
|
17
17
|
return import('${importPath}');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-switch.js","sources":["../../src/vite-wrappers/icon-switch.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"icon-switch.js","sources":["../../src/vite-wrappers/icon-switch.ts"],"sourcesContent":[null],"names":[],"mappings":"2JAKM,SAAU,gBAAgB,CAAC,KAAe,EAAE,QAAkB,EAAE,KAAe,EAAE,eAAmB,EAAA;IACxG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEvB,IAAA,IAAI,OAAO,GAAG,CAAA;;;CAGf,CAAC;AACA,IAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;QACrB,IAAI,MAAM,EAAE,QAAQ,CAAC;AACrB,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACpB,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACxC;AACD,QAAA,IAAI,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE;AACnC,YAAA,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE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glob-all'),lodashEs=require('lodash-es'),node_crypto=require('node:crypto'),wrapperComponent=require('./wrapperComponent.cjs'),dialogWrapper=require('./dialog-wrapper.cjs'),iconSwitch=require('./icon-switch.cjs')
|
|
1
|
+
'use strict';var getRoutes_js=require('@common-stack/client-react/lib/route/get-routes.js'),fs=require('fs'),globAll=require('glob-all'),lodashEs=require('lodash-es'),node_crypto=require('node:crypto'),wrapperComponent=require('./wrapperComponent.cjs'),dialogWrapper=require('./dialog-wrapper.cjs'),iconSwitch=require('./icon-switch.cjs');/* eslint-disable jest/require-hook */
|
|
2
|
+
/* eslint-disable array-callback-return */
|
|
3
|
+
/**
|
|
4
|
+
* Generates a hash from the source string.
|
|
5
|
+
* Used to create unique route suffixes.
|
|
6
|
+
*
|
|
7
|
+
* @param source - The source string to hash.
|
|
8
|
+
* @param maxLength - The maximum length of the hash. Default is 8.
|
|
9
|
+
* @returns A substring of the generated SHA256 hash.
|
|
10
|
+
*/
|
|
11
|
+
const getHash = (source, maxLength = 8) => {
|
|
2
12
|
const hash = node_crypto.createHash('sha256').update(source).digest('hex');
|
|
3
13
|
return typeof maxLength === 'number' ? hash.slice(0, maxLength) : hash;
|
|
4
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the directories containing files from specified packages.
|
|
17
|
+
* Searches for a specific file in the node_modules directories of the provided packages.
|
|
18
|
+
*
|
|
19
|
+
* @param packages - The list of package names to search in.
|
|
20
|
+
* @param fileName - The name of the file to search for.
|
|
21
|
+
* @param rootPath - Optional root path to start the search. Defaults to project root.
|
|
22
|
+
* @returns An array of directories where the specified file is found.
|
|
23
|
+
*/
|
|
5
24
|
function resolvePathsUsingPackages(packages, fileName, rootPath) {
|
|
6
25
|
const basePath = rootPath || wrapperComponent.getRootPath();
|
|
7
26
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
@@ -15,11 +34,26 @@ function resolvePathsUsingPackages(packages, fileName, rootPath) {
|
|
|
15
34
|
}, []);
|
|
16
35
|
return localesDirs;
|
|
17
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Custom merge function used to concatenate arrays when merging objects.
|
|
39
|
+
* Used when merging routes configurations.
|
|
40
|
+
*
|
|
41
|
+
* @param objValue - The existing value.
|
|
42
|
+
* @param srcValue - The new value to merge.
|
|
43
|
+
* @returns Concatenated array if objValue is an array, otherwise undefined.
|
|
44
|
+
*/
|
|
18
45
|
function customizer(objValue, srcValue) {
|
|
19
46
|
if (lodashEs.isArray(objValue)) {
|
|
20
47
|
return objValue.concat(srcValue);
|
|
21
48
|
}
|
|
22
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Loads the routes configuration from the specified packages and merges them.
|
|
52
|
+
* Returns the sorted and merged route configuration.
|
|
53
|
+
*
|
|
54
|
+
* @param options - The options containing package names and root path for route resolution.
|
|
55
|
+
* @returns The sorted routes configuration or null if no configuration is found.
|
|
56
|
+
*/
|
|
23
57
|
function loadRoutesConfig(options) {
|
|
24
58
|
const fileName = options.routesFileName || 'route.json';
|
|
25
59
|
const directories = resolvePathsUsingPackages(options.packages, fileName, options.rootPath);
|
|
@@ -35,15 +69,45 @@ function loadRoutesConfig(options) {
|
|
|
35
69
|
const result = content.length ? getRoutes_js.getSortedRoutes('/', Object.assign({}, ...content)) : null;
|
|
36
70
|
return result;
|
|
37
71
|
}
|
|
72
|
+
// Global variables to store dialog paths, icon names, and icon files.
|
|
38
73
|
let dialogPaths = [];
|
|
39
74
|
let iconNames = [];
|
|
40
75
|
let iconSvgPaths = [];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
const iconFiles = [];
|
|
77
|
+
/**
|
|
78
|
+
* Adds a unique icon name to the global iconNames array.
|
|
79
|
+
*
|
|
80
|
+
* @param icon - The icon name to add.
|
|
81
|
+
* @returns Null if the icon name is already in the array, otherwise adds the name.
|
|
82
|
+
*/
|
|
83
|
+
const addIconName = (icon) => (!iconNames.includes(icon) ? iconNames.push(icon) : null);
|
|
84
|
+
/**
|
|
85
|
+
* Adds a unique SVG path to the global iconSvgPaths array.
|
|
86
|
+
*
|
|
87
|
+
* @param icon - The SVG path to add.
|
|
88
|
+
* @returns Null if the SVG path is already in the array, otherwise adds the path.
|
|
89
|
+
*/
|
|
90
|
+
const addIconSvgPath = (icon) => (!iconSvgPaths.includes(icon) ? iconSvgPaths.push(icon) : null);
|
|
91
|
+
/**
|
|
92
|
+
* Adds a unique icon file path to the global iconFiles array.
|
|
93
|
+
*
|
|
94
|
+
* @param icon - The file path to add.
|
|
95
|
+
* @returns Null if the file path is already in the array, otherwise adds the path.
|
|
96
|
+
*/
|
|
97
|
+
const addIconFile = (icon) => (!iconFiles.includes(icon) ? iconFiles.push(icon) : null);
|
|
98
|
+
/**
|
|
99
|
+
* Defines a route and its associated settings based on the route configuration.
|
|
100
|
+
* Wraps the component with necessary middleware, permission, and client wrappers.
|
|
101
|
+
*
|
|
102
|
+
* @param routeFn - The route function to define a new route.
|
|
103
|
+
* @param jsonRoute - The JSON route configuration.
|
|
104
|
+
* @param metaJson - Metadata related to the route.
|
|
105
|
+
* @param settings - The application settings.
|
|
106
|
+
* @param paths - The paths configuration for various modules and components.
|
|
107
|
+
*/
|
|
45
108
|
function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
46
|
-
const { routes = null, relativePath: path, componentPath, clientOnly, dialogPath, isResourceRoute, auth = 'optional', hasLoader = false, hasAction = false, hasClientLoader = false, hasClientAction = false, hasComponent = false, hasErrorBoundary = false, hasLinks = false, hasMeta = false, hasHydrateFallback = false, hasShouldRevalidate = false, queryParamsGenerator = false, hasHandle = false, hasHeaders = false, wrapperPaths = [], middlewares = [], authority = [], extraPermissions = [], extraProps = {}, loaderReturnInfo = {}, queries = {}, clientMiddlewares = [], configurations = [], resourceUri, icon, ...rest } = jsonRoute;
|
|
109
|
+
const { routes = null, relativePath: path, componentPath, clientOnly, dialogPath, isResourceRoute, auth = 'optional', hasServerCode = false, hasLoader = false, hasAction = false, hasClientLoader = false, hasClientAction = false, hasComponent = false, hasErrorBoundary = false, hasLinks = false, hasMeta = false, hasHydrateFallback = false, hasShouldRevalidate = false, queryParamsGenerator = false, hasHandle = false, hasHeaders = false, wrapperPaths = [], middlewares = [], authority = [], authorityConfig = {}, extraPermissions = [], extraParams = {}, extraIcons = [], extraLink = [], extraProps = {}, loaderReturnInfo = {}, queries = {}, clientMiddlewares = [], configurations = [], resourceUri, icon, ...rest } = jsonRoute;
|
|
110
|
+
// Handle icons
|
|
47
111
|
if (icon) {
|
|
48
112
|
if (typeof icon === 'object') {
|
|
49
113
|
if (typeof icon.svgPath === 'string') {
|
|
@@ -60,19 +124,28 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
60
124
|
addIconName(icon);
|
|
61
125
|
}
|
|
62
126
|
}
|
|
127
|
+
// Handle extra icons if any
|
|
128
|
+
if (extraIcons?.length > 0) {
|
|
129
|
+
extraIcons?.map((icon) => {
|
|
130
|
+
if (typeof icon === 'string') {
|
|
131
|
+
addIconName(icon);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
console.warn(`Invalid icon type: ${typeof icon}`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// Handle dialog paths and component routes
|
|
63
139
|
if (dialogPath && !dialogPaths.includes(dialogPath)) {
|
|
64
140
|
dialogWrapper.dialogWrapperUtility(dialogPath, { path: rest.path });
|
|
65
141
|
dialogPaths.push(dialogPath);
|
|
66
142
|
}
|
|
67
143
|
else if (componentPath) {
|
|
68
144
|
if (clientOnly) {
|
|
69
|
-
wrapperPaths.push('$clientOnlyWrapper'); // Add a placeholder for
|
|
145
|
+
wrapperPaths.push('$clientOnlyWrapper'); // Add a placeholder for client-only wrapper
|
|
70
146
|
}
|
|
71
147
|
if (authority.length > 0) {
|
|
72
|
-
wrapperPaths.push('$
|
|
73
|
-
}
|
|
74
|
-
if (configurations.length > 0 && resourceUri) {
|
|
75
|
-
wrapperPaths.push('$configurationWrapper'); // Add a placeholder for the permission wrapper at last
|
|
148
|
+
wrapperPaths.push('$configPermissionWrapper'); // Add a placeholder for permission wrapper
|
|
76
149
|
}
|
|
77
150
|
const requireAuth = !!auth;
|
|
78
151
|
const options = {
|
|
@@ -83,6 +156,7 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
83
156
|
hasAction: settings.disableAction !== true && hasAction,
|
|
84
157
|
hasClientLoader: settings.disableClientLoader !== true && hasClientLoader,
|
|
85
158
|
hasComponent,
|
|
159
|
+
hasServerCode,
|
|
86
160
|
hasErrorBoundary: settings.disableErrorBoundary !== true && hasErrorBoundary,
|
|
87
161
|
hasLinks: settings.disableLinks !== true && hasLinks,
|
|
88
162
|
hasMeta: settings.disableMeta !== true && hasMeta,
|
|
@@ -96,7 +170,10 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
96
170
|
suffix: getHash(rest.path || '/'),
|
|
97
171
|
middlewares,
|
|
98
172
|
authority,
|
|
173
|
+
authorityConfig,
|
|
174
|
+
extraLink,
|
|
99
175
|
extraPermissions,
|
|
176
|
+
extraParams,
|
|
100
177
|
extraProps: settings.disableExtraProps !== true ? extraProps : {},
|
|
101
178
|
queries,
|
|
102
179
|
clientMiddlewares: settings.disableClientMiddlewares !== true ? clientMiddlewares : [],
|
|
@@ -104,6 +181,7 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
104
181
|
configurations,
|
|
105
182
|
settings,
|
|
106
183
|
paths,
|
|
184
|
+
extraIcons,
|
|
107
185
|
};
|
|
108
186
|
const file = wrapperComponent.wrapRouteComponent(componentPath, wrapperPaths, metaJson, options);
|
|
109
187
|
const opts = { ...rest, id: rest.path };
|
|
@@ -117,17 +195,28 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
117
195
|
}
|
|
118
196
|
}
|
|
119
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Defines the routes configuration for the application.
|
|
200
|
+
* Loads and defines routes based on the provided options and meta data.
|
|
201
|
+
*
|
|
202
|
+
* @param routeFn - The route function to define the route.
|
|
203
|
+
* @param options - The options containing route configurations, settings, and paths.
|
|
204
|
+
* @param metaJson - Optional metadata JSON for additional configurations.
|
|
205
|
+
*/
|
|
120
206
|
function defineRoutesConfig(routeFn, options, metaJson = null) {
|
|
121
207
|
const jsonRoute = loadRoutesConfig(options);
|
|
122
208
|
const settings = options.settings || {};
|
|
123
209
|
const paths = options.paths || {};
|
|
124
|
-
const
|
|
210
|
+
const iconsRepository = options.iconsRepository || {};
|
|
211
|
+
// Reset dialog paths and icon-related variables
|
|
125
212
|
dialogPaths = [];
|
|
126
213
|
iconNames = [];
|
|
127
214
|
iconSvgPaths = [];
|
|
215
|
+
// Define each route
|
|
128
216
|
jsonRoute.forEach((item) => {
|
|
129
217
|
defineRoute(routeFn, item, { metaJson, settings, paths });
|
|
130
218
|
});
|
|
219
|
+
// Write the dialogs and icons configuration
|
|
131
220
|
dialogWrapper.writeDialogsSwitch(dialogPaths);
|
|
132
|
-
iconSwitch.writeIconsSwitch(iconNames, iconSvgPaths, iconFiles,
|
|
133
|
-
}exports.defineRoutesConfig=defineRoutesConfig;exports.loadRoutesConfig=loadRoutesConfig;exports.resolvePathsUsingPackages=resolvePathsUsingPackages;//# sourceMappingURL=json-wrappers.cjs.map
|
|
221
|
+
iconSwitch.writeIconsSwitch(iconNames, iconSvgPaths, iconFiles, iconsRepository);
|
|
222
|
+
}exports.defineRoutesConfig=defineRoutesConfig;exports.getHash=getHash;exports.loadRoutesConfig=loadRoutesConfig;exports.resolvePathsUsingPackages=resolvePathsUsingPackages;//# sourceMappingURL=json-wrappers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-wrappers.cjs","sources":["../../src/vite-wrappers/json-wrappers.ts"],"sourcesContent":[null],"names":["createHash","getRootPath","isArray","mergeWith","getSortedRoutes","dialogWrapperUtility","wrapRouteComponent","writeDialogsSwitch","writeIconsSwitch"],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-wrappers.cjs","sources":["../../src/vite-wrappers/json-wrappers.ts"],"sourcesContent":[null],"names":["createHash","getRootPath","isArray","mergeWith","getSortedRoutes","dialogWrapperUtility","wrapRouteComponent","writeDialogsSwitch","writeIconsSwitch"],"mappings":"mVAAA;AACA;AAWA;;;;;;;AAOG;AACU,MAAA,OAAO,GAAG,CAAC,MAAc,EAAE,SAAS,GAAG,CAAC,KAAY;AAC7D,IAAA,MAAM,IAAI,GAAGA,sBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,IAAA,OAAO,OAAO,SAAS,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;AAC3E,EAAE;AAEF;;;;;;;;AAQG;SACa,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAA;AAClE,IAAA,MAAM,QAAQ,GAAG,QAAQ,IAAIC,4BAAW,EAAE,CAAC;;IAE3C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAG,EAAA,QAAQ,iBAAiB,IAAI,CAAA,CAAE,CAAC,CAAC,CAAC;IACzF,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAI;AAC7C,QAAA,MAAM,GAAG,GAAG,CAAA,EAAG,IAAI,CAAQ,KAAA,EAAA,QAAQ,EAAE,CAAC;AACtC,QAAA,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AACpB,YAAA,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;SACxB;AACD,QAAA,OAAO,GAAG,CAAC;KACd,EAAE,EAAE,CAAC,CAAC;AACP,IAAA,OAA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;AACxC,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;AAClC,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;;IAGtD,WAAW,GAAG,EAAE,CAAC;IACjB,SAAS,GAAG,EAAE,CAAC;IACf,YAAY,GAAG,EAAE,CAAC;;AAGlB,IAAA,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACvB,QAAA,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9D,KAAC,CAAC,CAAC;;IAGHC,gCAAkB,CAAC,WAAW,CAAC,CAAC;IAChCC,2BAAgB,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1E"}
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a hash from the source string.
|
|
3
|
+
* Used to create unique route suffixes.
|
|
4
|
+
*
|
|
5
|
+
* @param source - The source string to hash.
|
|
6
|
+
* @param maxLength - The maximum length of the hash. Default is 8.
|
|
7
|
+
* @returns A substring of the generated SHA256 hash.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getHash: (source: string, maxLength?: number) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the directories containing files from specified packages.
|
|
12
|
+
* Searches for a specific file in the node_modules directories of the provided packages.
|
|
13
|
+
*
|
|
14
|
+
* @param packages - The list of package names to search in.
|
|
15
|
+
* @param fileName - The name of the file to search for.
|
|
16
|
+
* @param rootPath - Optional root path to start the search. Defaults to project root.
|
|
17
|
+
* @returns An array of directories where the specified file is found.
|
|
18
|
+
*/
|
|
1
19
|
export declare function resolvePathsUsingPackages(packages: any, fileName: any, rootPath: any): any;
|
|
20
|
+
/**
|
|
21
|
+
* Loads the routes configuration from the specified packages and merges them.
|
|
22
|
+
* Returns the sorted and merged route configuration.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The options containing package names and root path for route resolution.
|
|
25
|
+
* @returns The sorted routes configuration or null if no configuration is found.
|
|
26
|
+
*/
|
|
2
27
|
export declare function loadRoutesConfig(options: any): any;
|
|
28
|
+
/**
|
|
29
|
+
* Defines the routes configuration for the application.
|
|
30
|
+
* Loads and defines routes based on the provided options and meta data.
|
|
31
|
+
*
|
|
32
|
+
* @param routeFn - The route function to define the route.
|
|
33
|
+
* @param options - The options containing route configurations, settings, and paths.
|
|
34
|
+
* @param metaJson - Optional metadata JSON for additional configurations.
|
|
35
|
+
*/
|
|
3
36
|
export declare function defineRoutesConfig(routeFn: any, options: any, metaJson?: any): void;
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
import {getSortedRoutes}from'@common-stack/client-react/lib/route/get-routes.js';import fs__default from'fs';import globAll from'glob-all';import {mergeWith,isArray}from'lodash-es';import {createHash}from'node:crypto';import {getRootPath,wrapRouteComponent}from'./wrapperComponent.js';import {writeDialogsSwitch,dialogWrapperUtility}from'./dialog-wrapper.js';import {writeIconsSwitch}from'./icon-switch.js'
|
|
1
|
+
import {getSortedRoutes}from'@common-stack/client-react/lib/route/get-routes.js';import fs__default from'fs';import globAll from'glob-all';import {mergeWith,isArray}from'lodash-es';import {createHash}from'node:crypto';import {getRootPath,wrapRouteComponent}from'./wrapperComponent.js';import {writeDialogsSwitch,dialogWrapperUtility}from'./dialog-wrapper.js';import {writeIconsSwitch}from'./icon-switch.js';/* eslint-disable jest/require-hook */
|
|
2
|
+
/* eslint-disable array-callback-return */
|
|
3
|
+
/**
|
|
4
|
+
* Generates a hash from the source string.
|
|
5
|
+
* Used to create unique route suffixes.
|
|
6
|
+
*
|
|
7
|
+
* @param source - The source string to hash.
|
|
8
|
+
* @param maxLength - The maximum length of the hash. Default is 8.
|
|
9
|
+
* @returns A substring of the generated SHA256 hash.
|
|
10
|
+
*/
|
|
11
|
+
const getHash = (source, maxLength = 8) => {
|
|
2
12
|
const hash = createHash('sha256').update(source).digest('hex');
|
|
3
13
|
return typeof maxLength === 'number' ? hash.slice(0, maxLength) : hash;
|
|
4
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the directories containing files from specified packages.
|
|
17
|
+
* Searches for a specific file in the node_modules directories of the provided packages.
|
|
18
|
+
*
|
|
19
|
+
* @param packages - The list of package names to search in.
|
|
20
|
+
* @param fileName - The name of the file to search for.
|
|
21
|
+
* @param rootPath - Optional root path to start the search. Defaults to project root.
|
|
22
|
+
* @returns An array of directories where the specified file is found.
|
|
23
|
+
*/
|
|
5
24
|
function resolvePathsUsingPackages(packages, fileName, rootPath) {
|
|
6
25
|
const basePath = rootPath || getRootPath();
|
|
7
26
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
@@ -15,11 +34,26 @@ function resolvePathsUsingPackages(packages, fileName, rootPath) {
|
|
|
15
34
|
}, []);
|
|
16
35
|
return localesDirs;
|
|
17
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Custom merge function used to concatenate arrays when merging objects.
|
|
39
|
+
* Used when merging routes configurations.
|
|
40
|
+
*
|
|
41
|
+
* @param objValue - The existing value.
|
|
42
|
+
* @param srcValue - The new value to merge.
|
|
43
|
+
* @returns Concatenated array if objValue is an array, otherwise undefined.
|
|
44
|
+
*/
|
|
18
45
|
function customizer(objValue, srcValue) {
|
|
19
46
|
if (isArray(objValue)) {
|
|
20
47
|
return objValue.concat(srcValue);
|
|
21
48
|
}
|
|
22
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Loads the routes configuration from the specified packages and merges them.
|
|
52
|
+
* Returns the sorted and merged route configuration.
|
|
53
|
+
*
|
|
54
|
+
* @param options - The options containing package names and root path for route resolution.
|
|
55
|
+
* @returns The sorted routes configuration or null if no configuration is found.
|
|
56
|
+
*/
|
|
23
57
|
function loadRoutesConfig(options) {
|
|
24
58
|
const fileName = options.routesFileName || 'route.json';
|
|
25
59
|
const directories = resolvePathsUsingPackages(options.packages, fileName, options.rootPath);
|
|
@@ -35,15 +69,45 @@ function loadRoutesConfig(options) {
|
|
|
35
69
|
const result = content.length ? getSortedRoutes('/', Object.assign({}, ...content)) : null;
|
|
36
70
|
return result;
|
|
37
71
|
}
|
|
72
|
+
// Global variables to store dialog paths, icon names, and icon files.
|
|
38
73
|
let dialogPaths = [];
|
|
39
74
|
let iconNames = [];
|
|
40
75
|
let iconSvgPaths = [];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
const iconFiles = [];
|
|
77
|
+
/**
|
|
78
|
+
* Adds a unique icon name to the global iconNames array.
|
|
79
|
+
*
|
|
80
|
+
* @param icon - The icon name to add.
|
|
81
|
+
* @returns Null if the icon name is already in the array, otherwise adds the name.
|
|
82
|
+
*/
|
|
83
|
+
const addIconName = (icon) => (!iconNames.includes(icon) ? iconNames.push(icon) : null);
|
|
84
|
+
/**
|
|
85
|
+
* Adds a unique SVG path to the global iconSvgPaths array.
|
|
86
|
+
*
|
|
87
|
+
* @param icon - The SVG path to add.
|
|
88
|
+
* @returns Null if the SVG path is already in the array, otherwise adds the path.
|
|
89
|
+
*/
|
|
90
|
+
const addIconSvgPath = (icon) => (!iconSvgPaths.includes(icon) ? iconSvgPaths.push(icon) : null);
|
|
91
|
+
/**
|
|
92
|
+
* Adds a unique icon file path to the global iconFiles array.
|
|
93
|
+
*
|
|
94
|
+
* @param icon - The file path to add.
|
|
95
|
+
* @returns Null if the file path is already in the array, otherwise adds the path.
|
|
96
|
+
*/
|
|
97
|
+
const addIconFile = (icon) => (!iconFiles.includes(icon) ? iconFiles.push(icon) : null);
|
|
98
|
+
/**
|
|
99
|
+
* Defines a route and its associated settings based on the route configuration.
|
|
100
|
+
* Wraps the component with necessary middleware, permission, and client wrappers.
|
|
101
|
+
*
|
|
102
|
+
* @param routeFn - The route function to define a new route.
|
|
103
|
+
* @param jsonRoute - The JSON route configuration.
|
|
104
|
+
* @param metaJson - Metadata related to the route.
|
|
105
|
+
* @param settings - The application settings.
|
|
106
|
+
* @param paths - The paths configuration for various modules and components.
|
|
107
|
+
*/
|
|
45
108
|
function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
46
|
-
const { routes = null, relativePath: path, componentPath, clientOnly, dialogPath, isResourceRoute, auth = 'optional', hasLoader = false, hasAction = false, hasClientLoader = false, hasClientAction = false, hasComponent = false, hasErrorBoundary = false, hasLinks = false, hasMeta = false, hasHydrateFallback = false, hasShouldRevalidate = false, queryParamsGenerator = false, hasHandle = false, hasHeaders = false, wrapperPaths = [], middlewares = [], authority = [], extraPermissions = [], extraProps = {}, loaderReturnInfo = {}, queries = {}, clientMiddlewares = [], configurations = [], resourceUri, icon, ...rest } = jsonRoute;
|
|
109
|
+
const { routes = null, relativePath: path, componentPath, clientOnly, dialogPath, isResourceRoute, auth = 'optional', hasServerCode = false, hasLoader = false, hasAction = false, hasClientLoader = false, hasClientAction = false, hasComponent = false, hasErrorBoundary = false, hasLinks = false, hasMeta = false, hasHydrateFallback = false, hasShouldRevalidate = false, queryParamsGenerator = false, hasHandle = false, hasHeaders = false, wrapperPaths = [], middlewares = [], authority = [], authorityConfig = {}, extraPermissions = [], extraParams = {}, extraIcons = [], extraLink = [], extraProps = {}, loaderReturnInfo = {}, queries = {}, clientMiddlewares = [], configurations = [], resourceUri, icon, ...rest } = jsonRoute;
|
|
110
|
+
// Handle icons
|
|
47
111
|
if (icon) {
|
|
48
112
|
if (typeof icon === 'object') {
|
|
49
113
|
if (typeof icon.svgPath === 'string') {
|
|
@@ -60,19 +124,28 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
60
124
|
addIconName(icon);
|
|
61
125
|
}
|
|
62
126
|
}
|
|
127
|
+
// Handle extra icons if any
|
|
128
|
+
if (extraIcons?.length > 0) {
|
|
129
|
+
extraIcons?.map((icon) => {
|
|
130
|
+
if (typeof icon === 'string') {
|
|
131
|
+
addIconName(icon);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
console.warn(`Invalid icon type: ${typeof icon}`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// Handle dialog paths and component routes
|
|
63
139
|
if (dialogPath && !dialogPaths.includes(dialogPath)) {
|
|
64
140
|
dialogWrapperUtility(dialogPath, { path: rest.path });
|
|
65
141
|
dialogPaths.push(dialogPath);
|
|
66
142
|
}
|
|
67
143
|
else if (componentPath) {
|
|
68
144
|
if (clientOnly) {
|
|
69
|
-
wrapperPaths.push('$clientOnlyWrapper'); // Add a placeholder for
|
|
145
|
+
wrapperPaths.push('$clientOnlyWrapper'); // Add a placeholder for client-only wrapper
|
|
70
146
|
}
|
|
71
147
|
if (authority.length > 0) {
|
|
72
|
-
wrapperPaths.push('$
|
|
73
|
-
}
|
|
74
|
-
if (configurations.length > 0 && resourceUri) {
|
|
75
|
-
wrapperPaths.push('$configurationWrapper'); // Add a placeholder for the permission wrapper at last
|
|
148
|
+
wrapperPaths.push('$configPermissionWrapper'); // Add a placeholder for permission wrapper
|
|
76
149
|
}
|
|
77
150
|
const requireAuth = !!auth;
|
|
78
151
|
const options = {
|
|
@@ -83,6 +156,7 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
83
156
|
hasAction: settings.disableAction !== true && hasAction,
|
|
84
157
|
hasClientLoader: settings.disableClientLoader !== true && hasClientLoader,
|
|
85
158
|
hasComponent,
|
|
159
|
+
hasServerCode,
|
|
86
160
|
hasErrorBoundary: settings.disableErrorBoundary !== true && hasErrorBoundary,
|
|
87
161
|
hasLinks: settings.disableLinks !== true && hasLinks,
|
|
88
162
|
hasMeta: settings.disableMeta !== true && hasMeta,
|
|
@@ -96,7 +170,10 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
96
170
|
suffix: getHash(rest.path || '/'),
|
|
97
171
|
middlewares,
|
|
98
172
|
authority,
|
|
173
|
+
authorityConfig,
|
|
174
|
+
extraLink,
|
|
99
175
|
extraPermissions,
|
|
176
|
+
extraParams,
|
|
100
177
|
extraProps: settings.disableExtraProps !== true ? extraProps : {},
|
|
101
178
|
queries,
|
|
102
179
|
clientMiddlewares: settings.disableClientMiddlewares !== true ? clientMiddlewares : [],
|
|
@@ -104,6 +181,7 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
104
181
|
configurations,
|
|
105
182
|
settings,
|
|
106
183
|
paths,
|
|
184
|
+
extraIcons,
|
|
107
185
|
};
|
|
108
186
|
const file = wrapRouteComponent(componentPath, wrapperPaths, metaJson, options);
|
|
109
187
|
const opts = { ...rest, id: rest.path };
|
|
@@ -117,17 +195,28 @@ function defineRoute(routeFn, jsonRoute, { metaJson, settings, paths }) {
|
|
|
117
195
|
}
|
|
118
196
|
}
|
|
119
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Defines the routes configuration for the application.
|
|
200
|
+
* Loads and defines routes based on the provided options and meta data.
|
|
201
|
+
*
|
|
202
|
+
* @param routeFn - The route function to define the route.
|
|
203
|
+
* @param options - The options containing route configurations, settings, and paths.
|
|
204
|
+
* @param metaJson - Optional metadata JSON for additional configurations.
|
|
205
|
+
*/
|
|
120
206
|
function defineRoutesConfig(routeFn, options, metaJson = null) {
|
|
121
207
|
const jsonRoute = loadRoutesConfig(options);
|
|
122
208
|
const settings = options.settings || {};
|
|
123
209
|
const paths = options.paths || {};
|
|
124
|
-
const
|
|
210
|
+
const iconsRepository = options.iconsRepository || {};
|
|
211
|
+
// Reset dialog paths and icon-related variables
|
|
125
212
|
dialogPaths = [];
|
|
126
213
|
iconNames = [];
|
|
127
214
|
iconSvgPaths = [];
|
|
215
|
+
// Define each route
|
|
128
216
|
jsonRoute.forEach((item) => {
|
|
129
217
|
defineRoute(routeFn, item, { metaJson, settings, paths });
|
|
130
218
|
});
|
|
219
|
+
// Write the dialogs and icons configuration
|
|
131
220
|
writeDialogsSwitch(dialogPaths);
|
|
132
|
-
writeIconsSwitch(iconNames, iconSvgPaths, iconFiles,
|
|
133
|
-
}export{defineRoutesConfig,loadRoutesConfig,resolvePathsUsingPackages};//# sourceMappingURL=json-wrappers.js.map
|
|
221
|
+
writeIconsSwitch(iconNames, iconSvgPaths, iconFiles, iconsRepository);
|
|
222
|
+
}export{defineRoutesConfig,getHash,loadRoutesConfig,resolvePathsUsingPackages};//# sourceMappingURL=json-wrappers.js.map
|