@casual-simulation/aux-records 3.8.1 → 3.10.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.
Files changed (239) hide show
  1. package/AIChatInterface.d.ts +7 -43
  2. package/AIChatInterface.js +8 -6
  3. package/AIChatInterface.js.map +1 -1
  4. package/AIController.js +44 -49
  5. package/AIController.js.map +1 -1
  6. package/AIOpenAIRealtimeInterface.d.ts +1 -1
  7. package/AnthropicAIChatInterface.js +4 -4
  8. package/AnthropicAIChatInterface.js.map +1 -1
  9. package/AuthController.d.ts +78 -10
  10. package/AuthController.js +230 -166
  11. package/AuthController.js.map +1 -1
  12. package/AuthStore.d.ts +317 -4
  13. package/BigIntPatch.d.ts +1 -0
  14. package/BigIntPatch.js +24 -0
  15. package/BigIntPatch.js.map +1 -0
  16. package/BlockadeLabsGenerateSkyboxInterface.js +4 -4
  17. package/BlockadeLabsGenerateSkyboxInterface.js.map +1 -1
  18. package/CachingConfigStore.d.ts +8 -1
  19. package/CachingConfigStore.js +50 -0
  20. package/CachingConfigStore.js.map +1 -1
  21. package/ComIdConfig.d.ts +132 -86
  22. package/ComIdConfig.js +5 -5
  23. package/ComIdConfig.js.map +1 -1
  24. package/ConfigurationStore.d.ts +1393 -3
  25. package/ConfigurationStore.js +49 -0
  26. package/ConfigurationStore.js.map +1 -1
  27. package/DataRecordsController.js +28 -28
  28. package/DataRecordsController.js.map +1 -1
  29. package/EventRecordsController.js +9 -9
  30. package/EventRecordsController.js.map +1 -1
  31. package/FileRecordsController.js +18 -17
  32. package/FileRecordsController.js.map +1 -1
  33. package/GoogleAIChatInterface.js +4 -4
  34. package/GoogleAIChatInterface.js.map +1 -1
  35. package/HttpTestUtils.d.ts +48 -0
  36. package/HttpTestUtils.js +256 -0
  37. package/HttpTestUtils.js.map +1 -0
  38. package/LivekitController.js +2 -2
  39. package/LivekitController.js.map +1 -1
  40. package/LoomController.js +3 -4
  41. package/LoomController.js.map +1 -1
  42. package/MemoryStore.d.ts +60 -7
  43. package/MemoryStore.js +427 -59
  44. package/MemoryStore.js.map +1 -1
  45. package/MetricsStore.d.ts +11 -0
  46. package/ModerationConfiguration.d.ts +11 -85
  47. package/ModerationConfiguration.js +17 -17
  48. package/ModerationConfiguration.js.map +1 -1
  49. package/ModerationController.js +9 -11
  50. package/ModerationController.js.map +1 -1
  51. package/OpenAIChatInterface.js +8 -13
  52. package/OpenAIChatInterface.js.map +1 -1
  53. package/OpenAIImageInterface.js +4 -5
  54. package/OpenAIImageInterface.js.map +1 -1
  55. package/PolicyController.js +66 -73
  56. package/PolicyController.js.map +1 -1
  57. package/PolicyStore.d.ts +59 -33
  58. package/PolicyStore.js +35 -1
  59. package/PolicyStore.js.map +1 -1
  60. package/PrivoClient.d.ts +3 -1
  61. package/PrivoClient.js +2 -4
  62. package/PrivoClient.js.map +1 -1
  63. package/PrivoConfiguration.d.ts +6 -72
  64. package/PrivoConfiguration.js +30 -31
  65. package/PrivoConfiguration.js.map +1 -1
  66. package/README.md +276 -2
  67. package/RateLimitController.js +2 -2
  68. package/RateLimitController.js.map +1 -1
  69. package/RecordsClient.d.ts +3 -1
  70. package/RecordsClient.js +6 -6
  71. package/RecordsClient.js.map +1 -1
  72. package/RecordsController.d.ts +145 -3
  73. package/RecordsController.js +399 -61
  74. package/RecordsController.js.map +1 -1
  75. package/RecordsServer.d.ts +1932 -1109
  76. package/RecordsStore.d.ts +99 -14
  77. package/RecordsStore.js +8 -10
  78. package/RecordsStore.js.map +1 -1
  79. package/ServerConfig.d.ts +698 -9867
  80. package/ServerConfig.js +457 -377
  81. package/ServerConfig.js.map +1 -1
  82. package/SloydInterface.js +1 -1
  83. package/SloydInterface.js.map +1 -1
  84. package/StabilityAIImageInterface.js +6 -9
  85. package/StabilityAIImageInterface.js.map +1 -1
  86. package/StripeInterface.d.ts +431 -287
  87. package/StripeInterface.js +21 -1
  88. package/StripeInterface.js.map +1 -1
  89. package/SubscriptionConfigBuilder.d.ts +10 -1
  90. package/SubscriptionConfigBuilder.js +72 -41
  91. package/SubscriptionConfigBuilder.js.map +1 -1
  92. package/SubscriptionConfiguration.d.ts +606 -6334
  93. package/SubscriptionConfiguration.js +460 -277
  94. package/SubscriptionConfiguration.js.map +1 -1
  95. package/SubscriptionController.d.ts +677 -4
  96. package/SubscriptionController.js +2986 -186
  97. package/SubscriptionController.js.map +1 -1
  98. package/SystemNotificationMessenger.d.ts +14 -70
  99. package/SystemNotificationMessenger.js +17 -20
  100. package/SystemNotificationMessenger.js.map +1 -1
  101. package/TestUtils.d.ts +18 -3
  102. package/TestUtils.js +84 -8
  103. package/TestUtils.js.map +1 -1
  104. package/TypeUtils.d.ts +991 -0
  105. package/TypeUtils.js +2 -0
  106. package/TypeUtils.js.map +1 -0
  107. package/Utils.d.ts +59 -0
  108. package/Utils.js +507 -3
  109. package/Utils.js.map +1 -1
  110. package/Validations.d.ts +24 -108
  111. package/Validations.js +62 -45
  112. package/Validations.js.map +1 -1
  113. package/ViewTemplateRenderer.d.ts +39 -0
  114. package/ViewTemplateRenderer.js +19 -0
  115. package/ViewTemplateRenderer.js.map +1 -0
  116. package/contracts/ContractRecordsController.d.ts +58 -0
  117. package/contracts/ContractRecordsController.js +144 -0
  118. package/contracts/ContractRecordsController.js.map +1 -0
  119. package/contracts/ContractRecordsStore.d.ts +285 -0
  120. package/contracts/ContractRecordsStore.js +19 -0
  121. package/contracts/ContractRecordsStore.js.map +1 -0
  122. package/contracts/MemoryContractRecordsStore.d.ts +27 -0
  123. package/contracts/MemoryContractRecordsStore.js +124 -0
  124. package/contracts/MemoryContractRecordsStore.js.map +1 -0
  125. package/contracts/index.d.ts +4 -0
  126. package/contracts/index.js +21 -0
  127. package/contracts/index.js.map +1 -0
  128. package/crud/CrudHelpers.d.ts +25 -26
  129. package/crud/CrudHelpers.js +1 -1
  130. package/crud/CrudHelpers.js.map +1 -1
  131. package/crud/CrudRecordsController.js +13 -16
  132. package/crud/CrudRecordsController.js.map +1 -1
  133. package/crud/CrudRecordsControllerTests.d.ts +2 -2
  134. package/crud/CrudRecordsControllerTests.js +605 -580
  135. package/crud/CrudRecordsControllerTests.js.map +1 -1
  136. package/crud/MemoryCrudRecordsStore.js +1 -2
  137. package/crud/MemoryCrudRecordsStore.js.map +1 -1
  138. package/crud/sub/MemorySubCrudRecordsStore.js +4 -6
  139. package/crud/sub/MemorySubCrudRecordsStore.js.map +1 -1
  140. package/crud/sub/SubCrudRecordsController.js +8 -8
  141. package/crud/sub/SubCrudRecordsController.js.map +1 -1
  142. package/database/DatabaseRecordsController.js +1 -2
  143. package/database/DatabaseRecordsController.js.map +1 -1
  144. package/database/SqliteDatabaseInterface.js +1 -2
  145. package/database/SqliteDatabaseInterface.js.map +1 -1
  146. package/dns/DNSDomainNameValidator.d.ts +11 -0
  147. package/dns/DNSDomainNameValidator.js +59 -0
  148. package/dns/DNSDomainNameValidator.js.map +1 -0
  149. package/dns/DomainNameValidator.d.ts +36 -0
  150. package/dns/DomainNameValidator.js +19 -0
  151. package/dns/DomainNameValidator.js.map +1 -0
  152. package/dns/index.d.ts +3 -0
  153. package/dns/index.js +20 -0
  154. package/dns/index.js.map +1 -0
  155. package/financial/FinancialController.d.ts +272 -0
  156. package/financial/FinancialController.js +762 -0
  157. package/financial/FinancialController.js.map +1 -0
  158. package/financial/FinancialInterface.d.ts +352 -0
  159. package/financial/FinancialInterface.js +642 -0
  160. package/financial/FinancialInterface.js.map +1 -0
  161. package/financial/FinancialStore.d.ts +186 -0
  162. package/financial/FinancialStore.js +19 -0
  163. package/financial/FinancialStore.js.map +1 -0
  164. package/financial/MemoryFinancialInterface.d.ts +23 -0
  165. package/financial/MemoryFinancialInterface.js +592 -0
  166. package/financial/MemoryFinancialInterface.js.map +1 -0
  167. package/financial/TigerBeetleFinancialInterface.d.ts +46 -0
  168. package/financial/TigerBeetleFinancialInterface.js +109 -0
  169. package/financial/TigerBeetleFinancialInterface.js.map +1 -0
  170. package/financial/TigerBeetleTestUtils.d.ts +40 -0
  171. package/financial/TigerBeetleTestUtils.js +185 -0
  172. package/financial/TigerBeetleTestUtils.js.map +1 -0
  173. package/financial/Types.d.ts +1 -0
  174. package/financial/Types.js +801 -0
  175. package/financial/Types.js.map +1 -0
  176. package/financial/index.d.ts +6 -0
  177. package/financial/index.js +24 -0
  178. package/financial/index.js.map +1 -0
  179. package/index.d.ts +4 -0
  180. package/index.js +3 -0
  181. package/index.js.map +1 -1
  182. package/notifications/NotificationRecordsController.js +14 -14
  183. package/notifications/NotificationRecordsController.js.map +1 -1
  184. package/notifications/WebPushInterface.d.ts +24 -155
  185. package/notifications/WebPushInterface.js +2 -2
  186. package/notifications/WebPushInterface.js.map +1 -1
  187. package/package.json +72 -70
  188. package/packages/version/MemoryPackageVersionRecordsStore.js +12 -15
  189. package/packages/version/MemoryPackageVersionRecordsStore.js.map +1 -1
  190. package/packages/version/PackageVersionRecordsController.d.ts +19 -0
  191. package/packages/version/PackageVersionRecordsController.js +102 -22
  192. package/packages/version/PackageVersionRecordsController.js.map +1 -1
  193. package/packages/version/PackageVersionRecordsStore.js +6 -8
  194. package/packages/version/PackageVersionRecordsStore.js.map +1 -1
  195. package/purchasable-items/MemoryPurchasableItemRecordsStore.d.ts +7 -0
  196. package/purchasable-items/MemoryPurchasableItemRecordsStore.js +33 -0
  197. package/purchasable-items/MemoryPurchasableItemRecordsStore.js.map +1 -0
  198. package/purchasable-items/PurchasableItemRecordsController.d.ts +16 -0
  199. package/purchasable-items/PurchasableItemRecordsController.js +72 -0
  200. package/purchasable-items/PurchasableItemRecordsController.js.map +1 -0
  201. package/purchasable-items/PurchasableItemRecordsStore.d.ts +66 -0
  202. package/purchasable-items/PurchasableItemRecordsStore.js +2 -0
  203. package/purchasable-items/PurchasableItemRecordsStore.js.map +1 -0
  204. package/purchasable-items/index.d.ts +4 -0
  205. package/purchasable-items/index.js +21 -0
  206. package/purchasable-items/index.js.map +1 -0
  207. package/queue/MemoryQueue.js +1 -1
  208. package/queue/MemoryQueue.js.map +1 -1
  209. package/search/MemorySearchInterface.js +1 -2
  210. package/search/MemorySearchInterface.js.map +1 -1
  211. package/search/SearchRecordsController.d.ts +66 -244
  212. package/search/SearchRecordsController.js +35 -36
  213. package/search/SearchRecordsController.js.map +1 -1
  214. package/search/SearchSyncProcessor.d.ts +7 -83
  215. package/search/TypesenseSearchInterface.js +8 -11
  216. package/search/TypesenseSearchInterface.js.map +1 -1
  217. package/tracing/TracingDecorators.js +5 -8
  218. package/tracing/TracingDecorators.js.map +1 -1
  219. package/webhooks/WebhookEnvironment.d.ts +36 -560
  220. package/webhooks/WebhookEnvironment.js +1 -1
  221. package/webhooks/WebhookEnvironment.js.map +1 -1
  222. package/webhooks/WebhookRecordsController.js +14 -16
  223. package/webhooks/WebhookRecordsController.js.map +1 -1
  224. package/websockets/MemoryLockStore.d.ts +18 -0
  225. package/websockets/MemoryLockStore.js +2 -0
  226. package/websockets/MemoryLockStore.js.map +1 -0
  227. package/websockets/MemoryTempInstRecordsStore.js +15 -27
  228. package/websockets/MemoryTempInstRecordsStore.js.map +1 -1
  229. package/websockets/MemoryWebsocketConnectionStore.js +6 -8
  230. package/websockets/MemoryWebsocketConnectionStore.js.map +1 -1
  231. package/websockets/MemoryWebsocketMessenger.js +1 -2
  232. package/websockets/MemoryWebsocketMessenger.js.map +1 -1
  233. package/websockets/SplitInstRecordsStore.js +2 -2
  234. package/websockets/SplitInstRecordsStore.js.map +1 -1
  235. package/websockets/WebsocketController.d.ts +5 -0
  236. package/websockets/WebsocketController.js +122 -83
  237. package/websockets/WebsocketController.js.map +1 -1
  238. package/RecordsServer.js +0 -6435
  239. package/RecordsServer.js.map +0 -1
