@coffre/client 0.8.2 → 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.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as TokenPlan, A as Decision, B as Me, C as ApprovalView, D as BindingPlan, E as AuthorizationView, F as DryRunResult, G as PersonalConfig, H as MemberAccess, I as IdentityRow, J as RemovedMember, K as ProjectSummary, L as InheritResult, M as DeletionResult, N as DismissedKey, O as BindingView, P as DryRunOutcome, Q as SetResult, R as KeysPlan, S as Api, T as AuthInfo, U as MissingKey, V as Member, W as OffboardingReport, X as SecretVersion, Y as SecretKey, Z as SessionRow, _ as byFolder, a as Params, b as olderThan, c as RouteOutput, d as planImport, et as TokenRow, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, j as Deletion, k as ConnectedApp, l as Transport, m as apiMember, n as CoffreClient, o as RouteInput, p as unreachable, q as ReferenceView, r as CoffreError, s as RouteKey, t as ClientOptions, tt as WorkloadIds, u as createClient, v as foldersOf, w as AuditEntryView, x as AccessValue, y as ageInDays, z as ListedReference } from "./index-DgII_R1y.js";
2
- export { type AccessValue, type Api, type ApprovalView, type AuditEntryView, type AuthInfo, type AuthorizationView, type BindingPlan, type BindingView, ClientOptions, CoffreClient, CoffreError, type ConnectedApp, type Decision, type Deletion, type DeletionResult, type DismissedKey, type DryRunOutcome, type DryRunResult, type IdentityRow, ImportAction, type InheritResult, type KeysPlan, type ListedReference, type Me, type Member, type MemberAccess, type MissingKey, type OffboardingReport, Params, type PersonalConfig, type ProjectSummary, type ReferenceView, type RemovedMember, RouteInput, RouteKey, RouteOutput, type SecretKey, type SecretVersion, type SessionRow, type SetResult, type TokenPlan, type TokenRow, Transport, Unreachable, type WorkloadIds, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, serviceName, shownMember, unreachable };
1
+ import { $ as RolesView, A as Decision, B as KeysPlan, C as ApprovalView, D as BindingPlan, E as AuthorizationView, F as DryRunResult, G as MissingKey, H as Me, I as EnvironmentView, J as ProjectSummary, K as OffboardingReport, L as IdentityRow, M as DeletionResult, N as DismissedKey, O as BindingView, P as DryRunOutcome, Q as RoleView, R as ImpactLine, S as Api, T as AuthInfo, U as Member, V as ListedReference, W as MemberAccess, X as RemovedMember, Y as ReferenceView, Z as RoleImpact, _ as byFolder, a as Params, at as TokenRow, b as olderThan, c as RouteOutput, d as planImport, et as SecretKey, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, it as TokenPlan, j as Deletion, k as ConnectedApp, l as Transport, m as apiMember, n as CoffreClient, nt as SessionRow, o as RouteInput, ot as WorkloadIds, p as unreachable, q as PersonalConfig, r as CoffreError, rt as SetResult, s as RouteKey, t as ClientOptions, tt as SecretVersion, u as createClient, v as foldersOf, w as AuditEntryView, x as AccessValue, y as ageInDays, z as InheritResult } from "./index-PXC2jUur.js";
2
+ export { type AccessValue, type Api, type ApprovalView, type AuditEntryView, type AuthInfo, type AuthorizationView, type BindingPlan, type BindingView, ClientOptions, CoffreClient, CoffreError, type ConnectedApp, type Decision, type Deletion, type DeletionResult, type DismissedKey, type DryRunOutcome, type DryRunResult, type EnvironmentView, type IdentityRow, type ImpactLine, ImportAction, type InheritResult, type KeysPlan, type ListedReference, type Me, type Member, type MemberAccess, type MissingKey, type OffboardingReport, Params, type PersonalConfig, type ProjectSummary, type ReferenceView, type RemovedMember, type RoleImpact, type RoleView, type RolesView, RouteInput, RouteKey, RouteOutput, type SecretKey, type SecretVersion, type SessionRow, type SetResult, type TokenPlan, type TokenRow, Transport, Unreachable, type WorkloadIds, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, serviceName, shownMember, unreachable };
package/dist/index.js CHANGED
@@ -128,6 +128,10 @@ function place(path) {
128
128
  key
129
129
  };
130
130
  }
