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