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.17 to 0.1.18

26

dist/generatedOneGraphClient.d.ts
export function verifyRequestSignature(request: any, options: any): any;
export function fetchListNetlifyEnabledServicesQuery(variables: any, options: any): Promise<any>;
export function executeAckCLISessionEventMutation(variables: any, options: any): Promise<any>;
export function fetchAppSchemaQuery(variables: any, options: any): Promise<any>;
export function fetchCLISessionQuery(variables: any, options: any): Promise<any>;
export function executeCreateApiTokenMutation(variables: any, options: any): Promise<any>;
export function executeCreateCLISessionEventMutation(variables: any, options: any): Promise<any>;
export function executeCreateCLISessionMutation(variables: any, options: any): Promise<any>;
export function executeCreateGraphQLSchemaMutation(variables: any, options: any): Promise<any>;
export function executeCreateNewSchemaMutation(variables: any, options: any): Promise<any>;
export function executeCreatePersistedQueryMutation(variables: any, options: any): Promise<any>;
export function executeCreateApiTokenMutation(variables: any, options: any): Promise<any>;
export function executeCreateSharedDocumentMutation(variables: any, options: any): Promise<any>;
export function fetchListPersistedQueries(variables: any, options: any): Promise<any>;
export function fetchListSharedDocumentsQuery(variables: any, options: any): Promise<any>;
export function executeMarkCLISessionActiveHeartbeat(variables: any, options: any): Promise<any>;
export function executeMarkCLISessionInactive(variables: any, options: any): Promise<any>;
export function fetchPersistedQueryQuery(variables: any, options: any): Promise<any>;
export function executeCreateCLISessionMutation(variables: any, options: any): Promise<any>;
export function fetchSharedDocumentQuery(variables: any, options: any): Promise<any>;
export function executeUpdateCLISessionMetadataMutation(variables: any, options: any): Promise<any>;
export function executeCreateCLISessionEventMutation(variables: any, options: any): Promise<any>;
export function fetchCLISessionQuery(variables: any, options: any): Promise<any>;
export function executeAckCLISessionEventMutation(variables: any, options: any): Promise<any>;
export function fetchAppSchemaQuery(variables: any, options: any): Promise<any>;
export function executeUpsertAppForSiteMutation(variables: any, options: any): Promise<any>;
export function executeCreateNewSchemaMutation(variables: any, options: any): Promise<any>;
export function executeMarkCLISessionActiveHeartbeat(variables: any, options: any): Promise<any>;
export function executeMarkCLISessionInactive(variables: any, options: any): Promise<any>;
export default functions;

@@ -38,2 +42,6 @@ export function handler(): {

export { executeMarkCLISessionInactive };
export { fetchListSharedDocumentsQuery };
export { executeCreateSharedDocumentMutation };
export { fetchSharedDocumentQuery };
export { fetchListNetlifyEnabledServicesQuery };
}

@@ -50,7 +50,35 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = exports.executeMarkCLISessionInactive = exports.executeMarkCLISessionActiveHeartbeat = exports.executeCreateNewSchemaMutation = exports.executeUpsertAppForSiteMutation = exports.fetchAppSchemaQuery = exports.executeAckCLISessionEventMutation = exports.fetchCLISessionQuery = exports.executeCreateCLISessionEventMutation = exports.executeUpdateCLISessionMetadataMutation = exports.executeCreateCLISessionMutation = exports.fetchPersistedQueryQuery = exports.fetchListPersistedQueries = exports.executeCreateApiTokenMutation = exports.executeCreatePersistedQueryMutation = exports.executeCreateGraphQLSchemaMutation = exports.verifyRequestSignature = void 0;
exports.handler = exports.executeUpsertAppForSiteMutation = exports.executeUpdateCLISessionMetadataMutation = exports.fetchSharedDocumentQuery = exports.fetchPersistedQueryQuery = exports.executeMarkCLISessionInactive = exports.executeMarkCLISessionActiveHeartbeat = exports.fetchListSharedDocumentsQuery = exports.fetchListPersistedQueries = exports.executeCreateSharedDocumentMutation = exports.executeCreatePersistedQueryMutation = exports.executeCreateNewSchemaMutation = exports.executeCreateGraphQLSchemaMutation = exports.executeCreateCLISessionMutation = exports.executeCreateCLISessionEventMutation = exports.executeCreateApiTokenMutation = exports.fetchCLISessionQuery = exports.fetchAppSchemaQuery = exports.executeAckCLISessionEventMutation = exports.fetchListNetlifyEnabledServicesQuery = exports.verifyRequestSignature = void 0;
/* eslint-disable */
// @ts-nocheck
// GENERATED VIA NETLIFY AUTOMATED DEV TOOLS, EDIT WITH CAUTION!
var fetch = require('node-fetch');
var internalConsole = require("./internalConsole").internalConsole;
var netlifyGraphHost = process.env.NETLIFY_GRAPH_HOST || "serve.onegraph.com";
var netlifyGraphHost = process.env.NETLIFY_GRAPH_HOST || "graph.netlify.com";
// Basic LRU cache implementation
var makeLRUCache = function (max) {
return { max: max, cache: new Map() };
};
var getFromCache = function (lru, key) {
var item = lru.cache.get(key);
if (item) {
lru.cache.delete(key);
lru.cache.set(key, item);
}
return item;
};
var setInCache = function (lru, key, value) {
if (lru.cache.has(key)) {
lru.cache.delete(key);
}
if (lru.cache.size == lru.max) {
lru.cache.delete(lru.first());
}
lru.cache.set(key, value);
};
// Cache the results of the Netlify Graph API for conditional requests
var cache = makeLRUCache(100);
var calculateCacheKey = function (payload) {
return JSON.stringify(payload);
};
var httpFetch = function (siteId, options) { return __awaiter(void 0, void 0, void 0, function () {

@@ -75,3 +103,3 @@ var reqBody, userHeaders, headers, timeoutMs, reqOptions, url, resp;

resp = _a.sent();
return [2 /*return*/, resp.text()];
return [2 /*return*/, resp];
}

@@ -81,28 +109,61 @@ });

