@peable.to/shared-types 0.16.0 → 0.17.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/file.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // (ADR 0016: Orbit owns the object; the storage is Oxy Files, a binding that
4
4
  // never reaches the wire). Stripe's Files API, with Oxy Files underneath.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FILE_PURPOSE_POLICIES = exports.FILE_STATUSES = exports.FILE_TYPES = exports.FILE_PURPOSES = void 0;
6
+ exports.FILE_PURPOSE_POLICIES = exports.FILE_STATUSES = exports.FILE_TYPES = exports.FILE_UPLOAD_PURPOSES = exports.FILE_PURPOSES = void 0;
7
7
  /**
8
8
  * What a file is FOR. Decided at upload and never changed: the purpose is what
9
9
  * sets the type and size policy, who may see the bytes, and which objects may
@@ -15,9 +15,22 @@ exports.FILE_PURPOSES = [
15
15
  'business_logo',
16
16
  'identity_document',
17
17
  'additional_verification',
18
+ 'finance_report_run',
19
+ ];
20
+ /**
21
+ * The purposes a merchant may upload or import. `finance_report_run` is not
22
+ * among them: a report's CSV is written by Peable's report runs
23
+ * (`/v1/reporting/report_runs`) and nobody else, so a file of that purpose is
24
+ * always a report Peable produced.
25
+ */
26
+ exports.FILE_UPLOAD_PURPOSES = [
27
+ 'dispute_evidence',
28
+ 'business_logo',
29
+ 'identity_document',
30
+ 'additional_verification',
18
31
  ];
19
32
  /** The stored format, by its conventional extension (Stripe's `type`). */
20
- exports.FILE_TYPES = ['pdf', 'png', 'jpg'];
33
+ exports.FILE_TYPES = ['pdf', 'png', 'jpg', 'csv'];
21
34
  /**
22
35
  * Whether the bytes can be used right now.
23
36
  *
@@ -29,16 +42,18 @@ exports.FILE_TYPES = ['pdf', 'png', 'jpg'];
29
42
  */
30
43
  exports.FILE_STATUSES = ['available', 'withheld', 'removed'];
31
44
  /**
32
- * The upload policy of each purpose: the formats it takes, recognised from the
33
- * bytes and never from a client's `Content-Type`, and the largest file.
45
+ * The policy of each purpose: the formats it takes, recognised from the bytes
46
+ * and never from a client's `Content-Type`, and the largest file.
34
47
  *
35
48
  * The provider's own ceilings, restated where the upload is parsed, so a file
36
49
  * the card network would refuse is refused at upload — not at the one-shot
37
- * dispute submission it was meant for.
50
+ * dispute submission it was meant for. `finance_report_run` is Peable's own
51
+ * output (see {@link FILE_UPLOAD_PURPOSES}); its ceiling bounds a report.
38
52
  */
