@blocklet/payment-types 1.13.113

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,110 @@
1
+ import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
2
+ import type { LiteralUnion } from 'type-fest';
3
+ import type { SubscriptionSchedulePhase } from './types';
4
+ export declare class SubscriptionSchedule extends Model<InferAttributes<SubscriptionSchedule>, InferCreationAttributes<SubscriptionSchedule>> {
5
+ id: CreationOptional<string>;
6
+ livemode: boolean;
7
+ current_phase: {
8
+ end_date: Date;
9
+ start_date: Date;
10
+ };
11
+ customer_id: string;
12
+ subscription_id: string;
13
+ metadata: Record<string, any>;
14
+ status: LiteralUnion<'active' | 'canceled' | 'completed' | 'not_started' | 'released', string>;
15
+ phases?: SubscriptionSchedulePhase[];
16
+ default_settings?: {
17
+ billing_cycle_anchor: LiteralUnion<'phase_start' | 'automatic', string>;
18
+ billing_thresholds: {
19
+ amount_gte: number;
20
+ reset_billing_cycle_anchor: boolean;
21
+ };
22
+ collection_method: LiteralUnion<'charge_automatically' | 'send_invoice', string>;
23
+ default_payment_method: string;
24
+ description: string;
25
+ invoice_settings: {
26
+ days_until_due: number;
27
+ };
28
+ };
29
+ end_behavior: LiteralUnion<'cancel' | 'release', string>;
30
+ released_subscription_id?: string;
31
+ test_clock_id?: string;
32
+ canceled_at: number;
33
+ completed_at: number;
34
+ released_at: number;
35
+ created_at: CreationOptional<Date>;
36
+ updated_at: CreationOptional<Date>;
37
+ static readonly GENESIS_ATTRIBUTES: {
38
+ id: {
39
+ type: DataTypes.StringDataType;
40
+ primaryKey: boolean;
41
+ allowNull: boolean;
42
+ defaultValue: (size?: number | undefined) => string;
43
+ };
44
+ livemode: {
45
+ type: DataTypes.AbstractDataTypeConstructor;
46
+ allowNull: boolean;
47
+ };
48
+ current_phase: {
49
+ type: DataTypes.AbstractDataTypeConstructor;
50
+ allowNull: boolean;
51
+ };
52
+ customer_id: {
53
+ type: DataTypes.StringDataType;
54
+ allowNull: boolean;
55
+ };
56
+ subscription_id: {
57
+ type: DataTypes.StringDataType;
58
+ allowNull: boolean;
59
+ };
60
+ released_subscription_id: {
61
+ type: DataTypes.StringDataType;
62
+ allowNull: boolean;
63
+ };
64
+ status: {
65
+ type: DataTypes.EnumDataType<"active" | "canceled" | "completed" | "not_started" | "released">;
66
+ allowNull: boolean;
67
+ };
68
+ default_settings: {
69
+ type: DataTypes.AbstractDataTypeConstructor;
70
+ allowNull: boolean;
71
+ };
72
+ end_behavior: {
73
+ type: DataTypes.EnumDataType<"cancel" | "release">;
74
+ allowNull: boolean;
75
+ };
76
+ test_clock_id: {
77
+ type: DataTypes.StringDataType;
78
+ allowNull: boolean;
79
+ };
80
+ metadata: {
81
+ type: DataTypes.AbstractDataTypeConstructor;
82
+ allowNull: boolean;
83
+ };
84
+ canceled_at: {
85
+ type: DataTypes.IntegerDataTypeConstructor;
86
+ allowNull: boolean;
87
+ };
88
+ completed_at: {
89
+ type: DataTypes.IntegerDataTypeConstructor;
90
+ allowNull: boolean;
91
+ };
92
+ released_at: {
93
+ type: DataTypes.IntegerDataTypeConstructor;
94
+ allowNull: boolean;
95
+ };
96
+ created_at: {
97
+ type: DataTypes.DateDataTypeConstructor;
98
+ defaultValue: DataTypes.AbstractDataTypeConstructor;
99
+ allowNull: boolean;
100
+ };
101
+ updated_at: {
102
+ type: DataTypes.DateDataTypeConstructor;
103
+ defaultValue: DataTypes.AbstractDataTypeConstructor;
104
+ allowNull: boolean;
105
+ };
106
+ };
107
+ static initialize(sequelize: any): void;
108
+ static associate(models: any): void;
109
+ }
110
+ export type TSubscriptionSchedule = InferAttributes<SubscriptionSchedule>;
@@ -0,0 +1,216 @@
1
+ import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
2
+ import type { LiteralUnion } from 'type-fest';
3
+ import type { PaymentDetails, PaymentSettings, PriceRecurring } from './types';
4
+ export declare const nextSubscriptionId: (size?: number | undefined) => string;
5
+ export declare class Subscription extends Model<InferAttributes<Subscription>, InferCreationAttributes<Subscription>> {
6
+ id: CreationOptional<string>;
7
+ livemode: boolean;
8
+ currency_id: string;
9
+ customer_id: string;
10
+ current_period_end: number;
11
+ current_period_start: number;
12
+ default_payment_method_id: string;
13
+ description?: string;
14
+ latest_invoice_id?: string;
15
+ metadata: Record<string, any>;
16
+ pending_setup_intent?: string;
17
+ pending_update?: {
18
+ billing_cycle_anchor?: number;
19
+ expires_at?: number;
20
+ subscription_items?: any[];
21
+ trial_end?: number;
22
+ };
23
+ status: LiteralUnion<'active' | 'past_due' | 'paused' | 'canceled' | 'incomplete' | 'incomplete_expired' | 'trialing', string>;
24
+ cancel_at_period_end: boolean;
25
+ cancel_at: CreationOptional<number>;
26
+ canceled_at: CreationOptional<number>;
27
+ cancelation_details?: {
28
+ comment: string;
29
+ feedback: LiteralUnion<'too_expensive' | 'missing_features' | 'switched_service' | 'unused' | 'customer_service' | 'too_complex' | 'low_quality' | 'other', string>;
30
+ reason: LiteralUnion<'cancellation_requested' | 'payment_disputed' | 'payment_failed', string>;
31
+ };
32
+ billing_cycle_anchor: number;
33
+ billing_thresholds?: {
34
+ amount_gte: number;
35
+ reset_billing_cycle_anchor: boolean;
36
+ };
37
+ collection_method: LiteralUnion<'charge_automatically' | 'send_invoice', string>;
38
+ days_until_due?: number;
39
+ discount_id?: string;
40
+ next_pending_invoice_item_invoice?: number;
41
+ pause_collection?: {
42
+ behavior: LiteralUnion<'keep_as_draft' | 'mark_uncollectible' | 'void', string>;
43
+ resumes_at: number;
44
+ };
45
+ payment_settings?: PaymentSettings;
46
+ pending_invoice_item_interval: PriceRecurring;
47
+ schedule_id?: string;
48
+ ended_at?: number;
49
+ start_date: number;
50
+ trail_end?: number;
51
+ trail_start?: number;
52
+ trail_settings?: {
53
+ end_behavior: {
54
+ missing_payment_method: LiteralUnion<'cancel' | 'pause' | 'create_invoice', string>;
55
+ };
56
+ };
57
+ payment_details?: PaymentDetails;
58
+ proration_behavior?: LiteralUnion<'always_invoice' | 'create_prorations' | 'none', string>;
59
+ payment_behavior?: LiteralUnion<'allow_incomplete' | 'error_if_incomplete' | 'pending_if_incomplete', string>;
60
+ created_at: CreationOptional<Date>;
61
+ updated_at: CreationOptional<Date>;
62
+ static readonly GENESIS_ATTRIBUTES: {
63
+ id: {
64
+ type: DataTypes.StringDataType;
65
+ primaryKey: boolean;
66
+ allowNull: boolean;
67
+ defaultValue: (size?: number | undefined) => string;
68
+ };
69
+ livemode: {
70
+ type: DataTypes.AbstractDataTypeConstructor;
71
+ allowNull: boolean;
72
+ };
73
+ currency_id: {
74
+ type: DataTypes.StringDataType;
75
+ allowNull: boolean;
76
+ };
77
+ customer_id: {
78
+ type: DataTypes.StringDataType;
79
+ allowNull: boolean;
80
+ };
81
+ cancel_at_period_end: {
82
+ type: DataTypes.AbstractDataTypeConstructor;
83
+ allowNull: boolean;
84
+ };
85
+ current_period_end: {
86
+ type: DataTypes.IntegerDataTypeConstructor;
87
+ allowNull: boolean;
88
+ };
89
+ current_period_start: {
90
+ type: DataTypes.IntegerDataTypeConstructor;
91
+ allowNull: boolean;
92
+ };
93
+ default_payment_method_id: {
94
+ type: DataTypes.StringDataType;
95
+ allowNull: boolean;
96
+ };
97
+ description: {
98
+ type: DataTypes.StringDataType;
99
+ allowNull: boolean;
100
+ };
101
+ latest_invoice_id: {
102
+ type: DataTypes.StringDataType;
103
+ allowNull: boolean;
104
+ };
105
+ pending_setup_intent: {
106
+ type: DataTypes.StringDataType;
107
+ allowNull: boolean;
108
+ };
109
+ pending_update: {
110
+ type: DataTypes.AbstractDataTypeConstructor;
111
+ allowNull: boolean;
112
+ };
113
+ status: {
114
+ type: DataTypes.EnumDataType<"active" | "canceled" | "past_due" | "paused" | "incomplete" | "incomplete_expired" | "trialing">;
115
+ allowNull: boolean;
116
+ };
117
+ cancel_at: {
118
+ type: DataTypes.IntegerDataTypeConstructor;
119
+ allowNull: boolean;
120
+ };
121
+ canceled_at: {
122
+ type: DataTypes.IntegerDataTypeConstructor;
123
+ allowNull: boolean;
124
+ };
125
+ cancelation_details: {
126
+ type: DataTypes.AbstractDataTypeConstructor;
127
+ allowNull: boolean;
128
+ };
129
+ billing_cycle_anchor: {
130
+ type: DataTypes.IntegerDataTypeConstructor;
131
+ allowNull: boolean;
132
+ };
133
+ billing_thresholds: {
134
+ type: DataTypes.AbstractDataTypeConstructor;
135
+ allowNull: boolean;
136
+ };
137
+ collection_method: {
138
+ type: DataTypes.EnumDataType<"charge_automatically" | "send_invoice">;
139
+ allowNull: boolean;
140
+ };
141
+ days_until_due: {
142
+ type: DataTypes.NumberDataTypeConstructor;
143
+ allowNull: boolean;
144
+ };
145
+ discount_id: {
146
+ type: DataTypes.StringDataType;
147
+ allowNull: boolean;
148
+ };
149
+ next_pending_invoice_item_invoice_id: {
150
+ type: DataTypes.StringDataType;
151
+ allowNull: boolean;
152
+ };
153
+ pause_collection: {
154
+ type: DataTypes.AbstractDataTypeConstructor;
155
+ allowNull: boolean;
156
+ };
157
+ payment_settings: {
158
+ type: DataTypes.AbstractDataTypeConstructor;
159
+ allowNull: boolean;
160
+ };
161
+ pending_invoice_item_interval: {
162
+ type: DataTypes.AbstractDataTypeConstructor;
163
+ allowNull: boolean;
164
+ };
165
+ schedule_id: {
166
+ type: DataTypes.StringDataType;
167
+ allowNull: boolean;
168
+ };
169
+ end_at: {
170
+ type: DataTypes.IntegerDataTypeConstructor;
171
+ allowNull: boolean;
172
+ };
173
+ start_date: {
174
+ type: DataTypes.IntegerDataTypeConstructor;
175
+ allowNull: boolean;
176
+ };
177
+ trail_end: {
178
+ type: DataTypes.IntegerDataTypeConstructor;
179
+ allowNull: boolean;
180
+ };
181
+ trail_start: {
182
+ type: DataTypes.IntegerDataTypeConstructor;
183
+ allowNull: boolean;
184
+ };
185
+ trail_settings: {
186
+ type: DataTypes.AbstractDataTypeConstructor;
187
+ allowNull: boolean;
188
+ };
189
+ payment_details: {
190
+ type: DataTypes.AbstractDataTypeConstructor;
191
+ allowNull: boolean;
192
+ };
193
+ metadata: {
194
+ type: DataTypes.AbstractDataTypeConstructor;
195
+ allowNull: boolean;
196
+ };
197
+ created_at: {
198
+ type: DataTypes.DateDataTypeConstructor;
199
+ defaultValue: DataTypes.AbstractDataTypeConstructor;
200
+ allowNull: boolean;
201
+ };
202
+ updated_at: {
203
+ type: DataTypes.DateDataTypeConstructor;
204
+ defaultValue: DataTypes.AbstractDataTypeConstructor;
205
+ allowNull: boolean;
206
+ };
207
+ };
208
+ static initialize(sequelize: any): void;
209
+ static associate(models: any): void;
210
+ isImmutable(): boolean;
211
+ isActive(): boolean;
212
+ isScheduledToCancel(): boolean;
213
+ start(): Promise<void>;
214
+ }
215
+ export type TSubscription = InferAttributes<Subscription>;
216
+ export declare function getSubscriptionEventType(current: TSubscription, previous: Partial<TSubscription>): "" | "paused" | "resumed";
package/lib/types.d.ts ADDED
@@ -0,0 +1,285 @@
1
+ import type { LiteralUnion } from 'type-fest';
2
+ export type Pagination<T = any> = T & {
3
+ page?: number;
4
+ pageSize?: number;
5
+ limit?: number;
6
+ starting_after?: string;
7
+ ending_before?: string;
8
+ };
9
+ export type Searchable<T = any> = Pagination<T> & {
10
+ query: string;
11
+ };
12
+ export type Paginated<T = any> = {
13
+ count: number;
14
+ list: T[];
15
+ };
16
+ export type InferFormType<T> = Omit<T, 'id' | 'created_at' | 'created_via' | 'updated_at' | 'active' | 'livemode' | 'metadata'> & {
17
+ metadata: {
18
+ key: string;
19
+ value: string;
20
+ }[];
21
+ };
22
+ export type PriceRecurring = {
23
+ interval: LiteralUnion<'hour' | 'day' | 'week' | 'month' | 'year', string>;
24
+ interval_count: number;
25
+ aggregate_usage?: LiteralUnion<'sum' | 'last_during_period' | 'max' | 'last_ever', string>;
26
+ usage_type?: LiteralUnion<'licensed' | 'metered', string>;
27
+ };
28
+ export type PriceCurrency = {
29
+ currency_id: string;
30
+ unit_amount: string;
31
+ tiers: PriceTier[] | null;
32
+ custom_unit_amount: CustomUnitAmount | null;
33
+ };
34
+ export type CustomUnitAmount = {
35
+ maximum: string;
36
+ minimum: string;
37
+ preset: string;
38
+ };
39
+ export type PriceTier = {
40
+ flat_amount?: number;
41
+ unit_amount?: string;
42
+ up_to?: number;
43
+ };
44
+ export type TransformQuantity = {
45
+ divide_by: number;
46
+ round: LiteralUnion<'up' | 'down', string>;
47
+ };
48
+ export type CustomField = {
49
+ key: string;
50
+ label: string;
51
+ type: LiteralUnion<'text' | 'numeric' | 'dropdown', string>;
52
+ optional: boolean;
53
+ text?: {
54
+ maximum_length: number;
55
+ minimum_length: number;
56
+ };
57
+ numeric?: {
58
+ maximum_length: number;
59
+ minimum_length: number;
60
+ };
61
+ dropdown?: {
62
+ options: {
63
+ label: string;
64
+ value: string;
65
+ }[];
66
+ };
67
+ };
68
+ export type AfterPayment = {
69
+ type: LiteralUnion<'redirect' | 'hosted_confirmation', string>;
70
+ redirect?: {
71
+ url: string;
72
+ };
73
+ hosted_confirmation?: {
74
+ custom_message: string;
75
+ };
76
+ };
77
+ export type SimpleCustomField = {
78
+ name: string;
79
+ value: string;
80
+ };
81
+ export type DiscountAmount = {
82
+ amount: number;
83
+ discount: string;
84
+ };
85
+ export type CustomerAddress = {
86
+ city?: string;
87
+ country?: string;
88
+ line1?: string;
89
+ line2?: string;
90
+ postal_code?: string;
91
+ state?: string;
92
+ };
93
+ export type CustomerShipping = {
94
+ address: CustomerAddress;
95
+ name: string;
96
+ phone: string;
97
+ };
98
+ export type CustomerDetail = {
99
+ address?: CustomerAddress;
100
+ email?: string;
101
+ name?: string;
102
+ phone?: string;
103
+ };
104
+ export type PaymentError = {
105
+ type: LiteralUnion<'api_error' | 'card_error' | 'idempotency_error' | 'invalid_request_error', string>;
106
+ charge?: string;
107
+ code?: string;
108
+ decline_code?: string;
109
+ doc_url?: string;
110
+ message?: string;
111
+ param?: string;
112
+ payment_settings?: any;
113
+ payment_method_id?: string;
114
+ payment_method_type?: string;
115
+ };
116
+ export type LineItem = {
117
+ price_id: string;
118
+ quantity: number;
119
+ adjustable_quantity?: {
120
+ enabled: boolean;
121
+ maximum: number;
122
+ minimum: number;
123
+ };
124
+ upsell_price_id?: string;
125
+ cross_sell?: boolean;
126
+ };
127
+ export type InvoiceData = {
128
+ description?: string;
129
+ footer?: string;
130
+ metadata?: Record<string, any>;
131
+ custom_fields?: SimpleCustomField[];
132
+ };
133
+ export type CurrencyConversion = {
134
+ amount_subtotal: string;
135
+ amount_total: string;
136
+ fx_rate: string;
137
+ source_currency: string;
138
+ };
139
+ export type SubscriptionSchedulePhase = {
140
+ billing_cycle_anchor: LiteralUnion<'phase_start' | 'automatic', string>;
141
+ billing_thresholds?: {
142
+ amount_gte: string;
143
+ reset_billing_cycle_anchor: boolean;
144
+ };
145
+ collection_method: LiteralUnion<'charge_automatically' | 'send_invoice', string>;
146
+ coupon_id?: string;
147
+ currency_id?: string;
148
+ description?: string;
149
+ start_date?: number;
150
+ end_date?: number;
151
+ trail_end?: number;
152
+ invoice_settings?: {
153
+ days_until_due?: number;
154
+ };
155
+ items: {
156
+ price: string;
157
+ quantity?: number;
158
+ billing_thresholds?: {
159
+ usage_gte: number;
160
+ };
161
+ }[];
162
+ metadata?: Record<string, any>;
163
+ };
164
+ export type PaymentMethodOptions = {
165
+ arcblock?: {
166
+ payer: string;
167
+ };
168
+ ethereum?: {
169
+ payer: string;
170
+ };
171
+ stripe?: {
172
+ payer: string;
173
+ };
174
+ };
175
+ export type PaymentMethodSettings = {
176
+ stripe?: {
177
+ dashboard: string;
178
+ publishable_key: string;
179
+ secret_key: string;
180
+ webhook_signing_secret: string;
181
+ };
182
+ arcblock?: {
183
+ chain_id: string;
184
+ api_host: string;
185
+ explorer_host: string;
186
+ };
187
+ ethereum?: {
188
+ chain_id: number;
189
+ api_host: string;
190
+ explorer_host: string;
191
+ };
192
+ bitcoin?: {
193
+ chain_id: number;
194
+ api_host: string;
195
+ explorer_host: string;
196
+ };
197
+ };
198
+ export type PaymentSettings = {
199
+ payment_method_options: PaymentMethodOptions;
200
+ payment_method_types: string[];
201
+ };
202
+ export type PaymentDetails = {
203
+ arcblock?: {
204
+ tx_hash: string;
205
+ payer: string;
206
+ };
207
+ stripe?: {
208
+ payment_intent_id?: string;
209
+ setup_intent_id?: string;
210
+ subscription_id?: string;
211
+ customer_id?: string;
212
+ };
213
+ ethereum?: {
214
+ tx_hash: string;
215
+ payer: string;
216
+ block_height: number;
217
+ confirmations: number;
218
+ };
219
+ bitcoin?: {
220
+ tx_hash: string;
221
+ payer: string;
222
+ block_height: number;
223
+ confirmations: number;
224
+ };
225
+ };
226
+ export type NftMintSettings = {
227
+ enabled: boolean;
228
+ behavior?: LiteralUnion<'per_customer' | 'per_checkout_session', string>;
229
+ factory?: string;
230
+ inputs?: Record<string, string>;
231
+ };
232
+ export interface NftMintItem {
233
+ tx_hash?: string;
234
+ address: string;
235
+ owner: string;
236
+ error?: string;
237
+ }
238
+ export type NftMintDetails = {
239
+ type: LiteralUnion<'arcblock' | 'ethereum' | 'bitcoin', string>;
240
+ arcblock?: NftMintItem;
241
+ ethereum?: NftMintItem;
242
+ };
243
+ export type PricingTableItem = {
244
+ price_id: string;
245
+ product_id: string;
246
+ adjustable_quantity: {
247
+ enabled: boolean;
248
+ maximum: number;
249
+ minimum: number;
250
+ };
251
+ after_completion?: AfterPayment;
252
+ allow_promotion_codes: boolean;
253
+ billing_address_collection?: LiteralUnion<'auto' | 'required', string>;
254
+ is_highlight: boolean;
255
+ highlight_text?: LiteralUnion<'deal' | 'popular' | 'recommended', string>;
256
+ consent_collection?: {
257
+ promotions?: LiteralUnion<'auto' | 'none', string>;
258
+ terms_of_service?: LiteralUnion<'required' | 'none', string>;
259
+ };
260
+ custom_fields: CustomField[];
261
+ phone_number_collection?: {
262
+ enabled: boolean;
263
+ };
264
+ submit_type: LiteralUnion<'auto' | 'book' | 'donate' | 'pay', string>;
265
+ subscription_data?: {
266
+ description: string;
267
+ trial_period_days: number;
268
+ };
269
+ nft_mint_settings?: NftMintSettings;
270
+ cross_sell_behavior?: LiteralUnion<'auto' | 'required', string>;
271
+ };
272
+ export type BrandSettings = {
273
+ background_color: string;
274
+ border_style: string;
275
+ button_color: string;
276
+ font_family: string;
277
+ };
278
+ export type SubscriptionUpdateItem = {
279
+ id?: string;
280
+ deleted?: boolean;
281
+ clear_usage?: boolean;
282
+ price_id?: string;
283
+ quantity?: number;
284
+ };
285
+ export type EventType = LiteralUnion<'account.application.authorized' | 'account.application.deauthorized' | 'account.external_account.created' | 'account.external_account.deleted' | 'account.external_account.updated' | 'account.updated' | 'application_fee.created' | 'application_fee.refund.updated' | 'application_fee.refunded' | 'balance.available' | 'billing_portal.configuration.created' | 'billing_portal.configuration.updated' | 'billing_portal.session.created' | 'capability.updated' | 'cash_balance.funds_available' | 'charge.captured' | 'charge.dispute.closed' | 'charge.dispute.created' | 'charge.dispute.funds_reinstated' | 'charge.dispute.funds_withdrawn' | 'charge.dispute.updated' | 'charge.expired' | 'charge.failed' | 'charge.pending' | 'charge.refund.updated' | 'charge.refunded' | 'charge.succeeded' | 'charge.updated' | 'checkout.session.async_payment_failed' | 'checkout.session.async_payment_succeeded' | 'checkout.session.nft_minted' | 'checkout.session.completed' | 'checkout.session.expired' | 'checkout.session.created' | 'coupon.created' | 'coupon.deleted' | 'coupon.updated' | 'credit_note.created' | 'credit_note.updated' | 'credit_note.voided' | 'customer_cash_balance_transaction.created' | 'customer.created' | 'customer.deleted' | 'customer.discount.created' | 'customer.discount.deleted' | 'customer.discount.updated' | 'customer.source.created' | 'customer.source.deleted' | 'customer.source.expiring' | 'customer.source.updated' | 'customer.subscription.created' | 'customer.subscription.deleted' | 'customer.subscription.paused' | 'customer.subscription.past_due' | 'customer.subscription.pending_update_applied' | 'customer.subscription.pending_update_expired' | 'customer.subscription.resumed' | 'customer.subscription.renewed' | 'customer.subscription.upgraded' | 'customer.subscription.renew_failed' | 'customer.subscription.trial_start' | 'customer.subscription.trial_will_end' | 'customer.subscription.trial_end' | 'customer.subscription.started' | 'customer.subscription.updated' | 'customer.tax_id.created' | 'customer.tax_id.deleted' | 'customer.tax_id.updated' | 'customer.updated' | 'file.created' | 'financial_connections.account.created' | 'financial_connections.account.deactivated' | 'financial_connections.account.disconnected' | 'financial_connections.account.reactivated' | 'financial_connections.account.refreshed_balance' | 'identity.verification_session.canceled' | 'identity.verification_session.created' | 'identity.verification_session.processing' | 'identity.verification_session.redacted' | 'identity.verification_session.requires_input' | 'identity.verification_session.verified' | 'invoice.created' | 'invoice.deleted' | 'invoice.finalization_failed' | 'invoice.finalized' | 'invoice.marked_uncollectible' | 'invoice.paid' | 'invoice.payment_action_required' | 'invoice.payment_failed' | 'invoice.payment_succeeded' | 'invoice.sent' | 'invoice.upcoming' | 'invoice.updated' | 'invoice.voided' | 'invoiceitem.created' | 'invoiceitem.deleted' | 'issuing_authorization.created' | 'issuing_authorization.request' | 'issuing_authorization.updated' | 'issuing_card.created' | 'issuing_card.updated' | 'issuing_cardholder.created' | 'issuing_cardholder.updated' | 'issuing_dispute.closed' | 'issuing_dispute.created' | 'issuing_dispute.funds_reinstated' | 'issuing_dispute.submitted' | 'issuing_dispute.updated' | 'issuing_transaction.created' | 'issuing_transaction.updated' | 'mandate.updated' | 'order.created' | 'payment_intent.amount_capturable_updated' | 'payment_intent.canceled' | 'payment_intent.created' | 'payment_intent.partially_funded' | 'payment_intent.payment_failed' | 'payment_intent.processing' | 'payment_intent.requires_action' | 'payment_intent.succeeded' | 'payment_link.created' | 'payment_link.updated' | 'payment_method.attached' | 'payment_method.automatically_updated' | 'payment_method.detached' | 'payment_method.updated' | 'payout.canceled' | 'payout.created' | 'payout.failed' | 'payout.paid' | 'payout.reconciliation_completed' | 'payout.updated' | 'person.created' | 'person.deleted' | 'person.updated' | 'plan.created' | 'plan.deleted' | 'plan.updated' | 'price.created' | 'price.deleted' | 'price.updated' | 'product.created' | 'product.deleted' | 'product.updated' | 'promotion_code.created' | 'promotion_code.updated' | 'quote.accepted' | 'quote.canceled' | 'quote.created' | 'quote.finalized' | 'radar.early_fraud_warning.created' | 'radar.early_fraud_warning.updated' | 'recipient.created' | 'recipient.deleted' | 'recipient.updated' | 'refund.created' | 'refund.updated' | 'reporting.report_run.failed' | 'reporting.report_run.succeeded' | 'reporting.report_type.updated' | 'review.closed' | 'review.opened' | 'setup_intent.canceled' | 'setup_intent.created' | 'setup_intent.requires_action' | 'setup_intent.setup_failed' | 'setup_intent.succeeded' | 'sigma.scheduled_query_run.created' | 'sku.created' | 'sku.deleted' | 'sku.updated' | 'source.canceled' | 'source.chargeable' | 'source.failed' | 'source.mandate_notification' | 'source.refund_attributes_required' | 'source.transaction.created' | 'source.transaction.updated' | 'subscription_schedule.aborted' | 'subscription_schedule.canceled' | 'subscription_schedule.completed' | 'subscription_schedule.created' | 'subscription_schedule.expiring' | 'subscription_schedule.released' | 'subscription_schedule.updated' | 'tax_rate.created' | 'tax_rate.updated' | 'tax.settings.updated' | 'terminal.reader.action_failed' | 'terminal.reader.action_succeeded' | 'test_helpers.test_clock.advancing' | 'test_helpers.test_clock.created' | 'test_helpers.test_clock.deleted' | 'test_helpers.test_clock.internal_failure' | 'test_helpers.test_clock.ready' | 'topup.canceled' | 'topup.created' | 'topup.failed' | 'topup.reversed' | 'topup.succeeded' | 'transfer.created' | 'transfer.reversed' | 'transfer.updated', string>;
@@ -0,0 +1,54 @@
1
+ import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
2
+ import type { LiteralUnion } from 'type-fest';
3
+ export declare class UsageRecord extends Model<InferAttributes<UsageRecord>, InferCreationAttributes<UsageRecord>> {
4
+ id: CreationOptional<string>;
5
+ livemode: boolean;
6
+ timestamp: number;
7
+ quantity: number;
8
+ subscription_item_id: string;
9
+ metadata: Record<string, any>;
10
+ created_at: CreationOptional<Date>;
11
+ updated_at: CreationOptional<Date>;
12
+ static readonly GENESIS_ATTRIBUTES: {
13
+ id: {
14
+ type: DataTypes.StringDataType;
15
+ primaryKey: boolean;
16
+ allowNull: boolean;
17
+ defaultValue: (size?: number | undefined) => string;
18
+ };
19
+ livemode: {
20
+ type: DataTypes.AbstractDataTypeConstructor;
21
+ allowNull: boolean;
22
+ };
23
+ timestamp: {
24
+ type: DataTypes.IntegerDataTypeConstructor;
25
+ allowNull: boolean;
26
+ };
27
+ quantity: {
28
+ type: DataTypes.BigIntDataTypeConstructor;
29
+ allowNull: boolean;
30
+ };
31
+ subscription_item_id: {
32
+ type: DataTypes.StringDataType;
33
+ allowNull: boolean;
34
+ };
35
+ metadata: {
36
+ type: DataTypes.AbstractDataTypeConstructor;
37
+ allowNull: boolean;
38
+ };
39
+ created_at: {
40
+ type: DataTypes.DateDataTypeConstructor;
41
+ defaultValue: DataTypes.AbstractDataTypeConstructor;
42
+ allowNull: boolean;
43
+ };
44
+ updated_at: {
45
+ type: DataTypes.DateDataTypeConstructor;
46
+ defaultValue: DataTypes.AbstractDataTypeConstructor;
47
+ allowNull: boolean;
48
+ };
49
+ };
50
+ static initialize(sequelize: any): void;
51
+ static associate(models: any): void;
52
+ static getSummary(subscription_item_id: string, period_start: number, period_end: number, method: LiteralUnion<'sum' | 'last_during_period' | 'max' | 'last_ever', string>): Promise<number>;
53
+ }
54
+ export type TUsageRecord = InferAttributes<UsageRecord>;