@platforma-sdk/model 1.8.19 → 1.10.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.
Files changed (64) hide show
  1. package/dist/bconfig/container.d.ts +46 -0
  2. package/dist/bconfig/container.d.ts.map +1 -0
  3. package/dist/bconfig/index.d.ts +7 -0
  4. package/dist/bconfig/index.d.ts.map +1 -0
  5. package/dist/bconfig/lambdas.d.ts +33 -0
  6. package/dist/bconfig/lambdas.d.ts.map +1 -0
  7. package/dist/bconfig/normalization.d.ts +13 -0
  8. package/dist/bconfig/normalization.d.ts.map +1 -0
  9. package/dist/bconfig/types.d.ts +11 -0
  10. package/dist/bconfig/types.d.ts.map +1 -0
  11. package/dist/bconfig/utils.d.ts +7 -0
  12. package/dist/bconfig/utils.d.ts.map +1 -0
  13. package/dist/bconfig/v3.d.ts +30 -0
  14. package/dist/bconfig/v3.d.ts.map +1 -0
  15. package/dist/builder.d.ts +45 -65
  16. package/dist/builder.d.ts.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +510 -271
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/internal.d.ts +3 -2
  24. package/dist/internal.d.ts.map +1 -1
  25. package/dist/platforma.d.ts +3 -2
  26. package/dist/platforma.d.ts.map +1 -1
  27. package/dist/raw_globals.d.ts.map +1 -1
  28. package/dist/render/accessor.d.ts +47 -0
  29. package/dist/render/accessor.d.ts.map +1 -1
  30. package/dist/render/api.d.ts +2 -0
  31. package/dist/render/api.d.ts.map +1 -1
  32. package/dist/render/index.d.ts +1 -0
  33. package/dist/render/index.d.ts.map +1 -1
  34. package/dist/render/internal.d.ts +4 -0
  35. package/dist/render/internal.d.ts.map +1 -1
  36. package/dist/render/traversal_ops.d.ts +5 -2
  37. package/dist/render/traversal_ops.d.ts.map +1 -1
  38. package/dist/render/util/index.d.ts +2 -0
  39. package/dist/render/util/index.d.ts.map +1 -0
  40. package/dist/render/util/resource_map.d.ts +15 -0
  41. package/dist/render/util/resource_map.d.ts.map +1 -0
  42. package/dist/version.d.ts +1 -1
  43. package/package.json +3 -3
  44. package/src/bconfig/container.ts +58 -0
  45. package/src/bconfig/index.ts +6 -0
  46. package/src/bconfig/lambdas.ts +44 -0
  47. package/src/bconfig/normalization.ts +120 -0
  48. package/src/bconfig/types.ts +18 -0
  49. package/src/bconfig/utils.ts +8 -0
  50. package/src/bconfig/v3.ts +46 -0
  51. package/src/builder.ts +165 -141
  52. package/src/global.d.ts +1 -1
  53. package/src/index.ts +1 -0
  54. package/src/internal.ts +1 -2
  55. package/src/platforma.ts +1 -2
  56. package/src/raw_globals.ts +2 -1
  57. package/src/render/accessor.ts +136 -0
  58. package/src/render/api.ts +22 -10
  59. package/src/render/index.ts +1 -0
  60. package/src/render/internal.ts +12 -0
  61. package/src/render/traversal_ops.ts +5 -2
  62. package/src/render/util/index.ts +1 -0
  63. package/src/render/util/resource_map.ts +74 -0
  64. package/src/typing.test.ts +5 -4
