@voxgig/sdkgen 4.44.2 → 4.45.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/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/AgentGuideFeature.js +2 -1
- package/dist/cmp/AgentGuideFeature.js.map +1 -1
- package/dist/helpers/facts.d.ts +3 -0
- package/dist/helpers/facts.js +57 -0
- package/dist/helpers/facts.js.map +1 -0
- package/dist/helpers/opShape.js +3 -6
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/shipped.d.ts +2 -1
- package/dist/helpers/shipped.js +4 -0
- package/dist/helpers/shipped.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -1
- package/dist/sdkgen.js +8 -4
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/model/fact.aontu +15 -0
- package/package.json +1 -1
- package/project/.sdk/tm/c/utility/make_point.c +9 -5
- package/project/.sdk/tm/clojure/src/sdk/core.clj +7 -1
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +15 -11
- package/project/.sdk/tm/csharp/utility/MakePoint.cs +19 -15
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +13 -1
- package/project/.sdk/tm/go/utility/make_point.go +16 -12
- package/project/.sdk/tm/java/utility/MakePoint.java +18 -13
- package/project/.sdk/tm/js/src/utility/MakePointUtility.js +13 -6
- package/project/.sdk/tm/kotlin/utility/MakePoint.kt +17 -12
- package/project/.sdk/tm/lua/utility/make_point.lua +14 -10
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +8 -4
- package/project/.sdk/tm/perl/utility/make_point.pm +8 -4
- package/project/.sdk/tm/php/utility/MakePoint.php +9 -4
- package/project/.sdk/tm/py/pkg/utility/make_point.py +12 -8
- package/project/.sdk/tm/rb/utility/make_point.rb +8 -4
- package/project/.sdk/tm/rust/utility/make_point.rs +12 -8
- package/project/.sdk/tm/scala/utility/Make.scala +8 -4
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/Make.swift +14 -11
- package/project/.sdk/tm/ts/src/utility/MakePointUtility.ts +13 -6
- package/project/.sdk/tm/zig/core/utility.zig +8 -5
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/AgentGuideFeature.ts +2 -1
- package/src/helpers/facts.ts +74 -0
- package/src/helpers/opShape.ts +3 -7
- package/src/helpers/shipped.ts +5 -0
- package/src/sdkgen.ts +5 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
|
|
3
|
+
import { Aontu } from 'aontu'
|
|
4
|
+
import { KIT } from '@voxgig/apidef'
|
|
5
|
+
|
|
6
|
+
import { factRulesFile } from './shipped'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// No fact rule reads these, and they are most of a large model.
|
|
10
|
+
const UNREAD = ['entity', 'flow']
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function isMap(v: any): boolean {
|
|
14
|
+
return null != v && 'object' === typeof v && !Array.isArray(v)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function copyFacts(from: any, to: any): void {
|
|
19
|
+
for (const [key, val] of Object.entries(from)) {
|
|
20
|
+
if ('fact' === key) {
|
|
21
|
+
to.fact = val
|
|
22
|
+
}
|
|
23
|
+
else if (isMap(val) && isMap(to[key])) {
|
|
24
|
+
copyFacts(val, to[key])
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Computes every fact once and writes it into the model beside what it
|
|
31
|
+
// describes, as `fact`. Templates read facts with `fact`; none computes one.
|
|
32
|
+
function applyFacts(model: any): any {
|
|
33
|
+
const kit = model?.main?.[KIT]
|
|
34
|
+
if (!isMap(kit)) {
|
|
35
|
+
return model
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const input: any = {}
|
|
39
|
+
for (const [key, val] of Object.entries(kit)) {
|
|
40
|
+
if (!UNREAD.includes(key)) {
|
|
41
|
+
input[key] = val
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const path = factRulesFile()
|
|
46
|
+
const src = JSON.stringify({ main: { [KIT]: input } }).slice(1, -1) +
|
|
47
|
+
'\n' + readFileSync(path, 'utf8')
|
|
48
|
+
|
|
49
|
+
const errs: any[] = []
|
|
50
|
+
const out = new Aontu().generate(src, { path, errs })
|
|
51
|
+
if (0 < errs.length || null == out?.main?.[KIT]) {
|
|
52
|
+
throw new Error('sdkgen facts: the fact rules did not evaluate: ' +
|
|
53
|
+
errs.map((e: any) => `[${e.why}] ${e.msg}`).join(' | '))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
copyFacts(out.main[KIT], kit)
|
|
57
|
+
return model
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function fact(node: any, name: string): any {
|
|
62
|
+
const facts = node?.fact
|
|
63
|
+
if (!isMap(facts) || !(name in facts)) {
|
|
64
|
+
throw new Error(`sdkgen facts: '${node?.name ?? '?'}' has no fact '${name}': ` +
|
|
65
|
+
'the model did not pass through applyFacts, or lacks what the fact reads')
|
|
66
|
+
}
|
|
67
|
+
return facts[name]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
applyFacts,
|
|
73
|
+
fact,
|
|
74
|
+
}
|
package/src/helpers/opShape.ts
CHANGED
|
@@ -140,24 +140,20 @@ function samePath(points: any[]): boolean {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
// The rule makePoint applies
|
|
144
|
-
//
|
|
143
|
+
// The rule makePoint applies to a call without an action: only a point
|
|
144
|
+
// without one, and one the call fills.
|
|
145
145
|
function opReachable(op: any, given: string[]): boolean {
|
|
146
146
|
const points: any[] = op && op.points ? each(op.points) : []
|
|
147
147
|
const have = new Set(given)
|
|
148
148
|
const fills = (pt: any) => pointPlaceholders(pt).every((name) => have.has(name))
|
|
149
149
|
|
|
150
|
-
if (1 === points.length) {
|
|
151
|
-
return fills(points[0])
|
|
152
|
-
}
|
|
153
|
-
|
|
154
150
|
return points.some((pt: any) => null == (pt && pt.q && pt.q['$action']) && fills(pt))
|
|
155
151
|
}
|
|
156
152
|
|
|
157
153
|
|
|
158
154
|
function opNeedsAction(op: any): boolean {
|
|
159
155
|
const points: any[] = op && op.points ? each(op.points) : []
|
|
160
|
-
return
|
|
156
|
+
return 0 < points.length &&
|
|
161
157
|
points.every((pt: any) => null != (pt && pt.q && pt.q['$action']))
|
|
162
158
|
}
|
|
163
159
|
|
package/src/helpers/shipped.ts
CHANGED
package/src/sdkgen.ts
CHANGED
|
@@ -65,6 +65,7 @@ import { getMatchEntries } from './helpers/getMatchEntries'
|
|
|
65
65
|
import { collectDeps } from './helpers/collectDeps'
|
|
66
66
|
import { guardModelNames } from './helpers/modelNames'
|
|
67
67
|
import { guardFlowSteps } from './helpers/flowGuard'
|
|
68
|
+
import { applyFacts, fact } from './helpers/facts'
|
|
68
69
|
import { claimedFiles, pruneGenerated } from './helpers/generated'
|
|
69
70
|
import { cmp as labelledCmp } from './helpers/component'
|
|
70
71
|
import type { DepEntry } from './helpers/collectDeps'
|
|
@@ -332,6 +333,8 @@ function SdkGen(opts: SdkGenOptions) {
|
|
|
332
333
|
// generated test makes it; see helpers/flowGuard.
|
|
333
334
|
guardFlowSteps(model, log)
|
|
334
335
|
|
|
336
|
+
applyFacts(model)
|
|
337
|
+
|
|
335
338
|
let Root = spec.root
|
|
336
339
|
|
|
337
340
|
if (null == Root && null != config?.root) {
|
|
@@ -1190,6 +1193,8 @@ export {
|
|
|
1190
1193
|
entityCollection,
|
|
1191
1194
|
guardModelNames,
|
|
1192
1195
|
guardFlowSteps,
|
|
1196
|
+
applyFacts,
|
|
1197
|
+
fact,
|
|
1193
1198
|
projectConst,
|
|
1194
1199
|
isReservedName,
|
|
1195
1200
|
safeVarName,
|