@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.
@@ -1,4 +1,4 @@
1
- // node_modules/@schematichq/schematic-js/dist/schematic.esm.js
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;
@@ -12,6 +12,10 @@ var __commonJS = (cb, mod) => function __require() {
12
12
  throw mod = 0, e;
13
13
  }
14
14
  };
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
15
19
  var __copyProps = (to, from, except, desc) => {
16
20
  if (from && typeof from === "object" || typeof from === "function") {
17
21
  for (let key of __getOwnPropNames(from))
@@ -29,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
33
  mod
30
34
  ));
31
35
  var require_browser_polyfill = __commonJS({
32
- "node_modules/cross-fetch/dist/browser-polyfill.js"(exports) {
36
+ "node_modules/.pnpm/cross-fetch@4.1.0/node_modules/cross-fetch/dist/browser-polyfill.js"(exports) {
33
37
  (function(self2) {
34
38
  var irrelevant = (function(exports2) {
35
39
  var g = typeof globalThis !== "undefined" && globalThis || typeof self2 !== "undefined" && self2 || // eslint-disable-next-line no-undef
@@ -613,6 +617,18 @@ function MetricPeriodMonthResetFromJSON(json) {
613
617
  function MetricPeriodMonthResetFromJSONTyped(json, ignoreDiscriminator) {
614
618
  return json;
615
619
  }
620
+ function WarningTierFromJSON(json) {
621
+ return WarningTierFromJSONTyped(json, false);
622
+ }
623
+ function WarningTierFromJSONTyped(json, ignoreDiscriminator) {
624
+ if (json == null) {
625
+ return json;
626
+ }
627
+ return {
628
+ key: json["key"],
629
+ value: json["value"]
630
+ };
631
+ }
616
632
  function MetricPeriodFromJSON(json) {
617
633
  return MetricPeriodFromJSONTyped(json, false);
618
634
  }
@@ -644,7 +660,8 @@ function FeatureEntitlementFromJSONTyped(json, ignoreDiscriminator) {
644
660
  monthReset: json["month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON(json["month_reset"]),
645
661
  softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
646
662
  usage: json["usage"] == null ? void 0 : json["usage"],
647
- valueType: EntitlementValueTypeFromJSON(json["value_type"])
663
+ valueType: EntitlementValueTypeFromJSON(json["value_type"]),
664
+ warningTiers: json["warning_tiers"] == null ? void 0 : json["warning_tiers"].map(WarningTierFromJSON)
648
665
  };
649
666
  }
650
667
  function RuleTypeFromJSON(json) {
@@ -972,6 +989,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
972
989
  trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
973
990
  };
974
991
  }
992
+ function CreditSpendPolicyScopeFromJSON(json) {
993
+ return CreditSpendPolicyScopeFromJSONTyped(json, false);
994
+ }
995
+ function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
996
+ return json;
997
+ }
998
+ function CreditSpendWindowFromJSON(json) {
999
+ return CreditSpendWindowFromJSONTyped(json, false);
1000
+ }
1001
+ function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
1002
+ if (json == null) {
1003
+ return json;
1004
+ }
1005
+ return {
1006
+ count: json["count"],
1007
+ unit: json["unit"]
1008
+ };
1009
+ }
1010
+ function CreditSpendPolicyFromJSON(json) {
1011
+ return CreditSpendPolicyFromJSONTyped(json, false);
1012
+ }
1013
+ function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
1014
+ if (json == null) {
1015
+ return json;
1016
+ }
1017
+ return {
1018
+ consumed: json["consumed"] == null ? void 0 : json["consumed"],
1019
+ creditId: json["credit_id"],
1020
+ id: json["id"],
1021
+ kind: json["kind"],
1022
+ label: json["label"] == null ? void 0 : json["label"],
1023
+ limit: json["limit"],
1024
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
1025
+ scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
1026
+ window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
1027
+ };
1028
+ }
975
1029
  function CheckFlagsResponseDataFromJSON(json) {
976
1030
  return CheckFlagsResponseDataFromJSONTyped(json, false);
977
1031
  }
@@ -981,6 +1035,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
981
1035
  }
982
1036
  return {
983
1037
  creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
1038
+ creditSpendPolicies: json["credit_spend_policies"].map(
1039
+ CreditSpendPolicyFromJSON
1040
+ ),
984
1041
  flags: json["flags"].map(CheckFlagResponseDataFromJSON),
985
1042
  plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
986
1043
  };
@@ -1009,6 +1066,7 @@ function EventBodyFlagCheckToJSONTyped(value, ignoreDiscriminator = false) {
1009
1066
  error: value["error"],
1010
1067
  flag_id: value["flagId"],
1011
1068
  flag_key: value["flagKey"],
1069
+ preflight: value["preflight"],
1012
1070
  reason: value["reason"],
1013
1071
  req_company: value["reqCompany"],
1014
1072
  req_user: value["reqUser"],
@@ -1080,7 +1138,8 @@ var CheckFlagReturnFromJSON = (json) => {
1080
1138
  ruleType: ruleType == null ? void 0 : ruleType,
1081
1139
  softLimit: entitlement?.softLimit == null ? void 0 : entitlement.softLimit,
1082
1140
  userId: userId == null ? void 0 : userId,
1083
- value
1141
+ value,
1142
+ warningTiers: entitlement?.warningTiers == null ? void 0 : entitlement.warningTiers
1084
1143
  };
1085
1144
  };
1086
1145
  var CheckPlanReturnFromJSON = (json) => {
@@ -1107,7 +1166,55 @@ var CreditBalancesFromJSON = (json) => {
1107
1166
  }
1108
1167
  return balances;
1109
1168
  };
1110
- var cacheVersion = "bb56e75d";
1169
+ var CreditSpendPoliciesFromJSON = (json) => {
1170
+ if (!Array.isArray(json)) {
1171
+ return [];
1172
+ }
1173
+ const policies = [];
1174
+ for (const raw of json) {
1175
+ if (raw == null || typeof raw !== "object") continue;
1176
+ const id = raw.id;
1177
+ const creditId = raw.credit_id ?? raw.creditId;
1178
+ const kind = raw.kind;
1179
+ const scope = raw.scope;
1180
+ const limit = raw.limit;
1181
+ if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
1182
+ continue;
1183
+ }
1184
+ const policy = {
1185
+ id,
1186
+ creditId,
1187
+ kind,
1188
+ scope,
1189
+ limit,
1190
+ consumed: typeof raw.consumed === "number" ? raw.consumed : 0
1191
+ };
1192
+ if (typeof raw.label === "string") {
1193
+ policy.label = raw.label;
1194
+ }
1195
+ const window2 = raw.window;
1196
+ if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
1197
+ policy.window = { unit: window2.unit, count: window2.count };
1198
+ }
1199
+ const resetsAt = raw.resets_at ?? raw.resetsAt;
1200
+ if (typeof resetsAt === "string" || resetsAt instanceof Date) {
1201
+ const parsed = new Date(resetsAt);
1202
+ if (!Number.isNaN(parsed.getTime())) {
1203
+ policy.resetsAt = parsed;
1204
+ }
1205
+ }
1206
+ policies.push(policy);
1207
+ }
1208
+ return policies;
1209
+ };
1210
+ var creditSpendPoliciesEqual = (a, b) => {
1211
+ if (a.length !== b.length) return false;
1212
+ return a.every((x, i) => {
1213
+ const y = b[i];
1214
+ 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;
1215
+ });
1216
+ };
1217
+ var cacheVersion = "35d92bc6";
1111
1218
  function contextString(context) {
1112
1219
  const sortedContext = Object.keys(context).reduce((acc, key) => {
1113
1220
  const sortedKeys = Object.keys(
@@ -1122,16 +1229,819 @@ function contextString(context) {
1122
1229
  }, {});
1123
1230
  return JSON.stringify(sortedContext);
1124
1231
  }
1125
- var version = "1.5.0";
1232
+ var version = "1.10.0";
1233
+ var models_exports = {};
1234
+ __export(models_exports, {
1235
+ ApiErrorFromJSON: () => ApiErrorFromJSON,
1236
+ ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
1237
+ ApiErrorToJSON: () => ApiErrorToJSON,
1238
+ ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
1239
+ BillingProviderType: () => BillingProviderType,
1240
+ BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
1241
+ BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
1242
+ BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
1243
+ BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
1244
+ CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
1245
+ CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
1246
+ CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
1247
+ CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
1248
+ CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
1249
+ CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
1250
+ CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
1251
+ CompanyInvoiceResponseDataToJSONTyped: () => CompanyInvoiceResponseDataToJSONTyped,
1252
+ CompanyInvoicesResponseDataFromJSON: () => CompanyInvoicesResponseDataFromJSON,
1253
+ CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
1254
+ CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
1255
+ CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
1256
+ CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
1257
+ CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
1258
+ CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
1259
+ CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
1260
+ CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
1261
+ CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
1262
+ CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
1263
+ CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
1264
+ CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
1265
+ CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
1266
+ CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
1267
+ CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
1268
+ CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
1269
+ CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
1270
+ CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
1271
+ CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
1272
+ DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
1273
+ DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
1274
+ DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
1275
+ DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
1276
+ DeleteResponseFromJSON: () => DeleteResponseFromJSON,
1277
+ DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
1278
+ DeleteResponseToJSON: () => DeleteResponseToJSON,
1279
+ DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
1280
+ GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
1281
+ GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
1282
+ GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
1283
+ GetCompanyInvoicesParamsToJSONTyped: () => GetCompanyInvoicesParamsToJSONTyped,
1284
+ GetCompanyInvoicesResponseFromJSON: () => GetCompanyInvoicesResponseFromJSON,
1285
+ GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
1286
+ GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
1287
+ GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
1288
+ GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
1289
+ GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
1290
+ GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
1291
+ GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
1292
+ GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
1293
+ GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
1294
+ GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
1295
+ GetCompanyUpcomingInvoiceResponseToJSONTyped: () => GetCompanyUpcomingInvoiceResponseToJSONTyped,
1296
+ InvoiceStatus: () => InvoiceStatus,
1297
+ InvoiceStatusFromJSON: () => InvoiceStatusFromJSON,
1298
+ InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
1299
+ InvoiceStatusToJSON: () => InvoiceStatusToJSON,
1300
+ InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
1301
+ PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
1302
+ PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
1303
+ PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
1304
+ PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
1305
+ SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
1306
+ SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
1307
+ SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
1308
+ SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
1309
+ UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
1310
+ UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
1311
+ UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
1312
+ UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
1313
+ UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
1314
+ UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
1315
+ UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
1316
+ UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
1317
+ instanceOfApiError: () => instanceOfApiError,
1318
+ instanceOfBillingProviderType: () => instanceOfBillingProviderType,
1319
+ instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
1320
+ instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
1321
+ instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
1322
+ instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
1323
+ instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
1324
+ instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
1325
+ instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
1326
+ instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
1327
+ instanceOfDeleteResponse: () => instanceOfDeleteResponse,
1328
+ instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
1329
+ instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
1330
+ instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
1331
+ instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
1332
+ instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
1333
+ instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
1334
+ instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
1335
+ instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
1336
+ instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
1337
+ });
1338
+ function instanceOfApiError(value) {
1339
+ if (!("error" in value) || value["error"] === void 0) return false;
1340
+ return true;
1341
+ }
1342
+ function ApiErrorFromJSON(json) {
1343
+ return ApiErrorFromJSONTyped(json, false);
1344
+ }
1345
+ function ApiErrorFromJSONTyped(json, ignoreDiscriminator) {
1346
+ if (json == null) {
1347
+ return json;
1348
+ }
1349
+ return {
1350
+ error: json["error"]
1351
+ };
1352
+ }
1353
+ function ApiErrorToJSON(json) {
1354
+ return ApiErrorToJSONTyped(json, false);
1355
+ }
1356
+ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
1357
+ if (value == null) {
1358
+ return value;
1359
+ }
1360
+ return {
1361
+ error: value["error"]
1362
+ };
1363
+ }
1364
+ var BillingProviderType = {
1365
+ Metronome: "metronome",
1366
+ Orb: "orb",
1367
+ Schematic: "schematic",
1368
+ Stripe: "stripe"
1369
+ };
1370
+ function instanceOfBillingProviderType(value) {
1371
+ for (const key in BillingProviderType) {
1372
+ if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
1373
+ if (BillingProviderType[key] === value) {
1374
+ return true;
1375
+ }
1376
+ }
1377
+ }
1378
+ return false;
1379
+ }
1380
+ function BillingProviderTypeFromJSON2(json) {
1381
+ return BillingProviderTypeFromJSONTyped11(json, false);
1382
+ }
1383
+ function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
1384
+ return json;
1385
+ }
1386
+ function BillingProviderTypeToJSON2(value) {
1387
+ return value;
1388
+ }
1389
+ function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
1390
+ return value;
1391
+ }
1392
+ function instanceOfCompanyDiscountResponseData(value) {
1393
+ if (!("couponName" in value) || value["couponName"] === void 0)
1394
+ return false;
1395
+ if (!("duration" in value) || value["duration"] === void 0) return false;
1396
+ return true;
1397
+ }
1398
+ function CompanyDiscountResponseDataFromJSON(json) {
1399
+ return CompanyDiscountResponseDataFromJSONTyped(json, false);
1400
+ }
1401
+ function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1402
+ if (json == null) {
1403
+ return json;
1404
+ }
1405
+ return {
1406
+ amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
1407
+ couponName: json["coupon_name"],
1408
+ currency: json["currency"] == null ? void 0 : json["currency"],
1409
+ customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
1410
+ duration: json["duration"],
1411
+ durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
1412
+ percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
1413
+ };
1414
+ }
1415
+ function CompanyDiscountResponseDataToJSON(json) {
1416
+ return CompanyDiscountResponseDataToJSONTyped(json, false);
1417
+ }
1418
+ function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1419
+ if (value == null) {
1420
+ return value;
1421
+ }
1422
+ return {
1423
+ amount_off: value["amountOff"],
1424
+ coupon_name: value["couponName"],
1425
+ currency: value["currency"],
1426
+ customer_facing_code: value["customerFacingCode"],
1427
+ duration: value["duration"],
1428
+ duration_in_months: value["durationInMonths"],
1429
+ percent_off: value["percentOff"]
1430
+ };
1431
+ }
1432
+ var InvoiceStatus = {
1433
+ Draft: "draft",
1434
+ Open: "open",
1435
+ Paid: "paid",
1436
+ Uncollectible: "uncollectible",
1437
+ Void: "void"
1438
+ };
1439
+ function instanceOfInvoiceStatus(value) {
1440
+ for (const key in InvoiceStatus) {
1441
+ if (Object.prototype.hasOwnProperty.call(InvoiceStatus, key)) {
1442
+ if (InvoiceStatus[key] === value) {
1443
+ return true;
1444
+ }
1445
+ }
1446
+ }
1447
+ return false;
1448
+ }
1449
+ function InvoiceStatusFromJSON(json) {
1450
+ return InvoiceStatusFromJSONTyped(json, false);
1451
+ }
1452
+ function InvoiceStatusFromJSONTyped(json, ignoreDiscriminator) {
1453
+ return json;
1454
+ }
1455
+ function InvoiceStatusToJSON(value) {
1456
+ return value;
1457
+ }
1458
+ function InvoiceStatusToJSONTyped(value, ignoreDiscriminator) {
1459
+ return value;
1460
+ }
1461
+ function instanceOfCompanyInvoiceResponseData(value) {
1462
+ if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
1463
+ if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
1464
+ if (!("currency" in value) || value["currency"] === void 0) return false;
1465
+ if (!("id" in value) || value["id"] === void 0) return false;
1466
+ return true;
1467
+ }
1468
+ function CompanyInvoiceResponseDataFromJSON(json) {
1469
+ return CompanyInvoiceResponseDataFromJSONTyped(json, false);
1470
+ }
1471
+ function CompanyInvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1472
+ if (json == null) {
1473
+ return json;
1474
+ }
1475
+ return {
1476
+ amountDue: json["amount_due"],
1477
+ createdAt: new Date(json["created_at"]),
1478
+ currency: json["currency"],
1479
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
1480
+ id: json["id"],
1481
+ status: json["status"] == null ? void 0 : InvoiceStatusFromJSON(json["status"]),
1482
+ url: json["url"] == null ? void 0 : json["url"]
1483
+ };
1484
+ }
1485
+ function CompanyInvoiceResponseDataToJSON(json) {
1486
+ return CompanyInvoiceResponseDataToJSONTyped(json, false);
1487
+ }
1488
+ function CompanyInvoiceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1489
+ if (value == null) {
1490
+ return value;
1491
+ }
1492
+ return {
1493
+ amount_due: value["amountDue"],
1494
+ created_at: value["createdAt"].toISOString(),
1495
+ currency: value["currency"],
1496
+ due_date: value["dueDate"] == null ? void 0 : value["dueDate"].toISOString(),
1497
+ id: value["id"],
1498
+ status: InvoiceStatusToJSON(value["status"]),
1499
+ url: value["url"]
1500
+ };
1501
+ }
1502
+ function instanceOfCompanyInvoicesResponseData(value) {
1503
+ if (!("count" in value) || value["count"] === void 0) return false;
1504
+ if (!("invoices" in value) || value["invoices"] === void 0) return false;
1505
+ return true;
1506
+ }
1507
+ function CompanyInvoicesResponseDataFromJSON(json) {
1508
+ return CompanyInvoicesResponseDataFromJSONTyped(json, false);
1509
+ }
1510
+ function CompanyInvoicesResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1511
+ if (json == null) {
1512
+ return json;
1513
+ }
1514
+ return {
1515
+ count: json["count"],
1516
+ invoices: json["invoices"].map(
1517
+ CompanyInvoiceResponseDataFromJSON
1518
+ )
1519
+ };
1520
+ }
1521
+ function CompanyInvoicesResponseDataToJSON(json) {
1522
+ return CompanyInvoicesResponseDataToJSONTyped(json, false);
1523
+ }
1524
+ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1525
+ if (value == null) {
1526
+ return value;
1527
+ }
1528
+ return {
1529
+ count: value["count"],
1530
+ invoices: value["invoices"].map(
1531
+ CompanyInvoiceResponseDataToJSON
1532
+ )
1533
+ };
1534
+ }
1535
+ function instanceOfCompanyPaymentMethodResponseData(value) {
1536
+ if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
1537
+ if (!("externalId" in value) || value["externalId"] === void 0)
1538
+ return false;
1539
+ if (!("id" in value) || value["id"] === void 0) return false;
1540
+ if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
1541
+ if (!("type" in value) || value["type"] === void 0) return false;
1542
+ return true;
1543
+ }
1544
+ function CompanyPaymentMethodResponseDataFromJSON(json) {
1545
+ return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
1546
+ }
1547
+ function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1548
+ if (json == null) {
1549
+ return json;
1550
+ }
1551
+ return {
1552
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
1553
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
1554
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
1555
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
1556
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
1557
+ canRemove: json["can_remove"],
1558
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
1559
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
1560
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
1561
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
1562
+ externalId: json["external_id"],
1563
+ id: json["id"],
1564
+ isDefault: json["is_default"],
1565
+ type: json["type"]
1566
+ };
1567
+ }
1568
+ function CompanyPaymentMethodResponseDataToJSON(json) {
1569
+ return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
1570
+ }
1571
+ function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1572
+ if (value == null) {
1573
+ return value;
1574
+ }
1575
+ return {
1576
+ account_last4: value["accountLast4"],
1577
+ account_name: value["accountName"],
1578
+ bank_name: value["bankName"],
1579
+ billing_email: value["billingEmail"],
1580
+ billing_name: value["billingName"],
1581
+ can_remove: value["canRemove"],
1582
+ card_brand: value["cardBrand"],
1583
+ card_exp_month: value["cardExpMonth"],
1584
+ card_exp_year: value["cardExpYear"],
1585
+ card_last4: value["cardLast4"],
1586
+ external_id: value["externalId"],
1587
+ id: value["id"],
1588
+ is_default: value["isDefault"],
1589
+ type: value["type"]
1590
+ };
1591
+ }
1592
+ function instanceOfCompanyPaymentMethodsResponseData(value) {
1593
+ if (!("count" in value) || value["count"] === void 0) return false;
1594
+ if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
1595
+ return false;
1596
+ return true;
1597
+ }
1598
+ function CompanyPaymentMethodsResponseDataFromJSON(json) {
1599
+ return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
1600
+ }
1601
+ function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1602
+ if (json == null) {
1603
+ return json;
1604
+ }
1605
+ return {
1606
+ count: json["count"],
1607
+ paymentMethods: json["payment_methods"].map(
1608
+ CompanyPaymentMethodResponseDataFromJSON
1609
+ )
1610
+ };
1611
+ }
1612
+ function CompanyPaymentMethodsResponseDataToJSON(json) {
1613
+ return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
1614
+ }
1615
+ function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1616
+ if (value == null) {
1617
+ return value;
1618
+ }
1619
+ return {
1620
+ count: value["count"],
1621
+ payment_methods: value["paymentMethods"].map(
1622
+ CompanyPaymentMethodResponseDataToJSON
1623
+ )
1624
+ };
1625
+ }
1626
+ function instanceOfCompanyUpcomingInvoiceResponseData(value) {
1627
+ if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
1628
+ if (!("currency" in value) || value["currency"] === void 0) return false;
1629
+ if (!("customerBalanceApplied" in value) || value["customerBalanceApplied"] === void 0)
1630
+ return false;
1631
+ if (!("customerBalanceRemaining" in value) || value["customerBalanceRemaining"] === void 0)
1632
+ return false;
1633
+ if (!("discounts" in value) || value["discounts"] === void 0) return false;
1634
+ if (!("subtotal" in value) || value["subtotal"] === void 0) return false;
1635
+ return true;
1636
+ }
1637
+ function CompanyUpcomingInvoiceResponseDataFromJSON(json) {
1638
+ return CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, false);
1639
+ }
1640
+ function CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1641
+ if (json == null) {
1642
+ return json;
1643
+ }
1644
+ return {
1645
+ amountDue: json["amount_due"],
1646
+ currency: json["currency"],
1647
+ customerBalanceApplied: json["customer_balance_applied"],
1648
+ customerBalanceRemaining: json["customer_balance_remaining"],
1649
+ discounts: json["discounts"].map(
1650
+ CompanyDiscountResponseDataFromJSON
1651
+ ),
1652
+ dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
1653
+ subtotal: json["subtotal"]
1654
+ };
1655
+ }
1656
+ function CompanyUpcomingInvoiceResponseDataToJSON(json) {
1657
+ return CompanyUpcomingInvoiceResponseDataToJSONTyped(json, false);
1658
+ }
1659
+ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1660
+ if (value == null) {
1661
+ return value;
1662
+ }
1663
+ return {
1664
+ amount_due: value["amountDue"],
1665
+ currency: value["currency"],
1666
+ customer_balance_applied: value["customerBalanceApplied"],
1667
+ customer_balance_remaining: value["customerBalanceRemaining"],
1668
+ discounts: value["discounts"].map(
1669
+ CompanyDiscountResponseDataToJSON
1670
+ ),
1671
+ due_date: value["dueDate"] == null ? void 0 : value["dueDate"].toISOString(),
1672
+ subtotal: value["subtotal"]
1673
+ };
1674
+ }
1675
+ function instanceOfSetupIntentResponseData(value) {
1676
+ if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
1677
+ return false;
1678
+ return true;
1679
+ }
1680
+ function SetupIntentResponseDataFromJSON(json) {
1681
+ return SetupIntentResponseDataFromJSONTyped(json, false);
1682
+ }
1683
+ function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1684
+ if (json == null) {
1685
+ return json;
1686
+ }
1687
+ return {
1688
+ accountId: json["account_id"] == null ? void 0 : json["account_id"],
1689
+ publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
1690
+ schematicPublishableKey: json["schematic_publishable_key"],
1691
+ setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
1692
+ };
1693
+ }
1694
+ function SetupIntentResponseDataToJSON(json) {
1695
+ return SetupIntentResponseDataToJSONTyped(json, false);
1696
+ }
1697
+ function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1698
+ if (value == null) {
1699
+ return value;
1700
+ }
1701
+ return {
1702
+ account_id: value["accountId"],
1703
+ publishable_key: value["publishableKey"],
1704
+ schematic_publishable_key: value["schematicPublishableKey"],
1705
+ setup_intent_client_secret: value["setupIntentClientSecret"]
1706
+ };
1707
+ }
1708
+ function instanceOfCreateSetupIntentResponse(value) {
1709
+ if (!("data" in value) || value["data"] === void 0) return false;
1710
+ if (!("params" in value) || value["params"] === void 0) return false;
1711
+ return true;
1712
+ }
1713
+ function CreateSetupIntentResponseFromJSON(json) {
1714
+ return CreateSetupIntentResponseFromJSONTyped(json, false);
1715
+ }
1716
+ function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
1717
+ if (json == null) {
1718
+ return json;
1719
+ }
1720
+ return {
1721
+ data: SetupIntentResponseDataFromJSON(json["data"]),
1722
+ params: json["params"]
1723
+ };
1724
+ }
1725
+ function CreateSetupIntentResponseToJSON(json) {
1726
+ return CreateSetupIntentResponseToJSONTyped(json, false);
1727
+ }
1728
+ function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
1729
+ if (value == null) {
1730
+ return value;
1731
+ }
1732
+ return {
1733
+ data: SetupIntentResponseDataToJSON(value["data"]),
1734
+ params: value["params"]
1735
+ };
1736
+ }
1737
+ function instanceOfDeleteResponse(value) {
1738
+ return true;
1739
+ }
1740
+ function DeleteResponseFromJSON(json) {
1741
+ return DeleteResponseFromJSONTyped(json, false);
1742
+ }
1743
+ function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
1744
+ if (json == null) {
1745
+ return json;
1746
+ }
1747
+ return {
1748
+ deleted: json["deleted"] == null ? void 0 : json["deleted"]
1749
+ };
1750
+ }
1751
+ function DeleteResponseToJSON(json) {
1752
+ return DeleteResponseToJSONTyped(json, false);
1753
+ }
1754
+ function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
1755
+ if (value == null) {
1756
+ return value;
1757
+ }
1758
+ return {
1759
+ deleted: value["deleted"]
1760
+ };
1761
+ }
1762
+ function instanceOfDeletePaymentMethodResponse(value) {
1763
+ if (!("data" in value) || value["data"] === void 0) return false;
1764
+ if (!("params" in value) || value["params"] === void 0) return false;
1765
+ return true;
1766
+ }
1767
+ function DeletePaymentMethodResponseFromJSON(json) {
1768
+ return DeletePaymentMethodResponseFromJSONTyped(json, false);
1769
+ }
1770
+ function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
1771
+ if (json == null) {
1772
+ return json;
1773
+ }
1774
+ return {
1775
+ data: DeleteResponseFromJSON(json["data"]),
1776
+ params: json["params"]
1777
+ };
1778
+ }
1779
+ function DeletePaymentMethodResponseToJSON(json) {
1780
+ return DeletePaymentMethodResponseToJSONTyped(json, false);
1781
+ }
1782
+ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
1783
+ if (value == null) {
1784
+ return value;
1785
+ }
1786
+ return {
1787
+ data: DeleteResponseToJSON(value["data"]),
1788
+ params: value["params"]
1789
+ };
1790
+ }
1791
+ function instanceOfGetCompanyInvoicesParams(value) {
1792
+ return true;
1793
+ }
1794
+ function GetCompanyInvoicesParamsFromJSON(json) {
1795
+ return GetCompanyInvoicesParamsFromJSONTyped(json, false);
1796
+ }
1797
+ function GetCompanyInvoicesParamsFromJSONTyped(json, ignoreDiscriminator) {
1798
+ if (json == null) {
1799
+ return json;
1800
+ }
1801
+ return {
1802
+ includePending: json["include_pending"] == null ? void 0 : json["include_pending"],
1803
+ limit: json["limit"] == null ? void 0 : json["limit"],
1804
+ offset: json["offset"] == null ? void 0 : json["offset"]
1805
+ };
1806
+ }
1807
+ function GetCompanyInvoicesParamsToJSON(json) {
1808
+ return GetCompanyInvoicesParamsToJSONTyped(json, false);
1809
+ }
1810
+ function GetCompanyInvoicesParamsToJSONTyped(value, ignoreDiscriminator = false) {
1811
+ if (value == null) {
1812
+ return value;
1813
+ }
1814
+ return {
1815
+ include_pending: value["includePending"],
1816
+ limit: value["limit"],
1817
+ offset: value["offset"]
1818
+ };
1819
+ }
1820
+ function instanceOfGetCompanyInvoicesResponse(value) {
1821
+ if (!("data" in value) || value["data"] === void 0) return false;
1822
+ if (!("params" in value) || value["params"] === void 0) return false;
1823
+ return true;
1824
+ }
1825
+ function GetCompanyInvoicesResponseFromJSON(json) {
1826
+ return GetCompanyInvoicesResponseFromJSONTyped(json, false);
1827
+ }
1828
+ function GetCompanyInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
1829
+ if (json == null) {
1830
+ return json;
1831
+ }
1832
+ return {
1833
+ data: CompanyInvoicesResponseDataFromJSON(json["data"]),
1834
+ params: GetCompanyInvoicesParamsFromJSON(json["params"])
1835
+ };
1836
+ }
1837
+ function GetCompanyInvoicesResponseToJSON(json) {
1838
+ return GetCompanyInvoicesResponseToJSONTyped(json, false);
1839
+ }
1840
+ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = false) {
1841
+ if (value == null) {
1842
+ return value;
1843
+ }
1844
+ return {
1845
+ data: CompanyInvoicesResponseDataToJSON(value["data"]),
1846
+ params: GetCompanyInvoicesParamsToJSON(value["params"])
1847
+ };
1848
+ }
1849
+ function instanceOfGetCompanyPaymentMethodsResponse(value) {
1850
+ if (!("data" in value) || value["data"] === void 0) return false;
1851
+ if (!("params" in value) || value["params"] === void 0) return false;
1852
+ return true;
1853
+ }
1854
+ function GetCompanyPaymentMethodsResponseFromJSON(json) {
1855
+ return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
1856
+ }
1857
+ function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
1858
+ if (json == null) {
1859
+ return json;
1860
+ }
1861
+ return {
1862
+ data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
1863
+ params: json["params"]
1864
+ };
1865
+ }
1866
+ function GetCompanyPaymentMethodsResponseToJSON(json) {
1867
+ return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
1868
+ }
1869
+ function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
1870
+ if (value == null) {
1871
+ return value;
1872
+ }
1873
+ return {
1874
+ data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
1875
+ params: value["params"]
1876
+ };
1877
+ }
1878
+ function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
1879
+ if (!("data" in value) || value["data"] === void 0) return false;
1880
+ if (!("params" in value) || value["params"] === void 0) return false;
1881
+ return true;
1882
+ }
1883
+ function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
1884
+ return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
1885
+ }
1886
+ function GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, ignoreDiscriminator) {
1887
+ if (json == null) {
1888
+ return json;
1889
+ }
1890
+ return {
1891
+ data: CompanyUpcomingInvoiceResponseDataFromJSON(json["data"]),
1892
+ params: json["params"]
1893
+ };
1894
+ }
1895
+ function GetCompanyUpcomingInvoiceResponseToJSON(json) {
1896
+ return GetCompanyUpcomingInvoiceResponseToJSONTyped(json, false);
1897
+ }
1898
+ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator = false) {
1899
+ if (value == null) {
1900
+ return value;
1901
+ }
1902
+ return {
1903
+ data: CompanyUpcomingInvoiceResponseDataToJSON(value["data"]),
1904
+ params: value["params"]
1905
+ };
1906
+ }
1907
+ function instanceOfPaymentMethodResponseData(value) {
1908
+ if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
1909
+ if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
1910
+ return false;
1911
+ if (!("environmentId" in value) || value["environmentId"] === void 0)
1912
+ return false;
1913
+ if (!("externalId" in value) || value["externalId"] === void 0)
1914
+ return false;
1915
+ if (!("id" in value) || value["id"] === void 0) return false;
1916
+ if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
1917
+ return false;
1918
+ if (!("providerType" in value) || value["providerType"] === void 0)
1919
+ return false;
1920
+ if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
1921
+ return true;
1922
+ }
1923
+ function PaymentMethodResponseDataFromJSON(json) {
1924
+ return PaymentMethodResponseDataFromJSONTyped(json, false);
1925
+ }
1926
+ function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1927
+ if (json == null) {
1928
+ return json;
1929
+ }
1930
+ return {
1931
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
1932
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
1933
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
1934
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
1935
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
1936
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
1937
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
1938
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
1939
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
1940
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
1941
+ createdAt: new Date(json["created_at"]),
1942
+ customerExternalId: json["customer_external_id"],
1943
+ environmentId: json["environment_id"],
1944
+ externalId: json["external_id"],
1945
+ id: json["id"],
1946
+ paymentMethodType: json["payment_method_type"],
1947
+ providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
1948
+ updatedAt: new Date(json["updated_at"])
1949
+ };
1950
+ }
1951
+ function PaymentMethodResponseDataToJSON(json) {
1952
+ return PaymentMethodResponseDataToJSONTyped(json, false);
1953
+ }
1954
+ function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1955
+ if (value == null) {
1956
+ return value;
1957
+ }
1958
+ return {
1959
+ account_last4: value["accountLast4"],
1960
+ account_name: value["accountName"],
1961
+ bank_name: value["bankName"],
1962
+ billing_email: value["billingEmail"],
1963
+ billing_name: value["billingName"],
1964
+ card_brand: value["cardBrand"],
1965
+ card_exp_month: value["cardExpMonth"],
1966
+ card_exp_year: value["cardExpYear"],
1967
+ card_last4: value["cardLast4"],
1968
+ company_id: value["companyId"],
1969
+ created_at: value["createdAt"].toISOString(),
1970
+ customer_external_id: value["customerExternalId"],
1971
+ environment_id: value["environmentId"],
1972
+ external_id: value["externalId"],
1973
+ id: value["id"],
1974
+ payment_method_type: value["paymentMethodType"],
1975
+ provider_type: BillingProviderTypeToJSON2(value["providerType"]),
1976
+ updated_at: value["updatedAt"].toISOString()
1977
+ };
1978
+ }
1979
+ function instanceOfUpdatePaymentMethodRequestBody(value) {
1980
+ if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
1981
+ return false;
1982
+ return true;
1983
+ }
1984
+ function UpdatePaymentMethodRequestBodyFromJSON(json) {
1985
+ return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
1986
+ }
1987
+ function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
1988
+ if (json == null) {
1989
+ return json;
1990
+ }
1991
+ return {
1992
+ paymentMethodId: json["payment_method_id"]
1993
+ };
1994
+ }
1995
+ function UpdatePaymentMethodRequestBodyToJSON(json) {
1996
+ return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
1997
+ }
1998
+ function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
1999
+ if (value == null) {
2000
+ return value;
2001
+ }
2002
+ return {
2003
+ payment_method_id: value["paymentMethodId"]
2004
+ };
2005
+ }
2006
+ function instanceOfUpdatePaymentMethodResponse(value) {
2007
+ if (!("data" in value) || value["data"] === void 0) return false;
2008
+ if (!("params" in value) || value["params"] === void 0) return false;
2009
+ return true;
2010
+ }
2011
+ function UpdatePaymentMethodResponseFromJSON(json) {
2012
+ return UpdatePaymentMethodResponseFromJSONTyped(json, false);
2013
+ }
2014
+ function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
2015
+ if (json == null) {
2016
+ return json;
2017
+ }
2018
+ return {
2019
+ data: PaymentMethodResponseDataFromJSON(json["data"]),
2020
+ params: json["params"]
2021
+ };
2022
+ }
2023
+ function UpdatePaymentMethodResponseToJSON(json) {
2024
+ return UpdatePaymentMethodResponseToJSONTyped(json, false);
2025
+ }
2026
+ function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
2027
+ if (value == null) {
2028
+ return value;
2029
+ }
2030
+ return {
2031
+ data: PaymentMethodResponseDataToJSON(value["data"]),
2032
+ params: value["params"]
2033
+ };
2034
+ }
1126
2035
  var anonymousIdKey = "schematicId";