39
53
  exports.FILE_PURPOSE_POLICIES = Object.freeze({
40
54
  dispute_evidence: { types: ['pdf', 'png', 'jpg'], max_bytes: 5 * 1024 * 1024 },
41
55
  business_logo: { types: ['png', 'jpg'], max_bytes: 512 * 1024 },
42
56
  identity_document: { types: ['pdf', 'png', 'jpg'], max_bytes: 10 * 1024 * 1024 },
43
57
  additional_verification: { types: ['pdf', 'png', 'jpg'], max_bytes: 10 * 1024 * 1024 },
58
+ finance_report_run: { types: ['csv'], max_bytes: 64 * 1024 * 1024 },
44
59
  });
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PAYOUT_STATUSES = exports.BALANCE_TRANSACTION_TYPES = exports.BALANCE_TRANSACTION_STATUSES = exports.PAYOUT_WEEKLY_ANCHORS = exports.PAYOUT_INTERVALS = exports.PAYMENT_METHOD_CURRENCIES = exports.PAYMENT_METHOD_CONFIGURATION_TYPES = exports.CARD_RAIL_PAYMENT_METHOD_TYPES = exports.FILE_TYPES = exports.FILE_STATUSES = exports.FILE_PURPOSE_POLICIES = exports.FILE_PURPOSES = exports.normalizeDisputeReason = exports.DISPUTE_TEXT_EVIDENCE_FIELDS = exports.DISPUTE_REASONS = exports.DISPUTE_FILE_EVIDENCE_FIELDS = exports.CATALOG_LIMITS = exports.COUPON_DURATIONS = exports.TRANSFORM_QUANTITY_ROUNDS = exports.PRICE_TAX_BEHAVIORS = exports.RECURRING_USAGE_TYPES = exports.RECURRING_INTERVALS = exports.PRICE_TYPES = exports.PRICE_TIERS_MODES = exports.PRICE_BILLING_SCHEMES = exports.WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS = exports.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = exports.WEBHOOK_ENDPOINT_DISABLED_REASONS = exports.WEBHOOK_ENDPOINT_STATUSES = exports.PEABLE_API_VERSION = exports.SETUP_INTENT_STATUSES = exports.isValidStatusTransition = exports.canStillBePaid = exports.canExpire = exports.TERMINAL_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.PAYMENT_INTENT_SETUP_FUTURE_USAGES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_CAPTURE_METHODS = exports.PAYMENT_INTENT_CANCELLATION_REASONS = exports.MERCHANT_CANCELLATION_REASONS = exports.EXPIRABLE_STATUSES = exports.CARD_ONLY_STATUSES = exports.isCurrencyCode = exports.decimalsFor = exports.FIAT_CURRENCY_CODES = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
4
- exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = exports.PEABLE_BILLING_AUTHORITY_KEYS = exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.DEFAULT_BRANDING = exports.BRANDING_COLOR_PATTERN = exports.BRANDING_BORDER_STYLES = exports.BRANDING_FONTS = exports.CHECKOUT_SESSION_ID_TEMPLATE = exports.CHECKOUT_LIMITS = exports.CHECKOUT_TAX_ID_TYPES = exports.CHECKOUT_CUSTOM_FIELD_TYPES = exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = exports.CHECKOUT_CUSTOMER_CREATIONS = exports.CHECKOUT_SUBMIT_TYPES = exports.CHECKOUT_LOCALES = exports.CHECKOUT_UI_MODES = exports.CHECKOUT_PAYMENT_STATUSES = exports.CHECKOUT_SESSION_STATUSES = exports.CHECKOUT_SESSION_MODES = exports.PAYMENT_LINK_LIMITS = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.SIMULATED_FAIRCOIN_OUTCOMES = exports.REQUEST_LOG_RETENTION_DAYS = exports.REQUEST_LOG_METHODS = exports.REFUND_REASONS = exports.RECONCILIATION_MISMATCH_KINDS = void 0;
3
+ exports.REPORT_TYPE_LAYOUTS = exports.REPORT_TYPE_IDS = exports.REPORT_RUN_STATUSES = exports.SEARCH_SUBSTRING_MIN_LENGTH = exports.SEARCH_QUERY_MAX_LENGTH = exports.SEARCH_QUERY_MAX_CLAUSES = exports.SEARCHABLE_RESOURCES = exports.FILE_TYPES = exports.FILE_STATUSES = exports.FILE_UPLOAD_PURPOSES = exports.FILE_PURPOSE_POLICIES = exports.FILE_PURPOSES = exports.normalizeDisputeReason = exports.DISPUTE_TEXT_EVIDENCE_FIELDS = exports.DISPUTE_REASONS = exports.DISPUTE_FILE_EVIDENCE_FIELDS = exports.CATALOG_LIMITS = exports.COUPON_DURATIONS = exports.TRANSFORM_QUANTITY_ROUNDS = exports.PRICE_TAX_BEHAVIORS = exports.RECURRING_USAGE_TYPES = exports.RECURRING_INTERVALS = exports.PRICE_TYPES = exports.PRICE_TIERS_MODES = exports.PRICE_BILLING_SCHEMES = exports.WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS = exports.WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = exports.WEBHOOK_ENDPOINT_DISABLED_REASONS = exports.WEBHOOK_ENDPOINT_STATUSES = exports.PEABLE_API_VERSION = exports.SETUP_INTENT_STATUSES = exports.isValidStatusTransition = exports.canStillBePaid = exports.canExpire = exports.TERMINAL_STATUSES = exports.PAYMENT_INTENT_STATUSES = exports.PAYMENT_INTENT_SETUP_FUTURE_USAGES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_CAPTURE_METHODS = exports.PAYMENT_INTENT_CANCELLATION_REASONS = exports.MERCHANT_CANCELLATION_REASONS = exports.EXPIRABLE_STATUSES = exports.CARD_ONLY_STATUSES = exports.isCurrencyCode = exports.decimalsFor = exports.FIAT_CURRENCY_CODES = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
4
+ exports.TAX_LOCATION_EVIDENCE_TYPES = exports.TAX_REGISTRATION_SCHEMES = exports.PEABLE_BILLING_AUTHORITY_KEYS = exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.DEFAULT_BRANDING = exports.BRANDING_COLOR_PATTERN = exports.BRANDING_BORDER_STYLES = exports.BRANDING_FONTS = exports.CHECKOUT_SESSION_ID_TEMPLATE = exports.CHECKOUT_LIMITS = exports.CHECKOUT_TAX_ID_TYPES = exports.CHECKOUT_CUSTOM_FIELD_TYPES = exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = exports.CHECKOUT_CUSTOMER_CREATIONS = exports.CHECKOUT_SUBMIT_TYPES = exports.CHECKOUT_LOCALES = exports.CHECKOUT_UI_MODES = exports.CHECKOUT_PAYMENT_STATUSES = exports.CHECKOUT_SESSION_STATUSES = exports.CHECKOUT_SESSION_MODES = exports.PAYMENT_LINK_LIMITS = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.SIMULATED_FAIRCOIN_OUTCOMES = exports.REQUEST_LOG_RETENTION_DAYS = exports.REQUEST_LOG_METHODS = exports.REFUND_REASONS = exports.RECONCILIATION_MISMATCH_KINDS = exports.PAYOUT_STATUSES = exports.BALANCE_TRANSACTION_TYPES = exports.BALANCE_TRANSACTION_STATUSES = exports.PAYOUT_WEEKLY_ANCHORS = exports.PAYOUT_INTERVALS = exports.PAYMENT_METHOD_CURRENCIES = exports.PAYMENT_METHOD_CONFIGURATION_TYPES = exports.CARD_RAIL_PAYMENT_METHOD_TYPES = void 0;
5
5
  // @peable.to/shared-types — public API for the Peable Gateway contract.
6
6
  var money_1 = require("./money");
7
7
  Object.defineProperty(exports, "UNITS_PER_COIN", { enumerable: true, get: function () { return money_1.UNITS_PER_COIN; } });
