@hamak/navigation-utils 0.4.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.
Files changed (49) hide show
  1. package/README.md +82 -0
  2. package/dist/es2015/filesystem/fs-node-abstract.types.js +1 -0
  3. package/dist/es2015/index.js +9 -0
  4. package/dist/es2015/itinerary/hyper-layer-node.js +21 -0
  5. package/dist/es2015/itinerary/itinerary.js +276 -0
  6. package/dist/es2015/itinerary/itinerary.spec.js +296 -0
  7. package/dist/es2015/itinerary/stack.js +47 -0
  8. package/dist/es2015/itinerary/stack.spec.js +35 -0
  9. package/dist/es2015/path/pathway-resolver.js +31 -0
  10. package/dist/es2015/path/pathway.js +206 -0
  11. package/dist/filesystem/fs-node-abstract.types.d.ts +34 -0
  12. package/dist/filesystem/fs-node-abstract.types.d.ts.map +1 -0
  13. package/dist/filesystem/fs-node-abstract.types.js +1 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +9 -0
  17. package/dist/itinerary/hyper-layer-node.d.ts +12 -0
  18. package/dist/itinerary/hyper-layer-node.d.ts.map +1 -0
  19. package/dist/itinerary/hyper-layer-node.js +21 -0
  20. package/dist/itinerary/itinerary.d.ts +86 -0
  21. package/dist/itinerary/itinerary.d.ts.map +1 -0
  22. package/dist/itinerary/itinerary.js +275 -0
  23. package/dist/itinerary/itinerary.spec.d.ts +2 -0
  24. package/dist/itinerary/itinerary.spec.d.ts.map +1 -0
  25. package/dist/itinerary/itinerary.spec.js +294 -0
  26. package/dist/itinerary/stack.d.ts +20 -0
  27. package/dist/itinerary/stack.d.ts.map +1 -0
  28. package/dist/itinerary/stack.js +47 -0
  29. package/dist/itinerary/stack.spec.d.ts +2 -0
  30. package/dist/itinerary/stack.spec.d.ts.map +1 -0
  31. package/dist/itinerary/stack.spec.js +34 -0
  32. package/dist/path/pathway-resolver.d.ts +20 -0
  33. package/dist/path/pathway-resolver.d.ts.map +1 -0
  34. package/dist/path/pathway-resolver.js +31 -0
  35. package/dist/path/pathway.d.ts +84 -0
  36. package/dist/path/pathway.d.ts.map +1 -0
  37. package/dist/path/pathway.js +206 -0
  38. package/package.json +41 -0
  39. package/src/filesystem/fs-node-abstract.types.ts +34 -0
  40. package/src/index.ts +11 -0
  41. package/src/itinerary/hyper-layer-node.ts +25 -0
  42. package/src/itinerary/itinerary.spec.ts +388 -0
  43. package/src/itinerary/itinerary.ts +363 -0
  44. package/src/itinerary/stack.spec.ts +46 -0
  45. package/src/itinerary/stack.ts +62 -0
  46. package/src/path/pathway-resolver.ts +36 -0
  47. package/src/path/pathway.ts +232 -0
  48. package/tsconfig.es2015.json +23 -0
  49. package/tsconfig.json +19 -0
