@apifuse/provider-sdk 2.2.0-beta.40 → 2.2.0-beta.41
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/CHANGELOG.md +4 -0
- package/bin/apifuse-check.ts +61 -0
- package/bin/apifuse-migrate-shape.ts +84 -0
- package/bin/apifuse-submit-check.ts +1760 -222
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +8 -0
- package/dist/cli/create.js +6 -0
- package/dist/cli/migrate-provider-shape.d.ts +52 -0
- package/dist/cli/migrate-provider-shape.js +515 -0
- package/dist/cli/templates/provider/provider.json.tpl +6 -0
- package/dist/contract.js +1 -0
- package/dist/define.js +22 -1
- package/dist/error-observability.d.ts +7 -0
- package/dist/error-observability.js +61 -0
- package/dist/errors.d.ts +15 -0
- package/dist/fixture-sanitization.js +13 -3
- package/dist/index.d.ts +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/runtime/executor.js +11 -1
- package/dist/server/error-observability.d.ts +1 -0
- package/dist/server/error-observability.js +1 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/self-test.js +3 -0
- package/dist/server/serve-implementation.d.ts +12 -0
- package/dist/server/serve-implementation.js +135 -66
- package/dist/types.d.ts +18 -10
- package/package.json +3 -3
- package/src/cli/commands.ts +10 -0
- package/src/cli/create.ts +6 -0
- package/src/cli/migrate-provider-shape.ts +701 -0
- package/src/cli/templates/provider/provider.json.tpl +6 -0
- package/src/contract.ts +1 -0
- package/src/define.ts +33 -1
- package/src/error-observability.ts +64 -0
- package/src/errors.ts +16 -0
- package/src/fixture-sanitization.ts +19 -3
- package/src/index.ts +1 -0
- package/src/provider.ts +1 -0
- package/src/runtime/executor.ts +13 -1
- package/src/server/error-observability.ts +1 -0
- package/src/server/index.ts +2 -0
- package/src/server/self-test.ts +5 -0
- package/src/server/serve-implementation.ts +172 -84
- package/src/types.ts +38 -27
package/src/types.ts
CHANGED
|
@@ -760,38 +760,13 @@ export interface HealthCheckCaseResult {
|
|
|
760
760
|
* so authors get IntelliSense and compile-time errors when accessing fields
|
|
761
761
|
* that do not exist on the operation's declared output schema.
|
|
762
762
|
*/
|
|
763
|
-
export
|
|
763
|
+
export type HealthCheckCase<TInput = unknown, TOutput = unknown> = {
|
|
764
764
|
/** Human-readable case name; unique within the suite. */
|
|
765
765
|
name: string;
|
|
766
766
|
/** Optional longer description shown on ops dashboards. */
|
|
767
767
|
description?: string;
|
|
768
768
|
/** Input passed to the operation handler for this case. */
|
|
769
769
|
input: TInput;
|
|
770
|
-
/**
|
|
771
|
-
* Optional runtime input preparation hook for volatile probes. Use this when
|
|
772
|
-
* the durable probe input must be derived from a live read-only operation
|
|
773
|
-
* immediately before the checked operation executes.
|
|
774
|
-
*/
|
|
775
|
-
prepareInput?: (
|
|
776
|
-
ctx: HealthCheckInputPreparationContext<TInput>,
|
|
777
|
-
) => TInput | Promise<TInput>;
|
|
778
|
-
/**
|
|
779
|
-
* Assertion executed against the operation's response and timing.
|
|
780
|
-
*
|
|
781
|
-
* - Throw to fail the case (recorded as `down`).
|
|
782
|
-
* - Return `{ status: "degraded", label }` to flag without failing.
|
|
783
|
-
* - Return `void` (implicit) for `ok`.
|
|
784
|
-
*
|
|
785
|
-
* MUST NOT access scheduler, recorder, or any runtime type — pure data
|
|
786
|
-
* + lambda only.
|
|
787
|
-
*/
|
|
788
|
-
assertions: (
|
|
789
|
-
ctx: HealthCheckAssertionContext<TOutput>,
|
|
790
|
-
) =>
|
|
791
|
-
| void
|
|
792
|
-
| Promise<void>
|
|
793
|
-
| HealthCheckCaseResult
|
|
794
|
-
| Promise<HealthCheckCaseResult>;
|
|
795
770
|
/** Override per-case degradation threshold (ms); falls back to the suite default. */
|
|
796
771
|
degradedThresholdMs?: number;
|
|
797
772
|
/** Override per-case timeout in milliseconds; falls back to the suite/provider/runtime default. */
|
|
@@ -800,7 +775,43 @@ export interface HealthCheckCase<TInput = unknown, TOutput = unknown> {
|
|
|
800
775
|
expectedStatus?: "ok" | "degraded";
|
|
801
776
|
/** Runtime gate (env-driven); if returns false the case is skipped & logged. */
|
|
802
777
|
enabled?: () => boolean;
|
|
803
|
-
}
|
|
778
|
+
} & (
|
|
779
|
+
| {
|
|
780
|
+
/**
|
|
781
|
+
* Optional runtime input preparation hook for volatile probes. Use this when
|
|
782
|
+
* the durable probe input must be derived from a live read-only operation
|
|
783
|
+
* immediately before the checked operation executes.
|
|
784
|
+
*/
|
|
785
|
+
prepareInput?: (
|
|
786
|
+
ctx: HealthCheckInputPreparationContext<TInput>,
|
|
787
|
+
) => TInput | Promise<TInput>;
|
|
788
|
+
/**
|
|
789
|
+
* Assertion executed against the operation's response and timing.
|
|
790
|
+
*
|
|
791
|
+
* - Throw to fail the case (recorded as `down`).
|
|
792
|
+
* - Return `{ status: "degraded", label }` to flag without failing.
|
|
793
|
+
* - Return `void` (implicit) for `ok`.
|
|
794
|
+
*
|
|
795
|
+
* MUST NOT access scheduler, recorder, or any runtime type — pure data
|
|
796
|
+
* + lambda only.
|
|
797
|
+
*/
|
|
798
|
+
assertions: (
|
|
799
|
+
ctx: HealthCheckAssertionContext<TOutput>,
|
|
800
|
+
) =>
|
|
801
|
+
| void
|
|
802
|
+
| Promise<void>
|
|
803
|
+
| HealthCheckCaseResult
|
|
804
|
+
| Promise<HealthCheckCaseResult>;
|
|
805
|
+
/** Declarative scenarios replace the imperative preparation and assertion hooks. */
|
|
806
|
+
scenario?: never;
|
|
807
|
+
}
|
|
808
|
+
| {
|
|
809
|
+
/** Declarative scenario executed by the health-monitor runtime. */
|
|
810
|
+
scenario: HealthScenario;
|
|
811
|
+
prepareInput?: never;
|
|
812
|
+
assertions?: never;
|
|
813
|
+
}
|
|
814
|
+
);
|
|
804
815
|
|
|
805
816
|
/**
|
|
806
817
|
* Operation-level health-check suite. At least one case is required when
|