@ztimson/momentum 0.53.2 → 1.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/README.md +96 -41
- package/bin/build-models.mjs +28 -37
- package/dist/actions.d.ts +67 -52
- package/dist/actions.d.ts.map +1 -1
- package/dist/ai.d.ts +43 -17
- package/dist/ai.d.ts.map +1 -1
- package/dist/analytics.d.ts +169 -36
- package/dist/analytics.d.ts.map +1 -1
- package/dist/api.d.ts +22 -22
- package/dist/api.d.ts.map +1 -1
- package/dist/asset-controller.d.ts +92 -0
- package/dist/asset-controller.d.ts.map +1 -0
- package/dist/audit.d.ts +22 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/auth.d.ts +34 -101
- package/dist/auth.d.ts.map +1 -1
- package/dist/call.d.ts +61 -0
- package/dist/call.d.ts.map +1 -0
- package/dist/captcha.d.ts +14 -0
- package/dist/captcha.d.ts.map +1 -0
- package/dist/client.d.ts +46 -33
- package/dist/client.d.ts.map +1 -1
- package/dist/core.d.ts +50 -21
- package/dist/core.d.ts.map +1 -1
- package/dist/data.d.ts +58 -76
- package/dist/data.d.ts.map +1 -1
- package/dist/dialog.d.ts +11 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/discounts.d.ts +8 -12
- package/dist/discounts.d.ts.map +1 -1
- package/dist/email.d.ts +19 -19
- package/dist/email.d.ts.map +1 -1
- package/dist/forms.d.ts +6 -13
- package/dist/forms.d.ts.map +1 -1
- package/dist/groups.d.ts +22 -16
- package/dist/groups.d.ts.map +1 -1
- package/dist/index.d.ts +14 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4473 -0
- package/dist/index.mjs +3469 -1752
- package/dist/logger.d.ts +78 -48
- package/dist/logger.d.ts.map +1 -1
- package/dist/momentum.d.ts +71 -15
- package/dist/momentum.d.ts.map +1 -1
- package/dist/momentum.worker.d.mts +2 -0
- package/dist/momentum.worker.d.mts.map +1 -0
- package/dist/momentum.worker.mjs +124 -0
- package/dist/notifications.d.ts +39 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/pdf.d.ts +32 -14
- package/dist/pdf.d.ts.map +1 -1
- package/dist/permissions.d.ts +19 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/products.d.ts +47 -0
- package/dist/products.d.ts.map +1 -0
- package/dist/routes.d.ts +40 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/schemas.d.ts +79 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/settings.d.ts +30 -14
- package/dist/settings.d.ts.map +1 -1
- package/dist/sms.d.ts +14 -0
- package/dist/sms.d.ts.map +1 -0
- package/dist/sockets.d.ts +22 -12
- package/dist/sockets.d.ts.map +1 -1
- package/dist/static.d.ts +4 -2
- package/dist/static.d.ts.map +1 -1
- package/dist/storage.d.ts +103 -24
- package/dist/storage.d.ts.map +1 -1
- package/dist/templates.d.ts +23 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/totp.d.ts +45 -0
- package/dist/totp.d.ts.map +1 -0
- package/dist/transactions.d.ts +153 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/users.d.ts +63 -25
- package/dist/users.d.ts.map +1 -1
- package/dist/webRtc.d.ts +39 -0
- package/dist/webRtc.d.ts.map +1 -0
- package/package.json +23 -13
- package/dist/index.cjs +0 -2756
- package/dist/momentum.worker.js +0 -16
- package/dist/payments.d.ts +0 -184
- package/dist/payments.d.ts.map +0 -1
- package/dist/phone.d.ts +0 -19
- package/dist/phone.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<br />
|
|
4
4
|
|
|
5
5
|
<!-- Logo -->
|
|
6
|
-
<img src="
|
|
6
|
+
<img src="https://momentum.zakscode.com/favicon.png" alt="Logo" width="200" height="200">
|
|
7
7
|
|
|
8
8
|
<!-- Title -->
|
|
9
9
|
### Momentum
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
Enterprise Record Management
|
|
13
13
|
|
|
14
14
|
<!-- Repo badges -->
|
|
15
|
-
[](https://git.zakscode.com/momentum/momentum/tags)
|
|
16
|
+
[](https://git.zakscode.com/momentum/momentum/pulls)
|
|
17
|
+
[](https://git.zakscode.com/momentum/momentum/issues)
|
|
18
18
|
|
|
19
19
|
<!-- Links -->
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
<div>
|
|
23
|
-
<a href="https://git.zakscode.com/
|
|
24
|
-
• <a href="https://git.zakscode.com/
|
|
25
|
-
• <a href="https://git.zakscode.com/
|
|
26
|
-
• <a href="https://git.zakscode.com/
|
|
23
|
+
<a href="https://git.zakscode.com/momentum/momentum/wiki" target="_blank">Documentation</a>
|
|
24
|
+
• <a href="https://git.zakscode.com/momentum/momentum/releases" target="_blank">Release Notes</a>
|
|
25
|
+
• <a href="https://git.zakscode.com/momentum/momentum/issues/new?template=.github%2fissue_template%2fbug.md" target="_blank">Report a Bug</a>
|
|
26
|
+
• <a href="https://git.zakscode.com/momentum/momentum/issues/new?template=.github%2fissue_template%2fenhancement.md" target="_blank">Request a Feature</a>
|
|
27
27
|
</div>
|
|
28
28
|
|
|
29
29
|
---
|
|
@@ -40,61 +40,112 @@
|
|
|
40
40
|
|
|
41
41
|
## About
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
https://momentum.zakscode.com
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Momentum is a self-hosted _Enterprise Resource Planning_ (ERP) tool with a _content managment system_ (CMS). What does that mean? We can automate your businesses day-to-day operations and give you a pretty interface to control it by storing & coordinating your data & information; from any location or server.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
While several businesses might deliver the same final product as your business, what sets you apart is your institutional knowledge and unique execution. However, most of this is
|
|
48
|
+
lost when businesses are forced to conform to software and not the other way around. This is where Momentum is different.
|
|
49
|
+
|
|
50
|
+
Momentum delivers several feature-packed modules to cover every software need and an intuitive _Content Management System_ (CMS) to connect features as needed.
|
|
51
|
+
And with the built-in AI or a programmer you can build & integrate custom apps and websites in seconds.
|
|
52
|
+
|
|
53
|
+
Here at ZaksCode we believe the current standard software is held to is pitiful. We aim to keep your business by being the best, not vendor lock-in practices.
|
|
54
|
+
Not only do we offer the most features and the best experience, but we do so while being the smallest, fastest, most efficient & secure ERP system out there.
|
|
48
55
|
|
|
49
56
|
Features include:
|
|
50
57
|
- Actions
|
|
51
|
-
- Write server side code to create custom functionality
|
|
58
|
+
- Write server side code to "mod" Momentum & create custom functionality
|
|
52
59
|
- Writen with javascript & the momentum client library to minimize the learning curve
|
|
53
60
|
- Custom library and can be installed & accessed from actions using Docker & NPM
|
|
54
|
-
- Trigger actions
|
|
55
|
-
-
|
|
61
|
+
- Trigger actions via events, CRONs or REST requests
|
|
62
|
+
- Kept in memory for high performance and 0 cold start time
|
|
63
|
+
- AI
|
|
64
|
+
- Ask the assistant questions about your records
|
|
65
|
+
- Automate your workflow and use AI to process data & files automatically
|
|
66
|
+
- Use the AI to build actions, apps & websites with momentum integration
|
|
67
|
+
- Local / Offline ASR & OCR models to extract text from most file types (text, image, pdf, audio, video)
|
|
68
|
+
- Local or remote LLM models
|
|
69
|
+
- Analytics
|
|
70
|
+
- Track device specs & performance
|
|
71
|
+
- Track IP addresses and trace on demand (not stored)
|
|
72
|
+
- Track a user journey (which pages are visited for how long)
|
|
73
|
+
- Track referrers & ad campaigns
|
|
74
|
+
- Track conversion rates & custom metrics tracking
|
|
75
|
+
- UI for viewing all data & running custom reports
|
|
56
76
|
- Authentication
|
|
57
77
|
- Manage users with custom values
|
|
58
78
|
- Manage groups with cascading permissions & custom values
|
|
59
79
|
- Token management for 3rd party applications
|
|
60
|
-
- Full permission system
|
|
80
|
+
- Full permission system with custom permissions support
|
|
61
81
|
- Account validation & reset emails
|
|
62
82
|
- Optional public registration form
|
|
63
|
-
- OAuth
|
|
64
|
-
- Custom password strength
|
|
83
|
+
- Host OAuth portal for custom application login
|
|
84
|
+
- Custom password strength & rotation settings
|
|
65
85
|
- Two-Factor Authentication
|
|
86
|
+
- OAuth & LDAP support
|
|
66
87
|
- Data
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
88
|
+
- Advanced search
|
|
89
|
+
- Edit database like an Excel spreadsheet
|
|
90
|
+
- Conditional styling
|
|
91
|
+
- Calculate columns with excel formulas or javascript
|
|
92
|
+
- Granular collection & record level permissions
|
|
93
|
+
- Automatic metadata & history tracking
|
|
72
94
|
- Easy import/export to CSV, Excel & JSON
|
|
95
|
+
- Forms
|
|
96
|
+
- Create forms that integrate with database
|
|
97
|
+
- Create custom reports with graphs, maps & more
|
|
98
|
+
- Granular permissions
|
|
73
99
|
- Logs
|
|
74
|
-
- Save & view server logs
|
|
75
|
-
- Submit
|
|
76
|
-
-
|
|
100
|
+
- Save & view server logs for easy debugging
|
|
101
|
+
- Submit logs to track remote environments
|
|
102
|
+
- Capture remote device specs for debugging
|
|
103
|
+
- Unlimited remote logging channels
|
|
104
|
+
- Local logs for debugging mobile devices
|
|
105
|
+
- All changes are recorded and can be reverted
|
|
106
|
+
- Messaging
|
|
107
|
+
- Send emails with SMTP
|
|
108
|
+
- Send notifications to apps
|
|
109
|
+
- Phone call & SMS integration with Twilio
|
|
110
|
+
- Supports WebRTC with built-in STUN/TURN server for video/voice calls
|
|
111
|
+
- Payments
|
|
112
|
+
- Stripe support to handle payments & subscriptions
|
|
113
|
+
- Manage products through spreadsheets
|
|
114
|
+
- Easy form & report integration
|
|
115
|
+
- Create custom discount codes
|
|
116
|
+
- Automatic taxes
|
|
77
117
|
- Storage
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
- Full file permissions
|
|
118
|
+
- Store files
|
|
119
|
+
- Share files with any user/group
|
|
120
|
+
- Built-in filebrowser with drag & drop
|
|
82
121
|
- Automatic metadata tracking
|
|
122
|
+
- Full file/folder permissions
|
|
83
123
|
- Static File Server
|
|
84
|
-
- Host your
|
|
124
|
+
- Host your web applications with the API
|
|
125
|
+
- Built-in filebrowser with drag & drop
|
|
126
|
+
- Automatic metadata tracking
|
|
85
127
|
- Configurable routing
|
|
86
128
|
- Settings
|
|
87
129
|
- Full theming & white label support
|
|
88
130
|
- Manage the server through variables which can be changed at runtime
|
|
89
131
|
- Create & use custom variables for your application
|
|
90
132
|
- Miscellaneous
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
- Generate PDFs from templates,
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
133
|
+
- CCPA / GDPR / PIPEDA compliant
|
|
134
|
+
- Configurable Terms of Service & Privacy Policy
|
|
135
|
+
- Automatic notifications/SMS/call/email alerts
|
|
136
|
+
- Generate PDFs from templates, forms, pages or HTML
|
|
137
|
+
- Turn any website into an offline mobile/desktop app
|
|
138
|
+
- Caching & offline support built in
|
|
139
|
+
- Live collaborative editing
|
|
140
|
+
- All features support REST for easy integration with websites & apps
|
|
141
|
+
- Writen documentation & OpenApi docs
|
|
142
|
+
- Extremely light weight & small
|
|
143
|
+
- Configurable endpoint protection with rate limiting & CAPTCHA bot detection
|
|
144
|
+
- Handles thousands of requests per second per instance while losing < 1GB of RAM
|
|
145
|
+
- Prometheus metrics
|
|
146
|
+
|
|
147
|
+
Demo Sites:
|
|
148
|
+
- https://law.momentum.zakscode.com
|
|
98
149
|
|
|
99
150
|
### Built With
|
|
100
151
|
[](https://docker.com/)
|
|
@@ -113,9 +164,9 @@ Features include:
|
|
|
113
164
|
- [Docker](https://docs.docker.com/install/)
|
|
114
165
|
|
|
115
166
|
#### Instructions
|
|
116
|
-
1. _Optional: Use momentum to host your [static site](https://git.zakscode.com/
|
|
117
|
-
2. Download the [docker-compose](https://git.zakscode.com/
|
|
118
|
-
3. Configure the [Environment Variables](https://git.zakscode.com/
|
|
167
|
+
1. _Optional: Use momentum to host your [static site](https://git.zakscode.com/momentum/momentum/wiki/Static)_
|
|
168
|
+
2. Download the [docker-compose](https://git.zakscode.com/momentum/momentum/src/branch/develop/docker-compose.yml) file: `curl -o momentum.yaml https://git.zakscode.com/momentum/momentum/raw/branch/develop/docker-compose.yml`
|
|
169
|
+
3. Configure the [Environment Variables](https://git.zakscode.com/momentum/momentum/wiki/Environment-Variables) inside the docker-compose
|
|
119
170
|
4. Start the server with: `docker-compose up -f momentum.yaml`
|
|
120
171
|
5. Open http://localhost:80
|
|
121
172
|
- Default login: `admin/admin`
|
|
@@ -132,13 +183,17 @@ Features include:
|
|
|
132
183
|
- [Docker](https://docs.docker.com/install/)
|
|
133
184
|
- [Node.js](https://nodejs.org/en/download)
|
|
134
185
|
|
|
186
|
+
##### Optional
|
|
187
|
+
- _[ffmpeg](https://ffmpeg.org/download.html) (Video utilities)_
|
|
188
|
+
- _[Whisper](https://github.com/ggml-org/whisper.cpp/releases/tag/v1.7.6) (Audio -> Text)_
|
|
189
|
+
|
|
135
190
|
#### Instructions
|
|
136
191
|
1. Install the dependencies: `npm install`
|
|
137
192
|
2. Start MongoDB: `docker-compose up db`
|
|
138
193
|
3. Start the dev server: `npm run start`
|
|
139
194
|
4. Open http://localhost:3000
|
|
140
195
|
- Default login: `admin/admin`
|
|
141
|
-
- Configure [System Variables](https://git.zakscode.com/
|
|
196
|
+
- Configure [System Variables](https://git.zakscode.com/momentum/momentum/wiki/System-Variables)
|
|
142
197
|
|
|
143
198
|
</details>
|
|
144
199
|
|
package/bin/build-models.mjs
CHANGED
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import {join} from 'path';
|
|
5
5
|
import {Momentum} from '../dist/index.mjs';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import {formatDate, kebabCase, pascalCase} from '@ztimson/utils';
|
|
7
|
+
import readline from 'readline';
|
|
8
|
+
import packageFile from '../package.json' with {type: 'json'};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
const rl = readline.createInterface({
|
|
10
|
+
function ask(prompt, hide = false) {
|
|
11
|
+
const rl = readline.createInterface({input: process.stdin, output: process.stdout, terminal: true});
|
|
11
12
|
return new Promise((resolve) => {
|
|
12
13
|
if (!hide) {
|
|
13
|
-
rl.question(prompt, (answer) =>
|
|
14
|
+
rl.question(prompt, (answer) => {
|
|
15
|
+
resolve(answer);
|
|
16
|
+
rl.close();
|
|
17
|
+
});
|
|
14
18
|
} else {
|
|
15
19
|
let input = '';
|
|
16
20
|
const onKeyPress = (char, key) => {
|
|
@@ -38,70 +42,57 @@ export function ask(prompt, hide = false) {
|
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
function createProp(column) {
|
|
42
|
-
let prop = column.prop;
|
|
43
|
-
if(column.type == 'formula' || column.type == 'javascript') prop = `readonly ${prop}`;
|
|
44
|
-
prop += column.required ? ': ' : '?: ';
|
|
45
|
-
if(column.type == 'formula' || column.type == 'javascript') prop += 'any';
|
|
46
|
-
else if(column.type == 'link') prop += 'string';
|
|
47
|
-
else if(column.type == 'timestamp') prop += 'Date';
|
|
48
|
-
else prop += `${column.type}`;
|
|
49
|
-
return prop;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
45
|
// Main loop
|
|
53
46
|
(async () => {
|
|
54
47
|
try {
|
|
55
48
|
// Arguments
|
|
56
|
-
let [
|
|
57
|
-
const packageFile = await import('../package.json', {with: { type: 'json' }});
|
|
49
|
+
let [, , destination, url, username, password] = process.argv;
|
|
58
50
|
console.log(`Momentum v${packageFile.default.version}`);
|
|
59
51
|
let momentum;
|
|
60
52
|
|
|
61
53
|
// Login
|
|
62
54
|
do {
|
|
63
|
-
while(!url) url = await ask('URL: ');
|
|
64
|
-
while(!username) username = await ask('Username: ');
|
|
65
|
-
while(!password) password = await ask('Password: ', true);
|
|
55
|
+
while (!url) url = await ask('URL: ');
|
|
56
|
+
while (!username) username = await ask('Username: ');
|
|
57
|
+
while (!password) password = await ask('Password: ', true);
|
|
66
58
|
|
|
67
|
-
if(!url.startsWith('http')) url = 'http://' + url;
|
|
59
|
+
if (!url.startsWith('http')) url = 'http://' + url;
|
|
68
60
|
momentum = new Momentum(url);
|
|
69
61
|
await momentum.auth.login(username, password)
|
|
70
62
|
.catch(err => {
|
|
71
63
|
url = username = password = '';
|
|
72
64
|
console.log('Failed to authenticate');
|
|
73
65
|
});
|
|
74
|
-
} while(!momentum?.auth.user);
|
|
66
|
+
} while (!momentum?.auth.user);
|
|
75
67
|
console.log('Login Succeeded!\n');
|
|
76
68
|
|
|
77
|
-
if(!destination) destination = await ask('Destination (src/models): ');
|
|
78
|
-
if(!destination) destination = 'src/models';
|
|
69
|
+
if (!destination) destination = await ask('Destination (src/models): ');
|
|
70
|
+
if (!destination) destination = 'src/models';
|
|
79
71
|
let path = join(process.cwd(), destination);
|
|
80
|
-
if(!fs.existsSync(path)) fs.mkdirSync(path);
|
|
72
|
+
if (!fs.existsSync(path)) fs.mkdirSync(path);
|
|
81
73
|
|
|
82
74
|
console.log('\nCollecting Schemas...');
|
|
83
|
-
const schemas = await momentum.
|
|
75
|
+
const schemas = await momentum.schemas.read();
|
|
84
76
|
schemas.forEach(schema => {
|
|
85
|
-
const fileName =
|
|
77
|
+
const fileName = kebabCase(schema.path) + '.ts';
|
|
86
78
|
console.log(`Creating Model: ${schema.path} -> ${fileName}`);
|
|
87
79
|
const path = join(process.cwd(), destination, fileName);
|
|
88
|
-
fs.writeFileSync(path, `import {Meta} from '@ztimson/momentum';
|
|
80
|
+
fs.writeFileSync(path, `import {Formula, Link, Meta} from '@ztimson/momentum';
|
|
89
81
|
|
|
90
82
|
/**
|
|
91
|
-
* ${
|
|
92
|
-
*
|
|
93
|
-
* ${schema.
|
|
94
|
-
*
|
|
95
|
-
* Generated by Momentum v${packageFile.default.version} - ${formatDate('YYYY-MM-DD')}
|
|
83
|
+
* Generated by Momentum v${packageFile.default.version}
|
|
84
|
+
* Date: ${formatDate('YYYY-MM-DD')}
|
|
85
|
+
* Schema: ${schema.path}
|
|
86
|
+
* Description: ${schema.description}
|
|
96
87
|
*/
|
|
97
|
-
export interface ${
|
|
98
|
-
${schema.columns.map(column => `\t${
|
|
88
|
+
export interface ${pascalCase(schema.path)} extends Meta${schema.columns.length ? '' : ', Record<string, any>'} {
|
|
89
|
+
${schema.columns.map(column => `\t${column.readonly ? 'readonly ' : ''}${column.prop}${column.required ? ':' : '?:'} ${column.type};`).join('\n')}
|
|
99
90
|
}
|
|
100
91
|
`);
|
|
101
92
|
});
|
|
102
93
|
console.log('Done!');
|
|
103
94
|
process.exit();
|
|
104
|
-
} catch(err) {
|
|
95
|
+
} catch (err) {
|
|
105
96
|
console.error(`\n${err.stack || err.stackTrace || err.message || err.toString()}`);
|
|
106
97
|
process.exit(1);
|
|
107
98
|
}
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,63 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HttpRequestOptions } from '@ztimson/utils';
|
|
2
|
+
import { AssetController } from './asset-controller';
|
|
3
3
|
import { Meta } from './core';
|
|
4
|
+
import { Momentum } from './momentum';
|
|
5
|
+
export type ToolArgs = {
|
|
6
|
+
[key: string]: {
|
|
7
|
+
/** Argument type */
|
|
8
|
+
type: 'array' | 'boolean' | 'number' | 'object' | 'string';
|
|
9
|
+
/** Argument description */
|
|
10
|
+
description: string;
|
|
11
|
+
/** Required argument */
|
|
12
|
+
required?: boolean;
|
|
13
|
+
/** Default value */
|
|
14
|
+
default?: any;
|
|
15
|
+
/** Options */
|
|
16
|
+
enum?: string[];
|
|
17
|
+
/** Minimum value or length */
|
|
18
|
+
min?: number;
|
|
19
|
+
/** Maximum value or length */
|
|
20
|
+
max?: number;
|
|
21
|
+
/** Match pattern */
|
|
22
|
+
pattern?: string;
|
|
23
|
+
/** Child arguments */
|
|
24
|
+
items?: {
|
|
25
|
+
[key: string]: ToolArgs;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
4
29
|
/** Action model */
|
|
5
30
|
export type Action = Meta & {
|
|
6
31
|
/** Action name */
|
|
7
32
|
name: string;
|
|
8
|
-
/**
|
|
33
|
+
/** Disable action */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** Trigger with AI call, CRON, CRUD or Event */
|
|
9
36
|
trigger: {
|
|
10
37
|
type: ActionType;
|
|
11
|
-
value: string;
|
|
38
|
+
value: string | ToolArgs;
|
|
12
39
|
};
|
|
13
40
|
/** Run as system or with triggering user permissions */
|
|
14
|
-
system?: boolean;
|
|
41
|
+
system?: boolean | null;
|
|
15
42
|
/** Action code */
|
|
16
43
|
fn: string;
|
|
17
44
|
/** User nodes */
|
|
18
|
-
notes?: string;
|
|
45
|
+
notes?: string | null;
|
|
19
46
|
/** Last execution timestamp */
|
|
20
|
-
lastRun?: Date;
|
|
47
|
+
readonly lastRun?: null | Date;
|
|
21
48
|
/** Last execution duration */
|
|
22
|
-
|
|
49
|
+
readonly lastRunDuration?: number | null;
|
|
23
50
|
/** Next scheduled run time (CRON only) */
|
|
24
|
-
nextRun?: Date;
|
|
51
|
+
readonly nextRun?: null | Date;
|
|
25
52
|
/** Last execution results */
|
|
26
|
-
response?: ActionResult;
|
|
53
|
+
readonly response?: ActionResult | null;
|
|
27
54
|
};
|
|
28
55
|
/** Action execution result */
|
|
29
56
|
export type ActionResult = {
|
|
30
57
|
/** ID of associated action */
|
|
31
|
-
action: string;
|
|
58
|
+
readonly action: string;
|
|
59
|
+
/** Runtime */
|
|
60
|
+
readonly duration: number;
|
|
61
|
+
/** Start timestamp */
|
|
62
|
+
readonly start: Date;
|
|
32
63
|
/** Console output */
|
|
33
|
-
stdout: any[];
|
|
64
|
+
readonly stdout: any[];
|
|
34
65
|
/** Console errors */
|
|
35
|
-
stderr: any[];
|
|
66
|
+
readonly stderr: any[];
|
|
36
67
|
/** HTTP Response */
|
|
37
|
-
response?: any;
|
|
68
|
+
readonly response?: any;
|
|
38
69
|
/** Action return value */
|
|
39
|
-
return?: any;
|
|
70
|
+
readonly return?: any;
|
|
40
71
|
};
|
|
72
|
+
/** Action triggers - Ordered to optimize filtering */
|
|
41
73
|
export declare enum ActionType {
|
|
42
|
-
|
|
43
|
-
'
|
|
44
|
-
|
|
45
|
-
'
|
|
46
|
-
|
|
47
|
-
'
|
|
48
|
-
|
|
74
|
+
/** HTTP DELETE request */
|
|
75
|
+
'DELETE' = 0,
|
|
76
|
+
/** HTTP POST request */
|
|
77
|
+
'POST' = 1,
|
|
78
|
+
/** HTTP PATCH request */
|
|
79
|
+
'PATCH' = 2,
|
|
80
|
+
/** HTTP PUT request */
|
|
81
|
+
'PUT' = 3,
|
|
82
|
+
/** HTTP GET request */
|
|
83
|
+
'GET' = 4,
|
|
84
|
+
/** Internal Event */
|
|
85
|
+
'EVENT' = 6,
|
|
86
|
+
/** CRON Job */
|
|
87
|
+
'CRON' = 5,
|
|
88
|
+
/** AI tool call */
|
|
89
|
+
'AI' = 7
|
|
49
90
|
}
|
|
50
|
-
/**
|
|
51
|
-
export declare class Actions extends
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
constructor(api: Api | string);
|
|
55
|
-
/**
|
|
56
|
-
* All saved actions
|
|
57
|
-
* @param {boolean} reload Will use cached response if false
|
|
58
|
-
* @return {Promise<Action[]>} List of saved actions
|
|
59
|
-
*/
|
|
60
|
-
all(reload?: boolean): Promise<Action[]>;
|
|
91
|
+
/** Run cloud functions & custom code */
|
|
92
|
+
export declare class Actions extends AssetController<Action> {
|
|
93
|
+
protected momentum: Momentum;
|
|
94
|
+
constructor(momentum: Momentum);
|
|
61
95
|
/**
|
|
62
96
|
* Manually trigger an actions execution
|
|
63
97
|
* @param {string} id Action ID
|
|
@@ -65,19 +99,6 @@ export declare class Actions extends PathEventEmitter {
|
|
|
65
99
|
* @return {Promise<ActionResult>} All action output including console logs & return
|
|
66
100
|
*/
|
|
67
101
|
debug(id: string, opts?: HttpRequestOptions): Promise<ActionResult>;
|
|
68
|
-
/**
|
|
69
|
-
* Delete an existing action
|
|
70
|
-
* @param {string} id Action ID
|
|
71
|
-
* @return {Promise<void>} Delete complete
|
|
72
|
-
*/
|
|
73
|
-
delete(id: string): Promise<void>;
|
|
74
|
-
/**
|
|
75
|
-
* Fetch action info
|
|
76
|
-
* @param {string} id Action ID
|
|
77
|
-
* @param {boolean} reload Will use cached response if false
|
|
78
|
-
* @return {Promise<Action | null>} Requested action
|
|
79
|
-
*/
|
|
80
|
-
read(id: string, reload?: boolean): Promise<Action | null>;
|
|
81
102
|
/**
|
|
82
103
|
* Run an HTTP action
|
|
83
104
|
* @param {string} path HTTP path excluding `/api/actions/run`
|
|
@@ -85,11 +106,5 @@ export declare class Actions extends PathEventEmitter {
|
|
|
85
106
|
* @return {Promise<T>} HTTP response
|
|
86
107
|
*/
|
|
87
108
|
run<T>(path: string, opts?: HttpRequestOptions): Promise<T>;
|
|
88
|
-
/**
|
|
89
|
-
* Update an action
|
|
90
|
-
* @param {Action} action The new action
|
|
91
|
-
* @return {Promise<Action>} Saved action
|
|
92
|
-
*/
|
|
93
|
-
update(action: Action): Promise<Action>;
|
|
94
109
|
}
|
|
95
110
|
//# sourceMappingURL=actions.d.ts.map
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,MAAM,MAAM,QAAQ,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG;QACtC,oBAAoB;QACpB,IAAI,EAAE,OAAO,GAAG,SAAS,G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 -1,36 +1,62 @@
|
|
|
1
|
-
import { PathEventEmitter } from '
|
|
2
|
-
import {
|
|
1
|
+
import { PathEventEmitter } from './core';
|
|
2
|
+
import { Momentum } from './momentum';
|
|
3
|
+
export type AiInfo = {
|
|
4
|
+
/** Service provider: Anthropic, OpenAI, Ollama */
|
|
5
|
+
readonly host: string;
|
|
6
|
+
/** Assistant LLM version */
|
|
7
|
+
readonly model: string;
|
|
8
|
+
/** Available tools */
|
|
9
|
+
readonly tools: {
|
|
10
|
+
[name: string]: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type AiMessage = {
|
|
14
|
+
/** Message type */
|
|
15
|
+
readonly role: 'assistant' | 'function' | 'system' | 'tool' | 'user';
|
|
16
|
+
/** OpenAI tool call */
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
/** Anthropic tool call */
|
|
19
|
+
readonly tool_use_id?: string;
|
|
20
|
+
/** Ollama tool call */
|
|
21
|
+
readonly tool_call_id?: string;
|
|
22
|
+
/** Message value */
|
|
23
|
+
readonly content: string;
|
|
24
|
+
};
|
|
3
25
|
/** AI integrations */
|
|
4
26
|
export declare class Ai extends PathEventEmitter {
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
27
|
+
protected momentum: Momentum;
|
|
28
|
+
constructor(momentum: Momentum);
|
|
29
|
+
/** Cancel current AI requests */
|
|
30
|
+
abort(): Promise<void>;
|
|
7
31
|
/**
|
|
8
32
|
* Ask the AI assistant a question
|
|
9
33
|
* @param {string} question Users question
|
|
10
|
-
* @param {
|
|
34
|
+
* @param {context: string, stream: Function} options context - Any hidden context information. stream - Receive response in chunks
|
|
11
35
|
* @return {Promise<string>} AI's response
|
|
12
36
|
*/
|
|
13
|
-
ask(question: string,
|
|
37
|
+
ask(question: string, options?: {
|
|
38
|
+
context?: any;
|
|
39
|
+
files?: File[];
|
|
40
|
+
stream?: (chunk: {
|
|
41
|
+
text?: string;
|
|
42
|
+
done?: boolean;
|
|
43
|
+
tool?: string;
|
|
44
|
+
}) => any;
|
|
45
|
+
}): Promise<string>;
|
|
14
46
|
/**
|
|
15
47
|
* Clear AI assistant memory & context
|
|
16
48
|
* @return {Promise<void>} Resolves once complete
|
|
17
49
|
*/
|
|
18
|
-
clear():
|
|
50
|
+
clear(): Promise<void>;
|
|
19
51
|
/**
|
|
20
52
|
* Current chat history
|
|
21
|
-
* @return {Promise<
|
|
53
|
+
* @return {Promise<AiMessage[]>}
|
|
22
54
|
*/
|
|
23
|
-
history(): Promise<
|
|
24
|
-
role: string;
|
|
25
|
-
content: string;
|
|
26
|
-
}[]>;
|
|
55
|
+
history(): Promise<AiMessage[]>;
|
|
27
56
|
/**
|
|
28
57
|
* Get model info
|
|
29
|
-
* @return {
|
|
58
|
+
* @return {AiInfo>} Model Info
|
|
30
59
|
*/
|
|
31
|
-
info(): Promise<
|
|
32
|
-
host: string;
|
|
33
|
-
model: string;
|
|
34
|
-
}>;
|
|
60
|
+
info(): Promise<AiInfo>;
|
|
35
61
|
}
|
|
36
62
|
//# sourceMappingURL=ai.d.ts.map
|
package/dist/ai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,MAAM,MAAM,MAAM,GAAG;IACpB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,QAAQ,CAAC,KAAK,EAAE;QAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;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