esi-cap 1.7.38 → 1.7.40

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.
@@ -1,56 +1,151 @@
1
+ export type CDSService = {
2
+ /**
3
+ * - Collection of entities served by this service.
4
+ */
5
+ entities: Record<string, any>;
6
+ /**
7
+ * - Executes a given query against the service.
8
+ */
9
+ run: (query: any) => Promise<any>;
10
+ /**
11
+ * - Starts a new transaction.
12
+ */
13
+ tx: (req: any) => CDSServiceTx;
14
+ /**
15
+ * - Alias for the tx method.
16
+ */
17
+ transaction: (req: any) => CDSServiceTx;
18
+ /**
19
+ * - Registers a handler for specific events.
20
+ */
21
+ on: CDSMethod;
22
+ /**
23
+ * - Registers a handler to run before the standard logic.
24
+ */
25
+ before: CDSMethod;
26
+ /**
27
+ * - Registers a handler to run after the standard logic.
28
+ */
29
+ after: CDSAfterMethod;
30
+ /**
31
+ * - Synchronously or asynchronously triggers an event.
32
+ */
33
+ emit: (event: string, data?: any) => Promise<void>;
34
+ /**
35
+ * - Sends a custom action or function call to the service.
36
+ */
37
+ send: (action: string, params?: any) => Promise<any>;
38
+ /**
39
+ * - Deletes records matching the given criteria.
40
+ */
41
+ delete: (entity: string, where: any) => Promise<number>;
42
+ };
1
43
  /**
2
- * impl module
44
+ * Handles 'on' and 'before' event registrations.
45
+ * Supports both signatures: (event, entities, handler) AND (event, handler).
3
46
  */
4
- export type Service = typeof import("../service").service;
47
+ export type CDSMethod = (event: string | string[], entitiesOrHandler: any | CDSHandler, handler?: CDSHandler) => void;
5
48
  /**
6
- * impl module
49
+ * Handles 'after' event registrations.
50
+ * Supports both signatures: (event, entities, handler) AND (event, handler).
7
51
  */
52
+ 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: any) => any | Promise<any>;
55
+ export type CDSServiceTx = CDSService;
56
+ export type ServiceEventInterceptor = (oService: CDSService) => Promise<void>;
57
+ export type Service = typeof import("../service").service;
8
58
  export type ServiceEvents = Service["events"];
9
- /**
10
- * impl module
11
- */
12
59
  export type ServiceEventsKey = keyof ServiceEvents;
13
- export type ServiceEventInterceptor = (oService: object) => Promise<void>;
60
+ export type ServieEventsHandler = Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>;
14
61
  /**
15
62
  * impl module
16
63
  * @class
17
64
  * @public
18
- * @typedef {typeof import('../service').service} Service
19
- * @typedef {Service['events']} ServiceEvents
20
- * @typedef {keyof ServiceEvents} ServiceEventsKey
65
+ */
66
+ /**
67
+ * @typedef {Object} CDSService
68
+ * @property {Record<string, any>} entities - Collection of entities served by this service.
69
+ * @property {(query: any) => Promise<any>} run - Executes a given query against the service.
70
+ * @property {(req: any) => CDSServiceTx} tx - Starts a new transaction.
71
+ * @property {(req: any) => CDSServiceTx} transaction - Alias for the tx method.
72
+ * @property {CDSMethod} on - Registers a handler for specific events.
73
+ * @property {CDSMethod} before - Registers a handler to run before the standard logic.
74
+ * @property {CDSAfterMethod} after - Registers a handler to run after the standard logic.
75
+ * @property {(event: string, data?: any) => Promise<void>} emit - Synchronously or asynchronously triggers an event.
76
+ * @property {(action: string, params?: any) => Promise<any>} send - Sends a custom action or function call to the service.
77
+ * @property {(entity: string, where: any) => Promise<number>} delete - Deletes records matching the given criteria.
78
+ */
79
+ /**
80
+ * Handles 'on' and 'before' event registrations.
81
+ * Supports both signatures: (event, entities, handler) AND (event, handler).
82
+ * @callback CDSMethod
83
+ * @param {string | string[]} event - The name of the event (e.g., 'READ', 'UPDATE').
84
+ * @param {any | CDSHandler} entitiesOrHandler - Either the target entity/entities or the handler function.
85
+ * @param {CDSHandler} [handler] - The handler function if an entity was provided as the second argument.
86
+ * @returns {void}
87
+ */
88
+ /**
89
+ * Handles 'after' event registrations.
90
+ * Supports both signatures: (event, entities, handler) AND (event, handler).
91
+ * @callback CDSAfterMethod
92
+ * @param {string | string[]} event - The name of the event.
93
+ * @param {any | CDSAfterHandler} entitiesOrHandler - Either the target entity or the handler function.
94
+ * @param {CDSAfterHandler} [handler] - The handler function if an entity was provided.
95
+ * @returns {void}
96
+ */
97
+ /**
98
+ * @callback CDSHandler
99
+ * @param {any} req - The incoming request object.
100
+ * @returns {any | Promise<any>}
101
+ */
102
+ /**
103
+ * @callback CDSAfterHandler
104
+ * @param {any} results - The results from the primary execution.
105
+ * @param {any} req - The incoming request object.
106
+ * @returns {any | Promise<any>}
107
+ */
108
+ /**
109
+ * @typedef {CDSService} CDSServiceTx
21
110
  */
