@stamprally/core 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -346,32 +346,22 @@ declare function rebuildUserStateFromLog(options: RebuildUserStateOptions): User
346
346
  declare function rebuildUserStateLog(baseline: UserRallyState, operations: ReadonlyArray<OfflineOperation>, config?: AdminRallyConfig | PublicRallyConfig): RebuildUserStateResult;
347
347
 
348
348
  type QueueOperationStatus = "PENDING" | "IN_FLIGHT" | "ACCEPTED" | "REJECTED_PERMANENT" | "FAILED_RETRYABLE";
349
- type OfflineStorageCapability = "indexeddb" | "localstorage" | "memory" | "custom" | "volatile_single_tab";
349
+ type OfflineStorageCapability = "indexeddb" | "localstorage" | "memory" | "custom" | "disabled" | "volatile_single_tab";
350
350
  type MultiTabSyncCapability = "supported_web_locks" | "disabled_unsafe_environment";
351
351
  type QueueCapabilityMode = "persistent" | "volatile_memory";
352
352
  type LegacyQueueCapability = "persistent" | "volatile";
353
- interface QueueCapability {
354
- /** 永続性の状態。永続ストレージの種類は `storage` で確認できます。 */
355
- readonly mode: QueueCapabilityMode;
356
- /** 複数タブ排他同期の対応レベル。 */
357
- readonly multiTabSync: MultiTabSyncCapability;
358
- /**
359
- * @deprecated `mode === "persistent"` を使用してください。永続ストレージを利用できるかを
360
- * 示す移行用の互換フラグです。
361
- */
353
+ type LegacyQueueCapabilityString = "indexeddb" | "localstorage" | "memory" | "custom" | "disabled";
354
+ interface QueueCapabilitiesDetail {
355
+ readonly storageType: "indexeddb" | "localstorage" | "memory" | "custom" | "none";
362
356
  readonly isPersistent: boolean;
363
- /**
364
- * @deprecated `mode` と `multiTabSync` を使用してください。`persistent` は
365
- * `mode === "persistent"`、`volatile` `mode === "volatile_memory"` に対応します。
366
- */
367
- readonly legacy: LegacyQueueCapability;
368
- /** 実際に選択されたストレージの種類。 */
369
- readonly storage: OfflineStorageCapability;
370
- }
371
- /** @deprecated Use QueueCapability. */
372
- type OfflineQueueCapability = QueueCapability;
373
- /** @deprecated Use `capability.mode` and `capability.multiTabSync`. */
374
- declare function getLegacyQueueCapability(capability: QueueCapability): LegacyQueueCapability;
357
+ readonly multiTabSync: MultiTabSyncCapability;
358
+ }
359
+ /** The legacy string exposed by `queueCapability`. */
360
+ type QueueCapability = LegacyQueueCapabilityString;
361
+ /** @deprecated Use LegacyQueueCapabilityString. */
362
+ type OfflineQueueCapability = LegacyQueueCapabilityString;
363
+ /** @deprecated Use the string value of `queueCapability` directly. */
364
+ declare function getLegacyQueueCapability(capability: LegacyQueueCapabilityString | QueueCapabilitiesDetail): LegacyQueueCapability;
375
365
  type OfflineOperation = {
376
366
  readonly kind: "checkIn";
377
367
  readonly request: CheckInRequest;
@@ -499,6 +489,7 @@ declare class OfflineQueue {
499
489
  get syncState(): SyncState;
500
490
  get pendingCount(): number;
501
491
  get queueCapability(): QueueCapability;
492
+ get queueCapabilities(): QueueCapabilitiesDetail;
502
493
  get storageCapability(): OfflineStorageCapability;
503
494
  get isStoragePersistent(): boolean;
504
495
  get rejectedHistory(): ReadonlyArray<RejectedOperationHistoryEntry>;
@@ -566,6 +557,12 @@ type ConflictResolutionPolicy = "authoritative_replay";
566
557
  /** Uses the server snapshot as the immutable replay baseline. */
567
558
  declare function resolveRallyStateConflict(serverState: UserRallyState, _localState: UserRallyState): UserRallyState;
568
559
 
560
+ interface DeterministicallySortableOperation {
561
+ readonly operationId: string;
562
+ readonly timestamp: number;
563
+ }
564
+ /** Sorts operations independently of queue insertion order or network arrival order. */
565
+ declare function sortOperationsDeterministically<T extends DeterministicallySortableOperation>(operations: ReadonlyArray<T>): T[];
569
566
  type RewardConsumeError = {
570
567
  readonly code: "NOT_AVAILABLE" | "ALREADY_CONSUMED" | "OUT_OF_STOCK" | "REWARD_NOT_FOUND";
571
568
  readonly rewardId: string;
@@ -788,7 +785,7 @@ interface ClientOptions {
788
785
  readonly clock?: () => string;
789
786
  readonly userId?: string | null;
790
787
  readonly anonymousSessionId?: string;
791
- readonly offlineQueue?: OfflineQueue;
788
+ readonly offlineQueue?: OfflineQueue | false;
792
789
  }
793
790
  type StorageOrOptions = StampStorage | ClientOptions;
794
791
  declare class StampRallyClient {
@@ -803,6 +800,7 @@ declare class StampRallyClient {
803
800
  get rejectedHistory(): ReadonlyArray<RejectedOperationHistoryEntry>;
804
801
  getSyncRevision(): number;
805
802
  get queueCapability(): QueueCapability;
803
+ get queueCapabilities(): QueueCapabilitiesDetail;
806
804
  get storageCapability(): OfflineStorageCapability;
807
805
  get isStoragePersistent(): boolean;
808
806
  discardRejected(operationId: string): Promise<boolean>;
@@ -931,4 +929,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
931
929
  declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
932
930
  declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
933
931
 
934
- 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 ConflictResolutionPolicy, 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, type LegacyQueueCapability, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MultiTabSyncCapability, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflictResult, type OfflineOperation, type OfflineOperationError, type OfflineOperationLifecycleStatus, type OfflineOperationResponse, type OfflineOperationStatus, OfflineQueue, type OfflineQueueCapability, type OfflineQueueCapabilityWarning, type OfflineQueueChangeListener, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineStorageCapability, 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 QueueCapability, type QueueCapabilityMode, type QueueOperationStatus, type RallyConfig, type RallyInventory, type RallyInventoryState, type RallySnapshot, type RebuildUserStateOptions, type RebuildUserStateResult, type RedemptionMethod, type RejectedOperation, type RejectedOperationHistoryEntry, 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 SyncEventListener, type SyncLifecycleEvent, type SyncOperationAction, type SyncOperationResult, type SyncProgressResponse, type SyncRetryOptions, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createAnonymousSessionId, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getLegacyQueueCapability, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, offlineOperationId, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, rebuildUserStateFromLog, rebuildUserStateLog, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, rollbackOptimisticOperation, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
932
+ 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 ConflictResolutionPolicy, type ConsumeResult, type ConsumeRewardParams, type CustomValidationContext, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type DeterministicallySortableOperation, type ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type IndexedDBOfflineQueueOptions, IndexedDBOfflineQueueStorage, type InventoryAggregationMode, type LegacyQueueCapability, type LegacyQueueCapabilityString, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MultiTabSyncCapability, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflictResult, type OfflineOperation, type OfflineOperationError, type OfflineOperationLifecycleStatus, type OfflineOperationResponse, type OfflineOperationStatus, OfflineQueue, type OfflineQueueCapability, type OfflineQueueCapabilityWarning, type OfflineQueueChangeListener, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineStorageCapability, 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 QueueCapabilitiesDetail, type QueueCapability, type QueueCapabilityMode, type QueueOperationStatus, type RallyConfig, type RallyInventory, type RallyInventoryState, type RallySnapshot, type RebuildUserStateOptions, type RebuildUserStateResult, type RedemptionMethod, type RejectedOperation, type RejectedOperationHistoryEntry, 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 SyncEventListener, type SyncLifecycleEvent, type SyncOperationAction, type SyncOperationResult, type SyncProgressResponse, type SyncRetryOptions, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createAnonymousSessionId, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getLegacyQueueCapability, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, offlineOperationId, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, rebuildUserStateFromLog, rebuildUserStateLog, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, rollbackOptimisticOperation, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, sortOperationsDeterministically, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
package/dist/index.d.ts CHANGED
@@ -346,32 +346,22 @@ declare function rebuildUserStateFromLog(options: RebuildUserStateOptions): User
346
346
  declare function rebuildUserStateLog(baseline: UserRallyState, operations: ReadonlyArray<OfflineOperation>, config?: AdminRallyConfig | PublicRallyConfig): RebuildUserStateResult;
347
347
 
348
348
  type QueueOperationStatus = "PENDING" | "IN_FLIGHT" | "ACCEPTED" | "REJECTED_PERMANENT" | "FAILED_RETRYABLE";
349
- type OfflineStorageCapability = "indexeddb" | "localstorage" | "memory" | "custom" | "volatile_single_tab";
349
+ type OfflineStorageCapability = "indexeddb" | "localstorage" | "memory" | "custom" | "disabled" | "volatile_single_tab";
350
350
  type MultiTabSyncCapability = "supported_web_locks" | "disabled_unsafe_environment";
351
351
  type QueueCapabilityMode = "persistent" | "volatile_memory";
352
352
  type LegacyQueueCapability = "persistent" | "volatile";
353
- interface QueueCapability {
354
- /** 永続性の状態。永続ストレージの種類は `storage` で確認できます。 */
355
- readonly mode: QueueCapabilityMode;
356
- /** 複数タブ排他同期の対応レベル。 */
357
- readonly multiTabSync: MultiTabSyncCapability;
358
- /**
359
- * @deprecated `mode === "persistent"` を使用してください。永続ストレージを利用できるかを
360
- * 示す移行用の互換フラグです。
361
- */
353
+ type LegacyQueueCapabilityString = "indexeddb" | "localstorage" | "memory" | "custom" | "disabled";
354
+ interface QueueCapabilitiesDetail {
355
+ readonly storageType: "indexeddb" | "localstorage" | "memory" | "custom" | "none";
362
356
  readonly isPersistent: boolean;
363
- /**
364
- * @deprecated `mode` と `multiTabSync` を使用してください。`persistent` は
365
- * `mode === "persistent"`、`volatile` `mode === "volatile_memory"` に対応します。
366
- */
367
- readonly legacy: LegacyQueueCapability;
368
- /** 実際に選択されたストレージの種類。 */
369
- readonly storage: OfflineStorageCapability;
370
- }
371
- /** @deprecated Use QueueCapability. */
372
- type OfflineQueueCapability = QueueCapability;
373
- /** @deprecated Use `capability.mode` and `capability.multiTabSync`. */
374
- declare function getLegacyQueueCapability(capability: QueueCapability): LegacyQueueCapability;
357
+ readonly multiTabSync: MultiTabSyncCapability;
358
+ }
359
+ /** The legacy string exposed by `queueCapability`. */
360
+ type QueueCapability = LegacyQueueCapabilityString;
361
+ /** @deprecated Use LegacyQueueCapabilityString. */
362
+ type OfflineQueueCapability = LegacyQueueCapabilityString;
363
+ /** @deprecated Use the string value of `queueCapability` directly. */
364
+ declare function getLegacyQueueCapability(capability: LegacyQueueCapabilityString | QueueCapabilitiesDetail): LegacyQueueCapability;
375
365
  type OfflineOperation = {
376
366
  readonly kind: "checkIn";
377
367
  readonly request: CheckInRequest;
@@ -499,6 +489,7 @@ declare class OfflineQueue {
499
489
  get syncState(): SyncState;
500
490
  get pendingCount(): number;
501
491
  get queueCapability(): QueueCapability;
492
+ get queueCapabilities(): QueueCapabilitiesDetail;
502
493
  get storageCapability(): OfflineStorageCapability;
503
494
  get isStoragePersistent(): boolean;
504
495
  get rejectedHistory(): ReadonlyArray<RejectedOperationHistoryEntry>;
@@ -566,6 +557,12 @@ type ConflictResolutionPolicy = "authoritative_replay";
566
557
  /** Uses the server snapshot as the immutable replay baseline. */
567
558
  declare function resolveRallyStateConflict(serverState: UserRallyState, _localState: UserRallyState): UserRallyState;
568
559
 
560
+ interface DeterministicallySortableOperation {
561
+ readonly operationId: string;
562
+ readonly timestamp: number;
563
+ }
564
+ /** Sorts operations independently of queue insertion order or network arrival order. */
565
+ declare function sortOperationsDeterministically<T extends DeterministicallySortableOperation>(operations: ReadonlyArray<T>): T[];
569
566
  type RewardConsumeError = {
570
567
  readonly code: "NOT_AVAILABLE" | "ALREADY_CONSUMED" | "OUT_OF_STOCK" | "REWARD_NOT_FOUND";
571
568
  readonly rewardId: string;
@@ -788,7 +785,7 @@ interface ClientOptions {
788
785
  readonly clock?: () => string;
789
786
  readonly userId?: string | null;
790
787
  readonly anonymousSessionId?: string;
791
- readonly offlineQueue?: OfflineQueue;
788
+ readonly offlineQueue?: OfflineQueue | false;
792
789
  }
793
790
  type StorageOrOptions = StampStorage | ClientOptions;
794
791
  declare class StampRallyClient {
@@ -803,6 +800,7 @@ declare class StampRallyClient {
803
800
  get rejectedHistory(): ReadonlyArray<RejectedOperationHistoryEntry>;
804
801
  getSyncRevision(): number;
805
802
  get queueCapability(): QueueCapability;
803
+ get queueCapabilities(): QueueCapabilitiesDetail;
806
804
  get storageCapability(): OfflineStorageCapability;
807
805
  get isStoragePersistent(): boolean;
808
806
  discardRejected(operationId: string): Promise<boolean>;
@@ -931,4 +929,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
931
929
  declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
932
930
  declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
933
931
 
934
- 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 ConflictResolutionPolicy, 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, type LegacyQueueCapability, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MultiTabSyncCapability, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflictResult, type OfflineOperation, type OfflineOperationError, type OfflineOperationLifecycleStatus, type OfflineOperationResponse, type OfflineOperationStatus, OfflineQueue, type OfflineQueueCapability, type OfflineQueueCapabilityWarning, type OfflineQueueChangeListener, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineStorageCapability, 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 QueueCapability, type QueueCapabilityMode, type QueueOperationStatus, type RallyConfig, type RallyInventory, type RallyInventoryState, type RallySnapshot, type RebuildUserStateOptions, type RebuildUserStateResult, type RedemptionMethod, type RejectedOperation, type RejectedOperationHistoryEntry, 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 SyncEventListener, type SyncLifecycleEvent, type SyncOperationAction, type SyncOperationResult, type SyncProgressResponse, type SyncRetryOptions, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createAnonymousSessionId, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getLegacyQueueCapability, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, offlineOperationId, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, rebuildUserStateFromLog, rebuildUserStateLog, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, rollbackOptimisticOperation, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
932
+ 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 ConflictResolutionPolicy, type ConsumeResult, type ConsumeRewardParams, type CustomValidationContext, type CustomValidator, DEFAULT_SHEET_THEME, type DetectorError, type DetectorErrorCode, type DetectorKind, type DetectorResult, type DeterministicallySortableOperation, type ExternalReference, type FontFamily, type GeoDetectorOptions, type GeoVerificationContext, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, type IndexedDBAdapterOptions, type IndexedDBOfflineQueueOptions, IndexedDBOfflineQueueStorage, type InventoryAggregationMode, type LegacyQueueCapability, type LegacyQueueCapabilityString, LocalStorageAdapter, type LocalStorageAdapterOptions, type LocalStorageFailureMode, type LocaleDictionary, type LocalizedString, type LocalizedText, type MultiTabSyncCapability, type NfcDetectorOptions, type NfcVerificationContext, type OfflineConflictResult, type OfflineOperation, type OfflineOperationError, type OfflineOperationLifecycleStatus, type OfflineOperationResponse, type OfflineOperationStatus, OfflineQueue, type OfflineQueueCapability, type OfflineQueueCapabilityWarning, type OfflineQueueChangeListener, type OfflineQueueOptions, type OfflineQueueStorage, type OfflineResult, type OfflineSender, type OfflineStorageCapability, 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 QueueCapabilitiesDetail, type QueueCapability, type QueueCapabilityMode, type QueueOperationStatus, type RallyConfig, type RallyInventory, type RallyInventoryState, type RallySnapshot, type RebuildUserStateOptions, type RebuildUserStateResult, type RedemptionMethod, type RejectedOperation, type RejectedOperationHistoryEntry, 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 SyncEventListener, type SyncLifecycleEvent, type SyncOperationAction, type SyncOperationResult, type SyncProgressResponse, type SyncRetryOptions, type SyncState, THEME_PRESETS, type ThemePreset, type ThemePresetId, type UserRallyState, type ValidationError, type Validator, type VerificationContext, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createAnonymousSessionId, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getLegacyQueueCapability, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, offlineOperationId, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, rebuildUserStateFromLog, rebuildUserStateLog, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, rollbackOptimisticOperation, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, sortOperationsDeterministically, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
package/dist/index.js CHANGED
@@ -455,6 +455,12 @@ async function readQrContext(videoElement, options = {}) {
455
455
  }
456
456
 
457
457
  // src/engine/transition.ts
458
+ function sortOperationsDeterministically(operations) {
459
+ return [...operations].sort((left, right) => {
460
+ if (left.timestamp !== right.timestamp) return left.timestamp - right.timestamp;
461
+ return left.operationId.localeCompare(right.operationId);
462
+ });
463
+ }
458
464
  function reconcileRewardStates(rewards, currentStates, acquiredStampCount, now) {
459
465
  const states = new Map(currentStates.map((state) => [state.rewardId, state]));
460
466
  return rewards.map((reward2) => {
@@ -1006,6 +1012,8 @@ var IndexedDBAdapter = class {
1006
1012
 
1007
1013
  // src/client/offlineQueue.ts
1008
1014
  function getLegacyQueueCapability(capability) {
1015
+ if (typeof capability === "string")
1016
+ return capability === "memory" || capability === "disabled" ? "volatile" : "persistent";
1009
1017
  return capability.isPersistent ? "persistent" : "volatile";
1010
1018
  }
1011
1019
  function rollbackOptimisticOperation(state, operation) {
@@ -1266,13 +1274,15 @@ var OfflineQueue = class {
1266
1274
  return this.#operations.length;
1267
1275
  }
1268
1276
  get queueCapability() {
1269
- const isPersistent = this.#queueCapability !== "memory";
1277
+ return this.#queueCapability;
1278
+ }
1279
+ get queueCapabilities() {
1280
+ const storageType = this.#queueCapability;
1281
+ const isPersistent = storageType !== "memory";
1270
1282
  return {
1271
- storage: this.#queueCapability,
1272
- mode: isPersistent ? "persistent" : "volatile_memory",
1273
- multiTabSync: this.#hasWebLocks() ? "supported_web_locks" : "disabled_unsafe_environment",
1283
+ storageType,
1274
1284
  isPersistent,
1275
- legacy: isPersistent ? "persistent" : "volatile"
1285
+ multiTabSync: this.#hasWebLocks() ? "supported_web_locks" : "disabled_unsafe_environment"
1276
1286
  };
1277
1287
  }
1278
1288
  get storageCapability() {
@@ -1330,7 +1340,7 @@ var OfflineQueue = class {
1330
1340
  }
1331
1341
  if (this.#queueCapability === "memory")
1332
1342
  this.#warnCapability("Offline queue persistence is unavailable; queued data is memory-only.");
1333
- if (this.queueCapability.multiTabSync === "disabled_unsafe_environment")
1343
+ if (this.queueCapabilities.multiTabSync === "disabled_unsafe_environment")
1334
1344
  this.#warnCapability(
1335
1345
  "Web Locks is unavailable; automatic cross-tab synchronization is disabled. Sync must be triggered by the foreground tab."
1336
1346
  );
@@ -1768,8 +1778,11 @@ function isReplayable(operation) {
1768
1778
  return operation.status === void 0 || operation.status === "ACCEPTED" || operation.status === "PENDING" || operation.status === "IN_FLIGHT" || operation.status === "FAILED_RETRYABLE";
1769
1779
  }
1770
1780
  function operationId(operation) {
1771
- const identity = operation.request.userId ?? operation.request.anonymousSessionId ?? "anonymous";
1772
- return `${operation.kind}:${operation.request.rallyId}:${identity}:${operation.request.idempotencyKey}`;
1781
+ return offlineOperationId(operation);
1782
+ }
1783
+ function operationTimestamp(operation) {
1784
+ const parsed = Date.parse(operation.request.now);
1785
+ return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
1773
1786
  }
1774
1787
  function applyInventoryDelta(state, previous, optimistic) {
1775
1788
  const previousInventory = previous.inventory;
@@ -1845,12 +1858,19 @@ function rebuildUserStateFromLog(baselineOrOptions, operationsArgument, configAr
1845
1858
  function rebuildUserStateLog(baseline, operations, config) {
1846
1859
  let state = cloneState(baseline);
1847
1860
  const rejectedOperationIds = [];
1861
+ const sortedOperations = sortOperationsDeterministically(
1862
+ operations.map((operation) => ({
1863
+ operation,
1864
+ operationId: offlineOperationId(operation),
1865
+ timestamp: operationTimestamp(operation)
1866
+ }))
1867
+ ).map(({ operation }) => operation);
1848
1868
  const rejectedCheckIns = new Set(
1849
- operations.filter(
1869
+ sortedOperations.filter(
1850
1870
  (operation) => operation.status === "REJECTED_PERMANENT" && operation.kind === "checkIn"
1851
1871
  ).map((operation) => operation.kind === "checkIn" ? operation.request.spotId : void 0).filter((spotId) => spotId !== void 0)
1852
1872
  );
1853
- for (const operation of operations) {
1873
+ for (const operation of sortedOperations) {
1854
1874
  if (operation.status === "REJECTED_PERMANENT") {
1855
1875
  if (operation.kind === "checkIn") rejectedCheckIns.add(operation.request.spotId);
1856
1876
  continue;
@@ -1958,7 +1978,7 @@ var StampRallyClient = class {
1958
1978
  this.#storage = this.#options.storage ?? new InMemoryStorage();
1959
1979
  this.#anonymousSessionId = this.#options.anonymousSessionId ?? createAnonymousSessionId();
1960
1980
  this.#userId = this.#options.userId ?? this.#anonymousSessionId;
1961
- this.#offlineQueue = this.#options.offlineQueue;
1981
+ this.#offlineQueue = this.#options.offlineQueue === false ? void 0 : this.#options.offlineQueue;
1962
1982
  this.#offlineQueue?.setReplayConfig(config);
1963
1983
  this.#offlineQueue?.setSyncResultListener((event) => this.#handleOfflineSyncResult(event));
1964
1984
  this.#offlineQueue?.setCapabilityWarningListener(
@@ -1994,19 +2014,20 @@ var StampRallyClient = class {
1994
2014
  return this.#syncRevision;
1995
2015
  }
1996
2016
  get queueCapability() {
1997
- return this.#offlineQueue?.queueCapability ?? {
1998
- storage: "custom",
1999
- mode: "persistent",
2000
- multiTabSync: "disabled_unsafe_environment",
2001
- isPersistent: true,
2002
- legacy: "persistent"
2017
+ return this.#offlineQueue?.queueCapability ?? "disabled";
2018
+ }
2019
+ get queueCapabilities() {
2020
+ return this.#offlineQueue?.queueCapabilities ?? {
2021
+ storageType: "none",
2022
+ isPersistent: false,
2023
+ multiTabSync: "disabled_unsafe_environment"
2003
2024
  };
2004
2025
  }
2005
2026
  get storageCapability() {
2006
- return this.#offlineQueue?.storageCapability ?? "custom";
2027
+ return this.#offlineQueue?.storageCapability ?? "disabled";
2007
2028
  }
2008
2029
  get isStoragePersistent() {
2009
- return this.#offlineQueue?.isStoragePersistent ?? true;
2030
+ return this.#offlineQueue?.isStoragePersistent ?? false;
2010
2031
  }
2011
2032
  discardRejected(operationId2) {
2012
2033
  return this.#offlineQueue?.discardRejected(operationId2) ?? Promise.resolve(false);
@@ -3464,6 +3485,6 @@ async function verifySnapshotToken(token, secretKey, now = Date.now()) {
3464
3485
  }
3465
3486
  }
3466
3487
 
3467
- export { ConfigValidationError, DEFAULT_SHEET_THEME, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, IndexedDBOfflineQueueStorage, LocalStorageAdapter, OfflineQueue, StampRallyClient, StorageAdapterError, THEME_PRESETS, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createAnonymousSessionId, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getLegacyQueueCapability, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, offlineOperationId, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, rebuildUserStateFromLog, rebuildUserStateLog, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, rollbackOptimisticOperation, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
3488
+ export { ConfigValidationError, DEFAULT_SHEET_THEME, MemoryQueueStorage as InMemoryOfflineQueueStorage, InMemoryStorage, IndexedDBAdapter, IndexedDBOfflineQueueStorage, LocalStorageAdapter, OfflineQueue, StampRallyClient, StorageAdapterError, THEME_PRESETS, assertPublicConfig, calculateDistanceMeters, calculateProgress, consumeReward, createAnonymousSessionId, createClaimTicketNumber, createSecureToken, createSignedSnapshotToken, createUniqueClaimTicketNumber, evaluateCondition, evaluateConditionDetailed, evaluateSpotStatus, exportProgressToken, getCurrentGeoContext, getLegacyQueueCapability, getOrderedSpots, getSpotStatus, importProgressToken, isGeolocationSupported, isNfcSupported, isPublicConfig, isQrSupported, isRewardState, isStampRallyState, issueClaimTicketNumber, normalizePasscode, offlineOperationId, parseAdminConfig, parsePublicConfig, processStamp, readNfcContext, readQrContext, rebuildUserStateFromLog, rebuildUserStateLog, reconcileRewardStates, resolveLocalizedText, resolveRallyStateConflict, rollbackOptimisticOperation, safeParseAdminConfig, safeParsePublicConfig, sanitizeAdminConfig, sortOperationsDeterministically, storageKey, toLocalizedString, toPublicConfig, updateLocalizedField, validatePublicConfigSafety, validateRallyConfigRelations, verifyPasscode, verifySecureToken, verifySnapshotToken };
3468
3489
  //# sourceMappingURL=index.js.map
3469
3490
  //# sourceMappingURL=index.js.map