@komaci/common-shared 240.1.3
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/build/__mocks__/@babel/parser.d.ts +2 -0
- package/build/__mocks__/@babel/parser.js +6 -0
- package/build/allowListGlobals.d.ts +4 -0
- package/build/allowListGlobals.js +7 -0
- package/build/allowlistNamespaces.d.ts +29 -0
- package/build/allowlistNamespaces.js +67 -0
- package/build/index.d.ts +7 -0
- package/build/index.js +19 -0
- package/build/internal-namespaces.json +1062 -0
- package/build/komaciDocumentIntrospection.d.ts +120 -0
- package/build/komaciDocumentIntrospection.js +366 -0
- package/build/parser.d.ts +9 -0
- package/build/parser.js +19 -0
- package/build/types.d.ts +193 -0
- package/build/types.js +16 -0
- package/build/utils.d.ts +153 -0
- package/build/utils.js +554 -0
- package/package.json +37 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the given namespace is an internal namespace. Note,
|
|
3
|
+
* case is ignored. e.g., if "flexipage" is defined as a supported namespace, then
|
|
4
|
+
* "flexiPage", "FLEXIPAGE", etc will return true
|
|
5
|
+
* @param namespace the namespace to check
|
|
6
|
+
* @returns true if namespace is internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function isNamespaceInternal(namespace: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the namespace for the given import; e.g., given "laf/someModule"
|
|
11
|
+
* returns "laf".
|
|
12
|
+
* @param importResource the resource being import
|
|
13
|
+
* @returns the namespace of the imported resource
|
|
14
|
+
*/
|
|
15
|
+
export declare function getNamespaceFromImport(importResource: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns true if the library of a supported namesapce is valid.
|
|
18
|
+
* @param importPath the import path
|
|
19
|
+
* @returns true if valid
|
|
20
|
+
*/
|
|
21
|
+
export declare function isLibraryValid(importPath: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Checks a path against a regex to deternmine if its valid
|
|
24
|
+
* @param path the path to check
|
|
25
|
+
* @param re the regular expression
|
|
26
|
+
* @returns true if the regex is satisfied.
|
|
27
|
+
*/
|
|
28
|
+
export declare function checkLibraryPathWithRegex(path: string, re: RegExp): boolean;
|
|
29
|
+
//# sourceMappingURL=allowlistNamespaces.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkLibraryPathWithRegex = exports.isLibraryValid = exports.getNamespaceFromImport = exports.isNamespaceInternal = void 0;
|
|
7
|
+
const internal_namespaces_json_1 = __importDefault(require("./internal-namespaces.json"));
|
|
8
|
+
const hardCodedNamespaces = ['lightning', 'laf', 'one', 'force', 'lst', '@salesforce'];
|
|
9
|
+
const internalButNotSupported = ['komaci', 'lwc', 'aura', 'lwr'];
|
|
10
|
+
const allowlistNamespaces = [...hardCodedNamespaces, ...internal_namespaces_json_1.default].filter((ns) => !internalButNotSupported.includes(ns.toLowerCase()));
|
|
11
|
+
const allowListLibrariesRegex = [
|
|
12
|
+
/^force\/shared$/,
|
|
13
|
+
/^laf\/transformWire$/,
|
|
14
|
+
/^formula\/formulaEngine$/,
|
|
15
|
+
/^@salesforce\/.*$/,
|
|
16
|
+
/^lightning\/graphql$/,
|
|
17
|
+
/^lightning\/ui.*Api$/,
|
|
18
|
+
/^lightning\/unstable_ui.*Api$/,
|
|
19
|
+
/^laf\/batchingPortable$/,
|
|
20
|
+
/^lightning\/navigation$/,
|
|
21
|
+
/^lightning\/base.*$/,
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if the given namespace is an internal namespace. Note,
|
|
25
|
+
* case is ignored. e.g., if "flexipage" is defined as a supported namespace, then
|
|
26
|
+
* "flexiPage", "FLEXIPAGE", etc will return true
|
|
27
|
+
* @param namespace the namespace to check
|
|
28
|
+
* @returns true if namespace is internal
|
|
29
|
+
*/
|
|
30
|
+
function isNamespaceInternal(namespace) {
|
|
31
|
+
return (allowlistNamespaces.findIndex((internalNamespace) => internalNamespace.toLowerCase() === namespace.toLowerCase()) >= 0);
|
|
32
|
+
}
|
|
33
|
+
exports.isNamespaceInternal = isNamespaceInternal;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the namespace for the given import; e.g., given "laf/someModule"
|
|
36
|
+
* returns "laf".
|
|
37
|
+
* @param importResource the resource being import
|
|
38
|
+
* @returns the namespace of the imported resource
|
|
39
|
+
*/
|
|
40
|
+
function getNamespaceFromImport(importResource) {
|
|
41
|
+
if (importResource.includes('/')) {
|
|
42
|
+
const [namespace = ''] = importResource.split('/');
|
|
43
|
+
return namespace;
|
|
44
|
+
}
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
exports.getNamespaceFromImport = getNamespaceFromImport;
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if the library of a supported namesapce is valid.
|
|
50
|
+
* @param importPath the import path
|
|
51
|
+
* @returns true if valid
|
|
52
|
+
*/
|
|
53
|
+
function isLibraryValid(importPath) {
|
|
54
|
+
return (allowListLibrariesRegex.findIndex((re) => checkLibraryPathWithRegex(importPath, re)) >= 0);
|
|
55
|
+
}
|
|
56
|
+
exports.isLibraryValid = isLibraryValid;
|
|
57
|
+
/**
|
|
58
|
+
* Checks a path against a regex to deternmine if its valid
|
|
59
|
+
* @param path the path to check
|
|
60
|
+
* @param re the regular expression
|
|
61
|
+
* @returns true if the regex is satisfied.
|
|
62
|
+
*/
|
|
63
|
+
function checkLibraryPathWithRegex(path, re) {
|
|
64
|
+
return path.match(re) !== null;
|
|
65
|
+
}
|
|
66
|
+
exports.checkLibraryPathWithRegex = checkLibraryPathWithRegex;
|
|
67
|
+
//# sourceMappingURL=allowlistNamespaces.js.map
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./parser"), exports);
|
|
14
|
+
__exportStar(require("./utils"), exports);
|
|
15
|
+
__exportStar(require("./types"), exports);
|
|
16
|
+
__exportStar(require("./allowlistNamespaces"), exports);
|
|
17
|
+
__exportStar(require("./komaciDocumentIntrospection"), exports);
|
|
18
|
+
__exportStar(require("./allowListGlobals"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|