@schematichq/schematic-vue 1.6.0 → 1.7.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 +35 -0
- package/dist/schematic-vue.cjs.js +633 -6
- package/dist/schematic-vue.d.ts +473 -5
- package/dist/schematic-vue.esm.js +633 -6
- package/package.json +11 -11
|
@@ -28,6 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
useSchematicClient: () => useSchematicClient,
|
|
29
29
|
useSchematicContext: () => useSchematicContext,
|
|
30
30
|
useSchematicCreditBalance: () => useSchematicCreditBalance,
|
|
31
|
+
useSchematicCreditSpendPolicies: () => useSchematicCreditSpendPolicies,
|
|
31
32
|
useSchematicEntitlement: () => useSchematicEntitlement,
|
|
32
33
|
useSchematicEvents: () => useSchematicEvents,
|
|
33
34
|
useSchematicFlag: () => useSchematicFlag,
|
|
@@ -36,7 +37,7 @@ __export(index_exports, {
|
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
|
|
39
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
40
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.10.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
|
|
40
41
|
var __create = Object.create;
|
|
41
42
|
var __defProp2 = Object.defineProperty;
|
|
42
43
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -1027,6 +1028,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
1027
1028
|
trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
|
|
1028
1029
|
};
|
|
1029
1030
|
}
|
|
1031
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
1032
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
1033
|
+
}
|
|
1034
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
1035
|
+
return json;
|
|
1036
|
+
}
|
|
1037
|
+
function CreditSpendWindowFromJSON(json) {
|
|
1038
|
+
return CreditSpendWindowFromJSONTyped(json, false);
|
|
1039
|
+
}
|
|
1040
|
+
function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
|
|
1041
|
+
if (json == null) {
|
|
1042
|
+
return json;
|
|
1043
|
+
}
|
|
1044
|
+
return {
|
|
1045
|
+
count: json["count"],
|
|
1046
|
+
unit: json["unit"]
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
function CreditSpendPolicyFromJSON(json) {
|
|
1050
|
+
return CreditSpendPolicyFromJSONTyped(json, false);
|
|
1051
|
+
}
|
|
1052
|
+
function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1053
|
+
if (json == null) {
|
|
1054
|
+
return json;
|
|
1055
|
+
}
|
|
1056
|
+
return {
|
|
1057
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
1058
|
+
creditId: json["credit_id"],
|
|
1059
|
+
id: json["id"],
|
|
1060
|
+
kind: json["kind"],
|
|
1061
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
1062
|
+
limit: json["limit"],
|
|
1063
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
1064
|
+
scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
|
|
1065
|
+
window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1030
1068
|
function CheckFlagsResponseDataFromJSON(json) {
|
|
1031
1069
|
return CheckFlagsResponseDataFromJSONTyped(json, false);
|
|
1032
1070
|
}
|
|
@@ -1036,6 +1074,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
1036
1074
|
}
|
|
1037
1075
|
return {
|
|
1038
1076
|
creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
|
|
1077
|
+
creditSpendPolicies: json["credit_spend_policies"].map(
|
|
1078
|
+
CreditSpendPolicyFromJSON
|
|
1079
|
+
),
|
|
1039
1080
|
flags: json["flags"].map(CheckFlagResponseDataFromJSON),
|
|
1040
1081
|
plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
|
|
1041
1082
|
};
|
|
@@ -1164,7 +1205,55 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1164
1205
|
}
|
|
1165
1206
|
return balances;
|
|
1166
1207
|
};
|
|
1167
|
-
var
|
|
1208
|
+
var CreditSpendPoliciesFromJSON = (json) => {
|
|
1209
|
+
if (!Array.isArray(json)) {
|
|
1210
|
+
return [];
|
|
1211
|
+
}
|
|
1212
|
+
const policies = [];
|
|
1213
|
+
for (const raw of json) {
|
|
1214
|
+
if (raw == null || typeof raw !== "object") continue;
|
|
1215
|
+
const id = raw.id;
|
|
1216
|
+
const creditId = raw.credit_id ?? raw.creditId;
|
|
1217
|
+
const kind = raw.kind;
|
|
1218
|
+
const scope = raw.scope;
|
|
1219
|
+
const limit = raw.limit;
|
|
1220
|
+
if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
|
|
1221
|
+
continue;
|
|
1222
|
+
}
|
|
1223
|
+
const policy = {
|
|
1224
|
+
id,
|
|
1225
|
+
creditId,
|
|
1226
|
+
kind,
|
|
1227
|
+
scope,
|
|
1228
|
+
limit,
|
|
1229
|
+
consumed: typeof raw.consumed === "number" ? raw.consumed : 0
|
|
1230
|
+
};
|
|
1231
|
+
if (typeof raw.label === "string") {
|
|
1232
|
+
policy.label = raw.label;
|
|
1233
|
+
}
|
|
1234
|
+
const window2 = raw.window;
|
|
1235
|
+
if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
|
|
1236
|
+
policy.window = { unit: window2.unit, count: window2.count };
|
|
1237
|
+
}
|
|
1238
|
+
const resetsAt = raw.resets_at ?? raw.resetsAt;
|
|
1239
|
+
if (typeof resetsAt === "string" || resetsAt instanceof Date) {
|
|
1240
|
+
const parsed = new Date(resetsAt);
|
|
1241
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
1242
|
+
policy.resetsAt = parsed;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
policies.push(policy);
|
|
1246
|
+
}
|
|
1247
|
+
return policies;
|
|
1248
|
+
};
|
|
1249
|
+
var creditSpendPoliciesEqual = (a, b) => {
|
|
1250
|
+
if (a.length !== b.length) return false;
|
|
1251
|
+
return a.every((x, i) => {
|
|
1252
|
+
const y = b[i];
|
|
1253
|
+
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;
|
|
1254
|
+
});
|
|
1255
|
+
};
|
|
1256
|
+
var cacheVersion = "35d92bc6";
|
|
1168
1257
|
function contextString(context) {
|
|
1169
1258
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1170
1259
|
const sortedKeys = Object.keys(
|
|
@@ -1179,13 +1268,18 @@ function contextString(context) {
|
|
|
1179
1268
|
}, {});
|
|
1180
1269
|
return JSON.stringify(sortedContext);
|
|
1181
1270
|
}
|
|
1182
|
-
var version = "1.
|
|
1271
|
+
var version = "1.10.0";
|
|
1183
1272
|
var models_exports = {};
|
|
1184
1273
|
__export2(models_exports, {
|
|
1185
1274
|
ApiErrorFromJSON: () => ApiErrorFromJSON,
|
|
1186
1275
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1187
1276
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1188
1277
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1278
|
+
BillingProviderType: () => BillingProviderType,
|
|
1279
|
+
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1280
|
+
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1281
|
+
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1282
|
+
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1189
1283
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1190
1284
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1191
1285
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
@@ -1198,10 +1292,30 @@ __export2(models_exports, {
|
|
|
1198
1292
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1199
1293
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1200
1294
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1295
|
+
CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
|
|
1296
|
+
CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
|
|
1297
|
+
CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
|
|
1298
|
+
CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
|
|
1299
|
+
CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
|
|
1300
|
+
CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
|
|
1301
|
+
CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
|
|
1302
|
+
CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
|
|
1201
1303
|
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1202
1304
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1203
1305
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1204
1306
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1307
|
+
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1308
|
+
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1309
|
+
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
1310
|
+
CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
|
|
1311
|
+
DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
|
|
1312
|
+
DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
|
|
1313
|
+
DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
|
|
1314
|
+
DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
|
|
1315
|
+
DeleteResponseFromJSON: () => DeleteResponseFromJSON,
|
|
1316
|
+
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1317
|
+
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1318
|
+
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1205
1319
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1206
1320
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1207
1321
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1210,6 +1324,10 @@ __export2(models_exports, {
|
|
|
1210
1324
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1211
1325
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1212
1326
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1327
|
+
GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
|
|
1328
|
+
GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
|
|
1329
|
+
GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
|
|
1330
|
+
GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
|
|
1213
1331
|
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1214
1332
|
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1215
1333
|
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
@@ -1219,15 +1337,42 @@ __export2(models_exports, {
|
|
|
1219
1337
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1220
1338
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1221
1339
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1340
|
+
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1341
|
+
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1342
|
+
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1343
|
+
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1344
|
+
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1345
|
+
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1346
|
+
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
1347
|
+
SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
|
|
1348
|
+
UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
|
|
1349
|
+
UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
|
|
1350
|
+
UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
|
|
1351
|
+
UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
|
|
1352
|
+
UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
|
|
1353
|
+
UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
|
|
1354
|
+
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1355
|
+
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1222
1356
|
instanceOfApiError: () => instanceOfApiError,
|
|
1357
|
+
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1223
1358
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1224
1359
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1225
1360
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1361
|
+
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1362
|
+
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1226
1363
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1364
|
+
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1365
|
+
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1366
|
+
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1227
1367
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1228
1368
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1369
|
+
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1229
1370
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1230
|
-
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1371
|
+
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1372
|
+
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1373
|
+
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1374
|
+
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1375
|
+
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
1231
1376
|
});
|
|
1232
1377
|
function instanceOfApiError(value) {
|
|
1233
1378
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
@@ -1255,6 +1400,34 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1255
1400
|
error: value["error"]
|
|
1256
1401
|
};
|
|
1257
1402
|
}
|
|
1403
|
+
var BillingProviderType = {
|
|
1404
|
+
Metronome: "metronome",
|
|
1405
|
+
Orb: "orb",
|
|
1406
|
+
Schematic: "schematic",
|
|
1407
|
+
Stripe: "stripe"
|
|
1408
|
+
};
|
|
1409
|
+
function instanceOfBillingProviderType(value) {
|
|
1410
|
+
for (const key in BillingProviderType) {
|
|
1411
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1412
|
+
if (BillingProviderType[key] === value) {
|
|
1413
|
+
return true;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1420
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1421
|
+
}
|
|
1422
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1423
|
+
return json;
|
|
1424
|
+
}
|
|
1425
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1426
|
+
return value;
|
|
1427
|
+
}
|
|
1428
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1429
|
+
return value;
|
|
1430
|
+
}
|
|
1258
1431
|
function instanceOfCompanyDiscountResponseData(value) {
|
|
1259
1432
|
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1260
1433
|
return false;
|
|
@@ -1398,6 +1571,97 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1398
1571
|
)
|
|
1399
1572
|
};
|
|
1400
1573
|
}
|
|
1574
|
+
function instanceOfCompanyPaymentMethodResponseData(value) {
|
|
1575
|
+
if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
|
|
1576
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1577
|
+
return false;
|
|
1578
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1579
|
+
if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
|
|
1580
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
1581
|
+
return true;
|
|
1582
|
+
}
|
|
1583
|
+
function CompanyPaymentMethodResponseDataFromJSON(json) {
|
|
1584
|
+
return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1585
|
+
}
|
|
1586
|
+
function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1587
|
+
if (json == null) {
|
|
1588
|
+
return json;
|
|
1589
|
+
}
|
|
1590
|
+
return {
|
|
1591
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1592
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1593
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1594
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1595
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1596
|
+
canRemove: json["can_remove"],
|
|
1597
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1598
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1599
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1600
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1601
|
+
externalId: json["external_id"],
|
|
1602
|
+
id: json["id"],
|
|
1603
|
+
isDefault: json["is_default"],
|
|
1604
|
+
type: json["type"]
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
function CompanyPaymentMethodResponseDataToJSON(json) {
|
|
1608
|
+
return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
|
|
1609
|
+
}
|
|
1610
|
+
function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1611
|
+
if (value == null) {
|
|
1612
|
+
return value;
|
|
1613
|
+
}
|
|
1614
|
+
return {
|
|
1615
|
+
account_last4: value["accountLast4"],
|
|
1616
|
+
account_name: value["accountName"],
|
|
1617
|
+
bank_name: value["bankName"],
|
|
1618
|
+
billing_email: value["billingEmail"],
|
|
1619
|
+
billing_name: value["billingName"],
|
|
1620
|
+
can_remove: value["canRemove"],
|
|
1621
|
+
card_brand: value["cardBrand"],
|
|
1622
|
+
card_exp_month: value["cardExpMonth"],
|
|
1623
|
+
card_exp_year: value["cardExpYear"],
|
|
1624
|
+
card_last4: value["cardLast4"],
|
|
1625
|
+
external_id: value["externalId"],
|
|
1626
|
+
id: value["id"],
|
|
1627
|
+
is_default: value["isDefault"],
|
|
1628
|
+
type: value["type"]
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
function instanceOfCompanyPaymentMethodsResponseData(value) {
|
|
1632
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
1633
|
+
if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
|
|
1634
|
+
return false;
|
|
1635
|
+
return true;
|
|
1636
|
+
}
|
|
1637
|
+
function CompanyPaymentMethodsResponseDataFromJSON(json) {
|
|
1638
|
+
return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
|
|
1639
|
+
}
|
|
1640
|
+
function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1641
|
+
if (json == null) {
|
|
1642
|
+
return json;
|
|
1643
|
+
}
|
|
1644
|
+
return {
|
|
1645
|
+
count: json["count"],
|
|
1646
|
+
paymentMethods: json["payment_methods"].map(
|
|
1647
|
+
CompanyPaymentMethodResponseDataFromJSON
|
|
1648
|
+
)
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
function CompanyPaymentMethodsResponseDataToJSON(json) {
|
|
1652
|
+
return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
|
|
1653
|
+
}
|
|
1654
|
+
function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1655
|
+
if (value == null) {
|
|
1656
|
+
return value;
|
|
1657
|
+
}
|
|
1658
|
+
return {
|
|
1659
|
+
count: value["count"],
|
|
1660
|
+
payment_methods: value["paymentMethods"].map(
|
|
1661
|
+
CompanyPaymentMethodResponseDataToJSON
|
|
1662
|
+
)
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1401
1665
|
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1402
1666
|
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1403
1667
|
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
@@ -1447,6 +1711,122 @@ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminato
|
|
|
1447
1711
|
subtotal: value["subtotal"]
|
|
1448
1712
|
};
|
|
1449
1713
|
}
|
|
1714
|
+
function instanceOfSetupIntentResponseData(value) {
|
|
1715
|
+
if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
|
|
1716
|
+
return false;
|
|
1717
|
+
return true;
|
|
1718
|
+
}
|
|
1719
|
+
function SetupIntentResponseDataFromJSON(json) {
|
|
1720
|
+
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
1721
|
+
}
|
|
1722
|
+
function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1723
|
+
if (json == null) {
|
|
1724
|
+
return json;
|
|
1725
|
+
}
|
|
1726
|
+
return {
|
|
1727
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
1728
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
1729
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
1730
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
function SetupIntentResponseDataToJSON(json) {
|
|
1734
|
+
return SetupIntentResponseDataToJSONTyped(json, false);
|
|
1735
|
+
}
|
|
1736
|
+
function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1737
|
+
if (value == null) {
|
|
1738
|
+
return value;
|
|
1739
|
+
}
|
|
1740
|
+
return {
|
|
1741
|
+
account_id: value["accountId"],
|
|
1742
|
+
publishable_key: value["publishableKey"],
|
|
1743
|
+
schematic_publishable_key: value["schematicPublishableKey"],
|
|
1744
|
+
setup_intent_client_secret: value["setupIntentClientSecret"]
|
|
1745
|
+
};
|
|
1746
|
+
}
|
|
1747
|
+
function instanceOfCreateSetupIntentResponse(value) {
|
|
1748
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1749
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1750
|
+
return true;
|
|
1751
|
+
}
|
|
1752
|
+
function CreateSetupIntentResponseFromJSON(json) {
|
|
1753
|
+
return CreateSetupIntentResponseFromJSONTyped(json, false);
|
|
1754
|
+
}
|
|
1755
|
+
function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1756
|
+
if (json == null) {
|
|
1757
|
+
return json;
|
|
1758
|
+
}
|
|
1759
|
+
return {
|
|
1760
|
+
data: SetupIntentResponseDataFromJSON(json["data"]),
|
|
1761
|
+
params: json["params"]
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
function CreateSetupIntentResponseToJSON(json) {
|
|
1765
|
+
return CreateSetupIntentResponseToJSONTyped(json, false);
|
|
1766
|
+
}
|
|
1767
|
+
function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1768
|
+
if (value == null) {
|
|
1769
|
+
return value;
|
|
1770
|
+
}
|
|
1771
|
+
return {
|
|
1772
|
+
data: SetupIntentResponseDataToJSON(value["data"]),
|
|
1773
|
+
params: value["params"]
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
function instanceOfDeleteResponse(value) {
|
|
1777
|
+
return true;
|
|
1778
|
+
}
|
|
1779
|
+
function DeleteResponseFromJSON(json) {
|
|
1780
|
+
return DeleteResponseFromJSONTyped(json, false);
|
|
1781
|
+
}
|
|
1782
|
+
function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1783
|
+
if (json == null) {
|
|
1784
|
+
return json;
|
|
1785
|
+
}
|
|
1786
|
+
return {
|
|
1787
|
+
deleted: json["deleted"] == null ? void 0 : json["deleted"]
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
function DeleteResponseToJSON(json) {
|
|
1791
|
+
return DeleteResponseToJSONTyped(json, false);
|
|
1792
|
+
}
|
|
1793
|
+
function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1794
|
+
if (value == null) {
|
|
1795
|
+
return value;
|
|
1796
|
+
}
|
|
1797
|
+
return {
|
|
1798
|
+
deleted: value["deleted"]
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
function instanceOfDeletePaymentMethodResponse(value) {
|
|
1802
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1803
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1804
|
+
return true;
|
|
1805
|
+
}
|
|
1806
|
+
function DeletePaymentMethodResponseFromJSON(json) {
|
|
1807
|
+
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
1808
|
+
}
|
|
1809
|
+
function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1810
|
+
if (json == null) {
|
|
1811
|
+
return json;
|
|
1812
|
+
}
|
|
1813
|
+
return {
|
|
1814
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
1815
|
+
params: json["params"]
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
function DeletePaymentMethodResponseToJSON(json) {
|
|
1819
|
+
return DeletePaymentMethodResponseToJSONTyped(json, false);
|
|
1820
|
+
}
|
|
1821
|
+
function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1822
|
+
if (value == null) {
|
|
1823
|
+
return value;
|
|
1824
|
+
}
|
|
1825
|
+
return {
|
|
1826
|
+
data: DeleteResponseToJSON(value["data"]),
|
|
1827
|
+
params: value["params"]
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1450
1830
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1451
1831
|
return true;
|
|
1452
1832
|
}
|
|
@@ -1505,6 +1885,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1505
1885
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1506
1886
|
};
|
|
1507
1887
|
}
|
|
1888
|
+
function instanceOfGetCompanyPaymentMethodsResponse(value) {
|
|
1889
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1890
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1891
|
+
return true;
|
|
1892
|
+
}
|
|
1893
|
+
function GetCompanyPaymentMethodsResponseFromJSON(json) {
|
|
1894
|
+
return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
|
|
1895
|
+
}
|
|
1896
|
+
function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1897
|
+
if (json == null) {
|
|
1898
|
+
return json;
|
|
1899
|
+
}
|
|
1900
|
+
return {
|
|
1901
|
+
data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
|
|
1902
|
+
params: json["params"]
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function GetCompanyPaymentMethodsResponseToJSON(json) {
|
|
1906
|
+
return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
|
|
1907
|
+
}
|
|
1908
|
+
function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1909
|
+
if (value == null) {
|
|
1910
|
+
return value;
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
|
|
1914
|
+
params: value["params"]
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1508
1917
|
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1509
1918
|
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1510
1919
|
if (!("params" in value) || value["params"] === void 0) return false;
|
|
@@ -1534,11 +1943,140 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
|
|
|
1534
1943
|
params: value["params"]
|
|
1535
1944
|
};
|
|
1536
1945
|
}
|
|
1946
|
+
function instanceOfPaymentMethodResponseData(value) {
|
|
1947
|
+
if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
|
|
1948
|
+
if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
|
|
1949
|
+
return false;
|
|
1950
|
+
if (!("environmentId" in value) || value["environmentId"] === void 0)
|
|
1951
|
+
return false;
|
|
1952
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1953
|
+
return false;
|
|
1954
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1955
|
+
if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
|
|
1956
|
+
return false;
|
|
1957
|
+
if (!("providerType" in value) || value["providerType"] === void 0)
|
|
1958
|
+
return false;
|
|
1959
|
+
if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
|
|
1960
|
+
return true;
|
|
1961
|
+
}
|
|
1962
|
+
function PaymentMethodResponseDataFromJSON(json) {
|
|
1963
|
+
return PaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1964
|
+
}
|
|
1965
|
+
function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1966
|
+
if (json == null) {
|
|
1967
|
+
return json;
|
|
1968
|
+
}
|
|
1969
|
+
return {
|
|
1970
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1971
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1972
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1973
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1974
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1975
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1976
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1977
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1978
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1979
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
1980
|
+
createdAt: new Date(json["created_at"]),
|
|
1981
|
+
customerExternalId: json["customer_external_id"],
|
|
1982
|
+
environmentId: json["environment_id"],
|
|
1983
|
+
externalId: json["external_id"],
|
|
1984
|
+
id: json["id"],
|
|
1985
|
+
paymentMethodType: json["payment_method_type"],
|
|
1986
|
+
providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
|
|
1987
|
+
updatedAt: new Date(json["updated_at"])
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
function PaymentMethodResponseDataToJSON(json) {
|
|
1991
|
+
return PaymentMethodResponseDataToJSONTyped(json, false);
|
|
1992
|
+
}
|
|
1993
|
+
function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1994
|
+
if (value == null) {
|
|
1995
|
+
return value;
|
|
1996
|
+
}
|
|
1997
|
+
return {
|
|
1998
|
+
account_last4: value["accountLast4"],
|
|
1999
|
+
account_name: value["accountName"],
|
|
2000
|
+
bank_name: value["bankName"],
|
|
2001
|
+
billing_email: value["billingEmail"],
|
|
2002
|
+
billing_name: value["billingName"],
|
|
2003
|
+
card_brand: value["cardBrand"],
|
|
2004
|
+
card_exp_month: value["cardExpMonth"],
|
|
2005
|
+
card_exp_year: value["cardExpYear"],
|
|
2006
|
+
card_last4: value["cardLast4"],
|
|
2007
|
+
company_id: value["companyId"],
|
|
2008
|
+
created_at: value["createdAt"].toISOString(),
|
|
2009
|
+
customer_external_id: value["customerExternalId"],
|
|
2010
|
+
environment_id: value["environmentId"],
|
|
2011
|
+
external_id: value["externalId"],
|
|
2012
|
+
id: value["id"],
|
|
2013
|
+
payment_method_type: value["paymentMethodType"],
|
|
2014
|
+
provider_type: BillingProviderTypeToJSON2(value["providerType"]),
|
|
2015
|
+
updated_at: value["updatedAt"].toISOString()
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
function instanceOfUpdatePaymentMethodRequestBody(value) {
|
|
2019
|
+
if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
|
|
2020
|
+
return false;
|
|
2021
|
+
return true;
|
|
2022
|
+
}
|
|
2023
|
+
function UpdatePaymentMethodRequestBodyFromJSON(json) {
|
|
2024
|
+
return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
|
|
2025
|
+
}
|
|
2026
|
+
function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
2027
|
+
if (json == null) {
|
|
2028
|
+
return json;
|
|
2029
|
+
}
|
|
2030
|
+
return {
|
|
2031
|
+
paymentMethodId: json["payment_method_id"]
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
2035
|
+
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
2036
|
+
}
|
|
2037
|
+
function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2038
|
+
if (value == null) {
|
|
2039
|
+
return value;
|
|
2040
|
+
}
|
|
2041
|
+
return {
|
|
2042
|
+
payment_method_id: value["paymentMethodId"]
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
function instanceOfUpdatePaymentMethodResponse(value) {
|
|
2046
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2047
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2048
|
+
return true;
|
|
2049
|
+
}
|
|
2050
|
+
function UpdatePaymentMethodResponseFromJSON(json) {
|
|
2051
|
+
return UpdatePaymentMethodResponseFromJSONTyped(json, false);
|
|
2052
|
+
}
|
|
2053
|
+
function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2054
|
+
if (json == null) {
|
|
2055
|
+
return json;
|
|
2056
|
+
}
|
|
2057
|
+
return {
|
|
2058
|
+
data: PaymentMethodResponseDataFromJSON(json["data"]),
|
|
2059
|
+
params: json["params"]
|
|
2060
|
+
};
|
|
2061
|
+
}
|
|
2062
|
+
function UpdatePaymentMethodResponseToJSON(json) {
|
|
2063
|
+
return UpdatePaymentMethodResponseToJSONTyped(json, false);
|
|
2064
|
+
}
|
|
2065
|
+
function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2066
|
+
if (value == null) {
|
|
2067
|
+
return value;
|
|
2068
|
+
}
|
|
2069
|
+
return {
|
|
2070
|
+
data: PaymentMethodResponseDataToJSON(value["data"]),
|
|
2071
|
+
params: value["params"]
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
1537
2074
|
var anonymousIdKey = "schematicId";
|
|
1538
2075
|
var flagStateCachePrefix = "schematicCache";
|
|
1539
2076
|
var flagStateCacheMaxContexts = 10;
|
|
1540
2077
|
var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
1541
2078
|
var emptyCreditBalances = Object.freeze({});
|
|
2079
|
+
var emptyCreditSpendPolicies = [];
|
|
1542
2080
|
var Schematic = class {
|
|
1543
2081
|
_additionalHeaders = {};
|
|
1544
2082
|
apiKey;
|
|
@@ -1556,6 +2094,7 @@ var Schematic = class {
|
|
|
1556
2094
|
isPendingListeners = /* @__PURE__ */ new Set();
|
|
1557
2095
|
planListeners = /* @__PURE__ */ new Set();
|
|
1558
2096
|
creditBalanceListeners = /* @__PURE__ */ new Set();
|
|
2097
|
+
creditSpendPolicyListeners = /* @__PURE__ */ new Set();
|
|
1559
2098
|
storage;
|
|
1560
2099
|
persistFlagState = true;
|
|
1561
2100
|
flagStateCacheKey;
|
|
@@ -1566,6 +2105,7 @@ var Schematic = class {
|
|
|
1566
2105
|
featureUsageEventMap = {};
|
|
1567
2106
|
planChecks = {};
|
|
1568
2107
|
creditBalances = {};
|
|
2108
|
+
creditSpendPolicies = {};
|
|
1569
2109
|
webSocketUrl = "wss://api.schematichq.com";
|
|
1570
2110
|
webSocketConnectionTimeout = 1e4;
|
|
1571
2111
|
webSocketReconnect = true;
|
|
@@ -1958,6 +2498,19 @@ var Schematic = class {
|
|
|
1958
2498
|
this.notifyCreditBalanceListeners(merged);
|
|
1959
2499
|
}
|
|
1960
2500
|
}
|
|
2501
|
+
if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
|
|
2502
|
+
const contextStr = contextString(context);
|
|
2503
|
+
const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
|
|
2504
|
+
const previous = this.creditSpendPolicies[contextStr] ?? [];
|
|
2505
|
+
if (!creditSpendPoliciesEqual(previous, next)) {
|
|
2506
|
+
this.creditSpendPolicies[contextStr] = next;
|
|
2507
|
+
this.debug(
|
|
2508
|
+
`WebSocket credit spend policy update received. Notifying listeners`,
|
|
2509
|
+
{ creditSpendPolicies: next }
|
|
2510
|
+
);
|
|
2511
|
+
this.notifyCreditSpendPolicyListeners(next);
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
1961
2514
|
this.persistContextToCache(contextString(context));
|
|
1962
2515
|
this.flushContextDependentEventQueue();
|
|
1963
2516
|
this.setIsPending(false);
|
|
@@ -2459,10 +3012,19 @@ var Schematic = class {
|
|
|
2459
3012
|
this.creditBalances[contextStr] = balances;
|
|
2460
3013
|
}
|
|
2461
3014
|
}
|
|
3015
|
+
let revivedCreditSpendPolicies;
|
|
3016
|
+
if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
|
|
3017
|
+
const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
|
|
3018
|
+
if (policies.length > 0) {
|
|
3019
|
+
revivedCreditSpendPolicies = policies;
|
|
3020
|
+
this.creditSpendPolicies[contextStr] = policies;
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
2462
3023
|
fresh[contextStr] = {
|
|
2463
3024
|
checks: revivedChecks,
|
|
2464
3025
|
plan: revivedPlan,
|
|
2465
3026
|
creditBalances: revivedCreditBalances,
|
|
3027
|
+
creditSpendPolicies: revivedCreditSpendPolicies,
|
|
2466
3028
|
updatedAt: entry.updatedAt
|
|
2467
3029
|
};
|
|
2468
3030
|
contextsLoaded += 1;
|
|
@@ -2476,7 +3038,8 @@ var Schematic = class {
|
|
|
2476
3038
|
const checksForContext = this.checks[contextStr];
|
|
2477
3039
|
const planForContext = this.planChecks[contextStr];
|
|
2478
3040
|
const creditBalancesForContext = this.creditBalances[contextStr];
|
|
2479
|
-
|
|
3041
|
+
const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
|
|
3042
|
+
if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
|
|
2480
3043
|
return;
|
|
2481
3044
|
}
|
|
2482
3045
|
if (this.cachedFlagState === null) {
|
|
@@ -2495,6 +3058,7 @@ var Schematic = class {
|
|
|
2495
3058
|
checks: cleanChecks,
|
|
2496
3059
|
plan: planForContext,
|
|
2497
3060
|
creditBalances: creditBalancesForContext,
|
|
3061
|
+
creditSpendPolicies: creditSpendPoliciesForContext,
|
|
2498
3062
|
updatedAt: Date.now()
|
|
2499
3063
|
};
|
|
2500
3064
|
const entries = Object.entries(this.cachedFlagState.contexts);
|
|
@@ -2511,6 +3075,9 @@ var Schematic = class {
|
|
|
2511
3075
|
for (const key of Object.keys(this.creditBalances)) {
|
|
2512
3076
|
if (!survivorKeys.has(key)) delete this.creditBalances[key];
|
|
2513
3077
|
}
|
|
3078
|
+
for (const key of Object.keys(this.creditSpendPolicies)) {
|
|
3079
|
+
if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
|
|
3080
|
+
}
|
|
2514
3081
|
this.cachedFlagState = {
|
|
2515
3082
|
version: cacheVersion,
|
|
2516
3083
|
contexts: Object.fromEntries(survivors)
|
|
@@ -3105,6 +3672,18 @@ var Schematic = class {
|
|
|
3105
3672
|
const contextStr = contextString(this.context);
|
|
3106
3673
|
return this.creditBalances[contextStr]?.[creditId];
|
|
3107
3674
|
};
|
|
3675
|
+
/** Get every credit spend policy binding the current context, company-scope first */
|
|
3676
|
+
getCreditSpendPolicies = () => {
|
|
3677
|
+
const contextStr = contextString(this.context);
|
|
3678
|
+
return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
|
|
3679
|
+
};
|
|
3680
|
+
/** Get the spend policies binding a single credit type in the current context */
|
|
3681
|
+
getCreditSpendPoliciesForCredit = (creditId) => {
|
|
3682
|
+
const policies = this.getCreditSpendPolicies().filter(
|
|
3683
|
+
(policy) => policy.creditId === creditId
|
|
3684
|
+
);
|
|
3685
|
+
return policies.length > 0 ? policies : emptyCreditSpendPolicies;
|
|
3686
|
+
};
|
|
3108
3687
|
// flag checks state
|
|
3109
3688
|
getFlagCheck = (flagKey) => {
|
|
3110
3689
|
const contextStr = contextString(this.context);
|
|
@@ -3171,6 +3750,13 @@ var Schematic = class {
|
|
|
3171
3750
|
this.creditBalanceListeners.delete(listener);
|
|
3172
3751
|
};
|
|
3173
3752
|
};
|
|
3753
|
+
/** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
|
|
3754
|
+
addCreditSpendPolicyListener = (listener) => {
|
|
3755
|
+
this.creditSpendPolicyListeners.add(listener);
|
|
3756
|
+
return () => {
|
|
3757
|
+
this.creditSpendPolicyListeners.delete(listener);
|
|
3758
|
+
};
|
|
3759
|
+
};
|
|
3174
3760
|
notifyFlagCheckListeners = (flagKey, check) => {
|
|
3175
3761
|
const listeners = this.flagCheckListeners?.[flagKey] ?? [];
|
|
3176
3762
|
if (listeners.size > 0) {
|
|
@@ -3234,6 +3820,16 @@ var Schematic = class {
|
|
|
3234
3820
|
});
|
|
3235
3821
|
});
|
|
3236
3822
|
};
|
|
3823
|
+
notifyCreditSpendPolicyListeners = (value) => {
|
|
3824
|
+
const listeners = this.creditSpendPolicyListeners ?? [];
|
|
3825
|
+
listeners.forEach((listener) => {
|
|
3826
|
+
if (listener.length > 0) {
|
|
3827
|
+
listener(value);
|
|
3828
|
+
return;
|
|
3829
|
+
}
|
|
3830
|
+
listener();
|
|
3831
|
+
});
|
|
3832
|
+
};
|
|
3237
3833
|
notifyCreditBalanceListeners = (value) => {
|
|
3238
3834
|
const listeners = this.creditBalanceListeners ?? [];
|
|
3239
3835
|
if (listeners.size > 0) {
|
|
@@ -3286,7 +3882,7 @@ var notifyCreditBalanceListener = (listener, value) => {
|
|
|
3286
3882
|
var import_vue = require("vue");
|
|
3287
3883
|
|
|
3288
3884
|
// src/version.ts
|
|
3289
|
-
var version2 = "1.
|
|
3885
|
+
var version2 = "1.7.0";
|
|
3290
3886
|
|
|
3291
3887
|
// src/context/schematic.ts
|
|
3292
3888
|
var SchematicSymbol = /* @__PURE__ */ Symbol("schematic");
|
|
@@ -3444,6 +4040,7 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
3444
4040
|
let unsubscribePending = null;
|
|
3445
4041
|
(0, import_vue2.onMounted)(() => {
|
|
3446
4042
|
creditBalance.value = readBalance();
|
|
4043
|
+
isPending.value = client.getIsPending();
|
|
3447
4044
|
unsubscribeBalance = client.addCreditBalanceListener(() => {
|
|
3448
4045
|
creditBalance.value = readBalance();
|
|
3449
4046
|
});
|
|
@@ -3464,6 +4061,36 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
3464
4061
|
)
|
|
3465
4062
|
};
|
|
3466
4063
|
};
|
|
4064
|
+
var useSchematicCreditSpendPolicies = (opts) => {
|
|
4065
|
+
const client = useSchematicClient(opts);
|
|
4066
|
+
const policies = (0, import_vue2.ref)(
|
|
4067
|
+
client.getCreditSpendPolicies()
|
|
4068
|
+
);
|
|
4069
|
+
const isPending = (0, import_vue2.ref)(client.getIsPending());
|
|
4070
|
+
let unsubscribePolicies = null;
|
|
4071
|
+
let unsubscribePending = null;
|
|
4072
|
+
(0, import_vue2.onMounted)(() => {
|
|
4073
|
+
policies.value = client.getCreditSpendPolicies();
|
|
4074
|
+
isPending.value = client.getIsPending();
|
|
4075
|
+
unsubscribePolicies = client.addCreditSpendPolicyListener(() => {
|
|
4076
|
+
policies.value = client.getCreditSpendPolicies();
|
|
4077
|
+
});
|
|
4078
|
+
unsubscribePending = client.addIsPendingListener(() => {
|
|
4079
|
+
isPending.value = client.getIsPending();
|
|
4080
|
+
policies.value = client.getCreditSpendPolicies();
|
|
4081
|
+
});
|
|
4082
|
+
});
|
|
4083
|
+
(0, import_vue2.onScopeDispose)(() => {
|
|
4084
|
+
unsubscribePolicies?.();
|
|
4085
|
+
unsubscribePending?.();
|
|
4086
|
+
});
|
|
4087
|
+
return {
|
|
4088
|
+
/** Company-scope policies first, then the user's own; empty when none bind */
|
|
4089
|
+
policies: (0, import_vue2.computed)(() => policies.value),
|
|
4090
|
+
/** True while the policies are still loading and nothing has arrived yet */
|
|
4091
|
+
isLoading: (0, import_vue2.computed)(() => policies.value.length === 0 && isPending.value)
|
|
4092
|
+
};
|
|
4093
|
+
};
|
|
3467
4094
|
var useSchematicIsPending = (opts) => {
|
|
3468
4095
|
const client = useSchematicClient(opts);
|
|
3469
4096
|
const isPending = (0, import_vue2.ref)(client.getIsPending());
|