@fabriktor/client 0.0.81 → 0.0.83

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,4 +1,11 @@
1
1
  export type FieldOf<T> = Extract<keyof T, string>;
2
+ type NestedQueryRecord<T> = T extends readonly (infer Value)[] ? Value : T;
3
+ export type NestedFieldOf<T> = {
4
+ [Key in FieldOf<T>]: NonNullable<NestedQueryRecord<NonNullable<T[Key]>>> extends object ? readonly [
5
+ Key,
6
+ FieldOf<NonNullable<NestedQueryRecord<NonNullable<T[Key]>>>>
7
+ ] : never;
8
+ }[FieldOf<T>];
2
9
  export type QueryValue = string | number | boolean | undefined | null;
3
10
  export type QueryInputValue = QueryValue | QueryValue[];
4
11
  export type QueryOptions = Record<string, QueryInputValue>;
@@ -17,5 +24,7 @@ export declare function collectionPath(opts: CollectionPathOptions): string;
17
24
  export declare function idPath(opts: IDPathOptions): string;
18
25
  export declare function queryParam<T>(key: FieldOf<T>, value: QueryInputValue): QueryOptions;
19
26
  export declare function queryParams<T>(query: TypedQueryOptions<T>): QueryOptions;
27
+ export declare function queryNestedParam<T>(path: NestedFieldOf<T>, value: QueryInputValue): QueryOptions;
20
28
  export declare function mergeQueryOptions(...queries: Array<QueryOptions | undefined>): QueryOptions;
21
29
  export declare function withQuery(path: string, opts?: BuildQueryOptions): string;
30
+ export {};
@@ -23,6 +23,9 @@ export function queryParam(key, value) {
23
23
  export function queryParams(query) {
24
24
  return query;
25
25
  }
26
+ export function queryNestedParam(path, value) {
27
+ return { [`${path[0]}.${path[1]}`]: value };
28
+ }
26
29
  export function mergeQueryOptions(...queries) {
27
30
  return Object.assign({}, ...queries);
28
31
  }
@@ -32,7 +32,7 @@ export type ReplaceOneOptionsCRUD<In> = Pick<RequestOptions, "signal"> & {
32
32
  export type DeleteOneOptionsCRUD = {
33
33
  id: string;
34
34
  };
35
- export type SearchManyOptionsCRUD = {
35
+ export type SearchManyOptionsCRUD = Pick<RequestOptions, "signal"> & {
36
36
  query?: QueryOptions;
37
37
  };
38
38
  export interface CRUDOperator<In, Out> {
@@ -119,6 +119,7 @@ export class CRUDClient {
119
119
  }),
120
120
  method: HTTPMethodGet,
121
121
  token,
122
+ signal: opts?.signal,
122
123
  });
123
124
  }
124
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,6 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/schema": "0.0.62"
20
+ "@fabriktor/schema": "0.0.63"
21
21
  }
22
22
  }