var fetchNetlifyGraph = function fetchNetlifyGraph(input) {
return __awaiter(this, void 0, void 0, function () {
var query, docId, operationName, variables, options, accessToken, siteId, payload, response;
return __generator(this, function (_a) {
query = input.query;
docId = input.doc_id;
operationName = input.operationName;
variables = input.variables;
options = input.options || {};
accessToken = options.accessToken;
siteId = options.siteId || process.env.SITE_ID;
payload = {
query: query,
doc_id: docId,
variables: variables,
operationName: operationName,
var query = input.query;
var docId = input.doc_id;
var operationName = input.operationName;
var variables = input.variables;
var options = input.options || {};
var accessToken = options.accessToken;
var siteId = options.siteId || process.env.SITE_ID;
var payload = {
query: query,
doc_id: docId,
variables: variables,
operationName: operationName,
};
var cachedOrLiveValue = new Promise(function (resolve) {
var cacheKey = calculateCacheKey(payload);
// Check the cache for a previous result
var cachedResultPair = getFromCache(cache, cacheKey);
var conditionalHeaders = {
"If-None-Match": "",
};
var cachedResultValue;
if (cachedResultPair) {
var etag = cachedResultPair[0], previousResult = cachedResultPair[1];
conditionalHeaders = {
"If-None-Match": etag,
};
response = httpFetch(siteId, {
method: "POST",
headers: {
Authorization: accessToken ? "Bearer " + accessToken : "",
},
body: JSON.stringify(payload),
});
return [2 /*return*/, response.then(function (result) { return JSON.parse(result); })];
cachedResultValue = previousResult;
}
var response = httpFetch(siteId, {
method: "POST",
headers: __assign(__assign({}, conditionalHeaders), { Authorization: accessToken ? "Bearer " + accessToken : "" }),
body: JSON.stringify(payload),
});
response.then(function (result) {
// Check response headers for a 304 Not Modified
if (result.status === 304) {
// Return the cached result
resolve(cachedResultValue);
}
else if (result.status === 200) {
// Update the cache with the new etag and result
var etag_1 = result.headers.get("etag");
var resultJson = result.json();
resultJson.then(function (json) {
if (etag_1) {
// Make a not of the new etag for the given payload
setInCache(cache, cacheKey, [etag_1, json]);
}
resolve(json);
});
}
else {
return result.json().then(function (json) {
resolve(json);
});
}
});
});
return cachedOrLiveValue;
};

@@ -121,16 +182,16 @@ var verifyRequestSignature = function (request, options) {

exports.verifyRequestSignature = verifyRequestSignature;
var executeCreateGraphQLSchemaMutation = function (variables, options) {
var fetchListNetlifyEnabledServicesQuery = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation CreateGraphQLSchemaMutation($input: OneGraphCreateGraphQLSchemaInput!) {\n oneGraph {\n createGraphQLSchema(input: $input) {\n graphQLSchema {\n id\n externalGraphQLSchemas {\n nodes {\n id\n endpoint\n service\n createdAt\n updatedAt\n }\n }\n parentGraphQLSchemaId\n salesforceSchema {\n id\n createdAt\n updatedAt\n }\n services {\n slug\n }\n updatedAt\n createdAt\n appId\n }\n }\n }\n}",
operationName: "CreateGraphQLSchemaMutation",
query: "query ListNetlifyEnabledServicesQuery($logoStyle: OneGraphAppLogoStyleEnum = ROUNDED_RECTANGLE, $betaServices: [OneGraphServiceEnumArg!] = []) {\n oneGraph {\n services(\n filter: {or: [{service: {in: $betaServices}}, {supportsNetlifyGraph: true}, {supportsNetlifyApiAuthentication: true}]}\n ) {\n friendlyServiceName\n logoUrl(style: $logoStyle)\n service\n slug\n supportsCustomRedirectUri\n supportsCustomServiceAuth\n supportsOauthLogin\n netlifyGraphEnabled\n netlifyApiAuthenticationEnabled\n }\n }\n}",
operationName: "ListNetlifyEnabledServicesQuery",
variables: variables,
options: options,
fetchStrategy: "POST",
fetchStrategy: "GET",
});
};
exports.executeCreateGraphQLSchemaMutation = executeCreateGraphQLSchemaMutation;
var executeCreatePersistedQueryMutation = function (variables, options) {
exports.fetchListNetlifyEnabledServicesQuery = fetchListNetlifyEnabledServicesQuery;
var executeAckCLISessionEventMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation CreatePersistedQueryMutation($nfToken: String!, $cacheStrategy: OneGraphPersistedQueryCacheStrategyArg, $allowedOperationNames: [String!]!, $fallbackOnError: Boolean!, $freeVariables: [String!]!, $query: String!, $tags: [String!]!, $description: String, $appId: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createPersistedQuery(\n input: {query: $query, appId: $appId, cacheStrategy: $cacheStrategy, allowedOperationNames: $allowedOperationNames, fallbackOnError: $fallbackOnError, freeVariables: $freeVariables, tags: $tags, description: $description}\n ) {\n persistedQuery {\n id\n allowedOperationNames\n description\n fixedVariables\n freeVariables\n query\n tags\n }\n }\n }\n}",
operationName: "CreatePersistedQueryMutation",
query: "mutation AckCLISessionEventMutation($nfToken: String!, $sessionId: String!, $eventIds: [String!]!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n ackNetlifyCliEvents(input: {eventIds: $eventIds, sessionId: $sessionId}) {\n events {\n id\n }\n }\n }\n}",
operationName: "AckCLISessionEventMutation",
variables: variables,

@@ -141,7 +202,7 @@ options: options,

};
exports.executeCreatePersistedQueryMutation = executeCreatePersistedQueryMutation;
var executeCreateApiTokenMutation = function (variables, options) {
exports.executeAckCLISessionEventMutation = executeAckCLISessionEventMutation;
var fetchAppSchemaQuery = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation CreateApiTokenMutation($input: OneGraphCreateApiTokenTokenInput!, $nfToken: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createApiToken(input: $input) {\n accessToken {\n token\n userAuths {\n service\n foreignUserId\n scopes\n }\n appId\n expireDate\n name\n netlifyId\n anchor\n }\n }\n }\n}",
operationName: "CreateApiTokenMutation",
query: "query AppSchemaQuery($nfToken: String!, $appId: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n app(id: $appId) {\n graphQLSchema {\n appId\n createdAt\n id\n services {\n friendlyServiceName\n logoUrl\n service\n slug\n supportsCustomRedirectUri\n supportsCustomServiceAuth\n supportsOauthLogin\n }\n updatedAt\n }\n }\n }\n}",
operationName: "AppSchemaQuery",
variables: variables,

@@ -152,7 +213,7 @@ options: options,

};
exports.executeCreateApiTokenMutation = executeCreateApiTokenMutation;
var fetchListPersistedQueries = function (variables, options) {
exports.fetchAppSchemaQuery = fetchAppSchemaQuery;
var fetchCLISessionQuery = function (variables, options) {
return fetchNetlifyGraph({
query: "query ListPersistedQueries($appId: String!, $first: Int!, $after: String, $tags: [String!]!) {\n oneGraph {\n app(id: $appId) {\n id\n persistedQueries(first: $first, after: $after, tags: $tags) {\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n id\n query\n fixedVariables\n freeVariables\n allowedOperationNames\n tags\n description\n }\n }\n }\n }\n}",
operationName: "ListPersistedQueries",
query: "query CLISessionQuery($nfToken: String!, $sessionId: String!, $first: Int!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n __typename\n netlifyCliSession(id: $sessionId) {\n appId\n createdAt\n id\n cliHeartbeatIntervalMs\n events(first: $first) {\n __typename\n createdAt\n id\n sessionId\n ... on OneGraphNetlifyCliSessionLogEvent {\n id\n message\n sessionId\n createdAt\n }\n ... on OneGraphNetlifyCliSessionTestEvent {\n id\n createdAt\n payload\n sessionId\n }\n }\n lastEventAt\n metadata\n name\n netlifyUserId\n }\n }\n}",
operationName: "CLISessionQuery",
variables: variables,

@@ -163,7 +224,7 @@ options: options,

};
exports.fetchListPersistedQueries = fetchListPersistedQueries;
var fetchPersistedQueryQuery = function (variables, options) {
exports.fetchCLISessionQuery = fetchCLISessionQuery;
var executeCreateApiTokenMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "query PersistedQueryQuery($nfToken: String!, $appId: String!, $id: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n persistedQuery(appId: $appId, id: $id) {\n id\n query\n allowedOperationNames\n description\n freeVariables\n fixedVariables\n tags\n }\n }\n}",
operationName: "PersistedQueryQuery",
query: "mutation CreateApiTokenMutation($input: OneGraphCreateApiTokenTokenInput!, $nfToken: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createApiToken(input: $input) {\n accessToken {\n token\n userAuths {\n service\n foreignUserId\n scopes\n }\n appId\n expireDate\n name\n netlifyId\n anchor\n }\n }\n }\n}",
operationName: "CreateApiTokenMutation",
variables: variables,

@@ -174,7 +235,7 @@ options: options,

};
exports.fetchPersistedQueryQuery = fetchPersistedQueryQuery;
var executeCreateCLISessionMutation = function (variables, options) {
exports.executeCreateApiTokenMutation = executeCreateApiTokenMutation;
var executeCreateCLISessionEventMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation CreateCLISessionMutation($nfToken: String!, $appId: String!, $name: String!, $metadata: JSON) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createNetlifyCliSession(\n input: {appId: $appId, name: $name, metadata: $metadata}\n ) {\n session {\n id\n appId\n netlifyUserId\n name\n cliHeartbeatIntervalMs\n }\n }\n }\n}",
operationName: "CreateCLISessionMutation",
query: "mutation CreateCLISessionEventMutation($nfToken: String!, $sessionId: String!, $payload: JSON!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createNetlifyCliTestEvent(\n input: {data: {payload: $payload}, sessionId: $sessionId}\n ) {\n event {\n id\n createdAt\n sessionId\n }\n }\n }\n}",
operationName: "CreateCLISessionEventMutation",
variables: variables,

@@ -185,7 +246,7 @@ options: options,

};
exports.executeCreateCLISessionMutation = executeCreateCLISessionMutation;
var executeUpdateCLISessionMetadataMutation = function (variables, options) {
exports.executeCreateCLISessionEventMutation = executeCreateCLISessionEventMutation;
var executeCreateCLISessionMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation UpdateCLISessionMetadataMutation($nfToken: String!, $sessionId: String!, $metadata: JSON!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n updateNetlifyCliSession(input: {id: $sessionId, metadata: $metadata}) {\n session {\n id\n name\n metadata\n cliHeartbeatIntervalMs\n }\n }\n }\n}",
operationName: "UpdateCLISessionMetadataMutation",
query: "mutation CreateCLISessionMutation($nfToken: String!, $appId: String!, $name: String!, $metadata: JSON) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createNetlifyCliSession(\n input: {appId: $appId, name: $name, metadata: $metadata}\n ) {\n session {\n id\n appId\n netlifyUserId\n name\n cliHeartbeatIntervalMs\n }\n }\n }\n}",
operationName: "CreateCLISessionMutation",
variables: variables,

@@ -196,7 +257,7 @@ options: options,

};
exports.executeUpdateCLISessionMetadataMutation = executeUpdateCLISessionMetadataMutation;
var executeCreateCLISessionEventMutation = function (variables, options) {
exports.executeCreateCLISessionMutation = executeCreateCLISessionMutation;
var executeCreateGraphQLSchemaMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation CreateCLISessionEventMutation($nfToken: String!, $sessionId: String!, $payload: JSON!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createNetlifyCliTestEvent(\n input: {data: {payload: $payload}, sessionId: $sessionId}\n ) {\n event {\n id\n createdAt\n sessionId\n }\n }\n }\n}",
operationName: "CreateCLISessionEventMutation",
query: "mutation CreateGraphQLSchemaMutation($input: OneGraphCreateGraphQLSchemaInput!) {\n oneGraph {\n createGraphQLSchema(input: $input) {\n graphQLSchema {\n id\n externalGraphQLSchemas {\n nodes {\n id\n endpoint\n service\n createdAt\n updatedAt\n }\n }\n parentGraphQLSchemaId\n salesforceSchema {\n id\n createdAt\n updatedAt\n }\n services {\n slug\n }\n updatedAt\n createdAt\n appId\n }\n }\n }\n}",
operationName: "CreateGraphQLSchemaMutation",
variables: variables,

@@ -207,7 +268,7 @@ options: options,

};
exports.executeCreateCLISessionEventMutation = executeCreateCLISessionEventMutation;
var fetchCLISessionQuery = function (variables, options) {
exports.executeCreateGraphQLSchemaMutation = executeCreateGraphQLSchemaMutation;
var executeCreateNewSchemaMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "query CLISessionQuery($nfToken: String!, $sessionId: String!, $first: Int!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n __typename\n netlifyCliSession(id: $sessionId) {\n appId\n createdAt\n id\n cliHeartbeatIntervalMs\n events(first: $first) {\n __typename\n createdAt\n id\n sessionId\n ... on OneGraphNetlifyCliSessionLogEvent {\n id\n message\n sessionId\n createdAt\n }\n ... on OneGraphNetlifyCliSessionTestEvent {\n id\n createdAt\n payload\n sessionId\n }\n }\n lastEventAt\n metadata\n name\n netlifyUserId\n }\n }\n}",
operationName: "CLISessionQuery",
query: "mutation CreateNewSchemaMutation($nfToken: String!, $input: OneGraphCreateGraphQLSchemaInput!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createGraphQLSchema(input: $input) {\n app {\n graphQLSchema {\n id\n }\n }\n graphqlSchema {\n id\n services {\n friendlyServiceName\n logoUrl\n service\n slug\n supportsCustomRedirectUri\n supportsCustomServiceAuth\n supportsOauthLogin\n }\n }\n }\n }\n}",
operationName: "CreateNewSchemaMutation",
variables: variables,

@@ -218,7 +279,7 @@ options: options,

};
exports.fetchCLISessionQuery = fetchCLISessionQuery;
var executeAckCLISessionEventMutation = function (variables, options) {
exports.executeCreateNewSchemaMutation = executeCreateNewSchemaMutation;
var executeCreatePersistedQueryMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation AckCLISessionEventMutation($nfToken: String!, $sessionId: String!, $eventIds: [String!]!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n ackNetlifyCliEvents(input: {eventIds: $eventIds, sessionId: $sessionId}) {\n events {\n id\n }\n }\n }\n}",
operationName: "AckCLISessionEventMutation",
query: "mutation CreatePersistedQueryMutation($nfToken: String!, $cacheStrategy: OneGraphPersistedQueryCacheStrategyArg, $allowedOperationNames: [String!]!, $fallbackOnError: Boolean!, $freeVariables: [String!]!, $query: String!, $tags: [String!]!, $description: String, $appId: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createPersistedQuery(\n input: {query: $query, appId: $appId, cacheStrategy: $cacheStrategy, allowedOperationNames: $allowedOperationNames, fallbackOnError: $fallbackOnError, freeVariables: $freeVariables, tags: $tags, description: $description}\n ) {\n persistedQuery {\n id\n allowedOperationNames\n description\n fixedVariables\n freeVariables\n query\n tags\n }\n }\n }\n}",
operationName: "CreatePersistedQueryMutation",
variables: variables,

@@ -229,7 +290,7 @@ options: options,

};
exports.executeAckCLISessionEventMutation = executeAckCLISessionEventMutation;
var fetchAppSchemaQuery = function (variables, options) {
exports.executeCreatePersistedQueryMutation = executeCreatePersistedQueryMutation;
var executeCreateSharedDocumentMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "query AppSchemaQuery($nfToken: String!, $appId: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n app(id: $appId) {\n graphQLSchema {\n appId\n createdAt\n id\n services {\n friendlyServiceName\n logoUrl\n service\n slug\n supportsCustomRedirectUri\n supportsCustomServiceAuth\n supportsOauthLogin\n }\n updatedAt\n }\n }\n }\n}",
operationName: "AppSchemaQuery",
query: "mutation CreateSharedDocumentMutation($nfToken: String!, $input: OneGraphCreateSharedDocumentInput!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createSharedDocument(input: $input) {\n sharedDocument {\n id\n moderationStatus\n operationName\n services {\n friendlyServiceName\n }\n description\n }\n }\n }\n}",
operationName: "CreateSharedDocumentMutation",
variables: variables,

@@ -240,7 +301,7 @@ options: options,

};
exports.fetchAppSchemaQuery = fetchAppSchemaQuery;
var executeUpsertAppForSiteMutation = function (variables, options) {
exports.executeCreateSharedDocumentMutation = executeCreateSharedDocumentMutation;
var fetchListPersistedQueries = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation UpsertAppForSiteMutation($nfToken: String!, $siteId: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n upsertAppForNetlifySite(input: {netlifySiteId: $siteId}) {\n org {\n id\n name\n }\n app {\n id\n name\n corsOrigins\n customCorsOrigins {\n friendlyServiceName\n displayName\n encodedValue\n }\n }\n }\n }\n}",
operationName: "UpsertAppForSiteMutation",
query: "query ListPersistedQueries($appId: String!, $first: Int!, $after: String, $tags: [String!]!) {\n oneGraph {\n app(id: $appId) {\n id\n persistedQueries(first: $first, after: $after, tags: $tags) {\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n id\n query\n fixedVariables\n freeVariables\n allowedOperationNames\n tags\n description\n }\n }\n }\n }\n}",
operationName: "ListPersistedQueries",
variables: variables,

