@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.
Files changed (86) hide show
  1. package/README.md +200 -148
  2. package/bin/build-models.mjs +28 -37
  3. package/dist/actions.d.ts +32 -43
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/ai.d.ts +38 -17
  6. package/dist/ai.d.ts.map +1 -1
  7. package/dist/analytics.d.ts +169 -36
  8. package/dist/analytics.d.ts.map +1 -1
  9. package/dist/api.d.ts +22 -22
  10. package/dist/api.d.ts.map +1 -1
  11. package/dist/asset-controller.d.ts +92 -0
  12. package/dist/asset-controller.d.ts.map +1 -0
  13. package/dist/audit.d.ts +22 -0
  14. package/dist/audit.d.ts.map +1 -0
  15. package/dist/auth.d.ts +39 -92
  16. package/dist/auth.d.ts.map +1 -1
  17. package/dist/call.d.ts +39 -0
  18. package/dist/call.d.ts.map +1 -0
  19. package/dist/captcha.d.ts +14 -0
  20. package/dist/captcha.d.ts.map +1 -0
  21. package/dist/client.d.ts +44 -33
  22. package/dist/client.d.ts.map +1 -1
  23. package/dist/core.d.ts +50 -21
  24. package/dist/core.d.ts.map +1 -1
  25. package/dist/data.d.ts +59 -77
  26. package/dist/data.d.ts.map +1 -1
  27. package/dist/dialog.d.ts +11 -0
  28. package/dist/dialog.d.ts.map +1 -0
  29. package/dist/discounts.d.ts +8 -12
  30. package/dist/discounts.d.ts.map +1 -1
  31. package/dist/email.d.ts +19 -19
  32. package/dist/email.d.ts.map +1 -1
  33. package/dist/forms.d.ts +6 -13
  34. package/dist/forms.d.ts.map +1 -1
  35. package/dist/groups.d.ts +22 -16
  36. package/dist/groups.d.ts.map +1 -1
  37. package/dist/index.d.ts +13 -3
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +4446 -0
  40. package/dist/index.mjs +3422 -1731
  41. package/dist/logger.d.ts +78 -48
  42. package/dist/logger.d.ts.map +1 -1
  43. package/dist/momentum.d.ts +69 -15
  44. package/dist/momentum.d.ts.map +1 -1
  45. package/dist/momentum.worker.d.mts +2 -0
  46. package/dist/momentum.worker.d.mts.map +1 -0
  47. package/dist/momentum.worker.mjs +103 -0
  48. package/dist/notifications.d.ts +39 -0
  49. package/dist/notifications.d.ts.map +1 -0
  50. package/dist/pdf.d.ts +31 -14
  51. package/dist/pdf.d.ts.map +1 -1
  52. package/dist/products.d.ts +47 -0
  53. package/dist/products.d.ts.map +1 -0
  54. package/dist/routes.d.ts +40 -0
  55. package/dist/routes.d.ts.map +1 -0
  56. package/dist/schemas.d.ts +79 -0
  57. package/dist/schemas.d.ts.map +1 -0
  58. package/dist/settings.d.ts +30 -14
  59. package/dist/settings.d.ts.map +1 -1
  60. package/dist/sms.d.ts +14 -0
  61. package/dist/sms.d.ts.map +1 -0
  62. package/dist/sockets.d.ts +21 -10
  63. package/dist/sockets.d.ts.map +1 -1
  64. package/dist/static.d.ts +4 -2
  65. package/dist/static.d.ts.map +1 -1
  66. package/dist/storage.d.ts +103 -24
  67. package/dist/storage.d.ts.map +1 -1
  68. package/dist/templates.d.ts +23 -0
  69. package/dist/templates.d.ts.map +1 -0
  70. package/dist/tokens.d.ts +50 -0
  71. package/dist/tokens.d.ts.map +1 -0
  72. package/dist/totp.d.ts +45 -0
  73. package/dist/totp.d.ts.map +1 -0
  74. package/dist/transactions.d.ts +153 -0
  75. package/dist/transactions.d.ts.map +1 -0
  76. package/dist/users.d.ts +63 -25
  77. package/dist/users.d.ts.map +1 -1
  78. package/dist/webRtc.d.ts +39 -0
  79. package/dist/webRtc.d.ts.map +1 -0
  80. package/package.json +53 -43
  81. package/dist/index.cjs +0 -2755
  82. package/dist/momentum.worker.js +0 -16
  83. package/dist/payments.d.ts +0 -184
  84. package/dist/payments.d.ts.map +0 -1
  85. package/dist/phone.d.ts +0 -19
  86. package/dist/phone.d.ts.map +0 -1
