@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.
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/@schematichq+schematic-js@1.10.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
1
+ // node_modules/.pnpm/@schematichq+schematic-js@1.12.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -658,6 +658,7 @@ function FeatureEntitlementFromJSONTyped(json, ignoreDiscriminator) {
658
658
  metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON(json["metric_period"]),
659
659
  metricResetAt: json["metric_reset_at"] == null ? void 0 : new Date(json["metric_reset_at"]),
660
660
  monthReset: json["month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON(json["month_reset"]),
661
+ quantityRates: json["quantity_rates"] == null ? void 0 : json["quantity_rates"],
661
662
  softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
662
663
  usage: json["usage"] == null ? void 0 : json["usage"],
663
664
  valueType: EntitlementValueTypeFromJSON(json["value_type"]),
@@ -1234,7 +1235,98 @@ function contextString(context) {
1234
1235
  }, {});
1235
1236
  return JSON.stringify(sortedContext);
1236
1237
  }
1237
- var version = "1.10.0";
1238
+ var contextSignatureHeader = "X-Schematic-Context-Sig";
1239
+ var refreshSkewMs = 6e4;
1240
+ var maxCachedSignatures = 50;
1241
+ function parseSignatureExpiryMs(signature) {
1242
+ const parts = signature.split(".");
1243
+ if (parts.length !== 3) {
1244
+ return null;
1245
+ }
1246
+ const expSeconds = Number(parts[1]);
1247
+ if (!Number.isFinite(expSeconds)) {
1248
+ return null;
1249
+ }
1250
+ return expSeconds * 1e3;
1251
+ }
1252
+ var ContextSignatureManager = class {
1253
+ provider;
1254
+ debug;
1255
+ cache = /* @__PURE__ */ new Map();
1256
+ inFlight = /* @__PURE__ */ new Map();
1257
+ constructor(provider, debug) {
1258
+ this.provider = provider;
1259
+ this.debug = debug;
1260
+ }
1261
+ /**
1262
+ * Return a valid signature for the given context, fetching a fresh one via
1263
+ * the provider when the cache is empty or close to expiry. Concurrent calls
1264
+ * for the same context share a single provider invocation. Returns undefined
1265
+ * (and logs a warning) if the provider throws, so callers can degrade
1266
+ * gracefully by sending the request without a signature.
1267
+ */
1268
+ async getSignature(context) {
1269
+ const key = contextString(context);
1270
+ const cached = this.cache.get(key);
1271
+ if (cached !== void 0 && Date.now() < cached.expiresAtMs - refreshSkewMs) {
1272
+ this.cache.delete(key);
1273
+ this.cache.set(key, cached);
1274
+ return cached.signature;
1275
+ }
1276
+ const existing = this.inFlight.get(key);
1277
+ if (existing !== void 0) {
1278
+ return existing;
1279
+ }
1280
+ const pending = this.fetchSignature(key, context).finally(() => {
1281
+ this.inFlight.delete(key);
1282
+ });
1283
+ this.inFlight.set(key, pending);
1284
+ return pending;
1285
+ }
1286
+ /** Drop all cached signatures. */
1287
+ clear() {
1288
+ this.cache.clear();
1289
+ }
1290
+ /**
1291
+ * Drop expired signatures, then the least recently used ones until the cache
1292
+ * is within `maxCachedSignatures`.
1293
+ */
1294
+ evict() {
1295
+ const now = Date.now();
1296
+ for (const [key, entry] of this.cache) {
1297
+ if (now >= entry.expiresAtMs) {
1298
+ this.cache.delete(key);
1299
+ }
1300
+ }
1301
+ for (const key of this.cache.keys()) {
1302
+ if (this.cache.size <= maxCachedSignatures) {
1303
+ break;
1304
+ }
1305
+ this.cache.delete(key);
1306
+ }
1307
+ }
1308
+ async fetchSignature(key, context) {
1309
+ try {
1310
+ const signature = await this.provider(context);
1311
+ const expiresAtMs = parseSignatureExpiryMs(signature);
1312
+ if (expiresAtMs === null) {
1313
+ this.debug(
1314
+ "getContextSignature returned a value without a parseable expiry; not caching",
1315
+ { signature }
1316
+ );
1317
+ return signature;
1318
+ }
1319
+ this.cache.delete(key);
1320
+ this.cache.set(key, { signature, expiresAtMs });
1321
+ this.evict();
1322
+ return signature;
1323
+ } catch (error) {
1324
+ console.warn("Failed to obtain context signature:", error);
1325
+ return void 0;
1326
+ }
1327
+ }
1328
+ };
1329
+ var version = "1.12.0";
1238
1330
  var SINGLETON = {};
1239
1331
  var models_exports = {};
