@octap/contracts 0.1.0 → 0.2.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.
@@ -0,0 +1,52 @@
1
+ import type { WebhookEventType } from './webhooks.js';
2
+ /**
3
+ * What changed, so a console screen knows what to refetch. Only ids: the stream never carries the
4
+ * data itself, which is read through the REST routes and their access checks.
5
+ */
6
+ export type OrganizationEventSubject = {
7
+ kind: 'voucher';
8
+ id: string;
9
+ batchId: string | null;
10
+ } | {
11
+ kind: 'voucherOwnership';
12
+ id: string;
13
+ voucherId: string;
14
+ memberId: string;
15
+ } | {
16
+ kind: 'loyaltyTransaction';
17
+ id: string;
18
+ memberId: string;
19
+ } | {
20
+ kind: 'issuanceBudget';
21
+ } | {
22
+ kind: 'webhookEndpoint';
23
+ id: string;
24
+ };
25
+ /**
26
+ * One message of the console event stream (`GET /v1/console/organizations/:id/events`, OCT-326):
27
+ * the SSE `event` is `type`, the SSE `id` is `sequence`, and `data` is this object as JSON.
28
+ */
29
+ export interface OrganizationStreamEvent {
30
+ /** The event's id, the same one its webhook carries. */
31
+ id: string;
32
+ /** Orders the organization's events; sent as the SSE `id`, so a reconnect resumes after it. */
33
+ sequence: number;
34
+ type: WebhookEventType;
35
+ subject: OrganizationEventSubject;
36
+ occurredAt: string;
37
+ }
38
+ /**
39
+ * Stream messages about the stream itself, sent as the SSE `event` with no `id`:
40
+ * - `stream.reset`: events since the `Last-Event-ID` are no longer available (kept 30 days) or the
41
+ * id is unknown. Refetch every screen, then carry on: newer events follow on the same stream.
42
+ * - `stream.token_expired`: the Google ID token the stream was opened with expired, and the stream
43
+ * closes. Reconnect with a fresh token and the last `id` seen; nothing is lost.
44
+ * - `stream.access_revoked`: the caller is no longer an active Owner or Business Developer of an
45
+ * active organization, and the stream closes. Don't reconnect.
46
+ */
47
+ export declare const ORGANIZATION_STREAM_CONTROL: {
48
+ readonly reset: "stream.reset";
49
+ readonly tokenExpired: "stream.token_expired";
50
+ readonly accessRevoked: "stream.access_revoked";
51
+ };
52
+ export type OrganizationStreamControl = (typeof ORGANIZATION_STREAM_CONTROL)[keyof typeof ORGANIZATION_STREAM_CONTROL];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Stream messages about the stream itself, sent as the SSE `event` with no `id`:
3
+ * - `stream.reset`: events since the `Last-Event-ID` are no longer available (kept 30 days) or the
4
+ * id is unknown. Refetch every screen, then carry on: newer events follow on the same stream.
5
+ * - `stream.token_expired`: the Google ID token the stream was opened with expired, and the stream
6
+ * closes. Reconnect with a fresh token and the last `id` seen; nothing is lost.
7
+ * - `stream.access_revoked`: the caller is no longer an active Owner or Business Developer of an
8
+ * active organization, and the stream closes. Don't reconnect.
9
+ */
10
+ export const ORGANIZATION_STREAM_CONTROL = {
11
+ reset: 'stream.reset',
12
+ tokenExpired: 'stream.token_expired',
13
+ accessRevoked: 'stream.access_revoked',
14
+ };
15
+ //# sourceMappingURL=organization-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-events.js","sourceRoot":"","sources":["../src/organization-events.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,cAAc;IACrB,YAAY,EAAE,sBAAsB;IACpC,aAAa,EAAE,uBAAuB;CAC9B,CAAC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Request log (OCT-298): every call an organization's API keys made, as the organization's own
3
+ * developers see it in the console. Kept 30 days. Field names follow the OpenTelemetry HTTP
4
+ * semantic conventions where one exists (`route` = `http.route`, `statusCode` =
5
+ * `http.response.status_code`, `latencyMs` = `http.server.request.duration` in milliseconds).
6
+ */
7
+ /** What part of the API a call belongs to, from its route. */
8
+ export type RequestLogCategory = 'credits' | 'vouchers' | 'refund-policy' | 'webhooks' | 'organizations' | 'other';
9
+ export declare const REQUEST_LOG_CATEGORIES: readonly RequestLogCategory[];
10
+ /** How many days a request log row is kept. */
11
+ export declare const REQUEST_LOG_RETENTION_DAYS = 30;
12
+ /** The API key that made a call, as the console shows it. Never the key itself. */
13
+ export interface RequestLogCredentialRef {
14
+ id: string;
15
+ name: string;
16
+ keyPrefix: string;
17
+ }
18
+ /** One row of the list. */
19
+ export interface RequestLogEntry {
20
+ /** The correlation id (`X-Request-Id` on the response): quote it to OctaP support. */
21
+ requestId: string;
22
+ method: string;
23
+ /** The route template, e.g. `/v1/credits/members/:memberId/balance`: groups calls to the same endpoint. */
24
+ route: string;
25
+ /**
26
+ * The path called, without its query string, with only UUID parameters filled in: any other value
27
+ * stays its placeholder (`:memberId`), so no free text or personal data is kept.
28
+ */
29
+ path: string;
30
+ statusCode: number;
31
+ latencyMs: number;
32
+ category: RequestLogCategory;
33
+ /** The `code` of a non-2xx response's error body, when it had one. */
34
+ errorCode: string | null;
35
+ /** The `message` of a non-2xx response's error body. */
36
+ errorMessage: string | null;
37
+ credential: RequestLogCredentialRef;
38
+ /** The caller's `User-Agent`, e.g. the SDK and its version. */
39
+ userAgent: string | null;
40
+ createdAt: string;
41
+ }
42
+ /** One row with everything recorded about it, including a non-2xx response's full error body. */
43
+ export interface RequestLogDetail extends RequestLogEntry {
44
+ errorBody: unknown;
45
+ }
46
+ /**
47
+ * `succeeded` = 2xx/3xx, `failed` = 4xx/5xx; a class (`4xx`) or an exact code (`404`) narrows it further.
48
+ */
49
+ export type RequestLogStatusFilter = 'succeeded' | 'failed' | '2xx' | '3xx' | '4xx' | '5xx' | `${number}`;
50
+ /** Filters shared by every request-log read. Times are ISO 8601; the window defaults to the last 24 hours. */
51
+ export interface RequestLogFilters {
52
+ from?: string;
53
+ to?: string;
54
+ credentialId?: string;
55
+ category?: RequestLogCategory;
56
+ method?: string;
57
+ status?: RequestLogStatusFilter;
58
+ /** Exact route template, e.g. from a summary row. */
59
+ route?: string;
60
+ }
61
+ /** `GET …/request-logs`: newest first, `page` from 1, `limit` 1–100 (default 50). */
62
+ export interface RequestLogListQuery extends RequestLogFilters {
63
+ page?: number;
64
+ limit?: number;
65
+ }
66
+ export interface RequestLogPage {
67
+ items: RequestLogEntry[];
68
+ page: number;
69
+ limit: number;
70
+ total: number;
71
+ }
72
+ /**
73
+ * `GET …/request-logs/tail`: what arrived after `cursor` (at most 100). Without a cursor nothing is
74
+ * returned, only the cursor to poll from: a tail starts now, like `stripe logs tail`, and only shows
75
+ * calls that arrived after it opened. A call is never skipped, even one whose row committed late; it
76
+ * may arrive a moment after newer ones.
77
+ */
78
+ export interface RequestLogTailQuery extends Omit<RequestLogFilters, 'from' | 'to'> {
79
+ cursor?: string;
80
+ }
81
+ export interface RequestLogTail {
82
+ items: RequestLogEntry[];
83
+ /** Opaque. Pass it back on the next poll. */
84
+ cursor: string;
85
+ }
86
+ export interface LatencyPercentiles {
87
+ p50: number | null;
88
+ p95: number | null;
89
+ p99: number | null;
90
+ }
91
+ /** Rate, errors, duration for one slice of traffic. `errorRate` is failed / requests, 0–1. */
92
+ export interface RequestLogStats {
93
+ requests: number;
94
+ succeeded: number;
95
+ clientErrors: number;
96
+ serverErrors: number;
97
+ errorRate: number;
98
+ latencyMs: LatencyPercentiles;
99
+ }
100
+ export interface RequestLogSummary {
101
+ from: string;
102
+ to: string;
103
+ totals: RequestLogStats;
104
+ byCategory: (RequestLogStats & {
105
+ category: RequestLogCategory;
106
+ })[];
107
+ /** The 20 busiest endpoints. */
108
+ byRoute: (RequestLogStats & {
109
+ method: string;
110
+ route: string;
111
+ })[];
112
+ byCredential: (RequestLogStats & {
113
+ credential: RequestLogCredentialRef;
114
+ })[];
115
+ }
116
+ export type RequestLogInterval = '1m' | '5m' | '15m' | '1h' | '1d';
117
+ /** `GET …/request-logs/timeseries`: `interval` defaults to one that gives at most ~100 buckets. */
118
+ export interface RequestLogTimeseriesQuery extends RequestLogFilters {
119
+ interval?: RequestLogInterval;
120
+ }
121
+ export interface RequestLogBucket {
122
+ start: string;
123
+ requests: number;
124
+ succeeded: number;
125
+ clientErrors: number;
126
+ serverErrors: number;
127
+ p95LatencyMs: number | null;
128
+ }
129
+ export interface RequestLogTimeseries {
130
+ from: string;
131
+ to: string;
132
+ interval: RequestLogInterval;
133
+ /** Every bucket in the window, empty ones included, oldest first. */
134
+ buckets: RequestLogBucket[];
135
+ }
136
+ /** `GET …/request-logs/errors`: failed calls grouped by endpoint, status and error code, most frequent first. */
137
+ export interface RequestLogErrorGroup {
138
+ method: string;
139
+ route: string;
140
+ statusCode: number;
141
+ errorCode: string | null;
142
+ /** The most recent message in the group. */
143
+ errorMessage: string | null;
144
+ count: number;
145
+ firstSeenAt: string;
146
+ lastSeenAt: string;
147
+ /** The most recent call in the group, to open its detail. */
148
+ lastRequestId: string;
149
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Request log (OCT-298): every call an organization's API keys made, as the organization's own
3
+ * developers see it in the console. Kept 30 days. Field names follow the OpenTelemetry HTTP
4
+ * semantic conventions where one exists (`route` = `http.route`, `statusCode` =
5
+ * `http.response.status_code`, `latencyMs` = `http.server.request.duration` in milliseconds).
6
+ */
7
+ export const REQUEST_LOG_CATEGORIES = [
8
+ 'credits',
9
+ 'vouchers',
10
+ 'refund-policy',
11
+ 'webhooks',
12
+ 'organizations',
13
+ 'other',
14
+ ];
15
+ /** How many days a request log row is kept. */
16
+ export const REQUEST_LOG_RETENTION_DAYS = 30;
17
+ //# sourceMappingURL=request-logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-logs.js","sourceRoot":"","sources":["../src/request-logs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAC,MAAM,sBAAsB,GAAkC;IACnE,SAAS;IACT,UAAU;IACV,eAAe;IACf,UAAU;IACV,eAAe;IACf,OAAO;CACR,CAAC;AAEF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC"}
package/dist/rewards.d.ts CHANGED
@@ -1,5 +1,60 @@
1
1
  import type { VoucherRefundPolicySnapshot } from './voucher-refunds.js';
2
- export type VoucherStatus = 'DRAFT' | 'ACTIVE' | 'PAUSED' | 'EXPIRED' | 'DEPLETED';
2
+ /**
3
+ * `PENDING_APPROVAL`: the organization requires approval and someone other than an Owner asked for
4
+ * it to go live (a Business Developer's submission, or an API key asking for `ACTIVE`). An Owner
5
+ * approves it (publishing starts) or rejects it (back to `DRAFT`); it cannot be edited meanwhile.
6
+ *
7
+ * `ARCHIVED`: a draft (or one waiting for approval) of a batch that was archived (OCT-303). It never
8
+ * went live and can't be edited, submitted, approved or claimed. Importing its `code` again in a new
9
+ * batch brings it back as a `DRAFT` there.
10
+ */
11
+ export type VoucherStatus = 'DRAFT' | 'PENDING_APPROVAL' | 'ACTIVE' | 'PAUSED' | 'EXPIRED' | 'DEPLETED' | 'ARCHIVED';
12
+ export type VoucherApprovalStatus = 'PENDING' | 'APPROVED' | 'REJECTED' | 'WITHDRAWN';
13
+ /** Who did something to a voucher: a console user or an API key; `null` once that user or key is deleted. */
14
+ export type VoucherActorRef = {
15
+ type: 'USER' | 'API_CREDENTIAL';
16
+ id: string;
17
+ } | null;
18
+ /**
19
+ * The terms a voucher had when it was submitted for approval: what the Owner reviews, and what
20
+ * approving publishes. Dates are ISO strings; `discountValue` is Core's decimal string.
21
+ */
22
+ export interface VoucherApprovalSnapshot {
23
+ code: string;
24
+ title: string;
25
+ description: string | null;
26
+ pointsCost: number;
27
+ discountType: string | null;
28
+ discountValue: string | null;
29
+ terms: Record<string, unknown> | null;
30
+ totalSupply: number | null;
31
+ perMemberLimit: number | null;
32
+ startsAt: string | null;
33
+ expiresAt: string | null;
34
+ validForDays: number | null;
35
+ }
36
+ /** The latest request to take a voucher live, when approval was needed. */
37
+ export interface VoucherApprovalDto {
38
+ /**
39
+ * This submission. An Owner approves or rejects by sending it back (`approvalRequestId`), so a
40
+ * voucher withdrawn and submitted again since is refused (409) instead of decided unseen (OCT-324).
41
+ */
42
+ id: string;
43
+ status: VoucherApprovalStatus;
44
+ /** A console user (Business Developer) or an API key; `null` once that user or key is deleted. */
45
+ submittedBy: {
46
+ type: 'USER' | 'API_CREDENTIAL';
47
+ id: string;
48
+ } | null;
49
+ submittedAt: string;
50
+ /** The Owner who approved or rejected it, or whoever withdrew it. */
51
+ reviewedById: string | null;
52
+ reviewedAt: string | null;
53
+ /** Why an Owner rejected it. */
54
+ reason: string | null;
55
+ /** The terms as submitted; `null` for a submission made before snapshots were kept. */
56
+ snapshot: VoucherApprovalSnapshot | null;
57
+ }
3
58
  export type VoucherOwnershipStatus = 'AVAILABLE' | 'RESERVED' | 'REDEEMED' | 'EXPIRED' | 'CANCELLED';
4
59
  export type DiscountType = 'PERCENTAGE' | 'FIXED_AMOUNT' | 'FREE_ITEM';
5
60
  /** Whether a voucher's terms are on-chain. Only a PUBLISHED voucher can be ACTIVE. */
@@ -100,6 +155,18 @@ export interface VoucherDto {
100
155
  /** `null`: every customer's voucher expires at `expiresAt`. */
101
156
  validForDays: number | null;
102
157
  metadata?: Record<string, unknown> | null;
158
+ /** On every catalog response (not a member's vouchers): the latest approval request, `null` if there never was one. */
159
+ approval?: VoucherApprovalDto | null;
160
+ /** The batch it was created or last imported in (`createVoucherBatch`), `null` if created on its own. */
161
+ batchId?: string | null;
162
+ /** Who created it (or last replaced it by importing its code again); `null` if not recorded. */
163
+ createdBy: VoucherActorRef;
164
+ /**
165
+ * Who took it live: whoever activated it, or the Owner who approved it. Set when publishing starts
166
+ * (again on a retry after a failed publish); `null` until then, or when not recorded.
167
+ */
168
+ activatedBy: VoucherActorRef;
169
+ activatedAt: string | null;
103
170
  createdAt: string;
104
171
  updatedAt: string;
105
172
  }
@@ -188,3 +255,176 @@ export interface VoucherOwnershipDto {
188
255
  expiresAt?: string | null;
189
256
  voucher?: VoucherDto;
190
257
  }
258
+ /** The most items one `createVoucherBatch` call takes; more is a 400 for the whole request. */
259
+ export declare const VOUCHER_BATCH_MAX_ITEMS = 100;
260
+ /** The longest batch `name`, after trimming. */
261
+ export declare const VOUCHER_BATCH_MAX_NAME_LENGTH = 120;
262
+ /** Where a batch came from: the console, or a merchant API key. */
263
+ export type VoucherBatchSource = 'CONSOLE' | 'API';
264
+ /**
265
+ * One voucher of a batch: what `createVoucher` takes, without `status`. A batch is always DRAFT; it
266
+ * goes live with `activateVoucherBatch`. Sending `status` makes that item an `INVALID` error.
267
+ */
268
+ export type VoucherBatchItem = Omit<CreateVoucherRequest, 'status'>;
269
+ export interface CreateVoucherBatchRequest {
270
+ /**
271
+ * A label to tell batches apart, such as the CSV file's name or "nightly-sync 2026-11-22". Up to
272
+ * `VOUCHER_BATCH_MAX_NAME_LENGTH` characters; it doesn't have to be unique. Left out or blank: none.
273
+ */
274
+ name?: string;
275
+ /** 1 to `VOUCHER_BATCH_MAX_ITEMS` items. Each one is handled on its own: a bad item fails alone. */
276
+ items: VoucherBatchItem[];
277
+ /** Run every check and report each item's result, but write nothing. */
278
+ dryRun?: boolean;
279
+ }
280
+ /** Machine-readable reason an item was not written. */
281
+ export type VoucherBatchItemErrorCode =
282
+ /** A field is wrong; `field` names it when Core can tell which one. */
283
+ 'INVALID'
284
+ /** An earlier item of the same request has the same `code`. */
285
+ | 'DUPLICATE_IN_BATCH';
286
+ /** One field where the stored voucher and the sent item differ, after normalizing both. */
287
+ export interface VoucherFieldDifference {
288
+ field: string;
289
+ stored: unknown;
290
+ sent: unknown;
291
+ }
292
+ /**
293
+ * What happened to one item, matched by its `index` in `items`. `code` is the natural key, unique
294
+ * per organization:
295
+ * - `created`: a new DRAFT voucher (`voucherId` is `null` on a dry run).
296
+ * - `unchanged`: a voucher with this `code` already holds exactly these values; nothing is written.
297
+ * `movedToBatch` is `true` when it was a DRAFT of an archived batch and now belongs to this one.
298
+ * - `conflict`: a voucher with this `code` holds other values and may not be overwritten (it is or
299
+ * was live, it is a DRAFT of an open batch, or a DRAFT created on its own). Nothing is written; use
300
+ * a new `code` to offer different terms.
301
+ * - `replaced`: it was a DRAFT of an archived batch: it now holds the sent values and belongs to
302
+ * this batch.
303
+ * - `error`: the item was not written; see `error`.
304
+ */
305
+ export type VoucherBatchItemResult = {
306
+ index: number;
307
+ code: string;
308
+ status: 'created';
309
+ voucherId: string | null;
310
+ } | {
311
+ index: number;
312
+ code: string;
313
+ status: 'unchanged';
314
+ voucherId: string;
315
+ movedToBatch: boolean;
316
+ } | {
317
+ index: number;
318
+ code: string;
319
+ status: 'conflict';
320
+ voucherId: string;
321
+ differences: VoucherFieldDifference[];
322
+ } | {
323
+ index: number;
324
+ code: string;
325
+ status: 'replaced';
326
+ voucherId: string | null;
327
+ differences: VoucherFieldDifference[];
328
+ } | {
329
+ index: number;
330
+ /** `null` when the item has no usable `code`. */
331
+ code: string | null;
332
+ status: 'error';
333
+ error: {
334
+ code: VoucherBatchItemErrorCode;
335
+ field: string | null;
336
+ message: string;
337
+ };
338
+ };
339
+ export interface VoucherBatchDto {
340
+ id: string;
341
+ organizationId: string;
342
+ /** `null` when it was created without one. */
343
+ name: string | null;
344
+ source: VoucherBatchSource;
345
+ /** A console user or an API key; `null` once that user or key is deleted. */
346
+ createdBy: {
347
+ type: 'USER' | 'API_CREDENTIAL';
348
+ id: string;
349
+ } | null;
350
+ createdAt: string;
351
+ /** Set once archived: the batch is hidden from the default list and can no longer be activated. */
352
+ archivedAt: string | null;
353
+ /** How many of its vouchers are in each status, e.g. `{ DRAFT: 98, ACTIVE: 2 }`. */
354
+ statusCounts: VoucherBatchStatusCounts;
355
+ }
356
+ /**
357
+ * How many of a batch's vouchers are in each status; a status with none is left out. A named type,
358
+ * not `Partial<Record<VoucherStatus, number>>`: the OpenAPI generator names an inline generic after the
359
+ * file's absolute path, which differs per machine.
360
+ */
361
+ export interface VoucherBatchStatusCounts {
362
+ DRAFT?: number;
363
+ PENDING_APPROVAL?: number;
364
+ ACTIVE?: number;
365
+ PAUSED?: number;
366
+ EXPIRED?: number;
367
+ DEPLETED?: number;
368
+ ARCHIVED?: number;
369
+ }
370
+ /** A batch with its vouchers. */
371
+ export interface VoucherBatchDetailDto extends VoucherBatchDto {
372
+ vouchers: VoucherDto[];
373
+ }
374
+ export interface CreateVoucherBatchResponse {
375
+ dryRun: boolean;
376
+ /** `null` on a dry run, and when no item landed in the batch (all unchanged, conflict or error). */
377
+ batch: VoucherBatchDto | null;
378
+ items: VoucherBatchItemResult[];
379
+ }
380
+ export interface ListVoucherBatchesRequest {
381
+ /** Include archived batches. Defaults to `false`. */
382
+ includeArchived?: boolean;
383
+ }
384
+ /**
385
+ * What a batch action did to one voucher of the batch. Every action handles each voucher on its own,
386
+ * with the checks of the same action on a single voucher, made now.
387
+ * - `publishing`: activate: its terms are on the way on-chain; ACTIVE once confirmed. An Owner's
388
+ * activation also approves the vouchers waiting for approval (OCT-59).
389
+ * - `pendingApproval`: activate: the organization requires approval and the caller is not an Owner,
390
+ * so it waits for an Owner.
391
+ * - `paused` / `resumed`: pause or resume took effect.
392
+ * - `archived`: archive: a draft, or one waiting for approval (its request is withdrawn), is now
393
+ * `ARCHIVED`.
394
+ * - `skipped`: nothing to do for this action, such as activating one already published, archiving
395
+ * one that is live, or pausing a draft. `status` says where it is. Calling the action again is safe.
396
+ * - `failed`: the action didn't apply to it; `reason` says why (for example less than 24 hours left
397
+ * before `expiresAt`, or no supply left).
398
+ */
399
+ export type VoucherBatchOutcome = 'publishing' | 'pendingApproval' | 'paused' | 'resumed' | 'archived' | 'skipped' | 'failed';
400
+ /** The outcomes `activateVoucherBatch` can report. */
401
+ export type VoucherBatchActivationOutcome = 'publishing' | 'pendingApproval' | 'skipped' | 'failed';
402
+ export interface VoucherBatchActionResult {
403
+ voucherId: string;
404
+ code: string;
405
+ outcome: VoucherBatchOutcome;
406
+ /** The voucher's status after the action, e.g. why a `skipped` one was skipped. */
407
+ status: VoucherStatus;
408
+ /** Set when `outcome` is `failed`. */
409
+ reason: string | null;
410
+ }
411
+ /** A voucher as an Owner reviewed it: its `updatedAt` at the time. */
412
+ export interface VoucherSeen {
413
+ voucherId: string;
414
+ updatedAt: string;
415
+ }
416
+ /**
417
+ * `POST …/voucher-batches/:batchId/activate` from the console. `seen` lists the vouchers as the Owner
418
+ * reviewed them (OCT-324). An Owner's activation approves a voucher waiting for approval, and, while
419
+ * the organization requires approval, publishes a draft, only when it is listed with its current
420
+ * `updatedAt`: one changed since (edited, or withdrawn and submitted again) or not listed is `failed`,
421
+ * with the reason. Business Developers don't send it: their activation is a submission.
422
+ */
423
+ export interface ActivateVoucherBatchRequest {
424
+ seen?: VoucherSeen[];
425
+ }
426
+ /** The result of activate, pause, resume or archive on a batch. */
427
+ export interface VoucherBatchActionResponse {
428
+ batch: VoucherBatchDto;
429
+ vouchers: VoucherBatchActionResult[];
430
+ }
package/dist/rewards.js CHANGED
@@ -25,4 +25,12 @@ export function voucherUseDeadline(voucher, issuedAt) {
25
25
  const own = issuedAt.getTime() + duration;
26
26
  return new Date(voucher.expiresAt === null ? own : Math.min(own, voucher.expiresAt.getTime()));
27
27
  }
28
+ // ---------------------------------------------------------------------------------------------------
29
+ // Voucher batches (OCT-303): create many vouchers as one DRAFT batch, review them, then activate the
30
+ // whole batch at once, or archive it.
31
+ // ---------------------------------------------------------------------------------------------------
32
+ /** The most items one `createVoucherBatch` call takes; more is a 400 for the whole request. */
33
+ export const VOUCHER_BATCH_MAX_ITEMS = 100;
34
+ /** The longest batch `name`, after trimming. */
35
+ export const VOUCHER_BATCH_MAX_NAME_LENGTH = 120;
28
36
  //# sourceMappingURL=rewards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rewards.js","sourceRoot":"","sources":["../src/rewards.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,OAAO,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiE,EACjE,QAAc;IAEd,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC"}
1
+ {"version":3,"file":"rewards.js","sourceRoot":"","sources":["../src/rewards.ts"],"names":[],"mappings":"AA4DA;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,OAAO,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiE,EACjE,QAAc;IAEd,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC,SAAS,CAAC;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC1C,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC;AAyLD,sGAAsG;AACtG,qGAAqG;AACrG,sCAAsC;AACtC,sGAAsG;AAEtG,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,gDAAgD;AAChD,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { OrganizationType } from './console.js';
1
2
  /** Platform identity roles. Organization membership is a separate authorization dimension. */
2
3
  export declare const SYSTEM_ROLES: readonly ["SYSTEM_USER", "SYSTEM_ADMIN"];
3
4
  export type SystemRole = (typeof SYSTEM_ROLES)[number];
@@ -15,6 +16,10 @@ export interface ConsoleIdentity {
15
16
  name: string;
16
17
  slug: string;
17
18
  persona: OrganizationPersona;
19
+ /** The registered legal type, or null when the organization has none yet. */
20
+ organizationType: OrganizationType | null;
21
+ /** The registered legal representative, or null when the organization has none yet. */
22
+ representativeName: string | null;
18
23
  }>;
19
24
  /** Expiration of the Google credential; Core does not issue a separate console token. */
20
25
  expiresAt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"system-users.js","sourceRoot":"","sources":["../src/system-users.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,aAAa,EAAE,cAAc,CAAU,CAAC"}
1
+ {"version":3,"file":"system-users.js","sourceRoot":"","sources":["../src/system-users.ts"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,aAAa,EAAE,cAAc,CAAU,CAAC"}
@@ -1,9 +1,12 @@
1
1
  /** Merchant refund terms, independent of the on-chain points earn/expiry policy. */
2
2
  export interface VoucherRefundPolicy {
3
3
  allowUnused: boolean;
4
- /** Opt-in only; refund execution additionally requires an admin-scoped credential. */
4
+ /** Opt-in only. When on, any `write` key may refund an expired coupon; the policy is the only gate. */
5
5
  allowExpired: boolean;
6
- /** Exceptional service recovery; preserves REDEEMED history and requires admin-scoped refund execution. */
6
+ /**
7
+ * Exceptional service recovery; preserves REDEEMED history. When on, any `write` key may refund a
8
+ * redeemed coupon; the policy is the only gate.
9
+ */
7
10
  allowRedeemed: boolean;
8
11
  /** False permanently consumes the campaign allocation even when an unused coupon is canceled. */
9
12
  restockUnused: boolean;
@@ -19,6 +22,9 @@ export interface SetVoucherRefundPolicyRequest extends VoucherRefundPolicy {
19
22
  }
20
23
  export interface VoucherRefundPolicyDto extends VoucherRefundPolicySnapshot {
21
24
  reason: string;
25
+ /** The Owner who published this version from the console. Null on the default policy and on legacy versions. */
26
+ createdByUserId: string | null;
27
+ /** The API key that published this version, before publishing moved to the console. Null otherwise. */
22
28
  createdByCredentialId: string | null;
23
29
  createdAt: string | null;
24
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"voucher-refunds.js","sourceRoot":"","sources":["../src/voucher-refunds.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,6BAA6B,GAA0C,MAAM,CAAC,MAAM,CAAC;IAChG,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,KAAK;IACpB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;CACvB,CAAC,CAAC"}
1
+ {"version":3,"file":"voucher-refunds.js","sourceRoot":"","sources":["../src/voucher-refunds.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,6BAA6B,GAA0C,MAAM,CAAC,MAAM,CAAC;IAChG,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,KAAK;IACpB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;CACvB,CAAC,CAAC"}