@stamprally/core 0.13.0 → 0.15.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 +7 -3
- package/dist/index.cjs +344 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +343 -31
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -96,6 +96,14 @@ 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";
|
|
100
|
+
type RallyInventory = Readonly<Record<string, number>> & {
|
|
101
|
+
readonly sharedStock?: number;
|
|
102
|
+
};
|
|
103
|
+
interface RallyInventoryState {
|
|
104
|
+
readonly sharedRemaining?: number;
|
|
105
|
+
readonly rewardRemaining?: Readonly<Record<string, number>>;
|
|
106
|
+
}
|
|
99
107
|
interface Reward<TLocale extends string = string> {
|
|
100
108
|
readonly id: string;
|
|
101
109
|
readonly title: LocalizedText<TLocale>;
|
|
@@ -120,7 +128,9 @@ interface AdminRallyConfig<TLocale extends string = string, TMeta extends Record
|
|
|
120
128
|
readonly spots: ReadonlyArray<SpotItem<TLocale, TMeta>>;
|
|
121
129
|
readonly rewards: ReadonlyArray<Reward<TLocale>>;
|
|
122
130
|
readonly staffPasscode?: string;
|
|
123
|
-
readonly inventory?:
|
|
131
|
+
readonly inventory?: RallyInventory;
|
|
132
|
+
/** How the optional top-level inventory limit is aggregated. */
|
|
133
|
+
readonly inventoryMode?: InventoryAggregationMode;
|
|
124
134
|
readonly serverMetadata?: Readonly<Record<string, unknown>>;
|
|
125
135
|
readonly metadata?: TMeta;
|
|
126
136
|
/** Explicit public metadata name. `metadata` remains supported for compatibility. */
|
|
@@ -164,6 +174,7 @@ interface StampRallyState {
|
|
|
164
174
|
readonly userId: string | null;
|
|
165
175
|
readonly records: ReadonlyArray<StampRecord>;
|
|
166
176
|
readonly rewards: ReadonlyArray<RewardState>;
|
|
177
|
+
readonly inventory?: RallyInventoryState;
|
|
167
178
|
readonly updatedAt: string;
|
|
168
179
|
}
|
|
169
180
|
type UserRallyState = StampRallyState;
|
|
@@ -285,6 +296,8 @@ declare class ConfigValidationError extends Error {
|
|
|
285
296
|
readonly name = "ConfigValidationError";
|
|
286
297
|
constructor(errors: ReadonlyArray<ValidationError>);
|
|
287
298
|
}
|
|
299
|
+
/** Validates relationships that can only be checked after all entities exist. */
|
|
300
|
+
declare function validateRallyConfigRelations(config: AdminRallyConfig | PublicRallyConfig): ReadonlyArray<ValidationError>;
|
|
288
301
|
declare function safeParseAdminConfig(input: unknown): ParseResult<AdminRallyConfig>;
|
|
289
302
|
declare function parseAdminConfig(input: unknown): AdminRallyConfig;
|
|
290
303
|
declare function safeParsePublicConfig(input: unknown): ParseResult<PublicRallyConfig>;
|
|
@@ -362,9 +375,13 @@ declare function processStamp(state: StampRallyState, config: AdminRallyConfig,
|
|
|
362
375
|
type OfflineOperation = {
|
|
363
376
|
readonly kind: "checkIn";
|
|
364
377
|
readonly request: CheckInRequest;
|
|
378
|
+
readonly status?: OfflineOperationLifecycleStatus;
|
|
379
|
+
readonly attempts?: number;
|
|
365
380
|
} | {
|
|
366
381
|
readonly kind: "claimReward";
|
|
367
382
|
readonly request: ClaimRequest;
|
|
383
|
+
readonly status?: OfflineOperationLifecycleStatus;
|
|
384
|
+
readonly attempts?: number;
|
|
368
385
|
};
|
|
369
386
|
type OfflineResult = CheckInResult | ClaimResult | UserRallyState;
|
|
370
387
|
type SyncState = "idle" | "syncing" | "error";
|
|
@@ -393,6 +410,17 @@ interface OfflineQueueOptions {
|
|
|
393
410
|
readonly databaseName?: string;
|
|
394
411
|
readonly conflictPolicy?: SyncConflictPolicy;
|
|
395
412
|
readonly onSyncConflict?: SyncConflictPolicy | ((context: OfflineConflict) => SyncConflictPolicy | Promise<SyncConflictPolicy>);
|
|
413
|
+
/** Enables storage-event/BroadcastChannel synchronization when browser APIs exist. */
|
|
414
|
+
readonly synchronizeInstances?: boolean;
|
|
415
|
+
readonly retryOptions?: SyncRetryOptions;
|
|
416
|
+
readonly retry?: SyncRetryOptions;
|
|
417
|
+
/** Alias accepted for callers that configure retry behavior at sync time. */
|
|
418
|
+
readonly syncRetryOptions?: SyncRetryOptions;
|
|
419
|
+
}
|
|
420
|
+
interface SyncRetryOptions {
|
|
421
|
+
readonly maxRetries?: number;
|
|
422
|
+
readonly initialIntervalMs?: number;
|
|
423
|
+
readonly backoffMultiplier?: number;
|
|
396
424
|
}
|
|
397
425
|
interface OfflineConflict {
|
|
398
426
|
readonly operation: OfflineOperation;
|
|
@@ -400,7 +428,8 @@ interface OfflineConflict {
|
|
|
400
428
|
readonly serverState: UserRallyState;
|
|
401
429
|
}
|
|
402
430
|
type OfflineSender = (operation: OfflineOperation) => Promise<OfflineResult | OfflineConflictResult | OfflineOperationResponse>;
|
|
403
|
-
type OfflineOperationStatus = "ACCEPTED" | "REJECTED_PERMANENT" | "RETRYABLE_ERROR";
|
|
431
|
+
type OfflineOperationStatus = "PENDING" | "IN_FLIGHT" | "ACCEPTED" | "REJECTED" | "REJECTED_PERMANENT" | "RETRYABLE_ERROR";
|
|
432
|
+
type OfflineOperationLifecycleStatus = "PENDING" | "IN_FLIGHT" | "ACCEPTED" | "REJECTED";
|
|
404
433
|
interface OfflineOperationError {
|
|
405
434
|
readonly code: string;
|
|
406
435
|
readonly message: string;
|
|
@@ -457,6 +486,8 @@ declare class OfflineQueue {
|
|
|
457
486
|
get userId(): string | null;
|
|
458
487
|
setSyncResultListener(listener: OfflineSyncResultListener | undefined): void;
|
|
459
488
|
initialize(): Promise<void>;
|
|
489
|
+
/** Releases browser listeners when the queue is no longer used. */
|
|
490
|
+
dispose(): void;
|
|
460
491
|
/** Selects a rally/user queue scope and loads its pending operations. */
|
|
461
492
|
setScope(rallyId: string, userId: string | null): Promise<void>;
|
|
462
493
|
switchUser(newUserId: string | null): Promise<void>;
|
|
@@ -510,6 +541,7 @@ declare class InMemoryStorage implements StampStorage {
|
|
|
510
541
|
remove(rallyId: string, userId: string | null): Promise<void>;
|
|
511
542
|
}
|
|
512
543
|
declare function storageKey(rallyId: string, userId: string | null): string;
|
|
544
|
+
declare function createAnonymousSessionId(storage?: StorageLike | null): string;
|
|
513
545
|
interface LocalStorageAdapterOptions {
|
|
514
546
|
readonly storage?: StorageLike | null;
|
|
515
547
|
readonly keyPrefix?: string;
|
|
@@ -598,6 +630,7 @@ interface CheckInRequest {
|
|
|
598
630
|
readonly idempotencyKey: string;
|
|
599
631
|
readonly now: string;
|
|
600
632
|
readonly state: UserRallyState;
|
|
633
|
+
readonly anonymousSessionId?: string;
|
|
601
634
|
}
|
|
602
635
|
interface ClaimRequest {
|
|
603
636
|
readonly rallyId: string;
|
|
@@ -607,6 +640,7 @@ interface ClaimRequest {
|
|
|
607
640
|
readonly now: string;
|
|
608
641
|
readonly options: ClaimOptions;
|
|
609
642
|
readonly state: UserRallyState;
|
|
643
|
+
readonly anonymousSessionId?: string;
|
|
610
644
|
}
|
|
611
645
|
interface SyncAdapter {
|
|
612
646
|
readonly checkIn?: (request: CheckInRequest) => Promise<CheckInResult>;
|
|
@@ -615,6 +649,7 @@ interface SyncAdapter {
|
|
|
615
649
|
readonly rallyId: string;
|
|
616
650
|
readonly userId: string | null;
|
|
617
651
|
readonly state: UserRallyState;
|
|
652
|
+
readonly anonymousSessionId?: string;
|
|
618
653
|
}) => Promise<UserRallyState>;
|
|
619
654
|
}
|
|
620
655
|
interface ClientOptions {
|
|
@@ -624,6 +659,7 @@ interface ClientOptions {
|
|
|
624
659
|
readonly customValidators?: Readonly<Record<string, Validator>>;
|
|
625
660
|
readonly clock?: () => string;
|
|
626
661
|
readonly userId?: string | null;
|
|
662
|
+
readonly anonymousSessionId?: string;
|
|
627
663
|
readonly offlineQueue?: OfflineQueue;
|
|
628
664
|
}
|
|
629
665
|
type StorageOrOptions = StampStorage | ClientOptions;
|
|
@@ -633,6 +669,7 @@ declare class StampRallyClient {
|
|
|
633
669
|
getConfig(): RallyConfig;
|
|
634
670
|
getState(): UserRallyState | null;
|
|
635
671
|
getUserId(): string | null;
|
|
672
|
+
getAnonymousSessionId(): string;
|
|
636
673
|
get syncState(): SyncState;
|
|
637
674
|
get pendingCount(): number;
|
|
638
675
|
subscribe(listener: ClientListener): () => void;
|
|
@@ -755,4 +792,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
|
|
|
755
792
|
declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
|
|
756
793
|
declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
|
|
757
794
|
|
|
758
|
-
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, 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, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
|
795
|
+
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 OfflineOperationLifecycleStatus, 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 RallyInventory, type RallyInventoryState, 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 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, 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,14 @@ 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";
|
|
100
|
+
type RallyInventory = Readonly<Record<string, number>> & {
|
|
101
|
+
readonly sharedStock?: number;
|
|
102
|
+
};
|
|
103
|
+
interface RallyInventoryState {
|
|
104
|
+
readonly sharedRemaining?: number;
|
|
105
|
+
readonly rewardRemaining?: Readonly<Record<string, number>>;
|
|
106
|
+
}
|
|
99
107
|
interface Reward<TLocale extends string = string> {
|
|
100
108
|
readonly id: string;
|
|
101
109
|
readonly title: LocalizedText<TLocale>;
|
|
@@ -120,7 +128,9 @@ interface AdminRallyConfig<TLocale extends string = string, TMeta extends Record
|
|
|
120
128
|
readonly spots: ReadonlyArray<SpotItem<TLocale, TMeta>>;
|
|
121
129
|
readonly rewards: ReadonlyArray<Reward<TLocale>>;
|
|
122
130
|
readonly staffPasscode?: string;
|
|
123
|
-
readonly inventory?:
|
|
131
|
+
readonly inventory?: RallyInventory;
|
|
132
|
+
/** How the optional top-level inventory limit is aggregated. */
|
|
133
|
+
readonly inventoryMode?: InventoryAggregationMode;
|
|
124
134
|
readonly serverMetadata?: Readonly<Record<string, unknown>>;
|
|
125
135
|
readonly metadata?: TMeta;
|
|
126
136
|
/** Explicit public metadata name. `metadata` remains supported for compatibility. */
|
|
@@ -164,6 +174,7 @@ interface StampRallyState {
|
|
|
164
174
|
readonly userId: string | null;
|
|
165
175
|
readonly records: ReadonlyArray<StampRecord>;
|
|
166
176
|
readonly rewards: ReadonlyArray<RewardState>;
|
|
177
|
+
readonly inventory?: RallyInventoryState;
|
|
167
178
|
readonly updatedAt: string;
|
|
168
179
|
}
|
|
169
180
|
type UserRallyState = StampRallyState;
|
|
@@ -285,6 +296,8 @@ declare class ConfigValidationError extends Error {
|
|
|
285
296
|
readonly name = "ConfigValidationError";
|
|
286
297
|
constructor(errors: ReadonlyArray<ValidationError>);
|
|
287
298
|
}
|
|
299
|
+
/** Validates relationships that can only be checked after all entities exist. */
|
|
300
|
+
declare function validateRallyConfigRelations(config: AdminRallyConfig | PublicRallyConfig): ReadonlyArray<ValidationError>;
|
|
288
301
|
declare function safeParseAdminConfig(input: unknown): ParseResult<AdminRallyConfig>;
|
|
289
302
|
declare function parseAdminConfig(input: unknown): AdminRallyConfig;
|
|
290
303
|
declare function safeParsePublicConfig(input: unknown): ParseResult<PublicRallyConfig>;
|
|
@@ -362,9 +375,13 @@ declare function processStamp(state: StampRallyState, config: AdminRallyConfig,
|
|
|
362
375
|
type OfflineOperation = {
|
|
363
376
|
readonly kind: "checkIn";
|
|
364
377
|
readonly request: CheckInRequest;
|
|
378
|
+
readonly status?: OfflineOperationLifecycleStatus;
|
|
379
|
+
readonly attempts?: number;
|
|
365
380
|
} | {
|
|
366
381
|
readonly kind: "claimReward";
|
|
367
382
|
readonly request: ClaimRequest;
|
|
383
|
+
readonly status?: OfflineOperationLifecycleStatus;
|
|
384
|
+
readonly attempts?: number;
|
|
368
385
|
};
|
|
369
386
|
type OfflineResult = CheckInResult | ClaimResult | UserRallyState;
|
|
370
387
|
type SyncState = "idle" | "syncing" | "error";
|
|
@@ -393,6 +410,17 @@ interface OfflineQueueOptions {
|
|
|
393
410
|
readonly databaseName?: string;
|
|
394
411
|
readonly conflictPolicy?: SyncConflictPolicy;
|
|
395
412
|
readonly onSyncConflict?: SyncConflictPolicy | ((context: OfflineConflict) => SyncConflictPolicy | Promise<SyncConflictPolicy>);
|
|
413
|
+
/** Enables storage-event/BroadcastChannel synchronization when browser APIs exist. */
|
|
414
|
+
readonly synchronizeInstances?: boolean;
|
|
415
|
+
readonly retryOptions?: SyncRetryOptions;
|
|
416
|
+
readonly retry?: SyncRetryOptions;
|
|
417
|
+
/** Alias accepted for callers that configure retry behavior at sync time. */
|
|
418
|
+
readonly syncRetryOptions?: SyncRetryOptions;
|
|
419
|
+
}
|
|
420
|
+
interface SyncRetryOptions {
|
|
421
|
+
readonly maxRetries?: number;
|
|
422
|
+
readonly initialIntervalMs?: number;
|
|
423
|
+
readonly backoffMultiplier?: number;
|
|
396
424
|
}
|
|
397
425
|
interface OfflineConflict {
|
|
398
426
|
readonly operation: OfflineOperation;
|
|
@@ -400,7 +428,8 @@ interface OfflineConflict {
|
|
|
400
428
|
readonly serverState: UserRallyState;
|
|
401
429
|
}
|
|
402
430
|
type OfflineSender = (operation: OfflineOperation) => Promise<OfflineResult | OfflineConflictResult | OfflineOperationResponse>;
|
|
403
|
-
type OfflineOperationStatus = "ACCEPTED" | "REJECTED_PERMANENT" | "RETRYABLE_ERROR";
|
|
431
|
+
type OfflineOperationStatus = "PENDING" | "IN_FLIGHT" | "ACCEPTED" | "REJECTED" | "REJECTED_PERMANENT" | "RETRYABLE_ERROR";
|
|
432
|
+
type OfflineOperationLifecycleStatus = "PENDING" | "IN_FLIGHT" | "ACCEPTED" | "REJECTED";
|
|
404
433
|
interface OfflineOperationError {
|
|
405
434
|
readonly code: string;
|
|
406
435
|
readonly message: string;
|
|
@@ -457,6 +486,8 @@ declare class OfflineQueue {
|
|
|
457
486
|
get userId(): string | null;
|
|
458
487
|
setSyncResultListener(listener: OfflineSyncResultListener | undefined): void;
|
|
459
488
|
initialize(): Promise<void>;
|
|
489
|
+
/** Releases browser listeners when the queue is no longer used. */
|
|
490
|
+
dispose(): void;
|
|
460
491
|
/** Selects a rally/user queue scope and loads its pending operations. */
|
|
461
492
|
setScope(rallyId: string, userId: string | null): Promise<void>;
|
|
462
493
|
switchUser(newUserId: string | null): Promise<void>;
|
|
@@ -510,6 +541,7 @@ declare class InMemoryStorage implements StampStorage {
|
|
|
510
541
|
remove(rallyId: string, userId: string | null): Promise<void>;
|
|
511
542
|
}
|
|
512
543
|
declare function storageKey(rallyId: string, userId: string | null): string;
|
|
544
|
+
declare function createAnonymousSessionId(storage?: StorageLike | null): string;
|
|
513
545
|
interface LocalStorageAdapterOptions {
|
|
514
546
|
readonly storage?: StorageLike | null;
|
|
515
547
|
readonly keyPrefix?: string;
|
|
@@ -598,6 +630,7 @@ interface CheckInRequest {
|
|
|
598
630
|
readonly idempotencyKey: string;
|
|
599
631
|
readonly now: string;
|
|
600
632
|
readonly state: UserRallyState;
|
|
633
|
+
readonly anonymousSessionId?: string;
|
|
601
634
|
}
|
|
602
635
|
interface ClaimRequest {
|
|
603
636
|
readonly rallyId: string;
|
|
@@ -607,6 +640,7 @@ interface ClaimRequest {
|
|
|
607
640
|
readonly now: string;
|
|
608
641
|
readonly options: ClaimOptions;
|
|
609
642
|
readonly state: UserRallyState;
|
|
643
|
+
readonly anonymousSessionId?: string;
|
|
610
644
|
}
|
|
611
645
|
interface SyncAdapter {
|
|
612
646
|
readonly checkIn?: (request: CheckInRequest) => Promise<CheckInResult>;
|
|
@@ -615,6 +649,7 @@ interface SyncAdapter {
|
|
|
615
649
|
readonly rallyId: string;
|
|
616
650
|
readonly userId: string | null;
|
|
617
651
|
readonly state: UserRallyState;
|
|
652
|
+
readonly anonymousSessionId?: string;
|
|
618
653
|
}) => Promise<UserRallyState>;
|
|
619
654
|
}
|
|
620
655
|
interface ClientOptions {
|
|
@@ -624,6 +659,7 @@ interface ClientOptions {
|
|
|
624
659
|
readonly customValidators?: Readonly<Record<string, Validator>>;
|
|
625
660
|
readonly clock?: () => string;
|
|
626
661
|
readonly userId?: string | null;
|
|
662
|
+
readonly anonymousSessionId?: string;
|
|
627
663
|
readonly offlineQueue?: OfflineQueue;
|
|
628
664
|
}
|
|
629
665
|
type StorageOrOptions = StampStorage | ClientOptions;
|
|
@@ -633,6 +669,7 @@ declare class StampRallyClient {
|
|
|
633
669
|
getConfig(): RallyConfig;
|
|
634
670
|
getState(): UserRallyState | null;
|
|
635
671
|
getUserId(): string | null;
|
|
672
|
+
getAnonymousSessionId(): string;
|
|
636
673
|
get syncState(): SyncState;
|
|
637
674
|
get pendingCount(): number;
|
|
638
675
|
subscribe(listener: ClientListener): () => void;
|
|
@@ -755,4 +792,4 @@ type SnapshotTokenVerification<T extends SnapshotTokenPayload = SnapshotTokenPay
|
|
|
755
792
|
declare function createSignedSnapshotToken<T extends SnapshotTokenPayload>(payload: T, secretKey: SnapshotSecretKey): Promise<string>;
|
|
756
793
|
declare function verifySnapshotToken<T extends SnapshotTokenPayload = SnapshotTokenPayload>(token: string, secretKey: SnapshotSecretKey, now?: number): Promise<SnapshotTokenVerification<T>>;
|
|
757
794
|
|
|
758
|
-
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, 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, verifyPasscode, verifySecureToken, verifySnapshotToken };
|
|
795
|
+
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 OfflineOperationLifecycleStatus, 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 RallyInventory, type RallyInventoryState, 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 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, 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 };
|