@salesforce/platform-sdk 11.44.4 → 11.45.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/data/index.js
CHANGED
|
@@ -245,7 +245,7 @@ const w = "Accept-Language", me = (r) => {
|
|
|
245
245
|
return u(r);
|
|
246
246
|
const [t, n] = r;
|
|
247
247
|
return (t instanceof Request && !n?.headers ? t.headers.has(w) : new Headers(n?.headers).has(w)) ? u(r) : u(b(w, e, r));
|
|
248
|
-
}, ye = "X-SFDC-Client-Name", be = "X-SFDC-Client-Version", ve = "@salesforce/platform-sdk", Se = "11.
|
|
248
|
+
}, ye = "X-SFDC-Client-Name", be = "X-SFDC-Client-Version", ve = "@salesforce/platform-sdk", Se = "11.45.0", ge = (r) => {
|
|
249
249
|
let e = b(ye, ve, r);
|
|
250
250
|
return e = b(be, Se, e), u(e);
|
|
251
251
|
}, we = "X-CSRF-Token";
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export { fetchI18nContext, createSalesforceDetector, reloadI18nContext, } from './salesforce-detector';
|
|
7
7
|
export type { I18nContext } from './salesforce-detector';
|
|
8
8
|
export { SalesforceBackend } from './salesforce-backend';
|
|
9
|
-
export type { SalesforceBackendOptions } from './salesforce-backend';
|
|
9
|
+
export type { SalesforceBackendOptions, LabelFallback } from './salesforce-backend';
|
|
10
10
|
export { createI18nFormatters } from './locale-format';
|
|
11
11
|
export type { I18nFormatters } from './locale-format';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/i18n/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
let
|
|
2
|
-
async function f(
|
|
3
|
-
if (
|
|
4
|
-
if (!
|
|
1
|
+
let l = null;
|
|
2
|
+
async function f(n) {
|
|
3
|
+
if (l) return l;
|
|
4
|
+
if (!n.graphql)
|
|
5
5
|
throw new Error("Data SDK GraphQL surface unavailable");
|
|
6
|
-
const
|
|
6
|
+
const r = await n.graphql.query({
|
|
7
7
|
operationName: "I18nDetect",
|
|
8
8
|
query: `
|
|
9
9
|
query I18nDetect {
|
|
@@ -21,29 +21,29 @@ async function f(a) {
|
|
|
21
21
|
}
|
|
22
22
|
`
|
|
23
23
|
});
|
|
24
|
-
if (!
|
|
24
|
+
if (!r.data)
|
|
25
25
|
throw new Error(
|
|
26
|
-
`I18nDetect query failed: ${JSON.stringify(
|
|
26
|
+
`I18nDetect query failed: ${JSON.stringify(r.errors ?? "no data, no errors")}`
|
|
27
27
|
);
|
|
28
|
-
const e =
|
|
29
|
-
return
|
|
28
|
+
const e = r.data.uiapi.platform.i18n;
|
|
29
|
+
return l = e, e;
|
|
30
30
|
}
|
|
31
|
-
async function
|
|
32
|
-
return
|
|
31
|
+
async function b(n) {
|
|
32
|
+
return l = null, f(n);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function g(n) {
|
|
35
35
|
return {
|
|
36
36
|
type: "languageDetector",
|
|
37
37
|
detect() {
|
|
38
|
-
return
|
|
38
|
+
return l?.lang;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const d = `
|
|
43
|
-
query Labels($ns: String!, $names: [String!]!, $locale: String) {
|
|
42
|
+
const d = "BASE_VALUE", m = `
|
|
43
|
+
query Labels($ns: String!, $names: [String!]!, $locale: String, $fallback: LabelFallback) {
|
|
44
44
|
uiapi {
|
|
45
45
|
platform {
|
|
46
|
-
labels(namespace: $ns, names: $names, locale: $locale) {
|
|
46
|
+
labels(namespace: $ns, names: $names, locale: $locale, fallback: $fallback) {
|
|
47
47
|
name
|
|
48
48
|
value
|
|
49
49
|
resolvedLocale
|
|
@@ -52,53 +52,58 @@ const d = `
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
`,
|
|
56
|
-
function
|
|
57
|
-
const e = [...new Set(
|
|
58
|
-
for (let
|
|
59
|
-
|
|
60
|
-
return
|
|
55
|
+
`, p = 100;
|
|
56
|
+
function h(n, r) {
|
|
57
|
+
const e = [...new Set(n)], t = [];
|
|
58
|
+
for (let a = 0; a < e.length; a += r)
|
|
59
|
+
t.push(e.slice(a, a + r));
|
|
60
|
+
return t;
|
|
61
61
|
}
|
|
62
|
-
function y(
|
|
63
|
-
const
|
|
64
|
-
for (const e of
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
(
|
|
62
|
+
function y(n) {
|
|
63
|
+
const r = {};
|
|
64
|
+
for (const e of n) {
|
|
65
|
+
const t = e.indexOf(":");
|
|
66
|
+
if (t === -1) continue;
|
|
67
|
+
const a = e.slice(0, t), o = e.slice(t + 1);
|
|
68
|
+
(r[a] ??= []).push(o);
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return r;
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class w {
|
|
73
73
|
type = "backend";
|
|
74
74
|
static type = "backend";
|
|
75
75
|
options = { dataSDK: {} };
|
|
76
76
|
grouped = {};
|
|
77
|
-
init(
|
|
77
|
+
init(r, e) {
|
|
78
78
|
this.options = e, this.grouped = y(e.labelManifest ?? []);
|
|
79
79
|
}
|
|
80
|
-
read(
|
|
81
|
-
this.loadLabels(
|
|
80
|
+
read(r, e, t) {
|
|
81
|
+
this.loadLabels(r, e).then((a) => t(null, a)).catch((a) => t(a, !1));
|
|
82
82
|
}
|
|
83
|
-
async loadLabels(
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
86
|
-
const { graphql:
|
|
87
|
-
if (!
|
|
83
|
+
async loadLabels(r, e) {
|
|
84
|
+
const t = this.grouped[e];
|
|
85
|
+
if (!t?.length) return {};
|
|
86
|
+
const { graphql: a } = this.options.dataSDK;
|
|
87
|
+
if (!a)
|
|
88
88
|
throw new Error("Data SDK GraphQL surface unavailable");
|
|
89
|
-
const o =
|
|
90
|
-
o.map((c) => this.queryBatch(
|
|
89
|
+
const o = h(t, p), u = await Promise.all(
|
|
90
|
+
o.map((c) => this.queryBatch(a, e, c, r))
|
|
91
91
|
), i = {};
|
|
92
92
|
for (const c of u)
|
|
93
|
-
for (const
|
|
94
|
-
|
|
93
|
+
for (const s of c)
|
|
94
|
+
s.value != null && (i[s.name] = s.value);
|
|
95
95
|
return i;
|
|
96
96
|
}
|
|
97
|
-
async queryBatch(
|
|
98
|
-
const o = await
|
|
97
|
+
async queryBatch(r, e, t, a) {
|
|
98
|
+
const o = await r.query({
|
|
99
99
|
operationName: "Labels",
|
|
100
|
-
query:
|
|
101
|
-
variables: {
|
|
100
|
+
query: m,
|
|
101
|
+
variables: {
|
|
102
|
+
ns: e,
|
|
103
|
+
names: t,
|
|
104
|
+
locale: a,
|
|
105
|
+
fallback: this.options.labelFallback ?? d
|
|
106
|
+
}
|
|
102
107
|
});
|
|
103
108
|
if (!o.data)
|
|
104
109
|
throw new Error(
|
|
@@ -107,36 +112,36 @@ class g {
|
|
|
107
112
|
return o.data.uiapi.platform.labels;
|
|
108
113
|
}
|
|
109
114
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
115
|
+
function L(n) {
|
|
116
|
+
const r = n.locale.replace(/_/g, "-") || void 0;
|
|
112
117
|
return {
|
|
113
|
-
formatDate(e,
|
|
114
|
-
return new Intl.DateTimeFormat(
|
|
115
|
-
timeZone:
|
|
116
|
-
...
|
|
118
|
+
formatDate(e, t) {
|
|
119
|
+
return new Intl.DateTimeFormat(r, {
|
|
120
|
+
timeZone: n.timeZone || void 0,
|
|
121
|
+
...t
|
|
117
122
|
}).format(e);
|
|
118
123
|
},
|
|
119
|
-
formatNumber(e,
|
|
120
|
-
return new Intl.NumberFormat(
|
|
124
|
+
formatNumber(e, t) {
|
|
125
|
+
return new Intl.NumberFormat(r, t).format(e);
|
|
121
126
|
},
|
|
122
|
-
formatCurrency(e,
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
127
|
+
formatCurrency(e, t) {
|
|
128
|
+
const a = t?.currency ?? n.currency;
|
|
129
|
+
if (!a)
|
|
125
130
|
throw new Error(
|
|
126
131
|
"createI18nFormatters: formatCurrency requires a currency code, but the i18n context did not provide one and none was passed in options."
|
|
127
132
|
);
|
|
128
|
-
return new Intl.NumberFormat(
|
|
133
|
+
return new Intl.NumberFormat(r, {
|
|
129
134
|
style: "currency",
|
|
130
|
-
...
|
|
131
|
-
currency:
|
|
135
|
+
...t,
|
|
136
|
+
currency: a
|
|
132
137
|
}).format(e);
|
|
133
138
|
}
|
|
134
139
|
};
|
|
135
140
|
}
|
|
136
141
|
export {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
w as SalesforceBackend,
|
|
143
|
+
L as createI18nFormatters,
|
|
144
|
+
g as createSalesforceDetector,
|
|
140
145
|
f as fetchI18nContext,
|
|
141
|
-
|
|
146
|
+
b as reloadI18nContext
|
|
142
147
|
};
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { DataSDK } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* How the server resolves a label with no translation for the requested locale.
|
|
4
|
+
* `BASE_VALUE` returns the org-default (base) value; `USER_DEFAULT` returns the
|
|
5
|
+
* logged-in user's language first; `NONE` returns nothing.
|
|
6
|
+
*/
|
|
7
|
+
export type LabelFallback = "BASE_VALUE" | "USER_DEFAULT" | "NONE";
|
|
2
8
|
export interface SalesforceBackendOptions {
|
|
3
9
|
dataSDK: DataSDK;
|
|
4
10
|
labelManifest?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Fallback strategy for labels with no translation for the requested locale.
|
|
13
|
+
* Defaults to `BASE_VALUE`. Pass `USER_DEFAULT` for the server's old behavior
|
|
14
|
+
* (prefer the user's language), for example on a guest / b2c site. Pass `NONE`
|
|
15
|
+
* to suppress fallback entirely: a label with no matching translation is then
|
|
16
|
+
* absent from the result map.
|
|
17
|
+
*
|
|
18
|
+
* Note: the GraphQL `labels()` server default is `USER_DEFAULT`; this SDK opts
|
|
19
|
+
* into `BASE_VALUE` because it resolves an explicit target locale, so direct
|
|
20
|
+
* GraphQL callers and the SDK intentionally differ on the default.
|
|
21
|
+
*/
|
|
22
|
+
labelFallback?: LabelFallback;
|
|
5
23
|
}
|
|
6
24
|
type ReadCallback = (err: unknown, data: Record<string, string> | false) => void;
|
|
7
25
|
export declare class SalesforceBackend {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesforce-backend.d.ts","sourceRoot":"","sources":["../../src/i18n/salesforce-backend.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,wBAAwB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"salesforce-backend.d.ts","sourceRoot":"","sources":["../../src/i18n/salesforce-backend.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,MAAM,CAAC;AASnE,MAAM,WAAW,wBAAwB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B;AAeD,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC;AA0CjF,qBAAa,iBAAiB;IAC7B,IAAI,EAAG,SAAS,CAAU;IAC1B,MAAM,CAAC,IAAI,EAAG,SAAS,CAAU;IAEjC,OAAO,CAAC,OAAO,CAA6C;IAC5D,OAAO,CAAC,OAAO,CAAgC;IAE/C,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,wBAAwB,GAAG,IAAI;IAKjE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;YAMzD,UAAU;YA2BV,UAAU;CA4BxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.45.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
124
124
|
"@conduit-client/service-retry": "3.19.6",
|
|
125
125
|
"@conduit-client/utils": "3.19.6",
|
|
126
|
-
"@salesforce/jsonrpc": "^11.
|
|
126
|
+
"@salesforce/jsonrpc": "^11.45.0",
|
|
127
127
|
"@salesforce/sf-embedding-bridge": "2.2.5-rc.2"
|
|
128
128
|
},
|
|
129
129
|
"peerDependencies": {
|