@schematichq/schematic-vue 1.5.0 → 1.7.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.
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  useSchematicClient: () => useSchematicClient,
29
29
  useSchematicContext: () => useSchematicContext,
30
30
  useSchematicCreditBalance: () => useSchematicCreditBalance,
31
+ useSchematicCreditSpendPolicies: () => useSchematicCreditSpendPolicies,
31
32
  useSchematicEntitlement: () => useSchematicEntitlement,
32
33
  useSchematicEvents: () => useSchematicEvents,
33
34
  useSchematicFlag: () => useSchematicFlag,
@@ -36,7 +37,7 @@ __export(index_exports, {
36
37
  });
37
38
  module.exports = __toCommonJS(index_exports);
38
39
 
39
- // node_modules/@schematichq/schematic-js/dist/schematic.esm.js
40
+ // node_modules/.pnpm/@schematichq+schematic-js@1.10.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
40
41
  var __create = Object.create;
41
42
  var __defProp2 = Object.defineProperty;
42
43
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -50,6 +51,10 @@ var __commonJS = (cb, mod) => function __require() {
50
51
  throw mod = 0, e;
51
52
  }
52
53
  };
54
+ var __export2 = (target, all) => {
55
+ for (var name in all)
56
+ __defProp2(target, name, { get: all[name], enumerable: true });
57
+ };
53
58
  var __copyProps2 = (to, from, except, desc) => {
54
59
  if (from && typeof from === "object" || typeof from === "function") {
55
60
  for (let key of __getOwnPropNames2(from))
@@ -67,7 +72,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
67
72
  mod
68
73
  ));
