@oblax/workflows 0.0.0-stage → 2.1.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/blueprints.d.ts +33 -0
- package/dist/blueprints.d.ts.map +1 -0
- package/dist/blueprints.js +43 -0
- package/dist/blueprints.js.map +1 -0
- package/dist/buckets.d.ts +51 -0
- package/dist/buckets.d.ts.map +1 -0
- package/dist/buckets.js +62 -0
- package/dist/buckets.js.map +1 -0
- package/dist/flows.d.ts +49 -0
- package/dist/flows.d.ts.map +1 -0
- package/dist/flows.js +75 -0
- package/dist/flows.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/item-types.d.ts +37 -0
- package/dist/item-types.d.ts.map +1 -0
- package/dist/item-types.js +53 -0
- package/dist/item-types.js.map +1 -0
- package/dist/items.d.ts +84 -0
- package/dist/items.d.ts.map +1 -0
- package/dist/items.js +190 -0
- package/dist/items.js.map +1 -0
- package/dist/permissions.d.ts +52 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +100 -0
- package/dist/permissions.js.map +1 -0
- package/dist/terms.d.ts +34 -0
- package/dist/terms.d.ts.map +1 -0
- package/dist/terms.js +69 -0
- package/dist/terms.js.map +1 -0
- package/dist/types.d.ts +1036 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/views.d.ts +29 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +51 -0
- package/dist/views.js.map +1 -0
- package/dist/vocabularies.d.ts +31 -0
- package/dist/vocabularies.d.ts.map +1 -0
- package/dist/vocabularies.js +47 -0
- package/dist/vocabularies.js.map +1 -0
- package/dist/workflows-module.d.ts +46 -0
- package/dist/workflows-module.d.ts.map +1 -0
- package/dist/workflows-module.js +45 -0
- package/dist/workflows-module.js.map +1 -0
- package/dist/workspaces.d.ts +42 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +72 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +49 -3
- package/README.md +0 -3
package/dist/items.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { listPairs, buildQuery as query, pathSegment as seg } from '@oblax/core';
|
|
2
|
+
function inputToApi(p) {
|
|
3
|
+
return {
|
|
4
|
+
title: p.title,
|
|
5
|
+
body: p.body,
|
|
6
|
+
body_format: p.bodyFormat,
|
|
7
|
+
fields: p.fields,
|
|
8
|
+
terms: p.terms,
|
|
9
|
+
due_at: p.dueAt,
|
|
10
|
+
assignee_id: p.assigneeId,
|
|
11
|
+
parent_id: p.parentId,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createToApi(p) {
|
|
15
|
+
return {
|
|
16
|
+
...inputToApi(p),
|
|
17
|
+
workspace_id: p.workspaceId,
|
|
18
|
+
type: p.type,
|
|
19
|
+
type_id: p.typeId,
|
|
20
|
+
watcher_ids: p.watcherIds,
|
|
21
|
+
status: p.status,
|
|
22
|
+
status_id: p.statusId,
|
|
23
|
+
subject_type: p.subjectType,
|
|
24
|
+
subject_id: p.subjectId,
|
|
25
|
+
subject: p.subject,
|
|
26
|
+
dedupe_key: p.dedupeKey,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Manages items: create, edit, move through the flow, rank, watch, link,
|
|
31
|
+
* follow up, convert and retype. Routes take an item's id or its key
|
|
32
|
+
* (`CRM-42`). Saves send the `version` they loaded as `expect`; a stale one
|
|
33
|
+
* fails with 409.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const ticket = await oblax.workflows.items.create({
|
|
38
|
+
* workspaceId: 'workspace-id',
|
|
39
|
+
* type: 'ticket',
|
|
40
|
+
* title: 'Printer on fire',
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* await oblax.workflows.items.move({ id: ticket.key, to: 'open', expect: ticket.status })
|
|
44
|
+
*
|
|
45
|
+
* // My open items, newest first
|
|
46
|
+
* const { data } = await oblax.workflows.items.list({
|
|
47
|
+
* filters: [
|
|
48
|
+
* { field: 'assignee_id', op: 'eq', value: 'me' },
|
|
49
|
+
* { field: 'open', op: 'eq', value: true },
|
|
50
|
+
* ],
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export class ItemsSubmodule {
|
|
55
|
+
constructor(ctx) {
|
|
56
|
+
this.ctx = ctx;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Lists the items the caller sees. Filter on `workspace_id`, `type_id`,
|
|
60
|
+
* `status`, `category`, `open`, `assignee_id` (`me`, `none`), `watcher`,
|
|
61
|
+
* `parent_id`, `top`, `ancestor`, `due_at`, `fields.<path>` (with one
|
|
62
|
+
* `type_id`), `bucket` (a bucket's id: its current members), `bucket_none`
|
|
63
|
+
* (a bucket type's id: the backlog), ...; order by `_created` (default), `_modified`, `number`,
|
|
64
|
+
* `title`, `due_at`, `closed_at`, `rank` or `fields.<path>`.
|
|
65
|
+
*/
|
|
66
|
+
async list(params = {}) {
|
|
67
|
+
const qs = query({ include: params.includeMoves ? 'moves' : undefined }, listPairs(params));
|
|
68
|
+
return this.ctx.http.get(`/workflows/items${qs}`);
|
|
69
|
+
}
|
|
70
|
+
/** Returns an item, with its people, organizations and what the caller may do (`can`). */
|
|
71
|
+
async get(params) {
|
|
72
|
+
const qs = query({ include: params.include?.join(',') });
|
|
73
|
+
return this.ctx.http.get(`/workflows/items/${seg(params.id)}${qs}`);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Creates an item. A subject with an open item of the type, or a taken
|
|
77
|
+
* dedupe key, fails with 409; `ensure()` returns that item instead.
|
|
78
|
+
*/
|
|
79
|
+
async create(params) {
|
|
80
|
+
return this.ctx.http.post('/workflows/items', createToApi(params));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the item a subject has in a type, or makes one: the item with the
|
|
84
|
+
* same dedupe key, else the subject's open item (snapshot updated), else a
|
|
85
|
+
* follow-up of its last closed one, else a new item.
|
|
86
|
+
*/
|
|
87
|
+
async ensure(params) {
|
|
88
|
+
return this.ctx.http.post('/workflows/items:ensure', createToApi(params));
|
|
89
|
+
}
|
|
90
|
+
/** Changes the keys given and keeps the others; `null` clears one. */
|
|
91
|
+
async update(params) {
|
|
92
|
+
return this.ctx.http.put(`/workflows/items/${seg(params.id)}`, {
|
|
93
|
+
...inputToApi(params),
|
|
94
|
+
reporter_id: params.reporterId,
|
|
95
|
+
expect: params.expect,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** Deletes an item; with children it fails with 409 unless `cascade`. Its history stays. */
|
|
99
|
+
async delete(params) {
|
|
100
|
+
return this.ctx.http.delete(`/workflows/items/${seg(params.id)}${query({ cascade: params.cascade })}`);
|
|
101
|
+
}
|
|
102
|
+
/** Moves an item to another status of its flow. Comes back with the move's warnings. */
|
|
103
|
+
async move(params) {
|
|
104
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}:move`, {
|
|
105
|
+
to: params.to,
|
|
106
|
+
expect: params.expect,
|
|
107
|
+
note: params.note,
|
|
108
|
+
fields: params.fields,
|
|
109
|
+
assignee_id: params.assigneeId,
|
|
110
|
+
after_id: params.afterId,
|
|
111
|
+
duplicate_of: params.duplicateOf,
|
|
112
|
+
carry_to: params.carryTo,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** Places an item within its status, after another item (or at the top). */
|
|
116
|
+
async rank(params) {
|
|
117
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}:rank`, {
|
|
118
|
+
after_id: params.afterId,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** The item's history, oldest first, with the people it names. Filter on `kind`, `actor_id`, `_created`. */
|
|
122
|
+
async history(params) {
|
|
123
|
+
return this.ctx.http.get(`/workflows/items/${seg(params.id)}/history${query({}, listPairs(params))}`);
|
|
124
|
+
}
|
|
125
|
+
/** Adds a watcher: a person, or the caller. */
|
|
126
|
+
async watch(params) {
|
|
127
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}/watchers`, {
|
|
128
|
+
person_id: params.personId,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/** Removes a watcher: a person, or the caller. */
|
|
132
|
+
async unwatch(params) {
|
|
133
|
+
return this.ctx.http.delete(`/workflows/items/${seg(params.id)}/watchers${query({ person_id: params.personId })}`);
|
|
134
|
+
}
|
|
135
|
+
/** Makes a follow-up of a closed item: a new item of the same type. */
|
|
136
|
+
async followUp(params) {
|
|
137
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}:followup`, {
|
|
138
|
+
title: params.title,
|
|
139
|
+
body: params.body,
|
|
140
|
+
body_format: params.bodyFormat,
|
|
141
|
+
fields: params.fields,
|
|
142
|
+
terms: params.terms,
|
|
143
|
+
parent_id: params.parentId,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/** Converts an open item into a new item of another type; the original moves to done. */
|
|
147
|
+
async convert(params) {
|
|
148
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}:convert`, {
|
|
149
|
+
type: params.type,
|
|
150
|
+
title: params.title,
|
|
151
|
+
fields: params.fields,
|
|
152
|
+
terms: params.terms,
|
|
153
|
+
expect: params.expect,
|
|
154
|
+
note: params.note,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/** Changes an item's type in place; the new type must share its flow. */
|
|
158
|
+
async retype(params) {
|
|
159
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}:retype`, {
|
|
160
|
+
type: params.type,
|
|
161
|
+
expect: params.expect,
|
|
162
|
+
fields: params.fields,
|
|
163
|
+
terms: params.terms,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/** Sends the item's last status event again, for a lost flux run. Writes nothing. */
|
|
167
|
+
async resend(params) {
|
|
168
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}:resend`);
|
|
169
|
+
}
|
|
170
|
+
/** Lists the item's links, each with the item at its other end. */
|
|
171
|
+
async listLinks(params) {
|
|
172
|
+
return this.ctx.http.get(`/workflows/items/${seg(params.id)}/links`);
|
|
173
|
+
}
|
|
174
|
+
/** Adds a link, read from the item's side. The same link already there comes back unchanged. */
|
|
175
|
+
async link(params) {
|
|
176
|
+
return this.ctx.http.post(`/workflows/items/${seg(params.id)}/links`, {
|
|
177
|
+
kind: params.kind,
|
|
178
|
+
item_id: params.itemId,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/** Removes a link, read from the item's side. */
|
|
182
|
+
async unlink(params) {
|
|
183
|
+
return this.ctx.http.delete(`/workflows/items/${seg(params.id)}/links${query({ kind: params.kind, item_id: params.itemId })}`);
|
|
184
|
+
}
|
|
185
|
+
/** Returns a download link (15 minutes) to a file in one of the item's file fields. */
|
|
186
|
+
async getFileLink(params) {
|
|
187
|
+
return this.ctx.http.get(`/workflows/items/${seg(params.id)}/files/${seg(params.fileId)}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"items.js","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AA2BhF,SAAS,UAAU,CAAC,CAAY;IAC9B,OAAO;QACL,KAAK,EAAQ,CAAC,CAAC,KAAK;QACpB,IAAI,EAAS,CAAC,CAAC,IAAI;QACnB,WAAW,EAAE,CAAC,CAAC,UAAU;QACzB,MAAM,EAAO,CAAC,CAAC,MAAM;QACrB,KAAK,EAAQ,CAAC,CAAC,KAAK;QACpB,MAAM,EAAO,CAAC,CAAC,KAAK;QACpB,WAAW,EAAE,CAAC,CAAC,UAAU;QACz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reateProfileParams, Grant, Holders, HoldersParams, IdParams, ListGrantsParams, MyPermissions, Profile, UpdateGrantParams, UpdateProfileParams, WorkflowsList } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Who may do what: capability profiles, grants of them to people and roles
|
|
5
|
+
* (module-wide or on a workspace), and what the caller holds.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* await oblax.workflows.permissions.createGrant({
|
|
10
|
+
* subject: { kind: 'person', id: 'person-id' },
|
|
11
|
+
* container: { kind: 'workspace', id: 'workspace-id' },
|
|
12
|
+
* profile: 'member',
|
|
13
|
+
* })
|
|
14
|
+
*
|
|
15
|
+
* const me = await oblax.workflows.permissions.me({
|
|
16
|
+
* containerKind: 'workspace',
|
|
17
|
+
* containerId: 'workspace-id',
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class PermissionsSubmodule {
|
|
22
|
+
private readonly ctx;
|
|
23
|
+
constructor(ctx: OblaxContext);
|
|
24
|
+
/** The module's capabilities, container kinds and built-in profiles. */
|
|
25
|
+
capabilities(): Promise<CapabilityCatalog>;
|
|
26
|
+
/** Lists the profiles, built-in ones first. */
|
|
27
|
+
listProfiles(): Promise<WorkflowsList<Profile>>;
|
|
28
|
+
/** Returns a profile by code: a custom one, else the built-in one. */
|
|
29
|
+
getProfile(params: CodeParams): Promise<Profile>;
|
|
30
|
+
createProfile(params: CreateProfileParams): Promise<Profile>;
|
|
31
|
+
/** Replaces a custom profile's name, description and capabilities. */
|
|
32
|
+
updateProfile(params: UpdateProfileParams): Promise<Profile>;
|
|
33
|
+
/** Deletes a custom profile no grant uses. */
|
|
34
|
+
deleteProfile(params: CodeParams): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Lists grants. With `containerKind` and `containerId`, one container's
|
|
37
|
+
* grants; without, every grant (needs `access.manage`). Filter on
|
|
38
|
+
* `subject_kind`, `subject_id`, `profile`, `module_wide`.
|
|
39
|
+
*/
|
|
40
|
+
listGrants(params?: ListGrantsParams): Promise<WorkflowsList<Grant>>;
|
|
41
|
+
getGrant(params: IdParams): Promise<Grant>;
|
|
42
|
+
/** Gives a profile to a subject, module-wide or on a container. */
|
|
43
|
+
createGrant(params: CreateGrantParams): Promise<Grant>;
|
|
44
|
+
/** Changes a grant's profile. */
|
|
45
|
+
updateGrant(params: UpdateGrantParams): Promise<Grant>;
|
|
46
|
+
deleteGrant(params: IdParams): Promise<void>;
|
|
47
|
+
/** What the caller holds module-wide and, when given, on a container. Visitors may ask too. */
|
|
48
|
+
me(params?: ContainerParams): Promise<MyPermissions>;
|
|
49
|
+
/** Who holds a capability: the grants that give it, and the admin roles. */
|
|
50
|
+
holders(params: HoldersParams): Promise<Holders>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,wEAAwE;IAClE,YAAY,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAIhD,+CAA+C;IACzC,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAIrD,sEAAsE;IAChE,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhD,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IASlE,sEAAsE;IAChE,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlE,8CAA8C;IACxC,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD;;;;OAIG;IACG,UAAU,CAAC,MAAM,GAAE,gBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAQxE,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAIhD,mEAAmE;IAC7D,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ5D,iCAAiC;IAC3B,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;IAMtD,WAAW,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,+FAA+F;IACzF,EAAE,CAAC,MAAM,GAAE,eAAoB,GAAG,OAAO,CAAC,aAAa,CAAC;IAK9D,4EAA4E;IACtE,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAQvD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { listPairs, buildQuery as query, pathSegment as seg } from '@oblax/core';
|
|
2
|
+
/**
|
|
3
|
+
* Who may do what: capability profiles, grants of them to people and roles
|
|
4
|
+
* (module-wide or on a workspace), and what the caller holds.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* await oblax.workflows.permissions.createGrant({
|
|
9
|
+
* subject: { kind: 'person', id: 'person-id' },
|
|
10
|
+
* container: { kind: 'workspace', id: 'workspace-id' },
|
|
11
|
+
* profile: 'member',
|
|
12
|
+
* })
|
|
13
|
+
*
|
|
14
|
+
* const me = await oblax.workflows.permissions.me({
|
|
15
|
+
* containerKind: 'workspace',
|
|
16
|
+
* containerId: 'workspace-id',
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class PermissionsSubmodule {
|
|
21
|
+
constructor(ctx) {
|
|
22
|
+
this.ctx = ctx;
|
|
23
|
+
}
|
|
24
|
+
/** The module's capabilities, container kinds and built-in profiles. */
|
|
25
|
+
async capabilities() {
|
|
26
|
+
return this.ctx.http.get('/workflows/permissions/capabilities');
|
|
27
|
+
}
|
|
28
|
+
/** Lists the profiles, built-in ones first. */
|
|
29
|
+
async listProfiles() {
|
|
30
|
+
return this.ctx.http.get('/workflows/permissions/profiles');
|
|
31
|
+
}
|
|
32
|
+
/** Returns a profile by code: a custom one, else the built-in one. */
|
|
33
|
+
async getProfile(params) {
|
|
34
|
+
return this.ctx.http.get(`/workflows/permissions/profiles/${seg(params.code)}`);
|
|
35
|
+
}
|
|
36
|
+
async createProfile(params) {
|
|
37
|
+
return this.ctx.http.post('/workflows/permissions/profiles', {
|
|
38
|
+
code: params.code,
|
|
39
|
+
name: params.name,
|
|
40
|
+
description: params.description,
|
|
41
|
+
capabilities: params.capabilities,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Replaces a custom profile's name, description and capabilities. */
|
|
45
|
+
async updateProfile(params) {
|
|
46
|
+
return this.ctx.http.put(`/workflows/permissions/profiles/${seg(params.code)}`, {
|
|
47
|
+
name: params.name,
|
|
48
|
+
description: params.description,
|
|
49
|
+
capabilities: params.capabilities,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** Deletes a custom profile no grant uses. */
|
|
53
|
+
async deleteProfile(params) {
|
|
54
|
+
return this.ctx.http.delete(`/workflows/permissions/profiles/${seg(params.code)}`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Lists grants. With `containerKind` and `containerId`, one container's
|
|
58
|
+
* grants; without, every grant (needs `access.manage`). Filter on
|
|
59
|
+
* `subject_kind`, `subject_id`, `profile`, `module_wide`.
|
|
60
|
+
*/
|
|
61
|
+
async listGrants(params = {}) {
|
|
62
|
+
const qs = query({ container_kind: params.containerKind, container_id: params.containerId }, listPairs(params));
|
|
63
|
+
return this.ctx.http.get(`/workflows/permissions/grants${qs}`);
|
|
64
|
+
}
|
|
65
|
+
async getGrant(params) {
|
|
66
|
+
return this.ctx.http.get(`/workflows/permissions/grants/${seg(params.id)}`);
|
|
67
|
+
}
|
|
68
|
+
/** Gives a profile to a subject, module-wide or on a container. */
|
|
69
|
+
async createGrant(params) {
|
|
70
|
+
return this.ctx.http.post('/workflows/permissions/grants', {
|
|
71
|
+
subject: params.subject,
|
|
72
|
+
container: params.container,
|
|
73
|
+
profile: params.profile,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Changes a grant's profile. */
|
|
77
|
+
async updateGrant(params) {
|
|
78
|
+
return this.ctx.http.put(`/workflows/permissions/grants/${seg(params.id)}`, {
|
|
79
|
+
profile: params.profile,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async deleteGrant(params) {
|
|
83
|
+
return this.ctx.http.delete(`/workflows/permissions/grants/${seg(params.id)}`);
|
|
84
|
+
}
|
|
85
|
+
/** What the caller holds module-wide and, when given, on a container. Visitors may ask too. */
|
|
86
|
+
async me(params = {}) {
|
|
87
|
+
const qs = query({ container_kind: params.containerKind, container_id: params.containerId });
|
|
88
|
+
return this.ctx.http.get(`/workflows/permissions/me${qs}`);
|
|
89
|
+
}
|
|
90
|
+
/** Who holds a capability: the grants that give it, and the admin roles. */
|
|
91
|
+
async holders(params) {
|
|
92
|
+
const qs = query({
|
|
93
|
+
capability: params.capability,
|
|
94
|
+
container_kind: params.containerKind,
|
|
95
|
+
container_id: params.containerId,
|
|
96
|
+
});
|
|
97
|
+
return this.ctx.http.get(`/workflows/permissions/holders${qs}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# source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,CAAC,EAAE,CAAC,EAAE,EAAE;YACjF,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAgB;QAChC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAO,iCAAiC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACtF,CAAC;IAED,+FAA+F;IAC/F,KAAK,CAAC,EAAE,CAAC,SAA0B,EAAE;QACnC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;QAC5F,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAgB,4BAA4B,EAAE,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,4EAA4E;IAC5E,KAAK,CAAC,OAAO,CAAC,MAAqB;QACjC,MAAM,EAAE,GAAG,KAAK,CAAC;YACf,UAAU,EAAM,MAAM,CAAC,UAAU;YACjC,cAAc,EAAE,MAAM,CAAC,aAAa;YACpC,YAAY,EAAI,MAAM,CAAC,WAAW;SACnC,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAU,iCAAiC,EAAE,EAAE,CAAC,CAAA;IAC1E,CAAC;CACF"}
|
package/dist/terms.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { OblaxContext } from '@oblax/core';
|
|
2
|
+
import type { CreateTermParams, IdParams, ListTermsParams, MergeTermParams, MoveTermParams, Term, TermPage, UpdateTermParams } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Manages a vocabulary's terms. The vocabulary is found by code: the
|
|
5
|
+
* workspace's when `workspaceId` is given and it has one, else the
|
|
6
|
+
* module-wide one.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await oblax.workflows.terms.create({
|
|
11
|
+
* workspaceId: 'workspace-id',
|
|
12
|
+
* vocabulary: 'components',
|
|
13
|
+
* labels: { en: { name: 'Billing' } },
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class TermsSubmodule {
|
|
18
|
+
private readonly ctx;
|
|
19
|
+
constructor(ctx: OblaxContext);
|
|
20
|
+
/** Lists a page of the vocabulary's terms by id, aliases left out. */
|
|
21
|
+
list(params: ListTermsParams): Promise<TermPage>;
|
|
22
|
+
get(params: IdParams): Promise<Term>;
|
|
23
|
+
/** Adds a term, live at once; slugs are made from the names when left out. */
|
|
24
|
+
create(params: CreateTermParams): Promise<Term>;
|
|
25
|
+
/** Updates a term; labels and fields given replace the old ones whole. */
|
|
26
|
+
update(params: UpdateTermParams): Promise<Term>;
|
|
27
|
+
/** Deletes a term without children, and its aliases. */
|
|
28
|
+
delete(params: IdParams): Promise<void>;
|
|
29
|
+
/** Puts a term under another one (or at the root) at a position. */
|
|
30
|
+
move(params: MoveTermParams): Promise<Term>;
|
|
31
|
+
/** Makes a term an alias of another one in its vocabulary. */
|
|
32
|
+
merge(params: MergeTermParams): Promise<Term>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../src/terms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,IAAI,EACJ,QAAQ,EACR,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,sEAAsE;IAChE,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAahD,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,8EAA8E;IACxE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYrD,0EAA0E;IACpE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrD,wDAAwD;IAClD,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,oEAAoE;IAC9D,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjD,8DAA8D;IACxD,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpD"}
|
package/dist/terms.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { buildQuery as query, pathSegment as seg } from '@oblax/core';
|
|
2
|
+
/**
|
|
3
|
+
* Manages a vocabulary's terms. The vocabulary is found by code: the
|
|
4
|
+
* workspace's when `workspaceId` is given and it has one, else the
|
|
5
|
+
* module-wide one.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* await oblax.workflows.terms.create({
|
|
10
|
+
* workspaceId: 'workspace-id',
|
|
11
|
+
* vocabulary: 'components',
|
|
12
|
+
* labels: { en: { name: 'Billing' } },
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class TermsSubmodule {
|
|
17
|
+
constructor(ctx) {
|
|
18
|
+
this.ctx = ctx;
|
|
19
|
+
}
|
|
20
|
+
/** Lists a page of the vocabulary's terms by id, aliases left out. */
|
|
21
|
+
async list(params) {
|
|
22
|
+
const qs = query({
|
|
23
|
+
workspace_id: params.workspaceId,
|
|
24
|
+
q: params.q,
|
|
25
|
+
locale: params.locale,
|
|
26
|
+
parent: params.parent,
|
|
27
|
+
unused: params.unused,
|
|
28
|
+
limit: params.limit,
|
|
29
|
+
after: params.after,
|
|
30
|
+
});
|
|
31
|
+
return this.ctx.http.get(`/workflows/vocabularies/${seg(params.vocabulary)}/terms${qs}`);
|
|
32
|
+
}
|
|
33
|
+
async get(params) {
|
|
34
|
+
return this.ctx.http.get(`/workflows/terms/${seg(params.id)}`);
|
|
35
|
+
}
|
|
36
|
+
/** Adds a term, live at once; slugs are made from the names when left out. */
|
|
37
|
+
async create(params) {
|
|
38
|
+
return this.ctx.http.post(`/workflows/vocabularies/${seg(params.vocabulary)}/terms${query({ workspace_id: params.workspaceId })}`, {
|
|
39
|
+
labels: params.labels,
|
|
40
|
+
parent_id: params.parentId,
|
|
41
|
+
position: params.position,
|
|
42
|
+
fields: params.fields,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Updates a term; labels and fields given replace the old ones whole. */
|
|
46
|
+
async update(params) {
|
|
47
|
+
return this.ctx.http.put(`/workflows/terms/${seg(params.id)}`, {
|
|
48
|
+
labels: params.labels,
|
|
49
|
+
position: params.position,
|
|
50
|
+
fields: params.fields,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** Deletes a term without children, and its aliases. */
|
|
54
|
+
async delete(params) {
|
|
55
|
+
return this.ctx.http.delete(`/workflows/terms/${seg(params.id)}`);
|
|
56
|
+
}
|
|
57
|
+
/** Puts a term under another one (or at the root) at a position. */
|
|
58
|
+
async move(params) {
|
|
59
|
+
return this.ctx.http.post(`/workflows/terms/${seg(params.id)}:move`, {
|
|
60
|
+
parent_id: params.parentId ?? '',
|
|
61
|
+
position: params.position,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Makes a term an alias of another one in its vocabulary. */
|
|
65
|
+
async merge(params) {
|
|
66
|
+
return this.ctx.http.post(`/workflows/terms/${seg(params.id)}:merge`, { into: params.into });
|
|
67
|
+
}
|
|
68
|
+
}
|
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