Initial Save

This commit is contained in:
jackbeeby
2025-03-28 12:30:19 +11:00
parent e381994f19
commit d8773925e8
9910 changed files with 982718 additions and 0 deletions

44
node_modules/apollo-cache-control/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import { ResponsePath } from 'graphql';
import { ApolloServerPlugin } from "apollo-server-plugin-base";
export interface CacheControlFormat {
version: 1;
hints: ({
path: (string | number)[];
} & CacheHint)[];
}
export interface CacheHint {
maxAge?: number;
scope?: CacheScope;
}
export declare enum CacheScope {
Public = "PUBLIC",
Private = "PRIVATE"
}
export interface CacheControlExtensionOptions {
defaultMaxAge?: number;
calculateHttpHeaders?: boolean;
stripFormattedExtensions?: boolean;
}
declare module 'graphql/type/definition' {
interface GraphQLResolveInfo {
cacheControl: {
setCacheHint: (hint: CacheHint) => void;
cacheHint: CacheHint;
};
}
}
declare module 'apollo-server-types' {
interface GraphQLRequestContext<TContext> {
overallCachePolicy?: Required<CacheHint> | undefined;
}
}
declare type MapResponsePathHints = Map<ResponsePath, CacheHint>;
export declare const plugin: (options?: CacheControlExtensionOptions) => ApolloServerPlugin;
declare function computeOverallCachePolicy(hints: MapResponsePathHints): Required<CacheHint> | undefined;
declare function addHint(hints: MapResponsePathHints, path: ResponsePath, hint: CacheHint): void;
export declare const __testing__: {
addHint: typeof addHint;
computeOverallCachePolicy: typeof computeOverallCachePolicy;
};
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EAEb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,CAAC;QAAE,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC,EAAE,CAAC;CACtD;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,kBAAkB;QAC1B,YAAY,EAAE;YACZ,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;YACxC,SAAS,EAAE,SAAS,CAAC;SACtB,CAAC;KACH;CACF;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,qBAAqB,CAAC,QAAQ;QAEtC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;KACtD;CACF;AAED,aAAK,oBAAoB,GAAG,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAEzD,eAAO,MAAM,MAAM,aACR,4BAA4B,KACpC,kBAyID,CAAC;AAkDH,iBAAS,yBAAyB,CAChC,KAAK,EAAE,oBAAoB,GAC1B,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,CAwBjC;AAED,iBAAS,OAAO,CAAC,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,QAOhF;AAED,eAAO,MAAM,WAAW;;;CAGvB,CAAC"}

148
node_modules/apollo-cache-control/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.__testing__ = exports.plugin = exports.CacheScope = void 0;
const graphql_1 = require("graphql");
var CacheScope;
(function (CacheScope) {
CacheScope["Public"] = "PUBLIC";
CacheScope["Private"] = "PRIVATE";
})(CacheScope = exports.CacheScope || (exports.CacheScope = {}));
exports.plugin = (options = Object.create(null)) => ({
requestDidStart(requestContext) {
const defaultMaxAge = options.defaultMaxAge || 0;
const hints = new Map();
function setOverallCachePolicyWhenUnset() {
if (!requestContext.overallCachePolicy) {
requestContext.overallCachePolicy = computeOverallCachePolicy(hints);
}
}
return {
executionDidStart: () => ({
executionDidEnd: () => setOverallCachePolicyWhenUnset(),
willResolveField({ info }) {
let hint = {};
const targetType = graphql_1.getNamedType(info.returnType);
if (targetType instanceof graphql_1.GraphQLObjectType ||
targetType instanceof graphql_1.GraphQLInterfaceType) {
if (targetType.astNode) {
hint = mergeHints(hint, cacheHintFromDirectives(targetType.astNode.directives));
}
}
const fieldDef = info.parentType.getFields()[info.fieldName];
if (fieldDef.astNode) {
hint = mergeHints(hint, cacheHintFromDirectives(fieldDef.astNode.directives));
}
if ((targetType instanceof graphql_1.GraphQLObjectType ||
targetType instanceof graphql_1.GraphQLInterfaceType ||
!info.path.prev) &&
hint.maxAge === undefined) {
hint.maxAge = defaultMaxAge;
}
if (hint.maxAge !== undefined || hint.scope !== undefined) {
addHint(hints, info.path, hint);
}
info.cacheControl = {
setCacheHint: (hint) => {
addHint(hints, info.path, hint);
},
cacheHint: hint,
};
},
}),
responseForOperation() {
setOverallCachePolicyWhenUnset();
return null;
},
willSendResponse(requestContext) {
const { response, overallCachePolicy: overallCachePolicyOverride, } = requestContext;
if (response.errors) {
return;
}
const overallCachePolicy = overallCachePolicyOverride ||
(requestContext.overallCachePolicy =
computeOverallCachePolicy(hints));
if (overallCachePolicy &&
options.calculateHttpHeaders &&
response.http) {
response.http.headers.set('Cache-Control', `max-age=${overallCachePolicy.maxAge}, ${overallCachePolicy.scope.toLowerCase()}`);
}
if (options.stripFormattedExtensions !== false)
return;
const extensions = response.extensions || (response.extensions = Object.create(null));
if (typeof extensions.cacheControl !== 'undefined') {
throw new Error("The cacheControl information already existed.");
}
extensions.cacheControl = {
version: 1,
hints: Array.from(hints).map(([path, hint]) => (Object.assign({ path: [...graphql_1.responsePathAsArray(path)] }, hint))),
};
}
};
}
});
function cacheHintFromDirectives(directives) {
if (!directives)
return undefined;
const cacheControlDirective = directives.find(directive => directive.name.value === 'cacheControl');
if (!cacheControlDirective)
return undefined;
if (!cacheControlDirective.arguments)
return undefined;
const maxAgeArgument = cacheControlDirective.arguments.find(argument => argument.name.value === 'maxAge');
const scopeArgument = cacheControlDirective.arguments.find(argument => argument.name.value === 'scope');
return {
maxAge: maxAgeArgument &&
maxAgeArgument.value &&
maxAgeArgument.value.kind === 'IntValue'
? parseInt(maxAgeArgument.value.value)
: undefined,
scope: scopeArgument &&
scopeArgument.value &&
scopeArgument.value.kind === 'EnumValue'
? scopeArgument.value.value
: undefined,
};
}
function mergeHints(hint, otherHint) {
if (!otherHint)
return hint;
return {
maxAge: otherHint.maxAge !== undefined ? otherHint.maxAge : hint.maxAge,
scope: otherHint.scope || hint.scope,
};
}
function computeOverallCachePolicy(hints) {
let lowestMaxAge = undefined;
let scope = CacheScope.Public;
for (const hint of hints.values()) {
if (hint.maxAge !== undefined) {
lowestMaxAge =
lowestMaxAge !== undefined
? Math.min(lowestMaxAge, hint.maxAge)
: hint.maxAge;
}
if (hint.scope === CacheScope.Private) {
scope = CacheScope.Private;
}
}
return lowestMaxAge
? {
maxAge: lowestMaxAge,
scope,
}
: undefined;
}
function addHint(hints, path, hint) {
const existingCacheHint = hints.get(path);
if (existingCacheHint) {
hints.set(path, mergeHints(existingCacheHint, hint));
}
else {
hints.set(path, hint);
}
}
exports.__testing__ = {
addHint,
computeOverallCachePolicy,
};
//# sourceMappingURL=index.js.map

1
node_modules/apollo-cache-control/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAOiB;AAajB,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,iCAAmB,CAAA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