@voltro/plugin-economy 0.0.0-stage → 0.87.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 (177) hide show
  1. package/CHANGELOG.md +24329 -0
  2. package/LICENSE +61 -0
  3. package/README.md +2719 -2
  4. package/SECURITY.md +56 -0
  5. package/THIRD-PARTY-NOTICES.md +9189 -0
  6. package/dist/amount.js +21 -0
  7. package/dist/appleIap.server.js +263 -0
  8. package/dist/appleIapNotifications.server.js +163 -0
  9. package/dist/appleIapTrust.server.js +31 -0
  10. package/dist/bundleValue.server.js +113 -0
  11. package/dist/canonicalDataJson.js +11 -0
  12. package/dist/capture.js +54 -0
  13. package/dist/codePort.fixture.js +124 -0
  14. package/dist/codeStore.server.js +440 -0
  15. package/dist/codeTables.entity.js +44 -0
  16. package/dist/codes.d.ts +150 -0
  17. package/dist/codes.js +83 -0
  18. package/dist/components.d.ts +397 -0
  19. package/dist/components.js +284 -0
  20. package/dist/consistency.server.js +116 -0
  21. package/dist/containerStore.server.js +688 -0
  22. package/dist/containerStore.testFixtures.js +76 -0
  23. package/dist/containerTables.entity.js +46 -0
  24. package/dist/containers.d.ts +311 -0
  25. package/dist/containers.fixture.js +129 -0
  26. package/dist/containers.js +215 -0
  27. package/dist/containers.server.js +40 -0
  28. package/dist/containersPort.fixture.js +75 -0
  29. package/dist/currency.js +33 -0
  30. package/dist/declarationFixtures.js +62 -0
  31. package/dist/economy-app/events/economy.refundReversed.event.ts +1 -0
  32. package/dist/economy-app/events/economy.refunded.event.ts +1 -0
  33. package/dist/economyPort.fixture.js +125 -0
  34. package/dist/errors.d.ts +14 -0
  35. package/dist/errors.js +22 -0
  36. package/dist/events.d.ts +46 -0
  37. package/dist/events.js +1 -0
  38. package/dist/googleIap.server.js +392 -0
  39. package/dist/googleIapNotifications.server.js +131 -0
  40. package/dist/googleIapSubscription.server.js +184 -0
  41. package/dist/iap.d.ts +309 -0
  42. package/dist/iap.js +304 -0
  43. package/dist/iap.testFixtures.js +145 -0
  44. package/dist/iapAccountTables.entity.js +40 -0
  45. package/dist/iapAccounts.server.js +201 -0
  46. package/dist/iapBinding.server.js +524 -0
  47. package/dist/iapCheckout.server.js +98 -0
  48. package/dist/iapCompletion.server.js +56 -0
  49. package/dist/iapCurrentState.server.js +108 -0
  50. package/dist/iapCurrentState.testFixtures.js +23 -0
  51. package/dist/iapCurrentStatePort.fixture.js +64 -0
  52. package/dist/iapEntitlements.d.ts +79 -0
  53. package/dist/iapEntitlements.js +58 -0
  54. package/dist/iapEntitlements.server.js +49 -0
  55. package/dist/iapEntitlementsBinding.server.js +106 -0
  56. package/dist/iapEntitlementsPort.fixture.js +81 -0
  57. package/dist/iapInstalledEntitlements.testFixtures.js +76 -0
  58. package/dist/iapInstalledNotifications.testFixtures.js +94 -0
  59. package/dist/iapInventoryRefunds.server.js +262 -0
  60. package/dist/iapNotificationCustodyPort.fixture.js +68 -0
  61. package/dist/iapNotificationPort.fixture.js +74 -0
  62. package/dist/iapNotificationProcessor.server.js +135 -0
  63. package/dist/iapNotificationProcessor.testFixtures.js +64 -0
  64. package/dist/iapNotificationProcessorPort.fixture.js +56 -0
  65. package/dist/iapNotificationSchedule.server.js +70 -0
  66. package/dist/iapNotificationStore.server.js +353 -0
  67. package/dist/iapNotificationStore.testFixtures.js +32 -0
  68. package/dist/iapNotificationTables.entity.js +49 -0
  69. package/dist/iapNotificationTarget.server.js +37 -0
  70. package/dist/iapNotificationTarget.testFixtures.js +30 -0
  71. package/dist/iapNotifications.d.ts +644 -0
  72. package/dist/iapNotifications.js +6 -0
  73. package/dist/iapNotifications.server.js +96 -0
  74. package/dist/iapNotificationsBinding.server.js +233 -0
  75. package/dist/iapNotificationsSystemPort.fixture.js +51 -0
  76. package/dist/iapPlugin.testFixtures.js +60 -0
  77. package/dist/iapPort.fixture.js +75 -0
  78. package/dist/iapProviderCapture.server.js +18 -0
  79. package/dist/iapRecovery.d.ts +146 -0
  80. package/dist/iapRecovery.js +90 -0
  81. package/dist/iapRefundEventDelivery.server.js +83 -0
  82. package/dist/iapRefundEvents.js +45 -0
  83. package/dist/iapRefundEventsPort.fixture.js +60 -0
  84. package/dist/iapRefundPort.fixture.js +55 -0
  85. package/dist/iapRefundTables.entity.js +56 -0
  86. package/dist/iapRefunds.d.ts +755 -0
  87. package/dist/iapRefunds.js +6 -0
  88. package/dist/iapRefunds.server.js +554 -0
  89. package/dist/iapRefunds.testFixtures.js +65 -0
  90. package/dist/iapSpendAdmission.server.js +99 -0
  91. package/dist/iapStore.server.js +741 -0
  92. package/dist/iapStore.testFixtures.js +128 -0
  93. package/dist/iapTables.entity.js +81 -0
  94. package/dist/iapVerification.server.js +121 -0
  95. package/dist/index.d.ts +2984 -0
  96. package/dist/index.js +15 -0
  97. package/dist/intentionRecovery.js +134 -0
  98. package/dist/ledger.js +78 -0
  99. package/dist/loyalty.d.ts +274 -0
  100. package/dist/loyalty.fixture.js +93 -0
  101. package/dist/loyalty.js +312 -0
  102. package/dist/loyaltyBinding.server.js +204 -0
  103. package/dist/loyaltyPort.fixture.js +87 -0
  104. package/dist/loyaltyShopSource.server.js +91 -0
  105. package/dist/loyaltyStore.server.js +553 -0
  106. package/dist/loyaltyStore.testFixtures.js +83 -0
  107. package/dist/loyaltyTables.entity.js +50 -0
  108. package/dist/offerMerchandising.fixture.js +115 -0
  109. package/dist/offerMerchandising.js +283 -0
  110. package/dist/offerPolicies.d.ts +441 -0
  111. package/dist/offerPolicies.fixture.js +54 -0
  112. package/dist/offerPolicies.js +268 -0
  113. package/dist/piggyBanks.d.ts +272 -0
  114. package/dist/piggyBanks.fixture.js +71 -0
  115. package/dist/piggyBanks.js +201 -0
  116. package/dist/piggyBinding.server.js +205 -0
  117. package/dist/piggyPort.fixture.js +73 -0
  118. package/dist/piggyStore.server.js +611 -0
  119. package/dist/piggyStore.testFixtures.js +98 -0
  120. package/dist/piggyTables.entity.js +41 -0
  121. package/dist/plugin.js +1048 -0
  122. package/dist/port.js +13 -0
  123. package/dist/price.d.ts +99 -0
  124. package/dist/price.js +144 -0
  125. package/dist/purchaseRecovery.js +56 -0
  126. package/dist/reports.server.js +115 -0
  127. package/dist/rpc.d.ts +3201 -0
  128. package/dist/rpc.js +1201 -0
  129. package/dist/sanctionsTradeAuthority.server.js +80 -0
  130. package/dist/server.d.ts +3856 -0
  131. package/dist/server.js +43 -0
  132. package/dist/shop.d.ts +279 -0
  133. package/dist/shop.js +196 -0
  134. package/dist/shop.testFixtures.js +114 -0
  135. package/dist/shopPort.fixture.js +72 -0
  136. package/dist/shopPresentation.js +68 -0
  137. package/dist/shopStore.server.js +624 -0
  138. package/dist/shopTables.entity.js +63 -0
  139. package/dist/shopUiCopy.js +57 -0
  140. package/dist/spendLimits.d.ts +140 -0
  141. package/dist/spendLimits.fixture.js +53 -0
  142. package/dist/spendLimits.js +155 -0
  143. package/dist/spendLimitsPort.fixture.js +120 -0
  144. package/dist/subscriptionBinding.server.js +211 -0
  145. package/dist/subscriptionStore.server.js +643 -0
  146. package/dist/subscriptionStore.testFixtures.js +72 -0
  147. package/dist/subscriptionTables.entity.js +37 -0
  148. package/dist/subscriptions.d.ts +394 -0
  149. package/dist/subscriptions.fixture.js +97 -0
  150. package/dist/subscriptions.js +213 -0
  151. package/dist/subscriptionsPort.fixture.js +76 -0
  152. package/dist/systemFixtures.js +89 -0
  153. package/dist/tables.entity.js +83 -0
  154. package/dist/testing.d.ts +4615 -0
  155. package/dist/testing.js +29 -0
  156. package/dist/tradeAuthority.server.js +172 -0
  157. package/dist/tradeBinding.server.js +201 -0
  158. package/dist/tradeComponents.js +342 -0
  159. package/dist/tradeEscrow.server.js +232 -0
  160. package/dist/tradeEscrow.testFixtures.js +133 -0
  161. package/dist/tradeExpiry.server.js +43 -0
  162. package/dist/tradeRecovery.js +48 -0
  163. package/dist/tradeStore.server.js +750 -0
  164. package/dist/tradeStore.testFixtures.js +73 -0
  165. package/dist/tradeTables.entity.js +66 -0
  166. package/dist/tradeUiCopy.js +79 -0
  167. package/dist/trades.d.ts +246 -0
  168. package/dist/trades.fixture.js +103 -0
  169. package/dist/trades.js +289 -0
  170. package/dist/tradesPort.fixture.js +94 -0
  171. package/dist/walletEscrow.js +106 -0
  172. package/dist/walletEscrow.server.js +376 -0
  173. package/dist/walletKeys.server.js +5 -0
  174. package/dist/walletStore.js +571 -0
  175. package/dist/web.d.ts +2257 -0
  176. package/dist/web.js +9 -0
  177. package/package.json +161 -4
