@ember-data-types/active-record 5.6.0-alpha.1 → 5.6.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/package.json +1 -1
- package/unstable-preview-types/index.d.ts +1 -5
- package/unstable-preview-types/request.d.ts +66 -64
- package/unstable-preview-types/request.d.ts.map +1 -1
- package/unstable-preview-types/-private/builders/-utils.d.ts +0 -7
- package/unstable-preview-types/-private/builders/-utils.d.ts.map +0 -1
- package/unstable-preview-types/-private/builders/find-record.d.ts +0 -71
- package/unstable-preview-types/-private/builders/find-record.d.ts.map +0 -1
- package/unstable-preview-types/-private/builders/query.d.ts +0 -59
- package/unstable-preview-types/-private/builders/query.d.ts.map +0 -1
- package/unstable-preview-types/-private/builders/save-record.d.ts +0 -153
- package/unstable-preview-types/-private/builders/save-record.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -68,11 +68,3 @@ URLs are stable. The same query will produce the same URL every time, even if th
|
|
|
68
68
|
the query or values in an array changes.
|
|
69
69
|
|
|
70
70
|
URLs follow the most common ActiveRecord format (underscored pluralized resource types).
|
|
71
|
-
|
|
72
|
-
### Available Builders
|
|
73
|
-
|
|
74
|
-
- [createRecord]()
|
|
75
|
-
- [deleteRecord]()
|
|
76
|
-
- [findRecord]()
|
|
77
|
-
- [query]()
|
|
78
|
-
- [updateRecord]()
|
package/package.json
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
/// <reference path="./request.d.ts" />
|
|
2
|
-
/// <reference path="./-private/builders/query.d.ts" />
|
|
3
|
-
/// <reference path="./-private/builders/save-record.d.ts" />
|
|
4
|
-
/// <reference path="./-private/builders/-utils.d.ts" />
|
|
5
|
-
/// <reference path="./-private/builders/find-record.d.ts" />
|
|
1
|
+
/// <reference path="./request.d.ts" />
|
|
@@ -1,69 +1,71 @@
|
|
|
1
1
|
declare module '@ember-data/active-record/request' {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
*This package provides utilities for working with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html#convention-over-configuration-in-active-record) APIs.
|
|
6
|
+
*
|
|
7
|
+
* ## Installation
|
|
8
|
+
*
|
|
9
|
+
* Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/)
|
|
10
|
+
*
|
|
11
|
+
* ::: code-group
|
|
12
|
+
*
|
|
13
|
+
* ```sh [pnpm]
|
|
14
|
+
* pnpm add -E @ember-data/active-record
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ```sh [npm]
|
|
18
|
+
* npm add -E @ember-data/active-record
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ```sh [yarn]
|
|
22
|
+
* yarn add -E @ember-data/active-record
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ```sh [bun]
|
|
26
|
+
* bun add --exact @ember-data/active-record
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* :::
|
|
30
|
+
*
|
|
31
|
+
* ## Usage
|
|
32
|
+
*
|
|
33
|
+
* Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
|
|
34
|
+
* They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details.
|
|
35
|
+
*
|
|
36
|
+
* For instance, to construct a request that would fetch a resource from your API:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { findRecord } from '@ember-data/active-record/request';
|
|
40
|
+
*
|
|
41
|
+
* const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* This would produce the following request object:
|
|
45
|
+
*
|
|
46
|
+
* ```js
|
|
47
|
+
* {
|
|
48
|
+
* url: 'https://api.example.com/v1/ember_developers/1?include=friends,pets',
|
|
49
|
+
* method: 'GET',
|
|
50
|
+
* headers: <Headers>, // 'Accept': 'application/json;charset=utf-8'
|
|
51
|
+
* op: 'findRecord';
|
|
52
|
+
* records: [{ type: 'ember-developer', id: '1' }]
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* Request builder output may be used with either `requestManager.request` or `store.request`.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const data = await store.request(options);
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* URLs are stable. The same query will produce the same URL every time, even if the order of keys in
|
|
63
|
+
* the query or values in an array changes.
|
|
64
|
+
*
|
|
65
|
+
* URLs follow the most common ActiveRecord format (underscored pluralized resource types).
|
|
66
|
+
*
|
|
67
|
+
* @module
|
|
64
68
|
*/
|
|
65
|
-
export { findRecord } from '@
|
|
66
|
-
export { query } from '@ember-data/active-record/-private/builders/query';
|
|
67
|
-
export { deleteRecord, createRecord, updateRecord } from '@ember-data/active-record/-private/builders/save-record';
|
|
69
|
+
export { findRecord, query, deleteRecord, createRecord, updateRecord } from '@warp-drive/utilities/active-record';
|
|
68
70
|
}
|
|
69
71
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
declare module '@ember-data/active-record/-private/builders/-utils' {
|
|
2
|
-
import type { UrlOptions } from '@ember-data/request-utils';
|
|
3
|
-
import type { CacheOptions, ConstrainedRequestOptions } from '@warp-drive/core-types/request';
|
|
4
|
-
export function copyForwardUrlOptions(urlOptions: UrlOptions, options: ConstrainedRequestOptions): void;
|
|
5
|
-
export function extractCacheOptions(options: ConstrainedRequestOptions): CacheOptions;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"-utils.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE9F,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,yBAAyB,GAAG,IAAI,CAUtG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CASpF"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
declare module '@ember-data/active-record/-private/builders/find-record' {
|
|
2
|
-
import type { TypeFromInstance } from '@warp-drive/core-types/record';
|
|
3
|
-
import type { FindRecordOptions, FindRecordRequestOptions, RemotelyAccessibleIdentifier } from '@warp-drive/core-types/request';
|
|
4
|
-
import type { SingleResourceDataDocument } from '@warp-drive/core-types/spec/document';
|
|
5
|
-
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, 'data'> & {
|
|
6
|
-
data: T;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Builds request options to fetch a single resource by a known id or identifier
|
|
10
|
-
* configured for the url and header expectations of most ActiveRecord APIs.
|
|
11
|
-
*
|
|
12
|
-
* **Basic Usage**
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { findRecord } from '@ember-data/active-record/request';
|
|
16
|
-
*
|
|
17
|
-
* const data = await store.request(findRecord('person', '1'));
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* **With Options**
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { findRecord } from '@ember-data/active-record/request';
|
|
24
|
-
*
|
|
25
|
-
* const options = findRecord('person', '1', { include: ['pets', 'friends'] });
|
|
26
|
-
* const data = await store.request(options);
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* **With an Identifier**
|
|
30
|
-
*
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { findRecord } from '@ember-data/active-record/request';
|
|
33
|
-
*
|
|
34
|
-
* const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
|
|
35
|
-
* const data = await store.request(options);
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
39
|
-
*
|
|
40
|
-
* The following options are supported:
|
|
41
|
-
*
|
|
42
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
43
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
44
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
|
|
45
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
46
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
47
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
48
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
49
|
-
* defaulting to `false` if none is configured.
|
|
50
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
51
|
-
*
|
|
52
|
-
* ```ts
|
|
53
|
-
* import { findRecord } from '@ember-data/active-record/request';
|
|
54
|
-
*
|
|
55
|
-
* const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
|
|
56
|
-
* const data = await store.request(options);
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @method findRecord
|
|
60
|
-
* @public
|
|
61
|
-
* @static
|
|
62
|
-
* @for @ember-data/active-record/request
|
|
63
|
-
* @param identifier
|
|
64
|
-
* @param options
|
|
65
|
-
*/
|
|
66
|
-
export function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<T, FindRecordResultDocument<T>>;
|
|
67
|
-
export function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
68
|
-
export function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<T, FindRecordResultDocument<T>>;
|
|
69
|
-
export function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=find-record.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/find-record.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIvF,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC;AAEpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,UAAU,EAAE,4BAA4B,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAC7D,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,wBAAwB,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,wBAAgB,UAAU,CACxB,UAAU,EAAE,4BAA4B,EACxC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,wBAAwB,CAAC;AAC5B,wBAAgB,UAAU,CAAC,CAAC,EAC1B,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACzB,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,wBAAwB,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
declare module '@ember-data/active-record/-private/builders/query' {
|
|
2
|
-
import type { QueryParamsSource } from '@warp-drive/core-types/params';
|
|
3
|
-
import type { TypeFromInstance } from '@warp-drive/core-types/record';
|
|
4
|
-
import type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive/core-types/request';
|
|
5
|
-
import type { CollectionResourceDataDocument } from '@warp-drive/core-types/spec/document';
|
|
6
|
-
/**
|
|
7
|
-
* Builds request options to query for resources, usually by a primary
|
|
8
|
-
* type, configured for the url and header expectations of most ActiveRecord APIs.
|
|
9
|
-
*
|
|
10
|
-
* **Basic Usage**
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { query } from '@ember-data/active-record/request';
|
|
14
|
-
*
|
|
15
|
-
* const data = await store.request(query('person'));
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* **With Query Params**
|
|
19
|
-
*
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { query } from '@ember-data/active-record/request';
|
|
22
|
-
*
|
|
23
|
-
* const options = query('person', { include: ['pets', 'friends'] });
|
|
24
|
-
* const data = await store.request(options);
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
28
|
-
*
|
|
29
|
-
* The following options are supported:
|
|
30
|
-
*
|
|
31
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
32
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
33
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
|
|
34
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
35
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
36
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
37
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
38
|
-
* defaulting to `false` if none is configured.
|
|
39
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { query } from '@ember-data/active-record/request';
|
|
43
|
-
*
|
|
44
|
-
* const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
|
|
45
|
-
* const data = await store.request(options);
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @method query
|
|
49
|
-
* @public
|
|
50
|
-
* @static
|
|
51
|
-
* @for @ember-data/active-record/request
|
|
52
|
-
* @param identifier
|
|
53
|
-
* @param query
|
|
54
|
-
* @param options
|
|
55
|
-
*/
|
|
56
|
-
export function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<T, CollectionResourceDataDocument<T>>;
|
|
57
|
-
export function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/query.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAI3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,KAAK,CAAC,CAAC,EACrB,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACzB,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC,CAAC,EAAE,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
declare module '@ember-data/active-record/-private/builders/save-record' {
|
|
2
|
-
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from '@warp-drive/core-types/request';
|
|
3
|
-
/**
|
|
4
|
-
* Builds request options to delete record for resources,
|
|
5
|
-
* configured for the url, method and header expectations of ActiveRecord APIs.
|
|
6
|
-
*
|
|
7
|
-
* **Basic Usage**
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { deleteRecord } from '@ember-data/active-record/request';
|
|
11
|
-
*
|
|
12
|
-
* const person = store.peekRecord('person', '1');
|
|
13
|
-
*
|
|
14
|
-
* // mark record as deleted
|
|
15
|
-
* store.deleteRecord(person);
|
|
16
|
-
*
|
|
17
|
-
* // persist deletion
|
|
18
|
-
* const data = await store.request(deleteRecord(person));
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
22
|
-
*
|
|
23
|
-
* The following options are supported:
|
|
24
|
-
*
|
|
25
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
26
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
27
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
28
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
29
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
30
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
31
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
32
|
-
* defaulting to `false` if none is configured.
|
|
33
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
34
|
-
*
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { deleteRecord } from '@ember-data/active-record/request';
|
|
37
|
-
*
|
|
38
|
-
* const person = store.peekRecord('person', '1');
|
|
39
|
-
*
|
|
40
|
-
* // mark record as deleted
|
|
41
|
-
* store.deleteRecord(person);
|
|
42
|
-
*
|
|
43
|
-
* // persist deletion
|
|
44
|
-
* const options = deleteRecord(person, { namespace: 'api/v1' });
|
|
45
|
-
* const data = await store.request(options);
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @method deleteRecord
|
|
49
|
-
* @public
|
|
50
|
-
* @static
|
|
51
|
-
* @for @ember-data/active-record/request
|
|
52
|
-
* @param record
|
|
53
|
-
* @param options
|
|
54
|
-
*/
|
|
55
|
-
export function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
|
|
56
|
-
export function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
|
|
57
|
-
/**
|
|
58
|
-
* Builds request options to create new record for resources,
|
|
59
|
-
* configured for the url, method and header expectations of most ActiveRecord APIs.
|
|
60
|
-
*
|
|
61
|
-
* **Basic Usage**
|
|
62
|
-
*
|
|
63
|
-
* ```ts
|
|
64
|
-
* import { createRecord } from '@ember-data/active-record/request';
|
|
65
|
-
*
|
|
66
|
-
* const person = store.createRecord('person', { name: 'Ted' });
|
|
67
|
-
* const data = await store.request(createRecord(person));
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
71
|
-
*
|
|
72
|
-
* The following options are supported:
|
|
73
|
-
*
|
|
74
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
75
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
76
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
77
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
78
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
79
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
80
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
81
|
-
* defaulting to `false` if none is configured.
|
|
82
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
83
|
-
*
|
|
84
|
-
* ```ts
|
|
85
|
-
* import { createRecord } from '@ember-data/active-record/request';
|
|
86
|
-
*
|
|
87
|
-
* const person = store.createRecord('person', { name: 'Ted' });
|
|
88
|
-
* const options = createRecord(person, { namespace: 'api/v1' });
|
|
89
|
-
* const data = await store.request(options);
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @method createRecord
|
|
93
|
-
* @public
|
|
94
|
-
* @static
|
|
95
|
-
* @for @ember-data/active-record/request
|
|
96
|
-
* @param record
|
|
97
|
-
* @param options
|
|
98
|
-
*/
|
|
99
|
-
export function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
|
|
100
|
-
export function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
|
|
101
|
-
/**
|
|
102
|
-
* Builds request options to update existing record for resources,
|
|
103
|
-
* configured for the url, method and header expectations of most ActiveRecord APIs.
|
|
104
|
-
*
|
|
105
|
-
* **Basic Usage**
|
|
106
|
-
*
|
|
107
|
-
* ```ts
|
|
108
|
-
* import { updateRecord } from '@ember-data/active-record/request';
|
|
109
|
-
*
|
|
110
|
-
* const person = store.peekRecord('person', '1');
|
|
111
|
-
* person.name = 'Chris';
|
|
112
|
-
* const data = await store.request(updateRecord(person));
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
116
|
-
*
|
|
117
|
-
* The following options are supported:
|
|
118
|
-
*
|
|
119
|
-
* - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
|
|
120
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
121
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
122
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
123
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
124
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
125
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
126
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
127
|
-
* defaulting to `false` if none is configured.
|
|
128
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
129
|
-
*
|
|
130
|
-
* ```ts
|
|
131
|
-
* import { updateRecord } from '@ember-data/active-record/request';
|
|
132
|
-
*
|
|
133
|
-
* const person = store.peekRecord('person', '1');
|
|
134
|
-
* person.name = 'Chris';
|
|
135
|
-
* const options = updateRecord(person, { patch: true });
|
|
136
|
-
* const data = await store.request(options);
|
|
137
|
-
* ```
|
|
138
|
-
*
|
|
139
|
-
* @method updateRecord
|
|
140
|
-
* @public
|
|
141
|
-
* @static
|
|
142
|
-
* @for @ember-data/active-record/request
|
|
143
|
-
* @param record
|
|
144
|
-
* @param options
|
|
145
|
-
*/
|
|
146
|
-
export function updateRecord<T>(record: T, options?: ConstrainedRequestOptions & {
|
|
147
|
-
patch?: boolean;
|
|
148
|
-
}): UpdateRequestOptions<T>;
|
|
149
|
-
export function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
|
|
150
|
-
patch?: boolean;
|
|
151
|
-
}): UpdateRequestOptions;
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=save-record.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"save-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/save-record.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAQxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC;AA8BzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,oBAAoB,CAAC;AA6BzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAC3B,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,oBAAoB,CAAC"}
|