@rbxts/scribe 2.6.1 → 2.8.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/README.md +1 -1
- package/Scribe-source-map.json +1 -1
- package/package.json +1 -1
- package/src/Client/init.luau +87 -25
- package/src/Internal/Big.luau +11 -3
- package/src/Internal/Store/ProfileStore.luau +20 -0
- package/src/Internal/Template.luau +2 -1
- package/src/Internal/Version.luau +1 -1
- package/src/Server/Commands.luau +17 -3
- package/src/Server/Monetization.luau +254 -91
- package/src/Server/Persistence.luau +38 -3
- package/src/Server/Replication.luau +108 -68
- package/src/Server/Timed.luau +7 -1
- package/src/Server/init.luau +6 -2
- package/src/Types.luau +11 -2
- package/src/init.luau +294 -125
- package/types/api.d.ts +19 -12
- package/types/common.d.ts +7 -0
- package/types/index.d.ts +1 -0
package/types/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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";
|
|
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, PassTrial, PurchaseFilter, PurchaseEntry, PurchaseLogOptions, ProductInfo, PolicyInfo, ReceiptInfo, EconomyConfig, ExchangeableSpec, ExchangeAPI, LogLevel, StatusThresholds, PeriodResetOptions, MockState } from "./common";
|
|
3
3
|
|
|
4
4
|
export interface LeaderboardConfig<T = unknown> {
|
|
5
5
|
Stat: NumericPaths<T, true>;
|
|
@@ -18,7 +18,8 @@ export interface LeaderboardConfig<T = unknown> {
|
|
|
18
18
|
export interface ProductConfig<T = unknown> {
|
|
19
19
|
Id: number;
|
|
20
20
|
Category?: string;
|
|
21
|
-
|
|
21
|
+
/** Runs on the buyer's data, or the recipient's for gifts. */
|
|
22
|
+
Grant?: (this: void, data: PlayerData<T>, player: Player) => void;
|
|
22
23
|
Grants?: string;
|
|
23
24
|
PaidRandom?: boolean;
|
|
24
25
|
}
|
|
@@ -27,7 +28,8 @@ export interface PurchaseSpec<T = unknown> {
|
|
|
27
28
|
Cost: { Path: NumericPaths<T, true>; Amount: BigOperand };
|
|
28
29
|
Category?: string;
|
|
29
30
|
ItemId: string;
|
|
30
|
-
|
|
31
|
+
/** Runs on the buyer's data. */
|
|
32
|
+
Grant?: (this: void, data: PlayerData<T>, player: Player) => void;
|
|
31
33
|
Meta?: UnknownRecord;
|
|
32
34
|
IdempotencyKey?: string;
|
|
33
35
|
PaidRandom?: boolean;
|
|
@@ -120,8 +122,10 @@ export interface ServerAPI<T, C = {}> {
|
|
|
120
122
|
readonly Owns: (this: void, player: Player, key: string) => boolean;
|
|
121
123
|
/** Verifies uncached pass ownership with Roblox before returning. */
|
|
122
124
|
readonly OwnsAsync: (this: void, player: Player, key: string, timeout?: number) => boolean;
|
|
125
|
+
/** Returns the cached trial if it alone grants access, otherwise `undefined`. */
|
|
126
|
+
readonly GetTrial: (this: void, player: Player, key: string) => PassTrial | undefined;
|
|
123
127
|
/** Reports ownership now and on changes; returns a disconnect function. */
|
|
124
|
-
readonly ObserveOwned: (this: void, player: Player, key: string, callback: (this: void, owned: boolean) => void) => Disconnect;
|
|
128
|
+
readonly ObserveOwned: (this: void, player: Player, key: string, callback: (this: void, owned: boolean, trial: boolean) => void) => Disconnect;
|
|
125
129
|
/** Grants a perk through Scribe's ownership state. */
|
|
126
130
|
readonly GrantPerk: (this: void, player: Player, key: string) => void;
|
|
127
131
|
/** Removes a granted perk from Scribe's ownership state. */
|
|
@@ -153,7 +157,7 @@ export interface ServerAPI<T, C = {}> {
|
|
|
153
157
|
/** Fires when a player receives an unassigned gift credit. */
|
|
154
158
|
readonly OnGiftCredit: Signal<[Player, string]>;
|
|
155
159
|
/** Fires when effective ownership changes after load. */
|
|
156
|
-
readonly OnOwnershipChanged: Signal<[Player, string, boolean]>;
|
|
160
|
+
readonly OnOwnershipChanged: Signal<[Player, string, boolean, boolean]>;
|
|
157
161
|
/** Fires when a cooldown expires during an active session. */
|
|
158
162
|
readonly OnCooldownEnded: Signal<[Player, string]>;
|
|
159
163
|
/** Fires when cached board contents change. */
|
|
@@ -169,7 +173,7 @@ export interface ServerAPI<T, C = {}> {
|
|
|
169
173
|
}
|
|
170
174
|
export type ServerData<T, S = {}, C = {}> = ServerAPI<T, C> & ServerStoreMember<S>;
|
|
171
175
|
|
|
172
|
-
/**
|
|
176
|
+
/** Mock merges records, dictionaries and maps by key. Arrays, sets, Flags and engine datatypes replace whole values. */
|
|
173
177
|
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;
|
|
174
178
|
export interface ClientAPI<T, C = {}> {
|
|
175
179
|
/** Reads snapshot readiness without yielding. */
|
|
@@ -200,10 +204,12 @@ export interface ClientAPI<T, C = {}> {
|
|
|
200
204
|
readonly Owns: (this: void, key: string) => boolean;
|
|
201
205
|
/** Waits for the server's initial ownership sync before reading the mirror. */
|
|
202
206
|
readonly OwnsAsync: (this: void, key: string, timeout?: number) => boolean;
|
|
203
|
-
/**
|
|
204
|
-
readonly
|
|
207
|
+
/** Reads trial-only access from the local mirror after load. */
|
|
208
|
+
readonly GetTrial: (this: void, key: string) => PassTrial | undefined;
|
|
209
|
+
/** Returns a disconnect immediately. Reports current ownership once loaded and on changes. */
|
|
210
|
+
readonly ObserveOwned: (this: void, key: string, callback: (this: void, owned: boolean, trial: boolean) => void) => Disconnect;
|
|
205
211
|
/** Fires for ownership changes after the initial baseline. */
|
|
206
|
-
readonly OnOwnershipChanged: Signal<[string, boolean]>;
|
|
212
|
+
readonly OnOwnershipChanged: Signal<[string, boolean, boolean]>;
|
|
207
213
|
/** Reads cached player-specific marketplace info, fetching on demand. */
|
|
208
214
|
readonly GetProductInfo: (this: void, name: string) => ProductInfo | undefined;
|
|
209
215
|
/** Reads the local player's cached Robux price, or `undefined` while loading. */
|
|
@@ -224,11 +230,11 @@ export interface ClientAPI<T, C = {}> {
|
|
|
224
230
|
readonly GetProductState: (this: void, name: string) => ProductState;
|
|
225
231
|
/** Reports shop state now and on changes; returns a disconnect function. */
|
|
226
232
|
readonly ObserveProductState: (this: void, name: string, callback: (this: void, state: ProductState) => void) => Disconnect;
|
|
227
|
-
/**
|
|
233
|
+
/** Waits for load, then reads the owner's replicated save status. */
|
|
228
234
|
readonly GetSaveInfo: (this: void) => SaveInfo;
|
|
229
|
-
/**
|
|
235
|
+
/** Waits for load, then reads unassigned gift credits. */
|
|
230
236
|
readonly GetGiftCredits: (this: void) => { [product: string]: number };
|
|
231
|
-
/**
|
|
237
|
+
/** Waits for load, then reads the enabled purchase logs. */
|
|
232
238
|
readonly GetPurchases: (this: void, filter?: PurchaseFilter) => PurchaseEntry[];
|
|
233
239
|
/** Seeds local mirror data in edit mode only. */
|
|
234
240
|
readonly Mock: (this: void, values?: MockValues<InputOf<ClientSchema<T>>>, state?: MockState) => void;
|
|
@@ -252,6 +258,7 @@ export interface ScribeOptions<T, S = {}, C = {}> {
|
|
|
252
258
|
Transport?: ScribeTransport | "Default";
|
|
253
259
|
Migrations?: { [version: number]: (this: void, data: UnknownRecord) => void };
|
|
254
260
|
UserOwnsGamePassAsync?: (this: void, userId: number, passId: number) => boolean;
|
|
261
|
+
GetPassOwnershipAsync?: (this: void, player: Player, passId: number) => UnknownRecord;
|
|
255
262
|
GetProductInfoAsync?: (this: void, assetId: number, infoType: Enum.InfoType) => ProductInfo | undefined;
|
|
256
263
|
GetPolicyInfoAsync?: (this: void, player: Player) => PolicyInfo | undefined;
|
|
257
264
|
DevMode?: boolean;
|
package/types/common.d.ts
CHANGED
|
@@ -146,6 +146,9 @@ export type LogCode =
|
|
|
146
146
|
| "RECEIPT_HISTORY_FULL"
|
|
147
147
|
| "OWNERSHIP_CHECK_FAIL"
|
|
148
148
|
| "PASS_PURCHASE_UNCONFIRMED"
|
|
149
|
+
| "PASS_TRIAL_STARTED"
|
|
150
|
+
| "PASS_TRIAL_ENDED"
|
|
151
|
+
| "PASS_TRIAL_READ_FAIL"
|
|
149
152
|
| "PERK_GRANTED"
|
|
150
153
|
| "PERK_REVOKED"
|
|
151
154
|
| "PRODUCT_INFO_FAIL"
|
|
@@ -218,6 +221,7 @@ export type LogCode =
|
|
|
218
221
|
| "LISTENER_ERROR"
|
|
219
222
|
| "ON_PLAYER_INIT_ERROR"
|
|
220
223
|
| "ON_PLAYER_INIT_LEDGER"
|
|
224
|
+
| "ON_PLAYER_INIT_SESSION"
|
|
221
225
|
| "PLAYER_LEAVING_HOOK_SLOW"
|
|
222
226
|
| "SANDBOXED"
|
|
223
227
|
| "SERVER_STARTED"
|
|
@@ -284,6 +288,8 @@ export interface LeaderboardStatusInfo {
|
|
|
284
288
|
export interface LeaderboardSnapshotEntry extends LeaderboardStatusInfo { BundleId: number; Name: string; }
|
|
285
289
|
export interface PassConfig { Id: number; Category?: string; }
|
|
286
290
|
export interface PurchaseFilter { Kind?: "Robux" | "InGame"; Category?: string; ItemId?: string; Since?: number; Limit?: number; }
|
|
291
|
+
/** Expected trial end in Unix seconds, absent if unknown. */
|
|
292
|
+
export interface PassTrial { EndsAt?: number; }
|
|
287
293
|
/** RecordPurchase accepts game-defined fields, so only Kind is universally present. */
|
|
288
294
|
export interface PurchaseEntry extends UnknownRecord {
|
|
289
295
|
Kind: "Robux" | "InGame";
|
|
@@ -370,6 +376,7 @@ export interface PeriodResetOptions { UtcOffset?: number; WeekStart?: "Monday" |
|
|
|
370
376
|
|
|
371
377
|
export interface MockState {
|
|
372
378
|
Perks?: ReadonlyArray<string>;
|
|
379
|
+
Trials?: { [pass: string]: number };
|
|
373
380
|
GiftCredits?: { [product: string]: number };
|
|
374
381
|
PurchaseLogs?: { Robux?: ReadonlyArray<UnknownRecord>; InGame?: ReadonlyArray<UnknownRecord> };
|
|
375
382
|
Leaderboards?: { [name: string]: ReadonlyArray<LeaderboardEntry> };
|
package/types/index.d.ts
CHANGED
|
@@ -234,6 +234,7 @@ declare namespace Scribe {
|
|
|
234
234
|
export type LeaderboardSnapshotEntry = Common.LeaderboardSnapshotEntry;
|
|
235
235
|
export type PassConfig = Common.PassConfig;
|
|
236
236
|
export type PurchaseFilter = Common.PurchaseFilter;
|
|
237
|
+
export type PassTrial = Common.PassTrial;
|
|
237
238
|
export type PurchaseEntry = Common.PurchaseEntry;
|
|
238
239
|
export type PurchaseLogOptions = Common.PurchaseLogOptions;
|
|
239
240
|
export type ProductInfo = Common.ProductInfo;
|