keeperboard 2.0.3 → 2.1.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.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +15 -6
- package/dist/index.mjs +15 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -93,6 +93,7 @@ interface HealthResult {
|
|
|
93
93
|
version: string;
|
|
94
94
|
timestamp: string;
|
|
95
95
|
}
|
|
96
|
+
type ErrorCode = 'PROFANITY_DETECTED' | 'RATE_LIMITED' | 'INVALID_REQUEST' | 'NOT_FOUND' | 'INTERNAL_ERROR';
|
|
96
97
|
interface SessionConfig {
|
|
97
98
|
/** API key from the KeeperBoard dashboard */
|
|
98
99
|
apiKey: string;
|
|
@@ -120,6 +121,14 @@ type SessionScoreResult = {
|
|
|
120
121
|
} | {
|
|
121
122
|
success: false;
|
|
122
123
|
error: string;
|
|
124
|
+
errorCode?: ErrorCode;
|
|
125
|
+
};
|
|
126
|
+
type UpdateNameResult = {
|
|
127
|
+
success: true;
|
|
128
|
+
} | {
|
|
129
|
+
success: false;
|
|
130
|
+
error: string;
|
|
131
|
+
errorCode?: ErrorCode;
|
|
123
132
|
};
|
|
124
133
|
interface SnapshotEntry {
|
|
125
134
|
rank: number;
|
|
@@ -334,9 +343,9 @@ declare class KeeperBoardSession {
|
|
|
334
343
|
}): Promise<SnapshotResult>;
|
|
335
344
|
/**
|
|
336
345
|
* Update the player's name on the server and locally.
|
|
337
|
-
* Returns true on success, false on failure.
|
|
346
|
+
* Returns `{ success: true }` on success, or `{ success: false, error, errorCode }` on failure.
|
|
338
347
|
*/
|
|
339
|
-
updatePlayerName(newName: string): Promise<
|
|
348
|
+
updatePlayerName(newName: string): Promise<UpdateNameResult>;
|
|
340
349
|
/**
|
|
341
350
|
* Retry submitting a pending score (from a previous failed submission).
|
|
342
351
|
* Call this on app startup.
|
|
@@ -510,4 +519,4 @@ declare class RetryQueue {
|
|
|
510
519
|
clear(): void;
|
|
511
520
|
}
|
|
512
521
|
|
|
513
|
-
export { Cache, type ClaimResponse, type ClaimResult, type ClaimScoreOptions, type GetLeaderboardOptions, type GetPlayerRankOptions, type HealthResponse, type HealthResult, KeeperBoardClient, type KeeperBoardConfig, KeeperBoardError, KeeperBoardSession, type LeaderboardEntry, type LeaderboardResponse, type LeaderboardResult, type NameValidationOptions, PlayerIdentity, type PlayerIdentityConfig, type PlayerResponse, type PlayerResult, type ResetSchedule, RetryQueue, type ScoreResponse, type ScoreResult, type ScoreSubmission, type SessionConfig, type SessionScoreResult, type SnapshotEntry, type SnapshotResult, type SubmitScoreOptions, type UpdatePlayerNameOptions, generatePlayerName, validateName };
|
|
522
|
+
export { Cache, type ClaimResponse, type ClaimResult, type ClaimScoreOptions, type ErrorCode, type GetLeaderboardOptions, type GetPlayerRankOptions, type HealthResponse, type HealthResult, KeeperBoardClient, type KeeperBoardConfig, KeeperBoardError, KeeperBoardSession, type LeaderboardEntry, type LeaderboardResponse, type LeaderboardResult, type NameValidationOptions, PlayerIdentity, type PlayerIdentityConfig, type PlayerResponse, type PlayerResult, type ResetSchedule, RetryQueue, type ScoreResponse, type ScoreResult, type ScoreSubmission, type SessionConfig, type SessionScoreResult, type SnapshotEntry, type SnapshotResult, type SubmitScoreOptions, type UpdateNameResult, type UpdatePlayerNameOptions, generatePlayerName, validateName };
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ interface HealthResult {
|
|
|
93
93
|
version: string;
|
|
94
94
|
timestamp: string;
|
|
95
95
|
}
|
|
96
|
+
type ErrorCode = 'PROFANITY_DETECTED' | 'RATE_LIMITED' | 'INVALID_REQUEST' | 'NOT_FOUND' | 'INTERNAL_ERROR';
|
|
96
97
|
interface SessionConfig {
|
|
97
98
|
/** API key from the KeeperBoard dashboard */
|
|
98
99
|
apiKey: string;
|
|
@@ -120,6 +121,14 @@ type SessionScoreResult = {
|
|
|
120
121
|
} | {
|
|
121
122
|
success: false;
|
|
122
123
|
error: string;
|
|
124
|
+
errorCode?: ErrorCode;
|
|
125
|
+
};
|
|
126
|
+
type UpdateNameResult = {
|
|
127
|
+
success: true;
|
|
128
|
+
} | {
|
|
129
|
+
success: false;
|
|
130
|
+
error: string;
|
|
131
|
+
errorCode?: ErrorCode;
|
|
123
132
|
};
|
|
124
133
|
interface SnapshotEntry {
|
|
125
134
|
rank: number;
|
|
@@ -334,9 +343,9 @@ declare class KeeperBoardSession {
|
|
|
334
343
|
}): Promise<SnapshotResult>;
|
|
335
344
|
/**
|
|
336
345
|
* Update the player's name on the server and locally.
|
|
337
|
-
* Returns true on success, false on failure.
|
|
346
|
+
* Returns `{ success: true }` on success, or `{ success: false, error, errorCode }` on failure.
|
|
338
347
|
*/
|
|
339
|
-
updatePlayerName(newName: string): Promise<
|
|
348
|
+
updatePlayerName(newName: string): Promise<UpdateNameResult>;
|
|
340
349
|
/**
|
|
341
350
|
* Retry submitting a pending score (from a previous failed submission).
|
|
342
351
|
* Call this on app startup.
|
|
@@ -510,4 +519,4 @@ declare class RetryQueue {
|
|
|
510
519
|
clear(): void;
|
|
511
520
|
}
|
|
512
521
|
|
|
513
|
-
export { Cache, type ClaimResponse, type ClaimResult, type ClaimScoreOptions, type GetLeaderboardOptions, type GetPlayerRankOptions, type HealthResponse, type HealthResult, KeeperBoardClient, type KeeperBoardConfig, KeeperBoardError, KeeperBoardSession, type LeaderboardEntry, type LeaderboardResponse, type LeaderboardResult, type NameValidationOptions, PlayerIdentity, type PlayerIdentityConfig, type PlayerResponse, type PlayerResult, type ResetSchedule, RetryQueue, type ScoreResponse, type ScoreResult, type ScoreSubmission, type SessionConfig, type SessionScoreResult, type SnapshotEntry, type SnapshotResult, type SubmitScoreOptions, type UpdatePlayerNameOptions, generatePlayerName, validateName };
|
|
522
|
+
export { Cache, type ClaimResponse, type ClaimResult, type ClaimScoreOptions, type ErrorCode, type GetLeaderboardOptions, type GetPlayerRankOptions, type HealthResponse, type HealthResult, KeeperBoardClient, type KeeperBoardConfig, KeeperBoardError, KeeperBoardSession, type LeaderboardEntry, type LeaderboardResponse, type LeaderboardResult, type NameValidationOptions, PlayerIdentity, type PlayerIdentityConfig, type PlayerResponse, type PlayerResult, type ResetSchedule, RetryQueue, type ScoreResponse, type ScoreResult, type ScoreSubmission, type SessionConfig, type SessionScoreResult, type SnapshotEntry, type SnapshotResult, type SubmitScoreOptions, type UpdateNameResult, type UpdatePlayerNameOptions, generatePlayerName, validateName };
|
package/dist/index.js
CHANGED
|
@@ -810,10 +810,14 @@ var KeeperBoardSession = class {
|
|
|
810
810
|
isNewHighScore: result.isNewHighScore
|
|
811
811
|
};
|
|
812
812
|
} catch (error) {
|
|
813
|
-
|
|
813
|
+
const errorCode = error instanceof KeeperBoardError ? error.code : void 0;
|
|
814
|
+
if (errorCode !== "PROFANITY_DETECTED") {
|
|
815
|
+
this.retryQueue?.save(score, metadata);
|
|
816
|
+
}
|
|
814
817
|
return {
|
|
815
818
|
success: false,
|
|
816
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
819
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
820
|
+
errorCode
|
|
817
821
|
};
|
|
818
822
|
} finally {
|
|
819
823
|
this.isSubmitting = false;
|
|
@@ -840,7 +844,7 @@ var KeeperBoardSession = class {
|
|
|
840
844
|
}
|
|
841
845
|
/**
|
|
842
846
|
* Update the player's name on the server and locally.
|
|
843
|
-
* Returns true on success, false on failure.
|
|
847
|
+
* Returns `{ success: true }` on success, or `{ success: false, error, errorCode }` on failure.
|
|
844
848
|
*/
|
|
845
849
|
async updatePlayerName(newName) {
|
|
846
850
|
try {
|
|
@@ -853,9 +857,14 @@ var KeeperBoardSession = class {
|
|
|
853
857
|
this.cache.invalidate();
|
|
854
858
|
this.cachedLimit = 0;
|
|
855
859
|
}
|
|
856
|
-
return true;
|
|
857
|
-
} catch {
|
|
858
|
-
|
|
860
|
+
return { success: true };
|
|
861
|
+
} catch (error) {
|
|
862
|
+
const errorCode = error instanceof KeeperBoardError ? error.code : void 0;
|
|
863
|
+
return {
|
|
864
|
+
success: false,
|
|
865
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
866
|
+
errorCode
|
|
867
|
+
};
|
|
859
868
|
}
|
|
860
869
|
}
|
|
861
870
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -777,10 +777,14 @@ var KeeperBoardSession = class {
|
|
|
777
777
|
isNewHighScore: result.isNewHighScore
|
|
778
778
|
};
|
|
779
779
|
} catch (error) {
|
|
780
|
-
|
|
780
|
+
const errorCode = error instanceof KeeperBoardError ? error.code : void 0;
|
|
781
|
+
if (errorCode !== "PROFANITY_DETECTED") {
|
|
782
|
+
this.retryQueue?.save(score, metadata);
|
|
783
|
+
}
|
|
781
784
|
return {
|
|
782
785
|
success: false,
|
|
783
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
786
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
787
|
+
errorCode
|
|
784
788
|
};
|
|
785
789
|
} finally {
|
|
786
790
|
this.isSubmitting = false;
|
|
@@ -807,7 +811,7 @@ var KeeperBoardSession = class {
|
|
|
807
811
|
}
|
|
808
812
|
/**
|
|
809
813
|
* Update the player's name on the server and locally.
|
|
810
|
-
* Returns true on success, false on failure.
|
|
814
|
+
* Returns `{ success: true }` on success, or `{ success: false, error, errorCode }` on failure.
|
|
811
815
|
*/
|
|
812
816
|
async updatePlayerName(newName) {
|
|
813
817
|
try {
|
|
@@ -820,9 +824,14 @@ var KeeperBoardSession = class {
|
|
|
820
824
|
this.cache.invalidate();
|
|
821
825
|
this.cachedLimit = 0;
|
|
822
826
|
}
|
|
823
|
-
return true;
|
|
824
|
-
} catch {
|
|
825
|
-
|
|
827
|
+
return { success: true };
|
|
828
|
+
} catch (error) {
|
|
829
|
+
const errorCode = error instanceof KeeperBoardError ? error.code : void 0;
|
|
830
|
+
return {
|
|
831
|
+
success: false,
|
|
832
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
833
|
+
errorCode
|
|
834
|
+
};
|
|
826
835
|
}
|
|
827
836
|
}
|
|
828
837
|
/**
|