plures 1.2.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 +1 -0
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ if (event.type === "task.completed" && event.data.result?.agreement === 1) {
|
|
|
46
46
|
|
|
47
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
|
@@ -42,6 +42,12 @@ type Task = {
|
|
|
42
42
|
result: Result | null;
|
|
43
43
|
escalation?: Escalation | null;
|
|
44
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;
|
|
45
51
|
/** Where this decision sits on the Plures ledger, once recorded. */
|
|
46
52
|
ledger?: {
|
|
47
53
|
seq: number;
|
|
@@ -78,13 +84,28 @@ type CreateTask = {
|
|
|
78
84
|
/** Agreement below which this task goes to your team, 0 to 1. Default from your dashboard. */
|
|
79
85
|
escalate_below?: number;
|
|
80
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
|
+
};
|
|
81
102
|
type WebhookEvent = {
|
|
82
103
|
id: string;
|
|
83
104
|
type: "task.completed" | "task.expired" | "task.canceled";
|
|
84
105
|
created_at: string;
|
|
85
106
|
data: Task;
|
|
86
107
|
};
|
|
87
|
-
declare const VERSION = "1.
|
|
108
|
+
declare const VERSION = "1.3.0";
|
|
88
109
|
declare class PluresError extends Error {
|
|
89
110
|
readonly status: number;
|
|
90
111
|
readonly type: string;
|
|
@@ -119,6 +140,8 @@ declare class Plures {
|
|
|
119
140
|
intervalMs?: number;
|
|
120
141
|
}) => Promise<Task>;
|
|
121
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>;
|
|
122
145
|
/** Creates a task and waits for people to answer it. */
|
|
123
146
|
verify(params: CreateTask, opts?: {
|
|
124
147
|
timeoutMs?: number;
|
|
@@ -132,4 +155,4 @@ declare class Plures {
|
|
|
132
155
|
static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
|
|
133
156
|
}
|
|
134
157
|
|
|
135
|
-
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
|
@@ -42,6 +42,12 @@ type Task = {
|
|
|
42
42
|
result: Result | null;
|
|
43
43
|
escalation?: Escalation | null;
|
|
44
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;
|
|
45
51
|
/** Where this decision sits on the Plures ledger, once recorded. */
|
|
46
52
|
ledger?: {
|
|
47
53
|
seq: number;
|
|
@@ -78,13 +84,28 @@ type CreateTask = {
|
|
|
78
84
|
/** Agreement below which this task goes to your team, 0 to 1. Default from your dashboard. */
|
|
79
85
|
escalate_below?: number;
|
|
80
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
|
+
};
|
|
81
102
|
type WebhookEvent = {
|
|
82
103
|
id: string;
|
|
83
104
|
type: "task.completed" | "task.expired" | "task.canceled";
|
|
84
105
|
created_at: string;
|
|
85
106
|
data: Task;
|
|
86
107
|
};
|
|
87
|
-
declare const VERSION = "1.
|
|
108
|
+
declare const VERSION = "1.3.0";
|
|
88
109
|
declare class PluresError extends Error {
|
|
89
110
|
readonly status: number;
|
|
90
111
|
readonly type: string;
|
|
@@ -119,6 +140,8 @@ declare class Plures {
|
|
|
119
140
|
intervalMs?: number;
|
|
120
141
|
}) => Promise<Task>;
|
|
121
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>;
|
|
122
145
|
/** Creates a task and waits for people to answer it. */
|
|
123
146
|
verify(params: CreateTask, opts?: {
|
|
124
147
|
timeoutMs?: number;
|
|
@@ -132,4 +155,4 @@ declare class Plures {
|
|
|
132
155
|
static verifyWebhook(rawBody: string, signatureHeader: string | null, secret: string, toleranceSec?: number): Promise<WebhookEvent>;
|
|
133
156
|
}
|
|
134
157
|
|
|
135
|
-
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 });
|