1240
1332
  __export(models_exports, {
@@ -1242,15 +1334,88 @@ __export(models_exports, {
1242
1334
  ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
1243
1335
  ApiErrorToJSON: () => ApiErrorToJSON,
1244
1336
  ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
1337
+ BillingCreditGrantReason: () => BillingCreditGrantReason,
1338
+ BillingCreditGrantReasonFromJSON: () => BillingCreditGrantReasonFromJSON,
1339
+ BillingCreditGrantReasonFromJSONTyped: () => BillingCreditGrantReasonFromJSONTyped,
1340
+ BillingCreditGrantReasonToJSON: () => BillingCreditGrantReasonToJSON,
1341
+ BillingCreditGrantReasonToJSONTyped: () => BillingCreditGrantReasonToJSONTyped,
1342
+ BillingPlanCreditGrantResetCadence: () => BillingPlanCreditGrantResetCadence,
1343
+ BillingPlanCreditGrantResetCadenceFromJSON: () => BillingPlanCreditGrantResetCadenceFromJSON2,
1344
+ BillingPlanCreditGrantResetCadenceFromJSONTyped: () => BillingPlanCreditGrantResetCadenceFromJSONTyped3,
1345
+ BillingPlanCreditGrantResetCadenceToJSON: () => BillingPlanCreditGrantResetCadenceToJSON2,
1346
+ BillingPlanCreditGrantResetCadenceToJSONTyped: () => BillingPlanCreditGrantResetCadenceToJSONTyped3,
1347
+ BillingPriceScheme: () => BillingPriceScheme,
1348
+ BillingPriceSchemeFromJSON: () => BillingPriceSchemeFromJSON2,
1349
+ BillingPriceSchemeFromJSONTyped: () => BillingPriceSchemeFromJSONTyped4,
1350
+ BillingPriceSchemeToJSON: () => BillingPriceSchemeToJSON2,
1351
+ BillingPriceSchemeToJSONTyped: () => BillingPriceSchemeToJSONTyped4,
1352
+ BillingProductPriceInterval: () => BillingProductPriceInterval,
1353
+ BillingProductPriceIntervalFromJSON: () => BillingProductPriceIntervalFromJSON2,
1354
+ BillingProductPriceIntervalFromJSONTyped: () => BillingProductPriceIntervalFromJSONTyped4,
1355
+ BillingProductPriceIntervalToJSON: () => BillingProductPriceIntervalToJSON2,
1356
+ BillingProductPriceIntervalToJSONTyped: () => BillingProductPriceIntervalToJSONTyped4,
1245
1357
  BillingProviderType: () => BillingProviderType,
1246
1358
  BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
1247
1359
  BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
1248
1360
  BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
1249
1361
  BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
1362
+ BillingTiersMode: () => BillingTiersMode,
1363
+ BillingTiersModeFromJSON: () => BillingTiersModeFromJSON2,
1364
+ BillingTiersModeFromJSONTyped: () => BillingTiersModeFromJSONTyped4,
1365
+ BillingTiersModeToJSON: () => BillingTiersModeToJSON2,
1366
+ BillingTiersModeToJSONTyped: () => BillingTiersModeToJSONTyped4,
1367
+ CatalogCreditGrantResponseDataFromJSON: () => CatalogCreditGrantResponseDataFromJSON,
1368
+ CatalogCreditGrantResponseDataFromJSONTyped: () => CatalogCreditGrantResponseDataFromJSONTyped,
1369
+ CatalogCreditGrantResponseDataToJSON: () => CatalogCreditGrantResponseDataToJSON,
1370
+ CatalogCreditGrantResponseDataToJSONTyped: () => CatalogCreditGrantResponseDataToJSONTyped,
1371
+ CatalogPriceResponseDataFromJSON: () => CatalogPriceResponseDataFromJSON,
1372
+ CatalogPriceResponseDataFromJSONTyped: () => CatalogPriceResponseDataFromJSONTyped,
1373
+ CatalogPriceResponseDataToJSON: () => CatalogPriceResponseDataToJSON,
1374
+ CatalogPriceResponseDataToJSONTyped: () => CatalogPriceResponseDataToJSONTyped,
1375
+ CatalogPriceTierResponseDataFromJSON: () => CatalogPriceTierResponseDataFromJSON,
1376
+ CatalogPriceTierResponseDataFromJSONTyped: () => CatalogPriceTierResponseDataFromJSONTyped,
1377
+ CatalogPriceTierResponseDataToJSON: () => CatalogPriceTierResponseDataToJSON,
1378
+ CatalogPriceTierResponseDataToJSONTyped: () => CatalogPriceTierResponseDataToJSONTyped,
1379
+ CompanyCreditBalanceResponseDataFromJSON: () => CompanyCreditBalanceResponseDataFromJSON,
1380
+ CompanyCreditBalanceResponseDataFromJSONTyped: () => CompanyCreditBalanceResponseDataFromJSONTyped,
1381
+ CompanyCreditBalanceResponseDataToJSON: () => CompanyCreditBalanceResponseDataToJSON,
1382
+ CompanyCreditBalanceResponseDataToJSONTyped: () => CompanyCreditBalanceResponseDataToJSONTyped,
1383
+ CompanyCreditBalancesResponseDataFromJSON: () => CompanyCreditBalancesResponseDataFromJSON,
1384
+ CompanyCreditBalancesResponseDataFromJSONTyped: () => CompanyCreditBalancesResponseDataFromJSONTyped,
1385
+ CompanyCreditBalancesResponseDataToJSON: () => CompanyCreditBalancesResponseDataToJSON,
1386
+ CompanyCreditBalancesResponseDataToJSONTyped: () => CompanyCreditBalancesResponseDataToJSONTyped,
1387
+ CompanyCreditCompositionResponseDataFromJSON: () => CompanyCreditCompositionResponseDataFromJSON,
1388
+ CompanyCreditCompositionResponseDataFromJSONTyped: () => CompanyCreditCompositionResponseDataFromJSONTyped,
1389
+ CompanyCreditCompositionResponseDataToJSON: () => CompanyCreditCompositionResponseDataToJSON,
1390
+ CompanyCreditCompositionResponseDataToJSONTyped: () => CompanyCreditCompositionResponseDataToJSONTyped,
1391
+ CompanyCreditGrantResponseDataFromJSON: () => CompanyCreditGrantResponseDataFromJSON,
1392
+ CompanyCreditGrantResponseDataFromJSONTyped: () => CompanyCreditGrantResponseDataFromJSONTyped,
1393
+ CompanyCreditGrantResponseDataToJSON: () => CompanyCreditGrantResponseDataToJSON,
1394
+ CompanyCreditGrantResponseDataToJSONTyped: () => CompanyCreditGrantResponseDataToJSONTyped,
1395
+ CompanyCreditUserUsageResponseDataFromJSON: () => CompanyCreditUserUsageResponseDataFromJSON,
1396
+ CompanyCreditUserUsageResponseDataFromJSONTyped: () => CompanyCreditUserUsageResponseDataFromJSONTyped,
1397
+ CompanyCreditUserUsageResponseDataToJSON: () => CompanyCreditUserUsageResponseDataToJSON,
1398
+ CompanyCreditUserUsageResponseDataToJSONTyped: () => CompanyCreditUserUsageResponseDataToJSONTyped,
1399
+ CompanyCreditUserUsageRowResponseDataFromJSON: () => CompanyCreditUserUsageRowResponseDataFromJSON,
1400
+ CompanyCreditUserUsageRowResponseDataFromJSONTyped: () => CompanyCreditUserUsageRowResponseDataFromJSONTyped,
1401
+ CompanyCreditUserUsageRowResponseDataToJSON: () => CompanyCreditUserUsageRowResponseDataToJSON,
1402
+ CompanyCreditUserUsageRowResponseDataToJSONTyped: () => CompanyCreditUserUsageRowResponseDataToJSONTyped,
1250
1403
  CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
1251
1404
  CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
1252
1405
  CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
1253
1406
  CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
1407
+ CompanyFeatureUsageListResponseDataFromJSON: () => CompanyFeatureUsageListResponseDataFromJSON,
1408
+ CompanyFeatureUsageListResponseDataFromJSONTyped: () => CompanyFeatureUsageListResponseDataFromJSONTyped,
1409
+ CompanyFeatureUsageListResponseDataToJSON: () => CompanyFeatureUsageListResponseDataToJSON,
1410
+ CompanyFeatureUsageListResponseDataToJSONTyped: () => CompanyFeatureUsageListResponseDataToJSONTyped,
1411
+ CompanyFeatureUsageResponseDataFromJSON: () => CompanyFeatureUsageResponseDataFromJSON,
1412
+ CompanyFeatureUsageResponseDataFromJSONTyped: () => CompanyFeatureUsageResponseDataFromJSONTyped,
1413
+ CompanyFeatureUsageResponseDataToJSON: () => CompanyFeatureUsageResponseDataToJSON,
1414
+ CompanyFeatureUsageResponseDataToJSONTyped: () => CompanyFeatureUsageResponseDataToJSONTyped,
1415
+ CompanyFeatureUserUsageResponseDataFromJSON: () => CompanyFeatureUserUsageResponseDataFromJSON,
1416
+ CompanyFeatureUserUsageResponseDataFromJSONTyped: () => CompanyFeatureUserUsageResponseDataFromJSONTyped,
1417
+ CompanyFeatureUserUsageResponseDataToJSON: () => CompanyFeatureUserUsageResponseDataToJSON,
1418
+ CompanyFeatureUserUsageResponseDataToJSONTyped: () => CompanyFeatureUserUsageResponseDataToJSONTyped,
1254
1419
  CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
1255
1420
  CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
1256
1421
  CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
@@ -1271,6 +1436,10 @@ __export(models_exports, {
1271
1436
  CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
1272
1437
  CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
1273
1438
  CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
1439
+ CompanyUserUsageResponseDataFromJSON: () => CompanyUserUsageResponseDataFromJSON,
1440
+ CompanyUserUsageResponseDataFromJSONTyped: () => CompanyUserUsageResponseDataFromJSONTyped,
1441
+ CompanyUserUsageResponseDataToJSON: () => CompanyUserUsageResponseDataToJSON,
1442
+ CompanyUserUsageResponseDataToJSONTyped: () => CompanyUserUsageResponseDataToJSONTyped,
1274
1443
  CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
1275
1444
  CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
1276
1445
  CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
@@ -1283,6 +1452,50 @@ __export(models_exports, {
1283
1452
  DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
1284
1453
  DeleteResponseToJSON: () => DeleteResponseToJSON,
1285
1454
  DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
1455
+ EntitlementPriceBehavior: () => EntitlementPriceBehavior,
1456
+ EntitlementPriceBehaviorFromJSON: () => EntitlementPriceBehaviorFromJSON2,
1457
+ EntitlementPriceBehaviorFromJSONTyped: () => EntitlementPriceBehaviorFromJSONTyped2,
1458
+ EntitlementPriceBehaviorToJSON: () => EntitlementPriceBehaviorToJSON2,
1459
+ EntitlementPriceBehaviorToJSONTyped: () => EntitlementPriceBehaviorToJSONTyped2,
1460
+ EntitlementType: () => EntitlementType,
1461
+ EntitlementTypeFromJSON: () => EntitlementTypeFromJSON,
1462
+ EntitlementTypeFromJSONTyped: () => EntitlementTypeFromJSONTyped,
1463
+ EntitlementTypeToJSON: () => EntitlementTypeToJSON,
1464
+ EntitlementTypeToJSONTyped: () => EntitlementTypeToJSONTyped,
1465
+ EntitlementValueType: () => EntitlementValueType,
1466
+ EntitlementValueTypeFromJSON: () => EntitlementValueTypeFromJSON2,
1467
+ EntitlementValueTypeFromJSONTyped: () => EntitlementValueTypeFromJSONTyped4,
1468
+ EntitlementValueTypeToJSON: () => EntitlementValueTypeToJSON2,
1469
+ EntitlementValueTypeToJSONTyped: () => EntitlementValueTypeToJSONTyped3,
1470
+ FeatureType: () => FeatureType,
1471
+ FeatureTypeFromJSON: () => FeatureTypeFromJSON2,
1472
+ FeatureTypeFromJSONTyped: () => FeatureTypeFromJSONTyped3,
1473
+ FeatureTypeToJSON: () => FeatureTypeToJSON2,
1474
+ FeatureTypeToJSONTyped: () => FeatureTypeToJSONTyped3,
1475
+ GetCompanyCreditBalancesResponseFromJSON: () => GetCompanyCreditBalancesResponseFromJSON,
1476
+ GetCompanyCreditBalancesResponseFromJSONTyped: () => GetCompanyCreditBalancesResponseFromJSONTyped,
1477
+ GetCompanyCreditBalancesResponseToJSON: () => GetCompanyCreditBalancesResponseToJSON,
1478
+ GetCompanyCreditBalancesResponseToJSONTyped: () => GetCompanyCreditBalancesResponseToJSONTyped,
1479
+ GetCompanyCreditUserUsageParamsFromJSON: () => GetCompanyCreditUserUsageParamsFromJSON,
1480
+ GetCompanyCreditUserUsageParamsFromJSONTyped: () => GetCompanyCreditUserUsageParamsFromJSONTyped,
1481
+ GetCompanyCreditUserUsageParamsToJSON: () => GetCompanyCreditUserUsageParamsToJSON,
1482
+ GetCompanyCreditUserUsageParamsToJSONTyped: () => GetCompanyCreditUserUsageParamsToJSONTyped,
1483
+ GetCompanyCreditUserUsageResponseFromJSON: () => GetCompanyCreditUserUsageResponseFromJSON,
1484
+ GetCompanyCreditUserUsageResponseFromJSONTyped: () => GetCompanyCreditUserUsageResponseFromJSONTyped,
1485
+ GetCompanyCreditUserUsageResponseToJSON: () => GetCompanyCreditUserUsageResponseToJSON,
1486
+ GetCompanyCreditUserUsageResponseToJSONTyped: () => GetCompanyCreditUserUsageResponseToJSONTyped,
1487
+ GetCompanyFeatureUsageResponseFromJSON: () => GetCompanyFeatureUsageResponseFromJSON,
1488
+ GetCompanyFeatureUsageResponseFromJSONTyped: () => GetCompanyFeatureUsageResponseFromJSONTyped,
1489
+ GetCompanyFeatureUsageResponseToJSON: () => GetCompanyFeatureUsageResponseToJSON,
1490
+ GetCompanyFeatureUsageResponseToJSONTyped: () => GetCompanyFeatureUsageResponseToJSONTyped,
1491
+ GetCompanyFeatureUserUsageParamsFromJSON: () => GetCompanyFeatureUserUsageParamsFromJSON,
1492
+ GetCompanyFeatureUserUsageParamsFromJSONTyped: () => GetCompanyFeatureUserUsageParamsFromJSONTyped,
1493
+ GetCompanyFeatureUserUsageParamsToJSON: () => GetCompanyFeatureUserUsageParamsToJSON,
1494
+ GetCompanyFeatureUserUsageParamsToJSONTyped: () => GetCompanyFeatureUserUsageParamsToJSONTyped,
1495
+ GetCompanyFeatureUserUsageResponseFromJSON: () => GetCompanyFeatureUserUsageResponseFromJSON,
1496
+ GetCompanyFeatureUserUsageResponseFromJSONTyped: () => GetCompanyFeatureUserUsageResponseFromJSONTyped,
1497
+ GetCompanyFeatureUserUsageResponseToJSON: () => GetCompanyFeatureUserUsageResponseToJSON,
1498
+ GetCompanyFeatureUserUsageResponseToJSONTyped: () => GetCompanyFeatureUserUsageResponseToJSONTyped,
1286
1499
  GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
1287
1500
  GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
1288
1501
  GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
@@ -1304,10 +1517,25 @@ __export(models_exports, {
1304
1517
  InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
1305
1518
  InvoiceStatusToJSON: () => InvoiceStatusToJSON,
1306
1519
  InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
1520
+ MetricPeriod: () => MetricPeriod,
1521
+ MetricPeriodFromJSON: () => MetricPeriodFromJSON2,
1522
+ MetricPeriodFromJSONTyped: () => MetricPeriodFromJSONTyped7,
1523
+ MetricPeriodMonthReset: () => MetricPeriodMonthReset,
1524
+ MetricPeriodMonthResetFromJSON: () => MetricPeriodMonthResetFromJSON2,
1525
+ MetricPeriodMonthResetFromJSONTyped: () => MetricPeriodMonthResetFromJSONTyped6,
1526
+ MetricPeriodMonthResetToJSON: () => MetricPeriodMonthResetToJSON2,
1527
+ MetricPeriodMonthResetToJSONTyped: () => MetricPeriodMonthResetToJSONTyped5,
1528
+ MetricPeriodToJSON: () => MetricPeriodToJSON2,
1529
+ MetricPeriodToJSONTyped: () => MetricPeriodToJSONTyped6,
1307
1530
  PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
1308
1531
  PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
1309
1532
  PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
1310
1533
  PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
1534
+ PlanCreditGrantScaling: () => PlanCreditGrantScaling,
1535
+ PlanCreditGrantScalingFromJSON: () => PlanCreditGrantScalingFromJSON2,
1536
+ PlanCreditGrantScalingFromJSONTyped: () => PlanCreditGrantScalingFromJSONTyped3,
1537
+ PlanCreditGrantScalingToJSON: () => PlanCreditGrantScalingToJSON2,
1538
+ PlanCreditGrantScalingToJSONTyped: () => PlanCreditGrantScalingToJSONTyped3,
1311
1539
  SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
1312
1540
  SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
1313
1541
  SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
@@ -1321,22 +1549,53 @@ __export(models_exports, {
1321
1549
  UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
1322
1550
  UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
1323
1551
  instanceOfApiError: () => instanceOfApiError,
1552
+ instanceOfBillingCreditGrantReason: () => instanceOfBillingCreditGrantReason,
1553
+ instanceOfBillingPlanCreditGrantResetCadence: () => instanceOfBillingPlanCreditGrantResetCadence,
1554
+ instanceOfBillingPriceScheme: () => instanceOfBillingPriceScheme,
1555
+ instanceOfBillingProductPriceInterval: () => instanceOfBillingProductPriceInterval,
1324
1556
  instanceOfBillingProviderType: () => instanceOfBillingProviderType,
1557
+ instanceOfBillingTiersMode: () => instanceOfBillingTiersMode,
1558
+ instanceOfCatalogCreditGrantResponseData: () => instanceOfCatalogCreditGrantResponseData,
1559
+ instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
1560
+ instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
1561
+ instanceOfCompanyCreditBalanceResponseData: () => instanceOfCompanyCreditBalanceResponseData,
1562
+ instanceOfCompanyCreditBalancesResponseData: () => instanceOfCompanyCreditBalancesResponseData,
1563
+ instanceOfCompanyCreditCompositionResponseData: () => instanceOfCompanyCreditCompositionResponseData,
1564
+ instanceOfCompanyCreditGrantResponseData: () => instanceOfCompanyCreditGrantResponseData,
1565
+ instanceOfCompanyCreditUserUsageResponseData: () => instanceOfCompanyCreditUserUsageResponseData,
1566
+ instanceOfCompanyCreditUserUsageRowResponseData: () => instanceOfCompanyCreditUserUsageRowResponseData,
1325
1567
  instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
1568
+ instanceOfCompanyFeatureUsageListResponseData: () => instanceOfCompanyFeatureUsageListResponseData,
1569
+ instanceOfCompanyFeatureUsageResponseData: () => instanceOfCompanyFeatureUsageResponseData,
1570
+ instanceOfCompanyFeatureUserUsageResponseData: () => instanceOfCompanyFeatureUserUsageResponseData,
1326
1571
  instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
1327
1572
  instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
1328
1573
  instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
1329
1574
  instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
1330
1575
  instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
1576
+ instanceOfCompanyUserUsageResponseData: () => instanceOfCompanyUserUsageResponseData,
1331
1577
  instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
1332
1578
  instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
1333
1579
  instanceOfDeleteResponse: () => instanceOfDeleteResponse,
1580
+ instanceOfEntitlementPriceBehavior: () => instanceOfEntitlementPriceBehavior,
1581
+ instanceOfEntitlementType: () => instanceOfEntitlementType,
1582
+ instanceOfEntitlementValueType: () => instanceOfEntitlementValueType,
1583
+ instanceOfFeatureType: () => instanceOfFeatureType,
1584
+ instanceOfGetCompanyCreditBalancesResponse: () => instanceOfGetCompanyCreditBalancesResponse,
1585
+ instanceOfGetCompanyCreditUserUsageParams: () => instanceOfGetCompanyCreditUserUsageParams,
1586
+ instanceOfGetCompanyCreditUserUsageResponse: () => instanceOfGetCompanyCreditUserUsageResponse,
1587
+ instanceOfGetCompanyFeatureUsageResponse: () => instanceOfGetCompanyFeatureUsageResponse,
1588
+ instanceOfGetCompanyFeatureUserUsageParams: () => instanceOfGetCompanyFeatureUserUsageParams,
1589
+ instanceOfGetCompanyFeatureUserUsageResponse: () => instanceOfGetCompanyFeatureUserUsageResponse,
1334
1590
  instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
1335
1591
  instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
1336
1592
  instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
1337
1593
  instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
1338
1594
  instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
1595
+ instanceOfMetricPeriod: () => instanceOfMetricPeriod,
1596
+ instanceOfMetricPeriodMonthReset: () => instanceOfMetricPeriodMonthReset,
1339
1597
  instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
1598
+ instanceOfPlanCreditGrantScaling: () => instanceOfPlanCreditGrantScaling,
1340
1599
  instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
1341
1600
  instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
1342
1601
  instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
@@ -1367,6 +1626,126 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
1367
1626
  error: value["error"]
1368
1627
  };
1369
1628
  }
1629
+ var BillingCreditGrantReason = {
1630
+ Adjustment: "adjustment",
1631
+ BillingCreditAutoTopup: "billing_credit_auto_topup",
1632
+ Free: "free",
1633
+ Plan: "plan",
1634
+ PostpaidForgiven: "postpaid_forgiven",
1635
+ PostpaidOverdraft: "postpaid_overdraft",
1636
+ PostpaidSettlement: "postpaid_settlement",
1637
+ Purchased: "purchased",
1638
+ Rollover: "rollover"
1639
+ };
1640
+ function instanceOfBillingCreditGrantReason(value) {
1641
+ for (const key in BillingCreditGrantReason) {
1642
+ if (Object.prototype.hasOwnProperty.call(BillingCreditGrantReason, key)) {
1643
+ if (BillingCreditGrantReason[key] === value) {
1644
+ return true;
1645
+ }
1646
+ }
1647
+ }
1648
+ return false;
1649
+ }
1650
+ function BillingCreditGrantReasonFromJSON(json) {
1651
+ return BillingCreditGrantReasonFromJSONTyped(json, false);
1652
+ }
1653
+ function BillingCreditGrantReasonFromJSONTyped(json, ignoreDiscriminator) {
1654
+ return json;
1655
+ }
1656
+ function BillingCreditGrantReasonToJSON(value) {
1657
+ return value;
1658
+ }
1659
+ function BillingCreditGrantReasonToJSONTyped(value, ignoreDiscriminator) {
1660
+ return value;
1661
+ }
1662
+ var BillingPlanCreditGrantResetCadence = {
1663
+ Daily: "daily",
1664
+ Every6Months: "every_6_months",
1665
+ Monthly: "monthly",
1666
+ Quarterly: "quarterly",
1667
+ Weekly: "weekly",
1668
+ Yearly: "yearly"
1669
+ };
1670
+ function instanceOfBillingPlanCreditGrantResetCadence(value) {
1671
+ for (const key in BillingPlanCreditGrantResetCadence) {
1672
+ if (Object.prototype.hasOwnProperty.call(
1673
+ BillingPlanCreditGrantResetCadence,
1674
+ key
1675
+ )) {
1676
+ if (BillingPlanCreditGrantResetCadence[key] === value) {
1677
+ return true;
1678
+ }
1679
+ }
1680
+ }
1681
+ return false;
1682
+ }
1683
+ function BillingPlanCreditGrantResetCadenceFromJSON2(json) {
1684
+ return BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, false);
1685
+ }
1686
+ function BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, ignoreDiscriminator) {
1687
+ return json;
1688
+ }
1689
+ function BillingPlanCreditGrantResetCadenceToJSON2(value) {
1690
+ return value;
1691
+ }
1692
+ function BillingPlanCreditGrantResetCadenceToJSONTyped3(value, ignoreDiscriminator) {
1693
+ return value;
1694
+ }
1695
+ var BillingPriceScheme = {
1696
+ PerUnit: "per_unit",
1697
+ Tiered: "tiered"
1698
+ };
1699
+ function instanceOfBillingPriceScheme(value) {
1700
+ for (const key in BillingPriceScheme) {
1701
+ if (Object.prototype.hasOwnProperty.call(BillingPriceScheme, key)) {
1702
+ if (BillingPriceScheme[key] === value) {
1703
+ return true;
1704
+ }
1705
+ }
1706
+ }
1707
+ return false;
1708
+ }
1709
+ function BillingPriceSchemeFromJSON2(json) {
1710
+ return BillingPriceSchemeFromJSONTyped4(json, false);
1711
+ }
1712
+ function BillingPriceSchemeFromJSONTyped4(json, ignoreDiscriminator) {
1713
+ return json;
1714
+ }
1715
+ function BillingPriceSchemeToJSON2(value) {
1716
+ return value;
1717
+ }
1718
+ function BillingPriceSchemeToJSONTyped4(value, ignoreDiscriminator) {
1719
+ return value;
1720
+ }
1721
+ var BillingProductPriceInterval = {
1722
+ Day: "day",
1723
+ Month: "month",
1724
+ OneTime: "one-time",
1725
+ Year: "year"
1726
+ };
1727
+ function instanceOfBillingProductPriceInterval(value) {
1728
+ for (const key in BillingProductPriceInterval) {
1729
+ if (Object.prototype.hasOwnProperty.call(BillingProductPriceInterval, key)) {
1730
+ if (BillingProductPriceInterval[key] === value) {
1731
+ return true;
1732
+ }
1733
+ }
1734
+ }
1735
+ return false;
1736
+ }
1737
+ function BillingProductPriceIntervalFromJSON2(json) {
1738
+ return BillingProductPriceIntervalFromJSONTyped4(json, false);
1739
+ }
1740
+ function BillingProductPriceIntervalFromJSONTyped4(json, ignoreDiscriminator) {
1741
+ return json;
1742
+ }
1743
+ function BillingProductPriceIntervalToJSON2(value) {
1744
+ return value;
1745
+ }
1746
+ function BillingProductPriceIntervalToJSONTyped4(value, ignoreDiscriminator) {
1747
+ return value;
1748
+ }
1370
1749
  var BillingProviderType = {
1371
1750
  Metronome: "metronome",
1372
1751
  Orb: "orb",
@@ -1395,44 +1774,926 @@ function BillingProviderTypeToJSON2(value) {
1395
1774
  function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
1396
1775
  return value;
1397
1776
  }
1777
+ var BillingTiersMode = {
1778
+ Graduated: "graduated",
1779
+ Volume: "volume"
1780
+ };
1781
+ function instanceOfBillingTiersMode(value) {
1782
+ for (const key in BillingTiersMode) {
1783
+ if (Object.prototype.hasOwnProperty.call(BillingTiersMode, key)) {
1784
+ if (BillingTiersMode[key] === value) {
1785
+ return true;
1786
+ }
1787
+ }
1788
+ }
1789
+ return false;
1790
+ }
1791
+ function BillingTiersModeFromJSON2(json) {
1792
+ return BillingTiersModeFromJSONTyped4(json, false);
1793
+ }
1794
+ function BillingTiersModeFromJSONTyped4(json, ignoreDiscriminator) {
1795
+ return json;
1796
+ }
1797
+ function BillingTiersModeToJSON2(value) {
1798
+ return value;
1799
+ }
1800
+ function BillingTiersModeToJSONTyped4(value, ignoreDiscriminator) {
1801
+ return value;
1802
+ }
1803
+ var PlanCreditGrantScaling = {
1804
+ Fixed: "fixed",
1805
+ PerLicense: "per_license"
1806
+ };
1807
+ function instanceOfPlanCreditGrantScaling(value) {
1808
+ for (const key in PlanCreditGrantScaling) {
1809
+ if (Object.prototype.hasOwnProperty.call(PlanCreditGrantScaling, key)) {
1810
+ if (PlanCreditGrantScaling[key] === value) {
1811
+ return true;
1812
+ }
1813
+ }
1814
+ }
1815
+ return false;
1816
+ }
1817
+ function PlanCreditGrantScalingFromJSON2(json) {
1818
+ return PlanCreditGrantScalingFromJSONTyped3(json, false);
1819
+ }
1820
+ function PlanCreditGrantScalingFromJSONTyped3(json, ignoreDiscriminator) {
1821
+ return json;
1822
+ }
1823
+ function PlanCreditGrantScalingToJSON2(value) {
1824
+ return value;
1825
+ }
1826
+ function PlanCreditGrantScalingToJSONTyped3(value, ignoreDiscriminator) {
1827
+ return value;
1828
+ }
1829
+ function instanceOfCatalogCreditGrantResponseData(value) {
1830
+ if (!("companyCreditAmount" in value) || value["companyCreditAmount"] === void 0)
1831
+ return false;
1832
+ if (!("creditAmount" in value) || value["creditAmount"] === void 0)
1833
+ return false;
1834
+ if (!("creditId" in value) || value["creditId"] === void 0) return false;
1835
+ if (!("creditName" in value) || value["creditName"] === void 0)
1836
+ return false;
1837
+ if (!("id" in value) || value["id"] === void 0) return false;
1838
+ if (!("scaling" in value) || value["scaling"] === void 0) return false;
1839
+ return true;
1840
+ }
1841
+ function CatalogCreditGrantResponseDataFromJSON(json) {
1842
+ return CatalogCreditGrantResponseDataFromJSONTyped(json, false);
1843
+ }
1844
+ function CatalogCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1845
+ if (json == null) {
1846
+ return json;
1847
+ }
1848
+ return {
1849
+ companyCreditAmount: json["company_credit_amount"],
1850
+ creditAmount: json["credit_amount"],
1851
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
1852
+ creditId: json["credit_id"],
1853
+ creditName: json["credit_name"],
1854
+ creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
1855
+ creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
1856
+ id: json["id"],
1857
+ licenseId: json["license_id"] == null ? void 0 : json["license_id"],
1858
+ resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
1859
+ scaling: PlanCreditGrantScalingFromJSON2(json["scaling"])
1860
+ };
1861
+ }
1862
+ function CatalogCreditGrantResponseDataToJSON(json) {
1863
+ return CatalogCreditGrantResponseDataToJSONTyped(json, false);
1864
+ }
1865
+ function CatalogCreditGrantResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1866
+ if (value == null) {
1867
+ return value;
1868
+ }
1869
+ return {
1870
+ company_credit_amount: value["companyCreditAmount"],
1871
+ credit_amount: value["creditAmount"],
1872
+ credit_icon: value["creditIcon"],
1873
+ credit_id: value["creditId"],
1874
+ credit_name: value["creditName"],
1875
+ credit_plural_name: value["creditPluralName"],
1876
+ credit_singular_name: value["creditSingularName"],
1877
+ id: value["id"],
1878
+ license_id: value["licenseId"],
1879
+ reset_cadence: BillingPlanCreditGrantResetCadenceToJSON2(
1880
+ value["resetCadence"]
1881
+ ),
1882
+ scaling: PlanCreditGrantScalingToJSON2(value["scaling"])
1883
+ };
1884
+ }
1885
+ function instanceOfCatalogPriceTierResponseData(value) {
1886
+ if (!("from" in value) || value["from"] === void 0) return false;
1887
+ return true;
1888
+ }
1889
+ function CatalogPriceTierResponseDataFromJSON(json) {
1890
+ return CatalogPriceTierResponseDataFromJSONTyped(json, false);
1891
+ }
1892
+ function CatalogPriceTierResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1893
+ if (json == null) {
1894
+ return json;
1895
+ }
1896
+ return {
1897
+ flatPrice: json["flat_price"] == null ? void 0 : json["flat_price"],
1898
+ from: json["from"],
1899
+ perUnitPrice: json["per_unit_price"] == null ? void 0 : json["per_unit_price"],
1900
+ perUnitPriceDecimal: json["per_unit_price_decimal"] == null ? void 0 : json["per_unit_price_decimal"],
1901
+ to: json["to"] == null ? void 0 : json["to"]
1902
+ };
1903
+ }
1904
+ function CatalogPriceTierResponseDataToJSON(json) {
1905
+ return CatalogPriceTierResponseDataToJSONTyped(json, false);
1906
+ }
1907
+ function CatalogPriceTierResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1908
+ if (value == null) {
1909
+ return value;
1910
+ }
1911
+ return {
1912
+ flat_price: value["flatPrice"],
1913
+ from: value["from"],
1914
+ per_unit_price: value["perUnitPrice"],
1915
+ per_unit_price_decimal: value["perUnitPriceDecimal"],
1916
+ to: value["to"]
1917
+ };
1918
+ }
1919
+ function instanceOfCatalogPriceResponseData(value) {
1920
+ if (!("currency" in value) || value["currency"] === void 0) return false;
1921
+ if (!("id" in value) || value["id"] === void 0) return false;
1922
+ if (!("interval" in value) || value["interval"] === void 0) return false;
1923
+ if (!("intervalCount" in value) || value["intervalCount"] === void 0)
1924
+ return false;
1925
+ if (!("packageSize" in value) || value["packageSize"] === void 0)
1926
+ return false;
1927
+ if (!("price" in value) || value["price"] === void 0) return false;
1928
+ if (!("priceTiers" in value) || value["priceTiers"] === void 0)
1929
+ return false;
1930
+ if (!("scheme" in value) || value["scheme"] === void 0) return false;
1931
+ return true;
1932
+ }
1933
+ function CatalogPriceResponseDataFromJSON(json) {
1934
+ return CatalogPriceResponseDataFromJSONTyped(json, false);
1935
+ }
1936
+ function CatalogPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1937
+ if (json == null) {
1938
+ return json;
1939
+ }
1940
+ return {
1941
+ currency: json["currency"],
1942
+ id: json["id"],
1943
+ interval: BillingProductPriceIntervalFromJSON2(json["interval"]),
1944
+ intervalCount: json["interval_count"],
1945
+ overageUnitPriceDecimal: json["overage_unit_price_decimal"] == null ? void 0 : json["overage_unit_price_decimal"],
1946
+ packageSize: json["package_size"],
1947
+ price: json["price"],
1948
+ priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
1949
+ priceTiers: json["price_tiers"].map(
1950
+ CatalogPriceTierResponseDataFromJSON
1951
+ ),
1952
+ scheme: BillingPriceSchemeFromJSON2(json["scheme"]),
1953
+ tiersMode: json["tiers_mode"] == null ? void 0 : BillingTiersModeFromJSON2(json["tiers_mode"])
1954
+ };
1955
+ }
1956
+ function CatalogPriceResponseDataToJSON(json) {
1957
+ return CatalogPriceResponseDataToJSONTyped(json, false);
1958
+ }
1959
+ function CatalogPriceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1960
+ if (value == null) {
1961
+ return value;
1962
+ }
1963
+ return {
1964
+ currency: value["currency"],
1965
+ id: value["id"],
1966
+ interval: BillingProductPriceIntervalToJSON2(value["interval"]),
1967
+ interval_count: value["intervalCount"],
1968
+ overage_unit_price_decimal: value["overageUnitPriceDecimal"],
1969
+ package_size: value["packageSize"],
1970
+ price: value["price"],
1971
+ price_decimal: value["priceDecimal"],
1972
+ price_tiers: value["priceTiers"].map(
1973
+ CatalogPriceTierResponseDataToJSON
1974
+ ),
1975
+ scheme: BillingPriceSchemeToJSON2(value["scheme"]),
1976
+ tiers_mode: BillingTiersModeToJSON2(value["tiersMode"])
1977
+ };
1978
+ }
1979
+ function instanceOfCompanyCreditGrantResponseData(value) {
1980
+ if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
1981
+ if (!("grantReason" in value) || value["grantReason"] === void 0)
1982
+ return false;
1983
+ if (!("id" in value) || value["id"] === void 0) return false;
1984
+ if (!("quantity" in value) || value["quantity"] === void 0) return false;
1985
+ if (!("quantityRemaining" in value) || value["quantityRemaining"] === void 0)
1986
+ return false;
1987
+ if (!("quantityUsed" in value) || value["quantityUsed"] === void 0)
1988
+ return false;
1989
+ return true;
1990
+ }
1991
+ function CompanyCreditGrantResponseDataFromJSON(json) {
1992
+ return CompanyCreditGrantResponseDataFromJSONTyped(json, false);
1993
+ }
1994
+ function CompanyCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1995
+ if (json == null) {
1996
+ return json;
1997
+ }
1998
+ return {
1999
+ bundleId: json["bundle_id"] == null ? void 0 : json["bundle_id"],
2000
+ bundleName: json["bundle_name"] == null ? void 0 : json["bundle_name"],
2001
+ createdAt: new Date(json["created_at"]),
2002
+ expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
2003
+ grantReason: BillingCreditGrantReasonFromJSON(json["grant_reason"]),
2004
+ id: json["id"],
2005
+ planId: json["plan_id"] == null ? void 0 : json["plan_id"],
2006
+ planName: json["plan_name"] == null ? void 0 : json["plan_name"],
2007
+ quantity: json["quantity"],
2008
+ quantityRemaining: json["quantity_remaining"],
2009
+ quantityUsed: json["quantity_used"],
2010
+ renewalPeriod: json["renewal_period"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["renewal_period"]),
2011
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
2012
+ validFrom: json["valid_from"] == null ? void 0 : new Date(json["valid_from"])
2013
+ };
2014
+ }
2015
+ function CompanyCreditGrantResponseDataToJSON(json) {
2016
+ return CompanyCreditGrantResponseDataToJSONTyped(json, false);
2017
+ }
2018
+ function CompanyCreditGrantResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2019
+ if (value == null) {
2020
+ return value;
2021
+ }
2022
+ return {
2023
+ bundle_id: value["bundleId"],
2024
+ bundle_name: value["bundleName"],
2025
+ created_at: value["createdAt"].toISOString(),
2026
+ expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
2027
+ grant_reason: BillingCreditGrantReasonToJSON(value["grantReason"]),
2028
+ id: value["id"],
2029
+ plan_id: value["planId"],
2030
+ plan_name: value["planName"],
2031
+ quantity: value["quantity"],
2032
+ quantity_remaining: value["quantityRemaining"],
2033
+ quantity_used: value["quantityUsed"],
2034
+ renewal_period: BillingPlanCreditGrantResetCadenceToJSON2(
2035
+ value["renewalPeriod"]
2036
+ ),
2037
+ resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
2038
+ valid_from: value["validFrom"] == null ? void 0 : value["validFrom"].toISOString()
2039
+ };
2040
+ }
2041
+ function instanceOfCompanyCreditCompositionResponseData(value) {
2042
+ if (!("fixedQuantity" in value) || value["fixedQuantity"] === void 0)
2043
+ return false;
2044
+ if (!("licenseName" in value) || value["licenseName"] === void 0)
2045
+ return false;
2046
+ if (!("licenseQuantity" in value) || value["licenseQuantity"] === void 0)
2047
+ return false;
2048
+ if (!("perLicenseAmount" in value) || value["perLicenseAmount"] === void 0)
2049
+ return false;
2050
+ if (!("period" in value) || value["period"] === void 0) return false;
2051
+ if (!("total" in value) || value["total"] === void 0) return false;
2052
+ return true;
2053
+ }
2054
+ function CompanyCreditCompositionResponseDataFromJSON(json) {
2055
+ return CompanyCreditCompositionResponseDataFromJSONTyped(json, false);
2056
+ }
2057
+ function CompanyCreditCompositionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2058
+ if (json == null) {
2059
+ return json;
2060
+ }
2061
+ return {
2062
+ fixedQuantity: json["fixed_quantity"],
2063
+ licenseId: json["license_id"] == null ? void 0 : json["license_id"],
2064
+ licenseName: json["license_name"],
2065
+ licensePluralName: json["license_plural_name"] == null ? void 0 : json["license_plural_name"],
2066
+ licenseQuantity: json["license_quantity"],
2067
+ licenseSingularName: json["license_singular_name"] == null ? void 0 : json["license_singular_name"],
2068
+ perLicenseAmount: json["per_license_amount"],
2069
+ period: json["period"],
2070
+ renewsAt: json["renews_at"] == null ? void 0 : new Date(json["renews_at"]),
2071
+ total: json["total"]
2072
+ };
2073
+ }
2074
+ function CompanyCreditCompositionResponseDataToJSON(json) {
2075
+ return CompanyCreditCompositionResponseDataToJSONTyped(json, false);
2076
+ }
2077
+ function CompanyCreditCompositionResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2078
+ if (value == null) {
2079
+ return value;
2080
+ }
2081
+ return {
2082
+ fixed_quantity: value["fixedQuantity"],
2083
+ license_id: value["licenseId"],
2084
+ license_name: value["licenseName"],
2085
+ license_plural_name: value["licensePluralName"],
2086
+ license_quantity: value["licenseQuantity"],
2087
+ license_singular_name: value["licenseSingularName"],
2088
+ per_license_amount: value["perLicenseAmount"],
2089
+ period: value["period"],
2090
+ renews_at: value["renewsAt"] == null ? void 0 : value["renewsAt"].toISOString(),
2091
+ total: value["total"]
2092
+ };
2093
+ }
2094
+ function instanceOfCompanyCreditBalanceResponseData(value) {
2095
+ if (!("creditDescription" in value) || value["creditDescription"] === void 0)
2096
+ return false;
2097
+ if (!("creditId" in value) || value["creditId"] === void 0) return false;
2098
+ if (!("creditName" in value) || value["creditName"] === void 0)
2099
+ return false;
2100
+ if (!("grants" in value) || value["grants"] === void 0) return false;
2101
+ if (!("purchasable" in value) || value["purchasable"] === void 0)
2102
+ return false;
2103
+ if (!("remaining" in value) || value["remaining"] === void 0) return false;
2104
+ if (!("total" in value) || value["total"] === void 0) return false;
2105
+ if (!("used" in value) || value["used"] === void 0) return false;
2106
+ return true;
2107
+ }
2108
+ function CompanyCreditBalanceResponseDataFromJSON(json) {
2109
+ return CompanyCreditBalanceResponseDataFromJSONTyped(json, false);
2110
+ }
2111
+ function CompanyCreditBalanceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2112
+ if (json == null) {
2113
+ return json;
2114
+ }
2115
+ return {
2116
+ composition: json["composition"] == null ? void 0 : CompanyCreditCompositionResponseDataFromJSON(json["composition"]),
2117
+ creditDescription: json["credit_description"],
2118
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
2119
+ creditId: json["credit_id"],
2120
+ creditName: json["credit_name"],
2121
+ creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
2122
+ creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
2123
+ expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
2124
+ grants: json["grants"].map(
2125
+ CompanyCreditGrantResponseDataFromJSON
2126
+ ),
2127
+ purchasable: json["purchasable"],
2128
+ remaining: json["remaining"],
2129
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
2130
+ total: json["total"],
2131
+ used: json["used"]
2132
+ };
2133
+ }
2134
+ function CompanyCreditBalanceResponseDataToJSON(json) {
2135
+ return CompanyCreditBalanceResponseDataToJSONTyped(json, false);
2136
+ }
2137
+ function CompanyCreditBalanceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2138
+ if (value == null) {
2139
+ return value;
2140
+ }
2141
+ return {
2142
+ composition: CompanyCreditCompositionResponseDataToJSON(
2143
+ value["composition"]
2144
+ ),
2145
+ credit_description: value["creditDescription"],
2146
+ credit_icon: value["creditIcon"],
2147
+ credit_id: value["creditId"],
2148
+ credit_name: value["creditName"],
2149
+ credit_plural_name: value["creditPluralName"],
2150
+ credit_singular_name: value["creditSingularName"],
2151
+ expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
2152
+ grants: value["grants"].map(
2153
+ CompanyCreditGrantResponseDataToJSON
2154
+ ),
2155
+ purchasable: value["purchasable"],
2156
+ remaining: value["remaining"],
2157
+ resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
2158
+ total: value["total"],
2159
+ used: value["used"]
2160
+ };
2161
+ }
2162
+ function instanceOfCompanyCreditBalancesResponseData(value) {
2163
+ if (!("balances" in value) || value["balances"] === void 0) return false;
2164
+ if (!("count" in value) || value["count"] === void 0) return false;
2165
+ return true;
2166
+ }
2167
+ function CompanyCreditBalancesResponseDataFromJSON(json) {
2168
+ return CompanyCreditBalancesResponseDataFromJSONTyped(json, false);
2169
+ }
2170
+ function CompanyCreditBalancesResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2171
+ if (json == null) {
2172
+ return json;
2173
+ }
2174
+ return {
2175
+ balances: json["balances"].map(
2176
+ CompanyCreditBalanceResponseDataFromJSON
2177
+ ),
2178
+ count: json["count"]
2179
+ };
2180
+ }
2181
+ function CompanyCreditBalancesResponseDataToJSON(json) {
2182
+ return CompanyCreditBalancesResponseDataToJSONTyped(json, false);
2183
+ }
2184
+ function CompanyCreditBalancesResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2185
+ if (value == null) {
2186
+ return value;
2187
+ }
2188
+ return {
2189
+ balances: value["balances"].map(
2190
+ CompanyCreditBalanceResponseDataToJSON
2191
+ ),
2192
+ count: value["count"]
2193
+ };
2194
+ }
2195
+ function instanceOfCompanyCreditUserUsageRowResponseData(value) {
2196
+ if (!("share" in value) || value["share"] === void 0) return false;
2197
+ if (!("used" in value) || value["used"] === void 0) return false;
2198
+ if (!("userId" in value) || value["userId"] === void 0) return false;
2199
+ return true;
2200
+ }
2201
+ function CompanyCreditUserUsageRowResponseDataFromJSON(json) {
2202
+ return CompanyCreditUserUsageRowResponseDataFromJSONTyped(json, false);
2203
+ }
2204
+ function CompanyCreditUserUsageRowResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2205
+ if (json == null) {
2206
+ return json;
2207
+ }
2208
+ return {
2209
+ name: json["name"] == null ? void 0 : json["name"],
2210
+ share: json["share"],
2211
+ used: json["used"],
2212
+ userId: json["user_id"]
2213
+ };
2214
+ }
2215
+ function CompanyCreditUserUsageRowResponseDataToJSON(json) {
2216
+ return CompanyCreditUserUsageRowResponseDataToJSONTyped(json, false);
2217
+ }
2218
+ function CompanyCreditUserUsageRowResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2219
+ if (value == null) {
2220
+ return value;
2221
+ }
2222
+ return {
2223
+ name: value["name"],
2224
+ share: value["share"],
2225
+ used: value["used"],
2226
+ user_id: value["userId"]
2227
+ };
2228
+ }
2229
+ function instanceOfCompanyCreditUserUsageResponseData(value) {
2230
+ if (!("count" in value) || value["count"] === void 0) return false;
2231
+ if (!("total" in value) || value["total"] === void 0) return false;
2232
+ if (!("users" in value) || value["users"] === void 0) return false;
2233
+ return true;
2234
+ }
2235
+ function CompanyCreditUserUsageResponseDataFromJSON(json) {
2236
+ return CompanyCreditUserUsageResponseDataFromJSONTyped(json, false);
2237
+ }
2238
+ function CompanyCreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2239
+ if (json == null) {
2240
+ return json;
2241
+ }
2242
+ return {
2243
+ count: json["count"],
2244
+ endTime: json["end_time"] == null ? void 0 : new Date(json["end_time"]),
2245
+ startTime: json["start_time"] == null ? void 0 : new Date(json["start_time"]),
2246
+ total: json["total"],
2247
+ unattributed: json["unattributed"] == null ? void 0 : json["unattributed"],
2248
+ users: json["users"].map(
2249
+ CompanyCreditUserUsageRowResponseDataFromJSON
2250
+ )
2251
+ };
2252
+ }
2253
+ function CompanyCreditUserUsageResponseDataToJSON(json) {
2254
+ return CompanyCreditUserUsageResponseDataToJSONTyped(json, false);
2255
+ }
2256
+ function CompanyCreditUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2257
+ if (value == null) {
2258
+ return value;
2259
+ }
2260
+ return {
2261
+ count: value["count"],
2262
+ end_time: value["endTime"] == null ? void 0 : value["endTime"].toISOString(),
2263
+ start_time: value["startTime"] == null ? void 0 : value["startTime"].toISOString(),
2264
+ total: value["total"],
2265
+ unattributed: value["unattributed"],
2266
+ users: value["users"].map(
2267
+ CompanyCreditUserUsageRowResponseDataToJSON
2268
+ )
2269
+ };
2270
+ }
1398
2271
  function instanceOfCompanyDiscountResponseData(value) {
1399
2272
  if (!("couponName" in value) || value["couponName"] === void 0)
1400
2273
  return false;
1401
2274
  if (!("duration" in value) || value["duration"] === void 0) return false;
1402
2275
  return true;
1403
2276
  }
