@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
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Earliest server release that builds a git-pushed draft: GraphQL `compileDraft` with `expectedDraftSha` compiles the
3
+ * script's draft branch and commits the output (and, when it vouches for the build, the build manifest) as a build
4
+ * commit (web CU-1k5g91bq6u2, web#2022). A server at or above it (or a `dev` build) gets the build after every push; any
5
+ * other gets the git push alone, and a snapshot push to it publishes nothing. Set to the day web#2022 was readied
6
+ * (2026-11-16): web releases are dated, so every release cut from that day on carries it, and every earlier release
7
+ * line (backport patches included) sorts below it.
8
+ * @lastreviewed null
9
+ */
10
+ export declare const MIN_SERVER_VERSION: string | null;
11
+ /**
12
+ * Parses a release tag (`YY.MM.DD.NN`) into its numeric parts, or `null` when the text is not one.
13
+ * Surrounding whitespace is ignored.
14
+ * @lastreviewed null
15
+ */
16
+ export declare function parseReleaseTag(text: string): number[] | null;
17
+ /**
18
+ * Whether a server version meets a floor, compared numerically part by part (so a backport patch
19
+ * such as `26.11.02.05` sorts below `26.11.09.00`). Exactly `dev` or `latest` is current and meets any floor.
20
+ * An unreadable version, or an unreadable floor, does not.
21
+ * @lastreviewed null
22
+ */
23
+ export declare function meetsMinimumVersion(serverVersion: string, floor: string): boolean;
24
+ /**
25
+ * Which route a push takes, and why.
26
+ * - `server-build`: the draft is git-pushed, then the platform builds it (`compileDraft`) and, for a snapshot push,
27
+ * the build commit is published; reason `dev` or `at-or-above-floor`.
28
+ * - `push-only`: the draft is git-pushed and nothing else happens, because the server does not build git drafts;
29
+ * reason `below-floor`, `unknown` (the version could not be read, or is not a release tag) or `floor-unset`.
30
+ * @lastreviewed null
31
+ */
32
+ export interface PushRoute {
33
+ /** What the push does after the draft is pushed. @lastreviewed null */
34
+ readonly mode: "server-build" | "push-only";
35
+ /** Why this mode was chosen. @lastreviewed null */
36
+ readonly reason: "dev" | "at-or-above-floor" | "below-floor" | "unknown" | "floor-unset";
37
+ /** The version the server reported (trimmed), or `null` when it could not be read. @lastreviewed null */
38
+ readonly serverVersion: string | null;
39
+ /** The floor compared against, or `null` while it is unset. @lastreviewed null */
40
+ readonly required: string | null;
41
+ }
42
+ /**
43
+ * Why a snapshot push took no snapshot: the server does not build git drafts.
44
+ * `too-old` (a readable version below the floor), `unknown` (no readable version) or `floor-unset`
45
+ * (the floor is not yet known). The draft was still pushed.
46
+ * @lastreviewed null
47
+ */
48
+ export interface SnapshotRefusal {
49
+ /** Why the server is not trusted to compile and publish. @lastreviewed null */
50
+ readonly reason: "too-old" | "unknown" | "floor-unset";
51
+ /** The version the server reported, or `null` when it could not be read. @lastreviewed null */
52
+ readonly serverVersion: string | null;
53
+ /** The earliest release that supports a snapshot, or `null` when that is not yet known. @lastreviewed null */
54
+ readonly required: string | null;
55
+ }
56
+ /**
57
+ * The snapshot refusal a route implies: `null` on the build route, otherwise why the push-only
58
+ * route cannot take a snapshot.
59
+ * @lastreviewed null
60
+ */
61
+ export declare function snapshotRefusalFor(route: PushRoute): SnapshotRefusal | null;
62
+ /**
63
+ * Asks the org's server for its version and picks the push's route: the build when it is a
64
+ * `dev` build or at or above the floor, otherwise push-only. Never throws and never refuses a
65
+ * push: a version that cannot be read picks push-only, which every git server supports. Called once
66
+ * per push, before anything is pushed.
67
+ * @param opts.origin The org's origin (same as the push's)
68
+ * @param opts.fetchFn The session's `fetch`, so the request shares the push's origin and session
69
+ * @param opts.floor Overrides {@link MIN_SERVER_VERSION} (`null` means unset); used by tests
70
+ * @lastreviewed null
71
+ */
72
+ export declare function resolvePushRoute(opts: {
73
+ origin: string | URL;
74
+ fetchFn: (url: string | URL, init?: RequestInit) => Promise<Response>;
75
+ floor?: string | null;
76
+ }): Promise<PushRoute>;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MIN_SERVER_VERSION = void 0;
4
+ exports.parseReleaseTag = parseReleaseTag;
5
+ exports.meetsMinimumVersion = meetsMinimumVersion;
6
+ exports.snapshotRefusalFor = snapshotRefusalFor;
7
+ exports.resolvePushRoute = resolvePushRoute;
8
+ const constants_1 = require("../constants");
9
+ /**
10
+ * Earliest server release that builds a git-pushed draft: GraphQL `compileDraft` with `expectedDraftSha` compiles the
11
+ * script's draft branch and commits the output (and, when it vouches for the build, the build manifest) as a build
12
+ * commit (web CU-1k5g91bq6u2, web#2022). A server at or above it (or a `dev` build) gets the build after every push; any
13
+ * other gets the git push alone, and a snapshot push to it publishes nothing. Set to the day web#2022 was readied
14
+ * (2026-11-16): web releases are dated, so every release cut from that day on carries it, and every earlier release
15
+ * line (backport patches included) sorts below it.
16
+ * @lastreviewed null
17
+ */
18
+ exports.MIN_SERVER_VERSION = "26.11.16.00";
19
+ /**
20
+ * What a development build reports instead of a release tag, taken as current: `dev`, and `latest`
21
+ * (web's fast local image build sets it, ruling 49). A stale local image predating the floor would
22
+ * get the build anyway, and its build request would fail after the push.
23
+ * @lastreviewed null
24
+ */
25
+ const DEV_VERSIONS = new Set(["dev", "latest"]);
26
+ const RELEASE_TAG = /^\d{2}\.\d{2}\.\d{2}\.\d{2}$/;
27
+ /**
28
+ * Parses a release tag (`YY.MM.DD.NN`) into its numeric parts, or `null` when the text is not one.
29
+ * Surrounding whitespace is ignored.
30
+ * @lastreviewed null
31
+ */
32
+ function parseReleaseTag(text) {
33
+ const trimmed = text.trim();
34
+ return RELEASE_TAG.test(trimmed) ? trimmed.split(".").map(Number) : null;
35
+ }
36
+ /**
37
+ * Whether a server version meets a floor, compared numerically part by part (so a backport patch
38
+ * such as `26.11.02.05` sorts below `26.11.09.00`). Exactly `dev` or `latest` is current and meets any floor.
39
+ * An unreadable version, or an unreadable floor, does not.
40
+ * @lastreviewed null
41
+ */
42
+ function meetsMinimumVersion(serverVersion, floor) {
43
+ if (DEV_VERSIONS.has(serverVersion.trim())) {
44
+ return true;
45
+ }
46
+ const have = parseReleaseTag(serverVersion);
47
+ const need = parseReleaseTag(floor);
48
+ if (have === null || need === null) {
49
+ return false;
50
+ }
51
+ for (let i = 0; i < need.length; i++) {
52
+ if (have[i] !== need[i]) {
53
+ return have[i] > need[i];
54
+ }
55
+ }
56
+ return true;
57
+ }
58
+ /**
59
+ * The snapshot refusal a route implies: `null` on the build route, otherwise why the push-only
60
+ * route cannot take a snapshot.
61
+ * @lastreviewed null
62
+ */
63
+ function snapshotRefusalFor(route) {
64
+ if (route.mode === "server-build") {
65
+ return null;
66
+ }
67
+ const reason = route.reason === "below-floor" ? "too-old" : route.reason === "floor-unset" ? "floor-unset" : "unknown";
68
+ return { reason, serverVersion: route.serverVersion, required: route.required };
69
+ }
70
+ /**
71
+ * Asks the org's server for its version and picks the push's route: the build when it is a
72
+ * `dev` build or at or above the floor, otherwise push-only. Never throws and never refuses a
73
+ * push: a version that cannot be read picks push-only, which every git server supports. Called once
74
+ * per push, before anything is pushed.
75
+ * @param opts.origin The org's origin (same as the push's)
76
+ * @param opts.fetchFn The session's `fetch`, so the request shares the push's origin and session
77
+ * @param opts.floor Overrides {@link MIN_SERVER_VERSION} (`null` means unset); used by tests
78
+ * @lastreviewed null
79
+ */
80
+ async function resolvePushRoute(opts) {
81
+ const { origin, fetchFn } = opts;
82
+ const required = opts.floor !== undefined ? opts.floor : exports.MIN_SERVER_VERSION;
83
+ const url = new URL(origin);
84
+ url.pathname = constants_1.ApiEndpoints.APPINFO_VERSION;
85
+ url.search = "";
86
+ let serverVersion = null;
87
+ try {
88
+ const response = await fetchFn(url);
89
+ if (response.status === 200) {
90
+ const text = (await response.text()).trim();
91
+ serverVersion = text.length > 0 ? text : null;
92
+ }
93
+ }
94
+ catch {
95
+ serverVersion = null;
96
+ }
97
+ if (serverVersion !== null && DEV_VERSIONS.has(serverVersion)) {
98
+ return { mode: "server-build", reason: "dev", serverVersion, required };
99
+ }
100
+ if (serverVersion === null || parseReleaseTag(serverVersion) === null) {
101
+ // Nothing readable, or something that is not a release tag: not trusted to compile.
102
+ return { mode: "push-only", reason: "unknown", serverVersion, required };
103
+ }
104
+ if (required === null) {
105
+ return { mode: "push-only", reason: "floor-unset", serverVersion, required };
106
+ }
107
+ return meetsMinimumVersion(serverVersion, required)
108
+ ? { mode: "server-build", reason: "at-or-above-floor", serverVersion, required }
109
+ : { mode: "push-only", reason: "below-floor", serverVersion, required };
110
+ }
111
+ //# sourceMappingURL=ServerVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerVersion.js","sourceRoot":"","sources":["../../src/data/ServerVersion.ts"],"names":[],"mappings":";;;;;;;AAAA,4CAA4C;AAE5C;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAkB,aAAa,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAErE,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAEnD;;;;GAIG;AACH,yBAAgC,IAAY;IAC1C,MAAM,OAAO,GAA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AO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IAC3E,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC;QACjD,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,aAAa,EAAE,QAAQ,EAAE;QAChF,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;AAC5E,CAAC"}
@@ -2,4 +2,6 @@ export { DownstairsPathParser } from "./DownstairsPathParser";
2
2
  export { GlobMatcher } from "./GlobMatcher";
3
3
  export { IdUtility } from "./IdUtility";
4
4
  export { OrgWorker } from "./OrgWorker";
5
+ export type { PushRoute, SnapshotRefusal } from "./ServerVersion";
6
+ export { MIN_SERVER_VERSION, meetsMinimumVersion, parseReleaseTag, resolvePushRoute, snapshotRefusalFor, } from "./ServerVersion";
5
7
  export { ScriptUrlParser } from "./ScriptUrlParser";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScriptUrlParser = exports.OrgWorker = exports.IdUtility = exports.GlobMatcher = exports.DownstairsPathParser = void 0;
3
+ exports.ScriptUrlParser = exports.snapshotRefusalFor = exports.resolvePushRoute = exports.parseReleaseTag = exports.meetsMinimumVersion = exports.MIN_SERVER_VERSION = exports.OrgWorker = exports.IdUtility = exports.GlobMatcher = exports.DownstairsPathParser = void 0;
4
4
  var DownstairsPathParser_1 = require("./DownstairsPathParser");
5
5
  Object.defineProperty(exports, "DownstairsPathParser", { enumerable: true, get: function () { return DownstairsPathParser_1.DownstairsPathParser; } });
6
6
  var GlobMatcher_1 = require("./GlobMatcher");
@@ -9,6 +9,12 @@ var IdUtility_1 = require("./IdUtility");
9
9
  Object.defineProperty(exports, "IdUtility", { enumerable: true, get: function () { return IdUtility_1.IdUtility; } });
10
10
  var OrgWorker_1 = require("./OrgWorker");
11
11
  Object.defineProperty(exports, "OrgWorker", { enumerable: true, get: function () { return OrgWorker_1.OrgWorker; } });
12
+ var ServerVersion_1 = require("./ServerVersion");
13
+ Object.defineProperty(exports, "MIN_SERVER_VERSION", { enumerable: true, get: function () { return ServerVersion_1.MIN_SERVER_VERSION; } });
14
+ Object.defineProperty(exports, "meetsMinimumVersion", { enumerable: true, get: function () { return ServerVersion_1.meetsMinimumVersion; } });
15
+ Object.defineProperty(exports, "parseReleaseTag", { enumerable: true, get: function () { return ServerVersion_1.parseReleaseTag; } });
16
+ Object.defineProperty(exports, "resolvePushRoute", { enumerable: true, get: function () { return ServerVersion_1.resolvePushRoute; } });
17
+ Object.defineProperty(exports, "snapshotRefusalFor", { enumerable: true, get: function () { return ServerVersion_1.snapshotRefusalFor; } });
12
18
  var ScriptUrlParser_1 = require("./ScriptUrlParser");
13
19
  Object.defineProperty(exports, "ScriptUrlParser", { enumerable: true, get: function () { return ScriptUrlParser_1.ScriptUrlParser; } });
14
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":";;;AAAA,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,iDAMyB;AALvB,mHAAA,kBAAkB,OAAA;AAClB,oHAAA,mBAAmB,OAAA;AACnB,gHAAA,eAAe,OAAA;AACf,iHAAA,gBAAgB,OAAA;AAChB,mHAAA,kBAAkB,OAAA;AAEpB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA"}
@@ -0,0 +1,147 @@
1
+ import { Err } from "../Err";
2
+ import type { JsonValue } from "../types";
3
+ import type { GatewayContext } from "./GatewayContext";
4
+ /**
5
+ * Options for one gateway REST request.
6
+ * @lastreviewed null
7
+ */
8
+ export interface GatewayRequestOptions {
9
+ /**
10
+ * Query parameters; `undefined` values are left out.
11
+ * @lastreviewed null
12
+ */
13
+ query?: Readonly<Record<string, string | undefined>>;
14
+ /**
15
+ * JSON request body.
16
+ * @lastreviewed null
17
+ */
18
+ body?: JsonValue;
19
+ /**
20
+ * Extra request headers, e.g. `Idempotency-Key`. A name the client sets itself (`Authorization`,
21
+ * `Accept`, `Content-Type`) or a credential header (`Cookie`, `Proxy-Authorization`) is refused
22
+ * with {@link Err.GatewayConfigError} and nothing is sent, as is a name that is not an HTTP token
23
+ * or a value with control characters. No message quotes a value.
24
+ * @lastreviewed null
25
+ */
26
+ headers?: Readonly<Record<string, string>>;
27
+ }
28
+ /**
29
+ * The handle a {@link GatewayClient.sequence} unit sends its requests through. Every request it
30
+ * sends presents the one token read by its first {@link token} call.
31
+ * @lastreviewed null
32
+ */
33
+ export interface GatewaySequence {
34
+ /**
35
+ * The stored token, read once on first call (a typed {@link Err.GatewayAuthError} when none is
36
+ * usable) and the same value on every later call and request of the unit. A secret: never log
37
+ * it or put it in a message.
38
+ * @lastreviewed null
39
+ */
40
+ token(): Promise<string>;
41
+ /**
42
+ * Send one request as part of the unit. Await each before sending the next: the unit holds the
43
+ * client's queue, so its own requests are not queued behind one another.
44
+ * @lastreviewed null
45
+ */
46
+ request(method: string, path: string, options?: GatewayRequestOptions): Promise<JsonValue | undefined>;
47
+ }
48
+ /**
49
+ * Tuning for a {@link GatewayClient}.
50
+ * @lastreviewed null
51
+ */
52
+ export interface GatewayClientOptions {
53
+ /**
54
+ * Milliseconds before a request is abandoned as {@link Err.GatewayUnavailableError}.
55
+ * Defaults to `Gateway.REQUEST_TIMEOUT_MS`.
56
+ * @lastreviewed null
57
+ */
58
+ timeoutMs?: number;
59
+ }
60
+ /**
61
+ * Validate a configured gateway URL and reduce it to its origin. Throws
62
+ * {@link Err.GatewayConfigError} for anything the token must not be sent to.
63
+ * @lastreviewed null
64
+ */
65
+ export declare function parseGatewayOrigin(raw: string): string;
66
+ /**
67
+ * Map a gateway error response to its typed error. Exported so the git layer, which sees the
68
+ * status (and a best-effort body) through its own HTTP client, maps failures exactly as REST does.
69
+ *
70
+ * @param status the HTTP status (non-2xx)
71
+ * @param bodyText the raw response body, `""` when there is none
72
+ * @param what what was being attempted, e.g. `GET /api/v1/knowledge-bases`; must not contain the token
73
+ * @param token the token that was sent, redacted from anything the server said
74
+ * @lastreviewed null
75
+ */
76
+ export declare function gatewayErrorFor(status: number, bodyText: string, what: string, token?: string): Err.GatewayError;
77
+ /**
78
+ * HTTP client for web-global's gateway.
79
+ *
80
+ * Every request carries `Authorization: Bearer <b6pt_ token>`, asked of the injected
81
+ * {@link GatewayContext.gatewayToken} each time. There is no session, no login and no cookie: this
82
+ * is deliberately not {@link SessionManager}, which bootstraps the web origin's cookie session.
83
+ *
84
+ * REST requests made through this client ({@link request} / {@link getJson}) run **one at a time**,
85
+ * in call order, so a burst from a caller cannot fan out into parallel token reads or parallel
86
+ * connections (the same discipline `SessionManager` keeps). {@link sequence} puts a longer task, such
87
+ * as one of the git layer's operations, in the same queue. {@link authHeadersFor} is not queued: a
88
+ * request a caller sends itself with that header is outside it unless wrapped in `sequence`.
89
+ *
90
+ * Redirects are never followed; a 3xx is an {@link Err.GatewayUnexpectedResponseError} with code
91
+ * `redirect-refused`. A request path that resolves off the gateway's origin is refused unsent.
92
+ *
93
+ * The token never appears in a thrown message or a log line: the client never formats it, and
94
+ * anything the server says is passed through {@link redactToken} first.
95
+ * @lastreviewed null
96
+ */
97
+ export declare class GatewayClient {
98
+ private readonly ctx;
99
+ private tail;
100
+ private readonly timeoutMs;
101
+ constructor(ctx: GatewayContext, options?: GatewayClientOptions);
102
+ /**
103
+ * The validated gateway origin (e.g. `https://gateway.bluestep.net`), with no trailing slash.
104
+ * @lastreviewed null
105
+ */
106
+ origin(): Promise<string>;
107
+ /**
108
+ * The `Authorization` header for a request to `url`, for a caller that sends requests itself
109
+ * (the git layer hands this to its HTTP client). Throws {@link Err.GatewayConfigError} when
110
+ * `url` is not on the gateway's origin, so a server-supplied URL cannot redirect the token, and
111
+ * {@link Err.GatewayAuthError} when no usable token is available.
112
+ * @lastreviewed null
113
+ */
114
+ authHeadersFor(url: string): Promise<Record<string, string>>;
115
+ /**
116
+ * `GET` a JSON resource.
117
+ * @lastreviewed null
118
+ */
119
+ getJson(path: string, query?: GatewayRequestOptions["query"]): Promise<JsonValue | undefined>;
120
+ /**
121
+ * Send one REST request and return its parsed JSON body (`undefined` for an empty body). Queued
122
+ * behind any request already in flight on this client.
123
+ *
124
+ * @param method HTTP method
125
+ * @param path absolute path on the gateway, e.g. `/api/v1/knowledge-bases`
126
+ * @throws {Err.GatewayError} a subclass naming what went wrong
127
+ * @lastreviewed null
128
+ */
129
+ request(method: string, path: string, options?: GatewayRequestOptions): Promise<JsonValue | undefined>;
130
+ /**
131
+ * Run `unit` as ONE entry in this client's one-at-a-time queue, behind any request or unit
132
+ * already in flight. Nothing else on this client runs until `unit` settles. The git layer wraps
133
+ * a whole operation (several HTTP requests) in this so git traffic and REST calls never overlap
134
+ * (it ignores `seq`); token rotation runs list + rotate + store in it, so nothing queued can
135
+ * present the just-revoked token.
136
+ *
137
+ * `seq.token()` reads the stored token once, on first use, and every later call and every
138
+ * `seq.request` of the unit presents that same value.
139
+ *
140
+ * Inside `unit`, send REST requests through `seq` only. Calling {@link request} or `sequence` on
141
+ * this client from inside it waits behind the unit itself and never runs.
142
+ * @lastreviewed null
143
+ */
144
+ sequence<T>(unit: (seq: GatewaySequence) => Promise<T>): Promise<T>;
145
+ private requireToken;
146
+ private send;
147
+ }