@decaf-ts/for-http 0.5.2 → 0.6.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.
Files changed (80) hide show
  1. package/lib/cjs/HttpDispatcher.js.map +1 -0
  2. package/lib/cjs/HttpPaginator.js.map +1 -0
  3. package/lib/cjs/HttpStatement.js.map +1 -0
  4. package/lib/cjs/RestRepository.js.map +1 -0
  5. package/lib/cjs/RestService.js.map +1 -0
  6. package/lib/cjs/adapter.js.map +1 -0
  7. package/lib/cjs/axios/axios.js.map +1 -0
  8. package/lib/cjs/axios/constants.js.map +1 -0
  9. package/lib/cjs/axios/index.js.map +1 -0
  10. package/lib/{event → cjs/axios}/types.js.map +1 -1
  11. package/lib/cjs/constants.js.map +1 -0
  12. package/lib/cjs/event/ServerEventConnector.js.map +1 -0
  13. package/lib/cjs/event/index.js.map +1 -0
  14. package/lib/cjs/event/types.js.map +1 -0
  15. package/lib/{index.cjs → cjs/index.cjs} +1 -1
  16. package/lib/cjs/index.js.map +1 -0
  17. package/lib/{axios → cjs}/types.js.map +1 -1
  18. package/lib/esm/index.js +1 -1
  19. package/lib/{esm → types}/index.d.ts +1 -1
  20. package/package.json +14 -7
  21. package/lib/HttpDispatcher.js.map +0 -1
  22. package/lib/HttpPaginator.js.map +0 -1
  23. package/lib/HttpStatement.js.map +0 -1
  24. package/lib/RestRepository.js.map +0 -1
  25. package/lib/RestService.js.map +0 -1
  26. package/lib/adapter.js.map +0 -1
  27. package/lib/axios/axios.js.map +0 -1
  28. package/lib/axios/constants.js.map +0 -1
  29. package/lib/axios/index.js.map +0 -1
  30. package/lib/constants.js.map +0 -1
  31. package/lib/esm/HttpDispatcher.d.ts +0 -18
  32. package/lib/esm/HttpPaginator.d.ts +0 -10
  33. package/lib/esm/HttpStatement.d.ts +0 -11
  34. package/lib/esm/RestRepository.d.ts +0 -63
  35. package/lib/esm/RestService.d.ts +0 -74
  36. package/lib/esm/adapter.d.ts +0 -230
  37. package/lib/esm/axios/axios.d.ts +0 -76
  38. package/lib/esm/axios/constants.d.ts +0 -9
  39. package/lib/esm/axios/index.d.ts +0 -3
  40. package/lib/esm/axios/types.d.ts +0 -8
  41. package/lib/esm/constants.d.ts +0 -5
  42. package/lib/event/ServerEventConnector.d.ts +0 -39
  43. package/lib/event/ServerEventConnector.js.map +0 -1
  44. package/lib/event/index.d.ts +0 -2
  45. package/lib/event/index.js.map +0 -1
  46. package/lib/event/types.d.ts +0 -26
  47. package/lib/index.d.ts +0 -25
  48. package/lib/index.js.map +0 -1
  49. package/lib/types.d.ts +0 -65
  50. package/lib/types.js.map +0 -1
  51. /package/lib/{HttpDispatcher.cjs → cjs/HttpDispatcher.cjs} +0 -0
  52. /package/lib/{HttpPaginator.cjs → cjs/HttpPaginator.cjs} +0 -0
  53. /package/lib/{HttpStatement.cjs → cjs/HttpStatement.cjs} +0 -0
  54. /package/lib/{RestRepository.cjs → cjs/RestRepository.cjs} +0 -0
  55. /package/lib/{RestService.cjs → cjs/RestService.cjs} +0 -0
  56. /package/lib/{adapter.cjs → cjs/adapter.cjs} +0 -0
  57. /package/lib/{axios → cjs/axios}/axios.cjs +0 -0
  58. /package/lib/{axios → cjs/axios}/constants.cjs +0 -0
  59. /package/lib/{axios → cjs/axios}/index.cjs +0 -0
  60. /package/lib/{axios → cjs/axios}/types.cjs +0 -0
  61. /package/lib/{constants.cjs → cjs/constants.cjs} +0 -0
  62. /package/lib/{event → cjs/event}/ServerEventConnector.cjs +0 -0
  63. /package/lib/{event → cjs/event}/index.cjs +0 -0
  64. /package/lib/{event → cjs/event}/types.cjs +0 -0
  65. /package/lib/{types.cjs → cjs/types.cjs} +0 -0
  66. /package/lib/{HttpDispatcher.d.ts → types/HttpDispatcher.d.ts} +0 -0
  67. /package/lib/{HttpPaginator.d.ts → types/HttpPaginator.d.ts} +0 -0
  68. /package/lib/{HttpStatement.d.ts → types/HttpStatement.d.ts} +0 -0
  69. /package/lib/{RestRepository.d.ts → types/RestRepository.d.ts} +0 -0
  70. /package/lib/{RestService.d.ts → types/RestService.d.ts} +0 -0
  71. /package/lib/{adapter.d.ts → types/adapter.d.ts} +0 -0
  72. /package/lib/{axios → types/axios}/axios.d.ts +0 -0
  73. /package/lib/{axios → types/axios}/constants.d.ts +0 -0
  74. /package/lib/{axios → types/axios}/index.d.ts +0 -0
  75. /package/lib/{axios → types/axios}/types.d.ts +0 -0
  76. /package/lib/{constants.d.ts → types/constants.d.ts} +0 -0
  77. /package/lib/{esm → types}/event/ServerEventConnector.d.ts +0 -0
  78. /package/lib/{esm → types}/event/index.d.ts +0 -0
  79. /package/lib/{esm → types}/event/types.d.ts +0 -0
  80. /package/lib/{esm → types}/types.d.ts +0 -0
