@rbxts/scribe 2.5.0 → 2.6.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/types/api.d.ts CHANGED
@@ -1,252 +1,253 @@
1
- import type { Accessor, PlayerData, ValueOf, InputOf, ClientSchema, SharedSchema, ReadonlyAccessor, NumericPaths, Disconnect, Datatype, BigValue } from "./schema";
2
- import type { UnknownRecord, ScribeTransport, Signal, LifecycleReason, SessionState, LoadPhase, Status, ProductState, RequestFailure, RequestFailedMarker, OperationResult, SaveInfo, SaveEvent, Anomaly, GiftReceived, VersionRecord, SchemaViolation, FlushOptions, UpdateOfflineOptions, RestoreOptions, CooldownOptions, MigrationContext, LeaderboardEntry, LeaderboardStatusInfo, PassConfig, PurchaseFilter, PurchaseEntry, PurchaseLogOptions, ProductInfo, PolicyInfo, ReceiptInfo, EconomyConfig, ExchangeableSpec, ExchangeAPI, LogLevel, StatusThresholds, PeriodResetOptions, MockState } from "./common";
3
-
4
- export interface LeaderboardConfig<T = unknown> {
5
- Stat: NumericPaths<T, true>;
6
- Limit?: number;
7
- Scale?: number;
8
- SigFigs?: number;
9
- Replicate?: boolean;
10
- RefreshInterval?: number;
11
- /** Minimum seconds between changed-score writes per player/store (default 30, minimum 1). Ignored for Server scope. */
12
- WriteInterval?: number;
13
- StoreName?: string;
14
- Period?: "Daily" | "Weekly";
15
- Mode?: "Gain" | "Peak";
16
- Scope?: "Global" | "Server";
17
- }
18
- export interface ProductConfig<T = unknown> {
19
- Id: number;
20
- Category?: string;
21
- Grant?: (this: void, data: PlayerData<T>) => void;
22
- Grants?: string;
23
- PaidRandom?: boolean;
24
- }
25
- export interface PurchaseSpec<T = unknown> {
26
- Cost: { Path: NumericPaths<T, false>; Amount: number };
27
- Category?: string;
28
- ItemId: string;
29
- Grant?: (this: void, data: PlayerData<T>) => void;
30
- Meta?: UnknownRecord;
31
- IdempotencyKey?: string;
32
- PaidRandom?: boolean;
33
- }
34
-
35
- /** A shared command contract maps each command name to its arguments and LuaTuple result. */
36
- export type CommandArguments<F> = F extends (this: void, ...args: infer A) => unknown ? A : never;
37
- export type CommandReturn<F> = F extends (this: void, ...args: never[]) => infer R ? R extends LuaTuple<unknown[]> ? R : never : never;
38
- export type CommandHandler<F> = (this: void, player: Player, ...args: CommandArguments<F>) => CommandReturn<F>;
39
- export interface CommandSpec { Args?: ReadonlyArray<unknown>; Idempotent?: boolean; }
40
-
41
- /** Uncontracted commands deliberately expose unknown results instead of claiming inferred safety. */
42
- export type RequestFunction<C> = keyof C extends never
43
- ? (this: void, name: string, ...args: unknown[]) => LuaTuple<unknown[]>
44
- : <K extends keyof C & string>(this: void, name: K, ...args: CommandArguments<C[K]>) => CommandReturn<C[K]> | RequestFailure;
45
- export type RequestOnceFunction<C> = keyof C extends never
46
- ? (this: void, name: string, key: string, ...args: unknown[]) => LuaTuple<unknown[]>
47
- : <K extends keyof C & string>(this: void, name: K, key: string, ...args: CommandArguments<C[K]>) => CommandReturn<C[K]> | RequestFailure;
48
- export type RegisterCommand<C> = keyof C extends never ? {
49
- <A extends unknown[], R>(this: void, name: string, handler: (this: void, player: Player, ...args: A) => R): void;
50
- <A extends unknown[], R>(this: void, name: string, spec: CommandSpec, handler: (this: void, player: Player, ...args: A) => R): void;
51
- } : {
52
- <K extends keyof C & string>(this: void, name: K, handler: CommandHandler<C[K]>): void;
53
- <K extends keyof C & string>(this: void, name: K, spec: CommandSpec, handler: CommandHandler<C[K]>): void;
54
- };
55
- export type MockCommand<C> = keyof C extends never
56
- ? <A extends unknown[], R>(this: void, name: string, handler: (this: void, ...args: A) => R) => void
57
- : <K extends keyof C & string>(this: void, name: K, handler: C[K]) => void;
58
-
59
- export type ServerStore<S> = { readonly [K in keyof S]: Accessor<S[K]> };
60
- export type ClientServerStore<S> = { readonly [K in keyof ClientSchema<S>]: ReadonlyAccessor<ClientSchema<S>[K]> };
61
- type ServerStoreMember<S> = keyof S extends never ? { readonly ServerStore?: never } : { readonly ServerStore: ServerStore<S> };
62
- type ClientStoreMember<S> = keyof S extends never ? { readonly ServerStore?: never } : { readonly ServerStore: ClientServerStore<S> };
63
- export type SharedData<T> = ValueOf<SharedSchema<ClientSchema<T>>>;
64
-
65
- export interface ServerAPI<T, C = {}> {
66
- readonly Get: (this: void, player: Player) => PlayerData<T>;
67
- readonly WaitForData: (this: void, player: Player, timeout?: number) => LuaTuple<[PlayerData<T> | undefined, LifecycleReason | undefined]>;
68
- readonly GetState: (this: void, player: Player) => LuaTuple<[SessionState, LoadPhase | undefined]>;
69
- readonly Batch: (this: void, player: Player, callback: (this: void) => void) => void;
70
- readonly Transaction: (this: void, player: Player, callback: (this: void) => void) => OperationResult;
71
- readonly Flush: (this: void, player: Player, options?: FlushOptions) => boolean;
72
- readonly GetSaveInfo: (this: void, player: Player) => SaveInfo;
73
- /** Offline/history reads are packed, potentially old schemas, not live accessor values. */
74
- readonly GetOffline: (this: void, userId: number) => UnknownRecord | undefined;
75
- readonly UpdateOffline: (this: void, userId: number, callback: (this: void, rawData: UnknownRecord) => void, options?: UpdateOfflineOptions) => LuaTuple<[boolean, string | undefined, SchemaViolation[] | undefined]>;
76
- readonly ListVersions: (this: void, userId: number, limit?: number) => VersionRecord[];
77
- readonly GetVersion: (this: void, userId: number, versionId: string) => UnknownRecord | undefined;
78
- readonly RestoreVersion: (this: void, userId: number, versionId: string, options?: RestoreOptions) => OperationResult;
79
- readonly Erase: (this: void, userId: number) => OperationResult;
80
- readonly Export: (this: void, userId: number) => string | undefined;
81
- readonly Command: RegisterCommand<C>;
82
- readonly GetLeaderboard: (this: void, name: string, limit?: number, offset?: number) => LeaderboardEntry[];
83
- readonly GetMyRank: (this: void, player: Player, name: string) => number | undefined;
84
- readonly GetLeaderboardRefreshIn: (this: void, name: string) => number | undefined;
85
- readonly GetLeaderboardStatus: (this: void, name: string) => LeaderboardStatusInfo | undefined;
86
- readonly GetLeaderboardResetIn: (this: void, name: string) => number | undefined;
87
- readonly PromptPurchase: (this: void, player: Player, name: string) => OperationResult;
88
- readonly GetProductState: (this: void, player: Player, name: string) => ProductState;
89
- readonly PromptGift: (this: void, buyer: Player, productName: string, recipientUserId: number) => OperationResult;
90
- readonly GetGiftCredits: (this: void, player: Player) => { [product: string]: number };
91
- readonly HandleReceipt: (this: void, receipt: ReceiptInfo) => Enum.ProductPurchaseDecision;
92
- readonly TryHandleReceipt: (this: void, receipt: ReceiptInfo) => Enum.ProductPurchaseDecision | undefined;
93
- readonly Owns: (this: void, player: Player, key: string) => boolean;
94
- readonly OwnsAsync: (this: void, player: Player, key: string, timeout?: number) => boolean;
95
- readonly ObserveOwned: (this: void, player: Player, key: string, callback: (this: void, owned: boolean) => void) => Disconnect;
96
- readonly GrantPerk: (this: void, player: Player, key: string) => void;
97
- readonly RevokePerk: (this: void, player: Player, key: string) => void;
98
- readonly Purchase: (this: void, player: Player, spec: PurchaseSpec<T>) => OperationResult;
99
- readonly RecordPurchase: (this: void, player: Player, entry: UnknownRecord) => void;
100
- readonly GetPurchases: (this: void, player: Player, filter?: PurchaseFilter) => PurchaseEntry[];
101
- readonly OnCooldown: (this: void, player: Player, key: string, seconds: number, options?: CooldownOptions) => LuaTuple<[boolean, number]>;
102
- readonly PeekCooldown: (this: void, player: Player, key: string) => LuaTuple<[boolean, number]>;
103
- readonly ClearCooldown: (this: void, player: Player, key: string) => void;
104
- readonly SendMessage: (this: void, userId: number, message: unknown) => boolean;
105
- readonly Exchange: ExchangeAPI;
106
- readonly OnSave: Signal<[SaveEvent]>;
107
- readonly SessionEnded: Signal<[Player, LifecycleReason]>;
108
- readonly OnAnomaly: Signal<[Anomaly]>;
109
- readonly OnGiftReceived: Signal<[Player, GiftReceived]>;
110
- readonly OnGiftCredit: Signal<[Player, string]>;
111
- readonly OnOwnershipChanged: Signal<[Player, string, boolean]>;
112
- readonly OnCooldownEnded: Signal<[Player, string]>;
113
- readonly OnLeaderboard: Signal<[string, LeaderboardEntry[]]>;
114
- readonly OnMessage: Signal<[Player, unknown]>;
115
- /** External ProfileStore implementation; narrow to its own public package type before use. */
116
- readonly ProfileStore: unknown;
117
- /** Escape hatch requiring explicit validation/assertion at its boundary. */
118
- readonly Raw: unknown;
119
- readonly Stop: (this: void) => void;
120
- }
121
- export type ServerData<T, S = {}, C = {}> = ServerAPI<T, C> & ServerStoreMember<S>;
122
-
123
- /** Partial records for Mock; arrays and Roblox engine datatypes remain whole values. */
124
- export type MockValues<T> = T extends Datatype | buffer | BigValue | ReadonlyArray<unknown> | ReadonlyMap<unknown, unknown> ? T : T extends object ? { [K in keyof T]?: MockValues<T[K]> } : T;
125
- export interface ClientAPI<T, C = {}> {
126
- readonly IsReady: (this: void) => boolean;
127
- readonly WaitForData: (this: void, timeout?: number) => boolean;
128
- readonly Batch: (this: void, callback: (this: void) => void) => void;
129
- readonly Request: RequestFunction<C>;
130
- readonly RequestOnce: RequestOnceFunction<C>;
131
- readonly GetLeaderboard: (this: void, name: string, limit?: number) => LeaderboardEntry[];
132
- readonly GetMyRank: (this: void, name: string) => number | undefined;
133
- readonly OnLeaderboard: Signal<[string, LeaderboardEntry[]]>;
134
- readonly GetServiceStatus: (this: void) => Status;
135
- readonly OnServiceStatus: Signal<[Status]>;
136
- readonly GetShared: (this: void, playerOrUserId: Player | number) => SharedData<T> | undefined;
137
- readonly OnSharedChanged: Signal<[number, SharedData<T> | undefined]>;
138
- readonly Owns: (this: void, key: string) => boolean;
139
- readonly OwnsAsync: (this: void, key: string, timeout?: number) => boolean;
140
- readonly ObserveOwned: (this: void, key: string, callback: (this: void, owned: boolean) => void) => Disconnect;
141
- readonly OnOwnershipChanged: Signal<[string, boolean]>;
142
- readonly GetProductInfo: (this: void, name: string) => ProductInfo | undefined;
143
- readonly GetPrice: (this: void, name: string) => number | undefined;
144
- readonly GetProductInfoAsync: (this: void, name: string, timeout?: number) => ProductInfo | undefined;
145
- readonly GetPriceAsync: (this: void, name: string, timeout?: number) => number | undefined;
146
- readonly ObserveProductInfo: (this: void, name: string, callback: (this: void, info: ProductInfo | undefined) => void) => Disconnect;
147
- readonly PrefetchProductInfo: (this: void, names?: ReadonlyArray<string>) => void;
148
- readonly RefreshProductInfo: (this: void, name?: string) => void;
149
- /** Asks the server to validate and prompt for the local player. Success is not a completed purchase; a timeout may occur after the prompt opens. No automatic retry. */
150
- readonly PromptPurchase: (this: void, name: string) => LuaTuple<[boolean, string | undefined, RequestFailedMarker | undefined]>;
151
- readonly GetProductState: (this: void, name: string) => ProductState;
152
- readonly ObserveProductState: (this: void, name: string, callback: (this: void, state: ProductState) => void) => Disconnect;
153
- readonly GetSaveInfo: (this: void) => SaveInfo;
154
- readonly GetGiftCredits: (this: void) => { [product: string]: number };
155
- readonly GetPurchases: (this: void, filter?: PurchaseFilter) => PurchaseEntry[];
156
- readonly Mock: (this: void, values?: MockValues<InputOf<ClientSchema<T>>>, state?: MockState) => void;
157
- readonly MockCommand: MockCommand<C>;
158
- readonly Raw: unknown;
159
- readonly Stop: (this: void) => void;
160
- }
161
- /** Client field writes are local optimistic edits; server-owned roots remain read-only. */
162
- export type ClientData<T, S = {}, C = {}> = Omit<PlayerData<ClientSchema<T>>, Extract<keyof PlayerData<ClientSchema<T>>, keyof ClientAPI<T, C> | "ServerStore">> & ClientAPI<T, C> & ClientStoreMember<S>;
163
- export interface Bundle<T, S = {}, C = {}> { readonly Server: ServerData<T, S, C>; readonly Client: ClientData<T, S, C>; }
164
-
165
- /** Both templates share root field IDs. Broad dictionaries are validated at runtime. */
166
- type DisjointStoreRoots<T, S> = string extends keyof T | keyof S ? unknown : { [K in keyof T & keyof S]?: never };
167
- export interface ScribeOptions<T, S = {}, C = {}> {
168
- Template: T;
169
- ServerStore?: S & DisjointStoreRoots<NoInfer<T>, NoInfer<S>>;
170
- Transport?: ScribeTransport | "Default";
171
- Migrations?: { [version: number]: (this: void, data: UnknownRecord) => void };
172
- UserOwnsGamePassAsync?: (this: void, userId: number, passId: number) => boolean;
173
- GetProductInfoAsync?: (this: void, assetId: number, infoType: Enum.InfoType) => ProductInfo | undefined;
174
- GetPolicyInfoAsync?: (this: void, player: Player) => PolicyInfo | undefined;
175
- DevMode?: boolean;
176
- IsRunning?: boolean;
177
- MigrationShadow?: boolean;
178
- ImportLegacyData?: (this: void, player: Player, userId: number, migration: MigrationContext) => UnknownRecord | undefined;
179
- MigrationConcurrency?: number;
180
- OnPlayerInit?: (this: void, player: Player, rawData: UnknownRecord, isNewProfile: boolean, migration: MigrationContext) => void;
181
- OnPlayerLeaving?: (this: void, player: Player, data: PlayerData<T>, reason: LifecycleReason) => void;
182
- ProfileStoreIndex: string;
183
- ProfileKeyPrefix: string;
184
- SaveInterval?: number;
185
- /** A supplied ProfileStore module/module script is an external integration boundary. */
186
- ProfileStore?: unknown;
187
- Mode?: "Live" | "Mock" | "NoSave";
188
- TargetUserId?: number;
189
- UseMock?: boolean;
190
- ViewedUserId?: number;
191
- OverriddenUserId?: number;
192
- DontSave?: boolean;
193
- ResetData?: boolean;
194
- LoadFailurePolicy?: "Kick" | "Wait";
195
- LoadTimeout?: number;
196
- EraseJoinTimeout?: number;
197
- VersionAheadPolicy?: "Kick" | "Allow";
198
- KickOnSessionEnd?: boolean;
199
- LoadFailureMessage?: string;
200
- LegacyImportFailureMessage?: string;
201
- MigrationFailureMessage?: string;
202
- VersionAheadMessage?: string;
203
- SchemaFailureMessage?: string;
204
- RateLimitedMessage?: string;
205
- ErasingMessage?: string;
206
- SessionEndMessage?: string;
207
- SessionStolenMessage?: string;
208
- SessionInterruptedMessage?: string;
209
- Leaderboards?: { [name: string]: LeaderboardConfig<T> };
210
- PeriodReset?: PeriodResetOptions;
211
- Products?: { [name: string]: ProductConfig<T> };
212
- /** Historical products still settle receipts and existing gifts, without offering new sales. */
213
- RetiredProducts?: { [name: string]: ProductConfig<T> };
214
- Passes?: { [name: string]: PassConfig };
215
- Perks?: ReadonlyArray<string>;
216
- OwnReceipts?: boolean;
217
- Exchangeable?: { [name: string]: ExchangeableSpec };
218
- PurchaseLog?: PurchaseLogOptions;
219
- GiftCooldown?: number;
220
- GiftMaxPending?: number;
221
- GiftIntentTTL?: number;
222
- /** Legacy default for purchase-claim and gift-aim retention; receipt history remains fixed at 30 days. */
223
- PurchaseIdTTL?: number;
224
- /** @deprecated Ignored. Completed receipt IDs are no longer evicted to meet a count cap. */
225
- MaxProcessedPurchaseIds?: number;
226
- /** Receipt-history admission budget, from 1 to 2097152 bytes (default 1048576). */
227
- MaxReceiptHistoryBytes?: number;
228
- PurchaseClaimTTL?: number;
229
- MaxPurchaseClaims?: number;
230
- AllowDuplicateGifts?: boolean;
231
- NoGiftIntentPolicy?: "GrantOrCredit" | "Hold";
232
- Economy?: EconomyConfig;
233
- CommandRateLimit?: number;
234
- RequestTimeout?: number;
235
- MaxInboundBytes?: number;
236
- MaxInboundRetainedBytes?: number;
237
- MaxOutboundBytes?: number;
238
- MaxInboundFrameRate?: number;
239
- TransportChannel?: string;
240
- BoundsPolicy?: "Clamp" | "Reject";
241
- WipeGuardPolicy?: "Warn" | "Block";
242
- SchemaPolicy?: "Warn" | "Reject";
243
- BudgetPolicy?: "Defer";
244
- WipeGuardShrinkRatio?: number;
245
- LogLevel?: LogLevel;
246
- /** Severity retained by GetRecentLogs, independently of console and sink filters. */
247
- LogRingLevel?: LogLevel;
248
- LogRingSize?: number;
249
- StatusThresholds?: StatusThresholds;
250
- Banner?: boolean;
251
- StudioHook?: boolean;
252
- }
1
+ import type { Accessor, PlayerData, ValueOf, InputOf, ClientSchema, SharedSchema, ReadonlyAccessor, NumericPaths, Disconnect, Datatype, BigValue, BigOperand } from "./schema";
2
+ import type { UnknownRecord, ScribeTransport, Signal, LifecycleReason, SessionState, LoadPhase, Status, ProductState, RequestFailure, RequestFailedMarker, OperationResult, SaveInfo, SaveEvent, Anomaly, GiftReceived, VersionRecord, SchemaViolation, FlushOptions, UpdateOfflineOptions, RestoreOptions, CooldownOptions, MigrationContext, LeaderboardEntry, LeaderboardStatusInfo, PassConfig, PurchaseFilter, PurchaseEntry, PurchaseLogOptions, ProductInfo, PolicyInfo, ReceiptInfo, EconomyConfig, ExchangeableSpec, ExchangeAPI, LogLevel, StatusThresholds, PeriodResetOptions, MockState } from "./common";
3
+
4
+ export interface LeaderboardConfig<T = unknown> {
5
+ Stat: NumericPaths<T, true>;
6
+ Limit?: number;
7
+ Scale?: number;
8
+ SigFigs?: number;
9
+ Replicate?: boolean;
10
+ RefreshInterval?: number;
11
+ /** Minimum seconds between changed-score writes per player/store (default 30, minimum 1). Ignored for Server scope. */
12
+ WriteInterval?: number;
13
+ StoreName?: string;
14
+ Period?: "Daily" | "Weekly";
15
+ Mode?: "Gain" | "Peak";
16
+ Scope?: "Global" | "Server";
17
+ }
18
+ export interface ProductConfig<T = unknown> {
19
+ Id: number;
20
+ Category?: string;
21
+ Grant?: (this: void, data: PlayerData<T>) => void;
22
+ Grants?: string;
23
+ PaidRandom?: boolean;
24
+ }
25
+ export interface PurchaseSpec<T = unknown> {
26
+ /** Strings and BigValue amounts require a Big currency. */
27
+ Cost: { Path: NumericPaths<T, true>; Amount: BigOperand };
28
+ Category?: string;
29
+ ItemId: string;
30
+ Grant?: (this: void, data: PlayerData<T>) => void;
31
+ Meta?: UnknownRecord;
32
+ IdempotencyKey?: string;
33
+ PaidRandom?: boolean;
34
+ }
35
+
36
+ /** A shared command contract maps each command name to its arguments and LuaTuple result. */
37
+ export type CommandArguments<F> = F extends (this: void, ...args: infer A) => unknown ? A : never;
38
+ export type CommandReturn<F> = F extends (this: void, ...args: never[]) => infer R ? R extends LuaTuple<unknown[]> ? R : never : never;
39
+ export type CommandHandler<F> = (this: void, player: Player, ...args: CommandArguments<F>) => CommandReturn<F>;
40
+ export interface CommandSpec { Args?: ReadonlyArray<unknown>; Idempotent?: boolean; }
41
+
42
+ /** Uncontracted commands deliberately expose unknown results instead of claiming inferred safety. */
43
+ export type RequestFunction<C> = keyof C extends never
44
+ ? (this: void, name: string, ...args: unknown[]) => LuaTuple<unknown[]>
45
+ : <K extends keyof C & string>(this: void, name: K, ...args: CommandArguments<C[K]>) => CommandReturn<C[K]> | RequestFailure;
46
+ export type RequestOnceFunction<C> = keyof C extends never
47
+ ? (this: void, name: string, key: string, ...args: unknown[]) => LuaTuple<unknown[]>
48
+ : <K extends keyof C & string>(this: void, name: K, key: string, ...args: CommandArguments<C[K]>) => CommandReturn<C[K]> | RequestFailure;
49
+ export type RegisterCommand<C> = keyof C extends never ? {
50
+ <A extends unknown[], R>(this: void, name: string, handler: (this: void, player: Player, ...args: A) => R): void;
51
+ <A extends unknown[], R>(this: void, name: string, spec: CommandSpec, handler: (this: void, player: Player, ...args: A) => R): void;
52
+ } : {
53
+ <K extends keyof C & string>(this: void, name: K, handler: CommandHandler<C[K]>): void;
54
+ <K extends keyof C & string>(this: void, name: K, spec: CommandSpec, handler: CommandHandler<C[K]>): void;
55
+ };
56
+ export type MockCommand<C> = keyof C extends never
57
+ ? <A extends unknown[], R>(this: void, name: string, handler: (this: void, ...args: A) => R) => void
58
+ : <K extends keyof C & string>(this: void, name: K, handler: C[K]) => void;
59
+
60
+ export type ServerStore<S> = { readonly [K in keyof S]: Accessor<S[K]> };
61
+ export type ClientServerStore<S> = { readonly [K in keyof ClientSchema<S>]: ReadonlyAccessor<ClientSchema<S>[K]> };
62
+ type ServerStoreMember<S> = keyof S extends never ? { readonly ServerStore?: never } : { readonly ServerStore: ServerStore<S> };
63
+ type ClientStoreMember<S> = keyof S extends never ? { readonly ServerStore?: never } : { readonly ServerStore: ClientServerStore<S> };
64
+ export type SharedData<T> = ValueOf<SharedSchema<ClientSchema<T>>>;
65
+
66
+ export interface ServerAPI<T, C = {}> {
67
+ readonly Get: (this: void, player: Player) => PlayerData<T>;
68
+ readonly WaitForData: (this: void, player: Player, timeout?: number) => LuaTuple<[PlayerData<T> | undefined, LifecycleReason | undefined]>;
69
+ readonly GetState: (this: void, player: Player) => LuaTuple<[SessionState, LoadPhase | undefined]>;
70
+ readonly Batch: (this: void, player: Player, callback: (this: void) => void) => void;
71
+ readonly Transaction: (this: void, player: Player, callback: (this: void) => void) => OperationResult;
72
+ readonly Flush: (this: void, player: Player, options?: FlushOptions) => boolean;
73
+ readonly GetSaveInfo: (this: void, player: Player) => SaveInfo;
74
+ /** Offline/history reads are packed, potentially old schemas, not live accessor values. */
75
+ readonly GetOffline: (this: void, userId: number) => UnknownRecord | undefined;
76
+ readonly UpdateOffline: (this: void, userId: number, callback: (this: void, rawData: UnknownRecord) => void, options?: UpdateOfflineOptions) => LuaTuple<[boolean, string | undefined, SchemaViolation[] | undefined]>;
77
+ readonly ListVersions: (this: void, userId: number, limit?: number) => VersionRecord[];
78
+ readonly GetVersion: (this: void, userId: number, versionId: string) => UnknownRecord | undefined;
79
+ readonly RestoreVersion: (this: void, userId: number, versionId: string, options?: RestoreOptions) => OperationResult;
80
+ readonly Erase: (this: void, userId: number) => OperationResult;
81
+ readonly Export: (this: void, userId: number) => string | undefined;
82
+ readonly Command: RegisterCommand<C>;
83
+ readonly GetLeaderboard: (this: void, name: string, limit?: number, offset?: number) => LeaderboardEntry[];
84
+ readonly GetMyRank: (this: void, player: Player, name: string) => number | undefined;
85
+ readonly GetLeaderboardRefreshIn: (this: void, name: string) => number | undefined;
86
+ readonly GetLeaderboardStatus: (this: void, name: string) => LeaderboardStatusInfo | undefined;
87
+ readonly GetLeaderboardResetIn: (this: void, name: string) => number | undefined;
88
+ readonly PromptPurchase: (this: void, player: Player, name: string) => OperationResult;
89
+ readonly GetProductState: (this: void, player: Player, name: string) => ProductState;
90
+ readonly PromptGift: (this: void, buyer: Player, productName: string, recipientUserId: number) => OperationResult;
91
+ readonly GetGiftCredits: (this: void, player: Player) => { [product: string]: number };
92
+ readonly HandleReceipt: (this: void, receipt: ReceiptInfo) => Enum.ProductPurchaseDecision;
93
+ readonly TryHandleReceipt: (this: void, receipt: ReceiptInfo) => Enum.ProductPurchaseDecision | undefined;
94
+ readonly Owns: (this: void, player: Player, key: string) => boolean;
95
+ readonly OwnsAsync: (this: void, player: Player, key: string, timeout?: number) => boolean;
96
+ readonly ObserveOwned: (this: void, player: Player, key: string, callback: (this: void, owned: boolean) => void) => Disconnect;
97
+ readonly GrantPerk: (this: void, player: Player, key: string) => void;
98
+ readonly RevokePerk: (this: void, player: Player, key: string) => void;
99
+ readonly Purchase: (this: void, player: Player, spec: PurchaseSpec<T>) => OperationResult;
100
+ readonly RecordPurchase: (this: void, player: Player, entry: UnknownRecord) => void;
101
+ readonly GetPurchases: (this: void, player: Player, filter?: PurchaseFilter) => PurchaseEntry[];
102
+ readonly OnCooldown: (this: void, player: Player, key: string, seconds: number, options?: CooldownOptions) => LuaTuple<[boolean, number]>;
103
+ readonly PeekCooldown: (this: void, player: Player, key: string) => LuaTuple<[boolean, number]>;
104
+ readonly ClearCooldown: (this: void, player: Player, key: string) => void;
105
+ readonly SendMessage: (this: void, userId: number, message: unknown) => boolean;
106
+ readonly Exchange: ExchangeAPI;
107
+ readonly OnSave: Signal<[SaveEvent]>;
108
+ readonly SessionEnded: Signal<[Player, LifecycleReason]>;
109
+ readonly OnAnomaly: Signal<[Anomaly]>;
110
+ readonly OnGiftReceived: Signal<[Player, GiftReceived]>;
111
+ readonly OnGiftCredit: Signal<[Player, string]>;
112
+ readonly OnOwnershipChanged: Signal<[Player, string, boolean]>;
113
+ readonly OnCooldownEnded: Signal<[Player, string]>;
114
+ readonly OnLeaderboard: Signal<[string, LeaderboardEntry[]]>;
115
+ readonly OnMessage: Signal<[Player, unknown]>;
116
+ /** External ProfileStore implementation; narrow to its own public package type before use. */
117
+ readonly ProfileStore: unknown;
118
+ /** Escape hatch requiring explicit validation/assertion at its boundary. */
119
+ readonly Raw: unknown;
120
+ readonly Stop: (this: void) => void;
121
+ }
122
+ export type ServerData<T, S = {}, C = {}> = ServerAPI<T, C> & ServerStoreMember<S>;
123
+
124
+ /** Partial records for Mock; arrays and Roblox engine datatypes remain whole values. */
125
+ export type MockValues<T> = T extends Datatype | buffer | BigValue | ReadonlyArray<unknown> | ReadonlyMap<unknown, unknown> ? T : T extends object ? { [K in keyof T]?: MockValues<T[K]> } : T;
126
+ export interface ClientAPI<T, C = {}> {
127
+ readonly IsReady: (this: void) => boolean;
128
+ readonly WaitForData: (this: void, timeout?: number) => boolean;
129
+ readonly Batch: (this: void, callback: (this: void) => void) => void;
130
+ readonly Request: RequestFunction<C>;
131
+ readonly RequestOnce: RequestOnceFunction<C>;
132
+ readonly GetLeaderboard: (this: void, name: string, limit?: number) => LeaderboardEntry[];
133
+ readonly GetMyRank: (this: void, name: string) => number | undefined;
134
+ readonly OnLeaderboard: Signal<[string, LeaderboardEntry[]]>;
135
+ readonly GetServiceStatus: (this: void) => Status;
136
+ readonly OnServiceStatus: Signal<[Status]>;
137
+ readonly GetShared: (this: void, playerOrUserId: Player | number) => SharedData<T> | undefined;
138
+ readonly OnSharedChanged: Signal<[number, SharedData<T> | undefined]>;
139
+ readonly Owns: (this: void, key: string) => boolean;
140
+ readonly OwnsAsync: (this: void, key: string, timeout?: number) => boolean;
141
+ readonly ObserveOwned: (this: void, key: string, callback: (this: void, owned: boolean) => void) => Disconnect;
142
+ readonly OnOwnershipChanged: Signal<[string, boolean]>;
143
+ readonly GetProductInfo: (this: void, name: string) => ProductInfo | undefined;
144
+ readonly GetPrice: (this: void, name: string) => number | undefined;
145
+ readonly GetProductInfoAsync: (this: void, name: string, timeout?: number) => ProductInfo | undefined;
146
+ readonly GetPriceAsync: (this: void, name: string, timeout?: number) => number | undefined;
147
+ readonly ObserveProductInfo: (this: void, name: string, callback: (this: void, info: ProductInfo | undefined) => void) => Disconnect;
148
+ readonly PrefetchProductInfo: (this: void, names?: ReadonlyArray<string>) => void;
149
+ readonly RefreshProductInfo: (this: void, name?: string) => void;
150
+ /** Asks the server to validate and prompt for the local player. Success is not a completed purchase; a timeout may occur after the prompt opens. No automatic retry. */
151
+ readonly PromptPurchase: (this: void, name: string) => LuaTuple<[boolean, string | undefined, RequestFailedMarker | undefined]>;
152
+ readonly GetProductState: (this: void, name: string) => ProductState;
153
+ readonly ObserveProductState: (this: void, name: string, callback: (this: void, state: ProductState) => void) => Disconnect;
154
+ readonly GetSaveInfo: (this: void) => SaveInfo;
155
+ readonly GetGiftCredits: (this: void) => { [product: string]: number };
156
+ readonly GetPurchases: (this: void, filter?: PurchaseFilter) => PurchaseEntry[];
157
+ readonly Mock: (this: void, values?: MockValues<InputOf<ClientSchema<T>>>, state?: MockState) => void;
158
+ readonly MockCommand: MockCommand<C>;
159
+ readonly Raw: unknown;
160
+ readonly Stop: (this: void) => void;
161
+ }
162
+ /** Client field writes are local optimistic edits; server-owned roots remain read-only. */
163
+ export type ClientData<T, S = {}, C = {}> = Omit<PlayerData<ClientSchema<T>>, Extract<keyof PlayerData<ClientSchema<T>>, keyof ClientAPI<T, C> | "ServerStore">> & ClientAPI<T, C> & ClientStoreMember<S>;
164
+ export interface Bundle<T, S = {}, C = {}> { readonly Server: ServerData<T, S, C>; readonly Client: ClientData<T, S, C>; }
165
+
166
+ /** Both templates share root field IDs. Broad dictionaries are validated at runtime. */
167
+ type DisjointStoreRoots<T, S> = string extends keyof T | keyof S ? unknown : { [K in keyof T & keyof S]?: never };
168
+ export interface ScribeOptions<T, S = {}, C = {}> {
169
+ Template: T;
170
+ ServerStore?: S & DisjointStoreRoots<NoInfer<T>, NoInfer<S>>;
171
+ Transport?: ScribeTransport | "Default";
172
+ Migrations?: { [version: number]: (this: void, data: UnknownRecord) => void };
173
+ UserOwnsGamePassAsync?: (this: void, userId: number, passId: number) => boolean;
174
+ GetProductInfoAsync?: (this: void, assetId: number, infoType: Enum.InfoType) => ProductInfo | undefined;
175
+ GetPolicyInfoAsync?: (this: void, player: Player) => PolicyInfo | undefined;
176
+ DevMode?: boolean;
177
+ IsRunning?: boolean;
178
+ MigrationShadow?: boolean;
179
+ ImportLegacyData?: (this: void, player: Player, userId: number, migration: MigrationContext) => UnknownRecord | undefined;
180
+ MigrationConcurrency?: number;
181
+ OnPlayerInit?: (this: void, player: Player, rawData: UnknownRecord, isNewProfile: boolean, migration: MigrationContext) => void;
182
+ OnPlayerLeaving?: (this: void, player: Player, data: PlayerData<T>, reason: LifecycleReason) => void;
183
+ ProfileStoreIndex: string;
184
+ ProfileKeyPrefix: string;
185
+ SaveInterval?: number;
186
+ /** A supplied ProfileStore module/module script is an external integration boundary. */
187
+ ProfileStore?: unknown;
188
+ Mode?: "Live" | "Mock" | "NoSave";
189
+ TargetUserId?: number;
190
+ UseMock?: boolean;
191
+ ViewedUserId?: number;
192
+ OverriddenUserId?: number;
193
+ DontSave?: boolean;
194
+ ResetData?: boolean;
195
+ LoadFailurePolicy?: "Kick" | "Wait";
196
+ LoadTimeout?: number;
197
+ EraseJoinTimeout?: number;
198
+ VersionAheadPolicy?: "Kick" | "Allow";
199
+ KickOnSessionEnd?: boolean;
200
+ LoadFailureMessage?: string;
201
+ LegacyImportFailureMessage?: string;
202
+ MigrationFailureMessage?: string;
203
+ VersionAheadMessage?: string;
204
+ SchemaFailureMessage?: string;
205
+ RateLimitedMessage?: string;
206
+ ErasingMessage?: string;
207
+ SessionEndMessage?: string;
208
+ SessionStolenMessage?: string;
209
+ SessionInterruptedMessage?: string;
210
+ Leaderboards?: { [name: string]: LeaderboardConfig<T> };
211
+ PeriodReset?: PeriodResetOptions;
212
+ Products?: { [name: string]: ProductConfig<T> };
213
+ /** Historical products still settle receipts and existing gifts, without offering new sales. */
214
+ RetiredProducts?: { [name: string]: ProductConfig<T> };
215
+ Passes?: { [name: string]: PassConfig };
216
+ Perks?: ReadonlyArray<string>;
217
+ OwnReceipts?: boolean;
218
+ Exchangeable?: { [name: string]: ExchangeableSpec };
219
+ PurchaseLog?: PurchaseLogOptions;
220
+ GiftCooldown?: number;
221
+ GiftMaxPending?: number;
222
+ GiftIntentTTL?: number;
223
+ /** Legacy default for purchase-claim and gift-aim retention; receipt history remains fixed at 30 days. */
224
+ PurchaseIdTTL?: number;
225
+ /** @deprecated Ignored. Completed receipt IDs are no longer evicted to meet a count cap. */
226
+ MaxProcessedPurchaseIds?: number;
227
+ /** Receipt-history admission budget, from 1 to 2097152 bytes (default 1048576). */
228
+ MaxReceiptHistoryBytes?: number;
229
+ PurchaseClaimTTL?: number;
230
+ MaxPurchaseClaims?: number;
231
+ AllowDuplicateGifts?: boolean;
232
+ NoGiftIntentPolicy?: "GrantOrCredit" | "Hold";
233
+ Economy?: EconomyConfig;
234
+ CommandRateLimit?: number;
235
+ RequestTimeout?: number;
236
+ MaxInboundBytes?: number;
237
+ MaxInboundRetainedBytes?: number;
238
+ MaxOutboundBytes?: number;
239
+ MaxInboundFrameRate?: number;
240
+ TransportChannel?: string;
241
+ BoundsPolicy?: "Clamp" | "Reject";
242
+ WipeGuardPolicy?: "Warn" | "Block";
243
+ SchemaPolicy?: "Warn" | "Reject";
244
+ BudgetPolicy?: "Defer";
245
+ WipeGuardShrinkRatio?: number;
246
+ LogLevel?: LogLevel;
247
+ /** Severity retained by GetRecentLogs, independently of console and sink filters. */
248
+ LogRingLevel?: LogLevel;
249
+ LogRingSize?: number;
250
+ StatusThresholds?: StatusThresholds;
251
+ Banner?: boolean;
252
+ StudioHook?: boolean;
253
+ }