esi-cap 1.7.41 → 1.7.43
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 +173 -15
- 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,16 @@ 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:
|
|
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>;
|
|
166
|
+
export type ServiceEventsRequestInterceptor = (oRequest: CDSRequest) => Promise<void>;
|
|
57
167
|
export type Service = typeof import("../service").service;
|
|
58
168
|
export type ServiceEvents = Service["events"];
|
|
59
169
|
export type ServiceEventsKey = keyof ServiceEvents;
|
|
60
|
-
export type
|
|
170
|
+
export type ServieEventsServiceHandler = Partial<Record<ServiceEventsKey, ServiceEventsServiceInterceptor>>;
|
|
171
|
+
export type ServieEventsRequestHandler = Partial<Record<ServiceEventsKey, ServiceEventsRequestInterceptor>>;
|
|
61
172
|
/**
|
|
62
173
|
* impl module
|
|
63
174
|
* @class
|
|
@@ -76,6 +187,47 @@ export type ServieEventsHandler = Partial<Record<ServiceEventsKey, ServiceEventI
|
|
|
76
187
|
* @property {(action: string, params?: any) => Promise<any>} send - Sends a custom action or function call to the service.
|
|
77
188
|
* @property {(entity: string, where: any) => Promise<number>} delete - Deletes records matching the given criteria.
|
|
78
189
|
*/
|
|
190
|
+
/**
|
|
191
|
+
* @template T
|
|
192
|
+
* @typedef {Object} CDSRequest
|
|
193
|
+
* @property {T & { params?: any }} data - The request payload.
|
|
194
|
+
* @property {Record<string, string>} headers - Map of request headers.
|
|
195
|
+
* @property {any[]} params - Positional parameters from the URL.
|
|
196
|
+
* @property {CDSUser} user - The authenticated user information.
|
|
197
|
+
* @property {any} query - The CQN (OData-like) query structure.
|
|
198
|
+
* @property {CDSTarget} target - Information about the target entity.
|
|
199
|
+
* @property {string} event - The name of the event (e.g., 'READ', 'UPDATE').
|
|
200
|
+
* @property {{ req: { headers: Record<string, string> } }} [http] - The underlying HTTP request (if applicable).
|
|
201
|
+
* @property {CDSReject} reject - Rejects the request with a specific status and message.
|
|
202
|
+
* @property {CDSError} error - Adds an error to the request without necessarily stopping execution.
|
|
203
|
+
* @property {(opts: { message: string }) => void} warn - Adds a warning message to the response.
|
|
204
|
+
* @property {(msg: string) => void} info - Adds an informational message to the response.
|
|
205
|
+
* @property {any[]} [errors] - Collection of errors collected during processing.
|
|
206
|
+
* @property {any} [PreOn] - esi-cap runtime extension: logic to run before the 'on' phase.
|
|
207
|
+
* @property {any} [PostOn] - esi-cap runtime extension: logic to run after the 'on' phase.
|
|
208
|
+
* @property {any} [PreMeshUp] - esi-cap runtime extension: pre-mashup processing.
|
|
209
|
+
*/
|
|
210
|
+
/**
|
|
211
|
+
* @typedef {Object} CDSUser
|
|
212
|
+
* @property {string} id - The user's unique identifier.
|
|
213
|
+
* @property {Record<string, any>} attr - Custom user attributes.
|
|
214
|
+
* @property {(role: string) => boolean} is - Checks if the user has a specific role.
|
|
215
|
+
*/
|
|
216
|
+
/**
|
|
217
|
+
* @typedef {Object} CDSTarget
|
|
218
|
+
* @property {string} name - The absolute name of the target entity.
|
|
219
|
+
* @property {any} [projection] - Any projection (select list) applied to the entity.
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* @callback CDSReject
|
|
223
|
+
* @param {{ status?: number; message?: string }} [opts]
|
|
224
|
+
* @returns {void}
|
|
225
|
+
*/
|
|
226
|
+
/**
|
|
227
|
+
* @callback CDSError
|
|
228
|
+
* @param {{ status?: number; message?: string; code?: string; target?: string; args?: any[] }} opts
|
|
229
|
+
* @returns {void}
|
|
230
|
+
*/
|
|
79
231
|
/**
|
|
80
232
|
* Handles 'on' and 'before' event registrations.
|
|
81
233
|
* Supports both signatures: (event, entities, handler) AND (event, handler).
|
|
@@ -96,57 +248,63 @@ export type ServieEventsHandler = Partial<Record<ServiceEventsKey, ServiceEventI
|
|
|
96
248
|
*/
|
|
97
249
|
/**
|
|
98
250
|
* @callback CDSHandler
|
|
99
|
-
* @param {
|
|
251
|
+
* @param {CDSRequest} req - The incoming request object.
|
|
100
252
|
* @param {() => Promise<any>} next - The function to call the next handler in the chain.
|
|
101
253
|
* @returns {any | Promise<any>}
|
|
102
254
|
*/
|
|
103
255
|
/**
|
|
104
256
|
* @callback CDSAfterHandler
|
|
105
257
|
* @param {any} results - The results from the primary execution.
|
|
106
|
-
* @param {
|
|
258
|
+
* @param {CDSRequest} req - The incoming request object.
|
|
107
259
|
* @returns {any | Promise<any>}
|
|
108
260
|
*/
|
|
109
261
|
/**
|
|
110
262
|
* @typedef {CDSService} CDSServiceTx
|
|
111
263
|
*/
|
|
112
264
|
/**
|
|
113
|
-
* @callback
|
|
265
|
+
* @callback ServiceEventsServiceInterceptor
|
|
114
266
|
* @param {CDSService} oService - Service object for which request to be executed
|
|
115
267
|
* @returns {Promise<void>}
|
|
116
268
|
*/
|
|
269
|
+
/**
|
|
270
|
+
* @callback ServiceEventsRequestInterceptor
|
|
271
|
+
* @param {CDSRequest} oRequest - Request object
|
|
272
|
+
* @returns {Promise<void>}
|
|
273
|
+
*/
|
|
117
274
|
/**
|
|
118
275
|
* @typedef {typeof import('../service').service} Service
|
|
119
276
|
* @typedef {Service['events']} ServiceEvents
|
|
120
277
|
* @typedef {keyof ServiceEvents} ServiceEventsKey
|
|
121
|
-
* @typedef {Partial<Record<ServiceEventsKey,
|
|
278
|
+
* @typedef {Partial<Record<ServiceEventsKey, ServiceEventsServiceInterceptor>>} ServieEventsServiceHandler
|
|
279
|
+
* @typedef {Partial<Record<ServiceEventsKey, ServiceEventsRequestInterceptor>>} ServieEventsRequestHandler
|
|
122
280
|
*/
|
|
123
281
|
export class impl {
|
|
124
282
|
/**
|
|
125
283
|
* @param {object} oService - Service object for which request to be executed
|
|
126
|
-
* @param {
|
|
284
|
+
* @param {ServieEventsServiceHandler|ServieEventsRequestHandler} oEvent
|
|
127
285
|
* @returns {Promise<void>}
|
|
128
286
|
*/
|
|
129
|
-
static DBService(oService: object, oEvent:
|
|
287
|
+
static DBService(oService: object, oEvent: ServieEventsServiceHandler | ServieEventsRequestHandler): Promise<void>;
|
|
130
288
|
/**
|
|
131
289
|
* @param {object} oService - Service object for which request to be executed
|
|
132
290
|
* @param {string} sServiceName - Service Name
|
|
133
|
-
* @param {
|
|
291
|
+
* @param {ServieEventsServiceHandler|ServieEventsRequestHandler} oEvent
|
|
134
292
|
* @param {string|any[]} oLocalEntities
|
|
135
|
-
* @param {
|
|
293
|
+
* @param {ServieEventsServiceHandler|ServieEventsRequestHandler} oRemoteEvent
|
|
136
294
|
* @param {string|any[]} [oRemoteEntities]
|
|
137
295
|
* @param {any[]} [oRemoteHandlers]
|
|
138
296
|
* @param {boolean} bRefreshUserContext
|
|
139
297
|
* @returns {Promise<void>}
|
|
140
298
|
*/
|
|
141
|
-
static LocalService(oService: object, sServiceName: string, oEvent?:
|
|
299
|
+
static LocalService(oService: object, sServiceName: string, oEvent?: ServieEventsServiceHandler | ServieEventsRequestHandler, oLocalEntities?: string | any[], oRemoteEvent?: ServieEventsServiceHandler | ServieEventsRequestHandler, oRemoteEntities?: string | any[], oRemoteHandlers?: any[], bRefreshUserContext?: boolean): Promise<void>;
|
|
142
300
|
/**
|
|
143
301
|
* @param {object} oService - Service object for which request to be executed
|
|
144
|
-
* @param {
|
|
302
|
+
* @param {ServieEventsServiceHandler|ServieEventsRequestHandler} oEvent
|
|
145
303
|
* @param {string|any[]} oEntities
|
|
146
304
|
* @param {any[]} [oHandlers]
|
|
147
305
|
* @param {boolean} bRefreshUserContext
|
|
148
306
|
* @returns {Promise<void>}
|
|
149
307
|
*/
|
|
150
|
-
static RemoteService(oService: object, oEvent?:
|
|
308
|
+
static RemoteService(oService: object, oEvent?: ServieEventsServiceHandler | ServieEventsRequestHandler, oEntities?: string | any[], oHandlers?: any[], bRefreshUserContext?: boolean): Promise<void>;
|
|
151
309
|
}
|
|
152
310
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,C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