@platforma-sdk/model 1.82.0 → 1.83.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/bconfig/index.d.ts +2 -2
- package/dist/bconfig/lambdas.d.ts +2 -12
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/v3.d.ts +1 -1
- package/dist/block_model.cjs +2 -2
- package/dist/block_model.js +2 -2
- package/dist/config/index.d.ts +2 -6
- package/dist/config/type_engine.d.ts +7 -28
- package/dist/config/type_engine.d.ts.map +1 -1
- package/dist/index.cjs +20 -60
- package/dist/index.d.ts +5 -11
- package/dist/index.js +4 -8
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/render/api.cjs +0 -22
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +1 -9
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +1 -22
- package/dist/render/api.js.map +1 -1
- package/dist/render/index.cjs +0 -1
- package/dist/render/index.d.ts +2 -2
- package/dist/render/index.js +2 -2
- package/package.json +4 -4
- package/src/bconfig/lambdas.ts +1 -25
- package/src/config/index.ts +0 -4
- package/src/config/type_engine.ts +6 -49
- package/src/index.ts +0 -2
- package/src/render/api.ts +0 -32
- package/src/typing.test.ts +4 -143
- package/dist/block_model_legacy.cjs +0 -240
- package/dist/block_model_legacy.cjs.map +0 -1
- package/dist/block_model_legacy.d.ts +0 -115
- package/dist/block_model_legacy.d.ts.map +0 -1
- package/dist/block_model_legacy.js +0 -240
- package/dist/block_model_legacy.js.map +0 -1
- package/dist/config/actions.cjs +0 -232
- package/dist/config/actions.cjs.map +0 -1
- package/dist/config/actions.d.ts +0 -48
- package/dist/config/actions.d.ts.map +0 -1
- package/dist/config/actions.js +0 -201
- package/dist/config/actions.js.map +0 -1
- package/dist/config/actions_kinds.d.ts +0 -116
- package/dist/config/actions_kinds.d.ts.map +0 -1
- package/dist/config/index.cjs +0 -33
- package/dist/config/index.js +0 -2
- package/dist/config/model_meta.d.ts +0 -9
- package/dist/config/model_meta.d.ts.map +0 -1
- package/dist/config/type_util.d.ts +0 -14
- package/dist/config/type_util.d.ts.map +0 -1
- package/dist/ref_util.cjs +0 -21
- package/dist/ref_util.cjs.map +0 -1
- package/dist/ref_util.d.ts +0 -19
- package/dist/ref_util.d.ts.map +0 -1
- package/dist/ref_util.js +0 -20
- package/dist/ref_util.js.map +0 -1
- package/src/block_model_legacy.ts +0 -465
- package/src/config/actions.ts +0 -468
- package/src/config/actions_kinds.ts +0 -264
- package/src/config/model_meta.ts +0 -5
- package/src/config/type_util.ts +0 -25
- package/src/ref_util.ts +0 -17
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { ConfigResult, TypedConfig } from "./config/type_engine.js";
|
|
2
|
-
import { Checked } from "./config/type_util.js";
|
|
3
|
-
import { TypedConfigOrConfigLambda } from "./bconfig/types.js";
|
|
4
|
-
import { ConfigRenderLambda, ConfigRenderLambdaFlags, InferOutputsFromConfigs, StdCtxArgsOnly } from "./bconfig/lambdas.js";
|
|
5
|
-
import { DeriveHref } from "./bconfig/util.js";
|
|
6
|
-
import { InferRenderFunctionReturn, RenderFunctionLegacy } from "./render/api.js";
|
|
7
|
-
import { PlatformaExtended, PlatformaV1, PlatformaV2 } from "./platforma.js";
|
|
8
|
-
import { BlockCodeKnownFeatureFlags, BlockRenderingMode, BlockSection, PlRef } from "@milaboratories/pl-model-common";
|
|
9
|
-
|
|
10
|
-
//#region src/block_model_legacy.d.ts
|
|
11
|
-
type SectionsExpectedType = readonly BlockSection[];
|
|
12
|
-
type SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<Cfg, ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false>;
|
|
13
|
-
type InputsValidExpectedType = boolean;
|
|
14
|
-
type InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<Cfg, ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false>;
|
|
15
|
-
type NoOb = Record<string, never>;
|
|
16
|
-
/** Main entry point that each block should use in it's "config" module. Don't forget
|
|
17
|
-
* to call {@link done()} at the end of configuration. Value returned by this builder must be
|
|
18
|
-
* exported as constant with name "platforma" from the "config" module. */
|
|
19
|
-
declare class BlockModel<Args, OutputsCfg extends Record<string, TypedConfigOrConfigLambda>, UiState, Href extends `/${string}` = "/"> {
|
|
20
|
-
#private;
|
|
21
|
-
private config;
|
|
22
|
-
private constructor();
|
|
23
|
-
static get INITIAL_BLOCK_FEATURE_FLAGS(): BlockCodeKnownFeatureFlags;
|
|
24
|
-
/** Initiates configuration builder */
|
|
25
|
-
static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;
|
|
26
|
-
/** Initiates configuration builder */
|
|
27
|
-
static create(): BlockModel<NoOb, {}, NoOb>;
|
|
28
|
-
/**
|
|
29
|
-
* Initiates configuration builder
|
|
30
|
-
* @deprecated use create method without generic parameter
|
|
31
|
-
*/
|
|
32
|
-
static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;
|
|
33
|
-
/**
|
|
34
|
-
* Initiates configuration builder
|
|
35
|
-
* @deprecated use create method without generic parameter
|
|
36
|
-
*/
|
|
37
|
-
static create<Args>(): BlockModel<Args, {}, NoOb>;
|
|
38
|
-
/**
|
|
39
|
-
* Add output cell to the configuration
|
|
40
|
-
*
|
|
41
|
-
* @param key output cell name, that can be later used to retrieve the rendered value
|
|
42
|
-
* @param cfg configuration describing how to render cell value from the blocks
|
|
43
|
-
* workflow outputs
|
|
44
|
-
* @deprecated use lambda-based API
|
|
45
|
-
* */
|
|
46
|
-
output<const Key extends string, const Cfg extends TypedConfig>(key: Key, cfg: Cfg): BlockModel<Args, OutputsCfg & { [K in Key]: Cfg }, UiState, Href>;
|
|
47
|
-
/**
|
|
48
|
-
* Add output cell wrapped with additional status information to the configuration
|
|
49
|
-
*
|
|
50
|
-
* @param key output cell name, that can be later used to retrieve the rendered value
|
|
51
|
-
* @param rf callback calculating output value using context, that allows to access
|
|
52
|
-
* workflows outputs and interact with platforma drivers
|
|
53
|
-
* @param flags additional flags that may alter lambda rendering procedure
|
|
54
|
-
* */
|
|
55
|
-
output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF, flags: ConfigRenderLambdaFlags & {
|
|
56
|
-
withStatus: true;
|
|
57
|
-
}): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & {
|
|
58
|
-
withStatus: true;
|
|
59
|
-
} }, UiState, Href>;
|
|
60
|
-
/**
|
|
61
|
-
* Add output cell to the configuration
|
|
62
|
-
*
|
|
63
|
-
* @param key output cell name, that can be later used to retrieve the rendered value
|
|
64
|
-
* @param rf callback calculating output value using context, that allows to access
|
|
65
|
-
* workflows outputs and interact with platforma drivers
|
|
66
|
-
* @param flags additional flags that may alter lambda rendering procedure
|
|
67
|
-
* */
|
|
68
|
-
output<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF, flags?: ConfigRenderLambdaFlags): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> }, UiState, Href>;
|
|
69
|
-
/** Shortcut for {@link output} with retentive flag set to true. */
|
|
70
|
-
retentiveOutput<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> }, UiState, Href>;
|
|
71
|
-
/** Shortcut for {@link output} with withStatus flag set to true. */
|
|
72
|
-
outputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & {
|
|
73
|
-
withStatus: true;
|
|
74
|
-
} }, UiState, Href>;
|
|
75
|
-
/** Shortcut for {@link output} with retentive and withStatus flags set to true. */
|
|
76
|
-
retentiveOutputWithStatus<const Key extends string, const RF extends RenderFunctionLegacy<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & { [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & {
|
|
77
|
-
withStatus: true;
|
|
78
|
-
} }, UiState, Href>;
|
|
79
|
-
/** Sets custom configuration predicate on the block args at which block can be executed
|
|
80
|
-
* @deprecated use lambda-based API */
|
|
81
|
-
argsValid<Cfg extends TypedConfig>(cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
82
|
-
/** Sets custom configuration predicate on the block args at which block can be executed */
|
|
83
|
-
argsValid<RF extends RenderFunctionLegacy<Args, UiState, boolean>>(rf: RF): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
84
|
-
/** Sets the config to generate list of section in the left block overviews panel
|
|
85
|
-
* @deprecated use lambda-based API */
|
|
86
|
-
sections<const S extends SectionsExpectedType>(rf: S): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;
|
|
87
|
-
/** Sets the config to generate list of section in the left block overviews panel */
|
|
88
|
-
sections<const Ret extends SectionsExpectedType, const RF extends RenderFunctionLegacy<Args, UiState, Ret>>(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;
|
|
89
|
-
sections<const Cfg extends TypedConfig>(cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>>;
|
|
90
|
-
/** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
|
|
91
|
-
title(rf: RenderFunctionLegacy<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
92
|
-
subtitle(rf: RenderFunctionLegacy<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
93
|
-
tags(rf: RenderFunctionLegacy<Args, UiState, string[]>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
94
|
-
/**
|
|
95
|
-
* Sets initial args for the block, this value must be specified.
|
|
96
|
-
* @deprecated use {@link withArgs}
|
|
97
|
-
* */
|
|
98
|
-
initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
99
|
-
/** Sets initial args for the block, this value must be specified. */
|
|
100
|
-
withArgs<Args>(initialArgs: Args): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
101
|
-
/** Defines type and sets initial value for block UiState. */
|
|
102
|
-
withUiState<UiState>(initialUiState: UiState): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
103
|
-
/** Sets or overrides feature flags for the block. */
|
|
104
|
-
withFeatureFlags(flags: Partial<BlockCodeKnownFeatureFlags>): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
105
|
-
/**
|
|
106
|
-
* Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
|
|
107
|
-
* Influences dependency graph construction.
|
|
108
|
-
*/
|
|
109
|
-
enriches(lambda: (args: Args) => PlRef[]): BlockModel<Args, OutputsCfg, UiState, Href>;
|
|
110
|
-
done(apiVersion?: 1): PlatformaExtended<PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>>;
|
|
111
|
-
done(apiVersion: 2): PlatformaExtended<PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>>;
|
|
112
|
-
}
|
|
113
|
-
//#endregion
|
|
114
|
-
export { BlockModel };
|
|
115
|
-
//# sourceMappingURL=block_model_legacy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block_model_legacy.d.ts","names":[],"sources":["../src/block_model_legacy.ts"],"mappings":";;;;;;;;;;KA2BK,oBAAA,YAAgC,YAAY;AAAA,KAE5C,kBAAA,aAA+B,WAAA,mBAA8B,OAAA,CAChE,GAAA,EACA,YAAA,CAAa,GAA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AA,EAAM,UAAA,EAAY,OAAA,EAAS,IAAA;EAxOlC;;;;EAsPA,QAAA,CAAS,MAAA,GAAS,IAAA,EAAM,IAAA,KAAS,KAAA,KAAU,UAAA,CAAW,IAAA,EAAM,UAAA,EAAY,OAAA,EAAS,IAAA;EAWjF,IAAA,CACL,UAAA,OACC,iBAAA,CACD,WAAA,CAAY,IAAA,EAAM,uBAAA,CAAwB,IAAA,EAAM,UAAA,EAAY,OAAA,GAAU,OAAA,EAAS,IAAA;EAG1E,IAAA,CACL,UAAA,MACC,iBAAA,CACD,WAAA,CAAY,IAAA,EAAM,uBAAA,CAAwB,IAAA,EAAM,UAAA,EAAY,OAAA,GAAU,OAAA,EAAS,IAAA;AAAA"}
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { getPlatformaInstance, isInUI, tryRegisterCallback } from "./internal.js";
|
|
2
|
-
import { getImmediate } from "./config/actions.js";
|
|
3
|
-
import "./config/index.js";
|
|
4
|
-
import { RenderCtxLegacy } from "./render/api.js";
|
|
5
|
-
import "./render/index.js";
|
|
6
|
-
import { PlatformaSDKVersion } from "./version.js";
|
|
7
|
-
import { isConfigLambda } from "./bconfig/types.js";
|
|
8
|
-
import { downgradeCfgOrLambda } from "./bconfig/normalization.js";
|
|
9
|
-
import "./bconfig/index.js";
|
|
10
|
-
import { REQUIRES_PFRAMES_VERSION } from "@milaboratories/pl-model-common";
|
|
11
|
-
//#region src/block_model_legacy.ts
|
|
12
|
-
/** Main entry point that each block should use in it's "config" module. Don't forget
|
|
13
|
-
* to call {@link done()} at the end of configuration. Value returned by this builder must be
|
|
14
|
-
* exported as constant with name "platforma" from the "config" module. */
|
|
15
|
-
var BlockModel = class BlockModel {
|
|
16
|
-
config;
|
|
17
|
-
constructor(config) {
|
|
18
|
-
this.config = config;
|
|
19
|
-
}
|
|
20
|
-
static get INITIAL_BLOCK_FEATURE_FLAGS() {
|
|
21
|
-
return {
|
|
22
|
-
supportsLazyState: true,
|
|
23
|
-
supportsPframeQueryRanking: true,
|
|
24
|
-
requiresUIAPIVersion: 1,
|
|
25
|
-
requiresModelAPIVersion: 1,
|
|
26
|
-
requiresCreatePTable: 2,
|
|
27
|
-
requiresPFramesVersion: REQUIRES_PFRAMES_VERSION
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
static create(renderingMode = "Heavy") {
|
|
31
|
-
return new BlockModel({
|
|
32
|
-
renderingMode,
|
|
33
|
-
initialUiState: {},
|
|
34
|
-
outputs: {},
|
|
35
|
-
inputsValid: getImmediate(true),
|
|
36
|
-
sections: getImmediate([]),
|
|
37
|
-
featureFlags: BlockModel.INITIAL_BLOCK_FEATURE_FLAGS
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
output(key, cfgOrRf, flags = {}) {
|
|
41
|
-
if (typeof cfgOrRf === "function") {
|
|
42
|
-
const handle = `output#${key}`;
|
|
43
|
-
tryRegisterCallback(handle, () => cfgOrRf(new RenderCtxLegacy()));
|
|
44
|
-
return new BlockModel({
|
|
45
|
-
...this.config,
|
|
46
|
-
outputs: {
|
|
47
|
-
...this.config.outputs,
|
|
48
|
-
[key]: {
|
|
49
|
-
__renderLambda: true,
|
|
50
|
-
handle,
|
|
51
|
-
...flags
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
} else return new BlockModel({
|
|
56
|
-
...this.config,
|
|
57
|
-
outputs: {
|
|
58
|
-
...this.config.outputs,
|
|
59
|
-
[key]: cfgOrRf
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/** Shortcut for {@link output} with retentive flag set to true. */
|
|
64
|
-
retentiveOutput(key, rf) {
|
|
65
|
-
return this.output(key, rf, { retentive: true });
|
|
66
|
-
}
|
|
67
|
-
/** Shortcut for {@link output} with withStatus flag set to true. */
|
|
68
|
-
outputWithStatus(key, rf) {
|
|
69
|
-
return this.output(key, rf, { withStatus: true });
|
|
70
|
-
}
|
|
71
|
-
/** Shortcut for {@link output} with retentive and withStatus flags set to true. */
|
|
72
|
-
retentiveOutputWithStatus(key, rf) {
|
|
73
|
-
return this.output(key, rf, {
|
|
74
|
-
retentive: true,
|
|
75
|
-
withStatus: true
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
argsValid(cfgOrRf) {
|
|
79
|
-
if (typeof cfgOrRf === "function") {
|
|
80
|
-
tryRegisterCallback("inputsValid", () => cfgOrRf(new RenderCtxLegacy()));
|
|
81
|
-
return new BlockModel({
|
|
82
|
-
...this.config,
|
|
83
|
-
inputsValid: {
|
|
84
|
-
__renderLambda: true,
|
|
85
|
-
handle: "inputsValid"
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
} else return new BlockModel({
|
|
89
|
-
...this.config,
|
|
90
|
-
inputsValid: cfgOrRf
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
sections(arrOrCfgOrRf) {
|
|
94
|
-
if (Array.isArray(arrOrCfgOrRf)) return this.sections(getImmediate(arrOrCfgOrRf));
|
|
95
|
-
else if (typeof arrOrCfgOrRf === "function") {
|
|
96
|
-
tryRegisterCallback("sections", () => arrOrCfgOrRf(new RenderCtxLegacy()));
|
|
97
|
-
return new BlockModel({
|
|
98
|
-
...this.config,
|
|
99
|
-
sections: {
|
|
100
|
-
__renderLambda: true,
|
|
101
|
-
handle: "sections"
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
} else return new BlockModel({
|
|
105
|
-
...this.config,
|
|
106
|
-
sections: arrOrCfgOrRf
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
|
|
110
|
-
title(rf) {
|
|
111
|
-
tryRegisterCallback("title", () => rf(new RenderCtxLegacy()));
|
|
112
|
-
return new BlockModel({
|
|
113
|
-
...this.config,
|
|
114
|
-
title: {
|
|
115
|
-
__renderLambda: true,
|
|
116
|
-
handle: "title"
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
subtitle(rf) {
|
|
121
|
-
tryRegisterCallback("subtitle", () => rf(new RenderCtxLegacy()));
|
|
122
|
-
return new BlockModel({
|
|
123
|
-
...this.config,
|
|
124
|
-
subtitle: {
|
|
125
|
-
__renderLambda: true,
|
|
126
|
-
handle: "subtitle"
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
tags(rf) {
|
|
131
|
-
tryRegisterCallback("tags", () => rf(new RenderCtxLegacy()));
|
|
132
|
-
return new BlockModel({
|
|
133
|
-
...this.config,
|
|
134
|
-
tags: {
|
|
135
|
-
__renderLambda: true,
|
|
136
|
-
handle: "tags"
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Sets initial args for the block, this value must be specified.
|
|
142
|
-
* @deprecated use {@link withArgs}
|
|
143
|
-
* */
|
|
144
|
-
initialArgs(value) {
|
|
145
|
-
return this.withArgs(value);
|
|
146
|
-
}
|
|
147
|
-
/** Sets initial args for the block, this value must be specified. */
|
|
148
|
-
withArgs(initialArgs) {
|
|
149
|
-
return new BlockModel({
|
|
150
|
-
...this.config,
|
|
151
|
-
initialArgs
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/** Defines type and sets initial value for block UiState. */
|
|
155
|
-
withUiState(initialUiState) {
|
|
156
|
-
return new BlockModel({
|
|
157
|
-
...this.config,
|
|
158
|
-
initialUiState
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
/** Sets or overrides feature flags for the block. */
|
|
162
|
-
withFeatureFlags(flags) {
|
|
163
|
-
return new BlockModel({
|
|
164
|
-
...this.config,
|
|
165
|
-
featureFlags: {
|
|
166
|
-
...this.config.featureFlags,
|
|
167
|
-
...flags
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
|
|
173
|
-
* Influences dependency graph construction.
|
|
174
|
-
*/
|
|
175
|
-
enriches(lambda) {
|
|
176
|
-
tryRegisterCallback("enrichmentTargets", lambda);
|
|
177
|
-
return new BlockModel({
|
|
178
|
-
...this.config,
|
|
179
|
-
enrichmentTargets: {
|
|
180
|
-
__renderLambda: true,
|
|
181
|
-
handle: "enrichmentTargets"
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/** Renders all provided block settings into a pre-configured platforma API
|
|
186
|
-
* instance, that can be used in frontend to interact with block state, and
|
|
187
|
-
* other features provided by the platforma to the block. */
|
|
188
|
-
done(apiVersion = 1) {
|
|
189
|
-
return this.withFeatureFlags({
|
|
190
|
-
...this.config.featureFlags,
|
|
191
|
-
requiresUIAPIVersion: apiVersion
|
|
192
|
-
}).#done();
|
|
193
|
-
}
|
|
194
|
-
#done() {
|
|
195
|
-
if (this.config.initialArgs === void 0) throw new Error("Initial arguments not set.");
|
|
196
|
-
const config = {
|
|
197
|
-
v4: void 0,
|
|
198
|
-
v3: {
|
|
199
|
-
configVersion: 3,
|
|
200
|
-
modelAPIVersion: 1,
|
|
201
|
-
sdkVersion: PlatformaSDKVersion,
|
|
202
|
-
renderingMode: this.config.renderingMode,
|
|
203
|
-
initialArgs: this.config.initialArgs,
|
|
204
|
-
initialUiState: this.config.initialUiState,
|
|
205
|
-
inputsValid: this.config.inputsValid,
|
|
206
|
-
sections: this.config.sections,
|
|
207
|
-
title: this.config.title,
|
|
208
|
-
subtitle: this.config.subtitle,
|
|
209
|
-
tags: this.config.tags,
|
|
210
|
-
outputs: this.config.outputs,
|
|
211
|
-
enrichmentTargets: this.config.enrichmentTargets,
|
|
212
|
-
featureFlags: this.config.featureFlags
|
|
213
|
-
},
|
|
214
|
-
sdkVersion: PlatformaSDKVersion,
|
|
215
|
-
renderingMode: this.config.renderingMode,
|
|
216
|
-
initialArgs: this.config.initialArgs,
|
|
217
|
-
inputsValid: downgradeCfgOrLambda(this.config.inputsValid),
|
|
218
|
-
sections: downgradeCfgOrLambda(this.config.sections),
|
|
219
|
-
outputs: Object.fromEntries(Object.entries(this.config.outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)]))
|
|
220
|
-
};
|
|
221
|
-
globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion;
|
|
222
|
-
if (!isInUI()) return { config };
|
|
223
|
-
else return {
|
|
224
|
-
...getPlatformaInstance({
|
|
225
|
-
sdkVersion: PlatformaSDKVersion,
|
|
226
|
-
apiVersion: platformaApiVersion
|
|
227
|
-
}),
|
|
228
|
-
blockModelInfo: {
|
|
229
|
-
outputs: Object.fromEntries(Object.entries(this.config.outputs).map(([key, value]) => [key, { withStatus: Boolean(isConfigLambda(value) && value.withStatus) }])),
|
|
230
|
-
pluginIds: [],
|
|
231
|
-
featureFlags: this.config.featureFlags,
|
|
232
|
-
pluginPublicOutputs: {}
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
//#endregion
|
|
238
|
-
export { BlockModel };
|
|
239
|
-
|
|
240
|
-
//# sourceMappingURL=block_model_legacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block_model_legacy.js","names":["#done"],"sources":["../src/block_model_legacy.ts"],"sourcesContent":["import type {\n BlockRenderingMode,\n BlockSection,\n AnyFunction,\n PlRef,\n BlockCodeKnownFeatureFlags,\n BlockConfigContainer,\n} from \"@milaboratories/pl-model-common\";\nimport { REQUIRES_PFRAMES_VERSION } 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, RenderFunctionLegacy } from \"./render\";\nimport { RenderCtxLegacy } from \"./render\";\nimport { PlatformaSDKVersion } from \"./version\";\nimport type {\n TypedConfigOrConfigLambda,\n ConfigRenderLambda,\n StdCtxArgsOnly,\n DeriveHref,\n ConfigRenderLambdaFlags,\n InferOutputsFromConfigs,\n} from \"./bconfig\";\nimport { downgradeCfgOrLambda, isConfigLambda } from \"./bconfig\";\nimport type { PlatformaExtended } from \"./platforma\";\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\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\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 supportsPframeQueryRanking: true,\n requiresUIAPIVersion: 1,\n requiresModelAPIVersion: 1,\n requiresCreatePTable: 2,\n requiresPFramesVersion: REQUIRES_PFRAMES_VERSION,\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 wrapped with additional status information 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 RenderFunctionLegacy<Args, UiState>>(\n key: Key,\n rf: RF,\n flags: ConfigRenderLambdaFlags & { withStatus: true },\n ): BlockModel<\n Args,\n OutputsCfg & {\n [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>> & { withStatus: true };\n },\n UiState,\n Href\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 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 RenderFunctionLegacy<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 RenderCtxLegacy()));\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<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { retentive: true });\n }\n\n /** Shortcut for {@link output} with withStatus flag set to true. */\n public outputWithStatus<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { withStatus: true });\n }\n\n /** Shortcut for {@link output} with retentive and withStatus flags set to true. */\n public retentiveOutputWithStatus<\n const Key extends string,\n const RF extends RenderFunctionLegacy<Args, UiState>,\n >(key: Key, rf: RF) {\n return this.output(key, rf, { retentive: true, withStatus: 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 RenderFunctionLegacy<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 RenderCtxLegacy()));\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 RenderFunctionLegacy<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 RenderCtxLegacy()));\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: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"title\", () => rf(new RenderCtxLegacy()));\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: RenderFunctionLegacy<Args, UiState, string>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"subtitle\", () => rf(new RenderCtxLegacy()));\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: RenderFunctionLegacy<Args, UiState, string[]>,\n ): BlockModel<Args, OutputsCfg, UiState, Href> {\n tryRegisterCallback(\"tags\", () => rf(new RenderCtxLegacy()));\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>(\n initialUiState: UiState,\n ): 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(\n flags: Partial<BlockCodeKnownFeatureFlags>,\n ): 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(lambda: (args: Args) => PlRef[]): 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(\n apiVersion?: 1,\n ): PlatformaExtended<\n PlatformaV1<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n >;\n\n public done(\n apiVersion: 2,\n ): PlatformaExtended<\n PlatformaV2<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, 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(\n apiVersion: PlatformaApiVersion = 1,\n ): PlatformaExtended<\n Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n > {\n return this.withFeatureFlags({\n ...this.config.featureFlags,\n requiresUIAPIVersion: apiVersion,\n }).#done();\n }\n\n #done(): PlatformaExtended<\n Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>\n > {\n if (this.config.initialArgs === undefined) throw new Error(\"Initial arguments not set.\");\n\n const config: BlockConfigContainer = {\n v4: undefined,\n v3: {\n configVersion: 3,\n modelAPIVersion: 1,\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]) => [\n key,\n downgradeCfgOrLambda(value),\n ]),\n ),\n };\n\n globalThis.platformaApiVersion = this.config.featureFlags\n .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 } else {\n // normal operation inside the UI\n return {\n ...getPlatformaInstance({\n sdkVersion: PlatformaSDKVersion,\n apiVersion: platformaApiVersion,\n }),\n blockModelInfo: {\n outputs: Object.fromEntries(\n Object.entries(this.config.outputs).map(([key, value]) => [\n key,\n {\n withStatus: Boolean(isConfigLambda(value) && value.withStatus),\n },\n ]),\n ),\n pluginIds: [],\n featureFlags: this.config.featureFlags,\n pluginPublicOutputs: {},\n },\n };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,IAAa,aAAb,MAAa,WAKX;CAEU;CADV,YACE,QAaA;EAbQ,KAAA,SAAA;CAaP;CAEH,WAAkB,8BAA0D;EAC1E,OAAO;GACL,mBAAmB;GACnB,4BAA4B;GAC5B,sBAAsB;GACtB,yBAAyB;GACzB,sBAAsB;GACtB,wBAAwB;EAC1B;CACF;CAgBA,OAAc,OAAO,gBAAoC,SAAqC;EAC5F,OAAO,IAAI,WAA2B;GACpC;GACA,gBAAgB,CAAC;GACjB,SAAS,CAAC;GACV,aAAa,aAAa,IAAI;GAC9B,UAAU,aAAa,CAAC,CAAC;GACzB,cAAc,WAAW;EAC3B,CAAC;CACH;CAoDA,OACE,KACA,SACA,QAAiC,CAAC,GACW;EAC7C,IAAI,OAAO,YAAY,YAAY;GACjC,MAAM,SAAS,UAAU;GACzB,oBAAoB,cAAc,QAAQ,IAAI,gBAAgB,CAAC,CAAC;GAChE,OAAO,IAAI,WAAW;IACpB,GAAG,KAAK;IACR,SAAS;KACP,GAAG,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;IACZ,eAAe,KAAK,OAAO;IAC3B,aAAa,KAAK,OAAO;IACzB,gBAAgB,KAAK,OAAO;IAC5B,aAAa,KAAK,OAAO;IACzB,UAAU,KAAK,OAAO;IACtB,OAAO,KAAK,OAAO;IACnB,UAAU,KAAK,OAAO;IACtB,MAAM,KAAK,OAAO;IAClB,SAAS,KAAK,OAAO;IACrB,mBAAmB,KAAK,OAAO;IAC/B,cAAc,KAAK,OAAO;GAC5B;GAGA,YAAY;GACZ,eAAe,KAAK,OAAO;GAC3B,aAAa,KAAK,OAAO;GACzB,aAAa,qBAAqB,KAAK,OAAO,WAAW;GACzD,UAAU,qBAAqB,KAAK,OAAO,QAAQ;GACnD,SAAS,OAAO,YACd,OAAO,QAAQ,KAAK,OAAO,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CACxD,KACA,qBAAqB,KAAK,CAC5B,CAAC,CACH;EACF;EAEA,WAAW,sBAAsB,KAAK,OAAO,aAC1C;EAEH,IAAI,CAAC,OAAO,GAEV,OAAO,EAAE,OAAO;OAGhB,OAAO;GACL,GAAG,qBAAqB;IACtB,YAAY;IACZ,YAAY;GACd,CAAC;GACD,gBAAgB;IACd,SAAS,OAAO,YACd,OAAO,QAAQ,KAAK,OAAO,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CACxD,KACA,EACE,YAAY,QAAQ,eAAe,KAAK,KAAK,MAAM,UAAU,EAC/D,CACF,CAAC,CACH;IACA,WAAW,CAAC;IACZ,cAAc,KAAK,OAAO;IAC1B,qBAAqB,CAAC;GACxB;EACF;CAEJ;AACF"}
|
package/dist/config/actions.cjs
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
//#region src/config/actions.ts
|
|
2
|
-
function primitiveToConfig(value) {
|
|
3
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) return getImmediate(value);
|
|
4
|
-
else return value;
|
|
5
|
-
}
|
|
6
|
-
function getFromCfg(variable) {
|
|
7
|
-
return {
|
|
8
|
-
type: "GetFromCtx",
|
|
9
|
-
variable
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function isolate(cfg) {
|
|
13
|
-
return {
|
|
14
|
-
type: "Isolate",
|
|
15
|
-
cfg
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const Args = getFromCfg("$args");
|
|
19
|
-
const It = getFromCfg("$it");
|
|
20
|
-
const MainOutputs = getFromCfg("$prod");
|
|
21
|
-
const StagingOutputs = getFromCfg("$staging");
|
|
22
|
-
const UiState = getFromCfg("$ui");
|
|
23
|
-
function getImmediate(value) {
|
|
24
|
-
return {
|
|
25
|
-
type: "Immediate",
|
|
26
|
-
value
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function makeObject(template) {
|
|
30
|
-
const normalizedTemplate = {};
|
|
31
|
-
for (const [k, cfg] of Object.entries(template)) normalizedTemplate[k] = primitiveToConfig(cfg);
|
|
32
|
-
return {
|
|
33
|
-
type: "MakeObject",
|
|
34
|
-
template: normalizedTemplate
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function makeArray(...template) {
|
|
38
|
-
const normalizedTemplate = [];
|
|
39
|
-
for (const cfg of template) normalizedTemplate.push(primitiveToConfig(cfg));
|
|
40
|
-
return {
|
|
41
|
-
type: "MakeArray",
|
|
42
|
-
template: normalizedTemplate
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function getJsonField(source, field) {
|
|
46
|
-
return {
|
|
47
|
-
type: "GetJsonField",
|
|
48
|
-
source: primitiveToConfig(source),
|
|
49
|
-
field: primitiveToConfig(field)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function mapRecordValues(source, mapping, itVar = "$it") {
|
|
53
|
-
return {
|
|
54
|
-
type: "MapRecordValues",
|
|
55
|
-
source,
|
|
56
|
-
mapping,
|
|
57
|
-
itVar
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function mapArrayValues(source, mapping, itVar = "$it") {
|
|
61
|
-
return {
|
|
62
|
-
type: "MapArrayValues",
|
|
63
|
-
source,
|
|
64
|
-
mapping,
|
|
65
|
-
itVar
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function flatten(source) {
|
|
69
|
-
return {
|
|
70
|
-
type: "Flatten",
|
|
71
|
-
source
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function isEmpty(arg) {
|
|
75
|
-
return {
|
|
76
|
-
type: "IsEmpty",
|
|
77
|
-
arg
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function not(operand) {
|
|
81
|
-
return {
|
|
82
|
-
type: "Not",
|
|
83
|
-
operand
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function and(operand1, operand2) {
|
|
87
|
-
return {
|
|
88
|
-
type: "And",
|
|
89
|
-
operand1,
|
|
90
|
-
operand2
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function or(operand1, operand2) {
|
|
94
|
-
return {
|
|
95
|
-
type: "Or",
|
|
96
|
-
operand1,
|
|
97
|
-
operand2
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function getResourceField(source, field) {
|
|
101
|
-
return {
|
|
102
|
-
type: "GetResourceField",
|
|
103
|
-
source: primitiveToConfig(source),
|
|
104
|
-
field: primitiveToConfig(field)
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function getResourceValueAsJson() {
|
|
108
|
-
return function(source) {
|
|
109
|
-
return {
|
|
110
|
-
type: "GetResourceValueAsJson",
|
|
111
|
-
source: primitiveToConfig(source)
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function mapResourceFields(source, mapping, itVar = "$it") {
|
|
116
|
-
return {
|
|
117
|
-
type: "MapResourceFields",
|
|
118
|
-
source,
|
|
119
|
-
mapping,
|
|
120
|
-
itVar
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function getBlobContent(source, range) {
|
|
124
|
-
return {
|
|
125
|
-
type: "GetBlobContent",
|
|
126
|
-
range,
|
|
127
|
-
source: primitiveToConfig(source)
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function getBlobContentAsString(source, range) {
|
|
131
|
-
return {
|
|
132
|
-
type: "GetBlobContentAsString",
|
|
133
|
-
range,
|
|
134
|
-
source: primitiveToConfig(source)
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function getBlobContentAsJson() {
|
|
138
|
-
return function(source, range) {
|
|
139
|
-
return {
|
|
140
|
-
type: "GetBlobContentAsJson",
|
|
141
|
-
range,
|
|
142
|
-
source: primitiveToConfig(source)
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function getDownloadedBlobContent(source) {
|
|
147
|
-
return {
|
|
148
|
-
type: "GetDownloadedBlobContent",
|
|
149
|
-
source: primitiveToConfig(source)
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function getOnDemandBlobContent(source) {
|
|
153
|
-
return {
|
|
154
|
-
type: "GetOnDemandBlobContent",
|
|
155
|
-
source: primitiveToConfig(source)
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function extractArchiveAndGetURL(source, format) {
|
|
159
|
-
return {
|
|
160
|
-
type: "ExtractArchiveAndGetURL",
|
|
161
|
-
format,
|
|
162
|
-
source: primitiveToConfig(source)
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function getImportProgress(source) {
|
|
166
|
-
return {
|
|
167
|
-
type: "GetImportProgress",
|
|
168
|
-
source: primitiveToConfig(source)
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function getLastLogs(source, lines) {
|
|
172
|
-
return {
|
|
173
|
-
type: "GetLastLogs",
|
|
174
|
-
source: primitiveToConfig(source),
|
|
175
|
-
lines
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function getProgressLog(source, patternToSearch) {
|
|
179
|
-
return {
|
|
180
|
-
type: "GetProgressLog",
|
|
181
|
-
source: primitiveToConfig(source),
|
|
182
|
-
patternToSearch
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function getProgressLogWithInfo(source, patternToSearch) {
|
|
186
|
-
return {
|
|
187
|
-
type: "GetProgressLogWithInfo",
|
|
188
|
-
source: primitiveToConfig(source),
|
|
189
|
-
patternToSearch
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function getLogHandle(source) {
|
|
193
|
-
return {
|
|
194
|
-
type: "GetLogHandle",
|
|
195
|
-
source: primitiveToConfig(source)
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
//#endregion
|
|
199
|
-
exports.Args = Args;
|
|
200
|
-
exports.It = It;
|
|
201
|
-
exports.MainOutputs = MainOutputs;
|
|
202
|
-
exports.StagingOutputs = StagingOutputs;
|
|
203
|
-
exports.UiState = UiState;
|
|
204
|
-
exports.and = and;
|
|
205
|
-
exports.extractArchiveAndGetURL = extractArchiveAndGetURL;
|
|
206
|
-
exports.flatten = flatten;
|
|
207
|
-
exports.getBlobContent = getBlobContent;
|
|
208
|
-
exports.getBlobContentAsJson = getBlobContentAsJson;
|
|
209
|
-
exports.getBlobContentAsString = getBlobContentAsString;
|
|
210
|
-
exports.getDownloadedBlobContent = getDownloadedBlobContent;
|
|
211
|
-
exports.getFromCfg = getFromCfg;
|
|
212
|
-
exports.getImmediate = getImmediate;
|
|
213
|
-
exports.getImportProgress = getImportProgress;
|
|
214
|
-
exports.getJsonField = getJsonField;
|
|
215
|
-
exports.getLastLogs = getLastLogs;
|
|
216
|
-
exports.getLogHandle = getLogHandle;
|
|
217
|
-
exports.getOnDemandBlobContent = getOnDemandBlobContent;
|
|
218
|
-
exports.getProgressLog = getProgressLog;
|
|
219
|
-
exports.getProgressLogWithInfo = getProgressLogWithInfo;
|
|
220
|
-
exports.getResourceField = getResourceField;
|
|
221
|
-
exports.getResourceValueAsJson = getResourceValueAsJson;
|
|
222
|
-
exports.isEmpty = isEmpty;
|
|
223
|
-
exports.isolate = isolate;
|
|
224
|
-
exports.makeArray = makeArray;
|
|
225
|
-
exports.makeObject = makeObject;
|
|
226
|
-
exports.mapArrayValues = mapArrayValues;
|
|
227
|
-
exports.mapRecordValues = mapRecordValues;
|
|
228
|
-
exports.mapResourceFields = mapResourceFields;
|
|
229
|
-
exports.not = not;
|
|
230
|
-
exports.or = or;
|
|
231
|
-
|
|
232
|
-
//# sourceMappingURL=actions.cjs.map
|