@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,
|
|
@@ -8315,6 +8316,84 @@ function CreateCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8315
8316
|
};
|
|
8316
8317
|
}
|
|
8317
8318
|
|
|
8319
|
+
// src/api/checkoutexternal/models/CreditSpendWindowUnit.ts
|
|
8320
|
+
function CreditSpendWindowUnitFromJSON(json) {
|
|
8321
|
+
return CreditSpendWindowUnitFromJSONTyped(json, false);
|
|
8322
|
+
}
|
|
8323
|
+
function CreditSpendWindowUnitFromJSONTyped(json, ignoreDiscriminator) {
|
|
8324
|
+
return json;
|
|
8325
|
+
}
|
|
8326
|
+
function CreditSpendWindowUnitToJSON(value) {
|
|
8327
|
+
return value;
|
|
8328
|
+
}
|
|
8329
|
+
|
|
8330
|
+
// src/api/checkoutexternal/models/CreateCompanySpendPolicyRequestBody.ts
|
|
8331
|
+
function CreateCompanySpendPolicyRequestBodyToJSON(json) {
|
|
8332
|
+
return CreateCompanySpendPolicyRequestBodyToJSONTyped(json, false);
|
|
8333
|
+
}
|
|
8334
|
+
function CreateCompanySpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
8335
|
+
if (value == null) {
|
|
8336
|
+
return value;
|
|
8337
|
+
}
|
|
8338
|
+
return {
|
|
8339
|
+
billing_credit_id: value["billingCreditId"],
|
|
8340
|
+
label: value["label"],
|
|
8341
|
+
max_per_draw: value["maxPerDraw"],
|
|
8342
|
+
user_id: value["userId"],
|
|
8343
|
+
window_amount: value["windowAmount"],
|
|
8344
|
+
window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
|
|
8345
|
+
};
|
|
8346
|
+
}
|
|
8347
|
+
|
|
8348
|
+
// src/api/checkoutexternal/models/CreditSpendPolicyScope.ts
|
|
8349
|
+
function CreditSpendPolicyScopeFromJSON(json) {
|
|
8350
|
+
return CreditSpendPolicyScopeFromJSONTyped(json, false);
|
|
8351
|
+
}
|
|
8352
|
+
function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
|
|
8353
|
+
return json;
|
|
8354
|
+
}
|
|
8355
|
+
|
|
8356
|
+
// src/api/checkoutexternal/models/CreditSpendPolicyResponseData.ts
|
|
8357
|
+
function CreditSpendPolicyResponseDataFromJSON(json) {
|
|
8358
|
+
return CreditSpendPolicyResponseDataFromJSONTyped(json, false);
|
|
8359
|
+
}
|
|
8360
|
+
function CreditSpendPolicyResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
8361
|
+
if (json == null) {
|
|
8362
|
+
return json;
|
|
8363
|
+
}
|
|
8364
|
+
return {
|
|
8365
|
+
billingCreditId: json["billing_credit_id"],
|
|
8366
|
+
companyId: json["company_id"] == null ? void 0 : json["company_id"],
|
|
8367
|
+
consumed: json["consumed"] == null ? void 0 : json["consumed"],
|
|
8368
|
+
createdAt: new Date(json["created_at"]),
|
|
8369
|
+
headroom: json["headroom"] == null ? void 0 : json["headroom"],
|
|
8370
|
+
id: json["id"],
|
|
8371
|
+
label: json["label"] == null ? void 0 : json["label"],
|
|
8372
|
+
maxPerDraw: json["max_per_draw"] == null ? void 0 : json["max_per_draw"],
|
|
8373
|
+
resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
|
|
8374
|
+
scopeType: CreditSpendPolicyScopeFromJSON(json["scope_type"]),
|
|
8375
|
+
updatedAt: new Date(json["updated_at"]),
|
|
8376
|
+
userId: json["user_id"] == null ? void 0 : json["user_id"],
|
|
8377
|
+
windowAmount: json["window_amount"] == null ? void 0 : json["window_amount"],
|
|
8378
|
+
windowCount: json["window_count"],
|
|
8379
|
+
windowUnit: json["window_unit"] == null ? void 0 : CreditSpendWindowUnitFromJSON(json["window_unit"])
|
|
8380
|
+
};
|
|
8381
|
+
}
|
|
8382
|
+
|
|
8383
|
+
// src/api/checkoutexternal/models/CreateCompanySpendPolicyResponse.ts
|
|
8384
|
+
function CreateCompanySpendPolicyResponseFromJSON(json) {
|
|
8385
|
+
return CreateCompanySpendPolicyResponseFromJSONTyped(json, false);
|
|
8386
|
+
}
|
|
8387
|
+
function CreateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8388
|
+
if (json == null) {
|
|
8389
|
+
return json;
|
|
8390
|
+
}
|
|
8391
|
+
return {
|
|
8392
|
+
data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
|
|
8393
|
+
params: json["params"]
|
|
8394
|
+
};
|
|
8395
|
+
}
|
|
8396
|
+
|
|
8318
8397
|
// src/api/checkoutexternal/models/SetupIntentResponseData.ts
|
|
8319
8398
|
function SetupIntentResponseDataFromJSON(json) {
|
|
8320
8399
|
return SetupIntentResponseDataFromJSONTyped(json, false);
|
|
@@ -8403,6 +8482,20 @@ function CreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8403
8482
|
};
|
|
8404
8483
|
}
|
|
8405
8484
|
|
|
8485
|
+
// src/api/checkoutexternal/models/DeleteCompanySpendPolicyResponse.ts
|
|
8486
|
+
function DeleteCompanySpendPolicyResponseFromJSON(json) {
|
|
8487
|
+
return DeleteCompanySpendPolicyResponseFromJSONTyped(json, false);
|
|
8488
|
+
}
|
|
8489
|
+
function DeleteCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8490
|
+
if (json == null) {
|
|
8491
|
+
return json;
|
|
8492
|
+
}
|
|
8493
|
+
return {
|
|
8494
|
+
data: DeleteResponseFromJSON(json["data"]),
|
|
8495
|
+
params: json["params"]
|
|
8496
|
+
};
|
|
8497
|
+
}
|
|
8498
|
+
|
|
8406
8499
|
// src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
|
|
8407
8500
|
function DeletePaymentMethodResponseFromJSON(json) {
|
|
8408
8501
|
return DeletePaymentMethodResponseFromJSONTyped(json, false);
|
|
@@ -8777,6 +8870,34 @@ function GetFeatureUsageByUserResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8777
8870
|
};
|
|
8778
8871
|
}
|
|
8779
8872
|
|
|
8873
|
+
// src/api/checkoutexternal/models/InvoiceLink.ts
|
|
8874
|
+
function InvoiceLinkFromJSON(json) {
|
|
8875
|
+
return InvoiceLinkFromJSONTyped(json, false);
|
|
8876
|
+
}
|
|
8877
|
+
function InvoiceLinkFromJSONTyped(json, ignoreDiscriminator) {
|
|
8878
|
+
if (json == null) {
|
|
8879
|
+
return json;
|
|
8880
|
+
}
|
|
8881
|
+
return {
|
|
8882
|
+
id: json["id"],
|
|
8883
|
+
url: json["url"]
|
|
8884
|
+
};
|
|
8885
|
+
}
|
|
8886
|
+
|
|
8887
|
+
// src/api/checkoutexternal/models/GetInvoiceLinkResponse.ts
|
|
8888
|
+
function GetInvoiceLinkResponseFromJSON(json) {
|
|
8889
|
+
return GetInvoiceLinkResponseFromJSONTyped(json, false);
|
|
8890
|
+
}
|
|
8891
|
+
function GetInvoiceLinkResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
8892
|
+
if (json == null) {
|
|
8893
|
+
return json;
|
|
8894
|
+
}
|
|
8895
|
+
return {
|
|
8896
|
+
data: InvoiceLinkFromJSON(json["data"]),
|
|
8897
|
+
params: json["params"]
|
|
8898
|
+
};
|
|
8899
|
+
}
|
|
8900
|
+
|
|
8780
8901
|
// src/api/checkoutexternal/models/GetSetupIntentResponse.ts
|
|
8781
8902
|
function GetSetupIntentResponseFromJSON(json) {
|
|
8782
8903
|
return GetSetupIntentResponseFromJSONTyped(json, false);
|
|
@@ -8890,6 +9011,35 @@ function ListCheckoutsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
8890
9011
|
};
|
|
8891
9012
|
}
|
|
8892
9013
|
|
|
9014
|
+
// src/api/checkoutexternal/models/ListCompanySpendPoliciesParams.ts
|
|
9015
|
+
function ListCompanySpendPoliciesParamsFromJSON(json) {
|
|
9016
|
+
return ListCompanySpendPoliciesParamsFromJSONTyped(json, false);
|
|
9017
|
+
}
|
|
9018
|
+
function ListCompanySpendPoliciesParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
9019
|
+
if (json == null) {
|
|
9020
|
+
return json;
|
|
9021
|
+
}
|
|
9022
|
+
return {
|
|
9023
|
+
billingCreditId: json["billing_credit_id"] == null ? void 0 : json["billing_credit_id"]
|
|
9024
|
+
};
|
|
9025
|
+
}
|
|
9026
|
+
|
|
9027
|
+
// src/api/checkoutexternal/models/ListCompanySpendPoliciesResponse.ts
|
|
9028
|
+
function ListCompanySpendPoliciesResponseFromJSON(json) {
|
|
9029
|
+
return ListCompanySpendPoliciesResponseFromJSONTyped(json, false);
|
|
9030
|
+
}
|
|
9031
|
+
function ListCompanySpendPoliciesResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
9032
|
+
if (json == null) {
|
|
9033
|
+
return json;
|
|
9034
|
+
}
|
|
9035
|
+
return {
|
|
9036
|
+
data: json["data"].map(
|
|
9037
|
+
CreditSpendPolicyResponseDataFromJSON
|
|
9038
|
+
),
|
|
9039
|
+
params: ListCompanySpendPoliciesParamsFromJSON(json["params"])
|
|
9040
|
+
};
|
|
9041
|
+
}
|
|
9042
|
+
|
|
8893
9043
|
// src/api/checkoutexternal/models/ListInvoicesParams.ts
|
|
8894
9044
|
function ListInvoicesParamsFromJSON(json) {
|
|
8895
9045
|
return ListInvoicesParamsFromJSONTyped(json, false);
|
|
@@ -9220,6 +9370,36 @@ function UpdateCheckoutTaxIDResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
9220
9370
|
};
|
|
9221
9371
|
}
|
|
9222
9372
|
|
|
9373
|
+
// src/api/checkoutexternal/models/UpdateCompanySpendPolicyResponse.ts
|
|
9374
|
+
function UpdateCompanySpendPolicyResponseFromJSON(json) {
|
|
9375
|
+
return UpdateCompanySpendPolicyResponseFromJSONTyped(json, false);
|
|
9376
|
+
}
|
|
9377
|
+
function UpdateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
9378
|
+
if (json == null) {
|
|
9379
|
+
return json;
|
|
9380
|
+
}
|
|
9381
|
+
return {
|
|
9382
|
+
data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
|
|
9383
|
+
params: json["params"]
|
|
9384
|
+
};
|
|
9385
|
+
}
|
|
9386
|
+
|
|
9387
|
+
// src/api/checkoutexternal/models/UpdateCreditSpendPolicyRequestBody.ts
|
|
9388
|
+
function UpdateCreditSpendPolicyRequestBodyToJSON(json) {
|
|
9389
|
+
return UpdateCreditSpendPolicyRequestBodyToJSONTyped(json, false);
|
|
9390
|
+
}
|
|
9391
|
+
function UpdateCreditSpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
|
|
9392
|
+
if (value == null) {
|
|
9393
|
+
return value;
|
|
9394
|
+
}
|
|
9395
|
+
return {
|
|
9396
|
+
label: value["label"],
|
|
9397
|
+
max_per_draw: value["maxPerDraw"],
|
|
9398
|
+
window_amount: value["windowAmount"],
|
|
9399
|
+
window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
|
|
9400
|
+
};
|
|
9401
|
+
}
|
|
9402
|
+
|
|
9223
9403
|
// src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
|
|
9224
9404
|
function UpdatePaymentMethodRequestBodyToJSON(json) {
|
|
9225
9405
|
return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
|
|
@@ -9377,6 +9557,51 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
9377
9557
|
);
|
|
9378
9558
|
return await response.value();
|
|
9379
9559
|
}
|
|
9560
|
+
/**
|
|
9561
|
+
* Create company spend policy
|
|
9562
|
+
*/
|
|
9563
|
+
async createCompanySpendPolicyRaw(requestParameters, initOverrides) {
|
|
9564
|
+
if (requestParameters["createCompanySpendPolicyRequestBody"] == null) {
|
|
9565
|
+
throw new RequiredError(
|
|
9566
|
+
"createCompanySpendPolicyRequestBody",
|
|
9567
|
+
'Required parameter "createCompanySpendPolicyRequestBody" was null or undefined when calling createCompanySpendPolicy().'
|
|
9568
|
+
);
|
|
9569
|
+
}
|
|
9570
|
+
const queryParameters = {};
|
|
9571
|
+
const headerParameters = {};
|
|
9572
|
+
headerParameters["Content-Type"] = "application/json";
|
|
9573
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
9574
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
9575
|
+
"X-Schematic-Api-Key"
|
|
9576
|
+
);
|
|
9577
|
+
}
|
|
9578
|
+
const response = await this.request(
|
|
9579
|
+
{
|
|
9580
|
+
path: `/company/credits/spend-policies`,
|
|
9581
|
+
method: "POST",
|
|
9582
|
+
headers: headerParameters,
|
|
9583
|
+
query: queryParameters,
|
|
9584
|
+
body: CreateCompanySpendPolicyRequestBodyToJSON(
|
|
9585
|
+
requestParameters["createCompanySpendPolicyRequestBody"]
|
|
9586
|
+
)
|
|
9587
|
+
},
|
|
9588
|
+
initOverrides
|
|
9589
|
+
);
|
|
9590
|
+
return new JSONApiResponse(
|
|
9591
|
+
response,
|
|
9592
|
+
(jsonValue) => CreateCompanySpendPolicyResponseFromJSON(jsonValue)
|
|
9593
|
+
);
|
|
9594
|
+
}
|
|
9595
|
+
/**
|
|
9596
|
+
* Create company spend policy
|
|
9597
|
+
*/
|
|
9598
|
+
async createCompanySpendPolicy(requestParameters, initOverrides) {
|
|
9599
|
+
const response = await this.createCompanySpendPolicyRaw(
|
|
9600
|
+
requestParameters,
|
|
9601
|
+
initOverrides
|
|
9602
|
+
);
|
|
9603
|
+
return await response.value();
|
|
9604
|
+
}
|
|
9380
9605
|
/**
|
|
9381
9606
|
* 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.
|
|
9382
9607
|
* Create a setup intent
|
|
@@ -9411,6 +9636,50 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
9411
9636
|
const response = await this.createSetupIntentRaw(initOverrides);
|
|
9412
9637
|
return await response.value();
|
|
9413
9638
|
}
|
|
9639
|
+
/**
|
|
9640
|
+
* Delete company spend policy
|
|
9641
|
+
*/
|
|
9642
|
+
async deleteCompanySpendPolicyRaw(requestParameters, initOverrides) {
|
|
9643
|
+
if (requestParameters["spendPolicyId"] == null) {
|
|
9644
|
+
throw new RequiredError(
|
|
9645
|
+
"spendPolicyId",
|
|
9646
|
+
'Required parameter "spendPolicyId" was null or undefined when calling deleteCompanySpendPolicy().'
|
|
9647
|
+
);
|
|
9648
|
+
}
|
|
9649
|
+
const queryParameters = {};
|
|
9650
|
+
const headerParameters = {};
|
|
9651
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
9652
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
9653
|
+
"X-Schematic-Api-Key"
|
|
9654
|
+
);
|
|
9655
|
+
}
|
|
9656
|
+
const response = await this.request(
|
|
9657
|
+
{
|
|
9658
|
+
path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
|
|
9659
|
+
`{${"spend_policy_id"}}`,
|
|
9660
|
+
encodeURIComponent(String(requestParameters["spendPolicyId"]))
|
|
9661
|
+
),
|
|
9662
|
+
method: "DELETE",
|
|
9663
|
+
headers: headerParameters,
|
|
9664
|
+
query: queryParameters
|
|
9665
|
+
},
|
|
9666
|
+
initOverrides
|
|
9667
|
+
);
|
|
9668
|
+
return new JSONApiResponse(
|
|
9669
|
+
response,
|
|
9670
|
+
(jsonValue) => DeleteCompanySpendPolicyResponseFromJSON(jsonValue)
|
|
9671
|
+
);
|
|
9672
|
+
}
|
|
9673
|
+
/**
|
|
9674
|
+
* Delete company spend policy
|
|
9675
|
+
*/
|
|
9676
|
+
async deleteCompanySpendPolicy(requestParameters, initOverrides) {
|
|
9677
|
+
const response = await this.deleteCompanySpendPolicyRaw(
|
|
9678
|
+
requestParameters,
|
|
9679
|
+
initOverrides
|
|
9680
|
+
);
|
|
9681
|
+
return await response.value();
|
|
9682
|
+
}
|
|
9414
9683
|
/**
|
|
9415
9684
|
* 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.
|
|
9416
9685
|
* Remove a payment method
|
|
@@ -10137,6 +10406,50 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
10137
10406
|
);
|
|
10138
10407
|
return await response.value();
|
|
10139
10408
|
}
|
|
10409
|
+
/**
|
|
10410
|
+
* Get invoice link
|
|
10411
|
+
*/
|
|
10412
|
+
async getInvoiceLinkRaw(requestParameters, initOverrides) {
|
|
10413
|
+
if (requestParameters["billingInvoiceId"] == null) {
|
|
10414
|
+
throw new RequiredError(
|
|
10415
|
+
"billingInvoiceId",
|
|
10416
|
+
'Required parameter "billingInvoiceId" was null or undefined when calling getInvoiceLink().'
|
|
10417
|
+
);
|
|
10418
|
+
}
|
|
10419
|
+
const queryParameters = {};
|
|
10420
|
+
const headerParameters = {};
|
|
10421
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
10422
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
10423
|
+
"X-Schematic-Api-Key"
|
|
10424
|
+
);
|
|
10425
|
+
}
|
|
10426
|
+
const response = await this.request(
|
|
10427
|
+
{
|
|
10428
|
+
path: `/components/invoices/{billing_invoice_id}/link`.replace(
|
|
10429
|
+
`{${"billing_invoice_id"}}`,
|
|
10430
|
+
encodeURIComponent(String(requestParameters["billingInvoiceId"]))
|
|
10431
|
+
),
|
|
10432
|
+
method: "GET",
|
|
10433
|
+
headers: headerParameters,
|
|
10434
|
+
query: queryParameters
|
|
10435
|
+
},
|
|
10436
|
+
initOverrides
|
|
10437
|
+
);
|
|
10438
|
+
return new JSONApiResponse(
|
|
10439
|
+
response,
|
|
10440
|
+
(jsonValue) => GetInvoiceLinkResponseFromJSON(jsonValue)
|
|
10441
|
+
);
|
|
10442
|
+
}
|
|
10443
|
+
/**
|
|
10444
|
+
* Get invoice link
|
|
10445
|
+
*/
|
|
10446
|
+
async getInvoiceLink(requestParameters, initOverrides) {
|
|
10447
|
+
const response = await this.getInvoiceLinkRaw(
|
|
10448
|
+
requestParameters,
|
|
10449
|
+
initOverrides
|
|
10450
|
+
);
|
|
10451
|
+
return await response.value();
|
|
10452
|
+
}
|
|
10140
10453
|
/**
|
|
10141
10454
|
* Get setup intent
|
|
10142
10455
|
*/
|
|
@@ -10359,6 +10672,44 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
10359
10672
|
);
|
|
10360
10673
|
return await response.value();
|
|
10361
10674
|
}
|
|
10675
|
+
/**
|
|
10676
|
+
* List company spend policies
|
|
10677
|
+
*/
|
|
10678
|
+
async listCompanySpendPoliciesRaw(requestParameters, initOverrides) {
|
|
10679
|
+
const queryParameters = {};
|
|
10680
|
+
if (requestParameters["billingCreditId"] != null) {
|
|
10681
|
+
queryParameters["billing_credit_id"] = requestParameters["billingCreditId"];
|
|
10682
|
+
}
|
|
10683
|
+
const headerParameters = {};
|
|
10684
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
10685
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
10686
|
+
"X-Schematic-Api-Key"
|
|
10687
|
+
);
|
|
10688
|
+
}
|
|
10689
|
+
const response = await this.request(
|
|
10690
|
+
{
|
|
10691
|
+
path: `/company/credits/spend-policies`,
|
|
10692
|
+
method: "GET",
|
|
10693
|
+
headers: headerParameters,
|
|
10694
|
+
query: queryParameters
|
|
10695
|
+
},
|
|
10696
|
+
initOverrides
|
|
10697
|
+
);
|
|
10698
|
+
return new JSONApiResponse(
|
|
10699
|
+
response,
|
|
10700
|
+
(jsonValue) => ListCompanySpendPoliciesResponseFromJSON(jsonValue)
|
|
10701
|
+
);
|
|
10702
|
+
}
|
|
10703
|
+
/**
|
|
10704
|
+
* List company spend policies
|
|
10705
|
+
*/
|
|
10706
|
+
async listCompanySpendPolicies(requestParameters = {}, initOverrides) {
|
|
10707
|
+
const response = await this.listCompanySpendPoliciesRaw(
|
|
10708
|
+
requestParameters,
|
|
10709
|
+
initOverrides
|
|
10710
|
+
);
|
|
10711
|
+
return await response.value();
|
|
10712
|
+
}
|
|
10362
10713
|
/**
|
|
10363
10714
|
* List invoices
|
|
10364
10715
|
*/
|
|
@@ -10593,6 +10944,60 @@ var CheckoutexternalApi = class extends BaseAPI {
|
|
|
10593
10944
|
);
|
|
10594
10945
|
return await response.value();
|
|
10595
10946
|
}
|
|
10947
|
+
/**
|
|
10948
|
+
* Update company spend policy
|
|
10949
|
+
*/
|
|
10950
|
+
async updateCompanySpendPolicyRaw(requestParameters, initOverrides) {
|
|
10951
|
+
if (requestParameters["spendPolicyId"] == null) {
|
|
10952
|
+
throw new RequiredError(
|
|
10953
|
+
"spendPolicyId",
|
|
10954
|
+
'Required parameter "spendPolicyId" was null or undefined when calling updateCompanySpendPolicy().'
|
|
10955
|
+
);
|
|
10956
|
+
}
|
|
10957
|
+
if (requestParameters["updateCreditSpendPolicyRequestBody"] == null) {
|
|
10958
|
+
throw new RequiredError(
|
|
10959
|
+
"updateCreditSpendPolicyRequestBody",
|
|
10960
|
+
'Required parameter "updateCreditSpendPolicyRequestBody" was null or undefined when calling updateCompanySpendPolicy().'
|
|
10961
|
+
);
|
|
10962
|
+
}
|
|
10963
|
+
const queryParameters = {};
|
|
10964
|
+
const headerParameters = {};
|
|
10965
|
+
headerParameters["Content-Type"] = "application/json";
|
|
10966
|
+
if (this.configuration && this.configuration.apiKey) {
|
|
10967
|
+
headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
|
|
10968
|
+
"X-Schematic-Api-Key"
|
|
10969
|
+
);
|
|
10970
|
+
}
|
|
10971
|
+
const response = await this.request(
|
|
10972
|
+
{
|
|
10973
|
+
path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
|
|
10974
|
+
`{${"spend_policy_id"}}`,
|
|
10975
|
+
encodeURIComponent(String(requestParameters["spendPolicyId"]))
|
|
10976
|
+
),
|
|
10977
|
+
method: "PUT",
|
|
10978
|
+
headers: headerParameters,
|
|
10979
|
+
query: queryParameters,
|
|
10980
|
+
body: UpdateCreditSpendPolicyRequestBodyToJSON(
|
|
10981
|
+
requestParameters["updateCreditSpendPolicyRequestBody"]
|
|
10982
|
+
)
|
|
10983
|
+
},
|
|
10984
|
+
initOverrides
|
|
10985
|
+
);
|
|
10986
|
+
return new JSONApiResponse(
|
|
10987
|
+
response,
|
|
10988
|
+
(jsonValue) => UpdateCompanySpendPolicyResponseFromJSON(jsonValue)
|
|
10989
|
+
);
|
|
10990
|
+
}
|
|
10991
|
+
/**
|
|
10992
|
+
* Update company spend policy
|
|
10993
|
+
*/
|
|
10994
|
+
async updateCompanySpendPolicy(requestParameters, initOverrides) {
|
|
10995
|
+
const response = await this.updateCompanySpendPolicyRaw(
|
|
10996
|
+
requestParameters,
|
|
10997
|
+
initOverrides
|
|
10998
|
+
);
|
|
10999
|
+
return await response.value();
|
|
11000
|
+
}
|
|
10596
11001
|
/**
|
|
10597
11002
|
* 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.
|
|
10598
11003
|
* Make a payment method the default
|
|
@@ -12627,7 +13032,7 @@ function resolveLocale(locale) {
|
|
|
12627
13032
|
return locale !== void 0 && locale !== "" && isUsableLocale(locale) ? locale : DEFAULT_LOCALE;
|
|
12628
13033
|
}
|
|
12629
13034
|
|
|
12630
|
-
// node_modules/.pnpm/i18next@
|
|
13035
|
+
// node_modules/.pnpm/i18next@27.0.0_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
|
|
12631
13036
|
var isString = (obj) => typeof obj === "string";
|
|
12632
13037
|
var defer = () => {
|
|
12633
13038
|
let res;
|
|
@@ -12742,12 +13147,11 @@ var _entityMap = {
|
|
|
12742
13147
|
"<": "<",
|
|
12743
13148
|
">": ">",
|
|
12744
13149
|
'"': """,
|
|
12745
|
-
"'": "'"
|
|
12746
|
-
"/": "/"
|
|
13150
|
+
"'": "'"
|
|
12747
13151
|
};
|
|
12748
13152
|
var escape = (data) => {
|
|
12749
13153
|
if (isString(data)) {
|
|
12750
|
-
return data.replace(/[&<>"'
|
|
13154
|
+
return data.replace(/[&<>"']/g, (s) => _entityMap[s]);
|
|
12751
13155
|
}
|
|
12752
13156
|
return data;
|
|
12753
13157
|
};
|
|
@@ -12794,6 +13198,9 @@ var deepFind = (obj, path, keySeparator = ".") => {
|
|
|
12794
13198
|
if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
|
|
12795
13199
|
return obj[path];
|
|
12796
13200
|
}
|
|
13201
|
+
if (!keySeparator) {
|
|
13202
|
+
return Object.prototype.hasOwnProperty.call(obj, path) ? obj[path] : void 0;
|
|
13203
|
+
}
|
|
12797
13204
|
const tokens = path.split(keySeparator);
|
|
12798
13205
|
let current = obj;
|
|
12799
13206
|
for (let i2 = 0; i2 < tokens.length; ) {
|
|
@@ -12938,15 +13345,20 @@ var EventEmitter = class {
|
|
|
12938
13345
|
}
|
|
12939
13346
|
};
|
|
12940
13347
|
var nonEmptyBundles = /* @__PURE__ */ new WeakSet();
|
|
13348
|
+
var assertSeparateArguments = (method, ...args) => {
|
|
13349
|
+
if (args.some((a2) => !isString(a2))) {
|
|
13350
|
+
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`);
|
|
13351
|
+
}
|
|
13352
|
+
};
|
|
12941
13353
|
var ResourceStore = class extends EventEmitter {
|
|
12942
13354
|
constructor(data, options = {
|
|
12943
13355
|
ns: ["translation"],
|
|
12944
13356
|
defaultNS: "translation"
|
|
12945
|
-
}) {
|
|
13357
|
+
}, logger = baseLogger) {
|
|
12946
13358
|
super();
|
|
12947
13359
|
this.data = data || {};
|
|
12948
13360
|
this.options = options;
|
|
12949
|
-
this.logger =
|
|
13361
|
+
this.logger = logger.create("resourceStore");
|
|
12950
13362
|
if (this.options.keySeparator === void 0) {
|
|
12951
13363
|
this.options.keySeparator = ".";
|
|
12952
13364
|
}
|
|
@@ -12965,49 +13377,30 @@ var ResourceStore = class extends EventEmitter {
|
|
|
12965
13377
|
this.options.ns.splice(index, 1);
|
|
12966
13378
|
}
|
|
12967
13379
|
}
|
|
12968
|
-
deprecateDottedLng(method) {
|
|
12969
|
-
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`);
|
|
12970
|
-
}
|
|
12971
13380
|
getResource(lng, ns, key, options = {}) {
|
|
12972
13381
|
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
12973
13382
|
const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
12974
|
-
|
|
12975
|
-
if (
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
path.push(...key);
|
|
12983
|
-
} else if (isString(key) && keySeparator) {
|
|
12984
|
-
path.push(...key.split(keySeparator));
|
|
12985
|
-
} else {
|
|
12986
|
-
path.push(key);
|
|
12987
|
-
}
|
|
13383
|
+
const path = [lng, ns];
|
|
13384
|
+
if (key) {
|
|
13385
|
+
if (Array.isArray(key)) {
|
|
13386
|
+
path.push(...key);
|
|
13387
|
+
} else if (isString(key) && keySeparator) {
|
|
13388
|
+
path.push(...key.split(keySeparator));
|
|
13389
|
+
} else {
|
|
13390
|
+
path.push(key);
|
|
12988
13391
|
}
|
|
12989
13392
|
}
|
|
12990
13393
|
const result = getPath(this.data, path);
|
|
12991
|
-
if (result == null && !ns && !key && lng.includes(".")) {
|
|
12992
|
-
lng = path[0];
|
|
12993
|
-
ns = path[1];
|
|
12994
|
-
key = path.slice(2).join(".");
|
|
12995
|
-
}
|
|
12996
13394
|
if (result != null || !ignoreJSONStructure || !isString(key)) return result;
|
|
12997
13395
|
return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
|
|
12998
13396
|
}
|
|
12999
13397
|
addResource(lng, ns, key, value, options = {
|
|
13000
13398
|
silent: false
|
|
13001
13399
|
}) {
|
|
13400
|
+
assertSeparateArguments("addResource", lng, ns, key);
|
|
13002
13401
|
const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
|
|
13003
13402
|
let path = [lng, ns];
|
|
13004
13403
|
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
13005
|
-
if (lng.includes(".")) {
|
|
13006
|
-
this.deprecateDottedLng("addResource");
|
|
13007
|
-
path = lng.split(".");
|
|
13008
|
-
value = ns;
|
|
13009
|
-
ns = path[1];
|
|
13010
|
-
}
|
|
13011
13404
|
this.addNamespaces(ns);
|
|
13012
13405
|
setPath(this.data, path, value);
|
|
13013
13406
|
if (!options.silent) this.emit("added", lng, ns, key, value);
|
|
@@ -13015,25 +13408,21 @@ var ResourceStore = class extends EventEmitter {
|
|
|
13015
13408
|
addResources(lng, ns, resources, options = {
|
|
13016
13409
|
silent: false
|
|
13017
13410
|
}) {
|
|
13018
|
-
|
|
13019
|
-
|
|
13411
|
+
assertSeparateArguments("addResources", lng, ns);
|
|
13412
|
+
Object.keys(resources || {}).forEach((m2) => {
|
|
13413
|
+
if (m2 === "__proto__" || m2 === "constructor") return;
|
|
13414
|
+
this.addResource(lng, ns, m2, resources[m2], {
|
|
13020
13415
|
silent: true
|
|
13021
13416
|
});
|
|
13022
|
-
}
|
|
13417
|
+
});
|
|
13023
13418
|
if (!options.silent) this.emit("added", lng, ns, resources);
|
|
13024
13419
|
}
|
|
13025
13420
|
addResourceBundle(lng, ns, resources, deep, overwrite, options = {
|
|
13026
13421
|
silent: false,
|
|
13027
13422
|
skipCopy: false
|
|
13028
13423
|
}) {
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
this.deprecateDottedLng("addResourceBundle");
|
|
13032
|
-
path = lng.split(".");
|
|
13033
|
-
deep = resources;
|
|
13034
|
-
resources = ns;
|
|
13035
|
-
ns = path[1];
|
|
13036
|
-
}
|
|
13424
|
+
assertSeparateArguments("addResourceBundle", lng, ns);
|
|
13425
|
+
const path = [lng, ns];
|
|
13037
13426
|
this.addNamespaces(ns);
|
|
13038
13427
|
let pack = getPath(this.data, path) || {};
|
|
13039
13428
|
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
|
@@ -13080,18 +13469,6 @@ var ResourceStore = class extends EventEmitter {
|
|
|
13080
13469
|
return this.data;
|
|
13081
13470
|
}
|
|
13082
13471
|
};
|
|
13083
|
-
var postProcessor = {
|
|
13084
|
-
processors: {},
|
|
13085
|
-
addPostProcessor(module) {
|
|
13086
|
-
this.processors[module.name] = module;
|
|
13087
|
-
},
|
|
13088
|
-
handle(processors, value, key, options, translator) {
|
|
13089
|
-
processors.forEach((processor) => {
|
|
13090
|
-
value = this.processors[processor]?.process(value, key, options, translator) ?? value;
|
|
13091
|
-
});
|
|
13092
|
-
return value;
|
|
13093
|
-
}
|
|
13094
|
-
};
|
|
13095
13472
|
var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
|
|
13096
13473
|
function createProxy() {
|
|
13097
13474
|
const state = [];
|
|
@@ -13110,7 +13487,7 @@ function keysFromSelector(selector, opts) {
|
|
|
13110
13487
|
const {
|
|
13111
13488
|
[PATH_KEY]: path
|
|
13112
13489
|
} = selector(createProxy());
|
|
13113
|
-
const keySeparator = opts?.keySeparator
|
|
13490
|
+
const keySeparator = opts?.keySeparator || ".";
|
|
13114
13491
|
const nsSeparator = opts?.nsSeparator ?? ":";
|
|
13115
13492
|
const strict = opts?.enableSelector === "strict";
|
|
13116
13493
|
if (path.length > 1 && nsSeparator) {
|
|
@@ -13129,12 +13506,12 @@ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" &
|
|
|
13129
13506
|
var Translator = class _Translator extends EventEmitter {
|
|
13130
13507
|
constructor(services, options = {}) {
|
|
13131
13508
|
super();
|
|
13132
|
-
copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "
|
|
13509
|
+
copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "postProcessors"], services, this);
|
|
13133
13510
|
this.options = options;
|
|
13134
13511
|
if (this.options.keySeparator === void 0) {
|
|
13135
13512
|
this.options.keySeparator = ".";
|
|
13136
13513
|
}
|
|
13137
|
-
this.logger = baseLogger.create("translator");
|
|
13514
|
+
this.logger = (services.logger || baseLogger).create("translator");
|
|
13138
13515
|
this.checkedLoadedFor = {};
|
|
13139
13516
|
}
|
|
13140
13517
|
changeLanguage(lng) {
|
|
@@ -13258,23 +13635,24 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13258
13635
|
}
|
|
13259
13636
|
const handleAsObject = shouldHandleAsObject(resForObjHndl);
|
|
13260
13637
|
const resType = Object.prototype.toString.apply(resForObjHndl);
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
resolved.res = r2;
|
|
13273
|
-
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
13274
|
-
return resolved;
|
|
13275
|
-
}
|
|
13276
|
-
return r2;
|
|
13638
|
+
const isObjectHit = handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl));
|
|
13639
|
+
const objectNotReturned = isObjectHit && !opt.returnObjects && !this.options.returnObjects;
|
|
13640
|
+
if (objectNotReturned && this.options.returnedObjectHandler) {
|
|
13641
|
+
const r2 = this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
|
|
13642
|
+
...opt,
|
|
13643
|
+
ns: namespaces
|
|
13644
|
+
});
|
|
13645
|
+
if (returnDetails) {
|
|
13646
|
+
resolved.res = r2;
|
|
13647
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
13648
|
+
return resolved;
|
|
13277
13649
|
}
|
|
13650
|
+
return r2;
|
|
13651
|
+
}
|
|
13652
|
+
if (objectNotReturned) {
|
|
13653
|
+
this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
13654
|
+
}
|
|
13655
|
+
if (isObjectHit && !objectNotReturned) {
|
|
13278
13656
|
if (keySeparator) {
|
|
13279
13657
|
const resTypeIsArray = Array.isArray(resForObjHndl);
|
|
13280
13658
|
const copy3 = resTypeIsArray ? [] : {};
|
|
@@ -13311,18 +13689,19 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13311
13689
|
} else {
|
|
13312
13690
|
let usedDefault = false;
|
|
13313
13691
|
let usedKey = false;
|
|
13314
|
-
if (
|
|
13692
|
+
if (objectNotReturned) res = void 0;
|
|
13693
|
+
if (!this.isValidLookup(res) && hasDefaultValue && !(objectNotReturned && shouldHandleAsObject(defaultValue))) {
|
|
13315
13694
|
usedDefault = true;
|
|
13316
13695
|
res = defaultValue;
|
|
13317
13696
|
}
|
|
13318
|
-
if (!this.isValidLookup(res)) {
|
|
13697
|
+
if (!this.isValidLookup(res) && !(usedDefault && res === "")) {
|
|
13319
13698
|
usedKey = true;
|
|
13320
13699
|
res = key;
|
|
13321
13700
|
}
|
|
13322
13701
|
const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
13323
13702
|
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
|
|
13324
13703
|
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
13325
|
-
if (usedKey || usedDefault || updateMissing) {
|
|
13704
|
+
if (!objectNotReturned && (usedKey || usedDefault || updateMissing)) {
|
|
13326
13705
|
this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
|
|
13327
13706
|
if (keySeparator) {
|
|
13328
13707
|
const fk = this.resolve(key, {
|
|
@@ -13430,18 +13809,21 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13430
13809
|
const postProcess = opt.postProcess || this.options.postProcess;
|
|
13431
13810
|
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
|
13432
13811
|
if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
|
|
13433
|
-
|
|
13434
|
-
if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
|
|
13435
|
-
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`);
|
|
13436
|
-
}
|
|
13437
|
-
});
|
|
13438
|
-
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
13812
|
+
const ppOptions = this.options?.postProcessPassResolved ? {
|
|
13439
13813
|
i18nResolved: {
|
|
13440
13814
|
...resolved,
|
|
13441
13815
|
usedParams: this.getUsedParamsDetails(opt)
|
|
13442
13816
|
},
|
|
13443
13817
|
...opt
|
|
13444
|
-
} : opt
|
|
13818
|
+
} : opt;
|
|
13819
|
+
postProcessorNames.forEach((name) => {
|
|
13820
|
+
const processor = this.postProcessors?.[name];
|
|
13821
|
+
if (!processor) {
|
|
13822
|
+
this.logger.once(`postProcess:${name}`, "warn", `postProcess: '${name}' is not registered on this i18next instance; call use() with it on this instance`);
|
|
13823
|
+
return;
|
|
13824
|
+
}
|
|
13825
|
+
res = processor.process(res, key, ppOptions, this) ?? res;
|
|
13826
|
+
});
|
|
13445
13827
|
}
|
|
13446
13828
|
return res;
|
|
13447
13829
|
}
|
|
@@ -13570,14 +13952,16 @@ var Translator = class _Translator extends EventEmitter {
|
|
|
13570
13952
|
}
|
|
13571
13953
|
};
|
|
13572
13954
|
var LanguageUtil = class {
|
|
13573
|
-
constructor(options) {
|
|
13955
|
+
constructor(options, logger = baseLogger) {
|
|
13574
13956
|
this.options = options;
|
|
13575
13957
|
this.supportedLngs = this.options.supportedLngs || false;
|
|
13576
|
-
this.logger =
|
|
13958
|
+
this.logger = logger.create("languageUtils");
|
|
13577
13959
|
this.resolveHierarchyCache = {};
|
|
13960
|
+
this.formattedCodes = /* @__PURE__ */ new Map();
|
|
13578
13961
|
}
|
|
13579
13962
|
clearCache() {
|
|
13580
13963
|
this.resolveHierarchyCache = {};
|
|
13964
|
+
this.formattedCodes.clear();
|
|
13581
13965
|
}
|
|
13582
13966
|
getScriptPartFromCode(code) {
|
|
13583
13967
|
code = getCleanedCode(code);
|
|
@@ -13595,35 +13979,28 @@ var LanguageUtil = class {
|
|
|
13595
13979
|
return this.formatLanguageCode(p2[0]);
|
|
13596
13980
|
}
|
|
13597
13981
|
formatLanguageCode(code) {
|
|
13598
|
-
if (isString(code)
|
|
13599
|
-
|
|
13982
|
+
if (!isString(code)) return code;
|
|
13983
|
+
let formatted = this.formattedCodes.get(code);
|
|
13984
|
+
if (formatted !== void 0) return formatted;
|
|
13985
|
+
formatted = this.formatUncached(code);
|
|
13986
|
+
if (this.formattedCodes.size >= 1e3) this.formattedCodes.clear();
|
|
13987
|
+
this.formattedCodes.set(code, formatted);
|
|
13988
|
+
return formatted;
|
|
13989
|
+
}
|
|
13990
|
+
formatUncached(code) {
|
|
13991
|
+
const hasSubtags = code.includes("-");
|
|
13992
|
+
if (hasSubtags || this.options.cleanCode !== false) {
|
|
13993
|
+
let canonical;
|
|
13600
13994
|
try {
|
|
13601
|
-
|
|
13995
|
+
canonical = Intl.getCanonicalLocales(code)[0];
|
|
13602
13996
|
} catch (e) {
|
|
13603
13997
|
}
|
|
13604
|
-
if (
|
|
13605
|
-
|
|
13606
|
-
}
|
|
13607
|
-
if (formattedCode) return formattedCode;
|
|
13608
|
-
if (this.options.lowerCaseLng) {
|
|
13609
|
-
return code.toLowerCase();
|
|
13998
|
+
if (canonical && (hasSubtags || canonical.toLowerCase() === code.toLowerCase())) {
|
|
13999
|
+
return this.options.lowerCaseLng ? canonical.toLowerCase() : canonical;
|
|
13610
14000
|
}
|
|
13611
|
-
return code;
|
|
14001
|
+
if (canonical) return code.toLowerCase();
|
|
13612
14002
|
}
|
|
13613
|
-
|
|
13614
|
-
if (this.logger.debug && isString(code)) this.deprecateBareCode(code, formatted);
|
|
13615
|
-
return formatted;
|
|
13616
|
-
}
|
|
13617
|
-
deprecateBareCode(code, formatted) {
|
|
13618
|
-
let v27;
|
|
13619
|
-
try {
|
|
13620
|
-
v27 = Intl.getCanonicalLocales(code)[0];
|
|
13621
|
-
} catch (e) {
|
|
13622
|
-
return;
|
|
13623
|
-
}
|
|
13624
|
-
if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
|
|
13625
|
-
if (v27 === formatted) return;
|
|
13626
|
-
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`);
|
|
14003
|
+
return this.options.lowerCaseLng || this.options.cleanCode && !hasSubtags ? code.toLowerCase() : code;
|
|
13627
14004
|
}
|
|
13628
14005
|
isSupportedCode(code) {
|
|
13629
14006
|
if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
|
|
@@ -13735,10 +14112,10 @@ var dummyRule = {
|
|
|
13735
14112
|
})
|
|
13736
14113
|
};
|
|
13737
14114
|
var PluralResolver = class {
|
|
13738
|
-
constructor(languageUtils, options = {}) {
|
|
14115
|
+
constructor(languageUtils, options = {}, logger = baseLogger) {
|
|
13739
14116
|
this.languageUtils = languageUtils;
|
|
13740
14117
|
this.options = options;
|
|
13741
|
-
this.logger =
|
|
14118
|
+
this.logger = logger.create("pluralResolver");
|
|
13742
14119
|
this.pluralRulesCache = {};
|
|
13743
14120
|
}
|
|
13744
14121
|
clearCache() {
|
|
@@ -13803,8 +14180,8 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
|
|
|
13803
14180
|
return path;
|
|
13804
14181
|
};
|
|
13805
14182
|
var Interpolator = class {
|
|
13806
|
-
constructor(options = {}) {
|
|
13807
|
-
this.logger =
|
|
14183
|
+
constructor(options = {}, logger = baseLogger) {
|
|
14184
|
+
this.logger = logger.create("interpolator");
|
|
13808
14185
|
this.options = options;
|
|
13809
14186
|
this.format = options?.interpolation?.format || ((value) => value);
|
|
13810
14187
|
this.init(options);
|
|
@@ -13818,39 +14195,26 @@ var Interpolator = class {
|
|
|
13818
14195
|
escapeValue,
|
|
13819
14196
|
useRawValueToEscape,
|
|
13820
14197
|
prefix: prefix2,
|
|
13821
|
-
prefixEscaped,
|
|
13822
14198
|
suffix,
|
|
13823
|
-
suffixEscaped,
|
|
13824
14199
|
formatSeparator,
|
|
13825
14200
|
unescapeSuffix,
|
|
13826
14201
|
unescapePrefix,
|
|
13827
14202
|
nestingPrefix,
|
|
13828
|
-
nestingPrefixEscaped,
|
|
13829
14203
|
nestingSuffix,
|
|
13830
|
-
nestingSuffixEscaped,
|
|
13831
14204
|
nestingOptionsSeparator,
|
|
13832
14205
|
maxReplaces,
|
|
13833
14206
|
alwaysFormat
|
|
13834
14207
|
} = options.interpolation;
|
|
13835
|
-
if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
|
|
13836
|
-
const names = Object.entries({
|
|
13837
|
-
prefixEscaped,
|
|
13838
|
-
suffixEscaped,
|
|
13839
|
-
nestingPrefixEscaped,
|
|
13840
|
-
nestingSuffixEscaped
|
|
13841
|
-
}).filter(([, v2]) => v2).map(([k2]) => k2);
|
|
13842
|
-
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`);
|
|
13843
|
-
}
|
|
13844
14208
|
this.escape = escape$1 !== void 0 ? escape$1 : escape;
|
|
13845
14209
|
this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
|
|
13846
14210
|
this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
|
|
13847
|
-
this.prefix = prefix2 ? regexEscape(prefix2) :
|
|
13848
|
-
this.suffix = suffix ? regexEscape(suffix) :
|
|
14211
|
+
this.prefix = prefix2 ? regexEscape(prefix2) : "{{";
|
|
14212
|
+
this.suffix = suffix ? regexEscape(suffix) : "}}";
|
|
13849
14213
|
this.formatSeparator = formatSeparator || ",";
|
|
13850
14214
|
this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
|
|
13851
14215
|
this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
|
|
13852
|
-
this.nestingPrefix =
|
|
13853
|
-
this.nestingSuffix =
|
|
14216
|
+
this.nestingPrefix = regexEscape(nestingPrefix || "$t(");
|
|
14217
|
+
this.nestingSuffix = regexEscape(nestingSuffix || ")");
|
|
13854
14218
|
this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
|
|
13855
14219
|
this.maxReplaces = maxReplaces || 1e3;
|
|
13856
14220
|
this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
|
|
@@ -13906,13 +14270,7 @@ var Interpolator = class {
|
|
|
13906
14270
|
safeValue: (val) => val
|
|
13907
14271
|
}, {
|
|
13908
14272
|
regex: this.regexp,
|
|
13909
|
-
safeValue: (val) =>
|
|
13910
|
-
if (!this.escapeValue) return val;
|
|
13911
|
-
if (this.escape === escape && this.options?.interpolation?.escapeValue !== false && isString(val) && val.includes("/")) {
|
|
13912
|
-
this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '/' today; from v27 the default escape leaves '/' as it is");
|
|
13913
|
-
}
|
|
13914
|
-
return this.escape(val);
|
|
13915
|
-
}
|
|
14273
|
+
safeValue: (val) => this.escapeValue ? this.escape(val) : val
|
|
13916
14274
|
}];
|
|
13917
14275
|
const unescapedValues = [];
|
|
13918
14276
|
let shift = 0;
|
|
@@ -14097,6 +14455,7 @@ var Formatter = class {
|
|
|
14097
14455
|
init(services, options = {
|
|
14098
14456
|
interpolation: {}
|
|
14099
14457
|
}) {
|
|
14458
|
+
if (services?.logger?.create) this.logger = services.logger.create("formatter");
|
|
14100
14459
|
this.formatSeparator = options.interpolation.formatSeparator || ",";
|
|
14101
14460
|
const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
|
|
14102
14461
|
this.formats = {
|
|
@@ -14192,7 +14551,7 @@ var Connector = class extends EventEmitter {
|
|
|
14192
14551
|
this.services = services;
|
|
14193
14552
|
this.languageUtils = services.languageUtils;
|
|
14194
14553
|
this.options = options;
|
|
14195
|
-
this.logger = baseLogger.create("backendConnector");
|
|
14554
|
+
this.logger = (services.logger || baseLogger).create("backendConnector");
|
|
14196
14555
|
this.waitingReads = [];
|
|
14197
14556
|
this.maxParallelReads = options.maxParallelReads || 10;
|
|
14198
14557
|
this.readingCalls = 0;
|
|
@@ -14352,15 +14711,10 @@ var Connector = class extends EventEmitter {
|
|
|
14352
14711
|
reload: true
|
|
14353
14712
|
}, callback);
|
|
14354
14713
|
}
|
|
14355
|
-
noticeDevFallback(lng) {
|
|
14356
|
-
if (lng !== "dev" || !this.devIsDefaultFallback) return;
|
|
14357
|
-
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");
|
|
14358
|
-
}
|
|
14359
14714
|
loadOne(name, prefix2 = "") {
|
|
14360
14715
|
const s = name.split("|");
|
|
14361
14716
|
const lng = s[0];
|
|
14362
14717
|
const ns = s[1];
|
|
14363
|
-
this.noticeDevFallback(lng);
|
|
14364
14718
|
this.read(lng, ns, "read", void 0, void 0, (err, data) => {
|
|
14365
14719
|
if (err) this.logger.warn(`${prefix2}loading namespace ${ns} for language ${lng} failed`, err);
|
|
14366
14720
|
if (!err && data) this.logger.log(`${prefix2}loaded namespace ${ns} for language ${lng}`, data);
|
|
@@ -14375,7 +14729,6 @@ var Connector = class extends EventEmitter {
|
|
|
14375
14729
|
}
|
|
14376
14730
|
if (key === void 0 || key === null || key === "") return;
|
|
14377
14731
|
if (this.backend?.create) {
|
|
14378
|
-
languages?.forEach?.((l2) => this.noticeDevFallback(l2));
|
|
14379
14732
|
const opts = {
|
|
14380
14733
|
...options,
|
|
14381
14734
|
isUpdate
|
|
@@ -14410,7 +14763,7 @@ var get = () => ({
|
|
|
14410
14763
|
initAsync: true,
|
|
14411
14764
|
ns: ["translation"],
|
|
14412
14765
|
defaultNS: ["translation"],
|
|
14413
|
-
fallbackLng:
|
|
14766
|
+
fallbackLng: false,
|
|
14414
14767
|
fallbackNS: false,
|
|
14415
14768
|
supportedLngs: false,
|
|
14416
14769
|
nonExplicitSupportedLngs: false,
|
|
@@ -14431,7 +14784,7 @@ var get = () => ({
|
|
|
14431
14784
|
postProcess: false,
|
|
14432
14785
|
postProcessPassResolved: false,
|
|
14433
14786
|
returnNull: false,
|
|
14434
|
-
returnEmptyString:
|
|
14787
|
+
returnEmptyString: false,
|
|
14435
14788
|
returnObjects: false,
|
|
14436
14789
|
joinArrays: false,
|
|
14437
14790
|
returnedObjectHandler: false,
|
|
@@ -14476,7 +14829,39 @@ var transformOptions = (options) => {
|
|
|
14476
14829
|
};
|
|
14477
14830
|
var noop = () => {
|
|
14478
14831
|
};
|
|
14479
|
-
var
|
|
14832
|
+
var withDefaults = (options) => {
|
|
14833
|
+
const defOpts = get();
|
|
14834
|
+
const merged = {
|
|
14835
|
+
...defOpts,
|
|
14836
|
+
...options
|
|
14837
|
+
};
|
|
14838
|
+
merged.interpolation = {
|
|
14839
|
+
...defOpts.interpolation,
|
|
14840
|
+
...options.interpolation
|
|
14841
|
+
};
|
|
14842
|
+
if (typeof merged.overloadTranslationOptionHandler !== "function") {
|
|
14843
|
+
merged.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
|
|
14844
|
+
}
|
|
14845
|
+
return merged;
|
|
14846
|
+
};
|
|
14847
|
+
var configuredLanguageCodes = (options) => {
|
|
14848
|
+
const codes = [].concat(options.supportedLngs || [], options.preload || []);
|
|
14849
|
+
codes.push(...Object.keys(options.resources || {}));
|
|
14850
|
+
const fallbackLng = options.fallbackLng;
|
|
14851
|
+
if (isString(fallbackLng) || Array.isArray(fallbackLng)) codes.push(...[].concat(fallbackLng));
|
|
14852
|
+
else if (fallbackLng && typeof fallbackLng === "object") {
|
|
14853
|
+
Object.keys(fallbackLng).forEach((code) => {
|
|
14854
|
+
if (code !== "default") codes.push(code);
|
|
14855
|
+
codes.push(...[].concat(fallbackLng[code]));
|
|
14856
|
+
});
|
|
14857
|
+
}
|
|
14858
|
+
return codes;
|
|
14859
|
+
};
|
|
14860
|
+
var isRefusedLanguageCode = (i18n2, code) => {
|
|
14861
|
+
if (!isString(code) || isSafeLanguageCode(code) || i18n2.configuredLngs?.has(code)) return false;
|
|
14862
|
+
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`);
|
|
14863
|
+
return true;
|
|
14864
|
+
};
|
|
14480
14865
|
var bindMemberFunctions = (inst) => {
|
|
14481
14866
|
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
14482
14867
|
mems.forEach((mem) => {
|
|
@@ -14488,17 +14873,18 @@ var bindMemberFunctions = (inst) => {
|
|
|
14488
14873
|
var I18n = class _I18n extends EventEmitter {
|
|
14489
14874
|
constructor(options = {}, callback) {
|
|
14490
14875
|
super();
|
|
14491
|
-
this.
|
|
14876
|
+
this.userOptions = transformOptions(options);
|
|
14877
|
+
this.options = withDefaults(this.userOptions);
|
|
14492
14878
|
this.services = {
|
|
14493
|
-
|
|
14879
|
+
postProcessors: /* @__PURE__ */ Object.create(null)
|
|
14494
14880
|
};
|
|
14495
|
-
this.logger =
|
|
14881
|
+
this.logger = new Logger(null, this.options);
|
|
14496
14882
|
this.modules = {
|
|
14497
14883
|
external: []
|
|
14498
14884
|
};
|
|
14499
14885
|
bindMemberFunctions(this);
|
|
14500
14886
|
if (callback && !this.isInitialized && !options.isClone) {
|
|
14501
|
-
if (!this.
|
|
14887
|
+
if (!this.userOptions.initAsync) {
|
|
14502
14888
|
this.init(options, callback);
|
|
14503
14889
|
return this;
|
|
14504
14890
|
}
|
|
@@ -14520,25 +14906,23 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14520
14906
|
options.defaultNS = options.ns[0];
|
|
14521
14907
|
}
|
|
14522
14908
|
}
|
|
14523
|
-
|
|
14524
|
-
const
|
|
14525
|
-
|
|
14526
|
-
...
|
|
14527
|
-
...this.options,
|
|
14528
|
-
...transformOptions(options)
|
|
14529
|
-
};
|
|
14530
|
-
this.options.interpolation = {
|
|
14531
|
-
...defOpts.interpolation,
|
|
14532
|
-
...this.options.interpolation
|
|
14909
|
+
transformOptions(options);
|
|
14910
|
+
const userOptions = {
|
|
14911
|
+
...this.userOptions,
|
|
14912
|
+
...options
|
|
14533
14913
|
};
|
|
14534
|
-
|
|
14535
|
-
this.options
|
|
14914
|
+
this.options = withDefaults({
|
|
14915
|
+
...this.options,
|
|
14916
|
+
...options
|
|
14917
|
+
});
|
|
14918
|
+
if (userOptions.keySeparator !== void 0) {
|
|
14919
|
+
this.options.userDefinedKeySeparator = userOptions.keySeparator;
|
|
14536
14920
|
}
|
|
14537
|
-
if (
|
|
14538
|
-
this.options.userDefinedNsSeparator =
|
|
14921
|
+
if (userOptions.nsSeparator !== void 0) {
|
|
14922
|
+
this.options.userDefinedNsSeparator = userOptions.nsSeparator;
|
|
14539
14923
|
}
|
|
14540
|
-
if (
|
|
14541
|
-
this.
|
|
14924
|
+
if (!this.options.isClone) {
|
|
14925
|
+
this.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(userOptions)]);
|
|
14542
14926
|
}
|
|
14543
14927
|
const createClassOnDemand = (ClassOrObject) => {
|
|
14544
14928
|
if (!ClassOrObject) return null;
|
|
@@ -14546,15 +14930,10 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14546
14930
|
return ClassOrObject;
|
|
14547
14931
|
};
|
|
14548
14932
|
if (!this.options.isClone) {
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
if (this.modules.logger) {
|
|
14554
|
-
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
14555
|
-
} else {
|
|
14556
|
-
baseLogger.init(null, this.options);
|
|
14557
|
-
}
|
|
14933
|
+
this.logger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
14934
|
+
const {
|
|
14935
|
+
logger
|
|
14936
|
+
} = this;
|
|
14558
14937
|
this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
|
|
14559
14938
|
this.pendingWarnings = void 0;
|
|
14560
14939
|
let formatter;
|
|
@@ -14563,27 +14942,26 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14563
14942
|
} else {
|
|
14564
14943
|
formatter = Formatter;
|
|
14565
14944
|
}
|
|
14566
|
-
const lu = new LanguageUtil(this.options);
|
|
14567
|
-
this.store = new ResourceStore(this.options.resources, this.options);
|
|
14945
|
+
const lu = new LanguageUtil(this.options, logger);
|
|
14946
|
+
this.store = new ResourceStore(this.options.resources, this.options, logger);
|
|
14568
14947
|
const s = this.services;
|
|
14569
|
-
s.logger =
|
|
14948
|
+
s.logger = logger;
|
|
14570
14949
|
s.resourceStore = this.store;
|
|
14571
14950
|
s.languageUtils = lu;
|
|
14572
14951
|
s.pluralResolver = new PluralResolver(lu, {
|
|
14573
14952
|
prepend: this.options.pluralSeparator
|
|
14574
|
-
});
|
|
14953
|
+
}, logger);
|
|
14575
14954
|
if (formatter) {
|
|
14576
14955
|
s.formatter = createClassOnDemand(formatter);
|
|
14577
14956
|
if (s.formatter.init) s.formatter.init(s, this.options);
|
|
14578
14957
|
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
14579
14958
|
}
|
|
14580
|
-
s.interpolator = new Interpolator(this.options);
|
|
14959
|
+
s.interpolator = new Interpolator(this.options, logger);
|
|
14581
14960
|
s.utils = {
|
|
14582
14961
|
hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
|
|
14583
14962
|
reloadResources: this.reloadResources.bind(this)
|
|
14584
14963
|
};
|
|
14585
14964
|
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
14586
|
-
s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
|
|
14587
14965
|
s.backendConnector.on("*", (event, ...args) => {
|
|
14588
14966
|
this.emit(event, ...args);
|
|
14589
14967
|
});
|
|
@@ -14724,8 +15102,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14724
15102
|
setModule("i18nFormat");
|
|
14725
15103
|
}
|
|
14726
15104
|
if (module.type === "postProcessor") {
|
|
14727
|
-
|
|
14728
|
-
this.services.ownPostProcessors?.add(module.name);
|
|
15105
|
+
this.services.postProcessors[module.name] = module;
|
|
14729
15106
|
}
|
|
14730
15107
|
if (module.type === "formatter") {
|
|
14731
15108
|
setModule("formatter");
|
|
@@ -14800,14 +15177,16 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14800
15177
|
};
|
|
14801
15178
|
const setLng = (lngs) => {
|
|
14802
15179
|
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
14803
|
-
const
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
}
|
|
15180
|
+
const {
|
|
15181
|
+
supportedLngs
|
|
15182
|
+
} = this.options;
|
|
15183
|
+
if (lngs && !supportedLngs) {
|
|
15184
|
+
const accepted = [].concat(lngs).filter((c2) => !isRefusedLanguageCode(this, c2));
|
|
15185
|
+
if (accepted.length < [].concat(lngs).length) lngs = accepted;
|
|
14810
15186
|
}
|
|
15187
|
+
const fl = isString(lngs) ? lngs : lngs && lngs[0];
|
|
15188
|
+
let l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
|
|
15189
|
+
if (supportedLngs && isRefusedLanguageCode(this, l2)) l2 = this.services.languageUtils.getBestMatchFromCodes([]);
|
|
14811
15190
|
if (l2) {
|
|
14812
15191
|
if (!this.language) {
|
|
14813
15192
|
setLngProps(l2);
|
|
@@ -14922,7 +15301,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14922
15301
|
}
|
|
14923
15302
|
loadNamespaces(ns, callback) {
|
|
14924
15303
|
const deferred = defer();
|
|
14925
|
-
if (!this.options.ns) {
|
|
15304
|
+
if (!this.options.ns || !this.services.backendConnector) {
|
|
14926
15305
|
if (callback) callback();
|
|
14927
15306
|
return Promise.resolve();
|
|
14928
15307
|
}
|
|
@@ -14940,7 +15319,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14940
15319
|
const deferred = defer();
|
|
14941
15320
|
if (isString(lngs)) lngs = [lngs];
|
|
14942
15321
|
const preloaded = this.options.preload || [];
|
|
14943
|
-
const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
|
|
15322
|
+
const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && !isRefusedLanguageCode(this, lng) && this.services.languageUtils.isSupportedCode(lng));
|
|
14944
15323
|
if (!newLngs.length) {
|
|
14945
15324
|
if (callback) callback();
|
|
14946
15325
|
return Promise.resolve();
|
|
@@ -14990,16 +15369,15 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
14990
15369
|
}
|
|
14991
15370
|
};
|
|
14992
15371
|
const clone = new _I18n(mergedOptions);
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
}
|
|
14996
|
-
const membersToCopy = ["store", "services", "language"];
|
|
15372
|
+
clone.logger = options.debug !== void 0 || options.prefix !== void 0 ? this.logger.clone(options) : this.logger;
|
|
15373
|
+
const membersToCopy = ["store", "language"];
|
|
14997
15374
|
membersToCopy.forEach((m2) => {
|
|
14998
15375
|
clone[m2] = this[m2];
|
|
14999
15376
|
});
|
|
15000
15377
|
clone.services = {
|
|
15001
15378
|
...this.services
|
|
15002
15379
|
};
|
|
15380
|
+
clone.services.postProcessors = Object.create(this.services.postProcessors);
|
|
15003
15381
|
clone.services.utils = {
|
|
15004
15382
|
...clone.services.utils,
|
|
15005
15383
|
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
|
|
@@ -15016,7 +15394,7 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
15016
15394
|
return copied;
|
|
15017
15395
|
};
|
|
15018
15396
|
const clonedData = copyData(this.store.data);
|
|
15019
|
-
clone.store = new ResourceStore(clonedData, mergedOptions);
|
|
15397
|
+
clone.store = new ResourceStore(clonedData, mergedOptions, this.logger);
|
|
15020
15398
|
clone.services.resourceStore = clone.store;
|
|
15021
15399
|
}
|
|
15022
15400
|
if (options.interpolation) {
|
|
@@ -15030,8 +15408,9 @@ var I18n = class _I18n extends EventEmitter {
|
|
|
15030
15408
|
...mergedOptions,
|
|
15031
15409
|
interpolation: mergedInterpolation
|
|
15032
15410
|
};
|
|
15033
|
-
clone.services.interpolator = new Interpolator(mergedForInterpolator);
|
|
15411
|
+
clone.services.interpolator = new Interpolator(mergedForInterpolator, this.logger);
|
|
15034
15412
|
}
|
|
15413
|
+
clone.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(options)]);
|
|
15035
15414
|
clone.translator = new Translator(clone.services, mergedOptions);
|
|
15036
15415
|
clone.translator.on("*", (event, ...args) => {
|
|
15037
15416
|
clone.emit(event, ...args);
|
|
@@ -17059,6 +17438,25 @@ var createKeyboardExecutionHandler = (fn) => {
|
|
|
17059
17438
|
return handler;
|
|
17060
17439
|
};
|
|
17061
17440
|
|
|
17441
|
+
// src/utils/invoiceLink.ts
|
|
17442
|
+
function openInvoiceLink(event, storedUrl, fetchUrl) {
|
|
17443
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
17444
|
+
return Promise.resolve();
|
|
17445
|
+
}
|
|
17446
|
+
const tab = window.open("", "_blank");
|
|
17447
|
+
if (tab === null) {
|
|
17448
|
+
return Promise.resolve();
|
|
17449
|
+
}
|
|
17450
|
+
event.preventDefault();
|
|
17451
|
+
tab.opener = null;
|
|
17452
|
+
return fetchUrl().then(
|
|
17453
|
+
(url) => url || storedUrl,
|
|
17454
|
+
() => storedUrl
|
|
17455
|
+
).then((url) => {
|
|
17456
|
+
tab.location.href = url;
|
|
17457
|
+
});
|
|
17458
|
+
}
|
|
17459
|
+
|
|
17062
17460
|
// src/utils/markdown.tsx
|
|
17063
17461
|
import { Fragment } from "react";
|
|
17064
17462
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -17811,7 +18209,7 @@ var reducer = (state, action) => {
|
|
|
17811
18209
|
// src/context/EmbedProvider.tsx
|
|
17812
18210
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
17813
18211
|
var getCustomHeaders = (sessionId) => ({
|
|
17814
|
-
"X-Schematic-Components-Version": "2.
|
|
18212
|
+
"X-Schematic-Components-Version": "2.38.0",
|
|
17815
18213
|
"X-Schematic-Session-ID": sessionId
|
|
17816
18214
|
});
|
|
17817
18215
|
var normalizeCurrencyFilter = (filter2) => {
|
|
@@ -18199,6 +18597,12 @@ var EmbedProvider = ({
|
|
|
18199
18597
|
() => (0, import_debounce2.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, LEADING_DEBOUNCE_SETTINGS),
|
|
18200
18598
|
[listInvoices]
|
|
18201
18599
|
);
|
|
18600
|
+
const getInvoiceLink = useCallback2(
|
|
18601
|
+
async (billingInvoiceId) => {
|
|
18602
|
+
return checkoutApi?.getInvoiceLink({ billingInvoiceId });
|
|
18603
|
+
},
|
|
18604
|
+
[checkoutApi]
|
|
18605
|
+
);
|
|
18202
18606
|
const getCreditUsageByUser = useCallback2(
|
|
18203
18607
|
async (billingCreditId, limit) => {
|
|
18204
18608
|
return checkoutApi?.getCreditUsageByUser({ billingCreditId, limit });
|
|
@@ -18393,6 +18797,7 @@ var EmbedProvider = ({
|
|
|
18393
18797
|
getUpcomingInvoice: debouncedGetUpcomingInvoice,
|
|
18394
18798
|
getCustomerBalance: debouncedGetCustomerBalance,
|
|
18395
18799
|
listInvoices: debouncedListInvoices,
|
|
18800
|
+
getInvoiceLink,
|
|
18396
18801
|
getCreditUsageByUser: debouncedGetCreditUsageByUser,
|
|
18397
18802
|
getFeatureUsageByUser: debouncedGetFeatureUsageByUser,
|
|
18398
18803
|
finishCheckout,
|
|
@@ -27403,12 +27808,13 @@ function formatInvoices(invoices, locale, options) {
|
|
|
27403
27808
|
const dateA = a2.dueDate ?? a2.createdAt;
|
|
27404
27809
|
const dateB = b2.dueDate ?? b2.createdAt;
|
|
27405
27810
|
return +dateB - +dateA;
|
|
27406
|
-
}).map(({ amountDue, dueDate, createdAt, url, currency }) => {
|
|
27811
|
+
}).map(({ amountDue, dueDate, createdAt, id, url, currency }) => {
|
|
27407
27812
|
const formatted = formatCurrency(Math.abs(amountDue), {
|
|
27408
27813
|
locale,
|
|
27409
27814
|
currency
|
|
27410
27815
|
});
|
|
27411
27816
|
return {
|
|
27817
|
+
id,
|
|
27412
27818
|
amount: amountDue < 0 ? `(${formatted})` : formatted,
|
|
27413
27819
|
amountDue,
|
|
27414
27820
|
date: toPrettyDate(dueDate ?? createdAt, { locale }),
|
|
@@ -27419,7 +27825,7 @@ function formatInvoices(invoices, locale, options) {
|
|
|
27419
27825
|
var Invoices = forwardRef11(({ className, ...rest }, ref) => {
|
|
27420
27826
|
const props = resolveDesignProps3(rest);
|
|
27421
27827
|
const { t: t3, locale } = useTranslation();
|
|
27422
|
-
const { data, listInvoices, settings } = useEmbed();
|
|
27828
|
+
const { data, getInvoiceLink, listInvoices, settings } = useEmbed();
|
|
27423
27829
|
const [isLoading, setIsLoading] = useState16(false);
|
|
27424
27830
|
const [error, setError] = useState16();
|
|
27425
27831
|
const [rawInvoices, setInvoices] = useState16(
|
|
@@ -27496,7 +27902,7 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
|
|
|
27496
27902
|
props.header.isVisible && /* @__PURE__ */ jsx54(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsx54(Text, { display: props.header.fontStyle, children: t3("Invoices") }) }),
|
|
27497
27903
|
invoices.length > 0 ? /* @__PURE__ */ jsxs39(Fragment20, { children: [
|
|
27498
27904
|
/* @__PURE__ */ jsx54(Flex, { $flexDirection: "column", $gap: "0.5rem", children: visibleInvoices.items.map(
|
|
27499
|
-
({ date, amount, amountDue, url }, index) => {
|
|
27905
|
+
({ id, date, amount, amountDue, url }, index) => {
|
|
27500
27906
|
return /* @__PURE__ */ jsxs39(
|
|
27501
27907
|
Flex,
|
|
27502
27908
|
{
|
|
@@ -27507,11 +27913,18 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
|
|
|
27507
27913
|
Text,
|
|
27508
27914
|
{
|
|
27509
27915
|
display: props.date.fontStyle,
|
|
27510
|
-
...url && {
|
|
27916
|
+
...id && url && {
|
|
27511
27917
|
as: "a",
|
|
27512
27918
|
href: url,
|
|
27513
27919
|
target: "_blank",
|
|
27514
|
-
rel: "noreferrer"
|
|
27920
|
+
rel: "noreferrer",
|
|
27921
|
+
onClick: (event) => {
|
|
27922
|
+
void openInvoiceLink(
|
|
27923
|
+
event,
|
|
27924
|
+
url,
|
|
27925
|
+
async () => (await getInvoiceLink(id))?.data.url
|
|
27926
|
+
);
|
|
27927
|
+
}
|
|
27515
27928
|
},
|
|
27516
27929
|
$color: url ? settings.theme.typography.link.color : settings.theme.typography.text.color,
|
|
27517
27930
|
children: date
|