@wildo-ai/external-connectors-models 1.1.11 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/esm/companion-exports.d.ts.map +1 -1
  2. package/dist/esm/companion-exports.js.map +1 -1
  3. package/dist/esm/core/commons.external-connectors-models.schemas.d.ts +10 -0
  4. package/dist/esm/core/commons.external-connectors-models.schemas.d.ts.map +1 -1
  5. package/dist/esm/core/commons.external-connectors-models.schemas.js +10 -0
  6. package/dist/esm/core/commons.external-connectors-models.schemas.js.map +1 -1
  7. package/dist/esm/core/oauth2.enums.d.ts.map +1 -1
  8. package/dist/esm/core/oauth2.enums.js.map +1 -1
  9. package/dist/esm/core/operation-classification.external-connectors-models.schemas.d.ts.map +1 -1
  10. package/dist/esm/core/operation-classification.external-connectors-models.schemas.js.map +1 -1
  11. package/dist/esm/core/operations.external-connectors-models.schemas.d.ts.map +1 -1
  12. package/dist/esm/core/operations.external-connectors-models.schemas.js.map +1 -1
  13. package/dist/esm/core/security.external-connectors-models.schemas.d.ts.map +1 -1
  14. package/dist/esm/core/security.external-connectors-models.schemas.js.map +1 -1
  15. package/dist/esm/index.d.ts +6 -0
  16. package/dist/esm/index.d.ts.map +1 -1
  17. package/dist/esm/index.js +6 -0
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.d.ts +8 -42
  20. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.d.ts.map +1 -1
  21. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.js +21 -0
  22. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.js.map +1 -1
  23. package/dist/esm/protocols/billing.standard-interface.schemas.d.ts +56 -3
  24. package/dist/esm/protocols/billing.standard-interface.schemas.d.ts.map +1 -1
  25. package/dist/esm/protocols/billing.standard-interface.schemas.js +15 -2
  26. package/dist/esm/protocols/billing.standard-interface.schemas.js.map +1 -1
  27. package/dist/esm/protocols/content-safety.external-connectors-models.schemas.d.ts.map +1 -1
  28. package/dist/esm/protocols/content-safety.external-connectors-models.schemas.js.map +1 -1
  29. package/dist/esm/protocols/document-extraction.external-connectors-models.schemas.d.ts.map +1 -1
  30. package/dist/esm/protocols/document-extraction.external-connectors-models.schemas.js.map +1 -1
  31. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.d.ts +157 -0
  32. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.d.ts.map +1 -0
  33. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.js +134 -0
  34. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.js.map +1 -0
  35. package/dist/esm/protocols/email-inbound.standard-interface.schemas.d.ts +85 -0
  36. package/dist/esm/protocols/email-inbound.standard-interface.schemas.d.ts.map +1 -1
  37. package/dist/esm/protocols/email-inbound.standard-interface.schemas.js +46 -2
  38. package/dist/esm/protocols/email-inbound.standard-interface.schemas.js.map +1 -1
  39. package/dist/esm/protocols/email.external-connectors-models.schemas.d.ts.map +1 -1
  40. package/dist/esm/protocols/email.external-connectors-models.schemas.js.map +1 -1
  41. package/dist/esm/protocols/email.standard-interface.schemas.d.ts.map +1 -1
  42. package/dist/esm/protocols/email.standard-interface.schemas.js.map +1 -1
  43. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.d.ts +49 -6
  44. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.d.ts.map +1 -1
  45. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.js +89 -6
  46. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.js.map +1 -1
  47. package/dist/esm/protocols/file-storage.standard-interface.d.ts +9 -2
  48. package/dist/esm/protocols/file-storage.standard-interface.d.ts.map +1 -1
  49. package/dist/esm/protocols/file-storage.standard-interface.js +6 -0
  50. package/dist/esm/protocols/file-storage.standard-interface.js.map +1 -1
  51. package/dist/esm/protocols/frontend.external-connectors-models.schemas.d.ts.map +1 -1
  52. package/dist/esm/protocols/frontend.external-connectors-models.schemas.js.map +1 -1
  53. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.d.ts +254 -0
  54. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.d.ts.map +1 -0
  55. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.js +480 -0
  56. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.js.map +1 -0
  57. package/dist/esm/protocols/hooks-capability.external-connectors-models.schemas.d.ts.map +1 -1
  58. package/dist/esm/protocols/hooks-capability.external-connectors-models.schemas.js.map +1 -1
  59. package/dist/esm/protocols/hooks.external-connectors-models.schemas.d.ts +95 -1
  60. package/dist/esm/protocols/hooks.external-connectors-models.schemas.d.ts.map +1 -1
  61. package/dist/esm/protocols/hooks.external-connectors-models.schemas.js +110 -0
  62. package/dist/esm/protocols/hooks.external-connectors-models.schemas.js.map +1 -1
  63. package/dist/esm/protocols/image.external-connectors-models.schemas.d.ts.map +1 -1
  64. package/dist/esm/protocols/image.external-connectors-models.schemas.js.map +1 -1
  65. package/dist/esm/protocols/llm.external-connectors-models.schemas.d.ts +95 -3
  66. package/dist/esm/protocols/llm.external-connectors-models.schemas.d.ts.map +1 -1
  67. package/dist/esm/protocols/llm.external-connectors-models.schemas.js +147 -15
  68. package/dist/esm/protocols/llm.external-connectors-models.schemas.js.map +1 -1
  69. package/dist/esm/protocols/oauth2-provider-assurance.definitions.d.ts.map +1 -1
  70. package/dist/esm/protocols/oauth2-provider-assurance.definitions.js.map +1 -1
  71. package/dist/esm/protocols/oauth2-provider-assurance.schemas.d.ts.map +1 -1
  72. package/dist/esm/protocols/oauth2-provider-assurance.schemas.js.map +1 -1
  73. package/dist/esm/protocols/oauth2.external-connectors-models.schemas.d.ts.map +1 -1
  74. package/dist/esm/protocols/oauth2.external-connectors-models.schemas.js.map +1 -1
  75. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.d.ts +52 -0
  76. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.d.ts.map +1 -0
  77. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.js +132 -0
  78. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.js.map +1 -0
  79. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.d.ts +111 -0
  80. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.d.ts.map +1 -0
  81. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.js +203 -0
  82. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.js.map +1 -0
  83. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.d.ts +6 -0
  84. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.d.ts.map +1 -1
  85. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.js +13 -7
  86. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.js.map +1 -1
  87. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.d.ts +50 -0
  88. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.d.ts.map +1 -0
  89. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.js +30 -0
  90. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.js.map +1 -0
  91. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.d.ts +730 -17
  92. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.d.ts.map +1 -1
  93. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.js +822 -20
  94. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.js.map +1 -1
  95. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.d.ts +73 -0
  96. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.d.ts.map +1 -0
  97. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.js +82 -0
  98. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.js.map +1 -0
  99. package/dist/esm/protocols/sms.external-connectors-models.schemas.d.ts.map +1 -1
  100. package/dist/esm/protocols/sms.external-connectors-models.schemas.js.map +1 -1
  101. package/dist/esm/protocols/sms.standard-interface.schemas.d.ts +79 -1
  102. package/dist/esm/protocols/sms.standard-interface.schemas.d.ts.map +1 -1
  103. package/dist/esm/protocols/sms.standard-interface.schemas.js +93 -0
  104. package/dist/esm/protocols/sms.standard-interface.schemas.js.map +1 -1
  105. package/dist/esm/protocols/subject-erasure-effect.standard-interface.d.ts.map +1 -1
  106. package/dist/esm/protocols/subject-erasure-effect.standard-interface.js.map +1 -1
  107. package/dist/tsconfig.build.tsbuildinfo +1 -1
  108. package/package.json +5 -5
  109. package/dist/esm/.native.tsbuildinfo +0 -1
