@mittwald/api-models 4.63.0 → 4.64.0

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.
@@ -1,9 +1,11 @@
1
1
  import { hash } from "object-code";
2
+ import { joinedId } from "../lib/joinedId.js";
2
3
  export class ListQueryModel {
3
4
  query;
4
5
  queryId;
5
- constructor(query) {
6
+ constructor(query, opts = {}) {
7
+ const { dependencies = [] } = opts;
6
8
  this.query = query;
7
- this.queryId = hash(query).toString();
9
+ this.queryId = joinedId(hash(query), ...dependencies);
8
10
  }
9
11
  }
@@ -0,0 +1 @@
1
+ export const joinedId = (...parts) => parts.join(" | ");
@@ -1,14 +1,11 @@
1
1
  import { reactUsePromise } from "./reactUsePromise.js";
2
2
  import { hash } from "object-code";
3
3
  import { reactProvisionContext } from "./reactProvisionContext.js";
4
- export const provideReact = (loader, dependencies) => {
5
- const provisionId = String(hash({
6
- loader,
7
- dependencies,
8
- }));
4
+ import { joinedId } from "../lib/joinedId.js";
5
+ export const provideReact = (loader, dependencies = []) => {
6
+ const provisionId = joinedId(hash(loader), ...dependencies);
9
7
  const getAsyncResource = (params) => {
10
- const paramsHash = params && params.length > 0 ? String(hash(params)) : "";
11
- const contextId = provisionId + paramsHash;
8
+ const contextId = joinedId(provisionId, hash(params));
12
9
  const loaderWithContext = reactProvisionContext.bind({
13
10
  id: contextId,
14
11
  }, loader);
@@ -1,5 +1,9 @@
1
+ interface Options {
2
+ dependencies?: string[];
3
+ }
1
4
  export declare abstract class ListQueryModel<TQuery> {
2
5
  protected readonly query: TQuery;
3
6
  readonly queryId: string;
4
- constructor(query: TQuery);
7
+ constructor(query: TQuery, opts?: Options);
5
8
  }
9
+ export {};
@@ -0,0 +1 @@
1
+ export declare const joinedId: (...parts: Array<number | string>) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-models",
3
- "version": "4.63.0",
3
+ "version": "4.64.0",
4
4
  "author": "Mittwald CM Service GmbH & Co. KG <opensource@mittwald.de>",
5
5
  "type": "module",
6
6
  "description": "Collection of domain models for coherent interaction with the API",
@@ -84,5 +84,5 @@
84
84
  "optional": true
85
85
  }
86
86
  },
87
- "gitHead": "ab7742169cf0221128ed193c169d52c4bbb237de"
87
+ "gitHead": "d8f0554d50dff2de81524e1c3749fa3499b4f888"
88
88
  }