@pushary/server 1.3.3 → 1.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 +121 -0
- package/dist/adapters.cjs +733 -0
- package/dist/adapters.cjs.map +1 -0
- package/dist/adapters.d.cts +310 -0
- package/dist/adapters.d.ts +310 -0
- package/dist/adapters.js +316 -0
- package/dist/adapters.js.map +1 -0
- package/dist/chunk-E6DWMKLZ.js +388 -0
- package/dist/chunk-E6DWMKLZ.js.map +1 -0
- package/dist/index.cjs +116 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -412
- package/dist/index.d.ts +2 -412
- package/dist/index.js +9 -265
- package/dist/index.js.map +1 -1
- package/dist/util-DeGBh5at.d.cts +652 -0
- package/dist/util-DeGBh5at.d.ts +652 -0
- package/package.json +6 -1
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
interface PusharyConfig {
|
|
2
|
+
readonly apiKey: string;
|
|
3
|
+
readonly baseUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
interface ListParams {
|
|
6
|
+
readonly limit?: number;
|
|
7
|
+
readonly cursor?: string;
|
|
8
|
+
}
|
|
9
|
+
interface PaginatedResponse<T> {
|
|
10
|
+
readonly data: readonly T[];
|
|
11
|
+
readonly nextCursor?: string;
|
|
12
|
+
readonly hasMore: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface Subscriber {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly siteId: string;
|
|
17
|
+
readonly endpoint: string;
|
|
18
|
+
readonly status: 'active' | 'unsubscribed' | 'expired' | 'bounced';
|
|
19
|
+
readonly browser?: string;
|
|
20
|
+
readonly os?: string;
|
|
21
|
+
readonly deviceType?: string;
|
|
22
|
+
readonly country?: string;
|
|
23
|
+
readonly city?: string;
|
|
24
|
+
readonly timezone?: string;
|
|
25
|
+
readonly language?: string;
|
|
26
|
+
readonly tags?: readonly string[];
|
|
27
|
+
readonly externalId?: string;
|
|
28
|
+
readonly createdAt: string;
|
|
29
|
+
readonly lastActiveAt?: string;
|
|
30
|
+
}
|
|
31
|
+
interface SubscriberListParams extends ListParams {
|
|
32
|
+
readonly status?: 'active' | 'unsubscribed' | 'expired' | 'bounced';
|
|
33
|
+
readonly tags?: readonly string[];
|
|
34
|
+
readonly externalId?: string;
|
|
35
|
+
}
|
|
36
|
+
interface UpdateSubscriber {
|
|
37
|
+
readonly tags?: readonly string[];
|
|
38
|
+
readonly externalId?: string;
|
|
39
|
+
readonly customData?: Readonly<Record<string, unknown>>;
|
|
40
|
+
}
|
|
41
|
+
interface Campaign {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly siteId: string;
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly title: string;
|
|
46
|
+
readonly body: string;
|
|
47
|
+
readonly iconUrl?: string;
|
|
48
|
+
readonly imageUrl?: string;
|
|
49
|
+
readonly actionUrl?: string;
|
|
50
|
+
readonly status: 'draft' | 'scheduled' | 'sending' | 'active' | 'paused' | 'completed' | 'cancelled';
|
|
51
|
+
readonly scheduledAt?: string;
|
|
52
|
+
readonly totalTargeted: number;
|
|
53
|
+
readonly totalSent: number;
|
|
54
|
+
readonly totalDelivered: number;
|
|
55
|
+
readonly totalClicked: number;
|
|
56
|
+
readonly createdAt: string;
|
|
57
|
+
}
|
|
58
|
+
interface CreateCampaign {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly title: string;
|
|
61
|
+
readonly body: string;
|
|
62
|
+
readonly iconUrl?: string;
|
|
63
|
+
readonly imageUrl?: string;
|
|
64
|
+
readonly actionUrl?: string;
|
|
65
|
+
readonly scheduledAt?: string;
|
|
66
|
+
readonly segmentId?: string;
|
|
67
|
+
readonly tags?: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
interface UpdateCampaign {
|
|
70
|
+
readonly name?: string;
|
|
71
|
+
readonly title?: string;
|
|
72
|
+
readonly body?: string;
|
|
73
|
+
readonly iconUrl?: string;
|
|
74
|
+
readonly imageUrl?: string;
|
|
75
|
+
readonly actionUrl?: string;
|
|
76
|
+
readonly scheduledAt?: string;
|
|
77
|
+
readonly status?: 'draft' | 'paused' | 'cancelled';
|
|
78
|
+
}
|
|
79
|
+
interface Template {
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly siteId: string;
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly title: string;
|
|
84
|
+
readonly body: string;
|
|
85
|
+
readonly iconUrl?: string;
|
|
86
|
+
readonly imageUrl?: string;
|
|
87
|
+
readonly actionUrl?: string;
|
|
88
|
+
readonly createdAt: string;
|
|
89
|
+
}
|
|
90
|
+
interface CreateTemplate {
|
|
91
|
+
readonly name: string;
|
|
92
|
+
readonly title: string;
|
|
93
|
+
readonly body: string;
|
|
94
|
+
readonly iconUrl?: string;
|
|
95
|
+
readonly imageUrl?: string;
|
|
96
|
+
readonly actionUrl?: string;
|
|
97
|
+
}
|
|
98
|
+
interface UpdateTemplate {
|
|
99
|
+
readonly name?: string;
|
|
100
|
+
readonly title?: string;
|
|
101
|
+
readonly body?: string;
|
|
102
|
+
readonly iconUrl?: string;
|
|
103
|
+
readonly imageUrl?: string;
|
|
104
|
+
readonly actionUrl?: string;
|
|
105
|
+
}
|
|
106
|
+
interface SendNotification {
|
|
107
|
+
readonly title: string;
|
|
108
|
+
readonly body: string;
|
|
109
|
+
readonly iconUrl?: string;
|
|
110
|
+
readonly imageUrl?: string;
|
|
111
|
+
readonly url?: string;
|
|
112
|
+
readonly subscriberIds?: readonly string[];
|
|
113
|
+
readonly externalIds?: readonly string[];
|
|
114
|
+
readonly tags?: readonly string[];
|
|
115
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
116
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
117
|
+
/** Stable across retries of one logical send. Maximum 200 characters. */
|
|
118
|
+
readonly idempotencyKey?: string;
|
|
119
|
+
}
|
|
120
|
+
interface SendResult {
|
|
121
|
+
readonly success: boolean;
|
|
122
|
+
readonly campaignId?: string;
|
|
123
|
+
readonly status?: 'queued';
|
|
124
|
+
readonly queued?: number;
|
|
125
|
+
readonly duplicate?: boolean;
|
|
126
|
+
/** @deprecated This is the queued recipient count, not a device receipt. */
|
|
127
|
+
readonly sent: number;
|
|
128
|
+
readonly limits: {
|
|
129
|
+
readonly remaining: number;
|
|
130
|
+
readonly limit: number;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
interface SubscriberCount {
|
|
134
|
+
readonly total: number;
|
|
135
|
+
readonly active: number;
|
|
136
|
+
readonly unsubscribed: number;
|
|
137
|
+
}
|
|
138
|
+
interface CampaignStats {
|
|
139
|
+
readonly totalSent: number;
|
|
140
|
+
readonly totalDelivered: number;
|
|
141
|
+
readonly totalClicked: number;
|
|
142
|
+
readonly totalFailed: number;
|
|
143
|
+
readonly deliveryRate: number;
|
|
144
|
+
readonly clickRate: number;
|
|
145
|
+
}
|
|
146
|
+
type FlowTriggerType = 'notification_click' | 'notification_impression' | 'notification_dismiss' | 'subscription' | 'unsubscription';
|
|
147
|
+
type FlowStepType = 'send_notification' | 'delay' | 'exit';
|
|
148
|
+
type FlowStatus = 'draft' | 'active' | 'paused' | 'archived';
|
|
149
|
+
interface FlowStepConfig {
|
|
150
|
+
readonly notification?: {
|
|
151
|
+
readonly title: string;
|
|
152
|
+
readonly body: string;
|
|
153
|
+
readonly iconUrl?: string;
|
|
154
|
+
readonly imageUrl?: string;
|
|
155
|
+
readonly actionUrl?: string;
|
|
156
|
+
};
|
|
157
|
+
readonly delay?: {
|
|
158
|
+
readonly value: number;
|
|
159
|
+
readonly unit: 'seconds' | 'minutes' | 'hours' | 'days';
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
interface FlowStep {
|
|
163
|
+
readonly id: string;
|
|
164
|
+
readonly flowId: string;
|
|
165
|
+
readonly stepOrder: number;
|
|
166
|
+
readonly stepType: FlowStepType;
|
|
167
|
+
readonly config: FlowStepConfig;
|
|
168
|
+
readonly createdAt: string;
|
|
169
|
+
readonly updatedAt: string;
|
|
170
|
+
}
|
|
171
|
+
interface Flow {
|
|
172
|
+
readonly id: string;
|
|
173
|
+
readonly siteId: string;
|
|
174
|
+
readonly name: string;
|
|
175
|
+
readonly description?: string;
|
|
176
|
+
readonly triggerType: FlowTriggerType;
|
|
177
|
+
readonly triggerCampaignId?: string;
|
|
178
|
+
readonly status: FlowStatus;
|
|
179
|
+
readonly executionCount: number;
|
|
180
|
+
readonly createdBy?: string;
|
|
181
|
+
readonly createdAt: string;
|
|
182
|
+
readonly updatedAt: string;
|
|
183
|
+
readonly steps?: readonly FlowStep[];
|
|
184
|
+
}
|
|
185
|
+
interface FlowStepInput {
|
|
186
|
+
readonly stepType: FlowStepType;
|
|
187
|
+
readonly config: FlowStepConfig;
|
|
188
|
+
}
|
|
189
|
+
interface CreateFlow {
|
|
190
|
+
readonly name: string;
|
|
191
|
+
readonly description?: string;
|
|
192
|
+
readonly triggerType: FlowTriggerType;
|
|
193
|
+
readonly triggerCampaignId?: string;
|
|
194
|
+
readonly steps?: readonly FlowStepInput[];
|
|
195
|
+
}
|
|
196
|
+
interface UpdateFlow {
|
|
197
|
+
readonly name?: string;
|
|
198
|
+
readonly description?: string;
|
|
199
|
+
readonly triggerType?: FlowTriggerType;
|
|
200
|
+
readonly triggerCampaignId?: string;
|
|
201
|
+
readonly status?: FlowStatus;
|
|
202
|
+
readonly steps?: readonly FlowStepInput[];
|
|
203
|
+
}
|
|
204
|
+
interface FlowListParams extends ListParams {
|
|
205
|
+
readonly status?: FlowStatus;
|
|
206
|
+
}
|
|
207
|
+
type DecisionType = 'confirm' | 'select' | 'input';
|
|
208
|
+
type DecisionStatus = 'pending' | 'answered' | 'expired' | 'cancelled';
|
|
209
|
+
/**
|
|
210
|
+
* Typed arguments of an action. Scalars only: a rule reads these, and a nested
|
|
211
|
+
* object has no comparable value to read.
|
|
212
|
+
*/
|
|
213
|
+
type DecisionParameters = Readonly<Record<string, string | number | boolean>>;
|
|
214
|
+
/**
|
|
215
|
+
* How to render one parameter to the person deciding.
|
|
216
|
+
*
|
|
217
|
+
* Declared here rather than imported, for the same reason AuthorizationVerdict
|
|
218
|
+
* is: this package is MIT and must not depend on Pushary's private core, so the
|
|
219
|
+
* wire values are the contract between them.
|
|
220
|
+
*
|
|
221
|
+
* A currency parameter holds MINOR units — 4800 is EUR 48.00. A float cannot
|
|
222
|
+
* hold money exactly and a pre-formatted string cannot be compared by a rule.
|
|
223
|
+
*/
|
|
224
|
+
type PresentedFormat = {
|
|
225
|
+
readonly kind: 'text';
|
|
226
|
+
} | {
|
|
227
|
+
readonly kind: 'currency';
|
|
228
|
+
readonly currency: string;
|
|
229
|
+
} | {
|
|
230
|
+
readonly kind: 'quantity';
|
|
231
|
+
readonly unit?: string;
|
|
232
|
+
} | {
|
|
233
|
+
readonly kind: 'timestamp';
|
|
234
|
+
} | {
|
|
235
|
+
readonly kind: 'boolean';
|
|
236
|
+
};
|
|
237
|
+
interface PresentedChange {
|
|
238
|
+
/**
|
|
239
|
+
* A key of `parameters`. The value is read from there and never carried here,
|
|
240
|
+
* so what the person sees and what a rule reads cannot be different numbers.
|
|
241
|
+
*/
|
|
242
|
+
readonly parameter: string;
|
|
243
|
+
/** What to call it to a person: "Refund amount", not "amount_minor". */
|
|
244
|
+
readonly label: string;
|
|
245
|
+
readonly format: PresentedFormat;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The action in business language, for the surfaces a person actually reads.
|
|
249
|
+
*
|
|
250
|
+
* Optional. A caller that sends none keeps the free-text `question` it has
|
|
251
|
+
* always sent; only a caller that claims a presentation is held to it, and an
|
|
252
|
+
* invalid one is refused rather than half-rendered.
|
|
253
|
+
*/
|
|
254
|
+
interface ActionPresentation {
|
|
255
|
+
/** The action as a person would name it. "Refund order #4471". */
|
|
256
|
+
readonly label: string;
|
|
257
|
+
/** What actually happens. "Returns EUR 48.00 to the customer's card." */
|
|
258
|
+
readonly effect: string;
|
|
259
|
+
readonly changes?: readonly PresentedChange[];
|
|
260
|
+
/** Optional. Why this one is worth stopping for. */
|
|
261
|
+
readonly risk?: string;
|
|
262
|
+
}
|
|
263
|
+
interface DecisionSubject {
|
|
264
|
+
readonly toolName?: string;
|
|
265
|
+
readonly toolTarget?: string;
|
|
266
|
+
/**
|
|
267
|
+
* Who the action runs on behalf of, e.g. `user:u_44` or `team:billing`. This is
|
|
268
|
+
* the principal, which is not necessarily the person who approves: `externalId`
|
|
269
|
+
* names the recipient of the question, `actor` names whose authority the action
|
|
270
|
+
* claims. Max 120 characters.
|
|
271
|
+
*/
|
|
272
|
+
readonly actor?: string;
|
|
273
|
+
/** Which deployment the action runs against, e.g. `production`. Max 40 characters. */
|
|
274
|
+
readonly environment?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Typed arguments of the action, e.g. `{ amount: 4800, currency: 'EUR' }`.
|
|
277
|
+
* Scalars only, at most 32 keys. Recorded on the audit row so an approval can be
|
|
278
|
+
* read back against what it approved.
|
|
279
|
+
*
|
|
280
|
+
* Rejected as a whole (400) if any value is not a string, a finite number or a
|
|
281
|
+
* boolean, rather than being partly dropped: a rule that reads a missing
|
|
282
|
+
* parameter can only ever decide more permissively than one that reads it.
|
|
283
|
+
*/
|
|
284
|
+
readonly parameters?: DecisionParameters;
|
|
285
|
+
/**
|
|
286
|
+
* What the person deciding sees, in business language. Its `changes` name
|
|
287
|
+
* parameters rather than carrying values, so display and policy read the same
|
|
288
|
+
* numbers. Refused (400) if it names a parameter you did not send, names one
|
|
289
|
+
* whose name marks it secret, or gives a value a format cannot render.
|
|
290
|
+
*/
|
|
291
|
+
readonly presentation?: ActionPresentation;
|
|
292
|
+
/**
|
|
293
|
+
* Return a short-lived `approvalUrl` you can deliver yourself, over the email,
|
|
294
|
+
* SMS or in-app inbox you already have for this end-user.
|
|
295
|
+
*
|
|
296
|
+
* Off by default: a capability URL returned on every create is a capability URL
|
|
297
|
+
* in every log, for the majority of decisions that never needed one. The link
|
|
298
|
+
* is bound to this decision, this site and this recipient, and expires.
|
|
299
|
+
*/
|
|
300
|
+
readonly approvalUrl?: boolean;
|
|
301
|
+
}
|
|
302
|
+
/** Whether a decision can reach this person, and by whose hands. */
|
|
303
|
+
type DecisionDeliverability = 'push' | 'fallback' | 'unreachable';
|
|
304
|
+
interface DecisionReach {
|
|
305
|
+
readonly externalId: string;
|
|
306
|
+
/**
|
|
307
|
+
* `push` — Pushary delivers it. `fallback` — nobody is enrolled, but you know
|
|
308
|
+
* this end-user: open the decision with `approvalUrl: true` and deliver the
|
|
309
|
+
* link yourself. `unreachable` — no end-user was named, so there is nobody to
|
|
310
|
+
* reach and no link to mint.
|
|
311
|
+
*/
|
|
312
|
+
readonly deliverability: DecisionDeliverability;
|
|
313
|
+
readonly reachable: boolean;
|
|
314
|
+
readonly reachableChannels: number;
|
|
315
|
+
readonly deviceCount: number;
|
|
316
|
+
readonly webEndpoints: number;
|
|
317
|
+
readonly hint: string;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* What the sandbox's simulated approver does.
|
|
321
|
+
*
|
|
322
|
+
* `approve` is the default. `no_answer` leaves the decision open, which is how
|
|
323
|
+
* you exercise your own fail-closed path without waiting on a real phone.
|
|
324
|
+
*
|
|
325
|
+
* Read only by a key issued on your workspace's sandbox site, where nothing is
|
|
326
|
+
* delivered and nobody is asked. Ignored in production, where the approver is a
|
|
327
|
+
* person.
|
|
328
|
+
*/
|
|
329
|
+
type SandboxOutcome = 'approve' | 'deny' | 'no_answer';
|
|
330
|
+
interface CreateDecision extends DecisionSubject {
|
|
331
|
+
readonly question: string;
|
|
332
|
+
readonly type?: DecisionType;
|
|
333
|
+
readonly options?: readonly string[];
|
|
334
|
+
readonly externalId?: string;
|
|
335
|
+
readonly email?: string;
|
|
336
|
+
readonly callbackUrl?: string;
|
|
337
|
+
readonly agentName?: string;
|
|
338
|
+
readonly context?: string;
|
|
339
|
+
readonly placeholder?: string;
|
|
340
|
+
readonly expiresInSeconds?: number;
|
|
341
|
+
readonly wait?: boolean;
|
|
342
|
+
readonly timeoutSeconds?: number;
|
|
343
|
+
readonly idempotencyKey?: string;
|
|
344
|
+
readonly poweredBy?: boolean;
|
|
345
|
+
readonly requireReachable?: boolean;
|
|
346
|
+
readonly sandboxOutcome?: SandboxOutcome;
|
|
347
|
+
}
|
|
348
|
+
type AuthorizationVerdict = 'allow' | 'deny' | 'requires_human';
|
|
349
|
+
interface AuthorizationQuery extends DecisionSubject {
|
|
350
|
+
/** The action being authorized. Required: a rule has to name it. */
|
|
351
|
+
readonly toolName: string;
|
|
352
|
+
/** Your own id for the end-user this action belongs to. */
|
|
353
|
+
readonly externalId?: string;
|
|
354
|
+
/**
|
|
355
|
+
* Shown to the person, if policy defers to one. Defaults to the action and its
|
|
356
|
+
* target, so a caller that only names the action still asks a readable question.
|
|
357
|
+
*/
|
|
358
|
+
readonly question?: string;
|
|
359
|
+
readonly agentName?: string;
|
|
360
|
+
}
|
|
361
|
+
interface AuthorizeRequest extends AuthorizationQuery {
|
|
362
|
+
/** Forwarded to the ask, and used only when policy defers to a person. */
|
|
363
|
+
readonly timeoutMs?: number;
|
|
364
|
+
readonly expiresInSeconds?: number;
|
|
365
|
+
readonly idempotencyKey?: string;
|
|
366
|
+
readonly requireReachable?: boolean;
|
|
367
|
+
}
|
|
368
|
+
interface AuthorizeResult {
|
|
369
|
+
/** Fail-closed. False for a denial, and false when nobody answered. */
|
|
370
|
+
readonly approved: boolean;
|
|
371
|
+
/** What settled it: a rule, or a person. */
|
|
372
|
+
readonly resolvedBy: 'policy' | 'human';
|
|
373
|
+
/** The rule that decided, or null when no rule named the action. */
|
|
374
|
+
readonly policy: string | null;
|
|
375
|
+
readonly reason: string;
|
|
376
|
+
/** The decision opened when policy deferred to a person, else null. */
|
|
377
|
+
readonly decisionId: string | null;
|
|
378
|
+
/** The audit row a policy-settled authorization produced, else null. */
|
|
379
|
+
readonly authorizationId: string | null;
|
|
380
|
+
}
|
|
381
|
+
interface AuthorizationEvaluation {
|
|
382
|
+
readonly verdict: AuthorizationVerdict;
|
|
383
|
+
readonly policy: string | null;
|
|
384
|
+
readonly reason: string;
|
|
385
|
+
readonly authorizationId: string | null;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The exact subject an authorization was recorded against.
|
|
389
|
+
*
|
|
390
|
+
* Carried from the gate to the consume rather than rebuilt, because the two have
|
|
391
|
+
* to name the same action and rebuilding it is a second chance for them not to.
|
|
392
|
+
* The server digests this and what it recorded, and refuses unless they match.
|
|
393
|
+
*/
|
|
394
|
+
interface AuthorizationBinding {
|
|
395
|
+
/** The settled authorization: a policy verdict's id, or an approved decision's id. */
|
|
396
|
+
readonly authorizationId: string;
|
|
397
|
+
readonly toolName: string;
|
|
398
|
+
readonly toolTarget?: string;
|
|
399
|
+
readonly actor?: string;
|
|
400
|
+
readonly environment?: string;
|
|
401
|
+
readonly externalId?: string;
|
|
402
|
+
readonly parameters?: DecisionParameters;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Who allowed it, frozen when it was allowed.
|
|
406
|
+
*
|
|
407
|
+
* A rule can be edited and a member can lose their seat. An authorization that
|
|
408
|
+
* can only say "something allowed this" is not an audit trail, so the deciding
|
|
409
|
+
* authority is copied onto the permit and never updated.
|
|
410
|
+
*/
|
|
411
|
+
type AuthorizationAuthority = {
|
|
412
|
+
readonly kind: 'policy';
|
|
413
|
+
readonly rulePattern?: string;
|
|
414
|
+
readonly authorizationRuleId?: string;
|
|
415
|
+
readonly policyId?: string;
|
|
416
|
+
} | {
|
|
417
|
+
readonly kind: 'human';
|
|
418
|
+
readonly answeredAt: string;
|
|
419
|
+
readonly answerSource?: string;
|
|
420
|
+
readonly approverUserId?: string;
|
|
421
|
+
readonly approverExternalId?: string;
|
|
422
|
+
};
|
|
423
|
+
/** Why a consume was refused. Every branch is a refusal; none of them means allowed. */
|
|
424
|
+
type PermitRefusal = 'not_authorized' | 'action_mismatch' | 'expired' | 'already_consumed';
|
|
425
|
+
type PermitExecutionState = 'running' | 'succeeded' | 'failed';
|
|
426
|
+
interface ConsumedAuthorization {
|
|
427
|
+
readonly permitId: string;
|
|
428
|
+
readonly authority: AuthorizationAuthority;
|
|
429
|
+
/** ISO-8601. The permit is spent already; this is when it would have stopped being spendable. */
|
|
430
|
+
readonly expiresAt: string;
|
|
431
|
+
}
|
|
432
|
+
type ConsumeAuthorizationResult = {
|
|
433
|
+
readonly consumed: true;
|
|
434
|
+
readonly permit: ConsumedAuthorization;
|
|
435
|
+
} | {
|
|
436
|
+
readonly consumed: false;
|
|
437
|
+
readonly refusal: PermitRefusal;
|
|
438
|
+
readonly reason: string;
|
|
439
|
+
/** On `already_consumed`, what the winning execution did. */
|
|
440
|
+
readonly executionState?: PermitExecutionState;
|
|
441
|
+
};
|
|
442
|
+
type ExecutionOutcome = 'succeeded' | 'failed';
|
|
443
|
+
interface ExecutionReceipt {
|
|
444
|
+
readonly permitId: string;
|
|
445
|
+
readonly outcome: ExecutionOutcome;
|
|
446
|
+
/** Bounded and redacted server-side. What the action did, or why it did not. */
|
|
447
|
+
readonly summary?: string;
|
|
448
|
+
}
|
|
449
|
+
interface DecisionReachability {
|
|
450
|
+
readonly reachable?: boolean;
|
|
451
|
+
readonly reachableChannels?: number;
|
|
452
|
+
readonly deviceCount?: number;
|
|
453
|
+
}
|
|
454
|
+
interface DecisionResult extends DecisionReachability {
|
|
455
|
+
readonly decisionId: string;
|
|
456
|
+
readonly status: DecisionStatus;
|
|
457
|
+
readonly answered: boolean;
|
|
458
|
+
readonly value?: string | null;
|
|
459
|
+
readonly type?: DecisionType;
|
|
460
|
+
readonly question?: string;
|
|
461
|
+
readonly pollUrl?: string;
|
|
462
|
+
readonly decisionPageUrl?: string;
|
|
463
|
+
readonly expiresInSeconds?: number;
|
|
464
|
+
readonly idempotent?: boolean;
|
|
465
|
+
readonly hint?: string;
|
|
466
|
+
}
|
|
467
|
+
interface Decision {
|
|
468
|
+
readonly decisionId: string;
|
|
469
|
+
readonly status: DecisionStatus;
|
|
470
|
+
readonly answered: boolean;
|
|
471
|
+
readonly value: string | null;
|
|
472
|
+
readonly type: DecisionType;
|
|
473
|
+
readonly question: string;
|
|
474
|
+
readonly options: readonly string[] | null;
|
|
475
|
+
readonly externalId: string | null;
|
|
476
|
+
readonly context: string | null;
|
|
477
|
+
readonly createdAt: string;
|
|
478
|
+
readonly answeredAt: string | null;
|
|
479
|
+
readonly expiresAt: string | null;
|
|
480
|
+
}
|
|
481
|
+
interface DecisionAnswerResult {
|
|
482
|
+
readonly decisionId: string;
|
|
483
|
+
readonly status: DecisionStatus;
|
|
484
|
+
readonly answered: boolean;
|
|
485
|
+
readonly value?: string | null;
|
|
486
|
+
}
|
|
487
|
+
interface CancelDecisionResult {
|
|
488
|
+
readonly decisionId: string;
|
|
489
|
+
readonly cancelled: boolean;
|
|
490
|
+
readonly status: string;
|
|
491
|
+
}
|
|
492
|
+
interface WebhookSecret {
|
|
493
|
+
readonly webhookSecret: string;
|
|
494
|
+
}
|
|
495
|
+
interface DecisionCallback {
|
|
496
|
+
readonly correlationId: string;
|
|
497
|
+
readonly answer: string;
|
|
498
|
+
readonly value: string;
|
|
499
|
+
readonly answeredAt: string;
|
|
500
|
+
readonly context?: string;
|
|
501
|
+
}
|
|
502
|
+
interface EnrollResult {
|
|
503
|
+
readonly externalId: string;
|
|
504
|
+
readonly token: string;
|
|
505
|
+
readonly deepLink: string;
|
|
506
|
+
readonly universalLink: string;
|
|
507
|
+
readonly expiresInSeconds: number;
|
|
508
|
+
}
|
|
509
|
+
interface AskDecision extends DecisionSubject {
|
|
510
|
+
readonly question: string;
|
|
511
|
+
readonly type?: DecisionType;
|
|
512
|
+
readonly options?: readonly string[];
|
|
513
|
+
readonly externalId?: string;
|
|
514
|
+
readonly email?: string;
|
|
515
|
+
readonly agentName?: string;
|
|
516
|
+
readonly context?: string;
|
|
517
|
+
readonly placeholder?: string;
|
|
518
|
+
readonly expiresInSeconds?: number;
|
|
519
|
+
readonly idempotencyKey?: string;
|
|
520
|
+
readonly poweredBy?: boolean;
|
|
521
|
+
readonly callbackUrl?: string;
|
|
522
|
+
readonly requireReachable?: boolean;
|
|
523
|
+
readonly sandboxOutcome?: SandboxOutcome;
|
|
524
|
+
readonly presentation?: ActionPresentation;
|
|
525
|
+
readonly approvalUrl?: boolean;
|
|
526
|
+
readonly timeoutMs?: number;
|
|
527
|
+
}
|
|
528
|
+
interface AskResult extends DecisionReachability {
|
|
529
|
+
readonly decisionId: string;
|
|
530
|
+
readonly status: DecisionStatus;
|
|
531
|
+
readonly answered: boolean;
|
|
532
|
+
readonly value: string | null;
|
|
533
|
+
readonly type: DecisionType;
|
|
534
|
+
readonly approved: boolean;
|
|
535
|
+
}
|
|
536
|
+
interface IssueBoundKey {
|
|
537
|
+
readonly externalId: string;
|
|
538
|
+
readonly name?: string;
|
|
539
|
+
readonly expiresInSeconds?: number;
|
|
540
|
+
}
|
|
541
|
+
interface BoundKeyResult {
|
|
542
|
+
readonly apiKey: string;
|
|
543
|
+
readonly keyPrefix: string;
|
|
544
|
+
readonly scope: 'bound';
|
|
545
|
+
readonly boundExternalId: string;
|
|
546
|
+
readonly expiresAt: string | null;
|
|
547
|
+
}
|
|
548
|
+
interface BoundKeySummary {
|
|
549
|
+
readonly keyPrefix: string;
|
|
550
|
+
readonly name: string;
|
|
551
|
+
readonly boundExternalId: string | null;
|
|
552
|
+
readonly isActive: boolean;
|
|
553
|
+
readonly lastUsedAt: string | null;
|
|
554
|
+
readonly expiresAt: string | null;
|
|
555
|
+
readonly createdAt: string;
|
|
556
|
+
}
|
|
557
|
+
interface RevokeKeyResult {
|
|
558
|
+
readonly keyPrefix: string;
|
|
559
|
+
readonly revoked: boolean;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
interface SubscribersResource {
|
|
563
|
+
readonly list: (params?: SubscriberListParams) => Promise<PaginatedResponse<Subscriber>>;
|
|
564
|
+
readonly get: (id: string) => Promise<Subscriber>;
|
|
565
|
+
readonly update: (id: string, data: UpdateSubscriber) => Promise<Subscriber>;
|
|
566
|
+
readonly delete: (id: string) => Promise<void>;
|
|
567
|
+
readonly count: () => Promise<SubscriberCount>;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
interface CampaignsResource {
|
|
571
|
+
readonly list: (params?: ListParams) => Promise<PaginatedResponse<Campaign>>;
|
|
572
|
+
readonly create: (data: CreateCampaign) => Promise<Campaign>;
|
|
573
|
+
readonly get: (id: string) => Promise<Campaign>;
|
|
574
|
+
readonly update: (id: string, data: UpdateCampaign) => Promise<Campaign>;
|
|
575
|
+
readonly delete: (id: string) => Promise<void>;
|
|
576
|
+
readonly send: (id: string) => Promise<Campaign>;
|
|
577
|
+
readonly pause: (id: string) => Promise<Campaign>;
|
|
578
|
+
readonly resume: (id: string) => Promise<Campaign>;
|
|
579
|
+
readonly stats: (id: string) => Promise<CampaignStats>;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
interface TemplatesResource {
|
|
583
|
+
readonly list: (params?: ListParams) => Promise<PaginatedResponse<Template>>;
|
|
584
|
+
readonly create: (data: CreateTemplate) => Promise<Template>;
|
|
585
|
+
readonly get: (id: string) => Promise<Template>;
|
|
586
|
+
readonly update: (id: string, data: UpdateTemplate) => Promise<Template>;
|
|
587
|
+
readonly delete: (id: string) => Promise<void>;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
interface NotificationsResource {
|
|
591
|
+
readonly send: (data: SendNotification) => Promise<SendResult>;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
interface FlowsResource {
|
|
595
|
+
readonly list: (params?: FlowListParams) => Promise<PaginatedResponse<Flow>>;
|
|
596
|
+
readonly create: (data: CreateFlow) => Promise<Flow>;
|
|
597
|
+
readonly get: (id: string) => Promise<Flow>;
|
|
598
|
+
readonly update: (id: string, data: UpdateFlow) => Promise<Flow>;
|
|
599
|
+
readonly delete: (id: string) => Promise<void>;
|
|
600
|
+
readonly activate: (id: string) => Promise<Flow>;
|
|
601
|
+
readonly pause: (id: string) => Promise<Flow>;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
interface DecisionsResource {
|
|
605
|
+
readonly create: (data: CreateDecision) => Promise<DecisionResult>;
|
|
606
|
+
readonly get: (id: string, opts?: {
|
|
607
|
+
readonly wait?: number;
|
|
608
|
+
}) => Promise<Decision>;
|
|
609
|
+
readonly ask: (data: AskDecision) => Promise<AskResult>;
|
|
610
|
+
readonly answer: (id: string, answer: string) => Promise<DecisionAnswerResult>;
|
|
611
|
+
readonly cancel: (id: string) => Promise<CancelDecisionResult>;
|
|
612
|
+
readonly getWebhookSecret: () => Promise<WebhookSecret>;
|
|
613
|
+
readonly rotateWebhookSecret: () => Promise<WebhookSecret>;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
interface KeysResource {
|
|
617
|
+
readonly issue: (data: IssueBoundKey) => Promise<BoundKeyResult>;
|
|
618
|
+
readonly list: () => Promise<readonly BoundKeySummary[]>;
|
|
619
|
+
readonly revoke: (keyPrefix: string) => Promise<RevokeKeyResult>;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
interface PusharyServer {
|
|
623
|
+
readonly subscribers: SubscribersResource;
|
|
624
|
+
readonly campaigns: CampaignsResource;
|
|
625
|
+
readonly templates: TemplatesResource;
|
|
626
|
+
readonly notifications: NotificationsResource;
|
|
627
|
+
readonly flows: FlowsResource;
|
|
628
|
+
readonly decisions: DecisionsResource;
|
|
629
|
+
readonly keys: KeysResource;
|
|
630
|
+
readonly authorize: (input: AuthorizeRequest) => Promise<AuthorizeResult>;
|
|
631
|
+
readonly evaluateAuthorization: (input: AuthorizationQuery) => Promise<AuthorizationEvaluation>;
|
|
632
|
+
readonly consumeAuthorization: (binding: AuthorizationBinding) => Promise<ConsumeAuthorizationResult>;
|
|
633
|
+
readonly recordExecution: (receipt: ExecutionReceipt) => Promise<{
|
|
634
|
+
readonly executionState: PermitExecutionState;
|
|
635
|
+
}>;
|
|
636
|
+
readonly enroll: (externalId: string) => Promise<EnrollResult>;
|
|
637
|
+
readonly reachability: (externalId: string) => Promise<DecisionReach>;
|
|
638
|
+
}
|
|
639
|
+
declare const createPusharyServer: (config: PusharyConfig) => PusharyServer;
|
|
640
|
+
|
|
641
|
+
declare const SIGNATURE_HEADER = "x-pushary-signature";
|
|
642
|
+
declare const verifyWebhookSignature: (rawBody: string, signature: string | null | undefined, secret: string) => boolean;
|
|
643
|
+
declare const parseDecisionCallback: (rawBody: string) => DecisionCallback | null;
|
|
644
|
+
|
|
645
|
+
declare const deterministicKey: (parts: readonly string[]) => string;
|
|
646
|
+
declare const isApproved: (decision: {
|
|
647
|
+
readonly status: DecisionStatus;
|
|
648
|
+
readonly type?: DecisionType;
|
|
649
|
+
readonly value: string | null;
|
|
650
|
+
}) => boolean;
|
|
651
|
+
|
|
652
|
+
export { type DecisionResult as $, type ActionPresentation as A, type PresentedChange as B, type Campaign as C, type DecisionType as D, type PresentedFormat as E, type Flow as F, type SandboxOutcome as G, type AuthorizationVerdict as H, type AuthorizationQuery as I, type AuthorizeRequest as J, type AuthorizeResult as K, type ListParams as L, type AuthorizationEvaluation as M, type AuthorizationBinding as N, type AuthorizationAuthority as O, type PusharyServer as P, type ConsumedAuthorization as Q, type ConsumeAuthorizationResult as R, type Subscriber as S, type Template as T, type UpdateSubscriber as U, type ExecutionOutcome as V, type ExecutionReceipt as W, type PermitRefusal as X, type PermitExecutionState as Y, type CreateDecision as Z, type DecisionReachability as _, type PusharyConfig as a, type Decision as a0, type DecisionAnswerResult as a1, type CancelDecisionResult as a2, type DecisionCallback as a3, type WebhookSecret as a4, type EnrollResult as a5, type AskDecision as a6, type AskResult as a7, type IssueBoundKey as a8, type BoundKeyResult as a9, type BoundKeySummary as aa, type RevokeKeyResult as ab, type SubscribersResource as ac, type CampaignsResource as ad, type TemplatesResource as ae, type NotificationsResource as af, type FlowsResource as ag, type DecisionsResource as ah, type KeysResource as ai, verifyWebhookSignature as aj, parseDecisionCallback as ak, SIGNATURE_HEADER as al, deterministicKey as am, isApproved as an, type SubscriberListParams as b, createPusharyServer as c, type SubscriberCount as d, type CreateCampaign as e, type UpdateCampaign as f, type CampaignStats as g, type CreateTemplate as h, type UpdateTemplate as i, type SendNotification as j, type SendResult as k, type CreateFlow as l, type UpdateFlow as m, type FlowListParams as n, type FlowTriggerType as o, type FlowStepType as p, type FlowStatus as q, type FlowStep as r, type FlowStepConfig as s, type FlowStepInput as t, type PaginatedResponse as u, type DecisionStatus as v, type DecisionSubject as w, type DecisionDeliverability as x, type DecisionReach as y, type DecisionParameters as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Pushary Server SDK: send push notifications and add human-in-the-loop approvals to your AI agent (pause on a decision until a specific human answers).",
|
|
5
5
|
"author": "Pushary <business@pushary.com>",
|
|
6
6
|
"homepage": "https://pushary.com",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"import": "./dist/index.js",
|
|
19
19
|
"require": "./dist/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./adapters": {
|
|
22
|
+
"types": "./dist/adapters.d.ts",
|
|
23
|
+
"import": "./dist/adapters.js",
|
|
24
|
+
"require": "./dist/adapters.cjs"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"files": [
|