@milaboratories/milaboratories.monetization-test.model 1.0.40 → 1.0.42

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.
@@ -1,16 +1,16 @@
1
1
   WARN  Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @milaboratories/milaboratories.monetization-test.model@1.0.40 build /home/runner/_work/platforma/platforma/etc/blocks/monetization-test/model
3
+ > @milaboratories/milaboratories.monetization-test.model@1.0.42 build /home/runner/_work/platforma/platforma/etc/blocks/monetization-test/model
4
4
  > ts-builder build --target block-model && block-tools build-model
5
5
 
6
6
  Building block-model project...
7
7
  ↳ rollup -c /configs/rollup.block-model.config.js
8
8
  
9
9
  ./src/index.ts → dist, dist...
10
- created dist, dist in 4.1s
10
+ created dist, dist in 3.5s
11
11
  
12
12
  ./src/index.ts → dist...
13
13
  (!) Circular dependency
14
14
  ../../../../sdk/model/dist/components/PFrameForGraphs.js -> ../../../../sdk/model/dist/pframe_utils/columns.js -> ../../../../sdk/model/dist/components/PFrameForGraphs.js
15
- created dist in 5.1s
15
+ created dist in 5.5s
16
16
  Build completed successfully
@@ -1,5 +1,5 @@
1
1
   WARN  Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @milaboratories/milaboratories.monetization-test.model@1.0.40 lint /home/runner/_work/platforma/platforma/etc/blocks/monetization-test/model
3
+ > @milaboratories/milaboratories.monetization-test.model@1.0.42 lint /home/runner/_work/platforma/platforma/etc/blocks/monetization-test/model
4
4
  > eslint .
5
5
 
@@ -1,6 +1,6 @@
1
1
   WARN  Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
2
2
 
3
- > @milaboratories/milaboratories.monetization-test.model@1.0.40 type-check /home/runner/_work/platforma/platforma/etc/blocks/monetization-test/model
3
+ > @milaboratories/milaboratories.monetization-test.model@1.0.42 type-check /home/runner/_work/platforma/platforma/etc/blocks/monetization-test/model
4
4
  > ts-builder types --target block-model
5
5
 
6
6
  ↳ tsc --noEmit --project ./tsconfig.json --customConditions ,
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @milaboratories/milaboratories.monetization-test.model
2
2
 
3
+ ## 1.0.42
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [fc75a16]
8
+ - @platforma-sdk/model@1.50.0
9
+
10
+ ## 1.0.41
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [88f33fa]
15
+ - @platforma-sdk/model@1.49.0
16
+
3
17
  ## 1.0.40
4
18
 
5
19
  ### Patch Changes
package/dist/bundle.js CHANGED
@@ -7358,7 +7358,7 @@
7358
7358
  }
7359
7359
  }
7360
7360
 
7361
- var version = "1.48.14";
7361
+ var version = "1.50.0";
7362
7362
 
7363
7363
  const PlatformaSDKVersion = version;
7364
7364
 
@@ -7378,67 +7378,82 @@
7378
7378
  * to call {@link done()} at the end of configuration. Value returned by this builder must be
7379
7379
  * exported as constant with name "platforma" from the "config" module. */
