@schematichq/schematic-react 1.10.0 → 1.12.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.
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  BillingDataProvider: () => BillingDataProvider,
34
34
  BillingProvider: () => BillingProvider,
35
35
  DEFAULT_INVOICE_QUERY: () => DEFAULT_INVOICE_QUERY,
36
+ FEATURE_USER_USAGE_LIMIT: () => FEATURE_USER_USAGE_LIMIT,
36
37
  INVOICE_PAGE_SIZE: () => INVOICE_PAGE_SIZE,
37
38
  InvoiceStatus: () => InvoiceStatus,
38
39
  RuleType: () => RuleType,
@@ -45,6 +46,10 @@ __export(index_exports, {
45
46
  UsagePeriod: () => UsagePeriod,
46
47
  normalizeInvoiceQuery: () => normalizeInvoiceQuery2,
47
48
  useBillingDataSource: () => useBillingDataSource,
49
+ useCreditBalances: () => useCreditBalances,
50
+ useCreditUserUsage: () => useCreditUserUsage,
51
+ useFeatureUsage: () => useFeatureUsage,
52
+ useFeatureUserUsage: () => useFeatureUserUsage,
48
53
  useInvalidateBillingData: () => useInvalidateBillingData,
49
54
  useInvoices: () => useInvoices,
50
55
  usePaymentMethods: () => usePaymentMethods,
@@ -66,7 +71,7 @@ __export(index_exports, {
66
71
  });
67
72
  module.exports = __toCommonJS(index_exports);
68
73
 
69
- // node_modules/.pnpm/@schematichq+schematic-js@1.10.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
74
+ // node_modules/.pnpm/@schematichq+schematic-js@1.12.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
70
75
  var __create2 = Object.create;
71
76
  var __defProp2 = Object.defineProperty;
72
77
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -726,6 +731,7 @@ function FeatureEntitlementFromJSONTyped(json, ignoreDiscriminator) {
726
731
  metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON(json["metric_period"]),
727
732
  metricResetAt: json["metric_reset_at"] == null ? void 0 : new Date(json["metric_reset_at"]),
728
733
  monthReset: json["month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON(json["month_reset"]),
734
+ quantityRates: json["quantity_rates"] == null ? void 0 : json["quantity_rates"],
729
735
  softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
730
736
  usage: json["usage"] == null ? void 0 : json["usage"],
731
737
  valueType: EntitlementValueTypeFromJSON(json["value_type"]),
@@ -1302,7 +1308,98 @@ function contextString(context) {
1302
1308
  }, {});
1303
1309
  return JSON.stringify(sortedContext);
1304
1310
  }
1305
- var version = "1.10.0";
1311
+ var contextSignatureHeader = "X-Schematic-Context-Sig";
1312
+ var refreshSkewMs = 6e4;
1313
+ var maxCachedSignatures = 50;
1314
+ function parseSignatureExpiryMs(signature) {
1315
+ const parts = signature.split(".");
1316
+ if (parts.length !== 3) {
1317
+ return null;
1318
+ }
1319
+ const expSeconds = Number(parts[1]);
1320
+ if (!Number.isFinite(expSeconds)) {
1321
+ return null;
1322
+ }
1323
+ return expSeconds * 1e3;
1324
+ }
1325
+ var ContextSignatureManager = class {
1326
+ provider;
1327
+ debug;
1328
+ cache = /* @__PURE__ */ new Map();
1329
+ inFlight = /* @__PURE__ */ new Map();
1330
+ constructor(provider, debug) {
1331
+ this.provider = provider;
1332
+ this.debug = debug;
1333
+ }
1334
+ /**
1335
+ * Return a valid signature for the given context, fetching a fresh one via
1336
+ * the provider when the cache is empty or close to expiry. Concurrent calls
1337
+ * for the same context share a single provider invocation. Returns undefined
1338
+ * (and logs a warning) if the provider throws, so callers can degrade
1339
+ * gracefully by sending the request without a signature.
1340
+ */
1341
+ async getSignature(context) {
1342
+ const key = contextString(context);
1343
+ const cached = this.cache.get(key);
1344
+ if (cached !== void 0 && Date.now() < cached.expiresAtMs - refreshSkewMs) {
1345
+ this.cache.delete(key);
1346
+ this.cache.set(key, cached);
1347
+ return cached.signature;
1348
+ }
1349
+ const existing = this.inFlight.get(key);
1350
+ if (existing !== void 0) {
1351
+ return existing;
1352
+ }
1353
+ const pending = this.fetchSignature(key, context).finally(() => {
1354
+ this.inFlight.delete(key);
1355
+ });
1356
+ this.inFlight.set(key, pending);
1357
+ return pending;
1358
+ }
1359
+ /** Drop all cached signatures. */
1360
+ clear() {
1361
+ this.cache.clear();
1362
+ }
1363
+ /**
1364
+ * Drop expired signatures, then the least recently used ones until the cache
1365
+ * is within `maxCachedSignatures`.
1366
+ */
1367
+ evict() {
1368
+ const now = Date.now();
1369
+ for (const [key, entry] of this.cache) {
1370
+ if (now >= entry.expiresAtMs) {
1371
+ this.cache.delete(key);
1372
+ }
1373
+ }
1374
+ for (const key of this.cache.keys()) {
1375
+ if (this.cache.size <= maxCachedSignatures) {
1376
+ break;
1377
+ }
1378
+ this.cache.delete(key);
1379
+ }
1380
+ }
1381
+ async fetchSignature(key, context) {
1382
+ try {
1383
+ const signature = await this.provider(context);
1384
+ const expiresAtMs = parseSignatureExpiryMs(signature);
1385
+ if (expiresAtMs === null) {
1386
+ this.debug(
1387
+ "getContextSignature returned a value without a parseable expiry; not caching",
1388
+ { signature }
1389
+ );
1390
+ return signature;
1391
+ }
1392
+ this.cache.delete(key);
1393
+ this.cache.set(key, { signature, expiresAtMs });
1394
+ this.evict();
1395
+ return signature;
1396
+ } catch (error) {
1397
+ console.warn("Failed to obtain context signature:", error);
1398
+ return void 0;
1399
+ }
1400
+ }
1401
+ };
1402
+ var version = "1.12.0";
1306
1403
  var SINGLETON = {};
1307
1404
  var models_exports = {};
1308
1405
  __export2(models_exports, {
@@ -1310,15 +1407,88 @@ __export2(models_exports, {
1310
1407
  ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
1311
1408
  ApiErrorToJSON: () => ApiErrorToJSON,
1312
1409
  ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
1410
+ BillingCreditGrantReason: () => BillingCreditGrantReason,
1411
+ BillingCreditGrantReasonFromJSON: () => BillingCreditGrantReasonFromJSON,
1412
+ BillingCreditGrantReasonFromJSONTyped: () => BillingCreditGrantReasonFromJSONTyped,
1413
+ BillingCreditGrantReasonToJSON: () => BillingCreditGrantReasonToJSON,
1414
+ BillingCreditGrantReasonToJSONTyped: () => BillingCreditGrantReasonToJSONTyped,
1415
+ BillingPlanCreditGrantResetCadence: () => BillingPlanCreditGrantResetCadence,
1416
+ BillingPlanCreditGrantResetCadenceFromJSON: () => BillingPlanCreditGrantResetCadenceFromJSON2,
1417
+ BillingPlanCreditGrantResetCadenceFromJSONTyped: () => BillingPlanCreditGrantResetCadenceFromJSONTyped3,
1418
+ BillingPlanCreditGrantResetCadenceToJSON: () => BillingPlanCreditGrantResetCadenceToJSON2,
1419
+ BillingPlanCreditGrantResetCadenceToJSONTyped: () => BillingPlanCreditGrantResetCadenceToJSONTyped3,
1420
+ BillingPriceScheme: () => BillingPriceScheme,
1421
+ BillingPriceSchemeFromJSON: () => BillingPriceSchemeFromJSON2,
1422
+ BillingPriceSchemeFromJSONTyped: () => BillingPriceSchemeFromJSONTyped4,
1423
+ BillingPriceSchemeToJSON: () => BillingPriceSchemeToJSON2,
1424
+ BillingPriceSchemeToJSONTyped: () => BillingPriceSchemeToJSONTyped4,
1425
+ BillingProductPriceInterval: () => BillingProductPriceInterval,
1426
+ BillingProductPriceIntervalFromJSON: () => BillingProductPriceIntervalFromJSON2,
1427
+ BillingProductPriceIntervalFromJSONTyped: () => BillingProductPriceIntervalFromJSONTyped4,
1428
+ BillingProductPriceIntervalToJSON: () => BillingProductPriceIntervalToJSON2,
1429
+ BillingProductPriceIntervalToJSONTyped: () => BillingProductPriceIntervalToJSONTyped4,
1313
1430
  BillingProviderType: () => BillingProviderType,
1314
1431
  BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
1315
1432
  BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
1316
1433
  BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
1317
1434
  BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
1435
+ BillingTiersMode: () => BillingTiersMode,
1436
+ BillingTiersModeFromJSON: () => BillingTiersModeFromJSON2,
1437
+ BillingTiersModeFromJSONTyped: () => BillingTiersModeFromJSONTyped4,
1438
+ BillingTiersModeToJSON: () => BillingTiersModeToJSON2,
1439
+ BillingTiersModeToJSONTyped: () => BillingTiersModeToJSONTyped4,
1440
+ CatalogCreditGrantResponseDataFromJSON: () => CatalogCreditGrantResponseDataFromJSON,
1441
+ CatalogCreditGrantResponseDataFromJSONTyped: () => CatalogCreditGrantResponseDataFromJSONTyped,
1442
+ CatalogCreditGrantResponseDataToJSON: () => CatalogCreditGrantResponseDataToJSON,
1443
+ CatalogCreditGrantResponseDataToJSONTyped: () => CatalogCreditGrantResponseDataToJSONTyped,
1444
+ CatalogPriceResponseDataFromJSON: () => CatalogPriceResponseDataFromJSON,
1445
+ CatalogPriceResponseDataFromJSONTyped: () => CatalogPriceResponseDataFromJSONTyped,
1446
+ CatalogPriceResponseDataToJSON: () => CatalogPriceResponseDataToJSON,
1447
+ CatalogPriceResponseDataToJSONTyped: () => CatalogPriceResponseDataToJSONTyped,
1448
+ CatalogPriceTierResponseDataFromJSON: () => CatalogPriceTierResponseDataFromJSON,
1449
+ CatalogPriceTierResponseDataFromJSONTyped: () => CatalogPriceTierResponseDataFromJSONTyped,
1450
+ CatalogPriceTierResponseDataToJSON: () => CatalogPriceTierResponseDataToJSON,
1451
+ CatalogPriceTierResponseDataToJSONTyped: () => CatalogPriceTierResponseDataToJSONTyped,
1452
+ CompanyCreditBalanceResponseDataFromJSON: () => CompanyCreditBalanceResponseDataFromJSON,
1453
+ CompanyCreditBalanceResponseDataFromJSONTyped: () => CompanyCreditBalanceResponseDataFromJSONTyped,
1454
+ CompanyCreditBalanceResponseDataToJSON: () => CompanyCreditBalanceResponseDataToJSON,
1455
+ CompanyCreditBalanceResponseDataToJSONTyped: () => CompanyCreditBalanceResponseDataToJSONTyped,
1456
+ CompanyCreditBalancesResponseDataFromJSON: () => CompanyCreditBalancesResponseDataFromJSON,
1457
+ CompanyCreditBalancesResponseDataFromJSONTyped: () => CompanyCreditBalancesResponseDataFromJSONTyped,
1458
+ CompanyCreditBalancesResponseDataToJSON: () => CompanyCreditBalancesResponseDataToJSON,
1459
+ CompanyCreditBalancesResponseDataToJSONTyped: () => CompanyCreditBalancesResponseDataToJSONTyped,
1460
+ CompanyCreditCompositionResponseDataFromJSON: () => CompanyCreditCompositionResponseDataFromJSON,
1461
+ CompanyCreditCompositionResponseDataFromJSONTyped: () => CompanyCreditCompositionResponseDataFromJSONTyped,
1462
+ CompanyCreditCompositionResponseDataToJSON: () => CompanyCreditCompositionResponseDataToJSON,
1463
+ CompanyCreditCompositionResponseDataToJSONTyped: () => CompanyCreditCompositionResponseDataToJSONTyped,
1464
+ CompanyCreditGrantResponseDataFromJSON: () => CompanyCreditGrantResponseDataFromJSON,
1465
+ CompanyCreditGrantResponseDataFromJSONTyped: () => CompanyCreditGrantResponseDataFromJSONTyped,
1466
+ CompanyCreditGrantResponseDataToJSON: () => CompanyCreditGrantResponseDataToJSON,
1467
+ CompanyCreditGrantResponseDataToJSONTyped: () => CompanyCreditGrantResponseDataToJSONTyped,
1468
+ CompanyCreditUserUsageResponseDataFromJSON: () => CompanyCreditUserUsageResponseDataFromJSON,
1469
+ CompanyCreditUserUsageResponseDataFromJSONTyped: () => CompanyCreditUserUsageResponseDataFromJSONTyped,
1470
+ CompanyCreditUserUsageResponseDataToJSON: () => CompanyCreditUserUsageResponseDataToJSON,
1471
+ CompanyCreditUserUsageResponseDataToJSONTyped: () => CompanyCreditUserUsageResponseDataToJSONTyped,
1472
+ CompanyCreditUserUsageRowResponseDataFromJSON: () => CompanyCreditUserUsageRowResponseDataFromJSON,
1473
+ CompanyCreditUserUsageRowResponseDataFromJSONTyped: () => CompanyCreditUserUsageRowResponseDataFromJSONTyped,
1474
+ CompanyCreditUserUsageRowResponseDataToJSON: () => CompanyCreditUserUsageRowResponseDataToJSON,
1475
+ CompanyCreditUserUsageRowResponseDataToJSONTyped: () => CompanyCreditUserUsageRowResponseDataToJSONTyped,
1318
1476
  CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
1319
1477
  CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
1320
1478
  CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
1321
1479
  CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
1480
+ CompanyFeatureUsageListResponseDataFromJSON: () => CompanyFeatureUsageListResponseDataFromJSON,
1481
+ CompanyFeatureUsageListResponseDataFromJSONTyped: () => CompanyFeatureUsageListResponseDataFromJSONTyped,
1482
+ CompanyFeatureUsageListResponseDataToJSON: () => CompanyFeatureUsageListResponseDataToJSON,
1483
+ CompanyFeatureUsageListResponseDataToJSONTyped: () => CompanyFeatureUsageListResponseDataToJSONTyped,
1484
+ CompanyFeatureUsageResponseDataFromJSON: () => CompanyFeatureUsageResponseDataFromJSON,
1485
+ CompanyFeatureUsageResponseDataFromJSONTyped: () => CompanyFeatureUsageResponseDataFromJSONTyped,
1486
+ CompanyFeatureUsageResponseDataToJSON: () => CompanyFeatureUsageResponseDataToJSON,
1487
+ CompanyFeatureUsageResponseDataToJSONTyped: () => CompanyFeatureUsageResponseDataToJSONTyped,
1488
+ CompanyFeatureUserUsageResponseDataFromJSON: () => CompanyFeatureUserUsageResponseDataFromJSON,
1489
+ CompanyFeatureUserUsageResponseDataFromJSONTyped: () => CompanyFeatureUserUsageResponseDataFromJSONTyped,
1490
+ CompanyFeatureUserUsageResponseDataToJSON: () => CompanyFeatureUserUsageResponseDataToJSON,
1491
+ CompanyFeatureUserUsageResponseDataToJSONTyped: () => CompanyFeatureUserUsageResponseDataToJSONTyped,
1322
1492
  CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
1323
1493
  CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
1324
1494
  CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
@@ -1339,6 +1509,10 @@ __export2(models_exports, {
1339
1509
  CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
1340
1510
  CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
1341
1511
  CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
1512
+ CompanyUserUsageResponseDataFromJSON: () => CompanyUserUsageResponseDataFromJSON,
1513
+ CompanyUserUsageResponseDataFromJSONTyped: () => CompanyUserUsageResponseDataFromJSONTyped,
1514
+ CompanyUserUsageResponseDataToJSON: () => CompanyUserUsageResponseDataToJSON,
1515
+ CompanyUserUsageResponseDataToJSONTyped: () => CompanyUserUsageResponseDataToJSONTyped,
1342
1516
  CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
1343
1517
  CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
1344
1518
  CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
@@ -1351,6 +1525,50 @@ __export2(models_exports, {
1351
1525
  DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
1352
1526
  DeleteResponseToJSON: () => DeleteResponseToJSON,
1353
1527
  DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
1528
+ EntitlementPriceBehavior: () => EntitlementPriceBehavior,
1529
+ EntitlementPriceBehaviorFromJSON: () => EntitlementPriceBehaviorFromJSON2,
1530
+ EntitlementPriceBehaviorFromJSONTyped: () => EntitlementPriceBehaviorFromJSONTyped2,
1531
+ EntitlementPriceBehaviorToJSON: () => EntitlementPriceBehaviorToJSON2,
1532
+ EntitlementPriceBehaviorToJSONTyped: () => EntitlementPriceBehaviorToJSONTyped2,
1533
+ EntitlementType: () => EntitlementType,
1534
+ EntitlementTypeFromJSON: () => EntitlementTypeFromJSON,
1535
+ EntitlementTypeFromJSONTyped: () => EntitlementTypeFromJSONTyped,
1536
+ EntitlementTypeToJSON: () => EntitlementTypeToJSON,
1537
+ EntitlementTypeToJSONTyped: () => EntitlementTypeToJSONTyped,
1538
+ EntitlementValueType: () => EntitlementValueType,
1539
+ EntitlementValueTypeFromJSON: () => EntitlementValueTypeFromJSON2,
1540
+ EntitlementValueTypeFromJSONTyped: () => EntitlementValueTypeFromJSONTyped4,
1541
+ EntitlementValueTypeToJSON: () => EntitlementValueTypeToJSON2,
1542
+ EntitlementValueTypeToJSONTyped: () => EntitlementValueTypeToJSONTyped3,
1543
+ FeatureType: () => FeatureType,
1544
+ FeatureTypeFromJSON: () => FeatureTypeFromJSON2,
1545
+ FeatureTypeFromJSONTyped: () => FeatureTypeFromJSONTyped3,
1546
+ FeatureTypeToJSON: () => FeatureTypeToJSON2,
1547
+ FeatureTypeToJSONTyped: () => FeatureTypeToJSONTyped3,
1548
+ GetCompanyCreditBalancesResponseFromJSON: () => GetCompanyCreditBalancesResponseFromJSON,
1549
+ GetCompanyCreditBalancesResponseFromJSONTyped: () => GetCompanyCreditBalancesResponseFromJSONTyped,
1550
+ GetCompanyCreditBalancesResponseToJSON: () => GetCompanyCreditBalancesResponseToJSON,
1551
+ GetCompanyCreditBalancesResponseToJSONTyped: () => GetCompanyCreditBalancesResponseToJSONTyped,
1552
+ GetCompanyCreditUserUsageParamsFromJSON: () => GetCompanyCreditUserUsageParamsFromJSON,
1553
+ GetCompanyCreditUserUsageParamsFromJSONTyped: () => GetCompanyCreditUserUsageParamsFromJSONTyped,
1554
+ GetCompanyCreditUserUsageParamsToJSON: () => GetCompanyCreditUserUsageParamsToJSON,
1555
+ GetCompanyCreditUserUsageParamsToJSONTyped: () => GetCompanyCreditUserUsageParamsToJSONTyped,
1556
+ GetCompanyCreditUserUsageResponseFromJSON: () => GetCompanyCreditUserUsageResponseFromJSON,
1557
+ GetCompanyCreditUserUsageResponseFromJSONTyped: () => GetCompanyCreditUserUsageResponseFromJSONTyped,
1558
+ GetCompanyCreditUserUsageResponseToJSON: () => GetCompanyCreditUserUsageResponseToJSON,
1559
+ GetCompanyCreditUserUsageResponseToJSONTyped: () => GetCompanyCreditUserUsageResponseToJSONTyped,
1560
+ GetCompanyFeatureUsageResponseFromJSON: () => GetCompanyFeatureUsageResponseFromJSON,
1561
+ GetCompanyFeatureUsageResponseFromJSONTyped: () => GetCompanyFeatureUsageResponseFromJSONTyped,
1562
+ GetCompanyFeatureUsageResponseToJSON: () => GetCompanyFeatureUsageResponseToJSON,
1563
+ GetCompanyFeatureUsageResponseToJSONTyped: () => GetCompanyFeatureUsageResponseToJSONTyped,
1564
+ GetCompanyFeatureUserUsageParamsFromJSON: () => GetCompanyFeatureUserUsageParamsFromJSON,
1565
+ GetCompanyFeatureUserUsageParamsFromJSONTyped: () => GetCompanyFeatureUserUsageParamsFromJSONTyped,
1566
+ GetCompanyFeatureUserUsageParamsToJSON: () => GetCompanyFeatureUserUsageParamsToJSON,
1567
+ GetCompanyFeatureUserUsageParamsToJSONTyped: () => GetCompanyFeatureUserUsageParamsToJSONTyped,
1568
+ GetCompanyFeatureUserUsageResponseFromJSON: () => GetCompanyFeatureUserUsageResponseFromJSON,
1569
+ GetCompanyFeatureUserUsageResponseFromJSONTyped: () => GetCompanyFeatureUserUsageResponseFromJSONTyped,
1570
+ GetCompanyFeatureUserUsageResponseToJSON: () => GetCompanyFeatureUserUsageResponseToJSON,
1571
+ GetCompanyFeatureUserUsageResponseToJSONTyped: () => GetCompanyFeatureUserUsageResponseToJSONTyped,
1354
1572
  GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
1355
1573
  GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
1356
1574
  GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
@@ -1372,10 +1590,25 @@ __export2(models_exports, {
1372
1590
  InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
1373
1591
  InvoiceStatusToJSON: () => InvoiceStatusToJSON,
1374
1592
  InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
1593
+ MetricPeriod: () => MetricPeriod,
1594
+ MetricPeriodFromJSON: () => MetricPeriodFromJSON2,
1595
+ MetricPeriodFromJSONTyped: () => MetricPeriodFromJSONTyped7,
1596
+ MetricPeriodMonthReset: () => MetricPeriodMonthReset,
1597
+ MetricPeriodMonthResetFromJSON: () => MetricPeriodMonthResetFromJSON2,
1598
+ MetricPeriodMonthResetFromJSONTyped: () => MetricPeriodMonthResetFromJSONTyped6,
1599
+ MetricPeriodMonthResetToJSON: () => MetricPeriodMonthResetToJSON2,
1600
+ MetricPeriodMonthResetToJSONTyped: () => MetricPeriodMonthResetToJSONTyped5,
1601
+ MetricPeriodToJSON: () => MetricPeriodToJSON2,
1602
+ MetricPeriodToJSONTyped: () => MetricPeriodToJSONTyped6,
1375
1603
  PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
1376
1604
  PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
1377
1605
  PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
1378
1606
  PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
1607
+ PlanCreditGrantScaling: () => PlanCreditGrantScaling,
1608
+ PlanCreditGrantScalingFromJSON: () => PlanCreditGrantScalingFromJSON2,
1609
+ PlanCreditGrantScalingFromJSONTyped: () => PlanCreditGrantScalingFromJSONTyped3,
1610
+ PlanCreditGrantScalingToJSON: () => PlanCreditGrantScalingToJSON2,
1611
+ PlanCreditGrantScalingToJSONTyped: () => PlanCreditGrantScalingToJSONTyped3,
1379
1612
  SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
1380
1613
  SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
1381
1614
  SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
@@ -1389,22 +1622,53 @@ __export2(models_exports, {
1389
1622
  UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
1390
1623
  UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
1391
1624
  instanceOfApiError: () => instanceOfApiError,
1625
+ instanceOfBillingCreditGrantReason: () => instanceOfBillingCreditGrantReason,
1626
+ instanceOfBillingPlanCreditGrantResetCadence: () => instanceOfBillingPlanCreditGrantResetCadence,
1627
+ instanceOfBillingPriceScheme: () => instanceOfBillingPriceScheme,
1628
+ instanceOfBillingProductPriceInterval: () => instanceOfBillingProductPriceInterval,
1392
1629
  instanceOfBillingProviderType: () => instanceOfBillingProviderType,
1630
+ instanceOfBillingTiersMode: () => instanceOfBillingTiersMode,
1631
+ instanceOfCatalogCreditGrantResponseData: () => instanceOfCatalogCreditGrantResponseData,
1632
+ instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
1633
+ instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
1634
+ instanceOfCompanyCreditBalanceResponseData: () => instanceOfCompanyCreditBalanceResponseData,
1635
+ instanceOfCompanyCreditBalancesResponseData: () => instanceOfCompanyCreditBalancesResponseData,
1636
+ instanceOfCompanyCreditCompositionResponseData: () => instanceOfCompanyCreditCompositionResponseData,
1637
+ instanceOfCompanyCreditGrantResponseData: () => instanceOfCompanyCreditGrantResponseData,
1638
+ instanceOfCompanyCreditUserUsageResponseData: () => instanceOfCompanyCreditUserUsageResponseData,
1639
+ instanceOfCompanyCreditUserUsageRowResponseData: () => instanceOfCompanyCreditUserUsageRowResponseData,
1393
1640
  instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
1641
+ instanceOfCompanyFeatureUsageListResponseData: () => instanceOfCompanyFeatureUsageListResponseData,
1642
+ instanceOfCompanyFeatureUsageResponseData: () => instanceOfCompanyFeatureUsageResponseData,
1643
+ instanceOfCompanyFeatureUserUsageResponseData: () => instanceOfCompanyFeatureUserUsageResponseData,
1394
1644
  instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
1395
1645
  instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
1396
1646
  instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
1397
1647
  instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
1398
1648
  instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
1649
+ instanceOfCompanyUserUsageResponseData: () => instanceOfCompanyUserUsageResponseData,
1399
1650
  instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
1400
1651
  instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
1401
1652
  instanceOfDeleteResponse: () => instanceOfDeleteResponse,
1653
+ instanceOfEntitlementPriceBehavior: () => instanceOfEntitlementPriceBehavior,
1654
+ instanceOfEntitlementType: () => instanceOfEntitlementType,
1655
+ instanceOfEntitlementValueType: () => instanceOfEntitlementValueType,
1656
+ instanceOfFeatureType: () => instanceOfFeatureType,
1657
+ instanceOfGetCompanyCreditBalancesResponse: () => instanceOfGetCompanyCreditBalancesResponse,
1658
+ instanceOfGetCompanyCreditUserUsageParams: () => instanceOfGetCompanyCreditUserUsageParams,
1659
+ instanceOfGetCompanyCreditUserUsageResponse: () => instanceOfGetCompanyCreditUserUsageResponse,
1660
+ instanceOfGetCompanyFeatureUsageResponse: () => instanceOfGetCompanyFeatureUsageResponse,
1661
+ instanceOfGetCompanyFeatureUserUsageParams: () => instanceOfGetCompanyFeatureUserUsageParams,
1662
+ instanceOfGetCompanyFeatureUserUsageResponse: () => instanceOfGetCompanyFeatureUserUsageResponse,
1402
1663
  instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
1403
1664
  instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
1404
1665
  instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
1405
1666
  instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
1406
1667
  instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
1668
+ instanceOfMetricPeriod: () => instanceOfMetricPeriod,
1669
+ instanceOfMetricPeriodMonthReset: () => instanceOfMetricPeriodMonthReset,
1407
1670
  instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
1671
+ instanceOfPlanCreditGrantScaling: () => instanceOfPlanCreditGrantScaling,
1408
1672
  instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
1409
1673
  instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
1410
1674
  instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
@@ -1435,6 +1699,126 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
1435
1699
  error: value["error"]
1436
1700
  };
1437
1701
  }
1702
+ var BillingCreditGrantReason = {
1703
+ Adjustment: "adjustment",
1704
+ BillingCreditAutoTopup: "billing_credit_auto_topup",
1705
+ Free: "free",
1706
+ Plan: "plan",
1707
+ PostpaidForgiven: "postpaid_forgiven",
1708
+ PostpaidOverdraft: "postpaid_overdraft",
1709
+ PostpaidSettlement: "postpaid_settlement",
1710
+ Purchased: "purchased",
1711
+ Rollover: "rollover"
1712
+ };
1713
+ function instanceOfBillingCreditGrantReason(value) {
1714
+ for (const key in BillingCreditGrantReason) {
1715
+ if (Object.prototype.hasOwnProperty.call(BillingCreditGrantReason, key)) {
1716
+ if (BillingCreditGrantReason[key] === value) {
1717
+ return true;
1718
+ }
1719
+ }
1720
+ }
1721
+ return false;
1722
+ }
1723
+ function BillingCreditGrantReasonFromJSON(json) {
1724
+ return BillingCreditGrantReasonFromJSONTyped(json, false);
1725
+ }
1726
+ function BillingCreditGrantReasonFromJSONTyped(json, ignoreDiscriminator) {
1727
+ return json;
1728
+ }
1729
+ function BillingCreditGrantReasonToJSON(value) {
1730
+ return value;
1731
+ }
1732
+ function BillingCreditGrantReasonToJSONTyped(value, ignoreDiscriminator) {
1733
+ return value;
1734
+ }
1735
+ var BillingPlanCreditGrantResetCadence = {
1736
+ Daily: "daily",
1737
+ Every6Months: "every_6_months",
1738
+ Monthly: "monthly",
1739
+ Quarterly: "quarterly",
1740
+ Weekly: "weekly",
1741
+ Yearly: "yearly"
1742
+ };
1743
+ function instanceOfBillingPlanCreditGrantResetCadence(value) {
1744
+ for (const key in BillingPlanCreditGrantResetCadence) {
1745
+ if (Object.prototype.hasOwnProperty.call(
1746
+ BillingPlanCreditGrantResetCadence,
1747
+ key
1748
+ )) {
1749
+ if (BillingPlanCreditGrantResetCadence[key] === value) {
1750
+ return true;
1751
+ }
1752
+ }
1753
+ }
1754
+ return false;
1755
+ }
1756
+ function BillingPlanCreditGrantResetCadenceFromJSON2(json) {
1757
+ return BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, false);
1758
+ }
1759
+ function BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, ignoreDiscriminator) {
1760
+ return json;
1761
+ }
1762
+ function BillingPlanCreditGrantResetCadenceToJSON2(value) {
1763
+ return value;
1764
+ }
1765
+ function BillingPlanCreditGrantResetCadenceToJSONTyped3(value, ignoreDiscriminator) {
1766
+ return value;
1767
+ }
1768
+ var BillingPriceScheme = {
1769
+ PerUnit: "per_unit",
1770
+ Tiered: "tiered"
1771
+ };
1772
+ function instanceOfBillingPriceScheme(value) {
1773
+ for (const key in BillingPriceScheme) {
1774
+ if (Object.prototype.hasOwnProperty.call(BillingPriceScheme, key)) {
1775
+ if (BillingPriceScheme[key] === value) {
1776
+ return true;
1777
+ }
1778
+ }
1779
+ }
1780
+ return false;
1781
+ }
1782
+ function BillingPriceSchemeFromJSON2(json) {
1783
+ return BillingPriceSchemeFromJSONTyped4(json, false);
1784
+ }
1785
+ function BillingPriceSchemeFromJSONTyped4(json, ignoreDiscriminator) {
1786
+ return json;
1787
+ }
1788
+ function BillingPriceSchemeToJSON2(value) {
1789
+ return value;
1790
+ }
1791
+ function BillingPriceSchemeToJSONTyped4(value, ignoreDiscriminator) {
1792
+ return value;
1793
+ }
1794
+ var BillingProductPriceInterval = {
1795
+ Day: "day",
1796
+ Month: "month",
1797
+ OneTime: "one-time",
1798
+ Year: "year"
1799
+ };
1800
+ function instanceOfBillingProductPriceInterval(value) {
1801
+ for (const key in BillingProductPriceInterval) {
1802
+ if (Object.prototype.hasOwnProperty.call(BillingProductPriceInterval, key)) {
1803
+ if (BillingProductPriceInterval[key] === value) {
1804
+ return true;
1805
+ }
1806
+ }
1807
+ }
1808
+ return false;
1809
+ }
1810
+ function BillingProductPriceIntervalFromJSON2(json) {
1811
+ return BillingProductPriceIntervalFromJSONTyped4(json, false);
1812
+ }
1813
+ function BillingProductPriceIntervalFromJSONTyped4(json, ignoreDiscriminator) {
1814
+ return json;
1815
+ }
1816
+ function BillingProductPriceIntervalToJSON2(value) {
1817
+ return value;
1818
+ }
1819
+ function BillingProductPriceIntervalToJSONTyped4(value, ignoreDiscriminator) {
1820
+ return value;
1821
+ }
1438
1822
  var BillingProviderType = {
1439
1823
  Metronome: "metronome",
1440
1824
  Orb: "orb",
@@ -1463,44 +1847,926 @@ function BillingProviderTypeToJSON2(value) {
1463
1847
  function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
1464
1848
  return value;
1465
1849
  }
1850
+ var BillingTiersMode = {
1851
+ Graduated: "graduated",
1852
+ Volume: "volume"
1853
+ };
1854
+ function instanceOfBillingTiersMode(value) {
1855
+ for (const key in BillingTiersMode) {
1856
+ if (Object.prototype.hasOwnProperty.call(BillingTiersMode, key)) {
1857
+ if (BillingTiersMode[key] === value) {
1858
+ return true;
1859
+ }
1860
+ }
1861
+ }
1862
+ return false;
1863
+ }
1864
+ function BillingTiersModeFromJSON2(json) {
1865
+ return BillingTiersModeFromJSONTyped4(json, false);
1866
+ }
1867
+ function BillingTiersModeFromJSONTyped4(json, ignoreDiscriminator) {
1868
+ return json;
1869
+ }
1870
+ function BillingTiersModeToJSON2(value) {
1871
+ return value;
1872
+ }
1873
+ function BillingTiersModeToJSONTyped4(value, ignoreDiscriminator) {
1874
+ return value;
1875
+ }
1876
+ var PlanCreditGrantScaling = {
1877
+ Fixed: "fixed",
1878
+ PerLicense: "per_license"
1879
+ };
1880
+ function instanceOfPlanCreditGrantScaling(value) {
1881
+ for (const key in PlanCreditGrantScaling) {
1882
+ if (Object.prototype.hasOwnProperty.call(PlanCreditGrantScaling, key)) {
1883
+ if (PlanCreditGrantScaling[key] === value) {
1884
+ return true;
1885
+ }
1886
+ }
1887
+ }
1888
+ return false;
1889
+ }
1890
+ function PlanCreditGrantScalingFromJSON2(json) {
1891
+ return PlanCreditGrantScalingFromJSONTyped3(json, false);
1892
+ }
1893
+ function PlanCreditGrantScalingFromJSONTyped3(json, ignoreDiscriminator) {
1894
+ return json;
1895
+ }
1896
+ function PlanCreditGrantScalingToJSON2(value) {
1897
+ return value;
1898
+ }
1899
+ function PlanCreditGrantScalingToJSONTyped3(value, ignoreDiscriminator) {
1900
+ return value;
1901
+ }
1902
+ function instanceOfCatalogCreditGrantResponseData(value) {
1903
+ if (!("companyCreditAmount" in value) || value["companyCreditAmount"] === void 0)
1904
+ return false;
1905
+ if (!("creditAmount" in value) || value["creditAmount"] === void 0)
1906
+ return false;
1907
+ if (!("creditId" in value) || value["creditId"] === void 0) return false;
1908
+ if (!("creditName" in value) || value["creditName"] === void 0)
1909
+ return false;
1910
+ if (!("id" in value) || value["id"] === void 0) return false;
1911
+ if (!("scaling" in value) || value["scaling"] === void 0) return false;
1912
+ return true;
1913
+ }
1914
+ function CatalogCreditGrantResponseDataFromJSON(json) {
1915
+ return CatalogCreditGrantResponseDataFromJSONTyped(json, false);
1916
+ }
1917
+ function CatalogCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1918
+ if (json == null) {
1919
+ return json;
1920
+ }
1921
+ return {
1922
+ companyCreditAmount: json["company_credit_amount"],
1923
+ creditAmount: json["credit_amount"],
1924
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
1925
+ creditId: json["credit_id"],
1926
+ creditName: json["credit_name"],
1927
+ creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
1928
+ creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
1929
+ id: json["id"],
1930
+ licenseId: json["license_id"] == null ? void 0 : json["license_id"],
1931
+ resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
1932
+ scaling: PlanCreditGrantScalingFromJSON2(json["scaling"])
1933
+ };
1934
+ }
1935
+ function CatalogCreditGrantResponseDataToJSON(json) {
1936
+ return CatalogCreditGrantResponseDataToJSONTyped(json, false);
1937
+ }
1938
+ function CatalogCreditGrantResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1939
+ if (value == null) {
1940
+ return value;
1941
+ }
1942
+ return {
1943
+ company_credit_amount: value["companyCreditAmount"],
1944
+ credit_amount: value["creditAmount"],
1945
+ credit_icon: value["creditIcon"],
1946
+ credit_id: value["creditId"],
1947
+ credit_name: value["creditName"],
1948
+ credit_plural_name: value["creditPluralName"],
1949
+ credit_singular_name: value["creditSingularName"],
1950
+ id: value["id"],
1951
+ license_id: value["licenseId"],
1952
+ reset_cadence: BillingPlanCreditGrantResetCadenceToJSON2(
1953
+ value["resetCadence"]
1954
+ ),
1955
+ scaling: PlanCreditGrantScalingToJSON2(value["scaling"])
1956
+ };
1957
+ }
1958
+ function instanceOfCatalogPriceTierResponseData(value) {
1959
+ if (!("from" in value) || value["from"] === void 0) return false;
1960
+ return true;
1961
+ }
1962
+ function CatalogPriceTierResponseDataFromJSON(json) {
1963
+ return CatalogPriceTierResponseDataFromJSONTyped(json, false);
1964
+ }
1965
+ function CatalogPriceTierResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1966
+ if (json == null) {
1967
+ return json;
1968
+ }
1969
+ return {
1970
+ flatPrice: json["flat_price"] == null ? void 0 : json["flat_price"],
1971
+ from: json["from"],
1972
+ perUnitPrice: json["per_unit_price"] == null ? void 0 : json["per_unit_price"],
1973
+ perUnitPriceDecimal: json["per_unit_price_decimal"] == null ? void 0 : json["per_unit_price_decimal"],
1974
+ to: json["to"] == null ? void 0 : json["to"]
1975
+ };
1976
+ }
1977
+ function CatalogPriceTierResponseDataToJSON(json) {
1978
+ return CatalogPriceTierResponseDataToJSONTyped(json, false);
1979
+ }
1980
+ function CatalogPriceTierResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1981
+ if (value == null) {
1982
+ return value;
1983
+ }
1984
+ return {
1985
+ flat_price: value["flatPrice"],
1986
+ from: value["from"],
1987
+ per_unit_price: value["perUnitPrice"],
1988
+ per_unit_price_decimal: value["perUnitPriceDecimal"],
1989
+ to: value["to"]
1990
+ };
1991
+ }
1992
+ function instanceOfCatalogPriceResponseData(value) {
1993
+ if (!("currency" in value) || value["currency"] === void 0) return false;
1994
+ if (!("id" in value) || value["id"] === void 0) return false;
1995
+ if (!("interval" in value) || value["interval"] === void 0) return false;
1996
+ if (!("intervalCount" in value) || value["intervalCount"] === void 0)
1997
+ return false;
1998
+ if (!("packageSize" in value) || value["packageSize"] === void 0)
1999
+ return false;
2000
+ if (!("price" in value) || value["price"] === void 0) return false;
2001
+ if (!("priceTiers" in value) || value["priceTiers"] === void 0)
2002
+ return false;
2003
+ if (!("scheme" in value) || value["scheme"] === void 0) return false;
2004
+ return true;
2005
+ }
2006
+ function CatalogPriceResponseDataFromJSON(json) {
2007
+ return CatalogPriceResponseDataFromJSONTyped(json, false);
2008
+ }
2009
+ function CatalogPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2010
+ if (json == null) {
2011
+ return json;
2012
+ }
2013
+ return {
2014
+ currency: json["currency"],
2015
+ id: json["id"],
2016
+ interval: BillingProductPriceIntervalFromJSON2(json["interval"]),
2017
+ intervalCount: json["interval_count"],
2018
+ overageUnitPriceDecimal: json["overage_unit_price_decimal"] == null ? void 0 : json["overage_unit_price_decimal"],
2019
+ packageSize: json["package_size"],
2020
+ price: json["price"],
2021
+ priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
2022
+ priceTiers: json["price_tiers"].map(
2023
+ CatalogPriceTierResponseDataFromJSON
2024
+ ),
2025
+ scheme: BillingPriceSchemeFromJSON2(json["scheme"]),
2026
+ tiersMode: json["tiers_mode"] == null ? void 0 : BillingTiersModeFromJSON2(json["tiers_mode"])
2027
+ };
2028
+ }
2029
+ function CatalogPriceResponseDataToJSON(json) {
2030
+ return CatalogPriceResponseDataToJSONTyped(json, false);
2031
+ }
2032
+ function CatalogPriceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2033
+ if (value == null) {
2034
+ return value;
2035
+ }
2036
+ return {
2037
+ currency: value["currency"],
2038
+ id: value["id"],
2039
+ interval: BillingProductPriceIntervalToJSON2(value["interval"]),
2040
+ interval_count: value["intervalCount"],
2041
+ overage_unit_price_decimal: value["overageUnitPriceDecimal"],
2042
+ package_size: value["packageSize"],
2043
+ price: value["price"],
2044
+ price_decimal: value["priceDecimal"],
2045
+ price_tiers: value["priceTiers"].map(
2046
+ CatalogPriceTierResponseDataToJSON
2047
+ ),
2048
+ scheme: BillingPriceSchemeToJSON2(value["scheme"]),
2049
+ tiers_mode: BillingTiersModeToJSON2(value["tiersMode"])
2050
+ };
2051
+ }
2052
+ function instanceOfCompanyCreditGrantResponseData(value) {
2053
+ if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
2054
+ if (!("grantReason" in value) || value["grantReason"] === void 0)
2055
+ return false;
2056
+ if (!("id" in value) || value["id"] === void 0) return false;
2057
+ if (!("quantity" in value) || value["quantity"] === void 0) return false;
2058
+ if (!("quantityRemaining" in value) || value["quantityRemaining"] === void 0)
2059
+ return false;
2060
+ if (!("quantityUsed" in value) || value["quantityUsed"] === void 0)
2061
+ return false;
2062
+ return true;
2063
+ }
2064
+ function CompanyCreditGrantResponseDataFromJSON(json) {
2065
+ return CompanyCreditGrantResponseDataFromJSONTyped(json, false);
2066
+ }
2067
+ function CompanyCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2068
+ if (json == null) {
2069
+ return json;
2070
+ }
2071
+ return {
2072
+ bundleId: json["bundle_id"] == null ? void 0 : json["bundle_id"],
2073
+ bundleName: json["bundle_name"] == null ? void 0 : json["bundle_name"],
2074
+ createdAt: new Date(json["created_at"]),
2075
+ expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
2076
+ grantReason: BillingCreditGrantReasonFromJSON(json["grant_reason"]),
2077
+ id: json["id"],
2078
+ planId: json["plan_id"] == null ? void 0 : json["plan_id"],
2079
+ planName: json["plan_name"] == null ? void 0 : json["plan_name"],
2080
+ quantity: json["quantity"],
2081
+ quantityRemaining: json["quantity_remaining"],
2082
+ quantityUsed: json["quantity_used"],
2083
+ renewalPeriod: json["renewal_period"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["renewal_period"]),
2084
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
2085
+ validFrom: json["valid_from"] == null ? void 0 : new Date(json["valid_from"])
2086
+ };
2087
+ }
2088
+ function CompanyCreditGrantResponseDataToJSON(json) {
2089
+ return CompanyCreditGrantResponseDataToJSONTyped(json, false);
2090
+ }
2091
+ function CompanyCreditGrantResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2092
+ if (value == null) {
2093
+ return value;
2094
+ }
2095
+ return {
2096
+ bundle_id: value["bundleId"],
2097
+ bundle_name: value["bundleName"],
2098
+ created_at: value["createdAt"].toISOString(),
2099
+ expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
2100
+ grant_reason: BillingCreditGrantReasonToJSON(value["grantReason"]),
2101
+ id: value["id"],
2102
+ plan_id: value["planId"],
2103
+ plan_name: value["planName"],
2104
+ quantity: value["quantity"],
2105
+ quantity_remaining: value["quantityRemaining"],
2106
+ quantity_used: value["quantityUsed"],
2107
+ renewal_period: BillingPlanCreditGrantResetCadenceToJSON2(
2108
+ value["renewalPeriod"]
2109
+ ),
2110
+ resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
2111
+ valid_from: value["validFrom"] == null ? void 0 : value["validFrom"].toISOString()
2112
+ };
2113
+ }
2114
+ function instanceOfCompanyCreditCompositionResponseData(value) {
2115
+ if (!("fixedQuantity" in value) || value["fixedQuantity"] === void 0)
2116
+ return false;
2117
+ if (!("licenseName" in value) || value["licenseName"] === void 0)
2118
+ return false;
2119
+ if (!("licenseQuantity" in value) || value["licenseQuantity"] === void 0)
2120
+ return false;
2121
+ if (!("perLicenseAmount" in value) || value["perLicenseAmount"] === void 0)
2122
+ return false;
2123
+ if (!("period" in value) || value["period"] === void 0) return false;
2124
+ if (!("total" in value) || value["total"] === void 0) return false;
2125
+ return true;
2126
+ }
2127
+ function CompanyCreditCompositionResponseDataFromJSON(json) {
2128
+ return CompanyCreditCompositionResponseDataFromJSONTyped(json, false);
2129
+ }
2130
+ function CompanyCreditCompositionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2131
+ if (json == null) {
2132
+ return json;
2133
+ }
2134
+ return {
2135
+ fixedQuantity: json["fixed_quantity"],
2136
+ licenseId: json["license_id"] == null ? void 0 : json["license_id"],
2137
+ licenseName: json["license_name"],
2138
+ licensePluralName: json["license_plural_name"] == null ? void 0 : json["license_plural_name"],
2139
+ licenseQuantity: json["license_quantity"],
2140
+ licenseSingularName: json["license_singular_name"] == null ? void 0 : json["license_singular_name"],
2141
+ perLicenseAmount: json["per_license_amount"],
2142
+ period: json["period"],
2143
+ renewsAt: json["renews_at"] == null ? void 0 : new Date(json["renews_at"]),
2144
+ total: json["total"]
2145
+ };
2146
+ }
2147
+ function CompanyCreditCompositionResponseDataToJSON(json) {
2148
+ return CompanyCreditCompositionResponseDataToJSONTyped(json, false);
2149
+ }
2150
+ function CompanyCreditCompositionResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2151
+ if (value == null) {
2152
+ return value;
2153
+ }
2154
+ return {
2155
+ fixed_quantity: value["fixedQuantity"],
2156
+ license_id: value["licenseId"],
2157
+ license_name: value["licenseName"],
2158
+ license_plural_name: value["licensePluralName"],
2159
+ license_quantity: value["licenseQuantity"],
2160
+ license_singular_name: value["licenseSingularName"],
2161
+ per_license_amount: value["perLicenseAmount"],
2162
+ period: value["period"],
2163
+ renews_at: value["renewsAt"] == null ? void 0 : value["renewsAt"].toISOString(),
2164
+ total: value["total"]
2165
+ };
2166
+ }
2167
+ function instanceOfCompanyCreditBalanceResponseData(value) {
2168
+ if (!("creditDescription" in value) || value["creditDescription"] === void 0)
2169
+ return false;
2170
+ if (!("creditId" in value) || value["creditId"] === void 0) return false;
2171
+ if (!("creditName" in value) || value["creditName"] === void 0)
2172
+ return false;
2173
+ if (!("grants" in value) || value["grants"] === void 0) return false;
2174
+ if (!("purchasable" in value) || value["purchasable"] === void 0)
2175
+ return false;
2176
+ if (!("remaining" in value) || value["remaining"] === void 0) return false;
2177
+ if (!("total" in value) || value["total"] === void 0) return false;
2178
+ if (!("used" in value) || value["used"] === void 0) return false;
2179
+ return true;
2180
+ }
2181
+ function CompanyCreditBalanceResponseDataFromJSON(json) {
2182
+ return CompanyCreditBalanceResponseDataFromJSONTyped(json, false);
2183
+ }
2184
+ function CompanyCreditBalanceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2185
+ if (json == null) {
2186
+ return json;
2187
+ }
2188
+ return {
2189
+ composition: json["composition"] == null ? void 0 : CompanyCreditCompositionResponseDataFromJSON(json["composition"]),
2190
+ creditDescription: json["credit_description"],
2191
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
2192
+ creditId: json["credit_id"],
2193
+ creditName: json["credit_name"],
2194
+ creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
2195
+ creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
2196
+ expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
2197
+ grants: json["grants"].map(
2198
+ CompanyCreditGrantResponseDataFromJSON
2199
+ ),
2200
+ purchasable: json["purchasable"],
2201
+ remaining: json["remaining"],
2202
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
2203
+ total: json["total"],
2204
+ used: json["used"]
2205
+ };
2206
+ }
2207
+ function CompanyCreditBalanceResponseDataToJSON(json) {
2208
+ return CompanyCreditBalanceResponseDataToJSONTyped(json, false);
2209
+ }
2210
+ function CompanyCreditBalanceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2211
+ if (value == null) {
2212
+ return value;
2213
+ }
2214
+ return {
2215
+ composition: CompanyCreditCompositionResponseDataToJSON(
2216
+ value["composition"]
2217
+ ),
2218
+ credit_description: value["creditDescription"],
2219
+ credit_icon: value["creditIcon"],
2220
+ credit_id: value["creditId"],
2221
+ credit_name: value["creditName"],
2222
+ credit_plural_name: value["creditPluralName"],
2223
+ credit_singular_name: value["creditSingularName"],
2224
+ expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
2225
+ grants: value["grants"].map(
2226
+ CompanyCreditGrantResponseDataToJSON
2227
+ ),
2228
+ purchasable: value["purchasable"],
2229
+ remaining: value["remaining"],
2230
+ resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
2231
+ total: value["total"],
2232
+ used: value["used"]
2233
+ };
2234
+ }
2235
+ function instanceOfCompanyCreditBalancesResponseData(value) {
2236
+ if (!("balances" in value) || value["balances"] === void 0) return false;
2237
+ if (!("count" in value) || value["count"] === void 0) return false;
2238
+ return true;
2239
+ }
2240
+ function CompanyCreditBalancesResponseDataFromJSON(json) {
2241
+ return CompanyCreditBalancesResponseDataFromJSONTyped(json, false);
2242
+ }
2243
+ function CompanyCreditBalancesResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2244
+ if (json == null) {
2245
+ return json;
2246
+ }
2247
+ return {
2248
+ balances: json["balances"].map(
2249
+ CompanyCreditBalanceResponseDataFromJSON
2250
+ ),
2251
+ count: json["count"]
2252
+ };
2253
+ }
2254
+ function CompanyCreditBalancesResponseDataToJSON(json) {
2255
+ return CompanyCreditBalancesResponseDataToJSONTyped(json, false);
2256
+ }
2257
+ function CompanyCreditBalancesResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2258
+ if (value == null) {
2259
+ return value;
2260
+ }
2261
+ return {
2262
+ balances: value["balances"].map(
2263
+ CompanyCreditBalanceResponseDataToJSON
2264
+ ),
2265
+ count: value["count"]
2266
+ };
2267
+ }
2268
+ function instanceOfCompanyCreditUserUsageRowResponseData(value) {
2269
+ if (!("share" in value) || value["share"] === void 0) return false;
2270
+ if (!("used" in value) || value["used"] === void 0) return false;
2271
+ if (!("userId" in value) || value["userId"] === void 0) return false;
2272
+ return true;
2273
+ }
2274
+ function CompanyCreditUserUsageRowResponseDataFromJSON(json) {
2275
+ return CompanyCreditUserUsageRowResponseDataFromJSONTyped(json, false);
2276
+ }
2277
+ function CompanyCreditUserUsageRowResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2278
+ if (json == null) {
2279
+ return json;
2280
+ }
2281
+ return {
2282
+ name: json["name"] == null ? void 0 : json["name"],
2283
+ share: json["share"],
2284
+ used: json["used"],
2285
+ userId: json["user_id"]
2286
+ };
2287
+ }
2288
+ function CompanyCreditUserUsageRowResponseDataToJSON(json) {
2289
+ return CompanyCreditUserUsageRowResponseDataToJSONTyped(json, false);
2290
+ }
2291
+ function CompanyCreditUserUsageRowResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2292
+ if (value == null) {
2293
+ return value;
2294
+ }
2295
+ return {
2296
+ name: value["name"],
2297
+ share: value["share"],
2298
+ used: value["used"],
2299
+ user_id: value["userId"]
2300
+ };
2301
+ }
2302
+ function instanceOfCompanyCreditUserUsageResponseData(value) {
2303
+ if (!("count" in value) || value["count"] === void 0) return false;
2304
+ if (!("total" in value) || value["total"] === void 0) return false;
2305
+ if (!("users" in value) || value["users"] === void 0) return false;
2306
+ return true;
2307
+ }
2308
+ function CompanyCreditUserUsageResponseDataFromJSON(json) {
2309
+ return CompanyCreditUserUsageResponseDataFromJSONTyped(json, false);
2310
+ }
2311
+ function CompanyCreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2312
+ if (json == null) {
2313
+ return json;
2314
+ }
2315
+ return {
2316
+ count: json["count"],
2317
+ endTime: json["end_time"] == null ? void 0 : new Date(json["end_time"]),
2318
+ startTime: json["start_time"] == null ? void 0 : new Date(json["start_time"]),
2319
+ total: json["total"],
2320
+ unattributed: json["unattributed"] == null ? void 0 : json["unattributed"],
2321
+ users: json["users"].map(
2322
+ CompanyCreditUserUsageRowResponseDataFromJSON
2323
+ )
2324
+ };
2325
+ }
2326
+ function CompanyCreditUserUsageResponseDataToJSON(json) {
2327
+ return CompanyCreditUserUsageResponseDataToJSONTyped(json, false);
2328
+ }
2329
+ function CompanyCreditUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2330
+ if (value == null) {
2331
+ return value;
2332
+ }
2333
+ return {
2334
+ count: value["count"],
2335
+ end_time: value["endTime"] == null ? void 0 : value["endTime"].toISOString(),
2336
+ start_time: value["startTime"] == null ? void 0 : value["startTime"].toISOString(),
2337
+ total: value["total"],
2338
+ unattributed: value["unattributed"],
2339
+ users: value["users"].map(
2340
+ CompanyCreditUserUsageRowResponseDataToJSON
2341
+ )
2342
+ };
2343
+ }
1466
2344
  function instanceOfCompanyDiscountResponseData(value) {
1467
2345
  if (!("couponName" in value) || value["couponName"] === void 0)
1468
2346
  return false;
1469
2347
  if (!("duration" in value) || value["duration"] === void 0) return false;
1470
2348
  return true;
1471
2349
  }
