@ember-data-mirror/request 5.6.0-alpha.15 → 5.6.0-alpha.18

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/fetch.js CHANGED
@@ -1,2 +1 @@
1
1
  export { Fetch as default } from '@warp-drive-mirror/core';
2
- //# sourceMappingURL=fetch.js.map
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from '@warp-drive-mirror/core/request';
2
2
  export { RequestManager as default } from '@warp-drive-mirror/core';
3
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-data-mirror/request",
3
3
  "description": "⚡️ A simple, small and fast framework-agnostic library to make `fetch` happen",
4
- "version": "5.6.0-alpha.15",
4
+ "version": "5.6.0-alpha.18",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -36,15 +36,15 @@
36
36
  "peerDependencies": {},
37
37
  "dependencies": {
38
38
  "@embroider/macros": "^1.16.12",
39
- "@warp-drive-mirror/core": "5.6.0-alpha.15"
39
+ "@warp-drive-mirror/core": "5.6.0-alpha.18"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@babel/core": "^7.26.10",
43
43
  "@babel/plugin-transform-typescript": "^7.27.0",
44
44
  "@babel/preset-env": "^7.26.9",
45
45
  "@babel/preset-typescript": "^7.27.0",
46
- "@warp-drive/internal-config": "5.6.0-alpha.15",
47
- "vite": "^5.4.15"
46
+ "@warp-drive/internal-config": "5.6.0-alpha.18",
47
+ "vite": "^7.0.0"
48
48
  },
49
49
  "volta": {
50
50
  "extends": "../../../../../../package.json"
@@ -1,29 +1,29 @@
1
1
  declare module '@ember-data-mirror/request/fetch' {
2
2
  /**
3
- * A basic Fetch Handler which converts a request into a
4
- * `fetch` call presuming the response to be `json`.
5
- *
6
- * ```ts
7
- * import Fetch from '@ember-data-mirror/request/fetch';
8
- *
9
- * manager.use([Fetch]);
10
- * ```
11
- *
12
- * @module
13
- */
3
+ * A basic Fetch Handler which converts a request into a
4
+ * `fetch` call presuming the response to be `json`.
5
+ *
6
+ * ```ts
7
+ * import Fetch from '@ember-data-mirror/request/fetch';
8
+ *
9
+ * manager.use([Fetch]);
10
+ * ```
11
+ *
12
+ * @module
13
+ */
14
14
  /**
15
- * A basic handler which converts a request into a
16
- * `fetch` call presuming the response to be `json`.
17
- *
18
- * ```ts
19
- * import Fetch from '@ember-data-mirror/request/fetch';
20
- *
21
- * manager.use([Fetch]);
22
- * ```
23
- *
24
- * @class Fetch
25
- * @public
26
- */
27
- export { Fetch as default } from '@warp-drive-mirror/core';
28
- }
29
- //# sourceMappingURL=fetch.d.ts.map
15
+ * A basic handler which converts a request into a
16
+ * `fetch` call presuming the response to be `json`.
17
+ *
18
+ * ```ts
19
+ * import Fetch from '@ember-data-mirror/request/fetch';
20
+ *
21
+ * manager.use([Fetch]);
22
+ * ```
23
+ *
24
+ * @class Fetch
25
+ * @public
26
+ */
27
+ export { Fetch as default } from "@warp-drive-mirror/core";
28
+
29
+ }
@@ -1,15 +1,15 @@
1
1
  /// <reference path="./fetch.d.ts" />
