@appweaver/client 1.3.1 → 1.4.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.
@@ -2,6 +2,7 @@ import { BaseModule, RequestOptions } from './base-module';
2
2
  import { BaseClientInterface } from '../base-client-interface';
3
3
  import { FileDataResponse } from '../responses';
4
4
  import { RESOURCE_OPERATIONS, RESOURCE_TYPES } from '../../constants';
5
+ import { ResourceId } from '../../types';
5
6
  export type ResourceType = Record<(typeof RESOURCE_TYPES)[number], unknown>;
6
7
  export type ResourceInterface = {
7
8
  [K in keyof typeof RESOURCE_OPERATIONS]: (...args: any[]) => Promise<any>;
@@ -10,13 +11,13 @@ export declare class ResourceClient<Resource extends ResourceType> extends BaseM
10
11
  readonly basePath: string;
11
12
  constructor(client: BaseClientInterface, basePath: string);
12
13
  /**
13
- * Fetches a single resource by its numeric ID.
14
+ * Fetches a single resource by its ID.
14
15
  *
15
- * @param {number} id - The ID of the resource to retrieve.
16
+ * @param {ResourceId} id - The ID of the resource to retrieve.
16
17
  * @param {RequestOptions} options - Additional request options (headers, query params, etc.).
17
18
  * @returns The resource record matching the given ID.
18
19
  */
19
- find(id: number, options?: RequestOptions): Promise<Resource['single']>;
20
+ find(id: ResourceId, options?: RequestOptions): Promise<Resource['single']>;
20
21
  /**
21
22
  * Executes a query against the resource collection.
22
23
  *
@@ -49,16 +50,16 @@ export declare class ResourceClient<Resource extends ResourceType> extends BaseM
49
50
  * @returns The updated resource record.
50
51
  */
51
52
  update(resource: Resource['update'] & {
52
- id: number;
53
+ id: ResourceId;
53
54
  }, options?: RequestOptions): Promise<Resource['single']>;
54
55
  /**
55
- * Deletes a resource record by its numeric ID.
56
+ * Deletes a resource record by its ID.
56
57
  *
57
- * @param {number} id - The ID of the resource to delete.
58
+ * @param {ResourceId} id - The ID of the resource to delete.
58
59
  * @param {RequestOptions} options - Additional request options.
59
60
  * @returns The deleted resource record.
60
61
  */
61
- delete(id: number, options?: RequestOptions): Promise<Resource['single']>;
62
+ delete(id: ResourceId, options?: RequestOptions): Promise<Resource['single']>;
62
63
  /**
63
64
  * Exports resource records as a file (e.g., CSV) and returns a streaming response.
64
65
  *
@@ -72,19 +73,19 @@ export declare class ResourceClient<Resource extends ResourceType> extends BaseM
72
73
  *
73
74
  * Each entry in `files` maps a field name to a single `File` or an array of `File` objects.
74
75
  *
75
- * @param {number} id - The ID of the resource for which to upload files.
76
+ * @param {ResourceId} id - The ID of the resource for which to upload files.
76
77
  * @param {Object} files - A map of field names to the file(s) to upload.
77
78
  * @param {RequestOptions} options - Additional request options.
78
79
  * @returns The updated file metadata for the resource.
79
80
  */
80
- uploadFiles(id: number, files: Resource['fileUpload'], options?: RequestOptions): Promise<Resource['files']>;
81
+ uploadFiles(id: ResourceId, files: Resource['fileUpload'], options?: RequestOptions): Promise<Resource['files']>;
81
82
  /**
82
83
  * Removes specific files from the resource record.
83
84
  *
84
- * @param {number} id - The ID of the resource for which to delete files.
85
+ * @param {ResourceId} id - The ID of the resource for which to delete files.
85
86
  * @param {Object} files - The file deletion payload identifying which files to remove.
86
87
  * @param {RequestOptions} options - Additional request options.
87
88
  * @returns The updated file metadata for the resource after deletion.
88
89
  */
89
- deleteFiles(id: number, files: Resource['fileDelete'], options?: RequestOptions): Promise<Resource['files']>;
90
+ deleteFiles(id: ResourceId, files: Resource['fileDelete'], options?: RequestOptions): Promise<Resource['files']>;
90
91
  }
@@ -9,9 +9,9 @@ class ResourceClient extends base_module_1.BaseModule {
9
9
  this.basePath = basePath;
10
10
  }
11
11
  /**
12
- * Fetches a single resource by its numeric ID.
12
+ * Fetches a single resource by its ID.
13
13
  *
14
- * @param {number} id - The ID of the resource to retrieve.
14
+ * @param {ResourceId} id - The ID of the resource to retrieve.
15
15
  * @param {RequestOptions} options - Additional request options (headers, query params, etc.).
16
16
  * @returns The resource record matching the given ID.
17
17
  */
