@reventlessdev/reventless-core 3.0.0-alpha.170 → 3.0.0-alpha.172
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/CHANGELOG.md +14 -0
- package/package.json +14 -14
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +5 -2
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res.mjs +3 -3
- package/src/components/Heartbeat/Heartbeat.res +2 -2
- package/src/components/Heartbeat/Heartbeat_Builder.res +2 -2
- package/src/components/Heartbeat/Heartbeat_Builder.res.mjs +2 -4
- package/src/components/Task/Task_Builder.res +6 -4
- package/src/components/Task/Task_Builder.res.mjs +4 -4
- package/src/plugin/component/Plugin_Builder.res +5 -1
- package/src/plugin/component/Plugin_Builder.res.mjs +1 -1
- package/src/plugin/component/Plugin_Helpers.res +6 -1
- package/src/plugin/connect/PluginExtensionPoint_Builder.res +2 -0
- package/src/plugin/connect/PluginExtensionPoint_Builder.res.mjs +3 -3
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res +12 -5
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +8 -2
- package/tests/plugin/HeartbeatDisconnectGraceTest.res +98 -0
- package/tests/IdentityTest.res.mjs +0 -174
- package/tests/adapter/MonitoringTest.res.mjs +0 -82
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +0 -356
- package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +0 -101
- package/tests/aggregate/AggregateCacheTest.res.mjs +0 -433
- package/tests/aggregate/AggregateCallbackTest.res.mjs +0 -143
- package/tests/aggregate/AggregateCausationTest.res.mjs +0 -47
- package/tests/aggregate/AggregateConflictTest.res.mjs +0 -386
- package/tests/aggregate/AggregateFixtures.res.mjs +0 -308
- package/tests/aggregate/AggregateRejectionTest.res.mjs +0 -166
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +0 -645
- package/tests/api/ApiNoApiTest.res.mjs +0 -90
- package/tests/api/GraphQL_StitcherTest.res.mjs +0 -112
- package/tests/api/SimpleTest.res.mjs +0 -10
- package/tests/api/SuryToJsonSchemaTest.res.mjs +0 -674
- package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +0 -160
- package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +0 -197
- package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +0 -152
- package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +0 -106
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +0 -109
- package/tests/counter/CounterCallbackTest.res.mjs +0 -140
- package/tests/counter/CounterFixtures.res.mjs +0 -67
- package/tests/dcb/DcbDecodeTest.res.mjs +0 -194
- package/tests/dcb/DcbEventLogOperationsTest.res.mjs +0 -268
- package/tests/dcb/DcbFixtures.res.mjs +0 -534
- package/tests/dcb/DcbScopeInferenceTest.res.mjs +0 -480
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +0 -540
- package/tests/dcb/DcbTagTest.res.mjs +0 -867
- package/tests/dcb/DcbValidationTest.res.mjs +0 -476
- package/tests/eventlog/EventLogFixtures.res.mjs +0 -196
- package/tests/eventlog/EventLogOperationsTest.res.mjs +0 -192
- package/tests/eventlog/EventLogRetryTest.res.mjs +0 -195
- package/tests/eventmapper/EventMapperCallbackTest.res.mjs +0 -141
- package/tests/eventmapper/EventMapperFixtures.res.mjs +0 -440
- package/tests/eventmapper/EventMapperTest.res.mjs +0 -83
- package/tests/eventtopic/EventTopicFixtures.res.mjs +0 -65
- package/tests/eventtopic/EventTopicOperationsTest.res.mjs +0 -71
- package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +0 -94
- package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +0 -205
- package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +0 -304
- package/tests/ftp/FTPTest.res.mjs +0 -88
- package/tests/logger/LogFormatTest.res.mjs +0 -309
- package/tests/logger/LoggerLazyTest.res.mjs +0 -40
- package/tests/message/MessageTest.res.mjs +0 -218
- package/tests/message/MetaEnvelopeTest.res.mjs +0 -188
- package/tests/plugin/ManifestVisibilityTest.res.mjs +0 -215
- package/tests/plugin/PluginSpecExperiment.res.mjs +0 -31
- package/tests/plugin/PluginStructureTest.res.mjs +0 -419
- package/tests/plugin/PluginVersionTest.res.mjs +0 -30
- package/tests/plugin/SchemaWalkerTest.res.mjs +0 -160
- package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +0 -62
- package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +0 -69
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +0 -95
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +0 -69
- package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +0 -69
- package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +0 -81
- package/tests/poc/StructuralSubtypingPoc.res.mjs +0 -61
- package/tests/projection/ProjectionOptimizeTest.res.mjs +0 -75
- package/tests/querydb/QueryDbFixtures.res.mjs +0 -135
- package/tests/querydb/QueryDbOperationsTest.res.mjs +0 -168
- package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +0 -77
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +0 -139
- package/tests/util/CommandPublisherTest.res.mjs +0 -78
- package/tests/util/CsvStreamTest.res.mjs +0 -51
- package/tests/util/LruTest.res.mjs +0 -105
- package/tests/util/MetricsTest.res.mjs +0 -53
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as S from "sury/src/S.res.mjs";
|
|
4
|
-
import * as Identity$Reventless from "@reventlessdev/reventless-spec/src/types/Identity.res.mjs";
|
|
5
|
-
import * as RequestContext$ReventlessCore from "../src/RequestContext.res.mjs";
|
|
6
|
-
|
|
7
|
-
S.enableJson();
|
|
8
|
-
|
|
9
|
-
globalThis.describe("Identity", () => {
|
|
10
|
-
globalThis.describe("anonymous", () => {
|
|
11
|
-
globalThis.test("has userId 'anonymous'", () => {
|
|
12
|
-
globalThis.expect(Identity$Reventless.anonymous.userId).toBe("anonymous");
|
|
13
|
-
});
|
|
14
|
-
globalThis.test("has empty groups", () => {
|
|
15
|
-
globalThis.expect(Identity$Reventless.anonymous.groups).toEqual([]);
|
|
16
|
-
});
|
|
17
|
-
globalThis.test("has InMemory provider", () => {
|
|
18
|
-
globalThis.expect(Identity$Reventless.anonymous.provider).toEqual("InMemory");
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
globalThis.describe("hasGroup", () => {
|
|
22
|
-
let identity_groups = [
|
|
23
|
-
"admin",
|
|
24
|
-
"editors"
|
|
25
|
-
];
|
|
26
|
-
let identity = {
|
|
27
|
-
userId: "user-1",
|
|
28
|
-
username: "alice",
|
|
29
|
-
groups: identity_groups,
|
|
30
|
-
provider: "Cognito"
|
|
31
|
-
};
|
|
32
|
-
globalThis.test("returns true when group is present", () => {
|
|
33
|
-
globalThis.expect(Identity$Reventless.hasGroup(identity, "admin")).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
globalThis.test("returns false when group is absent", () => {
|
|
36
|
-
globalThis.expect(Identity$Reventless.hasGroup(identity, "viewers")).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
globalThis.describe("getClaim", () => {
|
|
40
|
-
let identity_groups = [];
|
|
41
|
-
let identity_claims = Object.fromEntries([
|
|
42
|
-
[
|
|
43
|
-
"tenant",
|
|
44
|
-
"acme"
|
|
45
|
-
],
|
|
46
|
-
[
|
|
47
|
-
"role",
|
|
48
|
-
"manager"
|
|
49
|
-
]
|
|
50
|
-
]);
|
|
51
|
-
let identity = {
|
|
52
|
-
userId: "user-1",
|
|
53
|
-
username: "alice",
|
|
54
|
-
groups: identity_groups,
|
|
55
|
-
claims: identity_claims,
|
|
56
|
-
provider: "InMemory"
|
|
57
|
-
};
|
|
58
|
-
globalThis.test("returns Some for existing claim", () => {
|
|
59
|
-
globalThis.expect(Identity$Reventless.getClaim(identity, "tenant")).toEqual("acme");
|
|
60
|
-
});
|
|
61
|
-
globalThis.test("returns None for missing claim", () => {
|
|
62
|
-
globalThis.expect(Identity$Reventless.getClaim(identity, "missing")).toEqual(undefined);
|
|
63
|
-
});
|
|
64
|
-
globalThis.test("returns None when claims are absent", () => {
|
|
65
|
-
let noClaims_groups = [];
|
|
66
|
-
let noClaims = {
|
|
67
|
-
userId: "user-2",
|
|
68
|
-
username: "bob",
|
|
69
|
-
groups: noClaims_groups,
|
|
70
|
-
provider: "InMemory"
|
|
71
|
-
};
|
|
72
|
-
globalThis.expect(Identity$Reventless.getClaim(noClaims, "tenant")).toEqual(undefined);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
globalThis.describe("schema roundtrip", () => {
|
|
76
|
-
globalThis.test("encode then decode preserves identity", () => {
|
|
77
|
-
let identity_groups = ["admin"];
|
|
78
|
-
let identity_claims = Object.fromEntries([[
|
|
79
|
-
"tenant",
|
|
80
|
-
"acme"
|
|
81
|
-
]]);
|
|
82
|
-
let identity = {
|
|
83
|
-
userId: "user-1",
|
|
84
|
-
username: "alice",
|
|
85
|
-
groups: identity_groups,
|
|
86
|
-
claims: identity_claims,
|
|
87
|
-
provider: "Cognito"
|
|
88
|
-
};
|
|
89
|
-
let json = S.reverseConvertToJsonOrThrow(identity, Identity$Reventless.schema);
|
|
90
|
-
let decoded = S.parseJsonOrThrow(json, Identity$Reventless.schema);
|
|
91
|
-
globalThis.expect(decoded).toEqual(identity);
|
|
92
|
-
});
|
|
93
|
-
globalThis.test("roundtrip with Custom provider", () => {
|
|
94
|
-
let identity_groups = [];
|
|
95
|
-
let identity_provider = {
|
|
96
|
-
TAG: "Custom",
|
|
97
|
-
_0: "oauth2"
|
|
98
|
-
};
|
|
99
|
-
let identity = {
|
|
100
|
-
userId: "ext-1",
|
|
101
|
-
username: "external",
|
|
102
|
-
groups: identity_groups,
|
|
103
|
-
provider: identity_provider
|
|
104
|
-
};
|
|
105
|
-
let json = S.reverseConvertToJsonOrThrow(identity, Identity$Reventless.schema);
|
|
106
|
-
let decoded = S.parseJsonOrThrow(json, Identity$Reventless.schema);
|
|
107
|
-
globalThis.expect(decoded).toEqual(identity);
|
|
108
|
-
});
|
|
109
|
-
globalThis.test("roundtrip without optional claims", () => {
|
|
110
|
-
let identity_groups = [];
|
|
111
|
-
let identity = {
|
|
112
|
-
userId: "user-3",
|
|
113
|
-
username: "charlie",
|
|
114
|
-
groups: identity_groups,
|
|
115
|
-
provider: "InMemory"
|
|
116
|
-
};
|
|
117
|
-
let json = S.reverseConvertToJsonOrThrow(identity, Identity$Reventless.schema);
|
|
118
|
-
let decoded = S.parseJsonOrThrow(json, Identity$Reventless.schema);
|
|
119
|
-
globalThis.expect(decoded.userId).toBe("user-3");
|
|
120
|
-
globalThis.expect(decoded.provider).toEqual("InMemory");
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
globalThis.describe("RequestContext", () => {
|
|
126
|
-
globalThis.describe("test() constructor", () => {
|
|
127
|
-
globalThis.test("defaults to anonymous identity", () => {
|
|
128
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, undefined, undefined);
|
|
129
|
-
globalThis.expect(ctx.identity.userId).toBe("anonymous");
|
|
130
|
-
});
|
|
131
|
-
globalThis.test("accepts custom identity", () => {
|
|
132
|
-
let identity_groups = ["admin"];
|
|
133
|
-
let identity = {
|
|
134
|
-
userId: "user-1",
|
|
135
|
-
username: "alice",
|
|
136
|
-
groups: identity_groups,
|
|
137
|
-
provider: "Cognito"
|
|
138
|
-
};
|
|
139
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, identity, undefined);
|
|
140
|
-
globalThis.expect(ctx.identity.userId).toBe("user-1");
|
|
141
|
-
});
|
|
142
|
-
globalThis.test("defaults to empty claims", () => {
|
|
143
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, undefined, undefined);
|
|
144
|
-
globalThis.expect(Object.keys(ctx.claims)).toEqual([]);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
globalThis.describe("getClaim", () => {
|
|
148
|
-
globalThis.test("returns claim value when present", () => {
|
|
149
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, undefined, Object.fromEntries([[
|
|
150
|
-
"tenant",
|
|
151
|
-
"acme"
|
|
152
|
-
]]));
|
|
153
|
-
globalThis.expect(RequestContext$ReventlessCore.getClaim(ctx, "tenant")).toEqual("acme");
|
|
154
|
-
});
|
|
155
|
-
globalThis.test("returns None when absent", () => {
|
|
156
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, undefined, undefined);
|
|
157
|
-
globalThis.expect(RequestContext$ReventlessCore.getClaim(ctx, "missing")).toEqual(undefined);
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
globalThis.describe("withClaim", () => {
|
|
161
|
-
globalThis.test("adds a claim to the context", () => {
|
|
162
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, undefined, undefined);
|
|
163
|
-
let updated = RequestContext$ReventlessCore.withClaim(ctx, "tenant", "acme");
|
|
164
|
-
globalThis.expect(RequestContext$ReventlessCore.getClaim(updated, "tenant")).toEqual("acme");
|
|
165
|
-
});
|
|
166
|
-
globalThis.test("does not mutate the original context", () => {
|
|
167
|
-
let ctx = RequestContext$ReventlessCore.test(undefined, undefined, undefined);
|
|
168
|
-
RequestContext$ReventlessCore.withClaim(ctx, "tenant", "acme");
|
|
169
|
-
globalThis.expect(RequestContext$ReventlessCore.getClaim(ctx, "tenant")).toEqual(undefined);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
/* Not a pure module */
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Monitoring$ReventlessCore from "../../src/adapter/Monitoring/Monitoring.res.mjs";
|
|
4
|
-
|
|
5
|
-
let stubResource = {};
|
|
6
|
-
|
|
7
|
-
globalThis.describe("Monitoring", () => {
|
|
8
|
-
globalThis.test("Noop default: notify is silent and does not throw", () => {
|
|
9
|
-
Monitoring$ReventlessCore.notify("CommandHandler", "before", stubResource);
|
|
10
|
-
globalThis.expect(true).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
globalThis.test("use registers a backend that receives every notify, role and name", () => {
|
|
13
|
-
let recorded = [];
|
|
14
|
-
let onProvisioned = (kind, name, param) => {
|
|
15
|
-
recorded.push([
|
|
16
|
-
kind,
|
|
17
|
-
name
|
|
18
|
-
]);
|
|
19
|
-
};
|
|
20
|
-
let Recorder = {
|
|
21
|
-
onProvisioned: onProvisioned
|
|
22
|
-
};
|
|
23
|
-
Monitoring$ReventlessCore.use(Recorder);
|
|
24
|
-
Monitoring$ReventlessCore.notify("CommandHandler", "AllAggregatesCmdHandler", stubResource);
|
|
25
|
-
Monitoring$ReventlessCore.notify("Projection", "AllStateViewSlices", stubResource);
|
|
26
|
-
Monitoring$ReventlessCore.notify("DeadLetterSink", "DeadLetterQueue", stubResource);
|
|
27
|
-
Monitoring$ReventlessCore.notify({
|
|
28
|
-
TAG: "Other",
|
|
29
|
-
_0: "Counter"
|
|
30
|
-
}, "ProductCounter", stubResource);
|
|
31
|
-
globalThis.expect(recorded).toEqual([
|
|
32
|
-
[
|
|
33
|
-
"CommandHandler",
|
|
34
|
-
"AllAggregatesCmdHandler"
|
|
35
|
-
],
|
|
36
|
-
[
|
|
37
|
-
"Projection",
|
|
38
|
-
"AllStateViewSlices"
|
|
39
|
-
],
|
|
40
|
-
[
|
|
41
|
-
"DeadLetterSink",
|
|
42
|
-
"DeadLetterQueue"
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
{
|
|
46
|
-
TAG: "Other",
|
|
47
|
-
_0: "Counter"
|
|
48
|
-
},
|
|
49
|
-
"ProductCounter"
|
|
50
|
-
]
|
|
51
|
-
]);
|
|
52
|
-
Monitoring$ReventlessCore.use(Monitoring$ReventlessCore.Noop);
|
|
53
|
-
});
|
|
54
|
-
globalThis.test("notify forwards the static name and component resource to the backend", () => {
|
|
55
|
-
let seen = {
|
|
56
|
-
contents: undefined
|
|
57
|
-
};
|
|
58
|
-
let onProvisioned = (param, name, component) => {
|
|
59
|
-
seen.contents = [
|
|
60
|
-
name,
|
|
61
|
-
component
|
|
62
|
-
];
|
|
63
|
-
};
|
|
64
|
-
let Capture = {
|
|
65
|
-
onProvisioned: onProvisioned
|
|
66
|
-
};
|
|
67
|
-
Monitoring$ReventlessCore.use(Capture);
|
|
68
|
-
Monitoring$ReventlessCore.notify("Scheduler", "HeartbeatUnit", stubResource);
|
|
69
|
-
let match = seen.contents;
|
|
70
|
-
if (match !== undefined) {
|
|
71
|
-
globalThis.expect(match[0]).toBe("HeartbeatUnit");
|
|
72
|
-
} else {
|
|
73
|
-
globalThis.expect("no notify received").toBe("a notify");
|
|
74
|
-
}
|
|
75
|
-
Monitoring$ReventlessCore.use(Monitoring$ReventlessCore.Noop);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export {
|
|
80
|
-
stubResource,
|
|
81
|
-
}
|
|
82
|
-
/* Not a pure module */
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
4
|
-
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
-
import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js";
|
|
6
|
-
import * as Platform_ComponentDefinitionsApi$ReventlessCore from "../../src/admin/Platform_ComponentDefinitionsApi.res.mjs";
|
|
7
|
-
|
|
8
|
-
let cmd_references = [{
|
|
9
|
-
fieldName: "categoryId",
|
|
10
|
-
entity: "Category",
|
|
11
|
-
plugin: "Catalog"
|
|
12
|
-
}];
|
|
13
|
-
|
|
14
|
-
let cmd_apiExposed = true;
|
|
15
|
-
|
|
16
|
-
let cmd = {
|
|
17
|
-
name: "Add",
|
|
18
|
-
schema: "{}",
|
|
19
|
-
level: "Collection",
|
|
20
|
-
aggregateIdField: undefined,
|
|
21
|
-
mutationField: "AddProduct",
|
|
22
|
-
references: cmd_references,
|
|
23
|
-
allowedStates: undefined,
|
|
24
|
-
apiExposed: cmd_apiExposed
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
let qbl_consumedEventTypes = ["ProductAdded"];
|
|
28
|
-
|
|
29
|
-
let qbl_linkedWriteSide = ["Product"];
|
|
30
|
-
|
|
31
|
-
let qbl_searchableFields = ["displayName"];
|
|
32
|
-
|
|
33
|
-
let qbl = {
|
|
34
|
-
name: "Products",
|
|
35
|
-
queryField: "Catalog_Products",
|
|
36
|
-
schema: "{}",
|
|
37
|
-
consumedEventTypes: qbl_consumedEventTypes,
|
|
38
|
-
linkedWriteSide: qbl_linkedWriteSide,
|
|
39
|
-
labelField: "displayName",
|
|
40
|
-
searchableFields: qbl_searchableFields,
|
|
41
|
-
statusField: undefined,
|
|
42
|
-
visibility: undefined,
|
|
43
|
-
chapter: undefined
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
let wbl_commands = [cmd];
|
|
47
|
-
|
|
48
|
-
let wbl_producedEventTypes = ["ProductAdded"];
|
|
49
|
-
|
|
50
|
-
let wbl_consumedEventTypes = [];
|
|
51
|
-
|
|
52
|
-
let wbl_linkedViews = ["Products"];
|
|
53
|
-
|
|
54
|
-
let wbl_events = [{
|
|
55
|
-
name: "ProductAdded",
|
|
56
|
-
schema: "{}",
|
|
57
|
-
references: []
|
|
58
|
-
}];
|
|
59
|
-
|
|
60
|
-
let wbl = {
|
|
61
|
-
name: "Product",
|
|
62
|
-
commands: wbl_commands,
|
|
63
|
-
producedEventTypes: wbl_producedEventTypes,
|
|
64
|
-
consumedEventTypes: wbl_consumedEventTypes,
|
|
65
|
-
linkedViews: wbl_linkedViews,
|
|
66
|
-
consistencyRead: undefined,
|
|
67
|
-
events: wbl_events,
|
|
68
|
-
chapter: undefined
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
let structure_readModels = [qbl];
|
|
72
|
-
|
|
73
|
-
let structure_stateViewSlices = [];
|
|
74
|
-
|
|
75
|
-
let structure_stateChangeSlices = [];
|
|
76
|
-
|
|
77
|
-
let structure_aggregates = [wbl];
|
|
78
|
-
|
|
79
|
-
let structure_automationSlices = [{
|
|
80
|
-
name: "Restocker",
|
|
81
|
-
consumedEventTypes: ["StockLow"],
|
|
82
|
-
producedCommandTypes: ["Restock"],
|
|
83
|
-
targetName: "Product",
|
|
84
|
-
chapter: undefined
|
|
85
|
-
}];
|
|
86
|
-
|
|
87
|
-
let structure_outboundTranslationSlices = [{
|
|
88
|
-
name: "ToShipper",
|
|
89
|
-
consumedEventTypes: ["OrderPlaced"],
|
|
90
|
-
inboundCommandTypes: ["Ship"],
|
|
91
|
-
targetName: undefined,
|
|
92
|
-
externalSystem: undefined,
|
|
93
|
-
chapter: undefined
|
|
94
|
-
}];
|
|
95
|
-
|
|
96
|
-
let structure_inboundTranslationSlices = [{
|
|
97
|
-
name: "FromBilling",
|
|
98
|
-
commandTypes: ["RecordPayment"],
|
|
99
|
-
targetName: "Order",
|
|
100
|
-
externalSystem: undefined,
|
|
101
|
-
chapter: undefined
|
|
102
|
-
}];
|
|
103
|
-
|
|
104
|
-
let structure_extensions = [{
|
|
105
|
-
name: "Catalog.Products.Watcher",
|
|
106
|
-
delegateNames: ["onAdded"],
|
|
107
|
-
eventTypes: ["ProductAdded"],
|
|
108
|
-
commandTypes: []
|
|
109
|
-
}];
|
|
110
|
-
|
|
111
|
-
let structure = {
|
|
112
|
-
readModels: structure_readModels,
|
|
113
|
-
stateViewSlices: structure_stateViewSlices,
|
|
114
|
-
stateChangeSlices: structure_stateChangeSlices,
|
|
115
|
-
aggregates: structure_aggregates,
|
|
116
|
-
automationSlices: structure_automationSlices,
|
|
117
|
-
outboundTranslationSlices: structure_outboundTranslationSlices,
|
|
118
|
-
inboundTranslationSlices: structure_inboundTranslationSlices,
|
|
119
|
-
extensions: structure_extensions,
|
|
120
|
-
extensionPoints: undefined
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
let encoded = Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry("Catalog", structure);
|
|
124
|
-
|
|
125
|
-
let json = JSON.stringify(encoded);
|
|
126
|
-
|
|
127
|
-
globalThis.describe("encodePluginStructureEntry", () => {
|
|
128
|
-
globalThis.test("produces a JSON object with the expected top-level keys", () => {
|
|
129
|
-
let dict = Stdlib_Option.getOr(Stdlib_JSON.Decode.object(encoded), {});
|
|
130
|
-
let keys = Object.keys(dict).toSorted(Primitive_string.compare);
|
|
131
|
-
globalThis.expect(keys).toEqual([
|
|
132
|
-
"aggregates",
|
|
133
|
-
"automationSlices",
|
|
134
|
-
"extensions",
|
|
135
|
-
"inboundTranslationSlices",
|
|
136
|
-
"outboundTranslationSlices",
|
|
137
|
-
"pluginId",
|
|
138
|
-
"readModels",
|
|
139
|
-
"stateChangeSlices",
|
|
140
|
-
"stateViewSlices"
|
|
141
|
-
]);
|
|
142
|
-
});
|
|
143
|
-
globalThis.test("encodes pluginId", () => {
|
|
144
|
-
globalThis.expect(json.includes("\"pluginId\":\"Catalog\"")).toEqual(true);
|
|
145
|
-
});
|
|
146
|
-
globalThis.test("encodes commandLevel as a literal string", () => {
|
|
147
|
-
globalThis.expect(json.includes("\"level\":\"Collection\"")).toEqual(true);
|
|
148
|
-
});
|
|
149
|
-
globalThis.test("encodes None aggregateIdField as null", () => {
|
|
150
|
-
globalThis.expect(json.includes("\"aggregateIdField\":null")).toEqual(true);
|
|
151
|
-
});
|
|
152
|
-
globalThis.test("encodes None consistencyRead as null", () => {
|
|
153
|
-
globalThis.expect(json.includes("\"consistencyRead\":null")).toEqual(true);
|
|
154
|
-
});
|
|
155
|
-
globalThis.test("encodes Some plugin reference as its inner string", () => {
|
|
156
|
-
globalThis.expect(json.includes("\"plugin\":\"Catalog\"")).toEqual(true);
|
|
157
|
-
});
|
|
158
|
-
globalThis.test("includes the queryableDef name", () => {
|
|
159
|
-
globalThis.expect(json.includes("\"name\":\"Products\"")).toEqual(true);
|
|
160
|
-
});
|
|
161
|
-
globalThis.test("includes the automation slice name", () => {
|
|
162
|
-
globalThis.expect(json.includes("\"name\":\"Restocker\"")).toEqual(true);
|
|
163
|
-
});
|
|
164
|
-
globalThis.test("encodes None allowedStates as null", () => {
|
|
165
|
-
globalThis.expect(json.includes("\"allowedStates\":null")).toEqual(true);
|
|
166
|
-
});
|
|
167
|
-
globalThis.test("encodes the command's apiExposed flag (drives the event-graph API badge)", () => {
|
|
168
|
-
globalThis.expect(json.includes("\"apiExposed\":true")).toEqual(true);
|
|
169
|
-
});
|
|
170
|
-
globalThis.test("encodes None statusField as null", () => {
|
|
171
|
-
globalThis.expect(json.includes("\"statusField\":null")).toEqual(true);
|
|
172
|
-
});
|
|
173
|
-
globalThis.test("encodes writableDef events", () => {
|
|
174
|
-
globalThis.expect(json.includes("\"events\":[{\"name\":\"ProductAdded\"")).toEqual(true);
|
|
175
|
-
});
|
|
176
|
-
globalThis.test("encodes None outbound externalSystem as null", () => {
|
|
177
|
-
globalThis.expect(json.includes("\"inboundCommandTypes\":[\"Ship\"],\"externalSystem\":null")).toEqual(true);
|
|
178
|
-
});
|
|
179
|
-
globalThis.test("encodes None inbound externalSystem as null", () => {
|
|
180
|
-
globalThis.expect(json.includes("\"commandTypes\":[\"RecordPayment\"],\"externalSystem\":null")).toEqual(true);
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
globalThis.describe("translation-slice externalSystem round-trip", () => {
|
|
185
|
-
let externalStructure_readModels = structure_readModels;
|
|
186
|
-
let externalStructure_stateViewSlices = structure_stateViewSlices;
|
|
187
|
-
let externalStructure_stateChangeSlices = structure_stateChangeSlices;
|
|
188
|
-
let externalStructure_aggregates = structure_aggregates;
|
|
189
|
-
let externalStructure_automationSlices = structure_automationSlices;
|
|
190
|
-
let externalStructure_outboundTranslationSlices = [{
|
|
191
|
-
name: "ToShipper",
|
|
192
|
-
consumedEventTypes: ["OrderPlaced"],
|
|
193
|
-
inboundCommandTypes: ["Ship"],
|
|
194
|
-
targetName: undefined,
|
|
195
|
-
externalSystem: "ShipperGateway",
|
|
196
|
-
chapter: undefined
|
|
197
|
-
}];
|
|
198
|
-
let externalStructure_inboundTranslationSlices = [{
|
|
199
|
-
name: "FromBilling",
|
|
200
|
-
commandTypes: ["RecordPayment"],
|
|
201
|
-
targetName: "Order",
|
|
202
|
-
externalSystem: "BillingProvider",
|
|
203
|
-
chapter: undefined
|
|
204
|
-
}];
|
|
205
|
-
let externalStructure_extensions = structure_extensions;
|
|
206
|
-
let externalStructure = {
|
|
207
|
-
readModels: externalStructure_readModels,
|
|
208
|
-
stateViewSlices: externalStructure_stateViewSlices,
|
|
209
|
-
stateChangeSlices: externalStructure_stateChangeSlices,
|
|
210
|
-
aggregates: externalStructure_aggregates,
|
|
211
|
-
automationSlices: externalStructure_automationSlices,
|
|
212
|
-
outboundTranslationSlices: externalStructure_outboundTranslationSlices,
|
|
213
|
-
inboundTranslationSlices: externalStructure_inboundTranslationSlices,
|
|
214
|
-
extensions: externalStructure_extensions,
|
|
215
|
-
extensionPoints: undefined
|
|
216
|
-
};
|
|
217
|
-
let externalJson = JSON.stringify(Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry("Catalog", externalStructure));
|
|
218
|
-
globalThis.test("surfaces Some outbound externalSystem as its inner string", () => {
|
|
219
|
-
globalThis.expect(externalJson.includes("\"externalSystem\":\"ShipperGateway\"")).toEqual(true);
|
|
220
|
-
});
|
|
221
|
-
globalThis.test("surfaces Some inbound externalSystem as its inner string", () => {
|
|
222
|
-
globalThis.expect(externalJson.includes("\"externalSystem\":\"BillingProvider\"")).toEqual(true);
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
globalThis.describe("visibility filtering (deployed AutoUI hides Internal)", () => {
|
|
227
|
-
let internalQbl_consumedEventTypes = ["CatalogProductSynced"];
|
|
228
|
-
let internalQbl_linkedWriteSide = [];
|
|
229
|
-
let internalQbl_searchableFields = ["name"];
|
|
230
|
-
let internalQbl_visibility = "Internal";
|
|
231
|
-
let internalQbl = {
|
|
232
|
-
name: "AvailableProducts",
|
|
233
|
-
queryField: "Ordering_AvailableProducts",
|
|
234
|
-
schema: "{}",
|
|
235
|
-
consumedEventTypes: internalQbl_consumedEventTypes,
|
|
236
|
-
linkedWriteSide: internalQbl_linkedWriteSide,
|
|
237
|
-
labelField: "name",
|
|
238
|
-
searchableFields: internalQbl_searchableFields,
|
|
239
|
-
statusField: undefined,
|
|
240
|
-
visibility: internalQbl_visibility,
|
|
241
|
-
chapter: undefined
|
|
242
|
-
};
|
|
243
|
-
let mixed_readModels = [
|
|
244
|
-
qbl,
|
|
245
|
-
internalQbl
|
|
246
|
-
];
|
|
247
|
-
let mixed_stateViewSlices = [internalQbl];
|
|
248
|
-
let mixed_stateChangeSlices = structure_stateChangeSlices;
|
|
249
|
-
let mixed_aggregates = structure_aggregates;
|
|
250
|
-
let mixed_automationSlices = structure_automationSlices;
|
|
251
|
-
let mixed_outboundTranslationSlices = structure_outboundTranslationSlices;
|
|
252
|
-
let mixed_inboundTranslationSlices = structure_inboundTranslationSlices;
|
|
253
|
-
let mixed_extensions = structure_extensions;
|
|
254
|
-
let mixed = {
|
|
255
|
-
readModels: mixed_readModels,
|
|
256
|
-
stateViewSlices: mixed_stateViewSlices,
|
|
257
|
-
stateChangeSlices: mixed_stateChangeSlices,
|
|
258
|
-
aggregates: mixed_aggregates,
|
|
259
|
-
automationSlices: mixed_automationSlices,
|
|
260
|
-
outboundTranslationSlices: mixed_outboundTranslationSlices,
|
|
261
|
-
inboundTranslationSlices: mixed_inboundTranslationSlices,
|
|
262
|
-
extensions: mixed_extensions,
|
|
263
|
-
extensionPoints: undefined
|
|
264
|
-
};
|
|
265
|
-
let mixedJson = JSON.stringify(Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry("Ordering", mixed));
|
|
266
|
-
globalThis.test("excludes an Internal queryableDef from the encoded read-side", () => {
|
|
267
|
-
globalThis.expect(mixedJson.includes("AvailableProducts")).toEqual(false);
|
|
268
|
-
});
|
|
269
|
-
globalThis.test("keeps a Public queryableDef", () => {
|
|
270
|
-
globalThis.expect(mixedJson.includes("\"name\":\"Products\"")).toEqual(true);
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
globalThis.describe("allowedStates + statusField populated", () => {
|
|
275
|
-
let cmdWithStates_aggregateIdField = "id";
|
|
276
|
-
let cmdWithStates_references = [];
|
|
277
|
-
let cmdWithStates_allowedStates = ["Inactive"];
|
|
278
|
-
let cmdWithStates_apiExposed = true;
|
|
279
|
-
let cmdWithStates = {
|
|
280
|
-
name: "Activate",
|
|
281
|
-
schema: "{}",
|
|
282
|
-
level: "Instance",
|
|
283
|
-
aggregateIdField: cmdWithStates_aggregateIdField,
|
|
284
|
-
mutationField: "Platform_Plugin_Activate",
|
|
285
|
-
references: cmdWithStates_references,
|
|
286
|
-
allowedStates: cmdWithStates_allowedStates,
|
|
287
|
-
apiExposed: cmdWithStates_apiExposed
|
|
288
|
-
};
|
|
289
|
-
let qblWithStatus_consumedEventTypes = [];
|
|
290
|
-
let qblWithStatus_linkedWriteSide = ["Plugin"];
|
|
291
|
-
let qblWithStatus_searchableFields = ["name"];
|
|
292
|
-
let qblWithStatus_statusField = "status";
|
|
293
|
-
let qblWithStatus = {
|
|
294
|
-
name: "Plugin",
|
|
295
|
-
queryField: "Platform_Plugins",
|
|
296
|
-
schema: "{}",
|
|
297
|
-
consumedEventTypes: qblWithStatus_consumedEventTypes,
|
|
298
|
-
linkedWriteSide: qblWithStatus_linkedWriteSide,
|
|
299
|
-
labelField: "name",
|
|
300
|
-
searchableFields: qblWithStatus_searchableFields,
|
|
301
|
-
statusField: qblWithStatus_statusField,
|
|
302
|
-
visibility: undefined,
|
|
303
|
-
chapter: undefined
|
|
304
|
-
};
|
|
305
|
-
let wblWithStates_commands = [cmdWithStates];
|
|
306
|
-
let wblWithStates_producedEventTypes = [];
|
|
307
|
-
let wblWithStates_consumedEventTypes = [];
|
|
308
|
-
let wblWithStates_linkedViews = ["Plugin"];
|
|
309
|
-
let wblWithStates_events = [];
|
|
310
|
-
let wblWithStates = {
|
|
311
|
-
name: "Plugin",
|
|
312
|
-
commands: wblWithStates_commands,
|
|
313
|
-
producedEventTypes: wblWithStates_producedEventTypes,
|
|
314
|
-
consumedEventTypes: wblWithStates_consumedEventTypes,
|
|
315
|
-
linkedViews: wblWithStates_linkedViews,
|
|
316
|
-
consistencyRead: undefined,
|
|
317
|
-
events: wblWithStates_events,
|
|
318
|
-
chapter: undefined
|
|
319
|
-
};
|
|
320
|
-
let structureWithStates_readModels = [qblWithStatus];
|
|
321
|
-
let structureWithStates_stateViewSlices = [];
|
|
322
|
-
let structureWithStates_stateChangeSlices = [];
|
|
323
|
-
let structureWithStates_aggregates = [wblWithStates];
|
|
324
|
-
let structureWithStates_automationSlices = [];
|
|
325
|
-
let structureWithStates_outboundTranslationSlices = [];
|
|
326
|
-
let structureWithStates_inboundTranslationSlices = [];
|
|
327
|
-
let structureWithStates_extensions = [];
|
|
328
|
-
let structureWithStates = {
|
|
329
|
-
readModels: structureWithStates_readModels,
|
|
330
|
-
stateViewSlices: structureWithStates_stateViewSlices,
|
|
331
|
-
stateChangeSlices: structureWithStates_stateChangeSlices,
|
|
332
|
-
aggregates: structureWithStates_aggregates,
|
|
333
|
-
automationSlices: structureWithStates_automationSlices,
|
|
334
|
-
outboundTranslationSlices: structureWithStates_outboundTranslationSlices,
|
|
335
|
-
inboundTranslationSlices: structureWithStates_inboundTranslationSlices,
|
|
336
|
-
extensions: structureWithStates_extensions,
|
|
337
|
-
extensionPoints: undefined
|
|
338
|
-
};
|
|
339
|
-
let json = JSON.stringify(Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry("Platform", structureWithStates));
|
|
340
|
-
globalThis.test("encodes populated allowedStates as a JSON array", () => {
|
|
341
|
-
globalThis.expect(json.includes("\"allowedStates\":[\"Inactive\"]")).toEqual(true);
|
|
342
|
-
});
|
|
343
|
-
globalThis.test("encodes populated statusField as the field name string", () => {
|
|
344
|
-
globalThis.expect(json.includes("\"statusField\":\"status\"")).toEqual(true);
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
export {
|
|
349
|
-
cmd,
|
|
350
|
-
qbl,
|
|
351
|
-
wbl,
|
|
352
|
-
structure,
|
|
353
|
-
encoded,
|
|
354
|
-
json,
|
|
355
|
-
}
|
|
356
|
-
/* encoded Not a pure module */
|