@peable.to/contracts 6.1.0 → 6.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/dist/cjs/resources/billingEngine/index.js +4 -1
- package/dist/cjs/resources/billingEngine/quotes.js +342 -0
- package/dist/cjs/resources/connect/reporting.js +250 -2
- package/dist/cjs/resources/events/events.js +4 -0
- package/dist/cjs/vocabulary/errors.js +4 -0
- package/dist/cjs/vocabulary/events.js +4 -0
- package/dist/cjs/vocabulary/index.js +1 -0
- package/dist/cjs/vocabulary/invoices.js +3 -0
- package/dist/cjs/vocabulary/quotes.js +31 -0
- package/dist/cjs/vocabulary/reporting.js +28 -1
- package/dist/esm/resources/billingEngine/index.js +4 -1
- package/dist/esm/resources/billingEngine/quotes.js +339 -0
- package/dist/esm/resources/connect/reporting.js +251 -3
- package/dist/esm/resources/events/events.js +4 -0
- package/dist/esm/vocabulary/errors.js +4 -0
- package/dist/esm/vocabulary/events.js +4 -0
- package/dist/esm/vocabulary/index.js +1 -0
- package/dist/esm/vocabulary/invoices.js +3 -0
- package/dist/esm/vocabulary/quotes.js +28 -0
- package/dist/esm/vocabulary/reporting.js +27 -0
- package/dist/types/resources/billingEngine/index.d.ts +839 -1
- package/dist/types/resources/billingEngine/invoices.d.ts +12 -0
- package/dist/types/resources/billingEngine/quotes.d.ts +1032 -0
- package/dist/types/resources/connect/index.d.ts +671 -0
- package/dist/types/resources/connect/reporting.d.ts +894 -0
- package/dist/types/resources/events/events.d.ts +16 -0
- package/dist/types/resources/events/index.d.ts +54 -2
- package/dist/types/resources/events/webhookDeliveries.d.ts +12 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +52 -4
- package/dist/types/resources/payments/disputes.d.ts +10 -10
- package/dist/types/resources/payments/index.d.ts +6 -6
- package/dist/types/vocabulary/errors.d.ts +4 -0
- package/dist/types/vocabulary/events.d.ts +4 -0
- package/dist/types/vocabulary/index.d.ts +1 -0
- package/dist/types/vocabulary/invoices.d.ts +1 -1
- package/dist/types/vocabulary/quotes.d.ts +27 -0
- package/dist/types/vocabulary/reporting.d.ts +23 -0
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { embedded } from '../../common/objects.js';
|
|
2
|
+
import { embedded, expandable } from '../../common/objects.js';
|
|
3
3
|
import { listOf } from '../../common/envelopes.js';
|
|
4
4
|
import { defineComponent, defineObject, describe } from '../../common/objects.js';
|
|
5
5
|
import { emptyQuery, expandOnlyQuery, listQuery, queryInteger, unixSecondsParam, } from '../../common/params.js';
|
|
6
6
|
import { currency, livemode, unixSeconds } from '../../common/primitives.js';
|
|
7
7
|
import { defineRoute } from '../../route.js';
|
|
8
8
|
import { CURRENCY_CODES } from '../../vocabulary/money.js';
|
|
9
|
-
import { REPORT_RUN_STATUSES, REPORT_TYPE_IDS } from '../../vocabulary/reporting.js';
|
|
9
|
+
import { REPORT_RUN_STATUSES, REPORT_SCHEDULE_INTERVALS, REPORT_SCHEDULE_LOCALES, REPORT_SCHEDULE_MAX_RECIPIENTS, REPORT_SCHEDULE_STATUSES, REPORT_SCHEDULE_WEEKDAYS, REPORT_TYPE_IDS, } from '../../vocabulary/reporting.js';
|
|
10
10
|
/**
|
|
11
11
|
* Reporting (Stripe's `reporting.*`): a merchant asks for a report over an
|
|
12
12
|
* interval, Peable computes it in the background and stores the CSV as a
|
|
@@ -85,6 +85,7 @@ export const reportRunSchema = defineObject('reporting.report_run', 'ReportRun',
|
|
|
85
85
|
.nullable()
|
|
86
86
|
.describe('The CSV once `succeeded` — a File of purpose `finance_report_run` (`GET /v1/files/{id}/contents` reads it).'),
|
|
87
87
|
succeeded_at: unixSeconds.nullable(),
|
|
88
|
+
report_schedule: expandable('reporting.report_schedule', 'The schedule that fired this run (`frs_…`); `null` for a run asked for directly.').nullable(),
|
|
88
89
|
})
|
|
89
90
|
.strict(), {
|
|
90
91
|
examples: [
|
|
@@ -99,6 +100,78 @@ export const reportRunSchema = defineObject('reporting.report_run', 'ReportRun',
|
|
|
99
100
|
error: null,
|
|
100
101
|
result: null,
|
|
101
102
|
succeeded_at: null,
|
|
103
|
+
report_schedule: null,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
});
|
|
107
|
+
/** When a schedule fires (Stripe's payout-schedule spelling). */
|
|
108
|
+
export const reportScheduleCadenceSchema = defineComponent('ReportScheduleCadence', z
|
|
109
|
+
.object({
|
|
110
|
+
interval: z.enum(REPORT_SCHEDULE_INTERVALS),
|
|
111
|
+
weekly_anchor: z
|
|
112
|
+
.enum(REPORT_SCHEDULE_WEEKDAYS)
|
|
113
|
+
.nullable()
|
|
114
|
+
.describe('The day a `weekly` schedule fires; `null` otherwise.'),
|
|
115
|
+
monthly_anchor: z
|
|
116
|
+
.number()
|
|
117
|
+
.int()
|
|
118
|
+
.nullable()
|
|
119
|
+
.describe('The day of the month a `monthly` schedule fires (1–31; a shorter month fires on its last day); `null` otherwise.'),
|
|
120
|
+
})
|
|
121
|
+
.strict());
|
|
122
|
+
/**
|
|
123
|
+
* `reporting.report_schedule` (`frs_…`): a report run on a cadence. Each
|
|
124
|
+
* occurrence is local midnight in `timezone`; it creates an ordinary report
|
|
125
|
+
* run over the time since the previous occurrence, and emails `recipients` a
|
|
126
|
+
* link to it in Orbit once it succeeded (or failed). The CSV is never attached
|
|
127
|
+
* and never public: a recipient signs in to Orbit to download it.
|
|
128
|
+
*/
|
|
129
|
+
export const reportScheduleSchema = defineObject('reporting.report_schedule', 'ReportSchedule', z
|
|
130
|
+
.object({
|
|
131
|
+
id: z.string(),
|
|
132
|
+
object: z.literal('reporting.report_schedule'),
|
|
133
|
+
livemode,
|
|
134
|
+
created: unixSeconds,
|
|
135
|
+
report_type: reportTypeId,
|
|
136
|
+
parameters: z
|
|
137
|
+
.object({
|
|
138
|
+
columns: z.array(z.string()).optional(),
|
|
139
|
+
currency: currency.optional(),
|
|
140
|
+
})
|
|
141
|
+
.strict()
|
|
142
|
+
.describe("Every run's `parameters` but the interval, which each occurrence sets: the time since the previous occurrence."),
|
|
143
|
+
schedule: reportScheduleCadenceSchema,
|
|
144
|
+
timezone: z
|
|
145
|
+
.string()
|
|
146
|
+
.describe('The IANA time zone whose midnight each occurrence is (`Europe/Madrid`).'),
|
|
147
|
+
recipients: z
|
|
148
|
+
.array(z.string())
|
|
149
|
+
.describe('Who is emailed when a run of this schedule succeeds or fails.'),
|
|
150
|
+
locale: z.enum(REPORT_SCHEDULE_LOCALES).describe('The language of those emails.'),
|
|
151
|
+
status: z.enum(REPORT_SCHEDULE_STATUSES),
|
|
152
|
+
next_run_at: unixSeconds
|
|
153
|
+
.nullable()
|
|
154
|
+
.describe('The next occurrence while `active`; `null` while paused or canceled.'),
|
|
155
|
+
last_run: expandable('reporting.report_run', 'The newest run this schedule fired.').nullable(),
|
|
156
|
+
canceled_at: unixSeconds.nullable(),
|
|
157
|
+
})
|
|
158
|
+
.strict(), {
|
|
159
|
+
examples: [
|
|
160
|
+
{
|
|
161
|
+
id: 'frs_0193b8f34d1e4a6b8c27',
|
|
162
|
+
object: 'reporting.report_schedule',
|
|
163
|
+
livemode: false,
|
|
164
|
+
created: 1793750400,
|
|
165
|
+
report_type: 'balance.summary.1',
|
|
166
|
+
parameters: {},
|
|
167
|
+
schedule: { interval: 'monthly', weekly_anchor: null, monthly_anchor: 1 },
|
|
168
|
+
timezone: 'Europe/Madrid',
|
|
169
|
+
recipients: ['finance@example.com'],
|
|
170
|
+
locale: 'en',
|
|
171
|
+
status: 'active',
|
|
172
|
+
next_run_at: 1796079600,
|
|
173
|
+
last_run: null,
|
|
174
|
+
canceled_at: null,
|
|
102
175
|
},
|
|
103
176
|
],
|
|
104
177
|
});
|
|
@@ -122,7 +195,79 @@ export const createReportRunParams = z
|
|
|
122
195
|
.strict(),
|
|
123
196
|
})
|
|
124
197
|
.strict();
|
|
125
|
-
export const listReportRunsQuery = listQuery({
|
|
198
|
+
export const listReportRunsQuery = listQuery({
|
|
199
|
+
report_type: reportTypeId.optional(),
|
|
200
|
+
report_schedule: z
|
|
201
|
+
.string()
|
|
202
|
+
.min(1)
|
|
203
|
+
.max(64)
|
|
204
|
+
.optional()
|
|
205
|
+
.describe('Only the runs this schedule (`frs_…`) fired.'),
|
|
206
|
+
});
|
|
207
|
+
/** A schedule's run template: a run's `parameters` without the interval. */
|
|
208
|
+
const scheduleParameters = z
|
|
209
|
+
.object({
|
|
210
|
+
columns: z
|
|
211
|
+
.array(column)
|
|
212
|
+
.min(1)
|
|
213
|
+
.max(64)
|
|
214
|
+
.optional()
|
|
215
|
+
.describe("Columns of the report type's layout, each once."),
|
|
216
|
+
currency: z.enum(CURRENCY_CODES).optional(),
|
|
217
|
+
})
|
|
218
|
+
.strict();
|
|
219
|
+
const cadenceParams = z
|
|
220
|
+
.object({
|
|
221
|
+
interval: z.enum(REPORT_SCHEDULE_INTERVALS),
|
|
222
|
+
weekly_anchor: z
|
|
223
|
+
.enum(REPORT_SCHEDULE_WEEKDAYS)
|
|
224
|
+
.optional()
|
|
225
|
+
.describe('Required for `weekly`, refused otherwise.'),
|
|
226
|
+
monthly_anchor: z
|
|
227
|
+
.number()
|
|
228
|
+
.int()
|
|
229
|
+
.min(1)
|
|
230
|
+
.max(31)
|
|
231
|
+
.optional()
|
|
232
|
+
.describe('Required for `monthly`, refused otherwise; a shorter month fires on its last day.'),
|
|
233
|
+
})
|
|
234
|
+
.strict();
|
|
235
|
+
const recipientsParam = z
|
|
236
|
+
.array(z.email().max(254))
|
|
237
|
+
.max(REPORT_SCHEDULE_MAX_RECIPIENTS)
|
|
238
|
+
.describe(`At most ${String(REPORT_SCHEDULE_MAX_RECIPIENTS)} addresses, each once. They receive a link to the run in Orbit, never the file.`);
|
|
239
|
+
const timezoneParam = z
|
|
240
|
+
.string()
|
|
241
|
+
.min(1)
|
|
242
|
+
.max(64)
|
|
243
|
+
.describe('An IANA time zone (`Europe/Madrid`); `UTC` when absent.');
|
|
244
|
+
/** `POST /v1/reporting/report_schedules`. */
|
|
245
|
+
export const createReportScheduleParams = z
|
|
246
|
+
.object({
|
|
247
|
+
report_type: reportTypeId,
|
|
248
|
+
parameters: scheduleParameters.optional(),
|
|
249
|
+
schedule: cadenceParams,
|
|
250
|
+
timezone: timezoneParam.optional(),
|
|
251
|
+
recipients: recipientsParam.optional(),
|
|
252
|
+
locale: z.enum(REPORT_SCHEDULE_LOCALES).optional().describe('`en` when absent.'),
|
|
253
|
+
})
|
|
254
|
+
.strict();
|
|
255
|
+
/** `POST /v1/reporting/report_schedules/{id}`: each field sent replaces the stored one. */
|
|
256
|
+
export const updateReportScheduleParams = z
|
|
257
|
+
.object({
|
|
258
|
+
report_type: reportTypeId.optional(),
|
|
259
|
+
parameters: scheduleParameters.optional(),
|
|
260
|
+
schedule: cadenceParams.optional(),
|
|
261
|
+
timezone: timezoneParam.optional(),
|
|
262
|
+
recipients: recipientsParam.optional(),
|
|
263
|
+
locale: z.enum(REPORT_SCHEDULE_LOCALES).optional(),
|
|
264
|
+
})
|
|
265
|
+
.strict();
|
|
266
|
+
/** Pause, resume and cancel take no parameters. */
|
|
267
|
+
export const reportScheduleActionParams = z.object({}).strict();
|
|
268
|
+
export const listReportSchedulesQuery = listQuery({
|
|
269
|
+
status: z.enum(REPORT_SCHEDULE_STATUSES).optional(),
|
|
270
|
+
});
|
|
126
271
|
/**
|
|
127
272
|
* A download's query: a run's `parameters`, spelled as a query string
|
|
128
273
|
* (`columns[]=a&columns[]=b`, or one `columns=a`).
|
|
@@ -147,6 +292,7 @@ export const downloadReportQuery = z
|
|
|
147
292
|
})
|
|
148
293
|
.strict();
|
|
149
294
|
const reportTypeIdParam = { id: 'The report type (`payments.itemized.1`, …).' };
|
|
295
|
+
const reportScheduleIdParam = { id: 'The report schedule (`frs_…`).' };
|
|
150
296
|
export const reportingRoutes = [
|
|
151
297
|
defineRoute({
|
|
152
298
|
operationId: 'listReportTypes',
|
|
@@ -229,4 +375,106 @@ export const reportingRoutes = [
|
|
|
229
375
|
sdk: 'reporting.reportRuns.retrieve',
|
|
230
376
|
expandable: 'reporting.report_run',
|
|
231
377
|
}),
|
|
378
|
+
defineRoute({
|
|
379
|
+
operationId: 'createReportSchedule',
|
|
380
|
+
method: 'post',
|
|
381
|
+
path: '/v1/reporting/report_schedules',
|
|
382
|
+
tag: 'Reporting',
|
|
383
|
+
summary: 'Create a report schedule',
|
|
384
|
+
description: 'A report run at local midnight in `timezone` every day, week or month, each over the time since the previous occurrence. `next_run_at` is the first occurrence after now; nothing is backfilled.',
|
|
385
|
+
auth: 'service',
|
|
386
|
+
scope: 'payments:write',
|
|
387
|
+
idempotent: true,
|
|
388
|
+
body: createReportScheduleParams,
|
|
389
|
+
response: reportScheduleSchema,
|
|
390
|
+
sdk: 'reporting.reportSchedules.create',
|
|
391
|
+
}),
|
|
392
|
+
defineRoute({
|
|
393
|
+
operationId: 'listReportSchedules',
|
|
394
|
+
method: 'get',
|
|
395
|
+
path: '/v1/reporting/report_schedules',
|
|
396
|
+
tag: 'Reporting',
|
|
397
|
+
summary: 'List report schedules',
|
|
398
|
+
description: 'Newest first; a canceled schedule is listed too.',
|
|
399
|
+
auth: 'service',
|
|
400
|
+
scope: 'payments:read',
|
|
401
|
+
query: listReportSchedulesQuery,
|
|
402
|
+
response: listOf(reportScheduleSchema),
|
|
403
|
+
sdk: 'reporting.reportSchedules.list',
|
|
404
|
+
expandable: 'reporting.report_schedule',
|
|
405
|
+
}),
|
|
406
|
+
defineRoute({
|
|
407
|
+
operationId: 'retrieveReportSchedule',
|
|
408
|
+
method: 'get',
|
|
409
|
+
path: '/v1/reporting/report_schedules/{id}',
|
|
410
|
+
tag: 'Reporting',
|
|
411
|
+
summary: 'Retrieve a report schedule',
|
|
412
|
+
auth: 'service',
|
|
413
|
+
scope: 'payments:read',
|
|
414
|
+
params: reportScheduleIdParam,
|
|
415
|
+
query: expandOnlyQuery,
|
|
416
|
+
response: reportScheduleSchema,
|
|
417
|
+
sdk: 'reporting.reportSchedules.retrieve',
|
|
418
|
+
expandable: 'reporting.report_schedule',
|
|
419
|
+
}),
|
|
420
|
+
defineRoute({
|
|
421
|
+
operationId: 'updateReportSchedule',
|
|
422
|
+
method: 'post',
|
|
423
|
+
path: '/v1/reporting/report_schedules/{id}',
|
|
424
|
+
tag: 'Reporting',
|
|
425
|
+
summary: 'Update a report schedule',
|
|
426
|
+
description: 'A new `schedule` or `timezone` moves an active schedule to its first occurrence after now. A canceled schedule cannot change (409 `report_schedule_unexpected_state`).',
|
|
427
|
+
auth: 'service',
|
|
428
|
+
scope: 'payments:write',
|
|
429
|
+
idempotent: true,
|
|
430
|
+
params: reportScheduleIdParam,
|
|
431
|
+
body: updateReportScheduleParams,
|
|
432
|
+
response: reportScheduleSchema,
|
|
433
|
+
sdk: 'reporting.reportSchedules.update',
|
|
434
|
+
}),
|
|
435
|
+
defineRoute({
|
|
436
|
+
operationId: 'pauseReportSchedule',
|
|
437
|
+
method: 'post',
|
|
438
|
+
path: '/v1/reporting/report_schedules/{id}/pause',
|
|
439
|
+
tag: 'Reporting',
|
|
440
|
+
summary: 'Pause a report schedule',
|
|
441
|
+
description: 'Nothing fires until it is resumed. Pausing a paused schedule answers it as it is.',
|
|
442
|
+
auth: 'service',
|
|
443
|
+
scope: 'payments:write',
|
|
444
|
+
idempotent: true,
|
|
445
|
+
params: reportScheduleIdParam,
|
|
446
|
+
body: reportScheduleActionParams,
|
|
447
|
+
response: reportScheduleSchema,
|
|
448
|
+
sdk: 'reporting.reportSchedules.pause',
|
|
449
|
+
}),
|
|
450
|
+
defineRoute({
|
|
451
|
+
operationId: 'resumeReportSchedule',
|
|
452
|
+
method: 'post',
|
|
453
|
+
path: '/v1/reporting/report_schedules/{id}/resume',
|
|
454
|
+
tag: 'Reporting',
|
|
455
|
+
summary: 'Resume a paused report schedule',
|
|
456
|
+
description: 'It fires again from its first occurrence after now; the occurrences it missed while paused are not run.',
|
|
457
|
+
auth: 'service',
|
|
458
|
+
scope: 'payments:write',
|
|
459
|
+
idempotent: true,
|
|
460
|
+
params: reportScheduleIdParam,
|
|
461
|
+
body: reportScheduleActionParams,
|
|
462
|
+
response: reportScheduleSchema,
|
|
463
|
+
sdk: 'reporting.reportSchedules.resume',
|
|
464
|
+
}),
|
|
465
|
+
defineRoute({
|
|
466
|
+
operationId: 'cancelReportSchedule',
|
|
467
|
+
method: 'post',
|
|
468
|
+
path: '/v1/reporting/report_schedules/{id}/cancel',
|
|
469
|
+
tag: 'Reporting',
|
|
470
|
+
summary: 'Cancel a report schedule',
|
|
471
|
+
description: 'For good: it never fires again, and a run it fires no longer emails anyone. Its runs and their files stay.',
|
|
472
|
+
auth: 'service',
|
|
473
|
+
scope: 'payments:write',
|
|
474
|
+
idempotent: true,
|
|
475
|
+
params: reportScheduleIdParam,
|
|
476
|
+
body: reportScheduleActionParams,
|
|
477
|
+
response: reportScheduleSchema,
|
|
478
|
+
sdk: 'reporting.reportSchedules.cancel',
|
|
479
|
+
}),
|
|
232
480
|
];
|
|
@@ -270,6 +270,10 @@ export const WEBHOOK_EVENT_DESCRIPTIONS = {
|
|
|
270
270
|
'billing_portal.configuration.created': 'A customer portal configuration was created.',
|
|
271
271
|
'billing_portal.configuration.updated': 'A customer portal configuration was updated.',
|
|
272
272
|
'billing_portal.session.created': 'A customer portal session was created.',
|
|
273
|
+
'quote.created': 'A draft Quote was created.',
|
|
274
|
+
'quote.finalized': 'A Quote was finalized: numbered, priced and taxed, waiting for its customer.',
|
|
275
|
+
'quote.accepted': 'A Quote was accepted: its `invoice` (and, for recurring lines, its `subscription`) exists.',
|
|
276
|
+
'quote.canceled': 'A Quote was cancelled, or expired while open.',
|
|
273
277
|
'tax.assessment.created': 'A tax compliance assessment was run. Nothing was registered, filed or collected.',
|
|
274
278
|
'tax.review_item.created': 'A tax assessment finding opened a review item.',
|
|
275
279
|
'tax.review_item.updated': 'A tax review item was decided, or found again.',
|
|
@@ -112,8 +112,12 @@ export const ERROR_CODE_DESCRIPTIONS = {
|
|
|
112
112
|
invoice_not_editable: 'The invoice is finalized and can no longer be edited.',
|
|
113
113
|
invoice_unexpected_state: 'The invoice is in a status that does not allow this operation.',
|
|
114
114
|
invoice_no_customer_line_items: 'The invoice has no line items to finalize.',
|
|
115
|
+
quote_not_editable: 'Only a draft quote can be edited.',
|
|
116
|
+
quote_unexpected_state: "The quote's status does not allow this.",
|
|
117
|
+
quote_expired: 'The quote expired.',
|
|
115
118
|
invoice_payment_intent_requires_action: "The invoice's payment needs the customer to act (a card challenge).",
|
|
116
119
|
subscription_unexpected_state: 'The subscription is in a status that does not allow this operation.',
|
|
120
|
+
report_schedule_unexpected_state: 'A canceled report schedule never changes.',
|
|
117
121
|
customer_currency_mismatch: "The currency differs from the customer's billing currency.",
|
|
118
122
|
customer_test_clock_mismatch: 'The objects live on different test clocks.',
|
|
119
123
|
coupon_invalid: 'The coupon does not exist or is no longer valid.',
|
|
@@ -120,6 +120,10 @@ export const WEBHOOK_EVENT_OBJECTS = {
|
|
|
120
120
|
'billing_portal.configuration.created': 'billing_portal.configuration',
|
|
121
121
|
'billing_portal.configuration.updated': 'billing_portal.configuration',
|
|
122
122
|
'billing_portal.session.created': 'billing_portal.session',
|
|
123
|
+
'quote.created': 'quote',
|
|
124
|
+
'quote.finalized': 'quote',
|
|
125
|
+
'quote.accepted': 'quote',
|
|
126
|
+
'quote.canceled': 'quote',
|
|
123
127
|
'tax.assessment.created': 'tax.assessment',
|
|
124
128
|
'tax.review_item.created': 'tax.review_item',
|
|
125
129
|
'tax.review_item.updated': 'tax.review_item',
|
|
@@ -10,6 +10,9 @@ export const INVOICE_BILLING_REASONS = [
|
|
|
10
10
|
'subscription_update',
|
|
11
11
|
'subscription_cancel',
|
|
12
12
|
'upcoming',
|
|
13
|
+
// A one-time quote's invoice (Stripe's name); a recurring quote's first
|
|
14
|
+
// invoice is its subscription's `subscription_create`.
|
|
15
|
+
'quote_accept',
|
|
13
16
|
];
|
|
14
17
|
/**
|
|
15
18
|
* `automatic_tax.status` — Peable Tax (ADR 0011) is computed before an invoice
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Quotes (`qt_…`, ADR 0018 §5) — the closed value sets their schemas are built
|
|
2
|
+
// from. Zod-free: `@peable.to/shared-types` re-exports them at runtime.
|
|
3
|
+
/**
|
|
4
|
+
* Where a quote stands — Stripe's four.
|
|
5
|
+
*
|
|
6
|
+
* - `draft` — being written; the only status a quote can be edited in.
|
|
7
|
+
* - `open` — finalized: numbered, priced and taxed, waiting for the
|
|
8
|
+
* customer's answer until `expires_at`.
|
|
9
|
+
* - `accepted` — terminal: the native billing engine made its invoice (one-time
|
|
10
|
+
* lines) or its subscription and first invoice (recurring lines).
|
|
11
|
+
* - `canceled` — terminal: cancelled by the merchant, or expired while open.
|
|
12
|
+
*/
|
|
13
|
+
export const QUOTE_STATUSES = ['draft', 'open', 'accepted', 'canceled'];
|
|
14
|
+
/** Bounds a quote is checked against. */
|
|
15
|
+
export const QUOTE_LIMITS = {
|
|
16
|
+
/** Lines on one quote — a subscription's item limit. */
|
|
17
|
+
lineItemsMax: 20,
|
|
18
|
+
quantityMax: 1000000,
|
|
19
|
+
/** `header` and `footer`; `description` is 1500 like an invoice's. */
|
|
20
|
+
headerMax: 50,
|
|
21
|
+
footerMax: 500,
|
|
22
|
+
descriptionMax: 1500,
|
|
23
|
+
/** A quote expires 30 days after it is created unless `expires_at` says otherwise (Stripe's default). */
|
|
24
|
+
defaultExpiryDays: 30,
|
|
25
|
+
/** `expires_at` at most this far ahead. */
|
|
26
|
+
expiryMaxDays: 365,
|
|
27
|
+
trialPeriodDaysMax: 730,
|
|
28
|
+
};
|
|
@@ -22,3 +22,30 @@ export const REQUEST_LOG_METHODS = ['GET', 'POST', 'DELETE', 'PATCH', 'PUT'];
|
|
|
22
22
|
export const REQUEST_LOG_STATUS_CLASSES = ['2xx', '3xx', '4xx', '5xx'];
|
|
23
23
|
/** How long a request log is kept (and served). */
|
|
24
24
|
export const REQUEST_LOG_RETENTION_DAYS = 30;
|
|
25
|
+
/**
|
|
26
|
+
* A report schedule's lifecycle: `active` fires at each occurrence, `paused`
|
|
27
|
+
* fires nothing until resumed (resuming never backfills), `canceled` is
|
|
28
|
+
* terminal.
|
|
29
|
+
*/
|
|
30
|
+
export const REPORT_SCHEDULE_STATUSES = ['active', 'paused', 'canceled'];
|
|
31
|
+
/**
|
|
32
|
+
* How often a schedule fires — Stripe's payout-schedule spelling: every day,
|
|
33
|
+
* once a week on `weekly_anchor`, once a month on `monthly_anchor`. Each
|
|
34
|
+
* occurrence is local midnight in the schedule's timezone, and its run covers
|
|
35
|
+
* the time since the previous occurrence.
|
|
36
|
+
*/
|
|
37
|
+
export const REPORT_SCHEDULE_INTERVALS = ['daily', 'weekly', 'monthly'];
|
|
38
|
+
/** A weekly schedule's day, Monday first (ISO 8601). */
|
|
39
|
+
export const REPORT_SCHEDULE_WEEKDAYS = [
|
|
40
|
+
'monday',
|
|
41
|
+
'tuesday',
|
|
42
|
+
'wednesday',
|
|
43
|
+
'thursday',
|
|
44
|
+
'friday',
|
|
45
|
+
'saturday',
|
|
46
|
+
'sunday',
|
|
47
|
+
];
|
|
48
|
+
/** The languages a schedule's emails are written in — Orbit's own. */
|
|
49
|
+
export const REPORT_SCHEDULE_LOCALES = ['en', 'es'];
|
|
50
|
+
/** How many addresses one schedule may email. */
|
|
51
|
+
export const REPORT_SCHEDULE_MAX_RECIPIENTS = 10;
|