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