@voltro/plugin-guilds 0.89.1 → 0.90.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 +1835 -0
- package/README.md +16 -156
- package/dist/index.d.ts +68 -2
- package/dist/index.js +143 -83
- package/dist/inspect.js +25 -24
- package/dist/port.d.ts +37 -0
- package/dist/port.js +4 -3
- package/dist/rpc.js +68 -68
- package/dist/service.js +514 -457
- package/dist/strategies.js +21 -21
- package/dist/testing.d.ts +80 -0
- package/dist/testing.js +55 -20
- package/dist/unavailable.server.js +5 -0
- package/dist/web.d.ts +12 -0
- package/dist/web.js +7 -6
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,166 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## Take
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
import { guildsPlugin } from '@voltro/plugin-guilds'
|
|
7
|
-
|
|
8
|
-
const plugin = guildsPlugin()
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Eight SQL tables own guilds, members, roles, applications, invites, chronicle,
|
|
12
|
-
announcements and subject admission. Twenty-two typed RPCs and twelve web hooks
|
|
13
|
-
are authored. The server receives human intentions and trusted request identity;
|
|
14
|
-
anonymous/machine self calls refuse. Guest and registered users share stable IDs.
|
|
15
|
-
Guild-role bits are guild data; they never grant app/tenant RBAC permissions.
|
|
16
|
-
|
|
17
|
-
`guilds.create` takes a request ID, name, 3–5 ASCII alphanumeric tag, description,
|
|
18
|
-
membership policy, region and language. Deterministic sender/request IDs preserve
|
|
19
|
-
the exact creation claim. Name NFKC/space/case normalization and uppercase tags
|
|
20
|
-
use tenant-hashed unique SQL claims. This is no confusable-name proof. Name/tag
|
|
21
|
-
moderation composes the existing keyword provider; an empty denylist is no
|
|
22
|
-
classification coverage. This foundation creates guilds without currency charges.
|
|
23
|
-
Economy-backed optional creation cost and emblem Storage lifecycle remain open.
|
|
24
|
-
|
|
25
|
-
`guilds.mine`, `get`, `search`, `members`, `roles` read scoped state. Search is a
|
|
26
|
-
bounded exact name/tag or region/language query, not fuzzy search. Detailed member
|
|
27
|
-
and history reads require actual guild membership. Inputs never supply owner,
|
|
28
|
-
tenant, XP, membership rows or arbitrary metadata state.
|
|
29
|
-
|
|
30
|
-
Search projects a separate GuildSummary without owner identity, private metadata or creation claims; members-only get keeps the full scoped projection.
|
|
31
|
-
|
|
32
|
-
## Configure
|
|
33
|
-
|
|
34
|
-
| Option | Default | Meaning |
|
|
35
|
-
|---|---|---|
|
|
36
|
-
| `baseMemberCap` | 50 | Initial guild member budget |
|
|
37
|
-
| `maximumMemberCap` | 500 | Level-curve member ceiling |
|
|
38
|
-
| `maxGuildsPerSubject` | 1 | SQL-serialized guild admission budget |
|
|
39
|
-
| `maxRoles` | 20 | Configured role count budget |
|
|
40
|
-
| `maxPending` | 100 | Pending application/invite budget per guild |
|
|
41
|
-
| `inviteTtlMs` | 7 days | Invitation acceptance lifetime |
|
|
42
|
-
| `inactiveAfterMs` | 30 days | Successor proposal threshold |
|
|
43
|
-
| `pageSize` | 50 | Bounded search/chronicle/announcement page |
|
|
44
|
-
| `maxExportRows` | 10,000 | Complete export/operation scan ceiling |
|
|
45
|
-
| `maxDescriptionLength` | 2,000 code points | Description/application budget |
|
|
46
|
-
| `maxAnnouncementLength` | 4,000 code points | Announcement body budget |
|
|
47
|
-
| `denyWords` | empty | Explicit existing keyword-provider policy |
|
|
48
|
-
| `strategies` | three defaults | Permission, level and inactivity rules |
|
|
49
|
-
| `now` | `Date.now` | Trusted rule/observation clock |
|
|
50
|
-
|
|
51
|
-
These are budgets, not measured capacity. Subject admission rows are inserted
|
|
52
|
-
outside transactions, then locked in deterministic hash order before the guild
|
|
53
|
-
writer row. Guild/member counts and role state are read after writer admission.
|
|
54
|
-
SQL owns cross-pool limits; there is no in-memory mutex or second hot truth.
|
|
55
|
-
This conservative serialization has not been measured under load.
|
|
56
|
-
|
|
57
|
-
## Hook
|
|
1
|
+
<div align="center">
|
|
58
2
|
|
|
59
|
-
|
|
60
|
-
open/application/invite admission. Invites expire and re-check the inviter's
|
|
61
|
-
current membership/permission before acceptance. `SocialBlockPort` controls
|
|
62
|
-
invite admission and blocks at acceptance when installed; a replacement Layer is
|
|
63
|
-
used, never Social tables. Cross-system block-race admission is not yet proven.
|
|
64
|
-
|
|
65
|
-
`kick`, `setRole`, `configureRole` enforce permission bits, strict rank order,
|
|
66
|
-
no peer/owner kick, no self-promotion and no second owner via normal role changes.
|
|
67
|
-
Only the committed owner transfers ownership through `transferOwner`. An owner's
|
|
68
|
-
departure chooses a remaining member by rank/join date/ID; the last departure
|
|
69
|
-
dissolves the guild and frees name/tag claims. `updateProfile` requires version
|
|
70
|
-
CAS; `announce` is moderated, permission-checked and request-idempotent.
|
|
71
|
-
|
|
72
|
-
`guilds.changed` is a discovered operator metadata event (`guilds:events:read`):
|
|
73
|
-
guild routing key plus log ID/kind, no body or personal detail. Committed SQL log
|
|
74
|
-
rows select the tenant; the normal once change claimer is used. CDC is best-effort,
|
|
75
|
-
not durable notification delivery. Player state comes through guarded Live Queries.
|
|
76
|
-
Named business events, Notifications and end-to-end discovery remain open.
|
|
77
|
-
|
|
78
|
-
`dataStoreGuilds(...).recordContribution` accepts only internal System or same-
|
|
79
|
-
tenant service account with `guilds:contributions:write`; stable request IDs
|
|
80
|
-
apply trusted XP once in a SQL transaction. It updates guild XP/level/member cap
|
|
81
|
-
and the real member contribution. Clients cannot award themselves XP. This is
|
|
82
|
-
not an economy wallet, war rule or periodic leaderboard aggregation.
|
|
83
|
-
|
|
84
|
-
## Override
|
|
85
|
-
|
|
86
|
-
`./strategies` exports one default per slot: `bitSetGuildPermissions`,
|
|
87
|
-
`quadraticGuildLevels`, `highestActiveGuildSuccessor`. Permissions evaluate actual
|
|
88
|
-
guild role bits; owner/rank safety boundaries remain server invariants. The
|
|
89
|
-
level curve maps trusted XP to a validated level/member cap. Inactivity proposes
|
|
90
|
-
the highest active rank; it never transfers ownership automatically.
|
|
91
|
-
|
|
92
|
-
`inactivityProposal` requires System or a same-tenant service account with
|
|
93
|
-
`guilds:inactivity:read`. Custom proposals must name an existing candidate.
|
|
94
|
-
Activity currently comes from creation/join and trusted contribution; Presence-
|
|
95
|
-
driven activity, scheduled ownership offer and acknowledgement remain open.
|
|
96
|
-
|
|
97
|
-
## Extend or replace
|
|
98
|
-
|
|
99
|
-
Guilds is currently a leaf with three strategies and events, no dependency port.
|
|
100
|
-
Other dependency integrations use their own ports. Exported table handles and
|
|
101
|
-
JSON metadata carry small extensions; export preserves actual contributed row
|
|
102
|
-
columns. Arbitrary mixin fields are not yet propagated by static wire schemas/UI.
|
|
103
|
-
Complete S4a, namespace composition and system removal remain open.
|
|
104
|
-
|
|
105
|
-
Treasury requires the Economy guild wallet. Guild chat/membership revocation,
|
|
106
|
-
Presence, leaderboards, min-level admission, emblem lifecycle, weekly events/
|
|
107
|
-
workflow and currency-backed creation are not yet integrated. No store I/O belongs
|
|
108
|
-
in a Room tick. Rooms may submit trusted contributions outside ticks.
|
|
109
|
-
|
|
110
|
-
## Panel and GM
|
|
3
|
+
# @voltro/plugin-guilds
|
|
111
4
|
|
|
112
|
-
|
|
113
|
-
Cloud authorized-app/replica proxy are authored together. Strict decoders show
|
|
114
|
-
dated configuration, rule-slot selection and current binding; no guild/member
|
|
115
|
-
data, health or measured capacity is disclosed. Full guild list/treasury/log,
|
|
116
|
-
rename/transfer/dissolve/emblem-removal GM actions and metrics remain open.
|
|
5
|
+
**SQL-authoritative guilds, scoped roles, membership admission and privacy with replaceable rules**
|
|
117
6
|
|
|
118
|
-
|
|
119
|
-
`useGuildSearch`, `useGuildApplications`, `useGuildInvites`,
|
|
120
|
-
`useGuildAnnouncements`, `useGuildLog`, `useGuildCreate`, `useGuildJoin`,
|
|
121
|
-
`useGuildLeave`. Components are `GuildCard`, `GuildBrowser`, `GuildMemberList`,
|
|
122
|
-
`GuildCreateDialog`, `GuildLog`. They reuse ui-shadcn, en/de labels, escaped
|
|
123
|
-
text and explicit unknown identity. Parents provide trusted Players projections
|
|
124
|
-
and scoped data, permission projections, draft/request ID/pending state across
|
|
125
|
-
dialog close. Browser and creation use credential/tenant `scopeKey` and matching
|
|
126
|
-
`dataScopeKey`; old data/actions are hidden/refused. Mutation callbacks carry
|
|
127
|
-
target IDs/intent only; controls are not authorization. No automatic retry or
|
|
128
|
-
success clearing.
|
|
7
|
+
[📖 Documentation](https://docs.voltro.dev/docs/plugins/guilds) · [voltro.dev](https://voltro.dev) · [Voltro Cloud](https://voltro.cloud)
|
|
129
8
|
|
|
130
|
-
|
|
9
|
+
</div>
|
|
131
10
|
|
|
132
|
-
|
|
133
|
-
name/tag uniqueness, membership caps, roles/rank matrix, revoked invitations,
|
|
134
|
-
Social port replacement, moderation, profile CAS, trusted contribution receipts,
|
|
135
|
-
ownership erase, peer preservation and refused re-creation. Three slot fixtures
|
|
136
|
-
and `systemContractConformance` cover actual factory stages, events, metadata,
|
|
137
|
-
all eight tables' user/guest privacy and inspection. Native PostgreSQL/MySQL/
|
|
138
|
-
MariaDB/MSSQL/SQLite/Turso cases cover all tables, Unicode/JSON/date fields,
|
|
139
|
-
two-pool member/subject admission, version races and privacy/successor readback.
|
|
140
|
-
Missing native connection fields fail rather than silently skipping acceptance.
|
|
141
|
-
DOM/panel/provider contracts are written. None ran.
|
|
11
|
+
---
|
|
142
12
|
|
|
143
|
-
|
|
13
|
+
```sh
|
|
14
|
+
npm install @voltro/plugin-guilds
|
|
15
|
+
```
|
|
144
16
|
|
|
145
|
-
|
|
146
|
-
provides it through its service Layer, so other plugins and app code ask
|
|
147
|
-
`isMember(subject, guildId)` instead of reading Guild SQL. It answers `true`
|
|
148
|
-
only while the subject currently belongs to the guild in its own tenant;
|
|
149
|
-
strangers, other tenants, unknown guilds and anonymous callers get `false`, not
|
|
150
|
-
an error. It is the building block for guild chat, guild parties and guild
|
|
151
|
-
leaderboards; those bridges are not wired yet.
|
|
17
|
+
> ### [→ Read the documentation for @voltro/plugin-guilds](https://docs.voltro.dev/docs/plugins/guilds)
|
|
152
18
|
|
|
153
|
-
|
|
19
|
+
Installation, guides, the full API reference, and examples all live in the
|
|
20
|
+
**[Voltro documentation](https://docs.voltro.dev/docs/intro/getting-started)** — the single source of truth. This README is
|
|
21
|
+
deliberately short so there is nothing here to drift out of date.
|
|
154
22
|
|
|
155
|
-
|
|
156
|
-
serializes the subject, locks affected guilds, removes membership, transfers
|
|
157
|
-
ownership or dissolves a solo guild, scrubs former-owned content/role metadata,
|
|
158
|
-
applications/invites, authored announcements and personal chronicle references.
|
|
159
|
-
Peer membership/history and other tenants survive. A redacted deterministic SQL
|
|
160
|
-
admission tombstone retains no subject ID and refuses re-created membership
|
|
161
|
-
under the erased subject, including retries. There is no reactivation/unlock API
|
|
162
|
-
yet.
|
|
23
|
+
## License
|
|
163
24
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
Licensing contract and manual update migration.
|
|
25
|
+
Proprietary. © 2026 Voltro UG. Your use is governed by the
|
|
26
|
+
[Terms of Service](https://voltro.cloud/legal/terms). See the bundled `LICENSE`.
|
package/dist/index.d.ts
CHANGED
|
@@ -92,6 +92,17 @@ export declare const dataStoreGuilds: (store: DataStore, options: ResolvedGuildO
|
|
|
92
92
|
readonly guildId: string;
|
|
93
93
|
}) => Effect.Effect<string | null, GuildsError, never>;
|
|
94
94
|
exportSubject: (target: PluginPrivacyTarget) => Effect.Effect<unknown, GuildsError, never>;
|
|
95
|
+
/** Account merge inside the coordinator's transaction. The guest's memberships become the
|
|
96
|
+
* target's (a guild both are in keeps the target's row; a guild the guest owned passes to the
|
|
97
|
+
* target), within the target's guild limit. Its open applications and invites go; history
|
|
98
|
+
* (log, announcements, decided applications) names the target. The guest's admission row stays
|
|
99
|
+
* as an erased fence. */
|
|
100
|
+
mergeSubject: (context: {
|
|
101
|
+
readonly store: DataStore;
|
|
102
|
+
readonly tenantId: string;
|
|
103
|
+
readonly sourceId: string;
|
|
104
|
+
readonly targetId: string;
|
|
105
|
+
}) => Effect.Effect<void, GuildsError, never>;
|
|
95
106
|
eraseSubject: (target: PluginPrivacyTarget) => Effect.Effect<void, GuildsError, never>;
|
|
96
107
|
};
|
|
97
108
|
|
|
@@ -106,6 +117,9 @@ export declare const defaultGuildStrategies: Readonly<{
|
|
|
106
117
|
|
|
107
118
|
export declare type Guild = typeof GuildSchema.Type;
|
|
108
119
|
|
|
120
|
+
/** The SQL role whose changes alter a guild roster; a dependent live query declares it as a source. */
|
|
121
|
+
export declare const GUILD_MEMBERS_TABLE = "_voltro_guild_members";
|
|
122
|
+
|
|
109
123
|
/** Stable per-subject SQL row serializes guild-cap admission across independent pools. */
|
|
110
124
|
export declare const guildAdmissionsTable: Table<"_voltro_guild_admissions", FieldDefinitions<{
|
|
111
125
|
readonly id: ColumnBuilder<string, "id", boolean>;
|
|
@@ -287,6 +301,17 @@ export declare interface GuildOptions {
|
|
|
287
301
|
|
|
288
302
|
export declare type GuildPermission = keyof typeof PERMISSIONS;
|
|
289
303
|
|
|
304
|
+
export declare class GuildPermissionPort extends GuildPermissionPort_base {
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare const GuildPermissionPort_base: Context.ServiceClass<GuildPermissionPort, "@voltro/GuildPermissionPort", GuildPermissionService>;
|
|
308
|
+
|
|
309
|
+
/** Whether a member's role grants a permission in their guild (e.g. `treasury` for a guild wallet), for
|
|
310
|
+
* other systems acting for that member; never Guild SQL. Non-members, unknown or foreign guilds answer false. */
|
|
311
|
+
export declare interface GuildPermissionService {
|
|
312
|
+
readonly may: (subject: Subject, guildId: string, permission: GuildPermission) => Effect.Effect<boolean, GuildsError>;
|
|
313
|
+
}
|
|
314
|
+
|
|
290
315
|
export declare interface GuildPermissionsInput {
|
|
291
316
|
readonly role: GuildRole;
|
|
292
317
|
readonly permission: GuildPermission;
|
|
@@ -321,6 +346,17 @@ export declare const guildRolesTable: Table<"_voltro_guild_roles", FieldDefiniti
|
|
|
321
346
|
readonly metadata: ColumnBuilder<unknown, "json", boolean>;
|
|
322
347
|
}>, true, never>;
|
|
323
348
|
|
|
349
|
+
export declare class GuildRosterPort extends GuildRosterPort_base {
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
declare const GuildRosterPort_base: Context.ServiceClass<GuildRosterPort, "@voltro/GuildRosterPort", GuildRosterService>;
|
|
353
|
+
|
|
354
|
+
/** Member identifiers of one guild for a guild leaderboard or roster view; never Guild SQL. Only a member of
|
|
355
|
+
* that guild in its own tenant receives them: unknown, foreign or inaccessible guilds refuse. */
|
|
356
|
+
export declare interface GuildRosterService {
|
|
357
|
+
readonly memberIds: (subject: Subject, guildId: string) => Effect.Effect<ReadonlyArray<string>, GuildsError>;
|
|
358
|
+
}
|
|
359
|
+
|
|
324
360
|
declare const GUILDS_TABLE = "_voltro_guilds";
|
|
325
361
|
|
|
326
362
|
declare const GuildSchema: Schema.Struct<{
|
|
@@ -405,7 +441,26 @@ export declare interface GuildService {
|
|
|
405
441
|
readonly log: (subject: Subject, guildId: string) => Effect.Effect<ReadonlyArray<C.GuildLogEntry>, GuildsError>;
|
|
406
442
|
}
|
|
407
443
|
|
|
408
|
-
|
|
444
|
+
/** Server-only guild operations for trusted callers (never routes). */
|
|
445
|
+
export declare interface GuildsOperatorService {
|
|
446
|
+
/** Credits trusted XP (e.g. a won match) to every guild `subjectId` belongs to in `tenantId`, once per
|
|
447
|
+
* request ID and guild; a player without a guild credits none. Needs System or a same-tenant service
|
|
448
|
+
* account with `guilds:contributions:write`. Returns the guild IDs credited. */
|
|
449
|
+
readonly recordForMember: (subject: Subject, input: {
|
|
450
|
+
readonly tenantId: string;
|
|
451
|
+
readonly subjectId: string;
|
|
452
|
+
readonly requestId: string;
|
|
453
|
+
readonly xp: number;
|
|
454
|
+
}) => Effect.Effect<ReadonlyArray<string>, GuildsError>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export declare interface GuildsPlugin extends VoltroPlugin {
|
|
458
|
+
readonly guilds: {
|
|
459
|
+
readonly operator: () => GuildsOperatorService;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export declare const guildsPlugin: (input?: GuildOptions) => GuildsPlugin;
|
|
409
464
|
|
|
410
465
|
export declare const guildsTable: Table<"_voltro_guilds", FieldDefinitions<{
|
|
411
466
|
readonly id: ColumnBuilder<string, "id", boolean>;
|
|
@@ -466,7 +521,18 @@ export declare const guildSystemContract: {
|
|
|
466
521
|
readonly fixtureExport: "guildInactivityFixture";
|
|
467
522
|
};
|
|
468
523
|
};
|
|
469
|
-
readonly ports: {
|
|
524
|
+
readonly ports: {
|
|
525
|
+
readonly guildMembership: {
|
|
526
|
+
readonly tagExport: "GuildMembershipPort";
|
|
527
|
+
readonly fakeLayerExport: "guildMembershipFakeLayer";
|
|
528
|
+
readonly fixtureExport: "guildMembershipPortFixture";
|
|
529
|
+
};
|
|
530
|
+
readonly guildRoster: {
|
|
531
|
+
readonly tagExport: "GuildRosterPort";
|
|
532
|
+
readonly fakeLayerExport: "guildRosterFakeLayer";
|
|
533
|
+
readonly fixtureExport: "guildRosterPortFixture";
|
|
534
|
+
};
|
|
535
|
+
};
|
|
470
536
|
readonly events: readonly ["guilds.changed"];
|
|
471
537
|
};
|
|
472
538
|
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { GuildsError as e, guildsError as t } from "./errors.js";
|
|
2
|
+
import { guildAdmissionsTable as n, guildAnnouncementsTable as r, guildApplicationsTable as i, guildInvitesTable as a, guildLogTable as o, guildMembersTable as s, guildRolesTable as c, guildTables as l, guildsTable as u } from "./entities.js";
|
|
3
3
|
import { dataStoreGuilds as d } from "./service.js";
|
|
4
4
|
import { defaultGuildStrategies as f, resolveGuildOptions as p } from "./strategies.js";
|
|
5
5
|
import { BASE_NAME as m, guildRpcClientImports as h } from "./rpc.js";
|
|
6
6
|
import { guildRpcRoutes as g } from "./rpcRoutes.js";
|
|
7
7
|
import { guildStatus as _ } from "./inspect.js";
|
|
8
8
|
import { guildChanged as v } from "./events.js";
|
|
9
|
-
import {
|
|
10
|
-
import { defineLicensedGamePlugin as
|
|
11
|
-
import { fileURLToPath as
|
|
12
|
-
import { Effect as
|
|
9
|
+
import { GUILD_MEMBERS_TABLE as y, GuildMembershipPort as b, GuildPermissionPort as x, GuildRosterPort as S } from "./port.js";
|
|
10
|
+
import { defineLicensedGamePlugin as C } from "@voltro/plugin-licensing/gate";
|
|
11
|
+
import { fileURLToPath as w } from "node:url";
|
|
12
|
+
import { Effect as T, Layer as E } from "effect";
|
|
13
13
|
// src/index.ts
|
|
14
|
-
var
|
|
14
|
+
var D = {
|
|
15
15
|
slots: {
|
|
16
16
|
permissions: {
|
|
17
17
|
defaultExport: "bitSetGuildPermissions",
|
|
@@ -26,83 +26,143 @@ var w = {
|
|
|
26
26
|
fixtureExport: "guildInactivityFixture"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
ports: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
mine: (e) => i((t) => t.service.mine(e)),
|
|
35
|
-
get: (e, t) => i((n) => n.service.get(e, t)),
|
|
36
|
-
search: (e, t) => i((n) => n.service.search(e, t)),
|
|
37
|
-
members: (e, t) => i((n) => n.service.members(e, t)),
|
|
38
|
-
roles: (e, t) => i((n) => n.service.roles(e, t)),
|
|
39
|
-
join: (e, t) => i((n) => n.service.join(e, t)),
|
|
40
|
-
leave: (e, t) => i((n) => n.service.leave(e, t)),
|
|
41
|
-
apply: (e, t) => i((n) => n.service.apply(e, t)),
|
|
42
|
-
applications: (e, t) => i((n) => n.service.applications(e, t)),
|
|
43
|
-
decideApplication: (e, t) => i((n) => n.service.decideApplication(e, t)),
|
|
44
|
-
invite: (e, t) => i((n) => n.service.invite(e, t)),
|
|
45
|
-
invites: (e) => i((t) => t.service.invites(e)),
|
|
46
|
-
decideInvite: (e, t) => i((n) => n.service.decideInvite(e, t)),
|
|
47
|
-
kick: (e, t, n) => i((r) => r.service.kick(e, t, n)),
|
|
48
|
-
setRole: (e, t, n, r) => i((i) => i.service.setRole(e, t, n, r)),
|
|
49
|
-
configureRole: (e, t) => i((n) => n.service.configureRole(e, t)),
|
|
50
|
-
transferOwner: (e, t, n) => i((r) => r.service.transferOwner(e, t, n)),
|
|
51
|
-
updateProfile: (e, t) => i((n) => n.service.updateProfile(e, t)),
|
|
52
|
-
announce: (e, t) => i((n) => n.service.announce(e, t)),
|
|
53
|
-
announcements: (e, t) => i((n) => n.service.announcements(e, t)),
|
|
54
|
-
log: (e, t) => i((n) => n.service.log(e, t))
|
|
55
|
-
};
|
|
56
|
-
return b({
|
|
57
|
-
name: m,
|
|
58
|
-
description: "SQL-authoritative guilds, scoped roles and admission with replaceable rule slots.",
|
|
59
|
-
permissions: ["store:write", "inspect:read"],
|
|
60
|
-
services: C.succeed(y, { isMember: (e, t) => a.members(e, t).pipe(S.map((t) => e.type === "user" && t.some((t) => t.subjectId === e.id)), S.catchIf((e) => e.code === "forbidden" || e.code === "not_found" || e.code === "identity_required", () => S.succeed(!1))) }),
|
|
61
|
-
routes: g(a),
|
|
62
|
-
rpcClientDescriptors: h,
|
|
63
|
-
errorSchemas: [{
|
|
64
|
-
schema: l,
|
|
65
|
-
import: {
|
|
66
|
-
module: "@voltro/plugin-guilds/errors",
|
|
67
|
-
name: "GuildsError"
|
|
68
|
-
}
|
|
69
|
-
}],
|
|
70
|
-
sources: x(new URL("./guild-app", "" + import.meta.url)),
|
|
71
|
-
extendSchema: { tables: s },
|
|
72
|
-
subjectPrivacy: {
|
|
73
|
-
tables: s.map((e) => e.tableName),
|
|
74
|
-
kinds: ["user", "guest"]
|
|
29
|
+
ports: {
|
|
30
|
+
guildMembership: {
|
|
31
|
+
tagExport: "GuildMembershipPort",
|
|
32
|
+
fakeLayerExport: "guildMembershipFakeLayer",
|
|
33
|
+
fixtureExport: "guildMembershipPortFixture"
|
|
75
34
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
35
|
+
guildRoster: {
|
|
36
|
+
tagExport: "GuildRosterPort",
|
|
37
|
+
fakeLayerExport: "guildRosterFakeLayer",
|
|
38
|
+
fixtureExport: "guildRosterPortFixture"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
events: [v.name]
|
|
42
|
+
}, O = (n = {}) => {
|
|
43
|
+
let r = p(n), i, a, o = (e) => {
|
|
44
|
+
let n = a;
|
|
45
|
+
return T.suspend(() => n === void 0 || n !== a ? T.fail(t("unavailable")) : e(n).pipe(T.flatMap((e) => n === a ? T.succeed(e) : T.fail(t("unavailable")))));
|
|
46
|
+
}, s = {
|
|
47
|
+
create: (e, t) => o((n) => n.service.create(e, t)),
|
|
48
|
+
mine: (e) => o((t) => t.service.mine(e)),
|
|
49
|
+
get: (e, t) => o((n) => n.service.get(e, t)),
|
|
50
|
+
search: (e, t) => o((n) => n.service.search(e, t)),
|
|
51
|
+
members: (e, t) => o((n) => n.service.members(e, t)),
|
|
52
|
+
roles: (e, t) => o((n) => n.service.roles(e, t)),
|
|
53
|
+
join: (e, t) => o((n) => n.service.join(e, t)),
|
|
54
|
+
leave: (e, t) => o((n) => n.service.leave(e, t)),
|
|
55
|
+
apply: (e, t) => o((n) => n.service.apply(e, t)),
|
|
56
|
+
applications: (e, t) => o((n) => n.service.applications(e, t)),
|
|
57
|
+
decideApplication: (e, t) => o((n) => n.service.decideApplication(e, t)),
|
|
58
|
+
invite: (e, t) => o((n) => n.service.invite(e, t)),
|
|
59
|
+
invites: (e) => o((t) => t.service.invites(e)),
|
|
60
|
+
decideInvite: (e, t) => o((n) => n.service.decideInvite(e, t)),
|
|
61
|
+
kick: (e, t, n) => o((r) => r.service.kick(e, t, n)),
|
|
62
|
+
setRole: (e, t, n, r) => o((i) => i.service.setRole(e, t, n, r)),
|
|
63
|
+
configureRole: (e, t) => o((n) => n.service.configureRole(e, t)),
|
|
64
|
+
transferOwner: (e, t, n) => o((r) => r.service.transferOwner(e, t, n)),
|
|
65
|
+
updateProfile: (e, t) => o((n) => n.service.updateProfile(e, t)),
|
|
66
|
+
announce: (e, t) => o((n) => n.service.announce(e, t)),
|
|
67
|
+
announcements: (e, t) => o((n) => n.service.announcements(e, t)),
|
|
68
|
+
log: (e, t) => o((n) => n.service.log(e, t))
|
|
69
|
+
}, c = { isMember: (e, t) => s.members(e, t).pipe(T.map((t) => e.type === "user" && t.some((t) => t.subjectId === e.id)), T.catchIf((e) => e.code === "forbidden" || e.code === "not_found" || e.code === "identity_required", () => T.succeed(!1))) }, u = { may: (e, t, n) => T.gen(function* () {
|
|
70
|
+
if (e.type !== "user") return !1;
|
|
71
|
+
let i = (yield* s.members(e, t)).find((t) => t.subjectId === e.id);
|
|
72
|
+
if (i === void 0) return !1;
|
|
73
|
+
let a = (yield* s.roles(e, t)).find((e) => e.id === i.roleId);
|
|
74
|
+
return a !== void 0 && r.strategies.permissions({
|
|
75
|
+
role: a,
|
|
76
|
+
permission: n
|
|
77
|
+
}) === !0;
|
|
78
|
+
}).pipe(T.catchIf((e) => e.code === "forbidden" || e.code === "not_found" || e.code === "identity_required", () => T.succeed(!1))) }, f = { memberIds: (e, n) => {
|
|
79
|
+
let r;
|
|
80
|
+
try {
|
|
81
|
+
r = structuredClone(e);
|
|
82
|
+
} catch {
|
|
83
|
+
return T.fail(t("unavailable"));
|
|
84
|
+
}
|
|
85
|
+
return s.members(r, n).pipe(T.map((e) => Object.freeze(e.map((e) => e.subjectId))));
|
|
86
|
+
} }, v = { recordForMember: (e, n) => T.gen(function* () {
|
|
87
|
+
let r;
|
|
88
|
+
try {
|
|
89
|
+
r = structuredClone(n);
|
|
90
|
+
} catch {
|
|
91
|
+
return yield* T.fail(t("invalid_input"));
|
|
92
|
+
}
|
|
93
|
+
if (typeof r?.tenantId != "string" || typeof r.subjectId != "string") return yield* T.fail(t("invalid_input"));
|
|
94
|
+
let i = yield* s.mine({
|
|
95
|
+
type: "user",
|
|
96
|
+
id: r.subjectId,
|
|
97
|
+
tenantId: r.tenantId
|
|
98
|
+
});
|
|
99
|
+
for (let t of i) yield* o((n) => n.recordContribution(e, {
|
|
100
|
+
tenantId: r.tenantId,
|
|
101
|
+
guildId: t.id,
|
|
102
|
+
subjectId: r.subjectId,
|
|
103
|
+
requestId: r.requestId,
|
|
104
|
+
xp: r.xp
|
|
105
|
+
}));
|
|
106
|
+
return Object.freeze(i.map((e) => e.id));
|
|
107
|
+
}) };
|
|
108
|
+
return {
|
|
109
|
+
guilds: Object.freeze({ operator: () => v }),
|
|
110
|
+
...C({
|
|
111
|
+
name: m,
|
|
112
|
+
description: "SQL-authoritative guilds, scoped roles and admission with replaceable rule slots.",
|
|
113
|
+
permissions: ["store:write", "inspect:read"],
|
|
114
|
+
services: E.mergeAll(E.succeed(b, c), E.succeed(S, f), E.succeed(x, u)),
|
|
115
|
+
routes: g(s),
|
|
116
|
+
rpcClientDescriptors: h,
|
|
117
|
+
errorSchemas: [{
|
|
118
|
+
schema: e,
|
|
119
|
+
import: {
|
|
120
|
+
module: "@voltro/plugin-guilds/errors",
|
|
121
|
+
name: "GuildsError"
|
|
122
|
+
}
|
|
123
|
+
}],
|
|
124
|
+
sources: w(new URL("./guild-app", "" + import.meta.url)),
|
|
125
|
+
extendSchema: { tables: l },
|
|
126
|
+
subjectPrivacy: {
|
|
127
|
+
tables: l.map((e) => e.tableName),
|
|
128
|
+
kinds: ["user", "guest"]
|
|
129
|
+
},
|
|
130
|
+
subjectMerge: {
|
|
131
|
+
tables: l.map((e) => e.tableName),
|
|
132
|
+
kinds: ["guest"]
|
|
133
|
+
},
|
|
134
|
+
onMergeAccounts: (e) => o((t) => t.mergeSubject(e)),
|
|
135
|
+
inspectEndpoints: [{
|
|
136
|
+
method: "GET",
|
|
137
|
+
path: "/status",
|
|
138
|
+
scope: "process",
|
|
139
|
+
description: "Declared guild configuration and process binding, no guild/member enumeration.",
|
|
140
|
+
handler: () => T.try({
|
|
141
|
+
try: () => ({
|
|
142
|
+
kind: "json",
|
|
143
|
+
data: _(r, a !== void 0)
|
|
144
|
+
}),
|
|
145
|
+
catch: () => t("unavailable")
|
|
146
|
+
})
|
|
147
|
+
}],
|
|
148
|
+
bindDataStore: (e) => {
|
|
149
|
+
if (i !== void 0 && i !== e) throw Error("Guild plugin instance cannot cross app stores");
|
|
150
|
+
i = e, a ??= d(e, r);
|
|
151
|
+
},
|
|
152
|
+
onExport: (e, t) => o((n) => n.exportSubject({
|
|
153
|
+
subjectId: e,
|
|
154
|
+
tenantId: t.tenantId,
|
|
155
|
+
kind: t.kind
|
|
156
|
+
})),
|
|
157
|
+
onErase: (e, t) => o((n) => n.eraseSubject({
|
|
158
|
+
subjectId: e,
|
|
159
|
+
tenantId: t.tenantId,
|
|
160
|
+
kind: t.kind
|
|
161
|
+
})),
|
|
162
|
+
onDeactivate: () => T.sync(() => {
|
|
163
|
+
a = void 0, i = void 0;
|
|
87
164
|
})
|
|
88
|
-
}],
|
|
89
|
-
bindDataStore: (e) => {
|
|
90
|
-
if (n !== void 0 && n !== e) throw Error("Guild plugin instance cannot cross app stores");
|
|
91
|
-
n = e, r = d(e, t);
|
|
92
|
-
},
|
|
93
|
-
onExport: (e, t) => i((n) => n.exportSubject({
|
|
94
|
-
subjectId: e,
|
|
95
|
-
tenantId: t.tenantId,
|
|
96
|
-
kind: t.kind
|
|
97
|
-
})),
|
|
98
|
-
onErase: (e, t) => i((n) => n.eraseSubject({
|
|
99
|
-
subjectId: e,
|
|
100
|
-
tenantId: t.tenantId,
|
|
101
|
-
kind: t.kind
|
|
102
|
-
})),
|
|
103
|
-
onDeactivate: () => S.sync(() => {
|
|
104
|
-
r = void 0, n = void 0;
|
|
105
165
|
})
|
|
106
|
-
}
|
|
166
|
+
};
|
|
107
167
|
};
|
|
108
|
-
export { y as GuildMembershipPort,
|
|
168
|
+
export { y as GUILD_MEMBERS_TABLE, b as GuildMembershipPort, x as GuildPermissionPort, S as GuildRosterPort, e as GuildsError, d as dataStoreGuilds, f as defaultGuildStrategies, n as guildAdmissionsTable, r as guildAnnouncementsTable, i as guildApplicationsTable, a as guildInvitesTable, o as guildLogTable, s as guildMembersTable, c as guildRolesTable, D as guildSystemContract, l as guildTables, O as guildsPlugin, u as guildsTable, p as resolveGuildOptions };
|
package/dist/inspect.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { guildsError as e } from "./errors.js";
|
|
2
|
+
import { guildTables as t } from "./entities.js";
|
|
3
3
|
import { defaultGuildStrategies as n } from "./strategies.js";
|
|
4
|
+
import { decodeGuildsStatus as r } from "@voltro/protocol/inspect";
|
|
4
5
|
// src/inspect.ts
|
|
5
|
-
var
|
|
6
|
-
let
|
|
7
|
-
if (!Number.isSafeInteger(
|
|
8
|
-
return {
|
|
9
|
-
observedAt:
|
|
10
|
-
bound:
|
|
11
|
-
baseMemberCap:
|
|
12
|
-
maximumMemberCap:
|
|
13
|
-
maxGuildsPerSubject:
|
|
14
|
-
maxRoles:
|
|
15
|
-
maxPending:
|
|
16
|
-
inviteTtlMs:
|
|
17
|
-
inactiveAfterMs:
|
|
18
|
-
pageSize:
|
|
19
|
-
maxExportRows:
|
|
20
|
-
maxDescriptionLength:
|
|
21
|
-
maxAnnouncementLength:
|
|
22
|
-
denyWordCount:
|
|
23
|
-
slots: Object.fromEntries(Object.entries(n).map(([e, t]) => [e,
|
|
24
|
-
tables:
|
|
25
|
-
};
|
|
6
|
+
var i = (i, a) => {
|
|
7
|
+
let o = i.now();
|
|
8
|
+
if (!Number.isSafeInteger(o) || o < 0 || o > 864e13) throw e("unavailable");
|
|
9
|
+
return r({
|
|
10
|
+
observedAt: o,
|
|
11
|
+
bound: a,
|
|
12
|
+
baseMemberCap: i.baseMemberCap,
|
|
13
|
+
maximumMemberCap: i.maximumMemberCap,
|
|
14
|
+
maxGuildsPerSubject: i.maxGuildsPerSubject,
|
|
15
|
+
maxRoles: i.maxRoles,
|
|
16
|
+
maxPending: i.maxPending,
|
|
17
|
+
inviteTtlMs: i.inviteTtlMs,
|
|
18
|
+
inactiveAfterMs: i.inactiveAfterMs,
|
|
19
|
+
pageSize: i.pageSize,
|
|
20
|
+
maxExportRows: i.maxExportRows,
|
|
21
|
+
maxDescriptionLength: i.maxDescriptionLength,
|
|
22
|
+
maxAnnouncementLength: i.maxAnnouncementLength,
|
|
23
|
+
denyWordCount: i.denyWords.length,
|
|
24
|
+
slots: Object.fromEntries(Object.entries(n).map(([e, t]) => [e, i.strategies[e] === t ? "default" : "custom"])),
|
|
25
|
+
tables: t.map((e) => e.tableName)
|
|
26
|
+
});
|
|
26
27
|
};
|
|
27
|
-
export {
|
|
28
|
+
export { i as guildStatus };
|
package/dist/port.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ import { Schema } from 'effect';
|
|
|
4
4
|
import { Subject } from '@voltro/protocol';
|
|
5
5
|
import { YieldableError } from 'effect/Cause';
|
|
6
6
|
|
|
7
|
+
/** The SQL role whose changes alter a guild roster; a dependent live query declares it as a source. */
|
|
8
|
+
export declare const GUILD_MEMBERS_TABLE = "_voltro_guild_members";
|
|
9
|
+
|
|
7
10
|
export declare class GuildMembershipPort extends GuildMembershipPort_base {
|
|
8
11
|
}
|
|
9
12
|
|
|
@@ -15,6 +18,30 @@ export declare interface GuildMembershipService {
|
|
|
15
18
|
readonly isMember: (subject: Subject, guildId: string) => Effect.Effect<boolean, GuildsError>;
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
declare type GuildPermission = keyof typeof PERMISSIONS;
|
|
22
|
+
|
|
23
|
+
export declare class GuildPermissionPort extends GuildPermissionPort_base {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const GuildPermissionPort_base: Context.ServiceClass<GuildPermissionPort, "@voltro/GuildPermissionPort", GuildPermissionService>;
|
|
27
|
+
|
|
28
|
+
/** Whether a member's role grants a permission in their guild (e.g. `treasury` for a guild wallet), for
|
|
29
|
+
* other systems acting for that member; never Guild SQL. Non-members, unknown or foreign guilds answer false. */
|
|
30
|
+
export declare interface GuildPermissionService {
|
|
31
|
+
readonly may: (subject: Subject, guildId: string, permission: GuildPermission) => Effect.Effect<boolean, GuildsError>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare class GuildRosterPort extends GuildRosterPort_base {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare const GuildRosterPort_base: Context.ServiceClass<GuildRosterPort, "@voltro/GuildRosterPort", GuildRosterService>;
|
|
38
|
+
|
|
39
|
+
/** Member identifiers of one guild for a guild leaderboard or roster view; never Guild SQL. Only a member of
|
|
40
|
+
* that guild in its own tenant receives them: unknown, foreign or inaccessible guilds refuse. */
|
|
41
|
+
export declare interface GuildRosterService {
|
|
42
|
+
readonly memberIds: (subject: Subject, guildId: string) => Effect.Effect<ReadonlyArray<string>, GuildsError>;
|
|
43
|
+
}
|
|
44
|
+
|
|
18
45
|
declare class GuildsError extends GuildsError_base {
|
|
19
46
|
}
|
|
20
47
|
|
|
@@ -22,4 +49,14 @@ declare const GuildsError_base: Schema.Class<GuildsError, Schema.TaggedStruct<"G
|
|
|
22
49
|
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"]>;
|
|
23
50
|
}>, YieldableError>;
|
|
24
51
|
|
|
52
|
+
declare const PERMISSIONS: {
|
|
53
|
+
readonly invite: 1;
|
|
54
|
+
readonly kick: 2;
|
|
55
|
+
readonly promote: 4;
|
|
56
|
+
readonly treasury: 8;
|
|
57
|
+
readonly announce: 16;
|
|
58
|
+
readonly startEvent: 32;
|
|
59
|
+
readonly editProfile: 64;
|
|
60
|
+
};
|
|
61
|
+
|
|
25
62
|
export { }
|
package/dist/port.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MEMBERS_TABLE as e } from "./contract.js";
|
|
2
|
+
import { Context as t } from "effect";
|
|
2
3
|
// src/port.ts
|
|
3
|
-
var
|
|
4
|
-
export {
|
|
4
|
+
var n = class extends t.Service()("@voltro/GuildMembershipPort") {}, r = class extends t.Service()("@voltro/GuildRosterPort") {}, i = class extends t.Service()("@voltro/GuildPermissionPort") {}, a = e;
|
|
5
|
+
export { a as GUILD_MEMBERS_TABLE, n as GuildMembershipPort, i as GuildPermissionPort, r as GuildRosterPort };
|