@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
|
@@ -16,7 +16,9 @@ import { isControlSkipped } from './utility'
|
|
|
16
16
|
// Generated from the API definition, not from the model this SDK was built
|
|
17
17
|
// from: the route, the declared query parameters, the credential the security
|
|
18
18
|
// scheme names, and the definition's own response example.
|
|
19
|
-
|
|
19
|
+
// A JSON string, not an array literal: tsc types a literal as the union of its
|
|
20
|
+
// elements, and past about a thousand routes fails with TS2590.
|
|
21
|
+
const PLAN: any[] = JSON.parse(${JSON.stringify(JSON.stringify(plan))})
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
describe('definition', () => {
|
|
@@ -26,7 +26,7 @@ const client = sdk.${model.Name}SDK.new(h.jo(&.{
|
|
|
26
26
|
|
|
27
27
|
publishedOptions.map((option: any) => {
|
|
28
28
|
if ('apikey' === option.name) {
|
|
29
|
-
Content(` .{ "${option.name}", h.vstr(
|
|
29
|
+
Content(` .{ "${option.name}", h.vstr(init.environ_map.get("${envName(model)}_APIKEY") orelse "") },
|
|
30
30
|
`)
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -30,7 +30,7 @@ const ReadmeQuick = cmp(function ReadmeQuick(props: any) {
|
|
|
30
30
|
|
|
31
31
|
const authActive = isAuthActive(model)
|
|
32
32
|
const ctor = authActive
|
|
33
|
-
? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(
|
|
33
|
+
? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(init.environ_map.get("${envName(model)}_APIKEY") orelse "") },\n}))`
|
|
34
34
|
: `sdk.${model.const.Name}SDK.new(h.vnull())`
|
|
35
35
|
|
|
36
36
|
// A type-correct zig expression constructing a voxgig struct Value.
|
|
@@ -51,7 +51,7 @@ const std = @import("std");
|
|
|
51
51
|
const sdk = @import("sdk");
|
|
52
52
|
const h = sdk.h;
|
|
53
53
|
|
|
54
|
-
const client = ${ctor};
|
|
54
|
+
${authActive ? '// init is the std.process.Init that main receives.\n' : ''}const client = ${ctor};
|
|
55
55
|
\`\`\`
|
|
56
56
|
|
|
57
57
|
`)
|
|
@@ -145,7 +145,7 @@ switch (client.${method}(h.vnull()).load(${loadArg}, h.vnull())) {
|
|
|
145
145
|
// shape so the docs reference REAL writable fields.
|
|
146
146
|
const examplePairs = (opname: string): string[] => {
|
|
147
147
|
const items = requestExampleItems(exampleEntity, opname)
|
|
148
|
-
.filter((it: any) => (it.name !== idF && it.name !== 'id') ||
|
|
148
|
+
.filter((it: any) => (it.name !== idF && (it.name !== 'id' || !it.optional)) ||
|
|
149
149
|
('create' === opname && !it.optional))
|
|
150
150
|
const required = items.filter((it: any) => !it.optional)
|
|
151
151
|
const optional = items.filter((it: any) => it.optional)
|
|
@@ -33,7 +33,7 @@ const ReadmeTopQuick = cmp(function ReadmeTopQuick(props: any) {
|
|
|
33
33
|
|
|
34
34
|
const authActive = isAuthActive(model)
|
|
35
35
|
const ctor = authActive
|
|
36
|
-
? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(
|
|
36
|
+
? `sdk.${model.const.Name}SDK.new(h.jo(&.{\n .{ "apikey", h.vstr(init.environ_map.get("${envName(model)}_APIKEY") orelse "") },\n}))`
|
|
37
37
|
: `sdk.${model.const.Name}SDK.new(h.vnull())`
|
|
38
38
|
|
|
39
39
|
Content(`\`\`\`zig
|
|
@@ -41,7 +41,7 @@ const std = @import("std");
|
|
|
41
41
|
const sdk = @import("sdk");
|
|
42
42
|
const h = sdk.h;
|
|
43
43
|
|
|
44
|
-
const client = ${ctor};
|
|
44
|
+
${authActive ? '// init is the std.process.Init that main receives.\n' : ''}const client = ${ctor};
|
|
45
45
|
|
|
46
46
|
`)
|
|
47
47
|
|
|
@@ -300,7 +300,9 @@ let drive_entity (client : sdk_client) (r : recorder) : (unit, string) Stdlib.re
|
|
|
300
300
|
(* An op the entity does not define, or a route the call
|
|
301
301
|
* cannot fill, fails before the chain is consulted: keep
|
|
302
302
|
* going. Anything else is the answer. *)
|
|
303
|
-
if
|
|
303
|
+
if List.mem e.err_code
|
|
304
|
+
["unsupported_op"; "url_param_missing"; "point_no_match"; "point_action_required"]
|
|
305
|
+
then ops more
|
|
304
306
|
else (out := Error e.err_msg)
|
|
305
307
|
| exception e -> out := Error (Printexc.to_string e))
|
|
306
308
|
in
|
|
@@ -294,7 +294,8 @@ class ProjectNameSecretsTest extends TestCase
|
|
|
294
294
|
function (\Throwable $error) use (&$caught) {
|
|
295
295
|
// A call whose route it cannot fill is refused before the
|
|
296
296
|
// chain is consulted, so it is not the refusal under test.
|
|
297
|
-
if ($error instanceof ProjectNameError &&
|
|
297
|
+
if ($error instanceof ProjectNameError &&
|
|
298
|
+
!in_array($error->sdk_code, ['url_param_missing', 'point_no_match', 'point_action_required'], true)) {
|
|
298
299
|
$caught = $error;
|
|
299
300
|
}
|
|
300
301
|
});
|
|
@@ -54,6 +54,15 @@ fn vnull() Value {
|
|
|
54
54
|
return Value{ .null = {} };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// A route the call cannot fill is refused before the chain is consulted.
|
|
58
|
+
fn refusedBeforeChain(code: []const u8) bool {
|
|
59
|
+
const codes = [_][]const u8{ "url_param_missing", "point_no_match", "point_action_required" };
|
|
60
|
+
for (codes) |c| {
|
|
61
|
+
if (std.mem.eql(u8, code, c)) return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
// Every block runs only when the feature is in THIS SDK - build.zig lists
|
|
58
67
|
// this file only then, so this is belt and braces rather than a gate.
|
|
59
68
|
fn present() bool {
|
|
@@ -294,14 +303,14 @@ fn drive_entity(client: *sdk.SDK) Drive {
|
|
|
294
303
|
if (h.getp(ops, "load") == .object) {
|
|
295
304
|
const res = ent.load(h.jo(&.{.{ "id", h.vstr("s01") }}), vnull());
|
|
296
305
|
switch (res) {
|
|
297
|
-
.err => |e| if (!
|
|
306
|
+
.err => |e| if (!refusedBeforeChain(e.code))
|
|
298
307
|
return .{ .ran = true, .ok = false, .msg = e.msg },
|
|
299
308
|
.ok => return .{ .ran = true, .ok = true, .msg = "" },
|
|
300
309
|
}
|
|
301
310
|
} else if (h.getp(ops, "list") == .object) {
|
|
302
311
|
const res = ent.list(h.omap(), vnull());
|
|
303
312
|
switch (res) {
|
|
304
|
-
.err => |e| if (!
|
|
313
|
+
.err => |e| if (!refusedBeforeChain(e.code))
|
|
305
314
|
return .{ .ran = true, .ok = false, .msg = e.msg },
|
|
306
315
|
.ok => return .{ .ran = true, .ok = true, .msg = "" },
|
|
307
316
|
}
|
package/src/action/check.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { kindCollection } from '../helpers/kindCollection'
|
|
2
2
|
|
|
3
3
|
import { unknownTags, TAGS } from '../helpers/applicability'
|
|
4
|
+
import { SURFACES, SURFACE_SINCE } from '../helpers/surface'
|
|
5
|
+
import { applyFacts, fact } from '../helpers/facts'
|
|
6
|
+
import { admitsBelow } from '../helpers/semver'
|
|
7
|
+
import { SDKGEN_VERSION } from '../helpers/shipped'
|
|
8
|
+
import { entityless, entitylessNote } from '../helpers/targetguard'
|
|
4
9
|
import Path from 'node:path'
|
|
5
10
|
|
|
6
11
|
import { KIT } from '../types'
|
|
@@ -14,6 +19,7 @@ import { SdkGenError } from '../utility'
|
|
|
14
19
|
|
|
15
20
|
import {
|
|
16
21
|
MANIFEST,
|
|
22
|
+
parityFinding,
|
|
17
23
|
probePackage,
|
|
18
24
|
validateManifest,
|
|
19
25
|
} from '../helpers/manifest'
|
|
@@ -32,6 +38,7 @@ import {
|
|
|
32
38
|
ANCHOR_RE,
|
|
33
39
|
compileModel,
|
|
34
40
|
publishOverrideProbe,
|
|
41
|
+
schemaHooks,
|
|
35
42
|
slashComments,
|
|
36
43
|
} from '../helpers/modelcheck'
|
|
37
44
|
|
|
@@ -189,7 +196,11 @@ function checkItems(fs: any, sdk: string, manifest?: Manifest): Finding[] {
|
|
|
189
196
|
continue
|
|
190
197
|
}
|
|
191
198
|
|
|
192
|
-
found.push(...checkDefinition(fs, kind, name, file
|
|
199
|
+
found.push(...checkDefinition(fs, kind, name, file, {
|
|
200
|
+
manifest: Path.join(sdk, '..', MANIFEST),
|
|
201
|
+
tier: manifest?.parity?.[name],
|
|
202
|
+
range: manifest?.engines?.sdkgen,
|
|
203
|
+
}))
|
|
193
204
|
}
|
|
194
205
|
}
|
|
195
206
|
|
|
@@ -197,8 +208,12 @@ function checkItems(fs: any, sdk: string, manifest?: Manifest): Finding[] {
|
|
|
197
208
|
}
|
|
198
209
|
|
|
199
210
|
|
|
211
|
+
// What the manifest says about an item, for the checks that compare the two.
|
|
212
|
+
type Declared = { manifest: string, tier?: string, range?: string }
|
|
213
|
+
|
|
214
|
+
|
|
200
215
|
function checkDefinition(
|
|
201
|
-
fs: any, kind: string, name: string, file: string,
|
|
216
|
+
fs: any, kind: string, name: string, file: string, pkg?: Declared,
|
|
202
217
|
): Finding[] {
|
|
203
218
|
const found: Finding[] = []
|
|
204
219
|
const raw = String(fs.readFileSync(file, 'utf8'))
|
|
@@ -208,7 +223,7 @@ function checkDefinition(
|
|
|
208
223
|
const legacyFile = isLegacyPath(file)
|
|
209
224
|
const legacy = legacyFile || src !== raw
|
|
210
225
|
|
|
211
|
-
const at = (level: 'error' | 'warn', point: string, note: string): Finding =>
|
|
226
|
+
const at = (level: 'error' | 'warn' | 'info', point: string, note: string): Finding =>
|
|
212
227
|
({ level, point, kind, name, file, note: file + ': ' + note })
|
|
213
228
|
|
|
214
229
|
if (legacy) {
|
|
@@ -313,17 +328,78 @@ function checkDefinition(
|
|
|
313
328
|
|
|
314
329
|
if ('target' === kind) {
|
|
315
330
|
found.push(...checkTargetModel(checked, name, file, at))
|
|
331
|
+
|
|
332
|
+
if (0 === unified.errors.length && null != declared) {
|
|
333
|
+
found.push(...checkTargetSurface(unified.model, name, pkg, at))
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const title = (declared as any)?.title
|
|
337
|
+
if (null != declared && ('string' !== typeof title || '' === title.trim())) {
|
|
338
|
+
found.push(at('warn', 'target-title-missing',
|
|
339
|
+
'declares no `title` — the generated documents name this target by its ' +
|
|
340
|
+
"origin's label, else as `" + name + '`'))
|
|
341
|
+
}
|
|
316
342
|
}
|
|
317
343
|
|
|
318
344
|
if ('feature' === kind) {
|
|
319
345
|
found.push(...checkFeatureModel(strict.model, name, at))
|
|
346
|
+
found.push(...checkFeatureHooks(strict.model, name, at))
|
|
320
347
|
}
|
|
321
348
|
|
|
322
349
|
return found
|
|
323
350
|
}
|
|
324
351
|
|
|
325
352
|
|
|
326
|
-
type At = (level: 'error' | 'warn', point: string, note: string) => Finding
|
|
353
|
+
type At = (level: 'error' | 'warn' | 'info', point: string, note: string) => Finding
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
// The surface the fact rules give the target, against its parity tier, and
|
|
357
|
+
// its declared word against the releases that read it. Generation reads a
|
|
358
|
+
// word it does not know as unknown, so no word fails it.
|
|
359
|
+
function checkTargetSurface(
|
|
360
|
+
model: any, name: string, pkg: Declared | undefined, at: At,
|
|
361
|
+
): Finding[] {
|
|
362
|
+
let surface: string
|
|
363
|
+
|
|
364
|
+
try {
|
|
365
|
+
applyFacts(model)
|
|
366
|
+
surface = fact(model.main[KIT].target[name], 'surface')
|
|
367
|
+
}
|
|
368
|
+
catch (err: any) {
|
|
369
|
+
return [at('error', 'target-facts', 'the fact rules fail on this target alone: ' + err.message)]
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const found: Finding[] = null == pkg?.tier ? [] :
|
|
373
|
+
parityFinding(pkg.manifest, name, pkg.tier, surface)
|
|
374
|
+
|
|
375
|
+
const target = model.main[KIT].target[name]
|
|
376
|
+
if (entityless(target)) {
|
|
377
|
+
found.push(at('error', 'target-entity-off', entitylessNote(name)))
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const word = target.surface
|
|
381
|
+
if ('string' !== typeof word || '' === word) {
|
|
382
|
+
return found
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const since = SURFACE_SINCE[word]
|
|
386
|
+
if (null == since) {
|
|
387
|
+
found.push(at('warn', 'target-surface-unknown',
|
|
388
|
+
'declares surface `' + word + '`, which sdkgen ' + SDKGEN_VERSION +
|
|
389
|
+
' does not know (' + SURFACES.join(', ') + '): generation reads it as unknown ' +
|
|
390
|
+
'and names the target by its title. A release that introduces the word reads it, ' +
|
|
391
|
+
'from that release on; otherwise it is a misspelling'))
|
|
392
|
+
}
|
|
393
|
+
else if (false !== admitsBelow(pkg?.range ?? '', since)) {
|
|
394
|
+
found.push(at('info', 'target-surface-since',
|
|
395
|
+
'declares surface `' + word + '`, which sdkgen reads from ' + since + '; ' +
|
|
396
|
+
(null == pkg?.range ? 'the manifest declares no `engines.sdkgen`, so it' :
|
|
397
|
+
'`engines.sdkgen` `' + pkg.range + '`') +
|
|
398
|
+
' admits older releases, which ignore the slot'))
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
return found
|
|
402
|
+
}
|
|
327
403
|
|
|
328
404
|
|
|
329
405
|
// The publish-override probe: unify the target model with a project that sets
|
|
@@ -389,6 +465,25 @@ function checkFeatureModel(model: any, name: string, at: At): Finding[] {
|
|
|
389
465
|
}
|
|
390
466
|
|
|
391
467
|
|
|
468
|
+
function checkFeatureHooks(model: any, name: string, at: At): Finding[] {
|
|
469
|
+
const hook = model?.main?.[KIT]?.feature?.[name]?.hook
|
|
470
|
+
if (null == hook || 'object' !== typeof hook) {
|
|
471
|
+
return []
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const known = schemaHooks()
|
|
475
|
+
const unknown = Object.keys(hook).filter((h: string) => !known.includes(h)).sort()
|
|
476
|
+
if (0 === unknown.length) {
|
|
477
|
+
return []
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return [at('error', 'feature-hook-unknown',
|
|
481
|
+
'declares hook(s) the base schema does not list: ' + unknown.join(', ') +
|
|
482
|
+
' — no pipeline fires them, so the feature never runs there. The hooks are: ' +
|
|
483
|
+
known.join(', '))]
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
|
|
392
487
|
// The template trees: does a feature's declared coverage exist, and is
|
|
393
488
|
// anything in a target's tree feature-shaped but invisible to the trim?
|
|
394
489
|
function checkFeatureSource(
|
package/src/action/copies.ts
CHANGED
|
@@ -362,6 +362,8 @@ async function guardCopies<T>(
|
|
|
362
362
|
basedir: BASE_DIR,
|
|
363
363
|
conflictdir: CONFLICT_DIR,
|
|
364
364
|
versions: gitVersions,
|
|
365
|
+
forget: (rels: string[]) => appendEntry(actx, 'keep',
|
|
366
|
+
{ files: Object.fromEntries(rels.map((rel: string) => [rel, null])) }),
|
|
365
367
|
error: (msg: string) => new SdkGenError(msg),
|
|
366
368
|
}, (gfs: any) => run({ ...actx, fs: () => gfs, copyGuarded: true }))
|
|
367
369
|
}
|