@platforma-sdk/model 1.49.0 → 1.51.2
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 +8 -1
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +3 -3
- package/dist/block_state_util.d.ts.map +1 -1
- package/dist/block_state_util.js.map +1 -1
- package/dist/builder.cjs +18 -1
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +41 -8
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +18 -1
- package/dist/builder.js.map +1 -1
- package/dist/components/PlDataTable.cjs +16 -3
- package/dist/components/PlDataTable.cjs.map +1 -1
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlDataTable.js +16 -3
- package/dist/components/PlDataTable.js.map +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -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 +1 -0
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.js +1 -0
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/platforma.d.ts +5 -5
- package/dist/platforma.d.ts.map +1 -1
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +2 -2
- package/dist/raw_globals.d.ts.map +1 -1
- package/dist/raw_globals.js.map +1 -1
- package/package.json +7 -7
- package/src/bconfig/lambdas.ts +10 -1
- package/src/block_state_util.ts +3 -3
- package/src/builder.ts +69 -17
- package/src/components/PlDataTable.ts +17 -2
- package/src/internal.ts +2 -2
- package/src/platforma.ts +5 -5
- package/src/raw_globals.ts +2 -2
- package/src/typing.test.ts +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns.js","sources":["../../src/pframe_utils/columns.ts"],"sourcesContent":["import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratories/pl-model-common';\nimport { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';\nimport type { AxesVault } from '../components';\nimport { enrichCompatible, getAvailableWithLinkersAxes } from '../components';\nimport type { RenderCtx, PColumnDataUniversal } from '../render';\nimport { PColumnCollection } from '../render';\n\nexport function getAllRelatedColumns<A, U>(\n ctx: RenderCtx<A, U>, predicate: (spec: PColumnSpec) => boolean,\n): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block doesn't produce own columns then use all columns from result pool\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return extendedColumns;\n}\n\nexport function getRelatedColumns<A, U>(ctx: RenderCtx<A, U>, { columns: rootColumns, predicate }: {\n columns: PColumn<PColumnDataUniversal>[];\n predicate: (spec: PColumnSpec) => boolean;\n}): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(rootColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of rootColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n const blockAxesArr = Array.from(blockAxes.values());\n // all compatible with block columns but without label columns\n let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n const allAxesArr = Array.from(allAxes.values());\n // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)\n compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return extendedColumns;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"columns.js","sources":["../../src/pframe_utils/columns.ts"],"sourcesContent":["import type { PColumn, PColumnSpec, PColumnLazy, PFrameDef } from '@milaboratories/pl-model-common';\nimport { getNormalizedAxesList, getAxisId, canonicalizeJson, isLinkerColumn, matchAxisId, isLabelColumn } from '@milaboratories/pl-model-common';\nimport type { AxesVault } from '../components';\nimport { enrichCompatible, getAvailableWithLinkersAxes } from '../components';\nimport type { RenderCtx, PColumnDataUniversal } from '../render';\nimport { PColumnCollection } from '../render';\n\nexport function getAllRelatedColumns<A, U>(\n ctx: RenderCtx<A, U>, predicate: (spec: PColumnSpec) => boolean,\n): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block doesn't produce own columns then use all columns from result pool\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n const allColumns = columns.getUniversalEntries(predicate, { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? [];\n\n const allAxes: AxesVault = new Map(allColumns\n .flatMap((column) => getNormalizedAxesList(column.spec.axesSpec))\n .map((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return [canonicalizeJson(axisId), axisSpec];\n }));\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(allAxes, allColumns);\n\n return extendedColumns;\n}\n\nexport function getRelatedColumns<A, U>(ctx: RenderCtx<A, U>, { columns: rootColumns, predicate }: {\n columns: PColumn<PColumnDataUniversal>[];\n predicate: (spec: PColumnSpec) => boolean;\n}): PFrameDef<PColumn<PColumnDataUniversal> | PColumnLazy<undefined | PColumnDataUniversal>> {\n // if current block has its own columns then take from result pool only compatible with them\n const columns = new PColumnCollection();\n columns.addColumnProvider(ctx.resultPool);\n columns.addColumns(rootColumns);\n\n // all possible axes from block columns\n const blockAxes: AxesVault = new Map();\n // axes from block columns and compatible result pool columns\n const allAxes: AxesVault = new Map();\n for (const c of rootColumns) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n blockAxes.set(canonicalizeJson(aid), spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n // all linker columns always go to pFrame - even it's impossible to use some of them they all are hidden\n const linkerColumns = columns.getUniversalEntries((spec) => predicate(spec) && isLinkerColumn(spec)) ?? [];\n const availableWithLinkersAxes = getAvailableWithLinkersAxes(linkerColumns, blockAxes);\n\n // all possible axes from connected linkers\n for (const item of availableWithLinkersAxes) {\n blockAxes.set(...item);\n allAxes.set(...item);\n }\n\n const blockAxesArr = Array.from(blockAxes.values());\n // all compatible with block columns but without label columns\n let compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return blockAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // extend axes set for label columns request\n for (const c of compatibleWithoutLabels) {\n for (const spec of getNormalizedAxesList(c.spec.axesSpec)) {\n const aid = getAxisId(spec);\n allAxes.set(canonicalizeJson(aid), spec);\n }\n }\n\n const allAxesArr = Array.from(allAxes.values());\n // extend allowed columns - add columns thad doesn't have axes from block, but have all axes in 'allAxes' list (that means all axes from linkers or from 'hanging' of other selected columns)\n compatibleWithoutLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.every((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => !isLabelColumn(column.spec));\n\n // label columns must be compatible with full set of axes - block axes and axes from compatible columns from result pool\n const compatibleLabels = (columns.getUniversalEntries((spec) => predicate(spec) && spec.axesSpec.some((axisSpec) => {\n const axisId = getAxisId(axisSpec);\n return allAxesArr.some((selectorAxisSpec) => matchAxisId(getAxisId(selectorAxisSpec), axisId));\n }), { dontWaitAllData: true, overrideLabelAnnotation: false }) ?? []).filter((column) => isLabelColumn(column.spec));\n\n const compatible = [...compatibleWithoutLabels, ...compatibleLabels];\n\n // additional columns are duplicates with extra fields in domains for compatibility if there are ones with partial match\n const extendedColumns = enrichCompatible(blockAxes, compatible);\n\n return extendedColumns;\n}\n"],"names":[],"mappings":";;;;;;;AAOM,SAAU,oBAAoB,CAClC,GAAoB,EAAE,SAAyC,EAAA;;AAG/D,IAAA,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAE;AACvC,IAAA,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE;AAE1H,IAAA,MAAM,OAAO,GAAc,IAAI,GAAG,CAAC;AAChC,SAAA,OAAO,CAAC,CAAC,MAAM,KAAK,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC/D,SAAA,GAAG,CAAC,CAAC,QAAQ,KAAI;AAChB,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;QAClC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC7C,CAAC,CAAC,CAAC;;IAGL,MAAM,eAAe,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC;AAE7D,IAAA,OAAO,eAAe;AACxB;AAEM,SAAU,iBAAiB,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,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;IAGrH,MAAM,gBAAgB,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACjH,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;AAClC,QAAA,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,gBAAgB,KAAK,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAC;AAChG,IAAA,CAAC,CAAC,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,uBAAuB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpH,MAAM,UAAU,GAAG,CAAC,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,CAAC;;IAGpE,MAAM,eAAe,GAAG,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC;AAE/D,IAAA,OAAO,eAAe;AACxB;;;;"}
|
package/dist/platforma.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { BlockApiV1 } from './block_api_v1';
|
|
2
2
|
import type { BlockApiV2 } from './block_api_v2';
|
|
3
|
-
import type { BlockOutputsBase, BlockState, DriverKit,
|
|
3
|
+
import type { BlockOutputsBase, BlockState, DriverKit, OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
4
4
|
import type { SdkInfo } from './sdk_info';
|
|
5
5
|
import type { BlockStatePatch } from './block_state_patch';
|
|
6
6
|
/** Defines all methods to interact with the platform environment from within a block UI. @deprecated */
|
|
7
|
-
export interface PlatformaV1<Args = unknown, Outputs extends Record<string,
|
|
7
|
+
export interface PlatformaV1<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiState = unknown, Href extends `/${string}` = `/${string}`> extends BlockApiV1<Args, Outputs, UiState, Href>, DriverKit {
|
|
8
8
|
/** Information about SDK version current platforma environment was compiled with. */
|
|
9
9
|
readonly sdkInfo: SdkInfo;
|
|
10
10
|
readonly apiVersion?: 1;
|
|
11
11
|
}
|
|
12
12
|
/** V2 version based on effective json patches pulling API */
|
|
13
|
-
export interface PlatformaV2<Args = unknown, Outputs extends Record<string,
|
|
13
|
+
export interface PlatformaV2<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiState = unknown, Href extends `/${string}` = `/${string}`> extends BlockApiV2<Args, Outputs, UiState, Href>, DriverKit {
|
|
14
14
|
/** Information about SDK version current platforma environment was compiled with. */
|
|
15
15
|
readonly sdkInfo: SdkInfo;
|
|
16
16
|
readonly apiVersion: 2;
|
|
17
17
|
}
|
|
18
|
-
export type Platforma<Args = unknown, Outputs extends Record<string,
|
|
18
|
+
export type Platforma<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiState = unknown, Href extends `/${string}` = `/${string}`> = PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href>;
|
|
19
19
|
export type PlatformaApiVersion = Platforma['apiVersion'];
|
|
20
20
|
export type InferArgsType<Pl extends Platforma> = Pl extends Platforma<infer Args> ? Args : never;
|
|
21
21
|
export type InferOutputsType<Pl extends Platforma> = Pl extends Platforma<unknown, infer Outputs> ? Outputs : never;
|
|
22
|
-
export type InferUiState<Pl extends Platforma> = Pl extends Platforma<unknown, Record<string,
|
|
22
|
+
export type InferUiState<Pl extends Platforma> = Pl extends Platforma<unknown, Record<string, OutputWithStatus<unknown>>, infer UiState> ? UiState : never;
|
|
23
23
|
export type InferHrefType<Pl extends Platforma> = Pl extends Platforma<unknown, BlockOutputsBase, unknown, infer Href> ? Href : never;
|
|
24
24
|
export type PlatformaFactory = (config: {
|
|
25
25
|
sdkVersion: string;
|
package/dist/platforma.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platforma.d.ts","sourceRoot":"","sources":["../src/platforma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"platforma.d.ts","sourceRoot":"","sources":["../src/platforma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wGAAwG;AACxG,MAAM,WAAW,WAAW,CAC1B,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EACrG,OAAO,GAAG,OAAO,EACjB,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,CACxC,SAAQ,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAChD,SAAS;IACT,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1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AAC,GAAG,OAAO,GAAG,KAAK,CAAC;AAEjE,MAAM,MAAM,YAAY,CAAC,EAAE,SAAS,SAAS,IAC3C,EAAE,SAAS,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,OAAO,CAAC,GACnF,OAAO,GACP,KAAK,CAAC;AAEZ,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,SAAS,IAC5C,EAAE,SAAS,SAAS,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAEtF,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,KAAK,SAAS,CAAC;AAE7E,MAAM,MAAM,eAAe,CAAC,EAAE,SAAS,SAAS,IAAI,UAAU,CAC5D,aAAa,CAAC,EAAE,CAAC,EACjB,gBAAgB,CAAC,EAAE,CAAC,EACpB,YAAY,CAAC,EAAE,CAAC,EAChB,aAAa,CAAC,EAAE,CAAC,CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,EAAE,SAAS,SAAS,IAAI,eAAe,CACtE,aAAa,CAAC,EAAE,CAAC,EACjB,gBAAgB,CAAC,EAAE,CAAC,EACpB,YAAY,CAAC,EAAE,CAAC,EAChB,aAAa,CAAC,EAAE,CAAC,CAClB,CAAC"}
|
package/dist/raw_globals.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw_globals.cjs","sources":["../src/raw_globals.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"raw_globals.cjs","sources":["../src/raw_globals.ts"],"sourcesContent":["import type { OutputWithStatus } from '@milaboratories/pl-model-common';\nimport {} from './global';\nimport { getPlatformaInstance } from './internal';\nimport type { Platforma, PlatformaApiVersion } from './platforma';\nimport { PlatformaSDKVersion } from './version';\n\nexport function getPlatformaApiVersion(): PlatformaApiVersion {\n return platformaApiVersion ?? 1; // undefined means 1 for backward compatibility\n}\n\nexport function getRawPlatformaInstance<\n Args = unknown,\n Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n>(): Platforma<Args, Outputs, UiState, Href> {\n return getPlatformaInstance<Args, Outputs, UiState, Href>({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion });\n}\n\n/** Returns a global platforma instance or a provided fallback if it's not available. */\n// export function getPlatformaOrDefault<\n// Args = unknown,\n// Outputs extends Record<string, ValueOrErrors<unknown>> = Record<string, ValueOrErrors<unknown>>,\n// UiState = unknown,\n// Href extends `/${string}` = `/${string}`,\n// >(): PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href> {\n// try {\n// return getRawPlatformaInstance<Args, Outputs, UiState, Href>();\n// } catch {\n// return platforma;\n// }\n// }\n"],"names":["getPlatformaInstance","PlatformaSDKVersion"],"mappings":";;;;;SAMgB,sBAAsB,GAAA;AACpC,IAAA,OAAO,mBAAmB,IAAI,CAAC,CAAC;AAClC;SAEgB,uBAAuB,GAAA;AAMrC,IAAA,OAAOA,6BAAoB,CAA+B,EAAE,UAAU,EAAEC,2BAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;AACjI;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;"}
|
package/dist/raw_globals.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
2
2
|
import type { Platforma, PlatformaApiVersion } from './platforma';
|
|
3
3
|
export declare function getPlatformaApiVersion(): PlatformaApiVersion;
|
|
4
|
-
export declare function getRawPlatformaInstance<Args = unknown, Outputs extends Record<string,
|
|
4
|
+
export declare function getRawPlatformaInstance<Args = unknown, Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>, UiState = unknown, Href extends `/${string}` = `/${string}`>(): Platforma<Args, Outputs, UiState, Href>;
|
|
5
5
|
/** Returns a global platforma instance or a provided fallback if it's not available. */
|
|
6
6
|
//# sourceMappingURL=raw_globals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw_globals.d.ts","sourceRoot":"","sources":["../src/raw_globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"raw_globals.d.ts","sourceRoot":"","sources":["../src/raw_globals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlE,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D;AAED,wBAAgB,uBAAuB,CACrC,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EACrG,OAAO,GAAG,OAAO,EACjB,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,KACrC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAE3C;AAED,wFAAwF"}
|
package/dist/raw_globals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw_globals.js","sources":["../src/raw_globals.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"raw_globals.js","sources":["../src/raw_globals.ts"],"sourcesContent":["import type { OutputWithStatus } from '@milaboratories/pl-model-common';\nimport {} from './global';\nimport { getPlatformaInstance } from './internal';\nimport type { Platforma, PlatformaApiVersion } from './platforma';\nimport { PlatformaSDKVersion } from './version';\n\nexport function getPlatformaApiVersion(): PlatformaApiVersion {\n return platformaApiVersion ?? 1; // undefined means 1 for backward compatibility\n}\n\nexport function getRawPlatformaInstance<\n Args = unknown,\n Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n>(): Platforma<Args, Outputs, UiState, Href> {\n return getPlatformaInstance<Args, Outputs, UiState, Href>({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion });\n}\n\n/** Returns a global platforma instance or a provided fallback if it's not available. */\n// export function getPlatformaOrDefault<\n// Args = unknown,\n// Outputs extends Record<string, ValueOrErrors<unknown>> = Record<string, ValueOrErrors<unknown>>,\n// UiState = unknown,\n// Href extends `/${string}` = `/${string}`,\n// >(): PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href> {\n// try {\n// return getRawPlatformaInstance<Args, Outputs, UiState, Href>();\n// } catch {\n// return platforma;\n// }\n// }\n"],"names":[],"mappings":";;;SAMgB,sBAAsB,GAAA;AACpC,IAAA,OAAO,mBAAmB,IAAI,CAAC,CAAC;AAClC;SAEgB,uBAAuB,GAAA;AAMrC,IAAA,OAAO,oBAAoB,CAA+B,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;AACjI;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.51.2",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,20 +23,20 @@
|
|
|
23
23
|
"canonicalize": "~2.1.0",
|
|
24
24
|
"es-toolkit": "^1.39.10",
|
|
25
25
|
"zod": "~3.23.8",
|
|
26
|
-
"@milaboratories/ptabler-expression-js": "1.1.
|
|
26
|
+
"@milaboratories/ptabler-expression-js": "1.1.9",
|
|
27
27
|
"@milaboratories/pl-error-like": "1.12.5",
|
|
28
|
-
"@milaboratories/pl-model-common": "1.
|
|
28
|
+
"@milaboratories/pl-model-common": "1.23.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "~5.6.3",
|
|
32
32
|
"vitest": "^4.0.16",
|
|
33
33
|
"@vitest/coverage-istanbul": "^4.0.16",
|
|
34
34
|
"fast-json-patch": "^3.1.1",
|
|
35
|
-
"@milaboratories/eslint-config": "1.0.5",
|
|
36
35
|
"@milaboratories/build-configs": "1.2.1",
|
|
37
|
-
"@milaboratories/helpers": "1.
|
|
38
|
-
"@milaboratories/
|
|
39
|
-
"@milaboratories/ts-configs": "1.2.0"
|
|
36
|
+
"@milaboratories/helpers": "1.13.0",
|
|
37
|
+
"@milaboratories/eslint-config": "1.0.5",
|
|
38
|
+
"@milaboratories/ts-configs": "1.2.0",
|
|
39
|
+
"@milaboratories/ts-builder": "1.2.1"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"type-check": "ts-builder types --target node",
|
package/src/bconfig/lambdas.ts
CHANGED
|
@@ -29,13 +29,22 @@ export type ConfigRenderLambdaFlags = {
|
|
|
29
29
|
* nobody is actively monitoring rendered values. Like file upload progress, that triggers upload itself.
|
|
30
30
|
* */
|
|
31
31
|
isActive?: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* If true, result will be wrapped with additional status information,
|
|
35
|
+
* such as stability status and explicit error
|
|
36
|
+
*/
|
|
37
|
+
withStatus?: boolean;
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
/** Creates branded Cfg type */
|
|
35
|
-
export interface ConfigRenderLambda<
|
|
41
|
+
export interface ConfigRenderLambda<Return = unknown> extends ConfigRenderLambdaFlags {
|
|
36
42
|
/** Type marker */
|
|
37
43
|
__renderLambda: true;
|
|
38
44
|
|
|
45
|
+
/** Phantom property for type inference. Never set at runtime. */
|
|
46
|
+
__phantomReturn?: Return;
|
|
47
|
+
|
|
39
48
|
/** Reference to a callback registered inside the model code. */
|
|
40
49
|
handle: string;
|
|
41
50
|
}
|
package/src/block_state_util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockOutputsBase,
|
|
1
|
+
import type { BlockOutputsBase, OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
2
2
|
import type { ErrorLike } from '@milaboratories/pl-error-like';
|
|
3
3
|
|
|
4
4
|
export class OutputError extends Error {
|
|
@@ -10,12 +10,12 @@ export class OutputError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function readOutput<T>(outputValue:
|
|
13
|
+
export function readOutput<T>(outputValue: OutputWithStatus<T>): T {
|
|
14
14
|
if (!outputValue.ok) throw new OutputError(outputValue.errors, outputValue.moreErrors);
|
|
15
15
|
return outputValue.value;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
type ExtractValueType<V extends
|
|
18
|
+
type ExtractValueType<V extends OutputWithStatus<unknown>> = Extract<V, { ok: true }>['value'];
|
|
19
19
|
type SimpleOutputs<Outputs extends BlockOutputsBase> = {
|
|
20
20
|
[Key in keyof Outputs]: ExtractValueType<Outputs[Key]>;
|
|
21
21
|
};
|
package/src/builder.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockRenderingMode, BlockSection,
|
|
1
|
+
import type { BlockRenderingMode, BlockSection, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer, OutputWithStatus } 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';
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
} from './bconfig';
|
|
18
18
|
import {
|
|
19
19
|
downgradeCfgOrLambda,
|
|
20
|
+
isConfigLambda,
|
|
20
21
|
} from './bconfig';
|
|
21
22
|
|
|
22
23
|
type SectionsExpectedType = readonly BlockSection[];
|
|
@@ -117,6 +118,24 @@ export class BlockModel<
|
|
|
117
118
|
key: Key,
|
|
118
119
|
cfg: Cfg
|
|
119
120
|
): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;
|
|
121
|
+
/**
|
|
122
|
+
* Add output cell wrapped with additional status information to the configuration
|
|
123
|
+
*
|
|
124
|
+
* @param key output cell name, that can be later used to retrieve the rendered value
|
|
125
|
+
* @param rf callback calculating output value using context, that allows to access
|
|
126
|
+
* workflows outputs and interact with platforma drivers
|
|
127
|
+
* @param flags additional flags that may alter lambda rendering procedure
|
|
128
|
+
* */
|
|
129
|
+
public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(
|
|
130
|
+
key: Key,
|
|
131
|
+
rf: RF,
|
|
132
|
+
flags: ConfigRenderLambdaFlags & { withStatus: true }
|
|
133
|
+
): BlockModel<
|
|
134
|
+
Args,
|
|
135
|
+
OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true } },
|
|
136
|
+
UiState,
|
|
137
|
+
Href
|
|
138
|
+
>;
|
|
120
139
|
/**
|
|
121
140
|
* Add output cell to the configuration
|
|
122
141
|
*
|
|
@@ -169,15 +188,26 @@ export class BlockModel<
|
|
|
169
188
|
public retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(
|
|
170
189
|
key: Key,
|
|
171
190
|
rf: RF,
|
|
172
|
-
)
|
|
173
|
-
Args,
|
|
174
|
-
OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },
|
|
175
|
-
UiState,
|
|
176
|
-
Href
|
|
177
|
-
> {
|
|
191
|
+
) {
|
|
178
192
|
return this.output(key, rf, { retentive: true });
|
|
179
193
|
}
|
|
180
194
|
|
|
195
|
+
/** Shortcut for {@link output} with withStatus flag set to true. */
|
|
196
|
+
public outputWithStatus<const Key extends string, const RF extends RenderFunction<Args, UiState>>(
|
|
197
|
+
key: Key,
|
|
198
|
+
rf: RF,
|
|
199
|
+
) {
|
|
200
|
+
return this.output(key, rf, { withStatus: true });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Shortcut for {@link output} with retentive and withStatus flags set to true. */
|
|
204
|
+
public retentiveOutputWithStatus<const Key extends string, const RF extends RenderFunction<Args, UiState>>(
|
|
205
|
+
key: Key,
|
|
206
|
+
rf: RF,
|
|
207
|
+
) {
|
|
208
|
+
return this.output(key, rf, { retentive: true, withStatus: true });
|
|
209
|
+
}
|
|
210
|
+
|
|
181
211
|
/** Sets custom configuration predicate on the block args at which block can be executed
|
|
182
212
|
* @deprecated use lambda-based API */
|
|
183
213
|
public argsValid<Cfg extends TypedConfig>(
|
|
@@ -339,41 +369,41 @@ export class BlockModel<
|
|
|
339
369
|
});
|
|
340
370
|
}
|
|
341
371
|
|
|
342
|
-
public done(apiVersion?: 1): PlatformaV1<
|
|
372
|
+
public done(apiVersion?: 1): PlatformaExtended<PlatformaV1<
|
|
343
373
|
Args,
|
|
344
374
|
InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
|
|
345
375
|
UiState,
|
|
346
376
|
Href
|
|
347
|
-
|
|
377
|
+
>>;
|
|
348
378
|
|
|
349
|
-
public done(apiVersion: 2): PlatformaV2<
|
|
379
|
+
public done(apiVersion: 2): PlatformaExtended<PlatformaV2<
|
|
350
380
|
Args,
|
|
351
381
|
InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
|
|
352
382
|
UiState,
|
|
353
383
|
Href
|
|
354
|
-
|
|
384
|
+
>>;
|
|
355
385
|
|
|
356
386
|
/** Renders all provided block settings into a pre-configured platforma API
|
|
357
387
|
* instance, that can be used in frontend to interact with block state, and
|
|
358
388
|
* other features provided by the platforma to the block. */
|
|
359
|
-
public done(apiVersion: PlatformaApiVersion = 1): Platforma<
|
|
389
|
+
public done(apiVersion: PlatformaApiVersion = 1): PlatformaExtended<Platforma<
|
|
360
390
|
Args,
|
|
361
391
|
InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
|
|
362
392
|
UiState,
|
|
363
393
|
Href
|
|
364
|
-
|
|
394
|
+
>> {
|
|
365
395
|
return this.withFeatureFlags({
|
|
366
396
|
...this.config.featureFlags,
|
|
367
397
|
requiresUIAPIVersion: apiVersion,
|
|
368
398
|
}).#done();
|
|
369
399
|
}
|
|
370
400
|
|
|
371
|
-
#done(): Platforma<
|
|
401
|
+
#done(): PlatformaExtended<Platforma<
|
|
372
402
|
Args,
|
|
373
403
|
InferOutputsFromConfigs<Args, OutputsCfg, UiState>,
|
|
374
404
|
UiState,
|
|
375
405
|
Href
|
|
376
|
-
|
|
406
|
+
>> {
|
|
377
407
|
if (this.config.initialArgs === undefined) throw new Error('Initial arguments not set.');
|
|
378
408
|
|
|
379
409
|
const config: BlockConfigContainer = {
|
|
@@ -409,7 +439,17 @@ export class BlockModel<
|
|
|
409
439
|
// we are in the configuration rendering routine, not in actual UI
|
|
410
440
|
return { config } as any;
|
|
411
441
|
// normal operation inside the UI
|
|
412
|
-
else return
|
|
442
|
+
else return {
|
|
443
|
+
...getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }),
|
|
444
|
+
blockModelInfo: {
|
|
445
|
+
outputs: Object.fromEntries(
|
|
446
|
+
Object.entries(this.config.outputs)
|
|
447
|
+
.map(([key, value]) => [key, {
|
|
448
|
+
withStatus: Boolean(isConfigLambda(value) && value.withStatus),
|
|
449
|
+
}]),
|
|
450
|
+
),
|
|
451
|
+
},
|
|
452
|
+
};
|
|
413
453
|
}
|
|
414
454
|
}
|
|
415
455
|
|
|
@@ -424,5 +464,17 @@ type InferOutputsFromConfigs<
|
|
|
424
464
|
OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,
|
|
425
465
|
UiState,
|
|
426
466
|
> = {
|
|
427
|
-
[Key in keyof OutputsCfg]:
|
|
467
|
+
[Key in keyof OutputsCfg]:
|
|
468
|
+
& OutputWithStatus<InferOutputType<OutputsCfg[Key], Args, UiState>>
|
|
469
|
+
& { __unwrap: (OutputsCfg[Key] extends { withStatus: true } ? false : true) };
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
export type PlatformaExtended<Pl extends Platforma = Platforma> = Pl & {
|
|
473
|
+
blockModelInfo: BlockModelInfo;
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
export type BlockModelInfo = {
|
|
477
|
+
outputs: Record<string, {
|
|
478
|
+
withStatus: boolean;
|
|
479
|
+
}>;
|
|
428
480
|
};
|
|
@@ -39,8 +39,10 @@ import type {
|
|
|
39
39
|
} from '../render';
|
|
40
40
|
import {
|
|
41
41
|
allPColumnsReady,
|
|
42
|
+
deriveLabels,
|
|
42
43
|
PColumnCollection,
|
|
43
44
|
} from '../render';
|
|
45
|
+
import { identity } from 'es-toolkit';
|
|
44
46
|
|
|
45
47
|
export type PlTableColumnId = {
|
|
46
48
|
/** Original column spec */
|
|
@@ -485,7 +487,7 @@ export function getAllLabelColumns(
|
|
|
485
487
|
.getColumns({
|
|
486
488
|
name: PColumnName.Label,
|
|
487
489
|
axes: [{}], // exactly one axis
|
|
488
|
-
}, { dontWaitAllData: true });
|
|
490
|
+
}, { dontWaitAllData: true, overrideLabelAnnotation: false });
|
|
489
491
|
}
|
|
490
492
|
|
|
491
493
|
/** Get label columns matching the provided columns from the result pool */
|
|
@@ -641,7 +643,20 @@ export function createPlDataTableV2<A, U>(
|
|
|
641
643
|
const allLabelColumns = getAllLabelColumns(ctx.resultPool);
|
|
642
644
|
if (!allLabelColumns) return undefined;
|
|
643
645
|
|
|
644
|
-
|
|
646
|
+
let fullLabelColumns = getMatchingLabelColumns(columns.map(getColumnIdAndSpec), allLabelColumns);
|
|
647
|
+
fullLabelColumns = deriveLabels(fullLabelColumns, identity, { includeNativeLabel: true }).map((v) => {
|
|
648
|
+
return {
|
|
649
|
+
...v.value,
|
|
650
|
+
spec: {
|
|
651
|
+
...v.value.spec,
|
|
652
|
+
annotations: {
|
|
653
|
+
...v.value.spec.annotations,
|
|
654
|
+
[Annotation.Label]: v.label,
|
|
655
|
+
},
|
|
656
|
+
},
|
|
657
|
+
};
|
|
658
|
+
});
|
|
659
|
+
|
|
645
660
|
const fullColumns = [...columns, ...fullLabelColumns];
|
|
646
661
|
|
|
647
662
|
const fullColumnsAxes = uniqueBy(
|
package/src/internal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
2
2
|
import { } from './global';
|
|
3
3
|
import type { Platforma, PlatformaApiVersion } from './platforma';
|
|
4
4
|
import type { FutureHandle, GlobalCfgRenderCtx } from './render/internal';
|
|
@@ -13,7 +13,7 @@ export function isInUI() {
|
|
|
13
13
|
/** Utility code helping to retrieve a platforma instance form the environment */
|
|
14
14
|
export function getPlatformaInstance<
|
|
15
15
|
Args = unknown,
|
|
16
|
-
Outputs extends Record<string,
|
|
16
|
+
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
17
17
|
UiState = unknown,
|
|
18
18
|
Href extends `/${string}` = `/${string}`,
|
|
19
19
|
>(config?: { sdkVersion: string; apiVersion: PlatformaApiVersion }): Platforma<Args, Outputs, UiState, Href> {
|
package/src/platforma.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { BlockApiV1 } from './block_api_v1';
|
|
2
2
|
import type { BlockApiV2 } from './block_api_v2';
|
|
3
|
-
import type { BlockOutputsBase, BlockState, DriverKit,
|
|
3
|
+
import type { BlockOutputsBase, BlockState, DriverKit, OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
4
4
|
import type { SdkInfo } from './sdk_info';
|
|
5
5
|
import type { BlockStatePatch } from './block_state_patch';
|
|
6
6
|
|
|
7
7
|
/** Defines all methods to interact with the platform environment from within a block UI. @deprecated */
|
|
8
8
|
export interface PlatformaV1<
|
|
9
9
|
Args = unknown,
|
|
10
|
-
Outputs extends Record<string,
|
|
10
|
+
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
11
11
|
UiState = unknown,
|
|
12
12
|
Href extends `/${string}` = `/${string}`,
|
|
13
13
|
> extends BlockApiV1<Args, Outputs, UiState, Href>,
|
|
@@ -20,7 +20,7 @@ export interface PlatformaV1<
|
|
|
20
20
|
/** V2 version based on effective json patches pulling API */
|
|
21
21
|
export interface PlatformaV2<
|
|
22
22
|
Args = unknown,
|
|
23
|
-
Outputs extends Record<string,
|
|
23
|
+
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
24
24
|
UiState = unknown,
|
|
25
25
|
Href extends `/${string}` = `/${string}`,
|
|
26
26
|
> extends BlockApiV2<Args, Outputs, UiState, Href>,
|
|
@@ -32,7 +32,7 @@ export interface PlatformaV2<
|
|
|
32
32
|
|
|
33
33
|
export type Platforma<
|
|
34
34
|
Args = unknown,
|
|
35
|
-
Outputs extends Record<string,
|
|
35
|
+
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
36
36
|
UiState = unknown,
|
|
37
37
|
Href extends `/${string}` = `/${string}`,
|
|
38
38
|
> = PlatformaV1<Args, Outputs, UiState, Href> | PlatformaV2<Args, Outputs, UiState, Href>;
|
|
@@ -45,7 +45,7 @@ export type InferOutputsType<Pl extends Platforma> =
|
|
|
45
45
|
Pl extends Platforma<unknown, infer Outputs> ? Outputs : never;
|
|
46
46
|
|
|
47
47
|
export type InferUiState<Pl extends Platforma> =
|
|
48
|
-
Pl extends Platforma<unknown, Record<string,
|
|
48
|
+
Pl extends Platforma<unknown, Record<string, OutputWithStatus<unknown>>, infer UiState>
|
|
49
49
|
? UiState
|
|
50
50
|
: never;
|
|
51
51
|
|
package/src/raw_globals.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OutputWithStatus } from '@milaboratories/pl-model-common';
|
|
2
2
|
import {} from './global';
|
|
3
3
|
import { getPlatformaInstance } from './internal';
|
|
4
4
|
import type { Platforma, PlatformaApiVersion } from './platforma';
|
|
@@ -10,7 +10,7 @@ export function getPlatformaApiVersion(): PlatformaApiVersion {
|
|
|
10
10
|
|
|
11
11
|
export function getRawPlatformaInstance<
|
|
12
12
|
Args = unknown,
|
|
13
|
-
Outputs extends Record<string,
|
|
13
|
+
Outputs extends Record<string, OutputWithStatus<unknown>> = Record<string, OutputWithStatus<unknown>>,
|
|
14
14
|
UiState = unknown,
|
|
15
15
|
Href extends `/${string}` = `/${string}`,
|
|
16
16
|
>(): Platforma<Args, Outputs, UiState, Href> {
|
package/src/typing.test.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlockSection,
|
|
3
3
|
LocalBlobHandleAndSize,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
OutputWithStatus,
|
|
5
|
+
RemoteBlobHandleAndSize
|
|
6
6
|
} from '@milaboratories/pl-model-common';
|
|
7
7
|
import { expect, test } from 'vitest';
|
|
8
8
|
import { DeriveHref, StdCtx } from './bconfig';
|
|
@@ -117,8 +117,8 @@ test('test config content', () => {
|
|
|
117
117
|
assertType<
|
|
118
118
|
InferOutputsType<typeof platforma>,
|
|
119
119
|
{
|
|
120
|
-
cell1:
|
|
121
|
-
cell2:
|
|
120
|
+
cell1: OutputWithStatus<{ b: string[] }>;
|
|
121
|
+
cell2: OutputWithStatus<'v1'[]>;
|
|
122
122
|
}
|
|
123
123
|
>();
|
|
124
124
|
|
|
@@ -161,7 +161,7 @@ test('test config 2', () => {
|
|
|
161
161
|
assertType<
|
|
162
162
|
InferOutputsType<typeof platforma>,
|
|
163
163
|
{
|
|
164
|
-
cell1:
|
|
164
|
+
cell1: OutputWithStatus<{
|
|
165
165
|
b: string;
|
|
166
166
|
c: [Uint8Array, 'asd'];
|
|
167
167
|
d: string[];
|
|
@@ -169,8 +169,8 @@ test('test config 2', () => {
|
|
|
169
169
|
f: LocalBlobHandleAndSize;
|
|
170
170
|
g: RemoteBlobHandleAndSize;
|
|
171
171
|
}>;
|
|
172
|
-
cell2:
|
|
173
|
-
cell3:
|
|
172
|
+
cell2: OutputWithStatus<number>;
|
|
173
|
+
cell3: OutputWithStatus<undefined>;
|
|
174
174
|
}
|
|
175
175
|
>();
|
|
176
176
|
|