@@ -251,7 +312,7 @@ options: options,

};
exports.executeUpsertAppForSiteMutation = executeUpsertAppForSiteMutation;
var executeCreateNewSchemaMutation = function (variables, options) {
exports.fetchListPersistedQueries = fetchListPersistedQueries;
var fetchListSharedDocumentsQuery = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation CreateNewSchemaMutation($nfToken: String!, $input: OneGraphCreateGraphQLSchemaInput!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n createGraphQLSchema(input: $input) {\n app {\n graphQLSchema {\n id\n }\n }\n graphqlSchema {\n id\n services {\n friendlyServiceName\n logoUrl\n service\n slug\n supportsCustomRedirectUri\n supportsCustomServiceAuth\n supportsOauthLogin\n }\n }\n }\n }\n}",
operationName: "CreateNewSchemaMutation",
query: "query ListSharedDocumentsQuery($nfToken: String!, $first: Int = 10, $status: OneGraphSharedDocumentModerationStatusEnum, $services: [OneGraphServiceEnumArg!]!, $style: OneGraphAppLogoStyleEnum = ROUNDED_RECTANGLE) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n sharedDocuments(\n first: $first\n filter: {moderationStatus: {equalTo: $status}, services: {in: $services}}\n ) {\n nodes {\n description\n body\n createdAt\n id\n moderationStatus\n operationName\n siteId\n updatedAt\n services {\n friendlyServiceName\n logoUrl(style: $style)\n service\n slug\n }\n }\n }\n }\n}",
operationName: "ListSharedDocumentsQuery",
variables: variables,

