ozone-typescript-client
Advanced tools
Comparing version 6.1.7 to 6.1.8
import { FromOzone, Item, Query, SearchRequest, UUID, Patch, AggregationItem } from 'ozone-type'; | ||
import { TypedDocumentNode } from '@apollo/client/core'; | ||
interface ISearchResults<T> { | ||
@@ -22,3 +21,2 @@ id?: number; | ||
search(searchRequest: SearchRequest): Promise<SearchResults<FromOzone<T>>>; | ||
graphQLSearch<TData, TVariables>(query: TypedDocumentNode<TData, TVariables>, variables?: TVariables): Promise<TData>; | ||
searchIds(searchRequest: SearchRequest): Promise<SearchIdsResults>; | ||
@@ -25,0 +23,0 @@ count(query?: Query): Promise<number>; |
import { FromOzone, Item, Query, SearchRequest, UUID, Patch } from 'ozone-type'; | ||
import { ItemClient, SearchResults, SearchIterator, SearchIdsResults } from './itemClient'; | ||
import { OzoneClient } from '../ozoneClient/ozoneClient'; | ||
import { ApolloClient, NormalizedCacheObject, OperationVariables, TypedDocumentNode } from '@apollo/client/core'; | ||
export declare class ItemClientImpl<T extends Item> implements ItemClient<T> { | ||
@@ -10,3 +9,2 @@ private client; | ||
constructor(client: OzoneClient, baseUrl: string, typeIdentifier: string); | ||
graphQLClient: ApolloClient<NormalizedCacheObject>; | ||
count(query?: Query): Promise<number>; | ||
@@ -21,3 +19,2 @@ deleteById(id: UUID, permanent?: boolean): Promise<UUID | null>; | ||
search(searchRequest: SearchRequest): Promise<SearchResults<FromOzone<T>>>; | ||
graphQLSearch<TData = any, TVariables = OperationVariables>(query: TypedDocumentNode<TData, TVariables>, variables?: TVariables): Promise<TData>; | ||
searchIds(searchRequest: SearchRequest): Promise<SearchIdsResults>; | ||
@@ -28,3 +25,2 @@ searchGenerator(searchRequest: SearchRequest): SearchIterator<T>; | ||
queryDelete(searchQuery: Query, permanent?: boolean): Promise<UUID[]>; | ||
private createGraphQLClient; | ||
} |
@@ -13,3 +13,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { returnNullOn404 } from '../utility/utility'; | ||
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client/core'; | ||
export class ItemClientImpl { | ||
@@ -20,3 +19,2 @@ constructor(client, baseUrl, typeIdentifier) { | ||
this.typeIdentifier = typeIdentifier; | ||
this.graphQLClient = this.createGraphQLClient(); | ||
} | ||
@@ -93,7 +91,2 @@ count(query) { | ||
} | ||
graphQLSearch(query, variables) { | ||
return this.graphQLClient.query({ | ||
query, variables | ||
}).then(result => result.data); | ||
} | ||
searchIds(searchRequest) { | ||
@@ -141,22 +134,2 @@ const request = new Request(`${this.baseUrl}/rest/v3/items/${this.typeIdentifier}/searchIds`) | ||
} | ||
createGraphQLClient() { | ||
const link = new HttpLink({ | ||
fetch: (uri, options) => { | ||
const req = new Request(`${this.baseUrl}/rest/v3/graphql`, { | ||
method: options === null || options === void 0 ? void 0 : options.method, | ||
body: options === null || options === void 0 ? void 0 : options.body | ||
}); | ||
return this.client.call(req).then(it => { | ||
return { | ||
text: () => Promise.resolve(JSON.stringify(it)) | ||
}; | ||
}); | ||
} | ||
}); | ||
return new ApolloClient({ | ||
uri: `${this.baseUrl}/rest/v3/graphql`, | ||
cache: new InMemoryCache(), | ||
link | ||
}); | ||
} | ||
} | ||
@@ -163,0 +136,0 @@ class SearchIteratorImpl { |
@@ -14,2 +14,3 @@ import type { Logger } from 'generic-logger-typings'; | ||
import { FileTypeClient } from '../filetypeClient/filetypeClient'; | ||
import { TypedDocumentNode } from '@apollo/client/core'; | ||
export interface AuthInfo { | ||
@@ -93,2 +94,3 @@ principalClass: string; | ||
setLogger(logger: Logger): void; | ||
graphQLSearch<TData, TVariables>(query: TypedDocumentNode<TData, TVariables>, variables?: TVariables): Promise<TData>; | ||
} |
import type { Logger } from 'generic-logger-typings'; | ||
import { StateMachineImpl, ListenerRegistration } from 'typescript-state-machine'; | ||
import { Response, Request, InstalledFilter, Filter } from 'typescript-http-client'; | ||
import { Response as HttpClientResponse, Request, InstalledFilter, Filter } from 'typescript-http-client'; | ||
import { DeviceMessage, Item } from 'ozone-type'; | ||
@@ -15,2 +15,3 @@ import { ClientState } from './clientState'; | ||
import { FileTypeClient } from '../filetypeClient/filetypeClient'; | ||
import { OperationVariables, TypedDocumentNode } from '@apollo/client/core'; | ||
export interface OzoneClientInternals extends OzoneClient { | ||
@@ -35,3 +36,3 @@ setState(newState: ClientState): void; | ||
get authInfo(): AuthInfo | undefined; | ||
get lastFailedLogin(): Response<AuthInfo> | undefined; | ||
get lastFailedLogin(): HttpClientResponse<AuthInfo> | undefined; | ||
get isAuthenticated(): boolean; | ||
@@ -48,3 +49,3 @@ get isConnected(): boolean; | ||
call<T>(call: Request): Promise<T>; | ||
callForResponse<T>(call: Request): Promise<Response<T>>; | ||
callForResponse<T>(call: Request): Promise<HttpClientResponse<T>>; | ||
private onWsMessage; | ||
@@ -102,4 +103,7 @@ private acknowledgeMessage; | ||
fileTypeClient(): FileTypeClient; | ||
private _graphQLClient; | ||
insertSessionIdInURL(url: string): string; | ||
addCustomFilter(filter: Filter<any, any>, name: string): void; | ||
graphQLSearch<TData = any, TVariables = OperationVariables>(query: TypedDocumentNode<TData, TVariables>, variables?: TVariables): Promise<TData>; | ||
private createGraphQLClient; | ||
} |
@@ -20,3 +20,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
import { AssumeStateIsNot, AssumeStateIs, StateMachineImpl } from 'typescript-state-machine'; | ||
import { Response, Request, newHttpClient, FilterCollection, setLogger } from 'typescript-http-client'; | ||
import { Response as HttpClientResponse, Request, newHttpClient, FilterCollection, setLogger } from 'typescript-http-client'; | ||
import SockJS from 'sockjs-client'; | ||
@@ -33,2 +33,3 @@ import { states, validTransitions } from './clientState'; | ||
import { FiletypeClientImpl } from '../filetypeClient/filetypeClientImpl'; | ||
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client/core'; | ||
const MAX_REAUTH_DELAY = 30000; | ||
@@ -82,2 +83,3 @@ const INITIAL_REAUTH_DELAY = 1000; | ||
this._filetypeClient = new FiletypeClientImpl(this, this._config.ozoneURL); | ||
this._graphQLClient = this.createGraphQLClient(this, this._config.ozoneURL); | ||
} | ||
@@ -232,3 +234,3 @@ setLogger(logger) { | ||
catch (e) { | ||
if (e instanceof Response) { | ||
if (e instanceof HttpClientResponse) { | ||
(_d = this.log) === null || _d === void 0 ? void 0 : _d.debug(`Authentication error : code ${e.status}`); | ||
@@ -270,3 +272,3 @@ this._lastFailedLogin = e; | ||
catch (e) { | ||
if (e instanceof Response) { | ||
if (e instanceof HttpClientResponse) { | ||
(_b = this.log) === null || _b === void 0 ? void 0 : _b.debug(`Logout error : code ${e.status}`); | ||
@@ -632,2 +634,27 @@ this._lastFailedLogin = e; | ||
} | ||
graphQLSearch(query, variables) { | ||
return this._graphQLClient.query({ | ||
query, variables | ||
}).then(result => result.data); | ||
} | ||
createGraphQLClient(client, baseUrl) { | ||
const link = new HttpLink({ | ||
fetch: (uri, options) => { | ||
const req = new Request(`${baseUrl}/rest/v3/graphql`, { | ||
method: options === null || options === void 0 ? void 0 : options.method, | ||
body: options === null || options === void 0 ? void 0 : options.body | ||
}); | ||
return client.call(req).then(it => { | ||
return { | ||
text: () => Promise.resolve(JSON.stringify(it)) | ||
}; | ||
}); | ||
} | ||
}); | ||
return new ApolloClient({ | ||
uri: `${baseUrl}/rest/v3/graphql`, | ||
cache: new InMemoryCache(), | ||
link | ||
}); | ||
} | ||
} | ||
@@ -634,0 +661,0 @@ __decorate([ |
{ | ||
"name": "ozone-typescript-client", | ||
"version": "6.1.7", | ||
"version": "6.1.8", | ||
"description": "", | ||
@@ -40,3 +40,3 @@ "main": "dist/src/index.js", | ||
}, | ||
"gitHead": "b8447395a9e9d7f0dc7474fba8658bfdad6c78a9" | ||
"gitHead": "6c08a905487c3630b5ecd7f0e213951b67e47a5c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
477565