1404
- function CompanyDiscountResponseDataFromJSON(json) {
1405
- return CompanyDiscountResponseDataFromJSONTyped(json, false);
2277
+ function CompanyDiscountResponseDataFromJSON(json) {
2278
+ return CompanyDiscountResponseDataFromJSONTyped(json, false);
2279
+ }
2280
+ function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2281
+ if (json == null) {
2282
+ return json;
2283
+ }
2284
+ return {
2285
+ amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
2286
+ couponName: json["coupon_name"],
2287
+ currency: json["currency"] == null ? void 0 : json["currency"],
2288
+ customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
2289
+ duration: json["duration"],
2290
+ durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
2291
+ percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
2292
+ };
2293
+ }
2294
+ function CompanyDiscountResponseDataToJSON(json) {
2295
+ return CompanyDiscountResponseDataToJSONTyped(json, false);
2296
+ }
2297
+ function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2298
+ if (value == null) {
2299
+ return value;
2300
+ }
2301
+ return {
2302
+ amount_off: value["amountOff"],
2303
+ coupon_name: value["couponName"],
2304
+ currency: value["currency"],
2305
+ customer_facing_code: value["customerFacingCode"],
2306
+ duration: value["duration"],
2307
+ duration_in_months: value["durationInMonths"],
2308
+ percent_off: value["percentOff"]
2309
+ };
2310
+ }
2311
+ var EntitlementValueType = {
2312
+ Boolean: "boolean",
2313
+ Credit: "credit",
2314
+ Numeric: "numeric",
2315
+ Trait: "trait",
2316
+ Unknown: "unknown",
2317
+ Unlimited: "unlimited"
2318
+ };
2319
+ function instanceOfEntitlementValueType(value) {
2320
+ for (const key in EntitlementValueType) {
2321
+ if (Object.prototype.hasOwnProperty.call(EntitlementValueType, key)) {
2322
+ if (EntitlementValueType[key] === value) {
2323
+ return true;
2324
+ }
2325
+ }
2326
+ }
2327
+ return false;
2328
+ }
2329
+ function EntitlementValueTypeFromJSON2(json) {
2330
+ return EntitlementValueTypeFromJSONTyped4(json, false);
2331
+ }
2332
+ function EntitlementValueTypeFromJSONTyped4(json, ignoreDiscriminator) {
2333
+ return json;
2334
+ }
2335
+ function EntitlementValueTypeToJSON2(value) {
2336
+ return value;
2337
+ }
2338
+ function EntitlementValueTypeToJSONTyped3(value, ignoreDiscriminator) {
2339
+ return value;
2340
+ }
2341
+ var FeatureType = {
2342
+ Boolean: "boolean",
2343
+ Event: "event",
2344
+ License: "license",
2345
+ Trait: "trait"
2346
+ };
2347
+ function instanceOfFeatureType(value) {
2348
+ for (const key in FeatureType) {
2349
+ if (Object.prototype.hasOwnProperty.call(FeatureType, key)) {
2350
+ if (FeatureType[key] === value) {
2351
+ return true;
2352
+ }
2353
+ }
2354
+ }
2355
+ return false;
2356
+ }
2357
+ function FeatureTypeFromJSON2(json) {
2358
+ return FeatureTypeFromJSONTyped3(json, false);
2359
+ }
2360
+ function FeatureTypeFromJSONTyped3(json, ignoreDiscriminator) {
2361
+ return json;
2362
+ }
2363
+ function FeatureTypeToJSON2(value) {
2364
+ return value;
2365
+ }
2366
+ function FeatureTypeToJSONTyped3(value, ignoreDiscriminator) {
2367
+ return value;
2368
+ }
2369
+ var MetricPeriodMonthReset = {
2370
+ BillingCycle: "billing_cycle",
2371
+ FirstOfMonth: "first_of_month"
2372
+ };
2373
+ function instanceOfMetricPeriodMonthReset(value) {
2374
+ for (const key in MetricPeriodMonthReset) {
2375
+ if (Object.prototype.hasOwnProperty.call(MetricPeriodMonthReset, key)) {
2376
+ if (MetricPeriodMonthReset[key] === value) {
2377
+ return true;
2378
+ }
2379
+ }
2380
+ }
2381
+ return false;
2382
+ }
2383
+ function MetricPeriodMonthResetFromJSON2(json) {
2384
+ return MetricPeriodMonthResetFromJSONTyped6(json, false);
2385
+ }
2386
+ function MetricPeriodMonthResetFromJSONTyped6(json, ignoreDiscriminator) {
2387
+ return json;
2388
+ }
2389
+ function MetricPeriodMonthResetToJSON2(value) {
2390
+ return value;
2391
+ }
2392
+ function MetricPeriodMonthResetToJSONTyped5(value, ignoreDiscriminator) {
2393
+ return value;
2394
+ }
2395
+ var MetricPeriod = {
2396
+ AllTime: "all_time",
2397
+ CurrentDay: "current_day",
2398
+ CurrentMonth: "current_month",
2399
+ CurrentWeek: "current_week"
2400
+ };
2401
+ function instanceOfMetricPeriod(value) {
2402
+ for (const key in MetricPeriod) {
2403
+ if (Object.prototype.hasOwnProperty.call(MetricPeriod, key)) {
2404
+ if (MetricPeriod[key] === value) {
2405
+ return true;
2406
+ }
2407
+ }
2408
+ }
2409
+ return false;
2410
+ }
2411
+ function MetricPeriodFromJSON2(json) {
2412
+ return MetricPeriodFromJSONTyped7(json, false);
2413
+ }
2414
+ function MetricPeriodFromJSONTyped7(json, ignoreDiscriminator) {
2415
+ return json;
2416
+ }
2417
+ function MetricPeriodToJSON2(value) {
2418
+ return value;
2419
+ }
2420
+ function MetricPeriodToJSONTyped6(value, ignoreDiscriminator) {
2421
+ return value;
2422
+ }
2423
+ var EntitlementPriceBehavior = {
2424
+ CreditBurndown: "credit_burndown",
2425
+ Overage: "overage",
2426
+ PayAsYouGo: "pay_as_you_go",
2427
+ PayInAdvance: "pay_in_advance",
2428
+ Tier: "tier"
2429
+ };
2430
+ function instanceOfEntitlementPriceBehavior(value) {
2431
+ for (const key in EntitlementPriceBehavior) {
2432
+ if (Object.prototype.hasOwnProperty.call(EntitlementPriceBehavior, key)) {
2433
+ if (EntitlementPriceBehavior[key] === value) {
2434
+ return true;
2435
+ }
2436
+ }
2437
+ }
2438
+ return false;
2439
+ }
2440
+ function EntitlementPriceBehaviorFromJSON2(json) {
2441
+ return EntitlementPriceBehaviorFromJSONTyped2(json, false);
2442
+ }
2443
+ function EntitlementPriceBehaviorFromJSONTyped2(json, ignoreDiscriminator) {
2444
+ return json;
2445
+ }
2446
+ function EntitlementPriceBehaviorToJSON2(value) {
2447
+ return value;
2448
+ }
2449
+ function EntitlementPriceBehaviorToJSONTyped2(value, ignoreDiscriminator) {
2450
+ return value;
2451
+ }
2452
+ var EntitlementType = {
2453
+ CompanyOverride: "company_override",
2454
+ PlanEntitlement: "plan_entitlement",
2455
+ Unknown: "unknown"
2456
+ };
2457
+ function instanceOfEntitlementType(value) {
2458
+ for (const key in EntitlementType) {
2459
+ if (Object.prototype.hasOwnProperty.call(EntitlementType, key)) {
2460
+ if (EntitlementType[key] === value) {
2461
+ return true;
2462
+ }
2463
+ }
2464
+ }
2465
+ return false;
2466
+ }
2467
+ function EntitlementTypeFromJSON(json) {
2468
+ return EntitlementTypeFromJSONTyped(json, false);
2469
+ }
2470
+ function EntitlementTypeFromJSONTyped(json, ignoreDiscriminator) {
2471
+ return json;
2472
+ }
2473
+ function EntitlementTypeToJSON(value) {
2474
+ return value;
2475
+ }
2476
+ function EntitlementTypeToJSONTyped(value, ignoreDiscriminator) {
2477
+ return value;
2478
+ }
2479
+ function instanceOfCompanyFeatureUsageResponseData(value) {
2480
+ if (!("access" in value) || value["access"] === void 0) return false;
2481
+ if (!("entitlementType" in value) || value["entitlementType"] === void 0)
2482
+ return false;
2483
+ if (!("featureDescription" in value) || value["featureDescription"] === void 0)
2484
+ return false;
2485
+ if (!("featureIcon" in value) || value["featureIcon"] === void 0)
2486
+ return false;
2487
+ if (!("featureId" in value) || value["featureId"] === void 0) return false;
2488
+ if (!("featureName" in value) || value["featureName"] === void 0)
2489
+ return false;
2490
+ if (!("featureType" in value) || value["featureType"] === void 0)
2491
+ return false;
2492
+ if (!("perLicenseCreditGrants" in value) || value["perLicenseCreditGrants"] === void 0)
2493
+ return false;
2494
+ if (!("valueType" in value) || value["valueType"] === void 0) return false;
2495
+ return true;
2496
+ }
2497
+ function CompanyFeatureUsageResponseDataFromJSON(json) {
2498
+ return CompanyFeatureUsageResponseDataFromJSONTyped(json, false);
2499
+ }
2500
+ function CompanyFeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2501
+ if (json == null) {
2502
+ return json;
2503
+ }
2504
+ return {
2505
+ access: json["access"],
2506
+ allocation: json["allocation"] == null ? void 0 : json["allocation"],
2507
+ companyOverrideId: json["company_override_id"] == null ? void 0 : json["company_override_id"],
2508
+ consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
2509
+ creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
2510
+ creditId: json["credit_id"] == null ? void 0 : json["credit_id"],
2511
+ creditName: json["credit_name"] == null ? void 0 : json["credit_name"],
2512
+ creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
2513
+ creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
2514
+ currentCost: json["current_cost"] == null ? void 0 : json["current_cost"],
2515
+ entitlementType: EntitlementTypeFromJSON(json["entitlement_type"]),
2516
+ expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
2517
+ featureDescription: json["feature_description"],
2518
+ featureIcon: json["feature_icon"],
2519
+ featureId: json["feature_id"],
2520
+ featureName: json["feature_name"],
2521
+ featurePluralName: json["feature_plural_name"] == null ? void 0 : json["feature_plural_name"],
2522
+ featureSingularName: json["feature_singular_name"] == null ? void 0 : json["feature_singular_name"],
2523
+ featureType: FeatureTypeFromJSON2(json["feature_type"]),
2524
+ licenseId: json["license_id"] == null ? void 0 : json["license_id"],
2525
+ metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON2(json["metric_period"]),
2526
+ metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON2(json["metric_period_month_reset"]),
2527
+ perLicenseCreditGrants: json["per_license_credit_grants"].map(CatalogCreditGrantResponseDataFromJSON),
2528
+ planEntitlementId: json["plan_entitlement_id"] == null ? void 0 : json["plan_entitlement_id"],
2529
+ price: json["price"] == null ? void 0 : CatalogPriceResponseDataFromJSON(json["price"]),
2530
+ priceBehavior: json["price_behavior"] == null ? void 0 : EntitlementPriceBehaviorFromJSON2(json["price_behavior"]),
2531
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
2532
+ softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
2533
+ usage: json["usage"] == null ? void 0 : json["usage"],
2534
+ valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
2535
+ valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
2536
+ valueType: EntitlementValueTypeFromJSON2(json["value_type"]),
2537
+ warningThreshold: json["warning_threshold"] == null ? void 0 : json["warning_threshold"]
2538
+ };
2539
+ }
2540
+ function CompanyFeatureUsageResponseDataToJSON(json) {
2541
+ return CompanyFeatureUsageResponseDataToJSONTyped(json, false);
2542
+ }
2543
+ function CompanyFeatureUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2544
+ if (value == null) {
2545
+ return value;
2546
+ }
2547
+ return {
2548
+ access: value["access"],
2549
+ allocation: value["allocation"],
2550
+ company_override_id: value["companyOverrideId"],
2551
+ consumption_rate: value["consumptionRate"],
2552
+ credit_icon: value["creditIcon"],
2553
+ credit_id: value["creditId"],
2554
+ credit_name: value["creditName"],
2555
+ credit_plural_name: value["creditPluralName"],
2556
+ credit_singular_name: value["creditSingularName"],
2557
+ current_cost: value["currentCost"],
2558
+ entitlement_type: EntitlementTypeToJSON(value["entitlementType"]),
2559
+ expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
2560
+ feature_description: value["featureDescription"],
2561
+ feature_icon: value["featureIcon"],
2562
+ feature_id: value["featureId"],
2563
+ feature_name: value["featureName"],
2564
+ feature_plural_name: value["featurePluralName"],
2565
+ feature_singular_name: value["featureSingularName"],
2566
+ feature_type: FeatureTypeToJSON2(value["featureType"]),
2567
+ license_id: value["licenseId"],
2568
+ metric_period: MetricPeriodToJSON2(value["metricPeriod"]),
2569
+ metric_period_month_reset: MetricPeriodMonthResetToJSON2(
2570
+ value["metricPeriodMonthReset"]
2571
+ ),
2572
+ per_license_credit_grants: value["perLicenseCreditGrants"].map(CatalogCreditGrantResponseDataToJSON),
2573
+ plan_entitlement_id: value["planEntitlementId"],
2574
+ price: CatalogPriceResponseDataToJSON(value["price"]),
2575
+ price_behavior: EntitlementPriceBehaviorToJSON2(value["priceBehavior"]),
2576
+ resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
2577
+ soft_limit: value["softLimit"],
2578
+ usage: value["usage"],
2579
+ value_bool: value["valueBool"],
2580
+ value_numeric: value["valueNumeric"],
2581
+ value_type: EntitlementValueTypeToJSON2(value["valueType"]),
2582
+ warning_threshold: value["warningThreshold"]
2583
+ };
2584
+ }
2585
+ function instanceOfCompanyFeatureUsageListResponseData(value) {
2586
+ if (!("count" in value) || value["count"] === void 0) return false;
2587
+ if (!("features" in value) || value["features"] === void 0) return false;
2588
+ return true;
2589
+ }
2590
+ function CompanyFeatureUsageListResponseDataFromJSON(json) {
2591
+ return CompanyFeatureUsageListResponseDataFromJSONTyped(json, false);
2592
+ }
2593
+ function CompanyFeatureUsageListResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2594
+ if (json == null) {
2595
+ return json;
2596
+ }
2597
+ return {
2598
+ count: json["count"],
2599
+ features: json["features"].map(
2600
+ CompanyFeatureUsageResponseDataFromJSON
2601
+ )
2602
+ };
2603
+ }
2604
+ function CompanyFeatureUsageListResponseDataToJSON(json) {
2605
+ return CompanyFeatureUsageListResponseDataToJSONTyped(json, false);
2606
+ }
2607
+ function CompanyFeatureUsageListResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2608
+ if (value == null) {
2609
+ return value;
2610
+ }
2611
+ return {
2612
+ count: value["count"],
2613
+ features: value["features"].map(
2614
+ CompanyFeatureUsageResponseDataToJSON
2615
+ )
2616
+ };
2617
+ }
2618
+ function instanceOfCompanyUserUsageResponseData(value) {
2619
+ if (!("lastSeen" in value) || value["lastSeen"] === void 0) return false;
2620
+ if (!("share" in value) || value["share"] === void 0) return false;
2621
+ if (!("usage" in value) || value["usage"] === void 0) return false;
2622
+ if (!("userId" in value) || value["userId"] === void 0) return false;
2623
+ return true;
2624
+ }
2625
+ function CompanyUserUsageResponseDataFromJSON(json) {
2626
+ return CompanyUserUsageResponseDataFromJSONTyped(json, false);
2627
+ }
2628
+ function CompanyUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2629
+ if (json == null) {
2630
+ return json;
2631
+ }
2632
+ return {
2633
+ lastSeen: new Date(json["last_seen"]),
2634
+ name: json["name"] == null ? void 0 : json["name"],
2635
+ share: json["share"],
2636
+ usage: json["usage"],
2637
+ userId: json["user_id"]
2638
+ };
2639
+ }
2640
+ function CompanyUserUsageResponseDataToJSON(json) {
2641
+ return CompanyUserUsageResponseDataToJSONTyped(json, false);
2642
+ }
2643
+ function CompanyUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2644
+ if (value == null) {
2645
+ return value;
2646
+ }
2647
+ return {
2648
+ last_seen: value["lastSeen"].toISOString(),
2649
+ name: value["name"],
2650
+ share: value["share"],
2651
+ usage: value["usage"],
2652
+ user_id: value["userId"]
2653
+ };
2654
+ }
2655
+ function instanceOfCompanyFeatureUserUsageResponseData(value) {
2656
+ if (!("count" in value) || value["count"] === void 0) return false;
2657
+ if (!("endTime" in value) || value["endTime"] === void 0) return false;
2658
+ if (!("startTime" in value) || value["startTime"] === void 0) return false;
2659
+ if (!("total" in value) || value["total"] === void 0) return false;
2660
+ if (!("users" in value) || value["users"] === void 0) return false;
2661
+ return true;
2662
+ }
2663
+ function CompanyFeatureUserUsageResponseDataFromJSON(json) {
2664
+ return CompanyFeatureUserUsageResponseDataFromJSONTyped(json, false);
1406
2665
  }
