@warp-drive/utilities 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/CHANGELOG.md +1 -0
- package/LICENSE.md +23 -0
- package/README.md +54 -0
- package/addon-main.cjs +5 -0
- package/declarations/-private/active-record/find-record.d.ts +66 -0
- package/declarations/-private/active-record/find-record.d.ts.map +1 -0
- package/declarations/-private/active-record/query.d.ts +54 -0
- package/declarations/-private/active-record/query.d.ts.map +1 -0
- package/declarations/-private/active-record/save-record.d.ts +144 -0
- package/declarations/-private/active-record/save-record.d.ts.map +1 -0
- package/declarations/-private/builder-utils.d.ts +5 -0
- package/declarations/-private/builder-utils.d.ts.map +1 -0
- package/declarations/-private/handlers/auto-compress.d.ts +153 -0
- package/declarations/-private/handlers/auto-compress.d.ts.map +1 -0
- package/declarations/-private/json-api/-utils.d.ts +110 -0
- package/declarations/-private/json-api/-utils.d.ts.map +1 -0
- package/declarations/-private/json-api/find-record.d.ts +66 -0
- package/declarations/-private/json-api/find-record.d.ts.map +1 -0
- package/declarations/-private/json-api/find-record.type-test.d.ts +2 -0
- package/declarations/-private/json-api/find-record.type-test.d.ts.map +1 -0
- package/declarations/-private/json-api/query.d.ts +104 -0
- package/declarations/-private/json-api/query.d.ts.map +1 -0
- package/declarations/-private/json-api/query.type-test.d.ts +2 -0
- package/declarations/-private/json-api/query.type-test.d.ts.map +1 -0
- package/declarations/-private/json-api/save-record.d.ts +191 -0
- package/declarations/-private/json-api/save-record.d.ts.map +1 -0
- package/declarations/-private/json-api/serialize.d.ts +57 -0
- package/declarations/-private/json-api/serialize.d.ts.map +1 -0
- package/declarations/-private/rest/find-record.d.ts +66 -0
- package/declarations/-private/rest/find-record.d.ts.map +1 -0
- package/declarations/-private/rest/query.d.ts +54 -0
- package/declarations/-private/rest/query.d.ts.map +1 -0
- package/declarations/-private/rest/save-record.d.ts +144 -0
- package/declarations/-private/rest/save-record.d.ts.map +1 -0
- package/declarations/-private/string/inflect.d.ts +105 -0
- package/declarations/-private/string/inflect.d.ts.map +1 -0
- package/declarations/-private/string/inflections.d.ts +10 -0
- package/declarations/-private/string/inflections.d.ts.map +1 -0
- package/declarations/-private/string/transform.d.ts +89 -0
- package/declarations/-private/string/transform.d.ts.map +1 -0
- package/declarations/-private.d.ts +2 -0
- package/declarations/-private.d.ts.map +1 -0
- package/declarations/active-record.d.ts +71 -0
- package/declarations/active-record.d.ts.map +1 -0
- package/declarations/handlers.d.ts +8 -0
- package/declarations/handlers.d.ts.map +1 -0
- package/declarations/index.d.ts +255 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/json-api.d.ts +51 -0
- package/declarations/json-api.d.ts.map +1 -0
- package/declarations/rest.d.ts +51 -0
- package/declarations/rest.d.ts.map +1 -0
- package/declarations/string.d.ts +14 -0
- package/declarations/string.d.ts.map +1 -0
- package/dist/-private.js +7 -0
- package/dist/-private.js.map +1 -0
- package/dist/active-record.js +393 -0
- package/dist/active-record.js.map +1 -0
- package/dist/builder-utils-Donkk-BZ.js +22 -0
- package/dist/builder-utils-Donkk-BZ.js.map +1 -0
- package/dist/handlers.js +141 -0
- package/dist/handlers.js.map +1 -0
- package/dist/index.js +403 -0
- package/dist/index.js.map +1 -0
- package/dist/inflect-C1laviCe.js +376 -0
- package/dist/inflect-C1laviCe.js.map +1 -0
- package/dist/json-api.js +671 -0
- package/dist/json-api.js.map +1 -0
- package/dist/rest.js +393 -0
- package/dist/rest.js.map +1 -0
- package/dist/string.js +1 -0
- package/dist/string.js.map +1 -0
- package/logos/NCC-1701-a-blue.svg +4 -0
- package/logos/NCC-1701-a-gold.svg +4 -0
- package/logos/NCC-1701-a-gold_100.svg +1 -0
- package/logos/NCC-1701-a-gold_base-64.txt +1 -0
- package/logos/NCC-1701-a.svg +4 -0
- package/logos/README.md +4 -0
- package/logos/docs-badge.svg +2 -0
- package/logos/ember-data-logo-dark.svg +12 -0
- package/logos/ember-data-logo-light.svg +12 -0
- package/logos/github-header.svg +444 -0
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +4 -0
- package/logos/warp-drive-logo-gold.svg +4 -0
- package/package.json +68 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { TypedRecordInstance } from '@warp-drive/core/types/record';
|
|
2
|
+
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from '@warp-drive/core/types/request';
|
|
3
|
+
import type { SingleResourceDataDocument } from '@warp-drive/core/types/spec/document';
|
|
4
|
+
/**
|
|
5
|
+
* Builds request options to delete record for resources,
|
|
6
|
+
* configured for the url, method and header expectations of REST APIs.
|
|
7
|
+
*
|
|
8
|
+
* **Basic Usage**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { deleteRecord } from '@warp-drive/utilities/rest';
|
|
12
|
+
*
|
|
13
|
+
* const person = store.peekRecord('person', '1');
|
|
14
|
+
*
|
|
15
|
+
* // mark record as deleted
|
|
16
|
+
* store.deleteRecord(person);
|
|
17
|
+
*
|
|
18
|
+
* // persist deletion
|
|
19
|
+
* const data = await store.request(deleteRecord(person));
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
23
|
+
*
|
|
24
|
+
* The following options are supported:
|
|
25
|
+
*
|
|
26
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
27
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
28
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
29
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
30
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
31
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
32
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
33
|
+
* defaulting to `false` if none is configured.
|
|
34
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { deleteRecord } from '@warp-drive/utilities/rest';
|
|
38
|
+
*
|
|
39
|
+
* const person = store.peekRecord('person', '1');
|
|
40
|
+
*
|
|
41
|
+
* // mark record as deleted
|
|
42
|
+
* store.deleteRecord(person);
|
|
43
|
+
*
|
|
44
|
+
* // persist deletion
|
|
45
|
+
* const options = deleteRecord(person, { namespace: 'api/v1' });
|
|
46
|
+
* const data = await store.request(options);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
* @param record
|
|
51
|
+
* @param options
|
|
52
|
+
*/
|
|
53
|
+
export declare function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
|
|
54
|
+
export declare function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
|
|
55
|
+
/**
|
|
56
|
+
* Builds request options to create new record for resources,
|
|
57
|
+
* configured for the url, method and header expectations of most REST APIs.
|
|
58
|
+
*
|
|
59
|
+
* **Basic Usage**
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { createRecord } from '@warp-drive/utilities/rest';
|
|
63
|
+
*
|
|
64
|
+
* const person = store.createRecord('person', { name: 'Ted' });
|
|
65
|
+
* const data = await store.request(createRecord(person));
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
69
|
+
*
|
|
70
|
+
* The following options are supported:
|
|
71
|
+
*
|
|
72
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
73
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
74
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
75
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
76
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
77
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
78
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
79
|
+
* defaulting to `false` if none is configured.
|
|
80
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { createRecord } from '@warp-drive/utilities/rest';
|
|
84
|
+
*
|
|
85
|
+
* const person = store.createRecord('person', { name: 'Ted' });
|
|
86
|
+
* const options = createRecord(person, { namespace: 'api/v1' });
|
|
87
|
+
* const data = await store.request(options);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
* @param record
|
|
92
|
+
* @param options
|
|
93
|
+
*/
|
|
94
|
+
export declare function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
|
|
95
|
+
export declare function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
|
|
96
|
+
/**
|
|
97
|
+
* Builds request options to update existing record for resources,
|
|
98
|
+
* configured for the url, method and header expectations of most REST APIs.
|
|
99
|
+
*
|
|
100
|
+
* **Basic Usage**
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { updateRecord } from '@warp-drive/utilities/rest';
|
|
104
|
+
*
|
|
105
|
+
* const person = store.peekRecord('person', '1');
|
|
106
|
+
* person.name = 'Chris';
|
|
107
|
+
* const data = await store.request(updateRecord(person));
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
111
|
+
*
|
|
112
|
+
* The following options are supported:
|
|
113
|
+
*
|
|
114
|
+
* - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
|
|
115
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
116
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
117
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
118
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
119
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
120
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
121
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
122
|
+
* defaulting to `false` if none is configured.
|
|
123
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { updateRecord } from '@warp-drive/utilities/rest';
|
|
127
|
+
*
|
|
128
|
+
* const person = store.peekRecord('person', '1');
|
|
129
|
+
* person.name = 'Chris';
|
|
130
|
+
* const options = updateRecord(person, { patch: true });
|
|
131
|
+
* const data = await store.request(options);
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
* @param record
|
|
136
|
+
* @param options
|
|
137
|
+
*/
|
|
138
|
+
export declare function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(record: T, options?: ConstrainedRequestOptions & {
|
|
139
|
+
patch?: boolean;
|
|
140
|
+
}): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;
|
|
141
|
+
export declare function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
|
|
142
|
+
patch?: boolean;
|
|
143
|
+
}): UpdateRequestOptions;
|
|
144
|
+
//# sourceMappingURL=save-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-record.d.ts","sourceRoot":"","sources":["../../../src/-private/rest/save-record.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAevF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,mBAAmB,EAAE,EAAE,SAAS,mBAAmB,GAAG,CAAC,EAC5F,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,oBAAoB,CAAC,0BAA0B,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3D,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks a word as uncountable. Uncountable words are not pluralized
|
|
3
|
+
* or singularized.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @param {String} word
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @since 4.13.0
|
|
9
|
+
*/
|
|
10
|
+
export declare function uncountable(word: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Marks a list of words as uncountable. Uncountable words are not pluralized
|
|
13
|
+
* or singularized.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @param {Array<String>} uncountables
|
|
17
|
+
* @return {void}
|
|
18
|
+
* @since 4.13.0
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadUncountable(uncountables: string[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Marks a word as irregular. Irregular words have unique
|
|
23
|
+
* pluralization and singularization rules.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
* @param {String} single
|
|
27
|
+
* @param {String} plur
|
|
28
|
+
* @return {void}
|
|
29
|
+
* @since 4.13.0
|
|
30
|
+
*/
|
|
31
|
+
export declare function irregular(single: string, plur: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Marks a list of word pairs as irregular. Irregular words have unique
|
|
34
|
+
* pluralization and singularization rules.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
* @param {Array<Array<String>>} irregularPairs
|
|
38
|
+
* @return {void}
|
|
39
|
+
* @since 4.13.0
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadIrregular(irregularPairs: Array<[string, string]>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Clears the caches for singularize and pluralize.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
* @return {void}
|
|
47
|
+
* @since 4.13.0
|
|
48
|
+
*/
|
|
49
|
+
export declare function clear(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Resets the inflection rules to the defaults.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
* @return {void}
|
|
55
|
+
* @since 4.13.0
|
|
56
|
+
*/
|
|
57
|
+
export declare function resetToDefaults(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Clears all inflection rules
|
|
60
|
+
* and resets the caches for singularize and pluralize.
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @return {void}
|
|
64
|
+
* @since 4.13.0
|
|
65
|
+
*/
|
|
66
|
+
export declare function clearRules(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Singularizes a word.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
* @param {String} word
|
|
72
|
+
* @return {String}
|
|
73
|
+
* @since 4.13.0
|
|
74
|
+
*/
|
|
75
|
+
export declare function singularize(word: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Pluralizes a word.
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
* @param {String} word
|
|
81
|
+
* @return {String}
|
|
82
|
+
* @since 4.13.0
|
|
83
|
+
*/
|
|
84
|
+
export declare function pluralize(word: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Adds a pluralization rule.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
* @param {RegExp} regex
|
|
90
|
+
* @param {String} string
|
|
91
|
+
* @return {void}
|
|
92
|
+
* @since 4.13.0
|
|
93
|
+
*/
|
|
94
|
+
export declare function plural(regex: RegExp, string: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Adds a singularization rule.
|
|
97
|
+
*
|
|
98
|
+
* @public
|
|
99
|
+
* @param {RegExp} regex
|
|
100
|
+
* @param {String} string
|
|
101
|
+
* @return {void}
|
|
102
|
+
* @since 4.13.0
|
|
103
|
+
*/
|
|
104
|
+
export declare function singular(regex: RegExp, string: string): void;
|
|
105
|
+
//# sourceMappingURL=inflect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inflect.d.ts","sourceRoot":"","sources":["../../../src/-private/string/inflect.ts"],"names":[],"mappings":"AAuBA;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,QAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,QAIrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAQrD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAUpE;AAGD;;;;;;GAMG;AACH,wBAAgB,KAAK,SAGpB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,SAM9B;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,SAQzB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAIvC;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,UAIrC;AAWD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAQnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAQrD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type RulesArray = Array<[RegExp, string]>;
|
|
2
|
+
type DefaultRulesType = {
|
|
3
|
+
plurals: RulesArray;
|
|
4
|
+
singular: RulesArray;
|
|
5
|
+
irregularPairs: Array<[string, string]>;
|
|
6
|
+
uncountable: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare const defaultRules: DefaultRulesType;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=inflections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inflections.d.ts","sourceRoot":"","sources":["../../../src/-private/string/inflections.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AACjD,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,UAAU,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,gBAkE1B,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { dasherize as internalDasherize } from '@warp-drive/core/utils/string';
|
|
2
|
+
/**
|
|
3
|
+
* Replaces underscores, spaces, or camelCase with dashes.
|
|
4
|
+
*
|
|
5
|
+
* ```js
|
|
6
|
+
* import { dasherize } from '@warp-drive/utilities/string';
|
|
7
|
+
*
|
|
8
|
+
* dasherize('innerHTML'); // 'inner-html'
|
|
9
|
+
* dasherize('action_name'); // 'action-name'
|
|
10
|
+
* dasherize('css-class-name'); // 'css-class-name'
|
|
11
|
+
* dasherize('my favorite items'); // 'my-favorite-items'
|
|
12
|
+
* dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @param {String} str
|
|
17
|
+
* @return {String}
|
|
18
|
+
* @since 4.13.0
|
|
19
|
+
*/
|
|
20
|
+
export declare const dasherize: typeof internalDasherize;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the lowerCamelCase form of a string.
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* import { camelize } from '@warp-drive/utilities/string';
|
|
26
|
+
*
|
|
27
|
+
* camelize('innerHTML'); // 'innerHTML'
|
|
28
|
+
* camelize('action_name'); // 'actionName'
|
|
29
|
+
* camelize('css-class-name'); // 'cssClassName'
|
|
30
|
+
* camelize('my favorite items'); // 'myFavoriteItems'
|
|
31
|
+
* camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
32
|
+
* camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
* @param {String} str
|
|
37
|
+
* @return {String}
|
|
38
|
+
* @since 4.13.0
|
|
39
|
+
*/
|
|
40
|
+
export declare function camelize(str: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the lower\_case\_and\_underscored form of a string.
|
|
43
|
+
*
|
|
44
|
+
* ```js
|
|
45
|
+
* import { underscore } from '@warp-drive/utilities/string';
|
|
46
|
+
*
|
|
47
|
+
* underscore('innerHTML'); // 'inner_html'
|
|
48
|
+
* underscore('action_name'); // 'action_name'
|
|
49
|
+
* underscore('css-class-name'); // 'css_class_name'
|
|
50
|
+
* underscore('my favorite items'); // 'my_favorite_items'
|
|
51
|
+
* underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @param {String} str
|
|
56
|
+
* @return {String}
|
|
57
|
+
* @since 4.13.0
|
|
58
|
+
*/
|
|
59
|
+
export declare function underscore(str: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the Capitalized form of a string
|
|
62
|
+
*
|
|
63
|
+
* ```js
|
|
64
|
+
* import { capitalize } from '@warp-drive/utilities/string';
|
|
65
|
+
*
|
|
66
|
+
* capitalize('innerHTML') // 'InnerHTML'
|
|
67
|
+
* capitalize('action_name') // 'Action_name'
|
|
68
|
+
* capitalize('css-class-name') // 'Css-class-name'
|
|
69
|
+
* capitalize('my favorite items') // 'My favorite items'
|
|
70
|
+
* capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @param {String} str
|
|
75
|
+
* @return {String}
|
|
76
|
+
* @since 4.13.0
|
|
77
|
+
*/
|
|
78
|
+
export declare function capitalize(str: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the maximum size of the LRUCache for all string transformation functions.
|
|
81
|
+
* The default size is 10,000.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
* @param {Number} size
|
|
85
|
+
* @return {void}
|
|
86
|
+
* @since 4.13.0
|
|
87
|
+
*/
|
|
88
|
+
export declare function setMaxLRUCacheSize(size: number): void;
|
|
89
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/-private/string/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAoC,MAAM,+BAA+B,CAAC;AAuBjH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS,0BAAoB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,QAK9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"-private.d.ts","sourceRoot":"","sources":["../src/-private.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,sBAAsB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
*
|
|
4
|
+
*This package provides utilities for working with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html#convention-over-configuration-in-active-record) APIs.
|
|
5
|
+
*
|
|
6
|
+
* ## Installation
|
|
7
|
+
*
|
|
8
|
+
* Install using your javascript package manager of choice. For instance with [pnpm](https://pnpm.io/)
|
|
9
|
+
*
|
|
10
|
+
* ::: code-group
|
|
11
|
+
*
|
|
12
|
+
* ```sh [pnpm]
|
|
13
|
+
* pnpm add -E @ember-data/active-record
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```sh [npm]
|
|
17
|
+
* npm add -E @ember-data/active-record
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ```sh [yarn]
|
|
21
|
+
* yarn add -E @ember-data/active-record
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ```sh [bun]
|
|
25
|
+
* bun add --exact @ember-data/active-record
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* :::
|
|
29
|
+
*
|
|
30
|
+
* ## Usage
|
|
31
|
+
*
|
|
32
|
+
* Request builders are functions that produce [Fetch Options](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
|
|
33
|
+
* They take a few contextual inputs about the request you want to make, abstracting away the gnarlier details.
|
|
34
|
+
*
|
|
35
|
+
* For instance, to construct a request that would fetch a resource from your API:
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { findRecord } from '@ember-data/active-record/request';
|
|
39
|
+
*
|
|
40
|
+
* const options = findRecord('ember-developer', '1', { include: ['pets', 'friends'] });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* This would produce the following request object:
|
|
44
|
+
*
|
|
45
|
+
* ```js
|
|
46
|
+
* {
|
|
47
|
+
* url: 'https://api.example.com/v1/ember_developers/1?include=friends,pets',
|
|
48
|
+
* method: 'GET',
|
|
49
|
+
* headers: <Headers>, // 'Accept': 'application/json;charset=utf-8'
|
|
50
|
+
* op: 'findRecord';
|
|
51
|
+
* records: [{ type: 'ember-developer', id: '1' }]
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Request builder output may be used with either `requestManager.request` or `store.request`.
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* const data = await store.request(options);
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* URLs are stable. The same query will produce the same URL every time, even if the order of keys in
|
|
62
|
+
* the query or values in an array changes.
|
|
63
|
+
*
|
|
64
|
+
* URLs follow the most common ActiveRecord format (underscored pluralized resource types).
|
|
65
|
+
*
|
|
66
|
+
* @module
|
|
67
|
+
*/
|
|
68
|
+
export { findRecord } from './-private/active-record/find-record';
|
|
69
|
+
export { query } from './-private/active-record/query';
|
|
70
|
+
export { deleteRecord, createRecord, updateRecord } from './-private/active-record/save-record';
|
|
71
|
+
//# sourceMappingURL=active-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"active-record.d.ts","sourceRoot":"","sources":["../src/active-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC"}
|