@rotorsoft/act 1.31.14 → 1.31.15
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/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 +137 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +114 -71
- 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) => {
|
|
@@ -1878,18 +1879,83 @@ function close_correlation(correlator, actor) {
|
|
|
1878
1879
|
});
|
|
1879
1880
|
}
|
|
1880
1881
|
|
|
1881
|
-
// src/internal/
|
|
1882
|
+
// src/internal/date-reviver.ts
|
|
1882
1883
|
import { z as z3 } from "zod";
|
|
1883
|
-
var
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1884
|
+
var def_of = (schema) => schema._zod?.def ?? schema.def;
|
|
1885
|
+
function variant_schema(schema) {
|
|
1886
|
+
const shape = def_of(schema)?.shape;
|
|
1887
|
+
if (!shape) {
|
|
1888
|
+
const dates = date_reviver_schema(schema);
|
|
1889
|
+
return { schema: dates ?? schema, dated: !!dates };
|
|
1890
|
+
}
|
|
1891
|
+
const next = {};
|
|
1892
|
+
let dated = false;
|
|
1893
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
1894
|
+
const dates = date_reviver_schema(field);
|
|
1895
|
+
if (dates) dated = true;
|
|
1896
|
+
next[key] = (dates ?? field).optional();
|
|
1897
|
+
}
|
|
1898
|
+
return { schema: z3.looseObject(next), dated };
|
|
1899
|
+
}
|
|
1900
|
+
function date_reviver_schema(schema) {
|
|
1901
|
+
const def = def_of(schema);
|
|
1902
|
+
if (!def) return void 0;
|
|
1903
|
+
const inner = () => date_reviver_schema(def.innerType);
|
|
1904
|
+
switch (def.type) {
|
|
1905
|
+
case "date":
|
|
1906
|
+
return z3.coerce.date();
|
|
1907
|
+
case "object": {
|
|
1908
|
+
const shape = def.shape;
|
|
1909
|
+
if (!shape) return void 0;
|
|
1910
|
+
const dated = {};
|
|
1911
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
1912
|
+
const dates = date_reviver_schema(field);
|
|
1913
|
+
if (dates) dated[key] = dates.optional();
|
|
1914
|
+
}
|
|
1915
|
+
return Object.keys(dated).length ? z3.looseObject(dated) : void 0;
|
|
1916
|
+
}
|
|
1917
|
+
case "array": {
|
|
1918
|
+
const element = date_reviver_schema(def.element);
|
|
1919
|
+
return element && z3.array(element);
|
|
1920
|
+
}
|
|
1921
|
+
case "tuple": {
|
|
1922
|
+
const items = def.items.map((i) => date_reviver_schema(i));
|
|
1923
|
+
return items.some(Boolean) ? z3.tuple(items.map((i) => i ?? z3.unknown())) : void 0;
|
|
1924
|
+
}
|
|
1925
|
+
case "record": {
|
|
1926
|
+
const value = date_reviver_schema(def.valueType);
|
|
1927
|
+
return value && z3.record(z3.string(), value);
|
|
1928
|
+
}
|
|
1929
|
+
case "union": {
|
|
1930
|
+
const variants = def.options.map(variant_schema);
|
|
1931
|
+
return variants.some((v) => v.dated) ? z3.union(variants.map((v) => v.schema)) : void 0;
|
|
1932
|
+
}
|
|
1933
|
+
case "nullable":
|
|
1934
|
+
return inner()?.nullable();
|
|
1935
|
+
case "optional":
|
|
1936
|
+
case "nonoptional":
|
|
1937
|
+
case "readonly":
|
|
1938
|
+
case "default":
|
|
1939
|
+
case "prefault":
|
|
1940
|
+
case "catch":
|
|
1941
|
+
return inner();
|
|
1942
|
+
default:
|
|
1943
|
+
return void 0;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// src/internal/defer-config.ts
|
|
1948
|
+
import { z as z4 } from "zod";
|
|
1949
|
+
var DeferDurationSchema = z4.object({
|
|
1950
|
+
days: z4.number().positive().optional(),
|
|
1951
|
+
hours: z4.number().positive().optional(),
|
|
1952
|
+
minutes: z4.number().positive().optional()
|
|
1887
1953
|
}).strict().refine((d) => d.days != null || d.hours != null || d.minutes != null, {
|
|
1888
1954
|
message: "defer: a duration needs at least one of days, hours, or minutes"
|
|
1889
1955
|
});
|
|
1890
|
-
var DeferWhenSchema =
|
|
1956
|
+
var DeferWhenSchema = z4.object({
|
|
1891
1957
|
after: DeferDurationSchema.optional(),
|
|
1892
|
-
at:
|
|
1958
|
+
at: z4.date().optional()
|
|
1893
1959
|
}).strict().refine((w) => w.after === void 0 !== (w.at === void 0), {
|
|
1894
1960
|
message: "defer: specify exactly one of `after` or `at`"
|
|
1895
1961
|
});
|
|
@@ -3371,6 +3437,8 @@ var Act = class {
|
|
|
3371
3437
|
* per-Act ports (ACT-501). No-op when the Act is unscoped — so the singleton
|
|
3372
3438
|
* path keeps reading fresh `store()`/`cache()` per call, which matters for
|
|
3373
3439
|
* tests that dispose and re-seed mid-suite. */
|
|
3440
|
+
/** This Act's ports: its own bag, or the singleton adapters. */
|
|
3441
|
+
_ports;
|
|
3374
3442
|
_scoped;
|
|
3375
3443
|
/**
|
|
3376
3444
|
* Correlation-id generator for originating actions. Bound at
|
|
@@ -3449,7 +3517,8 @@ var Act = class {
|
|
|
3449
3517
|
this._batch_handlers = batch_handlers;
|
|
3450
3518
|
this._lanes = lanes;
|
|
3451
3519
|
validate_only_lanes(options, lanes);
|
|
3452
|
-
this.
|
|
3520
|
+
this._ports = options.scoped ?? default_scope();
|
|
3521
|
+
this._scoped = make_run_scoped(this._ports);
|
|
3453
3522
|
this._correlator = options.correlator ?? default_correlator;
|
|
3454
3523
|
this._es = build_es(this._logger, this._correlator, patch_fn);
|
|
3455
3524
|
this._cd = build_drain(this._logger);
|
|
@@ -3478,7 +3547,7 @@ var Act = class {
|
|
|
3478
3547
|
this._audit_deps = this._build_audit_deps();
|
|
3479
3548
|
this._correlate = this._build_correlate(options, classification);
|
|
3480
3549
|
this._settle = this._build_settle(options);
|
|
3481
|
-
this._notify_disposer = this._wire_notify(
|
|
3550
|
+
this._notify_disposer = this._wire_notify(this._ports.store);
|
|
3482
3551
|
register_weak_disposer(new WeakRef(this), (self) => self.shutdown());
|
|
3483
3552
|
}
|
|
3484
3553
|
/**
|
|
@@ -3727,13 +3796,13 @@ var Act = class {
|
|
|
3727
3796
|
this._shutdown_promise = (async () => {
|
|
3728
3797
|
this.stop_correlations();
|
|
3729
3798
|
await this._scoped(() => this._correlate.release_correlation());
|
|
3799
|
+
const disposer = await this._notify_disposer;
|
|
3800
|
+
if (disposer) await disposer();
|
|
3730
3801
|
this.stop_settling();
|
|
3731
3802
|
this._breaker.stop();
|
|
3732
3803
|
for (const c of this._drain_controllers.values()) c.stop();
|
|
3733
3804
|
await this._await_inflight(options?.graceMs);
|
|
3734
3805
|
this._emitter.removeAllListeners();
|
|
3735
|
-
const disposer = await this._notify_disposer;
|
|
3736
|
-
if (disposer) await disposer();
|
|
3737
3806
|
})();
|
|
3738
3807
|
}
|
|
3739
3808
|
return this._shutdown_promise;
|
|
@@ -4927,70 +4996,43 @@ function reaction_on(event, events, builder) {
|
|
|
4927
4996
|
}
|
|
4928
4997
|
|
|
4929
4998
|
// 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
|
-
}
|
|
4999
|
+
import { z as z5 } from "zod";
|
|
4968
5000
|
function event_tags(schema) {
|
|
4969
|
-
const
|
|
4970
|
-
const
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
const
|
|
4978
|
-
|
|
5001
|
+
const pii = pii_schemas(schema);
|
|
5002
|
+
const pii_dates = {};
|
|
5003
|
+
for (const [key, field] of Object.entries(pii)) {
|
|
5004
|
+
const dates = date_reviver_schema(field);
|
|
5005
|
+
if (dates) pii_dates[key] = dates.optional();
|
|
5006
|
+
}
|
|
5007
|
+
const data_reviver_schema = date_reviver_schema(schema);
|
|
5008
|
+
const revive = (schema2) => (data) => {
|
|
5009
|
+
const revived = schema2.safeParse(data);
|
|
5010
|
+
return revived.success ? revived.data : data;
|
|
4979
5011
|
};
|
|
4980
|
-
|
|
4981
|
-
const found = { date: false };
|
|
4982
|
-
const read_schema = to_read_schema(schema, found);
|
|
5012
|
+
const dated_pii = Object.keys(pii_dates).length > 0;
|
|
4983
5013
|
return {
|
|
4984
|
-
sensitive:
|
|
4985
|
-
|
|
5014
|
+
sensitive: Object.keys(pii),
|
|
5015
|
+
date_reviver: data_reviver_schema && revive(data_reviver_schema),
|
|
5016
|
+
pii_date_reviver: dated_pii ? revive(z5.looseObject(pii_dates)) : void 0
|
|
4986
5017
|
};
|
|
4987
5018
|
}
|
|
4988
5019
|
function make_event_reader(tags, disclosure, predicate = null) {
|
|
4989
|
-
const { sensitive: sensitive2,
|
|
4990
|
-
if (!
|
|
5020
|
+
const { sensitive: sensitive2, date_reviver, pii_date_reviver } = tags;
|
|
5021
|
+
if (!date_reviver && sensitive2.length === 0) return void 0;
|
|
4991
5022
|
const gate = sensitive2.length === 0 ? IDENTITY_GATE : disclosure === "strip" ? ((event) => pii_strip(event, sensitive2)) : make_gate(sensitive2, predicate);
|
|
4992
|
-
if (!
|
|
4993
|
-
|
|
5023
|
+
if (!date_reviver) return gate;
|
|
5024
|
+
const revive_pii = disclosure === "redact" && predicate ? pii_date_reviver : void 0;
|
|
5025
|
+
return ((event, actor) => {
|
|
5026
|
+
const pii = event.pii;
|
|
5027
|
+
return gate(
|
|
5028
|
+
{
|
|
5029
|
+
...event,
|
|
5030
|
+
data: date_reviver(event.data),
|
|
5031
|
+
...revive_pii && actor && pii != null ? { pii: revive_pii(pii) } : {}
|
|
5032
|
+
},
|
|
5033
|
+
actor
|
|
5034
|
+
);
|
|
5035
|
+
});
|
|
4994
5036
|
}
|
|
4995
5037
|
function build_events(registry, states, lanes, owners) {
|
|
4996
5038
|
const declared = /* @__PURE__ */ new Set([DEFAULT_LANE, ...lanes.map((l) => l.name)]);
|
|
@@ -5776,6 +5818,7 @@ export {
|
|
|
5776
5818
|
cache,
|
|
5777
5819
|
config,
|
|
5778
5820
|
dateReviver,
|
|
5821
|
+
default_scope,
|
|
5779
5822
|
dispose,
|
|
5780
5823
|
disposeAndExit,
|
|
5781
5824
|
extend,
|