prizerail 0.3.0 → 0.3.1
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 +2 -2
- package/dist/client.d.ts +4 -4
- package/dist/client.js +6 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ The Prizerail SDK for JavaScript and TypeScript. Send entries, read results and
|
|
|
11
11
|
npm install prizerail
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
The API is early (v0.x), so names can change between minor versions. 0.3.0 adds `entries.increment()
|
|
14
|
+
The API is early (v0.x), so names can change between minor versions. 0.3.0 adds `entries.increment()`, and 0.3.1 checks every event before sending any and lists only the drawings that took entries. 0.2.0 says `entries` where 0.1.0 said `weight`: an entrant is `{ entrantId, entries }`, and totals are `entrantCount` and `totalEntries`. The old names still work, marked deprecated. Each change is in the [changelog](https://docs.prizerail.com/changelog).
|
|
15
15
|
|
|
16
16
|
## Send entries
|
|
17
17
|
|
|
@@ -68,7 +68,7 @@ await campaign.entries.increment([
|
|
|
68
68
|
|
|
69
69
|
Prizerail records each `eventId` for the campaign and ignores it if it comes again, so retries and a queue that delivers an event twice never add twice, even across a cutoff. Set the id once, when the event happens, and send the same one every time. An id made fresh on each attempt would add the entries again. If you have no id for the event, make a UUID when it happens and store it with the event.
|
|
70
70
|
|
|
71
|
-
An increment goes to the drawing taking entries when it arrives, so an event after a cutoff counts in the next draw. `drawings` lists each drawing the
|
|
71
|
+
An increment goes to the drawing taking entries when it arrives, so an event after a cutoff counts in the next draw. `drawings` lists each drawing the events added entries to. Events Prizerail had already seen stay in the drawing they first went to.
|
|
72
72
|
|
|
73
73
|
### Entrant ids
|
|
74
74
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Http } from "./http.js";
|
|
2
2
|
import type { Campaign, Drawing, DrawingRef, DrawingStatus, DrawingsPage, Entrant, EntrantEvent, EntriesPage, Guarantee, SendEntriesResponse, SentEntrant } from "./types.js";
|
|
3
3
|
import { type DrawProof, type VerifyResult } from "./verify.js";
|
|
4
|
-
export declare const VERSION = "0.3.
|
|
4
|
+
export declare const VERSION = "0.3.1";
|
|
5
5
|
/** The API takes up to this many entries per request. */
|
|
6
6
|
export declare const ENTRIES_PER_REQUEST = 1000;
|
|
7
7
|
export type PrizerailOptions = {
|
|
@@ -49,9 +49,9 @@ export type IncrementResult = {
|
|
|
49
49
|
sent: number;
|
|
50
50
|
batches: number;
|
|
51
51
|
/**
|
|
52
|
-
* Each drawing
|
|
53
|
-
*
|
|
54
|
-
* which can be an earlier one.
|
|
52
|
+
* Each drawing these events added entries to, in order. A batch that was
|
|
53
|
+
* all duplicates adds none, since those events are in the drawing they
|
|
54
|
+
* first went to, which can be an earlier one.
|
|
55
55
|
*/
|
|
56
56
|
drawings: DrawingRef[];
|
|
57
57
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrizerailCutoffError, PrizerailDrawingChangedError, PrizerailError, } from "./errors.js";
|
|
2
2
|
import { Http } from "./http.js";
|
|
3
3
|
import { verifyDraw } from "./verify.js";
|
|
4
|
-
export const VERSION = "0.3.
|
|
4
|
+
export const VERSION = "0.3.1";
|
|
5
5
|
const badPage = (detail) => new PrizerailError(0, "invalid_response", `Paging stopped: ${detail}.`);
|
|
6
6
|
/** The API takes up to this many entries per request. */
|
|
7
7
|
export const ENTRIES_PER_REQUEST = 1000;
|
|
@@ -270,7 +270,11 @@ export class EntriesClient {
|
|
|
270
270
|
result.duplicates += res.duplicates ?? 0;
|
|
271
271
|
result.sent += batch.length;
|
|
272
272
|
result.batches++;
|
|
273
|
-
|
|
273
|
+
// Only a batch that added entries names where they went. One that was
|
|
274
|
+
// all duplicates, such as a retry after the cutoff of a batch already
|
|
275
|
+
// stored, names the next drawing, not the one the events are in.
|
|
276
|
+
if (res.added + res.updated > 0 &&
|
|
277
|
+
result.drawings.at(-1)?.id !== res.drawing.id) {
|
|
274
278
|
result.drawings.push(res.drawing);
|
|
275
279
|
}
|
|
276
280
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -138,9 +138,9 @@ export type EntrantEvent = {
|
|
|
138
138
|
/** Entries this event adds, a whole number from 1. Leave it out and it's 1. */
|
|
139
139
|
entries?: number;
|
|
140
140
|
eventId: string;
|
|
141
|
-
/** Up to 40 characters. Replaces the stored one when the event is first counted. */
|
|
141
|
+
/** Up to 40 characters. Replaces the stored one when the event is first counted. Empty keeps it. */
|
|
142
142
|
displayName?: string;
|
|
143
|
-
/** https, up to 2,048 characters. Replaces the stored one when the event is first counted. */
|
|
143
|
+
/** https, up to 2,048 characters. Replaces the stored one when the event is first counted. Empty keeps it. */
|
|
144
144
|
avatarUrl?: string;
|
|
145
145
|
};
|
|
146
146
|
export type SendEntriesResponse = {
|