@schematichq/schematic-react 1.8.0 → 1.10.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/README.md +37 -0
- package/dist/schematic-react.cjs.js +794 -11
- package/dist/schematic-react.d.ts +511 -10
- package/dist/schematic-react.esm.js +801 -12
- 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.10.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;
|
|
@@ -994,6 +994,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
994
994
|
trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
|
|
995
995
|
};
|
|
996
996
|
}
|
|
997
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
998
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
999
|
+
}
|
|
1000
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
1001
|
+
return json;
|
|
1002
|
+
}
|
|
1003
|
+
function CreditSpendWindowFromJSON(json) {
|
|
1004
|
+
return CreditSpendWindowFromJSONTyped(json, false);
|
|
1005
|
+
}
|
|
1006
|
+
function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
|
|
1007
|
+
if (json == null) {
|
|
1008
|
+
return json;
|
|
1009
|
+
}
|
|
1010
|
+
return {
|
|
1011
|
+
count: json["count"],
|
|
1012
|
+
unit: json["unit"]
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
function CreditSpendPolicyFromJSON(json) {
|
|
1016
|
+
return CreditSpendPolicyFromJSONTyped(json, false);
|
|
1017
|
+
}
|
|
1018
|
+
function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1019
|
+
if (json == null) {
|
|
1020
|
+
return json;
|
|
1021
|
+
}
|
|
1022
|
+
return {
|
|
1023
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
1024
|
+
creditId: json["credit_id"],
|
|
1025
|
+
id: json["id"],
|
|
1026
|
+
kind: json["kind"],
|
|
1027
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
1028
|
+
limit: json["limit"],
|
|
1029
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
1030
|
+
scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
|
|
1031
|
+
window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
997
1034
|
function CheckFlagsResponseDataFromJSON(json) {
|
|
998
1035
|
return CheckFlagsResponseDataFromJSONTyped(json, false);
|
|
999
1036
|
}
|
|
@@ -1003,6 +1040,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
1003
1040
|
}
|
|
1004
1041
|
return {
|
|
1005
1042
|
creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
|
|
1043
|
+
creditSpendPolicies: json["credit_spend_policies"].map(
|
|
1044
|
+
CreditSpendPolicyFromJSON
|
|
1045
|
+
),
|
|
1006
1046
|
flags: json["flags"].map(CheckFlagResponseDataFromJSON),
|
|
1007
1047
|
plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
|
|
1008
1048
|
};
|
|
@@ -1131,7 +1171,55 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1131
1171
|
}
|
|
1132
1172
|
return balances;
|
|
1133
1173
|
};
|
|
1134
|
-
var
|
|
1174
|
+
var CreditSpendPoliciesFromJSON = (json) => {
|
|
1175
|
+
if (!Array.isArray(json)) {
|
|
1176
|
+
return [];
|
|
1177
|
+
}
|
|
1178
|
+
const policies = [];
|
|
1179
|
+
for (const raw of json) {
|
|
1180
|
+
if (raw == null || typeof raw !== "object") continue;
|
|
1181
|
+
const id = raw.id;
|
|
1182
|
+
const creditId = raw.credit_id ?? raw.creditId;
|
|
1183
|
+
const kind = raw.kind;
|
|
1184
|
+
const scope = raw.scope;
|
|
1185
|
+
const limit = raw.limit;
|
|
1186
|
+
if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
const policy = {
|
|
1190
|
+
id,
|
|
1191
|
+
creditId,
|
|
1192
|
+
kind,
|
|
1193
|
+
scope,
|
|
1194
|
+
limit,
|
|
1195
|
+
consumed: typeof raw.consumed === "number" ? raw.consumed : 0
|
|
1196
|
+
};
|
|
1197
|
+
if (typeof raw.label === "string") {
|
|
1198
|
+
policy.label = raw.label;
|
|
1199
|
+
}
|
|
1200
|
+
const window2 = raw.window;
|
|
1201
|
+
if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
|
|
1202
|
+
policy.window = { unit: window2.unit, count: window2.count };
|
|
1203
|
+
}
|
|
1204
|
+
const resetsAt = raw.resets_at ?? raw.resetsAt;
|
|
1205
|
+
if (typeof resetsAt === "string" || resetsAt instanceof Date) {
|
|
1206
|
+
const parsed = new Date(resetsAt);
|
|
1207
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
1208
|
+
policy.resetsAt = parsed;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
policies.push(policy);
|
|
1212
|
+
}
|
|
1213
|
+
return policies;
|
|
1214
|
+
};
|
|
1215
|
+
var creditSpendPoliciesEqual = (a, b) => {
|
|
1216
|
+
if (a.length !== b.length) return false;
|
|
1217
|
+
return a.every((x, i) => {
|
|
1218
|
+
const y = b[i];
|
|
1219
|
+
return x.id === y.id && x.creditId === y.creditId && x.kind === y.kind && x.scope === y.scope && x.label === y.label && x.limit === y.limit && x.consumed === y.consumed && x.resetsAt?.getTime() === y.resetsAt?.getTime() && x.window?.unit === y.window?.unit && x.window?.count === y.window?.count;
|
|
1220
|
+
});
|
|
1221
|
+
};
|
|
1222
|
+
var cacheVersion = "35d92bc6";
|
|
1135
1223
|
function contextString(context) {
|
|
1136
1224
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1137
1225
|
const sortedKeys = Object.keys(
|
|
@@ -1146,7 +1234,7 @@ function contextString(context) {
|
|
|
1146
1234
|
}, {});
|
|
1147
1235
|
return JSON.stringify(sortedContext);
|
|
1148
1236
|
}
|
|
1149
|
-
var version = "1.
|
|
1237
|
+
var version = "1.10.0";
|
|
1150
1238
|
var SINGLETON = {};
|
|
1151
1239
|
var models_exports = {};
|
|
1152
1240
|
__export(models_exports, {
|
|
@@ -1154,6 +1242,11 @@ __export(models_exports, {
|
|
|
1154
1242
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1155
1243
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1156
1244
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1245
|
+
BillingProviderType: () => BillingProviderType,
|
|
1246
|
+
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1247
|
+
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1248
|
+
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1249
|
+
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1157
1250
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1158
1251
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1159
1252
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
@@ -1166,10 +1259,30 @@ __export(models_exports, {
|
|
|
1166
1259
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1167
1260
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1168
1261
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1262
|
+
CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
|
|
1263
|
+
CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
|
|
1264
|
+
CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
|
|
1265
|
+
CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
|
|
1266
|
+
CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
|
|
1267
|
+
CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
|
|
1268
|
+
CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
|
|
1269
|
+
CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
|
|
1169
1270
|
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1170
1271
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1171
1272
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1172
1273
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1274
|
+
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1275
|
+
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1276
|
+
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
1277
|
+
CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
|
|
1278
|
+
DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
|
|
1279
|
+
DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
|
|
1280
|
+
DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
|
|
1281
|
+
DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
|
|
1282
|
+
DeleteResponseFromJSON: () => DeleteResponseFromJSON,
|
|
1283
|
+
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1284
|
+
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1285
|
+
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1173
1286
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1174
1287
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1175
1288
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1178,6 +1291,10 @@ __export(models_exports, {
|
|
|
1178
1291
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1179
1292
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1180
1293
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1294
|
+
GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
|
|
1295
|
+
GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
|
|
1296
|
+
GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
|
|
1297
|
+
GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
|
|
1181
1298
|
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1182
1299
|
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1183
1300
|
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
@@ -1187,15 +1304,42 @@ __export(models_exports, {
|
|
|
1187
1304
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1188
1305
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1189
1306
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1307
|
+
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1308
|
+
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1309
|
+
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1310
|
+
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1311
|
+
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1312
|
+
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1313
|
+
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
1314
|
+
SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
|
|
1315
|
+
UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
|
|
1316
|
+
UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
|
|
1317
|
+
UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
|
|
1318
|
+
UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
|
|
1319
|
+
UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
|
|
1320
|
+
UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
|
|
1321
|
+
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1322
|
+
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1190
1323
|
instanceOfApiError: () => instanceOfApiError,
|
|
1324
|
+
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1191
1325
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1192
1326
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1193
1327
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1328
|
+
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1329
|
+
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1194
1330
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1331
|
+
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1332
|
+
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1333
|
+
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1195
1334
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1196
1335
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1336
|
+
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1197
1337
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1198
|
-
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1338
|
+
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1339
|
+
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1340
|
+
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1341
|
+
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1342
|
+
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
1199
1343
|
});
|
|
1200
1344
|
function instanceOfApiError(value) {
|
|
1201
1345
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
@@ -1223,6 +1367,34 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1223
1367
|
error: value["error"]
|
|
1224
1368
|
};
|
|
1225
1369
|
}
|
|
1370
|
+
var BillingProviderType = {
|
|
1371
|
+
Metronome: "metronome",
|
|
1372
|
+
Orb: "orb",
|
|
1373
|
+
Schematic: "schematic",
|
|
1374
|
+
Stripe: "stripe"
|
|
1375
|
+
};
|
|
1376
|
+
function instanceOfBillingProviderType(value) {
|
|
1377
|
+
for (const key in BillingProviderType) {
|
|
1378
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1379
|
+
if (BillingProviderType[key] === value) {
|
|
1380
|
+
return true;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
return false;
|
|
1385
|
+
}
|
|
1386
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1387
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1388
|
+
}
|
|
1389
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1390
|
+
return json;
|
|
1391
|
+
}
|
|
1392
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1393
|
+
return value;
|
|
1394
|
+
}
|
|
1395
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1396
|
+
return value;
|
|
1397
|
+
}
|
|
1226
1398
|
function instanceOfCompanyDiscountResponseData(value) {
|
|
1227
1399
|
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1228
1400
|
return false;
|
|
@@ -1366,6 +1538,97 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1366
1538
|
)
|
|
1367
1539
|
};
|
|
1368
1540
|
}
|
|
1541
|
+
function instanceOfCompanyPaymentMethodResponseData(value) {
|
|
1542
|
+
if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
|
|
1543
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1544
|
+
return false;
|
|
1545
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1546
|
+
if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
|
|
1547
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
1548
|
+
return true;
|
|
1549
|
+
}
|
|
1550
|
+
function CompanyPaymentMethodResponseDataFromJSON(json) {
|
|
1551
|
+
return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1552
|
+
}
|
|
1553
|
+
function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1554
|
+
if (json == null) {
|
|
1555
|
+
return json;
|
|
1556
|
+
}
|
|
1557
|
+
return {
|
|
1558
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1559
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1560
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1561
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1562
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1563
|
+
canRemove: json["can_remove"],
|
|
1564
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1565
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1566
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1567
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1568
|
+
externalId: json["external_id"],
|
|
1569
|
+
id: json["id"],
|
|
1570
|
+
isDefault: json["is_default"],
|
|
1571
|
+
type: json["type"]
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
function CompanyPaymentMethodResponseDataToJSON(json) {
|
|
1575
|
+
return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
|
|
1576
|
+
}
|
|
1577
|
+
function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1578
|
+
if (value == null) {
|
|
1579
|
+
return value;
|
|
1580
|
+
}
|
|
1581
|
+
return {
|
|
1582
|
+
account_last4: value["accountLast4"],
|
|
1583
|
+
account_name: value["accountName"],
|
|
1584
|
+
bank_name: value["bankName"],
|
|
1585
|
+
billing_email: value["billingEmail"],
|
|
1586
|
+
billing_name: value["billingName"],
|
|
1587
|
+
can_remove: value["canRemove"],
|
|
1588
|
+
card_brand: value["cardBrand"],
|
|
1589
|
+
card_exp_month: value["cardExpMonth"],
|
|
1590
|
+
card_exp_year: value["cardExpYear"],
|
|
1591
|
+
card_last4: value["cardLast4"],
|
|
1592
|
+
external_id: value["externalId"],
|
|
1593
|
+
id: value["id"],
|
|
1594
|
+
is_default: value["isDefault"],
|
|
1595
|
+
type: value["type"]
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
function instanceOfCompanyPaymentMethodsResponseData(value) {
|
|
1599
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
1600
|
+
if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
|
|
1601
|
+
return false;
|
|
1602
|
+
return true;
|
|
1603
|
+
}
|
|
1604
|
+
function CompanyPaymentMethodsResponseDataFromJSON(json) {
|
|
1605
|
+
return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
|
|
1606
|
+
}
|
|
1607
|
+
function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1608
|
+
if (json == null) {
|
|
1609
|
+
return json;
|
|
1610
|
+
}
|
|
1611
|
+
return {
|
|
1612
|
+
count: json["count"],
|
|
1613
|
+
paymentMethods: json["payment_methods"].map(
|
|
1614
|
+
CompanyPaymentMethodResponseDataFromJSON
|
|
1615
|
+
)
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
function CompanyPaymentMethodsResponseDataToJSON(json) {
|
|
1619
|
+
return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
|
|
1620
|
+
}
|
|
1621
|
+
function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1622
|
+
if (value == null) {
|
|
1623
|
+
return value;
|
|
1624
|
+
}
|
|
1625
|
+
return {
|
|
1626
|
+
count: value["count"],
|
|
1627
|
+
payment_methods: value["paymentMethods"].map(
|
|
1628
|
+
CompanyPaymentMethodResponseDataToJSON
|
|
1629
|
+
)
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1369
1632
|
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1370
1633
|
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1371
1634
|
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
@@ -1415,6 +1678,122 @@ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminato
|
|
|
1415
1678
|
subtotal: value["subtotal"]
|
|
1416
1679
|
};
|
|
1417
1680
|
}
|
|
1681
|
+
function instanceOfSetupIntentResponseData(value) {
|
|
1682
|
+
if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
|
|
1683
|
+
return false;
|
|
1684
|
+
return true;
|
|
1685
|
+
}
|
|
1686
|
+
function SetupIntentResponseDataFromJSON(json) {
|
|
1687
|
+
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
1688
|
+
}
|
|
1689
|
+
function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1690
|
+
if (json == null) {
|
|
1691
|
+
return json;
|
|
1692
|
+
}
|
|
1693
|
+
return {
|
|
1694
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
1695
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
1696
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
1697
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
function SetupIntentResponseDataToJSON(json) {
|
|
1701
|
+
return SetupIntentResponseDataToJSONTyped(json, false);
|
|
1702
|
+
}
|
|
1703
|
+
function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1704
|
+
if (value == null) {
|
|
1705
|
+
return value;
|
|
1706
|
+
}
|
|
1707
|
+
return {
|
|
1708
|
+
account_id: value["accountId"],
|
|
1709
|
+
publishable_key: value["publishableKey"],
|
|
1710
|
+
schematic_publishable_key: value["schematicPublishableKey"],
|
|
1711
|
+
setup_intent_client_secret: value["setupIntentClientSecret"]
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
function instanceOfCreateSetupIntentResponse(value) {
|
|
1715
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1716
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1717
|
+
return true;
|
|
1718
|
+
}
|
|
1719
|
+
function CreateSetupIntentResponseFromJSON(json) {
|
|
1720
|
+
return CreateSetupIntentResponseFromJSONTyped(json, false);
|
|
1721
|
+
}
|
|
1722
|
+
function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1723
|
+
if (json == null) {
|
|
1724
|
+
return json;
|
|
1725
|
+
}
|
|
1726
|
+
return {
|
|
1727
|
+
data: SetupIntentResponseDataFromJSON(json["data"]),
|
|
1728
|
+
params: json["params"]
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
function CreateSetupIntentResponseToJSON(json) {
|
|
1732
|
+
return CreateSetupIntentResponseToJSONTyped(json, false);
|
|
1733
|
+
}
|
|
1734
|
+
function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1735
|
+
if (value == null) {
|
|
1736
|
+
return value;
|
|
1737
|
+
}
|
|
1738
|
+
return {
|
|
1739
|
+
data: SetupIntentResponseDataToJSON(value["data"]),
|
|
1740
|
+
params: value["params"]
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
function instanceOfDeleteResponse(value) {
|
|
1744
|
+
return true;
|
|
1745
|
+
}
|
|
1746
|
+
function DeleteResponseFromJSON(json) {
|
|
1747
|
+
return DeleteResponseFromJSONTyped(json, false);
|
|
1748
|
+
}
|
|
1749
|
+
function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1750
|
+
if (json == null) {
|
|
1751
|
+
return json;
|
|
1752
|
+
}
|
|
1753
|
+
return {
|
|
1754
|
+
deleted: json["deleted"] == null ? void 0 : json["deleted"]
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
function DeleteResponseToJSON(json) {
|
|
1758
|
+
return DeleteResponseToJSONTyped(json, false);
|
|
1759
|
+
}
|
|
1760
|
+
function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1761
|
+
if (value == null) {
|
|
1762
|
+
return value;
|
|
1763
|
+
}
|
|
1764
|
+
return {
|
|
1765
|
+
deleted: value["deleted"]
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
function instanceOfDeletePaymentMethodResponse(value) {
|
|
1769
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1770
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1771
|
+
return true;
|
|
1772
|
+
}
|
|
1773
|
+
function DeletePaymentMethodResponseFromJSON(json) {
|
|
1774
|
+
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
1775
|
+
}
|
|
1776
|
+
function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1777
|
+
if (json == null) {
|
|
1778
|
+
return json;
|
|
1779
|
+
}
|
|
1780
|
+
return {
|
|
1781
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
1782
|
+
params: json["params"]
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
function DeletePaymentMethodResponseToJSON(json) {
|
|
1786
|
+
return DeletePaymentMethodResponseToJSONTyped(json, false);
|
|
1787
|
+
}
|
|
1788
|
+
function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1789
|
+
if (value == null) {
|
|
1790
|
+
return value;
|
|
1791
|
+
}
|
|
1792
|
+
return {
|
|
1793
|
+
data: DeleteResponseToJSON(value["data"]),
|
|
1794
|
+
params: value["params"]
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1418
1797
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1419
1798
|
return true;
|
|
1420
1799
|
}
|
|
@@ -1473,6 +1852,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1473
1852
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1474
1853
|
};
|
|
1475
1854
|
}
|
|
1855
|
+
function instanceOfGetCompanyPaymentMethodsResponse(value) {
|
|
1856
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1857
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1858
|
+
return true;
|
|
1859
|
+
}
|
|
1860
|
+
function GetCompanyPaymentMethodsResponseFromJSON(json) {
|
|
1861
|
+
return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
|
|
1862
|
+
}
|
|
1863
|
+
function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1864
|
+
if (json == null) {
|
|
1865
|
+
return json;
|
|
1866
|
+
}
|
|
1867
|
+
return {
|
|
1868
|
+
data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
|
|
1869
|
+
params: json["params"]
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
function GetCompanyPaymentMethodsResponseToJSON(json) {
|
|
1873
|
+
return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
|
|
1874
|
+
}
|
|
1875
|
+
function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1876
|
+
if (value == null) {
|
|
1877
|
+
return value;
|
|
1878
|
+
}
|
|
1879
|
+
return {
|
|
1880
|
+
data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
|
|
1881
|
+
params: value["params"]
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1476
1884
|
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1477
1885
|
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1478
1886
|
if (!("params" in value) || value["params"] === void 0) return false;
|
|
@@ -1502,6 +1910,134 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
|
|
|
1502
1910
|
params: value["params"]
|
|
1503
1911
|
};
|
|
1504
1912
|
}
|
|
1913
|
+
function instanceOfPaymentMethodResponseData(value) {
|
|
1914
|
+
if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
|
|
1915
|
+
if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
|
|
1916
|
+
return false;
|
|
1917
|
+
if (!("environmentId" in value) || value["environmentId"] === void 0)
|
|
1918
|
+
return false;
|
|
1919
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1920
|
+
return false;
|
|
1921
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1922
|
+
if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
|
|
1923
|
+
return false;
|
|
1924
|
+
if (!("providerType" in value) || value["providerType"] === void 0)
|
|
1925
|
+
return false;
|
|
1926
|
+
if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
|
|
1927
|
+
return true;
|
|
1928
|
+
}
|
|
1929
|
+
function PaymentMethodResponseDataFromJSON(json) {
|
|
1930
|
+
return PaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1931
|
+
}
|
|
1932
|
+
function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1933
|
+
if (json == null) {
|
|
1934
|
+
return json;
|
|
1935
|
+
}
|
|
1936
|
+
return {
|
|
1937
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1938
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1939
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1940
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1941
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1942
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1943
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1944
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1945
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1946
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
1947
|
+
createdAt: new Date(json["created_at"]),
|
|
1948
|
+
customerExternalId: json["customer_external_id"],
|
|
1949
|
+
environmentId: json["environment_id"],
|
|
1950
|
+
externalId: json["external_id"],
|
|
1951
|
+
id: json["id"],
|
|
1952
|
+
paymentMethodType: json["payment_method_type"],
|
|
1953
|
+
providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
|
|
1954
|
+
updatedAt: new Date(json["updated_at"])
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
function PaymentMethodResponseDataToJSON(json) {
|
|
1958
|
+
return PaymentMethodResponseDataToJSONTyped(json, false);
|
|
1959
|
+
}
|
|
1960
|
+
function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1961
|
+
if (value == null) {
|
|
1962
|
+
return value;
|
|
1963
|
+
}
|
|
1964
|
+
return {
|
|
1965
|
+
account_last4: value["accountLast4"],
|
|
1966
|
+
account_name: value["accountName"],
|
|
1967
|
+
bank_name: value["bankName"],
|
|
1968
|
+
billing_email: value["billingEmail"],
|
|
1969
|
+
billing_name: value["billingName"],
|
|
1970
|
+
card_brand: value["cardBrand"],
|
|
1971
|
+
card_exp_month: value["cardExpMonth"],
|
|
1972
|
+
card_exp_year: value["cardExpYear"],
|
|
1973
|
+
card_last4: value["cardLast4"],
|
|
1974
|
+
company_id: value["companyId"],
|
|
1975
|
+
created_at: value["createdAt"].toISOString(),
|
|
1976
|
+
customer_external_id: value["customerExternalId"],
|
|
1977
|
+
environment_id: value["environmentId"],
|
|
1978
|
+
external_id: value["externalId"],
|
|
1979
|
+
id: value["id"],
|
|
1980
|
+
payment_method_type: value["paymentMethodType"],
|
|
1981
|
+
provider_type: BillingProviderTypeToJSON2(value["providerType"]),
|
|
1982
|
+
updated_at: value["updatedAt"].toISOString()
|
|
1983
|
+
};
|
|
1984
|
+
}
|
|
1985
|
+
function instanceOfUpdatePaymentMethodRequestBody(value) {
|
|
1986
|
+
if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
|
|
1987
|
+
return false;
|
|
1988
|
+
return true;
|
|
1989
|
+
}
|
|
1990
|
+
function UpdatePaymentMethodRequestBodyFromJSON(json) {
|
|
1991
|
+
return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
|
|
1992
|
+
}
|
|
1993
|
+
function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1994
|
+
if (json == null) {
|
|
1995
|
+
return json;
|
|
1996
|
+
}
|
|
1997
|
+
return {
|
|
1998
|
+
paymentMethodId: json["payment_method_id"]
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
2002
|
+
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
2003
|
+
}
|
|
2004
|
+
function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2005
|
+
if (value == null) {
|
|
2006
|
+
return value;
|
|
2007
|
+
}
|
|
2008
|
+
return {
|
|
2009
|
+
payment_method_id: value["paymentMethodId"]
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
function instanceOfUpdatePaymentMethodResponse(value) {
|
|
2013
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2014
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2015
|
+
return true;
|
|
2016
|
+
}
|
|
2017
|
+
function UpdatePaymentMethodResponseFromJSON(json) {
|
|
2018
|
+
return UpdatePaymentMethodResponseFromJSONTyped(json, false);
|
|
2019
|
+
}
|
|
2020
|
+
function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2021
|
+
if (json == null) {
|
|
2022
|
+
return json;
|
|
2023
|
+
}
|
|
2024
|
+
return {
|
|
2025
|
+
data: PaymentMethodResponseDataFromJSON(json["data"]),
|
|
2026
|
+
params: json["params"]
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
function UpdatePaymentMethodResponseToJSON(json) {
|
|
2030
|
+
return UpdatePaymentMethodResponseToJSONTyped(json, false);
|
|
2031
|
+
}
|
|
2032
|
+
function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2033
|
+
if (value == null) {
|
|
2034
|
+
return value;
|
|
2035
|
+
}
|
|
2036
|
+
return {
|
|
2037
|
+
data: PaymentMethodResponseDataToJSON(value["data"]),
|
|
2038
|
+
params: value["params"]
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
1505
2041
|
var DEFAULT_INVOICE_QUERY = {};
|
|
1506
2042
|
function normalizeInvoiceQuery(query) {
|
|
1507
2043
|
const { includePending, ...rest } = query;
|
|
@@ -1826,12 +2362,46 @@ var SchematicBillingClient = class {
|
|
|
1826
2362
|
return GetCompanyUpcomingInvoiceResponseFromJSON(body).data;
|
|
1827
2363
|
});
|
|
1828
2364
|
}
|
|
2365
|
+
fetchPaymentMethods() {
|
|
2366
|
+
const path = "/company/payment-methods";
|
|
2367
|
+
return this.session.request(path).then((body) => {
|
|
2368
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
2369
|
+
throw new Error(`Malformed response from ${path}`);
|
|
2370
|
+
}
|
|
2371
|
+
const data = body.data;
|
|
2372
|
+
if (data == null || data.payment_methods == null) {
|
|
2373
|
+
return [];
|
|
2374
|
+
}
|
|
2375
|
+
return GetCompanyPaymentMethodsResponseFromJSON(body).data.paymentMethods;
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
createSetupIntent() {
|
|
2379
|
+
const path = "/components/setup-intent";
|
|
2380
|
+
return this.session.request(path, { method: "POST" }).then((body) => {
|
|
2381
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
2382
|
+
throw new Error(`Malformed response from ${path}`);
|
|
2383
|
+
}
|
|
2384
|
+
return CreateSetupIntentResponseFromJSON(body).data;
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
updatePaymentMethod(externalId) {
|
|
2388
|
+
return this.session.request("/checkout/paymentmethod/update", {
|
|
2389
|
+
method: "POST",
|
|
2390
|
+
body: { payment_method_id: externalId }
|
|
2391
|
+
}).then(() => void 0);
|
|
2392
|
+
}
|
|
2393
|
+
deletePaymentMethod(id) {
|
|
2394
|
+
return this.session.request(`/checkout/paymentmethod/${encodeURIComponent(id)}`, {
|
|
2395
|
+
method: "DELETE"
|
|
2396
|
+
}).then(() => void 0);
|
|
2397
|
+
}
|
|
1829
2398
|
};
|
|
1830
2399
|
var anonymousIdKey = "schematicId";
|
|
1831
2400
|
var flagStateCachePrefix = "schematicCache";
|
|
1832
2401
|
var flagStateCacheMaxContexts = 10;
|
|
1833
2402
|
var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
1834
2403
|
var emptyCreditBalances = Object.freeze({});
|
|
2404
|
+
var emptyCreditSpendPolicies = [];
|
|
1835
2405
|
var Schematic = class {
|
|
1836
2406
|
_additionalHeaders = {};
|
|
1837
2407
|
apiKey;
|
|
@@ -1849,6 +2419,7 @@ var Schematic = class {
|
|
|
1849
2419
|
isPendingListeners = /* @__PURE__ */ new Set();
|
|
1850
2420
|
planListeners = /* @__PURE__ */ new Set();
|
|
1851
2421
|
creditBalanceListeners = /* @__PURE__ */ new Set();
|
|
2422
|
+
creditSpendPolicyListeners = /* @__PURE__ */ new Set();
|
|
1852
2423
|
storage;
|
|
1853
2424
|
persistFlagState = true;
|
|
1854
2425
|
flagStateCacheKey;
|
|
@@ -1859,6 +2430,7 @@ var Schematic = class {
|
|
|
1859
2430
|
featureUsageEventMap = {};
|
|
1860
2431
|
planChecks = {};
|
|
1861
2432
|
creditBalances = {};
|
|
2433
|
+
creditSpendPolicies = {};
|
|
1862
2434
|
webSocketUrl = "wss://api.schematichq.com";
|
|
1863
2435
|
webSocketConnectionTimeout = 1e4;
|
|
1864
2436
|
webSocketReconnect = true;
|
|
@@ -2251,6 +2823,19 @@ var Schematic = class {
|
|
|
2251
2823
|
this.notifyCreditBalanceListeners(merged);
|
|
2252
2824
|
}
|
|
2253
2825
|
}
|
|
2826
|
+
if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
|
|
2827
|
+
const contextStr = contextString(context);
|
|
2828
|
+
const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
|
|
2829
|
+
const previous = this.creditSpendPolicies[contextStr] ?? [];
|
|
2830
|
+
if (!creditSpendPoliciesEqual(previous, next)) {
|
|
2831
|
+
this.creditSpendPolicies[contextStr] = next;
|
|
2832
|
+
this.debug(
|
|
2833
|
+
`WebSocket credit spend policy update received. Notifying listeners`,
|
|
2834
|
+
{ creditSpendPolicies: next }
|
|
2835
|
+
);
|
|
2836
|
+
this.notifyCreditSpendPolicyListeners(next);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2254
2839
|
this.persistContextToCache(contextString(context));
|
|
2255
2840
|
this.flushContextDependentEventQueue();
|
|
2256
2841
|
this.setIsPending(false);
|
|
@@ -2752,10 +3337,19 @@ var Schematic = class {
|
|
|
2752
3337
|
this.creditBalances[contextStr] = balances;
|
|
2753
3338
|
}
|
|
2754
3339
|
}
|
|
3340
|
+
let revivedCreditSpendPolicies;
|
|
3341
|
+
if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
|
|
3342
|
+
const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
|
|
3343
|
+
if (policies.length > 0) {
|
|
3344
|
+
revivedCreditSpendPolicies = policies;
|
|
3345
|
+
this.creditSpendPolicies[contextStr] = policies;
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
2755
3348
|
fresh[contextStr] = {
|
|
2756
3349
|
checks: revivedChecks,
|
|
2757
3350
|
plan: revivedPlan,
|
|
2758
3351
|
creditBalances: revivedCreditBalances,
|
|
3352
|
+
creditSpendPolicies: revivedCreditSpendPolicies,
|
|
2759
3353
|
updatedAt: entry.updatedAt
|
|
2760
3354
|
};
|
|
2761
3355
|
contextsLoaded += 1;
|
|
@@ -2769,7 +3363,8 @@ var Schematic = class {
|
|
|
2769
3363
|
const checksForContext = this.checks[contextStr];
|
|
2770
3364
|
const planForContext = this.planChecks[contextStr];
|
|
2771
3365
|
const creditBalancesForContext = this.creditBalances[contextStr];
|
|
2772
|
-
|
|
3366
|
+
const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
|
|
3367
|
+
if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
|
|
2773
3368
|
return;
|
|
2774
3369
|
}
|
|
2775
3370
|
if (this.cachedFlagState === null) {
|
|
@@ -2788,6 +3383,7 @@ var Schematic = class {
|
|
|
2788
3383
|
checks: cleanChecks,
|
|
2789
3384
|
plan: planForContext,
|
|
2790
3385
|
creditBalances: creditBalancesForContext,
|
|
3386
|
+
creditSpendPolicies: creditSpendPoliciesForContext,
|
|
2791
3387
|
updatedAt: Date.now()
|
|
2792
3388
|
};
|
|
2793
3389
|
const entries = Object.entries(this.cachedFlagState.contexts);
|
|
@@ -2804,6 +3400,9 @@ var Schematic = class {
|
|
|
2804
3400
|
for (const key of Object.keys(this.creditBalances)) {
|
|
2805
3401
|
if (!survivorKeys.has(key)) delete this.creditBalances[key];
|
|
2806
3402
|
}
|
|
3403
|
+
for (const key of Object.keys(this.creditSpendPolicies)) {
|
|
3404
|
+
if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
|
|
3405
|
+
}
|
|
2807
3406
|
this.cachedFlagState = {
|
|
2808
3407
|
version: cacheVersion,
|
|
2809
3408
|
contexts: Object.fromEntries(survivors)
|
|
@@ -3398,6 +3997,18 @@ var Schematic = class {
|
|
|
3398
3997
|
const contextStr = contextString(this.context);
|
|
3399
3998
|
return this.creditBalances[contextStr]?.[creditId];
|
|
3400
3999
|
};
|
|
4000
|
+
/** Get every credit spend policy binding the current context, company-scope first */
|
|
4001
|
+
getCreditSpendPolicies = () => {
|
|
4002
|
+
const contextStr = contextString(this.context);
|
|
4003
|
+
return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
|
|
4004
|
+
};
|
|
4005
|
+
/** Get the spend policies binding a single credit type in the current context */
|
|
4006
|
+
getCreditSpendPoliciesForCredit = (creditId) => {
|
|
4007
|
+
const policies = this.getCreditSpendPolicies().filter(
|
|
4008
|
+
(policy) => policy.creditId === creditId
|
|
4009
|
+
);
|
|
4010
|
+
return policies.length > 0 ? policies : emptyCreditSpendPolicies;
|
|
4011
|
+
};
|
|
3401
4012
|
// flag checks state
|
|
3402
4013
|
getFlagCheck = (flagKey) => {
|
|
3403
4014
|
const contextStr = contextString(this.context);
|
|
@@ -3464,6 +4075,13 @@ var Schematic = class {
|
|
|
3464
4075
|
this.creditBalanceListeners.delete(listener);
|
|
3465
4076
|
};
|
|
3466
4077
|
};
|
|
4078
|
+
/** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
|
|
4079
|
+
addCreditSpendPolicyListener = (listener) => {
|
|
4080
|
+
this.creditSpendPolicyListeners.add(listener);
|
|
4081
|
+
return () => {
|
|
4082
|
+
this.creditSpendPolicyListeners.delete(listener);
|
|
4083
|
+
};
|
|
4084
|
+
};
|
|
3467
4085
|
notifyFlagCheckListeners = (flagKey, check) => {
|
|
3468
4086
|
const listeners = this.flagCheckListeners?.[flagKey] ?? [];
|
|
3469
4087
|
if (listeners.size > 0) {
|
|
@@ -3527,6 +4145,16 @@ var Schematic = class {
|
|
|
3527
4145
|
});
|
|
3528
4146
|
});
|
|
3529
4147
|
};
|
|
4148
|
+
notifyCreditSpendPolicyListeners = (value) => {
|
|
4149
|
+
const listeners = this.creditSpendPolicyListeners ?? [];
|
|
4150
|
+
listeners.forEach((listener) => {
|
|
4151
|
+
if (listener.length > 0) {
|
|
4152
|
+
listener(value);
|
|
4153
|
+
return;
|
|
4154
|
+
}
|
|
4155
|
+
listener();
|
|
4156
|
+
});
|
|
4157
|
+
};
|
|
3530
4158
|
notifyCreditBalanceListeners = (value) => {
|
|
3531
4159
|
const listeners = this.creditBalanceListeners ?? [];
|
|
3532
4160
|
if (listeners.size > 0) {
|
|
@@ -3946,6 +4574,10 @@ var BillingStore = class {
|
|
|
3946
4574
|
() => this._client.fetchUpcomingInvoice(),
|
|
3947
4575
|
{ readiness }
|
|
3948
4576
|
);
|
|
4577
|
+
this.paymentMethods = new KeyedResource(
|
|
4578
|
+
() => this._client.fetchPaymentMethods(),
|
|
4579
|
+
{ readiness }
|
|
4580
|
+
);
|
|
3949
4581
|
const held = { key: initialData.sessionKey };
|
|
3950
4582
|
if (initialData.invoices !== void 0) {
|
|
3951
4583
|
held.invoices = {
|
|
@@ -3960,7 +4592,10 @@ var BillingStore = class {
|
|
|
3960
4592
|
if (initialData.upcomingInvoice !== void 0) {
|
|
3961
4593
|
held.upcomingInvoice = initialData.upcomingInvoice;
|
|
3962
4594
|
}
|
|
3963
|
-
if (
|
|
4595
|
+
if (initialData.paymentMethods !== void 0) {
|
|
4596
|
+
held.paymentMethods = initialData.paymentMethods;
|
|
4597
|
+
}
|
|
4598
|
+
if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0) {
|
|
3964
4599
|
this._held = held;
|
|
3965
4600
|
this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
|
|
3966
4601
|
}
|
|
@@ -3968,6 +4603,7 @@ var BillingStore = class {
|
|
|
3968
4603
|
_client;
|
|
3969
4604
|
invoices;
|
|
3970
4605
|
upcomingInvoice;
|
|
4606
|
+
paymentMethods;
|
|
3971
4607
|
_pageSize;
|
|
3972
4608
|
_unsubscribe;
|
|
3973
4609
|
_connected = false;
|
|
@@ -4043,6 +4679,9 @@ var BillingStore = class {
|
|
|
4043
4679
|
if (held.upcomingInvoice !== void 0) {
|
|
4044
4680
|
this.upcomingInvoice.seed(SINGLETON, held.upcomingInvoice);
|
|
4045
4681
|
}
|
|
4682
|
+
if (held.paymentMethods !== void 0) {
|
|
4683
|
+
this.paymentMethods.seed(SINGLETON, held.paymentMethods);
|
|
4684
|
+
}
|
|
4046
4685
|
this._seedKey = held.key;
|
|
4047
4686
|
this._seeded = true;
|
|
4048
4687
|
}
|
|
@@ -4104,9 +4743,46 @@ var BillingStore = class {
|
|
|
4104
4743
|
};
|
|
4105
4744
|
});
|
|
4106
4745
|
}
|
|
4746
|
+
/**
|
|
4747
|
+
* Makes the payment method `externalId` the company's default, then
|
|
4748
|
+
* reloads the list so it says so. Rejects with the client's error when
|
|
4749
|
+
* the write fails; a reload that fails afterwards lands on the list's
|
|
4750
|
+
* `error`, since the write itself went through.
|
|
4751
|
+
*/
|
|
4752
|
+
async setDefaultPaymentMethod(externalId) {
|
|
4753
|
+
await this._client.updatePaymentMethod(externalId);
|
|
4754
|
+
await this._reloadPaymentMethods();
|
|
4755
|
+
}
|
|
4756
|
+
/** Removes the payment method `id`, then reloads the list. Rejects as `setDefaultPaymentMethod` does. */
|
|
4757
|
+
async removePaymentMethod(id) {
|
|
4758
|
+
await this._client.deletePaymentMethod(id);
|
|
4759
|
+
await this._reloadPaymentMethods();
|
|
4760
|
+
}
|
|
4761
|
+
/**
|
|
4762
|
+
* Mints a setup intent for adding a payment method. Nothing in the store
|
|
4763
|
+
* changes until the provider confirms it and the host reloads the list,
|
|
4764
|
+
* so this is a pass-through to the client.
|
|
4765
|
+
*/
|
|
4766
|
+
createSetupIntent() {
|
|
4767
|
+
return this._client.createSetupIntent();
|
|
4768
|
+
}
|
|
4107
4769
|
dispose() {
|
|
4108
4770
|
this._unsubscribe?.();
|
|
4109
4771
|
}
|
|
4772
|
+
/**
|
|
4773
|
+
* After a write. A list nobody has read is left alone: it loads fresh
|
|
4774
|
+
* when someone does. One that is loaded, or subscribed and waiting on a
|
|
4775
|
+
* failed load, is fetched again; `refetch` never rejects.
|
|
4776
|
+
*/
|
|
4777
|
+
async _reloadPaymentMethods() {
|
|
4778
|
+
if (!this.paymentMethods.has(SINGLETON)) {
|
|
4779
|
+
return;
|
|
4780
|
+
}
|
|
4781
|
+
const resource = this.paymentMethods.get(SINGLETON);
|
|
4782
|
+
if (resource.snapshot.data !== void 0 || resource.subscriberCount > 0) {
|
|
4783
|
+
await resource.refetch();
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
4110
4786
|
/**
|
|
4111
4787
|
* Re-reads the window already loaded, in as many requests as the API's
|
|
4112
4788
|
* page cap needs. A window paged past that cap still comes back whole:
|
|
@@ -4146,7 +4822,8 @@ var BillingStore = class {
|
|
|
4146
4822
|
};
|
|
4147
4823
|
var RESOURCE_NAMES = [
|
|
4148
4824
|
"invoices",
|
|
4149
|
-
"upcomingInvoice"
|
|
4825
|
+
"upcomingInvoice",
|
|
4826
|
+
"paymentMethods"
|
|
4150
4827
|
];
|
|
4151
4828
|
|
|
4152
4829
|
// src/billing/context.tsx
|
|
@@ -4196,6 +4873,25 @@ var BillingDataContext = createContext2(
|
|
|
4196
4873
|
);
|
|
4197
4874
|
var MISSING_BILLING_SOURCE_MESSAGE = "Schematic billing hooks need a SchematicProvider with a session, billingClient, or initialData, or a BillingDataProvider.";
|
|
4198
4875
|
var missingSourceError = new Error(MISSING_BILLING_SOURCE_MESSAGE);
|
|
4876
|
+
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\`.`;
|
|
4877
|
+
var ACTION_NAMES = [
|
|
4878
|
+
"setDefaultPaymentMethod",
|
|
4879
|
+
"removePaymentMethod",
|
|
4880
|
+
"createSetupIntent"
|
|
4881
|
+
];
|
|
4882
|
+
function rejectingActions(reason, given = {}) {
|
|
4883
|
+
const actions = {};
|
|
4884
|
+
for (const name of ACTION_NAMES) {
|
|
4885
|
+
actions[name] = given[name] ?? (() => Promise.reject(reason(name)));
|
|
4886
|
+
}
|
|
4887
|
+
return actions;
|
|
4888
|
+
}
|
|
4889
|
+
var unavailableActions = rejectingActions(
|
|
4890
|
+
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name))
|
|
4891
|
+
);
|
|
4892
|
+
function actionsOf(source) {
|
|
4893
|
+
return source.actions ?? unavailableActions;
|
|
4894
|
+
}
|
|
4199
4895
|
var missingHandle = {
|
|
4200
4896
|
data: void 0,
|
|
4201
4897
|
error: missingSourceError,
|
|
@@ -4209,12 +4905,16 @@ var missingBillingSource = {
|
|
|
4209
4905
|
handle: () => missingHandle,
|
|
4210
4906
|
loadMoreInvoices: () => Promise.resolve(),
|
|
4211
4907
|
invalidateAll: () => {
|
|
4212
|
-
}
|
|
4908
|
+
},
|
|
4909
|
+
// The same error a read reports, so a write outside any provider names
|
|
4910
|
+
// the misconfiguration rather than a source that only reads.
|
|
4911
|
+
actions: rejectingActions(() => missingSourceError)
|
|
4213
4912
|
};
|
|
4214
4913
|
function useBillingDataSource() {
|
|
4215
4914
|
return useContext2(BillingDataContext) ?? missingBillingSource;
|
|
4216
4915
|
}
|
|
4217
4916
|
function BillingDataProvider({
|
|
4917
|
+
actions,
|
|
4218
4918
|
children,
|
|
4219
4919
|
data,
|
|
4220
4920
|
locale,
|
|
@@ -4228,6 +4928,10 @@ function BillingDataProvider({
|
|
|
4228
4928
|
const source = useMemo2(() => {
|
|
4229
4929
|
const handles = /* @__PURE__ */ new Map();
|
|
4230
4930
|
return {
|
|
4931
|
+
actions: rejectingActions(
|
|
4932
|
+
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
|
|
4933
|
+
actions
|
|
4934
|
+
),
|
|
4231
4935
|
subscribe: () => () => {
|
|
4232
4936
|
},
|
|
4233
4937
|
handle: (name) => {
|
|
@@ -4253,7 +4957,7 @@ function BillingDataProvider({
|
|
|
4253
4957
|
invalidateAll: () => {
|
|
4254
4958
|
}
|
|
4255
4959
|
};
|
|
4256
|
-
}, [data, onLoadMoreInvoices, onRefetch, status]);
|
|
4960
|
+
}, [actions, data, onLoadMoreInvoices, onRefetch, status]);
|
|
4257
4961
|
return /* @__PURE__ */ jsx2(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ jsx2(
|
|
4258
4962
|
SchematicI18nProvider,
|
|
4259
4963
|
{
|
|
@@ -4267,7 +4971,13 @@ function BillingDataProvider({
|
|
|
4267
4971
|
}
|
|
4268
4972
|
|
|
4269
4973
|
// src/billing/hooks.ts
|
|
4270
|
-
import {
|
|
4974
|
+
import {
|
|
4975
|
+
useCallback,
|
|
4976
|
+
useMemo as useMemo3,
|
|
4977
|
+
useRef,
|
|
4978
|
+
useState,
|
|
4979
|
+
useSyncExternalStore
|
|
4980
|
+
} from "react";
|
|
4271
4981
|
function useStableParams(params) {
|
|
4272
4982
|
const key = hashKey(params);
|
|
4273
4983
|
const ref = useRef({ key, params });
|
|
@@ -4301,6 +5011,48 @@ function useInvoices(query = DEFAULT_INVOICE_QUERY) {
|
|
|
4301
5011
|
function useUpcomingInvoice() {
|
|
4302
5012
|
return useBillingResource("upcomingInvoice", SINGLETON);
|
|
4303
5013
|
}
|
|
5014
|
+
var IDLE = { inflight: 0, error: void 0 };
|
|
5015
|
+
function usePaymentMethods() {
|
|
5016
|
+
const source = useBillingDataSource();
|
|
5017
|
+
const handle = useBillingResource("paymentMethods", SINGLETON);
|
|
5018
|
+
const [mutation, setMutation] = useState(IDLE);
|
|
5019
|
+
const run = useCallback(async (write) => {
|
|
5020
|
+
setMutation((m) => ({ inflight: m.inflight + 1, error: void 0 }));
|
|
5021
|
+
try {
|
|
5022
|
+
await write();
|
|
5023
|
+
} catch (cause) {
|
|
5024
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
5025
|
+
setMutation((m) => ({ inflight: m.inflight - 1, error }));
|
|
5026
|
+
throw error;
|
|
5027
|
+
}
|
|
5028
|
+
setMutation((m) => ({ inflight: m.inflight - 1, error: void 0 }));
|
|
5029
|
+
}, []);
|
|
5030
|
+
const setDefault = useCallback(
|
|
5031
|
+
(externalId) => run(() => actionsOf(source).setDefaultPaymentMethod(externalId)),
|
|
5032
|
+
[run, source]
|
|
5033
|
+
);
|
|
5034
|
+
const remove = useCallback(
|
|
5035
|
+
(id) => run(() => actionsOf(source).removePaymentMethod(id)),
|
|
5036
|
+
[run, source]
|
|
5037
|
+
);
|
|
5038
|
+
return useMemo3(
|
|
5039
|
+
() => ({
|
|
5040
|
+
...handle,
|
|
5041
|
+
setDefault,
|
|
5042
|
+
remove,
|
|
5043
|
+
isMutating: mutation.inflight > 0,
|
|
5044
|
+
mutationError: mutation.error
|
|
5045
|
+
}),
|
|
5046
|
+
[handle, mutation, remove, setDefault]
|
|
5047
|
+
);
|
|
5048
|
+
}
|
|
5049
|
+
function useSetupIntent() {
|
|
5050
|
+
const source = useBillingDataSource();
|
|
5051
|
+
return useMemo3(
|
|
5052
|
+
() => ({ create: () => actionsOf(source).createSetupIntent() }),
|
|
5053
|
+
[source]
|
|
5054
|
+
);
|
|
5055
|
+
}
|
|
4304
5056
|
function useInvalidateBillingData() {
|
|
4305
5057
|
return useBillingDataSource().invalidateAll;
|
|
4306
5058
|
}
|
|
@@ -4374,7 +5126,12 @@ function BillingProvider({
|
|
|
4374
5126
|
subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
|
|
4375
5127
|
handle,
|
|
4376
5128
|
loadMoreInvoices: (query) => store.loadMoreInvoices(query),
|
|
4377
|
-
invalidateAll: () => store.invalidateAll()
|
|
5129
|
+
invalidateAll: () => store.invalidateAll(),
|
|
5130
|
+
actions: {
|
|
5131
|
+
setDefaultPaymentMethod: (externalId) => store.setDefaultPaymentMethod(externalId),
|
|
5132
|
+
removePaymentMethod: (id) => store.removePaymentMethod(id),
|
|
5133
|
+
createSetupIntent: () => store.createSetupIntent()
|
|
5134
|
+
}
|
|
4378
5135
|
};
|
|
4379
5136
|
}, [store]);
|
|
4380
5137
|
const localized = /* @__PURE__ */ jsx3(
|
|
@@ -4420,7 +5177,7 @@ function staticSource(data) {
|
|
|
4420
5177
|
}
|
|
4421
5178
|
|
|
4422
5179
|
// src/version.ts
|
|
4423
|
-
var version2 = "1.
|
|
5180
|
+
var version2 = "1.10.0";
|
|
4424
5181
|
|
|
4425
5182
|
// src/context/schematic.tsx
|
|
4426
5183
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -4513,6 +5270,7 @@ var useSchematic = () => {
|
|
|
4513
5270
|
|
|
4514
5271
|
// src/hooks/schematic.ts
|
|
4515
5272
|
import { useMemo as useMemo6, useSyncExternalStore as useSyncExternalStore2, useCallback as useCallback2 } from "react";
|
|
5273
|
+
var emptyPolicies = [];
|
|
4516
5274
|
var useSchematicClient = (opts) => {
|
|
4517
5275
|
const schematic = useSchematic();
|
|
4518
5276
|
const { client } = opts ?? {};
|
|
@@ -4628,6 +5386,34 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
4628
5386
|
[balance, isPending]
|
|
4629
5387
|
);
|
|
4630
5388
|
};
|
|
5389
|
+
var useSchematicCreditSpendPolicies = (opts) => {
|
|
5390
|
+
const client = useSchematicClient(opts);
|
|
5391
|
+
const subscribe = useCallback2(
|
|
5392
|
+
(callback) => client.addCreditSpendPolicyListener(callback),
|
|
5393
|
+
[client]
|
|
5394
|
+
);
|
|
5395
|
+
const policies = useSyncExternalStore2(
|
|
5396
|
+
subscribe,
|
|
5397
|
+
() => client.getCreditSpendPolicies(),
|
|
5398
|
+
() => emptyPolicies
|
|
5399
|
+
);
|
|
5400
|
+
const isPendingSubscribe = useCallback2(
|
|
5401
|
+
(callback) => client.addIsPendingListener(callback),
|
|
5402
|
+
[client]
|
|
5403
|
+
);
|
|
5404
|
+
const isPending = useSyncExternalStore2(
|
|
5405
|
+
isPendingSubscribe,
|
|
5406
|
+
() => client.getIsPending(),
|
|
5407
|
+
() => true
|
|
5408
|
+
);
|
|
5409
|
+
return useMemo6(
|
|
5410
|
+
() => ({
|
|
5411
|
+
policies,
|
|
5412
|
+
isLoading: policies.length === 0 && isPending
|
|
5413
|
+
}),
|
|
5414
|
+
[policies, isPending]
|
|
5415
|
+
);
|
|
5416
|
+
};
|
|
4631
5417
|
var useSchematicIsPending = (opts) => {
|
|
4632
5418
|
const client = useSchematicClient(opts);
|
|
4633
5419
|
const subscribe = useCallback2(
|
|
@@ -4655,9 +5441,11 @@ export {
|
|
|
4655
5441
|
useBillingDataSource,
|
|
4656
5442
|
useInvalidateBillingData,
|
|
4657
5443
|
useInvoices,
|
|
5444
|
+
usePaymentMethods,
|
|
4658
5445
|
useSchematic,
|
|
4659
5446
|
useSchematicContext,
|
|
4660
5447
|
useSchematicCreditBalance,
|
|
5448
|
+
useSchematicCreditSpendPolicies,
|
|
4661
5449
|
useSchematicEntitlement,
|
|
4662
5450
|
useSchematicEvents,
|
|
4663
5451
|
useSchematicFlag,
|
|
@@ -4667,6 +5455,7 @@ export {
|
|
|
4667
5455
|
useSchematicPlan,
|
|
4668
5456
|
useSchematicStrings,
|
|
4669
5457
|
useSchematicTranslate,
|
|
5458
|
+
useSetupIntent,
|
|
4670
5459
|
useUpcomingInvoice
|
|
4671
5460
|
};
|
|
4672
5461
|
/*! Bundled license information:
|