@@ -51,8 +51,18 @@ Object.defineProperty(exports, "normalizeDisputeReason", { enumerable: true, get
51
51
  var file_1 = require("./file");
52
52
  Object.defineProperty(exports, "FILE_PURPOSES", { enumerable: true, get: function () { return file_1.FILE_PURPOSES; } });
53
53
  Object.defineProperty(exports, "FILE_PURPOSE_POLICIES", { enumerable: true, get: function () { return file_1.FILE_PURPOSE_POLICIES; } });
54
+ Object.defineProperty(exports, "FILE_UPLOAD_PURPOSES", { enumerable: true, get: function () { return file_1.FILE_UPLOAD_PURPOSES; } });
54
55
  Object.defineProperty(exports, "FILE_STATUSES", { enumerable: true, get: function () { return file_1.FILE_STATUSES; } });
55
56
  Object.defineProperty(exports, "FILE_TYPES", { enumerable: true, get: function () { return file_1.FILE_TYPES; } });
57
+ var search_1 = require("./search");
58
+ Object.defineProperty(exports, "SEARCHABLE_RESOURCES", { enumerable: true, get: function () { return search_1.SEARCHABLE_RESOURCES; } });
59
+ Object.defineProperty(exports, "SEARCH_QUERY_MAX_CLAUSES", { enumerable: true, get: function () { return search_1.SEARCH_QUERY_MAX_CLAUSES; } });
60
+ Object.defineProperty(exports, "SEARCH_QUERY_MAX_LENGTH", { enumerable: true, get: function () { return search_1.SEARCH_QUERY_MAX_LENGTH; } });
61
+ Object.defineProperty(exports, "SEARCH_SUBSTRING_MIN_LENGTH", { enumerable: true, get: function () { return search_1.SEARCH_SUBSTRING_MIN_LENGTH; } });
62
+ var reporting_1 = require("./reporting");
63
+ Object.defineProperty(exports, "REPORT_RUN_STATUSES", { enumerable: true, get: function () { return reporting_1.REPORT_RUN_STATUSES; } });
64
+ Object.defineProperty(exports, "REPORT_TYPE_IDS", { enumerable: true, get: function () { return reporting_1.REPORT_TYPE_IDS; } });
65
+ Object.defineProperty(exports, "REPORT_TYPE_LAYOUTS", { enumerable: true, get: function () { return reporting_1.REPORT_TYPE_LAYOUTS; } });
56
66
  var paymentMethodConfiguration_1 = require("./paymentMethodConfiguration");
57
67
  Object.defineProperty(exports, "CARD_RAIL_PAYMENT_METHOD_TYPES", { enumerable: true, get: function () { return paymentMethodConfiguration_1.CARD_RAIL_PAYMENT_METHOD_TYPES; } });
58
68
  Object.defineProperty(exports, "PAYMENT_METHOD_CONFIGURATION_TYPES", { enumerable: true, get: function () { return paymentMethodConfiguration_1.PAYMENT_METHOD_CONFIGURATION_TYPES; } });
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REPORT_RUN_STATUSES = exports.REPORT_TYPE_LAYOUTS = exports.REPORT_TYPE_IDS = void 0;
4
+ /**
5
+ * Every report Peable produces, by Stripe's versioned id: the trailing `.1` is
6
+ * the column layout's version, so a layout can change under a new id without
7
+ * changing a report a merchant already parses.
8
+ */
9
+ exports.REPORT_TYPE_IDS = [
10
+ 'payments.itemized.1',
11
+ 'balance.summary.1',
12
+ 'payouts.itemized.1',
13
+ ];
14
+ /**
15
+ * The layout of each report: its name, every column it can carry and the ones
16
+ * it carries when `parameters.columns` is absent. Fixed per version.
17
+ *
18
+ * - `payments.itemized.1` — one row per payment intent CREATED in the
19
+ * interval. Amounts are base-unit strings, as on the API.
20
+ * - `balance.summary.1` — per currency, the balance at `interval_start`, the
21
+ * activity and payouts inside the interval, and the balance at
22
+ * `interval_end`, from the ledger (ADR 0015). A figure built on a transaction
23
+ * whose fee the provider has not reported is empty, never `0`.
24
+ * - `payouts.itemized.1` — one row per payout created in the interval.
25
+ */
26
+ exports.REPORT_TYPE_LAYOUTS = Object.freeze({
27
+ 'payments.itemized.1': {
28
+ name: 'Itemized payments',
29
+ columns: [
30
+ 'payment_intent_id',
31
+ 'created_utc',
32
+ 'status',
33
+ 'rail',
34
+ 'currency',
35
+ 'amount',
36
+ 'amount_received',
37
+ 'amount_refunded',
38
+ 'customer_id',
39
+ 'charge_id',
40
+ 'capture_method',
41
+ 'description',
42
+ 'receipt_email',
43
+ 'cancellation_reason',
44
+ 'canceled_at_utc',
45
+ ],
46
+ default_columns: [
47
+ 'payment_intent_id',
48
+ 'created_utc',
49
+ 'status',
50
+ 'currency',
51
+ 'amount',
52
+ 'amount_received',
53
+ 'amount_refunded',
54
+ 'customer_id',
55
+ ],
56
+ ledger: false,
57
+ },
58
+ 'balance.summary.1': {
59
+ name: 'Balance summary',
60
+ columns: ['category', 'description', 'currency', 'net_amount', 'transaction_count'],
61
+ default_columns: ['category', 'description', 'currency', 'net_amount'],
62
+ ledger: true,
63
+ },
64
+ 'payouts.itemized.1': {
65
+ name: 'Itemized payouts',
66
+ columns: [
67
+ 'payout_id',
68
+ 'created_utc',
69
+ 'arrival_date_utc',
70
+ 'status',
71
+ 'currency',
72
+ 'amount',
73
+ 'method',
74
+ 'type',
75
+ 'automatic',
76
+ 'description',
77
+ 'statement_descriptor',
78
+ 'failure_code',
79
+ ],
80
+ default_columns: [
81
+ 'payout_id',
82
+ 'created_utc',
83
+ 'arrival_date_utc',
84
+ 'status',
85
+ 'currency',
86
+ 'amount',
87
+ 'automatic',
88
+ ],
89
+ ledger: true,
90
+ },
91
+ });
92
+ exports.REPORT_RUN_STATUSES = ['pending', 'succeeded', 'failed'];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ // The search contract (Stripe's Search API): `GET /v1/<objects>/search?query=…`.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SEARCH_SUBSTRING_MIN_LENGTH = exports.SEARCH_QUERY_MAX_CLAUSES = exports.SEARCH_QUERY_MAX_LENGTH = exports.SEARCHABLE_RESOURCES = void 0;
5
+ /** Every searchable resource, by its path segment (`/v1/<resource>/search`). */
6
+ exports.SEARCHABLE_RESOURCES = [
7
+ 'payment_intents',
8
+ 'charges',
9
+ 'customers',
10
+ 'products',
11
+ 'prices',
12
+ 'refunds',
13
+ ];
14
+ /** Search query bounds — the gateway's, restated so a client can check before it asks. */
15
+ exports.SEARCH_QUERY_MAX_LENGTH = 1000;
16
+ exports.SEARCH_QUERY_MAX_CLAUSES = 10;
17
+ /** A `~` substring needs at least this many characters (Stripe's rule). */
18
+ exports.SEARCH_SUBSTRING_MIN_LENGTH = 3;
package/dist/esm/file.js CHANGED
@@ -12,9 +12,22 @@ export const FILE_PURPOSES = [
12
12
  'business_logo',
13
13
  'identity_document',
14
14
  'additional_verification',
15
+ 'finance_report_run',
16
+ ];
17
+ /**
18
+ * The purposes a merchant may upload or import. `finance_report_run` is not
19
+ * among them: a report's CSV is written by Peable's report runs
20
+ * (`/v1/reporting/report_runs`) and nobody else, so a file of that purpose is
21
+ * always a report Peable produced.
22
+ */
23
+ export const FILE_UPLOAD_PURPOSES = [
24
+ 'dispute_evidence',
25
+ 'business_logo',
26
+ 'identity_document',
27
+ 'additional_verification',
15
28
  ];
16
29
  /** The stored format, by its conventional extension (Stripe's `type`). */
17
- export const FILE_TYPES = ['pdf', 'png', 'jpg'];
30
+ export const FILE_TYPES = ['pdf', 'png', 'jpg', 'csv'];
18
31
  /**
19
32
  * Whether the bytes can be used right now.
20
33
  *
@@ -26,16 +39,18 @@ export const FILE_TYPES = ['pdf', 'png', 'jpg'];
26
39
  */
27
40
  export const FILE_STATUSES = ['available', 'withheld', 'removed'];
28
41
  /**
29
- * The upload policy of each purpose: the formats it takes, recognised from the
30
- * bytes and never from a client's `Content-Type`, and the largest file.
42
+ * The policy of each purpose: the formats it takes, recognised from the bytes
43
+ * and never from a client's `Content-Type`, and the largest file.
31
44
  *
32
45
  * The provider's own ceilings, restated where the upload is parsed, so a file
33
46
  * the card network would refuse is refused at upload — not at the one-shot
34
- * dispute submission it was meant for.
47
+ * dispute submission it was meant for. `finance_report_run` is Peable's own
48
+ * output (see {@link FILE_UPLOAD_PURPOSES}); its ceiling bounds a report.
35
49
  */
36
50
  export const FILE_PURPOSE_POLICIES = Object.freeze({
37
51
  dispute_evidence: { types: ['pdf', 'png', 'jpg'], max_bytes: 5 * 1024 * 1024 },
38
52
  business_logo: { types: ['png', 'jpg'], max_bytes: 512 * 1024 },
39
53
  identity_document: { types: ['pdf', 'png', 'jpg'], max_bytes: 10 * 1024 * 1024 },
40
54
  additional_verification: { types: ['pdf', 'png', 'jpg'], max_bytes: 10 * 1024 * 1024 },
55
+ finance_report_run: { types: ['csv'], max_bytes: 64 * 1024 * 1024 },
41
56
  });
package/dist/esm/index.js CHANGED
@@ -6,7 +6,9 @@ export { PEABLE_API_VERSION, } from './event.js';
6
6
  export { WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_ENDPOINT_DISABLED_REASONS, WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT, WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS, } from './webhookEndpoint.js';
7
7
  export { PRICE_BILLING_SCHEMES, PRICE_TIERS_MODES, PRICE_TYPES, RECURRING_INTERVALS, RECURRING_USAGE_TYPES, PRICE_TAX_BEHAVIORS, TRANSFORM_QUANTITY_ROUNDS, COUPON_DURATIONS, CATALOG_LIMITS, } from './catalog.js';
8
8
  export { DISPUTE_FILE_EVIDENCE_FIELDS, DISPUTE_REASONS, DISPUTE_TEXT_EVIDENCE_FIELDS, normalizeDisputeReason, } from './dispute.js';
9
- export { FILE_PURPOSES, FILE_PURPOSE_POLICIES, FILE_STATUSES, FILE_TYPES, } from './file.js';
9
+ export { FILE_PURPOSES, FILE_PURPOSE_POLICIES, FILE_UPLOAD_PURPOSES, FILE_STATUSES, FILE_TYPES, } from './file.js';
10
+ export { SEARCHABLE_RESOURCES, SEARCH_QUERY_MAX_CLAUSES, SEARCH_QUERY_MAX_LENGTH, SEARCH_SUBSTRING_MIN_LENGTH, } from './search.js';
11
+ export { REPORT_RUN_STATUSES, REPORT_TYPE_IDS, REPORT_TYPE_LAYOUTS, } from './reporting.js';
10
12
  export { CARD_RAIL_PAYMENT_METHOD_TYPES, PAYMENT_METHOD_CONFIGURATION_TYPES, PAYMENT_METHOD_CURRENCIES, } from './paymentMethodConfiguration.js';
11
13
  export { PAYOUT_INTERVALS, PAYOUT_WEEKLY_ANCHORS, } from './account.js';
12
14
  export { BALANCE_TRANSACTION_STATUSES, BALANCE_TRANSACTION_TYPES, PAYOUT_STATUSES, RECONCILIATION_MISMATCH_KINDS, } from './balance.js';
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Every report Peable produces, by Stripe's versioned id: the trailing `.1` is
3
+ * the column layout's version, so a layout can change under a new id without
4
+ * changing a report a merchant already parses.
5
+ */
6
+ export const REPORT_TYPE_IDS = [
7
+ 'payments.itemized.1',
8
+ 'balance.summary.1',
9
+ 'payouts.itemized.1',
10
+ ];
11
+ /**
12
+ * The layout of each report: its name, every column it can carry and the ones
13
+ * it carries when `parameters.columns` is absent. Fixed per version.
14
+ *
15
+ * - `payments.itemized.1` — one row per payment intent CREATED in the
16
+ * interval. Amounts are base-unit strings, as on the API.
17
+ * - `balance.summary.1` — per currency, the balance at `interval_start`, the
18
+ * activity and payouts inside the interval, and the balance at
19
+ * `interval_end`, from the ledger (ADR 0015). A figure built on a transaction
20
+ * whose fee the provider has not reported is empty, never `0`.
21
+ * - `payouts.itemized.1` — one row per payout created in the interval.
22
+ */
23
+ export const REPORT_TYPE_LAYOUTS = Object.freeze({
24
+ 'payments.itemized.1': {
25
+ name: 'Itemized payments',
26
+ columns: [
27
+ 'payment_intent_id',
28
+ 'created_utc',
29
+ 'status',
30
+ 'rail',
31
+ 'currency',
32
+ 'amount',
33
+ 'amount_received',
34
+ 'amount_refunded',
35
+ 'customer_id',
36
+ 'charge_id',
37
+ 'capture_method',
38
+ 'description',
39
+ 'receipt_email',
40
+ 'cancellation_reason',
41
+ 'canceled_at_utc',
42
+ ],
43
+ default_columns: [
44
+ 'payment_intent_id',
45
+ 'created_utc',
46
+ 'status',
47
+ 'currency',
48
+ 'amount',
49
+ 'amount_received',
50
+ 'amount_refunded',
51
+ 'customer_id',
52
+ ],
53
+ ledger: false,
54
+ },
55
+ 'balance.summary.1': {
56
+ name: 'Balance summary',
57
+ columns: ['category', 'description', 'currency', 'net_amount', 'transaction_count'],
58
+ default_columns: ['category', 'description', 'currency', 'net_amount'],
59
+ ledger: true,
60
+ },
61
+ 'payouts.itemized.1': {
62
+ name: 'Itemized payouts',
63
+ columns: [
64
+ 'payout_id',
65
+ 'created_utc',
66
+ 'arrival_date_utc',
67
+ 'status',
68
+ 'currency',
69
+ 'amount',
70
+ 'method',
71
+ 'type',
72
+ 'automatic',
73
+ 'description',
74
+ 'statement_descriptor',
75
+ 'failure_code',
76
+ ],
77
+ default_columns: [
78
+ 'payout_id',
79
+ 'created_utc',
80
+ 'arrival_date_utc',
81
+ 'status',
82
+ 'currency',
83
+ 'amount',
84
+ 'automatic',
85
+ ],
86
+ ledger: true,
87
+ },
88
+ });
89
+ export const REPORT_RUN_STATUSES = ['pending', 'succeeded', 'failed'];
@@ -0,0 +1,15 @@
1
+ // The search contract (Stripe's Search API): `GET /v1/<objects>/search?query=…`.
2
+ /** Every searchable resource, by its path segment (`/v1/<resource>/search`). */
3
+ export const SEARCHABLE_RESOURCES = [
4
+ 'payment_intents',
5
+ 'charges',
6
+ 'customers',
7
+ 'products',
8
+ 'prices',
9
+ 'refunds',
10
+ ];
11
+ /** Search query bounds — the gateway's, restated so a client can check before it asks. */
12
+ export const SEARCH_QUERY_MAX_LENGTH = 1000;
13
+ export const SEARCH_QUERY_MAX_CLAUSES = 10;
14
+ /** A `~` substring needs at least this many characters (Stripe's rule). */
15
+ export const SEARCH_SUBSTRING_MIN_LENGTH = 3;
@@ -1,5 +1,6 @@
1
1
  import type { CurrencyCode } from './money';
2
2
  import type { PaymentIntent } from './paymentIntent';
3
+ import type { BillingDetails } from './paymentMethod';
3
4
  /** Card details safe to show: never the number, never the CVC. */
4
5
  export interface CardDetails {
5
6
  brand: string | null;
@@ -41,6 +42,11 @@ export interface Charge {
41
42
  refunded: boolean;
42
43
  disputed: boolean;
43
44
  outcome: ChargeOutcome | null;
45
+ /**
46
+ * Who the card's billing details name, as the provider reported them for this
47
+ * charge — `null` until the provider snapshot is read (as `outcome`).
48
+ */
49
+ billing_details: BillingDetails | null;
44
50
  payment_method_details: {
45
51
  type: 'card';
46
52
  card: CardDetails;
@@ -8,6 +8,7 @@ import type { Dispute } from './dispute';
8
8
  import type { PaymentIntent } from './paymentIntent';
9
9
  import type { PaymentLink } from './paymentLink';
10
10
  import type { PaymentMethod } from './paymentMethod';
11
+ import type { ReportRun } from './reporting';
11
12
  import type { ConnectedAccount, Refund } from './settlement';
12
13
  import type { SetupIntent } from './setupIntent';
13
14
  import type { WebhookEndpoint } from './webhookEndpoint';
@@ -140,6 +141,10 @@ export interface WebhookEventPayload {
140
141
  'payout.canceled': Payout;
141
142
  /** Funds became available in the account; carries the balance read from the ledger. */
142
143
  'balance.available': Balance;
144
+ /** A report run finished: its CSV is `result` (a `finance_report_run` file). */
145
+ 'reporting.report_run.succeeded': ReportRun;
146
+ /** A report run could not be produced; `error` says why. */
147
+ 'reporting.report_run.failed': ReportRun;
143
148
  'billing.observation.updated': BillingObservation;
144
149
  /**
145
150
  * A synthetic event sent to ONE endpoint when its owner asks to test it
@@ -4,10 +4,18 @@
4
4
  * reference the file — a `business_logo` is public, a `dispute_evidence` file
5
5
  * is private and can only be attached to the merchant's own disputes.
6
6
  */
7
- export declare const FILE_PURPOSES: readonly ["dispute_evidence", "business_logo", "identity_document", "additional_verification"];
7
+ export declare const FILE_PURPOSES: readonly ["dispute_evidence", "business_logo", "identity_document", "additional_verification", "finance_report_run"];
8
8
  export type FilePurpose = (typeof FILE_PURPOSES)[number];
9
+ /**
10
+ * The purposes a merchant may upload or import. `finance_report_run` is not
11
+ * among them: a report's CSV is written by Peable's report runs
12
+ * (`/v1/reporting/report_runs`) and nobody else, so a file of that purpose is
13
+ * always a report Peable produced.
14
+ */
15
+ export declare const FILE_UPLOAD_PURPOSES: readonly ["dispute_evidence", "business_logo", "identity_document", "additional_verification"];
16
+ export type FileUploadPurpose = (typeof FILE_UPLOAD_PURPOSES)[number];
9
17
  /** The stored format, by its conventional extension (Stripe's `type`). */
10
- export declare const FILE_TYPES: readonly ["pdf", "png", "jpg"];
18
+ export declare const FILE_TYPES: readonly ["pdf", "png", "jpg", "csv"];
11
19
  export type FileType = (typeof FILE_TYPES)[number];
12
20
  /**
13
21
  * Whether the bytes can be used right now.
@@ -21,12 +29,13 @@ export type FileType = (typeof FILE_TYPES)[number];
21
29
  export declare const FILE_STATUSES: readonly ["available", "withheld", "removed"];
22
30
  export type FileStatus = (typeof FILE_STATUSES)[number];
23
31
  /**
24
- * The upload policy of each purpose: the formats it takes, recognised from the
25
- * bytes and never from a client's `Content-Type`, and the largest file.
32
+ * The policy of each purpose: the formats it takes, recognised from the bytes
33
+ * and never from a client's `Content-Type`, and the largest file.
26
34
  *
27
35
  * The provider's own ceilings, restated where the upload is parsed, so a file
28
36
  * the card network would refuse is refused at upload — not at the one-shot
29
- * dispute submission it was meant for.
37
+ * dispute submission it was meant for. `finance_report_run` is Peable's own
38
+ * output (see {@link FILE_UPLOAD_PURPOSES}); its ceiling bounds a report.
30
39
  */
31
40
  export declare const FILE_PURPOSE_POLICIES: Readonly<Record<FilePurpose, {
32
41
  readonly types: readonly FileType[];
@@ -50,10 +59,16 @@ export interface FileObject {
50
59
  type: FileType;
51
60
  status: FileStatus;
52
61
  /**
53
- * A public URL for a `business_logo` that is `available` — what a payer
54
- * surface renders. `null` for every other purpose: evidence and identity
55
- * documents are never addressable by URL, and their bytes leave Peable only
56
- * to the provider they are submitted to.
62
+ * Where the bytes can be read, while the file is `available`:
63
+ *
64
+ * - a `business_logo`: a PUBLIC URL — what a payer surface renders;
65
+ * - a `finance_report_run`: the gateway's `GET /v1/files/:id/contents`,
66
+ * which answers the CSV to the merchant's own credential (Stripe's
67
+ * `files.stripe.com/v1/files/:id/contents`).
68
+ *
69
+ * `null` for every other purpose: evidence and identity documents are never
70
+ * addressable by URL, and their bytes leave Peable only to the provider they
71
+ * are submitted to.
57
72
  */
58
73
  url: string | null;
59
74
  created: number;
@@ -68,7 +83,7 @@ export interface FileObject {
68
83
  * checked once, here, and never again.
69
84
  */
70
85
  export interface CreateFileFromOxyParams {
71
- purpose: FilePurpose;
86
+ purpose: FileUploadPurpose;
72
87
  /** Oxy file id. */
73
88
  oxy_file: string;
74
89
  }
@@ -10,7 +10,9 @@ export { PEABLE_API_VERSION, type WebhookEventType, type WebhookEvent, type Webh
10
10
  export { WEBHOOK_ENDPOINT_STATUSES, WEBHOOK_ENDPOINT_DISABLED_REASONS, WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT, WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS, type WebhookEnabledEvent, type WebhookEndpoint, type WebhookEndpointStatus, type WebhookEndpointDisabledReason, type DeletedWebhookEndpoint, type CreateWebhookEndpointParams, type UpdateWebhookEndpointParams, type RollWebhookEndpointSecretParams, } from './webhookEndpoint';
11
11
  export { PRICE_BILLING_SCHEMES, PRICE_TIERS_MODES, PRICE_TYPES, RECURRING_INTERVALS, RECURRING_USAGE_TYPES, PRICE_TAX_BEHAVIORS, TRANSFORM_QUANTITY_ROUNDS, COUPON_DURATIONS, CATALOG_LIMITS, type PriceBillingScheme, type PriceTiersMode, type PriceType, type RecurringInterval, type RecurringUsageType, type PriceTaxBehavior, type TransformQuantityRound, type CouponDuration, type ProductMarketingFeature, type Product, type DeletedProduct, type PriceTier, type PriceTransformQuantity, type PriceRecurring, type Price, type Coupon, type DeletedCoupon, type PromotionCodeRestrictions, type PromotionCode, type RecurringParams, type PriceTierParams, type PriceDataParams, type DefaultPriceDataParams, type CreateProductParams, type UpdateProductParams, type ProductListParams, type CreatePriceParams, type UpdatePriceParams, type PriceListParams, type CreateCouponParams, type UpdateCouponParams, type CouponListParams, type CreatePromotionCodeParams, type UpdatePromotionCodeParams, type PromotionCodeListParams, } from './catalog';
12
12
  export { DISPUTE_FILE_EVIDENCE_FIELDS, DISPUTE_REASONS, DISPUTE_TEXT_EVIDENCE_FIELDS, normalizeDisputeReason, type Dispute, type DisputeEvidence, type DisputeEvidenceDetails, type DisputeEvidenceField, type DisputeEvidenceParams, type DisputeFileEvidenceField, type DisputeReason, type DisputeStatus, type DisputeTextEvidenceField, type ListDisputesParams, type UpdateDisputeParams, } from './dispute';
13
- export { FILE_PURPOSES, FILE_PURPOSE_POLICIES, FILE_STATUSES, FILE_TYPES, type CreateFileFromOxyParams, type FileObject, type FilePurpose, type FileStatus, type FileType, type ListFilesParams, } from './file';
13
+ export { FILE_PURPOSES, FILE_PURPOSE_POLICIES, FILE_UPLOAD_PURPOSES, FILE_STATUSES, FILE_TYPES, type CreateFileFromOxyParams, type FileObject, type FilePurpose, type FileStatus, type FileType, type FileUploadPurpose, type ListFilesParams, } from './file';
14
+ export { SEARCHABLE_RESOURCES, SEARCH_QUERY_MAX_CLAUSES, SEARCH_QUERY_MAX_LENGTH, SEARCH_SUBSTRING_MIN_LENGTH, type SearchParams, type SearchResult, type SearchableResource, } from './search';
15
+ export { REPORT_RUN_STATUSES, REPORT_TYPE_IDS, REPORT_TYPE_LAYOUTS, type CreateReportRunParams, type ListReportRunsParams, type ReportRun, type ReportRunParameters, type ReportRunStatus, type ReportType, type ReportTypeId, } from './reporting';
14
16
  export { CARD_RAIL_PAYMENT_METHOD_TYPES, PAYMENT_METHOD_CONFIGURATION_TYPES, PAYMENT_METHOD_CURRENCIES, type CardRailPaymentMethodType, type CreatePaymentMethodConfigurationParams, type CreatePaymentMethodDomainParams, type ListPaymentMethodDomainsParams, type PaymentMethodConfiguration, type PaymentMethodConfigurationEntry, type PaymentMethodConfigurationEntryParams, type PaymentMethodConfigurationType, type PaymentMethodDisplayPreference, type PaymentMethodDomain, type PaymentMethodDomainWalletStatus, type PaymentMethodUnavailableReason, type UpdatePaymentMethodConfigurationParams, type UpdatePaymentMethodDomainParams, } from './paymentMethodConfiguration';
15
17
  export { PAYOUT_INTERVALS, PAYOUT_WEEKLY_ANCHORS, type Account, type AccountBusinessProfile, type AccountCapabilityStatus, type AccountPayoutSchedule, type AccountRequirements, type AccountSettings, type AccountType, type CreateAccountLinkParams, type PayoutInterval, type PayoutWeeklyAnchor, type UpdateAccountParams, } from './account';
16
18
  export { BALANCE_TRANSACTION_STATUSES, BALANCE_TRANSACTION_TYPES, PAYOUT_STATUSES, RECONCILIATION_MISMATCH_KINDS, type ApplicationFee, type Balance, type BalanceAmount, type BalanceTransaction, type BalanceTransactionFeeDetail, type BalanceTransactionStatus, type BalanceTransactionType, type CreatePayoutParams, type FeeRefund, type ListBalanceTransactionsParams, type ListPayoutsParams, type Payout, type PayoutReconciliationReport, type PayoutStatus, type ReconciliationMismatch, type ReconciliationMismatchKind, } from './balance';
@@ -0,0 +1,84 @@
1
+ import type { CurrencyCode } from './money';
2
+ import type { FileObject } from './file';
3
+ /**
4
+ * Every report Peable produces, by Stripe's versioned id: the trailing `.1` is
5
+ * the column layout's version, so a layout can change under a new id without
6
+ * changing a report a merchant already parses.
7
+ */
8
+ export declare const REPORT_TYPE_IDS: readonly ["payments.itemized.1", "balance.summary.1", "payouts.itemized.1"];
9
+ export type ReportTypeId = (typeof REPORT_TYPE_IDS)[number];
10
+ /**
11
+ * The layout of each report: its name, every column it can carry and the ones
12
+ * it carries when `parameters.columns` is absent. Fixed per version.
13
+ *
14
+ * - `payments.itemized.1` — one row per payment intent CREATED in the
15
+ * interval. Amounts are base-unit strings, as on the API.
16
+ * - `balance.summary.1` — per currency, the balance at `interval_start`, the
17
+ * activity and payouts inside the interval, and the balance at
18
+ * `interval_end`, from the ledger (ADR 0015). A figure built on a transaction
19
+ * whose fee the provider has not reported is empty, never `0`.
20
+ * - `payouts.itemized.1` — one row per payout created in the interval.
21
+ */
22
+ export declare const REPORT_TYPE_LAYOUTS: Readonly<Record<ReportTypeId, {
23
+ readonly name: string;
24
+ readonly columns: readonly string[];
25
+ readonly default_columns: readonly string[];
26
+ /** Whether the report reads the ledger, and so needs the merchant's account. */
27
+ readonly ledger: boolean;
28
+ }>>;
29
+ /** `reporting.report_type` — what can be run, and over which interval data exists. */
30
+ export interface ReportType {
31
+ /** `payments.itemized.1`, … */
32
+ id: ReportTypeId;
33
+ object: 'reporting.report_type';
34
+ livemode: boolean;
35
+ name: string;
36
+ /** The column layout's version — the trailing number of the id. */
37
+ version: number;
38
+ /** Every column `parameters.columns` may name, in the order they are written. */
39
+ columns: string[];
40
+ default_columns: string[];
41
+ /** The earliest `interval_start` with data (Unix seconds). */
42
+ data_available_start: number;
43
+ /** The latest `interval_end` a run may ask for: now — the data is live. */
44
+ data_available_end: number;
45
+ /** When the layout last changed. */
46
+ updated: number;
47
+ }
48
+ export declare const REPORT_RUN_STATUSES: readonly ["pending", "succeeded", "failed"];
49
+ export type ReportRunStatus = (typeof REPORT_RUN_STATUSES)[number];
50
+ /** What a run was asked to cover. */
51
+ export interface ReportRunParameters {
52
+ /** Inclusive, Unix seconds. */
53
+ interval_start: number;
54
+ /** Exclusive, Unix seconds. */
55
+ interval_end: number;
56
+ /** The columns, in the layout's order; the report type's `default_columns` when absent. */
57
+ columns?: string[];
58
+ /** Only this currency. */
59
+ currency?: CurrencyCode;
60
+ }
61
+ /** `reporting.report_run` (`frr_…`). */
62
+ export interface ReportRun {
63
+ id: string;
64
+ object: 'reporting.report_run';
65
+ livemode: boolean;
66
+ created: number;
67
+ report_type: ReportTypeId;
68
+ parameters: ReportRunParameters;
69
+ status: ReportRunStatus;
70
+ /** Why a `failed` run failed; `null` otherwise. */
71
+ error: string | null;
72
+ /** The CSV once `succeeded` — a `file_…` of purpose `finance_report_run`. */
73
+ result: FileObject | null;
74
+ succeeded_at: number | null;
75
+ }
76
+ /** `POST /v1/reporting/report_runs`. */
77
+ export interface CreateReportRunParams {
78
+ report_type: ReportTypeId;
79
+ parameters: ReportRunParameters;
80
+ }
81
+ /** `GET /v1/reporting/report_runs`. */
82
+ export interface ListReportRunsParams {
83
+ report_type?: ReportTypeId;
84
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * One page of a search.
3
+ *
4
+ * Unlike a {@link List} it pages FORWARD only, by an opaque `next_page` token
5
+ * passed back as `page`: a search is a filter over the newest-first walk of the
6
+ * resource, and the token remembers both where the walk stopped and which
7
+ * query it belongs to (a token used with another query is refused).
8
+ */
9
+ export interface SearchResult<T> {
10
+ object: 'search_result';
11
+ data: T[];
12
+ has_more: boolean;
13
+ /** Pass as `page` for the next page; `null` on the last one. */
14
+ next_page: string | null;
15
+ /** The path that was searched (`/v1/customers/search`). */
16
+ url: string;
17
+ /** Present only when asked for with `expand: ['total_count']`. */
18
+ total_count?: number;
19
+ }
20
+ /** The parameters every search accepts. */
21
+ export interface SearchParams {
22
+ /**
23
+ * The query, in Stripe's search query language:
24
+ * `email:"jenny@example.com"`, `amount>1000 AND currency:"EUR"`,
25
+ * `metadata['order_id']:'6735'`, `name~"shirt"`, `-status:"canceled"`,
26
+ * `customer:null`. Clauses join with spaces or `AND` (all of them must
27
+ * match) or with `OR` (any), never both; at most 10 clauses and 1000
28
+ * characters.
29
+ */
30
+ query: string;
31
+ /** 1–100. Default 10. */
32
+ limit?: number;
33
+ /** The `next_page` of the previous page, with the SAME query. */
34
+ page?: string;
35
+ /**
36
+ * `data.`-prefixed expansions (`['data.customer']`), and `'total_count'` to
37
+ * count every match (one extra query).
38
+ */
39
+ expand?: string[];
40
+ }
41
+ /** Every searchable resource, by its path segment (`/v1/<resource>/search`). */
42
+ export declare const SEARCHABLE_RESOURCES: readonly ["payment_intents", "charges", "customers", "products", "prices", "refunds"];
43
+ export type SearchableResource = (typeof SEARCHABLE_RESOURCES)[number];
44
+ /** Search query bounds — the gateway's, restated so a client can check before it asks. */
45
+ export declare const SEARCH_QUERY_MAX_LENGTH = 1000;
46
+ export declare const SEARCH_QUERY_MAX_CLAUSES = 10;
47
+ /** A `~` substring needs at least this many characters (Stripe's rule). */
48
+ export declare const SEARCH_SUBSTRING_MIN_LENGTH = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peable.to/shared-types",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Shared TypeScript types for the Peable Gateway — the wire contract shared by the backend, SDK, and frontend.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",