UNPKG

@nacelle/compatibility-connector

Version:

Connect @nacelle/client-js-sdk to Nacelle's v2 back end with minimal code changes

1,646 lines 314 kB
var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __objRest = (source, exclude) => { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) { if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } return target; }; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; import { NacelleGraphQLConnector } from "@nacelle/client-js-sdk"; var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } var backoff = {}; var options = {}; var __assign = commonjsGlobal && commonjsGlobal.__assign || function() { __assign = Object.assign || function(t2) { for (var s2, i2 = 1, n = arguments.length; i2 < n; i2++) { s2 = arguments[i2]; for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t2[p2] = s2[p2]; } return t2; }; return __assign.apply(this, arguments); }; Object.defineProperty(options, "__esModule", { value: true }); var defaultOptions = { delayFirstAttempt: false, jitter: "none", maxDelay: Infinity, numOfAttempts: 10, retry: function() { return true; }, startingDelay: 100, timeMultiple: 2 }; function getSanitizedOptions(options2) { var sanitized = __assign(__assign({}, defaultOptions), options2); if (sanitized.numOfAttempts < 1) { sanitized.numOfAttempts = 1; } return sanitized; } options.getSanitizedOptions = getSanitizedOptions; var delay_factory = {}; var skipFirst_delay = {}; var delay_base = {}; var jitter_factory = {}; var full_jitter = {}; Object.defineProperty(full_jitter, "__esModule", { value: true }); function fullJitter(delay) { var jitteredDelay = Math.random() * delay; return Math.round(jitteredDelay); } full_jitter.fullJitter = fullJitter; var no_jitter = {}; Object.defineProperty(no_jitter, "__esModule", { value: true }); function noJitter(delay) { return delay; } no_jitter.noJitter = noJitter; Object.defineProperty(jitter_factory, "__esModule", { value: true }); var full_jitter_1 = full_jitter; var no_jitter_1 = no_jitter; function JitterFactory(options2) { switch (options2.jitter) { case "full": return full_jitter_1.fullJitter; case "none": default: return no_jitter_1.noJitter; } } jitter_factory.JitterFactory = JitterFactory; Object.defineProperty(delay_base, "__esModule", { value: true }); var jitter_factory_1 = jitter_factory; var Delay = function() { function Delay2(options2) { this.options = options2; this.attempt = 0; } Delay2.prototype.apply = function() { var _this = this; return new Promise(function(resolve) { return setTimeout(resolve, _this.jitteredDelay); }); }; Delay2.prototype.setAttemptNumber = function(attempt) { this.attempt = attempt; }; Object.defineProperty(Delay2.prototype, "jitteredDelay", { get: function() { var jitter = jitter_factory_1.JitterFactory(this.options); return jitter(this.delay); }, enumerable: true, configurable: true }); Object.defineProperty(Delay2.prototype, "delay", { get: function() { var constant = this.options.startingDelay; var base = this.options.timeMultiple; var power = this.numOfDelayedAttempts; var delay = constant * Math.pow(base, power); return Math.min(delay, this.options.maxDelay); }, enumerable: true, configurable: true }); Object.defineProperty(Delay2.prototype, "numOfDelayedAttempts", { get: function() { return this.attempt; }, enumerable: true, configurable: true }); return Delay2; }(); delay_base.Delay = Delay; var __extends$1 = commonjsGlobal && commonjsGlobal.__extends || function() { var extendStatics = function(d2, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b2) { d3.__proto__ = b2; } || function(d3, b2) { for (var p2 in b2) if (b2.hasOwnProperty(p2)) d3[p2] = b2[p2]; }; return extendStatics(d2, b); }; return function(d2, b) { extendStatics(d2, b); function __() { this.constructor = d2; } d2.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); var __awaiter$1 = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); }); } return new (P || (P = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator$1 = commonjsGlobal && commonjsGlobal.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t2[0] & 1) throw t2[1]; return t2[1]; }, trys: [], ops: [] }, f2, y, t2, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { return step([n, v]); }; } function step(op) { if (f2) throw new TypeError("Generator is already executing."); while (_) try { if (f2 = 1, y && (t2 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t2 = y["return"]) && t2.call(y), 0) : y.next) && !(t2 = t2.call(y, op[1])).done) return t2; if (y = 0, t2) op = [op[0] & 2, t2.value]; switch (op[0]) { case 0: case 1: t2 = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t2 = _.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t2[1]) { _.label = t2[1]; t2 = op; break; } if (t2 && _.label < t2[2]) { _.label = t2[2]; _.ops.push(op); break; } if (t2[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f2 = t2 = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(skipFirst_delay, "__esModule", { value: true }); var delay_base_1$1 = delay_base; var SkipFirstDelay = function(_super) { __extends$1(SkipFirstDelay2, _super); function SkipFirstDelay2() { return _super !== null && _super.apply(this, arguments) || this; } SkipFirstDelay2.prototype.apply = function() { return __awaiter$1(this, void 0, void 0, function() { return __generator$1(this, function(_a) { return [2, this.isFirstAttempt ? true : _super.prototype.apply.call(this)]; }); }); }; Object.defineProperty(SkipFirstDelay2.prototype, "isFirstAttempt", { get: function() { return this.attempt === 0; }, enumerable: true, configurable: true }); Object.defineProperty(SkipFirstDelay2.prototype, "numOfDelayedAttempts", { get: function() { return this.attempt - 1; }, enumerable: true, configurable: true }); return SkipFirstDelay2; }(delay_base_1$1.Delay); skipFirst_delay.SkipFirstDelay = SkipFirstDelay; var always_delay = {}; var __extends = commonjsGlobal && commonjsGlobal.__extends || function() { var extendStatics = function(d2, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b2) { d3.__proto__ = b2; } || function(d3, b2) { for (var p2 in b2) if (b2.hasOwnProperty(p2)) d3[p2] = b2[p2]; }; return extendStatics(d2, b); }; return function(d2, b) { extendStatics(d2, b); function __() { this.constructor = d2; } d2.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); Object.defineProperty(always_delay, "__esModule", { value: true }); var delay_base_1 = delay_base; var AlwaysDelay = function(_super) { __extends(AlwaysDelay2, _super); function AlwaysDelay2() { return _super !== null && _super.apply(this, arguments) || this; } return AlwaysDelay2; }(delay_base_1.Delay); always_delay.AlwaysDelay = AlwaysDelay; Object.defineProperty(delay_factory, "__esModule", { value: true }); var skip_first_delay_1 = skipFirst_delay; var always_delay_1 = always_delay; function DelayFactory(options2, attempt) { var delay = initDelayClass(options2); delay.setAttemptNumber(attempt); return delay; } delay_factory.DelayFactory = DelayFactory; function initDelayClass(options2) { if (!options2.delayFirstAttempt) { return new skip_first_delay_1.SkipFirstDelay(options2); } return new always_delay_1.AlwaysDelay(options2); } var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); }); } return new (P || (P = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = commonjsGlobal && commonjsGlobal.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t2[0] & 1) throw t2[1]; return t2[1]; }, trys: [], ops: [] }, f2, y, t2, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function(v) { return step([n, v]); }; } function step(op) { if (f2) throw new TypeError("Generator is already executing."); while (_) try { if (f2 = 1, y && (t2 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t2 = y["return"]) && t2.call(y), 0) : y.next) && !(t2 = t2.call(y, op[1])).done) return t2; if (y = 0, t2) op = [op[0] & 2, t2.value]; switch (op[0]) { case 0: case 1: t2 = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t2 = _.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t2[1]) { _.label = t2[1]; t2 = op; break; } if (t2 && _.label < t2[2]) { _.label = t2[2]; _.ops.push(op); break; } if (t2[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f2 = t2 = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(backoff, "__esModule", { value: true }); var options_1 = options; var delay_factory_1 = delay_factory; function backOff(request, options2) { if (options2 === void 0) { options2 = {}; } return __awaiter(this, void 0, void 0, function() { var sanitizedOptions, backOff2; return __generator(this, function(_a) { switch (_a.label) { case 0: sanitizedOptions = options_1.getSanitizedOptions(options2); backOff2 = new BackOff(request, sanitizedOptions); return [4, backOff2.execute()]; case 1: return [2, _a.sent()]; } }); }); } var backOff_1 = backoff.backOff = backOff; var BackOff = function() { function BackOff2(request, options2) { this.request = request; this.options = options2; this.attemptNumber = 0; } BackOff2.prototype.execute = function() { return __awaiter(this, void 0, void 0, function() { var e_1, shouldRetry2; return __generator(this, function(_a) { switch (_a.label) { case 0: if (!!this.attemptLimitReached) return [3, 7]; _a.label = 1; case 1: _a.trys.push([1, 4, , 6]); return [4, this.applyDelay()]; case 2: _a.sent(); return [4, this.request()]; case 3: return [2, _a.sent()]; case 4: e_1 = _a.sent(); this.attemptNumber++; return [4, this.options.retry(e_1, this.attemptNumber)]; case 5: shouldRetry2 = _a.sent(); if (!shouldRetry2 || this.attemptLimitReached) { throw e_1; } return [3, 6]; case 6: return [3, 0]; case 7: throw new Error("Something went wrong."); } }); }); }; Object.defineProperty(BackOff2.prototype, "attemptLimitReached", { get: function() { return this.attemptNumber >= this.options.numOfAttempts; }, enumerable: true, configurable: true }); BackOff2.prototype.applyDelay = function() { return __awaiter(this, void 0, void 0, function() { var delay; return __generator(this, function(_a) { switch (_a.label) { case 0: delay = delay_factory_1.DelayFactory(this.options, this.attemptNumber); return [4, delay.apply()]; case 1: _a.sent(); return [2]; } }); }); }; return BackOff2; }(); var browserPonyfill = { exports: {} }; (function(module, exports) { var global2 = typeof self !== "undefined" ? self : commonjsGlobal; var __self__ = function() { function F2() { this.fetch = false; this.DOMException = global2.DOMException; } F2.prototype = global2; return new F2(); }(); (function(self2) { (function(exports2) { var support = { searchParams: "URLSearchParams" in self2, iterable: "Symbol" in self2 && "iterator" in Symbol, blob: "FileReader" in self2 && "Blob" in self2 && function() { try { new Blob(); return true; } catch (e) { return false; } }(), formData: "FormData" in self2, arrayBuffer: "ArrayBuffer" in self2 }; function isDataView(obj) { return obj && DataView.prototype.isPrototypeOf(obj); } if (support.arrayBuffer) { var viewClasses = [ "[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]" ]; var isArrayBufferView = ArrayBuffer.isView || function(obj) { return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1; }; } function normalizeName(name) { if (typeof name !== "string") { name = String(name); } if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { throw new TypeError("Invalid character in header field name"); } return name.toLowerCase(); } function normalizeValue(value) { if (typeof value !== "string") { value = String(value); } return value; } function iteratorFor(items) { var iterator = { next: function() { var value = items.shift(); return { done: value === void 0, value }; } }; if (support.iterable) { iterator[Symbol.iterator] = function() { return iterator; }; } return iterator; } function Headers(headers) { this.map = {}; if (headers instanceof Headers) { headers.forEach(function(value, name) { this.append(name, value); }, this); } else if (Array.isArray(headers)) { headers.forEach(function(header) { this.append(header[0], header[1]); }, this); } else if (headers) { Object.getOwnPropertyNames(headers).forEach(function(name) { this.append(name, headers[name]); }, this); } } Headers.prototype.append = function(name, value) { name = normalizeName(name); value = normalizeValue(value); var oldValue = this.map[name]; this.map[name] = oldValue ? oldValue + ", " + value : value; }; Headers.prototype["delete"] = function(name) { delete this.map[normalizeName(name)]; }; Headers.prototype.get = function(name) { name = normalizeName(name); return this.has(name) ? this.map[name] : null; }; Headers.prototype.has = function(name) { return this.map.hasOwnProperty(normalizeName(name)); }; Headers.prototype.set = function(name, value) { this.map[normalizeName(name)] = normalizeValue(value); }; Headers.prototype.forEach = function(callback, thisArg) { for (var name in this.map) { if (this.map.hasOwnProperty(name)) { callback.call(thisArg, this.map[name], name, this); } } }; Headers.prototype.keys = function() { var items = []; this.forEach(function(value, name) { items.push(name); }); return iteratorFor(items); }; Headers.prototype.values = function() { var items = []; this.forEach(function(value) { items.push(value); }); return iteratorFor(items); }; Headers.prototype.entries = function() { var items = []; this.forEach(function(value, name) { items.push([name, value]); }); return iteratorFor(items); }; if (support.iterable) { Headers.prototype[Symbol.iterator] = Headers.prototype.entries; } function consumed(body) { if (body.bodyUsed) { return Promise.reject(new TypeError("Already read")); } body.bodyUsed = true; } function fileReaderReady(reader) { return new Promise(function(resolve, reject) { reader.onload = function() { resolve(reader.result); }; reader.onerror = function() { reject(reader.error); }; }); } function readBlobAsArrayBuffer(blob) { var reader = new FileReader(); var promise = fileReaderReady(reader); reader.readAsArrayBuffer(blob); return promise; } function readBlobAsText(blob) { var reader = new FileReader(); var promise = fileReaderReady(reader); reader.readAsText(blob); return promise; } function readArrayBufferAsText(buf) { var view = new Uint8Array(buf); var chars = new Array(view.length); for (var i2 = 0; i2 < view.length; i2++) { chars[i2] = String.fromCharCode(view[i2]); } return chars.join(""); } function bufferClone(buf) { if (buf.slice) { return buf.slice(0); } else { var view = new Uint8Array(buf.byteLength); view.set(new Uint8Array(buf)); return view.buffer; } } function Body() { this.bodyUsed = false; this._initBody = function(body) { this._bodyInit = body; if (!body) { this._bodyText = ""; } else if (typeof body === "string") { this._bodyText = body; } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { this._bodyBlob = body; } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { this._bodyFormData = body; } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { this._bodyText = body.toString(); } else if (support.arrayBuffer && support.blob && isDataView(body)) { this._bodyArrayBuffer = bufferClone(body.buffer); this._bodyInit = new Blob([this._bodyArrayBuffer]); } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { this._bodyArrayBuffer = bufferClone(body); } else { this._bodyText = body = Object.prototype.toString.call(body); } if (!this.headers.get("content-type")) { if (typeof body === "string") { this.headers.set("content-type", "text/plain;charset=UTF-8"); } else if (this._bodyBlob && this._bodyBlob.type) { this.headers.set("content-type", this._bodyBlob.type); } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"); } } }; if (support.blob) { this.blob = function() { var rejected = consumed(this); if (rejected) { return rejected; } if (this._bodyBlob) { return Promise.resolve(this._bodyBlob); } else if (this._bodyArrayBuffer) { return Promise.resolve(new Blob([this._bodyArrayBuffer])); } else if (this._bodyFormData) { throw new Error("could not read FormData body as blob"); } else { return Promise.resolve(new Blob([this._bodyText])); } }; this.arrayBuffer = function() { if (this._bodyArrayBuffer) { return consumed(this) || Promise.resolve(this._bodyArrayBuffer); } else { return this.blob().then(readBlobAsArrayBuffer); } }; } this.text = function() { var rejected = consumed(this); if (rejected) { return rejected; } if (this._bodyBlob) { return readBlobAsText(this._bodyBlob); } else if (this._bodyArrayBuffer) { return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)); } else if (this._bodyFormData) { throw new Error("could not read FormData body as text"); } else { return Promise.resolve(this._bodyText); } }; if (support.formData) { this.formData = function() { return this.text().then(decode); }; } this.json = function() { return this.text().then(JSON.parse); }; return this; } var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; function normalizeMethod(method) { var upcased = method.toUpperCase(); return methods.indexOf(upcased) > -1 ? upcased : method; } function Request(input, options2) { options2 = options2 || {}; var body = options2.body; if (input instanceof Request) { if (input.bodyUsed) { throw new TypeError("Already read"); } this.url = input.url; this.credentials = input.credentials; if (!options2.headers) { this.headers = new Headers(input.headers); } this.method = input.method; this.mode = input.mode; this.signal = input.signal; if (!body && input._bodyInit != null) { body = input._bodyInit; input.bodyUsed = true; } } else { this.url = String(input); } this.credentials = options2.credentials || this.credentials || "same-origin"; if (options2.headers || !this.headers) { this.headers = new Headers(options2.headers); } this.method = normalizeMethod(options2.method || this.method || "GET"); this.mode = options2.mode || this.mode || null; this.signal = options2.signal || this.signal; this.referrer = null; if ((this.method === "GET" || this.method === "HEAD") && body) { throw new TypeError("Body not allowed for GET or HEAD requests"); } this._initBody(body); } Request.prototype.clone = function() { return new Request(this, { body: this._bodyInit }); }; function decode(body) { var form = new FormData(); body.trim().split("&").forEach(function(bytes) { if (bytes) { var split = bytes.split("="); var name = split.shift().replace(/\+/g, " "); var value = split.join("=").replace(/\+/g, " "); form.append(decodeURIComponent(name), decodeURIComponent(value)); } }); return form; } function parseHeaders(rawHeaders) { var headers = new Headers(); var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " "); preProcessedHeaders.split(/\r?\n/).forEach(function(line) { var parts = line.split(":"); var key = parts.shift().trim(); if (key) { var value = parts.join(":").trim(); headers.append(key, value); } }); return headers; } Body.call(Request.prototype); function Response(bodyInit, options2) { if (!options2) { options2 = {}; } this.type = "default"; this.status = options2.status === void 0 ? 200 : options2.status; this.ok = this.status >= 200 && this.status < 300; this.statusText = "statusText" in options2 ? options2.statusText : "OK"; this.headers = new Headers(options2.headers); this.url = options2.url || ""; this._initBody(bodyInit); } Body.call(Response.prototype); Response.prototype.clone = function() { return new Response(this._bodyInit, { status: this.status, statusText: this.statusText, headers: new Headers(this.headers), url: this.url }); }; Response.error = function() { var response = new Response(null, { status: 0, statusText: "" }); response.type = "error"; return response; }; var redirectStatuses = [301, 302, 303, 307, 308]; Response.redirect = function(url, status) { if (redirectStatuses.indexOf(status) === -1) { throw new RangeError("Invalid status code"); } return new Response(null, { status, headers: { location: url } }); }; exports2.DOMException = self2.DOMException; try { new exports2.DOMException(); } catch (err) { exports2.DOMException = function(message, name) { this.message = message; this.name = name; var error = Error(message); this.stack = error.stack; }; exports2.DOMException.prototype = Object.create(Error.prototype); exports2.DOMException.prototype.constructor = exports2.DOMException; } function fetch2(input, init) { return new Promise(function(resolve, reject) { var request = new Request(input, init); if (request.signal && request.signal.aborted) { return reject(new exports2.DOMException("Aborted", "AbortError")); } var xhr = new XMLHttpRequest(); function abortXhr() { xhr.abort(); } xhr.onload = function() { var options2 = { status: xhr.status, statusText: xhr.statusText, headers: parseHeaders(xhr.getAllResponseHeaders() || "") }; options2.url = "responseURL" in xhr ? xhr.responseURL : options2.headers.get("X-Request-URL"); var body = "response" in xhr ? xhr.response : xhr.responseText; resolve(new Response(body, options2)); }; xhr.onerror = function() { reject(new TypeError("Network request failed")); }; xhr.ontimeout = function() { reject(new TypeError("Network request failed")); }; xhr.onabort = function() { reject(new exports2.DOMException("Aborted", "AbortError")); }; xhr.open(request.method, request.url, true); if (request.credentials === "include") { xhr.withCredentials = true; } else if (request.credentials === "omit") { xhr.withCredentials = false; } if ("responseType" in xhr && support.blob) { xhr.responseType = "blob"; } request.headers.forEach(function(value, name) { xhr.setRequestHeader(name, value); }); if (request.signal) { request.signal.addEventListener("abort", abortXhr); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { request.signal.removeEventListener("abort", abortXhr); } }; } xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit); }); } fetch2.polyfill = true; if (!self2.fetch) { self2.fetch = fetch2; self2.Headers = Headers; self2.Request = Request; self2.Response = Response; } exports2.Headers = Headers; exports2.Request = Request; exports2.Response = Response; exports2.fetch = fetch2; Object.defineProperty(exports2, "__esModule", { value: true }); return exports2; })({}); })(__self__); __self__.fetch.ponyfill = true; delete __self__.fetch.polyfill; var ctx = __self__; exports = ctx.fetch; exports.default = ctx.fetch; exports.fetch = ctx.fetch; exports.Headers = ctx.Headers; exports.Request = ctx.Request; exports.Response = ctx.Response; module.exports = exports; })(browserPonyfill, browserPonyfill.exports); var fetch$1 = /* @__PURE__ */ getDefaultExportFromCjs(browserPonyfill.exports); function devAssert(condition, message) { const booleanCondition = Boolean(condition); if (!booleanCondition) { throw new Error(message); } } const MAX_ARRAY_LENGTH = 10; const MAX_RECURSIVE_DEPTH = 2; function inspect(value) { return formatValue(value, []); } function formatValue(value, seenValues) { switch (typeof value) { case "string": return JSON.stringify(value); case "function": return value.name ? `[function ${value.name}]` : "[function]"; case "object": return formatObjectValue(value, seenValues); default: return String(value); } } function formatObjectValue(value, previouslySeenValues) { if (value === null) { return "null"; } if (previouslySeenValues.includes(value)) { return "[Circular]"; } const seenValues = [...previouslySeenValues, value]; if (isJSONable(value)) { const jsonValue = value.toJSON(); if (jsonValue !== value) { return typeof jsonValue === "string" ? jsonValue : formatValue(jsonValue, seenValues); } } else if (Array.isArray(value)) { return formatArray(value, seenValues); } return formatObject(value, seenValues); } function isJSONable(value) { return typeof value.toJSON === "function"; } function formatObject(object, seenValues) { const entries = Object.entries(object); if (entries.length === 0) { return "{}"; } if (seenValues.length > MAX_RECURSIVE_DEPTH) { return "[" + getObjectTag(object) + "]"; } const properties = entries.map( ([key, value]) => key + ": " + formatValue(value, seenValues) ); return "{ " + properties.join(", ") + " }"; } function formatArray(array, seenValues) { if (array.length === 0) { return "[]"; } if (seenValues.length > MAX_RECURSIVE_DEPTH) { return "[Array]"; } const len = Math.min(MAX_ARRAY_LENGTH, array.length); const remaining = array.length - len; const items = []; for (let i2 = 0; i2 < len; ++i2) { items.push(formatValue(array[i2], seenValues)); } if (remaining === 1) { items.push("... 1 more item"); } else if (remaining > 1) { items.push(`... ${remaining} more items`); } return "[" + items.join(", ") + "]"; } function getObjectTag(object) { const tag = Object.prototype.toString.call(object).replace(/^\[object /, "").replace(/]$/, ""); if (tag === "Object" && typeof object.constructor === "function") { const name = object.constructor.name; if (typeof name === "string" && name !== "") { return name; } } return tag; } class Location { constructor(startToken, endToken, source) { this.start = startToken.start; this.end = endToken.end; this.startToken = startToken; this.endToken = endToken; this.source = source; } get [Symbol.toStringTag]() { return "Location"; } toJSON() { return { start: this.start, end: this.end }; } } class Token { constructor(kind, start, end, line, column, value) { this.kind = kind; this.start = start; this.end = end; this.line = line; this.column = column; this.value = value; this.prev = null; this.next = null; } get [Symbol.toStringTag]() { return "Token"; } toJSON() { return { kind: this.kind, value: this.value, line: this.line, column: this.column }; } } const QueryDocumentKeys = { Name: [], Document: ["definitions"], OperationDefinition: [ "name", "variableDefinitions", "directives", "selectionSet" ], VariableDefinition: ["variable", "type", "defaultValue", "directives"], Variable: ["name"], SelectionSet: ["selections"], Field: ["alias", "name", "arguments", "directives", "selectionSet"], Argument: ["name", "value"], FragmentSpread: ["name", "directives"], InlineFragment: ["typeCondition", "directives", "selectionSet"], FragmentDefinition: [ "name", "variableDefinitions", "typeCondition", "directives", "selectionSet" ], IntValue: [], FloatValue: [], StringValue: [], BooleanValue: [], NullValue: [], EnumValue: [], ListValue: ["values"], ObjectValue: ["fields"], ObjectField: ["name", "value"], Directive: ["name", "arguments"], NamedType: ["name"], ListType: ["type"], NonNullType: ["type"], SchemaDefinition: ["description", "directives", "operationTypes"], OperationTypeDefinition: ["type"], ScalarTypeDefinition: ["description", "name", "directives"], ObjectTypeDefinition: [ "description", "name", "interfaces", "directives", "fields" ], FieldDefinition: ["description", "name", "arguments", "type", "directives"], InputValueDefinition: [ "description", "name", "type", "defaultValue", "directives" ], InterfaceTypeDefinition: [ "description", "name", "interfaces", "directives", "fields" ], UnionTypeDefinition: ["description", "name", "directives", "types"], EnumTypeDefinition: ["description", "name", "directives", "values"], EnumValueDefinition: ["description", "name", "directives"], InputObjectTypeDefinition: ["description", "name", "directives", "fields"], DirectiveDefinition: ["description", "name", "arguments", "locations"], SchemaExtension: ["directives", "operationTypes"], ScalarTypeExtension: ["name", "directives"], ObjectTypeExtension: ["name", "interfaces", "directives", "fields"], InterfaceTypeExtension: ["name", "interfaces", "directives", "fields"], UnionTypeExtension: ["name", "directives", "types"], EnumTypeExtension: ["name", "directives", "values"], InputObjectTypeExtension: ["name", "directives", "fields"] }; const kindValues = new Set(Object.keys(QueryDocumentKeys)); function isNode(maybeNode) { const maybeKind = maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind; return typeof maybeKind === "string" && kindValues.has(maybeKind); } var OperationTypeNode; (function(OperationTypeNode2) { OperationTypeNode2["QUERY"] = "query"; OperationTypeNode2["MUTATION"] = "mutation"; OperationTypeNode2["SUBSCRIPTION"] = "subscription"; })(OperationTypeNode || (OperationTypeNode = {})); var Kind; (function(Kind2) { Kind2["NAME"] = "Name"; Kind2["DOCUMENT"] = "Document"; Kind2["OPERATION_DEFINITION"] = "OperationDefinition"; Kind2["VARIABLE_DEFINITION"] = "VariableDefinition"; Kind2["SELECTION_SET"] = "SelectionSet"; Kind2["FIELD"] = "Field"; Kind2["ARGUMENT"] = "Argument"; Kind2["FRAGMENT_SPREAD"] = "FragmentSpread"; Kind2["INLINE_FRAGMENT"] = "InlineFragment"; Kind2["FRAGMENT_DEFINITION"] = "FragmentDefinition"; Kind2["VARIABLE"] = "Variable"; Kind2["INT"] = "IntValue"; Kind2["FLOAT"] = "FloatValue"; Kind2["STRING"] = "StringValue"; Kind2["BOOLEAN"] = "BooleanValue"; Kind2["NULL"] = "NullValue"; Kind2["ENUM"] = "EnumValue"; Kind2["LIST"] = "ListValue"; Kind2["OBJECT"] = "ObjectValue"; Kind2["OBJECT_FIELD"] = "ObjectField"; Kind2["DIRECTIVE"] = "Directive"; Kind2["NAMED_TYPE"] = "NamedType"; Kind2["LIST_TYPE"] = "ListType"; Kind2["NON_NULL_TYPE"] = "NonNullType"; Kind2["SCHEMA_DEFINITION"] = "SchemaDefinition"; Kind2["OPERATION_TYPE_DEFINITION"] = "OperationTypeDefinition"; Kind2["SCALAR_TYPE_DEFINITION"] = "ScalarTypeDefinition"; Kind2["OBJECT_TYPE_DEFINITION"] = "ObjectTypeDefinition"; Kind2["FIELD_DEFINITION"] = "FieldDefinition"; Kind2["INPUT_VALUE_DEFINITION"] = "InputValueDefinition"; Kind2["INTERFACE_TYPE_DEFINITION"] = "InterfaceTypeDefinition"; Kind2["UNION_TYPE_DEFINITION"] = "UnionTypeDefinition"; Kind2["ENUM_TYPE_DEFINITION"] = "EnumTypeDefinition"; Kind2["ENUM_VALUE_DEFINITION"] = "EnumValueDefinition"; Kind2["INPUT_OBJECT_TYPE_DEFINITION"] = "InputObjectTypeDefinition"; Kind2["DIRECTIVE_DEFINITION"] = "DirectiveDefinition"; Kind2["SCHEMA_EXTENSION"] = "SchemaExtension"; Kind2["SCALAR_TYPE_EXTENSION"] = "ScalarTypeExtension"; Kind2["OBJECT_TYPE_EXTENSION"] = "ObjectTypeExtension"; Kind2["INTERFACE_TYPE_EXTENSION"] = "InterfaceTypeExtension"; Kind2["UNION_TYPE_EXTENSION"] = "UnionTypeExtension"; Kind2["ENUM_TYPE_EXTENSION"] = "EnumTypeExtension"; Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension"; })(Kind || (Kind = {})); const BREAK = Object.freeze({}); function visit(root, visitor, visitorKeys = QueryDocumentKeys) { const enterLeaveMap = /* @__PURE__ */ new Map(); for (const kind of Object.values(Kind)) { enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); } let stack = void 0; let inArray = Array.isArray(root); let keys = [root]; let index = -1; let edits = []; let node = root; let key = void 0; let parent = void 0; const path = []; const ancestors = []; do { index++; const isLeaving = index === keys.length; const isEdited = isLeaving && edits.length !== 0; if (isLeaving) { key = ancestors.length === 0 ? void 0 : path[path.length - 1]; node = parent; parent = ancestors.pop(); if (isEdited) { if (inArray) { node = node.slice(); let editOffset = 0; for (const [editKey, editValue] of edits) { const arrayKey = editKey - editOffset; if (editValue === null) { node.splice(arrayKey, 1); editOffset++; } else { node[arrayKey] = editValue; } } } else { node = Object.defineProperties( {}, Object.getOwnPropertyDescriptors(node) ); for (const [editKey, editValue] of edits) { node[editKey] = editValue; } } } index = stack.index; keys = stack.keys; edits = stack.edits; inArray = stack.inArray; stack = stack.prev; } else if (parent) { key = inArray ? index : keys[index]; node = parent[key]; if (node === null || node === void 0) { continue; } path.push(key); } let result; if (!Array.isArray(node)) { var _enterLeaveMap$get, _enterLeaveMap$get2; isNode(node) || devAssert(false, `Invalid AST Node: ${inspect(node)}.`); const visitFn = isLeaving ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null || _enterLeaveMap$get === void 0 ? void 0 : _enterLeaveMap$get.leave : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null || _enterLeaveMap$get2 === void 0 ? void 0 : _enterLeaveMap$get2.enter; result = visitFn === null || visitFn === void 0 ? void 0 : visitFn.call(visitor, node, key, parent, path, ancestors); if (result === BREAK) { break; } if (result === false) { if (!isLeaving) { path.pop(); continue; } } else if (result !== void 0) { edits.push([key, result]); if (!isLeaving) { if (isNode(result)) { node = result; } else { path.pop(); continue; } } } } if (result === void 0 && isEdited) { edits.push([key, node]); } if (isLeaving) { path.pop(); } else { var _node$kind; stack = { inArray, index, keys, edits, prev: stack }; inArray = Array.isArray(node); keys = inArray ? node : (_node$kind = visitorKeys[node.kind]) !== null && _node$kind !== void 0 ? _node$kind : []; index = -1; edits = []; if (parent) { ancestors.push(parent); } parent = node; } } while (stack !== void 0); if (edits.length !== 0) { return edits[edits.length - 1][1]; } return root; } function getEnterLeaveForKind(visitor, kind) { const kindVisitor = visitor[kind]; if (typeof kindVisitor === "object") { return kindVisitor; } else if (typeof kindVisitor === "function") { return { enter: kindVisitor, leave: void 0 }; } return { enter: visitor.enter, leave: visitor.leave }; } function isWhiteSpace(code) { return code === 9 || code === 32; } function isDigit(code) { return code >= 48 && code <= 57; } function isLetter(code) { return code >= 97 && code <= 122 || code >= 65 && code <= 90; } function isNameStart(code) { return isLetter(code) || code === 95; } function isNameContinue(code) { return isLetter(code) || isDigit(code) || code === 95; } function dedentBlockStringLines(lines) { var _firstNonEmptyLine2; let commonIndent = Number.MAX_SAFE_INTEGER; let firstNonEmptyLine = null; let lastNonEmptyLine = -1; for (let i2 = 0; i2 < lines.length; ++i2) { var _firstNonEmptyLine; const line = lines[i2]; const indent2 = leadingWhitespace(line); if (indent2 === line.length) { continue; } firstNonEmptyLine = (_firstNonEmptyLine = firstNonEmptyLine) !== null && _firstNonEmptyLine !== void 0 ? _firstNonEmptyLine : i2; lastNonEmptyLine = i2; if (i2 !== 0 && indent2 < commonIndent) { commonIndent = indent2; } } return lines.map((line, i2) => i2 === 0 ? line : line.slice(commonIndent)).slice( (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && _firstNonEmptyLine2 !== void 0 ? _firstNonEmptyLine2 : 0, lastNonEmptyLine + 1 ); } function leadingWhitespace(str) { let i2 = 0; while (i2 < str.length && isWhiteSpace(str.charCodeAt(i2))) { ++i2; } return i2; } function printBlockString(value, options2) { const escapedValue = value.replace(/"""/g, '\\"""'); const lines = escapedValue.split(/\r\n|[\n\r]/g); const isSingleLine = lines.length === 1; const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every((line) => line.length === 0 || isWhiteSpace(line.charCodeAt(0))); const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; const hasTrailingSlash = value.endsWith("\\"); const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; const printAsMultipleLines = !(options2 !== null && options2 !== void 0 && options2.minimize) && (!isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes); let result = ""; const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0)); if (printAsMultipleLines && !skipLeadingNewLine || forceLeadingNewLine) { result += "\n"; } result += escapedValue; if (printAsMultipleLines || forceTrailingNewline) { result += "\n"; } return '"""' + result + '"""'; } function printString(str) { return `"${str.replace(escapedRegExp, escapedReplacer)}"`; } const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; function escapedReplacer(str) { return escapeSequences[str.charCodeAt(0)]; } const escapeSequences = [ "\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", "\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000B", "\\f", "\\r", "\\u000E", "\\u000F", "\\u0010", "\\u0011", "\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001A", "\\u001B", "\\u001C", "\\u001D", "\\u001E", "\\u001F", "", "", '\\"', "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "\\\\", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "\\u007F", "\\u0080", "\\u0081", "\\u0082", "\\u0083", "\\u0084", "\\u0085", "\\u0086", "\\u0087", "\\u0088", "\\u0089", "\\u008A", "\\u008B", "\\u008C", "\\u008D", "\\u008E", "\\u008F", "\\u0090", "\\u0091", "\\u0092", "\\u0093", "\\u0094", "\\u0095", "\\u0096", "\\u0097", "\\u0098", "\\u0099", "\\u009A", "\\u009B", "\\u009C", "\\u009D", "\\u009E", "\\u009F" ]; function print(ast) { return visit(ast, printDocASTReducer); } const M