@schematichq/schematic-react 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 +34 -0
- package/dist/schematic-react.cjs.js +156 -5
- package/dist/schematic-react.d.ts +199 -15
- package/dist/schematic-react.esm.js +156 -5
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -165,6 +165,40 @@ const MyComponent = () => {
|
|
|
165
165
|
|
|
166
166
|
These values refresh with each flag check. For a balance that also updates on the credit partials arriving between checks, pass `creditId` to [`useSchematicCreditBalance`](#credit-balances) instead.
|
|
167
167
|
|
|
168
|
+
### Usage warnings
|
|
169
|
+
|
|
170
|
+
If a usage warning is configured on the entitlement, the hook returns it as `warningTiers`, so you can warn a customer before they hit the limit rather than after:
|
|
171
|
+
|
|
172
|
+
| Property | Type | Description |
|
|
173
|
+
| --- | --- | --- |
|
|
174
|
+
| `warningTiers` | `WarningTier[] \| undefined` | The usage warning thresholds configured on the entitlement, each a `{ key, value }` pair in the entitlement's usage units. `undefined` when none are configured |
|
|
175
|
+
| `softLimit` | `number \| undefined` | For usage-based pricing, the soft limit for overage charges or the next tier boundary |
|
|
176
|
+
|
|
177
|
+
The dashboard writes a single tier under the key `default`.
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { useSchematicEntitlement } from "@schematichq/schematic-react";
|
|
181
|
+
import { Feature, ApproachingLimit } from "./components";
|
|
182
|
+
|
|
183
|
+
const MyComponent = () => {
|
|
184
|
+
const { featureUsage, warningTiers } =
|
|
185
|
+
useSchematicEntitlement("my-flag-key");
|
|
186
|
+
|
|
187
|
+
const warning = warningTiers?.find((tier) => tier.key === "default");
|
|
188
|
+
const approachingLimit =
|
|
189
|
+
typeof featureUsage === "number" &&
|
|
190
|
+
typeof warning?.value === "number" &&
|
|
191
|
+
featureUsage >= warning.value;
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<>
|
|
195
|
+
{approachingLimit && <ApproachingLimit limit={warning.value} />}
|
|
196
|
+
<Feature />
|
|
197
|
+
</>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
168
202
|
### Company plan information
|
|
169
203
|
|
|
170
204
|
To access the current company's plan and trial status, you can use the `useSchematicPlan` hook:
|
|
@@ -61,7 +61,7 @@ __export(index_exports, {
|
|
|
61
61
|
});
|
|
62
62
|
module.exports = __toCommonJS(index_exports);
|
|
63
63
|
|
|
64
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
64
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.8.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
|
|
65
65
|
var __create2 = Object.create;
|
|
66
66
|
var __defProp2 = Object.defineProperty;
|
|
67
67
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -1166,7 +1166,8 @@ var CheckFlagReturnFromJSON = (json) => {
|
|
|
1166
1166
|
ruleType: ruleType == null ? void 0 : ruleType,
|
|
1167
1167
|
softLimit: entitlement?.softLimit == null ? void 0 : entitlement.softLimit,
|
|
1168
1168
|
userId: userId == null ? void 0 : userId,
|
|
1169
|
-
value
|
|
1169
|
+
value,
|
|
1170
|
+
warningTiers: entitlement?.warningTiers == null ? void 0 : entitlement.warningTiers
|
|
1170
1171
|
};
|
|
1171
1172
|
};
|
|
1172
1173
|
var CheckPlanReturnFromJSON = (json) => {
|
|
@@ -1193,7 +1194,7 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1193
1194
|
}
|
|
1194
1195
|
return balances;
|
|
1195
1196
|
};
|
|
1196
|
-
var cacheVersion = "
|
|
1197
|
+
var cacheVersion = "7b920cf4";
|
|
1197
1198
|
function contextString(context) {
|
|
1198
1199
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1199
1200
|
const sortedKeys = Object.keys(
|
|
@@ -1208,13 +1209,17 @@ function contextString(context) {
|
|
|
1208
1209
|
}, {});
|
|
1209
1210
|
return JSON.stringify(sortedContext);
|
|
1210
1211
|
}
|
|
1211
|
-
var version = "1.
|
|
1212
|
+
var version = "1.8.0";
|
|
1212
1213
|
var models_exports = {};
|
|
1213
1214
|
__export2(models_exports, {
|
|
1214
1215
|
ApiErrorFromJSON: () => ApiErrorFromJSON,
|
|
1215
1216
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1216
1217
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1217
1218
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1219
|
+
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1220
|
+
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1221
|
+
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
1222
|
+
CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
|
|
1218
1223
|
CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
|
|
1219
1224
|
CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
|
|
1220
1225
|
CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
|
|
@@ -1223,6 +1228,10 @@ __export2(models_exports, {
|
|
|
1223
1228
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1224
1229
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1225
1230
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1231
|
+
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1232
|
+
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1233
|
+
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1234
|
+
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1226
1235
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1227
1236
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1228
1237
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1231,16 +1240,23 @@ __export2(models_exports, {
|
|
|
1231
1240
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1232
1241
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1233
1242
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1243
|
+
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1244
|
+
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1245
|
+
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
1246
|
+
GetCompanyUpcomingInvoiceResponseToJSONTyped: () => GetCompanyUpcomingInvoiceResponseToJSONTyped,
|
|
1234
1247
|
InvoiceStatus: () => InvoiceStatus,
|
|
1235
1248
|
InvoiceStatusFromJSON: () => InvoiceStatusFromJSON,
|
|
1236
1249
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1237
1250
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1238
1251
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1239
1252
|
instanceOfApiError: () => instanceOfApiError,
|
|
1253
|
+
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1240
1254
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1241
1255
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1256
|
+
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1242
1257
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1243
1258
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1259
|
+
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1244
1260
|
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1245
1261
|
});
|
|
1246
1262
|
function instanceOfApiError(value) {
|
|
@@ -1269,6 +1285,46 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1269
1285
|
error: value["error"]
|
|
1270
1286
|
};
|
|
1271
1287
|
}
|
|
1288
|
+
function instanceOfCompanyDiscountResponseData(value) {
|
|
1289
|
+
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1290
|
+
return false;
|
|
1291
|
+
if (!("duration" in value) || value["duration"] === void 0) return false;
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
function CompanyDiscountResponseDataFromJSON(json) {
|
|
1295
|
+
return CompanyDiscountResponseDataFromJSONTyped(json, false);
|
|
1296
|
+
}
|
|
1297
|
+
function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1298
|
+
if (json == null) {
|
|
1299
|
+
return json;
|
|
1300
|
+
}
|
|
1301
|
+
return {
|
|
1302
|
+
amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
|
|
1303
|
+
couponName: json["coupon_name"],
|
|
1304
|
+
currency: json["currency"] == null ? void 0 : json["currency"],
|
|
1305
|
+
customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
|
|
1306
|
+
duration: json["duration"],
|
|
1307
|
+
durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
|
|
1308
|
+
percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
function CompanyDiscountResponseDataToJSON(json) {
|
|
1312
|
+
return CompanyDiscountResponseDataToJSONTyped(json, false);
|
|
1313
|
+
}
|
|
1314
|
+
function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1315
|
+
if (value == null) {
|
|
1316
|
+
return value;
|
|
1317
|
+
}
|
|
1318
|
+
return {
|
|
1319
|
+
amount_off: value["amountOff"],
|
|
1320
|
+
coupon_name: value["couponName"],
|
|
1321
|
+
currency: value["currency"],
|
|
1322
|
+
customer_facing_code: value["customerFacingCode"],
|
|
1323
|
+
duration: value["duration"],
|
|
1324
|
+
duration_in_months: value["durationInMonths"],
|
|
1325
|
+
percent_off: value["percentOff"]
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1272
1328
|
var InvoiceStatus = {
|
|
1273
1329
|
Draft: "draft",
|
|
1274
1330
|
Open: "open",
|
|
@@ -1372,6 +1428,55 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1372
1428
|
)
|
|
1373
1429
|
};
|
|
1374
1430
|
}
|
|
1431
|
+
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1432
|
+
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1433
|
+
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
1434
|
+
if (!("customerBalanceApplied" in value) || value["customerBalanceApplied"] === void 0)
|
|
1435
|
+
return false;
|
|
1436
|
+
if (!("customerBalanceRemaining" in value) || value["customerBalanceRemaining"] === void 0)
|
|
1437
|
+
return false;
|
|
1438
|
+
if (!("discounts" in value) || value["discounts"] === void 0) return false;
|
|
1439
|
+
if (!("subtotal" in value) || value["subtotal"] === void 0) return false;
|
|
1440
|
+
return true;
|
|
1441
|
+
}
|
|
1442
|
+
function CompanyUpcomingInvoiceResponseDataFromJSON(json) {
|
|
1443
|
+
return CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, false);
|
|
1444
|
+
}
|
|
1445
|
+
function CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1446
|
+
if (json == null) {
|
|
1447
|
+
return json;
|
|
1448
|
+
}
|
|
1449
|
+
return {
|
|
1450
|
+
amountDue: json["amount_due"],
|
|
1451
|
+
currency: json["currency"],
|
|
1452
|
+
customerBalanceApplied: json["customer_balance_applied"],
|
|
1453
|
+
customerBalanceRemaining: json["customer_balance_remaining"],
|
|
1454
|
+
discounts: json["discounts"].map(
|
|
1455
|
+
CompanyDiscountResponseDataFromJSON
|
|
1456
|
+
),
|
|
1457
|
+
dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
|
|
1458
|
+
subtotal: json["subtotal"]
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
function CompanyUpcomingInvoiceResponseDataToJSON(json) {
|
|
1462
|
+
return CompanyUpcomingInvoiceResponseDataToJSONTyped(json, false);
|
|
1463
|
+
}
|
|
1464
|
+
function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1465
|
+
if (value == null) {
|
|
1466
|
+
return value;
|
|
1467
|
+
}
|
|
1468
|
+
return {
|
|
1469
|
+
amount_due: value["amountDue"],
|
|
1470
|
+
currency: value["currency"],
|
|
1471
|
+
customer_balance_applied: value["customerBalanceApplied"],
|
|
1472
|
+
customer_balance_remaining: value["customerBalanceRemaining"],
|
|
1473
|
+
discounts: value["discounts"].map(
|
|
1474
|
+
CompanyDiscountResponseDataToJSON
|
|
1475
|
+
),
|
|
1476
|
+
due_date: value["dueDate"] == null ? void 0 : value["dueDate"].toISOString(),
|
|
1477
|
+
subtotal: value["subtotal"]
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1375
1480
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1376
1481
|
return true;
|
|
1377
1482
|
}
|
|
@@ -1430,6 +1535,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1430
1535
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1431
1536
|
};
|
|
1432
1537
|
}
|
|
1538
|
+
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1539
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1540
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1541
|
+
return true;
|
|
1542
|
+
}
|
|
1543
|
+
function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
|
|
1544
|
+
return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
|
|
1545
|
+
}
|
|
1546
|
+
function GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1547
|
+
if (json == null) {
|
|
1548
|
+
return json;
|
|
1549
|
+
}
|
|
1550
|
+
return {
|
|
1551
|
+
data: CompanyUpcomingInvoiceResponseDataFromJSON(json["data"]),
|
|
1552
|
+
params: json["params"]
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
function GetCompanyUpcomingInvoiceResponseToJSON(json) {
|
|
1556
|
+
return GetCompanyUpcomingInvoiceResponseToJSONTyped(json, false);
|
|
1557
|
+
}
|
|
1558
|
+
function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1559
|
+
if (value == null) {
|
|
1560
|
+
return value;
|
|
1561
|
+
}
|
|
1562
|
+
return {
|
|
1563
|
+
data: CompanyUpcomingInvoiceResponseDataToJSON(value["data"]),
|
|
1564
|
+
params: value["params"]
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1433
1567
|
var DEFAULT_INVOICE_QUERY = {};
|
|
1434
1568
|
function normalizeInvoiceQuery(query) {
|
|
1435
1569
|
const { includePending, ...rest } = query;
|
|
@@ -1645,6 +1779,11 @@ var SchematicSession = class {
|
|
|
1645
1779
|
throw new SchematicApiError(status, path, rejected);
|
|
1646
1780
|
}
|
|
1647
1781
|
}
|
|
1782
|
+
if (options.noContentOn?.includes(response.status) === true) {
|
|
1783
|
+
await discardBody(response);
|
|
1784
|
+
await stillOurs();
|
|
1785
|
+
return void 0;
|
|
1786
|
+
}
|
|
1648
1787
|
const parsed = await readBody(response);
|
|
1649
1788
|
await stillOurs();
|
|
1650
1789
|
if (!response.ok) {
|
|
@@ -1737,6 +1876,18 @@ var SchematicBillingClient = class {
|
|
|
1737
1876
|
return { invoices: decoded.invoices, count: decoded.count };
|
|
1738
1877
|
});
|
|
1739
1878
|
}
|
|
1879
|
+
fetchUpcomingInvoice() {
|
|
1880
|
+
const path = "/company/upcoming-invoice";
|
|
1881
|
+
return this.session.request(path, { noContentOn: [204] }).then((body) => {
|
|
1882
|
+
if (body === void 0) {
|
|
1883
|
+
return null;
|
|
1884
|
+
}
|
|
1885
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
1886
|
+
throw new Error(`Malformed response from ${path}`);
|
|
1887
|
+
}
|
|
1888
|
+
return GetCompanyUpcomingInvoiceResponseFromJSON(body).data;
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1740
1891
|
};
|
|
1741
1892
|
var anonymousIdKey = "schematicId";
|
|
1742
1893
|
var flagStateCachePrefix = "schematicCache";
|
|
@@ -4313,7 +4464,7 @@ function staticSource(data) {
|
|
|
4313
4464
|
}
|
|
4314
4465
|
|
|
4315
4466
|
// src/version.ts
|
|
4316
|
-
var version2 = "1.
|
|
4467
|
+
var version2 = "1.7.0";
|
|
4317
4468
|
|
|
4318
4469
|
// src/context/schematic.tsx
|
|
4319
4470
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -34,7 +34,7 @@ declare type BaseSchematicProviderProps = Omit<SchematicJS.SchematicOptions, "cl
|
|
|
34
34
|
*/
|
|
35
35
|
session?: SessionInput;
|
|
36
36
|
/** A billing client; schematic-js supplies one when omitted. */
|
|
37
|
-
billingClient?:
|
|
37
|
+
billingClient?: BillingProviderClient;
|
|
38
38
|
/**
|
|
39
39
|
* Prefetched billing data, so the first render is complete (SSR). Rows
|
|
40
40
|
* stamped with their session paint on the first render only if `session`
|
|
@@ -53,6 +53,12 @@ declare namespace billingApi {
|
|
|
53
53
|
ApiErrorToJSON,
|
|
54
54
|
ApiErrorToJSONTyped,
|
|
55
55
|
ApiError,
|
|
56
|
+
instanceOfCompanyDiscountResponseData,
|
|
57
|
+
CompanyDiscountResponseDataFromJSON,
|
|
58
|
+
CompanyDiscountResponseDataFromJSONTyped,
|
|
59
|
+
CompanyDiscountResponseDataToJSON,
|
|
60
|
+
CompanyDiscountResponseDataToJSONTyped,
|
|
61
|
+
CompanyDiscountResponseData,
|
|
56
62
|
instanceOfCompanyInvoiceResponseData,
|
|
57
63
|
CompanyInvoiceResponseDataFromJSON,
|
|
58
64
|
CompanyInvoiceResponseDataFromJSONTyped,
|
|
@@ -65,6 +71,12 @@ declare namespace billingApi {
|
|
|
65
71
|
CompanyInvoicesResponseDataToJSON,
|
|
66
72
|
CompanyInvoicesResponseDataToJSONTyped,
|
|
67
73
|
CompanyInvoicesResponseData,
|
|
74
|
+
instanceOfCompanyUpcomingInvoiceResponseData,
|
|
75
|
+
CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
76
|
+
CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
77
|
+
CompanyUpcomingInvoiceResponseDataToJSON,
|
|
78
|
+
CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
79
|
+
CompanyUpcomingInvoiceResponseData,
|
|
68
80
|
instanceOfGetCompanyInvoicesParams,
|
|
69
81
|
GetCompanyInvoicesParamsFromJSON,
|
|
70
82
|
GetCompanyInvoicesParamsFromJSONTyped,
|
|
@@ -77,6 +89,12 @@ declare namespace billingApi {
|
|
|
77
89
|
GetCompanyInvoicesResponseToJSON,
|
|
78
90
|
GetCompanyInvoicesResponseToJSONTyped,
|
|
79
91
|
GetCompanyInvoicesResponse,
|
|
92
|
+
instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
93
|
+
GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
94
|
+
GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
95
|
+
GetCompanyUpcomingInvoiceResponseToJSON,
|
|
96
|
+
GetCompanyUpcomingInvoiceResponseToJSONTyped,
|
|
97
|
+
GetCompanyUpcomingInvoiceResponse,
|
|
80
98
|
instanceOfInvoiceStatus,
|
|
81
99
|
InvoiceStatusFromJSON,
|
|
82
100
|
InvoiceStatusFromJSONTyped,
|
|
@@ -91,8 +109,10 @@ declare namespace billingApi {
|
|
|
91
109
|
* rest of what `hydrate` serves — and the checkout calls that change them
|
|
92
110
|
* join this interface as their endpoints ship.
|
|
93
111
|
*/
|
|
94
|
-
|
|
112
|
+
declare interface BillingClient {
|
|
95
113
|
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
114
|
+
/** `null` when the company has no next bill. */
|
|
115
|
+
fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
|
|
96
116
|
readonly sessionStatus: SessionStatus;
|
|
97
117
|
readonly sessionKey: string | undefined;
|
|
98
118
|
setSession(session: SessionInput): void;
|
|
@@ -125,7 +145,7 @@ declare interface BillingDataProviderDataProps {
|
|
|
125
145
|
data: BillingData;
|
|
126
146
|
/** Simulated loading / failure per resource; wins over `data`. */
|
|
127
147
|
status?: BillingDataStatus;
|
|
128
|
-
onRefetch?: (name:
|
|
148
|
+
onRefetch?: (name: BillingResourceName_2) => void;
|
|
129
149
|
onLoadMoreInvoices?: (query: InvoiceQuery) => void;
|
|
130
150
|
children?: React_2.ReactNode;
|
|
131
151
|
}
|
|
@@ -146,8 +166,8 @@ export declare interface BillingDataSource {
|
|
|
146
166
|
* Sources that hold one value per resource (fixtures, prefetch) serve it
|
|
147
167
|
* for every parameter set.
|
|
148
168
|
*/
|
|
149
|
-
subscribe<K extends
|
|
150
|
-
handle<K extends
|
|
169
|
+
subscribe<K extends BillingResourceName_2>(name: K, params: BillingResourceParams_2[K], listener: () => void): () => void;
|
|
170
|
+
handle<K extends BillingResourceName_2>(name: K, params: BillingResourceParams_2[K]): ResourceHandle<BillingResources_2[K]>;
|
|
151
171
|
/** Never rejects: a failure lands on the resource's `error`. */
|
|
152
172
|
loadMoreInvoices: (query: InvoiceQuery) => Promise<void>;
|
|
153
173
|
invalidateAll: () => void;
|
|
@@ -155,24 +175,39 @@ export declare interface BillingDataSource {
|
|
|
155
175
|
|
|
156
176
|
/** Per-resource status overrides, for fixtures that simulate loading and failure. */
|
|
157
177
|
export declare type BillingDataStatus = {
|
|
158
|
-
[K in
|
|
178
|
+
[K in BillingResourceName_2]?: {
|
|
159
179
|
isPending?: boolean;
|
|
160
180
|
error?: Error;
|
|
161
181
|
};
|
|
162
182
|
};
|
|
163
183
|
|
|
164
184
|
declare interface BillingPrefetchOptions {
|
|
165
|
-
|
|
185
|
+
/**
|
|
186
|
+
* The resources the page renders, and no default: each one is a request
|
|
187
|
+
* on the server — the upcoming invoice is a live provider preview — and
|
|
188
|
+
* the list grows with every element, so a page names what it needs rather
|
|
189
|
+
* than paying for everything.
|
|
190
|
+
*/
|
|
191
|
+
names: BillingResourceName[];
|
|
166
192
|
/** The invoice query to prefetch for; the element must ask the same one. */
|
|
167
193
|
invoices?: InvoiceQuery;
|
|
168
194
|
}
|
|
169
195
|
|
|
170
196
|
/**
|
|
171
|
-
* Provides the billing hooks from a `BillingStore` over a `
|
|
197
|
+
* Provides the billing hooks from a `BillingStore` over a `BillingProviderClient`.
|
|
172
198
|
* Rendered by `SchematicProvider`; usable on its own with a client.
|
|
173
199
|
*/
|
|
174
200
|
export declare function BillingProvider({ billingClient, children, initialData, locale, onMissingString, session, strings, translate, }: BillingProviderProps): React_2.JSX.Element;
|
|
175
201
|
|
|
202
|
+
/**
|
|
203
|
+
* What `BillingProvider` asks of its client: the session it reads under, and
|
|
204
|
+
* the fetch behind each resource above. schematic-js's `SchematicBillingClient`
|
|
205
|
+
* satisfies it, and so does a host's own client that implements only this
|
|
206
|
+
* much. Named apart from schematic-js's `BillingClient`, which is the whole
|
|
207
|
+
* interface; this is the part the hooks here call.
|
|
208
|
+
*/
|
|
209
|
+
export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchInvoices">;
|
|
210
|
+
|
|
176
211
|
declare interface BillingProviderDataProps {
|
|
177
212
|
/**
|
|
178
213
|
* Required: this provider does not build one, and without it every hook
|
|
@@ -180,7 +215,7 @@ declare interface BillingProviderDataProps {
|
|
|
180
215
|
* `SchematicProvider` constructs one from its publishable key and renders
|
|
181
216
|
* this underneath, which is the usual path.
|
|
182
217
|
*/
|
|
183
|
-
billingClient?:
|
|
218
|
+
billingClient?: BillingProviderClient;
|
|
184
219
|
/**
|
|
185
220
|
* Read once, at mount. A prefetch stamped with its session paints on the
|
|
186
221
|
* first render only if `session` is stated on that render; under
|
|
@@ -210,13 +245,19 @@ declare interface BillingProviderDataProps {
|
|
|
210
245
|
*/
|
|
211
246
|
export declare type BillingProviderProps = BillingProviderDataProps & SchematicI18nConfig;
|
|
212
247
|
|
|
213
|
-
|
|
248
|
+
declare type BillingResourceName = keyof BillingResources;
|
|
249
|
+
|
|
250
|
+
/** The resources this package serves; a key of schematic-js's contract. */
|
|
251
|
+
declare type BillingResourceName_2 = "invoices";
|
|
214
252
|
|
|
215
253
|
/** `Record<string, never>` marks a singleton; anything else is keyed. */
|
|
216
|
-
|
|
254
|
+
declare interface BillingResourceParams {
|
|
217
255
|
invoices: InvoiceQuery;
|
|
256
|
+
upcomingInvoice: Record<string, never>;
|
|
218
257
|
}
|
|
219
258
|
|
|
259
|
+
declare type BillingResourceParams_2 = Pick<BillingResourceParams, BillingResourceName_2>;
|
|
260
|
+
|
|
220
261
|
/**
|
|
221
262
|
* Nothing in the store, the hooks, or the resource keys may be addressed by
|
|
222
263
|
* company or user id: users and companies are many-to-many, and a token names
|
|
@@ -224,11 +265,19 @@ export declare interface BillingResourceParams {
|
|
|
224
265
|
* pair, as `sessionKey` writes it — and a store that keeps more than one
|
|
225
266
|
* session's data keys it by that and serves only the active one.
|
|
226
267
|
*/
|
|
227
|
-
|
|
268
|
+
declare interface BillingResources {
|
|
228
269
|
/** `GET /company/invoices?limit&offset&include_pending`. */
|
|
229
270
|
invoices: InvoicePage;
|
|
271
|
+
/**
|
|
272
|
+
* `GET /company/upcoming-invoice`. `null` is a loaded value — the company
|
|
273
|
+
* has no next bill, which the endpoint reports as a 204 — so only
|
|
274
|
+
* `undefined` means the resource has not loaded.
|
|
275
|
+
*/
|
|
276
|
+
upcomingInvoice: UpcomingInvoice | null;
|
|
230
277
|
}
|
|
231
278
|
|
|
279
|
+
declare type BillingResources_2 = Pick<BillingResources, BillingResourceName_2>;
|
|
280
|
+
|
|
232
281
|
declare type BooleanListenerFn = (value: boolean) => void;
|
|
233
282
|
|
|
234
283
|
/**
|
|
@@ -397,6 +446,8 @@ export declare type CheckFlagReturn = {
|
|
|
397
446
|
userId?: string;
|
|
398
447
|
/** A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted */
|
|
399
448
|
value: boolean;
|
|
449
|
+
/** Customer-defined usage warning thresholds configured on this entitlement */
|
|
450
|
+
warningTiers?: WarningTier[];
|
|
400
451
|
};
|
|
401
452
|
|
|
402
453
|
declare const CheckFlagReturnFromJSON: (json: any) => CheckFlagReturn;
|
|
@@ -507,6 +558,67 @@ export declare interface CompanyCreditBalance {
|
|
|
507
558
|
settled: number;
|
|
508
559
|
}
|
|
509
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Schematic API
|
|
563
|
+
* Schematic API
|
|
564
|
+
*
|
|
565
|
+
* The version of the OpenAPI document: 0.1
|
|
566
|
+
*
|
|
567
|
+
*
|
|
568
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
569
|
+
* https://openapi-generator.tech
|
|
570
|
+
* Do not edit the class manually.
|
|
571
|
+
*/
|
|
572
|
+
/**
|
|
573
|
+
*
|
|
574
|
+
* @export
|
|
575
|
+
* @interface CompanyDiscountResponseData
|
|
576
|
+
*/
|
|
577
|
+
declare interface CompanyDiscountResponseData {
|
|
578
|
+
/**
|
|
579
|
+
*
|
|
580
|
+
* @type {number}
|
|
581
|
+
* @memberof CompanyDiscountResponseData
|
|
582
|
+
*/
|
|
583
|
+
amountOff?: number | null;
|
|
584
|
+
/**
|
|
585
|
+
*
|
|
586
|
+
* @type {string}
|
|
587
|
+
* @memberof CompanyDiscountResponseData
|
|
588
|
+
*/
|
|
589
|
+
couponName: string;
|
|
590
|
+
/**
|
|
591
|
+
*
|
|
592
|
+
* @type {string}
|
|
593
|
+
* @memberof CompanyDiscountResponseData
|
|
594
|
+
*/
|
|
595
|
+
currency?: string | null;
|
|
596
|
+
/**
|
|
597
|
+
*
|
|
598
|
+
* @type {string}
|
|
599
|
+
* @memberof CompanyDiscountResponseData
|
|
600
|
+
*/
|
|
601
|
+
customerFacingCode?: string | null;
|
|
602
|
+
/**
|
|
603
|
+
* Provider vocabulary: once, repeating, or forever.
|
|
604
|
+
* @type {string}
|
|
605
|
+
* @memberof CompanyDiscountResponseData
|
|
606
|
+
*/
|
|
607
|
+
duration: string;
|
|
608
|
+
/**
|
|
609
|
+
*
|
|
610
|
+
* @type {number}
|
|
611
|
+
* @memberof CompanyDiscountResponseData
|
|
612
|
+
*/
|
|
613
|
+
durationInMonths?: number | null;
|
|
614
|
+
/**
|
|
615
|
+
*
|
|
616
|
+
* @type {number}
|
|
617
|
+
* @memberof CompanyDiscountResponseData
|
|
618
|
+
*/
|
|
619
|
+
percentOff?: number | null;
|
|
620
|
+
}
|
|
621
|
+
|
|
510
622
|
/**
|
|
511
623
|
*
|
|
512
624
|
* @export
|
|
@@ -557,6 +669,56 @@ declare interface CompanyInvoiceResponseData {
|
|
|
557
669
|
url?: string | null;
|
|
558
670
|
}
|
|
559
671
|
|
|
672
|
+
/**
|
|
673
|
+
*
|
|
674
|
+
* @export
|
|
675
|
+
* @interface CompanyUpcomingInvoiceResponseData
|
|
676
|
+
*/
|
|
677
|
+
declare interface CompanyUpcomingInvoiceResponseData {
|
|
678
|
+
/**
|
|
679
|
+
*
|
|
680
|
+
* @type {number}
|
|
681
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
682
|
+
*/
|
|
683
|
+
amountDue: number;
|
|
684
|
+
/**
|
|
685
|
+
*
|
|
686
|
+
* @type {string}
|
|
687
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
688
|
+
*/
|
|
689
|
+
currency: string;
|
|
690
|
+
/**
|
|
691
|
+
* How much of the company's existing balance this invoice consumes.
|
|
692
|
+
* @type {number}
|
|
693
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
694
|
+
*/
|
|
695
|
+
customerBalanceApplied: number;
|
|
696
|
+
/**
|
|
697
|
+
* Balance left over after this invoice.
|
|
698
|
+
* @type {number}
|
|
699
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
700
|
+
*/
|
|
701
|
+
customerBalanceRemaining: number;
|
|
702
|
+
/**
|
|
703
|
+
* Only active discounts that reduce the bill.
|
|
704
|
+
* @type {Array<CompanyDiscountResponseData>}
|
|
705
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
706
|
+
*/
|
|
707
|
+
discounts: Array<CompanyDiscountResponseData>;
|
|
708
|
+
/**
|
|
709
|
+
*
|
|
710
|
+
* @type {Date}
|
|
711
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
712
|
+
*/
|
|
713
|
+
dueDate?: Date | null;
|
|
714
|
+
/**
|
|
715
|
+
* Amount before discounts and tax.
|
|
716
|
+
* @type {number}
|
|
717
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
718
|
+
*/
|
|
719
|
+
subtotal: number;
|
|
720
|
+
}
|
|
721
|
+
|
|
560
722
|
/** A company's lease-aware balance for a single credit type */
|
|
561
723
|
export declare type CreditBalance = {
|
|
562
724
|
/** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
|
|
@@ -612,6 +774,8 @@ declare function DatastreamCompanyPlanFromJSON(json: any): DatastreamCompanyPlan
|
|
|
612
774
|
|
|
613
775
|
export declare const DEFAULT_INVOICE_QUERY: InvoiceQuery;
|
|
614
776
|
|
|
777
|
+
declare type Discount = CompanyDiscountResponseData;
|
|
778
|
+
|
|
615
779
|
declare type EmptyListenerFn = () => void;
|
|
616
780
|
|
|
617
781
|
/**
|
|
@@ -879,7 +1043,7 @@ declare interface FeatureEntitlement {
|
|
|
879
1043
|
* Server prefetch for a provider's `initialData`. A resource that fails is
|
|
880
1044
|
* left out rather than thrown, so one of them cannot block a page.
|
|
881
1045
|
*/
|
|
882
|
-
declare function fetchBillingData(client: BillingClient, options
|
|
1046
|
+
declare function fetchBillingData(client: BillingClient, options: BillingPrefetchOptions): Promise<BillingData>;
|
|
883
1047
|
|
|
884
1048
|
declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
|
|
885
1049
|
|
|
@@ -989,6 +1153,14 @@ declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
|
|
|
989
1153
|
declare interface RequestOptions {
|
|
990
1154
|
method?: string;
|
|
991
1155
|
body?: unknown;
|
|
1156
|
+
/**
|
|
1157
|
+
* Success statuses that carry no body — a 204 for a resource that is
|
|
1158
|
+
* legitimately absent. The request resolves `undefined` for them, which
|
|
1159
|
+
* is distinct from a body that parsed to `null`. A 401 is never one — the
|
|
1160
|
+
* refresh and retry run first, and only what comes back from that is
|
|
1161
|
+
* judged.
|
|
1162
|
+
*/
|
|
1163
|
+
noContentOn?: number[];
|
|
992
1164
|
}
|
|
993
1165
|
|
|
994
1166
|
export declare interface ResourceHandle<T> extends ResourceState<T> {
|
|
@@ -1318,6 +1490,7 @@ declare class SchematicBillingClient implements BillingClient {
|
|
|
1318
1490
|
setSession(session: SessionInput): void;
|
|
1319
1491
|
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
1320
1492
|
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
1493
|
+
fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
|
|
1321
1494
|
}
|
|
1322
1495
|
|
|
1323
1496
|
/** Context for checking flags and sending events */
|
|
@@ -1399,13 +1572,16 @@ declare namespace SchematicJS {
|
|
|
1399
1572
|
CheckPlanReturnFromJSON,
|
|
1400
1573
|
CheckPlanReturnListenerFn,
|
|
1401
1574
|
CompanyCreditBalance,
|
|
1575
|
+
CompanyDiscountResponseData,
|
|
1402
1576
|
CompanyInvoiceResponseData,
|
|
1577
|
+
CompanyUpcomingInvoiceResponseData,
|
|
1403
1578
|
CreditBalance,
|
|
1404
1579
|
CreditBalanceListenerFn,
|
|
1405
1580
|
CreditBalances,
|
|
1406
1581
|
CreditBalancesFromJSON,
|
|
1407
1582
|
CreditBalancesListenerFn,
|
|
1408
1583
|
DEFAULT_INVOICE_QUERY,
|
|
1584
|
+
Discount,
|
|
1409
1585
|
EmptyListenerFn,
|
|
1410
1586
|
Event_2 as Event,
|
|
1411
1587
|
EventBody,
|
|
@@ -1440,11 +1616,14 @@ declare namespace SchematicJS {
|
|
|
1440
1616
|
SessionInput,
|
|
1441
1617
|
SessionOptions,
|
|
1442
1618
|
SessionStatus,
|
|
1619
|
+
SINGLETON,
|
|
1443
1620
|
StoragePersister,
|
|
1444
1621
|
TOKEN_CACHE_SIZE,
|
|
1445
1622
|
Traits,
|
|
1446
1623
|
TrialStatus,
|
|
1447
|
-
|
|
1624
|
+
UpcomingInvoice,
|
|
1625
|
+
UsagePeriod,
|
|
1626
|
+
WarningTier
|
|
1448
1627
|
}
|
|
1449
1628
|
}
|
|
1450
1629
|
|
|
@@ -1617,6 +1796,9 @@ declare interface SessionOptions {
|
|
|
1617
1796
|
|
|
1618
1797
|
export declare type SessionStatus = "pending" | "active" | "ended";
|
|
1619
1798
|
|
|
1799
|
+
/** The params of every singleton resource. */
|
|
1800
|
+
declare const SINGLETON: Record<string, never>;
|
|
1801
|
+
|
|
1620
1802
|
/** Optional type for implementing custom client-side storage */
|
|
1621
1803
|
export declare type StoragePersister = {
|
|
1622
1804
|
setItem(key: string, value: any): void;
|
|
@@ -1674,6 +1856,8 @@ export declare const TrialStatus: {
|
|
|
1674
1856
|
|
|
1675
1857
|
export declare type TrialStatus = (typeof TrialStatus)[keyof typeof TrialStatus];
|
|
1676
1858
|
|
|
1859
|
+
declare type UpcomingInvoice = CompanyUpcomingInvoiceResponseData;
|
|
1860
|
+
|
|
1677
1861
|
export declare enum UsagePeriod {
|
|
1678
1862
|
ALL_TIME = "all_time",
|
|
1679
1863
|
CURRENT_DAY = "current_day",
|
|
@@ -1760,7 +1944,7 @@ export declare function useSchematicTranslate(): Translate | undefined;
|
|
|
1760
1944
|
* @export
|
|
1761
1945
|
* @interface WarningTier
|
|
1762
1946
|
*/
|
|
1763
|
-
declare interface WarningTier {
|
|
1947
|
+
export declare interface WarningTier {
|
|
1764
1948
|
/**
|
|
1765
1949
|
* A customer-defined identifier for the warning tier
|
|
1766
1950
|
* @type {string}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@schematichq+schematic-js@1.
|
|
1
|
+
// node_modules/.pnpm/@schematichq+schematic-js@1.8.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;
|
|
@@ -1103,7 +1103,8 @@ var CheckFlagReturnFromJSON = (json) => {
|
|
|
1103
1103
|
ruleType: ruleType == null ? void 0 : ruleType,
|
|
1104
1104
|
softLimit: entitlement?.softLimit == null ? void 0 : entitlement.softLimit,
|
|
1105
1105
|
userId: userId == null ? void 0 : userId,
|
|
1106
|
-
value
|
|
1106
|
+
value,
|
|
1107
|
+
warningTiers: entitlement?.warningTiers == null ? void 0 : entitlement.warningTiers
|
|
1107
1108
|
};
|
|
1108
1109
|
};
|
|
1109
1110
|
var CheckPlanReturnFromJSON = (json) => {
|
|
@@ -1130,7 +1131,7 @@ var CreditBalancesFromJSON = (json) => {
|
|
|
1130
1131
|
}
|
|
1131
1132
|
return balances;
|
|
1132
1133
|
};
|
|
1133
|
-
var cacheVersion = "
|
|
1134
|
+
var cacheVersion = "7b920cf4";
|
|
1134
1135
|
function contextString(context) {
|
|
1135
1136
|
const sortedContext = Object.keys(context).reduce((acc, key) => {
|
|
1136
1137
|
const sortedKeys = Object.keys(
|
|
@@ -1145,13 +1146,17 @@ function contextString(context) {
|
|
|
1145
1146
|
}, {});
|
|
1146
1147
|
return JSON.stringify(sortedContext);
|
|
1147
1148
|
}
|
|
1148
|
-
var version = "1.
|
|
1149
|
+
var version = "1.8.0";
|
|
1149
1150
|
var models_exports = {};
|
|
1150
1151
|
__export(models_exports, {
|
|
1151
1152
|
ApiErrorFromJSON: () => ApiErrorFromJSON,
|
|
1152
1153
|
ApiErrorFromJSONTyped: () => ApiErrorFromJSONTyped,
|
|
1153
1154
|
ApiErrorToJSON: () => ApiErrorToJSON,
|
|
1154
1155
|
ApiErrorToJSONTyped: () => ApiErrorToJSONTyped,
|
|
1156
|
+
CompanyDiscountResponseDataFromJSON: () => CompanyDiscountResponseDataFromJSON,
|
|
1157
|
+
CompanyDiscountResponseDataFromJSONTyped: () => CompanyDiscountResponseDataFromJSONTyped,
|
|
1158
|
+
CompanyDiscountResponseDataToJSON: () => CompanyDiscountResponseDataToJSON,
|
|
1159
|
+
CompanyDiscountResponseDataToJSONTyped: () => CompanyDiscountResponseDataToJSONTyped,
|
|
1155
1160
|
CompanyInvoiceResponseDataFromJSON: () => CompanyInvoiceResponseDataFromJSON,
|
|
1156
1161
|
CompanyInvoiceResponseDataFromJSONTyped: () => CompanyInvoiceResponseDataFromJSONTyped,
|
|
1157
1162
|
CompanyInvoiceResponseDataToJSON: () => CompanyInvoiceResponseDataToJSON,
|
|
@@ -1160,6 +1165,10 @@ __export(models_exports, {
|
|
|
1160
1165
|
CompanyInvoicesResponseDataFromJSONTyped: () => CompanyInvoicesResponseDataFromJSONTyped,
|
|
1161
1166
|
CompanyInvoicesResponseDataToJSON: () => CompanyInvoicesResponseDataToJSON,
|
|
1162
1167
|
CompanyInvoicesResponseDataToJSONTyped: () => CompanyInvoicesResponseDataToJSONTyped,
|
|
1168
|
+
CompanyUpcomingInvoiceResponseDataFromJSON: () => CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
1169
|
+
CompanyUpcomingInvoiceResponseDataFromJSONTyped: () => CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
1170
|
+
CompanyUpcomingInvoiceResponseDataToJSON: () => CompanyUpcomingInvoiceResponseDataToJSON,
|
|
1171
|
+
CompanyUpcomingInvoiceResponseDataToJSONTyped: () => CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
1163
1172
|
GetCompanyInvoicesParamsFromJSON: () => GetCompanyInvoicesParamsFromJSON,
|
|
1164
1173
|
GetCompanyInvoicesParamsFromJSONTyped: () => GetCompanyInvoicesParamsFromJSONTyped,
|
|
1165
1174
|
GetCompanyInvoicesParamsToJSON: () => GetCompanyInvoicesParamsToJSON,
|
|
@@ -1168,16 +1177,23 @@ __export(models_exports, {
|
|
|
1168
1177
|
GetCompanyInvoicesResponseFromJSONTyped: () => GetCompanyInvoicesResponseFromJSONTyped,
|
|
1169
1178
|
GetCompanyInvoicesResponseToJSON: () => GetCompanyInvoicesResponseToJSON,
|
|
1170
1179
|
GetCompanyInvoicesResponseToJSONTyped: () => GetCompanyInvoicesResponseToJSONTyped,
|
|
1180
|
+
GetCompanyUpcomingInvoiceResponseFromJSON: () => GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
1181
|
+
GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
1182
|
+
GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
|
|
1183
|
+
GetCompanyUpcomingInvoiceResponseToJSONTyped: () => GetCompanyUpcomingInvoiceResponseToJSONTyped,
|
|
1171
1184
|
InvoiceStatus: () => InvoiceStatus,
|
|
1172
1185
|
InvoiceStatusFromJSON: () => InvoiceStatusFromJSON,
|
|
1173
1186
|
InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
|
|
1174
1187
|
InvoiceStatusToJSON: () => InvoiceStatusToJSON,
|
|
1175
1188
|
InvoiceStatusToJSONTyped: () => InvoiceStatusToJSONTyped,
|
|
1176
1189
|
instanceOfApiError: () => instanceOfApiError,
|
|
1190
|
+
instanceOfCompanyDiscountResponseData: () => instanceOfCompanyDiscountResponseData,
|
|
1177
1191
|
instanceOfCompanyInvoiceResponseData: () => instanceOfCompanyInvoiceResponseData,
|
|
1178
1192
|
instanceOfCompanyInvoicesResponseData: () => instanceOfCompanyInvoicesResponseData,
|
|
1193
|
+
instanceOfCompanyUpcomingInvoiceResponseData: () => instanceOfCompanyUpcomingInvoiceResponseData,
|
|
1179
1194
|
instanceOfGetCompanyInvoicesParams: () => instanceOfGetCompanyInvoicesParams,
|
|
1180
1195
|
instanceOfGetCompanyInvoicesResponse: () => instanceOfGetCompanyInvoicesResponse,
|
|
1196
|
+
instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
1181
1197
|
instanceOfInvoiceStatus: () => instanceOfInvoiceStatus
|
|
1182
1198
|
});
|
|
1183
1199
|
function instanceOfApiError(value) {
|
|
@@ -1206,6 +1222,46 @@ function ApiErrorToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
1206
1222
|
error: value["error"]
|
|
1207
1223
|
};
|
|
1208
1224
|
}
|
|
1225
|
+
function instanceOfCompanyDiscountResponseData(value) {
|
|
1226
|
+
if (!("couponName" in value) || value["couponName"] === void 0)
|
|
1227
|
+
return false;
|
|
1228
|
+
if (!("duration" in value) || value["duration"] === void 0) return false;
|
|
1229
|
+
return true;
|
|
1230
|
+
}
|
|
1231
|
+
function CompanyDiscountResponseDataFromJSON(json) {
|
|
1232
|
+
return CompanyDiscountResponseDataFromJSONTyped(json, false);
|
|
1233
|
+
}
|
|
1234
|
+
function CompanyDiscountResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1235
|
+
if (json == null) {
|
|
1236
|
+
return json;
|
|
1237
|
+
}
|
|
1238
|
+
return {
|
|
1239
|
+
amountOff: json["amount_off"] == null ? void 0 : json["amount_off"],
|
|
1240
|
+
couponName: json["coupon_name"],
|
|
1241
|
+
currency: json["currency"] == null ? void 0 : json["currency"],
|
|
1242
|
+
customerFacingCode: json["customer_facing_code"] == null ? void 0 : json["customer_facing_code"],
|
|
1243
|
+
duration: json["duration"],
|
|
1244
|
+
durationInMonths: json["duration_in_months"] == null ? void 0 : json["duration_in_months"],
|
|
1245
|
+
percentOff: json["percent_off"] == null ? void 0 : json["percent_off"]
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
function CompanyDiscountResponseDataToJSON(json) {
|
|
1249
|
+
return CompanyDiscountResponseDataToJSONTyped(json, false);
|
|
1250
|
+
}
|
|
1251
|
+
function CompanyDiscountResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1252
|
+
if (value == null) {
|
|
1253
|
+
return value;
|
|
1254
|
+
}
|
|
1255
|
+
return {
|
|
1256
|
+
amount_off: value["amountOff"],
|
|
1257
|
+
coupon_name: value["couponName"],
|
|
1258
|
+
currency: value["currency"],
|
|
1259
|
+
customer_facing_code: value["customerFacingCode"],
|
|
1260
|
+
duration: value["duration"],
|
|
1261
|
+
duration_in_months: value["durationInMonths"],
|
|
1262
|
+
percent_off: value["percentOff"]
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1209
1265
|
var InvoiceStatus = {
|
|
1210
1266
|
Draft: "draft",
|
|
1211
1267
|
Open: "open",
|
|
@@ -1309,6 +1365,55 @@ function CompanyInvoicesResponseDataToJSONTyped(value, ignoreDiscriminator = fal
|
|
|
1309
1365
|
)
|
|
1310
1366
|
};
|
|
1311
1367
|
}
|
|
1368
|
+
function instanceOfCompanyUpcomingInvoiceResponseData(value) {
|
|
1369
|
+
if (!("amountDue" in value) || value["amountDue"] === void 0) return false;
|
|
1370
|
+
if (!("currency" in value) || value["currency"] === void 0) return false;
|
|
1371
|
+
if (!("customerBalanceApplied" in value) || value["customerBalanceApplied"] === void 0)
|
|
1372
|
+
return false;
|
|
1373
|
+
if (!("customerBalanceRemaining" in value) || value["customerBalanceRemaining"] === void 0)
|
|
1374
|
+
return false;
|
|
1375
|
+
if (!("discounts" in value) || value["discounts"] === void 0) return false;
|
|
1376
|
+
if (!("subtotal" in value) || value["subtotal"] === void 0) return false;
|
|
1377
|
+
return true;
|
|
1378
|
+
}
|
|
1379
|
+
function CompanyUpcomingInvoiceResponseDataFromJSON(json) {
|
|
1380
|
+
return CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, false);
|
|
1381
|
+
}
|
|
1382
|
+
function CompanyUpcomingInvoiceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
1383
|
+
if (json == null) {
|
|
1384
|
+
return json;
|
|
1385
|
+
}
|
|
1386
|
+
return {
|
|
1387
|
+
amountDue: json["amount_due"],
|
|
1388
|
+
currency: json["currency"],
|
|
1389
|
+
customerBalanceApplied: json["customer_balance_applied"],
|
|
1390
|
+
customerBalanceRemaining: json["customer_balance_remaining"],
|
|
1391
|
+
discounts: json["discounts"].map(
|
|
1392
|
+
CompanyDiscountResponseDataFromJSON
|
|
1393
|
+
),
|
|
1394
|
+
dueDate: json["due_date"] == null ? void 0 : new Date(json["due_date"]),
|
|
1395
|
+
subtotal: json["subtotal"]
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
function CompanyUpcomingInvoiceResponseDataToJSON(json) {
|
|
1399
|
+
return CompanyUpcomingInvoiceResponseDataToJSONTyped(json, false);
|
|
1400
|
+
}
|
|
1401
|
+
function CompanyUpcomingInvoiceResponseDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1402
|
+
if (value == null) {
|
|
1403
|
+
return value;
|
|
1404
|
+
}
|
|
1405
|
+
return {
|
|
1406
|
+
amount_due: value["amountDue"],
|
|
1407
|
+
currency: value["currency"],
|
|
1408
|
+
customer_balance_applied: value["customerBalanceApplied"],
|
|
1409
|
+
customer_balance_remaining: value["customerBalanceRemaining"],
|
|
1410
|
+
discounts: value["discounts"].map(
|
|
1411
|
+
CompanyDiscountResponseDataToJSON
|
|
1412
|
+
),
|
|
1413
|
+
due_date: value["dueDate"] == null ? void 0 : value["dueDate"].toISOString(),
|
|
1414
|
+
subtotal: value["subtotal"]
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1312
1417
|
function instanceOfGetCompanyInvoicesParams(value) {
|
|
1313
1418
|
return true;
|
|
1314
1419
|
}
|
|
@@ -1367,6 +1472,35 @@ function GetCompanyInvoicesResponseToJSONTyped(value, ignoreDiscriminator = fals
|
|
|
1367
1472
|
params: GetCompanyInvoicesParamsToJSON(value["params"])
|
|
1368
1473
|
};
|
|
1369
1474
|
}
|
|
1475
|
+
function instanceOfGetCompanyUpcomingInvoiceResponse(value) {
|
|
1476
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
1477
|
+
if (!("params" in value) || value["params"] === void 0) return false;
|
|
1478
|
+
return true;
|
|
1479
|
+
}
|
|
1480
|
+
function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
|
|
1481
|
+
return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
|
|
1482
|
+
}
|
|
1483
|
+
function GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
1484
|
+
if (json == null) {
|
|
1485
|
+
return json;
|
|
1486
|
+
}
|
|
1487
|
+
return {
|
|
1488
|
+
data: CompanyUpcomingInvoiceResponseDataFromJSON(json["data"]),
|
|
1489
|
+
params: json["params"]
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
function GetCompanyUpcomingInvoiceResponseToJSON(json) {
|
|
1493
|
+
return GetCompanyUpcomingInvoiceResponseToJSONTyped(json, false);
|
|
1494
|
+
}
|
|
1495
|
+
function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator = false) {
|
|
1496
|
+
if (value == null) {
|
|
1497
|
+
return value;
|
|
1498
|
+
}
|
|
1499
|
+
return {
|
|
1500
|
+
data: CompanyUpcomingInvoiceResponseDataToJSON(value["data"]),
|
|
1501
|
+
params: value["params"]
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1370
1504
|
var DEFAULT_INVOICE_QUERY = {};
|
|
1371
1505
|
function normalizeInvoiceQuery(query) {
|
|
1372
1506
|
const { includePending, ...rest } = query;
|
|
@@ -1582,6 +1716,11 @@ var SchematicSession = class {
|
|
|
1582
1716
|
throw new SchematicApiError(status, path, rejected);
|
|
1583
1717
|
}
|
|
1584
1718
|
}
|
|
1719
|
+
if (options.noContentOn?.includes(response.status) === true) {
|
|
1720
|
+
await discardBody(response);
|
|
1721
|
+
await stillOurs();
|
|
1722
|
+
return void 0;
|
|
1723
|
+
}
|
|
1585
1724
|
const parsed = await readBody(response);
|
|
1586
1725
|
await stillOurs();
|
|
1587
1726
|
if (!response.ok) {
|
|
@@ -1674,6 +1813,18 @@ var SchematicBillingClient = class {
|
|
|
1674
1813
|
return { invoices: decoded.invoices, count: decoded.count };
|
|
1675
1814
|
});
|
|
1676
1815
|
}
|
|
1816
|
+
fetchUpcomingInvoice() {
|
|
1817
|
+
const path = "/company/upcoming-invoice";
|
|
1818
|
+
return this.session.request(path, { noContentOn: [204] }).then((body) => {
|
|
1819
|
+
if (body === void 0) {
|
|
1820
|
+
return null;
|
|
1821
|
+
}
|
|
1822
|
+
if (body === null || typeof body !== "object" || !("data" in body)) {
|
|
1823
|
+
throw new Error(`Malformed response from ${path}`);
|
|
1824
|
+
}
|
|
1825
|
+
return GetCompanyUpcomingInvoiceResponseFromJSON(body).data;
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1677
1828
|
};
|
|
1678
1829
|
var anonymousIdKey = "schematicId";
|
|
1679
1830
|
var flagStateCachePrefix = "schematicCache";
|
|
@@ -4250,7 +4401,7 @@ function staticSource(data) {
|
|
|
4250
4401
|
}
|
|
4251
4402
|
|
|
4252
4403
|
// src/version.ts
|
|
4253
|
-
var version2 = "1.
|
|
4404
|
+
var version2 = "1.7.0";
|
|
4254
4405
|
|
|
4255
4406
|
// src/context/schematic.tsx
|
|
4256
4407
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematichq/schematic-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"main": "dist/schematic-react.cjs.js",
|
|
5
5
|
"module": "dist/schematic-react.esm.js",
|
|
6
6
|
"types": "dist/schematic-react.d.ts",
|
|
@@ -34,24 +34,24 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/js": "^10.0.1",
|
|
36
36
|
"@microsoft/api-extractor": "^7.59.1",
|
|
37
|
-
"@schematichq/schematic-js": "^1.
|
|
38
|
-
"@testing-library/dom": "^10.4.
|
|
37
|
+
"@schematichq/schematic-js": "^1.8.0",
|
|
38
|
+
"@testing-library/dom": "^10.4.2",
|
|
39
39
|
"@testing-library/jest-dom": "^7.0.1",
|
|
40
40
|
"@testing-library/react": "^16.3.3",
|
|
41
|
-
"@types/react": "^19.
|
|
41
|
+
"@types/react": "^19.3.0",
|
|
42
42
|
"@vitest/browser": "^5.0.0",
|
|
43
43
|
"esbuild": "^0.28.2",
|
|
44
|
-
"eslint": "^10.
|
|
44
|
+
"eslint": "^10.11.0",
|
|
45
45
|
"eslint-plugin-import": "^2.32.0",
|
|
46
46
|
"eslint-plugin-react": "^7.37.5",
|
|
47
47
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
48
48
|
"globals": "^17.12.0",
|
|
49
|
-
"happy-dom": "^20.14.
|
|
49
|
+
"happy-dom": "^20.14.5",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
|
-
"jsdom": "^30.0
|
|
52
|
-
"prettier": "^3.9.
|
|
53
|
-
"react": "^19.
|
|
54
|
-
"react-dom": "^19.
|
|
51
|
+
"jsdom": "^30.1.0",
|
|
52
|
+
"prettier": "^3.9.8",
|
|
53
|
+
"react": "^19.3.0",
|
|
54
|
+
"react-dom": "^19.3.0",
|
|
55
55
|
"typescript": "^6.0.3",
|
|
56
56
|
"typescript-eslint": "^8.70.0",
|
|
57
57
|
"vitest": "^5.0.0"
|