@@ -0,0 +1,46 @@
1
+ import { BlockRenderingMode } from '@milaboratories/pl-model-common';
2
+ import { Code, TypedConfigOrString } from './types';
3
+ import { BlockConfigV3 } from './v3';
4
+ /** Container simplifying maintenance of forward and backward compatibility */
5
+ export type BlockConfigContainer = {
6
+ /** Actual config */
7
+ readonly v3: Omit<BlockConfigV3, 'code'>;
8
+ /** Config code bundle */
9
+ readonly code?: Code;
10
+ /**
11
+ * For backward compatibility
12
+ * @deprecated
13
+ */
14
+ readonly sdkVersion?: string;
15
+ /**
16
+ * For backward compatibility
17
+ * @deprecated
18
+ */
19
+ readonly renderingMode?: BlockRenderingMode;
20
+ /**
21
+ * For backward compatibility
22
+ * @deprecated
23
+ */
24
+ readonly initialArgs?: unknown;
25
+ /**
26
+ * For backward compatibility
27
+ * @deprecated
28
+ */
29
+ readonly canRun?: TypedConfigOrString;
30
+ /**
31
+ * For backward compatibility
32
+ * @deprecated
33
+ */
34
+ readonly inputsValid?: TypedConfigOrString;
35
+ /**
36
+ * For backward compatibility
37
+ * @deprecated
38
+ */
39
+ readonly sections?: TypedConfigOrString;
40
+ /**
41
+ * For backward compatibility
42
+ * @deprecated
43
+ */
44
+ readonly outputs?: Record<string, TypedConfigOrString>;
45
+ };
46
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/bconfig/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG;IACjC,oBAAoB;IACpB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAEzC,yBAAyB;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IAMrB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAE3C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAExC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CACxD,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './container';
2
+ export * from './lambdas';
3
+ export * from './normalization';
4
+ export * from './types';
5
+ export * from './utils';
6
+ export * from './v3';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bconfig/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,MAAM,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { ConfigResult, PlResourceEntry, TypedConfig } from '../config';
2
+ export type StdCtxArgsOnly<Args, UiState = undefined> = {
3
+ readonly $blockId: string;
4
+ readonly $args: Args;
5
+ readonly $ui: UiState;
6
+ };
7
+ export type StdCtx<Args, UiState = undefined> = StdCtxArgsOnly<Args, UiState> & {
8
+ readonly $prod: PlResourceEntry;
9
+ readonly $staging: PlResourceEntry;
10
+ };
11
+ export type ResolveCfgType<Cfg extends TypedConfig, Args, UiState = undefined> = ConfigResult<Cfg, StdCtx<Args, UiState>>;
12
+ /** Additional information that may alter lambda rendering procedure. */
13
+ export type ConfigRenderLambdaFlags = {
14
+ /**
15
+ * Tells the system that corresponding computable should be created with StableOnlyRetentive rendering mode.
16
+ * This flag can be overriden by the system.
17
+ * */
18
+ retentive?: boolean;
19
+ /**
20
+ * Tells the system that resulting computable has important side-effects, thus it's rendering is required even
21
+ * nobody is actively monitoring rendered values. Like file upload progress, that triggers upload itself.
22
+ * */
23
+ isActive?: boolean;
24
+ };
25
+ /** Creates branded Cfg type */
26
+ export interface ConfigRenderLambda<Return = unknown> extends ConfigRenderLambdaFlags {
27
+ /** Type marker */
28
+ __renderLambda: true;
29
+ /** Reference to a callback registered inside the model code. */
30
+ handle: string;
31
+ }
32
+ export type ExtractFunctionHandleReturn<Func extends ConfigRenderLambda> = Func extends ConfigRenderLambda<infer Return> ? Return : never;
33
+ //# sourceMappingUR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KAAK,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { BlockConfigContainer } from './container';
2
+ import { TypedConfigOrConfigLambda, TypedConfigOrString } from './types';
3
+ import { BlockConfig } from './v3';
4
+ export declare function downgradeCfgOrLambda(data: TypedConfigOrConfigLambda): TypedConfigOrString;
5
+ export declare function downgradeCfgOrLambda(data: TypedConfigOrConfigLambda | undefined): TypedConfigOrString | undefined;
6
+ /**
7
+ * Takes universal config, and converts it into latest config structure.
8
+ *
9
+ * **Important**: This operation is not meant to be executed recusively.
10
+ * In no circumstance result of this function should be persisted!
11
+ * */
12
+ export declare function extractConfig(cfg: BlockConfigContainer): BlockConfig;
13
+ //# sourceMappingURL=normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalization.d.ts","sourceRoot":"","sources":["../../src/bconfig/normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAkB,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAEnC,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,yBAAyB,GAAG,mBAAmB,CAAC;AAC3F,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,yBAAyB,GAAG,SAAS,GAC1C,mBAAmB,GAAG,SAAS,CAAC;AAqBnC;;;;;KAKK;AACL,wBAAgB,aAAa,CAAC,GAAG,EAAE,oBAAoB,GAAG,WAAW,CAqFpE"}
@@ -0,0 +1,11 @@
1
+ import { TypedConfig } from '../config';
2
+ import { ConfigRenderLambda } from './lambdas';
3
+ export type Code = {
4
+ type: 'plain';
5
+ content: string;
6
+ };
7
+ export declare function isConfigLambda(cfgOrFh: TypedConfigOrConfigLambda): cfgOrFh is ConfigRenderLambda;
8
+ export type TypedConfigOrConfigLambda = TypedConfig | ConfigRenderLambda;
9
+ /** @deprecated */
10
+ export type TypedConfigOrString = TypedConfig | string;
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bconfig/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,yBAAyB,GACjC,OAAO,IAAI,kBAAkB,CAE/B;AAED,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEzE,kBAAkB;AAClB,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { BlockSection } from '@milaboratories/pl-model-common';
2
+ type OnlyString<S> = S extends string ? S : '';
3
+ export type DeriveHref<S> = S extends readonly BlockSection[] ? OnlyString<Extract<S[number], {
4
+ type: 'link';
5
+ }>['href']> : never;
6
+ export {};
7
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/bconfig/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC;AAG/C,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,YAAY,EAAE,GACzD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GACxD,KAAK,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { BlockRenderingMode } from '@milaboratories/pl-model-common';
2
+ import { Code, TypedConfigOrConfigLambda } from './types';
3
+ import { ConfigRenderLambda } from './lambdas';
4
+ export type BlockConfigV3<Args = unknown, UiState = unknown, Outputs extends Record<string, TypedConfigOrConfigLambda> = Record<string, TypedConfigOrConfigLambda>> = {
5
+ /** SDK version used by the block */
6
+ readonly sdkVersion: string;
7
+ /** Main rendering mode for the block */
8
+ readonly renderingMode: BlockRenderingMode;
9
+ /** Initial value for the args when block is added to the project */
10
+ readonly initialArgs: Args;
11
+ /** Initial value for the args when block is added to the project */
12
+ readonly initialUiState: UiState;
13
+ /**
14
+ * Config to determine whether the block can be executed with current
15
+ * arguments.
16
+ *
17
+ * Optional to support earlier SDK version configs.
18
+ * */
19
+ readonly inputsValid: TypedConfigOrConfigLambda;
20
+ /** Configuration to derive list of section for the left overview panel */
21
+ readonly sections: TypedConfigOrConfigLambda;
22
+ /** Lambda to derive block title */
23
+ readonly title?: ConfigRenderLambda;
24
+ /** Configuration for the output cells */
25
+ readonly outputs: Outputs;
26
+ /** Config code bundle */
27
+ readonly code?: Code;
28
+ };
29
+ export type BlockConfig = BlockConfigV3;
30
+ //# sourceMappingURL=v3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3.d.ts","sourceRoot":"","sources":["../../src/bconfig/v3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,aAAa,CACvB,IAAI,GAAG,OAAO,EACd,OAAO,GAAG,OAAO,EACjB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAAG,MAAM,CAChE,MAAM,EACN,yBAAyB,CAC1B,IACC;IACF,oCAAoC;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,wCAAwC;IACxC,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;IAE3C,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAE3B,oEAAoE;IACpE,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IAEjC;;;;;SAKK;IACL,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC;IAEhD,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAE7C,mCAAmC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAEpC,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,yBAAyB;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC"}
package/dist/builder.d.ts CHANGED
@@ -1,91 +1,63 @@
1
1
  import { BlockRenderingMode, BlockSection, ValueOrErrors } from '@milaboratories/pl-model-common';
2
- import { Checked, ConfigResult, PlResourceEntry, TypedConfig } from './config';
2
+ import { Checked, ConfigResult, TypedConfig } from './config';
3
3
  import { Platforma } from './platforma';
4
4
  import { InferRenderFunctionReturn, RenderFunction } from './render';
5
- type StdCtxArgsOnly<Args, UiState = undefined> = {
6
- readonly $blockId: string;
7
- readonly $args: Args;
8
- readonly $ui: UiState;
9
- };
10
- export type StdCtx<Args, UiState = undefined> = StdCtxArgsOnly<Args, UiState> & {
11
- readonly $prod: PlResourceEntry;
12
- readonly $staging: PlResourceEntry;
13
- };
14
- export type ResolveCfgType<Cfg extends TypedConfig, Args, UiState = undefined> = ConfigResult<Cfg, StdCtx<Args, UiState>>;
5
+ import { TypedConfigOrConfigLambda, ConfigRenderLambda, StdCtxArgsOnly, DeriveHref, ResolveCfgType, ExtractFunctionHandleReturn, ConfigRenderLambdaFlags } from './bconfig';
15
6
  type SectionsExpectedType = readonly BlockSection[];
16
7
  type SectionsCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<Cfg, ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends SectionsExpectedType ? true : false>;