1407
- function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2666
+ function CompanyFeatureUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1408
2667
  if (json == null) {
1409
2668
  return json;
1410
2669
  }
1411
2670
  return {
1412
- amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
1413
- couponName: json["coupon_name"],
1414
- currency: json["currency"] == null ? void 0 : json["currency"],
1415
- customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
1416
- duration: json["duration"],
1417
- durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
1418
- percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
2671
+ count: json["count"],
2672
+ endTime: new Date(json["end_time"]),
2673
+ startTime: new Date(json["start_time"]),
2674
+ total: json["total"],
2675
+ unattributed: json["unattributed"] == null ? void 0 : json["unattributed"],
2676
+ users: json["users"].map(
2677
+ CompanyUserUsageResponseDataFromJSON
2678
+ )
1419
2679
  };
1420
2680
  }
1421
- function CompanyDiscountResponseDataToJSON(json) {
1422
- return CompanyDiscountResponseDataToJSONTyped(json, false);
2681
+ function CompanyFeatureUserUsageResponseDataToJSON(json) {
2682
+ return CompanyFeatureUserUsageResponseDataToJSONTyped(json, false);
1423
2683
  }
1424
- function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
2684
+ function CompanyFeatureUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
1425
2685
  if (value == null) {
1426
2686
  return value;
1427
2687
  }
1428
2688
  return {
1429
- amount_off: value["amountOff"],
1430
- coupon_name: value["couponName"],
1431
- currency: value["currency"],
1432
- customer_facing_code: value["customerFacingCode"],
1433
- duration: value["duration"],
1434
- duration_in_months: value["durationInMonths"],
1435
- percent_off: value["percentOff"]
2689
+ count: value["count"],
2690
+ end_time: value["endTime"].toISOString(),
2691
+ start_time: value["startTime"].toISOString(),
2692
+ total: value["total"],
2693
+ unattributed: value["unattributed"],
2694
+ users: value["users"].map(
2695
+ CompanyUserUsageResponseDataToJSON
2696
+ )
1436
2697
  };
1437
2698
  }
