@decaf-ts/for-http 0.2.13 → 0.3.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.
- package/README.md +1 -1
- package/dist/for-http.cjs +1 -1
- package/dist/for-http.cjs.map +1 -1
- package/dist/for-http.js +1 -1
- package/dist/for-http.js.map +1 -1
- package/lib/RestRepository.d.ts +5 -6
- package/lib/RestRepository.js.map +1 -1
- package/lib/RestService.cjs +9 -229
- package/lib/RestService.d.ts +6 -157
- package/lib/RestService.js.map +1 -1
- package/lib/adapter.cjs +13 -8
- package/lib/adapter.d.ts +21 -22
- package/lib/adapter.js.map +1 -1
- package/lib/axios/axios.cjs +21 -8
- package/lib/axios/axios.d.ts +10 -7
- package/lib/axios/axios.js.map +1 -1
- package/lib/esm/RestRepository.d.ts +5 -6
- package/lib/esm/RestRepository.js.map +1 -1
- package/lib/esm/RestService.d.ts +6 -157
- package/lib/esm/RestService.js +9 -229
- package/lib/esm/RestService.js.map +1 -1
- package/lib/esm/adapter.d.ts +21 -22
- package/lib/esm/adapter.js +14 -9
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/axios/axios.d.ts +10 -7
- package/lib/esm/axios/axios.js +21 -8
- package/lib/esm/axios/axios.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/package.json +5 -4
package/lib/RestService.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Constructor
|
|
3
|
-
import {
|
|
1
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
import { FlagsOf } from "@decaf-ts/core";
|
|
4
4
|
import { HttpAdapter } from "./adapter";
|
|
5
|
-
import {
|
|
6
|
-
import { LoggedClass, Logger } from "@decaf-ts/logging";
|
|
5
|
+
import { RestRepository } from "./RestRepository";
|
|
7
6
|
/**
|
|
8
7
|
* @description Service class for REST API operations
|
|
9
8
|
* @summary Provides a comprehensive implementation for interacting with REST APIs.
|
|
@@ -52,44 +51,8 @@ import { LoggedClass, Logger } from "@decaf-ts/logging";
|
|
|
52
51
|
* Adapter-->>Service: record
|
|
53
52
|
* Service-->>Client: revert(record)
|
|
54
53
|
*/
|
|
55
|
-
export declare class RestService<M extends Model,
|
|
56
|
-
|
|
57
|
-
private _pk;
|
|
58
|
-
private logger?;
|
|
59
|
-
/**
|
|
60
|
-
* @description Gets the model class constructor
|
|
61
|
-
* @summary Retrieves the model class constructor associated with this service.
|
|
62
|
-
* Throws an error if no class definition is found.
|
|
63
|
-
* @return {Constructor<M>} The model class constructor
|
|
64
|
-
* @throws {InternalError} If no class definition is found
|
|
65
|
-
*/
|
|
66
|
-
get class(): Constructor<M>;
|
|
67
|
-
protected get log(): Logger;
|
|
68
|
-
/**
|
|
69
|
-
* @description Gets the primary key property name
|
|
70
|
-
* @summary Retrieves the name of the primary key property for the model.
|
|
71
|
-
* If not already determined, it finds the primary key using the model class.
|
|
72
|
-
* @return The primary key property name
|
|
73
|
-
*/
|
|
74
|
-
get pk(): keyof M;
|
|
75
|
-
protected observers: Observer[];
|
|
76
|
-
private readonly _adapter;
|
|
77
|
-
private _tableName;
|
|
78
|
-
/**
|
|
79
|
-
* @description Gets the HTTP adapter
|
|
80
|
-
* @summary Retrieves the HTTP adapter associated with this service.
|
|
81
|
-
* Throws an error if no adapter is found.
|
|
82
|
-
* @return {A} The HTTP adapter instance
|
|
83
|
-
* @throws {InternalError} If no adapter is found
|
|
84
|
-
*/
|
|
85
|
-
protected get adapter(): A;
|
|
86
|
-
/**
|
|
87
|
-
* @description Gets the table name for the model
|
|
88
|
-
* @summary Retrieves the table name associated with the model class.
|
|
89
|
-
* If not already determined, it gets the table name from the Repository utility.
|
|
90
|
-
* @return {string} The table name
|
|
91
|
-
*/
|
|
92
|
-
protected get tableName(): string;
|
|
54
|
+
export declare class RestService<M extends Model, A extends HttpAdapter<any, any, any, any>, Q = A extends HttpAdapter<any, any, infer Q, any> ? Q : never> extends RestRepository<M, A, Q> {
|
|
55
|
+
protected _overrides: Partial<FlagsOf<A>>;
|
|
93
56
|
/**
|
|
94
57
|
* @description Initializes a new RestService instance
|
|
95
58
|
* @summary Creates a new service instance with the specified adapter and optional model class.
|
|
@@ -98,119 +61,5 @@ export declare class RestService<M extends Model, Q, A extends HttpAdapter<any,
|
|
|
98
61
|
* @param {Constructor<M>} [clazz] - Optional constructor for the model class
|
|
99
62
|
*/
|
|
100
63
|
constructor(adapter: A, clazz?: Constructor<M>);
|
|
101
|
-
url(path: string, queryParams?: Record<string, string | number>): string;
|
|
102
|
-
/**
|
|
103
|
-
* @description Creates a new resource
|
|
104
|
-
* @summary Creates a new resource in the REST API using the provided model.
|
|
105
|
-
* The method prepares the model for the adapter, sends the create request,
|
|
106
|
-
* and then converts the response back to a model instance.
|
|
107
|
-
* @param {M} model - The model instance to create
|
|
108
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
109
|
-
* @return {Promise<M>} A promise that resolves with the created model instance
|
|
110
|
-
*/
|
|
111
|
-
create(model: M, ...args: any[]): Promise<M>;
|
|
112
|
-
/**
|
|
113
|
-
* @description Retrieves a resource by ID
|
|
114
|
-
* @summary Fetches a resource from the REST API using the provided ID.
|
|
115
|
-
* The method sends the read request and converts the response to a model instance.
|
|
116
|
-
* @param {string|number} id - The identifier of the resource to retrieve
|
|
117
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
118
|
-
* @return {Promise<M>} A promise that resolves with the retrieved model instance
|
|
119
|
-
*/
|
|
120
|
-
read(id: string | number, ...args: any[]): Promise<M>;
|
|
121
|
-
/**
|
|
122
|
-
* @description Updates an existing resource
|
|
123
|
-
* @summary Updates an existing resource in the REST API using the provided model.
|
|
124
|
-
* The method prepares the model for the adapter, sends the update request,
|
|
125
|
-
* and then converts the response back to a model instance.
|
|
126
|
-
* @param {M} model - The model instance with updated data
|
|
127
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
128
|
-
* @return {Promise<M>} A promise that resolves with the updated model instance
|
|
129
|
-
*/
|
|
130
|
-
update(model: M, ...args: any[]): Promise<M>;
|
|
131
|
-
/**
|
|
132
|
-
* @description Deletes a resource by ID
|
|
133
|
-
* @summary Removes a resource from the REST API using the provided ID.
|
|
134
|
-
* The method sends the delete request and converts the response to a model instance.
|
|
135
|
-
* @param {string|number} id - The identifier of the resource to delete
|
|
136
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
137
|
-
* @return {Promise<M>} A promise that resolves with the deleted model instance
|
|
138
|
-
*/
|
|
139
|
-
delete(id: string | number, ...args: any[]): Promise<M>;
|
|
140
|
-
request<V>(details: Q): Promise<V>;
|
|
141
|
-
/**
|
|
142
|
-
* @description Creates multiple resources
|
|
143
|
-
* @summary Creates multiple resources in the REST API using the provided models.
|
|
144
|
-
* The method prepares each model for the adapter, sends a bulk create request,
|
|
145
|
-
* and then converts the responses back to model instances.
|
|
146
|
-
* @param {M[]} models - The model instances to create
|
|
147
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
148
|
-
* @return {Promise<M[]>} A promise that resolves with an array of created model instances
|
|
149
|
-
* @mermaid
|
|
150
|
-
* sequenceDiagram
|
|
151
|
-
* participant Client
|
|
152
|
-
* participant Service as RestService
|
|
153
|
-
* participant Adapter as HttpAdapter
|
|
154
|
-
* Client->>Service: createAll(models)
|
|
155
|
-
* Service->>Adapter: prepare(model, pk) x N
|
|
156
|
-
* Service->>Adapter: createAll(table, ids[], records[])
|
|
157
|
-
* Adapter-->>Service: records[]
|
|
158
|
-
* Service-->>Client: revert(records[])
|
|
159
|
-
*/
|
|
160
|
-
createAll(models: M[], ...args: any[]): Promise<M[]>;
|
|
161
|
-
/**
|
|
162
|
-
* @description Deletes multiple resources by IDs
|
|
163
|
-
* @summary Removes multiple resources from the REST API using the provided IDs.
|
|
164
|
-
* The method sends a bulk delete request and converts the responses to model instances.
|
|
165
|
-
* @param {string[]|number[]} keys - The identifiers of the resources to delete
|
|
166
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
167
|
-
* @return {Promise<M[]>} A promise that resolves with an array of deleted model instances
|
|
168
|
-
*/
|
|
169
|
-
deleteAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
|
|
170
|
-
/**
|
|
171
|
-
* @description Retrieves multiple resources by IDs
|
|
172
|
-
* @summary Fetches multiple resources from the REST API using the provided IDs.
|
|
173
|
-
* The method sends a bulk read request and converts the responses to model instances.
|
|
174
|
-
* @param {string[]|number[]} keys - The identifiers of the resources to retrieve
|
|
175
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
176
|
-
* @return {Promise<M[]>} A promise that resolves with an array of retrieved model instances
|
|
177
|
-
*/
|
|
178
|
-
readAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
|
|
179
|
-
/**
|
|
180
|
-
* @description Updates multiple resources
|
|
181
|
-
* @summary Updates multiple resources in the REST API using the provided models.
|
|
182
|
-
* The method prepares each model for the adapter, sends a bulk update request,
|
|
183
|
-
* and then converts the responses back to model instances.
|
|
184
|
-
* @param {M[]} models - The model instances with updated data
|
|
185
|
-
* @param {...any[]} args - Additional arguments to pass to the adapter
|
|
186
|
-
* @return {Promise<M[]>} A promise that resolves with an array of updated model instances
|
|
187
|
-
*/
|
|
188
|
-
updateAll(models: M[], ...args: any[]): Promise<M[]>;
|
|
189
|
-
/**
|
|
190
|
-
* @description Registers an observer
|
|
191
|
-
* @summary Adds an observer to the list of observers that will be notified of changes.
|
|
192
|
-
* Throws an error if the observer is already registered.
|
|
193
|
-
* @param {Observer} observer - The observer to register
|
|
194
|
-
* @return {void}
|
|
195
|
-
* @throws {InternalError} If the observer is already registered
|
|
196
|
-
*/
|
|
197
|
-
observe(observer: Observer): void;
|
|
198
|
-
/**
|
|
199
|
-
* @description Unregisters an observer
|
|
200
|
-
* @summary Removes an observer from the list of observers.
|
|
201
|
-
* Throws an error if the observer is not found.
|
|
202
|
-
* @param {Observer} observer - The observer to unregister
|
|
203
|
-
* @return {void}
|
|
204
|
-
* @throws {InternalError} If the observer is not found
|
|
205
|
-
*/
|
|
206
|
-
unObserve(observer: Observer): void;
|
|
207
|
-
/**
|
|
208
|
-
* @description Notifies all registered observers
|
|
209
|
-
* @summary Calls the refresh method on all registered observers to update themselves.
|
|
210
|
-
* Any errors during observer refresh are logged as warnings but don't stop the process.
|
|
211
|
-
* @param {...any[]} [args] - Optional arguments to pass to the observer refresh method
|
|
212
|
-
* @return {Promise<void>} A promise that resolves when all observers have been updated
|
|
213
|
-
*/
|
|
214
|
-
updateObservers(...args: any[]): Promise<void>;
|
|
215
64
|
toString(): string;
|
|
216
65
|
}
|
package/lib/RestService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestService.js","sourceRoot":"","sources":["../src/RestService.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RestService.js","sourceRoot":"","sources":["../src/RestService.ts"],"names":[],"mappings":";;;AAAA,yEAAuD;AAIvD,yDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAa,WAIX,SAAQ,+BAAuB;IAM/B;;;;;;OAMG;IACH,YAAY,OAAU,EAAE,KAAsB;QAC5C,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAbL,eAAU,GAAwB;YACnD,gBAAgB,EAAE,IAAI;YACtB,cAAc,EAAE,IAAI;SACE,CAAC;IAWzB,CAAC;IAEQ,QAAQ;QACf,OAAO,GAAG,4BAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;IACvD,CAAC;CACF;AAxBD,kCAwBC"}
|
package/lib/adapter.cjs
CHANGED
|
@@ -61,8 +61,8 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
61
61
|
* @description Returns the repository constructor for this adapter
|
|
62
62
|
* @summary Provides the RestService class as the repository implementation for this HTTP adapter.
|
|
63
63
|
* This method is used to create repository instances that work with this adapter type.
|
|
64
|
-
* @template
|
|
65
|
-
* @return {Constructor<
|
|
64
|
+
* @template R - Repository subtype working with this adapter
|
|
65
|
+
* @return {Constructor<R>} The repository constructor
|
|
66
66
|
*/
|
|
67
67
|
repository() {
|
|
68
68
|
return RestService_1.RestService;
|
|
@@ -74,10 +74,11 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
74
74
|
* @template M - The model type
|
|
75
75
|
* @param {M} model - The model instance to prepare
|
|
76
76
|
* @param pk - The primary key property name
|
|
77
|
+
* @param args
|
|
77
78
|
* @return The prepared data
|
|
78
79
|
*/
|
|
79
|
-
prepare(model,
|
|
80
|
-
const log = this.
|
|
80
|
+
prepare(model, ...args) {
|
|
81
|
+
const { log } = this.logCtx(args, this.prepare);
|
|
81
82
|
const result = Object.assign({}, model);
|
|
82
83
|
if (model[core_1.PersistenceKeys.METADATA]) {
|
|
83
84
|
log.silly(`Passing along persistence metadata for ${model[core_1.PersistenceKeys.METADATA]}`);
|
|
@@ -90,7 +91,7 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
90
91
|
}
|
|
91
92
|
return {
|
|
92
93
|
record: model,
|
|
93
|
-
id: model[pk],
|
|
94
|
+
id: model[decorator_validation_1.Model.pk(model.constructor)],
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
97
|
/**
|
|
@@ -104,8 +105,8 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
104
105
|
* @param {string|number|bigint} id - The primary key value
|
|
105
106
|
* @return {M} The reconstructed model instance
|
|
106
107
|
*/
|
|
107
|
-
revert(obj, clazz,
|
|
108
|
-
const log = this.
|
|
108
|
+
revert(obj, clazz, id, ...args) {
|
|
109
|
+
const { log } = this.logCtx(args, this.revert);
|
|
109
110
|
const ob = {};
|
|
110
111
|
const m = (typeof clazz === "string" ? decorator_validation_1.Model.build(ob, clazz) : new clazz(ob));
|
|
111
112
|
log.silly(`Rebuilding model ${m.constructor.name} id ${id}`);
|
|
@@ -125,6 +126,9 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
125
126
|
}
|
|
126
127
|
return result;
|
|
127
128
|
}
|
|
129
|
+
toTableName(t) {
|
|
130
|
+
return typeof t === "string" ? t : decorator_validation_1.Model.tableName(t);
|
|
131
|
+
}
|
|
128
132
|
/**
|
|
129
133
|
* @description Constructs a URL for API requests
|
|
130
134
|
* @summary Builds a complete URL for API requests using the configured protocol and host,
|
|
@@ -134,6 +138,7 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
134
138
|
* @return {string} The encoded URL string
|
|
135
139
|
*/
|
|
136
140
|
url(tableName, queryParams) {
|
|
141
|
+
tableName = this.toTableName(tableName);
|
|
137
142
|
const url = new URL(`${this.config.protocol}://${this.config.host}/${tableName}`);
|
|
138
143
|
if (queryParams)
|
|
139
144
|
Object.entries(queryParams).forEach(([key, value]) => url.searchParams.append(key, value.toString()));
|
|
@@ -153,7 +158,7 @@ class HttpAdapter extends core_1.Adapter {
|
|
|
153
158
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
154
159
|
*/
|
|
155
160
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
|
-
raw(rawInput,
|
|
161
|
+
raw(rawInput, ...args) {
|
|
157
162
|
return Promise.reject(new core_1.UnsupportedError("Api is not natively available for HttpAdapters. If required, please extends this class"));
|
|
158
163
|
}
|
|
159
164
|
/**
|
package/lib/adapter.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Adapter, Condition, Repository, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
2
|
-
import { Context, OperationKeys } from "@decaf-ts/db-decorators";
|
|
1
|
+
import { Adapter, Condition, ContextualArgs, PreparedModel, Repository, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
2
|
+
import { Context, FlagsOf, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { HttpConfig, HttpFlags } from "./types";
|
|
4
|
-
import {
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
5
6
|
import { Statement } from "@decaf-ts/core";
|
|
6
7
|
/**
|
|
7
8
|
* @description Abstract HTTP adapter for REST API interactions
|
|
@@ -35,8 +36,8 @@ import { Statement } from "@decaf-ts/core";
|
|
|
35
36
|
* }
|
|
36
37
|
* ```
|
|
37
38
|
*/
|
|
38
|
-
export declare abstract class HttpAdapter<
|
|
39
|
-
protected constructor(config:
|
|
39
|
+
export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C extends Context<HttpFlags> = Context<HttpFlags>> extends Adapter<CONF, CON, Q, C> {
|
|
40
|
+
protected constructor(config: CONF, flavour: string, alias?: string);
|
|
40
41
|
/**
|
|
41
42
|
* @description Generates operation flags with HTTP headers
|
|
42
43
|
* @summary Extends the base flags method to include HTTP-specific headers for operations.
|
|
@@ -48,17 +49,17 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
48
49
|
* @param {Partial<F>} overrides - Optional flag overrides
|
|
49
50
|
* @return {F} The flags object with headers
|
|
50
51
|
*/
|
|
51
|
-
flags<M extends Model>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE, model: Constructor<M>, overrides: Partial<
|
|
52
|
+
flags<M extends Model>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE, model: Constructor<M>, overrides: Partial<FlagsOf<C>>): Promise<import("@decaf-ts/core").FlagsOf<C>> & {
|
|
52
53
|
headers: {};
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
55
56
|
* @description Returns the repository constructor for this adapter
|
|
56
57
|
* @summary Provides the RestService class as the repository implementation for this HTTP adapter.
|
|
57
58
|
* This method is used to create repository instances that work with this adapter type.
|
|
58
|
-
* @template
|
|
59
|
-
* @return {Constructor<
|
|
59
|
+
* @template R - Repository subtype working with this adapter
|
|
60
|
+
* @return {Constructor<R>} The repository constructor
|
|
60
61
|
*/
|
|
61
|
-
repository<
|
|
62
|
+
repository<R extends Repository<any, Adapter<CONF, CON, Q, C>>>(): Constructor<R>;
|
|
62
63
|
/**
|
|
63
64
|
* @description Prepares a model for persistence
|
|
64
65
|
* @summary Converts a model instance into a format suitable for database storage,
|
|
@@ -66,13 +67,10 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
66
67
|
* @template M - The model type
|
|
67
68
|
* @param {M} model - The model instance to prepare
|
|
68
69
|
* @param pk - The primary key property name
|
|
70
|
+
* @param args
|
|
69
71
|
* @return The prepared data
|
|
70
72
|
*/
|
|
71
|
-
prepare<M extends Model>(model: M,
|
|
72
|
-
record: Record<string, any>;
|
|
73
|
-
id: string;
|
|
74
|
-
transient?: Record<string, any>;
|
|
75
|
-
};
|
|
73
|
+
prepare<M extends Model>(model: M, ...args: ContextualArgs<C>): PreparedModel;
|
|
76
74
|
/**
|
|
77
75
|
* @description Converts database data back into a model instance
|
|
78
76
|
* @summary Reconstructs a model instance from database data, handling column mapping
|
|
@@ -84,7 +82,8 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
84
82
|
* @param {string|number|bigint} id - The primary key value
|
|
85
83
|
* @return {M} The reconstructed model instance
|
|
86
84
|
*/
|
|
87
|
-
revert<M extends Model>(obj: Record<string, any>, clazz: string | Constructor<M>,
|
|
85
|
+
revert<M extends Model>(obj: Record<string, any>, clazz: string | Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): M;
|
|
86
|
+
protected toTableName<M extends Model>(t: string | Constructor<M>): string;
|
|
88
87
|
/**
|
|
89
88
|
* @description Constructs a URL for API requests
|
|
90
89
|
* @summary Builds a complete URL for API requests using the configured protocol and host,
|
|
@@ -93,7 +92,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
93
92
|
* @param {Record<string, string | number>} [queryParams] - Optional query parameters
|
|
94
93
|
* @return {string} The encoded URL string
|
|
95
94
|
*/
|
|
96
|
-
url(tableName: string
|
|
95
|
+
url<M extends Model>(tableName: string | Constructor<M>, queryParams?: Record<string, string | number>): string;
|
|
97
96
|
/**
|
|
98
97
|
* @description Sends an HTTP request
|
|
99
98
|
* @summary Abstract method that must be implemented by subclasses to send HTTP requests
|
|
@@ -113,7 +112,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
113
112
|
* @param {...any[]} args - Additional arguments
|
|
114
113
|
* @return {Promise<Record<string, any>>} A promise that resolves with the created resource
|
|
115
114
|
*/
|
|
116
|
-
abstract create(tableName: string, id:
|
|
115
|
+
abstract create<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
117
116
|
/**
|
|
118
117
|
* @description Retrieves a resource by ID
|
|
119
118
|
* @summary Abstract method that must be implemented by subclasses to retrieve a resource
|
|
@@ -123,7 +122,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
123
122
|
* @param {...any[]} args - Additional arguments
|
|
124
123
|
* @return {Promise<Record<string, any>>} A promise that resolves with the retrieved resource
|
|
125
124
|
*/
|
|
126
|
-
abstract read(tableName: string, id:
|
|
125
|
+
abstract read<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
127
126
|
/**
|
|
128
127
|
* @description Updates an existing resource
|
|
129
128
|
* @summary Abstract method that must be implemented by subclasses to update a resource
|
|
@@ -134,7 +133,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
134
133
|
* @param {...any[]} args - Additional arguments
|
|
135
134
|
* @return {Promise<Record<string, any>>} A promise that resolves with the updated resource
|
|
136
135
|
*/
|
|
137
|
-
abstract update(tableName: string, id: string | number, model: Record<string, any>, ...args:
|
|
136
|
+
abstract update<M extends Model>(tableName: Constructor<M> | string, id: string | number, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
138
137
|
/**
|
|
139
138
|
* @description Deletes a resource by ID
|
|
140
139
|
* @summary Abstract method that must be implemented by subclasses to delete a resource
|
|
@@ -144,7 +143,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
144
143
|
* @param {...any[]} args - Additional arguments
|
|
145
144
|
* @return {Promise<Record<string, any>>} A promise that resolves with the deletion result
|
|
146
145
|
*/
|
|
147
|
-
abstract delete(tableName: string, id:
|
|
146
|
+
abstract delete<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
|
|
148
147
|
/**
|
|
149
148
|
* @description Executes a raw query
|
|
150
149
|
* @summary Method for executing raw queries directly with the HTTP client.
|
|
@@ -157,7 +156,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
157
156
|
* @return {Promise<R>} A promise that resolves with the query result
|
|
158
157
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
159
158
|
*/
|
|
160
|
-
raw<R>(rawInput: Q,
|
|
159
|
+
raw<R>(rawInput: Q, ...args: ContextualArgs<C>): Promise<R>;
|
|
161
160
|
/**
|
|
162
161
|
* @description Creates a sequence
|
|
163
162
|
* @summary Method for creating a sequence for generating unique identifiers.
|
|
@@ -178,7 +177,7 @@ export declare abstract class HttpAdapter<Y extends HttpConfig, CON, Q, F extend
|
|
|
178
177
|
* @return {Statement<Q, M, any>} A statement object for building queries
|
|
179
178
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
180
179
|
*/
|
|
181
|
-
Statement<M extends Model>(): Statement<
|
|
180
|
+
Statement<M extends Model>(): Statement<M, Adapter<CONF, CON, Q, C>, any>;
|
|
182
181
|
/**
|
|
183
182
|
* @description Parses a condition into a query
|
|
184
183
|
* @summary Method for parsing a condition object into a query format understood by the HTTP client.
|
package/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;AAAA,yCAUwB;AACxB,2DAMiC;AAEjC,yEAAuD;AAEvD,mDAA4C;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAsB,WAKpB,SAAQ,cAAwB;IAChC,YAAsB,MAAY,EAAE,OAAe,EAAE,KAAc;QACjE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;;;;;OAUG;IACM,KAAK,CACZ,SAIwB,EACxB,KAAqB,EACrB,SAA8B;QAE9B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAI,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE;YAChE,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACM,UAAU;QAGjB,OAAO,yBAAwC,CAAC;IAClD,CAAC;IAED;;;;;;;;;OASG;IACM,OAAO,CACd,KAAQ,EACR,GAAG,IAAuB;QAE1B,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACxC,IAAK,KAAa,CAAC,sBAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7C,GAAG,CAAC,KAAK,CACP,0CAA2C,KAAa,CAAC,sBAAe,CAAC,QAAQ,CAAC,EAAE,CACrF,CAAC;YACF,MAAM,CAAC,cAAc,CAAC,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G,IAAuB;QAC5C,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,uBAAgB,CAClB,wFAAwF,CACzF,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,6DAA6D;IAC7D,QAAQ,CAAC,OAAwB;QAC/B,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,uBAAgB,CAClB,wFAAwF,CACzF,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACM,SAAS;QAKhB,MAAM,IAAI,uBAAgB,CACxB,wFAAwF,CACzF,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,6DAA6D;IAC7D,cAAc,CAAC,SAAyB;QACtC,MAAM,IAAI,uBAAgB,CACxB,wFAAwF,CACzF,CAAC;IACJ,CAAC;CACF;AAhTD,kCAgTC"}
|
package/lib/axios/axios.cjs
CHANGED
|
@@ -4,8 +4,8 @@ exports.AxiosHttpAdapter = void 0;
|
|
|
4
4
|
const adapter_1 = require("./../adapter.cjs");
|
|
5
5
|
const axios_1 = require("axios");
|
|
6
6
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
7
|
-
const constants_1 = require("./constants.cjs");
|
|
8
7
|
const core_1 = require("@decaf-ts/core");
|
|
8
|
+
const constants_1 = require("./constants.cjs");
|
|
9
9
|
/**
|
|
10
10
|
* @description Axios implementation of the HTTP adapter
|
|
11
11
|
* @summary Concrete implementation of HttpAdapter using Axios as the HTTP client.
|
|
@@ -82,7 +82,9 @@ class AxiosHttpAdapter extends adapter_1.HttpAdapter {
|
|
|
82
82
|
* @param {Record<string, any>} model - The data model to create
|
|
83
83
|
* @return {Promise<Record<string, any>>} A promise that resolves with the created resource
|
|
84
84
|
*/
|
|
85
|
-
async create(tableName, id, model
|
|
85
|
+
async create(tableName, id, model,
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
+
..._args) {
|
|
86
88
|
try {
|
|
87
89
|
const url = this.url(tableName);
|
|
88
90
|
return this.client.post(url, model);
|
|
@@ -99,9 +101,13 @@ class AxiosHttpAdapter extends adapter_1.HttpAdapter {
|
|
|
99
101
|
* @param {string|number|bigint} id - The identifier for the resource to retrieve
|
|
100
102
|
* @return {Promise<Record<string, any>>} A promise that resolves with the retrieved resource
|
|
101
103
|
*/
|
|
102
|
-
async read(tableName, id
|
|
104
|
+
async read(tableName, id,
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
106
|
+
...args) {
|
|
103
107
|
try {
|
|
104
|
-
const url = this.url(tableName, {
|
|
108
|
+
const url = this.url(tableName, {
|
|
109
|
+
id: id,
|
|
110
|
+
});
|
|
105
111
|
return this.client.get(url);
|
|
106
112
|
}
|
|
107
113
|
catch (e) {
|
|
@@ -117,7 +123,9 @@ class AxiosHttpAdapter extends adapter_1.HttpAdapter {
|
|
|
117
123
|
* @param {Record<string, any>} model - The updated data model
|
|
118
124
|
* @return {Promise<Record<string, any>>} A promise that resolves with the updated resource
|
|
119
125
|
*/
|
|
120
|
-
async update(tableName, id, model
|
|
126
|
+
async update(tableName, id, model,
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
128
|
+
..._args) {
|
|
121
129
|
try {
|
|
122
130
|
const url = this.url(tableName);
|
|
123
131
|
return this.client.put(url, model);
|
|
@@ -134,16 +142,21 @@ class AxiosHttpAdapter extends adapter_1.HttpAdapter {
|
|
|
134
142
|
* @param {string|number|bigint} id - The identifier for the resource to delete
|
|
135
143
|
* @return {Promise<Record<string, any>>} A promise that resolves with the deletion result
|
|
136
144
|
*/
|
|
137
|
-
async delete(tableName, id
|
|
145
|
+
async delete(tableName, id,
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
147
|
+
..._args) {
|
|
138
148
|
try {
|
|
139
|
-
const url = this.url(tableName, {
|
|
149
|
+
const url = this.url(tableName, {
|
|
150
|
+
id: id,
|
|
151
|
+
});
|
|
140
152
|
return this.client.delete(url);
|
|
141
153
|
}
|
|
142
154
|
catch (e) {
|
|
143
155
|
throw this.parseError(e);
|
|
144
156
|
}
|
|
145
157
|
}
|
|
146
|
-
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
159
|
+
parseError(err, ...args) {
|
|
147
160
|
const errs = [
|
|
148
161
|
db_decorators_1.InternalError,
|
|
149
162
|
core_1.AuthorizationError,
|
package/lib/axios/axios.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import { HttpAdapter } from "../adapter";
|
|
|
2
2
|
import { Axios, AxiosRequestConfig } from "axios";
|
|
3
3
|
import { HttpConfig } from "../types";
|
|
4
4
|
import { AxiosFlags } from "./types";
|
|
5
|
-
import { BaseError, Context } from "@decaf-ts/db-decorators";
|
|
5
|
+
import { BaseError, Context, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
6
|
+
import { ContextualArgs } from "@decaf-ts/core";
|
|
7
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
8
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
6
9
|
/**
|
|
7
10
|
* @description Axios implementation of the HTTP adapter
|
|
8
11
|
* @summary Concrete implementation of HttpAdapter using Axios as the HTTP client.
|
|
@@ -50,7 +53,7 @@ import { BaseError, Context } from "@decaf-ts/db-decorators";
|
|
|
50
53
|
* Axios-->>AxiosHttpAdapter: Response Data
|
|
51
54
|
* AxiosHttpAdapter-->>Client: Resource Data
|
|
52
55
|
*/
|
|
53
|
-
export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, AxiosRequestConfig,
|
|
56
|
+
export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, AxiosRequestConfig, Context<AxiosFlags>> {
|
|
54
57
|
constructor(config: HttpConfig, alias?: string);
|
|
55
58
|
protected getClient(): Axios;
|
|
56
59
|
/**
|
|
@@ -71,7 +74,7 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
71
74
|
* @param {Record<string, any>} model - The data model to create
|
|
72
75
|
* @return {Promise<Record<string, any>>} A promise that resolves with the created resource
|
|
73
76
|
*/
|
|
74
|
-
create(tableName: string, id:
|
|
77
|
+
create<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, model: Record<string, any>, ..._args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
75
78
|
/**
|
|
76
79
|
* @description Retrieves a resource by ID via HTTP GET
|
|
77
80
|
* @summary Implementation of the abstract read method from HttpAdapter.
|
|
@@ -80,7 +83,7 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
80
83
|
* @param {string|number|bigint} id - The identifier for the resource to retrieve
|
|
81
84
|
* @return {Promise<Record<string, any>>} A promise that resolves with the retrieved resource
|
|
82
85
|
*/
|
|
83
|
-
read(tableName: string, id:
|
|
86
|
+
read<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, ...args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
84
87
|
/**
|
|
85
88
|
* @description Updates an existing resource via HTTP PUT
|
|
86
89
|
* @summary Implementation of the abstract update method from HttpAdapter.
|
|
@@ -90,7 +93,7 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
90
93
|
* @param {Record<string, any>} model - The updated data model
|
|
91
94
|
* @return {Promise<Record<string, any>>} A promise that resolves with the updated resource
|
|
92
95
|
*/
|
|
93
|
-
update(tableName: string, id: string | number, model: Record<string, any
|
|
96
|
+
update<M extends Model>(tableName: Constructor<M> | string, id: string | number, model: Record<string, any>, ..._args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
94
97
|
/**
|
|
95
98
|
* @description Deletes a resource by ID via HTTP DELETE
|
|
96
99
|
* @summary Implementation of the abstract delete method from HttpAdapter.
|
|
@@ -99,6 +102,6 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
99
102
|
* @param {string|number|bigint} id - The identifier for the resource to delete
|
|
100
103
|
* @return {Promise<Record<string, any>>} A promise that resolves with the deletion result
|
|
101
104
|
*/
|
|
102
|
-
delete(tableName: string, id:
|
|
103
|
-
parseError(err: Error):
|
|
105
|
+
delete<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, ..._args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
106
|
+
parseError<E extends BaseError>(err: Error, ...args: any[]): E;
|
|
104
107
|
}
|
package/lib/axios/axios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/axios/axios.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,iCAAkD;AAGlD,
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/axios/axios.ts"],"names":[],"mappings":";;;AAAA,8CAAyC;AACzC,iCAAkD;AAGlD,2DAOiC;AACjC,yCAIwB;AACxB,+CAA2C;AAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,gBAAiB,SAAQ,qBAKrC;IACC,YAAY,MAAkB,EAAE,KAAc;QAC5C,KAAK,CAAC,MAAM,EAAE,wBAAY,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAEkB,SAAS;QAC1B,OAAO,IAAI,aAAK,CAAC;YACf,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;SACnC,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACM,KAAK,CAAC,OAAO,CAAI,OAA2B;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;OAQG;IACM,KAAK,CAAC,MAAM,CACnB,SAAkC,EAClC,EAAkB,EAClB,KAA0B;IAC1B,6DAA6D;IAC7D,GAAG,KAA0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GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;gBAC9B,EAAE,EAAE,EAAqB;aAC1B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,6DAA6D;IACpD,UAAU,CAAsB,GAAU,EAAE,GAAG,IAAW;QACjE,MAAM,IAAI,GAAG;YACX,6BAAa;YACb,yBAAkB;YAClB,6BAAa;YACb,6BAAa;YACb,uBAAgB;SACjB,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,IAAK,GAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;gBAC7C,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAM,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,6BAAa,CAAC,GAAG,CAAC,OAAO,CAAM,CAAC;IAC7C,CAAC;CACF;AA1ID,4CA0IC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Repository } from "@decaf-ts/core";
|
|
2
|
-
import {
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
4
|
import { HttpAdapter } from "./adapter";
|
|
4
|
-
import { Context } from "@decaf-ts/db-decorators";
|
|
5
|
-
import { HttpFlags } from "./types";
|
|
6
5
|
/**
|
|
7
6
|
* @description Repository for REST API interactions
|
|
8
7
|
* @summary A specialized repository implementation for interacting with REST APIs.
|
|
@@ -32,8 +31,8 @@ import { HttpFlags } from "./types";
|
|
|
32
31
|
* ```
|
|
33
32
|
* @see {@link RestService}
|
|
34
33
|
*/
|
|
35
|
-
export declare class RestRepository<M extends Model,
|
|
34
|
+
export declare class RestRepository<M extends Model, A extends HttpAdapter<any, any, any, any>, Q = A extends HttpAdapter<any, any, infer Q, any> ? Q : never> extends Repository<M, A> {
|
|
36
35
|
constructor(adapter: A, clazz?: Constructor<M>);
|
|
37
|
-
url(path: string
|
|
38
|
-
request<
|
|
36
|
+
url(path: string | Constructor<M>, queryParams?: Record<string, string | number>): string;
|
|
37
|
+
request<R>(details: Q): Promise<R>;
|
|
39
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestRepository.js","sourceRoot":"","sources":["../../src/RestRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"RestRepository.js","sourceRoot":"","sources":["../../src/RestRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,cAIX,SAAQ,UAAgB;IACxB,YAAY,OAAU,EAAE,KAAsB;QAC5C,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,GAAG,CACD,IAA6B,EAC7B,WAA6C;QAE7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO,CAAI,OAAU;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAI,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF"}
|