@@ -262,3 +323,3 @@ options: options,

};
exports.executeCreateNewSchemaMutation = executeCreateNewSchemaMutation;
exports.fetchListSharedDocumentsQuery = fetchListSharedDocumentsQuery;
var executeMarkCLISessionActiveHeartbeat = function (variables, options) {

@@ -284,2 +345,42 @@ return fetchNetlifyGraph({

exports.executeMarkCLISessionInactive = executeMarkCLISessionInactive;
var fetchPersistedQueryQuery = function (variables, options) {
return fetchNetlifyGraph({
query: "query PersistedQueryQuery($nfToken: String!, $appId: String!, $id: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n persistedQuery(appId: $appId, id: $id) {\n id\n query\n allowedOperationNames\n description\n freeVariables\n fixedVariables\n tags\n }\n }\n}",
operationName: "PersistedQueryQuery",
variables: variables,
options: options,
fetchStrategy: "POST",
});
};
exports.fetchPersistedQueryQuery = fetchPersistedQueryQuery;
var fetchSharedDocumentQuery = function (variables, options) {
return fetchNetlifyGraph({
query: "query SharedDocumentQuery($nfToken: String!, $id: String!, $logoStyle: OneGraphAppLogoStyleEnum = ROUNDED_RECTANGLE) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n sharedDocument(id: $id) {\n body\n createdAt\n description\n id\n moderationStatus\n operationName\n updatedAt\n services {\n logoUrl(style: $logoStyle)\n friendlyServiceName\n service\n slug\n }\n }\n }\n}",
operationName: "SharedDocumentQuery",
variables: variables,
options: options,
fetchStrategy: "POST",
});
};
exports.fetchSharedDocumentQuery = fetchSharedDocumentQuery;
var executeUpdateCLISessionMetadataMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation UpdateCLISessionMetadataMutation($nfToken: String!, $sessionId: String!, $metadata: JSON!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n updateNetlifyCliSession(input: {id: $sessionId, metadata: $metadata}) {\n session {\n id\n name\n metadata\n cliHeartbeatIntervalMs\n }\n }\n }\n}",
operationName: "UpdateCLISessionMetadataMutation",
variables: variables,
options: options,
fetchStrategy: "POST",
});
};
exports.executeUpdateCLISessionMetadataMutation = executeUpdateCLISessionMetadataMutation;
var executeUpsertAppForSiteMutation = function (variables, options) {
return fetchNetlifyGraph({
query: "mutation UpsertAppForSiteMutation($nfToken: String!, $siteId: String!) {\n oneGraph(auths: {netlifyAuth: {oauthToken: $nfToken}}) {\n upsertAppForNetlifySite(input: {netlifySiteId: $siteId}) {\n org {\n id\n name\n }\n app {\n id\n name\n corsOrigins\n customCorsOrigins {\n friendlyServiceName\n displayName\n encodedValue\n }\n }\n }\n }\n}",
operationName: "UpsertAppForSiteMutation",
variables: variables,
options: options,
fetchStrategy: "POST",
});
};
exports.executeUpsertAppForSiteMutation = executeUpsertAppForSiteMutation;
/**

@@ -349,2 +450,18 @@ * The generated NetlifyGraph library with your operations

executeMarkCLISessionInactive: exports.executeMarkCLISessionInactive,
/**
* List shared documents given a set of filters
*/
fetchListSharedDocumentsQuery: exports.fetchListSharedDocumentsQuery,
/**
* Create a document with a shared operation for others to import and use
*/
executeCreateSharedDocumentMutation: exports.executeCreateSharedDocumentMutation,
/**
* Find a shared document given its id
*/
fetchSharedDocumentQuery: exports.fetchSharedDocumentQuery,
/**
* Retrieve a list of _all_ supported services from OneGraph
*/
fetchListNetlifyEnabledServicesQuery: exports.fetchListNetlifyEnabledServicesQuery,
};