@@ -85,9 +85,9 @@ class ResourceClient extends base_module_1.BaseModule {
85
85
  });
86
86
  }
87
87
  /**
88
- * Deletes a resource record by its numeric ID.
88
+ * Deletes a resource record by its ID.
89
89
  *
90
- * @param {number} id - The ID of the resource to delete.
90
+ * @param {ResourceId} id - The ID of the resource to delete.
91
91
  * @param {RequestOptions} options - Additional request options.
92
92
  * @returns The deleted resource record.
93
93
  */
@@ -125,7 +125,7 @@ class ResourceClient extends base_module_1.BaseModule {
125
125
  *
126
126
  * Each entry in `files` maps a field name to a single `File` or an array of `File` objects.
127
127
  *
128
- * @param {number} id - The ID of the resource for which to upload files.
128
+ * @param {ResourceId} id - The ID of the resource for which to upload files.
129
129
  * @param {Object} files - A map of field names to the file(s) to upload.
130
130
  * @param {RequestOptions} options - Additional request options.
131
131
  * @returns The updated file metadata for the resource.
@@ -156,7 +156,7 @@ class ResourceClient extends base_module_1.BaseModule {
156
156
  /**
157
157
  * Removes specific files from the resource record.
158
158
  *
159
- * @param {number} id - The ID of the resource for which to delete files.
159
+ * @param {ResourceId} id - The ID of the resource for which to delete files.
160
160
  * @param {Object} files - The file deletion payload identifying which files to remove.
161
161
  * @param {RequestOptions} options - Additional request options.
162
162
  * @returns The updated file metadata for the resource after deletion.
package/cjs/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './clients';
2
2
  export * from './errors';
3
+ export * from './types/resource';
package/cjs/index.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./clients"), exports);
18
18
  __exportStar(require("./errors"), exports);
19
+ __exportStar(require("./types/resource"), exports);
@@ -1,2 +1,3 @@
1
1
  export * from './generator';
2
+ export * from './resource';
2
3
  export * from './routes';
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./generator"), exports);
18
+ __exportStar(require("./resource"), exports);
18
19
  __exportStar(require("./routes"), exports);
@@ -0,0 +1,2 @@
1
+ /** Primary key value: a number for `int` and `bigInt` ids, a string for `string` ids */
2
+ export type ResourceId = number | string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,6 +2,7 @@ import { BaseModule, RequestOptions } from './base-module.js';
2
2
  import { BaseClientInterface } from '../base-client-interface.js';
3
3
  import { FileDataResponse } from '../responses/index.js';
4
4
  import { RESOURCE_OPERATIONS, RESOURCE_TYPES } from '../../constants.js';
5
+ import { ResourceId } from '../../types/index.js';
5
6
  export type ResourceType = Record<(typeof RESOURCE_TYPES)[number], unknown>;
6
7
  export type ResourceInterface = {
7
8
  [K in keyof typeof RESOURCE_OPERATIONS]: (...args: any[]) => Promise<any>;
@@ -10,13 +11,13 @@ export declare class ResourceClient<Resource extends ResourceType> extends BaseM
10
11
  readonly basePath: string;
11
12
  constructor(client: BaseClientInterface, basePath: string);
12
13
  /**
13
- * Fetches a single resource by its numeric ID.
14
+ * Fetches a single resource by its ID.
14
15
  *
15
- * @param {number} id - The ID of the resource to retrieve.
16
+ * @param {ResourceId} id - The ID of the resource to retrieve.
16
17
  * @param {RequestOptions} options - Additional request options (headers, query params, etc.).
17
18
  * @returns The resource record matching the given ID.
18
19
  */
19
- find(id: number, options?: RequestOptions): Promise<Resource['single']>;
20
+ find(id: ResourceId, options?: RequestOptions): Promise<Resource['single']>;
20
21
  /**
21
22
  * Executes a query against the resource collection.
22
23
  *
@@ -49,16 +50,16 @@ export declare class ResourceClient<Resource extends ResourceType> extends BaseM
49
50
  * @returns The updated resource record.
50
51
  */
51
52
  update(resource: Resource['update'] & {
52
- id: number;
53
+ id: ResourceId;
53
54
  }, options?: RequestOptions): Promise<Resource['single']>;
54
55
  /**
55
- * Deletes a resource record by its numeric ID.
56
+ * Deletes a resource record by its ID.
56
57
  *
57
- * @param {number} id - The ID of the resource to delete.
58
+ * @param {ResourceId} id - The ID of the resource to delete.
58
59
  * @param {RequestOptions} options - Additional request options.
59
60
  * @returns The deleted resource record.
60
61
  */
61
- delete(id: number, options?: RequestOptions): Promise<Resource['single']>;
62
+ delete(id: ResourceId, options?: RequestOptions): Promise<Resource['single']>;
62
63
  /**
63
64
  * Exports resource records as a file (e.g., CSV) and returns a streaming response.
64
65
  *
@@ -72,19 +73,19 @@ export declare class ResourceClient<Resource extends ResourceType> extends BaseM
72
73
  *
73
74
  * Each entry in `files` maps a field name to a single `File` or an array of `File` objects.
74
75
  *
75
- * @param {number} id - The ID of the resource for which to upload files.
76
+ * @param {ResourceId} id - The ID of the resource for which to upload files.
76
77
  * @param {Object} files - A map of field names to the file(s) to upload.
77
78
  * @param {RequestOptions} options - Additional request options.
78
79
  * @returns The updated file metadata for the resource.
79
80
  */
80
- uploadFiles(id: number, files: Resource['fileUpload'], options?: RequestOptions): Promise<Resource['files']>;
81
+ uploadFiles(id: ResourceId, files: Resource['fileUpload'], options?: RequestOptions): Promise<Resource['files']>;
81
82
  /**
82
83
  * Removes specific files from the resource record.
83
84
  *
84
- * @param {number} id - The ID of the resource for which to delete files.
85
+ * @param {ResourceId} id - The ID of the resource for which to delete files.
85
86
  * @param {Object} files - The file deletion payload identifying which files to remove.
86
87
  * @param {RequestOptions} options - Additional request options.
87
88
  * @returns The updated file metadata for the resource after deletion.
88
89
  */
89
- deleteFiles(id: number, files: Resource['fileDelete'], options?: RequestOptions): Promise<Resource['files']>;
90
+ deleteFiles(id: ResourceId, files: Resource['fileDelete'], options?: RequestOptions): Promise<Resource['files']>;
90
91
  }
@@ -6,9 +6,9 @@ export class ResourceClient extends BaseModule {
6
6
  this.basePath = basePath;
7
7
  }
8
8
  /**
9
- * Fetches a single resource by its numeric ID.
9
+ * Fetches a single resource by its ID.
10
10
  *
11
- * @param {number} id - The ID of the resource to retrieve.
11
+ * @param {ResourceId} id - The ID of the resource to retrieve.
12
12
  * @param {RequestOptions} options - Additional request options (headers, query params, etc.).
13
13
  * @returns The resource record matching the given ID.
14
14
  */
@@ -82,9 +82,9 @@ export class ResourceClient extends BaseModule {
82
82
  });
83
83
  }
