@ztimson/momentum 0.48.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/ai.d.ts +1 -0
- package/dist/ai.d.ts.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/core.d.ts +8 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/data.d.ts +18 -19
- package/dist/data.d.ts.map +1 -1
- package/dist/forms.d.ts +19 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/index.cjs +72 -17
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +72 -17
- package/dist/momentum.d.ts +4 -0
- package/dist/momentum.d.ts.map +1 -1
- package/dist/phone.d.ts +19 -0
- package/dist/phone.d.ts.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
### Momentum
|
|
10
10
|
|
|
11
11
|
<!-- Description -->
|
|
12
|
-
|
|
12
|
+
Enterprise Resource Planning
|
|
13
13
|
|
|
14
14
|
<!-- Repo badges -->
|
|
15
15
|
[](https://git.zakscode.com/ztimson/momentum/tags)
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
## About
|
|
42
42
|
|
|
43
|
-
Momentum is a self-hosted
|
|
43
|
+
Momentum is a self-hosted enterprise resource planning tool. What does that mean? Think something similar to [Firebase](https://firebase.google.com) but you are in full control of your data & services.
|
|
44
44
|
|
|
45
45
|
It was developed as a generic backend to add functionality to single page applications such as angular, react, svelte or vue. Momentum comes with a client library to make integration extremely easy.
|
|
46
46
|
|
package/dist/ai.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export declare class Ai extends PathEventEmitter {
|
|
|
5
5
|
constructor(api: Api | string);
|
|
6
6
|
ask(question: string, context?: any): import('@ztimson/utils').PromiseProgress<any>;
|
|
7
7
|
clear(): import('@ztimson/utils').PromiseProgress<any>;
|
|
8
|
+
history(): import('@ztimson/utils').PromiseProgress<any>;
|
|
8
9
|
}
|
|
9
10
|
//# 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,qBAAa,EAAG,SAAQ,gBAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAWnC,KAAK;
|
|
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,qBAAa,EAAG,SAAQ,gBAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAWnC,KAAK;IAKL,OAAO;CAMP"}
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAiB,SAAS,EAAE,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,SAAS,CAAC;AAElC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
|
|
7
7
|
_updatedDate: Date;
|
|
8
8
|
};
|
|
9
|
-
export type NotificationMethod = '
|
|
9
|
+
export type NotificationMethod = 'email' | 'notification' | 'sms' | 'voice';
|
|
10
10
|
export type Notification = {
|
|
11
11
|
event: string;
|
|
12
12
|
method: NotificationMethod[];
|
|
@@ -14,4 +14,11 @@ export type Notification = {
|
|
|
14
14
|
body: string | ((event: PathEvent, ...args: any[]) => string);
|
|
15
15
|
link?: string;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Recursive type for defining tree data
|
|
19
|
+
*/
|
|
20
|
+
export type TreeNode<T> = T & {
|
|
21
|
+
name: string;
|
|
22
|
+
children: TreeNode<T>[];
|
|
23
|
+
};
|
|
17
24
|
//# sourceMappingURL=core.d.ts.map
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,MAAM,MAAM,IAAI,GAAG;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,MAAM,MAAM,IAAI,GAAG;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,IAAI,CAAC;CACnB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAI,OAAO,GAAG,cAAc,GAAG,KAAK,GAAG,OAAO,CAAC;AAE7E,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC;IAClE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;CACxB,CAAC"}
|
package/dist/data.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Api } from './api';
|
|
2
|
-
import { Meta } from './core';
|
|
2
|
+
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 = {
|
|
@@ -16,37 +16,36 @@ export type Schema = Meta & {
|
|
|
16
16
|
description?: string;
|
|
17
17
|
/** Last index number */
|
|
18
18
|
autoIncrement?: number;
|
|
19
|
+
/** Associated form for viewing/editing */
|
|
20
|
+
form?: string;
|
|
19
21
|
/** Hide columns */
|
|
20
22
|
hide?: string[];
|
|
21
23
|
/** Lock collection from changes */
|
|
22
24
|
lock?: boolean;
|
|
25
|
+
/** Data must match defined columns */
|
|
26
|
+
strict?: boolean;
|
|
23
27
|
/** Allow updates to create row if missing */
|
|
24
28
|
upsert?: boolean;
|
|
25
29
|
/** Defined fields */
|
|
26
|
-
|
|
30
|
+
columns?: SchemaColumn[];
|
|
27
31
|
};
|
|
28
|
-
export type
|
|
32
|
+
export type SchemaColumn = {
|
|
29
33
|
/** Display label */
|
|
30
34
|
label: string;
|
|
31
35
|
/** Property key */
|
|
32
|
-
|
|
36
|
+
prop: string;
|
|
33
37
|
/** Variable type */
|
|
34
|
-
type
|
|
38
|
+
type?: string;
|
|
35
39
|
/** Display formating */
|
|
36
|
-
format
|
|
37
|
-
/** Extra settings for formatting */
|
|
38
|
-
formatArgs: any;
|
|
40
|
+
format?: any;
|
|
39
41
|
/** Default value */
|
|
40
|
-
default
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export type SchemaNode = Schema & {
|
|
48
|
-
name: string;
|
|
49
|
-
children: SchemaNode[];
|
|
42
|
+
default?: any;
|
|
43
|
+
/** Must have value */
|
|
44
|
+
required?: boolean;
|
|
45
|
+
/** Style */
|
|
46
|
+
style?: {
|
|
47
|
+
width?: string;
|
|
48
|
+
};
|
|
50
49
|
};
|
|
51
50
|
export declare class Data extends PathEventEmitter {
|
|
52
51
|
private readonly api;
|
|
@@ -59,7 +58,7 @@ export declare class Data extends PathEventEmitter {
|
|
|
59
58
|
raw<T>(collection: string, query: RawQuery): Promise<Document<T>>;
|
|
60
59
|
deleteSchema(path: string): PromiseProgress<any>;
|
|
61
60
|
readSchema(tree?: false): Promise<string[]>;
|
|
62
|
-
readSchema(tree?: boolean): Promise<
|
|
61
|
+
readSchema(tree?: boolean): Promise<TreeNode<Schema>[]>;
|
|
63
62
|
readSchema(path?: string): Promise<Schema>;
|
|
64
63
|
updateSchema(schema: Partial<Schema> & {
|
|
65
64
|
path: string;
|
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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AAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAWjE,YAAY,CAAC,IAAI,EAAE,MAAM;IAMzB,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAC3C,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1C,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,eAAe,CAAC,MAAM,CAAC;CAO/E"}
|
package/dist/forms.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Cache, PathEventEmitter } from '@ztimson/utils';
|
|
2
|
+
import { Api } from './api';
|
|
3
|
+
import { Meta, TreeNode } from './core';
|
|
4
|
+
export type Form = Meta & {
|
|
5
|
+
path: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class Forms extends PathEventEmitter {
|
|
9
|
+
readonly api: Api;
|
|
10
|
+
cache: Cache<string, Form>;
|
|
11
|
+
constructor(api: Api | string);
|
|
12
|
+
all(tree?: false): Promise<string[]>;
|
|
13
|
+
all(tree?: boolean): Promise<TreeNode<Form>[]>;
|
|
14
|
+
all(path?: string): Promise<Form>;
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
read(path: string, reload?: boolean): Promise<Form | null>;
|
|
17
|
+
update(form: Form): Promise<Form>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=forms.d.ts.map
|
|
@@ -0,0 +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;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,qBAAa,KAAM,SAAQ,gBAAgB;IAC1C,QAAQ,CAAC,GAAG,EAAG,GAAG,CAAC;IAEnB,KAAK,sBAAiC;gBAE1B,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACpC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjC,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
|
@@ -35,12 +35,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
function JSONSanitize(obj, space) {
|
|
38
|
-
let cache = [];
|
|
39
38
|
return JSON.stringify(obj, (key, value) => {
|
|
40
|
-
if (typeof value === "object" && value !== null) {
|
|
41
|
-
if (cache.includes(value)) return;
|
|
42
|
-
cache.push(value);
|
|
43
|
-
}
|
|
44
39
|
return value;
|
|
45
40
|
}, space);
|
|
46
41
|
}
|
|
@@ -769,7 +764,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
769
764
|
__publicField2(this, "methods");
|
|
770
765
|
var _a;
|
|
771
766
|
if (typeof Event == "object") return Object.assign(this, Event);
|
|
772
|
-
let [p, scope, method] = Event.split(":");
|
|
767
|
+
let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
|
|
773
768
|
if (!method) method = scope || "*";
|
|
774
769
|
if (p == "*" || !p && method == "*") {
|
|
775
770
|
p = "";
|
|
@@ -1105,6 +1100,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1105
1100
|
clear() {
|
|
1106
1101
|
return this.api.request({ url: "/api/" + PES`ai`, method: "DELETE" }).then(() => this.emit(PES`ai:d`, this.api.token));
|
|
1107
1102
|
}
|
|
1103
|
+
history() {
|
|
1104
|
+
return this.api.request({ url: "/api/" + PES`ai` }).then((resp) => {
|
|
1105
|
+
this.emit(PES`ai:r`, resp);
|
|
1106
|
+
return resp;
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1108
1109
|
}
|
|
1109
1110
|
class Analytics extends PathEventEmitter {
|
|
1110
1111
|
constructor(api) {
|
|
@@ -1134,7 +1135,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1134
1135
|
__publicField(this, "hasAllFatal", (...events) => PathEvent.hasAllFatal(this.permissions, ...events));
|
|
1135
1136
|
__publicField(this, "enableTotp", this.resetTotp);
|
|
1136
1137
|
this.opts = opts;
|
|
1137
|
-
window.PathEvent = PathEvent;
|
|
1138
1138
|
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1139
1139
|
this.opts = {
|
|
1140
1140
|
loginUrl: this.api.url + "/ui/#/login",
|
|
@@ -1311,7 +1311,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1311
1311
|
return this._platform;
|
|
1312
1312
|
}
|
|
1313
1313
|
get pushSubscription() {
|
|
1314
|
-
|
|
1314
|
+
var _a;
|
|
1315
|
+
if (!((_a = navigator.serviceWorker) == null ? void 0 : _a.controller)) return Promise.resolve(null);
|
|
1315
1316
|
return navigator.serviceWorker.ready.then((sw) => sw.pushManager.getSubscription());
|
|
1316
1317
|
}
|
|
1317
1318
|
get pwa() {
|
|
@@ -1320,7 +1321,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1320
1321
|
return this._pwa;
|
|
1321
1322
|
}
|
|
1322
1323
|
async inject(reload = false, firstLoad = true) {
|
|
1323
|
-
var _a, _b, _c, _d, _e
|
|
1324
|
+
var _a, _b, _c, _d, _e;
|
|
1324
1325
|
let settings = this.settings.cache;
|
|
1325
1326
|
if (firstLoad) this.settings.all(false, reload).then(() => this.inject(false, false)).catch(() => {
|
|
1326
1327
|
});
|
|
@@ -1377,12 +1378,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1377
1378
|
}
|
|
1378
1379
|
style.innerHTML = `
|
|
1379
1380
|
:root {
|
|
1380
|
-
--theme-
|
|
1381
|
-
--theme-
|
|
1382
|
-
--theme-
|
|
1383
|
-
--theme-secondary: ${(_f = settings["theme"]) == null ? void 0 : _f.secondary};
|
|
1384
|
-
--theme-text: ${((_g = settings["theme"]) == null ? void 0 : _g.darkMode) ? "#ffffff" : "#000000"};
|
|
1385
|
-
--theme-muted: ${((_h = settings["theme"]) == null ? void 0 : _h.darkMode) ? "#cccccc" : "#6c757d"};
|
|
1381
|
+
--theme-backdrop: ${(_c = settings["theme"]) == null ? void 0 : _c.background};
|
|
1382
|
+
--theme-primary: ${(_d = settings["theme"]) == null ? void 0 : _d.primary};
|
|
1383
|
+
--theme-accent: ${(_e = settings["theme"]) == null ? void 0 : _e.secondary};
|
|
1386
1384
|
}`;
|
|
1387
1385
|
}
|
|
1388
1386
|
if (settings["pwa"]) {
|
|
@@ -1570,9 +1568,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1570
1568
|
return resp;
|
|
1571
1569
|
});
|
|
1572
1570
|
}
|
|
1573
|
-
update(collection, document2, append
|
|
1571
|
+
update(collection, document2, append) {
|
|
1574
1572
|
if (!collection || !document2) throw new Error("Cannot update document, missing collection or document");
|
|
1575
|
-
if (!document2._id) return this.create(collection, document2);
|
|
1576
1573
|
return this.api.request({
|
|
1577
1574
|
url: `/api/` + PES`data/${collection}/${document2._id}`,
|
|
1578
1575
|
method: append ? "PATCH" : "PUT",
|
|
@@ -1625,6 +1622,44 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1625
1622
|
});
|
|
1626
1623
|
}
|
|
1627
1624
|
}
|
|
1625
|
+
class Forms extends PathEventEmitter {
|
|
1626
|
+
constructor(api) {
|
|
1627
|
+
super();
|
|
1628
|
+
__publicField(this, "api");
|
|
1629
|
+
__publicField(this, "cache", new Cache("_id"));
|
|
1630
|
+
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1631
|
+
}
|
|
1632
|
+
all(pathOrTree) {
|
|
1633
|
+
return this.api.request({ url: "/api/" + PES`forms/${typeof pathOrTree == "string" ? pathOrTree : ""}` + (pathOrTree === true ? `?tree=${pathOrTree}` : "") }).then((resp) => {
|
|
1634
|
+
this.emit(PES`forms/${typeof pathOrTree == "string" ? pathOrTree : ""}:r`, resp);
|
|
1635
|
+
return resp;
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
delete(key) {
|
|
1639
|
+
if (!key) throw new Error("Cannot delete form, missing path");
|
|
1640
|
+
return this.api.request({ url: `/api/` + PES`forms/${key}`, method: "DELETE" }).then(() => {
|
|
1641
|
+
this.cache.delete(key);
|
|
1642
|
+
this.emit(PES`forms/${key}:d`, key);
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
read(path, reload = false) {
|
|
1646
|
+
if (!path) throw new Error("Cannot read form, missing path");
|
|
1647
|
+
if (!reload && this.cache.get(path)) return Promise.resolve(this.cache.get(path));
|
|
1648
|
+
return this.api.request({ url: `/api/` + PES`forms/${path}` }).then((form) => {
|
|
1649
|
+
if (form) this.cache.add(form);
|
|
1650
|
+
this.emit(PES`forms/${path}:r`, form);
|
|
1651
|
+
return form;
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
update(form) {
|
|
1655
|
+
if (!form.path) throw new Error("Cannot update form, missing path");
|
|
1656
|
+
return this.api.request({ url: `/api/` + PES`forms/${form.path}`, body: form }).then((f) => {
|
|
1657
|
+
if (f) this.cache.add(f);
|
|
1658
|
+
this.emit(`/api/` + PES`settings/${form.path}:${form._id ? "u" : "c"}`, f);
|
|
1659
|
+
return f;
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1628
1663
|
class Groups extends PathEventEmitter {
|
|
1629
1664
|
constructor(api) {
|
|
1630
1665
|
super();
|
|
@@ -1862,6 +1897,19 @@ ${log}`;
|
|
|
1862
1897
|
return this.createPdf({ url }, options);
|
|
1863
1898
|
}
|
|
1864
1899
|
}
|
|
1900
|
+
class Phone extends PathEventEmitter {
|
|
1901
|
+
constructor(api) {
|
|
1902
|
+
super();
|
|
1903
|
+
__publicField(this, "api");
|
|
1904
|
+
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1905
|
+
}
|
|
1906
|
+
sms(message) {
|
|
1907
|
+
return this.api.request({ url: "/api/" + PES`phone/sms`, body: message }).then((resp) => this.emit(PES`sms/${message.to}`, resp));
|
|
1908
|
+
}
|
|
1909
|
+
voice(message) {
|
|
1910
|
+
return this.api.request({ url: "/api/" + PES`phone/voice`, body: message }).then((resp) => this.emit(PES`voice/${message.to}`, resp));
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1865
1913
|
const _Socket = class _Socket {
|
|
1866
1914
|
constructor(api) {
|
|
1867
1915
|
__publicField(this, "api");
|
|
@@ -2136,9 +2184,11 @@ ${log}`;
|
|
|
2136
2184
|
__publicField(this, "client");
|
|
2137
2185
|
__publicField(this, "data");
|
|
2138
2186
|
__publicField(this, "email");
|
|
2187
|
+
__publicField(this, "forms");
|
|
2139
2188
|
__publicField(this, "groups");
|
|
2140
2189
|
__publicField(this, "logger");
|
|
2141
2190
|
__publicField(this, "payments");
|
|
2191
|
+
__publicField(this, "phone");
|
|
2142
2192
|
__publicField(this, "pdf");
|
|
2143
2193
|
__publicField(this, "settings");
|
|
2144
2194
|
__publicField(this, "socket");
|
|
@@ -2152,10 +2202,12 @@ ${log}`;
|
|
|
2152
2202
|
this.auth = new Auth(this.api, { loginUrl: opts == null ? void 0 : opts.loginUrl });
|
|
2153
2203
|
this.data = new Data(this.api);
|
|
2154
2204
|
this.email = new Email(this.api);
|
|
2205
|
+
this.forms = new Forms(this.api);
|
|
2155
2206
|
this.groups = new Groups(this.api);
|
|
2156
2207
|
this.logger = new Logger(this.api, (opts == null ? void 0 : opts.app) || "client", opts == null ? void 0 : opts.logLevel);
|
|
2157
2208
|
if (opts == null ? void 0 : opts.stripeSecret) this.payments = new Payments(this.api, opts.stripeSecret);
|
|
2158
2209
|
this.pdf = new Pdf(this.api);
|
|
2210
|
+
this.phone = new Phone(this.api);
|
|
2159
2211
|
this.settings = new Settings(this.api);
|
|
2160
2212
|
if (opts == null ? void 0 : opts.socket) this.socket = new Socket(this.api);
|
|
2161
2213
|
this.static = new Static(this.api);
|
|
@@ -2174,6 +2226,7 @@ ${log}`;
|
|
|
2174
2226
|
this.relayEvents(this.logger);
|
|
2175
2227
|
if (this.payments) this.relayEvents(this.payments);
|
|
2176
2228
|
this.relayEvents(this.pdf);
|
|
2229
|
+
this.relayEvents(this.phone);
|
|
2177
2230
|
this.relayEvents(this.settings);
|
|
2178
2231
|
this.relayEvents(this.static);
|
|
2179
2232
|
this.relayEvents(this.storage);
|
|
@@ -2197,6 +2250,7 @@ ${log}`;
|
|
|
2197
2250
|
exports2.Client = Client;
|
|
2198
2251
|
exports2.Data = Data;
|
|
2199
2252
|
exports2.Email = Email;
|
|
2253
|
+
exports2.Forms = Forms;
|
|
2200
2254
|
exports2.Groups = Groups;
|
|
2201
2255
|
exports2.Logger = Logger;
|
|
2202
2256
|
exports2.Momentum = Momentum;
|
|
@@ -2206,6 +2260,7 @@ ${log}`;
|
|
|
2206
2260
|
exports2.PathEventEmitter = PathEventEmitter;
|
|
2207
2261
|
exports2.Payments = Payments;
|
|
2208
2262
|
exports2.Pdf = Pdf;
|
|
2263
|
+
exports2.Phone = Phone;
|
|
2209
2264
|
exports2.Settings = Settings;
|
|
2210
2265
|
exports2.Socket = Socket;
|
|
2211
2266
|
exports2.Static = Static;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,12 @@ export * from './client';
|
|
|
8
8
|
export * from './core';
|
|
9
9
|
export * from './data';
|
|
10
10
|
export * from './email';
|
|
11
|
+
export * from './forms';
|
|
11
12
|
export * from './groups';
|
|
12
13
|
export * from './logger';
|
|
13
14
|
export * from './momentum';
|
|
14
15
|
export * from './payments';
|
|
16
|
+
export * from './phone';
|
|
15
17
|
export * from './pdf';
|
|
16
18
|
export * from './settings';
|
|
17
19
|
export * from './sockets';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,iBAAiB,EACtB,EAAE,EAAE,GAAG,EAAE,SAAS,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AAExB,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -31,12 +31,7 @@ function JSONAttemptParse(json) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
function JSONSanitize(obj, space) {
|
|
34
|
-
let cache = [];
|
|
35
34
|
return JSON.stringify(obj, (key, value) => {
|
|
36
|
-
if (typeof value === "object" && value !== null) {
|
|
37
|
-
if (cache.includes(value)) return;
|
|
38
|
-
cache.push(value);
|
|
39
|
-
}
|
|
40
35
|
return value;
|
|
41
36
|
}, space);
|
|
42
37
|
}
|
|
@@ -765,7 +760,7 @@ class PathEvent {
|
|
|
765
760
|
__publicField2(this, "methods");
|
|
766
761
|
var _a;
|
|
767
762
|
if (typeof Event == "object") return Object.assign(this, Event);
|
|
768
|
-
let [p, scope, method] = Event.split(":");
|
|
763
|
+
let [p, scope, method] = Event.replaceAll(/\/{2,}/g, "/").split(":");
|
|
769
764
|
if (!method) method = scope || "*";
|
|
770
765
|
if (p == "*" || !p && method == "*") {
|
|
771
766
|
p = "";
|
|
@@ -1101,6 +1096,12 @@ class Ai extends PathEventEmitter {
|
|
|
1101
1096
|
clear() {
|
|
1102
1097
|
return this.api.request({ url: "/api/" + PES`ai`, method: "DELETE" }).then(() => this.emit(PES`ai:d`, this.api.token));
|
|
1103
1098
|
}
|
|
1099
|
+
history() {
|
|
1100
|
+
return this.api.request({ url: "/api/" + PES`ai` }).then((resp) => {
|
|
1101
|
+
this.emit(PES`ai:r`, resp);
|
|
1102
|
+
return resp;
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1104
1105
|
}
|
|
1105
1106
|
class Analytics extends PathEventEmitter {
|
|
1106
1107
|
constructor(api) {
|
|
@@ -1130,7 +1131,6 @@ class Auth extends PathEventEmitter {
|
|
|
1130
1131
|
__publicField(this, "hasAllFatal", (...events) => PathEvent.hasAllFatal(this.permissions, ...events));
|
|
1131
1132
|
__publicField(this, "enableTotp", this.resetTotp);
|
|
1132
1133
|
this.opts = opts;
|
|
1133
|
-
window.PathEvent = PathEvent;
|
|
1134
1134
|
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1135
1135
|
this.opts = {
|
|
1136
1136
|
loginUrl: this.api.url + "/ui/#/login",
|
|
@@ -1307,7 +1307,8 @@ class Client extends PathEventEmitter {
|
|
|
1307
1307
|
return this._platform;
|
|
1308
1308
|
}
|
|
1309
1309
|
get pushSubscription() {
|
|
1310
|
-
|
|
1310
|
+
var _a;
|
|
1311
|
+
if (!((_a = navigator.serviceWorker) == null ? void 0 : _a.controller)) return Promise.resolve(null);
|
|
1311
1312
|
return navigator.serviceWorker.ready.then((sw) => sw.pushManager.getSubscription());
|
|
1312
1313
|
}
|
|
1313
1314
|
get pwa() {
|
|
@@ -1316,7 +1317,7 @@ class Client extends PathEventEmitter {
|
|
|
1316
1317
|
return this._pwa;
|
|
1317
1318
|
}
|
|
1318
1319
|
async inject(reload = false, firstLoad = true) {
|
|
1319
|
-
var _a, _b, _c, _d, _e
|
|
1320
|
+
var _a, _b, _c, _d, _e;
|
|
1320
1321
|
let settings = this.settings.cache;
|
|
1321
1322
|
if (firstLoad) this.settings.all(false, reload).then(() => this.inject(false, false)).catch(() => {
|
|
1322
1323
|
});
|
|
@@ -1373,12 +1374,9 @@ class Client extends PathEventEmitter {
|
|
|
1373
1374
|
}
|
|
1374
1375
|
style.innerHTML = `
|
|
1375
1376
|
:root {
|
|
1376
|
-
--theme-
|
|
1377
|
-
--theme-
|
|
1378
|
-
--theme-
|
|
1379
|
-
--theme-secondary: ${(_f = settings["theme"]) == null ? void 0 : _f.secondary};
|
|
1380
|
-
--theme-text: ${((_g = settings["theme"]) == null ? void 0 : _g.darkMode) ? "#ffffff" : "#000000"};
|
|
1381
|
-
--theme-muted: ${((_h = settings["theme"]) == null ? void 0 : _h.darkMode) ? "#cccccc" : "#6c757d"};
|
|
1377
|
+
--theme-backdrop: ${(_c = settings["theme"]) == null ? void 0 : _c.background};
|
|
1378
|
+
--theme-primary: ${(_d = settings["theme"]) == null ? void 0 : _d.primary};
|
|
1379
|
+
--theme-accent: ${(_e = settings["theme"]) == null ? void 0 : _e.secondary};
|
|
1382
1380
|
}`;
|
|
1383
1381
|
}
|
|
1384
1382
|
if (settings["pwa"]) {
|
|
@@ -1566,9 +1564,8 @@ class Data extends PathEventEmitter {
|
|
|
1566
1564
|
return resp;
|
|
1567
1565
|
});
|
|
1568
1566
|
}
|
|
1569
|
-
update(collection, document2, append
|
|
1567
|
+
update(collection, document2, append) {
|
|
1570
1568
|
if (!collection || !document2) throw new Error("Cannot update document, missing collection or document");
|
|
1571
|
-
if (!document2._id) return this.create(collection, document2);
|
|
1572
1569
|
return this.api.request({
|
|
1573
1570
|
url: `/api/` + PES`data/${collection}/${document2._id}`,
|
|
1574
1571
|
method: append ? "PATCH" : "PUT",
|
|
@@ -1621,6 +1618,44 @@ class Email extends PathEventEmitter {
|
|
|
1621
1618
|
});
|
|
1622
1619
|
}
|
|
1623
1620
|
}
|
|
1621
|
+
class Forms extends PathEventEmitter {
|
|
1622
|
+
constructor(api) {
|
|
1623
|
+
super();
|
|
1624
|
+
__publicField(this, "api");
|
|
1625
|
+
__publicField(this, "cache", new Cache("_id"));
|
|
1626
|
+
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1627
|
+
}
|
|
1628
|
+
all(pathOrTree) {
|
|
1629
|
+
return this.api.request({ url: "/api/" + PES`forms/${typeof pathOrTree == "string" ? pathOrTree : ""}` + (pathOrTree === true ? `?tree=${pathOrTree}` : "") }).then((resp) => {
|
|
1630
|
+
this.emit(PES`forms/${typeof pathOrTree == "string" ? pathOrTree : ""}:r`, resp);
|
|
1631
|
+
return resp;
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
delete(key) {
|
|
1635
|
+
if (!key) throw new Error("Cannot delete form, missing path");
|
|
1636
|
+
return this.api.request({ url: `/api/` + PES`forms/${key}`, method: "DELETE" }).then(() => {
|
|
1637
|
+
this.cache.delete(key);
|
|
1638
|
+
this.emit(PES`forms/${key}:d`, key);
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
read(path, reload = false) {
|
|
1642
|
+
if (!path) throw new Error("Cannot read form, missing path");
|
|
1643
|
+
if (!reload && this.cache.get(path)) return Promise.resolve(this.cache.get(path));
|
|
1644
|
+
return this.api.request({ url: `/api/` + PES`forms/${path}` }).then((form) => {
|
|
1645
|
+
if (form) this.cache.add(form);
|
|
1646
|
+
this.emit(PES`forms/${path}:r`, form);
|
|
1647
|
+
return form;
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
update(form) {
|
|
1651
|
+
if (!form.path) throw new Error("Cannot update form, missing path");
|
|
1652
|
+
return this.api.request({ url: `/api/` + PES`forms/${form.path}`, body: form }).then((f) => {
|
|
1653
|
+
if (f) this.cache.add(f);
|
|
1654
|
+
this.emit(`/api/` + PES`settings/${form.path}:${form._id ? "u" : "c"}`, f);
|
|
1655
|
+
return f;
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1624
1659
|
class Groups extends PathEventEmitter {
|
|
1625
1660
|
constructor(api) {
|
|
1626
1661
|
super();
|
|
@@ -1858,6 +1893,19 @@ class Pdf extends PathEventEmitter {
|
|
|
1858
1893
|
return this.createPdf({ url }, options);
|
|
1859
1894
|
}
|
|
1860
1895
|
}
|
|
1896
|
+
class Phone extends PathEventEmitter {
|
|
1897
|
+
constructor(api) {
|
|
1898
|
+
super();
|
|
1899
|
+
__publicField(this, "api");
|
|
1900
|
+
this.api = typeof api == "string" ? new Api(api) : api;
|
|
1901
|
+
}
|
|
1902
|
+
sms(message) {
|
|
1903
|
+
return this.api.request({ url: "/api/" + PES`phone/sms`, body: message }).then((resp) => this.emit(PES`sms/${message.to}`, resp));
|
|
1904
|
+
}
|
|
1905
|
+
voice(message) {
|
|
1906
|
+
return this.api.request({ url: "/api/" + PES`phone/voice`, body: message }).then((resp) => this.emit(PES`voice/${message.to}`, resp));
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1861
1909
|
const _Socket = class _Socket {
|
|
1862
1910
|
constructor(api) {
|
|
1863
1911
|
__publicField(this, "api");
|
|
@@ -2132,9 +2180,11 @@ class Momentum extends PathEventEmitter {
|
|
|
2132
2180
|
__publicField(this, "client");
|
|
2133
2181
|
__publicField(this, "data");
|
|
2134
2182
|
__publicField(this, "email");
|
|
2183
|
+
__publicField(this, "forms");
|
|
2135
2184
|
__publicField(this, "groups");
|
|
2136
2185
|
__publicField(this, "logger");
|
|
2137
2186
|
__publicField(this, "payments");
|
|
2187
|
+
__publicField(this, "phone");
|
|
2138
2188
|
__publicField(this, "pdf");
|
|
2139
2189
|
__publicField(this, "settings");
|
|
2140
2190
|
__publicField(this, "socket");
|
|
@@ -2148,10 +2198,12 @@ class Momentum extends PathEventEmitter {
|
|
|
2148
2198
|
this.auth = new Auth(this.api, { loginUrl: opts == null ? void 0 : opts.loginUrl });
|
|
2149
2199
|
this.data = new Data(this.api);
|
|
2150
2200
|
this.email = new Email(this.api);
|
|
2201
|
+
this.forms = new Forms(this.api);
|
|
2151
2202
|
this.groups = new Groups(this.api);
|
|
2152
2203
|
this.logger = new Logger(this.api, (opts == null ? void 0 : opts.app) || "client", opts == null ? void 0 : opts.logLevel);
|
|
2153
2204
|
if (opts == null ? void 0 : opts.stripeSecret) this.payments = new Payments(this.api, opts.stripeSecret);
|
|
2154
2205
|
this.pdf = new Pdf(this.api);
|
|
2206
|
+
this.phone = new Phone(this.api);
|
|
2155
2207
|
this.settings = new Settings(this.api);
|
|
2156
2208
|
if (opts == null ? void 0 : opts.socket) this.socket = new Socket(this.api);
|
|
2157
2209
|
this.static = new Static(this.api);
|
|
@@ -2170,6 +2222,7 @@ class Momentum extends PathEventEmitter {
|
|
|
2170
2222
|
this.relayEvents(this.logger);
|
|
2171
2223
|
if (this.payments) this.relayEvents(this.payments);
|
|
2172
2224
|
this.relayEvents(this.pdf);
|
|
2225
|
+
this.relayEvents(this.phone);
|
|
2173
2226
|
this.relayEvents(this.settings);
|
|
2174
2227
|
this.relayEvents(this.static);
|
|
2175
2228
|
this.relayEvents(this.storage);
|
|
@@ -2194,6 +2247,7 @@ export {
|
|
|
2194
2247
|
Client,
|
|
2195
2248
|
Data,
|
|
2196
2249
|
Email,
|
|
2250
|
+
Forms,
|
|
2197
2251
|
Groups,
|
|
2198
2252
|
Logger,
|
|
2199
2253
|
Momentum,
|
|
@@ -2203,6 +2257,7 @@ export {
|
|
|
2203
2257
|
PathEventEmitter,
|
|
2204
2258
|
Payments,
|
|
2205
2259
|
Pdf,
|
|
2260
|
+
Phone,
|
|
2206
2261
|
Settings,
|
|
2207
2262
|
Socket,
|
|
2208
2263
|
Static,
|
package/dist/momentum.d.ts
CHANGED
|
@@ -5,11 +5,13 @@ import { Api, ApiOptions } from './api';
|
|
|
5
5
|
import { Auth, AuthOptions } from './auth';
|
|
6
6
|
import { Data } from './data';
|
|
7
7
|
import { Email } from './email';
|
|
8
|
+
import { Forms } from './forms';
|
|
8
9
|
import { Groups } from './groups';
|
|
9
10
|
import { PathEventEmitter } from '@ztimson/utils';
|
|
10
11
|
import { Logger, LogLevel } from './logger';
|
|
11
12
|
import { Payments } from './payments';
|
|
12
13
|
import { Pdf } from './pdf';
|
|
14
|
+
import { Phone } from './phone';
|
|
13
15
|
import { Socket } from './sockets';
|
|
14
16
|
import { Storage } from './storage';
|
|
15
17
|
import { Client } from './client';
|
|
@@ -37,9 +39,11 @@ export declare class Momentum extends PathEventEmitter {
|
|
|
37
39
|
client: Client;
|
|
38
40
|
data: Data;
|
|
39
41
|
email: Email;
|
|
42
|
+
forms: Forms;
|
|
40
43
|
groups: Groups;
|
|
41
44
|
logger: Logger;
|
|
42
45
|
payments: Payments;
|
|
46
|
+
phone: Phone;
|
|
43
47
|
pdf: Pdf;
|
|
44
48
|
settings: Settings;
|
|
45
49
|
socket?: Socket;
|
package/dist/momentum.d.ts.map
CHANGED
|
@@ -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,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,GAAG,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AACtC,OAAO,EAAC,IAAI,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAA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;IAClB,EAAE,EAAG,EAAE,CAAC;IACR,SAAS,EAAG,SAAS,CAAC;IACtB,IAAI,EAAG,IAAI,CAAC;IACZ,MAAM,EAAG,MAAM,CAAC;IAChB,IAAI,EAAG,IAAI,CAAC;IACZ,KAAK,EAAG,KAAK,CAAC;IACd,KAAK,EAAG,KAAK,CAAC;IACd,MAAM,EAAG,MAAM,CAAC;IAChB,MAAM,EAAG,MAAM,CAAC;IAChB,QAAQ,EAAG,QAAQ,CAAC;IACpB,KAAK,EAAG,KAAK,CAAC;IACd,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,KAAK,EAAG,KAAK,CAAC;gBAEF,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe;CAmDhD"}
|
package/dist/phone.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PathEventEmitter } from '@ztimson/utils';
|
|
2
|
+
import { Api } from './api';
|
|
3
|
+
export type Message = {
|
|
4
|
+
_id?: string;
|
|
5
|
+
_createdBy?: string;
|
|
6
|
+
_createdDate?: Date;
|
|
7
|
+
to: string;
|
|
8
|
+
from?: string;
|
|
9
|
+
body: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
} | string;
|
|
12
|
+
};
|
|
13
|
+
export declare class Phone extends PathEventEmitter {
|
|
14
|
+
private readonly api;
|
|
15
|
+
constructor(api: Api | string);
|
|
16
|
+
sms(message: Message): import('@ztimson/utils').PromiseProgress<any>;
|
|
17
|
+
voice(message: Message): import('@ztimson/utils').PromiseProgress<any>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=phone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone.d.ts","sourceRoot":"","sources":["../src/phone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,OAAO,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,MAAM,CAAC;CACvC,CAAA;AAED,qBAAa,KAAM,SAAQ,gBAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,GAAG,CAAC,OAAO,EAAE,OAAO;IAKpB,KAAK,CAAC,OAAO,EAAE,OAAO;CAItB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ztimson/momentum",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Client library for momentum",
|
|
5
5
|
"keywords": ["Momentum"],
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"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')\""
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ztimson/utils": "0.
|
|
27
|
+
"@ztimson/utils": "0.22.6",
|
|
28
28
|
"var-persist": "^1.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|