22
111
  /**
23
112
  * @callback ServiceEventInterceptor
24
- * @param {object} oService - Service object for which request to be executed
113
+ * @param {CDSService} oService - Service object for which request to be executed
25
114
  * @returns {Promise<void>}
26
115
  */
116
+ /**
117
+ * @typedef {typeof import('../service').service} Service
118
+ * @typedef {Service['events']} ServiceEvents
119
+ * @typedef {keyof ServiceEvents} ServiceEventsKey
120
+ * @typedef {Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>} ServieEventsHandler
121
+ */
27
122
  export class impl {
28
123
  /**
29
124
  * @param {object} oService - Service object for which request to be executed
30
- * @param {Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>} oEvent
125
+ * @param {ServieEventsHandler} oEvent
31
126
  * @returns {Promise<void>}
32
127
  */
33
- static DBService(oService: object, oEvent: Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>): Promise<void>;
128
+ static DBService(oService: object, oEvent: ServieEventsHandler): Promise<void>;
34
129
  /**
35
130
  * @param {object} oService - Service object for which request to be executed
36
131
  * @param {string} sServiceName - Service Name
37
- * @param {Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>} oEvent
132
+ * @param {ServieEventsHandler} oEvent
38
133
  * @param {string|any[]} oLocalEntities
39
- * @param {Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>} oRemoteEvent
134
+ * @param {ServieEventsHandler} oRemoteEvent
40
135
  * @param {string|any[]} [oRemoteEntities]
41
136
  * @param {any[]} [oRemoteHandlers]
42
137
  * @param {boolean} bRefreshUserContext
43
138
  * @returns {Promise<void>}
44
139
  */
45
- static LocalService(oService: object, sServiceName: string, oEvent?: Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>, oLocalEntities?: string | any[], oRemoteEvent?: Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>, oRemoteEntities?: string | any[], oRemoteHandlers?: any[], bRefreshUserContext?: boolean): Promise<void>;
140
+ static LocalService(oService: object, sServiceName: string, oEvent?: ServieEventsHandler, oLocalEntities?: string | any[], oRemoteEvent?: ServieEventsHandler, oRemoteEntities?: string | any[], oRemoteHandlers?: any[], bRefreshUserContext?: boolean): Promise<void>;
46
141
  /**
47
142
  * @param {object} oService - Service object for which request to be executed
48
- * @param {Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>} oEvent
143
+ * @param {ServieEventsHandler} oEvent
49
144
  * @param {string|any[]} oEntities
50
145
  * @param {any[]} [oHandlers]
51
146
  * @param {boolean} bRefreshUserContext
52
147
  * @returns {Promise<void>}
53
148
  */
54
- static RemoteService(oService: object, oEvent?: Partial<Record<ServiceEventsKey, ServiceEventInterceptor>>, oEntities?: string | any[], oHandlers?: any[], bRefreshUserContext?: boolean): Promise<void>;
149
+ static RemoteService(oService: object, oEvent?: ServieEventsHandler, oEntities?: string | any[], oHandlers?: any[], bRefreshUserContext?: boolean): Promise<void>;
55
150
  }