69
74
  var require_browser_polyfill = __commonJS({
70
- "node_modules/cross-fetch/dist/browser-polyfill.js"(exports) {
75
+ "node_modules/.pnpm/cross-fetch@4.1.0/node_modules/cross-fetch/dist/browser-polyfill.js"(exports) {
71
76
  (function(self2) {
72
77
  var irrelevant = (function(exports2) {
73
78
  var g = typeof globalThis !== "undefined" && globalThis || typeof self2 !== "undefined" && self2 || // eslint-disable-next-line no-undef
@@ -651,6 +656,18 @@ function MetricPeriodMonthResetFromJSON(json) {
651
656
  function MetricPeriodMonthResetFromJSONTyped(json, ignoreDiscriminator) {
652
657
  return json;
653
658
  }
659
+ function WarningTierFromJSON(json) {
660
+ return WarningTierFromJSONTyped(json, false);
661
+ }
662
+ function WarningTierFromJSONTyped(json, ignoreDiscriminator) {
663
+ if (json == null) {
664
+ return json;
665
+ }
666
+ return {
667
+ key: json["key"],
668
+ value: json["value"]
669
+ };
670
+ }
654
671
  function MetricPeriodFromJSON(json) {
655
672
  return MetricPeriodFromJSONTyped(json, false);
656
673
  }
@@ -682,7 +699,8 @@ function FeatureEntitlementFromJSONTyped(json, ignoreDiscriminator) {
682
699
  monthReset: json["month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON(json["month_reset"]),
683
700
  softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
684
701
  usage: json["usage"] == null ? void 0 : json["usage"],
685
- valueType: EntitlementValueTypeFromJSON(json["value_type"])
702
+ valueType: EntitlementValueTypeFromJSON(json["value_type"]),
703
+ warningTiers: json["warning_tiers"] == null ? void 0 : json["warning_tiers"].map(WarningTierFromJSON)
686
704
  };
687
705
  }
688
706
  function RuleTypeFromJSON(json) {
@@ -1010,6 +1028,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
1010
1028
  trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
1011
1029
  };
1012
1030
  }
1031
+ function CreditSpendPolicyScopeFromJSON(json) {
1032
+ return CreditSpendPolicyScopeFromJSONTyped(json, false);
1033
+ }
1034
+ function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
1035
+ return json;
1036
+ }
1037
+ function CreditSpendWindowFromJSON(json) {
1038
+ return CreditSpendWindowFromJSONTyped(json, false);
1039
+ }
1040
+ function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
1041
+ if (json == null) {
1042
+ return json;
1043
+ }
1044
+ return {
1045
+ count: json["count"],
1046
+ unit: json["unit"]
1047
+ };
1048
+ }
1049
+ function CreditSpendPolicyFromJSON(json) {
1050
+ return CreditSpendPolicyFromJSONTyped(json, false);
1051
+ }
1052
+ function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
1053
+ if (json == null) {
1054
+ return json;
1055
+ }
1056
+ return {
1057
+ consumed: json["consumed"] == null ? void 0 : json["consumed"],
1058
+ creditId: json["credit_id"],
1059
+ id: json["id"],
1060
+ kind: json["kind"],
1061
+ label: json["label"] == null ? void 0 : json["label"],
1062
+ limit: json["limit"],
1063
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
1064
+ scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
1065
+ window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
1066
+ };
1067
+ }
1013
1068
  function CheckFlagsResponseDataFromJSON(json) {
1014
1069
  return CheckFlagsResponseDataFromJSONTyped(json, false);
1015
1070
  }
@@ -1019,6 +1074,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1019
1074
  }
1020
1075
  return {
1021
1076
  creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
1077
+ creditSpendPolicies: json["credit_spend_policies"].map(
1078
+ CreditSpendPolicyFromJSON
1079
+ ),
1022
1080
  flags: json["flags"].map(CheckFlagResponseDataFromJSON),
1023
1081
  plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
1024
1082
  };
@@ -1047,6 +1105,7 @@ function EventBodyFlagCheckToJSONTyped(value, ignoreDiscriminator = false) {
1047
1105
  error: value["error"],
1048
1106
  flag_id: value["flagId"],
1049
1107
  flag_key: value["flagKey"],
1108
+ preflight: value["preflight"],
1050
1109
  reason: value["reason"],
1051
1110
  req_company: value["reqCompany"],
1052
1111
  req_user: value["reqUser"],
@@ -1118,7 +1177,8 @@ var CheckFlagReturnFromJSON = (json) => {
1118
1177
  ruleType: ruleType == null ? void 0 : ruleType,
1119
1178
  softLimit: entitlement?.softLimit == null ? void 0 : entitlement.softLimit,
1120
1179
  userId: userId == null ? void 0 : userId,
1121
- value
1180
+ value,
1181
+ warningTiers: entitlement?.warningTiers == null ? void 0 : entitlement.warningTiers
1122
1182
  };
1123
1183
  };
1124
1184
  var CheckPlanReturnFromJSON = (json) => {
@@ -1145,7 +1205,55 @@ var CreditBalancesFromJSON = (json) => {
1145
1205
  }
1146
1206
  return balances;
1147
1207
  };
1148
- var cacheVersion = "bb56e75d";
1208
+ var CreditSpendPoliciesFromJSON = (json) => {
1209
+ if (!Array.isArray(json)) {
1210
+ return [];
1211
+ }
1212
+ const policies = [];
1213
+ for (const raw of json) {
1214
+ if (raw == null || typeof raw !== "object") continue;
1215
+ const id = raw.id;
1216
+ const creditId = raw.credit_id ?? raw.creditId;
1217
+ const kind = raw.kind;
1218
+ const scope = raw.scope;
1219
+ const limit = raw.limit;
1220
+ if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
1221
+ continue;
1222
+ }
1223
+ const policy = {
1224
+ id,
1225
+ creditId,
1226
+ kind,
1227
+ scope,
1228
+ limit,
1229
+ consumed: typeof raw.consumed === "number" ? raw.consumed : 0
1230
+ };
1231
+ if (typeof raw.label === "string") {
1232
+ policy.label = raw.label;
1233
+ }
1234
+ const window2 = raw.window;
1235
+ if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
1236
+ policy.window = { unit: window2.unit, count: window2.count };
1237
+ }
1238
+ const resetsAt = raw.resets_at ?? raw.resetsAt;
1239
+ if (typeof resetsAt === "string" || resetsAt instanceof Date) {
1240
+ const parsed = new Date(resetsAt);
1241
+ if (!Number.isNaN(parsed.getTime())) {
1242
+ policy.resetsAt = parsed;
1243
+ }
1244
+ }
1245
+ policies.push(policy);
1246
+ }
1247
+ return policies;
1248
+ };
1249
+ var creditSpendPoliciesEqual = (a, b) => {
1250
+ if (a.length !== b.length) return false;
1251
+ return a.every((x, i) => {
1252
+ const y = b[i];
1253
+ 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;
1254
+ });
1255
+ };
1256
+ var cacheVersion = "35d92bc6";
1149
1257
  function contextString(context) {
1150
1258
  const sortedContext = Object.keys(context).reduce((acc, key) => {
1151
1259
  const sortedKeys = Object.keys(
@@ -1160,16 +1268,819 @@ function contextString(context) {
1160
1268
  }, {});
1161
1269
  return JSON.stringify(sortedContext);
1162
1270
  }
1163
- var version = "1.5.0";
1271
+ var version = "1.10.0";
1272
+ var models_exports = {};
1273
+ __export2(models_exports, {
1274
+ ApiErrorFromJSON: () => ApiErrorFromJSON,
1275
+ ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
1276
+ ApiErrorToJSON: () => ApiErrorToJSON,
1277
+ ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
1278
+ BillingProviderType: () => BillingProviderType,
1279
+ BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
1280
+ BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
1281
+ BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
1282
+ BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
1283
+ CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
1284
+ CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
1285
+ CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
1286
+ CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
1287
+ CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
1288
+ CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
1289
+ CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
1290
+ CompanyInvoiceResponseDataToJSONTyped: () => CompanyInvoiceResponseDataToJSONTyped,
1291
+ CompanyInvoicesResponseDataFromJSON: () => CompanyInvoicesResponseDataFromJSON,
1292
+ CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
1293
+ CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
1294
+ CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
1295
+ CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
1296
+ CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
1297
+ CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
1298
+ CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
1299
+ CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
1300
+ CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
1301
+ CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
1302
+ CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
1303
+ CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
1304
+ CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
1305
+ CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
1306
+ CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
1307
+ CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
1308
+ CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
1309
+ CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
1310
+ CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
1311
+ DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
1312
+ DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
1313
+ DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
1314
+ DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
1315
+ DeleteResponseFromJSON: () => DeleteResponseFromJSON,
1316
+ DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
1317
+ DeleteResponseToJSON: () => DeleteResponseToJSON,
1318
+ DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
1319
+ GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
1320
+ GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
1321
+ GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
1322
+ GetCompanyInvoicesParamsToJSONTyped: () => GetCompanyInvoicesParamsToJSONTyped,
1323
+ GetCompanyInvoicesResponseFromJSON: () => GetCompanyInvoicesResponseFromJSON,
1324
+ GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
1325
+ GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
1326
+ GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
1327
+ GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
1328
+ GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
1329
+ GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
1330
+ GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
1331
+ GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
1332
+ GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
1333
+ GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
1334
+ GetCompanyUpcomingInvoiceResponseToJSONTyped: () => GetCompanyUpcomingInvoiceResponseToJSONTyped,
1335
+ InvoiceStatus: () => InvoiceStatus,
1336
+ InvoiceStatusFromJSON: () => InvoiceStatusFromJSON,
1337
+ InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
1338
+ InvoiceStatusToJSON: () => InvoiceStatusToJSON,
1339
+ InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
1340
+ PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
1341
+ PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
1342
+ PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
1343
+ PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
1344
+ SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
1345
+ SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
1346
+ SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
1347
+ SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
1348
+ UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
1349
+ UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
1350
+ UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
1351
+ UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
1352
+ UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
1353
+ UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
1354
+ UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
1355
+ UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
1356
+ instanceOfApiError: () => instanceOfApiError,
1357
+ instanceOfBillingProviderType: () => instanceOfBillingProviderType,
1358
+ instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
1359
+ instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
1360
+ instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
1361
+ instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
1362
+ instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
1363
+ instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
1364
+ instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
1365
+ instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
1366
+ instanceOfDeleteResponse: () => instanceOfDeleteResponse,
1367
+ instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
1368
+ instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
1369
+ instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
1370
+ instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
1371
+ instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
1372
+ instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
1373
+ instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
1374
+ instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
1375
+ instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
1376
+ });
1377
+ function instanceOfApiError(value) {
1378
+ if (!("error" in value) || value["error"] === void 0) return false;
1379
+ return true;
1380
+ }
1381
+ function ApiErrorFromJSON(json) {
1382
+ return ApiErrorFromJSONTyped(json, false);
1383
+ }
1384
+ function ApiErrorFromJSONTyped(json, ignoreDiscriminator) {
1385
+ if (json == null) {
1386
+ return json;
1387
+ }
1388
+ return {
1389
+ error: json["error"]
1390
+ };
1391
+ }
1392
+ function ApiErrorToJSON(json) {
1393
+ return ApiErrorToJSONTyped(json, false);
1394
+ }
1395
+ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
1396
+ if (value == null) {
1397
+ return value;
1398
+ }
1399
+ return {
1400
+ error: value["error"]
1401
+ };
1402
+ }
1403
+ var BillingProviderType = {
1404
+ Metronome: "metronome",
1405
+ Orb: "orb",
1406
+ Schematic: "schematic",
1407
+ Stripe: "stripe"
1408
+ };
1409
+ function instanceOfBillingProviderType(value) {
1410
+ for (const key in BillingProviderType) {
1411
+ if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
1412
+ if (BillingProviderType[key] === value) {
1413
+ return true;
1414
+ }
1415
+ }
1416
+ }
1417
+ return false;
1418
+ }
1419
+ function BillingProviderTypeFromJSON2(json) {
1420
+ return BillingProviderTypeFromJSONTyped11(json, false);
1421
+ }
1422
+ function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
1423
+ return json;
1424
+ }
1425
+ function BillingProviderTypeToJSON2(value) {
1426
+ return value;
1427
+ }
1428
+ function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
1429
+ return value;
1430
+ }
1431
+ function instanceOfCompanyDiscountResponseData(value) {
1432
+ if (!("couponName" in value) || value["couponName"] === void 0)
1433
+ return false;
1434
+ if (!("duration" in value) || value["duration"] === void 0) return false;
1435
+ return true;
1436
+ }
1437
+ function CompanyDiscountResponseDataFromJSON(json) {
1438
+ return CompanyDiscountResponseDataFromJSONTyped(json, false);
1439
+ }
1440
+ function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1441
+ if (json == null) {
1442
+ return json;
1443
+ }
1444
+ return {
1445
+ amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
1446
+ couponName: json["coupon_name"],
1447
+ currency: json["currency"] == null ? void 0 : json["currency"],
1448
+ customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
1449
+ duration: json["duration"],
1450
+ durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
1451
+ percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
1452
+ };
1453
+ }
1454
+ function CompanyDiscountResponseDataToJSON(json) {
1455
+ return CompanyDiscountResponseDataToJSONTyped(json, false);
1456
+ }
1457
+ function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1458
+ if (value == null) {
1459
+ return value;
1460
+ }
1461
+ return {
1462
+ amount_off: value["amountOff"],
1463
+ coupon_name: value["couponName"],
1464
+ currency: value["currency"],
1465
+ customer_facing_code: value["customerFacingCode"],
1466
+ duration: value["duration"],
1467
+ duration_in_months: value["durationInMonths"],
1468
+ percent_off: value["percentOff"]
1469
+ };
1470
+ }
1471
+ var InvoiceStatus = {
1472
+ Draft: "draft",
1473
+ Open: "open",
1474
+ Paid: "paid",
1475
+ Uncollectible: "uncollectible",
1476
+ Void: "void"
1477
+ };
1478
+ function instanceOfInvoiceStatus(value) {
1479
+ for (const key in InvoiceStatus) {
1480
+ if (Object.prototype.hasOwnProperty.call(InvoiceStatus, key)) {
1481
+ if (InvoiceStatus[key] === value) {
1482
+ return true;
1483
+ }
1484
+ }
1485
+ }
1486
+ return false;
1487
+ }
1488
+ function InvoiceStatusFromJSON(json) {
1489
+ return InvoiceStatusFromJSONTyped(json, false);
1490
+ }
1491
+ function InvoiceStatusFromJSONTyped(json, ignoreDiscriminator) {
1492
+ return json;
1493
+ }
1494
+ function InvoiceStatusToJSON(value) {
1495
+ return value;
1496
+ }
1497
+ function InvoiceStatusToJSONTyped(value, ignoreDiscriminator) {
1498
+ return value;
1499
+ }
1500
+ function instanceOfCompanyInvoiceResponseData(value) {
1501
+ if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
1502
+ if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
1503
+ if (!("currency" in value) || value["currency"] === void 0) return false;
1504
+ if (!("id" in value) || value["id"] === void 0) return false;
1505
+ return true;
1506
+ }
1507
+ function CompanyInvoiceResponseDataFromJSON(json) {
1508
+ return CompanyInvoiceResponseDataFromJSONTyped(json, false);
1509
+ }
1510
+ function CompanyInvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1511
+ if (json == null) {
1512
+ return json;
1513
+ }
1514
+ return {
1515
+ amountDue: json["amount_due"],
1516
+ createdAt: new Date(json["created_at"]),
1517
+ currency: json["currency"],
1518
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
1519
+ id: json["id"],
1520
+ status: json["status"] == null ? void 0 : InvoiceStatusFromJSON(json["status"]),
1521
+ url: json["url"] == null ? void 0 : json["url"]
1522
+ };
1523
+ }
1524
+ function CompanyInvoiceResponseDataToJSON(json) {
1525
+ return CompanyInvoiceResponseDataToJSONTyped(json, false);
1526
+ }
1527
+ function CompanyInvoiceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1528
+ if (value == null) {
1529
+ return value;
1530
+ }
1531
+ return {
1532
+ amount_due: value["amountDue"],
1533
+ created_at: value["createdAt"].toISOString(),
1534
+ currency: value["currency"],
1535
+ due_date: value["dueDate"] == null ? void 0 : value["dueDate"].toISOString(),
1536
+ id: value["id"],
1537
+ status: InvoiceStatusToJSON(value["status"]),
1538
+ url: value["url"]
1539
+ };
1540
+ }
1541
+ function instanceOfCompanyInvoicesResponseData(value) {
1542
+ if (!("count" in value) || value["count"] === void 0) return false;
1543
+ if (!("invoices" in value) || value["invoices"] === void 0) return false;
1544
+ return true;
1545
+ }
1546
+ function CompanyInvoicesResponseDataFromJSON(json) {
1547
+ return CompanyInvoicesResponseDataFromJSONTyped(json, false);
1548
+ }
1549
+ function CompanyInvoicesResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1550
+ if (json == null) {
1551
+ return json;
1552
+ }
1553
+ return {
1554
+ count: json["count"],
1555
+ invoices: json["invoices"].map(
1556
+ CompanyInvoiceResponseDataFromJSON
1557
+ )
1558
+ };
1559
+ }
1560
+ function CompanyInvoicesResponseDataToJSON(json) {
1561
+ return CompanyInvoicesResponseDataToJSONTyped(json, false);
1562
+ }
1563
+ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1564
+ if (value == null) {
1565
+ return value;
1566
+ }
1567
+ return {
1568
+ count: value["count"],
1569
+ invoices: value["invoices"].map(
1570
+ CompanyInvoiceResponseDataToJSON
1571
+ )
1572
+ };
1573
+ }
1574
+ function instanceOfCompanyPaymentMethodResponseData(value) {
1575
+ if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
1576
+ if (!("externalId" in value) || value["externalId"] === void 0)
1577
+ return false;
1578
+ if (!("id" in value) || value["id"] === void 0) return false;
1579
+ if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
1580
+ if (!("type" in value) || value["type"] === void 0) return false;
1581
+ return true;
1582
+ }
1583
+ function CompanyPaymentMethodResponseDataFromJSON(json) {
1584
+ return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
1585
+ }
1586
+ function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1587
+ if (json == null) {
1588
+ return json;
1589
+ }
1590
+ return {
1591
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
1592
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
1593
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
1594
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
1595
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
1596
+ canRemove: json["can_remove"],
1597
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
1598
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
1599
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
1600
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
1601
+ externalId: json["external_id"],
1602
+ id: json["id"],
1603
+ isDefault: json["is_default"],
1604
+ type: json["type"]
1605
+ };
1606
+ }
1607
+ function CompanyPaymentMethodResponseDataToJSON(json) {
1608
+ return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
1609
+ }
1610
+ function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1611
+ if (value == null) {
1612
+ return value;
1613
+ }
1614
+ return {
1615
+ account_last4: value["accountLast4"],
1616
+ account_name: value["accountName"],
1617
+ bank_name: value["bankName"],
1618
+ billing_email: value["billingEmail"],
1619
+ billing_name: value["billingName"],
1620
+ can_remove: value["canRemove"],
1621
+ card_brand: value["cardBrand"],
1622
+ card_exp_month: value["cardExpMonth"],
1623
+ card_exp_year: value["cardExpYear"],
1624
+ card_last4: value["cardLast4"],
1625
+ external_id: value["externalId"],
1626
+ id: value["id"],
1627
+ is_default: value["isDefault"],
1628
+ type: value["type"]
1629
+ };
1630
+ }
1631
+ function instanceOfCompanyPaymentMethodsResponseData(value) {
1632
+ if (!("count" in value) || value["count"] === void 0) return false;
1633
+ if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
1634
+ return false;
1635
+ return true;
1636
+ }
1637
+ function CompanyPaymentMethodsResponseDataFromJSON(json) {
1638
+ return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
1639
+ }
1640
+ function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1641
+ if (json == null) {
1642
+ return json;
1643
+ }
1644
+ return {
1645
+ count: json["count"],
1646
+ paymentMethods: json["payment_methods"].map(
1647
+ CompanyPaymentMethodResponseDataFromJSON
1648
+ )
1649
+ };
1650
+ }
1651
+ function CompanyPaymentMethodsResponseDataToJSON(json) {
1652
+ return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
1653
+ }
1654
+ function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1655
+ if (value == null) {
1656
+ return value;
1657
+ }
1658
+ return {
1659
+ count: value["count"],
1660
+ payment_methods: value["paymentMethods"].map(
1661
+ CompanyPaymentMethodResponseDataToJSON
1662
+ )
1663
+ };
1664
+ }
1665
+ function instanceOfCompanyUpcomingInvoiceResponseData(value) {
1666
+ if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
1667
+ if (!("currency" in value) || value["currency"] === void 0) return false;
1668
+ if (!("customerBalanceApplied" in value) || value["customerBalanceApplied"] === void 0)
1669
+ return false;
1670
+ if (!("customerBalanceRemaining" in value) || value["customerBalanceRemaining"] === void 0)
1671
+ return false;
1672
+ if (!("discounts" in value) || value["discounts"] === void 0) return false;
1673
+ if (!("subtotal" in value) || value["subtotal"] === void 0) return false;
1674
+ return true;
1675
+ }
1676
+ function CompanyUpcomingInvoiceResponseDataFromJSON(json) {
1677
+ return CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, false);
1678
+ }
1679
+ function CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1680
+ if (json == null) {
1681
+ return json;
1682
+ }
1683
+ return {
1684
+ amountDue: json["amount_due"],
1685
+ currency: json["currency"],
1686
+ customerBalanceApplied: json["customer_balance_applied"],
1687
+ customerBalanceRemaining: json["customer_balance_remaining"],
1688
+ discounts: json["discounts"].map(
1689
+ CompanyDiscountResponseDataFromJSON
1690
+ ),
1691
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
1692
+ subtotal: json["subtotal"]
1693
+ };
1694
+ }
1695
+ function CompanyUpcomingInvoiceResponseDataToJSON(json) {
1696
+ return CompanyUpcomingInvoiceResponseDataToJSONTyped(json, false);
1697
+ }
1698
+ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1699
+ if (value == null) {
1700
+ return value;
1701
+ }
1702
+ return {
1703
+ amount_due: value["amountDue"],
1704
+ currency: value["currency"],
1705
+ customer_balance_applied: value["customerBalanceApplied"],
1706
+ customer_balance_remaining: value["customerBalanceRemaining"],
1707
+ discounts: value["discounts"].map(
1708
+ CompanyDiscountResponseDataToJSON
1709
+ ),
1710
+ due_date: value["dueDate"] == null ? void 0 : value["dueDate"].toISOString(),
1711
+ subtotal: value["subtotal"]
1712
+ };
1713
+ }
1714
+ function instanceOfSetupIntentResponseData(value) {
1715
+ if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
1716
+ return false;
1717
+ return true;
1718
+ }
1719
+ function SetupIntentResponseDataFromJSON(json) {
1720
+ return SetupIntentResponseDataFromJSONTyped(json, false);
1721
+ }
1722
+ function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1723
+ if (json == null) {
1724
+ return json;
1725
+ }
1726
+ return {
1727
+ accountId: json["account_id"] == null ? void 0 : json["account_id"],
1728
+ publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
1729
+ schematicPublishableKey: json["schematic_publishable_key"],
1730
+ setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
1731
+ };
1732
+ }
1733
+ function SetupIntentResponseDataToJSON(json) {
1734
+ return SetupIntentResponseDataToJSONTyped(json, false);
1735
+ }
1736
+ function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1737
+ if (value == null) {
1738
+ return value;
1739
+ }
1740
+ return {
1741
+ account_id: value["accountId"],
1742
+ publishable_key: value["publishableKey"],
1743
+ schematic_publishable_key: value["schematicPublishableKey"],
1744
+ setup_intent_client_secret: value["setupIntentClientSecret"]
1745
+ };
1746
+ }
1747
+ function instanceOfCreateSetupIntentResponse(value) {
1748
+ if (!("data" in value) || value["data"] === void 0) return false;
1749
+ if (!("params" in value) || value["params"] === void 0) return false;
1750
+ return true;
1751
+ }
1752
+ function CreateSetupIntentResponseFromJSON(json) {
1753
+ return CreateSetupIntentResponseFromJSONTyped(json, false);
1754
+ }
1755
+ function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
1756
+ if (json == null) {
1757
+ return json;
1758
+ }
1759
+ return {
1760
+ data: SetupIntentResponseDataFromJSON(json["data"]),
1761
+ params: json["params"]
1762
+ };
1763
+ }
1764
+ function CreateSetupIntentResponseToJSON(json) {
1765
+ return CreateSetupIntentResponseToJSONTyped(json, false);
1766
+ }
1767
+ function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
1768
+ if (value == null) {
1769
+ return value;
1770
+ }
1771
+ return {
1772
+ data: SetupIntentResponseDataToJSON(value["data"]),
1773
+ params: value["params"]
1774
+ };
1775
+ }
1776
+ function instanceOfDeleteResponse(value) {
1777
+ return true;
1778
+ }
1779
+ function DeleteResponseFromJSON(json) {
1780
+ return DeleteResponseFromJSONTyped(json, false);
1781
+ }
1782
+ function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
1783
+ if (json == null) {
1784
+ return json;
1785
+ }
1786
+ return {
1787
+ deleted: json["deleted"] == null ? void 0 : json["deleted"]
1788
+ };
1789
+ }
1790
+ function DeleteResponseToJSON(json) {
1791
+ return DeleteResponseToJSONTyped(json, false);
1792
+ }
1793
+ function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
1794
+ if (value == null) {
1795
+ return value;
1796
+ }
1797
+ return {
1798
+ deleted: value["deleted"]
1799
+ };
1800
+ }
1801
+ function instanceOfDeletePaymentMethodResponse(value) {
1802
+ if (!("data" in value) || value["data"] === void 0) return false;
1803
+ if (!("params" in value) || value["params"] === void 0) return false;
1804
+ return true;
1805
+ }
1806
+ function DeletePaymentMethodResponseFromJSON(json) {
1807
+ return DeletePaymentMethodResponseFromJSONTyped(json, false);
1808
+ }
1809
+ function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
1810
+ if (json == null) {
1811
+ return json;
1812
+ }
1813
+ return {
1814
+ data: DeleteResponseFromJSON(json["data"]),
1815
+ params: json["params"]
1816
+ };
1817
+ }
1818
+ function DeletePaymentMethodResponseToJSON(json) {
1819
+ return DeletePaymentMethodResponseToJSONTyped(json, false);
1820
+ }
1821
+ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
1822
+ if (value == null) {
1823
+ return value;
1824
+ }
1825
+ return {
1826
+ data: DeleteResponseToJSON(value["data"]),
1827
+ params: value["params"]
1828
+ };
1829
+ }
1830
+ function instanceOfGetCompanyInvoicesParams(value) {
1831
+ return true;
1832
+ }
1833
+ function GetCompanyInvoicesParamsFromJSON(json) {
1834
+ return GetCompanyInvoicesParamsFromJSONTyped(json, false);
1835
+ }
1836
+ function GetCompanyInvoicesParamsFromJSONTyped(json, ignoreDiscriminator) {
1837
+ if (json == null) {
1838
+ return json;
1839
+ }
1840
+ return {
1841
+ includePending: json["include_pending"] == null ? void 0 : json["include_pending"],
1842
+ limit: json["limit"] == null ? void 0 : json["limit"],
1843
+ offset: json["offset"] == null ? void 0 : json["offset"]
1844
+ };
1845
+ }
1846
+ function GetCompanyInvoicesParamsToJSON(json) {
1847
+ return GetCompanyInvoicesParamsToJSONTyped(json, false);
1848
+ }
1849
+ function GetCompanyInvoicesParamsToJSONTyped(value, ignoreDiscriminator = false) {
1850
+ if (value == null) {
1851
+ return value;
1852
+ }
1853
+ return {
1854
+ include_pending: value["includePending"],
1855
+ limit: value["limit"],
1856
+ offset: value["offset"]
1857
+ };
1858
+ }
1859
+ function instanceOfGetCompanyInvoicesResponse(value) {
1860
+ if (!("data" in value) || value["data"] === void 0) return false;
1861
+ if (!("params" in value) || value["params"] === void 0) return false;
1862
+ return true;
1863
+ }
1864
+ function GetCompanyInvoicesResponseFromJSON(json) {
1865
+ return GetCompanyInvoicesResponseFromJSONTyped(json, false);
1866
+ }
1867
+ function GetCompanyInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
1868
+ if (json == null) {
1869
+ return json;
1870
+ }
1871
+ return {
1872
+ data: CompanyInvoicesResponseDataFromJSON(json["data"]),
1873
+ params: GetCompanyInvoicesParamsFromJSON(json["params"])
1874
+ };
1875
+ }
1876
+ function GetCompanyInvoicesResponseToJSON(json) {
1877
+ return GetCompanyInvoicesResponseToJSONTyped(json, false);
1878
+ }
1879
+ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = false) {
1880
+ if (value == null) {
1881
+ return value;
1882
+ }
1883
+ return {
1884
+ data: CompanyInvoicesResponseDataToJSON(value["data"]),
1885
+ params: GetCompanyInvoicesParamsToJSON(value["params"])
1886
+ };
1887
+ }
1888
+ function instanceOfGetCompanyPaymentMethodsResponse(value) {
1889
+ if (!("data" in value) || value["data"] === void 0) return false;
1890
+ if (!("params" in value) || value["params"] === void 0) return false;
1891
+ return true;
1892
+ }
1893
+ function GetCompanyPaymentMethodsResponseFromJSON(json) {
1894
+ return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
1895
+ }
1896
+ function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
1897
+ if (json == null) {
1898
+ return json;
1899
+ }
1900
+ return {
1901
+ data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
1902
+ params: json["params"]
1903
+ };
1904
+ }
1905
+ function GetCompanyPaymentMethodsResponseToJSON(json) {
1906
+ return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
1907
+ }
1908
+ function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
1909
+ if (value == null) {
1910
+ return value;
1911
+ }
1912
+ return {
1913
+ data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
1914
+ params: value["params"]
1915
+ };
1916
+ }
1917
+ function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
1918
+ if (!("data" in value) || value["data"] === void 0) return false;
1919
+ if (!("params" in value) || value["params"] === void 0) return false;
1920
+ return true;
1921
+ }
1922
+ function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
1923
+ return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
1924
+ }
1925
+ function GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, ignoreDiscriminator) {
1926
+ if (json == null) {
1927
+ return json;
1928
+ }
1929
+ return {
1930
+ data: CompanyUpcomingInvoiceResponseDataFromJSON(json["data"]),
1931
+ params: json["params"]
1932
+ };
1933
+ }
1934
+ function GetCompanyUpcomingInvoiceResponseToJSON(json) {
1935
+ return GetCompanyUpcomingInvoiceResponseToJSONTyped(json, false);
1936
+ }
1937
+ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator = false) {
1938
+ if (value == null) {
1939
+ return value;
1940
+ }
1941
+ return {
1942
+ data: CompanyUpcomingInvoiceResponseDataToJSON(value["data"]),
1943
+ params: value["params"]
1944
+ };
1945
+ }
1946
+ function instanceOfPaymentMethodResponseData(value) {
1947
+ if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
1948
+ if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
1949
+ return false;
1950
+ if (!("environmentId" in value) || value["environmentId"] === void 0)
1951
+ return false;
1952
+ if (!("externalId" in value) || value["externalId"] === void 0)
1953
+ return false;
1954
+ if (!("id" in value) || value["id"] === void 0) return false;
1955
+ if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
1956
+ return false;
1957
+ if (!("providerType" in value) || value["providerType"] === void 0)
1958
+ return false;
1959
+ if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
1960
+ return true;
1961
+ }
1962
+ function PaymentMethodResponseDataFromJSON(json) {
1963
+ return PaymentMethodResponseDataFromJSONTyped(json, false);
1964
+ }
1965
+ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1966
+ if (json == null) {
1967
+ return json;
1968
+ }
1969
+ return {
1970
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
1971
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
1972
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
1973
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
1974
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
1975
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
1976
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
1977
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
1978
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
1979
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
1980
+ createdAt: new Date(json["created_at"]),
1981
+ customerExternalId: json["customer_external_id"],
1982
+ environmentId: json["environment_id"],
1983
+ externalId: json["external_id"],
1984
+ id: json["id"],
1985
+ paymentMethodType: json["payment_method_type"],
1986
+ providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
1987
+ updatedAt: new Date(json["updated_at"])
1988
+ };
1989
+ }
1990
+ function PaymentMethodResponseDataToJSON(json) {
1991
+ return PaymentMethodResponseDataToJSONTyped(json, false);
1992
+ }
1993
+ function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1994
+ if (value == null) {
1995
+ return value;
1996
+ }
1997
+ return {
1998
+ account_last4: value["accountLast4"],
1999
+ account_name: value["accountName"],
2000
+ bank_name: value["bankName"],
2001
+ billing_email: value["billingEmail"],
2002
+ billing_name: value["billingName"],
2003
+ card_brand: value["cardBrand"],
2004
+ card_exp_month: value["cardExpMonth"],
2005
+ card_exp_year: value["cardExpYear"],
2006
+ card_last4: value["cardLast4"],
2007
+ company_id: value["companyId"],
2008
+ created_at: value["createdAt"].toISOString(),
2009
+ customer_external_id: value["customerExternalId"],
2010
+ environment_id: value["environmentId"],
2011
+ external_id: value["externalId"],
2012
+ id: value["id"],
2013
+ payment_method_type: value["paymentMethodType"],
2014
+ provider_type: BillingProviderTypeToJSON2(value["providerType"]),
2015
+ updated_at: value["updatedAt"].toISOString()
2016
+ };
2017
+ }
2018
+ function instanceOfUpdatePaymentMethodRequestBody(value) {
2019
+ if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
2020
+ return false;
2021
+ return true;
2022
+ }
2023
+ function UpdatePaymentMethodRequestBodyFromJSON(json) {
2024
+ return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
2025
+ }
2026
+ function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
2027
+ if (json == null) {
2028
+ return json;
2029
+ }
2030
+ return {
2031
+ paymentMethodId: json["payment_method_id"]
2032
+ };
2033
+ }
2034
+ function UpdatePaymentMethodRequestBodyToJSON(json) {
2035
+ return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
2036
+ }
2037
+ function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
2038
+ if (value == null) {
2039
+ return value;
2040
+ }
2041
+ return {
2042
+ payment_method_id: value["paymentMethodId"]
2043
+ };
2044
+ }
2045
+ function instanceOfUpdatePaymentMethodResponse(value) {
2046
+ if (!("data" in value) || value["data"] === void 0) return false;
2047
+ if (!("params" in value) || value["params"] === void 0) return false;
2048
+ return true;
2049
+ }
2050
+ function UpdatePaymentMethodResponseFromJSON(json) {
2051
+ return UpdatePaymentMethodResponseFromJSONTyped(json, false);
2052
+ }
2053
+ function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
2054
+ if (json == null) {
2055
+ return json;
2056
+ }
2057
+ return {
2058
+ data: PaymentMethodResponseDataFromJSON(json["data"]),
2059
+ params: json["params"]
2060
+ };
2061
+ }
2062
+ function UpdatePaymentMethodResponseToJSON(json) {
2063
+ return UpdatePaymentMethodResponseToJSONTyped(json, false);
2064
+ }
2065
+ function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
2066
+ if (value == null) {
2067
+ return value;
2068
+ }
2069
+ return {
2070
+ data: PaymentMethodResponseDataToJSON(value["data"]),
2071
+ params: value["params"]
2072
+ };
2073
+ }
1164
2074
  var anonymousIdKey = "schematicId";
