@voltro/plugin-guilds 0.89.2 → 0.91.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/dist/testing.d.ts CHANGED
@@ -1,5 +1,21 @@
1
+ import { Context } from 'effect';
1
2
  import { Effect } from 'effect';
3
+ import { Layer } from 'effect';
2
4
  import { Schema } from 'effect';
5
+ import { Subject } from '@voltro/protocol';
6
+ import { YieldableError } from 'effect/Cause';
7
+
8
+ export declare const fakeGuildMembershipLayer: (overrides?: Partial<GuildMembershipService>) => Layer.Layer<GuildMembershipPort, never, never>;
9
+
10
+ export declare const fakeGuildMembershipService: (overrides?: Partial<GuildMembershipService>) => GuildMembershipService;
11
+
12
+ export declare const fakeGuildPermissionLayer: (overrides?: Partial<GuildPermissionService>) => Layer.Layer<GuildPermissionPort, never, never>;
13
+
14
+ export declare const fakeGuildPermissionService: (overrides?: Partial<GuildPermissionService>) => GuildPermissionService;
15
+
16
+ export declare const fakeGuildRosterLayer: (overrides?: Partial<GuildRosterService>) => Layer.Layer<GuildRosterPort, never, never>;
17
+
18
+ export declare const fakeGuildRosterService: (overrides?: Partial<GuildRosterService>) => GuildRosterService;
3
19
 
