@objectstack/client 7.3.0 → 7.4.1
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/index.d.mts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -2714,6 +2714,7 @@ var ObjectStackClient = class {
|
|
|
2714
2714
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
2715
2715
|
this.token = config.token;
|
|
2716
2716
|
this.environmentId = config.environmentId;
|
|
2717
|
+
this.locale = config.locale;
|
|
2717
2718
|
this.fetchImpl = config.fetch || globalThis.fetch.bind(globalThis);
|
|
2718
2719
|
this.logger = config.logger || createLogger({
|
|
2719
2720
|
level: config.debug ? "debug" : "info",
|
|
@@ -2848,6 +2849,23 @@ var ObjectStackClient = class {
|
|
|
2848
2849
|
getProjectId() {
|
|
2849
2850
|
return this.environmentId;
|
|
2850
2851
|
}
|
|
2852
|
+
/**
|
|
2853
|
+
* Update the active UI locale used for subsequent requests. Apps should
|
|
2854
|
+
* call this from their language switcher so server-translated metadata
|
|
2855
|
+
* (object/field labels, view headers, action text) follows the in-app
|
|
2856
|
+
* language without a page refresh. Pass `undefined` to clear and fall
|
|
2857
|
+
* back to the browser's `Accept-Language` (issue #1319).
|
|
2858
|
+
*/
|
|
2859
|
+
setLocale(locale) {
|
|
2860
|
+
this.locale = locale;
|
|
2861
|
+
this.logger.debug("Active locale changed", { locale });
|
|
2862
|
+
}
|
|
2863
|
+
/**
|
|
2864
|
+
* Current active UI locale (if set).
|
|
2865
|
+
*/
|
|
2866
|
+
getLocale() {
|
|
2867
|
+
return this.locale;
|
|
2868
|
+
}
|
|
2851
2869
|
/**
|
|
2852
2870
|
* Event Subscription API
|
|
2853
2871
|
* Provides real-time event subscriptions for metadata and data changes
|
|
@@ -2891,6 +2909,9 @@ var ObjectStackClient = class {
|
|
|
2891
2909
|
if (this.environmentId) {
|
|
2892
2910
|
headers["X-Environment-Id"] = this.environmentId;
|
|
2893
2911
|
}
|
|
2912
|
+
if (this.locale && !Object.keys(headers).some((h) => h.toLowerCase() === "accept-language")) {
|
|
2913
|
+
headers["Accept-Language"] = this.locale;
|
|
2914
|
+
}
|
|
2894
2915
|
const res = await this.fetchImpl(url, { ...options, headers });
|
|
2895
2916
|
this.logger.debug("HTTP response", {
|
|
2896
2917
|
method: options.method || "GET",
|