codehooks-js 1.1.10 → 1.2.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.
- package/README.md +77 -7
- package/aggregation/index.mjs +9 -2
- package/crudlify/index.mjs +4 -4
- package/index.js +129 -93
- package/package.json +5 -2
- package/tsconfig.json +22 -0
- package/types/aggregation/index.d.mts +43 -0
- package/types/aggregation/index.d.mts.map +1 -0
- package/types/coderunner.d.mts +2 -0
- package/types/coderunner.d.mts.map +1 -0
- package/types/cronjob.d.mts +2 -0
- package/types/cronjob.d.mts.map +1 -0
- package/types/crudlify/index.d.mts +11 -0
- package/types/crudlify/index.d.mts.map +1 -0
- package/types/crudlify/lib/eventhooks.d.mts +56 -0
- package/types/crudlify/lib/eventhooks.d.mts.map +1 -0
- package/types/crudlify/lib/query/q2m/index.d.mts +15 -0
- package/types/crudlify/lib/query/q2m/index.d.mts.map +1 -0
- package/types/crudlify/lib/query/q2m/q2m.d.mts +11 -0
- package/types/crudlify/lib/query/q2m/q2m.d.mts.map +1 -0
- package/types/crudlify/lib/schema/json-schema/index.d.mts +4 -0
- package/types/crudlify/lib/schema/json-schema/index.d.mts.map +1 -0
- package/types/crudlify/lib/schema/yup/index.d.mts +4 -0
- package/types/crudlify/lib/schema/yup/index.d.mts.map +1 -0
- package/types/crudlify/lib/schema/zod/index.d.mts +4 -0
- package/types/crudlify/lib/schema/zod/index.d.mts.map +1 -0
- package/types/index.d.ts +681 -0
- package/types/index.d.ts.map +1 -0
- package/types/webserver.d.mts +3 -0
- package/types/webserver.d.mts.map +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent NoSql and Kev-Value datastore
|
|
3
|
+
* @typedef {Object} DataStream
|
|
4
|
+
* @property {function(string, function(*)):void} on - Emits data, stream.on('data', (data) => //console.debug(data))
|
|
5
|
+
* @property {function(httpResponse):void} json - Pipe datastream to JSON output
|
|
6
|
+
* @property {function():Promise.<object[]>} toArray - Return an array of objects
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {DataStream} readable - JSON stream
|
|
11
|
+
* @param {Object} spec - JSON aggregation spec
|
|
12
|
+
* @returns {Promise} with aggregation result
|
|
13
|
+
* @example
|
|
14
|
+
* Spec JSON example:
|
|
15
|
+
* {
|
|
16
|
+
* "$max": {$field: "open", $label: "Open"},
|
|
17
|
+
"$group": {
|
|
18
|
+
"$field": "Ticker",
|
|
19
|
+
$label: "Symbol",
|
|
20
|
+
"$max": "high",
|
|
21
|
+
"$min": {$field: "close", $label: "Low"}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
*/
|
|
25
|
+
export function agg(readable: DataStream, spec: any): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Persistent NoSql and Kev-Value datastore
|
|
28
|
+
*/
|
|
29
|
+
export type DataStream = {
|
|
30
|
+
/**
|
|
31
|
+
* - Emits data, stream.on('data', (data) => //console.debug(data))
|
|
32
|
+
*/
|
|
33
|
+
on: (arg0: string, arg1: (arg0: any) => any) => void;
|
|
34
|
+
/**
|
|
35
|
+
* - Pipe datastream to JSON output
|
|
36
|
+
*/
|
|
37
|
+
json: (arg0: httpResponse) => void;
|
|
38
|
+
/**
|
|
39
|
+
* - Return an array of objects
|
|
40
|
+
*/
|
|
41
|
+
toArray: () => Promise<object[]>;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../aggregation/index.mjs"],"names":[],"mappings":"AACA;;;;;;EAME;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,8BAfW,UAAU,2BAsCpB;;;;;;;;eA7CqB,MAAM,+BAAe,IAAI;;;;kCACX,IAAI;;;;mBAChB,QAAS,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coderunner.d.mts","sourceRoot":"","sources":["../coderunner.mjs"],"names":[],"mappings":"AAAA,iGAqBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronjob.d.mts","sourceRoot":"","sources":["../cronjob.mjs"],"names":[],"mappings":"AAMA,+DA6BC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {object} app - Codehooks app ( npm package codehooks-js)
|
|
4
|
+
* @param {object} schema - Yup schema object
|
|
5
|
+
* @param {object} options - Options
|
|
6
|
+
* @returns {EventHooks} Hooks for REST operations
|
|
7
|
+
*/
|
|
8
|
+
export default function crudlify(app: object, schema?: object, options?: object): EventHooks;
|
|
9
|
+
import { EventHooks } from "./lib/eventhooks.mjs";
|
|
10
|
+
export function setDatastore(ds: any): void;
|
|
11
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../crudlify/index.mjs"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,sCALW,MAAM,WACN,MAAM,YACN,MAAM,GACJ,UAAU,CA0EtB;2BAhG0B,sBAAsB;AAoGjD,4CAEC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware to add function hooks pre/post CRUD database operations
|
|
3
|
+
*/
|
|
4
|
+
export class EventHooks {
|
|
5
|
+
listeners: {};
|
|
6
|
+
/**
|
|
7
|
+
* Before hook
|
|
8
|
+
* @param {*} coll
|
|
9
|
+
* @param {*} verb
|
|
10
|
+
* @param {*} data
|
|
11
|
+
*/
|
|
12
|
+
fireBefore(coll: any, verb: any, data: any): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* After hook
|
|
15
|
+
* @param {*} coll
|
|
16
|
+
* @param {*} verb
|
|
17
|
+
* @param {*} data
|
|
18
|
+
*/
|
|
19
|
+
fireAfter(coll: any, verb: any, data: any): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Codehook called before data is updated in database
|
|
22
|
+
* @param {*} coll
|
|
23
|
+
* @param {*} func
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
beforePUT(coll: any, func: any): this;
|
|
27
|
+
/**
|
|
28
|
+
* Codehook called before data is inserted into database
|
|
29
|
+
* @param {*} coll
|
|
30
|
+
* @param {*} func
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
beforePOST(coll: any, func: any): this;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* @param {*} coll
|
|
37
|
+
* @param {*} func
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
afterPOST(coll: any, func: any): this;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {*} coll
|
|
44
|
+
* @param {*} func
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
beforePATCH(coll: any, func: any): this;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param {*} coll
|
|
51
|
+
* @param {*} func
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
beforeDELETE(coll: any, func: any): this;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=eventhooks.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventhooks.d.mts","sourceRoot":"","sources":["../../../crudlify/lib/eventhooks.mjs"],"names":[],"mappings":"AACA;;GAEG;AACH;IAEQ,cAAmB;IAGvB;;;;;OAKG;IACH,2DAOC;IAED;;;;;OAKG;IACH,0DAQC;IACD;;;;;OAKG;IACH,sCAIC;IAED;;;;;OAKG;IACH,uCAIC;IACD;;;;;OAKG;IACH,sCAIC;IAED;;;;;OAKG;IACH,wCAIC;IACD;;;;;OAKG;IACH,yCAIC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert request query to mongoDB query by query-to-mongo lib
|
|
3
|
+
* @param {*} query
|
|
4
|
+
* @param {*} headers
|
|
5
|
+
* @returns Object
|
|
6
|
+
*/
|
|
7
|
+
export function getMongoQuery(query: any, headers: any): {
|
|
8
|
+
filter: any;
|
|
9
|
+
hints: any;
|
|
10
|
+
aggregate: any;
|
|
11
|
+
limit: any;
|
|
12
|
+
offset: any;
|
|
13
|
+
fields: any;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../../crudlify/lib/query/q2m/index.mjs"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;;;;;;;EAsCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"q2m.d.mts","sourceRoot":"","sources":["../../../../../crudlify/lib/query/q2m/q2m.mjs"],"names":[],"mappings":"AA+MA;;;;;;;;;EAyDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../../crudlify/lib/schema/json-schema/index.mjs"],"names":[],"mappings":"AAUO,iFAWN;AAUM,sDAGN;AAEM,yDAIN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../../crudlify/lib/schema/yup/index.mjs"],"names":[],"mappings":"AAQO,0DAIN;AAEM,sDAGN;AAEM,2CAGN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../../crudlify/lib/schema/zod/index.mjs"],"names":[],"mappings":"AAQO,mEASN;AAEM,sDAGN;AAEM,2CAGN"}
|