@voxgig/sdkgen 4.45.0 → 4.46.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/action/check.js +15 -0
- package/dist/action/check.js.map +1 -1
- package/dist/action/copies.js +1 -0
- package/dist/action/copies.js.map +1 -1
- package/dist/action/doctor.d.ts +21 -2
- package/dist/action/doctor.js +166 -9
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/package.js +9 -0
- package/dist/action/package.js.map +1 -1
- package/dist/action/remove.js +2 -1
- package/dist/action/remove.js.map +1 -1
- package/dist/action/target.d.ts +2 -1
- package/dist/action/target.js +50 -11
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/AgentGuide.js +19 -8
- package/dist/cmp/AgentGuide.js.map +1 -1
- package/dist/cmp/AgentGuideContent.d.ts +6 -4
- package/dist/cmp/AgentGuideContent.js +51 -32
- package/dist/cmp/AgentGuideContent.js.map +1 -1
- package/dist/cmp/AgentGuideFeature.js +5 -3
- package/dist/cmp/AgentGuideFeature.js.map +1 -1
- package/dist/cmp/AgentGuideTop.js +84 -46
- package/dist/cmp/AgentGuideTop.js.map +1 -1
- package/dist/cmp/Changelog.js +12 -1
- package/dist/cmp/Changelog.js.map +1 -1
- package/dist/cmp/Deploy.js +22 -20
- package/dist/cmp/Deploy.js.map +1 -1
- package/dist/cmp/ExternalTarget.js +5 -5
- package/dist/cmp/ExternalTarget.js.map +1 -1
- package/dist/cmp/Feature.js +10 -3
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/FeatureDocs.d.ts +6 -4
- package/dist/cmp/FeatureDocs.js +14 -39
- package/dist/cmp/FeatureDocs.js.map +1 -1
- package/dist/cmp/FeatureHook.d.ts +7 -1
- package/dist/cmp/FeatureHook.js +34 -1
- package/dist/cmp/FeatureHook.js.map +1 -1
- package/dist/cmp/PublishWorkflow.js +30 -6
- package/dist/cmp/PublishWorkflow.js.map +1 -1
- package/dist/cmp/ReadmeErrors.js +521 -18
- package/dist/cmp/ReadmeErrors.js.map +1 -1
- package/dist/cmp/ReadmeExplanation.js +280 -44
- package/dist/cmp/ReadmeExplanation.js.map +1 -1
- package/dist/cmp/ReadmeFeatures.js +16 -7
- package/dist/cmp/ReadmeFeatures.js.map +1 -1
- package/dist/cmp/ReadmeIntro.js +3 -2
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeRefFeatures.js +34 -24
- package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
- package/dist/cmp/ReadmeStation.js +11 -8
- package/dist/cmp/ReadmeStation.js.map +1 -1
- package/dist/cmp/ReadmeTop.js +472 -373
- package/dist/cmp/ReadmeTop.js.map +1 -1
- package/dist/cmp/ReadmeUnions.js +8 -2
- package/dist/cmp/ReadmeUnions.js.map +1 -1
- package/dist/cmp/Security.js +3 -2
- package/dist/cmp/Security.js.map +1 -1
- package/dist/helpers/applicability.d.ts +2 -1
- package/dist/helpers/applicability.js +26 -0
- package/dist/helpers/applicability.js.map +1 -1
- package/dist/helpers/copymerge.d.ts +3 -0
- package/dist/helpers/copymerge.js +43 -10
- package/dist/helpers/copymerge.js.map +1 -1
- package/dist/helpers/doccheck.d.ts +11 -0
- package/dist/helpers/doccheck.js +146 -0
- package/dist/helpers/doccheck.js.map +1 -0
- package/dist/helpers/doctext.d.ts +11 -0
- package/dist/helpers/doctext.js +84 -0
- package/dist/helpers/doctext.js.map +1 -0
- package/dist/helpers/exampleCall.d.ts +16 -0
- package/dist/helpers/exampleCall.js +334 -0
- package/dist/helpers/exampleCall.js.map +1 -0
- package/dist/helpers/exportnames.d.ts +4 -0
- package/dist/helpers/exportnames.js +35 -0
- package/dist/helpers/exportnames.js.map +1 -0
- package/dist/helpers/facts.d.ts +2 -1
- package/dist/helpers/facts.js +37 -2
- package/dist/helpers/facts.js.map +1 -1
- package/dist/helpers/modelcheck.d.ts +2 -1
- package/dist/helpers/modelcheck.js +13 -0
- package/dist/helpers/modelcheck.js.map +1 -1
- package/dist/helpers/opExample.d.ts +9 -2
- package/dist/helpers/opExample.js +22 -2
- package/dist/helpers/opExample.js.map +1 -1
- package/dist/helpers/opShape.d.ts +2 -1
- package/dist/helpers/opShape.js +12 -0
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/packageMeta.js +21 -8
- package/dist/helpers/packageMeta.js.map +1 -1
- package/dist/helpers/semver.d.ts +2 -1
- package/dist/helpers/semver.js +7 -0
- package/dist/helpers/semver.js.map +1 -1
- package/dist/sdkgen.js +21 -2
- package/dist/sdkgen.js.map +1 -1
- package/dist/testkit.d.ts +1 -0
- package/dist/testkit.js +23 -19
- package/dist/testkit.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.js +2 -1
- package/dist/utility.js.map +1 -1
- package/model/fact.aontu +44 -0
- package/model/sdkgen.aontu +6 -2
- package/package.json +3 -1
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +1 -1
- package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
- package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +1 -0
- package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
- package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
- package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +2 -2
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/sdkgen-package.json +1 -1
- package/src/action/check.ts +21 -0
- package/src/action/copies.ts +2 -0
- package/src/action/doctor.ts +244 -13
- package/src/action/package.ts +10 -0
- package/src/action/remove.ts +2 -1
- package/src/action/target.ts +66 -15
- package/src/cmp/AgentGuide.ts +24 -10
- package/src/cmp/AgentGuideContent.ts +53 -32
- package/src/cmp/AgentGuideFeature.ts +6 -4
- package/src/cmp/AgentGuideTop.ts +108 -47
- package/src/cmp/Changelog.ts +13 -2
- package/src/cmp/Deploy.ts +23 -21
- package/src/cmp/ExternalTarget.ts +6 -6
- package/src/cmp/Feature.ts +11 -4
- package/src/cmp/FeatureDocs.ts +21 -40
- package/src/cmp/FeatureHook.ts +38 -1
- package/src/cmp/PublishWorkflow.ts +33 -7
- package/src/cmp/ReadmeErrors.ts +555 -25
- package/src/cmp/ReadmeExplanation.ts +316 -52
- package/src/cmp/ReadmeFeatures.ts +18 -8
- package/src/cmp/ReadmeIntro.ts +3 -2
- package/src/cmp/ReadmeRefFeatures.ts +39 -27
- package/src/cmp/ReadmeStation.ts +12 -14
- package/src/cmp/ReadmeTop.ts +528 -387
- package/src/cmp/ReadmeUnions.ts +10 -2
- package/src/cmp/Security.ts +3 -2
- package/src/helpers/applicability.ts +28 -0
- package/src/helpers/copymerge.ts +58 -10
- package/src/helpers/doccheck.ts +174 -0
- package/src/helpers/doctext.ts +113 -0
- package/src/helpers/exampleCall.ts +415 -0
- package/src/helpers/exportnames.ts +47 -0
- package/src/helpers/facts.ts +47 -2
- package/src/helpers/modelcheck.ts +16 -0
- package/src/helpers/opExample.ts +34 -2
- package/src/helpers/opShape.ts +13 -0
- package/src/helpers/packageMeta.ts +21 -8
- package/src/helpers/semver.ts +9 -0
- package/src/sdkgen.ts +27 -3
- package/src/testkit.ts +30 -20
- package/src/utility.ts +2 -1
|
@@ -10,10 +10,15 @@ import {
|
|
|
10
10
|
} from '../types'
|
|
11
11
|
|
|
12
12
|
import { optionalComponent } from '../helpers/optional'
|
|
13
|
+
import { honoursActivationOrder } from './FeatureDocs'
|
|
14
|
+
import { PIPELINE_STAGES, pipelineLength } from './FeatureHook'
|
|
13
15
|
|
|
14
16
|
import { entityIdField, pickExampleEntity } from '../helpers/opShape'
|
|
15
17
|
import { helperLang, idLiteral, matchArg, listMatchArg, dataArg } from '../helpers/opExample'
|
|
16
|
-
import {
|
|
18
|
+
import { exampleVarName, phpEntityAccessor } from '../helpers/naming'
|
|
19
|
+
import { exampleParts, entityName } from '../helpers/exampleCall'
|
|
20
|
+
import type { ExampleInput } from '../helpers/exampleCall'
|
|
21
|
+
import { originName } from '../helpers/packageMeta'
|
|
17
22
|
|
|
18
23
|
|
|
19
24
|
function cap(s: string): string {
|
|
@@ -21,33 +26,54 @@ function cap(s: string): string {
|
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
|
|
29
|
+
type StateExample = ExampleInput & {
|
|
30
|
+
eName: string
|
|
31
|
+
eLower: string
|
|
32
|
+
// The primary op's argument in the languages opExample writes.
|
|
33
|
+
arg: string
|
|
34
|
+
// The id key when the op is a match op, so the `.match()` comment can show
|
|
35
|
+
// `{ id: ... }`; else null.
|
|
36
|
+
matchIdF: string | null
|
|
37
|
+
idLit: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
24
41
|
type LangExplain = {
|
|
25
42
|
featureKind: string
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
// null (a generic comment).
|
|
31
|
-
entityState: (
|
|
32
|
-
eName: string, eLower: string,
|
|
33
|
-
op: string, arg: string,
|
|
34
|
-
matchIdF: string | null, idLit: string,
|
|
35
|
-
) => string
|
|
43
|
+
// Stateful-entity explanation and example, driven by the entity's PRIMARY
|
|
44
|
+
// op, never a hardcoded `load` a create-only entity lacks. A language
|
|
45
|
+
// without one has no entity object to keep state in, and writes nothing.
|
|
46
|
+
entityState?: (x: StateExample) => string
|
|
36
47
|
direct: string
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
|
|
51
|
+
// A language with no row writes neutral prose and no code.
|
|
40
52
|
const DEFAULT_LANG: LangExplain = {
|
|
53
|
+
featureKind: `Features are the extension mechanism. A feature implements hooks named
|
|
54
|
+
after the pipeline stages, and each hook receives the context.
|
|
55
|
+
|
|
56
|
+
`,
|
|
57
|
+
direct: `The \`direct\` method gives full control over the HTTP request. Use it
|
|
58
|
+
for non-standard endpoints, bulk operations, or any path not modelled
|
|
59
|
+
as an entity. The \`prepare\` method is useful for debugging — it
|
|
60
|
+
shows exactly what \`direct\` would send.
|
|
61
|
+
|
|
62
|
+
`,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const TS_EXPLAIN = (fence: string): LangExplain => ({
|
|
41
67
|
featureKind: `Features are the extension mechanism. A feature is an object with a
|
|
42
68
|
\`hooks\` map. Each hook key is a pipeline stage name, and the value is
|
|
43
69
|
a function that receives the context.
|
|
44
70
|
|
|
45
71
|
`,
|
|
46
|
-
entityState: (eName, eLower, op, arg, matchIdF, idLit) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
72
|
+
entityState: ({ eName, eLower, op, arg, matchIdF, idLit }) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
47
73
|
stores the returned data and match criteria internally. Subsequent
|
|
48
74
|
calls on the same instance can rely on this state.
|
|
49
75
|
|
|
50
|
-
|
|
76
|
+
\`\`\`${fence}
|
|
51
77
|
const ${eLower} = client.${eName}()
|
|
52
78
|
await ${eLower}.${op}(${arg})
|
|
53
79
|
|
|
@@ -59,14 +85,40 @@ Call \`make()\` to create a fresh instance with the same configuration
|
|
|
59
85
|
but no stored state.
|
|
60
86
|
|
|
61
87
|
`,
|
|
62
|
-
direct:
|
|
63
|
-
|
|
64
|
-
as an entity. The \`prepare\` method is useful for debugging — it
|
|
65
|
-
shows exactly what \`direct\` would send.
|
|
88
|
+
direct: DEFAULT_LANG.direct,
|
|
89
|
+
})
|
|
66
90
|
|
|
67
|
-
|
|
91
|
+
|
|
92
|
+
function featureClass(lang: string, point: string, spec: string, extra = ''): string {
|
|
93
|
+
return `Features are the extension mechanism. A feature is a ${lang} class${extra}
|
|
94
|
+
with hook methods named after pipeline stages (e.g. \`${point}\`,
|
|
95
|
+
\`${spec}\`). Each method receives the context.
|
|
96
|
+
|
|
97
|
+
`
|
|
68
98
|
}
|
|
69
99
|
|
|
100
|
+
function stateText(op: string, fence: string, code: string, make: string): string {
|
|
101
|
+
return `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
102
|
+
stores the returned data and match criteria internally.
|
|
103
|
+
|
|
104
|
+
\`\`\`${fence}
|
|
105
|
+
${code}
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
Call \`${make}\` to create a fresh instance with the same configuration
|
|
109
|
+
but no stored state.
|
|
110
|
+
|
|
111
|
+
`
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function directText(direct: string, prepare: string): string {
|
|
115
|
+
return `\`${direct}\` gives full control over the HTTP request. Use it for
|
|
116
|
+
non-standard endpoints, bulk operations, or any path not modelled as
|
|
117
|
+
an entity. \`${prepare}\` builds the request without sending it — useful
|
|
118
|
+
for debugging or custom transport.
|
|
119
|
+
|
|
120
|
+
`
|
|
121
|
+
}
|
|
70
122
|
|
|
71
123
|
const LANGS: Record<string, LangExplain> = {
|
|
72
124
|
py: {
|
|
@@ -75,7 +127,7 @@ with hook methods named after pipeline stages (e.g. \`PrePoint\`,
|
|
|
75
127
|
\`PreSpec\`). Each method receives the context.
|
|
76
128
|
|
|
77
129
|
`,
|
|
78
|
-
entityState: (eName, eLower, op, arg) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
130
|
+
entityState: ({ eName, eLower, op, arg }) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
79
131
|
stores the returned data and match criteria internally.
|
|
80
132
|
|
|
81
133
|
\`\`\`python
|
|
@@ -104,7 +156,7 @@ with hook methods named after pipeline stages (e.g. \`PrePoint\`,
|
|
|
104
156
|
\`PreSpec\`). Each method receives the context.
|
|
105
157
|
|
|
106
158
|
`,
|
|
107
|
-
entityState: (eName, eLower, op, arg) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
159
|
+
entityState: ({ eName, eLower, op, arg }) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
108
160
|
stores the returned data and match criteria internally.
|
|
109
161
|
|
|
110
162
|
\`\`\`php
|
|
@@ -133,7 +185,7 @@ with hook methods named after pipeline stages (e.g. \`PrePoint\`,
|
|
|
133
185
|
\`PreSpec\`). Each method receives the context.
|
|
134
186
|
|
|
135
187
|
`,
|
|
136
|
-
entityState: (eName, eLower, op, arg) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
188
|
+
entityState: ({ eName, eLower, op, arg }) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
137
189
|
stores the returned data and match criteria internally.
|
|
138
190
|
|
|
139
191
|
\`\`\`ruby
|
|
@@ -162,7 +214,7 @@ with hook methods named after pipeline stages (e.g. \`PrePoint\`,
|
|
|
162
214
|
\`PreSpec\`). Each method receives the context.
|
|
163
215
|
|
|
164
216
|
`,
|
|
165
|
-
entityState: (eName, eLower, op, arg) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
217
|
+
entityState: ({ eName, eLower, op, arg }) => `Entity instances are stateful. After a successful \`${op}\`, the entity
|
|
166
218
|
stores the returned data and match criteria internally.
|
|
167
219
|
|
|
168
220
|
\`\`\`lua
|
|
@@ -191,7 +243,7 @@ for debugging or custom transport.
|
|
|
191
243
|
stage names.
|
|
192
244
|
|
|
193
245
|
`,
|
|
194
|
-
entityState: (eName, eLower, op, arg) => `Entity instances are stateful. After a successful \`${cap(op)}\`, the entity
|
|
246
|
+
entityState: ({ eName, eLower, op, arg }) => `Entity instances are stateful. After a successful \`${cap(op)}\`, the entity
|
|
195
247
|
stores the returned data and match criteria internally.
|
|
196
248
|
|
|
197
249
|
\`\`\`go
|
|
@@ -213,6 +265,214 @@ for debugging or custom transport.
|
|
|
213
265
|
|
|
214
266
|
`,
|
|
215
267
|
},
|
|
268
|
+
|
|
269
|
+
ts: TS_EXPLAIN('ts'),
|
|
270
|
+
|
|
271
|
+
js: TS_EXPLAIN('js'),
|
|
272
|
+
|
|
273
|
+
c: {
|
|
274
|
+
featureKind: `Features are the extension mechanism. A feature is a struct whose first
|
|
275
|
+
member is a \`Feature\` holding its vtable. The vtable's \`hook\` function
|
|
276
|
+
receives each pipeline stage's name and the context.
|
|
277
|
+
|
|
278
|
+
`,
|
|
279
|
+
entityState: (x) => {
|
|
280
|
+
const { v, factory, arg } = exampleParts('c', x)
|
|
281
|
+
return stateText(x.op, 'c', `Entity* ${v} = ${factory};
|
|
282
|
+
PNError* err = NULL;
|
|
283
|
+
${v}->vt->${x.op}(${v}, ${arg}, NULL, &err);
|
|
284
|
+
|
|
285
|
+
// ${v}->vt->data(${v}, NULL) now returns the ${v} data from the last ${x.op}
|
|
286
|
+
// ${v}->vt->matchv(${v}, NULL) returns the last match criteria`, 'vt->make')
|
|
287
|
+
},
|
|
288
|
+
direct: directText('sdk_direct()', 'sdk_prepare()'),
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
cpp: {
|
|
292
|
+
featureKind: `Features are the extension mechanism. A feature is a class derived from
|
|
293
|
+
\`Feature\` that overrides a method per pipeline stage (e.g. \`prePoint\`,
|
|
294
|
+
\`preSpec\`). Each method receives the context.
|
|
295
|
+
|
|
296
|
+
`,
|
|
297
|
+
entityState: (x) => {
|
|
298
|
+
const { v, factory, arg } = exampleParts('cpp', x)
|
|
299
|
+
return stateText(x.op, 'cpp', `auto ${v} = ${factory};
|
|
300
|
+
${v}->${x.op}(${arg}, Value::undef());
|
|
301
|
+
|
|
302
|
+
// ${v}->data() now returns the ${v} data from the last ${x.op}
|
|
303
|
+
// ${v}->match() returns the last match criteria`, 'make()')
|
|
304
|
+
},
|
|
305
|
+
direct: directText('direct()', 'prepare()'),
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
rust: {
|
|
309
|
+
featureKind: `Features are the extension mechanism. A feature implements the \`Feature\`
|
|
310
|
+
trait, which has a method per pipeline stage (e.g. \`pre_point\`,
|
|
311
|
+
\`pre_spec\`). Each method receives the context.
|
|
312
|
+
|
|
313
|
+
`,
|
|
314
|
+
entityState: (x) => {
|
|
315
|
+
const { v, factory, arg } = exampleParts('rust', x)
|
|
316
|
+
return stateText(x.op, 'rust', `let ${v} = ${factory};
|
|
317
|
+
let _ = ${v}.${x.op}(${arg}, Value::Noval);
|
|
318
|
+
|
|
319
|
+
// ${v}.data(None) now returns the ${v} data from the last ${x.op}
|
|
320
|
+
// ${v}.matchv(None) returns the last match criteria`, 'make()')
|
|
321
|
+
},
|
|
322
|
+
direct: directText('direct()', 'prepare()'),
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
zig: {
|
|
326
|
+
featureKind: `Features are the extension mechanism. A feature is a \`Feature\` whose
|
|
327
|
+
\`dispatch\` function receives each pipeline stage's name and the context.
|
|
328
|
+
|
|
329
|
+
`,
|
|
330
|
+
entityState: (x) => {
|
|
331
|
+
const { v, factory, arg } = exampleParts('zig', x)
|
|
332
|
+
return stateText(x.op, 'zig', `const ${v} = ${factory};
|
|
333
|
+
switch (${v}.${x.op}(${arg}, h.vnull())) {
|
|
334
|
+
.ok => {},
|
|
335
|
+
.err => |e| std.debug.print("${x.op} failed: {s}\\n", .{e.msg}),
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// ${v}.asEntity().data(null) now returns the ${v} data from the last ${x.op}
|
|
339
|
+
// ${v}.asEntity().matchv(null) returns the last match criteria`, 'asEntity().makeEnt()')
|
|
340
|
+
},
|
|
341
|
+
direct: directText('direct()', 'prepare()'),
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
ocaml: {
|
|
345
|
+
featureKind: `Features are the extension mechanism. A feature is a \`feature\` record
|
|
346
|
+
whose \`f_hook\` function receives each pipeline stage's name and the context.
|
|
347
|
+
|
|
348
|
+
`,
|
|
349
|
+
entityState: (x) => {
|
|
350
|
+
const { v, factory, arg } = exampleParts('ocaml', x)
|
|
351
|
+
return stateText(x.op, 'ocaml', `let ${v} = ${factory} in
|
|
352
|
+
ignore (${v}.e_${x.op} ${arg} Noval)
|
|
353
|
+
(* ${v}.e_data_get () now returns the ${v} data from the last e_${x.op} *)
|
|
354
|
+
(* ${v}.e_match_get () returns the last match criteria *)`, 'e_make')
|
|
355
|
+
},
|
|
356
|
+
direct: directText('Sdk_client.direct', 'Sdk_client.prepare'),
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
perl: {
|
|
360
|
+
featureKind: featureClass('Perl', 'PrePoint', 'PreSpec'),
|
|
361
|
+
entityState: (x) => {
|
|
362
|
+
const { v, factory, arg } = exampleParts('perl', x)
|
|
363
|
+
return stateText(x.op, 'perl', `my $${v} = ${factory};
|
|
364
|
+
$${v}->${x.op}(${arg});
|
|
365
|
+
|
|
366
|
+
# $${v}->data_get now returns the ${v} data from the last ${x.op}
|
|
367
|
+
# $${v}->match_get returns the last match criteria`, 'make')
|
|
368
|
+
},
|
|
369
|
+
direct: directText('direct', 'prepare'),
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
java: {
|
|
373
|
+
featureKind: featureClass('Java', 'prePoint', 'preSpec', ' extending `BaseFeature`'),
|
|
374
|
+
entityState: (x) => {
|
|
375
|
+
const { v, factory, arg } = exampleParts('java', x)
|
|
376
|
+
return stateText(x.op, 'java', `SdkEntity ${v} = ${factory};
|
|
377
|
+
${v}.${x.op}(${arg}, null);
|
|
378
|
+
|
|
379
|
+
// ${v}.data() now returns the ${v} data from the last ${x.op}
|
|
380
|
+
// ${v}.match() returns the last match criteria`, 'make()')
|
|
381
|
+
},
|
|
382
|
+
direct: directText('direct()', 'prepare()'),
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
kotlin: {
|
|
386
|
+
featureKind: featureClass('Kotlin', 'prePoint', 'preSpec', ' extending `BaseFeature`'),
|
|
387
|
+
entityState: (x) => {
|
|
388
|
+
const { v, factory, arg } = exampleParts('kotlin', x)
|
|
389
|
+
return stateText(x.op, 'kotlin', `val ${v} = ${factory}
|
|
390
|
+
${v}.${x.op}(${arg}, null)
|
|
391
|
+
|
|
392
|
+
// ${v}.data() now returns the ${v} data from the last ${x.op}
|
|
393
|
+
// ${v}.match() returns the last match criteria`, 'make()')
|
|
394
|
+
},
|
|
395
|
+
direct: directText('direct()', 'prepare()'),
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
scala: {
|
|
399
|
+
featureKind: featureClass('Scala', 'prePoint', 'preSpec', ' extending `BaseFeature`'),
|
|
400
|
+
entityState: (x) => {
|
|
401
|
+
const { v, factory, arg } = exampleParts('scala', x)
|
|
402
|
+
return stateText(x.op, 'scala', `val ${v} = ${factory}
|
|
403
|
+
${v}.${x.op}(${arg}, null)
|
|
404
|
+
|
|
405
|
+
// ${v}.data() now returns the ${v} data from the last ${x.op}
|
|
406
|
+
// ${v}.matchArgs() returns the last match criteria`, 'make()')
|
|
407
|
+
},
|
|
408
|
+
direct: directText('direct()', 'prepare()'),
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
csharp: {
|
|
412
|
+
featureKind: featureClass('C#', 'PrePoint', 'PreSpec', ' extending `BaseFeature`'),
|
|
413
|
+
entityState: (x) => {
|
|
414
|
+
const { v, factory, arg } = exampleParts('csharp', x)
|
|
415
|
+
return stateText(x.op, 'csharp', `var ${v} = ${factory};
|
|
416
|
+
${v}.${cap(x.op)}(${arg});
|
|
417
|
+
|
|
418
|
+
// ${v}.Data() now returns the ${v} data from the last ${cap(x.op)}
|
|
419
|
+
// ${v}.Match() returns the last match criteria`, 'Make()')
|
|
420
|
+
},
|
|
421
|
+
direct: directText('Direct()', 'Prepare()'),
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
swift: {
|
|
425
|
+
featureKind: featureClass('Swift', 'prePoint', 'preSpec', ' extending `BaseFeature`'),
|
|
426
|
+
entityState: (x) => {
|
|
427
|
+
const { v, factory, arg } = exampleParts('swift', x)
|
|
428
|
+
return stateText(x.op, 'swift', `let ${v} = ${factory}
|
|
429
|
+
_ = try ${v}.${x.op}(${arg}, nil)
|
|
430
|
+
|
|
431
|
+
// ${v}.data() now returns the ${v} data from the last ${x.op}
|
|
432
|
+
// ${v}.matchv() returns the last match criteria`, 'make()')
|
|
433
|
+
},
|
|
434
|
+
direct: directText('direct()', 'prepare()'),
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
elixir: {
|
|
438
|
+
featureKind: `Features are the extension mechanism. A feature is a struct value node
|
|
439
|
+
carrying a closure for each hook it implements, keyed by pipeline stage
|
|
440
|
+
name (e.g. \`PrePoint\`). Each closure receives the context.
|
|
441
|
+
|
|
442
|
+
`,
|
|
443
|
+
entityState: (x) => {
|
|
444
|
+
const { v, factory, arg } = exampleParts('elixir', x)
|
|
445
|
+
const mod = `${x.model.const.Name}.Entity.${entityName(x.ent)}`
|
|
446
|
+
return stateText(x.op, 'elixir', `${v} = ${factory}
|
|
447
|
+
${mod}.${x.op}(${'' === arg ? v : v + ', ' + arg})
|
|
448
|
+
|
|
449
|
+
# ${mod}.data_get(${v}) now returns the ${v} data from the last ${x.op}
|
|
450
|
+
# ${mod}.match_get(${v}) returns the last match criteria`, 'make/1')
|
|
451
|
+
},
|
|
452
|
+
direct: directText('direct/2', 'prepare/2'),
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
clojure: {
|
|
456
|
+
featureKind: `Features are the extension mechanism. A feature is an atom wrapping a
|
|
457
|
+
map, with a function under the name of each pipeline stage it implements
|
|
458
|
+
(e.g. \`"PrePoint"\`). Each function receives the context.
|
|
459
|
+
|
|
460
|
+
`,
|
|
461
|
+
entityState: (x) => {
|
|
462
|
+
const { v, factory, arg } = exampleParts('clojure', x)
|
|
463
|
+
const ns = 'e-' + x.ent.name
|
|
464
|
+
return stateText(x.op, 'clojure', `(require '[sdk.api :as api]
|
|
465
|
+
'[sdk.entity.${x.ent.name} :as ${ns}]
|
|
466
|
+
'[voxgig.struct :as vs])
|
|
467
|
+
|
|
468
|
+
(def ${v} ${factory})
|
|
469
|
+
(${ns}/${x.op} ${v} ${arg} nil)
|
|
470
|
+
|
|
471
|
+
;; ((:data-get ${v})) now returns the ${v} data from the last ${x.op}
|
|
472
|
+
;; ((:match-get ${v})) returns the last match criteria`, `((:make ${v}))`)
|
|
473
|
+
},
|
|
474
|
+
direct: directText('api/direct', 'api/prepare'),
|
|
475
|
+
},
|
|
216
476
|
}
|
|
217
477
|
|
|
218
478
|
|
|
@@ -222,7 +482,9 @@ const ReadmeExplanation = cmp(function ReadmeExplanation(props: any) {
|
|
|
222
482
|
|
|
223
483
|
// Gated: this section describes a TARGET's features.
|
|
224
484
|
const feature = targetFeatures(model, target)
|
|
225
|
-
|
|
485
|
+
// An alias writes its origin's row.
|
|
486
|
+
const origin = originName(model, target.name)
|
|
487
|
+
const lang = LANGS[origin] || DEFAULT_LANG
|
|
226
488
|
|
|
227
489
|
// Pick a real example entity WITH a real op (prefer a read op) so the
|
|
228
490
|
// entity-state example never references a phantom entity or fabricates a
|
|
@@ -231,14 +493,15 @@ const ReadmeExplanation = cmp(function ReadmeExplanation(props: any) {
|
|
|
231
493
|
// skipped (a direct()-only SDK has no entity op to illustrate).
|
|
232
494
|
const entity = getModelPath(model, `main.${KIT}.entity`, { only_active: false, required: false })
|
|
233
495
|
const { entity: ex, primaryOp } = pickExampleEntity(entity || {})
|
|
234
|
-
const lname = helperLang(
|
|
235
|
-
const hasEntityExample = !!(ex && primaryOp)
|
|
496
|
+
const lname = helperLang(origin)
|
|
497
|
+
const hasEntityExample = !!(ex && primaryOp && lang.entityState)
|
|
236
498
|
|
|
237
499
|
let eName = 'Entity', eLower = 'entity', stateArg = '', matchIdF: string | null = null, idLit = ''
|
|
500
|
+
let idF: string | null = null
|
|
238
501
|
if (hasEntityExample) {
|
|
239
|
-
eName =
|
|
240
|
-
eLower = exampleVarName(eName.toLowerCase(),
|
|
241
|
-
|
|
502
|
+
eName = entityName(ex)
|
|
503
|
+
eLower = exampleVarName(eName.toLowerCase(), origin)
|
|
504
|
+
idF = entityIdField(ex)
|
|
242
505
|
const isMatchOp = 'load' === primaryOp || 'remove' === primaryOp
|
|
243
506
|
// Type-correct example id literal (numeric when the id param is integer-
|
|
244
507
|
// typed), derived from the OP's param type so an id carried only in the
|
|
@@ -266,23 +529,14 @@ const ReadmeExplanation = cmp(function ReadmeExplanation(props: any) {
|
|
|
266
529
|
|
|
267
530
|
### The operation pipeline
|
|
268
531
|
|
|
269
|
-
Every entity operation follows a
|
|
532
|
+
Every entity operation follows a ${pipelineLength()}-stage pipeline. Each stage fires a
|
|
270
533
|
feature hook before executing:
|
|
271
534
|
|
|
272
535
|
\`\`\`
|
|
273
|
-
|
|
536
|
+
${PIPELINE_STAGES.map((s) => s.hook).join(' → ')}
|
|
274
537
|
\`\`\`
|
|
275
538
|
|
|
276
|
-
- **
|
|
277
|
-
operation name and entity configuration.
|
|
278
|
-
- **PreSpec**: Builds the HTTP spec — URL, method, headers, body —
|
|
279
|
-
from the resolved point and the caller's parameters.
|
|
280
|
-
- **PreRequest**: Sends the HTTP request. Features can intercept here
|
|
281
|
-
to replace the transport (as TestFeature does with mocks).
|
|
282
|
-
- **PreResponse**: Parses the raw HTTP response.
|
|
283
|
-
- **PreResult**: Extracts the business data from the parsed response.
|
|
284
|
-
- **PreDone**: Final stage before returning to the caller. Entity
|
|
285
|
-
state (match, data) is updated here.
|
|
539
|
+
${PIPELINE_STAGES.map((s) => '- **' + s.hook + '**: ' + s.purpose).join('\n')}
|
|
286
540
|
|
|
287
541
|
If any stage errors, the pipeline short-circuits and the error surfaces
|
|
288
542
|
to the caller — see [Error handling](#error-handling) for how that looks
|
|
@@ -297,22 +551,28 @@ in this language.
|
|
|
297
551
|
|
|
298
552
|
Content(lang.featureKind)
|
|
299
553
|
|
|
300
|
-
|
|
554
|
+
const active = each(feature).filter((feat: any) => feat.active)
|
|
555
|
+
if (0 < active.length) {
|
|
556
|
+
Content(`The SDK ships with built-in features:
|
|
301
557
|
|
|
302
558
|
`)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
Content(`- **${feat.Name}Feature**: ${purpose}
|
|
559
|
+
for (const feat of active) {
|
|
560
|
+
if (!feat.Name) names(feat, feat.name)
|
|
561
|
+
const purpose = feat.title || feat.Name || feat.name
|
|
562
|
+
Content(`- **${feat.Name}Feature**: ${purpose}
|
|
308
563
|
`)
|
|
309
|
-
|
|
564
|
+
}
|
|
310
565
|
|
|
311
|
-
|
|
566
|
+
Content(honoursActivationOrder({ name: origin }) ? `
|
|
312
567
|
Features are initialized in order. Hooks fire in the order features
|
|
313
568
|
were added, so later features can override earlier ones.
|
|
314
569
|
|
|
570
|
+
` : `
|
|
571
|
+
Features are initialized in a fixed catalog order, whatever order they
|
|
572
|
+
were added in.
|
|
573
|
+
|
|
315
574
|
`)
|
|
575
|
+
}
|
|
316
576
|
|
|
317
577
|
|
|
318
578
|
const ReadmeExplanation_sdk =
|
|
@@ -324,18 +584,22 @@ were added, so later features can override earlier ones.
|
|
|
324
584
|
|
|
325
585
|
|
|
326
586
|
// Entity state — only when the SDK actually has an entity op to show.
|
|
327
|
-
if (hasEntityExample) {
|
|
587
|
+
if (hasEntityExample && lang.entityState) {
|
|
328
588
|
Content(`### Entity state
|
|
329
589
|
|
|
330
590
|
`)
|
|
331
|
-
Content(lang.entityState(
|
|
591
|
+
Content(lang.entityState({
|
|
592
|
+
model, ent: ex, op: primaryOp as string, idF,
|
|
593
|
+
eName, eLower, arg: stateArg, matchIdF, idLit,
|
|
594
|
+
}))
|
|
332
595
|
}
|
|
333
596
|
|
|
334
597
|
|
|
335
598
|
Content(`### Direct vs entity access
|
|
336
599
|
|
|
337
600
|
The entity interface handles URL construction, parameter placement,
|
|
338
|
-
and response parsing automatically. Use it for
|
|
601
|
+
and response parsing automatically. Use it for the operations each
|
|
602
|
+
entity declares.
|
|
339
603
|
|
|
340
604
|
`)
|
|
341
605
|
|
|
@@ -2,7 +2,7 @@ import { Content } from 'jostraca'
|
|
|
2
2
|
import { cmp } from '../helpers/component'
|
|
3
3
|
|
|
4
4
|
import { optionalComponent } from '../helpers/optional'
|
|
5
|
-
import { featureDocs, honoursActivationOrder } from './FeatureDocs'
|
|
5
|
+
import { featureDocs, codeList, honoursActivationOrder } from './FeatureDocs'
|
|
6
6
|
import type { FeatureDoc } from './FeatureDocs'
|
|
7
7
|
|
|
8
8
|
|
|
@@ -24,21 +24,31 @@ const ReadmeFeatures = cmp(function ReadmeFeatures(props: any) {
|
|
|
24
24
|
return
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const on = features.filter((f: FeatureDoc) => f.on).map((f: FeatureDoc) => f.name)
|
|
28
|
+
const off = features.length - on.length
|
|
29
|
+
const one = 1 === features.length
|
|
30
|
+
const state = 0 === on.length ?
|
|
31
|
+
`${one ? 'It is' : 'Each is'} **inactive until you switch it on**, so an SDK you have not
|
|
32
|
+
configured behaves exactly as if ${one ? 'it did not exist' : 'none of them existed'}, with no measurable overhead.` :
|
|
33
|
+
`${codeList(on)} ${1 === on.length ?
|
|
34
|
+
'is **on by default** and runs until you switch it off.' :
|
|
35
|
+
'are **on by default** and run until you switch them off.'}${0 === off ? '' : 1 === off ?
|
|
36
|
+
'\nThe other is **inactive until you switch it on**.' :
|
|
37
|
+
'\nThe others are **inactive until you switch them on**.'}`
|
|
38
|
+
|
|
27
39
|
Content(`## Features
|
|
28
40
|
|
|
29
|
-
This SDK ships ${features.length} optional
|
|
30
|
-
|
|
31
|
-
them existed — no retries, no cache, no logging, no measurable overhead.
|
|
41
|
+
This SDK ships ${features.length} optional feature${one ? '' : 's'}.
|
|
42
|
+
${state}
|
|
32
43
|
|
|
33
|
-
Activate a feature by name in the client
|
|
34
|
-
above:
|
|
44
|
+
Activate a feature by name in the \`feature\` client option:
|
|
35
45
|
|
|
36
46
|
| Feature | What it does |
|
|
37
47
|
|---|---|
|
|
38
48
|
`)
|
|
39
49
|
|
|
40
50
|
for (const f of features) {
|
|
41
|
-
Content(`| [\`${f.name}\`](#${f.name}) | ${f.
|
|
51
|
+
Content(`| [\`${f.name}\`](#${f.name}) | ${f.titleCell} |
|
|
42
52
|
`)
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -76,7 +86,7 @@ ${f.title}.
|
|
|
76
86
|
|---|---|
|
|
77
87
|
`)
|
|
78
88
|
for (const o of f.options) {
|
|
79
|
-
Content(`| \`${o.name}\` |
|
|
89
|
+
Content(`| \`${o.name}\` | ${o.code} |
|
|
80
90
|
`)
|
|
81
91
|
}
|
|
82
92
|
Content(`
|
package/src/cmp/ReadmeIntro.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { Content } from 'jostraca'
|
|
|
3
3
|
|
|
4
4
|
import { cmp } from '../helpers/component'
|
|
5
5
|
import { optionalComponent } from '../helpers/optional'
|
|
6
|
-
import {
|
|
6
|
+
import { fact } from '../helpers/facts'
|
|
7
|
+
import { KIT } from '../types'
|
|
7
8
|
import { alongsideNote } from '../helpers/alongside'
|
|
8
9
|
|
|
9
10
|
|
|
@@ -25,7 +26,7 @@ const ReadmeIntro = cmp(function ReadmeIntro(props: any) {
|
|
|
25
26
|
|
|
26
27
|
Content(`# ${model.Name} ${target.title} SDK
|
|
27
28
|
|
|
28
|
-
${
|
|
29
|
+
${fact(model.main[KIT], 'text').tagline.inline}
|
|
29
30
|
|
|
30
31
|
`)
|
|
31
32
|
intro.ReadmeIntroBody({ target })
|