@medyll/idae-api 0.28.0 → 0.30.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.
@@ -0,0 +1,9 @@
1
+ export interface ApiResponse<T extends object> {
2
+ data?: T[];
3
+ count?: number;
4
+ page?: number;
5
+ pageSize?: number;
6
+ totalPages?: number;
7
+ error?: string;
8
+ success?: boolean;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -22,13 +22,13 @@ class IdaeApiClient {
22
22
  }
23
23
  db(dbName) {
24
24
  return {
25
- collection: (collectionName) => new IdaeApiClientCollection(this, dbName, collectionName),
25
+ collection: (collectionName) => new IdaeApiClientCollection(this.clientConfig, dbName, collectionName),
26
26
  getCollections: () => this.getCollections(dbName),
27
27
  };
28
28
  }
29
29
  collection(collectionName, dbName) {
30
30
  dbName = dbName || this.clientConfig.defaultDb;
31
- return new IdaeApiClientCollection(this, dbName, collectionName);
31
+ return new IdaeApiClientCollection(this.clientConfig, dbName, collectionName);
32
32
  }
33
33
  }
34
34
  export { IdaeApiClient };
@@ -1,9 +1,9 @@
1
1
  import { IdaeApiClient } from "./IdaeApiClient.js";
2
2
  import type { IdaeApiClientRequestParams } from "./IdaeApiClient.js";
3
- declare class IdaeApiClientCollection {
4
- private apiClient;
3
+ import type { IdaeApiClientConfigCoreOptions } from "./IdaeApiClientConfig.js";
4
+ declare class IdaeApiClientCollection extends IdaeApiClient {
5
5
  private meta;
6
- constructor(apiClient: IdaeApiClient, dbName: string, collectionName: string);
6
+ constructor(clientConfig: IdaeApiClientConfigCoreOptions, dbName: string, collectionName: string);
7
7
  findAll<T>(params?: IdaeApiClientRequestParams): Promise<Response>;
8
8
  findById<T>(id: string): Promise<Response>;
9
9
  create<T>(body: T): Promise<Response>;
@@ -1,34 +1,34 @@
1
1
  // packages\idae-api\src\lib\client\IdaeApiClientCollection.ts
2
2
  import { IdaeApiClient } from "./IdaeApiClient.js";
3
- class IdaeApiClientCollection {
4
- constructor(apiClient, dbName, collectionName) {
5
- this.apiClient = apiClient;
3
+ class IdaeApiClientCollection extends IdaeApiClient {
4
+ constructor(clientConfig, dbName, collectionName) {
5
+ super(clientConfig);
6
6
  this.meta = {
7
7
  dbName,
8
8
  collectionName,
9
9
  };
10
10
  }
11
11
  async findAll(params) {
12
- return this.apiClient.request.doRequest({
12
+ return this.request.doRequest({
13
13
  ...this.meta,
14
14
  params,
15
15
  });
16
16
  }
17
17
  async findById(id) {
18
- return this.apiClient.request.doRequest({
18
+ return this.request.doRequest({
19
19
  ...this.meta,
20
20
  slug: id,
21
21
  });
22
22
  }
23
23
  async create(body) {
24
- return this.apiClient.request.doRequest({
24
+ return this.request.doRequest({
25
25
  method: "POST",
26
26
  ...this.meta,
27
27
  body,
28
28
  });
29
29
  }
30
30
  async update(id, body) {
31
- return this.apiClient.request.doRequest({
31
+ return this.request.doRequest({
32
32
  method: "PUT",
33
33
  ...this.meta,
34
34
  body,
@@ -36,14 +36,14 @@ class IdaeApiClientCollection {
36
36
  });
37
37
  }
38
38
  async deleteById(id) {
39
- return this.apiClient.request.doRequest({
39
+ return this.request.doRequest({
40
40
  method: "DELETE",
41
41
  ...this.meta,
42
42
  slug: id,
43
43
  });
44
44
  }
45
45
  async deleteManyByQuery(params) {
46
- return this.apiClient.request.doRequest({
46
+ return this.request.doRequest({
47
47
  method: "DELETE",
48
48
  ...this.meta,
49
49
  params,
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './client/IdaeApiClientRequest.js';
4
4
  export * from './client/IdaeApiClientConfig.js';
5
5
  export * from './client/IdaeApiClientCollection.js';
6
6
  export * from './client/IdaeApiClient.js';
7
+ export * from './@types/types.js';
7
8
  export * from './server/services/DBaseService.js';
8
9
  export * from './server/services/AuthService.js';
9
10
  export * from './server/middleware/databaseMiddleware.js';
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './client/IdaeApiClientRequest.js';
5
5
  export * from './client/IdaeApiClientConfig.js';
6
6
  export * from './client/IdaeApiClientCollection.js';
7
7
  export * from './client/IdaeApiClient.js';
8
+ export * from './@types/types.js';
8
9
  export * from './server/services/DBaseService.js';
9
10
  export * from './server/services/AuthService.js';
10
11
  export * from './server/middleware/databaseMiddleware.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@medyll/idae-api",
3
3
  "scope": "@medyll",
4
- "version": "0.28.0",
4
+ "version": "0.30.0",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
7
7
  "scripts": {