@fabricorg/platform 0.1.1 → 0.2.0
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/actions/index.cjs +48 -0
- package/dist/actions/index.cjs.map +1 -0
- package/dist/actions/index.d.cts +116 -0
- package/dist/actions/index.js +1 -57
- package/dist/actions/index.js.map +1 -1
- package/dist/adapters/index.cjs +28 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +83 -0
- package/dist/adapters/index.js +1 -99
- package/dist/adapters/index.js.map +1 -1
- package/dist/chunk-3A6FU3KV.js +67 -0
- package/dist/chunk-3A6FU3KV.js.map +1 -0
- package/dist/chunk-3F6FKQZA.js +89 -0
- package/dist/chunk-3F6FKQZA.js.map +1 -0
- package/dist/chunk-3ZW5USXF.js +101 -0
- package/dist/chunk-3ZW5USXF.js.map +1 -0
- package/dist/chunk-4YQOGV7H.js +55 -0
- package/dist/chunk-4YQOGV7H.js.map +1 -0
- package/dist/chunk-6FMW4NF6.js +59 -0
- package/dist/chunk-6FMW4NF6.js.map +1 -0
- package/dist/chunk-7KJHGAZY.cjs +99 -0
- package/dist/chunk-7KJHGAZY.cjs.map +1 -0
- package/dist/chunk-GB2PSZ33.cjs +74 -0
- package/dist/chunk-GB2PSZ33.cjs.map +1 -0
- package/dist/chunk-I35B576X.js +30 -0
- package/dist/chunk-I35B576X.js.map +1 -0
- package/dist/chunk-IFMZPLM4.js +27 -0
- package/dist/chunk-IFMZPLM4.js.map +1 -0
- package/dist/chunk-JAXDEK5Z.cjs +63 -0
- package/dist/chunk-JAXDEK5Z.cjs.map +1 -0
- package/dist/chunk-JSTGOT6P.js +181 -0
- package/dist/chunk-JSTGOT6P.js.map +1 -0
- package/dist/chunk-KOC4A7A4.js +544 -0
- package/dist/chunk-KOC4A7A4.js.map +1 -0
- package/dist/chunk-KQEBNUZI.cjs +70 -0
- package/dist/chunk-KQEBNUZI.cjs.map +1 -0
- package/dist/chunk-LHCSVEFT.cjs +8 -0
- package/dist/chunk-LHCSVEFT.cjs.map +1 -0
- package/dist/chunk-LYX73U3P.cjs +195 -0
- package/dist/chunk-LYX73U3P.cjs.map +1 -0
- package/dist/chunk-LZSE6QGQ.cjs +60 -0
- package/dist/chunk-LZSE6QGQ.cjs.map +1 -0
- package/dist/chunk-N24NLCZ6.js +6 -0
- package/dist/chunk-N24NLCZ6.js.map +1 -0
- package/dist/chunk-NPVIFZQV.cjs +107 -0
- package/dist/chunk-NPVIFZQV.cjs.map +1 -0
- package/dist/chunk-OZLZHISS.js +3 -0
- package/dist/chunk-OZLZHISS.js.map +1 -0
- package/dist/chunk-PG5LYTUX.cjs +4 -0
- package/dist/chunk-PG5LYTUX.cjs.map +1 -0
- package/dist/chunk-PXMKCAQI.js +187 -0
- package/dist/chunk-PXMKCAQI.js.map +1 -0
- package/dist/chunk-Q3WYIWCN.cjs +183 -0
- package/dist/chunk-Q3WYIWCN.cjs.map +1 -0
- package/dist/chunk-QETQGAXJ.cjs +35 -0
- package/dist/chunk-QETQGAXJ.cjs.map +1 -0
- package/dist/chunk-RALMUSOX.js +55 -0
- package/dist/chunk-RALMUSOX.js.map +1 -0
- package/dist/chunk-SDXDHVTV.cjs +555 -0
- package/dist/chunk-SDXDHVTV.cjs.map +1 -0
- package/dist/chunk-YZKUEC2J.cjs +31 -0
- package/dist/chunk-YZKUEC2J.cjs.map +1 -0
- package/dist/displays/index.cjs +24 -0
- package/dist/displays/index.cjs.map +1 -0
- package/dist/displays/index.d.cts +34 -0
- package/dist/displays/index.js +1 -87
- package/dist/displays/index.js.map +1 -1
- package/dist/events/index.cjs +36 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.d.cts +35 -0
- package/dist/events/index.js +1 -53
- package/dist/events/index.js.map +1 -1
- package/dist/evidence/index.cjs +6 -0
- package/dist/evidence/index.cjs.map +1 -0
- package/dist/evidence/index.d.cts +43 -0
- package/dist/evidence/index.js +1 -1
- package/dist/ids/index.cjs +24 -0
- package/dist/ids/index.cjs.map +1 -0
- package/dist/ids/index.d.cts +19 -0
- package/dist/ids/index.js +1 -53
- package/dist/ids/index.js.map +1 -1
- package/dist/index.cjs +268 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.js +13 -1355
- package/dist/index.js.map +1 -1
- package/dist/modules/index.cjs +42 -0
- package/dist/modules/index.cjs.map +1 -0
- package/dist/modules/index.d.cts +73 -0
- package/dist/modules/index.js +7 -373
- package/dist/modules/index.js.map +1 -1
- package/dist/objects/index.cjs +24 -0
- package/dist/objects/index.cjs.map +1 -0
- package/dist/objects/index.d.cts +7 -0
- package/dist/objects/index.js +1 -28
- package/dist/objects/index.js.map +1 -1
- package/dist/policies/index.cjs +48 -0
- package/dist/policies/index.cjs.map +1 -0
- package/dist/policies/index.d.cts +143 -0
- package/dist/policies/index.js +1 -542
- package/dist/policies/index.js.map +1 -1
- package/dist/privacy/index.cjs +12 -0
- package/dist/privacy/index.cjs.map +1 -0
- package/dist/privacy/index.d.cts +77 -0
- package/dist/privacy/index.js +1 -4
- package/dist/privacy/index.js.map +1 -1
- package/dist/projections/index.cjs +12 -0
- package/dist/projections/index.cjs.map +1 -0
- package/dist/projections/index.d.cts +52 -0
- package/dist/projections/index.js +1 -179
- package/dist/projections/index.js.map +1 -1
- package/dist/state-machines/index.cjs +32 -0
- package/dist/state-machines/index.cjs.map +1 -0
- package/dist/state-machines/index.d.cts +60 -0
- package/dist/state-machines/index.js +1 -65
- package/dist/state-machines/index.js.map +1 -1
- package/dist/testing/index.cjs +21 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +19 -0
- package/dist/testing/index.js +2 -56
- package/dist/testing/index.js.map +1 -1
- package/package.json +196 -111
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkNPVIFZQV_cjs = require('./chunk-NPVIFZQV.cjs');
|
|
4
|
+
|
|
5
|
+
// testing/index.ts
|
|
6
|
+
function createFakeActionContext(options = {}) {
|
|
7
|
+
return {
|
|
8
|
+
actionInvocationId: options.actionInvocationId ?? "act_test",
|
|
9
|
+
tenantId: options.tenantId ?? "tenant-test",
|
|
10
|
+
spaceId: options.spaceId ?? "space-test",
|
|
11
|
+
actorId: options.actorId ?? "actor-test",
|
|
12
|
+
actorType: options.actorType ?? "system",
|
|
13
|
+
correlationId: options.correlationId ?? "corr-test",
|
|
14
|
+
causationId: options.causationId,
|
|
15
|
+
db: options.db ?? {},
|
|
16
|
+
services: options.services ?? {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function createInMemoryAdapterRegistry() {
|
|
20
|
+
return new chunkNPVIFZQV_cjs.AdapterRegistry();
|
|
21
|
+
}
|
|
22
|
+
function createDeterministicIdFactory(prefix = "test") {
|
|
23
|
+
let sequence = 0;
|
|
24
|
+
return () => `${prefix}_${String(++sequence).padStart(6, "0")}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.createDeterministicIdFactory = createDeterministicIdFactory;
|
|
28
|
+
exports.createFakeActionContext = createFakeActionContext;
|
|
29
|
+
exports.createInMemoryAdapterRegistry = createInMemoryAdapterRegistry;
|
|
30
|
+
//# sourceMappingURL=chunk-YZKUEC2J.cjs.map
|
|
31
|
+
//# sourceMappingURL=chunk-YZKUEC2J.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../testing/index.ts"],"names":["AdapterRegistry"],"mappings":";;;;;AAeO,SAAS,uBAAA,CACf,OAAA,GAAyC,EAAC,EACrB;AACrB,EAAA,OAAO;AAAA,IACN,kBAAA,EAAoB,QAAQ,kBAAA,IAAsB,UAAA;AAAA,IAClD,QAAA,EAAU,QAAQ,QAAA,IAAY,aAAA;AAAA,IAC9B,OAAA,EAAS,QAAQ,OAAA,IAAW,YAAA;AAAA,IAC5B,OAAA,EAAS,QAAQ,OAAA,IAAW,YAAA;AAAA,IAC5B,SAAA,EAAW,QAAQ,SAAA,IAAa,QAAA;AAAA,IAChC,aAAA,EAAe,QAAQ,aAAA,IAAiB,WAAA;AAAA,IACxC,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,EAAA,EAAI,OAAA,CAAQ,EAAA,IAAO,EAAC;AAAA,IACpB,QAAA,EAAU,OAAA,CAAQ,QAAA,IAAY;AAAC,GAChC;AACD;AAEO,SAAS,6BAAA,GAAiD;AAChE,EAAA,OAAO,IAAIA,iCAAA,EAAgB;AAC5B;AAEO,SAAS,4BAAA,CAA6B,SAAS,MAAA,EAAsB;AAC3E,EAAA,IAAI,QAAA,GAAW,CAAA;AACf,EAAA,OAAO,MAAM,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,MAAA,CAAO,EAAE,QAAQ,CAAA,CAAE,QAAA,CAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA;AAC9D","file":"chunk-YZKUEC2J.cjs","sourcesContent":["import { AdapterRegistry } from \"../adapters\";\nimport type { ActionContext, ActorType } from \"../actions\";\n\nexport interface FakeActionContextOptions<TDb = Record<string, never>> {\n\tactionInvocationId?: string;\n\ttenantId?: string;\n\tspaceId?: string;\n\tactorId?: string;\n\tactorType?: ActorType;\n\tcorrelationId?: string;\n\tcausationId?: string;\n\tdb?: TDb;\n\tservices?: Record<string, unknown>;\n}\n\nexport function createFakeActionContext<TDb = Record<string, never>>(\n\toptions: FakeActionContextOptions<TDb> = {},\n): ActionContext<TDb> {\n\treturn {\n\t\tactionInvocationId: options.actionInvocationId ?? \"act_test\",\n\t\ttenantId: options.tenantId ?? \"tenant-test\",\n\t\tspaceId: options.spaceId ?? \"space-test\",\n\t\tactorId: options.actorId ?? \"actor-test\",\n\t\tactorType: options.actorType ?? \"system\",\n\t\tcorrelationId: options.correlationId ?? \"corr-test\",\n\t\tcausationId: options.causationId,\n\t\tdb: options.db ?? ({} as TDb),\n\t\tservices: options.services ?? {},\n\t};\n}\n\nexport function createInMemoryAdapterRegistry(): AdapterRegistry {\n\treturn new AdapterRegistry();\n}\n\nexport function createDeterministicIdFactory(prefix = \"test\"): () => string {\n\tlet sequence = 0;\n\treturn () => `${prefix}_${String(++sequence).padStart(6, \"0\")}`;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk7KJHGAZY_cjs = require('../chunk-7KJHGAZY.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "denormalizeDisplaySnapshot", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunk7KJHGAZY_cjs.denormalizeDisplaySnapshot; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "registerDisplayRenderer", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunk7KJHGAZY_cjs.registerDisplayRenderer; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "renderEventDisplay", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunk7KJHGAZY_cjs.renderEventDisplay; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "resolveDisplayRenderer", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunk7KJHGAZY_cjs.resolveDisplayRenderer; }
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
24
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface DisplayDescriptor {
|
|
2
|
+
title: string;
|
|
3
|
+
subtitle?: string;
|
|
4
|
+
stateLabel?: string;
|
|
5
|
+
primaryFacts?: Array<{
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
interface CachedDisplayDescriptor extends DisplayDescriptor {
|
|
11
|
+
_cachedDisplay?: {
|
|
12
|
+
source: "event_payload" | "projection_snapshot";
|
|
13
|
+
cursor?: string | null;
|
|
14
|
+
checksum?: string;
|
|
15
|
+
generatedAt?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type DisplayDatabaseClient = any;
|
|
19
|
+
interface DisplayContext<TDb = DisplayDatabaseClient> {
|
|
20
|
+
tenantId: string;
|
|
21
|
+
spaceId: string;
|
|
22
|
+
db: TDb;
|
|
23
|
+
}
|
|
24
|
+
type DisplayRenderer = (payload: unknown, ctx?: DisplayContext) => DisplayDescriptor | Promise<DisplayDescriptor>;
|
|
25
|
+
interface DisplayRendererRegistration {
|
|
26
|
+
eventType: string;
|
|
27
|
+
renderer: DisplayRenderer;
|
|
28
|
+
}
|
|
29
|
+
declare function registerDisplayRenderer(eventType: string, renderer: DisplayRenderer): void;
|
|
30
|
+
declare function resolveDisplayRenderer(eventType: string): DisplayRenderer | undefined;
|
|
31
|
+
declare function denormalizeDisplaySnapshot(payload: unknown): CachedDisplayDescriptor | undefined;
|
|
32
|
+
declare function renderEventDisplay(eventType: string, payload: unknown, ctx?: DisplayContext): Promise<CachedDisplayDescriptor>;
|
|
33
|
+
|
|
34
|
+
export { type CachedDisplayDescriptor, type DisplayContext, type DisplayDatabaseClient, type DisplayDescriptor, type DisplayRenderer, type DisplayRendererRegistration, denormalizeDisplaySnapshot, registerDisplayRenderer, renderEventDisplay, resolveDisplayRenderer };
|
package/dist/displays/index.js
CHANGED
|
@@ -1,89 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// displays/index.ts
|
|
4
|
-
var registry = /* @__PURE__ */ new Map();
|
|
5
|
-
function registerDisplayRenderer(eventType, renderer) {
|
|
6
|
-
registry.set(eventType, renderer);
|
|
7
|
-
}
|
|
8
|
-
function resolveDisplayRenderer(eventType) {
|
|
9
|
-
return registry.get(eventType);
|
|
10
|
-
}
|
|
11
|
-
function denormalizeDisplaySnapshot(payload) {
|
|
12
|
-
if (payload !== null && typeof payload === "object" && "_displaySnapshot" in payload && payload._displaySnapshot !== null && typeof payload._displaySnapshot === "object" && "title" in payload._displaySnapshot) {
|
|
13
|
-
return payload._displaySnapshot;
|
|
14
|
-
}
|
|
15
|
-
if (payload !== null && typeof payload === "object" && "_projectionSnapshot" in payload && payload._projectionSnapshot !== null && typeof payload._projectionSnapshot === "object" && "display" in payload._projectionSnapshot && payload._projectionSnapshot.display !== null && typeof payload._projectionSnapshot.display === "object" && "title" in payload._projectionSnapshot.display) {
|
|
16
|
-
const snapshot = payload._projectionSnapshot;
|
|
17
|
-
return {
|
|
18
|
-
...snapshot.display,
|
|
19
|
-
_cachedDisplay: {
|
|
20
|
-
source: "projection_snapshot",
|
|
21
|
-
cursor: snapshot.eventCursor,
|
|
22
|
-
checksum: snapshot.checksum,
|
|
23
|
-
generatedAt: snapshot.updatedAt
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
async function renderEventDisplay(eventType, payload, ctx) {
|
|
30
|
-
const snapshot = denormalizeDisplaySnapshot(payload);
|
|
31
|
-
if (snapshot) {
|
|
32
|
-
return snapshot;
|
|
33
|
-
}
|
|
34
|
-
const renderer = resolveDisplayRenderer(eventType);
|
|
35
|
-
if (!renderer) {
|
|
36
|
-
return {
|
|
37
|
-
title: eventType,
|
|
38
|
-
subtitle: "No display renderer registered for this event type."
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return await renderer(payload, ctx);
|
|
42
|
-
}
|
|
43
|
-
async function _runInlineTests() {
|
|
44
|
-
const testEventType = "__TestEvent__";
|
|
45
|
-
registerDisplayRenderer(testEventType, (payload) => ({
|
|
46
|
-
title: `Test: ${payload.name}`,
|
|
47
|
-
subtitle: "registered renderer"
|
|
48
|
-
}));
|
|
49
|
-
const renderer = resolveDisplayRenderer(testEventType);
|
|
50
|
-
assert.ok(renderer, "resolveDisplayRenderer should return the registered renderer");
|
|
51
|
-
const result = await renderEventDisplay(testEventType, { name: "Alice" });
|
|
52
|
-
assert.strictEqual(result.title, "Test: Alice");
|
|
53
|
-
assert.strictEqual(result.subtitle, "registered renderer");
|
|
54
|
-
const snapshot = {
|
|
55
|
-
title: "Snapshot Title",
|
|
56
|
-
subtitle: "snapshot subtitle",
|
|
57
|
-
stateLabel: "archived",
|
|
58
|
-
primaryFacts: [{ label: "ID", value: "123" }]
|
|
59
|
-
};
|
|
60
|
-
const snapshotResult = await renderEventDisplay(testEventType, {
|
|
61
|
-
_displaySnapshot: snapshot
|
|
62
|
-
});
|
|
63
|
-
assert.deepStrictEqual(snapshotResult, snapshot);
|
|
64
|
-
const fallback = await renderEventDisplay("__UnknownEvent__", {});
|
|
65
|
-
assert.strictEqual(fallback.title, "__UnknownEvent__");
|
|
66
|
-
assert.strictEqual(fallback.subtitle, "No display renderer registered for this event type.");
|
|
67
|
-
registerDisplayRenderer("__AsyncEvent__", async (_payload, ctx) => {
|
|
68
|
-
return {
|
|
69
|
-
title: `Async: ${ctx?.tenantId ?? "no-ctx"}`
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
const asyncResult = await renderEventDisplay(
|
|
73
|
-
"__AsyncEvent__",
|
|
74
|
-
{},
|
|
75
|
-
{ tenantId: "t-1", spaceId: "s-1", db: {} }
|
|
76
|
-
);
|
|
77
|
-
assert.strictEqual(asyncResult.title, "Async: t-1");
|
|
78
|
-
console.log("\u2705 display engine inline tests passed");
|
|
79
|
-
}
|
|
80
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
81
|
-
_runInlineTests().catch((err) => {
|
|
82
|
-
console.error("\u274C display engine inline tests failed", err);
|
|
83
|
-
process.exit(1);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { denormalizeDisplaySnapshot, registerDisplayRenderer, renderEventDisplay, resolveDisplayRenderer };
|
|
1
|
+
export { denormalizeDisplaySnapshot, registerDisplayRenderer, renderEventDisplay, resolveDisplayRenderer } from '../chunk-3F6FKQZA.js';
|
|
88
2
|
//# sourceMappingURL=index.js.map
|
|
89
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkJAXDEK5Z_cjs = require('../chunk-JAXDEK5Z.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "createEventTypeRegistry", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkJAXDEK5Z_cjs.createEventTypeRegistry; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "getRegisteredEventTypes", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkJAXDEK5Z_cjs.getRegisteredEventTypes; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "getRegisteredSubjectTypes", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkJAXDEK5Z_cjs.getRegisteredSubjectTypes; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "isValidEventType", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkJAXDEK5Z_cjs.isValidEventType; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "isValidSubjectType", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkJAXDEK5Z_cjs.isValidSubjectType; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "registerEventType", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkJAXDEK5Z_cjs.registerEventType; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "registerSubjectType", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkJAXDEK5Z_cjs.registerSubjectType; }
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.cjs.map
|
|
36
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface AssetEventEnvelope<TPayload = unknown> {
|
|
2
|
+
id: string;
|
|
3
|
+
tenantId: string;
|
|
4
|
+
spaceId: string;
|
|
5
|
+
eventType: string;
|
|
6
|
+
eventSchemaVersion: number;
|
|
7
|
+
subjectType: string;
|
|
8
|
+
subjectId: string;
|
|
9
|
+
actorId: string;
|
|
10
|
+
actorType: string;
|
|
11
|
+
actionInvocationId?: string;
|
|
12
|
+
payload: TPayload;
|
|
13
|
+
sequence: number;
|
|
14
|
+
occurredAt: Date;
|
|
15
|
+
recordedAt: Date;
|
|
16
|
+
correlationId: string;
|
|
17
|
+
causationId?: string;
|
|
18
|
+
}
|
|
19
|
+
type AssetEventSubjectType = string;
|
|
20
|
+
type AssetEventType = string;
|
|
21
|
+
type AssetEventActorType = "natural_person" | "agent" | "adapter" | "system" | "service_account" | "external_system" | "integration";
|
|
22
|
+
declare function registerSubjectType(type: string): void;
|
|
23
|
+
declare function isValidSubjectType(type: string): boolean;
|
|
24
|
+
declare function getRegisteredSubjectTypes(): string[];
|
|
25
|
+
declare function registerEventType(type: string): void;
|
|
26
|
+
declare function isValidEventType(type: string): boolean;
|
|
27
|
+
declare function getRegisteredEventTypes(): string[];
|
|
28
|
+
interface EventTypeRegistry {
|
|
29
|
+
register(eventType: string): void;
|
|
30
|
+
has(eventType: string): boolean;
|
|
31
|
+
list(): string[];
|
|
32
|
+
}
|
|
33
|
+
declare function createEventTypeRegistry(initialEventTypes?: string[]): EventTypeRegistry;
|
|
34
|
+
|
|
35
|
+
export { type AssetEventActorType, type AssetEventEnvelope, type AssetEventSubjectType, type AssetEventType, type EventTypeRegistry, createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType };
|
package/dist/events/index.js
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
var subjectTypeRegistry = /* @__PURE__ */ new Set([
|
|
3
|
-
"ActionInvocation",
|
|
4
|
-
"PolicyEvaluation",
|
|
5
|
-
"AdapterInvocation"
|
|
6
|
-
]);
|
|
7
|
-
var eventTypeRegistry = /* @__PURE__ */ new Set([
|
|
8
|
-
"ComplianceBlocked",
|
|
9
|
-
"StateTransitioned",
|
|
10
|
-
"AdapterInvocationStarted",
|
|
11
|
-
"AdapterInvocationSucceeded",
|
|
12
|
-
"AdapterInvocationFailed",
|
|
13
|
-
"WebhookReceived"
|
|
14
|
-
]);
|
|
15
|
-
var dynamicSubjectTypes = /* @__PURE__ */ new Set();
|
|
16
|
-
var dynamicEventTypes = /* @__PURE__ */ new Set();
|
|
17
|
-
function registerSubjectType(type) {
|
|
18
|
-
dynamicSubjectTypes.add(type);
|
|
19
|
-
}
|
|
20
|
-
function isValidSubjectType(type) {
|
|
21
|
-
return subjectTypeRegistry.has(type) || dynamicSubjectTypes.has(type);
|
|
22
|
-
}
|
|
23
|
-
function getRegisteredSubjectTypes() {
|
|
24
|
-
return Array.from(/* @__PURE__ */ new Set([...subjectTypeRegistry, ...dynamicSubjectTypes]));
|
|
25
|
-
}
|
|
26
|
-
function registerEventType(type) {
|
|
27
|
-
dynamicEventTypes.add(type);
|
|
28
|
-
}
|
|
29
|
-
function isValidEventType(type) {
|
|
30
|
-
return eventTypeRegistry.has(type) || dynamicEventTypes.has(type);
|
|
31
|
-
}
|
|
32
|
-
function getRegisteredEventTypes() {
|
|
33
|
-
return Array.from(/* @__PURE__ */ new Set([...eventTypeRegistry, ...dynamicEventTypes]));
|
|
34
|
-
}
|
|
35
|
-
function createEventTypeRegistry(initialEventTypes = []) {
|
|
36
|
-
const eventTypes = new Set(initialEventTypes);
|
|
37
|
-
return {
|
|
38
|
-
register(eventType) {
|
|
39
|
-
if (!eventType) {
|
|
40
|
-
throw new Error("Event type cannot be empty");
|
|
41
|
-
}
|
|
42
|
-
eventTypes.add(eventType);
|
|
43
|
-
},
|
|
44
|
-
has(eventType) {
|
|
45
|
-
return eventTypes.has(eventType);
|
|
46
|
-
},
|
|
47
|
-
list() {
|
|
48
|
-
return Array.from(eventTypes).sort();
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType };
|
|
1
|
+
export { createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType } from '../chunk-4YQOGV7H.js';
|
|
54
2
|
//# sourceMappingURL=index.js.map
|
|
55
3
|
//# sourceMappingURL=index.js.map
|
package/dist/events/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type EvidencePacketStatus = "draft" | "sealed" | "superseded";
|
|
2
|
+
interface EvidencePacketSubject {
|
|
3
|
+
subjectType: string;
|
|
4
|
+
subjectId: string;
|
|
5
|
+
}
|
|
6
|
+
interface EvidencePacketReference {
|
|
7
|
+
referenceType: "action_invocation" | "asset_event" | "policy_evaluation" | "adapter_invocation" | "document" | "external_observation";
|
|
8
|
+
referenceId: string;
|
|
9
|
+
checksum?: string;
|
|
10
|
+
uri?: string;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface EvidencePacketEnvelope<TPayload = Record<string, unknown>> {
|
|
14
|
+
id: string;
|
|
15
|
+
tenantId: string;
|
|
16
|
+
spaceId: string;
|
|
17
|
+
packetType: string;
|
|
18
|
+
status: EvidencePacketStatus;
|
|
19
|
+
subjects: EvidencePacketSubject[];
|
|
20
|
+
references: EvidencePacketReference[];
|
|
21
|
+
payload: TPayload;
|
|
22
|
+
generatedAt: Date | string;
|
|
23
|
+
generatedBy: string;
|
|
24
|
+
policyVersion?: string;
|
|
25
|
+
checksum?: string;
|
|
26
|
+
correlationId: string;
|
|
27
|
+
causationId?: string;
|
|
28
|
+
}
|
|
29
|
+
interface EvidenceGenerationContext<TDb = unknown> {
|
|
30
|
+
tenantId: string;
|
|
31
|
+
spaceId: string;
|
|
32
|
+
actorId: string;
|
|
33
|
+
correlationId: string;
|
|
34
|
+
causationId?: string;
|
|
35
|
+
db: TDb;
|
|
36
|
+
now?: Date;
|
|
37
|
+
}
|
|
38
|
+
interface EvidenceRenderer<TInput = unknown, TPayload = Record<string, unknown>, TDb = unknown> {
|
|
39
|
+
packetType: string;
|
|
40
|
+
render: (input: TInput, context: EvidenceGenerationContext<TDb>) => Promise<EvidencePacketEnvelope<TPayload>> | EvidencePacketEnvelope<TPayload>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type { EvidenceGenerationContext, EvidencePacketEnvelope, EvidencePacketReference, EvidencePacketStatus, EvidencePacketSubject, EvidenceRenderer };
|
package/dist/evidence/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkLZSE6QGQ_cjs = require('../chunk-LZSE6QGQ.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "FABRIC_ID_PREFIXES", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkLZSE6QGQ_cjs.FABRIC_ID_PREFIXES; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "createFabricId", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkLZSE6QGQ_cjs.createFabricId; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "isFabricId", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkLZSE6QGQ_cjs.isFabricId; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "parseFabricId", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkLZSE6QGQ_cjs.parseFabricId; }
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
24
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const FABRIC_ID_PREFIXES: {
|
|
2
|
+
readonly assetEvent: "evt";
|
|
3
|
+
readonly actionInvocation: "act";
|
|
4
|
+
readonly policyEvaluation: "pol";
|
|
5
|
+
readonly adapterInvocation: "adp";
|
|
6
|
+
readonly adapterDeadLetterQueue: "dlq";
|
|
7
|
+
readonly accessEvent: "acc";
|
|
8
|
+
readonly projectionSnapshot: "psn";
|
|
9
|
+
readonly complianceEvidencePacket: "cep";
|
|
10
|
+
};
|
|
11
|
+
type FabricIdPrefix = (typeof FABRIC_ID_PREFIXES)[keyof typeof FABRIC_ID_PREFIXES] | string;
|
|
12
|
+
declare function createFabricId(prefix: FabricIdPrefix): string;
|
|
13
|
+
declare function isFabricId(id: string, prefix?: FabricIdPrefix): boolean;
|
|
14
|
+
declare function parseFabricId(id: string): {
|
|
15
|
+
prefix: string;
|
|
16
|
+
ulid: string;
|
|
17
|
+
} | null;
|
|
18
|
+
|
|
19
|
+
export { FABRIC_ID_PREFIXES, type FabricIdPrefix, createFabricId, isFabricId, parseFabricId };
|
package/dist/ids/index.js
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
var CROCKFORD_BASE32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
3
|
-
var FABRIC_ID_PREFIXES = {
|
|
4
|
-
assetEvent: "evt",
|
|
5
|
-
actionInvocation: "act",
|
|
6
|
-
policyEvaluation: "pol",
|
|
7
|
-
adapterInvocation: "adp",
|
|
8
|
-
adapterDeadLetterQueue: "dlq",
|
|
9
|
-
accessEvent: "acc",
|
|
10
|
-
projectionSnapshot: "psn",
|
|
11
|
-
complianceEvidencePacket: "cep"
|
|
12
|
-
};
|
|
13
|
-
var ID_REGEX = /^([a-z][a-z0-9]{1,7})_([0-9A-Z]{26})$/;
|
|
14
|
-
function randomBase32(length) {
|
|
15
|
-
let output = "";
|
|
16
|
-
const randomValues = new Uint8Array(length);
|
|
17
|
-
globalThis.crypto.getRandomValues(randomValues);
|
|
18
|
-
for (const value of randomValues) {
|
|
19
|
-
output += CROCKFORD_BASE32[value % CROCKFORD_BASE32.length];
|
|
20
|
-
}
|
|
21
|
-
return output;
|
|
22
|
-
}
|
|
23
|
-
function createSortableRandomId() {
|
|
24
|
-
let timestamp = Date.now();
|
|
25
|
-
let encodedTime = "";
|
|
26
|
-
for (let index = 0; index < 10; index++) {
|
|
27
|
-
encodedTime = CROCKFORD_BASE32[timestamp % 32] + encodedTime;
|
|
28
|
-
timestamp = Math.floor(timestamp / 32);
|
|
29
|
-
}
|
|
30
|
-
return `${encodedTime}${randomBase32(16)}`;
|
|
31
|
-
}
|
|
32
|
-
function createFabricId(prefix) {
|
|
33
|
-
if (!/^[a-z][a-z0-9]{1,7}$/.test(prefix)) {
|
|
34
|
-
throw new Error(`Invalid Fabric ID prefix: ${prefix}`);
|
|
35
|
-
}
|
|
36
|
-
return `${prefix}_${createSortableRandomId()}`;
|
|
37
|
-
}
|
|
38
|
-
function isFabricId(id, prefix) {
|
|
39
|
-
const match = ID_REGEX.exec(id);
|
|
40
|
-
if (!match) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
return prefix ? match[1] === prefix : true;
|
|
44
|
-
}
|
|
45
|
-
function parseFabricId(id) {
|
|
46
|
-
const match = ID_REGEX.exec(id);
|
|
47
|
-
if (!match) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return { prefix: match[1], ulid: match[2] };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export { FABRIC_ID_PREFIXES, createFabricId, isFabricId, parseFabricId };
|
|
1
|
+
export { FABRIC_ID_PREFIXES, createFabricId, isFabricId, parseFabricId } from '../chunk-RALMUSOX.js';
|
|
54
2
|
//# sourceMappingURL=index.js.map
|
|
55
3
|
//# sourceMappingURL=index.js.map
|
package/dist/ids/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|