Skip to main content
Version: 0.17

Class: JSONAPISource<QO, TO, QB, TB>

Source for accessing a JSON API compliant RESTful API with a network fetch request.

If a single transform or query requires more than one fetch request, requests will be performed sequentially and resolved together. From the perspective of Orbit, these operations will all succeed or fail together. The maxRequestsPerTransform and maxRequestsPerQuery settings allow limits to be set on this behavior. These settings should be set to 1 if your client/server configuration is unable to resolve partially successful transforms / queries.

Type parameters

NameType
QOextends JSONAPIQueryOptions = JSONAPIQueryOptions
TOextends JSONAPITransformOptions = JSONAPITransformOptions
QBRecordQueryBuilder
TBRecordTransformBuilder

Hierarchy

Implements

Constructors

constructor

new JSONAPISource<QO, TO, QB, TB>(settings)

Type parameters

NameType
QOextends JSONAPIQueryOptions = JSONAPIQueryOptions
TOextends JSONAPITransformOptions = JSONAPITransformOptions
QBRecordQueryBuilder<string, RecordIdentity>
TBRecordTransformBuilder<string, RecordIdentity, UninitializedRecord>

Parameters

NameType
settingsJSONAPISourceSettings<QO, TO, QB, TB>

Inherited from

RecordSource<QO, TO, QB, TB>.constructor

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:161

Properties

requestProcessor

requestProcessor: JSONAPIRequestProcessor

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:159

Accessors

activated