2
2
  declare module '@ember-data-mirror/request' {
3
3
  /**
4
- *
5
- <p align="center">
6
- <img
7
- class="project-logo"
8
- src="https://raw.githubusercontent.com/emberjs/data/4612c9354e4c54d53327ec2cf21955075ce21294/ember-data-logo-light.svg#gh-light-mode-only"
9
- alt="EmberData RequestManager"
10
- width="240px"
11
- title="EmberData RequestManager"
12
- />
4
+ *
5
+ <p align="center">
6
+ <img
7
+ class="project-logo"
8
+ src="https://raw.githubusercontent.com/emberjs/data/4612c9354e4c54d53327ec2cf21955075ce21294/ember-data-logo-light.svg#gh-light-mode-only"
9
+ alt="EmberData RequestManager"
10
+ width="240px"
11
+ title="EmberData RequestManager"
12
+ />
13
13
  </p>
14
14
 
15
15
  <p align="center">⚡️ a simple abstraction over fetch to enable easy management of request/response flows</p>
@@ -20,16 +20,16 @@ declare module '@ember-data-mirror/request' {
20
20
  - [Basic Usage](#🚀-basic-usage)
21
21
  - [Architecture](#🪜-architecture)
22
22
  - [Usage](#usage)
23
- - [Making Requests](#making-requests)
24
- - [Using The Response](#using-the-response)
25
- - [Request Handlers](#handling-requests)
26
- - [Handling Errors](#handling-errors)
27
- - [Handling Abort](#handling-abort)
28
- - [Stream Currying](#stream-currying)
29
- - [Automatic Currying](#automatic-currying-of-stream-and-response)
30
- - [Using as a Service](#using-as-a-service)
31
- - [Using with `@ember-data-mirror/store`](#using-with-ember-datastore)
32
- - [Using with `ember-data`](#using-with-ember-data)
23
+ - [Making Requests](#making-requests)
24
+ - [Using The Response](#using-the-response)
25
+ - [Request Handlers](#handling-requests)
26
+ - [Handling Errors](#handling-errors)
27
+ - [Handling Abort](#handling-abort)
28
+ - [Stream Currying](#stream-currying)
29
+ - [Automatic Currying](#automatic-currying-of-stream-and-response)
30
+ - [Using as a Service](#using-as-a-service)
31
+ - [Using with `@ember-data-mirror/store`](#using-with-ember-datastore)
32
+ - [Using with `ember-data`](#using-with-ember-data)
33
33
 
34
34
  ---
35
35
 
@@ -56,11 +56,11 @@ declare module '@ember-data-mirror/request' {
56
56
 
57
57
  // ... create manager and add our Fetch handler
58
58
  const manager = new RequestManager()
59
- .use([Fetch]);
59
+ .use([Fetch]);
60
60
 
61
61
  // ... execute a request
62
62
  const response = await manager.request({
63
- url: `${apiUrl}/users`
63
+ url: `${apiUrl}/users`
64
64
  });
65
65
  ```
66
66
 
@@ -84,7 +84,7 @@ declare module '@ember-data-mirror/request' {
84
84
 
85
85
  ```ts
86
86
  const userList = await manager.request({
87
- url: `/api/v1/users.list`
87
+ url: `/api/v1/users.list`
88
88
  });
89
89
 
90
90
  const users = userList.content;
@@ -98,7 +98,7 @@ declare module '@ember-data-mirror/request' {
98
98
 
99
99
  ```ts
100
100
  class RequestManager {
101
- request<T>(req: RequestInfo): Future<T>;
101
+ request<T>(req: RequestInfo): Future<T>;
102
102
  }
103
103
  ```
104
104
 
@@ -109,17 +109,17 @@ declare module '@ember-data-mirror/request' {
109
109
 
110
110
  ```ts
111
111
  interface RequestInfo extends FetchOptions {
112
- op?: string;
113
- store?: Store;
112
+ op?: string;
113
+ store?: Store;
114
114
 
115
- url: string;
116
- // data that a handler should convert into
117
- // the query (GET) or body (POST)
118
- data?: Record<string, unknown>;
115
+ url: string;
116
+ // data that a handler should convert into
117
+ // the query (GET) or body (POST)
118
+ data?: Record<string, unknown>;
119
119
 
120
- // options specifically intended for handlers
121
- // to utilize to process the request
122
- options?: Record<string, unknown>;
120
+ // options specifically intended for handlers
121
+ // to utilize to process the request
122
+ options?: Record<string, unknown>;
123
123
  }
124
124
  ```
125
125
 
@@ -134,7 +134,7 @@ declare module '@ember-data-mirror/request' {
134
134
 
135
135
  ```ts
136
136
  const usersFuture = manager.request({
137
- url: `/api/v1/users.list`
137
+ url: `/api/v1/users.list`
138
138
  });
139
139
  ```
140
140
 
@@ -148,9 +148,9 @@ declare module '@ember-data-mirror/request' {
148
148
 
149
149
  ```ts
150
150
  interface Future<T> extends Promise<StructuredDocument<T>> {
151
- abort(): void;
151
+ abort(): void;
152
152
 
153
- async getStream(): ReadableStream | null;
153
+ async getStream(): ReadableStream | null;
154
154
  }
155
155
  ```
156
156
 
@@ -158,10 +158,10 @@ declare module '@ember-data-mirror/request' {
158
158
 
159
159
  ```ts
160
160
  interface StructuredDocument<T> {
161
- request: RequestInfo;
162
- response: ResponseInfo | null;
163
- content?: T;
164
- error?: Error;
161
+ request: RequestInfo;
162
+ response: ResponseInfo | null;
163
+ content?: T;
164
+ error?: Error;
165
165
  }
166
166
  ```
167
167
 
@@ -171,13 +171,13 @@ declare module '@ember-data-mirror/request' {
171
171
 
172
172
  ```ts
173
173
  interface ResponseInfo {
174
- headers?: Record<string, string>;
175
- ok?: boolean;
176
- redirected?: boolean;
177
- status?: HTTPStatusCode;
178
- statusText?: string;
179
- type?: 'basic' | 'cors';
180
- url?: string;
174
+ headers?: Record<string, string>;
175
+ ok?: boolean;
176
+ redirected?: boolean;
177
+ status?: HTTPStatusCode;
178
+ statusText?: string;
179
+ type?: 'basic' | 'cors';
180
+ url?: string;
181
181
  }
182
182
  ```
183
183
 
@@ -200,7 +200,7 @@ declare module '@ember-data-mirror/request' {
200
200
  type NextFn<P> = (req: RequestInfo) => Future<P>;
201
201
 
202
202
  interface Handler {
203
- async request<T>(context: RequestContext, next: NextFn<P>): T;
203
+ async request<T>(context: RequestContext, next: NextFn<P>): T;
204
204
  }
205
205
  ```
206
206
 
@@ -208,10 +208,10 @@ declare module '@ember-data-mirror/request' {
208
208
 
209
209
  ```ts
210
210
  interface RequestContext<T> {
211
- readonly request: RequestInfo;
211
+ readonly request: RequestInfo;
212
212
 
213
- setStream(stream: ReadableStream | Promise<ReadableStream>): void;
214
- setResponse(response: Response | ResponseInfo): void;
213
+ setStream(stream: ReadableStream | Promise<ReadableStream>): void;
214
+ setResponse(response: Response | ResponseInfo): void;
215
215
  }
216
216
  ```
217
217
 
@@ -224,13 +224,13 @@ declare module '@ember-data-mirror/request' {
224
224
 
225
225
  ```ts
226
226
  const FetchHandler = {
227
- async request(context) {
228
- const response = await fetch(context.request);
229
- context.setResponse(reponse);
230
- context.setStream(response.clone().body);
227
+ async request(context) {
228
+ const response = await fetch(context.request);
229
+ context.setResponse(reponse);
230
+ context.setStream(response.clone().body);
231
231
 
232
- return response.json();
233
- }
232
+ return response.json();
233
+ }
234
234
  }
235
235
  ```
236
236
 
@@ -253,24 +253,24 @@ declare module '@ember-data-mirror/request' {
253
253
  const MAX_RETRIES = 5;
254
254
 
255
255
  const Handler = {
256
- async request(context, next) {
257
- let attempts = 0;
258
-
259
- while (attempts < MAX_RETRIES) {
260
- attempts++;
261
- try {
262
- const response = await next(context.request);
263
- return response;
264
- } catch (e) {
265
- if (isTimeoutError(e) && attempts < MAX_RETRIES) {
266
- // retry request
267
- continue;
268
- }
269
- // rethrow if it is not a timeout error
270
- throw e;
271
- }
272
- }
273
- }
256
+ async request(context, next) {
257
+ let attempts = 0;
258
+
259
+ while (attempts < MAX_RETRIES) {
260
+ attempts++;
261
+ try {
262
+ const response = await next(context.request);
263
+ return response;
264
+ } catch (e) {
265
+ if (isTimeoutError(e) && attempts < MAX_RETRIES) {
266
+ // retry request
267
+ continue;
268
+ }
269
+ // rethrow if it is not a timeout error
270
+ throw e;
271
+ }
272
+ }
273
+ }
274
274
  }
275
275
  ```
276
276
 
@@ -312,12 +312,12 @@ declare module '@ember-data-mirror/request' {
312
312
 
313
313
  - to manage and return streaming content (such as video files)
314
314
  - to fulfill a request from multiple sources or by splitting one request into multiple requests
315
- - for instance one API call for a user and another for the user's friends
316
- - or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB
317
- etc.) and the rest from another source (a different API, a WebWorker, etc.)
315
+ - for instance one API call for a user and another for the user's friends
316
+ - or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB
317
+ etc.) and the rest from another source (a different API, a WebWorker, etc.)
318
318
  - to coalesce multiple requests
319
319
  - to decorate a request with additional info
320
- - e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached.
320
+ - e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached.
321
321
 
322
322
 
323
323
  `await fetch(<req>)` resolves at the moment headers are received. This allows for the body of the request to be processed as a stream by application
@@ -364,9 +364,9 @@ declare module '@ember-data-mirror/request' {
364
364
  import Fetch from '@ember-data-mirror/request/fetch';
365
365
 
366
366
  class extends Store {
367
- requestManager = new RequestManager()
368
- .use([Fetch])
369
- .useCache(CacheHandler);
367
+ requestManager = new RequestManager()
368
+ .use([Fetch])
369
+ .useCache(CacheHandler);
370
370
  }
371
371
  ```
372
372
 
@@ -384,11 +384,11 @@ declare module '@ember-data-mirror/request' {
384
384
  import Auth from 'ember-simple-auth/ember-data-handler';
385
385
 
386
386
  export default {
387
- create() {
388
- return new RequestManager()
389
- .use([Auth, Fetch])
390
- .use(CacheHandler);
391
- }
387
+ create() {
388
+ return new RequestManager()
389
+ .use([Auth, Fetch])
390
+ .use(CacheHandler);
391
+ }
392
392
  }
393
393
  ```
394
394
 
@@ -411,9 +411,9 @@ declare module '@ember-data-mirror/request' {
411
411
  import { LegacyNetworkHandler } from '@ember-data-mirror/legacy-compat';
412
412
 
413
413
  export default class extends Store {
414
- requestManager = new RequestManager()
415
- .use([LegacyNetworkHandler, Fetch])
416
- .useCache(CacheHandler);
414
+ requestManager = new RequestManager()
415
+ .use([LegacyNetworkHandler, Fetch])
416
+ .useCache(CacheHandler);
417
417
  }
418
418
  ```
419
419
 
@@ -424,11 +424,11 @@ declare module '@ember-data-mirror/request' {
424
424
  For usage of the store's `requestManager` via `store.request(<req>)` see the
425
425
  [Store](https://api.emberjs.com/ember-data/release/modules/@ember-data%2Fstore) documentation.
426
426
 
427
- *
428
- * @module
429
- */
430
- export * from '@warp-drive-mirror/core/request';
431
- export { RequestManager as default } from '@warp-drive-mirror/core';
432
- export type { RequestContext, ImmutableRequestInfo, RequestInfo, ResponseInfo, StructuredDocument, StructuredErrorDocument, StructuredDataDocument, } from '@warp-drive-mirror/core/types/request';
433
- }
434
- //# sourceMappingURL=index.d.ts.map
427
+ *
428
+ * @module
429
+ */
430
+ export * from "@warp-drive-mirror/core/request";
431
+ export { RequestManager as default } from "@warp-drive-mirror/core";
432
+ export type { RequestContext, ImmutableRequestInfo, RequestInfo, ResponseInfo, StructuredDocument, StructuredErrorDocument, StructuredDataDocument } from "@warp-drive-mirror/core/types/request";
433
+
434
+ }
package/dist/fetch.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0aG;AAEH,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC"}