1127
2036
  var flagStateCachePrefix = "schematicCache";
1128
2037
  var flagStateCacheMaxContexts = 10;
1129
2038
  var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
1130
2039
  var emptyCreditBalances = Object.freeze({});
2040
+ var emptyCreditSpendPolicies = [];
1131
2041
  var Schematic = class {
1132
- additionalHeaders = {};
2042
+ _additionalHeaders = {};
1133
2043
  apiKey;
1134
- apiUrl = "https://api.schematichq.com";
2044
+ _apiUrl = "https://api.schematichq.com";
1135
2045
  conn = null;
1136
2046
  context = {};
1137
2047
  debugEnabled = false;
@@ -1145,6 +2055,7 @@ var Schematic = class {
1145
2055
  isPendingListeners = /* @__PURE__ */ new Set();
1146
2056
  planListeners = /* @__PURE__ */ new Set();
1147
2057
  creditBalanceListeners = /* @__PURE__ */ new Set();
2058
+ creditSpendPolicyListeners = /* @__PURE__ */ new Set();
1148
2059
  storage;
1149
2060
  persistFlagState = true;
1150
2061
  flagStateCacheKey;
@@ -1155,6 +2066,7 @@ var Schematic = class {
1155
2066
  featureUsageEventMap = {};
1156
2067
  planChecks = {};
1157
2068
  creditBalances = {};
2069
+ creditSpendPolicies = {};
1158
2070
  webSocketUrl = "wss://api.schematichq.com";
1159
2071
  webSocketConnectionTimeout = 1e4;
1160
2072
  webSocketReconnect = true;
@@ -1211,7 +2123,7 @@ var Schematic = class {
1211
2123
  if (this.offlineEnabled) {
1212
2124
  this.setIsPending(false);
1213
2125
  }
1214
- this.additionalHeaders = {
2126
+ this._additionalHeaders = {
1215
2127
  "X-Schematic-Client-Version": `schematic-js@${version}`,
1216
2128
  ...options?.additionalHeaders ?? {}
1217
2129
  };
@@ -1227,7 +2139,7 @@ var Schematic = class {
1227
2139
  }
1228
2140
  this.hydrateFlagStateFromCache();
1229
2141
  if (options?.apiUrl !== void 0) {
1230
- this.apiUrl = options.apiUrl;
2142
+ this._apiUrl = options.apiUrl;
1231
2143
  }
1232
2144
  if (options?.eventUrl !== void 0) {
1233
2145
  this.eventUrl = options.eventUrl;
@@ -1292,6 +2204,12 @@ var Schematic = class {
1292
2204
  this.debug("Initialized with debug mode enabled");
1293
2205
  }
1294
2206
  }
2207
+ get apiUrl() {
2208
+ return this._apiUrl;
2209
+ }
2210
+ get additionalHeaders() {
2211
+ return { ...this._additionalHeaders };
2212
+ }
1295
2213
  /**
1296
2214
  * Resolve fallback value according to priority order:
1297
2215
  * 1. Callsite fallback value (if provided)
@@ -1377,11 +2295,11 @@ var Schematic = class {
1377
2295
  return resolvedFallbackResult.value;
1378
2296
  }
1379
2297
  if (!this.useWebSocket) {
1380
- const requestUrl = `${this.apiUrl}/flags/${key}/check`;
2298
+ const requestUrl = `${this._apiUrl}/flags/${key}/check`;
1381
2299
  return fetch(requestUrl, {
1382
2300
  method: "POST",
1383
2301
  headers: {
1384
- ...this.additionalHeaders ?? {},
2302
+ ...this._additionalHeaders ?? {},
1385
2303
  "Content-Type": "application/json;charset=UTF-8",
1386
2304
  "X-Schematic-Api-Key": this.apiKey
1387
2305
  },
@@ -1541,6 +2459,19 @@ var Schematic = class {
1541
2459
  this.notifyCreditBalanceListeners(merged);
1542
2460
  }
1543
2461
  }
2462
+ if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
2463
+ const contextStr = contextString(context);
2464
+ const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
2465
+ const previous = this.creditSpendPolicies[contextStr] ?? [];
2466
+ if (!creditSpendPoliciesEqual(previous, next)) {
2467
+ this.creditSpendPolicies[contextStr] = next;
2468
+ this.debug(
2469
+ `WebSocket credit spend policy update received. Notifying listeners`,
2470
+ { creditSpendPolicies: next }
2471
+ );
2472
+ this.notifyCreditSpendPolicyListeners(next);
2473
+ }
2474
+ }
1544
2475
  this.persistContextToCache(contextString(context));
1545
2476
  this.flushContextDependentEventQueue();
1546
2477
  this.setIsPending(false);
@@ -1584,12 +2515,12 @@ var Schematic = class {
1584
2515
  this.debug(`checkFlags offline result: returning empty object`);
1585
2516
  return {};
1586
2517
  }
1587
- const requestUrl = `${this.apiUrl}/flags/check`;
2518
+ const requestUrl = `${this._apiUrl}/flags/check`;
1588
2519
  const requestBody = JSON.stringify(context);
1589
2520
  return fetch(requestUrl, {
1590
2521
  method: "POST",
1591
2522
  headers: {
1592
- ...this.additionalHeaders ?? {},
2523
+ ...this._additionalHeaders ?? {},
1593
2524
  "Content-Type": "application/json;charset=UTF-8",
1594
2525
  "X-Schematic-Api-Key": this.apiKey
1595
2526
  },
@@ -2042,10 +2973,19 @@ var Schematic = class {
2042
2973
  this.creditBalances[contextStr] = balances;
2043
2974
  }
2044
2975
  }
2976
+ let revivedCreditSpendPolicies;
2977
+ if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
2978
+ const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
2979
+ if (policies.length > 0) {
2980
+ revivedCreditSpendPolicies = policies;
2981
+ this.creditSpendPolicies[contextStr] = policies;
2982
+ }
2983
+ }
2045
2984
  fresh[contextStr] = {
2046
2985
  checks: revivedChecks,
2047
2986
  plan: revivedPlan,
2048
2987
  creditBalances: revivedCreditBalances,
2988
+ creditSpendPolicies: revivedCreditSpendPolicies,
2049
2989
  updatedAt: entry.updatedAt
2050
2990
  };
2051
2991
  contextsLoaded += 1;
@@ -2059,7 +2999,8 @@ var Schematic = class {
2059
2999
  const checksForContext = this.checks[contextStr];
2060
3000
  const planForContext = this.planChecks[contextStr];
2061
3001
  const creditBalancesForContext = this.creditBalances[contextStr];
2062
- if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0) {
3002
+ const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
3003
+ if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
2063
3004
  return;
2064
3005
  }
2065
3006
  if (this.cachedFlagState === null) {
@@ -2078,6 +3019,7 @@ var Schematic = class {
2078
3019
  checks: cleanChecks,
2079
3020
  plan: planForContext,
2080
3021
  creditBalances: creditBalancesForContext,
3022
+ creditSpendPolicies: creditSpendPoliciesForContext,
2081
3023
  updatedAt: Date.now()
2082
3024
  };
2083
3025
  const entries = Object.entries(this.cachedFlagState.contexts);
@@ -2094,6 +3036,9 @@ var Schematic = class {
2094
3036
  for (const key of Object.keys(this.creditBalances)) {
2095
3037
  if (!survivorKeys.has(key)) delete this.creditBalances[key];
2096
3038
  }
3039
+ for (const key of Object.keys(this.creditSpendPolicies)) {
3040
+ if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
3041
+ }
2097
3042
  this.cachedFlagState = {
2098
3043
  version: cacheVersion,
2099
3044
  contexts: Object.fromEntries(survivors)
@@ -2136,7 +3081,7 @@ var Schematic = class {
2136
3081
  const response = await fetch(captureUrl, {
2137
3082
  method: "POST",
2138
3083
  headers: {
2139
- ...this.additionalHeaders ?? {},
3084
+ ...this._additionalHeaders ?? {},
2140
3085
  "Content-Type": "application/json;charset=UTF-8"
2141
3086
  },
2142
3087
  body: payload
@@ -2632,7 +3577,7 @@ var Schematic = class {
2632
3577
  }
2633
3578
  });
2634
3579
  this.currentWebSocket = socket;
2635
- const clientVersion = this.additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
3580
+ const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
2636
3581
  const messagePayload = {
2637
3582
  apiKey: this.apiKey,
2638
3583
  clientVersion,
@@ -2688,6 +3633,18 @@ var Schematic = class {
2688
3633
  const contextStr = contextString(this.context);
2689
3634
  return this.creditBalances[contextStr]?.[creditId];
2690
3635
  };
3636
+ /** Get every credit spend policy binding the current context, company-scope first */
3637
+ getCreditSpendPolicies = () => {
3638
+ const contextStr = contextString(this.context);
3639
+ return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
3640
+ };
3641
+ /** Get the spend policies binding a single credit type in the current context */
3642
+ getCreditSpendPoliciesForCredit = (creditId) => {
3643
+ const policies = this.getCreditSpendPolicies().filter(
3644
+ (policy) => policy.creditId === creditId
3645
+ );
3646
+ return policies.length > 0 ? policies : emptyCreditSpendPolicies;
3647
+ };
2691
3648
  // flag checks state
2692
3649
  getFlagCheck = (flagKey) => {
2693
3650
  const contextStr = contextString(this.context);
@@ -2754,6 +3711,13 @@ var Schematic = class {
2754
3711
  this.creditBalanceListeners.delete(listener);
2755
3712
  };
2756
3713
  };
3714
+ /** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
3715
+ addCreditSpendPolicyListener = (listener) => {
3716
+ this.creditSpendPolicyListeners.add(listener);
3717
+ return () => {
3718
+ this.creditSpendPolicyListeners.delete(listener);
3719
+ };
3720
+ };
2757
3721
  notifyFlagCheckListeners = (flagKey, check) => {
2758
3722
  const listeners = this.flagCheckListeners?.[flagKey] ?? [];
2759
3723
  if (listeners.size > 0) {
@@ -2817,6 +3781,16 @@ var Schematic = class {
2817
3781
  });
2818
3782
  });
2819
3783
  };
3784
+ notifyCreditSpendPolicyListeners = (value) => {
3785
+ const listeners = this.creditSpendPolicyListeners ?? [];
3786
+ listeners.forEach((listener) => {
3787
+ if (listener.length > 0) {
3788
+ listener(value);
3789
+ return;
3790
+ }
3791
+ listener();
3792
+ });
3793
+ };
2820
3794
  notifyCreditBalanceListeners = (value) => {
2821
3795
  const listeners = this.creditBalanceListeners ?? [];
2822
3796
  if (listeners.size > 0) {
@@ -2869,10 +3843,10 @@ var notifyCreditBalanceListener = (listener, value) => {
2869
3843
  import { inject, onScopeDispose } from "vue";
2870
3844
 
2871
3845
  // src/version.ts
2872
- var version2 = "1.5.0";
3846
+ var version2 = "1.7.0";
2873
3847
 
2874
3848
  // src/context/schematic.ts
2875
- var SchematicSymbol = Symbol("schematic");
3849
+ var SchematicSymbol = /* @__PURE__ */ Symbol("schematic");
2876
3850
  var SchematicPlugin = {
2877
3851
  install(app, options) {
2878
3852
  let client;
@@ -2909,7 +3883,14 @@ var useSchematic = () => {
2909
3883
  };
2910
3884
 
2911
3885
  // src/composables/schematic.ts
2912
- import { computed, onMounted, onScopeDispose as onScopeDispose2, ref } from "vue";
3886
+ import {
3887
+ computed,
3888
+ onMounted,
3889
+ onScopeDispose as onScopeDispose2,
3890
+ ref,
3891
+ toValue,
3892
+ watch
3893
+ } from "vue";
2913
3894
  var useSchematicClient = (opts) => {
2914
3895
  const schematic = useSchematic();
2915
3896
  const { client } = opts ?? {};
@@ -2979,10 +3960,17 @@ var useSchematicEntitlement = (key, opts) => {
2979
3960
  featureUsageExceeded: computed(() => flagCheck.value.featureUsageExceeded),
2980
3961
  featureUsageEvent: computed(() => flagCheck.value.featureUsageEvent),
2981
3962
  featureUsagePeriod: computed(() => flagCheck.value.featureUsagePeriod),
3963
+ softLimit: computed(() => flagCheck.value.softLimit),
3964
+ warningTiers: computed(() => flagCheck.value.warningTiers),
2982
3965
  flagId: computed(() => flagCheck.value.flagId),
2983
3966
  ruleId: computed(() => flagCheck.value.ruleId),
2984
3967
  companyId: computed(() => flagCheck.value.companyId),
2985
- userId: computed(() => flagCheck.value.userId)
3968
+ userId: computed(() => flagCheck.value.userId),
3969
+ // Credit fields, populated for features metered by credit burndown
3970
+ creditId: computed(() => flagCheck.value.creditId),
3971
+ creditSettled: computed(() => flagCheck.value.creditSettled),
3972
+ creditRemaining: computed(() => flagCheck.value.creditRemaining),
3973
+ creditReserved: computed(() => flagCheck.value.creditReserved)
2986
3974
  };
2987
3975
  };
2988
3976
  var useSchematicPlan = (opts) => {
@@ -3004,15 +3992,25 @@ var useSchematicPlan = (opts) => {
3004
3992
  };
3005
3993
  var useSchematicCreditBalance = (creditId, opts) => {
3006
3994
  const client = useSchematicClient(opts);
3995
+ const resolvedCreditId = computed(() => toValue(creditId));
3996
+ const readBalance = () => {
3997
+ const id = resolvedCreditId.value;
3998
+ return id === void 0 ? void 0 : client.getCreditBalance(id);
3999
+ };
3007
4000
  const creditBalance = ref(
3008
- client.getCreditBalance(creditId)
4001
+ readBalance()
3009
4002
  );
3010
4003
  const isPending = ref(client.getIsPending());
4004
+ watch(resolvedCreditId, () => {
4005
+ creditBalance.value = readBalance();
4006
+ });
3011
4007
  let unsubscribeBalance = null;
3012
4008
  let unsubscribePending = null;
3013
4009
  onMounted(() => {
4010
+ creditBalance.value = readBalance();
4011
+ isPending.value = client.getIsPending();
3014
4012
  unsubscribeBalance = client.addCreditBalanceListener(() => {
3015
- creditBalance.value = client.getCreditBalance(creditId);
4013
+ creditBalance.value = readBalance();
3016
4014
  });
3017
4015
  unsubscribePending = client.addIsPendingListener(() => {
3018
4016
  isPending.value = client.getIsPending();
@@ -3031,6 +4029,36 @@ var useSchematicCreditBalance = (creditId, opts) => {
3031
4029
  )
3032
4030
  };
3033
4031
  };
4032
+ var useSchematicCreditSpendPolicies = (opts) => {
4033
+ const client = useSchematicClient(opts);
4034
+ const policies = ref(
4035
+ client.getCreditSpendPolicies()
4036
+ );
4037
+ const isPending = ref(client.getIsPending());
4038
+ let unsubscribePolicies = null;
4039
+ let unsubscribePending = null;
4040
+ onMounted(() => {
4041
+ policies.value = client.getCreditSpendPolicies();
4042
+ isPending.value = client.getIsPending();
4043
+ unsubscribePolicies = client.addCreditSpendPolicyListener(() => {
4044
+ policies.value = client.getCreditSpendPolicies();
4045
+ });
4046
+ unsubscribePending = client.addIsPendingListener(() => {
4047
+ isPending.value = client.getIsPending();
4048
+ policies.value = client.getCreditSpendPolicies();
4049
+ });
4050
+ });
4051
+ onScopeDispose2(() => {
4052
+ unsubscribePolicies?.();
4053
+ unsubscribePending?.();
4054
+ });
4055
+ return {
4056
+ /** Company-scope policies first, then the user's own; empty when none bind */
4057
+ policies: computed(() => policies.value),
4058
+ /** True while the policies are still loading and nothing has arrived yet */
4059
+ isLoading: computed(() => policies.value.length === 0 && isPending.value)
4060
+ };
4061
+ };
3034
4062
  var useSchematicIsPending = (opts) => {
3035
4063
  const client = useSchematicClient(opts);
3036
4064
  const isPending = ref(client.getIsPending());
@@ -3054,6 +4082,7 @@ export {
3054
4082
  useSchematicClient,
3055
4083
  useSchematicContext,
3056
4084
  useSchematicCreditBalance,
4085
+ useSchematicCreditSpendPolicies,
3057
4086
  useSchematicEntitlement,
3058
4087
  useSchematicEvents,
3059
4088
  useSchematicFlag,