prizerail 0.4.0 → 0.5.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 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.4.0 sends a `pr_test_` key to https://test.prizerail.com unless you pass `siteUrl`. 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).
14
+ The API is early (v0.x), so names can change between minor versions. 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 test
102
+ ## Draw now, in the sandbox
103
103
 
104
- In the test environment, `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 `test_only`. See [Draw now](https://docs.prizerail.com/api/drawings#draw-now-test-only).
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 test campaign, add `--site https://test.prizerail.com`, or set `PRIZERAIL_API_KEY` to your `pr_test_` key. The same goes for the public helpers without a key: `new Prizerail({ siteUrl: "https://test.prizerail.com" })` reaches test campaigns.
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://test.prizerail.com for a pr_test_ key
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 test campaign, pass
16
- --site https://test.prizerail.com, or set PRIZERAIL_API_KEY to a pr_test_ key.`;
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.0";
4
+ export declare const VERSION = "0.5.0";
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://test.prizerail.com for a `pr_test_` key and
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
- * Test environment only: closes the drawing's entries now and draws it,
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 `test_only`.
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.0";
4
+ export const VERSION = "0.5.0";
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: test keys only work on the test site. */
134
+ /** The site a key belongs to: sandbox keys only work in the sandbox. */
135
135
  function defaultSiteUrl(apiKey) {
136
- return apiKey?.trim().startsWith("pr_test_")
137
- ? "https://test.prizerail.com"
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
- * Test environment only: closes the drawing's entries now and draws it,
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 `test_only`.
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizerail",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The Prizerail SDK: send entries, read draws and verify them.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.prizerail.com",