@platforma-sdk/model 1.2.29 → 1.2.32
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/env_value.d.ts +0 -3
- package/dist/env_value.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +196 -144
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +2 -9
- package/dist/internal.d.ts.map +1 -1
- package/dist/raw_globals.d.ts +3 -0
- package/dist/raw_globals.d.ts.map +1 -0
- package/dist/render/api.d.ts +28 -1
- package/dist/render/api.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -2
- package/src/env_value.ts +3 -5
- package/src/global.d.ts +12 -0
- package/src/index.ts +1 -0
- package/src/internal.ts +10 -15
- package/src/raw_globals.ts +7 -0
- package/src/render/api.ts +62 -0
- package/src/version.ts +1 -1
package/src/render/api.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
PTableHandle,
|
|
11
11
|
PTableRecordFilter,
|
|
12
12
|
PTableSorting,
|
|
13
|
+
Ref,
|
|
13
14
|
ResultCollection,
|
|
14
15
|
ValueOrError,
|
|
15
16
|
mapPObjectData,
|
|
@@ -25,11 +26,36 @@ import { GlobalCfgRenderCtx, MainAccessorName, StagingAccessorName } from './int
|
|
|
25
26
|
export class ResultPool {
|
|
26
27
|
private readonly ctx: GlobalCfgRenderCtx = getCfgRenderCtx();
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated use getOptions()
|
|
31
|
+
*/
|
|
28
32
|
public calculateOptions(predicate: PSpecPredicate): Option[] {
|
|
29
33
|
return this.ctx.calculateOptions(predicate);
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
private defaultLabelFn = (spec: PObjectSpec, ref: Ref) =>
|
|
37
|
+
spec.annotations?.['pl7.app/label'] ?? `Unlabelled`;
|
|
38
|
+
|
|
39
|
+
public getOptions(
|
|
40
|
+
predicate: (spec: PObjectSpec) => boolean,
|
|
41
|
+
labelFn: (spec: PObjectSpec, ref: Ref) => string = this.defaultLabelFn
|
|
42
|
+
): Option[] {
|
|
43
|
+
return this.getSpecs()
|
|
44
|
+
.entries.filter((s) => predicate(s.obj))
|
|
45
|
+
.map((s) => ({
|
|
46
|
+
ref: s.ref,
|
|
47
|
+
label: labelFn(s.obj, s.ref)
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated use getData()
|
|
53
|
+
*/
|
|
32
54
|
public getDataFromResultPool(): ResultCollection<PObject<TreeNodeAccessor>> {
|
|
55
|
+
return this.getData();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public getData(): ResultCollection<PObject<TreeNodeAccessor>> {
|
|
33
59
|
const result = this.ctx.getDataFromResultPool();
|
|
34
60
|
return {
|
|
35
61
|
isComplete: result.isComplete,
|
|
@@ -43,8 +69,17 @@ export class ResultPool {
|
|
|
43
69
|
};
|
|
44
70
|
}
|
|
45
71
|
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated use getDataWithErrors()
|
|
74
|
+
*/
|
|
46
75
|
public getDataWithErrorsFromResultPool(): ResultCollection<
|
|
47
76
|
Optional<PObject<ValueOrError<TreeNodeAccessor, string>>, 'id'>
|
|
77
|
+
> {
|
|
78
|
+
return this.getDataWithErrors();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public getDataWithErrors(): ResultCollection<
|
|
82
|
+
Optional<PObject<ValueOrError<TreeNodeAccessor, string>>, 'id'>
|
|
48
83
|
> {
|
|
49
84
|
const result = this.ctx.getDataWithErrorsFromResultPool();
|
|
50
85
|
return {
|
|
@@ -59,9 +94,36 @@ export class ResultPool {
|
|
|
59
94
|
};
|
|
60
95
|
}
|
|
61
96
|
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated use getSpecs()
|
|
99
|
+
*/
|
|
62
100
|
public getSpecsFromResultPool(): ResultCollection<PObjectSpec> {
|
|
101
|
+
return this.getSpecs();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public getSpecs(): ResultCollection<PObjectSpec> {
|
|
63
105
|
return this.ctx.getSpecsFromResultPool();
|
|
64
106
|
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param ref a Ref
|
|
110
|
+
* @returns data associated with the ref
|
|
111
|
+
*/
|
|
112
|
+
public getDataByRef(ref: Ref): PObject<TreeNodeAccessor> | undefined {
|
|
113
|
+
// https://github.com/milaboratory/platforma/issues/100
|
|
114
|
+
// @TODO use native pool method when available
|
|
115
|
+
return this.getData().entries.find((f) => f.ref.blockId === ref.blockId && f.ref.name === ref.name)?.obj;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param ref a Ref
|
|
120
|
+
* @returns object spec associated with the ref
|
|
121
|
+
*/
|
|
122
|
+
public getSpecByRef(ref: Ref): PObjectSpec | undefined {
|
|
123
|
+
// https://github.com/milaboratory/platforma/issues/100
|
|
124
|
+
// @TODO use native pool method when available
|
|
125
|
+
return this.getSpecs().entries.find((f) => f.ref.blockId === ref.blockId && f.ref.name === ref.name)?.obj;
|
|
126
|
+
}
|
|
65
127
|
}
|
|
66
128
|
|
|
67
129
|
export class RenderCtx<Args, UiState> {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PlatformaSDKVersion = '1.2.
|
|
1
|
+
export const PlatformaSDKVersion = '1.2.32';
|