56
151
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/impl/index.js"],"names":[],"mappings":";;;sBAmBa,cAAc,YAAY,EAAE,OAAO;;;;4BACnC,OAAO,CAAC,QAAQ,CAAC;;;;+BACjB,MAAM,aAAa;iDAKrB,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC;AAZ1B;;;;;;;GAOG;AAEH;;;;GAIG;AACH;IACI;;;;OAIG;IACH,2BAJW,MAAM,UACN,OAAO,CAAC,MA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,MAAM,EAAE,qBACjB,GAAG,GAAG,UAAU,YAChB,UAAU,KACR,IAAI;;;;;qCAON,MAAM,GAAG,MAAM,EAAE,qBACjB,GAAG,GAAG,eAAe,YACrB,eAAe,KACb,IAAI;+BAKN,GAAG,KACD,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;wCAKpB,GAAG,OACH,GAAG,KACD,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;2BAIlB,UAAU;iDAKZ,UAAU,KACR,OAAO,CAAC,IAAI,CAAC;sBAIb,cAAc,YAAY,EAAE,OAAO;4BACnC,OAAO,CAAC,QAAQ,CAAC;+BACjB,MAAM,aAAa;kCACnB,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;AAnEvE;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;IACI;;;;OAIG;IACH,2BAJW,MAAM,UACN,mBAAmB,GACjB,OAAO,CAAC,IAAI,CAAC,CAMzB;IAED;;;;;;;;;;OAUG;IACH,8BAVW,MAAM,gBACN,MAAM,WACN,mBAAmB,mBACnB,MAAM,GAAC,GAAG,EAAE,iBACZ,mBAAmB,oBACnB,MAAM,GAAC,GAAG,EAAE,oBACZ,GAAG,EAAE,wBACL,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CA0BzB;IAED;;;;;;;OAOG;IACH,+BAPW,MAAM,WACN,mBAAmB,cACnB,MAAM,GAAC,GAAG,EAAE,cACZ,GAAG,EAAE,wBACL,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CA8EzB;CACJ"}
@@ -1,9 +1,18 @@
1
- export function log(sServiceName?: any): {
2
- trace: (oEvent: any, oRequest: any, ...oArgs: any[]) => void;
3
- debug: (oEvent: any, oRequest: any, ...oArgs: any[]) => void;
4
- info: (oEvent: any, oRequest: any, ...oArgs: any[]) => void;
5
- warn: (oEvent: any, oRequest: any, ...oArgs: any[]) => void;
6
- error: (oEvent: any, oRequest: any, ...oArgs: any[]) => void;
7
- fatal: (oEvent: any, oRequest: any, ...oArgs: any[]) => void;
8
- };
1
+ declare namespace _exports {
2
+ export { Service, ServiceEvents, ServiceEventsValue };
3
+ }
4
+ declare namespace _exports {
5
+ function log(sServiceName?: string | undefined): {
6
+ trace: (oEvent: ServiceEventsValue, oRequest: object, ...oArgs: any[]) => void;
7
+ debug: (oEvent: ServiceEventsValue, oRequest: object, ...oArgs: any[]) => void;
8
+ info: (oEvent: ServiceEventsValue, oRequest: object, ...oArgs: any[]) => void;
9
+ warn: (oEvent: ServiceEventsValue, oRequest: object, ...oArgs: any[]) => void;
10
+ error: (oEvent: ServiceEventsValue, oRequest: object, ...oArgs: any[]) => void;
11
+ fatal: (oEvent: ServiceEventsValue, oRequest: object, ...oArgs: any[]) => void;
12
+ };
13
+ }
14
+ export = _exports;
15
+ type Service = typeof import("../service").service;
16
+ type ServiceEvents = Service["events"];
17
+ type ServiceEventsValue = ServiceEvents[keyof ServiceEvents];
9
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/log/index.js"],"names":[],"mappings":"AAMS;;;;;;;EAwBJ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../.types/lib/log/index.js"],"names":[],"mappings":";;;;IAaS,4BAAY,MAAM,GAAC,SAAS;wBAEe,kBAAkB,YAAuB,MAAM;wBAA/C,kBAAkB,YAAuB,MAAM;uBAA/C,kBAAkB,YAAuB,MAAM;uBAA/C,kBAAkB,YAAuB,MAAM;wBAA/C,kBAAkB,YAAuB,MAAM;wBAA/C,kBAAkB,YAAuB,MAAM;MAsB9F;;;eA9BQ,cAAc,YAAY,EAAE,OAAO;qBACnC,OAAO,CAAC,QAAQ,CAAC;0BACjB,aAAa,CAAC,MAAM,aAAa,CAAC"}