@stamprally/core 0.12.0 → 0.14.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 +13 -0
- package/dist/index.cjs +356 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -4
- package/dist/index.d.ts +51 -4
- package/dist/index.js +354 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -96,6 +96,7 @@ type RewardUnlockCondition = {
|
|
|
96
96
|
};
|
|
97
97
|
type RewardType = "digital" | "in_person";
|
|
98
98
|
type RedemptionMethod = "manual_slide" | "staff_passcode" | "view_only" | "server_claim";
|
|
99
|
+
type InventoryAggregationMode = "shared" | "per_reward";
|
|
99
100
|
interface Reward<TLocale extends string = string> {
|
|
100
101
|
readonly id: string;
|
|
101
102
|
readonly title: LocalizedText<TLocale>;
|
|
@@ -121,6 +122,8 @@ interface AdminRallyConfig<TLocale extends string = string, TMeta extends Record
|
|
|
121
122
|
readonly rewards: ReadonlyArray<Reward<TLocale>>;
|
|
122
123
|
readonly staffPasscode?: string;
|
|
123
124
|
readonly inventory?: Readonly<Record<string, number>>;
|
|
125
|
+
/** How the optional top-level inventory limit is aggregated. */
|
|
126
|
+
readonly inventoryMode?: InventoryAggregationMode;
|
|
124
127
|
readonly serverMetadata?: Readonly<Record<string, unknown>>;
|
|
125
128
|
readonly metadata?: TMeta;
|
|
126
129
|
/** Explicit public metadata name. `metadata` remains supported for compatibility. */
|
|
@@ -147,6 +150,7 @@ interface StampRecord {
|
|
|
147
150
|
readonly acquiredAt: string;
|
|
148
151
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
149
152
|
}
|
|
153
|
+
type SpotStatus = "UNCLAIMED" | "CLAIMED" | "LOCKED" | "VERIFYING";
|
|
150
154
|
type RewardStatus = "LOCKED" | "AVAILABLE" | "CONSUMED" | "EXPIRED";
|
|
151
155
|
interface RewardState {
|
|
152
156
|
readonly rewardId: string;
|
|
@@ -284,6 +288,8 @@ declare class ConfigValidationError extends Error {
|
|
|
284
288
|
readonly name = "ConfigValidationError";
|
|
285
289
|
constructor(errors: ReadonlyArray<ValidationError>);
|
|
286
290
|
}
|
|
291
|
+
/** Validates relationships that can only be checked after all entities exist. */
|
|
292
|
+
declare function validateRallyConfigRelations(config: AdminRallyConfig | PublicRallyConfig): ReadonlyArray<ValidationError>;
|
|
287
293
|
declare function safeParseAdminConfig(input: unknown): ParseResult<AdminRallyConfig>;
|
|
288
294
|
declare function parseAdminConfig(input: unknown): AdminRallyConfig;
|
|
289
295
|
declare function safeParsePublicConfig(input: unknown): ParseResult<PublicRallyConfig>;
|
|
@@ -292,6 +298,11 @@ declare function parsePublicConfig(input: unknown): PublicRallyConfig;
|
|
|
292
298
|
declare function calculateDistanceMeters(aLat: number, aLon: number, bLat: number, bLon: number): number;
|
|
293
299
|
declare function evaluateConditionDetailed(condition: CheckInCondition, context: VerificationContext): Result<ConditionMatch, ConditionMismatch>;
|
|
294
300
|
declare function evaluateCondition(condition: CheckInCondition, context: VerificationContext): boolean;
|
|
301
|
+
/** Derives a viewer-safe spot status without changing the supplied state. */
|
|
302
|
+
declare function evaluateSpotStatus(spot: Pick<SpotItem, "id" | "prerequisites">, state: Pick<UserRallyState, "records">, options?: {
|
|
303
|
+
readonly verifying?: boolean;
|
|
304
|
+
}): SpotStatus;
|
|
305
|
+
declare const getSpotStatus: typeof evaluateSpotStatus;
|
|
295
306
|
|
|
296
307
|
declare function getOrderedSpots<TLocale extends string, TMeta extends Record<string, unknown>>(spots: ReadonlyArray<SpotItem<TLocale, TMeta>>): ReadonlyArray<SpotItem<TLocale, TMeta>>;
|
|
297
308
|
|
|
@@ -380,19 +391,47 @@ interface OfflineQueueOptions {
|
|
|
380
391
|
removeItem?(key: string): void;
|
|
381
392
|
} | null;
|
|
382
393
|
readonly key?: string;
|
|
394
|
+
/** Rally scope used by the default durable key. */
|
|
395
|
+
readonly rallyId?: string;
|
|
396
|
+
/** User scope used by the default durable key. */
|
|
397
|
+
readonly userId?: string | null;
|
|
383
398
|
readonly databaseName?: string;
|
|
384
399
|
readonly conflictPolicy?: SyncConflictPolicy;
|
|
385
400
|
readonly onSyncConflict?: SyncConflictPolicy | ((context: OfflineConflict) => SyncConflictPolicy | Promise<SyncConflictPolicy>);
|
|
401
|
+
/** Enables storage-event/BroadcastChannel synchronization when browser APIs exist. */
|
|
402
|
+
readonly synchronizeInstances?: boolean;
|
|
386
403
|
}
|
|
387
404
|
interface OfflineConflict {
|
|
388
405
|
readonly operation: OfflineOperation;
|
|
389
406
|
readonly localState: UserRallyState;
|
|
390
407
|
readonly serverState: UserRallyState;
|
|
391
408
|
}
|
|
392
|
-
type OfflineSender = (operation: OfflineOperation) => Promise<OfflineResult | OfflineConflictResult>;
|
|
409
|
+
type OfflineSender = (operation: OfflineOperation) => Promise<OfflineResult | OfflineConflictResult | OfflineOperationResponse>;
|
|
410
|
+
type OfflineOperationStatus = "ACCEPTED" | "REJECTED_PERMANENT" | "RETRYABLE_ERROR";
|
|
411
|
+
interface OfflineOperationError {
|
|
412
|
+
readonly code: string;
|
|
413
|
+
readonly message: string;
|
|
414
|
+
readonly [key: string]: unknown;
|
|
415
|
+
}
|
|
416
|
+
type OfflineOperationResponse = {
|
|
417
|
+
readonly status: "ACCEPTED";
|
|
418
|
+
readonly result?: OfflineResult | OfflineConflictResult;
|
|
419
|
+
readonly state?: UserRallyState;
|
|
420
|
+
} | {
|
|
421
|
+
readonly status: "REJECTED_PERMANENT";
|
|
422
|
+
readonly error?: ClientError | OfflineOperationError;
|
|
423
|
+
readonly reason?: ClientError | OfflineOperationError;
|
|
424
|
+
readonly state?: UserRallyState;
|
|
425
|
+
} | {
|
|
426
|
+
readonly status: "RETRYABLE_ERROR";
|
|
427
|
+
readonly error?: ClientError | OfflineOperationError;
|
|
428
|
+
readonly reason?: ClientError | OfflineOperationError;
|
|
429
|
+
};
|
|
393
430
|
interface OfflineSyncResultEvent {
|
|
394
431
|
readonly operation: OfflineOperation;
|
|
395
|
-
readonly result
|
|
432
|
+
readonly result?: OfflineResult | OfflineConflictResult;
|
|
433
|
+
readonly status?: OfflineOperationStatus;
|
|
434
|
+
readonly error?: ClientError | OfflineOperationError;
|
|
396
435
|
readonly state?: UserRallyState;
|
|
397
436
|
}
|
|
398
437
|
type OfflineSyncResultListener = (event: OfflineSyncResultEvent) => void | Promise<void>;
|
|
@@ -420,8 +459,16 @@ declare class OfflineQueue {
|
|
|
420
459
|
get error(): Error | null;
|
|
421
460
|
get operations(): ReadonlyArray<OfflineOperation>;
|
|
422
461
|
get conflictPolicy(): SyncConflictPolicy;
|
|
462
|
+
get storageKey(): string;
|
|
463
|
+
get rallyId(): string | undefined;
|
|
464
|
+
get userId(): string | null;
|
|
423
465
|
setSyncResultListener(listener: OfflineSyncResultListener | undefined): void;
|
|
424
466
|
initialize(): Promise<void>;
|
|
467
|
+
/** Releases browser listeners when the queue is no longer used. */
|
|
468
|
+
dispose(): void;
|
|
469
|
+
/** Selects a rally/user queue scope and loads its pending operations. */
|
|
470
|
+
setScope(rallyId: string, userId: string | null): Promise<void>;
|
|
471
|
+
switchUser(newUserId: string | null): Promise<void>;
|
|
425
472
|
setSender(sender: OfflineSender): void;
|
|
426
473
|
enqueue(operation: OfflineOperation): Promise<void>;
|
|
427
474
|
enqueueCheckIn(request: CheckInRequest): Promise<void>;
|
|
@@ -548,7 +595,7 @@ type ClientEvent = {
|
|
|
548
595
|
readonly state: UserRallyState;
|
|
549
596
|
} | {
|
|
550
597
|
readonly type: "error";
|
|
551
|
-
readonly error: ClientError;
|
|
598
|
+
readonly error: ClientError | OfflineOperationError;
|
|
552
599
|
};
|
|
553
600
|
type ClientListener = (state: UserRallyState) => void;
|
|
554
601
|
type ClientEventListener = (event: ClientEvent) => void;
|
|
@@ -717,4 +764,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
|
|
|
717
764
|
declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
|
|
718
765
|
declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
|
|
719
766
|
|
|
720
|
-
export { type AdminRallyConfig, type CheckInCondition, type CheckInOptions, type CheckInRequest, type CheckInResult, type CheckInSuccess, type ClaimOptions, type ClaimRequest, type ClaimResult, type ClaimSuccess, type ClaimTicketOptions, type ClientError, type ClientEvent, type ClientEventListener, type ClientListener, type ClientOptions, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, ConfigValidationError, type ConsumeResult, type ConsumeRewardParams, type CustomValidationContext, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type IndexedDBOfflineQueueOptions, IndexedDBOfflineQueueStorage, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MergeConflictOptions, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflict, type OfflineConflictResult, type OfflineOperation, OfflineQueue, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineSyncResultEvent, type OfflineSyncResultListener, type ParseResult, type PasscodeCondition$1 as PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicConfigSafety, type PublicRallyConfig, type PublicReward, type PublicSpotItem, type QrDetectorOptions, type QrVerificationContext, type RallyConfig, type RallySnapshot, type RedemptionMethod, type Result, type Reward, type RewardConsumeError, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotItem, type StampError, StampRallyClient, type StampRallyProgress, type StampRallyState, type StampRecord, type StampStorage, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageWarningHandler, type SupportedLocale, type SyncAdapter, type SyncConflictPolicy, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, exportProgressToken, getCurrentGeoContext, getOrderedSpots, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
|
767
|
+
export { type AdminRallyConfig, type CheckInCondition, type CheckInOptions, type CheckInRequest, type CheckInResult, type CheckInSuccess, type ClaimOptions, type ClaimRequest, type ClaimResult, type ClaimSuccess, type ClaimTicketOptions, type ClientError, type ClientEvent, type ClientEventListener, type ClientListener, type ClientOptions, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, ConfigValidationError, type ConsumeResult, type ConsumeRewardParams, type CustomValidationContext, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type IndexedDBOfflineQueueOptions, IndexedDBOfflineQueueStorage, type InventoryAggregationMode, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MergeConflictOptions, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflict, type OfflineConflictResult, type OfflineOperation, type OfflineOperationError, type OfflineOperationResponse, type OfflineOperationStatus, OfflineQueue, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineSyncResultEvent, type OfflineSyncResultListener, type ParseResult, type PasscodeCondition$1 as PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicConfigSafety, type PublicRallyConfig, type PublicReward, type PublicSpotItem, type QrDetectorOptions, type QrVerificationContext, type RallyConfig, type RallySnapshot, type RedemptionMethod, type Result, type Reward, type RewardConsumeError, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotItem, type SpotStatus, type StampError, StampRallyClient, type StampRallyProgress, type StampRallyState, type StampRecord, type StampStorage, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageWarningHandler, type SupportedLocale, type SyncAdapter, type SyncConflictPolicy, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ type RewardUnlockCondition = {
|
|
|
96
96
|
};
|
|
97
97
|
type RewardType = "digital" | "in_person";
|
|
98
98
|
type RedemptionMethod = "manual_slide" | "staff_passcode" | "view_only" | "server_claim";
|
|
99
|
+
type InventoryAggregationMode = "shared" | "per_reward";
|
|
99
100
|
interface Reward<TLocale extends string = string> {
|
|
100
101
|
readonly id: string;
|
|
101
102
|
readonly title: LocalizedText<TLocale>;
|
|
@@ -121,6 +122,8 @@ interface AdminRallyConfig<TLocale extends string = string, TMeta extends Record
|
|
|
121
122
|
readonly rewards: ReadonlyArray<Reward<TLocale>>;
|
|
122
123
|
readonly staffPasscode?: string;
|
|
123
124
|
readonly inventory?: Readonly<Record<string, number>>;
|
|
125
|
+
/** How the optional top-level inventory limit is aggregated. */
|
|
126
|
+
readonly inventoryMode?: InventoryAggregationMode;
|
|
124
127
|
readonly serverMetadata?: Readonly<Record<string, unknown>>;
|
|
125
128
|
readonly metadata?: TMeta;
|
|
126
129
|
/** Explicit public metadata name. `metadata` remains supported for compatibility. */
|
|
@@ -147,6 +150,7 @@ interface StampRecord {
|
|
|
147
150
|
readonly acquiredAt: string;
|
|
148
151
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
149
152
|
}
|
|
153
|
+
type SpotStatus = "UNCLAIMED" | "CLAIMED" | "LOCKED" | "VERIFYING";
|
|
150
154
|
type RewardStatus = "LOCKED" | "AVAILABLE" | "CONSUMED" | "EXPIRED";
|
|
151
155
|
interface RewardState {
|
|
152
156
|
readonly rewardId: string;
|
|
@@ -284,6 +288,8 @@ declare class ConfigValidationError extends Error {
|
|
|
284
288
|
readonly name = "ConfigValidationError";
|
|
285
289
|
constructor(errors: ReadonlyArray<ValidationError>);
|
|
286
290
|
}
|
|
291
|
+
/** Validates relationships that can only be checked after all entities exist. */
|
|
292
|
+
declare function validateRallyConfigRelations(config: AdminRallyConfig | PublicRallyConfig): ReadonlyArray<ValidationError>;
|
|
287
293
|
declare function safeParseAdminConfig(input: unknown): ParseResult<AdminRallyConfig>;
|
|
288
294
|
declare function parseAdminConfig(input: unknown): AdminRallyConfig;
|
|
289
295
|
declare function safeParsePublicConfig(input: unknown): ParseResult<PublicRallyConfig>;
|
|
@@ -292,6 +298,11 @@ declare function parsePublicConfig(input: unknown): PublicRallyConfig;
|
|
|
292
298
|
declare function calculateDistanceMeters(aLat: number, aLon: number, bLat: number, bLon: number): number;
|
|
293
299
|
declare function evaluateConditionDetailed(condition: CheckInCondition, context: VerificationContext): Result<ConditionMatch, ConditionMismatch>;
|
|
294
300
|
declare function evaluateCondition(condition: CheckInCondition, context: VerificationContext): boolean;
|
|
301
|
+
/** Derives a viewer-safe spot status without changing the supplied state. */
|
|
302
|
+
declare function evaluateSpotStatus(spot: Pick<SpotItem, "id" | "prerequisites">, state: Pick<UserRallyState, "records">, options?: {
|
|
303
|
+
readonly verifying?: boolean;
|
|
304
|
+
}): SpotStatus;
|
|
305
|
+
declare const getSpotStatus: typeof evaluateSpotStatus;
|
|
295
306
|
|
|
296
307
|
declare function getOrderedSpots<TLocale extends string, TMeta extends Record<string, unknown>>(spots: ReadonlyArray<SpotItem<TLocale, TMeta>>): ReadonlyArray<SpotItem<TLocale, TMeta>>;
|
|
297
308
|
|
|
@@ -380,19 +391,47 @@ interface OfflineQueueOptions {
|
|
|
380
391
|
removeItem?(key: string): void;
|
|
381
392
|
} | null;
|
|
382
393
|
readonly key?: string;
|
|
394
|
+
/** Rally scope used by the default durable key. */
|
|
395
|
+
readonly rallyId?: string;
|
|
396
|
+
/** User scope used by the default durable key. */
|
|
397
|
+
readonly userId?: string | null;
|
|
383
398
|
readonly databaseName?: string;
|
|
384
399
|
readonly conflictPolicy?: SyncConflictPolicy;
|
|
385
400
|
readonly onSyncConflict?: SyncConflictPolicy | ((context: OfflineConflict) => SyncConflictPolicy | Promise<SyncConflictPolicy>);
|
|
401
|
+
/** Enables storage-event/BroadcastChannel synchronization when browser APIs exist. */
|
|
402
|
+
readonly synchronizeInstances?: boolean;
|
|
386
403
|
}
|
|
387
404
|
interface OfflineConflict {
|
|
388
405
|
readonly operation: OfflineOperation;
|
|
389
406
|
readonly localState: UserRallyState;
|
|
390
407
|
readonly serverState: UserRallyState;
|
|
391
408
|
}
|
|
392
|
-
type OfflineSender = (operation: OfflineOperation) => Promise<OfflineResult | OfflineConflictResult>;
|
|
409
|
+
type OfflineSender = (operation: OfflineOperation) => Promise<OfflineResult | OfflineConflictResult | OfflineOperationResponse>;
|
|
410
|
+
type OfflineOperationStatus = "ACCEPTED" | "REJECTED_PERMANENT" | "RETRYABLE_ERROR";
|
|
411
|
+
interface OfflineOperationError {
|
|
412
|
+
readonly code: string;
|
|
413
|
+
readonly message: string;
|
|
414
|
+
readonly [key: string]: unknown;
|
|
415
|
+
}
|
|
416
|
+
type OfflineOperationResponse = {
|
|
417
|
+
readonly status: "ACCEPTED";
|
|
418
|
+
readonly result?: OfflineResult | OfflineConflictResult;
|
|
419
|
+
readonly state?: UserRallyState;
|
|
420
|
+
} | {
|
|
421
|
+
readonly status: "REJECTED_PERMANENT";
|
|
422
|
+
readonly error?: ClientError | OfflineOperationError;
|
|
423
|
+
readonly reason?: ClientError | OfflineOperationError;
|
|
424
|
+
readonly state?: UserRallyState;
|
|
425
|
+
} | {
|
|
426
|
+
readonly status: "RETRYABLE_ERROR";
|
|
427
|
+
readonly error?: ClientError | OfflineOperationError;
|
|
428
|
+
readonly reason?: ClientError | OfflineOperationError;
|
|
429
|
+
};
|
|
393
430
|
interface OfflineSyncResultEvent {
|
|
394
431
|
readonly operation: OfflineOperation;
|
|
395
|
-
readonly result
|
|
432
|
+
readonly result?: OfflineResult | OfflineConflictResult;
|
|
433
|
+
readonly status?: OfflineOperationStatus;
|
|
434
|
+
readonly error?: ClientError | OfflineOperationError;
|
|
396
435
|
readonly state?: UserRallyState;
|
|
397
436
|
}
|
|
398
437
|
type OfflineSyncResultListener = (event: OfflineSyncResultEvent) => void | Promise<void>;
|
|
@@ -420,8 +459,16 @@ declare class OfflineQueue {
|
|
|
420
459
|
get error(): Error | null;
|
|
421
460
|
get operations(): ReadonlyArray<OfflineOperation>;
|
|
422
461
|
get conflictPolicy(): SyncConflictPolicy;
|
|
462
|
+
get storageKey(): string;
|
|
463
|
+
get rallyId(): string | undefined;
|
|
464
|
+
get userId(): string | null;
|
|
423
465
|
setSyncResultListener(listener: OfflineSyncResultListener | undefined): void;
|
|
424
466
|
initialize(): Promise<void>;
|
|
467
|
+
/** Releases browser listeners when the queue is no longer used. */
|
|
468
|
+
dispose(): void;
|
|
469
|
+
/** Selects a rally/user queue scope and loads its pending operations. */
|
|
470
|
+
setScope(rallyId: string, userId: string | null): Promise<void>;
|
|
471
|
+
switchUser(newUserId: string | null): Promise<void>;
|
|
425
472
|
setSender(sender: OfflineSender): void;
|
|
426
473
|
enqueue(operation: OfflineOperation): Promise<void>;
|
|
427
474
|
enqueueCheckIn(request: CheckInRequest): Promise<void>;
|
|
@@ -548,7 +595,7 @@ type ClientEvent = {
|
|
|
548
595
|
readonly state: UserRallyState;
|
|
549
596
|
} | {
|
|
550
597
|
readonly type: "error";
|
|
551
|
-
readonly error: ClientError;
|
|
598
|
+
readonly error: ClientError | OfflineOperationError;
|
|
552
599
|
};
|
|
553
600
|
type ClientListener = (state: UserRallyState) => void;
|
|
554
601
|
type ClientEventListener = (event: ClientEvent) => void;
|
|
@@ -717,4 +764,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
|
|
|
717
764
|
declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
|
|
718
765
|
declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
|
|
719
766
|
|
|
720
|
-
export { type AdminRallyConfig, type CheckInCondition, type CheckInOptions, type CheckInRequest, type CheckInResult, type CheckInSuccess, type ClaimOptions, type ClaimRequest, type ClaimResult, type ClaimSuccess, type ClaimTicketOptions, type ClientError, type ClientEvent, type ClientEventListener, type ClientListener, type ClientOptions, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, ConfigValidationError, type ConsumeResult, type ConsumeRewardParams, type CustomValidationContext, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type IndexedDBOfflineQueueOptions, IndexedDBOfflineQueueStorage, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MergeConflictOptions, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflict, type OfflineConflictResult, type OfflineOperation, OfflineQueue, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineSyncResultEvent, type OfflineSyncResultListener, type ParseResult, type PasscodeCondition$1 as PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicConfigSafety, type PublicRallyConfig, type PublicReward, type PublicSpotItem, type QrDetectorOptions, type QrVerificationContext, type RallyConfig, type RallySnapshot, type RedemptionMethod, type Result, type Reward, type RewardConsumeError, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotItem, type StampError, StampRallyClient, type StampRallyProgress, type StampRallyState, type StampRecord, type StampStorage, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageWarningHandler, type SupportedLocale, type SyncAdapter, type SyncConflictPolicy, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, exportProgressToken, getCurrentGeoContext, getOrderedSpots, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
|
767
|
+
export { type AdminRallyConfig, type CheckInCondition, type CheckInOptions, type CheckInRequest, type CheckInResult, type CheckInSuccess, type ClaimOptions, type ClaimRequest, type ClaimResult, type ClaimSuccess, type ClaimTicketOptions, type ClientError, type ClientEvent, type ClientEventListener, type ClientListener, type ClientOptions, type CompositeConditionFailure, type ConditionMatch, type ConditionMismatch, ConfigValidationError, type ConsumeResult, type ConsumeRewardParams, type CustomValidationContext, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type IndexedDBOfflineQueueOptions, IndexedDBOfflineQueueStorage, type InventoryAggregationMode, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MergeConflictOptions, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflict, type OfflineConflictResult, type OfflineOperation, type OfflineOperationError, type OfflineOperationResponse, type OfflineOperationStatus, OfflineQueue, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineSyncResultEvent, type OfflineSyncResultListener, type ParseResult, type PasscodeCondition$1 as PasscodeCondition, type ProcessStampValue, type PublicCheckInCondition, type PublicConfigSafety, type PublicRallyConfig, type PublicReward, type PublicSpotItem, type QrDetectorOptions, type QrVerificationContext, type RallyConfig, type RallySnapshot, type RedemptionMethod, type Result, type Reward, type RewardConsumeError, type RewardState, type RewardStatus, type RewardType, type RewardUnlockCondition, type SecureTokenError, type SecureTokenErrorCode, type SecureTokenOptions, type SecureTokenPayload, type SecureTokenSecretKey, type SecureTokenVerification, type SheetTheme, type SlotShape, type SnapshotSecretKey, type SnapshotTokenError, type SnapshotTokenErrorCode, type SnapshotTokenPayload, type SnapshotTokenVerification, type SpotItem, type SpotStatus, type StampError, StampRallyClient, type StampRallyProgress, type StampRallyState, type StampRecord, type StampStorage, StorageAdapterError, type StorageAdapterErrorCode, type StorageLike, type StorageOperation, type StorageWarningHandler, type SupportedLocale, type SyncAdapter, type SyncConflictPolicy, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
|