@@ -351,0 +468,0 @@ exports.default = functions;

@@ -25,2 +25,3 @@ "use strict";

var graphql_1 = require("graphql");
var internalConsole_1 = require("./internalConsole");
function capitalizeFirstLetter(string) {

@@ -148,2 +149,3 @@ return string.charAt(0).toUpperCase() + string.slice(1);

var argHandler = function (node) {
var _a;
if (node.value && node.value.kind === graphql_1.Kind.VARIABLE) {

@@ -156,3 +158,7 @@ var argument = typeInfo.getArgument();

}
variableRecords[node.value.name.value] = __assign(__assign({}, existingRecord), { usageCount: existingRecord.usageCount + 1 });
if (!existingRecord) {
internalConsole_1.internalConsole.warn("Undefined variable $" + node.value.name.value + " found in operation " + ((_a = operationDefinition.name) === null || _a === void 0 ? void 0 : _a.value));
return node;
}
variableRecords[node.value.name.value] = __assign(__assign({}, existingRecord), { usageCount: (existingRecord === null || existingRecord === void 0 ? void 0 : existingRecord.usageCount) + 1 });
}

@@ -162,2 +168,3 @@ return node;

var objectFieldHandler = function (node) {
var _a;
if (node.value && node.value.kind === graphql_1.Kind.VARIABLE) {

@@ -174,2 +181,6 @@ var parentType = typeInfo.getParentInputType();

}
if (!existingRecord) {
internalConsole_1.internalConsole.warn("Undefined variable $" + node.value.name.value + " found in operation " + ((_a = operationDefinition.name) === null || _a === void 0 ? void 0 : _a.value));
return node;
}
variableRecords[node.value.name.value] = __assign(__assign({}, existingRecord), { usageCount: existingRecord.usageCount + 1 });

@@ -176,0 +187,0 @@ }

@@ -109,6 +109,6 @@ "use strict";

var generatedNetlifyGraphDynamicClient = function (netlifyGraphConfig) {
return lruCacheImplementation + "\n\n" + out(netlifyGraphConfig, ["node"], "const httpFetch = (siteId, options) => {\n const reqBody = options.body || null\n const userHeaders = options.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 url = 'https://serve.onegraph.com/graphql?app_id=' + siteId\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.write(reqBody)\n req.end()\n })\n}\n") + "\n" + out(netlifyGraphConfig, ["browser"], "const httpFetch = (siteId, options) => {\n const reqBody = options.body || null;\n const userHeaders = options.headers || {};\n const headers = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'POST',\n headers: headers,\n timeout: timeoutMs,\n body: reqBody\n };\n\n const url = 'https://serve.onegraph.com/graphql?app_id=' + siteId;\n\n return fetch(url, reqOptions);\n}") + "\n\nconst fetchNetlifyGraph = function fetchNetlifyGraph(input) {\n const query = input.query;\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 payload = {\n query: 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': ''\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 response = httpFetch(siteId, {\n method: 'POST',\n headers: {\n ...conditionalHeaders,\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n body: JSON.stringify(payload),\n });\n\n response.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('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 return cachedOrLiveValue\n}\n";
return lruCacheImplementation + "\n\n" + out(netlifyGraphConfig, ["node"], "const httpFetch = (siteId, options) => {\n const reqBody = options.body || null\n const userHeaders = options.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 url = 'https://graph.netlify.com/graphql?app_id=' + siteId\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.write(reqBody)\n req.end()\n })\n}\n") + "\n" + out(netlifyGraphConfig, ["browser"], "const httpFetch = (siteId, options) => {\n const reqBody = options.body || null;\n const userHeaders = options.headers || {};\n const headers = {\n ...userHeaders,\n 'Content-Type': 'application/json',\n };\n\n const timeoutMs = 30_000;\n\n const reqOptions = {\n method: 'POST',\n headers: headers,\n timeout: timeoutMs,\n body: reqBody\n };\n\n const url = 'https://graph.netlify.com/graphql?app_id=' + siteId;\n\n return fetch(url, reqOptions);\n}") + "\n\nconst fetchNetlifyGraph = function fetchNetlifyGraph(input) {\n const query = input.query;\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 payload = {\n query: 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': ''\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 response = httpFetch(siteId, {\n method: 'POST',\n headers: {\n ...conditionalHeaders,\n Authorization: accessToken ? 'Bearer ' + accessToken : '',\n },\n body: JSON.stringify(payload),\n });\n\n response.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('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 return cachedOrLiveValue\n}\n";
};
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);\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': ''\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('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://graph.netlify.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://graph.netlify.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://graph.netlify.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://graph.netlify.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': ''\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('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) {