@@ -0,0 +1,480 @@
1
+ /**
2
+ * GRAPHQL provider operations (#3392): an operation whose provider-owned part is a GraphQL document, and whose input is
3
+ * the document's VARIABLES.
4
+ *
5
+ * A REST operation is a method, a path and a body built from the caller's input. A GraphQL vendor (GitHub v4, Linear,
6
+ * Shopify Admin, monday.com) exposes ONE endpoint and tells operations apart by the query document sent to it. Written
7
+ * as a REST operation, the document had to be an input, which handed the caller the vendor's whole schema and made every
8
+ * operation the same operation. Here the PROVIDER owns the document (`graphql.document`, with its `operationName`), and
9
+ * the caller supplies only values for the variables that document declares.
10
+ *
11
+ * ## The wire, settled by the GraphQL-over-HTTP specification
12
+ *
13
+ * The request is a POST whose JSON body holds `query` (the document), `operationName` and `variables`. The client
14
+ * accepts `application/graphql-response+json` first and `application/json` after it, because the vendor's support for
15
+ * the newer media type is unknown.
16
+ * spec-cite: GraphQL over HTTP, Current Working Draft (https://graphql.github.io/graphql-over-http/draft/, fetched
17
+ * 2026-11-09) — §4.1 lists the request parameters `query` (required), `operationName`, `variables` and `extensions`;
18
+ * §4.4 "A server MUST support POST requests with a body encoded as UTF-8 JSON, using the `application/json` media type";
19
+ * §4.2 "the client SHOULD set the Accept header to application/graphql-response+json, application/json;q=0.9".
20
+ *
21
+ * ## The answer: errors arrive IN BAND, on a 2xx
22
+ *
23
+ * A GraphQL server reports most failures inside a successful HTTP answer, in an `errors` list beside (or instead of)
24
+ * `data`. Read as REST, such an answer is a success, so a refused call would be returned to its caller as a result. The
25
+ * rule here, which {@link readProviderGraphqlResponse} applies and the engine's transport enforces on every GraphQL call:
26
+ *
27
+ * | the answer | verdict |
28
+ * |---|---|
29
+ * | `data` is an object, no `errors` (or an empty list) | SUCCEEDED; the output is read from `data` |
30
+ * | `errors`, and no `data` entry | REQUEST_ERROR: the server refused before executing anything |
31
+ * | `errors`, and a `data` entry (null or partial) | EXECUTION_ERROR: execution began and a field failed |
32
+ * | neither a `data` object nor `errors` | UNSTATED: the answer does not say what happened |
33
+ * | `data`, no `errors`, and the mutation's declared `payloadRefusal` says refused | PAYLOAD_REFUSED: the vendor did not do the write |
34
+ *
35
+ * spec-cite: GraphQL, September 2025 edition (https://spec.graphql.org/September2025/, fetched 2026-11-09) — §7.1.1
36
+ * "If execution raised any errors, the execution result must contain an entry with key "errors"" and "The value of this
37
+ * entry must be a non-empty list"; §7.1.3 "The request error result map must not contain an entry with key "data""; §7.1.5
38
+ * "If an error was raised during the execution that prevented a valid response, the "data" entry in the response should
39
+ * be null"; §6.3.4 (mutation) "the selections in the top most selection set will be executed in serial order".
40
+ * spec-cite: https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api — for the
41
+ * primary rate limit "the response status will still be `200`", fetched 2026-11-09: a 200 is not a success.
42
+ *
43
+ * PARTIAL DATA IS NEVER RETURNED AS A RESULT. Any error fails the call, whatever `data` holds, because a caller handed a
44
+ * partial object cannot tell a field the vendor left null from a field that failed. For a MUTATION whose execution began,
45
+ * the failure says the outcome is UNKNOWN: the root fields run in order and an error in one does not undo the ones
46
+ * before it, so whether the change landed is not stated. A request error (no `data`) applied nothing, mutation or not.
47
+ *
48
+ * ## What is not checked here
49
+ *
50
+ * The document is checked for its SHAPE (it parses into exactly one operation of the declared name and type, and its
51
+ * variables are the input's fields). It is not validated against the vendor's schema here: publish does that, against
52
+ * the schema the module pins as `provider.graphqlSchema` (#3392, the counterpart of the OpenAPI conformance check of
53
+ * #2028). The OpenAPI conformance check skips a GraphQL operation, since an OpenAPI description does not describe a
54
+ * GraphQL endpoint.
55
+ */
56
+ import { ExternalOperation_Classification } from '../core/operation-classification.external-connectors-models.schemas.js';
57
+ import { API_HttpMethod } from '../core/commons.external-connectors-models.schemas.js';
58
+ import { PROVIDER_VENDOR_ERROR_CODE_SHAPE, ProviderRestResponseDecoding } from './rest-operations.external-connectors-models.schemas.js';
59
+ /** How a mutation's payload states a refusal. See {@link ProviderRestOperationGraphql.payloadRefusal}. */
60
+ export var ProviderGraphqlPayloadRefusalKind;
61
+ (function (ProviderGraphqlPayloadRefusalKind) {
62
+ /** A list of the vendor's refusals (Shopify's `userErrors`): the write was refused when the list is not empty. */
63
+ ProviderGraphqlPayloadRefusalKind["USER_ERRORS"] = "user_errors";
64
+ /** A boolean the vendor sets to `false` when it did not do the write (Linear's `success`). */
65
+ ProviderGraphqlPayloadRefusalKind["SUCCESS_FLAG"] = "success_flag";
66
+ })(ProviderGraphqlPayloadRefusalKind || (ProviderGraphqlPayloadRefusalKind = {}));
67
+ /** What a GraphQL document's operation does. A `subscription` is not served over a single POST, so it is no member. */
68
+ export var ProviderGraphqlOperationType;
69
+ (function (ProviderGraphqlOperationType) {
70
+ /** Reads. The operation must be classified READ. */
71
+ ProviderGraphqlOperationType["QUERY"] = "query";
72
+ /** Changes the vendor. The operation must be classified WRITE. */
73
+ ProviderGraphqlOperationType["MUTATION"] = "mutation";
74
+ })(ProviderGraphqlOperationType || (ProviderGraphqlOperationType = {}));
75
+ /**
76
+ * The `Accept` a GraphQL call sends: the GraphQL response media type first, `application/json` for a server that predates
77
+ * it (GraphQL over HTTP §4.2, quoted in this module's header).
78
+ * semantic-literal-boundary: the media types GraphQL over HTTP names, sent on the wire.
79
+ */
80
+ export const PROVIDER_GRAPHQL_ACCEPT_HEADER = 'application/graphql-response+json, application/json;q=0.9';
81
+ /** At most this many of the vendor's error messages are kept on a failure. */
82
+ export const PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES = 10;
83
+ /** A kept error message is cut at this many characters. */
84
+ export const PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH = 500;
85
+ const GRAPHQL_NAME = /^[_A-Za-z][_0-9A-Za-z]*$/;
86
+ const GRAPHQL_PUNCTUATORS = new Set(['!', '$', '&', '(', ')', ':', '=', '@', '[', ']', '{', '|', '}']);
87
+ /**
88
+ * The tokens of a GraphQL document, with strings and comments dropped: enough to find its definitions and their
89
+ * variables. Not a validating parser: the vendor's server is the parser that decides, and this only has to see the
90
+ * document's outline. A block string (`"""…"""`) and a string (`"…"`, with `\` escapes) are skipped whole, so a brace or
91
+ * a `$` inside one is never read as structure. `undefined` for a string that never closes.
92
+ */
93
+ function tokenizeGraphqlDocument(document) {
94
+ const tokens = [];
95
+ let index = 0;
96
+ while (index < document.length) {
97
+ const character = document[index];
98
+ if (character === '#') {
99
+ while (index < document.length && document[index] !== '\n' && document[index] !== '\r')
100
+ index += 1;
101
+ continue;
102
+ }
103
+ if (character === '"') {
104
+ if (document.startsWith('"""', index)) {
105
+ const close = document.indexOf('"""', index + 3);
106
+ // A `\"""` inside a block string is an escaped delimiter, not its end.
107
+ let end = close;
108
+ while (end !== -1 && document[end - 1] === '\\')
109
+ end = document.indexOf('"""', end + 3);
110
+ if (end === -1)
111
+ return undefined;
112
+ index = end + 3;
113
+ }
114
+ else {
115
+ index += 1;
116
+ while (index < document.length && document[index] !== '"') {
117
+ if (document[index] === '\n')
118
+ return undefined;
119
+ index += document[index] === '\\' ? 2 : 1;
120
+ }
121
+ if (index >= document.length)
122
+ return undefined;
123
+ index += 1;
124
+ }
125
+ tokens.push('"');
126
+ continue;
127
+ }
128
+ if (character === '.' && document.startsWith('...', index)) {
129
+ tokens.push('...');
130
+ index += 3;
131
+ continue;
132
+ }
133
+ if (GRAPHQL_PUNCTUATORS.has(character)) {
134
+ tokens.push(character);
135
+ index += 1;
136
+ continue;
137
+ }
138
+ if (/[_A-Za-z0-9.+-]/.test(character)) {
139
+ let end = index + 1;
140
+ while (end < document.length && /[_A-Za-z0-9.+-]/.test(document[end]))
141
+ end += 1;
142
+ tokens.push(document.slice(index, end));
143
+ index = end;
144
+ continue;
145
+ }
146
+ // White space, commas (insignificant in GraphQL) and the byte order mark.
147
+ index += 1;
148
+ }
149
+ return tokens;
150
+ }
151
+ /**
152
+ * The executable definitions of a GraphQL document (#3392): each operation's type, name and declared variables. A
153
+ * fragment is skipped; a type-system definition (`type`, `schema`, …) is a defect, since a document sent to a server is
154
+ * executable only.
155
+ */
156
+ export function readProviderGraphqlDocument(document) {
157
+ const tokens = tokenizeGraphqlDocument(document);
158
+ if (tokens === undefined)
159
+ return { operations: [], defect: 'a string in it never closes' };
160
+ const operations = [];
161
+ let index = 0;
162
+ /** Skips the balanced block opening at `index` (a `{` or a `(`), and answers the index after it, or -1. */
163
+ const skipBalanced = (open, close) => {
164
+ let depth = 0;
165
+ for (let position = index; position < tokens.length; position += 1) {
166
+ if (tokens[position] === open)
167
+ depth += 1;
168
+ else if (tokens[position] === close) {
169
+ depth -= 1;
170
+ if (depth === 0)
171
+ return position + 1;
172
+ }
173
+ }
174
+ return -1;
175
+ };
176
+ while (index < tokens.length) {
177
+ const token = tokens[index];
178
+ if (token === '{') {
179
+ const after = skipBalanced('{', '}');
180
+ if (after === -1)
181
+ return { operations, defect: 'a selection set never closes' };
182
+ operations.push({ type: 'query', variables: [] });
183
+ index = after;
184
+ continue;
185
+ }
186
+ if (token === 'query' || token === 'mutation' || token === 'subscription') {
187
+ index += 1;
188
+ const name = tokens[index] !== undefined && GRAPHQL_NAME.test(tokens[index]) ? tokens[index] : undefined;
189
+ if (name !== undefined)
190
+ index += 1;
191
+ const variables = [];
192
+ if (tokens[index] === '(') {
193
+ const after = skipBalanced('(', ')');
194
+ if (after === -1)
195
+ return { operations, defect: `the variable definitions of ${name ?? 'an operation'} never close` };
196
+ // A definition is `$name :`; a default value is constant and holds no variable.
197
+ for (let position = index; position < after - 2; position += 1) {
198
+ if (tokens[position] === '$' && tokens[position + 2] === ':' && GRAPHQL_NAME.test(tokens[position + 1]))
199
+ variables.push(tokens[position + 1]);
200
+ }
201
+ index = after;
202
+ }
203
+ while (index < tokens.length && tokens[index] !== '{')
204
+ index += 1;
205
+ if (index >= tokens.length)
206
+ return { operations, defect: `${name ?? 'an operation'} has no selection set` };
207
+ const after = skipBalanced('{', '}');
208
+ if (after === -1)
209
+ return { operations, defect: `the selection set of ${name ?? 'an operation'} never closes` };
210
+ operations.push({ type: token, ...(name === undefined ? {} : { name }), variables });
211
+ index = after;
212
+ continue;
213
+ }
214
+ if (token === 'fragment') {
215
+ while (index < tokens.length && tokens[index] !== '{')
216
+ index += 1;
217
+ if (index >= tokens.length)
218
+ return { operations, defect: 'a fragment has no selection set' };
219
+ const after = skipBalanced('{', '}');
220
+ if (after === -1)
221
+ return { operations, defect: 'a fragment\'s selection set never closes' };
222
+ index = after;
223
+ continue;
224
+ }
225
+ return { operations, defect: `'${token}' begins no executable definition (an operation or a fragment)` };
226
+ }
227
+ return { operations };
228
+ }
229
+ /**
230
+ * The top-level fields an input schema declares, read through Zod's own definition (`_zod.def`) as the input-options
231
+ * check reads it, so a module built against another copy of Zod is read the same. Wrappers that keep the value's shape
232
+ * are seen through; a union declares what any of its options declares. `undefined` when the schema is not an object
233
+ * (or a union of objects), so its fields cannot be listed.
234
+ */
235
+ function inputSchemaTopLevelFields(schema) {
236
+ let current = schema;
237
+ for (let depth = 0; depth < 64; depth += 1) {
238
+ const def = current?._zod?.def;
239
+ if (def === undefined)
240
+ return undefined;
241
+ switch (def.type) {
242
+ case 'optional':
243
+ case 'nullable':
244
+ case 'default':
245
+ case 'prefault':
246
+ case 'readonly':
247
+ case 'catch':
248
+ case 'nonoptional':
249
+ current = def.innerType;
250
+ continue;
251
+ case 'pipe':
252
+ current = def.in;
253
+ continue;
254
+ case 'lazy':
255
+ current = typeof def.getter === 'function' ? def.getter() : undefined;
256
+ continue;
257
+ case 'object':
258
+ return new Set(Object.keys(def.shape ?? {}));
259
+ case 'union': {
260
+ const fields = new Set();
261
+ for (const option of Array.isArray(def.options) ? def.options : []) {
262
+ const optionFields = inputSchemaTopLevelFields(option);
263
+ if (optionFields === undefined)
264
+ return undefined;
265
+ for (const field of optionFields)
266
+ fields.add(field);
267
+ }
268
+ return fields;
269
+ }
270
+ default:
271
+ return undefined;
272
+ }
273
+ }
274
+ return undefined;
275
+ }
276
+ /**
277
+ * Why a GraphQL operation cannot be sent as declared, or an empty list (#3392). Empty for an operation without
278
+ * `graphql`. Checked where a catalogue loads (the operation executor, an augmentation merge), at `wildo registry publish`,
279
+ * and by the request compiler on every call, so the one rule refuses in every place:
280
+ *
281
+ * - the call is a POST with no `requestBody`, every parameter carries a `constantValue` (the input is the variables
282
+ * and nothing else), and the answer is read as JSON;
283
+ * - the document reads as exactly ONE operation, named `operationName`, beside any fragments;
284
+ * - a `query` is classified READ and a `mutation` WRITE; a `subscription` is refused;
285
+ * - each declared variable is a top-level field of `inputSchema`, and each top-level field is a declared variable, so no
286
+ * value a caller supplies is silently dropped (when `inputSchema` lists its fields; without one, the call refuses a
287
+ * value for a variable the document does not declare);
288
+ * - `errorCodePath` is a dot path;
289
+ * - each of `credentialRefusedErrorCodes` is code-shaped (a value of any other shape is never kept, so it could never
290
+ * match), and the list comes with an `errorCodePath` to read the code at;
291
+ * - a `payloadRefusal` belongs to a mutation, names a kind of its vocabulary, and reads every path as a dot path.
292
+ */
293
+ export function describeProviderRestOperationGraphqlDefects(operation) {
294
+ const graphql = operation.graphql;
295
+ if (graphql === undefined)
296
+ return [];
297
+ const at = `GraphQL operation '${operation.operationId}'`;
298
+ const defects = [];
299
+ if (operation.method !== API_HttpMethod.POST)
300
+ defects.push(`${at} is sent with ${operation.method}; a GraphQL call is a POST`);
301
+ if (operation.requestBody !== undefined)
302
+ defects.push(`${at} declares a requestBody; its body is the document and its variables`);
303
+ for (const parameter of operation.parameters ?? []) {
304
+ if (parameter.constantValue === undefined) {
305
+ defects.push(`${at} declares the ${parameter.in} parameter '${parameter.name}' fed by the input; its input is the document's variables only, so a parameter must carry a constantValue`);
306
+ }
307
+ }
308
+ if (operation.responseDecoding !== undefined && operation.responseDecoding !== ProviderRestResponseDecoding.JSON)
309
+ defects.push(`${at} reads its answer as ${operation.responseDecoding}; a GraphQL answer is JSON`);
310
+ if (operation.binaryResponse !== undefined)
311
+ defects.push(`${at} declares binaryResponse; a GraphQL answer is JSON`);
312
+ if (!GRAPHQL_NAME.test(graphql.operationName))
313
+ defects.push(`${at} names the operation '${graphql.operationName}', which is not a GraphQL name`);
314
+ if (graphql.errorCodePath !== undefined && graphql.errorCodePath.split('.').some((segment) => segment.length === 0)) {
315
+ defects.push(`${at} reads its error code at '${graphql.errorCodePath}', which is not a dot path`);
316
+ }
317
+ const payloadRefusal = graphql.payloadRefusal;
318
+ if (payloadRefusal !== undefined) {
319
+ const kinds = Object.values(ProviderGraphqlPayloadRefusalKind);
320
+ if (!kinds.includes(payloadRefusal.kind))
321
+ defects.push(`${at} declares the payload refusal kind ${JSON.stringify(payloadRefusal.kind)}, which is none of ${kinds.join(', ')}`);
322
+ const paths = [['path', payloadRefusal.path]];
323
+ if (payloadRefusal.kind === ProviderGraphqlPayloadRefusalKind.USER_ERRORS) {
324
+ paths.push(['messagePath', payloadRefusal.messagePath], ['fieldPath', payloadRefusal.fieldPath], ['codePath', payloadRefusal.codePath]);
325
+ }
326
+ for (const [field, value] of paths) {
327
+ if (value === undefined && field !== 'path')
328
+ continue;
329
+ if (typeof value !== 'string' || value.length === 0 || value.split('.').some((segment) => segment.length === 0)) {
330
+ defects.push(`${at} reads its payload refusal's ${field} at ${JSON.stringify(value)}, which is not a dot path`);
331
+ }
332
+ }
333
+ }
334
+ if (graphql.credentialRefusedErrorCodes !== undefined && graphql.errorCodePath === undefined) {
335
+ defects.push(`${at} lists credentialRefusedErrorCodes but no errorCodePath, so no code is read and none of them could ever match`);
336
+ }
337
+ for (const code of graphql.credentialRefusedErrorCodes ?? []) {
338
+ if (!PROVIDER_VENDOR_ERROR_CODE_SHAPE.test(code)) {
339
+ defects.push(`${at} lists the credential-refusal code '${code}', which is not code-shaped and would never match a code the transport keeps`);
340
+ }
341
+ }
342
+ const shape = readProviderGraphqlDocument(graphql.document);
343
+ if (shape.defect !== undefined) {
344
+ defects.push(`${at}: its document does not read as a GraphQL document (${shape.defect})`);
345
+ return defects;
346
+ }
347
+ const named = shape.operations.filter((candidate) => candidate.name === graphql.operationName);
348
+ if (named.length !== 1 || shape.operations.length !== 1) {
349
+ defects.push(`${at}: its document must define exactly one operation, named '${graphql.operationName}', and it defines `
350
+ + `${shape.operations.length === 0 ? 'none' : shape.operations.map((candidate) => `${candidate.type} ${candidate.name ?? '(anonymous)'}`).join(', ')}`);
351
+ return defects;
352
+ }
353
+ const [definition] = named;
354
+ const expected = definition.type === ProviderGraphqlOperationType.QUERY ? ExternalOperation_Classification.READ
355
+ : definition.type === ProviderGraphqlOperationType.MUTATION ? ExternalOperation_Classification.WRITE
356
+ : undefined;
357
+ if (expected === undefined)
358
+ defects.push(`${at} is a ${definition.type}, which is not answered over a single POST`);
359
+ // A refusal stated in a payload is a WRITE's: a query that answers data refused nothing.
360
+ if (graphql.payloadRefusal !== undefined && definition.type !== ProviderGraphqlOperationType.MUTATION) {
361
+ defects.push(`${at} is a ${definition.type} and declares a payload refusal, which only a mutation's payload states`);
362
+ }
363
+ else if (operation.classification !== expected)
364
+ defects.push(`${at} is a ${definition.type} classified ${operation.classification}; a query is a READ and a mutation a WRITE`);
365
+ const fields = operation.inputSchema === undefined ? undefined : inputSchemaTopLevelFields(operation.inputSchema);
366
+ if (operation.inputSchema !== undefined && fields === undefined) {
367
+ defects.push(`${at} has an inputSchema that is not an object, and its input is the document's variables`);
368
+ }
369
+ if (fields !== undefined) {
370
+ for (const variable of definition.variables) {
371
+ if (!fields.has(variable))
372
+ defects.push(`${at} declares the variable '$${variable}', which its inputSchema does not declare`);
373
+ }
374
+ for (const field of fields) {
375
+ if (!definition.variables.includes(field))
376
+ defects.push(`${at}: its inputSchema declares '${field}', which is no variable of the document, so a value for it would never be sent`);
377
+ }
378
+ }
379
+ return defects;
380
+ }
381
+ /** The variables a GraphQL operation's document declares, or `undefined` when the document cannot be read. */
382
+ export function providerGraphqlOperationVariables(graphql) {
383
+ const shape = readProviderGraphqlDocument(graphql.document);
384
+ if (shape.defect !== undefined)
385
+ return undefined;
386
+ return shape.operations.find((candidate) => candidate.name === graphql.operationName)?.variables;
387
+ }
388
+ /** What a GraphQL answer says about the call. See the table in this module's header. */
389
+ export var ProviderGraphqlResponseOutcomeKind;
390
+ (function (ProviderGraphqlResponseOutcomeKind) {
391
+ /** `data` is an object and no error was reported. */
392
+ ProviderGraphqlResponseOutcomeKind["SUCCEEDED"] = "succeeded";
393
+ /** Errors, and no `data` entry: the request was refused before anything executed. Nothing was applied. */
394
+ ProviderGraphqlResponseOutcomeKind["REQUEST_ERROR"] = "request_error";
395
+ /** Errors beside a `data` entry (null or partial): execution began and something failed. */
396
+ ProviderGraphqlResponseOutcomeKind["EXECUTION_ERROR"] = "execution_error";
397
+ /** Neither a `data` object nor an error list: the answer does not state what happened. */
398
+ ProviderGraphqlResponseOutcomeKind["UNSTATED"] = "unstated";
399
+ /**
400
+ * `data` and no `errors`, and the mutation's payload states the vendor refused it (its declared `payloadRefusal`): the
401
+ * write was not done, as the vendor says (follow-up to #3392).
402
+ */
403
+ ProviderGraphqlResponseOutcomeKind["PAYLOAD_REFUSED"] = "payload_refused";
404
+ })(ProviderGraphqlResponseOutcomeKind || (ProviderGraphqlResponseOutcomeKind = {}));
405
+ /** The value at a dot path, read through own properties only (an array's index is an own property), or `undefined`. */
406
+ function readGraphqlDotPath(value, path) {
407
+ let current = value;
408
+ for (const segment of path.split('.')) {
409
+ if (current === null || typeof current !== 'object' || !Object.hasOwn(current, segment))
410
+ return undefined;
411
+ current = current[segment];
412
+ }
413
+ return current;
414
+ }
415
+ function readGraphqlErrorCode(error, errorCodePath) {
416
+ const current = readGraphqlDotPath(error, errorCodePath);
417
+ return typeof current === 'string' && PROVIDER_VENDOR_ERROR_CODE_SHAPE.test(current) ? current : undefined;
418
+ }
419
+ /** A vendor message as the verdict keeps it: cut at {@link PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH}. */
420
+ function keptGraphqlMessage(message) {
421
+ return message.length > PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH ? `${message.slice(0, PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH)}…` : message;
422
+ }
423
+ /**
424
+ * The refusal a mutation's payload states, read as its declaration says ({@link ProviderGraphqlPayloadRefusal}), or
425
+ * `undefined` when the payload refuses nothing.
426
+ */
427
+ function readGraphqlPayloadRefusal(data, refusal) {
428
+ const stated = readGraphqlDotPath(data, refusal.path);
429
+ if (refusal.kind === ProviderGraphqlPayloadRefusalKind.SUCCESS_FLAG) {
430
+ return stated === false ? { errorMessages: [`the answer's ${refusal.path} is false: the vendor did not do the write`] } : undefined;
431
+ }
432
+ if (!Array.isArray(stated) || stated.length === 0)
433
+ return undefined;
434
+ const errorMessages = stated.slice(0, PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES).map((entry) => {
435
+ const message = readGraphqlDotPath(entry, refusal.messagePath ?? 'message');
436
+ const field = refusal.fieldPath === undefined ? undefined : readGraphqlDotPath(entry, refusal.fieldPath);
437
+ const fieldText = typeof field === 'string' ? field
438
+ : Array.isArray(field) && field.every((segment) => typeof segment === 'string' || typeof segment === 'number') ? field.join('.') : undefined;
439
+ const text = typeof message === 'string' ? message : 'the vendor refused the write without a message';
440
+ return keptGraphqlMessage(fieldText === undefined || fieldText.length === 0 ? text : `${fieldText}: ${text}`);
441
+ });
442
+ const errorCode = refusal.codePath === undefined ? undefined
443
+ : stated.map((entry) => readGraphqlErrorCode(entry, refusal.codePath)).find((code) => code !== undefined);
444
+ return { errorMessages, ...(errorCode === undefined ? {} : { errorCode }) };
445
+ }
446
+ /**
447
+ * Reads a parsed GraphQL answer (#3392). The ONE reader: the engine's transport, for a 2xx and a non-2xx answer alike,
448
+ * and every test go through it. See the module header for the rule and its sources.
449
+ */
450
+ export function readProviderGraphqlResponse(body, errorCodePath, payloadRefusal) {
451
+ if (body === null || typeof body !== 'object' || Array.isArray(body))
452
+ return { kind: ProviderGraphqlResponseOutcomeKind.UNSTATED };
453
+ const answer = body;
454
+ const errors = Object.hasOwn(answer, 'errors') ? answer.errors : undefined;
455
+ if (errors !== undefined && errors !== null && !Array.isArray(errors))
456
+ return { kind: ProviderGraphqlResponseOutcomeKind.UNSTATED };
457
+ if (Array.isArray(errors) && errors.length > 0) {
458
+ const errorMessages = errors
459
+ .map((error) => (error !== null && typeof error === 'object' && typeof error.message === 'string' ? error.message : undefined))
460
+ .filter((message) => message !== undefined)
461
+ .slice(0, PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES)
462
+ .map(keptGraphqlMessage);
463
+ const errorCode = errorCodePath === undefined ? undefined
464
+ : errors.map((error) => readGraphqlErrorCode(error, errorCodePath)).find((code) => code !== undefined);
465
+ return {
466
+ kind: Object.hasOwn(answer, 'data') ? ProviderGraphqlResponseOutcomeKind.EXECUTION_ERROR : ProviderGraphqlResponseOutcomeKind.REQUEST_ERROR,
467
+ errorMessages,
468
+ ...(errorCode === undefined ? {} : { errorCode }),
469
+ };
470
+ }
471
+ const data = Object.hasOwn(answer, 'data') ? answer.data : undefined;
472
+ if (data === null || typeof data !== 'object' || Array.isArray(data))
473
+ return { kind: ProviderGraphqlResponseOutcomeKind.UNSTATED };
474
+ const refused = payloadRefusal === undefined ? undefined : readGraphqlPayloadRefusal(data, payloadRefusal);
475
+ if (refused !== undefined)
476
+ return { kind: ProviderGraphqlResponseOutcomeKind.PAYLOAD_REFUSED, ...refused };
477
+ return { kind: ProviderGraphqlResponseOutcomeKind.SUCCEEDED, data: data };
478
+ }
479
+ /** @wildo_source:part:end external-connectors.models.rest-operation-contract */
480
+ //# sourceMappingURL=graphql-operations.external-connectors-models.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-operations.external-connectors-models.schemas.js","sourceRoot":"","sources":["../../../src/protocols/graphql-operations.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,gCAAgC,EAAE,MAAM,qEAAqE,CAAC;AACvH,OAAO,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAEpF,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAA8B,MAAM,sDAAsD,CAAC;AA8ElK,0GAA0G;AAC1G,MAAM,CAAN,IAAY,iCAKX;AALD,WAAY,iCAAiC;IAC3C,kHAAkH;IAClH,gEAA2B,CAAA;IAC3B,8FAA8F;IAC9F,kEAA6B,CAAA;AAC/B,CAAC,EALW,iCAAiC,KAAjC,iCAAiC,QAK5C;AAuBD,uHAAuH;AACvH,MAAM,CAAN,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,oDAAoD;IACpD,+CAAe,CAAA;IACf,kEAAkE;IAClE,qDAAqB,CAAA;AACvB,CAAC,EALW,4BAA4B,KAA5B,4BAA4B,QAKvC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,2DAA2D,CAAC;AAE1G,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uCAAuC,GAAG,EAAE,CAAC;AAC1D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,6CAA6C,GAAG,GAAG,CAAC;AAmBjE,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAChD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG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C,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,kCAAkC,CAAC,QAAQ,EAAE,CAAC;IACnI,MAAM,OAAO,GAAG,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,yBAAyB,CAAC,IAA+B,EAAE,cAAc,CAAC,CAAC;IACtI,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,kCAAkC,CAAC,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;IAC3G,OAAO,EAAE,IAAI,EAAE,kCAAkC,CAAC,SAAS,EAAE,IAAI,EAAE,IAA+B,EAAE,CAAC;AACvG,CAAC;AACD,gFAAgF","sourcesContent":["/**\n * GRAPHQL provider operations (#3392): an operation whose provider-owned part is a GraphQL document, and whose input is\n * the document's VARIABLES.\n *\n * A REST operation is a method, a path and a body built from the caller's input. A GraphQL vendor (GitHub v4, Linear,\n * Shopify Admin, monday.com) exposes ONE endpoint and tells operations apart by the query document sent to it. Written\n * as a REST operation, the document had to be an input, which handed the caller the vendor's whole schema and made every\n * operation the same operation. Here the PROVIDER owns the document (`graphql.document`, with its `operationName`), and\n * the caller supplies only values for the variables that document declares.\n *\n * ## The wire, settled by the GraphQL-over-HTTP specification\n *\n * The request is a POST whose JSON body holds `query` (the document), `operationName` and `variables`. The client\n * accepts `application/graphql-response+json` first and `application/json` after it, because the vendor's support for\n * the newer media type is unknown.\n * spec-cite: GraphQL over HTTP, Current Working Draft (https://graphql.github.io/graphql-over-http/draft/, fetched\n * 2026-11-09) — §4.1 lists the request parameters `query` (required), `operationName`, `variables` and `extensions`;\n * §4.4 \"A server MUST support POST requests with a body encoded as UTF-8 JSON, using the `application/json` media type\";\n * §4.2 \"the client SHOULD set the Accept header to application/graphql-response+json, application/json;q=0.9\".\n *\n * ## The answer: errors arrive IN BAND, on a 2xx\n *\n * A GraphQL server reports most failures inside a successful HTTP answer, in an `errors` list beside (or instead of)\n * `data`. Read as REST, such an answer is a success, so a refused call would be returned to its caller as a result. The\n * rule here, which {@link readProviderGraphqlResponse} applies and the engine's transport enforces on every GraphQL call:\n *\n * | the answer | verdict |\n * |---|---|\n * | `data` is an object, no `errors` (or an empty list) | SUCCEEDED; the output is read from `data` |\n * | `errors`, and no `data` entry | REQUEST_ERROR: the server refused before executing anything |\n * | `errors`, and a `data` entry (null or partial) | EXECUTION_ERROR: execution began and a field failed |\n * | neither a `data` object nor `errors` | UNSTATED: the answer does not say what happened |\n * | `data`, no `errors`, and the mutation's declared `payloadRefusal` says refused | PAYLOAD_REFUSED: the vendor did not do the write |\n *\n * spec-cite: GraphQL, September 2025 edition (https://spec.graphql.org/September2025/, fetched 2026-11-09) — §7.1.1\n * \"If execution raised any errors, the execution result must contain an entry with key \"errors\"\" and \"The value of this\n * entry must be a non-empty list\"; §7.1.3 \"The request error result map must not contain an entry with key \"data\"\"; §7.1.5\n * \"If an error was raised during the execution that prevented a valid response, the \"data\" entry in the response should\n * be null\"; §6.3.4 (mutation) \"the selections in the top most selection set will be executed in serial order\".\n * spec-cite: https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api — for the\n * primary rate limit \"the response status will still be `200`\", fetched 2026-11-09: a 200 is not a success.\n *\n * PARTIAL DATA IS NEVER RETURNED AS A RESULT. Any error fails the call, whatever `data` holds, because a caller handed a\n * partial object cannot tell a field the vendor left null from a field that failed. For a MUTATION whose execution began,\n * the failure says the outcome is UNKNOWN: the root fields run in order and an error in one does not undo the ones\n * before it, so whether the change landed is not stated. A request error (no `data`) applied nothing, mutation or not.\n *\n * ## What is not checked here\n *\n * The document is checked for its SHAPE (it parses into exactly one operation of the declared name and type, and its\n * variables are the input's fields). It is not validated against the vendor's schema here: publish does that, against\n * the schema the module pins as `provider.graphqlSchema` (#3392, the counterpart of the OpenAPI conformance check of\n * #2028). The OpenAPI conformance check skips a GraphQL operation, since an OpenAPI description does not describe a\n * GraphQL endpoint.\n */\n\nimport { ExternalOperation_Classification } from '../core/operation-classification.external-connectors-models.schemas';\nimport { API_HttpMethod } from '../core/commons.external-connectors-models.schemas';\n\nimport { PROVIDER_VENDOR_ERROR_CODE_SHAPE, ProviderRestResponseDecoding, type ProviderRestOperation } from './rest-operations.external-connectors-models.schemas';\n\n/** @wildo_source:part:start external-connectors.models.rest-operation-contract facet:layer:shared facet:family:provider facet:audience:app-developer */\n/**\n * The GraphQL document a provider operation sends (#3392), set as `ProviderRestOperation.graphql`.\n *\n * With it the operation is a GraphQL call: `method` must be `POST`, `pathTemplate` is the vendor's GraphQL endpoint\n * (`/graphql`), and the operation's input IS the variables. So it may declare no `requestBody`, and no parameter fed by\n * the input (a `constantValue` header or path parameter, such as a pinned API version, is allowed). `inputSchema`\n * describes the variables, one top-level field per variable the document declares, and `inputOptions` work on them as on\n * any input. `resultPath` and `outputSchema` read the answer's `data`, never the `{ data, errors }` envelope around it.\n * `responseDecoding` stays JSON.\n *\n * Checked when the catalogue loads, at publish and on every call ({@link describeProviderRestOperationGraphqlDefects}).\n *\n * @example\n * // GitHub: a repository's discussions, which GitHub serves through GraphQL only.\n * {\n * operationId: 'github_issues_list_discussions', domain: 'default', method: API_HttpMethod.POST, pathTemplate: '/graphql',\n * classification: ExternalOperation_Classification.READ,\n * graphql: {\n * operationName: 'ListDiscussions',\n * document: 'query ListDiscussions($owner: String!, $repo: String!, $first: Int!) { repository(owner: $owner, name: $repo) { discussions(first: $first) { nodes { number title } } } }',\n * },\n * inputSchema: z.strictObject({ owner: z.string(), repo: z.string(), first: z.number().int() }),\n * resultPath: 'repository.discussions',\n * }\n */\nexport interface ProviderRestOperationGraphql {\n /**\n * The executable document, owned by the provider: exactly ONE operation (a `query` or a `mutation`, named\n * {@link operationName}) and any fragments it uses. A `query` is a READ operation and a `mutation` a WRITE; a\n * `subscription` is refused, since it is not answered over a single POST.\n */\n readonly document: string;\n /** The operation's name in {@link document}, sent as `operationName`. */\n readonly operationName: string;\n /**\n * Dot path, inside EACH error of the answer's `errors` list, to the vendor's machine-readable code (`extensions.code`\n * by convention, where a vendor uses it). The specification standardizes no code, so absent, no code is read and the\n * failure carries the vendor's messages only. A code is kept only when it is code-shaped, as every vendor code is.\n */\n readonly errorCodePath?: string;\n /**\n * The codes, read at {@link errorCodePath}, that mean the vendor refused the CREDENTIAL itself rather than the request\n * (#3392): the stored credential is then recorded as rejected, as a REST vendor's\n * `applicationOutcome.credentialRefusedErrorCodes` records it. A GraphQL vendor may name a dead or expired token inside\n * a 200 (an error list beside or instead of `data`) or inside a 4xx carrying the same error list, and both are read.\n * The failure itself is unchanged: the call fails with the vendor's code and is never retried.\n *\n * List only a code the vendor DOCUMENTS as a refused credential. A code for a resource the credential may not reach\n * (`FORBIDDEN` on one repository), for a missing scope, or for a request sent with no credential at all, does not\n * belong here: the credential still works, and recording it rejected would show a working connection as broken.\n * Requires {@link errorCodePath}, without which no code is read and none could match.\n *\n * @example\n * // monday.com answers a key it refuses with the error code `Unauthorized`, whose documented resolution is a valid key.\n * // spec-cite: https://developer.monday.com/api-reference/docs/errors — the `Unauthorized` row (HTTP 401, resolution\n * // \"Input a valid API key.\"), fetched 2026-11-09.\n * graphql: { operationName: 'CreateItem', document: CREATE_ITEM, errorCodePath: 'extensions.code', credentialRefusedErrorCodes: ['Unauthorized'] }\n */\n readonly credentialRefusedErrorCodes?: readonly string[];\n /**\n * Where a MUTATION's answer says the vendor refused it in the DATA rather than in `errors` (follow-up to #3392). Several\n * GraphQL vendors answer a write they refused with a successful response whose payload carries the refusal: Shopify's\n * `userErrors` list (\"validation failures, such as invalid field values or business logic violations, that prevent the\n * operation from completing\"), Linear's `success: Boolean!`. Without it such an answer is returned as the result and a\n * caller that does not read the payload takes a refused write for a done one; with it the call FAILS, carrying the\n * vendor's messages, exactly as an `errors` entry does. See {@link ProviderGraphqlPayloadRefusal}.\n * spec-cite: https://shopify.dev/docs/api/admin-graphql — the `UserError` description quoted above, fetched 2026-11-10.\n *\n * @example\n * // Shopify: productCreate's userErrors, each `{ field, message }`.\n * payloadRefusal: { kind: ProviderGraphqlPayloadRefusalKind.USER_ERRORS, path: 'productCreate.userErrors', messagePath: 'message', fieldPath: 'field' }\n */\n readonly payloadRefusal?: ProviderGraphqlPayloadRefusal;\n}\n\n/** How a mutation's payload states a refusal. See {@link ProviderRestOperationGraphql.payloadRefusal}. */\nexport enum ProviderGraphqlPayloadRefusalKind {\n /** A list of the vendor's refusals (Shopify's `userErrors`): the write was refused when the list is not empty. */\n USER_ERRORS = 'user_errors',\n /** A boolean the vendor sets to `false` when it did not do the write (Linear's `success`). */\n SUCCESS_FLAG = 'success_flag',\n}\n\n/**\n * Where a mutation's payload states a refusal (follow-up to #3392). Every path is a dot path, `path` from the answer's\n * `data` (as `resultPath` is), `messagePath`, `fieldPath` and `codePath` from inside each listed refusal.\n *\n * - {@link ProviderGraphqlPayloadRefusalKind.USER_ERRORS}: a non-empty list at `path` fails the call. Each entry's text at\n * `messagePath` (`message` when absent) is kept, prefixed with the input field it names at `fieldPath` (a string or a\n * list of path segments), and the first code-shaped value at `codePath` is the failure's code.\n * - {@link ProviderGraphqlPayloadRefusalKind.SUCCESS_FLAG}: `false` at `path` fails the call.\n *\n * Anything else at `path` (an absent payload, `true`, an empty list) refuses nothing: the answer is read as it is.\n */\nexport type ProviderGraphqlPayloadRefusal =\n | {\n readonly kind: ProviderGraphqlPayloadRefusalKind.USER_ERRORS;\n readonly path: string;\n readonly messagePath?: string;\n readonly fieldPath?: string;\n readonly codePath?: string;\n }\n | { readonly kind: ProviderGraphqlPayloadRefusalKind.SUCCESS_FLAG; readonly path: string };\n\n/** What a GraphQL document's operation does. A `subscription` is not served over a single POST, so it is no member. */\nexport enum ProviderGraphqlOperationType {\n /** Reads. The operation must be classified READ. */\n QUERY = 'query',\n /** Changes the vendor. The operation must be classified WRITE. */\n MUTATION = 'mutation',\n}\n\n/**\n * The `Accept` a GraphQL call sends: the GraphQL response media type first, `application/json` for a server that predates\n * it (GraphQL over HTTP §4.2, quoted in this module's header).\n * semantic-literal-boundary: the media types GraphQL over HTTP names, sent on the wire.\n */\nexport const PROVIDER_GRAPHQL_ACCEPT_HEADER = 'application/graphql-response+json, application/json;q=0.9';\n\n/** At most this many of the vendor's error messages are kept on a failure. */\nexport const PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES = 10;\n/** A kept error message is cut at this many characters. */\nexport const PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH = 500;\n\n/** One operation a document defines, as {@link readProviderGraphqlDocument} reads it. */\nexport interface ProviderGraphqlDocumentOperation {\n /** `query`, `mutation` or `subscription`, as written (an anonymous `{ … }` is a query). */\n readonly type: string;\n /** Absent for an anonymous operation. */\n readonly name?: string;\n /** The variables it declares, without their `$`, in order. */\n readonly variables: readonly string[];\n}\n\n/** What a document holds, or why it cannot be read. */\nexport interface ProviderGraphqlDocumentShape {\n readonly operations: readonly ProviderGraphqlDocumentOperation[];\n /** Set when the text is not a document of executable definitions. `operations` is then what was read before it. */\n readonly defect?: string;\n}\n\nconst GRAPHQL_NAME = /^[_A-Za-z][_0-9A-Za-z]*$/;\nconst GRAPHQL_PUNCTUATORS = new Set(['!', '$', '&', '(', ')', ':', '=', '@', '[', ']', '{', '|', '}']);\n\n/**\n * The tokens of a GraphQL document, with strings and comments dropped: enough to find its definitions and their\n * variables. Not a validating parser: the vendor's server is the parser that decides, and this only has to see the\n * document's outline. A block string (`\"\"\"…\"\"\"`) and a string (`\"…\"`, with `\\` escapes) are skipped whole, so a brace or\n * a `$` inside one is never read as structure. `undefined` for a string that never closes.\n */\nfunction tokenizeGraphqlDocument(document: string): string[] | undefined {\n const tokens: string[] = [];\n let index = 0;\n while (index < document.length) {\n const character = document[index]!;\n if (character === '#') {\n while (index < document.length && document[index] !== '\\n' && document[index] !== '\\r') index += 1;\n continue;\n }\n if (character === '\"') {\n if (document.startsWith('\"\"\"', index)) {\n const close = document.indexOf('\"\"\"', index + 3);\n // A `\\\"\"\"` inside a block string is an escaped delimiter, not its end.\n let end = close;\n while (end !== -1 && document[end - 1] === '\\\\') end = document.indexOf('\"\"\"', end + 3);\n if (end === -1) return undefined;\n index = end + 3;\n } else {\n index += 1;\n while (index < document.length && document[index] !== '\"') {\n if (document[index] === '\\n') return undefined;\n index += document[index] === '\\\\' ? 2 : 1;\n }\n if (index >= document.length) return undefined;\n index += 1;\n }\n tokens.push('\"');\n continue;\n }\n if (character === '.' && document.startsWith('...', index)) {\n tokens.push('...');\n index += 3;\n continue;\n }\n if (GRAPHQL_PUNCTUATORS.has(character)) {\n tokens.push(character);\n index += 1;\n continue;\n }\n if (/[_A-Za-z0-9.+-]/.test(character)) {\n let end = index + 1;\n while (end < document.length && /[_A-Za-z0-9.+-]/.test(document[end]!)) end += 1;\n tokens.push(document.slice(index, end));\n index = end;\n continue;\n }\n // White space, commas (insignificant in GraphQL) and the byte order mark.\n index += 1;\n }\n return tokens;\n}\n\n/**\n * The executable definitions of a GraphQL document (#3392): each operation's type, name and declared variables. A\n * fragment is skipped; a type-system definition (`type`, `schema`, …) is a defect, since a document sent to a server is\n * executable only.\n */\nexport function readProviderGraphqlDocument(document: string): ProviderGraphqlDocumentShape {\n const tokens = tokenizeGraphqlDocument(document);\n if (tokens === undefined) return { operations: [], defect: 'a string in it never closes' };\n const operations: ProviderGraphqlDocumentOperation[] = [];\n let index = 0;\n /** Skips the balanced block opening at `index` (a `{` or a `(`), and answers the index after it, or -1. */\n const skipBalanced = (open: string, close: string): number => {\n let depth = 0;\n for (let position = index; position < tokens.length; position += 1) {\n if (tokens[position] === open) depth += 1;\n else if (tokens[position] === close) {\n depth -= 1;\n if (depth === 0) return position + 1;\n }\n }\n return -1;\n };\n while (index < tokens.length) {\n const token = tokens[index]!;\n if (token === '{') {\n const after = skipBalanced('{', '}');\n if (after === -1) return { operations, defect: 'a selection set never closes' };\n operations.push({ type: 'query', variables: [] });\n index = after;\n continue;\n }\n if (token === 'query' || token === 'mutation' || token === 'subscription') {\n index += 1;\n const name = tokens[index] !== undefined && GRAPHQL_NAME.test(tokens[index]!) ? tokens[index] : undefined;\n if (name !== undefined) index += 1;\n const variables: string[] = [];\n if (tokens[index] === '(') {\n const after = skipBalanced('(', ')');\n if (after === -1) return { operations, defect: `the variable definitions of ${name ?? 'an operation'} never close` };\n // A definition is `$name :`; a default value is constant and holds no variable.\n for (let position = index; position < after - 2; position += 1) {\n if (tokens[position] === '$' && tokens[position + 2] === ':' && GRAPHQL_NAME.test(tokens[position + 1]!)) variables.push(tokens[position + 1]!);\n }\n index = after;\n }\n while (index < tokens.length && tokens[index] !== '{') index += 1;\n if (index >= tokens.length) return { operations, defect: `${name ?? 'an operation'} has no selection set` };\n const after = skipBalanced('{', '}');\n if (after === -1) return { operations, defect: `the selection set of ${name ?? 'an operation'} never closes` };\n operations.push({ type: token, ...(name === undefined ? {} : { name }), variables });\n index = after;\n continue;\n }\n if (token === 'fragment') {\n while (index < tokens.length && tokens[index] !== '{') index += 1;\n if (index >= tokens.length) return { operations, defect: 'a fragment has no selection set' };\n const after = skipBalanced('{', '}');\n if (after === -1) return { operations, defect: 'a fragment\\'s selection set never closes' };\n index = after;\n continue;\n }\n return { operations, defect: `'${token}' begins no executable definition (an operation or a fragment)` };\n }\n return { operations };\n}\n\n/**\n * The top-level fields an input schema declares, read through Zod's own definition (`_zod.def`) as the input-options\n * check reads it, so a module built against another copy of Zod is read the same. Wrappers that keep the value's shape\n * are seen through; a union declares what any of its options declares. `undefined` when the schema is not an object\n * (or a union of objects), so its fields cannot be listed.\n */\nfunction inputSchemaTopLevelFields(schema: unknown): Set<string> | undefined {\n let current: unknown = schema;\n for (let depth = 0; depth < 64; depth += 1) {\n const def = (current as { _zod?: { def?: Record<string, unknown> } } | undefined)?._zod?.def;\n if (def === undefined) return undefined;\n switch (def.type) {\n case 'optional': case 'nullable': case 'default': case 'prefault': case 'readonly': case 'catch': case 'nonoptional':\n current = def.innerType;\n continue;\n case 'pipe':\n current = def.in;\n continue;\n case 'lazy':\n current = typeof def.getter === 'function' ? (def.getter as () => unknown)() : undefined;\n continue;\n case 'object':\n return new Set(Object.keys((def.shape as Record<string, unknown> | undefined) ?? {}));\n case 'union': {\n const fields = new Set<string>();\n for (const option of Array.isArray(def.options) ? def.options : []) {\n const optionFields = inputSchemaTopLevelFields(option);\n if (optionFields === undefined) return undefined;\n for (const field of optionFields) fields.add(field);\n }\n return fields;\n }\n default:\n return undefined;\n }\n }\n return undefined;\n}\n\n/**\n * Why a GraphQL operation cannot be sent as declared, or an empty list (#3392). Empty for an operation without\n * `graphql`. Checked where a catalogue loads (the operation executor, an augmentation merge), at `wildo registry publish`,\n * and by the request compiler on every call, so the one rule refuses in every place:\n *\n * - the call is a POST with no `requestBody`, every parameter carries a `constantValue` (the input is the variables\n * and nothing else), and the answer is read as JSON;\n * - the document reads as exactly ONE operation, named `operationName`, beside any fragments;\n * - a `query` is classified READ and a `mutation` WRITE; a `subscription` is refused;\n * - each declared variable is a top-level field of `inputSchema`, and each top-level field is a declared variable, so no\n * value a caller supplies is silently dropped (when `inputSchema` lists its fields; without one, the call refuses a\n * value for a variable the document does not declare);\n * - `errorCodePath` is a dot path;\n * - each of `credentialRefusedErrorCodes` is code-shaped (a value of any other shape is never kept, so it could never\n * match), and the list comes with an `errorCodePath` to read the code at;\n * - a `payloadRefusal` belongs to a mutation, names a kind of its vocabulary, and reads every path as a dot path.\n */\nexport function describeProviderRestOperationGraphqlDefects(\n operation: Pick<\n ProviderRestOperation,\n 'operationId' | 'method' | 'classification' | 'parameters' | 'requestBody' | 'responseDecoding' | 'binaryResponse' | 'inputSchema' | 'graphql'\n >,\n): string[] {\n const graphql = operation.graphql;\n if (graphql === undefined) return [];\n const at = `GraphQL operation '${operation.operationId}'`;\n const defects: string[] = [];\n if (operation.method !== API_HttpMethod.POST) defects.push(`${at} is sent with ${operation.method}; a GraphQL call is a POST`);\n if (operation.requestBody !== undefined) defects.push(`${at} declares a requestBody; its body is the document and its variables`);\n for (const parameter of operation.parameters ?? []) {\n if (parameter.constantValue === undefined) {\n defects.push(`${at} declares the ${parameter.in} parameter '${parameter.name}' fed by the input; its input is the document's variables only, so a parameter must carry a constantValue`);\n }\n }\n if (operation.responseDecoding !== undefined && operation.responseDecoding !== ProviderRestResponseDecoding.JSON) defects.push(`${at} reads its answer as ${operation.responseDecoding}; a GraphQL answer is JSON`);\n if (operation.binaryResponse !== undefined) defects.push(`${at} declares binaryResponse; a GraphQL answer is JSON`);\n if (!GRAPHQL_NAME.test(graphql.operationName)) defects.push(`${at} names the operation '${graphql.operationName}', which is not a GraphQL name`);\n if (graphql.errorCodePath !== undefined && graphql.errorCodePath.split('.').some((segment) => segment.length === 0)) {\n defects.push(`${at} reads its error code at '${graphql.errorCodePath}', which is not a dot path`);\n }\n const payloadRefusal = graphql.payloadRefusal;\n if (payloadRefusal !== undefined) {\n const kinds: readonly string[] = Object.values(ProviderGraphqlPayloadRefusalKind);\n if (!kinds.includes(payloadRefusal.kind)) defects.push(`${at} declares the payload refusal kind ${JSON.stringify(payloadRefusal.kind)}, which is none of ${kinds.join(', ')}`);\n const paths: [string, string | undefined][] = [['path', payloadRefusal.path]];\n if (payloadRefusal.kind === ProviderGraphqlPayloadRefusalKind.USER_ERRORS) {\n paths.push(['messagePath', payloadRefusal.messagePath], ['fieldPath', payloadRefusal.fieldPath], ['codePath', payloadRefusal.codePath]);\n }\n for (const [field, value] of paths) {\n if (value === undefined && field !== 'path') continue;\n if (typeof value !== 'string' || value.length === 0 || value.split('.').some((segment) => segment.length === 0)) {\n defects.push(`${at} reads its payload refusal's ${field} at ${JSON.stringify(value)}, which is not a dot path`);\n }\n }\n }\n if (graphql.credentialRefusedErrorCodes !== undefined && graphql.errorCodePath === undefined) {\n defects.push(`${at} lists credentialRefusedErrorCodes but no errorCodePath, so no code is read and none of them could ever match`);\n }\n for (const code of graphql.credentialRefusedErrorCodes ?? []) {\n if (!PROVIDER_VENDOR_ERROR_CODE_SHAPE.test(code)) {\n defects.push(`${at} lists the credential-refusal code '${code}', which is not code-shaped and would never match a code the transport keeps`);\n }\n }\n\n const shape = readProviderGraphqlDocument(graphql.document);\n if (shape.defect !== undefined) {\n defects.push(`${at}: its document does not read as a GraphQL document (${shape.defect})`);\n return defects;\n }\n const named = shape.operations.filter((candidate) => candidate.name === graphql.operationName);\n if (named.length !== 1 || shape.operations.length !== 1) {\n defects.push(\n `${at}: its document must define exactly one operation, named '${graphql.operationName}', and it defines `\n + `${shape.operations.length === 0 ? 'none' : shape.operations.map((candidate) => `${candidate.type} ${candidate.name ?? '(anonymous)'}`).join(', ')}`,\n );\n return defects;\n }\n const [definition] = named as [ProviderGraphqlDocumentOperation];\n const expected = definition.type === ProviderGraphqlOperationType.QUERY ? ExternalOperation_Classification.READ\n : definition.type === ProviderGraphqlOperationType.MUTATION ? ExternalOperation_Classification.WRITE\n : undefined;\n if (expected === undefined) defects.push(`${at} is a ${definition.type}, which is not answered over a single POST`);\n // A refusal stated in a payload is a WRITE's: a query that answers data refused nothing.\n if (graphql.payloadRefusal !== undefined && definition.type !== ProviderGraphqlOperationType.MUTATION) {\n defects.push(`${at} is a ${definition.type} and declares a payload refusal, which only a mutation's payload states`);\n }\n else if (operation.classification !== expected) defects.push(`${at} is a ${definition.type} classified ${operation.classification}; a query is a READ and a mutation a WRITE`);\n\n const fields = operation.inputSchema === undefined ? undefined : inputSchemaTopLevelFields(operation.inputSchema);\n if (operation.inputSchema !== undefined && fields === undefined) {\n defects.push(`${at} has an inputSchema that is not an object, and its input is the document's variables`);\n }\n if (fields !== undefined) {\n for (const variable of definition.variables) {\n if (!fields.has(variable)) defects.push(`${at} declares the variable '$${variable}', which its inputSchema does not declare`);\n }\n for (const field of fields) {\n if (!definition.variables.includes(field)) defects.push(`${at}: its inputSchema declares '${field}', which is no variable of the document, so a value for it would never be sent`);\n }\n }\n return defects;\n}\n\n/** The variables a GraphQL operation's document declares, or `undefined` when the document cannot be read. */\nexport function providerGraphqlOperationVariables(graphql: ProviderRestOperationGraphql): readonly string[] | undefined {\n const shape = readProviderGraphqlDocument(graphql.document);\n if (shape.defect !== undefined) return undefined;\n return shape.operations.find((candidate) => candidate.name === graphql.operationName)?.variables;\n}\n\n/** What a GraphQL answer says about the call. See the table in this module's header. */\nexport enum ProviderGraphqlResponseOutcomeKind {\n /** `data` is an object and no error was reported. */\n SUCCEEDED = 'succeeded',\n /** Errors, and no `data` entry: the request was refused before anything executed. Nothing was applied. */\n REQUEST_ERROR = 'request_error',\n /** Errors beside a `data` entry (null or partial): execution began and something failed. */\n EXECUTION_ERROR = 'execution_error',\n /** Neither a `data` object nor an error list: the answer does not state what happened. */\n UNSTATED = 'unstated',\n /**\n * `data` and no `errors`, and the mutation's payload states the vendor refused it (its declared `payloadRefusal`): the\n * write was not done, as the vendor says (follow-up to #3392).\n */\n PAYLOAD_REFUSED = 'payload_refused',\n}\n\n/** What {@link readProviderGraphqlResponse} read. */\nexport interface ProviderGraphqlResponseVerdict {\n readonly kind: ProviderGraphqlResponseOutcomeKind;\n /** On SUCCEEDED, the answer's `data` object: what the operation's `resultPath` and `outputSchema` read. */\n readonly data?: Readonly<Record<string, unknown>>;\n /**\n * The vendor's error messages, in its order, at most {@link PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES}, each cut at\n * {@link PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH} characters. Vendor prose: it may quote what the call sent, so it\n * travels to the caller and is never written to a log or an audit row by the engine.\n */\n readonly errorMessages?: readonly string[];\n /** The first code-shaped value at the operation's `errorCodePath` among the errors, when one is declared and found. */\n readonly errorCode?: string;\n}\n\n/** The value at a dot path, read through own properties only (an array's index is an own property), or `undefined`. */\nfunction readGraphqlDotPath(value: unknown, path: string): unknown {\n let current: unknown = value;\n for (const segment of path.split('.')) {\n if (current === null || typeof current !== 'object' || !Object.hasOwn(current, segment)) return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n}\n\nfunction readGraphqlErrorCode(error: unknown, errorCodePath: string): string | undefined {\n const current = readGraphqlDotPath(error, errorCodePath);\n return typeof current === 'string' && PROVIDER_VENDOR_ERROR_CODE_SHAPE.test(current) ? current : undefined;\n}\n\n/** A vendor message as the verdict keeps it: cut at {@link PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH}. */\nfunction keptGraphqlMessage(message: string): string {\n return message.length > PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH ? `${message.slice(0, PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGE_LENGTH)}…` : message;\n}\n\n/**\n * The refusal a mutation's payload states, read as its declaration says ({@link ProviderGraphqlPayloadRefusal}), or\n * `undefined` when the payload refuses nothing.\n */\nfunction readGraphqlPayloadRefusal(\n data: Readonly<Record<string, unknown>>,\n refusal: ProviderGraphqlPayloadRefusal,\n): Pick<ProviderGraphqlResponseVerdict, 'errorMessages' | 'errorCode'> | undefined {\n const stated = readGraphqlDotPath(data, refusal.path);\n if (refusal.kind === ProviderGraphqlPayloadRefusalKind.SUCCESS_FLAG) {\n return stated === false ? { errorMessages: [`the answer's ${refusal.path} is false: the vendor did not do the write`] } : undefined;\n }\n if (!Array.isArray(stated) || stated.length === 0) return undefined;\n const errorMessages = stated.slice(0, PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES).map((entry) => {\n const message = readGraphqlDotPath(entry, refusal.messagePath ?? 'message');\n const field = refusal.fieldPath === undefined ? undefined : readGraphqlDotPath(entry, refusal.fieldPath);\n const fieldText = typeof field === 'string' ? field\n : Array.isArray(field) && field.every((segment) => typeof segment === 'string' || typeof segment === 'number') ? field.join('.') : undefined;\n const text = typeof message === 'string' ? message : 'the vendor refused the write without a message';\n return keptGraphqlMessage(fieldText === undefined || fieldText.length === 0 ? text : `${fieldText}: ${text}`);\n });\n const errorCode = refusal.codePath === undefined ? undefined\n : stated.map((entry) => readGraphqlErrorCode(entry, refusal.codePath!)).find((code) => code !== undefined);\n return { errorMessages, ...(errorCode === undefined ? {} : { errorCode }) };\n}\n\n/**\n * Reads a parsed GraphQL answer (#3392). The ONE reader: the engine's transport, for a 2xx and a non-2xx answer alike,\n * and every test go through it. See the module header for the rule and its sources.\n */\nexport function readProviderGraphqlResponse(\n body: unknown,\n errorCodePath?: string,\n payloadRefusal?: ProviderGraphqlPayloadRefusal,\n): ProviderGraphqlResponseVerdict {\n if (body === null || typeof body !== 'object' || Array.isArray(body)) return { kind: ProviderGraphqlResponseOutcomeKind.UNSTATED };\n const answer = body as Record<string, unknown>;\n const errors = Object.hasOwn(answer, 'errors') ? answer.errors : undefined;\n if (errors !== undefined && errors !== null && !Array.isArray(errors)) return { kind: ProviderGraphqlResponseOutcomeKind.UNSTATED };\n if (Array.isArray(errors) && errors.length > 0) {\n const errorMessages = errors\n .map((error) => (error !== null && typeof error === 'object' && typeof (error as { message?: unknown }).message === 'string' ? (error as { message: string }).message : undefined))\n .filter((message): message is string => message !== undefined)\n .slice(0, PROVIDER_GRAPHQL_MAXIMUM_ERROR_MESSAGES)\n .map(keptGraphqlMessage);\n const errorCode = errorCodePath === undefined ? undefined\n : errors.map((error) => readGraphqlErrorCode(error, errorCodePath)).find((code) => code !== undefined);\n return {\n kind: Object.hasOwn(answer, 'data') ? ProviderGraphqlResponseOutcomeKind.EXECUTION_ERROR : ProviderGraphqlResponseOutcomeKind.REQUEST_ERROR,\n errorMessages,\n ...(errorCode === undefined ? {} : { errorCode }),\n };\n }\n const data = Object.hasOwn(answer, 'data') ? answer.data : undefined;\n if (data === null || typeof data !== 'object' || Array.isArray(data)) return { kind: ProviderGraphqlResponseOutcomeKind.UNSTATED };\n const refused = payloadRefusal === undefined ? undefined : readGraphqlPayloadRefusal(data as Record<string, unknown>, payloadRefusal);\n if (refused !== undefined) return { kind: ProviderGraphqlResponseOutcomeKind.PAYLOAD_REFUSED, ...refused };\n return { kind: ProviderGraphqlResponseOutcomeKind.SUCCEEDED, data: data as Record<string, unknown> };\n}\n/** @wildo_source:part:end external-connectors.models.rest-operation-contract */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks-capability.external-connectors-models.schemas.d.ts","sourceRoot":"","sources":["../../../../src/protocols/hooks-capability.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,sBAAsB;IACtB,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;CAC1B;AAMD;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAMD;;;;;;;;;GASG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,eAAe,CACb,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACxC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9B;;;OAGG;IACH,UAAU,CACR,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,wBAAwB,GAAG,IAAI,CAAC;CACpC;AAMD;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,WAAW,CACT,gBAAgB,EAAE,OAAO,EAAE,wEAAwE;IACnG,WAAW,EAAE,wBAAwB,GACpC,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAMD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,0BAA0B;IACzC,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,mDAAmD;IACnD,YAAY,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEzF,wFAAwF;IACxF,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7C"}
1
+ {"version":3,"file":"hooks-capability.external-connectors-models.schemas.d.ts","sourceRoot":"","sources":["../../../src/protocols/hooks-capability.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,sBAAsB;IACtB,SAAS,EAAE,IAAI,GAAG,MAAM,C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