7380
7380
  class BlockModel {
7381
- _renderingMode;
7382
- _initialArgs;
7383
- _initialUiState;
7384
- _outputs;
7385
- _inputsValid;
7386
- _sections;
7387
- _title;
7388
- _enrichmentTargets;
7389
- _featureFlags;
7390
- constructor(_renderingMode, _initialArgs, _initialUiState, _outputs, _inputsValid, _sections, _title, _enrichmentTargets, _featureFlags) {
7391
- this._renderingMode = _renderingMode;
7392
- this._initialArgs = _initialArgs;
7393
- this._initialUiState = _initialUiState;
7394
- this._outputs = _outputs;
7395
- this._inputsValid = _inputsValid;
7396
- this._sections = _sections;
7397
- this._title = _title;
7398
- this._enrichmentTargets = _enrichmentTargets;
7399
- this._featureFlags = _featureFlags;
7400
- }
7401
- static INITIAL_BLOCK_FEATURE_FLAGS = {
7402
- supportsLazyState: true,
7403
- requiresUIAPIVersion: 1,
7404
- requiresModelAPIVersion: 1,
7405
- };
7381
+ config;
7382
+ constructor(config) {
7383
+ this.config = config;
7384
+ }
7385
+ static get INITIAL_BLOCK_FEATURE_FLAGS() {
7386
+ return {
7387
+ supportsLazyState: true,
7388
+ requiresUIAPIVersion: 1,
7389
+ requiresModelAPIVersion: 1,
7390
+ };
7391
+ }
7406
7392
  static create(renderingMode = 'Heavy') {
7407
- return new BlockModel(renderingMode, undefined, {}, {}, getImmediate(true), getImmediate([]), undefined, undefined, { ...BlockModel.INITIAL_BLOCK_FEATURE_FLAGS });
7393
+ return new BlockModel({
7394
+ renderingMode,
7395
+ initialUiState: {},
7396
+ outputs: {},
7397
+ inputsValid: getImmediate(true),
7398
+ sections: getImmediate([]),
7399
+ featureFlags: BlockModel.INITIAL_BLOCK_FEATURE_FLAGS,
7400
+ });
7408
7401
  }
7409
7402
  output(key, cfgOrRf, flags = {}) {
7410
7403
  if (typeof cfgOrRf === 'function') {
7411
7404
  const handle = `output#${key}`;
7412
7405
  tryRegisterCallback(handle, () => cfgOrRf(new RenderCtx()));
7413
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
7414
- ...this._outputs,
7415
- [key]: {
7416
- __renderLambda: true,
7417
- handle,
7418
- ...flags,
7406
+ return new BlockModel({
7407
+ ...this.config,
7408
+ outputs: {
7409
+ ...this.config.outputs,
7410
+ [key]: {
7411
+ __renderLambda: true,
7412
+ handle,
7413
+ ...flags,
7414
+ },
7419
7415
  },
7420
- }, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7416
+ });
7417
+ }
7418
+ else {
7419
+ return new BlockModel({
7420
+ ...this.config,
7421
+ outputs: {
7422
+ ...this.config.outputs,
7423
+ [key]: cfgOrRf,
7424
+ },
7425
+ });
7421
7426
  }
7422
- else
7423
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, {
7424
- ...this._outputs,
7425
- [key]: cfgOrRf,
7426
- }, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7427
7427
  }
7428
7428
  /** Shortcut for {@link output} with retentive flag set to true. */
7429
7429
  retentiveOutput(key, rf) {
7430
7430
  return this.output(key, rf, { retentive: true });
7431
7431
  }
7432
+ /** Shortcut for {@link output} with withStatus flag set to true. */
7433
+ outputWithStatus(key, rf) {
7434
+ return this.output(key, rf, { withStatus: true });
7435
+ }
7436
+ /** Shortcut for {@link output} with retentive and withStatus flags set to true. */
7437
+ retentiveOutputWithStatus(key, rf) {
7438
+ return this.output(key, rf, { retentive: true, withStatus: true });
7439
+ }
7432
7440
  argsValid(cfgOrRf) {
7433
7441
  if (typeof cfgOrRf === 'function') {
7434
7442
  tryRegisterCallback('inputsValid', () => cfgOrRf(new RenderCtx()));
7435
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, {
7436
- __renderLambda: true,
7437
- handle: 'inputsValid',
7438
- }, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7443
+ return new BlockModel({
7444
+ ...this.config,
7445
+ inputsValid: {
7446
+ __renderLambda: true,
7447
+ handle: 'inputsValid',
7448
+ },
7449
+ });
7450
+ }
7451
+ else {
7452
+ return new BlockModel({
7453
+ ...this.config,
7454
+ inputsValid: cfgOrRf,
7455
+ });
7439
7456
  }
7440
- else
7441
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, cfgOrRf, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7442
7457
  }
7443
7458
  sections(arrOrCfgOrRf) {
7444
7459
  if (Array.isArray(arrOrCfgOrRf)) {
@@ -7446,34 +7461,82 @@
7446
7461
  }
7447
7462
  else if (typeof arrOrCfgOrRf === 'function') {
7448
7463
  tryRegisterCallback('sections', () => arrOrCfgOrRf(new RenderCtx()));
7449
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, { __renderLambda: true, handle: 'sections' }, this._title, this._enrichmentTargets, this._featureFlags);
7464
+ return new BlockModel({
7465
+ ...this.config,
7466
+ sections: {
7467
+ __renderLambda: true,
7468
+ handle: 'sections',
7469
+ },
7470
+ });
7471
+ }
7472
+ else {
7473
+ return new BlockModel({
7474
+ ...this.config,
7475
+ sections: arrOrCfgOrRf,
7476
+ });
7450
7477
  }
7451
- else
7452
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, arrOrCfgOrRf, this._title, this._enrichmentTargets, this._featureFlags);
7453
7478
  }
