@ztimson/momentum 0.0.0 → 0.14.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/dist/actions.d.ts +52 -51
- package/dist/api.d.ts +22 -21
- package/dist/auth.d.ts +61 -60
- package/dist/core.d.ts +7 -7
- package/dist/data.d.ts +21 -20
- package/dist/email.d.ts +22 -21
- package/dist/groups.d.ts +20 -19
- package/dist/index.d.ts +14 -14
- package/dist/logger.d.ts +53 -52
- package/dist/momentum.cjs.map +1 -1
- package/dist/momentum.d.ts +35 -34
- package/dist/momentum.mjs.map +1 -1
- package/dist/settings.d.ts +44 -43
- package/dist/sockets.d.ts +14 -13
- package/dist/static.d.ts +16 -15
- package/dist/storage.d.ts +39 -38
- package/dist/users.d.ts +23 -22
- package/package.json +1 -1
package/dist/actions.d.ts
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
import { Meta } from './core';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { TypedEmitter, XhrOptions, TypedEvents } from '@ztimson/utils';
|
|
4
|
+
import { Api } from './api';
|
|
5
|
+
|
|
6
|
+
export type Action = Meta & {
|
|
7
|
+
name: string;
|
|
8
|
+
trigger: {
|
|
9
|
+
type: ActionType;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
system: boolean;
|
|
13
|
+
fn: string;
|
|
14
|
+
notes: string;
|
|
15
|
+
lastRun: number;
|
|
16
|
+
};
|
|
17
|
+
export type ActionResponse = {
|
|
18
|
+
action: string;
|
|
19
|
+
stdout: any[];
|
|
20
|
+
stderr: any[];
|
|
21
|
+
return?: any;
|
|
22
|
+
};
|
|
23
|
+
export declare enum ActionType {
|
|
24
|
+
'DISABLED' = 0,
|
|
25
|
+
'CRON' = 1,
|
|
26
|
+
'EVENT' = 2,
|
|
27
|
+
'GET' = 3,
|
|
28
|
+
'POST' = 4,
|
|
29
|
+
'PATCH' = 5,
|
|
30
|
+
'PUT' = 6,
|
|
31
|
+
'DELETE' = 7
|
|
32
|
+
}
|
|
33
|
+
export type ActionEvents = TypedEvents & {
|
|
34
|
+
LIST: (actions: Action[]) => any;
|
|
35
|
+
DELETE: (id: string) => any;
|
|
36
|
+
READ: (action: Action | null) => any;
|
|
37
|
+
UPDATE: (action: Action) => any;
|
|
38
|
+
EXECUTE: (action: Action, resp: any) => any;
|
|
39
|
+
};
|
|
40
|
+
export declare class Actions extends TypedEmitter<ActionEvents> {
|
|
41
|
+
private readonly api;
|
|
42
|
+
$cache: BehaviorSubject<Action[]>;
|
|
43
|
+
get cache(): Action[];
|
|
44
|
+
set cache(val: Action[]);
|
|
45
|
+
constructor(api: Api | string);
|
|
46
|
+
delete(id: string): Promise<void>;
|
|
47
|
+
list(): Promise<Action[]>;
|
|
48
|
+
read(id: string, reload?: boolean): Promise<Action | null>;
|
|
49
|
+
run<T>(path: string, opts?: XhrOptions): Promise<T>;
|
|
50
|
+
runById(action: string | Action, opts?: XhrOptions): Promise<ActionResponse>;
|
|
51
|
+
update(action: Action): Promise<Action>;
|
|
52
|
+
}
|
|
52
53
|
//# sourceMappingURL=actions.d.ts.map
|
package/dist/api.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { TypedEvents, RequestOptions, XHR, XhrOptions } from '@ztimson/utils';
|
|
2
|
+
|
|
3
|
+
export type ApiEvents = TypedEvents & {
|
|
4
|
+
REQUEST: (request: Promise<any>, options: RequestOptions) => any;
|
|
5
|
+
RESPONSE: (response: any, options: RequestOptions) => any;
|
|
6
|
+
REJECTED: (response: Error, options: RequestOptions) => any;
|
|
7
|
+
TOKEN: (token: string | null) => any;
|
|
8
|
+
};
|
|
9
|
+
export declare class Api extends XHR {
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly opts: XhrOptions;
|
|
12
|
+
private emitter;
|
|
13
|
+
private _token;
|
|
14
|
+
get token(): string | null;
|
|
15
|
+
set token(token: string | null);
|
|
16
|
+
constructor(url?: string, opts?: XhrOptions);
|
|
17
|
+
emit: <K extends string | symbol>(event: K, ...args: Parameters<ApiEvents[K]>) => void;
|
|
18
|
+
off: <K extends string | symbol = string>(event: K, listener: ApiEvents[K]) => void;
|
|
19
|
+
on: <K extends string | symbol = string>(event: K, listener: ApiEvents[K]) => () => void;
|
|
20
|
+
once: <K extends string | symbol = string>(event: K, listener?: ApiEvents[K] | undefined) => Promise<any>;
|
|
21
|
+
request<T>(options: RequestOptions): Promise<T>;
|
|
22
|
+
}
|
|
22
23
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,61 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
private readonly
|
|
40
|
-
private readonly
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
reset(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
1
|
+
import { TypedEmitter, TypedEvents } from '@ztimson/utils';
|
|
2
|
+
import { Meta } from './core';
|
|
3
|
+
import { Api } from './api';
|
|
4
|
+
import { BehaviorSubject } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
export type Group = Meta & {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
notes?: string;
|
|
10
|
+
users: string[];
|
|
11
|
+
permissions: string[];
|
|
12
|
+
extra: any;
|
|
13
|
+
};
|
|
14
|
+
export type User = Meta & {
|
|
15
|
+
username: string;
|
|
16
|
+
name: string;
|
|
17
|
+
email: string;
|
|
18
|
+
image?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
groups?: string[];
|
|
21
|
+
permissions?: string[];
|
|
22
|
+
notes?: string;
|
|
23
|
+
extra: any;
|
|
24
|
+
lastLogin?: number | null;
|
|
25
|
+
};
|
|
26
|
+
export type AuthEvents = TypedEvents & {
|
|
27
|
+
USER: (user: User | null) => any;
|
|
28
|
+
LOGIN: (user: User) => any;
|
|
29
|
+
LOGOUT: () => any;
|
|
30
|
+
REGISTER: (user: Partial<User>) => any;
|
|
31
|
+
RESET_REQUEST: (email: string) => any;
|
|
32
|
+
RESET_COMPLETE: (token: string) => any;
|
|
33
|
+
};
|
|
34
|
+
export type AuthOptions = {
|
|
35
|
+
loginUi?: string;
|
|
36
|
+
persist?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare class Auth extends TypedEmitter<AuthEvents> {
|
|
39
|
+
private readonly opts?;
|
|
40
|
+
private readonly api;
|
|
41
|
+
private readonly storageKey;
|
|
42
|
+
$user: BehaviorSubject<User | null | undefined>;
|
|
43
|
+
get user(): User | null | undefined;
|
|
44
|
+
set user(user: User | null | undefined);
|
|
45
|
+
constructor(api: Api | string, opts?: AuthOptions | undefined);
|
|
46
|
+
knownHost(host?: string): Promise<void>;
|
|
47
|
+
login(username: string, password: string): Promise<User | null>;
|
|
48
|
+
loginRedirect(host?: string): Promise<string>;
|
|
49
|
+
logout(): void;
|
|
50
|
+
register(user: Partial<User> & {
|
|
51
|
+
username: string;
|
|
52
|
+
password: string;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
reset(password: string, token?: string): Promise<void>;
|
|
55
|
+
reset(email: string): Promise<void>;
|
|
56
|
+
whoAmI(token?: string, set?: boolean): Promise<{
|
|
57
|
+
token: string;
|
|
58
|
+
user: User;
|
|
59
|
+
permissions: string[];
|
|
60
|
+
} | null>;
|
|
61
|
+
}
|
|
61
62
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/core.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type Meta = {
|
|
2
|
-
_id?: string | any;
|
|
3
|
-
_createdBy: string;
|
|
4
|
-
_createdDate: number;
|
|
5
|
-
_updatedBy: string;
|
|
6
|
-
_updatedDate: number;
|
|
7
|
-
};
|
|
1
|
+
export type Meta = {
|
|
2
|
+
_id?: string | any;
|
|
3
|
+
_createdBy: string;
|
|
4
|
+
_createdDate: number;
|
|
5
|
+
_updatedBy: string;
|
|
6
|
+
_updatedDate: number;
|
|
7
|
+
};
|
|
8
8
|
//# sourceMappingURL=core.d.ts.map
|
package/dist/data.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get<T extends Meta>(collection: string
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
1
|
+
import { TypedEmitter, TypedEvents } from '@ztimson/utils';
|
|
2
|
+
import { Meta } from './core';
|
|
3
|
+
import { Api } from './api';
|
|
4
|
+
|
|
5
|
+
export type DataEvents = TypedEvents & {
|
|
6
|
+
DELETE: (collection: string, document: string) => any;
|
|
7
|
+
GET: (collection: string, documents: any) => any;
|
|
8
|
+
RAW: (collection: string, response: any) => any;
|
|
9
|
+
SET: (collection: string, document: any) => any;
|
|
10
|
+
};
|
|
11
|
+
export declare class Data extends TypedEmitter<DataEvents> {
|
|
12
|
+
private readonly api;
|
|
13
|
+
constructor(api: Api | string);
|
|
14
|
+
delete(collection: string, document: string): Promise<void>;
|
|
15
|
+
get<T extends Meta>(collection: string): Promise<T[]>;
|
|
16
|
+
get<T extends Meta>(collection: string, document: string): Promise<T>;
|
|
17
|
+
raw<T>(collection: string, operand: string, query: any, options: any): Promise<T>;
|
|
18
|
+
set<T extends Meta>(collection: string, document: Partial<T> & {
|
|
19
|
+
_id?: string;
|
|
20
|
+
}, append?: boolean): Promise<T>;
|
|
21
|
+
}
|
|
21
22
|
//# sourceMappingURL=data.d.ts.map
|
package/dist/email.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { TypedEmitter, TypedEvents } from '@ztimson/utils';
|
|
2
|
+
import { Api } from './api';
|
|
3
|
+
|
|
4
|
+
export type MailTemplate = {
|
|
5
|
+
template: string;
|
|
6
|
+
data?: any;
|
|
7
|
+
};
|
|
8
|
+
export type Mail = {
|
|
9
|
+
to: string | string[];
|
|
10
|
+
cc?: string[];
|
|
11
|
+
bcc?: string[];
|
|
12
|
+
subject?: string;
|
|
13
|
+
body: string | MailTemplate;
|
|
14
|
+
};
|
|
15
|
+
export type EmailEvents = TypedEvents & {
|
|
16
|
+
SENT: (email: Mail) => any;
|
|
17
|
+
};
|
|
18
|
+
export declare class Email extends TypedEmitter<EmailEvents> {
|
|
19
|
+
private readonly api;
|
|
20
|
+
constructor(api: Api | string);
|
|
21
|
+
send(email: Mail): Promise<unknown>;
|
|
22
|
+
}
|
|
22
23
|
//# sourceMappingURL=email.d.ts.map
|
package/dist/groups.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { TypedEmitter, TypedEvents } from '@ztimson/utils';
|
|
2
|
+
import { Group } from './auth';
|
|
3
|
+
import { Api } from './api';
|
|
4
|
+
|
|
5
|
+
export type GroupEvents = TypedEvents & {
|
|
6
|
+
LIST: (users: Group[]) => any;
|
|
7
|
+
CREATE: (user: Group) => any;
|
|
8
|
+
READ: (user: Group) => any;
|
|
9
|
+
UPDATE: (user: Group) => any;
|
|
10
|
+
DELETE: (name: string) => any;
|
|
11
|
+
};
|
|
12
|
+
export declare class Groups extends TypedEmitter<GroupEvents> {
|
|
13
|
+
private readonly api;
|
|
14
|
+
constructor(api: Api | string);
|
|
15
|
+
create(group: Group): Promise<Group>;
|
|
16
|
+
list(): Promise<Group[]>;
|
|
17
|
+
read(name: string): Promise<Group>;
|
|
18
|
+
update(group: Group): Promise<Group>;
|
|
19
|
+
delete(name: string): Promise<void>;
|
|
20
|
+
}
|
|
20
21
|
//# sourceMappingURL=groups.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from './actions';
|
|
2
|
-
export * from './api';
|
|
3
|
-
export * from './auth';
|
|
4
|
-
export * from './core';
|
|
5
|
-
export * from './data';
|
|
6
|
-
export * from './email';
|
|
7
|
-
export * from './groups';
|
|
8
|
-
export * from './logger';
|
|
9
|
-
export * from './momentum';
|
|
10
|
-
export * from './settings';
|
|
11
|
-
export * from './sockets';
|
|
12
|
-
export * from './static';
|
|
13
|
-
export * from './storage';
|
|
14
|
-
export * from './users';
|
|
1
|
+
export * from './actions';
|
|
2
|
+
export * from './api';
|
|
3
|
+
export * from './auth';
|
|
4
|
+
export * from './core';
|
|
5
|
+
export * from './data';
|
|
6
|
+
export * from './email';
|
|
7
|
+
export * from './groups';
|
|
8
|
+
export * from './logger';
|
|
9
|
+
export * from './momentum';
|
|
10
|
+
export * from './settings';
|
|
11
|
+
export * from './sockets';
|
|
12
|
+
export * from './static';
|
|
13
|
+
export * from './storage';
|
|
14
|
+
export * from './users';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import { LOG_LEVEL } from '@ztimson/utils';
|
|
2
|
+
import { Api } from './api';
|
|
3
|
+
|
|
4
|
+
export type LogLevel = 'ERROR' | 'WARN' | 'INFO' | 'LOG' | 'DEBUG' | 'NONE';
|
|
5
|
+
export type Log<T> = {
|
|
6
|
+
time: number;
|
|
7
|
+
level: LOG_LEVEL;
|
|
8
|
+
log: any[];
|
|
9
|
+
ctx?: T;
|
|
10
|
+
};
|
|
11
|
+
export type ClientLog = Log<{
|
|
12
|
+
url: string;
|
|
13
|
+
user: string;
|
|
14
|
+
ip: string;
|
|
15
|
+
res: [number, number];
|
|
16
|
+
ua: string | {
|
|
17
|
+
ua: string;
|
|
18
|
+
browser: {
|
|
19
|
+
name: string;
|
|
20
|
+
version: string;
|
|
21
|
+
major: string;
|
|
22
|
+
};
|
|
23
|
+
cpu: {
|
|
24
|
+
architecture: string;
|
|
25
|
+
};
|
|
26
|
+
device: {
|
|
27
|
+
mode?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
};
|
|
30
|
+
engine: {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
os: {
|
|
35
|
+
name: string;
|
|
36
|
+
version: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
export declare class Logger {
|
|
41
|
+
private readonly api;
|
|
42
|
+
constructor(api: Api | string, logLevel?: LogLevel | null);
|
|
43
|
+
private buildLog;
|
|
44
|
+
clearClientLogs(): Promise<ClientLog[]>;
|
|
45
|
+
clearServerLogs(): Promise<ClientLog[]>;
|
|
46
|
+
clientLogs(length?: number, page?: number): Promise<ClientLog[]>;
|
|
47
|
+
serverLogs(length?: number, page?: number): Promise<Log<any>[]>;
|
|
48
|
+
debug(...logs: any[]): Promise<unknown>;
|
|
49
|
+
log(...logs: any[]): Promise<unknown>;
|
|
50
|
+
info(...logs: any[]): Promise<unknown>;
|
|
51
|
+
warn(...logs: any[]): Promise<unknown>;
|
|
52
|
+
error(...logs: any[]): Promise<unknown>;
|
|
53
|
+
}
|
|
53
54
|
//# sourceMappingURL=logger.d.ts.map
|