@platforma-sdk/model 1.29.17 → 1.30.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/bconfig/normalization.d.ts.map +1 -1
- package/dist/bconfig/v3.d.ts +5 -0
- package/dist/bconfig/v3.d.ts.map +1 -1
- package/dist/builder.d.ts +7 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +402 -372
- package/dist/index.mjs.map +1 -1
- package/dist/render/api.d.ts +16 -0
- package/dist/render/api.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/bconfig/normalization.ts +2 -0
- package/src/bconfig/v3.ts +6 -0
- package/src/builder.ts +34 -1
- package/src/render/api.ts +49 -9
package/dist/render/api.d.ts
CHANGED
|
@@ -13,12 +13,28 @@ type UniversalPColumnOpts = {
|
|
|
13
13
|
labelOps?: LabelDerivationOps;
|
|
14
14
|
dontWaitAllData?: boolean;
|
|
15
15
|
} & ResolveAnchorsOptions;
|
|
16
|
+
type GetOptionsOpts = {
|
|
17
|
+
/**
|
|
18
|
+
* If true, references returned by the method will contain `requireEnrichments` flag set to true.
|
|
19
|
+
* If this reference is added to the block's args, it will communicate to the platform that the block
|
|
20
|
+
* expects enrichments of the referenced block to be available in the context of the current block.
|
|
21
|
+
*/
|
|
22
|
+
requireEnrichments?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Label derivation options.
|
|
25
|
+
* If provided, it will be used to derive labels for the options.
|
|
26
|
+
* If not provided, labels will be derived using the default logic.
|
|
27
|
+
*/
|
|
28
|
+
label?: ((spec: PObjectSpec, ref: PlRef) => string) | LabelDerivationOps;
|
|
29
|
+
};
|
|
16
30
|
export declare class ResultPool implements ColumnProvider, AxisLabelProvider {
|
|
17
31
|
private readonly ctx;
|
|
18
32
|
/**
|
|
19
33
|
* @deprecated use getOptions()
|
|
20
34
|
*/
|
|
21
35
|
calculateOptions(predicate: PSpecPredicate): Option[];
|
|
36
|
+
getOptions(predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[], opts?: GetOptionsOpts): Option[];
|
|
37
|
+
/** @deprecated wrap label ops with { label: <...> } */
|
|
22
38
|
getOptions(predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[], label?: ((spec: PObjectSpec, ref: PlRef) => string) | LabelDerivationOps): Option[];
|
|
23
39
|
resolveAnchorCtx(anchorsOrCtx: AnchoredIdDeriver | Record<string, PColumnSpec | PlRef>): AnchoredIdDeriver | undefined;
|
|
24
40
|
/**
|
package/dist/render/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/render/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,EACP,eAAe,EACf,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,EAEP,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,KAAK,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/render/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,EACP,eAAe,EACf,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACZ,OAAO,EAEP,WAAW,EACX,cAAc,EACd,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,KAAK,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACb,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AAc,CAAC,IAAI,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,IAAI,CAC7E,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,KAC3B,GAAG,CAAC;AAET,MAAM,MAAM,eAAe,CAAC,CAAC,IAC3B,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GACxB,CAAC,GACD,CAAC,SAAS,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GACtE,CAAC,GACD;KAAG,GAAG,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,CAAC;AAEtD,MAAM,MAAM,yBAAyB,CAAC,EAAE,SAAS,WAAW,IAAI,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAChG,eAAe,CAAC,CAAC,CAAC,GAClB,KAAK,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PlatformaSDKVersion = "1.
|
|
1
|
+
export declare const PlatformaSDKVersion = "1.30.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"utility-types": "^3.11.0",
|
|
22
22
|
"canonicalize": "~2.1.0",
|
|
23
23
|
"zod": "~3.23.8",
|
|
24
|
-
"@milaboratories/pl-model-common": "^1.
|
|
25
|
-
"@milaboratories/pl-error-like": "^1.12.
|
|
24
|
+
"@milaboratories/pl-model-common": "^1.14.0",
|
|
25
|
+
"@milaboratories/pl-error-like": "^1.12.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"typescript": "~5.5.4",
|
|
@@ -45,6 +45,7 @@ export function extractConfig(cfg: BlockConfigContainer): BlockConfig {
|
|
|
45
45
|
sdkVersion,
|
|
46
46
|
sections,
|
|
47
47
|
title,
|
|
48
|
+
enrichmentTargets,
|
|
48
49
|
} = cfg.v3;
|
|
49
50
|
const { code } = cfg;
|
|
50
51
|
return {
|
|
@@ -57,6 +58,7 @@ export function extractConfig(cfg: BlockConfigContainer): BlockConfig {
|
|
|
57
58
|
sections,
|
|
58
59
|
title,
|
|
59
60
|
code,
|
|
61
|
+
enrichmentTargets,
|
|
60
62
|
};
|
|
61
63
|
} else if (cfg.inputsValid !== undefined) {
|
|
62
64
|
// version 2
|
package/src/bconfig/v3.ts
CHANGED
|
@@ -36,6 +36,12 @@ export type BlockConfigV3<
|
|
|
36
36
|
/** Lambda to derive block title */
|
|
37
37
|
readonly title?: ConfigRenderLambda;
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Lambda returning list of upstream blocks this block enriches with its exports,
|
|
41
|
+
* influences dependency graph construction
|
|
42
|
+
* */
|
|
43
|
+
readonly enrichmentTargets?: ConfigRenderLambda;
|
|
44
|
+
|
|
39
45
|
/** Configuration for the output cells */
|
|
40
46
|
readonly outputs: Outputs;
|
|
41
47
|
|
package/src/builder.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockRenderingMode, BlockSection, ValueOrErrors, AnyFunction } from '@milaboratories/pl-model-common';
|
|
1
|
+
import type { BlockRenderingMode, BlockSection, ValueOrErrors, AnyFunction, PlRef } from '@milaboratories/pl-model-common';
|
|
2
2
|
import type { Checked, ConfigResult, TypedConfig } from './config';
|
|
3
3
|
import { getImmediate } from './config';
|
|
4
4
|
import { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';
|
|
@@ -65,6 +65,7 @@ export class BlockModel<
|
|
|
65
65
|
private readonly _inputsValid: TypedConfigOrConfigLambda,
|
|
66
66
|
private readonly _sections: TypedConfigOrConfigLambda,
|
|
67
67
|
private readonly _title: ConfigRenderLambda | undefined,
|
|
68
|
+
private readonly _enrichmentTargets: ConfigRenderLambda | undefined,
|
|
68
69
|
) {}
|
|
69
70
|
|
|
70
71
|
/** Initiates configuration builder */
|
|
@@ -90,6 +91,7 @@ export class BlockModel<
|
|
|
90
91
|
getImmediate(true),
|
|
91
92
|
getImmediate([]),
|
|
92
93
|
undefined,
|
|
94
|
+
undefined,
|
|
93
95
|
);
|
|
94
96
|
}
|
|
95
97
|
|
|
@@ -146,6 +148,7 @@ export class BlockModel<
|
|
|
146
148
|
this._inputsValid,
|
|
147
149
|
this._sections,
|
|
148
150
|
this._title,
|
|
151
|
+
this._enrichmentTargets,
|
|
149
152
|
);
|
|
150
153
|
} else
|
|
151
154
|
return new BlockModel(
|
|
@@ -159,6 +162,7 @@ export class BlockModel<
|
|
|
159
162
|
this._inputsValid,
|
|
160
163
|
this._sections,
|
|
161
164
|
this._title,
|
|
165
|
+
this._enrichmentTargets,
|
|
162
166
|
);
|
|
163
167
|
}
|
|
164
168
|
|
|
@@ -200,6 +204,7 @@ export class BlockModel<
|
|
|
200
204
|
} satisfies ConfigRenderLambda,
|
|
201
205
|
this._sections,
|
|
202
206
|
this._title,
|
|
207
|
+
this._enrichmentTargets,
|
|
203
208
|
);
|
|
204
209
|
} else
|
|
205
210
|
return new BlockModel<Args, OutputsCfg, UiState>(
|
|
@@ -210,6 +215,7 @@ export class BlockModel<
|
|
|
210
215
|
cfgOrRf,
|
|
211
216
|
this._sections,
|
|
212
217
|
this._title,
|
|
218
|
+
this._enrichmentTargets,
|
|
213
219
|
);
|
|
214
220
|
}
|
|
215
221
|
|
|
@@ -246,6 +252,7 @@ export class BlockModel<
|
|
|
246
252
|
this._inputsValid,
|
|
247
253
|
{ __renderLambda: true, handle: 'sections' } as ConfigRenderLambda,
|
|
248
254
|
this._title,
|
|
255
|
+
this._enrichmentTargets,
|
|
249
256
|
);
|
|
250
257
|
} else
|
|
251
258
|
return new BlockModel<Args, OutputsCfg, UiState>(
|
|
@@ -256,6 +263,7 @@ export class BlockModel<
|
|
|
256
263
|
this._inputsValid,
|
|
257
264
|
arrOrCfgOrRf as TypedConfig,
|
|
258
265
|
this._title,
|
|
266
|
+
this._enrichmentTargets,
|
|
259
267
|
);
|
|
260
268
|
}
|
|
261
269
|
|
|
@@ -272,6 +280,7 @@ export class BlockModel<
|
|
|
272
280
|
this._inputsValid,
|
|
273
281
|
this._sections,
|
|
274
282
|
{ __renderLambda: true, handle: 'title' } as ConfigRenderLambda,
|
|
283
|
+
this._enrichmentTargets,
|
|
275
284
|
);
|
|
276
285
|
}
|
|
277
286
|
|
|
@@ -288,6 +297,7 @@ export class BlockModel<
|
|
|
288
297
|
this._inputsValid,
|
|
289
298
|
this._sections,
|
|
290
299
|
this._title,
|
|
300
|
+
this._enrichmentTargets,
|
|
291
301
|
);
|
|
292
302
|
}
|
|
293
303
|
|
|
@@ -301,6 +311,7 @@ export class BlockModel<
|
|
|
301
311
|
this._inputsValid,
|
|
302
312
|
this._sections,
|
|
303
313
|
this._title,
|
|
314
|
+
this._enrichmentTargets,
|
|
304
315
|
);
|
|
305
316
|
}
|
|
306
317
|
|
|
@@ -314,6 +325,27 @@ export class BlockModel<
|
|
|
314
325
|
this._inputsValid,
|
|
315
326
|
this._sections,
|
|
316
327
|
this._title,
|
|
328
|
+
this._enrichmentTargets,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
|
|
334
|
+
* Influences dependency graph construction.
|
|
335
|
+
*/
|
|
336
|
+
public enriches(
|
|
337
|
+
lambda: (args: Args) => PlRef[],
|
|
338
|
+
): BlockModel<Args, OutputsCfg, UiState, Href> {
|
|
339
|
+
tryRegisterCallback('enrichmentTargets', lambda);
|
|
340
|
+
return new BlockModel<Args, OutputsCfg, UiState, Href>(
|
|
341
|
+
this._renderingMode,
|
|
342
|
+
this._initialArgs,
|
|
343
|
+
this._initialUiState,
|
|
344
|
+
this._outputs,
|
|
345
|
+
this._inputsValid,
|
|
346
|
+
this._sections,
|
|
347
|
+
this._title,
|
|
348
|
+
{ __renderLambda: true, handle: 'enrichmentTargets' } as ConfigRenderLambda,
|
|
317
349
|
);
|
|
318
350
|
}
|
|
319
351
|
|
|
@@ -338,6 +370,7 @@ export class BlockModel<
|
|
|
338
370
|
sections: this._sections,
|
|
339
371
|
title: this._title,
|
|
340
372
|
outputs: this._outputs,
|
|
373
|
+
enrichmentTargets: this._enrichmentTargets,
|
|
341
374
|
},
|
|
342
375
|
|
|
343
376
|
// fields below are added to allow previous desktop versions read generated configs
|
package/src/render/api.ts
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
mapPTableDef,
|
|
37
37
|
mapValueInVOE,
|
|
38
38
|
selectorsToPredicate,
|
|
39
|
+
withEnrichments,
|
|
39
40
|
} from '@milaboratories/pl-model-common';
|
|
40
41
|
import canonicalize from 'canonicalize';
|
|
41
42
|
import type { Optional } from 'utility-types';
|
|
@@ -89,6 +90,21 @@ type UniversalPColumnOpts = {
|
|
|
89
90
|
dontWaitAllData?: boolean;
|
|
90
91
|
} & ResolveAnchorsOptions;
|
|
91
92
|
|
|
93
|
+
type GetOptionsOpts = {
|
|
94
|
+
/**
|
|
95
|
+
* If true, references returned by the method will contain `requireEnrichments` flag set to true.
|
|
96
|
+
* If this reference is added to the block's args, it will communicate to the platform that the block
|
|
97
|
+
* expects enrichments of the referenced block to be available in the context of the current block.
|
|
98
|
+
*/
|
|
99
|
+
requireEnrichments?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Label derivation options.
|
|
102
|
+
* If provided, it will be used to derive labels for the options.
|
|
103
|
+
* If not provided, labels will be derived using the default logic.
|
|
104
|
+
*/
|
|
105
|
+
label?: ((spec: PObjectSpec, ref: PlRef) => string) | LabelDerivationOps;
|
|
106
|
+
};
|
|
107
|
+
|
|
92
108
|
export class ResultPool implements ColumnProvider, AxisLabelProvider {
|
|
93
109
|
private readonly ctx: GlobalCfgRenderCtx = getCfgRenderCtx();
|
|
94
110
|
|
|
@@ -99,23 +115,49 @@ export class ResultPool implements ColumnProvider, AxisLabelProvider {
|
|
|
99
115
|
return this.ctx.calculateOptions(predicate);
|
|
100
116
|
}
|
|
101
117
|
|
|
118
|
+
public getOptions(
|
|
119
|
+
predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[],
|
|
120
|
+
opts?: GetOptionsOpts,
|
|
121
|
+
): Option[];
|
|
122
|
+
/** @deprecated wrap label ops with { label: <...> } */
|
|
102
123
|
public getOptions(
|
|
103
124
|
predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[],
|
|
104
125
|
label?: ((spec: PObjectSpec, ref: PlRef) => string) | LabelDerivationOps,
|
|
126
|
+
): Option[];
|
|
127
|
+
public getOptions(
|
|
128
|
+
predicateOrSelector: ((spec: PObjectSpec) => boolean) | PColumnSelector | PColumnSelector[],
|
|
129
|
+
opts?: GetOptionsOpts | ((spec: PObjectSpec, ref: PlRef) => string) | LabelDerivationOps,
|
|
105
130
|
): Option[] {
|
|
106
131
|
const predicate = typeof predicateOrSelector === 'function'
|
|
107
132
|
? predicateOrSelector
|
|
108
133
|
: selectorsToPredicate(predicateOrSelector);
|
|
109
134
|
const filtered = this.getSpecs().entries.filter((s) => predicate(s.obj));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
135
|
+
|
|
136
|
+
let labelOps: LabelDerivationOps | ((spec: PObjectSpec, ref: PlRef) => string) = {};
|
|
137
|
+
let requireEnrichments: boolean = false;
|
|
138
|
+
if (typeof opts !== 'undefined') {
|
|
139
|
+
if (typeof opts === 'function') {
|
|
140
|
+
labelOps = opts;
|
|
141
|
+
} else if (typeof opts === 'object') {
|
|
142
|
+
if ('includeNativeLabel' in opts || 'separator' in opts || 'addLabelAsSuffix' in opts) {
|
|
143
|
+
labelOps = opts;
|
|
144
|
+
} else {
|
|
145
|
+
opts = opts as GetOptionsOpts;
|
|
146
|
+
labelOps = opts.label ?? {};
|
|
147
|
+
requireEnrichments = opts.requireEnrichments ?? false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (typeof labelOps === 'object')
|
|
153
|
+
return deriveLabels(filtered, (o) => o.obj, labelOps ?? {}).map(({ value: { ref }, label }) => ({
|
|
154
|
+
ref: withEnrichments(ref, requireEnrichments),
|
|
113
155
|
label,
|
|
114
156
|
}));
|
|
115
|
-
|
|
116
|
-
return filtered.map((
|
|
117
|
-
ref:
|
|
118
|
-
label:
|
|
157
|
+
else
|
|
158
|
+
return filtered.map(({ ref, obj }) => ({
|
|
159
|
+
ref: withEnrichments(ref, requireEnrichments),
|
|
160
|
+
label: labelOps(obj, ref),
|
|
119
161
|
}));
|
|
120
162
|
}
|
|
121
163
|
|
|
@@ -580,8 +622,6 @@ export class RenderCtx<Args, UiState> {
|
|
|
580
622
|
}
|
|
581
623
|
|
|
582
624
|
public getCurrentUnstableMarker(): string | undefined {
|
|
583
|
-
// @TODO remove after 1 Jan 2025; forward compatibility
|
|
584
|
-
if (typeof this.ctx.getCurrentUnstableMarker === 'undefined') return undefined;
|
|
585
625
|
return this.ctx.getCurrentUnstableMarker();
|
|
586
626
|
}
|
|
587
627
|
}
|