@rotorsoft/act 1.31.14 → 1.31.16
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/.tsbuildinfo +1 -1
- package/dist/@types/act.d.ts +2 -0
- package/dist/@types/act.d.ts.map +1 -1
- package/dist/@types/builders/event-builder.d.ts +11 -4
- package/dist/@types/builders/event-builder.d.ts.map +1 -1
- package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
- package/dist/@types/internal/date-reviver.d.ts +50 -0
- package/dist/@types/internal/date-reviver.d.ts.map +1 -0
- package/dist/@types/internal/index.d.ts +1 -0
- package/dist/@types/internal/index.d.ts.map +1 -1
- package/dist/@types/internal/sensitive.d.ts +22 -4
- package/dist/@types/internal/sensitive.d.ts.map +1 -1
- package/dist/@types/ports.d.ts +19 -0
- package/dist/@types/ports.d.ts.map +1 -1
- package/dist/@types/scoped.d.ts +17 -5
- package/dist/@types/scoped.d.ts.map +1 -1
- package/dist/{chunk-D5MBFIKL.js → chunk-7IBF4FTQ.js} +16 -11
- package/dist/{chunk-D5MBFIKL.js.map → chunk-7IBF4FTQ.js.map} +1 -1
- package/dist/{chunk-IO2OOCOR.js → chunk-T2AT4N6B.js} +13 -3
- package/dist/{chunk-IO2OOCOR.js.map → chunk-T2AT4N6B.js.map} +1 -1
- package/dist/index.cjs +144 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +121 -75
- package/dist/index.js.map +1 -1
- package/dist/test/index.cjs.map +1 -1
- package/dist/test/index.js +2 -2
- package/dist/types/index.cjs +14 -9
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
config,
|
|
13
13
|
current_reacting,
|
|
14
14
|
dateReviver,
|
|
15
|
+
default_scope,
|
|
15
16
|
dispose,
|
|
16
17
|
disposeAndExit,
|
|
17
18
|
extend,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
sleep,
|
|
25
26
|
store,
|
|
26
27
|
validate
|
|
27
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-T2AT4N6B.js";
|
|
28
29
|
import {
|
|
29
30
|
ActorSchema,
|
|
30
31
|
CausationEventSchema,
|
|
@@ -45,13 +46,13 @@ import {
|
|
|
45
46
|
TargetSchema,
|
|
46
47
|
ValidationError,
|
|
47
48
|
ZodEmpty,
|
|
48
|
-
is_pii,
|
|
49
49
|
make_gate,
|
|
50
50
|
pii_fields,
|
|
51
|
+
pii_schemas,
|
|
51
52
|
pii_split,
|
|
52
53
|
pii_strip,
|
|
53
54
|
sensitive
|
|
54
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-7IBF4FTQ.js";
|
|
55
56
|
|
|
56
57
|
// src/signals.ts
|
|
57
58
|
process.once("SIGINT", async (arg) => {
|
|
@@ -1729,14 +1730,17 @@ var CorrelateCycle = class {
|
|
|
1729
1730
|
upgraded,
|
|
1730
1731
|
correlated_at: void 0
|
|
1731
1732
|
};
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1733
|
+
const seen_in_scan = correlated.has(resolved.target);
|
|
1734
|
+
const held_lane = (seen_in_scan ? entry.lane : recorded?.lane) ?? DEFAULT_LANE;
|
|
1735
|
+
const held_priority = seen_in_scan ? entry.priority : recorded?.priority;
|
|
1736
|
+
const resolved_lane = lane ?? DEFAULT_LANE;
|
|
1737
|
+
if (held_priority === priority && held_lane !== resolved_lane)
|
|
1734
1738
|
report_lane_conflict(
|
|
1735
1739
|
this._reported,
|
|
1736
1740
|
reaction.handler.name,
|
|
1737
1741
|
resolved.target,
|
|
1738
|
-
|
|
1739
|
-
|
|
1742
|
+
held_lane,
|
|
1743
|
+
resolved_lane
|
|
1740
1744
|
);
|
|
1741
1745
|
if (carried.priority > entry.priority) {
|
|
1742
1746
|
entry.priority = carried.priority;
|
|
@@ -1878,18 +1882,83 @@ function close_correlation(correlator, actor) {
|
|
|
1878
1882
|
});
|
|
1879
1883
|
}
|
|
1880
1884
|
|
|
1881
|
-
// src/internal/
|
|
1885
|
+
// src/internal/date-reviver.ts
|
|
1882
1886
|
import { z as z3 } from "zod";
|
|
1883
|
-
var
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
+
var def_of = (schema) => schema._zod?.def ?? schema.def;
|
|
1888
|
+
function variant_schema(schema) {
|
|
1889
|
+
const shape = def_of(schema)?.shape;
|
|
1890
|
+
if (!shape) {
|
|
1891
|
+
const dates = date_reviver_schema(schema);
|
|
1892
|
+
return { schema: dates ?? schema, dated: !!dates };
|
|
1893
|
+
}
|
|
1894
|
+
const next = {};
|
|
1895
|
+
let dated = false;
|
|
1896
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
1897
|
+
const dates = date_reviver_schema(field);
|
|
1898
|
+
if (dates) dated = true;
|
|
1899
|
+
next[key] = (dates ?? field).optional();
|
|
1900
|
+
}
|
|
1901
|
+
return { schema: z3.looseObject(next), dated };
|
|
1902
|
+
}
|
|
1903
|
+
function date_reviver_schema(schema) {
|
|
1904
|
+
const def = def_of(schema);
|
|
1905
|
+
if (!def) return void 0;
|
|
1906
|
+
const inner = () => date_reviver_schema(def.innerType);
|
|
1907
|
+
switch (def.type) {
|
|
1908
|
+
case "date":
|
|
1909
|
+
return z3.coerce.date();
|
|
1910
|
+
case "object": {
|
|
1911
|
+
const shape = def.shape;
|
|
1912
|
+
if (!shape) return void 0;
|
|
1913
|
+
const dated = {};
|
|
1914
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
1915
|
+
const dates = date_reviver_schema(field);
|
|
1916
|
+
if (dates) dated[key] = dates.optional();
|
|
1917
|
+
}
|
|
1918
|
+
return Object.keys(dated).length ? z3.looseObject(dated) : void 0;
|
|
1919
|
+
}
|
|
1920
|
+
case "array": {
|
|
1921
|
+
const element = date_reviver_schema(def.element);
|
|
1922
|
+
return element && z3.array(element);
|
|
1923
|
+
}
|
|
1924
|
+
case "tuple": {
|
|
1925
|
+
const items = def.items.map((i) => date_reviver_schema(i));
|
|
1926
|
+
return items.some(Boolean) ? z3.tuple(items.map((i) => i ?? z3.unknown())) : void 0;
|
|
1927
|
+
}
|
|
1928
|
+
case "record": {
|
|
1929
|
+
const value = date_reviver_schema(def.valueType);
|
|
1930
|
+
return value && z3.record(z3.string(), value);
|
|
1931
|
+
}
|
|
1932
|
+
case "union": {
|
|
1933
|
+
const variants = def.options.map(variant_schema);
|
|
1934
|
+
return variants.some((v) => v.dated) ? z3.union(variants.map((v) => v.schema)) : void 0;
|
|
1935
|
+
}
|
|
1936
|
+
case "nullable":
|
|
1937
|
+
return inner()?.nullable();
|
|
1938
|
+
case "optional":
|
|
1939
|
+
case "nonoptional":
|
|
1940
|
+
case "readonly":
|
|
1941
|
+
case "default":
|
|
1942
|
+
case "prefault":
|
|
1943
|
+
case "catch":
|
|
1944
|
+
return inner();
|
|
1945
|
+
default:
|
|
1946
|
+
return void 0;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
// src/internal/defer-config.ts
|
|
1951
|
+
import { z as z4 } from "zod";
|
|
1952
|
+
var DeferDurationSchema = z4.object({
|
|
1953
|
+
days: z4.number().positive().optional(),
|
|
1954
|
+
hours: z4.number().positive().optional(),
|
|
1955
|
+
minutes: z4.number().positive().optional()
|
|
1887
1956
|
}).strict().refine((d) => d.days != null || d.hours != null || d.minutes != null, {
|
|
1888
1957
|
message: "defer: a duration needs at least one of days, hours, or minutes"
|
|
1889
1958
|
});
|
|
1890
|
-
var DeferWhenSchema =
|
|
1959
|
+
var DeferWhenSchema = z4.object({
|
|
1891
1960
|
after: DeferDurationSchema.optional(),
|
|
1892
|
-
at:
|
|
1961
|
+
at: z4.date().optional()
|
|
1893
1962
|
}).strict().refine((w) => w.after === void 0 !== (w.at === void 0), {
|
|
1894
1963
|
message: "defer: specify exactly one of `after` or `at`"
|
|
1895
1964
|
});
|
|
@@ -3371,6 +3440,8 @@ var Act = class {
|
|
|
3371
3440
|
* per-Act ports (ACT-501). No-op when the Act is unscoped — so the singleton
|
|
3372
3441
|
* path keeps reading fresh `store()`/`cache()` per call, which matters for
|
|
3373
3442
|
* tests that dispose and re-seed mid-suite. */
|
|
3443
|
+
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3444
|
+
_ports;
|
|
3374
3445
|
_scoped;
|
|
3375
3446
|
/**
|
|
3376
3447
|
* Correlation-id generator for originating actions. Bound at
|
|
@@ -3449,7 +3520,8 @@ var Act = class {
|
|
|
3449
3520
|
this._batch_handlers = batch_handlers;
|
|
3450
3521
|
this._lanes = lanes;
|
|
3451
3522
|
validate_only_lanes(options, lanes);
|
|
3452
|
-
this.
|
|
3523
|
+
this._ports = options.scoped ?? default_scope();
|
|
3524
|
+
this._scoped = make_run_scoped(this._ports);
|
|
3453
3525
|
this._correlator = options.correlator ?? default_correlator;
|
|
3454
3526
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3455
3527
|
this._cd = build_drain(this._logger);
|
|
@@ -3478,7 +3550,7 @@ var Act = class {
|
|
|
3478
3550
|
this._audit_deps = this._build_audit_deps();
|
|
3479
3551
|
this._correlate = this._build_correlate(options, classification);
|
|
3480
3552
|
this._settle = this._build_settle(options);
|
|
3481
|
-
this._notify_disposer = this._wire_notify(
|
|
3553
|
+
this._notify_disposer = this._wire_notify(this._ports.store);
|
|
3482
3554
|
register_weak_disposer(new WeakRef(this), (self) => self.shutdown());
|
|
3483
3555
|
}
|
|
3484
3556
|
/**
|
|
@@ -3727,13 +3799,13 @@ var Act = class {
|
|
|
3727
3799
|
this._shutdown_promise = (async () => {
|
|
3728
3800
|
this.stop_correlations();
|
|
3729
3801
|
await this._scoped(() => this._correlate.release_correlation());
|
|
3802
|
+
const disposer = await this._notify_disposer;
|
|
3803
|
+
if (disposer) await disposer();
|
|
3730
3804
|
this.stop_settling();
|
|
3731
3805
|
this._breaker.stop();
|
|
3732
3806
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3733
3807
|
await this._await_inflight(options?.graceMs);
|
|
3734
3808
|
this._emitter.removeAllListeners();
|
|
3735
|
-
const disposer = await this._notify_disposer;
|
|
3736
|
-
if (disposer) await disposer();
|
|
3737
3809
|
})();
|
|
3738
3810
|
}
|
|
3739
3811
|
return this._shutdown_promise;
|
|
@@ -4927,70 +4999,43 @@ function reaction_on(event, events, builder) {
|
|
|
4927
4999
|
}
|
|
4928
5000
|
|
|
4929
5001
|
// src/builders/event-builder.ts
|
|
4930
|
-
import { z as
|
|
4931
|
-
var def_of = (schema) => schema._zod?.def ?? schema.def;
|
|
4932
|
-
function to_read_schema(schema, found) {
|
|
4933
|
-
const def = def_of(schema);
|
|
4934
|
-
if (!def) return schema;
|
|
4935
|
-
switch (def.type) {
|
|
4936
|
-
case "date":
|
|
4937
|
-
found.date = true;
|
|
4938
|
-
return z4.coerce.date();
|
|
4939
|
-
case "object": {
|
|
4940
|
-
const shape = def.shape;
|
|
4941
|
-
if (!shape) return schema;
|
|
4942
|
-
const next = {};
|
|
4943
|
-
for (const [key, inner] of Object.entries(shape))
|
|
4944
|
-
next[key] = to_read_schema(inner, found);
|
|
4945
|
-
return z4.looseObject(next);
|
|
4946
|
-
}
|
|
4947
|
-
case "array":
|
|
4948
|
-
return z4.array(to_read_schema(def.element, found));
|
|
4949
|
-
case "record":
|
|
4950
|
-
return z4.record(
|
|
4951
|
-
z4.string(),
|
|
4952
|
-
to_read_schema(def.valueType, found)
|
|
4953
|
-
);
|
|
4954
|
-
case "union":
|
|
4955
|
-
return z4.union(
|
|
4956
|
-
def.options.map(
|
|
4957
|
-
(o) => to_read_schema(o, found)
|
|
4958
|
-
)
|
|
4959
|
-
);
|
|
4960
|
-
case "optional":
|
|
4961
|
-
return to_read_schema(def.innerType, found).optional();
|
|
4962
|
-
case "nullable":
|
|
4963
|
-
return to_read_schema(def.innerType, found).nullable();
|
|
4964
|
-
default:
|
|
4965
|
-
return schema;
|
|
4966
|
-
}
|
|
4967
|
-
}
|
|
5002
|
+
import { z as z5 } from "zod";
|
|
4968
5003
|
function event_tags(schema) {
|
|
4969
|
-
const
|
|
4970
|
-
const
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
const
|
|
4978
|
-
|
|
5004
|
+
const pii = pii_schemas(schema);
|
|
5005
|
+
const pii_dates = {};
|
|
5006
|
+
for (const [key, field] of Object.entries(pii)) {
|
|
5007
|
+
const dates = date_reviver_schema(field);
|
|
5008
|
+
if (dates) pii_dates[key] = dates.optional();
|
|
5009
|
+
}
|
|
5010
|
+
const data_reviver_schema = date_reviver_schema(schema);
|
|
5011
|
+
const revive = (schema2) => (data) => {
|
|
5012
|
+
const revived = schema2.safeParse(data);
|
|
5013
|
+
return revived.success ? revived.data : data;
|
|
4979
5014
|
};
|
|
4980
|
-
|
|
4981
|
-
const found = { date: false };
|
|
4982
|
-
const read_schema = to_read_schema(schema, found);
|
|
5015
|
+
const dated_pii = Object.keys(pii_dates).length > 0;
|
|
4983
5016
|
return {
|
|
4984
|
-
sensitive:
|
|
4985
|
-
|
|
5017
|
+
sensitive: Object.keys(pii),
|
|
5018
|
+
date_reviver: data_reviver_schema && revive(data_reviver_schema),
|
|
5019
|
+
pii_date_reviver: dated_pii ? revive(z5.looseObject(pii_dates)) : void 0
|
|
4986
5020
|
};
|
|
4987
5021
|
}
|
|
4988
5022
|
function make_event_reader(tags, disclosure, predicate = null) {
|
|
4989
|
-
const { sensitive: sensitive2,
|
|
4990
|
-
if (!
|
|
5023
|
+
const { sensitive: sensitive2, date_reviver, pii_date_reviver } = tags;
|
|
5024
|
+
if (!date_reviver && sensitive2.length === 0) return void 0;
|
|
4991
5025
|
const gate = sensitive2.length === 0 ? IDENTITY_GATE : disclosure === "strip" ? ((event) => pii_strip(event, sensitive2)) : make_gate(sensitive2, predicate);
|
|
4992
|
-
if (!
|
|
4993
|
-
|
|
5026
|
+
if (!date_reviver) return gate;
|
|
5027
|
+
const revive_pii = disclosure === "redact" && predicate ? pii_date_reviver : void 0;
|
|
5028
|
+
return ((event, actor) => {
|
|
5029
|
+
const pii = event.pii;
|
|
5030
|
+
return gate(
|
|
5031
|
+
{
|
|
5032
|
+
...event,
|
|
5033
|
+
data: date_reviver(event.data),
|
|
5034
|
+
...revive_pii && actor && pii != null ? { pii: revive_pii(pii) } : {}
|
|
5035
|
+
},
|
|
5036
|
+
actor
|
|
5037
|
+
);
|
|
5038
|
+
});
|
|
4994
5039
|
}
|
|
4995
5040
|
function build_events(registry, states, lanes, owners) {
|
|
4996
5041
|
const declared = /* @__PURE__ */ new Set([DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
@@ -5776,6 +5821,7 @@ export {
|
|
|
5776
5821
|
cache,
|
|
5777
5822
|
config,
|
|
5778
5823
|
dateReviver,
|
|
5824
|
+
default_scope,
|
|
5779
5825
|
dispose,
|
|
5780
5826
|
disposeAndExit,
|
|
5781
5827
|
extend,
|