@@ -1,230 +0,0 @@
1
- import { Adapter, AdapterFlags, Condition, Context, ContextualArgs, FlagsOf, MaybeContextualArg, Paginator, PreparedModel, PreparedStatement, Repository, Sequence, SequenceOptions, Statement } from "@decaf-ts/core";
2
- import { BaseError, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
3
- import { HttpConfig, HttpFlags, HttpMethod, HttpRequestOptions, HttpResponse } from "./types";
4
- import { Model } from "@decaf-ts/decorator-validation";
5
- import { Constructor } from "@decaf-ts/decoration";
6
- export declare function suffixMethod(obj: any, before: (...args: any[]) => any, suffix: (...args: any[]) => any, beforeName?: string): void;
7
- /**
8
- * @description Abstract HTTP adapter for REST API interactions
9
- * @summary Provides a base implementation for HTTP adapters with methods for CRUD operations,
10
- * URL construction, and error handling. This class extends the core Adapter class and
11
- * implements the necessary methods for HTTP communication. Concrete implementations
12
- * must provide specific HTTP client functionality.
13
- * @template Y - The native HTTP client type
14
- * @template Q - The query type used by the adapter
15
- * @template F - The HTTP flags type, extending HttpFlags
16
- * @template C - The context type, extending Context<F>
17
- * @param {Y} native - The native HTTP client instance
18
- * @param {HttpConfig} config - Configuration for the HTTP adapter
19
- * @param {string} flavour - The adapter flavor identifier
20
- * @param {string} [alias] - Optional alias for the adapter
21
- * @class HttpAdapter
22
- * @example
23
- * ```typescript
24
- * // Example implementation with Axios
25
- * class AxiosAdapter extends HttpAdapter<AxiosInstance, AxiosRequestConfig> {
26
- * constructor(config: HttpConfig) {
27
- * super(axios.create(), config, 'axios');
28
- * }
29
- *
30
- * async request<V>(details: AxiosRequestConfig): Promise<V> {
31
- * const response = await this.native.request(details);
32
- * return response.data;
33
- * }
34
- *
35
- * // Implement other abstract methods...
36
- * }
37
- * ```
38
- */
39
- export declare abstract class HttpAdapter<CONF extends HttpConfig, CON, REQ, Q extends PreparedStatement<any> = PreparedStatement<any>, C extends Context<HttpFlags> = Context<HttpFlags>> extends Adapter<CONF, CON, Q, C> {
40
- protected constructor(config: CONF, flavour: string, alias?: string);
41
- /**
42
- * @description Generates operation flags with HTTP headers
43
- * @summary Extends the base flags method to ensure HTTP headers exist on the flags payload.
44
- * @template M - The model type
45
- * @param {OperationKeys|string} operation - The type of operation being performed
46
- * @param {Constructor | Constructor[]} model - The target model constructor(s)
47
- * @param {Partial<FlagsOf<C>>} overrides - Optional flag overrides
48
- * @param {...any[]} args - Additional arguments forwarded to the base implementation
49
- * @return {Promise<FlagsOf<C>>} The flags object with headers
50
- */
51
- protected flags<M extends Model>(operation: OperationKeys | string, model: Constructor<M> | Constructor<M>[], overrides: Partial<FlagsOf<C>>): Promise<FlagsOf<C>>;
52
- protected Dispatch(): any;
53
- protected getEventHeaders(): Promise<{}>;
54
- /**
55
- * @description Returns the repository constructor for this adapter
56
- * @summary Provides the RestService class as the repository implementation for this HTTP adapter.
57
- * This method is used to create repository instances that work with this adapter type.
58
- * @template R - Repository subtype working with this adapter
59
- * @return {Constructor<R>} The repository constructor
60
- */
61
- repository<R extends Repository<any, Adapter<CONF, CON, Q, C>>>(): Constructor<R>;
62
- /**
63
- * @description Prepares a model for persistence
64
- * @summary Converts a model instance into a format suitable for database storage,
65
- * handling column mapping and separating transient properties
66
- * @template M - The model type
67
- * @param {M} model - The model instance to prepare
68
- * @param pk - The primary key property name
69
- * @param args
70
- * @return The prepared data
71
- */
72
- prepare<M extends Model>(model: M, ...args: ContextualArgs<C>): PreparedModel;
73
- /**
74
- * @description Converts database data back into a model instance
75
- * @summary Reconstructs a model instance from database data, handling column mapping
76
- * and reattaching transient properties
77
- * @template M - The model type
78
- * @param obj - The database record
79
- * @param {string|Constructor<M>} clazz - The model class or name
80
- * @param pk - The primary key property name
81
- * @param {string|number|bigint} id - The primary key value
82
- * @return {M} The reconstructed model instance
83
- */
84
- revert<M extends Model>(obj: Record<string, any>, clazz: string | Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): M;
85
- protected toTableName<M extends Model>(t: string | Constructor<M>): string;
86
- protected toHeaders(ctx: C): {
87
- [x: string]: any;
88
- };
89
- /**
90
- * @description Constructs a URL for API requests
91
- * @summary Builds a complete URL for API requests using the configured protocol and host,
92
- * the specified table name, and optional query parameters. The method handles URL encoding.
93
- * @param {string | Constructor} tableName - The name of the table or endpoint
94
- * @return {string} The encoded URL string
95
- */
96
- url<M extends Model>(tableName: string | Constructor<M>): string;
97
- /**
98
- * @description Constructs a URL for API requests
99
- * @summary Builds a complete URL for API requests using the configured protocol and host,
100
- * the specified table name, and optional query parameters. The method handles URL encoding.
101
- * @param {string | Constructor} tableName - The name of the table or endpoint
102
- * @param {string[]} pathParams - Optional query parameters
103
- * @return {string} The encoded URL string
104
- */
105
- url<M extends Model>(tableName: string | Constructor<M>, pathParams: string[]): string;
106
- /**
107
- * @description Constructs a URL for API requests
108
- * @summary Builds a complete URL for API requests using the configured protocol and host,
109
- * the specified table name, and optional query parameters. The method handles URL encoding.
110
- * @param {string | Constructor} tableName - The name of the table or endpoint
111
- * @param {Record<string, string | number>} queryParams - Optional query parameters
112
- * @return {string} The encoded URL string
113
- */
114
- url<M extends Model>(tableName: string | Constructor<M>, queryParams: Record<string, string | number>): string;
115
- url<M extends Model>(tableName: string | Constructor<M>, pathParams: string[], queryParams: Record<string, string | number>): string;
116
- abstract toRequest(query: Q): REQ;
117
- abstract toRequest(ctx: C): REQ;
118
- abstract toRequest(query: Q, ctx: C): REQ;
119
- abstract toRequest(method: HttpMethod, url: string, data?: unknown, options?: HttpRequestOptions): REQ;
120
- abstract toRequest(ctxOrQueryOrMethod: C | Q | HttpMethod, ctxOrUrl?: C | string, data?: unknown, options?: HttpRequestOptions): REQ;
121
- protected toHttpResponse<V = any, E = unknown>(parsed: any, raw?: any): HttpResponse<V, E>;
122
- get<V = any, E = unknown>(url: string, options?: HttpRequestOptions, ...args: MaybeContextualArg<C>): Promise<HttpResponse<V, E>>;
123
- post<V = any, E = unknown>(url: string, data: unknown, options?: HttpRequestOptions, ...args: MaybeContextualArg<C>): Promise<HttpResponse<V, E>>;
124
- put<V = any, E = unknown>(url: string, data: unknown, options?: HttpRequestOptions, ...args: MaybeContextualArg<C>): Promise<HttpResponse<V, E>>;
125
- /**
126
- * @description Sends an HTTP request
127
- * @summary Abstract method that must be implemented by subclasses to send HTTP requests
128
- * using the native HTTP client. This is the core method for making API calls.
129
- * @template V - The response value type
130
- * @param {REQ} details - The request details specific to the HTTP client
131
- * @return {Promise<V>} A promise that resolves with the response data
132
- */
133
- abstract request<V>(details: REQ, ...args: MaybeContextualArg<C>): Promise<V>;
134
- protected extractIdArgs<M extends Model>(model: Constructor<M> | string, id: PrimaryKeyType): string[];
135
- parseResponse<M extends Model>(clazz: Constructor<M> | undefined, method: OperationKeys | string, res: any): any;
136
- /**
137
- * @description Creates a new resource
138
- * @summary Abstract method that must be implemented by subclasses to create a new resource
139
- * via HTTP. This typically corresponds to a POST request.
140
- * @param {string} tableName - The name of the table or endpoint
141
- * @param {string|number} id - The identifier for the resource
142
- * @param {Record<string, any>} model - The data model to create
143
- * @param {...any[]} args - Additional arguments
144
- * @return {Promise<Record<string, any>>} A promise that resolves with the created resource
145
- */
146
- create<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
147
- createAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], model: Record<string, any>[], ...args: ContextualArgs<C>): Promise<Record<string, any>[]>;
148
- /**
149
- * @description Retrieves a resource by ID
150
- * @summary Abstract method that must be implemented by subclasses to retrieve a resource
151
- * via HTTP. This typically corresponds to a GET request.
152
- * @param {string} tableName - The name of the table or endpoint
153
- * @param {string|number|bigint} id - The identifier for the resource
154
- * @param {...any[]} args - Additional arguments
155
- * @return {Promise<Record<string, any>>} A promise that resolves with the retrieved resource
156
- */
157
- read<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
158
- readAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<C>): Promise<Record<string, any>[]>;
159
- /**
160
- * @description Updates an existing resource
161
- * @summary Abstract method that must be implemented by subclasses to update a resource
162
- * via HTTP. This typically corresponds to a PUT or PATCH request.
163
- * @param {string} tableName - The name of the table or endpoint
164
- * @param {string|number} id - The identifier for the resource
165
- * @param {Record<string, any>} model - The updated data model
166
- * @param {...any[]} args - Additional arguments
167
- * @return {Promise<Record<string, any>>} A promise that resolves with the updated resource
168
- */
169
- update<M extends Model>(tableName: Constructor<M>, id: string | number, model: Record<string, any>, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
170
- updateAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], model: Record<string, any>[], ...args: ContextualArgs<C>): Promise<Record<string, any>[]>;
171
- /**
172
- * @description Deletes a resource by ID
173
- * @summary Abstract method that must be implemented by subclasses to delete a resource
174
- * via HTTP. This typically corresponds to a DELETE request.
175
- * @param {string} tableName - The name of the table or endpoint
176
- * @param {string|number|bigint} id - The identifier for the resource to delete
177
- * @param {...any[]} args - Additional arguments
178
- * @return {Promise<Record<string, any>>} A promise that resolves with the deletion result
179
- */
180
- delete<M extends Model>(tableName: Constructor<M>, id: PrimaryKeyType, ...args: ContextualArgs<C>): Promise<Record<string, any>>;
181
- delete<V = any>(url: string, options?: HttpRequestOptions, ...args: MaybeContextualArg<C>): Promise<HttpResponse<V>>;
182
- deleteAll<M extends Model>(tableName: Constructor<M>, ids: PrimaryKeyType[], ...args: ContextualArgs<C>): Promise<Record<string, any>[]>;
183
- /**
184
- * @description Executes a raw query
185
- * @summary Method for executing raw queries directly with the HTTP client.
186
- * This method is not supported by default in HTTP adapters and throws an UnsupportedError.
187
- * Subclasses can override this method to provide implementation.
188
- * @template R - The result type
189
- * @param {Q} rawInput - The raw query input
190
- * @param {boolean} process - Whether to process the result
191
- * @param {...any[]} args - Additional arguments
192
- * @return {Promise<R>} A promise that resolves with the query result
193
- * @throws {UnsupportedError} Always throws as this method is not supported by default
194
- */
195
- raw<R>(rawInput: Q, ...args: ContextualArgs<C>): Promise<R>;
196
- /**
197
- * @description Creates a sequence
198
- * @summary Method for creating a sequence for generating unique identifiers.
199
- * This method is not supported by default in HTTP adapters and throws an UnsupportedError.
200
- * Subclasses can override this method to provide implementation.
201
- * @param {SequenceOptions} options - Options for creating the sequence
202
- * @return {Promise<Sequence>} A promise that resolves with the created sequence
203
- * @throws {UnsupportedError} Always throws as this method is not supported by default
204
- */
205
- Sequence(options: SequenceOptions): Promise<Sequence>;
206
- /**
207
- * @description Creates a statement for querying
208
- * @summary Method for creating a statement for building and executing queries.
209
- * This method is not supported by default in HTTP adapters and throws an UnsupportedError.
210
- * Subclasses can override this method to provide implementation.
211
- * @template M - The model type
212
- * @template ! - The raw query type
213
- * @return {Statement<Q, M, any>} A statement object for building queries
214
- * @throws {UnsupportedError} Always throws as this method is not supported by default
215
- */
216
- Statement<M extends Model>(overrides?: Partial<AdapterFlags>): Statement<M, Adapter<CONF, CON, Q, C>, any>;
217
- Paginator<M extends Model>(query: Q, size: number, clazz: Constructor<M>): Paginator<M, M, Q>;
218
- /**
219
- * @description Parses a condition into a query
220
- * @summary Method for parsing a condition object into a query format understood by the HTTP client.
221
- * This method is not supported by default in HTTP adapters and throws an UnsupportedError.
222
- * Subclasses can override this method to provide implementation.
223
- * @param {Condition<any>} condition - The condition to parse
224
- * @return {Q} The parsed query
225
- * @throws {UnsupportedError} Always throws as this method is not supported by default
226
- */
227
- parseCondition(condition: Condition<any>): Q;
228
- static parseError<E extends BaseError>(err: Error | string, ...args: any[]): E;
229
- static decoration(): void;
230
- }
@@ -1,76 +0,0 @@
1
- import { HttpAdapter } from "../adapter";
2
- import { Axios, AxiosRequestConfig } from "axios";
3
- import { HttpConfig, HttpMethod, HttpRequestOptions } from "../types";
4
- import { AxiosFlags } from "./types";
5
- import { BaseError, OperationKeys } from "@decaf-ts/db-decorators";
6
- import { Context, MaybeContextualArg, PreparedStatement } from "@decaf-ts/core";
7
- import { Model } from "@decaf-ts/decorator-validation";
8
- import { Constructor } from "@decaf-ts/decoration";
9
- /**
10
- * @description Axios implementation of the HTTP adapter
11
- * @summary Concrete implementation of HttpAdapter using Axios as the HTTP client.
12
- * This adapter provides CRUD operations for RESTful APIs using Axios for HTTP requests.
13
- * @template Axios - The Axios client type
14
- * @template AxiosRequestConfig - The Axios request configuration type
15
- * @template AxiosFlags - The flags type extending HttpFlags
16
- * @template Context<AxiosFlags> - The context type for this adapter
17
- * @param {Axios} native - The Axios instance
18
- * @param {HttpConfig} config - Configuration for the HTTP adapter
19
- * @param {string} [alias] - Optional alias for the adapter
20
- * @class
21
- * @example
22
- * ```typescript
23
- * import axios from 'axios';
24
- * import { AxiosHttpAdapter } from '@decaf-ts/for-http';
25
- *
26
- * const config = { protocol: 'https', host: 'api.example.com' };
27
- * const adapter = new AxiosHttpAdapter(axios.create(), config);
28
- *
29
- * // Use the adapter with a repository
30
- * const userRepo = adapter.getRepository(User);
31
- * const user = await userRepo.findById('123');
32
- * ```
33
- * @mermaid
34
- * sequenceDiagram
35
- * participant Client
36
- * participant AxiosHttpAdapter
37
- * participant Axios
38
- * participant API
39
- *
40
- * Client->>AxiosHttpAdapter: create(table, id, data)
41
- * AxiosHttpAdapter->>AxiosHttpAdapter: url(table)
42
- * AxiosHttpAdapter->>Axios: post(url, data)
43
- * Axios->>API: HTTP POST Request
44
- * API-->>Axios: Response
45
- * Axios-->>AxiosHttpAdapter: Response Data
46
- * AxiosHttpAdapter-->>Client: Created Resource
47
- *
48
- * Client->>AxiosHttpAdapter: read(table, id)
49
- * AxiosHttpAdapter->>AxiosHttpAdapter: url(table, {id})
50
- * AxiosHttpAdapter->>Axios: get(url)
51
- * Axios->>API: HTTP GET Request
52
- * API-->>Axios: Response
53
- * Axios-->>AxiosHttpAdapter: Response Data
54
- * AxiosHttpAdapter-->>Client: Resource Data
55
- */
56
- export declare class AxiosHttpAdapter extends HttpAdapter<HttpConfig, Axios, AxiosRequestConfig, PreparedStatement<any>, Context<AxiosFlags>> {
57
- constructor(config: HttpConfig, alias?: string);
58
- protected getClient(): Axios;
59
- toRequest(query: PreparedStatement<any>): AxiosRequestConfig;
60
- toRequest(ctx: Context<AxiosFlags>): AxiosRequestConfig;
61
- toRequest(query: PreparedStatement<any>, ctx: Context<AxiosFlags>): AxiosRequestConfig;
62
- toRequest(method: HttpMethod, url: string, data?: unknown, options?: HttpRequestOptions): AxiosRequestConfig;
63
- private toAxiosRequestOptions;
64
- /**
65
- * @description Sends an HTTP request using Axios
66
- * @summary Implementation of the abstract request method from HttpAdapter.
67
- * This method uses the Axios instance to send HTTP requests with the provided configuration.
68
- * @template V - The response value type
69
- * @param {AxiosRequestConfig} details - The Axios request configuration
70
- * @return {Promise<V>} A promise that resolves with the response data
71
- */
72
- request<V>(details: AxiosRequestConfig, ...args: MaybeContextualArg<Context<AxiosFlags>>): Promise<V>;
73
- parseResponse<M extends Model>(clazz: Constructor<M>, method: OperationKeys | string, res: any): any;
74
- private normalizeResponseBody;
75
- parseError<E extends BaseError>(err: Error, ...args: any[]): E;
76
- }
@@ -1,9 +0,0 @@
1
- import { ResponseParser } from "../types";
2
- /**
3
- * @description Axios adapter flavor identifier
4
- * @summary Constant string identifier used to identify the Axios implementation of the HTTP adapter
5
- * @const {string} AxiosFlavour
6
- * @memberOf module:for-http.axios
7
- */
8
- export declare const AxiosFlavour = "axios";
9
- export declare const TaskResponseParser: ResponseParser;
@@ -1,3 +0,0 @@
1
- export * from "./axios";
2
- export * from "./constants";
3
- export * from "./types";
@@ -1,8 +0,0 @@
1
- import { HttpFlags } from "../types";
2
- /**
3
- * @description Axios-specific HTTP flags type
4
- * @summary Type alias for HttpFlags used specifically with the Axios adapter implementation
5
- * @typedef {HttpFlags} AxiosFlags
6
- * @memberOf module:for-http.axios
7
- */
8
- export type AxiosFlags = HttpFlags;
@@ -1,5 +0,0 @@
1
- export declare enum DecafHeaders {
2
- PENDING_TASK = "x-pending-task",
3
- CORRELATION_ID = "x-correlation-id"
4
- }
5
- export declare const KeepAliveOperation = "keepalive";
@@ -1,39 +0,0 @@
1
- import { EventHandlers } from "./types";
2
- import { Context, ContextualLoggedClass } from "@decaf-ts/core";
3
- export type ServerEventConnectorHeaders = Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
4
- export declare class ServerEventConnector extends ContextualLoggedClass<Context<any>> {
5
- private readonly url;
6
- private readonly headers?;
7
- private static readonly cache;
8
- static get(url: string): ServerEventConnector;
9
- static open(url: string, headers?: ServerEventConnectorHeaders): ServerEventConnector;
10
- static close(url: string): void;
11
- private static parseReceivedEvent;
12
- /** Shared connection state (cached singleton instance). */
13
- private es?;
14
- private controller?;
15
- private readonly stateLock;
16
- private opening?;
17
- private ready;
18
- private listeners;
19
- constructor(url: string, headers?: ServerEventConnectorHeaders | undefined);
20
- isOpen(): boolean;
21
- private withStateLock;
22
- private setOpening;
23
- private isReady;
24
- private setReady;
25
- protected getHeaders(): Promise<ServerEventConnectorHeaders>;
26
- close(force?: boolean): void;
27
- /**
28
- * Increments refCount and ensures EventSource is created.
29
- * This method must be called only on the shared singleton instance.
30
- */
31
- private startListening;
32
- /**
33
- * Ensures the shared connection has completed its async open sequence.
34
- * Callers that need "ready before proceeding" semantics should await this.
35
- */
36
- ensureListening(): Promise<void>;
37
- addListener(handlers: EventHandlers): () => void;
38
- removeListener(handlers: EventHandlers): void;
39
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ServerEventConnector.js","sourceRoot":"","sources":["../../src/event/ServerEventConnector.ts"],"names":[],"mappings":";;;AACA,yDAAoD;AACpD,yEAA+D;AAC/D,yCAAgE;AAChE,iFAA0D;AAM1D,MAAa,oBAAqB,SAAQ,4BAAmC;aACnD,UAAK,GAAG,IAAI,GAAG,EAAgC,AAA1C,CAA2C;IAExE,MAAM,CAAC,GAAG,CAAC,GAAW;QACpB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAyB,CAAC;QAE5E,MAAM,IAAI,KAAK,CACb,6CAA6C,GAAG,mCAAmC,CACpF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CACT,GAAW,EACX,OAAqC;QAErC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAyB,CAAC;QAE5E,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAyB,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAW;QACtB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAyB,CAAC;YAC9D,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,GAAY;QAC5C,MAAM,kBAAkB,GAAG,C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AAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,cAAc,CAAC,QAAuB;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE7C,GAAG,CAAC,IAAI,CACN,yCAAyC,IAAI,CAAC,GAAG,+BAA+B,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EACrG;YACE,aAAa,EAAE,OAAO;SACvB,CACF,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,GAAG,CAAC,KAAK,CACP,wCAAwC,IAAI,CAAC,GAAG,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAC/F,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CACN,0DAA0D,IAAI,CAAC,GAAG,GAAG,EACrE;gBACE,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;aAC/B,CACF,CAAC;YACF,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;;AA5UH,oDA6UC"}
@@ -1,2 +0,0 @@
1
- export * from "./ServerEventConnector";
2
- export * from "./types";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/event/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAAuC;AACvC,8CAAwB"}
@@ -1,26 +0,0 @@
1
- import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
2
- import { SseMessage } from "event-source-plus";
3
- export type ServerEventType = "message" | "heartbeat" | string;
4
- export type ServerRawMessage = SseMessage & {
5
- id?: string;
6
- event: ServerEventType;
7
- data: string;
8
- retry?: number;
9
- };
10
- export type SingleServerEvent<T> = readonly [
11
- modelName: string,
12
- operation: OperationKeys | string,
13
- id: string,
14
- payload: T
15
- ];
16
- export type BulkServerEvent<T> = readonly [
17
- modelName: string,
18
- operation: BulkCrudOperationKeys,
19
- id: string[],
20
- payload: T[]
21
- ];
22
- export type ServerEvent<T> = SingleServerEvent<T> | BulkServerEvent<T>;
23
- export type EventHandlers = {
24
- onEvent: ([tableName, operation, id]: ServerEvent<any>) => void;
25
- onError: (err: unknown) => void;
26
- };
package/lib/index.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import "@decaf-ts/core";
2
- /**
3
- * @description HTTP client module for REST API interactions
4
- * @summary This module provides classes and utilities for interacting with REST APIs.
5
- * It exposes repository and service classes for making HTTP requests, along with
6
- * type definitions and adapters for different HTTP clients. The module includes
7
- * {@link RestRepository} and {@link RestService} for API interactions.
8
- * @module for-http
9
- */
10
- export * from "./axios";
11
- export * from "./adapter";
12
- export * from "./constants";
13
- export * from "./HttpPaginator";
14
- export * from "./HttpStatement";
15
- export * from "./RestRepository";
16
- export * from "./RestService";
17
- export * from "./types";
18
- export * from "./event";
19
- /**
20
- * @description Current version of the for-http module
21
- * @summary Version identifier for the module
22
- * @const VERSION
23
- */
24
- export declare const VERSION = "0.5.1";
25
- export declare const PACKAGE_NAME = "@decaf-ts/for-http";
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0BAAwB;AACxB,qDAAgD;AAEhD;;;;;;;GAOG;AACH,oDAAwB;AACxB,gDAA0B;AAC1B,kDAA4B;AAC5B,sDAAgC;AAChC,sDAAgC;AAChC,uDAAiC;AACjC,oDAA8B;AAC9B,8CAAwB;AACxB,oDAAwB;AAExB;;;;GAIG;AACU,QAAA,OAAO,GAAG,aAAa,CAAC;AAExB,QAAA,YAAY,GAAG,aAAa,CAAC;AAE1C,qBAAQ,CAAC,eAAe,CAAC,oBAAY,EAAE,eAAO,CAAC,CAAC"}
package/lib/types.d.ts DELETED
@@ -1,65 +0,0 @@
1
- import { AdapterFlags, Context } from "@decaf-ts/core";
2
- export type ResponseParser = <C extends Context<HttpFlags> = Context<HttpFlags>>(res: any, ctx: C) => void;
3
- /**
4
- * @description HTTP configuration type
5
- * @summary Configuration type for HTTP connections specifying protocol and host
6
- * @typedef {Object} HttpConfig
7
- * @property {('http'|'https')} protocol - The HTTP protocol to use
8
- * @property {string} host - The host address
9
- * @memberOf module:for-http
10
- */
11
- export type HttpConfig = {
12
- protocol: "http" | "https";
13
- host: string;
14
- parsers?: ResponseParser[];
15
- eventsListenerPath?: string;
16
- headers?: boolean;
17
- events?: boolean;
18
- eventHeaderResolver?: () => Promise<Record<string, string>> | Record<string, string>;
19
- };
20
- export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
21
- export type HttpRequestTransform = (data: any, headers?: Record<string, string>) => any;
22
- /**
23
- * @description Generic request options for simple HttpAdapter calls
24
- * @summary for-http owned request options shaped after Axios request config.
25
- * The adapter maps these options to the underlying client configuration.
26
- * @interface HttpRequestOptions
27
- */
28
- export interface HttpRequestOptions {
29
- timeout?: number;
30
- headers?: Record<string, any>;
31
- params?: Record<string, any>;
32
- baseURL?: string;
33
- responseType?: "json" | "text" | "arraybuffer" | "blob" | "document" | "stream";
34
- auth?: {
35
- username: string;
36
- password: string;
37
- };
38
- signal?: AbortSignal;
39
- transformRequest?: HttpRequestTransform | HttpRequestTransform[];
40
- transformResponse?: HttpRequestTransform | HttpRequestTransform[];
41
- validateStatus?: (status: number) => boolean;
42
- includeCredentials?: boolean;
43
- withCredentials?: boolean;
44
- }
45
- /**
46
- * @description Generic HTTP response shape used by simple HttpAdapter helpers
47
- * @summary for-http owned response envelope aligned with Axios semantics by default.
48
- * `code` maps to HTTP status code, `data` to response payload, and `error` to failure details.
49
- * @interface HttpResponse
50
- */
51
- export interface HttpResponse<T = any, E = unknown> {
52
- code: number;
53
- data?: T;
54
- error?: E;
55
- }
56
- /**
57
- * @description HTTP flags interface
58
- * @summary Interface extending RepositoryFlags with HTTP-specific options
59
- * @interface HttpFlags
60
- * @property {Record<string, string>} [headers] - Optional HTTP headers to include with requests
61
- * @memberOf module:for-http
62
- */
63
- export interface HttpFlags extends AdapterFlags {
64
- headers?: Record<string, string>;
65
- }
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes