@bluestep-systems/b6p-core 0.9.0 → 1.0.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.
Files changed (136) hide show
  1. package/README.md +264 -25
  2. package/dist/B6PCore.d.ts +7 -0
  3. package/dist/B6PCore.js +54 -1
  4. package/dist/B6PCore.js.map +1 -1
  5. package/dist/B6PUri.d.ts +6 -8
  6. package/dist/B6PUri.js +6 -8
  7. package/dist/B6PUri.js.map +1 -1
  8. package/dist/Err.d.ts +415 -0
  9. package/dist/Err.js +552 -0
  10. package/dist/Err.js.map +1 -1
  11. package/dist/auth/BearerAuthProvider.d.ts +32 -0
  12. package/dist/auth/BearerAuthProvider.js +49 -0
  13. package/dist/auth/BearerAuthProvider.js.map +1 -1
  14. package/dist/cache/OrgCache.js.map +1 -1
  15. package/dist/cache/ScriptMetaDataStore.js.map +1 -1
  16. package/dist/constants/ApiEndpoints.d.ts +1 -0
  17. package/dist/constants/ApiEndpoints.js +1 -0
  18. package/dist/constants/ApiEndpoints.js.map +1 -1
  19. package/dist/constants/AuthTypes.js.map +1 -1
  20. package/dist/constants/BlueHQ.js.map +1 -1
  21. package/dist/constants/CryptoAlgorithms.js.map +1 -1
  22. package/dist/constants/ExtensionConfig.js.map +1 -1
  23. package/dist/constants/FileExtensions.js.map +1 -1
  24. package/dist/constants/FolderNames.js.map +1 -1
  25. package/dist/constants/Gateway.d.ts +71 -0
  26. package/dist/constants/Gateway.js +79 -0
  27. package/dist/constants/Gateway.js.map +1 -0
  28. package/dist/constants/GitHubUrls.js.map +1 -1
  29. package/dist/constants/Http.js.map +1 -1
  30. package/dist/constants/MimeTypes.js.map +1 -1
  31. package/dist/constants/Numerical.js.map +1 -1
  32. package/dist/constants/OutputChannels.js.map +1 -1
  33. package/dist/constants/SettingsKeys.d.ts +5 -0
  34. package/dist/constants/SettingsKeys.js +5 -0
  35. package/dist/constants/SettingsKeys.js.map +1 -1
  36. package/dist/constants/SpecialFiles.js.map +1 -1
  37. package/dist/constants/WebDAVElements.js.map +1 -1
  38. package/dist/constants/index.d.ts +1 -0
  39. package/dist/constants/index.js +3 -1
  40. package/dist/constants/index.js.map +1 -1
  41. package/dist/data/DownstairsPathParser.js.map +1 -1
  42. package/dist/data/GlobMatcher.js.map +1 -1
  43. package/dist/data/IdUtility.js.map +1 -1
  44. package/dist/data/OrgWorker.js.map +1 -1
  45. package/dist/data/ScriptKey.js.map +1 -1
  46. package/dist/data/ScriptUrlParser.js.map +1 -1
  47. package/dist/data/ServerVersion.d.ts +76 -0
  48. package/dist/data/ServerVersion.js +111 -0
  49. package/dist/data/ServerVersion.js.map +1 -0
  50. package/dist/data/index.d.ts +2 -0
  51. package/dist/data/index.js +7 -1
  52. package/dist/data/index.js.map +1 -1
  53. package/dist/gateway/GatewayClient.d.ts +147 -0
  54. package/dist/gateway/GatewayClient.js +395 -0
  55. package/dist/gateway/GatewayClient.js.map +1 -0
  56. package/dist/gateway/GatewayContext.d.ts +43 -0
  57. package/dist/gateway/GatewayContext.js +3 -0
  58. package/dist/gateway/GatewayContext.js.map +1 -0
  59. package/dist/gateway/GatewayGit.d.ts +291 -0
  60. package/dist/gateway/GatewayGit.js +731 -0
  61. package/dist/gateway/GatewayGit.js.map +1 -0
  62. package/dist/gateway/GatewayKb.d.ts +173 -0
  63. package/dist/gateway/GatewayKb.js +354 -0
  64. package/dist/gateway/GatewayKb.js.map +1 -0
  65. package/dist/gateway/GatewayMarketplace.d.ts +116 -0
  66. package/dist/gateway/GatewayMarketplace.js +278 -0
  67. package/dist/gateway/GatewayMarketplace.js.map +1 -0
  68. package/dist/gateway/GatewayService.d.ts +47 -0
  69. package/dist/gateway/GatewayService.js +54 -0
  70. package/dist/gateway/GatewayService.js.map +1 -0
  71. package/dist/gateway/GatewayToken.d.ts +18 -0
  72. package/dist/gateway/GatewayToken.js +43 -0
  73. package/dist/gateway/GatewayToken.js.map +1 -0
  74. package/dist/gateway/GatewayTokenService.d.ts +101 -0
  75. package/dist/gateway/GatewayTokenService.js +465 -0
  76. package/dist/gateway/GatewayTokenService.js.map +1 -0
  77. package/dist/index.d.ts +24 -9
  78. package/dist/index.js +33 -7
  79. package/dist/index.js.map +1 -1
  80. package/dist/network/HttpClient.js.map +1 -1
  81. package/dist/network/HttpClientProvider.js.map +1 -1
  82. package/dist/network/StatusCodes.js.map +1 -1
  83. package/dist/persistence/PersistablePseudoMap.js.map +1 -1
  84. package/dist/persistence/PersistenceKeys.js.map +1 -1
  85. package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
  86. package/dist/persistence/PseudoMap.js.map +1 -1
  87. package/dist/persistence/PublicPersistanceMap.js.map +1 -1
  88. package/dist/persistence/Serializable.js.map +1 -1
  89. package/dist/persistence/SharedFilePersistence.d.ts +22 -0
  90. package/dist/persistence/SharedFilePersistence.js +65 -14
  91. package/dist/persistence/SharedFilePersistence.js.map +1 -1
  92. package/dist/persistence/TypedMap.js.map +1 -1
  93. package/dist/persistence/TypedPersistable.js.map +1 -1
  94. package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
  95. package/dist/persistence/dirLockdown.js.map +1 -1
  96. package/dist/providers.d.ts +36 -19
  97. package/dist/script/GitIdentity.js.map +1 -1
  98. package/dist/script/GitSync.d.ts +78 -11
  99. package/dist/script/GitSync.js +84 -17
  100. package/dist/script/GitSync.js.map +1 -1
  101. package/dist/script/ScriptContext.d.ts +1 -8
  102. package/dist/script/ScriptFactory.d.ts +1 -2
  103. package/dist/script/ScriptFactory.js +1 -2
  104. package/dist/script/ScriptFactory.js.map +1 -1
  105. package/dist/script/ScriptFile.js.map +1 -1
  106. package/dist/script/ScriptFolder.js.map +1 -1
  107. package/dist/script/ScriptNode.js.map +1 -1
  108. package/dist/script/ScriptRoot.d.ts +0 -63
  109. package/dist/script/ScriptRoot.js +0 -178
  110. package/dist/script/ScriptRoot.js.map +1 -1
  111. package/dist/script/ScriptService.d.ts +45 -11
  112. package/dist/script/ScriptService.js +44 -6
  113. package/dist/script/ScriptService.js.map +1 -1
  114. package/dist/script/ServerCompile.d.ts +35 -0
  115. package/dist/script/ServerCompile.js +40 -0
  116. package/dist/script/ServerCompile.js.map +1 -0
  117. package/dist/script/TsConfig.d.ts +2 -2
  118. package/dist/script/TsConfig.js +3 -3
  119. package/dist/script/TsConfig.js.map +1 -1
  120. package/dist/script/push.d.ts +117 -77
  121. package/dist/script/push.js +151 -170
  122. package/dist/script/push.js.map +1 -1
  123. package/dist/session/SessionManager.js.map +1 -1
  124. package/dist/testing/FakeGateway.d.ts +280 -0
  125. package/dist/testing/FakeGateway.js +627 -0
  126. package/dist/testing/FakeGateway.js.map +1 -0
  127. package/dist/testing/MockFileSystem.js.map +1 -1
  128. package/dist/types.d.ts +332 -0
  129. package/dist/update/UpdateService.js.map +1 -1
  130. package/package.json +8 -7
  131. package/dist/script/ScriptTranspiler.d.ts +0 -183
  132. package/dist/script/ScriptTranspiler.js +0 -425
  133. package/dist/script/ScriptTranspiler.js.map +0 -1
  134. package/dist/script/TsLibResolver.d.ts +0 -60
  135. package/dist/script/TsLibResolver.js +0 -134
  136. package/dist/script/TsLibResolver.js.map +0 -1
