@segmentstream/ontology 0.119.0 → 0.120.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/CHANGELOG.md +7 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/service/chat/delivery.js +2 -0
- package/dist/service/errors.js +4 -3
- package/dist/service/schemas.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.120.0
|
|
4
|
+
|
|
5
|
+
A chat post whose delivery did not happen and spent its idempotency key, a message the provider
|
|
6
|
+
refused or a replay of one, now answers `422 action_rejected` with `key_consumed: true`, so a client
|
|
7
|
+
sends it again with a new key. Any other failure keeps meaning: retry with the same key.
|
|
8
|
+
`ActionRejected` takes `keyConsumed: true` for any action whose key a refusal spends.
|
|
9
|
+
|
|
3
10
|
## 0.119.0
|
|
4
11
|
|
|
5
12
|
A trigger can run one action without a workflow file. List it in `defineOntology({ triggers })`
|
package/dist/errors.d.ts
CHANGED
|
@@ -58,6 +58,12 @@ declare const ActionRejected_base: Schema.Class<ActionRejected, Schema.TaggedStr
|
|
|
58
58
|
readonly live: Schema.Int;
|
|
59
59
|
readonly max: Schema.Int;
|
|
60
60
|
}>]>>;
|
|
61
|
+
/**
|
|
62
|
+
* The request's idempotency key is spent on an operation that did not happen, such as a message
|
|
63
|
+
* the provider refused: the same key is refused again, and a new attempt takes a new key. Absent,
|
|
64
|
+
* a client that is unsure whether its request took effect retries with the same key.
|
|
65
|
+
*/
|
|
66
|
+
readonly keyConsumed: Schema.optionalKey<Schema.Literal<true>>;
|
|
61
67
|
}>, import("effect/Cause").YieldableError>;
|
|
62
68
|
/**
|
|
63
69
|
* An action refused the request for a business reason. The message is written for the caller and is
|
package/dist/errors.js
CHANGED
|
@@ -35,6 +35,12 @@ export class ActionRejected extends Schema.TaggedError()("ActionRejected", {
|
|
|
35
35
|
cause: Schema.optionalKey(Schema.Unknown),
|
|
36
36
|
batch: Schema.optionalKey(BatchErrorDetails),
|
|
37
37
|
limit: Schema.optionalKey(LimitErrorDetails),
|
|
38
|
+
/**
|
|
39
|
+
* The request's idempotency key is spent on an operation that did not happen, such as a message
|
|
40
|
+
* the provider refused: the same key is refused again, and a new attempt takes a new key. Absent,
|
|
41
|
+
* a client that is unsure whether its request took effect retries with the same key.
|
|
42
|
+
*/
|
|
43
|
+
keyConsumed: Schema.optionalKey(Schema.Literal(true)),
|
|
38
44
|
}) {
|
|
39
45
|
}
|
|
40
46
|
/**
|
|
@@ -303,6 +303,7 @@ agent = {}) {
|
|
|
303
303
|
if (reserve.status === "failed") {
|
|
304
304
|
return yield* new ActionRejected({
|
|
305
305
|
message: "This operation was refused. Its idempotency key is consumed.",
|
|
306
|
+
keyConsumed: true,
|
|
306
307
|
});
|
|
307
308
|
}
|
|
308
309
|
return {
|
|
@@ -382,6 +383,7 @@ agent = {}) {
|
|
|
382
383
|
if (outcome.status === "failed") {
|
|
383
384
|
return yield* new ActionRejected({
|
|
384
385
|
message: "The provider refused the message. This operation key is consumed.",
|
|
386
|
+
keyConsumed: true,
|
|
385
387
|
});
|
|
386
388
|
}
|
|
387
389
|
return {
|
package/dist/service/errors.js
CHANGED
|
@@ -490,16 +490,17 @@ export function expectedFailure(error, requestId) {
|
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
if (Predicate.isTagged(error, "ActionRejected")) {
|
|
493
|
-
const message =
|
|
493
|
+
const { message, keyConsumed } = error;
|
|
494
494
|
return {
|
|
495
495
|
status: 422,
|
|
496
496
|
body: {
|
|
497
497
|
error: "action_rejected",
|
|
498
|
-
detail: message,
|
|
498
|
+
detail: String(message),
|
|
499
499
|
requestId,
|
|
500
|
-
issues: [{ path: [], message }],
|
|
500
|
+
issues: [{ path: [], message: String(message) }],
|
|
501
501
|
...batchDetails(error),
|
|
502
502
|
...limitDetails(error),
|
|
503
|
+
...(keyConsumed === true ? { key_consumed: true } : {}),
|
|
503
504
|
},
|
|
504
505
|
};
|
|
505
506
|
}
|
package/dist/service/schemas.js
CHANGED
|
@@ -612,6 +612,8 @@ export const ErrorSchemas = {
|
|
|
612
612
|
issues: Schema.Array(ValidationIssue),
|
|
613
613
|
batch: Schema.optionalKey(BatchErrorDetails),
|
|
614
614
|
limit: Schema.optionalKey(LimitErrorWire),
|
|
615
|
+
// The idempotency key is spent on an operation that did not happen: retry with a new one.
|
|
616
|
+
key_consumed: Schema.optionalKey(Schema.Literal(true)),
|
|
615
617
|
}),
|
|
616
618
|
rateLimited: errorBody("RateLimited", 429, ["rate_limited"]),
|
|
617
619
|
internal: errorBody("InternalError", 500, ["internal_error"]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.120.0",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|