@milaboratories/pl-model-common 1.13.8 → 1.14.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/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
- }, "strict", z.ZodTypeAny, {
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;;;;;;;;;;;;GAcL,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,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,WAEnD"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-common",
3
- "version": "1.13.8",
3
+ "version": "1.14.1",
4
4
  "description": "Platforma SDK Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "@milaboratories/pl-error-like": "1.12.1"
23
23
  },
24
24
  "devDependencies": {
25
- "eslint": "^9.23.0",
25
+ "eslint": "^9.25.1",
26
26
  "typescript": "~5.5.4",
27
27
  "vite": "^5.4.11",
28
28
  "vitest": "^2.1.8",
@@ -2,6 +2,8 @@ import type { PTableColumnId, PTableColumnSpec } from './table_common';
2
2
  import type { PTableVector } from './data_types';
3
3
  import type { PObjectId } from '../../pool';
4
4
  import { assertNever } from '../../util';
5
+ import type { PColumn } from './spec/spec';
6
+ import type { PColumnValues } from './data_info';
5
7
 
6
8
  /** Defines a terminal column node in the join request tree */
7
9
  export interface ColumnJoinEntry<Col> {
@@ -42,6 +44,15 @@ export interface SlicedColumnJoinEntry<Col> {
42
44
  readonly axisFilters: ConstantAxisFilter[];
43
45
  }
44
46
 
47
+ /** Defines a terminal column node in the join request tree */
48
+ export interface InlineColumnJoinEntry {
49
+ /** Node type discriminator */
50
+ readonly type: 'inlineColumn';
51
+
52
+ /** Column definition */
53
+ readonly column: PColumn<PColumnValues>;
54
+ }
55
+
45
56
  /**
46
57
  * Defines a join request tree node that will output only records present in
47
58
  * all child nodes ({@link entries}).
@@ -100,6 +111,7 @@ export interface OuterJoin<Col> {
100
111
  export type JoinEntry<Col> =
101
112
  | ColumnJoinEntry<Col>
102
113
  | SlicedColumnJoinEntry<Col>
114
+ | InlineColumnJoinEntry
103
115
  | InnerJoin<Col>
104
116
  | FullJoin<Col>
105
117
  | OuterJoin<Col>;
@@ -364,6 +376,8 @@ export function mapJoinEntry<C1, C2>(
364
376
  newId: entry.newId,
365
377
  axisFilters: entry.axisFilters,
366
378
  };
379
+ case 'inlineColumn':
380
+ return entry;
367
381
  case 'inner':
368
382
  case 'full':
369
383
  return {
package/src/pool/spec.ts CHANGED
@@ -88,6 +88,8 @@ export function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[]
88
88
  case 'slicedColumn':
89
89
  columns.set(entry.column.id, entry.column);
90
90
  return;
91
+ case 'inlineColumn':
92
+ return;
91
93
  case 'full':
92
94
  case 'inner':
93
95
  for (const e of entry.entries) addAllColumns(e);
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().describe('Upstream block id'),
9
- name: z.string().describe('Name of the output provided to the upstream block\'s output context'),
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
  }