@voltro/plugin-inventory 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 +441 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +7737 -0
- package/dist/capture.js +53 -0
- package/dist/catalog.d.ts +63 -0
- package/dist/catalog.js +5 -0
- package/dist/cmsCatalog.d.ts +95 -0
- package/dist/cmsCatalog.js +80 -0
- package/dist/components.d.ts +247 -0
- package/dist/components.js +321 -0
- package/dist/crafting.d.ts +211 -0
- package/dist/crafting.js +193 -0
- package/dist/declarationFixtures.js +66 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +22 -0
- package/dist/index.d.ts +576 -0
- package/dist/index.js +8 -0
- package/dist/inventoryPort.fixture.js +66 -0
- package/dist/inventoryPresentation.js +109 -0
- package/dist/inventoryStore.js +1576 -0
- package/dist/inventoryUiCopy.js +63 -0
- package/dist/item.d.ts +73 -0
- package/dist/item.js +105 -0
- package/dist/plugin.js +407 -0
- package/dist/port.js +5 -0
- package/dist/reservation.js +85 -0
- package/dist/rpc.d.ts +145 -0
- package/dist/rpc.js +135 -0
- package/dist/server.d.ts +816 -0
- package/dist/server.js +4 -0
- package/dist/sqlCatalog.js +185 -0
- package/dist/strategies.d.ts +64 -0
- package/dist/strategies.js +47 -0
- package/dist/systemFixtures.js +172 -0
- package/dist/tables.entity.js +164 -0
- package/dist/testing.d.ts +448 -0
- package/dist/testing.js +4 -0
- package/dist/web.d.ts +60 -0
- package/dist/web.js +7 -0
- package/package.json +104 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { inventoryError as e } from "./errors.js";
|
|
2
|
+
import { identifier as t, integer as n, jsonData as r, list as i, object as a } from "./capture.js";
|
|
3
|
+
import { defineRecipe as o, resolveCraftPlan as s } from "./crafting.js";
|
|
4
|
+
import { contractKey as c } from "./item.js";
|
|
5
|
+
import { CatalogItemSchema as l, InventoryInstanceSchema as u, InventoryLoadoutSchema as d } from "./rpc.js";
|
|
6
|
+
import { Schema as f } from "effect";
|
|
7
|
+
//#region src/inventoryPresentation.ts
|
|
8
|
+
var p = (e) => n(e, 0, 864e13), m = (o, s, m, h) => {
|
|
9
|
+
let g = p(h), _ = a(s, ["revision", "items"]), v = t(_.revision), y = Object.freeze(i(_.items, 1e4).map((o) => {
|
|
10
|
+
let s = a(o, [
|
|
11
|
+
"id",
|
|
12
|
+
"schemaVersion",
|
|
13
|
+
"kind",
|
|
14
|
+
"stackable",
|
|
15
|
+
"maxStack",
|
|
16
|
+
"tradable",
|
|
17
|
+
"rarity",
|
|
18
|
+
"tags",
|
|
19
|
+
"equipSlot",
|
|
20
|
+
"expiresAfter",
|
|
21
|
+
"display",
|
|
22
|
+
"attributes",
|
|
23
|
+
"instanceDefaults"
|
|
24
|
+
]), c = a(s.display, ["nameKey", "icon"]), u = f.decodeUnknownSync(l, { onExcessProperty: "error" })({
|
|
25
|
+
...s,
|
|
26
|
+
tags: i(s.tags, 64),
|
|
27
|
+
display: c,
|
|
28
|
+
attributes: r(s.attributes),
|
|
29
|
+
instanceDefaults: r(s.instanceDefaults)
|
|
30
|
+
});
|
|
31
|
+
if (t(u.id), n(u.schemaVersion, 1, 1e6), n(u.maxStack, 1, 1e6), t(u.rarity), t(u.display.nameKey), !u.stackable && u.maxStack !== 1 || new Set(u.tags).size !== u.tags.length || (u.tags.forEach(t), u.equipSlot !== null && t(u.equipSlot), u.expiresAfter !== null && n(u.expiresAfter, 1, 31536e7), u.display.icon !== null && (u.display.icon.length > 512 || !/^storage:\/\/[A-Za-z0-9][A-Za-z0-9/_.-]*$/.test(u.display.icon)))) throw e("invalid_record");
|
|
32
|
+
return Object.freeze({
|
|
33
|
+
...u,
|
|
34
|
+
tags: Object.freeze([...u.tags]),
|
|
35
|
+
display: Object.freeze({ ...u.display })
|
|
36
|
+
});
|
|
37
|
+
})), b = new Map(y.map((e) => [c(e.id, e.schemaVersion), e]));
|
|
38
|
+
if (b.size !== y.length) throw e("invalid_record");
|
|
39
|
+
let x = Object.freeze(i(o, 1e4).map((i) => {
|
|
40
|
+
let o = a(i, [
|
|
41
|
+
"id",
|
|
42
|
+
"itemId",
|
|
43
|
+
"schemaVersion",
|
|
44
|
+
"qty",
|
|
45
|
+
"attributes",
|
|
46
|
+
"acquiredAt",
|
|
47
|
+
"expiresAt",
|
|
48
|
+
"locked",
|
|
49
|
+
"source"
|
|
50
|
+
]), s = f.decodeUnknownSync(u, { onExcessProperty: "error" })({
|
|
51
|
+
...o,
|
|
52
|
+
attributes: r(o.attributes)
|
|
53
|
+
});
|
|
54
|
+
t(s.id), t(s.itemId), t(s.source), n(s.schemaVersion, 1, 1e6), n(s.qty, 1, 1e6), p(s.acquiredAt), s.expiresAt !== null && n(s.expiresAt, s.acquiredAt + 1, 864e13);
|
|
55
|
+
let l = b.get(c(s.itemId, s.schemaVersion));
|
|
56
|
+
if (l && s.qty > l.maxStack) throw e("invalid_record");
|
|
57
|
+
return Object.freeze(s);
|
|
58
|
+
})), S = new Map(x.map((e) => [e.id, e]));
|
|
59
|
+
if (S.size !== x.length) throw e("invalid_record");
|
|
60
|
+
let C = Object.freeze(i(m, 256).map((n) => {
|
|
61
|
+
let r = a(n, [
|
|
62
|
+
"slotSet",
|
|
63
|
+
"slot",
|
|
64
|
+
"instanceId"
|
|
65
|
+
]), i = f.decodeUnknownSync(d, { onExcessProperty: "error" })(r);
|
|
66
|
+
if (t(i.slotSet), t(i.slot), t(i.instanceId), !S.has(i.instanceId)) throw e("invalid_record");
|
|
67
|
+
return Object.freeze(i);
|
|
68
|
+
}));
|
|
69
|
+
if (new Set(C.map((e) => JSON.stringify([e.slotSet, e.slot]))).size !== C.length) throw e("invalid_record");
|
|
70
|
+
let w = new Set(C.map((e) => e.instanceId));
|
|
71
|
+
return Object.freeze({
|
|
72
|
+
catalog: Object.freeze({
|
|
73
|
+
revision: v,
|
|
74
|
+
items: y
|
|
75
|
+
}),
|
|
76
|
+
loadout: C,
|
|
77
|
+
items: Object.freeze(x.map((e) => Object.freeze({
|
|
78
|
+
instance: e,
|
|
79
|
+
content: b.get(c(e.itemId, e.schemaVersion)),
|
|
80
|
+
equipped: w.has(e.id),
|
|
81
|
+
expired: e.expiresAt !== null && e.expiresAt <= g
|
|
82
|
+
})))
|
|
83
|
+
});
|
|
84
|
+
}, h = (e, t) => e.content?.equipSlot === t && !e.expired && !e.instance.locked, g = (e, t, r, i) => {
|
|
85
|
+
let a = o(t), c = n(r, 1, a.maxBatches), l = p(i), u = !0;
|
|
86
|
+
try {
|
|
87
|
+
s({
|
|
88
|
+
recipe: a,
|
|
89
|
+
batches: c,
|
|
90
|
+
at: l,
|
|
91
|
+
available: e.items.map((e) => e.instance),
|
|
92
|
+
excludedIds: [...new Set(e.loadout.map((e) => e.instanceId))]
|
|
93
|
+
});
|
|
94
|
+
} catch (e) {
|
|
95
|
+
if (e && typeof e == "object" && "code" in e && e.code === "insufficient_items") u = !1;
|
|
96
|
+
else throw e;
|
|
97
|
+
}
|
|
98
|
+
return Object.freeze({
|
|
99
|
+
recipe: a,
|
|
100
|
+
batches: c,
|
|
101
|
+
materialsAvailable: u,
|
|
102
|
+
currencyCost: a.cost === null ? null : Object.freeze({
|
|
103
|
+
currency: a.cost.currency,
|
|
104
|
+
amount: (BigInt(a.cost.amount) * BigInt(c)).toString()
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { m as captureInventoryPresentation, h as inventoryCanEquip, g as inventoryRecipePreview };
|