1438
2699
  var InvoiceStatus = {
@@ -1794,6 +3055,176 @@ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = fal
1794
3055
  params: value["params"]
1795
3056
  };
1796
3057
  }
3058
+ function instanceOfGetCompanyCreditBalancesResponse(value) {
3059
+ if (!("data" in value) || value["data"] === void 0) return false;
3060
+ if (!("params" in value) || value["params"] === void 0) return false;
3061
+ return true;
3062
+ }
3063
+ function GetCompanyCreditBalancesResponseFromJSON(json) {
3064
+ return GetCompanyCreditBalancesResponseFromJSONTyped(json, false);
3065
+ }
3066
+ function GetCompanyCreditBalancesResponseFromJSONTyped(json, ignoreDiscriminator) {
3067
+ if (json == null) {
3068
+ return json;
3069
+ }
3070
+ return {
3071
+ data: CompanyCreditBalancesResponseDataFromJSON(json["data"]),
3072
+ params: json["params"]
3073
+ };
3074
+ }
3075
+ function GetCompanyCreditBalancesResponseToJSON(json) {
3076
+ return GetCompanyCreditBalancesResponseToJSONTyped(json, false);
3077
+ }
3078
+ function GetCompanyCreditBalancesResponseToJSONTyped(value, ignoreDiscriminator = false) {
3079
+ if (value == null) {
3080
+ return value;
3081
+ }
3082
+ return {
3083
+ data: CompanyCreditBalancesResponseDataToJSON(value["data"]),
3084
+ params: value["params"]
3085
+ };
3086
+ }
3087
+ function instanceOfGetCompanyCreditUserUsageParams(value) {
3088
+ return true;
3089
+ }
3090
+ function GetCompanyCreditUserUsageParamsFromJSON(json) {
3091
+ return GetCompanyCreditUserUsageParamsFromJSONTyped(json, false);
3092
+ }
3093
+ function GetCompanyCreditUserUsageParamsFromJSONTyped(json, ignoreDiscriminator) {
3094
+ if (json == null) {
3095
+ return json;
3096
+ }
3097
+ return {
3098
+ limit: json["limit"] == null ? void 0 : json["limit"],
3099
+ offset: json["offset"] == null ? void 0 : json["offset"]
3100
+ };
3101
+ }
3102
+ function GetCompanyCreditUserUsageParamsToJSON(json) {
3103
+ return GetCompanyCreditUserUsageParamsToJSONTyped(json, false);
3104
+ }
3105
+ function GetCompanyCreditUserUsageParamsToJSONTyped(value, ignoreDiscriminator = false) {
3106
+ if (value == null) {
3107
+ return value;
3108
+ }
3109
+ return {
3110
+ limit: value["limit"],
3111
+ offset: value["offset"]
3112
+ };
3113
+ }
3114
+ function instanceOfGetCompanyCreditUserUsageResponse(value) {
3115
+ if (!("data" in value) || value["data"] === void 0) return false;
3116
+ if (!("params" in value) || value["params"] === void 0) return false;
3117
+ return true;
3118
+ }
3119
+ function GetCompanyCreditUserUsageResponseFromJSON(json) {
3120
+ return GetCompanyCreditUserUsageResponseFromJSONTyped(json, false);
3121
+ }
3122
+ function GetCompanyCreditUserUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
3123
+ if (json == null) {
3124
+ return json;
3125
+ }
3126
+ return {
3127
+ data: CompanyCreditUserUsageResponseDataFromJSON(json["data"]),
3128
+ params: GetCompanyCreditUserUsageParamsFromJSON(json["params"])
3129
+ };
3130
+ }
3131
+ function GetCompanyCreditUserUsageResponseToJSON(json) {
3132
+ return GetCompanyCreditUserUsageResponseToJSONTyped(json, false);
3133
+ }
3134
+ function GetCompanyCreditUserUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
3135
+ if (value == null) {
3136
+ return value;
3137
+ }
3138
+ return {
3139
+ data: CompanyCreditUserUsageResponseDataToJSON(value["data"]),
3140
+ params: GetCompanyCreditUserUsageParamsToJSON(value["params"])
3141
+ };
3142
+ }
3143
+ function instanceOfGetCompanyFeatureUsageResponse(value) {
3144
+ if (!("data" in value) || value["data"] === void 0) return false;
3145
+ if (!("params" in value) || value["params"] === void 0) return false;
3146
+ return true;
3147
+ }
3148
+ function GetCompanyFeatureUsageResponseFromJSON(json) {
3149
+ return GetCompanyFeatureUsageResponseFromJSONTyped(json, false);
3150
+ }
3151
+ function GetCompanyFeatureUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
3152
+ if (json == null) {
3153
+ return json;
3154
+ }
3155
+ return {
3156
+ data: CompanyFeatureUsageListResponseDataFromJSON(json["data"]),
3157
+ params: json["params"]
3158
+ };
3159
+ }
3160
+ function GetCompanyFeatureUsageResponseToJSON(json) {
3161
+ return GetCompanyFeatureUsageResponseToJSONTyped(json, false);
3162
+ }
3163
+ function GetCompanyFeatureUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
3164
+ if (value == null) {
3165
+ return value;
3166
+ }
3167
+ return {
3168
+ data: CompanyFeatureUsageListResponseDataToJSON(value["data"]),
3169
+ params: value["params"]
3170
+ };
3171
+ }
3172
+ function instanceOfGetCompanyFeatureUserUsageParams(value) {
3173
+ return true;
3174
+ }
3175
+ function GetCompanyFeatureUserUsageParamsFromJSON(json) {
3176
+ return GetCompanyFeatureUserUsageParamsFromJSONTyped(json, false);
3177
+ }
3178
+ function GetCompanyFeatureUserUsageParamsFromJSONTyped(json, ignoreDiscriminator) {
3179
+ if (json == null) {
3180
+ return json;
3181
+ }
3182
+ return {
3183
+ limit: json["limit"] == null ? void 0 : json["limit"],
3184
+ offset: json["offset"] == null ? void 0 : json["offset"]
3185
+ };
3186
+ }
3187
+ function GetCompanyFeatureUserUsageParamsToJSON(json) {
3188
+ return GetCompanyFeatureUserUsageParamsToJSONTyped(json, false);
3189
+ }
3190
+ function GetCompanyFeatureUserUsageParamsToJSONTyped(value, ignoreDiscriminator = false) {
3191
+ if (value == null) {
3192
+ return value;
3193
+ }
3194
+ return {
3195
+ limit: value["limit"],
3196
+ offset: value["offset"]
3197
+ };
3198
+ }
3199
+ function instanceOfGetCompanyFeatureUserUsageResponse(value) {
3200
+ if (!("data" in value) || value["data"] === void 0) return false;
3201
+ if (!("params" in value) || value["params"] === void 0) return false;
3202
+ return true;
3203
+ }
3204
+ function GetCompanyFeatureUserUsageResponseFromJSON(json) {
3205
+ return GetCompanyFeatureUserUsageResponseFromJSONTyped(json, false);
3206
+ }
3207
+ function GetCompanyFeatureUserUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
3208
+ if (json == null) {
3209
+ return json;
3210
+ }
3211
+ return {
3212
+ data: CompanyFeatureUserUsageResponseDataFromJSON(json["data"]),
3213
+ params: GetCompanyFeatureUserUsageParamsFromJSON(json["params"])
3214
+ };
3215
+ }
3216
+ function GetCompanyFeatureUserUsageResponseToJSON(json) {
3217
+ return GetCompanyFeatureUserUsageResponseToJSONTyped(json, false);
3218
+ }
3219
+ function GetCompanyFeatureUserUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
3220
+ if (value == null) {
3221
+ return value;
3222
+ }
3223
+ return {
3224
+ data: CompanyFeatureUserUsageResponseDataToJSON(value["data"]),
3225
+ params: GetCompanyFeatureUserUsageParamsToJSON(value["params"])
3226
+ };
3227
+ }
1797
3228
  function instanceOfGetCompanyInvoicesParams(value) {
1798
3229
  return true;
1799
3230
  }
