decord/source/__helpers/00xxx/952__getGraphQLOperation.js
github-actions f0f877e8ce chore: update source for alpha 347.1
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4824.js (118.4 MB)
2026-09-15 14:23:42 +00:00

344 lines
13 KiB
JavaScript

// Module ID: 952
// Function ID: 953
// Name: _getGraphQLOperation
// Dependencies: [682, 898]
// Exports: getRequestPayloadXhrOrFetch, parseGraphQLQuery
// Module 952 (_getGraphQLOperation)
import triggerHandlers from "triggerHandlers" /* 898 */;
import registerSpanErrorInstrumentation from "module_682" /* 682 */;
function _getGraphQLOperation(operationName) {
let tmp = typeof operationName === "object";
let tmp2 = tmp;
if (typeof operationName === "object") {
tmp2 = null !== operationName;
}
if (tmp2) {
tmp2 = typeof operationName.operationName === "string";
}
if (tmp2) {
const extensions = operationName.extensions;
let tmp3 = typeof extensions === "object";
if (typeof extensions === "object") {
tmp3 = null !== extensions;
}
tmp2 = tmp3;
}
if (tmp2) {
const persistedQuery = operationName.extensions.persistedQuery;
let tmp4 = typeof persistedQuery === "object";
if (typeof persistedQuery === "object") {
tmp4 = null !== persistedQuery;
}
tmp2 = tmp4;
}
if (tmp2) {
tmp2 = typeof operationName.extensions.persistedQuery.sha256Hash === "string";
}
if (tmp2) {
tmp2 = typeof operationName.extensions.persistedQuery.version === "number";
}
if (tmp2) {
const _HermesInternal2 = HermesInternal;
return "persisted " + operationName.operationName;
} else {
if (typeof operationName === "object") {
tmp = null !== operationName;
}
if (tmp) {
tmp = typeof operationName.query === "string";
}
if (tmp) {
({ query, operationName } = operationName);
const match = query.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)(\w+)(?:\s*)[{(]/);
if (match) {
const obj2 = { operationType: match[1], operationName: match[2] };
let obj = obj2;
} else {
const match1 = query.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)[{(]/);
if (match1) {
const obj3 = { operationType: match1[1], operationName: "Array" };
obj = obj3;
} else {
obj = { operationType: "Array", operationName: "PX_16" };
}
}
let operationName2 = obj.operationName;
if (undefined === operationName2) {
operationName2 = operationName;
}
const operationType = obj.operationType;
const _HermesInternal = HermesInternal;
if (operationName2) {
let combined = concat(operationType, " ", operationName2);
} else {
combined = concat(operationType);
}
return combined;
} else {
return "unknown";
}
}
}
function isStandardRequest(parsed) {
let tmp = typeof parsed === "object";
if (typeof parsed === "object") {
tmp = null !== parsed;
}
if (tmp) {
tmp = typeof parsed.query === "string";
}
return tmp;
}
function isPersistedRequest(operationName) {
let tmp = typeof operationName === "object";
if (typeof operationName === "object") {
tmp = null !== operationName;
}
if (tmp) {
tmp = typeof operationName.operationName === "string";
}
if (tmp) {
const extensions = operationName.extensions;
let tmp2 = typeof extensions === "object";
if (typeof extensions === "object") {
tmp2 = null !== extensions;
}
tmp = tmp2;
}
if (tmp) {
const persistedQuery = operationName.extensions.persistedQuery;
let tmp3 = typeof persistedQuery === "object";
if (typeof persistedQuery === "object") {
tmp3 = null !== persistedQuery;
}
tmp = tmp3;
}
if (tmp) {
tmp = typeof operationName.extensions.persistedQuery.sha256Hash === "string";
}
if (tmp) {
tmp = typeof operationName.extensions.persistedQuery.version === "number";
}
return tmp;
}
function getGraphQLRequestPayload(arg0) {
try {
const _JSON = JSON;
const parsed = JSON.parse(arg0);
if (isStandardRequest(parsed)) {
const tmp9 = parsed;
}
return tmp9;
} catch (err) {
return tmp;
}
}
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
export { _getGraphQLOperation };
export { getGraphQLRequestPayload };
export const getRequestPayloadXhrOrFetch = function getRequestPayloadXhrOrFetch(input) {
if ("xhr" in input) {
const tmp7 = input.xhr[triggerHandlers.SENTRY_XHR_DATA_KEY];
let first = tmp7;
if (tmp7) {
first = tmp5(898).getBodyString(tmp7.body)[0];
const tmp5Result = tmp5(898);
}
let first1 = first;
tmp5 = require;
} else {
const fetchRequestArgBody = triggerHandlers.getFetchRequestArgBody(input.input);
first1 = triggerHandlers.getBodyString(fetchRequestArgBody)[0];
}
return first1;
};
export const graphqlClientIntegration = registerSpanErrorInstrumentation.defineIntegration((arg0) => {
closure_0 = arg0;
return {
name: "GraphQLClient",
setup(on) {
on.on("beforeOutgoingRequestSpan", (updateName, input) => {
const tmp3 = closure_0(682).spanToJSON(updateName).data || {};
if ("http.client" === tmp3[closure_0(undefined, 682).SEMANTIC_ATTRIBUTE_SENTRY_OP]) {
const tmp4 = tmp3[tmp(undefined, 682).SEMANTIC_ATTRIBUTE_URL_FULL] || tmp3["http.url"];
const tmp5 = tmp3[tmp(undefined, 682).SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD] || tmp3["http.method"];
if (tmpResult.isString(tmp4)) {
if (tmpResult6.isString(tmp5)) {
const result = tmp(682).stringMatchesSomePattern(tmp4, closure_0.endpoints);
if ("xhr" in input) {
const tmp11 = input.xhr[tmp(undefined, 898).SENTRY_XHR_DATA_KEY];
let first = tmp11;
if (tmp11) {
first = tmp(898).getBodyString(tmp11.body)[0];
const tmpResult8 = tmp(898);
}
let first1 = first;
} else {
const fetchRequestArgBody = tmp(898).getFetchRequestArgBody(input.input);
const tmpResult9 = tmp(898);
first1 = tmp(898).getBodyString(fetchRequestArgBody)[0];
const tmpResult10 = tmp(898);
}
if (result) {
if (first1) {
const tmp14 = getGraphQLRequestPayload(first1);
if (tmp14) {
const _HermesInternal = HermesInternal;
updateName.updateName("" + tmp5 + " " + tmp4 + " (" + _getGraphQLOperation(tmp14) + ")");
let tmp20 = typeof tmp14 === "object";
let tmp21 = tmp20;
if (typeof tmp14 === "object") {
tmp21 = null !== tmp14;
}
if (tmp21) {
tmp21 = typeof tmp14.query === "string";
}
if (tmp21) {
const attr = updateName.setAttribute("graphql.document", tmp14.query);
}
if (typeof tmp14 === "object") {
tmp20 = null !== tmp14;
}
if (tmp20) {
tmp20 = typeof tmp14.operationName === "string";
}
if (tmp20) {
const extensions = tmp14.extensions;
let tmp23 = typeof extensions === "object";
if (typeof extensions === "object") {
tmp23 = null !== extensions;
}
tmp20 = tmp23;
}
if (tmp20) {
const persistedQuery = tmp14.extensions.persistedQuery;
let tmp24 = typeof persistedQuery === "object";
if (typeof persistedQuery === "object") {
tmp24 = null !== persistedQuery;
}
tmp20 = tmp24;
}
if (tmp20) {
tmp20 = typeof tmp14.extensions.persistedQuery.sha256Hash === "string";
}
if (tmp20) {
tmp20 = typeof tmp14.extensions.persistedQuery.version === "number";
}
if (tmp20) {
const attr1 = updateName.setAttribute("graphql.persisted_query.hash.sha256", tmp14.extensions.persistedQuery.sha256Hash);
const attr2 = updateName.setAttribute("graphql.persisted_query.version", tmp14.extensions.persistedQuery.version);
}
}
}
}
const tmpResult7 = tmp(682);
}
tmpResult6 = tmp(682);
}
tmpResult = tmp(682);
}
});
on.on("beforeOutgoingRequestBreadcrumb", (type, input) => {
({ category, data } = type);
if ("http" === type.type) {
if ("fetch" === category) {
let url;
if (data != null) {
url = data.url;
}
const result = closure_0(682).stringMatchesSomePattern(url, closure_0.endpoints);
if ("xhr" in input) {
const tmp10 = input.xhr[tmp5(undefined, 898).SENTRY_XHR_DATA_KEY];
let first = tmp10;
if (tmp10) {
first = tmp5(898).getBodyString(tmp10.body)[0];
const tmp5Result = tmp5(898);
}
let first1 = first;
} else {
const fetchRequestArgBody = tmp5(898).getFetchRequestArgBody(input.input);
const tmp5Result3 = tmp5(898);
first1 = tmp5(898).getBodyString(fetchRequestArgBody)[0];
const tmp5Result4 = tmp5(898);
}
if (result) {
if (data) {
if (first1) {
const tmp13 = getGraphQLRequestPayload(first1);
if (!data.graphql) {
if (tmp13) {
data["graphql.operation"] = _getGraphQLOperation(tmp13);
let tmp15 = typeof tmp13 === "object";
let tmp16 = tmp15;
if (typeof tmp13 === "object") {
tmp16 = null !== tmp13;
}
if (tmp16) {
tmp16 = typeof tmp13.query === "string";
}
if (tmp16) {
data["graphql.document"] = tmp13.query;
}
if (typeof tmp13 === "object") {
tmp15 = null !== tmp13;
}
if (tmp15) {
tmp15 = typeof tmp13.operationName === "string";
}
if (tmp15) {
const extensions = tmp13.extensions;
let tmp17 = typeof extensions === "object";
if (typeof extensions === "object") {
tmp17 = null !== extensions;
}
tmp15 = tmp17;
}
if (tmp15) {
const persistedQuery = tmp13.extensions.persistedQuery;
let tmp18 = typeof persistedQuery === "object";
if (typeof persistedQuery === "object") {
tmp18 = null !== persistedQuery;
}
tmp15 = tmp18;
}
if (tmp15) {
tmp15 = typeof tmp13.extensions.persistedQuery.sha256Hash === "string";
}
if (tmp15) {
tmp15 = typeof tmp13.extensions.persistedQuery.version === "number";
}
if (tmp15) {
data["graphql.persisted_query.hash.sha256"] = tmp13.extensions.persistedQuery.sha256Hash;
data["graphql.persisted_query.version"] = tmp13.extensions.persistedQuery.version;
}
}
}
}
}
}
const obj = closure_0(682);
}
}
});
}
};
});
export const parseGraphQLQuery = function parseGraphQLQuery(str) {
const match = str.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)(\w+)(?:\s*)[{(]/);
if (match) {
const obj2 = { operationType: match[1], operationName: match[2] };
return obj2;
} else {
const match1 = str.match(/^(?:\s*)(query|mutation|subscription)(?:\s*)[{(]/);
if (match1) {
const obj3 = { operationType: match1[1], operationName: "Array" };
let obj = obj3;
} else {
obj = { operationType: "Array", operationName: "PX_16" };
}
return obj;
}
};