@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.
Files changed (54) hide show
  1. package/dist/blueprints.d.ts +33 -0
  2. package/dist/blueprints.d.ts.map +1 -0
  3. package/dist/blueprints.js +43 -0
  4. package/dist/blueprints.js.map +1 -0
  5. package/dist/buckets.d.ts +51 -0
  6. package/dist/buckets.d.ts.map +1 -0
  7. package/dist/buckets.js +62 -0
  8. package/dist/buckets.js.map +1 -0
  9. package/dist/flows.d.ts +49 -0
  10. package/dist/flows.d.ts.map +1 -0
  11. package/dist/flows.js +75 -0
  12. package/dist/flows.js.map +1 -0
  13. package/dist/index.d.ts +40 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +44 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/item-types.d.ts +37 -0
  18. package/dist/item-types.d.ts.map +1 -0
  19. package/dist/item-types.js +53 -0
  20. package/dist/item-types.js.map +1 -0
  21. package/dist/items.d.ts +84 -0
  22. package/dist/items.d.ts.map +1 -0
  23. package/dist/items.js +190 -0
  24. package/dist/items.js.map +1 -0
  25. package/dist/permissions.d.ts +52 -0
  26. package/dist/permissions.d.ts.map +1 -0
  27. package/dist/permissions.js +100 -0
  28. package/dist/permissions.js.map +1 -0
  29. package/dist/terms.d.ts +34 -0
  30. package/dist/terms.d.ts.map +1 -0
  31. package/dist/terms.js +69 -0
  32. package/dist/terms.js.map +1 -0
  33. package/dist/types.d.ts +1036 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/dist/types.js +2 -0
  36. package/dist/types.js.map +1 -0
  37. package/dist/views.d.ts +29 -0
  38. package/dist/views.d.ts.map +1 -0
  39. package/dist/views.js +51 -0
  40. package/dist/views.js.map +1 -0
  41. package/dist/vocabularies.d.ts +31 -0
  42. package/dist/vocabularies.d.ts.map +1 -0
  43. package/dist/vocabularies.js +47 -0
  44. package/dist/vocabularies.js.map +1 -0
  45. package/dist/workflows-module.d.ts +46 -0
  46. package/dist/workflows-module.d.ts.map +1 -0
  47. package/dist/workflows-module.js +45 -0
  48. package/dist/workflows-module.js.map +1 -0
  49. package/dist/workspaces.d.ts +42 -0
  50. package/dist/workspaces.d.ts.map +1 -0
  51. package/dist/workspaces.js +72 -0
  52. package/dist/workspaces.js.map +1 -0
  53. package/package.json +49 -3
  54. package/README.md +0 -3
