@platforma-sdk/model 1.24.5 → 1.24.10
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/container.d.ts.map +1 -1
- package/dist/bconfig/lambdas.d.ts +1 -1
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/normalization.d.ts.map +1 -1
- package/dist/bconfig/types.d.ts.map +1 -1
- package/dist/bconfig/utils.d.ts.map +1 -1
- package/dist/bconfig/v3.d.ts.map +1 -1
- package/dist/block_api.d.ts.map +1 -1
- package/dist/block_state_patch.d.ts.map +1 -1
- package/dist/block_state_util.d.ts.map +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PlDataTable.d.ts +6 -0
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/config/actions.d.ts.map +1 -1
- package/dist/config/actions_kinds.d.ts.map +1 -1
- package/dist/config/model.d.ts.map +1 -1
- package/dist/config/type_engine.d.ts.map +1 -1
- package/dist/config/type_util.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/pframe.d.ts.map +1 -1
- package/dist/platforma.d.ts.map +1 -1
- package/dist/raw_globals.d.ts.map +1 -1
- package/dist/ref_util.d.ts.map +1 -1
- package/dist/render/accessor.d.ts.map +1 -1
- package/dist/render/api.d.ts +2 -2
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/future.d.ts +2 -2
- package/dist/render/future.d.ts.map +1 -1
- package/dist/render/internal.d.ts +2 -2
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/render/util/resource_map.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/bconfig/container.ts +3 -3
- package/src/bconfig/lambdas.ts +2 -2
- package/src/bconfig/normalization.ts +26 -25
- package/src/bconfig/types.ts +3 -3
- package/src/bconfig/utils.ts +1 -1
- package/src/bconfig/v3.ts +4 -4
- package/src/block_api.ts +3 -3
- package/src/block_state_patch.ts +3 -3
- package/src/block_state_util.ts +4 -4
- package/src/builder.ts +50 -44
- package/src/components/PFrameForGraphs.ts +171 -169
- package/src/components/PlDataTable.ts +27 -17
- package/src/config/actions.ts +71 -71
- package/src/config/actions_kinds.ts +9 -9
- package/src/config/model.ts +3 -1
- package/src/config/type_engine.ts +3 -2
- package/src/config/type_util.ts +1 -1
- package/src/internal.ts +4 -4
- package/src/pframe.ts +3 -3
- package/src/platforma.ts +7 -7
- package/src/raw_globals.ts +1 -1
- package/src/ref_util.ts +4 -3
- package/src/render/accessor.ts +30 -28
- package/src/render/api.ts +10 -6
- package/src/render/future.ts +3 -3
- package/src/render/internal.ts +8 -8
- package/src/render/util/label.ts +7 -7
- package/src/render/util/resource_map.ts +6 -7
- package/src/sdk_info.ts +1 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
AxisSpec,
|
|
3
|
-
getAxisId,
|
|
4
|
-
isPColumn,
|
|
5
3
|
JoinEntry,
|
|
6
|
-
matchAxisId,
|
|
7
4
|
PColumn,
|
|
8
5
|
PColumnIdAndSpec,
|
|
9
6
|
PColumnSpec,
|
|
@@ -11,12 +8,23 @@ import {
|
|
|
11
8
|
PObjectId,
|
|
12
9
|
PTableHandle,
|
|
13
10
|
PTableRecordFilter,
|
|
14
|
-
PTableSorting
|
|
11
|
+
PTableSorting,
|
|
15
12
|
} from '@milaboratories/pl-model-common';
|
|
16
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
getAxisId,
|
|
15
|
+
isPColumn,
|
|
16
|
+
matchAxisId,
|
|
17
|
+
} from '@milaboratories/pl-model-common';
|
|
18
|
+
import type { RenderCtx } from '../render';
|
|
19
|
+
import { TreeNodeAccessor } from '../render';
|
|
17
20
|
|
|
18
21
|
/** Data table state */
|
|
19
22
|
export type PlDataTableGridState = {
|
|
23
|
+
// TODO request stable key from the driver
|
|
24
|
+
/**
|
|
25
|
+
* Hash of the specs for now, but in the future it will be a stable id of the source
|
|
26
|
+
*/
|
|
27
|
+
sourceId?: string;
|
|
20
28
|
/** Includes column ordering */
|
|
21
29
|
columnOrder?: {
|
|
22
30
|
/** All colIds in order */
|
|
@@ -37,11 +45,13 @@ export type PlDataTableGridState = {
|
|
|
37
45
|
/** All colIds which were hidden */
|
|
38
46
|
hiddenColIds: string[];
|
|
39
47
|
};
|
|
40
|
-
|
|
41
48
|
/** current sheet selections */
|
|
42
49
|
sheets?: Record<string, string | number>;
|
|
43
50
|
};
|
|
44
51
|
|
|
52
|
+
/** TODO: refactor to use sheets in the grid state */
|
|
53
|
+
export type PlDataTableGridStateWithoutSheets = Omit<PlDataTableGridState, 'sheets'>;
|
|
54
|
+
|
|
45
55
|
export type PlDataTableSheet = {
|
|
46
56
|
/** spec of the axis to use */
|
|
47
57
|
axis: AxisSpec;
|
|
@@ -338,7 +348,7 @@ export function createPlDataTable<A, U>(
|
|
|
338
348
|
ctx: RenderCtx<A, U>,
|
|
339
349
|
columns: PColumn<TreeNodeAccessor | PColumnValues>[],
|
|
340
350
|
tableState: PlDataTableState | undefined,
|
|
341
|
-
ops?: PTableRecordFilter[] | CreatePlDataTableOps
|
|
351
|
+
ops?: PTableRecordFilter[] | CreatePlDataTableOps,
|
|
342
352
|
): PTableHandle | undefined {
|
|
343
353
|
// ops migration for backward compatibility with previous deprecated API
|
|
344
354
|
if (Array.isArray(ops)) {
|
|
@@ -380,9 +390,9 @@ export function createPlDataTable<A, U>(
|
|
|
380
390
|
id: id as PObjectId,
|
|
381
391
|
spec: {
|
|
382
392
|
...labelColumn.spec,
|
|
383
|
-
axesSpec: [{ ...axisId, annotations: labelAxis.annotations }]
|
|
393
|
+
axesSpec: [{ ...axisId, annotations: labelAxis.annotations }],
|
|
384
394
|
},
|
|
385
|
-
data: labelColumn.data
|
|
395
|
+
data: labelColumn.data,
|
|
386
396
|
});
|
|
387
397
|
} else {
|
|
388
398
|
labelColumns.set(colId(labelColumn.id), labelColumn);
|
|
@@ -395,7 +405,7 @@ export function createPlDataTable<A, U>(
|
|
|
395
405
|
// if at least one column is not yet ready, we can't show the table
|
|
396
406
|
if (
|
|
397
407
|
[...columns, ...labelColumns.values()].some(
|
|
398
|
-
(a) => a.data instanceof TreeNodeAccessor && !a.data.getIsReadyOrError()
|
|
408
|
+
(a) => a.data instanceof TreeNodeAccessor && !a.data.getIsReadyOrError(),
|
|
399
409
|
)
|
|
400
410
|
)
|
|
401
411
|
return undefined;
|
|
@@ -417,12 +427,12 @@ export function createPlDataTable<A, U>(
|
|
|
417
427
|
type: 'outer',
|
|
418
428
|
primary: {
|
|
419
429
|
type: ops?.coreJoinType ?? 'full',
|
|
420
|
-
entries: coreColumns.map((c) => ({ type: 'column', column: c }))
|
|
430
|
+
entries: coreColumns.map((c) => ({ type: 'column', column: c })),
|
|
421
431
|
},
|
|
422
|
-
secondary: secondaryColumns.map((c) => ({ type: 'column', column: c }))
|
|
432
|
+
secondary: secondaryColumns.map((c) => ({ type: 'column', column: c })),
|
|
423
433
|
},
|
|
424
434
|
filters: [...(ops?.filters ?? []), ...(tableState?.pTableParams?.filters ?? [])],
|
|
425
|
-
sorting: tableState?.pTableParams?.sorting ?? []
|
|
435
|
+
sorting: tableState?.pTableParams?.sorting ?? [],
|
|
426
436
|
});
|
|
427
437
|
}
|
|
428
438
|
|
|
@@ -430,15 +440,15 @@ export function createPlDataTable<A, U>(
|
|
|
430
440
|
export function createPlDataTableSheet<A, U>(
|
|
431
441
|
ctx: RenderCtx<A, U>,
|
|
432
442
|
axis: AxisSpec,
|
|
433
|
-
values: (string | number)[]
|
|
443
|
+
values: (string | number)[],
|
|
434
444
|
): PlDataTableSheet {
|
|
435
445
|
const labels = ctx.findLabels(axis);
|
|
436
446
|
return {
|
|
437
447
|
axis,
|
|
438
448
|
options: values.map((v) => ({
|
|
439
449
|
value: v,
|
|
440
|
-
label: labels?.[v] ?? v.toString()
|
|
450
|
+
label: labels?.[v] ?? v.toString(),
|
|
441
451
|
})),
|
|
442
|
-
defaultValue: values[0]
|
|
452
|
+
defaultValue: values[0],
|
|
443
453
|
};
|
|
444
454
|
}
|
package/src/config/actions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
ActGetField,
|
|
3
3
|
ActGetFromCtx,
|
|
4
4
|
ActGetImmediate,
|
|
@@ -25,12 +25,12 @@ import {
|
|
|
25
25
|
ActGetProgressLog,
|
|
26
26
|
ActGetProgressLogWithInfo,
|
|
27
27
|
ActGetLogHandle,
|
|
28
|
-
ActExtractArchiveAndGetURL
|
|
28
|
+
ActExtractArchiveAndGetURL,
|
|
29
29
|
} from './actions_kinds';
|
|
30
|
-
import { ExtractAction, POCExtractAction, PrimitiveOrConfig, TypedConfig } from './type_engine';
|
|
31
|
-
import { Cfg } from './model';
|
|
32
|
-
import { CheckedSyncConf } from './type_util';
|
|
33
|
-
import { ArchiveFormat } from '@milaboratories/pl-model-common';
|
|
30
|
+
import type { ExtractAction, POCExtractAction, PrimitiveOrConfig, TypedConfig } from './type_engine';
|
|
31
|
+
import type { Cfg } from './model';
|
|
32
|
+
import type { CheckedSyncConf } from './type_util';
|
|
33
|
+
import type { ArchiveFormat } from '@milaboratories/pl-model-common';
|
|
34
34
|
|
|
35
35
|
//
|
|
36
36
|
// Helpers
|
|
@@ -38,10 +38,10 @@ import { ArchiveFormat } from '@milaboratories/pl-model-common';
|
|
|
38
38
|
|
|
39
39
|
function primitiveToConfig(value: PrimitiveOrConfig): TypedConfig {
|
|
40
40
|
if (
|
|
41
|
-
typeof value === 'string'
|
|
42
|
-
typeof value === 'number'
|
|
43
|
-
typeof value === 'boolean'
|
|
44
|
-
value === null
|
|
41
|
+
typeof value === 'string'
|
|
42
|
+
|| typeof value === 'number'
|
|
43
|
+
|| typeof value === 'boolean'
|
|
44
|
+
|| value === null
|
|
45
45
|
)
|
|
46
46
|
return getImmediate(value);
|
|
47
47
|
else return value as TypedConfig;
|
|
@@ -60,11 +60,11 @@ export function getFromCfg<const V extends string>(variable: V): TypedConfig<Act
|
|
|
60
60
|
//
|
|
61
61
|
|
|
62
62
|
export function isolate<const Config extends TypedConfig>(
|
|
63
|
-
cfg: Config
|
|
63
|
+
cfg: Config,
|
|
64
64
|
): TypedConfig<ActIsolate<ExtractAction<Config>>> {
|
|
65
65
|
return {
|
|
66
66
|
type: 'Isolate',
|
|
67
|
-
cfg
|
|
67
|
+
cfg,
|
|
68
68
|
} as Cfg as any;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -87,13 +87,13 @@ export function getImmediate<const T>(value: T): TypedConfig<ActGetImmediate<T>>
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export function makeObject<const T extends Record<string, PrimitiveOrConfig>>(
|
|
90
|
-
template: T
|
|
90
|
+
template: T,
|
|
91
91
|
): TypedConfig<ActMakeObject<{ [Key in keyof T]: POCExtractAction<T[Key]> }>> {
|
|
92
92
|
const normalizedTemplate: Record<string, TypedConfig> = {};
|
|
93
93
|
for (const [k, cfg] of Object.entries(template)) normalizedTemplate[k] = primitiveToConfig(cfg);
|
|
94
94
|
return {
|
|
95
95
|
type: 'MakeObject',
|
|
96
|
-
template: normalizedTemplate
|
|
96
|
+
template: normalizedTemplate,
|
|
97
97
|
} as Cfg as any;
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -104,34 +104,34 @@ export function makeArray<const T extends PrimitiveOrConfig[]>(
|
|
|
104
104
|
for (const cfg of template) normalizedTemplate.push(primitiveToConfig(cfg));
|
|
105
105
|
return {
|
|
106
106
|
type: 'MakeArray',
|
|
107
|
-
template: normalizedTemplate
|
|
107
|
+
template: normalizedTemplate,
|
|
108
108
|
} as Cfg as any;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
export function getJsonField<
|
|
112
112
|
const Source extends PrimitiveOrConfig,
|
|
113
|
-
const Field extends PrimitiveOrConfig
|
|
113
|
+
const Field extends PrimitiveOrConfig,
|
|
114
114
|
>(
|
|
115
115
|
source: Source,
|
|
116
|
-
field: Field
|
|
116
|
+
field: Field,
|
|
117
117
|
): TypedConfig<ActGetField<POCExtractAction<Source>, POCExtractAction<Field>>> {
|
|
118
118
|
return {
|
|
119
119
|
type: 'GetJsonField',
|
|
120
120
|
source: primitiveToConfig(source),
|
|
121
|
-
field: primitiveToConfig(field)
|
|
121
|
+
field: primitiveToConfig(field),
|
|
122
122
|
} as Cfg as any;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export function mapRecordValues<
|
|
126
126
|
const Source extends TypedConfig,
|
|
127
|
-
const Mapping extends TypedConfig
|
|
127
|
+
const Mapping extends TypedConfig,
|
|
128
128
|
>(
|
|
129
129
|
source: Source & CheckedSyncConf<Source>,
|
|
130
130
|
mapping: Mapping
|
|
131
131
|
): TypedConfig<ActMapRecordValues<ExtractAction<Source>, ExtractAction<Mapping>, '$it'>>;
|
|
132
132
|
export function mapRecordValues<
|
|
133
133
|
const Source extends TypedConfig,
|
|
134
|
-
const Mapping extends TypedConfig
|
|
134
|
+
const Mapping extends TypedConfig,
|
|
135
135
|
>(
|
|
136
136
|
source: Source,
|
|
137
137
|
mapping: Mapping & CheckedSyncConf<Mapping>
|
|
@@ -139,7 +139,7 @@ export function mapRecordValues<
|
|
|
139
139
|
export function mapRecordValues<
|
|
140
140
|
const Source extends TypedConfig,
|
|
141
141
|
const Mapping extends TypedConfig,
|
|
142
|
-
const ItVar extends string
|
|
142
|
+
const ItVar extends string,
|
|
143
143
|
>(
|
|
144
144
|
source: Source & CheckedSyncConf<Source>,
|
|
145
145
|
mapping: Mapping,
|
|
@@ -148,7 +148,7 @@ export function mapRecordValues<
|
|
|
148
148
|
export function mapRecordValues<
|
|
149
149
|
const Source extends TypedConfig,
|
|
150
150
|
const Mapping extends TypedConfig,
|
|
151
|
-
const ItVar extends string
|
|
151
|
+
const ItVar extends string,
|
|
152
152
|
>(
|
|
153
153
|
source: Source,
|
|
154
154
|
mapping: Mapping & CheckedSyncConf<Mapping>,
|
|
@@ -157,17 +157,17 @@ export function mapRecordValues<
|
|
|
157
157
|
export function mapRecordValues<
|
|
158
158
|
const Source extends TypedConfig,
|
|
159
159
|
const Mapping extends TypedConfig,
|
|
160
|
-
const ItVar extends string
|
|
160
|
+
const ItVar extends string,
|
|
161
161
|
>(
|
|
162
162
|
source: Source,
|
|
163
163
|
mapping: Mapping,
|
|
164
|
-
itVar: ItVar = '$it' as ItVar
|
|
164
|
+
itVar: ItVar = '$it' as ItVar,
|
|
165
165
|
): TypedConfig<ActMapRecordValues<ExtractAction<Source>, ExtractAction<Mapping>, ItVar>> {
|
|
166
166
|
return {
|
|
167
167
|
type: 'MapRecordValues',
|
|
168
168
|
source,
|
|
169
169
|
mapping,
|
|
170
|
-
itVar
|
|
170
|
+
itVar,
|
|
171
171
|
} as Cfg as any;
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -182,7 +182,7 @@ export function mapArrayValues<const Source extends TypedConfig, const Mapping e
|
|
|
182
182
|
export function mapArrayValues<
|
|
183
183
|
const Source extends TypedConfig,
|
|
184
184
|
const Mapping extends TypedConfig,
|
|
185
|
-
const ItVar extends string
|
|
185
|
+
const ItVar extends string,
|
|
186
186
|
>(
|
|
187
187
|
source: Source & CheckedSyncConf<Source>,
|
|
188
188
|
mapping: Mapping,
|
|
@@ -191,7 +191,7 @@ export function mapArrayValues<
|
|
|
191
191
|
export function mapArrayValues<
|
|
192
192
|
const Source extends TypedConfig,
|
|
193
193
|
const Mapping extends TypedConfig,
|
|
194
|
-
const ItVar extends string
|
|
194
|
+
const ItVar extends string,
|
|
195
195
|
>(
|
|
196
196
|
source: Source,
|
|
197
197
|
mapping: Mapping & CheckedSyncConf<Mapping>,
|
|
@@ -200,26 +200,26 @@ export function mapArrayValues<
|
|
|
200
200
|
export function mapArrayValues<
|
|
201
201
|
const Source extends TypedConfig,
|
|
202
202
|
const Mapping extends TypedConfig,
|
|
203
|
-
const ItVar extends string
|
|
203
|
+
const ItVar extends string,
|
|
204
204
|
>(
|
|
205
205
|
source: Source,
|
|
206
206
|
mapping: Mapping,
|
|
207
|
-
itVar: ItVar = '$it' as ItVar
|
|
207
|
+
itVar: ItVar = '$it' as ItVar,
|
|
208
208
|
): TypedConfig<ActMapArrayValues<ExtractAction<Source>, ExtractAction<Mapping>, ItVar>> {
|
|
209
209
|
return {
|
|
210
210
|
type: 'MapArrayValues',
|
|
211
211
|
source,
|
|
212
212
|
mapping,
|
|
213
|
-
itVar
|
|
213
|
+
itVar,
|
|
214
214
|
} as Cfg as any;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
export function flatten<const Source extends TypedConfig>(
|
|
218
|
-
source: Source
|
|
218
|
+
source: Source,
|
|
219
219
|
): TypedConfig<ActFlatten<ExtractAction<Source>>> {
|
|
220
220
|
return {
|
|
221
221
|
type: 'Flatten',
|
|
222
|
-
source
|
|
222
|
+
source,
|
|
223
223
|
} as Cfg as any;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -228,42 +228,42 @@ export function flatten<const Source extends TypedConfig>(
|
|
|
228
228
|
//
|
|
229
229
|
|
|
230
230
|
export function isEmpty<const Arg extends TypedConfig>(
|
|
231
|
-
arg: Arg
|
|
231
|
+
arg: Arg,
|
|
232
232
|
): TypedConfig<ActIsEmpty<ExtractAction<Arg>>> {
|
|
233
233
|
return {
|
|
234
234
|
type: 'IsEmpty',
|
|
235
|
-
arg
|
|
235
|
+
arg,
|
|
236
236
|
} as Cfg as any;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
export function not<const Operand extends TypedConfig>(
|
|
240
|
-
operand: Operand
|
|
240
|
+
operand: Operand,
|
|
241
241
|
): TypedConfig<ActNot<ExtractAction<Operand>>> {
|
|
242
242
|
return {
|
|
243
243
|
type: 'Not',
|
|
244
|
-
operand
|
|
244
|
+
operand,
|
|
245
245
|
} as Cfg as any;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
export function and<const Operand1 extends TypedConfig, const Operand2 extends TypedConfig>(
|
|
249
249
|
operand1: Operand1,
|
|
250
|
-
operand2: Operand2
|
|
250
|
+
operand2: Operand2,
|
|
251
251
|
): TypedConfig<ActAnd<ExtractAction<Operand1>, ExtractAction<Operand2>>> {
|
|
252
252
|
return {
|
|
253
253
|
type: 'And',
|
|
254
254
|
operand1,
|
|
255
|
-
operand2
|
|
255
|
+
operand2,
|
|
256
256
|
} as Cfg as any;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
export function or<const Operand1 extends TypedConfig, const Operand2 extends TypedConfig>(
|
|
260
260
|
operand1: Operand1,
|
|
261
|
-
operand2: Operand2
|
|
261
|
+
operand2: Operand2,
|
|
262
262
|
): TypedConfig<ActOr<ExtractAction<Operand1>, ExtractAction<Operand2>>> {
|
|
263
263
|
return {
|
|
264
264
|
type: 'Or',
|
|
265
265
|
operand1,
|
|
266
|
-
operand2
|
|
266
|
+
operand2,
|
|
267
267
|
} as Cfg as any;
|
|
268
268
|
}
|
|
269
269
|
|
|
@@ -273,32 +273,32 @@ export function or<const Operand1 extends TypedConfig, const Operand2 extends Ty
|
|
|
273
273
|
|
|
274
274
|
export function getResourceField<
|
|
275
275
|
const Source extends PrimitiveOrConfig,
|
|
276
|
-
const Field extends PrimitiveOrConfig
|
|
276
|
+
const Field extends PrimitiveOrConfig,
|
|
277
277
|
>(
|
|
278
278
|
source: Source,
|
|
279
|
-
field: Field
|
|
279
|
+
field: Field,
|
|
280
280
|
): TypedConfig<ActGetResourceField<POCExtractAction<Source>, POCExtractAction<Field>>> {
|
|
281
281
|
return {
|
|
282
282
|
type: 'GetResourceField',
|
|
283
283
|
source: primitiveToConfig(source),
|
|
284
|
-
field: primitiveToConfig(field)
|
|
284
|
+
field: primitiveToConfig(field),
|
|
285
285
|
} as Cfg as any;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
export function getResourceValueAsJson<T>() {
|
|
289
289
|
return function <const Source extends PrimitiveOrConfig>(
|
|
290
|
-
source: Source
|
|
290
|
+
source: Source,
|
|
291
291
|
): TypedConfig<ActGetResourceValueAsJson<POCExtractAction<Source>, T>> {
|
|
292
292
|
return {
|
|
293
293
|
type: 'GetResourceValueAsJson',
|
|
294
|
-
source: primitiveToConfig(source)
|
|
294
|
+
source: primitiveToConfig(source),
|
|
295
295
|
} as Cfg as any;
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
export function mapResourceFields<
|
|
300
300
|
const Source extends TypedConfig,
|
|
301
|
-
const Mapping extends TypedConfig
|
|
301
|
+
const Mapping extends TypedConfig,
|
|
302
302
|
>(
|
|
303
303
|
source: Source,
|
|
304
304
|
mapping: Mapping
|
|
@@ -306,7 +306,7 @@ export function mapResourceFields<
|
|
|
306
306
|
export function mapResourceFields<
|
|
307
307
|
const Source extends TypedConfig,
|
|
308
308
|
const Mapping extends TypedConfig,
|
|
309
|
-
const ItVar extends string
|
|
309
|
+
const ItVar extends string,
|
|
310
310
|
>(
|
|
311
311
|
source: Source,
|
|
312
312
|
mapping: Mapping,
|
|
@@ -315,17 +315,17 @@ export function mapResourceFields<
|
|
|
315
315
|
export function mapResourceFields<
|
|
316
316
|
const Source extends TypedConfig,
|
|
317
317
|
const Mapping extends TypedConfig,
|
|
318
|
-
const ItVar extends string
|
|
318
|
+
const ItVar extends string,
|
|
319
319
|
>(
|
|
320
320
|
source: Source,
|
|
321
321
|
mapping: Mapping,
|
|
322
|
-
itVar: ItVar = '$it' as ItVar
|
|
322
|
+
itVar: ItVar = '$it' as ItVar,
|
|
323
323
|
): TypedConfig<ActMapResourceFields<ExtractAction<Source>, ExtractAction<Mapping>, ItVar>> {
|
|
324
324
|
return {
|
|
325
325
|
type: 'MapResourceFields',
|
|
326
326
|
source,
|
|
327
327
|
mapping,
|
|
328
|
-
itVar
|
|
328
|
+
itVar,
|
|
329
329
|
} as Cfg as TypedConfig<
|
|
330
330
|
ActMapResourceFields<ExtractAction<Source>, ExtractAction<Mapping>, ItVar>
|
|
331
331
|
>;
|
|
@@ -336,49 +336,49 @@ export function mapResourceFields<
|
|
|
336
336
|
//
|
|
337
337
|
|
|
338
338
|
export function getBlobContent<const Source extends TypedConfig>(
|
|
339
|
-
source: Source
|
|
339
|
+
source: Source,
|
|
340
340
|
): TypedConfig<ActGetBlobContent<ExtractAction<Source>>> {
|
|
341
341
|
return {
|
|
342
342
|
type: 'GetBlobContent',
|
|
343
|
-
source: primitiveToConfig(source)
|
|
343
|
+
source: primitiveToConfig(source),
|
|
344
344
|
} as Cfg as any;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
export function getBlobContentAsString<const Source extends TypedConfig>(
|
|
348
|
-
source: Source
|
|
348
|
+
source: Source,
|
|
349
349
|
): TypedConfig<ActGetBlobContentAsString<ExtractAction<Source>>> {
|
|
350
350
|
return {
|
|
351
351
|
type: 'GetBlobContentAsString',
|
|
352
|
-
source: primitiveToConfig(source)
|
|
352
|
+
source: primitiveToConfig(source),
|
|
353
353
|
} as Cfg as any;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
export function getBlobContentAsJson<T>() {
|
|
357
357
|
return function <const Source extends TypedConfig>(
|
|
358
|
-
source: Source
|
|
358
|
+
source: Source,
|
|
359
359
|
): TypedConfig<ActGetBlobContentAsJson<ExtractAction<Source>, T>> {
|
|
360
360
|
return {
|
|
361
361
|
type: 'GetBlobContentAsJson',
|
|
362
|
-
source: primitiveToConfig(source)
|
|
362
|
+
source: primitiveToConfig(source),
|
|
363
363
|
} as Cfg as any;
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
export function getDownloadedBlobContent<const Source extends TypedConfig>(
|
|
368
|
-
source: Source
|
|
368
|
+
source: Source,
|
|
369
369
|
): TypedConfig<ActGetDownloadedBlobContent<ExtractAction<Source>>> {
|
|
370
370
|
return {
|
|
371
371
|
type: 'GetDownloadedBlobContent',
|
|
372
|
-
source: primitiveToConfig(source)
|
|
372
|
+
source: primitiveToConfig(source),
|
|
373
373
|
} as Cfg as any;
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
export function getOnDemandBlobContent<const Source extends TypedConfig>(
|
|
377
|
-
source: Source
|
|
377
|
+
source: Source,
|
|
378
378
|
): TypedConfig<ActGetOnDemandBlobContent<ExtractAction<Source>>> {
|
|
379
379
|
return {
|
|
380
380
|
type: 'GetOnDemandBlobContent',
|
|
381
|
-
source: primitiveToConfig(source)
|
|
381
|
+
source: primitiveToConfig(source),
|
|
382
382
|
} as Cfg as any;
|
|
383
383
|
}
|
|
384
384
|
|
|
@@ -393,7 +393,7 @@ export function extractArchiveAndGetURL<const Source extends TypedConfig>(
|
|
|
393
393
|
return {
|
|
394
394
|
type: 'ExtractArchiveAndGetURL',
|
|
395
395
|
format,
|
|
396
|
-
source: primitiveToConfig(source)
|
|
396
|
+
source: primitiveToConfig(source),
|
|
397
397
|
} as Cfg as any;
|
|
398
398
|
}
|
|
399
399
|
|
|
@@ -402,11 +402,11 @@ export function extractArchiveAndGetURL<const Source extends TypedConfig>(
|
|
|
402
402
|
//
|
|
403
403
|
|
|
404
404
|
export function getImportProgress<const Source extends TypedConfig>(
|
|
405
|
-
source: Source
|
|
405
|
+
source: Source,
|
|
406
406
|
): TypedConfig<ActImportProgress<ExtractAction<Source>>> {
|
|
407
407
|
return {
|
|
408
408
|
type: 'GetImportProgress',
|
|
409
|
-
source: primitiveToConfig(source)
|
|
409
|
+
source: primitiveToConfig(source),
|
|
410
410
|
} as Cfg as any;
|
|
411
411
|
}
|
|
412
412
|
|
|
@@ -416,42 +416,42 @@ export function getImportProgress<const Source extends TypedConfig>(
|
|
|
416
416
|
|
|
417
417
|
export function getLastLogs<const Source extends TypedConfig>(
|
|
418
418
|
source: Source,
|
|
419
|
-
lines: number
|
|
419
|
+
lines: number,
|
|
420
420
|
): TypedConfig<ActGetLastLogs<ExtractAction<Source>>> {
|
|
421
421
|
return {
|
|
422
422
|
type: 'GetLastLogs',
|
|
423
423
|
source: primitiveToConfig(source),
|
|
424
|
-
lines
|
|
424
|
+
lines,
|
|
425
425
|
} as Cfg as any;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
export function getProgressLog<const Source extends TypedConfig>(
|
|
429
429
|
source: Source,
|
|
430
|
-
patternToSearch: string
|
|
430
|
+
patternToSearch: string,
|
|
431
431
|
): TypedConfig<ActGetProgressLog<ExtractAction<Source>>> {
|
|
432
432
|
return {
|
|
433
433
|
type: 'GetProgressLog',
|
|
434
434
|
source: primitiveToConfig(source),
|
|
435
|
-
patternToSearch
|
|
435
|
+
patternToSearch,
|
|
436
436
|
} as Cfg as any;
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
export function getProgressLogWithInfo<const Source extends TypedConfig>(
|
|
440
440
|
source: Source,
|
|
441
|
-
patternToSearch: string
|
|
441
|
+
patternToSearch: string,
|
|
442
442
|
): TypedConfig<ActGetProgressLogWithInfo<ExtractAction<Source>>> {
|
|
443
443
|
return {
|
|
444
444
|
type: 'GetProgressLogWithInfo',
|
|
445
445
|
source: primitiveToConfig(source),
|
|
446
|
-
patternToSearch
|
|
446
|
+
patternToSearch,
|
|
447
447
|
} as Cfg as any;
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
export function getLogHandle<const Source extends TypedConfig>(
|
|
451
|
-
source: Source
|
|
451
|
+
source: Source,
|
|
452
452
|
): TypedConfig<ActGetLogHandle<ExtractAction<Source>>> {
|
|
453
453
|
return {
|
|
454
454
|
type: 'GetLogHandle',
|
|
455
|
-
source: primitiveToConfig(source)
|
|
455
|
+
source: primitiveToConfig(source),
|
|
456
456
|
} as Cfg as any;
|
|
457
457
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ConfAction, ActionResult, InferVarTypeSafe, PlResourceEntry } from './type_engine';
|
|
2
|
-
import { And, IsA, SyncConfAction } from './type_util';
|
|
3
|
-
import {
|
|
1
|
+
import type { ConfAction, ActionResult, InferVarTypeSafe, PlResourceEntry } from './type_engine';
|
|
2
|
+
import type { And, IsA, SyncConfAction } from './type_util';
|
|
3
|
+
import type {
|
|
4
4
|
LocalBlobHandleAndSize,
|
|
5
5
|
RemoteBlobHandleAndSize,
|
|
6
6
|
ImportProgress,
|
|
7
|
-
FolderURL
|
|
7
|
+
FolderURL,
|
|
8
8
|
} from '@milaboratories/pl-model-common';
|
|
9
|
-
import { AnyLogHandle } from '@milaboratories/pl-model-common';
|
|
9
|
+
import type { AnyLogHandle } from '@milaboratories/pl-model-common';
|
|
10
10
|
|
|
11
11
|
//
|
|
12
12
|
// Context
|
|
@@ -64,7 +64,7 @@ export interface ActGetField<Source extends ConfAction, Field extends ConfAction
|
|
|
64
64
|
export interface ActMapRecordValues<
|
|
65
65
|
Source extends ConfAction,
|
|
66
66
|
Mapping extends ConfAction,
|
|
67
|
-
ItVar extends string
|
|
67
|
+
ItVar extends string,
|
|
68
68
|
> extends ConfAction {
|
|
69
69
|
new: (
|
|
70
70
|
x: this['ctx']
|
|
@@ -77,7 +77,7 @@ export interface ActMapRecordValues<
|
|
|
77
77
|
export interface ActMapArrayValues<
|
|
78
78
|
Source extends ConfAction,
|
|
79
79
|
Mapping extends ConfAction,
|
|
80
|
-
ItVar extends string
|
|
80
|
+
ItVar extends string,
|
|
81
81
|
> extends ConfAction {
|
|
82
82
|
new: (
|
|
83
83
|
x: this['ctx']
|
|
@@ -149,7 +149,7 @@ export interface ActGetResourceField<Source extends ConfAction, Field extends Co
|
|
|
149
149
|
export interface ActMapResourceFields<
|
|
150
150
|
Source extends ConfAction,
|
|
151
151
|
Mapping extends ConfAction,
|
|
152
|
-
ItVar extends string
|
|
152
|
+
ItVar extends string,
|
|
153
153
|
> extends ConfAction {
|
|
154
154
|
new: (
|
|
155
155
|
x: this['ctx']
|
|
@@ -212,7 +212,7 @@ export interface ActGetOnDemandBlobContent<Source extends ConfAction> extends Co
|
|
|
212
212
|
export interface ActExtractArchiveAndGetURL<Source extends ConfAction> extends ConfAction {
|
|
213
213
|
new: (
|
|
214
214
|
x: this['ctx']
|
|
215
|
-
) => ActionResult<Source, typeof x> extends PlResourceEntry? FolderURL : unknown;
|
|
215
|
+
) => ActionResult<Source, typeof x> extends PlResourceEntry ? FolderURL : unknown;
|
|
216
216
|
isSync: IsA<Source, SyncConfAction>;
|
|
217
217
|
}
|
|
218
218
|
|
package/src/config/model.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArchiveFormat } from
|
|
1
|
+
import type { ArchiveFormat } from '@milaboratories/pl-model-common';
|
|
2
2
|
|
|
3
3
|
export type Cfg =
|
|
4
4
|
| CfgGetFromCtx
|
|
@@ -55,6 +55,8 @@ export type CfgGetFromCtx = {
|
|
|
55
55
|
|
|
56
56
|
export type CfgImmediate = {
|
|
57
57
|
type: 'Immediate';
|
|
58
|
+
// TODO: could we use `unknown` here?
|
|
59
|
+
|
|
58
60
|
value: any;
|
|
59
61
|
};
|
|
60
62
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ActGetImmediate } from './actions_kinds';
|
|
2
|
-
import { Cfg } from './model';
|
|
1
|
+
import type { ActGetImmediate } from './actions_kinds';
|
|
2
|
+
import type { Cfg } from './model';
|
|
3
3
|
|
|
4
4
|
// Higher kind types pattern taken from here: https://code.lol/post/programming/higher-kinded-types/
|
|
5
5
|
|
|
@@ -50,6 +50,7 @@ export type InferVarTypeSafe<Ctx, V> = V extends string
|
|
|
50
50
|
|
|
51
51
|
export type ConfigResult<Cfg extends TypedConfig, Ctx> = ActionResult<ExtractAction<Cfg>, Ctx>;
|
|
52
52
|
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
54
|
declare const plResourceEntry: unique symbol;
|
|
54
55
|
|
|
55
56
|
/** Marks that a certain variable in context is a resource entry */
|
package/src/config/type_util.ts
CHANGED
package/src/internal.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {} from './global';
|
|
2
|
-
import { Platforma
|
|
3
|
-
import { FutureHandle, GlobalCfgRenderCtx } from './render/internal';
|
|
2
|
+
import type { Platforma } from './platforma';
|
|
3
|
+
import type { FutureHandle, GlobalCfgRenderCtx } from './render/internal';
|
|
4
4
|
|
|
5
5
|
/** Utility code helping to identify whether the code is running in actual UI environment */
|
|
6
6
|
export function isInUI() {
|
|
@@ -10,11 +10,11 @@ export function isInUI() {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/** Utility code helping to retrieve a platforma instance form the environment */
|
|
13
|
-
export function getPlatformaInstance(config?: {sdkVersion: string}): Platforma {
|
|
13
|
+
export function getPlatformaInstance(config?: { sdkVersion: string }): Platforma {
|
|
14
14
|
if (config && typeof globalThis.getPlatforma === 'function')
|
|
15
15
|
return globalThis.getPlatforma(config);
|
|
16
16
|
else if (typeof globalThis.platforma !== 'undefined') return globalThis.platforma;
|
|
17
|
-
else throw new Error(
|
|
17
|
+
else throw new Error('Can\'t get platforma instance.');
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function tryGetCfgRenderCtx(): GlobalCfgRenderCtx | undefined {
|