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

21
node_modules/apollo-tracing/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016-2020 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

24
node_modules/apollo-tracing/README.md generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Apollo Tracing (for Node.js)
This package is used to collect and expose trace data in the [Apollo Tracing](https://github.com/apollographql/apollo-tracing) format.
It relies on instrumenting a GraphQL schema to collect resolver timings, and exposes trace data for an individual request under `extensions` as part of the GraphQL response.
This data can be consumed by [Apollo Studio](https://www.apollographql.com/docs/studio/) (previously, Apollo Engine and Apollo Graph Manager) or any other tool to provide visualization and history of field-by-field execution performance.
## Usage
### Apollo Server
Apollo Server includes built-in support for tracing from version 1.1.0 onwards.
The only code change required is to add `tracing: true` to the options passed to the `ApolloServer` constructor options for your integration of choice. For example, for [`apollo-server-express`](https://npm.im/apollo-server-express):
```javascript
const { ApolloServer } = require('apollo-server-express');
const server = new ApolloServer({
schema,
tracing: true,
});
```

19
node_modules/apollo-tracing/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import { ApolloServerPlugin } from "apollo-server-plugin-base";
export interface TracingFormat {
version: 1;
startTime: string;
endTime: string;
duration: number;
execution: {
resolvers: {
path: (string | number)[];
parentType: string;
fieldName: string;
returnType: string;
startOffset: number;
duration: number;
}[];
};
}
export declare const plugin: (_futureOptions?: {}) => () => ApolloServerPlugin;
//# sourceMappingURL=index.d.ts.map

1
node_modules/apollo-tracing/dist/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE;QACT,SAAS,EAAE;YACT,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;YAC1B,UAAU,EAAE,MAAM,CAAC;YACnB,SAAS,EAAE,MAAM,CAAC;YAClB,UAAU,EAAE,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC;SAClB,EAAE,CAAC;KACL,CAAC;CACH;AAWD,eAAO,MAAM,MAAM,iCAAgC,kBA8FjD,CAAA"}

72
node_modules/apollo-tracing/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = void 0;
const graphql_1 = require("graphql");
const { name: PACKAGE_NAME } = require("../package.json");
exports.plugin = (_futureOptions = {}) => () => ({
requestDidStart() {
const startWallTime = new Date();
let endWallTime;
const startHrTime = process.hrtime();
let duration;
const resolverCalls = [];
return {
executionDidStart: () => ({
executionDidEnd: () => {
duration = process.hrtime(startHrTime);
endWallTime = new Date();
},
willResolveField({ info }) {
const resolverCall = {
path: info.path,
fieldName: info.fieldName,
parentType: info.parentType,
returnType: info.returnType,
startOffset: process.hrtime(startHrTime),
};
resolverCalls.push(resolverCall);
return () => {
resolverCall.endOffset = process.hrtime(startHrTime);
};
},
}),
willSendResponse({ response }) {
if (typeof endWallTime === 'undefined' ||
typeof duration === 'undefined') {
return;
}
const extensions = response.extensions || (response.extensions = Object.create(null));
if (typeof extensions.tracing !== 'undefined') {
throw new Error(PACKAGE_NAME + ": Could not add `tracing` to " +
"`extensions` since `tracing` was unexpectedly already present.");
}
extensions.tracing = {
version: 1,
startTime: startWallTime.toISOString(),
endTime: endWallTime.toISOString(),
duration: durationHrTimeToNanos(duration),
execution: {
resolvers: resolverCalls.map(resolverCall => {
const startOffset = durationHrTimeToNanos(resolverCall.startOffset);
const duration = resolverCall.endOffset
? durationHrTimeToNanos(resolverCall.endOffset) - startOffset
: 0;
return {
path: [...graphql_1.responsePathAsArray(resolverCall.path)],
parentType: resolverCall.parentType.toString(),
fieldName: resolverCall.fieldName,
returnType: resolverCall.returnType.toString(),
startOffset,
duration,
};
}),
},
};
},
};
},
});
function durationHrTimeToNanos(hrtime) {
return hrtime[0] * 1e9 + hrtime[1];
}
//# sourceMappingURL=index.js.map

1
node_modules/apollo-tracing/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,qCAIiB;AAGjB,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AA4B7C,QAAA,MAAM,GAAG,CAAC,cAAc,GAAG,EAAE,EAAE,EAAE,CAAC,GAAuB,EAAE,CAAC,CAAC;IACxE,eAAe;QACb,MAAM,aAAa,GA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C5D,gEAAgE,CAAC,CAAC;iBACrE;gBAGD,UAAU,CAAC,OAAO,GAAG;oBACnB,OAAO,EAAE,CAAC;oBACV,SAAS,EAAE,aAAa,CAAC,WAAW,EAAE;oBACtC,OAAO,EAAE,WAAW,CAAC,WAAW,EAAE;oBAClC,QAAQ,EAAE,qBAAqB,CAAC,QAAQ,CAAC;oBACzC,SAAS,EAAE;wBACT,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;4BAC1C,MAAM,WAAW,GAAG,qBAAqB,CACvC,YAAY,CAAC,WAAW,CACzB,CAAC;4BACF,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS;gCACrC,CAAC,CAAC,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,WAAW;gCAC7D,CAAC,CAAC,CAAC,CAAC;4BACN,OAAO;gCACL,IAAI,EAAE,CAAC,GAAG,6BAAmB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gCACjD,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE;gCAC9C,SAAS,EAAE,YAAY,CAAC,SAAS;gCACjC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE;gCAC9C,WAAW;gCACX,QAAQ;6BACT,CAAC;wBACJ,CAAC,CAAC;qBACH;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAA;AAeF,SAAS,qBAAqB,CAAC,MAA0B;IACvD,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}

21
node_modules/apollo-tracing/package.json generated vendored Normal file
View File

@@ -0,0 +1,21 @@
{
"name": "apollo-tracing",
"version": "0.16.0",
"description": "Collect and expose trace data for GraphQL requests",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"license": "MIT",
"repository": "apollographql/apollo-tracing-js",
"author": "Apollo <opensource@apollographql.com>",
"engines": {
"node": ">=4.0"
},
"dependencies": {
"apollo-server-env": "^3.2.0",
"apollo-server-plugin-base": "^0.14.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
},
"gitHead": "91de501bb389c07ccfc5e684811153267b91e9ac"
}

147
node_modules/apollo-tracing/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,147 @@
import {
ResponsePath,
responsePathAsArray,
GraphQLType,
} from 'graphql';
import { ApolloServerPlugin } from "apollo-server-plugin-base";
const { name: PACKAGE_NAME } = require("../package.json");
export interface TracingFormat {
version: 1;
startTime: string;
endTime: string;
duration: number;
execution: {
resolvers: {
path: (string | number)[];
parentType: string;
fieldName: string;
returnType: string;
startOffset: number;
duration: number;
}[];
};
}
interface ResolverCall {
path: ResponsePath;
fieldName: string;
parentType: GraphQLType;
returnType: GraphQLType;
startOffset: HighResolutionTime;
endOffset?: HighResolutionTime;
}
export const plugin = (_futureOptions = {}) => (): ApolloServerPlugin => ({
requestDidStart() {
const startWallTime: Date = new Date();
let endWallTime: Date | undefined;
const startHrTime: HighResolutionTime = process.hrtime();
let duration: HighResolutionTime | undefined;
const resolverCalls: ResolverCall[] = [];
return {
executionDidStart: () => ({
// It's a little odd that we record the end time after execution rather
// than at the end of the whole request, but because we need to include
// our formatted trace in the request itself, we have to record it
// before the request is over!
// Historically speaking: It's WAS odd that we don't do traces for parse
// or validation errors. Reason being: at the time that this was written
// (now a plugin but originally an extension)). That was the case
// because runQuery DIDN'T (again, at the time, when it was an
// extension) support that since format() was only invoked after
// execution.
executionDidEnd: () => {
duration = process.hrtime(startHrTime);
endWallTime = new Date();
},
willResolveField({ info }) {
const resolverCall: ResolverCall = {
path: info.path,
fieldName: info.fieldName,
parentType: info.parentType,
returnType: info.returnType,
startOffset: process.hrtime(startHrTime),
};
resolverCalls.push(resolverCall);
return () => {
resolverCall.endOffset = process.hrtime(startHrTime);
};
},
}),
willSendResponse({ response }) {
// In the event that we are called prior to the initialization of
// critical date metrics, we'll return undefined to signal that the
// extension did not format properly. Any undefined extension
// results are simply purged by the graphql-extensions module.
if (
typeof endWallTime === 'undefined' ||
typeof duration === 'undefined'
) {
return;
}
const extensions =
response.extensions || (response.extensions = Object.create(null));
// Be defensive and make sure nothing else (other plugin, etc.) has
// already used the `tracing` property on `extensions`.
if (typeof extensions.tracing !== 'undefined') {
throw new Error(PACKAGE_NAME + ": Could not add `tracing` to " +
"`extensions` since `tracing` was unexpectedly already present.");
}
// Set the extensions.
extensions.tracing = {
version: 1,
startTime: startWallTime.toISOString(),
endTime: endWallTime.toISOString(),
duration: durationHrTimeToNanos(duration),
execution: {
resolvers: resolverCalls.map(resolverCall => {
const startOffset = durationHrTimeToNanos(
resolverCall.startOffset,
);
const duration = resolverCall.endOffset
? durationHrTimeToNanos(resolverCall.endOffset) - startOffset
: 0;
return {
path: [...responsePathAsArray(resolverCall.path)],
parentType: resolverCall.parentType.toString(),
fieldName: resolverCall.fieldName,
returnType: resolverCall.returnType.toString(),
startOffset,
duration,
};
}),
},
};
},
};
},
})
type HighResolutionTime = [number, number];
// Converts an hrtime array (as returned from process.hrtime) to nanoseconds.
//
// ONLY CALL THIS ON VALUES REPRESENTING DELTAS, NOT ON THE RAW RETURN VALUE
// FROM process.hrtime() WITH NO ARGUMENTS.
//
// The entire point of the hrtime data structure is that the JavaScript Number
// type can't represent all int64 values without loss of precision:
// Number.MAX_SAFE_INTEGER nanoseconds is about 104 days. Calling this function
// on a duration that represents a value less than 104 days is fine. Calling
// this function on an absolute time (which is generally roughly time since
// system boot) is not a good idea.
function durationHrTimeToNanos(hrtime: HighResolutionTime) {
return hrtime[0] * 1e9 + hrtime[1];
}