@zendesk/laika
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -274,2 +274,3 @@ "use strict"; | ||
const onSubscribe = ({ operation, observer, enablePassthrough, disablePassthrough, }) => { | ||
var _a; | ||
observerToOperationMap.set(observer, operation); | ||
@@ -324,3 +325,3 @@ passthroughEnablers.add(enablePassthrough); | ||
!keepNonSubscriptionConnectionsOpen) { | ||
observer.complete(); | ||
(_a = observer.complete) === null || _a === void 0 ? void 0 : _a.call(observer); | ||
} | ||
@@ -327,0 +328,0 @@ } |
@@ -33,3 +33,3 @@ "use strict"; | ||
const getEmitValueFn = (result, matcher) => (operation, observer) => { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
if (matcher && !matcher(operation)) { | ||
@@ -43,9 +43,9 @@ return; | ||
if (result.error) { | ||
observer.error(result.error); | ||
(_a = observer.error) === null || _a === void 0 ? void 0 : _a.call(observer, result.error); | ||
} | ||
else if (result.result) { | ||
observer.next(result.result); | ||
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, result.result); | ||
} | ||
else { | ||
observer.error(new Error(`You haven't provided 'result' or 'error' properties to be pushed to the listeners of '${(_a = operation.operationName) !== null && _a !== void 0 ? _a : '(anonymous operation)'}'! Your mock object was: ${JSON.stringify(result, null, 2)}`)); | ||
(_c = observer.error) === null || _c === void 0 ? void 0 : _c.call(observer, new Error(`You haven't provided 'result' or 'error' properties to be pushed to the listeners of '${(_d = operation.operationName) !== null && _d !== void 0 ? _d : '(anonymous operation)'}'! Your mock object was: ${JSON.stringify(result, null, 2)}`)); | ||
} | ||
@@ -52,0 +52,0 @@ }; |
@@ -1,4 +0,9 @@ | ||
/// <reference types="zen-observable" /> | ||
import type { FetchResult, NextLink, Observable, Operation } from '@apollo/client/core'; | ||
import type { FetchResult, NextLink, Observable, ObservableSubscription, Operation } from '@apollo/client/core'; | ||
import type { Laika } from './laika'; | ||
interface SubscriptionObserver<T> { | ||
closed: boolean; | ||
next: (value: T) => void; | ||
error: (errorValue: any) => void; | ||
complete: () => void; | ||
} | ||
/** @ignore */ | ||
@@ -9,5 +14,5 @@ export type { FetchResult, NextLink, Operation } from '@apollo/client/core'; | ||
/** @ignore */ | ||
export declare type FetchResultSubscriptionObserver = ZenObservable.SubscriptionObserver<FetchResult>; | ||
export declare type FetchResultSubscriptionObserver = SubscriptionObserver<FetchResult>; | ||
/** @ignore */ | ||
export declare type Subscription = ZenObservable.Subscription; | ||
export declare type Subscription = ObservableSubscription; | ||
export declare type OnSubscribeCallback = (options: { | ||
@@ -14,0 +19,0 @@ operation: Operation; |
@@ -268,2 +268,3 @@ /* eslint-disable @typescript-eslint/member-ordering,@typescript-eslint/no-shadow,max-classes-per-file */ | ||
const onSubscribe = ({ operation, observer, enablePassthrough, disablePassthrough, }) => { | ||
var _a; | ||
observerToOperationMap.set(observer, operation); | ||
@@ -318,3 +319,3 @@ passthroughEnablers.add(enablePassthrough); | ||
!keepNonSubscriptionConnectionsOpen) { | ||
observer.complete(); | ||
(_a = observer.complete) === null || _a === void 0 ? void 0 : _a.call(observer); | ||
} | ||
@@ -321,0 +322,0 @@ } |
@@ -26,3 +26,3 @@ import isMatch from 'lodash/isMatch'; | ||
export const getEmitValueFn = (result, matcher) => (operation, observer) => { | ||
var _a; | ||
var _a, _b, _c, _d; | ||
if (matcher && !matcher(operation)) { | ||
@@ -36,11 +36,11 @@ return; | ||
if (result.error) { | ||
observer.error(result.error); | ||
(_a = observer.error) === null || _a === void 0 ? void 0 : _a.call(observer, result.error); | ||
} | ||
else if (result.result) { | ||
observer.next(result.result); | ||
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, result.result); | ||
} | ||
else { | ||
observer.error(new Error(`You haven't provided 'result' or 'error' properties to be pushed to the listeners of '${(_a = operation.operationName) !== null && _a !== void 0 ? _a : '(anonymous operation)'}'! Your mock object was: ${JSON.stringify(result, null, 2)}`)); | ||
(_c = observer.error) === null || _c === void 0 ? void 0 : _c.call(observer, new Error(`You haven't provided 'result' or 'error' properties to be pushed to the listeners of '${(_d = operation.operationName) !== null && _d !== void 0 ? _d : '(anonymous operation)'}'! Your mock object was: ${JSON.stringify(result, null, 2)}`)); | ||
} | ||
}; | ||
//# sourceMappingURL=linkUtils.js.map |
@@ -1,4 +0,9 @@ | ||
/// <reference types="zen-observable" /> | ||
import type { FetchResult, NextLink, Observable, Operation } from '@apollo/client/core'; | ||
import type { FetchResult, NextLink, Observable, ObservableSubscription, Operation } from '@apollo/client/core'; | ||
import type { Laika } from './laika'; | ||
interface SubscriptionObserver<T> { | ||
closed: boolean; | ||
next: (value: T) => void; | ||
error: (errorValue: any) => void; | ||
complete: () => void; | ||
} | ||
/** @ignore */ | ||
@@ -9,5 +14,5 @@ export type { FetchResult, NextLink, Operation } from '@apollo/client/core'; | ||
/** @ignore */ | ||
export declare type FetchResultSubscriptionObserver = ZenObservable.SubscriptionObserver<FetchResult>; | ||
export declare type FetchResultSubscriptionObserver = SubscriptionObserver<FetchResult>; | ||
/** @ignore */ | ||
export declare type Subscription = ZenObservable.Subscription; | ||
export declare type Subscription = ObservableSubscription; | ||
export declare type OnSubscribeCallback = (options: { | ||
@@ -14,0 +19,0 @@ operation: Operation; |
{ | ||
"name": "@zendesk/laika", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Test, mock, intercept and modify Apollo Client's operations — in both browser and unit tests!", | ||
@@ -22,2 +22,5 @@ "keywords": [ | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"license": "Apache-2.0", | ||
@@ -65,6 +68,6 @@ "author": "Zendesk <pingu-npm@zendesk.com>", | ||
"dependencies": { | ||
"@apollo/client": "^3.2.5", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@apollo/client": "^3.8.1", | ||
"@niieani/scaffold": "^1.5.0", | ||
@@ -71,0 +74,0 @@ "@types/jest": "^27.5.1", |
@@ -220,3 +220,3 @@ /* eslint-disable @typescript-eslint/member-ordering,@typescript-eslint/no-shadow,max-classes-per-file */ | ||
) { | ||
observer.complete() | ||
observer.complete?.() | ||
} | ||
@@ -223,0 +223,0 @@ } else if ( |
@@ -55,7 +55,7 @@ import isMatch from 'lodash/isMatch' | ||
if (result.error) { | ||
observer.error(result.error) | ||
observer.error?.(result.error) | ||
} else if (result.result) { | ||
observer.next(result.result) | ||
observer.next?.(result.result) | ||
} else { | ||
observer.error( | ||
observer.error?.( | ||
new Error( | ||
@@ -62,0 +62,0 @@ `You haven't provided 'result' or 'error' properties to be pushed to the listeners of '${ |
@@ -6,2 +6,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
Observable, | ||
ObservableSubscription, | ||
Operation, | ||
@@ -11,2 +12,9 @@ } from '@apollo/client/core' | ||
interface SubscriptionObserver<T> { | ||
closed: boolean | ||
next: (value: T) => void | ||
error: (errorValue: any) => void | ||
complete: () => void | ||
} | ||
/** @ignore */ | ||
@@ -17,6 +25,5 @@ export type { FetchResult, NextLink, Operation } from '@apollo/client/core' | ||
/** @ignore */ | ||
export type FetchResultSubscriptionObserver = | ||
ZenObservable.SubscriptionObserver<FetchResult> | ||
export type FetchResultSubscriptionObserver = SubscriptionObserver<FetchResult> | ||
/** @ignore */ | ||
export type Subscription = ZenObservable.Subscription | ||
export type Subscription = ObservableSubscription | ||
@@ -23,0 +30,0 @@ export type OnSubscribeCallback = (options: { |
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
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
400876
2
6469
7
1
- Removed@apollo/client@^3.2.5