milieu-cli 0.3.2 → 0.4.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/README.md +177 -76
- package/dist/bridges/context/agents-json.d.ts +0 -1
- package/dist/bridges/context/agents-json.js +21 -12
- package/dist/bridges/context/auth-clarity.d.ts +0 -1
- package/dist/bridges/context/auth-clarity.js +11 -9
- package/dist/bridges/context/auth-legibility.d.ts +2 -2
- package/dist/bridges/context/auth-legibility.js +67 -60
- package/dist/bridges/context/index.d.ts +1 -2
- package/dist/bridges/context/index.js +19 -40
- package/dist/bridges/context/oauth-metadata.d.ts +14 -0
- package/dist/bridges/context/oauth-metadata.js +127 -0
- package/dist/bridges/context/probe.d.ts +33 -0
- package/dist/bridges/context/probe.js +157 -0
- package/dist/bridges/context/rate-limits.d.ts +5 -2
- package/dist/bridges/context/rate-limits.js +27 -51
- package/dist/bridges/context/tos-contact.d.ts +13 -4
- package/dist/bridges/context/tos-contact.js +108 -46
- package/dist/bridges/context/versioning.d.ts +1 -2
- package/dist/bridges/context/versioning.js +42 -7
- package/dist/bridges/index.d.ts +0 -1
- package/dist/bridges/index.js +0 -1
- package/dist/bridges/reachability/crawler-policy.d.ts +30 -10
- package/dist/bridges/reachability/crawler-policy.js +41 -56
- package/dist/bridges/reachability/http-status.d.ts +3 -2
- package/dist/bridges/reachability/http-status.js +18 -3
- package/dist/bridges/reachability/https-check.d.ts +2 -2
- package/dist/bridges/reachability/https-check.js +6 -3
- package/dist/bridges/reachability/index.d.ts +1 -2
- package/dist/bridges/reachability/index.js +34 -43
- package/dist/bridges/reachability/meta-robots.d.ts +0 -13
- package/dist/bridges/reachability/meta-robots.js +89 -101
- package/dist/bridges/reachability/robots-parser.d.ts +7 -7
- package/dist/bridges/reachability/robots-parser.js +65 -15
- package/dist/bridges/reachability/robots-txt.d.ts +4 -2
- package/dist/bridges/reachability/robots-txt.js +33 -60
- package/dist/bridges/schema/descriptions.d.ts +2 -2
- package/dist/bridges/schema/descriptions.js +79 -44
- package/dist/bridges/schema/error-schemas.d.ts +2 -2
- package/dist/bridges/schema/error-schemas.js +31 -18
- package/dist/bridges/schema/index.d.ts +2 -2
- package/dist/bridges/schema/index.js +48 -30
- package/dist/bridges/schema/oas-types.d.ts +65 -26
- package/dist/bridges/schema/oas-types.js +37 -7
- package/dist/bridges/schema/operation-ids.d.ts +2 -2
- package/dist/bridges/schema/operation-ids.js +2 -3
- package/dist/bridges/schema/required-fields.d.ts +2 -2
- package/dist/bridges/schema/required-fields.js +12 -10
- package/dist/bridges/schema/schema-sources.d.ts +19 -0
- package/dist/bridges/schema/schema-sources.js +182 -0
- package/dist/bridges/schema/schema-types.d.ts +2 -2
- package/dist/bridges/schema/schema-types.js +20 -21
- package/dist/bridges/separation/api-presence.d.ts +3 -15
- package/dist/bridges/separation/api-presence.js +34 -85
- package/dist/bridges/separation/developer-docs.d.ts +6 -18
- package/dist/bridges/separation/developer-docs.js +100 -99
- package/dist/bridges/separation/docs-discovery.d.ts +28 -0
- package/dist/bridges/separation/docs-discovery.js +95 -0
- package/dist/bridges/separation/evidence-summary.d.ts +2 -0
- package/dist/bridges/separation/evidence-summary.js +67 -0
- package/dist/bridges/separation/index.d.ts +2 -19
- package/dist/bridges/separation/index.js +35 -39
- package/dist/bridges/separation/published-routes.d.ts +69 -0
- package/dist/bridges/separation/published-routes.js +271 -0
- package/dist/bridges/separation/sdk-references.d.ts +8 -3
- package/dist/bridges/separation/sdk-references.js +86 -61
- package/dist/bridges/separation/webhook-support.d.ts +3 -23
- package/dist/bridges/separation/webhook-support.js +61 -162
- package/dist/bridges/standards/a2a-agent-card.d.ts +0 -1
- package/dist/bridges/standards/a2a-agent-card.js +24 -9
- package/dist/bridges/standards/graphql.d.ts +3 -4
- package/dist/bridges/standards/graphql.js +70 -66
- package/dist/bridges/standards/index.d.ts +1 -2
- package/dist/bridges/standards/index.js +57 -47
- package/dist/bridges/standards/json-ld.d.ts +25 -11
- package/dist/bridges/standards/json-ld.js +114 -56
- package/dist/bridges/standards/llms-txt.d.ts +4 -2
- package/dist/bridges/standards/llms-txt.js +46 -32
- package/dist/bridges/standards/markdown-negotiation.d.ts +4 -1
- package/dist/bridges/standards/markdown-negotiation.js +16 -11
- package/dist/bridges/standards/mcp.d.ts +3 -12
- package/dist/bridges/standards/mcp.js +89 -132
- package/dist/bridges/standards/openapi.d.ts +7 -15
- package/dist/bridges/standards/openapi.js +657 -207
- package/dist/bridges/standards/probe-evidence.d.ts +30 -0
- package/dist/bridges/standards/probe-evidence.js +90 -0
- package/dist/bridges/standards/schema-org.d.ts +15 -9
- package/dist/bridges/standards/schema-org.js +38 -64
- package/dist/bridges/standards/sitemap.d.ts +2 -3
- package/dist/bridges/standards/sitemap.js +161 -169
- package/dist/bridges/standards/well-known.d.ts +3 -7
- package/dist/bridges/standards/well-known.js +28 -12
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +107 -22
- package/dist/cli/journey-commands.d.ts +3 -0
- package/dist/cli/journey-commands.js +35 -0
- package/dist/cli/read-report.d.ts +2 -0
- package/dist/cli/read-report.js +11 -0
- package/dist/core/bridge-output.d.ts +11 -0
- package/dist/core/bridge-output.js +86 -0
- package/dist/core/bridge-session.d.ts +28 -0
- package/dist/core/bridge-session.js +58 -0
- package/dist/core/bridge-worker.d.ts +1 -0
- package/dist/core/bridge-worker.js +66 -0
- package/dist/core/diff.d.ts +79 -0
- package/dist/core/diff.js +499 -0
- package/dist/core/explanations.d.ts +1 -3
- package/dist/core/explanations.js +36 -59
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +2 -3
- package/dist/core/scan-options.d.ts +0 -1
- package/dist/core/scan-options.js +14 -6
- package/dist/core/scan.d.ts +0 -1
- package/dist/core/scan.js +91 -41
- package/dist/core/scoring.d.ts +6 -0
- package/dist/core/scoring.js +27 -0
- package/dist/core/types.d.ts +97 -61
- package/dist/core/types.js +9 -3
- package/dist/core/validate-report.d.ts +5 -0
- package/dist/core/validate-report.js +95 -0
- package/dist/core/version.d.ts +0 -1
- package/dist/core/version.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/journey/body-worker.d.ts +27 -0
- package/dist/journey/body-worker.js +140 -0
- package/dist/journey/case.d.ts +74 -0
- package/dist/journey/case.js +187 -0
- package/dist/journey/cli.d.ts +14 -0
- package/dist/journey/cli.js +226 -0
- package/dist/journey/compare.d.ts +43 -0
- package/dist/journey/compare.js +83 -0
- package/dist/journey/contracts.d.ts +143 -0
- package/dist/journey/contracts.js +37 -0
- package/dist/journey/decision.d.ts +72 -0
- package/dist/journey/decision.js +121 -0
- package/dist/journey/demo.d.ts +36 -0
- package/dist/journey/demo.js +137 -0
- package/dist/journey/document.d.ts +8 -0
- package/dist/journey/document.js +113 -0
- package/dist/journey/excerpt.d.ts +6 -0
- package/dist/journey/excerpt.js +54 -0
- package/dist/journey/name-guidance.d.ts +2 -0
- package/dist/journey/name-guidance.js +41 -0
- package/dist/journey/providers.d.ts +34 -0
- package/dist/journey/providers.js +197 -0
- package/dist/journey/report-validation.d.ts +3 -0
- package/dist/journey/report-validation.js +457 -0
- package/dist/journey/runner.d.ts +12 -0
- package/dist/journey/runner.js +321 -0
- package/dist/journey/scope.d.ts +8 -0
- package/dist/journey/scope.js +50 -0
- package/dist/journey/transport.d.ts +3 -0
- package/dist/journey/transport.js +45 -0
- package/dist/journey/verify.d.ts +21 -0
- package/dist/journey/verify.js +213 -0
- package/dist/render/colors.d.ts +6 -7
- package/dist/render/colors.js +16 -25
- package/dist/render/discovery-guidance.d.ts +3 -0
- package/dist/render/discovery-guidance.js +66 -0
- package/dist/render/format-bridge.d.ts +1 -2
- package/dist/render/format-bridge.js +22 -17
- package/dist/render/format-diff.d.ts +2 -0
- package/dist/render/format-diff.js +169 -0
- package/dist/render/format-scan.d.ts +0 -1
- package/dist/render/format-scan.js +6 -4
- package/dist/render/format-verbose.d.ts +0 -1
- package/dist/render/format-verbose.js +7 -4
- package/dist/render/index.d.ts +0 -1
- package/dist/render/index.js +1 -2
- package/dist/render/oauth-observations.d.ts +4 -0
- package/dist/render/oauth-observations.js +27 -0
- package/dist/render/progress-bar.d.ts +1 -2
- package/dist/render/progress-bar.js +8 -6
- package/dist/render/robots-inventory.d.ts +3 -0
- package/dist/render/robots-inventory.js +38 -0
- package/dist/render/symbols.d.ts +4 -10
- package/dist/render/symbols.js +15 -17
- package/dist/render/terminal-text.d.ts +1 -3
- package/dist/render/terminal-text.js +1 -5
- package/dist/utils/analysis-worker-entry.d.ts +3 -0
- package/dist/utils/analysis-worker-entry.js +12 -0
- package/dist/utils/analysis-worker.d.ts +12 -0
- package/dist/utils/analysis-worker.js +54 -0
- package/dist/utils/html.d.ts +39 -0
- package/dist/utils/html.js +261 -0
- package/dist/utils/http-client.d.ts +24 -17
- package/dist/utils/http-client.js +166 -200
- package/dist/utils/http-types.d.ts +43 -0
- package/dist/utils/http-types.js +11 -0
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/package-registry.d.ts +11 -0
- package/dist/utils/package-registry.js +69 -0
- package/dist/utils/read-json-file.d.ts +3 -0
- package/dist/utils/read-json-file.js +41 -0
- package/dist/utils/record.d.ts +1 -0
- package/dist/utils/record.js +3 -0
- package/dist/utils/response-body.d.ts +7 -0
- package/dist/utils/response-body.js +71 -0
- package/dist/utils/ssrf.d.ts +11 -15
- package/dist/utils/ssrf.js +80 -44
- package/dist/utils/terminal-text.d.ts +2 -0
- package/dist/utils/terminal-text.js +4 -0
- package/dist/utils/url.d.ts +29 -1
- package/dist/utils/url.js +147 -17
- package/docs/examples/onboarding/account-claim.json +25 -0
- package/docs/examples/onboarding/pages/account-claim.html +3 -0
- package/docs/examples/onboarding/pages/production-activation.html +3 -0
- package/docs/examples/onboarding/pages/test-credential.html +3 -0
- package/docs/examples/onboarding/production-activation.json +25 -0
- package/docs/examples/onboarding/test-credential.json +25 -0
- package/docs/journey-qualification.md +46 -0
- package/docs/journeys.md +83 -0
- package/package.json +28 -8
- package/dist/bridges/context/agents-json.d.ts.map +0 -1
- package/dist/bridges/context/agents-json.js.map +0 -1
- package/dist/bridges/context/auth-clarity.d.ts.map +0 -1
- package/dist/bridges/context/auth-clarity.js.map +0 -1
- package/dist/bridges/context/auth-legibility.d.ts.map +0 -1
- package/dist/bridges/context/auth-legibility.js.map +0 -1
- package/dist/bridges/context/index.d.ts.map +0 -1
- package/dist/bridges/context/index.js.map +0 -1
- package/dist/bridges/context/rate-limits.d.ts.map +0 -1
- package/dist/bridges/context/rate-limits.js.map +0 -1
- package/dist/bridges/context/tos-contact.d.ts.map +0 -1
- package/dist/bridges/context/tos-contact.js.map +0 -1
- package/dist/bridges/context/versioning.d.ts.map +0 -1
- package/dist/bridges/context/versioning.js.map +0 -1
- package/dist/bridges/index.d.ts.map +0 -1
- package/dist/bridges/index.js.map +0 -1
- package/dist/bridges/reachability/crawler-policy.d.ts.map +0 -1
- package/dist/bridges/reachability/crawler-policy.js.map +0 -1
- package/dist/bridges/reachability/http-status.d.ts.map +0 -1
- package/dist/bridges/reachability/http-status.js.map +0 -1
- package/dist/bridges/reachability/https-check.d.ts.map +0 -1
- package/dist/bridges/reachability/https-check.js.map +0 -1
- package/dist/bridges/reachability/index.d.ts.map +0 -1
- package/dist/bridges/reachability/index.js.map +0 -1
- package/dist/bridges/reachability/meta-robots.d.ts.map +0 -1
- package/dist/bridges/reachability/meta-robots.js.map +0 -1
- package/dist/bridges/reachability/robots-parser.d.ts.map +0 -1
- package/dist/bridges/reachability/robots-parser.js.map +0 -1
- package/dist/bridges/reachability/robots-txt.d.ts.map +0 -1
- package/dist/bridges/reachability/robots-txt.js.map +0 -1
- package/dist/bridges/schema/descriptions.d.ts.map +0 -1
- package/dist/bridges/schema/descriptions.js.map +0 -1
- package/dist/bridges/schema/error-schemas.d.ts.map +0 -1
- package/dist/bridges/schema/error-schemas.js.map +0 -1
- package/dist/bridges/schema/index.d.ts.map +0 -1
- package/dist/bridges/schema/index.js.map +0 -1
- package/dist/bridges/schema/oas-types.d.ts.map +0 -1
- package/dist/bridges/schema/oas-types.js.map +0 -1
- package/dist/bridges/schema/operation-ids.d.ts.map +0 -1
- package/dist/bridges/schema/operation-ids.js.map +0 -1
- package/dist/bridges/schema/required-fields.d.ts.map +0 -1
- package/dist/bridges/schema/required-fields.js.map +0 -1
- package/dist/bridges/schema/schema-types.d.ts.map +0 -1
- package/dist/bridges/schema/schema-types.js.map +0 -1
- package/dist/bridges/separation/api-presence.d.ts.map +0 -1
- package/dist/bridges/separation/api-presence.js.map +0 -1
- package/dist/bridges/separation/developer-docs.d.ts.map +0 -1
- package/dist/bridges/separation/developer-docs.js.map +0 -1
- package/dist/bridges/separation/index.d.ts.map +0 -1
- package/dist/bridges/separation/index.js.map +0 -1
- package/dist/bridges/separation/sdk-references.d.ts.map +0 -1
- package/dist/bridges/separation/sdk-references.js.map +0 -1
- package/dist/bridges/separation/webhook-support.d.ts.map +0 -1
- package/dist/bridges/separation/webhook-support.js.map +0 -1
- package/dist/bridges/standards/a2a-agent-card.d.ts.map +0 -1
- package/dist/bridges/standards/a2a-agent-card.js.map +0 -1
- package/dist/bridges/standards/graphql.d.ts.map +0 -1
- package/dist/bridges/standards/graphql.js.map +0 -1
- package/dist/bridges/standards/index.d.ts.map +0 -1
- package/dist/bridges/standards/index.js.map +0 -1
- package/dist/bridges/standards/json-ld.d.ts.map +0 -1
- package/dist/bridges/standards/json-ld.js.map +0 -1
- package/dist/bridges/standards/llms-txt.d.ts.map +0 -1
- package/dist/bridges/standards/llms-txt.js.map +0 -1
- package/dist/bridges/standards/markdown-negotiation.d.ts.map +0 -1
- package/dist/bridges/standards/markdown-negotiation.js.map +0 -1
- package/dist/bridges/standards/mcp.d.ts.map +0 -1
- package/dist/bridges/standards/mcp.js.map +0 -1
- package/dist/bridges/standards/openapi.d.ts.map +0 -1
- package/dist/bridges/standards/openapi.js.map +0 -1
- package/dist/bridges/standards/schema-org.d.ts.map +0 -1
- package/dist/bridges/standards/schema-org.js.map +0 -1
- package/dist/bridges/standards/sitemap.d.ts.map +0 -1
- package/dist/bridges/standards/sitemap.js.map +0 -1
- package/dist/bridges/standards/well-known.d.ts.map +0 -1
- package/dist/bridges/standards/well-known.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/core/explanations.d.ts.map +0 -1
- package/dist/core/explanations.js.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/scan-options.d.ts.map +0 -1
- package/dist/core/scan-options.js.map +0 -1
- package/dist/core/scan.d.ts.map +0 -1
- package/dist/core/scan.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/render/colors.d.ts.map +0 -1
- package/dist/render/colors.js.map +0 -1
- package/dist/render/format-bridge.d.ts.map +0 -1
- package/dist/render/format-bridge.js.map +0 -1
- package/dist/render/format-scan.d.ts.map +0 -1
- package/dist/render/format-scan.js.map +0 -1
- package/dist/render/format-verbose.d.ts.map +0 -1
- package/dist/render/format-verbose.js.map +0 -1
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/index.js.map +0 -1
- package/dist/render/progress-bar.d.ts.map +0 -1
- package/dist/render/progress-bar.js.map +0 -1
- package/dist/render/symbols.d.ts.map +0 -1
- package/dist/render/symbols.js.map +0 -1
- package/dist/render/terminal-text.d.ts.map +0 -1
- package/dist/render/terminal-text.js.map +0 -1
- package/dist/utils/http-client.d.ts.map +0 -1
- package/dist/utils/http-client.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/ssrf.d.ts.map +0 -1
- package/dist/utils/ssrf.js.map +0 -1
- package/dist/utils/url.d.ts.map +0 -1
- package/dist/utils/url.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { collectOperations } from "./oas-types.js";
|
|
2
|
-
export function checkOperationIds(spec) {
|
|
2
|
+
export function checkOperationIds(spec, ops = collectOperations(spec), budget) {
|
|
3
|
+
budget?.charge(ops.length);
|
|
3
4
|
const id = "schema_operation_ids";
|
|
4
5
|
const label = "Operation IDs";
|
|
5
|
-
const ops = collectOperations(spec);
|
|
6
6
|
const total = ops.length;
|
|
7
7
|
if (total === 0) {
|
|
8
8
|
return { id, label, status: "fail", detail: "No operations found in spec", data: { total: 0, missing: 0 } };
|
|
@@ -15,4 +15,3 @@ export function checkOperationIds(spec) {
|
|
|
15
15
|
return { id, label, status: "partial", detail: `${withId} of ${total} operations have operationId (${missing} missing)`, data: { total, missing } };
|
|
16
16
|
return { id, label, status: "fail", detail: `Only ${withId} of ${total} operations have operationId (${missing} missing)`, data: { total, missing } };
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=operation-ids.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Check } from "../../core/types.js";
|
|
2
2
|
import type { ParsedOpenApiSpec } from "./oas-types.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { type SchemaWorkBudget } from "./schema-sources.js";
|
|
4
|
+
export declare function checkRequiredFields(spec: ParsedOpenApiSpec | undefined, ops?: [string, string, import("./oas-types.js").OasOperation][], budget?: SchemaWorkBudget): Check;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { collectOperations } from "./oas-types.js";
|
|
2
|
-
|
|
2
|
+
import { requestSchemas, schemaForFields } from "./schema-sources.js";
|
|
3
|
+
export function checkRequiredFields(spec, ops = collectOperations(spec), budget) {
|
|
4
|
+
budget?.charge(ops.length);
|
|
3
5
|
const id = "schema_required_fields";
|
|
4
6
|
const label = "Required Fields";
|
|
5
|
-
const ops = collectOperations(spec);
|
|
6
7
|
let schemasWithProperties = 0;
|
|
7
8
|
let withRequired = 0;
|
|
8
|
-
for (const [, , op] of ops) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
for (const [path, , op] of ops) {
|
|
10
|
+
for (const raw of requestSchemas(spec, path, op, budget)) {
|
|
11
|
+
const schema = schemaForFields(spec, raw, budget);
|
|
12
|
+
if (!schema)
|
|
13
|
+
return { id, label, status: "error", detail: "Could not inspect all request fields due to a reference or schema composition" };
|
|
14
|
+
const fieldCount = Object.keys(schema.properties ?? {}).length;
|
|
15
|
+
budget?.charge(fieldCount);
|
|
16
|
+
if (fieldCount === 0)
|
|
14
17
|
continue;
|
|
15
18
|
schemasWithProperties++;
|
|
16
19
|
if (Array.isArray(schema.required) && schema.required.length > 0)
|
|
@@ -18,11 +21,10 @@ export function checkRequiredFields(spec) {
|
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
if (schemasWithProperties === 0)
|
|
21
|
-
return { id, label, status: "
|
|
24
|
+
return { id, label, status: "error", detail: "No request body schemas with properties to evaluate", data: { schemasWithProperties: 0, withRequired: 0 } };
|
|
22
25
|
if (withRequired === schemasWithProperties)
|
|
23
26
|
return { id, label, status: "pass", detail: `All ${schemasWithProperties} request schemas declare required fields`, data: { schemasWithProperties, withRequired } };
|
|
24
27
|
if (withRequired >= Math.ceil(schemasWithProperties * 0.5))
|
|
25
28
|
return { id, label, status: "partial", detail: `${withRequired} of ${schemasWithProperties} request schemas declare required fields`, data: { schemasWithProperties, withRequired } };
|
|
26
29
|
return { id, label, status: "fail", detail: `Only ${withRequired} of ${schemasWithProperties} request schemas declare required fields`, data: { schemasWithProperties, withRequired } };
|
|
27
30
|
}
|
|
28
|
-
//# sourceMappingURL=required-fields.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OasOperation, OasParameter, OasPathItem, OasRequestBody, OasResponse, OasSchema, OasSchemaObject, ParsedOpenApiSpec } from "./oas-types.js";
|
|
2
|
+
/** One budget per inspection. Shared references count again each time their contents are traversed. */
|
|
3
|
+
export declare class SchemaWorkBudget {
|
|
4
|
+
private remaining;
|
|
5
|
+
constructor(remaining?: number);
|
|
6
|
+
charge(units?: number): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class SchemaWorkLimit extends Error {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare function resolvePathItem(spec: ParsedOpenApiSpec | undefined, path: string, budget?: SchemaWorkBudget): OasPathItem | undefined;
|
|
12
|
+
/** Operations inherit path parameters, overriding by (in, name) in both dialects. */
|
|
13
|
+
export declare function operationParameters(spec: ParsedOpenApiSpec | undefined, path: string, op: OasOperation, budget?: SchemaWorkBudget): OasParameter[];
|
|
14
|
+
export declare function resolveRequestBody(spec: ParsedOpenApiSpec | undefined, op: OasOperation, budget?: SchemaWorkBudget): OasRequestBody | undefined;
|
|
15
|
+
export declare function declaresType(spec: ParsedOpenApiSpec | undefined, schema: OasSchema | undefined, budget?: SchemaWorkBudget): boolean | undefined;
|
|
16
|
+
/** An undefined entry means a declared source could not be inspected. */
|
|
17
|
+
export declare function requestSchemas(spec: ParsedOpenApiSpec | undefined, path: string, op: OasOperation, budget?: SchemaWorkBudget): (OasSchema | undefined)[];
|
|
18
|
+
export declare function responseSchemas(spec: ParsedOpenApiSpec | undefined, response: OasResponse | undefined, budget?: SchemaWorkBudget): (OasSchema | undefined)[];
|
|
19
|
+
export declare function schemaForFields(spec: ParsedOpenApiSpec | undefined, schema: OasSchema | undefined, budget?: SchemaWorkBudget): OasSchemaObject | undefined;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { isRecord } from "../../utils/record.js";
|
|
2
|
+
/** One budget per inspection. Shared references count again each time their contents are traversed. */
|
|
3
|
+
export class SchemaWorkBudget {
|
|
4
|
+
remaining;
|
|
5
|
+
constructor(remaining = 2_000_000) {
|
|
6
|
+
this.remaining = remaining;
|
|
7
|
+
}
|
|
8
|
+
charge(units = 1) {
|
|
9
|
+
this.remaining -= units;
|
|
10
|
+
if (this.remaining < 0)
|
|
11
|
+
throw new SchemaWorkLimit();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class SchemaWorkLimit extends Error {
|
|
15
|
+
constructor() { super("OpenAPI inspection exceeded its work limit"); }
|
|
16
|
+
}
|
|
17
|
+
function supportsJsonSchema(spec) {
|
|
18
|
+
return /^3\.(?:[1-9]\d*)\./.test(spec?.openapi ?? "");
|
|
19
|
+
}
|
|
20
|
+
/** Follow JSON Pointers in this document. Named anchors and other resources require a different resolver. */
|
|
21
|
+
function localValue(spec, raw, budget, kind = "object") {
|
|
22
|
+
budget?.charge();
|
|
23
|
+
let value = raw;
|
|
24
|
+
let description;
|
|
25
|
+
const visited = new Set();
|
|
26
|
+
const modern = supportsJsonSchema(spec);
|
|
27
|
+
while (isRecord(value) && "$ref" in value) {
|
|
28
|
+
const ref = value.$ref;
|
|
29
|
+
if (typeof ref !== "string" || !ref.startsWith("#/") || ref.length > 8192 || visited.has(ref) || visited.size >= 64)
|
|
30
|
+
return;
|
|
31
|
+
budget?.charge();
|
|
32
|
+
visited.add(ref);
|
|
33
|
+
// Sibling operations, parameters or servers could collide with the
|
|
34
|
+
// referenced item. Do not silently drop or override either definition.
|
|
35
|
+
if (kind === "path" && Object.keys(value).some(key => !["$ref", "summary", "description"].includes(key)))
|
|
36
|
+
return;
|
|
37
|
+
if (modern) {
|
|
38
|
+
// Schema $ref siblings apply alongside the target. Unsupported structural
|
|
39
|
+
// siblings cannot safely be dropped or combined by shallow object spread.
|
|
40
|
+
if (kind === "schema" && Object.keys(value).some(key => !["$ref", "description", "title", "$comment"].includes(key)))
|
|
41
|
+
return;
|
|
42
|
+
if (typeof value.description === "string")
|
|
43
|
+
description ??= value.description;
|
|
44
|
+
}
|
|
45
|
+
let pointer;
|
|
46
|
+
try {
|
|
47
|
+
pointer = decodeURIComponent(ref.slice(2));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const tokens = pointer.split("/");
|
|
53
|
+
budget?.charge(tokens.length);
|
|
54
|
+
if (tokens.length > 128)
|
|
55
|
+
return;
|
|
56
|
+
value = spec;
|
|
57
|
+
for (const token of tokens) {
|
|
58
|
+
if (/~(?![01])/.test(token))
|
|
59
|
+
return;
|
|
60
|
+
const key = token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
61
|
+
if (!value || typeof value !== "object" || !Object.hasOwn(value, key))
|
|
62
|
+
return;
|
|
63
|
+
// An embedded JSON Schema resource changes the base for references within it.
|
|
64
|
+
if (kind === "schema" && modern && Object.hasOwn(value, "$id"))
|
|
65
|
+
return;
|
|
66
|
+
value = value[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (description !== undefined) {
|
|
70
|
+
if (isRecord(value))
|
|
71
|
+
return { ...value, description };
|
|
72
|
+
// Boolean schemas declare no types or fields, but a 3.1 use site can
|
|
73
|
+
// still supply a field description alongside its $ref to a boolean.
|
|
74
|
+
if (kind === "schema" && typeof value === "boolean")
|
|
75
|
+
return { description };
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
export function resolvePathItem(spec, path, budget) {
|
|
80
|
+
const value = localValue(spec, spec?.paths?.[path], budget, "path");
|
|
81
|
+
return isRecord(value) ? value : undefined;
|
|
82
|
+
}
|
|
83
|
+
/** Operations inherit path parameters, overriding by (in, name) in both dialects. */
|
|
84
|
+
export function operationParameters(spec, path, op, budget) {
|
|
85
|
+
const effective = [];
|
|
86
|
+
// Keyed by the two strings as they are: a combined key would copy each
|
|
87
|
+
// name once for every operation that reads the parameter.
|
|
88
|
+
const positions = new Map();
|
|
89
|
+
const unmerged = [];
|
|
90
|
+
for (const group of [resolvePathItem(spec, path, budget)?.parameters, op.parameters]) {
|
|
91
|
+
if (!Array.isArray(group))
|
|
92
|
+
continue;
|
|
93
|
+
budget?.charge(group.length);
|
|
94
|
+
for (const raw of group) {
|
|
95
|
+
const parameter = localValue(spec, raw, budget);
|
|
96
|
+
if (isRecord(parameter) && typeof parameter.name === "string" && typeof parameter.in === "string") {
|
|
97
|
+
let names = positions.get(parameter.in);
|
|
98
|
+
if (!names)
|
|
99
|
+
positions.set(parameter.in, names = new Map());
|
|
100
|
+
let position = names.get(parameter.name);
|
|
101
|
+
if (position === undefined)
|
|
102
|
+
names.set(parameter.name, position = effective.length);
|
|
103
|
+
effective[position] = parameter;
|
|
104
|
+
}
|
|
105
|
+
else if (isRecord(raw)) {
|
|
106
|
+
// Keep unresolved refs and incomplete inline parameters visible to the
|
|
107
|
+
// checks that can still inspect them (or must decline to probe).
|
|
108
|
+
unmerged.push(raw);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return [...effective, ...unmerged];
|
|
113
|
+
}
|
|
114
|
+
export function resolveRequestBody(spec, op, budget) {
|
|
115
|
+
const body = localValue(spec, op.requestBody, budget);
|
|
116
|
+
return isRecord(body) && isRecord(body.content) ? body : undefined;
|
|
117
|
+
}
|
|
118
|
+
function resolveSchema(spec, schema, budget) {
|
|
119
|
+
const value = localValue(spec, schema, budget, "schema");
|
|
120
|
+
if (typeof value === "boolean" && supportsJsonSchema(spec))
|
|
121
|
+
return value;
|
|
122
|
+
if (!isRecord(value) || "$dynamicRef" in value || "$recursiveRef" in value)
|
|
123
|
+
return;
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
export function declaresType(spec, schema, budget) {
|
|
127
|
+
if (typeof schema !== "object")
|
|
128
|
+
return false;
|
|
129
|
+
const type = schema.type;
|
|
130
|
+
if (typeof type === "string" && type.trim() !== "")
|
|
131
|
+
return true;
|
|
132
|
+
if (Array.isArray(type))
|
|
133
|
+
budget?.charge(type.length);
|
|
134
|
+
if (supportsJsonSchema(spec) && Array.isArray(type) && type.length > 0 &&
|
|
135
|
+
type.every(item => typeof item === "string" && item.trim() !== ""))
|
|
136
|
+
return true;
|
|
137
|
+
return schemaForFields(spec, schema, budget) ? false : undefined;
|
|
138
|
+
}
|
|
139
|
+
function mediaSchemas(spec, content, budget) {
|
|
140
|
+
const mediaTypes = Object.values(content ?? {});
|
|
141
|
+
budget?.charge(mediaTypes.length);
|
|
142
|
+
return mediaTypes.filter(media => media?.schema != null).map(media => resolveSchema(spec, media.schema, budget));
|
|
143
|
+
}
|
|
144
|
+
/** An undefined entry means a declared source could not be inspected. */
|
|
145
|
+
export function requestSchemas(spec, path, op, budget) {
|
|
146
|
+
if (spec?.swagger !== "2.0") {
|
|
147
|
+
if (!op.requestBody)
|
|
148
|
+
return [];
|
|
149
|
+
const body = resolveRequestBody(spec, op, budget);
|
|
150
|
+
return body ? mediaSchemas(spec, body.content, budget) : [undefined];
|
|
151
|
+
}
|
|
152
|
+
const parameters = operationParameters(spec, path, op, budget);
|
|
153
|
+
const schemas = parameters.flatMap(p => p.$ref ? [undefined] : p.in === "body" && p.schema ? [resolveSchema(spec, p.schema, budget)] : []);
|
|
154
|
+
const form = parameters.filter(p => p.in === "formData");
|
|
155
|
+
if (form.length) {
|
|
156
|
+
schemas.push({
|
|
157
|
+
type: form.every(p => typeof p.type === "string" && p.type.trim()) ? "object" : undefined,
|
|
158
|
+
properties: Object.fromEntries(form.map(p => [p.name, { type: p.type, description: p.description }])),
|
|
159
|
+
required: form.filter(p => p.required === true).map(p => p.name),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return schemas;
|
|
163
|
+
}
|
|
164
|
+
export function responseSchemas(spec, response, budget) {
|
|
165
|
+
const value = localValue(spec, response, budget);
|
|
166
|
+
if (!isRecord(value))
|
|
167
|
+
return response?.$ref ? [undefined] : [];
|
|
168
|
+
const resolved = value;
|
|
169
|
+
if (spec?.swagger !== "2.0")
|
|
170
|
+
return mediaSchemas(spec, resolved.content, budget);
|
|
171
|
+
return resolved.schema ? [resolveSchema(spec, resolved.schema, budget)] : [];
|
|
172
|
+
}
|
|
173
|
+
export function schemaForFields(spec, schema, budget) {
|
|
174
|
+
const resolved = resolveSchema(spec, schema, budget);
|
|
175
|
+
// Boolean schemas have no named fields. Applicators and embedded resources
|
|
176
|
+
// need deeper evaluation before we can attribute fields or descriptions.
|
|
177
|
+
if (typeof resolved === "boolean")
|
|
178
|
+
return {};
|
|
179
|
+
if (resolved && ["allOf", "anyOf", "oneOf", "if", "then", "else", "not", "dependentSchemas", "$id"].some(key => Object.hasOwn(resolved, key)))
|
|
180
|
+
return;
|
|
181
|
+
return resolved;
|
|
182
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Check } from "../../core/types.js";
|
|
2
2
|
import type { ParsedOpenApiSpec } from "./oas-types.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { type SchemaWorkBudget } from "./schema-sources.js";
|
|
4
|
+
export declare function checkSchemaTypes(spec: ParsedOpenApiSpec | undefined, ops?: [string, string, import("./oas-types.js").OasOperation][], budget?: SchemaWorkBudget): Check;
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import { collectOperations } from "./oas-types.js";
|
|
2
|
-
|
|
2
|
+
import { declaresType, requestSchemas, responseSchemas } from "./schema-sources.js";
|
|
3
|
+
export function checkSchemaTypes(spec, ops = collectOperations(spec), budget) {
|
|
4
|
+
budget?.charge(ops.length);
|
|
3
5
|
const id = "schema_types_defined";
|
|
4
6
|
const label = "Schema Types";
|
|
5
|
-
const ops = collectOperations(spec);
|
|
6
7
|
const schemas = [];
|
|
7
|
-
for (const [, , op] of ops) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (mediaType?.schema)
|
|
11
|
-
schemas.push(mediaType.schema);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
8
|
+
for (const [path, , op] of ops) {
|
|
9
|
+
for (const schema of requestSchemas(spec, path, op, budget))
|
|
10
|
+
schemas.push(schema);
|
|
14
11
|
if (op.responses) {
|
|
15
|
-
|
|
12
|
+
const responses = Object.entries(op.responses);
|
|
13
|
+
budget?.charge(responses.length);
|
|
14
|
+
for (const [code, resp] of responses) {
|
|
16
15
|
if (!code.startsWith("2"))
|
|
17
16
|
continue;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (mediaType?.schema)
|
|
21
|
-
schemas.push(mediaType.schema);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
17
|
+
for (const schema of responseSchemas(spec, resp, budget))
|
|
18
|
+
schemas.push(schema);
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
22
|
const total = schemas.length;
|
|
23
|
+
if (schemas.includes(undefined))
|
|
24
|
+
return { id, label, status: "error", detail: "A request or successful response schema could not be inspected" };
|
|
28
25
|
if (total === 0)
|
|
29
26
|
return { id, label, status: "fail", detail: "No request/response schemas found in spec", data: { total: 0, untyped: 0 } };
|
|
30
|
-
const
|
|
27
|
+
const declared = schemas.map(schema => declaresType(spec, schema, budget));
|
|
28
|
+
if (declared.includes(undefined))
|
|
29
|
+
return { id, label, status: "error", detail: "A schema type could not be inspected due to schema composition" };
|
|
30
|
+
const typed = declared.filter(Boolean).length;
|
|
31
31
|
const untyped = total - typed;
|
|
32
32
|
if (typed === total)
|
|
33
|
-
return { id, label, status: "pass", detail: `All ${total} schemas
|
|
33
|
+
return { id, label, status: "pass", detail: `All ${total} schemas declare a type`, data: { total, untyped: 0 } };
|
|
34
34
|
if (typed >= Math.ceil(total * 0.8))
|
|
35
|
-
return { id, label, status: "partial", detail: `${typed} of ${total} schemas
|
|
36
|
-
return { id, label, status: "fail", detail: `Only ${typed} of ${total} schemas
|
|
35
|
+
return { id, label, status: "partial", detail: `${typed} of ${total} schemas declare a type (${untyped} untyped)`, data: { total, untyped } };
|
|
36
|
+
return { id, label, status: "fail", detail: `Only ${typed} of ${total} schemas declare a type (${untyped} untyped)`, data: { total, untyped } };
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=schema-types.js.map
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import type { Check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Five signal sources:
|
|
6
|
-
* 1. OpenAPI spec detected by Bridge 2 (boolean from ctx.shared.openApiDetected)
|
|
7
|
-
* 2. GraphQL endpoint detected by Bridge 2 (boolean from ctx.shared.graphqlDetected)
|
|
8
|
-
* 3. API-related response headers (X-RateLimit-*, X-Request-Id, etc.)
|
|
9
|
-
* 4. HTML links containing /api/ paths (scanned from all content sources)
|
|
10
|
-
* 5. Markdown links containing /api/ paths (scanned from all content sources)
|
|
11
|
-
*
|
|
12
|
-
* Pure function -- no HTTP calls.
|
|
13
|
-
*/
|
|
14
|
-
export declare function checkApiPresence(openApiDetected: boolean, sources: ContentSource[], headers: Record<string, string>, graphqlDetected?: boolean): Check;
|
|
15
|
-
//# sourceMappingURL=api-presence.d.ts.map
|
|
1
|
+
import type { Check } from "../../core/types.js";
|
|
2
|
+
import { type DiscoverySource } from "./published-routes.js";
|
|
3
|
+
export declare function checkApiPresence(openApiDetected: boolean, sources: DiscoverySource[], headers: Record<string, string>, graphqlDetected?: boolean, baseUrl?: string): Check;
|
|
@@ -1,100 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
import { parseReference } from "../../utils/url.js";
|
|
2
|
+
import { HOME_LINKS_SIZE, isMarkdownSource, markdownLinks, relatedHost, sourceDocument, urlSample } from "./published-routes.js";
|
|
2
3
|
const API_HEADERS = [
|
|
3
|
-
"x-ratelimit-limit",
|
|
4
|
-
"
|
|
5
|
-
"x-ratelimit-reset",
|
|
6
|
-
"x-request-id",
|
|
7
|
-
"x-api-key",
|
|
8
|
-
"x-api-version",
|
|
9
|
-
"ratelimit-limit",
|
|
10
|
-
"ratelimit-remaining",
|
|
11
|
-
"ratelimit-reset",
|
|
4
|
+
"x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-api-key", "x-api-version",
|
|
5
|
+
"ratelimit", "ratelimit-limit", "ratelimit-remaining", "ratelimit-reset",
|
|
12
6
|
];
|
|
13
|
-
|
|
14
|
-
* Scan for <a> tags with hrefs containing API-related paths.
|
|
15
|
-
* Matches /api/ followed by a slash, dot, or word boundary.
|
|
16
|
-
* Does NOT match /developer/ (that belongs to the developer-docs check).
|
|
17
|
-
*/
|
|
18
|
-
function scanApiLinks(html) {
|
|
19
|
-
const links = [];
|
|
20
|
-
const regex = /<a\s[^>]*href=["']([^"']*\/api(?:\/|\.|\b)[^"']*)["']/gi;
|
|
21
|
-
let match;
|
|
22
|
-
while ((match = regex.exec(html)) !== null) {
|
|
23
|
-
const href = match[1];
|
|
24
|
-
if (!links.includes(href))
|
|
25
|
-
links.push(href);
|
|
26
|
-
}
|
|
27
|
-
return links;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Scan for Markdown links containing API-related paths.
|
|
31
|
-
* Matches [text](url) where url contains /api/ followed by a slash, dot, or word boundary.
|
|
32
|
-
*/
|
|
33
|
-
function scanApiLinksMarkdown(text) {
|
|
34
|
-
const links = [];
|
|
35
|
-
const regex = /\[[^\]]*\]\(([^)]*\/api(?:\/|\.|\b)[^)]*)\)/g;
|
|
36
|
-
let match;
|
|
37
|
-
while ((match = regex.exec(text)) !== null) {
|
|
38
|
-
const href = match[1];
|
|
39
|
-
if (!links.includes(href))
|
|
40
|
-
links.push(href);
|
|
41
|
-
}
|
|
42
|
-
return links;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Detect API presence via multiple signals across content sources.
|
|
46
|
-
*
|
|
47
|
-
* Five signal sources:
|
|
48
|
-
* 1. OpenAPI spec detected by Bridge 2 (boolean from ctx.shared.openApiDetected)
|
|
49
|
-
* 2. GraphQL endpoint detected by Bridge 2 (boolean from ctx.shared.graphqlDetected)
|
|
50
|
-
* 3. API-related response headers (X-RateLimit-*, X-Request-Id, etc.)
|
|
51
|
-
* 4. HTML links containing /api/ paths (scanned from all content sources)
|
|
52
|
-
* 5. Markdown links containing /api/ paths (scanned from all content sources)
|
|
53
|
-
*
|
|
54
|
-
* Pure function -- no HTTP calls.
|
|
55
|
-
*/
|
|
56
|
-
export function checkApiPresence(openApiDetected, sources, headers, graphqlDetected = false) {
|
|
7
|
+
export function checkApiPresence(openApiDetected, sources, headers, graphqlDetected = false, baseUrl = "https://source.invalid/") {
|
|
57
8
|
const id = "api_presence";
|
|
58
9
|
const label = "API Presence";
|
|
59
10
|
const signals = [];
|
|
60
|
-
// Signal 1: OpenAPI spec detected by Bridge 2
|
|
61
11
|
if (openApiDetected)
|
|
62
12
|
signals.push("OpenAPI spec");
|
|
63
|
-
// Signal 2: GraphQL endpoint detected by Bridge 2
|
|
64
13
|
if (graphqlDetected)
|
|
65
14
|
signals.push("GraphQL endpoint");
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (apiHeaders.length > 0)
|
|
15
|
+
const apiHeaders = API_HEADERS.filter(name => headers[name]?.trim());
|
|
16
|
+
if (apiHeaders.length)
|
|
69
17
|
signals.push(`API headers (${apiHeaders.join(", ")})`);
|
|
70
|
-
|
|
71
|
-
const apiLinks =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
18
|
+
const site = new URL(baseUrl);
|
|
19
|
+
const apiLinks = new Set();
|
|
20
|
+
// Markdown links are resolved where they stand, and a relative one under a long page URL records that URL's length:
|
|
21
|
+
// 20,000 of them in an llms.txt of 220 KB once held 160 MB. Links past this many characters are not read.
|
|
22
|
+
let room = HOME_LINKS_SIZE;
|
|
23
|
+
function record(url) {
|
|
24
|
+
if (!url || !["http:", "https:"].includes(url.protocol) || !relatedHost(url, site) ||
|
|
25
|
+
!/^\/api(?:\/|\.|$)/i.test(url.pathname) || url.username || url.password)
|
|
26
|
+
return;
|
|
27
|
+
const link = url.origin === site.origin ? url.pathname : url.origin + url.pathname;
|
|
28
|
+
if (!apiLinks.has(link) && (room -= link.length + 64) >= 0)
|
|
29
|
+
apiLinks.add(link);
|
|
30
|
+
}
|
|
31
|
+
for (const source of sources) {
|
|
32
|
+
if (isMarkdownSource(source)) {
|
|
33
|
+
for (const match of markdownLinks(source.content)) {
|
|
34
|
+
if (room < 0)
|
|
35
|
+
break;
|
|
36
|
+
record(parseReference(match[2], source.url ?? baseUrl));
|
|
37
|
+
}
|
|
76
38
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
39
|
+
else {
|
|
40
|
+
for (const url of (source.document ?? sourceDocument({ ...source, url: source.url ?? baseUrl })).links)
|
|
41
|
+
record(url);
|
|
80
42
|
}
|
|
81
43
|
}
|
|
82
|
-
if (apiLinks.
|
|
44
|
+
if (apiLinks.size)
|
|
83
45
|
signals.push("API links found");
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
label,
|
|
88
|
-
status: "fail",
|
|
89
|
-
detail: "No API presence signals detected",
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
id,
|
|
94
|
-
label,
|
|
95
|
-
status: "pass",
|
|
96
|
-
detail: `API presence detected: ${signals.join(", ")}`,
|
|
97
|
-
data: { signals, apiLinks, apiHeaders },
|
|
98
|
-
};
|
|
46
|
+
return signals.length
|
|
47
|
+
? { id, label, status: "pass", detail: "API presence detected: " + signals.join(", "), data: { signals, ...urlSample("apiLinks", apiLinks), apiHeaders } }
|
|
48
|
+
: { id, label, status: "fail", detail: "No API presence signals detected" };
|
|
99
49
|
}
|
|
100
|
-
//# sourceMappingURL=api-presence.js.map
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import type { Check,
|
|
2
|
-
|
|
1
|
+
import type { Check, HttpResponse, HttpSuccess } from "../../core/types.js";
|
|
2
|
+
import { type DiscoverySource, type PublishedSources } from "./published-routes.js";
|
|
3
3
|
export interface DeveloperDocsResult {
|
|
4
4
|
check: Check;
|
|
5
|
-
pages:
|
|
5
|
+
pages: DiscoverySource[];
|
|
6
|
+
routeSources?: PublishedSources;
|
|
6
7
|
}
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* Probes 5 well-known documentation paths with GET requests in parallel
|
|
11
|
-
* (capped at 1 MB body). Also scans homepage HTML for links pointing to
|
|
12
|
-
* documentation paths. Returns pass if any path is reachable or linked,
|
|
13
|
-
* fail otherwise.
|
|
14
|
-
*
|
|
15
|
-
* Returns both the check result and page bodies (ContentSource[]) for
|
|
16
|
-
* downstream content scanning by other Bridge 3 checks.
|
|
17
|
-
*
|
|
18
|
-
* This is the only async check module in Bridge 3 -- it requires HTTP.
|
|
19
|
-
*/
|
|
20
|
-
export declare function checkDeveloperDocs(baseUrl: string, html: string, timeout?: number): Promise<DeveloperDocsResult>;
|
|
21
|
-
//# sourceMappingURL=developer-docs.d.ts.map
|
|
8
|
+
/** Keep the published inventory, observed fetches, and verified documentation independently attributable. */
|
|
9
|
+
export declare function checkDeveloperDocs(baseUrl: string, html: string, timeout?: number, homepage?: string | HttpSuccess | null, rootIndex?: HttpResponse): Promise<DeveloperDocsResult>;
|