@superdurable/connector-front 0.1.0 → 0.1.1
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/README.md +1 -1
- package/dex-connector.json +194 -7
- package/dist/{chunk-7HCGNRLW.js → chunk-V55LK3PU.js} +70 -15
- package/dist/{connection-BKHmrBii.d.ts → connection-Cn_WglIz.d.ts} +33 -25
- package/dist/index.d.ts +22 -14
- package/dist/index.js +96 -45
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -12,6 +12,6 @@ Use Node.js 22 or 24 and Dex TypeScript SDK 1.28.0 or newer. Create a secret Fro
|
|
|
12
12
|
| `newUpdateConversationStep` | Set status, assignee, and tags | `updated` |
|
|
13
13
|
| `newFindContactByEmailStep` | Look up a contact email alias | `found` |
|
|
14
14
|
|
|
15
|
-
Every other branch is optional, so an unwired branch fails the Flow. Replies and comments use the SDK single-dispatch fence: Front has no provider idempotency key,
|
|
15
|
+
Every other branch is optional, so an unwired branch fails the Flow. Replies and comments use the SDK single-dispatch fence: Front has no provider idempotency key, so an ambiguous send is resent while the manifest send cap allows and selects `uncertain` at the cap. Updates set absolute values and read back the conversation, so they can retry safely.
|
|
16
16
|
|
|
17
17
|
Run `npm ci`, `npm run check`, and `npm run test:integration` with a local `dexcli dev` address. The package replays the Go-recorded provider scenarios; the integration test runs the checked-in Flow through a real Dex Worker and Client against a local Front-compatible fixture. Live Front authorization, conversation operations, and contact lookup have not been verified.
|
package/dex-connector.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"connectorId": "front",
|
|
3
|
-
"releaseTag": "connectors/front/go/v0.23.
|
|
3
|
+
"releaseTag": "connectors/front/go/v0.23.1",
|
|
4
4
|
"package": {
|
|
5
5
|
"ecosystem": "npm",
|
|
6
6
|
"name": "@superdurable/connector-front",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.1"
|
|
8
8
|
},
|
|
9
9
|
"factories": [
|
|
10
10
|
{
|
|
11
11
|
"name": "newSearchConversationsStep",
|
|
12
12
|
"kind": "query",
|
|
13
13
|
"operationId": "searchConversations",
|
|
14
|
+
"inputType": "SearchConversationsInput",
|
|
15
|
+
"description": "Search conversations by text, inbox, tag, Front status filters, recipient email, assignee, and recent activity, returning one bounded page newest activity first and a page token for the next.",
|
|
14
16
|
"fields": {
|
|
15
17
|
"stepType": "stepType",
|
|
16
18
|
"annotations": "annotations",
|
|
@@ -38,12 +40,75 @@
|
|
|
38
40
|
"field": "defect",
|
|
39
41
|
"optional": true
|
|
40
42
|
}
|
|
41
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"inputSchema": {
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "SearchConversationsInput selects one page of Front's conversation search. Every set field is one filter, and Front combines them with AND. At least one field other than the page fields is required.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"activityAfter": {
|
|
49
|
+
"description": "ActivityAfter keeps conversations with a message or comment created after this time, in whole seconds.",
|
|
50
|
+
"format": "date-time",
|
|
51
|
+
"type": [
|
|
52
|
+
"string",
|
|
53
|
+
"null"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"assigneeId": {
|
|
57
|
+
"description": "AssigneeID keeps conversations assigned to one teammate, such as tea_2thf.",
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"inboxId": {
|
|
61
|
+
"description": "InboxID keeps conversations in one inbox, such as inb_41w25.",
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"pageSize": {
|
|
65
|
+
"description": "PageSize is 1 to MaxSearchPageSize; zero requests DefaultSearchPageSize.",
|
|
66
|
+
"type": "integer"
|
|
67
|
+
},
|
|
68
|
+
"pageToken": {
|
|
69
|
+
"description": "PageToken is a previous Result's NextPageToken; send it with the same filters.",
|
|
70
|
+
"type": "string"
|
|
71
|
+
},
|
|
72
|
+
"recipientEmail": {
|
|
73
|
+
"description": "RecipientEmail keeps conversations where the address is a from, to, cc, or bcc handle of any message.",
|
|
74
|
+
"type": "string"
|
|
75
|
+
},
|
|
76
|
+
"statuses": {
|
|
77
|
+
"description": "Statuses are is: filters such as open and unassigned. Blank omits trashed conversations, Front's default.",
|
|
78
|
+
"items": {
|
|
79
|
+
"enum": [
|
|
80
|
+
"archived",
|
|
81
|
+
"assigned",
|
|
82
|
+
"open",
|
|
83
|
+
"resolved",
|
|
84
|
+
"snoozed",
|
|
85
|
+
"trashed",
|
|
86
|
+
"unassigned",
|
|
87
|
+
"unreplied",
|
|
88
|
+
"waiting"
|
|
89
|
+
],
|
|
90
|
+
"type": "string"
|
|
91
|
+
},
|
|
92
|
+
"type": "array"
|
|
93
|
+
},
|
|
94
|
+
"tagId": {
|
|
95
|
+
"description": "TagID keeps conversations with one tag, such as tag_13o8r1.",
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"text": {
|
|
99
|
+
"description": "Text is Front search text matched in subjects and bodies: words, which all must match, and quoted phrases. It is sent unchanged, so Front also applies any filter it contains; quote user-supplied text.",
|
|
100
|
+
"type": "string"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"type": "object"
|
|
104
|
+
}
|
|
42
105
|
},
|
|
43
106
|
{
|
|
44
107
|
"name": "newGetConversationStep",
|
|
45
108
|
"kind": "query",
|
|
46
109
|
"operationId": "getConversation",
|
|
110
|
+
"inputType": "GetConversationInput",
|
|
111
|
+
"description": "Read one conversation by ID with a bounded list of its newest messages and newest internal comments.",
|
|
47
112
|
"fields": {
|
|
48
113
|
"stepType": "stepType",
|
|
49
114
|
"annotations": "annotations",
|
|
@@ -81,12 +146,36 @@
|
|
|
81
146
|
"field": "defect",
|
|
82
147
|
"optional": true
|
|
83
148
|
}
|
|
84
|
-
]
|
|
149
|
+
],
|
|
150
|
+
"inputSchema": {
|
|
151
|
+
"additionalProperties": false,
|
|
152
|
+
"description": "GetConversationInput identifies one conversation and how much of its history to return.",
|
|
153
|
+
"properties": {
|
|
154
|
+
"commentLimit": {
|
|
155
|
+
"description": "CommentLimit is 1 to MaxCommentLimit newest internal comments; zero returns DefaultCommentLimit.",
|
|
156
|
+
"type": "integer"
|
|
157
|
+
},
|
|
158
|
+
"conversationId": {
|
|
159
|
+
"description": "ConversationID is the Front conversation ID, such as cnv_55c8c149.",
|
|
160
|
+
"type": "string"
|
|
161
|
+
},
|
|
162
|
+
"messageLimit": {
|
|
163
|
+
"description": "MessageLimit is 1 to MaxMessageLimit newest messages; zero reads DefaultMessageLimit.",
|
|
164
|
+
"type": "integer"
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"required": [
|
|
168
|
+
"conversationId"
|
|
169
|
+
],
|
|
170
|
+
"type": "object"
|
|
171
|
+
}
|
|
85
172
|
},
|
|
86
173
|
{
|
|
87
174
|
"name": "newReplyToConversationStep",
|
|
88
175
|
"kind": "mutation",
|
|
89
176
|
"operationId": "replyToConversation",
|
|
177
|
+
"inputType": "ReplyToConversationInput",
|
|
178
|
+
"description": "Send one reply that Front delivers to the conversation's recipients, or add one internal comment that only teammates see. Front has no idempotency key or client-supplied lookup value, so the shared single-dispatch fence needs sync durability for visible heartbeat checkpoints across attempts.",
|
|
90
179
|
"fields": {
|
|
91
180
|
"stepType": "stepType",
|
|
92
181
|
"annotations": "annotations",
|
|
@@ -119,12 +208,45 @@
|
|
|
119
208
|
"field": "defect",
|
|
120
209
|
"optional": true
|
|
121
210
|
}
|
|
122
|
-
]
|
|
211
|
+
],
|
|
212
|
+
"inputSchema": {
|
|
213
|
+
"additionalProperties": false,
|
|
214
|
+
"description": "ReplyToConversationInput is one reply to the customer or one internal comment.",
|
|
215
|
+
"properties": {
|
|
216
|
+
"authorId": {
|
|
217
|
+
"description": "AuthorID is the teammate the reply is sent on behalf of, or who writes the comment, such as tea_2thf. Blank lets Front choose: a comment is then written as the API token.",
|
|
218
|
+
"type": "string"
|
|
219
|
+
},
|
|
220
|
+
"conversationId": {
|
|
221
|
+
"description": "ConversationID is the Front conversation ID, such as cnv_55c8c149.",
|
|
222
|
+
"type": "string"
|
|
223
|
+
},
|
|
224
|
+
"isInternalNote": {
|
|
225
|
+
"description": "IsInternalNote adds a comment that only teammates see, through POST /conversations/{id}/comments. False sends a reply that Front delivers to the conversation's recipients, through POST /conversations/{id}/messages.",
|
|
226
|
+
"type": "boolean"
|
|
227
|
+
},
|
|
228
|
+
"shouldArchive": {
|
|
229
|
+
"description": "ShouldArchive archives the conversation when the reply is sent. False keeps it open, unlike Front's own default; a comment must leave it false.",
|
|
230
|
+
"type": "boolean"
|
|
231
|
+
},
|
|
232
|
+
"text": {
|
|
233
|
+
"description": "Text is the plain text to send, required and at most MaxReplyTextBytes. A reply sends it as text and as an HTML body with one paragraph per blank-line-separated block; a comment sends it unchanged, and Front renders Markdown in comments.",
|
|
234
|
+
"type": "string"
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"required": [
|
|
238
|
+
"conversationId",
|
|
239
|
+
"text"
|
|
240
|
+
],
|
|
241
|
+
"type": "object"
|
|
242
|
+
}
|
|
123
243
|
},
|
|
124
244
|
{
|
|
125
245
|
"name": "newUpdateConversationStep",
|
|
126
246
|
"kind": "mutation",
|
|
127
247
|
"operationId": "updateConversation",
|
|
248
|
+
"inputType": "UpdateConversationInput",
|
|
249
|
+
"description": "Set the Front status or ticket status, assignee, and tags of one conversation, then read it back; a repeated attempt finds the values already applied and writes nothing.",
|
|
128
250
|
"fields": {
|
|
129
251
|
"stepType": "stepType",
|
|
130
252
|
"annotations": "annotations",
|
|
@@ -157,12 +279,63 @@
|
|
|
157
279
|
"field": "defect",
|
|
158
280
|
"optional": true
|
|
159
281
|
}
|
|
160
|
-
]
|
|
282
|
+
],
|
|
283
|
+
"inputSchema": {
|
|
284
|
+
"additionalProperties": false,
|
|
285
|
+
"description": "UpdateConversationInput sets a conversation's status, assignee, and tags. Every field is optional, but at least one change is required. Unset fields are left as they are.",
|
|
286
|
+
"properties": {
|
|
287
|
+
"addTagIds": {
|
|
288
|
+
"description": "AddTagIDs are tag IDs to add, such as tag_13o8r1; a tag already on the conversation is kept once.",
|
|
289
|
+
"items": {
|
|
290
|
+
"type": "string"
|
|
291
|
+
},
|
|
292
|
+
"type": "array"
|
|
293
|
+
},
|
|
294
|
+
"assigneeId": {
|
|
295
|
+
"description": "AssigneeID assigns the conversation to one teammate, such as tea_2thf.",
|
|
296
|
+
"type": "string"
|
|
297
|
+
},
|
|
298
|
+
"conversationId": {
|
|
299
|
+
"description": "ConversationID is the Front conversation ID, such as cnv_55c8c149.",
|
|
300
|
+
"type": "string"
|
|
301
|
+
},
|
|
302
|
+
"isUnassigned": {
|
|
303
|
+
"description": "IsUnassigned removes the assignee; it cannot be combined with AssigneeID.",
|
|
304
|
+
"type": "boolean"
|
|
305
|
+
},
|
|
306
|
+
"removeTagIds": {
|
|
307
|
+
"description": "RemoveTagIDs are tag IDs to remove; a tag not on the conversation is ignored.",
|
|
308
|
+
"items": {
|
|
309
|
+
"type": "string"
|
|
310
|
+
},
|
|
311
|
+
"type": "array"
|
|
312
|
+
},
|
|
313
|
+
"status": {
|
|
314
|
+
"description": "Status is open, archived, or deleted, in Front's write vocabulary. It cannot be combined with StatusID.",
|
|
315
|
+
"enum": [
|
|
316
|
+
"archived",
|
|
317
|
+
"deleted",
|
|
318
|
+
"open"
|
|
319
|
+
],
|
|
320
|
+
"type": "string"
|
|
321
|
+
},
|
|
322
|
+
"statusId": {
|
|
323
|
+
"description": "StatusID is a ticket status ID, such as sts_5x, for a company that uses ticketing.",
|
|
324
|
+
"type": "string"
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
"required": [
|
|
328
|
+
"conversationId"
|
|
329
|
+
],
|
|
330
|
+
"type": "object"
|
|
331
|
+
}
|
|
161
332
|
},
|
|
162
333
|
{
|
|
163
334
|
"name": "newFindContactByEmailStep",
|
|
164
335
|
"kind": "query",
|
|
165
336
|
"operationId": "findContactByEmail",
|
|
337
|
+
"inputType": "FindContactByEmailInput",
|
|
338
|
+
"description": "Find the Front contact whose email handle equals one address; Front keeps each handle on at most one contact.",
|
|
166
339
|
"fields": {
|
|
167
340
|
"stepType": "stepType",
|
|
168
341
|
"annotations": "annotations",
|
|
@@ -195,7 +368,21 @@
|
|
|
195
368
|
"field": "defect",
|
|
196
369
|
"optional": true
|
|
197
370
|
}
|
|
198
|
-
]
|
|
371
|
+
],
|
|
372
|
+
"inputSchema": {
|
|
373
|
+
"additionalProperties": false,
|
|
374
|
+
"description": "FindContactByEmailInput is the email handle to look up.",
|
|
375
|
+
"properties": {
|
|
376
|
+
"email": {
|
|
377
|
+
"description": "Email is one bare address, such as jane@acme.example.com, sent as Front's alt:email: contact alias.",
|
|
378
|
+
"type": "string"
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
"required": [
|
|
382
|
+
"email"
|
|
383
|
+
],
|
|
384
|
+
"type": "object"
|
|
385
|
+
}
|
|
199
386
|
}
|
|
200
387
|
]
|
|
201
388
|
}
|
|
@@ -1,8 +1,57 @@
|
|
|
1
1
|
// src/generated/models.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
5
|
+
function isGoTimeJSON(value) {
|
|
6
|
+
const match = goTimeJSONPattern.exec(value);
|
|
7
|
+
if (!match) return false;
|
|
8
|
+
const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
|
|
9
|
+
const year = Number(yearText);
|
|
10
|
+
const month = Number(monthText);
|
|
11
|
+
const day = Number(dayText);
|
|
12
|
+
const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
13
|
+
const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
|
|
15
|
+
}
|
|
16
|
+
function canonicalGoTimeJSON(value) {
|
|
17
|
+
const match = goTimeJSONPattern.exec(value);
|
|
18
|
+
const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
|
|
19
|
+
const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
|
|
20
|
+
const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
|
|
21
|
+
const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
|
|
22
|
+
if (Math.abs(offsetMinutes) >= 1440) return value;
|
|
23
|
+
const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
|
|
24
|
+
return clock + (digits ? "." + digits : "") + offset;
|
|
25
|
+
}
|
|
26
|
+
var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
|
|
3
27
|
var ConfigSchema = z.object({
|
|
4
28
|
"maxResponseBytes": z.number().int().optional()
|
|
5
29
|
});
|
|
30
|
+
var CredentialMaterialError = class extends TypeError {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "CredentialMaterialError";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
37
|
+
"project credential decoding failed",
|
|
38
|
+
"shared project credential decoding failed",
|
|
39
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
40
|
+
]);
|
|
41
|
+
function isCredentialMaterialError(error) {
|
|
42
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
43
|
+
}
|
|
44
|
+
function decodeCredentials(value) {
|
|
45
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
46
|
+
const fields = value;
|
|
47
|
+
const allowed = /* @__PURE__ */ new Set(["api_token"]);
|
|
48
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
49
|
+
if (fields["api_token"] != null && !(typeof fields["api_token"] === "string")) throw new CredentialMaterialError("credential api_token has an invalid type");
|
|
50
|
+
const credentials = {};
|
|
51
|
+
if (!fields["api_token"]) throw new CredentialMaterialError("credential api_token is required");
|
|
52
|
+
credentials.apiToken = new SecretString(fields["api_token"] ?? "");
|
|
53
|
+
return credentials;
|
|
54
|
+
}
|
|
6
55
|
var SearchConversationsInputSchema = z.strictObject({
|
|
7
56
|
"text": z.string().optional(),
|
|
8
57
|
"inboxId": z.string().optional(),
|
|
@@ -10,7 +59,7 @@ var SearchConversationsInputSchema = z.strictObject({
|
|
|
10
59
|
"statuses": z.array(z.string()).optional(),
|
|
11
60
|
"recipientEmail": z.string().optional(),
|
|
12
61
|
"assigneeId": z.string().optional(),
|
|
13
|
-
"activityAfter":
|
|
62
|
+
"activityAfter": GoTimeJSONSchema.nullable().optional(),
|
|
14
63
|
"pageSize": z.number().int().optional(),
|
|
15
64
|
"pageToken": z.string().optional()
|
|
16
65
|
});
|
|
@@ -43,10 +92,10 @@ var ConversationSchema = z.strictObject({
|
|
|
43
92
|
"tags": z.array(TagSchema).optional(),
|
|
44
93
|
"isPrivate": z.boolean().optional(),
|
|
45
94
|
"isSnoozed": z.boolean().optional(),
|
|
46
|
-
"createdAt":
|
|
47
|
-
"updatedAt":
|
|
48
|
-
"waitingSince":
|
|
49
|
-
"dueAt":
|
|
95
|
+
"createdAt": GoTimeJSONSchema,
|
|
96
|
+
"updatedAt": GoTimeJSONSchema.nullable().optional(),
|
|
97
|
+
"waitingSince": GoTimeJSONSchema.nullable().optional(),
|
|
98
|
+
"dueAt": GoTimeJSONSchema.nullable().optional()
|
|
50
99
|
});
|
|
51
100
|
var SearchConversationsOutputSchema = z.strictObject({
|
|
52
101
|
"conversations": z.array(ConversationSchema).nullable(),
|
|
@@ -70,7 +119,7 @@ var MessageSchema = z.strictObject({
|
|
|
70
119
|
"isBodyTruncated": z.boolean().optional(),
|
|
71
120
|
"author": TeammateSchema.optional(),
|
|
72
121
|
"recipients": z.array(RecipientSchema).optional(),
|
|
73
|
-
"createdAt":
|
|
122
|
+
"createdAt": GoTimeJSONSchema
|
|
74
123
|
});
|
|
75
124
|
var CommentSchema = z.strictObject({
|
|
76
125
|
"id": z.string(),
|
|
@@ -78,7 +127,7 @@ var CommentSchema = z.strictObject({
|
|
|
78
127
|
"isBodyTruncated": z.boolean().optional(),
|
|
79
128
|
"author": TeammateSchema.optional(),
|
|
80
129
|
"isPinned": z.boolean().optional(),
|
|
81
|
-
"postedAt":
|
|
130
|
+
"postedAt": GoTimeJSONSchema
|
|
82
131
|
});
|
|
83
132
|
var ConversationDetailsSchema = z.strictObject({
|
|
84
133
|
"conversation": ConversationSchema,
|
|
@@ -129,7 +178,7 @@ var ContactSchema = z.strictObject({
|
|
|
129
178
|
"handles": z.array(ContactHandleSchema).optional(),
|
|
130
179
|
"listNames": z.array(z.string()).optional(),
|
|
131
180
|
"isPrivate": z.boolean().optional(),
|
|
132
|
-
"updatedAt":
|
|
181
|
+
"updatedAt": GoTimeJSONSchema.nullable().optional()
|
|
133
182
|
});
|
|
134
183
|
var FindContactByEmailOutputSchema = z.strictObject({
|
|
135
184
|
"contacts": z.array(ContactSchema).nullable()
|
|
@@ -202,12 +251,14 @@ var ReplyToConversationDefinition = {
|
|
|
202
251
|
operation: { connectorId: ConnectorID, operationId: "replyToConversation" },
|
|
203
252
|
branches: [
|
|
204
253
|
{ id: "replied", description: "Front accepted the reply for delivery or created the comment." },
|
|
205
|
-
{ id: "notFound", description: "The conversation does not exist
|
|
254
|
+
{ id: "notFound", description: "The conversation does not exist or is not visible to the API token (HTTP 404); nothing was sent. A merged conversation's 301 is an unknown outcome instead.", optional: true },
|
|
206
255
|
{ id: "providerRejected", description: "Front conclusively rejected the reply or comment, such as a token without send permission or an unknown author; nothing was sent.", optional: true },
|
|
207
|
-
{ id: "uncertain", description: "The reply or comment may exist after
|
|
208
|
-
{ id: "defect", description: "Local input, connection credentials that require reauthorization or are unusable before
|
|
256
|
+
{ id: "uncertain", description: "The reply or comment may exist: the send cap is reached after answers that were lost, late, 409, a 3xx such as a merged conversation's 301, an unlisted status, an ambiguous server error, or a refusal with an unreadable body; Front accepted it with a 2xx that carries no usable provider ID; a refusal or a reconnection requirement follows a possible earlier send; or an accepted write could not be read back, such as after a terminal credential failure or a deleted comment. Without a provider ID, an unknown outcome is resent while the cap allows; a 2xx is never resent.", optional: true },
|
|
257
|
+
{ id: "defect", description: "Local input, connection credentials that require reauthorization or are unusable before a first send, or the connector definition is invalid; transient credential failures Retry.", optional: true }
|
|
209
258
|
],
|
|
210
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 5, totalDurationMs: 3e5 } }
|
|
259
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 6e4, maximumAttempts: 5, totalDurationMs: 3e5 } },
|
|
260
|
+
repeatOnUnknown: "limited",
|
|
261
|
+
maxSends: 3
|
|
211
262
|
};
|
|
212
263
|
var ReplyToConversationMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
213
264
|
var UpdateConversationBranch = {
|
|
@@ -228,10 +279,11 @@ var UpdateConversationDefinition = {
|
|
|
228
279
|
{ id: "updated", description: "The conversation holds the requested status, assignee, and tags, written now or by an earlier attempt." },
|
|
229
280
|
{ id: "notFound", description: "The conversation does not exist, was merged, or is not visible to the API token.", optional: true },
|
|
230
281
|
{ id: "providerRejected", description: "Front conclusively rejected a change, such as an unknown teammate, tag, or ticket status; changes sent before it stay applied.", optional: true },
|
|
231
|
-
{ id: "invalidResponse", description: "
|
|
232
|
-
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
282
|
+
{ id: "invalidResponse", description: "Declared for compatibility and no longer selected: an earlier attempt's change may have applied, so a malformed or oversized conversation on any read is retried.", optional: true },
|
|
283
|
+
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid, or the connection needs reconnection on the first attempt; a transient credential failure, or one after an earlier attempt, Retries.", optional: true }
|
|
233
284
|
],
|
|
234
|
-
stepDefaults: { executeMethodTimeoutMs: 6e4, executeDurability: "async" }
|
|
285
|
+
stepDefaults: { executeMethodTimeoutMs: 6e4, executeDurability: "async" },
|
|
286
|
+
repeatOnUnknown: "safe"
|
|
235
287
|
};
|
|
236
288
|
var UpdateConversationMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
237
289
|
var FindContactByEmailBranch = {
|
|
@@ -291,6 +343,9 @@ function newProjectConnection(project, connectionName, createClient) {
|
|
|
291
343
|
|
|
292
344
|
export {
|
|
293
345
|
ConfigSchema,
|
|
346
|
+
CredentialMaterialError,
|
|
347
|
+
isCredentialMaterialError,
|
|
348
|
+
decodeCredentials,
|
|
294
349
|
SearchConversationsInputSchema,
|
|
295
350
|
TeammateSchema,
|
|
296
351
|
RecipientSchema,
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod';
|
|
|
3
3
|
|
|
4
4
|
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
5
|
interface Config {
|
|
6
|
-
/** Largest complete Front API response, in bytes, that one request reads; a larger response selects invalidResponse. getConversation reads a conversation's newest messages as HTML and every comment, so raise it only when conversations with very long emails select invalidResponse; enter a positive integer. Blank keeps the displayed safety limit. */
|
|
6
|
+
/** Largest complete Front API response, in bytes, that one request reads; a larger response selects invalidResponse for a Query and is retried by updateConversation. getConversation reads a conversation's newest messages as HTML and every comment, so raise it only when conversations with very long emails select invalidResponse; enter a positive integer. Blank keeps the displayed safety limit. */
|
|
7
7
|
maxResponseBytes?: number;
|
|
8
8
|
}
|
|
9
9
|
/** Runtime schema for manifest configuration. */
|
|
@@ -15,6 +15,14 @@ interface Credentials {
|
|
|
15
15
|
/** Secret Front API token. Sign in at https://app.frontapp.com/ as a company admin, open Settings > Developers > API Tokens, choose Create API token, and after it is created open the token and choose Copy; it is a long JSON Web Token of three dot-separated segments that begins with eyJ. It is sent only as an Authorization bearer token to https://api2.frontapp.com and stored only in this credential field. Required. Front tokens do not expire; after deleting a token in Front, create a new one and paste it here, which takes effect without a restart. */
|
|
16
16
|
apiToken: SecretString;
|
|
17
17
|
}
|
|
18
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
19
|
+
declare class CredentialMaterialError extends TypeError {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
23
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
24
|
+
/** Decode private credential fields for the connector. */
|
|
25
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
18
26
|
/** Host-owned source of private connector credentials. */
|
|
19
27
|
type CredentialSource = CredentialProvider<Credentials>;
|
|
20
28
|
/** SearchConversationsInput selects one page of Front's conversation search. Every set field is one
|
|
@@ -283,7 +291,7 @@ declare const SearchConversationsInputSchema: z.ZodObject<{
|
|
|
283
291
|
statuses: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
284
292
|
recipientEmail: z.ZodOptional<z.ZodString>;
|
|
285
293
|
assigneeId: z.ZodOptional<z.ZodString>;
|
|
286
|
-
activityAfter: z.ZodOptional<z.ZodNullable<z.
|
|
294
|
+
activityAfter: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
287
295
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
288
296
|
pageToken: z.ZodOptional<z.ZodString>;
|
|
289
297
|
}, z.core.$strict>;
|
|
@@ -333,10 +341,10 @@ declare const ConversationSchema: z.ZodObject<{
|
|
|
333
341
|
}, z.core.$strict>>>;
|
|
334
342
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
335
343
|
isSnoozed: z.ZodOptional<z.ZodBoolean>;
|
|
336
|
-
createdAt: z.
|
|
337
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.
|
|
338
|
-
waitingSince: z.ZodOptional<z.ZodNullable<z.
|
|
339
|
-
dueAt: z.ZodOptional<z.ZodNullable<z.
|
|
344
|
+
createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
345
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
346
|
+
waitingSince: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
347
|
+
dueAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
340
348
|
}, z.core.$strict>;
|
|
341
349
|
/** Runtime validator for SearchConversationsOutput. */
|
|
342
350
|
declare const SearchConversationsOutputSchema: z.ZodObject<{
|
|
@@ -366,10 +374,10 @@ declare const SearchConversationsOutputSchema: z.ZodObject<{
|
|
|
366
374
|
}, z.core.$strict>>>;
|
|
367
375
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
368
376
|
isSnoozed: z.ZodOptional<z.ZodBoolean>;
|
|
369
|
-
createdAt: z.
|
|
370
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.
|
|
371
|
-
waitingSince: z.ZodOptional<z.ZodNullable<z.
|
|
372
|
-
dueAt: z.ZodOptional<z.ZodNullable<z.
|
|
377
|
+
createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
378
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
379
|
+
waitingSince: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
380
|
+
dueAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
373
381
|
}, z.core.$strict>>>;
|
|
374
382
|
totalCount: z.ZodNumber;
|
|
375
383
|
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
@@ -403,7 +411,7 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
403
411
|
name: z.ZodOptional<z.ZodString>;
|
|
404
412
|
contactId: z.ZodOptional<z.ZodString>;
|
|
405
413
|
}, z.core.$strict>>>;
|
|
406
|
-
createdAt: z.
|
|
414
|
+
createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
407
415
|
}, z.core.$strict>;
|
|
408
416
|
/** Runtime validator for Comment. */
|
|
409
417
|
declare const CommentSchema: z.ZodObject<{
|
|
@@ -417,7 +425,7 @@ declare const CommentSchema: z.ZodObject<{
|
|
|
417
425
|
lastName: z.ZodOptional<z.ZodString>;
|
|
418
426
|
}, z.core.$strict>>;
|
|
419
427
|
isPinned: z.ZodOptional<z.ZodBoolean>;
|
|
420
|
-
postedAt: z.
|
|
428
|
+
postedAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
421
429
|
}, z.core.$strict>;
|
|
422
430
|
/** Runtime validator for ConversationDetails. */
|
|
423
431
|
declare const ConversationDetailsSchema: z.ZodObject<{
|
|
@@ -447,10 +455,10 @@ declare const ConversationDetailsSchema: z.ZodObject<{
|
|
|
447
455
|
}, z.core.$strict>>>;
|
|
448
456
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
449
457
|
isSnoozed: z.ZodOptional<z.ZodBoolean>;
|
|
450
|
-
createdAt: z.
|
|
451
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.
|
|
452
|
-
waitingSince: z.ZodOptional<z.ZodNullable<z.
|
|
453
|
-
dueAt: z.ZodOptional<z.ZodNullable<z.
|
|
458
|
+
createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
459
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
460
|
+
waitingSince: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
461
|
+
dueAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
454
462
|
}, z.core.$strict>;
|
|
455
463
|
messages: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
456
464
|
id: z.ZodString;
|
|
@@ -473,7 +481,7 @@ declare const ConversationDetailsSchema: z.ZodObject<{
|
|
|
473
481
|
name: z.ZodOptional<z.ZodString>;
|
|
474
482
|
contactId: z.ZodOptional<z.ZodString>;
|
|
475
483
|
}, z.core.$strict>>>;
|
|
476
|
-
createdAt: z.
|
|
484
|
+
createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
477
485
|
}, z.core.$strict>>>;
|
|
478
486
|
hasOlderMessages: z.ZodOptional<z.ZodBoolean>;
|
|
479
487
|
comments: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -487,7 +495,7 @@ declare const ConversationDetailsSchema: z.ZodObject<{
|
|
|
487
495
|
lastName: z.ZodOptional<z.ZodString>;
|
|
488
496
|
}, z.core.$strict>>;
|
|
489
497
|
isPinned: z.ZodOptional<z.ZodBoolean>;
|
|
490
|
-
postedAt: z.
|
|
498
|
+
postedAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
491
499
|
}, z.core.$strict>>>;
|
|
492
500
|
hasOlderComments: z.ZodOptional<z.ZodBoolean>;
|
|
493
501
|
mergedIntoConversationId: z.ZodOptional<z.ZodString>;
|
|
@@ -546,10 +554,10 @@ declare const UpdateConversationOutputSchema: z.ZodObject<{
|
|
|
546
554
|
}, z.core.$strict>>>;
|
|
547
555
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
548
556
|
isSnoozed: z.ZodOptional<z.ZodBoolean>;
|
|
549
|
-
createdAt: z.
|
|
550
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.
|
|
551
|
-
waitingSince: z.ZodOptional<z.ZodNullable<z.
|
|
552
|
-
dueAt: z.ZodOptional<z.ZodNullable<z.
|
|
557
|
+
createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
558
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
559
|
+
waitingSince: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
560
|
+
dueAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
553
561
|
}, z.core.$strict>;
|
|
554
562
|
wasAlreadyApplied: z.ZodOptional<z.ZodBoolean>;
|
|
555
563
|
}, z.core.$strict>;
|
|
@@ -573,7 +581,7 @@ declare const ContactSchema: z.ZodObject<{
|
|
|
573
581
|
}, z.core.$strict>>>;
|
|
574
582
|
listNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
575
583
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
576
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.
|
|
584
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
577
585
|
}, z.core.$strict>;
|
|
578
586
|
/** Runtime validator for FindContactByEmailOutput. */
|
|
579
587
|
declare const FindContactByEmailOutputSchema: z.ZodObject<{
|
|
@@ -587,7 +595,7 @@ declare const FindContactByEmailOutputSchema: z.ZodObject<{
|
|
|
587
595
|
}, z.core.$strict>>>;
|
|
588
596
|
listNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
589
597
|
isPrivate: z.ZodOptional<z.ZodBoolean>;
|
|
590
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.
|
|
598
|
+
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
591
599
|
}, z.core.$strict>>>;
|
|
592
600
|
}, z.core.$strict>;
|
|
593
601
|
|
|
@@ -618,4 +626,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
|
|
|
618
626
|
/** Bind scripted operations to a named connection. */
|
|
619
627
|
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
620
628
|
|
|
621
|
-
export {
|
|
629
|
+
export { ReplyToConversationInputSchema as A, SearchConversationsInputSchema as B, Connection as C, SearchConversationsOutputSchema as D, TagSchema as E, type FindContactByEmailInput as F, type GetConversationInput as G, type Teammate as H, TeammateSchema as I, UpdateConversationInputSchema as J, UpdateConversationOutputSchema as K, decodeCredentials as L, type Message as M, isCredentialMaterialError as N, type Operations as O, newConnection as P, newConnectionWithOperations as Q, type ReplyToConversationInput as R, type SearchConversationsInput as S, type Tag as T, type UpdateConversationInput as U, type FindContactByEmailOutput as a, type ConversationDetails as b, type ConversationReply as c, type SearchConversationsOutput as d, type UpdateConversationOutput as e, type Config as f, type Credentials as g, type Comment as h, CommentSchema as i, ConfigSchema as j, type Contact as k, type ContactHandle as l, ContactHandleSchema as m, ContactSchema as n, type Conversation as o, ConversationDetailsSchema as p, ConversationReplySchema as q, ConversationSchema as r, CredentialMaterialError as s, type CredentialSource as t, FindContactByEmailInputSchema as u, FindContactByEmailOutputSchema as v, GetConversationInputSchema as w, MessageSchema as x, type Recipient as y, RecipientSchema as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FindContactByEmailInput, a as FindContactByEmailOutput, C as Connection, G as GetConversationInput, b as ConversationDetails, R as ReplyToConversationInput, c as ConversationReply, S as SearchConversationsInput, d as SearchConversationsOutput, U as UpdateConversationInput, e as UpdateConversationOutput, O as Operations, f as Config, g as Credentials } from './connection-
|
|
2
|
-
export { h as Comment, i as CommentSchema, j as ConfigSchema, k as Contact, l as ContactHandle, m as ContactHandleSchema, n as ContactSchema, o as Conversation, p as ConversationDetailsSchema, q as ConversationReplySchema, r as ConversationSchema, s as
|
|
1
|
+
import { F as FindContactByEmailInput, a as FindContactByEmailOutput, C as Connection, G as GetConversationInput, b as ConversationDetails, R as ReplyToConversationInput, c as ConversationReply, S as SearchConversationsInput, d as SearchConversationsOutput, U as UpdateConversationInput, e as UpdateConversationOutput, O as Operations, f as Config, g as Credentials } from './connection-Cn_WglIz.js';
|
|
2
|
+
export { h as Comment, i as CommentSchema, j as ConfigSchema, k as Contact, l as ContactHandle, m as ContactHandleSchema, n as ContactSchema, o as Conversation, p as ConversationDetailsSchema, q as ConversationReplySchema, r as ConversationSchema, s as CredentialMaterialError, t as CredentialSource, u as FindContactByEmailInputSchema, v as FindContactByEmailOutputSchema, w as GetConversationInputSchema, M as Message, x as MessageSchema, y as Recipient, z as RecipientSchema, A as ReplyToConversationInputSchema, B as SearchConversationsInputSchema, D as SearchConversationsOutputSchema, T as Tag, E as TagSchema, H as Teammate, I as TeammateSchema, J as UpdateConversationInputSchema, K as UpdateConversationOutputSchema, L as decodeCredentials, N as isCredentialMaterialError, P as newConnection, Q as newConnectionWithOperations } from './connection-Cn_WglIz.js';
|
|
3
3
|
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
4
|
import { QueryDefinition, MutationDefinition, QueryStepConfig, Query, QueryResult, MutationStepConfig, Mutation, MutationResult, QueryStep, MutationStep, Call, QueryAttempt, MutationAttempt, CredentialProvider, Failure, ReceiptDraft } from '@superdurable/connectors-sdk';
|
|
5
5
|
import { StepTarget } from '@superdurable/dex';
|
|
@@ -73,13 +73,13 @@ declare const ReplyToConversationBranch: {
|
|
|
73
73
|
};
|
|
74
74
|
/** Front accepted the reply for delivery or created the comment. */
|
|
75
75
|
declare const ReplyToConversationBranchReplied: "replied";
|
|
76
|
-
/** The conversation does not exist
|
|
76
|
+
/** The conversation does not exist or is not visible to the API token (HTTP 404); nothing was sent. A merged conversation's 301 is an unknown outcome instead. */
|
|
77
77
|
declare const ReplyToConversationBranchNotFound: "notFound";
|
|
78
78
|
/** Front conclusively rejected the reply or comment, such as a token without send permission or an unknown author; nothing was sent. */
|
|
79
79
|
declare const ReplyToConversationBranchProviderRejected: "providerRejected";
|
|
80
|
-
/** The reply or comment may exist after
|
|
80
|
+
/** The reply or comment may exist: the send cap is reached after answers that were lost, late, 409, a 3xx such as a merged conversation's 301, an unlisted status, an ambiguous server error, or a refusal with an unreadable body; Front accepted it with a 2xx that carries no usable provider ID; a refusal or a reconnection requirement follows a possible earlier send; or an accepted write could not be read back, such as after a terminal credential failure or a deleted comment. Without a provider ID, an unknown outcome is resent while the cap allows; a 2xx is never resent. */
|
|
81
81
|
declare const ReplyToConversationBranchUncertain: "uncertain";
|
|
82
|
-
/** Local input, connection credentials that require reauthorization or are unusable before
|
|
82
|
+
/** Local input, connection credentials that require reauthorization or are unusable before a first send, or the connector definition is invalid; transient credential failures Retry. */
|
|
83
83
|
declare const ReplyToConversationBranchDefect: "defect";
|
|
84
84
|
/** Manifest definition for replyToConversation. */
|
|
85
85
|
declare const ReplyToConversationDefinition: MutationDefinition;
|
|
@@ -103,9 +103,9 @@ declare const UpdateConversationBranchUpdated: "updated";
|
|
|
103
103
|
declare const UpdateConversationBranchNotFound: "notFound";
|
|
104
104
|
/** Front conclusively rejected a change, such as an unknown teammate, tag, or ticket status; changes sent before it stay applied. */
|
|
105
105
|
declare const UpdateConversationBranchProviderRejected: "providerRejected";
|
|
106
|
-
/**
|
|
106
|
+
/** Declared for compatibility and no longer selected: an earlier attempt's change may have applied, so a malformed or oversized conversation on any read is retried. */
|
|
107
107
|
declare const UpdateConversationBranchInvalidResponse: "invalidResponse";
|
|
108
|
-
/** Local input, connection configuration, or connector definition is invalid. */
|
|
108
|
+
/** Local input, connection configuration, or connector definition is invalid, or the connection needs reconnection on the first attempt; a transient credential failure, or one after an earlier attempt, Retries. */
|
|
109
109
|
declare const UpdateConversationBranchDefect: "defect";
|
|
110
110
|
/** Manifest definition for updateConversation. */
|
|
111
111
|
declare const UpdateConversationDefinition: MutationDefinition;
|
|
@@ -194,13 +194,13 @@ interface ReplyToConversationStepConfig<StepInput, OperationInput = ReplyToConve
|
|
|
194
194
|
connectionName: string;
|
|
195
195
|
/** Front accepted the reply for delivery or created the comment. */
|
|
196
196
|
replied: StepTarget<MutationResult<OperationOutput>>;
|
|
197
|
-
/** The conversation does not exist
|
|
197
|
+
/** The conversation does not exist or is not visible to the API token (HTTP 404); nothing was sent. A merged conversation's 301 is an unknown outcome instead. */
|
|
198
198
|
notFound?: StepTarget<MutationResult<OperationOutput>>;
|
|
199
199
|
/** Front conclusively rejected the reply or comment, such as a token without send permission or an unknown author; nothing was sent. */
|
|
200
200
|
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
201
|
-
/** The reply or comment may exist after
|
|
201
|
+
/** The reply or comment may exist: the send cap is reached after answers that were lost, late, 409, a 3xx such as a merged conversation's 301, an unlisted status, an ambiguous server error, or a refusal with an unreadable body; Front accepted it with a 2xx that carries no usable provider ID; a refusal or a reconnection requirement follows a possible earlier send; or an accepted write could not be read back, such as after a terminal credential failure or a deleted comment. Without a provider ID, an unknown outcome is resent while the cap allows; a 2xx is never resent. */
|
|
202
202
|
uncertain?: StepTarget<MutationResult<OperationOutput>>;
|
|
203
|
-
/** Local input, connection credentials that require reauthorization or are unusable before
|
|
203
|
+
/** Local input, connection credentials that require reauthorization or are unusable before a first send, or the connector definition is invalid; transient credential failures Retry. */
|
|
204
204
|
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
205
205
|
}
|
|
206
206
|
/** Build the replyToConversation Step from a named connection. */
|
|
@@ -219,10 +219,12 @@ interface UpdateConversationStepConfig<StepInput, OperationInput = UpdateConvers
|
|
|
219
219
|
notFound?: StepTarget<MutationResult<OperationOutput>>;
|
|
220
220
|
/** Front conclusively rejected a change, such as an unknown teammate, tag, or ticket status; changes sent before it stay applied. */
|
|
221
221
|
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
222
|
-
/**
|
|
222
|
+
/** Declared for compatibility and no longer selected: an earlier attempt's change may have applied, so a malformed or oversized conversation on any read is retried. */
|
|
223
223
|
invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
|
|
224
|
-
/** Local input, connection configuration, or connector definition is invalid. */
|
|
224
|
+
/** Local input, connection configuration, or connector definition is invalid, or the connection needs reconnection on the first attempt; a transient credential failure, or one after an earlier attempt, Retries. */
|
|
225
225
|
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
226
|
+
/** Accepted for compatibility; ignored because the operation is safe to repeat. */
|
|
227
|
+
maxSends?: number;
|
|
226
228
|
}
|
|
227
229
|
/** Build the updateConversation Step from a named connection. */
|
|
228
230
|
declare function newUpdateConversationStep<StepInput, OperationInput = UpdateConversationInput, OperationOutput = UpdateConversationOutput>(configuration: UpdateConversationStepConfig<StepInput, OperationInput, OperationOutput>): MutationStep<StepInput, OperationInput, OperationOutput>;
|
|
@@ -279,7 +281,7 @@ declare class FindContactByEmailOperation implements Query<FindContactByEmailInp
|
|
|
279
281
|
declare class UpdateConversationOperation implements Mutation<UpdateConversationInput, UpdateConversationOutput> {
|
|
280
282
|
private readonly client;
|
|
281
283
|
/** Bind one client. */ constructor(client: FrontClient);
|
|
282
|
-
/** Return the manifest definition. */ definition(): _superdurable_connectors_sdk.
|
|
284
|
+
/** Return the manifest definition. */ definition(): _superdurable_connectors_sdk.MutationDefinition;
|
|
283
285
|
/** Stable call identity; writes set absolute values. */ idempotencyKey(callId: string): string;
|
|
284
286
|
/** Read, plan writes, and confirm the result. */
|
|
285
287
|
invoke(call: Call, input: UpdateConversationInput): Promise<MutationAttempt<UpdateConversationOutput>>;
|
|
@@ -288,12 +290,17 @@ declare class UpdateConversationOperation implements Mutation<UpdateConversation
|
|
|
288
290
|
declare class ReplyToConversationOperation implements Mutation<ReplyToConversationInput, ConversationReply> {
|
|
289
291
|
private readonly client;
|
|
290
292
|
/** Bind one client. */ constructor(client: FrontClient);
|
|
291
|
-
/** Return the manifest definition. */ definition(): _superdurable_connectors_sdk.
|
|
293
|
+
/** Return the manifest definition. */ definition(): _superdurable_connectors_sdk.MutationDefinition;
|
|
292
294
|
/** Stable call identity, recorded in the receipt. */ idempotencyKey(callId: string): string;
|
|
293
295
|
/** Send once with a durable claim, or read back an accepted provider ID. */
|
|
294
296
|
invoke(call: Call, input: ReplyToConversationInput): Promise<MutationAttempt<ConversationReply>>;
|
|
295
297
|
private readBack;
|
|
298
|
+
/** Only a definite refusal selects a refusal branch; any other outcome resends while the send cap allows. */
|
|
296
299
|
private classifySend;
|
|
300
|
+
/** Retry an unknown outcome while the send cap allows another send, else select uncertain. */
|
|
301
|
+
private resendOrUncertain;
|
|
302
|
+
/** Select a refusal branch only when no earlier send of this call may have applied. */
|
|
303
|
+
private reject;
|
|
297
304
|
private uncertain;
|
|
298
305
|
}
|
|
299
306
|
/** Build the ordered search filters Front expects. */
|
|
@@ -315,6 +322,7 @@ interface FrontExchange {
|
|
|
315
322
|
/** Bounded HTTP response, when one arrived. */ response?: ProviderResponse;
|
|
316
323
|
/** Secret-safe failure for unsuccessful exchanges. */ failure?: Failure;
|
|
317
324
|
/** Provider-directed delay for a safe retry, in milliseconds. */ retryAfterMs: number;
|
|
325
|
+
/** A non-2xx body was oversized, failed to read, or reflected the token, so a write cannot rule out acceptance. */ isErrorBodyUnreadable?: boolean;
|
|
318
326
|
}
|
|
319
327
|
/** Transport replacement for deterministic provider tests. */
|
|
320
328
|
type FrontRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ConversationDetailsSchema,
|
|
9
9
|
ConversationReplySchema,
|
|
10
10
|
ConversationSchema,
|
|
11
|
+
CredentialMaterialError,
|
|
11
12
|
FindContactByEmailBranch,
|
|
12
13
|
FindContactByEmailBranchDefect,
|
|
13
14
|
FindContactByEmailBranchFound,
|
|
@@ -61,10 +62,12 @@ import {
|
|
|
61
62
|
UpdateConversationInputSchema,
|
|
62
63
|
UpdateConversationMetadata,
|
|
63
64
|
UpdateConversationOutputSchema,
|
|
65
|
+
decodeCredentials,
|
|
66
|
+
isCredentialMaterialError,
|
|
64
67
|
newConnection,
|
|
65
68
|
newConnectionWithOperations,
|
|
66
69
|
newProjectConnection
|
|
67
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-V55LK3PU.js";
|
|
68
71
|
|
|
69
72
|
// src/generated/steps.ts
|
|
70
73
|
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
@@ -102,7 +105,7 @@ function newReplyToConversationStep(configuration) {
|
|
|
102
105
|
] });
|
|
103
106
|
}
|
|
104
107
|
function newUpdateConversationStep(configuration) {
|
|
105
|
-
const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
108
|
+
const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
|
|
106
109
|
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
107
110
|
return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateConversation(), connection: connection.reference, branches: [
|
|
108
111
|
goToBranch("updated", updated),
|
|
@@ -129,11 +132,12 @@ import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
|
129
132
|
import { z } from "zod";
|
|
130
133
|
|
|
131
134
|
// src/client.ts
|
|
132
|
-
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, ProviderTransportError, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
135
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, ProviderStalledError, ProviderTransportError, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
133
136
|
import { ReauthorizationRequiredError, SecretString, resolveCredentialAfterRejection } from "@superdurable/connectors-sdk";
|
|
137
|
+
import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
|
|
134
138
|
|
|
135
139
|
// src/operations.ts
|
|
136
|
-
import { newMutationBranch, newMutationRetry, newMutationUncertain, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
140
|
+
import { definitionMaxSends, newMutationBranch, newMutationRetry, newMutationUncertain, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
137
141
|
import { newFence } from "@superdurable/connectors-sdk/singledispatch";
|
|
138
142
|
|
|
139
143
|
// src/wire.ts
|
|
@@ -471,32 +475,37 @@ var UpdateConversationOperation = class {
|
|
|
471
475
|
return mutationFailure(this.client, "updateConversation", "defect", zero, {}, "VALIDATION", errorMessage(error));
|
|
472
476
|
}
|
|
473
477
|
const selected = await this.client.resolveToken(call);
|
|
478
|
+
if (!("token" in selected) && !selected.terminal) return newMutationRetry(fail(this.client, "updateConversation", "AVAILABILITY", "Front credentials were temporarily unavailable; nothing was written in this attempt"));
|
|
479
|
+
if (!("token" in selected) && call.context.attempt > 1) return newMutationRetry(fail(this.client, "updateConversation", "AUTHENTICATION", "Reconnect the Front connection; an earlier attempt may have written some changes"));
|
|
474
480
|
if (!("token" in selected)) return newMutationBranch("defect", zero, {}, selected.failure);
|
|
475
481
|
const path = `/conversations/${input.conversationId}`;
|
|
476
482
|
const receipt = this.client.receipt(call, input.conversationId);
|
|
477
|
-
const read = async () => {
|
|
483
|
+
const read = async (isAfterWrite) => {
|
|
478
484
|
const result = await this.client.exchange(call, selected.token, "updateConversation", { method: "GET", path });
|
|
485
|
+
if (isAfterWrite && (result.outcome === "invalid" || result.outcome === "rejected")) return { attempt: newMutationRetry({ ...result.failure, message: `Front accepted the change but its read-back failed: ${result.failure.message}` }, result.retryAfterMs) };
|
|
486
|
+
if (!isAfterWrite && isUnknownConversationRead(result)) return { attempt: newMutationRetry(result.failure, result.retryAfterMs) };
|
|
479
487
|
if (result.outcome !== "succeeded") return { attempt: classifyUpdate(result, zero, receipt) };
|
|
480
488
|
try {
|
|
481
489
|
const value = conversation(decode(result.response.body));
|
|
482
490
|
if (value.id !== input.conversationId) throw new Error("Front returned another conversation");
|
|
483
491
|
return { conversation: value };
|
|
484
492
|
} catch (error) {
|
|
485
|
-
|
|
493
|
+
const prefix = isAfterWrite ? "Front accepted the change but returned an invalid conversation" : "Front returned an invalid conversation";
|
|
494
|
+
return { attempt: newMutationRetry(fail(this.client, "updateConversation", "PROTOCOL", `${prefix}: ${errorMessage(error)}`)) };
|
|
486
495
|
}
|
|
487
496
|
};
|
|
488
|
-
const initial = await read();
|
|
497
|
+
const initial = await read(false);
|
|
489
498
|
if ("attempt" in initial) return initial.attempt;
|
|
490
499
|
const writes = planWrites(input, initial.conversation, path);
|
|
491
500
|
for (let index = 0; index < writes.length; index++) {
|
|
492
501
|
const result = await this.client.exchange(call, selected.token, "updateConversation", writes[index]);
|
|
493
|
-
if (result.
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
502
|
+
if (result.isErrorBodyUnreadable && !isRetry(result)) return newMutationRetry(result.failure, result.retryAfterMs);
|
|
503
|
+
if (result.outcome === "notFound") result.outcome = "rejected";
|
|
504
|
+
if (result.outcome === "invalid" || result.outcome === "rejected" && !definiteRefusalStatuses.has(result.response?.status ?? 0)) return newMutationRetry(result.failure, result.retryAfterMs);
|
|
505
|
+
if (result.outcome !== "succeeded") return classifyUpdate(result, zero, receipt, index > 0 ? "; writes sent before it stay applied" : "");
|
|
497
506
|
}
|
|
498
507
|
if (!writes.length) return newMutationBranch("updated", { conversation: initial.conversation, wasAlreadyApplied: true }, receipt);
|
|
499
|
-
const final = await read();
|
|
508
|
+
const final = await read(true);
|
|
500
509
|
if ("attempt" in final) return final.attempt;
|
|
501
510
|
if (planWrites(input, final.conversation, path).length) return newMutationRetry(fail(this.client, "updateConversation", "AVAILABILITY", "Front accepted the change but does not show it on the conversation yet"));
|
|
502
511
|
return newMutationBranch("updated", { conversation: final.conversation }, receipt);
|
|
@@ -524,16 +533,23 @@ var ReplyToConversationOperation = class {
|
|
|
524
533
|
} catch (error) {
|
|
525
534
|
return mutationFailure(this.client, "replyToConversation", "defect", output, {}, "VALIDATION", errorMessage(error));
|
|
526
535
|
}
|
|
536
|
+
const operationMaxSends = definitionMaxSends(ReplyToConversationDefinition);
|
|
527
537
|
let fence;
|
|
528
538
|
try {
|
|
529
|
-
fence = newFence(call, 3e4);
|
|
539
|
+
fence = newFence(call, 3e4, { maxSends: operationMaxSends });
|
|
530
540
|
} catch (error) {
|
|
531
541
|
return mutationFailure(this.client, "replyToConversation", "defect", output, {}, "LOCAL_DEFECT", errorMessage(error));
|
|
532
542
|
}
|
|
533
543
|
const decision = fence.decide();
|
|
534
|
-
if (decision.kind === "failClosed") return this.
|
|
535
|
-
if (decision.kind === "readBackRequired") return this.readBack(call, input, output, decision.marker);
|
|
544
|
+
if (decision.kind === "failClosed") return newMutationRetry(fail(this.client, "replyToConversation", "AVAILABILITY", "the dispatch checkpoint could not be read; nothing was sent in this attempt"));
|
|
545
|
+
if (decision.kind === "readBackRequired" || decision.kind === "readBackThenResendAllowed" && decision.marker?.providerId) return this.readBack(call, input, output, decision.marker);
|
|
546
|
+
const priorSends = decision.priorSendUpperBound ?? 0;
|
|
547
|
+
const permit = { fence, isFirstSend: priorSends === 0, canResendUnknownOutcome: priorSends + 1 < effectiveMaxSends(call, operationMaxSends) };
|
|
536
548
|
const selected = await this.client.resolveToken(call);
|
|
549
|
+
if (!("token" in selected) && !permit.isFirstSend) {
|
|
550
|
+
if (selected.terminal) return this.uncertain(call, output, "AUTHENTICATION", "an earlier attempt may have sent the reply or comment, and the connection needs reconnection to resend it");
|
|
551
|
+
return newMutationRetry(fail(this.client, "replyToConversation", "AVAILABILITY", "Front credentials were temporarily unavailable; nothing was sent in this attempt"));
|
|
552
|
+
}
|
|
537
553
|
if (!("token" in selected)) {
|
|
538
554
|
try {
|
|
539
555
|
await fence.recordNotSent();
|
|
@@ -551,7 +567,7 @@ var ReplyToConversationOperation = class {
|
|
|
551
567
|
} catch {
|
|
552
568
|
return newMutationRetry(fail(this.client, "replyToConversation", "AVAILABILITY", "the reply was not dispatched; retry after the checkpoint or attempt budget recovers"));
|
|
553
569
|
}
|
|
554
|
-
return this.classifySend(call, output, result,
|
|
570
|
+
return this.classifySend(call, output, result, permit, selected.token);
|
|
555
571
|
}
|
|
556
572
|
async readBack(call, input, output, marker) {
|
|
557
573
|
if (!marker || marker.callId !== call.id || !marker.providerId) return this.uncertain(call, output, marker?.state === "claimed" ? "TRANSPORT" : "AVAILABILITY", "an earlier attempt may have sent the reply or comment without a provider ID");
|
|
@@ -564,8 +580,8 @@ var ReplyToConversationOperation = class {
|
|
|
564
580
|
if (isRetry(result) || result.outcome === "notFound" && !input.isInternalNote) return newMutationRetry(result.failure, result.retryAfterMs);
|
|
565
581
|
return newMutationUncertain(output, fail(this.client, "replyToConversation", result.failure.kind, "Front could not confirm an earlier accepted reply or comment"), this.client.receipt(call, marker.providerId));
|
|
566
582
|
}
|
|
567
|
-
|
|
568
|
-
|
|
583
|
+
/** Only a definite refusal selects a refusal branch; any other outcome resends while the send cap allows. */
|
|
584
|
+
async classifySend(call, output, result, permit, rejectedToken) {
|
|
569
585
|
if (result.response && result.response.status >= 200 && result.response.status < 300) {
|
|
570
586
|
let identity = "";
|
|
571
587
|
try {
|
|
@@ -573,40 +589,58 @@ var ReplyToConversationOperation = class {
|
|
|
573
589
|
identity = string(output.isInternalNote ? answer.id : answer.message_uid);
|
|
574
590
|
} catch {
|
|
575
591
|
}
|
|
576
|
-
if (!(output.isInternalNote ? identifiers.comment : /^[A-Za-z0-9]{1,64}$/).test(identity)) return this.uncertain(call, output, result.failure?.kind ?? "PROTOCOL", "Front accepted the reply or comment
|
|
592
|
+
if (!(output.isInternalNote ? identifiers.comment : /^[A-Za-z0-9]{1,64}$/).test(identity)) return this.uncertain(call, output, result.failure?.kind ?? "PROTOCOL", "Front accepted the reply or comment but answered without a usable provider ID; it is not resent");
|
|
577
593
|
try {
|
|
578
|
-
await fence.recordProviderId(identity);
|
|
594
|
+
await permit.fence.recordProviderId(identity);
|
|
579
595
|
} catch {
|
|
580
596
|
}
|
|
581
597
|
return newMutationBranch("replied", { ...output, ...output.isInternalNote ? { commentId: identity } : { messageUid: identity } }, this.client.receipt(call, identity));
|
|
582
598
|
}
|
|
583
|
-
|
|
599
|
+
const status = result.response?.status ?? 0;
|
|
600
|
+
if (result.isErrorBodyUnreadable && (result.outcome === "rejected" || result.outcome === "notFound" || result.outcome === "merged")) return this.resendOrUncertain(call, output, permit, { ...result.failure, message: `${result.failure.message}; its error body could not be read, so the reply or comment may exist` });
|
|
601
|
+
if (result.outcome === "defect") return permit.isFirstSend ? this.reject(call, output, permit, "defect", result.failure) : newMutationUncertain(output, result.failure, this.client.receipt(call, output.conversationId));
|
|
602
|
+
if (result.outcome === "notSent" || result.outcome === "rateLimited" || result.outcome === "unconfirmed" && status === 503) {
|
|
584
603
|
try {
|
|
585
|
-
await fence.recordCanResend();
|
|
604
|
+
await permit.fence.recordCanResend();
|
|
586
605
|
} catch {
|
|
587
|
-
return newMutationRetry(fail(this.client, "replyToConversation", "AVAILABILITY", "the resend checkpoint failed"));
|
|
588
606
|
}
|
|
589
607
|
return newMutationRetry(result.failure, result.retryAfterMs);
|
|
590
608
|
}
|
|
591
|
-
if (result.outcome === "unconfirmed") return
|
|
592
|
-
if (result.outcome === "
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
return newMutationRetry(fail(this.client, "replyToConversation", "
|
|
609
|
+
if (result.outcome === "unconfirmed") return this.resendOrUncertain(call, output, permit, { ...result.failure, message: `${result.failure.message}; the reply or comment may exist` }, result.retryAfterMs);
|
|
610
|
+
if (result.outcome === "merged") {
|
|
611
|
+
const merged = mergedID(result);
|
|
612
|
+
return this.resendOrUncertain(call, output, permit, { ...result.failure, message: merged ? `the conversation was merged into ${merged}; the reply or comment may exist` : `${result.failure.message}; the reply or comment may exist` });
|
|
613
|
+
}
|
|
614
|
+
if (result.outcome === "notFound" && status === 404) return this.reject(call, output, permit, "notFound", result.failure);
|
|
615
|
+
if (result.outcome === "rejected" && status === 401) {
|
|
616
|
+
const replacement = await this.client.replacementAfterRejection(call, rejectedToken);
|
|
617
|
+
if (replacement === "replacement") {
|
|
618
|
+
try {
|
|
619
|
+
await permit.fence.recordCanResend();
|
|
620
|
+
} catch {
|
|
621
|
+
return newMutationRetry(fail(this.client, "replyToConversation", "AVAILABILITY", "the credential resend checkpoint failed"));
|
|
604
622
|
}
|
|
605
|
-
return
|
|
623
|
+
return newMutationRetry(fail(this.client, "replyToConversation", "AUTHENTICATION", "Front rejected the prior API token; retry with its replacement"));
|
|
606
624
|
}
|
|
607
|
-
return
|
|
625
|
+
return this.reject(call, output, permit, "providerRejected", fail(this.client, "replyToConversation", "AUTHENTICATION", replacement === "reconnect" ? "Front rejected the API token (HTTP 401); reconnect the Front connection" : "Front rejected the API token (HTTP 401); credential refresh is temporarily unavailable"));
|
|
608
626
|
}
|
|
609
|
-
return this.
|
|
627
|
+
if (result.outcome === "rejected" && definiteRefusalStatuses.has(status)) return this.reject(call, output, permit, "providerRejected", result.failure);
|
|
628
|
+
if (result.outcome === "rejected" || result.outcome === "notFound") return this.resendOrUncertain(call, output, permit, result.failure);
|
|
629
|
+
return this.resendOrUncertain(call, output, permit, fail(this.client, "replyToConversation", result.failure?.kind ?? "PROTOCOL", `${result.failure?.message ?? "the Front answer is invalid"}; the reply or comment may exist`));
|
|
630
|
+
}
|
|
631
|
+
/** Retry an unknown outcome while the send cap allows another send, else select uncertain. */
|
|
632
|
+
resendOrUncertain(call, output, permit, cause, retryAfterMs = 0) {
|
|
633
|
+
return permit.canResendUnknownOutcome ? newMutationRetry(cause, retryAfterMs) : newMutationUncertain(output, cause, this.client.receipt(call, output.conversationId));
|
|
634
|
+
}
|
|
635
|
+
/** Select a refusal branch only when no earlier send of this call may have applied. */
|
|
636
|
+
async reject(call, output, permit, branch, cause) {
|
|
637
|
+
if (!permit.isFirstSend) return newMutationUncertain(output, cause, this.client.receipt(call, output.conversationId));
|
|
638
|
+
try {
|
|
639
|
+
await permit.fence.recordCanResend();
|
|
640
|
+
} catch {
|
|
641
|
+
return newMutationRetry(fail(this.client, "replyToConversation", "AVAILABILITY", "the refusal checkpoint failed"));
|
|
642
|
+
}
|
|
643
|
+
return newMutationBranch(branch, output, branch === "defect" ? {} : this.client.receipt(call, output.conversationId), cause);
|
|
610
644
|
}
|
|
611
645
|
uncertain(call, output, kind, message2) {
|
|
612
646
|
return newMutationUncertain(output, fail(this.client, "replyToConversation", kind, message2), this.client.receipt(call, output.conversationId));
|
|
@@ -665,6 +699,15 @@ function buildConversationSearchQuery(input) {
|
|
|
665
699
|
if (!terms.length) throw new Error("set text or at least one filter; Front has no empty search");
|
|
666
700
|
return terms.join(" ");
|
|
667
701
|
}
|
|
702
|
+
var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
|
|
703
|
+
function isUnknownConversationRead(result) {
|
|
704
|
+
if (result.outcome === "invalid") return true;
|
|
705
|
+
if (result.outcome !== "rejected" && result.outcome !== "notFound") return false;
|
|
706
|
+
return !definiteRefusalStatuses.has(result.response?.status ?? 0) || result.isErrorBodyUnreadable === true;
|
|
707
|
+
}
|
|
708
|
+
function effectiveMaxSends(call, operationMaxSends) {
|
|
709
|
+
return operationMaxSends >= 2 ? call.maxSendsOverride ?? operationMaxSends : 1;
|
|
710
|
+
}
|
|
668
711
|
function classifyUpdate(result, output, receipt, note = "") {
|
|
669
712
|
if (isRetry(result)) return newMutationRetry(result.failure, result.retryAfterMs);
|
|
670
713
|
const branch = result.outcome === "merged" || result.outcome === "notFound" ? "notFound" : result.outcome === "invalid" ? "invalidResponse" : result.outcome === "defect" ? "defect" : "providerRejected";
|
|
@@ -707,6 +750,9 @@ function buildReplyHTML(value) {
|
|
|
707
750
|
var defaultEndpoint = "https://api2.frontapp.com";
|
|
708
751
|
var InvalidFrontTokenError = class extends Error {
|
|
709
752
|
};
|
|
753
|
+
function isTerminalCredentialError(error) {
|
|
754
|
+
return error instanceof InvalidFrontTokenError || error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || isCredentialMaterialError(error);
|
|
755
|
+
}
|
|
710
756
|
var FrontClient = class {
|
|
711
757
|
/** Validated Front API base URL. */
|
|
712
758
|
endpoint;
|
|
@@ -753,7 +799,7 @@ var FrontClient = class {
|
|
|
753
799
|
if (!isHeaderSafeCredential(token)) throw new InvalidFrontTokenError();
|
|
754
800
|
return { token };
|
|
755
801
|
} catch (error) {
|
|
756
|
-
return { failure: this.failure("AUTHENTICATION", call.operation.operationId, "the Front API token is unavailable, blank, or contains characters a header cannot carry"), terminal: error
|
|
802
|
+
return { failure: this.failure("AUTHENTICATION", call.operation.operationId, "the Front API token is unavailable, blank, or contains characters a header cannot carry"), terminal: isTerminalCredentialError(error) };
|
|
757
803
|
}
|
|
758
804
|
}
|
|
759
805
|
/** Ask a refresh-capable credential source for a replacement after HTTP 401. */
|
|
@@ -798,10 +844,11 @@ var FrontClient = class {
|
|
|
798
844
|
signal: request.signal ?? call.context.cancellationSignal
|
|
799
845
|
});
|
|
800
846
|
} catch (error) {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
}
|
|
847
|
+
const failedAfterHeaders = error instanceof BodyTooLargeError || error instanceof ProviderTransportError || error instanceof ProviderStalledError ? error : void 0;
|
|
848
|
+
const headersOnly = failedAfterHeaders?.status ? { status: failedAfterHeaders.status, headers: failedAfterHeaders.headers ?? {}, body: new Uint8Array() } : void 0;
|
|
849
|
+
if (headersOnly && (headersOnly.status < 200 || headersOnly.status >= 300)) return { ...this.classifyFailureStatus(headersOnly.status, headersOnly.headers, operation, headersOnly), isErrorBodyUnreadable: true };
|
|
850
|
+
if (error instanceof BodyTooLargeError) return { outcome: "invalid", ...headersOnly ? { response: headersOnly } : {}, failure: this.failure("RESPONSE_TOO_LARGE", operation, "the Front response exceeds the configured maxResponseBytes"), retryAfterMs: 0 };
|
|
851
|
+
if (headersOnly) return { outcome: "unconfirmed", response: headersOnly, failure: this.failure("TRANSPORT", operation, "the Front response could not be read"), retryAfterMs: 0 };
|
|
805
852
|
return { outcome: error instanceof ProviderTransportError && error.isProvablyNotSent ? "notSent" : "unconfirmed", failure: this.failure("TRANSPORT", operation, error instanceof ProviderTransportError && error.isProvablyNotSent ? "Front could not be reached; no request was sent" : "the Front request may have been sent, but no answer arrived"), retryAfterMs: 0 };
|
|
806
853
|
}
|
|
807
854
|
const status = response.status;
|
|
@@ -810,7 +857,8 @@ var FrontClient = class {
|
|
|
810
857
|
if (Buffer.from(response.body).includes(Buffer.from(token))) return { outcome: "invalid", response, failure: this.failure("PROTOCOL", operation, "the Front response reflected the API token"), retryAfterMs: 0 };
|
|
811
858
|
return { outcome: "succeeded", response, retryAfterMs: 0 };
|
|
812
859
|
}
|
|
813
|
-
|
|
860
|
+
const failed = this.classifyFailureStatus(status, response.headers, operation, response);
|
|
861
|
+
return token !== "" && Buffer.from(response.body).includes(Buffer.from(token)) ? { ...failed, isErrorBodyUnreadable: true } : failed;
|
|
814
862
|
}
|
|
815
863
|
classifyFailureStatus(status, headers, operation, response) {
|
|
816
864
|
let outcome = "rejected";
|
|
@@ -903,6 +951,7 @@ export {
|
|
|
903
951
|
ConversationDetailsSchema,
|
|
904
952
|
ConversationReplySchema,
|
|
905
953
|
ConversationSchema,
|
|
954
|
+
CredentialMaterialError,
|
|
906
955
|
FindContactByEmailBranch,
|
|
907
956
|
FindContactByEmailBranchDefect,
|
|
908
957
|
FindContactByEmailBranchFound,
|
|
@@ -964,6 +1013,8 @@ export {
|
|
|
964
1013
|
UpdateConversationOutputSchema,
|
|
965
1014
|
buildConversationSearchQuery,
|
|
966
1015
|
buildReplyHTML,
|
|
1016
|
+
decodeCredentials,
|
|
1017
|
+
isCredentialMaterialError,
|
|
967
1018
|
newConnection,
|
|
968
1019
|
newConnectionWithOperations,
|
|
969
1020
|
newFindContactByEmailStep,
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockQuery, MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
2
|
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
-
import { O as Operations, C as Connection, S as SearchConversationsInput, d as SearchConversationsOutput, G as GetConversationInput, b as ConversationDetails, R as ReplyToConversationInput, c as ConversationReply, U as UpdateConversationInput, e as UpdateConversationOutput, F as FindContactByEmailInput, a as FindContactByEmailOutput, h as Comment, k as Contact, l as ContactHandle, o as Conversation, M as Message,
|
|
3
|
+
import { O as Operations, C as Connection, S as SearchConversationsInput, d as SearchConversationsOutput, G as GetConversationInput, b as ConversationDetails, R as ReplyToConversationInput, c as ConversationReply, U as UpdateConversationInput, e as UpdateConversationOutput, F as FindContactByEmailInput, a as FindContactByEmailOutput, h as Comment, k as Contact, l as ContactHandle, o as Conversation, M as Message, y as Recipient, T as Tag, H as Teammate } from './connection-Cn_WglIz.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/** Go zero value for SearchConversationsInput in scripted cases. */
|
package/dist/mock.js
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
UpdateConversationInputSchema,
|
|
26
26
|
UpdateConversationOutputSchema,
|
|
27
27
|
newConnectionWithOperations
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-V55LK3PU.js";
|
|
29
29
|
|
|
30
30
|
// src/generated/mock.ts
|
|
31
31
|
import { branchCase, retryCase, uncertainCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-front",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Front conversation and contact operations for Dex Flows",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"./mock": {
|
|
27
27
|
"types": "./dist/mock.d.ts",
|
|
28
28
|
"import": "./dist/mock.js"
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"example:contact:start": "npm run build && tsx examples/find-contact/start.ts"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@superdurable/connectors-sdk": "0.
|
|
48
|
+
"@superdurable/connectors-sdk": "0.12.0",
|
|
48
49
|
"@superdurable/dex": ">=1.28.0",
|
|
49
50
|
"zod": "^4.1.0"
|
|
50
51
|
},
|