@@ -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 === null || t === void 0 ? void 0 : 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,35 @@
1
+ import stack from "./stack";
2
+ import { describe, it, expect } from 'vitest';
3
+ describe("Core util stack", () => {
4
+ it("fromArray should work", () => {
5
+ var _a, _b, _c;
6
+ const itinerary = stack.fromArray([1, 2, 3, 4]);
7
+ expect(itinerary === null || itinerary === void 0 ? void 0 : itinerary.value).toBe(4);
8
+ expect((_c = (_b = (_a = itinerary === null || itinerary === void 0 ? void 0 : itinerary.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.value).toBe(1);
9
+ expect(stack.fromArray([])).toBe(undefined);
10
+ expect(stack.fromArray(undefined)).toBe(undefined);
11
+ });
12
+ it("reduce should work", () => {
13
+ const itinerary = stack.fromArray([1, 2, 3, 4]);
14
+ const result = stack.reduce(itinerary, (acc, t) => acc + t, 0);
15
+ expect(result).toBe(10);
16
+ });
17
+ it("reduce order should work", () => {
18
+ const itinerary = stack.fromArray([1, 2, 3, 4]);
19
+ const result = stack.reduce(itinerary, (acc, t) => [...acc, t], []);
20
+ expect(result).toStrictEqual([1, 2, 3, 4]);
21
+ });
22
+ it("equal should work", () => {
23
+ expect(stack.equal(undefined, undefined)).toBe(false);
24
+ expect(stack.equal(null, null)).toBe(false);
25
+ expect(stack.equal(undefined, null)).toBe(false);
26
+ expect(stack.equal(null, undefined)).toBe(false);
27
+ expect(stack.equal(stack.fromArray([1, 2, 3, 4]), undefined)).toBe(false);
28
+ expect(stack.equal(stack.fromArray([1, 2, 3, 4]), null)).toBe(false);
29
+ expect(stack.equal(undefined, stack.fromArray([1, 2, 3, 4]))).toBe(false);
30
+ expect(stack.equal(null, stack.fromArray([1, 2, 3, 4]))).toBe(false);
31
+ expect(stack.equal(stack.fromArray([1]), stack.fromArray([2]))).toBe(false);
32
+ expect(stack.equal(stack.fromArray([1]), stack.fromArray([1, 2]))).toBe(false);
33
+ expect(stack.equal(stack.fromArray([1, 2, 3, 4]), stack.fromArray([1, 2, 3, 4]))).toBe(true);
34
+ });
35
+ });
@@ -0,0 +1,31 @@
1
+ import { Pathway } from "./pathway";
2
+ export class RecordPathwayResolver {
3
+ constructor(record) {
4
+ this.record = record;
5
+ }
6
+ resolve(path) {
7
+ const key = Pathway.asString(path);
8
+ return this.record[key];
9
+ }
10
+ }
11
+ export class EmptyPathwayResolver {
12
+ resolve(path) {
13
+ return undefined;
14
+ }
15
+ }
16
+ export class RelativePathwayResolver {
17
+ constructor(parentResolver, path) {
18
+ this.parentResolver = parentResolver;
19
+ this.path = path;
20
+ this.relativePathway = Pathway.of(path);
21
+ }
22
+ resolve(path) {
23
+ const pathway = Pathway.of(path);
24
+ if (pathway.isAbsolute()) {
25
+ return this.parentResolver.resolve(path);
26
+ }
27
+ else {
28
+ return this.parentResolver.resolve(this.relativePathway.resolve(pathway));
29
+ }
30
+ }
31
+ }
@@ -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,34 @@
1
+ /**
2
+ * Schema information for file content
3
+ */
4
+ export type FileContentSchema = string | {
5
+ schemaObject: string;
6
+ namespace?: string;
7
+ };
8
+ /**
9
+ * Base interface for filesystem nodes (without state)
10
+ */
11
+ export interface AbstractFileSystemNodeBase {
12
+ type: 'directory' | 'file';
13
+ name: string;
14
+ }
15
+ /**
16
+ * Abstract directory node (without state management)
17
+ */
18
+ export interface AbstractDirectoryNode<T extends AbstractFileSystemNodeBase = AbstractFileSystemNode> extends AbstractFileSystemNodeBase {
19
+ type: 'directory';
20
+ children: Record<string, T>;
21
+ }
22
+ /**
23
+ * Abstract file node (without state management)
24
+ */
25
+ export interface AbstractFileNode<T = any> extends AbstractFileSystemNodeBase {
26
+ type: 'file';
27
+ content: T;
28
+ schema: string | FileContentSchema;
29
+ }
30
+ /**
31
+ * Union type for abstract filesystem nodes
32
+ */
33
+ export type AbstractFileSystemNode = AbstractDirectoryNode | AbstractFileNode;
34
+ //# sourceMappingURL=fs-node-abstract.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-node-abstract.types.d.ts","sourceRoot":"","sources":["../../src/filesystem/fs-node-abstract.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAErF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,0BAA0B,GAAG,sBAAsB,CAAE,SAAQ,0BAA0B;IACtI,IAAI,EAAE,WAAW,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,0BAA0B;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,CAAC,CAAA;IACV,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,GAAG,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './path/pathway';
2
+ export * from './path/pathway-resolver';
3
+ export * from './itinerary/itinerary';
4
+ export * from './itinerary/stack';
5
+ export * from './itinerary/hyper-layer-node';
6
+ export * from './filesystem/fs-node-abstract.types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AAGxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAG7C,cAAc,qCAAqC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // Path utilities
2
+ export * from './path/pathway';
3
+ export * from './path/pathway-resolver';
4
+ // Itinerary utilities
5
+ export * from './itinerary/itinerary';
6
+ export * from './itinerary/stack';
7
+ export * from './itinerary/hyper-layer-node';
8
+ // Filesystem abstractions
9
+ export * from './filesystem/fs-node-abstract.types';
@@ -0,0 +1,12 @@
1
+ export interface HyperLayerNode<T> {
2
+ keys?: Record<PropertyKey, any>;
3
+ data?: T;
4
+ children?: Record<string, HyperLayerNode<T>> | Array<HyperLayerNode<T>>;
5
+ }
6
+ export declare function hyper<T>(data: T, children?: Record<string, HyperLayerNode<T>> | Array<HyperLayerNode<T>>): HyperLayerNode<T>;
7
+ /**
8
+ * Utility function that create Overlay which mirror original object
9
+ * @param o
10
+ */
11
+ export declare function hyperReflect(o: any): HyperLayerNode<any>;
12
+ //# sourceMappingURL=hyper-layer-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyper-layer-node.d.ts","sourceRoot":"","sources":["../../src/itinerary/hyper-layer-node.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;IAC/B,IAAI,CAAC,EAAG,CAAC,CAAA;IACT,QAAQ,CAAC,EAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;CACzE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAI,cAAc,CAAC,CAAC,CAAC,CAE9H;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAG,GAAG,GAAI,cAAc,CAAC,GAAG,CAAC,CAU1D"}
@@ -0,0 +1,21 @@
1
+ export function hyper(data, children) {
2
+ return { data, children };
3
+ }
4
+ /**
5
+ * Utility function that create Overlay which mirror original object
6
+ * @param o
7
+ */
8
+ export function hyperReflect(o) {
9
+ if (o === null || o === undefined) {
10
+ return hyper(o);
11
+ }
12
+ else if (Array.isArray(o)) {
13
+ return hyper(o, o.map(e => hyperReflect(e)));
14
+ }
15
+ else if (typeof o === "object") {
16
+ return hyper(o, Object.entries(o).reduce((acc, [k, v]) => ({ ...acc, [k]: hyperReflect(v) }), {}));
17
+ }
18
+ else {
19
+ return hyper(o);
20
+ }
21
+ }
@@ -0,0 +1,86 @@
1
+ import { StackElement } from "./stack";
2
+ import { HyperLayerNode } from "./hyper-layer-node";
3
+ export type ObjectId = string | number;
4
+ interface PropertyValuePair<P = string, V = any> {
5
+ propertyName: P;
6
+ propertyValue: V;
7
+ }
8
+ export interface ItineraryStepBase {
9
+ type: "property" | "lookup" | "position";
10
+ }
11
+ export interface PropertyStep extends ItineraryStepBase {
12
+ type: "property";
13
+ propertyName: string;
14
+ }
15
+ export interface LookupStep extends ItineraryStepBase {
16
+ type: "lookup";
17
+ keys: PropertyValuePair[];
18
+ }
19
+ export interface PositionStep extends ItineraryStepBase {
20
+ type: "position";
21
+ position: number;
22
+ }
23
+ export type ItineraryStep = PropertyStep | LookupStep | PositionStep;
24
+ export type Itinerary = StackElement<ItineraryStep>;
25
+ export interface ConstructiveItinerary {
26
+ itinerary: Itinerary | undefined;
27
+ prototypes: StackElement<any> | undefined;
28
+ }
29
+ export type StepValueNodeType = Array<any> | Record<string | number, any>;
30
+ export declare function constructiveItinerary(steps: Array<string | number | StepValueNodeType>): ConstructiveItinerary;
31
+ export declare function areSameItineraryStep(step1: ItineraryStep | null | undefined, step2: ItineraryStep | null | undefined): boolean;
32
+ export declare function itineraryOf(...args: (string | number)[]): Itinerary | undefined;
33
+ export declare function itineraryOverlay(it: Itinerary | undefined): Itinerary;
34
+ export declare function itineraryToStepArray(itinerary: Itinerary | undefined): ItineraryStep[];
35
+ export declare function propertyStep(propertyName: string): PropertyStep;
36
+ export declare function positionStep(position: number): PositionStep;
37
+ export declare function lookupStep(criteria: Record<string, any>): LookupStep;
38
+ export declare function xpathFromStack(path?: StackElement<ItineraryStep>): string;
39
+ export declare function navigate(from: any, itinerary: Itinerary | undefined, prototype?: StackElement<any>): any;
40
+ export declare function navigateStep(from: any, step: ItineraryStep, prototype?: any): any;
41
+ export declare function navigationDepth(from: any, itinerary: Itinerary | undefined, originalPath?: string): {
42
+ value: any;
43
+ path: string;
44
+ originalPath: string;
45
+ };
46
+ declare class OverlayNavigator {
47
+ navigate<T>(from: HyperLayerNode<T>, itinerary: Itinerary | undefined): HyperLayerNode<T> | undefined;
48
+ protected navigateStep<T>(from: HyperLayerNode<T>, step: ItineraryStep): HyperLayerNode<T> | undefined;
49
+ }
50
+ export declare const overlayNavigator: OverlayNavigator;
51
+ /**
52
+ * Same as {navigate} but try to path missing data node using prototype parameter
53
+ * @param from
54
+ * @param itinerary
55
+ * @param prototype
56
+ */
57
+ export declare function ensurePath(from: any, itinerary: Itinerary | undefined, prototype?: any): any;
58
+ interface PointerBase {
59
+ type: "absolute" | "relative";
60
+ itinerary: ItineraryStep[];
61
+ }
62
+ export interface AbsolutePointer extends PointerBase {
63
+ type: "absolute";
64
+ }
65
+ export interface RelativePointer extends PointerBase {
66
+ type: "relative";
67
+ originUuid: ObjectId;
68
+ }
69
+ declare abstract class AbstractPointerBuilder {
70
+ readonly itinerary: ItineraryStep[];
71
+ child(propertyName: string): this;
72
+ lookup(...criterion: [string, any]): void;
73
+ }
74
+ declare class RelativePointerBuilder extends AbstractPointerBuilder implements RelativePointer {
75
+ originUuid: ObjectId;
76
+ readonly type = "relative";
77
+ constructor(originUuid: ObjectId);
78
+ }
79
+ declare class AbsolutePointerBuilder extends AbstractPointerBuilder implements AbsolutePointer {
80
+ readonly type = "absolute";
81
+ constructor();
82
+ }
83
+ export declare function pointer(fromId?: ObjectId): AbsolutePointerBuilder | RelativePointerBuilder;
84
+ export declare const ROOT: AbsolutePointer;
85
+ export {};
86
+ //# sourceMappingURL=itinerary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"itinerary.d.ts","sourceRoot":"","sources":["../../src/itinerary/itinerary.ts"],"names":[],"mappings":"AAAA,OAAc,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAEtC,UAAU,iBAAiB,CAAC,CAAC,GAAG,MAAM,EAAC,CAAC,GAAG,GAAG;IAC5C,YAAY,EAAG,CAAC,CAAA;IAChB,aAAa,EAAG,CAAC,CAAA;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAA;CAC1C;AAED,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,IAAI,EAAG,UAAU,CAAA;IACjB,YAAY,EAAG,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IACnD,IAAI,EAAG,QAAQ,CAAC;IAChB,IAAI,EAAG,iBAAiB,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,IAAI,EAAG,UAAU,CAAC;IAClB,QAAQ,EAAG,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,CAAA;AAEpE,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,CAAC,CAAA;AA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