1472
- function CompanyDiscountResponseDataFromJSON(json) {
1473
- return CompanyDiscountResponseDataFromJSONTyped(json, false);
2350
+ function CompanyDiscountResponseDataFromJSON(json) {
2351
+ return CompanyDiscountResponseDataFromJSONTyped(json, false);
2352
+ }
2353
+ function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2354
+ if (json == null) {
2355
+ return json;
2356
+ }
2357
+ return {
2358
+ amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
2359
+ couponName: json["coupon_name"],
2360
+ currency: json["currency"] == null ? void 0 : json["currency"],
2361
+ customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
2362
+ duration: json["duration"],
2363
+ durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
2364
+ percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
2365
+ };
2366
+ }
2367
+ function CompanyDiscountResponseDataToJSON(json) {
2368
+ return CompanyDiscountResponseDataToJSONTyped(json, false);
2369
+ }
2370
+ function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2371
+ if (value == null) {
2372
+ return value;
2373
+ }
2374
+ return {
2375
+ amount_off: value["amountOff"],
2376
+ coupon_name: value["couponName"],
2377
+ currency: value["currency"],
2378
+ customer_facing_code: value["customerFacingCode"],
2379
+ duration: value["duration"],
2380
+ duration_in_months: value["durationInMonths"],
2381
+ percent_off: value["percentOff"]
2382
+ };
2383
+ }
2384
+ var EntitlementValueType = {
2385
+ Boolean: "boolean",
2386
+ Credit: "credit",
2387
+ Numeric: "numeric",
2388
+ Trait: "trait",
2389
+ Unknown: "unknown",
2390
+ Unlimited: "unlimited"
2391
+ };
2392
+ function instanceOfEntitlementValueType(value) {
2393
+ for (const key in EntitlementValueType) {
2394
+ if (Object.prototype.hasOwnProperty.call(EntitlementValueType, key)) {
2395
+ if (EntitlementValueType[key] === value) {
2396
+ return true;
2397
+ }
2398
+ }
2399
+ }
2400
+ return false;
2401
+ }
2402
+ function EntitlementValueTypeFromJSON2(json) {
2403
+ return EntitlementValueTypeFromJSONTyped4(json, false);
2404
+ }
2405
+ function EntitlementValueTypeFromJSONTyped4(json, ignoreDiscriminator) {
2406
+ return json;
2407
+ }
2408
+ function EntitlementValueTypeToJSON2(value) {
2409
+ return value;
2410
+ }
2411
+ function EntitlementValueTypeToJSONTyped3(value, ignoreDiscriminator) {
2412
+ return value;
2413
+ }
2414
+ var FeatureType = {
2415
+ Boolean: "boolean",
2416
+ Event: "event",
2417
+ License: "license",
2418
+ Trait: "trait"
2419
+ };
2420
+ function instanceOfFeatureType(value) {
2421
+ for (const key in FeatureType) {
2422
+ if (Object.prototype.hasOwnProperty.call(FeatureType, key)) {
2423
+ if (FeatureType[key] === value) {
2424
+ return true;
2425
+ }
2426
+ }
2427
+ }
2428
+ return false;
2429
+ }
2430
+ function FeatureTypeFromJSON2(json) {
2431
+ return FeatureTypeFromJSONTyped3(json, false);
2432
+ }
2433
+ function FeatureTypeFromJSONTyped3(json, ignoreDiscriminator) {
2434
+ return json;
2435
+ }
2436
+ function FeatureTypeToJSON2(value) {
2437
+ return value;
2438
+ }
2439
+ function FeatureTypeToJSONTyped3(value, ignoreDiscriminator) {
2440
+ return value;
2441
+ }
2442
+ var MetricPeriodMonthReset = {
2443
+ BillingCycle: "billing_cycle",
2444
+ FirstOfMonth: "first_of_month"
2445
+ };
2446
+ function instanceOfMetricPeriodMonthReset(value) {
2447
+ for (const key in MetricPeriodMonthReset) {
2448
+ if (Object.prototype.hasOwnProperty.call(MetricPeriodMonthReset, key)) {
2449
+ if (MetricPeriodMonthReset[key] === value) {
2450
+ return true;
2451
+ }
2452
+ }
2453
+ }
2454
+ return false;
2455
+ }
2456
+ function MetricPeriodMonthResetFromJSON2(json) {
2457
+ return MetricPeriodMonthResetFromJSONTyped6(json, false);
2458
+ }
2459
+ function MetricPeriodMonthResetFromJSONTyped6(json, ignoreDiscriminator) {
2460
+ return json;
2461
+ }
2462
+ function MetricPeriodMonthResetToJSON2(value) {
2463
+ return value;
2464
+ }
2465
+ function MetricPeriodMonthResetToJSONTyped5(value, ignoreDiscriminator) {
2466
+ return value;
2467
+ }
2468
+ var MetricPeriod = {
2469
+ AllTime: "all_time",
2470
+ CurrentDay: "current_day",
2471
+ CurrentMonth: "current_month",
2472
+ CurrentWeek: "current_week"
2473
+ };
2474
+ function instanceOfMetricPeriod(value) {
2475
+ for (const key in MetricPeriod) {
2476
+ if (Object.prototype.hasOwnProperty.call(MetricPeriod, key)) {
2477
+ if (MetricPeriod[key] === value) {
2478
+ return true;
2479
+ }
2480
+ }
2481
+ }
2482
+ return false;
2483
+ }
2484
+ function MetricPeriodFromJSON2(json) {
2485
+ return MetricPeriodFromJSONTyped7(json, false);
2486
+ }
2487
+ function MetricPeriodFromJSONTyped7(json, ignoreDiscriminator) {
2488
+ return json;
2489
+ }
2490
+ function MetricPeriodToJSON2(value) {
2491
+ return value;
2492
+ }
2493
+ function MetricPeriodToJSONTyped6(value, ignoreDiscriminator) {
2494
+ return value;
2495
+ }
2496
+ var EntitlementPriceBehavior = {
2497
+ CreditBurndown: "credit_burndown",
2498
+ Overage: "overage",
2499
+ PayAsYouGo: "pay_as_you_go",
2500
+ PayInAdvance: "pay_in_advance",
2501
+ Tier: "tier"
2502
+ };
2503
+ function instanceOfEntitlementPriceBehavior(value) {
2504
+ for (const key in EntitlementPriceBehavior) {
2505
+ if (Object.prototype.hasOwnProperty.call(EntitlementPriceBehavior, key)) {
2506
+ if (EntitlementPriceBehavior[key] === value) {
2507
+ return true;
2508
+ }
2509
+ }
2510
+ }
2511
+ return false;
2512
+ }
2513
+ function EntitlementPriceBehaviorFromJSON2(json) {
2514
+ return EntitlementPriceBehaviorFromJSONTyped2(json, false);
2515
+ }
2516
+ function EntitlementPriceBehaviorFromJSONTyped2(json, ignoreDiscriminator) {
2517
+ return json;
2518
+ }
2519
+ function EntitlementPriceBehaviorToJSON2(value) {
2520
+ return value;
2521
+ }
2522
+ function EntitlementPriceBehaviorToJSONTyped2(value, ignoreDiscriminator) {
2523
+ return value;
2524
+ }
2525
+ var EntitlementType = {
2526
+ CompanyOverride: "company_override",
2527
+ PlanEntitlement: "plan_entitlement",
2528
+ Unknown: "unknown"
2529
+ };
2530
+ function instanceOfEntitlementType(value) {
2531
+ for (const key in EntitlementType) {
2532
+ if (Object.prototype.hasOwnProperty.call(EntitlementType, key)) {
2533
+ if (EntitlementType[key] === value) {
2534
+ return true;
2535
+ }
2536
+ }
2537
+ }
2538
+ return false;
2539
+ }
2540
+ function EntitlementTypeFromJSON(json) {
2541
+ return EntitlementTypeFromJSONTyped(json, false);
2542
+ }
2543
+ function EntitlementTypeFromJSONTyped(json, ignoreDiscriminator) {
2544
+ return json;
2545
+ }
2546
+ function EntitlementTypeToJSON(value) {
2547
+ return value;
2548
+ }
2549
+ function EntitlementTypeToJSONTyped(value, ignoreDiscriminator) {
2550
+ return value;
2551
+ }
2552
+ function instanceOfCompanyFeatureUsageResponseData(value) {
2553
+ if (!("access" in value) || value["access"] === void 0) return false;
2554
+ if (!("entitlementType" in value) || value["entitlementType"] === void 0)
2555
+ return false;
2556
+ if (!("featureDescription" in value) || value["featureDescription"] === void 0)
2557
+ return false;
2558
+ if (!("featureIcon" in value) || value["featureIcon"] === void 0)
2559
+ return false;
2560
+ if (!("featureId" in value) || value["featureId"] === void 0) return false;
2561
+ if (!("featureName" in value) || value["featureName"] === void 0)
2562
+ return false;
2563
+ if (!("featureType" in value) || value["featureType"] === void 0)
2564
+ return false;
2565
+ if (!("perLicenseCreditGrants" in value) || value["perLicenseCreditGrants"] === void 0)
2566
+ return false;
2567
+ if (!("valueType" in value) || value["valueType"] === void 0) return false;
2568
+ return true;
2569
+ }
2570
+ function CompanyFeatureUsageResponseDataFromJSON(json) {
2571
+ return CompanyFeatureUsageResponseDataFromJSONTyped(json, false);
2572
+ }
2573
+ function CompanyFeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2574
+ if (json == null) {
2575
+ return json;
2576
+ }
2577
+ return {
2578
+ access: json["access"],
2579
+ allocation: json["allocation"] == null ? void 0 : json["allocation"],
2580
+ companyOverrideId: json["company_override_id"] == null ? void 0 : json["company_override_id"],
2581
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
2582
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
2583
+ creditId: json["credit_id"] == null ? void 0 : json["credit_id"],
2584
+ creditName: json["credit_name"] == null ? void 0 : json["credit_name"],
2585
+ creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
2586
+ creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
2587
+ currentCost: json["current_cost"] == null ? void 0 : json["current_cost"],
2588
+ entitlementType: EntitlementTypeFromJSON(json["entitlement_type"]),
2589
+ expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
2590
+ featureDescription: json["feature_description"],
2591
+ featureIcon: json["feature_icon"],
2592
+ featureId: json["feature_id"],
2593
+ featureName: json["feature_name"],
2594
+ featurePluralName: json["feature_plural_name"] == null ? void 0 : json["feature_plural_name"],
2595
+ featureSingularName: json["feature_singular_name"] == null ? void 0 : json["feature_singular_name"],
2596
+ featureType: FeatureTypeFromJSON2(json["feature_type"]),
2597
+ licenseId: json["license_id"] == null ? void 0 : json["license_id"],
2598
+ metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON2(json["metric_period"]),
2599
+ metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON2(json["metric_period_month_reset"]),
2600
+ perLicenseCreditGrants: json["per_license_credit_grants"].map(CatalogCreditGrantResponseDataFromJSON),
2601
+ planEntitlementId: json["plan_entitlement_id"] == null ? void 0 : json["plan_entitlement_id"],
2602
+ price: json["price"] == null ? void 0 : CatalogPriceResponseDataFromJSON(json["price"]),
2603
+ priceBehavior: json["price_behavior"] == null ? void 0 : EntitlementPriceBehaviorFromJSON2(json["price_behavior"]),
2604
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
2605
+ softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
2606
+ usage: json["usage"] == null ? void 0 : json["usage"],
2607
+ valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
2608
+ valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
2609
+ valueType: EntitlementValueTypeFromJSON2(json["value_type"]),
2610
+ warningThreshold: json["warning_threshold"] == null ? void 0 : json["warning_threshold"]
2611
+ };
2612
+ }
2613
+ function CompanyFeatureUsageResponseDataToJSON(json) {
2614
+ return CompanyFeatureUsageResponseDataToJSONTyped(json, false);
2615
+ }
2616
+ function CompanyFeatureUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2617
+ if (value == null) {
2618
+ return value;
2619
+ }
2620
+ return {
2621
+ access: value["access"],
2622
+ allocation: value["allocation"],
2623
+ company_override_id: value["companyOverrideId"],
2624
+ consumption_rate: value["consumptionRate"],
2625
+ credit_icon: value["creditIcon"],
2626
+ credit_id: value["creditId"],
2627
+ credit_name: value["creditName"],
2628
+ credit_plural_name: value["creditPluralName"],
2629
+ credit_singular_name: value["creditSingularName"],
2630
+ current_cost: value["currentCost"],
2631
+ entitlement_type: EntitlementTypeToJSON(value["entitlementType"]),
2632
+ expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
2633
+ feature_description: value["featureDescription"],
2634
+ feature_icon: value["featureIcon"],
2635
+ feature_id: value["featureId"],
2636
+ feature_name: value["featureName"],
2637
+ feature_plural_name: value["featurePluralName"],
2638
+ feature_singular_name: value["featureSingularName"],
2639
+ feature_type: FeatureTypeToJSON2(value["featureType"]),
2640
+ license_id: value["licenseId"],
2641
+ metric_period: MetricPeriodToJSON2(value["metricPeriod"]),
2642
+ metric_period_month_reset: MetricPeriodMonthResetToJSON2(
2643
+ value["metricPeriodMonthReset"]
2644
+ ),
2645
+ per_license_credit_grants: value["perLicenseCreditGrants"].map(CatalogCreditGrantResponseDataToJSON),
2646
+ plan_entitlement_id: value["planEntitlementId"],
2647
+ price: CatalogPriceResponseDataToJSON(value["price"]),
2648
+ price_behavior: EntitlementPriceBehaviorToJSON2(value["priceBehavior"]),
2649
+ resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
2650
+ soft_limit: value["softLimit"],
2651
+ usage: value["usage"],
2652
+ value_bool: value["valueBool"],
2653
+ value_numeric: value["valueNumeric"],
2654
+ value_type: EntitlementValueTypeToJSON2(value["valueType"]),
2655
+ warning_threshold: value["warningThreshold"]
2656
+ };
2657
+ }
2658
+ function instanceOfCompanyFeatureUsageListResponseData(value) {
2659
+ if (!("count" in value) || value["count"] === void 0) return false;
2660
+ if (!("features" in value) || value["features"] === void 0) return false;
2661
+ return true;
2662
+ }
2663
+ function CompanyFeatureUsageListResponseDataFromJSON(json) {
2664
+ return CompanyFeatureUsageListResponseDataFromJSONTyped(json, false);
2665
+ }
2666
+ function CompanyFeatureUsageListResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2667
+ if (json == null) {
2668
+ return json;
2669
+ }
2670
+ return {
2671
+ count: json["count"],
2672
+ features: json["features"].map(
2673
+ CompanyFeatureUsageResponseDataFromJSON
2674
+ )
2675
+ };
2676
+ }
2677
+ function CompanyFeatureUsageListResponseDataToJSON(json) {
2678
+ return CompanyFeatureUsageListResponseDataToJSONTyped(json, false);
2679
+ }
2680
+ function CompanyFeatureUsageListResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2681
+ if (value == null) {
2682
+ return value;
2683
+ }
2684
+ return {
2685
+ count: value["count"],
2686
+ features: value["features"].map(
2687
+ CompanyFeatureUsageResponseDataToJSON
2688
+ )
2689
+ };
2690
+ }
2691
+ function instanceOfCompanyUserUsageResponseData(value) {
2692
+ if (!("lastSeen" in value) || value["lastSeen"] === void 0) return false;
2693
+ if (!("share" in value) || value["share"] === void 0) return false;
2694
+ if (!("usage" in value) || value["usage"] === void 0) return false;
2695
+ if (!("userId" in value) || value["userId"] === void 0) return false;
2696
+ return true;
2697
+ }
2698
+ function CompanyUserUsageResponseDataFromJSON(json) {
2699
+ return CompanyUserUsageResponseDataFromJSONTyped(json, false);
2700
+ }
2701
+ function CompanyUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2702
+ if (json == null) {
2703
+ return json;
2704
+ }
2705
+ return {
2706
+ lastSeen: new Date(json["last_seen"]),
2707
+ name: json["name"] == null ? void 0 : json["name"],
2708
+ share: json["share"],
2709
+ usage: json["usage"],
2710
+ userId: json["user_id"]
2711
+ };
2712
+ }
2713
+ function CompanyUserUsageResponseDataToJSON(json) {
2714
+ return CompanyUserUsageResponseDataToJSONTyped(json, false);
2715
+ }
2716
+ function CompanyUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2717
+ if (value == null) {
2718
+ return value;
2719
+ }
2720
+ return {
2721
+ last_seen: value["lastSeen"].toISOString(),
2722
+ name: value["name"],
2723
+ share: value["share"],
2724
+ usage: value["usage"],
2725
+ user_id: value["userId"]
2726
+ };
2727
+ }
2728
+ function instanceOfCompanyFeatureUserUsageResponseData(value) {
2729
+ if (!("count" in value) || value["count"] === void 0) return false;
2730
+ if (!("endTime" in value) || value["endTime"] === void 0) return false;
2731
+ if (!("startTime" in value) || value["startTime"] === void 0) return false;
2732
+ if (!("total" in value) || value["total"] === void 0) return false;
2733
+ if (!("users" in value) || value["users"] === void 0) return false;
2734
+ return true;
2735
+ }
2736
+ function CompanyFeatureUserUsageResponseDataFromJSON(json) {
2737
+ return CompanyFeatureUserUsageResponseDataFromJSONTyped(json, false);
1474
2738
  }
