@ztimson/momentum 0.53.1 → 0.58.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 +200 -148
- package/bin/build-models.mjs +28 -37
- package/dist/actions.d.ts +32 -43
- package/dist/actions.d.ts.map +1 -1
- package/dist/ai.d.ts +38 -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 +39 -92
- package/dist/auth.d.ts.map +1 -1
- package/dist/call.d.ts +39 -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 +44 -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 +59 -77
- 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 +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4446 -0
- package/dist/index.mjs +3422 -1731
- package/dist/logger.d.ts +78 -48
- package/dist/logger.d.ts.map +1 -1
- package/dist/momentum.d.ts +69 -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 +103 -0
- package/dist/notifications.d.ts +39 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/pdf.d.ts +31 -14
- package/dist/pdf.d.ts.map +1 -1
- 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 +21 -10
- 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 +53 -43
- package/dist/index.cjs +0 -2755
- 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
|
@@ -1,148 +1,200 @@
|
|
|
1
|
-
<!-- Header -->
|
|
2
|
-
<div id="top" align="center">
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<!-- Logo -->
|
|
6
|
-
<img src="
|
|
7
|
-
|
|
8
|
-
<!-- Title -->
|
|
9
|
-
### Momentum
|
|
10
|
-
|
|
11
|
-
<!-- Description -->
|
|
12
|
-
Enterprise Record Management
|
|
13
|
-
|
|
14
|
-
<!-- Repo badges -->
|
|
15
|
-
[
|
|
34
|
-
- [About](#about)
|
|
35
|
-
- [Built With](#built-with)
|
|
36
|
-
- [Setup](#setup)
|
|
37
|
-
- [Production](#production)
|
|
38
|
-
- [Development](#development)
|
|
39
|
-
- [License](#license)
|
|
40
|
-
|
|
41
|
-
## About
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
1
|
+
<!-- Header -->
|
|
2
|
+
<div id="top" align="center">
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<!-- Logo -->
|
|
6
|
+
<img src="https://momentum.zakscode.com/favicon.png" alt="Logo" width="200" height="200">
|
|
7
|
+
|
|
8
|
+
<!-- Title -->
|
|
9
|
+
### Momentum
|
|
10
|
+
|
|
11
|
+
<!-- Description -->
|
|
12
|
+
Enterprise Record Management
|
|
13
|
+
|
|
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
|
+
|
|
19
|
+
<!-- Links -->
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
<div>
|
|
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
|
+
</div>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
## Table of Contents
|
|
33
|
+
- [Momentum](#top)
|
|
34
|
+
- [About](#about)
|
|
35
|
+
- [Built With](#built-with)
|
|
36
|
+
- [Setup](#setup)
|
|
37
|
+
- [Production](#production)
|
|
38
|
+
- [Development](#development)
|
|
39
|
+
- [License](#license)
|
|
40
|
+
|
|
41
|
+
## About
|
|
42
|
+
|
|
43
|
+
https://momentum.zakscode.com
|
|
44
|
+
|
|
45
|
+
Momentum is a self-hosted _Enterprise Resource Planning_ (ERP) tool. What does that mean? We can help you run your businesses day-to-day operations by storing, automating & coordinating your data & information; from any location or server.
|
|
46
|
+
|
|
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.
|
|
55
|
+
|
|
56
|
+
Features include:
|
|
57
|
+
- Actions
|
|
58
|
+
- Write server side code to "mod" Momentum & create custom functionality
|
|
59
|
+
- Writen with javascript & the momentum client library to minimize the learning curve
|
|
60
|
+
- Custom library and can be installed & accessed from actions using Docker & NPM
|
|
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
|
|
76
|
+
- Authentication
|
|
77
|
+
- Manage users with custom values
|
|
78
|
+
- Manage groups with cascading permissions & custom values
|
|
79
|
+
- Token management for 3rd party applications
|
|
80
|
+
- Full permission system with custom permissions support
|
|
81
|
+
- Account validation & reset emails
|
|
82
|
+
- Optional public registration form
|
|
83
|
+
- Host OAuth portal for custom application login
|
|
84
|
+
- Custom password strength & rotation settings
|
|
85
|
+
- Two-Factor Authentication
|
|
86
|
+
- OAuth & LDAP support
|
|
87
|
+
- Data
|
|
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
|
|
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
|
|
99
|
+
- Logs
|
|
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
|
|
117
|
+
- Storage
|
|
118
|
+
- Store files
|
|
119
|
+
- Share files with any user/group
|
|
120
|
+
- Built-in filebrowser with drag & drop
|
|
121
|
+
- Automatic metadata tracking
|
|
122
|
+
- Full file/folder permissions
|
|
123
|
+
- Static File Server
|
|
124
|
+
- Host your web applications with the API
|
|
125
|
+
- Built-in filebrowser with drag & drop
|
|
126
|
+
- Automatic metadata tracking
|
|
127
|
+
- Configurable routing
|
|
128
|
+
- Settings
|
|
129
|
+
- Full theming & white label support
|
|
130
|
+
- Manage the server through variables which can be changed at runtime
|
|
131
|
+
- Create & use custom variables for your application
|
|
132
|
+
- Miscellaneous
|
|
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
|
+
### Built With
|
|
148
|
+
[](https://docker.com/)
|
|
149
|
+
[](https://www.mongodb.com/)
|
|
150
|
+
[](https://nodejs.org/)
|
|
151
|
+
[](https://typescriptlang.org/)
|
|
152
|
+
|
|
153
|
+
## Setup
|
|
154
|
+
|
|
155
|
+
<details>
|
|
156
|
+
<summary>
|
|
157
|
+
<h3 id="production" style="display: inline">Production</h3>
|
|
158
|
+
</summary>
|
|
159
|
+
|
|
160
|
+
#### Prerequisites
|
|
161
|
+
- [Docker](https://docs.docker.com/install/)
|
|
162
|
+
|
|
163
|
+
#### Instructions
|
|
164
|
+
1. _Optional: Use momentum to host your [static site](https://git.zakscode.com/momentum/momentum/wiki/Static)_
|
|
165
|
+
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`
|
|
166
|
+
3. Configure the [Environment Variables](https://git.zakscode.com/momentum/momentum/wiki/Environment-Variables) inside the docker-compose
|
|
167
|
+
4. Start the server with: `docker-compose up -f momentum.yaml`
|
|
168
|
+
5. Open http://localhost:80
|
|
169
|
+
- Default login: `admin/admin`
|
|
170
|
+
- Configure [System Variables](https://git.zakscode.com/ztimson/momentum/wiki/System-Variables)
|
|
171
|
+
|
|
172
|
+
</details>
|
|
173
|
+
|
|
174
|
+
<details>
|
|
175
|
+
<summary>
|
|
176
|
+
<h3 id="development" style="display: inline">Development</h3>
|
|
177
|
+
</summary>
|
|
178
|
+
|
|
179
|
+
#### Prerequisites
|
|
180
|
+
- [Docker](https://docs.docker.com/install/)
|
|
181
|
+
- [Node.js](https://nodejs.org/en/download)
|
|
182
|
+
|
|
183
|
+
##### Optional
|
|
184
|
+
- _[ffmpeg](https://ffmpeg.org/download.html) (Video utilities)_
|
|
185
|
+
- _[Whisper](https://github.com/ggml-org/whisper.cpp/releases/tag/v1.7.6) (Audio -> Text)_
|
|
186
|
+
|
|
187
|
+
#### Instructions
|
|
188
|
+
1. Install the dependencies: `npm install`
|
|
189
|
+
2. Start MongoDB: `docker-compose up db`
|
|
190
|
+
3. Start the dev server: `npm run start`
|
|
191
|
+
4. Open http://localhost:3000
|
|
192
|
+
- Default login: `admin/admin`
|
|
193
|
+
- Configure [System Variables](https://git.zakscode.com/momentum/momentum/wiki/System-Variables)
|
|
194
|
+
|
|
195
|
+
</details>
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
Copyright © 2024 Zakary Timson | All Rights Reserved
|
|
199
|
+
|
|
200
|
+
See the [license](./LICENSE) for more information.
|
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,71 @@
|
|
|
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';
|
|
4
5
|
/** Action model */
|
|
5
6
|
export type Action = Meta & {
|
|
6
7
|
/** Action name */
|
|
7
8
|
name: string;
|
|
9
|
+
/** Disable action */
|
|
10
|
+
disabled?: boolean;
|
|
8
11
|
/** Trigger with CRON, CRUD or Event */
|
|
9
12
|
trigger: {
|
|
10
13
|
type: ActionType;
|
|
11
14
|
value: string;
|
|
12
15
|
};
|
|
13
16
|
/** Run as system or with triggering user permissions */
|
|
14
|
-
system?: boolean;
|
|
17
|
+
system?: boolean | null;
|
|
15
18
|
/** Action code */
|
|
16
19
|
fn: string;
|
|
17
20
|
/** User nodes */
|
|
18
|
-
notes?: string;
|
|
21
|
+
notes?: string | null;
|
|
19
22
|
/** Last execution timestamp */
|
|
20
|
-
lastRun?: Date;
|
|
23
|
+
readonly lastRun?: null | Date;
|
|
21
24
|
/** Last execution duration */
|
|
22
|
-
|
|
25
|
+
readonly lastRunDuration?: number | null;
|
|
23
26
|
/** Next scheduled run time (CRON only) */
|
|
24
|
-
nextRun?: Date;
|
|
27
|
+
readonly nextRun?: null | Date;
|
|
25
28
|
/** Last execution results */
|
|
26
|
-
response?: ActionResult;
|
|
29
|
+
readonly response?: ActionResult | null;
|
|
27
30
|
};
|
|
28
31
|
/** Action execution result */
|
|
29
32
|
export type ActionResult = {
|
|
30
33
|
/** ID of associated action */
|
|
31
|
-
action: string;
|
|
34
|
+
readonly action: string;
|
|
35
|
+
/** Runtime */
|
|
36
|
+
readonly duration: number;
|
|
37
|
+
/** Start timestamp */
|
|
38
|
+
readonly start: Date;
|
|
32
39
|
/** Console output */
|
|
33
|
-
stdout: any[];
|
|
40
|
+
readonly stdout: any[];
|
|
34
41
|
/** Console errors */
|
|
35
|
-
stderr: any[];
|
|
42
|
+
readonly stderr: any[];
|
|
36
43
|
/** HTTP Response */
|
|
37
|
-
response?: any;
|
|
44
|
+
readonly response?: any;
|
|
38
45
|
/** Action return value */
|
|
39
|
-
return?: any;
|
|
46
|
+
readonly return?: any;
|
|
40
47
|
};
|
|
48
|
+
/** Action triggers */
|
|
41
49
|
export declare enum ActionType {
|
|
50
|
+
/** CRON Job */
|
|
42
51
|
'CRON' = 0,
|
|
52
|
+
/** Internal Event */
|
|
43
53
|
'EVENT' = 1,
|
|
54
|
+
/** HTTP DELETE request */
|
|
44
55
|
'DELETE' = 2,
|
|
56
|
+
/** HTTP GET request */
|
|
45
57
|
'GET' = 3,
|
|
58
|
+
/** HTTP PATCH request */
|
|
46
59
|
'PATCH' = 4,
|
|
60
|
+
/** HTTP POST request */
|
|
47
61
|
'POST' = 5,
|
|
62
|
+
/** HTTP PUT request */
|
|
48
63
|
'PUT' = 6
|
|
49
64
|
}
|
|
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[]>;
|
|
65
|
+
/** Run cloud functions & custom code */
|
|
66
|
+
export declare class Actions extends AssetController<Action> {
|
|
67
|
+
protected momentum: Momentum;
|
|
68
|
+
constructor(momentum: Momentum);
|
|
61
69
|
/**
|
|
62
70
|
* Manually trigger an actions execution
|
|
63
71
|
* @param {string} id Action ID
|
|
@@ -65,19 +73,6 @@ export declare class Actions extends PathEventEmitter {
|
|
|
65
73
|
* @return {Promise<ActionResult>} All action output including console logs & return
|
|
66
74
|
*/
|
|
67
75
|
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
76
|
/**
|
|
82
77
|
* Run an HTTP action
|
|
83
78
|
* @param {string} path HTTP path excluding `/api/actions/run`
|
|
@@ -85,11 +80,5 @@ export declare class Actions extends PathEventEmitter {
|
|
|
85
80
|
* @return {Promise<T>} HTTP response
|
|
86
81
|
*/
|
|
87
82
|
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
83
|
}
|
|
95
84
|
//# 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,mBAAmB;AACnB,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG;IAC3B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,OAAO,EAAE;QAAC,IAAI,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;IAC3C,wDAAwD;IACxD,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,kBAAkB;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,6BAA6B;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACxC,CAAA;AAED,8BAA8B;AAC9B,MAAM,MAAM,YAAY,GAAG;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,cAAc;IACd,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sBAAsB;IACtB,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC;IACvB,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC;IACvB,oBAAoB;IACpB,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACxB,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC;CACtB,CAAA;AAED,sBAAsB;AACtB,oBAAY,UAAU;IACrB,eAAe;IACf,MAAM,IAAI;IACV,qBAAqB;IACrB,OAAO,IAAI;IACX,0BAA0B;IAC1B,QAAQ,IAAI;IACZ,uBAAuB;IACvB,KAAK,IAAI;IACT,yBAAyB;IACzB,OAAO,IAAI;IACX,wBAAwB;IACxB,MAAM,IAAI;IACV,uBAAuB;IACvB,KAAK,IAAI;CACT;AAED,wCAAwC;AACxC,qBAAa,OAAQ,SAAQ,eAAe,CAAC,MAAM,CAAC;IACvC,SAAS,CAAC,QAAQ,EAAE,QAAQ;gBAAlB,QAAQ,EAAE,QAAQ;IAIxC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC;IAIvE;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,CAAC;CAG/D"}
|