@apifuse/provider-sdk 2.2.0-beta.62 → 2.2.0-beta.64
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/AUTHORING.md +367 -9
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/bin/apifuse-check.ts +84 -2
- package/bin/apifuse-dev.ts +11 -31
- package/bin/apifuse-migrate-deployment.ts +200 -0
- package/bin/apifuse-pack-check.ts +11 -4
- package/bin/apifuse-pack-types.ts +187 -4
- package/bin/apifuse-record.ts +44 -32
- package/bin/apifuse-submit-check.ts +9 -5
- package/bin/apifuse-test.ts +3 -1
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +11 -0
- package/dist/cli/deployment-intent.d.ts +178 -0
- package/dist/cli/deployment-intent.js +277 -0
- package/dist/cli/migrate-deployment-intent.d.ts +132 -0
- package/dist/cli/migrate-deployment-intent.js +1552 -0
- package/dist/cli/migrate-provider-shape.d.ts +5 -1
- package/dist/cli/migrate-provider-shape.js +4 -2
- package/dist/cli/resolver-runtime.d.ts +21 -0
- package/dist/cli/resolver-runtime.js +31 -0
- package/dist/define.d.ts +3 -0
- package/dist/define.js +5 -0
- package/dist/dev.d.ts +3 -1
- package/dist/dev.js +6 -1
- package/dist/engine.d.ts +35 -1
- package/dist/engine.js +21 -2
- package/dist/error-resolution.d.ts +1 -0
- package/dist/error-resolution.js +54 -0
- package/dist/errors.d.ts +39 -1
- package/dist/errors.js +50 -0
- package/dist/handle-meta.d.ts +36 -1
- package/dist/handle-meta.js +16 -0
- package/dist/handle.d.ts +23 -5
- package/dist/handle.js +54 -8
- package/dist/health-scenario.d.ts +38 -0
- package/dist/i18n/error-messages.d.ts +86 -0
- package/dist/i18n/error-messages.js +192 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/keys.d.ts +12 -0
- package/dist/i18n/keys.js +76 -5
- package/dist/index.d.ts +11 -3
- package/dist/index.js +9 -1
- package/dist/lint.d.ts +15 -0
- package/dist/lint.js +469 -82
- package/dist/provider.d.ts +6 -6
- package/dist/provider.js +3 -3
- package/dist/runtime/browser-telemetry-binding.d.ts +5 -0
- package/dist/runtime/browser-telemetry-binding.js +83 -0
- package/dist/runtime/browser-telemetry.d.ts +76 -0
- package/dist/runtime/browser-telemetry.js +165 -0
- package/dist/runtime/browser.d.ts +3 -0
- package/dist/runtime/browser.js +208 -47
- package/dist/runtime/cache-telemetry.d.ts +71 -0
- package/dist/runtime/cache-telemetry.js +177 -0
- package/dist/runtime/cache.js +67 -7
- package/dist/runtime/capability-response.d.ts +3 -0
- package/dist/runtime/capability-response.js +56 -0
- package/dist/runtime/capability-telemetry.d.ts +46 -0
- package/dist/runtime/capability-telemetry.js +68 -0
- package/dist/runtime/diagnostic-env.d.ts +3 -0
- package/dist/runtime/diagnostic-env.js +10 -1
- package/dist/runtime/engine-mode.d.ts +74 -0
- package/dist/runtime/engine-mode.js +152 -0
- package/dist/runtime/handle.js +9 -1
- package/dist/runtime/http-telemetry-guard.d.ts +10 -0
- package/dist/runtime/http-telemetry-guard.js +62 -10
- package/dist/runtime/http.js +141 -35
- package/dist/runtime/instrumentation.js +92 -13
- package/dist/runtime/ocr-telemetry.d.ts +82 -0
- package/dist/runtime/ocr-telemetry.js +192 -0
- package/dist/runtime/ocr.js +35 -8
- package/dist/runtime/request-telemetry.d.ts +2 -0
- package/dist/runtime/request-telemetry.js +2 -1
- package/dist/runtime/resolver-runtime-options.d.ts +14 -0
- package/dist/runtime/resolver-runtime-options.js +33 -0
- package/dist/runtime/resolver-shared.d.ts +3 -2
- package/dist/runtime/resolver-shared.js +4 -4
- package/dist/runtime/resolver-telemetry.d.ts +1 -0
- package/dist/runtime/resolver-telemetry.js +1 -1
- package/dist/runtime/resolver-vendors/browser.d.ts +2 -0
- package/dist/runtime/resolver-vendors/browser.js +46 -0
- package/dist/runtime/resolver-vendors/hosts.d.ts +21 -0
- package/dist/runtime/resolver-vendors/hosts.js +35 -0
- package/dist/runtime/resolver-vendors/hypersolutions.js +2 -2
- package/dist/runtime/resolver-vendors/types.d.ts +5 -4
- package/dist/runtime/resolver.d.ts +4 -1
- package/dist/runtime/resolver.js +46 -13
- package/dist/runtime/state-telemetry.d.ts +79 -0
- package/dist/runtime/state-telemetry.js +194 -0
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +26 -7
- package/dist/runtime/stealth-cookies.d.ts +5 -1
- package/dist/runtime/stealth-cookies.js +21 -1
- package/dist/runtime/stealth-owned-headers.d.ts +26 -0
- package/dist/runtime/stealth-owned-headers.js +37 -0
- package/dist/runtime/stealth-telemetry.d.ts +92 -0
- package/dist/runtime/stealth-telemetry.js +179 -0
- package/dist/runtime/stealth.d.ts +4 -1
- package/dist/runtime/stealth.js +228 -85
- package/dist/runtime/stt-telemetry.d.ts +77 -0
- package/dist/runtime/stt-telemetry.js +176 -0
- package/dist/runtime/stt.js +15 -6
- package/dist/runtime-boundary-lint.d.ts +132 -0
- package/dist/runtime-boundary-lint.js +586 -0
- package/dist/server/error-stack-frames.d.ts +35 -0
- package/dist/server/error-stack-frames.js +219 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +4 -0
- package/dist/server/sdk-version.d.ts +3 -0
- package/dist/server/sdk-version.js +19 -0
- package/dist/server/self-test.js +1 -18
- package/dist/server/sensitive-values.d.ts +1 -1
- package/dist/server/sensitive-values.js +9 -0
- package/dist/server/serve-implementation.d.ts +51 -2
- package/dist/server/serve-implementation.js +337 -90
- package/dist/server/types.d.ts +1 -0
- package/dist/server/types.js +7 -0
- package/dist/stateful/stateful-provider-owner-forwarder.js +22 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +3 -0
- package/dist/stateful/stateful-provider-runtime-context.js +1 -0
- package/dist/types.d.ts +123 -1
- package/dist/typescript-module.d.ts +39 -0
- package/dist/typescript-module.js +72 -0
- package/package.json +6 -1
- package/src/cli/commands.ts +14 -0
- package/src/cli/deployment-intent.ts +364 -0
- package/src/cli/migrate-deployment-intent.ts +1908 -0
- package/src/cli/migrate-provider-shape.ts +10 -4
- package/src/cli/resolver-runtime.ts +72 -0
- package/src/define.ts +13 -0
- package/src/dev.ts +9 -2
- package/src/engine.ts +38 -2
- package/src/error-resolution.ts +58 -0
- package/src/errors.ts +77 -1
- package/src/handle-meta.ts +51 -1
- package/src/handle.ts +92 -10
- package/src/health-scenario.ts +38 -0
- package/src/i18n/error-messages.ts +255 -0
- package/src/i18n/index.ts +1 -0
- package/src/i18n/keys.ts +80 -6
- package/src/index.ts +86 -0
- package/src/lint.ts +604 -91
- package/src/provider.ts +12 -0
- package/src/runtime/browser-telemetry-binding.ts +92 -0
- package/src/runtime/browser-telemetry.ts +289 -0
- package/src/runtime/browser.ts +249 -65
- package/src/runtime/cache-telemetry.ts +247 -0
- package/src/runtime/cache.ts +68 -17
- package/src/runtime/capability-response.ts +53 -0
- package/src/runtime/capability-telemetry.ts +101 -0
- package/src/runtime/diagnostic-env.ts +11 -1
- package/src/runtime/engine-mode.ts +233 -0
- package/src/runtime/handle.ts +9 -1
- package/src/runtime/http-telemetry-guard.ts +66 -13
- package/src/runtime/http.ts +168 -37
- package/src/runtime/instrumentation.ts +105 -16
- package/src/runtime/ocr-telemetry.ts +308 -0
- package/src/runtime/ocr.ts +114 -74
- package/src/runtime/request-telemetry.ts +2 -1
- package/src/runtime/resolver-runtime-options.ts +50 -0
- package/src/runtime/resolver-shared.ts +9 -4
- package/src/runtime/resolver-telemetry.ts +1 -1
- package/src/runtime/resolver-vendors/browser.ts +65 -7
- package/src/runtime/resolver-vendors/hosts.ts +43 -0
- package/src/runtime/resolver-vendors/hypersolutions.ts +2 -2
- package/src/runtime/resolver-vendors/types.ts +5 -4
- package/src/runtime/resolver.ts +64 -21
- package/src/runtime/state-telemetry.ts +298 -0
- package/src/runtime/state.ts +46 -45
- package/src/runtime/stealth-cookies.ts +24 -1
- package/src/runtime/stealth-owned-headers.ts +41 -0
- package/src/runtime/stealth-telemetry.ts +304 -0
- package/src/runtime/stealth.ts +355 -150
- package/src/runtime/stt-telemetry.ts +282 -0
- package/src/runtime/stt.ts +93 -71
- package/src/runtime-boundary-lint.ts +703 -0
- package/src/server/error-stack-frames.ts +214 -0
- package/src/server/index.ts +53 -0
- package/src/server/sdk-version.ts +22 -0
- package/src/server/self-test.ts +1 -21
- package/src/server/sensitive-values.ts +14 -0
- package/src/server/serve-implementation.ts +569 -108
- package/src/server/types.ts +7 -0
- package/src/stateful/stateful-provider-owner-forwarder.ts +23 -0
- package/src/stateful/stateful-provider-runtime-context.ts +4 -0
- package/src/types.ts +128 -1
- package/src/typescript-module.ts +100 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/approval-override.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/codemod-syntax.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/connection-precedence.ts.txt +0 -10
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-a.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-b.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-barrel.ts.txt +0 -2
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-ambiguous-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-computed.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-cycle-a.ts.txt +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-cycle-b.ts.txt +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-cycle-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-barrel.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-catalog.ts.txt +0 -19
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-docs.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-daiso-stores.ts.txt +0 -8
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-indirect-config.ts.txt +0 -5
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-nonstatic.ts.txt +0 -4
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-package-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-leaf.ts.txt +0 -10
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-one.ts.txt +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-reexport-two.ts.txt +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-runtime-composed-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-runtime-composed-one.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-runtime-composed-two.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-runtime-mixed-index.ts.txt +0 -14
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-runtime-registry.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-star-package-barrel.ts.txt +0 -2
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-star-package-index.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/discovery-star-package-leaf.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/docs-conflict.ts.txt +0 -8
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-hoisted-array-spread.ts.txt +0 -15
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-imported-array-spread.ts.txt +0 -9
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-kebab-operation-id.ts.txt +0 -17
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +0 -5
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-mixed-array-spread.ts.txt +0 -24
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-operation.ts.txt +0 -16
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-snake-operation-id.ts.txt +0 -21
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-duplicate-provider.ts.txt +0 -11
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-id-unresolved.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-map.ts.txt +0 -3
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-one-to-many.ts.txt +0 -18
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-one-to-one.ts.txt +0 -13
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoist-all.ts.txt +0 -31
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoisted-const.ts.txt +0 -11
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/imported-spread.ts.txt +0 -11
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-map.ts.txt +0 -11
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt +0 -21
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-ekitan.ts.txt +0 -11
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt +0 -14
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/locale-canonical-en.json +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/locale-canonical-ja.json +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/locale-canonical-ko.json +0 -1
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/locale-existing-operation-namespace-en.json +0 -8
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/missing-english-locale.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/no-safety.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/non-literal.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/redundant-approval.ts.txt +0 -6
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-binding-ambiguous.ts.txt +0 -12
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-imported-other.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-imported.ts.txt +0 -5
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-key-ambiguous.ts.txt +0 -19
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-shorthand.ts.txt +0 -9
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-typed.ts.txt +0 -11
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/registry-unrelated.ts.txt +0 -13
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/safety-conflict.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/stream.ts.txt +0 -7
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/tool-router-spread.ts.txt +0 -15
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/unparseable.ts.txt +0 -4
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/verbatim-template.ts.txt +0 -12
package/bin/apifuse-record.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
createHandleContext,
|
|
15
15
|
createProviderEnvironment,
|
|
16
16
|
createSttClientFromEnv,
|
|
17
|
-
createUnsupportedResolverClient,
|
|
18
17
|
executeOperation,
|
|
19
18
|
type HttpClient,
|
|
20
19
|
type HttpResponse,
|
|
@@ -23,13 +22,13 @@ import {
|
|
|
23
22
|
type ProviderDefinition,
|
|
24
23
|
type ProviderEngineBindingCandidates,
|
|
25
24
|
ProviderError,
|
|
26
|
-
readEngineProxyCredentials,
|
|
27
|
-
type ProviderProxyPolicy,
|
|
28
25
|
type RequestOptions,
|
|
29
26
|
type StealthClient,
|
|
30
27
|
TransportError,
|
|
31
28
|
ValidationError,
|
|
32
29
|
} from "../src/index.js";
|
|
30
|
+
import { createCliResolverRuntime } from "../src/cli/resolver-runtime.js";
|
|
31
|
+
import { assertProcessEngineModeSupported } from "../src/runtime/engine-mode.js";
|
|
33
32
|
import type { JsonValue } from "../src/contract-json.js";
|
|
34
33
|
import {
|
|
35
34
|
isSensitiveFixtureKey,
|
|
@@ -37,7 +36,6 @@ import {
|
|
|
37
36
|
sanitizeDiagnosticText,
|
|
38
37
|
sanitizeFixtureString,
|
|
39
38
|
} from "../src/fixture-sanitization.js";
|
|
40
|
-
import { createResolverClientFromEnv } from "../src/runtime/resolver.js";
|
|
41
39
|
import {
|
|
42
40
|
isSensitiveKey,
|
|
43
41
|
normalizeSensitiveParams,
|
|
@@ -50,10 +48,10 @@ import {
|
|
|
50
48
|
requestOptionsFromHttpInvocation,
|
|
51
49
|
serializeRequestUrl,
|
|
52
50
|
} from "../src/runtime/request-options.js";
|
|
51
|
+
import type { ResolverTelemetryCollector } from "../src/runtime/resolver-telemetry.js";
|
|
53
52
|
import { createMemoryProviderRuntimeState } from "../src/runtime/state.js";
|
|
54
53
|
import { createStealthClient } from "../src/runtime/stealth.js";
|
|
55
54
|
import { parseSchema } from "../src/schema.js";
|
|
56
|
-
import { getStealthProfile } from "../src/stealth/profiles.js";
|
|
57
55
|
import {
|
|
58
56
|
captureStreamEvidence,
|
|
59
57
|
createStreamCaptureEnvelope,
|
|
@@ -107,6 +105,8 @@ export async function main() {
|
|
|
107
105
|
const args = parseArgs(normalizeArgs(process.argv.slice(2)));
|
|
108
106
|
const location = resolveProviderLocation(args.providerPath);
|
|
109
107
|
const provider = await loadProvider(location.rootDir);
|
|
108
|
+
// The capture context attaches in-process; refuse an explicit remote request instead of ignoring it.
|
|
109
|
+
assertProcessEngineModeSupported();
|
|
110
110
|
const operationName = resolveOperationName(provider, args.operation);
|
|
111
111
|
const operation = provider.operations[operationName];
|
|
112
112
|
const parsedParams = await parseParams(operation, args.params);
|
|
@@ -140,6 +140,12 @@ export async function main() {
|
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
throw operationError;
|
|
143
|
+
} finally {
|
|
144
|
+
const telemetryLine = formatResolverTelemetry(
|
|
145
|
+
capture.resolverTelemetry,
|
|
146
|
+
capture.getCapturedSensitiveParams().values,
|
|
147
|
+
);
|
|
148
|
+
if (telemetryLine) console.log(telemetryLine);
|
|
143
149
|
}
|
|
144
150
|
const captured = await capture.getCapturedRaw();
|
|
145
151
|
|
|
@@ -256,6 +262,25 @@ function parseArgs(argv: string[]): CliArgs {
|
|
|
256
262
|
return { append, providerPath, operation, params, sanitize };
|
|
257
263
|
}
|
|
258
264
|
|
|
265
|
+
/**
|
|
266
|
+
* The `resolver` sibling of the server request log, printed once per recorded invocation. The
|
|
267
|
+
* collector redacts at record time with the values registered so far; the mandatory query-secret
|
|
268
|
+
* pass over the final line also covers values captured after a solve and short low-entropy values
|
|
269
|
+
* the diagnostic redactor does not match, the same way handleCliError treats CLI errors.
|
|
270
|
+
*/
|
|
271
|
+
export function formatResolverTelemetry(
|
|
272
|
+
collector: ResolverTelemetryCollector,
|
|
273
|
+
sensitiveValues: readonly string[] = [],
|
|
274
|
+
): string | undefined {
|
|
275
|
+
const resolver = collector.toLogPayload();
|
|
276
|
+
return resolver
|
|
277
|
+
? `[apifuse record] Resolver telemetry ${redactSensitiveText(
|
|
278
|
+
JSON.stringify({ resolver }),
|
|
279
|
+
sensitiveValues,
|
|
280
|
+
)}`
|
|
281
|
+
: undefined;
|
|
282
|
+
}
|
|
283
|
+
|
|
259
284
|
function handleCliError(error: unknown, sensitiveValues: readonly string[] = []): never {
|
|
260
285
|
const message = redactSensitiveText(formatCliError(error), sensitiveValues);
|
|
261
286
|
console.error(`[apifuse record] ${message}`);
|
|
@@ -430,13 +455,6 @@ function resolveOperationBaseUrl(provider: ProviderRuntime, operationName: strin
|
|
|
430
455
|
return baseUrl;
|
|
431
456
|
}
|
|
432
457
|
|
|
433
|
-
function resolveNativeProxyPolicy(provider: ProviderDefinition): ProviderProxyPolicy | undefined {
|
|
434
|
-
if (typeof provider.proxy === "object") return provider.proxy;
|
|
435
|
-
if (provider.proxy === true) return { mode: "optional" };
|
|
436
|
-
if (provider.proxy === false) return { mode: "disabled" };
|
|
437
|
-
return undefined;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
458
|
export function createCaptureContext(
|
|
441
459
|
provider: ProviderRuntime,
|
|
442
460
|
baseUrl: string,
|
|
@@ -454,8 +472,19 @@ export function createCaptureContext(
|
|
|
454
472
|
let capturedSse: { order: number; method: string; path: string } | undefined;
|
|
455
473
|
const sensitiveParamNames = new Set<string>();
|
|
456
474
|
const sensitiveParamValues = new Set<string>();
|
|
475
|
+
const cache = createBypassProviderCache({ providerId: provider.id });
|
|
476
|
+
const { resolver, resolverTelemetry, registerSensitiveValues } = createCliResolverRuntime(
|
|
477
|
+
provider,
|
|
478
|
+
cache,
|
|
479
|
+
);
|
|
457
480
|
const captureSensitiveParams = (url: string, options?: SensitiveRequestOptions) => {
|
|
458
|
-
|
|
481
|
+
try {
|
|
482
|
+
captureSensitiveRequestValues(url, options, sensitiveParamNames, sensitiveParamValues);
|
|
483
|
+
} finally {
|
|
484
|
+
// Resolver telemetry redacts at record time, so the vendor diagnostics of a later solve
|
|
485
|
+
// must not echo a query secret captured here (same guarantee as handleCliError).
|
|
486
|
+
registerSensitiveValues([...sensitiveParamValues]);
|
|
487
|
+
}
|
|
459
488
|
};
|
|
460
489
|
const getCapturedSensitiveParams = (): CapturedSensitiveParams => ({
|
|
461
490
|
names: [...sensitiveParamNames],
|
|
@@ -521,7 +550,6 @@ export function createCaptureContext(
|
|
|
521
550
|
provider.secrets?.map((secret) => secret.name) ?? [],
|
|
522
551
|
);
|
|
523
552
|
const env = { get: (key: string) => readDiagnosticEnv(key, providerEnvironment) };
|
|
524
|
-
const engineCredentials = readEngineProxyCredentials();
|
|
525
553
|
const credential = {
|
|
526
554
|
mode: "none" as const,
|
|
527
555
|
get: () => undefined,
|
|
@@ -530,9 +558,6 @@ export function createCaptureContext(
|
|
|
530
558
|
getScopes: () => [],
|
|
531
559
|
};
|
|
532
560
|
const state = createMemoryProviderRuntimeState();
|
|
533
|
-
const cache = createBypassProviderCache({ providerId: provider.id });
|
|
534
|
-
const proxyPolicy = resolveNativeProxyPolicy(provider);
|
|
535
|
-
const stealthProfile = provider.stealth ? getStealthProfile(provider.stealth) : undefined;
|
|
536
561
|
const candidates: ProviderEngineBindingCandidates = {
|
|
537
562
|
env,
|
|
538
563
|
credential,
|
|
@@ -567,21 +592,7 @@ export function createCaptureContext(
|
|
|
567
592
|
},
|
|
568
593
|
ocr: createOcrClientFromEnv(provider.ocr),
|
|
569
594
|
stt: createSttClientFromEnv(provider.stt),
|
|
570
|
-
resolver
|
|
571
|
-
? createResolverClientFromEnv(provider.resolver, engineCredentials, {
|
|
572
|
-
allowedHosts: provider.allowedHosts,
|
|
573
|
-
cache,
|
|
574
|
-
...(proxyPolicy
|
|
575
|
-
? {
|
|
576
|
-
proxyIntent: {
|
|
577
|
-
mode: proxyPolicy.mode,
|
|
578
|
-
upstream: { proxy: provider.proxy },
|
|
579
|
-
...(stealthProfile ? { userAgent: stealthProfile.userAgent } : {}),
|
|
580
|
-
},
|
|
581
|
-
}
|
|
582
|
-
: {}),
|
|
583
|
-
})
|
|
584
|
-
: createUnsupportedResolverClient("Provider does not declare resolver capability"),
|
|
595
|
+
resolver,
|
|
585
596
|
handle: createHandleContext({
|
|
586
597
|
providerId: provider.id,
|
|
587
598
|
request: { headers: {}, connectionId: "local-record" },
|
|
@@ -595,6 +606,7 @@ export function createCaptureContext(
|
|
|
595
606
|
|
|
596
607
|
return {
|
|
597
608
|
ctx,
|
|
609
|
+
resolverTelemetry,
|
|
598
610
|
getCapturedRaw: async () => {
|
|
599
611
|
if (streamCaptures.length === 0) {
|
|
600
612
|
if (capturedSse) throw unsupportedSseCaptureError(capturedSse);
|
|
@@ -25,18 +25,22 @@ import {
|
|
|
25
25
|
hasStreamEvidenceMarker,
|
|
26
26
|
parseStreamEvidenceRecord,
|
|
27
27
|
} from "../src/stream-evidence.js";
|
|
28
|
+
import { getTypeScript } from "../src/typescript-module.js";
|
|
28
29
|
import { type CheckResult, PROMPT_ASSETS_CHECK_MESSAGE, runChecks } from "./apifuse-check.js";
|
|
29
30
|
import { hasSubstantiveDelimitedTextStructure } from "./submit-check-delimited-text.js";
|
|
30
31
|
import { hasSubstantiveXmlStructure } from "./submit-check-xml.js";
|
|
31
32
|
|
|
32
|
-
const ts: typeof import("typescript") =
|
|
33
|
+
const ts: typeof import("typescript") = loadTypeScript();
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// Shares the lint rules' loader so a workspace whose `typescript` is the 7.x
|
|
36
|
+
// native shell (no compiler API) falls back to `@typescript/typescript6`
|
|
37
|
+
// instead of failing inside the first parse.
|
|
38
|
+
function loadTypeScript(): typeof import("typescript") {
|
|
35
39
|
try {
|
|
36
|
-
return
|
|
37
|
-
} catch {
|
|
40
|
+
return getTypeScript();
|
|
41
|
+
} catch (error) {
|
|
38
42
|
console.error(
|
|
39
|
-
|
|
43
|
+
`apifuse submit-check requires the TypeScript compiler API; install it in the workspace running the CLI (bun add -d typescript). ${error instanceof Error ? error.message : String(error)}`,
|
|
40
44
|
);
|
|
41
45
|
process.exit(1);
|
|
42
46
|
}
|
package/bin/apifuse-test.ts
CHANGED
package/dist/cli/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ApifuseCommandName = "create" | "dev" | "check" | "sync-assets" | "migrate-shape" | "migrate-operation-declaration" | "submit-check" | "bounty-check" | "record" | "test" | "perf";
|
|
1
|
+
export type ApifuseCommandName = "create" | "dev" | "check" | "sync-assets" | "migrate-shape" | "migrate-operation-declaration" | "migrate-deployment" | "submit-check" | "bounty-check" | "record" | "test" | "perf";
|
|
2
2
|
export type ApifuseCommandManifest = {
|
|
3
3
|
name: ApifuseCommandName;
|
|
4
4
|
summary: string;
|
package/dist/cli/commands.js
CHANGED
|
@@ -47,6 +47,16 @@ export const COMMAND_MANIFEST = {
|
|
|
47
47
|
],
|
|
48
48
|
modulePath: "./apifuse-migrate-operation-declaration",
|
|
49
49
|
},
|
|
50
|
+
"migrate-deployment": {
|
|
51
|
+
name: "migrate-deployment",
|
|
52
|
+
summary: "Retire a legacy deploy.ts: hoist its non-default values into the defineProvider() deployment key and delete the file.",
|
|
53
|
+
usage: "apifuse migrate-deployment [path] [--check] [--json] [--drop-codeowners-lock]",
|
|
54
|
+
examples: [
|
|
55
|
+
"apifuse migrate-deployment .",
|
|
56
|
+
"apifuse migrate-deployment . --check --json",
|
|
57
|
+
],
|
|
58
|
+
modulePath: "./apifuse-migrate-deployment",
|
|
59
|
+
},
|
|
50
60
|
"submit-check": {
|
|
51
61
|
name: "submit-check",
|
|
52
62
|
summary: "Score provider bounty submission readiness and emit checklist evidence.",
|
|
@@ -100,6 +110,7 @@ export const COMMAND_ORDER = [
|
|
|
100
110
|
"sync-assets",
|
|
101
111
|
"migrate-shape",
|
|
102
112
|
"migrate-operation-declaration",
|
|
113
|
+
"migrate-deployment",
|
|
103
114
|
"submit-check",
|
|
104
115
|
"record",
|
|
105
116
|
"test",
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ProviderDeploymentOverrides } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Deployment-intent helpers shared by `apifuse check` and
|
|
5
|
+
* `apifuse migrate-deployment`.
|
|
6
|
+
*
|
|
7
|
+
* Deployment intent has exactly one authored home: the optional `deployment`
|
|
8
|
+
* key on `defineProvider()`. The APIFuse registry builder is the only reader;
|
|
9
|
+
* it resolves omitted fields from a runtime profile and rejects anything it
|
|
10
|
+
* cannot resolve. This module mirrors that profile table so the CLI can
|
|
11
|
+
* (a) subtract profile defaults when hoisting a legacy `deploy.ts` into the
|
|
12
|
+
* key and (b) warn when a declared key restates a default. The registry
|
|
13
|
+
* stays canonical — keep the constants below identical to
|
|
14
|
+
* `resolveProviderDeploymentConfig` in `@apifuse/provider-registry`.
|
|
15
|
+
*/
|
|
16
|
+
export type DeploymentRuntime = "shared" | "dedicated" | "browser";
|
|
17
|
+
export type DeploymentLanguage = "typescript" | "python";
|
|
18
|
+
export interface DeploymentResources {
|
|
19
|
+
cpu: string;
|
|
20
|
+
memory: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DeploymentHpa {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
minReplicas?: number;
|
|
25
|
+
maxReplicas?: number;
|
|
26
|
+
targetCPUUtilizationPercentage?: number;
|
|
27
|
+
}
|
|
28
|
+
/** Fully resolved deployment view: what the platform materializes for a provider. */
|
|
29
|
+
export interface ResolvedDeploymentIntent {
|
|
30
|
+
runtime: DeploymentRuntime;
|
|
31
|
+
language: DeploymentLanguage;
|
|
32
|
+
replicas: number;
|
|
33
|
+
hpa: DeploymentHpa;
|
|
34
|
+
resources: DeploymentResources;
|
|
35
|
+
cache?: {
|
|
36
|
+
redis?: {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
url?: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
network?: {
|
|
42
|
+
additionalTcpPorts: number[];
|
|
43
|
+
};
|
|
44
|
+
buildContext: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Runtime-profile defaults. `dedicated` carries no resource profile and
|
|
48
|
+
* therefore always needs explicit `resources`.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DEPLOYMENT_PROFILE_DEFAULTS: Readonly<{
|
|
51
|
+
runtime: DeploymentRuntime;
|
|
52
|
+
language: DeploymentLanguage;
|
|
53
|
+
replicas: 1;
|
|
54
|
+
hpa: Readonly<DeploymentHpa>;
|
|
55
|
+
buildContext: ".";
|
|
56
|
+
resources: Readonly<Record<DeploymentRuntime, Readonly<DeploymentResources> | undefined>>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* The standalone `deploy.ts` contract (legacy). Mirrors the registry's
|
|
60
|
+
* `ProviderDeploymentConfigSchema`, including its own defaults — note that a
|
|
61
|
+
* legacy file without `hpa` resolved to `{ enabled: false }`, not the
|
|
62
|
+
* profile HPA, so the two default tables are deliberately different.
|
|
63
|
+
*/
|
|
64
|
+
export declare const legacyDeploymentConfigSchema: z.ZodObject<{
|
|
65
|
+
runtime: z.ZodEnum<{
|
|
66
|
+
browser: "browser";
|
|
67
|
+
shared: "shared";
|
|
68
|
+
dedicated: "dedicated";
|
|
69
|
+
}>;
|
|
70
|
+
language: z.ZodEnum<{
|
|
71
|
+
typescript: "typescript";
|
|
72
|
+
python: "python";
|
|
73
|
+
}>;
|
|
74
|
+
replicas: z.ZodDefault<z.ZodNumber>;
|
|
75
|
+
hpa: z.ZodDefault<z.ZodObject<{
|
|
76
|
+
enabled: z.ZodBoolean;
|
|
77
|
+
minReplicas: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
maxReplicas: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
targetCPUUtilizationPercentage: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
}, z.core.$strict>>;
|
|
81
|
+
resources: z.ZodObject<{
|
|
82
|
+
cpu: z.ZodString;
|
|
83
|
+
memory: z.ZodString;
|
|
84
|
+
}, z.core.$strict>;
|
|
85
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
86
|
+
redis: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
enabled: z.ZodBoolean;
|
|
88
|
+
url: z.ZodOptional<z.ZodString>;
|
|
89
|
+
}, z.core.$strict>>;
|
|
90
|
+
}, z.core.$strict>>;
|
|
91
|
+
network: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
additionalTcpPorts: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
|
|
93
|
+
}, z.core.$strict>>;
|
|
94
|
+
buildContext: z.ZodOptional<z.ZodString & z.ZodType<".", string, z.core.$ZodTypeInternals<".", string>>>;
|
|
95
|
+
}, z.core.$strict>;
|
|
96
|
+
/** The authored `deployment` key: every field optional (registry `ProviderDeploymentOverridesSchema`). */
|
|
97
|
+
export declare const deploymentOverridesSchema: z.ZodObject<{
|
|
98
|
+
runtime: z.ZodOptional<z.ZodEnum<{
|
|
99
|
+
browser: "browser";
|
|
100
|
+
shared: "shared";
|
|
101
|
+
dedicated: "dedicated";
|
|
102
|
+
}>>;
|
|
103
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
104
|
+
typescript: "typescript";
|
|
105
|
+
python: "python";
|
|
106
|
+
}>>;
|
|
107
|
+
replicas: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
hpa: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
enabled: z.ZodBoolean;
|
|
110
|
+
minReplicas: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
maxReplicas: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
targetCPUUtilizationPercentage: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
}, z.core.$strict>>;
|
|
114
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
cpu: z.ZodString;
|
|
116
|
+
memory: z.ZodString;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
redis: z.ZodOptional<z.ZodObject<{
|
|
120
|
+
enabled: z.ZodBoolean;
|
|
121
|
+
url: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strict>>;
|
|
123
|
+
}, z.core.$strict>>;
|
|
124
|
+
network: z.ZodOptional<z.ZodObject<{
|
|
125
|
+
additionalTcpPorts: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
|
|
126
|
+
}, z.core.$strict>>;
|
|
127
|
+
buildContext: z.ZodOptional<z.ZodString & z.ZodType<".", string, z.core.$ZodTypeInternals<".", string>>>;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
export type DeploymentParse<T> = {
|
|
130
|
+
readonly ok: true;
|
|
131
|
+
readonly value: T;
|
|
132
|
+
} | {
|
|
133
|
+
readonly ok: false;
|
|
134
|
+
readonly reason: string;
|
|
135
|
+
};
|
|
136
|
+
/** Parse a legacy `deploy.ts` default export into the resolved view. */
|
|
137
|
+
export declare function normalizeLegacyDeployment(value: unknown): DeploymentParse<ResolvedDeploymentIntent>;
|
|
138
|
+
/** Parse an authored `deployment` key against the strict overrides contract. */
|
|
139
|
+
export declare function parseDeploymentIntent(value: unknown): DeploymentParse<ProviderDeploymentOverrides>;
|
|
140
|
+
/**
|
|
141
|
+
* Resolve an authored key against the runtime profiles, per field;
|
|
142
|
+
* `resources` and `hpa` resolve as whole objects (never deep-merged).
|
|
143
|
+
* Throws when the intent cannot resolve (dedicated runtime without
|
|
144
|
+
* resources, non-default buildContext) — the registry rejects the same.
|
|
145
|
+
*/
|
|
146
|
+
export declare function resolveDeploymentIntent(intent?: ProviderDeploymentOverrides): ResolvedDeploymentIntent;
|
|
147
|
+
/**
|
|
148
|
+
* Two resolved views describe the same deployment when they are deep-equal
|
|
149
|
+
* after dropping empty shells (`network: { additionalTcpPorts: [] }`,
|
|
150
|
+
* `cache: {}`) that carry no intent — the manifests they render are
|
|
151
|
+
* byte-identical.
|
|
152
|
+
*/
|
|
153
|
+
export declare function deploymentIntentsEquivalent(left: ResolvedDeploymentIntent, right: ResolvedDeploymentIntent): boolean;
|
|
154
|
+
export declare function canonicalResolvedDeployment(resolved: ResolvedDeploymentIntent): ResolvedDeploymentIntent;
|
|
155
|
+
/**
|
|
156
|
+
* The smallest `deployment` key that resolves to `resolved`: profile
|
|
157
|
+
* defaults are omitted, `hpa`/`resources` are kept whole when they differ
|
|
158
|
+
* (the resolver never deep-merges them), and empty shells are dropped.
|
|
159
|
+
* Callers prove the result with
|
|
160
|
+
* `deploymentIntentsEquivalent(resolveDeploymentIntent(key), resolved)`.
|
|
161
|
+
*/
|
|
162
|
+
export declare function subtractDeploymentDefaults(resolved: ResolvedDeploymentIntent): ProviderDeploymentOverrides;
|
|
163
|
+
/** Authored order for emitted keys: the registry contract's field order. */
|
|
164
|
+
export declare const DEPLOYMENT_INTENT_FIELD_ORDER: readonly (keyof ProviderDeploymentOverrides)[];
|
|
165
|
+
export interface RedundantDeploymentField {
|
|
166
|
+
/** Dotted path under `deployment`, e.g. `hpa` or `network.additionalTcpPorts`. */
|
|
167
|
+
readonly path: string;
|
|
168
|
+
readonly message: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Fields of an authored `deployment` key that restate what the runtime
|
|
172
|
+
* profile already resolves (ADR-0009 "derived values are not re-stated").
|
|
173
|
+
* Accepts an unvalidated value because `apifuse check` inspects the loaded
|
|
174
|
+
* definition, whose key the SDK passes through verbatim.
|
|
175
|
+
*/
|
|
176
|
+
export declare function redundantDeploymentDefaults(intent: unknown): RedundantDeploymentField[];
|
|
177
|
+
/** Structural equality for JSON-shaped values, key order insensitive. */
|
|
178
|
+
export declare function deepEqual(left: unknown, right: unknown): boolean;
|