@@ -0,1 +1,2 @@

import GeneratedClient from "./generatedOneGraphClient";
/**

@@ -250,4 +251,20 @@ * Given an appId and desired services, fetch the schema (in json form) for that app

}>;
export declare const executeCreateApiTokenMutation: typeof import("./generatedOneGraphClient").executeCreateApiTokenMutation;
export declare const executeCreateGraphQLSchemaMutation: typeof import("./generatedOneGraphClient").executeCreateGraphQLSchemaMutation;
export declare const executeCreateApiTokenMutation: typeof GeneratedClient.executeCreateApiTokenMutation;
export declare const executeCreateGraphQLSchemaMutation: typeof GeneratedClient.executeCreateGraphQLSchemaMutation;
/**
* List shared documents given a set of filters
*/
export declare const fetchListSharedDocumentsQuery: typeof GeneratedClient.fetchListSharedDocumentsQuery;
/**
* Create a document with a shared operation for others to import and use
*/
export declare const executeCreateSharedDocumentMutation: typeof GeneratedClient.executeCreateSharedDocumentMutation;
/**
* Find a shared document given its id
*/
export declare const fetchSharedDocumentQuery: typeof GeneratedClient.fetchSharedDocumentQuery;
/**
* Find a shared document given its id
*/
export declare const fetchListNetlifyEnabledServicesQuery: typeof GeneratedClient.fetchListNetlifyEnabledServicesQuery;
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.executeCreateGraphQLSchemaMutation = exports.executeCreateApiTokenMutation = exports.executeMarkCliSessionInactive = exports.executeMarkCliSessionActiveHeartbeat = exports.fetchEnabledServices = exports.ensureAppForSite = exports.createNewAppSchema = exports.upsertAppForSite = exports.fetchAppSchema = exports.friendlyEventName = exports.executeCreatePersistedQueryMutation = exports.ackCLISessionEvents = exports.updateCLISessionMetadata = exports.createCLISession = exports.fetchCliSessionEvents = exports.fetchCliSession = exports.fetchPersistedQuery = exports.fetchOneGraphSchema = exports.fetchOneGraphSchemaJson = void 0;
exports.fetchListNetlifyEnabledServicesQuery = exports.fetchSharedDocumentQuery = exports.executeCreateSharedDocumentMutation = exports.fetchListSharedDocumentsQuery = exports.executeCreateGraphQLSchemaMutation = exports.executeCreateApiTokenMutation = exports.executeMarkCliSessionInactive = exports.executeMarkCliSessionActiveHeartbeat = exports.fetchEnabledServices = exports.ensureAppForSite = exports.createNewAppSchema = exports.upsertAppForSite = exports.fetchAppSchema = exports.friendlyEventName = exports.executeCreatePersistedQueryMutation = exports.ackCLISessionEvents = exports.updateCLISessionMetadata = exports.createCLISession = exports.fetchCliSessionEvents = exports.fetchCliSession = exports.fetchPersistedQuery = exports.fetchOneGraphSchema = exports.fetchOneGraphSchemaJson = void 0;
var graphql_1 = require("graphql");

