apollo-link-core
Advanced tools
Comparing version 0.5.0 to 0.5.2
@@ -1,15 +0,7 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var link_1 = require("./link"); | ||
exports.execute = link_1.execute; | ||
exports.ApolloLink = link_1.ApolloLink; | ||
var linkUtils_1 = require("./linkUtils"); | ||
exports.makePromise = linkUtils_1.makePromise; | ||
var zen_observable_ts_1 = require("zen-observable-ts"); | ||
exports.Observable = zen_observable_ts_1.default; | ||
__export(require("zen-observable-ts")); | ||
exports.default = link_1.ApolloLink; | ||
import { execute, ApolloLink } from './link'; | ||
export { makePromise } from './linkUtils'; | ||
import Observable from 'zen-observable-ts'; | ||
export * from 'zen-observable-ts'; | ||
export default ApolloLink; | ||
export { Observable, ApolloLink, execute }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -20,6 +19,5 @@ var extendStatics = Object.setPrototypeOf || | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var linkUtils_1 = require("./linkUtils"); | ||
var graphql_tag_1 = require("graphql-tag"); | ||
var zen_observable_ts_1 = require("zen-observable-ts"); | ||
import { validateOperation, toLink, isTerminating, LinkError, validateLink, } from './linkUtils'; | ||
import gql from 'graphql-tag'; | ||
import Observable from 'zen-observable-ts'; | ||
var ApolloLink = (function () { | ||
@@ -32,19 +30,19 @@ function ApolloLink() { | ||
} | ||
return links.map(linkUtils_1.toLink).reduce(function (x, y) { return x.concat(y); }); | ||
return links.map(toLink).reduce(function (x, y) { return x.concat(y); }); | ||
}; | ||
ApolloLink.empty = function () { | ||
return new FunctionLink(function (op, forward) { return zen_observable_ts_1.default.of(); }); | ||
return new FunctionLink(function (op, forward) { return Observable.of(); }); | ||
}; | ||
ApolloLink.passthrough = function () { | ||
return new FunctionLink(function (op, forward) { return (forward ? forward(op) : zen_observable_ts_1.default.of()); }); | ||
return new FunctionLink(function (op, forward) { return (forward ? forward(op) : Observable.of()); }); | ||
}; | ||
ApolloLink.split = function (test, left, right) { | ||
if (right === void 0) { right = ApolloLink.passthrough(); } | ||
var leftLink = linkUtils_1.validateLink(linkUtils_1.toLink(left)); | ||
var rightLink = linkUtils_1.validateLink(linkUtils_1.toLink(right)); | ||
if (linkUtils_1.isTerminating(leftLink) && linkUtils_1.isTerminating(rightLink)) { | ||
var leftLink = validateLink(toLink(left)); | ||
var rightLink = validateLink(toLink(right)); | ||
if (isTerminating(leftLink) && isTerminating(rightLink)) { | ||
return new FunctionLink(function (operation) { | ||
return test(operation) | ||
? leftLink.request(operation) || zen_observable_ts_1.default.of() | ||
: rightLink.request(operation) || zen_observable_ts_1.default.of(); | ||
? leftLink.request(operation) || Observable.of() | ||
: rightLink.request(operation) || Observable.of(); | ||
}); | ||
@@ -55,4 +53,4 @@ } | ||
return test(operation) | ||
? leftLink.request(operation, forward) || zen_observable_ts_1.default.of() | ||
: rightLink.request(operation, forward) || zen_observable_ts_1.default.of(); | ||
? leftLink.request(operation, forward) || Observable.of() | ||
: rightLink.request(operation, forward) || Observable.of(); | ||
}); | ||
@@ -67,11 +65,11 @@ } | ||
var _this = this; | ||
linkUtils_1.validateLink(this); | ||
if (linkUtils_1.isTerminating(this)) { | ||
console.warn(new linkUtils_1.LinkError("You are calling concat on a terminating link, which will have no effect", this)); | ||
validateLink(this); | ||
if (isTerminating(this)) { | ||
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect", this)); | ||
return this; | ||
} | ||
var nextLink = linkUtils_1.validateLink(linkUtils_1.toLink(next)); | ||
if (linkUtils_1.isTerminating(nextLink)) { | ||
var nextLink = validateLink(toLink(next)); | ||
if (isTerminating(nextLink)) { | ||
return new FunctionLink(function (operation) { | ||
return _this.request(operation, function (op) { return nextLink.request(op) || zen_observable_ts_1.default.of(); }) || zen_observable_ts_1.default.of(); | ||
return _this.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of(); | ||
}); | ||
@@ -82,4 +80,4 @@ } | ||
return (_this.request(operation, function (op) { | ||
return nextLink.request(op, forward) || zen_observable_ts_1.default.of(); | ||
}) || zen_observable_ts_1.default.of()); | ||
return nextLink.request(op, forward) || Observable.of(); | ||
}) || Observable.of()); | ||
}); | ||
@@ -90,6 +88,6 @@ } | ||
}()); | ||
exports.ApolloLink = ApolloLink; | ||
function execute(link, operation) { | ||
export { ApolloLink }; | ||
export function execute(link, operation) { | ||
var copy = __assign({}, operation); | ||
linkUtils_1.validateOperation(copy); | ||
validateOperation(copy); | ||
if (!copy.context) { | ||
@@ -105,5 +103,4 @@ copy.context = {}; | ||
} | ||
return link.request(transformOperation(copy)) || zen_observable_ts_1.default.of(); | ||
return link.request(transformOperation(copy)) || Observable.of(); | ||
} | ||
exports.execute = execute; | ||
function getName(node) { | ||
@@ -115,3 +112,3 @@ return node && node.name && node.name.kind === 'Name' && node.name.value; | ||
if (typeof operation.query === 'string') { | ||
transformedOperation = __assign({}, operation, { query: graphql_tag_1.default(operation.query) }); | ||
transformedOperation = __assign({}, operation, { query: gql(operation.query) }); | ||
} | ||
@@ -149,3 +146,3 @@ else { | ||
}(ApolloLink)); | ||
exports.FunctionLink = FunctionLink; | ||
export { FunctionLink }; | ||
//# sourceMappingURL=link.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -12,6 +11,5 @@ var extendStatics = Object.setPrototypeOf || | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var link_1 = require("./link"); | ||
function validateLink(link) { | ||
if (link instanceof link_1.ApolloLink && typeof link.request === 'function') { | ||
import { ApolloLink, FunctionLink } from './link'; | ||
export function validateLink(link) { | ||
if (link instanceof ApolloLink && typeof link.request === 'function') { | ||
return link; | ||
@@ -23,4 +21,3 @@ } | ||
} | ||
exports.validateLink = validateLink; | ||
function validateOperation(operation) { | ||
export function validateOperation(operation) { | ||
var OPERATION_FIELDS = ['query', 'operationName', 'variables', 'context']; | ||
@@ -35,3 +32,2 @@ for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) { | ||
} | ||
exports.validateOperation = validateOperation; | ||
var LinkError = (function (_super) { | ||
@@ -46,6 +42,6 @@ __extends(LinkError, _super); | ||
}(Error)); | ||
exports.LinkError = LinkError; | ||
function toLink(link) { | ||
export { LinkError }; | ||
export function toLink(link) { | ||
if (typeof link === 'function') { | ||
return new link_1.FunctionLink(link); | ||
return new FunctionLink(link); | ||
} | ||
@@ -56,8 +52,6 @@ else { | ||
} | ||
exports.toLink = toLink; | ||
function isTerminating(link) { | ||
export function isTerminating(link) { | ||
return link.request.length <= 1; | ||
} | ||
exports.isTerminating = isTerminating; | ||
function makePromise(observable) { | ||
export function makePromise(observable) { | ||
var completed = false; | ||
@@ -79,3 +73,2 @@ return new Promise(function (resolve, reject) { | ||
} | ||
exports.makePromise = makePromise; | ||
//# sourceMappingURL=linkUtils.js.map |
@@ -1,11 +0,5 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mockLink_1 = require("./test-utils/mockLink"); | ||
exports.MockLink = mockLink_1.default; | ||
var setContext_1 = require("./test-utils/setContext"); | ||
exports.SetContextLink = setContext_1.default; | ||
__export(require("./test-utils/testingUtils")); | ||
import MockLink from './test-utils/mockLink'; | ||
import SetContextLink from './test-utils/setContext'; | ||
export * from './test-utils/testingUtils'; | ||
export { MockLink, SetContextLink }; | ||
//# sourceMappingURL=test-utils.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -12,4 +11,3 @@ var extendStatics = Object.setPrototypeOf || | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var link_1 = require("../link"); | ||
import { ApolloLink } from '../link'; | ||
var MockLink = (function (_super) { | ||
@@ -27,4 +25,4 @@ __extends(MockLink, _super); | ||
return MockLink; | ||
}(link_1.ApolloLink)); | ||
exports.default = MockLink; | ||
}(ApolloLink)); | ||
export default MockLink; | ||
//# sourceMappingURL=mockLink.js.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -12,4 +11,3 @@ var extendStatics = Object.setPrototypeOf || | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var link_1 = require("../link"); | ||
import { ApolloLink } from '../link'; | ||
var SetContextLink = (function (_super) { | ||
@@ -31,4 +29,4 @@ __extends(SetContextLink, _super); | ||
return SetContextLink; | ||
}(link_1.ApolloLink)); | ||
exports.default = SetContextLink; | ||
}(ApolloLink)); | ||
export default SetContextLink; | ||
//# sourceMappingURL=setContext.js.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var chai_1 = require("chai"); | ||
var sinon = require("sinon"); | ||
var Links = require("../link"); | ||
import { assert } from 'chai'; | ||
import * as sinon from 'sinon'; | ||
import * as Links from '../link'; | ||
var sampleQuery = "\nquery SampleQuery {\n stub{\n id\n }\n}\n"; | ||
function checkCalls(calls, results) { | ||
chai_1.assert.deepEqual(calls.length, results.length); | ||
calls.map(function (call, i) { return chai_1.assert.deepEqual(call.args[0].data, results[i]); }); | ||
export function checkCalls(calls, results) { | ||
assert.deepEqual(calls.length, results.length); | ||
calls.map(function (call, i) { return assert.deepEqual(call.args[0].data, results[i]); }); | ||
} | ||
exports.checkCalls = checkCalls; | ||
function testLinkResults(params) { | ||
export function testLinkResults(params) { | ||
var link = params.link, context = params.context, variables = params.variables; | ||
@@ -21,3 +18,3 @@ var results = params.results || []; | ||
error: function (error) { | ||
chai_1.assert(error, results.pop()); | ||
assert(error, results.pop()); | ||
checkCalls(spy.getCalls(), results); | ||
@@ -36,3 +33,2 @@ if (done) { | ||
} | ||
exports.testLinkResults = testLinkResults; | ||
//# sourceMappingURL=testingUtils.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "apollo-link-core", | ||
"version": "0.5.0", | ||
"version": "0.5.2", | ||
"description": "Flexible, lightweight transport layer for GraphQL", | ||
@@ -13,4 +13,6 @@ "author": "Evans Hauser <evanshauser@gmail.com>", | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"typings": "./lib/index.d.ts", | ||
"main": "./dist/src/bundle.umd.js", | ||
"module": "./dist/src/index.js", | ||
"jsnext:main": "./dist/src/index.js", | ||
"typings": "./dist/src/index.d.ts", | ||
"repository": { | ||
@@ -25,16 +27,23 @@ "type": "git", | ||
"scripts": { | ||
"pretest": "npm run build", | ||
"pretest": "npm run build-test", | ||
"test": "npm run test-only --", | ||
"posttest": "npm run lint", | ||
"test-only": "mocha --reporter spec --full-trace dist/tests/tests.js", | ||
"test-watch": "mocha --reporter spec --full-trace dist/tests/tests.js --watch", | ||
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js", | ||
"postcoverage": "remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info", | ||
"lint": "tslint --type-check -p tsconfig.json src/*.ts && tslint --type-check -p tsconfig.json tests/*.ts", | ||
"test-watch": | ||
"mocha --reporter spec --full-trace dist/tests/tests.js --watch", | ||
"coverage": | ||
"istanbul cover ./node_modules/mocha/bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js", | ||
"postcoverage": | ||
"remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info", | ||
"lint": | ||
"tslint --type-check -p tsconfig.test.json src/*.ts && tslint --type-check -p tsconfig.test.json tests/*.ts", | ||
"prebuild": "npm run clean:dist", | ||
"build": "tsc -p .", | ||
"postbuild": "cp -R ./dist/src/. ./lib", | ||
"build-test": "tsc -p tsconfig.test.json", | ||
"postbuild": "npm run bundle", | ||
"postbuild-test": "npm run bundle", | ||
"bundle": "rollup -c", | ||
"watch": "tsc -w -p .", | ||
"clean": "npm run clean:dist && npm run clean:coverage", | ||
"clean:dist": "rimraf dist/* && rimraf lib/*", | ||
"clean:dist": "rimraf dist/*", | ||
"clean:coverage": "rimraf coverage/*", | ||
@@ -46,23 +55,24 @@ "prepublishOnly": "npm run clean && npm run build" | ||
"graphql-tag": "^2.4.2", | ||
"zen-observable-ts": "^0.4.0" | ||
"zen-observable-ts": "^0.4.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.0.0", | ||
"@types/chai": "4.0.4", | ||
"@types/chai-as-promised": "0.0.31", | ||
"@types/graphql": "~0.10.2", | ||
"@types/mocha": "^2.2.31", | ||
"@types/sinon": "^2.3.2", | ||
"chai": "^4.0.2", | ||
"chai-as-promised": "^7.0.0", | ||
"fetch-mock": "^5.11.0", | ||
"istanbul": "^0.4.4", | ||
"lodash": "^4.17.4", | ||
"mocha": "^3.2.0", | ||
"remap-istanbul": "^0.9.0", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^2.3.4", | ||
"source-map-support": "^0.4.5", | ||
"tslint": "^5.0.0", | ||
"typescript": "^2.2.1" | ||
"@types/graphql": "0.10.2", | ||
"@types/mocha": "2.2.42", | ||
"@types/sinon": "2.3.3", | ||
"chai": "4.1.1", | ||
"chai-as-promised": "7.1.1", | ||
"fetch-mock": "5.12.2", | ||
"istanbul": "0.4.5", | ||
"lodash": "4.17.4", | ||
"mocha": "3.5.0", | ||
"remap-istanbul": "0.9.5", | ||
"rimraf": "2.6.1", | ||
"rollup": "^0.45.2", | ||
"sinon": "3.2.0", | ||
"source-map-support": "0.4.16", | ||
"tslint": "5.7.0", | ||
"typescript": "2.5.1" | ||
} | ||
} |
{ | ||
"extends": "../../tsconfig", | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es6", "dom"], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"removeComments": true, | ||
"sourceMap": true, | ||
"declaration": true, | ||
"rootDir": ".", | ||
"outDir": "dist", | ||
"noImplicitAny": true, | ||
"noUnusedParameters": false, | ||
"noUnusedLocals": true, | ||
"skipLibCheck": true | ||
"rootDir": "." | ||
}, | ||
"include": ["src/**/*.ts", "tests/**/*.ts"] | ||
"include": ["src/**/*.ts"] | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
92461
18
63
1506
1
Updatedzen-observable-ts@^0.4.2