run402 4.19.0 → 4.21.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 +13 -0
- package/cli.mjs +12 -0
- package/lib/command-manifest.mjs +6 -0
- package/lib/escalations.mjs +323 -0
- package/lib/init.mjs +104 -0
- package/lib/redeem.mjs +80 -0
- package/package.json +1 -1
- package/sdk/dist/index.d.ts +14 -0
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +14 -0
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/namespaces/escalations.d.ts +160 -0
- package/sdk/dist/namespaces/escalations.d.ts.map +1 -0
- package/sdk/dist/namespaces/escalations.js +278 -0
- package/sdk/dist/namespaces/escalations.js.map +1 -0
- package/sdk/dist/namespaces/escalations.types.d.ts +179 -0
- package/sdk/dist/namespaces/escalations.types.d.ts.map +1 -0
- package/sdk/dist/namespaces/escalations.types.js +9 -0
- package/sdk/dist/namespaces/escalations.types.js.map +1 -0
- package/sdk/dist/namespaces/vouchers.d.ts +76 -0
- package/sdk/dist/namespaces/vouchers.d.ts.map +1 -0
- package/sdk/dist/namespaces/vouchers.js +55 -0
- package/sdk/dist/namespaces/vouchers.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalations.js","sourceRoot":"","sources":["../../src/namespaces/escalations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAe1C,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,YAAY,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;AACjD,CAAC;AAED,SAAS,SAAS,CAAC,IAA4B;IAC7C,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,IAAI,IAAI,CAAC,MAAM;QAAE,MAAM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AAC;QACxC,IAAI,OAAO,GAAe,MAAM,CAAC;QACjC,OAAO,OAAO,CAAC,MAAM,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;YAC1D,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAC5D,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the `escalations` namespace — the agent→human hotline
|
|
3
|
+
* (gateway `add-agent-escalations`).
|
|
4
|
+
*
|
|
5
|
+
* Every field is the gateway's `snake_case` wire shape, passed through
|
|
6
|
+
* unchanged. Timestamps are ISO 8601.
|
|
7
|
+
*/
|
|
8
|
+
/** Who raised it. An escalation is always attributed — that is the point. */
|
|
9
|
+
export interface EscalationRaisedBy {
|
|
10
|
+
/** The control-plane principal the judgement belongs to. */
|
|
11
|
+
principal_id: string;
|
|
12
|
+
/** Set when the raiser was a scoped delegate rather than a member. */
|
|
13
|
+
delegate_id: string | null;
|
|
14
|
+
/** The coordination-room presence name, when the agent supplied one. */
|
|
15
|
+
presence_name: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** A human took ownership. This is what the raiser is waiting for. */
|
|
18
|
+
export interface EscalationAcknowledgement {
|
|
19
|
+
at: string;
|
|
20
|
+
/** The acking human's verified email; null when acked by an unnamed token tap. */
|
|
21
|
+
by_email: string | null;
|
|
22
|
+
/** `token` = one-tap link from the page; `authenticated` = an org member. */
|
|
23
|
+
channel: "token" | "authenticated";
|
|
24
|
+
}
|
|
25
|
+
export interface EscalationResolution {
|
|
26
|
+
at: string;
|
|
27
|
+
by_email: string | null;
|
|
28
|
+
note: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** One deadman hop, appended when a level let its deadline lapse. */
|
|
31
|
+
export interface EscalationClimb {
|
|
32
|
+
from_level: number;
|
|
33
|
+
to_level: number;
|
|
34
|
+
at: string;
|
|
35
|
+
reason: "deadline_lapsed";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* What actually happened on the wire, per contact × channel. Only present when
|
|
39
|
+
* the read asked for it (`include: "delivery"`) — it is read from the delivery
|
|
40
|
+
* audit log, never assumed.
|
|
41
|
+
*/
|
|
42
|
+
export interface EscalationDeliveryAttempt {
|
|
43
|
+
email: string;
|
|
44
|
+
/** `email` | `telegram` | `webhook`. */
|
|
45
|
+
channel: string;
|
|
46
|
+
/** `delivered` | `failed_transient` | `failed_permanent` | `skipped_disabled`. */
|
|
47
|
+
status: string;
|
|
48
|
+
error: string | null;
|
|
49
|
+
at: string;
|
|
50
|
+
}
|
|
51
|
+
export interface Escalation {
|
|
52
|
+
escalation_id: string;
|
|
53
|
+
org_id: string;
|
|
54
|
+
/**
|
|
55
|
+
* A SOFT reference: the escalation outlives this project's deletion, because
|
|
56
|
+
* the case that matters most is being paged about something that then gets
|
|
57
|
+
* deleted.
|
|
58
|
+
*/
|
|
59
|
+
project_id: string | null;
|
|
60
|
+
raised_by: EscalationRaisedBy;
|
|
61
|
+
severity: "normal" | "high";
|
|
62
|
+
/** The agent's argument, verbatim. Rendered as DATA wherever it is shown. */
|
|
63
|
+
reason: string;
|
|
64
|
+
/** Structured sidecar. Readable here; never rendered into a page body. */
|
|
65
|
+
details: Record<string, unknown>;
|
|
66
|
+
status: "open" | "acknowledged" | "resolved";
|
|
67
|
+
/** Which contact level is currently paged. */
|
|
68
|
+
level: number;
|
|
69
|
+
raised_at: string;
|
|
70
|
+
/** When an unacknowledged escalation climbs to the next level. */
|
|
71
|
+
deadline_at: string;
|
|
72
|
+
acknowledged: EscalationAcknowledgement | null;
|
|
73
|
+
resolved: EscalationResolution | null;
|
|
74
|
+
climbs: EscalationClimb[];
|
|
75
|
+
/**
|
|
76
|
+
* Top-level re-pages so far. At the bound the escalation rests OPEN — never
|
|
77
|
+
* auto-resolved, because "every human was paged and none answered" is not
|
|
78
|
+
* the same thing as "handled".
|
|
79
|
+
*/
|
|
80
|
+
repage_count: number;
|
|
81
|
+
/** Only when the read passed `include: "delivery"`. */
|
|
82
|
+
delivery_attempts?: EscalationDeliveryAttempt[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Who the raise is about to page. FUTURE TENSE on purpose: at raise time the
|
|
86
|
+
* page is enqueued, not delivered, and a contact with no verified operator
|
|
87
|
+
* email never receives the Telegram half at all. Ask for
|
|
88
|
+
* `include: "delivery"` on a read to learn what actually landed.
|
|
89
|
+
*/
|
|
90
|
+
export interface EscalationDelivery {
|
|
91
|
+
status: "queued";
|
|
92
|
+
level: number;
|
|
93
|
+
will_page: Array<{
|
|
94
|
+
email: string;
|
|
95
|
+
display_name: string | null;
|
|
96
|
+
}>;
|
|
97
|
+
deadline_at: string;
|
|
98
|
+
}
|
|
99
|
+
export interface RaisedEscalation extends Escalation {
|
|
100
|
+
delivery: EscalationDelivery;
|
|
101
|
+
/** True when an `idempotencyKey` replay returned the ORIGINAL escalation. */
|
|
102
|
+
deduplicated: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Non-blocking reachability notes — e.g. the org has no escalation contacts
|
|
105
|
+
* configured, so the escalation was recorded but nobody was paged.
|
|
106
|
+
*/
|
|
107
|
+
warnings?: string[];
|
|
108
|
+
next_actions?: Array<Record<string, unknown>>;
|
|
109
|
+
}
|
|
110
|
+
export interface EscalationList {
|
|
111
|
+
escalations: Escalation[];
|
|
112
|
+
/**
|
|
113
|
+
* `organization` when the caller is a member (sees every escalation);
|
|
114
|
+
* `own` for a delegate or grant-only principal (sees only what it raised).
|
|
115
|
+
*/
|
|
116
|
+
scope: "organization" | "own";
|
|
117
|
+
has_more: boolean;
|
|
118
|
+
/** Opaque keyset continuation. Store and echo; never parse. */
|
|
119
|
+
next_cursor: string | null;
|
|
120
|
+
}
|
|
121
|
+
export interface EscalationContact {
|
|
122
|
+
contact_id: string;
|
|
123
|
+
email: string;
|
|
124
|
+
display_name: string | null;
|
|
125
|
+
/** An ordering, not a rank: level 1 is paged first. */
|
|
126
|
+
level: number;
|
|
127
|
+
created_at: string;
|
|
128
|
+
/** Present when the address has no verified operator email yet. */
|
|
129
|
+
warnings?: string[];
|
|
130
|
+
}
|
|
131
|
+
export interface EscalationContactList {
|
|
132
|
+
escalation_contacts: EscalationContact[];
|
|
133
|
+
}
|
|
134
|
+
export interface RaiseEscalationInput {
|
|
135
|
+
/**
|
|
136
|
+
* Your argument for why a human is needed. Over ~4 KiB is a 400, never a
|
|
137
|
+
* truncation — the argument IS the escalation.
|
|
138
|
+
*/
|
|
139
|
+
reason: string;
|
|
140
|
+
severity?: "normal" | "high";
|
|
141
|
+
projectId?: string;
|
|
142
|
+
/** Your coordination-room presence name, so a human knows which agent this is. */
|
|
143
|
+
presenceName?: string;
|
|
144
|
+
details?: Record<string, unknown>;
|
|
145
|
+
/** A replay returns the ORIGINAL escalation and never pages twice. */
|
|
146
|
+
idempotencyKey?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface ListEscalationsOptions {
|
|
149
|
+
status?: "open" | "acknowledged" | "resolved";
|
|
150
|
+
limit?: number;
|
|
151
|
+
/** Opaque `next_cursor` from a previous page. */
|
|
152
|
+
cursor?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface GetEscalationOptions {
|
|
155
|
+
/**
|
|
156
|
+
* `"delivery"` adds `delivery_attempts[]` from the delivery audit log.
|
|
157
|
+
* Opt-in: the wait-for-human poll is the hot path and should not pay for an
|
|
158
|
+
* audit read it rarely needs.
|
|
159
|
+
*/
|
|
160
|
+
include?: "delivery";
|
|
161
|
+
}
|
|
162
|
+
export interface AddEscalationContactInput {
|
|
163
|
+
email: string;
|
|
164
|
+
displayName?: string;
|
|
165
|
+
/** Defaults to 1. Level N is paged only if level < N let the deadline lapse. */
|
|
166
|
+
level?: number;
|
|
167
|
+
}
|
|
168
|
+
export interface EscalationActionResult extends Escalation {
|
|
169
|
+
/** False on an idempotent replay — the ORIGINAL acknowledgement is reported. */
|
|
170
|
+
changed: boolean;
|
|
171
|
+
}
|
|
172
|
+
export interface TokenAckResult {
|
|
173
|
+
escalation_id: string;
|
|
174
|
+
status: "acknowledged" | "resolved";
|
|
175
|
+
acknowledged_at: string | null;
|
|
176
|
+
changed: boolean;
|
|
177
|
+
reason: string;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=escalations.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalations.types.d.ts","sourceRoot":"","sources":["../../src/namespaces/escalations.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,wEAAwE;IACxE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,sEAAsE;AACtE,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,kFAAkF;IAClF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,6EAA6E;IAC7E,OAAO,EAAE,OAAO,GAAG,eAAe,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED;;;;GAIG;AACH,MA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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACxD,gFAAgF;IAChF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC;IACpC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the `escalations` namespace — the agent→human hotline
|
|
3
|
+
* (gateway `add-agent-escalations`).
|
|
4
|
+
*
|
|
5
|
+
* Every field is the gateway's `snake_case` wire shape, passed through
|
|
6
|
+
* unchanged. Timestamps are ISO 8601.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=escalations.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escalations.types.js","sourceRoot":"","sources":["../../src/namespaces/escalations.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vouchers` namespace — redeem a promo code for platform credit.
|
|
3
|
+
*
|
|
4
|
+
* A promo code credits your organization with run402 prepaid credit. That
|
|
5
|
+
* credit spends like any other prepaid balance: a tier purchase settles from
|
|
6
|
+
* it with no on-chain payment.
|
|
7
|
+
*
|
|
8
|
+
* Two properties make this safe to call from anywhere in an agent's lifecycle:
|
|
9
|
+
*
|
|
10
|
+
* - **Order does not matter.** Redemption works as the very first authenticated
|
|
11
|
+
* call a brand-new wallet makes (the organization is provisioned on demand),
|
|
12
|
+
* or long after `run402 init`. There is no init-before-redeem requirement.
|
|
13
|
+
* - **Retrying is safe.** A repeat by the same organization returns the ORIGINAL
|
|
14
|
+
* result with `already_redeemed: true` and never credits twice, so a call that
|
|
15
|
+
* times out client-side can simply be re-issued.
|
|
16
|
+
*
|
|
17
|
+
* This namespace is deliberately thin and semantically blind: it forwards an
|
|
18
|
+
* opaque code string to one gateway route. It does not know what a code means,
|
|
19
|
+
* where it came from, or who issued it. Minting is not an agent operation —
|
|
20
|
+
* it needs a registered issuer key that no tenant holds.
|
|
21
|
+
*/
|
|
22
|
+
import type { Client } from "../kernel.js";
|
|
23
|
+
/**
|
|
24
|
+
* A follow-up the gateway suggests after a redemption — most often buying the
|
|
25
|
+
* tier the new balance now covers.
|
|
26
|
+
*/
|
|
27
|
+
export interface VoucherNextAction {
|
|
28
|
+
type: string;
|
|
29
|
+
method?: string;
|
|
30
|
+
path?: string;
|
|
31
|
+
/** Ready-to-run CLI equivalent, when the action has one. */
|
|
32
|
+
cli?: string;
|
|
33
|
+
why?: string;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface RedeemVoucherResult {
|
|
37
|
+
voucher_id: string;
|
|
38
|
+
/** Credit applied by this voucher. */
|
|
39
|
+
amount_usd_micros: number;
|
|
40
|
+
/** The organization's available prepaid balance AFTER the credit. */
|
|
41
|
+
balance_usd_micros: number;
|
|
42
|
+
organization_id: string;
|
|
43
|
+
redeemed_at: string;
|
|
44
|
+
/**
|
|
45
|
+
* True when THIS organization had already redeemed this code. The original
|
|
46
|
+
* result is returned unchanged and no second credit was made — a replay is
|
|
47
|
+
* reported honestly rather than dressed up as a fresh redemption.
|
|
48
|
+
*/
|
|
49
|
+
already_redeemed: boolean;
|
|
50
|
+
/** Lifetime promo-credit ceiling for one organization. */
|
|
51
|
+
promo_lifetime_ceiling_usd_micros: number;
|
|
52
|
+
next_actions: VoucherNextAction[];
|
|
53
|
+
}
|
|
54
|
+
export declare class Vouchers {
|
|
55
|
+
private readonly client;
|
|
56
|
+
/** Alias of {@link redeem}. */
|
|
57
|
+
readonly redeemCode: (code: string) => Promise<RedeemVoucherResult>;
|
|
58
|
+
constructor(client: Client);
|
|
59
|
+
/**
|
|
60
|
+
* Redeem a promo code into the authenticated wallet's organization.
|
|
61
|
+
*
|
|
62
|
+
* The code is sent verbatim — the gateway owns the grammar and is forgiving
|
|
63
|
+
* about it (case-insensitive, hyphens optional, and the Crockford
|
|
64
|
+
* confusables `O`→`0` / `I`,`L`→`1` are mapped), so a client-side format
|
|
65
|
+
* check would only invent ways to reject a code the server would have
|
|
66
|
+
* accepted.
|
|
67
|
+
*
|
|
68
|
+
* Requires wallet (SIWX) auth. Errors carry the canonical envelope:
|
|
69
|
+
* `VOUCHER_NOT_FOUND` (404 — unknown *or* malformed, deliberately
|
|
70
|
+
* indistinguishable), `VOUCHER_EXPIRED` (410), `VOUCHER_ALREADY_REDEEMED`
|
|
71
|
+
* (409 — a different organization got there first), `PROMO_LIMIT_REACHED`
|
|
72
|
+
* (403), `RATE_LIMITED` (429).
|
|
73
|
+
*/
|
|
74
|
+
redeem(code: string): Promise<RedeemVoucherResult>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=vouchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vouchers.d.ts","sourceRoot":"","sources":["../../src/namespaces/vouchers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B,0DAA0D;IAC1D,iCAAiC,EAAE,MAAM,CAAC;IAC1C,YAAY,EAAE,iBAAiB,EAAE,CAAC;CACnC;AAED,qBAAa,QAAQ;IAIP,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,+BAA+B;IAC/B,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;gBAEvC,MAAM,EAAE,MAAM;IAI3C;;;;;;;;;;;;;;OAcG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAQzD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vouchers` namespace — redeem a promo code for platform credit.
|
|
3
|
+
*
|
|
4
|
+
* A promo code credits your organization with run402 prepaid credit. That
|
|
5
|
+
* credit spends like any other prepaid balance: a tier purchase settles from
|
|
6
|
+
* it with no on-chain payment.
|
|
7
|
+
*
|
|
8
|
+
* Two properties make this safe to call from anywhere in an agent's lifecycle:
|
|
9
|
+
*
|
|
10
|
+
* - **Order does not matter.** Redemption works as the very first authenticated
|
|
11
|
+
* call a brand-new wallet makes (the organization is provisioned on demand),
|
|
12
|
+
* or long after `run402 init`. There is no init-before-redeem requirement.
|
|
13
|
+
* - **Retrying is safe.** A repeat by the same organization returns the ORIGINAL
|
|
14
|
+
* result with `already_redeemed: true` and never credits twice, so a call that
|
|
15
|
+
* times out client-side can simply be re-issued.
|
|
16
|
+
*
|
|
17
|
+
* This namespace is deliberately thin and semantically blind: it forwards an
|
|
18
|
+
* opaque code string to one gateway route. It does not know what a code means,
|
|
19
|
+
* where it came from, or who issued it. Minting is not an agent operation —
|
|
20
|
+
* it needs a registered issuer key that no tenant holds.
|
|
21
|
+
*/
|
|
22
|
+
import { assertNonEmptyString } from "../validation.js";
|
|
23
|
+
export class Vouchers {
|
|
24
|
+
client;
|
|
25
|
+
/** Alias of {@link redeem}. */
|
|
26
|
+
redeemCode;
|
|
27
|
+
constructor(client) {
|
|
28
|
+
this.client = client;
|
|
29
|
+
this.redeemCode = this.redeem.bind(this);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Redeem a promo code into the authenticated wallet's organization.
|
|
33
|
+
*
|
|
34
|
+
* The code is sent verbatim — the gateway owns the grammar and is forgiving
|
|
35
|
+
* about it (case-insensitive, hyphens optional, and the Crockford
|
|
36
|
+
* confusables `O`→`0` / `I`,`L`→`1` are mapped), so a client-side format
|
|
37
|
+
* check would only invent ways to reject a code the server would have
|
|
38
|
+
* accepted.
|
|
39
|
+
*
|
|
40
|
+
* Requires wallet (SIWX) auth. Errors carry the canonical envelope:
|
|
41
|
+
* `VOUCHER_NOT_FOUND` (404 — unknown *or* malformed, deliberately
|
|
42
|
+
* indistinguishable), `VOUCHER_EXPIRED` (410), `VOUCHER_ALREADY_REDEEMED`
|
|
43
|
+
* (409 — a different organization got there first), `PROMO_LIMIT_REACHED`
|
|
44
|
+
* (403), `RATE_LIMITED` (429).
|
|
45
|
+
*/
|
|
46
|
+
async redeem(code) {
|
|
47
|
+
assertNonEmptyString(code, "code", "redeeming a promo code");
|
|
48
|
+
return this.client.request("/vouchers/v1/redemptions", {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: { code },
|
|
51
|
+
context: "redeeming a promo code",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=vouchers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vouchers.js","sourceRoot":"","sources":["../../src/namespaces/vouchers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAmCxD,MAAM,OAAO,QAAQ;IAIU;IAH7B,+BAA+B;IACtB,UAAU,CAAiD;IAEpE,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY;QACvB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB,0BAA0B,EAAE;YAC1E,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,IAAI,EAAE;YACd,OAAO,EAAE,wBAAwB;SAClC,CAAC,CAAC;IACL,CAAC;CACF"}
|