@@ -47,3 +47,3 @@ var fetch = require("node-fetch");

var ONEDASH_APP_ID = "0b066ba6-ed39-4db8-a497-ba0be34d5b2a";
var netlifyGraphHost = "serve.onegraph.com";
var netlifyGraphHost = "graph.netlify.com";
/**

@@ -502,2 +502,18 @@ * Given an appId and desired services, fetch the schema (in json form) for that app

exports.executeCreateGraphQLSchemaMutation = generatedOneGraphClient_1.default.executeCreateGraphQLSchemaMutation;
/**
* List shared documents given a set of filters
*/
exports.fetchListSharedDocumentsQuery = generatedOneGraphClient_1.default.fetchListSharedDocumentsQuery;
/**
* Create a document with a shared operation for others to import and use
*/
exports.executeCreateSharedDocumentMutation = generatedOneGraphClient_1.default.executeCreateSharedDocumentMutation;
/**
* Find a shared document given its id
*/
exports.fetchSharedDocumentQuery = generatedOneGraphClient_1.default.fetchSharedDocumentQuery;
/**
* Find a shared document given its id
*/
exports.fetchListNetlifyEnabledServicesQuery = generatedOneGraphClient_1.default.fetchListNetlifyEnabledServicesQuery;
//# sourceMappingURL=oneGraphClient.js.map
{
"name": "netlify-onegraph-internal",
"version": "0.1.17",
"version": "0.1.18",
"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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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