@digipair/skill-process 0.89.0 → 0.91.0-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/.swcrc ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2017",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true
12
+ },
13
+ "keepClassNames": true,
14
+ "externalHelpers": true,
15
+ "loose": true
16
+ },
17
+ "module": {
18
+ "type": "es6"
19
+ },
20
+ "sourceMaps": true,
21
+ "exclude": [
22
+ "jest.config.ts",
23
+ ".*\\.spec.tsx?$",
24
+ ".*\\.test.tsx?$",
25
+ "./src/jest-setup.ts$",
26
+ "./**/jest-setup.ts$"
27
+ ]
28
+ }
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # mylib
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build mylib` to build the library.
@@ -0,0 +1,22 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig,
5
+ {
6
+ files: ['**/*.json'],
7
+ rules: {
8
+ '@nx/dependency-checks': [
9
+ 'error',
10
+ {
11
+ ignoredFiles: [
12
+ '{projectRoot}/eslint.config.{js,cjs,mjs}',
13
+ '{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
14
+ ],
15
+ },
16
+ ],
17
+ },
18
+ languageOptions: {
19
+ parser: await import('jsonc-eslint-parser'),
20
+ },
21
+ },
22
+ ];
package/package.json CHANGED
@@ -1,12 +1,28 @@
1
1
  {
2
2
  "name": "@digipair/skill-process",
3
- "version": "0.89.0",
3
+ "version": "0.91.0-0",
4
+ "type": "module",
5
+ "main": "dist/libs/skill-process/index.cjs.js",
6
+ "module": "dist/libs/skill-process/index.esm.js",
7
+ "types": "dist/libs/skill-process/index.esm.d.ts",
8
+ "exports": {
9
+ "./package.json": "./libs/skill-process/package.json",
10
+ ".": {
11
+ "development": "./dist/libs/skill-process/src/index.ts",
12
+ "types": "./dist/libs/skill-process/index.esm.d.ts",
13
+ "import": "./dist/libs/skill-process/index.esm.js",
14
+ "default": "./dist/libs/skill-process/index.cjs.js"
15
+ }
16
+ },
4
17
  "keywords": [
5
18
  "digipair",
6
- "service",
7
- "util"
19
+ "util",
20
+ "service"
8
21
  ],
9
- "dependencies": {},
10
- "main": "./index.cjs.js",
11
- "module": "./index.esm.js"
12
- }
22
+ "nx": {
23
+ "name": "skill-process"
24
+ },
25
+ "dependencies": {
26
+ "@digipair/engine": "0.91.0-0"
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ const { withNx } = require('@nx/rollup/with-nx');
2
+
3
+ module.exports = withNx(
4
+ {
5
+ main: 'libs/skill-process/src/index.ts',
6
+ outputPath: 'dist/libs/skill-process',
7
+ tsConfig: 'libs/skill-process/tsconfig.lib.json',
8
+ compiler: 'swc',
9
+ format: ['esm', "cjs"],
10
+ assets: [
11
+ {
12
+ input: 'libs/skill-process/',
13
+ glob: 'package.json',
14
+ output: '.'
15
+ },
16
+ {
17
+ input: 'libs/skill-process/src/',
18
+ glob: '*.json',
19
+ output: '.'
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
25
+ // e.g.
26
+ // output: { sourcemap: true },
27
+ }
28
+ );
@@ -0,0 +1,7 @@
1
+ import { skillProcess } from './skill-process';
2
+
3
+ describe('skillProcess', () => {
4
+ it('should work', () => {
5
+ expect(skillProcess()).toEqual('skill-process');
6
+ });
7
+ });
@@ -0,0 +1,67 @@
1
+ import { PinsSettings } from '@digipair/engine';
2
+ import { Response } from 'express';
3
+ import { v4 } from 'uuid';
4
+
5
+ class ProcessService {
6
+ private processList: {
7
+ id: string;
8
+ time: number;
9
+ digipair: string;
10
+ reasoning: string;
11
+ abortController: AbortController;
12
+ res: Response;
13
+ }[] = [];
14
+
15
+ add(digipair: string, reasoning: string, res: Response) {
16
+ const id = v4();
17
+ const abortController = new AbortController();
18
+ const time = Date.now();
19
+
20
+ this.processList.push({ id, time, digipair, reasoning, abortController, res });
21
+
22
+ return { id, signal: abortController.signal };
23
+ }
24
+
25
+ remove(id: string) {
26
+ const process = this.processList.find(p => p.id === id);
27
+ process?.abortController.abort();
28
+ this.processList = this.processList.filter(p => p.id !== id);
29
+ }
30
+
31
+ async stop(params: any, _pinsSettingsList: PinsSettings[], _context: any) {
32
+ const { id } = params;
33
+ const process = this.processList.find(p => p.id === id);
34
+
35
+ if (!process) {
36
+ return false;
37
+ }
38
+
39
+ process.abortController.abort();
40
+ process.res?.status(503).send({ status: 'stopped' });
41
+ this.processList = this.processList.filter(p => p.id !== id);
42
+
43
+ return true;
44
+ }
45
+
46
+ async list(_params: any, _pinsSettingsList: PinsSettings[], _context: any) {
47
+ return this.processList.map(p => ({
48
+ id: p.id,
49
+ digipair: p.digipair,
50
+ reasoning: p.reasoning,
51
+ time: p.time,
52
+ }));
53
+ }
54
+ }
55
+
56
+ const instance = new ProcessService();
57
+
58
+ export const add = (digipair: string, reasoning: string, res: Response) =>
59
+ instance.add(digipair, reasoning, res);
60
+
61
+ export const remove = (id: string) => instance.remove(id);
62
+
63
+ export const stop = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
64
+ instance.stop(params, pinsSettingsList, context);
65
+
66
+ export const list = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
67
+ instance.list(params, pinsSettingsList, context);
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "../engine"
8
+ },
9
+ {
10
+ "path": "./tsconfig.lib.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "module": "esnext",
9
+ "moduleResolution": "node",
10
+ "forceConsistentCasingInFileNames": true,
11
+ "types": ["node"]
12
+ },
13
+ "include": ["src/**/*.ts"],
14
+ "references": [
15
+ {
16
+ "path": "../engine/tsconfig.lib.json"
17
+ }
18
+ ]
19
+ }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.cjs.js DELETED
@@ -1,122 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /**
6
- * Convert array of 16 byte values to UUID string format of the form:
7
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
8
- */ var byteToHex = [];
9
- for(var i = 0; i < 256; ++i){
10
- byteToHex.push((i + 0x100).toString(16).slice(1));
11
- }
12
- function unsafeStringify(arr) {
13
- var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
14
- // Note: Be careful editing this code! It's been tuned for performance
15
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
16
- //
17
- // Note to future-self: No, you can't remove the `toLowerCase()` call.
18
- // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
19
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
20
- }
21
-
22
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
23
- // require the crypto API and do not support built-in fallback to lower quality random number
24
- // generators (like Math.random()).
25
- var getRandomValues;
26
- var rnds8 = new Uint8Array(16);
27
- function rng() {
28
- // lazy load so that environments that need to polyfill have a chance to do so
29
- if (!getRandomValues) {
30
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
31
- getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
32
- if (!getRandomValues) {
33
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
34
- }
35
- }
36
- return getRandomValues(rnds8);
37
- }
38
-
39
- var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
40
- var native = {
41
- randomUUID: randomUUID
42
- };
43
-
44
- function v4(options, buf, offset) {
45
- if (native.randomUUID && !buf && !options) {
46
- return native.randomUUID();
47
- }
48
- options = options || {};
49
- var rnds = options.random || (options.rng || rng)();
50
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
51
- rnds[6] = rnds[6] & 0x0f | 0x40;
52
- rnds[8] = rnds[8] & 0x3f | 0x80;
53
- // Copy bytes to buffer, if provided
54
- if (buf) {
55
- offset = offset || 0;
56
- for(var i = 0; i < 16; ++i){
57
- buf[offset + i] = rnds[i];
58
- }
59
- return buf;
60
- }
61
- return unsafeStringify(rnds);
62
- }
63
-
64
- let ProcessService = class ProcessService {
65
- add(digipair, reasoning, res) {
66
- const id = v4();
67
- const abortController = new AbortController();
68
- const time = Date.now();
69
- this.processList.push({
70
- id,
71
- time,
72
- digipair,
73
- reasoning,
74
- abortController,
75
- res
76
- });
77
- return {
78
- id,
79
- signal: abortController.signal
80
- };
81
- }
82
- remove(id) {
83
- const process = this.processList.find((p)=>p.id === id);
84
- process == null ? void 0 : process.abortController.abort();
85
- this.processList = this.processList.filter((p)=>p.id !== id);
86
- }
87
- async stop(params, _pinsSettingsList, _context) {
88
- var _process_res;
89
- const { id } = params;
90
- const process = this.processList.find((p)=>p.id === id);
91
- if (!process) {
92
- return false;
93
- }
94
- process.abortController.abort();
95
- (_process_res = process.res) == null ? void 0 : _process_res.status(503).send({
96
- status: 'stopped'
97
- });
98
- this.processList = this.processList.filter((p)=>p.id !== id);
99
- return true;
100
- }
101
- async list(_params, _pinsSettingsList, _context) {
102
- return this.processList.map((p)=>({
103
- id: p.id,
104
- digipair: p.digipair,
105
- reasoning: p.reasoning,
106
- time: p.time
107
- }));
108
- }
109
- constructor(){
110
- this.processList = [];
111
- }
112
- };
113
- const instance = new ProcessService();
114
- const add = (digipair, reasoning, res)=>instance.add(digipair, reasoning, res);
115
- const remove = (id)=>instance.remove(id);
116
- const stop = (params, pinsSettingsList, context)=>instance.stop(params, pinsSettingsList, context);
117
- const list = (params, pinsSettingsList, context)=>instance.list(params, pinsSettingsList, context);
118
-
119
- exports.add = add;
120
- exports.list = list;
121
- exports.remove = remove;
122
- exports.stop = stop;
package/index.esm.js DELETED
@@ -1,115 +0,0 @@
1
- /**
2
- * Convert array of 16 byte values to UUID string format of the form:
3
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
4
- */ var byteToHex = [];
5
- for(var i = 0; i < 256; ++i){
6
- byteToHex.push((i + 0x100).toString(16).slice(1));
7
- }
8
- function unsafeStringify(arr) {
9
- var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
10
- // Note: Be careful editing this code! It's been tuned for performance
11
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
12
- //
13
- // Note to future-self: No, you can't remove the `toLowerCase()` call.
14
- // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
15
- return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
16
- }
17
-
18
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
19
- // require the crypto API and do not support built-in fallback to lower quality random number
20
- // generators (like Math.random()).
21
- var getRandomValues;
22
- var rnds8 = new Uint8Array(16);
23
- function rng() {
24
- // lazy load so that environments that need to polyfill have a chance to do so
25
- if (!getRandomValues) {
26
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
27
- getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
28
- if (!getRandomValues) {
29
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
30
- }
31
- }
32
- return getRandomValues(rnds8);
33
- }
34
-
35
- var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
36
- var native = {
37
- randomUUID: randomUUID
38
- };
39
-
40
- function v4(options, buf, offset) {
41
- if (native.randomUUID && !buf && !options) {
42
- return native.randomUUID();
43
- }
44
- options = options || {};
45
- var rnds = options.random || (options.rng || rng)();
46
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
47
- rnds[6] = rnds[6] & 0x0f | 0x40;
48
- rnds[8] = rnds[8] & 0x3f | 0x80;
49
- // Copy bytes to buffer, if provided
50
- if (buf) {
51
- offset = offset || 0;
52
- for(var i = 0; i < 16; ++i){
53
- buf[offset + i] = rnds[i];
54
- }
55
- return buf;
56
- }
57
- return unsafeStringify(rnds);
58
- }
59
-
60
- let ProcessService = class ProcessService {
61
- add(digipair, reasoning, res) {
62
- const id = v4();
63
- const abortController = new AbortController();
64
- const time = Date.now();
65
- this.processList.push({
66
- id,
67
- time,
68
- digipair,
69
- reasoning,
70
- abortController,
71
- res
72
- });
73
- return {
74
- id,
75
- signal: abortController.signal
76
- };
77
- }
78
- remove(id) {
79
- const process = this.processList.find((p)=>p.id === id);
80
- process == null ? void 0 : process.abortController.abort();
81
- this.processList = this.processList.filter((p)=>p.id !== id);
82
- }
83
- async stop(params, _pinsSettingsList, _context) {
84
- var _process_res;
85
- const { id } = params;
86
- const process = this.processList.find((p)=>p.id === id);
87
- if (!process) {
88
- return false;
89
- }
90
- process.abortController.abort();
91
- (_process_res = process.res) == null ? void 0 : _process_res.status(503).send({
92
- status: 'stopped'
93
- });
94
- this.processList = this.processList.filter((p)=>p.id !== id);
95
- return true;
96
- }
97
- async list(_params, _pinsSettingsList, _context) {
98
- return this.processList.map((p)=>({
99
- id: p.id,
100
- digipair: p.digipair,
101
- reasoning: p.reasoning,
102
- time: p.time
103
- }));
104
- }
105
- constructor(){
106
- this.processList = [];
107
- }
108
- };
109
- const instance = new ProcessService();
110
- const add = (digipair, reasoning, res)=>instance.add(digipair, reasoning, res);
111
- const remove = (id)=>instance.remove(id);
112
- const stop = (params, pinsSettingsList, context)=>instance.stop(params, pinsSettingsList, context);
113
- const list = (params, pinsSettingsList, context)=>instance.list(params, pinsSettingsList, context);
114
-
115
- export { add, list, remove, stop };
@@ -1,14 +0,0 @@
1
- import { PinsSettings } from '@digipair/engine';
2
- import { Response } from 'express';
3
- export declare const add: (digipair: string, reasoning: string, res: Response) => {
4
- id: string;
5
- signal: AbortSignal;
6
- };
7
- export declare const remove: (id: string) => void;
8
- export declare const stop: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<boolean>;
9
- export declare const list: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<{
10
- id: string;
11
- digipair: string;
12
- reasoning: string;
13
- time: number;
14
- }[]>;
File without changes
File without changes
File without changes