@@ -1,16 +0,0 @@
1
- self.addEventListener('push', (event) => {
2
- if(!(self.Notification && self.Notification.permission === "granted")) return;
3
- const data = event.data?.json() ?? {};
4
- self.registration.showNotification(data.title, {
5
- body: data.message,
6
- tag: data.title || 'general',
7
- icon: data.icon || `/favicon.ico`,
8
- data
9
- });
10
- });
11
-
12
- self.addEventListener('notificationclick', (event) => {
13
- const data = event.notification.data;
14
- event.notification.close();
15
- if (data.link) event.waitUntil(clients.openWindow(data.link));
16
- });
@@ -1,184 +0,0 @@
1
- import { PathEventEmitter } from '@ztimson/utils';
2
- import { Api } from './api';
3
- import { Meta } from './core';
4
- import { Discounts } from './discounts';
5
- /** Credit-card information for payments */
6
- export type Card = {
7
- /** Credit-card number */
8
- number: number | string;
9
- /** Year card expires */
10
- expYear: number | string;
11
- /** Month card expires */
12
- expMonth: number | string;
13
- /** 3 digit security code */
14
- csv: number | string;
15
- /** Additional details for anti-fraud */
16
- details?: {
17
- /** Cardholder name */
18
- name?: string;
19
- /** Billing address */
20
- address?: {
21
- postal_code?: string;
22
- };
23
- };
24
- };
25
- /** User financial status */
26
- export type Finances = {
27
- /** Username */
28
- _id?: string;
29
- /** Account balance */
30
- balance: number;
31
- /** Account subscriptions */
32
- subscriptions: {
33
- /** Product ID */
34
- _id: string;
35
- /** Date subscription started */
36
- created: Date;
37
- /** Number of days the subscription lasts */
38
- interval: number;
39
- /** Date of next renewal, null if cancelled */
40
- renewal?: Date | null;
41
- }[];
42
- };
43
- /** Payment API options */
44
- export type PaymentOptions = {
45
- /** Path to payment page */
46
- paymentUrl?: string;
47
- };
48
- /** Returned products */
49
- export type Product<T = any> = T & {
50
- _id: number;
51
- name: string;
52
- cost: number;
53
- subscription?: number;
54
- socked: boolean;
55
- };
56
- /** Purchase options */
57
- export type Transaction = Meta & {
58
- /** Purchased items */
59
- cart: {
60
- /** Product ID number, 'balance' for credit or null if custom */
61
- _id?: number | 'balance';
62
- /** Product name or description */
63
- name: string;
64
- /** Number of units to purchase */
65
- quantity: number;
66
- /** Individual unit cost */
67
- cost: number;
68
- }[];
69
- /** How was the transaction completed */
70
- complete?: string;
71
- /** Apply credit (Infinity to use all credit) */
72
- credit: number;
73
- /** Apply discount */
74
- discount?: {
75
- code?: string;
76
- type: 'fixed' | 'percent';
77
- value: number;
78
- };
79
- /** Receipt/Invoice number */
80
- invoiceNum?: string;
81
- /** Transaction notes */
82
- notes?: string | null;
83
- /** Recipient username or information */
84
- recipient?: {
85
- /** Billing address */
86
- address?: string;
87
- /** Delivery email */
88
- email?: string;
89
- /** Receipt name */
90
- name?: string;
91
- /** Account name */
92
- username?: string;
93
- };
94
- /** Whether the transaction/invoice has been refunded / canceled respectively */
95
- refunded?: boolean;
96
- /** Current status of transaction - null for self-checkout */
97
- status?: 'Invoice' | 'Cancelled' | 'Receipt' | 'Refunded';
98
- /** Transaction total */
99
- subtotal: number;
100
- /** Tax percentage as float */
101
- tax: number;
102
- /** Transaction total (subtotal - discount - credit + tax) */
103
- total: number;
104
- /** Stripe transaction */
105
- tx?: any;
106
- };
107
- export declare class Payments extends PathEventEmitter {
108
- readonly opts: PaymentOptions;
109
- private readonly api;
110
- discounts: Discounts;
111
- /** Stripe object */
112
- stripe?: any;
113
- /** Public stripe token */
114
- token?: string;
115
- constructor(api: Api | string, opts?: PaymentOptions);
116
- /**
117
- * Initialize stripe API
118
- * @return {Promise<any>} Returns stripe API
119
- * @private
120
- */
121
- private init;
122
- /**
123
- * Create a stripe client secret to complete transaction
124
- * @param {string} id Transaction ID
125
- * @return {Promise<string>} Client secret
126
- * @private
127
- */
128
- private createSecret;
129
- /**
130
- * Create/Update a transaction
131
- * @param {Optional<Transaction, "subtotal" | "total">} transaction Transaction information
132
- * @return {Promise<string>} Completed translation information
133
- */
134
- checkout(transaction: Partial<Transaction> & {
135
- recipient: string;
136
- discount: string;
137
- }): Promise<Transaction>;
138
- /**
139
- * Get translation history
140
- * @param {string} username Limit history to user
141
- * @return {Promise<Transaction[]>} List of translations
142
- */
143
- history(username?: string): Promise<Transaction[]>;
144
- /**
145
- * Send recipient transaction receipt or invoice
146
- * @param {string} id Translation ID
147
- * @return {Promise<void>} Returns once complete
148
- */
149
- notify(id: string): Promise<void>;
150
- /**
151
- * Retrieve a list of available products
152
- * @param {string | number} id Limit to specific product
153
- * @return {Promise<any>} List of products or single product if ID is used
154
- */
155
- products<T = any>(id?: string): Promise<T[]>;
156
- /**
157
- * Process payment programmatically
158
- * @param {string} id Transaction ID
159
- * @param {Card} card Credit card information
160
- * @return {Promise<any>} Stripe confirmation
161
- */
162
- payment(id: string, card: Card): Promise<any>;
163
- /**
164
- * Process payment using Stripe form
165
- * @param {string} id Transaction ID
166
- * @param {string} element DOM element to inject form into
167
- * @return {Promise<() => Promise<any>>} Callback to submit form
168
- */
169
- paymentForm(id: string, element: string): Promise<() => Promise<any>>;
170
- /**
171
- * Complete payment via Momentum's payment page
172
- * @param {string} id Transaction ID
173
- * @param {string} host Host origin attempting to login
174
- * @return {Promise<string>} Translation ID on success
175
- */
176
- paymentRedirect(id: string, host?: string): Promise<string>;
177
- /**
178
- * Refund a transaction
179
- * @param {string} id Transaction number to refund
180
- * @return {PromiseProgress<any>}
181
- */
182
- refund(id: string): import('@ztimson/utils').PromiseProgress<any>;
183
- }
184
- //# sourceMappingURL=payments.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,2CAA2C;AAC3C,MAAM,MAAM,IAAI,GAAG;IAClB,yBAAyB;IACzB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,wBAAwB;IACxB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,yBAAyB;IACzB,QAAQ,EAAE,MAAM,GAAG,MAAM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IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEH,GAAG,EAAE,GAAG,GAAG,MAAM,EAAkB,IAAI,GAAE,cAAmB;IAaxE;;;;OAIG;YACW,IAAI;IAYlB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAKpB;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAWzG;;;;OAIG;IACG,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAOxD;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC;;;;OAIG;IACH,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAO5C;;;;;OAKG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAanD;;;;;OAKG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAW3E;;;;;OAKG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,MAAwB,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB5E;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM;CAMjB"}
package/dist/phone.d.ts DELETED
@@ -1,19 +0,0 @@
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
@@ -1 +0,0 @@
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"}