@voxgig/sdkgen 4.45.0 → 4.47.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 +73 -4
- 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 +26 -2
- package/dist/action/doctor.js +208 -11
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/package.d.ts +1 -1
- package/dist/action/package.js +15 -16
- package/dist/action/package.js.map +1 -1
- package/dist/action/remove.js +16 -4
- package/dist/action/remove.js.map +1 -1
- package/dist/action/resolve.d.ts +1 -0
- package/dist/action/resolve.js +10 -4
- package/dist/action/resolve.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/admin/status.d.ts +7 -1
- package/dist/admin/status.js +34 -5
- package/dist/admin/status.js.map +1 -1
- package/dist/cmp/AgentGuide.js +46 -23
- package/dist/cmp/AgentGuide.js.map +1 -1
- package/dist/cmp/AgentGuideContent.d.ts +9 -7
- package/dist/cmp/AgentGuideContent.js +73 -43
- package/dist/cmp/AgentGuideContent.js.map +1 -1
- package/dist/cmp/AgentGuideFeature.js +19 -9
- package/dist/cmp/AgentGuideFeature.js.map +1 -1
- package/dist/cmp/AgentGuideTop.js +95 -49
- package/dist/cmp/AgentGuideTop.js.map +1 -1
- package/dist/cmp/Changelog.js +45 -4
- package/dist/cmp/Changelog.js.map +1 -1
- package/dist/cmp/Deploy.js +73 -35
- package/dist/cmp/Deploy.js.map +1 -1
- package/dist/cmp/Entity.js +1 -1
- package/dist/cmp/Entity.js.map +1 -1
- package/dist/cmp/ExternalTarget.js +10 -5
- package/dist/cmp/ExternalTarget.js.map +1 -1
- package/dist/cmp/Feature.js +12 -5
- 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/Main.js +1 -1
- package/dist/cmp/Main.js.map +1 -1
- package/dist/cmp/PublishWorkflow.js +89 -55
- 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 +4 -3
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +2 -2
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeRefFeatures.js +34 -24
- package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
- package/dist/cmp/ReadmeStation.js +12 -9
- package/dist/cmp/ReadmeStation.js.map +1 -1
- package/dist/cmp/ReadmeTop.js +479 -382
- 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/Registered.js +1 -1
- package/dist/cmp/Registered.js.map +1 -1
- package/dist/cmp/Security.js +26 -5
- package/dist/cmp/Security.js.map +1 -1
- package/dist/cmp/Test.js +1 -1
- package/dist/cmp/Test.js.map +1 -1
- package/dist/helpers/alongside.d.ts +2 -3
- package/dist/helpers/alongside.js +16 -15
- package/dist/helpers/alongside.js.map +1 -1
- package/dist/helpers/applicability.d.ts +3 -1
- package/dist/helpers/applicability.js +40 -1
- package/dist/helpers/applicability.js.map +1 -1
- package/dist/helpers/component.js +9 -1
- package/dist/helpers/component.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/definitionPlan.js +0 -1
- package/dist/helpers/definitionPlan.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 +85 -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 +210 -5
- package/dist/helpers/facts.js.map +1 -1
- package/dist/helpers/flowGuard.d.ts +1 -1
- package/dist/helpers/flowGuard.js +20 -7
- package/dist/helpers/flowGuard.js.map +1 -1
- package/dist/helpers/generated.d.ts +1 -0
- package/dist/helpers/generated.js +1 -1
- package/dist/helpers/generated.js.map +1 -1
- package/dist/helpers/graphqlPoint.d.ts +2 -1
- package/dist/helpers/graphqlPoint.js +17 -0
- package/dist/helpers/graphqlPoint.js.map +1 -1
- package/dist/helpers/guardModel.d.ts +2 -0
- package/dist/helpers/guardModel.js +41 -0
- package/dist/helpers/guardModel.js.map +1 -0
- package/dist/helpers/manifest.d.ts +2 -1
- package/dist/helpers/manifest.js +16 -0
- package/dist/helpers/manifest.js.map +1 -1
- package/dist/helpers/mcpTools.d.ts +2 -1
- package/dist/helpers/mcpTools.js +8 -1
- package/dist/helpers/mcpTools.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 +29 -17
- package/dist/helpers/opShape.js.map +1 -1
- package/dist/helpers/packageMeta.d.ts +6 -4
- package/dist/helpers/packageMeta.js +88 -53
- package/dist/helpers/packageMeta.js.map +1 -1
- package/dist/helpers/placement.d.ts +15 -0
- package/dist/helpers/placement.js +76 -0
- package/dist/helpers/placement.js.map +1 -0
- package/dist/helpers/semver.d.ts +3 -1
- package/dist/helpers/semver.js +28 -0
- package/dist/helpers/semver.js.map +1 -1
- package/dist/helpers/serverVars.js +3 -2
- package/dist/helpers/serverVars.js.map +1 -1
- package/dist/helpers/shipped.d.ts +2 -1
- package/dist/helpers/shipped.js +12 -0
- package/dist/helpers/shipped.js.map +1 -1
- package/dist/helpers/sourcestring.d.ts +3 -0
- package/dist/helpers/sourcestring.js +43 -0
- package/dist/helpers/sourcestring.js.map +1 -0
- package/dist/helpers/stdrep.d.ts +1 -1
- package/dist/helpers/stdrep.js +5 -1
- package/dist/helpers/stdrep.js.map +1 -1
- package/dist/helpers/surface.d.ts +7 -0
- package/dist/helpers/surface.js +69 -0
- package/dist/helpers/surface.js.map +1 -0
- package/dist/helpers/targetguard.d.ts +13 -0
- package/dist/helpers/targetguard.js +65 -0
- package/dist/helpers/targetguard.js.map +1 -0
- package/dist/helpers/text.d.ts +3 -1
- package/dist/helpers/text.js +16 -0
- package/dist/helpers/text.js.map +1 -1
- package/dist/helpers/textguard.d.ts +31 -0
- package/dist/helpers/textguard.js +157 -0
- package/dist/helpers/textguard.js.map +1 -0
- package/dist/helpers/title.d.ts +4 -0
- package/dist/helpers/title.js +52 -0
- package/dist/helpers/title.js.map +1 -0
- package/dist/sdkgen.d.ts +4 -6
- package/dist/sdkgen.js +72 -63
- package/dist/sdkgen.js.map +1 -1
- package/dist/testkit.d.ts +7 -2
- package/dist/testkit.js +27 -20
- 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 +150 -0
- package/model/sdkgen.aontu +15 -3
- package/package.json +3 -1
- package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +2 -2
- 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/clojure/ReadmeQuick_clojure.ts +1 -1
- package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +1 -1
- package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +1 -1
- package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +1 -1
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +1 -1
- package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +1 -1
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
- package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +1 -1
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +1 -1
- package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +1 -1
- package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +1 -1
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +1 -1
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +1 -1
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +1 -1
- package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +1 -1
- package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +1 -1
- package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
- package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +2 -1
- 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/ts/ReadmeQuick_ts.ts +1 -1
- package/project/.sdk/src/cmp/ts/TestDefinition_ts.ts +3 -1
- package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
- package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +3 -3
- package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
- package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +2 -1
- package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +11 -2
- package/project/sdkgen-package.json +1 -1
- package/src/action/check.ts +99 -4
- package/src/action/copies.ts +2 -0
- package/src/action/doctor.ts +304 -15
- package/src/action/package.ts +11 -13
- package/src/action/remove.ts +20 -5
- package/src/action/resolve.ts +11 -4
- package/src/action/target.ts +66 -15
- package/src/admin/status.ts +25 -5
- package/src/cmp/AgentGuide.ts +52 -25
- package/src/cmp/AgentGuideContent.ts +75 -43
- package/src/cmp/AgentGuideFeature.ts +21 -10
- package/src/cmp/AgentGuideTop.ts +119 -49
- package/src/cmp/Changelog.ts +56 -5
- package/src/cmp/Deploy.ts +81 -40
- package/src/cmp/Entity.ts +1 -1
- package/src/cmp/ExternalTarget.ts +12 -6
- package/src/cmp/Feature.ts +13 -6
- package/src/cmp/FeatureDocs.ts +21 -40
- package/src/cmp/FeatureHook.ts +38 -1
- package/src/cmp/Main.ts +1 -1
- package/src/cmp/PublishWorkflow.ts +94 -60
- 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 +4 -3
- package/src/cmp/ReadmeModel.ts +2 -2
- package/src/cmp/ReadmeRefFeatures.ts +39 -27
- package/src/cmp/ReadmeStation.ts +13 -16
- package/src/cmp/ReadmeTop.ts +538 -397
- package/src/cmp/ReadmeUnions.ts +10 -2
- package/src/cmp/Registered.ts +1 -1
- package/src/cmp/Security.ts +35 -7
- package/src/cmp/Test.ts +1 -1
- package/src/helpers/alongside.ts +16 -19
- package/src/helpers/applicability.ts +44 -1
- package/src/helpers/component.ts +11 -1
- package/src/helpers/copymerge.ts +58 -10
- package/src/helpers/definitionPlan.ts +0 -1
- package/src/helpers/doccheck.ts +174 -0
- package/src/helpers/doctext.ts +115 -0
- package/src/helpers/exampleCall.ts +415 -0
- package/src/helpers/exportnames.ts +47 -0
- package/src/helpers/facts.ts +259 -5
- package/src/helpers/flowGuard.ts +22 -7
- package/src/helpers/generated.ts +3 -1
- package/src/helpers/graphqlPoint.ts +20 -1
- package/src/helpers/guardModel.ts +50 -0
- package/src/helpers/manifest.ts +19 -0
- package/src/helpers/mcpTools.ts +11 -1
- package/src/helpers/modelcheck.ts +16 -0
- package/src/helpers/opExample.ts +34 -2
- package/src/helpers/opShape.ts +29 -16
- package/src/helpers/packageMeta.ts +89 -52
- package/src/helpers/placement.ts +114 -0
- package/src/helpers/semver.ts +35 -0
- package/src/helpers/serverVars.ts +4 -2
- package/src/helpers/shipped.ts +13 -0
- package/src/helpers/sourcestring.ts +47 -0
- package/src/helpers/stdrep.ts +6 -1
- package/src/helpers/surface.ts +82 -0
- package/src/helpers/targetguard.ts +91 -0
- package/src/helpers/text.ts +22 -0
- package/src/helpers/textguard.ts +208 -0
- package/src/helpers/title.ts +59 -0
- package/src/sdkgen.ts +82 -78
- package/src/testkit.ts +42 -20
- package/src/utility.ts +2 -1
package/src/helpers/opShape.ts
CHANGED
|
@@ -395,19 +395,17 @@ function invalidRequest(ent: any):
|
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
|
|
398
|
-
// The entity's ACTIVE op names
|
|
399
|
-
//
|
|
400
|
-
// `Object.keys(ent.op)`: an
|
|
401
|
-
// whose every route is an action is refused without one, so a plain
|
|
402
|
-
// of either would fail.
|
|
398
|
+
// The entity's ACTIVE op names that the bundled targets generate, in canonical
|
|
399
|
+
// CRUD order. Doc generators gate an op example on this, NOT on the raw
|
|
400
|
+
// `Object.keys(ent.op)`: an op outside `CANON_OP_ORDER` generates no method,
|
|
401
|
+
// and an op whose every route is an action is refused without one, so a plain
|
|
402
|
+
// example of either would fail.
|
|
403
403
|
const CANON_OP_ORDER = ['list', 'load', 'create', 'update', 'patch', 'remove']
|
|
404
404
|
|
|
405
405
|
function entityOps(ent: any): string[] {
|
|
406
406
|
const ops = (ent && ent.op) || {}
|
|
407
|
-
|
|
407
|
+
return CANON_OP_ORDER.filter((o: string) =>
|
|
408
408
|
ops[o] && ops[o].active !== false && !opNeedsAction(ops[o]))
|
|
409
|
-
return CANON_OP_ORDER.filter((o) => active.includes(o))
|
|
410
|
-
.concat(active.filter((o) => !CANON_OP_ORDER.includes(o)).sort())
|
|
411
409
|
}
|
|
412
410
|
|
|
413
411
|
|
|
@@ -422,11 +420,22 @@ function introOps(model: any): string[] {
|
|
|
422
420
|
}
|
|
423
421
|
}
|
|
424
422
|
const names = CANON_OP_ORDER.filter((o) => found.has(o))
|
|
425
|
-
.concat([...found].filter((o) => !CANON_OP_ORDER.includes(o)))
|
|
426
423
|
return 0 < names.length ? names : ['list', 'load']
|
|
427
424
|
}
|
|
428
425
|
|
|
429
426
|
|
|
427
|
+
// The operations the active entities have a generated method for, in
|
|
428
|
+
// canonical order; none when no entity has one.
|
|
429
|
+
function generatedOps(model: any): string[] {
|
|
430
|
+
const entity = getModelPath(model, `main.${KIT}.entity`, { required: false }) || {}
|
|
431
|
+
const found = new Set<string>()
|
|
432
|
+
for (const e of Object.values(entity) as any[]) {
|
|
433
|
+
for (const o of entityOps(e)) found.add(o)
|
|
434
|
+
}
|
|
435
|
+
return CANON_OP_ORDER.filter((o) => found.has(o))
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
430
439
|
type UngeneratedOp = { entity: string, op: string, points: string[] }
|
|
431
440
|
|
|
432
441
|
|
|
@@ -470,8 +479,8 @@ function ungeneratedOps(model: any): UngeneratedOp[] {
|
|
|
470
479
|
}
|
|
471
480
|
|
|
472
481
|
|
|
473
|
-
// Speaks only for the bundled targets: a target from another package
|
|
474
|
-
// generate more ops, so it is named
|
|
482
|
+
// Speaks only for the bundled targets: a target from another package or the
|
|
483
|
+
// project's own may generate more ops, so it is named outside the claim.
|
|
475
484
|
function warnUngeneratedOps(
|
|
476
485
|
model: any, log: any, origins: TargetOrigins,
|
|
477
486
|
): UngeneratedOp[] {
|
|
@@ -481,11 +490,14 @@ function warnUngeneratedOps(
|
|
|
481
490
|
(0 < d.points.length ? ` (${d.points.join(', ')})` : ''))
|
|
482
491
|
const generated = CANON_OP_ORDER.slice(0, -1).join(', ') + ' and ' +
|
|
483
492
|
CANON_OP_ORDER[CANON_OP_ORDER.length - 1]
|
|
484
|
-
const
|
|
493
|
+
const outside = [
|
|
494
|
+
...origins.external.map((t) => `${t.name} from ${t.from}`),
|
|
495
|
+
...origins.owned.map((name) => `${name} (the project's own)`),
|
|
496
|
+
]
|
|
485
497
|
log.warn({
|
|
486
498
|
point: 'entity-op-ungenerated', ops: dropped,
|
|
487
|
-
bundled: origins.bundled, external: origins.external,
|
|
488
|
-
note: 0 ===
|
|
499
|
+
bundled: origins.bundled, external: origins.external, owned: origins.owned,
|
|
500
|
+
note: 0 === outside.length
|
|
489
501
|
? `operation(s) in the model that the bundled targets do not ` +
|
|
490
502
|
`generate (each generates ${generated} only), so the SDK has no ` +
|
|
491
503
|
`method for them: ${listed.join(', ')}. To reach one, reclassify it ` +
|
|
@@ -494,8 +506,8 @@ function warnUngeneratedOps(
|
|
|
494
506
|
: `operation(s) in the model that the bundled targets ` +
|
|
495
507
|
`(${origins.bundled.join(', ')}) do not generate (each generates ` +
|
|
496
508
|
`${generated} only), so their SDKs have no method for them: ` +
|
|
497
|
-
`${listed.join(', ')}. Targets
|
|
498
|
-
`
|
|
509
|
+
`${listed.join(', ')}. Targets from elsewhere may generate them, ` +
|
|
510
|
+
`so they are not judged here: ${outside.join(', ')}. ` +
|
|
499
511
|
`To reach one in a bundled target, reclassify it in the guide ` +
|
|
500
512
|
`(.sdk/model/guide/guide.aontu)`,
|
|
501
513
|
})
|
|
@@ -792,6 +804,7 @@ export {
|
|
|
792
804
|
entityRecordIdField,
|
|
793
805
|
entityOps,
|
|
794
806
|
introOps,
|
|
807
|
+
generatedOps,
|
|
795
808
|
invalidRequest,
|
|
796
809
|
entityPrimaryOp,
|
|
797
810
|
pickExampleEntity,
|
|
@@ -3,33 +3,16 @@ import { each } from 'jostraca'
|
|
|
3
3
|
|
|
4
4
|
import { KIT, nom } from '@voxgig/apidef'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { surfaceName, surfaceOf } from './surface'
|
|
7
|
+
import { fact } from './facts'
|
|
7
8
|
import { kindCollection } from './kindCollection'
|
|
8
|
-
import {
|
|
9
|
+
import { LANG_LABEL, langLabel } from './title'
|
|
9
10
|
|
|
10
11
|
const PUBLISHER = 'Voxgig'
|
|
11
12
|
const PUBLISHER_URL = 'https://voxgig.com'
|
|
12
13
|
const SECURITY_EMAIL = 'security@voxgig.com'
|
|
13
14
|
const GENERATOR_URL = 'https://github.com/voxgig/sdkgen'
|
|
14
15
|
|
|
15
|
-
const LANG_LABEL: Record<string, string> = {
|
|
16
|
-
ts: 'TypeScript',
|
|
17
|
-
js: 'JavaScript',
|
|
18
|
-
py: 'Python',
|
|
19
|
-
php: 'PHP',
|
|
20
|
-
rb: 'Ruby',
|
|
21
|
-
lua: 'Lua',
|
|
22
|
-
go: 'Go',
|
|
23
|
-
'go-cli': 'Go CLI',
|
|
24
|
-
'go-mcp': 'Go MCP server',
|
|
25
|
-
'py-data': 'Python Data',
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function langLabel(target: string): string {
|
|
29
|
-
return LANG_LABEL[target] || target
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
16
|
function originName(model: any, target: string): string {
|
|
34
17
|
const orig = model?.main?.[KIT]?.target?.[target]?.origname
|
|
35
18
|
return (null != orig && '' !== orig) ? String(orig) : target
|
|
@@ -40,20 +23,22 @@ function sdkName(slug: string): string {
|
|
|
40
23
|
}
|
|
41
24
|
|
|
42
25
|
|
|
43
|
-
function repoInfo(model: any) {
|
|
26
|
+
function repoInfo(model: any, target?: string) {
|
|
44
27
|
const slug = model.name
|
|
45
28
|
const origin = model.origin || 'voxgig-sdk'
|
|
46
29
|
|
|
47
30
|
const declared = (model && model.main && model.main[KIT] && model.main[KIT].repo) || {}
|
|
31
|
+
const targetRepo = null == target ? '' : model?.main?.[KIT]?.target?.[target]?.output?.repo
|
|
48
32
|
|
|
49
33
|
const host = '' === (declared.host || '') ? 'github.com' : (declared.host || 'github.com')
|
|
50
|
-
const path =
|
|
34
|
+
const path = null != targetRepo && '' !== targetRepo ? String(targetRepo) :
|
|
35
|
+
'' === (declared.path || '') ? `${origin}/${sdkName(slug)}` : String(declared.path)
|
|
51
36
|
|
|
52
37
|
const seg = path.split('/')
|
|
53
38
|
const repo = seg[seg.length - 1]
|
|
54
39
|
|
|
55
40
|
const repoUrl = `https://${host}/${path}`
|
|
56
|
-
const pages = repoPages(host, repoUrl)
|
|
41
|
+
const pages = repoPages(host, repoUrl, releaseBranch(model))
|
|
57
42
|
|
|
58
43
|
return {
|
|
59
44
|
slug,
|
|
@@ -73,12 +58,12 @@ function repoInfo(model: any) {
|
|
|
73
58
|
|
|
74
59
|
// GitLab keeps a project's pages under `/-/`, and Bitbucket lists its tags
|
|
75
60
|
// among its downloads; any other host is laid out as GitHub is.
|
|
76
|
-
function repoPages(host: string, repoUrl: string) {
|
|
61
|
+
function repoPages(host: string, repoUrl: string, branch: string) {
|
|
77
62
|
if (host.includes('gitlab')) {
|
|
78
63
|
return {
|
|
79
64
|
name: 'GitLab',
|
|
80
65
|
issues: `${repoUrl}/-/issues`,
|
|
81
|
-
changelog: `${repoUrl}/-/blob/
|
|
66
|
+
changelog: `${repoUrl}/-/blob/${branch}/CHANGELOG.md`,
|
|
82
67
|
releases: `${repoUrl}/-/releases`,
|
|
83
68
|
tags: `${repoUrl}/-/tags`,
|
|
84
69
|
}
|
|
@@ -87,7 +72,7 @@ function repoPages(host: string, repoUrl: string) {
|
|
|
87
72
|
return {
|
|
88
73
|
name: 'Bitbucket',
|
|
89
74
|
issues: `${repoUrl}/issues`,
|
|
90
|
-
changelog: `${repoUrl}/src/
|
|
75
|
+
changelog: `${repoUrl}/src/${branch}/CHANGELOG.md`,
|
|
91
76
|
releases: `${repoUrl}/downloads/?tab=tags`,
|
|
92
77
|
tags: `${repoUrl}/downloads/?tab=tags`,
|
|
93
78
|
}
|
|
@@ -95,13 +80,19 @@ function repoPages(host: string, repoUrl: string) {
|
|
|
95
80
|
return {
|
|
96
81
|
name: host.includes('github') ? 'GitHub' : host,
|
|
97
82
|
issues: `${repoUrl}/issues`,
|
|
98
|
-
changelog: `${repoUrl}/blob/
|
|
83
|
+
changelog: `${repoUrl}/blob/${branch}/CHANGELOG.md`,
|
|
99
84
|
releases: `${repoUrl}/releases`,
|
|
100
85
|
tags: `${repoUrl}/tags`,
|
|
101
86
|
}
|
|
102
87
|
}
|
|
103
88
|
|
|
104
89
|
|
|
90
|
+
function releaseBranch(model: any): string {
|
|
91
|
+
const branch = model?.main?.[KIT]?.doc?.ci?.branch
|
|
92
|
+
return 'string' === typeof branch && '' !== branch ? branch : 'main'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
105
96
|
function docsSiteUrl(model: any): string {
|
|
106
97
|
const { host, path } = repoInfo(model)
|
|
107
98
|
|
|
@@ -171,36 +162,60 @@ function goPackageIdent(model: any, target: string): string {
|
|
|
171
162
|
}
|
|
172
163
|
|
|
173
164
|
|
|
165
|
+
// A registry named `none` is no registry: c, cpp and zig declare it.
|
|
174
166
|
function registryState(model: any, target: string): 'tag' | 'pending' | 'active' | 'inactive' {
|
|
175
|
-
const eco = originName(model, target)
|
|
176
|
-
if ('go' === eco || 'go-cli' === eco || 'go-mcp' === eco) return 'tag'
|
|
177
167
|
const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
|
|
178
|
-
if (null == reg || '' === (
|
|
168
|
+
if (null == reg || '' === registryName(model, target) || goFamily(model, target)) return 'tag'
|
|
179
169
|
if (true === reg.active) return 'active'
|
|
180
170
|
const s = reg.state
|
|
181
171
|
if ('active' === s || 'inactive' === s || 'pending' === s) return s
|
|
182
172
|
return 'pending'
|
|
183
173
|
}
|
|
184
174
|
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
// else — pending, inactive, tag-only — installs from the git tag instead.
|
|
175
|
+
// Only a package live on its registry gets a registry install command; any
|
|
176
|
+
// other installs from the git tag.
|
|
188
177
|
function isPublished(model: any, target: string): boolean {
|
|
189
178
|
return 'active' === registryState(model, target)
|
|
190
179
|
}
|
|
191
180
|
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
return
|
|
181
|
+
// Go installs from its git tag whatever the registry, as does a target built on it.
|
|
182
|
+
function goFamily(model: any, target: string): boolean {
|
|
183
|
+
if ('go' === originName(model, target)) return true
|
|
184
|
+
const wraps = fact(model.main[KIT].target[target], 'consumes')
|
|
185
|
+
return '' !== wraps && 'go' === originName(model, wraps)
|
|
197
186
|
}
|
|
198
187
|
|
|
199
|
-
// The
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
188
|
+
// The registry a target uploads to (npm | pypi | packagist | ...), or '' for a tag-only port.
|
|
189
|
+
function registryName(model: any, target: string): string {
|
|
190
|
+
const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
|
|
191
|
+
const name = (reg && reg.name) ? String(reg.name) : ''
|
|
192
|
+
return 'none' === name ? '' : name
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const REGISTRY_LABEL: Record<string, string> = {
|
|
196
|
+
npm: 'npm',
|
|
197
|
+
pypi: 'PyPI',
|
|
198
|
+
packagist: 'Packagist',
|
|
199
|
+
rubygems: 'RubyGems',
|
|
200
|
+
luarocks: 'LuaRocks',
|
|
201
|
+
'crates.io': 'crates.io',
|
|
202
|
+
nuget: 'NuGet',
|
|
203
|
+
'maven-central': 'Maven Central',
|
|
204
|
+
clojars: 'Clojars',
|
|
205
|
+
hex: 'Hex',
|
|
206
|
+
cpan: 'CPAN',
|
|
207
|
+
opam: 'opam',
|
|
208
|
+
swiftpm: 'Swift Package Manager',
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function registryLabel(name: string): string {
|
|
212
|
+
return REGISTRY_LABEL[name] || name
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// The install route for a target not on a registry: `go get <module>@latest`
|
|
216
|
+
// for go, resolved by the proxy from the `go/vX.Y.Z` tag. go-cli, go-mcp and a
|
|
217
|
+
// port with no registry get '', and their README's build steps are the route.
|
|
218
|
+
// A declared registry gets a "not yet on <registry>" pointer to the git tag.
|
|
204
219
|
function vendorCommand(model: any, target: string): string {
|
|
205
220
|
const { tagsUrl } = repoInfo(model)
|
|
206
221
|
switch (originName(model, target)) {
|
|
@@ -218,15 +233,15 @@ function vendorCommand(model: any, target: string): string {
|
|
|
218
233
|
return ''
|
|
219
234
|
default: {
|
|
220
235
|
const reg = registryName(model, target)
|
|
221
|
-
return `not yet on ${reg
|
|
236
|
+
return '' === reg ? '' : `not yet on ${reg} — install from the git tag: ${tagsUrl}`
|
|
222
237
|
}
|
|
223
238
|
}
|
|
224
239
|
}
|
|
225
240
|
|
|
241
|
+
// The API's name fact without a trailing "API", for "the <name> public API".
|
|
226
242
|
function apiName(model: any): string {
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
const stripped = raw.replace(/\s*API\s*$/i, '').trim()
|
|
243
|
+
const stripped = String(fact(model.main[KIT], 'apiName').raw).trim()
|
|
244
|
+
.replace(/\s*API\s*$/i, '').trim()
|
|
230
245
|
return stripped || nom(model, 'Name') || model.name
|
|
231
246
|
}
|
|
232
247
|
|
|
@@ -286,7 +301,7 @@ const NAMED_CONSUMERS = ['go-cli', 'go-mcp', 'py-data']
|
|
|
286
301
|
|
|
287
302
|
function hasPackageName(model: any, target: string): boolean {
|
|
288
303
|
const declared = model?.main?.[KIT]?.target?.[target]
|
|
289
|
-
if (
|
|
304
|
+
if ('sdk' === surfaceOf(declared)) {
|
|
290
305
|
return true
|
|
291
306
|
}
|
|
292
307
|
const pkg = declared?.publish?.registry?.package
|
|
@@ -317,13 +332,28 @@ function installCommand(model: any, target: string): string {
|
|
|
317
332
|
return `luarocks install ${packageName(model, target)}`
|
|
318
333
|
case 'go':
|
|
319
334
|
return `go get ${packageName(model, target)}`
|
|
335
|
+
case 'rust':
|
|
336
|
+
return `cargo add ${packageName(model, target)}`
|
|
337
|
+
case 'csharp':
|
|
338
|
+
return `dotnet add package ${packageName(model, target)}`
|
|
339
|
+
case 'perl':
|
|
340
|
+
return `cpanm ${packageName(model, target)}`
|
|
341
|
+
case 'ocaml':
|
|
342
|
+
return `opam install ${packageName(model, target)}`
|
|
343
|
+
// No package manager installs these: the release tag is the route.
|
|
344
|
+
case 'c':
|
|
345
|
+
case 'zig':
|
|
346
|
+
return `install from the git tag: ${repoInfo(model).tagsUrl}`
|
|
320
347
|
default:
|
|
321
348
|
return ''
|
|
322
349
|
}
|
|
323
350
|
}
|
|
324
351
|
|
|
325
352
|
function pkgDescription(model: any, target: string): string {
|
|
326
|
-
|
|
353
|
+
const what = surfaceName(model.main[KIT].target[target])
|
|
354
|
+
return publisherInfo(model).official ?
|
|
355
|
+
`Generated ${what} for the ${apiName(model)} API.` :
|
|
356
|
+
`Unofficial generated ${what}` +
|
|
327
357
|
` for the ${apiName(model)} public API.` +
|
|
328
358
|
` Not affiliated with or endorsed by the upstream API provider.`
|
|
329
359
|
}
|
|
@@ -338,8 +368,12 @@ function tomlString(s: string): string {
|
|
|
338
368
|
// SECURITY.md. Generic on the upstream owner (owner names are only ~45%
|
|
339
369
|
// reliably known across the fleet).
|
|
340
370
|
function nonAffiliation(model: any): string {
|
|
341
|
-
|
|
342
|
-
|
|
371
|
+
const { name, official } = publisherInfo(model)
|
|
372
|
+
return official ?
|
|
373
|
+
`This SDK for the ${apiName(model)} API is generated by ${name} with ` +
|
|
374
|
+
`[\`@voxgig/sdkgen\`](${GENERATOR_URL}).` :
|
|
375
|
+
`This is an unofficial SDK for the ${apiName(model)} public API, generated by ` +
|
|
376
|
+
`${name} with [\`@voxgig/sdkgen\`](${GENERATOR_URL}). ` +
|
|
343
377
|
`It is not affiliated with, endorsed by, or sponsored by the upstream API provider.`
|
|
344
378
|
}
|
|
345
379
|
|
|
@@ -355,7 +389,7 @@ function declaredText(value: any): string {
|
|
|
355
389
|
|
|
356
390
|
|
|
357
391
|
// Voxgig's url and security contact apply only while Voxgig is the publisher.
|
|
358
|
-
function publisherInfo(model: any): { name: string, url: string, security: string } {
|
|
392
|
+
function publisherInfo(model: any): { name: string, url: string, security: string, official: boolean } {
|
|
359
393
|
const declared = model?.main?.[KIT]?.publisher || {}
|
|
360
394
|
|
|
361
395
|
const name = declaredText(declared.name) || PUBLISHER
|
|
@@ -365,6 +399,7 @@ function publisherInfo(model: any): { name: string, url: string, security: strin
|
|
|
365
399
|
name,
|
|
366
400
|
url: declaredText(declared.url) || (own ? PUBLISHER_URL : ''),
|
|
367
401
|
security: declaredText(declared.security) || (own ? SECURITY_EMAIL : ''),
|
|
402
|
+
official: true === declared.official,
|
|
368
403
|
}
|
|
369
404
|
}
|
|
370
405
|
|
|
@@ -428,6 +463,7 @@ export {
|
|
|
428
463
|
langLabel,
|
|
429
464
|
originName,
|
|
430
465
|
repoInfo,
|
|
466
|
+
releaseBranch,
|
|
431
467
|
apiName,
|
|
432
468
|
packageName,
|
|
433
469
|
hasPackageName,
|
|
@@ -435,6 +471,7 @@ export {
|
|
|
435
471
|
registryState,
|
|
436
472
|
isPublished,
|
|
437
473
|
registryName,
|
|
474
|
+
registryLabel,
|
|
438
475
|
vendorCommand,
|
|
439
476
|
pkgDescription,
|
|
440
477
|
tomlString,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import Path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import { SdkGenError } from '../utility'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type ExternalOverride = {
|
|
7
|
+
path?: string
|
|
8
|
+
sdkrel?: string
|
|
9
|
+
enclosing?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
type Place = 'root' | 'folder' | 'external'
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// The run override for each target: the `external` build option, with
|
|
17
|
+
// SDKGEN_EXTERNAL merged over it. `named` lists the targets the variable names.
|
|
18
|
+
function readOverride(
|
|
19
|
+
declared: Record<string, ExternalOverride> | undefined,
|
|
20
|
+
raw: string | undefined,
|
|
21
|
+
targets: string[],
|
|
22
|
+
): { override: Record<string, ExternalOverride>, named: string[] } {
|
|
23
|
+
const base = declared || {}
|
|
24
|
+
|
|
25
|
+
if (null == raw || '' === raw.trim()) {
|
|
26
|
+
return { override: base, named: [] }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let parsed: any
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
parsed = JSON.parse(raw)
|
|
33
|
+
}
|
|
34
|
+
catch (err: any) {
|
|
35
|
+
throw new SdkGenError(
|
|
36
|
+
'SDKGEN_EXTERNAL is not valid JSON: ' + (err?.message || err) +
|
|
37
|
+
'\n Expected an object keyed by item name, for example:' +
|
|
38
|
+
'\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
|
|
39
|
+
'\n Got: ' + raw.slice(0, 200))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (null == parsed || 'object' !== typeof parsed || Array.isArray(parsed)) {
|
|
43
|
+
throw new SdkGenError(
|
|
44
|
+
'SDKGEN_EXTERNAL must be a JSON OBJECT keyed by item name, for example:' +
|
|
45
|
+
'\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
|
|
46
|
+
'\n Got: ' + raw.slice(0, 200))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// A misspelled name would otherwise change nothing and still be logged as
|
|
50
|
+
// an override.
|
|
51
|
+
const unknown = Object.keys(parsed).filter((name: string) => !targets.includes(name)).sort()
|
|
52
|
+
if (0 < unknown.length) {
|
|
53
|
+
throw new SdkGenError(
|
|
54
|
+
'SDKGEN_EXTERNAL names ' + unknown.join(', ') + ', which ' +
|
|
55
|
+
(1 === unknown.length ? 'is not a target' : 'are not targets') + ' of this model' +
|
|
56
|
+
'\n Its targets are: ' + [...targets].sort().join(', '))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const override: Record<string, ExternalOverride> = { ...base }
|
|
60
|
+
for (const name of Object.keys(parsed)) {
|
|
61
|
+
override[name] = { ...(base[name] || {}), ...(parsed[name] || {}) }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { override, named: Object.keys(parsed).sort() }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// A target's output for this run, as a shallow copy: the override's path
|
|
69
|
+
// replaces the declared one, root placement included.
|
|
70
|
+
function runOutput(output: any, ov?: ExternalOverride): any {
|
|
71
|
+
const out = { ...(output || {}) }
|
|
72
|
+
|
|
73
|
+
if (null != ov?.path && '' !== ov.path) {
|
|
74
|
+
out.path = ov.path
|
|
75
|
+
delete out.root
|
|
76
|
+
}
|
|
77
|
+
if (null != ov?.sdkrel && '' !== ov.sdkrel) {
|
|
78
|
+
out.sdkrel = ov.sdkrel
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return out
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// Where this run writes a target: the override's path, else the place fact
|
|
86
|
+
// of a prepared model. A target with no `output` claims no place: in tree.
|
|
87
|
+
function runPlace(target: any, ov?: ExternalOverride): Place {
|
|
88
|
+
if (null != ov?.path && '' !== ov.path) {
|
|
89
|
+
return 'external'
|
|
90
|
+
}
|
|
91
|
+
const place = target?.fact?.place
|
|
92
|
+
return 'root' === place || 'external' === place ? place : 'folder'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
function runFolder(target: any, name: string, project: string, ov?: ExternalOverride): string {
|
|
97
|
+
const place = runPlace(target, ov)
|
|
98
|
+
return 'root' === place ? Path.resolve(project) :
|
|
99
|
+
'external' === place ? Path.resolve(project, String(runOutput(target?.output, ov).path)) :
|
|
100
|
+
Path.resolve(project, name)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
export type {
|
|
105
|
+
ExternalOverride,
|
|
106
|
+
Place,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
readOverride,
|
|
111
|
+
runOutput,
|
|
112
|
+
runPlace,
|
|
113
|
+
runFolder,
|
|
114
|
+
}
|
package/src/helpers/semver.ts
CHANGED
|
@@ -86,6 +86,14 @@ function satisfiesOne(version: Parts, comparator: string): boolean | undefined {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
// Undefined when either is not a plain version, so no order is claimed.
|
|
90
|
+
function compareVersions(a: string, b: string): number | undefined {
|
|
91
|
+
const pa = parseVersion(a)
|
|
92
|
+
const pb = parseVersion(b)
|
|
93
|
+
return null == pa || null == pb ? undefined : compare(pa, pb)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
89
97
|
// Does `version` satisfy `range`?
|
|
90
98
|
//
|
|
91
99
|
// `true` / `false` / `undefined` — see the note at the top: undefined means
|
|
@@ -146,7 +154,34 @@ function satisfies(version: string, range: string): boolean | undefined {
|
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
|
|
157
|
+
// Does `range` admit a release older than `version`? Tried at the versions the
|
|
158
|
+
// range names and the release just below; undefined when nothing is understood.
|
|
159
|
+
function admitsBelow(range: string, version: string): boolean | undefined {
|
|
160
|
+
const v = parseVersion(version)
|
|
161
|
+
if (null == v) {
|
|
162
|
+
return undefined
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const named: Parts[] = (String(range ?? '').match(/\d+(?:\.\d+){0,2}/g) ?? [])
|
|
166
|
+
.map((m: string) => {
|
|
167
|
+
const p = m.split('.').map(Number)
|
|
168
|
+
return [p[0], p[1] ?? 0, p[2] ?? 0] as Parts
|
|
169
|
+
})
|
|
170
|
+
const top = Number.MAX_SAFE_INTEGER
|
|
171
|
+
const below: Parts | undefined = 0 < v[2] ? [v[0], v[1], v[2] - 1] :
|
|
172
|
+
0 < v[1] ? [v[0], v[1] - 1, top] : 0 < v[0] ? [v[0] - 1, top, top] : undefined
|
|
173
|
+
|
|
174
|
+
const tried = [...named, ...(null == below ? [] : [below])]
|
|
175
|
+
.filter((p: Parts) => 0 > compare(p, v))
|
|
176
|
+
.map((p: Parts) => satisfies(p.join('.'), range))
|
|
177
|
+
|
|
178
|
+
return tried.includes(true) ? true : tried.includes(undefined) ? undefined : false
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
149
182
|
export {
|
|
150
183
|
satisfies,
|
|
151
184
|
parseVersion,
|
|
185
|
+
compareVersions,
|
|
186
|
+
admitsBelow,
|
|
152
187
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { KIT } from '@voxgig/apidef'
|
|
2
|
+
|
|
1
3
|
|
|
2
4
|
// One declared server variable. `required` is true when the spec gives no
|
|
3
5
|
// usable default — the caller MUST supply it for live use.
|
|
@@ -16,7 +18,7 @@ const SERVER_VAR_RE = /\{([A-Za-z0-9_]+)\}/g
|
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
function serverVariables(model: any): ServerVar[] {
|
|
19
|
-
const info = model?.main?.
|
|
21
|
+
const info = model?.main?.[KIT]?.info
|
|
20
22
|
const server = info?.servers?.[0]
|
|
21
23
|
const url: string = server?.url || ''
|
|
22
24
|
const declared = server?.variables || {}
|
|
@@ -64,7 +66,7 @@ function serverVarEnv(projenvname: string, name: string): string {
|
|
|
64
66
|
|
|
65
67
|
// Does the model's server URL contain any {name} placeholders at all?
|
|
66
68
|
function hasServerVariables(model: any): boolean {
|
|
67
|
-
const info = model?.main?.
|
|
69
|
+
const info = model?.main?.[KIT]?.info
|
|
68
70
|
const url: string = info?.servers?.[0]?.url || ''
|
|
69
71
|
SERVER_VAR_RE.lastIndex = 0
|
|
70
72
|
return SERVER_VAR_RE.test(url)
|
package/src/helpers/shipped.ts
CHANGED
|
@@ -23,7 +23,20 @@ function factRulesFile(): string {
|
|
|
23
23
|
return Path.join(packageRoot(), 'model', 'fact.aontu')
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
|
|
27
|
+
// This generator's own version, from the package.json beside `dist`. Not from
|
|
28
|
+
// the consumer's model: `engines.sdkgen` is about the generator running.
|
|
29
|
+
const SDKGEN_VERSION: string = (() => {
|
|
30
|
+
try {
|
|
31
|
+
return require(Path.join(packageRoot(), 'package.json')).version
|
|
32
|
+
}
|
|
33
|
+
catch (err: any) {
|
|
34
|
+
return '0.0.0'
|
|
35
|
+
}
|
|
36
|
+
})()
|
|
37
|
+
|
|
26
38
|
export {
|
|
39
|
+
SDKGEN_VERSION,
|
|
27
40
|
packageRoot,
|
|
28
41
|
schemaFile,
|
|
29
42
|
scaffoldFolder,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* Copyright (c) 2024-2026 Voxgig Ltd, MIT License */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// How each language writes `$` inside an escape-processing string literal, so
|
|
5
|
+
// that vendor text a copy prints never shows jostraca's template pass a `$$`.
|
|
6
|
+
// C's hex escape runs on through every hex digit after it, so C and C++ take
|
|
7
|
+
// the fixed three-digit octal form.
|
|
8
|
+
const DOLLAR: Record<string, string> = {
|
|
9
|
+
json: '\\u0024',
|
|
10
|
+
ts: '\\u0024',
|
|
11
|
+
js: '\\u0024',
|
|
12
|
+
java: '\\u0024',
|
|
13
|
+
kotlin: '\\u0024',
|
|
14
|
+
scala: '\\u0024',
|
|
15
|
+
csharp: '\\u0024',
|
|
16
|
+
clojure: '\\u0024',
|
|
17
|
+
elixir: '\\u0024',
|
|
18
|
+
go: '\\u0024',
|
|
19
|
+
py: '\\u0024',
|
|
20
|
+
rb: '\\u0024',
|
|
21
|
+
swift: '\\u{24}',
|
|
22
|
+
rust: '\\u{24}',
|
|
23
|
+
lua: '\\u{24}',
|
|
24
|
+
php: '\\u{24}',
|
|
25
|
+
perl: '\\x{24}',
|
|
26
|
+
zig: '\\x24',
|
|
27
|
+
ocaml: '\\x24',
|
|
28
|
+
c: '\\044',
|
|
29
|
+
cpp: '\\044',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// The text for the inside of a string literal of `lang`, which the copy
|
|
34
|
+
// writes double-quoted, every `$` escaped. A language with no entry fails.
|
|
35
|
+
function sourceString(lang: string, text: string): string {
|
|
36
|
+
const dollar = DOLLAR[lang]
|
|
37
|
+
if (null == dollar) {
|
|
38
|
+
throw new Error(`sdkgen: no string escape for the language '${lang}'`)
|
|
39
|
+
}
|
|
40
|
+
return String(text).replace(/\$/g, dollar)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
DOLLAR,
|
|
46
|
+
sourceString,
|
|
47
|
+
}
|
package/src/helpers/stdrep.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { envName, packageVersion, publisherInfo } from './packageMeta'
|
|
3
|
+
import { fact } from './facts'
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
function ensureStdrep(ctx$: any): any {
|
|
6
|
+
function ensureStdrep(ctx$: any, target?: any): any {
|
|
6
7
|
const stdrep = ctx$.stdrep = (ctx$.stdrep || {})
|
|
7
8
|
|
|
9
|
+
if (null != target) {
|
|
10
|
+
stdrep.SDKREL = null != ctx$.sdkrelpath ? ctx$.sdkrelpath : fact(target, 'sdkrel')
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
if (null == stdrep.PROJECTENV) {
|
|
9
14
|
stdrep.PROJECTENV = envName(ctx$.model)
|
|
10
15
|
}
|