1475
- function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2739
+ function CompanyFeatureUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1476
2740
  if (json == null) {
1477
2741
  return json;
1478
2742
  }
1479
2743
  return {
1480
- amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
1481
- couponName: json["coupon_name"],
1482
- currency: json["currency"] == null ? void 0 : json["currency"],
1483
- customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
1484
- duration: json["duration"],
1485
- durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
1486
- percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
2744
+ count: json["count"],
2745
+ endTime: new Date(json["end_time"]),
2746
+ startTime: new Date(json["start_time"]),
2747
+ total: json["total"],
2748
+ unattributed: json["unattributed"] == null ? void 0 : json["unattributed"],
2749
+ users: json["users"].map(
2750
+ CompanyUserUsageResponseDataFromJSON
2751
+ )
1487
2752
  };
1488
2753
  }
1489
- function CompanyDiscountResponseDataToJSON(json) {
1490
- return CompanyDiscountResponseDataToJSONTyped(json, false);
2754
+ function CompanyFeatureUserUsageResponseDataToJSON(json) {
2755
+ return CompanyFeatureUserUsageResponseDataToJSONTyped(json, false);
1491
2756
  }
1492
- function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2757
+ function CompanyFeatureUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1493
2758
  if (value == null) {
1494
2759
  return value;
1495
2760
  }
1496
2761
  return {
1497
- amount_off: value["amountOff"],
1498
- coupon_name: value["couponName"],
1499
- currency: value["currency"],
1500
- customer_facing_code: value["customerFacingCode"],
1501
- duration: value["duration"],
1502
- duration_in_months: value["durationInMonths"],
1503
- percent_off: value["percentOff"]
2762
+ count: value["count"],
2763
+ end_time: value["endTime"].toISOString(),
2764
+ start_time: value["startTime"].toISOString(),
2765
+ total: value["total"],
2766
+ unattributed: value["unattributed"],
2767
+ users: value["users"].map(
2768
+ CompanyUserUsageResponseDataToJSON
2769
+ )
1504
2770
  };
1505
2771
  }
