@ember-data-types/active-record 5.6.0-alpha.2 → 5.6.0-alpha.4
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/-private/builders/find-record.d.ts +2 -5
- package/unstable-preview-types/-private/builders/find-record.d.ts.map +1 -1
- package/unstable-preview-types/-private/builders/query.d.ts +1 -4
- package/unstable-preview-types/-private/builders/query.d.ts.map +1 -1
- package/unstable-preview-types/-private/builders/save-record.d.ts +4 -11
- package/unstable-preview-types/-private/builders/save-record.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +3 -3
- package/unstable-preview-types/request.d.ts +65 -61
- package/unstable-preview-types/request.d.ts.map +1 -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
|
@@ -56,16 +56,13 @@ declare module '@ember-data/active-record/-private/builders/find-record' {
|
|
|
56
56
|
* const data = await store.request(options);
|
|
57
57
|
* ```
|
|
58
58
|
*
|
|
59
|
-
* @method findRecord
|
|
60
59
|
* @public
|
|
61
|
-
* @static
|
|
62
|
-
* @for @ember-data/active-record/request
|
|
63
60
|
* @param identifier
|
|
64
61
|
* @param options
|
|
65
62
|
*/
|
|
66
|
-
export function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<
|
|
63
|
+
export function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
67
64
|
export function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
68
|
-
export function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<
|
|
65
|
+
export function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
69
66
|
export function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
70
67
|
}
|
|
71
68
|
//# sourceMappingURL=find-record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/find-record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/find-record.ts"],"names":[],"mappings":"AAEA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;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,wBAAwB,CAAC,CAAC,CAAC,EAAE,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,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC5D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,wBAAwB,CAAC"}
|
|
@@ -45,15 +45,12 @@ declare module '@ember-data/active-record/-private/builders/query' {
|
|
|
45
45
|
* const data = await store.request(options);
|
|
46
46
|
* ```
|
|
47
47
|
*
|
|
48
|
-
* @method query
|
|
49
48
|
* @public
|
|
50
|
-
* @static
|
|
51
|
-
* @for @ember-data/active-record/request
|
|
52
49
|
* @param identifier
|
|
53
50
|
* @param query
|
|
54
51
|
* @param options
|
|
55
52
|
*/
|
|
56
|
-
export function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<
|
|
53
|
+
export function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;
|
|
57
54
|
export function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
58
55
|
}
|
|
59
56
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/query.ts"],"names":[],"mappings":"AAEA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;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,8BAA8B,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7D,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
declare module '@ember-data/active-record/-private/builders/save-record' {
|
|
2
|
+
import type { TypedRecordInstance } from '@warp-drive/core-types/record';
|
|
2
3
|
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from '@warp-drive/core-types/request';
|
|
4
|
+
import type { SingleResourceDataDocument } from '@warp-drive/core-types/spec/document';
|
|
3
5
|
/**
|
|
4
6
|
* Builds request options to delete record for resources,
|
|
5
7
|
* configured for the url, method and header expectations of ActiveRecord APIs.
|
|
@@ -45,10 +47,7 @@ declare module '@ember-data/active-record/-private/builders/save-record' {
|
|
|
45
47
|
* const data = await store.request(options);
|
|
46
48
|
* ```
|
|
47
49
|
*
|
|
48
|
-
* @method deleteRecord
|
|
49
50
|
* @public
|
|
50
|
-
* @static
|
|
51
|
-
* @for @ember-data/active-record/request
|
|
52
51
|
* @param record
|
|
53
52
|
* @param options
|
|
54
53
|
*/
|
|
@@ -89,10 +88,7 @@ declare module '@ember-data/active-record/-private/builders/save-record' {
|
|
|
89
88
|
* const data = await store.request(options);
|
|
90
89
|
* ```
|
|
91
90
|
*
|
|
92
|
-
* @method createRecord
|
|
93
91
|
* @public
|
|
94
|
-
* @static
|
|
95
|
-
* @for @ember-data/active-record/request
|
|
96
92
|
* @param record
|
|
97
93
|
* @param options
|
|
98
94
|
*/
|
|
@@ -136,16 +132,13 @@ declare module '@ember-data/active-record/-private/builders/save-record' {
|
|
|
136
132
|
* const data = await store.request(options);
|
|
137
133
|
* ```
|
|
138
134
|
*
|
|
139
|
-
* @method updateRecord
|
|
140
135
|
* @public
|
|
141
|
-
* @static
|
|
142
|
-
* @for @ember-data/active-record/request
|
|
143
136
|
* @param record
|
|
144
137
|
* @param options
|
|
145
138
|
*/
|
|
146
|
-
export function updateRecord<T>(record: T, options?: ConstrainedRequestOptions & {
|
|
139
|
+
export function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(record: T, options?: ConstrainedRequestOptions & {
|
|
147
140
|
patch?: boolean;
|
|
148
|
-
}): UpdateRequestOptions<T>;
|
|
141
|
+
}): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;
|
|
149
142
|
export function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
|
|
150
143
|
patch?: boolean;
|
|
151
144
|
}): UpdateRequestOptions;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"save-record.d.ts","sourceRoot":"","sources":["../../../src/-private/builders/save-record.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,E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C"}
|
|
@@ -1,5 +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
2
|
/// <reference path="./-private/builders/-utils.d.ts" />
|
|
5
|
-
/// <reference path="./-private/builders/find-record.d.ts" />
|
|
3
|
+
/// <reference path="./-private/builders/find-record.d.ts" />
|
|
4
|
+
/// <reference path="./-private/builders/save-record.d.ts" />
|
|
5
|
+
/// <reference path="./-private/builders/query.d.ts" />
|
|
@@ -1,66 +1,70 @@
|
|
|
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
69
|
export { findRecord } from '@ember-data/active-record/-private/builders/find-record';
|
|
66
70
|
export { query } from '@ember-data/active-record/-private/builders/query';
|
|
@@ -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,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
|