@ztimson/momentum 0.53.1 → 0.58.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 +200 -148
- package/bin/build-models.mjs +28 -37
- package/dist/actions.d.ts +32 -43
- package/dist/actions.d.ts.map +1 -1
- package/dist/ai.d.ts +38 -17
- package/dist/ai.d.ts.map +1 -1
- package/dist/analytics.d.ts +169 -36
- package/dist/analytics.d.ts.map +1 -1
- package/dist/api.d.ts +22 -22
- package/dist/api.d.ts.map +1 -1
- package/dist/asset-controller.d.ts +92 -0
- package/dist/asset-controller.d.ts.map +1 -0
- package/dist/audit.d.ts +22 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/auth.d.ts +39 -92
- package/dist/auth.d.ts.map +1 -1
- package/dist/call.d.ts +39 -0
- package/dist/call.d.ts.map +1 -0
- package/dist/captcha.d.ts +14 -0
- package/dist/captcha.d.ts.map +1 -0
- package/dist/client.d.ts +44 -33
- package/dist/client.d.ts.map +1 -1
- package/dist/core.d.ts +50 -21
- package/dist/core.d.ts.map +1 -1
- package/dist/data.d.ts +59 -77
- package/dist/data.d.ts.map +1 -1
- package/dist/dialog.d.ts +11 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/discounts.d.ts +8 -12
- package/dist/discounts.d.ts.map +1 -1
- package/dist/email.d.ts +19 -19
- package/dist/email.d.ts.map +1 -1
- package/dist/forms.d.ts +6 -13
- package/dist/forms.d.ts.map +1 -1
- package/dist/groups.d.ts +22 -16
- package/dist/groups.d.ts.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4446 -0
- package/dist/index.mjs +3422 -1731
- package/dist/logger.d.ts +78 -48
- package/dist/logger.d.ts.map +1 -1
- package/dist/momentum.d.ts +69 -15
- package/dist/momentum.d.ts.map +1 -1
- package/dist/momentum.worker.d.mts +2 -0
- package/dist/momentum.worker.d.mts.map +1 -0
- package/dist/momentum.worker.mjs +103 -0
- package/dist/notifications.d.ts +39 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/pdf.d.ts +31 -14
- package/dist/pdf.d.ts.map +1 -1
- package/dist/products.d.ts +47 -0
- package/dist/products.d.ts.map +1 -0
- package/dist/routes.d.ts +40 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/schemas.d.ts +79 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/settings.d.ts +30 -14
- package/dist/settings.d.ts.map +1 -1
- package/dist/sms.d.ts +14 -0
- package/dist/sms.d.ts.map +1 -0
- package/dist/sockets.d.ts +21 -10
- package/dist/sockets.d.ts.map +1 -1
- package/dist/static.d.ts +4 -2
- package/dist/static.d.ts.map +1 -1
- package/dist/storage.d.ts +103 -24
- package/dist/storage.d.ts.map +1 -1
- package/dist/templates.d.ts +23 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/totp.d.ts +45 -0
- package/dist/totp.d.ts.map +1 -0
- package/dist/transactions.d.ts +153 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/users.d.ts +63 -25
- package/dist/users.d.ts.map +1 -1
- package/dist/webRtc.d.ts +39 -0
- package/dist/webRtc.d.ts.map +1 -0
- package/package.json +53 -43
- package/dist/index.cjs +0 -2755
- package/dist/momentum.worker.js +0 -16
- package/dist/payments.d.ts +0 -184
- package/dist/payments.d.ts.map +0 -1
- package/dist/phone.d.ts +0 -19
- package/dist/phone.d.ts.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { AssetController } from './asset-controller';
|
|
2
|
+
import { Meta } from './core';
|
|
3
|
+
import { Momentum } from './momentum';
|
|
4
|
+
/** Credit-card information for payments */
|
|
5
|
+
export type Card = {
|
|
6
|
+
/** Credit-card number */
|
|
7
|
+
number: number | string;
|
|
8
|
+
/** Year card expires */
|
|
9
|
+
expYear: number | string;
|
|
10
|
+
/** Month card expires */
|
|
11
|
+
expMonth: number | string;
|
|
12
|
+
/** 3 digit security code */
|
|
13
|
+
csv: number | string;
|
|
14
|
+
/** Additional details for anti-fraud */
|
|
15
|
+
details?: {
|
|
16
|
+
/** Cardholder name */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Billing address */
|
|
19
|
+
address?: {
|
|
20
|
+
postal_code?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** User financial status */
|
|
25
|
+
export type Finances = {
|
|
26
|
+
/** Username */
|
|
27
|
+
readonly _id?: string;
|
|
28
|
+
/** Account balance */
|
|
29
|
+
readonly balance: number;
|
|
30
|
+
/** Account subscriptions */
|
|
31
|
+
readonly subscriptions: {
|
|
32
|
+
/** Product ID */
|
|
33
|
+
readonly _id: string;
|
|
34
|
+
/** Date subscription started */
|
|
35
|
+
readonly created: Date;
|
|
36
|
+
/** Number of days the subscription lasts */
|
|
37
|
+
readonly interval: number;
|
|
38
|
+
/** Date of next renewal, null if cancelled */
|
|
39
|
+
readonly renewal?: Date | null;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
/** Purchase options */
|
|
43
|
+
export type Transaction = Meta & {
|
|
44
|
+
/** Purchased items */
|
|
45
|
+
readonly cart: {
|
|
46
|
+
/** Product ID number, 'balance' for credit or null if custom */
|
|
47
|
+
readonly _id?: number | 'balance';
|
|
48
|
+
/** Product name or description */
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/** Number of units to purchase */
|
|
51
|
+
readonly quantity: number;
|
|
52
|
+
/** Individual unit cost */
|
|
53
|
+
readonly cost: number;
|
|
54
|
+
}[];
|
|
55
|
+
/** How was the Payment completed */
|
|
56
|
+
readonly complete?: string;
|
|
57
|
+
/** Apply credit (Infinity to use all credit) */
|
|
58
|
+
readonly credit: number;
|
|
59
|
+
/** Apply discount */
|
|
60
|
+
readonly discount?: {
|
|
61
|
+
code?: string;
|
|
62
|
+
type: 'fixed' | 'percent';
|
|
63
|
+
value: number;
|
|
64
|
+
};
|
|
65
|
+
/** Receipt/Invoice number */
|
|
66
|
+
readonly invoiceNum?: string;
|
|
67
|
+
/** Payment notes */
|
|
68
|
+
readonly notes?: string | null;
|
|
69
|
+
/** Recipient username or information */
|
|
70
|
+
readonly recipient?: {
|
|
71
|
+
/** Billing address */
|
|
72
|
+
readonly address?: string;
|
|
73
|
+
/** Delivery email */
|
|
74
|
+
readonly email?: string;
|
|
75
|
+
/** Receipt name */
|
|
76
|
+
readonly name?: string;
|
|
77
|
+
/** Account name */
|
|
78
|
+
readonly username?: string;
|
|
79
|
+
};
|
|
80
|
+
/** Whether the Payment/invoice has been refunded / canceled respectively */
|
|
81
|
+
readonly refunded?: boolean;
|
|
82
|
+
/** Current status of Payment - null for self-checkout */
|
|
83
|
+
readonly status?: 'Invoice' | 'Cancelled' | 'Receipt' | 'Refunded';
|
|
84
|
+
/** Payment total */
|
|
85
|
+
readonly subtotal: number;
|
|
86
|
+
/** Tax percentage as float */
|
|
87
|
+
readonly tax: number;
|
|
88
|
+
/** Payment total (subtotal - discount - credit + tax) */
|
|
89
|
+
readonly total: number;
|
|
90
|
+
/** Stripe Payment */
|
|
91
|
+
readonly tx?: any;
|
|
92
|
+
};
|
|
93
|
+
/** Process payments */
|
|
94
|
+
export declare class Transactions extends AssetController<Transaction> {
|
|
95
|
+
protected momentum: Momentum;
|
|
96
|
+
/** Stripe object */
|
|
97
|
+
stripe?: any;
|
|
98
|
+
constructor(momentum: Momentum);
|
|
99
|
+
/**
|
|
100
|
+
* Initialize stripe API
|
|
101
|
+
* @return {Promise<any>} Returns stripe API
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
private initStripe;
|
|
105
|
+
/**
|
|
106
|
+
* Create a stripe client secret to complete Payment
|
|
107
|
+
* @param {string} id Payment ID
|
|
108
|
+
* @return {Promise<string>} Client secret
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
private getToken;
|
|
112
|
+
/**
|
|
113
|
+
* Process transaction programmatically
|
|
114
|
+
* @param {string} id Transaction ID
|
|
115
|
+
* @param {Card} card Credit card information
|
|
116
|
+
* @return {Promise<any>} Stripe confirmation
|
|
117
|
+
*/
|
|
118
|
+
checkout(id: string, card: Card): Promise<any>;
|
|
119
|
+
/**
|
|
120
|
+
* Process transaction using Stripe form
|
|
121
|
+
* @param {string} id Transaction ID
|
|
122
|
+
* @param {string} element DOM element to inject form into
|
|
123
|
+
* @return {Promise<() => Promise<any>>} Callback to submit form
|
|
124
|
+
*/
|
|
125
|
+
checkoutForm(id: string, element: string): Promise<() => Promise<any>>;
|
|
126
|
+
/**
|
|
127
|
+
* Complete transaction via Momentum's checkout page
|
|
128
|
+
* @param {string} id Transaction ID
|
|
129
|
+
* @param {string} host Host origin attempting to login
|
|
130
|
+
* @return {Promise<string>} Translation ID on success
|
|
131
|
+
*/
|
|
132
|
+
checkoutRedirect(id: string, host?: string): Promise<string>;
|
|
133
|
+
/**
|
|
134
|
+
* Get URL to checkout page for transaction
|
|
135
|
+
* @param {string} id Transaction ID
|
|
136
|
+
* @returns {string} URL
|
|
137
|
+
*/
|
|
138
|
+
checkoutUrl(id: string): string;
|
|
139
|
+
delete(key: string): Promise<number>;
|
|
140
|
+
/**
|
|
141
|
+
* Send recipient transaction receipt or invoice
|
|
142
|
+
* @param {string} id Translation ID
|
|
143
|
+
* @return {Promise<void>} Returns once complete
|
|
144
|
+
*/
|
|
145
|
+
notify(id: string): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Refund a transaction
|
|
148
|
+
* @param {string} key Asset primary key
|
|
149
|
+
* @return {Promise<Transaction>} Returns on success
|
|
150
|
+
*/
|
|
151
|
+
refund(key: string): Promise<Transaction>;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,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AAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG,CAAA;CACjB,CAAA;AAED,uBAAuB;AACvB,qBAAa,YAAa,SAAQ,eAAe,CAAC,WAAW,CAAC;IAIjD,SAAS,CAAC,QAAQ,EAAE,QAAQ;IAHxC,oBAAoB;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;gBAES,QAAQ,EAAE,QAAQ;IAIxC;;;;OAIG;YACW,UAAU;IAaxB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAKhB;;;;;OAKG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAapD;;;;;OAKG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAW5E;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,MAAwB,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB7E;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM;IAIhB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1C;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC;;;;OAIG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAK/C"}
|
package/dist/users.d.ts
CHANGED
|
@@ -1,32 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { PromiseProgress } from '@ztimson/utils';
|
|
2
|
+
import { AssetController } from './asset-controller';
|
|
3
|
+
import { Alert, Meta } from './core';
|
|
4
|
+
import { Momentum } from './momentum';
|
|
5
|
+
import { Socket } from './sockets';
|
|
4
6
|
export type User = Meta & {
|
|
5
|
-
|
|
7
|
+
/** Username */
|
|
8
|
+
readonly _id: string;
|
|
9
|
+
/** Full name */
|
|
6
10
|
name: string;
|
|
7
|
-
email
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/** Contact email */
|
|
12
|
+
email: string | null;
|
|
13
|
+
/** Contact phone number */
|
|
14
|
+
phone: string | null;
|
|
15
|
+
/** Full primary address */
|
|
16
|
+
address: string | null;
|
|
17
|
+
/** Disable account */
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
/** Group membership */
|
|
12
20
|
groups: string[];
|
|
13
|
-
|
|
21
|
+
/** UI dashboard page */
|
|
22
|
+
dashboardUrl: string | null;
|
|
23
|
+
/** Redirect user to URL on login */
|
|
24
|
+
loginRedirect: string | null;
|
|
25
|
+
/** Subscribed alerts */
|
|
26
|
+
alerts: Alert[];
|
|
27
|
+
/** User permissions */
|
|
14
28
|
permissions: string[];
|
|
15
|
-
notes
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
/** User notes, not available without update permission */
|
|
30
|
+
notes: string;
|
|
31
|
+
/** Custom data, overrides group custom data */
|
|
32
|
+
custom: {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
};
|
|
35
|
+
/** Account balance */
|
|
36
|
+
readonly balance?: number;
|
|
37
|
+
/** Profile image URL */
|
|
38
|
+
readonly image?: string;
|
|
39
|
+
/** Last login timestamp */
|
|
40
|
+
readonly lastLogin?: null | {
|
|
41
|
+
from: Date;
|
|
42
|
+
to: Date | null;
|
|
43
|
+
};
|
|
44
|
+
/** Locked from useful login attempts */
|
|
45
|
+
readonly locked?: null | {
|
|
46
|
+
from: Date;
|
|
47
|
+
to: Date | null;
|
|
48
|
+
};
|
|
49
|
+
/** Product subscriptions */
|
|
50
|
+
readonly subscriptions?: any[];
|
|
51
|
+
/** 2FA method */
|
|
52
|
+
readonly totp?: string;
|
|
21
53
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
54
|
+
/** System users */
|
|
55
|
+
export declare class Users extends AssetController<User> {
|
|
56
|
+
protected momentum: Momentum;
|
|
57
|
+
protected socket?: Socket | undefined;
|
|
58
|
+
constructor(momentum: Momentum, socket?: Socket | undefined);
|
|
59
|
+
protected afterRead(user: any): any;
|
|
60
|
+
protected beforeWrite(user: any): any;
|
|
61
|
+
profileImage(username: string, token?: boolean): string;
|
|
62
|
+
/**
|
|
63
|
+
* Upload new profile image for user
|
|
64
|
+
* @param {string} username Target user
|
|
65
|
+
* @param {File} file File from form input
|
|
66
|
+
* @return {PromiseProgress<void>} Returns once upload is complete, provides progress callback
|
|
67
|
+
*/
|
|
68
|
+
uploadImage(username: string, file: File): PromiseProgress<void>;
|
|
31
69
|
}
|
|
32
70
|
//# sourceMappingURL=users.d.ts.map
|
package/dist/users.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAqB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAM,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG;IACzB,eAAe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AAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB,CAAA;AAED,mBAAmB;AACnB,qBAAa,KAAM,SAAQ,eAAe,CAAC,IAAI,CAAC;IACnC,SAAS,CAAC,QAAQ,EAAE,QAAQ;IAAE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM;gBAA7C,QAAQ,EAAE,QAAQ,EAAY,MAAM,CAAC,EAAE,MAAM,YAAA;IAInE,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG;IAM7B,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG;IAK/B,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,UAAO,GAAG,MAAM;IAMpD;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;CAOhE"}
|
package/dist/webRtc.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PathEventEmitter, Unsubscribe } from '@ztimson/utils';
|
|
2
|
+
import { Momentum } from './momentum';
|
|
3
|
+
/** WebRTC peer */
|
|
4
|
+
export type WebRTCPeer = {
|
|
5
|
+
/** Peer connection UID */
|
|
6
|
+
uid: string;
|
|
7
|
+
/** Peer username */
|
|
8
|
+
username: string;
|
|
9
|
+
/** Remote connection to stream */
|
|
10
|
+
connection: RTCPeerConnection;
|
|
11
|
+
/** Remote media stream */
|
|
12
|
+
stream?: MediaStream;
|
|
13
|
+
};
|
|
14
|
+
/** WebRTC session */
|
|
15
|
+
export type WebRTCSession = {
|
|
16
|
+
/** Is the connection active? */
|
|
17
|
+
open: boolean;
|
|
18
|
+
/** Room ID */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Connection UID */
|
|
21
|
+
uid: string;
|
|
22
|
+
/** Local media stream */
|
|
23
|
+
stream: MediaStream;
|
|
24
|
+
/** Connected peers sorted by UID */
|
|
25
|
+
peers: {
|
|
26
|
+
[key: string]: WebRTCPeer;
|
|
27
|
+
};
|
|
28
|
+
/** Disconnection session */
|
|
29
|
+
disconnect: Unsubscribe;
|
|
30
|
+
};
|
|
31
|
+
export declare class WebRtc extends PathEventEmitter {
|
|
32
|
+
private momentum;
|
|
33
|
+
private get ice();
|
|
34
|
+
constructor(momentum: Momentum);
|
|
35
|
+
private answer;
|
|
36
|
+
private offer;
|
|
37
|
+
connect(id?: string, audio?: boolean, video?: boolean): Promise<WebRTCSession>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=webRtc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtc.d.ts","sourceRoot":"","sources":["../src/webRtc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,gBAAgB,EAAuB,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,kBAAkB;AAClB,MAAM,MAAM,UAAU,GAAG;IACxB,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,0BAA0B;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,CAAA;AAED,qBAAqB;AACrB,MAAM,MAAM,aAAa,GAAG;IAC3B,gCAAgC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,oCAAoC;IACpC,KAAK,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAC;IACnC,4BAA4B;IAC5B,UAAU,EAAE,WAAW,CAAC;CACxB,CAAA;AAED,qBAAa,MAAO,SAAQ,gBAAgB;IAY/B,OAAO,CAAC,QAAQ;IAV5B,OAAO,KAAK,GAAG,GAQd;gBAEmB,QAAQ,EAAE,QAAQ;YAIxB,MAAM;YAaN,KAAK;IAWb,OAAO,CAAC,EAAE,GAAE,MAA4C,EAAE,KAAK,UAAO,EAAE,KAAK,UAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CA6EnH"}
|
package/package.json
CHANGED
|
@@ -1,43 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ztimson/momentum",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Client library for momentum",
|
|
5
|
-
"keywords": [
|
|
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
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@ztimson/momentum",
|
|
3
|
+
"version": "0.58.0",
|
|
4
|
+
"description": "Client library for momentum",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Momentum"
|
|
7
|
+
],
|
|
8
|
+
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://git.zakscode.com/momentum/momentum"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/index.cjs",
|
|
14
|
+
"module": "dist/index.mjs",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"typings": "dist/index.d.ts",
|
|
17
|
+
"bin": {
|
|
18
|
+
"build-models": "bin/build-models.mjs"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.mjs",
|
|
24
|
+
"require": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"start": "vite build --watch",
|
|
29
|
+
"prebuild": "node -e \"const fs=require('fs');fs.cpSync('../README.md','./README.md')\"",
|
|
30
|
+
"build": "tsc && vite build",
|
|
31
|
+
"build:docs": "typedoc",
|
|
32
|
+
"build-models": "node --no-warnings ./bin/build-models.mjs",
|
|
33
|
+
"postbuild": "npm run build:docs && node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.js','../server/public/momentum.js');fs.cpSync('dist/momentum.worker.mjs','../server/public/momentum.worker.mjs')\""
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@ztimson/utils": "0.28.12"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.5.4",
|
|
40
|
+
"tweetnacl": "^1.0.3",
|
|
41
|
+
"typedoc": "^0.28.3",
|
|
42
|
+
"typedoc-github-wiki-theme": "^2.1.0",
|
|
43
|
+
"typedoc-plugin-markdown": "^4.6.3",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vite": "^7.2.4",
|
|
46
|
+
"vite-plugin-dts": "^4.5.4",
|
|
47
|
+
"vite-plugin-static-copy": "^3.1.4"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"bin",
|
|
51
|
+
"dist"
|
|
52
|
+
]
|
|
53
|
+
}
|