codehooks-js 1.2.19 → 1.3.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/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {agg} from './aggregation/index.mjs';
2
2
  import {crudlify as crud} from './crudlify/index.mjs';
3
3
  import {serveStatic as ws, render as renderView} from './webserver.mjs';
4
+ import {Steps, StepsConfig} from './workflow/index.mjs';
4
5
 
5
6
  function createRoute(str) {
6
7
  if(str instanceof RegExp) {
@@ -115,6 +116,11 @@ class Codehooks {
115
116
  res.status(200).json({...data});
116
117
  })
117
118
  }
119
+
120
+ createSteps = (name, description, steps, options={}) => {
121
+ Steps.register(this, name, description, steps, options);
122
+ return Steps;
123
+ }
118
124
 
119
125
  init = (hook) => {
120
126
  const manifest = {
@@ -187,7 +193,11 @@ export const aggregation = agg;
187
193
  export const crudlify = crud;
188
194
  export const coho = _coho;
189
195
  export const app = _coho;
190
-
196
+ export const stepsconfig = StepsConfig;
197
+ export {
198
+ Steps,
199
+ StepsConfig
200
+ };
191
201
  export const realtime = {
192
202
  createChannel: (path, ...hook) => {
193
203
  Codehooks.getInstance().realtime(path, ...hook);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "codehooks-js",
3
- "version": "1.2.19",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "Codehooks.io official library - provides express.JS like syntax",
6
6
  "main": "index.js",
7
- "types": "./types",
7
+ "types": "./types/index.d.ts",
8
8
  "files": [
9
9
  "index.js",
10
10
  "./aggregation/index.mjs",
@@ -16,11 +16,15 @@
16
16
  "./crudlify/lib/schema/yup/index.mjs",
17
17
  "./crudlify/lib/schema/json-schema/index.mjs",
18
18
  "./crudlify/lib/schema/zod/index.mjs",
19
+ "./workflow/index.mjs",
20
+ "./workflow/engine.mjs",
19
21
  "./types",
20
22
  "tsconfig.json"
21
23
  ],
22
24
  "scripts": {
23
- "test": "echo \"Warning: no tests specified\""
25
+ "test": "echo \"Warning: no tests specified\"",
26
+ "build": "tsc",
27
+ "prepublishOnly": "npm run build"
24
28
  },
25
29
  "author": "Codehooks",
26
30
  "license": "ISC",
@@ -45,5 +49,9 @@
45
49
  "lodash": "^4.17.21",
46
50
  "mime": "^3.0.0",
47
51
  "node-cron": "^3.0.2"
52
+ },
53
+ "devDependencies": {
54
+ "@types/mime": "^3.0.4",
55
+ "@types/node": "^22.15.19"
48
56
  }
49
57
  }
package/tsconfig.json CHANGED
@@ -1,22 +1,35 @@
1
1
  {
2
- // Change this to match your project
3
- "include": ["**/*"],
4
- "exclude": ["node_modules/**"],
5
- "compilerOptions": {
6
- // Tells TypeScript to read JS files, as
7
- // normally they are ignored as source files
8
- "allowJs": true,
9
- // Generate d.ts files
10
- "declaration": true,
11
- // This compiler run should
12
- // only output d.ts files
13
- "emitDeclarationOnly": true,
14
- // Types should go into this directory.
15
- // Removing this would place the .d.ts files
16
- // next to the .js files
17
- "outDir": "dist",
18
- // go to js file when using IDE functions like
19
- // "Go to Definition" in VSCode
20
- "declarationMap": true
21
- }
22
- }
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2020",
5
+ "moduleResolution": "node",
6
+ "declaration": true,
7
+ "emitDeclarationOnly": true,
8
+ "allowJs": true,
9
+ "checkJs": false,
10
+ "outDir": "./types",
11
+ "rootDir": ".",
12
+ "strict": false,
13
+ "noImplicitAny": false,
14
+ "esModuleInterop": true,
15
+ "skipLibCheck": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "resolveJsonModule": true,
18
+ "isolatedModules": true,
19
+ "allowSyntheticDefaultImports": true
20
+ },
21
+ "include": [
22
+ "*.js",
23
+ "*.mjs",
24
+ "aggregation/**/*.js",
25
+ "aggregation/**/*.mjs",
26
+ "crudlify/**/*.js",
27
+ "crudlify/**/*.mjs",
28
+ "workflow/**/*.js",
29
+ "workflow/**/*.mjs"
30
+ ],
31
+ "exclude": [
32
+ "node_modules",
33
+ "dist"
34
+ ]
35
+ }
@@ -1,38 +1 @@
1
- import { httpResponse } from '..';
2
-
3
- /**
4
- *
5
- * @param {DataStream} readable - JSON stream
6
- * @param {Object} spec - JSON aggregation spec
7
- * @returns {Promise} with aggregation result
8
- * @example
9
- * Spec JSON example:
10
- * {
11
- * "$max": {$field: "open", $label: "Open"},
12
- "$group": {
13
- "$field": "Ticker",
14
- $label: "Symbol",
15
- "$max": "high",
16
- "$min": {$field: "close", $label: "Low"}
17
- }
18
- }
19
- */
20
- export function agg(readable: DataStream, spec: any): Promise<any>;
21
- /**
22
- * Persistent NoSql and Kev-Value datastore
23
- */
24
- export type DataStream = {
25
- /**
26
- * - Emits data, stream.on('data', (data) => //console.debug(data))
27
- */
28
- on: (arg0: string, arg1: (arg0: any) => any) => void;
29
- /**
30
- * - Pipe datastream to JSON output
31
- */
32
- json: (response: httpResponse) => void;
33
- /**
34
- * - Return an array of objects
35
- */
36
- toArray: () => Promise<object[]>;
37
- };
38
- //# sourceMappingURL=index.d.mts.map
1
+ export function agg(readable: any, spec: any): Promise<any>;
@@ -1,11 +1,7 @@
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 {Promise} EventHooks for REST operations
7
- */
8
- export default function crudlify(app: object, schema?: object, options?: object): Promise<EventHooks>;
1
+ export default function crudlify(app: any, schema?: {}, options?: {
2
+ schema: string;
3
+ query: string;
4
+ prefix: string;
5
+ }): Promise<EventHooks>;
9
6
  import { EventHooks } from "./lib/eventhooks.mjs";
