@mdbase-dev/connect-protocol 0.1.0-beta.100
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/LICENSE +21 -0
- package/dist/application-authorization.d.ts +32 -0
- package/dist/application-authorization.js +207 -0
- package/dist/capabilities.d.ts +73 -0
- package/dist/capabilities.js +92 -0
- package/dist/collection-setup.d.ts +90 -0
- package/dist/collection-setup.js +1 -0
- package/dist/compatibility.d.ts +37 -0
- package/dist/compatibility.js +65 -0
- package/dist/connect-problems.generated.d.ts +1388 -0
- package/dist/connect-problems.generated.js +574 -0
- package/dist/files.d.ts +269 -0
- package/dist/files.js +426 -0
- package/dist/index.d.ts +878 -0
- package/dist/index.js +94 -0
- package/dist/manifest.d.ts +62 -0
- package/dist/manifest.js +527 -0
- package/dist/mutation-fingerprint.d.ts +6 -0
- package/dist/mutation-fingerprint.js +116 -0
- package/dist/operations.d.ts +15 -0
- package/dist/operations.js +194 -0
- package/dist/type-packs.d.ts +133 -0
- package/dist/type-packs.js +30 -0
- package/package.json +42 -0
- package/schemas/application-capability-catalog.v1.json +40 -0
- package/schemas/application-capability-catalog.v2.json +68 -0
- package/schemas/catalog.json +17 -0
- package/schemas/connect-problem.v1.schema.json +5132 -0
- package/schemas/connect-problems.v1.catalog.json +351 -0
- package/schemas/connect-protocol.v1.schema.json +800 -0
- package/schemas/data-contract.schema.json +163 -0
- package/schemas/encrypted-relay.v1.schema.json +63 -0
- package/schemas/encrypted-relay.v2.schema.json +63 -0
- package/schemas/encrypted-relay.v3.schema.json +64 -0
- package/schemas/files.v1.schema.json +507 -0
- package/schemas/interop/v0.1/action-cancellation.schema.json +6 -0
- package/schemas/interop/v0.1/action-invocation.schema.json +6 -0
- package/schemas/interop/v0.1/action-outcome.schema.json +6 -0
- package/schemas/interop/v0.1/action-provider-declaration.schema.json +6 -0
- package/schemas/interop/v0.1/action-request.schema.json +6 -0
- package/schemas/interop/v0.1/conformance-claim.schema.json +6 -0
- package/schemas/interop/v0.1/event-source-declaration.schema.json +6 -0
- package/schemas/interop/v0.1/event.schema.json +6 -0
- package/schemas/interop/v0.1/profile.schema.json +456 -0
- package/schemas/mdbase-app.legacy-v1.schema.json +405 -0
- package/schemas/mdbase-app.schema.json +381 -0
- package/schemas/mdbase-query.v0.3.schema.json +171 -0
- package/schemas/notification-webhook.v1.schema.json +56 -0
- package/schemas/operation-catalog.v1.json +42 -0
- package/schemas/operation-mutation-classification.v1.json +537 -0
- package/schemas/sync.v1.schema.json +483 -0
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
// Generated by scripts/generate-connect-problems.mjs. Do not edit directly.
|
|
2
|
+
export const CONNECT_PROBLEM_VERSION = 1;
|
|
3
|
+
export const CONNECT_PROBLEM_CATALOG = {
|
|
4
|
+
"access_denied": { category: "authorization", recovery: "reauthorize" },
|
|
5
|
+
"access_paused": { category: "availability", recovery: "resume_connector_access" },
|
|
6
|
+
"application_declaration_mismatch": { category: "authorization", recovery: "reauthorize" },
|
|
7
|
+
"application_identity_unavailable": { category: "compatibility", recovery: "upgrade_application" },
|
|
8
|
+
"approval_window_blocked": { category: "authorization", recovery: "reauthorize" },
|
|
9
|
+
"authority_authorization_changed": { category: "authorization", recovery: "reauthorize" },
|
|
10
|
+
"authorization_binding_incompatible": { category: "compatibility", recovery: "upgrade_application" },
|
|
11
|
+
"authorization_cancelled": { category: "cancellation", recovery: "none" },
|
|
12
|
+
"authorization_expired": { category: "authorization", recovery: "reauthorize" },
|
|
13
|
+
"authorization_replayed": { category: "integrity", recovery: "reauthorize" },
|
|
14
|
+
"browser_required": { category: "compatibility", recovery: "none" },
|
|
15
|
+
"callback_url_required": { category: "validation", recovery: "fix_request" },
|
|
16
|
+
"capability_contract_incompatible": { category: "compatibility", recovery: "upgrade_application" },
|
|
17
|
+
"change_cursor_reset": { category: "conflict", recovery: "refresh" },
|
|
18
|
+
"collection_access_denied": { category: "authorization", recovery: "reauthorize" },
|
|
19
|
+
"collection_configuration_invalid": { category: "validation", recovery: "repair_collection" },
|
|
20
|
+
"collection_contracts_missing": { category: "compatibility", recovery: "choose_collection" },
|
|
21
|
+
"collection_incompatible": { category: "compatibility", recovery: "choose_collection" },
|
|
22
|
+
"collection_invalid": { category: "validation", recovery: "repair_collection" },
|
|
23
|
+
"collection_kind_unsupported": { category: "compatibility", recovery: "choose_collection" },
|
|
24
|
+
"collection_mismatch": { category: "selection", recovery: "choose_collection" },
|
|
25
|
+
"collection_not_found": { category: "selection", recovery: "choose_collection" },
|
|
26
|
+
"collection_not_ready": { category: "selection", recovery: "choose_collection" },
|
|
27
|
+
"collection_not_selected": { category: "selection", recovery: "choose_collection" },
|
|
28
|
+
"collection_type_registry_invalid": { category: "validation", recovery: "repair_collection" },
|
|
29
|
+
"collection_version_unsupported": { category: "compatibility", recovery: "upgrade_collection" },
|
|
30
|
+
"concurrent_modification": { category: "conflict", recovery: "refresh" },
|
|
31
|
+
"connector_busy": { category: "availability", recovery: "retry" },
|
|
32
|
+
"connector_identity_changed": { category: "integrity", recovery: "reauthorize" },
|
|
33
|
+
"connector_offline": { category: "availability", recovery: "retry" },
|
|
34
|
+
"connector_upgrade_required": { category: "compatibility", recovery: "upgrade_connector" },
|
|
35
|
+
"cursor_capacity_exhausted": { category: "availability", recovery: "retry" },
|
|
36
|
+
"device_authorization_failed": { category: "authorization", recovery: "reauthorize" },
|
|
37
|
+
"direct_operation_rejected": { category: "authorization", recovery: "reauthorize" },
|
|
38
|
+
"discovery_failed": { category: "availability", recovery: "retry" },
|
|
39
|
+
"durable_mutation_unsupported": { category: "compatibility", recovery: "upgrade_connector" },
|
|
40
|
+
"encrypted_relay_rejected": { category: "authorization", recovery: "reauthorize" },
|
|
41
|
+
"encryption_required": { category: "authorization", recovery: "reauthorize" },
|
|
42
|
+
"expired_token": { category: "authorization", recovery: "reauthorize" },
|
|
43
|
+
"file_changed_during_move": { category: "conflict", recovery: "refresh" },
|
|
44
|
+
"file_changed_during_read": { category: "conflict", recovery: "refresh" },
|
|
45
|
+
"file_index_warming": { category: "availability", recovery: "retry" },
|
|
46
|
+
"file_move_failed": { category: "internal", recovery: "contact_support" },
|
|
47
|
+
"file_mutation_conflict": { category: "conflict", recovery: "resolve_conflict" },
|
|
48
|
+
"file_not_found": { category: "conflict", recovery: "refresh" },
|
|
49
|
+
"file_source_mismatch": { category: "conflict", recovery: "refresh" },
|
|
50
|
+
"file_upload_incomplete": { category: "conflict", recovery: "retry" },
|
|
51
|
+
"fresh_request_required": { category: "availability", recovery: "retry" },
|
|
52
|
+
"generation_expired": { category: "conflict", recovery: "refresh" },
|
|
53
|
+
"hosted_provider_unavailable": { category: "availability", recovery: "retry" },
|
|
54
|
+
"insufficient_access": { category: "authorization", recovery: "reauthorize" },
|
|
55
|
+
"invalid_application_authorization": { category: "validation", recovery: "fix_request" },
|
|
56
|
+
"invalid_application_manifest": { category: "validation", recovery: "fix_request" },
|
|
57
|
+
"invalid_callback": { category: "validation", recovery: "fix_request" },
|
|
58
|
+
"invalid_device_authorization_response": { category: "integrity", recovery: "contact_support" },
|
|
59
|
+
"invalid_encrypted_response": { category: "integrity", recovery: "contact_support" },
|
|
60
|
+
"invalid_loopback_url": { category: "validation", recovery: "fix_request" },
|
|
61
|
+
"invalid_mutation_id": { category: "validation", recovery: "fix_request" },
|
|
62
|
+
"invalid_operation_response": { category: "integrity", recovery: "contact_support" },
|
|
63
|
+
"invalid_path": { category: "validation", recovery: "fix_request" },
|
|
64
|
+
"invalid_preflight": { category: "conflict", recovery: "refresh" },
|
|
65
|
+
"invalid_push_payload": { category: "validation", recovery: "fix_request" },
|
|
66
|
+
"invalid_push_subscription": { category: "validation", recovery: "fix_request" },
|
|
67
|
+
"invalid_read_cursor": { category: "validation", recovery: "fix_request" },
|
|
68
|
+
"invalid_request": { category: "validation", recovery: "fix_request" },
|
|
69
|
+
"invalid_token_response": { category: "integrity", recovery: "contact_support" },
|
|
70
|
+
"legacy_scope_reauthorization_required": { category: "authorization", recovery: "reauthorize" },
|
|
71
|
+
"managed_fcm_not_declared": { category: "compatibility", recovery: "fix_request" },
|
|
72
|
+
"manifest_load_failed": { category: "availability", recovery: "retry" },
|
|
73
|
+
"manifest_required": { category: "validation", recovery: "fix_request" },
|
|
74
|
+
"missing_grant_key": { category: "authorization", recovery: "reauthorize" },
|
|
75
|
+
"mutation_recovery_expired": { category: "compatibility", recovery: "none" },
|
|
76
|
+
"mutation_request_conflict": { category: "conflict", recovery: "resolve_conflict" },
|
|
77
|
+
"no_pending_mutation": { category: "conflict", recovery: "refresh" },
|
|
78
|
+
"not_authorized": { category: "authorization", recovery: "reauthorize" },
|
|
79
|
+
"not_remote_authority": { category: "compatibility", recovery: "choose_collection" },
|
|
80
|
+
"notification_criterion_not_declared": { category: "validation", recovery: "fix_request" },
|
|
81
|
+
"notification_reauthorization_required": { category: "authorization", recovery: "reauthorize" },
|
|
82
|
+
"notification_registration_failed": { category: "availability", recovery: "retry" },
|
|
83
|
+
"notification_unregistration_failed": { category: "availability", recovery: "retry" },
|
|
84
|
+
"notifications_not_declared": { category: "compatibility", recovery: "fix_request" },
|
|
85
|
+
"notifications_unavailable": { category: "availability", recovery: "retry" },
|
|
86
|
+
"operation_cancelled": { category: "cancellation", recovery: "none" },
|
|
87
|
+
"operation_failed": { category: "internal", recovery: "contact_support" },
|
|
88
|
+
"operation_invalid": { category: "validation", recovery: "fix_request" },
|
|
89
|
+
"operation_outcome_unknown": { category: "conflict", recovery: "resolve_outcome" },
|
|
90
|
+
"path_occupied": { category: "conflict", recovery: "resolve_conflict" },
|
|
91
|
+
"pending_mutation_unresolved": { category: "conflict", recovery: "resolve_outcome" },
|
|
92
|
+
"query_snapshot_changed": { category: "conflict", recovery: "refresh" },
|
|
93
|
+
"rate_limited": { category: "availability", recovery: "retry" },
|
|
94
|
+
"reconnect_required": { category: "authorization", recovery: "reauthorize" },
|
|
95
|
+
"redirect_uri_required": { category: "validation", recovery: "fix_request" },
|
|
96
|
+
"reference_updates_unsupported": { category: "compatibility", recovery: "fix_request" },
|
|
97
|
+
"registry_backup_invalid": { category: "integrity", recovery: "contact_support" },
|
|
98
|
+
"registry_busy": { category: "availability", recovery: "retry" },
|
|
99
|
+
"registry_corrupt": { category: "integrity", recovery: "repair_collection" },
|
|
100
|
+
"registry_migration_failed": { category: "internal", recovery: "contact_support" },
|
|
101
|
+
"registry_schema_incompatible": { category: "compatibility", recovery: "upgrade_connector" },
|
|
102
|
+
"relay_authorization_expired": { category: "authorization", recovery: "reauthorize" },
|
|
103
|
+
"relay_unavailable": { category: "availability", recovery: "retry" },
|
|
104
|
+
"sandbox_unsupported": { category: "compatibility", recovery: "fix_request" },
|
|
105
|
+
"scope_denied": { category: "authorization", recovery: "reauthorize" },
|
|
106
|
+
"session_destroyed": { category: "cancellation", recovery: "none" },
|
|
107
|
+
"session_not_started": { category: "validation", recovery: "fix_request" },
|
|
108
|
+
"session_starting": { category: "availability", recovery: "retry" },
|
|
109
|
+
"stale_file_revision": { category: "conflict", recovery: "refresh" },
|
|
110
|
+
"storage_required": { category: "compatibility", recovery: "none" },
|
|
111
|
+
"sync_failed": { category: "availability", recovery: "retry" },
|
|
112
|
+
"temporarily_unavailable": { category: "availability", recovery: "retry" },
|
|
113
|
+
"timeout": { category: "availability", recovery: "retry" },
|
|
114
|
+
"token_exchange_failed": { category: "availability", recovery: "retry" },
|
|
115
|
+
"transport_protocol_incompatible": { category: "compatibility", recovery: "upgrade_connector" },
|
|
116
|
+
"type_pack_provision_failed": { category: "validation", recovery: "repair_collection" },
|
|
117
|
+
"unknown_collection": { category: "selection", recovery: "choose_collection" },
|
|
118
|
+
"unsafe_file_path": { category: "validation", recovery: "fix_request" },
|
|
119
|
+
"unsupported_encryption": { category: "compatibility", recovery: "upgrade_application" },
|
|
120
|
+
"unsupported_operation": { category: "compatibility", recovery: "fix_request" }
|
|
121
|
+
};
|
|
122
|
+
const CONNECT_PROBLEM_DETAIL_SCHEMAS = {
|
|
123
|
+
"access_denied": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"required": [],
|
|
126
|
+
"properties": {
|
|
127
|
+
"return_to": {
|
|
128
|
+
"type": "string"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"approval_window_blocked": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"required": [
|
|
135
|
+
"user_code",
|
|
136
|
+
"verification_uri",
|
|
137
|
+
"verification_uri_complete",
|
|
138
|
+
"expires_at",
|
|
139
|
+
"interval_seconds"
|
|
140
|
+
],
|
|
141
|
+
"properties": {
|
|
142
|
+
"user_code": {
|
|
143
|
+
"type": "string"
|
|
144
|
+
},
|
|
145
|
+
"verification_uri": {
|
|
146
|
+
"type": "string"
|
|
147
|
+
},
|
|
148
|
+
"verification_uri_complete": {
|
|
149
|
+
"type": "string"
|
|
150
|
+
},
|
|
151
|
+
"expires_at": {
|
|
152
|
+
"type": "integer"
|
|
153
|
+
},
|
|
154
|
+
"interval_seconds": {
|
|
155
|
+
"type": "integer"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"authorization_binding_incompatible": {
|
|
160
|
+
"type": "object",
|
|
161
|
+
"required": [
|
|
162
|
+
"contract",
|
|
163
|
+
"required",
|
|
164
|
+
"supported",
|
|
165
|
+
"peer"
|
|
166
|
+
],
|
|
167
|
+
"properties": {
|
|
168
|
+
"contract": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
},
|
|
171
|
+
"required": {
|
|
172
|
+
"type": "array",
|
|
173
|
+
"items": {
|
|
174
|
+
"type": "integer"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"supported": {
|
|
178
|
+
"type": "array",
|
|
179
|
+
"items": {
|
|
180
|
+
"type": "integer"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"peer": {
|
|
184
|
+
"type": "string"
|
|
185
|
+
},
|
|
186
|
+
"operation": {
|
|
187
|
+
"type": "string"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"capability_contract_incompatible": {
|
|
192
|
+
"type": "object",
|
|
193
|
+
"required": [
|
|
194
|
+
"contract",
|
|
195
|
+
"required",
|
|
196
|
+
"supported",
|
|
197
|
+
"peer"
|
|
198
|
+
],
|
|
199
|
+
"properties": {
|
|
200
|
+
"contract": {
|
|
201
|
+
"type": "string"
|
|
202
|
+
},
|
|
203
|
+
"required": {
|
|
204
|
+
"type": "array",
|
|
205
|
+
"items": {
|
|
206
|
+
"type": "integer"
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
"supported": {
|
|
210
|
+
"type": "array",
|
|
211
|
+
"items": {
|
|
212
|
+
"type": "integer"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"peer": {
|
|
216
|
+
"type": "string"
|
|
217
|
+
},
|
|
218
|
+
"operation": {
|
|
219
|
+
"type": "string"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"collection_configuration_invalid": {
|
|
224
|
+
"type": "object",
|
|
225
|
+
"required": [
|
|
226
|
+
"diagnostics"
|
|
227
|
+
],
|
|
228
|
+
"properties": {
|
|
229
|
+
"diagnostics": {
|
|
230
|
+
"type": "array",
|
|
231
|
+
"items": {
|
|
232
|
+
"type": "object"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"collection_contracts_missing": {
|
|
238
|
+
"type": "object",
|
|
239
|
+
"required": [
|
|
240
|
+
"contracts"
|
|
241
|
+
],
|
|
242
|
+
"properties": {
|
|
243
|
+
"contracts": {
|
|
244
|
+
"type": "array",
|
|
245
|
+
"items": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"required": [
|
|
248
|
+
"id",
|
|
249
|
+
"version"
|
|
250
|
+
],
|
|
251
|
+
"properties": {
|
|
252
|
+
"id": {
|
|
253
|
+
"type": "string"
|
|
254
|
+
},
|
|
255
|
+
"version": {
|
|
256
|
+
"type": "string"
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"collection_invalid": {
|
|
264
|
+
"type": "object",
|
|
265
|
+
"required": [
|
|
266
|
+
"diagnostics"
|
|
267
|
+
],
|
|
268
|
+
"properties": {
|
|
269
|
+
"diagnostics": {
|
|
270
|
+
"type": "array",
|
|
271
|
+
"items": {
|
|
272
|
+
"type": "object"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
"collection_type_registry_invalid": {
|
|
278
|
+
"type": "object",
|
|
279
|
+
"required": [
|
|
280
|
+
"diagnostics"
|
|
281
|
+
],
|
|
282
|
+
"properties": {
|
|
283
|
+
"diagnostics": {
|
|
284
|
+
"type": "array",
|
|
285
|
+
"items": {
|
|
286
|
+
"type": "object"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
"collection_version_unsupported": {
|
|
292
|
+
"type": "object",
|
|
293
|
+
"required": [
|
|
294
|
+
"current_version",
|
|
295
|
+
"required_version"
|
|
296
|
+
],
|
|
297
|
+
"properties": {
|
|
298
|
+
"current_version": {
|
|
299
|
+
"type": "string"
|
|
300
|
+
},
|
|
301
|
+
"required_version": {
|
|
302
|
+
"type": "string"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
"connector_offline": {
|
|
307
|
+
"type": "object",
|
|
308
|
+
"required": [],
|
|
309
|
+
"properties": {
|
|
310
|
+
"connector_name": {
|
|
311
|
+
"type": "string"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"durable_mutation_unsupported": {
|
|
316
|
+
"type": "object",
|
|
317
|
+
"required": [
|
|
318
|
+
"contract",
|
|
319
|
+
"required",
|
|
320
|
+
"supported",
|
|
321
|
+
"peer"
|
|
322
|
+
],
|
|
323
|
+
"properties": {
|
|
324
|
+
"contract": {
|
|
325
|
+
"type": "string"
|
|
326
|
+
},
|
|
327
|
+
"required": {
|
|
328
|
+
"type": "array",
|
|
329
|
+
"items": {
|
|
330
|
+
"type": "integer"
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"supported": {
|
|
334
|
+
"type": "array",
|
|
335
|
+
"items": {
|
|
336
|
+
"type": "integer"
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
"peer": {
|
|
340
|
+
"type": "string"
|
|
341
|
+
},
|
|
342
|
+
"operation": {
|
|
343
|
+
"type": "string"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"insufficient_access": {
|
|
348
|
+
"type": "object",
|
|
349
|
+
"required": [
|
|
350
|
+
"required_operations",
|
|
351
|
+
"granted_operations",
|
|
352
|
+
"missing_operations"
|
|
353
|
+
],
|
|
354
|
+
"properties": {
|
|
355
|
+
"required_operations": {
|
|
356
|
+
"type": "array",
|
|
357
|
+
"items": {
|
|
358
|
+
"type": "string"
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
"granted_operations": {
|
|
362
|
+
"type": "array",
|
|
363
|
+
"items": {
|
|
364
|
+
"type": "string"
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
"missing_operations": {
|
|
368
|
+
"type": "array",
|
|
369
|
+
"items": {
|
|
370
|
+
"type": "string"
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
"invalid_application_manifest": {
|
|
376
|
+
"type": "object",
|
|
377
|
+
"required": [
|
|
378
|
+
"issues"
|
|
379
|
+
],
|
|
380
|
+
"properties": {
|
|
381
|
+
"issues": {
|
|
382
|
+
"type": "array",
|
|
383
|
+
"items": {
|
|
384
|
+
"type": "object",
|
|
385
|
+
"required": [
|
|
386
|
+
"path",
|
|
387
|
+
"keyword",
|
|
388
|
+
"message",
|
|
389
|
+
"params"
|
|
390
|
+
],
|
|
391
|
+
"properties": {
|
|
392
|
+
"path": {
|
|
393
|
+
"type": "string"
|
|
394
|
+
},
|
|
395
|
+
"keyword": {
|
|
396
|
+
"type": "string"
|
|
397
|
+
},
|
|
398
|
+
"message": {
|
|
399
|
+
"type": "string"
|
|
400
|
+
},
|
|
401
|
+
"params": {
|
|
402
|
+
"type": "object"
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
"mutation_request_conflict": {
|
|
410
|
+
"type": "object",
|
|
411
|
+
"required": [
|
|
412
|
+
"request_id"
|
|
413
|
+
],
|
|
414
|
+
"properties": {
|
|
415
|
+
"request_id": {
|
|
416
|
+
"type": "string"
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
"operation_invalid": {
|
|
421
|
+
"type": "object",
|
|
422
|
+
"required": [
|
|
423
|
+
"diagnostics"
|
|
424
|
+
],
|
|
425
|
+
"properties": {
|
|
426
|
+
"diagnostics": {
|
|
427
|
+
"type": "array",
|
|
428
|
+
"items": {
|
|
429
|
+
"type": "object"
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
"partial_result": {}
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
"operation_outcome_unknown": {
|
|
436
|
+
"type": "object",
|
|
437
|
+
"required": [
|
|
438
|
+
"request_id"
|
|
439
|
+
],
|
|
440
|
+
"properties": {
|
|
441
|
+
"request_id": {
|
|
442
|
+
"type": "string"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
"rate_limited": {
|
|
447
|
+
"type": "object",
|
|
448
|
+
"required": [],
|
|
449
|
+
"properties": {
|
|
450
|
+
"retry_after_ms": {
|
|
451
|
+
"type": "integer"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
"transport_protocol_incompatible": {
|
|
456
|
+
"type": "object",
|
|
457
|
+
"required": [
|
|
458
|
+
"contract",
|
|
459
|
+
"required",
|
|
460
|
+
"supported",
|
|
461
|
+
"peer"
|
|
462
|
+
],
|
|
463
|
+
"properties": {
|
|
464
|
+
"contract": {
|
|
465
|
+
"type": "string"
|
|
466
|
+
},
|
|
467
|
+
"required": {
|
|
468
|
+
"type": "array",
|
|
469
|
+
"items": {
|
|
470
|
+
"type": "integer"
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
"supported": {
|
|
474
|
+
"type": "array",
|
|
475
|
+
"items": {
|
|
476
|
+
"type": "integer"
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
"peer": {
|
|
480
|
+
"type": "string"
|
|
481
|
+
},
|
|
482
|
+
"operation": {
|
|
483
|
+
"type": "string"
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
export function isConnectProblemCode(code) {
|
|
489
|
+
return Object.hasOwn(CONNECT_PROBLEM_CATALOG, code);
|
|
490
|
+
}
|
|
491
|
+
export function isConnectProblem(value) {
|
|
492
|
+
if (!isPlainObject(value))
|
|
493
|
+
return false;
|
|
494
|
+
const candidate = value;
|
|
495
|
+
if (candidate.problem_version !== CONNECT_PROBLEM_VERSION || typeof candidate.message !== "string" || candidate.message.length === 0)
|
|
496
|
+
return false;
|
|
497
|
+
if (candidate.operation_outcome !== undefined && candidate.operation_outcome !== "not_sent" && candidate.operation_outcome !== "rejected" && candidate.operation_outcome !== "unknown")
|
|
498
|
+
return false;
|
|
499
|
+
if (candidate.trace_id !== undefined && (typeof candidate.trace_id !== "string" || candidate.trace_id.length === 0))
|
|
500
|
+
return false;
|
|
501
|
+
if (candidate.code === "unknown") {
|
|
502
|
+
return typeof candidate.server_code === "string"
|
|
503
|
+
&& candidate.server_code.length > 0
|
|
504
|
+
&& candidate.category === "unknown"
|
|
505
|
+
&& candidate.recovery === "none";
|
|
506
|
+
}
|
|
507
|
+
if (typeof candidate.code !== "string" || !isConnectProblemCode(candidate.code) || candidate.server_code !== undefined)
|
|
508
|
+
return false;
|
|
509
|
+
const definition = CONNECT_PROBLEM_CATALOG[candidate.code];
|
|
510
|
+
const detailsSchema = CONNECT_PROBLEM_DETAIL_SCHEMAS[candidate.code];
|
|
511
|
+
const detailsMatch = detailsSchema === undefined
|
|
512
|
+
? candidate.details === undefined
|
|
513
|
+
: candidate.details === undefined
|
|
514
|
+
? (detailsSchema.required?.length ?? 0) === 0
|
|
515
|
+
: matchesDetailSchema(candidate.details, detailsSchema);
|
|
516
|
+
return candidate.category === definition.category
|
|
517
|
+
&& candidate.recovery === definition.recovery
|
|
518
|
+
&& detailsMatch;
|
|
519
|
+
}
|
|
520
|
+
function matchesDetailSchema(value, schema) {
|
|
521
|
+
if (schema.type === undefined)
|
|
522
|
+
return true;
|
|
523
|
+
if (schema.type === "string")
|
|
524
|
+
return typeof value === "string";
|
|
525
|
+
if (schema.type === "integer")
|
|
526
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
527
|
+
if (schema.type === "number")
|
|
528
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
529
|
+
if (schema.type === "boolean")
|
|
530
|
+
return typeof value === "boolean";
|
|
531
|
+
if (schema.type === "array")
|
|
532
|
+
return Array.isArray(value) && value.every((item) => matchesDetailSchema(item, schema.items ?? {}));
|
|
533
|
+
if (!isPlainObject(value))
|
|
534
|
+
return false;
|
|
535
|
+
if (!schema.properties)
|
|
536
|
+
return true;
|
|
537
|
+
const candidate = value;
|
|
538
|
+
if (!Object.keys(candidate).every((key) => Object.hasOwn(schema.properties, key)))
|
|
539
|
+
return false;
|
|
540
|
+
if (!(schema.required ?? []).every((key) => Object.hasOwn(candidate, key)))
|
|
541
|
+
return false;
|
|
542
|
+
return Object.entries(candidate).every(([key, item]) => matchesDetailSchema(item, schema.properties[key]));
|
|
543
|
+
}
|
|
544
|
+
function isPlainObject(value) {
|
|
545
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
546
|
+
}
|
|
547
|
+
export function normalizeConnectProblem(serverCode, message, options = {}) {
|
|
548
|
+
if (isConnectProblemCode(serverCode)) {
|
|
549
|
+
const definition = CONNECT_PROBLEM_CATALOG[serverCode];
|
|
550
|
+
const candidate = {
|
|
551
|
+
problem_version: CONNECT_PROBLEM_VERSION,
|
|
552
|
+
code: serverCode,
|
|
553
|
+
category: definition.category,
|
|
554
|
+
recovery: definition.recovery,
|
|
555
|
+
message,
|
|
556
|
+
...(options.details === undefined ? {} : { details: options.details }),
|
|
557
|
+
...(options.operation_outcome === undefined ? {} : { operation_outcome: options.operation_outcome }),
|
|
558
|
+
...(options.trace_id === undefined ? {} : { trace_id: options.trace_id })
|
|
559
|
+
};
|
|
560
|
+
if (isConnectProblem(candidate))
|
|
561
|
+
return candidate;
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
problem_version: CONNECT_PROBLEM_VERSION,
|
|
565
|
+
code: "unknown",
|
|
566
|
+
server_code: serverCode,
|
|
567
|
+
category: "unknown",
|
|
568
|
+
recovery: "none",
|
|
569
|
+
message,
|
|
570
|
+
...(options.details === undefined ? {} : { details: options.details }),
|
|
571
|
+
...(options.operation_outcome === undefined ? {} : { operation_outcome: options.operation_outcome }),
|
|
572
|
+
...(options.trace_id === undefined ? {} : { trace_id: options.trace_id })
|
|
573
|
+
};
|
|
574
|
+
}
|