@bluestep-systems/b6p-core 1.3.0 → 1.5.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.
- package/README.md +37 -2
- package/dist/Err.d.ts +39 -0
- package/dist/Err.js +59 -0
- package/dist/Err.js.map +1 -1
- package/dist/constants/Gateway.d.ts +1 -0
- package/dist/constants/Gateway.js +1 -0
- package/dist/constants/Gateway.js.map +1 -1
- package/dist/gateway/GatewayClient.js +16 -0
- package/dist/gateway/GatewayClient.js.map +1 -1
- package/dist/gateway/GatewayMarketplace.d.ts +164 -8
- package/dist/gateway/GatewayMarketplace.js +434 -12
- package/dist/gateway/GatewayMarketplace.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/testing/FakeGateway.d.ts +43 -2
- package/dist/testing/FakeGateway.js +259 -1
- package/dist/testing/FakeGateway.js.map +1 -1
- package/dist/types.d.ts +96 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GatewayMarketplaceRepo } from "../types";
|
|
1
|
+
import type { GatewayMarketplaceCreateRequest, GatewayMarketplaceCreateResult, GatewayMarketplaceRepo, GatewayMarketplaceRepoMetadata, GatewayMarketplaceTombstone } from "../types";
|
|
2
2
|
import type { GatewayClient } from "./GatewayClient";
|
|
3
3
|
import type { GatewayGit } from "./GatewayGit";
|
|
4
4
|
/**
|
|
@@ -66,9 +66,9 @@ export interface GatewayMarketplacePullResult {
|
|
|
66
66
|
from: string;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Marketplace repositories on web-global's gateway: browse them
|
|
70
|
-
*
|
|
71
|
-
* changes any script's sources or pins.
|
|
69
|
+
* Marketplace repositories on web-global's gateway: browse them, pull a plain working clone, and
|
|
70
|
+
* manage their lifecycle (create, edit, archive, rename, delete, purge). Core has no push of its own (a repo is pushed with plain `git`), and a
|
|
71
|
+
* pull never reads or changes any script's sources or pins.
|
|
72
72
|
* @lastreviewed null
|
|
73
73
|
*/
|
|
74
74
|
export declare class GatewayMarketplace {
|
|
@@ -84,12 +84,168 @@ export declare class GatewayMarketplace {
|
|
|
84
84
|
*/
|
|
85
85
|
list(): Promise<GatewayMarketplaceRepo[]>;
|
|
86
86
|
/**
|
|
87
|
-
* One marketplace repo by name.
|
|
88
|
-
* @
|
|
89
|
-
*
|
|
87
|
+
* One marketplace repo by name (`GET /api/v1/registry/repos/{name}`, scope `registry:read`). Unlike
|
|
88
|
+
* {@link list}, it finds an empty repo too (one just created and not yet pushed to), and it carries the
|
|
89
|
+
* repo's `website`, `topics` and `archived`. A name the gateway could never hold (not a marketplace repo name,
|
|
90
|
+
* or one the forge reserves) is not found, with nothing sent.
|
|
91
|
+
* @throws {Err.GatewayNotFoundError} no repo has exactly that name (a renamed repo's old name is not found
|
|
92
|
+
* either)
|
|
93
|
+
* @throws {Err.GatewayUnexpectedResponseError} the answer is malformed, or is for another repo
|
|
94
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
90
95
|
* @lastreviewed null
|
|
91
96
|
*/
|
|
92
97
|
get(name: string): Promise<GatewayMarketplaceRepo>;
|
|
98
|
+
/**
|
|
99
|
+
* Change a marketplace repo's metadata (`PATCH /api/v1/registry/repos/{name}`, scope `registry:push`, a fleet
|
|
100
|
+
* super). Only the members given change; one left out (or `undefined`) stays as it is. The members are checked as
|
|
101
|
+
* `create` checks them, and a change that names none (or any member but `description`, `website` and `topics`)
|
|
102
|
+
* fails here with nothing sent, as the gateway refuses it as `400`.
|
|
103
|
+
* @returns the repo as the forge now holds it
|
|
104
|
+
* @throws {Err.GatewayInvalidArgumentError} the name or a member is one the gateway would refuse; nothing sent
|
|
105
|
+
* @throws {Err.GatewayNotFoundError} `404`: no repo has exactly that name
|
|
106
|
+
* @throws {Err.GatewayRepoArchivedError} `409 repo-archived`: unarchive it first
|
|
107
|
+
* @throws {Err.GatewayRewriteInProgressError} `409 rewrite-in-progress`: retry shortly
|
|
108
|
+
* @throws {Err.GatewayInvalidRequestError} `400`
|
|
109
|
+
* @throws {Err.GatewayTooLargeError} `413`
|
|
110
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push`
|
|
111
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super
|
|
112
|
+
* @throws {Err.GatewayForgeUnavailableError} `502 forge-unavailable`
|
|
113
|
+
* @throws {Err.GatewayUnexpectedResponseError} the answer is not the repo asked for
|
|
114
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
115
|
+
* @lastreviewed null
|
|
116
|
+
*/
|
|
117
|
+
edit(name: string, metadata: GatewayMarketplaceRepoMetadata): Promise<GatewayMarketplaceRepo>;
|
|
118
|
+
/**
|
|
119
|
+
* Archive a marketplace repo (`POST /api/v1/registry/repos/{name}/archive`, scope `registry:push`, a fleet
|
|
120
|
+
* super): it can still be fetched, deleted and unarchived, but not pushed to, edited or renamed. Archiving an
|
|
121
|
+
* archived repo changes nothing and is not an error. npm packages are unaffected.
|
|
122
|
+
* @returns the repo, `archived` true
|
|
123
|
+
* @throws {Err.GatewayInvalidArgumentError} the name is not a marketplace repo name; nothing sent
|
|
124
|
+
* @throws {Err.GatewayNotFoundError} `404`
|
|
125
|
+
* @throws {Err.GatewayRewriteInProgressError} `409 rewrite-in-progress`: retry shortly
|
|
126
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push`
|
|
127
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super
|
|
128
|
+
* @throws {Err.GatewayForgeUnavailableError} `502 forge-unavailable`
|
|
129
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
130
|
+
* @lastreviewed null
|
|
131
|
+
*/
|
|
132
|
+
archive(name: string): Promise<GatewayMarketplaceRepo>;
|
|
133
|
+
/**
|
|
134
|
+
* Unarchive a marketplace repo (`POST /api/v1/registry/repos/{name}/unarchive`), so it can be pushed to,
|
|
135
|
+
* edited and renamed again. Unarchiving a repo that is not archived changes nothing and is not an error.
|
|
136
|
+
* Same errors as {@link archive}.
|
|
137
|
+
* @returns the repo, `archived` false
|
|
138
|
+
* @lastreviewed null
|
|
139
|
+
*/
|
|
140
|
+
unarchive(name: string): Promise<GatewayMarketplaceRepo>;
|
|
141
|
+
/**
|
|
142
|
+
* Rename a marketplace repo (`POST /api/v1/registry/repos/{name}/rename`, scope `registry:push`, a fleet
|
|
143
|
+
* super). Its metadata, tags and branch protection move with it, the gateway answers a git client on the old
|
|
144
|
+
* URL with a `301` to the new one, and npm packages are unaffected. The new name is checked as `create` checks a
|
|
145
|
+
* name (reserved names included) and must differ from the old one; both fail here with nothing sent.
|
|
146
|
+
*
|
|
147
|
+
* A consumer with a clone of the repo should point its remote at the returned repo's `gitUrl`.
|
|
148
|
+
* @returns the repo at its new name
|
|
149
|
+
* @throws {Err.GatewayInvalidArgumentError} either name is one the gateway would refuse, or they are the same
|
|
150
|
+
* @throws {Err.GatewayNotFoundError} `404`: no repo has exactly the old name
|
|
151
|
+
* @throws {Err.GatewayRepoArchivedError} `409 repo-archived`: unarchive it first
|
|
152
|
+
* @throws {Err.GatewayRepoExistsError} `409 repo-exists`: a repo already holds the new name (any case)
|
|
153
|
+
* @throws {Err.GatewayRewriteInProgressError} `409 rewrite-in-progress`: retry shortly
|
|
154
|
+
* @throws {Err.GatewayInvalidRequestError} `400`: the forge does not accept the new name
|
|
155
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push`
|
|
156
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super
|
|
157
|
+
* @throws {Err.GatewayForgeUnavailableError} `502 forge-unavailable`
|
|
158
|
+
* @throws {Err.GatewayUnexpectedResponseError} the answer is not the repo at the new name
|
|
159
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
160
|
+
* @lastreviewed null
|
|
161
|
+
*/
|
|
162
|
+
rename(name: string, newName: string): Promise<GatewayMarketplaceRepo>;
|
|
163
|
+
/**
|
|
164
|
+
* Delete a marketplace repo (`DELETE /api/v1/registry/repos/{name}`, scope `registry:push`, a fleet super):
|
|
165
|
+
* the gateway renames it to its tombstone and archives it. Nothing is destroyed (history, tags and npm packages
|
|
166
|
+
* stay), the name is free for `create` again, and a git client on the old URL gets `404`. A purge of the
|
|
167
|
+
* tombstone is what destroys it.
|
|
168
|
+
* @returns the tombstone's name (`_deleted-<id>-<name>`), which {@link purge} takes
|
|
169
|
+
* @throws {Err.GatewayInvalidArgumentError} the name is not a marketplace repo name; nothing sent
|
|
170
|
+
* @throws {Err.GatewayNotFoundError} `404`
|
|
171
|
+
* @throws {Err.GatewayRepoExistsError} `409 repo-exists`: a repo already holds the tombstone's name
|
|
172
|
+
* @throws {Err.GatewayRewriteInProgressError} `409 rewrite-in-progress`: retry shortly
|
|
173
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push`
|
|
174
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super
|
|
175
|
+
* @throws {Err.GatewayForgeUnavailableError} `502 forge-unavailable`
|
|
176
|
+
* @throws {Err.GatewayUnexpectedResponseError} the answer names no tombstone of this repo
|
|
177
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
178
|
+
* @lastreviewed null
|
|
179
|
+
*/
|
|
180
|
+
delete(name: string): Promise<string>;
|
|
181
|
+
/**
|
|
182
|
+
* The deleted marketplace repos still awaiting a purge (`GET /api/v1/registry/tombstones`, scope
|
|
183
|
+
* `registry:push`, a fleet super), sorted by tombstone name as the gateway sends them. An entry of the wrong
|
|
184
|
+
* shape is left out. There is no restore.
|
|
185
|
+
* @throws {Err.GatewayUnexpectedResponseError} the body is not a tombstone list at all
|
|
186
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push`
|
|
187
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super
|
|
188
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
189
|
+
* @lastreviewed null
|
|
190
|
+
*/
|
|
191
|
+
tombstones(): Promise<GatewayMarketplaceTombstone[]>;
|
|
192
|
+
/**
|
|
193
|
+
* Purge a tombstone for good (`DELETE /api/v1/registry/tombstones/{tombstone}`): the gateway deletes the
|
|
194
|
+
* archived repo from the forge, history and tags with it. There is no undo and no waiting period, and the purge
|
|
195
|
+
* is audited. npm packages are unaffected. The caller must be a fleet super holding `registry:push` AND the
|
|
196
|
+
* history-manager grant.
|
|
197
|
+
*
|
|
198
|
+
* `tombstone` is the name {@link delete} returned or {@link tombstones} lists (`_deleted-<id>-<name>`), not a
|
|
199
|
+
* marketplace repo name: it is checked against the tombstone rule, not the repo name rule.
|
|
200
|
+
* @throws {Err.GatewayInvalidArgumentError} not a tombstone name; nothing sent
|
|
201
|
+
* @throws {Err.GatewayNotFoundError} `404`: no such tombstone
|
|
202
|
+
* @throws {Err.GatewayNotArchivedError} `409 not-archived`: the tombstone is not archived
|
|
203
|
+
* @throws {Err.GatewayRewriteInProgressError} `409 rewrite-in-progress`: retry shortly
|
|
204
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push`
|
|
205
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super or lacks the
|
|
206
|
+
* history-manager grant (the message says both are needed)
|
|
207
|
+
* @throws {Err.GatewayForgeUnavailableError} `502 forge-unavailable`
|
|
208
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
209
|
+
* @lastreviewed null
|
|
210
|
+
*/
|
|
211
|
+
purge(tombstone: string): Promise<void>;
|
|
212
|
+
private setArchived;
|
|
213
|
+
private requireName;
|
|
214
|
+
private repoPath;
|
|
215
|
+
/**
|
|
216
|
+
* The repo an answer carries, which must be the one the request was about.
|
|
217
|
+
* @lastreviewed null
|
|
218
|
+
*/
|
|
219
|
+
private repoAnswer;
|
|
220
|
+
/**
|
|
221
|
+
* Create a marketplace repo (`POST /api/v1/registry/repos`, scope `registry:push`, a fleet super): the gateway
|
|
222
|
+
* makes it private and empty with default branch `main`, sets the metadata given and protects `main`.
|
|
223
|
+
* An existing empty repo of the same name (left by an earlier attempt) is adopted rather than refused.
|
|
224
|
+
* Only the members given are sent. The request is checked as the gateway checks it, so a bad one fails here
|
|
225
|
+
* with nothing sent.
|
|
226
|
+
*
|
|
227
|
+
* The repo is empty, so it is NOT in {@link list} until its first push: the result carries the repo from
|
|
228
|
+
* the answer (do not list to find it). The first push is `git push --atomic <gitUrl> main` alone, then its tags in a second push.
|
|
229
|
+
*
|
|
230
|
+
* @returns `created` is `true` for a new repo (`201`), `false` when an existing empty one was adopted (`200`)
|
|
231
|
+
* @throws {Err.GatewayInvalidArgumentError} the name or a metadata member is one the gateway would refuse; nothing sent
|
|
232
|
+
* @throws {Err.GatewayInvalidRequestError} `400`, the gateway refused the request
|
|
233
|
+
* @throws {Err.GatewayTooLargeError} `413`
|
|
234
|
+
* @throws {Err.GatewayScopeError} the token lacks `registry:push` (`scope`)
|
|
235
|
+
* @throws {Err.GatewayNotPermittedError} `403 not-permitted`: the owner is not a fleet super
|
|
236
|
+
* @throws {Err.GatewayRepoExistsError} `409 repo-exists`: a repo of that name has history, is archived, or differs in case
|
|
237
|
+
* @throws {Err.GatewayRewriteInProgressError} `409 rewrite-in-progress`: another change holds the repo; retry shortly
|
|
238
|
+
* @throws {Err.GatewayForgeUnavailableError} `502 forge-unavailable`: an empty repo may be left; calling again adopts it
|
|
239
|
+
* @throws {Err.GatewayUnexpectedResponseError} the answer is not a repo named as asked
|
|
240
|
+
* @throws {Err.GatewayError} a subclass for any other gateway failure
|
|
241
|
+
* @lastreviewed null
|
|
242
|
+
*/
|
|
243
|
+
create(request: GatewayMarketplaceCreateRequest): Promise<GatewayMarketplaceCreateResult>;
|
|
244
|
+
/**
|
|
245
|
+
* A repo by name from the listing: what {@link pull} clones. An empty repo is not listed, and so is not pulled.
|
|
246
|
+
* @lastreviewed null
|
|
247
|
+
*/
|
|
248
|
+
private listed;
|
|
93
249
|
private entries;
|
|
94
250
|
/**
|
|
95
251
|
* Make `options.dir` (default: `<cwd>/<name>`, relative paths resolved against `options.cwd`) a
|
|
@@ -99,7 +255,7 @@ export declare class GatewayMarketplace {
|
|
|
99
255
|
* tracks it; a clone on a tag is `up-to-date` only while the gateway's tag still points at the
|
|
100
256
|
* checked-out commit. Nothing is merged, rebased or overwritten, and nothing is pushed.
|
|
101
257
|
*
|
|
102
|
-
* @param name the repo's name from {@link list}
|
|
258
|
+
* @param name the repo's name from {@link list}: an empty repo is not listed, so it is not pulled
|
|
103
259
|
* @throws {Err.GatewayNotFoundError} no such repo
|
|
104
260
|
* @throws {Err.GatewayConfigError} the folder is relative and `cwd` is missing or not absolute
|
|
105
261
|
* @throws {Err.GatewayUnexpectedResponseError} the name cannot be a folder name (with no `dir`)
|