10
7
  export function setDatastore(ds: any): void;
11
- //# sourceMappingURL=index.d.mts.map
@@ -53,4 +53,3 @@ export class EventHooks {
53
53
  */
54
54
  beforeDELETE(coll: any, func: any): this;
55
55
  }
56
- //# sourceMappingURL=eventhooks.d.mts.map
@@ -1,9 +1,3 @@
1
- /**
2
- * Convert request query to mongoDB query by query-to-mongo lib
3
- * @param {*} query
4
- * @param {*} headers
5
- * @returns Object
6
- */
7
1
  export function getMongoQuery(query: any, headers: any): {
8
2
  filter: any;
9
3
  hints: any;
@@ -12,4 +6,3 @@ export function getMongoQuery(query: any, headers: any): {
12
6
  offset: any;
13
7
  fields: any;
14
8
  };
15
- //# sourceMappingURL=index.d.mts.map
@@ -8,4 +8,3 @@ export default function _default(query: any, options: any): {
8
8
  };
9
9
  links: (url: any, totalCount: any) => {};
10
10
  };
11
- //# sourceMappingURL=q2m.d.mts.map
@@ -1,4 +1,3 @@
1
1
  export function validate(schema: any, document: any, options: any): Promise<any>;
2
2
  export function cast(schema: any, document: any): any;
3
3
  export function prepare(schemas: any, options: any): any;
4
- //# sourceMappingURL=index.d.mts.map
@@ -1,4 +1,3 @@
1
- export function validate(schema: any, document: any): any;
1
+ export function validate(schema: any, document: any): Promise<any>;
2
2
  export function cast(schema: any, document: any): any;
3
3
  export function prepare(schemas: any): any;
4
- //# sourceMappingURL=index.d.mts.map
@@ -1,4 +1,3 @@
1
1
  export function validate(schema: any, document: any): Promise<any>;
2
2
  export function cast(schema: any, document: any): any;
3
3
  export function prepare(schemas: any): any;
4
- //# sourceMappingURL=index.d.mts.map