@milaboratories/pl-model-common 1.13.8 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +297 -271
- package/dist/index.mjs.map +1 -1
- package/dist/ref.d.ts +33 -2
- package/dist/ref.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ref.ts +53 -5
package/dist/ref.d.ts
CHANGED
|
@@ -3,14 +3,17 @@ export declare const PlRef: z.ZodReadonly<z.ZodObject<{
|
|
|
3
3
|
__isRef: z.ZodLiteral<true>;
|
|
4
4
|
blockId: z.ZodString;
|
|
5
5
|
name: z.ZodString;
|
|
6
|
-
|
|
6
|
+
requireEnrichments: z.ZodOptional<z.ZodLiteral<true>>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
8
|
__isRef: true;
|
|
8
9
|
blockId: string;
|
|
9
10
|
name: string;
|
|
11
|
+
requireEnrichments?: true | undefined;
|
|
10
12
|
}, {
|
|
11
13
|
__isRef: true;
|
|
12
14
|
blockId: string;
|
|
13
15
|
name: string;
|
|
16
|
+
requireEnrichments?: true | undefined;
|
|
14
17
|
}>>;
|
|
15
18
|
export type PlRef = z.infer<typeof PlRef>;
|
|
16
19
|
/** @deprecated use {@link PlRef} */
|
|
@@ -31,6 +34,34 @@ export type Option = {
|
|
|
31
34
|
/** Label to be present for the user in i.e. drop-down list */
|
|
32
35
|
readonly label: string;
|
|
33
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Creates a PlRef with the given blockId and name.
|
|
39
|
+
*
|
|
40
|
+
* @param blockId - The blockId of the reference.
|
|
41
|
+
* @param name - The name of the reference.
|
|
42
|
+
* @param requireEnrichments - Whether the reference requires enrichments.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createPlRef(blockId: string, name: string, requireEnrichments?: boolean): {
|
|
45
|
+
__isRef: boolean;
|
|
46
|
+
blockId: string;
|
|
47
|
+
name: string;
|
|
48
|
+
requireEnrichments: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
__isRef: boolean;
|
|
51
|
+
blockId: string;
|
|
52
|
+
name: string;
|
|
53
|
+
requireEnrichments?: undefined;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new PlRef based on an existing one, explicitly setting (default) or removing the
|
|
57
|
+
* requireEnrichments property.
|
|
58
|
+
*
|
|
59
|
+
* @param ref - The original PlRef object.
|
|
60
|
+
* @param requireEnrichments - If true, the `requireEnrichments: true` property is added
|
|
61
|
+
* to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.
|
|
62
|
+
* @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.
|
|
63
|
+
*/
|
|
64
|
+
export declare function withEnrichments(ref: PlRef, requireEnrichments?: boolean): PlRef;
|
|
34
65
|
/** Compare two PlRefs and returns true if they are qual */
|
|
35
|
-
export declare function plRefsEqual(ref1: PlRef, ref2: PlRef): boolean;
|
|
66
|
+
export declare function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments?: boolean): boolean;
|
|
36
67
|
//# sourceMappingURL=ref.d.ts.map
|
package/dist/ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../src/ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../src/ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;GAkBL,CAAC;AACd,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAC1C,oCAAoC;AACpC,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAStD;AAED;qCACqC;AACrC,MAAM,MAAM,MAAM,GAAG;IACnB;cACU;IACV,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC;IAEpB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,kBAAkB,GAAE,OAAe;;;;;;;;;;EAc7F;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,kBAAkB,GAAE,OAAc,GAAG,KAAK,CAUrF;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,GAAE,OAAe,WAEvF"}
|
package/package.json
CHANGED
package/src/ref.ts
CHANGED
|
@@ -5,15 +5,19 @@ export const PlRef = z
|
|
|
5
5
|
__isRef: z
|
|
6
6
|
.literal(true)
|
|
7
7
|
.describe('Crucial marker for the block dependency tree reconstruction'),
|
|
8
|
-
blockId: z.string()
|
|
9
|
-
|
|
8
|
+
blockId: z.string()
|
|
9
|
+
.describe('Upstream block id'),
|
|
10
|
+
name: z.string()
|
|
11
|
+
.describe('Name of the output provided to the upstream block\'s output context'),
|
|
12
|
+
requireEnrichments: z.literal(true).optional()
|
|
13
|
+
.describe('True if current block that stores this reference in its args, may need enrichments '
|
|
14
|
+
+ 'for the references value originating from the blocks in between current and referenced block'),
|
|
10
15
|
})
|
|
11
16
|
.describe(
|
|
12
17
|
'Universal reference type, allowing to set block connections. It is crucial that '
|
|
13
18
|
+ '{@link __isRef} is present and equal to true, internal logic relies on this marker '
|
|
14
19
|
+ 'to build block dependency trees.',
|
|
15
20
|
)
|
|
16
|
-
.strict()
|
|
17
21
|
.readonly();
|
|
18
22
|
export type PlRef = z.infer<typeof PlRef>;
|
|
19
23
|
/** @deprecated use {@link PlRef} */
|
|
@@ -47,7 +51,51 @@ export type Option = {
|
|
|
47
51
|
readonly label: string;
|
|
48
52
|
};
|
|
49
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Creates a PlRef with the given blockId and name.
|
|
56
|
+
*
|
|
57
|
+
* @param blockId - The blockId of the reference.
|
|
58
|
+
* @param name - The name of the reference.
|
|
59
|
+
* @param requireEnrichments - Whether the reference requires enrichments.
|
|
60
|
+
*/
|
|
61
|
+
export function createPlRef(blockId: string, name: string, requireEnrichments: boolean = false) {
|
|
62
|
+
if (requireEnrichments)
|
|
63
|
+
return {
|
|
64
|
+
__isRef: true,
|
|
65
|
+
blockId,
|
|
66
|
+
name,
|
|
67
|
+
requireEnrichments: true,
|
|
68
|
+
};
|
|
69
|
+
else
|
|
70
|
+
return {
|
|
71
|
+
__isRef: true,
|
|
72
|
+
blockId,
|
|
73
|
+
name,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new PlRef based on an existing one, explicitly setting (default) or removing the
|
|
79
|
+
* requireEnrichments property.
|
|
80
|
+
*
|
|
81
|
+
* @param ref - The original PlRef object.
|
|
82
|
+
* @param requireEnrichments - If true, the `requireEnrichments: true` property is added
|
|
83
|
+
* to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.
|
|
84
|
+
* @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.
|
|
85
|
+
*/
|
|
86
|
+
export function withEnrichments(ref: PlRef, requireEnrichments: boolean = true): PlRef {
|
|
87
|
+
if (requireEnrichments)
|
|
88
|
+
return {
|
|
89
|
+
...ref,
|
|
90
|
+
requireEnrichments: true,
|
|
91
|
+
};
|
|
92
|
+
else {
|
|
93
|
+
const { requireEnrichments: _, ...rest } = ref;
|
|
94
|
+
return rest;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
50
98
|
/** Compare two PlRefs and returns true if they are qual */
|
|
51
|
-
export function plRefsEqual(ref1: PlRef, ref2: PlRef) {
|
|
52
|
-
return ref1.blockId === ref2.blockId && ref1.name === ref2.name;
|
|
99
|
+
export function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments: boolean = false) {
|
|
100
|
+
return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);
|
|
53
101
|
}
|