17
8
  type InputsValidExpectedType = boolean;
18
9
  type InputsValidCfgChecked<Cfg extends TypedConfig, Args, UiState> = Checked<Cfg, ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>> extends InputsValidExpectedType ? true : false>;
19
- export type Code = {
20
- type: 'plain';
21
- content: string;
22
- };
23
- /** Field key to attach ConfAction information to a config type. */
24
- declare const __function_handle__: unique symbol;
25
- /** Creates branded Cfg type */
26
- export type FunctionHandle<Return = unknown> = string & {
27
- [__function_handle__]: Return;
28
- };
29
- export type ExtractFunctionHandleReturn<Func extends FunctionHandle> = Func[typeof __function_handle__];
30
- export type TypedConfigOrFunctionHandle = TypedConfig | FunctionHandle;
31
- export declare function isFunctionHandle(cfgOrFh: TypedConfigOrFunctionHandle): cfgOrFh is FunctionHandle;
32
- type OnlyString<S> = S extends string ? S : '';
33
- export type DeriveHref<S> = S extends readonly BlockSection[] ? OnlyString<Extract<S[number], {
34
- type: 'link';
35
- }>['href']> : never;
36
- /** This structure is rendered from the configuration, type can accommodate any
37
- * version of config structure. */
38
- export type BlockConfigUniversal<Args = unknown, Outputs extends Record<string, TypedConfigOrFunctionHandle> = Record<string, TypedConfigOrFunctionHandle>> = {
39
- /** SDK version used by the block */
40
- readonly sdkVersion: string;
41
- /** Main rendering mode for the block */
42
- readonly renderingMode: BlockRenderingMode;
43
- /** Initial value for the args when block is added to the project */
44
- readonly initialArgs: Args;
45
- /** @deprecated */
46
- readonly canRun?: TypedConfigOrFunctionHandle;
47
- /**
48
- * Config to determine whether the block can be executed with current
49
- * arguments.
50
- *
51
- * Optional to support earlier SDK version configs.
52
- * */
53
- readonly inputsValid?: TypedConfigOrFunctionHandle;
54
- /** Configuration to derive list of section for the left overview panel */
55
- readonly sections: TypedConfigOrFunctionHandle;
56
- /** Configuration for the output cells */
57
- readonly outputs: Outputs;
58
- /** Config code bundle */
59
- readonly code?: Code;
60
- };
61
- /** This structure is rendered from the configuration */
62
- export type BlockConfig<Args = unknown, Outputs extends Record<string, TypedConfigOrFunctionHandle> = Record<string, TypedConfigOrFunctionHandle>> = Required<Omit<BlockConfigUniversal<Args, Outputs>, 'canRun' | 'code'>> & Pick<BlockConfigUniversal<Args, Outputs>, 'code'>;
63
- /** Takes universal config, and converts it into latest structure */
64
- export declare function normalizeBlockConfig<Args, Outputs extends Record<string, TypedConfigOrFunctionHandle>>(cfg: BlockConfigUniversal<Args, Outputs>): BlockConfig<Args, Outputs>;
10
+ type NoOb = Record<string, never>;
65
11
  /** Main entry point that each block should use in it's "config" module. Don't forget
66
12
  * to call {@link done()} at the end of configuration. Value returned by this builder must be
67
13
  * exported as constant with name "platforma" from the "config" module. */
