Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netlify-onegraph-internal

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify-onegraph-internal - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

2

dist/netlifyGraph.js

@@ -112,3 +112,3 @@ "use strict";

var generatedNetlifyGraphPersistedClient = function (netlifyGraphConfig, schemaId) {
return lruCacheImplementation + "\n\n" + out(netlifyGraphConfig, ["node"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json'\n };\n const timeoutMs = 30_000\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n if (!input.docId) {\n throw new Error('docId is required for GET requests: ' + input.operationName);\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const encodedVariables = encodeURIComponent(input.variables || \"null\");\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId + '&doc_id=' + input.docId + (input.operationName ? ('&operationName=' + input.operationName) : '') + (schemaId ? ('&schemaId=' + schemaId) : '') + '&variables=' + encodedVariables;\n \n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.end()\n })\n}\n\nconst httpPost = (input) => {\n const reqBody = input.body || null\n const userHeaders = input.headers || {}\n const headers = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n 'Content-Length': reqBody.length,\n }\n\n const timeoutMs = 30_000\n\n const reqOptions = {\n method: 'POST',\n headers: headers,\n timeout: timeoutMs,\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.write(reqBody)\n req.end()\n })\n}") + "\n\n" + out(netlifyGraphConfig, ["browser"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n const encodedVariables = encodeURIComponent(\n JSON.stringify(input.variables || null)\n );\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url =\n 'https://serve.onegraph.com/graphql?app_id=' +\n input.siteId +\n '&doc_id=' +\n input.docId +\n (input.operationName ? '&operationName=' + input.operationName : '') +\n (schemaId ? ('&schemaId=' + schemaId) : '') +\n '&variables=' +\n encodedVariables;\n\n return fetch(url, reqOptions).then((response) => response.text());\n};\n\nconst httpPost = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const reqBody = JSON.stringify({\n doc_id: input.docId,\n query: input.query,\n operationName: input.operationName,\n variables: input.variables,\n });\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'POST',\n headers: fullHeaders,\n timeout: timeoutMs,\n body: reqBody,\n };\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n\n return fetch(url, reqOptions).then((response) => response.text());\n};") + "\n\nconst fetchNetlifyGraph = function fetchNetlifyGraph(input) {\n const docId = input.doc_id;\n const operationName = input.operationName;\n const variables = input.variables;\n\n const options = input.options || {};\n const accessToken = options.accessToken;\n const siteId = options.siteId || process.env.SITE_ID;\n\n const httpMethod = input.fetchStrategy === 'GET' ? httpGet : httpPost;\n\n let response;\n\n if (input.fetchStrategy === 'GET') {\n response = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n }).then((result) => JSON.parse(result));\n } else {\n const payload = {\n query: input.query,\n doc_id: docId,\n variables: variables,\n operationName: operationName,\n };\n\n let cachedOrLiveValue = new Promise((resolve) => {\n const cacheKey = calculateCacheKey(payload);\n\n // Check the cache for a previous result\n const cachedResultPair = getFromCache(cache, cacheKey);\n\n let conditionalHeaders = {};\n let cachedResultValue;\n\n if (cachedResultPair) {\n const [etag, previousResult] = cachedResultPair;\n conditionalHeaders = {\n 'If-None-Match': etag,\n };\n cachedResultValue = previousResult;\n }\n\n const persistedResponse = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n ...conditionalHeaders,\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n });\n\n persistedResponse.then((result) => {\n // Check response headers for a 304 Not Modified\n if (result.status === 304) {\n // Return the cached result\n resolve(cachedResultValue);\n }\n else if (result.status === 200) {\n // Update the cache with the new etag and result\n const etag = result.headers.get('ng-etag');\n const resultJson = result.json();\n resultJson.then((json) => {\n if (etag) {\n // Make a not of the new etag for the given payload\n setInCache(cache, cacheKey, [etag, json])\n };\n resolve(json);\n });\n } else {\n return result.json().then((json) => {\n resolve(json);\n });\n }\n });\n });\n\n response = cachedOrLiveValue;\n }\n\n return response;\n};\n";
return lruCacheImplementation + "\n\n" + out(netlifyGraphConfig, ["node"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json'\n };\n const timeoutMs = 30_000\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n if (!input.docId) {\n throw new Error('docId is required for GET requests: ' + input.operationName);\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const encodedVariables = encodeURIComponent(input.variables || \"null\");\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId + '&doc_id=' + input.docId + (input.operationName ? ('&operationName=' + input.operationName) : '') + (schemaId ? ('&schemaId=' + schemaId) : '') + '&variables=' + encodedVariables;\n \n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.end()\n })\n}\n\nconst httpPost = (input) => {\n const reqBody = input.body || null\n const userHeaders = input.headers || {}\n const headers = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n 'Content-Length': reqBody.length,\n }\n\n const timeoutMs = 30_000\n\n const reqOptions = {\n method: 'POST',\n headers: headers,\n timeout: timeoutMs,\n }\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n const respBody = []\n\n return new Promise((resolve, reject) => {\n const req = https.request(url, reqOptions, (res) => {\n if (res.statusCode && (res.statusCode < 200 || res.statusCode > 299)) {\n return reject(\n new Error(\n \"Netlify Graph return non-OK HTTP status code\" + res.statusCode,\n ),\n )\n }\n\n res.on('data', (chunk) => respBody.push(chunk))\n\n res.on('end', () => {\n const resString = buffer.Buffer.concat(respBody).toString()\n resolve(resString)\n })\n })\n\n req.on('error', (error) => {\n console.error('Error making request to Netlify Graph:', error)\n })\n\n req.on('timeout', () => {\n req.destroy()\n reject(new Error('Request to Netlify Graph timed out'))\n })\n\n req.write(reqBody)\n req.end()\n })\n}") + "\n\n" + out(netlifyGraphConfig, ["browser"], "const httpGet = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'GET',\n headers: fullHeaders,\n timeout: timeoutMs,\n };\n\n const encodedVariables = encodeURIComponent(\n JSON.stringify(input.variables || null)\n );\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url =\n 'https://serve.onegraph.com/graphql?app_id=' +\n input.siteId +\n '&doc_id=' +\n input.docId +\n (input.operationName ? '&operationName=' + input.operationName : '') +\n (schemaId ? ('&schemaId=' + schemaId) : '') +\n '&variables=' +\n encodedVariables;\n\n return fetch(url, reqOptions).then((response) => response.text());\n};\n\nconst httpPost = (input) => {\n const userHeaders = input.headers || {};\n const fullHeaders = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const reqBody = JSON.stringify({\n doc_id: input.docId,\n query: input.query,\n operationName: input.operationName,\n variables: input.variables,\n });\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'POST',\n headers: fullHeaders,\n timeout: timeoutMs,\n body: reqBody,\n };\n\n const schemaId = input.schemaId || " + (schemaId ? "\"" + schemaId + "\"" : "undefined") + ";\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + input.siteId +\n (schemaId ? ('&schemaId=' + schemaId) : '');\n\n return fetch(url, reqOptions);\n};") + "\n\nconst fetchNetlifyGraph = function fetchNetlifyGraph(input) {\n const docId = input.doc_id;\n const operationName = input.operationName;\n const variables = input.variables;\n\n const options = input.options || {};\n const accessToken = options.accessToken;\n const siteId = options.siteId || process.env.SITE_ID;\n\n const httpMethod = input.fetchStrategy === 'GET' ? httpGet : httpPost;\n\n let response;\n\n if (input.fetchStrategy === 'GET') {\n response = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n }).then((result) => JSON.parse(result));\n } else {\n const payload = {\n query: input.query,\n doc_id: docId,\n variables: variables,\n operationName: operationName,\n };\n\n let cachedOrLiveValue = new Promise((resolve) => {\n const cacheKey = calculateCacheKey(payload);\n\n // Check the cache for a previous result\n const cachedResultPair = getFromCache(cache, cacheKey);\n\n let conditionalHeaders = {\n 'If-None-Match': undefined,\n };\n let cachedResultValue;\n\n if (cachedResultPair) {\n const [etag, previousResult] = cachedResultPair;\n conditionalHeaders = {\n 'If-None-Match': etag,\n };\n cachedResultValue = previousResult;\n }\n\n const persistedResponse = httpMethod({\n siteId: siteId,\n docId: docId,\n query: input.query,\n headers: {\n ...conditionalHeaders,\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n variables: variables,\n operationName: operationName,\n });\n\n persistedResponse.then((result) => {\n // Check response headers for a 304 Not Modified\n if (result.status === 304) {\n // Return the cached result\n resolve(cachedResultValue);\n }\n else if (result.status === 200) {\n // Update the cache with the new etag and result\n const etag = result.headers.get('ng-etag');\n const resultJson = result.json();\n resultJson.then((json) => {\n if (etag) {\n // Make a not of the new etag for the given payload\n setInCache(cache, cacheKey, [etag, json])\n };\n resolve(json);\n });\n } else {\n return result.json().then((json) => {\n resolve(json);\n });\n }\n });\n });\n\n response = cachedOrLiveValue;\n }\n\n return response;\n};\n";
};

@@ -115,0 +115,0 @@ var subscriptionParserReturnName = function (fn) {

{
"name": "netlify-onegraph-internal",
"version": "0.1.14",
"version": "0.1.15",
"description": "Internal tools for use by Netlify",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc