@openctx/client
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -34,3 +34,3 @@ import type { AnnotationsParams, ItemsParams, ItemsResult, MentionsParams, MentionsResult, MetaParams, MetaResult } from '@openctx/protocol'; | ||
*/ | ||
providers?: ImportedProviderConfiguration[] | Observable<ImportedProviderConfiguration[]> | (() => AsyncGenerator<ImportedProviderConfiguration[]>); | ||
providers?: ObservableInput<ImportedProviderConfiguration[]>; | ||
/** | ||
@@ -126,11 +126,2 @@ * The authentication info for the provider. | ||
/** | ||
* Observe information about the configured providers using an async generator. | ||
* | ||
* The returned generator streams information as it is received from the providers and continues | ||
* passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
metaChanges__asyncGenerator(params: MetaParams, opts?: ProviderMethodOptions, signal?: AbortSignal): AsyncGenerator<EachWithProviderUri<MetaResult[]>>; | ||
/** | ||
* Get the mentions returned by the configured providers. | ||
@@ -152,11 +143,2 @@ * | ||
/** | ||
* Observe OpenCtx mentions from the configured providers using an async generator. | ||
* | ||
* The returned generator streams mentions as they are received from the providers and continues | ||
* passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
mentionsChanges__asyncGenerator(params: MentionsParams, opts?: ProviderMethodOptions, signal?: AbortSignal): AsyncGenerator<EachWithProviderUri<MentionsResult>>; | ||
/** | ||
* Get the items returned by the configured providers. | ||
@@ -178,12 +160,2 @@ * | ||
/** | ||
* Observe OpenCtx items from the configured providers for the given resource using an async | ||
* generator. | ||
* | ||
* The returned generator streams items as they are received from the providers and continues | ||
* passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
itemsChanges__asyncGenerator(params: ItemsParams, opts?: ProviderMethodOptions, signal?: AbortSignal): AsyncGenerator<EachWithProviderUri<ItemsResult>>; | ||
/** | ||
* Get the annotations returned by the configured providers for the given resource. | ||
@@ -205,12 +177,2 @@ * | ||
/** | ||
* Observe OpenCtx annotations from the configured providers for the given resource using an | ||
* async generator. | ||
* | ||
* The returned generator streams annotations as they are received from the providers and | ||
* continues passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
annotationsChanges__asyncGenerator(params: AnnotationsParams, opts?: ProviderMethodOptions, signal?: AbortSignal): AsyncGenerator<EachWithProviderUri<Annotation<R>[]>>; | ||
/** | ||
* Dispose of the client and release all resources. | ||
@@ -217,0 +179,0 @@ */ |
import { LRUCache } from 'lru-cache'; | ||
import { catchError, combineLatest, concatMap, distinctUntilChanged, firstValueFrom, from, isObservable, map, mergeMap, of, shareReplay, take, timer, } from 'rxjs'; | ||
import { catchError, combineLatest, concatMap, distinctUntilChanged, firstValueFrom, from, map, mergeMap, of, shareReplay, take, timer, } from 'rxjs'; | ||
import { observeAnnotations, observeItems, observeMentions, observeMeta, } from '../api.js'; | ||
import { configurationFromUserInput, } from '../configuration.js'; | ||
import { createProviderClient } from '../providerClient/createProviderClient.js'; | ||
import { asyncGeneratorToObservable, observableToAsyncGenerator } from './util.js'; | ||
/** | ||
@@ -28,8 +27,6 @@ * Create a new OpenCtx client. | ||
function providerClientsWithSettings(resource) { | ||
const providers = isObservable(env.providers) | ||
? env.providers | ||
: env.providers instanceof Function | ||
? asyncGeneratorToObservable(env.providers()) | ||
: of(env.providers); | ||
return combineLatest([env.configuration(resource), providers]) | ||
return combineLatest([ | ||
env.configuration(resource), | ||
env.providers ? env.providers : of(undefined), | ||
]) | ||
.pipe(map(([config, providers]) => { | ||
@@ -103,3 +100,2 @@ if (!config.enable) { | ||
metaChanges: (params, opts) => metaChanges(params, { ...opts, emitPartial: true }), | ||
metaChanges__asyncGenerator: (params, opts, signal) => observableToAsyncGenerator(metaChanges(params, { ...opts, emitPartial: true }), signal), | ||
mentions: (params, opts) => firstValueFrom(mentionsChanges(params, { ...opts, emitPartial: false }), { | ||
@@ -109,3 +105,2 @@ defaultValue: [], | ||
mentionsChanges: (params, opts) => mentionsChanges(params, { ...opts, emitPartial: true }), | ||
mentionsChanges__asyncGenerator: (params, opts, signal) => observableToAsyncGenerator(mentionsChanges(params, { ...opts, emitPartial: true }), signal), | ||
items: (params, opts) => firstValueFrom(itemsChanges(params, { ...opts, emitPartial: false }), { | ||
@@ -115,3 +110,2 @@ defaultValue: [], | ||
itemsChanges: (params, opts) => itemsChanges(params, { ...opts, emitPartial: true }), | ||
itemsChanges__asyncGenerator: (params, opts, signal) => observableToAsyncGenerator(itemsChanges(params, { ...opts, emitPartial: true }), signal), | ||
annotations: (params, opts) => firstValueFrom(annotationsChanges(params, { ...opts, emitPartial: false }), { | ||
@@ -121,3 +115,2 @@ defaultValue: [], | ||
annotationsChanges: (params, opts) => annotationsChanges(params, { ...opts, emitPartial: true }), | ||
annotationsChanges__asyncGenerator: (params, opts, signal) => observableToAsyncGenerator(annotationsChanges(params, { ...opts, emitPartial: true }), signal), | ||
dispose() { | ||
@@ -124,0 +117,0 @@ for (const sub of subscriptions) { |
{ | ||
"name": "@openctx/client", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "OpenCtx client library", | ||
@@ -26,4 +26,4 @@ "license": "Apache-2.0", | ||
"@openctx/protocol": "0.0.16", | ||
"@openctx/provider": "0.0.15", | ||
"@openctx/schema": "0.0.12" | ||
"@openctx/schema": "0.0.12", | ||
"@openctx/provider": "0.0.15" | ||
}, | ||
@@ -30,0 +30,0 @@ "devDependencies": { |
@@ -23,3 +23,2 @@ import type { | ||
from, | ||
isObservable, | ||
map, | ||
@@ -50,3 +49,2 @@ mergeMap, | ||
import { type ProviderClient, createProviderClient } from '../providerClient/createProviderClient.js' | ||
import { asyncGeneratorToObservable, observableToAsyncGenerator } from './util.js' | ||
@@ -81,6 +79,3 @@ /** | ||
*/ | ||
providers?: | ||
| ImportedProviderConfiguration[] | ||
| Observable<ImportedProviderConfiguration[]> | ||
| (() => AsyncGenerator<ImportedProviderConfiguration[]>) | ||
providers?: ObservableInput<ImportedProviderConfiguration[]> | ||
@@ -187,16 +182,2 @@ /** | ||
/** | ||
* Observe information about the configured providers using an async generator. | ||
* | ||
* The returned generator streams information as it is received from the providers and continues | ||
* passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
metaChanges__asyncGenerator( | ||
params: MetaParams, | ||
opts?: ProviderMethodOptions, | ||
signal?: AbortSignal, | ||
): AsyncGenerator<EachWithProviderUri<MetaResult[]>> | ||
/** | ||
* Get the mentions returned by the configured providers. | ||
@@ -226,16 +207,2 @@ * | ||
/** | ||
* Observe OpenCtx mentions from the configured providers using an async generator. | ||
* | ||
* The returned generator streams mentions as they are received from the providers and continues | ||
* passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
mentionsChanges__asyncGenerator( | ||
params: MentionsParams, | ||
opts?: ProviderMethodOptions, | ||
signal?: AbortSignal, | ||
): AsyncGenerator<EachWithProviderUri<MentionsResult>> | ||
/** | ||
* Get the items returned by the configured providers. | ||
@@ -262,17 +229,2 @@ * | ||
/** | ||
* Observe OpenCtx items from the configured providers for the given resource using an async | ||
* generator. | ||
* | ||
* The returned generator streams items as they are received from the providers and continues | ||
* passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
itemsChanges__asyncGenerator( | ||
params: ItemsParams, | ||
opts?: ProviderMethodOptions, | ||
signal?: AbortSignal, | ||
): AsyncGenerator<EachWithProviderUri<ItemsResult>> | ||
/** | ||
* Get the annotations returned by the configured providers for the given resource. | ||
@@ -302,17 +254,2 @@ * | ||
/** | ||
* Observe OpenCtx annotations from the configured providers for the given resource using an | ||
* async generator. | ||
* | ||
* The returned generator streams annotations as they are received from the providers and | ||
* continues passing along any updates until {@link signal} is aborted. | ||
* | ||
* @internal | ||
*/ | ||
annotationsChanges__asyncGenerator( | ||
params: AnnotationsParams, | ||
opts?: ProviderMethodOptions, | ||
signal?: AbortSignal, | ||
): AsyncGenerator<EachWithProviderUri<Annotation<R>[]>> | ||
/** | ||
* Dispose of the client and release all resources. | ||
@@ -351,8 +288,6 @@ */ | ||
function providerClientsWithSettings(resource?: string): Observable<ProviderClientWithSettings[]> { | ||
const providers = isObservable(env.providers) | ||
? env.providers | ||
: env.providers instanceof Function | ||
? asyncGeneratorToObservable(env.providers()) | ||
: of(env.providers) | ||
return combineLatest([env.configuration(resource), providers]) | ||
return combineLatest([ | ||
env.configuration(resource), | ||
env.providers ? env.providers : of(undefined), | ||
]) | ||
.pipe( | ||
@@ -485,4 +420,2 @@ map(([config, providers]) => { | ||
metaChanges: (params, opts) => metaChanges(params, { ...opts, emitPartial: true }), | ||
metaChanges__asyncGenerator: (params, opts, signal) => | ||
observableToAsyncGenerator(metaChanges(params, { ...opts, emitPartial: true }), signal), | ||
mentions: (params, opts) => | ||
@@ -493,4 +426,2 @@ firstValueFrom(mentionsChanges(params, { ...opts, emitPartial: false }), { | ||
mentionsChanges: (params, opts) => mentionsChanges(params, { ...opts, emitPartial: true }), | ||
mentionsChanges__asyncGenerator: (params, opts, signal) => | ||
observableToAsyncGenerator(mentionsChanges(params, { ...opts, emitPartial: true }), signal), | ||
items: (params, opts) => | ||
@@ -501,4 +432,2 @@ firstValueFrom(itemsChanges(params, { ...opts, emitPartial: false }), { | ||
itemsChanges: (params, opts) => itemsChanges(params, { ...opts, emitPartial: true }), | ||
itemsChanges__asyncGenerator: (params, opts, signal) => | ||
observableToAsyncGenerator(itemsChanges(params, { ...opts, emitPartial: true }), signal), | ||
annotations: (params, opts) => | ||
@@ -509,7 +438,2 @@ firstValueFrom(annotationsChanges(params, { ...opts, emitPartial: false }), { | ||
annotationsChanges: (params, opts) => annotationsChanges(params, { ...opts, emitPartial: true }), | ||
annotationsChanges__asyncGenerator: (params, opts, signal) => | ||
observableToAsyncGenerator( | ||
annotationsChanges(params, { ...opts, emitPartial: true }), | ||
signal, | ||
), | ||
dispose() { | ||
@@ -516,0 +440,0 @@ for (const sub of subscriptions) { |
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
135677
62
2129