@fraym/crud 0.9.2 → 0.10.1

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,13 +1,12 @@
1
1
  import { ClientConfig } from "../config/config";
2
2
  import { CreatedCrudData } from "./create";
3
- import { GetCrudData } from "./getData";
4
3
  import { Filter, GetCrudDataList } from "./getDataList";
5
4
  export interface DeliveryClient {
6
5
  create: (tenantId: string, type: string, data: Record<string, any>) => Promise<CreatedCrudData>;
7
6
  update: (tenantId: string, type: string, id: string, data: Record<string, any>) => Promise<void>;
8
7
  delete: (tenantId: string, type: string, id: string) => Promise<void>;
9
- getData: (tenantId: string, type: string, id: string, returnEmptyDataIfNotFound?: boolean) => Promise<GetCrudData | null>;
10
- getDataList: (tenantId: string, type: string, limit?: number, page?: number, filter?: Filter) => Promise<GetCrudDataList | null>;
8
+ getData: <T extends {}>(tenantId: string, type: string, id: string, returnEmptyDataIfNotFound?: boolean) => Promise<T>;
9
+ getDataList: <T extends {}>(tenantId: string, type: string, limit?: number, page?: number, filter?: Filter) => Promise<GetCrudDataList<T>>;
11
10
  close: () => Promise<void>;
12
11
  }
13
12
  export declare const newDeliveryClient: (config?: ClientConfig) => Promise<DeliveryClient>;
@@ -1,3 +1,2 @@
1
1
  import { DeliveryServiceClient } from "@fraym/crud-proto";
2
- export type GetCrudData = Record<string, any>;
3
- export declare const getCrudData: (tenantId: string, type: string, id: string, returnEmptyDataIfNotFound: boolean, serviceClient: DeliveryServiceClient) => Promise<GetCrudData | null>;
2
+ export declare const getCrudData: <T extends {}>(tenantId: string, type: string, id: string, returnEmptyDataIfNotFound: boolean, serviceClient: DeliveryServiceClient) => Promise<T>;
@@ -17,8 +17,7 @@ const getCrudData = async (tenantId, type, id, returnEmptyDataIfNotFound, servic
17
17
  return;
18
18
  }
19
19
  if (response.result.length !== 1) {
20
- resolve(null);
21
- return;
20
+ throw new Error("did not find the requested crud entry");
22
21
  }
23
22
  const data = {};
24
23
  const resultData = response.result[0].data;
@@ -1,8 +1,8 @@
1
1
  import { DeliveryServiceClient } from "@fraym/crud-proto";
2
- export interface GetCrudDataList {
2
+ export interface GetCrudDataList<T extends {}> {
3
3
  limit: number;
4
4
  page: number;
5
- data: Record<string, any>[];
5
+ data: T[];
6
6
  }
7
7
  export interface Filter {
8
8
  fields: Record<string, FieldFilter>;
@@ -14,4 +14,4 @@ export interface FieldFilter {
14
14
  operation: string;
15
15
  value: any;
16
16
  }
17
- export declare const getCrudDataList: (tenantId: string, type: string, limit: number, page: number, filter: Filter, serviceClient: DeliveryServiceClient) => Promise<GetCrudDataList | null>;
17
+ export declare const getCrudDataList: <T extends {}>(tenantId: string, type: string, limit: number, page: number, filter: Filter, serviceClient: DeliveryServiceClient) => Promise<GetCrudDataList<T>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fraym/crud",
3
- "version": "0.9.2",
3
+ "version": "0.10.1",
4
4
  "license": "UNLICENSED",
5
5
  "homepage": "https://github.com/fraym/crud-nodejs",
6
6
  "repository": {