@ztimson/momentum 0.53.0 → 0.53.2
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/bin/build-models.mjs +108 -0
- package/dist/ai.d.ts +8 -0
- package/dist/ai.d.ts.map +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/data.d.ts +26 -10
- package/dist/data.d.ts.map +1 -1
- package/dist/forms.d.ts +24 -4
- package/dist/forms.d.ts.map +1 -1
- package/dist/index.cjs +147 -25
- package/dist/index.mjs +147 -25
- package/dist/sockets.d.ts +2 -1
- package/dist/sockets.d.ts.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import {join} from 'path';
|
|
5
|
+
import {Momentum} from '../dist/index.mjs';
|
|
6
|
+
import * as readline from 'node:readline';
|
|
7
|
+
import {camelCase, formatDate} from '@ztimson/utils';
|
|
8
|
+
|
|
9
|
+
export function ask(prompt, hide = false) {
|
|
10
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: true });
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
if (!hide) {
|
|
13
|
+
rl.question(prompt, (answer) => (rl.close(), resolve(answer)));
|
|
14
|
+
} else {
|
|
15
|
+
let input = '';
|
|
16
|
+
const onKeyPress = (char, key) => {
|
|
17
|
+
if (key && key.name === 'return') {
|
|
18
|
+
rl.input.setRawMode(false);
|
|
19
|
+
rl.input.removeListener('keypress', onKeyPress);
|
|
20
|
+
rl.close();
|
|
21
|
+
resolve(input);
|
|
22
|
+
} else {
|
|
23
|
+
if (key && key.name === 'backspace') {
|
|
24
|
+
if (input.length > 0) input = input.slice(0, -1);
|
|
25
|
+
} else {
|
|
26
|
+
input += char;
|
|
27
|
+
}
|
|
28
|
+
rl.output.write(`\r${prompt}${'*'.repeat(input.length)} `);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Attach keypress event
|
|
33
|
+
rl.input.on('keypress', onKeyPress);
|
|
34
|
+
rl.input.setRawMode(true);
|
|
35
|
+
rl.input.resume();
|
|
36
|
+
rl.output.write(prompt);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
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
|
+
// Main loop
|
|
53
|
+
(async () => {
|
|
54
|
+
try {
|
|
55
|
+
// Arguments
|
|
56
|
+
let [,, destination, url, username, password] = process.argv;
|
|
57
|
+
const packageFile = await import('../package.json', {with: { type: 'json' }});
|
|
58
|
+
console.log(`Momentum v${packageFile.default.version}`);
|
|
59
|
+
let momentum;
|
|
60
|
+
|
|
61
|
+
// Login
|
|
62
|
+
do {
|
|
63
|
+
while(!url) url = await ask('URL: ');
|
|
64
|
+
while(!username) username = await ask('Username: ');
|
|
65
|
+
while(!password) password = await ask('Password: ', true);
|
|
66
|
+
|
|
67
|
+
if(!url.startsWith('http')) url = 'http://' + url;
|
|
68
|
+
momentum = new Momentum(url);
|
|
69
|
+
await momentum.auth.login(username, password)
|
|
70
|
+
.catch(err => {
|
|
71
|
+
url = username = password = '';
|
|
72
|
+
console.log('Failed to authenticate');
|
|
73
|
+
});
|
|
74
|
+
} while(!momentum?.auth.user);
|
|
75
|
+
console.log('Login Succeeded!\n');
|
|
76
|
+
|
|
77
|
+
if(!destination) destination = await ask('Destination (src/models): ');
|
|
78
|
+
if(!destination) destination = 'src/models';
|
|
79
|
+
let path = join(process.cwd(), destination);
|
|
80
|
+
if(!fs.existsSync(path)) fs.mkdirSync(path);
|
|
81
|
+
|
|
82
|
+
console.log('\nCollecting Schemas...');
|
|
83
|
+
const schemas = await momentum.data.schema.read();
|
|
84
|
+
schemas.forEach(schema => {
|
|
85
|
+
const fileName = camelCase(schema.path) + '.ts';
|
|
86
|
+
console.log(`Creating Model: ${schema.path} -> ${fileName}`);
|
|
87
|
+
const path = join(process.cwd(), destination, fileName);
|
|
88
|
+
fs.writeFileSync(path, `import {Meta} from '@ztimson/momentum';
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* ${schema.path}
|
|
92
|
+
*
|
|
93
|
+
* ${schema.description}
|
|
94
|
+
*
|
|
95
|
+
* Generated by Momentum v${packageFile.default.version} - ${formatDate('YYYY-MM-DD')}
|
|
96
|
+
*/
|
|
97
|
+
export interface ${camelCase(schema.path)} extends Meta${schema.columns.length ? '' : ', Record<string, any>'} {
|
|
98
|
+
${schema.columns.map(column => `\t${createProp(column)};`).join('\n')}
|
|
99
|
+
}
|
|
100
|
+
`);
|
|
101
|
+
});
|
|
102
|
+
console.log('Done!');
|
|
103
|
+
process.exit();
|
|
104
|
+
} catch(err) {
|
|
105
|
+
console.error(`\n${err.stack || err.stackTrace || err.message || err.toString()}`);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
})();
|
package/dist/ai.d.ts
CHANGED
|
@@ -24,5 +24,13 @@ export declare class Ai extends PathEventEmitter {
|
|
|
24
24
|
role: string;
|
|
25
25
|
content: string;
|
|
26
26
|
}[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Get model info
|
|
29
|
+
* @return {Promise<{host: string, model: string}>} Model Info
|
|
30
|
+
*/
|
|
31
|
+
info(): Promise<{
|
|
32
|
+
host: string;
|
|
33
|
+
model: string;
|
|
34
|
+
}>;
|
|
27
35
|
}
|
|
28
36
|
//# 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,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,sBAAsB;AACtB,qBAAa,EAAG,SAAQ,gBAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrD;;;OAGG;IACH,KAAK;IAKL;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,sBAAsB;AACtB,qBAAa,EAAG,SAAQ,gBAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAWrD;;;OAGG;IACH,KAAK;IAKL;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAOrD;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CAG9C"}
|
package/dist/api.d.ts
CHANGED
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAEjB,eAAe,EACf,MAAM,gBAAgB,CAAC;AAExB,8BAA8B;AAC9B,MAAM,MAAM,MAAM,GAAG;IACpB,sBAAsB;IACtB,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC;IAChD,qBAAqB;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,gBAAgB;IAChB,EAAE,EAAE,YAAY,CAAC;IACjB,sBAAsB;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,mBAAmB;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,sBAAsB;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,mBAAmB;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;CACf,CAAA;AAED,6BAA6B;AAC7B,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhE,kBAAkB;AAClB,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AAEF,0BAA0B;AAC1B,qBAAa,GAAI,SAAQ,IAAK,YAAW,iBAAiB;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],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AS;IAC/B,gCAAgC;IAChC,IAAI,aAAa,IAAI,OAAO,CAAgC;IAC5D,OAAO,KAAK,aAAa,QAGxB;IAED,OAAO,CAAC,SAAS,CAAC,CAAW;IAC7B,oCAAoC;IACpC,IAAI,QAAQ,IAAI,QAAQ,CAWvB;IAED,iCAAiC;IACjC,IAAI,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAGvD;IAED,OAAO,CAAC,IAAI,CAAC,CAAU;IACvB,gCAAgC;IAChC,IAAI,GAAG,IAAI,OAAO,CAIjB;gBAEmB,GAAG,EAAE,GAAG,EAAmB,QAAQ,EAAE,QAAQ;IAKjE;;;;OAIG;IACG,IAAI,CAAC,IAAI,GAAE;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAM;IA4FvD;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,KAAK;IAqItC;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAa1C;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;CAO3C"}
|
package/dist/data.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Meta, TreeNode } from './core';
|
|
|
3
3
|
import { PathEventEmitter, PromiseProgress } from '@ztimson/utils';
|
|
4
4
|
export type Document<T> = Meta & T;
|
|
5
5
|
export type RawQuery = {
|
|
6
|
-
operand: 'delete' | 'deleteOne' | 'find' | 'findOne' | '
|
|
6
|
+
operand: 'delete' | 'deleteOne' | 'find' | 'findOne' | 'insertOne' | 'replaceOne' | 'update' | 'updateOne';
|
|
7
7
|
filter?: any;
|
|
8
8
|
data?: any;
|
|
9
9
|
options?: any;
|
|
@@ -14,16 +14,12 @@ export type Schema = Meta & {
|
|
|
14
14
|
path: string;
|
|
15
15
|
/** Description of data */
|
|
16
16
|
description?: string;
|
|
17
|
-
/** Last index number */
|
|
18
|
-
autoIncrement?: number;
|
|
19
17
|
/** Associated form for viewing/editing */
|
|
20
18
|
form?: string;
|
|
21
19
|
/** Hide columns */
|
|
22
20
|
hide?: string[];
|
|
23
21
|
/** Lock collection from changes */
|
|
24
22
|
lock?: boolean;
|
|
25
|
-
/** Display column letters */
|
|
26
|
-
showLetters?: boolean;
|
|
27
23
|
/** Data must match defined columns */
|
|
28
24
|
strict?: boolean;
|
|
29
25
|
/** Allow updates to create row if missing */
|
|
@@ -45,17 +41,37 @@ export type SchemaColumn = {
|
|
|
45
41
|
/** Must have value */
|
|
46
42
|
required?: boolean;
|
|
47
43
|
/** Style */
|
|
48
|
-
style
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
style: SchemaColumnStyle;
|
|
45
|
+
};
|
|
46
|
+
export type SchemaColumnStyle = {
|
|
47
|
+
/** Align column content */
|
|
48
|
+
align?: 'center' | 'left' | 'right';
|
|
49
|
+
/** Background color */
|
|
50
|
+
background?: string;
|
|
51
|
+
/** Bold column text */
|
|
52
|
+
bold?: boolean;
|
|
53
|
+
/** Column text color */
|
|
54
|
+
color?: string;
|
|
55
|
+
/** Italicize column text */
|
|
56
|
+
italics?: boolean;
|
|
57
|
+
/** Strikethrough column text */
|
|
58
|
+
strike?: boolean;
|
|
59
|
+
/** Underline column text */
|
|
60
|
+
underline?: boolean;
|
|
61
|
+
/** Column width */
|
|
62
|
+
width?: string;
|
|
63
|
+
/** Conditional formating */
|
|
64
|
+
conditional: (Omit<SchemaColumnStyle, 'conditional'> & {
|
|
65
|
+
condition: string;
|
|
66
|
+
})[];
|
|
51
67
|
};
|
|
52
68
|
declare class Schemas extends PathEventEmitter {
|
|
53
69
|
private api;
|
|
54
70
|
constructor(api: Api);
|
|
55
71
|
delete(path: string): PromiseProgress<any>;
|
|
56
72
|
read(tree?: false): Promise<Schema[]>;
|
|
57
|
-
read(tree
|
|
58
|
-
read(path
|
|
73
|
+
read(tree: true): Promise<TreeNode<Schema>[]>;
|
|
74
|
+
read(path: string): Promise<Schema>;
|
|
59
75
|
update(schema: Partial<Schema> & {
|
|
60
76
|
path: string;
|
|
61
77
|
}): PromiseProgress<Schema>;
|
package/dist/data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,IAAI,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,KAAK,IAAI,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAC,gBAAgB,EAAO,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAEtE,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;AAEnC,MAAM,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3G,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG;IAC3B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,mCAAmC;IACnC,IA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AAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAY5F,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;CAQjE"}
|
package/dist/forms.d.ts
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import { Cache, PathEventEmitter } from '@ztimson/utils';
|
|
2
2
|
import { Api } from './api';
|
|
3
3
|
import { Meta, TreeNode } from './core';
|
|
4
|
-
export type Form = Meta & {
|
|
4
|
+
export type Form<T = any> = Meta & {
|
|
5
5
|
path: string;
|
|
6
|
+
collection: string;
|
|
6
7
|
description?: string;
|
|
8
|
+
schema: {
|
|
9
|
+
type: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
prop?: string;
|
|
12
|
+
default?: any;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
options?: {
|
|
15
|
+
choices?: string[];
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
min?: number;
|
|
18
|
+
max?: number;
|
|
19
|
+
step?: number;
|
|
20
|
+
};
|
|
21
|
+
style?: {
|
|
22
|
+
inline?: boolean;
|
|
23
|
+
width?: string;
|
|
24
|
+
};
|
|
25
|
+
}[];
|
|
26
|
+
data?: T;
|
|
7
27
|
};
|
|
8
28
|
export declare class Forms extends PathEventEmitter {
|
|
9
29
|
readonly api: Api;
|
|
10
|
-
cache: Cache<string, Form
|
|
30
|
+
cache: Cache<string, Form<any>>;
|
|
11
31
|
constructor(api: Api | string);
|
|
12
32
|
all(tree?: false): Promise<string[]>;
|
|
13
|
-
all(tree
|
|
14
|
-
all(path
|
|
33
|
+
all(tree: true): Promise<TreeNode<Form>[]>;
|
|
34
|
+
all(path: string): Promise<Form>;
|
|
15
35
|
delete(key: string): Promise<void>;
|
|
16
36
|
read(path: string, reload?: boolean): Promise<Form | null>;
|
|
17
37
|
update(form: Form): Promise<Form>;
|
package/dist/forms.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../src/forms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,gBAAgB,EAAuB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG;
|
|
1
|
+
{"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../src/forms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,gBAAgB,EAAuB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,IAAI,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE;YACT,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;YACnB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,IAAI,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;QACF,KAAK,CAAC,EAAE;YACP,MAAM,CAAC,EAAE,OAAO,CAAC;YACjB,KAAK,CAAC,EAAE,MAAM,CAAC;SACf,CAAA;KACD,EAAE,CAAC;IACJ,IAAI,CAAC,EAAE,CAAC,CAAC;CACT,CAAA;AAED,qBAAa,KAAM,SAAQ,gBAAgB;IAC1C,QAAQ,CAAC,GAAG,EAAG,GAAG,CAAC;IAEnB,KAAK,2BAAiC;gBAE1B,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACpC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,UAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAUtD,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAQjC"}
|
package/dist/index.cjs
CHANGED
|
@@ -19,6 +19,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
19
19
|
}
|
|
20
20
|
return obj;
|
|
21
21
|
}
|
|
22
|
+
function deepCopy(value2) {
|
|
23
|
+
try {
|
|
24
|
+
return structuredClone(value2);
|
|
25
|
+
} catch {
|
|
26
|
+
return JSON.parse(JSONSanitize(value2));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
22
29
|
function isEqual(a2, b2) {
|
|
23
30
|
const ta = typeof a2, tb = typeof b2;
|
|
24
31
|
if (ta != "object" || a2 == null || (tb != "object" || b2 == null))
|
|
@@ -177,11 +184,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
177
184
|
return new Proxy(this, {
|
|
178
185
|
get: (target, prop2) => {
|
|
179
186
|
if (prop2 in target) return target[prop2];
|
|
180
|
-
return target.store[prop2];
|
|
187
|
+
return deepCopy(target.store[prop2]);
|
|
181
188
|
},
|
|
182
189
|
set: (target, prop2, value2) => {
|
|
183
190
|
if (prop2 in target) target[prop2] = value2;
|
|
184
|
-
else
|
|
191
|
+
else this.set(prop2, value2);
|
|
185
192
|
return true;
|
|
186
193
|
}
|
|
187
194
|
});
|
|
@@ -196,7 +203,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
196
203
|
* @return {T[]} Array of items
|
|
197
204
|
*/
|
|
198
205
|
all() {
|
|
199
|
-
return Object.values(this.store);
|
|
206
|
+
return deepCopy(Object.values(this.store));
|
|
200
207
|
}
|
|
201
208
|
/**
|
|
202
209
|
* Add a new item to the cache. Like set, but finds key automatically
|
|
@@ -251,7 +258,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
251
258
|
* @return {T} Cached item
|
|
252
259
|
*/
|
|
253
260
|
get(key) {
|
|
254
|
-
return this.store[key];
|
|
261
|
+
return deepCopy(this.store[key]);
|
|
255
262
|
}
|
|
256
263
|
/**
|
|
257
264
|
* Get a list of cached keys
|
|
@@ -267,7 +274,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
267
274
|
* @return {Record<K, T>}
|
|
268
275
|
*/
|
|
269
276
|
map() {
|
|
270
|
-
return
|
|
277
|
+
return deepCopy(this.store);
|
|
271
278
|
}
|
|
272
279
|
/**
|
|
273
280
|
* Add an item to the cache manually specifying the key
|
|
@@ -337,6 +344,106 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
337
344
|
return this.from(super.finally(res));
|
|
338
345
|
}
|
|
339
346
|
}
|
|
347
|
+
function formatDate(format = "YYYY-MM-DD H:mm", date = /* @__PURE__ */ new Date(), tz) {
|
|
348
|
+
const timezones = [
|
|
349
|
+
["IDLW", -12],
|
|
350
|
+
["SST", -11],
|
|
351
|
+
["HST", -10],
|
|
352
|
+
["AKST", -9],
|
|
353
|
+
["PST", -8],
|
|
354
|
+
["MST", -7],
|
|
355
|
+
["CST", -6],
|
|
356
|
+
["EST", -5],
|
|
357
|
+
["AST", -4],
|
|
358
|
+
["BRT", -3],
|
|
359
|
+
["MAT", -2],
|
|
360
|
+
["AZOT", -1],
|
|
361
|
+
["UTC", 0],
|
|
362
|
+
["CET", 1],
|
|
363
|
+
["EET", 2],
|
|
364
|
+
["MSK", 3],
|
|
365
|
+
["AST", 4],
|
|
366
|
+
["PKT", 5],
|
|
367
|
+
["IST", 5.5],
|
|
368
|
+
["BST", 6],
|
|
369
|
+
["ICT", 7],
|
|
370
|
+
["CST", 8],
|
|
371
|
+
["JST", 9],
|
|
372
|
+
["AEST", 10],
|
|
373
|
+
["SBT", 11],
|
|
374
|
+
["FJT", 12],
|
|
375
|
+
["TOT", 13],
|
|
376
|
+
["LINT", 14]
|
|
377
|
+
];
|
|
378
|
+
function adjustTz(date2, gmt) {
|
|
379
|
+
const currentOffset = date2.getTimezoneOffset();
|
|
380
|
+
const adjustedOffset = gmt * 60;
|
|
381
|
+
return new Date(date2.getTime() + (adjustedOffset + currentOffset) * 6e4);
|
|
382
|
+
}
|
|
383
|
+
function day(num) {
|
|
384
|
+
return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][num] || "Unknown";
|
|
385
|
+
}
|
|
386
|
+
function doy(date2) {
|
|
387
|
+
const start = /* @__PURE__ */ new Date(`${date2.getFullYear()}-01-01 0:00:00`);
|
|
388
|
+
return Math.ceil((date2.getTime() - start.getTime()) / (1e3 * 60 * 60 * 24));
|
|
389
|
+
}
|
|
390
|
+
function month(num) {
|
|
391
|
+
return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][num] || "Unknown";
|
|
392
|
+
}
|
|
393
|
+
function suffix(num) {
|
|
394
|
+
if (num % 100 >= 11 && num % 100 <= 13) return `${num}th`;
|
|
395
|
+
switch (num % 10) {
|
|
396
|
+
case 1:
|
|
397
|
+
return `${num}st`;
|
|
398
|
+
case 2:
|
|
399
|
+
return `${num}nd`;
|
|
400
|
+
case 3:
|
|
401
|
+
return `${num}rd`;
|
|
402
|
+
default:
|
|
403
|
+
return `${num}th`;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function tzOffset(offset) {
|
|
407
|
+
const hours = ~~(offset / 60);
|
|
408
|
+
const minutes = offset % 60;
|
|
409
|
+
return (offset > 0 ? "-" : "") + `${hours}:${minutes.toString().padStart(2, "0")}`;
|
|
410
|
+
}
|
|
411
|
+
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
412
|
+
let t;
|
|
413
|
+
if (tz == null) tz = -(date.getTimezoneOffset() / 60);
|
|
414
|
+
t = timezones.find((t2) => isNaN(tz) ? t2[0] == tz : t2[1] == tz);
|
|
415
|
+
if (!t) throw new Error(`Unknown timezone: ${tz}`);
|
|
416
|
+
date = adjustTz(date, t[1]);
|
|
417
|
+
const tokens = {
|
|
418
|
+
"YYYY": date.getFullYear().toString(),
|
|
419
|
+
"YY": date.getFullYear().toString().slice(2),
|
|
420
|
+
"MMMM": month(date.getMonth()),
|
|
421
|
+
"MMM": month(date.getMonth()).slice(0, 3),
|
|
422
|
+
"MM": (date.getMonth() + 1).toString().padStart(2, "0"),
|
|
423
|
+
"M": (date.getMonth() + 1).toString(),
|
|
424
|
+
"DDD": doy(date).toString(),
|
|
425
|
+
"DD": date.getDate().toString().padStart(2, "0"),
|
|
426
|
+
"Do": suffix(date.getDate()),
|
|
427
|
+
"D": date.getDate().toString(),
|
|
428
|
+
"dddd": day(date.getDay()),
|
|
429
|
+
"ddd": day(date.getDay()).slice(0, 3),
|
|
430
|
+
"HH": date.getHours().toString().padStart(2, "0"),
|
|
431
|
+
"H": date.getHours().toString(),
|
|
432
|
+
"hh": (date.getHours() % 12 || 12).toString().padStart(2, "0"),
|
|
433
|
+
"h": (date.getHours() % 12 || 12).toString(),
|
|
434
|
+
"mm": date.getMinutes().toString().padStart(2, "0"),
|
|
435
|
+
"m": date.getMinutes().toString(),
|
|
436
|
+
"ss": date.getSeconds().toString().padStart(2, "0"),
|
|
437
|
+
"s": date.getSeconds().toString(),
|
|
438
|
+
"SSS": date.getMilliseconds().toString().padStart(3, "0"),
|
|
439
|
+
"A": date.getHours() >= 12 ? "PM" : "AM",
|
|
440
|
+
"a": date.getHours() >= 12 ? "pm" : "am",
|
|
441
|
+
"ZZ": tzOffset(t[1] * 60).replace(":", ""),
|
|
442
|
+
"Z": tzOffset(t[1] * 60),
|
|
443
|
+
"z": typeof tz == "string" ? tz : t[0]
|
|
444
|
+
};
|
|
445
|
+
return format.replace(/YYYY|YY|MMMM|MMM|MM|M|DDD|DD|Do|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|SSS|A|a|ZZ|Z|z/g, (token) => tokens[token]);
|
|
446
|
+
}
|
|
340
447
|
function downloadFile(blob, name) {
|
|
341
448
|
if (!(blob instanceof Blob)) blob = new Blob(makeArray(blob));
|
|
342
449
|
const url = URL.createObjectURL(blob);
|
|
@@ -368,7 +475,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
368
475
|
}
|
|
369
476
|
function timestampFilename(name, date = /* @__PURE__ */ new Date()) {
|
|
370
477
|
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
371
|
-
const timestamp =
|
|
478
|
+
const timestamp = formatDate("YYYY-MM-DD_HH:mm:ss", date);
|
|
372
479
|
return timestamp;
|
|
373
480
|
}
|
|
374
481
|
function uploadWithProgress(options) {
|
|
@@ -986,6 +1093,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
986
1093
|
if (token) this.token = token;
|
|
987
1094
|
}
|
|
988
1095
|
}
|
|
1096
|
+
get sameOrigin() {
|
|
1097
|
+
if (typeof window == "undefined" || !(window == null ? void 0 : window.location)) return false;
|
|
1098
|
+
return window.location.host == this.host;
|
|
1099
|
+
}
|
|
989
1100
|
/** Current API token */
|
|
990
1101
|
get token() {
|
|
991
1102
|
return this._token;
|
|
@@ -1019,7 +1130,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1019
1130
|
const key = JSONSanitize(options);
|
|
1020
1131
|
const method = options.method == "GET" ? "r" : options.method == "POST" ? "c" : options.method == "DELETE" ? "d" : "u";
|
|
1021
1132
|
if (this.pending[key] != null) return this.pending[key];
|
|
1022
|
-
this.pending[key] = super.request(options).then((response) => {
|
|
1133
|
+
this.pending[key] = super.request({ ...options, credentials: "include" }).then((response) => {
|
|
1023
1134
|
this.emit(PES`api/response:${method}`, { request: options, response });
|
|
1024
1135
|
return options.decode === false ? response : response.data;
|
|
1025
1136
|
}).catch((err) => {
|
|
@@ -1163,6 +1274,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1163
1274
|
return resp;
|
|
1164
1275
|
});
|
|
1165
1276
|
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Get model info
|
|
1279
|
+
* @return {Promise<{host: string, model: string}>} Model Info
|
|
1280
|
+
*/
|
|
1281
|
+
info() {
|
|
1282
|
+
return this.api.request({ url: "/api/ai/info" });
|
|
1283
|
+
}
|
|
1166
1284
|
}
|
|
1167
1285
|
class Analytics extends PathEventEmitter {
|
|
1168
1286
|
constructor(api) {
|
|
@@ -1386,6 +1504,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1386
1504
|
logout() {
|
|
1387
1505
|
this.emit(PES`auth/logout:d`, this.user);
|
|
1388
1506
|
this.api.token = null;
|
|
1507
|
+
this.api.request({ url: "/api/auth/logout", method: "DELETE" });
|
|
1389
1508
|
this.user = null;
|
|
1390
1509
|
}
|
|
1391
1510
|
/**
|
|
@@ -1397,8 +1516,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1397
1516
|
var _a;
|
|
1398
1517
|
if (!user.username || !user.password) throw new Error("Cannot register user, missing username or password");
|
|
1399
1518
|
const u = await this.api.request({ url: "/api/auth/register", body: { ...user } });
|
|
1400
|
-
if ((_a = u == null ? void 0 : u.image) == null ? void 0 : _a.startsWith("/")) u.image = `${this.api.url}${u.image}?token=${this.api.token}`;
|
|
1401
|
-
this.
|
|
1519
|
+
if ((_a = u == null ? void 0 : u.image) == null ? void 0 : _a.startsWith("/")) u.image = `${this.api.url}${u.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1520
|
+
this.user = u;
|
|
1521
|
+
this.permissions = [];
|
|
1522
|
+
this.emit(PES`auth/register:u`, u);
|
|
1402
1523
|
return u;
|
|
1403
1524
|
}
|
|
1404
1525
|
reset(emailOrPass, token) {
|
|
@@ -1429,7 +1550,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1429
1550
|
this.emit(PES`auth/session:r`, session);
|
|
1430
1551
|
if (set) {
|
|
1431
1552
|
this.api.token = token;
|
|
1432
|
-
if (session == null ? void 0 : session.user) session.user.image = `${this.api.url}${session.user.image}?token=${this.api.token}`;
|
|
1553
|
+
if (session == null ? void 0 : session.user) session.user.image = `${this.api.url}${session.user.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1433
1554
|
this.user = (session == null ? void 0 : session.user) || null;
|
|
1434
1555
|
this.permissions = (session == null ? void 0 : session.permissions) || [];
|
|
1435
1556
|
if (session) this.emit(PES`auth/login:c`, session.user);
|
|
@@ -1531,7 +1652,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1531
1652
|
if (!this.settings.cache.keys().length) opts.reload = true;
|
|
1532
1653
|
let settings = await (opts.reload ? this.settings.all(false, true) : this.settings.cache);
|
|
1533
1654
|
if (opts.reload == null) this.settings.all(false, true).then(() => this.init({ reload: false }));
|
|
1534
|
-
if (settings["title"]) document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
|
|
1655
|
+
if (settings["title"]) document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = el.innerText.includes("|") ? `${el.innerText.split("|")[0].trim()} | ${settings["title"]}` : settings["title"]);
|
|
1535
1656
|
if (settings["description"]) document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
|
|
1536
1657
|
if (settings["version"]) document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
|
|
1537
1658
|
if (settings["logo"]) document.querySelectorAll(".momentum-logo").forEach((el) => el.src = settings["logo"]);
|
|
@@ -1807,7 +1928,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1807
1928
|
}
|
|
1808
1929
|
raw(collection, query) {
|
|
1809
1930
|
if (!collection || !query) throw new Error("Cannot execute raw query, missing collection or query");
|
|
1810
|
-
const mode = query.operand.startsWith("find") ? "r" : query.operand == "
|
|
1931
|
+
const mode = query.operand.startsWith("find") ? "r" : query.operand == "insertOne" ? "c" : query.operand.startsWith("delete") ? "d" : "u";
|
|
1811
1932
|
return this.api.request({ url: `/api/` + PES`data/${collection}` + "?raw", body: query }).then((resp) => {
|
|
1812
1933
|
this.emit(PES`data/${collection}:${mode}`, resp);
|
|
1813
1934
|
return resp;
|
|
@@ -2002,7 +2123,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2002
2123
|
if (LOG_LEVEL[logLevel] >= 0) {
|
|
2003
2124
|
console.error = (...args) => {
|
|
2004
2125
|
this.console.error(...args);
|
|
2005
|
-
this.error(
|
|
2126
|
+
this.error(args);
|
|
2006
2127
|
};
|
|
2007
2128
|
window.addEventListener("unhandledrejection", async (event) => {
|
|
2008
2129
|
var _a, _b, _c, _d;
|
|
@@ -2017,25 +2138,25 @@ ${log}`;
|
|
|
2017
2138
|
if (LOG_LEVEL[logLevel] >= 1) {
|
|
2018
2139
|
console.warn = (...args) => {
|
|
2019
2140
|
this.console.warn(...args);
|
|
2020
|
-
this.warn(
|
|
2141
|
+
this.warn(args);
|
|
2021
2142
|
};
|
|
2022
2143
|
}
|
|
2023
2144
|
if (LOG_LEVEL[logLevel] >= 2) {
|
|
2024
2145
|
console.info = (...args) => {
|
|
2025
2146
|
this.console.info(...args);
|
|
2026
|
-
this.info(
|
|
2147
|
+
this.info(args);
|
|
2027
2148
|
};
|
|
2028
2149
|
}
|
|
2029
2150
|
if (LOG_LEVEL[logLevel] >= 3) {
|
|
2030
2151
|
console.log = (...args) => {
|
|
2031
2152
|
this.console.log(...args);
|
|
2032
|
-
this.log(
|
|
2153
|
+
this.log(args);
|
|
2033
2154
|
};
|
|
2034
2155
|
}
|
|
2035
2156
|
if (LOG_LEVEL[logLevel] >= 4) {
|
|
2036
2157
|
console.debug = (...args) => {
|
|
2037
2158
|
this.console.debug(...args);
|
|
2038
|
-
this.debug(
|
|
2159
|
+
this.debug(args);
|
|
2039
2160
|
};
|
|
2040
2161
|
}
|
|
2041
2162
|
}
|
|
@@ -2325,14 +2446,15 @@ ${log}`;
|
|
|
2325
2446
|
this.connect();
|
|
2326
2447
|
}, _Socket.pollingSpeed);
|
|
2327
2448
|
}
|
|
2328
|
-
handle(
|
|
2329
|
-
|
|
2449
|
+
handle(message) {
|
|
2450
|
+
const data = JSONAttemptParse(message.data);
|
|
2451
|
+
if (data.event) data.event = new PathEvent(data.event);
|
|
2452
|
+
console.log(data);
|
|
2330
2453
|
}
|
|
2331
|
-
send(
|
|
2454
|
+
send(event, payload) {
|
|
2332
2455
|
var _a;
|
|
2333
2456
|
(_a = this.connection) == null ? void 0 : _a.send(JSON.stringify({
|
|
2334
|
-
|
|
2335
|
-
channel,
|
|
2457
|
+
event: new PathEvent(event).toString(),
|
|
2336
2458
|
payload
|
|
2337
2459
|
}));
|
|
2338
2460
|
}
|
|
@@ -2378,7 +2500,7 @@ ${log}`;
|
|
|
2378
2500
|
}
|
|
2379
2501
|
open(path, target = "_blank") {
|
|
2380
2502
|
if (!path) throw new Error("Cannot download file, missing path");
|
|
2381
|
-
const link = `${this.api.url}/api/` + PES`${this.path}/${path}
|
|
2503
|
+
const link = `${this.api.url}/api/` + PES`${this.path}/${path}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
2382
2504
|
if (!target) return link;
|
|
2383
2505
|
this.emit(PES`${this.path}/${path}:r`, path);
|
|
2384
2506
|
return window.open(link, target);
|
|
@@ -2427,7 +2549,7 @@ ${log}`;
|
|
|
2427
2549
|
if (!reload && this.cache.complete) return this.cache.all();
|
|
2428
2550
|
return this.api.request({ url: "/api/" + PES`users` }).then((resp) => {
|
|
2429
2551
|
resp == null ? void 0 : resp.forEach((r) => {
|
|
2430
|
-
r.image = this.api.url
|
|
2552
|
+
r.image = `${this.api.url}${r.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
2431
2553
|
return r;
|
|
2432
2554
|
});
|
|
2433
2555
|
this.cache.addAll(resp);
|
|
@@ -2450,7 +2572,7 @@ ${log}`;
|
|
|
2450
2572
|
if (!reload && this.cache.get(username)) return this.cache.get(username);
|
|
2451
2573
|
return this.api.request({ url: "/api/" + PES`users/${username}` }).then((resp) => {
|
|
2452
2574
|
if (resp) {
|
|
2453
|
-
resp.image = this.api.url
|
|
2575
|
+
resp.image = `${this.api.url}${resp.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
2454
2576
|
this.cache.add(resp);
|
|
2455
2577
|
}
|
|
2456
2578
|
this.emit(PES`users/${username}:r`, resp);
|
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,13 @@ function clean(obj, undefinedOnly = false) {
|
|
|
15
15
|
}
|
|
16
16
|
return obj;
|
|
17
17
|
}
|
|
18
|
+
function deepCopy(value2) {
|
|
19
|
+
try {
|
|
20
|
+
return structuredClone(value2);
|
|
21
|
+
} catch {
|
|
22
|
+
return JSON.parse(JSONSanitize(value2));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
18
25
|
function isEqual(a2, b2) {
|
|
19
26
|
const ta = typeof a2, tb = typeof b2;
|
|
20
27
|
if (ta != "object" || a2 == null || (tb != "object" || b2 == null))
|
|
@@ -173,11 +180,11 @@ class Cache {
|
|
|
173
180
|
return new Proxy(this, {
|
|
174
181
|
get: (target, prop2) => {
|
|
175
182
|
if (prop2 in target) return target[prop2];
|
|
176
|
-
return target.store[prop2];
|
|
183
|
+
return deepCopy(target.store[prop2]);
|
|
177
184
|
},
|
|
178
185
|
set: (target, prop2, value2) => {
|
|
179
186
|
if (prop2 in target) target[prop2] = value2;
|
|
180
|
-
else
|
|
187
|
+
else this.set(prop2, value2);
|
|
181
188
|
return true;
|
|
182
189
|
}
|
|
183
190
|
});
|
|
@@ -192,7 +199,7 @@ class Cache {
|
|
|
192
199
|
* @return {T[]} Array of items
|
|
193
200
|
*/
|
|
194
201
|
all() {
|
|
195
|
-
return Object.values(this.store);
|
|
202
|
+
return deepCopy(Object.values(this.store));
|
|
196
203
|
}
|
|
197
204
|
/**
|
|
198
205
|
* Add a new item to the cache. Like set, but finds key automatically
|
|
@@ -247,7 +254,7 @@ class Cache {
|
|
|
247
254
|
* @return {T} Cached item
|
|
248
255
|
*/
|
|
249
256
|
get(key) {
|
|
250
|
-
return this.store[key];
|
|
257
|
+
return deepCopy(this.store[key]);
|
|
251
258
|
}
|
|
252
259
|
/**
|
|
253
260
|
* Get a list of cached keys
|
|
@@ -263,7 +270,7 @@ class Cache {
|
|
|
263
270
|
* @return {Record<K, T>}
|
|
264
271
|
*/
|
|
265
272
|
map() {
|
|
266
|
-
return
|
|
273
|
+
return deepCopy(this.store);
|
|
267
274
|
}
|
|
268
275
|
/**
|
|
269
276
|
* Add an item to the cache manually specifying the key
|
|
@@ -333,6 +340,106 @@ class PromiseProgress extends Promise {
|
|
|
333
340
|
return this.from(super.finally(res));
|
|
334
341
|
}
|
|
335
342
|
}
|
|
343
|
+
function formatDate(format = "YYYY-MM-DD H:mm", date = /* @__PURE__ */ new Date(), tz) {
|
|
344
|
+
const timezones = [
|
|
345
|
+
["IDLW", -12],
|
|
346
|
+
["SST", -11],
|
|
347
|
+
["HST", -10],
|
|
348
|
+
["AKST", -9],
|
|
349
|
+
["PST", -8],
|
|
350
|
+
["MST", -7],
|
|
351
|
+
["CST", -6],
|
|
352
|
+
["EST", -5],
|
|
353
|
+
["AST", -4],
|
|
354
|
+
["BRT", -3],
|
|
355
|
+
["MAT", -2],
|
|
356
|
+
["AZOT", -1],
|
|
357
|
+
["UTC", 0],
|
|
358
|
+
["CET", 1],
|
|
359
|
+
["EET", 2],
|
|
360
|
+
["MSK", 3],
|
|
361
|
+
["AST", 4],
|
|
362
|
+
["PKT", 5],
|
|
363
|
+
["IST", 5.5],
|
|
364
|
+
["BST", 6],
|
|
365
|
+
["ICT", 7],
|
|
366
|
+
["CST", 8],
|
|
367
|
+
["JST", 9],
|
|
368
|
+
["AEST", 10],
|
|
369
|
+
["SBT", 11],
|
|
370
|
+
["FJT", 12],
|
|
371
|
+
["TOT", 13],
|
|
372
|
+
["LINT", 14]
|
|
373
|
+
];
|
|
374
|
+
function adjustTz(date2, gmt) {
|
|
375
|
+
const currentOffset = date2.getTimezoneOffset();
|
|
376
|
+
const adjustedOffset = gmt * 60;
|
|
377
|
+
return new Date(date2.getTime() + (adjustedOffset + currentOffset) * 6e4);
|
|
378
|
+
}
|
|
379
|
+
function day(num) {
|
|
380
|
+
return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][num] || "Unknown";
|
|
381
|
+
}
|
|
382
|
+
function doy(date2) {
|
|
383
|
+
const start = /* @__PURE__ */ new Date(`${date2.getFullYear()}-01-01 0:00:00`);
|
|
384
|
+
return Math.ceil((date2.getTime() - start.getTime()) / (1e3 * 60 * 60 * 24));
|
|
385
|
+
}
|
|
386
|
+
function month(num) {
|
|
387
|
+
return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"][num] || "Unknown";
|
|
388
|
+
}
|
|
389
|
+
function suffix(num) {
|
|
390
|
+
if (num % 100 >= 11 && num % 100 <= 13) return `${num}th`;
|
|
391
|
+
switch (num % 10) {
|
|
392
|
+
case 1:
|
|
393
|
+
return `${num}st`;
|
|
394
|
+
case 2:
|
|
395
|
+
return `${num}nd`;
|
|
396
|
+
case 3:
|
|
397
|
+
return `${num}rd`;
|
|
398
|
+
default:
|
|
399
|
+
return `${num}th`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function tzOffset(offset) {
|
|
403
|
+
const hours = ~~(offset / 60);
|
|
404
|
+
const minutes = offset % 60;
|
|
405
|
+
return (offset > 0 ? "-" : "") + `${hours}:${minutes.toString().padStart(2, "0")}`;
|
|
406
|
+
}
|
|
407
|
+
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
408
|
+
let t;
|
|
409
|
+
if (tz == null) tz = -(date.getTimezoneOffset() / 60);
|
|
410
|
+
t = timezones.find((t2) => isNaN(tz) ? t2[0] == tz : t2[1] == tz);
|
|
411
|
+
if (!t) throw new Error(`Unknown timezone: ${tz}`);
|
|
412
|
+
date = adjustTz(date, t[1]);
|
|
413
|
+
const tokens = {
|
|
414
|
+
"YYYY": date.getFullYear().toString(),
|
|
415
|
+
"YY": date.getFullYear().toString().slice(2),
|
|
416
|
+
"MMMM": month(date.getMonth()),
|
|
417
|
+
"MMM": month(date.getMonth()).slice(0, 3),
|
|
418
|
+
"MM": (date.getMonth() + 1).toString().padStart(2, "0"),
|
|
419
|
+
"M": (date.getMonth() + 1).toString(),
|
|
420
|
+
"DDD": doy(date).toString(),
|
|
421
|
+
"DD": date.getDate().toString().padStart(2, "0"),
|
|
422
|
+
"Do": suffix(date.getDate()),
|
|
423
|
+
"D": date.getDate().toString(),
|
|
424
|
+
"dddd": day(date.getDay()),
|
|
425
|
+
"ddd": day(date.getDay()).slice(0, 3),
|
|
426
|
+
"HH": date.getHours().toString().padStart(2, "0"),
|
|
427
|
+
"H": date.getHours().toString(),
|
|
428
|
+
"hh": (date.getHours() % 12 || 12).toString().padStart(2, "0"),
|
|
429
|
+
"h": (date.getHours() % 12 || 12).toString(),
|
|
430
|
+
"mm": date.getMinutes().toString().padStart(2, "0"),
|
|
431
|
+
"m": date.getMinutes().toString(),
|
|
432
|
+
"ss": date.getSeconds().toString().padStart(2, "0"),
|
|
433
|
+
"s": date.getSeconds().toString(),
|
|
434
|
+
"SSS": date.getMilliseconds().toString().padStart(3, "0"),
|
|
435
|
+
"A": date.getHours() >= 12 ? "PM" : "AM",
|
|
436
|
+
"a": date.getHours() >= 12 ? "pm" : "am",
|
|
437
|
+
"ZZ": tzOffset(t[1] * 60).replace(":", ""),
|
|
438
|
+
"Z": tzOffset(t[1] * 60),
|
|
439
|
+
"z": typeof tz == "string" ? tz : t[0]
|
|
440
|
+
};
|
|
441
|
+
return format.replace(/YYYY|YY|MMMM|MMM|MM|M|DDD|DD|Do|D|dddd|ddd|HH|H|hh|h|mm|m|ss|s|SSS|A|a|ZZ|Z|z/g, (token) => tokens[token]);
|
|
442
|
+
}
|
|
336
443
|
function downloadFile(blob, name) {
|
|
337
444
|
if (!(blob instanceof Blob)) blob = new Blob(makeArray(blob));
|
|
338
445
|
const url = URL.createObjectURL(blob);
|
|
@@ -364,7 +471,7 @@ function fileBrowser(options = {}) {
|
|
|
364
471
|
}
|
|
365
472
|
function timestampFilename(name, date = /* @__PURE__ */ new Date()) {
|
|
366
473
|
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
367
|
-
const timestamp =
|
|
474
|
+
const timestamp = formatDate("YYYY-MM-DD_HH:mm:ss", date);
|
|
368
475
|
return timestamp;
|
|
369
476
|
}
|
|
370
477
|
function uploadWithProgress(options) {
|
|
@@ -982,6 +1089,10 @@ class Api extends Http {
|
|
|
982
1089
|
if (token) this.token = token;
|
|
983
1090
|
}
|
|
984
1091
|
}
|
|
1092
|
+
get sameOrigin() {
|
|
1093
|
+
if (typeof window == "undefined" || !(window == null ? void 0 : window.location)) return false;
|
|
1094
|
+
return window.location.host == this.host;
|
|
1095
|
+
}
|
|
985
1096
|
/** Current API token */
|
|
986
1097
|
get token() {
|
|
987
1098
|
return this._token;
|
|
@@ -1015,7 +1126,7 @@ class Api extends Http {
|
|
|
1015
1126
|
const key = JSONSanitize(options);
|
|
1016
1127
|
const method = options.method == "GET" ? "r" : options.method == "POST" ? "c" : options.method == "DELETE" ? "d" : "u";
|
|
1017
1128
|
if (this.pending[key] != null) return this.pending[key];
|
|
1018
|
-
this.pending[key] = super.request(options).then((response) => {
|
|
1129
|
+
this.pending[key] = super.request({ ...options, credentials: "include" }).then((response) => {
|
|
1019
1130
|
this.emit(PES`api/response:${method}`, { request: options, response });
|
|
1020
1131
|
return options.decode === false ? response : response.data;
|
|
1021
1132
|
}).catch((err) => {
|
|
@@ -1159,6 +1270,13 @@ class Ai extends PathEventEmitter {
|
|
|
1159
1270
|
return resp;
|
|
1160
1271
|
});
|
|
1161
1272
|
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Get model info
|
|
1275
|
+
* @return {Promise<{host: string, model: string}>} Model Info
|
|
1276
|
+
*/
|
|
1277
|
+
info() {
|
|
1278
|
+
return this.api.request({ url: "/api/ai/info" });
|
|
1279
|
+
}
|
|
1162
1280
|
}
|
|
1163
1281
|
class Analytics extends PathEventEmitter {
|
|
1164
1282
|
constructor(api) {
|
|
@@ -1382,6 +1500,7 @@ class Auth extends PathEventEmitter {
|
|
|
1382
1500
|
logout() {
|
|
1383
1501
|
this.emit(PES`auth/logout:d`, this.user);
|
|
1384
1502
|
this.api.token = null;
|
|
1503
|
+
this.api.request({ url: "/api/auth/logout", method: "DELETE" });
|
|
1385
1504
|
this.user = null;
|
|
1386
1505
|
}
|
|
1387
1506
|
/**
|
|
@@ -1393,8 +1512,10 @@ class Auth extends PathEventEmitter {
|
|
|
1393
1512
|
var _a;
|
|
1394
1513
|
if (!user.username || !user.password) throw new Error("Cannot register user, missing username or password");
|
|
1395
1514
|
const u = await this.api.request({ url: "/api/auth/register", body: { ...user } });
|
|
1396
|
-
if ((_a = u == null ? void 0 : u.image) == null ? void 0 : _a.startsWith("/")) u.image = `${this.api.url}${u.image}?token=${this.api.token}`;
|
|
1397
|
-
this.
|
|
1515
|
+
if ((_a = u == null ? void 0 : u.image) == null ? void 0 : _a.startsWith("/")) u.image = `${this.api.url}${u.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1516
|
+
this.user = u;
|
|
1517
|
+
this.permissions = [];
|
|
1518
|
+
this.emit(PES`auth/register:u`, u);
|
|
1398
1519
|
return u;
|
|
1399
1520
|
}
|
|
1400
1521
|
reset(emailOrPass, token) {
|
|
@@ -1425,7 +1546,7 @@ class Auth extends PathEventEmitter {
|
|
|
1425
1546
|
this.emit(PES`auth/session:r`, session);
|
|
1426
1547
|
if (set) {
|
|
1427
1548
|
this.api.token = token;
|
|
1428
|
-
if (session == null ? void 0 : session.user) session.user.image = `${this.api.url}${session.user.image}?token=${this.api.token}`;
|
|
1549
|
+
if (session == null ? void 0 : session.user) session.user.image = `${this.api.url}${session.user.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
1429
1550
|
this.user = (session == null ? void 0 : session.user) || null;
|
|
1430
1551
|
this.permissions = (session == null ? void 0 : session.permissions) || [];
|
|
1431
1552
|
if (session) this.emit(PES`auth/login:c`, session.user);
|
|
@@ -1527,7 +1648,7 @@ class Client extends PathEventEmitter {
|
|
|
1527
1648
|
if (!this.settings.cache.keys().length) opts.reload = true;
|
|
1528
1649
|
let settings = await (opts.reload ? this.settings.all(false, true) : this.settings.cache);
|
|
1529
1650
|
if (opts.reload == null) this.settings.all(false, true).then(() => this.init({ reload: false }));
|
|
1530
|
-
if (settings["title"]) document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = settings["title"]);
|
|
1651
|
+
if (settings["title"]) document.querySelectorAll(".momentum-title").forEach((el) => el.innerText = el.innerText.includes("|") ? `${el.innerText.split("|")[0].trim()} | ${settings["title"]}` : settings["title"]);
|
|
1531
1652
|
if (settings["description"]) document.querySelectorAll(".momentum-description").forEach((el) => el.innerText = settings["description"]);
|
|
1532
1653
|
if (settings["version"]) document.querySelectorAll(".momentum-version").forEach((el) => el.innerText = settings["version"]);
|
|
1533
1654
|
if (settings["logo"]) document.querySelectorAll(".momentum-logo").forEach((el) => el.src = settings["logo"]);
|
|
@@ -1803,7 +1924,7 @@ class Data extends PathEventEmitter {
|
|
|
1803
1924
|
}
|
|
1804
1925
|
raw(collection, query) {
|
|
1805
1926
|
if (!collection || !query) throw new Error("Cannot execute raw query, missing collection or query");
|
|
1806
|
-
const mode = query.operand.startsWith("find") ? "r" : query.operand == "
|
|
1927
|
+
const mode = query.operand.startsWith("find") ? "r" : query.operand == "insertOne" ? "c" : query.operand.startsWith("delete") ? "d" : "u";
|
|
1807
1928
|
return this.api.request({ url: `/api/` + PES`data/${collection}` + "?raw", body: query }).then((resp) => {
|
|
1808
1929
|
this.emit(PES`data/${collection}:${mode}`, resp);
|
|
1809
1930
|
return resp;
|
|
@@ -1998,7 +2119,7 @@ class Logger extends PathEventEmitter {
|
|
|
1998
2119
|
if (LOG_LEVEL[logLevel] >= 0) {
|
|
1999
2120
|
console.error = (...args) => {
|
|
2000
2121
|
this.console.error(...args);
|
|
2001
|
-
this.error(
|
|
2122
|
+
this.error(args);
|
|
2002
2123
|
};
|
|
2003
2124
|
window.addEventListener("unhandledrejection", async (event) => {
|
|
2004
2125
|
var _a, _b, _c, _d;
|
|
@@ -2013,25 +2134,25 @@ ${log}`;
|
|
|
2013
2134
|
if (LOG_LEVEL[logLevel] >= 1) {
|
|
2014
2135
|
console.warn = (...args) => {
|
|
2015
2136
|
this.console.warn(...args);
|
|
2016
|
-
this.warn(
|
|
2137
|
+
this.warn(args);
|
|
2017
2138
|
};
|
|
2018
2139
|
}
|
|
2019
2140
|
if (LOG_LEVEL[logLevel] >= 2) {
|
|
2020
2141
|
console.info = (...args) => {
|
|
2021
2142
|
this.console.info(...args);
|
|
2022
|
-
this.info(
|
|
2143
|
+
this.info(args);
|
|
2023
2144
|
};
|
|
2024
2145
|
}
|
|
2025
2146
|
if (LOG_LEVEL[logLevel] >= 3) {
|
|
2026
2147
|
console.log = (...args) => {
|
|
2027
2148
|
this.console.log(...args);
|
|
2028
|
-
this.log(
|
|
2149
|
+
this.log(args);
|
|
2029
2150
|
};
|
|
2030
2151
|
}
|
|
2031
2152
|
if (LOG_LEVEL[logLevel] >= 4) {
|
|
2032
2153
|
console.debug = (...args) => {
|
|
2033
2154
|
this.console.debug(...args);
|
|
2034
|
-
this.debug(
|
|
2155
|
+
this.debug(args);
|
|
2035
2156
|
};
|
|
2036
2157
|
}
|
|
2037
2158
|
}
|
|
@@ -2321,14 +2442,15 @@ const _Socket = class _Socket {
|
|
|
2321
2442
|
this.connect();
|
|
2322
2443
|
}, _Socket.pollingSpeed);
|
|
2323
2444
|
}
|
|
2324
|
-
handle(
|
|
2325
|
-
|
|
2445
|
+
handle(message) {
|
|
2446
|
+
const data = JSONAttemptParse(message.data);
|
|
2447
|
+
if (data.event) data.event = new PathEvent(data.event);
|
|
2448
|
+
console.log(data);
|
|
2326
2449
|
}
|
|
2327
|
-
send(
|
|
2450
|
+
send(event, payload) {
|
|
2328
2451
|
var _a;
|
|
2329
2452
|
(_a = this.connection) == null ? void 0 : _a.send(JSON.stringify({
|
|
2330
|
-
|
|
2331
|
-
channel,
|
|
2453
|
+
event: new PathEvent(event).toString(),
|
|
2332
2454
|
payload
|
|
2333
2455
|
}));
|
|
2334
2456
|
}
|
|
@@ -2374,7 +2496,7 @@ let Storage$1 = class Storage2 extends PathEventEmitter {
|
|
|
2374
2496
|
}
|
|
2375
2497
|
open(path, target = "_blank") {
|
|
2376
2498
|
if (!path) throw new Error("Cannot download file, missing path");
|
|
2377
|
-
const link = `${this.api.url}/api/` + PES`${this.path}/${path}
|
|
2499
|
+
const link = `${this.api.url}/api/` + PES`${this.path}/${path}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
2378
2500
|
if (!target) return link;
|
|
2379
2501
|
this.emit(PES`${this.path}/${path}:r`, path);
|
|
2380
2502
|
return window.open(link, target);
|
|
@@ -2423,7 +2545,7 @@ class Users extends PathEventEmitter {
|
|
|
2423
2545
|
if (!reload && this.cache.complete) return this.cache.all();
|
|
2424
2546
|
return this.api.request({ url: "/api/" + PES`users` }).then((resp) => {
|
|
2425
2547
|
resp == null ? void 0 : resp.forEach((r) => {
|
|
2426
|
-
r.image = this.api.url
|
|
2548
|
+
r.image = `${this.api.url}${r.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
2427
2549
|
return r;
|
|
2428
2550
|
});
|
|
2429
2551
|
this.cache.addAll(resp);
|
|
@@ -2446,7 +2568,7 @@ class Users extends PathEventEmitter {
|
|
|
2446
2568
|
if (!reload && this.cache.get(username)) return this.cache.get(username);
|
|
2447
2569
|
return this.api.request({ url: "/api/" + PES`users/${username}` }).then((resp) => {
|
|
2448
2570
|
if (resp) {
|
|
2449
|
-
resp.image = this.api.url
|
|
2571
|
+
resp.image = `${this.api.url}${resp.image}${!this.api.sameOrigin && this.api.token ? `?token=${this.api.token}` : ""}`;
|
|
2450
2572
|
this.cache.add(resp);
|
|
2451
2573
|
}
|
|
2452
2574
|
this.emit(PES`users/${username}:r`, resp);
|
package/dist/sockets.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PathEvent } from '@ztimson/utils';
|
|
1
2
|
import { Api } from './api';
|
|
2
3
|
export declare class Socket {
|
|
3
4
|
static readonly pollingSpeed = 30000;
|
|
@@ -9,6 +10,6 @@ export declare class Socket {
|
|
|
9
10
|
close(): void;
|
|
10
11
|
connect(): void;
|
|
11
12
|
private handle;
|
|
12
|
-
send(
|
|
13
|
+
send(event: string | PathEvent, payload?: any): void;
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=sockets.d.ts.map
|
package/dist/sockets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sockets.d.ts","sourceRoot":"","sources":["../src/sockets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,qBAAa,MAAM;IAClB,MAAM,CAAC,QAAQ,CAAC,YAAY,SAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;IAE3B,QAAQ,CAAC,GAAG,EAAG,MAAM,CAAC;IAEtB,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,IAAI,UAAS;gBAED,GAAG,EAAE,GAAG,GAAG,MAAM;IAO7B,KAAK;IAOL,OAAO;IAmBP,OAAO,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"sockets.d.ts","sourceRoot":"","sources":["../src/sockets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,qBAAa,MAAM;IAClB,MAAM,CAAC,QAAQ,CAAC,YAAY,SAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;IAE3B,QAAQ,CAAC,GAAG,EAAG,MAAM,CAAC;IAEtB,OAAO,CAAC,UAAU,CAAC,CAAY;IAE/B,IAAI,UAAS;gBAED,GAAG,EAAE,GAAG,GAAG,MAAM;IAO7B,KAAK;IAOL,OAAO;IAmBP,OAAO,CAAC,MAAM;IAMd,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG;CAM7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ztimson/momentum",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.2",
|
|
4
4
|
"description": "Client library for momentum",
|
|
5
5
|
"keywords": ["Momentum"],
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"module": "dist/index.mjs",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"typings": "dist/index.d.ts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"build-models": "./bin/build-models.mjs"
|
|
17
|
+
},
|
|
15
18
|
"exports": {
|
|
16
19
|
"import": "./dist/index.mjs",
|
|
17
20
|
"require": "./dist/index.cjs",
|
|
@@ -21,10 +24,11 @@
|
|
|
21
24
|
"start": "vite build --watch",
|
|
22
25
|
"prebuild": "node -e \"const fs=require('fs');fs.cpSync('../README.md','./README.md')\"",
|
|
23
26
|
"build": "tsc && vite build",
|
|
27
|
+
"build-models": "node --no-warnings ./bin/build-models.mjs",
|
|
24
28
|
"postbuild": "node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.cjs','../server/public/momentum.js');fs.cpSync('dist/momentum.worker.js','../server/public/momentum.worker.js')\""
|
|
25
29
|
},
|
|
26
30
|
"dependencies": {
|
|
27
|
-
"@ztimson/utils": "0.23.
|
|
31
|
+
"@ztimson/utils": "0.23.15",
|
|
28
32
|
"var-persist": "^1.0.1"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|