68
- export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedConfigOrFunctionHandle>, UiState, Href extends `/${string}` = '/'> {
14
+ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedConfigOrConfigLambda>, UiState, Href extends `/${string}` = '/'> {
69
15
  private readonly _renderingMode;
70
16
  private readonly _initialArgs;
17
+ private readonly _initialUiState;
71
18
  private readonly _outputs;
72
19
  private readonly _inputsValid;
73
20
  private readonly _sections;
21
+ private readonly _title;
74
22
  private constructor();
75
23
  /** Initiates configuration builder */
76
- static create<Args, UiState = undefined>(renderingMode?: BlockRenderingMode): BlockModel<Args, {}, UiState>;
24
+ static create(renderingMode: BlockRenderingMode): BlockModel<NoOb, {}, NoOb>;
25
+ /** Initiates configuration builder */
26
+ static create(): BlockModel<NoOb, {}, NoOb>;
27
+ /**
28
+ * Initiates configuration builder
29
+ * @deprecated use create method without generic parameter
30
+ */
31
+ static create<Args>(renderingMode: BlockRenderingMode): BlockModel<Args, {}, NoOb>;
32
+ /**
33
+ * Initiates configuration builder
34
+ * @deprecated use create method without generic parameter
35
+ */
36
+ static create<Args>(): BlockModel<Args, {}, NoOb>;
77
37
  /**
78
38
  * Add output cell to the configuration
79
39
  *
80
- * @param key cell name, that can be used to retrieve the rendered value
40
+ * @param key output cell name, that can be later used to retrieve the rendered value
81
41
  * @param cfg configuration describing how to render cell value from the blocks
82
42
  * workflow outputs
83
43
  * */
84
44
  output<const Key extends string, const Cfg extends TypedConfig>(key: Key, cfg: Cfg): BlockModel<Args, OutputsCfg & {
85
45
  [K in Key]: Cfg;
86
46
  }, UiState, Href>;
87
- output<const Key extends string, const RF extends RenderFunction<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & {
88
- [K in Key]: FunctionHandle<InferRenderFunctionReturn<RF>>;
47
+ /**
48
+ * Add output cell 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 RenderFunction<Args, UiState>>(key: Key, rf: RF, flags?: ConfigRenderLambdaFlags): BlockModel<Args, OutputsCfg & {
56
+ [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>>;
57
+ }, UiState, Href>;
58
+ /** Shortcut for {@link output} with retentive flag set to true. */
59
+ retentiveOutput<const Key extends string, const RF extends RenderFunction<Args, UiState>>(key: Key, rf: RF): BlockModel<Args, OutputsCfg & {
60
+ [K in Key]: ConfigRenderLambda<InferRenderFunctionReturn<RF>>;
89
61
  }, UiState, Href>;
90
62
  /** @deprecated */
91
63
  canRun<Cfg extends TypedConfig>(cfg: Cfg & InputsValidCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, Href>;
@@ -101,15 +73,23 @@ export declare class BlockModel<Args, OutputsCfg extends Record<string, TypedCon
101
73
  sections<const S extends SectionsExpectedType>(rf: S): BlockModel<Args, OutputsCfg, UiState, DeriveHref<S>>;
102
74
  sections<const Ret extends SectionsExpectedType, const RF extends RenderFunction<Args, UiState, Ret>>(rf: RF): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ReturnType<RF>>>;
103
75
  sections<const Cfg extends TypedConfig>(cfg: Cfg & SectionsCfgChecked<Cfg, Args, UiState>): BlockModel<Args, OutputsCfg, UiState, DeriveHref<ConfigResult<Cfg, StdCtxArgsOnly<Args, UiState>>>>;
104
- /** Sets initial args for the block, this value must be specified. */
76
+ title(rf: RenderFunction<Args, UiState, string>): BlockModel<Args, OutputsCfg, UiState, Href>;
77
+ /**
78
+ * Sets initial args for the block, this value must be specified.
79
+ * @deprecated use {@link withArgs}
80
+ * */
105
81
  initialArgs(value: Args): BlockModel<Args, OutputsCfg, UiState, Href>;
82
+ /** Sets initial args for the block, this value must be specified. */
83
+ withArgs<Args>(initialValue: Args): BlockModel<Args, OutputsCfg, UiState, Href>;
84
+ /** Defines type and sets initial value for block UiState. */
85
+ withUiState<UiState>(initialValue: UiState): BlockModel<Args, OutputsCfg, UiState, Href>;
106
86
  /** Renders all provided block settings into a pre-configured platforma API
107
87
  * instance, that can be used in frontend to interact with block state, and
108
88
  * other features provided by the platforma to the block. */
109
89
  done(): Platforma<Args, InferOutputsFromConfigs<Args, OutputsCfg, UiState>, UiState, Href>;
110
90
  }
111
- export type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig ? ResolveCfgType<CfgOrFH, Args, UiState> : CfgOrFH extends FunctionHandle ? ExtractFunctionHandleReturn<CfgOrFH> : never;
112
- type InferOutputsFromConfigs<Args, OutputsCfg extends Record<string, TypedConfigOrFunctionHandle>, UiState> = {
91
+ export type InferOutputType<CfgOrFH, Args, UiState> = CfgOrFH extends TypedConfig ? ResolveCfgType<CfgOrFH, Args, UiState> : CfgOrFH extends ConfigRenderLambda ? ExtractFunctionHandleReturn<CfgOrFH> : never;
92
+ type InferOutputsFromConfigs<Args, OutputsCfg extends Record<string, TypedConfigOrConfigLambda>, UiState> = {
113
93
  [Key in keyof OutputsCfg]: ValueOrErrors<InferOutputType<OutputsCfg[Key], Args, UiState>>;
114
94
  };
115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C,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,GACtC,OAAO,SAAS,kBAAkB,GAChC,2BAA2B,CAAC,OAAO,CAAC,GACpC,KAAK,CAAC;AAEZ,KAAK,uBAAuB,CAC1B,IAAI,EACJ,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,EAC5D,OAAO,IACL;KACD,GAAG,IAAI,MAAM,UAAU,GAAG,aAAa,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;CAC1F,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './block_state_patch';
2
2
  export * from './block_state_util';
3
3
  export * from './builder';
4
+ export * from './bconfig';
4
5
  export * from './components';
5
6
  export * from './config';
6
7
  export * from './pframe';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAG9B,cAAc,iCAAiC,CAAC;AAEhD,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAG9B,cAAc,iCAAiC,CAAC;AAEhD,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var L=Object.defineProperty;var k=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var d=(e,t,n)=>k(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@milaboratories/pl-model-common");class S extends Error{constructor(t,n){super(`${t.length}${n?"+":""} errors, first error: `+t[0]),this.errors=t,this.moreErrors=n}}function R(e){if(!e.ok)throw new S(e.errors,e.moreErrors);return e.value}function J(e){return new Proxy(e,{get(t,n){return R(t[n])}})}function i(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null?m(e):e}function h(e){return{type:"GetFromCtx",variable:e}}function H(e){return{type:"Isolate",cfg:e}}const M=h("$args"),N=h("$it"),G=h("$prod"),$=h("$staging"),K=h("$ui");function m(e){return{type:"Immediate",value:e}}function P(e){const t={};for(const[n,r]of Object.entries(e))t[n]=i(r);return{type:"MakeObject",template:t}}function W(...e){const t=[];for(const n of e)t.push(i(n));return{type:"MakeArray",template:t}}function b(e,t){return{type:"GetJsonField",source:i(e),field:i(t)}}function U(e,t,n="$it"){return{type:"MapRecordValues",source:e,mapping:t,itVar:n}}function z(e,t,n="$it"){return{type:"MapArrayValues",source:e,mapping:t,itVar:n}}function q(e){return{type:"Flatten",source:e}}function Q(e){return{type:"IsEmpty",arg:e}}function X(e){return{type:"Not",operand:e}}function Y(e,t){return{type:"And",operand1:e,operand2:t}}function Z(e,t){return{type:"Or",operand1:e,operand2:t}}function tt(e,t){return{type:"GetResourceField",source:i(e),field:i(t)}}function et(){return function(e){return{type:"GetResourceValueAsJson",source:i(e)}}}function nt(e,t,n="$it"){return{type:"MapResourceFields",source:e,mapping:t,itVar:n}}function rt(e){return{type:"GetBlobContent",source:i(e)}}function st(e){return{type:"GetBlobContentAsString",source:i(e)}}function ot(){return function(e){return{type:"GetBlobContentAsJson",source:i(e)}}}function it(e){return{type:"GetDownloadedBlobContent",source:i(e)}}function at(e){return{type:"GetOnDemandBlobContent",source:i(e)}}function ut(e){return{type:"GetImportProgress",source:i(e)}}function lt(e,t){return{type:"GetLastLogs",source:i(e),lines:t}}function ct(e,t){return{type:"GetProgressLog",source:i(e),patternToSearch:t}}function gt(e){return{type:"GetLogHandle",source:i(e)}}function dt(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function v(e){if(e&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(e);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function pt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function s(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function w(e,t){const n=pt();if(n===void 0)return!1;if(e in n.callbackRegistry)throw new Error(`Callback with key ${e} already registered.`);return n.callbackRegistry[e]=t,!0}const A=new Map;function ft(e,t){e in s().callbackRegistry||(s().callbackRegistry[e]=n=>{for(const r of A.get(e))r(n)},A.set(e,[])),A.get(e).push(t)}class u{constructor(t,n=r=>r){d(this,"isResolved",!1);d(this,"resolvedValue");this.handle=t,this.postProcess=n,ft(t,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(t){return new u(this.handle,n=>t(this.postProcess(n)))}mapDefined(t){return new u(this.handle,n=>{const r=this.postProcess(n);return r?t(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function _(e){return e===void 0?void 0:new f(e)}class f{constructor(t){this.handle=t}resolve(...t){return this.resolveWithCommon({},...t)}resolveWithCommon(t,...n){return _(s().resolveWithCommon(this.handle,t,...n))}get resourceType(){return s().getResourceType(this.handle)}getInputsLocked(){return s().getInputsLocked(this.handle)}getOutputsLocked(){return s().getOutputsLocked(this.handle)}getIsReadyOrError(){return s().getIsReadyOrError(this.handle)}getIsFinal(){return s().getIsFinal(this.handle)}getError(){return _(s().getError(this.handle))}listInputFields(){return s().listInputFields(this.handle)}listOutputFields(){return s().listOutputFields(this.handle)}listDynamicFields(){return s().listDynamicFields(this.handle)}getKeyValueBase64(t){return s().getKeyValueBase64(this.handle,t)}getKeyValueAsString(t){return s().getKeyValueAsString(this.handle,t)}getKeyValueAsJson(t){const n=this.getKeyValueAsString(t);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return s().getDataBase64(this.handle)}getDataAsString(){return s().getDataAsString(this.handle)}getDataAsJson(){const t=this.getDataAsString();if(t==null)throw new Error("Resource has no content.");return JSON.parse(t)}getPColumns(t=!1,n=""){const r=this.parsePObjectCollection(t,n);return r===void 0?void 0:Object.entries(r).map(([,a])=>{if(!l.isPColumn(a))throw new Error(`not a PColumn (kind = ${a.spec.kind})`);return a})}parsePObjectCollection(t=!1,n=""){const r=s().parsePObjectCollection(this.handle,t,n);if(r===void 0)return;const o={};for(const[a,p]of Object.entries(r))o[a]=l.mapPObjectData(p,c=>new f(c));return o}getFileContentAsBase64(){return new u(s().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new u(s().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new u(s().getBlobContentAsString(this.handle)).mapDefined(t=>JSON.parse(t))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new u(s().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new u(s().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}getImportProgress(){return new u(s().getImportProgress(this.handle))}getLastLogs(t){return new u(s().getLastLogs(this.handle,t))}getProgressLog(t){return new u(s().getProgressLog(this.handle,t))}getLogHandle(){return new u(s().getLogHandle(this.handle))}}const O="staging",I="main";function V(e){return typeof e=="object"&&e!==null&&"__awaited_futures__"in e}function C(e,t,n){if(t.has(n))return;if(t.add(n),typeof n==="object")if(V(n))n.__awaited_futures__.forEach(o=>e.add(o));else if(Array.isArray(n))for(const o of n)C(e,t,o);else for(const[,o]of Object.entries(n))o!==n&&C(e,t,o)}function ht(e){const t=new Set;return C(t,new Set,e),t}const mt=Object.freeze(Object.defineProperty({__proto__:null,MainAccessorName:I,StagingAccessorName:O,getAllFutureAwaits:ht,isFutureAwait:V},Symbol.toStringTag,{value:"Module"}));class x{constructor(){d(this,"ctx",s());d(this,"defaultLabelFn",(t,n)=>{var r;return((r=t.annotations)==null?void 0:r["pl7.app/label"])??"Unlabelled"})}calculateOptions(t){return this.ctx.calculateOptions(t)}getOptions(t,n=this.defaultLabelFn){return this.getSpecs().entries.filter(r=>t(r.obj)).map(r=>({ref:r.ref,label:n(r.obj,r.ref)}))}getDataFromResultPool(){return this.getData()}getData(){const t=this.ctx.getDataFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new f(n.obj.data)}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const t=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:l.mapValueInVOE(n.obj.data,r=>new f(r))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(t){var n;return(n=this.getData().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj}getSpecByRef(t){var n;return(n=this.getSpecs().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj}findDataWithCompatibleSpec(t){const n=[];t:for(const r of this.getData().entries){if(!l.isPColumnSpec(r.obj.spec))continue;const o=r.obj.spec;if(t.name===o.name&&t.valueType===o.valueType&&t.axesSpec.length===o.axesSpec.length&&D(t.domain,o.domain)){for(let a=0;a<t.axesSpec.length;++a){const p=t.axesSpec[a],c=o.axesSpec[a];if(p.name!==c.name||p.type!==c.type||!D(p.domain,c.domain))continue t}n.push(r.obj)}}return n}}function D(e,t){if(e===void 0)return t===void 0;if(t===void 0)return!0;for(const n in t)if(e[n]!==t[n])return!1;return!0}class y{constructor(){d(this,"ctx");d(this,"args");d(this,"uiState");d(this,"resultPool",new x);this.ctx=s(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):void 0}getNamedAccessor(t){const n=this.ctx.getAccessorHandleByName(t);return n?new f(n):void 0}get prerun(){return this.getNamedAccessor(O)}get precalc(){return this.prerun}get stagingOutput(){return this.precalc}get outputs(){return this.getNamedAccessor(I)}get mainOutput(){return this.outputs}createPFrame(t){return this.ctx.createPFrame(t.map(n=>l.mapPObjectData(n,r=>r.handle)))}createPTable(t){var n;return"columns"in t?n={src:{type:"inner",entries:t.columns.map(r=>({type:"column",column:r}))},filters:t.filters??[],sorting:t.sorting??[]}:n=t,this.ctx.createPTable(l.mapPTableDef(n,r=>l.mapPObjectData(r,o=>o.handle)))}getBlockLabel(t){return this.ctx.getBlockLabel(t)}}const B="1.8.19";function bt(e){return typeof e=="string"}function yt(e){if(e.inputsValid!==void 0)return e;{if(e.canRun===void 0)throw new Error(`Malformed config, SDK version ${e.sdkVersion}`);const t={...e,inputsValid:e.canRun};return delete t.canRun,t}}class g{constructor(t,n,r,o,a){this._renderingMode=t,this._initialArgs=n,this._outputs=r,this._inputsValid=o,this._sections=a}static create(t="Heavy"){return new g(t,void 0,{},m(!0),m([]))}output(t,n){if(typeof n=="function"){const r=`output#${t}`;return w(r,()=>n(new y)),new g(this._renderingMode,this._initialArgs,{...this._outputs,[t]:r},this._inputsValid,this._sections)}else return new g(this._renderingMode,this._initialArgs,{...this._outputs,[t]:n},this._inputsValid,this._sections)}canRun(t){return this.inputsValid(t)}argsValid(t){return typeof t=="function"?(w("inputsValid",()=>t(new y)),new g(this._renderingMode,this._initialArgs,this._outputs,"inputsValid",this._sections)):new g(this._renderingMode,this._initialArgs,this._outputs,t,this._sections)}inputsValid(t){return this.argsValid(t)}sections(t){return Array.isArray(t)?this.sections(m(t)):typeof t=="function"?(w("sections",()=>t(new y)),new g(this._renderingMode,this._initialArgs,this._outputs,this._inputsValid,"sections")):new g(this._renderingMode,this._initialArgs,this._outputs,this._inputsValid,t)}initialArgs(t){return new g(this._renderingMode,t,this._outputs,this._inputsValid,this._sections)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const t={sdkVersion:B,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:this._inputsValid,sections:this._sections,outputs:this._outputs};return dt()?v(t):{config:t}}}function wt(e,t,n){var a,p;const r=e.resultPool.getData().entries.map(c=>c.obj).filter(l.isPColumn).filter(c=>c.spec.name==="pl7.app/label"&&c.spec.axesSpec.length===1),o=[];for(const c of t)for(const T of c.spec.axesSpec){const E=l.getAxisId(T);for(const F of r)l.matchAxisId(E,l.getAxisId(F.spec.axesSpec[0]))&&o.push(F)}return e.createPTable({columns:[...t,...o],filters:(a=n==null?void 0:n.pTableParams)==null?void 0:a.filters,sorting:(p=n==null?void 0:n.pTableParams)==null?void 0:p.sorting})}class At{constructor(t){this.handle=t}async findColumns(t){return await platforma.pFrameDriver.findColumns(this.handle,t)}async getColumnSpec(t){return await platforma.pFrameDriver.getColumnSpec(this.handle,t)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(t){return await platforma.pFrameDriver.calculateTableData(this.handle,t)}async getUniqueValues(t){return await platforma.pFrameDriver.getUniqueValues(this.handle,t)}}function j(e){return P({__isRef:!0,blockId:b(e,"blockId"),name:b(e,"name")})}function Ct(e){return P({ref:j(b(e,"ref")),label:b(e,"label")})}const Pt={sdkVersion:B};function Ft(){return v()}function _t(e){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(e)}exports.Args=M;exports.BlockModel=g;exports.CurrentSdkInfo=Pt;exports.FutureRef=u;exports.It=N;exports.JsRenderInternal=mt;exports.MainOutputs=G;exports.OutputError=S;exports.PFrameImpl=At;exports.RenderCtx=y;exports.ResultPool=x;exports.StagingOutputs=$;exports.TreeNodeAccessor=f;exports.UiState=K;exports.and=Y;exports.createPlDataTable=wt;exports.flatten=q;exports.fromPlOption=Ct;exports.fromPlRef=j;exports.getBlobContent=rt;exports.getBlobContentAsJson=ot;exports.getBlobContentAsString=st;exports.getDownloadedBlobContent=it;exports.getEnvironmentValue=_t;exports.getFromCfg=h;exports.getImmediate=m;exports.getImportProgress=ut;exports.getJsonField=b;exports.getLastLogs=lt;exports.getLogHandle=gt;exports.getOnDemandBlobContent=at;exports.getProgressLog=ct;exports.getRawPlatformaInstance=Ft;exports.getResourceField=tt;exports.getResourceValueAsJson=et;exports.isEmpty=Q;exports.isFunctionHandle=bt;exports.isolate=H;exports.makeArray=W;exports.makeObject=P;exports.mapArrayValues=z;exports.mapRecordValues=U;exports.mapResourceFields=nt;exports.normalizeBlockConfig=yt;exports.not=X;exports.or=Z;exports.readOutput=R;exports.wrapOutputs=J;Object.keys(l).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>l[e]})});
1
+ "use strict";var $=Object.defineProperty;var H=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var f=(e,t,n)=>H(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@milaboratories/pl-model-common");class V extends Error{constructor(t,n){super(`${t.length}${n?"+":""} errors, first error: `+t[0]),this.errors=t,this.moreErrors=n}}function k(e){if(!e.ok)throw new V(e.errors,e.moreErrors);return e.value}function G(e){return new Proxy(e,{get(t,n){return k(t[n])}})}function c(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null?w(e):e}function v(e){return{type:"GetFromCtx",variable:e}}function K(e){return{type:"Isolate",cfg:e}}const W=v("$args"),q=v("$it"),z=v("$prod"),Q=v("$staging"),X=v("$ui");function w(e){return{type:"Immediate",value:e}}function R(e){const t={};for(const[n,r]of Object.entries(e))t[n]=c(r);return{type:"MakeObject",template:t}}function Y(...e){const t=[];for(const n of e)t.push(c(n));return{type:"MakeArray",template:t}}function A(e,t){return{type:"GetJsonField",source:c(e),field:c(t)}}function Z(e,t,n="$it"){return{type:"MapRecordValues",source:e,mapping:t,itVar:n}}function tt(e,t,n="$it"){return{type:"MapArrayValues",source:e,mapping:t,itVar:n}}function et(e){return{type:"Flatten",source:e}}function nt(e){return{type:"IsEmpty",arg:e}}function rt(e){return{type:"Not",operand:e}}function it(e,t){return{type:"And",operand1:e,operand2:t}}function st(e,t){return{type:"Or",operand1:e,operand2:t}}function ot(e,t){return{type:"GetResourceField",source:c(e),field:c(t)}}function at(){return function(e){return{type:"GetResourceValueAsJson",source:c(e)}}}function ut(e,t,n="$it"){return{type:"MapResourceFields",source:e,mapping:t,itVar:n}}function lt(e){return{type:"GetBlobContent",source:c(e)}}function ct(e){return{type:"GetBlobContentAsString",source:c(e)}}function dt(){return function(e){return{type:"GetBlobContentAsJson",source:c(e)}}}function pt(e){return{type:"GetDownloadedBlobContent",source:c(e)}}function gt(e){return{type:"GetOnDemandBlobContent",source:c(e)}}function ht(e){return{type:"GetImportProgress",source:c(e)}}function ft(e,t){return{type:"GetLastLogs",source:c(e),lines:t}}function mt(e,t){return{type:"GetProgressLog",source:c(e),patternToSearch:t}}function yt(e){return{type:"GetLogHandle",source:c(e)}}function bt(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function L(e){if(e&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(e);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function vt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function o(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function S(e,t){const n=vt();if(n===void 0)return!1;if(e in n.callbackRegistry)throw new Error(`Callback with key ${e} already registered.`);return n.callbackRegistry[e]=t,!0}const O=new Map;function _t(e,t){e in o().callbackRegistry||(o().callbackRegistry[e]=n=>{for(const r of O.get(e))r(n)},O.set(e,[])),O.get(e).push(t)}class h{constructor(t,n=r=>r){f(this,"isResolved",!1);f(this,"resolvedValue");this.handle=t,this.postProcess=n,_t(t,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(t){return new h(this.handle,n=>t(this.postProcess(n)))}mapDefined(t){return new h(this.handle,n=>{const r=this.postProcess(n);return r?t(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function I(e){return e===void 0?void 0:new y(e)}class y{constructor(t){this.handle=t}resolve(...t){const n=t.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...t){const n=t.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...t){const n=t.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...t){return this.resolveWithCommon({},...t)}resolveWithCommon(t,...n){return I(o().resolveWithCommon(this.handle,t,...n))}get resourceType(){return o().getResourceType(this.handle)}getInputsLocked(){return o().getInputsLocked(this.handle)}getOutputsLocked(){return o().getOutputsLocked(this.handle)}getIsReadyOrError(){return o().getIsReadyOrError(this.handle)}getIsFinal(){return o().getIsFinal(this.handle)}getError(){return I(o().getError(this.handle))}listInputFields(){return o().listInputFields(this.handle)}listOutputFields(){return o().listOutputFields(this.handle)}listDynamicFields(){return o().listDynamicFields(this.handle)}getKeyValueBase64(t){return o().getKeyValueBase64(this.handle,t)}getKeyValueAsString(t){return o().getKeyValueAsString(this.handle,t)}getKeyValueAsJson(t){const n=this.getKeyValueAsString(t);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return o().getDataBase64(this.handle)}getDataAsString(){return o().getDataAsString(this.handle)}getDataAsJson(){const t=this.getDataAsString();if(t==null)throw new Error("Resource has no content.");return JSON.parse(t)}getPColumns(t=!1,n=""){const r=this.parsePObjectCollection(t,n);return r===void 0?void 0:Object.entries(r).map(([,s])=>{if(!p.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(t=!1,n=""){const r=o().parsePObjectCollection(this.handle,t,n);if(r===void 0)return;const i={};for(const[s,u]of Object.entries(r))i[s]=p.mapPObjectData(u,a=>new y(a));return i}getFileContentAsBase64(){return new h(o().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new h(o().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new h(o().getBlobContentAsString(this.handle)).mapDefined(t=>JSON.parse(t))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new h(o().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new h(o().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}getImportProgress(){return new h(o().getImportProgress(this.handle))}getLastLogs(t){return new h(o().getLastLogs(this.handle,t))}getProgressLog(t){return new h(o().getProgressLog(this.handle,t))}getLogHandle(){return new h(o().getLogHandle(this.handle))}allFieldsResolved(t="Input"){switch(t){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(t,n){const{fieldType:r,requireLocked:i,skipUnresolved:s}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},u=t;if(i&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let d=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(l=>[l,this.resolve({field:l,assertFieldType:r})]);return s&&(d=d.filter(l=>l[1]!==void 0)),d.map(([l,m])=>u(l,m))}}const x="staging",T="main";function j(e){return typeof e=="object"&&e!==null&&"__awaited_futures__"in e}function P(e,t,n){if(t.has(n))return;if(t.add(n),typeof n==="object")if(j(n))n.__awaited_futures__.forEach(i=>e.add(i));else if(Array.isArray(n))for(const i of n)P(e,t,i);else for(const[,i]of Object.entries(n))i!==n&&P(e,t,i)}function wt(e){const t=new Set;return P(t,new Set,e),t}const Ct=Object.freeze(Object.defineProperty({__proto__:null,MainAccessorName:T,StagingAccessorName:x,getAllFutureAwaits:wt,isFutureAwait:j},Symbol.toStringTag,{value:"Module"}));class E{constructor(){f(this,"ctx",o());f(this,"defaultLabelFn",(t,n)=>{var r;return((r=t.annotations)==null?void 0:r["pl7.app/label"])??"Unlabelled"})}calculateOptions(t){return this.ctx.calculateOptions(t)}getOptions(t,n=this.defaultLabelFn){return this.getSpecs().entries.filter(r=>t(r.obj)).map(r=>({ref:r.ref,label:n(r.obj,r.ref)}))}getDataFromResultPool(){return this.getData()}getData(){const t=this.ctx.getDataFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new y(n.obj.data)}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const t=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:p.mapValueInVOE(n.obj.data,r=>new y(r))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(t){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj:p.mapPObjectData(this.ctx.getDataFromResultPoolByRef(t.blockId,t.name),r=>new y(r))}getSpecByRef(t){var n;return typeof this.ctx.getSpecFromResultPoolByRef>"u"?(n=this.getSpecs().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj:this.ctx.getSpecFromResultPoolByRef(t.blockId,t.name)}findDataWithCompatibleSpec(t){const n=[];t:for(const r of this.getData().entries){if(!p.isPColumnSpec(r.obj.spec))continue;const i=r.obj.spec;if(t.name===i.name&&t.valueType===i.valueType&&t.axesSpec.length===i.axesSpec.length&&D(t.domain,i.domain)){for(let s=0;s<t.axesSpec.length;++s){const u=t.axesSpec[s],a=i.axesSpec[s];if(u.name!==a.name||u.type!==a.type||!D(u.domain,a.domain))continue t}n.push(r.obj)}}return n}}function D(e,t){if(e===void 0)return t===void 0;if(t===void 0)return!0;for(const n in t)if(e[n]!==t[n])return!1;return!0}class _{constructor(){f(this,"ctx");f(this,"args");f(this,"uiState");f(this,"resultPool",new E);this.ctx=o(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):void 0}getNamedAccessor(t){const n=this.ctx.getAccessorHandleByName(t);return n?new y(n):void 0}get prerun(){return this.getNamedAccessor(x)}get precalc(){return this.prerun}get stagingOutput(){return this.precalc}get outputs(){return this.getNamedAccessor(T)}get mainOutput(){return this.outputs}createPFrame(t){return this.ctx.createPFrame(t.map(n=>p.mapPObjectData(n,r=>r.handle)))}createPTable(t){var n;return"columns"in t?n={src:{type:"inner",entries:t.columns.map(r=>({type:"column",column:r}))},filters:t.filters??[],sorting:t.sorting??[]}:n=t,this.ctx.createPTable(p.mapPTableDef(n,r=>p.mapPObjectData(r,i=>i.handle)))}getBlockLabel(t){return this.ctx.getBlockLabel(t)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const M="PColumnData/ResourceMap",B="PColumnData/Partitioned/ResourceMap";function U(e,t,n,r=[],i){if(e===void 0)return!1;switch(e.resourceType.name){case M:{let s=e.getInputsLocked();for(const u of e.listInputFields()){const a=e.resolve({field:u,assertFieldType:"Input"}),d=[...r,...JSON.parse(u)],l=a===void 0?void 0:t(a);l===void 0&&(s=!1),(l!==void 0||i)&&n.push({key:d,value:l})}return s}case B:{let s=e.getInputsLocked();for(const u of e.listInputFields()){const a=e.resolve({field:u,assertFieldType:"Input"});if(a===void 0)s=!1;else{const d=[...r,...JSON.parse(u)],l=U(a,t,n,d,i);s=s&&l}}return s}default:throw new Error(`Unknown resource type: ${e.resourceType.name}`)}}function At(e,t,n=!1){const r=[];return{isComplete:U(e,t,r,[],n),data:r}}const C="1.10.0";function J(e){return e.__renderLambda===!0}function F(e){if(e!==void 0)return J(e)?e.handle:e}function b(e){if(e!==void 0)return typeof e=="string"?{__renderLambda:!0,handle:e,retentive:!1}:e}function St(e){if(e.v3!==void 0){const{initialArgs:t,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:u,sections:a,title:d}=e.v3,{code:l}=e;return{initialArgs:t,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:u,sections:a,title:d,code:l}}else if(e.inputsValid!==void 0){const{sdkVersion:t,renderingMode:n,outputs:r,inputsValid:i,sections:s,initialArgs:u,code:a}=e,d=Object.keys(e);if(t===void 0||n===void 0||r===void 0||i===void 0||s===void 0||u===void 0)throw new Error(`Malformed config v2. SDK version ${t}; Fields = ${d.join(", ")}`);return{sdkVersion:t,renderingMode:n,initialArgs:u,outputs:Object.fromEntries(Object.entries(r).map(([l,m])=>[l,b(m)])),inputsValid:b(i),sections:b(s),initialUiState:void 0,code:a}}else if(e.renderingMode!==void 0){const{sdkVersion:t,canRun:n,renderingMode:r,outputs:i,sections:s,initialArgs:u,code:a}=e,d=Object.keys(e);if(r===void 0||i===void 0||n===void 0||s===void 0||u===void 0)throw new Error(`Malformed config v1. SDK version ${t}; Fields = ${d.join(", ")}`);return{sdkVersion:t??"unknown",renderingMode:r,initialArgs:u,outputs:Object.fromEntries(Object.entries(i).map(([l,m])=>[l,b(m)])),inputsValid:b(n),sections:b(s),initialUiState:void 0,code:a}}else{const{sdkVersion:t}=e,n=Object.keys(e);throw new Error(`Config format not supported: SDK = ${t}; Fields = ${n.join(", ")}`)}}class g{constructor(t,n,r,i,s,u,a){this._renderingMode=t,this._initialArgs=n,this._initialUiState=r,this._outputs=i,this._inputsValid=s,this._sections=u,this._title=a}static create(t="Heavy"){return new g(t,void 0,{},{},w(!0),w([]),void 0)}output(t,n,r={}){if(typeof n=="function"){const i=`output#${t}`;return S(i,()=>n(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[t]:{__renderLambda:!0,handle:i,...r}},this._inputsValid,this._sections,this._title)}else return new g(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[t]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(t,n){return this.output(t,n,{retentive:!0})}canRun(t){return this.inputsValid(t)}argsValid(t){return typeof t=="function"?(S("inputsValid",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,t,this._sections,this._title)}inputsValid(t){return this.argsValid(t)}sections(t){return Array.isArray(t)?this.sections(w(t)):typeof t=="function"?(S("sections",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,t,this._title)}title(t){return S("title",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(t){return new g(this._renderingMode,t,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(t){return new g(this._renderingMode,t,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(t){return new g(this._renderingMode,this._initialArgs,t,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const t={v3:{sdkVersion:C,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:C,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:F(this._inputsValid),sections:F(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,F(r)]))};return bt()?L({sdkVersion:C}):{config:t}}}function Ft(e,t,n){var s,u;const r=e.resultPool.getData().entries.map(a=>a.obj).filter(p.isPColumn).filter(a=>a.spec.name==="pl7.app/label"&&a.spec.axesSpec.length===1),i=[];for(const a of t)for(const d of a.spec.axesSpec){const l=p.getAxisId(d);for(const m of r)p.matchAxisId(l,p.getAxisId(m.spec.axesSpec[0]))&&i.push(m)}return e.createPTable({columns:[...t,...i],filters:(s=n==null?void 0:n.pTableParams)==null?void 0:s.filters,sorting:(u=n==null?void 0:n.pTableParams)==null?void 0:u.sorting})}class Ot{constructor(t){this.handle=t}async findColumns(t){return await platforma.pFrameDriver.findColumns(this.handle,t)}async getColumnSpec(t){return await platforma.pFrameDriver.getColumnSpec(this.handle,t)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(t){return await platforma.pFrameDriver.calculateTableData(this.handle,t)}async getUniqueValues(t){return await platforma.pFrameDriver.getUniqueValues(this.handle,t)}}function N(e){return R({__isRef:!0,blockId:A(e,"blockId"),name:A(e,"name")})}function Pt(e){return R({ref:N(A(e,"ref")),label:A(e,"label")})}const Rt={sdkVersion:C};function It(){return L({sdkVersion:C})}function Dt(e){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(e)}exports.Args=W;exports.BlockModel=g;exports.CurrentSdkInfo=Rt;exports.FutureRef=h;exports.It=q;exports.JsRenderInternal=Ct;exports.MainOutputs=z;exports.OutputError=V;exports.PFrameImpl=Ot;exports.RenderCtx=_;exports.ResourceMapResourcePartitionedTypeName=B;exports.ResourceMapResourceTypeName=M;exports.ResultPool=E;exports.StagingOutputs=Q;exports.TreeNodeAccessor=y;exports.UiState=X;exports.and=it;exports.createPlDataTable=Ft;exports.downgradeCfgOrLambda=F;exports.extractConfig=St;exports.flatten=et;exports.fromPlOption=Pt;exports.fromPlRef=N;exports.getBlobContent=lt;exports.getBlobContentAsJson=dt;exports.getBlobContentAsString=ct;exports.getDownloadedBlobContent=pt;exports.getEnvironmentValue=Dt;exports.getFromCfg=v;exports.getImmediate=w;exports.getImportProgress=ht;exports.getJsonField=A;exports.getLastLogs=ft;exports.getLogHandle=yt;exports.getOnDemandBlobContent=gt;exports.getProgressLog=mt;exports.getRawPlatformaInstance=It;exports.getResourceField=ot;exports.getResourceValueAsJson=at;exports.isConfigLambda=J;exports.isEmpty=nt;exports.isolate=K;exports.makeArray=Y;exports.makeObject=R;exports.mapArrayValues=tt;exports.mapRecordValues=Z;exports.mapResourceFields=ut;exports.not=rt;exports.or=st;exports.parseResourceMap=At;exports.readOutput=k;exports.wrapOutputs=G;Object.keys(p).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>p[e]})});
2
2
  //# sourceMappingURL=index.js.map