@@ -2395,6 +3826,66 @@ var SchematicBillingClient = class {
2395
3826
  method: "DELETE"
2396
3827
  }).then(() => void 0);
2397
3828
  }
3829
+ fetchFeatureUsage() {
3830
+ const path = "/company/usage";
3831
+ return this.session.request(path).then((body) => {
3832
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3833
+ throw new Error(`Malformed response from ${path}`);
3834
+ }
3835
+ const data = body.data;
3836
+ if (data == null || data.features == null) {
3837
+ return [];
3838
+ }
3839
+ return GetCompanyFeatureUsageResponseFromJSON(body).data.features;
3840
+ });
3841
+ }
3842
+ fetchCreditBalances() {
3843
+ const path = "/company/credits";
3844
+ return this.session.request(path).then((body) => {
3845
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3846
+ throw new Error(`Malformed response from ${path}`);
3847
+ }
3848
+ const data = body.data;
3849
+ if (data == null || data.balances == null) {
3850
+ return [];
3851
+ }
3852
+ return GetCompanyCreditBalancesResponseFromJSON(body).data.balances;
3853
+ });
3854
+ }
3855
+ fetchCreditUserUsage(params) {
3856
+ const query = new URLSearchParams();
3857
+ if (params.limit !== void 0) {
3858
+ query.set("limit", String(params.limit));
3859
+ }
3860
+ if (params.offset !== void 0) {
3861
+ query.set("offset", String(params.offset));
3862
+ }
3863
+ const search = query.toString();
3864
+ const path = `/company/credits/${encodeURIComponent(params.creditId)}/users${search === "" ? "" : `?${search}`}`;
3865
+ return this.session.request(path).then((body) => {
3866
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3867
+ throw new Error(`Malformed response from ${path}`);
3868
+ }
3869
+ return GetCompanyCreditUserUsageResponseFromJSON(body).data;
3870
+ });
3871
+ }
3872
+ fetchFeatureUserUsage(params) {
3873
+ const query = new URLSearchParams();
3874
+ if (params.limit !== void 0) {
3875
+ query.set("limit", String(params.limit));
3876
+ }
3877
+ if (params.offset !== void 0) {
3878
+ query.set("offset", String(params.offset));
3879
+ }
3880
+ const search = query.toString();
3881
+ const path = `/company/usage/${encodeURIComponent(params.featureId)}/users${search === "" ? "" : `?${search}`}`;
3882
+ return this.session.request(path).then((body) => {
3883
+ if (body === null || typeof body !== "object" || !("data" in body)) {
3884
+ throw new Error(`Malformed response from ${path}`);
3885
+ }
3886
+ return GetCompanyFeatureUserUsageResponseFromJSON(body).data;
3887
+ });
3888
+ }
2398
3889
  };