@@ -0,0 +1,33 @@
1
+ import type { OblaxContext } from '@oblax/core';
2
+ import type { ApplyBlueprintParams, Blueprint, BlueprintNameParams, Workspace, WorkflowsList } from './types.js';
3
+ /**
4
+ * Ready-made workspace setups (e.g. a CRM): read a shipped blueprint, change
5
+ * it if you like, and apply it as a new workspace. Needs `workspaces.create`.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // As shipped
10
+ * await oblax.workflows.blueprints.apply({ blueprint: 'crm', code: 'CRM', name: 'Sales' })
11
+ *
12
+ * // Customised
13
+ * const crm = await oblax.workflows.blueprints.get({ name: 'crm' })
14
+ * await oblax.workflows.blueprints.apply({
15
+ * blueprint: { ...crm, views: [] },
16
+ * code: 'CRM2',
17
+ * name: 'Sales (lite)',
18
+ * })
19
+ * ```
20
+ */
21
+ export declare class BlueprintsSubmodule {
22
+ private readonly ctx;
23
+ constructor(ctx: OblaxContext);
24
+ /** Lists the shipped blueprints, whole. */
25
+ list(): Promise<WorkflowsList<Blueprint>>;
26
+ get(params: BlueprintNameParams): Promise<Blueprint>;
27
+ /**
28
+ * Creates a workspace from a blueprint, with everything in it, in one
29
+ * transaction. The caller gets admin on it.
30
+ */
31
+ apply(params: ApplyBlueprintParams): Promise<Workspace>;
32
+ }
33
+ //# sourceMappingURL=blueprints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blueprints.d.ts","sourceRoot":"","sources":["../src/blueprints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,2CAA2C;IACrC,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAIzC,GAAG,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IAI1D;;;OAGG;IACG,KAAK,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC;CAO9D"}
@@ -0,0 +1,43 @@
1
+ import { pathSegment as seg } from '@oblax/core';
2
+ /**
3
+ * Ready-made workspace setups (e.g. a CRM): read a shipped blueprint, change
4
+ * it if you like, and apply it as a new workspace. Needs `workspaces.create`.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // As shipped
9
+ * await oblax.workflows.blueprints.apply({ blueprint: 'crm', code: 'CRM', name: 'Sales' })
10
+ *
11
+ * // Customised
12
+ * const crm = await oblax.workflows.blueprints.get({ name: 'crm' })
13
+ * await oblax.workflows.blueprints.apply({
14
+ * blueprint: { ...crm, views: [] },
15
+ * code: 'CRM2',
16
+ * name: 'Sales (lite)',
17
+ * })
18
+ * ```
19
+ */
20
+ export class BlueprintsSubmodule {
21
+ constructor(ctx) {
22
+ this.ctx = ctx;
23
+ }
24
+ /** Lists the shipped blueprints, whole. */
25
+ async list() {
26
+ return this.ctx.http.get('/workflows/blueprints');
27
+ }
28
+ async get(params) {
29
+ return this.ctx.http.get(`/workflows/blueprints/${seg(params.name)}`);
30
+ }
31
+ /**
32
+ * Creates a workspace from a blueprint, with everything in it, in one
33
+ * transaction. The caller gets admin on it.
34
+ */
35
+ async apply(params) {
36
+ return this.ctx.http.post('/workflows/blueprints:apply', {
37
+ blueprint: params.blueprint,
38
+ code: params.code,
39
+ name: params.name,
40
+ });
41
+ }
42
+ }
43
+ //# sourceMappingURL=blueprints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blueprints.js","sourceRoot":"","sources":["../src/blueprints.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAShD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,mBAAmB;IAC9B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,2CAA2C;IAC3C,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAA2B,uBAAuB,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAA2B;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAY,yBAAyB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAClF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,MAA4B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAY,6BAA6B,EAAE;YAClE,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,IAAI,EAAO,MAAM,CAAC,IAAI;YACtB,IAAI,EAAO,MAAM,CAAC,IAAI;SACvB,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,51 @@
1
+ import type { OblaxContext } from '@oblax/core';
2
+ import type { AddBucketMemberParams, BucketJoin, BucketMember, ListBucketMembersParams, ListItemBucketsParams, RemoveBucketMemberParams, WorkflowsList } from './types.js';
3
+ /**
4
+ * Manages bucket membership. A bucket (a sprint, a release) is an item of a
5
+ * bucket type: create, start and close it through `items`, and put items in
6
+ * and out of it here. An item is in one bucket of each bucket type at most.
7
+ * Routes take a bucket's or an item's id or key.
8
+ *
9
+ * Starting a bucket is a move into an `active` status; closing it is a move
10
+ * into `done` or `cancelled`, where `carryTo` picks where open members go.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * await oblax.workflows.buckets.add({ id: 'DEV-140', itemId: 'DEV-151' })
15
+ *
16
+ * // Move it on to the next sprint
17
+ * await oblax.workflows.buckets.add({ id: 'DEV-160', itemId: 'DEV-151', from: 'DEV-140' })
18
+ *
19
+ * // What's in the sprint now
20
+ * const { data } = await oblax.workflows.buckets.members({
21
+ * id: 'DEV-160',
22
+ * filters: [{ field: 'current', op: 'eq', value: true }],
23
+ * })
24
+ * ```
25
+ */
26
+ export declare class BucketsSubmodule {
27
+ private readonly ctx;
28
+ constructor(ctx: OblaxContext);
29
+ /**
30
+ * Lists a bucket's rows, current and ended, oldest first, each with its
31
+ * member (`item`). Filter on `current`, `outcome`, `item_id`; order by
32
+ * `joined_at` or `left_at`. Members the caller can't see are left out.
33
+ */
34
+ members(params: ListBucketMembersParams): Promise<WorkflowsList<BucketMember>>;
35
+ /**
36
+ * Adds an item to a bucket, or moves it there from the bucket `from` names.
37
+ * An item already in the bucket comes back as it is. A join past the
38
+ * measure's `warn` limit comes back with a warning; past a `refuse` limit
39
+ * it fails with 409.
40
+ */
41
+ add(params: AddBucketMemberParams): Promise<BucketJoin>;
42
+ /** Takes an item out of a bucket; its row ends as `removed`. */
43
+ remove(params: RemoveBucketMemberParams): Promise<void>;
44
+ /**
45
+ * Lists every row an item has had, newest first, each with its `bucket`.
46
+ * Filter on `current`, `outcome`, `bucket_type_id`; order by `joined_at`
47
+ * or `left_at`.
48
+ */
49
+ ofItem(params: ListItemBucketsParams): Promise<WorkflowsList<BucketMember>>;
50
+ }
51
+ //# sourceMappingURL=buckets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buckets.d.ts","sourceRoot":"","sources":["../src/buckets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAMpF;;;;;OAKG;IACG,GAAG,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC;IAO7D,gEAAgE;IAC1D,MAAM,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7D;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;CAKlF"}
@@ -0,0 +1,62 @@
1
+ import { listPairs, buildQuery as query, pathSegment as seg } from '@oblax/core';
2
+ /**
3
+ * Manages bucket membership. A bucket (a sprint, a release) is an item of a
4
+ * bucket type: create, start and close it through `items`, and put items in
5
+ * and out of it here. An item is in one bucket of each bucket type at most.
6
+ * Routes take a bucket's or an item's id or key.
7
+ *
8
+ * Starting a bucket is a move into an `active` status; closing it is a move
9
+ * into `done` or `cancelled`, where `carryTo` picks where open members go.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * await oblax.workflows.buckets.add({ id: 'DEV-140', itemId: 'DEV-151' })
14
+ *
15
+ * // Move it on to the next sprint
16
+ * await oblax.workflows.buckets.add({ id: 'DEV-160', itemId: 'DEV-151', from: 'DEV-140' })
17
+ *
18
+ * // What's in the sprint now
19
+ * const { data } = await oblax.workflows.buckets.members({
20
+ * id: 'DEV-160',
21
+ * filters: [{ field: 'current', op: 'eq', value: true }],
22
+ * })
23
+ * ```
24
+ */
25
+ export class BucketsSubmodule {
26
+ constructor(ctx) {
27
+ this.ctx = ctx;
28
+ }
29
+ /**
30
+ * Lists a bucket's rows, current and ended, oldest first, each with its
31
+ * member (`item`). Filter on `current`, `outcome`, `item_id`; order by
32
+ * `joined_at` or `left_at`. Members the caller can't see are left out.
33
+ */
34
+ async members(params) {
35
+ return this.ctx.http.get(`/workflows/buckets/${seg(params.id)}/members${query({}, listPairs(params))}`);
36
+ }
37
+ /**
38
+ * Adds an item to a bucket, or moves it there from the bucket `from` names.
39
+ * An item already in the bucket comes back as it is. A join past the
40
+ * measure's `warn` limit comes back with a warning; past a `refuse` limit
41
+ * it fails with 409.
42
+ */
43
+ async add(params) {
44
+ return this.ctx.http.post(`/workflows/buckets/${seg(params.id)}/members`, {
45
+ item_id: params.itemId,
46
+ from: params.from,
47
+ });
48
+ }
49
+ /** Takes an item out of a bucket; its row ends as `removed`. */
50
+ async remove(params) {
51
+ return this.ctx.http.delete(`/workflows/buckets/${seg(params.id)}/members${query({ item_id: params.itemId })}`);
52
+ }
53
+ /**
54
+ * Lists every row an item has had, newest first, each with its `bucket`.
55
+ * Filter on `current`, `outcome`, `bucket_type_id`; order by `joined_at`
56
+ * or `left_at`.
57
+ */
58
+ async ofItem(params) {
59
+ return this.ctx.http.get(`/workflows/items/${seg(params.id)}/buckets${query({}, listPairs(params))}`);
60
+ }
61
+ }
62
+ //# sourceMappingURL=buckets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buckets.js","sourceRoot":"","sources":["../src/buckets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAWhF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,MAA+B;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CACtB,sBAAsB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAC9E,CAAA;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,MAA6B;QACrC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAa,sBAAsB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE;YACpF,OAAO,EAAE,MAAM,CAAC,MAAM;YACtB,IAAI,EAAK,MAAM,CAAC,IAAI;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,gEAAgE;IAChE,KAAK,CAAC,MAAM,CAAC,MAAgC;QAC3C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CACzB,sBAAsB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CACnF,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,MAA6B;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CACtB,oBAAoB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,WAAW,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAC5E,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,49 @@
1
+ import type { OblaxContext } from '@oblax/core';
2
+ import type { CopyFlowParams, CreateFlowParams, Flow, FlowVersion, FlowVersionParams, IdParams, ListFlowVersionsParams, UpdateFlowParams, WorkflowsList, WorkspaceScopedParams } from './types.js';
3
+ /**
4
+ * Manages flows: a workspace's statuses and the moves between them. The flow
5
+ * document (statuses, transitions, status fields) uses the API's snake_case
6
+ * names, so a flow read from the API can be edited and saved back.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const flow = await oblax.workflows.flows.create({
11
+ * workspaceId: 'workspace-id',
12
+ * code: 'support',
13
+ * name: 'Support',
14
+ * statuses: [
15
+ * { code: 'new', name: 'New', category: 'triage' },
16
+ * { code: 'open', name: 'Open', category: 'active' },
17
+ * { code: 'closed', name: 'Closed', category: 'done' },
18
+ * ],
19
+ * })
20
+ *
21
+ * const { id, version, ...doc } = flow
22
+ * await oblax.workflows.flows.update({
23
+ * ...doc,
24
+ * id,
25
+ * expect: version,
26
+ * statuses: [...doc.statuses, { code: 'waiting', name: 'Waiting', category: 'active' }],
27
+ * })
28
+ * ```
29
+ */
30
+ export declare class FlowsSubmodule {
31
+ private readonly ctx;
32
+ constructor(ctx: OblaxContext);
33
+ /** Lists a workspace's flows, each with its statuses sorted. */
34
+ list(params: WorkspaceScopedParams): Promise<WorkflowsList<Flow>>;
35
+ get(params: IdParams): Promise<Flow>;
36
+ /** Creates a flow. Needs `workspace.manage`. */
37
+ create(params: CreateFlowParams): Promise<Flow>;
38
+ /** Replaces the flow whole (send the full document) and keeps a version. A stale `expect` fails with 409. */
39
+ update(params: UpdateFlowParams): Promise<Flow>;
40
+ /** Deletes a flow no item type uses; its versions stay. */
41
+ delete(params: IdParams): Promise<void>;
42
+ /** Copies a flow (into another workspace too) with new ids and no grants. */
43
+ copy(params: CopyFlowParams): Promise<Flow>;
44
+ /** Lists the flow's saves, newest first, without their content. */
45
+ listVersions(params: ListFlowVersionsParams): Promise<WorkflowsList<FlowVersion>>;
46
+ /** Returns one save of the flow, with its content. */
47
+ getVersion(params: FlowVersionParams): Promise<FlowVersion>;
48
+ }
49
+ //# sourceMappingURL=flows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../src/flows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,IAAI,EACJ,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,gEAAgE;IAC1D,IAAI,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAMjE,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,gDAAgD;IAC1C,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrD,6GAA6G;IACvG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IASrD,2DAA2D;IACrD,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,6EAA6E;IACvE,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjD,mEAAmE;IAC7D,YAAY,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAMvF,sDAAsD;IAChD,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;CAKlE"}
package/dist/flows.js ADDED
@@ -0,0 +1,75 @@
1
+ import { buildQuery as query, pathSegment as seg } from '@oblax/core';
2
+ /**
3
+ * Manages flows: a workspace's statuses and the moves between them. The flow
4
+ * document (statuses, transitions, status fields) uses the API's snake_case
5
+ * names, so a flow read from the API can be edited and saved back.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const flow = await oblax.workflows.flows.create({
10
+ * workspaceId: 'workspace-id',
11
+ * code: 'support',
12
+ * name: 'Support',
13
+ * statuses: [
14
+ * { code: 'new', name: 'New', category: 'triage' },
15
+ * { code: 'open', name: 'Open', category: 'active' },
16
+ * { code: 'closed', name: 'Closed', category: 'done' },
17
+ * ],
18
+ * })
19
+ *
20
+ * const { id, version, ...doc } = flow
21
+ * await oblax.workflows.flows.update({
22
+ * ...doc,
23
+ * id,
24
+ * expect: version,
25
+ * statuses: [...doc.statuses, { code: 'waiting', name: 'Waiting', category: 'active' }],
26
+ * })
27
+ * ```
28
+ */
29
+ export class FlowsSubmodule {
30
+ constructor(ctx) {
31
+ this.ctx = ctx;
32
+ }
33
+ /** Lists a workspace's flows, each with its statuses sorted. */
34
+ async list(params) {
35
+ return this.ctx.http.get(`/workflows/flows${query({ workspace_id: params.workspaceId })}`);
36
+ }
37
+ async get(params) {
38
+ return this.ctx.http.get(`/workflows/flows/${seg(params.id)}`);
39
+ }
40
+ /** Creates a flow. Needs `workspace.manage`. */
41
+ async create(params) {
42
+ const { workspaceId, ...doc } = params;
43
+ return this.ctx.http.post('/workflows/flows', { ...doc, workspace_id: workspaceId });
44
+ }
45
+ /** Replaces the flow whole (send the full document) and keeps a version. A stale `expect` fails with 409. */
46
+ async update(params) {
47
+ const { id, expect, statusMap, ...doc } = params;
48
+ return this.ctx.http.put(`/workflows/flows/${seg(id)}`, {
49
+ ...doc,
50
+ expect,
51
+ status_map: statusMap,
52
+ });
53
+ }
54
+ /** Deletes a flow no item type uses; its versions stay. */
55
+ async delete(params) {
56
+ return this.ctx.http.delete(`/workflows/flows/${seg(params.id)}`);
57
+ }
58
+ /** Copies a flow (into another workspace too) with new ids and no grants. */
59
+ async copy(params) {
60
+ return this.ctx.http.post(`/workflows/flows/${seg(params.id)}:copy`, {
61
+ workspace_id: params.workspaceId,
62
+ code: params.code,
63
+ name: params.name,
64
+ });
65
+ }
66
+ /** Lists the flow's saves, newest first, without their content. */
67
+ async listVersions(params) {
68
+ return this.ctx.http.get(`/workflows/flows/${seg(params.id)}/versions${query({ limit: params.limit })}`);
69
+ }
70
+ /** Returns one save of the flow, with its content. */
71
+ async getVersion(params) {
72
+ return this.ctx.http.get(`/workflows/flows/${seg(params.id)}/versions/${params.version}`);
73
+ }
74
+ }
75
+ //# sourceMappingURL=flows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flows.js","sourceRoot":"","sources":["../src/flows.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAcrE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,cAAc;IACzB,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,gEAAgE;IAChE,KAAK,CAAC,IAAI,CAAC,MAA6B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CACtB,mBAAmB,KAAK,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CACjE,CAAA;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAgB;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAO,oBAAoB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACtE,CAAC;IAED,gDAAgD;IAChD,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,CAAA;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAO,kBAAkB,EAAE,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAA;IAC5F,CAAC;IAED,6GAA6G;IAC7G,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,CA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ows-module.js';
3
+ import type { WorkflowsConfig } from './types.js';
4
+ export { WorkflowsModule } from './workflows-module.js';
5
+ export { WorkspacesSubmodule } from './workspaces.js';
6
+ export { PermissionsSubmodule } from './permissions.js';
7
+ export { FlowsSubmodule } from './flows.js';
8
+ export { ItemTypesSubmodule } from './item-types.js';
9
+ export { ItemsSubmodule } from './items.js';
10
+ export { BucketsSubmodule } from './buckets.js';
11
+ export { ViewsSubmodule } from './views.js';
12
+ export { VocabulariesSubmodule } from './vocabularies.js';
13
+ export { TermsSubmodule } from './terms.js';
14
+ export { BlueprintsSubmodule } from './blueprints.js';
15
+ export type { WorkflowsConfig, WorkflowsRecord, WorkflowsList, JsonObject, Localized, FilterOp, ListFilter, ListQuery, Warning, FieldRule, Category, Scope, CapabilitySet, FieldsRequirement, IdParams, CodeParams, FileLink, Person, Organization, Workspace, CreateWorkspaceParams, UpdateWorkspaceParams, ListWorkspacesParams, WorkspacePeopleParams, PeoplePage, Capability, Profile, CapabilityCatalog, CreateProfileParams, UpdateProfileParams, GrantSubjectKind, Grant, ListGrantsParams, CreateGrantParams, UpdateGrantParams, ContainerParams, MyPermissions, HoldersParams, Holders, StatusEntry, Status, Transition, FlowDocument, Flow, CreateFlowParams, UpdateFlowParams, CopyFlowParams, FlowVersion, ListFlowVersionsParams, FlowVersionParams, WorkspaceScopedParams, VocabularyUsage, ItemTypeDocument, ItemType, CreateItemTypeParams, UpdateItemTypeParams, BucketMembershipRule, BucketMeasureRule, BucketSection, SlaState, ItemFile, MoveOption, ItemSummary, SubtreeCounts, Item, ListItemsParams, GetItemParams, ItemInput, CreateItemParams, EnsureItemParams, UpdateItemParams, DeleteItemParams, MoveItemParams, RankItemParams, ItemHistoryParams, HistoryKind, HistoryEntry, HistoryPage, WatchParams, FollowUpParams, ConvertItemParams, RetypeItemParams, Resent, LinkKind, ItemLink, LinkParams, ItemFileParams, BucketSummary, BucketStats, BucketOutcome, BucketMember, BucketJoin, ListBucketMembersParams, ListItemBucketsParams, AddBucketMemberParams, RemoveBucketMemberParams, BoardParams, BoardColumn, Board, ViewFilter, View, CreateViewParams, UpdateViewParams, VocabularySettings, Vocabulary, VocabularyScope, ListVocabulariesParams, VocabularyCodeParams, CreateVocabularyParams, UpdateVocabularyParams, TermLabel, Term, TermPage, ListTermsParams, CreateTermParams, UpdateTermParams, MoveTermParams, MergeTermParams, Blueprint, BlueprintNameParams, ApplyBlueprintParams, } from './types.js';
16
+ /**
17
+ * Workflows module factory.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { Oblax } from '@oblax/core'
22
+ * import { PlatformBrowser } from '@oblax/platform-browser'
23
+ * import { Workflows } from '@oblax/workflows'
24
+ *
25
+ * const oblax = new Oblax({
26
+ * endpoint: 'https://api.my-app.oblax.io',
27
+ * clientId: 'my-web-app',
28
+ * modules: [PlatformBrowser(), Workflows()],
29
+ * })
30
+ *
31
+ * const item = await oblax.workflows.items.create({
32
+ * workspaceId: 'workspace-id',
33
+ * type: 'ticket',
34
+ * title: 'Printer on fire',
35
+ * })
36
+ * await oblax.workflows.items.move({ id: item.key, to: 'open', expect: item.status })
37
+ * ```
38
+ */
39
+ export declare function Workflows(config?: WorkflowsConfig): OblaxModulePlugin<'workflows', WorkflowsModule>;
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,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gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,WAAW,EACX,KAAK,EACL,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,SAAS,EACT,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAE,eAAoB,GAAG,iBAAiB,CAAC,WAAW,EAAE,eAAe,CAAC,CAOvG"}
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ import { WorkflowsModule } from './workflows-module.js';
2
+ export { WorkflowsModule } from './workflows-module.js';
3
+ export { WorkspacesSubmodule } from './workspaces.js';
4
+ export { PermissionsSubmodule } from './permissions.js';
5
+ export { FlowsSubmodule } from './flows.js';
6
+ export { ItemTypesSubmodule } from './item-types.js';
7
+ export { ItemsSubmodule } from './items.js';
8
+ export { BucketsSubmodule } from './buckets.js';
9
+ export { ViewsSubmodule } from './views.js';
10
+ export { VocabulariesSubmodule } from './vocabularies.js';
11
+ export { TermsSubmodule } from './terms.js';
12
+ export { BlueprintsSubmodule } from './blueprints.js';
13
+ /**
14
+ * Workflows module factory.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { Oblax } from '@oblax/core'
19
+ * import { PlatformBrowser } from '@oblax/platform-browser'
20
+ * import { Workflows } from '@oblax/workflows'
21
+ *
22
+ * const oblax = new Oblax({
23
+ * endpoint: 'https://api.my-app.oblax.io',
24
+ * clientId: 'my-web-app',
25
+ * modules: [PlatformBrowser(), Workflows()],
26
+ * })
27
+ *
28
+ * const item = await oblax.workflows.items.create({
29
+ * workspaceId: 'workspace-id',
30
+ * type: 'ticket',
31
+ * title: 'Printer on fire',
32
+ * })
33
+ * await oblax.workflows.items.move({ id: item.key, to: 'open', expect: item.status })
34
+ * ```
35
+ */
36
+ export function Workflows(config = {}) {
37
+ return {
38
+ name: 'workflows',
39
+ create(ctx) {
40
+ return new WorkflowsModule(ctx, config);
41
+ },
42
+ };
43
+ }
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AA8HrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,SAAS,CAAC,SAA0B,EAAE;IACpD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,MAAM,CAAC,GAAiB;YACtB,OAAO,IAAI,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACzC,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { OblaxContext } from '@oblax/core';
2
+ import type { CreateItemTypeParams, IdParams, ItemType, UpdateItemTypeParams, WorkflowsList, WorkspaceScopedParams } from './types.js';
3
+ /**
4
+ * Manages item types (tickets, leads, tasks...): their flow, custom fields,
5
+ * children, conversions and SLAs. The type document uses the API's
6
+ * snake_case names, so a type read from the API can be edited and saved back.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * await oblax.workflows.types.create({
11
+ * workspaceId: 'workspace-id',
12
+ * code: 'ticket',
13
+ * name: 'Ticket',
14
+ * flow_id: 'flow-id',
15
+ * visible_to: 'everyone',
16
+ * fields: [{ path: 'priority', type: 'string', rules: 'oneof=low high' }],
17
+ * sla: { first_response: '4h' },
18
+ * })
19
+ * ```
20
+ */
21
+ export declare class ItemTypesSubmodule {
22
+ private readonly ctx;
23
+ constructor(ctx: OblaxContext);
24
+ /** Lists a workspace's item types; team-only types only for its team. */
25
+ list(params: WorkspaceScopedParams): Promise<WorkflowsList<ItemType>>;
26
+ get(params: IdParams): Promise<ItemType>;
27
+ /** Creates an item type. Needs `workspace.manage`. */
28
+ create(params: CreateItemTypeParams): Promise<ItemType>;
29
+ /**
30
+ * Replaces the type whole. Pointing it at another flow takes `statusMap`;
31
+ * a background job then moves the items.
32
+ */
33
+ update(params: UpdateItemTypeParams): Promise<ItemType>;
34
+ /** Deletes a type no other type names and no item uses. */
35
+ delete(params: IdParams): Promise<void>;
36
+ }
37
+ //# sourceMappingURL=item-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-types.d.ts","sourceRoot":"","sources":["../src/item-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,oBAAoB,EACpB,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,YAAY;IAE9C,yEAAyE;IACnE,IAAI,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAMrE,GAAG,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI9C,sDAAsD;IAChD,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAK7D;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAS7D,2DAA2D;IACrD,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
@@ -0,0 +1,53 @@
1
+ import { buildQuery as query, pathSegment as seg } from '@oblax/core';
2
+ /**
3
+ * Manages item types (tickets, leads, tasks...): their flow, custom fields,
4
+ * children, conversions and SLAs. The type document uses the API's
5
+ * snake_case names, so a type read from the API can be edited and saved back.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * await oblax.workflows.types.create({
10
+ * workspaceId: 'workspace-id',
11
+ * code: 'ticket',
12
+ * name: 'Ticket',
13
+ * flow_id: 'flow-id',
14
+ * visible_to: 'everyone',
15
+ * fields: [{ path: 'priority', type: 'string', rules: 'oneof=low high' }],
16
+ * sla: { first_response: '4h' },
17
+ * })
18
+ * ```
19
+ */
20
+ export class ItemTypesSubmodule {
21
+ constructor(ctx) {
22
+ this.ctx = ctx;
23
+ }
24
+ /** Lists a workspace's item types; team-only types only for its team. */
25
+ async list(params) {
26
+ return this.ctx.http.get(`/workflows/types${query({ workspace_id: params.workspaceId })}`);
27
+ }
28
+ async get(params) {
29
+ return this.ctx.http.get(`/workflows/types/${seg(params.id)}`);
30
+ }
31
+ /** Creates an item type. Needs `workspace.manage`. */
32
+ async create(params) {
33
+ const { workspaceId, ...doc } = params;
34
+ return this.ctx.http.post('/workflows/types', { ...doc, workspace_id: workspaceId });
35
+ }
36
+ /**
37
+ * Replaces the type whole. Pointing it at another flow takes `statusMap`;
38
+ * a background job then moves the items.
39
+ */
40
+ async update(params) {
41
+ const { id, expect, statusMap, ...doc } = params;
42
+ return this.ctx.http.put(`/workflows/types/${seg(id)}`, {
43
+ ...doc,
44
+ expect,
45
+ status_map: statusMap,
46
+ });
47
+ }
48
+ /** Deletes a type no other type names and no item uses. */
49
+ async delete(params) {
50
+ return this.ctx.http.delete(`/workflows/types/${seg(params.id)}`);
51
+ }
52
+ }
53
+ //# sourceMappingURL=item-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-types.js","sourceRoot":"","sources":["../src/item-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,aAAa,CAAA;AAUrE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,kBAAkB;IAC7B,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,yEAAyE;IACzE,KAAK,CAAC,IAAI,CAAC,MAA6B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CACtB,mBAAmB,KAAK,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CACjE,CAAA;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAgB;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAW,oBAAoB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IAC1E,CAAC;IAED,sDAAsD;IACtD,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,CAAA;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAW,kBAAkB,EAAE,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAA;IAChG,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,MAA4B;QACvC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,CAAA;QAChD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAW,oBAAoB,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAChE,GAAG,GAAG;YACN,MAAM;YACN,UAAU,EAAE,SAAS;SACtB,CAAC,CAAA;IACJ,CAAC;IAED,2DAA2D;IAC3D,KAAK,CAAC,MAAM,CAAC,MAAgB;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAO,oBAAoB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;CACF"}
@@ -0,0 +1,84 @@
1
+ import type { OblaxContext } from '@oblax/core';
2
+ import type { ConvertItemParams, CreateItemParams, DeleteItemParams, EnsureItemParams, FileLink, FollowUpParams, GetItemParams, HistoryPage, IdParams, Item, ItemFileParams, ItemHistoryParams, ItemLink, LinkParams, ListItemsParams, MoveItemParams, RankItemParams, Resent, RetypeItemParams, UpdateItemParams, WatchParams, WorkflowsList } from './types.js';
3
+ /**
4
+ * Manages items: create, edit, move through the flow, rank, watch, link,
5
+ * follow up, convert and retype. Routes take an item's id or its key
6
+ * (`CRM-42`). Saves send the `version` they loaded as `expect`; a stale one
7
+ * fails with 409.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const ticket = await oblax.workflows.items.create({
12
+ * workspaceId: 'workspace-id',
13
+ * type: 'ticket',
14
+ * title: 'Printer on fire',
15
+ * })
16
+ *
17
+ * await oblax.workflows.items.move({ id: ticket.key, to: 'open', expect: ticket.status })
18
+ *
19
+ * // My open items, newest first
20
+ * const { data } = await oblax.workflows.items.list({
21
+ * filters: [
22
+ * { field: 'assignee_id', op: 'eq', value: 'me' },
23
+ * { field: 'open', op: 'eq', value: true },
24
+ * ],
25
+ * })
26
+ * ```
27
+ */
28
+ export declare class ItemsSubmodule {
29
+ private readonly ctx;
30
+ constructor(ctx: OblaxContext);
31
+ /**
32
+ * Lists the items the caller sees. Filter on `workspace_id`, `type_id`,
33
+ * `status`, `category`, `open`, `assignee_id` (`me`, `none`), `watcher`,
34
+ * `parent_id`, `top`, `ancestor`, `due_at`, `fields.<path>` (with one
35
+ * `type_id`), `bucket` (a bucket's id: its current members), `bucket_none`
36
+ * (a bucket type's id: the backlog), ...; order by `_created` (default), `_modified`, `number`,
37
+ * `title`, `due_at`, `closed_at`, `rank` or `fields.<path>`.
38
+ */
39
+ list(params?: ListItemsParams): Promise<WorkflowsList<Item>>;
40
+ /** Returns an item, with its people, organizations and what the caller may do (`can`). */
41
+ get(params: GetItemParams): Promise<Item>;
42
+ /**
43
+ * Creates an item. A subject with an open item of the type, or a taken
44
+ * dedupe key, fails with 409; `ensure()` returns that item instead.
45
+ */
46
+ create(params: CreateItemParams): Promise<Item>;
47
+ /**
48
+ * Returns the item a subject has in a type, or makes one: the item with the
49
+ * same dedupe key, else the subject's open item (snapshot updated), else a
50
+ * follow-up of its last closed one, else a new item.
51
+ */
52
+ ensure(params: EnsureItemParams): Promise<Item>;
53
+ /** Changes the keys given and keeps the others; `null` clears one. */
54
+ update(params: UpdateItemParams): Promise<Item>;
55
+ /** Deletes an item; with children it fails with 409 unless `cascade`. Its history stays. */
56
+ delete(params: DeleteItemParams): Promise<void>;
57
+ /** Moves an item to another status of its flow. Comes back with the move's warnings. */
58
+ move(params: MoveItemParams): Promise<Item>;
59
+ /** Places an item within its status, after another item (or at the top). */
60
+ rank(params: RankItemParams): Promise<Item>;
61
+ /** The item's history, oldest first, with the people it names. Filter on `kind`, `actor_id`, `_created`. */
62
+ history(params: ItemHistoryParams): Promise<HistoryPage>;
63
+ /** Adds a watcher: a person, or the caller. */
64
+ watch(params: WatchParams): Promise<Item>;
65
+ /** Removes a watcher: a person, or the caller. */
66
+ unwatch(params: WatchParams): Promise<Item>;
67
+ /** Makes a follow-up of a closed item: a new item of the same type. */
68
+ followUp(params: FollowUpParams): Promise<Item>;
69
+ /** Converts an open item into a new item of another type; the original moves to done. */
70
+ convert(params: ConvertItemParams): Promise<Item>;
71
+ /** Changes an item's type in place; the new type must share its flow. */
72
+ retype(params: RetypeItemParams): Promise<Item>;
73
+ /** Sends the item's last status event again, for a lost flux run. Writes nothing. */
74
+ resend(params: IdParams): Promise<Resent>;
75
+ /** Lists the item's links, each with the item at its other end. */
76
+ listLinks(params: IdParams): Promise<WorkflowsList<ItemLink>>;
77
+ /** Adds a link, read from the item's side. The same link already there comes back unchanged. */
78
+ link(params: LinkParams): Promise<ItemLink>;
79
+ /** Removes a link, read from the item's side. */
80
+ unlink(params: LinkParams): Promise<void>;
81
+ /** Returns a download link (15 minutes) to a file in one of the item's file fields. */
82
+ getFileLink(params: ItemFileParams): Promise<FileLink>;
83
+ }
84
+ //# sourceMappingURL=items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,WAAW,EACX,QAAQ,EACR,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