@reventlessdev/reventless-local 3.0.0-alpha.198 → 3.0.0-alpha.200
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 +8 -8
- package/src/Platform.res +70 -49
- package/src/Platform.res.mjs +12 -10
- package/src/adapter/LocalGeocodeResolvers.res +63 -0
- package/src/adapter/LocalGeocodeResolvers.res.mjs +58 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.200 (2026-08-04)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **admin:** serve the complete plugin structure to developer tooling ([e99cda0](https://github.com/ReventlessDev/reventless-core/commit/e99cda02a2f862b36bcfdb018a0fb34bb7426a2b))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# 3.0.0-alpha.199 (2026-08-04)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **geocoding:** serve geocoding through the platform GraphQL API (D9 half 2) ([914d3c0](https://github.com/ReventlessDev/reventless-core/commit/914d3c0a99a1b67ffb89e2b8259dd30f67ff9bae))
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
# 3.0.0-alpha.198 (2026-08-04)
|
|
7
21
|
|
|
8
22
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-local",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.200",
|
|
4
4
|
"description": "Local platform for Reventless (in-memory or SQLite backend, for development and testing without AWS)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"graphql-yoga": "^5.21.0",
|
|
35
35
|
"sury": "11.0.0-alpha.4",
|
|
36
36
|
"ws": "^8.18.0",
|
|
37
|
-
"@reventlessdev/rescript-graphql-yoga": "1.0.0-alpha.26",
|
|
38
37
|
"@reventlessdev/rescript-effect": "0.1.0-alpha.32",
|
|
39
38
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.10",
|
|
40
|
-
"@reventlessdev/rescript-node": "2.0.0-alpha.1",
|
|
41
39
|
"@reventlessdev/rescript-mcp-sdk": "1.0.0-alpha.21",
|
|
40
|
+
"@reventlessdev/rescript-node": "2.0.0-alpha.1",
|
|
42
41
|
"@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.18",
|
|
43
|
-
"@reventlessdev/
|
|
44
|
-
"@reventlessdev/reventless-
|
|
45
|
-
"@reventlessdev/reventless-
|
|
46
|
-
"@reventlessdev/reventless-
|
|
42
|
+
"@reventlessdev/rescript-graphql-yoga": "1.0.0-alpha.26",
|
|
43
|
+
"@reventlessdev/reventless-core": "3.0.0-alpha.212",
|
|
44
|
+
"@reventlessdev/reventless-graphql-server": "1.0.0-alpha.60",
|
|
45
|
+
"@reventlessdev/reventless-gwt": "1.0.0-alpha.159",
|
|
46
|
+
"@reventlessdev/reventless-postgres": "3.0.0-alpha.76",
|
|
47
47
|
"@reventlessdev/reventless-spec": "3.0.0-alpha.100",
|
|
48
|
-
"@reventlessdev/reventless-
|
|
48
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.126"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"rescript": "12.3.0",
|
package/src/Platform.res
CHANGED
|
@@ -1635,60 +1635,78 @@ module MakeWithConfig = (
|
|
|
1635
1635
|
// whose Plugin RM row is not Connected are hidden until reactivated. The built-in
|
|
1636
1636
|
// Platform_Admin entry has no Plugin RM row — include it unconditionally since
|
|
1637
1637
|
// it can't be deactivated.
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
)
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1638
|
+
// The plugins both structure queries answer over: one entry per plugin name,
|
|
1639
|
+
// Connected only, highest version. Shared so the two fields can never disagree
|
|
1640
|
+
// about which plugins exist — mirrors the single Lambda serving both fields on
|
|
1641
|
+
// the AWS side.
|
|
1642
|
+
let connectedLatestStructures = () => {
|
|
1643
|
+
let pluginStatusById = {
|
|
1644
|
+
let dict = Dict.make()
|
|
1645
|
+
switch Bus.getQueryDbScan(pluginQueryDbName) {
|
|
1646
|
+
| Some(scanAll) =>
|
|
1647
|
+
scanAll()->Array.forEach(json =>
|
|
1648
|
+
switch json->S.convertOrThrow(ReventlessCore.PluginsReadModelSpec.stateSchema) {
|
|
1649
|
+
| state =>
|
|
1650
|
+
let id = state.name ++ "@" ++ state.version
|
|
1651
|
+
dict->Dict.set(id, state.status)
|
|
1652
|
+
| exception _ => ()
|
|
1653
|
+
}
|
|
1654
|
+
)
|
|
1655
|
+
| None => ()
|
|
1656
1656
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1657
|
+
dict
|
|
1658
|
+
}
|
|
1659
|
+
let adminPluginId = ReventlessCore.Platform_Admin_Structure.pluginId
|
|
1660
|
+
// One entry per plugin name: among Connected versions keep the highest
|
|
1661
|
+
// version, enforcing the deploy-time one-version-per-plugin invariant.
|
|
1662
|
+
// Without this, a lingering Connected older version (rolling deploy or a
|
|
1663
|
+
// missed retire) surfaces a full duplicate set of AutoUI menu entries —
|
|
1664
|
+
// mirrors the dedup in Platform_ComponentDefinitions_Lambda.res.
|
|
1665
|
+
let latestByName = Dict.make()
|
|
1666
|
+
pluginStructuresStore.contents
|
|
1667
|
+
->Dict.toArray
|
|
1668
|
+
->Array.forEach(((pluginId, def)) => {
|
|
1669
|
+
let connected =
|
|
1670
|
+
pluginId === adminPluginId ||
|
|
1671
|
+
switch pluginStatusById->Dict.get(pluginId) {
|
|
1672
|
+
| Some(Connected) => true
|
|
1673
|
+
| _ => false
|
|
1674
|
+
}
|
|
1675
|
+
if connected {
|
|
1676
|
+
let name = ReventlessCore.Plugin.name(pluginId)
|
|
1677
|
+
let version = ReventlessCore.Plugin.version(pluginId)
|
|
1678
|
+
switch latestByName->Dict.get(name) {
|
|
1679
|
+
| Some((prevVersion, _)) =>
|
|
1680
|
+
if ReventlessCore.Plugin.compareVersions(version, prevVersion) > 0 {
|
|
1681
|
+
latestByName->Dict.set(name, (version, (pluginId, def)))
|
|
1682
1682
|
}
|
|
1683
|
+
| None => latestByName->Dict.set(name, (version, (pluginId, def)))
|
|
1683
1684
|
}
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1685
|
+
}
|
|
1686
|
+
})
|
|
1687
|
+
latestByName->Dict.valuesToArray->Array.map(((_, pair)) => pair)
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
queryResolvers->Dict.set(
|
|
1691
|
+
"Platform_ComponentDefinitions",
|
|
1692
|
+
async (_root, _args, _ctx): JSON.t =>
|
|
1693
|
+
connectedLatestStructures()
|
|
1694
|
+
->Array.map(((pluginId, def)) =>
|
|
1688
1695
|
ReventlessCore.Platform_ComponentDefinitionsApi.encodePluginStructureEntry(~pluginId, def)
|
|
1689
1696
|
)
|
|
1690
|
-
->JSON.Encode.array
|
|
1691
|
-
|
|
1697
|
+
->JSON.Encode.array,
|
|
1698
|
+
)
|
|
1699
|
+
|
|
1700
|
+
// Platform_PluginStructures resolver — the same plugins, encoded unfiltered for
|
|
1701
|
+
// developer tooling (Internal components kept, extension points carried).
|
|
1702
|
+
queryResolvers->Dict.set(
|
|
1703
|
+
"Platform_PluginStructures",
|
|
1704
|
+
async (_root, _args, _ctx): JSON.t =>
|
|
1705
|
+
connectedLatestStructures()
|
|
1706
|
+
->Array.map(((pluginId, def)) =>
|
|
1707
|
+
ReventlessCore.Platform_PluginStructuresApi.encodePluginStructureEntry(~pluginId, def)
|
|
1708
|
+
)
|
|
1709
|
+
->JSON.Encode.array,
|
|
1692
1710
|
)
|
|
1693
1711
|
|
|
1694
1712
|
// Platform_UIFragments resolver — reads the UiFragments StateViewSlice
|
|
@@ -1938,6 +1956,9 @@ module MakeWithConfig = (
|
|
|
1938
1956
|
// Upload service (route B) on the domain server — mirrors adding it to
|
|
1939
1957
|
// `domainBaseFragment` on AWS.
|
|
1940
1958
|
LocalUploadResolvers.register(DomainGraphQL_Server.asInterface)
|
|
1959
|
+
// Geocoding client door (D9 half 2) on the domain server — same mirror. A dev
|
|
1960
|
+
// stub (no real geocoder locally), so the map picker's search box works offline.
|
|
1961
|
+
LocalGeocodeResolvers.register(DomainGraphQL_Server.asInterface)
|
|
1941
1962
|
// In split mode, inject Relay base types (Node interface, PageInfo) into the platform
|
|
1942
1963
|
// server so SDL fragments compile. The node(id) query is Domain-only — the Platform
|
|
1943
1964
|
// API is consumed by admin tools and agents, not Relay clients.
|
package/src/Platform.res.mjs
CHANGED
|
@@ -61,6 +61,7 @@ import * as EventPublish_Callback$ReventlessCore from "@reventlessdev/reventless
|
|
|
61
61
|
import * as LocalUploadResolvers$ReventlessLocal from "./adapter/LocalUploadResolvers.res.mjs";
|
|
62
62
|
import * as ProjectionCheckpoint$ReventlessLocal from "./adapter/ProjectionCheckpoint.res.mjs";
|
|
63
63
|
import * as ExtensionPointMapping$ReventlessInfra from "@reventlessdev/reventless-infra/src/types/ExtensionPointMapping.res.mjs";
|
|
64
|
+
import * as LocalGeocodeResolvers$ReventlessLocal from "./adapter/LocalGeocodeResolvers.res.mjs";
|
|
64
65
|
import * as UiFragments_Projection$ReventlessCore from "@reventlessdev/reventless-core/src/admin/UiFragmentRegistry/StateViewSlice/UiFragments_Projection.res.mjs";
|
|
65
66
|
import * as EventLogStorage_Sqlite$ReventlessLocal from "./adapter/EventLog/EventLogStorage_Sqlite.res.mjs";
|
|
66
67
|
import * as ExtensionPoint_Builder$ReventlessLocal from "./components/ExtensionPoint_Builder.res.mjs";
|
|
@@ -79,6 +80,7 @@ import * as DcbEventLogStorage_Sqlite$ReventlessLocal from "./adapter/DcbEventLo
|
|
|
79
80
|
import * as LocalEventCollectorChannel$ReventlessLocal from "./adapter/EventCollector/LocalEventCollectorChannel.res.mjs";
|
|
80
81
|
import * as PluginRuntime_Builder_Micro$ReventlessCore from "@reventlessdev/reventless-core/src/adapter/Runtime/PluginRuntime_Builder_Micro.res.mjs";
|
|
81
82
|
import * as UiFragmentRegistry_Behavior$ReventlessCore from "@reventlessdev/reventless-core/src/admin/UiFragmentRegistry/StateChangeSlice/UiFragmentRegistry_Behavior.res.mjs";
|
|
83
|
+
import * as Platform_PluginStructuresApi$ReventlessCore from "@reventlessdev/reventless-core/src/admin/Platform_PluginStructuresApi.res.mjs";
|
|
82
84
|
import * as EventHistoryResolvers_GraphQL$ReventlessLocal from "./adapter/EventHistory/EventHistoryResolvers_GraphQL.res.mjs";
|
|
83
85
|
import * as InboundTranslationSlice_Builder$ReventlessLocal from "./components/InboundTranslationSlice_Builder.res.mjs";
|
|
84
86
|
import * as Platform_ComponentDefinitionsApi$ReventlessCore from "@reventlessdev/reventless-core/src/admin/Platform_ComponentDefinitionsApi.res.mjs";
|
|
@@ -1340,7 +1342,7 @@ function MakeWithConfig(Config) {
|
|
|
1340
1342
|
let scanAll = Bus.getQueryDbScan(PluginsReadModelSpec$ReventlessCore.name);
|
|
1341
1343
|
return connectionResponse(scanAll !== undefined ? scanAll() : []);
|
|
1342
1344
|
};
|
|
1343
|
-
|
|
1345
|
+
let connectedLatestStructures = () => {
|
|
1344
1346
|
let dict = {};
|
|
1345
1347
|
let scanAll = Bus.getQueryDbScan(PluginsReadModelSpec$ReventlessCore.name);
|
|
1346
1348
|
if (scanAll !== undefined) {
|
|
@@ -1385,11 +1387,10 @@ function MakeWithConfig(Config) {
|
|
|
1385
1387
|
return;
|
|
1386
1388
|
}
|
|
1387
1389
|
});
|
|
1388
|
-
return Object.values(latestByName).map(param =>
|
|
1389
|
-
let match = param[1];
|
|
1390
|
-
return Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry(match[0], match[1]);
|
|
1391
|
-
});
|
|
1390
|
+
return Object.values(latestByName).map(param => param[1]);
|
|
1392
1391
|
};
|
|
1392
|
+
queryResolvers["Platform_ComponentDefinitions"] = async (_root, _args, _ctx) => connectedLatestStructures().map(param => Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry(param[0], param[1]));
|
|
1393
|
+
queryResolvers["Platform_PluginStructures"] = async (_root, _args, _ctx) => connectedLatestStructures().map(param => Platform_PluginStructuresApi$ReventlessCore.encodePluginStructureEntry(param[0], param[1]));
|
|
1393
1394
|
queryResolvers["Platform_UIFragments"] = async (_root, _args, _ctx) => {
|
|
1394
1395
|
let scanAll = Bus.getQueryDbScan(UiFragments$ReventlessCore.name);
|
|
1395
1396
|
let items = scanAll !== undefined ? scanAll() : [];
|
|
@@ -1559,6 +1560,7 @@ function MakeWithConfig(Config) {
|
|
|
1559
1560
|
DomainGraphQL_Server$ReventlessLocal.registerTypes(GraphQL_Stitcher$ReventlessCore.relayBaseTypes);
|
|
1560
1561
|
DomainGraphQL_Server$ReventlessLocal.registerQueries(GraphQL_Stitcher$ReventlessCore.relayBaseQueries, {});
|
|
1561
1562
|
LocalUploadResolvers$ReventlessLocal.register(DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
1563
|
+
LocalGeocodeResolvers$ReventlessLocal.register(DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
1562
1564
|
if (Config.splitApi) {
|
|
1563
1565
|
PlatformGraphQL_Server$ReventlessLocal.registerTypes(GraphQL_Stitcher$ReventlessCore.relayBaseTypes);
|
|
1564
1566
|
}
|
|
@@ -3025,7 +3027,7 @@ function Make($star) {
|
|
|
3025
3027
|
let scanAll = Bus.getQueryDbScan(PluginsReadModelSpec$ReventlessCore.name);
|
|
3026
3028
|
return connectionResponse(scanAll !== undefined ? scanAll() : []);
|
|
3027
3029
|
};
|
|
3028
|
-
|
|
3030
|
+
let connectedLatestStructures = () => {
|
|
3029
3031
|
let dict = {};
|
|
3030
3032
|
let scanAll = Bus.getQueryDbScan(PluginsReadModelSpec$ReventlessCore.name);
|
|
3031
3033
|
if (scanAll !== undefined) {
|
|
@@ -3070,11 +3072,10 @@ function Make($star) {
|
|
|
3070
3072
|
return;
|
|
3071
3073
|
}
|
|
3072
3074
|
});
|
|
3073
|
-
return Object.values(latestByName).map(param =>
|
|
3074
|
-
let match = param[1];
|
|
3075
|
-
return Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry(match[0], match[1]);
|
|
3076
|
-
});
|
|
3075
|
+
return Object.values(latestByName).map(param => param[1]);
|
|
3077
3076
|
};
|
|
3077
|
+
queryResolvers["Platform_ComponentDefinitions"] = async (_root, _args, _ctx) => connectedLatestStructures().map(param => Platform_ComponentDefinitionsApi$ReventlessCore.encodePluginStructureEntry(param[0], param[1]));
|
|
3078
|
+
queryResolvers["Platform_PluginStructures"] = async (_root, _args, _ctx) => connectedLatestStructures().map(param => Platform_PluginStructuresApi$ReventlessCore.encodePluginStructureEntry(param[0], param[1]));
|
|
3078
3079
|
queryResolvers["Platform_UIFragments"] = async (_root, _args, _ctx) => {
|
|
3079
3080
|
let scanAll = Bus.getQueryDbScan(UiFragments$ReventlessCore.name);
|
|
3080
3081
|
let items = scanAll !== undefined ? scanAll() : [];
|
|
@@ -3244,6 +3245,7 @@ function Make($star) {
|
|
|
3244
3245
|
DomainGraphQL_Server$ReventlessLocal.registerTypes(GraphQL_Stitcher$ReventlessCore.relayBaseTypes);
|
|
3245
3246
|
DomainGraphQL_Server$ReventlessLocal.registerQueries(GraphQL_Stitcher$ReventlessCore.relayBaseQueries, {});
|
|
3246
3247
|
LocalUploadResolvers$ReventlessLocal.register(DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
3248
|
+
LocalGeocodeResolvers$ReventlessLocal.register(DomainGraphQL_Server$ReventlessLocal.asInterface);
|
|
3247
3249
|
PlatformGraphQL_Server$ReventlessLocal.registerTypes(GraphQL_Stitcher$ReventlessCore.relayBaseTypes);
|
|
3248
3250
|
currentDeployTarget.contents = "Domain";
|
|
3249
3251
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Local geocode resolver — the *client* door of the geocoding capability (D9 half
|
|
2
|
+
// 2) on the dev platform. Registers `Query.geocode` on the domain server the same
|
|
3
|
+
// way `LocalUploadResolvers` registers `Upload_Presign`, which is the local analogue
|
|
4
|
+
// of adding the field to `domainBaseFragment` on AWS.
|
|
5
|
+
//
|
|
6
|
+
// This closes a dev-experience gap: before it, `config.geocoderEndpoint` was unset
|
|
7
|
+
// in local dev, so the map picker's search box did not render at all and the input
|
|
8
|
+
// was click-to-place only. With this door registered, address search works in dev.
|
|
9
|
+
//
|
|
10
|
+
// The dev platform provisions no real geocoder — `LocalCapabilities` keeps the
|
|
11
|
+
// *unattended* slice path at `Capabilities.none`, and the two doors are
|
|
12
|
+
// independent. This browser door is a deterministic stub: a non-empty query
|
|
13
|
+
// resolves to one candidate whose point is a stable function of the query text, so
|
|
14
|
+
// a search places a pin, in the same spot every time, with no network call or API
|
|
15
|
+
// key. The coordinates are placeholders — echoed back beside the query as the label
|
|
16
|
+
// — not a real geocode. An empty query yields no results, matching the AWS door and
|
|
17
|
+
// the browser's cleared-input case.
|
|
18
|
+
|
|
19
|
+
// A stable, in-range `(lat, lng)` derived from the query text: fold the character
|
|
20
|
+
// codes into one number and map it into safe coordinate bands. Deterministic, so a
|
|
21
|
+
// dev search is reproducible across reloads.
|
|
22
|
+
let stubPoint = (text: string): (float, float) => {
|
|
23
|
+
let sum = ref(0)
|
|
24
|
+
for i in 0 to text->String.length - 1 {
|
|
25
|
+
let code = text->String.codePointAt(i)->Option.getOr(0)
|
|
26
|
+
sum := sum.contents + code * (i + 1)
|
|
27
|
+
}
|
|
28
|
+
let n = sum.contents
|
|
29
|
+
let lat = mod(n, 120)->Int.toFloat -. 60.0 // −60 … 59
|
|
30
|
+
let lng = mod(n / 7, 240)->Int.toFloat -. 120.0 // −120 … 119
|
|
31
|
+
(lat, lng)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let register = (server: ReventlessGraphqlServer.GraphQL_ServerInstance.t): unit => {
|
|
35
|
+
let resolvers = Dict.make()
|
|
36
|
+
resolvers->Dict.set("geocode", async (_root, args, _ctx): JSON.t => {
|
|
37
|
+
let obj = args->JSON.Decode.object->Option.getOr(Dict.make())
|
|
38
|
+
let text =
|
|
39
|
+
obj
|
|
40
|
+
->Dict.get("text")
|
|
41
|
+
->Option.flatMap(JSON.Decode.string)
|
|
42
|
+
->Option.getOr("")
|
|
43
|
+
->String.trim
|
|
44
|
+
if text == "" {
|
|
45
|
+
JSON.Encode.array([])
|
|
46
|
+
} else {
|
|
47
|
+
let (lat, lng) = stubPoint(text)
|
|
48
|
+
let candidate =
|
|
49
|
+
Dict.fromArray([
|
|
50
|
+
("label", JSON.Encode.string(text)),
|
|
51
|
+
("lat", JSON.Encode.float(lat)),
|
|
52
|
+
("lng", JSON.Encode.float(lng)),
|
|
53
|
+
("relevance", JSON.Encode.float(1.0)),
|
|
54
|
+
])->JSON.Encode.object
|
|
55
|
+
JSON.Encode.array([candidate])
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
server.registerTypes(~sdlTypes=ReventlessCore.Platform_AdminApi.geocodeTypes)
|
|
59
|
+
server.registerQueries(
|
|
60
|
+
~sdlFields=ReventlessCore.Platform_AdminApi.geocodeQueryFields,
|
|
61
|
+
~resolvers,
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 Platform_AdminApi$ReventlessCore from "@reventlessdev/reventless-core/src/admin/Platform_AdminApi.res.mjs";
|
|
6
|
+
|
|
7
|
+
function stubPoint(text) {
|
|
8
|
+
let sum = 0;
|
|
9
|
+
for (let i = 0, i_finish = text.length; i < i_finish; ++i) {
|
|
10
|
+
let code = Stdlib_Option.getOr(text.codePointAt(i), 0);
|
|
11
|
+
sum = sum + (code * (i + 1 | 0) | 0) | 0;
|
|
12
|
+
}
|
|
13
|
+
let n = sum;
|
|
14
|
+
let lat = n % 120 - 60.0;
|
|
15
|
+
let lng = (n / 7 | 0) % 240 - 120.0;
|
|
16
|
+
return [
|
|
17
|
+
lat,
|
|
18
|
+
lng
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function register(server) {
|
|
23
|
+
let resolvers = {};
|
|
24
|
+
resolvers["geocode"] = async (_root, args, _ctx) => {
|
|
25
|
+
let obj = Stdlib_Option.getOr(Stdlib_JSON.Decode.object(args), {});
|
|
26
|
+
let text = Stdlib_Option.getOr(Stdlib_Option.flatMap(obj["text"], Stdlib_JSON.Decode.string), "").trim();
|
|
27
|
+
if (text === "") {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
let match = stubPoint(text);
|
|
31
|
+
return [Object.fromEntries([
|
|
32
|
+
[
|
|
33
|
+
"label",
|
|
34
|
+
text
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"lat",
|
|
38
|
+
match[0]
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
"lng",
|
|
42
|
+
match[1]
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"relevance",
|
|
46
|
+
1.0
|
|
47
|
+
]
|
|
48
|
+
])];
|
|
49
|
+
};
|
|
50
|
+
server.registerTypes(Platform_AdminApi$ReventlessCore.geocodeTypes);
|
|
51
|
+
server.registerQueries(Platform_AdminApi$ReventlessCore.geocodeQueryFields, resolvers);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
stubPoint,
|
|
56
|
+
register,
|
|
57
|
+
}
|
|
58
|
+
/* Platform_AdminApi-ReventlessCore Not a pure module */
|