2399
3890
  var anonymousIdKey = "schematicId";
2400
3891
  var flagStateCachePrefix = "schematicCache";
@@ -2402,9 +3893,41 @@ var flagStateCacheMaxContexts = 10;
2402
3893
  var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
2403
3894
  var emptyCreditBalances = Object.freeze({});
2404
3895
  var emptyCreditSpendPolicies = [];
3896
+ function extractEventContext(event) {
3897
+ const body = event.body;
3898
+ const context = {};
3899
+ switch (event.type) {
3900
+ case "identify":
3901
+ if (body.keys != null) {
3902
+ context.user = body.keys;
3903
+ }
3904
+ if (body.company?.keys != null) {
3905
+ context.company = body.company.keys;
3906
+ }
3907
+ break;
3908
+ case "track":
3909
+ if (body.company != null) {
3910
+ context.company = body.company;
3911
+ }
3912
+ if (body.user != null) {
3913
+ context.user = body.user;
3914
+ }
3915
+ break;
3916
+ case "flag_check":
3917
+ if (body.req_company != null) {
3918
+ context.company = body.req_company;
3919
+ }
3920
+ if (body.req_user != null) {
3921
+ context.user = body.req_user;
3922
+ }
3923
+ break;
3924
+ }
3925
+ return context;
3926
+ }
2405
3927
  var Schematic = class {
2406
3928
  _additionalHeaders = {};
2407
3929
  apiKey;
3930
+ contextSignatureManager;
2408
3931
  _apiUrl = "https://api.schematichq.com";
2409
3932
  conn = null;
2410
3933
  context = {};
@@ -2491,6 +4014,12 @@ var Schematic = class {
2491
4014
  "X-Schematic-Client-Version": `schematic-js@${version}`,
2492
4015
  ...options?.additionalHeaders ?? {}
2493
4016
  };
4017
+ if (options?.getContextSignature !== void 0) {
4018
+ this.contextSignatureManager = new ContextSignatureManager(
4019
+ options.getContextSignature,
4020
+ this.debug.bind(this)
4021
+ );
4022
+ }
2494
4023
  if (options?.storage) {
2495
4024
  this.storage = options.storage;
2496
4025
  } else {
@@ -2660,12 +4189,14 @@ var Schematic = class {
2660
4189
  }
2661
4190
  if (!this.useWebSocket) {
2662
4191
  const requestUrl = `${this._apiUrl}/flags/${key}/check`;
4192
+ const sigHeaders = await this.contextSignatureHeaders(context);
2663
4193
  return fetch(requestUrl, {
2664
4194
  method: "POST",
2665
4195
  headers: {
2666
4196
  ...this._additionalHeaders ?? {},
2667
4197
  "Content-Type": "application/json;charset=UTF-8",
2668
- "X-Schematic-Api-Key": this.apiKey
4198
+ "X-Schematic-Api-Key": this.apiKey,
4199
+ ...sigHeaders
2669
4200
  },
2670
4201
  body: JSON.stringify(context)
2671
4202
  }).then((response) => {
@@ -2758,6 +4289,34 @@ var Schematic = class {
2758
4289
  console.log(`[Schematic] ${message}`, ...args);
2759
4290
  }
2760
4291
  }
4292
+ /**
4293
+ * Resolve the HMAC context-signature value for a context, if a signature
4294
+ * provider is configured. Returns undefined when no provider is set, when
4295
+ * offline, or when the signature could not be obtained.
4296
+ */
4297
+ contextSignature(context) {
4298
+ if (this.contextSignatureManager === void 0 || this.isOffline()) {
4299
+ return void 0;
4300
+ }
4301
+ return this.contextSignatureManager.getSignature(context);
4302
+ }
4303
+ /**
4304
+ * Build the `X-Schematic-Context-Sig` header for a context, or an empty
4305
+ * object when no signature is available. Spread into request headers.
4306
+ *
4307
+ * Returns synchronously (not a Promise) when no signature provider is
4308
+ * configured, so callers that dispatch on the same tick (e.g. fire-and-forget
4309
+ * event sends) keep their existing timing; only a configured provider, which
4310
+ * must fetch a signature, yields a Promise.
4311
+ */
4312
+ contextSignatureHeaders(context) {
4313
+ if (this.contextSignatureManager === void 0 || this.isOffline()) {
4314
+ return {};
4315
+ }
4316
+ return this.contextSignatureManager.getSignature(context).then(
4317
+ (signature) => signature === void 0 ? {} : { [contextSignatureHeader]: signature }
4318
+ );
4319
+ }
2761
4320
  /**
2762
4321
  * Create a persistent message handler for websocket flag updates
2763
4322
  */
@@ -2881,12 +4440,14 @@ var Schematic = class {
2881
4440
  }
2882
4441
  const requestUrl = `${this._apiUrl}/flags/check`;
2883
4442
  const requestBody = JSON.stringify(context);
4443
+ const sigHeaders = await this.contextSignatureHeaders(context);
2884
4444
  return fetch(requestUrl, {
2885
4445
  method: "POST",
2886
4446
  headers: {
2887
4447
  ...this._additionalHeaders ?? {},
2888
4448
  "Content-Type": "application/json;charset=UTF-8",
2889
- "X-Schematic-Api-Key": this.apiKey
4449
+ "X-Schematic-Api-Key": this.apiKey,
4450
+ ...sigHeaders
2890
4451
  },
2891
4452
  body: requestBody
2892
4453
  }).then((response) => {
@@ -3441,12 +5002,17 @@ var Schematic = class {
3441
5002
  this.debug(`event not sent (offline mode):`, { event });
3442
5003
  return Promise.resolve();
3443
5004
  }
5005
+ const maybeSigHeaders = this.contextSignatureHeaders(
5006
+ extractEventContext(event)
5007
+ );
5008
+ const sigHeaders = maybeSigHeaders instanceof Promise ? await maybeSigHeaders : maybeSigHeaders;
3444
5009
  try {
3445
5010
  const response = await fetch(captureUrl, {
3446
5011
  method: "POST",
3447
5012
  headers: {
3448
5013
  ...this._additionalHeaders ?? {},
3449
- "Content-Type": "application/json;charset=UTF-8"
5014
+ "Content-Type": "application/json;charset=UTF-8",
5015
+ ...sigHeaders
3450
5016
  },
3451
5017
  body: payload
3452
5018
  });
@@ -3630,6 +5196,7 @@ var Schematic = class {
3630
5196
  * In offline mode, this is a no-op.
3631
5197
  */
3632
5198
  cleanup = async () => {
5199
+ this.contextSignatureManager?.clear();
3633
5200
  if (this.isOffline()) {
3634
5201
  this.debug("cleanup: skipped (offline mode)");
3635
5202
  return Promise.resolve();
@@ -3915,7 +5482,7 @@ var Schematic = class {
3915
5482
  context
3916
5483
  );
3917
5484
  this.context = context;
3918
- const sendMessage = () => {
5485
+ const sendMessage = async () => {
3919
5486
  let resolved = false;
3920
5487
  const persistentMessageHandler = this.createPersistentMessageHandler(context);
3921
5488
  const messageHandler = (event) => {
@@ -3942,20 +5509,22 @@ var Schematic = class {
3942
5509
  });
3943
5510
  this.currentWebSocket = socket;
3944
5511
  const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
5512
+ const sig = await this.contextSignature(context);
3945
5513
  const messagePayload = {
3946
5514
  apiKey: this.apiKey,
3947
5515
  clientVersion,
3948
- data: context
5516
+ data: context,
5517
+ ...sig !== void 0 ? { sig } : {}
3949
5518
  };
3950
5519
  this.debug(`WebSocket sending message:`, messagePayload);
3951
5520
  socket.send(JSON.stringify(messagePayload));
3952
5521
  };
3953
5522
  if (socket.readyState === WebSocket.OPEN) {
3954
5523
  this.debug(`WebSocket already open, sending message`);
3955
- sendMessage();
5524
+ void sendMessage();
3956
5525
  } else if (socket.readyState === WebSocket.CONNECTING) {
3957
5526
  this.debug(`WebSocket connecting, waiting for open to send message`);
3958
- socket.addEventListener("open", sendMessage);
5527
+ socket.addEventListener("open", () => void sendMessage());
3959
5528
  } else {
3960
5529
  this.debug(`WebSocket is closed, cannot send message`);
3961
5530
  reject("WebSocket is not open or connecting");
@@ -4558,6 +6127,7 @@ var READINESS = {
4558
6127
  active: "ready",
4559
6128
  ended: "never"
4560
6129
  };
6130
+ var FEATURE_USER_USAGE_LIMIT = 20;
4561
6131
  var BillingStore = class {
4562
6132
  constructor(_client, initialData = {}, options = {}) {
4563
6133
  this._client = _client;
@@ -4578,6 +6148,28 @@ var BillingStore = class {
4578
6148
  () => this._client.fetchPaymentMethods(),
4579
6149
  { readiness }
4580
6150
  );
6151
+ this.featureUsage = new KeyedResource(
6152
+ () => this._client.fetchFeatureUsage(),
6153
+ { readiness }
6154
+ );
6155
+ this.featureUserUsage = new KeyedResource(
6156
+ ({ featureId }) => this._client.fetchFeatureUserUsage({
6157
+ featureId,
6158
+ limit: FEATURE_USER_USAGE_LIMIT
6159
+ }),
6160
+ { readiness }
6161
+ );
6162
+ this.creditBalances = new KeyedResource(
6163
+ () => this._client.fetchCreditBalances(),
6164
+ { readiness }
6165
+ );
6166
+ this.creditUserUsage = new KeyedResource(
6167
+ ({ creditId }) => this._client.fetchCreditUserUsage({
6168
+ creditId,
6169
+ limit: FEATURE_USER_USAGE_LIMIT
6170
+ }),
6171
+ { readiness }
6172
+ );
4581
6173
  const held = { key: initialData.sessionKey };
4582
6174
  if (initialData.invoices !== void 0) {
4583
6175
  held.invoices = {
@@ -4595,7 +6187,13 @@ var BillingStore = class {
4595
6187
  if (initialData.paymentMethods !== void 0) {
4596
6188
  held.paymentMethods = initialData.paymentMethods;
4597
6189
  }
4598
- if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0) {
6190
+ if (initialData.featureUsage !== void 0) {
6191
+ held.featureUsage = initialData.featureUsage;
6192
+ }
6193
+ if (initialData.creditBalances !== void 0) {
6194
+ held.creditBalances = initialData.creditBalances;
6195
+ }
6196
+ if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0 || held.featureUsage !== void 0 || held.creditBalances !== void 0) {
4599
6197
  this._held = held;
4600
6198
  this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
4601
6199
  }
@@ -4604,6 +6202,10 @@ var BillingStore = class {
4604
6202
  invoices;
4605
6203
  upcomingInvoice;
4606
6204
  paymentMethods;
6205
+ featureUsage;
6206
+ creditBalances;
6207
+ creditUserUsage;
6208
+ featureUserUsage;
4607
6209
  _pageSize;
4608
6210
  _unsubscribe;
4609
6211
  _connected = false;
@@ -4682,6 +6284,12 @@ var BillingStore = class {
4682
6284
  if (held.paymentMethods !== void 0) {
4683
6285
  this.paymentMethods.seed(SINGLETON, held.paymentMethods);
4684
6286
  }
6287
+ if (held.featureUsage !== void 0) {
6288
+ this.featureUsage.seed(SINGLETON, held.featureUsage);
6289
+ }
6290
+ if (held.creditBalances !== void 0) {
6291
+ this.creditBalances.seed(SINGLETON, held.creditBalances);
6292
+ }
4685
6293
  this._seedKey = held.key;
4686
6294
  this._seeded = true;
4687
6295
  }
@@ -4694,24 +6302,32 @@ var BillingStore = class {
4694
6302
  for (const name of RESOURCE_NAMES) {
4695
6303
  this[name].resetAll();
4696
6304
  }
6305
+ this.featureUserUsage.resetAll();
6306
+ this.creditUserUsage.resetAll();
4697
6307
  }
4698
6308
  /** Forgets every resource and leaves them empty; nothing reloads. */
4699
6309
  clearAll() {
4700
6310
  for (const name of RESOURCE_NAMES) {
4701
6311
  this[name].clearAll();
4702
6312
  }
6313
+ this.featureUserUsage.clearAll();
6314
+ this.creditUserUsage.clearAll();
4703
6315
  }
4704
6316
  /** Loads every resource that is subscribed and has nothing yet. */
4705
6317
  resumeAll() {
4706
6318
  for (const name of RESOURCE_NAMES) {
4707
6319
  this[name].resumeAll();
4708
6320
  }
6321
+ this.featureUserUsage.resumeAll();
6322
+ this.creditUserUsage.resumeAll();
4709
6323
  }
4710
6324
  /** Reloads every resource that has been loaded, keeping its current data. */
4711
6325
  invalidateAll() {
4712
6326
  for (const name of RESOURCE_NAMES) {
4713
6327
  this[name].invalidateAll();
4714
6328
  }
6329
+ this.featureUserUsage.invalidateAll();
6330
+ this.creditUserUsage.invalidateAll();
4715
6331
  }
4716
6332
  /**
4717
6333
  * Appends the next page to the invoices list for `query`, when there is
@@ -4823,7 +6439,9 @@ var BillingStore = class {
4823
6439
  var RESOURCE_NAMES = [
4824
6440
  "invoices",
4825
6441
  "upcomingInvoice",
4826
- "paymentMethods"
6442
+ "paymentMethods",
6443
+ "featureUsage",
6444
+ "creditBalances"
4827
6445
  ];
4828
6446
 
4829
6447
  // src/billing/context.tsx
@@ -4903,6 +6521,12 @@ var missingBillingSource = {
4903
6521
  subscribe: () => () => {
4904
6522
  },
4905
6523
  handle: () => missingHandle,
6524
+ subscribeFeatureUserUsage: () => () => {
6525
+ },
6526
+ featureUserUsage: () => missingHandle,
6527
+ subscribeCreditUserUsage: () => () => {
6528
+ },
6529
+ creditUserUsage: () => missingHandle,
4906
6530
  loadMoreInvoices: () => Promise.resolve(),
4907
6531
  invalidateAll: () => {
4908
6532
  },
@@ -4916,7 +6540,9 @@ function useBillingDataSource() {
4916
6540
  function BillingDataProvider({
4917
6541
  actions,
4918
6542
  children,
6543
+ creditUserUsage,
4919
6544
  data,
6545
+ featureUserUsage,
4920
6546
  locale,
4921
6547
  onLoadMoreInvoices,
4922
6548
  onMissingString,
@@ -4927,6 +6553,8 @@ function BillingDataProvider({
4927
6553
  }) {
4928
6554
  const source = useMemo2(() => {
4929
6555
  const handles = /* @__PURE__ */ new Map();
6556
+ const userUsageHandles = /* @__PURE__ */ new Map();
6557
+ const creditUsageHandles = /* @__PURE__ */ new Map();
4930
6558
  return {
4931
6559
  actions: rejectingActions(
4932
6560
  (name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
@@ -4950,6 +6578,42 @@ function BillingDataProvider({
4950
6578
  handles.set(name, handle);
4951
6579
  return handle;
4952
6580
  },
6581
+ subscribeFeatureUserUsage: () => () => {
6582
+ },
6583
+ featureUserUsage: (featureId) => {
6584
+ const cached = userUsageHandles.get(featureId);
6585
+ if (cached !== void 0) {
6586
+ return cached;
6587
+ }
6588
+ const value = featureUserUsage?.[featureId];
6589
+ const handle = {
6590
+ data: value,
6591
+ error: void 0,
6592
+ isPending: value === void 0,
6593
+ refetch: () => {
6594
+ }
6595
+ };
6596
+ userUsageHandles.set(featureId, handle);
6597
+ return handle;
6598
+ },
6599
+ subscribeCreditUserUsage: () => () => {
6600
+ },
6601
+ creditUserUsage: (creditId) => {
6602
+ const cached = creditUsageHandles.get(creditId);
6603
+ if (cached !== void 0) {
6604
+ return cached;
6605
+ }
6606
+ const value = creditUserUsage?.[creditId];
6607
+ const handle = {
6608
+ data: value,
6609
+ error: void 0,
6610
+ isPending: value === void 0,
6611
+ refetch: () => {
6612
+ }
6613
+ };
6614
+ creditUsageHandles.set(creditId, handle);
6615
+ return handle;
6616
+ },
4953
6617
  loadMoreInvoices: (query) => {
4954
6618
  onLoadMoreInvoices?.(query);
4955
6619
  return Promise.resolve();
@@ -4957,7 +6621,15 @@ function BillingDataProvider({
4957
6621
  invalidateAll: () => {
4958
6622
  }
4959
6623
  };
4960
- }, [actions, data, onLoadMoreInvoices, onRefetch, status]);
6624
+ }, [
6625
+ actions,
6626
+ creditUserUsage,
6627
+ data,
6628
+ featureUserUsage,
6629
+ onLoadMoreInvoices,
6630
+ onRefetch,
6631
+ status
6632
+ ]);
4961
6633
  return /* @__PURE__ */ jsx2(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ jsx2(
4962
6634
  SchematicI18nProvider,
4963
6635
  {
@@ -5053,6 +6725,36 @@ function useSetupIntent() {
5053
6725
  [source]
5054
6726
  );
5055
6727
  }
6728
+ function useFeatureUsage() {
6729
+ return useBillingResource("featureUsage", SINGLETON);
6730
+ }
6731
+ function useFeatureUserUsage(featureId) {
6732
+ const source = useBillingDataSource();
6733
+ const subscribe = useCallback(
6734
+ (listener) => source.subscribeFeatureUserUsage(featureId, listener),
6735
+ [featureId, source]
6736
+ );
6737
+ const getSnapshot = useCallback(
6738
+ () => source.featureUserUsage(featureId),
6739
+ [featureId, source]
6740
+ );
6741
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
6742
+ }
6743
+ function useCreditBalances() {
6744
+ return useBillingResource("creditBalances", SINGLETON);
6745
+ }
6746
+ function useCreditUserUsage(creditId) {
6747
+ const source = useBillingDataSource();
6748
+ const subscribe = useCallback(
6749
+ (listener) => source.subscribeCreditUserUsage(creditId, listener),
6750
+ [creditId, source]
6751
+ );
6752
+ const getSnapshot = useCallback(
6753
+ () => source.creditUserUsage(creditId),
6754
+ [creditId, source]
6755
+ );
6756
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
6757
+ }
5056
6758
  function useInvalidateBillingData() {
5057
6759
  return useBillingDataSource().invalidateAll;
5058
6760
  }
@@ -5108,8 +6810,7 @@ function BillingProvider({
5108
6810
  return initialRef.current === void 0 ? void 0 : staticSource(initialRef.current);
5109
6811
  }
5110
6812
  const handles = /* @__PURE__ */ new WeakMap();
5111
- const handle = (name, params) => {
5112
- const resource = store.resource(name).get(params);
6813
+ const handleOf = (resource) => {
5113
6814
  const snapshot = resource.getSnapshot();
5114
6815
  const cached = handles.get(resource);
5115
6816
  if (cached !== void 0 && cached.snapshot === snapshot) {
@@ -5119,12 +6820,20 @@ function BillingProvider({
5119
6820
  ...snapshot,
5120
6821
  refetch: () => void resource.refetch()
5121
6822
  };
5122
- handles.set(resource, { snapshot, handle: next });
6823
+ handles.set(resource, {
6824
+ snapshot,
6825
+ handle: next
6826
+ });
5123
6827
  return next;
5124
6828
  };
6829
+ const handle = (name, params) => handleOf(store.resource(name).get(params));
5125
6830
  return {
5126
6831
  subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
5127
6832
  handle,
6833
+ subscribeFeatureUserUsage: (featureId, listener) => store.featureUserUsage.subscribe({ featureId }, listener),
6834
+ featureUserUsage: (featureId) => handleOf(store.featureUserUsage.get({ featureId })),
6835
+ subscribeCreditUserUsage: (creditId, listener) => store.creditUserUsage.subscribe({ creditId }, listener),
6836
+ creditUserUsage: (creditId) => handleOf(store.creditUserUsage.get({ creditId })),
5128
6837
  loadMoreInvoices: (query) => store.loadMoreInvoices(query),
5129
6838
  invalidateAll: () => store.invalidateAll(),
5130
6839
  actions: {
@@ -5151,7 +6860,27 @@ function BillingProvider({
5151
6860
  }
5152
6861
  function staticSource(data) {
5153
6862
  const handles = /* @__PURE__ */ new Map();
6863
+ const pendingUserUsage = {
6864
+ data: void 0,
6865
+ error: void 0,
6866
+ isPending: true,
6867
+ refetch: () => {
6868
+ }
6869
+ };
6870
+ const pendingCreditUsage = {
6871
+ data: void 0,
6872
+ error: void 0,
6873
+ isPending: true,
6874
+ refetch: () => {
6875
+ }
6876
+ };
5154
6877
  return {
6878
+ subscribeFeatureUserUsage: () => () => {
6879
+ },
6880
+ featureUserUsage: () => pendingUserUsage,
6881
+ subscribeCreditUserUsage: () => () => {
6882
+ },
6883
+ creditUserUsage: () => pendingCreditUsage,
5155
6884
  subscribe: () => () => {
5156
6885
  },
5157
6886
  handle: (name) => {
@@ -5177,7 +6906,7 @@ function staticSource(data) {
5177
6906
  }
5178
6907
 
5179
6908
  // src/version.ts
5180
- var version2 = "1.10.0";
6909
+ var version2 = "1.12.0";
5181
6910
 
5182
6911
  // src/context/schematic.tsx
5183
6912
  import { jsx as jsx4 } from "react/jsx-runtime";
@@ -5427,6 +7156,7 @@ export {
5427
7156
  BillingDataProvider,
5428
7157
  BillingProvider,
5429
7158
  DEFAULT_INVOICE_QUERY,
7159
+ FEATURE_USER_USAGE_LIMIT,
5430
7160
  INVOICE_PAGE_SIZE,
5431
7161
  InvoiceStatus,
5432
7162
  RuleType,
@@ -5439,6 +7169,10 @@ export {
5439
7169
  UsagePeriod,
5440
7170
  normalizeInvoiceQuery2 as normalizeInvoiceQuery,
5441
7171
  useBillingDataSource,
7172
+ useCreditBalances,
7173
+ useCreditUserUsage,
7174
+ useFeatureUsage,
7175
+ useFeatureUserUsage,
5442
7176
  useInvalidateBillingData,
5443
7177
  useInvoices,
5444
7178
  usePaymentMethods,