package/dist/Err.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { GatewayMintedToken } from "./types";
1
2
  /**
2
3
  * Centralized error namespace containing all custom error types used throughout the application.
3
4
  * All error classes extend {@link Error} and have descriptive names that indicate why the error was thrown.
@@ -488,4 +489,418 @@ export declare namespace Err {
488
489
  class ScriptUrlParserError extends Error {
489
490
  constructor(message: string);
490
491
  }
492
+ /**
493
+ * Base of every error the gateway client throws. Messages say what happened, never how to
494
+ * respond, and never contain the access token.
495
+ * @lastreviewed null
496
+ */
497
+ class GatewayError extends Error {
498
+ /**
499
+ * The HTTP status, or `null` when no response was received or the failure is local.
500
+ * @lastreviewed null
501
+ */
502
+ readonly status: number | null;
503
+ /**
504
+ * The `error` code from the response body, a local code (`token-missing`, `token-malformed`),
505
+ * or `null` when none was given.
506
+ * @lastreviewed null
507
+ */
508
+ readonly code: string | null;
509
+ constructor(message: string, status: number | null, code: string | null);
510
+ }
511
+ /**
512
+ * The request carried no usable access token: none is available (`token-missing`, also thrown
513
+ * locally before any request is sent), the gateway refused it (`token-invalid`), or it is not
514
+ * shaped like a gateway token (`token-malformed`, local, nothing sent).
515
+ * @lastreviewed null
516
+ */
517
+ class GatewayAuthError extends GatewayError {
518
+ /**
519
+ * Which of the three it was.
520
+ * @lastreviewed null
521
+ */
522
+ readonly reason: "token-missing" | "token-invalid" | "token-malformed";
523
+ constructor(message: string, reason: "token-missing" | "token-invalid" | "token-malformed", status: number | null);
524
+ }
525
+ /**
526
+ * `403 scope-missing`: the token is valid but lacks the scope the route needs.
527
+ * @lastreviewed null
528
+ */
529
+ class GatewayScopeError extends GatewayError {
530
+ /**
531
+ * The missing scope (e.g. `kb:push`), or `null` when the gateway did not name it.
532
+ * @lastreviewed null
533
+ */
534
+ readonly scope: string | null;
535
+ constructor(message: string, scope: string | null);
536
+ }
537
+ /**
538
+ * `403 not-permitted` (or a `403` with no recognised body): the global user may not do this to
539
+ * this target, whatever the token's scopes.
540
+ * @lastreviewed null
541
+ */
542
+ class GatewayNotPermittedError extends GatewayError {
543
+ /**
544
+ * The `reason` the response body gave (`expiry-exceeds-presenting`, `restricted-mints-disabled`,
545
+ * `rewrite-not-permitted`, or a
546
+ * value this version does not know), or `null` when it gave none.
547
+ * @lastreviewed null
548
+ */
549
+ readonly reason: string | null;
550
+ /**
551
+ * With reason `expiry-exceeds-presenting`: when the presenting token expires, ISO 8601; else `null`.
552
+ * @lastreviewed null
553
+ */
554
+ readonly presentingExpiresAt: string | null;
555
+ /**
556
+ * With reason `rewrite-not-permitted`: the scope that was refused (`kb:rewrite`); else `null`. Only a
557
+ * short scope-shaped value is kept.
558
+ * @lastreviewed null
559
+ */
560
+ readonly scope: string | null;
561
+ constructor(message: string, code: string | null, reason?: string | null, presentingExpiresAt?: string | null, scope?: string | null);
562
+ }
563
+ /**
564
+ * `403 not-permitted` with reason `expiry-exceeds-presenting` on a token mint (`POST /api/v1/tokens`)
565
+ * or rotate: the token asked for would outlive the token making the request, whose expiry caps
566
+ * every new token's.
567
+ * @lastreviewed null
568
+ */
569
+ class GatewayTokenExpiryRefusedError extends GatewayNotPermittedError {
570
+ /**
571
+ * The expiry asked for, ISO 8601; `null` for a token that never expires; `undefined` when the
572
+ * request named none (a rotate keeps the rotated token's own lifetime).
573
+ * @lastreviewed null
574
+ */
575
+ readonly requestedExpiresAt: string | null | undefined;
576
+ /**
577
+ * When the presenting token expires, ISO 8601, as the gateway reported it.
578
+ * @lastreviewed null
579
+ */
580
+ readonly presentingExpiresAt: string;
581
+ constructor(message: string, requestedExpiresAt: string | null | undefined, presentingExpiresAt: string);
582
+ }
583
+ /**
584
+ * `403 not-permitted` with reason `restricted-mints-disabled` on a token mint or rotate: the gateway
585
+ * is not yet issuing tokens beyond the `mcp` scope (a rollout switch, not a property of the user).
586
+ * @lastreviewed null
587
+ */
588
+ class GatewayRestrictedMintsDisabledError extends GatewayNotPermittedError {
589
+ constructor(message: string);
590
+ }
591
+ /**
592
+ * `403 not-permitted` with reason `rewrite-not-permitted` on a token mint or rotate: this account may
593
+ * not hold the `kb:rewrite` scope, whatever the presenting token holds.
594
+ * @lastreviewed null
595
+ */
596
+ class GatewayRewriteNotPermittedError extends GatewayNotPermittedError {
597
+ constructor(message: string, scope: string);
598
+ }
599
+ /**
600
+ * `404`: the target does not exist, or exists but is not visible to this user. The gateway
601
+ * deliberately does not say which.
602
+ * @lastreviewed null
603
+ */
604
+ class GatewayNotFoundError extends GatewayError {
605
+ constructor(message: string, code: string | null);
606
+ }
607
+ /**
608
+ * `400 invalid-request`: the gateway rejected the request itself (malformed body or query, bad
609
+ * alias, an expiry in the past, no vocabulary scope, an unknown scope, a bad filter value). The
610
+ * gateway's own message says which; `code` is `invalid-request` or `null`.
611
+ * @lastreviewed null
612
+ */
613
+ class GatewayInvalidRequestError extends GatewayError {
614
+ constructor(message: string, code: string | null);
615
+ }
616
+ /**
617
+ * `409 token-limit`: the user already holds the maximum number of live tokens.
618
+ * @lastreviewed null
619
+ */
620
+ class GatewayTokenLimitError extends GatewayError {
621
+ /**
622
+ * The maximum number of live tokens (50 at the time of writing) when the response states it,
623
+ * else `null`.
624
+ * @lastreviewed null
625
+ */
626
+ readonly limit: number | null;
627
+ constructor(message: string, limit: number | null);
628
+ }
629
+ /**
630
+ * A `409` conflict. `non-fast-forward` (or a code-less `409` from the git routes) means the push
631
+ * does not build on the branch's current head; any other code is a different conflict (e.g.
632
+ * `alias-taken`) and the message says only that the request conflicts with current state.
633
+ * @lastreviewed null
634
+ */
635
+ class GatewayConflictError extends GatewayError {
636
+ constructor(message: string, code: string | null);
637
+ }
638
+ /**
639
+ * `409 live-branch-unprotected`: a push to a knowledge base's live branch was refused because the
640
+ * forge's protection rule for that branch is missing or has drifted. Nothing was pushed.
641
+ * @lastreviewed null
642
+ */
643
+ class GatewayLiveBranchUnprotectedError extends GatewayConflictError {
644
+ constructor(message: string);
645
+ }
646
+ /**
647
+ * `413 too-large`: the request body exceeds what the gateway accepts.
648
+ * @lastreviewed null
649
+ */
650
+ class GatewayTooLargeError extends GatewayError {
651
+ constructor(message: string, code: string | null);
652
+ }
653
+ /**
654
+ * The gateway, or the forge behind it, could not be reached: `502 forge-unavailable`, `503`
655
+ * (`registry-unavailable` means web-global, which holds the registry, could not answer), `504`, a network failure or a timeout (`status` is then `null`).
656
+ * @lastreviewed null
657
+ */
658
+ class GatewayUnavailableError extends GatewayError {
659
+ constructor(message: string, status: number | null, code: string | null);
660
+ }
661
+ /**
662
+ * Any other non-2xx status, a refused redirect (code `redirect-refused`; redirects are never
663
+ * followed), or a 2xx whose body is not the JSON the route promises.
664
+ * @lastreviewed null
665
+ */
666
+ class GatewayUnexpectedResponseError extends GatewayError {
667
+ constructor(message: string, status: number | null, code: string | null);
668
+ }
669
+ /**
670
+ * The configured gateway URL is unusable (not a URL, not `https:` off loopback, or carrying
671
+ * credentials, a query or a fragment), or a URL handed to the client is not on the gateway's
672
+ * origin. Thrown before any request, so the token is never sent anywhere unintended.
673
+ * @lastreviewed null
674
+ */
675
+ class GatewayConfigError extends GatewayError {
676
+ constructor(message: string);
677
+ }
678
+ /**
679
+ * A pull would overwrite local changes: the files the incoming commits change are modified,
680
+ * staged, deleted or untracked in the working copy. Nothing was changed.
681
+ * @lastreviewed null
682
+ */
683
+ class GatewayDirtyWorkingTreeError extends GatewayError {
684
+ /**
685
+ * Repo-relative, `/`-separated paths with local changes that the incoming commits also touch.
686
+ * @lastreviewed null
687
+ */
688
+ readonly paths: string[];
689
+ constructor(message: string, paths: string[]);
690
+ }
691
+ /**
692
+ * The local folder is not in a state the git operation can use. `reason` is `not-empty` (a clone
693
+ * target that has files), `not-a-clone` (no git repository there), `detached` (no current
694
+ * branch), `no-upstream` (the branch tracks nothing), `diverged` (the branch and its upstream
695
+ * each have commits the other lacks, so a fast-forward is impossible), `ref-not-found` (the
696
+ * remote has no such branch or tag), `wrong-repository` (the folder is a clone of a different
697
+ * repository than the one asked for) or `unsafe-target` (a clone target with a `.git` or `git~N`
698
+ * path component, which would put the clone's config inside a git directory).
699
+ * @lastreviewed null
700
+ */
701
+ class GatewayWorkingCopyError extends GatewayError {
702
+ /**
703
+ * Which of the states it was.
704
+ * @lastreviewed null
705
+ */
706
+ readonly reason: "not-empty" | "not-a-clone" | "detached" | "no-upstream" | "diverged" | "ref-not-found" | "wrong-repository" | "unsafe-target";
707
+ constructor(message: string, reason: "not-empty" | "not-a-clone" | "detached" | "no-upstream" | "diverged" | "ref-not-found" | "wrong-repository" | "unsafe-target");
708
+ }
709
+ /**
710
+ * A request that mints or rotates a token (code `outcome-unknown`) failed in a way that does
711
+ * not say whether the gateway acted: the connection dropped, no answer came in time, or a
712
+ * `502`/`503`/`504` came back. The token may have been minted (create) or rotated (rotate, in
713
+ * which case the old one is revoked), and any new secret was never received. It extends
714
+ * {@link GatewayUnavailableError}, so a generic handler still sees "unavailable", but it is a
715
+ * distinct type so a consumer can tell it apart from a request that never reached the gateway.
716
+ *
717
+ * A rotation is retried once, with the same `Idempotency-Key` and the same presenting token,
718
+ * before this is thrown (`retried: true`): when the retry is also unanswered, or when it is a
719
+ * `401`/`404` for the stored token (the first attempt most likely rotated it, which revoked it).
720
+ * A create is never retried.
721
+ * @lastreviewed null
722
+ */
723
+ class GatewayOutcomeUnknownError extends GatewayUnavailableError {
724
+ /**
725
+ * Which operation's outcome is unknown.
726
+ * @lastreviewed null
727
+ */
728
+ readonly operation: "create" | "rotate";
729
+ /**
730
+ * `true` when the request was retried once (with the same idempotency key) before giving up.
731
+ * @lastreviewed null
732
+ */
733
+ readonly retried: boolean;
734
+ constructor(message: string, operation: "create" | "rotate", status: number | null, retried?: boolean);
735
+ }
736
+ /**
737
+ * `403 scope-escalation`: a token was asked for with a scope the presenting token does not
738
+ * hold. A new token's scopes never exceed the presenting token's.
739
+ * @lastreviewed null
740
+ */
741
+ class GatewayScopeEscalationError extends GatewayError {
742
+ constructor(message: string);
743
+ }
744
+ /**
745
+ * `409 alias-taken`: another of this user's tokens already has the alias.
746
+ * @lastreviewed null
747
+ */
748
+ class GatewayAliasTakenError extends GatewayError {
749
+ constructor(message: string);
750
+ }
751
+ /**
752
+ * An argument to a gateway operation was refused before anything was sent (code
753
+ * `invalid-argument`): an empty alias or scope list, an expiry that is not a date, or a value
754
+ * shaped like a token secret where an id or alias belongs, or a relative path with no absolute
755
+ * `cwd` to resolve it against (core never reads `process.cwd()`). The value is never quoted.
756
+ * @lastreviewed null
757
+ */
758
+ class GatewayInvalidArgumentError extends GatewayError {
759
+ constructor(message: string);
760
+ }
761
+ /**
762
+ * An id-or-alias matched more than one of the caller's tokens (one by id, another by alias), so
763
+ * nothing was revoked or rotated (code `ambiguous`).
764
+ * @lastreviewed null
765
+ */
766
+ class GatewayTokenAmbiguousError extends GatewayError {
767
+ /**
768
+ * The ids of the tokens it matched.
769
+ * @lastreviewed null
770
+ */
771
+ readonly ids: readonly string[];
772
+ constructor(message: string, ids: readonly string[]);
773
+ }
774
+ /**
775
+ * The gateway rotated the stored token, so the old one is already revoked, but storing the
776
+ * replacement failed (code `store-failed`). The replacement's secret exists only here: it is
777
+ * carried in {@link replacement} so the consumer can show it and the user is not locked out.
778
+ *
779
+ * `replacement` is non-enumerable, so a generic error logger or `JSON.stringify` does not print
780
+ * the secret; read the property by name. The message never contains it.
781
+ * @lastreviewed null
782
+ */
783
+ class GatewayTokenStoreError extends GatewayError {
784
+ /**
785
+ * The minted replacement, secret included.
786
+ * @lastreviewed null
787
+ */
788
+ readonly replacement: GatewayMintedToken;
789
+ constructor(message: string, replacement: GatewayMintedToken);
790
+ }
791
+ /**
792
+ * The gateway minted or rotated a token (code `off-contract`), but its `2xx` answer about the
793
+ * token was malformed (a field missing or of the wrong type). The answer did carry the secret,
794
+ * which exists nowhere else, so this error carries it in {@link secret} rather than dropping it.
795
+ *
796
+ * For a rotation of the stored token, the old token is already revoked, and the secret was
797
+ * still offered to the store; {@link stored} says whether that worked. `secret` is
798
+ * non-enumerable, so a generic error logger or `JSON.stringify` does not print it; read the
799
+ * property by name. The message never contains it.
800
+ * @lastreviewed null
801
+ */
802
+ class GatewayOffContractTokenError extends GatewayError {
803
+ /**
804
+ * The minted `b6pt_…` secret.
805
+ * @lastreviewed null
806
+ */
807
+ readonly secret: string;
808
+ /**
809
+ * Which operation minted it.
810
+ * @lastreviewed null
811
+ */
812
+ readonly operation: "create" | "rotate";
813
+ /**
814
+ * Whether the secret is now the stored token (only ever `true` for a rotation of the stored token).
815
+ * @lastreviewed null
816
+ */
817
+ readonly stored: boolean;
818
+ constructor(message: string, operation: "create" | "rotate", secret: string, stored: boolean);
819
+ }
820
+ /**
821
+ * A marketplace pull found a clone it must not update. `reason` is `different-repo` (the
822
+ * folder's `origin` is not this repo's `gitUrl`), `different-ref` (the clone is on another branch
823
+ * or tag than the one asked for, or its branch tracks something other than that ref), `tag-moved`
824
+ * (the tag checked out now points at another commit on the gateway) or `tag-gone` (the gateway
825
+ * no longer has the tag). Nothing was changed.
826
+ * @lastreviewed null
827
+ */
828
+ class GatewayCloneMismatchError extends GatewayError {
829
+ /**
830
+ * Which of the four it was.
831
+ * @lastreviewed null
832
+ */
833
+ readonly reason: "different-repo" | "different-ref" | "tag-moved" | "tag-gone";
834
+ /**
835
+ * The local folder.
836
+ * @lastreviewed null
837
+ */
838
+ readonly dir: string;
839
+ /**
840
+ * The marketplace repo the pull was for.
841
+ * @lastreviewed null
842
+ */
843
+ readonly repo: string;
844
+ constructor(message: string, reason: "different-repo" | "different-ref" | "tag-moved" | "tag-gone", dir: string, repo: string);
845
+ }
846
+ /**
847
+ * A knowledge base could not be settled on. `reason` is `bad-ref` (the address is not `<name>` or
848
+ * `<U…>/<name>`), `not-found` (no knowledge base the caller may read has that address; the
849
+ * gateway does not say whether it exists), `ambiguous` (the listing holds more than one match;
850
+ * `candidates` are their refs), `unsafe-name` (the listed name cannot be a folder name),
851
+ * `not-a-kb` (a clone's remote is not a knowledge base the caller can see) or `wrong-branch` (a pull or push
852
+ * from a clone that is not on the knowledge base's live branch, does not track it, or is on a detached head).
853
+ * @lastreviewed null
854
+ */
855
+ class GatewayKnowledgeBaseError extends GatewayError {
856
+ /**
857
+ * Which of the situations it was.
858
+ * @lastreviewed null
859
+ */
860
+ readonly reason: "bad-ref" | "not-found" | "ambiguous" | "unsafe-name" | "not-a-kb" | "wrong-branch";
861
+ /**
862
+ * The address that was asked for, or `null` when none applies (`not-a-kb`).
863
+ * @lastreviewed null
864
+ */
865
+ readonly ref: string | null;
866
+ /**
867
+ * The `ref`s of the listed matches when `reason` is `ambiguous`, otherwise empty.
868
+ * @lastreviewed null
869
+ */
870
+ readonly candidates: string[];
871
+ /**
872
+ * For `wrong-branch`: the clone's current branch, `null` on a detached head. Otherwise `null`.
873
+ * @lastreviewed null
874
+ */
875
+ readonly branch: string | null;
876
+ /**
877
+ * For `wrong-branch`: the knowledge base's live branch. Otherwise `null`.
878
+ * @lastreviewed null
879
+ */
880
+ readonly liveBranch: string | null;
881
+ /**
882
+ * For `wrong-branch`: what the clone's branch tracks, as `origin/<branch>`, or `null` when it
883
+ * tracks nothing. Otherwise `null`.
884
+ * @lastreviewed null
885
+ */
886
+ readonly upstream: string | null;
887
+ constructor(message: string, reason: "bad-ref" | "not-found" | "ambiguous" | "unsafe-name" | "not-a-kb" | "wrong-branch", ref: string | null, candidates?: string[], branches?: {
888
+ branch: string | null;
889
+ liveBranch: string;
890
+ upstream: string | null;
891
+ } | null);
892
+ }
893
+ /**
894
+ * The caller may read a knowledge base but not push to it (`canPush` was `false` in a fresh
895
+ * listing). Thrown before anything is sent.
896
+ * @lastreviewed null
897
+ */
898
+ class GatewayKnowledgeBasePushNotPermittedError extends GatewayNotPermittedError {
899
+ /**
900
+ * The knowledge base's `ref` (e.g. `global/onboarding`).
901
+ * @lastreviewed null
902
+ */
903
+ readonly ref: string;
904
+ constructor(message: string, ref: string);
905
+ }
491
906
  }