@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,291 @@
1
+ import type { GatewayClient } from "./GatewayClient";
2
+ import type { GatewayContext } from "./GatewayContext";
3
+ /**
4
+ * Tuning for a {@link GatewayGit}.
5
+ * @lastreviewed null
6
+ */
7
+ export interface GatewayGitOptions {
8
+ /**
9
+ * Milliseconds to wait for a git request's response headers. Defaults to
10
+ * `Gateway.GIT_FIRST_BYTE_TIMEOUT_MS`.
11
+ * @lastreviewed null
12
+ */
13
+ firstByteTimeoutMs?: number;
14
+ /**
15
+ * Milliseconds a response body may yield nothing before it is abandoned. Defaults to
16
+ * `Gateway.GIT_IDLE_TIMEOUT_MS`.
17
+ * @lastreviewed null
18
+ */
19
+ idleTimeoutMs?: number;
20
+ }
21
+ /**
22
+ * Options for {@link GatewayGit.clone}.
23
+ * @lastreviewed null
24
+ */
25
+ export interface GatewayCloneOptions {
26
+ /**
27
+ * The branch or tag to check out. Defaults to the remote's default branch.
28
+ * @lastreviewed null
29
+ */
30
+ ref?: string;
31
+ }
32
+ /**
33
+ * What {@link GatewayGit.inspect} read from a clone.
34
+ * @lastreviewed null
35
+ */
36
+ export interface GatewayGitInspection {
37
+ /**
38
+ * The `origin` remote's URL, or `null` when none is set.
39
+ * @lastreviewed null
40
+ */
41
+ origin: string | null;
42
+ /**
43
+ * The current branch, or `null` on a detached head.
44
+ * @lastreviewed null
45
+ */
46
+ branch: string | null;
47
+ /**
48
+ * The commit checked out.
49
+ * @lastreviewed null
50
+ */
51
+ head: string;
52
+ /**
53
+ * The remote branch the current branch tracks (`master`, not `origin/master`), or `null`.
54
+ * @lastreviewed null
55
+ */
56
+ upstream: string | null;
57
+ /**
58
+ * The commit the asked-for local tag names, fully peeled; `null` when no tag was asked for or it does not exist.
59
+ * @lastreviewed null
60
+ */
61
+ tagCommit: string | null;
62
+ }
63
+ /**
64
+ * What {@link GatewayGit.clone} did.
65
+ * @lastreviewed null
66
+ */
67
+ export interface GatewayCloneResult {
68
+ /**
69
+ * The checked-out branch, or `null` when `ref` named a tag (a detached head).
70
+ * @lastreviewed null
71
+ */
72
+ branch: string | null;
73
+ /**
74
+ * The commit now checked out.
75
+ * @lastreviewed null
76
+ */
77
+ head: string;
78
+ }
79
+ /**
80
+ * The state of a clone made by {@link GatewayGit}.
81
+ * @lastreviewed null
82
+ */
83
+ export interface GatewayGitStatus {
84
+ /**
85
+ * The current branch, or `null` on a detached head.
86
+ * @lastreviewed null
87
+ */
88
+ branch: string | null;
89
+ /**
90
+ * The branch's upstream as `origin/<branch>`, or `null` when it tracks nothing.
91
+ * @lastreviewed null
92
+ */
93
+ upstream: string | null;
94
+ /**
95
+ * The commit checked out.
96
+ * @lastreviewed null
97
+ */
98
+ head: string;
99
+ /**
100
+ * Whether any file is modified, staged, deleted or untracked.
101
+ * @lastreviewed null
102
+ */
103
+ dirty: boolean;
104
+ /**
105
+ * Repo-relative, `/`-separated paths with local changes (empty when clean).
106
+ * @lastreviewed null
107
+ */
108
+ dirtyPaths: string[];
109
+ /**
110
+ * Commits on the branch that its upstream lacks, as of the last fetch (`0` without an upstream).
111
+ * @lastreviewed null
112
+ */
113
+ ahead: number;
114
+ /**
115
+ * Commits on the upstream that the branch lacks, as of the last fetch (`0` without an upstream).
116
+ * @lastreviewed null
117
+ */
118
+ behind: number;
119
+ }
120
+ /**
121
+ * Options for {@link GatewayGit.status}.
122
+ * @lastreviewed null
123
+ */
124
+ export interface GatewayGitStatusOptions {
125
+ /**
126
+ * Fetch from the gateway first, so `ahead` / `behind` are current. Off by default: status then
127
+ * uses only what is on disk.
128
+ * @lastreviewed null
129
+ */
130
+ fetch?: boolean;
131
+ }
132
+ /**
133
+ * What {@link GatewayGit.pull} did: `up-to-date` (nothing new upstream), `ahead` (the branch has
134
+ * commits upstream lacks and upstream has none new; nothing to pull) or `fast-forwarded`.
135
+ * @lastreviewed null
136
+ */
137
+ export interface GatewayPullResult {
138
+ outcome: "up-to-date" | "ahead" | "fast-forwarded";
139
+ branch: string;
140
+ /**
141
+ * The commit before the pull.
142
+ * @lastreviewed null
143
+ */
144
+ from: string;
145
+ /**
146
+ * The commit after the pull.
147
+ * @lastreviewed null
148
+ */
149
+ to: string;
150
+ }
151
+ /**
152
+ * What {@link GatewayGit.push} did.
153
+ * @lastreviewed null
154
+ */
155
+ export interface GatewayPushResult {
156
+ /**
157
+ * `false` when the branch had no commits upstream lacks, so nothing was sent.
158
+ * @lastreviewed null
159
+ */
160
+ pushed: boolean;
161
+ branch: string;
162
+ /**
163
+ * The upstream branch that was updated, e.g. `master`.
164
+ * @lastreviewed null
165
+ */
166
+ remoteBranch: string;
167
+ /**
168
+ * The commit the branch is now at.
169
+ * @lastreviewed null
170
+ */
171
+ head: string;
172
+ }
173
+ /**
174
+ * Git over the gateway's smart HTTP endpoints, in pure JS (isomorphic-git; no git install needed).
175
+ * It works only with the gateway-supplied `gitUrl` from the listings, never one it builds.
176
+ *
177
+ * Safety rules, all enforced here rather than left to a caller:
178
+ * - every request carries the `b6pt_` token via {@link GatewayClient.authHeadersFor}, which refuses
179
+ * a URL off the gateway's origin before any request is made; redirects are never followed;
180
+ * - {@link push} sends the current branch to its upstream only as a fast-forward: never forced,
181
+ * never a ref deletion, never a tag;
182
+ * - {@link pull} only fast-forwards, and refuses (naming the paths) when it would overwrite local
183
+ * changes;
184
+ * - file contents are never rewritten: no `autocrlf`, no filters, so a Windows checkout keeps the
185
+ * bytes the repository holds.
186
+ *
187
+ * Each operation runs inside the {@link GatewayClient} queue, so git traffic never overlaps a REST
188
+ * call or another git operation. The working copy is on the local disk through Node's `fs`
189
+ * directly: isomorphic-git needs the Node-fs surface (`lstat`, symlinks, file modes, sub-second
190
+ * mtimes) that the core `FileSystem` provider (URI-based, no `lstat`/`symlink`/`chmod`) does not
191
+ * offer, and a clone is always a real folder on the local machine.
192
+ * @lastreviewed null
193
+ */
194
+ export declare class GatewayGit {
195
+ private readonly ctx;
196
+ private readonly client;
197
+ private readonly firstByteTimeoutMs;
198
+ private readonly idleTimeoutMs;
199
+ private stall;
200
+ constructor(ctx: GatewayContext, client: GatewayClient, options?: GatewayGitOptions);
201
+ /**
202
+ * Clone `gitUrl` into `dir` (created if missing; it must be empty if it exists) and check out
203
+ * `ref`, or the default branch.
204
+ *
205
+ * @param gitUrl the `gitUrl` of a knowledge base or marketplace repo from the gateway's listing
206
+ * @param dir the local folder (an OS path)
207
+ * @throws {Err.GatewayWorkingCopyError} `not-empty` when `dir` has files; `ref-not-found`
208
+ * @throws {Err.GatewayError} a subclass for any gateway failure (see {@link gatewayErrorFor})
209
+ * @lastreviewed null
210
+ */
211
+ clone(gitUrl: string, dir: string, options?: GatewayCloneOptions): Promise<GatewayCloneResult>;
212
+ /**
213
+ * The URL the clone in `dir` fetches from and pushes to (its `origin`), or `null` when it has none.
214
+ * @throws {Err.GatewayWorkingCopyError} `not-a-clone` when `dir` is not a clone
215
+ * @lastreviewed null
216
+ */
217
+ originUrl(dir: string): Promise<string | null>;
218
+ /**
219
+ * The state of the clone in `dir`.
220
+ * @throws {Err.GatewayWorkingCopyError} `not-a-clone` when `dir` is not a clone (a detached head is not an
221
+ * error: `branch` is then `null`)
222
+ * @lastreviewed null
223
+ */
224
+ status(dir: string, options?: GatewayGitStatusOptions): Promise<GatewayGitStatus>;
225
+ /**
226
+ * Fetch the current branch's upstream and fast-forward to it. A clean tree just proceeds. Local
227
+ * changes the incoming commits do not touch are kept. The call never merges, rebases or
228
+ * overwrites.
229
+ *
230
+ * @throws {Err.GatewayDirtyWorkingTreeError} the incoming commits change files that have local
231
+ * changes (`paths`); nothing was changed
232
+ * @throws {Err.GatewayWorkingCopyError} `not-a-clone`, `detached`, `no-upstream`, or `diverged`
233
+ * @throws {Err.GatewayError} a subclass for any gateway failure
234
+ * @lastreviewed null
235
+ */
236
+ pull(dir: string): Promise<GatewayPullResult>;
237
+ /**
238
+ * Push the current branch to its upstream, only as a fast-forward. Never forced, never a
239
+ * deletion, never tags. Nothing is sent when the branch has no commits upstream lacks.
240
+ *
241
+ * @throws {Err.GatewayConflictError} the upstream has moved on (not a fast-forward), whether the
242
+ * client or the gateway noticed
243
+ * @throws {Err.GatewayWorkingCopyError} `not-a-clone`, `detached` or `no-upstream`
244
+ * @throws {Err.GatewayError} a subclass for any other gateway failure (auth, scope, not permitted, ...)
245
+ * @lastreviewed null
246
+ */
247
+ push(dir: string): Promise<GatewayPushResult>;
248
+ /**
249
+ * What a clone's own config and refs say, for a caller deciding whether it is the clone it wants:
250
+ * the `origin` URL, the current branch (`null` when detached), the head commit, the remote branch
251
+ * the current branch tracks, and, when `tag` is given, the commit that local tag names (peeled
252
+ * through any chain of annotated tags, to a depth of 10), or `null` when there is no such tag.
253
+ * @throws {Err.GatewayWorkingCopyError} `not-a-clone` when `dir` has no usable git repository
254
+ * (no `.git`, a gitdir file, or a damaged one)
255
+ * @lastreviewed null
256
+ */
257
+ inspect(dir: string, tag?: string): Promise<GatewayGitInspection>;
258
+ /**
259
+ * The commit a tag points at on the gateway right now (an annotated tag is peeled to its commit),
260
+ * or `null` when the repo has no such tag. Nothing is written locally.
261
+ * @param gitUrl the `gitUrl` of a listing
262
+ * @throws {Err.GatewayError} a subclass for any gateway failure
263
+ * @lastreviewed null
264
+ */
265
+ remoteTagCommit(gitUrl: string, tag: string): Promise<string | null>;
266
+ private localTagCommit;
267
+ private sequenced;
268
+ private typed;
269
+ private tokenText;
270
+ private throwIfStalled;
271
+ private requireClone;
272
+ private tracking;
273
+ private upstreamOf;
274
+ private noUpstream;
275
+ private dirtyError;
276
+ private stagedPaths;
277
+ private matchesCommit;
278
+ private notFoundRef;
279
+ private fetchBranch;
280
+ private aheadBehind;
281
+ private dirtyPaths;
282
+ private changedBetween;
283
+ /**
284
+ * The HTTP client isomorphic-git talks through: the injected `fetchFn` (so a consumer's proxy
285
+ * and TLS settings apply), the bearer header from {@link GatewayClient.authHeadersFor} on every
286
+ * request (so a URL off the gateway's origin throws before any bytes are sent), and redirects
287
+ * refused. A non-2xx answer becomes the typed gateway error right here.
288
+ * @lastreviewed null
289
+ */
290
+ private http;
291
+ }