@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.
- package/CHANGELOG.md +24329 -0
- package/LICENSE +61 -0
- package/README.md +2719 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +9189 -0
- package/dist/amount.js +21 -0
- package/dist/appleIap.server.js +263 -0
- package/dist/appleIapNotifications.server.js +163 -0
- package/dist/appleIapTrust.server.js +31 -0
- package/dist/bundleValue.server.js +113 -0
- package/dist/canonicalDataJson.js +11 -0
- package/dist/capture.js +54 -0
- package/dist/codePort.fixture.js +124 -0
- package/dist/codeStore.server.js +440 -0
- package/dist/codeTables.entity.js +44 -0
- package/dist/codes.d.ts +150 -0
- package/dist/codes.js +83 -0
- package/dist/components.d.ts +397 -0
- package/dist/components.js +284 -0
- package/dist/consistency.server.js +116 -0
- package/dist/containerStore.server.js +688 -0
- package/dist/containerStore.testFixtures.js +76 -0
- package/dist/containerTables.entity.js +46 -0
- package/dist/containers.d.ts +311 -0
- package/dist/containers.fixture.js +129 -0
- package/dist/containers.js +215 -0
- package/dist/containers.server.js +40 -0
- package/dist/containersPort.fixture.js +75 -0
- package/dist/currency.js +33 -0
- package/dist/declarationFixtures.js +62 -0
- package/dist/economy-app/events/economy.refundReversed.event.ts +1 -0
- package/dist/economy-app/events/economy.refunded.event.ts +1 -0
- package/dist/economyPort.fixture.js +125 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +22 -0
- package/dist/events.d.ts +46 -0
- package/dist/events.js +1 -0
- package/dist/googleIap.server.js +392 -0
- package/dist/googleIapNotifications.server.js +131 -0
- package/dist/googleIapSubscription.server.js +184 -0
- package/dist/iap.d.ts +309 -0
- package/dist/iap.js +304 -0
- package/dist/iap.testFixtures.js +145 -0
- package/dist/iapAccountTables.entity.js +40 -0
- package/dist/iapAccounts.server.js +201 -0
- package/dist/iapBinding.server.js +524 -0
- package/dist/iapCheckout.server.js +98 -0
- package/dist/iapCompletion.server.js +56 -0
- package/dist/iapCurrentState.server.js +108 -0
- package/dist/iapCurrentState.testFixtures.js +23 -0
- package/dist/iapCurrentStatePort.fixture.js +64 -0
- package/dist/iapEntitlements.d.ts +79 -0
- package/dist/iapEntitlements.js +58 -0
- package/dist/iapEntitlements.server.js +49 -0
- package/dist/iapEntitlementsBinding.server.js +106 -0
- package/dist/iapEntitlementsPort.fixture.js +81 -0
- package/dist/iapInstalledEntitlements.testFixtures.js +76 -0
- package/dist/iapInstalledNotifications.testFixtures.js +94 -0
- package/dist/iapInventoryRefunds.server.js +262 -0
- package/dist/iapNotificationCustodyPort.fixture.js +68 -0
- package/dist/iapNotificationPort.fixture.js +74 -0
- package/dist/iapNotificationProcessor.server.js +135 -0
- package/dist/iapNotificationProcessor.testFixtures.js +64 -0
- package/dist/iapNotificationProcessorPort.fixture.js +56 -0
- package/dist/iapNotificationSchedule.server.js +70 -0
- package/dist/iapNotificationStore.server.js +353 -0
- package/dist/iapNotificationStore.testFixtures.js +32 -0
- package/dist/iapNotificationTables.entity.js +49 -0
- package/dist/iapNotificationTarget.server.js +37 -0
- package/dist/iapNotificationTarget.testFixtures.js +30 -0
- package/dist/iapNotifications.d.ts +644 -0
- package/dist/iapNotifications.js +6 -0
- package/dist/iapNotifications.server.js +96 -0
- package/dist/iapNotificationsBinding.server.js +233 -0
- package/dist/iapNotificationsSystemPort.fixture.js +51 -0
- package/dist/iapPlugin.testFixtures.js +60 -0
- package/dist/iapPort.fixture.js +75 -0
- package/dist/iapProviderCapture.server.js +18 -0
- package/dist/iapRecovery.d.ts +146 -0
- package/dist/iapRecovery.js +90 -0
- package/dist/iapRefundEventDelivery.server.js +83 -0
- package/dist/iapRefundEvents.js +45 -0
- package/dist/iapRefundEventsPort.fixture.js +60 -0
- package/dist/iapRefundPort.fixture.js +55 -0
- package/dist/iapRefundTables.entity.js +56 -0
- package/dist/iapRefunds.d.ts +755 -0
- package/dist/iapRefunds.js +6 -0
- package/dist/iapRefunds.server.js +554 -0
- package/dist/iapRefunds.testFixtures.js +65 -0
- package/dist/iapSpendAdmission.server.js +99 -0
- package/dist/iapStore.server.js +741 -0
- package/dist/iapStore.testFixtures.js +128 -0
- package/dist/iapTables.entity.js +81 -0
- package/dist/iapVerification.server.js +121 -0
- package/dist/index.d.ts +2984 -0
- package/dist/index.js +15 -0
- package/dist/intentionRecovery.js +134 -0
- package/dist/ledger.js +78 -0
- package/dist/loyalty.d.ts +274 -0
- package/dist/loyalty.fixture.js +93 -0
- package/dist/loyalty.js +312 -0
- package/dist/loyaltyBinding.server.js +204 -0
- package/dist/loyaltyPort.fixture.js +87 -0
- package/dist/loyaltyShopSource.server.js +91 -0
- package/dist/loyaltyStore.server.js +553 -0
- package/dist/loyaltyStore.testFixtures.js +83 -0
- package/dist/loyaltyTables.entity.js +50 -0
- package/dist/offerMerchandising.fixture.js +115 -0
- package/dist/offerMerchandising.js +283 -0
- package/dist/offerPolicies.d.ts +441 -0
- package/dist/offerPolicies.fixture.js +54 -0
- package/dist/offerPolicies.js +268 -0
- package/dist/piggyBanks.d.ts +272 -0
- package/dist/piggyBanks.fixture.js +71 -0
- package/dist/piggyBanks.js +201 -0
- package/dist/piggyBinding.server.js +205 -0
- package/dist/piggyPort.fixture.js +73 -0
- package/dist/piggyStore.server.js +611 -0
- package/dist/piggyStore.testFixtures.js +98 -0
- package/dist/piggyTables.entity.js +41 -0
- package/dist/plugin.js +1048 -0
- package/dist/port.js +13 -0
- package/dist/price.d.ts +99 -0
- package/dist/price.js +144 -0
- package/dist/purchaseRecovery.js +56 -0
- package/dist/reports.server.js +115 -0
- package/dist/rpc.d.ts +3201 -0
- package/dist/rpc.js +1201 -0
- package/dist/sanctionsTradeAuthority.server.js +80 -0
- package/dist/server.d.ts +3856 -0
- package/dist/server.js +43 -0
- package/dist/shop.d.ts +279 -0
- package/dist/shop.js +196 -0
- package/dist/shop.testFixtures.js +114 -0
- package/dist/shopPort.fixture.js +72 -0
- package/dist/shopPresentation.js +68 -0
- package/dist/shopStore.server.js +624 -0
- package/dist/shopTables.entity.js +63 -0
- package/dist/shopUiCopy.js +57 -0
- package/dist/spendLimits.d.ts +140 -0
- package/dist/spendLimits.fixture.js +53 -0
- package/dist/spendLimits.js +155 -0
- package/dist/spendLimitsPort.fixture.js +120 -0
- package/dist/subscriptionBinding.server.js +211 -0
- package/dist/subscriptionStore.server.js +643 -0
- package/dist/subscriptionStore.testFixtures.js +72 -0
- package/dist/subscriptionTables.entity.js +37 -0
- package/dist/subscriptions.d.ts +394 -0
- package/dist/subscriptions.fixture.js +97 -0
- package/dist/subscriptions.js +213 -0
- package/dist/subscriptionsPort.fixture.js +76 -0
- package/dist/systemFixtures.js +89 -0
- package/dist/tables.entity.js +83 -0
- package/dist/testing.d.ts +4615 -0
- package/dist/testing.js +29 -0
- package/dist/tradeAuthority.server.js +172 -0
- package/dist/tradeBinding.server.js +201 -0
- package/dist/tradeComponents.js +342 -0
- package/dist/tradeEscrow.server.js +232 -0
- package/dist/tradeEscrow.testFixtures.js +133 -0
- package/dist/tradeExpiry.server.js +43 -0
- package/dist/tradeRecovery.js +48 -0
- package/dist/tradeStore.server.js +750 -0
- package/dist/tradeStore.testFixtures.js +73 -0
- package/dist/tradeTables.entity.js +66 -0
- package/dist/tradeUiCopy.js +79 -0
- package/dist/trades.d.ts +246 -0
- package/dist/trades.fixture.js +103 -0
- package/dist/trades.js +289 -0
- package/dist/tradesPort.fixture.js +94 -0
- package/dist/walletEscrow.js +106 -0
- package/dist/walletEscrow.server.js +376 -0
- package/dist/walletKeys.server.js +5 -0
- package/dist/walletStore.js +571 -0
- package/dist/web.d.ts +2257 -0
- package/dist/web.js +9 -0
- package/package.json +161 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ShopPort as e } from "./shop.js";
|
|
2
|
+
import { EconomyPort as t } from "./port.js";
|
|
3
|
+
import { economyPlugin as n } from "./plugin.js";
|
|
4
|
+
import { shopFixture as r } from "./shop.testFixtures.js";
|
|
5
|
+
import { Effect as i, Layer as a } from "effect";
|
|
6
|
+
import { InMemoryDataStore as o } from "@voltro/runtime";
|
|
7
|
+
//#region src/shopPort.fixture.ts
|
|
8
|
+
var s = {
|
|
9
|
+
app: {
|
|
10
|
+
name: "shop-fixture",
|
|
11
|
+
type: "api",
|
|
12
|
+
voltroVersion: "0.83.1"
|
|
13
|
+
},
|
|
14
|
+
config: {},
|
|
15
|
+
env: {},
|
|
16
|
+
logger: {
|
|
17
|
+
info() {},
|
|
18
|
+
warn() {},
|
|
19
|
+
error() {},
|
|
20
|
+
debug() {}
|
|
21
|
+
}
|
|
22
|
+
}, c = i.gen(function* () {
|
|
23
|
+
let e = new o(), t = yield* i.promise(() => r(e, "fixture")), a = t.options, c = n({
|
|
24
|
+
currencies: a.currencies,
|
|
25
|
+
now: a.now,
|
|
26
|
+
shop: {
|
|
27
|
+
offers: a.offers,
|
|
28
|
+
inventory: a.inventory,
|
|
29
|
+
now: a.now
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return yield* i.promise(async () => {
|
|
33
|
+
await c.bindDataStore?.(e);
|
|
34
|
+
}), Object.freeze({
|
|
35
|
+
store: e,
|
|
36
|
+
plugin: c,
|
|
37
|
+
base: t,
|
|
38
|
+
close: i.suspend(() => c.onDeactivate?.(s))
|
|
39
|
+
});
|
|
40
|
+
}), l = a.effectContext(i.acquireRelease(c, (e) => e.close).pipe(i.flatMap((e) => a.build(e.plugin.services)))), u = Object.freeze({
|
|
41
|
+
kind: "port",
|
|
42
|
+
tag: e,
|
|
43
|
+
fakeLayer: l,
|
|
44
|
+
probe: {
|
|
45
|
+
run: () => i.scoped(i.gen(function* () {
|
|
46
|
+
let n = yield* e, r = yield* t, i = {
|
|
47
|
+
type: "user",
|
|
48
|
+
id: "a",
|
|
49
|
+
tenantId: "fixture",
|
|
50
|
+
kind: "guest"
|
|
51
|
+
}, a = (yield* n.offers(i))[0], o = {
|
|
52
|
+
offerId: a.offer.id,
|
|
53
|
+
offerVersion: a.offer.version,
|
|
54
|
+
offerDigest: a.offerDigest,
|
|
55
|
+
requestId: "buy",
|
|
56
|
+
currency: "test.gold"
|
|
57
|
+
}, s = yield* n.buy(i, o), c = yield* n.buy(i, o), l = yield* r.mine(i);
|
|
58
|
+
return {
|
|
59
|
+
same: s.orderId === c.orderId,
|
|
60
|
+
quantity: s.quantity,
|
|
61
|
+
balance: l[0]?.balance
|
|
62
|
+
};
|
|
63
|
+
}).pipe(i.provide(l))),
|
|
64
|
+
expected: {
|
|
65
|
+
same: !0,
|
|
66
|
+
quantity: 1,
|
|
67
|
+
balance: "93"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
//#endregion
|
|
72
|
+
export { l as shopFakeLayer, c as shopPortFixture, u as shopPortSystemFixture };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { economyError as e } from "./errors.js";
|
|
2
|
+
import { dataList as t, dataObject as n, identifier as r } from "./capture.js";
|
|
3
|
+
import { definePrice as i, priceResolverContext as a, resolvePrice as o } from "./price.js";
|
|
4
|
+
import { defineShopOffer as s, shopBuyIntent as c, shopInteger as l, shopPayment as u } from "./shop.js";
|
|
5
|
+
//#region src/shopPresentation.ts
|
|
6
|
+
var d = (c) => {
|
|
7
|
+
let l = n(c, [
|
|
8
|
+
"offer",
|
|
9
|
+
"price",
|
|
10
|
+
"offerDigest"
|
|
11
|
+
]);
|
|
12
|
+
if (typeof l.offerDigest != "string" || !/^[a-f0-9]{64}$/.test(l.offerDigest)) throw e("invalid_record");
|
|
13
|
+
let u = n(l.offer, [
|
|
14
|
+
"id",
|
|
15
|
+
"version",
|
|
16
|
+
"titleKey",
|
|
17
|
+
"price",
|
|
18
|
+
"items",
|
|
19
|
+
"currencies",
|
|
20
|
+
"from",
|
|
21
|
+
"until",
|
|
22
|
+
"segment",
|
|
23
|
+
"flag",
|
|
24
|
+
"countries",
|
|
25
|
+
"limits",
|
|
26
|
+
"oneTime",
|
|
27
|
+
"maxQuantity"
|
|
28
|
+
]), d = n(u.price, [
|
|
29
|
+
"kind",
|
|
30
|
+
"options",
|
|
31
|
+
"real",
|
|
32
|
+
"virtual",
|
|
33
|
+
"prices",
|
|
34
|
+
"storeProductIds"
|
|
35
|
+
]), f = d.kind === "virtual" ? d.options : d.kind === "mixed" ? d.virtual : [], p = /* @__PURE__ */ new Set();
|
|
36
|
+
for (let e of [...t(f, 32, "invalid_record"), ...t(u.currencies, 16, "invalid_record")]) p.add(r(n(e, ["currency", "amount"]).currency));
|
|
37
|
+
let m = Array.from(p, (e) => ({
|
|
38
|
+
id: e,
|
|
39
|
+
kind: "soft"
|
|
40
|
+
})), h = s(l.offer, m, !0), g = o(a(h.price, m, !0), () => i(l.price, m, !0));
|
|
41
|
+
return Object.freeze({
|
|
42
|
+
offer: h,
|
|
43
|
+
price: g,
|
|
44
|
+
offerDigest: l.offerDigest
|
|
45
|
+
});
|
|
46
|
+
}, f = (t, n) => {
|
|
47
|
+
let r = d(t), i = c(n);
|
|
48
|
+
if (i.offerId !== r.offer.id || i.offerVersion !== r.offer.version || i.offerDigest !== r.offerDigest || i.qty > r.offer.maxQuantity) throw e("conflict");
|
|
49
|
+
let a = u(r.price, i.currency, i.qty), o = u(r.offer.price, i.currency, i.qty), s = o.kind === "virtual" && a.kind === "virtual" && BigInt(o.amount) > 0n ? Number((BigInt(o.amount) - BigInt(a.amount)) * 100n / BigInt(o.amount)) : 0;
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
request: Object.freeze({
|
|
52
|
+
offerId: i.offerId,
|
|
53
|
+
offerVersion: i.offerVersion,
|
|
54
|
+
offerDigest: i.offerDigest,
|
|
55
|
+
requestId: i.requestId,
|
|
56
|
+
qty: i.qty,
|
|
57
|
+
...i.currency === null ? {} : { currency: i.currency }
|
|
58
|
+
}),
|
|
59
|
+
current: a,
|
|
60
|
+
maximum: o,
|
|
61
|
+
discountPercent: s
|
|
62
|
+
});
|
|
63
|
+
}, p = (e, t) => {
|
|
64
|
+
let n = d(e).offer;
|
|
65
|
+
return l(t, 0, 864e13), (n.from === null || t >= n.from) && (n.until === null || t < n.until);
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { d as captureShopOfferView, p as shopOfferAvailable, f as shopPurchaseTerms };
|