@milaboratories/milaboratories.monetization-test.model 1.0.1 → 1.0.3

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,5 +1,5 @@
1
1
 
2
- > @milaboratories/milaboratories.monetization-test.model@1.0.1 build /home/runner/work/platforma/platforma/etc/blocks/monetization-test/model
2
+ > @milaboratories/milaboratories.monetization-test.model@1.0.3 build /home/runner/work/platforma/platforma/etc/blocks/monetization-test/model
3
3
  > tsup && vite build && block-tools build-model
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,21 +10,21 @@
10
10
  CLI Cleaning output folder
11
11
  CJS Build start
12
12
  ESM Build start
13
- CJS dist/index.cjs 1.00 KB
14
- CJS dist/index.cjs.map 2.43 KB
13
+ CJS dist/index.cjs 1.13 KB
14
+ CJS dist/index.cjs.map 2.74 KB
15
15
  CJS ⚡️ Build success in 63ms
16
- ESM dist/index.js 999.00 B
17
- ESM dist/index.js.map 2.42 KB
18
- ESM ⚡️ Build success in 63ms
16
+ ESM dist/index.js 1.10 KB
17
+ ESM dist/index.js.map 2.72 KB
18
+ ESM ⚡️ Build success in 62ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 679ms
21
- DTS dist/index.d.cts 796.00 B
22
- DTS dist/index.d.ts 796.00 B
20
+ DTS ⚡️ Build success in 720ms
21
+ DTS dist/index.d.cts 884.00 B
22
+ DTS dist/index.d.ts 884.00 B
23
23
  vite v5.4.11 building for production...
24
24
  transforming...
25
25
  ✓ 4 modules transformed.
26
26
  rendering chunks...
27
27
  computing gzip size...
28
- dist/bundle.js 141.13 kB │ gzip: 25.49 kB │ map: 311.28 kB
29
- dist/bundle.js 151.09 kB │ gzip: 25.96 kB │ map: 312.36 kB
30
- ✓ built in 422ms
28
+ dist/bundle.js 141.27 kB │ gzip: 25.56 kB │ map: 312.43 kB
29
+ dist/bundle.js 151.24 kB │ gzip: 26.03 kB │ map: 313.51 kB
30
+ ✓ built in 410ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @milaboratories/milaboratories.monetization-test.model
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 5828a76: fix mnz-client in edge cases like empty arg list, empty runs
8
+
9
+ ## 1.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 2dee61b: Monetization Component Demo
14
+ - 36e4ae8: Monetization demo part 1
15
+
3
16
  ## 1.0.1
4
17
 
5
18
  ### Patch Changes
package/dist/bundle.js CHANGED
@@ -3798,7 +3798,7 @@
3798
3798
  date: (arg) => ZodDate.create({ ...arg, coerce: true })
3799
3799
  };
3800
3800
  const NEVER = INVALID;