package/dist/plugin.js ADDED
@@ -0,0 +1,1048 @@
1
+ import { EconomyError as e, economyError as t } from "./errors.js";
2
+ import { captureQueryTables as n, dataList as r, dataObject as i, declaredSources as a, identifier as o } from "./capture.js";
3
+ import { defaultPriceResolver as s, definePrice as c, priceResolverContext as ee, resolvePrice as te } from "./price.js";
4
+ import { ShopPort as ne, captureShopService as re, defineShopOffer as ie, shopBuyIntent as ae, shopInteger as oe } from "./shop.js";
5
+ import { unavailableIapEntitlements as se } from "./iapEntitlementsBinding.server.js";
6
+ import { unavailableIapRefundEvents as ce } from "./iapRefundEvents.js";
7
+ import { captureAccount as le, planLedgerTransfer as ue } from "./ledger.js";
8
+ import { economyTables as de } from "./tables.entity.js";
9
+ import { captureWalletEscrowInput as fe, captureWalletEscrowReserveInput as pe, captureWalletEscrowReserveTaxSettleInput as me, captureWalletEscrowSettleInput as he, captureWalletEscrowTaxSettleInput as ge } from "./walletEscrow.js";
10
+ import { defaultSpendLimitPolicy as _e } from "./spendLimits.js";
11
+ import { dataStoreEconomy as ve, resolveEconomyStoreOptions as ye } from "./walletStore.js";
12
+ import { unavailableIapNotifications as be } from "./iapNotificationsBinding.server.js";
13
+ import { ECONOMY_NAME as xe, codesReceiptDescriptor as Se, codesRedeemDescriptor as Ce, codesRpcClientImports as we, containerOpenDescriptor as Te, containerReceiptDescriptor as Ee, containersListDescriptor as De, containersRpcClientImports as Oe, economyMineDescriptor as ke, economyRpcClientImports as Ae, shopBuyDescriptor as je, shopOffersDescriptor as Me, shopReceiptDescriptor as Ne, shopRpcClientImports as Pe } from "./rpc.js";
14
+ import { bindIapSystem as Fe, unavailableIap as Ie } from "./iapBinding.server.js";
15
+ import { bindTradesSystem as Le, unavailableTrades as Re } from "./tradeBinding.server.js";
16
+ import { shopTables as ze } from "./shopTables.entity.js";
17
+ import { dataStoreShop as Be, resolveShopStoreOptions as Ve } from "./shopStore.server.js";
18
+ import { CodePort as He, captureCodeIntent as Ue, captureCodeService as We, captureCodeValue as Ge, defaultCodeEligibility as Ke, defineCode as qe } from "./codes.js";
19
+ import { codeTables as Je } from "./codeTables.entity.js";
20
+ import { dataStoreCodes as Ye, resolveCodeStoreOptions as Xe } from "./codeStore.server.js";
21
+ import { ContainersPort as Ze, captureContainerIntent as Qe, captureContainersService as $e, defaultContainerEligibility as et, defaultContainerProbability as tt, defaultContainerRoll as nt, defineContainer as rt } from "./containers.js";
22
+ import { cryptoContainerRandom as it } from "./containers.server.js";
23
+ import { containerTables as at } from "./containerTables.entity.js";
24
+ import { dataStoreContainers as ot, resolveContainersStoreOptions as st } from "./containerStore.server.js";
25
+ import { bindSubscriptionsSystem as ct, unavailableSubscriptions as lt } from "./subscriptionBinding.server.js";
26
+ import { bindLoyaltySystem as ut, unavailableLoyalty as dt } from "./loyaltyBinding.server.js";
27
+ import { bindPiggyBanksSystem as ft, unavailablePiggyBanks as pt } from "./piggyBinding.server.js";
28
+ import { EconomyPort as mt, captureEconomyService as ht } from "./port.js";
29
+ import { captureEconomyConsistencyInput as gt, checkSqlEconomyConsistency as _t } from "./consistency.server.js";
30
+ import { Effect as l, Layer as u } from "effect";
31
+ import { defineLicensedGamePlugin as vt } from "@voltro/plugin-licensing/gate";
32
+ import { fileURLToPath as yt } from "node:url";
33
+ //#region src/plugin.ts
34
+ var bt = (e) => JSON.parse(JSON.stringify(e, (e, t) => typeof t == "bigint" ? t.toString() : t)), xt = Object.freeze({
35
+ slots: { priceResolver: {
36
+ defaultExport: "defaultPriceResolver",
37
+ fixtureExport: "priceResolverSystemFixture"
38
+ } },
39
+ ports: { economy: {
40
+ tagExport: "EconomyPort",
41
+ fakeLayerExport: "economyFakeLayer",
42
+ fixtureExport: "economyPortSystemFixture"
43
+ } },
44
+ events: []
45
+ }), d = Object.freeze({
46
+ slots: { codeEligibility: {
47
+ defaultExport: "defaultCodeEligibility",
48
+ fixtureExport: "codeEligibilitySystemFixture"
49
+ } },
50
+ ports: { codes: {
51
+ tagExport: "CodePort",
52
+ fakeLayerExport: "codesFakeLayer",
53
+ fixtureExport: "codePortSystemFixture"
54
+ } },
55
+ events: []
56
+ }), f = Object.freeze({
57
+ slots: {
58
+ subscriptionPeriod: {
59
+ defaultExport: "defaultSubscriptionPeriod",
60
+ fixtureExport: "subscriptionPeriodSystemFixture"
61
+ },
62
+ subscriptionDaily: {
63
+ defaultExport: "defaultSubscriptionDailyGrant",
64
+ fixtureExport: "subscriptionDailySystemFixture"
65
+ }
66
+ },
67
+ ports: { subscriptions: {
68
+ tagExport: "SubscriptionsPort",
69
+ fakeLayerExport: "subscriptionsFakeLayer",
70
+ fixtureExport: "subscriptionsPortSystemFixture"
71
+ } },
72
+ events: []
73
+ }), p = Object.freeze({
74
+ slots: {
75
+ loyaltyTier: {
76
+ defaultExport: "defaultLoyaltyTier",
77
+ fixtureExport: "loyaltyTierSystemFixture"
78
+ },
79
+ loyaltyPerks: {
80
+ defaultExport: "defaultLoyaltyPerks",
81
+ fixtureExport: "loyaltyPerksSystemFixture"
82
+ }
83
+ },
84
+ ports: { loyalty: {
85
+ tagExport: "LoyaltyPort",
86
+ fakeLayerExport: "loyaltyFakeLayer",
87
+ fixtureExport: "loyaltyPortSystemFixture"
88
+ } },
89
+ events: []
90
+ }), m = Object.freeze({
91
+ slots: {
92
+ piggyFill: {
93
+ defaultExport: "defaultPiggyFill",
94
+ fixtureExport: "piggyFillSystemFixture"
95
+ },
96
+ piggyReset: {
97
+ defaultExport: "defaultPiggyReset",
98
+ fixtureExport: "piggyResetSystemFixture"
99
+ }
100
+ },
101
+ ports: { piggyBanks: {
102
+ tagExport: "PiggyBanksPort",
103
+ fakeLayerExport: "piggyBanksFakeLayer",
104
+ fixtureExport: "piggyBanksPortSystemFixture"
105
+ } },
106
+ events: []
107
+ }), St = Object.freeze({
108
+ slots: {
109
+ tradeTax: {
110
+ defaultExport: "defaultTradeTaxPolicy",
111
+ fixtureExport: "tradeTaxSystemFixture"
112
+ },
113
+ tradeEligibility: {
114
+ defaultExport: "defaultTradeEligibilityPolicy",
115
+ fixtureExport: "tradeEligibilitySystemFixture"
116
+ }
117
+ },
118
+ ports: { trades: {
119
+ tagExport: "TradesPort",
120
+ fakeLayerExport: "tradesFakeLayer",
121
+ fixtureExport: "tradesPortSystemFixture"
122
+ } },
123
+ events: []
124
+ }), h = Object.freeze({
125
+ slots: { spendLimitPolicy: {
126
+ defaultExport: "defaultSpendLimitPolicy",
127
+ fixtureExport: "spendLimitPolicySystemFixture"
128
+ } },
129
+ ports: { economy: {
130
+ tagExport: "EconomyPort",
131
+ fakeLayerExport: "spendLimitsFakeLayer",
132
+ fixtureExport: "spendLimitsPortSystemFixture"
133
+ } },
134
+ events: []
135
+ }), g = Object.freeze({
136
+ slots: {
137
+ experimentBucket: {
138
+ defaultExport: "defaultExperimentBucket",
139
+ fixtureExport: "experimentBucketSystemFixture"
140
+ },
141
+ personalizedOfferSelector: {
142
+ defaultExport: "defaultPersonalizedOfferSelector",
143
+ fixtureExport: "personalizedSelectorSystemFixture"
144
+ },
145
+ flashTrigger: {
146
+ defaultExport: "defaultFlashTriggerPolicy",
147
+ fixtureExport: "flashTriggerSystemFixture"
148
+ }
149
+ },
150
+ ports: { shop: {
151
+ tagExport: "ShopPort",
152
+ fakeLayerExport: "shopFakeLayer",
153
+ fixtureExport: "shopPortSystemFixture"
154
+ } },
155
+ events: []
156
+ }), _ = Object.freeze({
157
+ slots: { iapEntitlementPolicy: {
158
+ defaultExport: "defaultIapEntitlementPolicy",
159
+ fixtureExport: "iapEntitlementPolicySystemFixture"
160
+ } },
161
+ ports: {
162
+ iap: {
163
+ tagExport: "IapPort",
164
+ fakeLayerExport: "iapFakeLayer",
165
+ fixtureExport: "iapPortSystemFixture"
166
+ },
167
+ iapSystem: {
168
+ tagExport: "IapSystemPort",
169
+ fakeLayerExport: "iapFakeLayer",
170
+ fixtureExport: "iapSystemPortSystemFixture"
171
+ },
172
+ iapNotification: {
173
+ tagExport: "IapNotificationPort",
174
+ fakeLayerExport: "iapNotificationFakeLayer",
175
+ fixtureExport: "iapNotificationPortSystemFixture"
176
+ },
177
+ iapCurrentState: {
178
+ tagExport: "IapCurrentStatePort",
179
+ fakeLayerExport: "iapCurrentStateFakeLayer",
180
+ fixtureExport: "iapCurrentStatePortSystemFixture"
181
+ },
182
+ iapNotificationCustody: {
183
+ tagExport: "IapNotificationCustodyPort",
184
+ fakeLayerExport: "iapNotificationCustodyFakeLayer",
185
+ fixtureExport: "iapNotificationCustodyPortSystemFixture"
186
+ },
187
+ iapRefund: {
188
+ tagExport: "IapRefundPort",
189
+ fakeLayerExport: "iapRefundFakeLayer",
190
+ fixtureExport: "iapRefundPortSystemFixture"
191
+ },
192
+ iapNotificationProcessor: {
193
+ tagExport: "IapNotificationProcessorPort",
194
+ fakeLayerExport: "iapNotificationProcessorFakeLayer",
195
+ fixtureExport: "iapNotificationProcessorPortSystemFixture"
196
+ },
197
+ iapNotificationsSystem: {
198
+ tagExport: "IapNotificationsSystemPort",
199
+ fakeLayerExport: "iapNotificationsSystemFakeLayer",
200
+ fixtureExport: "iapNotificationsSystemPortSystemFixture"
201
+ },
202
+ iapRefundEvents: {
203
+ tagExport: "IapRefundEventsPort",
204
+ fakeLayerExport: "iapRefundEventsFakeLayer",
205
+ fixtureExport: "iapRefundEventsPortSystemFixture"
206
+ },
207
+ iapEntitlements: {
208
+ tagExport: "IapEntitlementsPort",
209
+ fakeLayerExport: "iapEntitlementsFakeLayer",
210
+ fixtureExport: "iapEntitlementsPortSystemFixture"
211
+ }
212
+ },
213
+ events: []
214
+ }), v = Object.freeze({
215
+ slots: {
216
+ containerProbability: {
217
+ defaultExport: "defaultContainerProbability",
218
+ fixtureExport: "containerProbabilitySystemFixture"
219
+ },
220
+ containerRoll: {
221
+ defaultExport: "defaultContainerRoll",
222
+ fixtureExport: "containerRollSystemFixture"
223
+ },
224
+ containerEligibility: {
225
+ defaultExport: "defaultContainerEligibility",
226
+ fixtureExport: "containerEligibilitySystemFixture"
227
+ }
228
+ },
229
+ ports: {
230
+ containers: {
231
+ tagExport: "ContainersPort",
232
+ fakeLayerExport: "containersFakeLayer",
233
+ fixtureExport: "containersPortSystemFixture"
234
+ },
235
+ containerRandom: {
236
+ tagExport: "ContainerRandomPort",
237
+ fakeLayerExport: "containerRandomFakeLayer",
238
+ fixtureExport: "containerRandomPortSystemFixture"
239
+ }
240
+ },
241
+ events: []
242
+ }), y = (xt) => {
243
+ let d = i(xt, [
244
+ "currencies",
245
+ "allowedServices",
246
+ "maxLedgerRows",
247
+ "maxExportRows",
248
+ "now",
249
+ "realMoney",
250
+ "offers",
251
+ "priceResolver",
252
+ "shop",
253
+ "codes",
254
+ "containers",
255
+ "subscriptions",
256
+ "loyalty",
257
+ "piggyBanks",
258
+ "trades",
259
+ "iap",
260
+ "spendLimits",
261
+ "service",
262
+ "version",
263
+ "querySources"
264
+ ]), f = ye({
265
+ currencies: d.currencies,
266
+ allowedServices: d.allowedServices,
267
+ maxLedgerRows: d.maxLedgerRows,
268
+ maxExportRows: d.maxExportRows,
269
+ now: d.now,
270
+ spendLimits: d.spendLimits
271
+ }), p = d.service === void 0 ? void 0 : ht(d.service), m = o(d.version ?? (p ? void 0 : "default.v1"));
272
+ if (p && (m === "default.v1" || [
273
+ "now",
274
+ "maxLedgerRows",
275
+ "maxExportRows",
276
+ "spendLimits"
277
+ ].some((e) => d[e] !== void 0)) || !p && d.querySources !== void 0) throw t("invalid_input");
278
+ let St = p ? n(d.querySources) : ke.source, h = d.realMoney ?? !1, g = d.priceResolver ?? s;
279
+ if (typeof h != "boolean" || typeof g != "function") throw t("invalid_input");
280
+ let _ = Object.freeze(r(d.offers ?? [], 256).map((e) => {
281
+ let t = i(e, ["id", "price"]);
282
+ return Object.freeze({
283
+ id: o(t.id),
284
+ price: c(t.price, f.currencies, h)
285
+ });
286
+ }));
287
+ if (new Set(_.map((e) => e.id)).size !== _.length) throw t("invalid_input");
288
+ let v = new Set(f.allowedServices), y = !1, b, x, S = !1, C = (e) => l.suspend(() => {
289
+ let n = p ?? x;
290
+ return y && n ? e(n) : l.fail(t("unavailable"));
291
+ }), w = d.shop === void 0 ? void 0 : i(d.shop, [
292
+ "offers",
293
+ "priceResolver",
294
+ "contextSource",
295
+ "version",
296
+ "systemAccount",
297
+ "maxOrders",
298
+ "maxAuditRows",
299
+ "now",
300
+ "inventory",
301
+ "service",
302
+ "querySources"
303
+ ]), T = w?.service === void 0 ? void 0 : re(w.service);
304
+ if (!T && w?.querySources !== void 0) throw t("invalid_input");
305
+ let E = T ? i(w?.querySources, ["offers", "receipt"]) : void 0, Ct = E ? Object.freeze({
306
+ offers: n(E.offers),
307
+ receipt: n(E.receipt)
308
+ }) : void 0;
309
+ if (p && w && !T) throw t("invalid_input");
310
+ let D = Object.freeze({
311
+ prepareIapRefund: (e, n, r) => l.suspend(() => y && x && !p ? x.prepareIapRefund(e, n, r) : l.fail(t("unavailable"))),
312
+ prepareTransfer: (e, n) => l.suspend(() => y && x && !p ? x.prepareTransfer(e, n) : l.fail(t("unavailable")))
313
+ }), O = w === void 0 || T !== void 0 ? void 0 : Ve({
314
+ currencies: f.currencies,
315
+ realMoney: h,
316
+ economy: D,
317
+ offers: w.offers,
318
+ priceResolver: w.priceResolver ?? g,
319
+ contextSource: w.contextSource,
320
+ version: w.version,
321
+ systemAccount: w.systemAccount,
322
+ maxOrders: w.maxOrders,
323
+ maxAuditRows: w.maxAuditRows,
324
+ now: w.now ?? f.now,
325
+ inventory: w.inventory
326
+ }), k = O?.offers ?? (w === void 0 ? void 0 : Object.freeze(r(w.offers, 256).map((e) => ie(e, f.currencies, h))));
327
+ if (k && (!k.length || new Set(k.map((e) => e.id)).size !== k.length) || w && T && [
328
+ "inventory",
329
+ "contextSource",
330
+ "priceResolver",
331
+ "systemAccount",
332
+ "now",
333
+ "maxOrders",
334
+ "maxAuditRows"
335
+ ].some((e) => w[e] !== void 0)) throw t("invalid_input");
336
+ let wt = O?.version ?? (w === void 0 ? void 0 : o(w.version));
337
+ if (T && wt === "default.v1") throw t("invalid_input");
338
+ let Tt = w === void 0 || T ? void 0 : Object.freeze({
339
+ orders: oe(O?.maxOrders ?? w.maxOrders ?? 1e4, 1, 1e5),
340
+ auditRows: oe(O?.maxAuditRows ?? w.maxAuditRows ?? 1e4, 1, 1e5)
341
+ }), A, j = (e) => l.suspend(() => {
342
+ let n = T ?? A;
343
+ return y && w !== void 0 && n ? e(n) : l.fail(t("unavailable"));
344
+ }), M = Object.freeze({
345
+ offers: (n) => {
346
+ try {
347
+ let e = structuredClone(n);
348
+ if (e.type !== "user") throw t("forbidden");
349
+ return j((t) => t.offers(e));
350
+ } catch (n) {
351
+ return l.fail(n instanceof e ? n : t("invalid_input"));
352
+ }
353
+ },
354
+ buy: (n, r) => {
355
+ try {
356
+ let e = structuredClone(n), i = ae(r);
357
+ if (e.type !== "user") throw t("forbidden");
358
+ return j((t) => t.buy(e, {
359
+ offerId: i.offerId,
360
+ offerVersion: i.offerVersion,
361
+ offerDigest: i.offerDigest,
362
+ requestId: i.requestId,
363
+ qty: i.qty,
364
+ currency: i.currency ?? void 0
365
+ }));
366
+ } catch (n) {
367
+ return l.fail(n instanceof e ? n : t("invalid_input"));
368
+ }
369
+ },
370
+ receipt: (n, r) => {
371
+ try {
372
+ let e = structuredClone(n), i = ae(r);
373
+ if (e.type !== "user") throw t("forbidden");
374
+ return j((t) => t.receipt(e, {
375
+ offerId: i.offerId,
376
+ offerVersion: i.offerVersion,
377
+ offerDigest: i.offerDigest,
378
+ requestId: i.requestId,
379
+ qty: i.qty,
380
+ currency: i.currency ?? void 0
381
+ }));
382
+ } catch (n) {
383
+ return l.fail(n instanceof e ? n : t("invalid_input"));
384
+ }
385
+ },
386
+ exportSubject: (e) => {
387
+ try {
388
+ let t = structuredClone(e);
389
+ return j((e) => e.exportSubject(t));
390
+ } catch {
391
+ return l.fail(t("invalid_input"));
392
+ }
393
+ },
394
+ eraseSubject: (e) => {
395
+ try {
396
+ let t = structuredClone(e);
397
+ return j((e) => e.eraseSubject(t));
398
+ } catch {
399
+ return l.fail(t("invalid_input"));
400
+ }
401
+ }
402
+ }), N = d.codes === void 0 ? void 0 : i(d.codes, [
403
+ "inventory",
404
+ "systemAccount",
405
+ "allowedServices",
406
+ "maxHistoryRows",
407
+ "now",
408
+ "eligibility",
409
+ "version",
410
+ "service",
411
+ "querySources"
412
+ ]), P = N?.service === void 0 ? void 0 : We(N.service);
413
+ if (!P && N?.querySources !== void 0 || p && N && !P || P && [
414
+ "inventory",
415
+ "systemAccount",
416
+ "allowedServices",
417
+ "maxHistoryRows",
418
+ "now",
419
+ "eligibility"
420
+ ].some((e) => N?.[e] !== void 0)) throw t("invalid_input");
421
+ let Et = P ? i(N?.querySources, ["receipt"]) : void 0, Dt = Et ? n(Et.receipt) : Se.source, F = N === void 0 || P ? void 0 : Xe({
422
+ currencies: f.currencies,
423
+ economy: D,
424
+ inventory: N.inventory,
425
+ systemAccount: N.systemAccount,
426
+ allowedServices: N.allowedServices ?? f.allowedServices,
427
+ maxHistoryRows: N.maxHistoryRows,
428
+ now: N.now ?? f.now,
429
+ eligibility: N.eligibility,
430
+ version: N.version
431
+ }), Ot = F?.version ?? (N === void 0 ? void 0 : o(N.version));
432
+ if (P && Ot === "default.v1") throw t("invalid_input");
433
+ let kt = new Set(F?.allowedServices ?? f.allowedServices), I, L = (e) => l.suspend(() => {
434
+ let n = P ?? I;
435
+ return y && N !== void 0 && n ? e(n) : l.fail(t("unavailable"));
436
+ }), At = (n, r, i) => {
437
+ try {
438
+ let e = structuredClone(n), a = Ue(r);
439
+ if (e.type !== "user") throw t("forbidden");
440
+ return o(e.id), o(e.tenantId), L((t) => i(t, e, a));
441
+ } catch (n) {
442
+ return l.fail(n instanceof e ? n : t("invalid_input"));
443
+ }
444
+ }, R = Object.freeze({
445
+ create: (n, r) => {
446
+ try {
447
+ let e = structuredClone(n), a = i(r, [
448
+ "tenantId",
449
+ "code",
450
+ "definition"
451
+ ]);
452
+ if (e.type !== "system" && !(e.type === "service" && kt.has(e.service))) throw t("forbidden");
453
+ let s = Object.freeze({
454
+ tenantId: o(a.tenantId),
455
+ code: Ge(a.code),
456
+ definition: qe(a.definition, f.currencies)
457
+ });
458
+ return L((t) => t.create(e, s));
459
+ } catch (n) {
460
+ return l.fail(n instanceof e ? n : t("invalid_input"));
461
+ }
462
+ },
463
+ redeem: (e, t) => At(e, t, (e, t, n) => e.redeem(t, n)),
464
+ receipt: (e, t) => At(e, t, (e, t, n) => e.receipt(t, n)),
465
+ exportSubject: (e) => {
466
+ try {
467
+ let n = structuredClone(e);
468
+ if (o(n.tenantId), o(n.subjectId), n.kind !== "user" && n.kind !== "guest") throw t("invalid_input");
469
+ return L((e) => e.exportSubject(n));
470
+ } catch {
471
+ return l.fail(t("invalid_input"));
472
+ }
473
+ },
474
+ eraseSubject: (e) => {
475
+ try {
476
+ let n = structuredClone(e);
477
+ if (o(n.tenantId), o(n.subjectId), n.kind !== "user" && n.kind !== "guest") throw t("invalid_input");
478
+ return L((e) => e.eraseSubject(n));
479
+ } catch {
480
+ return l.fail(t("invalid_input"));
481
+ }
482
+ }
483
+ }), z = d.containers === void 0 ? void 0 : i(d.containers, [
484
+ "containers",
485
+ "inventory",
486
+ "accessSource",
487
+ "version",
488
+ "probability",
489
+ "roll",
490
+ "random",
491
+ "eligibility",
492
+ "priceResolver",
493
+ "systemAccount",
494
+ "maxHistoryRows",
495
+ "now",
496
+ "service",
497
+ "querySources"
498
+ ]), B = z?.service === void 0 ? void 0 : $e(z.service);
499
+ if (p && z && !B || B && [
500
+ "inventory",
501
+ "accessSource",
502
+ "probability",
503
+ "roll",
504
+ "random",
505
+ "eligibility",
506
+ "priceResolver",
507
+ "systemAccount",
508
+ "maxHistoryRows",
509
+ "now"
510
+ ].some((e) => z?.[e] !== void 0)) throw t("invalid_input");
511
+ let V = z?.querySources === void 0 ? void 0 : i(z.querySources, ["list", "receipt"]);
512
+ if (B && !V) throw t("invalid_input");
513
+ let H = V ? Object.freeze({
514
+ list: n(V.list),
515
+ receipt: n(V.receipt)
516
+ }) : void 0, U = z === void 0 || B ? void 0 : st({
517
+ currencies: f.currencies,
518
+ realMoney: h,
519
+ economy: D,
520
+ containers: z.containers,
521
+ inventory: z.inventory,
522
+ accessSource: z.accessSource,
523
+ version: z.version,
524
+ probability: z.probability,
525
+ roll: z.roll,
526
+ random: z.random,
527
+ eligibility: z.eligibility,
528
+ priceResolver: z.priceResolver ?? g,
529
+ systemAccount: z.systemAccount,
530
+ maxHistoryRows: z.maxHistoryRows,
531
+ now: z.now ?? f.now
532
+ }), W = U?.containers ?? (z ? Object.freeze(r(z.containers, 256).map((e) => rt(e, f.currencies, h))) : void 0);
533
+ if (W && (!W.length || new Set(W.map((e) => e.id)).size !== W.length)) throw t("invalid_input");
534
+ let jt = U?.version ?? (z === void 0 ? void 0 : o(z.version));
535
+ if (jt === "default.v1") throw t("invalid_input");
536
+ let G, K = (e) => l.suspend(() => {
537
+ let n = B ?? G;
538
+ return y && z !== void 0 && n ? e(n) : l.fail(t("unavailable"));
539
+ }), Mt = (n, r, i) => {
540
+ try {
541
+ let e = structuredClone(n), a = Qe(r);
542
+ if (e.type !== "user") throw t("forbidden");
543
+ o(e.id), o(e.tenantId);
544
+ let s = Object.freeze({
545
+ containerId: a.containerId,
546
+ containerVersion: a.containerVersion,
547
+ containerDigest: a.containerDigest,
548
+ disclosureDigest: a.disclosureDigest,
549
+ requestId: a.requestId,
550
+ ...a.currency === null ? {} : { currency: a.currency }
551
+ });
552
+ return K((t) => i(t, e, s));
553
+ } catch (n) {
554
+ return l.fail(n instanceof e ? n : t("invalid_input"));
555
+ }
556
+ }, q = Object.freeze({
557
+ list: (n) => {
558
+ try {
559
+ let e = structuredClone(n);
560
+ if (e.type !== "user") throw t("forbidden");
561
+ return o(e.id), o(e.tenantId), K((t) => t.list(e));
562
+ } catch (n) {
563
+ return l.fail(n instanceof e ? n : t("invalid_input"));
564
+ }
565
+ },
566
+ open: (e, t) => Mt(e, t, (e, t, n) => e.open(t, n)),
567
+ receipt: (e, t) => Mt(e, t, (e, t, n) => e.receipt(t, n)),
568
+ exportSubject: (e) => {
569
+ try {
570
+ let n = structuredClone(e);
571
+ if (o(n.tenantId), o(n.subjectId), n.kind !== "user" && n.kind !== "guest") throw t("invalid_input");
572
+ return K((e) => e.exportSubject(n));
573
+ } catch {
574
+ return l.fail(t("invalid_input"));
575
+ }
576
+ },
577
+ eraseSubject: (e) => {
578
+ try {
579
+ let n = structuredClone(e);
580
+ if (o(n.tenantId), o(n.subjectId), n.kind !== "user" && n.kind !== "guest") throw t("invalid_input");
581
+ return K((e) => e.eraseSubject(n));
582
+ } catch {
583
+ return l.fail(t("invalid_input"));
584
+ }
585
+ }
586
+ }), J = ct(d.subscriptions, {
587
+ currencies: f.currencies,
588
+ realMoney: h,
589
+ economy: D,
590
+ priceResolver: g,
591
+ now: f.now,
592
+ replacedWallet: p !== void 0
593
+ }), Y = ut(d.loyalty, {
594
+ currencies: f.currencies,
595
+ realMoney: h,
596
+ now: f.now,
597
+ allowedServices: f.allowedServices
598
+ }), X = ft(d.piggyBanks, {
599
+ currencies: f.currencies,
600
+ realMoney: h,
601
+ economy: D,
602
+ priceResolver: g,
603
+ now: f.now,
604
+ allowedServices: f.allowedServices,
605
+ replacedWallet: p !== void 0
606
+ }), Nt = Object.freeze({
607
+ prepareEscrowReserve: (e, n) => l.suspend(() => y && x && !p ? x.prepareEscrowReserve(e, n) : l.fail(t("unavailable"))),
608
+ prepareEscrowRelease: (e, n) => l.suspend(() => y && x && !p ? x.prepareEscrowRelease(e, n) : l.fail(t("unavailable"))),
609
+ prepareEscrowTaxSettle: (e, n) => l.suspend(() => y && x && !p ? x.prepareEscrowTaxSettle(e, n) : l.fail(t("unavailable"))),
610
+ prepareEscrowReserveTaxSettle: (e, n) => l.suspend(() => y && x && !p ? x.prepareEscrowReserveTaxSettle(e, n) : l.fail(t("unavailable"))),
611
+ escrow: (e, n) => l.suspend(() => y && x && !p ? x.escrow(e, n) : l.fail(t("unavailable")))
612
+ }), Z = Le(d.trades, {
613
+ currencies: f.currencies,
614
+ economy: Nt,
615
+ now: f.now,
616
+ allowedServices: f.allowedServices,
617
+ replacedWallet: p !== void 0
618
+ }), Q = Fe(d.iap, {
619
+ currencies: f.currencies,
620
+ realMoney: h,
621
+ economy: D,
622
+ now: f.now,
623
+ replacedWallet: p !== void 0
624
+ }), Pt = [
625
+ ...p ? [] : de,
626
+ ...O ? ze : [],
627
+ ...F ? Je : [],
628
+ ...U ? at : [],
629
+ ...J?.tables ?? [],
630
+ ...Y?.tables ?? [],
631
+ ...X?.tables ?? [],
632
+ ...Z?.tables ?? [],
633
+ ...Q?.tables ?? []
634
+ ], Ft = (e, n, r) => {
635
+ try {
636
+ let t = structuredClone(e), i = structuredClone(n);
637
+ return C((e) => r(e, t, i));
638
+ } catch {
639
+ return l.fail(t("invalid_input"));
640
+ }
641
+ }, It = (n) => (r, i, a, s) => Ft(r, {
642
+ tenantId: i,
643
+ account: a,
644
+ currency: s
645
+ }, (r, i, a) => {
646
+ if (i.type !== "system" && !(i.type === "service" && v.has(i.service))) return l.fail(t("forbidden"));
647
+ try {
648
+ let e = o(a.tenantId), s = le(a.account), c = o(a.currency);
649
+ if (s.kind !== "wallet") throw t("invalid_input");
650
+ if (!f.currencies.some((e) => e.id === c)) throw t("invalid_currency");
651
+ return n ? r.rebuildWallet(i, e, s, c) : r.auditWallet(i, e, s, c);
652
+ } catch (n) {
653
+ return l.fail(n instanceof e ? n : t("invalid_input"));
654
+ }
655
+ }), $ = Object.freeze({
656
+ transfer: (n, r) => Ft(n, r, (n, r, i) => {
657
+ if (r.type !== "system" && !(r.type === "service" && v.has(r.service))) return l.fail(t("forbidden"));
658
+ try {
659
+ let e = ue(i);
660
+ if (!f.currencies.some((t) => t.id === e.currency)) throw t("invalid_currency");
661
+ } catch (n) {
662
+ return l.fail(n instanceof e ? n : t("invalid_input"));
663
+ }
664
+ return n.transfer(r, i);
665
+ }),
666
+ mine: (e) => Ft(e, null, (e, n) => {
667
+ if (n.type !== "user") return l.fail(t("forbidden"));
668
+ try {
669
+ o(n.id), o(n.tenantId);
670
+ } catch {
671
+ return l.fail(t("invalid_input"));
672
+ }
673
+ return e.mine(n);
674
+ }),
675
+ auditWallet: It(!1),
676
+ rebuildWallet: It(!0)
677
+ }), Lt = (n, r, i = []) => {
678
+ try {
679
+ let a = structuredClone(n), s = o(r);
680
+ if (a.type !== "system" && !(a.type === "service" && v.has(a.service))) throw t("forbidden");
681
+ let c = _.find((e) => e.id === s);
682
+ if (!c) throw t("not_found");
683
+ let ne = ee(c.price, f.currencies, h, i);
684
+ return C(() => l.try({
685
+ try: () => te(ne, g),
686
+ catch: (n) => n instanceof e ? n : t("unavailable")
687
+ }));
688
+ } catch (n) {
689
+ return l.fail(n instanceof e ? n : t("invalid_input"));
690
+ }
691
+ }, Rt = u.succeed(mt, $), zt = w ? u.merge(Rt, u.succeed(ne, M)) : Rt, Bt = N ? u.merge(zt, u.succeed(He, R)) : zt, Vt = z ? u.merge(Bt, u.succeed(Ze, q)) : Bt, Ht = J ? u.merge(Vt, J.layer) : Vt, Ut = Y ? u.merge(Ht, Y.layer) : Ht, Wt = X ? u.merge(Ut, X.layer) : Ut, Gt = Z ? u.merge(Wt, Z.layer) : Wt, Kt = Q ? u.merge(Gt, Q.layer) : Gt, qt = vt({
692
+ name: xe,
693
+ description: "Exact game-currency wallet port and captured reference pricing.",
694
+ permissions: [
695
+ ...Pt.length ? ["store:write"] : [],
696
+ "inspect:read",
697
+ ...Q ? ["network:outbound:*"] : []
698
+ ],
699
+ services: Kt,
700
+ ...Q?.httpRoutes.length ? { httpRoutes: Q.httpRoutes } : {},
701
+ ...Q?.status.notificationSystem?.eventQueue ? { sources: yt(new URL("./economy-app", "" + import.meta.url)) } : {},
702
+ routes: [
703
+ ...Q?.routes ?? [],
704
+ ...Z?.routes ?? [],
705
+ ...X?.routes ?? [],
706
+ ...Y?.routes ?? [],
707
+ ...J?.routes ?? [],
708
+ {
709
+ ...ke,
710
+ source: St,
711
+ execute: (e, t) => $.mine(t.request.subject)
712
+ },
713
+ ...w ? [
714
+ {
715
+ ...Me,
716
+ source: Ct?.offers ?? Me.source,
717
+ execute: (e, t) => M.offers(t.request.subject)
718
+ },
719
+ {
720
+ ...Ne,
721
+ source: Ct?.receipt ?? Ne.source,
722
+ execute: (e, t) => M.receipt(t.request.subject, e)
723
+ },
724
+ {
725
+ ...je,
726
+ execute: (e, t) => M.buy(t.request.subject, e)
727
+ }
728
+ ] : [],
729
+ ...N ? [{
730
+ ...Se,
731
+ source: Dt,
732
+ execute: (e, t) => R.receipt(t.request.subject, e)
733
+ }, {
734
+ ...Ce,
735
+ execute: (e, t) => R.redeem(t.request.subject, e)
736
+ }] : [],
737
+ ...z ? [
738
+ {
739
+ ...De,
740
+ source: B ? H.list : [.../* @__PURE__ */ new Set([...a(De.source), ...H?.list ?? []])],
741
+ execute: (e, t) => q.list(t.request.subject)
742
+ },
743
+ {
744
+ ...Ee,
745
+ source: B ? H.receipt : [.../* @__PURE__ */ new Set([...a(Ee.source), ...H?.receipt ?? []])],
746
+ execute: (e, t) => q.receipt(t.request.subject, e)
747
+ },
748
+ {
749
+ ...Te,
750
+ execute: (e, t) => q.open(t.request.subject, e)
751
+ }
752
+ ] : []
753
+ ],
754
+ rpcClientDescriptors: [
755
+ ...Ae,
756
+ ...w ? Pe : [],
757
+ ...N ? we : [],
758
+ ...z ? Oe : [],
759
+ ...J?.rpcClientDescriptors ?? [],
760
+ ...Y?.rpcClientDescriptors ?? [],
761
+ ...X?.rpcClientDescriptors ?? [],
762
+ ...Z?.rpcClientDescriptors ?? [],
763
+ ...Q?.rpcClientDescriptors ?? []
764
+ ],
765
+ errorSchemas: [{
766
+ schema: e,
767
+ import: {
768
+ module: "@voltro/plugin-economy/errors",
769
+ name: "EconomyError"
770
+ }
771
+ }],
772
+ extendSchema: { tables: Pt },
773
+ subjectPrivacy: {
774
+ tables: Pt.map((e) => e.tableName),
775
+ kinds: ["user", "guest"]
776
+ },
777
+ bindDataStore: (e) => {
778
+ if (b !== void 0 && b !== e) throw Error("Economy plugin instance cannot cross app stores");
779
+ if (b = e, p || (x = ve(e, f)), O && (A = Be(e, O)), F && (I = Ye(e, F)), U && (G = ot(e, U)), J?.bind(e), Y?.bind(e), X?.bind(e), Z?.bind(e), Q?.bind(e), y = !0, Q && S) return S = !1, l.runPromise(Q.activate());
780
+ },
781
+ ...Q ? { onActivate: () => l.suspend(() => b === void 0 ? (S = !0, l.void) : Q.activate()) } : {},
782
+ onDeactivate: () => l.sync(() => {
783
+ y = !1, S = !1, x = void 0, A = void 0, I = void 0, G = void 0, J?.deactivate(), Y?.deactivate(), X?.deactivate(), Z?.deactivate(), Q?.deactivate();
784
+ }),
785
+ onExport: (e, t) => {
786
+ let n = {
787
+ subjectId: e,
788
+ tenantId: t.tenantId,
789
+ kind: t.kind
790
+ };
791
+ return (w || N || z || J || Y || X || Z || Q ? l.gen(function* () {
792
+ return {
793
+ economy: yield* C((e) => e.exportSubject(n)),
794
+ ...w ? { shop: yield* M.exportSubject(n) } : {},
795
+ ...N ? { codes: yield* R.exportSubject(n) } : {},
796
+ ...z ? { containers: yield* q.exportSubject(n) } : {},
797
+ ...J ? { subscriptions: yield* J.service.exportSubject(n) } : {},
798
+ ...Y ? { loyalty: yield* Y.service.exportSubject(n) } : {},
799
+ ...X ? { piggyBanks: yield* X.service.exportSubject(n) } : {},
800
+ ...Z ? { trades: yield* Z.service.exportSubject(n) } : {},
801
+ ...Q ? { iap: yield* Q.service.exportSubject(n) } : {}
802
+ };
803
+ }) : C((e) => e.exportSubject(n))).pipe(l.map(bt));
804
+ },
805
+ onErase: (e, t) => {
806
+ let n = {
807
+ subjectId: e,
808
+ tenantId: t.tenantId,
809
+ kind: t.kind
810
+ };
811
+ return l.gen(function* () {
812
+ Q && (yield* Q.service.eraseSubject(n)), yield* C((e) => e.eraseSubject(n)), w && (yield* M.eraseSubject(n)), N && (yield* R.eraseSubject(n)), z && (yield* q.eraseSubject(n)), J && (yield* J.service.eraseSubject(n)), Y && (yield* Y.service.eraseSubject(n)), X && (yield* X.service.eraseSubject(n)), Z && (yield* Z.service.eraseSubject(n));
813
+ });
814
+ },
815
+ inspectEndpoints: [{
816
+ method: "GET",
817
+ path: "/status",
818
+ scope: "process",
819
+ description: "Captured declarations and installed port binding; contains no wallets, ledger values, subjects or payment references.",
820
+ handler: () => l.sync(() => ({
821
+ kind: "json",
822
+ data: {
823
+ capturedAt: (f.now ?? Date.now)(),
824
+ bound: y,
825
+ backend: p ? "custom" : "sql",
826
+ version: m,
827
+ realMoney: h,
828
+ slots: { priceResolver: g === s ? "default" : "custom" },
829
+ currencies: f.currencies.map((e) => ({
830
+ id: e.id,
831
+ kind: e.kind,
832
+ cap: e.cap,
833
+ premium: e.premium
834
+ })),
835
+ offers: _.map((e) => ({
836
+ id: e.id,
837
+ kind: e.price.kind
838
+ })),
839
+ budgets: p ? null : {
840
+ ledgerRows: f.maxLedgerRows,
841
+ exportRows: f.maxExportRows
842
+ },
843
+ tableRoles: [
844
+ ...p ? [] : [
845
+ "currencies",
846
+ "wallets",
847
+ "ledger",
848
+ "transactions",
849
+ "subjects"
850
+ ],
851
+ ...O ? [
852
+ "shopTenants",
853
+ "shopSubjects",
854
+ "offers",
855
+ "orders",
856
+ "shopCounters"
857
+ ] : [],
858
+ ...F ? [
859
+ "codeTenants",
860
+ "codes",
861
+ "codeSubjects",
862
+ "codeClaims"
863
+ ] : [],
864
+ ...U ? [
865
+ "containerTenants",
866
+ "containers",
867
+ "containerSubjects",
868
+ "containerOpenings"
869
+ ] : [],
870
+ ...J?.roles ?? [],
871
+ ...Y?.roles ?? [],
872
+ ...X?.roles ?? [],
873
+ ...Z?.roles ?? [],
874
+ ...Q?.roles ?? []
875
+ ],
876
+ spendLimitsInstalled: f.spendLimits !== void 0,
877
+ spendLimitsSystem: f.spendLimits ? {
878
+ version: f.spendLimits.version,
879
+ policy: f.spendLimits.policy === _e ? "default" : "custom",
880
+ source: "custom",
881
+ period: "utc",
882
+ historyRows: f.maxLedgerRows,
883
+ limits: f.spendLimits.limits,
884
+ providerLimitsInstalled: !1,
885
+ coolingOffInstalled: !1,
886
+ parentalUiInstalled: !1
887
+ } : null,
888
+ paymentsInstalled: Q !== void 0,
889
+ iapInstalled: Q !== void 0,
890
+ iapSystem: Q?.status ?? null,
891
+ shopInstalled: w !== void 0,
892
+ shopSystem: w && k ? {
893
+ backend: T ? "custom" : "sql",
894
+ version: wt,
895
+ priceResolver: T ? "custom" : O?.priceResolver === s ? "default" : "custom",
896
+ contextSource: T || O?.contextSource ? "custom" : "none",
897
+ offers: k.map((e) => ({
898
+ id: e.id,
899
+ version: e.version,
900
+ kind: e.price.kind,
901
+ itemKinds: e.items.length,
902
+ currencyKinds: e.currencies.length,
903
+ maxQuantity: e.maxQuantity,
904
+ oneTime: e.oneTime,
905
+ limits: e.limits
906
+ })),
907
+ budgets: T ? null : Tt,
908
+ virtualBuyInstalled: !0,
909
+ rotationInstalled: !1,
910
+ realPaymentInstalled: !1,
911
+ liveOpsSourceInstalled: !1
912
+ } : null,
913
+ codesInstalled: N !== void 0,
914
+ codesSystem: N ? {
915
+ backend: P ? "custom" : "sql",
916
+ version: Ot,
917
+ eligibility: P || F?.eligibility !== Ke ? "custom" : "default",
918
+ budgets: P ? null : { historyRows: F.maxHistoryRows },
919
+ itemParticipant: P ? "app-owned" : F?.inventory ? "prepared-sql" : "none",
920
+ redemptionInstalled: !0,
921
+ referralInstalled: !1,
922
+ clientRecoveryInstalled: !1
923
+ } : null,
924
+ tradesInstalled: Z !== void 0,
925
+ tradesSystem: Z?.status ?? null,
926
+ piggyBanksInstalled: X !== void 0,
927
+ piggyBanksSystem: X?.status ?? null,
928
+ loyaltyInstalled: Y !== void 0,
929
+ loyaltySystem: Y?.status ?? null,
930
+ subscriptionsInstalled: J !== void 0,
931
+ subscriptionsSystem: J?.status ?? null,
932
+ containersInstalled: z !== void 0,
933
+ containersSystem: z && W ? {
934
+ backend: B ? "custom" : "sql",
935
+ version: jt,
936
+ slots: {
937
+ probability: B || U?.probability !== tt ? "custom" : "default",
938
+ roll: B || U?.roll !== nt ? "custom" : "default",
939
+ eligibility: B || U?.eligibility !== et ? "custom" : "default",
940
+ priceResolver: B || U?.priceResolver !== s ? "custom" : "default",
941
+ random: B ? "app-owned" : z.random === void 0 || z.random === it ? "crypto" : "custom"
942
+ },
943
+ containers: W.map((e) => ({
944
+ id: e.id,
945
+ version: e.version,
946
+ group: e.group,
947
+ kind: e.price.kind,
948
+ dropKinds: e.drops.length,
949
+ pityAfter: e.pity?.after ?? null,
950
+ countries: e.countries.length
951
+ })),
952
+ budgets: B ? null : { historyRows: U.maxHistoryRows },
953
+ openingInstalled: !0,
954
+ realPaymentInstalled: !1,
955
+ clientRecoveryInstalled: !1,
956
+ gmActionsInstalled: !1
957
+ } : null
958
+ }
959
+ }))
960
+ }]
961
+ }), Jt = (e, n) => {
962
+ try {
963
+ let r = structuredClone(e), i = structuredClone(n);
964
+ return l.suspend(() => y && x && !p ? x.prepareTransfer(r, i) : l.fail(t("unavailable")));
965
+ } catch {
966
+ return l.fail(t("invalid_input"));
967
+ }
968
+ }, Yt = (n, r) => {
969
+ try {
970
+ let e = structuredClone(n), i = pe(r);
971
+ return l.suspend(() => y && x && !p ? x.prepareEscrowReserve(e, i) : l.fail(t("unavailable")));
972
+ } catch (n) {
973
+ return l.fail(n instanceof e ? n : t("invalid_input"));
974
+ }
975
+ }, Xt = (n, r) => {
976
+ try {
977
+ let e = structuredClone(n), i = fe(r);
978
+ return l.suspend(() => y && x && !p ? x.prepareEscrowRelease(e, i) : l.fail(t("unavailable")));
979
+ } catch (n) {
980
+ return l.fail(n instanceof e ? n : t("invalid_input"));
981
+ }
982
+ }, Zt = (n, r) => {
983
+ try {
984
+ let e = structuredClone(n), i = he(r);
985
+ return l.suspend(() => y && x && !p ? x.prepareEscrowSettle(e, i) : l.fail(t("unavailable")));
986
+ } catch (n) {
987
+ return l.fail(n instanceof e ? n : t("invalid_input"));
988
+ }
989
+ }, Qt = (n, r) => {
990
+ try {
991
+ let e = structuredClone(n), i = me(r);
992
+ return l.suspend(() => y && x && !p ? x.prepareEscrowReserveTaxSettle(e, i) : l.fail(t("unavailable")));
993
+ } catch (n) {
994
+ return l.fail(n instanceof e ? n : t("invalid_input"));
995
+ }
996
+ }, $t = (n, r) => {
997
+ try {
998
+ let e = structuredClone(n), i = ge(r);
999
+ return l.suspend(() => y && x && !p ? x.prepareEscrowTaxSettle(e, i) : l.fail(t("unavailable")));
1000
+ } catch (n) {
1001
+ return l.fail(n instanceof e ? n : t("invalid_input"));
1002
+ }
1003
+ }, en = (n, r) => {
1004
+ try {
1005
+ let e = structuredClone(n), i = fe(r);
1006
+ return l.suspend(() => y && x && !p ? x.escrow(e, i) : l.fail(t("unavailable")));
1007
+ } catch (n) {
1008
+ return l.fail(n instanceof e ? n : t("invalid_input"));
1009
+ }
1010
+ }, tn = (n, r) => {
1011
+ try {
1012
+ let e = structuredClone(n), i = gt(r);
1013
+ return l.suspend(() => y && b && x && !p ? _t(b, x, f.currencies.map((e) => e.id), e, i) : l.fail(t("unavailable")));
1014
+ } catch (n) {
1015
+ return l.fail(n instanceof e ? n : t("invalid_input"));
1016
+ }
1017
+ };
1018
+ return {
1019
+ ...qt,
1020
+ economy: Object.freeze({
1021
+ service: () => $,
1022
+ prepareTransfer: Jt,
1023
+ prepareEscrowReserve: Yt,
1024
+ prepareEscrowRelease: Xt,
1025
+ prepareEscrowSettle: Zt,
1026
+ prepareEscrowTaxSettle: $t,
1027
+ prepareEscrowReserveTaxSettle: Qt,
1028
+ escrow: en,
1029
+ checkConsistency: tn,
1030
+ iap: () => Q?.service ?? Ie,
1031
+ iapEntitlements: () => Q?.entitlements ?? se,
1032
+ iapNotifications: () => Q?.notifications ?? be,
1033
+ iapRefundEvents: () => Q?.refundEvents ?? ce,
1034
+ shop: () => M,
1035
+ codes: () => R,
1036
+ containers: () => q,
1037
+ subscriptions: () => J?.service ?? lt,
1038
+ loyalty: () => Y?.service ?? dt,
1039
+ piggyBanks: () => X?.service ?? pt,
1040
+ trades: () => Z?.service ?? Re,
1041
+ expireTrade: (e, n) => Z?.expire(e, n) ?? l.fail(t("unavailable")),
1042
+ expireDueTrades: (e, n) => Z?.expireDue(e, n) ?? l.fail(t("unavailable")),
1043
+ price: Lt
1044
+ })
1045
+ };
1046
+ };
1047
+ //#endregion
1048
+ export { d as economyCodesSystemContract, v as economyContainersSystemContract, _ as economyIapSystemContract, p as economyLoyaltySystemContract, m as economyPiggyBanksSystemContract, y as economyPlugin, g as economyShopSystemContract, h as economySpendLimitsSystemContract, f as economySubscriptionsSystemContract, xt as economySystemContract, St as economyTradesSystemContract };