7454
7479
  /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
7455
7480
  title(rf) {
7456
7481
  tryRegisterCallback('title', () => rf(new RenderCtx()));
7457
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, { __renderLambda: true, handle: 'title' }, this._enrichmentTargets, this._featureFlags);
7482
+ return new BlockModel({
7483
+ ...this.config,
7484
+ title: {
7485
+ __renderLambda: true,
7486
+ handle: 'title',
7487
+ },
7488
+ });
7489
+ }
7490
+ subtitle(rf) {
7491
+ tryRegisterCallback('subtitle', () => rf(new RenderCtx()));
7492
+ return new BlockModel({
7493
+ ...this.config,
7494
+ subtitle: {
7495
+ __renderLambda: true,
7496
+ handle: 'subtitle',
7497
+ },
7498
+ });
7499
+ }
7500
+ tags(rf) {
7501
+ tryRegisterCallback('tags', () => rf(new RenderCtx()));
7502
+ return new BlockModel({
7503
+ ...this.config,
7504
+ tags: {
7505
+ __renderLambda: true,
7506
+ handle: 'tags',
7507
+ },
7508
+ });
7458
7509
  }
7459
7510
  /**
7460
7511
  * Sets initial args for the block, this value must be specified.
7461
7512
  * @deprecated use {@link withArgs}
7462
7513
  * */
