@objectstack/client 7.5.0 → 7.7.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.mts +47 -7
- package/dist/index.d.ts +47 -7
- package/dist/index.js +62 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -2149,34 +2149,79 @@ var ObjectStackClient = class {
|
|
|
2149
2149
|
})
|
|
2150
2150
|
});
|
|
2151
2151
|
return this.unwrapResponse(res);
|
|
2152
|
+
}
|
|
2153
|
+
// ADR-0019: approve/reject are no longer workflow operations. Approval is a
|
|
2154
|
+
// flow node — see the `approvals` namespace below for recording decisions.
|
|
2155
|
+
};
|
|
2156
|
+
/**
|
|
2157
|
+
* Approval Services (ADR-0019)
|
|
2158
|
+
*
|
|
2159
|
+
* Approval is a first-class flow node, not a workflow step: a flow's
|
|
2160
|
+
* Approval node opens a request and suspends the run; recording a decision
|
|
2161
|
+
* here finalises the request and resumes the owning flow down the matching
|
|
2162
|
+
* `approve` / `reject` edge. This namespace drives the "my approvals" inbox
|
|
2163
|
+
* and the decision API exposed under `/api/v1/approvals`.
|
|
2164
|
+
*/
|
|
2165
|
+
this.approvals = {
|
|
2166
|
+
/**
|
|
2167
|
+
* List approval requests ("my approvals" inbox). Filter by status, target
|
|
2168
|
+
* object / record, the user expected to act next, or the submitter.
|
|
2169
|
+
*/
|
|
2170
|
+
listRequests: async (filter) => {
|
|
2171
|
+
const route = this.getRoute("approvals");
|
|
2172
|
+
const params = new URLSearchParams();
|
|
2173
|
+
if (filter?.object) params.set("object", filter.object);
|
|
2174
|
+
if (filter?.recordId) params.set("recordId", filter.recordId);
|
|
2175
|
+
if (filter?.status) {
|
|
2176
|
+
params.set("status", Array.isArray(filter.status) ? filter.status.join(",") : filter.status);
|
|
2177
|
+
}
|
|
2178
|
+
if (filter?.approverId) params.set("approverId", filter.approverId);
|
|
2179
|
+
if (filter?.submitterId) params.set("submitterId", filter.submitterId);
|
|
2180
|
+
const qs = params.toString();
|
|
2181
|
+
const res = await this.fetch(`${this.baseUrl}${route}/requests${qs ? `?${qs}` : ""}`);
|
|
2182
|
+
const body = await this.unwrapResponse(res);
|
|
2183
|
+
return Array.isArray(body) ? body : body?.data ?? [];
|
|
2152
2184
|
},
|
|
2153
2185
|
/**
|
|
2154
|
-
*
|
|
2186
|
+
* Get a single approval request by id.
|
|
2155
2187
|
*/
|
|
2156
|
-
|
|
2157
|
-
const route = this.getRoute("
|
|
2158
|
-
const res = await this.fetch(`${this.baseUrl}${route}/${encodeURIComponent(
|
|
2188
|
+
getRequest: async (requestId) => {
|
|
2189
|
+
const route = this.getRoute("approvals");
|
|
2190
|
+
const res = await this.fetch(`${this.baseUrl}${route}/requests/${encodeURIComponent(requestId)}`);
|
|
2191
|
+
return this.unwrapResponse(res);
|
|
2192
|
+
},
|
|
2193
|
+
/**
|
|
2194
|
+
* Record an approve decision on a request. Finalises the request when the
|
|
2195
|
+
* node's behaviour is satisfied and resumes the owning flow run.
|
|
2196
|
+
*/
|
|
2197
|
+
approve: async (requestId, decision) => {
|
|
2198
|
+
const route = this.getRoute("approvals");
|
|
2199
|
+
const res = await this.fetch(`${this.baseUrl}${route}/requests/${encodeURIComponent(requestId)}/approve`, {
|
|
2159
2200
|
method: "POST",
|
|
2160
|
-
body: JSON.stringify({
|
|
2161
|
-
comment: request.comment,
|
|
2162
|
-
data: request.data
|
|
2163
|
-
})
|
|
2201
|
+
body: JSON.stringify({ actorId: decision?.actorId, comment: decision?.comment })
|
|
2164
2202
|
});
|
|
2165
2203
|
return this.unwrapResponse(res);
|
|
2166
2204
|
},
|
|
2167
2205
|
/**
|
|
2168
|
-
*
|
|
2206
|
+
* Record a reject decision on a request. Resumes the owning flow run down
|
|
2207
|
+
* the `reject` edge.
|
|
2169
2208
|
*/
|
|
2170
|
-
reject: async (
|
|
2171
|
-
const route = this.getRoute("
|
|
2172
|
-
const res = await this.fetch(`${this.baseUrl}${route}/${encodeURIComponent(
|
|
2209
|
+
reject: async (requestId, decision) => {
|
|
2210
|
+
const route = this.getRoute("approvals");
|
|
2211
|
+
const res = await this.fetch(`${this.baseUrl}${route}/requests/${encodeURIComponent(requestId)}/reject`, {
|
|
2173
2212
|
method: "POST",
|
|
2174
|
-
body: JSON.stringify({
|
|
2175
|
-
reason: request.reason,
|
|
2176
|
-
comment: request.comment
|
|
2177
|
-
})
|
|
2213
|
+
body: JSON.stringify({ actorId: decision?.actorId, comment: decision?.comment })
|
|
2178
2214
|
});
|
|
2179
2215
|
return this.unwrapResponse(res);
|
|
2216
|
+
},
|
|
2217
|
+
/**
|
|
2218
|
+
* Audit trail (the immutable action log) for an approval request.
|
|
2219
|
+
*/
|
|
2220
|
+
listActions: async (requestId) => {
|
|
2221
|
+
const route = this.getRoute("approvals");
|
|
2222
|
+
const res = await this.fetch(`${this.baseUrl}${route}/requests/${encodeURIComponent(requestId)}/actions`);
|
|
2223
|
+
const body = await this.unwrapResponse(res);
|
|
2224
|
+
return Array.isArray(body) ? body : body?.data ?? [];
|
|
2180
2225
|
}
|
|
2181
2226
|
};
|
|
2182
2227
|
/**
|
|
@@ -2968,6 +3013,7 @@ var ObjectStackClient = class {
|
|
|
2968
3013
|
permissions: "/api/v1/permissions",
|
|
2969
3014
|
realtime: "/api/v1/realtime",
|
|
2970
3015
|
workflow: "/api/v1/workflow",
|
|
3016
|
+
approvals: "/api/v1/approvals",
|
|
2971
3017
|
views: "/api/v1/ui/views",
|
|
2972
3018
|
notifications: "/api/v1/notifications",
|
|
2973
3019
|
ai: "/api/v1/ai",
|