@warp-drive-mirror/utilities 5.8.0-alpha.37 → 5.8.0-alpha.40
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/unpkg/dev/active-record.js +11 -12
- package/dist/unpkg/dev/handlers.js +4 -5
- package/dist/unpkg/dev/index.js +50 -49
- package/dist/unpkg/{prod-deprecated/inflect-BSG696t-.js → dev/inflect-BEv8WqY1.js} +4 -5
- package/dist/unpkg/dev/json-api.js +16 -16
- package/dist/unpkg/dev/rest.js +11 -12
- package/dist/unpkg/dev/string.js +1 -1
- package/dist/unpkg/dev-deprecated/active-record.js +11 -12
- package/dist/unpkg/dev-deprecated/handlers.js +4 -5
- package/dist/unpkg/dev-deprecated/index.js +50 -49
- package/dist/unpkg/dev-deprecated/{inflect-BSG696t-.js → inflect-BEv8WqY1.js} +4 -5
- package/dist/unpkg/dev-deprecated/json-api.js +16 -16
- package/dist/unpkg/dev-deprecated/rest.js +11 -12
- package/dist/unpkg/dev-deprecated/string.js +1 -1
- package/dist/unpkg/prod/active-record.js +1 -30
- package/dist/unpkg/prod/handlers.js +1 -13
- package/dist/unpkg/prod/index.js +2 -124
- package/dist/unpkg/{dev/inflect-BSG696t-.js → prod/inflect-Dh9dyEYx.js} +0 -11
- package/dist/unpkg/prod/json-api.js +2 -40
- package/dist/unpkg/prod/rest.js +1 -30
- package/dist/unpkg/prod/string.js +1 -1
- package/dist/unpkg/prod-deprecated/active-record.js +1 -30
- package/dist/unpkg/prod-deprecated/handlers.js +1 -13
- package/dist/unpkg/prod-deprecated/index.js +2 -124
- package/dist/unpkg/{prod/inflect-BSG696t-.js → prod-deprecated/inflect-Dh9dyEYx.js} +0 -11
- package/dist/unpkg/prod-deprecated/json-api.js +2 -40
- package/dist/unpkg/prod-deprecated/rest.js +1 -30
- package/dist/unpkg/prod-deprecated/string.js +1 -1
- package/package.json +12 -20
- package/dist/unpkg/dev/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/dev/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/dev/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/dev/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/dev/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/dev/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/dev/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/dev/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/dev/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/dev/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/dev/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/dev/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/dev/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/dev/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/dev/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/dev/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/dev/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/dev/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/dev/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/dev/declarations/-private.d.ts +0 -1
- package/dist/unpkg/dev/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/dev/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/dev/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/dev/declarations/index.d.ts +0 -208
- package/dist/unpkg/dev/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/dev/declarations/rest.d.ts +0 -3
- package/dist/unpkg/dev/declarations/string.d.ts +0 -14
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/dev-deprecated/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/dev-deprecated/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/dev-deprecated/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/dev-deprecated/declarations/-private.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/dev-deprecated/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/dev-deprecated/declarations/index.d.ts +0 -208
- package/dist/unpkg/dev-deprecated/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/rest.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/string.d.ts +0 -14
- package/dist/unpkg/prod/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/prod/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/prod/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/prod/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/prod/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/prod/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/prod/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/prod/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/prod/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/prod/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/prod/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/prod/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/prod/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/prod/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/prod/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/prod/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/prod/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/prod/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/prod/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/prod/declarations/-private.d.ts +0 -1
- package/dist/unpkg/prod/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/prod/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/prod/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/prod/declarations/index.d.ts +0 -208
- package/dist/unpkg/prod/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/prod/declarations/rest.d.ts +0 -3
- package/dist/unpkg/prod/declarations/string.d.ts +0 -14
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/prod-deprecated/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/prod-deprecated/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/prod-deprecated/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/prod-deprecated/declarations/-private.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/prod-deprecated/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/prod-deprecated/declarations/index.d.ts +0 -208
- package/dist/unpkg/prod-deprecated/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/rest.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/string.d.ts +0 -14
package/dist/unpkg/prod/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { getOrSetGlobal } from '@warp-drive-mirror/core/types/-private';
|
|
2
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @module
|
|
6
5
|
* @mergeModuleWith <project>
|
|
7
6
|
*/
|
|
8
7
|
|
|
8
|
+
// prevents the final constructed object from needing to add
|
|
9
9
|
// host and namespace which are provided by the final consuming
|
|
10
10
|
// class to the prototype which can result in overwrite errors
|
|
11
|
+
|
|
11
12
|
const CONFIG = getOrSetGlobal('CONFIG', {
|
|
12
13
|
host: '',
|
|
13
14
|
namespace: ''
|
|
@@ -49,47 +50,14 @@ const CONFIG = getOrSetGlobal('CONFIG', {
|
|
|
49
50
|
* @public
|
|
50
51
|
*/
|
|
51
52
|
function setBuildURLConfig(config) {
|
|
52
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
53
|
-
if (!test) {
|
|
54
|
-
throw new Error(`setBuildURLConfig: You must pass a config object`);
|
|
55
|
-
}
|
|
56
|
-
})(config) : {};
|
|
57
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
58
|
-
if (!test) {
|
|
59
|
-
throw new Error(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`);
|
|
60
|
-
}
|
|
61
|
-
})('host' in config || 'namespace' in config) : {};
|
|
62
53
|
CONFIG.host = config.host || '';
|
|
63
54
|
CONFIG.namespace = config.namespace || '';
|
|
64
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
65
|
-
if (!test) {
|
|
66
|
-
throw new Error(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`);
|
|
67
|
-
}
|
|
68
|
-
})(CONFIG.host === '/' || !CONFIG.host.endsWith('/')) : {};
|
|
69
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
70
|
-
if (!test) {
|
|
71
|
-
throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`);
|
|
72
|
-
}
|
|
73
|
-
})(!CONFIG.namespace.startsWith('/')) : {};
|
|
74
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
75
|
-
if (!test) {
|
|
76
|
-
throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`);
|
|
77
|
-
}
|
|
78
|
-
})(!CONFIG.namespace.endsWith('/')) : {};
|
|
79
55
|
}
|
|
80
56
|
const OPERATIONS_WITH_PRIMARY_RECORDS = new Set(['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord']);
|
|
81
57
|
function isOperationWithPrimaryRecord(options) {
|
|
82
58
|
return 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);
|
|
83
59
|
}
|
|
84
|
-
function hasResourcePath(options) {
|
|
85
|
-
return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;
|
|
86
|
-
}
|
|
87
60
|
function resourcePathForType(options) {
|
|
88
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
89
|
-
if (!test) {
|
|
90
|
-
throw new Error(`resourcePathForType: You must pass a valid op as part of options`);
|
|
91
|
-
}
|
|
92
|
-
})('op' in options && typeof options.op === 'string') : {};
|
|
93
61
|
return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;
|
|
94
62
|
}
|
|
95
63
|
|
|
@@ -134,41 +102,6 @@ function buildBaseURL(urlOptions) {
|
|
|
134
102
|
host: CONFIG.host,
|
|
135
103
|
namespace: CONFIG.namespace
|
|
136
104
|
}, urlOptions);
|
|
137
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
138
|
-
if (!test) {
|
|
139
|
-
throw new Error(`buildBaseURL: You must pass \`op\` as part of options`);
|
|
140
|
-
}
|
|
141
|
-
})(hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0) : {};
|
|
142
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
143
|
-
if (!test) {
|
|
144
|
-
throw new Error(`buildBaseURL: You must pass \`identifier\` as part of options`);
|
|
145
|
-
}
|
|
146
|
-
})(hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object') : {};
|
|
147
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
148
|
-
if (!test) {
|
|
149
|
-
throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
|
|
150
|
-
}
|
|
151
|
-
})(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object')) : {};
|
|
152
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
153
|
-
if (!test) {
|
|
154
|
-
throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`);
|
|
155
|
-
}
|
|
156
|
-
})(hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0) : {};
|
|
157
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
158
|
-
if (!test) {
|
|
159
|
-
throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
|
|
160
|
-
}
|
|
161
|
-
})(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0)) : {};
|
|
162
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
163
|
-
if (!test) {
|
|
164
|
-
throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`);
|
|
165
|
-
}
|
|
166
|
-
})(hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0) : {};
|
|
167
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
168
|
-
if (!test) {
|
|
169
|
-
throw new Error(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`);
|
|
170
|
-
}
|
|
171
|
-
})(hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0) : {};
|
|
172
105
|
|
|
173
106
|
// prettier-ignore
|
|
174
107
|
const idPath = isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id) : '';
|
|
@@ -178,56 +111,6 @@ function buildBaseURL(urlOptions) {
|
|
|
178
111
|
namespace
|
|
179
112
|
} = options;
|
|
180
113
|
const fieldPath = 'fieldPath' in options ? options.fieldPath : '';
|
|
181
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
182
|
-
if (!test) {
|
|
183
|
-
throw new Error(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`);
|
|
184
|
-
}
|
|
185
|
-
})(hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op)) : {};
|
|
186
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
187
|
-
if (!test) {
|
|
188
|
-
throw new Error(`buildBaseURL: host must NOT end with '/', received '${host}'`);
|
|
189
|
-
}
|
|
190
|
-
})(host === '/' || !host.endsWith('/')) : {};
|
|
191
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
192
|
-
if (!test) {
|
|
193
|
-
throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`);
|
|
194
|
-
}
|
|
195
|
-
})(!namespace.startsWith('/')) : {};
|
|
196
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
197
|
-
if (!test) {
|
|
198
|
-
throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`);
|
|
199
|
-
}
|
|
200
|
-
})(!namespace.endsWith('/')) : {};
|
|
201
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
202
|
-
if (!test) {
|
|
203
|
-
throw new Error(`buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`);
|
|
204
|
-
}
|
|
205
|
-
})(!resourcePath.startsWith('/')) : {};
|
|
206
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
207
|
-
if (!test) {
|
|
208
|
-
throw new Error(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`);
|
|
209
|
-
}
|
|
210
|
-
})(!resourcePath.endsWith('/')) : {};
|
|
211
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
212
|
-
if (!test) {
|
|
213
|
-
throw new Error(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`);
|
|
214
|
-
}
|
|
215
|
-
})(!fieldPath.startsWith('/')) : {};
|
|
216
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
217
|
-
if (!test) {
|
|
218
|
-
throw new Error(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`);
|
|
219
|
-
}
|
|
220
|
-
})(!fieldPath.endsWith('/')) : {};
|
|
221
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
222
|
-
if (!test) {
|
|
223
|
-
throw new Error(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`);
|
|
224
|
-
}
|
|
225
|
-
})(!idPath.startsWith('/')) : {};
|
|
226
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
227
|
-
if (!test) {
|
|
228
|
-
throw new Error(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`);
|
|
229
|
-
}
|
|
230
|
-
})(!idPath.endsWith('/')) : {};
|
|
231
114
|
const hasHost = host !== '' && host !== '/';
|
|
232
115
|
const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');
|
|
233
116
|
return hasHost ? url : `/${url}`;
|
|
@@ -236,11 +119,6 @@ const DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS = {
|
|
|
236
119
|
arrayFormat: 'comma'
|
|
237
120
|
};
|
|
238
121
|
function handleInclude(include) {
|
|
239
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
240
|
-
if (!test) {
|
|
241
|
-
throw new Error(`Expected include to be a string or array, got ${typeof include}`);
|
|
242
|
-
}
|
|
243
|
-
})(typeof include === 'string' || Array.isArray(include)) : {};
|
|
244
122
|
return typeof include === 'string' ? include.split(',') : include;
|
|
245
123
|
}
|
|
246
124
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LRUCache, dasherize as dasherize$1, STRING_DASHERIZE_CACHE } from '@warp-drive-mirror/core/utils/string';
|
|
2
2
|
import { InflectionRuleDefaults as defaultRules } from './-private.js';
|
|
3
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
3
|
|
|
5
4
|
// eslint-disable-next-line no-useless-escape
|
|
6
5
|
const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
|
|
@@ -231,11 +230,6 @@ function clearRules() {
|
|
|
231
230
|
* @since 4.13.0
|
|
232
231
|
*/
|
|
233
232
|
function singularize(word) {
|
|
234
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
235
|
-
if (!test) {
|
|
236
|
-
throw new Error(`singularize expects to receive a non-empty string`);
|
|
237
|
-
}
|
|
238
|
-
})(typeof word === 'string' && word.length > 0) : {};
|
|
239
233
|
if (!word) return '';
|
|
240
234
|
return SINGULARS.get(word);
|
|
241
235
|
}
|
|
@@ -247,11 +241,6 @@ function singularize(word) {
|
|
|
247
241
|
* @since 4.13.0
|
|
248
242
|
*/
|
|
249
243
|
function pluralize(word) {
|
|
250
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
251
|
-
if (!test) {
|
|
252
|
-
throw new Error(`pluralize expects to receive a non-empty string`);
|
|
253
|
-
}
|
|
254
|
-
})(typeof word === 'string' && word.length > 0) : {};
|
|
255
244
|
if (!word) return '';
|
|
256
245
|
return PLURALS.get(word);
|
|
257
246
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { setBuildURLConfig as setBuildURLConfig$1, buildBaseURL, buildQueryParams } from './index.js';
|
|
2
|
-
import { p as pluralize } from "./inflect-
|
|
2
|
+
import { p as pluralize } from "./inflect-Dh9dyEYx.js";
|
|
3
3
|
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
4
|
import { recordIdentifierFor } from '@warp-drive-mirror/core';
|
|
5
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
5
|
const JsonApiAccept = 'application/vnd.api+json';
|
|
7
6
|
const DEFAULT_CONFIG = {
|
|
8
7
|
host: '',
|
|
@@ -321,9 +320,6 @@ query = {}, options = {}) {
|
|
|
321
320
|
op: 'query'
|
|
322
321
|
};
|
|
323
322
|
}
|
|
324
|
-
function isExisting(identifier) {
|
|
325
|
-
return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;
|
|
326
|
-
}
|
|
327
323
|
|
|
328
324
|
/**
|
|
329
325
|
* :::warning ⚠️ **These Mutation Builders DO NOT Set The Request Body**
|
|
@@ -382,16 +378,6 @@ function isExisting(identifier) {
|
|
|
382
378
|
|
|
383
379
|
function deleteRecord(record, options = {}) {
|
|
384
380
|
const identifier = recordIdentifierFor(record);
|
|
385
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
386
|
-
if (!test) {
|
|
387
|
-
throw new Error(`Expected to be given a record instance`);
|
|
388
|
-
}
|
|
389
|
-
})(identifier) : {};
|
|
390
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
391
|
-
if (!test) {
|
|
392
|
-
throw new Error(`Cannot delete a record that does not have an associated type and id.`);
|
|
393
|
-
}
|
|
394
|
-
})(isExisting(identifier)) : {};
|
|
395
381
|
const urlOptions = {
|
|
396
382
|
identifier: identifier,
|
|
397
383
|
op: 'deleteRecord',
|
|
@@ -470,11 +456,6 @@ function deleteRecord(record, options = {}) {
|
|
|
470
456
|
|
|
471
457
|
function createRecord(record, options = {}) {
|
|
472
458
|
const identifier = recordIdentifierFor(record);
|
|
473
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
474
|
-
if (!test) {
|
|
475
|
-
throw new Error(`Expected to be given a record instance`);
|
|
476
|
-
}
|
|
477
|
-
})(identifier) : {};
|
|
478
459
|
const urlOptions = {
|
|
479
460
|
identifier: identifier,
|
|
480
461
|
op: 'createRecord',
|
|
@@ -556,16 +537,6 @@ function createRecord(record, options = {}) {
|
|
|
556
537
|
|
|
557
538
|
function updateRecord(record, options = {}) {
|
|
558
539
|
const identifier = recordIdentifierFor(record);
|
|
559
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
560
|
-
if (!test) {
|
|
561
|
-
throw new Error(`Expected to be given a record instance`);
|
|
562
|
-
}
|
|
563
|
-
})(identifier) : {};
|
|
564
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
565
|
-
if (!test) {
|
|
566
|
-
throw new Error(`Cannot update a record that does not have an associated type and id.`);
|
|
567
|
-
}
|
|
568
|
-
})(isExisting(identifier)) : {};
|
|
569
540
|
const urlOptions = {
|
|
570
541
|
identifier: identifier,
|
|
571
542
|
op: 'updateRecord',
|
|
@@ -602,6 +573,7 @@ function updateRecord(record, options = {}) {
|
|
|
602
573
|
* @param {ResourceKey} identifier
|
|
603
574
|
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
604
575
|
*/
|
|
576
|
+
|
|
605
577
|
function serializeResources(cache, identifiers) {
|
|
606
578
|
return {
|
|
607
579
|
data: Array.isArray(identifiers) ? identifiers.map(identifier => _serializeResource(cache, identifier)) : _serializeResource(cache, identifiers)
|
|
@@ -641,11 +613,6 @@ function _serializeResource(cache, identifier) {
|
|
|
641
613
|
// peek gives us everything we want, but since its referentially the same data
|
|
642
614
|
// as is in the cache we clone it to avoid any accidental mutations
|
|
643
615
|
const record = structuredClone(cache.peek(identifier));
|
|
644
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
645
|
-
if (!test) {
|
|
646
|
-
throw new Error(`A record with id ${String(id)} and type ${type} for lid ${lid} was not found not in the supplied Cache.`);
|
|
647
|
-
}
|
|
648
|
-
})(record) : {};
|
|
649
616
|
|
|
650
617
|
// remove lid from anything that has an ID and slice any relationship arrays
|
|
651
618
|
if (record.id !== null) {
|
|
@@ -700,11 +667,6 @@ function serializePatch(cache, identifier) {
|
|
|
700
667
|
lid,
|
|
701
668
|
type
|
|
702
669
|
} = identifier;
|
|
703
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
704
|
-
if (!test) {
|
|
705
|
-
throw new Error(`A record with id ${String(id)} and type ${type} for lid ${lid} was not found not in the supplied Cache.`);
|
|
706
|
-
}
|
|
707
|
-
})(cache.peek(identifier)) : {};
|
|
708
670
|
const data = id === null ? {
|
|
709
671
|
type,
|
|
710
672
|
lid,
|
package/dist/unpkg/prod/rest.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { buildBaseURL, buildQueryParams } from './index.js';
|
|
2
|
-
import { p as pluralize, g as camelize } from "./inflect-
|
|
2
|
+
import { p as pluralize, g as camelize } from "./inflect-Dh9dyEYx.js";
|
|
3
3
|
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
4
|
import { recordIdentifierFor } from '@warp-drive-mirror/core';
|
|
5
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Builds request options to fetch a single resource by a known id or identifier
|
|
@@ -160,9 +159,6 @@ query = {}, options = {}) {
|
|
|
160
159
|
op: 'query'
|
|
161
160
|
};
|
|
162
161
|
}
|
|
163
|
-
function isExisting(identifier) {
|
|
164
|
-
return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;
|
|
165
|
-
}
|
|
166
162
|
|
|
167
163
|
/**
|
|
168
164
|
* Builds request options to delete record for resources,
|
|
@@ -216,16 +212,6 @@ function isExisting(identifier) {
|
|
|
216
212
|
|
|
217
213
|
function deleteRecord(record, options = {}) {
|
|
218
214
|
const identifier = recordIdentifierFor(record);
|
|
219
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
220
|
-
if (!test) {
|
|
221
|
-
throw new Error(`Expected to be given a record instance`);
|
|
222
|
-
}
|
|
223
|
-
})(identifier) : {};
|
|
224
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
225
|
-
if (!test) {
|
|
226
|
-
throw new Error(`Cannot delete a record that does not have an associated type and id.`);
|
|
227
|
-
}
|
|
228
|
-
})(isExisting(identifier)) : {};
|
|
229
215
|
const urlOptions = {
|
|
230
216
|
identifier: identifier,
|
|
231
217
|
op: 'deleteRecord',
|
|
@@ -289,11 +275,6 @@ function deleteRecord(record, options = {}) {
|
|
|
289
275
|
|
|
290
276
|
function createRecord(record, options = {}) {
|
|
291
277
|
const identifier = recordIdentifierFor(record);
|
|
292
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
293
|
-
if (!test) {
|
|
294
|
-
throw new Error(`Expected to be given a record instance`);
|
|
295
|
-
}
|
|
296
|
-
})(identifier) : {};
|
|
297
278
|
const urlOptions = {
|
|
298
279
|
identifier: identifier,
|
|
299
280
|
op: 'createRecord',
|
|
@@ -360,16 +341,6 @@ function createRecord(record, options = {}) {
|
|
|
360
341
|
|
|
361
342
|
function updateRecord(record, options = {}) {
|
|
362
343
|
const identifier = recordIdentifierFor(record);
|
|
363
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
364
|
-
if (!test) {
|
|
365
|
-
throw new Error(`Expected to be given a record instance`);
|
|
366
|
-
}
|
|
367
|
-
})(identifier) : {};
|
|
368
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
369
|
-
if (!test) {
|
|
370
|
-
throw new Error(`Cannot update a record that does not have an associated type and id.`);
|
|
371
|
-
}
|
|
372
|
-
})(isExisting(identifier)) : {};
|
|
373
344
|
const urlOptions = {
|
|
374
345
|
identifier: identifier,
|
|
375
346
|
op: 'updateRecord',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { g as camelize, h as capitalize, d as clear, e as clearRules, f as dasherize, i as irregular, l as loadIrregular, c as loadUncountable, b as plural, p as pluralize, r as resetToDefaults, k as setMaxLRUCacheSize, a as singular, s as singularize, u as uncountable, j as underscore } from "./inflect-
|
|
1
|
+
export { g as camelize, h as capitalize, d as clear, e as clearRules, f as dasherize, i as irregular, l as loadIrregular, c as loadUncountable, b as plural, p as pluralize, r as resetToDefaults, k as setMaxLRUCacheSize, a as singular, s as singularize, u as uncountable, j as underscore } from "./inflect-Dh9dyEYx.js";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { buildBaseURL, buildQueryParams } from './index.js';
|
|
2
|
-
import { p as pluralize, j as underscore } from "./inflect-
|
|
2
|
+
import { p as pluralize, j as underscore } from "./inflect-Dh9dyEYx.js";
|
|
3
3
|
import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
|
|
4
4
|
import { recordIdentifierFor } from '@warp-drive-mirror/core';
|
|
5
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Builds request options to fetch a single resource by a known id or identifier
|
|
@@ -162,9 +161,6 @@ query = {}, options = {}) {
|
|
|
162
161
|
op: 'query'
|
|
163
162
|
};
|
|
164
163
|
}
|
|
165
|
-
function isExisting(identifier) {
|
|
166
|
-
return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;
|
|
167
|
-
}
|
|
168
164
|
|
|
169
165
|
/**
|
|
170
166
|
* Builds request options to delete record for resources,
|
|
@@ -218,16 +214,6 @@ function isExisting(identifier) {
|
|
|
218
214
|
|
|
219
215
|
function deleteRecord(record, options = {}) {
|
|
220
216
|
const identifier = recordIdentifierFor(record);
|
|
221
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
222
|
-
if (!test) {
|
|
223
|
-
throw new Error(`Expected to be given a record instance`);
|
|
224
|
-
}
|
|
225
|
-
})(identifier) : {};
|
|
226
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
227
|
-
if (!test) {
|
|
228
|
-
throw new Error(`Cannot delete a record that does not have an associated type and id.`);
|
|
229
|
-
}
|
|
230
|
-
})(isExisting(identifier)) : {};
|
|
231
217
|
const urlOptions = {
|
|
232
218
|
identifier: identifier,
|
|
233
219
|
op: 'deleteRecord',
|
|
@@ -291,11 +277,6 @@ function deleteRecord(record, options = {}) {
|
|
|
291
277
|
|
|
292
278
|
function createRecord(record, options = {}) {
|
|
293
279
|
const identifier = recordIdentifierFor(record);
|
|
294
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
295
|
-
if (!test) {
|
|
296
|
-
throw new Error(`Expected to be given a record instance`);
|
|
297
|
-
}
|
|
298
|
-
})(identifier) : {};
|
|
299
280
|
const urlOptions = {
|
|
300
281
|
identifier: identifier,
|
|
301
282
|
op: 'createRecord',
|
|
@@ -362,16 +343,6 @@ function createRecord(record, options = {}) {
|
|
|
362
343
|
|
|
363
344
|
function updateRecord(record, options = {}) {
|
|
364
345
|
const identifier = recordIdentifierFor(record);
|
|
365
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
366
|
-
if (!test) {
|
|
367
|
-
throw new Error(`Expected to be given a record instance`);
|
|
368
|
-
}
|
|
369
|
-
})(identifier) : {};
|
|
370
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
371
|
-
if (!test) {
|
|
372
|
-
throw new Error(`Cannot update a record that does not have an associated type and id.`);
|
|
373
|
-
}
|
|
374
|
-
})(isExisting(identifier)) : {};
|
|
375
346
|
const urlOptions = {
|
|
376
347
|
identifier: identifier,
|
|
377
348
|
op: 'updateRecord',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
1
|
function isCompressibleMethod(method) {
|
|
3
2
|
return method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE';
|
|
4
3
|
}
|
|
@@ -144,11 +143,6 @@ function encodingForFormat(format) {
|
|
|
144
143
|
case 'deflate-raw':
|
|
145
144
|
return format;
|
|
146
145
|
default:
|
|
147
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
148
|
-
{
|
|
149
|
-
throw new Error(`Unsupported compression format: ${format}`);
|
|
150
|
-
}
|
|
151
|
-
})() : {};
|
|
152
146
|
// @ts-expect-error - unreachable code is reachable in production
|
|
153
147
|
return format;
|
|
154
148
|
}
|
|
@@ -307,11 +301,5 @@ const MAX_URL_LENGTH = 8192;
|
|
|
307
301
|
*
|
|
308
302
|
* @group Utility Functions
|
|
309
303
|
*/
|
|
310
|
-
function assertInvalidUrlLength(url) {
|
|
311
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
312
|
-
if (!test) {
|
|
313
|
-
throw new Error(`URL length ${url?.length} exceeds the maximum URL length of ${MAX_URL_LENGTH} bytes.\n\nConsider converting this request query a \`/query\` endpoint instead of a GET, or upgrade the current endpoint to be able to receive a POST request directly (ideally specifying the header HTTP-Method-Override: QUERY)\n\nThe Invalid URL is:\n\n${url}`);
|
|
314
|
-
}
|
|
315
|
-
})(!url || url.length <= MAX_URL_LENGTH) : {};
|
|
316
|
-
}
|
|
304
|
+
function assertInvalidUrlLength(url) {}
|
|
317
305
|
export { AutoCompress, Gate, MAX_URL_LENGTH, MetaDocHandler, SupportsRequestStreams, TAB_ASSIGNED, TAB_ID, addTraceHeader, assertInvalidUrlLength };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { getOrSetGlobal } from '@warp-drive-mirror/core/types/-private';
|
|
2
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @module
|
|
6
5
|
* @mergeModuleWith <project>
|
|
7
6
|
*/
|
|
8
7
|
|
|
8
|
+
// prevents the final constructed object from needing to add
|
|
9
9
|
// host and namespace which are provided by the final consuming
|
|
10
10
|
// class to the prototype which can result in overwrite errors
|
|
11
|
+
|
|
11
12
|
const CONFIG = getOrSetGlobal('CONFIG', {
|
|
12
13
|
host: '',
|
|
13
14
|
namespace: ''
|
|
@@ -49,47 +50,14 @@ const CONFIG = getOrSetGlobal('CONFIG', {
|
|
|
49
50
|
* @public
|
|
50
51
|
*/
|
|
51
52
|
function setBuildURLConfig(config) {
|
|
52
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
53
|
-
if (!test) {
|
|
54
|
-
throw new Error(`setBuildURLConfig: You must pass a config object`);
|
|
55
|
-
}
|
|
56
|
-
})(config) : {};
|
|
57
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
58
|
-
if (!test) {
|
|
59
|
-
throw new Error(`setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`);
|
|
60
|
-
}
|
|
61
|
-
})('host' in config || 'namespace' in config) : {};
|
|
62
53
|
CONFIG.host = config.host || '';
|
|
63
54
|
CONFIG.namespace = config.namespace || '';
|
|
64
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
65
|
-
if (!test) {
|
|
66
|
-
throw new Error(`buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`);
|
|
67
|
-
}
|
|
68
|
-
})(CONFIG.host === '/' || !CONFIG.host.endsWith('/')) : {};
|
|
69
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
70
|
-
if (!test) {
|
|
71
|
-
throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`);
|
|
72
|
-
}
|
|
73
|
-
})(!CONFIG.namespace.startsWith('/')) : {};
|
|
74
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
75
|
-
if (!test) {
|
|
76
|
-
throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`);
|
|
77
|
-
}
|
|
78
|
-
})(!CONFIG.namespace.endsWith('/')) : {};
|
|
79
55
|
}
|
|
80
56
|
const OPERATIONS_WITH_PRIMARY_RECORDS = new Set(['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord']);
|
|
81
57
|
function isOperationWithPrimaryRecord(options) {
|
|
82
58
|
return 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);
|
|
83
59
|
}
|
|
84
|
-
function hasResourcePath(options) {
|
|
85
|
-
return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;
|
|
86
|
-
}
|
|
87
60
|
function resourcePathForType(options) {
|
|
88
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
89
|
-
if (!test) {
|
|
90
|
-
throw new Error(`resourcePathForType: You must pass a valid op as part of options`);
|
|
91
|
-
}
|
|
92
|
-
})('op' in options && typeof options.op === 'string') : {};
|
|
93
61
|
return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;
|
|
94
62
|
}
|
|
95
63
|
|
|
@@ -134,41 +102,6 @@ function buildBaseURL(urlOptions) {
|
|
|
134
102
|
host: CONFIG.host,
|
|
135
103
|
namespace: CONFIG.namespace
|
|
136
104
|
}, urlOptions);
|
|
137
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
138
|
-
if (!test) {
|
|
139
|
-
throw new Error(`buildBaseURL: You must pass \`op\` as part of options`);
|
|
140
|
-
}
|
|
141
|
-
})(hasResourcePath(options) || typeof options.op === 'string' && options.op.length > 0) : {};
|
|
142
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
143
|
-
if (!test) {
|
|
144
|
-
throw new Error(`buildBaseURL: You must pass \`identifier\` as part of options`);
|
|
145
|
-
}
|
|
146
|
-
})(hasResourcePath(options) || options.op === 'findMany' || options.identifier && typeof options.identifier === 'object') : {};
|
|
147
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
148
|
-
if (!test) {
|
|
149
|
-
throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
|
|
150
|
-
}
|
|
151
|
-
})(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers && Array.isArray(options.identifiers) && options.identifiers.length > 0 && options.identifiers.every(i => i && typeof i === 'object')) : {};
|
|
152
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
153
|
-
if (!test) {
|
|
154
|
-
throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'id'`);
|
|
155
|
-
}
|
|
156
|
-
})(hasResourcePath(options) || !isOperationWithPrimaryRecord(options) || typeof options.identifier.id === 'string' && options.identifier.id.length > 0) : {};
|
|
157
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
158
|
-
if (!test) {
|
|
159
|
-
throw new Error(`buildBaseURL: You must pass \`identifiers\` as part of options`);
|
|
160
|
-
}
|
|
161
|
-
})(hasResourcePath(options) || options.op !== 'findMany' || options.identifiers.every(i => typeof i.id === 'string' && i.id.length > 0)) : {};
|
|
162
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
163
|
-
if (!test) {
|
|
164
|
-
throw new Error(`buildBaseURL: You must pass valid \`identifier\` as part of options, expected 'type'`);
|
|
165
|
-
}
|
|
166
|
-
})(hasResourcePath(options) || options.op === 'findMany' || typeof options.identifier.type === 'string' && options.identifier.type.length > 0) : {};
|
|
167
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
168
|
-
if (!test) {
|
|
169
|
-
throw new Error(`buildBaseURL: You must pass valid \`identifiers\` as part of options, expected 'type'`);
|
|
170
|
-
}
|
|
171
|
-
})(hasResourcePath(options) || options.op !== 'findMany' || typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0) : {};
|
|
172
105
|
|
|
173
106
|
// prettier-ignore
|
|
174
107
|
const idPath = isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id) : '';
|
|
@@ -178,56 +111,6 @@ function buildBaseURL(urlOptions) {
|
|
|
178
111
|
namespace
|
|
179
112
|
} = options;
|
|
180
113
|
const fieldPath = 'fieldPath' in options ? options.fieldPath : '';
|
|
181
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
182
|
-
if (!test) {
|
|
183
|
-
throw new Error(`buildBaseURL: You tried to build a url for a ${String('op' in options ? options.op + ' ' : '')}request to ${resourcePath} but resourcePath must be set or op must be one of "${['findRecord', 'findRelatedRecord', 'findRelatedCollection', 'updateRecord', 'deleteRecord', 'createRecord', 'query', 'findMany'].join('","')}".`);
|
|
184
|
-
}
|
|
185
|
-
})(hasResourcePath(options) || ['findRecord', 'query', 'findMany', 'findRelatedCollection', 'findRelatedRecord', 'createRecord', 'updateRecord', 'deleteRecord'].includes(options.op)) : {};
|
|
186
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
187
|
-
if (!test) {
|
|
188
|
-
throw new Error(`buildBaseURL: host must NOT end with '/', received '${host}'`);
|
|
189
|
-
}
|
|
190
|
-
})(host === '/' || !host.endsWith('/')) : {};
|
|
191
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
192
|
-
if (!test) {
|
|
193
|
-
throw new Error(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`);
|
|
194
|
-
}
|
|
195
|
-
})(!namespace.startsWith('/')) : {};
|
|
196
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
197
|
-
if (!test) {
|
|
198
|
-
throw new Error(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`);
|
|
199
|
-
}
|
|
200
|
-
})(!namespace.endsWith('/')) : {};
|
|
201
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
202
|
-
if (!test) {
|
|
203
|
-
throw new Error(`buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`);
|
|
204
|
-
}
|
|
205
|
-
})(!resourcePath.startsWith('/')) : {};
|
|
206
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
207
|
-
if (!test) {
|
|
208
|
-
throw new Error(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`);
|
|
209
|
-
}
|
|
210
|
-
})(!resourcePath.endsWith('/')) : {};
|
|
211
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
212
|
-
if (!test) {
|
|
213
|
-
throw new Error(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`);
|
|
214
|
-
}
|
|
215
|
-
})(!fieldPath.startsWith('/')) : {};
|
|
216
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
217
|
-
if (!test) {
|
|
218
|
-
throw new Error(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`);
|
|
219
|
-
}
|
|
220
|
-
})(!fieldPath.endsWith('/')) : {};
|
|
221
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
222
|
-
if (!test) {
|
|
223
|
-
throw new Error(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`);
|
|
224
|
-
}
|
|
225
|
-
})(!idPath.startsWith('/')) : {};
|
|
226
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
227
|
-
if (!test) {
|
|
228
|
-
throw new Error(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`);
|
|
229
|
-
}
|
|
230
|
-
})(!idPath.endsWith('/')) : {};
|
|
231
114
|
const hasHost = host !== '' && host !== '/';
|
|
232
115
|
const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');
|
|
233
116
|
return hasHost ? url : `/${url}`;
|
|
@@ -236,11 +119,6 @@ const DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS = {
|
|
|
236
119
|
arrayFormat: 'comma'
|
|
237
120
|
};
|
|
238
121
|
function handleInclude(include) {
|
|
239
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
240
|
-
if (!test) {
|
|
241
|
-
throw new Error(`Expected include to be a string or array, got ${typeof include}`);
|
|
242
|
-
}
|
|
243
|
-
})(typeof include === 'string' || Array.isArray(include)) : {};
|
|
244
122
|
return typeof include === 'string' ? include.split(',') : include;
|
|
245
123
|
}
|
|
246
124
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LRUCache, dasherize as dasherize$1, STRING_DASHERIZE_CACHE } from '@warp-drive-mirror/core/utils/string';
|
|
2
2
|
import { InflectionRuleDefaults as defaultRules } from './-private.js';
|
|
3
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
3
|
|
|
5
4
|
// eslint-disable-next-line no-useless-escape
|
|
6
5
|
const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
|
|
@@ -231,11 +230,6 @@ function clearRules() {
|
|
|
231
230
|
* @since 4.13.0
|
|
232
231
|
*/
|
|
233
232
|
function singularize(word) {
|
|
234
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
235
|
-
if (!test) {
|
|
236
|
-
throw new Error(`singularize expects to receive a non-empty string`);
|
|
237
|
-
}
|
|
238
|
-
})(typeof word === 'string' && word.length > 0) : {};
|
|
239
233
|
if (!word) return '';
|
|
240
234
|
return SINGULARS.get(word);
|
|
241
235
|
}
|
|
@@ -247,11 +241,6 @@ function singularize(word) {
|
|
|
247
241
|
* @since 4.13.0
|
|
248
242
|
*/
|
|
249
243
|
function pluralize(word) {
|
|
250
|
-
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
|
|
251
|
-
if (!test) {
|
|
252
|
-
throw new Error(`pluralize expects to receive a non-empty string`);
|
|
253
|
-
}
|
|
254
|
-
})(typeof word === 'string' && word.length > 0) : {};
|
|
255
244
|
if (!word) return '';
|
|
256
245
|
return PLURALS.get(word);
|
|
257
246
|
}
|