@rotorsoft/act 1.23.7 → 1.23.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  sleep,
21
21
  store,
22
22
  validate
23
- } from "./chunk-C7H3GARW.js";
23
+ } from "./chunk-T722JHPU.js";
24
24
  import {
25
25
  ActorSchema,
26
26
  CausationEventSchema,
@@ -29,6 +29,7 @@ import {
29
29
  Environments,
30
30
  Errors,
31
31
  EventMetaSchema,
32
+ IDENTITY_GATE,
32
33
  InvariantError,
33
34
  LogLevels,
34
35
  NonRetryableError,
@@ -40,12 +41,12 @@ import {
40
41
  TargetSchema,
41
42
  ValidationError,
42
43
  ZodEmpty,
44
+ make_gate,
43
45
  pii_fields,
44
- pii_gate,
45
46
  pii_split,
46
47
  pii_strip,
47
48
  sensitive
48
- } from "./chunk-LDWS6I2C.js";
49
+ } from "./chunk-RLM4M5UV.js";
49
50
 
50
51
  // src/signals.ts
51
52
  process.once("SIGINT", async (arg) => {
@@ -2425,9 +2426,10 @@ async function run_drain_cycle(ops, registry, batch_handlers, handle, handle_bat
2425
2426
  })
2426
2427
  );
2427
2428
  const acked = await ops.ack(
2428
- handled.flatMap(
2429
- (h) => h.defer !== void 0 ? { ...h.lease, due: h.defer, retry: -1 } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : h.next_attempt_at !== void 0 ? { ...h.lease, due: h.next_attempt_at } : []
2430
- )
2429
+ handled.flatMap((h, i) => {
2430
+ const advance = h.handled > 0 ? h.acked_at : leased[i].at;
2431
+ return h.defer !== void 0 ? { ...h.lease, at: advance, due: h.defer, retry: -1 } : h.next_attempt_at !== void 0 ? { ...h.lease, at: advance, due: h.next_attempt_at } : h.handled > 0 || !h.error ? { ...h.lease, at: h.acked_at } : [];
2432
+ })
2431
2433
  );
2432
2434
  const blocked = await ops.block(
2433
2435
  handled.filter(({ block: block2 }) => block2).map(({ lease, error }) => ({ ...lease, error }))
@@ -3502,9 +3504,10 @@ var Act = class {
3502
3504
  let first;
3503
3505
  let last;
3504
3506
  const count = await store().query((e) => {
3505
- if (!first) first = e;
3506
- last = e;
3507
- callback?.(e);
3507
+ const gated = this.registry.query_gate(e.name)(e);
3508
+ if (!first) first = gated;
3509
+ last = gated;
3510
+ callback?.(gated);
3508
3511
  }, query);
3509
3512
  return { first, last, count };
3510
3513
  });
@@ -3538,7 +3541,10 @@ var Act = class {
3538
3541
  async query_array(query) {
3539
3542
  return this._scoped(async () => {
3540
3543
  const events = [];
3541
- await store().query((e) => events.push(e), query);
3544
+ await store().query(
3545
+ (e) => events.push(this.registry.query_gate(e.name)(e)),
3546
+ query
3547
+ );
3542
3548
  return events;
3543
3549
  });
3544
3550
  }
@@ -4205,6 +4211,7 @@ function validate_lane_references(registry, lanes) {
4205
4211
  function act() {
4206
4212
  const states = /* @__PURE__ */ new Map();
4207
4213
  const _sf = /* @__PURE__ */ new Map();
4214
+ const _qg = /* @__PURE__ */ new Map();
4208
4215
  const _dp = /* @__PURE__ */ new Map();
4209
4216
  const _de = /* @__PURE__ */ new Map();
4210
4217
  const _ac = /* @__PURE__ */ new Map();
@@ -4214,6 +4221,7 @@ function act() {
4214
4221
  actions: {},
4215
4222
  events: {},
4216
4223
  sensitive_fields: (event_name) => _sf.get(event_name) ?? [],
4224
+ query_gate: (event_name) => _qg.get(event_name) ?? IDENTITY_GATE,
4217
4225
  disclosure_predicate: (state_name) => _dp.get(state_name) ?? null,
4218
4226
  deprecated_events: (state_name) => _de.get(state_name) ?? EMPTY_DEPRECATED,
4219
4227
  autoclose_policy: (state_name) => _ac.get(state_name) ?? null,
@@ -4332,6 +4340,7 @@ function act() {
4332
4340
  const fields = pii_fields(reg.schema);
4333
4341
  if (fields.length === 0) continue;
4334
4342
  _sf.set(event_name, fields);
4343
+ _qg.set(event_name, make_gate(fields, null));
4335
4344
  for (const [name, reaction] of reg.reactions) {
4336
4345
  const inner = reaction.handler;
4337
4346
  const wrapped = (event, stream, app) => inner(pii_strip(event, fields), stream, app);
@@ -4358,10 +4367,12 @@ function act() {
4358
4367
  }
4359
4368
  const disclose = state2.disclose ?? null;
4360
4369
  state2.pii_aware = true;
4361
- state2.view = (event, actor) => pii_gate(
4370
+ const view_gates = /* @__PURE__ */ new Map();
4371
+ for (const [event_name, fields] of fields_by_event) {
4372
+ view_gates.set(event_name, make_gate(fields, disclose));
4373
+ }
4374
+ state2.view = (event, actor) => (view_gates.get(event.name) ?? IDENTITY_GATE)(
4362
4375
  event,
4363
- fields_by_event.get(event.name) ?? [],
4364
- disclose,
4365
4376
  actor
4366
4377
  );
4367
4378
  state2.message = (validated) => {