@hamak/shared-utils 0.4.1
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/dist/core-utils-chrono.d.ts +8 -0
- package/dist/core-utils-chrono.d.ts.map +1 -0
- package/dist/core-utils-chrono.js +16 -0
- package/dist/core-utils-comparator.d.ts +11 -0
- package/dist/core-utils-comparator.d.ts.map +1 -0
- package/dist/core-utils-comparator.js +22 -0
- package/dist/core-utils-file.d.ts +10 -0
- package/dist/core-utils-file.d.ts.map +1 -0
- package/dist/core-utils-file.js +1 -0
- package/dist/core-utils-filesystem.d.ts +69 -0
- package/dist/core-utils-filesystem.d.ts.map +1 -0
- package/dist/core-utils-filesystem.js +156 -0
- package/dist/core-utils-fqn.d.ts +11 -0
- package/dist/core-utils-fqn.d.ts.map +1 -0
- package/dist/core-utils-fqn.js +19 -0
- package/dist/core-utils-pathway-resolver.d.ts +20 -0
- package/dist/core-utils-pathway-resolver.d.ts.map +1 -0
- package/dist/core-utils-pathway-resolver.js +31 -0
- package/dist/core-utils-pathway.d.ts +84 -0
- package/dist/core-utils-pathway.d.ts.map +1 -0
- package/dist/core-utils-pathway.js +206 -0
- package/dist/core-utils-registry.d.ts +7 -0
- package/dist/core-utils-registry.d.ts.map +1 -0
- package/dist/core-utils-registry.js +22 -0
- package/dist/core-utils-resolver.d.ts +33 -0
- package/dist/core-utils-resolver.d.ts.map +1 -0
- package/dist/core-utils-resolver.js +65 -0
- package/dist/core-utils-stack.d.ts +20 -0
- package/dist/core-utils-stack.d.ts.map +1 -0
- package/dist/core-utils-stack.js +47 -0
- package/dist/core-utils-types-hkt.d.ts +12 -0
- package/dist/core-utils-types-hkt.d.ts.map +1 -0
- package/dist/core-utils-types-hkt.js +1 -0
- package/dist/core-utils-types.d.ts +83 -0
- package/dist/core-utils-types.d.ts.map +1 -0
- package/dist/core-utils-types.js +39 -0
- package/dist/core-utils-validations.d.ts +21 -0
- package/dist/core-utils-validations.d.ts.map +1 -0
- package/dist/core-utils-validations.js +18 -0
- package/dist/core-utils.d.ts +39 -0
- package/dist/core-utils.d.ts.map +1 -0
- package/dist/core-utils.js +113 -0
- package/dist/es2015/core-utils-chrono.js +16 -0
- package/dist/es2015/core-utils-comparator.js +22 -0
- package/dist/es2015/core-utils-file.js +1 -0
- package/dist/es2015/core-utils-filesystem.js +157 -0
- package/dist/es2015/core-utils-fqn.js +19 -0
- package/dist/es2015/core-utils-pathway-resolver.js +31 -0
- package/dist/es2015/core-utils-pathway.js +206 -0
- package/dist/es2015/core-utils-registry.js +22 -0
- package/dist/es2015/core-utils-resolver.js +68 -0
- package/dist/es2015/core-utils-stack.js +47 -0
- package/dist/es2015/core-utils-types-hkt.js +1 -0
- package/dist/es2015/core-utils-types.js +39 -0
- package/dist/es2015/core-utils-validations.js +18 -0
- package/dist/es2015/core-utils.js +113 -0
- package/dist/es2015/index.js +24 -0
- package/dist/es2015/itinerary/hyper-layer-node.js +21 -0
- package/dist/es2015/itinerary/itinerary.js +276 -0
- package/dist/es2015/itinerary/stack.js +47 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/itinerary/hyper-layer-node.d.ts +12 -0
- package/dist/itinerary/hyper-layer-node.d.ts.map +1 -0
- package/dist/itinerary/hyper-layer-node.js +21 -0
- package/dist/itinerary/itinerary.d.ts +86 -0
- package/dist/itinerary/itinerary.d.ts.map +1 -0
- package/dist/itinerary/itinerary.js +275 -0
- package/dist/itinerary/stack.d.ts +20 -0
- package/dist/itinerary/stack.d.ts.map +1 -0
- package/dist/itinerary/stack.js +47 -0
- package/package.json +41 -0
- package/src/core-utils-chrono.ts +21 -0
- package/src/core-utils-comparator.ts +27 -0
- package/src/core-utils-file.ts +10 -0
- package/src/core-utils-filesystem.spec.ts +63 -0
- package/src/core-utils-filesystem.ts +232 -0
- package/src/core-utils-fqn.ts +17 -0
- package/src/core-utils-pathway-resolver.ts +36 -0
- package/src/core-utils-pathway.ts +232 -0
- package/src/core-utils-registry.ts +23 -0
- package/src/core-utils-resolver.ts +75 -0
- package/src/core-utils-stack.spec.ts +42 -0
- package/src/core-utils-stack.ts +62 -0
- package/src/core-utils-types-hkt.ts +9 -0
- package/src/core-utils-types.ts +127 -0
- package/src/core-utils-validations.ts +36 -0
- package/src/core-utils.spec.ts +56 -0
- package/src/core-utils.ts +139 -0
- package/src/index.ts +34 -0
- package/src/itinerary/hyper-layer-node.ts +25 -0
- package/src/itinerary/itinerary.spec.ts +388 -0
- package/src/itinerary/itinerary.ts +363 -0
- package/src/itinerary/stack.spec.ts +46 -0
- package/src/itinerary/stack.ts +62 -0
- package/tsconfig.es2015.json +24 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class representing a normalized pathway.
|
|
3
|
+
*/
|
|
4
|
+
export class Pathway {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Pathway instance.
|
|
7
|
+
* @param path - The pathway to normalize, either as a string or an array of strings.
|
|
8
|
+
* An empty array or "." represents the current directory.
|
|
9
|
+
*/
|
|
10
|
+
constructor(path) {
|
|
11
|
+
if (path == null || path === "." || (Array.isArray(path) && path.length === 0)) {
|
|
12
|
+
this.segments = [];
|
|
13
|
+
this.isAbsolutePath = false;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this.isAbsolutePath = Array.isArray(path) ? path[0].startsWith('/') : path.startsWith('/');
|
|
17
|
+
this.segments = this.normalizePath(path);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Factory method to create a Pathway instance.
|
|
22
|
+
* @param path - The pathway to normalize, either as a string or an array of strings.
|
|
23
|
+
* @returns A new Pathway instance.
|
|
24
|
+
*/
|
|
25
|
+
static of(path) {
|
|
26
|
+
if (path !== undefined && path !== null && typeof path === "object" && !Array.isArray(path)) {
|
|
27
|
+
return path;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return new Pathway(path);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Normalizes a pathway by converting it into an array of segments.
|
|
35
|
+
* @param path - The pathway to normalize, either as a string or an array of strings.
|
|
36
|
+
* @returns An array of normalized path segments, or an empty array if the input is null or undefined.
|
|
37
|
+
*/
|
|
38
|
+
normalizePath(path) {
|
|
39
|
+
if (path == null) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const segments = Array.isArray(path) ? path : path.split('/');
|
|
43
|
+
return segments
|
|
44
|
+
.reduce((acc, segment) => {
|
|
45
|
+
if (segment === "." || segment === "") {
|
|
46
|
+
return acc;
|
|
47
|
+
}
|
|
48
|
+
return acc.concat(segment.split('/'));
|
|
49
|
+
}, [])
|
|
50
|
+
.filter(segment => segment.length > 0);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the normalized path segments.
|
|
54
|
+
* @returns An array of normalized path segments.
|
|
55
|
+
*/
|
|
56
|
+
getSegments() {
|
|
57
|
+
return this.segments;
|
|
58
|
+
}
|
|
59
|
+
isCurrentDir() {
|
|
60
|
+
return this.getSegments().length === 0;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Converts the normalized path segments back to a string.
|
|
64
|
+
* @returns The normalized path as a string.
|
|
65
|
+
*/
|
|
66
|
+
toString() {
|
|
67
|
+
return this.isAbsolute() ? '/' + this.segments.join('/') : this.segments.join('/');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if the pathway is absolute.
|
|
71
|
+
* @returns True if the pathway is absolute, false otherwise.
|
|
72
|
+
*/
|
|
73
|
+
isAbsolute() {
|
|
74
|
+
return this.isAbsolutePath;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Checks if the pathway is relative.
|
|
78
|
+
* @returns True if the pathway is relative, false otherwise.
|
|
79
|
+
*/
|
|
80
|
+
isRelative() {
|
|
81
|
+
return !this.isAbsolutePath;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolves the current pathway with another pathway or string.
|
|
85
|
+
* @param otherPath - The other pathway or string to resolve against.
|
|
86
|
+
* @returns A new Pathway instance representing the resolved path.
|
|
87
|
+
*/
|
|
88
|
+
resolve(otherPath) {
|
|
89
|
+
const otherSegments = otherPath instanceof Pathway ? otherPath.getSegments() : this.normalizePath(otherPath);
|
|
90
|
+
const resolvedSegments = [...this.segments];
|
|
91
|
+
if (otherPath instanceof Pathway ? otherPath.isAbsolute() : (Array.isArray(otherPath) ? otherPath[0].startsWith('/') : otherPath.startsWith('/'))) {
|
|
92
|
+
return new Pathway(otherSegments);
|
|
93
|
+
}
|
|
94
|
+
for (const segment of otherSegments) {
|
|
95
|
+
if (segment === '..') {
|
|
96
|
+
if (resolvedSegments.length > 0 && resolvedSegments[resolvedSegments.length - 1] !== '..') {
|
|
97
|
+
resolvedSegments.pop();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
resolvedSegments.push(segment);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (segment !== '.') {
|
|
104
|
+
resolvedSegments.push(segment);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return new Pathway(this.isAbsolute() ? ["/", ...resolvedSegments] : resolvedSegments);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets the parent directory of the current pathway.
|
|
111
|
+
* @returns A new Pathway instance representing the parent directory.
|
|
112
|
+
*/
|
|
113
|
+
getParent() {
|
|
114
|
+
if (this.segments.length === 0) {
|
|
115
|
+
return new Pathway(null);
|
|
116
|
+
}
|
|
117
|
+
const parentSegments = this.segments.slice(0, -1);
|
|
118
|
+
return new Pathway(this.isAbsolute() ? ["/", ...parentSegments] : parentSegments);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Gets the current directory of the pathway.
|
|
122
|
+
* @returns The current directory as a string.
|
|
123
|
+
*/
|
|
124
|
+
getCurrentDirectory() {
|
|
125
|
+
if (this.segments.length === 0) {
|
|
126
|
+
return '';
|
|
127
|
+
}
|
|
128
|
+
return this.segments[this.segments.length - 1];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Static method to get the absolute path of the root.
|
|
132
|
+
* @returns A new Pathway instance representing the root path.
|
|
133
|
+
*/
|
|
134
|
+
static ofRoot() {
|
|
135
|
+
return new Pathway('/');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Determines the relative path from this pathway to another pathway.
|
|
139
|
+
* @param otherPath - The other pathway to relativize against.
|
|
140
|
+
* @returns A new Pathway instance representing the relative path.
|
|
141
|
+
*/
|
|
142
|
+
relativize(otherPath) {
|
|
143
|
+
const otherSegments = otherPath instanceof Pathway ? otherPath.getSegments() : this.normalizePath(otherPath);
|
|
144
|
+
if (this.isAbsolute() !== (otherPath instanceof Pathway ? otherPath.isAbsolute() : (Array.isArray(otherPath) ? otherPath[0].startsWith('/') : otherPath.startsWith('/')))) {
|
|
145
|
+
throw new Error("Cannot relativize between absolute and relative paths");
|
|
146
|
+
}
|
|
147
|
+
let commonLength = 0;
|
|
148
|
+
const maxLength = Math.min(this.segments.length, otherSegments.length);
|
|
149
|
+
for (let i = 0; i < maxLength; i++) {
|
|
150
|
+
if (this.segments[i] !== otherSegments[i]) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
commonLength++;
|
|
154
|
+
}
|
|
155
|
+
const upSegments = this.segments.slice(commonLength).map(() => '..');
|
|
156
|
+
const downSegments = otherSegments.slice(commonLength);
|
|
157
|
+
return new Pathway(upSegments.concat(downSegments));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Checks if the given path is a descendant of the current pathway.
|
|
161
|
+
* @param otherPath - The other pathway to check.
|
|
162
|
+
* @returns True if the given path is a descendant, false otherwise.
|
|
163
|
+
*/
|
|
164
|
+
isDescendant(otherPath) {
|
|
165
|
+
const otherSegments = otherPath instanceof Pathway ? otherPath.getSegments() : this.normalizePath(otherPath);
|
|
166
|
+
if (otherSegments.length < this.segments.length) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
for (let i = 0; i < this.segments.length; i++) {
|
|
170
|
+
if (this.segments[i] !== otherSegments[i]) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
static isRelativePath(path) {
|
|
177
|
+
const pathway = typeof path === "object" && !Array.isArray(path) ? path : Pathway.of(path);
|
|
178
|
+
return pathway.isRelative();
|
|
179
|
+
}
|
|
180
|
+
static asString(path) {
|
|
181
|
+
if (typeof path === "string") {
|
|
182
|
+
return path;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const pathway = typeof path === "object" && !Array.isArray(path) ? path : Pathway.of(path);
|
|
186
|
+
return pathway.toString();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
static getName(path) {
|
|
190
|
+
let name;
|
|
191
|
+
switch (typeof path) {
|
|
192
|
+
case "string":
|
|
193
|
+
{
|
|
194
|
+
name = path;
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
case "object":
|
|
198
|
+
{
|
|
199
|
+
const segments = Array.isArray(path) ? path : path.getSegments();
|
|
200
|
+
name = segments[segments.length - 1];
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
return name;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Resolver } from './core-utils-resolver';
|
|
2
|
+
export declare class SimpleRegistry<T> implements Resolver<T> {
|
|
3
|
+
private readonly records;
|
|
4
|
+
resolve(namespace: string | undefined, prefix: string | undefined, variableName: string): T | undefined;
|
|
5
|
+
register(namespace: string | undefined, variableName: string, t: T): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=core-utils-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils-registry.d.ts","sourceRoot":"","sources":["../src/core-utils-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyD;IACjF,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IASvG,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,EAAG,CAAC;CASpE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class SimpleRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.records = new Map();
|
|
4
|
+
}
|
|
5
|
+
resolve(namespace, prefix, variableName) {
|
|
6
|
+
if (prefix !== undefined) {
|
|
7
|
+
throw new Error(`Not support namespace prefix for name resolution : '${prefix}'`);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
const record = this.records.get(namespace);
|
|
11
|
+
return record?.[variableName];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
register(namespace, variableName, t) {
|
|
15
|
+
let namespaceRecord = this.records.get(namespace);
|
|
16
|
+
if (namespaceRecord === undefined) {
|
|
17
|
+
namespaceRecord = {};
|
|
18
|
+
this.records.set(namespace, namespaceRecord);
|
|
19
|
+
}
|
|
20
|
+
namespaceRecord[variableName] = t;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Resolver<T> {
|
|
2
|
+
resolve(namespace: string | undefined, prefix: string | undefined, variableName: string): T | undefined;
|
|
3
|
+
}
|
|
4
|
+
export declare class RecordResolver<T> implements Resolver<T> {
|
|
5
|
+
readonly variables: Record<string, T>;
|
|
6
|
+
readonly parent?: Resolver<T> | undefined;
|
|
7
|
+
constructor(variables: Record<string, T>, parent?: Resolver<T> | undefined);
|
|
8
|
+
resolve(namespace: string | undefined, prefix: string | undefined, variableName: string): T | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare class QualifiedNameResolverImpl<T> implements Resolver<T> {
|
|
11
|
+
readonly ignoreNs: boolean;
|
|
12
|
+
readonly entries: Map<string | undefined, Map<string, T>>;
|
|
13
|
+
constructor(ignoreNs?: boolean);
|
|
14
|
+
resolve(namespace: string | undefined, prefix: string | undefined, name: string): T | undefined;
|
|
15
|
+
setEntries(prefix: string | undefined, entries: Record<string, T>): void;
|
|
16
|
+
setEntry(prefix: string | undefined, name: string, entry: T): void;
|
|
17
|
+
private getOrCreatePrefixEntry;
|
|
18
|
+
}
|
|
19
|
+
export type ResolverPredicate = (namespace: string | undefined, prefix: string | undefined, name: string) => boolean;
|
|
20
|
+
export declare class SimpleResolver<T> implements Resolver<T> {
|
|
21
|
+
readonly parent: Resolver<T> | undefined;
|
|
22
|
+
readonly namespace: string | undefined;
|
|
23
|
+
readonly variableName: string | undefined;
|
|
24
|
+
readonly variableValue: T;
|
|
25
|
+
constructor(parent: Resolver<T> | undefined, namespace: string | undefined, variableName: string | undefined, variableValue: T);
|
|
26
|
+
resolve(namespace: string | undefined, prefix: string | undefined, variableName: string): T | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare class ChainedResolver<T> implements Resolver<T> {
|
|
29
|
+
readonly resolvers: Resolver<T>[];
|
|
30
|
+
constructor(resolvers: Resolver<T>[]);
|
|
31
|
+
resolve(namespace: string | undefined, prefix: string | undefined, variableName: string): T | undefined;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=core-utils-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils-resolver.d.ts","sourceRoot":"","sources":["../src/core-utils-resolver.ts"],"names":[],"mappings":"AAAA,MAAM,WAA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BAAa,cAAc,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAAE,QAAQ,CAAC,aAAa,EAAE,CAAC;gBAA7I,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,EAAW,SAAS,EAAE,MAAM,GAAG,SAAS,EAAW,YAAY,EAAE,MAAM,GAAG,SAAS,EAAW,aAAa,EAAE,CAAC;IAGlK,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;CAOxG;AAED,qBAAa,eAAe,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAAxB,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE;IAG7C,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;CAUxG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export class RecordResolver {
|
|
2
|
+
constructor(variables, parent) {
|
|
3
|
+
this.variables = variables;
|
|
4
|
+
this.parent = parent;
|
|
5
|
+
}
|
|
6
|
+
resolve(namespace, prefix, variableName) {
|
|
7
|
+
return this.variables[variableName] ?? this.parent?.resolve(undefined, undefined, variableName);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class QualifiedNameResolverImpl {
|
|
11
|
+
constructor(ignoreNs = false) {
|
|
12
|
+
this.ignoreNs = ignoreNs;
|
|
13
|
+
this.entries = new Map();
|
|
14
|
+
}
|
|
15
|
+
resolve(namespace, prefix, name) {
|
|
16
|
+
if (!this.ignoreNs && namespace !== undefined && namespace !== null) {
|
|
17
|
+
throw new Error(`Not support namespace URI but passed as parameter: ${namespace}`);
|
|
18
|
+
}
|
|
19
|
+
return this.entries.get(namespace)?.get(name);
|
|
20
|
+
}
|
|
21
|
+
setEntries(prefix, entries) {
|
|
22
|
+
const prefixEntry = this.getOrCreatePrefixEntry(prefix);
|
|
23
|
+
Object.entries(entries).forEach(([k, v]) => prefixEntry.set(k, v));
|
|
24
|
+
}
|
|
25
|
+
setEntry(prefix, name, entry) {
|
|
26
|
+
const prefixEntry = this.getOrCreatePrefixEntry(prefix);
|
|
27
|
+
prefixEntry.set(name, entry);
|
|
28
|
+
}
|
|
29
|
+
getOrCreatePrefixEntry(prefix) {
|
|
30
|
+
let prefixEntry = this.entries.get(prefix);
|
|
31
|
+
if (prefixEntry === undefined) {
|
|
32
|
+
prefixEntry = new Map();
|
|
33
|
+
this.entries.set(prefix, prefixEntry);
|
|
34
|
+
}
|
|
35
|
+
return prefixEntry;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class SimpleResolver {
|
|
39
|
+
constructor(parent, namespace, variableName, variableValue) {
|
|
40
|
+
this.parent = parent;
|
|
41
|
+
this.namespace = namespace;
|
|
42
|
+
this.variableName = variableName;
|
|
43
|
+
this.variableValue = variableValue;
|
|
44
|
+
}
|
|
45
|
+
resolve(namespace, prefix, variableName) {
|
|
46
|
+
if (this.namespace === namespace && this.variableName === variableName) {
|
|
47
|
+
return this.variableValue;
|
|
48
|
+
}
|
|
49
|
+
return this.parent?.resolve(namespace, prefix, variableName);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class ChainedResolver {
|
|
53
|
+
constructor(resolvers) {
|
|
54
|
+
this.resolvers = resolvers;
|
|
55
|
+
}
|
|
56
|
+
resolve(namespace, prefix, variableName) {
|
|
57
|
+
for (const resolver of this.resolvers) {
|
|
58
|
+
const s = resolver.resolve(namespace, prefix, variableName);
|
|
59
|
+
if (s !== undefined) {
|
|
60
|
+
return s;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface StackElement<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
parent?: StackElement<T>;
|
|
4
|
+
}
|
|
5
|
+
export declare function head<T>(value: T): StackElement<T>;
|
|
6
|
+
export declare function push<T>(head: StackElement<T> | undefined, value: T): StackElement<T>;
|
|
7
|
+
export declare function concat<T>(tail: StackElement<T> | undefined, stack: StackElement<T> | undefined): StackElement<T> | undefined;
|
|
8
|
+
export declare function fromArray<T = any>(t: T[] | undefined): StackElement<T> | undefined;
|
|
9
|
+
export declare function reduce<T, R>(head: StackElement<T> | undefined, reducer: (r: R, t: T) => R, initial: R): R;
|
|
10
|
+
declare function equal<T>(a: StackElement<T> | null | undefined, b: StackElement<T> | null | undefined): boolean;
|
|
11
|
+
declare const stack: {
|
|
12
|
+
push: typeof push;
|
|
13
|
+
head: typeof head;
|
|
14
|
+
concat: typeof concat;
|
|
15
|
+
reduce: typeof reduce;
|
|
16
|
+
fromArray: typeof fromArray;
|
|
17
|
+
equal: typeof equal;
|
|
18
|
+
};
|
|
19
|
+
export default stack;
|
|
20
|
+
//# sourceMappingURL=core-utils-stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils-stack.d.ts","sourceRoot":"","sources":["../src/core-utils-stack.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAG,CAAC,CAAA;IACT,MAAM,CAAC,EAAG,YAAY,CAAC,CAAC,CAAC,CAAA;CAC1B;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAG,CAAC,GAAI,YAAY,CAAC,CAAC,CAAC,CAEnD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,KAAK,EAAG,CAAC,GAAI,YAAY,CAAC,CAAC,CAAC,CAEvF;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,KAAK,EAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,GAAI,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAO/H;AAED,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAG,CAAC,EAAE,GAAG,SAAS,GAAI,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAEpF;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAG,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,EAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAG,CAAC,KAAK,CAAC,EAAE,OAAO,EAAG,CAAC,GAAI,CAAC,CAQ9G;AAED,iBAAS,KAAK,CAAC,CAAC,EAAE,CAAC,EAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,EAAG,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAI,OAAO,CAqBxG;AAED,QAAA,MAAM,KAAK;;;;;;;CAAiD,CAAA;AAE5D,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function head(value) {
|
|
2
|
+
return { value };
|
|
3
|
+
}
|
|
4
|
+
export function push(head, value) {
|
|
5
|
+
return { value, parent: head };
|
|
6
|
+
}
|
|
7
|
+
export function concat(tail, stack) {
|
|
8
|
+
if (tail === undefined)
|
|
9
|
+
return stack;
|
|
10
|
+
if (stack === undefined)
|
|
11
|
+
return tail;
|
|
12
|
+
const { parent, value } = stack;
|
|
13
|
+
return { value, parent: concat(tail, parent) };
|
|
14
|
+
}
|
|
15
|
+
export function fromArray(t) {
|
|
16
|
+
return t?.reduce((acc, t) => push(acc, t), undefined);
|
|
17
|
+
}
|
|
18
|
+
export function reduce(head, reducer, initial) {
|
|
19
|
+
if (head === undefined) {
|
|
20
|
+
return initial;
|
|
21
|
+
}
|
|
22
|
+
const { parent, value } = head;
|
|
23
|
+
const acc = reduce(parent, reducer, initial);
|
|
24
|
+
return reducer(acc, value);
|
|
25
|
+
}
|
|
26
|
+
function equal(a, b) {
|
|
27
|
+
// Not equal if both are nullish
|
|
28
|
+
if (a === undefined || a === null || b === undefined || b === null) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
while (a !== undefined && b !== undefined) {
|
|
32
|
+
if (a.value !== b.value) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
a = a.parent;
|
|
36
|
+
b = b.parent;
|
|
37
|
+
}
|
|
38
|
+
// Equal if traversed all stack at both side
|
|
39
|
+
if ((a === undefined || a === null) && (b === undefined || b === null)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const stack = { push, head, concat, reduce, fromArray, equal };
|
|
47
|
+
export default stack;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface HKT3<Obj, Key extends PropertyKey, Value> {
|
|
2
|
+
_Obj: Obj;
|
|
3
|
+
_Key: Key;
|
|
4
|
+
_Value: Value;
|
|
5
|
+
_Result: unknown;
|
|
6
|
+
}
|
|
7
|
+
export type Apply3<F extends HKT3<any, any, any>, Obj, Key extends PropertyKey, Value> = (F & {
|
|
8
|
+
_Obj: Obj;
|
|
9
|
+
_Key: Key;
|
|
10
|
+
_Value: Value;
|
|
11
|
+
})["_Result"];
|
|
12
|
+
//# sourceMappingURL=core-utils-types-hkt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils-types-hkt.d.ts","sourceRoot":"","sources":["../src/core-utils-types-hkt.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,WAAW,EAAE,KAAK;IACvD,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,WAAW,EAAE,KAAK,IACnF,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Apply3, HKT3 } from "./core-utils-types-hkt";
|
|
2
|
+
export type TypedObject<T extends string = string> = {
|
|
3
|
+
type: T;
|
|
4
|
+
};
|
|
5
|
+
export type AnyFunction = (...args: any[]) => any;
|
|
6
|
+
/**
|
|
7
|
+
* Intended to hold value which can be undefined.
|
|
8
|
+
* It helps to know if a value (incl. undefined) is present or not.
|
|
9
|
+
*/
|
|
10
|
+
export interface Holder<T = any> {
|
|
11
|
+
value: T;
|
|
12
|
+
}
|
|
13
|
+
export declare function holder<T = any>(value: T): Holder<T>;
|
|
14
|
+
export interface GenericReason {
|
|
15
|
+
code?: string;
|
|
16
|
+
message?: string;
|
|
17
|
+
parameters?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
export type GenericError = GenericReason;
|
|
20
|
+
export type ExpressionString = string;
|
|
21
|
+
export interface HyperLayerNode<T> {
|
|
22
|
+
keys?: Record<PropertyKey, any>;
|
|
23
|
+
data?: T;
|
|
24
|
+
children?: Record<string, HyperLayerNode<T>> | Array<HyperLayerNode<T>>;
|
|
25
|
+
}
|
|
26
|
+
export declare function hyper<T>(data: T, children?: Record<string, HyperLayerNode<T>> | Array<HyperLayerNode<T>>): HyperLayerNode<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Utility function that create Overlay which mirror original object
|
|
29
|
+
* @param o
|
|
30
|
+
*/
|
|
31
|
+
export declare function hyperReflect(o: any): HyperLayerNode<any>;
|
|
32
|
+
export type HyperLayerNodeHKT<T, F extends HKT3<any, any, any>, Host = never, Key extends PropertyKey = never> = T extends Array<infer U> ? {
|
|
33
|
+
data?: Apply3<F, Host, Key, T>;
|
|
34
|
+
children?: HyperLayerNodeHKT<U, F, T, never>[];
|
|
35
|
+
} : T extends Record<string, any> ? {
|
|
36
|
+
data?: Apply3<F, Host, Key, T>;
|
|
37
|
+
children?: {
|
|
38
|
+
[K in keyof T]?: HyperLayerNodeHKT<T[K], F, T, K>;
|
|
39
|
+
};
|
|
40
|
+
} : {
|
|
41
|
+
data?: Apply3<F, Host, Key, T>;
|
|
42
|
+
};
|
|
43
|
+
export interface OverlayNodeBase<A> {
|
|
44
|
+
type: "object" | "array" | "scalar";
|
|
45
|
+
annotation?: A;
|
|
46
|
+
}
|
|
47
|
+
export interface ObjectOverlayNode<A> extends OverlayNodeBase<A> {
|
|
48
|
+
type: "object";
|
|
49
|
+
children: Record<string, OverlayNode<A>>;
|
|
50
|
+
}
|
|
51
|
+
export interface ArrayOverlayNode<A> extends OverlayNodeBase<A> {
|
|
52
|
+
type: "array";
|
|
53
|
+
children: Array<OverlayNode<A>>;
|
|
54
|
+
}
|
|
55
|
+
export interface ScalarOverlayNode<A> extends OverlayNodeBase<A> {
|
|
56
|
+
type: "scalar";
|
|
57
|
+
}
|
|
58
|
+
export type OverlayNode<A> = ObjectOverlayNode<A> | ArrayOverlayNode<A> | ScalarOverlayNode<A>;
|
|
59
|
+
export interface Annotation<A> {
|
|
60
|
+
annotation?: A;
|
|
61
|
+
}
|
|
62
|
+
export type Overlay<T, A> = T extends Array<infer U> ? {
|
|
63
|
+
type: "array";
|
|
64
|
+
children: Overlay<U, A>[];
|
|
65
|
+
} & Annotation<A> : T extends Record<string, any> ? {
|
|
66
|
+
type: "object";
|
|
67
|
+
children: {
|
|
68
|
+
[K in keyof T]?: Overlay<T[K], A>;
|
|
69
|
+
};
|
|
70
|
+
} & Annotation<A> : {
|
|
71
|
+
type: "scalar";
|
|
72
|
+
} & Annotation<A>;
|
|
73
|
+
/**
|
|
74
|
+
* Mainly used to prevent re-entrant navitation
|
|
75
|
+
*/
|
|
76
|
+
export declare class ExplorationContext<T> {
|
|
77
|
+
readonly parent: ExplorationContext<T> | undefined;
|
|
78
|
+
readonly values: T[];
|
|
79
|
+
constructor(parent: ExplorationContext<T> | undefined, values: T[]);
|
|
80
|
+
explored(t: T): boolean;
|
|
81
|
+
newChild(values: T[]): ExplorationContext<T>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=core-utils-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils-types.d.ts","sourceRoot":"","sources":["../src/core-utils-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAEpD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAAC,IAAI,EAAG,CAAC,CAAA;CAAC,CAAA;AAC/D,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAG,GAAG,EAAE,KAAK,GAAG,CAAA;AAElD;;;GAGG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,GAAG;IAC7B,KAAK,EAAC,CAAC,CAAA;CACR;AACD,wBAAgB,MAAM,CAAC,CAAC,GAAC,GAAG,EAAE,KAAK,EAAG,CAAC,GAAI,MAAM,CAAC,CAAC,CAAC,CAEnD;AAED,MAAM,WAAW,aAAa;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AC3B,UAAU,CAAC,EAAE,CAAC,CAAC;CAChB;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IACtB,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;CAC3B,GAAG,UAAU,CAAC,CAAC,CAAC,GACf,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE;SACP,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAClC,CAAC;CACH,GAAG,UAAU,CAAC,CAAC,CAAC,GACf;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAGxB;;GAEG;AACH,qBAAa,kBAAkB,CAAC,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAG,CAAC,EAAE;gBAAjE,MAAM,EAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,SAAS,EAAW,MAAM,EAAG,CAAC,EAAE;IAGtF,QAAQ,CAAC,CAAC,EAAG,CAAC,GAAI,OAAO;IAIzB,QAAQ,CAAC,MAAM,EAAG,CAAC,EAAE,GAAG,kBAAkB,CAAC,CAAC,CAAC;CAG9C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function holder(value) {
|
|
2
|
+
return { value };
|
|
3
|
+
}
|
|
4
|
+
export function hyper(data, children) {
|
|
5
|
+
return { data, children };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Utility function that create Overlay which mirror original object
|
|
9
|
+
* @param o
|
|
10
|
+
*/
|
|
11
|
+
export function hyperReflect(o) {
|
|
12
|
+
if (o === null || o === undefined) {
|
|
13
|
+
return hyper(o);
|
|
14
|
+
}
|
|
15
|
+
else if (Array.isArray(o)) {
|
|
16
|
+
return hyper(o, o.map(e => hyperReflect(e)));
|
|
17
|
+
}
|
|
18
|
+
else if (typeof o === "object") {
|
|
19
|
+
return hyper(o, Object.entries(o).reduce((acc, [k, v]) => ({ ...acc, [k]: hyperReflect(v) }), {}));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return hyper(o);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Mainly used to prevent re-entrant navitation
|
|
27
|
+
*/
|
|
28
|
+
export class ExplorationContext {
|
|
29
|
+
constructor(parent, values) {
|
|
30
|
+
this.parent = parent;
|
|
31
|
+
this.values = values;
|
|
32
|
+
}
|
|
33
|
+
explored(t) {
|
|
34
|
+
return this.values.includes(t);
|
|
35
|
+
}
|
|
36
|
+
newChild(values) {
|
|
37
|
+
return new ExplorationContext(this, values);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface NodeValidation {
|
|
2
|
+
type: "core:node-validation";
|
|
3
|
+
notes: ValidationNote[];
|
|
4
|
+
}
|
|
5
|
+
export interface ValidationNote {
|
|
6
|
+
uuid?: string;
|
|
7
|
+
severity: "info" | "warning" | "error";
|
|
8
|
+
key?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
params?: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
declare class NoteUtils {
|
|
13
|
+
add(nv: NodeValidation, ...notes: ValidationNote[]): NodeValidation;
|
|
14
|
+
of(...notes: ValidationNote[]): NodeValidation;
|
|
15
|
+
info(key?: string, message?: string, params?: Record<string, any>): ValidationNote;
|
|
16
|
+
warning(key?: string, message?: string, params?: Record<string, any>): ValidationNote;
|
|
17
|
+
error(key?: string, message?: string, params?: Record<string, any>): ValidationNote;
|
|
18
|
+
}
|
|
19
|
+
export declare const notes: NoteUtils;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=core-utils-validations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils-validations.d.ts","sourceRoot":"","sources":["../src/core-utils-validations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAG,cAAc,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAA;IACvC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC7B;AAGD,cAAM,SAAS;IACb,GAAG,CAAC,EAAE,EAAG,cAAc,EAAE,GAAG,KAAK,EAAG,cAAc,EAAE,GAAI,cAAc;IAGtE,EAAE,CAAC,GAAG,KAAK,EAAG,cAAc,EAAE,GAAI,cAAc;IAGhD,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc;IAIlF,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc;IAIrF,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc;CAGpF;AAGD,eAAO,MAAM,KAAK,WAAkB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class NoteUtils {
|
|
2
|
+
add(nv, ...notes) {
|
|
3
|
+
return { ...(nv ?? { type: "core:node-validation" }), notes };
|
|
4
|
+
}
|
|
5
|
+
of(...notes) {
|
|
6
|
+
return { type: "core:node-validation", notes };
|
|
7
|
+
}
|
|
8
|
+
info(key, message, params) {
|
|
9
|
+
return { severity: "info", key, message, params };
|
|
10
|
+
}
|
|
11
|
+
warning(key, message, params) {
|
|
12
|
+
return { severity: "warning", key, message, params };
|
|
13
|
+
}
|
|
14
|
+
error(key, message, params) {
|
|
15
|
+
return { severity: "error", key, message, params };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const notes = new NoteUtils();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare function includes<T extends U, U>(arr: Array<T>, t: U): t is U;
|
|
2
|
+
export declare function isNonNullObject(data: any): boolean;
|
|
3
|
+
declare function isBlank(s: string): boolean;
|
|
4
|
+
declare function isDefined(data: any): boolean;
|
|
5
|
+
declare function isNotDefined(data: any): boolean;
|
|
6
|
+
export declare function isNullish(o: any): o is (null | undefined);
|
|
7
|
+
export declare function isEmptyObject(object: Record<any, any>): boolean;
|
|
8
|
+
export declare function equalSet(a: Set<unknown>, b: Set<unknown>): boolean;
|
|
9
|
+
export type EqualFn<T> = (a: T, b: T) => boolean;
|
|
10
|
+
export declare const DEFAULT_EQUAL_FN: EqualFn<any>;
|
|
11
|
+
export declare function areSameDefined<T>(a: T | undefined, b: T | undefined, equalFn?: EqualFn<T>): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Warning: non performant O(n2)
|
|
14
|
+
* @param arr
|
|
15
|
+
* @param equals
|
|
16
|
+
*/
|
|
17
|
+
export declare function removeDuplicates<T>(arr: T[], equals?: EqualFn<T>): T[];
|
|
18
|
+
declare function intersection<T>(o1: Record<string, T>, o2: Record<string, T>): string[];
|
|
19
|
+
declare function deepEqual(obj1: any, obj2: any): boolean;
|
|
20
|
+
declare function escapeForXPath(input: string): string;
|
|
21
|
+
export type ArrayFilterFn<T> = (value: T, index: number, array: Array<T>) => boolean;
|
|
22
|
+
declare function cascadeFilter<T>(arr: Array<T>, fns: ArrayFilterFn<T>[]): Array<T>;
|
|
23
|
+
export declare const utils: {
|
|
24
|
+
includes: typeof includes;
|
|
25
|
+
isNonNullObject: typeof isNonNullObject;
|
|
26
|
+
isEmptyObject: typeof isEmptyObject;
|
|
27
|
+
equalSet: typeof equalSet;
|
|
28
|
+
isDefined: typeof isDefined;
|
|
29
|
+
isBlank: typeof isBlank;
|
|
30
|
+
isNotDefined: typeof isNotDefined;
|
|
31
|
+
removeDuplicates: typeof removeDuplicates;
|
|
32
|
+
areSameDefined: typeof areSameDefined;
|
|
33
|
+
intersection: typeof intersection;
|
|
34
|
+
deepEqual: typeof deepEqual;
|
|
35
|
+
escapeForXPath: typeof escapeForXPath;
|
|
36
|
+
cascadeFilter: typeof cascadeFilter;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=core-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-utils.d.ts","sourceRoot":"","sources":["../src/core-utils.ts"],"names":[],"mappings":"AAAA,iBAAS,QAAQ,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAG,GAAG,EAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAG,CAAC,GAAI,CAAC,IAAI,CAAC,CAEjE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAG,GAAG,GAAI,OAAO,CAOpD;AAGD,iBAAS,OAAO,CAAC,CAAC,EAAG,MAAM,GAAI,OAAO,CAErC;AAED,iBAAS,SAAS,CAAC,IAAI,EAAG,GAAG,GAAI,OAAO,CAEvC;AAED,iBAAS,YAAY,CAAC,IAAI,EAAG,GAAG,GAAI,OAAO,CAE1C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAG,GAAG,GAAI,CAAC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,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