@apifuse/provider-sdk 2.2.0-beta.65 → 2.2.0-beta.66

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.66
4
+
5
+ - Release candidate for main commit e7f93a6c71e3bca3a680861c0968e22dbe5d1d40.
6
+
3
7
  ## 2.2.0-beta.65
4
8
 
5
9
  - Release candidate for main commit 4731ac76145caf85a6c340ad0c446371bd24b052.
@@ -588,12 +588,56 @@ function checkPackageJson(packageJsonPath: string): CheckResult {
588
588
 
589
589
  export const PROVIDER_JSON_CHECK_MESSAGE = "provider.json exists with a valid declaration";
590
590
 
591
+ /**
592
+ * Markets a provider may declare as its primary, and the locales the platform
593
+ * catalogs can carry.
594
+ *
595
+ * These mirror `scripts/provider-deploy/provider-locale-coverage.mjs` in the
596
+ * APIFuse monorepo, which is the policy's source of truth. The duplication is
597
+ * deliberate and bounded: the monorepo cannot be imported from a provider
598
+ * checkout, and a *closed* mirror is the point — it keeps a typo
599
+ * (`primaryMarket: "jp-JP"`) a local failure instead of one that only surfaces
600
+ * in the monorepo's contract validator days later.
601
+ */
602
+ const PROVIDER_PRIMARY_MARKETS = ["jp", "kr", "global"] as const;
603
+ const PROVIDER_COVERAGE_LOCALES = ["en", "ko", "ja"] as const;
604
+ const PROVIDER_BASELINE_LOCALE = "en";
605
+
606
+ /**
607
+ * Declared locale coverage, optional at schemaVersion 1.
608
+ *
609
+ * `apifuse provider declare-locale-coverage` writes this block, and the
610
+ * monorepo declaration schema has accepted it since the rollout landed. This
611
+ * check used to close `provider.json` over four keys, which made the only
612
+ * documented way to clear the monorepo's `LOCALE_COVERAGE_UNDECLARED` finding
613
+ * turn a green `bun run check` red — the declaration was unfixable from either
614
+ * side. The fix is to mirror the monorepo schema rather than to stop
615
+ * validating: the block stays closed over its own two keys so a misspelled
616
+ * field is still caught here, at authoring time.
617
+ */
618
+ const providerI18nDeclarationSchema = z
619
+ .object({
620
+ primaryMarket: z.enum(PROVIDER_PRIMARY_MARKETS),
621
+ locales: z
622
+ .array(z.enum(PROVIDER_COVERAGE_LOCALES))
623
+ .nonempty()
624
+ .refine((locales) => new Set(locales).size === locales.length, {
625
+ message: "i18n.locales must not repeat a locale",
626
+ })
627
+ .refine((locales) => locales.includes(PROVIDER_BASELINE_LOCALE), {
628
+ message: `i18n.locales must include "${PROVIDER_BASELINE_LOCALE}": it is the fallback every other locale resolves through`,
629
+ })
630
+ .optional(),
631
+ })
632
+ .strict();
633
+
591
634
  const providerDeclarationSchema = z
592
635
  .object({
593
636
  schemaVersion: z.literal(1),
594
637
  providerId: z.string(),
595
638
  owner: z.string(),
596
639
  lifecycle: z.enum(["draft", "ready", "live", "retired"]),
640
+ i18n: providerI18nDeclarationSchema.optional(),
597
641
  })
598
642
  .strict();
599
643
 
@@ -624,7 +668,17 @@ function checkProviderJson(providerJsonPath: string, packageJsonPath: string): C
624
668
  return {
625
669
  message: PROVIDER_JSON_CHECK_MESSAGE,
626
670
  passed: true,
627
- details: [`providerId: ${declaration.providerId}`, `lifecycle: ${declaration.lifecycle}`],
671
+ details: [
672
+ `providerId: ${declaration.providerId}`,
673
+ `lifecycle: ${declaration.lifecycle}`,
674
+ ...(declaration.i18n
675
+ ? [
676
+ `locale coverage: primaryMarket ${declaration.i18n.primaryMarket}${
677
+ declaration.i18n.locales ? ` (locales: ${declaration.i18n.locales.join(", ")})` : ""
678
+ }`,
679
+ ]
680
+ : []),
681
+ ],
628
682
  };
629
683
  } catch (error) {
630
684
  return {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0-beta.65",
2
+ "version": "2.2.0-beta.66",
3
3
  "name": "@apifuse/provider-sdk",
4
4
  "private": false,
5
5
  "type": "module",