@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
1
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.10.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;
|
|
@@ -989,6 +989,43 @@ function DatastreamCompanyPlanFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
989
989
|
trialStatus: json["trial_status"] == null ? void 0 : TrialStatusFromJSON(json["trial_status"])
|
|
990
990
|
};
|
|
991
991
|
}
|
|
992
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
993
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
994
|
+
}
|
|
995
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
996
|
+
return json;
|
|
997
|
+
}
|
|
998
|
+
function CreditSpendWindowFromJSON(json) {
|
|
999
|
+
return CreditSpendWindowFromJSONTyped(json, false);
|
|
1000
|
+
}
|
|
1001
|
+
function CreditSpendWindowFromJSONTyped(json, ignoreDiscriminator) {
|
|
1002
|
+
if (json == null) {
|
|
1003
|
+
return json;
|
|
1004
|
+
}
|
|
1005
|
+
return {
|
|
1006
|
+
count: json["count"],
|
|
1007
|
+
unit: json["unit"]
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
function CreditSpendPolicyFromJSON(json) {
|
|
1011
|
+
return CreditSpendPolicyFromJSONTyped(json, false);
|
|
1012
|
+
}
|
|
1013
|
+
function CreditSpendPolicyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1014
|
+
if (json == null) {
|
|
1015
|
+
return json;
|
|
1016
|
+
}
|
|
1017
|
+
return {
|
|
1018
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
1019
|
+
creditId: json["credit_id"],
|
|
1020
|
+
id: json["id"],
|
|
1021
|
+
kind: json["kind"],
|
|
1022
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
1023
|
+
limit: json["limit"],
|
|
1024
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
1025
|
+
scope: CreditSpendPolicyScopeFromJSON(json["scope"]),
|
|
1026
|
+
window: json["window"] == null ? void 0 : CreditSpendWindowFromJSON(json["window"])
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
992
1029
|
function CheckFlagsResponseDataFromJSON(json) {
|
|
993
1030
|
return CheckFlagsResponseDataFromJSONTyped(json, false);
|
|
994
1031
|
}
|
|
@@ -998,6 +1035,9 @@ function CheckFlagsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
998
1035
|
}
|
|
999
1036
|
return {
|
|
1000
1037
|
creditBalances: json["credit_balances"] == null ? void 0 : mapValues(json["credit_balances"], CompanyCreditBalanceFromJSON),
|
|
1038
|
+
creditSpendPolicies: json["credit_spend_policies"].map(
|
|
1039
|
+
CreditSpendPolicyFromJSON
|
|
1040
|
+
),
|
|
1001
1041
|
flags: json["flags"].map(CheckFlagResponseDataFromJSON),
|
|
1002
1042
|
plan: json["plan"] == null ? void 0 : DatastreamCompanyPlanFromJSON(json["plan"])
|
|
1003
1043
|
};
|
|
@@ -1126,7 +1166,55 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1126
1166
|
}
|
|
1127
1167
|
return balances;
|
|
1128
1168
|
};
|
|
1129
|
-
var
|
|
1169
|
+
var CreditSpendPoliciesFromJSON = (json) => {
|
|
1170
|
+
if (!Array.isArray(json)) {
|
|
1171
|
+
return [];
|
|
1172
|
+
}
|
|
1173
|
+
const policies = [];
|
|
1174
|
+
for (const raw of json) {
|
|
1175
|
+
if (raw == null || typeof raw !== "object") continue;
|
|
1176
|
+
const id = raw.id;
|
|
1177
|
+
const creditId = raw.credit_id ?? raw.creditId;
|
|
1178
|
+
const kind = raw.kind;
|
|
1179
|
+
const scope = raw.scope;
|
|
1180
|
+
const limit = raw.limit;
|
|
1181
|
+
if (typeof id !== "string" || typeof creditId !== "string" || typeof kind !== "string" || typeof scope !== "string" || typeof limit !== "number") {
|
|
1182
|
+
continue;
|
|
1183
|
+
}
|
|
1184
|
+
const policy = {
|
|
1185
|
+
id,
|
|
1186
|
+
creditId,
|
|
1187
|
+
kind,
|
|
1188
|
+
scope,
|
|
1189
|
+
limit,
|
|
1190
|
+
consumed: typeof raw.consumed === "number" ? raw.consumed : 0
|
|
1191
|
+
};
|
|
1192
|
+
if (typeof raw.label === "string") {
|
|
1193
|
+
policy.label = raw.label;
|
|
1194
|
+
}
|
|
1195
|
+
const window2 = raw.window;
|
|
1196
|
+
if (window2 != null && typeof window2 === "object" && typeof window2.unit === "string" && typeof window2.count === "number") {
|
|
1197
|
+
policy.window = { unit: window2.unit, count: window2.count };
|
|
1198
|
+
}
|
|
1199
|
+
const resetsAt = raw.resets_at ?? raw.resetsAt;
|
|
1200
|
+
if (typeof resetsAt === "string" || resetsAt instanceof Date) {
|
|
1201
|
+
const parsed = new Date(resetsAt);
|
|
1202
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
1203
|
+
policy.resetsAt = parsed;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
policies.push(policy);
|
|
1207
|
+
}
|
|
1208
|
+
return policies;
|
|
1209
|
+
};
|
|
1210
|
+
var creditSpendPoliciesEqual = (a, b) => {
|
|
1211
|
+
if (a.length !== b.length) return false;
|
|
1212
|
+
return a.every((x, i) => {
|
|
1213
|
+
const y = b[i];
|
|
1214
|
+
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;
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
var cacheVersion = "35d92bc6";
|
|
1130
1218
|
function contextString(context) {
|
|
1131
1219
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1132
1220
|
const sortedKeys = Object.keys(
|
|
@@ -1141,13 +1229,18 @@ function contextString(context) {
|
|
|
1141
1229
|
}, {});
|
|
1142
1230
|
return JSON.stringify(sortedContext);
|
|
1143
1231
|
}
|
|
1144
|
-
var version = "1.
|
|
1232
|
+
var version = "1.10.0";
|
|
1145
1233
|
var models_exports = {};
|
|
1146
1234
|
__export(models_exports, {
|
|
1147
1235
|
ApiErrorFromJSON: () => ApiErrorFromJSON,
|
|
1148
1236
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1149
1237
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1150
1238
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1239
|
+
BillingProviderType: () => BillingProviderType,
|
|
1240
|
+
BillingProviderTypeFromJSON: () => BillingProviderTypeFromJSON2,
|
|
1241
|
+
BillingProviderTypeFromJSONTyped: () => BillingProviderTypeFromJSONTyped11,
|
|
1242
|
+
BillingProviderTypeToJSON: () => BillingProviderTypeToJSON2,
|
|
1243
|
+
BillingProviderTypeToJSONTyped: () => BillingProviderTypeToJSONTyped11,
|
|
1151
1244
|
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1152
1245
|
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1153
1246
|
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
@@ -1160,10 +1253,30 @@ __export(models_exports, {
|
|
|
1160
1253
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1161
1254
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1162
1255
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1256
|
+
CompanyPaymentMethodResponseDataFromJSON: () => CompanyPaymentMethodResponseDataFromJSON,
|
|
1257
|
+
CompanyPaymentMethodResponseDataFromJSONTyped: () => CompanyPaymentMethodResponseDataFromJSONTyped,
|
|
1258
|
+
CompanyPaymentMethodResponseDataToJSON: () => CompanyPaymentMethodResponseDataToJSON,
|
|
1259
|
+
CompanyPaymentMethodResponseDataToJSONTyped: () => CompanyPaymentMethodResponseDataToJSONTyped,
|
|
1260
|
+
CompanyPaymentMethodsResponseDataFromJSON: () => CompanyPaymentMethodsResponseDataFromJSON,
|
|
1261
|
+
CompanyPaymentMethodsResponseDataFromJSONTyped: () => CompanyPaymentMethodsResponseDataFromJSONTyped,
|
|
1262
|
+
CompanyPaymentMethodsResponseDataToJSON: () => CompanyPaymentMethodsResponseDataToJSON,
|
|
1263
|
+
CompanyPaymentMethodsResponseDataToJSONTyped: () => CompanyPaymentMethodsResponseDataToJSONTyped,
|
|
1163
1264
|
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1164
1265
|
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1165
1266
|
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1166
1267
|
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1268
|
+
CreateSetupIntentResponseFromJSON: () => CreateSetupIntentResponseFromJSON,
|
|
1269
|
+
CreateSetupIntentResponseFromJSONTyped: () => CreateSetupIntentResponseFromJSONTyped,
|
|
1270
|
+
CreateSetupIntentResponseToJSON: () => CreateSetupIntentResponseToJSON,
|
|
1271
|
+
CreateSetupIntentResponseToJSONTyped: () => CreateSetupIntentResponseToJSONTyped,
|
|
1272
|
+
DeletePaymentMethodResponseFromJSON: () => DeletePaymentMethodResponseFromJSON,
|
|
1273
|
+
DeletePaymentMethodResponseFromJSONTyped: () => DeletePaymentMethodResponseFromJSONTyped,
|
|
1274
|
+
DeletePaymentMethodResponseToJSON: () => DeletePaymentMethodResponseToJSON,
|
|
1275
|
+
DeletePaymentMethodResponseToJSONTyped: () => DeletePaymentMethodResponseToJSONTyped,
|
|
1276
|
+
DeleteResponseFromJSON: () => DeleteResponseFromJSON,
|
|
1277
|
+
DeleteResponseFromJSONTyped: () => DeleteResponseFromJSONTyped,
|
|
1278
|
+
DeleteResponseToJSON: () => DeleteResponseToJSON,
|
|
1279
|
+
DeleteResponseToJSONTyped: () => DeleteResponseToJSONTyped,
|
|
1167
1280
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1168
1281
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1169
1282
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1172,6 +1285,10 @@ __export(models_exports, {
|
|
|
1172
1285
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1173
1286
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1174
1287
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1288
|
+
GetCompanyPaymentMethodsResponseFromJSON: () => GetCompanyPaymentMethodsResponseFromJSON,
|
|
1289
|
+
GetCompanyPaymentMethodsResponseFromJSONTyped: () => GetCompanyPaymentMethodsResponseFromJSONTyped,
|
|
1290
|
+
GetCompanyPaymentMethodsResponseToJSON: () => GetCompanyPaymentMethodsResponseToJSON,
|
|
1291
|
+
GetCompanyPaymentMethodsResponseToJSONTyped: () => GetCompanyPaymentMethodsResponseToJSONTyped,
|
|
1175
1292
|
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1176
1293
|
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1177
1294
|
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
@@ -1181,15 +1298,42 @@ __export(models_exports, {
|
|
|
1181
1298
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1182
1299
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1183
1300
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1301
|
+
PaymentMethodResponseDataFromJSON: () => PaymentMethodResponseDataFromJSON,
|
|
1302
|
+
PaymentMethodResponseDataFromJSONTyped: () => PaymentMethodResponseDataFromJSONTyped,
|
|
1303
|
+
PaymentMethodResponseDataToJSON: () => PaymentMethodResponseDataToJSON,
|
|
1304
|
+
PaymentMethodResponseDataToJSONTyped: () => PaymentMethodResponseDataToJSONTyped,
|
|
1305
|
+
SetupIntentResponseDataFromJSON: () => SetupIntentResponseDataFromJSON,
|
|
1306
|
+
SetupIntentResponseDataFromJSONTyped: () => SetupIntentResponseDataFromJSONTyped,
|
|
1307
|
+
SetupIntentResponseDataToJSON: () => SetupIntentResponseDataToJSON,
|
|
1308
|
+
SetupIntentResponseDataToJSONTyped: () => SetupIntentResponseDataToJSONTyped,
|
|
1309
|
+
UpdatePaymentMethodRequestBodyFromJSON: () => UpdatePaymentMethodRequestBodyFromJSON,
|
|
1310
|
+
UpdatePaymentMethodRequestBodyFromJSONTyped: () => UpdatePaymentMethodRequestBodyFromJSONTyped,
|
|
1311
|
+
UpdatePaymentMethodRequestBodyToJSON: () => UpdatePaymentMethodRequestBodyToJSON,
|
|
1312
|
+
UpdatePaymentMethodRequestBodyToJSONTyped: () => UpdatePaymentMethodRequestBodyToJSONTyped,
|
|
1313
|
+
UpdatePaymentMethodResponseFromJSON: () => UpdatePaymentMethodResponseFromJSON,
|
|
1314
|
+
UpdatePaymentMethodResponseFromJSONTyped: () => UpdatePaymentMethodResponseFromJSONTyped,
|
|
1315
|
+
UpdatePaymentMethodResponseToJSON: () => UpdatePaymentMethodResponseToJSON,
|
|
1316
|
+
UpdatePaymentMethodResponseToJSONTyped: () => UpdatePaymentMethodResponseToJSONTyped,
|
|
1184
1317
|
instanceOfApiError: () => instanceOfApiError,
|
|
1318
|
+
instanceOfBillingProviderType: () => instanceOfBillingProviderType,
|
|
1185
1319
|
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1186
1320
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1187
1321
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1322
|
+
instanceOfCompanyPaymentMethodResponseData: () => instanceOfCompanyPaymentMethodResponseData,
|
|
1323
|
+
instanceOfCompanyPaymentMethodsResponseData: () => instanceOfCompanyPaymentMethodsResponseData,
|
|
1188
1324
|
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1325
|
+
instanceOfCreateSetupIntentResponse: () => instanceOfCreateSetupIntentResponse,
|
|
1326
|
+
instanceOfDeletePaymentMethodResponse: () => instanceOfDeletePaymentMethodResponse,
|
|
1327
|
+
instanceOfDeleteResponse: () => instanceOfDeleteResponse,
|
|
1189
1328
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1190
1329
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1330
|
+
instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
|
|
1191
1331
|
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1192
|
-
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1332
|
+
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
|
|
1333
|
+
instanceOfPaymentMethodResponseData: () => instanceOfPaymentMethodResponseData,
|
|
1334
|
+
instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
|
|
1335
|
+
instanceOfUpdatePaymentMethodRequestBody: () => instanceOfUpdatePaymentMethodRequestBody,
|
|
1336
|
+
instanceOfUpdatePaymentMethodResponse: () => instanceOfUpdatePaymentMethodResponse
|
|
1193
1337
|
});
|
|
1194
1338
|
function instanceOfApiError(value) {
|
|
1195
1339
|
if (!("error" in value) || value["error"] === void 0) return false;
|
|
@@ -1217,6 +1361,34 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1217
1361
|
error: value["error"]
|
|
1218
1362
|
};
|
|
1219
1363
|
}
|
|
1364
|
+
var BillingProviderType = {
|
|
1365
|
+
Metronome: "metronome",
|
|
1366
|
+
Orb: "orb",
|
|
1367
|
+
Schematic: "schematic",
|
|
1368
|
+
Stripe: "stripe"
|
|
1369
|
+
};
|
|
1370
|
+
function instanceOfBillingProviderType(value) {
|
|
1371
|
+
for (const key in BillingProviderType) {
|
|
1372
|
+
if (Object.prototype.hasOwnProperty.call(BillingProviderType, key)) {
|
|
1373
|
+
if (BillingProviderType[key] === value) {
|
|
1374
|
+
return true;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return false;
|
|
1379
|
+
}
|
|
1380
|
+
function BillingProviderTypeFromJSON2(json) {
|
|
1381
|
+
return BillingProviderTypeFromJSONTyped11(json, false);
|
|
1382
|
+
}
|
|
1383
|
+
function BillingProviderTypeFromJSONTyped11(json, ignoreDiscriminator) {
|
|
1384
|
+
return json;
|
|
1385
|
+
}
|
|
1386
|
+
function BillingProviderTypeToJSON2(value) {
|
|
1387
|
+
return value;
|
|
1388
|
+
}
|
|
1389
|
+
function BillingProviderTypeToJSONTyped11(value, ignoreDiscriminator) {
|
|
1390
|
+
return value;
|
|
1391
|
+
}
|
|
1220
1392
|
function instanceOfCompanyDiscountResponseData(value) {
|
|
1221
1393
|
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1222
1394
|
return false;
|
|
@@ -1360,6 +1532,97 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1360
1532
|
)
|
|
1361
1533
|
};
|
|
1362
1534
|
}
|
|
1535
|
+
function instanceOfCompanyPaymentMethodResponseData(value) {
|
|
1536
|
+
if (!("canRemove" in value) || value["canRemove"] === void 0) return false;
|
|
1537
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1538
|
+
return false;
|
|
1539
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1540
|
+
if (!("isDefault" in value) || value["isDefault"] === void 0) return false;
|
|
1541
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
1542
|
+
return true;
|
|
1543
|
+
}
|
|
1544
|
+
function CompanyPaymentMethodResponseDataFromJSON(json) {
|
|
1545
|
+
return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1546
|
+
}
|
|
1547
|
+
function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1548
|
+
if (json == null) {
|
|
1549
|
+
return json;
|
|
1550
|
+
}
|
|
1551
|
+
return {
|
|
1552
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1553
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1554
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1555
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1556
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1557
|
+
canRemove: json["can_remove"],
|
|
1558
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1559
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1560
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1561
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1562
|
+
externalId: json["external_id"],
|
|
1563
|
+
id: json["id"],
|
|
1564
|
+
isDefault: json["is_default"],
|
|
1565
|
+
type: json["type"]
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
function CompanyPaymentMethodResponseDataToJSON(json) {
|
|
1569
|
+
return CompanyPaymentMethodResponseDataToJSONTyped(json, false);
|
|
1570
|
+
}
|
|
1571
|
+
function CompanyPaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1572
|
+
if (value == null) {
|
|
1573
|
+
return value;
|
|
1574
|
+
}
|
|
1575
|
+
return {
|
|
1576
|
+
account_last4: value["accountLast4"],
|
|
1577
|
+
account_name: value["accountName"],
|
|
1578
|
+
bank_name: value["bankName"],
|
|
1579
|
+
billing_email: value["billingEmail"],
|
|
1580
|
+
billing_name: value["billingName"],
|
|
1581
|
+
can_remove: value["canRemove"],
|
|
1582
|
+
card_brand: value["cardBrand"],
|
|
1583
|
+
card_exp_month: value["cardExpMonth"],
|
|
1584
|
+
card_exp_year: value["cardExpYear"],
|
|
1585
|
+
card_last4: value["cardLast4"],
|
|
1586
|
+
external_id: value["externalId"],
|
|
1587
|
+
id: value["id"],
|
|
1588
|
+
is_default: value["isDefault"],
|
|
1589
|
+
type: value["type"]
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
function instanceOfCompanyPaymentMethodsResponseData(value) {
|
|
1593
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
1594
|
+
if (!("paymentMethods" in value) || value["paymentMethods"] === void 0)
|
|
1595
|
+
return false;
|
|
1596
|
+
return true;
|
|
1597
|
+
}
|
|
1598
|
+
function CompanyPaymentMethodsResponseDataFromJSON(json) {
|
|
1599
|
+
return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
|
|
1600
|
+
}
|
|
1601
|
+
function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1602
|
+
if (json == null) {
|
|
1603
|
+
return json;
|
|
1604
|
+
}
|
|
1605
|
+
return {
|
|
1606
|
+
count: json["count"],
|
|
1607
|
+
paymentMethods: json["payment_methods"].map(
|
|
1608
|
+
CompanyPaymentMethodResponseDataFromJSON
|
|
1609
|
+
)
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
function CompanyPaymentMethodsResponseDataToJSON(json) {
|
|
1613
|
+
return CompanyPaymentMethodsResponseDataToJSONTyped(json, false);
|
|
1614
|
+
}
|
|
1615
|
+
function CompanyPaymentMethodsResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1616
|
+
if (value == null) {
|
|
1617
|
+
return value;
|
|
1618
|
+
}
|
|
1619
|
+
return {
|
|
1620
|
+
count: value["count"],
|
|
1621
|
+
payment_methods: value["paymentMethods"].map(
|
|
1622
|
+
CompanyPaymentMethodResponseDataToJSON
|
|
1623
|
+
)
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1363
1626
|
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1364
1627
|
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1365
1628
|
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
@@ -1409,6 +1672,122 @@ function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminato
|
|
|
1409
1672
|
subtotal: value["subtotal"]
|
|
1410
1673
|
};
|
|
1411
1674
|
}
|
|
1675
|
+
function instanceOfSetupIntentResponseData(value) {
|
|
1676
|
+
if (!("schematicPublishableKey" in value) || value["schematicPublishableKey"] === void 0)
|
|
1677
|
+
return false;
|
|
1678
|
+
return true;
|
|
1679
|
+
}
|
|
1680
|
+
function SetupIntentResponseDataFromJSON(json) {
|
|
1681
|
+
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
1682
|
+
}
|
|
1683
|
+
function SetupIntentResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1684
|
+
if (json == null) {
|
|
1685
|
+
return json;
|
|
1686
|
+
}
|
|
1687
|
+
return {
|
|
1688
|
+
accountId: json["account_id"] == null ? void 0 : json["account_id"],
|
|
1689
|
+
publishableKey: json["publishable_key"] == null ? void 0 : json["publishable_key"],
|
|
1690
|
+
schematicPublishableKey: json["schematic_publishable_key"],
|
|
1691
|
+
setupIntentClientSecret: json["setup_intent_client_secret"] == null ? void 0 : json["setup_intent_client_secret"]
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
function SetupIntentResponseDataToJSON(json) {
|
|
1695
|
+
return SetupIntentResponseDataToJSONTyped(json, false);
|
|
1696
|
+
}
|
|
1697
|
+
function SetupIntentResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1698
|
+
if (value == null) {
|
|
1699
|
+
return value;
|
|
1700
|
+
}
|
|
1701
|
+
return {
|
|
1702
|
+
account_id: value["accountId"],
|
|
1703
|
+
publishable_key: value["publishableKey"],
|
|
1704
|
+
schematic_publishable_key: value["schematicPublishableKey"],
|
|
1705
|
+
setup_intent_client_secret: value["setupIntentClientSecret"]
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
function instanceOfCreateSetupIntentResponse(value) {
|
|
1709
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1710
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
function CreateSetupIntentResponseFromJSON(json) {
|
|
1714
|
+
return CreateSetupIntentResponseFromJSONTyped(json, false);
|
|
1715
|
+
}
|
|
1716
|
+
function CreateSetupIntentResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1717
|
+
if (json == null) {
|
|
1718
|
+
return json;
|
|
1719
|
+
}
|
|
1720
|
+
return {
|
|
1721
|
+
data: SetupIntentResponseDataFromJSON(json["data"]),
|
|
1722
|
+
params: json["params"]
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
function CreateSetupIntentResponseToJSON(json) {
|
|
1726
|
+
return CreateSetupIntentResponseToJSONTyped(json, false);
|
|
1727
|
+
}
|
|
1728
|
+
function CreateSetupIntentResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1729
|
+
if (value == null) {
|
|
1730
|
+
return value;
|
|
1731
|
+
}
|
|
1732
|
+
return {
|
|
1733
|
+
data: SetupIntentResponseDataToJSON(value["data"]),
|
|
1734
|
+
params: value["params"]
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
function instanceOfDeleteResponse(value) {
|
|
1738
|
+
return true;
|
|
1739
|
+
}
|
|
1740
|
+
function DeleteResponseFromJSON(json) {
|
|
1741
|
+
return DeleteResponseFromJSONTyped(json, false);
|
|
1742
|
+
}
|
|
1743
|
+
function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1744
|
+
if (json == null) {
|
|
1745
|
+
return json;
|
|
1746
|
+
}
|
|
1747
|
+
return {
|
|
1748
|
+
deleted: json["deleted"] == null ? void 0 : json["deleted"]
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
function DeleteResponseToJSON(json) {
|
|
1752
|
+
return DeleteResponseToJSONTyped(json, false);
|
|
1753
|
+
}
|
|
1754
|
+
function DeleteResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1755
|
+
if (value == null) {
|
|
1756
|
+
return value;
|
|
1757
|
+
}
|
|
1758
|
+
return {
|
|
1759
|
+
deleted: value["deleted"]
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
function instanceOfDeletePaymentMethodResponse(value) {
|
|
1763
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1764
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1765
|
+
return true;
|
|
1766
|
+
}
|
|
1767
|
+
function DeletePaymentMethodResponseFromJSON(json) {
|
|
1768
|
+
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
1769
|
+
}
|
|
1770
|
+
function DeletePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1771
|
+
if (json == null) {
|
|
1772
|
+
return json;
|
|
1773
|
+
}
|
|
1774
|
+
return {
|
|
1775
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
1776
|
+
params: json["params"]
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
function DeletePaymentMethodResponseToJSON(json) {
|
|
1780
|
+
return DeletePaymentMethodResponseToJSONTyped(json, false);
|
|
1781
|
+
}
|
|
1782
|
+
function DeletePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1783
|
+
if (value == null) {
|
|
1784
|
+
return value;
|
|
1785
|
+
}
|
|
1786
|
+
return {
|
|
1787
|
+
data: DeleteResponseToJSON(value["data"]),
|
|
1788
|
+
params: value["params"]
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1412
1791
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1413
1792
|
return true;
|
|
1414
1793
|
}
|
|
@@ -1467,6 +1846,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1467
1846
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1468
1847
|
};
|
|
1469
1848
|
}
|
|
1849
|
+
function instanceOfGetCompanyPaymentMethodsResponse(value) {
|
|
1850
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1851
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1852
|
+
return true;
|
|
1853
|
+
}
|
|
1854
|
+
function GetCompanyPaymentMethodsResponseFromJSON(json) {
|
|
1855
|
+
return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
|
|
1856
|
+
}
|
|
1857
|
+
function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1858
|
+
if (json == null) {
|
|
1859
|
+
return json;
|
|
1860
|
+
}
|
|
1861
|
+
return {
|
|
1862
|
+
data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
|
|
1863
|
+
params: json["params"]
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
function GetCompanyPaymentMethodsResponseToJSON(json) {
|
|
1867
|
+
return GetCompanyPaymentMethodsResponseToJSONTyped(json, false);
|
|
1868
|
+
}
|
|
1869
|
+
function GetCompanyPaymentMethodsResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1870
|
+
if (value == null) {
|
|
1871
|
+
return value;
|
|
1872
|
+
}
|
|
1873
|
+
return {
|
|
1874
|
+
data: CompanyPaymentMethodsResponseDataToJSON(value["data"]),
|
|
1875
|
+
params: value["params"]
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1470
1878
|
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1471
1879
|
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1472
1880
|
if (!("params" in value) || value["params"] === void 0) return false;
|
|
@@ -1496,11 +1904,140 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
|
|
|
1496
1904
|
params: value["params"]
|
|
1497
1905
|
};
|
|
1498
1906
|
}
|
|
1907
|
+
function instanceOfPaymentMethodResponseData(value) {
|
|
1908
|
+
if (!("createdAt" in value) || value["createdAt"] === void 0) return false;
|
|
1909
|
+
if (!("customerExternalId" in value) || value["customerExternalId"] === void 0)
|
|
1910
|
+
return false;
|
|
1911
|
+
if (!("environmentId" in value) || value["environmentId"] === void 0)
|
|
1912
|
+
return false;
|
|
1913
|
+
if (!("externalId" in value) || value["externalId"] === void 0)
|
|
1914
|
+
return false;
|
|
1915
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
1916
|
+
if (!("paymentMethodType" in value) || value["paymentMethodType"] === void 0)
|
|
1917
|
+
return false;
|
|
1918
|
+
if (!("providerType" in value) || value["providerType"] === void 0)
|
|
1919
|
+
return false;
|
|
1920
|
+
if (!("updatedAt" in value) || value["updatedAt"] === void 0) return false;
|
|
1921
|
+
return true;
|
|
1922
|
+
}
|
|
1923
|
+
function PaymentMethodResponseDataFromJSON(json) {
|
|
1924
|
+
return PaymentMethodResponseDataFromJSONTyped(json, false);
|
|
1925
|
+
}
|
|
1926
|
+
function PaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1927
|
+
if (json == null) {
|
|
1928
|
+
return json;
|
|
1929
|
+
}
|
|
1930
|
+
return {
|
|
1931
|
+
accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
|
|
1932
|
+
accountName: json["account_name"] == null ? void 0 : json["account_name"],
|
|
1933
|
+
bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
|
|
1934
|
+
billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
|
|
1935
|
+
billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
|
|
1936
|
+
cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
|
|
1937
|
+
cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
|
|
1938
|
+
cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
|
|
1939
|
+
cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
|
|
1940
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
1941
|
+
createdAt: new Date(json["created_at"]),
|
|
1942
|
+
customerExternalId: json["customer_external_id"],
|
|
1943
|
+
environmentId: json["environment_id"],
|
|
1944
|
+
externalId: json["external_id"],
|
|
1945
|
+
id: json["id"],
|
|
1946
|
+
paymentMethodType: json["payment_method_type"],
|
|
1947
|
+
providerType: BillingProviderTypeFromJSON2(json["provider_type"]),
|
|
1948
|
+
updatedAt: new Date(json["updated_at"])
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
function PaymentMethodResponseDataToJSON(json) {
|
|
1952
|
+
return PaymentMethodResponseDataToJSONTyped(json, false);
|
|
1953
|
+
}
|
|
1954
|
+
function PaymentMethodResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1955
|
+
if (value == null) {
|
|
1956
|
+
return value;
|
|
1957
|
+
}
|
|
1958
|
+
return {
|
|
1959
|
+
account_last4: value["accountLast4"],
|
|
1960
|
+
account_name: value["accountName"],
|
|
1961
|
+
bank_name: value["bankName"],
|
|
1962
|
+
billing_email: value["billingEmail"],
|
|
1963
|
+
billing_name: value["billingName"],
|
|
1964
|
+
card_brand: value["cardBrand"],
|
|
1965
|
+
card_exp_month: value["cardExpMonth"],
|
|
1966
|
+
card_exp_year: value["cardExpYear"],
|
|
1967
|
+
card_last4: value["cardLast4"],
|
|
1968
|
+
company_id: value["companyId"],
|
|
1969
|
+
created_at: value["createdAt"].toISOString(),
|
|
1970
|
+
customer_external_id: value["customerExternalId"],
|
|
1971
|
+
environment_id: value["environmentId"],
|
|
1972
|
+
external_id: value["externalId"],
|
|
1973
|
+
id: value["id"],
|
|
1974
|
+
payment_method_type: value["paymentMethodType"],
|
|
1975
|
+
provider_type: BillingProviderTypeToJSON2(value["providerType"]),
|
|
1976
|
+
updated_at: value["updatedAt"].toISOString()
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
function instanceOfUpdatePaymentMethodRequestBody(value) {
|
|
1980
|
+
if (!("paymentMethodId" in value) || value["paymentMethodId"] === void 0)
|
|
1981
|
+
return false;
|
|
1982
|
+
return true;
|
|
1983
|
+
}
|
|
1984
|
+
function UpdatePaymentMethodRequestBodyFromJSON(json) {
|
|
1985
|
+
return UpdatePaymentMethodRequestBodyFromJSONTyped(json, false);
|
|
1986
|
+
}
|
|
1987
|
+
function UpdatePaymentMethodRequestBodyFromJSONTyped(json, ignoreDiscriminator) {
|
|
1988
|
+
if (json == null) {
|
|
1989
|
+
return json;
|
|
1990
|
+
}
|
|
1991
|
+
return {
|
|
1992
|
+
paymentMethodId: json["payment_method_id"]
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1995
|
+
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
1996
|
+
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
1997
|
+
}
|
|
1998
|
+
function UpdatePaymentMethodRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1999
|
+
if (value == null) {
|
|
2000
|
+
return value;
|
|
2001
|
+
}
|
|
2002
|
+
return {
|
|
2003
|
+
payment_method_id: value["paymentMethodId"]
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
function instanceOfUpdatePaymentMethodResponse(value) {
|
|
2007
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
2008
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
2009
|
+
return true;
|
|
2010
|
+
}
|
|
2011
|
+
function UpdatePaymentMethodResponseFromJSON(json) {
|
|
2012
|
+
return UpdatePaymentMethodResponseFromJSONTyped(json, false);
|
|
2013
|
+
}
|
|
2014
|
+
function UpdatePaymentMethodResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
2015
|
+
if (json == null) {
|
|
2016
|
+
return json;
|
|
2017
|
+
}
|
|
2018
|
+
return {
|
|
2019
|
+
data: PaymentMethodResponseDataFromJSON(json["data"]),
|
|
2020
|
+
params: json["params"]
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
2023
|
+
function UpdatePaymentMethodResponseToJSON(json) {
|
|
2024
|
+
return UpdatePaymentMethodResponseToJSONTyped(json, false);
|
|
2025
|
+
}
|
|
2026
|
+
function UpdatePaymentMethodResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
2027
|
+
if (value == null) {
|
|
2028
|
+
return value;
|
|
2029
|
+
}
|
|
2030
|
+
return {
|
|
2031
|
+
data: PaymentMethodResponseDataToJSON(value["data"]),
|
|
2032
|
+
params: value["params"]
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
1499
2035
|
var anonymousIdKey = "schematicId";
|
|
1500
2036
|
var flagStateCachePrefix = "schematicCache";
|
|
1501
2037
|
var flagStateCacheMaxContexts = 10;
|
|
1502
2038
|
var flagStateCacheDefaultMaxAgeMs = 7 * 24 * 60 * 60 * 1e3;
|
|
1503
2039
|
var emptyCreditBalances = Object.freeze({});
|
|
2040
|
+
var emptyCreditSpendPolicies = [];
|
|
1504
2041
|
var Schematic = class {
|
|
1505
2042
|
_additionalHeaders = {};
|
|
1506
2043
|
apiKey;
|
|
@@ -1518,6 +2055,7 @@ var Schematic = class {
|
|
|
1518
2055
|
isPendingListeners = /* @__PURE__ */ new Set();
|
|
1519
2056
|
planListeners = /* @__PURE__ */ new Set();
|
|
1520
2057
|
creditBalanceListeners = /* @__PURE__ */ new Set();
|
|
2058
|
+
creditSpendPolicyListeners = /* @__PURE__ */ new Set();
|
|
1521
2059
|
storage;
|
|
1522
2060
|
persistFlagState = true;
|
|
1523
2061
|
flagStateCacheKey;
|
|
@@ -1528,6 +2066,7 @@ var Schematic = class {
|
|
|
1528
2066
|
featureUsageEventMap = {};
|
|
1529
2067
|
planChecks = {};
|
|
1530
2068
|
creditBalances = {};
|
|
2069
|
+
creditSpendPolicies = {};
|
|
1531
2070
|
webSocketUrl = "wss://api.schematichq.com";
|
|
1532
2071
|
webSocketConnectionTimeout = 1e4;
|
|
1533
2072
|
webSocketReconnect = true;
|
|
@@ -1920,6 +2459,19 @@ var Schematic = class {
|
|
|
1920
2459
|
this.notifyCreditBalanceListeners(merged);
|
|
1921
2460
|
}
|
|
1922
2461
|
}
|
|
2462
|
+
if (message.credit_spend_policies !== void 0 && message.credit_spend_policies !== null) {
|
|
2463
|
+
const contextStr = contextString(context);
|
|
2464
|
+
const next = CreditSpendPoliciesFromJSON(message.credit_spend_policies);
|
|
2465
|
+
const previous = this.creditSpendPolicies[contextStr] ?? [];
|
|
2466
|
+
if (!creditSpendPoliciesEqual(previous, next)) {
|
|
2467
|
+
this.creditSpendPolicies[contextStr] = next;
|
|
2468
|
+
this.debug(
|
|
2469
|
+
`WebSocket credit spend policy update received. Notifying listeners`,
|
|
2470
|
+
{ creditSpendPolicies: next }
|
|
2471
|
+
);
|
|
2472
|
+
this.notifyCreditSpendPolicyListeners(next);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
1923
2475
|
this.persistContextToCache(contextString(context));
|
|
1924
2476
|
this.flushContextDependentEventQueue();
|
|
1925
2477
|
this.setIsPending(false);
|
|
@@ -2421,10 +2973,19 @@ var Schematic = class {
|
|
|
2421
2973
|
this.creditBalances[contextStr] = balances;
|
|
2422
2974
|
}
|
|
2423
2975
|
}
|
|
2976
|
+
let revivedCreditSpendPolicies;
|
|
2977
|
+
if (entry.creditSpendPolicies !== void 0 && entry.creditSpendPolicies !== null) {
|
|
2978
|
+
const policies = CreditSpendPoliciesFromJSON(entry.creditSpendPolicies);
|
|
2979
|
+
if (policies.length > 0) {
|
|
2980
|
+
revivedCreditSpendPolicies = policies;
|
|
2981
|
+
this.creditSpendPolicies[contextStr] = policies;
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2424
2984
|
fresh[contextStr] = {
|
|
2425
2985
|
checks: revivedChecks,
|
|
2426
2986
|
plan: revivedPlan,
|
|
2427
2987
|
creditBalances: revivedCreditBalances,
|
|
2988
|
+
creditSpendPolicies: revivedCreditSpendPolicies,
|
|
2428
2989
|
updatedAt: entry.updatedAt
|
|
2429
2990
|
};
|
|
2430
2991
|
contextsLoaded += 1;
|
|
@@ -2438,7 +2999,8 @@ var Schematic = class {
|
|
|
2438
2999
|
const checksForContext = this.checks[contextStr];
|
|
2439
3000
|
const planForContext = this.planChecks[contextStr];
|
|
2440
3001
|
const creditBalancesForContext = this.creditBalances[contextStr];
|
|
2441
|
-
|
|
3002
|
+
const creditSpendPoliciesForContext = this.creditSpendPolicies[contextStr];
|
|
3003
|
+
if (checksForContext === void 0 && planForContext === void 0 && creditBalancesForContext === void 0 && creditSpendPoliciesForContext === void 0) {
|
|
2442
3004
|
return;
|
|
2443
3005
|
}
|
|
2444
3006
|
if (this.cachedFlagState === null) {
|
|
@@ -2457,6 +3019,7 @@ var Schematic = class {
|
|
|
2457
3019
|
checks: cleanChecks,
|
|
2458
3020
|
plan: planForContext,
|
|
2459
3021
|
creditBalances: creditBalancesForContext,
|
|
3022
|
+
creditSpendPolicies: creditSpendPoliciesForContext,
|
|
2460
3023
|
updatedAt: Date.now()
|
|
2461
3024
|
};
|
|
2462
3025
|
const entries = Object.entries(this.cachedFlagState.contexts);
|
|
@@ -2473,6 +3036,9 @@ var Schematic = class {
|
|
|
2473
3036
|
for (const key of Object.keys(this.creditBalances)) {
|
|
2474
3037
|
if (!survivorKeys.has(key)) delete this.creditBalances[key];
|
|
2475
3038
|
}
|
|
3039
|
+
for (const key of Object.keys(this.creditSpendPolicies)) {
|
|
3040
|
+
if (!survivorKeys.has(key)) delete this.creditSpendPolicies[key];
|
|
3041
|
+
}
|
|
2476
3042
|
this.cachedFlagState = {
|
|
2477
3043
|
version: cacheVersion,
|
|
2478
3044
|
contexts: Object.fromEntries(survivors)
|
|
@@ -3067,6 +3633,18 @@ var Schematic = class {
|
|
|
3067
3633
|
const contextStr = contextString(this.context);
|
|
3068
3634
|
return this.creditBalances[contextStr]?.[creditId];
|
|
3069
3635
|
};
|
|
3636
|
+
/** Get every credit spend policy binding the current context, company-scope first */
|
|
3637
|
+
getCreditSpendPolicies = () => {
|
|
3638
|
+
const contextStr = contextString(this.context);
|
|
3639
|
+
return this.creditSpendPolicies[contextStr] ?? emptyCreditSpendPolicies;
|
|
3640
|
+
};
|
|
3641
|
+
/** Get the spend policies binding a single credit type in the current context */
|
|
3642
|
+
getCreditSpendPoliciesForCredit = (creditId) => {
|
|
3643
|
+
const policies = this.getCreditSpendPolicies().filter(
|
|
3644
|
+
(policy) => policy.creditId === creditId
|
|
3645
|
+
);
|
|
3646
|
+
return policies.length > 0 ? policies : emptyCreditSpendPolicies;
|
|
3647
|
+
};
|
|
3070
3648
|
// flag checks state
|
|
3071
3649
|
getFlagCheck = (flagKey) => {
|
|
3072
3650
|
const contextStr = contextString(this.context);
|
|
@@ -3133,6 +3711,13 @@ var Schematic = class {
|
|
|
3133
3711
|
this.creditBalanceListeners.delete(listener);
|
|
3134
3712
|
};
|
|
3135
3713
|
};
|
|
3714
|
+
/** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
|
|
3715
|
+
addCreditSpendPolicyListener = (listener) => {
|
|
3716
|
+
this.creditSpendPolicyListeners.add(listener);
|
|
3717
|
+
return () => {
|
|
3718
|
+
this.creditSpendPolicyListeners.delete(listener);
|
|
3719
|
+
};
|
|
3720
|
+
};
|
|
3136
3721
|
notifyFlagCheckListeners = (flagKey, check) => {
|
|
3137
3722
|
const listeners = this.flagCheckListeners?.[flagKey] ?? [];
|
|
3138
3723
|
if (listeners.size > 0) {
|
|
@@ -3196,6 +3781,16 @@ var Schematic = class {
|
|
|
3196
3781
|
});
|
|
3197
3782
|
});
|
|
3198
3783
|
};
|
|
3784
|
+
notifyCreditSpendPolicyListeners = (value) => {
|
|
3785
|
+
const listeners = this.creditSpendPolicyListeners ?? [];
|
|
3786
|
+
listeners.forEach((listener) => {
|
|
3787
|
+
if (listener.length > 0) {
|
|
3788
|
+
listener(value);
|
|
3789
|
+
return;
|
|
3790
|
+
}
|
|
3791
|
+
listener();
|
|
3792
|
+
});
|
|
3793
|
+
};
|
|
3199
3794
|
notifyCreditBalanceListeners = (value) => {
|
|
3200
3795
|
const listeners = this.creditBalanceListeners ?? [];
|
|
3201
3796
|
if (listeners.size > 0) {
|
|
@@ -3248,7 +3843,7 @@ var notifyCreditBalanceListener = (listener, value) => {
|
|
|
3248
3843
|
import { inject, onScopeDispose } from "vue";
|
|
3249
3844
|
|
|
3250
3845
|
// src/version.ts
|
|
3251
|
-
var version2 = "1.
|
|
3846
|
+
var version2 = "1.7.0";
|
|
3252
3847
|
|
|
3253
3848
|
// src/context/schematic.ts
|
|
3254
3849
|
var SchematicSymbol = /* @__PURE__ */ Symbol("schematic");
|
|
@@ -3413,6 +4008,7 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
3413
4008
|
let unsubscribePending = null;
|
|
3414
4009
|
onMounted(() => {
|
|
3415
4010
|
creditBalance.value = readBalance();
|
|
4011
|
+
isPending.value = client.getIsPending();
|
|
3416
4012
|
unsubscribeBalance = client.addCreditBalanceListener(() => {
|
|
3417
4013
|
creditBalance.value = readBalance();
|
|
3418
4014
|
});
|
|
@@ -3433,6 +4029,36 @@ var useSchematicCreditBalance = (creditId, opts) => {
|
|
|
3433
4029
|
)
|
|
3434
4030
|
};
|
|
3435
4031
|
};
|
|
4032
|
+
var useSchematicCreditSpendPolicies = (opts) => {
|
|
4033
|
+
const client = useSchematicClient(opts);
|
|
4034
|
+
const policies = ref(
|
|
4035
|
+
client.getCreditSpendPolicies()
|
|
4036
|
+
);
|
|
4037
|
+
const isPending = ref(client.getIsPending());
|
|
4038
|
+
let unsubscribePolicies = null;
|
|
4039
|
+
let unsubscribePending = null;
|
|
4040
|
+
onMounted(() => {
|
|
4041
|
+
policies.value = client.getCreditSpendPolicies();
|
|
4042
|
+
isPending.value = client.getIsPending();
|
|
4043
|
+
unsubscribePolicies = client.addCreditSpendPolicyListener(() => {
|
|
4044
|
+
policies.value = client.getCreditSpendPolicies();
|
|
4045
|
+
});
|
|
4046
|
+
unsubscribePending = client.addIsPendingListener(() => {
|
|
4047
|
+
isPending.value = client.getIsPending();
|
|
4048
|
+
policies.value = client.getCreditSpendPolicies();
|
|
4049
|
+
});
|
|
4050
|
+
});
|
|
4051
|
+
onScopeDispose2(() => {
|
|
4052
|
+
unsubscribePolicies?.();
|
|
4053
|
+
unsubscribePending?.();
|
|
4054
|
+
});
|
|
4055
|
+
return {
|
|
4056
|
+
/** Company-scope policies first, then the user's own; empty when none bind */
|
|
4057
|
+
policies: computed(() => policies.value),
|
|
4058
|
+
/** True while the policies are still loading and nothing has arrived yet */
|
|
4059
|
+
isLoading: computed(() => policies.value.length === 0 && isPending.value)
|
|
4060
|
+
};
|
|
4061
|
+
};
|
|
3436
4062
|
var useSchematicIsPending = (opts) => {
|
|
3437
4063
|
const client = useSchematicClient(opts);
|
|
3438
4064
|
const isPending = ref(client.getIsPending());
|
|
@@ -3456,6 +4082,7 @@ export {
|
|
|
3456
4082
|
useSchematicClient,
|
|
3457
4083
|
useSchematicContext,
|
|
3458
4084
|
useSchematicCreditBalance,
|
|
4085
|
+
useSchematicCreditSpendPolicies,
|
|
3459
4086
|
useSchematicEntitlement,
|
|
3460
4087
|
useSchematicEvents,
|
|
3461
4088
|
useSchematicFlag,
|