esi-cap 1.7.40 → 1.7.42
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/dist/index.js +1 -1
- package/dist/lib/_classes/index.js +1 -1
- package/dist/lib/_config/index.js +1 -1
- package/dist/lib/_interface/appender/index.js +1 -1
- package/dist/lib/_interface/file/index.js +1 -1
- package/dist/lib/_interface/formatter/index.js +1 -1
- package/dist/lib/_interface/index.js +1 -1
- package/dist/lib/_interface/layout/index.js +1 -1
- package/dist/lib/_interface/log/index.js +1 -1
- package/dist/lib/_interface/path/index.js +1 -1
- package/dist/lib/connect/index.js +1 -1
- package/dist/lib/impl/index.js +1 -1
- package/dist/lib/log/index.js +1 -1
- package/dist/lib/query/index.js +1 -1
- package/dist/lib/service/index.js +1 -1
- package/dist/lib/utils/index.js +1 -1
- package/package.json +1 -1
- package/types/lib/impl/index.d.ts +164 -8
- package/types/lib/impl/index.d.ts.map +1 -1
|
@@ -40,6 +40,115 @@ export type CDSService = {
|
|
|
40
40
|
*/
|
|
41
41
|
delete: (entity: string, where: any) => Promise<number>;
|
|
42
42
|
};
|
|
43
|
+
export type CDSRequest<T> = {
|
|
44
|
+
/**
|
|
45
|
+
* - The request payload.
|
|
46
|
+
*/
|
|
47
|
+
data: T & {
|
|
48
|
+
params?: any;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* - Map of request headers.
|
|
52
|
+
*/
|
|
53
|
+
headers: Record<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* - Positional parameters from the URL.
|
|
56
|
+
*/
|
|
57
|
+
params: any[];
|
|
58
|
+
/**
|
|
59
|
+
* - The authenticated user information.
|
|
60
|
+
*/
|
|
61
|
+
user: CDSUser;
|
|
62
|
+
/**
|
|
63
|
+
* - The CQN (OData-like) query structure.
|
|
64
|
+
*/
|
|
65
|
+
query: any;
|
|
66
|
+
/**
|
|
67
|
+
* - Information about the target entity.
|
|
68
|
+
*/
|
|
69
|
+
target: CDSTarget;
|
|
70
|
+
/**
|
|
71
|
+
* - The name of the event (e.g., 'READ', 'UPDATE').
|
|
72
|
+
*/
|
|
73
|
+
event: string;
|
|
74
|
+
/**
|
|
75
|
+
* - The underlying HTTP request (if applicable).
|
|
76
|
+
*/
|
|
77
|
+
http?: {
|
|
78
|
+
req: {
|
|
79
|
+
headers: Record<string, string>;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* - Rejects the request with a specific status and message.
|
|
84
|
+
*/
|
|
85
|
+
reject: CDSReject;
|
|
86
|
+
/**
|
|
87
|
+
* - Adds an error to the request without necessarily stopping execution.
|
|
88
|
+
*/
|
|
89
|
+
error: CDSError;
|
|
90
|
+
/**
|
|
91
|
+
* - Adds a warning message to the response.
|
|
92
|
+
*/
|
|
93
|
+
warn: (opts: {
|
|
94
|
+
message: string;
|
|
95
|
+
}) => void;
|
|
96
|
+
/**
|
|
97
|
+
* - Adds an informational message to the response.
|
|
98
|
+
*/
|
|
99
|
+
info: (msg: string) => void;
|
|
100
|
+
/**
|
|
101
|
+
* - Collection of errors collected during processing.
|
|
102
|
+
*/
|
|
103
|
+
errors?: any[];
|
|
104
|
+
/**
|
|
105
|
+
* - esi-cap runtime extension: logic to run before the 'on' phase.
|
|
106
|
+
*/
|
|
107
|
+
PreOn?: any;
|
|
108
|
+
/**
|
|
109
|
+
* - esi-cap runtime extension: logic to run after the 'on' phase.
|
|
110
|
+
*/
|
|
111
|
+
PostOn?: any;
|
|
112
|
+
/**
|
|
113
|
+
* - esi-cap runtime extension: pre-mashup processing.
|
|
114
|
+
*/
|
|
115
|
+
PreMeshUp?: any;
|
|
116
|
+
};
|
|
117
|
+
export type CDSUser = {
|
|
118
|
+
/**
|
|
119
|
+
* - The user's unique identifier.
|
|
120
|
+
*/
|
|
121
|
+
id: string;
|
|
122
|
+
/**
|
|
123
|
+
* - Custom user attributes.
|
|
124
|
+
*/
|
|
125
|
+
attr: Record<string, any>;
|
|
126
|
+
/**
|
|
127
|
+
* - Checks if the user has a specific role.
|
|
128
|
+
*/
|
|
129
|
+
is: (role: string) => boolean;
|
|
130
|
+
};
|
|
131
|
+
export type CDSTarget = {
|
|
132
|
+
/**
|
|
133
|
+
* - The absolute name of the target entity.
|
|
134
|
+
*/
|
|
135
|
+
name: string;
|
|
136
|
+
/**
|
|
137
|
+
* - Any projection (select list) applied to the entity.
|
|
138
|
+
*/
|
|
139
|
+
projection?: any;
|
|
140
|
+
};
|
|
141
|
+
export type CDSReject = (opts?: {
|
|
142
|
+
status?: number;
|
|
143
|
+
message?: string;
|
|
144
|
+
}) => void;
|
|
145
|
+
export type CDSError = (opts: {
|
|
146
|
+
status?: number;
|
|
147
|
+
message?: string;
|
|
148
|
+
code?: string;
|
|
149
|
+
target?: string;
|
|
150
|
+
args?: any[];
|
|
151
|
+
}) => void;
|
|
43
152
|
/**
|
|
44
153
|
* Handles 'on' and 'before' event registrations.
|
|
45
154
|
* Supports both signatures: (event, entities, handler) AND (event, handler).
|
|
@@ -50,14 +159,14 @@ export type CDSMethod = (event: string | string[], entitiesOrHandler: any | CDSH
|
|
|
50
159
|
* Supports both signatures: (event, entities, handler) AND (event, handler).
|
|
51
160
|
*/
|
|
52
161
|
export type CDSAfterMethod = (event: string | string[], entitiesOrHandler: any | CDSAfterHandler, handler?: CDSAfterHandler) => void;
|
|
53
|
-
export type CDSHandler = (req: any) => any | Promise<any>;
|
|
54
|
-
export type CDSAfterHandler = (results: any, req:
|
|
162
|
+
export type CDSHandler = (req: CDSRequest, next: () => Promise<any>) => any | Promise<any>;
|
|
163
|
+
export type CDSAfterHandler = (results: any, req: CDSRequest) => any | Promise<any>;
|
|
55
164
|
export type CDSServiceTx = CDSService;
|
|
56
|
-
export type
|
|
165
|
+
export type ServiceEventsServiceInterceptor = (oService: CDSService) => Promise<void>;
|
|
57
166
|
export type Service = typeof import("../service").service;
|
|
58
167
|
export type ServiceEvents = Service["events"];
|
|
59
168
|
export type ServiceEventsKey = keyof ServiceEvents;
|
|
60
|
-
export type ServieEventsHandler = Partial<Record<ServiceEventsKey,
|
|
169
|
+
export type ServieEventsHandler = Partial<Record<ServiceEventsKey, ServiceEventsServiceInterceptor>>;
|
|
61
170
|
/**
|
|
62
171
|
* impl module
|
|
63
172
|
* @class
|
|
@@ -76,6 +185,47 @@ export type ServieEventsHandler = Partial<Record<ServiceEventsKey, ServiceEventI
|
|
|
76
185
|
* @property {(action: string, params?: any) => Promise<any>} send - Sends a custom action or function call to the service.
|
|
77
186
|
* @property {(entity: string, where: any) => Promise<number>} delete - Deletes records matching the given criteria.
|
|
78
187
|
*/
|
|
188
|
+
/**
|
|
189
|
+
* @template T
|
|
190
|
+
* @typedef {Object} CDSRequest
|
|
191
|
+
* @property {T & { params?: any }} data - The request payload.
|
|
192
|
+
* @property {Record<string, string>} headers - Map of request headers.
|
|
193
|
+
* @property {any[]} params - Positional parameters from the URL.
|
|
194
|
+
* @property {CDSUser} user - The authenticated user information.
|
|
195
|
+
* @property {any} query - The CQN (OData-like) query structure.
|
|
196
|
+
* @property {CDSTarget} target - Information about the target entity.
|
|
197
|
+
* @property {string} event - The name of the event (e.g., 'READ', 'UPDATE').
|
|
198
|
+
* @property {{ req: { headers: Record<string, string> } }} [http] - The underlying HTTP request (if applicable).
|
|
199
|
+
* @property {CDSReject} reject - Rejects the request with a specific status and message.
|
|
200
|
+
* @property {CDSError} error - Adds an error to the request without necessarily stopping execution.
|
|
201
|
+
* @property {(opts: { message: string }) => void} warn - Adds a warning message to the response.
|
|
202
|
+
* @property {(msg: string) => void} info - Adds an informational message to the response.
|
|
203
|
+
* @property {any[]} [errors] - Collection of errors collected during processing.
|
|
204
|
+
* @property {any} [PreOn] - esi-cap runtime extension: logic to run before the 'on' phase.
|
|
205
|
+
* @property {any} [PostOn] - esi-cap runtime extension: logic to run after the 'on' phase.
|
|
206
|
+
* @property {any} [PreMeshUp] - esi-cap runtime extension: pre-mashup processing.
|
|
207
|
+
*/
|
|
208
|
+
/**
|
|
209
|
+
* @typedef {Object} CDSUser
|
|
210
|
+
* @property {string} id - The user's unique identifier.
|
|
211
|
+
* @property {Record<string, any>} attr - Custom user attributes.
|
|
212
|
+
* @property {(role: string) => boolean} is - Checks if the user has a specific role.
|
|
213
|
+
*/
|
|
214
|
+
/**
|
|
215
|
+
* @typedef {Object} CDSTarget
|
|
216
|
+
* @property {string} name - The absolute name of the target entity.
|
|
217
|
+
* @property {any} [projection] - Any projection (select list) applied to the entity.
|
|
218
|
+
*/
|
|
219
|
+
/**
|
|
220
|
+
* @callback CDSReject
|
|
221
|
+
* @param {{ status?: number; message?: string }} [opts]
|
|
222
|
+
* @returns {void}
|
|
223
|
+
*/
|
|
224
|
+
/**
|
|
225
|
+
* @callback CDSError
|
|
226
|
+
* @param {{ status?: number; message?: string; code?: string; target?: string; args?: any[] }} opts
|
|
227
|
+
* @returns {void}
|
|
228
|
+
*/
|
|
79
229
|
/**
|
|
80
230
|
* Handles 'on' and 'before' event registrations.
|
|
81
231
|
* Supports both signatures: (event, entities, handler) AND (event, handler).
|
|
@@ -96,28 +246,34 @@ export type ServieEventsHandler = Partial<Record<ServiceEventsKey, ServiceEventI
|
|
|
96
246
|
*/
|
|
97
247
|
/**
|
|
98
248
|
* @callback CDSHandler
|
|
99
|
-
* @param {
|
|
249
|
+
* @param {CDSRequest} req - The incoming request object.
|
|
250
|
+
* @param {() => Promise<any>} next - The function to call the next handler in the chain.
|
|
100
251
|
* @returns {any | Promise<any>}
|
|
101
252
|
*/
|
|
102
253
|
/**
|
|
103
254
|
* @callback CDSAfterHandler
|
|
104
255
|
* @param {any} results - The results from the primary execution.
|
|
105
|
-
* @param {
|
|
256
|
+
* @param {CDSRequest} req - The incoming request object.
|
|
106
257
|
* @returns {any | Promise<any>}
|
|
107
258
|
*/
|
|
108
259
|
/**
|
|
109
260
|
* @typedef {CDSService} CDSServiceTx
|
|
110
261
|
*/
|
|
111
262
|
/**
|
|
112
|
-
* @callback
|
|
263
|
+
* @callback ServiceEventsServiceInterceptor
|
|
113
264
|
* @param {CDSService} oService - Service object for which request to be executed
|
|
114
265
|
* @returns {Promise<void>}
|
|
115
266
|
*/
|
|
267
|
+
/**
|
|
268
|
+
* @callback ServiceEventsServiceInterceptor
|
|
269
|
+
* @param {CDSRequest} oRequest - Request object
|
|
270
|
+
* @returns {Promise<void>}
|
|
271
|
+
*/
|
|
116
272
|
/**
|
|
117
273
|
* @typedef {typeof import('../service').service} Service
|
|
118
274
|
* @typedef {Service['events']} ServiceEvents
|
|
119
275
|
* @typedef {keyof ServiceEvents} ServiceEventsKey
|
|
120
|
-
* @typedef {Partial<Record<ServiceEventsKey,
|
|
276
|
+
* @typedef {Partial<Record<ServiceEventsKey, ServiceEventsServiceInterceptor>>} ServieEventsHandler
|
|
121
277
|
*/
|
|
122
278
|
export class impl {
|
|
123
279
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/impl/index.js"],"names":[],"mappings":";;;;cAuBc,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;SACnB,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;;;;QAC5B,CAAC,GAAG,EAAE,GAAG,KAAK,YAAY;;;;iBAC1B,CAAC,GAAG,EAAE,GAAG,KAAK,YAAY;;;;QAC1B,SAAS;;;;YACT,SAAS;;;;WACT,cAAc;;;;UACd,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC;;;;UAC5C,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;;;;YAC9C,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/impl/index.js"],"names":[],"m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