@decaf-ts/for-http 0.3.3 → 0.3.5
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 +6 -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/HttpPaginator.cjs +69 -0
- package/lib/HttpPaginator.d.ts +10 -0
- package/lib/HttpPaginator.js.map +1 -0
- package/lib/HttpStatement.cjs +111 -0
- package/lib/HttpStatement.d.ts +9 -0
- package/lib/HttpStatement.js.map +1 -0
- package/lib/RestRepository.cjs +38 -4
- package/lib/RestRepository.d.ts +10 -4
- package/lib/RestRepository.js.map +1 -1
- package/lib/RestService.d.ts +1 -1
- package/lib/adapter.cjs +50 -9
- package/lib/adapter.d.ts +33 -10
- package/lib/adapter.js.map +1 -1
- package/lib/axios/axios.cjs +57 -15
- package/lib/axios/axios.d.ts +10 -7
- package/lib/axios/axios.js.map +1 -1
- package/lib/esm/HttpPaginator.d.ts +10 -0
- package/lib/esm/HttpPaginator.js +65 -0
- package/lib/esm/HttpPaginator.js.map +1 -0
- package/lib/esm/HttpStatement.d.ts +9 -0
- package/lib/esm/HttpStatement.js +107 -0
- package/lib/esm/HttpStatement.js.map +1 -0
- package/lib/esm/RestRepository.d.ts +10 -4
- package/lib/esm/RestRepository.js +39 -5
- package/lib/esm/RestRepository.js.map +1 -1
- package/lib/esm/RestService.d.ts +1 -1
- package/lib/esm/adapter.d.ts +33 -10
- package/lib/esm/adapter.js +51 -10
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/axios/axios.d.ts +10 -7
- package/lib/esm/axios/axios.js +57 -15
- 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/esm/types.d.ts +7 -0
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/types.d.ts +7 -0
- package/package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AAC,CAAC;QAC7D,CAAC;QAED,OAAO,MAEE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Repository } from "@decaf-ts/core";
|
|
1
|
+
import { ContextOf, MaybeContextualArg, OrderDirection, Paginator, Repository } from "@decaf-ts/core";
|
|
2
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { Constructor } from "@decaf-ts/decoration";
|
|
4
4
|
import { HttpAdapter } from "./adapter";
|
|
@@ -31,8 +31,14 @@ import { HttpAdapter } from "./adapter";
|
|
|
31
31
|
* ```
|
|
32
32
|
* @see {@link RestService}
|
|
33
33
|
*/
|
|
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> {
|
|
34
|
+
export declare class RestRepository<M extends Model, A extends HttpAdapter<any, any, any, any, any>, Q = A extends HttpAdapter<any, any, any, infer Q, any> ? Q : never> extends Repository<M, A> {
|
|
35
35
|
constructor(adapter: A, clazz?: Constructor<M>);
|
|
36
|
-
url(
|
|
37
|
-
|
|
36
|
+
url<M extends Model>(tableName: string | Constructor<M>): string;
|
|
37
|
+
url<M extends Model>(tableName: string | Constructor<M>, pathParams: string[]): string;
|
|
38
|
+
url<M extends Model>(tableName: string | Constructor<M>, queryParams: Record<string, string | number> | undefined): string;
|
|
39
|
+
paginateBy(key: keyof M, order: OrderDirection, size: number, ...args: MaybeContextualArg<ContextOf<A>>): Promise<Paginator<M, M[], any>>;
|
|
40
|
+
listBy(key: keyof M, order: OrderDirection, ...args: MaybeContextualArg<ContextOf<A>>): Promise<any>;
|
|
41
|
+
findOneBy(key: keyof M, value: any, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>;
|
|
42
|
+
statement(name: string, ...args: MaybeContextualArg<ContextOf<A>>): Promise<any>;
|
|
43
|
+
request<R>(details: Q, ...args: MaybeContextualArg<ContextOf<A>>): Promise<R>;
|
|
38
44
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Repository } from "@decaf-ts/core";
|
|
1
|
+
import { Repository, } from "@decaf-ts/core";
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
import { Context } from "@decaf-ts/db-decorators";
|
|
2
4
|
/**
|
|
3
5
|
* @description Repository for REST API interactions
|
|
4
6
|
* @summary A specialized repository implementation for interacting with REST APIs.
|
|
@@ -32,11 +34,43 @@ export class RestRepository extends Repository {
|
|
|
32
34
|
constructor(adapter, clazz) {
|
|
33
35
|
super(adapter, clazz);
|
|
34
36
|
}
|
|
35
|
-
url(
|
|
36
|
-
return this.adapter.url(
|
|
37
|
+
url(tableName, pathParams, queryParams) {
|
|
38
|
+
return this.adapter.url(tableName, pathParams, queryParams);
|
|
37
39
|
}
|
|
38
|
-
async
|
|
39
|
-
|
|
40
|
+
async paginateBy(key, order, size, ...args) {
|
|
41
|
+
const contextArgs = await Context.args("paginateBy", this.class, args, this.adapter, this._overrides || {});
|
|
42
|
+
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.paginateBy);
|
|
43
|
+
log.verbose(`paginating ${Model.tableName(this.class)} with page size ${size}`);
|
|
44
|
+
return (await this.statement(this.paginateBy.name, key, order, size, ...ctxArgs));
|
|
45
|
+
}
|
|
46
|
+
async listBy(key, order, ...args) {
|
|
47
|
+
const contextArgs = await Context.args("list", this.class, args, this.adapter, this._overrides || {});
|
|
48
|
+
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.listBy);
|
|
49
|
+
log.verbose(`listing ${Model.tableName(this.class)} by ${key} ${order}`);
|
|
50
|
+
return (await this.statement(this.listBy.name, key, order, ...ctxArgs));
|
|
51
|
+
}
|
|
52
|
+
async findOneBy(key, value, ...args) {
|
|
53
|
+
const contextArgs = await Context.args("findOneBy", this.class, args, this.adapter, this._overrides || {});
|
|
54
|
+
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.findOneBy);
|
|
55
|
+
log.verbose(`finding ${Model.tableName(this.class)} with ${key} ${value}`);
|
|
56
|
+
return (await this.statement(this.findOneBy.name, key, value, ...ctxArgs));
|
|
57
|
+
}
|
|
58
|
+
async statement(name, ...args) {
|
|
59
|
+
const contextArgs = await Context.args("statement", this.class, args, this.adapter, this._overrides || {});
|
|
60
|
+
const { log, ctxArgs, ctx } = this.logCtx(contextArgs.args, this.statement);
|
|
61
|
+
const query = {
|
|
62
|
+
class: this.class,
|
|
63
|
+
args: args,
|
|
64
|
+
method: name,
|
|
65
|
+
};
|
|
66
|
+
const req = this.adapter.toRequest(query, ctx);
|
|
67
|
+
log.verbose(`Executing prepared statement ${name}`);
|
|
68
|
+
return this.request(req, ...ctxArgs);
|
|
69
|
+
}
|
|
70
|
+
async request(details, ...args) {
|
|
71
|
+
const contextArgs = await Context.args("request", this.class, args, this.adapter, this._overrides || {});
|
|
72
|
+
const { ctxArgs } = this.logCtx(contextArgs.args, this.request);
|
|
73
|
+
return this.adapter.request(details, ...ctxArgs);
|
|
40
74
|
}
|
|
41
75
|
}
|
|
42
76
|
//# sourceMappingURL=RestRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RestRepository.js","sourceRoot":"","sources":["../../src/RestRepository.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RestRepository.js","sourceRoot":"","sources":["../../src/RestRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAGvD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,cAIX,SAAQ,UAAgB;IACxB,YAAY,OAAU,EAAE,KAAsB;QAC5C,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;IAWD,GAAG,CACD,SAAk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,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAI;SACb,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/C,GAAG,CAAC,OAAO,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,OAAO,CACX,OAAU,EACV,GAAG,IAAsC;QAEzC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,IAAI,CACpC,SAAS,EACT,IAAI,CAAC,KAAK,EACV,IAAI,EACJ,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,UAAU,IAAI,EAAE,CACtB,CAAC;QACF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAI,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;IACtD,CAAC;CACF"}
|
package/lib/esm/RestService.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ import { RestRepository } from "./RestRepository";
|
|
|
51
51
|
* Adapter-->>Service: record
|
|
52
52
|
* Service-->>Client: revert(record)
|
|
53
53
|
*/
|
|
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> {
|
|
54
|
+
export declare class RestService<M extends Model, A extends HttpAdapter<any, any, any, any, any>, Q = A extends HttpAdapter<any, any, any, infer Q, any> ? Q : never> extends RestRepository<M, A, Q> {
|
|
55
55
|
protected _overrides: Partial<FlagsOf<A>>;
|
|
56
56
|
/**
|
|
57
57
|
* @description Initializes a new RestService instance
|
package/lib/esm/adapter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Adapter, Condition, ContextualArgs, PreparedModel, Repository, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
1
|
+
import { Adapter, Condition, ContextualArgs, MaybeContextualArg, PreparedModel, Repository, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
2
2
|
import { BaseError, Context, FlagsOf, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
3
|
-
import { HttpConfig, HttpFlags } from "./types";
|
|
3
|
+
import { HttpConfig, HttpFlags, HttpQuery } from "./types";
|
|
4
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
5
|
import { Constructor } from "@decaf-ts/decoration";
|
|
6
6
|
import { Statement } from "@decaf-ts/core";
|
|
@@ -36,7 +36,7 @@ import { Statement } from "@decaf-ts/core";
|
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C extends Context<HttpFlags> = Context<HttpFlags>> extends Adapter<CONF, CON, Q, C> {
|
|
39
|
+
export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, REQ, Q extends HttpQuery = HttpQuery, C extends Context<HttpFlags> = Context<HttpFlags>> extends Adapter<CONF, CON, Q, C> {
|
|
40
40
|
protected constructor(config: CONF, flavour: string, alias?: string);
|
|
41
41
|
/**
|
|
42
42
|
* @description Generates operation flags with HTTP headers
|
|
@@ -49,9 +49,9 @@ export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C ext
|
|
|
49
49
|
* @param {Partial<F>} overrides - Optional flag overrides
|
|
50
50
|
* @return {F} The flags object with headers
|
|
51
51
|
*/
|
|
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
|
+
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> & {
|
|
53
53
|
headers: {};
|
|
54
|
-
}
|
|
54
|
+
}>;
|
|
55
55
|
/**
|
|
56
56
|
* @description Returns the repository constructor for this adapter
|
|
57
57
|
* @summary Provides the RestService class as the repository implementation for this HTTP adapter.
|
|
@@ -88,20 +88,42 @@ export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C ext
|
|
|
88
88
|
* @description Constructs a URL for API requests
|
|
89
89
|
* @summary Builds a complete URL for API requests using the configured protocol and host,
|
|
90
90
|
* the specified table name, and optional query parameters. The method handles URL encoding.
|
|
91
|
-
* @param {string} tableName - The name of the table or endpoint
|
|
92
|
-
* @
|
|
91
|
+
* @param {string | Constructor} tableName - The name of the table or endpoint
|
|
92
|
+
* @return {string} The encoded URL string
|
|
93
|
+
*/
|
|
94
|
+
url<M extends Model>(tableName: string | Constructor<M>): string;
|
|
95
|
+
/**
|
|
96
|
+
* @description Constructs a URL for API requests
|
|
97
|
+
* @summary Builds a complete URL for API requests using the configured protocol and host,
|
|
98
|
+
* the specified table name, and optional query parameters. The method handles URL encoding.
|
|
99
|
+
* @param {string | Constructor} tableName - The name of the table or endpoint
|
|
100
|
+
* @param {string[]} pathParams - Optional query parameters
|
|
101
|
+
* @return {string} The encoded URL string
|
|
102
|
+
*/
|
|
103
|
+
url<M extends Model>(tableName: string | Constructor<M>, pathParams: string[]): string;
|
|
104
|
+
/**
|
|
105
|
+
* @description Constructs a URL for API requests
|
|
106
|
+
* @summary Builds a complete URL for API requests using the configured protocol and host,
|
|
107
|
+
* the specified table name, and optional query parameters. The method handles URL encoding.
|
|
108
|
+
* @param {string | Constructor} tableName - The name of the table or endpoint
|
|
109
|
+
* @param {Record<string, string | number>} queryParams - Optional query parameters
|
|
93
110
|
* @return {string} The encoded URL string
|
|
94
111
|
*/
|
|
95
|
-
url<M extends Model>(tableName: string | Constructor<M>, queryParams
|
|
112
|
+
url<M extends Model>(tableName: string | Constructor<M>, queryParams: Record<string, string | number>): string;
|
|
113
|
+
url<M extends Model>(tableName: string | Constructor<M>, pathParams: string[], queryParams: Record<string, string | number>): string;
|
|
114
|
+
abstract toRequest(query: Q): REQ;
|
|
115
|
+
abstract toRequest(ctx: C): REQ;
|
|
116
|
+
abstract toRequest(query: Q, ctx: C): REQ;
|
|
117
|
+
abstract toRequest(ctxOrQuery: C | Q, ctx?: C): REQ;
|
|
96
118
|
/**
|
|
97
119
|
* @description Sends an HTTP request
|
|
98
120
|
* @summary Abstract method that must be implemented by subclasses to send HTTP requests
|
|
99
121
|
* using the native HTTP client. This is the core method for making API calls.
|
|
100
122
|
* @template V - The response value type
|
|
101
|
-
* @param {
|
|
123
|
+
* @param {REQ} details - The request details specific to the HTTP client
|
|
102
124
|
* @return {Promise<V>} A promise that resolves with the response data
|
|
103
125
|
*/
|
|
104
|
-
abstract request<V>(details:
|
|
126
|
+
abstract request<V>(details: REQ, ...args: MaybeContextualArg<C>): Promise<V>;
|
|
105
127
|
/**
|
|
106
128
|
* @description Creates a new resource
|
|
107
129
|
* @summary Abstract method that must be implemented by subclasses to create a new resource
|
|
@@ -189,4 +211,5 @@ export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, Q, C ext
|
|
|
189
211
|
*/
|
|
190
212
|
parseCondition(condition: Condition<any>): Q;
|
|
191
213
|
static parseError<E extends BaseError>(err: Error | string, ...args: any[]): E;
|
|
214
|
+
static decoration(): void;
|
|
192
215
|
}
|
package/lib/esm/adapter.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { Adapter, AuthorizationError, ConnectionError, ForbiddenError, MigrationError, ObserverError, PagingError, PersistenceKeys, QueryError, UnsupportedError, } from "@decaf-ts/core";
|
|
2
|
-
import { BadRequestError, ConflictError, InternalError, NotFoundError, SerializationError, } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { BadRequestError, ConflictError, Context, InternalError, NotFoundError, SerializationError, } from "@decaf-ts/db-decorators";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
import { apply, Decoration, methodMetadata, Metadata, } from "@decaf-ts/decoration";
|
|
4
5
|
import { RestService } from "./RestService.js";
|
|
6
|
+
import { prepared } from "@decaf-ts/core";
|
|
7
|
+
import { toKebabCase } from "@decaf-ts/logging";
|
|
8
|
+
import { HttpStatement } from "./HttpStatement.js";
|
|
5
9
|
/**
|
|
6
10
|
* @description Abstract HTTP adapter for REST API interactions
|
|
7
11
|
* @summary Provides a base implementation for HTTP adapters with methods for CRUD operations,
|
|
@@ -49,8 +53,8 @@ export class HttpAdapter extends Adapter {
|
|
|
49
53
|
* @param {Partial<F>} overrides - Optional flag overrides
|
|
50
54
|
* @return {F} The flags object with headers
|
|
51
55
|
*/
|
|
52
|
-
flags(operation, model, overrides) {
|
|
53
|
-
return Object.assign(super.flags(operation, model, overrides), {
|
|
56
|
+
async flags(operation, model, overrides) {
|
|
57
|
+
return Object.assign(await super.flags(operation, model, overrides), {
|
|
54
58
|
headers: {},
|
|
55
59
|
});
|
|
56
60
|
}
|
|
@@ -124,19 +128,26 @@ export class HttpAdapter extends Adapter {
|
|
|
124
128
|
return result;
|
|
125
129
|
}
|
|
126
130
|
toTableName(t) {
|
|
127
|
-
return typeof t === "string" ? t : Model.tableName(t);
|
|
131
|
+
return typeof t === "string" ? t : toKebabCase(Model.tableName(t));
|
|
128
132
|
}
|
|
129
133
|
/**
|
|
130
134
|
* @description Constructs a URL for API requests
|
|
131
135
|
* @summary Builds a complete URL for API requests using the configured protocol and host,
|
|
132
136
|
* the specified table name, and optional query parameters. The method handles URL encoding.
|
|
133
|
-
* @param {string} tableName - The name of the table or endpoint
|
|
137
|
+
* @param {string | Constructor} tableName - The name of the table or endpoint
|
|
138
|
+
* @param {string[]} [pathParams] - Optional query parameters
|
|
134
139
|
* @param {Record<string, string | number>} [queryParams] - Optional query parameters
|
|
135
140
|
* @return {string} The encoded URL string
|
|
136
141
|
*/
|
|
137
|
-
url(tableName, queryParams) {
|
|
142
|
+
url(tableName, pathParams, queryParams) {
|
|
143
|
+
if (!queryParams) {
|
|
144
|
+
if (pathParams && !Array.isArray(pathParams)) {
|
|
145
|
+
queryParams = pathParams;
|
|
146
|
+
pathParams = [];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
138
149
|
tableName = this.toTableName(tableName);
|
|
139
|
-
const url = new URL(`${this.config.protocol}://${this.config.host}/${tableName}`);
|
|
150
|
+
const url = new URL(`${this.config.protocol}://${this.config.host}/${tableName}${pathParams && pathParams.length ? `/${pathParams.join("/")}` : ""}`);
|
|
140
151
|
if (queryParams)
|
|
141
152
|
Object.entries(queryParams).forEach(([key, value]) => url.searchParams.append(key, value.toString()));
|
|
142
153
|
// ensure spaces are encoded as %20 (not '+') to match expectations
|
|
@@ -154,9 +165,10 @@ export class HttpAdapter extends Adapter {
|
|
|
154
165
|
* @return {Promise<R>} A promise that resolves with the query result
|
|
155
166
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
156
167
|
*/
|
|
157
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
158
168
|
raw(rawInput, ...args) {
|
|
159
|
-
|
|
169
|
+
const { ctxArgs, ctx } = this.logCtx(args, this.raw);
|
|
170
|
+
const req = this.toRequest(rawInput, ctx);
|
|
171
|
+
return this.request(req, ...ctxArgs);
|
|
160
172
|
}
|
|
161
173
|
/**
|
|
162
174
|
* @description Creates a sequence
|
|
@@ -182,7 +194,7 @@ export class HttpAdapter extends Adapter {
|
|
|
182
194
|
* @throws {UnsupportedError} Always throws as this method is not supported by default
|
|
183
195
|
*/
|
|
184
196
|
Statement() {
|
|
185
|
-
|
|
197
|
+
return new HttpStatement(this);
|
|
186
198
|
}
|
|
187
199
|
/**
|
|
188
200
|
* @description Parses a condition into a query
|
|
@@ -227,5 +239,34 @@ export class HttpAdapter extends Adapter {
|
|
|
227
239
|
return new SerializationError(err);
|
|
228
240
|
return new InternalError(err);
|
|
229
241
|
}
|
|
242
|
+
static decoration() {
|
|
243
|
+
super.decoration();
|
|
244
|
+
function query(options) {
|
|
245
|
+
return function query(obj, prop, descriptor) {
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
247
|
+
function innerQuery(options) {
|
|
248
|
+
return function innerQuery(obj, propertyKey, descriptor) {
|
|
249
|
+
descriptor.value = new Proxy(descriptor.value, {
|
|
250
|
+
async apply(target, thisArg, args) {
|
|
251
|
+
const repo = thisArg;
|
|
252
|
+
const contextArgs = await Context.args(propertyKey, repo.class, args, repo["adapter"], repo["_overrides"] || {});
|
|
253
|
+
const { log, ctxArgs } = repo["logCtx"](contextArgs.args, target);
|
|
254
|
+
log.verbose(`Running prepared statement ${target.name}`);
|
|
255
|
+
log.debug(`With args: ${JSON.stringify(args, null, 2)}`);
|
|
256
|
+
return thisArg.statement(target.name, ...ctxArgs);
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return apply(methodMetadata(Metadata.key(PersistenceKeys.QUERY, prop), options), prepared(), innerQuery(options))(obj, prop, descriptor);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
Decoration.for(PersistenceKeys.QUERY)
|
|
265
|
+
.define({
|
|
266
|
+
decorator: query,
|
|
267
|
+
})
|
|
268
|
+
.apply();
|
|
269
|
+
}
|
|
230
270
|
}
|
|
271
|
+
HttpAdapter.decoration();
|
|
231
272
|
//# sourceMappingURL=adapter.js.map
|
package/lib/esm/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAElB,eAAe,EAEf,cAAc,
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/adapter.ts"],"names":[],"mappings":"AAAA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KAAK,CAAC,cAAc,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;gCACzD,OAAQ,OAAgC,CAAC,SAAS,CAChD,MAAM,CAAC,IAAI,EACX,GAAG,OAAO,CACX,CAAC;4BACJ,CAAC;yBACF,CACF,CAAC;oBACJ,CAAC,CAAC;gBACJ,CAAC;gBAED,OAAO,KAAK,CACV,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,EAClE,QAAQ,EAAE,EACV,UAAU,CAAC,OAAO,CAAC,CACpB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;YAC3B,CAAC,CAAC;QACJ,CAAC;QAED,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC;aAClC,MAAM,CAAC;YACN,SAAS,EAAE,KAAK;SACV,CAAC;aACR,KAAK,EAAE,CAAC;IACb,CAAC;CACF;AAED,WAAW,CAAC,UAAU,EAAE,CAAC"}
|
package/lib/esm/axios/axios.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HttpAdapter } from "../adapter";
|
|
2
2
|
import { Axios, AxiosRequestConfig } from "axios";
|
|
3
|
-
import { HttpConfig } from "../types";
|
|
3
|
+
import { HttpConfig, HttpQuery } from "../types";
|
|
4
4
|
import { AxiosFlags } from "./types";
|
|
5
5
|
import { BaseError, Context, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
6
|
-
import { ContextualArgs } from "@decaf-ts/core";
|
|
6
|
+
import { ContextualArgs, MaybeContextualArg } from "@decaf-ts/core";
|
|
7
7
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
8
8
|
import { Constructor } from "@decaf-ts/decoration";
|
|
9
9
|
/**
|
|
@@ -53,9 +53,12 @@ import { Constructor } from "@decaf-ts/decoration";
|
|
|
53
53
|
* Axios-->>AxiosHttpAdapter: Response Data
|
|
54
54
|
* AxiosHttpAdapter-->>Client: Resource Data
|
|
55
55
|
*/
|
|
56
|
-
export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, AxiosRequestConfig, Context<AxiosFlags>> {
|
|
56
|
+
export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, AxiosRequestConfig, HttpQuery, Context<AxiosFlags>> {
|
|
57
57
|
constructor(config: HttpConfig, alias?: string);
|
|
58
58
|
protected getClient(): Axios;
|
|
59
|
+
toRequest(query: HttpQuery): AxiosRequestConfig;
|
|
60
|
+
toRequest(ctx: Context<AxiosFlags>): AxiosRequestConfig;
|
|
61
|
+
toRequest(query: HttpQuery, ctx: Context<AxiosFlags>): AxiosRequestConfig;
|
|
59
62
|
/**
|
|
60
63
|
* @description Sends an HTTP request using Axios
|
|
61
64
|
* @summary Implementation of the abstract request method from HttpAdapter.
|
|
@@ -64,7 +67,7 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
64
67
|
* @param {AxiosRequestConfig} details - The Axios request configuration
|
|
65
68
|
* @return {Promise<V>} A promise that resolves with the response data
|
|
66
69
|
*/
|
|
67
|
-
request<V>(details: AxiosRequestConfig): Promise<V>;
|
|
70
|
+
request<V>(details: AxiosRequestConfig, ...args: MaybeContextualArg<Context<AxiosFlags>>): Promise<V>;
|
|
68
71
|
/**
|
|
69
72
|
* @description Creates a new resource via HTTP POST
|
|
70
73
|
* @summary Implementation of the abstract create method from HttpAdapter.
|
|
@@ -74,7 +77,7 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
74
77
|
* @param {Record<string, any>} model - The data model to create
|
|
75
78
|
* @return {Promise<Record<string, any>>} A promise that resolves with the created resource
|
|
76
79
|
*/
|
|
77
|
-
create<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, model: Record<string, any>, ...
|
|
80
|
+
create<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
78
81
|
/**
|
|
79
82
|
* @description Retrieves a resource by ID via HTTP GET
|
|
80
83
|
* @summary Implementation of the abstract read method from HttpAdapter.
|
|
@@ -93,7 +96,7 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
93
96
|
* @param {Record<string, any>} model - The updated data model
|
|
94
97
|
* @return {Promise<Record<string, any>>} A promise that resolves with the updated resource
|
|
95
98
|
*/
|
|
96
|
-
update<M extends Model>(tableName: Constructor<M> | string, id:
|
|
99
|
+
update<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
97
100
|
/**
|
|
98
101
|
* @description Deletes a resource by ID via HTTP DELETE
|
|
99
102
|
* @summary Implementation of the abstract delete method from HttpAdapter.
|
|
@@ -102,6 +105,6 @@ export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, Axi
|
|
|
102
105
|
* @param {string|number|bigint} id - The identifier for the resource to delete
|
|
103
106
|
* @return {Promise<Record<string, any>>} A promise that resolves with the deletion result
|
|
104
107
|
*/
|
|
105
|
-
delete<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, ...
|
|
108
|
+
delete<M extends Model>(tableName: Constructor<M> | string, id: PrimaryKeyType, ...args: ContextualArgs<Context<AxiosFlags>>): Promise<Record<string, any>>;
|
|
106
109
|
parseError<E extends BaseError>(err: Error, ...args: any[]): E;
|
|
107
110
|
}
|
package/lib/esm/axios/axios.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HttpAdapter } from "./../adapter.js";
|
|
2
2
|
import { Axios } from "axios";
|
|
3
|
+
import { Context } from "@decaf-ts/db-decorators";
|
|
4
|
+
import { PersistenceKeys, } from "@decaf-ts/core";
|
|
3
5
|
import { AxiosFlavour } from "./constants.js";
|
|
4
6
|
/**
|
|
5
7
|
* @description Axios implementation of the HTTP adapter
|
|
@@ -57,6 +59,33 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
57
59
|
baseURL: `${this.config.protocol}://${this.config.host}`,
|
|
58
60
|
});
|
|
59
61
|
}
|
|
62
|
+
toRequest(ctxOrQuery, ctx) {
|
|
63
|
+
let query;
|
|
64
|
+
let context;
|
|
65
|
+
if (ctxOrQuery instanceof Context) {
|
|
66
|
+
context = ctxOrQuery;
|
|
67
|
+
query = undefined; // In this overload, ctx is actually the query
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
query = ctxOrQuery;
|
|
71
|
+
context = ctx;
|
|
72
|
+
}
|
|
73
|
+
const req = {};
|
|
74
|
+
if (context) {
|
|
75
|
+
try {
|
|
76
|
+
req.headers = context.get("headers") || {};
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
// do nothing
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (query) {
|
|
84
|
+
req.method = "GET";
|
|
85
|
+
req.url = this.url(query.class, [PersistenceKeys.STATEMENT, query.method, ...query.args], query.params);
|
|
86
|
+
}
|
|
87
|
+
return req;
|
|
88
|
+
}
|
|
60
89
|
/**
|
|
61
90
|
* @description Sends an HTTP request using Axios
|
|
62
91
|
* @summary Implementation of the abstract request method from HttpAdapter.
|
|
@@ -65,8 +94,17 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
65
94
|
* @param {AxiosRequestConfig} details - The Axios request configuration
|
|
66
95
|
* @return {Promise<V>} A promise that resolves with the response data
|
|
67
96
|
*/
|
|
68
|
-
async request(details) {
|
|
69
|
-
|
|
97
|
+
async request(details, ...args) {
|
|
98
|
+
let overrides = {};
|
|
99
|
+
try {
|
|
100
|
+
const { ctx } = this.logCtx(args, this.request);
|
|
101
|
+
overrides = this.toRequest(ctx);
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
// do nothing
|
|
106
|
+
}
|
|
107
|
+
return this.client.request(Object.assign({}, details, overrides));
|
|
70
108
|
}
|
|
71
109
|
/**
|
|
72
110
|
* @description Creates a new resource via HTTP POST
|
|
@@ -77,12 +115,13 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
77
115
|
* @param {Record<string, any>} model - The data model to create
|
|
78
116
|
* @return {Promise<Record<string, any>>} A promise that resolves with the created resource
|
|
79
117
|
*/
|
|
80
|
-
async create(tableName, id, model,
|
|
81
|
-
|
|
82
|
-
..._args) {
|
|
118
|
+
async create(tableName, id, model, ...args) {
|
|
119
|
+
const { log, ctx } = this.logCtx(args, this.create);
|
|
83
120
|
try {
|
|
84
121
|
const url = this.url(tableName);
|
|
85
|
-
|
|
122
|
+
const cfg = this.toRequest(ctx);
|
|
123
|
+
log.debug(`POSTing to ${url} with ${JSON.stringify(model)} and cfg ${JSON.stringify(cfg)}`);
|
|
124
|
+
return this.client.post(url, model, cfg);
|
|
86
125
|
}
|
|
87
126
|
catch (e) {
|
|
88
127
|
throw this.parseError(e);
|
|
@@ -96,13 +135,14 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
96
135
|
* @param {string|number|bigint} id - The identifier for the resource to retrieve
|
|
97
136
|
* @return {Promise<Record<string, any>>} A promise that resolves with the retrieved resource
|
|
98
137
|
*/
|
|
99
|
-
async read(tableName, id,
|
|
100
|
-
|
|
101
|
-
...args) {
|
|
138
|
+
async read(tableName, id, ...args) {
|
|
139
|
+
const { log, ctx } = this.logCtx(args, this.read);
|
|
102
140
|
try {
|
|
103
141
|
const url = this.url(tableName, {
|
|
104
142
|
id: id,
|
|
105
143
|
});
|
|
144
|
+
const cfg = this.toRequest(ctx);
|
|
145
|
+
log.debug(`GETing from ${url} and cfg ${JSON.stringify(cfg)}`);
|
|
106
146
|
return this.client.get(url);
|
|
107
147
|
}
|
|
108
148
|
catch (e) {
|
|
@@ -118,11 +158,12 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
118
158
|
* @param {Record<string, any>} model - The updated data model
|
|
119
159
|
* @return {Promise<Record<string, any>>} A promise that resolves with the updated resource
|
|
120
160
|
*/
|
|
121
|
-
async update(tableName, id, model,
|
|
122
|
-
|
|
123
|
-
..._args) {
|
|
161
|
+
async update(tableName, id, model, ...args) {
|
|
162
|
+
const { log, ctx } = this.logCtx(args, this.update);
|
|
124
163
|
try {
|
|
125
164
|
const url = this.url(tableName);
|
|
165
|
+
const cfg = this.toRequest(ctx);
|
|
166
|
+
log.debug(`PUTing to ${url} with ${JSON.stringify(model)} and cfg ${JSON.stringify(cfg)}`);
|
|
126
167
|
return this.client.put(url, model);
|
|
127
168
|
}
|
|
128
169
|
catch (e) {
|
|
@@ -137,13 +178,14 @@ export class AxiosHttpAdapter extends HttpAdapter {
|
|
|
137
178
|
* @param {string|number|bigint} id - The identifier for the resource to delete
|
|
138
179
|
* @return {Promise<Record<string, any>>} A promise that resolves with the deletion result
|
|
139
180
|
*/
|
|
140
|
-
async delete(tableName, id,
|
|
141
|
-
|
|
142
|
-
..._args) {
|
|
181
|
+
async delete(tableName, id, ...args) {
|
|
182
|
+
const { log, ctx } = this.logCtx(args, this.delete);
|
|
143
183
|
try {
|
|
144
184
|
const url = this.url(tableName, {
|
|
145
185
|
id: id,
|
|
146
186
|
});
|
|
187
|
+
const cfg = this.toRequest(ctx);
|
|
188
|
+
log.debug(`DELETEing from ${url} and cfg ${JSON.stringify(cfg)}`);
|
|
147
189
|
return this.client.delete(url);
|
|
148
190
|
}
|
|
149
191
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../../src/axios/axios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,wBAAmB;AACzC,OAAO,EAAE,KAAK,EAAsB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3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AC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RepositoryFlags } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
3
|
/**
|
|
3
4
|
* @description HTTP configuration type
|
|
4
5
|
* @summary Configuration type for HTTP connections specifying protocol and host
|
|
@@ -21,3 +22,9 @@ export type HttpConfig = {
|
|
|
21
22
|
export interface HttpFlags extends RepositoryFlags {
|
|
22
23
|
headers?: Record<string, string>;
|
|
23
24
|
}
|
|
25
|
+
export type HttpQuery = {
|
|
26
|
+
class: ModelConstructor<any> | string;
|
|
27
|
+
method: string;
|
|
28
|
+
args: any[];
|
|
29
|
+
params?: Record<"limit" | "skip", number>;
|
|
30
|
+
};
|
package/lib/index.cjs
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RepositoryFlags } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
3
|
/**
|
|
3
4
|
* @description HTTP configuration type
|
|
4
5
|
* @summary Configuration type for HTTP connections specifying protocol and host
|
|
@@ -21,3 +22,9 @@ export type HttpConfig = {
|
|
|
21
22
|
export interface HttpFlags extends RepositoryFlags {
|
|
22
23
|
headers?: Record<string, string>;
|
|
23
24
|
}
|
|
25
|
+
export type HttpQuery = {
|
|
26
|
+
class: ModelConstructor<any> | string;
|
|
27
|
+
method: string;
|
|
28
|
+
args: any[];
|
|
29
|
+
params?: Record<"limit" | "skip", number>;
|
|
30
|
+
};
|