1506
2772
  var InvoiceStatus = {
@@ -1862,6 +3128,176 @@ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = fal
1862
3128
  params: value["params"]
1863
3129
  };
1864
3130
  }
3131
+ function instanceOfGetCompanyCreditBalancesResponse(value) {
3132
+ if (!("data" in value) || value["data"] === void 0) return false;
3133
+ if (!("params" in value) || value["params"] === void 0) return false;
3134
+ return true;
3135
+ }
3136
+ function GetCompanyCreditBalancesResponseFromJSON(json) {
3137
+ return GetCompanyCreditBalancesResponseFromJSONTyped(json, false);
3138
+ }
3139
+ function GetCompanyCreditBalancesResponseFromJSONTyped(json, ignoreDiscriminator) {
3140
+ if (json == null) {
3141
+ return json;
3142
+ }
3143
+ return {
3144
+ data: CompanyCreditBalancesResponseDataFromJSON(json["data"]),
3145
+ params: json["params"]
3146
+ };
3147
+ }
3148
+ function GetCompanyCreditBalancesResponseToJSON(json) {
3149
+ return GetCompanyCreditBalancesResponseToJSONTyped(json, false);
3150
+ }
3151
+ function GetCompanyCreditBalancesResponseToJSONTyped(value, ignoreDiscriminator = false) {
3152
+ if (value == null) {
3153
+ return value;
3154
+ }
3155
+ return {
3156
+ data: CompanyCreditBalancesResponseDataToJSON(value["data"]),
3157
+ params: value["params"]
3158
+ };
3159
+ }
3160
+ function instanceOfGetCompanyCreditUserUsageParams(value) {
3161
+ return true;
3162
+ }
3163
+ function GetCompanyCreditUserUsageParamsFromJSON(json) {
3164
+ return GetCompanyCreditUserUsageParamsFromJSONTyped(json, false);
3165
+ }
3166
+ function GetCompanyCreditUserUsageParamsFromJSONTyped(json, ignoreDiscriminator) {
3167
+ if (json == null) {
3168
+ return json;
3169
+ }
3170
+ return {
3171
+ limit: json["limit"] == null ? void 0 : json["limit"],
3172
+ offset: json["offset"] == null ? void 0 : json["offset"]
3173
+ };
3174
+ }
3175
+ function GetCompanyCreditUserUsageParamsToJSON(json) {
3176
+ return GetCompanyCreditUserUsageParamsToJSONTyped(json, false);
3177
+ }
3178
+ function GetCompanyCreditUserUsageParamsToJSONTyped(value, ignoreDiscriminator = false) {
3179
+ if (value == null) {
3180
+ return value;
3181
+ }
3182
+ return {
3183
+ limit: value["limit"],
3184
+ offset: value["offset"]
3185
+ };
3186
+ }
3187
+ function instanceOfGetCompanyCreditUserUsageResponse(value) {
3188
+ if (!("data" in value) || value["data"] === void 0) return false;
3189
+ if (!("params" in value) || value["params"] === void 0) return false;
3190
+ return true;
3191
+ }
3192
+ function GetCompanyCreditUserUsageResponseFromJSON(json) {
3193
+ return GetCompanyCreditUserUsageResponseFromJSONTyped(json, false);
3194
+ }
3195
+ function GetCompanyCreditUserUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
3196
+ if (json == null) {
3197
+ return json;
3198
+ }
3199
+ return {
3200
+ data: CompanyCreditUserUsageResponseDataFromJSON(json["data"]),
3201
+ params: GetCompanyCreditUserUsageParamsFromJSON(json["params"])
3202
+ };
3203
+ }
3204
+ function GetCompanyCreditUserUsageResponseToJSON(json) {
3205
+ return GetCompanyCreditUserUsageResponseToJSONTyped(json, false);
3206
+ }
3207
+ function GetCompanyCreditUserUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
3208
+ if (value == null) {
3209
+ return value;
3210
+ }
3211
+ return {
3212
+ data: CompanyCreditUserUsageResponseDataToJSON(value["data"]),
3213
+ params: GetCompanyCreditUserUsageParamsToJSON(value["params"])
3214
+ };
3215
+ }
3216
+ function instanceOfGetCompanyFeatureUsageResponse(value) {
3217
+ if (!("data" in value) || value["data"] === void 0) return false;
3218
+ if (!("params" in value) || value["params"] === void 0) return false;
3219
+ return true;
3220
+ }
3221
+ function GetCompanyFeatureUsageResponseFromJSON(json) {
3222
+ return GetCompanyFeatureUsageResponseFromJSONTyped(json, false);
3223
+ }
3224
+ function GetCompanyFeatureUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
3225
+ if (json == null) {
3226
+ return json;
3227
+ }
3228
+ return {
3229
+ data: CompanyFeatureUsageListResponseDataFromJSON(json["data"]),
3230
+ params: json["params"]
3231
+ };
3232
+ }
3233
+ function GetCompanyFeatureUsageResponseToJSON(json) {
3234
+ return GetCompanyFeatureUsageResponseToJSONTyped(json, false);
3235
+ }
3236
+ function GetCompanyFeatureUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
3237
+ if (value == null) {
3238
+ return value;
3239
+ }
3240
+ return {
3241
+ data: CompanyFeatureUsageListResponseDataToJSON(value["data"]),
3242
+ params: value["params"]
3243
+ };
3244
+ }
3245
+ function instanceOfGetCompanyFeatureUserUsageParams(value) {
3246
+ return true;
3247
+ }
3248
+ function GetCompanyFeatureUserUsageParamsFromJSON(json) {
3249
+ return GetCompanyFeatureUserUsageParamsFromJSONTyped(json, false);
3250
+ }
3251
+ function GetCompanyFeatureUserUsageParamsFromJSONTyped(json, ignoreDiscriminator) {
3252
+ if (json == null) {
3253
+ return json;
3254
+ }
3255
+ return {
3256
+ limit: json["limit"] == null ? void 0 : json["limit"],
3257
+ offset: json["offset"] == null ? void 0 : json["offset"]
3258
+ };
3259
+ }
3260
+ function GetCompanyFeatureUserUsageParamsToJSON(json) {
3261
+ return GetCompanyFeatureUserUsageParamsToJSONTyped(json, false);
3262
+ }
3263
+ function GetCompanyFeatureUserUsageParamsToJSONTyped(value, ignoreDiscriminator = false) {
3264
+ if (value == null) {
3265
+ return value;
3266
+ }
3267
+ return {
3268
+ limit: value["limit"],
3269
+ offset: value["offset"]
3270
+ };
3271
+ }
3272
+ function instanceOfGetCompanyFeatureUserUsageResponse(value) {
3273
+ if (!("data" in value) || value["data"] === void 0) return false;
3274
+ if (!("params" in value) || value["params"] === void 0) return false;
3275
+ return true;
3276
+ }
3277
+ function GetCompanyFeatureUserUsageResponseFromJSON(json) {
3278
+ return GetCompanyFeatureUserUsageResponseFromJSONTyped(json, false);
3279
+ }
3280
+ function GetCompanyFeatureUserUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
3281
+ if (json == null) {
3282
+ return json;
3283
+ }
3284
+ return {
3285
+ data: CompanyFeatureUserUsageResponseDataFromJSON(json["data"]),
3286
+ params: GetCompanyFeatureUserUsageParamsFromJSON(json["params"])
3287
+ };
3288
+ }
3289
+ function GetCompanyFeatureUserUsageResponseToJSON(json) {
3290
+ return GetCompanyFeatureUserUsageResponseToJSONTyped(json, false);
3291
+ }
3292
+ function GetCompanyFeatureUserUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
3293
+ if (value == null) {
3294
+ return value;
3295
+ }
3296
+ return {
3297
+ data: CompanyFeatureUserUsageResponseDataToJSON(value["data"]),
3298
+ params: GetCompanyFeatureUserUsageParamsToJSON(value["params"])
3299
+ };
3300
+ }
1865
3301
  function instanceOfGetCompanyInvoicesParams(value) {
1866
3302
  return true;
1867
3303
  }
