@schematichq/schematic-react 1.7.0 → 1.9.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/schematic-react.cjs.js +646 -19
- package/dist/schematic-react.d.ts +354 -30
- package/dist/schematic-react.esm.js +653 -20
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
1
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.9.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1146,13 +1146,19 @@ function contextString(context) {
|
|
|
1146
1146
|
}, {});
|
|
1147
1147
|
return JSON.stringify(sortedContext);
|
|
1148
1148
|
}
|
|
1149
|
-
var version = "1.
|
|
1149
|
+
var version = "1.9.0";
|
|
1150
|
+
var SINGLETON = {};
|
|
1150
1151
|
var models_exports = {};
|
|
1151
1152
|
__export(models_exports, {
|
|
1152
1153
|
ApiErrorFromJSON: () => ApiErrorFromJSON,
|
|
1153
1154
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1154
1155
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1155
1156
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1157
|
+
BillingProviderType: () => BillingProviderType,
|
|
1158
|
+
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1159
|
+
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1160
|
+
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1161
|
+
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1156
1162
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1157
1163
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1158
1164
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
@@ -1165,10 +1171,30 @@ __export(models_exports, {
|
|
|
1165
1171
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1166
1172
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1167
1173
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1174
|
+
CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
|
|
1175
|
+
CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
|
|
1176
|
+
CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
|
|
1177
|
+
CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
|
|
1178
|
+
CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
|
|
1179
|
+
CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
|
|
1180
|
+
CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
|
|
1181
|
+
CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
|
|
1168
1182
|
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1169
1183
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1170
1184
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1171
1185
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1186
|
+
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1187
|
+
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1188
|
+
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
1189
|
+
CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
|
|
1190
|
+
DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
|
|
1191
|
+
DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
|
|
1192
|
+
DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
|
|
1193
|
+
DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
|
|
1194
|
+
DeleteResponseFromJSON: () => DeleteResponseFromJSON,
|
|
1195
|
+
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1196
|
+
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1197
|
+
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1172
1198
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1173
1199
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1174
1200
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1177,6 +1203,10 @@ __export(models_exports, {
|
|
|
1177
1203
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1178
1204
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1179
1205
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1206
|
+
GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
|
|
1207
|
+
GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
|
|
1208
|
+
GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
|
|
1209
|
+
GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
|
|
1180
1210
|
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1181
1211
|
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1182
1212
|
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
@@ -1186,15 +1216,42 @@ __export(models_exports, {
|
|
|
1186
1216
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1187
1217
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1188
1218
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1219
|
+
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1220
|
+
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1221
|
+
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1222
|
+
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1223
|
+
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1224
|
+
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1225
|
+
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
1226
|
+
SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
|
|
1227
|
+
UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
|
|
1228
|
+
UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
|
|
1229
|
+
UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
|
|
1230
|
+
UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
|
|
1231
|
+
UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
|
|
1232
|
+
UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
|
|
1233
|
+
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1234
|
+
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1189
1235
|
instanceOfApiError: () => instanceOfApiError,
|
|
1236
|
+
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1190
1237
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1191
1238
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1192
1239
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1240
|
+
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1241
|
+
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1193
1242
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1243
|
+
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1244
|
+
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1245
|
+
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1194
1246
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1195
1247
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1248
|
+
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1196
1249
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1197
|
-
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1250
|
+
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1251
|
+
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1252
|
+
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1253
|
+
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1254
|
+
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
1198
1255
|
});
|
|
1199
1256
|
function instanceOfApiError(value) {
|
|
1200
1257
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
@@ -1222,6 +1279,34 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1222
1279
|
error: value["error"]
|
|
1223
1280
|
};
|
|
1224
1281
|
}
|
|
1282
|
+
var BillingProviderType = {
|
|
1283
|
+
Metronome: "metronome",
|
|
1284
|
+
Orb: "orb",
|
|
1285
|
+
Schematic: "schematic",
|
|
1286
|
+
Stripe: "stripe"
|
|
1287
|
+
};
|
|
1288
|
+
function instanceOfBillingProviderType(value) {
|
|
1289
|
+
for (const key in BillingProviderType) {
|
|
1290
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1291
|
+
if (BillingProviderType[key] === value) {
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
return false;
|
|
1297
|
+
}
|
|
1298
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1299
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1300
|
+
}
|
|
1301
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1302
|
+
return json;
|
|
1303
|
+
}
|
|
1304
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1305
|
+
return value;
|
|
1306
|
+
}
|
|
1307
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1308
|
+
return value;
|
|
1309
|
+
}
|
|
1225
1310
|
function instanceOfCompanyDiscountResponseData(value) {
|
|
1226
1311
|
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1227
1312
|
return false;
|
|
@@ -1365,6 +1450,97 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1365
1450
|
)
|
|
1366
1451
|
};
|
|
1367
1452
|
}
|
|
1453
|
+
function instanceOfCompanyPaymentMethodResponseData(value) {
|
|
1454
|
+
if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
|
|
1455
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1456
|
+
return false;
|
|
1457
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1458
|
+
if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
|
|
1459
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
1460
|
+
return true;
|
|
1461
|
+
}
|
|
1462
|
+
function CompanyPaymentMethodResponseDataFromJSON(json) {
|
|
1463
|
+
return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1464
|
+
}
|
|
1465
|
+
function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1466
|
+
if (json == null) {
|
|
1467
|
+
return json;
|
|
1468
|
+
}
|
|
1469
|
+
return {
|
|
1470
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1471
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1472
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1473
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1474
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1475
|
+
canRemove: json["can_remove"],
|
|
1476
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1477
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1478
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1479
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1480
|
+
externalId: json["external_id"],
|
|
1481
|
+
id: json["id"],
|
|
1482
|
+
isDefault: json["is_default"],
|
|
1483
|
+
type: json["type"]
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function CompanyPaymentMethodResponseDataToJSON(json) {
|
|
1487
|
+
return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
|
|
1488
|
+
}
|
|
1489
|
+
function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1490
|
+
if (value == null) {
|
|
1491
|
+
return value;
|
|
1492
|
+
}
|
|
1493
|
+
return {
|
|
1494
|
+
account_last4: value["accountLast4"],
|
|
1495
|
+
account_name: value["accountName"],
|
|
1496
|
+
bank_name: value["bankName"],
|
|
1497
|
+
billing_email: value["billingEmail"],
|
|
1498
|
+
billing_name: value["billingName"],
|
|
1499
|
+
can_remove: value["canRemove"],
|
|
1500
|
+
card_brand: value["cardBrand"],
|
|
1501
|
+
card_exp_month: value["cardExpMonth"],
|
|
1502
|
+
card_exp_year: value["cardExpYear"],
|
|
1503
|
+
card_last4: value["cardLast4"],
|
|
1504
|
+
external_id: value["externalId"],
|
|
1505
|
+
id: value["id"],
|
|
1506
|
+
is_default: value["isDefault"],
|
|
1507
|
+
type: value["type"]
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function instanceOfCompanyPaymentMethodsResponseData(value) {
|
|
1511
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
1512
|
+
if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
|
|
1513
|
+
return false;
|
|
1514
|
+
return true;
|
|
1515
|
+
}
|
|
1516
|
+
function CompanyPaymentMethodsResponseDataFromJSON(json) {
|
|
1517
|
+
return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
|
|
1518
|
+
}
|
|
1519
|
+
function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1520
|
+
if (json == null) {
|
|
1521
|
+
return json;
|
|
1522
|
+
}
|
|
1523
|
+
return {
|
|
1524
|
+
count: json["count"],
|
|
1525
|
+
paymentMethods: json["payment_methods"].map(
|
|
1526
|
+
CompanyPaymentMethodResponseDataFromJSON
|
|
1527
|
+
)
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function CompanyPaymentMethodsResponseDataToJSON(json) {
|
|
1531
|
+
return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
|
|
1532
|
+
}
|
|
1533
|
+
function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1534
|
+
if (value == null) {
|
|
1535
|
+
return value;
|
|
1536
|
+
}
|
|
1537
|
+
return {
|
|
1538
|
+
count: value["count"],
|
|
1539
|
+
payment_methods: value["paymentMethods"].map(
|
|
1540
|
+
CompanyPaymentMethodResponseDataToJSON
|
|
1541
|
+
)
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1368
1544
|
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1369
1545
|
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1370
1546
|
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
@@ -1414,6 +1590,122 @@ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminato
|
|
|
1414
1590
|
subtotal: value["subtotal"]
|
|
1415
1591
|
};
|
|
1416
1592
|
}
|
|
1593
|
+
function instanceOfSetupIntentResponseData(value) {
|
|
1594
|
+
if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
|
|
1595
|
+
return false;
|
|
1596
|
+
return true;
|
|
1597
|
+
}
|
|
1598
|
+
function SetupIntentResponseDataFromJSON(json) {
|
|
1599
|
+
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
1600
|
+
}
|
|
1601
|
+
function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1602
|
+
if (json == null) {
|
|
1603
|
+
return json;
|
|
1604
|
+
}
|
|
1605
|
+
return {
|
|
1606
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
1607
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
1608
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
1609
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
function SetupIntentResponseDataToJSON(json) {
|
|
1613
|
+
return SetupIntentResponseDataToJSONTyped(json, false);
|
|
1614
|
+
}
|
|
1615
|
+
function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1616
|
+
if (value == null) {
|
|
1617
|
+
return value;
|
|
1618
|
+
}
|
|
1619
|
+
return {
|
|
1620
|
+
account_id: value["accountId"],
|
|
1621
|
+
publishable_key: value["publishableKey"],
|
|
1622
|
+
schematic_publishable_key: value["schematicPublishableKey"],
|
|
1623
|
+
setup_intent_client_secret: value["setupIntentClientSecret"]
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
function instanceOfCreateSetupIntentResponse(value) {
|
|
1627
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1628
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1629
|
+
return true;
|
|
1630
|
+
}
|
|
1631
|
+
function CreateSetupIntentResponseFromJSON(json) {
|
|
1632
|
+
return CreateSetupIntentResponseFromJSONTyped(json, false);
|
|
1633
|
+
}
|
|
1634
|
+
function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1635
|
+
if (json == null) {
|
|
1636
|
+
return json;
|
|
1637
|
+
}
|
|
1638
|
+
return {
|
|
1639
|
+
data: SetupIntentResponseDataFromJSON(json["data"]),
|
|
1640
|
+
params: json["params"]
|
|
1641
|
+
};
|
|
1642
|
+
}
|
|
1643
|
+
function CreateSetupIntentResponseToJSON(json) {
|
|
1644
|
+
return CreateSetupIntentResponseToJSONTyped(json, false);
|
|
1645
|
+
}
|
|
1646
|
+
function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1647
|
+
if (value == null) {
|
|
1648
|
+
return value;
|
|
1649
|
+
}
|
|
1650
|
+
return {
|
|
1651
|
+
data: SetupIntentResponseDataToJSON(value["data"]),
|
|
1652
|
+
params: value["params"]
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
function instanceOfDeleteResponse(value) {
|
|
1656
|
+
return true;
|
|
1657
|
+
}
|
|
1658
|
+
function DeleteResponseFromJSON(json) {
|
|
1659
|
+
return DeleteResponseFromJSONTyped(json, false);
|
|
1660
|
+
}
|
|
1661
|
+
function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1662
|
+
if (json == null) {
|
|
1663
|
+
return json;
|
|
1664
|
+
}
|
|
1665
|
+
return {
|
|
1666
|
+
deleted: json["deleted"] == null ? void 0 : json["deleted"]
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
function DeleteResponseToJSON(json) {
|
|
1670
|
+
return DeleteResponseToJSONTyped(json, false);
|
|
1671
|
+
}
|
|
1672
|
+
function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1673
|
+
if (value == null) {
|
|
1674
|
+
return value;
|
|
1675
|
+
}
|
|
1676
|
+
return {
|
|
1677
|
+
deleted: value["deleted"]
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
function instanceOfDeletePaymentMethodResponse(value) {
|
|
1681
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1682
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1683
|
+
return true;
|
|
1684
|
+
}
|
|
1685
|
+
function DeletePaymentMethodResponseFromJSON(json) {
|
|
1686
|
+
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
1687
|
+
}
|
|
1688
|
+
function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1689
|
+
if (json == null) {
|
|
1690
|
+
return json;
|
|
1691
|
+
}
|
|
1692
|
+
return {
|
|
1693
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
1694
|
+
params: json["params"]
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
function DeletePaymentMethodResponseToJSON(json) {
|
|
1698
|
+
return DeletePaymentMethodResponseToJSONTyped(json, false);
|
|
1699
|
+
}
|
|
1700
|
+
function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1701
|
+
if (value == null) {
|
|
1702
|
+
return value;
|
|
1703
|
+
}
|
|
1704
|
+
return {
|
|
1705
|
+
data: DeleteResponseToJSON(value["data"]),
|
|
1706
|
+
params: value["params"]
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1417
1709
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1418
1710
|
return true;
|
|
1419
1711
|
}
|
|
@@ -1472,6 +1764,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1472
1764
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1473
1765
|
};
|
|
1474
1766
|
}
|
|
1767
|
+
function instanceOfGetCompanyPaymentMethodsResponse(value) {
|
|
1768
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1769
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1770
|
+
return true;
|
|
1771
|
+
}
|
|
1772
|
+
function GetCompanyPaymentMethodsResponseFromJSON(json) {
|
|
1773
|
+
return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
|
|
1774
|
+
}
|
|
1775
|
+
function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1776
|
+
if (json == null) {
|
|
1777
|
+
return json;
|
|
1778
|
+
}
|
|
1779
|
+
return {
|
|
1780
|
+
data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
|
|
1781
|
+
params: json["params"]
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
function GetCompanyPaymentMethodsResponseToJSON(json) {
|
|
1785
|
+
return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
|
|
1786
|
+
}
|
|
1787
|
+
function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1788
|
+
if (value == null) {
|
|
1789
|
+
return value;
|
|
1790
|
+
}
|
|
1791
|
+
return {
|
|
1792
|
+
data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
|
|
1793
|
+
params: value["params"]
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1475
1796
|
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1476
1797
|
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1477
1798
|
if (!("params" in value) || value["params"] === void 0) return false;
|
|
@@ -1501,6 +1822,134 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
|
|
|
1501
1822
|
params: value["params"]
|
|
1502
1823
|
};
|
|
1503
1824
|
}
|
|
1825
|
+
function instanceOfPaymentMethodResponseData(value) {
|
|
1826
|
+
if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
|
|
1827
|
+
if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
|
|
1828
|
+
return false;
|
|
1829
|
+
if (!("environmentId" in value) || value["environmentId"] === void 0)
|
|
1830
|
+
return false;
|
|
1831
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1832
|
+
return false;
|
|
1833
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1834
|
+
if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
|
|
1835
|
+
return false;
|
|
1836
|
+
if (!("providerType" in value) || value["providerType"] === void 0)
|
|
1837
|
+
return false;
|
|
1838
|
+
if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
|
|
1839
|
+
return true;
|
|
1840
|
+
}
|
|
1841
|
+
function PaymentMethodResponseDataFromJSON(json) {
|
|
1842
|
+
return PaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1843
|
+
}
|
|
1844
|
+
function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1845
|
+
if (json == null) {
|
|
1846
|
+
return json;
|
|
1847
|
+
}
|
|
1848
|
+
return {
|
|
1849
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1850
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1851
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1852
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1853
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1854
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1855
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1856
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1857
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1858
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
1859
|
+
createdAt: new Date(json["created_at"]),
|
|
1860
|
+
customerExternalId: json["customer_external_id"],
|
|
1861
|
+
environmentId: json["environment_id"],
|
|
1862
|
+
externalId: json["external_id"],
|
|
1863
|
+
id: json["id"],
|
|
1864
|
+
paymentMethodType: json["payment_method_type"],
|
|
1865
|
+
providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
|
|
1866
|
+
updatedAt: new Date(json["updated_at"])
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function PaymentMethodResponseDataToJSON(json) {
|
|
1870
|
+
return PaymentMethodResponseDataToJSONTyped(json, false);
|
|
1871
|
+
}
|
|
1872
|
+
function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1873
|
+
if (value == null) {
|
|
1874
|
+
return value;
|
|
1875
|
+
}
|
|
1876
|
+
return {
|
|
1877
|
+
account_last4: value["accountLast4"],
|
|
1878
|
+
account_name: value["accountName"],
|
|
1879
|
+
bank_name: value["bankName"],
|
|
1880
|
+
billing_email: value["billingEmail"],
|
|
1881
|
+
billing_name: value["billingName"],
|
|
1882
|
+
card_brand: value["cardBrand"],
|
|
1883
|
+
card_exp_month: value["cardExpMonth"],
|
|
1884
|
+
card_exp_year: value["cardExpYear"],
|
|
1885
|
+
card_last4: value["cardLast4"],
|
|
1886
|
+
company_id: value["companyId"],
|
|
1887
|
+
created_at: value["createdAt"].toISOString(),
|
|
1888
|
+
customer_external_id: value["customerExternalId"],
|
|
1889
|
+
environment_id: value["environmentId"],
|
|
1890
|
+
external_id: value["externalId"],
|
|
1891
|
+
id: value["id"],
|
|
1892
|
+
payment_method_type: value["paymentMethodType"],
|
|
1893
|
+
provider_type: BillingProviderTypeToJSON2(value["providerType"]),
|
|
1894
|
+
updated_at: value["updatedAt"].toISOString()
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
function instanceOfUpdatePaymentMethodRequestBody(value) {
|
|
1898
|
+
if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
|
|
1899
|
+
return false;
|
|
1900
|
+
return true;
|
|
1901
|
+
}
|
|
1902
|
+
function UpdatePaymentMethodRequestBodyFromJSON(json) {
|
|
1903
|
+
return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
|
|
1904
|
+
}
|
|
1905
|
+
function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1906
|
+
if (json == null) {
|
|
1907
|
+
return json;
|
|
1908
|
+
}
|
|
1909
|
+
return {
|
|
1910
|
+
paymentMethodId: json["payment_method_id"]
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
1914
|
+
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
1915
|
+
}
|
|
1916
|
+
function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1917
|
+
if (value == null) {
|
|
1918
|
+
return value;
|
|
1919
|
+
}
|
|
1920
|
+
return {
|
|
1921
|
+
payment_method_id: value["paymentMethodId"]
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
function instanceOfUpdatePaymentMethodResponse(value) {
|
|
1925
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1926
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1927
|
+
return true;
|
|
1928
|
+
}
|
|
1929
|
+
function UpdatePaymentMethodResponseFromJSON(json) {
|
|
1930
|
+
return UpdatePaymentMethodResponseFromJSONTyped(json, false);
|
|
1931
|
+
}
|
|
1932
|
+
function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1933
|
+
if (json == null) {
|
|
1934
|
+
return json;
|
|
1935
|
+
}
|
|
1936
|
+
return {
|
|
1937
|
+
data: PaymentMethodResponseDataFromJSON(json["data"]),
|
|
1938
|
+
params: json["params"]
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
function UpdatePaymentMethodResponseToJSON(json) {
|
|
1942
|
+
return UpdatePaymentMethodResponseToJSONTyped(json, false);
|
|
1943
|
+
}
|
|
1944
|
+
function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1945
|
+
if (value == null) {
|
|
1946
|
+
return value;
|
|
1947
|
+
}
|
|
1948
|
+
return {
|
|
1949
|
+
data: PaymentMethodResponseDataToJSON(value["data"]),
|
|
1950
|
+
params: value["params"]
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1504
1953
|
var DEFAULT_INVOICE_QUERY = {};
|
|
1505
1954
|
function normalizeInvoiceQuery(query) {
|
|
1506
1955
|
const { includePending, ...rest } = query;
|
|
@@ -1825,6 +2274,39 @@ var SchematicBillingClient = class {
|
|
|
1825
2274
|
return GetCompanyUpcomingInvoiceResponseFromJSON(body).data;
|
|
1826
2275
|
});
|
|
1827
2276
|
}
|
|
2277
|
+
fetchPaymentMethods() {
|
|
2278
|
+
const path = "/company/payment-methods";
|
|
2279
|
+
return this.session.request(path).then((body) => {
|
|
2280
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
2281
|
+
throw new Error(`Malformed response from ${path}`);
|
|
2282
|
+
}
|
|
2283
|
+
const data = body.data;
|
|
2284
|
+
if (data == null || data.payment_methods == null) {
|
|
2285
|
+
return [];
|
|
2286
|
+
}
|
|
2287
|
+
return GetCompanyPaymentMethodsResponseFromJSON(body).data.paymentMethods;
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
createSetupIntent() {
|
|
2291
|
+
const path = "/components/setup-intent";
|
|
2292
|
+
return this.session.request(path, { method: "POST" }).then((body) => {
|
|
2293
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
2294
|
+
throw new Error(`Malformed response from ${path}`);
|
|
2295
|
+
}
|
|
2296
|
+
return CreateSetupIntentResponseFromJSON(body).data;
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
updatePaymentMethod(externalId) {
|
|
2300
|
+
return this.session.request("/checkout/paymentmethod/update", {
|
|
2301
|
+
method: "POST",
|
|
2302
|
+
body: { payment_method_id: externalId }
|
|
2303
|
+
}).then(() => void 0);
|
|
2304
|
+
}
|
|
2305
|
+
deletePaymentMethod(id) {
|
|
2306
|
+
return this.session.request(`/checkout/paymentmethod/${encodeURIComponent(id)}`, {
|
|
2307
|
+
method: "DELETE"
|
|
2308
|
+
}).then(() => void 0);
|
|
2309
|
+
}
|
|
1828
2310
|
};
|
|
1829
2311
|
var anonymousIdKey = "schematicId";
|
|
1830
2312
|
var flagStateCachePrefix = "schematicCache";
|
|
@@ -3933,33 +4415,48 @@ var BillingStore = class {
|
|
|
3933
4415
|
constructor(_client, initialData = {}, options = {}) {
|
|
3934
4416
|
this._client = _client;
|
|
3935
4417
|
this._pageSize = options.pageSize ?? INVOICE_PAGE_SIZE;
|
|
4418
|
+
const readiness = () => this._connected ? READINESS[this._client.sessionStatus] : "waiting";
|
|
3936
4419
|
this.invoices = new KeyedResource(
|
|
3937
4420
|
(query, current) => this._reloadWindow(
|
|
3938
4421
|
query,
|
|
3939
4422
|
Math.max(this._pageSize, current?.invoices.length ?? 0)
|
|
3940
4423
|
),
|
|
3941
|
-
|
|
3942
|
-
// pending, and one that has ended settles empty rather than recording
|
|
3943
|
-
// the client's refusal as an error.
|
|
3944
|
-
{
|
|
3945
|
-
readiness: () => this._connected ? READINESS[this._client.sessionStatus] : "waiting"
|
|
3946
|
-
}
|
|
4424
|
+
{ readiness }
|
|
3947
4425
|
);
|
|
4426
|
+
this.upcomingInvoice = new KeyedResource(
|
|
4427
|
+
() => this._client.fetchUpcomingInvoice(),
|
|
4428
|
+
{ readiness }
|
|
4429
|
+
);
|
|
4430
|
+
this.paymentMethods = new KeyedResource(
|
|
4431
|
+
() => this._client.fetchPaymentMethods(),
|
|
4432
|
+
{ readiness }
|
|
4433
|
+
);
|
|
4434
|
+
const held = { key: initialData.sessionKey };
|
|
3948
4435
|
if (initialData.invoices !== void 0) {
|
|
3949
|
-
|
|
4436
|
+
held.invoices = {
|
|
3950
4437
|
// Normalized the way the hook normalizes, or the caller asking for
|
|
3951
4438
|
// it fetches the same page again.
|
|
3952
4439
|
params: normalizeInvoiceQuery2(
|
|
3953
4440
|
initialData.params?.invoices ?? DEFAULT_INVOICE_QUERY
|
|
3954
4441
|
),
|
|
3955
|
-
data: initialData.invoices
|
|
3956
|
-
key: initialData.sessionKey
|
|
4442
|
+
data: initialData.invoices
|
|
3957
4443
|
};
|
|
4444
|
+
}
|
|
4445
|
+
if (initialData.upcomingInvoice !== void 0) {
|
|
4446
|
+
held.upcomingInvoice = initialData.upcomingInvoice;
|
|
4447
|
+
}
|
|
4448
|
+
if (initialData.paymentMethods !== void 0) {
|
|
4449
|
+
held.paymentMethods = initialData.paymentMethods;
|
|
4450
|
+
}
|
|
4451
|
+
if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0) {
|
|
4452
|
+
this._held = held;
|
|
3958
4453
|
this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
|
|
3959
4454
|
}
|
|
3960
4455
|
}
|
|
3961
4456
|
_client;
|
|
3962
4457
|
invoices;
|
|
4458
|
+
upcomingInvoice;
|
|
4459
|
+
paymentMethods;
|
|
3963
4460
|
_pageSize;
|
|
3964
4461
|
_unsubscribe;
|
|
3965
4462
|
_connected = false;
|
|
@@ -4029,7 +4526,15 @@ var BillingStore = class {
|
|
|
4029
4526
|
}
|
|
4030
4527
|
this._held = void 0;
|
|
4031
4528
|
if (verdict === "adopt") {
|
|
4032
|
-
|
|
4529
|
+
if (held.invoices !== void 0) {
|
|
4530
|
+
this.invoices.seed(held.invoices.params, held.invoices.data);
|
|
4531
|
+
}
|
|
4532
|
+
if (held.upcomingInvoice !== void 0) {
|
|
4533
|
+
this.upcomingInvoice.seed(SINGLETON, held.upcomingInvoice);
|
|
4534
|
+
}
|
|
4535
|
+
if (held.paymentMethods !== void 0) {
|
|
4536
|
+
this.paymentMethods.seed(SINGLETON, held.paymentMethods);
|
|
4537
|
+
}
|
|
4033
4538
|
this._seedKey = held.key;
|
|
4034
4539
|
this._seeded = true;
|
|
4035
4540
|
}
|
|
@@ -4091,9 +4596,46 @@ var BillingStore = class {
|
|
|
4091
4596
|
};
|
|
4092
4597
|
});
|
|
4093
4598
|
}
|
|
4599
|
+
/**
|
|
4600
|
+
* Makes the payment method `externalId` the company's default, then
|
|
4601
|
+
* reloads the list so it says so. Rejects with the client's error when
|
|
4602
|
+
* the write fails; a reload that fails afterwards lands on the list's
|
|
4603
|
+
* `error`, since the write itself went through.
|
|
4604
|
+
*/
|
|
4605
|
+
async setDefaultPaymentMethod(externalId) {
|
|
4606
|
+
await this._client.updatePaymentMethod(externalId);
|
|
4607
|
+
await this._reloadPaymentMethods();
|
|
4608
|
+
}
|
|
4609
|
+
/** Removes the payment method `id`, then reloads the list. Rejects as `setDefaultPaymentMethod` does. */
|
|
4610
|
+
async removePaymentMethod(id) {
|
|
4611
|
+
await this._client.deletePaymentMethod(id);
|
|
4612
|
+
await this._reloadPaymentMethods();
|
|
4613
|
+
}
|
|
4614
|
+
/**
|
|
4615
|
+
* Mints a setup intent for adding a payment method. Nothing in the store
|
|
4616
|
+
* changes until the provider confirms it and the host reloads the list,
|
|
4617
|
+
* so this is a pass-through to the client.
|
|
4618
|
+
*/
|
|
4619
|
+
createSetupIntent() {
|
|
4620
|
+
return this._client.createSetupIntent();
|
|
4621
|
+
}
|
|
4094
4622
|
dispose() {
|
|
4095
4623
|
this._unsubscribe?.();
|
|
4096
4624
|
}
|
|
4625
|
+
/**
|
|
4626
|
+
* After a write. A list nobody has read is left alone: it loads fresh
|
|
4627
|
+
* when someone does. One that is loaded, or subscribed and waiting on a
|
|
4628
|
+
* failed load, is fetched again; `refetch` never rejects.
|
|
4629
|
+
*/
|
|
4630
|
+
async _reloadPaymentMethods() {
|
|
4631
|
+
if (!this.paymentMethods.has(SINGLETON)) {
|
|
4632
|
+
return;
|
|
4633
|
+
}
|
|
4634
|
+
const resource = this.paymentMethods.get(SINGLETON);
|
|
4635
|
+
if (resource.snapshot.data !== void 0 || resource.subscriberCount > 0) {
|
|
4636
|
+
await resource.refetch();
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4097
4639
|
/**
|
|
4098
4640
|
* Re-reads the window already loaded, in as many requests as the API's
|
|
4099
4641
|
* page cap needs. A window paged past that cap still comes back whole:
|
|
@@ -4131,7 +4673,11 @@ var BillingStore = class {
|
|
|
4131
4673
|
return this._client.fetchInvoices({ ...query, limit, offset });
|
|
4132
4674
|
}
|
|
4133
4675
|
};
|
|
4134
|
-
var RESOURCE_NAMES = [
|
|
4676
|
+
var RESOURCE_NAMES = [
|
|
4677
|
+
"invoices",
|
|
4678
|
+
"upcomingInvoice",
|
|
4679
|
+
"paymentMethods"
|
|
4680
|
+
];
|
|
4135
4681
|
|
|
4136
4682
|
// src/billing/context.tsx
|
|
4137
4683
|
import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2 } from "react";
|
|
@@ -4180,6 +4726,25 @@ var BillingDataContext = createContext2(
|
|
|
4180
4726
|
);
|
|
4181
4727
|
var MISSING_BILLING_SOURCE_MESSAGE = "Schematic billing hooks need a SchematicProvider with a session, billingClient, or initialData, or a BillingDataProvider.";
|
|
4182
4728
|
var missingSourceError = new Error(MISSING_BILLING_SOURCE_MESSAGE);
|
|
4729
|
+
var BILLING_ACTION_UNAVAILABLE_MESSAGE = (name) => `Schematic billing action ${name} is not available: the provider only reads. Writes need a SchematicProvider with a session or billingClient, or a BillingDataProvider given \`actions\`.`;
|
|
4730
|
+
var ACTION_NAMES = [
|
|
4731
|
+
"setDefaultPaymentMethod",
|
|
4732
|
+
"removePaymentMethod",
|
|
4733
|
+
"createSetupIntent"
|
|
4734
|
+
];
|
|
4735
|
+
function rejectingActions(reason, given = {}) {
|
|
4736
|
+
const actions = {};
|
|
4737
|
+
for (const name of ACTION_NAMES) {
|
|
4738
|
+
actions[name] = given[name] ?? (() => Promise.reject(reason(name)));
|
|
4739
|
+
}
|
|
4740
|
+
return actions;
|
|
4741
|
+
}
|
|
4742
|
+
var unavailableActions = rejectingActions(
|
|
4743
|
+
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name))
|
|
4744
|
+
);
|
|
4745
|
+
function actionsOf(source) {
|
|
4746
|
+
return source.actions ?? unavailableActions;
|
|
4747
|
+
}
|
|
4183
4748
|
var missingHandle = {
|
|
4184
4749
|
data: void 0,
|
|
4185
4750
|
error: missingSourceError,
|
|
@@ -4193,12 +4758,16 @@ var missingBillingSource = {
|
|
|
4193
4758
|
handle: () => missingHandle,
|
|
4194
4759
|
loadMoreInvoices: () => Promise.resolve(),
|
|
4195
4760
|
invalidateAll: () => {
|
|
4196
|
-
}
|
|
4761
|
+
},
|
|
4762
|
+
// The same error a read reports, so a write outside any provider names
|
|
4763
|
+
// the misconfiguration rather than a source that only reads.
|
|
4764
|
+
actions: rejectingActions(() => missingSourceError)
|
|
4197
4765
|
};
|
|
4198
4766
|
function useBillingDataSource() {
|
|
4199
4767
|
return useContext2(BillingDataContext) ?? missingBillingSource;
|
|
4200
4768
|
}
|
|
4201
4769
|
function BillingDataProvider({
|
|
4770
|
+
actions,
|
|
4202
4771
|
children,
|
|
4203
4772
|
data,
|
|
4204
4773
|
locale,
|
|
@@ -4212,6 +4781,10 @@ function BillingDataProvider({
|
|
|
4212
4781
|
const source = useMemo2(() => {
|
|
4213
4782
|
const handles = /* @__PURE__ */ new Map();
|
|
4214
4783
|
return {
|
|
4784
|
+
actions: rejectingActions(
|
|
4785
|
+
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
|
|
4786
|
+
actions
|
|
4787
|
+
),
|
|
4215
4788
|
subscribe: () => () => {
|
|
4216
4789
|
},
|
|
4217
4790
|
handle: (name) => {
|
|
@@ -4237,7 +4810,7 @@ function BillingDataProvider({
|
|
|
4237
4810
|
invalidateAll: () => {
|
|
4238
4811
|
}
|
|
4239
4812
|
};
|
|
4240
|
-
}, [data, onLoadMoreInvoices, onRefetch, status]);
|
|
4813
|
+
}, [actions, data, onLoadMoreInvoices, onRefetch, status]);
|
|
4241
4814
|
return /* @__PURE__ */ jsx2(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ jsx2(
|
|
4242
4815
|
SchematicI18nProvider,
|
|
4243
4816
|
{
|
|
@@ -4251,7 +4824,13 @@ function BillingDataProvider({
|
|
|
4251
4824
|
}
|
|
4252
4825
|
|
|
4253
4826
|
// src/billing/hooks.ts
|
|
4254
|
-
import {
|
|
4827
|
+
import {
|
|
4828
|
+
useCallback,
|
|
4829
|
+
useMemo as useMemo3,
|
|
4830
|
+
useRef,
|
|
4831
|
+
useState,
|
|
4832
|
+
useSyncExternalStore
|
|
4833
|
+
} from "react";
|
|
4255
4834
|
function useStableParams(params) {
|
|
4256
4835
|
const key = hashKey(params);
|
|
4257
4836
|
const ref = useRef({ key, params });
|
|
@@ -4282,6 +4861,51 @@ function useInvoices(query = DEFAULT_INVOICE_QUERY) {
|
|
|
4282
4861
|
);
|
|
4283
4862
|
return useMemo3(() => ({ ...handle, loadMore }), [handle, loadMore]);
|
|
4284
4863
|
}
|
|
4864
|
+
function useUpcomingInvoice() {
|
|
4865
|
+
return useBillingResource("upcomingInvoice", SINGLETON);
|
|
4866
|
+
}
|
|
4867
|
+
var IDLE = { inflight: 0, error: void 0 };
|
|
4868
|
+
function usePaymentMethods() {
|
|
4869
|
+
const source = useBillingDataSource();
|
|
4870
|
+
const handle = useBillingResource("paymentMethods", SINGLETON);
|
|
4871
|
+
const [mutation, setMutation] = useState(IDLE);
|
|
4872
|
+
const run = useCallback(async (write) => {
|
|
4873
|
+
setMutation((m) => ({ inflight: m.inflight + 1, error: void 0 }));
|
|
4874
|
+
try {
|
|
4875
|
+
await write();
|
|
4876
|
+
} catch (cause) {
|
|
4877
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
4878
|
+
setMutation((m) => ({ inflight: m.inflight - 1, error }));
|
|
4879
|
+
throw error;
|
|
4880
|
+
}
|
|
4881
|
+
setMutation((m) => ({ inflight: m.inflight - 1, error: void 0 }));
|
|
4882
|
+
}, []);
|
|
4883
|
+
const setDefault = useCallback(
|
|
4884
|
+
(externalId) => run(() => actionsOf(source).setDefaultPaymentMethod(externalId)),
|
|
4885
|
+
[run, source]
|
|
4886
|
+
);
|
|
4887
|
+
const remove = useCallback(
|
|
4888
|
+
(id) => run(() => actionsOf(source).removePaymentMethod(id)),
|
|
4889
|
+
[run, source]
|
|
4890
|
+
);
|
|
4891
|
+
return useMemo3(
|
|
4892
|
+
() => ({
|
|
4893
|
+
...handle,
|
|
4894
|
+
setDefault,
|
|
4895
|
+
remove,
|
|
4896
|
+
isMutating: mutation.inflight > 0,
|
|
4897
|
+
mutationError: mutation.error
|
|
4898
|
+
}),
|
|
4899
|
+
[handle, mutation, remove, setDefault]
|
|
4900
|
+
);
|
|
4901
|
+
}
|
|
4902
|
+
function useSetupIntent() {
|
|
4903
|
+
const source = useBillingDataSource();
|
|
4904
|
+
return useMemo3(
|
|
4905
|
+
() => ({ create: () => actionsOf(source).createSetupIntent() }),
|
|
4906
|
+
[source]
|
|
4907
|
+
);
|
|
4908
|
+
}
|
|
4285
4909
|
function useInvalidateBillingData() {
|
|
4286
4910
|
return useBillingDataSource().invalidateAll;
|
|
4287
4911
|
}
|
|
@@ -4355,7 +4979,12 @@ function BillingProvider({
|
|
|
4355
4979
|
subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
|
|
4356
4980
|
handle,
|
|
4357
4981
|
loadMoreInvoices: (query) => store.loadMoreInvoices(query),
|
|
4358
|
-
invalidateAll: () => store.invalidateAll()
|
|
4982
|
+
invalidateAll: () => store.invalidateAll(),
|
|
4983
|
+
actions: {
|
|
4984
|
+
setDefaultPaymentMethod: (externalId) => store.setDefaultPaymentMethod(externalId),
|
|
4985
|
+
removePaymentMethod: (id) => store.removePaymentMethod(id),
|
|
4986
|
+
createSetupIntent: () => store.createSetupIntent()
|
|
4987
|
+
}
|
|
4359
4988
|
};
|
|
4360
4989
|
}, [store]);
|
|
4361
4990
|
const localized = /* @__PURE__ */ jsx3(
|
|
@@ -4401,7 +5030,7 @@ function staticSource(data) {
|
|
|
4401
5030
|
}
|
|
4402
5031
|
|
|
4403
5032
|
// src/version.ts
|
|
4404
|
-
var version2 = "1.
|
|
5033
|
+
var version2 = "1.9.0";
|
|
4405
5034
|
|
|
4406
5035
|
// src/context/schematic.tsx
|
|
4407
5036
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -4625,6 +5254,7 @@ export {
|
|
|
4625
5254
|
INVOICE_PAGE_SIZE,
|
|
4626
5255
|
InvoiceStatus,
|
|
4627
5256
|
RuleType,
|
|
5257
|
+
SINGLETON,
|
|
4628
5258
|
Schematic,
|
|
4629
5259
|
SchematicI18nContext,
|
|
4630
5260
|
SchematicI18nProvider,
|
|
@@ -4635,6 +5265,7 @@ export {
|
|
|
4635
5265
|
useBillingDataSource,
|
|
4636
5266
|
useInvalidateBillingData,
|
|
4637
5267
|
useInvoices,
|
|
5268
|
+
usePaymentMethods,
|
|
4638
5269
|
useSchematic,
|
|
4639
5270
|
useSchematicContext,
|
|
4640
5271
|
useSchematicCreditBalance,
|
|
@@ -4646,7 +5277,9 @@ export {
|
|
|
4646
5277
|
useSchematicLocale,
|
|
4647
5278
|
useSchematicPlan,
|
|
4648
5279
|
useSchematicStrings,
|
|
4649
|
-
useSchematicTranslate
|
|
5280
|
+
useSchematicTranslate,
|
|
5281
|
+
useSetupIntent,
|
|
5282
|
+
useUpcomingInvoice
|
|
4650
5283
|
};
|
|
4651
5284
|
/*! Bundled license information:
|
|
4652
5285
|
|