shelving 1.145.0 → 1.145.2

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/api/Endpoint.js CHANGED
@@ -42,7 +42,9 @@ export class Endpoint {
42
42
  // Validate the payload against this endpoint's payload type.
43
43
  const payload = this.payload.validate(unsafePayload);
44
44
  // Call the callback with the validated payload to get the result.
45
- return getResponse(await callback(payload, request));
45
+ const result = await callback(payload, request);
46
+ // Convert the result to a `Response` object.
47
+ return getResponse(result);
46
48
  }
47
49
  /** Convert to string, e.g. `GET /user/{id}` */
48
50
  toString() {
package/api/util.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { NotFoundError, RequestError } from "../error/RequestError.js";
2
- import { isData } from "../util/data.js";
3
2
  import { getDictionary } from "../util/dictionary.js";
4
3
  import { getRequestContent } from "../util/http.js";
4
+ import { isPlainObject } from "../util/object.js";
5
5
  import { matchTemplate } from "../util/template.js";
6
6
  import { getURL } from "../util/url.js";
7
7
  /**
@@ -44,9 +44,9 @@ async function handleEndpoint(endpoint, callback, params, request) {
44
44
  // Extract a data object from the request body and validate it against the endpoint's payload type.
45
45
  const content = await getRequestContent(request, handleEndpoints);
46
46
  // If content is undefined, it means the request has no body, so params are the only payload.
47
- // If the content is a data object merge if with the params.
48
- // If the content is not a data object (e.g. string, number, array), set a single `content` property and merge it with the params.
49
- const payload = content === undefined ? params : isData(content) ? { ...content, ...params } : { content, ...params };
47
+ // - If the content is a plain object, merge if with the params.
48
+ // - If the content is anything else (e.g. string, number, array), set it as a single `content` property.
49
+ const payload = content === undefined ? params : isPlainObject(content) ? { ...content, ...params } : { content, ...params };
50
50
  // Call `endpoint.handle()` with the payload and request.
51
51
  return endpoint.handle(callback, payload, request);
52
52
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.145.0",
14
+ "version": "1.145.2",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
package/react/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export * from "./createCacheContext.js";
2
2
  export * from "./createDataContext.js";
3
- export * from "./useProps.js";
4
- export * from "./useMap.js";
3
+ export * from "./useInstance.js";
5
4
  export * from "./useLazy.js";
5
+ export * from "./useMap.js";
6
+ export * from "./useProps.js";
6
7
  export * from "./useReduce.js";
7
8
  export * from "./useSequence.js";
8
9
  export * from "./useStore.js";
package/react/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  export * from "./createCacheContext.js";
2
2
  export * from "./createDataContext.js";
3
- export * from "./useProps.js";
4
- export * from "./useMap.js";
3
+ export * from "./useInstance.js";
5
4
  export * from "./useLazy.js";
5
+ export * from "./useMap.js";
6
+ export * from "./useProps.js";
6
7
  export * from "./useReduce.js";
7
8
  export * from "./useSequence.js";
8
9
  export * from "./useStore.js";
package/util/ansi.d.ts CHANGED
@@ -1,21 +1,12 @@
1
- export declare const ANSI_TEXT_DEFAULT = "\u001B[39m";
2
- export declare const ANSI_TEXT_BLACK = "\u001B[30m";
3
- export declare const ANSI_TEXT_RED = "\u001B[31m";
4
- export declare const ANSI_TEXT_GREEN = "\u001B[32m";
5
- export declare const ANSI_TEXT_YELLOW = "\u001B[33m";
6
- export declare const ANSI_TEXT_BLUE = "\u001B[34m";
7
- export declare const ANSI_TEXT_MAGENTA = "\u001B[35m";
8
- export declare const ANSI_TEXT_CYAN = "\u001B[36m";
9
- export declare const ANSI_TEXT_WHITE = "\u001B[37m";
10
- export declare const ANSI_FILL_DEFAULT = "\u001B[49m";
11
- export declare const ANSI_FILL_BLACK = "\u001B[40m";
12
- export declare const ANSI_FILL_RED = "\u001B[41m";
13
- export declare const ANSI_FILL_GREEN = "\u001B[42m";
14
- export declare const ANSI_FILL_YELLOW = "\u001B[43m";
15
- export declare const ANSI_FILL_BLUE = "\u001B[44m";
16
- export declare const ANSI_FILL_MAGENTA = "\u001B[45m";
17
- export declare const ANSI_FILL_CYAN = "\u001B[46m";
18
- export declare const ANSI_FILL_WHITE = "\u001B[47m";
1
+ export declare const ANSI_DEFAULT = "\u001B[39m";
2
+ export declare const ANSI_BLACK = "\u001B[30m";
3
+ export declare const ANSI_RED = "\u001B[31m";
4
+ export declare const ANSI_GREEN = "\u001B[32m";
5
+ export declare const ANSI_YELLOW = "\u001B[33m";
6
+ export declare const ANSI_BLUE = "\u001B[34m";
7
+ export declare const ANSI_MAGENTA = "\u001B[35m";
8
+ export declare const ANSI_CYAN = "\u001B[36m";
9
+ export declare const ANSI_WHITE = "\u001B[37m";
19
10
  export declare const ANSI_BOLD = "\u001B[1m";
20
11
  export declare const ANSI_ITALIC = "\u001B[3m";
21
12
  export declare const ANSI_UNDERLINE = "\u001B[4m";
package/util/ansi.js CHANGED
@@ -1,23 +1,13 @@
1
- // Foreground colors.
2
- export const ANSI_TEXT_DEFAULT = "\x1b[39m";
3
- export const ANSI_TEXT_BLACK = "\x1b[30m";
4
- export const ANSI_TEXT_RED = "\x1b[31m";
5
- export const ANSI_TEXT_GREEN = "\x1b[32m";
6
- export const ANSI_TEXT_YELLOW = "\x1b[33m";
7
- export const ANSI_TEXT_BLUE = "\x1b[34m";
8
- export const ANSI_TEXT_MAGENTA = "\x1b[35m";
9
- export const ANSI_TEXT_CYAN = "\x1b[36m";
10
- export const ANSI_TEXT_WHITE = "\x1b[37m";
11
- // Background colors.
12
- export const ANSI_FILL_DEFAULT = "\x1b[49m";
13
- export const ANSI_FILL_BLACK = "\x1b[40m";
14
- export const ANSI_FILL_RED = "\x1b[41m";
15
- export const ANSI_FILL_GREEN = "\x1b[42m";
16
- export const ANSI_FILL_YELLOW = "\x1b[43m";
17
- export const ANSI_FILL_BLUE = "\x1b[44m";
18
- export const ANSI_FILL_MAGENTA = "\x1b[45m";
19
- export const ANSI_FILL_CYAN = "\x1b[46m";
20
- export const ANSI_FILL_WHITE = "\x1b[47m";
1
+ // Colors.
2
+ export const ANSI_DEFAULT = "\x1b[39m";
3
+ export const ANSI_BLACK = "\x1b[30m";
4
+ export const ANSI_RED = "\x1b[31m";
5
+ export const ANSI_GREEN = "\x1b[32m";
6
+ export const ANSI_YELLOW = "\x1b[33m";
7
+ export const ANSI_BLUE = "\x1b[34m";
8
+ export const ANSI_MAGENTA = "\x1b[35m";
9
+ export const ANSI_CYAN = "\x1b[36m";
10
+ export const ANSI_WHITE = "\x1b[37m";
21
11
  // Styles.
22
12
  export const ANSI_BOLD = "\x1b[1m";
23
13
  export const ANSI_ITALIC = "\x1b[3m";