@blotout/qinto-cli 0.1.27 → 0.1.28

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.
@@ -20056,11 +20056,16 @@ var MAX_PUSH_BYTES = 16 * 1024;
20056
20056
  var MAX_RESPONSE_BYTES = 1024 * 1024;
20057
20057
  var MAX_RPC_BYTES = 128 * 1024;
20058
20058
  var installSchema = external_exports.object({ id: external_exports.string().min(1).max(64), ord: external_exports.number().int().min(1), label: external_exports.string().max(100) }).strict();
20059
- var emitSchema = external_exports.object({ type: external_exports.literal("track"), occurredAt: external_exports.number().int().nonnegative().safe(), payload: external_exports.record(external_exports.string(), external_exports.unknown()) }).strict();
20060
20059
  var installRuleSchema = external_exports.object({
20061
20060
  mode: external_exports.enum(["except", "only"]),
20062
20061
  installIds: external_exports.array(external_exports.string().min(1).max(64)).max(MAX_APPS_PER_DOMAIN * MAX_INSTALLS_PER_APP)
20063
20062
  }).strict();
20063
+ var emitSchema = external_exports.object({
20064
+ type: external_exports.literal("track"),
20065
+ occurredAt: external_exports.number().int().nonnegative().safe(),
20066
+ payload: external_exports.record(external_exports.string(), external_exports.unknown()),
20067
+ installs: installRuleSchema.optional()
20068
+ }).strict();
20064
20069
  var pushSchema = external_exports.object({ topic: external_exports.string().min(1).max(64), data: external_exports.unknown(), broadcast: external_exports.enum(PUSH_BROADCASTS).optional() }).strict().refine((push) => {
20065
20070
  return new TextEncoder().encode(JSON.stringify(push.data ?? null)).length <= MAX_PUSH_BYTES;
20066
20071
  }, "Push data exceeds the per-message size cap");
@@ -20987,6 +20992,16 @@ var checkEmittedEvent = (event) => {
20987
20992
  }
20988
20993
  return { ...event, occurredAt };
20989
20994
  };
20995
+ var withInstallRule = (emit, installs) => {
20996
+ if (installs === void 0) {
20997
+ return emit;
20998
+ }
20999
+ const parsed = installRuleSchema.safeParse(installs);
21000
+ if (!parsed.success) {
21001
+ throw new Error("an emitted event installs rule must be { mode: except | only, installIds: string[] }");
21002
+ }
21003
+ return { ...emit, installs: parsed.data };
21004
+ };
20990
21005
 
20991
21006
  // src/read-body.ts
20992
21007
  var MAX_ENVELOPE_BYTES = 1024 * 1024;
@@ -21647,6 +21662,41 @@ var asyncContext = (env, subject) => {
21647
21662
  };
21648
21663
  };
21649
21664
 
21665
+ // src/currency.ts
21666
+ var rateBetween = (rates, from, to) => {
21667
+ const source = from.trim().toUpperCase();
21668
+ const target = to.trim().toUpperCase();
21669
+ if (!Object.hasOwn(rates, source) || !Object.hasOwn(rates, target)) {
21670
+ return null;
21671
+ }
21672
+ return rates[source] / rates[target];
21673
+ };
21674
+ var buildCurrency = (env) => {
21675
+ let snapshot;
21676
+ const load = () => {
21677
+ snapshot ??= brokerCurrencyRates(env).catch((error61) => {
21678
+ snapshot = void 0;
21679
+ throw new Error("the platform currency rates are not available", { cause: error61 });
21680
+ });
21681
+ return snapshot;
21682
+ };
21683
+ return {
21684
+ convert: async (amount, from, to) => {
21685
+ const rate = rateBetween((await load()).rates, from, to);
21686
+ return rate === null ? null : amount * rate;
21687
+ },
21688
+ rate: async (from, to) => {
21689
+ return rateBetween((await load()).rates, from, to);
21690
+ },
21691
+ list: async () => {
21692
+ return Object.keys((await load()).rates).sort();
21693
+ },
21694
+ updatedAt: async () => {
21695
+ return new Date((await load()).fetchedAt);
21696
+ }
21697
+ };
21698
+ };
21699
+
21650
21700
  // src/workflow.ts
21651
21701
  var stampParams = (stamp, payload) => {
21652
21702
  return { q: stamp, payload };
@@ -21702,6 +21752,7 @@ var buildWorkflowContext = (env, stamp) => {
21702
21752
  userId: stamp.anonId,
21703
21753
  observability: buildObservability(stamp.ord),
21704
21754
  identity: buildIdentity(env),
21755
+ currency: buildCurrency(env),
21705
21756
  context: asyncContext(env, (what) => {
21706
21757
  return requireSubject(stamp.anonId, what);
21707
21758
  }),
@@ -21787,9 +21838,9 @@ var buildContext = ({
21787
21838
  geo: envelope.geo,
21788
21839
  // Collect one entry past the per-install cap: the platform rejects an over-limit group whole,
21789
21840
  // and the extra entry keeps it visibly over while bounding memory.
21790
- emit: (event) => {
21841
+ emit: (event, options) => {
21791
21842
  requireSubject(subject, "emit");
21792
- const checked = checkEmittedEvent(event);
21843
+ const checked = withInstallRule(checkEmittedEvent(event), options?.installs);
21793
21844
  if (emits.length <= MAX_EMITS_PER_INSTALL) {
21794
21845
  emits.push(checked);
21795
21846
  }
@@ -21837,40 +21888,6 @@ var buildContext = ({
21837
21888
  };
21838
21889
  };
21839
21890
 
21840
- // src/currency.ts
21841
- var rateBetween = (rates, from, to) => {
21842
- const source = from.trim().toUpperCase();
21843
- const target = to.trim().toUpperCase();
21844
- if (!Object.hasOwn(rates, source) || !Object.hasOwn(rates, target)) {
21845
- return null;
21846
- }
21847
- return rates[source] / rates[target];
21848
- };
21849
- var buildCurrency = (env) => {
21850
- let snapshot;
21851
- const load = () => {
21852
- snapshot ??= brokerCurrencyRates(env).catch((error61) => {
21853
- throw new Error("the platform currency rates are not available", { cause: error61 });
21854
- });
21855
- return snapshot;
21856
- };
21857
- return {
21858
- convert: async (amount, from, to) => {
21859
- const rate = rateBetween((await load()).rates, from, to);
21860
- return rate === null ? null : amount * rate;
21861
- },
21862
- rate: async (from, to) => {
21863
- return rateBetween((await load()).rates, from, to);
21864
- },
21865
- list: async () => {
21866
- return Object.keys((await load()).rates).sort();
21867
- },
21868
- updatedAt: async () => {
21869
- return new Date((await load()).fetchedAt);
21870
- }
21871
- };
21872
- };
21873
-
21874
21891
  // src/install-span.ts
21875
21892
  var installSpan = (install, run) => {
21876
21893
  return traced(