@schematichq/schematic-components 2.37.0 → 2.38.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/dist/schematic-components-elements.cjs.js +47 -16
- package/dist/schematic-components-elements.d.ts +3 -3
- package/dist/schematic-components-elements.esm.js +47 -16
- package/dist/schematic-components.browser.cjs.js +621 -208
- package/dist/schematic-components.browser.esm.js +621 -208
- package/dist/schematic-components.cjs.js +621 -208
- package/dist/schematic-components.d.ts +55 -1
- package/dist/schematic-components.esm.js +621 -208
- package/package.json +8 -8
|
@@ -1936,6 +1936,7 @@ var initialContext = {
|
|
|
1936
1936
|
getUpcomingInvoice: stub,
|
|
1937
1937
|
getCustomerBalance: stub,
|
|
1938
1938
|
listInvoices: stub,
|
|
1939
|
+
getInvoiceLink: stub,
|
|
1939
1940
|
getCreditUsageByUser: stub,
|
|
1940
1941
|
getFeatureUsageByUser: stub,
|
|
1941
1942
|
createSetupIntent: stub,
|
|
@@ -8178,6 +8179,84 @@ function CreateCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8178
8179
|
};
|
|
8179
8180
|
}
|
|
8180
8181
|
|
|
8182
|
+
// src/api/checkoutexternal/models/CreditSpendWindowUnit.ts
|
|
8183
|
+
function CreditSpendWindowUnitFromJSON(json) {
|
|
8184
|
+
return CreditSpendWindowUnitFromJSONTyped(json, false);
|
|
8185
|
+
}
|
|
8186
|
+
function CreditSpendWindowUnitFromJSONTyped(json, ignoreDiscriminator) {
|
|
8187
|
+
return json;
|
|
8188
|
+
}
|
|
8189
|
+
function CreditSpendWindowUnitToJSON(value) {
|
|
8190
|
+
return value;
|
|
8191
|
+
}
|
|
8192
|
+
|
|
8193
|
+
// src/api/checkoutexternal/models/CreateCompanySpendPolicyRequestBody.ts
|
|
8194
|
+
function CreateCompanySpendPolicyRequestBodyToJSON(json) {
|
|
8195
|
+
return CreateCompanySpendPolicyRequestBodyToJSONTyped(json, false);
|
|
8196
|
+
}
|
|
8197
|
+
function CreateCompanySpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
8198
|
+
if (value == null) {
|
|
8199
|
+
return value;
|
|
8200
|
+
}
|
|
8201
|
+
return {
|
|
8202
|
+
billing_credit_id: value["billingCreditId"],
|
|
8203
|
+
label: value["label"],
|
|
8204
|
+
max_per_draw: value["maxPerDraw"],
|
|
8205
|
+
user_id: value["userId"],
|
|
8206
|
+
window_amount: value["windowAmount"],
|
|
8207
|
+
window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
|
|
8208
|
+
};
|
|
8209
|
+
}
|
|
8210
|
+
|
|
8211
|
+
// src/api/checkoutexternal/models/CreditSpendPolicyScope.ts
|
|
8212
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
8213
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
8214
|
+
}
|
|
8215
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
8216
|
+
return json;
|
|
8217
|
+
}
|
|
8218
|
+
|
|
8219
|
+
// src/api/checkoutexternal/models/CreditSpendPolicyResponseData.ts
|
|
8220
|
+
function CreditSpendPolicyResponseDataFromJSON(json) {
|
|
8221
|
+
return CreditSpendPolicyResponseDataFromJSONTyped(json, false);
|
|
8222
|
+
}
|
|
8223
|
+
function CreditSpendPolicyResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
8224
|
+
if (json == null) {
|
|
8225
|
+
return json;
|
|
8226
|
+
}
|
|
8227
|
+
return {
|
|
8228
|
+
billingCreditId: json["billing_credit_id"],
|
|
8229
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
8230
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
8231
|
+
createdAt: new Date(json["created_at"]),
|
|
8232
|
+
headroom: json["headroom"] == null ? void 0 : json["headroom"],
|
|
8233
|
+
id: json["id"],
|
|
8234
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
8235
|
+
maxPerDraw: json["max_per_draw"] == null ? void 0 : json["max_per_draw"],
|
|
8236
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
8237
|
+
scopeType: CreditSpendPolicyScopeFromJSON(json["scope_type"]),
|
|
8238
|
+
updatedAt: new Date(json["updated_at"]),
|
|
8239
|
+
userId: json["user_id"] == null ? void 0 : json["user_id"],
|
|
8240
|
+
windowAmount: json["window_amount"] == null ? void 0 : json["window_amount"],
|
|
8241
|
+
windowCount: json["window_count"],
|
|
8242
|
+
windowUnit: json["window_unit"] == null ? void 0 : CreditSpendWindowUnitFromJSON(json["window_unit"])
|
|
8243
|
+
};
|
|
8244
|
+
}
|
|
8245
|
+
|
|
8246
|
+
// src/api/checkoutexternal/models/CreateCompanySpendPolicyResponse.ts
|
|
8247
|
+
function CreateCompanySpendPolicyResponseFromJSON(json) {
|
|
8248
|
+
return CreateCompanySpendPolicyResponseFromJSONTyped(json, false);
|
|
8249
|
+
}
|
|
8250
|
+
function CreateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8251
|
+
if (json == null) {
|
|
8252
|
+
return json;
|
|
8253
|
+
}
|
|
8254
|
+
return {
|
|
8255
|
+
data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
|
|
8256
|
+
params: json["params"]
|
|
8257
|
+
};
|
|
8258
|
+
}
|
|
8259
|
+
|
|
8181
8260
|
// src/api/checkoutexternal/models/SetupIntentResponseData.ts
|
|
8182
8261
|
function SetupIntentResponseDataFromJSON(json) {
|
|
8183
8262
|
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
@@ -8266,6 +8345,20 @@ function CreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8266
8345
|
};
|
|
8267
8346
|
}
|
|
8268
8347
|
|
|
8348
|
+
// src/api/checkoutexternal/models/DeleteCompanySpendPolicyResponse.ts
|
|
8349
|
+
function DeleteCompanySpendPolicyResponseFromJSON(json) {
|
|
8350
|
+
return DeleteCompanySpendPolicyResponseFromJSONTyped(json, false);
|
|
8351
|
+
}
|
|
8352
|
+
function DeleteCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8353
|
+
if (json == null) {
|
|
8354
|
+
return json;
|
|
8355
|
+
}
|
|
8356
|
+
return {
|
|
8357
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
8358
|
+
params: json["params"]
|
|
8359
|
+
};
|
|
8360
|
+
}
|
|
8361
|
+
|
|
8269
8362
|
// src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
|
|
8270
8363
|
function DeletePaymentMethodResponseFromJSON(json) {
|
|
8271
8364
|
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
@@ -8640,6 +8733,34 @@ function GetFeatureUsageByUserResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8640
8733
|
};
|
|
8641
8734
|
}
|
|
8642
8735
|
|
|
8736
|
+
// src/api/checkoutexternal/models/InvoiceLink.ts
|
|
8737
|
+
function InvoiceLinkFromJSON(json) {
|
|
8738
|
+
return InvoiceLinkFromJSONTyped(json, false);
|
|
8739
|
+
}
|
|
8740
|
+
function InvoiceLinkFromJSONTyped(json, ignoreDiscriminator) {
|
|
8741
|
+
if (json == null) {
|
|
8742
|
+
return json;
|
|
8743
|
+
}
|
|
8744
|
+
return {
|
|
8745
|
+
id: json["id"],
|
|
8746
|
+
url: json["url"]
|
|
8747
|
+
};
|
|
8748
|
+
}
|
|
8749
|
+
|
|
8750
|
+
// src/api/checkoutexternal/models/GetInvoiceLinkResponse.ts
|
|
8751
|
+
function GetInvoiceLinkResponseFromJSON(json) {
|
|
8752
|
+
return GetInvoiceLinkResponseFromJSONTyped(json, false);
|
|
8753
|
+
}
|
|
8754
|
+
function GetInvoiceLinkResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8755
|
+
if (json == null) {
|
|
8756
|
+
return json;
|
|
8757
|
+
}
|
|
8758
|
+
return {
|
|
8759
|
+
data: InvoiceLinkFromJSON(json["data"]),
|
|
8760
|
+
params: json["params"]
|
|
8761
|
+
};
|
|
8762
|
+
}
|
|
8763
|
+
|
|
8643
8764
|
// src/api/checkoutexternal/models/GetSetupIntentResponse.ts
|
|
8644
8765
|
function GetSetupIntentResponseFromJSON(json) {
|
|
8645
8766
|
return GetSetupIntentResponseFromJSONTyped(json, false);
|
|
@@ -8753,6 +8874,35 @@ function ListCheckoutsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8753
8874
|
};
|
|
8754
8875
|
}
|
|
8755
8876
|
|
|
8877
|
+
// src/api/checkoutexternal/models/ListCompanySpendPoliciesParams.ts
|
|
8878
|
+
function ListCompanySpendPoliciesParamsFromJSON(json) {
|
|
8879
|
+
return ListCompanySpendPoliciesParamsFromJSONTyped(json, false);
|
|
8880
|
+
}
|
|
8881
|
+
function ListCompanySpendPoliciesParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
8882
|
+
if (json == null) {
|
|
8883
|
+
return json;
|
|
8884
|
+
}
|
|
8885
|
+
return {
|
|
8886
|
+
billingCreditId: json["billing_credit_id"] == null ? void 0 : json["billing_credit_id"]
|
|
8887
|
+
};
|
|
8888
|
+
}
|
|
8889
|
+
|
|
8890
|
+
// src/api/checkoutexternal/models/ListCompanySpendPoliciesResponse.ts
|
|
8891
|
+
function ListCompanySpendPoliciesResponseFromJSON(json) {
|
|
8892
|
+
return ListCompanySpendPoliciesResponseFromJSONTyped(json, false);
|
|
8893
|
+
}
|
|
8894
|
+
function ListCompanySpendPoliciesResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8895
|
+
if (json == null) {
|
|
8896
|
+
return json;
|
|
8897
|
+
}
|
|
8898
|
+
return {
|
|
8899
|
+
data: json["data"].map(
|
|
8900
|
+
CreditSpendPolicyResponseDataFromJSON
|
|
8901
|
+
),
|
|
8902
|
+
params: ListCompanySpendPoliciesParamsFromJSON(json["params"])
|
|
8903
|
+
};
|
|
8904
|
+
}
|
|
8905
|
+
|
|
8756
8906
|
// src/api/checkoutexternal/models/ListInvoicesParams.ts
|
|
8757
8907
|
function ListInvoicesParamsFromJSON(json) {
|
|
8758
8908
|
return ListInvoicesParamsFromJSONTyped(json, false);
|
|
@@ -9083,6 +9233,36 @@ function UpdateCheckoutTaxIDResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
9083
9233
|
};
|
|
9084
9234
|
}
|
|
9085
9235
|
|
|
9236
|
+
// src/api/checkoutexternal/models/UpdateCompanySpendPolicyResponse.ts
|
|
9237
|
+
function UpdateCompanySpendPolicyResponseFromJSON(json) {
|
|
9238
|
+
return UpdateCompanySpendPolicyResponseFromJSONTyped(json, false);
|
|
9239
|
+
}
|
|
9240
|
+
function UpdateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
9241
|
+
if (json == null) {
|
|
9242
|
+
return json;
|
|
9243
|
+
}
|
|
9244
|
+
return {
|
|
9245
|
+
data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
|
|
9246
|
+
params: json["params"]
|
|
9247
|
+
};
|
|
9248
|
+
}
|
|
9249
|
+
|
|
9250
|
+
// src/api/checkoutexternal/models/UpdateCreditSpendPolicyRequestBody.ts
|
|
9251
|
+
function UpdateCreditSpendPolicyRequestBodyToJSON(json) {
|
|
9252
|
+
return UpdateCreditSpendPolicyRequestBodyToJSONTyped(json, false);
|
|
9253
|
+
}
|
|
9254
|
+
function UpdateCreditSpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
9255
|
+
if (value == null) {
|
|
9256
|
+
return value;
|
|
9257
|
+
}
|
|
9258
|
+
return {
|
|
9259
|
+
label: value["label"],
|
|
9260
|
+
max_per_draw: value["maxPerDraw"],
|
|
9261
|
+
window_amount: value["windowAmount"],
|
|
9262
|
+
window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
|
|
9263
|
+
};
|
|
9264
|
+
}
|
|
9265
|
+
|
|
9086
9266
|
// src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
|
|
9087
9267
|
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
9088
9268
|
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
@@ -9240,6 +9420,51 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
9240
9420
|
);
|
|
9241
9421
|
return await response.value();
|
|
9242
9422
|
}
|
|
9423
|
+
/**
|
|
9424
|
+
* Create company spend policy
|
|
9425
|
+
*/
|
|
9426
|
+
async createCompanySpendPolicyRaw(requestParameters, initOverrides) {
|
|
9427
|
+
if (requestParameters["createCompanySpendPolicyRequestBody"] == null) {
|
|
9428
|
+
throw new RequiredError(
|
|
9429
|
+
"createCompanySpendPolicyRequestBody",
|
|
9430
|
+
'Required parameter "createCompanySpendPolicyRequestBody" was null or undefined when calling createCompanySpendPolicy().'
|
|
9431
|
+
);
|
|
9432
|
+
}
|
|
9433
|
+
const queryParameters = {};
|
|
9434
|
+
const headerParameters = {};
|
|
9435
|
+
headerParameters["Content-Type"] = "application/json";
|
|
9436
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
9437
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
9438
|
+
"X-Schematic-Api-Key"
|
|
9439
|
+
);
|
|
9440
|
+
}
|
|
9441
|
+
const response = await this.request(
|
|
9442
|
+
{
|
|
9443
|
+
path: `/company/credits/spend-policies`,
|
|
9444
|
+
method: "POST",
|
|
9445
|
+
headers: headerParameters,
|
|
9446
|
+
query: queryParameters,
|
|
9447
|
+
body: CreateCompanySpendPolicyRequestBodyToJSON(
|
|
9448
|
+
requestParameters["createCompanySpendPolicyRequestBody"]
|
|
9449
|
+
)
|
|
9450
|
+
},
|
|
9451
|
+
initOverrides
|
|
9452
|
+
);
|
|
9453
|
+
return new JSONApiResponse(
|
|
9454
|
+
response,
|
|
9455
|
+
(jsonValue) => CreateCompanySpendPolicyResponseFromJSON(jsonValue)
|
|
9456
|
+
);
|
|
9457
|
+
}
|
|
9458
|
+
/**
|
|
9459
|
+
* Create company spend policy
|
|
9460
|
+
*/
|
|
9461
|
+
async createCompanySpendPolicy(requestParameters, initOverrides) {
|
|
9462
|
+
const response = await this.createCompanySpendPolicyRaw(
|
|
9463
|
+
requestParameters,
|
|
9464
|
+
initOverrides
|
|
9465
|
+
);
|
|
9466
|
+
return await response.value();
|
|
9467
|
+
}
|
|
9243
9468
|
/**
|
|
9244
9469
|
* A Stripe SetupIntent for collecting a new payment method with Stripe\'s Payment Element. Confirm it with `stripe.confirmSetup`; the method it saves joins the company\'s methods on file.
|
|
9245
9470
|
* Create a setup intent
|
|
@@ -9274,6 +9499,50 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
9274
9499
|
const response = await this.createSetupIntentRaw(initOverrides);
|
|
9275
9500
|
return await response.value();
|
|
9276
9501
|
}
|
|
9502
|
+
/**
|
|
9503
|
+
* Delete company spend policy
|
|
9504
|
+
*/
|
|
9505
|
+
async deleteCompanySpendPolicyRaw(requestParameters, initOverrides) {
|
|
9506
|
+
if (requestParameters["spendPolicyId"] == null) {
|
|
9507
|
+
throw new RequiredError(
|
|
9508
|
+
"spendPolicyId",
|
|
9509
|
+
'Required parameter "spendPolicyId" was null or undefined when calling deleteCompanySpendPolicy().'
|
|
9510
|
+
);
|
|
9511
|
+
}
|
|
9512
|
+
const queryParameters = {};
|
|
9513
|
+
const headerParameters = {};
|
|
9514
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
9515
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
9516
|
+
"X-Schematic-Api-Key"
|
|
9517
|
+
);
|
|
9518
|
+
}
|
|
9519
|
+
const response = await this.request(
|
|
9520
|
+
{
|
|
9521
|
+
path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
|
|
9522
|
+
`{${"spend_policy_id"}}`,
|
|
9523
|
+
encodeURIComponent(String(requestParameters["spendPolicyId"]))
|
|
9524
|
+
),
|
|
9525
|
+
method: "DELETE",
|
|
9526
|
+
headers: headerParameters,
|
|
9527
|
+
query: queryParameters
|
|
9528
|
+
},
|
|
9529
|
+
initOverrides
|
|
9530
|
+
);
|
|
9531
|
+
return new JSONApiResponse(
|
|
9532
|
+
response,
|
|
9533
|
+
(jsonValue) => DeleteCompanySpendPolicyResponseFromJSON(jsonValue)
|
|
9534
|
+
);
|
|
9535
|
+
}
|
|
9536
|
+
/**
|
|
9537
|
+
* Delete company spend policy
|
|
9538
|
+
*/
|
|
9539
|
+
async deleteCompanySpendPolicy(requestParameters, initOverrides) {
|
|
9540
|
+
const response = await this.deleteCompanySpendPolicyRaw(
|
|
9541
|
+
requestParameters,
|
|
9542
|
+
initOverrides
|
|
9543
|
+
);
|
|
9544
|
+
return await response.value();
|
|
9545
|
+
}
|
|
9277
9546
|
/**
|
|
9278
9547
|
* Detaches a payment method from the company\'s billing customer. The path parameter is the payment method\'s `id` from the list, not a checkout\'s; `usePaymentMethods().remove` calls this and reloads the list. The list says whether each method can be removed.
|
|
9279
9548
|
* Remove a payment method
|
|
@@ -10000,6 +10269,50 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
10000
10269
|
);
|
|
10001
10270
|
return await response.value();
|
|
10002
10271
|
}
|
|
10272
|
+
/**
|
|
10273
|
+
* Get invoice link
|
|
10274
|
+
*/
|
|
10275
|
+
async getInvoiceLinkRaw(requestParameters, initOverrides) {
|
|
10276
|
+
if (requestParameters["billingInvoiceId"] == null) {
|
|
10277
|
+
throw new RequiredError(
|
|
10278
|
+
"billingInvoiceId",
|
|
10279
|
+
'Required parameter "billingInvoiceId" was null or undefined when calling getInvoiceLink().'
|
|
10280
|
+
);
|
|
10281
|
+
}
|
|
10282
|
+
const queryParameters = {};
|
|
10283
|
+
const headerParameters = {};
|
|
10284
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
10285
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
10286
|
+
"X-Schematic-Api-Key"
|
|
10287
|
+
);
|
|
10288
|
+
}
|
|
10289
|
+
const response = await this.request(
|
|
10290
|
+
{
|
|
10291
|
+
path: `/components/invoices/{billing_invoice_id}/link`.replace(
|
|
10292
|
+
`{${"billing_invoice_id"}}`,
|
|
10293
|
+
encodeURIComponent(String(requestParameters["billingInvoiceId"]))
|
|
10294
|
+
),
|
|
10295
|
+
method: "GET",
|
|
10296
|
+
headers: headerParameters,
|
|
10297
|
+
query: queryParameters
|
|
10298
|
+
},
|
|
10299
|
+
initOverrides
|
|
10300
|
+
);
|
|
10301
|
+
return new JSONApiResponse(
|
|
10302
|
+
response,
|
|
10303
|
+
(jsonValue) => GetInvoiceLinkResponseFromJSON(jsonValue)
|
|
10304
|
+
);
|
|
10305
|
+
}
|
|
10306
|
+
/**
|
|
10307
|
+
* Get invoice link
|
|
10308
|
+
*/
|
|
10309
|
+
async getInvoiceLink(requestParameters, initOverrides) {
|
|
10310
|
+
const response = await this.getInvoiceLinkRaw(
|
|
10311
|
+
requestParameters,
|
|
10312
|
+
initOverrides
|
|
10313
|
+
);
|
|
10314
|
+
return await response.value();
|
|
10315
|
+
}
|
|
10003
10316
|
/**
|
|
10004
10317
|
* Get setup intent
|
|
10005
10318
|
*/
|
|
@@ -10222,6 +10535,44 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
10222
10535
|
);
|
|
10223
10536
|
return await response.value();
|
|
10224
10537
|
}
|
|
10538
|
+
/**
|
|
10539
|
+
* List company spend policies
|
|
10540
|
+
*/
|
|
10541
|
+
async listCompanySpendPoliciesRaw(requestParameters, initOverrides) {
|
|
10542
|
+
const queryParameters = {};
|
|
10543
|
+
if (requestParameters["billingCreditId"] != null) {
|
|
10544
|
+
queryParameters["billing_credit_id"] = requestParameters["billingCreditId"];
|
|
10545
|
+
}
|
|
10546
|
+
const headerParameters = {};
|
|
10547
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
10548
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
10549
|
+
"X-Schematic-Api-Key"
|
|
10550
|
+
);
|
|
10551
|
+
}
|
|
10552
|
+
const response = await this.request(
|
|
10553
|
+
{
|
|
10554
|
+
path: `/company/credits/spend-policies`,
|
|
10555
|
+
method: "GET",
|
|
10556
|
+
headers: headerParameters,
|
|
10557
|
+
query: queryParameters
|
|
10558
|
+
},
|
|
10559
|
+
initOverrides
|
|
10560
|
+
);
|
|
10561
|
+
return new JSONApiResponse(
|
|
10562
|
+
response,
|
|
10563
|
+
(jsonValue) => ListCompanySpendPoliciesResponseFromJSON(jsonValue)
|
|
10564
|
+
);
|
|
10565
|
+
}
|
|
10566
|
+
/**
|
|
10567
|
+
* List company spend policies
|
|
10568
|
+
*/
|
|
10569
|
+
async listCompanySpendPolicies(requestParameters = {}, initOverrides) {
|
|
10570
|
+
const response = await this.listCompanySpendPoliciesRaw(
|
|
10571
|
+
requestParameters,
|
|
10572
|
+
initOverrides
|
|
10573
|
+
);
|
|
10574
|
+
return await response.value();
|
|
10575
|
+
}
|
|
10225
10576
|
/**
|
|
10226
10577
|
* List invoices
|
|
10227
10578
|
*/
|
|
@@ -10456,6 +10807,60 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
10456
10807
|
);
|
|
10457
10808
|
return await response.value();
|
|
10458
10809
|
}
|
|
10810
|
+
/**
|
|
10811
|
+
* Update company spend policy
|
|
10812
|
+
*/
|
|
10813
|
+
async updateCompanySpendPolicyRaw(requestParameters, initOverrides) {
|
|
10814
|
+
if (requestParameters["spendPolicyId"] == null) {
|
|
10815
|
+
throw new RequiredError(
|
|
10816
|
+
"spendPolicyId",
|
|
10817
|
+
'Required parameter "spendPolicyId" was null or undefined when calling updateCompanySpendPolicy().'
|
|
10818
|
+
);
|
|
10819
|
+
}
|
|
10820
|
+
if (requestParameters["updateCreditSpendPolicyRequestBody"] == null) {
|
|
10821
|
+
throw new RequiredError(
|
|
10822
|
+
"updateCreditSpendPolicyRequestBody",
|
|
10823
|
+
'Required parameter "updateCreditSpendPolicyRequestBody" was null or undefined when calling updateCompanySpendPolicy().'
|
|
10824
|
+
);
|
|
10825
|
+
}
|
|
10826
|
+
const queryParameters = {};
|
|
10827
|
+
const headerParameters = {};
|
|
10828
|
+
headerParameters["Content-Type"] = "application/json";
|
|
10829
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
10830
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
10831
|
+
"X-Schematic-Api-Key"
|
|
10832
|
+
);
|
|
10833
|
+
}
|
|
10834
|
+
const response = await this.request(
|
|
10835
|
+
{
|
|
10836
|
+
path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
|
|
10837
|
+
`{${"spend_policy_id"}}`,
|
|
10838
|
+
encodeURIComponent(String(requestParameters["spendPolicyId"]))
|
|
10839
|
+
),
|
|
10840
|
+
method: "PUT",
|
|
10841
|
+
headers: headerParameters,
|
|
10842
|
+
query: queryParameters,
|
|
10843
|
+
body: UpdateCreditSpendPolicyRequestBodyToJSON(
|
|
10844
|
+
requestParameters["updateCreditSpendPolicyRequestBody"]
|
|
10845
|
+
)
|
|
10846
|
+
},
|
|
10847
|
+
initOverrides
|
|
10848
|
+
);
|
|
10849
|
+
return new JSONApiResponse(
|
|
10850
|
+
response,
|
|
10851
|
+
(jsonValue) => UpdateCompanySpendPolicyResponseFromJSON(jsonValue)
|
|
10852
|
+
);
|
|
10853
|
+
}
|
|
10854
|
+
/**
|
|
10855
|
+
* Update company spend policy
|
|
10856
|
+
*/
|
|
10857
|
+
async updateCompanySpendPolicy(requestParameters, initOverrides) {
|
|
10858
|
+
const response = await this.updateCompanySpendPolicyRaw(
|
|
10859
|
+
requestParameters,
|
|
10860
|
+
initOverrides
|
|
10861
|
+
);
|
|
10862
|
+
return await response.value();
|
|
10863
|
+
}
|
|
10459
10864
|
/**
|
|
10460
10865
|
* Makes a method on file the one the company\'s charges use. The body\'s `payment_method_id` is the provider\'s id of the method, the `external_id` the list returns; `usePaymentMethods().setDefault` calls this and reloads the list. A card saved during a checkout joins the methods on file and becomes the default the same way.
|
|
10461
10866
|
* Make a payment method the default
|
|
@@ -12490,7 +12895,7 @@ function resolveLocale(locale) {
|
|
|
12490
12895
|
return locale !== void 0 && locale !== "" && isUsableLocale(locale) ? locale : DEFAULT_LOCALE;
|
|
12491
12896
|
}
|
|
12492
12897
|
|
|
12493
|
-
// node_modules/.pnpm/i18next@
|
|
12898
|
+
// node_modules/.pnpm/i18next@27.0.0_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
|
|
12494
12899
|
var isString = (obj) => typeof obj === "string";
|
|
12495
12900
|
var defer = () => {
|
|
12496
12901
|
let res;
|
|
@@ -12605,12 +13010,11 @@ var _entityMap = {
|
|
|
12605
13010
|
"<": "<",
|
|
12606
13011
|
">": ">",
|
|
12607
13012
|
'"': """,
|
|
12608
|
-
"'": "'"
|
|
12609
|
-
"/": "/"
|
|
13013
|
+
"'": "'"
|
|
12610
13014
|
};
|
|
12611
13015
|
var escape = (data) => {
|
|
12612
13016
|
if (isString(data)) {
|
|
12613
|
-
return data.replace(/[&<>"'
|
|
13017
|
+
return data.replace(/[&<>"']/g, (s) => _entityMap[s]);
|
|
12614
13018
|
}
|
|
12615
13019
|
return data;
|
|
12616
13020
|
};
|
|
@@ -12657,6 +13061,9 @@ var deepFind = (obj, path, keySeparator = ".") => {
|
|
|
12657
13061
|
if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
|
|
12658
13062
|
return obj[path];
|
|
12659
13063
|
}
|
|
13064
|
+
if (!keySeparator) {
|
|
13065
|
+
return Object.prototype.hasOwnProperty.call(obj, path) ? obj[path] : void 0;
|
|
13066
|
+
}
|
|
12660
13067
|
const tokens = path.split(keySeparator);
|
|
12661
13068
|
let current = obj;
|
|
12662
13069
|
for (let i2 = 0; i2 < tokens.length; ) {
|
|
@@ -12801,15 +13208,20 @@ var EventEmitter = class {
|
|
|
12801
13208
|
}
|
|
12802
13209
|
};
|
|
12803
13210
|
var nonEmptyBundles = /* @__PURE__ */ new WeakSet();
|
|
13211
|
+
var assertSeparateArguments = (method, ...args) => {
|
|
13212
|
+
if (args.some((a2) => !isString(a2))) {
|
|
13213
|
+
throw new TypeError(`${method}: pass language, namespace${method === "addResource" ? " and key" : ""} as separate strings; the dotted form ('en.translation.key') was removed in i18next v27`);
|
|
13214
|
+
}
|
|
13215
|
+
};
|
|
12804
13216
|
var ResourceStore = class extends EventEmitter {
|
|
12805
13217
|
constructor(data, options = {
|
|
12806
13218
|
ns: ["translation"],
|
|
12807
13219
|
defaultNS: "translation"
|
|
12808
|
-
}) {
|
|
13220
|
+
}, logger = baseLogger) {
|
|
12809
13221
|
super();
|
|
12810
13222
|
this.data = data || {};
|
|
12811
13223
|
this.options = options;
|
|
12812
|
-
this.logger =
|
|
13224
|
+
this.logger = logger.create("resourceStore");
|
|
12813
13225
|
if (this.options.keySeparator === void 0) {
|
|
12814
13226
|
this.options.keySeparator = ".";
|
|
12815
13227
|
}
|
|
@@ -12828,49 +13240,30 @@ var ResourceStore = class extends EventEmitter {
|
|
|
12828
13240
|
this.options.ns.splice(index, 1);
|
|
12829
13241
|
}
|
|
12830
13242
|
}
|
|
12831
|
-
deprecateDottedLng(method) {
|
|
12832
|
-
this.logger.once(method, "deprecate", `${method}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`);
|
|
12833
|
-
}
|
|
12834
13243
|
getResource(lng, ns, key, options = {}) {
|
|
12835
13244
|
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
12836
13245
|
const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
12837
|
-
|
|
12838
|
-
if (
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
path.push(...key);
|
|
12846
|
-
} else if (isString(key) && keySeparator) {
|
|
12847
|
-
path.push(...key.split(keySeparator));
|
|
12848
|
-
} else {
|
|
12849
|
-
path.push(key);
|
|
12850
|
-
}
|
|
13246
|
+
const path = [lng, ns];
|
|
13247
|
+
if (key) {
|
|
13248
|
+
if (Array.isArray(key)) {
|
|
13249
|
+
path.push(...key);
|
|
13250
|
+
} else if (isString(key) && keySeparator) {
|
|
13251
|
+
path.push(...key.split(keySeparator));
|
|
13252
|
+
} else {
|
|
13253
|
+
path.push(key);
|
|
12851
13254
|
}
|
|
12852
13255
|
}
|
|
12853
13256
|
const result = getPath(this.data, path);
|
|
12854
|
-
if (result == null && !ns && !key && lng.includes(".")) {
|
|
12855
|
-
lng = path[0];
|
|
12856
|
-
ns = path[1];
|
|
12857
|
-
key = path.slice(2).join(".");
|
|
12858
|
-
}
|
|
12859
13257
|
if (result != null || !ignoreJSONStructure || !isString(key)) return result;
|
|
12860
13258
|
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
12861
13259
|
}
|
|
12862
13260
|
addResource(lng, ns, key, value, options = {
|
|
12863
13261
|
silent: false
|
|
12864
13262
|
}) {
|
|
13263
|
+
assertSeparateArguments("addResource", lng, ns, key);
|
|
12865
13264
|
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
12866
13265
|
let path = [lng, ns];
|
|
12867
13266
|
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
12868
|
-
if (lng.includes(".")) {
|
|
12869
|
-
this.deprecateDottedLng("addResource");
|
|
12870
|
-
path = lng.split(".");
|
|
12871
|
-
value = ns;
|
|
12872
|
-
ns = path[1];
|
|
12873
|
-
}
|
|
12874
13267
|
this.addNamespaces(ns);
|
|
12875
13268
|
setPath(this.data, path, value);
|
|
12876
13269
|
if (!options.silent) this.emit("added", lng, ns, key, value);
|
|
@@ -12878,25 +13271,21 @@ var ResourceStore = class extends EventEmitter {
|
|
|
12878
13271
|
addResources(lng, ns, resources, options = {
|
|
12879
13272
|
silent: false
|
|
12880
13273
|
}) {
|
|
12881
|
-
|
|
12882
|
-
|
|
13274
|
+
assertSeparateArguments("addResources", lng, ns);
|
|
13275
|
+
Object.keys(resources || {}).forEach((m2) => {
|
|
13276
|
+
if (m2 === "__proto__" || m2 === "constructor") return;
|
|
13277
|
+
this.addResource(lng, ns, m2, resources[m2], {
|
|
12883
13278
|
silent: true
|
|
12884
13279
|
});
|
|
12885
|
-
}
|
|
13280
|
+
});
|
|
12886
13281
|
if (!options.silent) this.emit("added", lng, ns, resources);
|
|
12887
13282
|
}
|
|
12888
13283
|
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
12889
13284
|
silent: false,
|
|
12890
13285
|
skipCopy: false
|
|
12891
13286
|
}) {
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
this.deprecateDottedLng("addResourceBundle");
|
|
12895
|
-
path = lng.split(".");
|
|
12896
|
-
deep = resources;
|
|
12897
|
-
resources = ns;
|
|
12898
|
-
ns = path[1];
|
|
12899
|
-
}
|
|
13287
|
+
assertSeparateArguments("addResourceBundle", lng, ns);
|
|
13288
|
+
const path = [lng, ns];
|
|
12900
13289
|
this.addNamespaces(ns);
|
|
12901
13290
|
let pack = getPath(this.data, path) || {};
|
|
12902
13291
|
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
|
@@ -12943,18 +13332,6 @@ var ResourceStore = class extends EventEmitter {
|
|
|
12943
13332
|
return this.data;
|
|
12944
13333
|
}
|
|
12945
13334
|
};
|
|
12946
|
-
var postProcessor = {
|
|
12947
|
-
processors: {},
|
|
12948
|
-
addPostProcessor(module) {
|
|
12949
|
-
this.processors[module.name] = module;
|
|
12950
|
-
},
|
|
12951
|
-
handle(processors, value, key, options, translator) {
|
|
12952
|
-
processors.forEach((processor) => {
|
|
12953
|
-
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
|
12954
|
-
});
|
|
12955
|
-
return value;
|
|
12956
|
-
}
|
|
12957
|
-
};
|
|
12958
13335
|
var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
|
|
12959
13336
|
function createProxy() {
|
|
12960
13337
|
const state = [];
|
|
@@ -12973,7 +13350,7 @@ function keysFromSelector(selector, opts) {
|
|
|
12973
13350
|
const {
|
|
12974
13351
|
[PATH_KEY]: path
|
|
12975
13352
|
} = selector(createProxy());
|
|
12976
|
-
const keySeparator = opts?.keySeparator
|
|
13353
|
+
const keySeparator = opts?.keySeparator || ".";
|
|
12977
13354
|
const nsSeparator = opts?.nsSeparator ?? ":";
|
|
12978
13355
|
const strict = opts?.enableSelector === "strict";
|
|
12979
13356
|
if (path.length > 1 && nsSeparator) {
|
|
@@ -12992,12 +13369,12 @@ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" &
|
|
|
12992
13369
|
var Translator = class _Translator extends EventEmitter {
|
|
12993
13370
|
constructor(services, options = {}) {
|
|
12994
13371
|
super();
|
|
12995
|
-
copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "
|
|
13372
|
+
copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "postProcessors"], services, this);
|
|
12996
13373
|
this.options = options;
|
|
12997
13374
|
if (this.options.keySeparator === void 0) {
|
|
12998
13375
|
this.options.keySeparator = ".";
|
|
12999
13376
|
}
|
|
13000
|
-
this.logger = baseLogger.create("translator");
|
|
13377
|
+
this.logger = (services.logger || baseLogger).create("translator");
|
|
13001
13378
|
this.checkedLoadedFor = {};
|
|
13002
13379
|
}
|
|
13003
13380
|
changeLanguage(lng) {
|
|
@@ -13121,23 +13498,24 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13121
13498
|
}
|
|
13122
13499
|
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
13123
13500
|
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
resolved.res = r2;
|
|
13136
|
-
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
13137
|
-
return resolved;
|
|
13138
|
-
}
|
|
13139
|
-
return r2;
|
|
13501
|
+
const isObjectHit = handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl));
|
|
13502
|
+
const objectNotReturned = isObjectHit && !opt.returnObjects && !this.options.returnObjects;
|
|
13503
|
+
if (objectNotReturned && this.options.returnedObjectHandler) {
|
|
13504
|
+
const r2 = this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
|
13505
|
+
...opt,
|
|
13506
|
+
ns: namespaces
|
|
13507
|
+
});
|
|
13508
|
+
if (returnDetails) {
|
|
13509
|
+
resolved.res = r2;
|
|
13510
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
13511
|
+
return resolved;
|
|
13140
13512
|
}
|
|
13513
|
+
return r2;
|
|
13514
|
+
}
|
|
13515
|
+
if (objectNotReturned) {
|
|
13516
|
+
this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
13517
|
+
}
|
|
13518
|
+
if (isObjectHit && !objectNotReturned) {
|
|
13141
13519
|
if (keySeparator) {
|
|
13142
13520
|
const resTypeIsArray = Array.isArray(resForObjHndl);
|
|
13143
13521
|
const copy3 = resTypeIsArray ? [] : {};
|
|
@@ -13174,18 +13552,19 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13174
13552
|
} else {
|
|
13175
13553
|
let usedDefault = false;
|
|
13176
13554
|
let usedKey = false;
|
|
13177
|
-
if (
|
|
13555
|
+
if (objectNotReturned) res = void 0;
|
|
13556
|
+
if (!this.isValidLookup(res) && hasDefaultValue && !(objectNotReturned && shouldHandleAsObject(defaultValue))) {
|
|
13178
13557
|
usedDefault = true;
|
|
13179
13558
|
res = defaultValue;
|
|
13180
13559
|
}
|
|
13181
|
-
if (!this.isValidLookup(res)) {
|
|
13560
|
+
if (!this.isValidLookup(res) && !(usedDefault && res === "")) {
|
|
13182
13561
|
usedKey = true;
|
|
13183
13562
|
res = key;
|
|
13184
13563
|
}
|
|
13185
13564
|
const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
13186
13565
|
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
|
|
13187
13566
|
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
13188
|
-
if (usedKey || usedDefault || updateMissing) {
|
|
13567
|
+
if (!objectNotReturned && (usedKey || usedDefault || updateMissing)) {
|
|
13189
13568
|
this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
|
|
13190
13569
|
if (keySeparator) {
|
|
13191
13570
|
const fk = this.resolve(key, {
|
|
@@ -13293,18 +13672,21 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13293
13672
|
const postProcess = opt.postProcess || this.options.postProcess;
|
|
13294
13673
|
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
|
13295
13674
|
if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
|
|
13296
|
-
|
|
13297
|
-
if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
|
|
13298
|
-
this.logger.once(name, "deprecate", `postProcess: '${name}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`);
|
|
13299
|
-
}
|
|
13300
|
-
});
|
|
13301
|
-
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
13675
|
+
const ppOptions = this.options?.postProcessPassResolved ? {
|
|
13302
13676
|
i18nResolved: {
|
|
13303
13677
|
...resolved,
|
|
13304
13678
|
usedParams: this.getUsedParamsDetails(opt)
|
|
13305
13679
|
},
|
|
13306
13680
|
...opt
|
|
13307
|
-
} : opt
|
|
13681
|
+
} : opt;
|
|
13682
|
+
postProcessorNames.forEach((name) => {
|
|
13683
|
+
const processor = this.postProcessors?.[name];
|
|
13684
|
+
if (!processor) {
|
|
13685
|
+
this.logger.once(`postProcess:${name}`, "warn", `postProcess: '${name}' is not registered on this i18next instance; call use() with it on this instance`);
|
|
13686
|
+
return;
|
|
13687
|
+
}
|
|
13688
|
+
res = processor.process(res, key, ppOptions, this) ?? res;
|
|
13689
|
+
});
|
|
13308
13690
|
}
|
|
13309
13691
|
return res;
|
|
13310
13692
|
}
|
|
@@ -13433,14 +13815,16 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13433
13815
|
}
|
|
13434
13816
|
};
|
|
13435
13817
|
var LanguageUtil = class {
|
|
13436
|
-
constructor(options) {
|
|
13818
|
+
constructor(options, logger = baseLogger) {
|
|
13437
13819
|
this.options = options;
|
|
13438
13820
|
this.supportedLngs = this.options.supportedLngs || false;
|
|
13439
|
-
this.logger =
|
|
13821
|
+
this.logger = logger.create("languageUtils");
|
|
13440
13822
|
this.resolveHierarchyCache = {};
|
|
13823
|
+
this.formattedCodes = /* @__PURE__ */ new Map();
|
|
13441
13824
|
}
|
|
13442
13825
|
clearCache() {
|
|
13443
13826
|
this.resolveHierarchyCache = {};
|
|
13827
|
+
this.formattedCodes.clear();
|
|
13444
13828
|
}
|
|
13445
13829
|
getScriptPartFromCode(code) {
|
|
13446
13830
|
code = getCleanedCode(code);
|
|
@@ -13458,35 +13842,28 @@ var LanguageUtil = class {
|
|
|
13458
13842
|
return this.formatLanguageCode(p2[0]);
|
|
13459
13843
|
}
|
|
13460
13844
|
formatLanguageCode(code) {
|
|
13461
|
-
if (isString(code)
|
|
13462
|
-
|
|
13845
|
+
if (!isString(code)) return code;
|
|
13846
|
+
let formatted = this.formattedCodes.get(code);
|
|
13847
|
+
if (formatted !== void 0) return formatted;
|
|
13848
|
+
formatted = this.formatUncached(code);
|
|
13849
|
+
if (this.formattedCodes.size >= 1e3) this.formattedCodes.clear();
|
|
13850
|
+
this.formattedCodes.set(code, formatted);
|
|
13851
|
+
return formatted;
|
|
13852
|
+
}
|
|
13853
|
+
formatUncached(code) {
|
|
13854
|
+
const hasSubtags = code.includes("-");
|
|
13855
|
+
if (hasSubtags || this.options.cleanCode !== false) {
|
|
13856
|
+
let canonical;
|
|
13463
13857
|
try {
|
|
13464
|
-
|
|
13858
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
13465
13859
|
} catch (e) {
|
|
13466
13860
|
}
|
|
13467
|
-
if (
|
|
13468
|
-
|
|
13469
|
-
}
|
|
13470
|
-
if (formattedCode) return formattedCode;
|
|
13471
|
-
if (this.options.lowerCaseLng) {
|
|
13472
|
-
return code.toLowerCase();
|
|
13861
|
+
if (canonical && (hasSubtags || canonical.toLowerCase() === code.toLowerCase())) {
|
|
13862
|
+
return this.options.lowerCaseLng ? canonical.toLowerCase() : canonical;
|
|
13473
13863
|
}
|
|
13474
|
-
return code;
|
|
13864
|
+
if (canonical) return code.toLowerCase();
|
|
13475
13865
|
}
|
|
13476
|
-
|
|
13477
|
-
if (this.logger.debug && isString(code)) this.deprecateBareCode(code, formatted);
|
|
13478
|
-
return formatted;
|
|
13479
|
-
}
|
|
13480
|
-
deprecateBareCode(code, formatted) {
|
|
13481
|
-
let v27;
|
|
13482
|
-
try {
|
|
13483
|
-
v27 = Intl.getCanonicalLocales(code)[0];
|
|
13484
|
-
} catch (e) {
|
|
13485
|
-
return;
|
|
13486
|
-
}
|
|
13487
|
-
if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
|
|
13488
|
-
if (v27 === formatted) return;
|
|
13489
|
-
this.logger.once(code, "deprecate", `language code '${code}' is used as '${formatted}'; i18next v27 canonicalizes it to '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
|
|
13866
|
+
return this.options.lowerCaseLng || this.options.cleanCode && !hasSubtags ? code.toLowerCase() : code;
|
|
13490
13867
|
}
|
|
13491
13868
|
isSupportedCode(code) {
|
|
13492
13869
|
if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
|
|
@@ -13598,10 +13975,10 @@ var dummyRule = {
|
|
|
13598
13975
|
})
|
|
13599
13976
|
};
|
|
13600
13977
|
var PluralResolver = class {
|
|
13601
|
-
constructor(languageUtils, options = {}) {
|
|
13978
|
+
constructor(languageUtils, options = {}, logger = baseLogger) {
|
|
13602
13979
|
this.languageUtils = languageUtils;
|
|
13603
13980
|
this.options = options;
|
|
13604
|
-
this.logger =
|
|
13981
|
+
this.logger = logger.create("pluralResolver");
|
|
13605
13982
|
this.pluralRulesCache = {};
|
|
13606
13983
|
}
|
|
13607
13984
|
clearCache() {
|
|
@@ -13666,8 +14043,8 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
|
|
|
13666
14043
|
return path;
|
|
13667
14044
|
};
|
|
13668
14045
|
var Interpolator = class {
|
|
13669
|
-
constructor(options = {}) {
|
|
13670
|
-
this.logger =
|
|
14046
|
+
constructor(options = {}, logger = baseLogger) {
|
|
14047
|
+
this.logger = logger.create("interpolator");
|
|
13671
14048
|
this.options = options;
|
|
13672
14049
|
this.format = options?.interpolation?.format || ((value) => value);
|
|
13673
14050
|
this.init(options);
|
|
@@ -13681,39 +14058,26 @@ var Interpolator = class {
|
|
|
13681
14058
|
escapeValue,
|
|
13682
14059
|
useRawValueToEscape,
|
|
13683
14060
|
prefix: prefix2,
|
|
13684
|
-
prefixEscaped,
|
|
13685
14061
|
suffix,
|
|
13686
|
-
suffixEscaped,
|
|
13687
14062
|
formatSeparator,
|
|
13688
14063
|
unescapeSuffix,
|
|
13689
14064
|
unescapePrefix,
|
|
13690
14065
|
nestingPrefix,
|
|
13691
|
-
nestingPrefixEscaped,
|
|
13692
14066
|
nestingSuffix,
|
|
13693
|
-
nestingSuffixEscaped,
|
|
13694
14067
|
nestingOptionsSeparator,
|
|
13695
14068
|
maxReplaces,
|
|
13696
14069
|
alwaysFormat
|
|
13697
14070
|
} = options.interpolation;
|
|
13698
|
-
if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
|
|
13699
|
-
const names = Object.entries({
|
|
13700
|
-
prefixEscaped,
|
|
13701
|
-
suffixEscaped,
|
|
13702
|
-
nestingPrefixEscaped,
|
|
13703
|
-
nestingSuffixEscaped
|
|
13704
|
-
}).filter(([, v2]) => v2).map(([k2]) => k2);
|
|
13705
|
-
this.logger.once(names.join(), "deprecate", `interpolation.${names.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`);
|
|
13706
|
-
}
|
|
13707
14071
|
this.escape = escape$1 !== void 0 ? escape$1 : escape;
|
|
13708
14072
|
this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
|
|
13709
14073
|
this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
|
|
13710
|
-
this.prefix = prefix2 ? regexEscape(prefix2) :
|
|
13711
|
-
this.suffix = suffix ? regexEscape(suffix) :
|
|
14074
|
+
this.prefix = prefix2 ? regexEscape(prefix2) : "{{";
|
|
14075
|
+
this.suffix = suffix ? regexEscape(suffix) : "}}";
|
|
13712
14076
|
this.formatSeparator = formatSeparator || ",";
|
|
13713
14077
|
this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
|
|
13714
14078
|
this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
|
|
13715
|
-
this.nestingPrefix =
|
|
13716
|
-
this.nestingSuffix =
|
|
14079
|
+
this.nestingPrefix = regexEscape(nestingPrefix || "$t(");
|
|
14080
|
+
this.nestingSuffix = regexEscape(nestingSuffix || ")");
|
|
13717
14081
|
this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
|
|
13718
14082
|
this.maxReplaces = maxReplaces || 1e3;
|
|
13719
14083
|
this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
|
|
@@ -13769,13 +14133,7 @@ var Interpolator = class {
|
|
|
13769
14133
|
safeValue: (val) => val
|
|
13770
14134
|
}, {
|
|
13771
14135
|
regex: this.regexp,
|
|
13772
|
-
safeValue: (val) =>
|
|
13773
|
-
if (!this.escapeValue) return val;
|
|
13774
|
-
if (this.escape === escape && this.options?.interpolation?.escapeValue !== false && isString(val) && val.includes("/")) {
|
|
13775
|
-
this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is");
|
|
13776
|
-
}
|
|
13777
|
-
return this.escape(val);
|
|
13778
|
-
}
|
|
14136
|
+
safeValue: (val) => this.escapeValue ? this.escape(val) : val
|
|
13779
14137
|
}];
|
|
13780
14138
|
const unescapedValues = [];
|
|
13781
14139
|
let shift = 0;
|
|
@@ -13960,6 +14318,7 @@ var Formatter = class {
|
|
|
13960
14318
|
init(services, options = {
|
|
13961
14319
|
interpolation: {}
|
|
13962
14320
|
}) {
|
|
14321
|
+
if (services?.logger?.create) this.logger = services.logger.create("formatter");
|
|
13963
14322
|
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
13964
14323
|
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
13965
14324
|
this.formats = {
|
|
@@ -14055,7 +14414,7 @@ var Connector = class extends EventEmitter {
|
|
|
14055
14414
|
this.services = services;
|
|
14056
14415
|
this.languageUtils = services.languageUtils;
|
|
14057
14416
|
this.options = options;
|
|
14058
|
-
this.logger = baseLogger.create("backendConnector");
|
|
14417
|
+
this.logger = (services.logger || baseLogger).create("backendConnector");
|
|
14059
14418
|
this.waitingReads = [];
|
|
14060
14419
|
this.maxParallelReads = options.maxParallelReads || 10;
|
|
14061
14420
|
this.readingCalls = 0;
|
|
@@ -14215,15 +14574,10 @@ var Connector = class extends EventEmitter {
|
|
|
14215
14574
|
reload: true
|
|
14216
14575
|
}, callback);
|
|
14217
14576
|
}
|
|
14218
|
-
noticeDevFallback(lng) {
|
|
14219
|
-
if (lng !== "dev" || !this.devIsDefaultFallback) return;
|
|
14220
|
-
this.logger.once("dev", "warn", "language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior");
|
|
14221
|
-
}
|
|
14222
14577
|
loadOne(name, prefix2 = "") {
|
|
14223
14578
|
const s = name.split("|");
|
|
14224
14579
|
const lng = s[0];
|
|
14225
14580
|
const ns = s[1];
|
|
14226
|
-
this.noticeDevFallback(lng);
|
|
14227
14581
|
this.read(lng, ns, "read", void 0, void 0, (err, data) => {
|
|
14228
14582
|
if (err) this.logger.warn(`${prefix2}loading namespace ${ns} for language ${lng} failed`, err);
|
|
14229
14583
|
if (!err && data) this.logger.log(`${prefix2}loaded namespace ${ns} for language ${lng}`, data);
|
|
@@ -14238,7 +14592,6 @@ var Connector = class extends EventEmitter {
|
|
|
14238
14592
|
}
|
|
14239
14593
|
if (key === void 0 || key === null || key === "") return;
|
|
14240
14594
|
if (this.backend?.create) {
|
|
14241
|
-
languages?.forEach?.((l2) => this.noticeDevFallback(l2));
|
|
14242
14595
|
const opts = {
|
|
14243
14596
|
...options,
|
|
14244
14597
|
isUpdate
|
|
@@ -14273,7 +14626,7 @@ var get = () => ({
|
|
|
14273
14626
|
initAsync: true,
|
|
14274
14627
|
ns: ["translation"],
|
|
14275
14628
|
defaultNS: ["translation"],
|
|
14276
|
-
fallbackLng:
|
|
14629
|
+
fallbackLng: false,
|
|
14277
14630
|
fallbackNS: false,
|
|
14278
14631
|
supportedLngs: false,
|
|
14279
14632
|
nonExplicitSupportedLngs: false,
|
|
@@ -14294,7 +14647,7 @@ var get = () => ({
|
|
|
14294
14647
|
postProcess: false,
|
|
14295
14648
|
postProcessPassResolved: false,
|
|
14296
14649
|
returnNull: false,
|
|
14297
|
-
returnEmptyString:
|
|
14650
|
+
returnEmptyString: false,
|
|
14298
14651
|
returnObjects: false,
|
|
14299
14652
|
joinArrays: false,
|
|
14300
14653
|
returnedObjectHandler: false,
|
|
@@ -14339,7 +14692,39 @@ var transformOptions = (options) => {
|
|
|
14339
14692
|
};
|
|
14340
14693
|
var noop = () => {
|
|
14341
14694
|
};
|
|
14342
|
-
var
|
|
14695
|
+
var withDefaults = (options) => {
|
|
14696
|
+
const defOpts = get();
|
|
14697
|
+
const merged = {
|
|
14698
|
+
...defOpts,
|
|
14699
|
+
...options
|
|
14700
|
+
};
|
|
14701
|
+
merged.interpolation = {
|
|
14702
|
+
...defOpts.interpolation,
|
|
14703
|
+
...options.interpolation
|
|
14704
|
+
};
|
|
14705
|
+
if (typeof merged.overloadTranslationOptionHandler !== "function") {
|
|
14706
|
+
merged.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
|
|
14707
|
+
}
|
|
14708
|
+
return merged;
|
|
14709
|
+
};
|
|
14710
|
+
var configuredLanguageCodes = (options) => {
|
|
14711
|
+
const codes = [].concat(options.supportedLngs || [], options.preload || []);
|
|
14712
|
+
codes.push(...Object.keys(options.resources || {}));
|
|
14713
|
+
const fallbackLng = options.fallbackLng;
|
|
14714
|
+
if (isString(fallbackLng) || Array.isArray(fallbackLng)) codes.push(...[].concat(fallbackLng));
|
|
14715
|
+
else if (fallbackLng && typeof fallbackLng === "object") {
|
|
14716
|
+
Object.keys(fallbackLng).forEach((code) => {
|
|
14717
|
+
if (code !== "default") codes.push(code);
|
|
14718
|
+
codes.push(...[].concat(fallbackLng[code]));
|
|
14719
|
+
});
|
|
14720
|
+
}
|
|
14721
|
+
return codes;
|
|
14722
|
+
};
|
|
14723
|
+
var isRefusedLanguageCode = (i18n2, code) => {
|
|
14724
|
+
if (!isString(code) || isSafeLanguageCode(code) || i18n2.configuredLngs?.has(code)) return false;
|
|
14725
|
+
i18n2.logger.once(`lng:${code}`, "warn", `refused the language code '${code.slice(0, 64)}' from lng, changeLanguage(), the language detector or loadLanguages(): it is not configured and has other characters than letters, digits, '-', '_', '@' and '.' (or '..', or more than 128). List it in supportedLngs to use it`);
|
|
14726
|
+
return true;
|
|
14727
|
+
};
|
|
14343
14728
|
var bindMemberFunctions = (inst) => {
|
|
14344
14729
|
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
14345
14730
|
mems.forEach((mem) => {
|
|
@@ -14351,17 +14736,18 @@ var bindMemberFunctions = (inst) => {
|
|
|
14351
14736
|
var I18n = class _I18n extends EventEmitter {
|
|
14352
14737
|
constructor(options = {}, callback) {
|
|
14353
14738
|
super();
|
|
14354
|
-
this.
|
|
14739
|
+
this.userOptions = transformOptions(options);
|
|
14740
|
+
this.options = withDefaults(this.userOptions);
|
|
14355
14741
|
this.services = {
|
|
14356
|
-
|
|
14742
|
+
postProcessors: /* @__PURE__ */ Object.create(null)
|
|
14357
14743
|
};
|
|
14358
|
-
this.logger =
|
|
14744
|
+
this.logger = new Logger(null, this.options);
|
|
14359
14745
|
this.modules = {
|
|
14360
14746
|
external: []
|
|
14361
14747
|
};
|
|
14362
14748
|
bindMemberFunctions(this);
|
|
14363
14749
|
if (callback && !this.isInitialized && !options.isClone) {
|
|
14364
|
-
if (!this.
|
|
14750
|
+
if (!this.userOptions.initAsync) {
|
|
14365
14751
|
this.init(options, callback);
|
|
14366
14752
|
return this;
|
|
14367
14753
|
}
|
|
@@ -14383,25 +14769,23 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14383
14769
|
options.defaultNS = options.ns[0];
|
|
14384
14770
|
}
|
|
14385
14771
|
}
|
|
14386
|
-
|
|
14387
|
-
const
|
|
14388
|
-
|
|
14389
|
-
...
|
|
14390
|
-
...this.options,
|
|
14391
|
-
...transformOptions(options)
|
|
14392
|
-
};
|
|
14393
|
-
this.options.interpolation = {
|
|
14394
|
-
...defOpts.interpolation,
|
|
14395
|
-
...this.options.interpolation
|
|
14772
|
+
transformOptions(options);
|
|
14773
|
+
const userOptions = {
|
|
14774
|
+
...this.userOptions,
|
|
14775
|
+
...options
|
|
14396
14776
|
};
|
|
14397
|
-
|
|
14398
|
-
this.options
|
|
14777
|
+
this.options = withDefaults({
|
|
14778
|
+
...this.options,
|
|
14779
|
+
...options
|
|
14780
|
+
});
|
|
14781
|
+
if (userOptions.keySeparator !== void 0) {
|
|
14782
|
+
this.options.userDefinedKeySeparator = userOptions.keySeparator;
|
|
14399
14783
|
}
|
|
14400
|
-
if (
|
|
14401
|
-
this.options.userDefinedNsSeparator =
|
|
14784
|
+
if (userOptions.nsSeparator !== void 0) {
|
|
14785
|
+
this.options.userDefinedNsSeparator = userOptions.nsSeparator;
|
|
14402
14786
|
}
|
|
14403
|
-
if (
|
|
14404
|
-
this.
|
|
14787
|
+
if (!this.options.isClone) {
|
|
14788
|
+
this.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(userOptions)]);
|
|
14405
14789
|
}
|
|
14406
14790
|
const createClassOnDemand = (ClassOrObject) => {
|
|
14407
14791
|
if (!ClassOrObject) return null;
|
|
@@ -14409,15 +14793,10 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14409
14793
|
return ClassOrObject;
|
|
14410
14794
|
};
|
|
14411
14795
|
if (!this.options.isClone) {
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
if (this.modules.logger) {
|
|
14417
|
-
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
14418
|
-
} else {
|
|
14419
|
-
baseLogger.init(null, this.options);
|
|
14420
|
-
}
|
|
14796
|
+
this.logger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
14797
|
+
const {
|
|
14798
|
+
logger
|
|
14799
|
+
} = this;
|
|
14421
14800
|
this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
|
|
14422
14801
|
this.pendingWarnings = void 0;
|
|
14423
14802
|
let formatter;
|
|
@@ -14426,27 +14805,26 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14426
14805
|
} else {
|
|
14427
14806
|
formatter = Formatter;
|
|
14428
14807
|
}
|
|
14429
|
-
const lu = new LanguageUtil(this.options);
|
|
14430
|
-
this.store = new ResourceStore(this.options.resources, this.options);
|
|
14808
|
+
const lu = new LanguageUtil(this.options, logger);
|
|
14809
|
+
this.store = new ResourceStore(this.options.resources, this.options, logger);
|
|
14431
14810
|
const s = this.services;
|
|
14432
|
-
s.logger =
|
|
14811
|
+
s.logger = logger;
|
|
14433
14812
|
s.resourceStore = this.store;
|
|
14434
14813
|
s.languageUtils = lu;
|
|
14435
14814
|
s.pluralResolver = new PluralResolver(lu, {
|
|
14436
14815
|
prepend: this.options.pluralSeparator
|
|
14437
|
-
});
|
|
14816
|
+
}, logger);
|
|
14438
14817
|
if (formatter) {
|
|
14439
14818
|
s.formatter = createClassOnDemand(formatter);
|
|
14440
14819
|
if (s.formatter.init) s.formatter.init(s, this.options);
|
|
14441
14820
|
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
14442
14821
|
}
|
|
14443
|
-
s.interpolator = new Interpolator(this.options);
|
|
14822
|
+
s.interpolator = new Interpolator(this.options, logger);
|
|
14444
14823
|
s.utils = {
|
|
14445
14824
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
|
|
14446
14825
|
reloadResources: this.reloadResources.bind(this)
|
|
14447
14826
|
};
|
|
14448
14827
|
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
14449
|
-
s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
|
|
14450
14828
|
s.backendConnector.on("*", (event, ...args) => {
|
|
14451
14829
|
this.emit(event, ...args);
|
|
14452
14830
|
});
|
|
@@ -14587,8 +14965,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14587
14965
|
setModule("i18nFormat");
|
|
14588
14966
|
}
|
|
14589
14967
|
if (module.type === "postProcessor") {
|
|
14590
|
-
|
|
14591
|
-
this.services.ownPostProcessors?.add(module.name);
|
|
14968
|
+
this.services.postProcessors[module.name] = module;
|
|
14592
14969
|
}
|
|
14593
14970
|
if (module.type === "formatter") {
|
|
14594
14971
|
setModule("formatter");
|
|
@@ -14663,14 +15040,16 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14663
15040
|
};
|
|
14664
15041
|
const setLng = (lngs) => {
|
|
14665
15042
|
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
14666
|
-
const
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
}
|
|
15043
|
+
const {
|
|
15044
|
+
supportedLngs
|
|
15045
|
+
} = this.options;
|
|
15046
|
+
if (lngs && !supportedLngs) {
|
|
15047
|
+
const accepted = [].concat(lngs).filter((c2) => !isRefusedLanguageCode(this, c2));
|
|
15048
|
+
if (accepted.length < [].concat(lngs).length) lngs = accepted;
|
|
14673
15049
|
}
|
|
15050
|
+
const fl = isString(lngs) ? lngs : lngs && lngs[0];
|
|
15051
|
+
let l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
|
|
15052
|
+
if (supportedLngs && isRefusedLanguageCode(this, l2)) l2 = this.services.languageUtils.getBestMatchFromCodes([]);
|
|
14674
15053
|
if (l2) {
|
|
14675
15054
|
if (!this.language) {
|
|
14676
15055
|
setLngProps(l2);
|
|
@@ -14785,7 +15164,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14785
15164
|
}
|
|
14786
15165
|
loadNamespaces(ns, callback) {
|
|
14787
15166
|
const deferred = defer();
|
|
14788
|
-
if (!this.options.ns) {
|
|
15167
|
+
if (!this.options.ns || !this.services.backendConnector) {
|
|
14789
15168
|
if (callback) callback();
|
|
14790
15169
|
return Promise.resolve();
|
|
14791
15170
|
}
|
|
@@ -14803,7 +15182,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14803
15182
|
const deferred = defer();
|
|
14804
15183
|
if (isString(lngs)) lngs = [lngs];
|
|
14805
15184
|
const preloaded = this.options.preload || [];
|
|
14806
|
-
const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
|
|
15185
|
+
const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && !isRefusedLanguageCode(this, lng) && this.services.languageUtils.isSupportedCode(lng));
|
|
14807
15186
|
if (!newLngs.length) {
|
|
14808
15187
|
if (callback) callback();
|
|
14809
15188
|
return Promise.resolve();
|
|
@@ -14853,16 +15232,15 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14853
15232
|
}
|
|
14854
15233
|
};
|
|
14855
15234
|
const clone = new _I18n(mergedOptions);
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
}
|
|
14859
|
-
const membersToCopy = ["store", "services", "language"];
|
|
15235
|
+
clone.logger = options.debug !== void 0 || options.prefix !== void 0 ? this.logger.clone(options) : this.logger;
|
|
15236
|
+
const membersToCopy = ["store", "language"];
|
|
14860
15237
|
membersToCopy.forEach((m2) => {
|
|
14861
15238
|
clone[m2] = this[m2];
|
|
14862
15239
|
});
|
|
14863
15240
|
clone.services = {
|
|
14864
15241
|
...this.services
|
|
14865
15242
|
};
|
|
15243
|
+
clone.services.postProcessors = Object.create(this.services.postProcessors);
|
|
14866
15244
|
clone.services.utils = {
|
|
14867
15245
|
...clone.services.utils,
|
|
14868
15246
|
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
|
|
@@ -14879,7 +15257,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14879
15257
|
return copied;
|
|
14880
15258
|
};
|
|
14881
15259
|
const clonedData = copyData(this.store.data);
|
|
14882
|
-
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
15260
|
+
clone.store = new ResourceStore(clonedData, mergedOptions, this.logger);
|
|
14883
15261
|
clone.services.resourceStore = clone.store;
|
|
14884
15262
|
}
|
|
14885
15263
|
if (options.interpolation) {
|
|
@@ -14893,8 +15271,9 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14893
15271
|
...mergedOptions,
|
|
14894
15272
|
interpolation: mergedInterpolation
|
|
14895
15273
|
};
|
|
14896
|
-
clone.services.interpolator = new Interpolator(mergedForInterpolator);
|
|
15274
|
+
clone.services.interpolator = new Interpolator(mergedForInterpolator, this.logger);
|
|
14897
15275
|
}
|
|
15276
|
+
clone.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(options)]);
|
|
14898
15277
|
clone.translator = new Translator(clone.services, mergedOptions);
|
|
14899
15278
|
clone.translator.on("*", (event, ...args) => {
|
|
14900
15279
|
clone.emit(event, ...args);
|
|
@@ -16922,6 +17301,25 @@ var createKeyboardExecutionHandler = (fn) => {
|
|
|
16922
17301
|
return handler;
|
|
16923
17302
|
};
|
|
16924
17303
|
|
|
17304
|
+
// src/utils/invoiceLink.ts
|
|
17305
|
+
function openInvoiceLink(event, storedUrl, fetchUrl) {
|
|
17306
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
17307
|
+
return Promise.resolve();
|
|
17308
|
+
}
|
|
17309
|
+
const tab = window.open("", "_blank");
|
|
17310
|
+
if (tab === null) {
|
|
17311
|
+
return Promise.resolve();
|
|
17312
|
+
}
|
|
17313
|
+
event.preventDefault();
|
|
17314
|
+
tab.opener = null;
|
|
17315
|
+
return fetchUrl().then(
|
|
17316
|
+
(url) => url || storedUrl,
|
|
17317
|
+
() => storedUrl
|
|
17318
|
+
).then((url) => {
|
|
17319
|
+
tab.location.href = url;
|
|
17320
|
+
});
|
|
17321
|
+
}
|
|
17322
|
+
|
|
16925
17323
|
// src/utils/markdown.tsx
|
|
16926
17324
|
import { Fragment } from "react";
|
|
16927
17325
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -17674,7 +18072,7 @@ var reducer = (state, action) => {
|
|
|
17674
18072
|
// src/context/EmbedProvider.tsx
|
|
17675
18073
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
17676
18074
|
var getCustomHeaders = (sessionId) => ({
|
|
17677
|
-
"X-Schematic-Components-Version": "2.
|
|
18075
|
+
"X-Schematic-Components-Version": "2.38.0",
|
|
17678
18076
|
"X-Schematic-Session-ID": sessionId
|
|
17679
18077
|
});
|
|
17680
18078
|
var normalizeCurrencyFilter = (filter2) => {
|
|
@@ -18062,6 +18460,12 @@ var EmbedProvider = ({
|
|
|
18062
18460
|
() => (0, import_debounce2.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, LEADING_DEBOUNCE_SETTINGS),
|
|
18063
18461
|
[listInvoices]
|
|
18064
18462
|
);
|
|
18463
|
+
const getInvoiceLink = useCallback2(
|
|
18464
|
+
async (billingInvoiceId) => {
|
|
18465
|
+
return checkoutApi?.getInvoiceLink({ billingInvoiceId });
|
|
18466
|
+
},
|
|
18467
|
+
[checkoutApi]
|
|
18468
|
+
);
|
|
18065
18469
|
const getCreditUsageByUser = useCallback2(
|
|
18066
18470
|
async (billingCreditId, limit) => {
|
|
18067
18471
|
return checkoutApi?.getCreditUsageByUser({ billingCreditId, limit });
|
|
@@ -18256,6 +18660,7 @@ var EmbedProvider = ({
|
|
|
18256
18660
|
getUpcomingInvoice: debouncedGetUpcomingInvoice,
|
|
18257
18661
|
getCustomerBalance: debouncedGetCustomerBalance,
|
|
18258
18662
|
listInvoices: debouncedListInvoices,
|
|
18663
|
+
getInvoiceLink,
|
|
18259
18664
|
getCreditUsageByUser: debouncedGetCreditUsageByUser,
|
|
18260
18665
|
getFeatureUsageByUser: debouncedGetFeatureUsageByUser,
|
|
18261
18666
|
finishCheckout,
|
|
@@ -27266,12 +27671,13 @@ function formatInvoices(invoices, locale, options) {
|
|
|
27266
27671
|
const dateA = a2.dueDate ?? a2.createdAt;
|
|
27267
27672
|
const dateB = b2.dueDate ?? b2.createdAt;
|
|
27268
27673
|
return +dateB - +dateA;
|
|
27269
|
-
}).map(({ amountDue, dueDate, createdAt, url, currency }) => {
|
|
27674
|
+
}).map(({ amountDue, dueDate, createdAt, id, url, currency }) => {
|
|
27270
27675
|
const formatted = formatCurrency(Math.abs(amountDue), {
|
|
27271
27676
|
locale,
|
|
27272
27677
|
currency
|
|
27273
27678
|
});
|
|
27274
27679
|
return {
|
|
27680
|
+
id,
|
|
27275
27681
|
amount: amountDue < 0 ? `(${formatted})` : formatted,
|
|
27276
27682
|
amountDue,
|
|
27277
27683
|
date: toPrettyDate(dueDate ?? createdAt, { locale }),
|
|
@@ -27282,7 +27688,7 @@ function formatInvoices(invoices, locale, options) {
|
|
|
27282
27688
|
var Invoices = forwardRef11(({ className, ...rest }, ref) => {
|
|
27283
27689
|
const props = resolveDesignProps3(rest);
|
|
27284
27690
|
const { t: t3, locale } = useTranslation();
|
|
27285
|
-
const { data, listInvoices, settings } = useEmbed();
|
|
27691
|
+
const { data, getInvoiceLink, listInvoices, settings } = useEmbed();
|
|
27286
27692
|
const [isLoading, setIsLoading] = useState16(false);
|
|
27287
27693
|
const [error, setError] = useState16();
|
|
27288
27694
|
const [rawInvoices, setInvoices] = useState16(
|
|
@@ -27359,7 +27765,7 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
|
|
|
27359
27765
|
props.header.isVisible && /* @__PURE__ */ jsx54(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsx54(Text, { display: props.header.fontStyle, children: t3("Invoices") }) }),
|
|
27360
27766
|
invoices.length > 0 ? /* @__PURE__ */ jsxs39(Fragment20, { children: [
|
|
27361
27767
|
/* @__PURE__ */ jsx54(Flex, { $flexDirection: "column", $gap: "0.5rem", children: visibleInvoices.items.map(
|
|
27362
|
-
({ date, amount, amountDue, url }, index) => {
|
|
27768
|
+
({ id, date, amount, amountDue, url }, index) => {
|
|
27363
27769
|
return /* @__PURE__ */ jsxs39(
|
|
27364
27770
|
Flex,
|
|
27365
27771
|
{
|
|
@@ -27370,11 +27776,18 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
|
|
|
27370
27776
|
Text,
|
|
27371
27777
|
{
|
|
27372
27778
|
display: props.date.fontStyle,
|
|
27373
|
-
...url && {
|
|
27779
|
+
...id && url && {
|
|
27374
27780
|
as: "a",
|
|
27375
27781
|
href: url,
|
|
27376
27782
|
target: "_blank",
|
|
27377
|
-
rel: "noreferrer"
|
|
27783
|
+
rel: "noreferrer",
|
|
27784
|
+
onClick: (event) => {
|
|
27785
|
+
void openInvoiceLink(
|
|
27786
|
+
event,
|
|
27787
|
+
url,
|
|
27788
|
+
async () => (await getInvoiceLink(id))?.data.url
|
|
27789
|
+
);
|
|
27790
|
+
}
|
|
27378
27791
|
},
|
|
27379
27792
|
$color: url ? settings.theme.typography.link.color : settings.theme.typography.text.color,
|
|
27380
27793
|
children: date
|