@apifuse/provider-sdk 2.2.0-beta.37 → 2.2.0-beta.38

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @apifuse/provider-sdk Changelog
2
2
 
3
+ ## 2.2.0-beta.38
4
+
5
+ - Release candidate for main commit 448775077dbc9ab907209f1feee4e6e4e5ef4283.
6
+
3
7
  ## 2.2.0-beta.37
4
8
 
5
9
  - Release candidate for main commit aa14b268dffe1196f25c2b6b314598fe0896edec.
@@ -4,6 +4,8 @@ export declare const DECLARATION_INVALID_CODE = "DECLARATION_INVALID";
4
4
  export declare const DECLARATION_RULE_IDS: {
5
5
  readonly challengeShape: "credentials-challenge-shape";
6
6
  readonly journeyExecutable: "health-journey-executable";
7
+ readonly journeyRunScenarioExclusive: "health-journey-run-scenario-exclusive";
8
+ readonly journeyScenarioValid: "health-journey-scenario-valid";
7
9
  readonly schemaSerializable: "operation-schema-serializable";
8
10
  readonly proxyExplicitPolicy: "proxy-explicit-policy";
9
11
  readonly proxyVendorExclusive: "proxy-vendor-fields-exclusive";
@@ -1,9 +1,12 @@
1
1
  import { describeSchema } from "./contract-serialization.js";
2
2
  import { ProviderError } from "./errors.js";
3
+ import { HealthScenarioSchema } from "./health-scenario.js";
3
4
  export const DECLARATION_INVALID_CODE = "DECLARATION_INVALID";
4
5
  export const DECLARATION_RULE_IDS = {
5
6
  challengeShape: "credentials-challenge-shape",
6
7
  journeyExecutable: "health-journey-executable",
8
+ journeyRunScenarioExclusive: "health-journey-run-scenario-exclusive",
9
+ journeyScenarioValid: "health-journey-scenario-valid",
7
10
  schemaSerializable: "operation-schema-serializable",
8
11
  proxyExplicitPolicy: "proxy-explicit-policy",
9
12
  proxyVendorExclusive: "proxy-vendor-fields-exclusive",
@@ -35,15 +38,38 @@ function validateHealthDeclaration(provider, violations) {
35
38
  for (const [index, journey] of (provider.healthJourneys ?? []).entries()) {
36
39
  if (!journey || typeof journey !== "object")
37
40
  continue;
38
- if (typeof journey.run !== "function") {
41
+ const hasRun = journey.run !== undefined;
42
+ const hasScenario = journey.scenario !== undefined;
43
+ if (hasRun && hasScenario) {
44
+ const journeyPath = healthJourneyPath(journey, index);
45
+ violations.push({
46
+ ruleId: DECLARATION_RULE_IDS.journeyRunScenarioExclusive,
47
+ path: journeyPath,
48
+ message: "A health journey must declare exactly one of run or scenario, not both.",
49
+ fix: `Remove either ${journeyPath}.run or ${journeyPath}.scenario.`,
50
+ });
51
+ }
52
+ if (!hasRun && !hasScenario) {
39
53
  const journeyPath = healthJourneyPath(journey, index);
40
54
  violations.push({
41
55
  ruleId: DECLARATION_RULE_IDS.journeyExecutable,
42
56
  path: `${journeyPath}.run`,
43
- message: "coversOperations cannot provide health coverage without executable run logic.",
44
- fix: `Add an async run(ctx) implementation to ${journeyPath}.`,
57
+ message: "coversOperations cannot provide health coverage without run or a declarative scenario.",
58
+ fix: `Add an async run(ctx) implementation or a valid scenario to ${journeyPath}.`,
45
59
  });
46
60
  }
61
+ if (hasScenario) {
62
+ const parsed = HealthScenarioSchema.safeParse(journey.scenario);
63
+ if (!parsed.success) {
64
+ const journeyPath = healthJourneyPath(journey, index);
65
+ violations.push({
66
+ ruleId: DECLARATION_RULE_IDS.journeyScenarioValid,
67
+ path: `${journeyPath}.scenario`,
68
+ message: "scenario must conform to HealthScenario.",
69
+ fix: "Build the scenario with defineHealthScenario().",
70
+ });
71
+ }
72
+ }
47
73
  }
48
74
  // NOTE: healthCheck.cases[].enabled is intentionally NOT validated here.
49
75
  // self-test.ts reports a gated case as status "skipped" with skipReason
package/dist/define.js CHANGED
@@ -1413,6 +1413,7 @@ const HEALTH_JOURNEY_FIELDS = new Set([
1413
1413
  "manualTrigger",
1414
1414
  "steps",
1415
1415
  "run",
1416
+ "scenario",
1416
1417
  ]);
1417
1418
  const HEALTH_JOURNEY_SCHEDULE_FIELDS = new Set(["kind", "interval", "jitter", "randomize"]);
1418
1419
  const HEALTH_JOURNEY_STEP_FIELDS = new Set([
@@ -1835,6 +1836,10 @@ function validateHealthJourneys(providerId, operations, healthJourneys) {
1835
1836
  }
1836
1837
  if (journey.manualTrigger !== undefined)
1837
1838
  validateHealthJourneyManualTrigger(providerId, journey.id, journey.manualTrigger);
1839
+ if (journey.scenario !== undefined && journey.smsMatchers !== undefined)
1840
+ throw new ValidationError(`Provider "${providerId}" healthJourneys.${journey.id}.smsMatchers is not allowed on declarative scenarios.`);
1841
+ if (journey.scenario !== undefined && journey.requiredSecrets !== undefined)
1842
+ throw new ValidationError(`Provider "${providerId}" healthJourneys.${journey.id}.requiredSecrets is not allowed on declarative scenarios.`);
1838
1843
  if (journey.timeout !== undefined)
1839
1844
  assertIsoDuration(journey.timeout, `Provider "${providerId}" healthJourneys.${journey.id}.timeout`);
1840
1845
  if (journey.cooldown !== undefined)