prizerail 0.4.0 → 0.5.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 +5 -5
- package/dist/cli.js +2 -2
- package/dist/client.d.ts +4 -4
- package/dist/client.js +6 -6
- package/dist/types.d.ts +3 -1
- 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.
|
|
14
|
+
The API is early (v0.x), so names can change between minor versions. 0.5.1 adds the `skipped` drawing status. 0.5.0 sends a `pr_sandbox_` key to https://sandbox.prizerail.com unless you pass `siteUrl` (0.4.0 did the same for the old `pr_test_` keys). 0.3.0 adds `entries.increment()`, 0.3.1 checks every event before sending any and lists only the drawings that took entries, and 0.3.2 and 0.3.3 check avatar URLs, names and the older `weight` up front too. 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
|
|
|
@@ -99,9 +99,9 @@ for await (const drawing of campaign.drawings.all({ status: "paid" })) {
|
|
|
99
99
|
const guarantees = await campaign.guarantees.list()
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
## Draw now, in
|
|
102
|
+
## Draw now, in the sandbox
|
|
103
103
|
|
|
104
|
-
In the
|
|
104
|
+
In the sandbox, `campaign.drawings.run(id)` closes a drawing's entries now and draws it, so you can see a whole draw without waiting for its cutoff. It resolves with the drawing, usually settled within seconds. Anywhere else it throws a `PrizerailError` with code `sandbox_only`. See [Draw now](https://docs.prizerail.com/api/drawings#draw-now-sandbox-only).
|
|
105
105
|
|
|
106
106
|
## Errors
|
|
107
107
|
|
|
@@ -132,7 +132,7 @@ npx prizerail verify https://www.prizerail.com/campaigns/your-campaign/draws/DRA
|
|
|
132
132
|
npx prizerail verify your-campaign DRAWING_ID
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
A slug is looked up on www.prizerail.com. For a draw from a
|
|
135
|
+
A slug is looked up on www.prizerail.com. For a draw from a sandbox campaign, add `--site https://sandbox.prizerail.com`, or set `PRIZERAIL_API_KEY` to your `pr_sandbox_` key. The same goes for the public helpers without a key: `new Prizerail({ siteUrl: "https://sandbox.prizerail.com" })` reaches sandbox campaigns.
|
|
136
136
|
|
|
137
137
|
It exits 0 when every check passes, 1 when one fails, and 2 when the proof can't be read.
|
|
138
138
|
|
|
@@ -141,7 +141,7 @@ It exits 0 when every check passes, 1 when one fails, and 2 when the proof can't
|
|
|
141
141
|
```ts
|
|
142
142
|
new Prizerail({
|
|
143
143
|
apiKey: "pr_…",
|
|
144
|
-
siteUrl: "https://www.prizerail.com", // the default, or https://
|
|
144
|
+
siteUrl: "https://www.prizerail.com", // the default, or https://sandbox.prizerail.com for a pr_sandbox_ key
|
|
145
145
|
timeoutMs: 30_000, // per attempt
|
|
146
146
|
maxRetries: 4,
|
|
147
147
|
fetch, // your own fetch, if you need one
|
package/dist/cli.js
CHANGED
|
@@ -12,8 +12,8 @@ Checks a draw from its public proof: the locked entrant list, the random
|
|
|
12
12
|
value, and every winner and prize. Exits 0 when every check passes, 1 when
|
|
13
13
|
one fails, and 2 when the proof can't be read.
|
|
14
14
|
|
|
15
|
-
A slug is looked up on www.prizerail.com. For a
|
|
16
|
-
--site https://
|
|
15
|
+
A slug is looked up on www.prizerail.com. For a sandbox campaign, pass
|
|
16
|
+
--site https://sandbox.prizerail.com, or set PRIZERAIL_API_KEY to a pr_sandbox_ key.`;
|
|
17
17
|
function print(result) {
|
|
18
18
|
const { proof, checks } = result;
|
|
19
19
|
// A malformed proof may lack these, and its failed checks still print.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.
|
|
4
|
+
export declare const VERSION = "0.5.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 = {
|
|
8
8
|
/** Your `pr_…` key. Only the public helpers work without one. */
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
/**
|
|
11
|
-
* Defaults to https://
|
|
11
|
+
* Defaults to https://sandbox.prizerail.com for a `pr_sandbox_` key and
|
|
12
12
|
* https://www.prizerail.com otherwise. Set it to point anywhere else, such
|
|
13
13
|
* as a local server.
|
|
14
14
|
*/
|
|
@@ -147,11 +147,11 @@ export declare class DrawingsClient {
|
|
|
147
147
|
}): AsyncGenerator<Drawing>;
|
|
148
148
|
get(id: string): Promise<Drawing>;
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
150
|
+
* Sandbox only: closes the drawing's entries now and draws it,
|
|
151
151
|
* instead of waiting for its cutoff. Resolves with the drawing, settled or
|
|
152
152
|
* paid, or still `entropy_requested` if the random value is on its way, in
|
|
153
153
|
* which case read it again with `get(id)`. Elsewhere it throws a
|
|
154
|
-
* PrizerailError with code `
|
|
154
|
+
* PrizerailError with code `sandbox_only`.
|
|
155
155
|
*/
|
|
156
156
|
run(id: string): Promise<Drawing>;
|
|
157
157
|
/**
|
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.
|
|
4
|
+
export const VERSION = "0.5.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;
|
|
@@ -131,10 +131,10 @@ function normalizePage(page) {
|
|
|
131
131
|
next: page.next,
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
/** The site a key belongs to:
|
|
134
|
+
/** The site a key belongs to: sandbox keys only work in the sandbox. */
|
|
135
135
|
function defaultSiteUrl(apiKey) {
|
|
136
|
-
return apiKey?.trim().startsWith("
|
|
137
|
-
? "https://
|
|
136
|
+
return apiKey?.trim().startsWith("pr_sandbox_")
|
|
137
|
+
? "https://sandbox.prizerail.com"
|
|
138
138
|
: "https://www.prizerail.com";
|
|
139
139
|
}
|
|
140
140
|
export class Prizerail {
|
|
@@ -398,11 +398,11 @@ export class DrawingsClient {
|
|
|
398
398
|
return (await this.campaign.http.request("GET", this.campaign.path(`/drawings/${encodeURIComponent(id)}`))).drawing;
|
|
399
399
|
}
|
|
400
400
|
/**
|
|
401
|
-
*
|
|
401
|
+
* Sandbox only: closes the drawing's entries now and draws it,
|
|
402
402
|
* instead of waiting for its cutoff. Resolves with the drawing, settled or
|
|
403
403
|
* paid, or still `entropy_requested` if the random value is on its way, in
|
|
404
404
|
* which case read it again with `get(id)`. Elsewhere it throws a
|
|
405
|
-
* PrizerailError with code `
|
|
405
|
+
* PrizerailError with code `sandbox_only`.
|
|
406
406
|
*/
|
|
407
407
|
async run(id) {
|
|
408
408
|
return (await this.campaign.http.request("POST", this.campaign.path(`/drawings/${encodeURIComponent(id)}/run`),
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** Shapes the Prizerail partner API returns, as documented at docs.prizerail.com. */
|
|
2
2
|
export type CampaignStatus = "draft" | "active" | "paused" | "ended";
|
|
3
3
|
export type Cadence = "hourly" | "daily" | "weekly" | "monthly";
|
|
4
|
-
export type DrawingStatus = "open" | "locked" | "entropy_requested" | "settled" | "paid"
|
|
4
|
+
export type DrawingStatus = "open" | "locked" | "entropy_requested" | "settled" | "paid"
|
|
5
|
+
/** No entries by the cutoff, so closed without a draw. */
|
|
6
|
+
| "skipped";
|
|
5
7
|
export type DrawingKind = "regular" | "guarantee";
|
|
6
8
|
export type PayoutKind = "lump_sum" | "large_prize" | "guarantee";
|
|
7
9
|
export type PayoutStatus = "pending" | "submitted" | "confirmed" | "failed" | "held_manual";
|