1165
2075
  var flagStateCachePrefix = "schematicCache";
1166
2076
  var flagStateCacheMaxContexts = 10;
1167
2077
  var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
1168
2078
  var emptyCreditBalances = Object.freeze({});
2079
+ var emptyCreditSpendPolicies = [];
1169
2080
  var Schematic = class {
1170
- additionalHeaders = {};
2081
+ _additionalHeaders = {};
1171
2082
  apiKey;
1172
- apiUrl = "https://api.schematichq.com";
2083
+ _apiUrl = "https://api.schematichq.com";
1173
2084
  conn = null;
1174
2085
  context = {};
1175
2086
  debugEnabled = false;
@@ -1183,6 +2094,7 @@ var Schematic = class {
1183
2094
  isPendingListeners = /* @__PURE__ */ new Set();
1184
2095
  planListeners = /* @__PURE__ */ new Set();
1185
2096
  creditBalanceListeners = /* @__PURE__ */ new Set();
2097
+ creditSpendPolicyListeners = /* @__PURE__ */ new Set();
1186
2098
  storage;
1187
2099
  persistFlagState = true;
1188
2100
  flagStateCacheKey;
@@ -1193,6 +2105,7 @@ var Schematic = class {
1193
2105
  featureUsageEventMap = {};
1194
2106
  planChecks = {};
1195
2107
  creditBalances = {};
2108
+ creditSpendPolicies = {};
1196
2109
  webSocketUrl = "wss://api.schematichq.com";
1197
2110
  webSocketConnectionTimeout = 1e4;
1198
2111
  webSocketReconnect = true;
@@ -1249,7 +2162,7 @@ var Schematic = class {
1249
2162
  if (this.offlineEnabled) {
1250
2163
  this.setIsPending(false);
1251
2164
  }
1252
- this.additionalHeaders = {
2165
+ this._additionalHeaders = {
1253
2166
  "X-Schematic-Client-Version": `schematic-js@${version}`,
1254
2167
  ...options?.additionalHeaders ?? {}
1255
2168
  };
@@ -1265,7 +2178,7 @@ var Schematic = class {
1265
2178
  }
1266
2179
  this.hydrateFlagStateFromCache();
1267
2180
  if (options?.apiUrl !== void 0) {
1268
- this.apiUrl = options.apiUrl;
2181
+ this._apiUrl = options.apiUrl;
1269
2182
  }
1270
2183
  if (options?.eventUrl !== void 0) {
1271
2184
  this.eventUrl = options.eventUrl;
@@ -1330,6 +2243,12 @@ var Schematic = class {
1330
2243
  this.debug("Initialized with debug mode enabled");
1331
2244
  }
1332
2245
  }
2246
+ get apiUrl() {
2247
+ return this._apiUrl;
2248
+ }
2249
+ get additionalHeaders() {
2250
+ return { ...this._additionalHeaders };
2251
+ }
1333
2252
  /**
1334
2253
  * Resolve fallback value according to priority order:
1335
2254
  * 1. Callsite fallback value (if provided)
@@ -1415,11 +2334,11 @@ var Schematic = class {
1415
2334
  return resolvedFallbackResult.value;
1416
2335
  }
1417
2336
  if (!this.useWebSocket) {
1418
- const requestUrl = `${this.apiUrl}/flags/${key}/check`;
2337
+ const requestUrl = `${this._apiUrl}/flags/${key}/check`;
1419
2338
  return fetch(requestUrl, {
1420
2339
  method: "POST",
1421
2340
  headers: {
1422
- ...this.additionalHeaders ?? {},
2341
+ ...this._additionalHeaders ?? {},
1423
2342
  "Content-Type": "application/json;charset=UTF-8",
1424
2343
  "X-Schematic-Api-Key": this.apiKey
1425
2344
  },
@@ -1579,6 +2498,19 @@ var Schematic = class {
1579
2498
  this.notifyCreditBalanceListeners(merged);
1580
2499
  }
1581
2500
  }
2501
+ if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
2502
+ const contextStr = contextString(context);
2503
+ const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
2504
+ const previous = this.creditSpendPolicies[contextStr] ?? [];
2505
+ if (!creditSpendPoliciesEqual(previous, next)) {
2506
+ this.creditSpendPolicies[contextStr] = next;
2507
+ this.debug(
2508
+ `WebSocket credit spend policy update received. Notifying listeners`,
2509
+ { creditSpendPolicies: next }
2510
+ );
2511
+ this.notifyCreditSpendPolicyListeners(next);
2512
+ }
2513
+ }
1582
2514
  this.persistContextToCache(contextString(context));
1583
2515
  this.flushContextDependentEventQueue();
1584
2516
  this.setIsPending(false);
@@ -1622,12 +2554,12 @@ var Schematic = class {
1622
2554
  this.debug(`checkFlags offline result: returning empty object`);
1623
2555
  return {};
1624
2556
  }
1625
- const requestUrl = `${this.apiUrl}/flags/check`;
2557
+ const requestUrl = `${this._apiUrl}/flags/check`;
1626
2558
  const requestBody = JSON.stringify(context);
1627
2559
  return fetch(requestUrl, {
1628
2560
  method: "POST",
1629
2561
  headers: {
1630
- ...this.additionalHeaders ?? {},
2562
+ ...this._additionalHeaders ?? {},
1631
2563
  "Content-Type": "application/json;charset=UTF-8",
1632
2564
  "X-Schematic-Api-Key": this.apiKey
1633
2565
  },
@@ -2080,10 +3012,19 @@ var Schematic = class {
2080
3012
  this.creditBalances[contextStr] = balances;
2081
3013
  }
2082
3014
  }
3015
+ let revivedCreditSpendPolicies;
3016
+ if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
3017
+ const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
3018
+ if (policies.length > 0) {
3019
+ revivedCreditSpendPolicies = policies;
3020
+ this.creditSpendPolicies[contextStr] = policies;
3021
+ }
3022
+ }
2083
3023
  fresh[contextStr] = {
2084
3024
  checks: revivedChecks,
2085
3025
  plan: revivedPlan,
2086
3026
  creditBalances: revivedCreditBalances,
3027
+ creditSpendPolicies: revivedCreditSpendPolicies,
2087
3028
  updatedAt: entry.updatedAt
2088
3029
  };
2089
3030
  contextsLoaded += 1;
@@ -2097,7 +3038,8 @@ var Schematic = class {
2097
3038
  const checksForContext = this.checks[contextStr];
2098
3039
  const planForContext = this.planChecks[contextStr];
2099
3040
  const creditBalancesForContext = this.creditBalances[contextStr];
2100
- if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0) {
3041
+ const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
3042
+ if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
2101
3043
  return;
2102
3044
  }
2103
3045
  if (this.cachedFlagState === null) {
@@ -2116,6 +3058,7 @@ var Schematic = class {
2116
3058
  checks: cleanChecks,
2117
3059
  plan: planForContext,
2118
3060
  creditBalances: creditBalancesForContext,
3061
+ creditSpendPolicies: creditSpendPoliciesForContext,
2119
3062
  updatedAt: Date.now()
2120
3063
  };
2121
3064
  const entries = Object.entries(this.cachedFlagState.contexts);
@@ -2132,6 +3075,9 @@ var Schematic = class {
2132
3075
  for (const key of Object.keys(this.creditBalances)) {
2133
3076
  if (!survivorKeys.has(key)) delete this.creditBalances[key];
2134
3077
  }
3078
+ for (const key of Object.keys(this.creditSpendPolicies)) {
3079
+ if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
3080
+ }
2135
3081
  this.cachedFlagState = {
2136
3082
  version: cacheVersion,
2137
3083
  contexts: Object.fromEntries(survivors)
@@ -2174,7 +3120,7 @@ var Schematic = class {
2174
3120
  const response = await fetch(captureUrl, {
2175
3121
  method: "POST",
2176
3122
  headers: {
2177
- ...this.additionalHeaders ?? {},
3123
+ ...this._additionalHeaders ?? {},
2178
3124
  "Content-Type": "application/json;charset=UTF-8"
2179
3125
  },
2180
3126
  body: payload
@@ -2670,7 +3616,7 @@ var Schematic = class {
2670
3616
  }
2671
3617
  });
2672
3618
  this.currentWebSocket = socket;
2673
- const clientVersion = this.additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
3619
+ const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
2674
3620
  const messagePayload = {
2675
3621
  apiKey: this.apiKey,
2676
3622
  clientVersion,
@@ -2726,6 +3672,18 @@ var Schematic = class {
2726
3672
  const contextStr = contextString(this.context);
2727
3673
  return this.creditBalances[contextStr]?.[creditId];
2728
3674
  };
3675
+ /** Get every credit spend policy binding the current context, company-scope first */
3676
+ getCreditSpendPolicies = () => {
3677
+ const contextStr = contextString(this.context);
3678
+ return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
3679
+ };
3680
+ /** Get the spend policies binding a single credit type in the current context */
3681
+ getCreditSpendPoliciesForCredit = (creditId) => {
3682
+ const policies = this.getCreditSpendPolicies().filter(
3683
+ (policy) => policy.creditId === creditId
3684
+ );
3685
+ return policies.length > 0 ? policies : emptyCreditSpendPolicies;
3686
+ };
2729
3687
  // flag checks state
2730
3688
  getFlagCheck = (flagKey) => {
2731
3689
  const contextStr = contextString(this.context);
@@ -2792,6 +3750,13 @@ var Schematic = class {
2792
3750
  this.creditBalanceListeners.delete(listener);
2793
3751
  };
2794
3752
  };
3753
+ /** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
3754
+ addCreditSpendPolicyListener = (listener) => {
3755
+ this.creditSpendPolicyListeners.add(listener);
3756
+ return () => {
3757
+ this.creditSpendPolicyListeners.delete(listener);
3758
+ };
3759
+ };
2795
3760
  notifyFlagCheckListeners = (flagKey, check) => {
2796
3761
  const listeners = this.flagCheckListeners?.[flagKey] ?? [];
2797
3762
  if (listeners.size > 0) {
@@ -2855,6 +3820,16 @@ var Schematic = class {
2855
3820
  });
2856
3821
  });
2857
3822
  };
3823
+ notifyCreditSpendPolicyListeners = (value) => {
3824
+ const listeners = this.creditSpendPolicyListeners ?? [];
3825
+ listeners.forEach((listener) => {
3826
+ if (listener.length > 0) {
3827
+ listener(value);
3828
+ return;
3829
+ }
3830
+ listener();
3831
+ });
3832
+ };
2858
3833
  notifyCreditBalanceListeners = (value) => {
2859
3834
  const listeners = this.creditBalanceListeners ?? [];
2860
3835
  if (listeners.size > 0) {
@@ -2907,10 +3882,10 @@ var notifyCreditBalanceListener = (listener, value) => {
2907
3882
  var import_vue = require("vue");
2908
3883
 
2909
3884
  // src/version.ts
2910
- var version2 = "1.5.0";
3885
+ var version2 = "1.7.0";
2911
3886
 
2912
3887
  // src/context/schematic.ts
2913
- var SchematicSymbol = Symbol("schematic");
3888
+ var SchematicSymbol = /* @__PURE__ */ Symbol("schematic");
2914
3889
  var SchematicPlugin = {
2915
3890
  install(app, options) {
2916
3891
  let client;
@@ -3017,10 +3992,17 @@ var useSchematicEntitlement = (key, opts) => {
3017
3992
  featureUsageExceeded: (0, import_vue2.computed)(() => flagCheck.value.featureUsageExceeded),
3018
3993
  featureUsageEvent: (0, import_vue2.computed)(() => flagCheck.value.featureUsageEvent),
3019
3994
  featureUsagePeriod: (0, import_vue2.computed)(() => flagCheck.value.featureUsagePeriod),
3995
+ softLimit: (0, import_vue2.computed)(() => flagCheck.value.softLimit),
3996
+ warningTiers: (0, import_vue2.computed)(() => flagCheck.value.warningTiers),
3020
3997
  flagId: (0, import_vue2.computed)(() => flagCheck.value.flagId),
3021
3998
  ruleId: (0, import_vue2.computed)(() => flagCheck.value.ruleId),
3022
3999
  companyId: (0, import_vue2.computed)(() => flagCheck.value.companyId),
3023
- userId: (0, import_vue2.computed)(() => flagCheck.value.userId)
4000
+ userId: (0, import_vue2.computed)(() => flagCheck.value.userId),
4001
+ // Credit fields, populated for features metered by credit burndown
4002
+ creditId: (0, import_vue2.computed)(() => flagCheck.value.creditId),
4003
+ creditSettled: (0, import_vue2.computed)(() => flagCheck.value.creditSettled),
4004
+ creditRemaining: (0, import_vue2.computed)(() => flagCheck.value.creditRemaining),
4005
+ creditReserved: (0, import_vue2.computed)(() => flagCheck.value.creditReserved)
3024
4006
  };
3025
4007
  };
3026
4008
  var useSchematicPlan = (opts) => {
@@ -3042,15 +4024,25 @@ var useSchematicPlan = (opts) => {
3042
4024
  };
3043
4025
  var useSchematicCreditBalance = (creditId, opts) => {
3044
4026
  const client = useSchematicClient(opts);
4027
+ const resolvedCreditId = (0, import_vue2.computed)(() => (0, import_vue2.toValue)(creditId));
4028
+ const readBalance = () => {
4029
+ const id = resolvedCreditId.value;
4030
+ return id === void 0 ? void 0 : client.getCreditBalance(id);
4031
+ };
3045
4032
  const creditBalance = (0, import_vue2.ref)(
3046
- client.getCreditBalance(creditId)
4033
+ readBalance()
3047
4034
  );
3048
4035
  const isPending = (0, import_vue2.ref)(client.getIsPending());
4036
+ (0, import_vue2.watch)(resolvedCreditId, () => {
4037
+ creditBalance.value = readBalance();
4038
+ });
3049
4039
  let unsubscribeBalance = null;
3050
4040
  let unsubscribePending = null;
3051
4041
  (0, import_vue2.onMounted)(() => {
4042
+ creditBalance.value = readBalance();
4043
+ isPending.value = client.getIsPending();
3052
4044
  unsubscribeBalance = client.addCreditBalanceListener(() => {
3053
- creditBalance.value = client.getCreditBalance(creditId);
4045
+ creditBalance.value = readBalance();
3054
4046
  });
3055
4047
  unsubscribePending = client.addIsPendingListener(() => {
3056
4048
  isPending.value = client.getIsPending();
@@ -3069,6 +4061,36 @@ var useSchematicCreditBalance = (creditId, opts) => {
3069
4061
  )
3070
4062
  };
3071
4063
  };
4064
+ var useSchematicCreditSpendPolicies = (opts) => {
4065
+ const client = useSchematicClient(opts);
4066
+ const policies = (0, import_vue2.ref)(
4067
+ client.getCreditSpendPolicies()
4068
+ );
4069
+ const isPending = (0, import_vue2.ref)(client.getIsPending());
4070
+ let unsubscribePolicies = null;
4071
+ let unsubscribePending = null;
4072
+ (0, import_vue2.onMounted)(() => {
4073
+ policies.value = client.getCreditSpendPolicies();
4074
+ isPending.value = client.getIsPending();
4075
+ unsubscribePolicies = client.addCreditSpendPolicyListener(() => {
4076
+ policies.value = client.getCreditSpendPolicies();
4077
+ });
4078
+ unsubscribePending = client.addIsPendingListener(() => {
4079
+ isPending.value = client.getIsPending();
4080
+ policies.value = client.getCreditSpendPolicies();
4081
+ });
4082
+ });
4083
+ (0, import_vue2.onScopeDispose)(() => {
4084
+ unsubscribePolicies?.();
4085
+ unsubscribePending?.();
4086
+ });
4087
+ return {
4088
+ /** Company-scope policies first, then the user's own; empty when none bind */
4089
+ policies: (0, import_vue2.computed)(() => policies.value),
4090
+ /** True while the policies are still loading and nothing has arrived yet */
4091
+ isLoading: (0, import_vue2.computed)(() => policies.value.length === 0 && isPending.value)
4092
+ };
4093
+ };
3072
4094
  var useSchematicIsPending = (opts) => {
3073
4095
  const client = useSchematicClient(opts);
3074
4096
  const isPending = (0, import_vue2.ref)(client.getIsPending());