@schematichq/schematic-react 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schematic-react.cjs.js +1174 -16
- package/dist/schematic-react.d.ts +910 -3
- package/dist/schematic-react.esm.js +1174 -16
- package/package.json +7 -7
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
BillingDataProvider: () => BillingDataProvider,
|
|
34
34
|
BillingProvider: () => BillingProvider,
|
|
35
35
|
DEFAULT_INVOICE_QUERY: () => DEFAULT_INVOICE_QUERY,
|
|
36
|
+
FEATURE_USER_USAGE_LIMIT: () => FEATURE_USER_USAGE_LIMIT,
|
|
36
37
|
INVOICE_PAGE_SIZE: () => INVOICE_PAGE_SIZE,
|
|
37
38
|
InvoiceStatus: () => InvoiceStatus,
|
|
38
39
|
RuleType: () => RuleType,
|
|
@@ -45,6 +46,8 @@ __export(index_exports, {
|
|
|
45
46
|
UsagePeriod: () => UsagePeriod,
|
|
46
47
|
normalizeInvoiceQuery: () => normalizeInvoiceQuery2,
|
|
47
48
|
useBillingDataSource: () => useBillingDataSource,
|
|
49
|
+
useFeatureUsage: () => useFeatureUsage,
|
|
50
|
+
useFeatureUserUsage: () => useFeatureUserUsage,
|
|
48
51
|
useInvalidateBillingData: () => useInvalidateBillingData,
|
|
49
52
|
useInvoices: () => useInvoices,
|
|
50
53
|
usePaymentMethods: () => usePaymentMethods,
|
|
@@ -66,7 +69,7 @@ __export(index_exports, {
|
|
|
66
69
|
});
|
|
67
70
|
module.exports = __toCommonJS(index_exports);
|
|
68
71
|
|
|
69
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
72
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.11.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
|
|
70
73
|
var __create2 = Object.create;
|
|
71
74
|
var __defProp2 = Object.defineProperty;
|
|
72
75
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -1302,7 +1305,98 @@ function contextString(context) {
|
|
|
1302
1305
|
}, {});
|
|
1303
1306
|
return JSON.stringify(sortedContext);
|
|
1304
1307
|
}
|
|
1305
|
-
var
|
|
1308
|
+
var contextSignatureHeader = "X-Schematic-Context-Sig";
|
|
1309
|
+
var refreshSkewMs = 6e4;
|
|
1310
|
+
var maxCachedSignatures = 50;
|
|
1311
|
+
function parseSignatureExpiryMs(signature) {
|
|
1312
|
+
const parts = signature.split(".");
|
|
1313
|
+
if (parts.length !== 3) {
|
|
1314
|
+
return null;
|
|
1315
|
+
}
|
|
1316
|
+
const expSeconds = Number(parts[1]);
|
|
1317
|
+
if (!Number.isFinite(expSeconds)) {
|
|
1318
|
+
return null;
|
|
1319
|
+
}
|
|
1320
|
+
return expSeconds * 1e3;
|
|
1321
|
+
}
|
|
1322
|
+
var ContextSignatureManager = class {
|
|
1323
|
+
provider;
|
|
1324
|
+
debug;
|
|
1325
|
+
cache = /* @__PURE__ */ new Map();
|
|
1326
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
1327
|
+
constructor(provider, debug) {
|
|
1328
|
+
this.provider = provider;
|
|
1329
|
+
this.debug = debug;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Return a valid signature for the given context, fetching a fresh one via
|
|
1333
|
+
* the provider when the cache is empty or close to expiry. Concurrent calls
|
|
1334
|
+
* for the same context share a single provider invocation. Returns undefined
|
|
1335
|
+
* (and logs a warning) if the provider throws, so callers can degrade
|
|
1336
|
+
* gracefully by sending the request without a signature.
|
|
1337
|
+
*/
|
|
1338
|
+
async getSignature(context) {
|
|
1339
|
+
const key = contextString(context);
|
|
1340
|
+
const cached = this.cache.get(key);
|
|
1341
|
+
if (cached !== void 0 && Date.now() < cached.expiresAtMs - refreshSkewMs) {
|
|
1342
|
+
this.cache.delete(key);
|
|
1343
|
+
this.cache.set(key, cached);
|
|
1344
|
+
return cached.signature;
|
|
1345
|
+
}
|
|
1346
|
+
const existing = this.inFlight.get(key);
|
|
1347
|
+
if (existing !== void 0) {
|
|
1348
|
+
return existing;
|
|
1349
|
+
}
|
|
1350
|
+
const pending = this.fetchSignature(key, context).finally(() => {
|
|
1351
|
+
this.inFlight.delete(key);
|
|
1352
|
+
});
|
|
1353
|
+
this.inFlight.set(key, pending);
|
|
1354
|
+
return pending;
|
|
1355
|
+
}
|
|
1356
|
+
/** Drop all cached signatures. */
|
|
1357
|
+
clear() {
|
|
1358
|
+
this.cache.clear();
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Drop expired signatures, then the least recently used ones until the cache
|
|
1362
|
+
* is within `maxCachedSignatures`.
|
|
1363
|
+
*/
|
|
1364
|
+
evict() {
|
|
1365
|
+
const now = Date.now();
|
|
1366
|
+
for (const [key, entry] of this.cache) {
|
|
1367
|
+
if (now >= entry.expiresAtMs) {
|
|
1368
|
+
this.cache.delete(key);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
for (const key of this.cache.keys()) {
|
|
1372
|
+
if (this.cache.size <= maxCachedSignatures) {
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
this.cache.delete(key);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
async fetchSignature(key, context) {
|
|
1379
|
+
try {
|
|
1380
|
+
const signature = await this.provider(context);
|
|
1381
|
+
const expiresAtMs = parseSignatureExpiryMs(signature);
|
|
1382
|
+
if (expiresAtMs === null) {
|
|
1383
|
+
this.debug(
|
|
1384
|
+
"getContextSignature returned a value without a parseable expiry; not caching",
|
|
1385
|
+
{ signature }
|
|
1386
|
+
);
|
|
1387
|
+
return signature;
|
|
1388
|
+
}
|
|
1389
|
+
this.cache.delete(key);
|
|
1390
|
+
this.cache.set(key, { signature, expiresAtMs });
|
|
1391
|
+
this.evict();
|
|
1392
|
+
return signature;
|
|
1393
|
+
} catch (error) {
|
|
1394
|
+
console.warn("Failed to obtain context signature:", error);
|
|
1395
|
+
return void 0;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
var version = "1.11.0";
|
|
1306
1400
|
var SINGLETON = {};
|
|
1307
1401
|
var models_exports = {};
|
|
1308
1402
|
__export2(models_exports, {
|
|
@@ -1310,15 +1404,59 @@ __export2(models_exports, {
|
|
|
1310
1404
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1311
1405
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1312
1406
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1407
|
+
BillingPlanCreditGrantResetCadence: () => BillingPlanCreditGrantResetCadence,
|
|
1408
|
+
BillingPlanCreditGrantResetCadenceFromJSON: () => BillingPlanCreditGrantResetCadenceFromJSON2,
|
|
1409
|
+
BillingPlanCreditGrantResetCadenceFromJSONTyped: () => BillingPlanCreditGrantResetCadenceFromJSONTyped3,
|
|
1410
|
+
BillingPlanCreditGrantResetCadenceToJSON: () => BillingPlanCreditGrantResetCadenceToJSON2,
|
|
1411
|
+
BillingPlanCreditGrantResetCadenceToJSONTyped: () => BillingPlanCreditGrantResetCadenceToJSONTyped3,
|
|
1412
|
+
BillingPriceScheme: () => BillingPriceScheme,
|
|
1413
|
+
BillingPriceSchemeFromJSON: () => BillingPriceSchemeFromJSON2,
|
|
1414
|
+
BillingPriceSchemeFromJSONTyped: () => BillingPriceSchemeFromJSONTyped4,
|
|
1415
|
+
BillingPriceSchemeToJSON: () => BillingPriceSchemeToJSON2,
|
|
1416
|
+
BillingPriceSchemeToJSONTyped: () => BillingPriceSchemeToJSONTyped4,
|
|
1417
|
+
BillingProductPriceInterval: () => BillingProductPriceInterval,
|
|
1418
|
+
BillingProductPriceIntervalFromJSON: () => BillingProductPriceIntervalFromJSON2,
|
|
1419
|
+
BillingProductPriceIntervalFromJSONTyped: () => BillingProductPriceIntervalFromJSONTyped4,
|
|
1420
|
+
BillingProductPriceIntervalToJSON: () => BillingProductPriceIntervalToJSON2,
|
|
1421
|
+
BillingProductPriceIntervalToJSONTyped: () => BillingProductPriceIntervalToJSONTyped4,
|
|
1313
1422
|
BillingProviderType: () => BillingProviderType,
|
|
1314
1423
|
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1315
1424
|
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1316
1425
|
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1317
1426
|
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1427
|
+
BillingTiersMode: () => BillingTiersMode,
|
|
1428
|
+
BillingTiersModeFromJSON: () => BillingTiersModeFromJSON2,
|
|
1429
|
+
BillingTiersModeFromJSONTyped: () => BillingTiersModeFromJSONTyped4,
|
|
1430
|
+
BillingTiersModeToJSON: () => BillingTiersModeToJSON2,
|
|
1431
|
+
BillingTiersModeToJSONTyped: () => BillingTiersModeToJSONTyped4,
|
|
1432
|
+
CatalogCreditGrantResponseDataFromJSON: () => CatalogCreditGrantResponseDataFromJSON,
|
|
1433
|
+
CatalogCreditGrantResponseDataFromJSONTyped: () => CatalogCreditGrantResponseDataFromJSONTyped,
|
|
1434
|
+
CatalogCreditGrantResponseDataToJSON: () => CatalogCreditGrantResponseDataToJSON,
|
|
1435
|
+
CatalogCreditGrantResponseDataToJSONTyped: () => CatalogCreditGrantResponseDataToJSONTyped,
|
|
1436
|
+
CatalogPriceResponseDataFromJSON: () => CatalogPriceResponseDataFromJSON,
|
|
1437
|
+
CatalogPriceResponseDataFromJSONTyped: () => CatalogPriceResponseDataFromJSONTyped,
|
|
1438
|
+
CatalogPriceResponseDataToJSON: () => CatalogPriceResponseDataToJSON,
|
|
1439
|
+
CatalogPriceResponseDataToJSONTyped: () => CatalogPriceResponseDataToJSONTyped,
|
|
1440
|
+
CatalogPriceTierResponseDataFromJSON: () => CatalogPriceTierResponseDataFromJSON,
|
|
1441
|
+
CatalogPriceTierResponseDataFromJSONTyped: () => CatalogPriceTierResponseDataFromJSONTyped,
|
|
1442
|
+
CatalogPriceTierResponseDataToJSON: () => CatalogPriceTierResponseDataToJSON,
|
|
1443
|
+
CatalogPriceTierResponseDataToJSONTyped: () => CatalogPriceTierResponseDataToJSONTyped,
|
|
1318
1444
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1319
1445
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1320
1446
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
1321
1447
|
CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
|
|
1448
|
+
CompanyFeatureUsageListResponseDataFromJSON: () => CompanyFeatureUsageListResponseDataFromJSON,
|
|
1449
|
+
CompanyFeatureUsageListResponseDataFromJSONTyped: () => CompanyFeatureUsageListResponseDataFromJSONTyped,
|
|
1450
|
+
CompanyFeatureUsageListResponseDataToJSON: () => CompanyFeatureUsageListResponseDataToJSON,
|
|
1451
|
+
CompanyFeatureUsageListResponseDataToJSONTyped: () => CompanyFeatureUsageListResponseDataToJSONTyped,
|
|
1452
|
+
CompanyFeatureUsageResponseDataFromJSON: () => CompanyFeatureUsageResponseDataFromJSON,
|
|
1453
|
+
CompanyFeatureUsageResponseDataFromJSONTyped: () => CompanyFeatureUsageResponseDataFromJSONTyped,
|
|
1454
|
+
CompanyFeatureUsageResponseDataToJSON: () => CompanyFeatureUsageResponseDataToJSON,
|
|
1455
|
+
CompanyFeatureUsageResponseDataToJSONTyped: () => CompanyFeatureUsageResponseDataToJSONTyped,
|
|
1456
|
+
CompanyFeatureUserUsageResponseDataFromJSON: () => CompanyFeatureUserUsageResponseDataFromJSON,
|
|
1457
|
+
CompanyFeatureUserUsageResponseDataFromJSONTyped: () => CompanyFeatureUserUsageResponseDataFromJSONTyped,
|
|
1458
|
+
CompanyFeatureUserUsageResponseDataToJSON: () => CompanyFeatureUserUsageResponseDataToJSON,
|
|
1459
|
+
CompanyFeatureUserUsageResponseDataToJSONTyped: () => CompanyFeatureUserUsageResponseDataToJSONTyped,
|
|
1322
1460
|
CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
|
|
1323
1461
|
CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
|
|
1324
1462
|
CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
|
|
@@ -1339,6 +1477,10 @@ __export2(models_exports, {
|
|
|
1339
1477
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1340
1478
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1341
1479
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1480
|
+
CompanyUserUsageResponseDataFromJSON: () => CompanyUserUsageResponseDataFromJSON,
|
|
1481
|
+
CompanyUserUsageResponseDataFromJSONTyped: () => CompanyUserUsageResponseDataFromJSONTyped,
|
|
1482
|
+
CompanyUserUsageResponseDataToJSON: () => CompanyUserUsageResponseDataToJSON,
|
|
1483
|
+
CompanyUserUsageResponseDataToJSONTyped: () => CompanyUserUsageResponseDataToJSONTyped,
|
|
1342
1484
|
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1343
1485
|
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1344
1486
|
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
@@ -1351,6 +1493,38 @@ __export2(models_exports, {
|
|
|
1351
1493
|
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1352
1494
|
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1353
1495
|
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1496
|
+
EntitlementPriceBehavior: () => EntitlementPriceBehavior,
|
|
1497
|
+
EntitlementPriceBehaviorFromJSON: () => EntitlementPriceBehaviorFromJSON2,
|
|
1498
|
+
EntitlementPriceBehaviorFromJSONTyped: () => EntitlementPriceBehaviorFromJSONTyped2,
|
|
1499
|
+
EntitlementPriceBehaviorToJSON: () => EntitlementPriceBehaviorToJSON2,
|
|
1500
|
+
EntitlementPriceBehaviorToJSONTyped: () => EntitlementPriceBehaviorToJSONTyped2,
|
|
1501
|
+
EntitlementType: () => EntitlementType,
|
|
1502
|
+
EntitlementTypeFromJSON: () => EntitlementTypeFromJSON,
|
|
1503
|
+
EntitlementTypeFromJSONTyped: () => EntitlementTypeFromJSONTyped,
|
|
1504
|
+
EntitlementTypeToJSON: () => EntitlementTypeToJSON,
|
|
1505
|
+
EntitlementTypeToJSONTyped: () => EntitlementTypeToJSONTyped,
|
|
1506
|
+
EntitlementValueType: () => EntitlementValueType,
|
|
1507
|
+
EntitlementValueTypeFromJSON: () => EntitlementValueTypeFromJSON2,
|
|
1508
|
+
EntitlementValueTypeFromJSONTyped: () => EntitlementValueTypeFromJSONTyped4,
|
|
1509
|
+
EntitlementValueTypeToJSON: () => EntitlementValueTypeToJSON2,
|
|
1510
|
+
EntitlementValueTypeToJSONTyped: () => EntitlementValueTypeToJSONTyped3,
|
|
1511
|
+
FeatureType: () => FeatureType,
|
|
1512
|
+
FeatureTypeFromJSON: () => FeatureTypeFromJSON2,
|
|
1513
|
+
FeatureTypeFromJSONTyped: () => FeatureTypeFromJSONTyped3,
|
|
1514
|
+
FeatureTypeToJSON: () => FeatureTypeToJSON2,
|
|
1515
|
+
FeatureTypeToJSONTyped: () => FeatureTypeToJSONTyped3,
|
|
1516
|
+
GetCompanyFeatureUsageResponseFromJSON: () => GetCompanyFeatureUsageResponseFromJSON,
|
|
1517
|
+
GetCompanyFeatureUsageResponseFromJSONTyped: () => GetCompanyFeatureUsageResponseFromJSONTyped,
|
|
1518
|
+
GetCompanyFeatureUsageResponseToJSON: () => GetCompanyFeatureUsageResponseToJSON,
|
|
1519
|
+
GetCompanyFeatureUsageResponseToJSONTyped: () => GetCompanyFeatureUsageResponseToJSONTyped,
|
|
1520
|
+
GetCompanyFeatureUserUsageParamsFromJSON: () => GetCompanyFeatureUserUsageParamsFromJSON,
|
|
1521
|
+
GetCompanyFeatureUserUsageParamsFromJSONTyped: () => GetCompanyFeatureUserUsageParamsFromJSONTyped,
|
|
1522
|
+
GetCompanyFeatureUserUsageParamsToJSON: () => GetCompanyFeatureUserUsageParamsToJSON,
|
|
1523
|
+
GetCompanyFeatureUserUsageParamsToJSONTyped: () => GetCompanyFeatureUserUsageParamsToJSONTyped,
|
|
1524
|
+
GetCompanyFeatureUserUsageResponseFromJSON: () => GetCompanyFeatureUserUsageResponseFromJSON,
|
|
1525
|
+
GetCompanyFeatureUserUsageResponseFromJSONTyped: () => GetCompanyFeatureUserUsageResponseFromJSONTyped,
|
|
1526
|
+
GetCompanyFeatureUserUsageResponseToJSON: () => GetCompanyFeatureUserUsageResponseToJSON,
|
|
1527
|
+
GetCompanyFeatureUserUsageResponseToJSONTyped: () => GetCompanyFeatureUserUsageResponseToJSONTyped,
|
|
1354
1528
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1355
1529
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1356
1530
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1372,10 +1546,25 @@ __export2(models_exports, {
|
|
|
1372
1546
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1373
1547
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1374
1548
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1549
|
+
MetricPeriod: () => MetricPeriod,
|
|
1550
|
+
MetricPeriodFromJSON: () => MetricPeriodFromJSON2,
|
|
1551
|
+
MetricPeriodFromJSONTyped: () => MetricPeriodFromJSONTyped7,
|
|
1552
|
+
MetricPeriodMonthReset: () => MetricPeriodMonthReset,
|
|
1553
|
+
MetricPeriodMonthResetFromJSON: () => MetricPeriodMonthResetFromJSON2,
|
|
1554
|
+
MetricPeriodMonthResetFromJSONTyped: () => MetricPeriodMonthResetFromJSONTyped6,
|
|
1555
|
+
MetricPeriodMonthResetToJSON: () => MetricPeriodMonthResetToJSON2,
|
|
1556
|
+
MetricPeriodMonthResetToJSONTyped: () => MetricPeriodMonthResetToJSONTyped5,
|
|
1557
|
+
MetricPeriodToJSON: () => MetricPeriodToJSON2,
|
|
1558
|
+
MetricPeriodToJSONTyped: () => MetricPeriodToJSONTyped6,
|
|
1375
1559
|
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1376
1560
|
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1377
1561
|
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1378
1562
|
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1563
|
+
PlanCreditGrantScaling: () => PlanCreditGrantScaling,
|
|
1564
|
+
PlanCreditGrantScalingFromJSON: () => PlanCreditGrantScalingFromJSON2,
|
|
1565
|
+
PlanCreditGrantScalingFromJSONTyped: () => PlanCreditGrantScalingFromJSONTyped3,
|
|
1566
|
+
PlanCreditGrantScalingToJSON: () => PlanCreditGrantScalingToJSON2,
|
|
1567
|
+
PlanCreditGrantScalingToJSONTyped: () => PlanCreditGrantScalingToJSONTyped3,
|
|
1379
1568
|
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1380
1569
|
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1381
1570
|
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
@@ -1389,22 +1578,43 @@ __export2(models_exports, {
|
|
|
1389
1578
|
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1390
1579
|
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1391
1580
|
instanceOfApiError: () => instanceOfApiError,
|
|
1581
|
+
instanceOfBillingPlanCreditGrantResetCadence: () => instanceOfBillingPlanCreditGrantResetCadence,
|
|
1582
|
+
instanceOfBillingPriceScheme: () => instanceOfBillingPriceScheme,
|
|
1583
|
+
instanceOfBillingProductPriceInterval: () => instanceOfBillingProductPriceInterval,
|
|
1392
1584
|
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1585
|
+
instanceOfBillingTiersMode: () => instanceOfBillingTiersMode,
|
|
1586
|
+
instanceOfCatalogCreditGrantResponseData: () => instanceOfCatalogCreditGrantResponseData,
|
|
1587
|
+
instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
|
|
1588
|
+
instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
|
|
1393
1589
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1590
|
+
instanceOfCompanyFeatureUsageListResponseData: () => instanceOfCompanyFeatureUsageListResponseData,
|
|
1591
|
+
instanceOfCompanyFeatureUsageResponseData: () => instanceOfCompanyFeatureUsageResponseData,
|
|
1592
|
+
instanceOfCompanyFeatureUserUsageResponseData: () => instanceOfCompanyFeatureUserUsageResponseData,
|
|
1394
1593
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1395
1594
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1396
1595
|
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1397
1596
|
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1398
1597
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1598
|
+
instanceOfCompanyUserUsageResponseData: () => instanceOfCompanyUserUsageResponseData,
|
|
1399
1599
|
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1400
1600
|
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1401
1601
|
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1602
|
+
instanceOfEntitlementPriceBehavior: () => instanceOfEntitlementPriceBehavior,
|
|
1603
|
+
instanceOfEntitlementType: () => instanceOfEntitlementType,
|
|
1604
|
+
instanceOfEntitlementValueType: () => instanceOfEntitlementValueType,
|
|
1605
|
+
instanceOfFeatureType: () => instanceOfFeatureType,
|
|
1606
|
+
instanceOfGetCompanyFeatureUsageResponse: () => instanceOfGetCompanyFeatureUsageResponse,
|
|
1607
|
+
instanceOfGetCompanyFeatureUserUsageParams: () => instanceOfGetCompanyFeatureUserUsageParams,
|
|
1608
|
+
instanceOfGetCompanyFeatureUserUsageResponse: () => instanceOfGetCompanyFeatureUserUsageResponse,
|
|
1402
1609
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1403
1610
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1404
1611
|
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1405
1612
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1406
1613
|
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1614
|
+
instanceOfMetricPeriod: () => instanceOfMetricPeriod,
|
|
1615
|
+
instanceOfMetricPeriodMonthReset: () => instanceOfMetricPeriodMonthReset,
|
|
1407
1616
|
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1617
|
+
instanceOfPlanCreditGrantScaling: () => instanceOfPlanCreditGrantScaling,
|
|
1408
1618
|
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1409
1619
|
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1410
1620
|
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
@@ -1435,6 +1645,93 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1435
1645
|
error: value["error"]
|
|
1436
1646
|
};
|
|
1437
1647
|
}
|
|
1648
|
+
var BillingPlanCreditGrantResetCadence = {
|
|
1649
|
+
Daily: "daily",
|
|
1650
|
+
Every6Months: "every_6_months",
|
|
1651
|
+
Monthly: "monthly",
|
|
1652
|
+
Quarterly: "quarterly",
|
|
1653
|
+
Weekly: "weekly",
|
|
1654
|
+
Yearly: "yearly"
|
|
1655
|
+
};
|
|
1656
|
+
function instanceOfBillingPlanCreditGrantResetCadence(value) {
|
|
1657
|
+
for (const key in BillingPlanCreditGrantResetCadence) {
|
|
1658
|
+
if (Object.prototype.hasOwnProperty.call(
|
|
1659
|
+
BillingPlanCreditGrantResetCadence,
|
|
1660
|
+
key
|
|
1661
|
+
)) {
|
|
1662
|
+
if (BillingPlanCreditGrantResetCadence[key] === value) {
|
|
1663
|
+
return true;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
return false;
|
|
1668
|
+
}
|
|
1669
|
+
function BillingPlanCreditGrantResetCadenceFromJSON2(json) {
|
|
1670
|
+
return BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, false);
|
|
1671
|
+
}
|
|
1672
|
+
function BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, ignoreDiscriminator) {
|
|
1673
|
+
return json;
|
|
1674
|
+
}
|
|
1675
|
+
function BillingPlanCreditGrantResetCadenceToJSON2(value) {
|
|
1676
|
+
return value;
|
|
1677
|
+
}
|
|
1678
|
+
function BillingPlanCreditGrantResetCadenceToJSONTyped3(value, ignoreDiscriminator) {
|
|
1679
|
+
return value;
|
|
1680
|
+
}
|
|
1681
|
+
var BillingPriceScheme = {
|
|
1682
|
+
PerUnit: "per_unit",
|
|
1683
|
+
Tiered: "tiered"
|
|
1684
|
+
};
|
|
1685
|
+
function instanceOfBillingPriceScheme(value) {
|
|
1686
|
+
for (const key in BillingPriceScheme) {
|
|
1687
|
+
if (Object.prototype.hasOwnProperty.call(BillingPriceScheme, key)) {
|
|
1688
|
+
if (BillingPriceScheme[key] === value) {
|
|
1689
|
+
return true;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
return false;
|
|
1694
|
+
}
|
|
1695
|
+
function BillingPriceSchemeFromJSON2(json) {
|
|
1696
|
+
return BillingPriceSchemeFromJSONTyped4(json, false);
|
|
1697
|
+
}
|
|
1698
|
+
function BillingPriceSchemeFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1699
|
+
return json;
|
|
1700
|
+
}
|
|
1701
|
+
function BillingPriceSchemeToJSON2(value) {
|
|
1702
|
+
return value;
|
|
1703
|
+
}
|
|
1704
|
+
function BillingPriceSchemeToJSONTyped4(value, ignoreDiscriminator) {
|
|
1705
|
+
return value;
|
|
1706
|
+
}
|
|
1707
|
+
var BillingProductPriceInterval = {
|
|
1708
|
+
Day: "day",
|
|
1709
|
+
Month: "month",
|
|
1710
|
+
OneTime: "one-time",
|
|
1711
|
+
Year: "year"
|
|
1712
|
+
};
|
|
1713
|
+
function instanceOfBillingProductPriceInterval(value) {
|
|
1714
|
+
for (const key in BillingProductPriceInterval) {
|
|
1715
|
+
if (Object.prototype.hasOwnProperty.call(BillingProductPriceInterval, key)) {
|
|
1716
|
+
if (BillingProductPriceInterval[key] === value) {
|
|
1717
|
+
return true;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
return false;
|
|
1722
|
+
}
|
|
1723
|
+
function BillingProductPriceIntervalFromJSON2(json) {
|
|
1724
|
+
return BillingProductPriceIntervalFromJSONTyped4(json, false);
|
|
1725
|
+
}
|
|
1726
|
+
function BillingProductPriceIntervalFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1727
|
+
return json;
|
|
1728
|
+
}
|
|
1729
|
+
function BillingProductPriceIntervalToJSON2(value) {
|
|
1730
|
+
return value;
|
|
1731
|
+
}
|
|
1732
|
+
function BillingProductPriceIntervalToJSONTyped4(value, ignoreDiscriminator) {
|
|
1733
|
+
return value;
|
|
1734
|
+
}
|
|
1438
1735
|
var BillingProviderType = {
|
|
1439
1736
|
Metronome: "metronome",
|
|
1440
1737
|
Orb: "orb",
|
|
@@ -1463,6 +1760,208 @@ function BillingProviderTypeToJSON2(value) {
|
|
|
1463
1760
|
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1464
1761
|
return value;
|
|
1465
1762
|
}
|
|
1763
|
+
var BillingTiersMode = {
|
|
1764
|
+
Graduated: "graduated",
|
|
1765
|
+
Volume: "volume"
|
|
1766
|
+
};
|
|
1767
|
+
function instanceOfBillingTiersMode(value) {
|
|
1768
|
+
for (const key in BillingTiersMode) {
|
|
1769
|
+
if (Object.prototype.hasOwnProperty.call(BillingTiersMode, key)) {
|
|
1770
|
+
if (BillingTiersMode[key] === value) {
|
|
1771
|
+
return true;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
function BillingTiersModeFromJSON2(json) {
|
|
1778
|
+
return BillingTiersModeFromJSONTyped4(json, false);
|
|
1779
|
+
}
|
|
1780
|
+
function BillingTiersModeFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1781
|
+
return json;
|
|
1782
|
+
}
|
|
1783
|
+
function BillingTiersModeToJSON2(value) {
|
|
1784
|
+
return value;
|
|
1785
|
+
}
|
|
1786
|
+
function BillingTiersModeToJSONTyped4(value, ignoreDiscriminator) {
|
|
1787
|
+
return value;
|
|
1788
|
+
}
|
|
1789
|
+
var PlanCreditGrantScaling = {
|
|
1790
|
+
Fixed: "fixed",
|
|
1791
|
+
PerLicense: "per_license"
|
|
1792
|
+
};
|
|
1793
|
+
function instanceOfPlanCreditGrantScaling(value) {
|
|
1794
|
+
for (const key in PlanCreditGrantScaling) {
|
|
1795
|
+
if (Object.prototype.hasOwnProperty.call(PlanCreditGrantScaling, key)) {
|
|
1796
|
+
if (PlanCreditGrantScaling[key] === value) {
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
return false;
|
|
1802
|
+
}
|
|
1803
|
+
function PlanCreditGrantScalingFromJSON2(json) {
|
|
1804
|
+
return PlanCreditGrantScalingFromJSONTyped3(json, false);
|
|
1805
|
+
}
|
|
1806
|
+
function PlanCreditGrantScalingFromJSONTyped3(json, ignoreDiscriminator) {
|
|
1807
|
+
return json;
|
|
1808
|
+
}
|
|
1809
|
+
function PlanCreditGrantScalingToJSON2(value) {
|
|
1810
|
+
return value;
|
|
1811
|
+
}
|
|
1812
|
+
function PlanCreditGrantScalingToJSONTyped3(value, ignoreDiscriminator) {
|
|
1813
|
+
return value;
|
|
1814
|
+
}
|
|
1815
|
+
function instanceOfCatalogCreditGrantResponseData(value) {
|
|
1816
|
+
if (!("companyCreditAmount" in value) || value["companyCreditAmount"] === void 0)
|
|
1817
|
+
return false;
|
|
1818
|
+
if (!("creditAmount" in value) || value["creditAmount"] === void 0)
|
|
1819
|
+
return false;
|
|
1820
|
+
if (!("creditId" in value) || value["creditId"] === void 0) return false;
|
|
1821
|
+
if (!("creditName" in value) || value["creditName"] === void 0)
|
|
1822
|
+
return false;
|
|
1823
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1824
|
+
if (!("scaling" in value) || value["scaling"] === void 0) return false;
|
|
1825
|
+
return true;
|
|
1826
|
+
}
|
|
1827
|
+
function CatalogCreditGrantResponseDataFromJSON(json) {
|
|
1828
|
+
return CatalogCreditGrantResponseDataFromJSONTyped(json, false);
|
|
1829
|
+
}
|
|
1830
|
+
function CatalogCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1831
|
+
if (json == null) {
|
|
1832
|
+
return json;
|
|
1833
|
+
}
|
|
1834
|
+
return {
|
|
1835
|
+
companyCreditAmount: json["company_credit_amount"],
|
|
1836
|
+
creditAmount: json["credit_amount"],
|
|
1837
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
1838
|
+
creditId: json["credit_id"],
|
|
1839
|
+
creditName: json["credit_name"],
|
|
1840
|
+
creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
|
|
1841
|
+
creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
|
|
1842
|
+
id: json["id"],
|
|
1843
|
+
licenseId: json["license_id"] == null ? void 0 : json["license_id"],
|
|
1844
|
+
resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
|
|
1845
|
+
scaling: PlanCreditGrantScalingFromJSON2(json["scaling"])
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
function CatalogCreditGrantResponseDataToJSON(json) {
|
|
1849
|
+
return CatalogCreditGrantResponseDataToJSONTyped(json, false);
|
|
1850
|
+
}
|
|
1851
|
+
function CatalogCreditGrantResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1852
|
+
if (value == null) {
|
|
1853
|
+
return value;
|
|
1854
|
+
}
|
|
1855
|
+
return {
|
|
1856
|
+
company_credit_amount: value["companyCreditAmount"],
|
|
1857
|
+
credit_amount: value["creditAmount"],
|
|
1858
|
+
credit_icon: value["creditIcon"],
|
|
1859
|
+
credit_id: value["creditId"],
|
|
1860
|
+
credit_name: value["creditName"],
|
|
1861
|
+
credit_plural_name: value["creditPluralName"],
|
|
1862
|
+
credit_singular_name: value["creditSingularName"],
|
|
1863
|
+
id: value["id"],
|
|
1864
|
+
license_id: value["licenseId"],
|
|
1865
|
+
reset_cadence: BillingPlanCreditGrantResetCadenceToJSON2(
|
|
1866
|
+
value["resetCadence"]
|
|
1867
|
+
),
|
|
1868
|
+
scaling: PlanCreditGrantScalingToJSON2(value["scaling"])
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
function instanceOfCatalogPriceTierResponseData(value) {
|
|
1872
|
+
if (!("from" in value) || value["from"] === void 0) return false;
|
|
1873
|
+
return true;
|
|
1874
|
+
}
|
|
1875
|
+
function CatalogPriceTierResponseDataFromJSON(json) {
|
|
1876
|
+
return CatalogPriceTierResponseDataFromJSONTyped(json, false);
|
|
1877
|
+
}
|
|
1878
|
+
function CatalogPriceTierResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1879
|
+
if (json == null) {
|
|
1880
|
+
return json;
|
|
1881
|
+
}
|
|
1882
|
+
return {
|
|
1883
|
+
flatPrice: json["flat_price"] == null ? void 0 : json["flat_price"],
|
|
1884
|
+
from: json["from"],
|
|
1885
|
+
perUnitPrice: json["per_unit_price"] == null ? void 0 : json["per_unit_price"],
|
|
1886
|
+
perUnitPriceDecimal: json["per_unit_price_decimal"] == null ? void 0 : json["per_unit_price_decimal"],
|
|
1887
|
+
to: json["to"] == null ? void 0 : json["to"]
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
function CatalogPriceTierResponseDataToJSON(json) {
|
|
1891
|
+
return CatalogPriceTierResponseDataToJSONTyped(json, false);
|
|
1892
|
+
}
|
|
1893
|
+
function CatalogPriceTierResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1894
|
+
if (value == null) {
|
|
1895
|
+
return value;
|
|
1896
|
+
}
|
|
1897
|
+
return {
|
|
1898
|
+
flat_price: value["flatPrice"],
|
|
1899
|
+
from: value["from"],
|
|
1900
|
+
per_unit_price: value["perUnitPrice"],
|
|
1901
|
+
per_unit_price_decimal: value["perUnitPriceDecimal"],
|
|
1902
|
+
to: value["to"]
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function instanceOfCatalogPriceResponseData(value) {
|
|
1906
|
+
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
1907
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1908
|
+
if (!("interval" in value) || value["interval"] === void 0) return false;
|
|
1909
|
+
if (!("intervalCount" in value) || value["intervalCount"] === void 0)
|
|
1910
|
+
return false;
|
|
1911
|
+
if (!("packageSize" in value) || value["packageSize"] === void 0)
|
|
1912
|
+
return false;
|
|
1913
|
+
if (!("price" in value) || value["price"] === void 0) return false;
|
|
1914
|
+
if (!("priceTiers" in value) || value["priceTiers"] === void 0)
|
|
1915
|
+
return false;
|
|
1916
|
+
if (!("scheme" in value) || value["scheme"] === void 0) return false;
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
function CatalogPriceResponseDataFromJSON(json) {
|
|
1920
|
+
return CatalogPriceResponseDataFromJSONTyped(json, false);
|
|
1921
|
+
}
|
|
1922
|
+
function CatalogPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1923
|
+
if (json == null) {
|
|
1924
|
+
return json;
|
|
1925
|
+
}
|
|
1926
|
+
return {
|
|
1927
|
+
currency: json["currency"],
|
|
1928
|
+
id: json["id"],
|
|
1929
|
+
interval: BillingProductPriceIntervalFromJSON2(json["interval"]),
|
|
1930
|
+
intervalCount: json["interval_count"],
|
|
1931
|
+
overageUnitPriceDecimal: json["overage_unit_price_decimal"] == null ? void 0 : json["overage_unit_price_decimal"],
|
|
1932
|
+
packageSize: json["package_size"],
|
|
1933
|
+
price: json["price"],
|
|
1934
|
+
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
1935
|
+
priceTiers: json["price_tiers"].map(
|
|
1936
|
+
CatalogPriceTierResponseDataFromJSON
|
|
1937
|
+
),
|
|
1938
|
+
scheme: BillingPriceSchemeFromJSON2(json["scheme"]),
|
|
1939
|
+
tiersMode: json["tiers_mode"] == null ? void 0 : BillingTiersModeFromJSON2(json["tiers_mode"])
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
function CatalogPriceResponseDataToJSON(json) {
|
|
1943
|
+
return CatalogPriceResponseDataToJSONTyped(json, false);
|
|
1944
|
+
}
|
|
1945
|
+
function CatalogPriceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1946
|
+
if (value == null) {
|
|
1947
|
+
return value;
|
|
1948
|
+
}
|
|
1949
|
+
return {
|
|
1950
|
+
currency: value["currency"],
|
|
1951
|
+
id: value["id"],
|
|
1952
|
+
interval: BillingProductPriceIntervalToJSON2(value["interval"]),
|
|
1953
|
+
interval_count: value["intervalCount"],
|
|
1954
|
+
overage_unit_price_decimal: value["overageUnitPriceDecimal"],
|
|
1955
|
+
package_size: value["packageSize"],
|
|
1956
|
+
price: value["price"],
|
|
1957
|
+
price_decimal: value["priceDecimal"],
|
|
1958
|
+
price_tiers: value["priceTiers"].map(
|
|
1959
|
+
CatalogPriceTierResponseDataToJSON
|
|
1960
|
+
),
|
|
1961
|
+
scheme: BillingPriceSchemeToJSON2(value["scheme"]),
|
|
1962
|
+
tiers_mode: BillingTiersModeToJSON2(value["tiersMode"])
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1466
1965
|
function instanceOfCompanyDiscountResponseData(value) {
|
|
1467
1966
|
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1468
1967
|
return false;
|
|
@@ -1503,6 +2002,394 @@ function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1503
2002
|
percent_off: value["percentOff"]
|
|
1504
2003
|
};
|
|
1505
2004
|
}
|
|
2005
|
+
var EntitlementValueType = {
|
|
2006
|
+
Boolean: "boolean",
|
|
2007
|
+
Credit: "credit",
|
|
2008
|
+
Numeric: "numeric",
|
|
2009
|
+
Trait: "trait",
|
|
2010
|
+
Unknown: "unknown",
|
|
2011
|
+
Unlimited: "unlimited"
|
|
2012
|
+
};
|
|
2013
|
+
function instanceOfEntitlementValueType(value) {
|
|
2014
|
+
for (const key in EntitlementValueType) {
|
|
2015
|
+
if (Object.prototype.hasOwnProperty.call(EntitlementValueType, key)) {
|
|
2016
|
+
if (EntitlementValueType[key] === value) {
|
|
2017
|
+
return true;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return false;
|
|
2022
|
+
}
|
|
2023
|
+
function EntitlementValueTypeFromJSON2(json) {
|
|
2024
|
+
return EntitlementValueTypeFromJSONTyped4(json, false);
|
|
2025
|
+
}
|
|
2026
|
+
function EntitlementValueTypeFromJSONTyped4(json, ignoreDiscriminator) {
|
|
2027
|
+
return json;
|
|
2028
|
+
}
|
|
2029
|
+
function EntitlementValueTypeToJSON2(value) {
|
|
2030
|
+
return value;
|
|
2031
|
+
}
|
|
2032
|
+
function EntitlementValueTypeToJSONTyped3(value, ignoreDiscriminator) {
|
|
2033
|
+
return value;
|
|
2034
|
+
}
|
|
2035
|
+
var FeatureType = {
|
|
2036
|
+
Boolean: "boolean",
|
|
2037
|
+
Event: "event",
|
|
2038
|
+
License: "license",
|
|
2039
|
+
Trait: "trait"
|
|
2040
|
+
};
|
|
2041
|
+
function instanceOfFeatureType(value) {
|
|
2042
|
+
for (const key in FeatureType) {
|
|
2043
|
+
if (Object.prototype.hasOwnProperty.call(FeatureType, key)) {
|
|
2044
|
+
if (FeatureType[key] === value) {
|
|
2045
|
+
return true;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
return false;
|
|
2050
|
+
}
|
|
2051
|
+
function FeatureTypeFromJSON2(json) {
|
|
2052
|
+
return FeatureTypeFromJSONTyped3(json, false);
|
|
2053
|
+
}
|
|
2054
|
+
function FeatureTypeFromJSONTyped3(json, ignoreDiscriminator) {
|
|
2055
|
+
return json;
|
|
2056
|
+
}
|
|
2057
|
+
function FeatureTypeToJSON2(value) {
|
|
2058
|
+
return value;
|
|
2059
|
+
}
|
|
2060
|
+
function FeatureTypeToJSONTyped3(value, ignoreDiscriminator) {
|
|
2061
|
+
return value;
|
|
2062
|
+
}
|
|
2063
|
+
var MetricPeriodMonthReset = {
|
|
2064
|
+
BillingCycle: "billing_cycle",
|
|
2065
|
+
FirstOfMonth: "first_of_month"
|
|
2066
|
+
};
|
|
2067
|
+
function instanceOfMetricPeriodMonthReset(value) {
|
|
2068
|
+
for (const key in MetricPeriodMonthReset) {
|
|
2069
|
+
if (Object.prototype.hasOwnProperty.call(MetricPeriodMonthReset, key)) {
|
|
2070
|
+
if (MetricPeriodMonthReset[key] === value) {
|
|
2071
|
+
return true;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
return false;
|
|
2076
|
+
}
|
|
2077
|
+
function MetricPeriodMonthResetFromJSON2(json) {
|
|
2078
|
+
return MetricPeriodMonthResetFromJSONTyped6(json, false);
|
|
2079
|
+
}
|
|
2080
|
+
function MetricPeriodMonthResetFromJSONTyped6(json, ignoreDiscriminator) {
|
|
2081
|
+
return json;
|
|
2082
|
+
}
|
|
2083
|
+
function MetricPeriodMonthResetToJSON2(value) {
|
|
2084
|
+
return value;
|
|
2085
|
+
}
|
|
2086
|
+
function MetricPeriodMonthResetToJSONTyped5(value, ignoreDiscriminator) {
|
|
2087
|
+
return value;
|
|
2088
|
+
}
|
|
2089
|
+
var MetricPeriod = {
|
|
2090
|
+
AllTime: "all_time",
|
|
2091
|
+
CurrentDay: "current_day",
|
|
2092
|
+
CurrentMonth: "current_month",
|
|
2093
|
+
CurrentWeek: "current_week"
|
|
2094
|
+
};
|
|
2095
|
+
function instanceOfMetricPeriod(value) {
|
|
2096
|
+
for (const key in MetricPeriod) {
|
|
2097
|
+
if (Object.prototype.hasOwnProperty.call(MetricPeriod, key)) {
|
|
2098
|
+
if (MetricPeriod[key] === value) {
|
|
2099
|
+
return true;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
return false;
|
|
2104
|
+
}
|
|
2105
|
+
function MetricPeriodFromJSON2(json) {
|
|
2106
|
+
return MetricPeriodFromJSONTyped7(json, false);
|
|
2107
|
+
}
|
|
2108
|
+
function MetricPeriodFromJSONTyped7(json, ignoreDiscriminator) {
|
|
2109
|
+
return json;
|
|
2110
|
+
}
|
|
2111
|
+
function MetricPeriodToJSON2(value) {
|
|
2112
|
+
return value;
|
|
2113
|
+
}
|
|
2114
|
+
function MetricPeriodToJSONTyped6(value, ignoreDiscriminator) {
|
|
2115
|
+
return value;
|
|
2116
|
+
}
|
|
2117
|
+
var EntitlementPriceBehavior = {
|
|
2118
|
+
CreditBurndown: "credit_burndown",
|
|
2119
|
+
Overage: "overage",
|
|
2120
|
+
PayAsYouGo: "pay_as_you_go",
|
|
2121
|
+
PayInAdvance: "pay_in_advance",
|
|
2122
|
+
Tier: "tier"
|
|
2123
|
+
};
|
|
2124
|
+
function instanceOfEntitlementPriceBehavior(value) {
|
|
2125
|
+
for (const key in EntitlementPriceBehavior) {
|
|
2126
|
+
if (Object.prototype.hasOwnProperty.call(EntitlementPriceBehavior, key)) {
|
|
2127
|
+
if (EntitlementPriceBehavior[key] === value) {
|
|
2128
|
+
return true;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
return false;
|
|
2133
|
+
}
|
|
2134
|
+
function EntitlementPriceBehaviorFromJSON2(json) {
|
|
2135
|
+
return EntitlementPriceBehaviorFromJSONTyped2(json, false);
|
|
2136
|
+
}
|
|
2137
|
+
function EntitlementPriceBehaviorFromJSONTyped2(json, ignoreDiscriminator) {
|
|
2138
|
+
return json;
|
|
2139
|
+
}
|
|
2140
|
+
function EntitlementPriceBehaviorToJSON2(value) {
|
|
2141
|
+
return value;
|
|
2142
|
+
}
|
|
2143
|
+
function EntitlementPriceBehaviorToJSONTyped2(value, ignoreDiscriminator) {
|
|
2144
|
+
return value;
|
|
2145
|
+
}
|
|
2146
|
+
var EntitlementType = {
|
|
2147
|
+
CompanyOverride: "company_override",
|
|
2148
|
+
PlanEntitlement: "plan_entitlement",
|
|
2149
|
+
Unknown: "unknown"
|
|
2150
|
+
};
|
|
2151
|
+
function instanceOfEntitlementType(value) {
|
|
2152
|
+
for (const key in EntitlementType) {
|
|
2153
|
+
if (Object.prototype.hasOwnProperty.call(EntitlementType, key)) {
|
|
2154
|
+
if (EntitlementType[key] === value) {
|
|
2155
|
+
return true;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
return false;
|
|
2160
|
+
}
|
|
2161
|
+
function EntitlementTypeFromJSON(json) {
|
|
2162
|
+
return EntitlementTypeFromJSONTyped(json, false);
|
|
2163
|
+
}
|
|
2164
|
+
function EntitlementTypeFromJSONTyped(json, ignoreDiscriminator) {
|
|
2165
|
+
return json;
|
|
2166
|
+
}
|
|
2167
|
+
function EntitlementTypeToJSON(value) {
|
|
2168
|
+
return value;
|
|
2169
|
+
}
|
|
2170
|
+
function EntitlementTypeToJSONTyped(value, ignoreDiscriminator) {
|
|
2171
|
+
return value;
|
|
2172
|
+
}
|
|
2173
|
+
function instanceOfCompanyFeatureUsageResponseData(value) {
|
|
2174
|
+
if (!("access" in value) || value["access"] === void 0) return false;
|
|
2175
|
+
if (!("entitlementType" in value) || value["entitlementType"] === void 0)
|
|
2176
|
+
return false;
|
|
2177
|
+
if (!("featureDescription" in value) || value["featureDescription"] === void 0)
|
|
2178
|
+
return false;
|
|
2179
|
+
if (!("featureIcon" in value) || value["featureIcon"] === void 0)
|
|
2180
|
+
return false;
|
|
2181
|
+
if (!("featureId" in value) || value["featureId"] === void 0) return false;
|
|
2182
|
+
if (!("featureName" in value) || value["featureName"] === void 0)
|
|
2183
|
+
return false;
|
|
2184
|
+
if (!("featureType" in value) || value["featureType"] === void 0)
|
|
2185
|
+
return false;
|
|
2186
|
+
if (!("perLicenseCreditGrants" in value) || value["perLicenseCreditGrants"] === void 0)
|
|
2187
|
+
return false;
|
|
2188
|
+
if (!("valueType" in value) || value["valueType"] === void 0) return false;
|
|
2189
|
+
return true;
|
|
2190
|
+
}
|
|
2191
|
+
function CompanyFeatureUsageResponseDataFromJSON(json) {
|
|
2192
|
+
return CompanyFeatureUsageResponseDataFromJSONTyped(json, false);
|
|
2193
|
+
}
|
|
2194
|
+
function CompanyFeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
2195
|
+
if (json == null) {
|
|
2196
|
+
return json;
|
|
2197
|
+
}
|
|
2198
|
+
return {
|
|
2199
|
+
access: json["access"],
|
|
2200
|
+
allocation: json["allocation"] == null ? void 0 : json["allocation"],
|
|
2201
|
+
companyOverrideId: json["company_override_id"] == null ? void 0 : json["company_override_id"],
|
|
2202
|
+
consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
|
|
2203
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
2204
|
+
creditId: json["credit_id"] == null ? void 0 : json["credit_id"],
|
|
2205
|
+
creditName: json["credit_name"] == null ? void 0 : json["credit_name"],
|
|
2206
|
+
creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
|
|
2207
|
+
creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
|
|
2208
|
+
currentCost: json["current_cost"] == null ? void 0 : json["current_cost"],
|
|
2209
|
+
entitlementType: EntitlementTypeFromJSON(json["entitlement_type"]),
|
|
2210
|
+
expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
|
|
2211
|
+
featureDescription: json["feature_description"],
|
|
2212
|
+
featureIcon: json["feature_icon"],
|
|
2213
|
+
featureId: json["feature_id"],
|
|
2214
|
+
featureName: json["feature_name"],
|
|
2215
|
+
featurePluralName: json["feature_plural_name"] == null ? void 0 : json["feature_plural_name"],
|
|
2216
|
+
featureSingularName: json["feature_singular_name"] == null ? void 0 : json["feature_singular_name"],
|
|
2217
|
+
featureType: FeatureTypeFromJSON2(json["feature_type"]),
|
|
2218
|
+
licenseId: json["license_id"] == null ? void 0 : json["license_id"],
|
|
2219
|
+
metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON2(json["metric_period"]),
|
|
2220
|
+
metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON2(json["metric_period_month_reset"]),
|
|
2221
|
+
perLicenseCreditGrants: json["per_license_credit_grants"].map(CatalogCreditGrantResponseDataFromJSON),
|
|
2222
|
+
planEntitlementId: json["plan_entitlement_id"] == null ? void 0 : json["plan_entitlement_id"],
|
|
2223
|
+
price: json["price"] == null ? void 0 : CatalogPriceResponseDataFromJSON(json["price"]),
|
|
2224
|
+
priceBehavior: json["price_behavior"] == null ? void 0 : EntitlementPriceBehaviorFromJSON2(json["price_behavior"]),
|
|
2225
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
2226
|
+
softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
|
|
2227
|
+
usage: json["usage"] == null ? void 0 : json["usage"],
|
|
2228
|
+
valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
|
|
2229
|
+
valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
|
|
2230
|
+
valueType: EntitlementValueTypeFromJSON2(json["value_type"]),
|
|
2231
|
+
warningThreshold: json["warning_threshold"] == null ? void 0 : json["warning_threshold"]
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
function CompanyFeatureUsageResponseDataToJSON(json) {
|
|
2235
|
+
return CompanyFeatureUsageResponseDataToJSONTyped(json, false);
|
|
2236
|
+
}
|
|
2237
|
+
function CompanyFeatureUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2238
|
+
if (value == null) {
|
|
2239
|
+
return value;
|
|
2240
|
+
}
|
|
2241
|
+
return {
|
|
2242
|
+
access: value["access"],
|
|
2243
|
+
allocation: value["allocation"],
|
|
2244
|
+
company_override_id: value["companyOverrideId"],
|
|
2245
|
+
consumption_rate: value["consumptionRate"],
|
|
2246
|
+
credit_icon: value["creditIcon"],
|
|
2247
|
+
credit_id: value["creditId"],
|
|
2248
|
+
credit_name: value["creditName"],
|
|
2249
|
+
credit_plural_name: value["creditPluralName"],
|
|
2250
|
+
credit_singular_name: value["creditSingularName"],
|
|
2251
|
+
current_cost: value["currentCost"],
|
|
2252
|
+
entitlement_type: EntitlementTypeToJSON(value["entitlementType"]),
|
|
2253
|
+
expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
|
|
2254
|
+
feature_description: value["featureDescription"],
|
|
2255
|
+
feature_icon: value["featureIcon"],
|
|
2256
|
+
feature_id: value["featureId"],
|
|
2257
|
+
feature_name: value["featureName"],
|
|
2258
|
+
feature_plural_name: value["featurePluralName"],
|
|
2259
|
+
feature_singular_name: value["featureSingularName"],
|
|
2260
|
+
feature_type: FeatureTypeToJSON2(value["featureType"]),
|
|
2261
|
+
license_id: value["licenseId"],
|
|
2262
|
+
metric_period: MetricPeriodToJSON2(value["metricPeriod"]),
|
|
2263
|
+
metric_period_month_reset: MetricPeriodMonthResetToJSON2(
|
|
2264
|
+
value["metricPeriodMonthReset"]
|
|
2265
|
+
),
|
|
2266
|
+
per_license_credit_grants: value["perLicenseCreditGrants"].map(CatalogCreditGrantResponseDataToJSON),
|
|
2267
|
+
plan_entitlement_id: value["planEntitlementId"],
|
|
2268
|
+
price: CatalogPriceResponseDataToJSON(value["price"]),
|
|
2269
|
+
price_behavior: EntitlementPriceBehaviorToJSON2(value["priceBehavior"]),
|
|
2270
|
+
resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
|
|
2271
|
+
soft_limit: value["softLimit"],
|
|
2272
|
+
usage: value["usage"],
|
|
2273
|
+
value_bool: value["valueBool"],
|
|
2274
|
+
value_numeric: value["valueNumeric"],
|
|
2275
|
+
value_type: EntitlementValueTypeToJSON2(value["valueType"]),
|
|
2276
|
+
warning_threshold: value["warningThreshold"]
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2279
|
+
function instanceOfCompanyFeatureUsageListResponseData(value) {
|
|
2280
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
2281
|
+
if (!("features" in value) || value["features"] === void 0) return false;
|
|
2282
|
+
return true;
|
|
2283
|
+
}
|
|
2284
|
+
function CompanyFeatureUsageListResponseDataFromJSON(json) {
|
|
2285
|
+
return CompanyFeatureUsageListResponseDataFromJSONTyped(json, false);
|
|
2286
|
+
}
|
|
2287
|
+
function CompanyFeatureUsageListResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
2288
|
+
if (json == null) {
|
|
2289
|
+
return json;
|
|
2290
|
+
}
|
|
2291
|
+
return {
|
|
2292
|
+
count: json["count"],
|
|
2293
|
+
features: json["features"].map(
|
|
2294
|
+
CompanyFeatureUsageResponseDataFromJSON
|
|
2295
|
+
)
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
function CompanyFeatureUsageListResponseDataToJSON(json) {
|
|
2299
|
+
return CompanyFeatureUsageListResponseDataToJSONTyped(json, false);
|
|
2300
|
+
}
|
|
2301
|
+
function CompanyFeatureUsageListResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2302
|
+
if (value == null) {
|
|
2303
|
+
return value;
|
|
2304
|
+
}
|
|
2305
|
+
return {
|
|
2306
|
+
count: value["count"],
|
|
2307
|
+
features: value["features"].map(
|
|
2308
|
+
CompanyFeatureUsageResponseDataToJSON
|
|
2309
|
+
)
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
function instanceOfCompanyUserUsageResponseData(value) {
|
|
2313
|
+
if (!("lastSeen" in value) || value["lastSeen"] === void 0) return false;
|
|
2314
|
+
if (!("share" in value) || value["share"] === void 0) return false;
|
|
2315
|
+
if (!("usage" in value) || value["usage"] === void 0) return false;
|
|
2316
|
+
if (!("userId" in value) || value["userId"] === void 0) return false;
|
|
2317
|
+
return true;
|
|
2318
|
+
}
|
|
2319
|
+
function CompanyUserUsageResponseDataFromJSON(json) {
|
|
2320
|
+
return CompanyUserUsageResponseDataFromJSONTyped(json, false);
|
|
2321
|
+
}
|
|
2322
|
+
function CompanyUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
2323
|
+
if (json == null) {
|
|
2324
|
+
return json;
|
|
2325
|
+
}
|
|
2326
|
+
return {
|
|
2327
|
+
lastSeen: new Date(json["last_seen"]),
|
|
2328
|
+
name: json["name"] == null ? void 0 : json["name"],
|
|
2329
|
+
share: json["share"],
|
|
2330
|
+
usage: json["usage"],
|
|
2331
|
+
userId: json["user_id"]
|
|
2332
|
+
};
|
|
2333
|
+
}
|
|
2334
|
+
function CompanyUserUsageResponseDataToJSON(json) {
|
|
2335
|
+
return CompanyUserUsageResponseDataToJSONTyped(json, false);
|
|
2336
|
+
}
|
|
2337
|
+
function CompanyUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2338
|
+
if (value == null) {
|
|
2339
|
+
return value;
|
|
2340
|
+
}
|
|
2341
|
+
return {
|
|
2342
|
+
last_seen: value["lastSeen"].toISOString(),
|
|
2343
|
+
name: value["name"],
|
|
2344
|
+
share: value["share"],
|
|
2345
|
+
usage: value["usage"],
|
|
2346
|
+
user_id: value["userId"]
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
function instanceOfCompanyFeatureUserUsageResponseData(value) {
|
|
2350
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
2351
|
+
if (!("endTime" in value) || value["endTime"] === void 0) return false;
|
|
2352
|
+
if (!("startTime" in value) || value["startTime"] === void 0) return false;
|
|
2353
|
+
if (!("total" in value) || value["total"] === void 0) return false;
|
|
2354
|
+
if (!("users" in value) || value["users"] === void 0) return false;
|
|
2355
|
+
return true;
|
|
2356
|
+
}
|
|
2357
|
+
function CompanyFeatureUserUsageResponseDataFromJSON(json) {
|
|
2358
|
+
return CompanyFeatureUserUsageResponseDataFromJSONTyped(json, false);
|
|
2359
|
+
}
|
|
2360
|
+
function CompanyFeatureUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
2361
|
+
if (json == null) {
|
|
2362
|
+
return json;
|
|
2363
|
+
}
|
|
2364
|
+
return {
|
|
2365
|
+
count: json["count"],
|
|
2366
|
+
endTime: new Date(json["end_time"]),
|
|
2367
|
+
startTime: new Date(json["start_time"]),
|
|
2368
|
+
total: json["total"],
|
|
2369
|
+
unattributed: json["unattributed"] == null ? void 0 : json["unattributed"],
|
|
2370
|
+
users: json["users"].map(
|
|
2371
|
+
CompanyUserUsageResponseDataFromJSON
|
|
2372
|
+
)
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
function CompanyFeatureUserUsageResponseDataToJSON(json) {
|
|
2376
|
+
return CompanyFeatureUserUsageResponseDataToJSONTyped(json, false);
|
|
2377
|
+
}
|
|
2378
|
+
function CompanyFeatureUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2379
|
+
if (value == null) {
|
|
2380
|
+
return value;
|
|
2381
|
+
}
|
|
2382
|
+
return {
|
|
2383
|
+
count: value["count"],
|
|
2384
|
+
end_time: value["endTime"].toISOString(),
|
|
2385
|
+
start_time: value["startTime"].toISOString(),
|
|
2386
|
+
total: value["total"],
|
|
2387
|
+
unattributed: value["unattributed"],
|
|
2388
|
+
users: value["users"].map(
|
|
2389
|
+
CompanyUserUsageResponseDataToJSON
|
|
2390
|
+
)
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
1506
2393
|
var InvoiceStatus = {
|
|
1507
2394
|
Draft: "draft",
|
|
1508
2395
|
Open: "open",
|
|
@@ -1862,6 +2749,91 @@ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1862
2749
|
params: value["params"]
|
|
1863
2750
|
};
|
|
1864
2751
|
}
|
|
2752
|
+
function instanceOfGetCompanyFeatureUsageResponse(value) {
|
|
2753
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2754
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2755
|
+
return true;
|
|
2756
|
+
}
|
|
2757
|
+
function GetCompanyFeatureUsageResponseFromJSON(json) {
|
|
2758
|
+
return GetCompanyFeatureUsageResponseFromJSONTyped(json, false);
|
|
2759
|
+
}
|
|
2760
|
+
function GetCompanyFeatureUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2761
|
+
if (json == null) {
|
|
2762
|
+
return json;
|
|
2763
|
+
}
|
|
2764
|
+
return {
|
|
2765
|
+
data: CompanyFeatureUsageListResponseDataFromJSON(json["data"]),
|
|
2766
|
+
params: json["params"]
|
|
2767
|
+
};
|
|
2768
|
+
}
|
|
2769
|
+
function GetCompanyFeatureUsageResponseToJSON(json) {
|
|
2770
|
+
return GetCompanyFeatureUsageResponseToJSONTyped(json, false);
|
|
2771
|
+
}
|
|
2772
|
+
function GetCompanyFeatureUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2773
|
+
if (value == null) {
|
|
2774
|
+
return value;
|
|
2775
|
+
}
|
|
2776
|
+
return {
|
|
2777
|
+
data: CompanyFeatureUsageListResponseDataToJSON(value["data"]),
|
|
2778
|
+
params: value["params"]
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
function instanceOfGetCompanyFeatureUserUsageParams(value) {
|
|
2782
|
+
return true;
|
|
2783
|
+
}
|
|
2784
|
+
function GetCompanyFeatureUserUsageParamsFromJSON(json) {
|
|
2785
|
+
return GetCompanyFeatureUserUsageParamsFromJSONTyped(json, false);
|
|
2786
|
+
}
|
|
2787
|
+
function GetCompanyFeatureUserUsageParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
2788
|
+
if (json == null) {
|
|
2789
|
+
return json;
|
|
2790
|
+
}
|
|
2791
|
+
return {
|
|
2792
|
+
limit: json["limit"] == null ? void 0 : json["limit"],
|
|
2793
|
+
offset: json["offset"] == null ? void 0 : json["offset"]
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
function GetCompanyFeatureUserUsageParamsToJSON(json) {
|
|
2797
|
+
return GetCompanyFeatureUserUsageParamsToJSONTyped(json, false);
|
|
2798
|
+
}
|
|
2799
|
+
function GetCompanyFeatureUserUsageParamsToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2800
|
+
if (value == null) {
|
|
2801
|
+
return value;
|
|
2802
|
+
}
|
|
2803
|
+
return {
|
|
2804
|
+
limit: value["limit"],
|
|
2805
|
+
offset: value["offset"]
|
|
2806
|
+
};
|
|
2807
|
+
}
|
|
2808
|
+
function instanceOfGetCompanyFeatureUserUsageResponse(value) {
|
|
2809
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2810
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2811
|
+
return true;
|
|
2812
|
+
}
|
|
2813
|
+
function GetCompanyFeatureUserUsageResponseFromJSON(json) {
|
|
2814
|
+
return GetCompanyFeatureUserUsageResponseFromJSONTyped(json, false);
|
|
2815
|
+
}
|
|
2816
|
+
function GetCompanyFeatureUserUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2817
|
+
if (json == null) {
|
|
2818
|
+
return json;
|
|
2819
|
+
}
|
|
2820
|
+
return {
|
|
2821
|
+
data: CompanyFeatureUserUsageResponseDataFromJSON(json["data"]),
|
|
2822
|
+
params: GetCompanyFeatureUserUsageParamsFromJSON(json["params"])
|
|
2823
|
+
};
|
|
2824
|
+
}
|
|
2825
|
+
function GetCompanyFeatureUserUsageResponseToJSON(json) {
|
|
2826
|
+
return GetCompanyFeatureUserUsageResponseToJSONTyped(json, false);
|
|
2827
|
+
}
|
|
2828
|
+
function GetCompanyFeatureUserUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2829
|
+
if (value == null) {
|
|
2830
|
+
return value;
|
|
2831
|
+
}
|
|
2832
|
+
return {
|
|
2833
|
+
data: CompanyFeatureUserUsageResponseDataToJSON(value["data"]),
|
|
2834
|
+
params: GetCompanyFeatureUserUsageParamsToJSON(value["params"])
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
1865
2837
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1866
2838
|
return true;
|
|
1867
2839
|
}
|
|
@@ -2463,6 +3435,36 @@ var SchematicBillingClient = class {
|
|
|
2463
3435
|
method: "DELETE"
|
|
2464
3436
|
}).then(() => void 0);
|
|
2465
3437
|
}
|
|
3438
|
+
fetchFeatureUsage() {
|
|
3439
|
+
const path = "/company/usage";
|
|
3440
|
+
return this.session.request(path).then((body) => {
|
|
3441
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
3442
|
+
throw new Error(`Malformed response from ${path}`);
|
|
3443
|
+
}
|
|
3444
|
+
const data = body.data;
|
|
3445
|
+
if (data == null || data.features == null) {
|
|
3446
|
+
return [];
|
|
3447
|
+
}
|
|
3448
|
+
return GetCompanyFeatureUsageResponseFromJSON(body).data.features;
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3451
|
+
fetchFeatureUserUsage(params) {
|
|
3452
|
+
const query = new URLSearchParams();
|
|
3453
|
+
if (params.limit !== void 0) {
|
|
3454
|
+
query.set("limit", String(params.limit));
|
|
3455
|
+
}
|
|
3456
|
+
if (params.offset !== void 0) {
|
|
3457
|
+
query.set("offset", String(params.offset));
|
|
3458
|
+
}
|
|
3459
|
+
const search = query.toString();
|
|
3460
|
+
const path = `/company/usage/${encodeURIComponent(params.featureId)}/users${search === "" ? "" : `?${search}`}`;
|
|
3461
|
+
return this.session.request(path).then((body) => {
|
|
3462
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
3463
|
+
throw new Error(`Malformed response from ${path}`);
|
|
3464
|
+
}
|
|
3465
|
+
return GetCompanyFeatureUserUsageResponseFromJSON(body).data;
|
|
3466
|
+
});
|
|
3467
|
+
}
|
|
2466
3468
|
};
|
|
2467
3469
|
var anonymousIdKey = "schematicId";
|
|
2468
3470
|
var flagStateCachePrefix = "schematicCache";
|
|
@@ -2470,9 +3472,41 @@ var flagStateCacheMaxContexts = 10;
|
|
|
2470
3472
|
var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
2471
3473
|
var emptyCreditBalances = Object.freeze({});
|
|
2472
3474
|
var emptyCreditSpendPolicies = [];
|
|
3475
|
+
function extractEventContext(event) {
|
|
3476
|
+
const body = event.body;
|
|
3477
|
+
const context = {};
|
|
3478
|
+
switch (event.type) {
|
|
3479
|
+
case "identify":
|
|
3480
|
+
if (body.keys != null) {
|
|
3481
|
+
context.user = body.keys;
|
|
3482
|
+
}
|
|
3483
|
+
if (body.company?.keys != null) {
|
|
3484
|
+
context.company = body.company.keys;
|
|
3485
|
+
}
|
|
3486
|
+
break;
|
|
3487
|
+
case "track":
|
|
3488
|
+
if (body.company != null) {
|
|
3489
|
+
context.company = body.company;
|
|
3490
|
+
}
|
|
3491
|
+
if (body.user != null) {
|
|
3492
|
+
context.user = body.user;
|
|
3493
|
+
}
|
|
3494
|
+
break;
|
|
3495
|
+
case "flag_check":
|
|
3496
|
+
if (body.req_company != null) {
|
|
3497
|
+
context.company = body.req_company;
|
|
3498
|
+
}
|
|
3499
|
+
if (body.req_user != null) {
|
|
3500
|
+
context.user = body.req_user;
|
|
3501
|
+
}
|
|
3502
|
+
break;
|
|
3503
|
+
}
|
|
3504
|
+
return context;
|
|
3505
|
+
}
|
|
2473
3506
|
var Schematic = class {
|
|
2474
3507
|
_additionalHeaders = {};
|
|
2475
3508
|
apiKey;
|
|
3509
|
+
contextSignatureManager;
|
|
2476
3510
|
_apiUrl = "https://api.schematichq.com";
|
|
2477
3511
|
conn = null;
|
|
2478
3512
|
context = {};
|
|
@@ -2559,6 +3593,12 @@ var Schematic = class {
|
|
|
2559
3593
|
"X-Schematic-Client-Version": `schematic-js@${version}`,
|
|
2560
3594
|
...options?.additionalHeaders ?? {}
|
|
2561
3595
|
};
|
|
3596
|
+
if (options?.getContextSignature !== void 0) {
|
|
3597
|
+
this.contextSignatureManager = new ContextSignatureManager(
|
|
3598
|
+
options.getContextSignature,
|
|
3599
|
+
this.debug.bind(this)
|
|
3600
|
+
);
|
|
3601
|
+
}
|
|
2562
3602
|
if (options?.storage) {
|
|
2563
3603
|
this.storage = options.storage;
|
|
2564
3604
|
} else {
|
|
@@ -2728,12 +3768,14 @@ var Schematic = class {
|
|
|
2728
3768
|
}
|
|
2729
3769
|
if (!this.useWebSocket) {
|
|
2730
3770
|
const requestUrl = `${this._apiUrl}/flags/${key}/check`;
|
|
3771
|
+
const sigHeaders = await this.contextSignatureHeaders(context);
|
|
2731
3772
|
return fetch(requestUrl, {
|
|
2732
3773
|
method: "POST",
|
|
2733
3774
|
headers: {
|
|
2734
3775
|
...this._additionalHeaders ?? {},
|
|
2735
3776
|
"Content-Type": "application/json;charset=UTF-8",
|
|
2736
|
-
"X-Schematic-Api-Key": this.apiKey
|
|
3777
|
+
"X-Schematic-Api-Key": this.apiKey,
|
|
3778
|
+
...sigHeaders
|
|
2737
3779
|
},
|
|
2738
3780
|
body: JSON.stringify(context)
|
|
2739
3781
|
}).then((response) => {
|
|
@@ -2826,6 +3868,34 @@ var Schematic = class {
|
|
|
2826
3868
|
console.log(`[Schematic] ${message}`, ...args);
|
|
2827
3869
|
}
|
|
2828
3870
|
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Resolve the HMAC context-signature value for a context, if a signature
|
|
3873
|
+
* provider is configured. Returns undefined when no provider is set, when
|
|
3874
|
+
* offline, or when the signature could not be obtained.
|
|
3875
|
+
*/
|
|
3876
|
+
contextSignature(context) {
|
|
3877
|
+
if (this.contextSignatureManager === void 0 || this.isOffline()) {
|
|
3878
|
+
return void 0;
|
|
3879
|
+
}
|
|
3880
|
+
return this.contextSignatureManager.getSignature(context);
|
|
3881
|
+
}
|
|
3882
|
+
/**
|
|
3883
|
+
* Build the `X-Schematic-Context-Sig` header for a context, or an empty
|
|
3884
|
+
* object when no signature is available. Spread into request headers.
|
|
3885
|
+
*
|
|
3886
|
+
* Returns synchronously (not a Promise) when no signature provider is
|
|
3887
|
+
* configured, so callers that dispatch on the same tick (e.g. fire-and-forget
|
|
3888
|
+
* event sends) keep their existing timing; only a configured provider, which
|
|
3889
|
+
* must fetch a signature, yields a Promise.
|
|
3890
|
+
*/
|
|
3891
|
+
contextSignatureHeaders(context) {
|
|
3892
|
+
if (this.contextSignatureManager === void 0 || this.isOffline()) {
|
|
3893
|
+
return {};
|
|
3894
|
+
}
|
|
3895
|
+
return this.contextSignatureManager.getSignature(context).then(
|
|
3896
|
+
(signature) => signature === void 0 ? {} : { [contextSignatureHeader]: signature }
|
|
3897
|
+
);
|
|
3898
|
+
}
|
|
2829
3899
|
/**
|
|
2830
3900
|
* Create a persistent message handler for websocket flag updates
|
|
2831
3901
|
*/
|
|
@@ -2949,12 +4019,14 @@ var Schematic = class {
|
|
|
2949
4019
|
}
|
|
2950
4020
|
const requestUrl = `${this._apiUrl}/flags/check`;
|
|
2951
4021
|
const requestBody = JSON.stringify(context);
|
|
4022
|
+
const sigHeaders = await this.contextSignatureHeaders(context);
|
|
2952
4023
|
return fetch(requestUrl, {
|
|
2953
4024
|
method: "POST",
|
|
2954
4025
|
headers: {
|
|
2955
4026
|
...this._additionalHeaders ?? {},
|
|
2956
4027
|
"Content-Type": "application/json;charset=UTF-8",
|
|
2957
|
-
"X-Schematic-Api-Key": this.apiKey
|
|
4028
|
+
"X-Schematic-Api-Key": this.apiKey,
|
|
4029
|
+
...sigHeaders
|
|
2958
4030
|
},
|
|
2959
4031
|
body: requestBody
|
|
2960
4032
|
}).then((response) => {
|
|
@@ -3509,12 +4581,17 @@ var Schematic = class {
|
|
|
3509
4581
|
this.debug(`event not sent (offline mode):`, { event });
|
|
3510
4582
|
return Promise.resolve();
|
|
3511
4583
|
}
|
|
4584
|
+
const maybeSigHeaders = this.contextSignatureHeaders(
|
|
4585
|
+
extractEventContext(event)
|
|
4586
|
+
);
|
|
4587
|
+
const sigHeaders = maybeSigHeaders instanceof Promise ? await maybeSigHeaders : maybeSigHeaders;
|
|
3512
4588
|
try {
|
|
3513
4589
|
const response = await fetch(captureUrl, {
|
|
3514
4590
|
method: "POST",
|
|
3515
4591
|
headers: {
|
|
3516
4592
|
...this._additionalHeaders ?? {},
|
|
3517
|
-
"Content-Type": "application/json;charset=UTF-8"
|
|
4593
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
4594
|
+
...sigHeaders
|
|
3518
4595
|
},
|
|
3519
4596
|
body: payload
|
|
3520
4597
|
});
|
|
@@ -3698,6 +4775,7 @@ var Schematic = class {
|
|
|
3698
4775
|
* In offline mode, this is a no-op.
|
|
3699
4776
|
*/
|
|
3700
4777
|
cleanup = async () => {
|
|
4778
|
+
this.contextSignatureManager?.clear();
|
|
3701
4779
|
if (this.isOffline()) {
|
|
3702
4780
|
this.debug("cleanup: skipped (offline mode)");
|
|
3703
4781
|
return Promise.resolve();
|
|
@@ -3983,7 +5061,7 @@ var Schematic = class {
|
|
|
3983
5061
|
context
|
|
3984
5062
|
);
|
|
3985
5063
|
this.context = context;
|
|
3986
|
-
const sendMessage = () => {
|
|
5064
|
+
const sendMessage = async () => {
|
|
3987
5065
|
let resolved = false;
|
|
3988
5066
|
const persistentMessageHandler = this.createPersistentMessageHandler(context);
|
|
3989
5067
|
const messageHandler = (event) => {
|
|
@@ -4010,20 +5088,22 @@ var Schematic = class {
|
|
|
4010
5088
|
});
|
|
4011
5089
|
this.currentWebSocket = socket;
|
|
4012
5090
|
const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
|
|
5091
|
+
const sig = await this.contextSignature(context);
|
|
4013
5092
|
const messagePayload = {
|
|
4014
5093
|
apiKey: this.apiKey,
|
|
4015
5094
|
clientVersion,
|
|
4016
|
-
data: context
|
|
5095
|
+
data: context,
|
|
5096
|
+
...sig !== void 0 ? { sig } : {}
|
|
4017
5097
|
};
|
|
4018
5098
|
this.debug(`WebSocket sending message:`, messagePayload);
|
|
4019
5099
|
socket.send(JSON.stringify(messagePayload));
|
|
4020
5100
|
};
|
|
4021
5101
|
if (socket.readyState === WebSocket.OPEN) {
|
|
4022
5102
|
this.debug(`WebSocket already open, sending message`);
|
|
4023
|
-
sendMessage();
|
|
5103
|
+
void sendMessage();
|
|
4024
5104
|
} else if (socket.readyState === WebSocket.CONNECTING) {
|
|
4025
5105
|
this.debug(`WebSocket connecting, waiting for open to send message`);
|
|
4026
|
-
socket.addEventListener("open", sendMessage);
|
|
5106
|
+
socket.addEventListener("open", () => void sendMessage());
|
|
4027
5107
|
} else {
|
|
4028
5108
|
this.debug(`WebSocket is closed, cannot send message`);
|
|
4029
5109
|
reject("WebSocket is not open or connecting");
|
|
@@ -4626,6 +5706,7 @@ var READINESS = {
|
|
|
4626
5706
|
active: "ready",
|
|
4627
5707
|
ended: "never"
|
|
4628
5708
|
};
|
|
5709
|
+
var FEATURE_USER_USAGE_LIMIT = 20;
|
|
4629
5710
|
var BillingStore = class {
|
|
4630
5711
|
constructor(_client, initialData = {}, options = {}) {
|
|
4631
5712
|
this._client = _client;
|
|
@@ -4646,6 +5727,17 @@ var BillingStore = class {
|
|
|
4646
5727
|
() => this._client.fetchPaymentMethods(),
|
|
4647
5728
|
{ readiness }
|
|
4648
5729
|
);
|
|
5730
|
+
this.featureUsage = new KeyedResource(
|
|
5731
|
+
() => this._client.fetchFeatureUsage(),
|
|
5732
|
+
{ readiness }
|
|
5733
|
+
);
|
|
5734
|
+
this.featureUserUsage = new KeyedResource(
|
|
5735
|
+
({ featureId }) => this._client.fetchFeatureUserUsage({
|
|
5736
|
+
featureId,
|
|
5737
|
+
limit: FEATURE_USER_USAGE_LIMIT
|
|
5738
|
+
}),
|
|
5739
|
+
{ readiness }
|
|
5740
|
+
);
|
|
4649
5741
|
const held = { key: initialData.sessionKey };
|
|
4650
5742
|
if (initialData.invoices !== void 0) {
|
|
4651
5743
|
held.invoices = {
|
|
@@ -4663,7 +5755,10 @@ var BillingStore = class {
|
|
|
4663
5755
|
if (initialData.paymentMethods !== void 0) {
|
|
4664
5756
|
held.paymentMethods = initialData.paymentMethods;
|
|
4665
5757
|
}
|
|
4666
|
-
if (
|
|
5758
|
+
if (initialData.featureUsage !== void 0) {
|
|
5759
|
+
held.featureUsage = initialData.featureUsage;
|
|
5760
|
+
}
|
|
5761
|
+
if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0 || held.featureUsage !== void 0) {
|
|
4667
5762
|
this._held = held;
|
|
4668
5763
|
this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
|
|
4669
5764
|
}
|
|
@@ -4672,6 +5767,8 @@ var BillingStore = class {
|
|
|
4672
5767
|
invoices;
|
|
4673
5768
|
upcomingInvoice;
|
|
4674
5769
|
paymentMethods;
|
|
5770
|
+
featureUsage;
|
|
5771
|
+
featureUserUsage;
|
|
4675
5772
|
_pageSize;
|
|
4676
5773
|
_unsubscribe;
|
|
4677
5774
|
_connected = false;
|
|
@@ -4750,6 +5847,9 @@ var BillingStore = class {
|
|
|
4750
5847
|
if (held.paymentMethods !== void 0) {
|
|
4751
5848
|
this.paymentMethods.seed(SINGLETON, held.paymentMethods);
|
|
4752
5849
|
}
|
|
5850
|
+
if (held.featureUsage !== void 0) {
|
|
5851
|
+
this.featureUsage.seed(SINGLETON, held.featureUsage);
|
|
5852
|
+
}
|
|
4753
5853
|
this._seedKey = held.key;
|
|
4754
5854
|
this._seeded = true;
|
|
4755
5855
|
}
|
|
@@ -4762,24 +5862,28 @@ var BillingStore = class {
|
|
|
4762
5862
|
for (const name of RESOURCE_NAMES) {
|
|
4763
5863
|
this[name].resetAll();
|
|
4764
5864
|
}
|
|
5865
|
+
this.featureUserUsage.resetAll();
|
|
4765
5866
|
}
|
|
4766
5867
|
/** Forgets every resource and leaves them empty; nothing reloads. */
|
|
4767
5868
|
clearAll() {
|
|
4768
5869
|
for (const name of RESOURCE_NAMES) {
|
|
4769
5870
|
this[name].clearAll();
|
|
4770
5871
|
}
|
|
5872
|
+
this.featureUserUsage.clearAll();
|
|
4771
5873
|
}
|
|
4772
5874
|
/** Loads every resource that is subscribed and has nothing yet. */
|
|
4773
5875
|
resumeAll() {
|
|
4774
5876
|
for (const name of RESOURCE_NAMES) {
|
|
4775
5877
|
this[name].resumeAll();
|
|
4776
5878
|
}
|
|
5879
|
+
this.featureUserUsage.resumeAll();
|
|
4777
5880
|
}
|
|
4778
5881
|
/** Reloads every resource that has been loaded, keeping its current data. */
|
|
4779
5882
|
invalidateAll() {
|
|
4780
5883
|
for (const name of RESOURCE_NAMES) {
|
|
4781
5884
|
this[name].invalidateAll();
|
|
4782
5885
|
}
|
|
5886
|
+
this.featureUserUsage.invalidateAll();
|
|
4783
5887
|
}
|
|
4784
5888
|
/**
|
|
4785
5889
|
* Appends the next page to the invoices list for `query`, when there is
|
|
@@ -4891,7 +5995,8 @@ var BillingStore = class {
|
|
|
4891
5995
|
var RESOURCE_NAMES = [
|
|
4892
5996
|
"invoices",
|
|
4893
5997
|
"upcomingInvoice",
|
|
4894
|
-
"paymentMethods"
|
|
5998
|
+
"paymentMethods",
|
|
5999
|
+
"featureUsage"
|
|
4895
6000
|
];
|
|
4896
6001
|
|
|
4897
6002
|
// src/billing/context.tsx
|
|
@@ -4971,6 +6076,9 @@ var missingBillingSource = {
|
|
|
4971
6076
|
subscribe: () => () => {
|
|
4972
6077
|
},
|
|
4973
6078
|
handle: () => missingHandle,
|
|
6079
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6080
|
+
},
|
|
6081
|
+
featureUserUsage: () => missingHandle,
|
|
4974
6082
|
loadMoreInvoices: () => Promise.resolve(),
|
|
4975
6083
|
invalidateAll: () => {
|
|
4976
6084
|
},
|
|
@@ -4985,6 +6093,7 @@ function BillingDataProvider({
|
|
|
4985
6093
|
actions,
|
|
4986
6094
|
children,
|
|
4987
6095
|
data,
|
|
6096
|
+
featureUserUsage,
|
|
4988
6097
|
locale,
|
|
4989
6098
|
onLoadMoreInvoices,
|
|
4990
6099
|
onMissingString,
|
|
@@ -4995,6 +6104,7 @@ function BillingDataProvider({
|
|
|
4995
6104
|
}) {
|
|
4996
6105
|
const source = (0, import_react2.useMemo)(() => {
|
|
4997
6106
|
const handles = /* @__PURE__ */ new Map();
|
|
6107
|
+
const userUsageHandles = /* @__PURE__ */ new Map();
|
|
4998
6108
|
return {
|
|
4999
6109
|
actions: rejectingActions(
|
|
5000
6110
|
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
|
|
@@ -5018,6 +6128,24 @@ function BillingDataProvider({
|
|
|
5018
6128
|
handles.set(name, handle);
|
|
5019
6129
|
return handle;
|
|
5020
6130
|
},
|
|
6131
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6132
|
+
},
|
|
6133
|
+
featureUserUsage: (featureId) => {
|
|
6134
|
+
const cached = userUsageHandles.get(featureId);
|
|
6135
|
+
if (cached !== void 0) {
|
|
6136
|
+
return cached;
|
|
6137
|
+
}
|
|
6138
|
+
const value = featureUserUsage?.[featureId];
|
|
6139
|
+
const handle = {
|
|
6140
|
+
data: value,
|
|
6141
|
+
error: void 0,
|
|
6142
|
+
isPending: value === void 0,
|
|
6143
|
+
refetch: () => {
|
|
6144
|
+
}
|
|
6145
|
+
};
|
|
6146
|
+
userUsageHandles.set(featureId, handle);
|
|
6147
|
+
return handle;
|
|
6148
|
+
},
|
|
5021
6149
|
loadMoreInvoices: (query) => {
|
|
5022
6150
|
onLoadMoreInvoices?.(query);
|
|
5023
6151
|
return Promise.resolve();
|
|
@@ -5025,7 +6153,7 @@ function BillingDataProvider({
|
|
|
5025
6153
|
invalidateAll: () => {
|
|
5026
6154
|
}
|
|
5027
6155
|
};
|
|
5028
|
-
}, [actions, data, onLoadMoreInvoices, onRefetch, status]);
|
|
6156
|
+
}, [actions, data, featureUserUsage, onLoadMoreInvoices, onRefetch, status]);
|
|
5029
6157
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
5030
6158
|
SchematicI18nProvider,
|
|
5031
6159
|
{
|
|
@@ -5115,6 +6243,21 @@ function useSetupIntent() {
|
|
|
5115
6243
|
[source]
|
|
5116
6244
|
);
|
|
5117
6245
|
}
|
|
6246
|
+
function useFeatureUsage() {
|
|
6247
|
+
return useBillingResource("featureUsage", SINGLETON);
|
|
6248
|
+
}
|
|
6249
|
+
function useFeatureUserUsage(featureId) {
|
|
6250
|
+
const source = useBillingDataSource();
|
|
6251
|
+
const subscribe = (0, import_react3.useCallback)(
|
|
6252
|
+
(listener) => source.subscribeFeatureUserUsage(featureId, listener),
|
|
6253
|
+
[featureId, source]
|
|
6254
|
+
);
|
|
6255
|
+
const getSnapshot = (0, import_react3.useCallback)(
|
|
6256
|
+
() => source.featureUserUsage(featureId),
|
|
6257
|
+
[featureId, source]
|
|
6258
|
+
);
|
|
6259
|
+
return (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
6260
|
+
}
|
|
5118
6261
|
function useInvalidateBillingData() {
|
|
5119
6262
|
return useBillingDataSource().invalidateAll;
|
|
5120
6263
|
}
|
|
@@ -5170,8 +6313,7 @@ function BillingProvider({
|
|
|
5170
6313
|
return initialRef.current === void 0 ? void 0 : staticSource(initialRef.current);
|
|
5171
6314
|
}
|
|
5172
6315
|
const handles = /* @__PURE__ */ new WeakMap();
|
|
5173
|
-
const
|
|
5174
|
-
const resource = store.resource(name).get(params);
|
|
6316
|
+
const handleOf = (resource) => {
|
|
5175
6317
|
const snapshot = resource.getSnapshot();
|
|
5176
6318
|
const cached = handles.get(resource);
|
|
5177
6319
|
if (cached !== void 0 && cached.snapshot === snapshot) {
|
|
@@ -5181,12 +6323,18 @@ function BillingProvider({
|
|
|
5181
6323
|
...snapshot,
|
|
5182
6324
|
refetch: () => void resource.refetch()
|
|
5183
6325
|
};
|
|
5184
|
-
handles.set(resource, {
|
|
6326
|
+
handles.set(resource, {
|
|
6327
|
+
snapshot,
|
|
6328
|
+
handle: next
|
|
6329
|
+
});
|
|
5185
6330
|
return next;
|
|
5186
6331
|
};
|
|
6332
|
+
const handle = (name, params) => handleOf(store.resource(name).get(params));
|
|
5187
6333
|
return {
|
|
5188
6334
|
subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
|
|
5189
6335
|
handle,
|
|
6336
|
+
subscribeFeatureUserUsage: (featureId, listener) => store.featureUserUsage.subscribe({ featureId }, listener),
|
|
6337
|
+
featureUserUsage: (featureId) => handleOf(store.featureUserUsage.get({ featureId })),
|
|
5190
6338
|
loadMoreInvoices: (query) => store.loadMoreInvoices(query),
|
|
5191
6339
|
invalidateAll: () => store.invalidateAll(),
|
|
5192
6340
|
actions: {
|
|
@@ -5213,7 +6361,17 @@ function BillingProvider({
|
|
|
5213
6361
|
}
|
|
5214
6362
|
function staticSource(data) {
|
|
5215
6363
|
const handles = /* @__PURE__ */ new Map();
|
|
6364
|
+
const pendingUserUsage = {
|
|
6365
|
+
data: void 0,
|
|
6366
|
+
error: void 0,
|
|
6367
|
+
isPending: true,
|
|
6368
|
+
refetch: () => {
|
|
6369
|
+
}
|
|
6370
|
+
};
|
|
5216
6371
|
return {
|
|
6372
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6373
|
+
},
|
|
6374
|
+
featureUserUsage: () => pendingUserUsage,
|
|
5217
6375
|
subscribe: () => () => {
|
|
5218
6376
|
},
|
|
5219
6377
|
handle: (name) => {
|
|
@@ -5239,7 +6397,7 @@ function staticSource(data) {
|
|
|
5239
6397
|
}
|
|
5240
6398
|
|
|
5241
6399
|
// src/version.ts
|
|
5242
|
-
var version2 = "1.
|
|
6400
|
+
var version2 = "1.11.0";
|
|
5243
6401
|
|
|
5244
6402
|
// src/context/schematic.tsx
|
|
5245
6403
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|