@warp-drive-mirror/utilities 5.8.0-alpha.30 → 5.8.0-alpha.32
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/dist/string.js +428 -1
- package/dist/unpkg/dev/-private.js +7 -0
- package/dist/unpkg/dev/active-record.js +395 -0
- package/dist/unpkg/dev/builder-utils-Donkk-BZ.js +22 -0
- package/dist/unpkg/dev/declarations/-private/active-record/find-record.d.ts +64 -0
- package/dist/unpkg/dev/declarations/-private/active-record/query.d.ts +53 -0
- package/dist/unpkg/dev/declarations/-private/active-record/save-record.d.ts +146 -0
- package/dist/unpkg/dev/declarations/-private/builder-utils.d.ts +4 -0
- package/dist/unpkg/dev/declarations/-private/handlers/auto-compress.d.ts +158 -0
- package/dist/unpkg/dev/declarations/-private/handlers/gated.d.ts +19 -0
- package/dist/unpkg/dev/declarations/-private/handlers/meta-doc.d.ts +47 -0
- package/dist/unpkg/dev/declarations/-private/handlers/utils.d.ts +41 -0
- package/dist/unpkg/dev/declarations/-private/json-api/-utils.d.ts +109 -0
- package/dist/unpkg/dev/declarations/-private/json-api/find-record.d.ts +84 -0
- package/dist/unpkg/dev/declarations/-private/json-api/query.d.ts +100 -0
- package/dist/unpkg/dev/declarations/-private/json-api/save-record.d.ts +228 -0
- package/dist/unpkg/dev/declarations/-private/json-api/serialize.d.ts +70 -0
- package/dist/unpkg/dev/declarations/-private/rest/find-record.d.ts +62 -0
- package/dist/unpkg/dev/declarations/-private/rest/query.d.ts +53 -0
- package/dist/unpkg/dev/declarations/-private/rest/save-record.d.ts +146 -0
- package/dist/unpkg/dev/declarations/-private/string/inflect.d.ts +82 -0
- package/dist/unpkg/dev/declarations/-private/string/inflections.d.ts +9 -0
- package/dist/unpkg/dev/declarations/-private/string/transform.d.ts +77 -0
- package/dist/unpkg/dev/declarations/-private.d.ts +1 -0
- package/dist/unpkg/dev/declarations/active-record.d.ts +3 -0
- package/dist/unpkg/dev/declarations/derivations.d.ts +27 -0
- package/dist/unpkg/dev/declarations/handlers.d.ts +10 -0
- package/dist/unpkg/dev/declarations/index.d.ts +208 -0
- package/dist/unpkg/dev/declarations/json-api.d.ts +5 -0
- package/dist/unpkg/dev/declarations/rest.d.ts +3 -0
- package/dist/unpkg/dev/declarations/string.d.ts +14 -0
- package/dist/unpkg/dev/derivations.js +30 -0
- package/dist/unpkg/dev/handlers.js +317 -0
- package/dist/unpkg/dev/index.js +361 -0
- package/dist/unpkg/dev/inflect-BSG696t-.js +344 -0
- package/dist/unpkg/dev/json-api.js +740 -0
- package/dist/unpkg/dev/rest.js +393 -0
- package/dist/unpkg/dev/string.js +1 -0
- package/dist/unpkg/dev-deprecated/-private.js +7 -0
- package/dist/unpkg/dev-deprecated/active-record.js +395 -0
- package/dist/unpkg/dev-deprecated/builder-utils-Donkk-BZ.js +22 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/find-record.d.ts +64 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/query.d.ts +53 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/save-record.d.ts +146 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/builder-utils.d.ts +4 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/auto-compress.d.ts +158 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/gated.d.ts +19 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/meta-doc.d.ts +47 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/utils.d.ts +41 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/-utils.d.ts +109 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/find-record.d.ts +84 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/query.d.ts +100 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/save-record.d.ts +228 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/serialize.d.ts +70 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/find-record.d.ts +62 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/query.d.ts +53 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/save-record.d.ts +146 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/string/inflect.d.ts +82 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/string/inflections.d.ts +9 -0
- package/dist/unpkg/dev-deprecated/declarations/-private/string/transform.d.ts +77 -0
- package/dist/unpkg/dev-deprecated/declarations/-private.d.ts +1 -0
- package/dist/unpkg/dev-deprecated/declarations/active-record.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/declarations/derivations.d.ts +27 -0
- package/dist/unpkg/dev-deprecated/declarations/handlers.d.ts +10 -0
- package/dist/unpkg/dev-deprecated/declarations/index.d.ts +208 -0
- package/dist/unpkg/dev-deprecated/declarations/json-api.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/rest.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/declarations/string.d.ts +14 -0
- package/dist/unpkg/dev-deprecated/derivations.js +30 -0
- package/dist/unpkg/dev-deprecated/handlers.js +317 -0
- package/dist/unpkg/dev-deprecated/index.js +361 -0
- package/dist/unpkg/dev-deprecated/inflect-BSG696t-.js +344 -0
- package/dist/unpkg/dev-deprecated/json-api.js +740 -0
- package/dist/unpkg/dev-deprecated/rest.js +393 -0
- package/dist/unpkg/dev-deprecated/string.js +1 -0
- package/dist/unpkg/prod/-private.js +7 -0
- package/dist/unpkg/prod/active-record.js +395 -0
- package/dist/unpkg/prod/builder-utils-Donkk-BZ.js +22 -0
- package/dist/unpkg/prod/declarations/-private/active-record/find-record.d.ts +64 -0
- package/dist/unpkg/prod/declarations/-private/active-record/query.d.ts +53 -0
- package/dist/unpkg/prod/declarations/-private/active-record/save-record.d.ts +146 -0
- package/dist/unpkg/prod/declarations/-private/builder-utils.d.ts +4 -0
- package/dist/unpkg/prod/declarations/-private/handlers/auto-compress.d.ts +158 -0
- package/dist/unpkg/prod/declarations/-private/handlers/gated.d.ts +19 -0
- package/dist/unpkg/prod/declarations/-private/handlers/meta-doc.d.ts +47 -0
- package/dist/unpkg/prod/declarations/-private/handlers/utils.d.ts +41 -0
- package/dist/unpkg/prod/declarations/-private/json-api/-utils.d.ts +109 -0
- package/dist/unpkg/prod/declarations/-private/json-api/find-record.d.ts +84 -0
- package/dist/unpkg/prod/declarations/-private/json-api/query.d.ts +100 -0
- package/dist/unpkg/prod/declarations/-private/json-api/save-record.d.ts +228 -0
- package/dist/unpkg/prod/declarations/-private/json-api/serialize.d.ts +70 -0
- package/dist/unpkg/prod/declarations/-private/rest/find-record.d.ts +62 -0
- package/dist/unpkg/prod/declarations/-private/rest/query.d.ts +53 -0
- package/dist/unpkg/prod/declarations/-private/rest/save-record.d.ts +146 -0
- package/dist/unpkg/prod/declarations/-private/string/inflect.d.ts +82 -0
- package/dist/unpkg/prod/declarations/-private/string/inflections.d.ts +9 -0
- package/dist/unpkg/prod/declarations/-private/string/transform.d.ts +77 -0
- package/dist/unpkg/prod/declarations/-private.d.ts +1 -0
- package/dist/unpkg/prod/declarations/active-record.d.ts +3 -0
- package/dist/unpkg/prod/declarations/derivations.d.ts +27 -0
- package/dist/unpkg/prod/declarations/handlers.d.ts +10 -0
- package/dist/unpkg/prod/declarations/index.d.ts +208 -0
- package/dist/unpkg/prod/declarations/json-api.d.ts +5 -0
- package/dist/unpkg/prod/declarations/rest.d.ts +3 -0
- package/dist/unpkg/prod/declarations/string.d.ts +14 -0
- package/dist/unpkg/prod/derivations.js +30 -0
- package/dist/unpkg/prod/handlers.js +317 -0
- package/dist/unpkg/prod/index.js +361 -0
- package/dist/unpkg/prod/inflect-BSG696t-.js +344 -0
- package/dist/unpkg/prod/json-api.js +740 -0
- package/dist/unpkg/prod/rest.js +393 -0
- package/dist/unpkg/prod/string.js +1 -0
- package/dist/unpkg/prod-deprecated/-private.js +7 -0
- package/dist/unpkg/prod-deprecated/active-record.js +395 -0
- package/dist/unpkg/prod-deprecated/builder-utils-Donkk-BZ.js +22 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/find-record.d.ts +64 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/query.d.ts +53 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/save-record.d.ts +146 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/builder-utils.d.ts +4 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/auto-compress.d.ts +158 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/gated.d.ts +19 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/meta-doc.d.ts +47 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/utils.d.ts +41 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/-utils.d.ts +109 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/find-record.d.ts +84 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/query.d.ts +100 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/save-record.d.ts +228 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/serialize.d.ts +70 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/find-record.d.ts +62 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/query.d.ts +53 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/save-record.d.ts +146 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/string/inflect.d.ts +82 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/string/inflections.d.ts +9 -0
- package/dist/unpkg/prod-deprecated/declarations/-private/string/transform.d.ts +77 -0
- package/dist/unpkg/prod-deprecated/declarations/-private.d.ts +1 -0
- package/dist/unpkg/prod-deprecated/declarations/active-record.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/declarations/derivations.d.ts +27 -0
- package/dist/unpkg/prod-deprecated/declarations/handlers.d.ts +10 -0
- package/dist/unpkg/prod-deprecated/declarations/index.d.ts +208 -0
- package/dist/unpkg/prod-deprecated/declarations/json-api.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/rest.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/declarations/string.d.ts +14 -0
- package/dist/unpkg/prod-deprecated/derivations.js +30 -0
- package/dist/unpkg/prod-deprecated/handlers.js +317 -0
- package/dist/unpkg/prod-deprecated/index.js +361 -0
- package/dist/unpkg/prod-deprecated/inflect-BSG696t-.js +344 -0
- package/dist/unpkg/prod-deprecated/json-api.js +740 -0
- package/dist/unpkg/prod-deprecated/rest.js +393 -0
- package/dist/unpkg/prod-deprecated/string.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replaces underscores, spaces, or camelCase with dashes.
|
|
3
|
+
*
|
|
4
|
+
* ```js
|
|
5
|
+
* import { dasherize } from '@warp-drive-mirror/utilities/string';
|
|
6
|
+
*
|
|
7
|
+
* dasherize('innerHTML'); // 'inner-html'
|
|
8
|
+
* dasherize('action_name'); // 'action-name'
|
|
9
|
+
* dasherize('css-class-name'); // 'css-class-name'
|
|
10
|
+
* dasherize('my favorite items'); // 'my-favorite-items'
|
|
11
|
+
* dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
* @since 4.13.0
|
|
16
|
+
*/
|
|
17
|
+
export declare const dasherize: (str: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the lowerCamelCase form of a string.
|
|
20
|
+
*
|
|
21
|
+
* ```js
|
|
22
|
+
* import { camelize } from '@warp-drive-mirror/utilities/string';
|
|
23
|
+
*
|
|
24
|
+
* camelize('innerHTML'); // 'innerHTML'
|
|
25
|
+
* camelize('action_name'); // 'actionName'
|
|
26
|
+
* camelize('css-class-name'); // 'cssClassName'
|
|
27
|
+
* camelize('my favorite items'); // 'myFavoriteItems'
|
|
28
|
+
* camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
29
|
+
* camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @since 4.13.0
|
|
34
|
+
*/
|
|
35
|
+
export declare function camelize(str: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the lower\_case\_and\_underscored form of a string.
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* import { underscore } from '@warp-drive-mirror/utilities/string';
|
|
41
|
+
*
|
|
42
|
+
* underscore('innerHTML'); // 'inner_html'
|
|
43
|
+
* underscore('action_name'); // 'action_name'
|
|
44
|
+
* underscore('css-class-name'); // 'css_class_name'
|
|
45
|
+
* underscore('my favorite items'); // 'my_favorite_items'
|
|
46
|
+
* underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
* @since 4.13.0
|
|
51
|
+
*/
|
|
52
|
+
export declare function underscore(str: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the Capitalized form of a string
|
|
55
|
+
*
|
|
56
|
+
* ```js
|
|
57
|
+
* import { capitalize } from '@warp-drive-mirror/utilities/string';
|
|
58
|
+
*
|
|
59
|
+
* capitalize('innerHTML') // 'InnerHTML'
|
|
60
|
+
* capitalize('action_name') // 'Action_name'
|
|
61
|
+
* capitalize('css-class-name') // 'Css-class-name'
|
|
62
|
+
* capitalize('my favorite items') // 'My favorite items'
|
|
63
|
+
* capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
* @since 4.13.0
|
|
68
|
+
*/
|
|
69
|
+
export declare function capitalize(str: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the maximum size of the LRUCache for all string transformation functions.
|
|
72
|
+
* The default size is 10,000.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
* @since 4.13.0
|
|
76
|
+
*/
|
|
77
|
+
export declare function setMaxLRUCacheSize(size: number): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultRules as InflectionRuleDefaults } from "./-private/string/inflections.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactiveResource } from "@warp-drive-mirror/core/reactive";
|
|
2
|
+
import { Type } from "@warp-drive-mirror/core/types/symbols";
|
|
3
|
+
interface ConcatDerivation {
|
|
4
|
+
(record: ReactiveResource & {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}, options: Record<string, unknown> | null, _prop: string): string;
|
|
7
|
+
[Type]: "concat";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A derivation for use by {@link ReactiveResource} that joins the given fields
|
|
11
|
+
* with the optional separator (or '' if no separator is provided).
|
|
12
|
+
*
|
|
13
|
+
* Generally you should not need to import and use this function directly.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* {
|
|
17
|
+
* name: 'fullName',
|
|
18
|
+
* kind: 'derived',
|
|
19
|
+
* type: 'concat',
|
|
20
|
+
* options: {
|
|
21
|
+
* fields: ['firstName', 'lastName'],
|
|
22
|
+
* separator: ' ',
|
|
23
|
+
* },
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export declare const concat: ConcatDerivation;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A selection of pre-built request handlers for handling common
|
|
3
|
+
* request scenarios.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { AutoCompress, SupportsRequestStreams } from "./-private/handlers/auto-compress.js";
|
|
8
|
+
export { Gate } from "./-private/handlers/gated.js";
|
|
9
|
+
export { MetaDocHandler } from "./-private/handlers/meta-doc.js";
|
|
10
|
+
export { addTraceHeader, TAB_ASSIGNED, TAB_ID, assertInvalidUrlLength, MAX_URL_LENGTH } from "./-private/handlers/utils.js";
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from "@warp-drive-mirror/core/types/params";
|
|
2
|
+
export interface BuildURLConfig {
|
|
3
|
+
host: string | null;
|
|
4
|
+
namespace: string | null;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Sets the global configuration for `buildBaseURL`
|
|
8
|
+
* for host and namespace values for the application.
|
|
9
|
+
*
|
|
10
|
+
* These values may still be overridden by passing
|
|
11
|
+
* them to buildBaseURL directly.
|
|
12
|
+
*
|
|
13
|
+
* This method may be called as many times as needed.
|
|
14
|
+
* host values of `''` or `'/'` are equivalent.
|
|
15
|
+
*
|
|
16
|
+
* Except for the value of `/` as host, host should not
|
|
17
|
+
* end with `/`.
|
|
18
|
+
*
|
|
19
|
+
* namespace should not start or end with a `/`.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* type BuildURLConfig = {
|
|
23
|
+
* host: string;
|
|
24
|
+
* namespace: string'
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { setBuildURLConfig } from '@ember-data-mirror/request-utils';
|
|
32
|
+
*
|
|
33
|
+
* setBuildURLConfig({
|
|
34
|
+
* host: 'https://api.example.com',
|
|
35
|
+
* namespace: 'api/v1'
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare function setBuildURLConfig(config: BuildURLConfig): void;
|
|
42
|
+
export interface FindRecordUrlOptions {
|
|
43
|
+
op: "findRecord";
|
|
44
|
+
identifier: {
|
|
45
|
+
type: string;
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
resourcePath?: string;
|
|
49
|
+
host?: string;
|
|
50
|
+
namespace?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface QueryUrlOptions {
|
|
53
|
+
op: "query";
|
|
54
|
+
identifier: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
resourcePath?: string;
|
|
58
|
+
host?: string;
|
|
59
|
+
namespace?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface FindManyUrlOptions {
|
|
62
|
+
op: "findMany";
|
|
63
|
+
identifiers: {
|
|
64
|
+
type: string;
|
|
65
|
+
id: string;
|
|
66
|
+
}[];
|
|
67
|
+
resourcePath?: string;
|
|
68
|
+
host?: string;
|
|
69
|
+
namespace?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface FindRelatedCollectionUrlOptions {
|
|
72
|
+
op: "findRelatedCollection";
|
|
73
|
+
identifier: {
|
|
74
|
+
type: string;
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
fieldPath: string;
|
|
78
|
+
resourcePath?: string;
|
|
79
|
+
host?: string;
|
|
80
|
+
namespace?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface FindRelatedResourceUrlOptions {
|
|
83
|
+
op: "findRelatedRecord";
|
|
84
|
+
identifier: {
|
|
85
|
+
type: string;
|
|
86
|
+
id: string;
|
|
87
|
+
};
|
|
88
|
+
fieldPath: string;
|
|
89
|
+
resourcePath?: string;
|
|
90
|
+
host?: string;
|
|
91
|
+
namespace?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface CreateRecordUrlOptions {
|
|
94
|
+
op: "createRecord";
|
|
95
|
+
identifier: {
|
|
96
|
+
type: string;
|
|
97
|
+
};
|
|
98
|
+
resourcePath?: string;
|
|
99
|
+
host?: string;
|
|
100
|
+
namespace?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface UpdateRecordUrlOptions {
|
|
103
|
+
op: "updateRecord";
|
|
104
|
+
identifier: {
|
|
105
|
+
type: string;
|
|
106
|
+
id: string;
|
|
107
|
+
};
|
|
108
|
+
resourcePath?: string;
|
|
109
|
+
host?: string;
|
|
110
|
+
namespace?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface DeleteRecordUrlOptions {
|
|
113
|
+
op: "deleteRecord";
|
|
114
|
+
identifier: {
|
|
115
|
+
type: string;
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
118
|
+
resourcePath?: string;
|
|
119
|
+
host?: string;
|
|
120
|
+
namespace?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface GenericUrlOptions {
|
|
123
|
+
resourcePath: string;
|
|
124
|
+
host?: string;
|
|
125
|
+
namespace?: string;
|
|
126
|
+
}
|
|
127
|
+
export type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions;
|
|
128
|
+
/**
|
|
129
|
+
* Builds a URL for a request based on the provided options.
|
|
130
|
+
* Does not include support for building query params (see `buildQueryParams`)
|
|
131
|
+
* so that it may be composed cleanly with other query-params strategies.
|
|
132
|
+
*
|
|
133
|
+
* Usage:
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* import { buildBaseURL } from '@ember-data-mirror/request-utils';
|
|
137
|
+
*
|
|
138
|
+
* const url = buildBaseURL({
|
|
139
|
+
* host: 'https://api.example.com',
|
|
140
|
+
* namespace: 'api/v1',
|
|
141
|
+
* resourcePath: 'emberDevelopers',
|
|
142
|
+
* op: 'query',
|
|
143
|
+
* identifier: { type: 'ember-developer' }
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // => 'https://api.example.com/api/v1/emberDevelopers'
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* On the surface this may seem like a lot of work to do something simple, but
|
|
150
|
+
* it is designed to be composable with other utilities and interfaces that the
|
|
151
|
+
* average product engineer will never need to see or use.
|
|
152
|
+
*
|
|
153
|
+
* A few notes:
|
|
154
|
+
*
|
|
155
|
+
* - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.
|
|
156
|
+
* - `host` and `namespace` are optional, but if they are not provided, the values globally
|
|
157
|
+
* configured via `setBuildURLConfig` will be used.
|
|
158
|
+
* - `op` is required and must be one of the following:
|
|
159
|
+
* - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
|
|
160
|
+
* - Depending on the value of `op`, `identifier` or `identifiers` will be required.
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildBaseURL(urlOptions: UrlOptions): string;
|
|
165
|
+
/**
|
|
166
|
+
* filter out keys of an object that have falsy values or point to empty arrays
|
|
167
|
+
* returning a new object with only those keys that have truthy values / non-empty arrays
|
|
168
|
+
*
|
|
169
|
+
* @public
|
|
170
|
+
* @param source object to filter keys with empty values from
|
|
171
|
+
* @return A new object with the keys that contained empty values removed
|
|
172
|
+
*/
|
|
173
|
+
export declare function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable>;
|
|
174
|
+
/**
|
|
175
|
+
* Sorts query params by both key and value returning a new URLSearchParams
|
|
176
|
+
* object with the keys inserted in sorted order.
|
|
177
|
+
*
|
|
178
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
179
|
+
*
|
|
180
|
+
* Options:
|
|
181
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
182
|
+
*
|
|
183
|
+
* 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`
|
|
184
|
+
* 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`
|
|
185
|
+
* 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
|
|
186
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
* @return A {@link URLSearchParams} with keys inserted in sorted order
|
|
190
|
+
*/
|
|
191
|
+
export declare function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams;
|
|
192
|
+
/**
|
|
193
|
+
* Sorts query params by both key and value, returning a query params string
|
|
194
|
+
*
|
|
195
|
+
* Treats `included` specially, splicing it into an array if it is a string and sorting the array.
|
|
196
|
+
*
|
|
197
|
+
* Options:
|
|
198
|
+
* - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
|
|
199
|
+
*
|
|
200
|
+
* 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`
|
|
201
|
+
* 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`
|
|
202
|
+
* 'repeat': appends the key for every value e.g. `ids=1&ids=2`
|
|
203
|
+
* 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
* @return A sorted query params string without the leading `?`
|
|
207
|
+
*/
|
|
208
|
+
export declare function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { findRecord } from "./-private/json-api/find-record.js";
|
|
2
|
+
export { query, postQuery } from "./-private/json-api/query.js";
|
|
3
|
+
export { deleteRecord, createRecord, updateRecord } from "./-private/json-api/save-record.js";
|
|
4
|
+
export { serializeResources, serializePatch } from "./-private/json-api/serialize.js";
|
|
5
|
+
export { setBuildURLConfig } from "./-private/json-api/-utils.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String utilities for transforming and inflecting strings useful for
|
|
3
|
+
* when the format provided by the server is not the format you want to use
|
|
4
|
+
* in your application.
|
|
5
|
+
*
|
|
6
|
+
* Each transformation function stores its results in an LRUCache to avoid
|
|
7
|
+
* recomputing the same value multiple times. The cache size can be set
|
|
8
|
+
* using the `setMaxLRUCacheSize` function. The default size is 10,000.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export { pluralize, singularize, singular, plural, loadIrregular, loadUncountable, irregular, uncountable, resetToDefaults, clear, clearRules } from "./-private/string/inflect.js";
|
|
14
|
+
export { dasherize, camelize, capitalize, underscore, setMaxLRUCacheSize } from "./-private/string/transform.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Type } from '@warp-drive-mirror/core/types/symbols';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A derivation for use by {@link ReactiveResource} that joins the given fields
|
|
5
|
+
* with the optional separator (or '' if no separator is provided).
|
|
6
|
+
*
|
|
7
|
+
* Generally you should not need to import and use this function directly.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* {
|
|
11
|
+
* name: 'fullName',
|
|
12
|
+
* kind: 'derived',
|
|
13
|
+
* type: 'concat',
|
|
14
|
+
* options: {
|
|
15
|
+
* fields: ['firstName', 'lastName'],
|
|
16
|
+
* separator: ' ',
|
|
17
|
+
* },
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
const concat = (record, options, _prop) => {
|
|
21
|
+
if (!options) {
|
|
22
|
+
throw new Error(`options is required`);
|
|
23
|
+
}
|
|
24
|
+
// SAFETY: we cast internally to a more specific type, for our own use
|
|
25
|
+
// SAFETY: but provide the more general signature to the schema service
|
|
26
|
+
const opts = options;
|
|
27
|
+
return opts.fields.map(field => record[field]).join(opts.separator ?? '');
|
|
28
|
+
};
|
|
29
|
+
concat[Type] = 'concat';
|
|
30
|
+
export { concat };
|