4
20
  export declare const guildInactivityFixture: {
5
21
  kind: "slot";
@@ -60,8 +76,42 @@ declare interface GuildLevelInput {
60
76
  readonly maximumMemberCap: number;
61
77
  }
62
78
 
79
+ export declare const guildMembershipFakeLayer: Layer.Layer<GuildMembershipPort, never, never>;
80
+
81
+ declare class GuildMembershipPort extends GuildMembershipPort_base {
82
+ }
83
+
84
+ declare const GuildMembershipPort_base: Context.ServiceClass<GuildMembershipPort, "@voltro/GuildMembershipPort", GuildMembershipService>;
85
+
86
+ export declare const guildMembershipPortFixture: {
87
+ kind: "port";
88
+ tag: typeof GuildMembershipPort;
89
+ fakeLayer: Layer.Layer<GuildMembershipPort, never, never>;
90
+ probe: {
91
+ run: () => Effect.Effect<boolean | "expired" | "unavailable" | "conflict" | "identity_required" | "invalid_input" | "forbidden" | "not_found" | "name_taken" | "guild_limit" | "member_limit" | "pending_limit" | "blocked" | "content_rejected" | "export_limit", never, never>;
92
+ expected: string;
93
+ };
94
+ };
95
+
96
+ /** Chat, matchmaking parties and guild leaderboards ask this port, never Guild SQL. */
97
+ declare interface GuildMembershipService {
98
+ /** True only while `subject` belongs to `guildId` in its own tenant. Unknown, foreign or inaccessible guilds answer false. */
99
+ readonly isMember: (subject: Subject, guildId: string) => Effect.Effect<boolean, GuildsError>;
100
+ }
101
+
63
102
  declare type GuildPermission = keyof typeof PERMISSIONS;
64
103
 
104
+ declare class GuildPermissionPort extends GuildPermissionPort_base {
105
+ }
106
+
107
+ declare const GuildPermissionPort_base: Context.ServiceClass<GuildPermissionPort, "@voltro/GuildPermissionPort", GuildPermissionService>;
108
+
109
+ /** Whether a member's role grants a permission in their guild (e.g. `treasury` for a guild wallet), for
110
+ * other systems acting for that member; never Guild SQL. Non-members, unknown or foreign guilds answer false. */
111
+ declare interface GuildPermissionService {
112
+ readonly may: (subject: Subject, guildId: string, permission: GuildPermission) => Effect.Effect<boolean, GuildsError>;
113
+ }
114
+
65
115
  export declare const guildPermissionsFixture: {
66
116
  kind: "slot";
67
117
  defaultImplementation: ({ role, permission }: GuildPermissionsInput) => boolean;
@@ -91,6 +141,36 @@ declare const GuildRoleSchema: Schema.Struct<{
91
141
  readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
92
142
  }>;
93
143
 
144
+ export declare const guildRosterFakeLayer: Layer.Layer<GuildRosterPort, never, never>;
145
+
146
+ declare class GuildRosterPort extends GuildRosterPort_base {
147
+ }
148
+
149
+ declare const GuildRosterPort_base: Context.ServiceClass<GuildRosterPort, "@voltro/GuildRosterPort", GuildRosterService>;
150
+
151
+ export declare const guildRosterPortFixture: {
152
+ kind: "port";
153
+ tag: typeof GuildRosterPort;
154
+ fakeLayer: Layer.Layer<GuildRosterPort, never, never>;
155
+ probe: {
156
+ run: () => Effect.Effect<readonly string[] | "expired" | "unavailable" | "conflict" | "identity_required" | "invalid_input" | "forbidden" | "not_found" | "name_taken" | "guild_limit" | "member_limit" | "pending_limit" | "blocked" | "content_rejected" | "export_limit", never, never>;
157
+ expected: string;
158
+ };
159
+ };
160
+
161
+ /** Member identifiers of one guild for a guild leaderboard or roster view; never Guild SQL. Only a member of
162
+ * that guild in its own tenant receives them: unknown, foreign or inaccessible guilds refuse. */
163
+ declare interface GuildRosterService {
164
+ readonly memberIds: (subject: Subject, guildId: string) => Effect.Effect<ReadonlyArray<string>, GuildsError>;
165
+ }
166
+
167
+ declare class GuildsError extends GuildsError_base {
168
+ }
169
+
170
+ declare const GuildsError_base: Schema.Class<GuildsError, Schema.TaggedStruct<"GuildsError", {
171
+ readonly code: Schema.Literals<readonly ["identity_required", "invalid_input", "forbidden", "not_found", "conflict", "name_taken", "guild_limit", "member_limit", "pending_limit", "blocked", "content_rejected", "expired", "unavailable", "export_limit"]>;
172
+ }>, YieldableError>;
173
+
94
174
  declare const PERMISSIONS: {
95
175
  readonly invite: 1;
96
176
  readonly kick: 2;
package/dist/testing.js CHANGED
@@ -1,7 +1,9 @@
1
- import { bitSetGuildPermissions as e, highestActiveGuildSuccessor as t, quadraticGuildLevels as n, resolveGuildOptions as r } from "./strategies.js";
2
- import { Effect as i } from "effect";
1
+ import { GuildMembershipPort as e, GuildPermissionPort as t, GuildRosterPort as n } from "./port.js";
2
+ import { guildsError as r } from "./errors.js";
3
+ import { bitSetGuildPermissions as i, highestActiveGuildSuccessor as a, quadraticGuildLevels as o, resolveGuildOptions as s } from "./strategies.js";
4
+ import { Effect as c, Layer as l, Result as u } from "effect";
3
5
  // src/testing.ts
4
- var a = {
6
+ var d = {
5
7
  role: {
6
8
  id: "role",
7
9
  guildId: "guild",
@@ -11,42 +13,42 @@ var a = {
11
13
  metadata: {}
12
14
  },
13
15
  permission: "kick"
14
- }, o = {
16
+ }, f = {
15
17
  kind: "slot",
16
- defaultImplementation: e,
18
+ defaultImplementation: i,
17
19
  defaultProbe: {
18
- run: () => i.sync(() => e(a)),
20
+ run: () => c.sync(() => i(d)),
19
21
  expected: !1
20
22
  },
21
23
  overrideProbe: {
22
- run: () => i.sync(() => r({ strategies: { permissions: () => !0 } }).strategies.permissions(a)),
24
+ run: () => c.sync(() => s({ strategies: { permissions: () => !0 } }).strategies.permissions(d)),
23
25
  expected: !0
24
26
  }
25
- }, s = {
27
+ }, p = {
26
28
  xp: 1e3,
27
29
  baseMemberCap: 50,
28
30
  maximumMemberCap: 500
29
- }, c = {
31
+ }, m = {
30
32
  kind: "slot",
31
- defaultImplementation: n,
33
+ defaultImplementation: o,
32
34
  defaultProbe: {
33
- run: () => i.sync(() => n(s)),
35
+ run: () => c.sync(() => o(p)),
34
36
  expected: {
35
37
  level: 2,
36
38
  memberCap: 55
37
39
  }
38
40
  },
39
41
  overrideProbe: {
40
- run: () => i.sync(() => r({ strategies: { levelCurve: () => ({
42
+ run: () => c.sync(() => s({ strategies: { levelCurve: () => ({
41
43
  level: 3,
42
44
  memberCap: 60
43
- }) } }).strategies.levelCurve(s)),
45
+ }) } }).strategies.levelCurve(p)),
44
46
  expected: {
45
47
  level: 3,
46
48
  memberCap: 60
47
49
  }
48
50
  }
49
- }, l = {
51
+ }, h = {
50
52
  now: 1e3,
51
53
  inactiveAfterMs: 100,
52
54
  ownerLastActiveAt: 0,
@@ -61,16 +63,49 @@ var a = {
61
63
  lastActiveAt: 999,
62
64
  joinedAt: 0
63
65
  }]
64
- }, u = {
66
+ }, g = {
65
67
  kind: "slot",
66
- defaultImplementation: t,
68
+ defaultImplementation: a,
67
69
  defaultProbe: {
68
- run: () => i.sync(() => t(l)),
70
+ run: () => c.sync(() => a(h)),
69
71
  expected: "a"
70
72
  },
71
73
  overrideProbe: {
72
- run: () => i.sync(() => r({ strategies: { inactivityPolicy: () => null } }).strategies.inactivityPolicy(l)),
74
+ run: () => c.sync(() => s({ strategies: { inactivityPolicy: () => null } }).strategies.inactivityPolicy(h)),
73
75
  expected: null
74
76
  }
75
- };
76
- export { u as guildInactivityFixture, c as guildLevelFixture, o as guildPermissionsFixture };
77
+ }, _ = (e = {}) => ({
78
+ isMember: () => c.fail(r("unavailable")),
79
+ ...e
80
+ }), v = (t = {}) => l.sync(e, () => _(t)), y = v(), b = {
81
+ kind: "port",
82
+ tag: e,
83
+ fakeLayer: y,
84
+ probe: {
85
+ run: () => c.scoped(e.pipe(c.flatMap((e) => e.isMember({
86
+ type: "user",
87
+ id: "one",
88
+ tenantId: "tenant"
89
+ }, "guild")), c.result, c.map((e) => u.isFailure(e) ? e.failure.code : e.success), c.provide(y))),
90
+ expected: "unavailable"
91
+ }
92
+ }, x = (e = {}) => ({
93
+ memberIds: () => c.fail(r("unavailable")),
94
+ ...e
95
+ }), S = (e = {}) => l.sync(n, () => x(e)), C = S(), w = {
96
+ kind: "port",
97
+ tag: n,
98
+ fakeLayer: C,
99
+ probe: {
100
+ run: () => c.scoped(n.pipe(c.flatMap((e) => e.memberIds({
101
+ type: "user",
102
+ id: "one",
103
+ tenantId: "tenant"
104
+ }, "guild")), c.result, c.map((e) => u.isFailure(e) ? e.failure.code : e.success), c.provide(C))),
105
+ expected: "unavailable"
106
+ }
107
+ }, T = (e = {}) => ({
108
+ may: () => c.fail(r("unavailable")),
109
+ ...e
110
+ }), E = (e = {}) => l.sync(t, () => T(e));
111
+ export { v as fakeGuildMembershipLayer, _ as fakeGuildMembershipService, E as fakeGuildPermissionLayer, T as fakeGuildPermissionService, S as fakeGuildRosterLayer, x as fakeGuildRosterService, g as guildInactivityFixture, m as guildLevelFixture, y as guildMembershipFakeLayer, b as guildMembershipPortFixture, f as guildPermissionsFixture, C as guildRosterFakeLayer, w as guildRosterPortFixture };
@@ -0,0 +1,5 @@
1
+ import { GuildsError as e, guildsError as t } from "./errors.js";
2
+ import { logUnavailableCause as n } from "@voltro/database";
3
+ // src/unavailable.server.ts
4
+ var r = (r) => (r instanceof e || n("@voltro/plugin-guilds", r), t("unavailable"));
5
+ export { r as guildsUnavailable };
package/dist/web.d.ts CHANGED
@@ -162,6 +162,8 @@ declare const GuildMemberSchema: Schema.Struct<{
162
162
  readonly metadata: Schema.$Record<Schema.String, Schema.Unknown>;
163
163
  }>;
164
164
 
165
+ export declare type GuildPermission = keyof typeof PERMISSIONS;
166
+
165
167
  declare type GuildRole = typeof GuildRoleSchema.Type;
166
168
 
167
169
  declare const GuildRoleSchema: Schema.Struct<{
@@ -211,6 +213,16 @@ declare const GuildSummarySchema: Schema.Struct<{
211
213
  readonly version: Schema.Number;
212
214
  }>;
213
215
 
216
+ export declare const PERMISSIONS: {
217
+ readonly invite: 1;
218
+ readonly kick: 2;
219
+ readonly promote: 4;
220
+ readonly treasury: 8;
221
+ readonly announce: 16;
222
+ readonly startEvent: 32;
223
+ readonly editProfile: 64;
224
+ };
225
+
214
226
  export declare const useGuild: (guildId: string, apiName?: string) => SubscriptionState<{
215
227
  readonly id: string;
216
228
  readonly name: string;
package/dist/web.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { BASE_NAME as e } from "./rpc.js";
2
2
  import { GuildBrowser as t, GuildCard as n, GuildCreateDialog as r, GuildLog as i, GuildMemberList as a, guildLabels as o } from "./components.js";
3
- import { pluginTag as s } from "@voltro/protocol";
4
- import { useAction as c, useSubscription as l } from "@voltro/client";
3
+ import { PERMISSIONS as s } from "./contract.js";
4
+ import { pluginTag as c } from "@voltro/protocol";
5
+ import { useAction as l, useSubscription as u } from "@voltro/client";
5
6
  // src/web.ts
6
- var u = (t, n = "app") => l(n, s(e, "get"), { guildId: t }), d = (t = "app") => l(t, s(e, "mine"), {}), f = (t, n = "app") => l(n, s(e, "members"), { guildId: t }), p = (t, n = "app") => l(n, s(e, "roles"), { guildId: t }), m = (t = {}, n = "app") => l(n, s(e, "search"), t), h = (t, n = "app") => l(n, s(e, "applications"), { guildId: t }), g = (t = "app") => l(t, s(e, "invites"), {}), _ = (t, n = "app") => l(n, s(e, "announcements"), { guildId: t }), v = (t, n = "app") => l(n, s(e, "log"), { guildId: t }), y = (t = "app") => c(t, s(e, "create")), b = (t = "app") => c(t, s(e, "join")), x = (t = "app") => c(t, s(e, "leave"));
7
- export { t as GuildBrowser, n as GuildCard, r as GuildCreateDialog, i as GuildLog, a as GuildMemberList, o as guildLabels, u as useGuild, _ as useGuildAnnouncements, h as useGuildApplications, y as useGuildCreate, g as useGuildInvites, b as useGuildJoin, x as useGuildLeave, d as useGuildList, v as useGuildLog, f as useGuildMembers, p as useGuildRoles, m as useGuildSearch };
7
+ var d = (t, n = "app") => u(n, c(e, "get"), { guildId: t }), f = (t = "app") => u(t, c(e, "mine"), {}), p = (t, n = "app") => u(n, c(e, "members"), { guildId: t }), m = (t, n = "app") => u(n, c(e, "roles"), { guildId: t }), h = (t = {}, n = "app") => u(n, c(e, "search"), t), g = (t, n = "app") => u(n, c(e, "applications"), { guildId: t }), _ = (t = "app") => u(t, c(e, "invites"), {}), v = (t, n = "app") => u(n, c(e, "announcements"), { guildId: t }), y = (t, n = "app") => u(n, c(e, "log"), { guildId: t }), b = (t = "app") => l(t, c(e, "create")), x = (t = "app") => l(t, c(e, "join")), S = (t = "app") => l(t, c(e, "leave"));
8
+ export { t as GuildBrowser, n as GuildCard, r as GuildCreateDialog, i as GuildLog, a as GuildMemberList, s as PERMISSIONS, o as guildLabels, d as useGuild, v as useGuildAnnouncements, g as useGuildApplications, b as useGuildCreate, _ as useGuildInvites, x as useGuildJoin, S as useGuildLeave, f as useGuildList, y as useGuildLog, p as useGuildMembers, m as useGuildRoles, h as useGuildSearch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-guilds",
3
- "version": "0.89.2",
3
+ "version": "0.91.0",
4
4
  "description": "SQL-authoritative guilds, scoped roles, membership admission and privacy with replaceable rules",
5
5
  "keywords": [
6
6
  "voltro",
@@ -73,17 +73,17 @@
73
73
  "node": ">=24.0.0"
74
74
  },
75
75
  "dependencies": {
76
- "@voltro/protocol": "0.89.2",
77
- "@voltro/database": "0.89.2",
78
- "@voltro/client": "0.89.2",
79
- "@voltro/runtime": "0.89.2",
80
- "@voltro/plugin-moderation": "0.89.2",
81
- "@voltro/plugin-social": "0.89.2",
82
- "@voltro/ui-shadcn": "0.89.2",
83
- "@voltro/plugin-licensing": "0.89.2"
76
+ "@voltro/protocol": "0.91.0",
77
+ "@voltro/database": "0.91.0",
78
+ "@voltro/client": "0.91.0",
79
+ "@voltro/runtime": "0.91.0",
80
+ "@voltro/plugin-moderation": "0.91.0",
81
+ "@voltro/plugin-social": "0.91.0",
82
+ "@voltro/ui-shadcn": "0.91.0",
83
+ "@voltro/plugin-licensing": "0.91.0"
84
84
  },
85
85
  "peerDependencies": {
86
- "effect": "4.1.2",
86
+ "effect": "4.1.4",
87
87
  "react": "^19.0.0"
88
88
  },
89
89
  "publishConfig": {