plures 1.1.0 → 1.3.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 +2 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,8 +44,9 @@ if (event.type === "task.completed" && event.data.result?.agreement === 1) {
|
|
|
44
44
|
|
|
45
45
|
## API
|
|
46
46
|
|
|
47
|
-
- `plures.tasks.create(params, { idempotencyKey? })`: send a task. Params: `question`, `options` (2 to 8, strings or `{ id, label }`), `context`, `image_url`, `instructions`, `verifiers` (1, 3, 5, 7 or 9), `max_verifiers`, `presence_check` (default true), `webhook_url`, `metadata`, `expires_in`.
|
|
47
|
+
- `plures.tasks.create(params, { idempotencyKey? })`: send a task. Params: `question`, `options` (2 to 8, strings or `{ id, label }`), `context`, `image_url`, `audio_url` or `video_url` with `media_seconds` (a clip up to 180 seconds that people play through before answering), `sensitive`, `instructions`, `verifiers` (1, 3, 5, 7 or 9), `max_verifiers`, `presence_check` (default true), `webhook_url`, `metadata`, `expires_in`.
|
|
48
48
|
- `plures.tasks.retrieve(id)`, `plures.tasks.list({ status?, limit?, starting_after? })`, `plures.tasks.cancel(id)`
|
|
49
|
+
- `plures.balance()`: your prepaid credit for live tasks, in cents. Live tasks cost $0.20 per answer (more for clips); a task that could cost more than your available credit throws a `PluresError` with `type` `insufficient_credits` (status 402).
|
|
49
50
|
- `plures.tasks.waitFor(id, { timeoutMs?, intervalMs? })`: poll until settled
|
|
50
51
|
- `plures.verify(params, { timeoutMs?, idempotencyKey? })`: create and wait
|
|
51
52
|
- `Plures.verifyWebhook(rawBody, signatureHeader, secret)`: check a webhook and return the event
|
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
default: () => index_default
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
var VERSION = "1.
|
|
29
|
+
var VERSION = "1.3.0";
|
|
30
30
|
var PluresError = class extends Error {
|
|
31
31
|
constructor(message, status, type) {
|
|
32
32
|
super(message);
|
|
@@ -81,6 +81,8 @@ var Plures = class {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
+
/** Your prepaid credit. A live task that could cost more than available_cents is refused with a 402 insufficient_credits error. */
|
|
85
|
+
balance = () => this.req("GET", "/api/v1/balance");
|
|
84
86
|
/** Creates a task and waits for people to answer it. */
|
|
85
87
|
async verify(params, opts = {}) {
|
|
86
88
|
const t = await this.tasks.create(params, { idempotencyKey: opts.idempotencyKey });
|
package/dist/index.d.cts
CHANGED
|
@@ -32,12 +32,27 @@ type Task = {
|
|
|
32
32
|
context: string | null;
|
|
33
33
|
image_url: string | null;
|
|
34
34
|
instructions: string | null;
|
|
35
|
+
audio_url?: string | null;
|
|
36
|
+
video_url?: string | null;
|
|
37
|
+
media_seconds?: number | null;
|
|
38
|
+
sensitive?: boolean;
|
|
35
39
|
options: Option[];
|
|
36
40
|
verifiers: number;
|
|
37
41
|
presence_check?: boolean;
|
|
38
42
|
result: Result | null;
|
|
39
43
|
escalation?: Escalation | null;
|
|
40
44
|
metadata: Record<string, unknown>;
|
|
45
|
+
/** Live tasks only: price per answer and what answers have cost so far, in US cents. */
|
|
46
|
+
cost?: {
|
|
47
|
+
per_answer_cents: number;
|
|
48
|
+
answers_billed: number;
|
|
49
|
+
total_cents: number;
|
|
50
|
+
} | null;
|
|
51
|
+
/** Where this decision sits on the Plures ledger, once recorded. */
|
|
52
|
+
ledger?: {
|
|
53
|
+
seq: number;
|
|
54
|
+
url: string;
|
|
55
|
+
} | null;
|
|
41
56
|
webhook_url: string | null;
|
|
42
57
|
created_at: string;
|
|
43
58
|
completed_at: string | null;
|
|
@@ -48,6 +63,14 @@ type CreateTask = {
|
|
|
48
63
|
options: (string | Option)[];
|
|
49
64
|
context?: string;
|
|
50
65
|
image_url?: string;
|
|
66
|
+
/** A recording people play through before answering, up to 3 minutes. Needs media_seconds. */
|
|
67
|
+
audio_url?: string;
|
|
68
|
+
/** A video people play through before answering, up to 3 minutes. Needs media_seconds. Not with audio_url. */
|
|
69
|
+
video_url?: string;
|
|
70
|
+
/** The clip's length in seconds, 1 to 180. Required with audio_url or video_url; pay scales with it. */
|
|
71
|
+
media_seconds?: number;
|
|
72
|
+
/** Disturbing content: only verifiers who opted in get it, behind a warning. Default false. */
|
|
73
|
+
sensitive?: boolean;
|
|
51
74
|
instructions?: string;
|
|
52
75
|
verifiers?: 1 | 3 | 5 | 7 | 9;
|
|
53
76
|
max_verifiers?: number;
|
|
@@ -61,13 +84,28 @@ type CreateTask = {
|
|
|
61
84
|
/** Agreement below which this task goes to your team, 0 to 1. Default from your dashboard. */
|
|
62
85
|
escalate_below?: number;
|
|
63
86
|
};
|
|
87
|
+
/** Prepaid credit for live tasks, in US cents. */
|
|
88
|
+
type Balance = {
|
|
89
|
+
object: "balance";
|
|
90
|
+
currency: "usd";
|
|
91
|
+
available_cents: number;
|
|
92
|
+
held_cents: number;
|
|
93
|
+
balance_cents: number;
|
|
94
|
+
price_per_unit_cents: number;
|
|
95
|
+
billing: "prepaid" | "invoice";
|
|
96
|
+
auto_topup: {
|
|
97
|
+
enabled: boolean;
|
|
98
|
+
below_cents: number;
|
|
99
|
+
amount_cents: number;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
64
102
|
type WebhookEvent = {
|
|
65
103
|
id: string;
|
|
66
104
|
type: "task.completed" | "task.expired" | "task.canceled";
|
|
67
105
|
created_at: string;
|
|
68
106
|
data: Task;
|
|
69
107
|
};
|
|
70
|
-
declare const VERSION = "1.
|
|
108
|
+
declare const VERSION = "1.3.0";
|
|
71
109
|
declare class PluresError extends Error {
|
|
72
110
|
readonly status: number;
|
|
73
111
|
readonly type: string;
|
|
@@ -102,6 +140,8 @@ declare class Plures {
|
|
|
102
140
|
intervalMs?: number;
|
|
103
141
|
}) => Promise<Task>;
|
|
104
142
|
};
|
|
143
|
+
/** Your prepaid credit. A live task that could cost more than available_cents is refused with a 402 insufficient_credits error. */
|
|
144
|
+
balance: () => Promise<Balance>;
|
|
105
145
|
/** Creates a task and waits for people to answer it. */
|
|
106
146
|
verify(params: CreateTask, opts?: {
|
|
107
147
|
timeoutMs?: number;
|
|
@@ -115,4 +155,4 @@ declare class Plures {
|
|
|
115
155
|
static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
|
|
116
156
|
}
|
|
117
157
|
|
|
118
|
-
export { type CreateTask, type Escalation, type Option, Plures, PluresError, type Result, type Task, type TaskStatus, VERSION, type WebhookEvent, Plures as default };
|
|
158
|
+
export { type Balance, type CreateTask, type Escalation, type Option, Plures, PluresError, type Result, type Task, type TaskStatus, VERSION, type WebhookEvent, Plures as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -32,12 +32,27 @@ type Task = {
|
|
|
32
32
|
context: string | null;
|
|
33
33
|
image_url: string | null;
|
|
34
34
|
instructions: string | null;
|
|
35
|
+
audio_url?: string | null;
|
|
36
|
+
video_url?: string | null;
|
|
37
|
+
media_seconds?: number | null;
|
|
38
|
+
sensitive?: boolean;
|
|
35
39
|
options: Option[];
|
|
36
40
|
verifiers: number;
|
|
37
41
|
presence_check?: boolean;
|
|
38
42
|
result: Result | null;
|
|
39
43
|
escalation?: Escalation | null;
|
|
40
44
|
metadata: Record<string, unknown>;
|
|
45
|
+
/** Live tasks only: price per answer and what answers have cost so far, in US cents. */
|
|
46
|
+
cost?: {
|
|
47
|
+
per_answer_cents: number;
|
|
48
|
+
answers_billed: number;
|
|
49
|
+
total_cents: number;
|
|
50
|
+
} | null;
|
|
51
|
+
/** Where this decision sits on the Plures ledger, once recorded. */
|
|
52
|
+
ledger?: {
|
|
53
|
+
seq: number;
|
|
54
|
+
url: string;
|
|
55
|
+
} | null;
|
|
41
56
|
webhook_url: string | null;
|
|
42
57
|
created_at: string;
|
|
43
58
|
completed_at: string | null;
|
|
@@ -48,6 +63,14 @@ type CreateTask = {
|
|
|
48
63
|
options: (string | Option)[];
|
|
49
64
|
context?: string;
|
|
50
65
|
image_url?: string;
|
|
66
|
+
/** A recording people play through before answering, up to 3 minutes. Needs media_seconds. */
|
|
67
|
+
audio_url?: string;
|
|
68
|
+
/** A video people play through before answering, up to 3 minutes. Needs media_seconds. Not with audio_url. */
|
|
69
|
+
video_url?: string;
|
|
70
|
+
/** The clip's length in seconds, 1 to 180. Required with audio_url or video_url; pay scales with it. */
|
|
71
|
+
media_seconds?: number;
|
|
72
|
+
/** Disturbing content: only verifiers who opted in get it, behind a warning. Default false. */
|
|
73
|
+
sensitive?: boolean;
|
|
51
74
|
instructions?: string;
|
|
52
75
|
verifiers?: 1 | 3 | 5 | 7 | 9;
|
|
53
76
|
max_verifiers?: number;
|
|
@@ -61,13 +84,28 @@ type CreateTask = {
|
|
|
61
84
|
/** Agreement below which this task goes to your team, 0 to 1. Default from your dashboard. */
|
|
62
85
|
escalate_below?: number;
|
|
63
86
|
};
|
|
87
|
+
/** Prepaid credit for live tasks, in US cents. */
|
|
88
|
+
type Balance = {
|
|
89
|
+
object: "balance";
|
|
90
|
+
currency: "usd";
|
|
91
|
+
available_cents: number;
|
|
92
|
+
held_cents: number;
|
|
93
|
+
balance_cents: number;
|
|
94
|
+
price_per_unit_cents: number;
|
|
95
|
+
billing: "prepaid" | "invoice";
|
|
96
|
+
auto_topup: {
|
|
97
|
+
enabled: boolean;
|
|
98
|
+
below_cents: number;
|
|
99
|
+
amount_cents: number;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
64
102
|
type WebhookEvent = {
|
|
65
103
|
id: string;
|
|
66
104
|
type: "task.completed" | "task.expired" | "task.canceled";
|
|
67
105
|
created_at: string;
|
|
68
106
|
data: Task;
|
|
69
107
|
};
|
|
70
|
-
declare const VERSION = "1.
|
|
108
|
+
declare const VERSION = "1.3.0";
|
|
71
109
|
declare class PluresError extends Error {
|
|
72
110
|
readonly status: number;
|
|
73
111
|
readonly type: string;
|
|
@@ -102,6 +140,8 @@ declare class Plures {
|
|
|
102
140
|
intervalMs?: number;
|
|
103
141
|
}) => Promise<Task>;
|
|
104
142
|
};
|
|
143
|
+
/** Your prepaid credit. A live task that could cost more than available_cents is refused with a 402 insufficient_credits error. */
|
|
144
|
+
balance: () => Promise<Balance>;
|
|
105
145
|
/** Creates a task and waits for people to answer it. */
|
|
106
146
|
verify(params: CreateTask, opts?: {
|
|
107
147
|
timeoutMs?: number;
|
|
@@ -115,4 +155,4 @@ declare class Plures {
|
|
|
115
155
|
static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
|
|
116
156
|
}
|
|
117
157
|
|
|
118
|
-
export { type CreateTask, type Escalation, type Option, Plures, PluresError, type Result, type Task, type TaskStatus, VERSION, type WebhookEvent, Plures as default };
|
|
158
|
+
export { type Balance, type CreateTask, type Escalation, type Option, Plures, PluresError, type Result, type Task, type TaskStatus, VERSION, type WebhookEvent, Plures as default };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var VERSION = "1.
|
|
2
|
+
var VERSION = "1.3.0";
|
|
3
3
|
var PluresError = class extends Error {
|
|
4
4
|
constructor(message, status, type) {
|
|
5
5
|
super(message);
|
|
@@ -54,6 +54,8 @@ var Plures = class {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
+
/** Your prepaid credit. A live task that could cost more than available_cents is refused with a 402 insufficient_credits error. */
|
|
58
|
+
balance = () => this.req("GET", "/api/v1/balance");
|
|
57
59
|
/** Creates a task and waits for people to answer it. */
|
|
58
60
|
async verify(params, opts = {}) {
|
|
59
61
|
const t = await this.tasks.create(params, { idempotencyKey: opts.idempotencyKey });
|