@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
1
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.11.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -994,6 +994,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
994
994
|
trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
|
|
995
995
|
};
|
|
996
996
|
}
|
|
997
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
998
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
999
|
+
}
|
|
1000
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
1001
|
+
return json;
|
|
1002
|
+
}
|
|
1003
|
+
function CreditSpendWindowFromJSON(json) {
|
|
1004
|
+
return CreditSpendWindowFromJSONTyped(json, false);
|
|
1005
|
+
}
|
|
1006
|
+
function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
|
|
1007
|
+
if (json == null) {
|
|
1008
|
+
return json;
|
|
1009
|
+
}
|
|
1010
|
+
return {
|
|
1011
|
+
count: json["count"],
|
|
1012
|
+
unit: json["unit"]
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
function CreditSpendPolicyFromJSON(json) {
|
|
1016
|
+
return CreditSpendPolicyFromJSONTyped(json, false);
|
|
1017
|
+
}
|
|
1018
|
+
function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1019
|
+
if (json == null) {
|
|
1020
|
+
return json;
|
|
1021
|
+
}
|
|
1022
|
+
return {
|
|
1023
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
1024
|
+
creditId: json["credit_id"],
|
|
1025
|
+
id: json["id"],
|
|
1026
|
+
kind: json["kind"],
|
|
1027
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
1028
|
+
limit: json["limit"],
|
|
1029
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
1030
|
+
scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
|
|
1031
|
+
window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
997
1034
|
function CheckFlagsResponseDataFromJSON(json) {
|
|
998
1035
|
return CheckFlagsResponseDataFromJSONTyped(json, false);
|
|
999
1036
|
}
|
|
@@ -1003,6 +1040,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
1003
1040
|
}
|
|
1004
1041
|
return {
|
|
1005
1042
|
creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
|
|
1043
|
+
creditSpendPolicies: json["credit_spend_policies"].map(
|
|
1044
|
+
CreditSpendPolicyFromJSON
|
|
1045
|
+
),
|
|
1006
1046
|
flags: json["flags"].map(CheckFlagResponseDataFromJSON),
|
|
1007
1047
|
plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
|
|
1008
1048
|
};
|
|
@@ -1131,7 +1171,55 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1131
1171
|
}
|
|
1132
1172
|
return balances;
|
|
1133
1173
|
};
|
|
1134
|
-
var
|
|
1174
|
+
var CreditSpendPoliciesFromJSON = (json) => {
|
|
1175
|
+
if (!Array.isArray(json)) {
|
|
1176
|
+
return [];
|
|
1177
|
+
}
|
|
1178
|
+
const policies = [];
|
|
1179
|
+
for (const raw of json) {
|
|
1180
|
+
if (raw == null || typeof raw !== "object") continue;
|
|
1181
|
+
const id = raw.id;
|
|
1182
|
+
const creditId = raw.credit_id ?? raw.creditId;
|
|
1183
|
+
const kind = raw.kind;
|
|
1184
|
+
const scope = raw.scope;
|
|
1185
|
+
const limit = raw.limit;
|
|
1186
|
+
if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
const policy = {
|
|
1190
|
+
id,
|
|
1191
|
+
creditId,
|
|
1192
|
+
kind,
|
|
1193
|
+
scope,
|
|
1194
|
+
limit,
|
|
1195
|
+
consumed: typeof raw.consumed === "number" ? raw.consumed : 0
|
|
1196
|
+
};
|
|
1197
|
+
if (typeof raw.label === "string") {
|
|
1198
|
+
policy.label = raw.label;
|
|
1199
|
+
}
|
|
1200
|
+
const window2 = raw.window;
|
|
1201
|
+
if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
|
|
1202
|
+
policy.window = { unit: window2.unit, count: window2.count };
|
|
1203
|
+
}
|
|
1204
|
+
const resetsAt = raw.resets_at ?? raw.resetsAt;
|
|
1205
|
+
if (typeof resetsAt === "string" || resetsAt instanceof Date) {
|
|
1206
|
+
const parsed = new Date(resetsAt);
|
|
1207
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
1208
|
+
policy.resetsAt = parsed;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
policies.push(policy);
|
|
1212
|
+
}
|
|
1213
|
+
return policies;
|
|
1214
|
+
};
|
|
1215
|
+
var creditSpendPoliciesEqual = (a, b) => {
|
|
1216
|
+
if (a.length !== b.length) return false;
|
|
1217
|
+
return a.every((x, i) => {
|
|
1218
|
+
const y = b[i];
|
|
1219
|
+
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;
|
|
1220
|
+
});
|
|
1221
|
+
};
|
|
1222
|
+
var cacheVersion = "35d92bc6";
|
|
1135
1223
|
function contextString(context) {
|
|
1136
1224
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1137
1225
|
const sortedKeys = Object.keys(
|
|
@@ -1146,7 +1234,98 @@ function contextString(context) {
|
|
|
1146
1234
|
}, {});
|
|
1147
1235
|
return JSON.stringify(sortedContext);
|
|
1148
1236
|
}
|
|
1149
|
-
var
|
|
1237
|
+
var contextSignatureHeader = "X-Schematic-Context-Sig";
|
|
1238
|
+
var refreshSkewMs = 6e4;
|
|
1239
|
+
var maxCachedSignatures = 50;
|
|
1240
|
+
function parseSignatureExpiryMs(signature) {
|
|
1241
|
+
const parts = signature.split(".");
|
|
1242
|
+
if (parts.length !== 3) {
|
|
1243
|
+
return null;
|
|
1244
|
+
}
|
|
1245
|
+
const expSeconds = Number(parts[1]);
|
|
1246
|
+
if (!Number.isFinite(expSeconds)) {
|
|
1247
|
+
return null;
|
|
1248
|
+
}
|
|
1249
|
+
return expSeconds * 1e3;
|
|
1250
|
+
}
|
|
1251
|
+
var ContextSignatureManager = class {
|
|
1252
|
+
provider;
|
|
1253
|
+
debug;
|
|
1254
|
+
cache = /* @__PURE__ */ new Map();
|
|
1255
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
1256
|
+
constructor(provider, debug) {
|
|
1257
|
+
this.provider = provider;
|
|
1258
|
+
this.debug = debug;
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Return a valid signature for the given context, fetching a fresh one via
|
|
1262
|
+
* the provider when the cache is empty or close to expiry. Concurrent calls
|
|
1263
|
+
* for the same context share a single provider invocation. Returns undefined
|
|
1264
|
+
* (and logs a warning) if the provider throws, so callers can degrade
|
|
1265
|
+
* gracefully by sending the request without a signature.
|
|
1266
|
+
*/
|
|
1267
|
+
async getSignature(context) {
|
|
1268
|
+
const key = contextString(context);
|
|
1269
|
+
const cached = this.cache.get(key);
|
|
1270
|
+
if (cached !== void 0 && Date.now() < cached.expiresAtMs - refreshSkewMs) {
|
|
1271
|
+
this.cache.delete(key);
|
|
1272
|
+
this.cache.set(key, cached);
|
|
1273
|
+
return cached.signature;
|
|
1274
|
+
}
|
|
1275
|
+
const existing = this.inFlight.get(key);
|
|
1276
|
+
if (existing !== void 0) {
|
|
1277
|
+
return existing;
|
|
1278
|
+
}
|
|
1279
|
+
const pending = this.fetchSignature(key, context).finally(() => {
|
|
1280
|
+
this.inFlight.delete(key);
|
|
1281
|
+
});
|
|
1282
|
+
this.inFlight.set(key, pending);
|
|
1283
|
+
return pending;
|
|
1284
|
+
}
|
|
1285
|
+
/** Drop all cached signatures. */
|
|
1286
|
+
clear() {
|
|
1287
|
+
this.cache.clear();
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Drop expired signatures, then the least recently used ones until the cache
|
|
1291
|
+
* is within `maxCachedSignatures`.
|
|
1292
|
+
*/
|
|
1293
|
+
evict() {
|
|
1294
|
+
const now = Date.now();
|
|
1295
|
+
for (const [key, entry] of this.cache) {
|
|
1296
|
+
if (now >= entry.expiresAtMs) {
|
|
1297
|
+
this.cache.delete(key);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
for (const key of this.cache.keys()) {
|
|
1301
|
+
if (this.cache.size <= maxCachedSignatures) {
|
|
1302
|
+
break;
|
|
1303
|
+
}
|
|
1304
|
+
this.cache.delete(key);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
async fetchSignature(key, context) {
|
|
1308
|
+
try {
|
|
1309
|
+
const signature = await this.provider(context);
|
|
1310
|
+
const expiresAtMs = parseSignatureExpiryMs(signature);
|
|
1311
|
+
if (expiresAtMs === null) {
|
|
1312
|
+
this.debug(
|
|
1313
|
+
"getContextSignature returned a value without a parseable expiry; not caching",
|
|
1314
|
+
{ signature }
|
|
1315
|
+
);
|
|
1316
|
+
return signature;
|
|
1317
|
+
}
|
|
1318
|
+
this.cache.delete(key);
|
|
1319
|
+
this.cache.set(key, { signature, expiresAtMs });
|
|
1320
|
+
this.evict();
|
|
1321
|
+
return signature;
|
|
1322
|
+
} catch (error) {
|
|
1323
|
+
console.warn("Failed to obtain context signature:", error);
|
|
1324
|
+
return void 0;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
var version = "1.11.0";
|
|
1150
1329
|
var SINGLETON = {};
|
|
1151
1330
|
var models_exports = {};
|
|
1152
1331
|
__export(models_exports, {
|
|
@@ -1154,15 +1333,59 @@ __export(models_exports, {
|
|
|
1154
1333
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1155
1334
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1156
1335
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1336
|
+
BillingPlanCreditGrantResetCadence: () => BillingPlanCreditGrantResetCadence,
|
|
1337
|
+
BillingPlanCreditGrantResetCadenceFromJSON: () => BillingPlanCreditGrantResetCadenceFromJSON2,
|
|
1338
|
+
BillingPlanCreditGrantResetCadenceFromJSONTyped: () => BillingPlanCreditGrantResetCadenceFromJSONTyped3,
|
|
1339
|
+
BillingPlanCreditGrantResetCadenceToJSON: () => BillingPlanCreditGrantResetCadenceToJSON2,
|
|
1340
|
+
BillingPlanCreditGrantResetCadenceToJSONTyped: () => BillingPlanCreditGrantResetCadenceToJSONTyped3,
|
|
1341
|
+
BillingPriceScheme: () => BillingPriceScheme,
|
|
1342
|
+
BillingPriceSchemeFromJSON: () => BillingPriceSchemeFromJSON2,
|
|
1343
|
+
BillingPriceSchemeFromJSONTyped: () => BillingPriceSchemeFromJSONTyped4,
|
|
1344
|
+
BillingPriceSchemeToJSON: () => BillingPriceSchemeToJSON2,
|
|
1345
|
+
BillingPriceSchemeToJSONTyped: () => BillingPriceSchemeToJSONTyped4,
|
|
1346
|
+
BillingProductPriceInterval: () => BillingProductPriceInterval,
|
|
1347
|
+
BillingProductPriceIntervalFromJSON: () => BillingProductPriceIntervalFromJSON2,
|
|
1348
|
+
BillingProductPriceIntervalFromJSONTyped: () => BillingProductPriceIntervalFromJSONTyped4,
|
|
1349
|
+
BillingProductPriceIntervalToJSON: () => BillingProductPriceIntervalToJSON2,
|
|
1350
|
+
BillingProductPriceIntervalToJSONTyped: () => BillingProductPriceIntervalToJSONTyped4,
|
|
1157
1351
|
BillingProviderType: () => BillingProviderType,
|
|
1158
1352
|
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1159
1353
|
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1160
1354
|
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1161
1355
|
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1356
|
+
BillingTiersMode: () => BillingTiersMode,
|
|
1357
|
+
BillingTiersModeFromJSON: () => BillingTiersModeFromJSON2,
|
|
1358
|
+
BillingTiersModeFromJSONTyped: () => BillingTiersModeFromJSONTyped4,
|
|
1359
|
+
BillingTiersModeToJSON: () => BillingTiersModeToJSON2,
|
|
1360
|
+
BillingTiersModeToJSONTyped: () => BillingTiersModeToJSONTyped4,
|
|
1361
|
+
CatalogCreditGrantResponseDataFromJSON: () => CatalogCreditGrantResponseDataFromJSON,
|
|
1362
|
+
CatalogCreditGrantResponseDataFromJSONTyped: () => CatalogCreditGrantResponseDataFromJSONTyped,
|
|
1363
|
+
CatalogCreditGrantResponseDataToJSON: () => CatalogCreditGrantResponseDataToJSON,
|
|
1364
|
+
CatalogCreditGrantResponseDataToJSONTyped: () => CatalogCreditGrantResponseDataToJSONTyped,
|
|
1365
|
+
CatalogPriceResponseDataFromJSON: () => CatalogPriceResponseDataFromJSON,
|
|
1366
|
+
CatalogPriceResponseDataFromJSONTyped: () => CatalogPriceResponseDataFromJSONTyped,
|
|
1367
|
+
CatalogPriceResponseDataToJSON: () => CatalogPriceResponseDataToJSON,
|
|
1368
|
+
CatalogPriceResponseDataToJSONTyped: () => CatalogPriceResponseDataToJSONTyped,
|
|
1369
|
+
CatalogPriceTierResponseDataFromJSON: () => CatalogPriceTierResponseDataFromJSON,
|
|
1370
|
+
CatalogPriceTierResponseDataFromJSONTyped: () => CatalogPriceTierResponseDataFromJSONTyped,
|
|
1371
|
+
CatalogPriceTierResponseDataToJSON: () => CatalogPriceTierResponseDataToJSON,
|
|
1372
|
+
CatalogPriceTierResponseDataToJSONTyped: () => CatalogPriceTierResponseDataToJSONTyped,
|
|
1162
1373
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1163
1374
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1164
1375
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
1165
1376
|
CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
|
|
1377
|
+
CompanyFeatureUsageListResponseDataFromJSON: () => CompanyFeatureUsageListResponseDataFromJSON,
|
|
1378
|
+
CompanyFeatureUsageListResponseDataFromJSONTyped: () => CompanyFeatureUsageListResponseDataFromJSONTyped,
|
|
1379
|
+
CompanyFeatureUsageListResponseDataToJSON: () => CompanyFeatureUsageListResponseDataToJSON,
|
|
1380
|
+
CompanyFeatureUsageListResponseDataToJSONTyped: () => CompanyFeatureUsageListResponseDataToJSONTyped,
|
|
1381
|
+
CompanyFeatureUsageResponseDataFromJSON: () => CompanyFeatureUsageResponseDataFromJSON,
|
|
1382
|
+
CompanyFeatureUsageResponseDataFromJSONTyped: () => CompanyFeatureUsageResponseDataFromJSONTyped,
|
|
1383
|
+
CompanyFeatureUsageResponseDataToJSON: () => CompanyFeatureUsageResponseDataToJSON,
|
|
1384
|
+
CompanyFeatureUsageResponseDataToJSONTyped: () => CompanyFeatureUsageResponseDataToJSONTyped,
|
|
1385
|
+
CompanyFeatureUserUsageResponseDataFromJSON: () => CompanyFeatureUserUsageResponseDataFromJSON,
|
|
1386
|
+
CompanyFeatureUserUsageResponseDataFromJSONTyped: () => CompanyFeatureUserUsageResponseDataFromJSONTyped,
|
|
1387
|
+
CompanyFeatureUserUsageResponseDataToJSON: () => CompanyFeatureUserUsageResponseDataToJSON,
|
|
1388
|
+
CompanyFeatureUserUsageResponseDataToJSONTyped: () => CompanyFeatureUserUsageResponseDataToJSONTyped,
|
|
1166
1389
|
CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
|
|
1167
1390
|
CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
|
|
1168
1391
|
CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
|
|
@@ -1183,6 +1406,10 @@ __export(models_exports, {
|
|
|
1183
1406
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1184
1407
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1185
1408
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1409
|
+
CompanyUserUsageResponseDataFromJSON: () => CompanyUserUsageResponseDataFromJSON,
|
|
1410
|
+
CompanyUserUsageResponseDataFromJSONTyped: () => CompanyUserUsageResponseDataFromJSONTyped,
|
|
1411
|
+
CompanyUserUsageResponseDataToJSON: () => CompanyUserUsageResponseDataToJSON,
|
|
1412
|
+
CompanyUserUsageResponseDataToJSONTyped: () => CompanyUserUsageResponseDataToJSONTyped,
|
|
1186
1413
|
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1187
1414
|
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1188
1415
|
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
@@ -1195,6 +1422,38 @@ __export(models_exports, {
|
|
|
1195
1422
|
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1196
1423
|
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1197
1424
|
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1425
|
+
EntitlementPriceBehavior: () => EntitlementPriceBehavior,
|
|
1426
|
+
EntitlementPriceBehaviorFromJSON: () => EntitlementPriceBehaviorFromJSON2,
|
|
1427
|
+
EntitlementPriceBehaviorFromJSONTyped: () => EntitlementPriceBehaviorFromJSONTyped2,
|
|
1428
|
+
EntitlementPriceBehaviorToJSON: () => EntitlementPriceBehaviorToJSON2,
|
|
1429
|
+
EntitlementPriceBehaviorToJSONTyped: () => EntitlementPriceBehaviorToJSONTyped2,
|
|
1430
|
+
EntitlementType: () => EntitlementType,
|
|
1431
|
+
EntitlementTypeFromJSON: () => EntitlementTypeFromJSON,
|
|
1432
|
+
EntitlementTypeFromJSONTyped: () => EntitlementTypeFromJSONTyped,
|
|
1433
|
+
EntitlementTypeToJSON: () => EntitlementTypeToJSON,
|
|
1434
|
+
EntitlementTypeToJSONTyped: () => EntitlementTypeToJSONTyped,
|
|
1435
|
+
EntitlementValueType: () => EntitlementValueType,
|
|
1436
|
+
EntitlementValueTypeFromJSON: () => EntitlementValueTypeFromJSON2,
|
|
1437
|
+
EntitlementValueTypeFromJSONTyped: () => EntitlementValueTypeFromJSONTyped4,
|
|
1438
|
+
EntitlementValueTypeToJSON: () => EntitlementValueTypeToJSON2,
|
|
1439
|
+
EntitlementValueTypeToJSONTyped: () => EntitlementValueTypeToJSONTyped3,
|
|
1440
|
+
FeatureType: () => FeatureType,
|
|
1441
|
+
FeatureTypeFromJSON: () => FeatureTypeFromJSON2,
|
|
1442
|
+
FeatureTypeFromJSONTyped: () => FeatureTypeFromJSONTyped3,
|
|
1443
|
+
FeatureTypeToJSON: () => FeatureTypeToJSON2,
|
|
1444
|
+
FeatureTypeToJSONTyped: () => FeatureTypeToJSONTyped3,
|
|
1445
|
+
GetCompanyFeatureUsageResponseFromJSON: () => GetCompanyFeatureUsageResponseFromJSON,
|
|
1446
|
+
GetCompanyFeatureUsageResponseFromJSONTyped: () => GetCompanyFeatureUsageResponseFromJSONTyped,
|
|
1447
|
+
GetCompanyFeatureUsageResponseToJSON: () => GetCompanyFeatureUsageResponseToJSON,
|
|
1448
|
+
GetCompanyFeatureUsageResponseToJSONTyped: () => GetCompanyFeatureUsageResponseToJSONTyped,
|
|
1449
|
+
GetCompanyFeatureUserUsageParamsFromJSON: () => GetCompanyFeatureUserUsageParamsFromJSON,
|
|
1450
|
+
GetCompanyFeatureUserUsageParamsFromJSONTyped: () => GetCompanyFeatureUserUsageParamsFromJSONTyped,
|
|
1451
|
+
GetCompanyFeatureUserUsageParamsToJSON: () => GetCompanyFeatureUserUsageParamsToJSON,
|
|
1452
|
+
GetCompanyFeatureUserUsageParamsToJSONTyped: () => GetCompanyFeatureUserUsageParamsToJSONTyped,
|
|
1453
|
+
GetCompanyFeatureUserUsageResponseFromJSON: () => GetCompanyFeatureUserUsageResponseFromJSON,
|
|
1454
|
+
GetCompanyFeatureUserUsageResponseFromJSONTyped: () => GetCompanyFeatureUserUsageResponseFromJSONTyped,
|
|
1455
|
+
GetCompanyFeatureUserUsageResponseToJSON: () => GetCompanyFeatureUserUsageResponseToJSON,
|
|
1456
|
+
GetCompanyFeatureUserUsageResponseToJSONTyped: () => GetCompanyFeatureUserUsageResponseToJSONTyped,
|
|
1198
1457
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1199
1458
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1200
1459
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1216,10 +1475,25 @@ __export(models_exports, {
|
|
|
1216
1475
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1217
1476
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1218
1477
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1478
|
+
MetricPeriod: () => MetricPeriod,
|
|
1479
|
+
MetricPeriodFromJSON: () => MetricPeriodFromJSON2,
|
|
1480
|
+
MetricPeriodFromJSONTyped: () => MetricPeriodFromJSONTyped7,
|
|
1481
|
+
MetricPeriodMonthReset: () => MetricPeriodMonthReset,
|
|
1482
|
+
MetricPeriodMonthResetFromJSON: () => MetricPeriodMonthResetFromJSON2,
|
|
1483
|
+
MetricPeriodMonthResetFromJSONTyped: () => MetricPeriodMonthResetFromJSONTyped6,
|
|
1484
|
+
MetricPeriodMonthResetToJSON: () => MetricPeriodMonthResetToJSON2,
|
|
1485
|
+
MetricPeriodMonthResetToJSONTyped: () => MetricPeriodMonthResetToJSONTyped5,
|
|
1486
|
+
MetricPeriodToJSON: () => MetricPeriodToJSON2,
|
|
1487
|
+
MetricPeriodToJSONTyped: () => MetricPeriodToJSONTyped6,
|
|
1219
1488
|
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1220
1489
|
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1221
1490
|
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1222
1491
|
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1492
|
+
PlanCreditGrantScaling: () => PlanCreditGrantScaling,
|
|
1493
|
+
PlanCreditGrantScalingFromJSON: () => PlanCreditGrantScalingFromJSON2,
|
|
1494
|
+
PlanCreditGrantScalingFromJSONTyped: () => PlanCreditGrantScalingFromJSONTyped3,
|
|
1495
|
+
PlanCreditGrantScalingToJSON: () => PlanCreditGrantScalingToJSON2,
|
|
1496
|
+
PlanCreditGrantScalingToJSONTyped: () => PlanCreditGrantScalingToJSONTyped3,
|
|
1223
1497
|
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1224
1498
|
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1225
1499
|
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
@@ -1233,22 +1507,43 @@ __export(models_exports, {
|
|
|
1233
1507
|
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1234
1508
|
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1235
1509
|
instanceOfApiError: () => instanceOfApiError,
|
|
1510
|
+
instanceOfBillingPlanCreditGrantResetCadence: () => instanceOfBillingPlanCreditGrantResetCadence,
|
|
1511
|
+
instanceOfBillingPriceScheme: () => instanceOfBillingPriceScheme,
|
|
1512
|
+
instanceOfBillingProductPriceInterval: () => instanceOfBillingProductPriceInterval,
|
|
1236
1513
|
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1514
|
+
instanceOfBillingTiersMode: () => instanceOfBillingTiersMode,
|
|
1515
|
+
instanceOfCatalogCreditGrantResponseData: () => instanceOfCatalogCreditGrantResponseData,
|
|
1516
|
+
instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
|
|
1517
|
+
instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
|
|
1237
1518
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1519
|
+
instanceOfCompanyFeatureUsageListResponseData: () => instanceOfCompanyFeatureUsageListResponseData,
|
|
1520
|
+
instanceOfCompanyFeatureUsageResponseData: () => instanceOfCompanyFeatureUsageResponseData,
|
|
1521
|
+
instanceOfCompanyFeatureUserUsageResponseData: () => instanceOfCompanyFeatureUserUsageResponseData,
|
|
1238
1522
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1239
1523
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1240
1524
|
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1241
1525
|
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1242
1526
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1527
|
+
instanceOfCompanyUserUsageResponseData: () => instanceOfCompanyUserUsageResponseData,
|
|
1243
1528
|
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1244
1529
|
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1245
1530
|
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1531
|
+
instanceOfEntitlementPriceBehavior: () => instanceOfEntitlementPriceBehavior,
|
|
1532
|
+
instanceOfEntitlementType: () => instanceOfEntitlementType,
|
|
1533
|
+
instanceOfEntitlementValueType: () => instanceOfEntitlementValueType,
|
|
1534
|
+
instanceOfFeatureType: () => instanceOfFeatureType,
|
|
1535
|
+
instanceOfGetCompanyFeatureUsageResponse: () => instanceOfGetCompanyFeatureUsageResponse,
|
|
1536
|
+
instanceOfGetCompanyFeatureUserUsageParams: () => instanceOfGetCompanyFeatureUserUsageParams,
|
|
1537
|
+
instanceOfGetCompanyFeatureUserUsageResponse: () => instanceOfGetCompanyFeatureUserUsageResponse,
|
|
1246
1538
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1247
1539
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1248
1540
|
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1249
1541
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1250
1542
|
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1543
|
+
instanceOfMetricPeriod: () => instanceOfMetricPeriod,
|
|
1544
|
+
instanceOfMetricPeriodMonthReset: () => instanceOfMetricPeriodMonthReset,
|
|
1251
1545
|
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1546
|
+
instanceOfPlanCreditGrantScaling: () => instanceOfPlanCreditGrantScaling,
|
|
1252
1547
|
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1253
1548
|
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1254
1549
|
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
@@ -1257,94 +1552,771 @@ function instanceOfApiError(value) {
|
|
|
1257
1552
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
1258
1553
|
return true;
|
|
1259
1554
|
}
|
|
1260
|
-
function ApiErrorFromJSON(json) {
|
|
1261
|
-
return ApiErrorFromJSONTyped(json, false);
|
|
1555
|
+
function ApiErrorFromJSON(json) {
|
|
1556
|
+
return ApiErrorFromJSONTyped(json, false);
|
|
1557
|
+
}
|
|
1558
|
+
function ApiErrorFromJSONTyped(json, ignoreDiscriminator) {
|
|
1559
|
+
if (json == null) {
|
|
1560
|
+
return json;
|
|
1561
|
+
}
|
|
1562
|
+
return {
|
|
1563
|
+
error: json["error"]
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
function ApiErrorToJSON(json) {
|
|
1567
|
+
return ApiErrorToJSONTyped(json, false);
|
|
1568
|
+
}
|
|
1569
|
+
function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1570
|
+
if (value == null) {
|
|
1571
|
+
return value;
|
|
1572
|
+
}
|
|
1573
|
+
return {
|
|
1574
|
+
error: value["error"]
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
var BillingPlanCreditGrantResetCadence = {
|
|
1578
|
+
Daily: "daily",
|
|
1579
|
+
Every6Months: "every_6_months",
|
|
1580
|
+
Monthly: "monthly",
|
|
1581
|
+
Quarterly: "quarterly",
|
|
1582
|
+
Weekly: "weekly",
|
|
1583
|
+
Yearly: "yearly"
|
|
1584
|
+
};
|
|
1585
|
+
function instanceOfBillingPlanCreditGrantResetCadence(value) {
|
|
1586
|
+
for (const key in BillingPlanCreditGrantResetCadence) {
|
|
1587
|
+
if (Object.prototype.hasOwnProperty.call(
|
|
1588
|
+
BillingPlanCreditGrantResetCadence,
|
|
1589
|
+
key
|
|
1590
|
+
)) {
|
|
1591
|
+
if (BillingPlanCreditGrantResetCadence[key] === value) {
|
|
1592
|
+
return true;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
return false;
|
|
1597
|
+
}
|
|
1598
|
+
function BillingPlanCreditGrantResetCadenceFromJSON2(json) {
|
|
1599
|
+
return BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, false);
|
|
1600
|
+
}
|
|
1601
|
+
function BillingPlanCreditGrantResetCadenceFromJSONTyped3(json, ignoreDiscriminator) {
|
|
1602
|
+
return json;
|
|
1603
|
+
}
|
|
1604
|
+
function BillingPlanCreditGrantResetCadenceToJSON2(value) {
|
|
1605
|
+
return value;
|
|
1606
|
+
}
|
|
1607
|
+
function BillingPlanCreditGrantResetCadenceToJSONTyped3(value, ignoreDiscriminator) {
|
|
1608
|
+
return value;
|
|
1609
|
+
}
|
|
1610
|
+
var BillingPriceScheme = {
|
|
1611
|
+
PerUnit: "per_unit",
|
|
1612
|
+
Tiered: "tiered"
|
|
1613
|
+
};
|
|
1614
|
+
function instanceOfBillingPriceScheme(value) {
|
|
1615
|
+
for (const key in BillingPriceScheme) {
|
|
1616
|
+
if (Object.prototype.hasOwnProperty.call(BillingPriceScheme, key)) {
|
|
1617
|
+
if (BillingPriceScheme[key] === value) {
|
|
1618
|
+
return true;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
return false;
|
|
1623
|
+
}
|
|
1624
|
+
function BillingPriceSchemeFromJSON2(json) {
|
|
1625
|
+
return BillingPriceSchemeFromJSONTyped4(json, false);
|
|
1626
|
+
}
|
|
1627
|
+
function BillingPriceSchemeFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1628
|
+
return json;
|
|
1629
|
+
}
|
|
1630
|
+
function BillingPriceSchemeToJSON2(value) {
|
|
1631
|
+
return value;
|
|
1632
|
+
}
|
|
1633
|
+
function BillingPriceSchemeToJSONTyped4(value, ignoreDiscriminator) {
|
|
1634
|
+
return value;
|
|
1635
|
+
}
|
|
1636
|
+
var BillingProductPriceInterval = {
|
|
1637
|
+
Day: "day",
|
|
1638
|
+
Month: "month",
|
|
1639
|
+
OneTime: "one-time",
|
|
1640
|
+
Year: "year"
|
|
1641
|
+
};
|
|
1642
|
+
function instanceOfBillingProductPriceInterval(value) {
|
|
1643
|
+
for (const key in BillingProductPriceInterval) {
|
|
1644
|
+
if (Object.prototype.hasOwnProperty.call(BillingProductPriceInterval, key)) {
|
|
1645
|
+
if (BillingProductPriceInterval[key] === value) {
|
|
1646
|
+
return true;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
function BillingProductPriceIntervalFromJSON2(json) {
|
|
1653
|
+
return BillingProductPriceIntervalFromJSONTyped4(json, false);
|
|
1654
|
+
}
|
|
1655
|
+
function BillingProductPriceIntervalFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1656
|
+
return json;
|
|
1657
|
+
}
|
|
1658
|
+
function BillingProductPriceIntervalToJSON2(value) {
|
|
1659
|
+
return value;
|
|
1660
|
+
}
|
|
1661
|
+
function BillingProductPriceIntervalToJSONTyped4(value, ignoreDiscriminator) {
|
|
1662
|
+
return value;
|
|
1663
|
+
}
|
|
1664
|
+
var BillingProviderType = {
|
|
1665
|
+
Metronome: "metronome",
|
|
1666
|
+
Orb: "orb",
|
|
1667
|
+
Schematic: "schematic",
|
|
1668
|
+
Stripe: "stripe"
|
|
1669
|
+
};
|
|
1670
|
+
function instanceOfBillingProviderType(value) {
|
|
1671
|
+
for (const key in BillingProviderType) {
|
|
1672
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1673
|
+
if (BillingProviderType[key] === value) {
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
return false;
|
|
1679
|
+
}
|
|
1680
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1681
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1682
|
+
}
|
|
1683
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1684
|
+
return json;
|
|
1685
|
+
}
|
|
1686
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1687
|
+
return value;
|
|
1688
|
+
}
|
|
1689
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1690
|
+
return value;
|
|
1691
|
+
}
|
|
1692
|
+
var BillingTiersMode = {
|
|
1693
|
+
Graduated: "graduated",
|
|
1694
|
+
Volume: "volume"
|
|
1695
|
+
};
|
|
1696
|
+
function instanceOfBillingTiersMode(value) {
|
|
1697
|
+
for (const key in BillingTiersMode) {
|
|
1698
|
+
if (Object.prototype.hasOwnProperty.call(BillingTiersMode, key)) {
|
|
1699
|
+
if (BillingTiersMode[key] === value) {
|
|
1700
|
+
return true;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
return false;
|
|
1705
|
+
}
|
|
1706
|
+
function BillingTiersModeFromJSON2(json) {
|
|
1707
|
+
return BillingTiersModeFromJSONTyped4(json, false);
|
|
1708
|
+
}
|
|
1709
|
+
function BillingTiersModeFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1710
|
+
return json;
|
|
1711
|
+
}
|
|
1712
|
+
function BillingTiersModeToJSON2(value) {
|
|
1713
|
+
return value;
|
|
1714
|
+
}
|
|
1715
|
+
function BillingTiersModeToJSONTyped4(value, ignoreDiscriminator) {
|
|
1716
|
+
return value;
|
|
1717
|
+
}
|
|
1718
|
+
var PlanCreditGrantScaling = {
|
|
1719
|
+
Fixed: "fixed",
|
|
1720
|
+
PerLicense: "per_license"
|
|
1721
|
+
};
|
|
1722
|
+
function instanceOfPlanCreditGrantScaling(value) {
|
|
1723
|
+
for (const key in PlanCreditGrantScaling) {
|
|
1724
|
+
if (Object.prototype.hasOwnProperty.call(PlanCreditGrantScaling, key)) {
|
|
1725
|
+
if (PlanCreditGrantScaling[key] === value) {
|
|
1726
|
+
return true;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1732
|
+
function PlanCreditGrantScalingFromJSON2(json) {
|
|
1733
|
+
return PlanCreditGrantScalingFromJSONTyped3(json, false);
|
|
1734
|
+
}
|
|
1735
|
+
function PlanCreditGrantScalingFromJSONTyped3(json, ignoreDiscriminator) {
|
|
1736
|
+
return json;
|
|
1737
|
+
}
|
|
1738
|
+
function PlanCreditGrantScalingToJSON2(value) {
|
|
1739
|
+
return value;
|
|
1740
|
+
}
|
|
1741
|
+
function PlanCreditGrantScalingToJSONTyped3(value, ignoreDiscriminator) {
|
|
1742
|
+
return value;
|
|
1743
|
+
}
|
|
1744
|
+
function instanceOfCatalogCreditGrantResponseData(value) {
|
|
1745
|
+
if (!("companyCreditAmount" in value) || value["companyCreditAmount"] === void 0)
|
|
1746
|
+
return false;
|
|
1747
|
+
if (!("creditAmount" in value) || value["creditAmount"] === void 0)
|
|
1748
|
+
return false;
|
|
1749
|
+
if (!("creditId" in value) || value["creditId"] === void 0) return false;
|
|
1750
|
+
if (!("creditName" in value) || value["creditName"] === void 0)
|
|
1751
|
+
return false;
|
|
1752
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1753
|
+
if (!("scaling" in value) || value["scaling"] === void 0) return false;
|
|
1754
|
+
return true;
|
|
1755
|
+
}
|
|
1756
|
+
function CatalogCreditGrantResponseDataFromJSON(json) {
|
|
1757
|
+
return CatalogCreditGrantResponseDataFromJSONTyped(json, false);
|
|
1758
|
+
}
|
|
1759
|
+
function CatalogCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1760
|
+
if (json == null) {
|
|
1761
|
+
return json;
|
|
1762
|
+
}
|
|
1763
|
+
return {
|
|
1764
|
+
companyCreditAmount: json["company_credit_amount"],
|
|
1765
|
+
creditAmount: json["credit_amount"],
|
|
1766
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
1767
|
+
creditId: json["credit_id"],
|
|
1768
|
+
creditName: json["credit_name"],
|
|
1769
|
+
creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
|
|
1770
|
+
creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
|
|
1771
|
+
id: json["id"],
|
|
1772
|
+
licenseId: json["license_id"] == null ? void 0 : json["license_id"],
|
|
1773
|
+
resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
|
|
1774
|
+
scaling: PlanCreditGrantScalingFromJSON2(json["scaling"])
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
function CatalogCreditGrantResponseDataToJSON(json) {
|
|
1778
|
+
return CatalogCreditGrantResponseDataToJSONTyped(json, false);
|
|
1779
|
+
}
|
|
1780
|
+
function CatalogCreditGrantResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1781
|
+
if (value == null) {
|
|
1782
|
+
return value;
|
|
1783
|
+
}
|
|
1784
|
+
return {
|
|
1785
|
+
company_credit_amount: value["companyCreditAmount"],
|
|
1786
|
+
credit_amount: value["creditAmount"],
|
|
1787
|
+
credit_icon: value["creditIcon"],
|
|
1788
|
+
credit_id: value["creditId"],
|
|
1789
|
+
credit_name: value["creditName"],
|
|
1790
|
+
credit_plural_name: value["creditPluralName"],
|
|
1791
|
+
credit_singular_name: value["creditSingularName"],
|
|
1792
|
+
id: value["id"],
|
|
1793
|
+
license_id: value["licenseId"],
|
|
1794
|
+
reset_cadence: BillingPlanCreditGrantResetCadenceToJSON2(
|
|
1795
|
+
value["resetCadence"]
|
|
1796
|
+
),
|
|
1797
|
+
scaling: PlanCreditGrantScalingToJSON2(value["scaling"])
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
function instanceOfCatalogPriceTierResponseData(value) {
|
|
1801
|
+
if (!("from" in value) || value["from"] === void 0) return false;
|
|
1802
|
+
return true;
|
|
1803
|
+
}
|
|
1804
|
+
function CatalogPriceTierResponseDataFromJSON(json) {
|
|
1805
|
+
return CatalogPriceTierResponseDataFromJSONTyped(json, false);
|
|
1806
|
+
}
|
|
1807
|
+
function CatalogPriceTierResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1808
|
+
if (json == null) {
|
|
1809
|
+
return json;
|
|
1810
|
+
}
|
|
1811
|
+
return {
|
|
1812
|
+
flatPrice: json["flat_price"] == null ? void 0 : json["flat_price"],
|
|
1813
|
+
from: json["from"],
|
|
1814
|
+
perUnitPrice: json["per_unit_price"] == null ? void 0 : json["per_unit_price"],
|
|
1815
|
+
perUnitPriceDecimal: json["per_unit_price_decimal"] == null ? void 0 : json["per_unit_price_decimal"],
|
|
1816
|
+
to: json["to"] == null ? void 0 : json["to"]
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
function CatalogPriceTierResponseDataToJSON(json) {
|
|
1820
|
+
return CatalogPriceTierResponseDataToJSONTyped(json, false);
|
|
1821
|
+
}
|
|
1822
|
+
function CatalogPriceTierResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1823
|
+
if (value == null) {
|
|
1824
|
+
return value;
|
|
1825
|
+
}
|
|
1826
|
+
return {
|
|
1827
|
+
flat_price: value["flatPrice"],
|
|
1828
|
+
from: value["from"],
|
|
1829
|
+
per_unit_price: value["perUnitPrice"],
|
|
1830
|
+
per_unit_price_decimal: value["perUnitPriceDecimal"],
|
|
1831
|
+
to: value["to"]
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
function instanceOfCatalogPriceResponseData(value) {
|
|
1835
|
+
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
1836
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1837
|
+
if (!("interval" in value) || value["interval"] === void 0) return false;
|
|
1838
|
+
if (!("intervalCount" in value) || value["intervalCount"] === void 0)
|
|
1839
|
+
return false;
|
|
1840
|
+
if (!("packageSize" in value) || value["packageSize"] === void 0)
|
|
1841
|
+
return false;
|
|
1842
|
+
if (!("price" in value) || value["price"] === void 0) return false;
|
|
1843
|
+
if (!("priceTiers" in value) || value["priceTiers"] === void 0)
|
|
1844
|
+
return false;
|
|
1845
|
+
if (!("scheme" in value) || value["scheme"] === void 0) return false;
|
|
1846
|
+
return true;
|
|
1847
|
+
}
|
|
1848
|
+
function CatalogPriceResponseDataFromJSON(json) {
|
|
1849
|
+
return CatalogPriceResponseDataFromJSONTyped(json, false);
|
|
1850
|
+
}
|
|
1851
|
+
function CatalogPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1852
|
+
if (json == null) {
|
|
1853
|
+
return json;
|
|
1854
|
+
}
|
|
1855
|
+
return {
|
|
1856
|
+
currency: json["currency"],
|
|
1857
|
+
id: json["id"],
|
|
1858
|
+
interval: BillingProductPriceIntervalFromJSON2(json["interval"]),
|
|
1859
|
+
intervalCount: json["interval_count"],
|
|
1860
|
+
overageUnitPriceDecimal: json["overage_unit_price_decimal"] == null ? void 0 : json["overage_unit_price_decimal"],
|
|
1861
|
+
packageSize: json["package_size"],
|
|
1862
|
+
price: json["price"],
|
|
1863
|
+
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
1864
|
+
priceTiers: json["price_tiers"].map(
|
|
1865
|
+
CatalogPriceTierResponseDataFromJSON
|
|
1866
|
+
),
|
|
1867
|
+
scheme: BillingPriceSchemeFromJSON2(json["scheme"]),
|
|
1868
|
+
tiersMode: json["tiers_mode"] == null ? void 0 : BillingTiersModeFromJSON2(json["tiers_mode"])
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
function CatalogPriceResponseDataToJSON(json) {
|
|
1872
|
+
return CatalogPriceResponseDataToJSONTyped(json, false);
|
|
1873
|
+
}
|
|
1874
|
+
function CatalogPriceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1875
|
+
if (value == null) {
|
|
1876
|
+
return value;
|
|
1877
|
+
}
|
|
1878
|
+
return {
|
|
1879
|
+
currency: value["currency"],
|
|
1880
|
+
id: value["id"],
|
|
1881
|
+
interval: BillingProductPriceIntervalToJSON2(value["interval"]),
|
|
1882
|
+
interval_count: value["intervalCount"],
|
|
1883
|
+
overage_unit_price_decimal: value["overageUnitPriceDecimal"],
|
|
1884
|
+
package_size: value["packageSize"],
|
|
1885
|
+
price: value["price"],
|
|
1886
|
+
price_decimal: value["priceDecimal"],
|
|
1887
|
+
price_tiers: value["priceTiers"].map(
|
|
1888
|
+
CatalogPriceTierResponseDataToJSON
|
|
1889
|
+
),
|
|
1890
|
+
scheme: BillingPriceSchemeToJSON2(value["scheme"]),
|
|
1891
|
+
tiers_mode: BillingTiersModeToJSON2(value["tiersMode"])
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
function instanceOfCompanyDiscountResponseData(value) {
|
|
1895
|
+
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1896
|
+
return false;
|
|
1897
|
+
if (!("duration" in value) || value["duration"] === void 0) return false;
|
|
1898
|
+
return true;
|
|
1899
|
+
}
|
|
1900
|
+
function CompanyDiscountResponseDataFromJSON(json) {
|
|
1901
|
+
return CompanyDiscountResponseDataFromJSONTyped(json, false);
|
|
1902
|
+
}
|
|
1903
|
+
function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1904
|
+
if (json == null) {
|
|
1905
|
+
return json;
|
|
1906
|
+
}
|
|
1907
|
+
return {
|
|
1908
|
+
amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
|
|
1909
|
+
couponName: json["coupon_name"],
|
|
1910
|
+
currency: json["currency"] == null ? void 0 : json["currency"],
|
|
1911
|
+
customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
|
|
1912
|
+
duration: json["duration"],
|
|
1913
|
+
durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
|
|
1914
|
+
percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
function CompanyDiscountResponseDataToJSON(json) {
|
|
1918
|
+
return CompanyDiscountResponseDataToJSONTyped(json, false);
|
|
1919
|
+
}
|
|
1920
|
+
function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1921
|
+
if (value == null) {
|
|
1922
|
+
return value;
|
|
1923
|
+
}
|
|
1924
|
+
return {
|
|
1925
|
+
amount_off: value["amountOff"],
|
|
1926
|
+
coupon_name: value["couponName"],
|
|
1927
|
+
currency: value["currency"],
|
|
1928
|
+
customer_facing_code: value["customerFacingCode"],
|
|
1929
|
+
duration: value["duration"],
|
|
1930
|
+
duration_in_months: value["durationInMonths"],
|
|
1931
|
+
percent_off: value["percentOff"]
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
var EntitlementValueType = {
|
|
1935
|
+
Boolean: "boolean",
|
|
1936
|
+
Credit: "credit",
|
|
1937
|
+
Numeric: "numeric",
|
|
1938
|
+
Trait: "trait",
|
|
1939
|
+
Unknown: "unknown",
|
|
1940
|
+
Unlimited: "unlimited"
|
|
1941
|
+
};
|
|
1942
|
+
function instanceOfEntitlementValueType(value) {
|
|
1943
|
+
for (const key in EntitlementValueType) {
|
|
1944
|
+
if (Object.prototype.hasOwnProperty.call(EntitlementValueType, key)) {
|
|
1945
|
+
if (EntitlementValueType[key] === value) {
|
|
1946
|
+
return true;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
function EntitlementValueTypeFromJSON2(json) {
|
|
1953
|
+
return EntitlementValueTypeFromJSONTyped4(json, false);
|
|
1954
|
+
}
|
|
1955
|
+
function EntitlementValueTypeFromJSONTyped4(json, ignoreDiscriminator) {
|
|
1956
|
+
return json;
|
|
1957
|
+
}
|
|
1958
|
+
function EntitlementValueTypeToJSON2(value) {
|
|
1959
|
+
return value;
|
|
1960
|
+
}
|
|
1961
|
+
function EntitlementValueTypeToJSONTyped3(value, ignoreDiscriminator) {
|
|
1962
|
+
return value;
|
|
1963
|
+
}
|
|
1964
|
+
var FeatureType = {
|
|
1965
|
+
Boolean: "boolean",
|
|
1966
|
+
Event: "event",
|
|
1967
|
+
License: "license",
|
|
1968
|
+
Trait: "trait"
|
|
1969
|
+
};
|
|
1970
|
+
function instanceOfFeatureType(value) {
|
|
1971
|
+
for (const key in FeatureType) {
|
|
1972
|
+
if (Object.prototype.hasOwnProperty.call(FeatureType, key)) {
|
|
1973
|
+
if (FeatureType[key] === value) {
|
|
1974
|
+
return true;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
function FeatureTypeFromJSON2(json) {
|
|
1981
|
+
return FeatureTypeFromJSONTyped3(json, false);
|
|
1982
|
+
}
|
|
1983
|
+
function FeatureTypeFromJSONTyped3(json, ignoreDiscriminator) {
|
|
1984
|
+
return json;
|
|
1985
|
+
}
|
|
1986
|
+
function FeatureTypeToJSON2(value) {
|
|
1987
|
+
return value;
|
|
1988
|
+
}
|
|
1989
|
+
function FeatureTypeToJSONTyped3(value, ignoreDiscriminator) {
|
|
1990
|
+
return value;
|
|
1991
|
+
}
|
|
1992
|
+
var MetricPeriodMonthReset = {
|
|
1993
|
+
BillingCycle: "billing_cycle",
|
|
1994
|
+
FirstOfMonth: "first_of_month"
|
|
1995
|
+
};
|
|
1996
|
+
function instanceOfMetricPeriodMonthReset(value) {
|
|
1997
|
+
for (const key in MetricPeriodMonthReset) {
|
|
1998
|
+
if (Object.prototype.hasOwnProperty.call(MetricPeriodMonthReset, key)) {
|
|
1999
|
+
if (MetricPeriodMonthReset[key] === value) {
|
|
2000
|
+
return true;
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
return false;
|
|
2005
|
+
}
|
|
2006
|
+
function MetricPeriodMonthResetFromJSON2(json) {
|
|
2007
|
+
return MetricPeriodMonthResetFromJSONTyped6(json, false);
|
|
2008
|
+
}
|
|
2009
|
+
function MetricPeriodMonthResetFromJSONTyped6(json, ignoreDiscriminator) {
|
|
2010
|
+
return json;
|
|
2011
|
+
}
|
|
2012
|
+
function MetricPeriodMonthResetToJSON2(value) {
|
|
2013
|
+
return value;
|
|
2014
|
+
}
|
|
2015
|
+
function MetricPeriodMonthResetToJSONTyped5(value, ignoreDiscriminator) {
|
|
2016
|
+
return value;
|
|
2017
|
+
}
|
|
2018
|
+
var MetricPeriod = {
|
|
2019
|
+
AllTime: "all_time",
|
|
2020
|
+
CurrentDay: "current_day",
|
|
2021
|
+
CurrentMonth: "current_month",
|
|
2022
|
+
CurrentWeek: "current_week"
|
|
2023
|
+
};
|
|
2024
|
+
function instanceOfMetricPeriod(value) {
|
|
2025
|
+
for (const key in MetricPeriod) {
|
|
2026
|
+
if (Object.prototype.hasOwnProperty.call(MetricPeriod, key)) {
|
|
2027
|
+
if (MetricPeriod[key] === value) {
|
|
2028
|
+
return true;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
return false;
|
|
2033
|
+
}
|
|
2034
|
+
function MetricPeriodFromJSON2(json) {
|
|
2035
|
+
return MetricPeriodFromJSONTyped7(json, false);
|
|
2036
|
+
}
|
|
2037
|
+
function MetricPeriodFromJSONTyped7(json, ignoreDiscriminator) {
|
|
2038
|
+
return json;
|
|
2039
|
+
}
|
|
2040
|
+
function MetricPeriodToJSON2(value) {
|
|
2041
|
+
return value;
|
|
2042
|
+
}
|
|
2043
|
+
function MetricPeriodToJSONTyped6(value, ignoreDiscriminator) {
|
|
2044
|
+
return value;
|
|
2045
|
+
}
|
|
2046
|
+
var EntitlementPriceBehavior = {
|
|
2047
|
+
CreditBurndown: "credit_burndown",
|
|
2048
|
+
Overage: "overage",
|
|
2049
|
+
PayAsYouGo: "pay_as_you_go",
|
|
2050
|
+
PayInAdvance: "pay_in_advance",
|
|
2051
|
+
Tier: "tier"
|
|
2052
|
+
};
|
|
2053
|
+
function instanceOfEntitlementPriceBehavior(value) {
|
|
2054
|
+
for (const key in EntitlementPriceBehavior) {
|
|
2055
|
+
if (Object.prototype.hasOwnProperty.call(EntitlementPriceBehavior, key)) {
|
|
2056
|
+
if (EntitlementPriceBehavior[key] === value) {
|
|
2057
|
+
return true;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
return false;
|
|
2062
|
+
}
|
|
2063
|
+
function EntitlementPriceBehaviorFromJSON2(json) {
|
|
2064
|
+
return EntitlementPriceBehaviorFromJSONTyped2(json, false);
|
|
2065
|
+
}
|
|
2066
|
+
function EntitlementPriceBehaviorFromJSONTyped2(json, ignoreDiscriminator) {
|
|
2067
|
+
return json;
|
|
2068
|
+
}
|
|
2069
|
+
function EntitlementPriceBehaviorToJSON2(value) {
|
|
2070
|
+
return value;
|
|
2071
|
+
}
|
|
2072
|
+
function EntitlementPriceBehaviorToJSONTyped2(value, ignoreDiscriminator) {
|
|
2073
|
+
return value;
|
|
2074
|
+
}
|
|
2075
|
+
var EntitlementType = {
|
|
2076
|
+
CompanyOverride: "company_override",
|
|
2077
|
+
PlanEntitlement: "plan_entitlement",
|
|
2078
|
+
Unknown: "unknown"
|
|
2079
|
+
};
|
|
2080
|
+
function instanceOfEntitlementType(value) {
|
|
2081
|
+
for (const key in EntitlementType) {
|
|
2082
|
+
if (Object.prototype.hasOwnProperty.call(EntitlementType, key)) {
|
|
2083
|
+
if (EntitlementType[key] === value) {
|
|
2084
|
+
return true;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
return false;
|
|
2089
|
+
}
|
|
2090
|
+
function EntitlementTypeFromJSON(json) {
|
|
2091
|
+
return EntitlementTypeFromJSONTyped(json, false);
|
|
2092
|
+
}
|
|
2093
|
+
function EntitlementTypeFromJSONTyped(json, ignoreDiscriminator) {
|
|
2094
|
+
return json;
|
|
2095
|
+
}
|
|
2096
|
+
function EntitlementTypeToJSON(value) {
|
|
2097
|
+
return value;
|
|
2098
|
+
}
|
|
2099
|
+
function EntitlementTypeToJSONTyped(value, ignoreDiscriminator) {
|
|
2100
|
+
return value;
|
|
2101
|
+
}
|
|
2102
|
+
function instanceOfCompanyFeatureUsageResponseData(value) {
|
|
2103
|
+
if (!("access" in value) || value["access"] === void 0) return false;
|
|
2104
|
+
if (!("entitlementType" in value) || value["entitlementType"] === void 0)
|
|
2105
|
+
return false;
|
|
2106
|
+
if (!("featureDescription" in value) || value["featureDescription"] === void 0)
|
|
2107
|
+
return false;
|
|
2108
|
+
if (!("featureIcon" in value) || value["featureIcon"] === void 0)
|
|
2109
|
+
return false;
|
|
2110
|
+
if (!("featureId" in value) || value["featureId"] === void 0) return false;
|
|
2111
|
+
if (!("featureName" in value) || value["featureName"] === void 0)
|
|
2112
|
+
return false;
|
|
2113
|
+
if (!("featureType" in value) || value["featureType"] === void 0)
|
|
2114
|
+
return false;
|
|
2115
|
+
if (!("perLicenseCreditGrants" in value) || value["perLicenseCreditGrants"] === void 0)
|
|
2116
|
+
return false;
|
|
2117
|
+
if (!("valueType" in value) || value["valueType"] === void 0) return false;
|
|
2118
|
+
return true;
|
|
2119
|
+
}
|
|
2120
|
+
function CompanyFeatureUsageResponseDataFromJSON(json) {
|
|
2121
|
+
return CompanyFeatureUsageResponseDataFromJSONTyped(json, false);
|
|
2122
|
+
}
|
|
2123
|
+
function CompanyFeatureUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
2124
|
+
if (json == null) {
|
|
2125
|
+
return json;
|
|
2126
|
+
}
|
|
2127
|
+
return {
|
|
2128
|
+
access: json["access"],
|
|
2129
|
+
allocation: json["allocation"] == null ? void 0 : json["allocation"],
|
|
2130
|
+
companyOverrideId: json["company_override_id"] == null ? void 0 : json["company_override_id"],
|
|
2131
|
+
consumptionRate: json["consumption_rate"] == null ? void 0 : json["consumption_rate"],
|
|
2132
|
+
creditIcon: json["credit_icon"] == null ? void 0 : json["credit_icon"],
|
|
2133
|
+
creditId: json["credit_id"] == null ? void 0 : json["credit_id"],
|
|
2134
|
+
creditName: json["credit_name"] == null ? void 0 : json["credit_name"],
|
|
2135
|
+
creditPluralName: json["credit_plural_name"] == null ? void 0 : json["credit_plural_name"],
|
|
2136
|
+
creditSingularName: json["credit_singular_name"] == null ? void 0 : json["credit_singular_name"],
|
|
2137
|
+
currentCost: json["current_cost"] == null ? void 0 : json["current_cost"],
|
|
2138
|
+
entitlementType: EntitlementTypeFromJSON(json["entitlement_type"]),
|
|
2139
|
+
expiresAt: json["expires_at"] == null ? void 0 : new Date(json["expires_at"]),
|
|
2140
|
+
featureDescription: json["feature_description"],
|
|
2141
|
+
featureIcon: json["feature_icon"],
|
|
2142
|
+
featureId: json["feature_id"],
|
|
2143
|
+
featureName: json["feature_name"],
|
|
2144
|
+
featurePluralName: json["feature_plural_name"] == null ? void 0 : json["feature_plural_name"],
|
|
2145
|
+
featureSingularName: json["feature_singular_name"] == null ? void 0 : json["feature_singular_name"],
|
|
2146
|
+
featureType: FeatureTypeFromJSON2(json["feature_type"]),
|
|
2147
|
+
licenseId: json["license_id"] == null ? void 0 : json["license_id"],
|
|
2148
|
+
metricPeriod: json["metric_period"] == null ? void 0 : MetricPeriodFromJSON2(json["metric_period"]),
|
|
2149
|
+
metricPeriodMonthReset: json["metric_period_month_reset"] == null ? void 0 : MetricPeriodMonthResetFromJSON2(json["metric_period_month_reset"]),
|
|
2150
|
+
perLicenseCreditGrants: json["per_license_credit_grants"].map(CatalogCreditGrantResponseDataFromJSON),
|
|
2151
|
+
planEntitlementId: json["plan_entitlement_id"] == null ? void 0 : json["plan_entitlement_id"],
|
|
2152
|
+
price: json["price"] == null ? void 0 : CatalogPriceResponseDataFromJSON(json["price"]),
|
|
2153
|
+
priceBehavior: json["price_behavior"] == null ? void 0 : EntitlementPriceBehaviorFromJSON2(json["price_behavior"]),
|
|
2154
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
2155
|
+
softLimit: json["soft_limit"] == null ? void 0 : json["soft_limit"],
|
|
2156
|
+
usage: json["usage"] == null ? void 0 : json["usage"],
|
|
2157
|
+
valueBool: json["value_bool"] == null ? void 0 : json["value_bool"],
|
|
2158
|
+
valueNumeric: json["value_numeric"] == null ? void 0 : json["value_numeric"],
|
|
2159
|
+
valueType: EntitlementValueTypeFromJSON2(json["value_type"]),
|
|
2160
|
+
warningThreshold: json["warning_threshold"] == null ? void 0 : json["warning_threshold"]
|
|
2161
|
+
};
|
|
2162
|
+
}
|
|
2163
|
+
function CompanyFeatureUsageResponseDataToJSON(json) {
|
|
2164
|
+
return CompanyFeatureUsageResponseDataToJSONTyped(json, false);
|
|
2165
|
+
}
|
|
2166
|
+
function CompanyFeatureUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2167
|
+
if (value == null) {
|
|
2168
|
+
return value;
|
|
2169
|
+
}
|
|
2170
|
+
return {
|
|
2171
|
+
access: value["access"],
|
|
2172
|
+
allocation: value["allocation"],
|
|
2173
|
+
company_override_id: value["companyOverrideId"],
|
|
2174
|
+
consumption_rate: value["consumptionRate"],
|
|
2175
|
+
credit_icon: value["creditIcon"],
|
|
2176
|
+
credit_id: value["creditId"],
|
|
2177
|
+
credit_name: value["creditName"],
|
|
2178
|
+
credit_plural_name: value["creditPluralName"],
|
|
2179
|
+
credit_singular_name: value["creditSingularName"],
|
|
2180
|
+
current_cost: value["currentCost"],
|
|
2181
|
+
entitlement_type: EntitlementTypeToJSON(value["entitlementType"]),
|
|
2182
|
+
expires_at: value["expiresAt"] == null ? void 0 : value["expiresAt"].toISOString(),
|
|
2183
|
+
feature_description: value["featureDescription"],
|
|
2184
|
+
feature_icon: value["featureIcon"],
|
|
2185
|
+
feature_id: value["featureId"],
|
|
2186
|
+
feature_name: value["featureName"],
|
|
2187
|
+
feature_plural_name: value["featurePluralName"],
|
|
2188
|
+
feature_singular_name: value["featureSingularName"],
|
|
2189
|
+
feature_type: FeatureTypeToJSON2(value["featureType"]),
|
|
2190
|
+
license_id: value["licenseId"],
|
|
2191
|
+
metric_period: MetricPeriodToJSON2(value["metricPeriod"]),
|
|
2192
|
+
metric_period_month_reset: MetricPeriodMonthResetToJSON2(
|
|
2193
|
+
value["metricPeriodMonthReset"]
|
|
2194
|
+
),
|
|
2195
|
+
per_license_credit_grants: value["perLicenseCreditGrants"].map(CatalogCreditGrantResponseDataToJSON),
|
|
2196
|
+
plan_entitlement_id: value["planEntitlementId"],
|
|
2197
|
+
price: CatalogPriceResponseDataToJSON(value["price"]),
|
|
2198
|
+
price_behavior: EntitlementPriceBehaviorToJSON2(value["priceBehavior"]),
|
|
2199
|
+
resets_at: value["resetsAt"] == null ? void 0 : value["resetsAt"].toISOString(),
|
|
2200
|
+
soft_limit: value["softLimit"],
|
|
2201
|
+
usage: value["usage"],
|
|
2202
|
+
value_bool: value["valueBool"],
|
|
2203
|
+
value_numeric: value["valueNumeric"],
|
|
2204
|
+
value_type: EntitlementValueTypeToJSON2(value["valueType"]),
|
|
2205
|
+
warning_threshold: value["warningThreshold"]
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
function instanceOfCompanyFeatureUsageListResponseData(value) {
|
|
2209
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
2210
|
+
if (!("features" in value) || value["features"] === void 0) return false;
|
|
2211
|
+
return true;
|
|
2212
|
+
}
|
|
2213
|
+
function CompanyFeatureUsageListResponseDataFromJSON(json) {
|
|
2214
|
+
return CompanyFeatureUsageListResponseDataFromJSONTyped(json, false);
|
|
1262
2215
|
}
|
|
1263
|
-
function
|
|
2216
|
+
function CompanyFeatureUsageListResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1264
2217
|
if (json == null) {
|
|
1265
2218
|
return json;
|
|
1266
2219
|
}
|
|
1267
2220
|
return {
|
|
1268
|
-
|
|
2221
|
+
count: json["count"],
|
|
2222
|
+
features: json["features"].map(
|
|
2223
|
+
CompanyFeatureUsageResponseDataFromJSON
|
|
2224
|
+
)
|
|
1269
2225
|
};
|
|
1270
2226
|
}
|
|
1271
|
-
function
|
|
1272
|
-
return
|
|
2227
|
+
function CompanyFeatureUsageListResponseDataToJSON(json) {
|
|
2228
|
+
return CompanyFeatureUsageListResponseDataToJSONTyped(json, false);
|
|
1273
2229
|
}
|
|
1274
|
-
function
|
|
2230
|
+
function CompanyFeatureUsageListResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1275
2231
|
if (value == null) {
|
|
1276
2232
|
return value;
|
|
1277
2233
|
}
|
|
1278
2234
|
return {
|
|
1279
|
-
|
|
2235
|
+
count: value["count"],
|
|
2236
|
+
features: value["features"].map(
|
|
2237
|
+
CompanyFeatureUsageResponseDataToJSON
|
|
2238
|
+
)
|
|
1280
2239
|
};
|
|
1281
2240
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
function instanceOfBillingProviderType(value) {
|
|
1289
|
-
for (const key in BillingProviderType) {
|
|
1290
|
-
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1291
|
-
if (BillingProviderType[key] === value) {
|
|
1292
|
-
return true;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
return false;
|
|
2241
|
+
function instanceOfCompanyUserUsageResponseData(value) {
|
|
2242
|
+
if (!("lastSeen" in value) || value["lastSeen"] === void 0) return false;
|
|
2243
|
+
if (!("share" in value) || value["share"] === void 0) return false;
|
|
2244
|
+
if (!("usage" in value) || value["usage"] === void 0) return false;
|
|
2245
|
+
if (!("userId" in value) || value["userId"] === void 0) return false;
|
|
2246
|
+
return true;
|
|
1297
2247
|
}
|
|
1298
|
-
function
|
|
1299
|
-
return
|
|
2248
|
+
function CompanyUserUsageResponseDataFromJSON(json) {
|
|
2249
|
+
return CompanyUserUsageResponseDataFromJSONTyped(json, false);
|
|
1300
2250
|
}
|
|
1301
|
-
function
|
|
1302
|
-
|
|
2251
|
+
function CompanyUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
2252
|
+
if (json == null) {
|
|
2253
|
+
return json;
|
|
2254
|
+
}
|
|
2255
|
+
return {
|
|
2256
|
+
lastSeen: new Date(json["last_seen"]),
|
|
2257
|
+
name: json["name"] == null ? void 0 : json["name"],
|
|
2258
|
+
share: json["share"],
|
|
2259
|
+
usage: json["usage"],
|
|
2260
|
+
userId: json["user_id"]
|
|
2261
|
+
};
|
|
1303
2262
|
}
|
|
1304
|
-
function
|
|
1305
|
-
return
|
|
2263
|
+
function CompanyUserUsageResponseDataToJSON(json) {
|
|
2264
|
+
return CompanyUserUsageResponseDataToJSONTyped(json, false);
|
|
1306
2265
|
}
|
|
1307
|
-
function
|
|
1308
|
-
|
|
2266
|
+
function CompanyUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2267
|
+
if (value == null) {
|
|
2268
|
+
return value;
|
|
2269
|
+
}
|
|
2270
|
+
return {
|
|
2271
|
+
last_seen: value["lastSeen"].toISOString(),
|
|
2272
|
+
name: value["name"],
|
|
2273
|
+
share: value["share"],
|
|
2274
|
+
usage: value["usage"],
|
|
2275
|
+
user_id: value["userId"]
|
|
2276
|
+
};
|
|
1309
2277
|
}
|
|
1310
|
-
function
|
|
1311
|
-
if (!("
|
|
1312
|
-
|
|
1313
|
-
if (!("
|
|
2278
|
+
function instanceOfCompanyFeatureUserUsageResponseData(value) {
|
|
2279
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
2280
|
+
if (!("endTime" in value) || value["endTime"] === void 0) return false;
|
|
2281
|
+
if (!("startTime" in value) || value["startTime"] === void 0) return false;
|
|
2282
|
+
if (!("total" in value) || value["total"] === void 0) return false;
|
|
2283
|
+
if (!("users" in value) || value["users"] === void 0) return false;
|
|
1314
2284
|
return true;
|
|
1315
2285
|
}
|
|
1316
|
-
function
|
|
1317
|
-
return
|
|
2286
|
+
function CompanyFeatureUserUsageResponseDataFromJSON(json) {
|
|
2287
|
+
return CompanyFeatureUserUsageResponseDataFromJSONTyped(json, false);
|
|
1318
2288
|
}
|
|
1319
|
-
function
|
|
2289
|
+
function CompanyFeatureUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1320
2290
|
if (json == null) {
|
|
1321
2291
|
return json;
|
|
1322
2292
|
}
|
|
1323
2293
|
return {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
2294
|
+
count: json["count"],
|
|
2295
|
+
endTime: new Date(json["end_time"]),
|
|
2296
|
+
startTime: new Date(json["start_time"]),
|
|
2297
|
+
total: json["total"],
|
|
2298
|
+
unattributed: json["unattributed"] == null ? void 0 : json["unattributed"],
|
|
2299
|
+
users: json["users"].map(
|
|
2300
|
+
CompanyUserUsageResponseDataFromJSON
|
|
2301
|
+
)
|
|
1331
2302
|
};
|
|
1332
2303
|
}
|
|
1333
|
-
function
|
|
1334
|
-
return
|
|
2304
|
+
function CompanyFeatureUserUsageResponseDataToJSON(json) {
|
|
2305
|
+
return CompanyFeatureUserUsageResponseDataToJSONTyped(json, false);
|
|
1335
2306
|
}
|
|
1336
|
-
function
|
|
2307
|
+
function CompanyFeatureUserUsageResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1337
2308
|
if (value == null) {
|
|
1338
2309
|
return value;
|
|
1339
2310
|
}
|
|
1340
2311
|
return {
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
2312
|
+
count: value["count"],
|
|
2313
|
+
end_time: value["endTime"].toISOString(),
|
|
2314
|
+
start_time: value["startTime"].toISOString(),
|
|
2315
|
+
total: value["total"],
|
|
2316
|
+
unattributed: value["unattributed"],
|
|
2317
|
+
users: value["users"].map(
|
|
2318
|
+
CompanyUserUsageResponseDataToJSON
|
|
2319
|
+
)
|
|
1348
2320
|
};
|
|
1349
2321
|
}
|
|
1350
2322
|
var InvoiceStatus = {
|
|
@@ -1706,6 +2678,91 @@ function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1706
2678
|
params: value["params"]
|
|
1707
2679
|
};
|
|
1708
2680
|
}
|
|
2681
|
+
function instanceOfGetCompanyFeatureUsageResponse(value) {
|
|
2682
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2683
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2684
|
+
return true;
|
|
2685
|
+
}
|
|
2686
|
+
function GetCompanyFeatureUsageResponseFromJSON(json) {
|
|
2687
|
+
return GetCompanyFeatureUsageResponseFromJSONTyped(json, false);
|
|
2688
|
+
}
|
|
2689
|
+
function GetCompanyFeatureUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2690
|
+
if (json == null) {
|
|
2691
|
+
return json;
|
|
2692
|
+
}
|
|
2693
|
+
return {
|
|
2694
|
+
data: CompanyFeatureUsageListResponseDataFromJSON(json["data"]),
|
|
2695
|
+
params: json["params"]
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
function GetCompanyFeatureUsageResponseToJSON(json) {
|
|
2699
|
+
return GetCompanyFeatureUsageResponseToJSONTyped(json, false);
|
|
2700
|
+
}
|
|
2701
|
+
function GetCompanyFeatureUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2702
|
+
if (value == null) {
|
|
2703
|
+
return value;
|
|
2704
|
+
}
|
|
2705
|
+
return {
|
|
2706
|
+
data: CompanyFeatureUsageListResponseDataToJSON(value["data"]),
|
|
2707
|
+
params: value["params"]
|
|
2708
|
+
};
|
|
2709
|
+
}
|
|
2710
|
+
function instanceOfGetCompanyFeatureUserUsageParams(value) {
|
|
2711
|
+
return true;
|
|
2712
|
+
}
|
|
2713
|
+
function GetCompanyFeatureUserUsageParamsFromJSON(json) {
|
|
2714
|
+
return GetCompanyFeatureUserUsageParamsFromJSONTyped(json, false);
|
|
2715
|
+
}
|
|
2716
|
+
function GetCompanyFeatureUserUsageParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
2717
|
+
if (json == null) {
|
|
2718
|
+
return json;
|
|
2719
|
+
}
|
|
2720
|
+
return {
|
|
2721
|
+
limit: json["limit"] == null ? void 0 : json["limit"],
|
|
2722
|
+
offset: json["offset"] == null ? void 0 : json["offset"]
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
function GetCompanyFeatureUserUsageParamsToJSON(json) {
|
|
2726
|
+
return GetCompanyFeatureUserUsageParamsToJSONTyped(json, false);
|
|
2727
|
+
}
|
|
2728
|
+
function GetCompanyFeatureUserUsageParamsToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2729
|
+
if (value == null) {
|
|
2730
|
+
return value;
|
|
2731
|
+
}
|
|
2732
|
+
return {
|
|
2733
|
+
limit: value["limit"],
|
|
2734
|
+
offset: value["offset"]
|
|
2735
|
+
};
|
|
2736
|
+
}
|
|
2737
|
+
function instanceOfGetCompanyFeatureUserUsageResponse(value) {
|
|
2738
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2739
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2740
|
+
return true;
|
|
2741
|
+
}
|
|
2742
|
+
function GetCompanyFeatureUserUsageResponseFromJSON(json) {
|
|
2743
|
+
return GetCompanyFeatureUserUsageResponseFromJSONTyped(json, false);
|
|
2744
|
+
}
|
|
2745
|
+
function GetCompanyFeatureUserUsageResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2746
|
+
if (json == null) {
|
|
2747
|
+
return json;
|
|
2748
|
+
}
|
|
2749
|
+
return {
|
|
2750
|
+
data: CompanyFeatureUserUsageResponseDataFromJSON(json["data"]),
|
|
2751
|
+
params: GetCompanyFeatureUserUsageParamsFromJSON(json["params"])
|
|
2752
|
+
};
|
|
2753
|
+
}
|
|
2754
|
+
function GetCompanyFeatureUserUsageResponseToJSON(json) {
|
|
2755
|
+
return GetCompanyFeatureUserUsageResponseToJSONTyped(json, false);
|
|
2756
|
+
}
|
|
2757
|
+
function GetCompanyFeatureUserUsageResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2758
|
+
if (value == null) {
|
|
2759
|
+
return value;
|
|
2760
|
+
}
|
|
2761
|
+
return {
|
|
2762
|
+
data: CompanyFeatureUserUsageResponseDataToJSON(value["data"]),
|
|
2763
|
+
params: GetCompanyFeatureUserUsageParamsToJSON(value["params"])
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
1709
2766
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1710
2767
|
return true;
|
|
1711
2768
|
}
|
|
@@ -2307,15 +3364,78 @@ var SchematicBillingClient = class {
|
|
|
2307
3364
|
method: "DELETE"
|
|
2308
3365
|
}).then(() => void 0);
|
|
2309
3366
|
}
|
|
3367
|
+
fetchFeatureUsage() {
|
|
3368
|
+
const path = "/company/usage";
|
|
3369
|
+
return this.session.request(path).then((body) => {
|
|
3370
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
3371
|
+
throw new Error(`Malformed response from ${path}`);
|
|
3372
|
+
}
|
|
3373
|
+
const data = body.data;
|
|
3374
|
+
if (data == null || data.features == null) {
|
|
3375
|
+
return [];
|
|
3376
|
+
}
|
|
3377
|
+
return GetCompanyFeatureUsageResponseFromJSON(body).data.features;
|
|
3378
|
+
});
|
|
3379
|
+
}
|
|
3380
|
+
fetchFeatureUserUsage(params) {
|
|
3381
|
+
const query = new URLSearchParams();
|
|
3382
|
+
if (params.limit !== void 0) {
|
|
3383
|
+
query.set("limit", String(params.limit));
|
|
3384
|
+
}
|
|
3385
|
+
if (params.offset !== void 0) {
|
|
3386
|
+
query.set("offset", String(params.offset));
|
|
3387
|
+
}
|
|
3388
|
+
const search = query.toString();
|
|
3389
|
+
const path = `/company/usage/${encodeURIComponent(params.featureId)}/users${search === "" ? "" : `?${search}`}`;
|
|
3390
|
+
return this.session.request(path).then((body) => {
|
|
3391
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
3392
|
+
throw new Error(`Malformed response from ${path}`);
|
|
3393
|
+
}
|
|
3394
|
+
return GetCompanyFeatureUserUsageResponseFromJSON(body).data;
|
|
3395
|
+
});
|
|
3396
|
+
}
|
|
2310
3397
|
};
|
|
2311
3398
|
var anonymousIdKey = "schematicId";
|
|
2312
3399
|
var flagStateCachePrefix = "schematicCache";
|
|
2313
3400
|
var flagStateCacheMaxContexts = 10;
|
|
2314
3401
|
var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
2315
3402
|
var emptyCreditBalances = Object.freeze({});
|
|
3403
|
+
var emptyCreditSpendPolicies = [];
|
|
3404
|
+
function extractEventContext(event) {
|
|
3405
|
+
const body = event.body;
|
|
3406
|
+
const context = {};
|
|
3407
|
+
switch (event.type) {
|
|
3408
|
+
case "identify":
|
|
3409
|
+
if (body.keys != null) {
|
|
3410
|
+
context.user = body.keys;
|
|
3411
|
+
}
|
|
3412
|
+
if (body.company?.keys != null) {
|
|
3413
|
+
context.company = body.company.keys;
|
|
3414
|
+
}
|
|
3415
|
+
break;
|
|
3416
|
+
case "track":
|
|
3417
|
+
if (body.company != null) {
|
|
3418
|
+
context.company = body.company;
|
|
3419
|
+
}
|
|
3420
|
+
if (body.user != null) {
|
|
3421
|
+
context.user = body.user;
|
|
3422
|
+
}
|
|
3423
|
+
break;
|
|
3424
|
+
case "flag_check":
|
|
3425
|
+
if (body.req_company != null) {
|
|
3426
|
+
context.company = body.req_company;
|
|
3427
|
+
}
|
|
3428
|
+
if (body.req_user != null) {
|
|
3429
|
+
context.user = body.req_user;
|
|
3430
|
+
}
|
|
3431
|
+
break;
|
|
3432
|
+
}
|
|
3433
|
+
return context;
|
|
3434
|
+
}
|
|
2316
3435
|
var Schematic = class {
|
|
2317
3436
|
_additionalHeaders = {};
|
|
2318
3437
|
apiKey;
|
|
3438
|
+
contextSignatureManager;
|
|
2319
3439
|
_apiUrl = "https://api.schematichq.com";
|
|
2320
3440
|
conn = null;
|
|
2321
3441
|
context = {};
|
|
@@ -2330,6 +3450,7 @@ var Schematic = class {
|
|
|
2330
3450
|
isPendingListeners = /* @__PURE__ */ new Set();
|
|
2331
3451
|
planListeners = /* @__PURE__ */ new Set();
|
|
2332
3452
|
creditBalanceListeners = /* @__PURE__ */ new Set();
|
|
3453
|
+
creditSpendPolicyListeners = /* @__PURE__ */ new Set();
|
|
2333
3454
|
storage;
|
|
2334
3455
|
persistFlagState = true;
|
|
2335
3456
|
flagStateCacheKey;
|
|
@@ -2340,6 +3461,7 @@ var Schematic = class {
|
|
|
2340
3461
|
featureUsageEventMap = {};
|
|
2341
3462
|
planChecks = {};
|
|
2342
3463
|
creditBalances = {};
|
|
3464
|
+
creditSpendPolicies = {};
|
|
2343
3465
|
webSocketUrl = "wss://api.schematichq.com";
|
|
2344
3466
|
webSocketConnectionTimeout = 1e4;
|
|
2345
3467
|
webSocketReconnect = true;
|
|
@@ -2400,6 +3522,12 @@ var Schematic = class {
|
|
|
2400
3522
|
"X-Schematic-Client-Version": `schematic-js@${version}`,
|
|
2401
3523
|
...options?.additionalHeaders ?? {}
|
|
2402
3524
|
};
|
|
3525
|
+
if (options?.getContextSignature !== void 0) {
|
|
3526
|
+
this.contextSignatureManager = new ContextSignatureManager(
|
|
3527
|
+
options.getContextSignature,
|
|
3528
|
+
this.debug.bind(this)
|
|
3529
|
+
);
|
|
3530
|
+
}
|
|
2403
3531
|
if (options?.storage) {
|
|
2404
3532
|
this.storage = options.storage;
|
|
2405
3533
|
} else {
|
|
@@ -2569,12 +3697,14 @@ var Schematic = class {
|
|
|
2569
3697
|
}
|
|
2570
3698
|
if (!this.useWebSocket) {
|
|
2571
3699
|
const requestUrl = `${this._apiUrl}/flags/${key}/check`;
|
|
3700
|
+
const sigHeaders = await this.contextSignatureHeaders(context);
|
|
2572
3701
|
return fetch(requestUrl, {
|
|
2573
3702
|
method: "POST",
|
|
2574
3703
|
headers: {
|
|
2575
3704
|
...this._additionalHeaders ?? {},
|
|
2576
3705
|
"Content-Type": "application/json;charset=UTF-8",
|
|
2577
|
-
"X-Schematic-Api-Key": this.apiKey
|
|
3706
|
+
"X-Schematic-Api-Key": this.apiKey,
|
|
3707
|
+
...sigHeaders
|
|
2578
3708
|
},
|
|
2579
3709
|
body: JSON.stringify(context)
|
|
2580
3710
|
}).then((response) => {
|
|
@@ -2667,6 +3797,34 @@ var Schematic = class {
|
|
|
2667
3797
|
console.log(`[Schematic] ${message}`, ...args);
|
|
2668
3798
|
}
|
|
2669
3799
|
}
|
|
3800
|
+
/**
|
|
3801
|
+
* Resolve the HMAC context-signature value for a context, if a signature
|
|
3802
|
+
* provider is configured. Returns undefined when no provider is set, when
|
|
3803
|
+
* offline, or when the signature could not be obtained.
|
|
3804
|
+
*/
|
|
3805
|
+
contextSignature(context) {
|
|
3806
|
+
if (this.contextSignatureManager === void 0 || this.isOffline()) {
|
|
3807
|
+
return void 0;
|
|
3808
|
+
}
|
|
3809
|
+
return this.contextSignatureManager.getSignature(context);
|
|
3810
|
+
}
|
|
3811
|
+
/**
|
|
3812
|
+
* Build the `X-Schematic-Context-Sig` header for a context, or an empty
|
|
3813
|
+
* object when no signature is available. Spread into request headers.
|
|
3814
|
+
*
|
|
3815
|
+
* Returns synchronously (not a Promise) when no signature provider is
|
|
3816
|
+
* configured, so callers that dispatch on the same tick (e.g. fire-and-forget
|
|
3817
|
+
* event sends) keep their existing timing; only a configured provider, which
|
|
3818
|
+
* must fetch a signature, yields a Promise.
|
|
3819
|
+
*/
|
|
3820
|
+
contextSignatureHeaders(context) {
|
|
3821
|
+
if (this.contextSignatureManager === void 0 || this.isOffline()) {
|
|
3822
|
+
return {};
|
|
3823
|
+
}
|
|
3824
|
+
return this.contextSignatureManager.getSignature(context).then(
|
|
3825
|
+
(signature) => signature === void 0 ? {} : { [contextSignatureHeader]: signature }
|
|
3826
|
+
);
|
|
3827
|
+
}
|
|
2670
3828
|
/**
|
|
2671
3829
|
* Create a persistent message handler for websocket flag updates
|
|
2672
3830
|
*/
|
|
@@ -2732,6 +3890,19 @@ var Schematic = class {
|
|
|
2732
3890
|
this.notifyCreditBalanceListeners(merged);
|
|
2733
3891
|
}
|
|
2734
3892
|
}
|
|
3893
|
+
if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
|
|
3894
|
+
const contextStr = contextString(context);
|
|
3895
|
+
const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
|
|
3896
|
+
const previous = this.creditSpendPolicies[contextStr] ?? [];
|
|
3897
|
+
if (!creditSpendPoliciesEqual(previous, next)) {
|
|
3898
|
+
this.creditSpendPolicies[contextStr] = next;
|
|
3899
|
+
this.debug(
|
|
3900
|
+
`WebSocket credit spend policy update received. Notifying listeners`,
|
|
3901
|
+
{ creditSpendPolicies: next }
|
|
3902
|
+
);
|
|
3903
|
+
this.notifyCreditSpendPolicyListeners(next);
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
2735
3906
|
this.persistContextToCache(contextString(context));
|
|
2736
3907
|
this.flushContextDependentEventQueue();
|
|
2737
3908
|
this.setIsPending(false);
|
|
@@ -2777,12 +3948,14 @@ var Schematic = class {
|
|
|
2777
3948
|
}
|
|
2778
3949
|
const requestUrl = `${this._apiUrl}/flags/check`;
|
|
2779
3950
|
const requestBody = JSON.stringify(context);
|
|
3951
|
+
const sigHeaders = await this.contextSignatureHeaders(context);
|
|
2780
3952
|
return fetch(requestUrl, {
|
|
2781
3953
|
method: "POST",
|
|
2782
3954
|
headers: {
|
|
2783
3955
|
...this._additionalHeaders ?? {},
|
|
2784
3956
|
"Content-Type": "application/json;charset=UTF-8",
|
|
2785
|
-
"X-Schematic-Api-Key": this.apiKey
|
|
3957
|
+
"X-Schematic-Api-Key": this.apiKey,
|
|
3958
|
+
...sigHeaders
|
|
2786
3959
|
},
|
|
2787
3960
|
body: requestBody
|
|
2788
3961
|
}).then((response) => {
|
|
@@ -3233,10 +4406,19 @@ var Schematic = class {
|
|
|
3233
4406
|
this.creditBalances[contextStr] = balances;
|
|
3234
4407
|
}
|
|
3235
4408
|
}
|
|
4409
|
+
let revivedCreditSpendPolicies;
|
|
4410
|
+
if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
|
|
4411
|
+
const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
|
|
4412
|
+
if (policies.length > 0) {
|
|
4413
|
+
revivedCreditSpendPolicies = policies;
|
|
4414
|
+
this.creditSpendPolicies[contextStr] = policies;
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
3236
4417
|
fresh[contextStr] = {
|
|
3237
4418
|
checks: revivedChecks,
|
|
3238
4419
|
plan: revivedPlan,
|
|
3239
4420
|
creditBalances: revivedCreditBalances,
|
|
4421
|
+
creditSpendPolicies: revivedCreditSpendPolicies,
|
|
3240
4422
|
updatedAt: entry.updatedAt
|
|
3241
4423
|
};
|
|
3242
4424
|
contextsLoaded += 1;
|
|
@@ -3250,7 +4432,8 @@ var Schematic = class {
|
|
|
3250
4432
|
const checksForContext = this.checks[contextStr];
|
|
3251
4433
|
const planForContext = this.planChecks[contextStr];
|
|
3252
4434
|
const creditBalancesForContext = this.creditBalances[contextStr];
|
|
3253
|
-
|
|
4435
|
+
const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
|
|
4436
|
+
if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
|
|
3254
4437
|
return;
|
|
3255
4438
|
}
|
|
3256
4439
|
if (this.cachedFlagState === null) {
|
|
@@ -3269,6 +4452,7 @@ var Schematic = class {
|
|
|
3269
4452
|
checks: cleanChecks,
|
|
3270
4453
|
plan: planForContext,
|
|
3271
4454
|
creditBalances: creditBalancesForContext,
|
|
4455
|
+
creditSpendPolicies: creditSpendPoliciesForContext,
|
|
3272
4456
|
updatedAt: Date.now()
|
|
3273
4457
|
};
|
|
3274
4458
|
const entries = Object.entries(this.cachedFlagState.contexts);
|
|
@@ -3285,6 +4469,9 @@ var Schematic = class {
|
|
|
3285
4469
|
for (const key of Object.keys(this.creditBalances)) {
|
|
3286
4470
|
if (!survivorKeys.has(key)) delete this.creditBalances[key];
|
|
3287
4471
|
}
|
|
4472
|
+
for (const key of Object.keys(this.creditSpendPolicies)) {
|
|
4473
|
+
if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
|
|
4474
|
+
}
|
|
3288
4475
|
this.cachedFlagState = {
|
|
3289
4476
|
version: cacheVersion,
|
|
3290
4477
|
contexts: Object.fromEntries(survivors)
|
|
@@ -3323,12 +4510,17 @@ var Schematic = class {
|
|
|
3323
4510
|
this.debug(`event not sent (offline mode):`, { event });
|
|
3324
4511
|
return Promise.resolve();
|
|
3325
4512
|
}
|
|
4513
|
+
const maybeSigHeaders = this.contextSignatureHeaders(
|
|
4514
|
+
extractEventContext(event)
|
|
4515
|
+
);
|
|
4516
|
+
const sigHeaders = maybeSigHeaders instanceof Promise ? await maybeSigHeaders : maybeSigHeaders;
|
|
3326
4517
|
try {
|
|
3327
4518
|
const response = await fetch(captureUrl, {
|
|
3328
4519
|
method: "POST",
|
|
3329
4520
|
headers: {
|
|
3330
4521
|
...this._additionalHeaders ?? {},
|
|
3331
|
-
"Content-Type": "application/json;charset=UTF-8"
|
|
4522
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
4523
|
+
...sigHeaders
|
|
3332
4524
|
},
|
|
3333
4525
|
body: payload
|
|
3334
4526
|
});
|
|
@@ -3512,6 +4704,7 @@ var Schematic = class {
|
|
|
3512
4704
|
* In offline mode, this is a no-op.
|
|
3513
4705
|
*/
|
|
3514
4706
|
cleanup = async () => {
|
|
4707
|
+
this.contextSignatureManager?.clear();
|
|
3515
4708
|
if (this.isOffline()) {
|
|
3516
4709
|
this.debug("cleanup: skipped (offline mode)");
|
|
3517
4710
|
return Promise.resolve();
|
|
@@ -3797,7 +4990,7 @@ var Schematic = class {
|
|
|
3797
4990
|
context
|
|
3798
4991
|
);
|
|
3799
4992
|
this.context = context;
|
|
3800
|
-
const sendMessage = () => {
|
|
4993
|
+
const sendMessage = async () => {
|
|
3801
4994
|
let resolved = false;
|
|
3802
4995
|
const persistentMessageHandler = this.createPersistentMessageHandler(context);
|
|
3803
4996
|
const messageHandler = (event) => {
|
|
@@ -3824,20 +5017,22 @@ var Schematic = class {
|
|
|
3824
5017
|
});
|
|
3825
5018
|
this.currentWebSocket = socket;
|
|
3826
5019
|
const clientVersion = this._additionalHeaders["X-Schematic-Client-Version"] ?? `schematic-js@${version}`;
|
|
5020
|
+
const sig = await this.contextSignature(context);
|
|
3827
5021
|
const messagePayload = {
|
|
3828
5022
|
apiKey: this.apiKey,
|
|
3829
5023
|
clientVersion,
|
|
3830
|
-
data: context
|
|
5024
|
+
data: context,
|
|
5025
|
+
...sig !== void 0 ? { sig } : {}
|
|
3831
5026
|
};
|
|
3832
5027
|
this.debug(`WebSocket sending message:`, messagePayload);
|
|
3833
5028
|
socket.send(JSON.stringify(messagePayload));
|
|
3834
5029
|
};
|
|
3835
5030
|
if (socket.readyState === WebSocket.OPEN) {
|
|
3836
5031
|
this.debug(`WebSocket already open, sending message`);
|
|
3837
|
-
sendMessage();
|
|
5032
|
+
void sendMessage();
|
|
3838
5033
|
} else if (socket.readyState === WebSocket.CONNECTING) {
|
|
3839
5034
|
this.debug(`WebSocket connecting, waiting for open to send message`);
|
|
3840
|
-
socket.addEventListener("open", sendMessage);
|
|
5035
|
+
socket.addEventListener("open", () => void sendMessage());
|
|
3841
5036
|
} else {
|
|
3842
5037
|
this.debug(`WebSocket is closed, cannot send message`);
|
|
3843
5038
|
reject("WebSocket is not open or connecting");
|
|
@@ -3879,6 +5074,18 @@ var Schematic = class {
|
|
|
3879
5074
|
const contextStr = contextString(this.context);
|
|
3880
5075
|
return this.creditBalances[contextStr]?.[creditId];
|
|
3881
5076
|
};
|
|
5077
|
+
/** Get every credit spend policy binding the current context, company-scope first */
|
|
5078
|
+
getCreditSpendPolicies = () => {
|
|
5079
|
+
const contextStr = contextString(this.context);
|
|
5080
|
+
return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
|
|
5081
|
+
};
|
|
5082
|
+
/** Get the spend policies binding a single credit type in the current context */
|
|
5083
|
+
getCreditSpendPoliciesForCredit = (creditId) => {
|
|
5084
|
+
const policies = this.getCreditSpendPolicies().filter(
|
|
5085
|
+
(policy) => policy.creditId === creditId
|
|
5086
|
+
);
|
|
5087
|
+
return policies.length > 0 ? policies : emptyCreditSpendPolicies;
|
|
5088
|
+
};
|
|
3882
5089
|
// flag checks state
|
|
3883
5090
|
getFlagCheck = (flagKey) => {
|
|
3884
5091
|
const contextStr = contextString(this.context);
|
|
@@ -3945,6 +5152,13 @@ var Schematic = class {
|
|
|
3945
5152
|
this.creditBalanceListeners.delete(listener);
|
|
3946
5153
|
};
|
|
3947
5154
|
};
|
|
5155
|
+
/** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
|
|
5156
|
+
addCreditSpendPolicyListener = (listener) => {
|
|
5157
|
+
this.creditSpendPolicyListeners.add(listener);
|
|
5158
|
+
return () => {
|
|
5159
|
+
this.creditSpendPolicyListeners.delete(listener);
|
|
5160
|
+
};
|
|
5161
|
+
};
|
|
3948
5162
|
notifyFlagCheckListeners = (flagKey, check) => {
|
|
3949
5163
|
const listeners = this.flagCheckListeners?.[flagKey] ?? [];
|
|
3950
5164
|
if (listeners.size > 0) {
|
|
@@ -4008,6 +5222,16 @@ var Schematic = class {
|
|
|
4008
5222
|
});
|
|
4009
5223
|
});
|
|
4010
5224
|
};
|
|
5225
|
+
notifyCreditSpendPolicyListeners = (value) => {
|
|
5226
|
+
const listeners = this.creditSpendPolicyListeners ?? [];
|
|
5227
|
+
listeners.forEach((listener) => {
|
|
5228
|
+
if (listener.length > 0) {
|
|
5229
|
+
listener(value);
|
|
5230
|
+
return;
|
|
5231
|
+
}
|
|
5232
|
+
listener();
|
|
5233
|
+
});
|
|
5234
|
+
};
|
|
4011
5235
|
notifyCreditBalanceListeners = (value) => {
|
|
4012
5236
|
const listeners = this.creditBalanceListeners ?? [];
|
|
4013
5237
|
if (listeners.size > 0) {
|
|
@@ -4411,6 +5635,7 @@ var READINESS = {
|
|
|
4411
5635
|
active: "ready",
|
|
4412
5636
|
ended: "never"
|
|
4413
5637
|
};
|
|
5638
|
+
var FEATURE_USER_USAGE_LIMIT = 20;
|
|
4414
5639
|
var BillingStore = class {
|
|
4415
5640
|
constructor(_client, initialData = {}, options = {}) {
|
|
4416
5641
|
this._client = _client;
|
|
@@ -4431,6 +5656,17 @@ var BillingStore = class {
|
|
|
4431
5656
|
() => this._client.fetchPaymentMethods(),
|
|
4432
5657
|
{ readiness }
|
|
4433
5658
|
);
|
|
5659
|
+
this.featureUsage = new KeyedResource(
|
|
5660
|
+
() => this._client.fetchFeatureUsage(),
|
|
5661
|
+
{ readiness }
|
|
5662
|
+
);
|
|
5663
|
+
this.featureUserUsage = new KeyedResource(
|
|
5664
|
+
({ featureId }) => this._client.fetchFeatureUserUsage({
|
|
5665
|
+
featureId,
|
|
5666
|
+
limit: FEATURE_USER_USAGE_LIMIT
|
|
5667
|
+
}),
|
|
5668
|
+
{ readiness }
|
|
5669
|
+
);
|
|
4434
5670
|
const held = { key: initialData.sessionKey };
|
|
4435
5671
|
if (initialData.invoices !== void 0) {
|
|
4436
5672
|
held.invoices = {
|
|
@@ -4448,7 +5684,10 @@ var BillingStore = class {
|
|
|
4448
5684
|
if (initialData.paymentMethods !== void 0) {
|
|
4449
5685
|
held.paymentMethods = initialData.paymentMethods;
|
|
4450
5686
|
}
|
|
4451
|
-
if (
|
|
5687
|
+
if (initialData.featureUsage !== void 0) {
|
|
5688
|
+
held.featureUsage = initialData.featureUsage;
|
|
5689
|
+
}
|
|
5690
|
+
if (held.invoices !== void 0 || held.upcomingInvoice !== void 0 || held.paymentMethods !== void 0 || held.featureUsage !== void 0) {
|
|
4452
5691
|
this._held = held;
|
|
4453
5692
|
this._settleSeed(claimFrom(options.session) ?? claimOf(this._client));
|
|
4454
5693
|
}
|
|
@@ -4457,6 +5696,8 @@ var BillingStore = class {
|
|
|
4457
5696
|
invoices;
|
|
4458
5697
|
upcomingInvoice;
|
|
4459
5698
|
paymentMethods;
|
|
5699
|
+
featureUsage;
|
|
5700
|
+
featureUserUsage;
|
|
4460
5701
|
_pageSize;
|
|
4461
5702
|
_unsubscribe;
|
|
4462
5703
|
_connected = false;
|
|
@@ -4535,6 +5776,9 @@ var BillingStore = class {
|
|
|
4535
5776
|
if (held.paymentMethods !== void 0) {
|
|
4536
5777
|
this.paymentMethods.seed(SINGLETON, held.paymentMethods);
|
|
4537
5778
|
}
|
|
5779
|
+
if (held.featureUsage !== void 0) {
|
|
5780
|
+
this.featureUsage.seed(SINGLETON, held.featureUsage);
|
|
5781
|
+
}
|
|
4538
5782
|
this._seedKey = held.key;
|
|
4539
5783
|
this._seeded = true;
|
|
4540
5784
|
}
|
|
@@ -4547,24 +5791,28 @@ var BillingStore = class {
|
|
|
4547
5791
|
for (const name of RESOURCE_NAMES) {
|
|
4548
5792
|
this[name].resetAll();
|
|
4549
5793
|
}
|
|
5794
|
+
this.featureUserUsage.resetAll();
|
|
4550
5795
|
}
|
|
4551
5796
|
/** Forgets every resource and leaves them empty; nothing reloads. */
|
|
4552
5797
|
clearAll() {
|
|
4553
5798
|
for (const name of RESOURCE_NAMES) {
|
|
4554
5799
|
this[name].clearAll();
|
|
4555
5800
|
}
|
|
5801
|
+
this.featureUserUsage.clearAll();
|
|
4556
5802
|
}
|
|
4557
5803
|
/** Loads every resource that is subscribed and has nothing yet. */
|
|
4558
5804
|
resumeAll() {
|
|
4559
5805
|
for (const name of RESOURCE_NAMES) {
|
|
4560
5806
|
this[name].resumeAll();
|
|
4561
5807
|
}
|
|
5808
|
+
this.featureUserUsage.resumeAll();
|
|
4562
5809
|
}
|
|
4563
5810
|
/** Reloads every resource that has been loaded, keeping its current data. */
|
|
4564
5811
|
invalidateAll() {
|
|
4565
5812
|
for (const name of RESOURCE_NAMES) {
|
|
4566
5813
|
this[name].invalidateAll();
|
|
4567
5814
|
}
|
|
5815
|
+
this.featureUserUsage.invalidateAll();
|
|
4568
5816
|
}
|
|
4569
5817
|
/**
|
|
4570
5818
|
* Appends the next page to the invoices list for `query`, when there is
|
|
@@ -4676,7 +5924,8 @@ var BillingStore = class {
|
|
|
4676
5924
|
var RESOURCE_NAMES = [
|
|
4677
5925
|
"invoices",
|
|
4678
5926
|
"upcomingInvoice",
|
|
4679
|
-
"paymentMethods"
|
|
5927
|
+
"paymentMethods",
|
|
5928
|
+
"featureUsage"
|
|
4680
5929
|
];
|
|
4681
5930
|
|
|
4682
5931
|
// src/billing/context.tsx
|
|
@@ -4756,6 +6005,9 @@ var missingBillingSource = {
|
|
|
4756
6005
|
subscribe: () => () => {
|
|
4757
6006
|
},
|
|
4758
6007
|
handle: () => missingHandle,
|
|
6008
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6009
|
+
},
|
|
6010
|
+
featureUserUsage: () => missingHandle,
|
|
4759
6011
|
loadMoreInvoices: () => Promise.resolve(),
|
|
4760
6012
|
invalidateAll: () => {
|
|
4761
6013
|
},
|
|
@@ -4770,6 +6022,7 @@ function BillingDataProvider({
|
|
|
4770
6022
|
actions,
|
|
4771
6023
|
children,
|
|
4772
6024
|
data,
|
|
6025
|
+
featureUserUsage,
|
|
4773
6026
|
locale,
|
|
4774
6027
|
onLoadMoreInvoices,
|
|
4775
6028
|
onMissingString,
|
|
@@ -4780,6 +6033,7 @@ function BillingDataProvider({
|
|
|
4780
6033
|
}) {
|
|
4781
6034
|
const source = useMemo2(() => {
|
|
4782
6035
|
const handles = /* @__PURE__ */ new Map();
|
|
6036
|
+
const userUsageHandles = /* @__PURE__ */ new Map();
|
|
4783
6037
|
return {
|
|
4784
6038
|
actions: rejectingActions(
|
|
4785
6039
|
(name) => new Error(BILLING_ACTION_UNAVAILABLE_MESSAGE(name)),
|
|
@@ -4803,6 +6057,24 @@ function BillingDataProvider({
|
|
|
4803
6057
|
handles.set(name, handle);
|
|
4804
6058
|
return handle;
|
|
4805
6059
|
},
|
|
6060
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6061
|
+
},
|
|
6062
|
+
featureUserUsage: (featureId) => {
|
|
6063
|
+
const cached = userUsageHandles.get(featureId);
|
|
6064
|
+
if (cached !== void 0) {
|
|
6065
|
+
return cached;
|
|
6066
|
+
}
|
|
6067
|
+
const value = featureUserUsage?.[featureId];
|
|
6068
|
+
const handle = {
|
|
6069
|
+
data: value,
|
|
6070
|
+
error: void 0,
|
|
6071
|
+
isPending: value === void 0,
|
|
6072
|
+
refetch: () => {
|
|
6073
|
+
}
|
|
6074
|
+
};
|
|
6075
|
+
userUsageHandles.set(featureId, handle);
|
|
6076
|
+
return handle;
|
|
6077
|
+
},
|
|
4806
6078
|
loadMoreInvoices: (query) => {
|
|
4807
6079
|
onLoadMoreInvoices?.(query);
|
|
4808
6080
|
return Promise.resolve();
|
|
@@ -4810,7 +6082,7 @@ function BillingDataProvider({
|
|
|
4810
6082
|
invalidateAll: () => {
|
|
4811
6083
|
}
|
|
4812
6084
|
};
|
|
4813
|
-
}, [actions, data, onLoadMoreInvoices, onRefetch, status]);
|
|
6085
|
+
}, [actions, data, featureUserUsage, onLoadMoreInvoices, onRefetch, status]);
|
|
4814
6086
|
return /* @__PURE__ */ jsx2(BillingDataContext.Provider, { value: source, children: /* @__PURE__ */ jsx2(
|
|
4815
6087
|
SchematicI18nProvider,
|
|
4816
6088
|
{
|
|
@@ -4906,6 +6178,21 @@ function useSetupIntent() {
|
|
|
4906
6178
|
[source]
|
|
4907
6179
|
);
|
|
4908
6180
|
}
|
|
6181
|
+
function useFeatureUsage() {
|
|
6182
|
+
return useBillingResource("featureUsage", SINGLETON);
|
|
6183
|
+
}
|
|
6184
|
+
function useFeatureUserUsage(featureId) {
|
|
6185
|
+
const source = useBillingDataSource();
|
|
6186
|
+
const subscribe = useCallback(
|
|
6187
|
+
(listener) => source.subscribeFeatureUserUsage(featureId, listener),
|
|
6188
|
+
[featureId, source]
|
|
6189
|
+
);
|
|
6190
|
+
const getSnapshot = useCallback(
|
|
6191
|
+
() => source.featureUserUsage(featureId),
|
|
6192
|
+
[featureId, source]
|
|
6193
|
+
);
|
|
6194
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
6195
|
+
}
|
|
4909
6196
|
function useInvalidateBillingData() {
|
|
4910
6197
|
return useBillingDataSource().invalidateAll;
|
|
4911
6198
|
}
|
|
@@ -4961,8 +6248,7 @@ function BillingProvider({
|
|
|
4961
6248
|
return initialRef.current === void 0 ? void 0 : staticSource(initialRef.current);
|
|
4962
6249
|
}
|
|
4963
6250
|
const handles = /* @__PURE__ */ new WeakMap();
|
|
4964
|
-
const
|
|
4965
|
-
const resource = store.resource(name).get(params);
|
|
6251
|
+
const handleOf = (resource) => {
|
|
4966
6252
|
const snapshot = resource.getSnapshot();
|
|
4967
6253
|
const cached = handles.get(resource);
|
|
4968
6254
|
if (cached !== void 0 && cached.snapshot === snapshot) {
|
|
@@ -4972,12 +6258,18 @@ function BillingProvider({
|
|
|
4972
6258
|
...snapshot,
|
|
4973
6259
|
refetch: () => void resource.refetch()
|
|
4974
6260
|
};
|
|
4975
|
-
handles.set(resource, {
|
|
6261
|
+
handles.set(resource, {
|
|
6262
|
+
snapshot,
|
|
6263
|
+
handle: next
|
|
6264
|
+
});
|
|
4976
6265
|
return next;
|
|
4977
6266
|
};
|
|
6267
|
+
const handle = (name, params) => handleOf(store.resource(name).get(params));
|
|
4978
6268
|
return {
|
|
4979
6269
|
subscribe: (name, params, listener) => store.resource(name).subscribe(params, listener),
|
|
4980
6270
|
handle,
|
|
6271
|
+
subscribeFeatureUserUsage: (featureId, listener) => store.featureUserUsage.subscribe({ featureId }, listener),
|
|
6272
|
+
featureUserUsage: (featureId) => handleOf(store.featureUserUsage.get({ featureId })),
|
|
4981
6273
|
loadMoreInvoices: (query) => store.loadMoreInvoices(query),
|
|
4982
6274
|
invalidateAll: () => store.invalidateAll(),
|
|
4983
6275
|
actions: {
|
|
@@ -5004,7 +6296,17 @@ function BillingProvider({
|
|
|
5004
6296
|
}
|
|
5005
6297
|
function staticSource(data) {
|
|
5006
6298
|
const handles = /* @__PURE__ */ new Map();
|
|
6299
|
+
const pendingUserUsage = {
|
|
6300
|
+
data: void 0,
|
|
6301
|
+
error: void 0,
|
|
6302
|
+
isPending: true,
|
|
6303
|
+
refetch: () => {
|
|
6304
|
+
}
|
|
6305
|
+
};
|
|
5007
6306
|
return {
|
|
6307
|
+
subscribeFeatureUserUsage: () => () => {
|
|
6308
|
+
},
|
|
6309
|
+
featureUserUsage: () => pendingUserUsage,
|
|
5008
6310
|
subscribe: () => () => {
|
|
5009
6311
|
},
|
|
5010
6312
|
handle: (name) => {
|
|
@@ -5030,7 +6332,7 @@ function staticSource(data) {
|
|
|
5030
6332
|
}
|
|
5031
6333
|
|
|
5032
6334
|
// src/version.ts
|
|
5033
|
-
var version2 = "1.
|
|
6335
|
+
var version2 = "1.11.0";
|
|
5034
6336
|
|
|
5035
6337
|
// src/context/schematic.tsx
|
|
5036
6338
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -5123,6 +6425,7 @@ var useSchematic = () => {
|
|
|
5123
6425
|
|
|
5124
6426
|
// src/hooks/schematic.ts
|
|
5125
6427
|
import { useMemo as useMemo6, useSyncExternalStore as useSyncExternalStore2, useCallback as useCallback2 } from "react";
|
|
6428
|
+
var emptyPolicies = [];
|
|
5126
6429
|
var useSchematicClient = (opts) => {
|
|
5127
6430
|
const schematic = useSchematic();
|
|
5128
6431
|
const { client } = opts ?? {};
|
|
@@ -5238,6 +6541,34 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
5238
6541
|
[balance, isPending]
|
|
5239
6542
|
);
|
|
5240
6543
|
};
|
|
6544
|
+
var useSchematicCreditSpendPolicies = (opts) => {
|
|
6545
|
+
const client = useSchematicClient(opts);
|
|
6546
|
+
const subscribe = useCallback2(
|
|
6547
|
+
(callback) => client.addCreditSpendPolicyListener(callback),
|
|
6548
|
+
[client]
|
|
6549
|
+
);
|
|
6550
|
+
const policies = useSyncExternalStore2(
|
|
6551
|
+
subscribe,
|
|
6552
|
+
() => client.getCreditSpendPolicies(),
|
|
6553
|
+
() => emptyPolicies
|
|
6554
|
+
);
|
|
6555
|
+
const isPendingSubscribe = useCallback2(
|
|
6556
|
+
(callback) => client.addIsPendingListener(callback),
|
|
6557
|
+
[client]
|
|
6558
|
+
);
|
|
6559
|
+
const isPending = useSyncExternalStore2(
|
|
6560
|
+
isPendingSubscribe,
|
|
6561
|
+
() => client.getIsPending(),
|
|
6562
|
+
() => true
|
|
6563
|
+
);
|
|
6564
|
+
return useMemo6(
|
|
6565
|
+
() => ({
|
|
6566
|
+
policies,
|
|
6567
|
+
isLoading: policies.length === 0 && isPending
|
|
6568
|
+
}),
|
|
6569
|
+
[policies, isPending]
|
|
6570
|
+
);
|
|
6571
|
+
};
|
|
5241
6572
|
var useSchematicIsPending = (opts) => {
|
|
5242
6573
|
const client = useSchematicClient(opts);
|
|
5243
6574
|
const subscribe = useCallback2(
|
|
@@ -5251,6 +6582,7 @@ export {
|
|
|
5251
6582
|
BillingDataProvider,
|
|
5252
6583
|
BillingProvider,
|
|
5253
6584
|
DEFAULT_INVOICE_QUERY,
|
|
6585
|
+
FEATURE_USER_USAGE_LIMIT,
|
|
5254
6586
|
INVOICE_PAGE_SIZE,
|
|
5255
6587
|
InvoiceStatus,
|
|
5256
6588
|
RuleType,
|
|
@@ -5263,12 +6595,15 @@ export {
|
|
|
5263
6595
|
UsagePeriod,
|
|
5264
6596
|
normalizeInvoiceQuery2 as normalizeInvoiceQuery,
|
|
5265
6597
|
useBillingDataSource,
|
|
6598
|
+
useFeatureUsage,
|
|
6599
|
+
useFeatureUserUsage,
|
|
5266
6600
|
useInvalidateBillingData,
|
|
5267
6601
|
useInvoices,
|
|
5268
6602
|
usePaymentMethods,
|
|
5269
6603
|
useSchematic,
|
|
5270
6604
|
useSchematicContext,
|
|
5271
6605
|
useSchematicCreditBalance,
|
|
6606
|
+
useSchematicCreditSpendPolicies,
|
|
5272
6607
|
useSchematicEntitlement,
|
|
5273
6608
|
useSchematicEvents,
|
|
5274
6609
|
useSchematicFlag,
|