@@ -0,0 +1,642 @@
1
+ import { failure, success } from '@casual-simulation/aux-common';
2
+ import { CreateTransferError, TransferFlags } from 'tigerbeetle-node';
3
+ import { AccountFlags, CreateAccountError } from 'tigerbeetle-node';
4
+ export const AMOUNT_MAX = 340282366920938463463374607431768211455n; // 2^128 - 1
5
+ /**
6
+ * The map of currencies to ledger IDs that the system uses.
7
+ */
8
+ export const LEDGERS = {
9
+ /**
10
+ * The ID of the ledger for transactions denominated in USD.
11
+ * The big difference between this and credits is we allow payouts in USD to external services (e.g. Stripe, PayPal, etc.).
12
+ */
13
+ usd: 1,
14
+ /**
15
+ * The ID of the ledger for transactions denominated in credits (internal-use currency for in-store-credit - has a 1,000,000:1 mapping with USD).
16
+ */
17
+ credits: 2,
18
+ };
19
+ export const CurrencyCodes = {
20
+ /**
21
+ * The currency code for USD.
22
+ */
23
+ usd: 'usd',
24
+ /**
25
+ * The currency code for USD.
26
+ */
27
+ credits: 'credits',
28
+ };
29
+ /**
30
+ * The map of ledger IDs to their currency codes.
31
+ */
32
+ export const CURRENCIES = new Map([
33
+ [LEDGERS.credits, 'credits'],
34
+ [LEDGERS.usd, 'usd'],
35
+ ]);
36
+ /**
37
+ * The conversion rate from USD to credits.
38
+ * 1 USD = 1,000,000 credits.
39
+ */
40
+ export const USD_TO_CREDITS = 1000000n; // 1 USD = 1,000,000 credits
41
+ /**
42
+ * The factor for displaying credits to users.
43
+ *
44
+ * This is the number of credits that make up one credit to be displayed to users.
45
+ *
46
+ * For example, if the factor is 1,000,000, then 1 display credit = 1,000,000 credits.
47
+ */
48
+ export const CREDITS_DISPLAY_FACTOR = USD_TO_CREDITS * 100n; // 1 display credit = 1,000,000,000 credits
49
+ /**
50
+ * The factor for displaying USD to users.
51
+ */
52
+ export const USD_DISPLAY_FACTOR = 100n; // 1 display USD = 100 cents
53
+ /**
54
+ * The exchange rates between ledgers.
55
+ */
56
+ export const LEDGER_EXCHANGE_RATES = new Map([
57
+ [
58
+ LEDGERS.usd,
59
+ new Map([
60
+ [LEDGERS.credits, USD_TO_CREDITS], // 1 Credits = 1,000,000 USD
61
+ ]),
62
+ ],
63
+ ]);
64
+ // export const CURRENCY_EXCHANGE_RATES = new Map<CurrencyCodesType, Map<CurrencyCodesType, bigint>>();
65
+ // for(const [fromLedger, rates] of LEDGER_EXCHANGE_RATES.entries()) {
66
+ // const fromCurrency = CURRENCIES.get(fromLedger);
67
+ // if (fromCurrency) {
68
+ // const toRates = new Map<CurrencyCodesType, bigint>();
69
+ // for (const [toLedger, rate] of rates.entries()) {
70
+ // const toCurrency = CURRENCIES.get(toLedger);
71
+ // if (toCurrency) {
72
+ // toRates.set(toCurrency, rate);
73
+ // }
74
+ // }
75
+ // CURRENCY_EXCHANGE_RATES.set(fromCurrency, toRates);
76
+ // }
77
+ // }
78
+ /**
79
+ * Gets the currency code for the given account.
80
+ * @param account The account to get the currency code for.
81
+ */
82
+ export function getAccountCurrency(account) {
83
+ return CURRENCIES.get(account.ledger);
84
+ }
85
+ /**
86
+ * Converts a value between two ledgers.
87
+ * @param from The ledger to convert from.
88
+ * @param to The ledger to convert to.
89
+ * @param value The value to convert.
90
+ */
91
+ export function convertBetweenLedgers(from, to, value) {
92
+ let rate = getExchangeRate(from, to);
93
+ if (rate) {
94
+ return {
95
+ value: value * rate,
96
+ remainder: 0n,
97
+ rate,
98
+ };
99
+ }
100
+ else {
101
+ rate = getExchangeRate(to, from);
102
+ return {
103
+ value: value / rate,
104
+ remainder: value % rate,
105
+ rate,
106
+ };
107
+ }
108
+ }
109
+ /**
110
+ * Gets the exchange rate between two ledgers.
111
+ * Returns null if the exchange rate is not defined.
112
+ * @param fromLedger The ledger to convert from.
113
+ * @param toLedger The ledger to convert to.
114
+ */
115
+ export function getExchangeRate(fromLedger, toLedger) {
116
+ if (fromLedger === toLedger) {
117
+ return 1n;
118
+ }
119
+ const rates = LEDGER_EXCHANGE_RATES.get(fromLedger);
120
+ if (!rates) {
121
+ return null;
122
+ }
123
+ const rate = rates.get(toLedger);
124
+ if (!rate) {
125
+ return null;
126
+ }
127
+ return rate;
128
+ }
129
+ /**
130
+ * Account IDs for built-in accounts.
131
+ */
132
+ export const ACCOUNT_IDS = {
133
+ /**
134
+ * The ID of the USD SETUP control account.
135
+ *
136
+ * Used for implementing some transaction patterns like (multiple debits, single credit, balancing debits).
137
+ *
138
+ * See https://docs.tigerbeetle.com/coding/recipes/multi-debit-credit-transfers/
139
+ */
140
+ USD_SETUP: 9999n,
141
+ /**
142
+ * The ID of the USD debit LIMIT control account.
143
+ *
144
+ * Helper account for setting custom limits on the number of debits that can be proceessed in a transaction.
145
+ *
146
+ * See https://docs.tigerbeetle.com/coding/recipes/multi-debit-credit-transfers/
147
+ */
148
+ USD_LIMIT_DEBITS: 9998n,
149
+ /**
150
+ * The ID of the USD credit LIMIT control account.
151
+ *
152
+ * Helper account for setting custom limits on the number of credits that can be proceessed in a transaction.
153
+ *
154
+ * See https://docs.tigerbeetle.com/coding/recipes/multi-debit-credit-transfers/
155
+ */
156
+ USD_LIMIT_CREDITS: 9997n,
157
+ /**
158
+ * The ID of the Credits SETUP control account.
159
+ *
160
+ * Used for implementing some transaction patterns like (multiple debits, single credit, balancing debits).
161
+ *
162
+ * See https://docs.tigerbeetle.com/coding/recipes/multi-debit-credit-transfers/
163
+ */
164
+ CREDITS_SETUP: 9996n,
165
+ /**
166
+ * The ID of the Credits debit LIMIT control account.
167
+ *
168
+ * Helper account for setting custom limits on the number of debits that can be proceessed in a transaction.
169
+ *
170
+ * See https://docs.tigerbeetle.com/coding/recipes/multi-debit-credit-transfers/
171
+ */
172
+ CREDITS_LIMIT_DEBITS: 9995n,
173
+ /**
174
+ * The ID of the Credits credit LIMIT control account.
175
+ *
176
+ * Helper account for setting custom limits on the number of credits that can be proceessed in a transaction.
177
+ *
178
+ * See https://docs.tigerbeetle.com/coding/recipes/multi-debit-credit-transfers/
179
+ */
180
+ CREDITS_LIMIT_CREDITS: 9994n,
181
+ /**
182
+ * The ID of the cash assets account.
183
+ *
184
+ * Used for tracking cash in the system (e.g. manual payments/transfers).
185
+ * Compare this to other accounts which track automatic payments (e.g. Stripe).
186
+ */
187
+ assets_cash: 1001n,
188
+ /**
189
+ * The ID of the stripe asset account.
190
+ *
191
+ * Used for tracking money that was transferred to the system via Stripe.
192
+ */
193
+ assets_stripe: 1002n,
194
+ /**
195
+ * The ID of the platform fees revenue account.
196
+ */
197
+ revenue_xp_platform_fees: 4101n,
198
+ /**
199
+ * The ID of the store platform fees revenue account.
200
+ */
201
+ revenue_store_platform_fees: 4102n,
202
+ /**
203
+ * The ID of the USD liquidity account.
204
+ */
205
+ liquidity_usd: 6001n,
206
+ /**
207
+ * The ID of the credits liquidity account.
208
+ */
209
+ liquidity_credits: 6002n,
210
+ };
211
+ /**
212
+ * A map of built-in account IDs to their names.
213
+ */
214
+ export const ACCOUNT_NAMES = new Map([
215
+ [ACCOUNT_IDS.assets_cash, 'Cash'],
216
+ [ACCOUNT_IDS.assets_stripe, 'Stripe'],
217
+ [ACCOUNT_IDS.revenue_xp_platform_fees, 'XP Platform Fees'],
218
+ [ACCOUNT_IDS.revenue_store_platform_fees, 'Store Platform Fees'],
219
+ [ACCOUNT_IDS.liquidity_credits, 'Credits'],
220
+ [ACCOUNT_IDS.liquidity_usd, 'USD'],
221
+ ]);
222
+ export function getLiquidityAccountByLedger(ledger) {
223
+ switch (ledger) {
224
+ case LEDGERS.usd:
225
+ return ACCOUNT_IDS.liquidity_usd;
226
+ case LEDGERS.credits:
227
+ return ACCOUNT_IDS.liquidity_credits;
228
+ default:
229
+ throw new Error(`Unknown ledger: ${ledger}`);
230
+ }
231
+ }
232
+ /**
233
+ * Standards for account codes from the systems perspective.
234
+ * * [1000] assets
235
+ * * * [1001] cash
236
+ * * [2000] liabilities
237
+ * * * [2100] liabilities to users (e.g. deposit to system via stripe / balance reload)
238
+ * * * * [2101] liabilities to users (e.g. money in a user account)
239
+ * * * * [2102] liabilities to users held in escrow (e.g. money in a contract account)
240
+ * * [3000] equity
241
+ * * [4000] revenue
242
+ * * * [4100] revenue from fees
243
+ * * * * [4101] revenue from xp platform fees
244
+ * * [5000] expenses
245
+ * * [6000] Liquidity
246
+ */
247
+ export var AccountCodes;
248
+ (function (AccountCodes) {
249
+ /**
250
+ * Accounts for helping control transactions and transfers.
251
+ */
252
+ AccountCodes[AccountCodes["control"] = 1] = "control";
253
+ /**
254
+ * Cash accounts for the system
255
+ */
256
+ AccountCodes[AccountCodes["assets_cash"] = 1001] = "assets_cash";
257
+ /**
258
+ * Stripe accounts for the system
259
+ */
260
+ AccountCodes[AccountCodes["assets_stripe"] = 1002] = "assets_stripe";
261
+ /**
262
+ * liabilities held by users.
263
+ */
264
+ AccountCodes[AccountCodes["liabilities_user"] = 2101] = "liabilities_user";
265
+ /**
266
+ * liabilities held by studios.
267
+ */
268
+ AccountCodes[AccountCodes["liabilities_studio"] = 2102] = "liabilities_studio";
269
+ /**
270
+ * liabilities held by contracts.
271
+ */
272
+ AccountCodes[AccountCodes["liabilities_contract"] = 2103] = "liabilities_contract";
273
+ /**
274
+ * Revenue accounts from platform fees.
275
+ */
276
+ AccountCodes[AccountCodes["revenue_platform_fees"] = 4101] = "revenue_platform_fees";
277
+ /**
278
+ * Liquidity pool account for currency exchanges.
279
+ */
280
+ AccountCodes[AccountCodes["liquidity_pool"] = 6001] = "liquidity_pool";
281
+ })(AccountCodes || (AccountCodes = {}));
282
+ /**
283
+ * Standards for transfer codes from the systems perspective.
284
+ * * [0000] <1000's class> Administrative transfers and reversals.
285
+ * * [1000] <1000's class> General transfers
286
+ * * [2000] <1000's class> XP exchange activities
287
+ * * [3000] <1000's class> Store activities
288
+ *
289
+ * ? The spacing levels future-proof the system for more codes.
290
+ * ? Additional codes in this MLNC could be flags for nominally similar (to existing) multi-phase transactions.
291
+ *
292
+ */
293
+ export var TransferCodes;
294
+ (function (TransferCodes) {
295
+ /**
296
+ * Administrative transfers to rebalance cash in the system.
297
+ */
298
+ TransferCodes[TransferCodes["system_cash_rebalance"] = 1] = "system_cash_rebalance";
299
+ /**
300
+ * Reversing a previous transfer.
301
+ */
302
+ TransferCodes[TransferCodes["reverse_transfer"] = 2] = "reverse_transfer";
303
+ /**
304
+ * A administrative credit to an account from the system.
305
+ */
306
+ TransferCodes[TransferCodes["admin_credit"] = 3] = "admin_credit";
307
+ /**
308
+ * A administrative debit to an account from the system.
309
+ */
310
+ TransferCodes[TransferCodes["admin_debit"] = 4] = "admin_debit";
311
+ /**
312
+ * A currency exchange transfer.
313
+ */
314
+ TransferCodes[TransferCodes["exchange"] = 5] = "exchange";
315
+ /**
316
+ * A transfer to help control transactions and transfers.
317
+ */
318
+ TransferCodes[TransferCodes["control"] = 6] = "control";
319
+ /**
320
+ * A transfer that closes an account.
321
+ */
322
+ TransferCodes[TransferCodes["account_closing"] = 7] = "account_closing";
323
+ /**
324
+ * A credit to a user's account based on the purchase of credits.
325
+ * This generally functions as a top-up of the user's account and corresponds to a debit from an assets account.
326
+ */
327
+ TransferCodes[TransferCodes["purchase_credits"] = 1000] = "purchase_credits";
328
+ /**
329
+ * A debit from a user's account to redeem credits to an external payment source.
330
+ * This generally functions as a payout to the user and corresponds to a credit to an assets account.
331
+ */
332
+ TransferCodes[TransferCodes["user_payout"] = 1001] = "user_payout";
333
+ /**
334
+ * A credit to a contract account from a user and a corresponding debit from the corresponding payment source.
335
+ * This is used to fund a contract.
336
+ */
337
+ TransferCodes[TransferCodes["contract_payment"] = 2000] = "contract_payment";
338
+ /**
339
+ * A credit to a users account and a corresponding debit from the contract account.
340
+ * This is used to pay out a contract.
341
+ */
342
+ TransferCodes[TransferCodes["invoice_payment"] = 2001] = "invoice_payment";
343
+ /**
344
+ * A credit to the equity account and a debit from the corresponding payment source.
345
+ * In the XP Exchange, sponsors always pay platform fees.
346
+ */
347
+ TransferCodes[TransferCodes["xp_platform_fee"] = 2002] = "xp_platform_fee";
348
+ /**
349
+ * A credit to a user account and a corresponding closing debit from the contract account.
350
+ */
351
+ TransferCodes[TransferCodes["contract_refund"] = 2003] = "contract_refund";
352
+ /**
353
+ * A credit to the seller's account and a corresponding debit from the payment source.
354
+ * This is used when a user purchases an item from a store.
355
+ */
356
+ TransferCodes[TransferCodes["item_payment"] = 3000] = "item_payment";
357
+ /**
358
+ * A credit to the equity account and a debit from the corresponding payment source.
359
+ * This is used when a user purchases an item from the store and the platform takes a fee.
360
+ */
361
+ TransferCodes[TransferCodes["store_platform_fee"] = 3003] = "store_platform_fee";
362
+ // /**
363
+ // * A credit to the user from external entities (e.g. deposit to system via stripe / balance reload)
364
+ // */
365
+ // external_credits_user = 1101,
366
+ // /**
367
+ // * A credit to a contract from a user
368
+ // */
369
+ // user_credits_contract = 1200,
370
+ // /**
371
+ // * A debit to the user from the system.
372
+ // */
373
+ // system_debits_user = 2000,
374
+ // /**
375
+ // * A debit to a user from external entities (e.g. withdrawal from system via stripe / payout)
376
+ // */
377
+ // external_debits_user = 2100,
378
+ // /**
379
+ // * A debit to a contract from a user
380
+ // */
381
+ // user_debits_contract = 2200,
382
+ })(TransferCodes || (TransferCodes = {}));
383
+ /**
384
+ * Gets the account flags for the given account code.
385
+ * @param code The code of the account.
386
+ */
387
+ export function getFlagsForAccountCode(code) {
388
+ switch (code) {
389
+ case AccountCodes.assets_stripe:
390
+ case AccountCodes.assets_cash:
391
+ return (AccountFlags.credits_must_not_exceed_debits |
392
+ AccountFlags.history);
393
+ case AccountCodes.liabilities_user:
394
+ case AccountCodes.liabilities_studio:
395
+ case AccountCodes.liabilities_contract:
396
+ case AccountCodes.revenue_platform_fees:
397
+ return (AccountFlags.debits_must_not_exceed_credits |
398
+ AccountFlags.history);
399
+ case AccountCodes.liquidity_pool:
400
+ return AccountFlags.none;
401
+ default:
402
+ throw new Error(`Unknown account code: ${code}`);
403
+ }
404
+ }
405
+ export function getMessageForAccountError(error) {
406
+ switch (error) {
407
+ case CreateAccountError.code_must_not_be_zero:
408
+ return 'The account code must not be zero.';
409
+ case CreateAccountError.credits_pending_must_be_zero:
410
+ return 'The account credits pending must be zero.';
411
+ case CreateAccountError.debits_pending_must_be_zero:
412
+ return 'The account debits pending must be zero.';
413
+ case CreateAccountError.credits_posted_must_be_zero:
414
+ return 'The account credits posted must be zero.';
415
+ case CreateAccountError.debits_posted_must_be_zero:
416
+ return 'The account debits posted must be zero.';
417
+ case CreateAccountError.exists:
418
+ return 'The account already exists.';
419
+ case CreateAccountError.exists_with_different_code:
420
+ return 'The account already exists with a different code.';
421
+ case CreateAccountError.exists_with_different_flags:
422
+ return 'The account already exists with different flags.';
423
+ case CreateAccountError.exists_with_different_ledger:
424
+ return 'The account already exists with a different ledger.';
425
+ case CreateAccountError.exists_with_different_user_data_128:
426
+ case CreateAccountError.exists_with_different_user_data_64:
427
+ case CreateAccountError.exists_with_different_user_data_32:
428
+ return 'The account already exists with different user data.';
429
+ case CreateAccountError.flags_are_mutually_exclusive:
430
+ return 'The account flags are mutually exclusive.';
431
+ case CreateAccountError.timestamp_must_be_zero:
432
+ return 'The account timestamp must be zero.';
433
+ default:
434
+ return 'An unknown error occurred.';
435
+ }
436
+ }
437
+ export function getCodeForAccountError(error) {
438
+ switch (error) {
439
+ case CreateAccountError.code_must_not_be_zero:
440
+ return 'code_must_not_be_zero';
441
+ case CreateAccountError.credits_pending_must_be_zero:
442
+ return 'credits_pending_must_be_zero';
443
+ case CreateAccountError.debits_pending_must_be_zero:
444
+ return 'debits_pending_must_be_zero';
445
+ case CreateAccountError.credits_posted_must_be_zero:
446
+ return 'credits_posted_must_be_zero';
447
+ case CreateAccountError.debits_posted_must_be_zero:
448
+ return 'debits_posted_must_be_zero';
449
+ case CreateAccountError.exists:
450
+ return 'exists';
451
+ case CreateAccountError.exists_with_different_code:
452
+ return 'exists_with_different_code';
453
+ case CreateAccountError.exists_with_different_flags:
454
+ return 'exists_with_different_flags';
455
+ case CreateAccountError.exists_with_different_ledger:
456
+ return 'exists_with_different_ledger';
457
+ case CreateAccountError.exists_with_different_user_data_128:
458
+ case CreateAccountError.exists_with_different_user_data_64:
459
+ case CreateAccountError.exists_with_different_user_data_32:
460
+ return 'exists_with_different_user_data';
461
+ case CreateAccountError.flags_are_mutually_exclusive:
462
+ return 'flags_are_mutually_exclusive';
463
+ case CreateAccountError.timestamp_must_be_zero:
464
+ return 'timestamp_must_be_zero';
465
+ default:
466
+ return 'server_error';
467
+ }
468
+ }
469
+ export function getMessageForTransferError(error) {
470
+ switch (error) {
471
+ case CreateTransferError.code_must_not_be_zero:
472
+ return 'The transfer code must not be zero.';
473
+ case CreateTransferError.accounts_must_be_different:
474
+ return 'The transfer accounts must be different.';
475
+ case CreateTransferError.accounts_must_have_the_same_ledger:
476
+ return 'The transfer accounts must have the same ledger.';
477
+ case CreateTransferError.closing_transfer_must_be_pending:
478
+ return 'The closing transfer must be pending.';
479
+ case CreateTransferError.credit_account_already_closed:
480
+ return 'The credit account is already closed.';
481
+ case CreateTransferError.debit_account_already_closed:
482
+ return 'The debit account is already closed.';
483
+ case CreateTransferError.credit_account_not_found:
484
+ return 'The credit account was not found.';
485
+ case CreateTransferError.debit_account_not_found:
486
+ return 'The debit account was not found.';
487
+ case CreateTransferError.exceeds_credits:
488
+ return 'The transfer would cause the debits on the account to exceed its credits.';
489
+ case CreateTransferError.exceeds_debits:
490
+ return 'The transfer would cause the credits on the account to exceed its debits.';
491
+ case CreateTransferError.exists:
492
+ return 'The transfer already exists.';
493
+ case CreateTransferError.exceeds_pending_transfer_amount:
494
+ return 'The transfer would cause the pending transfer amount to exceed its limit.';
495
+ case CreateTransferError.exists_with_different_amount:
496
+ return 'The transfer already exists with a different amount.';
497
+ case CreateTransferError.exists_with_different_code:
498
+ return 'The transfer already exists with a different code.';
499
+ case CreateTransferError.exists_with_different_flags:
500
+ return 'The transfer already exists with different flags.';
501
+ case CreateTransferError.exists_with_different_ledger:
502
+ return 'The transfer already exists with a different ledger.';
503
+ case CreateTransferError.exists_with_different_user_data_128:
504
+ case CreateTransferError.exists_with_different_user_data_64:
505
+ case CreateTransferError.exists_with_different_user_data_32:
506
+ return 'The transfer already exists with different user data.';
507
+ case CreateTransferError.flags_are_mutually_exclusive:
508
+ return 'The transfer flags are mutually exclusive.';
509
+ case CreateTransferError.timestamp_must_be_zero:
510
+ return 'The transfer timestamp must be zero.';
511
+ case CreateTransferError.id_already_failed:
512
+ return 'A transfer with the same ID has already failed.';
513
+ case CreateTransferError.overflows_credits:
514
+ return 'The transfer would cause the credits on the account to overflow a 128-bit unsigned int.';
515
+ case CreateTransferError.overflows_debits:
516
+ return 'The transfer would cause the debits on the account to overflow a 128-bit unsigned int.';
517
+ case CreateTransferError.overflows_credits_pending:
518
+ return 'The transfer would cause the credits pending on the account to overflow a 128-bit unsigned int.';
519
+ case CreateTransferError.overflows_debits_pending:
520
+ return 'The transfer would cause the debits pending on the account to overflow a 128-bit unsigned int.';
521
+ case CreateTransferError.overflows_credits_posted:
522
+ return 'The transfer would cause the credits posted on the account to overflow a 128-bit unsigned int.';
523
+ case CreateTransferError.overflows_debits_posted:
524
+ return 'The transfer would cause the debits posted on the account to overflow a 128-bit unsigned int.';
525
+ case CreateTransferError.overflows_timeout:
526
+ return 'The transfer would cause the timeout on the account to overflow a 64-bit unsigned int.';
527
+ case CreateTransferError.transfer_must_have_the_same_ledger_as_accounts:
528
+ return 'The transfer must have the same ledger as the accounts.';
529
+ case CreateTransferError.linked_event_failed:
530
+ return 'The linked event for the transfer failed.';
531
+ case CreateTransferError.pending_transfer_not_pending:
532
+ return 'The pending transfer was not pending.';
533
+ default:
534
+ return `An unknown error occurred (${error}).`;
535
+ }
536
+ }
537
+ export function getCodeForTransferError(error) {
538
+ switch (error) {
539
+ case CreateTransferError.code_must_not_be_zero:
540
+ return 'code_must_not_be_zero';
541
+ case CreateTransferError.accounts_must_be_different:
542
+ return 'accounts_must_be_different';
543
+ case CreateTransferError.accounts_must_have_the_same_ledger:
544
+ return 'accounts_must_have_the_same_ledger';
545
+ case CreateTransferError.closing_transfer_must_be_pending:
546
+ return 'closing_transfer_must_be_pending';
547
+ case CreateTransferError.credit_account_already_closed:
548
+ return 'credit_account_already_closed';
549
+ case CreateTransferError.debit_account_already_closed:
550
+ return 'debit_account_already_closed';
551
+ case CreateTransferError.credit_account_not_found:
552
+ return 'credit_account_not_found';
553
+ case CreateTransferError.debit_account_not_found:
554
+ return 'debit_account_not_found';
555
+ case CreateTransferError.exceeds_credits:
556
+ return 'exceeds_credits';
557
+ case CreateTransferError.exceeds_debits:
558
+ return 'exceeds_debits';
559
+ case CreateTransferError.exists:
560
+ case CreateTransferError.exceeds_pending_transfer_amount:
561
+ case CreateTransferError.exists_with_different_amount:
562
+ case CreateTransferError.exists_with_different_code:
563
+ case CreateTransferError.exists_with_different_flags:
564
+ case CreateTransferError.exists_with_different_ledger:
565
+ case CreateTransferError.exists_with_different_user_data_128:
566
+ case CreateTransferError.exists_with_different_user_data_64:
567
+ case CreateTransferError.exists_with_different_user_data_32:
568
+ return 'exists';
569
+ case CreateTransferError.flags_are_mutually_exclusive:
570
+ return 'flags_are_mutually_exclusive';
571
+ case CreateTransferError.timestamp_must_be_zero:
572
+ return 'timestamp_must_be_zero';
573
+ case CreateTransferError.id_already_failed:
574
+ return 'id_already_failed';
575
+ case CreateTransferError.overflows_credits:
576
+ return 'overflows_credits';
577
+ case CreateTransferError.overflows_debits:
578
+ return 'overflows_debits';
579
+ case CreateTransferError.overflows_credits_pending:
580
+ return 'overflows_credits_pending';
581
+ case CreateTransferError.overflows_debits_pending:
582
+ return 'overflows_debits_pending';
583
+ case CreateTransferError.overflows_credits_posted:
584
+ return 'overflows_credits_posted';
585
+ case CreateTransferError.overflows_debits_posted:
586
+ return 'overflows_debits_posted';
587
+ case CreateTransferError.overflows_timeout:
588
+ return 'overflows_timeout';
589
+ case CreateTransferError.pending_transfer_already_posted:
590
+ return 'already_posted';
591
+ case CreateTransferError.pending_transfer_already_voided:
592
+ return 'already_voided';
593
+ default:
594
+ return 'server_error';
595
+ }
596
+ }
597
+ export function getFlagsForTransferCode(code) {
598
+ return TransferFlags.none;
599
+ }
600
+ export function processAccountErrors(results) {
601
+ let errors = [];
602
+ for (let result of results) {
603
+ if (result.result !== CreateAccountError.ok) {
604
+ errors.push({
605
+ errorCode: getCodeForAccountError(result.result),
606
+ errorMessage: getMessageForAccountError(result.result),
607
+ error: result.result,
608
+ });
609
+ }
610
+ }
611
+ if (errors.length > 0) {
612
+ return failure({
613
+ errorCode: 'multi_error',
614
+ errorMessage: 'Multiple errors occurred.',
615
+ errors,
616
+ });
617
+ }
618
+ return success();
619
+ }
620
+ export function processTransferErrors(results, transfers) {
621
+ let errors = [];
622
+ for (let result of results) {
623
+ if (result.result !== CreateTransferError.ok) {
624
+ const transfer = transfers[result.index];
625
+ errors.push({
626
+ errorCode: getCodeForTransferError(result.result),
627
+ errorMessage: `[transferId: ${transfer.id}, debitAccountId: ${transfer.debit_account_id}, creditAccountId: ${transfer.credit_account_id}, code: ${transfer.code}] ${getMessageForTransferError(result.result)}`,
628
+ error: result.result,
629
+ transfer: transfer,
630
+ });
631
+ }
632
+ }
633
+ if (errors.length > 0) {
634
+ return failure({
635
+ errorCode: 'multi_error',
636
+ errorMessage: 'Multiple errors occurred.',
637
+ errors,
638
+ });
639
+ }
640
+ return success();
641
+ }
642
+ //# sourceMappingURL=FinancialInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FinancialInterface.js","sourceRoot":"","sources":["FinancialInterface.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAUjE,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAIpE,MAAM,CAAC,MAAM,UAAU,GAAW,wCAAwC,CAAC,CAAC,YAAY;AAExF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACnB;;;OAGG;IACH,GAAG,EAAE,CAAC;IAEN;;OAEG;IACH,OAAO,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB;;OAEG;IACH,GAAG,EAAE,KAAK;IAEV;;OAEG;IACH,OAAO,EAAE,SAAS;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAiC;IAC9D,CAAC,OAAO,CAAC,O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