@platforma-sdk/model 1.48.13 → 1.49.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/builder.cjs +139 -77
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +8 -14
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +139 -77
- package/dist/builder.js.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pframe_utils/index.cjs +2 -0
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +1 -1
- package/dist/pframe_utils/index.d.ts.map +1 -1
- package/dist/pframe_utils/index.js +2 -0
- package/dist/pframe_utils/index.js.map +1 -1
- package/package.json +5 -5
- package/src/builder.ts +145 -187
- package/src/pframe_utils/index.ts +2 -0
package/dist/builder.cjs
CHANGED
|
@@ -13,52 +13,52 @@ var normalization = require('./bconfig/normalization.cjs');
|
|
|
13
13
|
* to call {@link done()} at the end of configuration. Value returned by this builder must be
|
|
14
14
|
* exported as constant with name "platforma" from the "config" module. */
|
|
15
15
|
class BlockModel {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this._initialArgs = _initialArgs;
|
|
28
|
-
this._initialUiState = _initialUiState;
|
|
29
|
-
this._outputs = _outputs;
|
|
30
|
-
this._inputsValid = _inputsValid;
|
|
31
|
-
this._sections = _sections;
|
|
32
|
-
this._title = _title;
|
|
33
|
-
this._enrichmentTargets = _enrichmentTargets;
|
|
34
|
-
this._featureFlags = _featureFlags;
|
|
35
|
-
}
|
|
36
|
-
static INITIAL_BLOCK_FEATURE_FLAGS = {
|
|
37
|
-
supportsLazyState: true,
|
|
38
|
-
requiresUIAPIVersion: 1,
|
|
39
|
-
requiresModelAPIVersion: 1,
|
|
40
|
-
};
|
|
16
|
+
config;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = config;
|
|
19
|
+
}
|
|
20
|
+
static get INITIAL_BLOCK_FEATURE_FLAGS() {
|
|
21
|
+
return {
|
|
22
|
+
supportsLazyState: true,
|
|
23
|
+
requiresUIAPIVersion: 1,
|
|
24
|
+
requiresModelAPIVersion: 1,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
41
27
|
static create(renderingMode = 'Heavy') {
|
|
42
|
-
return new BlockModel(
|
|
28
|
+
return new BlockModel({
|
|
29
|
+
renderingMode,
|
|
30
|
+
initialUiState: {},
|
|
31
|
+
outputs: {},
|
|
32
|
+
inputsValid: actions.getImmediate(true),
|
|
33
|
+
sections: actions.getImmediate([]),
|
|
34
|
+
featureFlags: BlockModel.INITIAL_BLOCK_FEATURE_FLAGS,
|
|
35
|
+
});
|
|
43
36
|
}
|
|
44
37
|
output(key, cfgOrRf, flags = {}) {
|
|
45
38
|
if (typeof cfgOrRf === 'function') {
|
|
46
39
|
const handle = `output#${key}`;
|
|
47
40
|
internal.tryRegisterCallback(handle, () => cfgOrRf(new api.RenderCtx()));
|
|
48
|
-
return new BlockModel(
|
|
49
|
-
...this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
return new BlockModel({
|
|
42
|
+
...this.config,
|
|
43
|
+
outputs: {
|
|
44
|
+
...this.config.outputs,
|
|
45
|
+
[key]: {
|
|
46
|
+
__renderLambda: true,
|
|
47
|
+
handle,
|
|
48
|
+
...flags,
|
|
49
|
+
},
|
|
54
50
|
},
|
|
55
|
-
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return new BlockModel({
|
|
55
|
+
...this.config,
|
|
56
|
+
outputs: {
|
|
57
|
+
...this.config.outputs,
|
|
58
|
+
[key]: cfgOrRf,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
56
61
|
}
|
|
57
|
-
else
|
|
58
|
-
return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
|
|
59
|
-
...this._outputs,
|
|
60
|
-
[key]: cfgOrRf,
|
|
61
|
-
}, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
|
|
62
62
|
}
|
|
63
63
|
/** Shortcut for {@link output} with retentive flag set to true. */
|
|
64
64
|
retentiveOutput(key, rf) {
|
|
@@ -67,13 +67,20 @@ class BlockModel {
|
|
|
67
67
|
argsValid(cfgOrRf) {
|
|
68
68
|
if (typeof cfgOrRf === 'function') {
|
|
69
69
|
internal.tryRegisterCallback('inputsValid', () => cfgOrRf(new api.RenderCtx()));
|
|
70
|
-
return new BlockModel(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
return new BlockModel({
|
|
71
|
+
...this.config,
|
|
72
|
+
inputsValid: {
|
|
73
|
+
__renderLambda: true,
|
|
74
|
+
handle: 'inputsValid',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return new BlockModel({
|
|
80
|
+
...this.config,
|
|
81
|
+
inputsValid: cfgOrRf,
|
|
82
|
+
});
|
|
74
83
|
}
|
|
75
|
-
else
|
|
76
|
-
return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, cfgOrRf, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
|
|
77
84
|
}
|
|
78
85
|
sections(arrOrCfgOrRf) {
|
|
79
86
|
if (Array.isArray(arrOrCfgOrRf)) {
|
|
@@ -81,34 +88,82 @@ class BlockModel {
|
|
|
81
88
|
}
|
|
82
89
|
else if (typeof arrOrCfgOrRf === 'function') {
|
|
83
90
|
internal.tryRegisterCallback('sections', () => arrOrCfgOrRf(new api.RenderCtx()));
|
|
84
|
-
return new BlockModel(
|
|
91
|
+
return new BlockModel({
|
|
92
|
+
...this.config,
|
|
93
|
+
sections: {
|
|
94
|
+
__renderLambda: true,
|
|
95
|
+
handle: 'sections',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return new BlockModel({
|
|
101
|
+
...this.config,
|
|
102
|
+
sections: arrOrCfgOrRf,
|
|
103
|
+
});
|
|
85
104
|
}
|
|
86
|
-
else
|
|
87
|
-
return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, arrOrCfgOrRf, this._title, this._enrichmentTargets, this._featureFlags);
|
|
88
105
|
}
|
|
89
106
|
/** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
|
|
90
107
|
title(rf) {
|
|
91
108
|
internal.tryRegisterCallback('title', () => rf(new api.RenderCtx()));
|
|
92
|
-
return new BlockModel(
|
|
109
|
+
return new BlockModel({
|
|
110
|
+
...this.config,
|
|
111
|
+
title: {
|
|
112
|
+
__renderLambda: true,
|
|
113
|
+
handle: 'title',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
subtitle(rf) {
|
|
118
|
+
internal.tryRegisterCallback('subtitle', () => rf(new api.RenderCtx()));
|
|
119
|
+
return new BlockModel({
|
|
120
|
+
...this.config,
|
|
121
|
+
subtitle: {
|
|
122
|
+
__renderLambda: true,
|
|
123
|
+
handle: 'subtitle',
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
tags(rf) {
|
|
128
|
+
internal.tryRegisterCallback('tags', () => rf(new api.RenderCtx()));
|
|
129
|
+
return new BlockModel({
|
|
130
|
+
...this.config,
|
|
131
|
+
tags: {
|
|
132
|
+
__renderLambda: true,
|
|
133
|
+
handle: 'tags',
|
|
134
|
+
},
|
|
135
|
+
});
|
|
93
136
|
}
|
|
94
137
|
/**
|
|
95
138
|
* Sets initial args for the block, this value must be specified.
|
|
96
139
|
* @deprecated use {@link withArgs}
|
|
97
140
|
* */
|
|
98
141
|
initialArgs(value) {
|
|
99
|
-
return
|
|
142
|
+
return this.withArgs(value);
|
|
100
143
|
}
|
|
101
144
|
/** Sets initial args for the block, this value must be specified. */
|
|
102
|
-
withArgs(
|
|
103
|
-
return new BlockModel(
|
|
145
|
+
withArgs(initialArgs) {
|
|
146
|
+
return new BlockModel({
|
|
147
|
+
...this.config,
|
|
148
|
+
initialArgs,
|
|
149
|
+
});
|
|
104
150
|
}
|
|
105
151
|
/** Defines type and sets initial value for block UiState. */
|
|
106
|
-
withUiState(
|
|
107
|
-
return new BlockModel(
|
|
152
|
+
withUiState(initialUiState) {
|
|
153
|
+
return new BlockModel({
|
|
154
|
+
...this.config,
|
|
155
|
+
initialUiState,
|
|
156
|
+
});
|
|
108
157
|
}
|
|
109
158
|
/** Sets or overrides feature flags for the block. */
|
|
110
159
|
withFeatureFlags(flags) {
|
|
111
|
-
return new BlockModel(
|
|
160
|
+
return new BlockModel({
|
|
161
|
+
...this.config,
|
|
162
|
+
featureFlags: {
|
|
163
|
+
...this.config.featureFlags,
|
|
164
|
+
...flags,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
112
167
|
}
|
|
113
168
|
/**
|
|
114
169
|
* Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
|
|
@@ -116,43 +171,50 @@ class BlockModel {
|
|
|
116
171
|
*/
|
|
117
172
|
enriches(lambda) {
|
|
118
173
|
internal.tryRegisterCallback('enrichmentTargets', lambda);
|
|
119
|
-
return new BlockModel(
|
|
174
|
+
return new BlockModel({
|
|
175
|
+
...this.config,
|
|
176
|
+
enrichmentTargets: {
|
|
177
|
+
__renderLambda: true,
|
|
178
|
+
handle: 'enrichmentTargets',
|
|
179
|
+
},
|
|
180
|
+
});
|
|
120
181
|
}
|
|
121
182
|
/** Renders all provided block settings into a pre-configured platforma API
|
|
122
183
|
* instance, that can be used in frontend to interact with block state, and
|
|
123
184
|
* other features provided by the platforma to the block. */
|
|
124
|
-
done(apiVersion) {
|
|
125
|
-
const requiresUIAPIVersion = apiVersion ?? 1;
|
|
185
|
+
done(apiVersion = 1) {
|
|
126
186
|
return this.withFeatureFlags({
|
|
127
|
-
...this.
|
|
128
|
-
requiresUIAPIVersion,
|
|
129
|
-
})
|
|
187
|
+
...this.config.featureFlags,
|
|
188
|
+
requiresUIAPIVersion: apiVersion,
|
|
189
|
+
}).#done();
|
|
130
190
|
}
|
|
131
|
-
|
|
132
|
-
if (this.
|
|
191
|
+
#done() {
|
|
192
|
+
if (this.config.initialArgs === undefined)
|
|
133
193
|
throw new Error('Initial arguments not set.');
|
|
134
194
|
const config = {
|
|
135
195
|
v3: {
|
|
136
196
|
sdkVersion: version.PlatformaSDKVersion,
|
|
137
|
-
renderingMode: this.
|
|
138
|
-
initialArgs: this.
|
|
139
|
-
initialUiState: this.
|
|
140
|
-
inputsValid: this.
|
|
141
|
-
sections: this.
|
|
142
|
-
title: this.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
197
|
+
renderingMode: this.config.renderingMode,
|
|
198
|
+
initialArgs: this.config.initialArgs,
|
|
199
|
+
initialUiState: this.config.initialUiState,
|
|
200
|
+
inputsValid: this.config.inputsValid,
|
|
201
|
+
sections: this.config.sections,
|
|
202
|
+
title: this.config.title,
|
|
203
|
+
subtitle: this.config.subtitle,
|
|
204
|
+
tags: this.config.tags,
|
|
205
|
+
outputs: this.config.outputs,
|
|
206
|
+
enrichmentTargets: this.config.enrichmentTargets,
|
|
207
|
+
featureFlags: this.config.featureFlags,
|
|
146
208
|
},
|
|
147
209
|
// fields below are added to allow previous desktop versions read generated configs
|
|
148
210
|
sdkVersion: version.PlatformaSDKVersion,
|
|
149
|
-
renderingMode: this.
|
|
150
|
-
initialArgs: this.
|
|
151
|
-
inputsValid: normalization.downgradeCfgOrLambda(this.
|
|
152
|
-
sections: normalization.downgradeCfgOrLambda(this.
|
|
153
|
-
outputs: Object.fromEntries(Object.entries(this.
|
|
211
|
+
renderingMode: this.config.renderingMode,
|
|
212
|
+
initialArgs: this.config.initialArgs,
|
|
213
|
+
inputsValid: normalization.downgradeCfgOrLambda(this.config.inputsValid),
|
|
214
|
+
sections: normalization.downgradeCfgOrLambda(this.config.sections),
|
|
215
|
+
outputs: Object.fromEntries(Object.entries(this.config.outputs).map(([key, value]) => [key, normalization.downgradeCfgOrLambda(value)])),
|
|
154
216
|
};
|
|
155
|
-
globalThis.platformaApiVersion =
|
|
217
|
+
globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion;
|
|
156
218
|
if (!internal.isInUI())
|
|
157
219
|
// we are in the configuration rendering routine, not in actual UI
|
|
158
220
|
return { config };
|
package/dist/builder.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.cjs","sources":["../src/builder.ts"],"sourcesContent":["import type { BlockRenderingMode, BlockSection, ValueOrErrors, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { Checked, ConfigResult, TypedConfig } from './config';\nimport { getImmediate } from './config';\nimport { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';\nimport type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';\nimport type { InferRenderFunctionReturn, RenderFunction } from './render';\nimport { RenderCtx } from './render';\nimport { PlatformaSDKVersion } from './version';\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ResolveCfgType,\n ExtractFunctionHandleReturn,\n ConfigRenderLambdaFlags,\n} from './bconfig';\nimport {\n downgradeCfgOrLambda,\n} from './bconfig';\n\ntype SectionsExpectedType = readonly BlockSection[];\n\ntype SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type SectionsRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends SectionsExpectedType ? true : false\n// >;\n\ntype InputsValidExpectedType = boolean;\n\ntype InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type InputsValidRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends InputsValidExpectedType ? true : false\n// >;\n\ntype NoOb = Record<string, never>;\n\n/** Main entry point that each block should use in it's \"config\" module. Don't forget\n * to call {@link done()} at the end of configuration. Value returned by this builder must be\n * exported as constant with name \"platforma\" from the \"config\" module. */\nexport class BlockModel<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n Href extends `/${string}` = '/',\n> {\n private constructor(\n private readonly _renderingMode: BlockRenderingMode,\n private readonly _initialArgs: Args | undefined,\n private readonly _initialUiState: UiState,\n private readonly _outputs: OutputsCfg,\n private readonly _inputsValid: TypedConfigOrConfigLambda,\n private readonly _sections: TypedConfigOrConfigLambda,\n private readonly _title: ConfigRenderLambda | undefined,\n private readonly _enrichmentTargets: ConfigRenderLambda | undefined,\n private readonly _featureFlags: BlockCodeKnownFeatureFlags,\n ) {}\n\n public static readonly INITIAL_BLOCK_FEATURE_FLAGS: BlockCodeKnownFeatureFlags = {\n supportsLazyState: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n };\n\n /** Initiates configuration builder */\n public static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;\n /** Initiates configuration builder */\n public static create(): BlockModel<NoOb, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(): BlockModel<Args, {}, NoOb>;\n public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {\n return new BlockModel<NoOb, {}, NoOb>(\n renderingMode,\n undefined,\n {},\n {},\n getImmediate(true),\n getImmediate([]),\n undefined,\n undefined,\n { ...BlockModel.INITIAL_BLOCK_FEATURE_FLAGS },\n );\n }\n\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param cfg configuration describing how to render cell value from the blocks\n * workflow outputs\n * @deprecated use lambda-based API\n * */\n public output<const Key extends string, const Cfg extends TypedConfig>(\n key: Key,\n cfg: Cfg\n ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n flags?: ConfigRenderLambdaFlags\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n >;\n public output(\n key: string,\n cfgOrRf: TypedConfig | AnyFunction,\n flags: ConfigRenderLambdaFlags = {},\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n if (typeof cfgOrRf === 'function') {\n const handle = `output#${key}`;\n tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));\n return new BlockModel(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n {\n ...this._outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n } satisfies ConfigRenderLambda,\n },\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n {\n ...this._outputs,\n [key]: cfgOrRf,\n },\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n > {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Sets custom configuration predicate on the block args at which block can be executed\n * @deprecated use lambda-based API */\n public argsValid<Cfg extends TypedConfig>(\n cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n /** Sets custom configuration predicate on the block args at which block can be executed */\n public argsValid<RF extends RenderFunction<Args, UiState, boolean>>(\n rf: RF\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n public argsValid(\n cfgOrRf: TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (typeof cfgOrRf === 'function') {\n tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n {\n __renderLambda: true,\n handle: 'inputsValid',\n } satisfies ConfigRenderLambda,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n cfgOrRf,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets the config to generate list of section in the left block overviews panel\n * @deprecated use lambda-based API */\n public sections<const S extends SectionsExpectedType>(\n rf: S\n ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;\n /** Sets the config to generate list of section in the left block overviews panel */\n public sections<\n const Ret extends SectionsExpectedType,\n const RF extends RenderFunction<Args, UiState, Ret>,\n >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;\n public sections<const Cfg extends TypedConfig>(\n cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>\n ): BlockModel<\n Args,\n OutputsCfg,\n UiState,\n DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>\n >;\n public sections(\n arrOrCfgOrRf: SectionsExpectedType | TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (Array.isArray(arrOrCfgOrRf)) {\n return this.sections(getImmediate(arrOrCfgOrRf));\n } else if (typeof arrOrCfgOrRf === 'function') {\n tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n { __renderLambda: true, handle: 'sections' } as ConfigRenderLambda,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n } else\n return new BlockModel<Args, OutputsCfg, UiState>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n arrOrCfgOrRf as TypedConfig,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */\n public title(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('title', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n { __renderLambda: true, handle: 'title' } as ConfigRenderLambda,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /**\n * Sets initial args for the block, this value must be specified.\n * @deprecated use {@link withArgs}\n * */\n public initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n value,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialValue: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n initialValue,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(initialValue: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n initialValue,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n this._featureFlags,\n );\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n this._enrichmentTargets,\n { ...this._featureFlags, ...flags },\n );\n }\n\n /**\n * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.\n * Influences dependency graph construction.\n */\n public enriches(\n lambda: (args: Args) => PlRef[],\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('enrichmentTargets', lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>(\n this._renderingMode,\n this._initialArgs,\n this._initialUiState,\n this._outputs,\n this._inputsValid,\n this._sections,\n this._title,\n { __renderLambda: true, handle: 'enrichmentTargets' } as ConfigRenderLambda,\n this._featureFlags,\n );\n }\n\n public done(apiVersion?: 1): PlatformaV1<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n public done(apiVersion: 2): PlatformaV2<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n /** Renders all provided block settings into a pre-configured platforma API\n * instance, that can be used in frontend to interact with block state, and\n * other features provided by the platforma to the block. */\n public done(apiVersion?: PlatformaApiVersion): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n const requiresUIAPIVersion = apiVersion ?? 1;\n return this.withFeatureFlags({\n ...this._featureFlags,\n requiresUIAPIVersion,\n })._done(requiresUIAPIVersion);\n }\n\n public _done(apiVersion: PlatformaApiVersion): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n if (this._initialArgs === undefined) throw new Error('Initial arguments not set.');\n\n const config: BlockConfigContainer = {\n v3: {\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this._renderingMode,\n initialArgs: this._initialArgs,\n initialUiState: this._initialUiState,\n inputsValid: this._inputsValid,\n sections: this._sections,\n title: this._title,\n outputs: this._outputs,\n enrichmentTargets: this._enrichmentTargets,\n featureFlags: this._featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this._renderingMode,\n initialArgs: this._initialArgs,\n inputsValid: downgradeCfgOrLambda(this._inputsValid),\n sections: downgradeCfgOrLambda(this._sections),\n outputs: Object.fromEntries(\n Object.entries(this._outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),\n ),\n };\n\n globalThis.platformaApiVersion = apiVersion;\n\n if (!isInUI())\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n // normal operation inside the UI\n else return getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }) as any;\n }\n}\n\nexport type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig\n ? ResolveCfgType<CfgOrFH, Args, UiState>\n : CfgOrFH extends ConfigRenderLambda\n ? ExtractFunctionHandleReturn<CfgOrFH>\n : never;\n\ntype InferOutputsFromConfigs<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n> = {\n [Key in keyof OutputsCfg]: ValueOrErrors<InferOutputType<OutputsCfg[Key], Args, UiState>>;\n};\n"],"names":["getImmediate","tryRegisterCallback","RenderCtx","PlatformaSDKVersion","downgradeCfgOrLambda","isInUI","getPlatformaInstance"],"mappings":";;;;;;;;;;;AAiDA;;AAE0E;MAC7D,UAAU,CAAA;AAOF,IAAA,cAAA;AACA,IAAA,YAAA;AACA,IAAA,eAAA;AACA,IAAA,QAAA;AACA,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,kBAAA;AACA,IAAA,aAAA;AATnB,IAAA,WAAA,CACmB,cAAkC,EAClC,YAA8B,EAC9B,eAAwB,EACxB,QAAoB,EACpB,YAAuC,EACvC,SAAoC,EACpC,MAAsC,EACtC,kBAAkD,EAClD,aAAyC,EAAA;QARzC,IAAA,CAAA,cAAc,GAAd,cAAc;QACd,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,eAAe,GAAf,eAAe;QACf,IAAA,CAAA,QAAQ,GAAR,QAAQ;QACR,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,SAAS,GAAT,SAAS;QACT,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,kBAAkB,GAAlB,kBAAkB;QAClB,IAAA,CAAA,aAAa,GAAb,aAAa;IAC7B;IAEI,OAAgB,2BAA2B,GAA+B;AAC/E,QAAA,iBAAiB,EAAE,IAAI;AACvB,QAAA,oBAAoB,EAAE,CAAC;AACvB,QAAA,uBAAuB,EAAE,CAAC;KAC3B;AAgBM,IAAA,OAAO,MAAM,CAAC,aAAA,GAAoC,OAAO,EAAA;AAC9D,QAAA,OAAO,IAAI,UAAU,CACnB,aAAa,EACb,SAAS,EACT,EAAE,EACF,EAAE,EACFA,oBAAY,CAAC,IAAI,CAAC,EAClBA,oBAAY,CAAC,EAAE,CAAC,EAChB,SAAS,EACT,SAAS,EAC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ErB,YAAA,OAAOC,6BAAoB,CAAC,EAAE,UAAU,EAAEH,2BAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAQ;IAC/G;;;;;"}
|
|
1
|
+
{"version":3,"file":"builder.cjs","sources":["../src/builder.ts"],"sourcesContent":["import type { BlockRenderingMode, BlockSection, ValueOrErrors, AnyFunction, PlRef, BlockCodeKnownFeatureFlags, BlockConfigContainer } from '@milaboratories/pl-model-common';\nimport type { Checked, ConfigResult, TypedConfig } from './config';\nimport { getImmediate } from './config';\nimport { getPlatformaInstance, isInUI, tryRegisterCallback } from './internal';\nimport type { Platforma, PlatformaApiVersion, PlatformaV1, PlatformaV2 } from './platforma';\nimport type { InferRenderFunctionReturn, RenderFunction } from './render';\nimport { RenderCtx } from './render';\nimport { PlatformaSDKVersion } from './version';\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ResolveCfgType,\n ExtractFunctionHandleReturn,\n ConfigRenderLambdaFlags,\n} from './bconfig';\nimport {\n downgradeCfgOrLambda,\n} from './bconfig';\n\ntype SectionsExpectedType = readonly BlockSection[];\n\ntype SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type SectionsRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends SectionsExpectedType ? true : false\n// >;\n\ntype InputsValidExpectedType = boolean;\n\ntype InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<\n Cfg,\n ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false\n>;\n\n// TODO (Unused type in code)\n// type InputsValidRFChecked<RF extends Function> = Checked<\n// RF,\n// InferRenderFunctionReturn<RF> extends InputsValidExpectedType ? true : false\n// >;\n\ntype NoOb = Record<string, never>;\n\n/** Main entry point that each block should use in it's \"config\" module. Don't forget\n * to call {@link done()} at the end of configuration. Value returned by this builder must be\n * exported as constant with name \"platforma\" from the \"config\" module. */\nexport class BlockModel<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n Href extends `/${string}` = '/',\n> {\n private constructor(\n private config: {\n readonly renderingMode: BlockRenderingMode;\n readonly initialArgs?: Args;\n readonly initialUiState: UiState;\n readonly outputs: OutputsCfg;\n readonly inputsValid: TypedConfigOrConfigLambda;\n readonly sections: TypedConfigOrConfigLambda;\n readonly title?: ConfigRenderLambda;\n readonly subtitle?: ConfigRenderLambda;\n readonly tags?: ConfigRenderLambda;\n readonly enrichmentTargets?: ConfigRenderLambda;\n readonly featureFlags: BlockCodeKnownFeatureFlags;\n },\n ) {}\n\n public static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags {\n return {\n supportsLazyState: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n };\n }\n\n /** Initiates configuration builder */\n public static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;\n /** Initiates configuration builder */\n public static create(): BlockModel<NoOb, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;\n /**\n * Initiates configuration builder\n * @deprecated use create method without generic parameter\n */\n public static create<Args>(): BlockModel<Args, {}, NoOb>;\n public static create(renderingMode: BlockRenderingMode = 'Heavy'): BlockModel<NoOb, {}, NoOb> {\n return new BlockModel<NoOb, {}, NoOb>({\n renderingMode,\n initialUiState: {},\n outputs: {},\n inputsValid: getImmediate(true),\n sections: getImmediate([]),\n featureFlags: BlockModel.INITIAL_BLOCK_FEATURE_FLAGS,\n });\n }\n\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param cfg configuration describing how to render cell value from the blocks\n * workflow outputs\n * @deprecated use lambda-based API\n * */\n public output<const Key extends string, const Cfg extends TypedConfig>(\n key: Key,\n cfg: Cfg\n ): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;\n /**\n * Add output cell to the configuration\n *\n * @param key output cell name, that can be later used to retrieve the rendered value\n * @param rf callback calculating output value using context, that allows to access\n * workflows outputs and interact with platforma drivers\n * @param flags additional flags that may alter lambda rendering procedure\n * */\n public output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n flags?: ConfigRenderLambdaFlags\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n >;\n public output(\n key: string,\n cfgOrRf: TypedConfig | AnyFunction,\n flags: ConfigRenderLambdaFlags = {},\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n if (typeof cfgOrRf === 'function') {\n const handle = `output#${key}`;\n tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: {\n __renderLambda: true,\n handle,\n ...flags,\n },\n },\n });\n } else {\n return new BlockModel({\n ...this.config,\n outputs: {\n ...this.config.outputs,\n [key]: cfgOrRf,\n },\n });\n }\n }\n\n /** Shortcut for {@link output} with retentive flag set to true. */\n public retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(\n key: Key,\n rf: RF,\n ): BlockModel<\n Args,\n OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> },\n UiState,\n Href\n > {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Sets custom configuration predicate on the block args at which block can be executed\n * @deprecated use lambda-based API */\n public argsValid<Cfg extends TypedConfig>(\n cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n /** Sets custom configuration predicate on the block args at which block can be executed */\n public argsValid<RF extends RenderFunction<Args, UiState, boolean>>(\n rf: RF\n ): BlockModel<Args, OutputsCfg, UiState, Href>;\n public argsValid(\n cfgOrRf: TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (typeof cfgOrRf === 'function') {\n tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: {\n __renderLambda: true,\n handle: 'inputsValid',\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n inputsValid: cfgOrRf,\n });\n }\n }\n\n /** Sets the config to generate list of section in the left block overviews panel\n * @deprecated use lambda-based API */\n public sections<const S extends SectionsExpectedType>(\n rf: S\n ): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;\n /** Sets the config to generate list of section in the left block overviews panel */\n public sections<\n const Ret extends SectionsExpectedType,\n const RF extends RenderFunction<Args, UiState, Ret>,\n >(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;\n public sections<const Cfg extends TypedConfig>(\n cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>\n ): BlockModel<\n Args,\n OutputsCfg,\n UiState,\n DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>\n >;\n public sections(\n arrOrCfgOrRf: SectionsExpectedType | TypedConfig | AnyFunction,\n ): BlockModel<Args, OutputsCfg, UiState, `/${string}`> {\n if (Array.isArray(arrOrCfgOrRf)) {\n return this.sections(getImmediate(arrOrCfgOrRf));\n } else if (typeof arrOrCfgOrRf === 'function') {\n tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: {\n __renderLambda: true,\n handle: 'sections',\n },\n });\n } else {\n return new BlockModel<Args, OutputsCfg, UiState>({\n ...this.config,\n sections: arrOrCfgOrRf as TypedConfig,\n });\n }\n }\n\n /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */\n public title(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('title', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n title: {\n __renderLambda: true,\n handle: 'title',\n },\n });\n }\n\n public subtitle(\n rf: RenderFunction<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('subtitle', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n subtitle: {\n __renderLambda: true,\n handle: 'subtitle',\n },\n });\n }\n\n public tags(\n rf: RenderFunction<Args, UiState, string[]>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('tags', () => rf(new RenderCtx()));\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n tags: {\n __renderLambda: true,\n handle: 'tags',\n },\n });\n }\n\n /**\n * Sets initial args for the block, this value must be specified.\n * @deprecated use {@link withArgs}\n * */\n public initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return this.withArgs(value);\n }\n\n /** Sets initial args for the block, this value must be specified. */\n public withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialArgs,\n });\n }\n\n /** Defines type and sets initial value for block UiState. */\n public withUiState<UiState>(initialUiState: UiState): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n initialUiState,\n });\n }\n\n /** Sets or overrides feature flags for the block. */\n public withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href> {\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n featureFlags: {\n ...this.config.featureFlags,\n ...flags,\n },\n });\n }\n\n /**\n * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.\n * Influences dependency graph construction.\n */\n public enriches(\n lambda: (args: Args) => PlRef[],\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback('enrichmentTargets', lambda);\n return new BlockModel<Args, OutputsCfg, UiState, Href>({\n ...this.config,\n enrichmentTargets: {\n __renderLambda: true,\n handle: 'enrichmentTargets',\n },\n });\n }\n\n public done(apiVersion?: 1): PlatformaV1<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n public done(apiVersion: 2): PlatformaV2<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n >;\n\n /** Renders all provided block settings into a pre-configured platforma API\n * instance, that can be used in frontend to interact with block state, and\n * other features provided by the platforma to the block. */\n public done(apiVersion: PlatformaApiVersion = 1): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n return this.withFeatureFlags({\n ...this.config.featureFlags,\n requiresUIAPIVersion: apiVersion,\n }).#done();\n }\n\n #done(): Platforma<\n Args,\n InferOutputsFromConfigs<Args, OutputsCfg, UiState>,\n UiState,\n Href\n > {\n if (this.config.initialArgs === undefined) throw new Error('Initial arguments not set.');\n\n const config: BlockConfigContainer = {\n v3: {\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n initialUiState: this.config.initialUiState,\n inputsValid: this.config.inputsValid,\n sections: this.config.sections,\n title: this.config.title,\n subtitle: this.config.subtitle,\n tags: this.config.tags,\n outputs: this.config.outputs,\n enrichmentTargets: this.config.enrichmentTargets,\n featureFlags: this.config.featureFlags,\n },\n\n // fields below are added to allow previous desktop versions read generated configs\n sdkVersion: PlatformaSDKVersion,\n renderingMode: this.config.renderingMode,\n initialArgs: this.config.initialArgs,\n inputsValid: downgradeCfgOrLambda(this.config.inputsValid),\n sections: downgradeCfgOrLambda(this.config.sections),\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]),\n ),\n };\n\n globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion as PlatformaApiVersion;\n\n if (!isInUI())\n // we are in the configuration rendering routine, not in actual UI\n return { config } as any;\n // normal operation inside the UI\n else return getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }) as any;\n }\n}\n\nexport type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig\n ? ResolveCfgType<CfgOrFH, Args, UiState>\n : CfgOrFH extends ConfigRenderLambda\n ? ExtractFunctionHandleReturn<CfgOrFH>\n : never;\n\ntype InferOutputsFromConfigs<\n Args,\n OutputsCfg extends Record<string, TypedConfigOrConfigLambda>,\n UiState,\n> = {\n [Key in keyof OutputsCfg]: ValueOrErrors<InferOutputType<OutputsCfg[Key], Args, UiState>>;\n};\n"],"names":["getImmediate","tryRegisterCallback","RenderCtx","PlatformaSDKVersion","downgradeCfgOrLambda","isInUI","getPlatformaInstance"],"mappings":";;;;;;;;;;;AAiDA;;AAE0E;MAC7D,UAAU,CAAA;AAOX,IAAA,MAAA;AADV,IAAA,WAAA,CACU,MAYP,EAAA;QAZO,IAAA,CAAA,MAAM,GAAN,MAAM;IAab;AAEI,IAAA,WAAW,2BAA2B,GAAA;QAC3C,OAAO;AACL,YAAA,iBAAiB,EAAE,IAAI;AACvB,YAAA,oBAAoB,EAAE,CAAC;AACvB,YAAA,uBAAuB,EAAE,CAAC;SAC3B;IACH;AAgBO,IAAA,OAAO,MAAM,CAAC,aAAA,GAAoC,OAAO,EAAA;QAC9D,OAAO,IAAI,UAAU,CAAiB;YACpC,aAAa;AACb,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,WAAW,EAAEA,oBAAY,CAAC,IAAI,CAAC;AAC/B,YAAA,QAAQ,EAAEA,oBAAY,CAAC,EAAE,CAAC;YAC1B,YAAY,EAAE,UAAU,CAAC,2BAA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,YAAY;AACvC,aAAA;;AAGD,YAAA,UAAU,EAAEA,2BAAmB;AAC/B,YAAA,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;AACxC,YAAA,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;YACpC,WAAW,EAAEC,kCAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC1D,QAAQ,EAAEA,kCAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;AACpD,YAAA,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAEA,kCAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAC9F;SACF;QAED,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,oBAA2C;QAErG,IAAI,CAACC,eAAM,EAAE;;YAEX,OAAO,EAAE,MAAM,EAAS;;;AAErB,YAAA,OAAOC,6BAAoB,CAAC,EAAE,UAAU,EAAEH,2BAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAQ;IAC/G;AACD;;;;"}
|
package/dist/builder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BlockRenderingMode, BlockSection, ValueOrErrors, PlRef, BlockCodeKnownFeatureFlags } from '@milaboratories/pl-model-common';
|
|
2
2
|
import type { Checked, ConfigResult, TypedConfig } from './config';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PlatformaV1, PlatformaV2 } from './platforma';
|
|
4
4
|
import type { InferRenderFunctionReturn, RenderFunction } from './render';
|
|
5
5
|
import type { TypedConfigOrConfigLambda, ConfigRenderLambda, StdCtxArgsOnly, DeriveHref, ResolveCfgType, ExtractFunctionHandleReturn, ConfigRenderLambdaFlags } from './bconfig';
|
|
6
6
|
type SectionsExpectedType = readonly BlockSection[];
|
|
@@ -12,17 +12,10 @@ type NoOb = Record<string, never>;
|
|
|
12
12
|
* to call {@link done()} at the end of configuration. Value returned by this builder must be
|
|
13
13
|
* exported as constant with name "platforma" from the "config" module. */
|
|
14
14
|
export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedConfigOrConfigLambda>, UiState, Href extends `/${string}` = '/'> {
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private readonly _initialUiState;
|
|
18
|
-
private readonly _outputs;
|
|
19
|
-
private readonly _inputsValid;
|
|
20
|
-
private readonly _sections;
|
|
21
|
-
private readonly _title;
|
|
22
|
-
private readonly _enrichmentTargets;
|
|
23
|
-
private readonly _featureFlags;
|
|
15
|
+
#private;
|
|
16
|
+
private config;
|
|
24
17
|
private constructor();
|
|
25
|
-
static
|
|
18
|
+
static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags;
|
|
26
19
|
/** Initiates configuration builder */
|
|
27
20
|
static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;
|
|
28
21
|
/** Initiates configuration builder */
|
|
@@ -76,15 +69,17 @@ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedCon
|
|
|
76
69
|
sections<const Cfg extends TypedConfig>(cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>>;
|
|
77
70
|
/** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
|
|
78
71
|
title(rf: RenderFunction<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
72
|
+
subtitle(rf: RenderFunction<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
73
|
+
tags(rf: RenderFunction<Args, UiState, string[]>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
79
74
|
/**
|
|
80
75
|
* Sets initial args for the block, this value must be specified.
|
|
81
76
|
* @deprecated use {@link withArgs}
|
|
82
77
|
* */
|
|
83
78
|
initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
84
79
|
/** Sets initial args for the block, this value must be specified. */
|
|
85
|
-
withArgs<Args>(
|
|
80
|
+
withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
86
81
|
/** Defines type and sets initial value for block UiState. */
|
|
87
|
-
withUiState<UiState>(
|
|
82
|
+
withUiState<UiState>(initialUiState: UiState): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
88
83
|
/** Sets or overrides feature flags for the block. */
|
|
89
84
|
withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
90
85
|
/**
|
|
@@ -94,7 +89,6 @@ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedCon
|
|
|
94
89
|
enriches(lambda: (args: Args) => PlRef[]): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
95
90
|
done(apiVersion?: 1): PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>;
|
|
96
91
|
done(apiVersion: 2): PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>;
|
|
97
|
-
_done(apiVersion: PlatformaApiVersion): Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>;
|
|
98
92
|
}
|
|
99
93
|
export type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig ? ResolveCfgType<CfgOrFH, Args, UiState> : CfgOrFH extends ConfigRenderLambda ? ExtractFunctionHandleReturn<CfgOrFH> : never;
|
|
100
94
|
type InferOutputsFromConfigs<Args, OutputsCfg extends Record<string, TypedConfigOrConfigLambda>, UiState> = {
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"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