1 | {"version":3,"file":"utils.cjs","sources":["fromError.js","toPromise.js","fromPromise.js","throwServerError.js","validateOperation.js","createOperation.js","transformOperation.js","filterOperationVariables.js"],"sourcesContent":["import { Observable } from \"../../utilities/index.js\";\nexport function fromError(errorValue) {\n return new Observable(function (observer) {\n observer.error(errorValue);\n });\n}\n//# sourceMappingURL=fromError.js.map","import { invariant } from \"../../utilities/globals/index.js\";\nexport function toPromise(observable) {\n var completed = false;\n return new Promise(function (resolve, reject) {\n observable.subscribe({\n next: function (data) {\n if (completed) {\n globalThis.__DEV__ !== false && invariant.warn(43);\n }\n else {\n completed = true;\n resolve(data);\n }\n },\n error: reject,\n });\n });\n}\n//# sourceMappingURL=toPromise.js.map","import { Observable } from \"../../utilities/index.js\";\nexport function fromPromise(promise) {\n return new Observable(function (observer) {\n promise\n .then(function (value) {\n observer.next(value);\n observer.complete();\n })\n .catch(observer.error.bind(observer));\n });\n}\n//# sourceMappingURL=fromPromise.js.map","export var throwServerError = function (response, result, message) {\n var error = new Error(message);\n error.name = \"ServerError\";\n error.response = response;\n error.statusCode = response.status;\n error.result = result;\n throw error;\n};\n//# sourceMappingURL=throwServerError.js.map","import { newInvariantError } from \"../../utilities/globals/index.js\";\nexport function validateOperation(operation) {\n var OPERATION_FIELDS = [\n \"query\",\n \"operationName\",\n \"variables\",\n \"extensions\",\n \"context\",\n ];\n for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {\n var key = _a[_i];\n if (OPERATION_FIELDS.indexOf(key) < 0) {\n throw newInvariantError(44, key);\n }\n }\n return operation;\n}\n//# sourceMappingURL=validateOperation.js.map","import { __assign } from \"tslib\";\nexport function createOperation(starting, operation) {\n var context = __assign({}, starting);\n var setContext = function (next) {\n if (typeof next === \"function\") {\n context = __assign(__assign({}, context), next(context));\n }\n else {\n context = __assign(__assign({}, context), next);\n }\n };\n var getContext = function () { return (__assign({}, context)); };\n Object.defineProperty(operation, \"setContext\", {\n enumerable: false,\n value: setContext,\n });\n Object.defineProperty(operation, \"getContext\", {\n enumerable: false,\n value: getContext,\n });\n return operation;\n}\n//# sourceMappingURL=createOperation.js.map","import { getOperationName } from \"../../utilities/index.js\";\nexport function transformOperation(operation) {\n var transformedOperation = {\n variables: operation.variables || {},\n extensions: operation.extensions || {},\n operationName: operation.operationName,\n query: operation.query,\n };\n // Best guess at an operation name\n if (!transformedOperation.operationName) {\n transformedOperation.operationName =\n typeof transformedOperation.query !== \"string\" ?\n getOperationName(transformedOperation.query) || undefined\n : \"\";\n }\n return transformedOperation;\n}\n//# sourceMappingURL=transformOperation.js.map","import { __assign } from \"tslib\";\nimport { visit } from \"graphql\";\nexport function filterOperationVariables(variables, query) {\n var result = __assign({}, variables);\n var unusedNames = new Set(Object.keys(variables));\n visit(query, {\n Variable: function (node, _key, parent) {\n // A variable type definition at the top level of a query is not\n // enough to silence server-side errors about the variable being\n // unused, so variable definitions do not count as usage.\n // https://spec.graphql.org/draft/#sec-All-Variables-Used\n if (parent &&\n parent.kind !== \"VariableDefinition\") {\n unusedNames.delete(node.name.value);\n }\n },\n });\n unusedNames.forEach(function (name) {\n delete result[name];\n });\n return result;\n}\n//# sourceMappingURL=filterOperationVariables.js.map"],"names":["Observable","invariant","newInvariantError","__assign","getOperationName","visit"],"mappings":";;;;;;;;;AACO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,OAAO,IAAIA,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAC9C,QAAQ,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACnC,KAAK,CAAC,CAAC;AACP;;ACJO,SAAS,SAAS,CAAC,UAAU,EAAE;AACtC,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC;AAC1B,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM,EAAE;AAClD,QAAQ,UAAU,CAAC,SAAS,CAAC;AAC7B,YAAY,IAAI,EAAE,UAAU,IAAI,EAAE;AAClC,gBAAgB,IAAI,SAAS,EAAE;AAC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