131
+ /** `?revision=57.3f9a0c2e81b4d7a6`, or nothing for a change asked without its preview. */
132
+ function asPreviewed(revision) {
133
+ return revision === void 0 ? "" : `?revision=${encodeURIComponent(revision)}`;
134
+ }
131
135
  function createClient(options) {
132
136
  const origin = options.url.replace(/\/+$/, "");
133
137
  const transport = options.transport ?? (async (request) => {
@@ -193,6 +197,12 @@ function createClient(options) {
193
197
  /** As a project's: its `name` defaults to the slug. `from` forks a sibling. */
194
198
  create: (path, input = {}) => call("PUT /projects/:project/:environment", place(path), input),
195
199
  update: (path, patch) => call("PATCH /projects/:project/:environment", place(path), patch),
200
+ /**
201
+ * Protected, a person holds their role's protected column there
202
+ * (docs/design/roles.md); whoever manages the project's environments
203
+ * protects one, and only an Owner of the whole instance unprotects it.
204
+ */
205
+ protect: (path, on = true) => call("PATCH /projects/:project/:environment", place(path), { protected: on }),
196
206
  /** What deleting an archived environment would erase and revoke; changes nothing. */
197
207
  previewDelete: (path) => {
198
208
  const [method, route] = address("DELETE /projects/:project/:environment", place(path));
@@ -280,7 +290,7 @@ function createClient(options) {
280
290
  })
281
291
  },
282
292
  /**
283
- * Handles: stand-ins a person's app holds in place of an environment's
293
+ * Handles: placeholders a person's app holds in place of an environment's
284
294
  * values, which only the credential proxy (`/use`) takes. The value is
285
295
  * in the answer, and only there; it is revoked as a token is.
286
296
  */
@@ -377,6 +387,39 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
377
387
  list: () => call("GET /apps", {}),
378
388
  disconnect: (id) => call("DELETE /apps/:id", { id })
379
389
  },
390
+ /**
391
+ * The instance's roles, in two columns, an environment's that is not
392
+ * protected and one's that is (docs/design/roles.md). Any member lists
393
+ * them; an Owner of the whole instance edits them. `instance` is about
394
+ * instance roles, a person's across every project in their scope.
395
+ */
396
+ roles: {
397
+ list: () => call("GET /roles", {}),
398
+ /** What defining the role so would do to everyone it reaches; changes nothing. */
399
+ preview: (role, definition, { instance = false } = {}) => {
400
+ const [method, route] = instance ? address("PUT /instance-roles/:role", { role }) : address("PUT /roles/:role", { role });
401
+ return send(method, `${route}?dryRun=1`, definition);
402
+ },
403
+ /**
404
+ * A built-in role edited, or one an Owner makes. With its preview's
405
+ * `revision`, made as previewed, or refused (409 `policy_changed`)
406
+ * if the policy changed since: preview it again.
407
+ */
408
+ set: (role, definition, { instance = false, revision } = {}) => {
409
+ const [method, route] = instance ? address("PUT /instance-roles/:role", { role }) : address("PUT /roles/:role", { role });
410
+ return send(method, `${route}${asPreviewed(revision)}`, definition);
411
+ },
412
+ /** What putting it back as it ships, or deleting one an Owner made, would do; changes nothing. */
413
+ previewReset: (role, { instance = false } = {}) => {
414
+ const [method, route] = instance ? address("DELETE /instance-roles/:role", { role }) : address("DELETE /roles/:role", { role });
415
+ return send(method, `${route}?dryRun=1`, void 0);
416
+ },
417
+ /** 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`. */
418
+ reset: (role, { instance = false, revision } = {}) => {
419
+ const [method, route] = instance ? address("DELETE /instance-roles/:role", { role }) : address("DELETE /roles/:role", { role });
420
+ return send(method, `${route}${asPreviewed(revision)}`, void 0);
421
+ }
422
+ },
380
423
  /** The instance's settings, for those who run it: where people set up service accounts themselves. */
381
424
  settings: {
382
425
  get: () => call("GET /settings", {}),
package/dist/routes.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Params, o as RouteInput, s as RouteKey } from "./index-DgII_R1y.js";
1
+ import { a as Params, o as RouteInput, s as RouteKey } from "./index-PXC2jUur.js";
2
2
  //#region src/routes.d.ts
3
3
  export type GetKey = Extract<RouteKey, `GET ${string}`>;
4
4
  /** Each GET route, with what to ask it. */
package/dist/routes.js CHANGED
@@ -29,6 +29,7 @@ function getCalls({ places, secrets, members, services }) {
29
29
  input: { github: "acme/api" }
30
30
  }],
31
31
  "GET /workloads/repositories": [{ params: {} }],
32
+ "GET /roles": [{ params: {} }],
32
33
  "GET /settings": [{ params: {} }],
33
34
  "GET /sessions": [{ params: {} }],
34
35
  "GET /identities": [{ params: {} }],
@@ -106,6 +107,11 @@ const EVERY_ROUTE = {
106
107
  "DELETE /members/:member/bindings/:id": true,
107
108
  "GET /workloads/lookup": true,
108
109
  "GET /workloads/repositories": true,
110
+ "GET /roles": true,
111
+ "PUT /roles/:role": true,
112
+ "DELETE /roles/:role": true,
113
+ "PUT /instance-roles/:role": true,
114
+ "DELETE /instance-roles/:role": true,
109
115
  "GET /settings": true,
110
116
  "PUT /settings": true,
111
117
  "PATCH /access/:member": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/client",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "description": "The coffre API as typed function calls.",
5
5
  "license": "MIT",
6
6
  "repository": {