@schematichq/schematic-react 1.9.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/README.md +37 -0
- package/dist/schematic-react.cjs.js +1408 -73
- package/dist/schematic-react.d.ts +1117 -26
- package/dist/schematic-react.esm.js +1408 -73
- 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,12 +46,15 @@ __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,
|
|
51
54
|
useSchematic: () => useSchematic,
|
|
52
55
|
useSchematicContext: () => useSchematicContext,
|
|
53
56
|
useSchematicCreditBalance: () => useSchematicCreditBalance,
|
|
57
|
+
useSchematicCreditSpendPolicies: () => useSchematicCreditSpendPolicies,
|
|
54
58
|
useSchematicEntitlement: () => useSchematicEntitlement,
|
|
55
59
|
useSchematicEvents: () => useSchematicEvents,
|
|
56
60
|
useSchematicFlag: () => useSchematicFlag,
|
|
@@ -65,7 +69,7 @@ __export(index_exports, {
|
|
|
65
69
|
});
|
|
66
70
|
module.exports = __toCommonJS(index_exports);
|
|
67
71
|
|
|
68
|
-
// 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
|
|
69
73
|
var __create2 = Object.create;
|
|
70
74
|
var __defProp2 = Object.defineProperty;
|
|
71
75
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -1061,6 +1065,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
1061
1065
|
trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
|
|
1062
1066
|
};
|
|
1063
1067
|
}
|
|
1068
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
1069
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
1070
|
+
}
|
|
1071
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
1072
|
+
return json;
|
|
1073
|
+
}
|
|
1074
|
+
function CreditSpendWindowFromJSON(json) {
|
|
1075
|
+
return CreditSpendWindowFromJSONTyped(json, false);
|
|
1076
|
+
}
|
|
1077
|
+
function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
|
|
1078
|
+
if (json == null) {
|
|
1079
|
+
return json;
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
count: json["count"],
|
|
1083
|
+
unit: json["unit"]
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
function CreditSpendPolicyFromJSON(json) {
|
|
1087
|
+
return CreditSpendPolicyFromJSONTyped(json, false);
|
|
1088
|
+
}
|
|
1089
|
+
function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1090
|
+
if (json == null) {
|
|
1091
|
+
return json;
|
|
1092
|
+
}
|
|
1093
|
+
return {
|
|
1094
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
1095
|
+
creditId: json["credit_id"],
|
|
1096
|
+
id: json["id"],
|
|
1097
|
+
kind: json["kind"],
|
|
1098
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
1099
|
+
limit: json["limit"],
|
|
1100
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
1101
|
+
scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
|
|
1102
|
+
window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1064
1105
|
function CheckFlagsResponseDataFromJSON(json) {
|
|
1065
1106
|
return CheckFlagsResponseDataFromJSONTyped(json, false);
|
|
1066
1107
|
}
|
|
@@ -1070,6 +1111,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
1070
1111
|
}
|
|
1071
1112
|
return {
|
|
1072
1113
|
creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
|
|
1114
|
+
creditSpendPolicies: json["credit_spend_policies"].map(
|
|
1115
|
+
CreditSpendPolicyFromJSON
|
|
1116
|
+
),
|
|
1073
1117
|
flags: json["flags"].map(CheckFlagResponseDataFromJSON),
|
|
1074
1118
|
plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
|
|
1075
1119
|
};
|
|
@@ -1198,7 +1242,55 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1198
1242
|
}
|
|
1199
1243
|
return balances;
|
|
1200
1244
|
};
|
|
1201
|
-
var
|
|
1245
|
+
var CreditSpendPoliciesFromJSON = (json) => {
|
|
1246
|
+
if (!Array.isArray(json)) {
|
|
1247
|
+
return [];
|
|
1248
|
+
}
|
|
1249
|
+
const policies = [];
|
|
1250
|
+
for (const raw of json) {
|
|
1251
|
+
if (raw == null || typeof raw !== "object") continue;
|
|
1252
|
+
const id = raw.id;
|
|
1253
|
+
const creditId = raw.credit_id ?? raw.creditId;
|
|
1254
|
+
const kind = raw.kind;
|
|
1255
|
+
const scope = raw.scope;
|
|
1256
|
+
const limit = raw.limit;
|
|
1257
|
+
if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
const policy = {
|
|
1261
|
+
id,
|
|
1262
|
+
creditId,
|
|
1263
|
+
kind,
|
|
1264
|
+
scope,
|
|
1265
|
+
limit,
|
|
1266
|
+
consumed: typeof raw.consumed === "number" ? raw.consumed : 0
|
|
1267
|
+
};
|
|
1268
|
+
if (typeof raw.label === "string") {
|
|
1269
|
+
policy.label = raw.label;
|
|
1270
|
+
}
|
|
1271
|
+
const window2 = raw.window;
|
|
1272
|
+
if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
|
|
1273
|
+
policy.window = { unit: window2.unit, count: window2.count };
|
|
1274
|
+
}
|
|
1275
|
+
const resetsAt = raw.resets_at ?? raw.resetsAt;
|
|
1276
|
+
if (typeof resetsAt === "string" || resetsAt instanceof Date) {
|
|
1277
|
+
const parsed = new Date(resetsAt);
|
|
1278
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
1279
|
+
policy.resetsAt = parsed;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
policies.push(policy);
|
|
1283
|
+
}
|
|
1284
|
+
return policies;
|
|
1285
|
+
};
|
|
1286
|
+
var creditSpendPoliciesEqual = (a, b) => {
|
|
1287
|
+
if (a.length !== b.length) return false;
|
|
1288
|
+
return a.every((x, i) => {
|
|
1289
|
+
const y = b[i];
|
|
1290
|
+
return x.id === y.id && x.creditId === y.creditId && x.kind === y.kind && x.scope === y.scope && x.label === y.label && x.limit === y.limit && x.consumed === y.consumed && x.resetsAt?.getTime() === y.resetsAt?.getTime() && x.window?.unit === y.window?.unit && x.window?.count === y.window?.count;
|
|
1291
|
+
});
|
|
1292
|
+
};
|
|
1293
|
+
var cacheVersion = "35d92bc6";
|
|
1202
1294
|
function contextString(context) {
|
|
1203
1295
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1204
1296
|
const sortedKeys = Object.keys(
|
|
@@ -1213,7 +1305,98 @@ function contextString(context) {
|
|
|
1213
1305
|
}, {});
|
|
1214
1306
|
return JSON.stringify(sortedContext);
|
|
1215
1307
|
}
|
|
1216
|
-
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";
|
|
1217
1400
|
var SINGLETON = {};
|
|
1218
1401
|
var models_exports = {};
|
|
1219
1402
|
__export2(models_exports, {
|
|
@@ -1221,15 +1404,59 @@ __export2(models_exports, {
|
|
|
1221
1404
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1222
1405
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1223
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,
|
|
1224
1422
|
BillingProviderType: () => BillingProviderType,
|
|
1225
1423
|
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1226
1424
|
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1227
1425
|
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1228
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,
|
|
1229
1444
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1230
1445
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1231
1446
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
1232
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,
|
|
1233
1460
|
CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
|
|
1234
1461
|
CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
|
|
1235
1462
|
CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
|
|
@@ -1250,6 +1477,10 @@ __export2(models_exports, {
|
|
|
1250
1477
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1251
1478
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1252
1479
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1480
|
+
CompanyUserUsageResponseDataFromJSON: () => CompanyUserUsageResponseDataFromJSON,
|
|
1481
|
+
CompanyUserUsageResponseDataFromJSONTyped: () => CompanyUserUsageResponseDataFromJSONTyped,
|
|
1482
|
+
CompanyUserUsageResponseDataToJSON: () => CompanyUserUsageResponseDataToJSON,
|
|
1483
|
+
CompanyUserUsageResponseDataToJSONTyped: () => CompanyUserUsageResponseDataToJSONTyped,
|
|
1253
1484
|
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1254
1485
|
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1255
1486
|
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
@@ -1262,6 +1493,38 @@ __export2(models_exports, {
|
|
|
1262
1493
|
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1263
1494
|
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1264
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,
|
|
1265
1528
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1266
1529
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1267
1530
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1283,10 +1546,25 @@ __export2(models_exports, {
|
|
|
1283
1546
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1284
1547
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1285
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,
|
|
1286
1559
|
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1287
1560
|
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1288
1561
|
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1289
1562
|
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1563
|
+
PlanCreditGrantScaling: () => PlanCreditGrantScaling,
|
|
1564
|
+
PlanCreditGrantScalingFromJSON: () => PlanCreditGrantScalingFromJSON2,
|
|
1565
|
+
PlanCreditGrantScalingFromJSONTyped: () => PlanCreditGrantScalingFromJSONTyped3,
|
|
1566
|
+
PlanCreditGrantScalingToJSON: () => PlanCreditGrantScalingToJSON2,
|
|
1567
|
+
PlanCreditGrantScalingToJSONTyped: () => PlanCreditGrantScalingToJSONTyped3,
|
|
1290
1568
|
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1291
1569
|
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1292
1570
|
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
@@ -1300,22 +1578,43 @@ __export2(models_exports, {
|
|
|
1300
1578
|
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1301
1579
|
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1302
1580
|
instanceOfApiError: () => instanceOfApiError,
|
|
1581
|
+
instanceOfBillingPlanCreditGrantResetCadence: () => instanceOfBillingPlanCreditGrantResetCadence,
|
|
1582
|
+
instanceOfBillingPriceScheme: () => instanceOfBillingPriceScheme,
|
|
1583
|
+
instanceOfBillingProductPriceInterval: () => instanceOfBillingProductPriceInterval,
|
|
1303
1584
|
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1585
|
+
instanceOfBillingTiersMode: () => instanceOfBillingTiersMode,
|
|
1586
|
+
instanceOfCatalogCreditGrantResponseData: () => instanceOfCatalogCreditGrantResponseData,
|
|
1587
|
+
instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
|
|
1588
|
+
instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
|
|
1304
1589
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1590
|
+
instanceOfCompanyFeatureUsageListResponseData: () => instanceOfCompanyFeatureUsageListResponseData,
|
|
1591
|
+
instanceOfCompanyFeatureUsageResponseData: () => instanceOfCompanyFeatureUsageResponseData,
|
|
1592
|
+
instanceOfCompanyFeatureUserUsageResponseData: () => instanceOfCompanyFeatureUserUsageResponseData,
|
|
1305
1593
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1306
1594
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1307
1595
|
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1308
1596
|
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1309
1597
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1598
|
+
instanceOfCompanyUserUsageResponseData: () => instanceOfCompanyUserUsageResponseData,
|
|
1310
1599
|
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1311
1600
|
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1312
1601
|
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1602
|
+
instanceOfEntitlementPriceBehavior: () => instanceOfEntitlementPriceBehavior,
|
|
1603
|
+
instanceOfEntitlementType: () => instanceOfEntitlementType,
|
|
1604
|
+
instanceOfEntitlementValueType: () => instanceOfEntitlementValueType,
|
|
1605
|
+
instanceOfFeatureType: () => instanceOfFeatureType,
|
|
1606
|
+
instanceOfGetCompanyFeatureUsageResponse: () => instanceOfGetCompanyFeatureUsageResponse,
|
|
1607
|
+
instanceOfGetCompanyFeatureUserUsageParams: () => instanceOfGetCompanyFeatureUserUsageParams,
|
|
1608
|
+
instanceOfGetCompanyFeatureUserUsageResponse: () => instanceOfGetCompanyFeatureUserUsageResponse,
|
|
1313
1609
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1314
1610
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1315
1611
|
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1316
1612
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1317
1613
|
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1614
|
+
instanceOfMetricPeriod: () => instanceOfMetricPeriod,
|
|
1615
|
+
instanceOfMetricPeriodMonthReset: () => instanceOfMetricPeriodMonthReset,
|
|
1318
1616
|
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1617
|
+
instanceOfPlanCreditGrantScaling: () => instanceOfPlanCreditGrantScaling,
|
|
1319
1618
|
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1320
1619
|
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1321
1620
|
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
@@ -1324,94 +1623,771 @@ function instanceOfApiError(value) {
|
|
|
1324
1623
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
1325
1624
|
return true;
|
|
1326
1625
|
}
|
|
1327
|
-
function ApiErrorFromJSON(json) {
|
|
1328
|
-
return ApiErrorFromJSONTyped(json, false);
|
|
1626
|
+
function ApiErrorFromJSON(json) {
|
|
1627
|
+
return ApiErrorFromJSONTyped(json, false);
|
|
1628
|
+
}
|
|
1629
|
+
function ApiErrorFromJSONTyped(json, ignoreDiscriminator) {
|
|
1630
|
+
if (json == null) {
|
|
1631
|
+
return json;
|
|
1632
|
+
}
|
|
1633
|
+
return {
|
|
1634
|
+
error: json["error"]
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
function ApiErrorToJSON(json) {
|
|
1638
|
+
return ApiErrorToJSONTyped(json, false);
|
|
1639
|
+
}
|
|
1640
|
+
function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1641
|
+
if (value == null) {
|
|
1642
|
+
return value;
|
|
1643
|
+
}
|
|
1644
|
+
return {
|
|
1645
|
+
error: value["error"]
|
|
1646
|
+
};
|
|
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
|
+
}
|
|
1735
|
+
var BillingProviderType = {
|
|
1736
|
+
Metronome: "metronome",
|
|
1737
|
+
Orb: "orb",
|
|
1738
|
+
Schematic: "schematic",
|
|
1739
|
+
Stripe: "stripe"
|
|
1740
|
+
};
|
|
1741
|
+
function instanceOfBillingProviderType(value) {
|
|
1742
|
+
for (const key in BillingProviderType) {
|
|
1743
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1744
|
+
if (BillingProviderType[key] === value) {
|
|
1745
|
+
return true;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1752
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1753
|
+
}
|
|
1754
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1755
|
+
return json;
|
|
1756
|
+
}
|
|
1757
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1758
|
+
return value;
|
|
1759
|
+
}
|
|
1760
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1761
|
+
return value;
|
|
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
|
+
}
|
|
1965
|
+
function instanceOfCompanyDiscountResponseData(value) {
|
|
1966
|
+
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1967
|
+
return false;
|
|
1968
|
+
if (!("duration" in value) || value["duration"] === void 0) return false;
|
|
1969
|
+
return true;
|
|
1970
|
+
}
|
|
1971
|
+
function CompanyDiscountResponseDataFromJSON(json) {
|
|
1972
|
+
return CompanyDiscountResponseDataFromJSONTyped(json, false);
|
|
1973
|
+
}
|
|
1974
|
+
function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1975
|
+
if (json == null) {
|
|
1976
|
+
return json;
|
|
1977
|
+
}
|
|
1978
|
+
return {
|
|
1979
|
+
amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
|
|
1980
|
+
couponName: json["coupon_name"],
|
|
1981
|
+
currency: json["currency"] == null ? void 0 : json["currency"],
|
|
1982
|
+
customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
|
|
1983
|
+
duration: json["duration"],
|
|
1984
|
+
durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
|
|
1985
|
+
percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
function CompanyDiscountResponseDataToJSON(json) {
|
|
1989
|
+
return CompanyDiscountResponseDataToJSONTyped(json, false);
|
|
1990
|
+
}
|
|
1991
|
+
function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1992
|
+
if (value == null) {
|
|
1993
|
+
return value;
|
|
1994
|
+
}
|
|
1995
|
+
return {
|
|
1996
|
+
amount_off: value["amountOff"],
|
|
1997
|
+
coupon_name: value["couponName"],
|
|
1998
|
+
currency: value["currency"],
|
|
1999
|
+
customer_facing_code: value["customerFacingCode"],
|
|
2000
|
+
duration: value["duration"],
|
|
2001
|
+
duration_in_months: value["durationInMonths"],
|
|
2002
|
+
percent_off: value["percentOff"]
|
|
2003
|
+
};
|
|
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);
|
|
1329
2286
|
}
|
|
1330
|
-
function
|
|
2287
|
+
function CompanyFeatureUsageListResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1331
2288
|
if (json == null) {
|
|
1332
2289
|
return json;
|
|
1333
2290
|
}
|
|
1334
2291
|
return {
|
|
1335
|
-
|
|
2292
|
+
count: json["count"],
|
|
2293
|
+
features: json["features"].map(
|
|
2294
|
+
CompanyFeatureUsageResponseDataFromJSON
|
|
2295
|
+
)
|
|
1336
2296
|
};
|
|
1337
2297
|
}
|
|
1338
|
-
function
|
|
1339
|
-
return
|
|
2298
|
+
function CompanyFeatureUsageListResponseDataToJSON(json) {
|
|
2299
|
+
return CompanyFeatureUsageListResponseDataToJSONTyped(json, false);
|
|
1340
2300
|
}
|
|
1341
|
-
function
|
|
2301
|
+
function CompanyFeatureUsageListResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1342
2302
|
if (value == null) {
|
|
1343
2303
|
return value;
|
|
1344
2304
|
}
|
|
1345
2305
|
return {
|
|
1346
|
-
|
|
2306
|
+
count: value["count"],
|
|
2307
|
+
features: value["features"].map(
|
|
2308
|
+
CompanyFeatureUsageResponseDataToJSON
|
|
2309
|
+
)
|
|
1347
2310
|
};
|
|
1348
2311
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
function instanceOfBillingProviderType(value) {
|
|
1356
|
-
for (const key in BillingProviderType) {
|
|
1357
|
-
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1358
|
-
if (BillingProviderType[key] === value) {
|
|
1359
|
-
return true;
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
return false;
|
|
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;
|
|
1364
2318
|
}
|
|
1365
|
-
function
|
|
1366
|
-
return
|
|
2319
|
+
function CompanyUserUsageResponseDataFromJSON(json) {
|
|
2320
|
+
return CompanyUserUsageResponseDataFromJSONTyped(json, false);
|
|
1367
2321
|
}
|
|
1368
|
-
function
|
|
1369
|
-
|
|
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
|
+
};
|
|
1370
2333
|
}
|
|
1371
|
-
function
|
|
1372
|
-
return
|
|
2334
|
+
function CompanyUserUsageResponseDataToJSON(json) {
|
|
2335
|
+
return CompanyUserUsageResponseDataToJSONTyped(json, false);
|
|
1373
2336
|
}
|
|
1374
|
-
function
|
|
1375
|
-
|
|
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
|
+
};
|
|
1376
2348
|
}
|
|
1377
|
-
function
|
|
1378
|
-
if (!("
|
|
1379
|
-
|
|
1380
|
-
if (!("
|
|
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;
|
|
1381
2355
|
return true;
|
|
1382
2356
|
}
|
|
1383
|
-
function
|
|
1384
|
-
return
|
|
2357
|
+
function CompanyFeatureUserUsageResponseDataFromJSON(json) {
|
|
2358
|
+
return CompanyFeatureUserUsageResponseDataFromJSONTyped(json, false);
|
|
1385
2359
|
}
|
|
1386
|
-
function
|
|
2360
|
+
function CompanyFeatureUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1387
2361
|
if (json == null) {
|
|
1388
2362
|
return json;
|
|
1389
2363
|
}
|
|
1390
2364
|
return {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
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
|
+
)
|
|
1398
2373
|
};
|
|
1399
2374
|
}
|
|
1400
|
-
function
|
|
1401
|
-
return
|
|
2375
|
+
function CompanyFeatureUserUsageResponseDataToJSON(json) {
|
|
2376
|
+
return CompanyFeatureUserUsageResponseDataToJSONTyped(json, false);
|
|
1402
2377
|
}
|
|
1403
|
-
function
|
|
2378
|
+
function CompanyFeatureUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1404
2379
|
if (value == null) {
|
|
1405
2380
|
return value;
|
|
1406
2381
|
}
|
|
1407
2382
|
return {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
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
|
+
)
|
|
1415
2391
|
};
|
|
1416
2392
|
}
|
|
1417
2393
|
var InvoiceStatus = {
|
|
@@ -1773,6 +2749,91 @@ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1773
2749
|
params: value["params"]
|
|
1774
2750
|
};
|
|
1775
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
|
+
}
|
|
1776
2837
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1777
2838
|
return true;
|
|
1778
2839
|
}
|
|
@@ -2374,15 +3435,78 @@ var SchematicBillingClient = class {
|
|
|
2374
3435
|
method: "DELETE"
|
|
2375
3436
|
}).then(() => void 0);
|
|
2376
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
|
+
}
|
|
2377
3468
|
};
|
|
2378
3469
|
var anonymousIdKey = "schematicId";
|
|
2379
3470
|
var flagStateCachePrefix = "schematicCache";
|
|
2380
3471
|
var flagStateCacheMaxContexts = 10;
|
|
2381
3472
|
var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
2382
3473
|
var emptyCreditBalances = Object.freeze({});
|
|
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
|
+
}
|
|
2383
3506
|
var Schematic = class {
|
|
2384
3507
|
_additionalHeaders = {};
|
|
2385
3508
|
apiKey;
|
|
3509
|
+
contextSignatureManager;
|
|
2386
3510
|
_apiUrl = "https://api.schematichq.com";
|
|
2387
3511
|
conn = null;
|
|
2388
3512
|
context = {};
|
|
@@ -2397,6 +3521,7 @@ var Schematic = class {
|
|
|
2397
3521
|
isPendingListeners = /* @__PURE__ */ new Set();
|
|
2398
3522
|
planListeners = /* @__PURE__ */ new Set();
|
|
2399
3523
|
creditBalanceListeners = /* @__PURE__ */ new Set();
|
|
3524
|
+
creditSpendPolicyListeners = /* @__PURE__ */ new Set();
|
|
2400
3525
|
storage;
|
|
2401
3526
|
persistFlagState = true;
|
|
2402
3527
|
flagStateCacheKey;
|
|
@@ -2407,6 +3532,7 @@ var Schematic = class {
|
|
|
2407
3532
|
featureUsageEventMap = {};
|
|
2408
3533
|
planChecks = {};
|
|
2409
3534
|
creditBalances = {};
|
|
3535
|
+
creditSpendPolicies = {};
|
|
2410
3536
|
webSocketUrl = "wss://api.schematichq.com";
|
|
2411
3537
|
webSocketConnectionTimeout = 1e4;
|
|
2412
3538
|
webSocketReconnect = true;
|
|
@@ -2467,6 +3593,12 @@ var Schematic = class {
|
|
|
2467
3593
|
"X-Schematic-Client-Version": `schematic-js@${version}`,
|
|
2468
3594
|
...options?.additionalHeaders ?? {}
|
|
2469
3595
|
};
|
|
3596
|
+
if (options?.getContextSignature !== void 0) {
|
|
3597
|
+
this.contextSignatureManager = new ContextSignatureManager(
|
|
3598
|
+
options.getContextSignature,
|
|
3599
|
+
this.debug.bind(this)
|
|
3600
|
+
);
|
|
3601
|
+
}
|
|
2470
3602
|
if (options?.storage) {
|
|
2471
3603
|
this.storage = options.storage;
|
|
2472
3604
|
} else {
|
|
@@ -2636,12 +3768,14 @@ var Schematic = class {
|
|
|
2636
3768
|
}
|
|
2637
3769
|
if (!this.useWebSocket) {
|
|
2638
3770
|
const requestUrl = `${this._apiUrl}/flags/${key}/check`;
|
|
3771
|
+
const sigHeaders = await this.contextSignatureHeaders(context);
|
|
2639
3772
|
return fetch(requestUrl, {
|
|
2640
3773
|
method: "POST",
|
|
2641
3774
|
headers: {
|
|
2642
3775
|
...this._additionalHeaders ?? {},
|
|
2643
3776
|
"Content-Type": "application/json;charset=UTF-8",
|
|
2644
|
-
"X-Schematic-Api-Key": this.apiKey
|
|
3777
|
+
"X-Schematic-Api-Key": this.apiKey,
|
|
3778
|
+
...sigHeaders
|
|
2645
3779
|
},
|
|
2646
3780
|
body: JSON.stringify(context)
|
|
2647
3781
|
}).then((response) => {
|
|
@@ -2734,6 +3868,34 @@ var Schematic = class {
|
|
|
2734
3868
|
console.log(`[Schematic] ${message}`, ...args);
|
|
2735
3869
|
}
|
|
2736
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
|
+
}
|
|
2737
3899
|
/**
|
|
2738
3900
|
* Create a persistent message handler for websocket flag updates
|
|
2739
3901
|
*/
|
|
@@ -2799,6 +3961,19 @@ var Schematic = class {
|
|
|
2799
3961
|
this.notifyCreditBalanceListeners(merged);
|
|
2800
3962
|
}
|
|
2801
3963
|
}
|
|
3964
|
+
if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
|
|
3965
|
+
const contextStr = contextString(context);
|
|
3966
|
+
const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
|
|
3967
|
+
const previous = this.creditSpendPolicies[contextStr] ?? [];
|
|
3968
|
+
if (!creditSpendPoliciesEqual(previous, next)) {
|
|
3969
|
+
this.creditSpendPolicies[contextStr] = next;
|
|
3970
|
+
this.debug(
|
|
3971
|
+
`WebSocket credit spend policy update received. Notifying listeners`,
|
|
3972
|
+
{ creditSpendPolicies: next }
|
|
3973
|
+
);
|
|
3974
|
+
this.notifyCreditSpendPolicyListeners(next);
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
2802
3977
|
this.persistContextToCache(contextString(context));
|
|
2803
3978
|
this.flushContextDependentEventQueue();
|
|
2804
3979
|
this.setIsPending(false);
|
|
@@ -2844,12 +4019,14 @@ var Schematic = class {
|
|
|
2844
4019
|
}
|
|
2845
4020
|
const requestUrl = `${this._apiUrl}/flags/check`;
|
|
2846
4021
|
const requestBody = JSON.stringify(context);
|
|
4022
|
+
const sigHeaders = await this.contextSignatureHeaders(context);
|
|
2847
4023
|
return fetch(requestUrl, {
|
|
2848
4024
|
method: "POST",
|
|
2849
4025
|
headers: {
|
|
2850
4026
|
...this._additionalHeaders ?? {},
|
|
2851
4027
|
"Content-Type": "application/json;charset=UTF-8",
|
|
2852
|
-
"X-Schematic-Api-Key": this.apiKey
|
|
4028
|
+
"X-Schematic-Api-Key": this.apiKey,
|
|
4029
|
+
...sigHeaders
|
|
2853
4030
|
},
|
|
2854
4031
|
body: requestBody
|
|
2855
4032
|
}).then((response) => {
|
|
@@ -3300,10 +4477,19 @@ var Schematic = class {
|
|
|
3300
4477
|
this.creditBalances[contextStr] = balances;
|
|
3301
4478
|
}
|
|
3302
4479
|
}
|
|
4480
|
+
let revivedCreditSpendPolicies;
|
|
4481
|
+
if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
|
|
4482
|
+
const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
|
|
4483
|
+
if (policies.length > 0) {
|
|
4484
|
+
revivedCreditSpendPolicies = policies;
|
|
4485
|
+
this.creditSpendPolicies[contextStr] = policies;
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
3303
4488
|
fresh[contextStr] = {
|
|
3304
4489
|
checks: revivedChecks,
|
|
3305
4490
|
plan: revivedPlan,
|
|
3306
4491
|
creditBalances: revivedCreditBalances,
|
|
4492
|
+
creditSpendPolicies: revivedCreditSpendPolicies,
|
|
3307
4493
|
updatedAt: entry.updatedAt
|
|
3308
4494
|
};
|
|
3309
4495
|
contextsLoaded += 1;
|
|
@@ -3317,7 +4503,8 @@ var Schematic = class {
|
|
|
3317
4503
|
const checksForContext = this.checks[contextStr];
|
|
3318
4504
|
const planForContext = this.planChecks[contextStr];
|
|
3319
4505
|
const creditBalancesForContext = this.creditBalances[contextStr];
|
|
3320
|
-
|
|
4506
|
+
const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
|
|
4507
|
+
if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
|
|
3321
4508
|
return;
|
|
3322
4509
|
}
|
|
3323
4510
|
if (this.cachedFlagState === null) {
|
|
@@ -3336,6 +4523,7 @@ var Schematic = class {
|
|
|
3336
4523
|
checks: cleanChecks,
|
|
3337
4524
|
plan: planForContext,
|
|
3338
4525
|
creditBalances: creditBalancesForContext,
|
|
4526
|
+
creditSpendPolicies: creditSpendPoliciesForContext,
|
|
3339
4527
|
updatedAt: Date.now()
|
|
3340
4528
|
};
|
|
3341
4529
|
const entries = Object.entries(this.cachedFlagState.contexts);
|
|
@@ -3352,6 +4540,9 @@ var Schematic = class {
|
|
|
3352
4540
|
for (const key of Object.keys(this.creditBalances)) {
|
|
3353
4541
|
if (!survivorKeys.has(key)) delete this.creditBalances[key];
|
|
3354
4542
|
}
|
|
4543
|
+
for (const key of Object.keys(this.creditSpendPolicies)) {
|
|
4544
|
+
if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
|
|
4545
|
+
}
|
|
3355
4546
|
this.cachedFlagState = {
|
|
3356
4547
|
version: cacheVersion,
|
|
3357
4548
|
contexts: Object.fromEntries(survivors)
|
|
@@ -3390,12 +4581,17 @@ var Schematic = class {
|
|
|
3390
4581
|
this.debug(`event not sent (offline mode):`, { event });
|
|
3391
4582
|
return Promise.resolve();
|
|
3392
4583
|
}
|
|
4584
|
+
const maybeSigHeaders = this.contextSignatureHeaders(
|
|
4585
|
+
extractEventContext(event)
|
|
4586
|
+
);
|
|
4587
|
+
const sigHeaders = maybeSigHeaders instanceof Promise ? await maybeSigHeaders : maybeSigHeaders;
|
|
3393
4588
|
try {
|
|
3394
4589
|
const response = await fetch(captureUrl, {
|
|
3395
4590
|
method: "POST",
|
|
3396
4591
|
headers: {
|
|
3397
4592
|
...this._additionalHeaders ?? {},
|
|
3398
|
-
"Content-Type": "application/json;charset=UTF-8"
|
|
4593
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
4594
|
+
...sigHeaders
|
|
3399
4595
|
},
|
|
3400
4596
|
body: payload
|
|
3401
4597
|
});
|
|
@@ -3579,6 +4775,7 @@ var Schematic = class {
|
|
|
3579
4775
|
* In offline mode, this is a no-op.
|
|
3580
4776
|
*/
|
|
3581
4777
|
cleanup = async () => {
|
|
4778
|
+
this.contextSignatureManager?.clear();
|
|
3582
4779
|
if (this.isOffline()) {
|
|
3583
4780
|
this.debug("cleanup: skipped (offline mode)");
|
|
3584
4781
|
return Promise.resolve();
|
|
@@ -3864,7 +5061,7 @@ var Schematic = class {
|
|
|
3864
5061
|
context
|
|
3865
5062
|
);
|
|
3866
5063
|
this.context = context;
|
|
3867
|
-
const sendMessage = () => {
|
|
5064
|
+
const sendMessage = async () => {
|
|
3868
5065
|
let resolved = false;
|
|
3869
5066
|
const persistentMessageHandler = this.createPersistentMessageHandler(context);
|
|
3870
5067
|
const messageHandler = (event) => {
|
|
@@ -3891,20 +5088,22 @@ var Schematic = class {
|
|
|
3891
5088
|
});
|
|
3892
5089
|
this.currentWebSocket = socket;
|
|
3893
5090
|
const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
|
|
5091
|
+
const sig = await this.contextSignature(context);
|
|
3894
5092
|
const messagePayload = {
|
|
3895
5093
|
apiKey: this.apiKey,
|
|
3896
5094
|
clientVersion,
|
|
3897
|
-
data: context
|
|
5095
|
+
data: context,
|
|
5096
|
+
...sig !== void 0 ? { sig } : {}
|
|
3898
5097
|
};
|
|
3899
5098
|
this.debug(`WebSocket sending message:`, messagePayload);
|
|
3900
5099
|
socket.send(JSON.stringify(messagePayload));
|
|
3901
5100
|
};
|
|
3902
5101
|
if (socket.readyState === WebSocket.OPEN) {
|
|
3903
5102
|
this.debug(`WebSocket already open, sending message`);
|
|
3904
|
-
sendMessage();
|
|
5103
|
+
void sendMessage();
|
|
3905
5104
|
} else if (socket.readyState === WebSocket.CONNECTING) {
|
|
3906
5105
|
this.debug(`WebSocket connecting, waiting for open to send message`);
|
|
3907
|
-
socket.addEventListener("open", sendMessage);
|
|
5106
|
+
socket.addEventListener("open", () => void sendMessage());
|
|
3908
5107
|
} else {
|
|
3909
5108
|
this.debug(`WebSocket is closed, cannot send message`);
|
|
3910
5109
|
reject("WebSocket is not open or connecting");
|
|
@@ -3946,6 +5145,18 @@ var Schematic = class {
|
|
|
3946
5145
|
const contextStr = contextString(this.context);
|
|
3947
5146
|
return this.creditBalances[contextStr]?.[creditId];
|
|
3948
5147
|
};
|
|
5148
|
+
/** Get every credit spend policy binding the current context, company-scope first */
|
|
5149
|
+
getCreditSpendPolicies = () => {
|
|
5150
|
+
const contextStr = contextString(this.context);
|
|
5151
|
+
return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
|
|
5152
|
+
};
|
|
5153
|
+
/** Get the spend policies binding a single credit type in the current context */
|
|
5154
|
+
getCreditSpendPoliciesForCredit = (creditId) => {
|
|
5155
|
+
const policies = this.getCreditSpendPolicies().filter(
|
|
5156
|
+
(policy) => policy.creditId === creditId
|
|
5157
|
+
);
|
|
5158
|
+
return policies.length > 0 ? policies : emptyCreditSpendPolicies;
|
|
5159
|
+
};
|
|
3949
5160
|
// flag checks state
|
|
3950
5161
|
getFlagCheck = (flagKey) => {
|
|
3951
5162
|
const contextStr = contextString(this.context);
|
|
@@ -4012,6 +5223,13 @@ var Schematic = class {
|
|
|
4012
5223
|
this.creditBalanceListeners.delete(listener);
|
|
4013
5224
|
};
|
|
4014
5225
|
};
|
|
5226
|
+
/** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
|
|
5227
|
+
addCreditSpendPolicyListener = (listener) => {
|
|
5228
|
+
this.creditSpendPolicyListeners.add(listener);
|
|
5229
|
+
return () => {
|
|
5230
|
+
this.creditSpendPolicyListeners.delete(listener);
|
|
5231
|
+
};
|
|
5232
|
+
};
|
|
4015
5233
|
notifyFlagCheckListeners = (flagKey, check) => {
|
|
4016
5234
|
const listeners = this.flagCheckListeners?.[flagKey] ?? [];
|
|
4017
5235
|
if (listeners.size > 0) {
|
|
@@ -4075,6 +5293,16 @@ var Schematic = class {
|
|
|
4075
5293
|
});
|
|
4076
5294
|
});
|
|
4077
5295
|
};
|
|
5296
|
+
notifyCreditSpendPolicyListeners = (value) => {
|
|
5297
|
+
const listeners = this.creditSpendPolicyListeners ?? [];
|
|
5298
|
+
listeners.forEach((listener) => {
|
|
5299
|
+
if (listener.length > 0) {
|
|
5300
|
+
listener(value);
|
|
5301
|
+
return;
|
|
5302
|
+
}
|
|
5303
|
+
listener();
|
|
5304
|
+
});
|
|
5305
|
+
};
|
|
4078
5306
|
notifyCreditBalanceListeners = (value) => {
|
|
4079
5307
|
const listeners = this.creditBalanceListeners ?? [];
|
|
4080
5308
|
if (listeners.size > 0) {
|
|
@@ -4478,6 +5706,7 @@ var READINESS = {
|
|
|
4478
5706
|
active: "ready",
|
|
4479
5707
|
ended: "never"
|
|
4480
5708
|
};
|
|
5709
|
+
var FEATURE_USER_USAGE_LIMIT = 20;
|
|
4481
5710
|
var BillingStore = class {
|
|
4482
5711
|
constructor(_client, initialData = {}, options = {}) {
|
|
4483
5712
|
this._client = _client;
|
|
@@ -4498,6 +5727,17 @@ var BillingStore = class {
|
|
|
4498
5727
|
() => this._client.fetchPaymentMethods(),
|
|
4499
5728
|
{ readiness }
|
|
4500
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
|
+
);
|
|
4501
5741
|
const held = { key: initialData.sessionKey };
|
|
4502
5742
|
if (initialData.invoices !== void 0) {
|
|
4503
5743
|
held.invoices = {
|
|
@@ -4515,7 +5755,10 @@ var BillingStore = class {
|
|
|
4515
5755
|
if (initialData.paymentMethods !== void 0) {
|
|
4516
5756
|
held.paymentMethods = initialData.paymentMethods;
|
|
4517
5757
|
}
|
|
4518
|
-
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) {
|
|
4519
5762
|
this._held = held;
|
|
4520
5763
|
this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
|
|
4521
5764
|
}
|
|
@@ -4524,6 +5767,8 @@ var BillingStore = class {
|
|
|
4524
5767
|
invoices;
|
|
4525
5768
|
upcomingInvoice;
|
|
4526
5769
|
paymentMethods;
|
|
5770
|
+
featureUsage;
|
|
5771
|
+
featureUserUsage;
|
|
4527
5772
|
_pageSize;
|
|
4528
5773
|
_unsubscribe;
|
|
4529
5774
|
_connected = false;
|
|
@@ -4602,6 +5847,9 @@ var BillingStore = class {
|
|
|
4602
5847
|
if (held.paymentMethods !== void 0) {
|
|
4603
5848
|
this.paymentMethods.seed(SINGLETON, held.paymentMethods);
|
|
4604
5849
|
}
|
|
5850
|
+
if (held.featureUsage !== void 0) {
|
|
5851
|
+
this.featureUsage.seed(SINGLETON, held.featureUsage);
|
|
5852
|
+
}
|
|
4605
5853
|
this._seedKey = held.key;
|
|
4606
5854
|
this._seeded = true;
|
|
4607
5855
|
}
|
|
@@ -4614,24 +5862,28 @@ var BillingStore = class {
|
|
|
4614
5862
|
for (const name of RESOURCE_NAMES) {
|
|
4615
5863
|
this[name].resetAll();
|
|
4616
5864
|
}
|
|
5865
|
+
this.featureUserUsage.resetAll();
|
|
4617
5866
|
}
|
|
4618
5867
|
/** Forgets every resource and leaves them empty; nothing reloads. */
|
|
4619
5868
|
clearAll() {
|
|
4620
5869
|
for (const name of RESOURCE_NAMES) {
|
|
4621
5870
|
this[name].clearAll();
|
|
4622
5871
|
}
|
|
5872
|
+
this.featureUserUsage.clearAll();
|
|
4623
5873
|
}
|
|
4624
5874
|
/** Loads every resource that is subscribed and has nothing yet. */
|
|
4625
5875
|
resumeAll() {
|
|
4626
5876
|
for (const name of RESOURCE_NAMES) {
|
|
4627
5877
|
this[name].resumeAll();
|
|
4628
5878
|
}
|
|
5879
|
+
this.featureUserUsage.resumeAll();
|
|
4629
5880
|
}
|
|
4630
5881
|
/** Reloads every resource that has been loaded, keeping its current data. */
|
|
4631
5882
|
invalidateAll() {
|
|
4632
5883
|
for (const name of RESOURCE_NAMES) {
|
|
4633
5884
|
this[name].invalidateAll();
|
|
4634
5885
|
}
|
|
5886
|
+
this.featureUserUsage.invalidateAll();
|
|
4635
5887
|
}
|
|
4636
5888
|
/**
|
|
4637
5889
|
* Appends the next page to the invoices list for `query`, when there is
|
|
@@ -4743,7 +5995,8 @@ var BillingStore = class {
|
|
|
4743
5995
|
var RESOURCE_NAMES = [
|
|
4744
5996
|
"invoices",
|
|
4745
5997
|
"upcomingInvoice",
|
|
4746
|
-
"paymentMethods"
|
|
5998
|
+
"paymentMethods",
|
|
5999
|
+
"featureUsage"
|
|
4747
6000
|
];
|
|
4748
6001
|
|
|
4749
6002
|
// src/billing/context.tsx
|
|
@@ -4823,6 +6076,9 @@ var missingBillingSource = {
|
|
|
4823
6076
|
subscribe: () => () => {
|
|
4824
6077
|
},
|
|
4825
6078
|
handle: () => missingHandle,
|
|
6079
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6080
|
+
},
|
|
6081
|
+
featureUserUsage: () => missingHandle,
|
|
4826
6082
|
loadMoreInvoices: () => Promise.resolve(),
|
|
4827
6083
|
invalidateAll: () => {
|
|
4828
6084
|
},
|
|
@@ -4837,6 +6093,7 @@ function BillingDataProvider({
|
|
|
4837
6093
|
actions,
|
|
4838
6094
|
children,
|
|
4839
6095
|
data,
|
|
6096
|
+
featureUserUsage,
|
|
4840
6097
|
locale,
|
|
4841
6098
|
onLoadMoreInvoices,
|
|
4842
6099
|
onMissingString,
|
|
@@ -4847,6 +6104,7 @@ function BillingDataProvider({
|
|
|
4847
6104
|
}) {
|
|
4848
6105
|
const source = (0, import_react2.useMemo)(() => {
|
|
4849
6106
|
const handles = /* @__PURE__ */ new Map();
|
|
6107
|
+
const userUsageHandles = /* @__PURE__ */ new Map();
|
|
4850
6108
|
return {
|
|
4851
6109
|
actions: rejectingActions(
|
|
4852
6110
|
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
|
|
@@ -4870,6 +6128,24 @@ function BillingDataProvider({
|
|
|
4870
6128
|
handles.set(name, handle);
|
|
4871
6129
|
return handle;
|
|
4872
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
|
+
},
|
|
4873
6149
|
loadMoreInvoices: (query) => {
|
|
4874
6150
|
onLoadMoreInvoices?.(query);
|
|
4875
6151
|
return Promise.resolve();
|
|
@@ -4877,7 +6153,7 @@ function BillingDataProvider({
|
|
|
4877
6153
|
invalidateAll: () => {
|
|
4878
6154
|
}
|
|
4879
6155
|
};
|
|
4880
|
-
}, [actions, data, onLoadMoreInvoices, onRefetch, status]);
|
|
6156
|
+
}, [actions, data, featureUserUsage, onLoadMoreInvoices, onRefetch, status]);
|
|
4881
6157
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
4882
6158
|
SchematicI18nProvider,
|
|
4883
6159
|
{
|
|
@@ -4967,6 +6243,21 @@ function useSetupIntent() {
|
|
|
4967
6243
|
[source]
|
|
4968
6244
|
);
|
|
4969
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
|
+
}
|
|
4970
6261
|
function useInvalidateBillingData() {
|
|
4971
6262
|
return useBillingDataSource().invalidateAll;
|
|
4972
6263
|
}
|
|
@@ -5022,8 +6313,7 @@ function BillingProvider({
|
|
|
5022
6313
|
return initialRef.current === void 0 ? void 0 : staticSource(initialRef.current);
|
|
5023
6314
|
}
|
|
5024
6315
|
const handles = /* @__PURE__ */ new WeakMap();
|
|
5025
|
-
const
|
|
5026
|
-
const resource = store.resource(name).get(params);
|
|
6316
|
+
const handleOf = (resource) => {
|
|
5027
6317
|
const snapshot = resource.getSnapshot();
|
|
5028
6318
|
const cached = handles.get(resource);
|
|
5029
6319
|
if (cached !== void 0 && cached.snapshot === snapshot) {
|
|
@@ -5033,12 +6323,18 @@ function BillingProvider({
|
|
|
5033
6323
|
...snapshot,
|
|
5034
6324
|
refetch: () => void resource.refetch()
|
|
5035
6325
|
};
|
|
5036
|
-
handles.set(resource, {
|
|
6326
|
+
handles.set(resource, {
|
|
6327
|
+
snapshot,
|
|
6328
|
+
handle: next
|
|
6329
|
+
});
|
|
5037
6330
|
return next;
|
|
5038
6331
|
};
|
|
6332
|
+
const handle = (name, params) => handleOf(store.resource(name).get(params));
|
|
5039
6333
|
return {
|
|
5040
6334
|
subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
|
|
5041
6335
|
handle,
|
|
6336
|
+
subscribeFeatureUserUsage: (featureId, listener) => store.featureUserUsage.subscribe({ featureId }, listener),
|
|
6337
|
+
featureUserUsage: (featureId) => handleOf(store.featureUserUsage.get({ featureId })),
|
|
5042
6338
|
loadMoreInvoices: (query) => store.loadMoreInvoices(query),
|
|
5043
6339
|
invalidateAll: () => store.invalidateAll(),
|
|
5044
6340
|
actions: {
|
|
@@ -5065,7 +6361,17 @@ function BillingProvider({
|
|
|
5065
6361
|
}
|
|
5066
6362
|
function staticSource(data) {
|
|
5067
6363
|
const handles = /* @__PURE__ */ new Map();
|
|
6364
|
+
const pendingUserUsage = {
|
|
6365
|
+
data: void 0,
|
|
6366
|
+
error: void 0,
|
|
6367
|
+
isPending: true,
|
|
6368
|
+
refetch: () => {
|
|
6369
|
+
}
|
|
6370
|
+
};
|
|
5068
6371
|
return {
|
|
6372
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6373
|
+
},
|
|
6374
|
+
featureUserUsage: () => pendingUserUsage,
|
|
5069
6375
|
subscribe: () => () => {
|
|
5070
6376
|
},
|
|
5071
6377
|
handle: (name) => {
|
|
@@ -5091,7 +6397,7 @@ function staticSource(data) {
|
|
|
5091
6397
|
}
|
|
5092
6398
|
|
|
5093
6399
|
// src/version.ts
|
|
5094
|
-
var version2 = "1.
|
|
6400
|
+
var version2 = "1.11.0";
|
|
5095
6401
|
|
|
5096
6402
|
// src/context/schematic.tsx
|
|
5097
6403
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -5184,6 +6490,7 @@ var useSchematic = () => {
|
|
|
5184
6490
|
|
|
5185
6491
|
// src/hooks/schematic.ts
|
|
5186
6492
|
var import_react6 = require("react");
|
|
6493
|
+
var emptyPolicies = [];
|
|
5187
6494
|
var useSchematicClient = (opts) => {
|
|
5188
6495
|
const schematic = useSchematic();
|
|
5189
6496
|
const { client } = opts ?? {};
|
|
@@ -5299,6 +6606,34 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
5299
6606
|
[balance, isPending]
|
|
5300
6607
|
);
|
|
5301
6608
|
};
|
|
6609
|
+
var useSchematicCreditSpendPolicies = (opts) => {
|
|
6610
|
+
const client = useSchematicClient(opts);
|
|
6611
|
+
const subscribe = (0, import_react6.useCallback)(
|
|
6612
|
+
(callback) => client.addCreditSpendPolicyListener(callback),
|
|
6613
|
+
[client]
|
|
6614
|
+
);
|
|
6615
|
+
const policies = (0, import_react6.useSyncExternalStore)(
|
|
6616
|
+
subscribe,
|
|
6617
|
+
() => client.getCreditSpendPolicies(),
|
|
6618
|
+
() => emptyPolicies
|
|
6619
|
+
);
|
|
6620
|
+
const isPendingSubscribe = (0, import_react6.useCallback)(
|
|
6621
|
+
(callback) => client.addIsPendingListener(callback),
|
|
6622
|
+
[client]
|
|
6623
|
+
);
|
|
6624
|
+
const isPending = (0, import_react6.useSyncExternalStore)(
|
|
6625
|
+
isPendingSubscribe,
|
|
6626
|
+
() => client.getIsPending(),
|
|
6627
|
+
() => true
|
|
6628
|
+
);
|
|
6629
|
+
return (0, import_react6.useMemo)(
|
|
6630
|
+
() => ({
|
|
6631
|
+
policies,
|
|
6632
|
+
isLoading: policies.length === 0 && isPending
|
|
6633
|
+
}),
|
|
6634
|
+
[policies, isPending]
|
|
6635
|
+
);
|
|
6636
|
+
};
|
|
5302
6637
|
var useSchematicIsPending = (opts) => {
|
|
5303
6638
|
const client = useSchematicClient(opts);
|
|
5304
6639
|
const subscribe = (0, import_react6.useCallback)(
|