@reventlessdev/reventless-core 3.0.0-alpha.166 → 3.0.0-alpha.167
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 +8 -0
- package/package.json +4 -4
- package/src/admin/AdminApi.res +9 -62
- package/src/admin/AdminApi.res.mjs +6 -28
- package/src/components/Api/GraphQL_Stitcher.res +4 -112
- package/src/components/Api/GraphQL_Stitcher.res.mjs +0 -90
- package/tests/api/GraphQL_StitcherTest.res +0 -198
- package/src/admin/ApiFragmentRegistry/ApiFragmentRegistryBehavior.res +0 -108
- package/src/admin/ApiFragmentRegistry/ApiFragmentRegistryBehavior.res.mjs +0 -190
- package/src/admin/ApiFragmentRegistry/ApiFragmentRegistrySpec.res +0 -71
- package/src/admin/ApiFragmentRegistry/ApiFragmentRegistrySpec.res.mjs +0 -92
- package/src/admin/ApiFragmentRegistry/ApiFragmentsProjection.res +0 -63
- package/src/admin/ApiFragmentRegistry/ApiFragmentsProjection.res.mjs +0 -108
- package/src/admin/ApiFragmentRegistry/ApiFragmentsReadModelSpec.res +0 -23
- package/src/admin/ApiFragmentRegistry/ApiFragmentsReadModelSpec.res.mjs +0 -43
- package/src/admin/Platform_ApiFragmentsApi.res +0 -32
- package/src/admin/Platform_ApiFragmentsApi.res.mjs +0 -52
- package/src/components/Api/Api_Builder.res +0 -40
- package/src/components/Api/Api_Builder.res.mjs +0 -33
- package/src/components/Api/Api_Operations.res +0 -13
- package/src/components/Api/Api_Operations.res.mjs +0 -12
- package/src/components/Api/GraphQL_PushPlanner.res +0 -65
- package/src/components/Api/GraphQL_PushPlanner.res.mjs +0 -46
- package/tests/admin/Platform_ApiFragmentsApiTest.res +0 -66
- package/tests/admin/Platform_ApiFragmentsApiTest.res.mjs +0 -68
- package/tests/api/GraphQL_PushPlannerTest.res +0 -62
- package/tests/api/GraphQL_PushPlannerTest.res.mjs +0 -80
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.0.0-alpha.167 (2026-07-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @reventlessdev/reventless-core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# 3.0.0-alpha.166 (2026-07-14)
|
|
7
15
|
|
|
8
16
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.167",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"sury": "11.0.0-alpha.4",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
|
-
"@reventlessdev/rescript-effect": "0.1.0-alpha.27",
|
|
32
31
|
"@reventlessdev/rescript-fast-csv": "1.2.0-alpha.12",
|
|
32
|
+
"@reventlessdev/rescript-effect": "0.1.0-alpha.27",
|
|
33
33
|
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.11",
|
|
34
34
|
"@reventlessdev/rescript-node-streams": "1.1.0-alpha.11",
|
|
35
35
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.7",
|
|
36
|
-
"@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.15",
|
|
37
36
|
"@reventlessdev/rescript-ssh2": "1.1.0-alpha.12",
|
|
37
|
+
"@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.15",
|
|
38
38
|
"@reventlessdev/rescript-uuid": "1.1.0-alpha.15",
|
|
39
|
-
"@reventlessdev/reventless-infra": "3.0.0-alpha.98",
|
|
40
39
|
"@reventlessdev/reventless-interop": "3.0.0-alpha.26",
|
|
40
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.99",
|
|
41
41
|
"@reventlessdev/reventless-spec": "3.0.0-alpha.76"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
package/src/admin/AdminApi.res
CHANGED
|
@@ -9,46 +9,14 @@ let cloneMutationEntry: mutationSchemaEntry = {
|
|
|
9
9
|
description: "Clone the system to a specific point in time",
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
// ApiFragmentRegistry admin mutations — the real GraphQL surface of the ApiFragmentRegistry
|
|
13
|
-
// singleton aggregate: the plugin / standalone-service deploy calls
|
|
14
|
-
// `Platform_ApiFragmentRegistry_RegisterApiFragment` / `..._DeregisterApiFragment` as a SigV4
|
|
15
|
-
// system caller. Derived from the aggregate's `commandSchema` exactly like the Plugin aggregate's
|
|
16
|
-
// entries (`PluginBaseFragment.pluginAggregateMutationEntries`) — one `Platform_<Spec>_<Command>`
|
|
17
|
-
// field per non-`@noApi` variant (`RecordApiFragmentPush` is `@noApi`, filtered out). The matching
|
|
18
|
-
// resolver wiring is fired by `Plugin_Helpers.registerAdminAggregateMutations` over the same
|
|
19
|
-
// `~aggregates` list in `Platform_Admin.construct`, so the SDL field and the auto-bound resolver
|
|
20
|
-
// carry byte-identical names.
|
|
21
|
-
let apiFragmentRegistryMutationEntries: array<mutationSchemaEntry> = {
|
|
22
|
-
let commandSchema = ApiFragmentRegistrySpec.commandSchema->S.castToUnknown
|
|
23
|
-
let constructorNames = Reventless.DcbTag.extractAllVariantNames(ApiFragmentRegistrySpec.commandSchema)
|
|
24
|
-
let filteredConstructorNames = ApiNoApiHelpers.filterNoApiVariants(constructorNames, commandSchema)
|
|
25
|
-
let fieldNames =
|
|
26
|
-
filteredConstructorNames->Array.map(cname =>
|
|
27
|
-
Api_Naming.adminField(~name=ApiFragmentRegistrySpec.name ++ "_" ++ cname)
|
|
28
|
-
)
|
|
29
|
-
if fieldNames->Array.length === 0 {
|
|
30
|
-
[]
|
|
31
|
-
} else {
|
|
32
|
-
[
|
|
33
|
-
{
|
|
34
|
-
ReventlessInfra.Api.fieldNames,
|
|
35
|
-
commandSchema,
|
|
36
|
-
},
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
12
|
// Aggregate-derived admin mutations come from `PluginBaseFragment.pluginAggregateMutationEntries`
|
|
42
|
-
// (Plugin aggregate)
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
13
|
+
// (Plugin aggregate) so they end up in the admin base document. The corresponding resolver wiring
|
|
14
|
+
// is fired in parallel by `Plugin_Helpers.registerAdminAggregateMutations` from
|
|
15
|
+
// `Platform_Admin.construct` over the same `~aggregates` list.
|
|
16
|
+
// (The ApiFragmentRegistry aggregate's entries were retired with the merged-API cutover —
|
|
17
|
+
// schema composition is push-free, so no deploy-time register/deregister surface exists.)
|
|
47
18
|
let mutationEntries = (~cloner: bool) => {
|
|
48
|
-
let base =
|
|
49
|
-
PluginBaseFragment.pluginAggregateMutationEntries,
|
|
50
|
-
apiFragmentRegistryMutationEntries,
|
|
51
|
-
)
|
|
19
|
+
let base = PluginBaseFragment.pluginAggregateMutationEntries
|
|
52
20
|
if cloner {
|
|
53
21
|
Array.concat(base, [cloneMutationEntry])
|
|
54
22
|
} else {
|
|
@@ -58,17 +26,6 @@ let mutationEntries = (~cloner: bool) => {
|
|
|
58
26
|
|
|
59
27
|
let queryEntries = PluginBaseFragment.queryEntries
|
|
60
28
|
|
|
61
|
-
// Admin fields a deploy-time system caller (machine credentials — SigV4/IAM on AWS) invokes: the
|
|
62
|
-
// two ApiFragmentRegistry mutations (the deploy's register/deregister write path) and
|
|
63
|
-
// `Platform_ApiFragments` (the deploy waiter's push-status poll). Provider-neutral by design — the
|
|
64
|
-
// AWS adapter threads these into `injectAwsAuthAll`'s `~iamFieldNames` so only these fields carry
|
|
65
|
-
// the dual-auth (`@aws_cognito_user_pools @aws_iam`) directive; every other admin field stays
|
|
66
|
-
// Cognito-only. Derived from the same mutation entries so the names never drift from the SDL.
|
|
67
|
-
let systemCallerFieldNames =
|
|
68
|
-
apiFragmentRegistryMutationEntries
|
|
69
|
-
->Array.flatMap(e => e.fieldNames)
|
|
70
|
-
->Array.concat([Platform_ApiFragmentsApi.queryFieldName])
|
|
71
|
-
|
|
72
29
|
// UIFragment lifecycle Source C subscriptions.
|
|
73
30
|
// Mutations are called by the backend when UIFragment events occur; the
|
|
74
31
|
// subscription→mutation fan-in is carried as neutral `subscriptionSource`
|
|
@@ -132,35 +89,25 @@ let baseFragment = (~cloner: bool) => {
|
|
|
132
89
|
// matching SDL fields, AppSync's CreateResolver fails with "Type not found".
|
|
133
90
|
let (pluginAggregateSubscriptionFields, pluginAggregateSubscriptionSources) =
|
|
134
91
|
Plugin_SubscriptionSchema.sourceCFields(~mutationEntries=PluginBaseFragment.pluginAggregateMutationEntries)
|
|
135
|
-
// The ApiFragmentRegistry aggregate's mutations go through the same CommandGenerator
|
|
136
|
-
// auto-flow, which creates an `on<field>` subscription resolver per mutation. On the
|
|
137
|
-
// static-push platform (AWS) those resolvers orphan unless the fields are declared in the
|
|
138
|
-
// pushed baseFragment — so generate them here too, symmetric with the Plugin aggregate.
|
|
139
|
-
let (apiFragmentAggregateSubscriptionFields, apiFragmentAggregateSubscriptionSources) =
|
|
140
|
-
Plugin_SubscriptionSchema.sourceCFields(~mutationEntries=apiFragmentRegistryMutationEntries)
|
|
141
92
|
GraphQL_Stitcher.encode({
|
|
142
93
|
types: parts.types
|
|
143
94
|
->Array.concat(uiFragmentSubscriptionTypes)
|
|
144
95
|
->Array.concat(pluginStatusSubscriptionTypes)
|
|
145
96
|
->Array.concat(Platform_ComponentDefinitionsApi.sdlTypes)
|
|
146
|
-
->Array.concat(Platform_UIFragmentsApi.sdlTypes)
|
|
147
|
-
->Array.concat(Platform_ApiFragmentsApi.sdlTypes),
|
|
97
|
+
->Array.concat(Platform_UIFragmentsApi.sdlTypes),
|
|
148
98
|
queries: Array.concat(
|
|
149
99
|
parts.queries,
|
|
150
100
|
[
|
|
151
101
|
Platform_ComponentDefinitionsApi.sdlQueryField,
|
|
152
102
|
Platform_UIFragmentsApi.sdlQueryField,
|
|
153
|
-
Platform_ApiFragmentsApi.sdlQueryField,
|
|
154
103
|
],
|
|
155
104
|
),
|
|
156
105
|
mutations: parts.mutations
|
|
157
106
|
->Array.concat(uiFragmentMutationFields)
|
|
158
107
|
->Array.concat(pluginStatusMutationFields),
|
|
159
108
|
subscriptions: [uiFragmentSubscriptionField, pluginStatusSubscriptionField]
|
|
160
|
-
->Array.concat(pluginAggregateSubscriptionFields)
|
|
161
|
-
->Array.concat(apiFragmentAggregateSubscriptionFields),
|
|
109
|
+
->Array.concat(pluginAggregateSubscriptionFields),
|
|
162
110
|
subscriptionSources: [uiFragmentSubscriptionSource, pluginStatusSubscriptionSource]
|
|
163
|
-
->Array.concat(pluginAggregateSubscriptionSources)
|
|
164
|
-
->Array.concat(apiFragmentAggregateSubscriptionSources),
|
|
111
|
+
->Array.concat(pluginAggregateSubscriptionSources),
|
|
165
112
|
})
|
|
166
113
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as S from "sury/src/S.res.mjs";
|
|
4
|
-
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
4
|
import * as Api_Naming$ReventlessCore from "../components/Api/Api_Naming.res.mjs";
|
|
6
|
-
import * as ApiNoApiHelpers$ReventlessCore from "../components/Api/ApiNoApiHelpers.res.mjs";
|
|
7
5
|
import * as GraphQL_Stitcher$ReventlessCore from "../components/Api/GraphQL_Stitcher.res.mjs";
|
|
8
6
|
import * as PluginBaseFragment$ReventlessCore from "../plugin/api/PluginBaseFragment.res.mjs";
|
|
9
|
-
import * as ApiFragmentRegistrySpec$ReventlessCore from "./ApiFragmentRegistry/ApiFragmentRegistrySpec.res.mjs";
|
|
10
7
|
import * as Platform_UIFragmentsApi$ReventlessCore from "./Platform_UIFragmentsApi.res.mjs";
|
|
11
|
-
import * as Platform_ApiFragmentsApi$ReventlessCore from "./Platform_ApiFragmentsApi.res.mjs";
|
|
12
8
|
import * as GraphQL_FragmentGenerator$ReventlessCore from "../components/Api/GraphQL_FragmentGenerator.res.mjs";
|
|
13
9
|
import * as Plugin_SubscriptionSchema$ReventlessCore from "../plugin/component/Plugin_SubscriptionSchema.res.mjs";
|
|
14
10
|
import * as Platform_ComponentDefinitionsApi$ReventlessCore from "./Platform_ComponentDefinitionsApi.res.mjs";
|
|
@@ -27,28 +23,14 @@ let cloneMutationEntry = {
|
|
|
27
23
|
description: cloneMutationEntry_description
|
|
28
24
|
};
|
|
29
25
|
|
|
30
|
-
let constructorNames = DcbTag$Reventless.extractAllVariantNames(ApiFragmentRegistrySpec$ReventlessCore.commandSchema);
|
|
31
|
-
|
|
32
|
-
let filteredConstructorNames = ApiNoApiHelpers$ReventlessCore.filterNoApiVariants(constructorNames, ApiFragmentRegistrySpec$ReventlessCore.commandSchema);
|
|
33
|
-
|
|
34
|
-
let fieldNames = filteredConstructorNames.map(cname => Api_Naming$ReventlessCore.adminField(ApiFragmentRegistrySpec$ReventlessCore.name + "_" + cname));
|
|
35
|
-
|
|
36
|
-
let apiFragmentRegistryMutationEntries = fieldNames.length === 0 ? [] : [{
|
|
37
|
-
fieldNames: fieldNames,
|
|
38
|
-
commandSchema: ApiFragmentRegistrySpec$ReventlessCore.commandSchema
|
|
39
|
-
}];
|
|
40
|
-
|
|
41
26
|
function mutationEntries(cloner) {
|
|
42
|
-
let base = PluginBaseFragment$ReventlessCore.pluginAggregateMutationEntries.concat(apiFragmentRegistryMutationEntries);
|
|
43
27
|
if (cloner) {
|
|
44
|
-
return
|
|
28
|
+
return PluginBaseFragment$ReventlessCore.pluginAggregateMutationEntries.concat([cloneMutationEntry]);
|
|
45
29
|
} else {
|
|
46
|
-
return
|
|
30
|
+
return PluginBaseFragment$ReventlessCore.pluginAggregateMutationEntries;
|
|
47
31
|
}
|
|
48
32
|
}
|
|
49
33
|
|
|
50
|
-
let systemCallerFieldNames = apiFragmentRegistryMutationEntries.flatMap(e => e.fieldNames).concat([Platform_ApiFragmentsApi$ReventlessCore.queryFieldName]);
|
|
51
|
-
|
|
52
34
|
let uiFragmentSubscriptionTypes = [
|
|
53
35
|
`enum UIFragmentChangeKind {\n Registered\n Updated\n Deregistered\n}`,
|
|
54
36
|
`type UIFragmentChangeEvent {\n pluginId: ID!\n changeKind: UIFragmentChangeKind!\n manifest: String\n}`
|
|
@@ -93,23 +75,21 @@ function baseFragment(cloner) {
|
|
|
93
75
|
let base = GraphQL_FragmentGenerator$ReventlessCore.generate(mutationEntries(cloner), PluginBaseFragment$ReventlessCore.queryEntries);
|
|
94
76
|
let parts = GraphQL_Stitcher$ReventlessCore.decode(base);
|
|
95
77
|
let match = Plugin_SubscriptionSchema$ReventlessCore.sourceCFields(PluginBaseFragment$ReventlessCore.pluginAggregateMutationEntries);
|
|
96
|
-
let match$1 = Plugin_SubscriptionSchema$ReventlessCore.sourceCFields(apiFragmentRegistryMutationEntries);
|
|
97
78
|
return GraphQL_Stitcher$ReventlessCore.encode({
|
|
98
|
-
types: parts.types.concat(uiFragmentSubscriptionTypes).concat(pluginStatusSubscriptionTypes).concat(Platform_ComponentDefinitionsApi$ReventlessCore.sdlTypes).concat(Platform_UIFragmentsApi$ReventlessCore.sdlTypes)
|
|
79
|
+
types: parts.types.concat(uiFragmentSubscriptionTypes).concat(pluginStatusSubscriptionTypes).concat(Platform_ComponentDefinitionsApi$ReventlessCore.sdlTypes).concat(Platform_UIFragmentsApi$ReventlessCore.sdlTypes),
|
|
99
80
|
mutations: parts.mutations.concat(uiFragmentMutationFields).concat(pluginStatusMutationFields),
|
|
100
81
|
queries: parts.queries.concat([
|
|
101
82
|
Platform_ComponentDefinitionsApi$ReventlessCore.sdlQueryField,
|
|
102
|
-
Platform_UIFragmentsApi$ReventlessCore.sdlQueryField
|
|
103
|
-
Platform_ApiFragmentsApi$ReventlessCore.sdlQueryField
|
|
83
|
+
Platform_UIFragmentsApi$ReventlessCore.sdlQueryField
|
|
104
84
|
]),
|
|
105
85
|
subscriptions: [
|
|
106
86
|
uiFragmentSubscriptionField,
|
|
107
87
|
pluginStatusSubscriptionField
|
|
108
|
-
].concat(match[0])
|
|
88
|
+
].concat(match[0]),
|
|
109
89
|
subscriptionSources: [
|
|
110
90
|
uiFragmentSubscriptionSource,
|
|
111
91
|
pluginStatusSubscriptionSource
|
|
112
|
-
].concat(match[1])
|
|
92
|
+
].concat(match[1])
|
|
113
93
|
});
|
|
114
94
|
}
|
|
115
95
|
|
|
@@ -118,10 +98,8 @@ let queryEntries = PluginBaseFragment$ReventlessCore.queryEntries;
|
|
|
118
98
|
export {
|
|
119
99
|
cloneArgsSchema,
|
|
120
100
|
cloneMutationEntry,
|
|
121
|
-
apiFragmentRegistryMutationEntries,
|
|
122
101
|
mutationEntries,
|
|
123
102
|
queryEntries,
|
|
124
|
-
systemCallerFieldNames,
|
|
125
103
|
uiFragmentSubscriptionTypes,
|
|
126
104
|
uiFragmentMutationFields,
|
|
127
105
|
uiFragmentSubscriptionField,
|
|
@@ -317,115 +317,7 @@ document carries it (via `stitch`).
|
|
|
317
317
|
let stitchStandalone = (~fragment: Reventless.Plugin.apiSchemaFragment): string =>
|
|
318
318
|
assembleSdl(~fragments=[fragment], ~includeGlobalNodeQuery=false)
|
|
319
319
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
| None => false
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
List the field NAMES defined inside a root object type (`Mutation` / `Query` /
|
|
329
|
-
`Subscription`) of a full SDL string.
|
|
330
|
-
|
|
331
|
-
This is the identity-aware primitive underlying every schema-clobber guard:
|
|
332
|
-
`countRootTypeFields` is just its length, and the deploy-time repair / shrink
|
|
333
|
-
guards compare the returned NAME SETS rather than cardinalities so they catch
|
|
334
|
-
field *swaps* and equal-cardinality drift that a count comparison misses.
|
|
335
|
-
|
|
336
|
-
Heuristic but adequate: root operation fields are flat single-line declarations
|
|
337
|
-
(`name(args): T` or `name: T`), so we slice the `type <typeName> { … }` block at
|
|
338
|
-
its first `{`/`}` and read the leading identifier of each indented line that
|
|
339
|
-
begins with an identifier character, ignoring directive-only lines (`@…`),
|
|
340
|
-
comments (`#…`) and braces.
|
|
341
|
-
*/
|
|
342
|
-
let rootTypeFieldNames = (~sdl: string, ~typeName: string): array<string> => {
|
|
343
|
-
let marker = `type ${typeName}`
|
|
344
|
-
switch sdl->String.indexOfOpt(marker) {
|
|
345
|
-
| None => []
|
|
346
|
-
| Some(typeStart) =>
|
|
347
|
-
let rest = sdl->String.slice(~start=typeStart)
|
|
348
|
-
switch (rest->String.indexOfOpt("{"), rest->String.indexOfOpt("}")) {
|
|
349
|
-
| (Some(openIdx), Some(closeIdx)) if closeIdx > openIdx =>
|
|
350
|
-
rest
|
|
351
|
-
->String.slice(~start=openIdx + 1, ~end=closeIdx)
|
|
352
|
-
->String.split("\n")
|
|
353
|
-
->Array.filterMap(line => {
|
|
354
|
-
let trimmed = line->String.trim
|
|
355
|
-
if trimmed->String.length > 0 && isIdentStart(trimmed) {
|
|
356
|
-
// `name(args): T` → extractLeadingName strips the arg list; `name: T`
|
|
357
|
-
// (no args) leaves a trailing colon on the token — drop it so a field
|
|
358
|
-
// reads the same whether or not it takes arguments.
|
|
359
|
-
let name = extractLeadingName(trimmed)
|
|
360
|
-
let name = name->String.endsWith(":")
|
|
361
|
-
? name->String.slice(~start=0, ~end=name->String.length - 1)
|
|
362
|
-
: name
|
|
363
|
-
name->String.length > 0 ? Some(name) : None
|
|
364
|
-
} else {
|
|
365
|
-
None
|
|
366
|
-
}
|
|
367
|
-
})
|
|
368
|
-
| _ => []
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
Count the field definitions inside a root object type (`Mutation` / `Query`) of a
|
|
375
|
-
full SDL string. Length of `rootTypeFieldNames`.
|
|
376
|
-
*/
|
|
377
|
-
let countRootTypeFields = (~sdl: string, ~typeName: string): int =>
|
|
378
|
-
rootTypeFieldNames(~sdl, ~typeName)->Array.length
|
|
379
|
-
|
|
380
|
-
// The three GraphQL root operation types every clobber guard reasons over.
|
|
381
|
-
let rootTypeNames = ["Mutation", "Query", "Subscription"]
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
Union of every root-operation field name across `Mutation` + `Query` +
|
|
385
|
-
`Subscription`. The identity set the deploy-time repair and shrink guards diff.
|
|
386
|
-
*/
|
|
387
|
-
let allRootFieldNames = (~sdl: string): array<string> =>
|
|
388
|
-
rootTypeNames->Array.flatMap(typeName => rootTypeFieldNames(~sdl, ~typeName))
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
Root-operation field names present in `expectedSdl` but MISSING from `liveSdl`
|
|
392
|
-
(across Mutation + Query + Subscription). Non-empty ⇒ the live schema is not a
|
|
393
|
-
superset of what we expect and a repair push is warranted — this heals field
|
|
394
|
-
*swaps* and equal-cardinality drift that a bare count comparison would skip.
|
|
395
|
-
*/
|
|
396
|
-
let missingRootFields = (~expectedSdl: string, ~liveSdl: string): array<string> => {
|
|
397
|
-
let liveSet = allRootFieldNames(~sdl=liveSdl)->Set.fromArray
|
|
398
|
-
allRootFieldNames(~sdl=expectedSdl)->Array.filter(name => !(liveSet->Set.has(name)))
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
Decide whether replacing the live schema (`currentSdl`) with `newSdl` would drop
|
|
403
|
-
root-operation fields the pushing stack does not carry — i.e. an almost-certainly
|
|
404
|
-
transient/incomplete stitch rather than an intentional removal.
|
|
405
|
-
|
|
406
|
-
Identity-based (across `Mutation` + `Query` + `Subscription`):
|
|
407
|
-
- When `newSdl`'s field-name set is a SUPERSET of the live set — nothing is
|
|
408
|
-
dropped — it is purely additive (or unchanged) and never a clobber, so this
|
|
409
|
-
returns `false` even when the pushing stack is legitimately adding its own
|
|
410
|
-
fields.
|
|
411
|
-
- Otherwise it falls back to the cardinality threshold on the union of the three
|
|
412
|
-
root types: `true` only when the new total drops below `threshold` × the
|
|
413
|
-
current total. A small intentional removal (above threshold) is allowed.
|
|
414
|
-
|
|
415
|
-
When the current schema has no countable root fields (e.g. first deploy, or
|
|
416
|
-
introspection was unavailable so `currentSdl` is empty) it returns `false` so the
|
|
417
|
-
initial push always proceeds.
|
|
418
|
-
*/
|
|
419
|
-
let isCatastrophicSchemaShrink = (~currentSdl: string, ~newSdl: string, ~threshold: float): bool => {
|
|
420
|
-
let currentNames = allRootFieldNames(~sdl=currentSdl)
|
|
421
|
-
let newSet = allRootFieldNames(~sdl=newSdl)->Set.fromArray
|
|
422
|
-
let dropped = currentNames->Array.filter(name => !(newSet->Set.has(name)))
|
|
423
|
-
if dropped->Array.length == 0 {
|
|
424
|
-
// Additive or unchanged push — the new schema keeps every live field.
|
|
425
|
-
false
|
|
426
|
-
} else {
|
|
427
|
-
let current = currentNames->Array.length
|
|
428
|
-
let next = allRootFieldNames(~sdl=newSdl)->Array.length
|
|
429
|
-
current > 0 && next->Int.toFloat < current->Int.toFloat *. threshold
|
|
430
|
-
}
|
|
431
|
-
}
|
|
320
|
+
// (The schema-clobber guard family — rootTypeFieldNames / countRootTypeFields /
|
|
321
|
+
// missingRootFields / isCatastrophicSchemaShrink — was retired with the push
|
|
322
|
+
// machinery: under merged-API composition every source API is a single writer,
|
|
323
|
+
// so no whole-replace push exists to guard.)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
4
4
|
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
|
|
5
5
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
6
|
-
import * as Stdlib_String from "@rescript/runtime/lib/es6/Stdlib_String.js";
|
|
7
6
|
import * as Logger$ReventlessCore from "../../util/Logger.res.mjs";
|
|
8
7
|
|
|
9
8
|
let log = Logger$ReventlessCore.fromEnv();
|
|
@@ -226,88 +225,6 @@ function stitchStandalone(fragment) {
|
|
|
226
225
|
return assembleSdl([fragment], false);
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
function isIdentStart(line) {
|
|
230
|
-
let c = line.codePointAt(0);
|
|
231
|
-
if (c !== undefined) {
|
|
232
|
-
if (c >= 65 && c <= 90 || c >= 97 && c <= 122) {
|
|
233
|
-
return true;
|
|
234
|
-
} else {
|
|
235
|
-
return c === 95;
|
|
236
|
-
}
|
|
237
|
-
} else {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function rootTypeFieldNames(sdl, typeName) {
|
|
243
|
-
let marker = `type ` + typeName;
|
|
244
|
-
let typeStart = Stdlib_String.indexOfOpt(sdl, marker);
|
|
245
|
-
if (typeStart === undefined) {
|
|
246
|
-
return [];
|
|
247
|
-
}
|
|
248
|
-
let rest = sdl.slice(typeStart);
|
|
249
|
-
let match = Stdlib_String.indexOfOpt(rest, "{");
|
|
250
|
-
let match$1 = Stdlib_String.indexOfOpt(rest, "}");
|
|
251
|
-
if (match !== undefined) {
|
|
252
|
-
if (match$1 !== undefined) {
|
|
253
|
-
if (match$1 > match) {
|
|
254
|
-
return Stdlib_Array.filterMap(rest.slice(match + 1 | 0, match$1).split("\n"), line => {
|
|
255
|
-
let trimmed = line.trim();
|
|
256
|
-
if (!(trimmed.length > 0 && isIdentStart(trimmed))) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
let name = extractLeadingName(trimmed);
|
|
260
|
-
let name$1 = name.endsWith(":") ? name.slice(0, name.length - 1 | 0) : name;
|
|
261
|
-
if (name$1.length > 0) {
|
|
262
|
-
return name$1;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
} else {
|
|
266
|
-
return [];
|
|
267
|
-
}
|
|
268
|
-
} else {
|
|
269
|
-
return [];
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
return [];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function countRootTypeFields(sdl, typeName) {
|
|
277
|
-
return rootTypeFieldNames(sdl, typeName).length;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
let rootTypeNames = [
|
|
281
|
-
"Mutation",
|
|
282
|
-
"Query",
|
|
283
|
-
"Subscription"
|
|
284
|
-
];
|
|
285
|
-
|
|
286
|
-
function allRootFieldNames(sdl) {
|
|
287
|
-
return rootTypeNames.flatMap(typeName => rootTypeFieldNames(sdl, typeName));
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function missingRootFields(expectedSdl, liveSdl) {
|
|
291
|
-
let liveSet = new Set(allRootFieldNames(liveSdl));
|
|
292
|
-
return allRootFieldNames(expectedSdl).filter(name => !liveSet.has(name));
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function isCatastrophicSchemaShrink(currentSdl, newSdl, threshold) {
|
|
296
|
-
let currentNames = allRootFieldNames(currentSdl);
|
|
297
|
-
let newSet = new Set(allRootFieldNames(newSdl));
|
|
298
|
-
let dropped = currentNames.filter(name => !newSet.has(name));
|
|
299
|
-
if (dropped.length === 0) {
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
let current = currentNames.length;
|
|
303
|
-
let next = allRootFieldNames(newSdl).length;
|
|
304
|
-
if (current > 0) {
|
|
305
|
-
return next < current * threshold;
|
|
306
|
-
} else {
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
228
|
export {
|
|
312
229
|
log,
|
|
313
230
|
encodeSubscriptionSource,
|
|
@@ -320,12 +237,5 @@ export {
|
|
|
320
237
|
assembleSdl,
|
|
321
238
|
stitch,
|
|
322
239
|
stitchStandalone,
|
|
323
|
-
isIdentStart,
|
|
324
|
-
rootTypeFieldNames,
|
|
325
|
-
countRootTypeFields,
|
|
326
|
-
rootTypeNames,
|
|
327
|
-
allRootFieldNames,
|
|
328
|
-
missingRootFields,
|
|
329
|
-
isCatastrophicSchemaShrink,
|
|
330
240
|
}
|
|
331
241
|
/* log Not a pure module */
|
|
@@ -1,204 +1,6 @@
|
|
|
1
1
|
open JestGlobals
|
|
2
2
|
open GraphQL_Stitcher
|
|
3
3
|
|
|
4
|
-
// A representative stitched schema: admin base (Platform_*) plus two domain
|
|
5
|
-
// plugins (Catalog_*, Ordering_*). 4 Mutation + 4 Query root fields.
|
|
6
|
-
let fullSchemaSdl = `type Node {
|
|
7
|
-
id: ID!
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Query {
|
|
11
|
-
node(id: ID!): Node
|
|
12
|
-
Platform_plugins: [Plugin]
|
|
13
|
-
Catalog_products: [Product]
|
|
14
|
-
Ordering_orders: [Order]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type Mutation {
|
|
18
|
-
Platform_connectPlugin(input: ConnectInput): ConnectResult
|
|
19
|
-
Catalog_addProduct(input: AddInput): Product
|
|
20
|
-
Catalog_updateProduct(input: UpdateInput): Product
|
|
21
|
-
Ordering_placeOrder(input: OrderInput): Order
|
|
22
|
-
}`
|
|
23
|
-
|
|
24
|
-
// The exact failure observed in alpha: a lifecycle window collapses the live
|
|
25
|
-
// schema back to admin-base only — every Catalog_*/Ordering_* field gone.
|
|
26
|
-
// 1 Mutation + 2 Query root fields.
|
|
27
|
-
let collapsedSchemaSdl = `type Node {
|
|
28
|
-
id: ID!
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type Query {
|
|
32
|
-
node(id: ID!): Node
|
|
33
|
-
Platform_plugins: [Plugin]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type Mutation {
|
|
37
|
-
Platform_connectPlugin(input: ConnectInput): ConnectResult
|
|
38
|
-
}`
|
|
39
|
-
|
|
40
|
-
// Real stitched shape: injectAwsAuthAll appends @aws_auth on its own indented
|
|
41
|
-
// line after each Mutation field, so a field spans two physical lines.
|
|
42
|
-
let authAnnotatedSdl = `type Mutation {
|
|
43
|
-
Platform_connectPlugin(input: ConnectInput): ConnectResult
|
|
44
|
-
@aws_auth(cognito_groups: ["Admin"])
|
|
45
|
-
Catalog_addProduct(input: AddInput): Product
|
|
46
|
-
@aws_auth(cognito_groups: ["User"])
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type Query {
|
|
50
|
-
node(id: ID!): Node @aws_auth(cognito_groups: ["Admin"])
|
|
51
|
-
}`
|
|
52
|
-
|
|
53
|
-
describe("GraphQL_Stitcher.countRootTypeFields", () => {
|
|
54
|
-
testSync("counts Mutation fields", () => {
|
|
55
|
-
expect(countRootTypeFields(~sdl=fullSchemaSdl, ~typeName="Mutation"))->toBe(4)
|
|
56
|
-
})
|
|
57
|
-
testSync("counts Query fields", () => {
|
|
58
|
-
expect(countRootTypeFields(~sdl=fullSchemaSdl, ~typeName="Query"))->toBe(4)
|
|
59
|
-
})
|
|
60
|
-
testSync("ignores @aws_auth directive lines, counts each Mutation field once", () => {
|
|
61
|
-
expect(countRootTypeFields(~sdl=authAnnotatedSdl, ~typeName="Mutation"))->toBe(2)
|
|
62
|
-
})
|
|
63
|
-
testSync("ignores @aws_auth directive lines, counts each Query field once", () => {
|
|
64
|
-
expect(countRootTypeFields(~sdl=authAnnotatedSdl, ~typeName="Query"))->toBe(1)
|
|
65
|
-
})
|
|
66
|
-
testSync("missing type returns 0", () => {
|
|
67
|
-
expect(countRootTypeFields(~sdl=fullSchemaSdl, ~typeName="Subscription"))->toBe(0)
|
|
68
|
-
})
|
|
69
|
-
testSync("empty SDL returns 0", () => {
|
|
70
|
-
expect(countRootTypeFields(~sdl="", ~typeName="Mutation"))->toBe(0)
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
describe("GraphQL_Stitcher.isCatastrophicSchemaShrink", () => {
|
|
75
|
-
testSync("rejects the all-disconnected collapse (8 → 3 root fields, < 50%)", () => {
|
|
76
|
-
expect(
|
|
77
|
-
isCatastrophicSchemaShrink(~currentSdl=fullSchemaSdl, ~newSdl=collapsedSchemaSdl, ~threshold=0.5),
|
|
78
|
-
)->toBe(true)
|
|
79
|
-
})
|
|
80
|
-
testSync("allows an intentional small removal above threshold (8 → 7)", () => {
|
|
81
|
-
let minusOneSdl = `type Query {
|
|
82
|
-
node(id: ID!): Node
|
|
83
|
-
Platform_plugins: [Plugin]
|
|
84
|
-
Catalog_products: [Product]
|
|
85
|
-
Ordering_orders: [Order]
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
type Mutation {
|
|
89
|
-
Platform_connectPlugin(input: ConnectInput): ConnectResult
|
|
90
|
-
Catalog_addProduct(input: AddInput): Product
|
|
91
|
-
Ordering_placeOrder(input: OrderInput): Order
|
|
92
|
-
}`
|
|
93
|
-
expect(
|
|
94
|
-
isCatastrophicSchemaShrink(~currentSdl=fullSchemaSdl, ~newSdl=minusOneSdl, ~threshold=0.5),
|
|
95
|
-
)->toBe(false)
|
|
96
|
-
})
|
|
97
|
-
testSync("allows the first push when there is no live schema to protect", () => {
|
|
98
|
-
expect(
|
|
99
|
-
isCatastrophicSchemaShrink(~currentSdl="", ~newSdl=fullSchemaSdl, ~threshold=0.5),
|
|
100
|
-
)->toBe(false)
|
|
101
|
-
})
|
|
102
|
-
testSync("allows an unchanged re-push (same SDL)", () => {
|
|
103
|
-
expect(
|
|
104
|
-
isCatastrophicSchemaShrink(~currentSdl=fullSchemaSdl, ~newSdl=fullSchemaSdl, ~threshold=0.5),
|
|
105
|
-
)->toBe(false)
|
|
106
|
-
})
|
|
107
|
-
testSync("allows a purely additive push even below threshold cardinality", () => {
|
|
108
|
-
// A tiny live schema growing into a big one drops nothing → never a clobber,
|
|
109
|
-
// regardless of the ratio.
|
|
110
|
-
expect(
|
|
111
|
-
isCatastrophicSchemaShrink(~currentSdl=collapsedSchemaSdl, ~newSdl=fullSchemaSdl, ~threshold=0.5),
|
|
112
|
-
)->toBe(false)
|
|
113
|
-
})
|
|
114
|
-
testSync("includes Subscription fields when judging a shrink", () => {
|
|
115
|
-
let withSubs = `type Query {
|
|
116
|
-
node(id: ID!): Node
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
type Mutation {
|
|
120
|
-
Ordering_placeOrder(input: OrderInput): Order
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
type Subscription {
|
|
124
|
-
onOrdering_Customer_Register: Customer
|
|
125
|
-
onOrdering_Customer_UpdateAddress: Customer
|
|
126
|
-
onCatalog_Product_Added: Product
|
|
127
|
-
}`
|
|
128
|
-
// Dropping every Subscription field (and keeping Mutation/Query) is a shrink
|
|
129
|
-
// the Mutation+Query-only guard would have missed.
|
|
130
|
-
let subsGone = `type Query {
|
|
131
|
-
node(id: ID!): Node
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
type Mutation {
|
|
135
|
-
Ordering_placeOrder(input: OrderInput): Order
|
|
136
|
-
}`
|
|
137
|
-
expect(
|
|
138
|
-
isCatastrophicSchemaShrink(~currentSdl=withSubs, ~newSdl=subsGone, ~threshold=0.5),
|
|
139
|
-
)->toBe(true)
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
describe("GraphQL_Stitcher.rootTypeFieldNames", () => {
|
|
144
|
-
testSync("lists Mutation field names", () => {
|
|
145
|
-
expect(rootTypeFieldNames(~sdl=fullSchemaSdl, ~typeName="Mutation"))->toEqual([
|
|
146
|
-
"Platform_connectPlugin",
|
|
147
|
-
"Catalog_addProduct",
|
|
148
|
-
"Catalog_updateProduct",
|
|
149
|
-
"Ordering_placeOrder",
|
|
150
|
-
])
|
|
151
|
-
})
|
|
152
|
-
testSync("strips args and @aws_auth directive lines", () => {
|
|
153
|
-
expect(rootTypeFieldNames(~sdl=authAnnotatedSdl, ~typeName="Mutation"))->toEqual([
|
|
154
|
-
"Platform_connectPlugin",
|
|
155
|
-
"Catalog_addProduct",
|
|
156
|
-
])
|
|
157
|
-
})
|
|
158
|
-
testSync("missing type returns []", () => {
|
|
159
|
-
expect(rootTypeFieldNames(~sdl=fullSchemaSdl, ~typeName="Subscription"))->toEqual([])
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
describe("GraphQL_Stitcher.missingRootFields", () => {
|
|
164
|
-
testSync("reports plugin fields absent from an admin-base clobber", () => {
|
|
165
|
-
// The alpha 2026-07-08 clobber: live schema is admin-base only. Every
|
|
166
|
-
// Catalog_*/Ordering_* field the deploy expects is missing → repair fires.
|
|
167
|
-
let missing = missingRootFields(~expectedSdl=fullSchemaSdl, ~liveSdl=collapsedSchemaSdl)
|
|
168
|
-
expect(missing->Array.includes("Catalog_addProduct"))->toBe(true)
|
|
169
|
-
expect(missing->Array.includes("Ordering_placeOrder"))->toBe(true)
|
|
170
|
-
expect(missing->Array.includes("Ordering_orders"))->toBe(true)
|
|
171
|
-
})
|
|
172
|
-
testSync("empty when live schema is a superset (intact)", () => {
|
|
173
|
-
expect(missingRootFields(~expectedSdl=fullSchemaSdl, ~liveSdl=fullSchemaSdl))->toEqual([])
|
|
174
|
-
})
|
|
175
|
-
testSync("detects an equal-cardinality field swap the count test misses", () => {
|
|
176
|
-
// Same number of root fields, but one Mutation field replaced by a foreign
|
|
177
|
-
// one — a swap. countRootTypeFields would report no drift; the name-set diff
|
|
178
|
-
// catches it.
|
|
179
|
-
let swapped = `type Query {
|
|
180
|
-
node(id: ID!): Node
|
|
181
|
-
Platform_plugins: [Plugin]
|
|
182
|
-
Catalog_products: [Product]
|
|
183
|
-
Ordering_orders: [Order]
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
type Mutation {
|
|
187
|
-
Platform_connectPlugin(input: ConnectInput): ConnectResult
|
|
188
|
-
Catalog_addProduct(input: AddInput): Product
|
|
189
|
-
Catalog_updateProduct(input: UpdateInput): Product
|
|
190
|
-
Foreign_strayField(input: OrderInput): Order
|
|
191
|
-
}`
|
|
192
|
-
// Same count on both sides.
|
|
193
|
-
expect(countRootTypeFields(~sdl=swapped, ~typeName="Mutation"))->toBe(
|
|
194
|
-
countRootTypeFields(~sdl=fullSchemaSdl, ~typeName="Mutation"),
|
|
195
|
-
)
|
|
196
|
-
// But the expected Ordering_placeOrder is missing from the live (swapped) schema.
|
|
197
|
-
let missing = missingRootFields(~expectedSdl=fullSchemaSdl, ~liveSdl=swapped)
|
|
198
|
-
expect(missing->Array.includes("Ordering_placeOrder"))->toBe(true)
|
|
199
|
-
})
|
|
200
|
-
})
|
|
201
|
-
|
|
202
4
|
describe("GraphQL_Stitcher.subscriptionSources", () => {
|
|
203
5
|
testSync("encode/decode round-trips the subscription→mutation source mapping", () => {
|
|
204
6
|
let fragment = encode({
|