@platforma-sdk/model 1.51.9 → 1.52.3
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/lambdas.d.ts +26 -4
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/v3.d.ts +4 -2
- package/dist/bconfig/v3.d.ts.map +1 -1
- package/dist/block_api_v3.d.ts +32 -0
- package/dist/block_api_v3.d.ts.map +1 -0
- package/dist/block_migrations.cjs +138 -0
- package/dist/block_migrations.cjs.map +1 -0
- package/dist/block_migrations.d.ts +79 -0
- package/dist/block_migrations.d.ts.map +1 -0
- package/dist/block_migrations.js +136 -0
- package/dist/block_migrations.js.map +1 -0
- package/dist/block_model.cjs +222 -0
- package/dist/block_model.cjs.map +1 -0
- package/dist/block_model.d.ts +132 -0
- package/dist/block_model.d.ts.map +1 -0
- package/dist/block_model.js +220 -0
- package/dist/block_model.js.map +1 -0
- package/dist/block_storage.cjs +244 -0
- package/dist/block_storage.cjs.map +1 -0
- package/dist/block_storage.d.ts +208 -0
- package/dist/block_storage.d.ts.map +1 -0
- package/dist/block_storage.js +225 -0
- package/dist/block_storage.js.map +1 -0
- package/dist/block_storage_vm.cjs +264 -0
- package/dist/block_storage_vm.cjs.map +1 -0
- package/dist/block_storage_vm.d.ts +67 -0
- package/dist/block_storage_vm.d.ts.map +1 -0
- package/dist/block_storage_vm.js +260 -0
- package/dist/block_storage_vm.js.map +1 -0
- package/dist/builder.cjs +9 -6
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +15 -30
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +10 -7
- package/dist/builder.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +2 -2
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlDataTable.cjs.map +1 -1
- package/dist/components/PlDataTable.d.ts +3 -3
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlDataTable.js.map +1 -1
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +38 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +21 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +36 -1
- package/dist/internal.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +3 -3
- package/dist/pframe_utils/columns.d.ts.map +1 -1
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/platforma.d.ts +18 -3
- package/dist/platforma.d.ts.map +1 -1
- package/dist/render/api.cjs +43 -16
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +19 -7
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +42 -17
- package/dist/render/api.js.map +1 -1
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +3 -1
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/internal.js.map +1 -1
- package/package.json +7 -7
- package/src/bconfig/lambdas.ts +35 -4
- package/src/bconfig/v3.ts +12 -2
- package/src/block_api_v3.ts +49 -0
- package/src/block_migrations.ts +173 -0
- package/src/block_model.ts +440 -0
- package/src/block_storage.test.ts +258 -0
- package/src/block_storage.ts +365 -0
- package/src/block_storage_vm.ts +349 -0
- package/src/builder.ts +24 -59
- package/src/components/PFrameForGraphs.ts +2 -2
- package/src/components/PlDataTable.ts +3 -3
- package/src/index.ts +3 -0
- package/src/internal.ts +51 -0
- package/src/pframe_utils/columns.ts +3 -3
- package/src/platforma.ts +31 -5
- package/src/render/api.ts +52 -21
- package/src/render/internal.ts +3 -1
|
@@ -2,11 +2,11 @@ import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratori
|
|
|
2
2
|
import { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';
|
|
3
3
|
import type { AxesVault } from '../components';
|
|
4
4
|
import { enrichCompatible, getAvailableWithLinkersAxes } from '../components';
|
|
5
|
-
import type {
|
|
5
|
+
import type { RenderCtxBase, PColumnDataUniversal } from '../render';
|
|
6
6
|
import { PColumnCollection } from '../render';
|
|
7
7
|
|
|
8
8
|
export function getAllRelatedColumns<A, U>(
|
|
9
|
-
ctx:
|
|
9
|
+
ctx: RenderCtxBase<A, U>, predicate: (spec: PColumnSpec) => boolean,
|
|
10
10
|
): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {
|
|
11
11
|
// if current block doesn't produce own columns then use all columns from result pool
|
|
12
12
|
const columns = new PColumnCollection();
|
|
@@ -26,7 +26,7 @@ export function getAllRelatedColumns<A, U>(
|
|
|
26
26
|
return extendedColumns;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function getRelatedColumns<A, U>(ctx:
|
|
29
|
+
export function getRelatedColumns<A, U>(ctx: RenderCtxBase<A, U>, { columns: rootColumns, predicate }: {
|
|
30
30
|
columns: PColumn<PColumnDataUniversal>[];
|
|
31
31
|
predicate: (spec: PColumnSpec) => boolean;
|
|
32
32
|
}): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {
|
package/src/platforma.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BlockApiV1 } from './block_api_v1';
|
|
2
2
|
import type { BlockApiV2 } from './block_api_v2';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlockApiV3 } from './block_api_v3';
|
|
4
|
+
import type { BlockOutputsBase, BlockStateV3, DriverKit, OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
4
5
|
import type { SdkInfo } from './sdk_info';
|
|
5
6
|
import type { BlockStatePatch } from './block_state_patch';
|
|
6
7
|
|
|
@@ -30,12 +31,34 @@ export interface PlatformaV2<
|
|
|
30
31
|
readonly apiVersion: 2;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
export interface PlatformaV3<
|
|
35
|
+
Args = unknown,
|
|
36
|
+
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
37
|
+
Data = unknown,
|
|
38
|
+
Href extends `/${string}` = `/${string}`,
|
|
39
|
+
> extends BlockApiV3<Args, Outputs, Data, Href>,
|
|
40
|
+
DriverKit {
|
|
41
|
+
/** Information about SDK version current platforma environment was compiled with. */
|
|
42
|
+
readonly sdkInfo: SdkInfo;
|
|
43
|
+
readonly apiVersion: 3;
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
export type Platforma<
|
|
34
47
|
Args = unknown,
|
|
35
48
|
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
36
49
|
UiState = unknown,
|
|
37
50
|
Href extends `/${string}` = `/${string}`,
|
|
38
|
-
> = PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href>;
|
|
51
|
+
> = PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href> | PlatformaV3<Args, Outputs, UiState, Href>;
|
|
52
|
+
|
|
53
|
+
export type PlatformaExtended<Pl extends Platforma = Platforma> = Pl & {
|
|
54
|
+
blockModelInfo: BlockModelInfo;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type BlockModelInfo = {
|
|
58
|
+
outputs: Record<string, {
|
|
59
|
+
withStatus: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
39
62
|
|
|
40
63
|
export type PlatformaApiVersion = Platforma['apiVersion'];
|
|
41
64
|
|
|
@@ -49,15 +72,18 @@ export type InferUiState<Pl extends Platforma> =
|
|
|
49
72
|
? UiState
|
|
50
73
|
: never;
|
|
51
74
|
|
|
75
|
+
export type InferDataType<Pl extends Platforma> =
|
|
76
|
+
Pl extends Platforma<unknown, Record<string, OutputWithStatus<unknown>>, infer Data>
|
|
77
|
+
? Data
|
|
78
|
+
: never;
|
|
79
|
+
|
|
52
80
|
export type InferHrefType<Pl extends Platforma> =
|
|
53
81
|
Pl extends Platforma<unknown, BlockOutputsBase, unknown, infer Href> ? Href : never;
|
|
54
82
|
|
|
55
83
|
export type PlatformaFactory = (config: { sdkVersion: string }) => Platforma;
|
|
56
84
|
|
|
57
|
-
export type InferBlockState<Pl extends Platforma> =
|
|
58
|
-
InferArgsType<Pl>,
|
|
85
|
+
export type InferBlockState<Pl extends Platforma> = BlockStateV3<
|
|
59
86
|
InferOutputsType<Pl>,
|
|
60
|
-
InferUiState<Pl>,
|
|
61
87
|
InferHrefType<Pl>
|
|
62
88
|
>;
|
|
63
89
|
|
package/src/render/api.ts
CHANGED
|
@@ -515,33 +515,22 @@ export class ResultPool implements ColumnProvider, AxisLabelProvider {
|
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
/** Main entry point to the API available within model lambdas (like outputs, sections, etc..) */
|
|
518
|
-
export class
|
|
519
|
-
|
|
518
|
+
export abstract class RenderCtxBase<Args, Data> {
|
|
519
|
+
protected readonly ctx: GlobalCfgRenderCtx;
|
|
520
520
|
|
|
521
521
|
constructor() {
|
|
522
522
|
this.ctx = getCfgRenderCtx();
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
private
|
|
526
|
-
|
|
527
|
-
public get args(): Args {
|
|
528
|
-
if (this._argsCache === undefined) {
|
|
529
|
-
const raw = this.ctx.args;
|
|
530
|
-
const value = typeof raw === 'function' ? raw() : raw;
|
|
531
|
-
this._argsCache = { v: JSON.parse(value) };
|
|
532
|
-
}
|
|
533
|
-
return this._argsCache.v;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
private _uiStateCache?: { v: UiState };
|
|
525
|
+
private _dataCache?: { v: Data };
|
|
537
526
|
|
|
538
|
-
public get
|
|
539
|
-
if (this.
|
|
540
|
-
const raw = this.ctx.
|
|
527
|
+
public get data(): Data {
|
|
528
|
+
if (this._dataCache === undefined) {
|
|
529
|
+
const raw = this.ctx.data;
|
|
541
530
|
const value = typeof raw === 'function' ? raw() : raw;
|
|
542
|
-
this.
|
|
531
|
+
this._dataCache = { v: value ? JSON.parse(value) : ({} as Data) };
|
|
543
532
|
}
|
|
544
|
-
return this.
|
|
533
|
+
return this._dataCache.v;
|
|
545
534
|
}
|
|
546
535
|
|
|
547
536
|
// lazy rendering because this feature is rarely used
|
|
@@ -691,8 +680,50 @@ export class RenderCtx<Args, UiState> {
|
|
|
691
680
|
}
|
|
692
681
|
}
|
|
693
682
|
|
|
694
|
-
|
|
695
|
-
|
|
683
|
+
/** Main entry point to the API available within model lambdas (like outputs, sections, etc..) for v3+ blocks */
|
|
684
|
+
export class RenderCtx<Args, Data> extends RenderCtxBase<Args, Data> {
|
|
685
|
+
private _argsCache?: { v: Args | undefined };
|
|
686
|
+
public get args(): Args | undefined {
|
|
687
|
+
if (this._argsCache === undefined) {
|
|
688
|
+
const raw = this.ctx.args;
|
|
689
|
+
const value = typeof raw === 'function' ? raw() : raw;
|
|
690
|
+
// args can be undefined when derivation fails (e.g., validation error in args())
|
|
691
|
+
this._argsCache = { v: value === undefined ? undefined : JSON.parse(value) };
|
|
692
|
+
}
|
|
693
|
+
return this._argsCache.v;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Render context for legacy v1/v2 blocks - provides backward compatibility */
|
|
698
|
+
export class RenderCtxLegacy<Args, UiState> extends RenderCtxBase<Args, UiState> {
|
|
699
|
+
private _argsCache?: { v: Args };
|
|
700
|
+
public get args(): Args {
|
|
701
|
+
if (this._argsCache === undefined) {
|
|
702
|
+
const raw = this.ctx.args;
|
|
703
|
+
const value = typeof raw === 'function' ? raw() : raw;
|
|
704
|
+
this._argsCache = { v: JSON.parse(value) };
|
|
705
|
+
}
|
|
706
|
+
return this._argsCache.v;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
private _uiStateCache?: { v: UiState };
|
|
710
|
+
|
|
711
|
+
public get uiState(): UiState {
|
|
712
|
+
if (this._uiStateCache === undefined) {
|
|
713
|
+
const raw = this.ctx.uiState!;
|
|
714
|
+
const value = typeof raw === 'function' ? raw() : raw;
|
|
715
|
+
this._uiStateCache = { v: value ? JSON.parse(value) : ({} as UiState) };
|
|
716
|
+
}
|
|
717
|
+
return this._uiStateCache.v;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
export type RenderFunction<Args = unknown, State = unknown, Ret = unknown> = (
|
|
722
|
+
rCtx: RenderCtx<Args, State>
|
|
723
|
+
) => Ret;
|
|
724
|
+
|
|
725
|
+
export type RenderFunctionLegacy<Args = unknown, State = unknown, Ret = unknown> = (
|
|
726
|
+
rCtx: RenderCtxLegacy<Args, State>
|
|
696
727
|
) => Ret;
|
|
697
728
|
|
|
698
729
|
export type UnwrapFutureRef<K> =
|
package/src/render/internal.ts
CHANGED
|
@@ -183,7 +183,9 @@ export interface GlobalCfgRenderCtx extends GlobalCfgRenderCtxMethods {
|
|
|
183
183
|
//
|
|
184
184
|
|
|
185
185
|
readonly args: string | (() => string);
|
|
186
|
-
|
|
186
|
+
/** @deprecated Use `data` instead. Optional for backward compatibility - falls back to `data` if not injected. */
|
|
187
|
+
readonly uiState?: string | (() => string);
|
|
188
|
+
readonly data: string | (() => string);
|
|
187
189
|
readonly activeArgs: undefined | string | (() => string | undefined);
|
|
188
190
|
|
|
189
191
|
// Note: strings below are used because, anyway, using strings is the only way
|