@apollo/core-schema
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -7,4 +7,8 @@ # CHANGELOG | ||
## v0.1.1 | ||
- Remove unnecessary `engines` specification for `npm` which limited it to only working on `npm@7`. The spirit of that specificity was to provide a hint to _maintainers_ as to what version of `npm` should be used to generate the `package-lock.json` file and reduce churn on that file which happened between npm@6 and npm@7. Of course, while this was effective and harmless in the `federation` monorepo (from which this was copied and pasted from), it obviously has implications on consumers in published packages. Fixed via [`ee1a330e`](https://github.com/apollographql/core-schema-js/commit/ee1a330e2f2c3f8b45a4526caf3bf4b3a4de4f7a). | ||
## v0.1.0 | ||
- Initial Release 🎉 |
@@ -5,3 +5,3 @@ "use strict"; | ||
const error_1 = require("./error"); | ||
const ErrNoData = (causes) => error_1.err('NoData', { | ||
const ErrNoData = (causes) => (0, error_1.err)('NoData', { | ||
message: 'no data', | ||
@@ -11,3 +11,3 @@ causes | ||
exports.ErrNoData = ErrNoData; | ||
const ErrEvalStackEmpty = () => error_1.err('EvalStackEmpty', { | ||
const ErrEvalStackEmpty = () => (0, error_1.err)('EvalStackEmpty', { | ||
code: 'EvalStackEmpty', | ||
@@ -17,3 +17,3 @@ message: 'this method must only be called from an evaluator, during evaluation. no evaluation is ongoing.' | ||
exports.ErrEvalStackEmpty = ErrEvalStackEmpty; | ||
const ErrCheckFailed = (causes) => error_1.err('CheckFailed', { | ||
const ErrCheckFailed = (causes) => (0, error_1.err)('CheckFailed', { | ||
message: 'one or more checks failed', | ||
@@ -36,3 +36,3 @@ causes | ||
if (!cell.result) { | ||
throw exports.ErrNoData(); | ||
throw (0, exports.ErrNoData)(); | ||
} | ||
@@ -42,3 +42,3 @@ if (cell.result.data === undefined) { | ||
throw cell.result.errors[0]; | ||
throw exports.ErrNoData(cell.result.errors); | ||
throw (0, exports.ErrNoData)(cell.result.errors); | ||
} | ||
@@ -77,3 +77,3 @@ return cell.result.data; | ||
return this; | ||
throw exports.ErrCheckFailed(errors); | ||
throw (0, exports.ErrCheckFailed)(errors); | ||
} | ||
@@ -95,3 +95,3 @@ update(update) { | ||
if (!top) | ||
throw exports.ErrEvalStackEmpty(); | ||
throw (0, exports.ErrEvalStackEmpty)(); | ||
return top; | ||
@@ -98,0 +98,0 @@ } |
@@ -19,3 +19,3 @@ "use strict"; | ||
toString() { | ||
let output = `[${this.code}] ${graphql_1.printError(this)}`; | ||
let output = `[${this.code}] ${(0, graphql_1.printError)(this)}`; | ||
const causes = this.causes; | ||
@@ -22,0 +22,0 @@ if (causes && causes.length) { |
@@ -7,3 +7,3 @@ "use strict"; | ||
const error_1 = require("./error"); | ||
const ErrNoPath = (url, node) => error_1.err('NoPath', { | ||
const ErrNoPath = (url, node) => (0, error_1.err)('NoPath', { | ||
message: `feature url does not have a path: ${url}`, | ||
@@ -14,3 +14,3 @@ url, | ||
exports.ErrNoPath = ErrNoPath; | ||
const ErrNoName = (url, node) => error_1.err('NoName', { | ||
const ErrNoName = (url, node) => (0, error_1.err)('NoName', { | ||
message: `feature url does not specify a name: ${url}`, | ||
@@ -21,3 +21,3 @@ url, | ||
exports.ErrNoName = ErrNoName; | ||
const ErrNoVersion = (url, node) => error_1.err('NoVersion', { | ||
const ErrNoVersion = (url, node) => (0, error_1.err)('NoVersion', { | ||
message: `feature url does not specify a version: ${url}`, | ||
@@ -38,11 +38,11 @@ url, | ||
if (!url.pathname || url.pathname === '/') | ||
throw exports.ErrNoPath(url, node); | ||
throw (0, exports.ErrNoPath)(url, node); | ||
const path = url.pathname.split('/'); | ||
const verStr = path.pop(); | ||
if (!verStr) | ||
throw exports.ErrNoVersion(url, node); | ||
throw (0, exports.ErrNoVersion)(url, node); | ||
const version = version_1.Version.parse(verStr); | ||
const name = path[path.length - 1]; | ||
if (!name) | ||
throw exports.ErrNoName(url, node); | ||
throw (0, exports.ErrNoName)(url, node); | ||
const element = url.hash ? url.hash.slice(1) : undefined; | ||
@@ -49,0 +49,0 @@ url.hash = ''; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const names_1 = require("./names"); | ||
const ErrTooManyFeatureVersions = (features) => error_1.err('TooManyFeatureVersions', { | ||
const ErrTooManyFeatureVersions = (features) => (0, error_1.err)('TooManyFeatureVersions', { | ||
message: `too many versions of ${features[0].url.identity} at v${features[0].url.version.series}`, | ||
@@ -25,3 +25,3 @@ features, | ||
canonicalName(docName) { | ||
const [prefix, base] = names_1.getPrefix(docName); | ||
const [prefix, base] = (0, names_1.getPrefix)(docName); | ||
if (prefix) { | ||
@@ -28,0 +28,0 @@ if (prefix !== this.name) |
export declare type Template = Parameters<typeof String.raw>; | ||
export declare const isTemplate: (args: any[]) => args is [template: TemplateStringsArray, ...substitutions: any[]]; | ||
export declare const isTemplate: (args: any[]) => args is [template: { | ||
raw: readonly string[] | ArrayLike<string>; | ||
}, ...substitutions: any[]]; | ||
export declare const isAsString: (args: any[]) => args is AsString; | ||
@@ -4,0 +6,0 @@ export declare type AsTemplateOr<T> = Template | [T]; |
@@ -10,9 +10,9 @@ "use strict"; | ||
exports.isTemplate = isTemplate; | ||
const isAsString = (args) => exports.isTemplate(args) || (args.length === 1 && typeof args[0] === 'string'); | ||
const isAsString = (args) => (0, exports.isTemplate)(args) || (args.length === 1 && typeof args[0] === 'string'); | ||
exports.isAsString = isAsString; | ||
function asString(input) { | ||
return (!exports.isAsString(input) | ||
return (!(0, exports.isAsString)(input) | ||
? undefined | ||
: | ||
exports.isTemplate(input) | ||
(0, exports.isTemplate)(input) | ||
? String.raw(...input) | ||
@@ -19,0 +19,0 @@ : input[0]); |
@@ -34,3 +34,3 @@ "use strict"; | ||
const names_1 = require("./names"); | ||
const ErrExtraSchema = (def) => error_1.err('ExtraSchema', { | ||
const ErrExtraSchema = (def) => (0, error_1.err)('ExtraSchema', { | ||
message: 'extra schema definition ignored', | ||
@@ -41,5 +41,5 @@ schemaDefinition: def, | ||
exports.ErrExtraSchema = ErrExtraSchema; | ||
const ErrNoSchema = () => error_1.err('NoSchema', 'no schema definitions found'); | ||
const ErrNoSchema = () => (0, error_1.err)('NoSchema', 'no schema definitions found'); | ||
exports.ErrNoSchema = ErrNoSchema; | ||
const ErrNoCore = (causes) => error_1.err('NoCore', { | ||
const ErrNoCore = (causes) => (0, error_1.err)('NoCore', { | ||
message: 'no core feature found', | ||
@@ -49,3 +49,3 @@ causes | ||
exports.ErrNoCore = ErrNoCore; | ||
const ErrBadFeature = (node, ...causes) => error_1.err('BadFeature', { | ||
const ErrBadFeature = (node, ...causes) => (0, error_1.err)('BadFeature', { | ||
message: 'bad core feature request', | ||
@@ -57,3 +57,3 @@ directive: node, | ||
exports.ErrBadFeature = ErrBadFeature; | ||
const ErrOverlappingNames = (name, features) => error_1.err('OverlappingNames', { | ||
const ErrOverlappingNames = (name, features) => (0, error_1.err)('OverlappingNames', { | ||
message: `the name "${name}" is defined by multiple features`, | ||
@@ -70,3 +70,3 @@ name, | ||
static fromSource(source) { | ||
return new CoreSchema(graphql_1.parse(source)); | ||
return new CoreSchema((0, graphql_1.parse)(source)); | ||
} | ||
@@ -92,3 +92,3 @@ check(...fns) { | ||
: (dir) => this.featureFor(dir) === feature; | ||
if (!is_1.hasDirectives(node)) | ||
if (!(0, is_1.hasDirectives)(node)) | ||
return; | ||
@@ -100,3 +100,3 @@ if (!feature) | ||
const data = directive instanceof graphql_1.GraphQLDirective | ||
? values_1.getArgumentValues(directive, d) | ||
? (0, values_1.getArgumentValues)(directive, d) | ||
: undefined; | ||
@@ -116,6 +116,6 @@ const item = { | ||
featureFor(node) { | ||
if (!is_1.hasName(node)) | ||
if (!(0, is_1.hasName)(node)) | ||
return; | ||
const [prefix] = names_1.getPrefix(node.name.value); | ||
if (prefix || is_1.isAst(node, 'Directive', 'DirectiveDefinition')) { | ||
const [prefix] = (0, names_1.getPrefix)(node.name.value); | ||
if (prefix || (0, is_1.isAst)(node, 'Directive', 'DirectiveDefinition')) { | ||
return this.names.get(prefix !== null && prefix !== void 0 ? prefix : node.name.value); | ||
@@ -135,7 +135,7 @@ } | ||
else | ||
this.report(exports.ErrExtraSchema(def)); | ||
this.report((0, exports.ErrExtraSchema)(def)); | ||
} | ||
} | ||
if (!schema) { | ||
throw exports.ErrNoSchema(); | ||
throw (0, exports.ErrNoSchema)(); | ||
} | ||
@@ -155,3 +155,3 @@ return schema; | ||
try { | ||
const candidate = values_1.getArgumentValues($core, d); | ||
const candidate = (0, values_1.getArgumentValues)($core, d); | ||
if (CORE_VERSIONS.has(candidate.feature) && | ||
@@ -168,3 +168,3 @@ d.name.value === ((_b = candidate.as) !== null && _b !== void 0 ? _b : 'core')) { | ||
try { | ||
const values = values_1.getArgumentValues($core, d); | ||
const values = (0, values_1.getArgumentValues)($core, d); | ||
const url = feature_url_1.default.parse(values.feature); | ||
@@ -174,7 +174,7 @@ features.add(new features_1.Feature(url, (_d = values.as) !== null && _d !== void 0 ? _d : url.name, d, values.for)); | ||
catch (err) { | ||
this.report(exports.ErrBadFeature(d, err)); | ||
this.report((0, exports.ErrBadFeature)(d, err)); | ||
} | ||
} | ||
if (!coreFeature) | ||
throw exports.ErrNoCore(noCoreErrors); | ||
throw (0, exports.ErrNoCore)(noCoreErrors); | ||
this.report(...features.validate()); | ||
@@ -197,3 +197,3 @@ return features; | ||
if (features.length > 1) { | ||
this.report(exports.ErrOverlappingNames(name, features)); | ||
this.report((0, exports.ErrOverlappingNames)(name, features)); | ||
continue; | ||
@@ -220,3 +220,3 @@ } | ||
args: { | ||
feature: { type: graphql_1.GraphQLNonNull(graphql_1.GraphQLString), }, | ||
feature: { type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLString), }, | ||
as: { type: graphql_1.GraphQLString }, | ||
@@ -223,0 +223,0 @@ 'for': { type: Purpose } |
@@ -7,4 +7,4 @@ "use strict"; | ||
exports.test = test; | ||
const print = (val) => graphql_1.printLocation(val.loc); | ||
const print = (val) => (0, graphql_1.printLocation)(val.loc); | ||
exports.print = print; | ||
//# sourceMappingURL=ast.js.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
const error_1 = __importDefault(require("./error")); | ||
const ErrVersionParse = (input) => error_1.default('VersionParse', { | ||
const ErrVersionParse = (input) => (0, error_1.default)('VersionParse', { | ||
message: `expected a version specifier like "v9.8", got "${input}"`, | ||
@@ -22,3 +22,3 @@ input, | ||
if (!match) | ||
throw exports.ErrVersionParse(input); | ||
throw (0, exports.ErrVersionParse)(input); | ||
return new this(+match[1], +match[2]); | ||
@@ -25,0 +25,0 @@ } |
{ | ||
"name": "@apollo/core-schema", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Apollo Core Schema processing library", | ||
@@ -26,4 +26,3 @@ "main": "dist/index.js", | ||
"engines": { | ||
"node": ">=12.13.0 <17.0", | ||
"npm": "7.x" | ||
"node": ">=12.13.0 <17.0" | ||
}, | ||
@@ -33,4 +32,3 @@ "publishConfig": { | ||
}, | ||
"dependencies": { | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
@@ -40,9 +38,9 @@ "graphql": "^14.5.0 || ^15.0.0" | ||
"devDependencies": { | ||
"@types/jest": "^26.0.20", | ||
"graphql": "^15.5.1", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.3.2", | ||
"ts-jest": "^26.5.0", | ||
"typescript": "^4.3.5" | ||
"@types/jest": "27.0.2", | ||
"graphql": "15.6.1", | ||
"jest": "27.3.1", | ||
"prettier": "2.4.1", | ||
"ts-jest": "27.0.7", | ||
"typescript": "4.4.4" | ||
} | ||
} |
@@ -210,3 +210,3 @@ import { err } from './error' | ||
} else { | ||
this.report(err) | ||
this.report(err as Error) | ||
} | ||
@@ -213,0 +213,0 @@ } finally { |
@@ -127,3 +127,3 @@ import { ASTNode, DirectiveNode, DocumentNode, GraphQLDirective, GraphQLEnumType, GraphQLNonNull, GraphQLString, parse, SchemaDefinitionNode, Source } from 'graphql' | ||
this.pure(...schema.directives ?? []) | ||
const noCoreErrors = [] | ||
const noCoreErrors: Error[] = [] | ||
let coreFeature: Feature | null = null | ||
@@ -140,3 +140,3 @@ const features = new Features | ||
} catch (err) { | ||
noCoreErrors.push(err) | ||
noCoreErrors.push(err as Error) | ||
} | ||
@@ -149,3 +149,3 @@ | ||
} catch (err) { | ||
this.report(ErrBadFeature(d, err)) | ||
this.report(ErrBadFeature(d, err as Error)) | ||
} | ||
@@ -152,0 +152,0 @@ } |
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
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138631
68
2680