@coffre/conformance 0.9.0 → 0.10.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 (2) hide show
  1. package/dist/main.js +45 -1
  2. package/package.json +4 -4
package/dist/main.js CHANGED
@@ -154,6 +154,10 @@ function place(path) {
154
154
  key
155
155
  };
156
156
  }
157
+ /** `?revision=57.3f9a0c2e81b4d7a6`, or nothing for a change asked without its preview. */
158
+ function asPreviewed(revision) {
159
+ return revision === void 0 ? "" : `?revision=${encodeURIComponent(revision)}`;
160
+ }
157
161
  function createClient(options) {
158
162
  const origin = options.url.replace(/\/+$/, "");
159
163
  const transport = options.transport ?? (async (request) => {
@@ -219,6 +223,12 @@ function createClient(options) {
219
223
  /** As a project's: its `name` defaults to the slug. `from` forks a sibling. */
220
224
  create: (path, input = {}) => call("PUT /projects/:project/:environment", place(path), input),
221
225
  update: (path, patch) => call("PATCH /projects/:project/:environment", place(path), patch),
226
+ /**
227
+ * Protected, a person holds their role's protected column there
228
+ * (docs/design/roles.md); whoever manages the project's environments
229
+ * protects one, and only an Owner of the whole instance unprotects it.
230
+ */
231
+ protect: (path, on = true) => call("PATCH /projects/:project/:environment", place(path), { protected: on }),
222
232
  /** What deleting an archived environment would erase and revoke; changes nothing. */
223
233
  previewDelete: (path) => {
224
234
  const [method, route] = address("DELETE /projects/:project/:environment", place(path));
@@ -306,7 +316,7 @@ function createClient(options) {
306
316
  })
307
317
  },
308
318
  /**
309
- * Handles: stand-ins a person's app holds in place of an environment's
319
+ * Handles: placeholders a person's app holds in place of an environment's
310
320
  * values, which only the credential proxy (`/use`) takes. The value is
311
321
  * in the answer, and only there; it is revoked as a token is.
312
322
  */
@@ -403,6 +413,39 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
403
413
  list: () => call("GET /apps", {}),
404
414
  disconnect: (id) => call("DELETE /apps/:id", { id })
405
415
  },
416
+ /**
417
+ * The instance's roles, in two columns, an environment's that is not
418
+ * protected and one's that is (docs/design/roles.md). Any member lists
419
+ * them; an Owner of the whole instance edits them. `instance` is about
420
+ * instance roles, a person's across every project in their scope.
421
+ */
422
+ roles: {
423
+ list: () => call("GET /roles", {}),
424
+ /** What defining the role so would do to everyone it reaches; changes nothing. */
425
+ preview: (role, definition, { instance = false } = {}) => {
426
+ const [method, route] = instance ? address("PUT /instance-roles/:role", { role }) : address("PUT /roles/:role", { role });
427
+ return send(method, `${route}?dryRun=1`, definition);
428
+ },
429
+ /**
430
+ * A built-in role edited, or one an Owner makes. With its preview's
431
+ * `revision`, made as previewed, or refused (409 `policy_changed`)
432
+ * if the policy changed since: preview it again.
433
+ */
434
+ set: (role, definition, { instance = false, revision } = {}) => {
435
+ const [method, route] = instance ? address("PUT /instance-roles/:role", { role }) : address("PUT /roles/:role", { role });
436
+ return send(method, `${route}${asPreviewed(revision)}`, definition);
437
+ },
438
+ /** What putting it back as it ships, or deleting one an Owner made, would do; changes nothing. */
439
+ previewReset: (role, { instance = false } = {}) => {
440
+ const [method, route] = instance ? address("DELETE /instance-roles/:role", { role }) : address("DELETE /roles/:role", { role });
441
+ return send(method, `${route}?dryRun=1`, void 0);
442
+ },
443
+ /** A built-in role back as it ships; one an Owner made, deleted, while no grant names it. With its preview's `revision`, as `set`. */
444
+ reset: (role, { instance = false, revision } = {}) => {
445
+ const [method, route] = instance ? address("DELETE /instance-roles/:role", { role }) : address("DELETE /roles/:role", { role });
446
+ return send(method, `${route}${asPreviewed(revision)}`, void 0);
447
+ }
448
+ },
406
449
  /** The instance's settings, for those who run it: where people set up service accounts themselves. */
407
450
  settings: {
408
451
  get: () => call("GET /settings", {}),
@@ -3217,6 +3260,7 @@ function getCalls({ places, secrets, members, services }) {
3217
3260
  input: { github: "acme/api" }
3218
3261
  }],
3219
3262
  "GET /workloads/repositories": [{ params: {} }],
3263
+ "GET /roles": [{ params: {} }],
3220
3264
  "GET /settings": [{ params: {} }],
3221
3265
  "GET /sessions": [{ params: {} }],
3222
3266
  "GET /identities": [{ params: {} }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/conformance",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Checks a coffre deployment from outside: what it must never do, whatever code it runs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "jose": "6.2.3",
33
33
  "pg": "8.16.3",
34
- "@coffre/db": "0.9.0",
35
- "@coffre/cli": "0.9.0"
34
+ "@coffre/cli": "0.10.0",
35
+ "@coffre/db": "0.10.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "26.1.1",
@@ -41,7 +41,7 @@
41
41
  "tsdown": "0.23.0",
42
42
  "typescript": "5.9.3",
43
43
  "vite": "8.1.5",
44
- "@coffre/client": "0.9.0"
44
+ "@coffre/client": "0.10.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsdown",