@ztimson/momentum 0.27.4 → 0.28.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/dist/logger.d.ts CHANGED
@@ -42,14 +42,14 @@ export declare class Logger {
42
42
  private readonly api;
43
43
  constructor(api: Api | string, logLevel?: LogLevel | null);
44
44
  private buildLog;
45
- clearClientLogs(): import("@ztimson/utils").PromiseProgress<import("@ztimson/utils").DecodedResponse<ClientLog[]>>;
46
- clearServerLogs(): import("@ztimson/utils").PromiseProgress<import("@ztimson/utils").DecodedResponse<ClientLog[]>>;
45
+ clearClientLogs(): import('@ztimson/utils').PromiseProgress<ClientLog[]>;
46
+ clearServerLogs(): import('@ztimson/utils').PromiseProgress<ClientLog[]>;
47
47
  clientLogs(length?: number, page?: number): Promise<ClientLog[]>;
48
48
  serverLogs(length?: number, page?: number): Promise<Log<any>[]>;
49
- debug(...logs: any[]): import("@ztimson/utils").PromiseProgress<any>;
50
- log(...logs: any[]): import("@ztimson/utils").PromiseProgress<any>;
51
- info(...logs: any[]): import("@ztimson/utils").PromiseProgress<any>;
52
- warn(...logs: any[]): import("@ztimson/utils").PromiseProgress<any>;
53
- error(...logs: any[]): import("@ztimson/utils").PromiseProgress<any>;
49
+ debug(...logs: any[]): import('@ztimson/utils').PromiseProgress<any>;
50
+ log(...logs: any[]): import('@ztimson/utils').PromiseProgress<any>;
51
+ info(...logs: any[]): import('@ztimson/utils').PromiseProgress<any>;
52
+ warn(...logs: any[]): import('@ztimson/utils').PromiseProgress<any>;
53
+ error(...logs: any[]): import('@ztimson/utils').PromiseProgress<any>;
54
54
  }
55
55
  //# sourceMappingURL=logger.d.ts.map
@@ -1,18 +1,19 @@
1
1
  import { Actions } from './actions';
2
- import { Api, type ApiEvents } from './api';
3
- import { Auth, type AuthEvents, AuthOptions } from './auth';
4
- import { Data, type DataEvents } from './data';
5
- import { Email, type EmailEvents } from './email';
2
+ import { Api, ApiEvents } from './api';
3
+ import { Auth, AuthEvents, AuthOptions } from './auth';
4
+ import { Data, DataEvents } from './data';
5
+ import { Email, EmailEvents } from './email';
6
6
  import { Groups } from './groups';
7
- import { TypedEmitter, type TypedEvents, type HttpRequestOptions } from '@ztimson/utils';
7
+ import { TypedEmitter, TypedEvents, HttpRequestOptions } from '@ztimson/utils';
8
8
  import { Logger, LogLevel } from './logger';
9
9
  import { Payments } from './payments';
10
- import { Pdf, type PdfEvents } from './pdf';
10
+ import { Pdf, PdfEvents } from './pdf';
11
11
  import { Socket } from './sockets';
12
- import { Storage, type StorageEvents } from './storage';
12
+ import { Storage, StorageEvents } from './storage';
13
+ import { UI } from './ui';
13
14
  import { Users } from './users';
14
- import { Settings, type SettingEvents } from './settings';
15
- import { Static, type StaticEvents } from './static';
15
+ import { Settings, SettingEvents } from './settings';
16
+ import { Static, StaticEvents } from './static';
16
17
  export type MomentumEvents = TypedEvents & ApiEvents & AuthEvents & DataEvents & EmailEvents & PdfEvents & StaticEvents & StorageEvents & SettingEvents;
17
18
  export type MomentumOptions = AuthOptions & {
18
19
  logLevel?: LogLevel;
@@ -34,6 +35,7 @@ export declare class Momentum extends TypedEmitter<MomentumEvents> {
34
35
  socket?: Socket;
35
36
  static: Static;
36
37
  storage: Storage;
38
+ ui: UI;
37
39
  users: Users;
38
40
  constructor(url?: string, opts?: MomentumOptions);
39
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"momentum.d.ts","sourceRoot":"","sources":["../src/momentum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,GAAG,EAAE,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,IAAI,EAAE,KAAK,UAAU,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAC,IAAI,EAAE,KAAK,UAAU,EAAC,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAC,KAAK,EAAE,KAAK,WAAW,EAAC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AO,EAAC,QAAQ,EAAE,KAAK,aAAa,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EAAC,MAAM,EAAE,KAAK,YAAY,EAAC,MAAM,UAAU,CAAC;AAEnD,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,aAAa,CAAC;AAExJ,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC3C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,kBAAkB,CAAC;CACzB,CAAA;AAED,qBAAa,QAAS,SAAQ,YAAY,CAAC,cAAc,CAAC;IACzD,GAAG,EAAG,GAAG,CAAC;IACV,OAAO,EAAG,OAAO,CAAC;IAClB,IAAI,EAAG,IAAI,CAAC;IACZ,IAAI,EAAG,IAAI,CAAC;IACZ,KAAK,EAAG,KAAK,CAAC;IACd,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,QAAQ,EAAG,QAAQ,CAAC;IACpB,GAAG,EAAG,GAAG,CAAC;IACV,QAAQ,EAAG,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,OAAO,EAAG,OAAO,CAAC;IAClB,EAAE,EAAG,EAAE,CAAC;IACR,KAAK,EAAG,KAAK,CAAC;gBAEF,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe;CA2ChD"}
@@ -1,4 +1,4 @@
1
- import { TypedEmitter, type TypedEvents } from '@ztimson/utils';
1
+ import { TypedEmitter, TypedEvents } from '@ztimson/utils';
2
2
  import { Api } from './api';
3
3
  export type PaymentEvents = TypedEvents & {
4
4
  'CHECKOUT': (amount: number, custom: any) => any;
@@ -10,6 +10,6 @@ export declare class Payments extends TypedEmitter<PaymentEvents> {
10
10
  constructor(api: Api | string, secret: string);
11
11
  private charge;
12
12
  createForm(element: string, amount: number, custom?: any): Promise<() => Promise<any>>;
13
- history(username?: string): Promise<any[] | null>;
13
+ history(username?: string): Promise<any[]>;
14
14
  }
15
15
  //# sourceMappingURL=payments.d.ts.map
package/dist/pdf.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Api } from './api';
2
- import { TypedEmitter, type TypedEvents } from '@ztimson/utils';
2
+ import { TypedEmitter, TypedEvents } from '@ztimson/utils';
3
3
  export type PdfOptions = {
4
4
  download?: boolean;
5
5
  fileName?: string;
@@ -11,8 +11,8 @@ export declare class Pdf extends TypedEmitter<PdfEvents> {
11
11
  private readonly api;
12
12
  constructor(api: Api | string);
13
13
  private handleResponse;
14
- fromHtml(content: string, opts?: PdfOptions): import("@ztimson/utils").PromiseProgress<any>;
15
- fromTemplate(template: string, data: object, opts?: PdfOptions): import("@ztimson/utils").PromiseProgress<any>;
16
- fromUrl(url: string, opts?: PdfOptions): import("@ztimson/utils").PromiseProgress<any>;
14
+ fromHtml(content: string, opts?: PdfOptions): import('@ztimson/utils').PromiseProgress<any>;
15
+ fromTemplate(template: string, data: object, opts?: PdfOptions): import('@ztimson/utils').PromiseProgress<any>;
16
+ fromUrl(url: string, opts?: PdfOptions): import('@ztimson/utils').PromiseProgress<any>;
17
17
  }
18
18
  //# sourceMappingURL=pdf.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { Api } from './api';
2
- import { TypedEmitter, type TypedEvents } from '@ztimson/utils';
2
+ import { TypedEmitter, TypedEvents } from '@ztimson/utils';
3
3
  import { BehaviorSubject } from 'rxjs';
4
4
  /** Momentum variable */
5
5
  export type Setting<T> = {
@@ -23,7 +23,7 @@ export type SettingEvents = TypedEvents & {
23
23
  UPDATE: (variable: Setting<any>) => any;
24
24
  };
25
25
  export declare class Settings extends TypedEmitter<SettingEvents> {
26
- private readonly api;
26
+ readonly api: Api;
27
27
  $cache: BehaviorSubject<{
28
28
  [key: string]: any;
29
29
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,YAAY,EAAE,KAAK,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,MAAM,CAAC;AAErC,wBAAwB;AACxB,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACxB,kBAAkB;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,KAAK,EAAE,CAAC,CAAC;IACT,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACzC,IAAI,EAAE,CAAC,SAAS,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,KAAK,GAAG,CAAC;IAC/C,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,GAAG,CAAC;IAC7B,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,KAAK,GAAG,CAAC;IAC7C,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;CACxC,CAAA;AAED,qBAAa,QAAS,SAAQ,YAAY,CAAC,aAAa,CAAC;IACxD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;IAE3B,MAAM;;OAAiD;IACvD,IAAI,KAAK;;MAAgC;IACzC,IAAI,KAAK,CAAC,GAAG;;KAAA,EAA4B;gBAE7B,GAAG,EAAE,GAAG,GAAG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GAAG,IAAI,KAAK,GAAG,CAAC;IAC7C,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;CACxC,CAAA;AAED,qBAAa,QAAS,SAAQ,YAAY,CAAC,aAAa,CAAC;IACxD,QAAQ,CAAC,GAAG,EAAG,GAAG,CAAC;IAEnB,MAAM;;OAAiD;IACvD,IAAI,KAAK;;MAAgC;IACzC,IAAI,KAAK,CAAC,GAAG;;KAAA,EAA4B;gBAE7B,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,IAAI,CAAC,QAAQ,UAAQ,GAAG,OAAO,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IAQrD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAS7D,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;CAOrD"}
package/dist/static.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Api } from './api';
2
- import { TypedEmitter, type TypedEvents } from '@ztimson/utils';
3
- import { type FileMeta } from './storage';
2
+ import { TypedEmitter, TypedEvents } from '@ztimson/utils';
3
+ import { FileMeta } from './storage';
4
4
  export type StaticEvents = TypedEvents & {
5
5
  LIST: (path: string, response: string[] | FileMeta) => any;
6
6
  DELETE: (path: string) => any;
package/dist/storage.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Api } from './api';
2
- import { type Meta } from './core';
3
- import { PromiseProgress, TypedEmitter, type TypedEvents, HttpRequestOptions } from '@ztimson/utils';
2
+ import { Meta } from './core';
3
+ import { PromiseProgress, TypedEmitter, TypedEvents, HttpRequestOptions } from '@ztimson/utils';
4
4
  export type DirMeta = {
5
5
  children: (DirMeta | FileMeta)[];
6
6
  path: string;
package/dist/ui.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { Settings } from './settings';
2
+ export declare class UI {
3
+ private readonly settings;
4
+ constructor(settings: Settings);
5
+ inject(reload?: boolean): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,qBAAa,EAAE;IAEF,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAEzC,MAAM,CAAC,MAAM,UAAQ;CAkD3B"}
package/dist/users.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Api } from './api';
2
- import { TypedEmitter, type TypedEvents } from '@ztimson/utils';
2
+ import { TypedEmitter, TypedEvents } from '@ztimson/utils';
3
3
  import { BehaviorSubject } from 'rxjs';
4
- import type { Meta } from './core';
4
+ import { Meta } from './core';
5
5
  export type User = Meta & {
6
6
  username: string;
7
7
  name: string;
@@ -34,6 +34,6 @@ export declare class Users extends TypedEmitter<UserEvents> {
34
34
  list(reload?: boolean): Promise<User[]>;
35
35
  read(username: string, reload?: boolean): Promise<User>;
36
36
  update(user: User): Promise<User>;
37
- uploadImage(username: string, file: File): import("@ztimson/utils").PromiseProgress<any>;
37
+ uploadImage(username: string, file: File): import('@ztimson/utils').PromiseProgress<any>;
38
38
  }
39
39
  //# sourceMappingURL=users.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "0.27.4",
3
+ "version": "0.28.2",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": [
6
6
  "Momentum"
@@ -10,27 +10,30 @@
10
10
  "type": "git",
11
11
  "url": "https://git.zakscode.com/ztimson/momentum"
12
12
  },
13
- "main": "dist/index.js",
13
+ "main": "dist/index.cjs",
14
14
  "module": "dist/index.mjs",
15
15
  "types": "dist/index.d.ts",
16
16
  "typings": "dist/index.d.ts",
17
17
  "exports": {
18
18
  "import": "./dist/index.mjs",
19
- "require": "./dist/index.js",
19
+ "require": "./dist/index.cjs",
20
20
  "types": "./dist/index.d.ts"
21
21
  },
22
22
  "scripts": {
23
- "prebuild": "bun -e \"const fs=require('fs');fs.cpSync('../README.md','./README.md')\"",
24
- "build": "tsc && bun build --target browser --outfile dist/index.mjs --minify src/index.ts",
25
- "postbuild": "bun -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs')\"",
26
- "watch": "tsc -w & bun build --watch --target browser --outfile dist/index.mjs --minify src/index.ts"
23
+ "prebuild": "node -e \"const fs=require('fs');fs.cpSync('../README.md','./README.md')\"",
24
+ "build": "tsc && vite build",
25
+ "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')\"",
26
+ "watch": "vite build --watch"
27
27
  },
28
28
  "dependencies": {
29
29
  "@ztimson/utils": "^0.14.11",
30
30
  "rxjs": "^7.8.1"
31
31
  },
32
32
  "devDependencies": {
33
- "typescript": "^5.3.3"
33
+ "@types/node": "^22.2.0",
34
+ "typescript": "^5.3.3",
35
+ "vite": "^5.4.0",
36
+ "vite-plugin-dts": "^4.0.2"
34
37
  },
35
38
  "files": [
36
39
  "dist"
package/dist/actions.js DELETED
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Actions = exports.ActionType = void 0;
4
- const api_1 = require("./api");
5
- const utils_1 = require("@ztimson/utils");
6
- const rxjs_1 = require("rxjs");
7
- var ActionType;
8
- (function (ActionType) {
9
- ActionType[ActionType["CRON"] = 0] = "CRON";
10
- ActionType[ActionType["EVENT"] = 1] = "EVENT";
11
- ActionType[ActionType["DELETE"] = 2] = "DELETE";
12
- ActionType[ActionType["GET"] = 3] = "GET";
13
- ActionType[ActionType["PATCH"] = 4] = "PATCH";
14
- ActionType[ActionType["POST"] = 5] = "POST";
15
- ActionType[ActionType["PUT"] = 6] = "PUT";
16
- })(ActionType || (exports.ActionType = ActionType = {}));
17
- class Actions extends utils_1.TypedEmitter {
18
- api;
19
- $cache = new rxjs_1.BehaviorSubject([]);
20
- get cache() { return this.$cache.value; }
21
- set cache(val) { this.$cache.next(val); }
22
- constructor(api) {
23
- super();
24
- this.api = typeof api == 'string' ? new api_1.Api(api) : api;
25
- }
26
- delete(id) {
27
- return this.api.request({ url: `/api/actions/${id}`, method: 'DELETE' }).then(() => {
28
- this.cache = this.cache.filter(a => a._id != id);
29
- this.emit('DELETE', id);
30
- });
31
- }
32
- list() {
33
- return this.api.request({ url: `/api/actions` }).then(resp => {
34
- if (resp.data)
35
- this.cache = resp.data;
36
- this.emit('LIST', resp.data || []);
37
- return resp.data;
38
- });
39
- }
40
- read(id, reload = false) {
41
- const cached = this.cache.find(a => a._id == id);
42
- if (!reload && cached)
43
- return Promise.resolve(cached);
44
- return this.api.request({ url: `/api/actions/${id}` }).then(action => {
45
- if (action.data)
46
- this.cache = this.cache.filter(a => a._id != id).concat([action.data]);
47
- this.emit('READ', action.data);
48
- return action.data;
49
- });
50
- }
51
- run(path, opts = {}) {
52
- return this.api.request({ url: (`/api/actions/run/` + path).replaceAll('//', '/'), ...opts })
53
- .then(resp => resp.data);
54
- }
55
- runById(action, opts = {}) {
56
- const id = typeof action == 'string' ? action : action._id;
57
- return this.api.request({ url: '/api/actions/run-by-id/' + id, method: 'POST', ...opts })
58
- .then(resp => resp.data);
59
- }
60
- update(action) {
61
- return this.api.request({
62
- url: `/api/actions${action._id ? `/${action._id}` : ''}`,
63
- method: 'POST',
64
- body: action
65
- }).then(action => {
66
- if (action.data)
67
- this.cache = this.cache.filter(a => a._id != action.data?._id).concat([action.data]);
68
- this.emit('UPDATE', action.data);
69
- return action.data;
70
- });
71
- }
72
- }
73
- exports.Actions = Actions;
package/dist/api.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Api = void 0;
4
- const utils_1 = require("@ztimson/utils");
5
- class Api extends utils_1.Http {
6
- url;
7
- opts;
8
- emitter = new utils_1.TypedEmitter();
9
- _token = null;
10
- get token() { return this._token; }
11
- set token(token) {
12
- if (token == this._token)
13
- return;
14
- this._token = token;
15
- this.headers['Authorization'] = token ? `Bearer ${token}` : undefined;
16
- this.emit('TOKEN', token);
17
- }
18
- constructor(url = location.origin, opts = {}) {
19
- opts.url = url;
20
- super(opts);
21
- this.url = url;
22
- this.opts = opts;
23
- }
24
- emit = this.emitter.emit.bind(this.emitter);
25
- off = this.emitter.off.bind(this.emitter);
26
- on = this.emitter.on.bind(this.emitter);
27
- once = this.emitter.once.bind(this.emitter);
28
- request(options) {
29
- const req = super.request(options)
30
- .then(resp => {
31
- this.emit('RESPONSE', resp, options);
32
- return resp;
33
- }).catch(err => {
34
- const e = err?.data || err;
35
- this.emit('REJECTED', e, options);
36
- throw e;
37
- });
38
- this.emit('REQUEST', req, options);
39
- return req;
40
- }
41
- }
42
- exports.Api = Api;
package/dist/auth.js DELETED
@@ -1,166 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Auth = exports.Totp = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const api_1 = require("./api");
6
- const utils_1 = require("@ztimson/utils");
7
- class Totp {
8
- api;
9
- constructor(api) {
10
- this.api = api;
11
- }
12
- disable(username) {
13
- return this.api.request({ url: `/api/auth/totp/${username}`, method: 'DELETE' });
14
- }
15
- enable = this.reset;
16
- reset(username) {
17
- return this.api.request({ url: `/api/auth/totp/${username}`, method: 'POST' });
18
- }
19
- setup(username, method = 'app', totp) {
20
- return this.api.request({ url: `/api/auth/totp/${username}`, body: (0, utils_1.clean)({
21
- method,
22
- totp
23
- }) });
24
- }
25
- }
26
- exports.Totp = Totp;
27
- class Auth extends utils_1.TypedEmitter {
28
- opts;
29
- api;
30
- storageKey;
31
- totp;
32
- $user = new rxjs_1.BehaviorSubject(undefined);
33
- get user() { return this.$user.value; }
34
- set user(user) {
35
- if (!(0, utils_1.isEqual)(this.user, user)) {
36
- const u = user ? user : null;
37
- this.$user.next(u);
38
- this.emit('USER', u);
39
- }
40
- }
41
- constructor(api, opts) {
42
- super();
43
- this.opts = opts;
44
- this.api = typeof api == 'string' ? new api_1.Api(api) : api;
45
- this.totp = new Totp(this.api);
46
- if (!this.opts?.loginUi)
47
- this.opts = { ...this.opts, loginUi: this.api.url + '/ui/login' };
48
- this.storageKey = `momentum:${new URL(this.api.url).host}`;
49
- this.api.addInterceptor((resp, next) => {
50
- const blacklist = [
51
- '/api/auth/login',
52
- '/api/auth/password',
53
- '/api/auth/totp'
54
- ];
55
- if (resp.status == 401 && !blacklist.find(url => resp.url.includes(url)))
56
- this.emit('SESSION_EXPIRED');
57
- next();
58
- });
59
- this.api.on('TOKEN', token => {
60
- if (this.opts?.persist) {
61
- if (token)
62
- localStorage.setItem(this.storageKey, token);
63
- else
64
- localStorage.removeItem(this.storageKey);
65
- }
66
- if (token)
67
- this.session(token, true).catch(() => { });
68
- else
69
- this.user = null;
70
- });
71
- if (opts?.persist) {
72
- const token = localStorage.getItem(this.storageKey);
73
- if (token)
74
- this.api.token = token;
75
- else
76
- this.user = null;
77
- }
78
- else {
79
- this.user = null;
80
- }
81
- }
82
- knownHost(host = location.origin) {
83
- if (host.startsWith('/'))
84
- return Promise.resolve();
85
- return this.api.request({ url: `/api/auth/known-host?host=${encodeURI(new URL(host).origin)}` })
86
- .then(() => { });
87
- }
88
- login(username, password, totp) {
89
- return this.api.request({
90
- url: '/api/auth/login',
91
- headers: { Authorization: undefined },
92
- method: 'POST',
93
- body: {
94
- username: username.trim(),
95
- password: password.trim(),
96
- totp,
97
- }
98
- }).then(async (resp) => {
99
- this.api.token = resp.data?.token || null;
100
- return await this.once('USER');
101
- });
102
- }
103
- loginRedirect(host = location.origin) {
104
- return new Promise((res, rej) => {
105
- const win = window.open(encodeURI(`${this.opts?.loginUi}?redirect=postmessage&host=${host}`), '_blank');
106
- if (!win)
107
- return rej('Unable to open login');
108
- win.addEventListener('message', (event) => {
109
- if (!event?.data?.token)
110
- return rej('Unknown response from login');
111
- this.api.token = event.data.token;
112
- res(event.data.token);
113
- win.close();
114
- });
115
- });
116
- }
117
- logout() {
118
- this.api.token = null;
119
- this.user = null;
120
- this.emit('LOGOUT');
121
- }
122
- async register(u) {
123
- const user = (await this.api.request({ url: '/api/auth/register', body: { ...u } }))?.data;
124
- if (user?.image?.startsWith('/'))
125
- user.image = `${this.api.url}${user.image}?token=${this.api.token}`;
126
- this.emit('REGISTER', user);
127
- return user;
128
- }
129
- reset(emailOrPass, token) {
130
- return this.api.request({
131
- url: '/api/auth/reset',
132
- headers: { 'Authorization': token ? `Bearer ${token}` : undefined },
133
- body: {
134
- email: token ? undefined : emailOrPass,
135
- password: token ? emailOrPass : undefined,
136
- }
137
- }).then(() => { });
138
- }
139
- async session(token, set = false) {
140
- if (!token)
141
- token = this.api.token;
142
- const session = (await this.api.request({
143
- url: '/api/auth/session',
144
- headers: token ? { 'Authorization': `Bearer ${token}` } : undefined
145
- }))?.data;
146
- if (set) {
147
- this.api.token = token;
148
- if (session?.user)
149
- session.user.image = `${this.api.url}${session.user.image}?token=${this.api.token}`;
150
- this.user = session?.user || null;
151
- if (session)
152
- this.emit('LOGIN', session.user);
153
- }
154
- return session;
155
- }
156
- async updatePassword(username, password, oldPassword) {
157
- return this.api.request({
158
- url: '/api/auth/password',
159
- body: { username, password, oldPassword }
160
- }).then(resp => {
161
- if (resp?.data?.token)
162
- this.api.token = resp.data.token;
163
- });
164
- }
165
- }
166
- exports.Auth = Auth;
package/dist/core.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/data.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Data = void 0;
4
- const api_1 = require("./api");
5
- const utils_1 = require("@ztimson/utils");
6
- class Data extends utils_1.TypedEmitter {
7
- api;
8
- constructor(api) {
9
- super();
10
- this.api = typeof api == 'string' ? new api_1.Api(api) : api;
11
- }
12
- delete(collection, document) {
13
- return this.api.request({
14
- url: `/api/data/${collection}/${document}`,
15
- method: 'DELETE'
16
- }).then(() => this.emit('DELETE', collection, document));
17
- }
18
- get(collection, document) {
19
- return this.api.request({ url: `/api/data/${collection}${document ? `/${document}` : ''}` }).then(resp => {
20
- this.emit('GET', collection, resp.data);
21
- return resp.data;
22
- });
23
- }
24
- raw(collection, operand, query, options) {
25
- return this.api.request({
26
- url: `/api/data/${collection}`,
27
- body: {
28
- operand,
29
- query,
30
- options,
31
- }
32
- }).then(resp => {
33
- this.emit('RAW', collection, resp.data);
34
- return resp.data;
35
- });
36
- }
37
- set(collection, document, append = false) {
38
- return this.api.request({
39
- url: `/api/data/${collection}/${document._id || ''}`,
40
- method: append ? 'PATCH' : 'POST',
41
- body: document
42
- }).then(resp => {
43
- this.emit('SET', collection, resp.data);
44
- return resp.data;
45
- });
46
- }
47
- }
48
- exports.Data = Data;
package/dist/email.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Email = void 0;
4
- const api_1 = require("./api");
5
- const utils_1 = require("@ztimson/utils");
6
- class Email extends utils_1.TypedEmitter {
7
- api;
8
- constructor(api) {
9
- super();
10
- this.api = typeof api == 'string' ? new api_1.Api(api) : api;
11
- }
12
- send(email) {
13
- let url = '/api/email';
14
- if (typeof email.body == 'object')
15
- url += `/${email.body.template}`;
16
- return this.api.request({ url, body: email }).then(resp => {
17
- this.emit('SENT', email);
18
- return resp.data;
19
- });
20
- }
21
- }
22
- exports.Email = Email;
package/dist/groups.js DELETED
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Groups = void 0;
4
- const api_1 = require("./api");
5
- const utils_1 = require("@ztimson/utils");
6
- class Groups extends utils_1.TypedEmitter {
7
- api;
8
- constructor(api) {
9
- super();
10
- this.api = typeof api == 'string' ? new api_1.Api(api) : api;
11
- }
12
- create(group) {
13
- return this.api.request({
14
- url: `/api/groups/${group.name}`,
15
- method: 'POST',
16
- body: group
17
- }).then(resp => {
18
- this.emit('CREATE', resp.data);
19
- return resp.data;
20
- });
21
- }
22
- list() {
23
- return this.api.request({ url: `/api/groups` }).then(resp => {
24
- this.emit('LIST', resp.data || []);
25
- return resp.data;
26
- });
27
- }
28
- read(name) {
29
- return this.api.request({ url: `/api/groups/${name}` }).then(resp => {
30
- this.emit('READ', resp.data);
31
- return resp.data;
32
- });
33
- }
34
- update(group) {
35
- return this.api.request({
36
- url: `/api/groups/${group.name}`,
37
- method: 'PATCH',
38
- body: group
39
- }).then(resp => {
40
- this.emit('UPDATE', resp.data);
41
- return resp.data;
42
- });
43
- }
44
- delete(name) {
45
- return this.api.request({
46
- url: `/api/groups/${name}`,
47
- method: 'DELETE'
48
- }).then(() => this.emit('DELETE', name));
49
- }
50
- }
51
- exports.Groups = Groups;