get activated(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.activated

Defined in

packages/@orbit/data/dist/modules/source.d.ts:54


bucket

get bucket(): undefined | Bucket<unknown>

Returns

undefined | Bucket<unknown>

Inherited from

RecordSource.bucket

Defined in

packages/@orbit/data/dist/modules/source.d.ts:37


defaultQueryOptions

get defaultQueryOptions(): undefined | DefaultRequestOptions<QueryOptions>

Returns

undefined | DefaultRequestOptions<QueryOptions>

Inherited from

RecordSource.defaultQueryOptions

Defined in

packages/@orbit/data/dist/modules/source.d.ts:43

set defaultQueryOptions(options): void

Parameters

NameType
optionsundefined | DefaultRequestOptions<QueryOptions>

Returns

void

Inherited from

RecordSource.defaultQueryOptions

Defined in

packages/@orbit/data/dist/modules/source.d.ts:44


defaultTransformOptions

get defaultTransformOptions(): undefined | DefaultRequestOptions<TransformOptions>

Returns

undefined | DefaultRequestOptions<TransformOptions>

Inherited from

RecordSource.defaultTransformOptions

Defined in

packages/@orbit/data/dist/modules/source.d.ts:45

set defaultTransformOptions(options): void

Parameters

NameType
optionsundefined | DefaultRequestOptions<TransformOptions>

Returns

void

Inherited from

RecordSource.defaultTransformOptions

Defined in

packages/@orbit/data/dist/modules/source.d.ts:46


keyMap

get keyMap(): undefined | RecordKeyMap

Returns

undefined | RecordKeyMap

Inherited from

RecordSource.keyMap

Defined in

packages/@orbit/records/dist/modules/record-source.d.ts:57


maxRequestsPerQuery

get maxRequestsPerQuery(): undefined | number

Deprecated in favor of defaultQueryOptions.maxRequests

deprecated since v0.17, remove in v0.18

Returns

undefined | number

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:263

set maxRequestsPerQuery(val): void

Deprecated in favor of defaultQueryOptions.maxRequests

deprecated since v0.17, remove in v0.18

Parameters

NameType
valundefined | number

Returns

void

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:275


maxRequestsPerTransform

get maxRequestsPerTransform(): undefined | number

Deprecated in favor of defaultTransformOptions.maxRequests

deprecated since v0.17, remove in v0.18

Returns

undefined | number

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:236

set maxRequestsPerTransform(val): void

Deprecated in favor of defaultTransformOptions.maxRequests

deprecated since v0.17, remove in v0.18

Parameters

NameType
valundefined | number

Returns

void

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:248


name

get name(): undefined | string

Returns

undefined | string

Inherited from

RecordSource.name

Defined in

packages/@orbit/data/dist/modules/source.d.ts:36


queryBuilder

get queryBuilder(): QB

Returns

QB

Inherited from

RecordSource.queryBuilder

Defined in

packages/@orbit/records/dist/modules/record-source.d.ts:59


requestQueue

get requestQueue(): TaskQueue<string, unknown, unknown, unknown>

Returns

TaskQueue<string, unknown, unknown, unknown>

Inherited from

RecordSource.requestQueue

Defined in

packages/@orbit/data/dist/modules/source.d.ts:39


schema

get schema(): RecordSchema

Returns

RecordSchema

Inherited from

RecordSource.schema

Defined in

packages/@orbit/records/dist/modules/record-source.d.ts:56


syncQueue

get syncQueue(): TaskQueue<string, unknown, unknown, unknown>

Returns

TaskQueue<string, unknown, unknown, unknown>

Inherited from

RecordSource.syncQueue

Defined in

packages/@orbit/data/dist/modules/source.d.ts:40


transformBuilder

get transformBuilder(): TB

Returns

TB

Inherited from

RecordSource.transformBuilder

Defined in

packages/@orbit/records/dist/modules/record-source.d.ts:60


transformLog

get transformLog(): Log

Returns

Log

Inherited from

RecordSource.transformLog

Defined in

packages/@orbit/data/dist/modules/source.d.ts:38


validatorFor

get validatorFor(): undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Returns

undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Inherited from

RecordSource.validatorFor

Defined in

packages/@orbit/records/dist/modules/record-source.d.ts:58

Methods

_pull

_pull(query): Promise<FullResponse<undefined, JSONAPIResponse[], RecordOperation>>

Parameters

NameType
queryRecordQuery

Returns

Promise<FullResponse<undefined, JSONAPIResponse[], RecordOperation>>

Inherited from

RecordPullable._pull

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:319


_push

_push(transform): Promise<FullResponse<undefined, JSONAPIResponse[], RecordOperation>>

Parameters

NameType
transformRecordTransform

Returns

Promise<FullResponse<undefined, JSONAPIResponse[], RecordOperation>>

Inherited from

RecordPushable._push

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:289


_query

_query(query): Promise<FullResponse<RecordQueryResult<InitializedRecord>, JSONAPIResponse[], RecordOperation>>

Parameters

NameType
queryRecordQuery

Returns

Promise<FullResponse<RecordQueryResult<InitializedRecord>, JSONAPIResponse[], RecordOperation>>

Inherited from

RecordQueryable._query

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:345


_update

_update(transform): Promise<FullResponse<RecordTransformResult<InitializedRecord>, JSONAPIResponse[], RecordOperation>>

Parameters

NameType
transformRecordTransform

Returns

Promise<FullResponse<RecordTransformResult<InitializedRecord>, JSONAPIResponse[], RecordOperation>>

Inherited from

RecordUpdatable._update

Defined in

packages/@orbit/jsonapi/src/jsonapi-source.ts:376


activate

activate(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.activate

Defined in

packages/@orbit/data/dist/modules/source.d.ts:55


deactivate

deactivate(): Promise<void>

Returns

Promise<void>

Inherited from

RecordSource.deactivate

Defined in

packages/@orbit/data/dist/modules/source.d.ts:56


emit

emit(event, ...args): void

Parameters

NameType
eventEvent
...argsunknown[]

Returns

void

Inherited from

RecordSource.emit

Defined in

packages/@orbit/core/dist/modules/evented.d.ts:23


getQueryOptions

getQueryOptions(query, expression?): undefined | QO

Parameters

NameType
queryQuery<QueryExpression>
expression?QueryExpression

Returns

undefined | QO

Inherited from

RecordSource.getQueryOptions

Defined in

packages/@orbit/data/dist/modules/source.d.ts:47


getTransformOptions

getTransformOptions(transform, operation?): undefined | TO

Parameters

NameType
transformTransform<Operation>
operation?Operation

Returns

undefined | TO

Inherited from

RecordSource.getTransformOptions

Defined in

packages/@orbit/data/dist/modules/source.d.ts:48


listeners

listeners(event): Listener[]

Parameters

NameType
eventEvent

Returns

Listener[]

Inherited from

RecordSource.listeners

Defined in

packages/@orbit/core/dist/modules/evented.d.ts:24


off

off(event, listener?): void

Parameters

NameType
eventEvent
listener?Listener

Returns

void

Inherited from

RecordSource.off

Defined in

packages/@orbit/core/dist/modules/evented.d.ts:21


on

on(event, listener): () => void

Parameters

NameType
eventEvent
listenerListener

Returns

fn

▸ (): void

Returns

void

Inherited from

RecordSource.on

Defined in

packages/@orbit/core/dist/modules/evented.d.ts:20


one

one(event, listener): () => void

Parameters

NameType
eventEvent
listenerListener

Returns

fn

▸ (): void

Returns

void

Inherited from

RecordSource.one

Defined in

packages/@orbit/core/dist/modules/evented.d.ts:22


perform

perform(task): Promise<unknown>

Parameters

NameType
taskTask<string, unknown, unknown>

Returns

Promise<unknown>

Inherited from

RecordSource.perform

Defined in

packages/@orbit/data/dist/modules/source.d.ts:49


pull

pull<RequestOperation>(queryOrExpressions, options?, id?): Promise<Transform<RequestOperation>[]>

The pull method accepts a query or expression(s) and returns a promise that resolves to an array of Transform instances that represent the changeset that resulted from applying the query. In other words, a pull request retrieves the results of a query in Transform form.

Type parameters

NameType
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, RecordQueryBuilder<string, RecordIdentity>>
options?DefaultRequestOptions<RequestOptions>
id?string

Returns

Promise<Transform<RequestOperation>[]>

Inherited from

RecordPullable.pull

Defined in

packages/@orbit/data/dist/modules/source-interfaces/pullable.d.ts:25

pull<RequestData, RequestDetails, RequestOperation>(queryOrExpressions, options?, id?): Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>
RequestDetailsextends JSONAPIResponse[] = JSONAPIResponse[]
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, RecordQueryBuilder<string, RecordIdentity>>
options?FullRequestOptions<RequestOptions>
id?string

Returns

Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Inherited from

RecordPullable.pull

Defined in

packages/@orbit/data/dist/modules/source-interfaces/pullable.d.ts:26


push

push<RequestOperation>(transformOrOperations, options?, id?): Promise<Transform<RequestOperation>[]>

The push method accepts a Transform instance as an argument and returns a promise that resolves to an array of Transform instances that are applied as a result. In other words, push captures the direct results and side effects of applying a Transform to a source.

Type parameters

NameType
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, RecordTransformBuilder<string, RecordIdentity, UninitializedRecord>>
options?DefaultRequestOptions<RequestOptions>
id?string

Returns

Promise<Transform<RequestOperation>[]>

Inherited from

RecordPushable.push

Defined in

packages/@orbit/data/dist/modules/source-interfaces/pushable.d.ts:23

push<RequestData, RequestDetails, RequestOperation>(transformOrOperations, options, id?): Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>
RequestDetailsextends JSONAPIResponse[] = JSONAPIResponse[]
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, RecordTransformBuilder<string, RecordIdentity, UninitializedRecord>>
optionsFullRequestOptions<RequestOptions>
id?string

Returns

Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Inherited from

RecordPushable.push

Defined in

packages/@orbit/data/dist/modules/source-interfaces/pushable.d.ts:24


query

query<RequestData>(queryOrExpressions, options?, id?): Promise<RequestData>

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
options?DefaultRequestOptions<QO>
id?string

Returns

Promise<RequestData>

Inherited from

RecordQueryable.query

Defined in

packages/@orbit/data/dist/modules/queryable.d.ts:7

query<RequestData, RequestDetails, RequestOperation>(queryOrExpressions, options, id?): Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>
RequestDetailsextends JSONAPIResponse[] = JSONAPIResponse[]
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
optionsFullRequestOptions<QO>
id?string

Returns

Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Inherited from

RecordQueryable.query

Defined in

packages/@orbit/data/dist/modules/queryable.d.ts:8


transformed

transformed(transforms): Promise<void>

Notifies listeners that this source has been transformed by emitting the transform event.

Resolves when any promises returned to event listeners are resolved.

Also, adds an entry to the Source's transformLog for each transform.

Parameters

NameType
transformsTransform<Operation>[]

Returns

Promise<void>

Inherited from

RecordSource.transformed

Defined in

packages/@orbit/data/dist/modules/source.d.ts:65


update

update<RequestData>(transformOrOperations, options?, id?): Promise<RequestData>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
options?DefaultRequestOptions<TO>
id?string

Returns

Promise<RequestData>

Inherited from

RecordUpdatable.update

Defined in

packages/@orbit/data/dist/modules/updatable.d.ts:6

update<RequestData, RequestDetails, RequestOperation>(transformOrOperations, options, id?): Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>
RequestDetailsextends JSONAPIResponse[] = JSONAPIResponse[]
RequestOperationextends RecordOperation = RecordOperation

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
optionsFullRequestOptions<TO>
id?string

Returns

Promise<FullResponse<RequestData, RequestDetails, RequestOperation>>

Inherited from

RecordUpdatable.update

Defined in

packages/@orbit/data/dist/modules/updatable.d.ts:7


upgrade

upgrade(): Promise<void>

Upgrade source as part of a schema upgrade.

Returns

Promise<void>

Inherited from

RecordSource.upgrade

Defined in

packages/@orbit/records/dist/modules/record-source.d.ts:64