Odoo GraphQL Subscription using Node, Express JS for Sample
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
8.4 KiB

4 months ago
{"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(42);\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(43, 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 vi