@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.
@@ -0,0 +1,85 @@
1
+ import { inventoryError as e } from "./errors.js";
2
+ import { identifier as t, integer as n, list as r, object as i } from "./capture.js";
3
+ //#region src/reservation.ts
4
+ var a = (a) => {
5
+ let o = r(a, 32).map((e) => {
6
+ let r = i(e, ["instanceId", "qty"]);
7
+ return Object.freeze({
8
+ instanceId: t(r.instanceId),
9
+ qty: n(r.qty, 1, 1e6)
10
+ });
11
+ }).sort((e, t) => e.instanceId < t.instanceId ? -1 : +(e.instanceId > t.instanceId));
12
+ if (!o.length || new Set(o.map((e) => e.instanceId)).size !== o.length) throw e("invalid_input");
13
+ return Object.freeze(o);
14
+ }, o = (n) => {
15
+ let r = i(n, [
16
+ "tenantId",
17
+ "owner",
18
+ "reservationId"
19
+ ]), a = i(r.owner, ["ownerKind", "ownerId"]);
20
+ if (a.ownerKind !== "player" && a.ownerKind !== "guild") throw e("invalid_input");
21
+ return Object.freeze({
22
+ tenantId: t(r.tenantId),
23
+ reservationId: t(r.reservationId),
24
+ owner: Object.freeze({
25
+ ownerKind: a.ownerKind,
26
+ ownerId: t(a.ownerId)
27
+ })
28
+ });
29
+ }, s = (e) => {
30
+ let t = i(e, [
31
+ "tenantId",
32
+ "owner",
33
+ "reservationId",
34
+ "items"
35
+ ]);
36
+ return Object.freeze({
37
+ ...o({
38
+ tenantId: t.tenantId,
39
+ owner: t.owner,
40
+ reservationId: t.reservationId
41
+ }),
42
+ items: a(t.items)
43
+ });
44
+ }, c = (t) => {
45
+ let n = i(t, [
46
+ "tenantId",
47
+ "from",
48
+ "to",
49
+ "reservationId"
50
+ ]), r = o({
51
+ tenantId: n.tenantId,
52
+ owner: n.from,
53
+ reservationId: n.reservationId
54
+ }), a = o({
55
+ tenantId: n.tenantId,
56
+ owner: n.to,
57
+ reservationId: n.reservationId
58
+ });
59
+ if (r.owner.ownerKind === a.owner.ownerKind && r.owner.ownerId === a.owner.ownerId) throw e("invalid_input");
60
+ return Object.freeze({
61
+ tenantId: r.tenantId,
62
+ reservationId: r.reservationId,
63
+ from: r.owner,
64
+ to: a.owner
65
+ });
66
+ }, l = (e) => {
67
+ let t = i(e, [
68
+ "tenantId",
69
+ "from",
70
+ "to",
71
+ "reservationId",
72
+ "items"
73
+ ]), n = c({
74
+ tenantId: t.tenantId,
75
+ from: t.from,
76
+ to: t.to,
77
+ reservationId: t.reservationId
78
+ });
79
+ return Object.freeze({
80
+ ...n,
81
+ items: a(t.items)
82
+ });
83
+ };
84
+ //#endregion
85
+ export { o as captureInventoryReleaseInput, c as captureInventoryReservationTransferInput, s as captureInventoryReserveInput, l as captureInventoryReserveTransferInput, a as captureReservationItems };
package/dist/rpc.d.ts ADDED
@@ -0,0 +1,145 @@
1
+ import { ActionProcedureDescriptor } from '@voltro/protocol';
2
+ import { PluginRpcClientDescriptor } from '@voltro/protocol';
3
+ import { QueryProcedureDescriptor } from '@voltro/protocol';
4
+ import { Schema } from 'effect';
5
+ import { YieldableError } from 'effect/Cause';
6
+
7
+ export declare const CatalogItemSchema: Schema.Struct<{
8
+ readonly id: Schema.String;
9
+ readonly schemaVersion: Schema.Number;
10
+ readonly kind: Schema.Literals<readonly ["consumable", "equipment", "cosmetic", "currencyBundle", "key", "mod"]>;
11
+ readonly stackable: Schema.Boolean;
12
+ readonly maxStack: Schema.Number;
13
+ readonly tradable: Schema.Boolean;
14
+ readonly rarity: Schema.String;
15
+ readonly tags: Schema.$Array<Schema.String>;
16
+ readonly equipSlot: Schema.NullOr<Schema.String>;
17
+ readonly expiresAfter: Schema.NullOr<Schema.Number>;
18
+ readonly display: Schema.Struct<{
19
+ readonly nameKey: Schema.String;
20
+ readonly icon: Schema.NullOr<Schema.String>;
21
+ }>;
22
+ readonly attributes: Schema.Unknown;
23
+ readonly instanceDefaults: Schema.Unknown;
24
+ }>;
25
+
26
+ export declare const CatalogSnapshotSchema: Schema.Struct<{
27
+ readonly revision: Schema.String;
28
+ readonly items: Schema.$Array<Schema.Struct<{
29
+ readonly id: Schema.String;
30
+ readonly schemaVersion: Schema.Number;
31
+ readonly kind: Schema.Literals<readonly ["consumable", "equipment", "cosmetic", "currencyBundle", "key", "mod"]>;
32
+ readonly stackable: Schema.Boolean;
33
+ readonly maxStack: Schema.Number;
34
+ readonly tradable: Schema.Boolean;
35
+ readonly rarity: Schema.String;
36
+ readonly tags: Schema.$Array<Schema.String>;
37
+ readonly equipSlot: Schema.NullOr<Schema.String>;
38
+ readonly expiresAfter: Schema.NullOr<Schema.Number>;
39
+ readonly display: Schema.Struct<{
40
+ readonly nameKey: Schema.String;
41
+ readonly icon: Schema.NullOr<Schema.String>;
42
+ }>;
43
+ readonly attributes: Schema.Unknown;
44
+ readonly instanceDefaults: Schema.Unknown;
45
+ }>>;
46
+ }>;
47
+
48
+ export declare const INVENTORY_NAME = "@voltro/plugin-inventory";
49
+
50
+ export declare const inventoryCatalogDescriptor: QueryProcedureDescriptor<"inventory.catalog", Schema.Struct<{}>, Schema.Struct<{
51
+ readonly revision: Schema.String;
52
+ readonly items: Schema.$Array<Schema.Struct<{
53
+ readonly id: Schema.String;
54
+ readonly schemaVersion: Schema.Number;
55
+ readonly kind: Schema.Literals<readonly ["consumable", "equipment", "cosmetic", "currencyBundle", "key", "mod"]>;
56
+ readonly stackable: Schema.Boolean;
57
+ readonly maxStack: Schema.Number;
58
+ readonly tradable: Schema.Boolean;
59
+ readonly rarity: Schema.String;
60
+ readonly tags: Schema.$Array<Schema.String>;
61
+ readonly equipSlot: Schema.NullOr<Schema.String>;
62
+ readonly expiresAfter: Schema.NullOr<Schema.Number>;
63
+ readonly display: Schema.Struct<{
64
+ readonly nameKey: Schema.String;
65
+ readonly icon: Schema.NullOr<Schema.String>;
66
+ }>;
67
+ readonly attributes: Schema.Unknown;
68
+ readonly instanceDefaults: Schema.Unknown;
69
+ }>>;
70
+ }>, typeof InventoryError>;
71
+
72
+ export declare const inventoryEquipDescriptor: ActionProcedureDescriptor<"inventory.equip", Schema.Struct<{
73
+ readonly slotSet: Schema.String;
74
+ readonly slot: Schema.String;
75
+ readonly instanceId: Schema.NullOr<Schema.String>;
76
+ readonly requestId: Schema.String;
77
+ }>, Schema.Struct<{
78
+ readonly operationId: Schema.String;
79
+ readonly kind: Schema.Literals<readonly ["grant", "consume", "equip", "expire", "craft", "reserve", "release", "transfer-out", "transfer-in"]>;
80
+ readonly changes: Schema.$Array<Schema.Struct<{
81
+ readonly instanceId: Schema.String;
82
+ readonly delta: Schema.Number;
83
+ }>>;
84
+ readonly at: Schema.Number;
85
+ }>, typeof InventoryError>;
86
+
87
+ /** Public errors carry codes, never subjects, catalog values or provider causes. */
88
+ declare class InventoryError extends InventoryError_base {
89
+ }
90
+
91
+ declare const InventoryError_base: Schema.Class<InventoryError, Schema.TaggedStruct<"InventoryError", {
92
+ readonly code: Schema.Literals<readonly ["invalid_input", "invalid_record", "invalid_item", "invalid_attributes", "conflict", "forbidden", "not_found", "unavailable", "limit_exceeded", "erased", "insufficient_items", "insufficient_funds", "payment_refused", "locked", "expired", "invalid_slot"]>;
93
+ }>, YieldableError>;
94
+
95
+ export declare const InventoryInstanceSchema: Schema.Struct<{
96
+ readonly id: Schema.String;
97
+ readonly itemId: Schema.String;
98
+ readonly schemaVersion: Schema.Number;
99
+ readonly qty: Schema.Number;
100
+ readonly attributes: Schema.Unknown;
101
+ readonly acquiredAt: Schema.Number;
102
+ readonly expiresAt: Schema.NullOr<Schema.Number>;
103
+ readonly locked: Schema.Boolean;
104
+ readonly source: Schema.String;
105
+ }>;
106
+
107
+ export declare const inventoryLoadoutDescriptor: QueryProcedureDescriptor<"inventory.loadout", Schema.Struct<{
108
+ readonly slotSet: Schema.String;
109
+ }>, Schema.$Array<Schema.Struct<{
110
+ readonly slotSet: Schema.String;
111
+ readonly slot: Schema.String;
112
+ readonly instanceId: Schema.String;
113
+ }>>, typeof InventoryError>;
114
+
115
+ export declare const InventoryLoadoutSchema: Schema.Struct<{
116
+ readonly slotSet: Schema.String;
117
+ readonly slot: Schema.String;
118
+ readonly instanceId: Schema.String;
119
+ }>;
120
+
121
+ export declare const inventoryMineDescriptor: QueryProcedureDescriptor<"inventory.mine", Schema.Struct<{}>, Schema.$Array<Schema.Struct<{
122
+ readonly id: Schema.String;
123
+ readonly itemId: Schema.String;
124
+ readonly schemaVersion: Schema.Number;
125
+ readonly qty: Schema.Number;
126
+ readonly attributes: Schema.Unknown;
127
+ readonly acquiredAt: Schema.Number;
128
+ readonly expiresAt: Schema.NullOr<Schema.Number>;
129
+ readonly locked: Schema.Boolean;
130
+ readonly source: Schema.String;
131
+ }>>, typeof InventoryError>;
132
+
133
+ export declare const InventoryReceiptSchema: Schema.Struct<{
134
+ readonly operationId: Schema.String;
135
+ readonly kind: Schema.Literals<readonly ["grant", "consume", "equip", "expire", "craft", "reserve", "release", "transfer-out", "transfer-in"]>;
136
+ readonly changes: Schema.$Array<Schema.Struct<{
137
+ readonly instanceId: Schema.String;
138
+ readonly delta: Schema.Number;
139
+ }>>;
140
+ readonly at: Schema.Number;
141
+ }>;
142
+
143
+ export declare const inventoryRpcClientImports: readonly PluginRpcClientDescriptor[];
144
+
145
+ export { }
package/dist/rpc.js ADDED
@@ -0,0 +1,135 @@
1
+ import { InventoryError as e } from "./errors.js";
2
+ import { Schema as t } from "effect";
3
+ import { defineAction as n, defineQuery as r } from "@voltro/protocol";
4
+ //#region src/rpc.ts
5
+ var i = "@voltro/plugin-inventory", a = t.Struct({
6
+ id: t.String,
7
+ itemId: t.String,
8
+ schemaVersion: t.Number,
9
+ qty: t.Number,
10
+ attributes: t.Unknown,
11
+ acquiredAt: t.Number,
12
+ expiresAt: t.NullOr(t.Number),
13
+ locked: t.Boolean,
14
+ source: t.String
15
+ }), o = t.Struct({
16
+ slotSet: t.String,
17
+ slot: t.String,
18
+ instanceId: t.String
19
+ }), s = t.Struct({
20
+ operationId: t.String,
21
+ kind: t.Literals([
22
+ "grant",
23
+ "consume",
24
+ "equip",
25
+ "expire",
26
+ "craft",
27
+ "reserve",
28
+ "release",
29
+ "transfer-out",
30
+ "transfer-in"
31
+ ]),
32
+ changes: t.Array(t.Struct({
33
+ instanceId: t.String,
34
+ delta: t.Number
35
+ })),
36
+ at: t.Number
37
+ }), c = t.Struct({
38
+ id: t.String,
39
+ schemaVersion: t.Number,
40
+ kind: t.Literals([
41
+ "consumable",
42
+ "equipment",
43
+ "cosmetic",
44
+ "currencyBundle",
45
+ "key",
46
+ "mod"
47
+ ]),
48
+ stackable: t.Boolean,
49
+ maxStack: t.Number,
50
+ tradable: t.Boolean,
51
+ rarity: t.String,
52
+ tags: t.Array(t.String),
53
+ equipSlot: t.NullOr(t.String),
54
+ expiresAfter: t.NullOr(t.Number),
55
+ display: t.Struct({
56
+ nameKey: t.String,
57
+ icon: t.NullOr(t.String)
58
+ }),
59
+ attributes: t.Unknown,
60
+ instanceDefaults: t.Unknown
61
+ }), l = t.Struct({
62
+ revision: t.String,
63
+ items: t.Array(c)
64
+ }), u = "The installed service requires a verified user or guest; tenant and owner come from its authenticated Subject.", d = r({
65
+ name: "inventory.mine",
66
+ input: t.Struct({}),
67
+ output: t.Array(a),
68
+ error: e,
69
+ source: ["_voltro_inv_items", "_voltro_inv_subjects"],
70
+ openAccess: u
71
+ }), f = r({
72
+ name: "inventory.loadout",
73
+ input: t.Struct({ slotSet: t.String }),
74
+ output: t.Array(o),
75
+ error: e,
76
+ source: [
77
+ "_voltro_inv_items",
78
+ "_voltro_inv_loadouts",
79
+ "_voltro_inv_subjects"
80
+ ],
81
+ openAccess: u
82
+ }), p = r({
83
+ name: "inventory.catalog",
84
+ input: t.Struct({}),
85
+ output: l,
86
+ error: e,
87
+ source: ["_voltro_inv_catalog", "_voltro_inv_catalog_heads"],
88
+ openAccess: "Authenticated user or guest reads only the app-configured channel and locale in the Subject tenant."
89
+ }), m = n({
90
+ name: "inventory.equip",
91
+ input: t.Struct({
92
+ slotSet: t.String,
93
+ slot: t.String,
94
+ instanceId: t.NullOr(t.String),
95
+ requestId: t.String
96
+ }),
97
+ output: s,
98
+ error: e,
99
+ openAccess: "Only an equip/unequip intention is accepted. The installed service derives owner and tenant, checks possession and slot, and never accepts client state."
100
+ }), h = [
101
+ {
102
+ tag: "inventory.mine",
103
+ kind: "query",
104
+ import: {
105
+ module: "@voltro/plugin-inventory/rpc",
106
+ name: "inventoryMineDescriptor"
107
+ }
108
+ },
109
+ {
110
+ tag: "inventory.loadout",
111
+ kind: "query",
112
+ import: {
113
+ module: "@voltro/plugin-inventory/rpc",
114
+ name: "inventoryLoadoutDescriptor"
115
+ }
116
+ },
117
+ {
118
+ tag: "inventory.catalog",
119
+ kind: "query",
120
+ import: {
121
+ module: "@voltro/plugin-inventory/rpc",
122
+ name: "inventoryCatalogDescriptor"
123
+ }
124
+ },
125
+ {
126
+ tag: "inventory.equip",
127
+ kind: "action",
128
+ import: {
129
+ module: "@voltro/plugin-inventory/rpc",
130
+ name: "inventoryEquipDescriptor"
131
+ }
132
+ }
133
+ ];
134
+ //#endregion
135
+ export { c as CatalogItemSchema, l as CatalogSnapshotSchema, i as INVENTORY_NAME, a as InventoryInstanceSchema, o as InventoryLoadoutSchema, s as InventoryReceiptSchema, p as inventoryCatalogDescriptor, m as inventoryEquipDescriptor, f as inventoryLoadoutDescriptor, d as inventoryMineDescriptor, h as inventoryRpcClientImports };