84
84
  /**
85
- * Deletes a resource record by its numeric ID.
85
+ * Deletes a resource record by its ID.
86
86
  *
87
- * @param {number} id - The ID of the resource to delete.
87
+ * @param {ResourceId} id - The ID of the resource to delete.
88
88
  * @param {RequestOptions} options - Additional request options.
89
89
  * @returns The deleted resource record.
90
90
  */
@@ -122,7 +122,7 @@ export class ResourceClient extends BaseModule {
122
122
  *
123
123
  * Each entry in `files` maps a field name to a single `File` or an array of `File` objects.
124
124
  *
125
- * @param {number} id - The ID of the resource for which to upload files.
125
+ * @param {ResourceId} id - The ID of the resource for which to upload files.
126
126
  * @param {Object} files - A map of field names to the file(s) to upload.
127
127
  * @param {RequestOptions} options - Additional request options.
128
128
  * @returns The updated file metadata for the resource.
@@ -153,7 +153,7 @@ export class ResourceClient extends BaseModule {
153
153
  /**
154
154
  * Removes specific files from the resource record.
155
155
  *
156
- * @param {number} id - The ID of the resource for which to delete files.
156
+ * @param {ResourceId} id - The ID of the resource for which to delete files.
157
157
  * @param {Object} files - The file deletion payload identifying which files to remove.
158
158
  * @param {RequestOptions} options - Additional request options.
159
159
  * @returns The updated file metadata for the resource after deletion.
package/esm/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './clients/index.js';
2
2
  export * from './errors/index.js';
3
+ export * from './types/resource.js';
package/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './clients/index.js';
2
2
  export * from './errors/index.js';
3
+ export * from './types/resource.js';
@@ -1,2 +1,3 @@
1
1
  export * from './generator.js';
2
+ export * from './resource.js';
2
3
  export * from './routes.js';
@@ -1,2 +1,3 @@
1
1
  export * from './generator.js';
2
+ export * from './resource.js';
2
3
  export * from './routes.js';
@@ -0,0 +1,2 @@
1
+ /** Primary key value: a number for `int` and `bigInt` ids, a string for `string` ids */
2
+ export type ResourceId = number | string;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appweaver/client",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Appweaver - the backend framework for AI-first development (@client)",
5
5
  "author": "Luka Matosevic",
6
6
  "license": "MIT",