@@ -2463,6 +3899,66 @@ var SchematicBillingClient = class {
2463
3899
  method: "DELETE"
2464
3900
  }).then(() => void 0);
2465
3901
  }
3902
+ fetchFeatureUsage() {
3903
+ const path = "/company/usage";
3904
+ return this.session.request(path).then((body) => {
3905
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3906
+ throw new Error(`Malformed response from ${path}`);
3907
+ }
3908
+ const data = body.data;
3909
+ if (data == null || data.features == null) {
3910
+ return [];
3911
+ }
3912
+ return GetCompanyFeatureUsageResponseFromJSON(body).data.features;
3913
+ });
3914
+ }
3915
+ fetchCreditBalances() {
3916
+ const path = "/company/credits";
3917
+ return this.session.request(path).then((body) => {
3918
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3919
+ throw new Error(`Malformed response from ${path}`);
3920
+ }
3921
+ const data = body.data;
3922
+ if (data == null || data.balances == null) {
3923
+ return [];
3924
+ }
3925
+ return GetCompanyCreditBalancesResponseFromJSON(body).data.balances;
3926
+ });
3927
+ }
3928
+ fetchCreditUserUsage(params) {
3929
+ const query = new URLSearchParams();
3930
+ if (params.limit !== void 0) {
3931
+ query.set("limit", String(params.limit));
3932
+ }
3933
+ if (params.offset !== void 0) {
3934
+ query.set("offset", String(params.offset));
3935
+ }
3936
+ const search = query.toString();
3937
+ const path = `/company/credits/${encodeURIComponent(params.creditId)}/users${search === "" ? "" : `?${search}`}`;
3938
+ return this.session.request(path).then((body) => {
3939
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3940
+ throw new Error(`Malformed response from ${path}`);
3941
+ }
3942
+ return GetCompanyCreditUserUsageResponseFromJSON(body).data;
3943
+ });
3944
+ }
3945
+ fetchFeatureUserUsage(params) {
3946
+ const query = new URLSearchParams();
3947
+ if (params.limit !== void 0) {
3948
+ query.set("limit", String(params.limit));
3949
+ }
3950
+ if (params.offset !== void 0) {
3951
+ query.set("offset", String(params.offset));
3952
+ }
3953
+ const search = query.toString();
3954
+ const path = `/company/usage/${encodeURIComponent(params.featureId)}/users${search === "" ? "" : `?${search}`}`;
3955
+ return this.session.request(path).then((body) => {
3956
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3957
+ throw new Error(`Malformed response from ${path}`);
3958
+ }
3959
+ return GetCompanyFeatureUserUsageResponseFromJSON(body).data;
3960
+ });
3961
+ }
2466
3962
  };