3801
- var z = /* @__PURE__ */ Object.freeze({
3801
+ var z$1 = /* @__PURE__ */ Object.freeze({
3802
3802
  __proto__: null,
3803
3803
  defaultErrorMap: errorMap,
3804
3804
  setErrorMap,
@@ -3943,21 +3943,21 @@
3943
3943
  b$1(t);
3944
3944
  }
3945
3945
  }
3946
- z.object({
3947
- __isRef: z.literal(true).describe("Crucial marker for the block dependency tree reconstruction"),
3948
- blockId: z.string().describe("Upstream block id"),
3949
- name: z.string().describe("Name of the output provided to the upstream block's output context")
3946
+ z$1.object({
3947
+ __isRef: z$1.literal(true).describe("Crucial marker for the block dependency tree reconstruction"),
3948
+ blockId: z$1.string().describe("Upstream block id"),
3949
+ name: z$1.string().describe("Name of the output provided to the upstream block's output context")
3950
3950
  }).describe(
3951
3951
  "Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees."
3952
3952
  ).strict().readonly();
3953
3953
  function i(t) {
3954
3954
  return t.kind === "PColumn";
3955
3955
  }
3956
- function W$1(t) {
3956
+ function W(t) {
3957
3957
  return i(t.spec);
3958
3958
  }
3959
3959
  function dt(t) {
3960
- if (!W$1(t)) throw new Error(`not a PColumn (kind = ${t.spec.kind})`);
3960
+ if (!W(t)) throw new Error(`not a PColumn (kind = ${t.spec.kind})`);
3961
3961
  return t;
3962
3962
  }
3963
3963
  function lt(t, n) {
@@ -3990,14 +3990,14 @@
3990
3990
  return t.ok ? { ok: true, value: n(t.value) } : t;
3991
3991
  }
3992
3992
  const Q = 24;
3993
- z.string().length(Q).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
3994
- var fe = Object.defineProperty;
3995
- var he = (t, e, n) => e in t ? fe(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
3996
- var S = (t, e, n) => he(t, typeof e != "symbol" ? e + "" : e, n);
3997
- function V(t) {
3993
+ z$1.string().length(Q).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
3994
+ var he = Object.defineProperty;
3995
+ var ge = (t, e, n) => e in t ? he(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
3996
+ var S = (t, e, n) => ge(t, typeof e != "symbol" ? e + "" : e, n);
3997
+ function j(t) {
3998
3998
  return { type: "Immediate", value: t };
3999
3999
  }
4000
- function Se() {
4000
+ function Ae() {
4001
4001
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
4002
4002
  }
4003
4003
  function oe(t) {
@@ -4013,24 +4013,24 @@
4013
4013
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
4014
4014
  throw new Error("Not in config rendering context");
4015
4015
  }
4016
- function D(t, e) {
4016
+ function E(t, e) {
4017
4017
  const n = we();
4018
4018
  if (n === void 0) return false;
4019
4019
  if (t in n.callbackRegistry) throw new Error(`Callback with key ${t} already registered.`);
4020
4020
  return n.callbackRegistry[t] = e, true;
4021
4021
  }
4022
- const J = /* @__PURE__ */ new Map();
4023
- function Ae(t, e) {
4022
+ const $ = /* @__PURE__ */ new Map();
4023
+ function Ie(t, e) {
4024
4024
  t in c().callbackRegistry || (c().callbackRegistry[t] = (n) => {
4025
- for (const r of J.get(t))
4025
+ for (const r of $.get(t))
4026
4026
  r(n);
4027
- }, J.set(t, [])), J.get(t).push(e);
4027
+ }, $.set(t, [])), $.get(t).push(e);
4028
4028
  }
4029
4029
  class b {
4030
4030
  constructor(e, n = (r) => r) {
4031
4031
  S(this, "isResolved", false);
4032
4032
  S(this, "resolvedValue");
4033
- this.handle = e, this.postProcess = n, Ae(e, (r) => {
4033
+ this.handle = e, this.postProcess = n, Ie(e, (r) => {
4034
4034
  this.resolvedValue = n(r), this.isResolved = true;
4035
4035
  });
4036
4036
  }
@@ -4047,7 +4047,7 @@
4047
4047
  return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
4048
4048
  }
4049
4049
  }
4050
- function W(t, e) {
4050
+ function H(t, e) {
4051
4051
  return t === void 0 ? void 0 : e(t);
4052
4052
  }
4053
4053
  class v {
@@ -4089,7 +4089,7 @@
4089
4089
  ...this.resolvePath,
4090
4090
  ...n.map((s) => typeof s == "string" ? s : s.field)
4091
4091
  ];
4092
- return W(
4092
+ return H(
4093
4093
  c().resolveWithCommon(this.handle, e, ...n),
4094
4094
  (s) => new v(s, r)
4095
4095
  );
@@ -4111,7 +4111,7 @@
4111
4111
  }
4112
4112
  getError() {
4113
4113
  const e = [...this.resolvePath, "error"];
4114
- return W(
4114
+ return H(
4115
4115
  c().getError(this.handle),
4116
4116
  (n) => new v(n, e)
4117
4117
  );
@@ -4153,7 +4153,7 @@
4153
4153
  getPColumns(e = false, n = "") {
4154
4154
  const r = this.parsePObjectCollection(e, n);
4155
4155
  return r === void 0 ? void 0 : Object.entries(r).map(([, i2]) => {
4156
- if (!W$1(i2)) throw new Error(`not a PColumn (kind = ${i2.spec.kind})`);
4156
+ if (!W(i2)) throw new Error(`not a PColumn (kind = ${i2.spec.kind})`);
4157
4157
  return i2;
4158
4158
  });
4159
4159
  }
@@ -4170,8 +4170,8 @@
4170
4170
  if (r === void 0) return;
4171
4171
  const s = {};
4172
4172
  for (const [i2, o] of Object.entries(r)) {
4173
- const l = [...this.resolvePath, i2];
4174
- s[i2] = lt(o, (a) => new v(a, l));
4173
+ const a = [...this.resolvePath, i2];
4174
+ s[i2] = lt(o, (l) => new v(l, a));
4175
4175
  }
4176
4176
  return s;
4177
4177
  }
@@ -4264,59 +4264,59 @@
4264
4264
  }, o = e;
4265
4265
  if (s && (r === "Input" && !this.getInputsLocked() || r === "Output" && !this.getOutputsLocked()))
4266
4266
  return;
4267
- let a = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
4267
+ let l = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
4268
4268
  (u) => [u, this.resolve({ field: u, assertFieldType: r })]
4269
4269
  );
4270
- return i2 && (a = a.filter((u) => u[1] !== void 0)), a.map(([u, h]) => o(u, h));
4270
+ return i2 && (l = l.filter((u) => u[1] !== void 0)), l.map(([u, h]) => o(u, h));
4271
4271
  }
4272
4272
  }
4273
4273
  const ae = "staging", le = "main";
4274
- const Ie = "pl7.app/label", Re = "pl7.app/trace", Fe = z.object({
4275
- type: z.string(),
4276
- importance: z.number().optional(),
4277
- id: z.string().optional(),
4278
- label: z.string()
4279
- }), xe = z.array(Fe), Te = 1e-3, Oe = "__LABEL__", ee = "__LABEL__@1";
4280
- function ke(t, e, n = {}) {
4274
+ const Fe = "pl7.app/label", Re = "pl7.app/trace", xe = z$1.object({
4275
+ type: z$1.string(),
4276
+ importance: z$1.number().optional(),
4277
+ id: z$1.string().optional(),
4278
+ label: z$1.string()
4279
+ }), Te = z$1.array(xe), Oe = 1e-3, ke = "__LABEL__", ee = "__LABEL__@1";
4280
+ function Le(t, e, n = {}) {
4281
4281
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i2 = t.map((p) => {
4282
4282
  var R, Q2;
4283
- const g = e(p), f2 = (R = g.annotations) == null ? void 0 : R[Ie], A = (Q2 = g.annotations) == null ? void 0 : Q2[Re], y = (A ? xe.safeParse(JSON.parse(A)).data : void 0) ?? [];
4283
+ const g = e(p), f2 = (R = g.annotations) == null ? void 0 : R[Fe], I = (Q2 = g.annotations) == null ? void 0 : Q2[Re], y = (I ? Te.safeParse(JSON.parse(I)).data : void 0) ?? [];
4284
4284
  if (f2) {
4285
- const w = { label: f2, type: Oe, importance: -2 };
4286
- n.addLabelAsSuffix ? y.push(w) : y.splice(0, 0, w);
4285
+ const A = { label: f2, type: ke, importance: -2 };
4286
+ n.addLabelAsSuffix ? y.push(A) : y.splice(0, 0, A);
4287
4287
  }
4288
- const I = [], L = /* @__PURE__ */ new Map();
4289
- for (let w = y.length - 1; w >= 0; --w) {
4290
- const { type: N } = y[w], pe = y[w].importance ?? 0, M = (L.get(N) ?? 0) + 1;
4291
- L.set(N, M);
4292
- const F = `${N}@${M}`;
4293
- s.set(F, (s.get(F) ?? 0) + 1), r.set(
4294
- F,
4288
+ const F = [], D = /* @__PURE__ */ new Map();
4289
+ for (let A = y.length - 1; A >= 0; --A) {
4290
+ const { type: M } = y[A], fe = y[A].importance ?? 0, J = (D.get(M) ?? 0) + 1;
4291
+ D.set(M, J);
4292
+ const x = `${M}@${J}`;
4293
+ s.set(x, (s.get(x) ?? 0) + 1), r.set(
4294
+ x,
4295
4295
  Math.max(
4296
- r.get(F) ?? Number.NEGATIVE_INFINITY,
4297
- pe - (y.length - w) * Te
4296
+ r.get(x) ?? Number.NEGATIVE_INFINITY,
4297
+ fe - (y.length - A) * Oe
4298
4298
  )
4299
- ), I.push({ ...y[w], fullType: F, occurenceIndex: M });
4299
+ ), F.push({ ...y[A], fullType: x, occurenceIndex: J });
4300
4300
  }
4301
- return I.reverse(), {
4301
+ return F.reverse(), {
4302
4302
  value: p,
4303
4303
  spec: g,
4304
4304
  label: f2,
4305
- fullTrace: I
4305
+ fullTrace: F
4306
4306
  };
4307
- }), o = [], l = [], a = [...r];
4308
- a.sort(([, p], [, g]) => g - p);
4309
- for (const [p] of a)
4310
- p.endsWith("@1") || s.get(p) === t.length ? o.push(p) : l.push(p);
4307
+ }), o = [], a = [], l = [...r];
4308
+ l.sort(([, p], [, g]) => g - p);
4309
+ for (const [p] of l)
4310
+ p.endsWith("@1") || s.get(p) === t.length ? o.push(p) : a.push(p);
4311
4311
  const u = (p) => i2.map((g) => {
4312
- const f2 = g.fullTrace.filter((y) => p.has(y.fullType)).map((y) => y.label), A = n.separator ?? " / ";
4312
+ const f2 = g.fullTrace.filter((y) => p.has(y.fullType)).map((y) => y.label), I = n.separator ?? " / ";
4313
4313
  return {
4314
- label: f2.join(A),
4314
+ label: f2.join(I),
4315
4315
  value: g.value
4316
4316
  };
4317
4317
  });
4318
4318
  if (o.length === 0) {
4319
- if (l.length !== 0) throw new Error("Assertion error.");
4319
+ if (a.length !== 0) throw new Error("Assertion error.");
4320
4320
  return u(new Set(ee));
4321
4321
  }
4322
4322
  let h = 0, d = 0;
@@ -4329,9 +4329,9 @@
4329
4329
  if (new Set(g.map((f2) => f2.label)).size === t.length) return g;
4330
4330
  d++, d == o.length && (h++, d = h);
4331
4331
  }
4332
- return u(/* @__PURE__ */ new Set([...o, ...l]));
4332
+ return u(/* @__PURE__ */ new Set([...o, ...a]));
4333
4333
  }
4334
- class Le {
4334
+ class De {
4335
4335
  constructor() {
4336
4336
  S(this, "ctx", c());
4337
4337
  S(this, "defaultLabelFn", (e, n) => {
@@ -4347,7 +4347,7 @@
4347
4347
  }
4348
4348
  getOptions(e, n) {
4349
4349
  const r = this.getSpecs().entries.filter((s) => e(s.obj));
4350
- return typeof n == "object" || typeof n > "u" ? ke(r, (s) => s.obj, n ?? {}).map(({ value: { ref: s }, label: i2 }) => ({
4350
+ return typeof n == "object" || typeof n > "u" ? Le(r, (s) => s.obj, n ?? {}).map(({ value: { ref: s }, label: i2 }) => ({
4351
4351
  ref: s,
4352
4352
  label: i2
4353
4353
  })) : r.map((s) => ({
@@ -4461,10 +4461,10 @@
4461
4461
  if (!i(r.obj.spec))
4462
4462
  continue;
4463
4463
  const s = r.obj.spec;
4464
- if (e.name === s.name && e.valueType === s.valueType && e.axesSpec.length === s.axesSpec.length && q(e.domain, s.domain)) {
4464
+ if (e.name === s.name && e.valueType === s.valueType && e.axesSpec.length === s.axesSpec.length && z(e.domain, s.domain)) {
4465
4465
  for (let i2 = 0; i2 < e.axesSpec.length; ++i2) {
4466
- const o = e.axesSpec[i2], l = s.axesSpec[i2];
4467
- if (o.name !== l.name || o.type !== l.type || !q(o.domain, l.domain))
4466
+ const o = e.axesSpec[i2], a = s.axesSpec[i2];
4467
+ if (o.name !== a.name || o.type !== a.type || !z(o.domain, a.domain))
4468
4468
  continue e;
4469
4469
  }
4470
4470
  n.push(r.obj);
@@ -4473,20 +4473,20 @@
4473
4473
  return n;
4474
4474
  }
4475
4475
  }
4476
- function q(t, e) {
4476
+ function z(t, e) {
4477
4477
  if (t === void 0) return e === void 0;
4478
4478
  if (e === void 0) return true;
4479
4479
  for (const n in e)
4480
4480
  if (t[n] !== e[n]) return false;
4481
4481
  return true;
4482
4482
  }
4483
- class E {
4483
+ class V {
4484
4484
  constructor() {
4485
4485
  S(this, "ctx");
4486
4486
  S(this, "args");
4487
4487
  S(this, "uiState");
4488
4488
  S(this, "_activeArgsCache");
4489
- S(this, "resultPool", new Le());
4489
+ S(this, "resultPool", new De());
4490
4490
  this.ctx = c(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : {};
4491
4491
  }
4492
4492
  /**
@@ -4503,7 +4503,7 @@
4503
4503
  // return this.ctx.featureFlags;
4504
4504
  // }
4505
4505
  getNamedAccessor(e) {
4506
- return W(
4506
+ return H(
4507
4507
  this.ctx.getAccessorHandleByName(e),
4508
4508
  (n) => new v(n, [e])
4509
4509
  );
@@ -4521,9 +4521,9 @@
4521
4521
  findLabels(e) {
4522
4522
  const n = this.resultPool.getData();
4523
4523
  for (const r of n.entries) {
4524
- if (!W$1(r.obj)) continue;
4524
+ if (!W(r.obj)) continue;
4525
4525
  const s = r.obj.spec;
4526
- if (s.name === "pl7.app/label" && s.axesSpec.length === 1 && s.axesSpec[0].name === e.name && s.axesSpec[0].type === e.type && q(e.domain, s.axesSpec[0].domain)) {
4526
+ if (s.name === "pl7.app/label" && s.axesSpec.length === 1 && s.axesSpec[0].name === e.name && s.axesSpec[0].type === e.type && z(e.domain, s.axesSpec[0].domain)) {
4527
4527
  if (r.obj.data.resourceType.name !== "PColumnData/Json")
4528
4528
  throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);
4529
4529
  return Object.fromEntries(
@@ -4569,17 +4569,17 @@
4569
4569
  return this.ctx.getCurrentUnstableMarker();
4570
4570
  }
4571
4571
  }
4572
- const T = "1.22.59";
4573
- function Ee(t) {
4572
+ const T = "1.22.97";
4573
+ function Ve(t) {
4574
4574
  return t.__renderLambda === true;
4575
4575
  }
4576
4576
  function K(t) {
4577
4577
  if (t !== void 0)
4578
- return Ee(t) ? t.handle : t;
4578
+ return Ve(t) ? t.handle : t;
4579
4579
  }
4580
4580
  class _ {
4581
- constructor(e, n, r, s, i2, o, l) {
4582
- this._renderingMode = e, this._initialArgs = n, this._initialUiState = r, this._outputs = s, this._inputsValid = i2, this._sections = o, this._title = l;
4581
+ constructor(e, n, r, s, i2, o, a) {
4582
+ this._renderingMode = e, this._initialArgs = n, this._initialUiState = r, this._outputs = s, this._inputsValid = i2, this._sections = o, this._title = a;
4583
4583
  }
4584
4584
  static create(e = "Heavy") {
4585
4585
  return new _(
@@ -4587,15 +4587,15 @@
4587
4587
  void 0,
4588
4588
  {},
4589
4589
  {},
4590
- V(true),
4591
- V([]),
4590
+ j(true),
4591
+ j([]),
4592
4592
  void 0
4593
4593
  );
4594
4594
  }
4595
4595
  output(e, n, r = {}) {
4596
4596
  if (typeof n == "function") {
4597
4597
  const s = `output#${e}`;
4598
- return D(s, () => n(new E())), new _(
4598
+ return E(s, () => n(new V())), new _(
4599
4599
  this._renderingMode,
4600
4600
  this._initialArgs,
4601
4601
  this._initialUiState,
@@ -4630,7 +4630,7 @@
4630
4630
  return this.output(e, n, { retentive: true });
4631
4631
  }
4632
4632
  argsValid(e) {
4633
- return typeof e == "function" ? (D("inputsValid", () => e(new E())), new _(
4633
+ return typeof e == "function" ? (E("inputsValid", () => e(new V())), new _(
4634
4634
  this._renderingMode,
4635
4635
  this._initialArgs,
4636
4636
  this._initialUiState,
@@ -4652,7 +4652,7 @@
4652
4652
  );
4653
4653
  }
4654
4654
  sections(e) {
4655
- return Array.isArray(e) ? this.sections(V(e)) : typeof e == "function" ? (D("sections", () => e(new E())), new _(
4655
+ return Array.isArray(e) ? this.sections(j(e)) : typeof e == "function" ? (E("sections", () => e(new V())), new _(
4656
4656
  this._renderingMode,
4657
4657
  this._initialArgs,
4658
4658
  this._initialUiState,
@@ -4672,7 +4672,7 @@
4672
4672
  }
4673
4673
  /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
4674
4674
  title(e) {
4675
- return D("title", () => e(new E())), new _(
4675
+ return E("title", () => e(new V())), new _(
4676
4676
  this._renderingMode,
4677
4677
  this._initialArgs,
4678
4678
  this._initialUiState,
@@ -4747,14 +4747,18 @@
4747
4747
  Object.entries(this._outputs).map(([n, r]) => [n, K(r)])
4748
4748
  )
4749
4749
  };
4750
- return Se() ? oe({ sdkVersion: T }) : { config: e };
4750
+ return Ae() ? oe({ sdkVersion: T }) : { config: e };
4751
4751
  }
4752
4752
  }
4753
4753
  const model = _.create().withArgs({
4754
4754
  // a fake product key so our mnz client response with a fake response without changing prod db.
4755
4755
  productKey: "MIFAKEMIFAKEMIFAKE",
4756
- inputHandles: []
4757
- }).output("info", (ctx) => {
4756
+ inputHandles: [],
4757
+ shouldAddRunPerFile: false,
4758
+ __mnzDate: (/* @__PURE__ */ new Date()).toISOString(),
4759
+ // It's OK
4760
+ __mnzCanRun: false
4761
+ }).output("__mnzInfo", (ctx) => {
4758
4762
  var _a, _b;
4759
4763
  return (_b = (_a = ctx.prerun) == null ? void 0 : _a.resolve("info")) == null ? void 0 : _b.getDataAsJson();
4760
4764
  }).output("token", (ctx) => {