7463
7514
  initialArgs(value) {
7464
- return new BlockModel(this._renderingMode, value, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7515
+ return this.withArgs(value);
7465
7516
  }
7466
7517
  /** Sets initial args for the block, this value must be specified. */
7467
- withArgs(initialValue) {
7468
- return new BlockModel(this._renderingMode, initialValue, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7518
+ withArgs(initialArgs) {
7519
+ return new BlockModel({
7520
+ ...this.config,
7521
+ initialArgs,
7522
+ });
7469
7523
  }
7470
7524
  /** Defines type and sets initial value for block UiState. */
7471
- withUiState(initialValue) {
7472
- return new BlockModel(this._renderingMode, this._initialArgs, initialValue, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, this._featureFlags);
7525
+ withUiState(initialUiState) {
7526
+ return new BlockModel({
7527
+ ...this.config,
7528
+ initialUiState,
7529
+ });
7473
7530
  }
7474
7531
  /** Sets or overrides feature flags for the block. */
7475
7532
  withFeatureFlags(flags) {
7476
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, this._enrichmentTargets, { ...this._featureFlags, ...flags });
7533
+ return new BlockModel({
7534
+ ...this.config,
7535
+ featureFlags: {
7536
+ ...this.config.featureFlags,
7537
+ ...flags,
7538
+ },
7539
+ });
7477
7540
  }
7478
7541
  /**
7479
7542
  * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
@@ -7481,49 +7544,64 @@
7481
7544
  */
7482
7545
  enriches(lambda) {
7483
7546
  tryRegisterCallback('enrichmentTargets', lambda);
7484
- return new BlockModel(this._renderingMode, this._initialArgs, this._initialUiState, this._outputs, this._inputsValid, this._sections, this._title, { __renderLambda: true, handle: 'enrichmentTargets' }, this._featureFlags);
7547
+ return new BlockModel({
7548
+ ...this.config,
7549
+ enrichmentTargets: {
7550
+ __renderLambda: true,
7551
+ handle: 'enrichmentTargets',
7552
+ },
7553
+ });
7485
7554
  }
7486
7555
  /** Renders all provided block settings into a pre-configured platforma API
7487
7556
  * instance, that can be used in frontend to interact with block state, and
7488
7557
  * other features provided by the platforma to the block. */
7489
- done(apiVersion) {
7490
- const requiresUIAPIVersion = apiVersion ?? 1;
7558
+ done(apiVersion = 1) {
7491
7559
  return this.withFeatureFlags({
7492
- ...this._featureFlags,
7493
- requiresUIAPIVersion,
7494
- })._done(requiresUIAPIVersion);
7560
+ ...this.config.featureFlags,
7561
+ requiresUIAPIVersion: apiVersion,
7562
+ }).#done();
7495
7563
  }
7496
- _done(apiVersion) {
7497
- if (this._initialArgs === undefined)
7564
+ #done() {
7565
+ if (this.config.initialArgs === undefined)
7498
7566
  throw new Error('Initial arguments not set.');
7499
7567
  const config = {
7500
7568
  v3: {
7501
7569
  sdkVersion: PlatformaSDKVersion,
7502
- renderingMode: this._renderingMode,
7503
- initialArgs: this._initialArgs,
7504
- initialUiState: this._initialUiState,
7505
- inputsValid: this._inputsValid,
7506
- sections: this._sections,
7507
- title: this._title,
7508
- outputs: this._outputs,
7509
- enrichmentTargets: this._enrichmentTargets,
7510
- featureFlags: this._featureFlags,
7570
+ renderingMode: this.config.renderingMode,
7571
+ initialArgs: this.config.initialArgs,
7572
+ initialUiState: this.config.initialUiState,
7573
+ inputsValid: this.config.inputsValid,
7574
+ sections: this.config.sections,
7575
+ title: this.config.title,
7576
+ subtitle: this.config.subtitle,
7577
+ tags: this.config.tags,
7578
+ outputs: this.config.outputs,
7579
+ enrichmentTargets: this.config.enrichmentTargets,
7580
+ featureFlags: this.config.featureFlags,
7511
7581
  },
7512
7582
  // fields below are added to allow previous desktop versions read generated configs
7513
7583
  sdkVersion: PlatformaSDKVersion,
7514
- renderingMode: this._renderingMode,
7515
- initialArgs: this._initialArgs,
7516
- inputsValid: downgradeCfgOrLambda(this._inputsValid),
7517
- sections: downgradeCfgOrLambda(this._sections),
7518
- outputs: Object.fromEntries(Object.entries(this._outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)])),
7584
+ renderingMode: this.config.renderingMode,
7585
+ initialArgs: this.config.initialArgs,
7586
+ inputsValid: downgradeCfgOrLambda(this.config.inputsValid),
7587
+ sections: downgradeCfgOrLambda(this.config.sections),
7588
+ outputs: Object.fromEntries(Object.entries(this.config.outputs).map(([key, value]) => [key, downgradeCfgOrLambda(value)])),
7519
7589
  };
7520
- globalThis.platformaApiVersion = apiVersion;
7590
+ globalThis.platformaApiVersion = this.config.featureFlags.requiresUIAPIVersion;
7521
7591
  if (!isInUI())
7522
7592
  // we are in the configuration rendering routine, not in actual UI
7523
7593
  return { config };
7524
7594
  // normal operation inside the UI
7525
7595
  else
7526
- return getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion });
7596
+ return {
7597
+ ...getPlatformaInstance({ sdkVersion: PlatformaSDKVersion, apiVersion: platformaApiVersion }),
7598
+ blockModelInfo: {
7599
+ outputs: Object.fromEntries(Object.entries(this.config.outputs)
7600
+ .map(([key, value]) => [key, {
7601
+ withStatus: Boolean(isConfigLambda(value) && value.withStatus),
7602
+ }])),
7603
+ },
7604
+ };
7527
7605
  }
7528
7606
  }
7529
7607