2467
3963
  var anonymousIdKey = "schematicId";
2468
3964
  var flagStateCachePrefix = "schematicCache";
@@ -2470,9 +3966,41 @@ var flagStateCacheMaxContexts = 10;
2470
3966
  var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
2471
3967
  var emptyCreditBalances = Object.freeze({});
2472
3968
  var emptyCreditSpendPolicies = [];
3969
+ function extractEventContext(event) {
3970
+ const body = event.body;
3971
+ const context = {};
3972
+ switch (event.type) {
3973
+ case "identify":
3974
+ if (body.keys != null) {
3975
+ context.user = body.keys;
3976
+ }
3977
+ if (body.company?.keys != null) {
3978
+ context.company = body.company.keys;
3979
+ }
3980
+ break;
3981
+ case "track":
3982
+ if (body.company != null) {
3983
+ context.company = body.company;
3984
+ }
3985
+ if (body.user != null) {
3986
+ context.user = body.user;
3987
+ }
3988
+ break;
3989
+ case "flag_check":
3990
+ if (body.req_company != null) {
3991
+ context.company = body.req_company;
3992
+ }
3993
+ if (body.req_user != null) {
3994
+ context.user = body.req_user;
3995
+ }
3996
+ break;
3997
+ }
3998
+ return context;
3999
+ }
2473
4000
  var Schematic = class {
2474
4001
  _additionalHeaders = {};
2475
4002
  apiKey;
4003
+ contextSignatureManager;
2476
4004
  _apiUrl = "https://api.schematichq.com";
2477
4005
  conn = null;
2478
4006
  context = {};
@@ -2559,6 +4087,12 @@ var Schematic = class {
2559
4087
  "X-Schematic-Client-Version": `schematic-js@${version}`,
2560
4088
  ...options?.additionalHeaders ?? {}
2561
4089
  };
4090
+ if (options?.getContextSignature !== void 0) {
4091
+ this.contextSignatureManager = new ContextSignatureManager(
4092
+ options.getContextSignature,
4093
+ this.debug.bind(this)
4094
+ );
4095
+ }
2562
4096
  if (options?.storage) {
2563
4097
  this.storage = options.storage;
2564
4098
  } else {
@@ -2728,12 +4262,14 @@ var Schematic = class {
2728
4262
  }
2729
4263
  if (!this.useWebSocket) {
2730
4264
  const requestUrl = `${this._apiUrl}/flags/${key}/check`;
4265
+ const sigHeaders = await this.contextSignatureHeaders(context);
2731
4266
  return fetch(requestUrl, {
2732
4267
  method: "POST",
2733
4268
  headers: {
2734
4269
  ...this._additionalHeaders ?? {},
2735
4270
  "Content-Type": "application/json;charset=UTF-8",
2736
- "X-Schematic-Api-Key": this.apiKey
4271
+ "X-Schematic-Api-Key": this.apiKey,
4272
+ ...sigHeaders
2737
4273
  },
2738
4274
  body: JSON.stringify(context)
2739
4275
  }).then((response) => {
@@ -2826,6 +4362,34 @@ var Schematic = class {
2826
4362
  console.log(`[Schematic] ${message}`, ...args);
2827
4363
  }
2828
4364
  }
4365
+ /**
4366
+ * Resolve the HMAC context-signature value for a context, if a signature
4367
+ * provider is configured. Returns undefined when no provider is set, when
4368
+ * offline, or when the signature could not be obtained.
4369
+ */
4370
+ contextSignature(context) {
4371
+ if (this.contextSignatureManager === void 0 || this.isOffline()) {
4372
+ return void 0;
4373
+ }
4374
+ return this.contextSignatureManager.getSignature(context);
4375
+ }
4376
+ /**
4377
+ * Build the `X-Schematic-Context-Sig` header for a context, or an empty
4378
+ * object when no signature is available. Spread into request headers.
4379
+ *
4380
+ * Returns synchronously (not a Promise) when no signature provider is
4381
+ * configured, so callers that dispatch on the same tick (e.g. fire-and-forget
4382
+ * event sends) keep their existing timing; only a configured provider, which
4383
+ * must fetch a signature, yields a Promise.
4384
+ */
4385
+ contextSignatureHeaders(context) {
4386
+ if (this.contextSignatureManager === void 0 || this.isOffline()) {
4387
+ return {};
4388
+ }
4389
+ return this.contextSignatureManager.getSignature(context).then(
4390
+ (signature) => signature === void 0 ? {} : { [contextSignatureHeader]: signature }
4391
+ );
4392
+ }
2829
4393
  /**
2830
4394
  * Create a persistent message handler for websocket flag updates
2831
4395
  */
@@ -2949,12 +4513,14 @@ var Schematic = class {
2949
4513
  }
2950
4514
  const requestUrl = `${this._apiUrl}/flags/check`;
2951
4515
  const requestBody = JSON.stringify(context);
4516
+ const sigHeaders = await this.contextSignatureHeaders(context);
2952
4517
  return fetch(requestUrl, {
2953
4518
  method: "POST",
2954
4519
  headers: {
2955
4520
  ...this._additionalHeaders ?? {},
2956
4521
  "Content-Type": "application/json;charset=UTF-8",
2957
- "X-Schematic-Api-Key": this.apiKey
4522
+ "X-Schematic-Api-Key": this.apiKey,
4523
+ ...sigHeaders
2958
4524
  },
2959
4525
  body: requestBody
2960
4526
  }).then((response) => {
@@ -3509,12 +5075,17 @@ var Schematic = class {
3509
5075
  this.debug(`event not sent (offline mode):`, { event });
3510
5076
  return Promise.resolve();
3511
5077
  }
5078
+ const maybeSigHeaders = this.contextSignatureHeaders(
5079
+ extractEventContext(event)
5080
+ );
5081
+ const sigHeaders = maybeSigHeaders instanceof Promise ? await maybeSigHeaders : maybeSigHeaders;
3512
5082
  try {
3513
5083
  const response = await fetch(captureUrl, {
3514
5084
  method: "POST",
3515
5085
  headers: {
3516
5086
  ...this._additionalHeaders ?? {},
3517
- "Content-Type": "application/json;charset=UTF-8"
5087
+ "Content-Type": "application/json;charset=UTF-8",
5088
+ ...sigHeaders
3518
5089
  },
3519
5090
  body: payload
3520
5091
  });
@@ -3698,6 +5269,7 @@ var Schematic = class {
3698
5269
  * In offline mode, this is a no-op.
3699
5270
  */
3700
5271
  cleanup = async () => {
5272
+ this.contextSignatureManager?.clear();
3701
5273
  if (this.isOffline()) {
3702
5274
  this.debug("cleanup: skipped (offline mode)");
3703
5275
  return Promise.resolve();
@@ -3983,7 +5555,7 @@ var Schematic = class {
3983
5555
  context
3984
5556
  );
3985
5557
  this.context = context;
3986
- const sendMessage = () => {
5558
+ const sendMessage = async () => {
3987
5559
  let resolved = false;
3988
5560
  const persistentMessageHandler = this.createPersistentMessageHandler(context);
3989
5561
  const messageHandler = (event) => {
@@ -4010,20 +5582,22 @@ var Schematic = class {
4010
5582
  });
4011
5583
  this.currentWebSocket = socket;
4012
5584
  const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
5585
+ const sig = await this.contextSignature(context);
4013
5586
  const messagePayload = {
4014
5587
  apiKey: this.apiKey,
4015
5588
  clientVersion,
4016
- data: context
5589
+ data: context,
5590
+ ...sig !== void 0 ? { sig } : {}
4017
5591
  };
4018
5592
  this.debug(`WebSocket sending message:`, messagePayload);
4019
5593
  socket.send(JSON.stringify(messagePayload));
4020
5594
  };
4021
5595
  if (socket.readyState === WebSocket.OPEN) {
4022
5596
  this.debug(`WebSocket already open, sending message`);
4023
- sendMessage();
5597
+ void sendMessage();
4024
5598
  } else if (socket.readyState === WebSocket.CONNECTING) {
4025
5599
  this.debug(`WebSocket connecting, waiting for open to send message`);
4026
- socket.addEventListener("open", sendMessage);
5600
+ socket.addEventListener("open", () => void sendMessage());
4027
5601
  } else {
4028
5602
  this.debug(`WebSocket is closed, cannot send message`);
4029
5603
  reject("WebSocket is not open or connecting");
@@ -4626,6 +6200,7 @@ var READINESS = {
4626
6200
  active: "ready",
4627
6201
  ended: "never"
4628
6202
  };
6203
+ var FEATURE_USER_USAGE_LIMIT = 20;
4629
6204
  var BillingStore = class {
4630
6205
  constructor(_client, initialData = {}, options = {}) {
4631
6206
  this._client = _client;
@@ -4646,6 +6221,28 @@ var BillingStore = class {
4646
6221
  () => this._client.fetchPaymentMethods(),
4647
6222
  { readiness }
4648
6223
  );
6224
+ this.featureUsage = new KeyedResource(
6225
+ () => this._client.fetchFeatureUsage(),
6226
+ { readiness }
6227
+ );
6228
+ this.featureUserUsage = new KeyedResource(
6229
+ ({ featureId }) => this._client.fetchFeatureUserUsage({
6230
+ featureId,
6231
+ limit: FEATURE_USER_USAGE_LIMIT
6232
+ }),
6233
+ { readiness }
6234
+ );
6235
+ this.creditBalances = new KeyedResource(
6236
+ () => this._client.fetchCreditBalances(),
6237
+ { readiness }
6238
+ );
6239
+ this.creditUserUsage = new KeyedResource(
6240
+ ({ creditId }) => this._client.fetchCreditUserUsage({
6241
+ creditId,
6242
+ limit: FEATURE_USER_USAGE_LIMIT
6243
+ }),
6244
+ { readiness }
6245
+ );
4649
6246
  const held = { key: initialData.sessionKey };
4650
6247
  if (initialData.invoices !== void 0) {
4651
6248
  held.invoices = {
@@ -4663,7 +6260,13 @@ var BillingStore = class {
4663
6260
  if (initialData.paymentMethods !== void 0) {
4664
6261
  held.paymentMethods = initialData.paymentMethods;
4665
6262
  }
4666
- if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0) {
6263
+ if (initialData.featureUsage !== void 0) {
6264
+ held.featureUsage = initialData.featureUsage;
6265
+ }
6266
+ if (initialData.creditBalances !== void 0) {
6267
+ held.creditBalances = initialData.creditBalances;
6268
+ }
6269
+ if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0 || held.featureUsage !== void 0 || held.creditBalances !== void 0) {
4667
6270
  this._held = held;
4668
6271
  this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
4669
6272
  }
@@ -4672,6 +6275,10 @@ var BillingStore = class {
4672
6275
  invoices;
4673
6276
  upcomingInvoice;
4674
6277
  paymentMethods;
6278
+ featureUsage;
6279
+ creditBalances;
6280
+ creditUserUsage;
6281
+ featureUserUsage;
4675
6282
  _pageSize;
4676
6283
  _unsubscribe;
4677
6284
  _connected = false;
@@ -4750,6 +6357,12 @@ var BillingStore = class {
4750
6357
  if (held.paymentMethods !== void 0) {
4751
6358
  this.paymentMethods.seed(SINGLETON, held.paymentMethods);
4752
6359
  }
6360
+ if (held.featureUsage !== void 0) {
6361
+ this.featureUsage.seed(SINGLETON, held.featureUsage);
6362
+ }
6363
+ if (held.creditBalances !== void 0) {
6364
+ this.creditBalances.seed(SINGLETON, held.creditBalances);
6365
+ }
4753
6366
  this._seedKey = held.key;
4754
6367
  this._seeded = true;
4755
6368
  }
@@ -4762,24 +6375,32 @@ var BillingStore = class {
4762
6375
  for (const name of RESOURCE_NAMES) {
4763
6376
  this[name].resetAll();
4764
6377
  }
6378
+ this.featureUserUsage.resetAll();
6379
+ this.creditUserUsage.resetAll();
4765
6380
  }
4766
6381
  /** Forgets every resource and leaves them empty; nothing reloads. */
4767
6382
  clearAll() {
4768
6383
  for (const name of RESOURCE_NAMES) {
4769
6384
  this[name].clearAll();
4770
6385
  }
6386
+ this.featureUserUsage.clearAll();
6387
+ this.creditUserUsage.clearAll();
4771
6388
  }
4772
6389
  /** Loads every resource that is subscribed and has nothing yet. */
4773
6390
  resumeAll() {
4774
6391
  for (const name of RESOURCE_NAMES) {
4775
6392
  this[name].resumeAll();
4776
6393
  }
6394
+ this.featureUserUsage.resumeAll();
6395
+ this.creditUserUsage.resumeAll();
4777
6396
  }
4778
6397
  /** Reloads every resource that has been loaded, keeping its current data. */
4779
6398
  invalidateAll() {
4780
6399
  for (const name of RESOURCE_NAMES) {
4781
6400
  this[name].invalidateAll();
4782
6401
  }
6402
+ this.featureUserUsage.invalidateAll();
6403
+ this.creditUserUsage.invalidateAll();
4783
6404
  }
4784
6405
  /**
4785
6406
  * Appends the next page to the invoices list for `query`, when there is
@@ -4891,7 +6512,9 @@ var BillingStore = class {
4891
6512
  var RESOURCE_NAMES = [
4892
6513
  "invoices",
4893
6514
  "upcomingInvoice",
4894
- "paymentMethods"
6515
+ "paymentMethods",
6516
+ "featureUsage",
6517
+ "creditBalances"
4895
6518
  ];
4896
6519
 
4897
6520
  // src/billing/context.tsx
@@ -4971,6 +6594,12 @@ var missingBillingSource = {
4971
6594
  subscribe: () => () => {
4972
6595
  },
4973
6596
  handle: () => missingHandle,
6597
+ subscribeFeatureUserUsage: () => () => {
6598
+ },
6599
+ featureUserUsage: () => missingHandle,
6600
+ subscribeCreditUserUsage: () => () => {
6601
+ },
6602
+ creditUserUsage: () => missingHandle,
4974
6603
  loadMoreInvoices: () => Promise.resolve(),
4975
6604
  invalidateAll: () => {
4976
6605
  },
@@ -4984,7 +6613,9 @@ function useBillingDataSource() {
4984
6613
  function BillingDataProvider({
4985
6614
  actions,
4986
6615
  children,
6616
+ creditUserUsage,
4987
6617
  data,
6618
+ featureUserUsage,
4988
6619
  locale,
4989
6620
  onLoadMoreInvoices,
4990
6621
  onMissingString,
@@ -4995,6 +6626,8 @@ function BillingDataProvider({
4995
6626
  }) {
4996
6627
  const source = (0, import_react2.useMemo)(() => {
4997
6628
  const handles = /* @__PURE__ */ new Map();
6629
+ const userUsageHandles = /* @__PURE__ */ new Map();
6630
+ const creditUsageHandles = /* @__PURE__ */ new Map();
4998
6631
  return {
4999
6632
  actions: rejectingActions(
5000
6633
  (name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
@@ -5018,6 +6651,42 @@ function BillingDataProvider({
5018
6651
  handles.set(name, handle);
5019
6652
  return handle;
5020
6653
  },
6654
+ subscribeFeatureUserUsage: () => () => {
6655
+ },
6656
+ featureUserUsage: (featureId) => {
6657
+ const cached = userUsageHandles.get(featureId);
6658
+ if (cached !== void 0) {
6659
+ return cached;
6660
+ }
6661
+ const value = featureUserUsage?.[featureId];
6662
+ const handle = {
6663
+ data: value,
6664
+ error: void 0,
6665
+ isPending: value === void 0,
6666
+ refetch: () => {
6667
+ }
6668
+ };
6669
+ userUsageHandles.set(featureId, handle);
6670
+ return handle;
6671
+ },
6672
+ subscribeCreditUserUsage: () => () => {
6673
+ },
6674
+ creditUserUsage: (creditId) => {
6675
+ const cached = creditUsageHandles.get(creditId);
6676
+ if (cached !== void 0) {
6677
+ return cached;
6678
+ }
6679
+ const value = creditUserUsage?.[creditId];
6680
+ const handle = {
6681
+ data: value,
6682
+ error: void 0,
6683
+ isPending: value === void 0,
6684
+ refetch: () => {
6685
+ }
6686
+ };
6687
+ creditUsageHandles.set(creditId, handle);
6688
+ return handle;
6689
+ },
5021
6690
  loadMoreInvoices: (query) => {
5022
6691
  onLoadMoreInvoices?.(query);
5023
6692
  return Promise.resolve();
@@ -5025,7 +6694,15 @@ function BillingDataProvider({
5025
6694
  invalidateAll: () => {
5026
6695
  }
5027
6696
  };
5028
- }, [actions, data, onLoadMoreInvoices, onRefetch, status]);
6697
+ }, [
6698
+ actions,
6699
+ creditUserUsage,
6700
+ data,
6701
+ featureUserUsage,
6702
+ onLoadMoreInvoices,
6703
+ onRefetch,
6704
+ status
6705
+ ]);
5029
6706
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
5030
6707
  SchematicI18nProvider,
5031
6708
  {
@@ -5115,6 +6792,36 @@ function useSetupIntent() {
5115
6792
  [source]
5116
6793
  );
5117
6794
  }
6795
+ function useFeatureUsage() {
6796
+ return useBillingResource("featureUsage", SINGLETON);
6797
+ }
6798
+ function useFeatureUserUsage(featureId) {
6799
+ const source = useBillingDataSource();
6800
+ const subscribe = (0, import_react3.useCallback)(
6801
+ (listener) => source.subscribeFeatureUserUsage(featureId, listener),
6802
+ [featureId, source]
6803
+ );
6804
+ const getSnapshot = (0, import_react3.useCallback)(
6805
+ () => source.featureUserUsage(featureId),
6806
+ [featureId, source]
6807
+ );
6808
+ return (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
6809
+ }
6810
+ function useCreditBalances() {
6811
+ return useBillingResource("creditBalances", SINGLETON);
6812
+ }
6813
+ function useCreditUserUsage(creditId) {
6814
+ const source = useBillingDataSource();
6815
+ const subscribe = (0, import_react3.useCallback)(
6816
+ (listener) => source.subscribeCreditUserUsage(creditId, listener),
6817
+ [creditId, source]
6818
+ );
6819
+ const getSnapshot = (0, import_react3.useCallback)(
6820
+ () => source.creditUserUsage(creditId),
6821
+ [creditId, source]
6822
+ );
6823
+ return (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
6824
+ }
5118
6825
  function useInvalidateBillingData() {
5119
6826
  return useBillingDataSource().invalidateAll;
5120
6827
  }
@@ -5170,8 +6877,7 @@ function BillingProvider({
5170
6877
  return initialRef.current === void 0 ? void 0 : staticSource(initialRef.current);
5171
6878
  }
5172
6879
  const handles = /* @__PURE__ */ new WeakMap();
5173
- const handle = (name, params) => {
5174
- const resource = store.resource(name).get(params);
6880
+ const handleOf = (resource) => {
5175
6881
  const snapshot = resource.getSnapshot();
5176
6882
  const cached = handles.get(resource);
5177
6883
  if (cached !== void 0 && cached.snapshot === snapshot) {
@@ -5181,12 +6887,20 @@ function BillingProvider({
5181
6887
  ...snapshot,
5182
6888
  refetch: () => void resource.refetch()
5183
6889
  };
5184
- handles.set(resource, { snapshot, handle: next });
6890
+ handles.set(resource, {
6891
+ snapshot,
6892
+ handle: next
6893
+ });
5185
6894
  return next;
5186
6895
  };
6896
+ const handle = (name, params) => handleOf(store.resource(name).get(params));
5187
6897
  return {
5188
6898
  subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
5189
6899
  handle,
6900
+ subscribeFeatureUserUsage: (featureId, listener) => store.featureUserUsage.subscribe({ featureId }, listener),
6901
+ featureUserUsage: (featureId) => handleOf(store.featureUserUsage.get({ featureId })),
6902
+ subscribeCreditUserUsage: (creditId, listener) => store.creditUserUsage.subscribe({ creditId }, listener),
6903
+ creditUserUsage: (creditId) => handleOf(store.creditUserUsage.get({ creditId })),
5190
6904
  loadMoreInvoices: (query) => store.loadMoreInvoices(query),
5191
6905
  invalidateAll: () => store.invalidateAll(),
5192
6906
  actions: {
@@ -5213,7 +6927,27 @@ function BillingProvider({
5213
6927
  }
5214
6928
  function staticSource(data) {
5215
6929
  const handles = /* @__PURE__ */ new Map();
6930
+ const pendingUserUsage = {
6931
+ data: void 0,
6932
+ error: void 0,
6933
+ isPending: true,
6934
+ refetch: () => {
6935
+ }
6936
+ };
6937
+ const pendingCreditUsage = {
6938
+ data: void 0,
6939
+ error: void 0,
6940
+ isPending: true,
6941
+ refetch: () => {
6942
+ }
6943
+ };
5216
6944
  return {
6945
+ subscribeFeatureUserUsage: () => () => {
6946
+ },
6947
+ featureUserUsage: () => pendingUserUsage,
6948
+ subscribeCreditUserUsage: () => () => {
6949
+ },
6950
+ creditUserUsage: () => pendingCreditUsage,
5217
6951
  subscribe: () => () => {
5218
6952
  },
5219
6953
  handle: (name) => {
@@ -5239,7 +6973,7 @@ function staticSource(data) {
5239
6973
  }
5240
6974
 
5241
6975
  // src/version.ts
5242
- var version2 = "1.10.0";
6976
+ var version2 = "1.12.0";
5243
6977
 
5244
6978
  // src/context/schematic.tsx
5245
6979
  var import_jsx_runtime4 = require("react/jsx-runtime");