@uniformdev/canvas 19.87.0 → 19.88.1-alpha.7
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 +1343 -605
- package/dist/index.d.ts +1343 -605
- package/dist/index.esm.js +78 -14
- package/dist/index.js +83 -17
- package/dist/index.mjs +78 -14
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
@@ -634,13 +634,15 @@ var unstable_CompositionRelationshipClient = class extends ApiClient3 {
|
|
634
634
|
super(options);
|
635
635
|
this.getDefinitionsRelationships = async ({
|
636
636
|
definitionIds,
|
637
|
-
withCompositions
|
637
|
+
withCompositions,
|
638
|
+
entityType = "composition"
|
638
639
|
}) => {
|
639
640
|
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
640
641
|
type: "definition",
|
641
642
|
projectId: this._options.projectId,
|
642
643
|
definitionIds: definitionIds.join(","),
|
643
|
-
withCompositions
|
644
|
+
withCompositions,
|
645
|
+
entityType
|
644
646
|
});
|
645
647
|
return this.apiClient(url);
|
646
648
|
};
|
@@ -1638,18 +1640,22 @@ function extractLocales({ component }) {
|
|
1638
1640
|
});
|
1639
1641
|
return variations;
|
1640
1642
|
}
|
1641
|
-
function localize({
|
1642
|
-
composition
|
1643
|
-
locale
|
1644
|
-
}) {
|
1645
|
-
walkNodeTree(composition, ({ type, node, actions }) => {
|
1643
|
+
function localize(options) {
|
1644
|
+
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1645
|
+
const locale = options.locale;
|
1646
|
+
walkNodeTree(nodes, ({ type, node, actions }) => {
|
1646
1647
|
if (type !== "component") {
|
1647
|
-
|
1648
|
+
if (typeof locale === "string") {
|
1649
|
+
localizeProperties(node.fields, locale);
|
1650
|
+
}
|
1648
1651
|
return;
|
1649
1652
|
}
|
1653
|
+
if (typeof locale === "string") {
|
1654
|
+
localizeProperties(getPropertiesValue(node), locale);
|
1655
|
+
}
|
1650
1656
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1651
1657
|
const locales = extractLocales({ component: node });
|
1652
|
-
const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
|
1658
|
+
const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1653
1659
|
let replaceComponent;
|
1654
1660
|
if (resolvedLocale) {
|
1655
1661
|
replaceComponent = locales[resolvedLocale];
|
@@ -1666,6 +1672,25 @@ function localize({
|
|
1666
1672
|
}
|
1667
1673
|
});
|
1668
1674
|
}
|
1675
|
+
function localizeProperties(properties, locale) {
|
1676
|
+
if (!properties) {
|
1677
|
+
return void 0;
|
1678
|
+
}
|
1679
|
+
Object.entries(properties).forEach(([key, property]) => {
|
1680
|
+
var _a;
|
1681
|
+
if (!locale) {
|
1682
|
+
delete property.locales;
|
1683
|
+
}
|
1684
|
+
const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
|
1685
|
+
if (currentLocaleValue !== void 0) {
|
1686
|
+
property.value = currentLocaleValue;
|
1687
|
+
}
|
1688
|
+
delete property.locales;
|
1689
|
+
if (property.value === void 0) {
|
1690
|
+
delete properties[key];
|
1691
|
+
}
|
1692
|
+
});
|
1693
|
+
}
|
1669
1694
|
|
1670
1695
|
// src/enhancement/UniqueBatchEntries.ts
|
1671
1696
|
var UniqueBatchEntries = class {
|
@@ -1812,6 +1837,39 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1812
1837
|
} while (componentQueue.length > 0);
|
1813
1838
|
}
|
1814
1839
|
|
1840
|
+
// src/LocaleClient.ts
|
1841
|
+
import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
|
1842
|
+
var localesUrl = "/api/v1/locales";
|
1843
|
+
var LocaleClient = class extends ApiClient7 {
|
1844
|
+
constructor(options) {
|
1845
|
+
super(options);
|
1846
|
+
}
|
1847
|
+
/** Fetches all locales for a project */
|
1848
|
+
async get(options) {
|
1849
|
+
const { projectId } = this.options;
|
1850
|
+
const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
|
1851
|
+
return await this.apiClient(fetchUri);
|
1852
|
+
}
|
1853
|
+
/** Updates or creates (based on id) a locale */
|
1854
|
+
async upsert(body) {
|
1855
|
+
const fetchUri = this.createUrl(localesUrl);
|
1856
|
+
await this.apiClient(fetchUri, {
|
1857
|
+
method: "PUT",
|
1858
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1859
|
+
expectNoContent: true
|
1860
|
+
});
|
1861
|
+
}
|
1862
|
+
/** Deletes a locale */
|
1863
|
+
async remove(body) {
|
1864
|
+
const fetchUri = this.createUrl(localesUrl);
|
1865
|
+
await this.apiClient(fetchUri, {
|
1866
|
+
method: "DELETE",
|
1867
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1868
|
+
expectNoContent: true
|
1869
|
+
});
|
1870
|
+
}
|
1871
|
+
};
|
1872
|
+
|
1815
1873
|
// src/utils/hash.ts
|
1816
1874
|
var generateHash = ({
|
1817
1875
|
composition,
|
@@ -2169,9 +2227,9 @@ function subscribeToComposition({
|
|
2169
2227
|
}
|
2170
2228
|
|
2171
2229
|
// src/PromptClient.ts
|
2172
|
-
import { ApiClient as
|
2230
|
+
import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
|
2173
2231
|
var PromptsUrl = "/api/v1/prompts";
|
2174
|
-
var PromptClient = class extends
|
2232
|
+
var PromptClient = class extends ApiClient8 {
|
2175
2233
|
constructor(options) {
|
2176
2234
|
super(options);
|
2177
2235
|
}
|
@@ -2202,9 +2260,9 @@ var PromptClient = class extends ApiClient7 {
|
|
2202
2260
|
};
|
2203
2261
|
|
2204
2262
|
// src/RouteClient.ts
|
2205
|
-
import { ApiClient as
|
2263
|
+
import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
|
2206
2264
|
var ROUTE_URL = "/api/v1/route";
|
2207
|
-
var RouteClient = class extends
|
2265
|
+
var RouteClient = class extends ApiClient9 {
|
2208
2266
|
constructor(options) {
|
2209
2267
|
var _a;
|
2210
2268
|
if (!options.limitPolicy) {
|
@@ -2221,6 +2279,9 @@ var RouteClient = class extends ApiClient8 {
|
|
2221
2279
|
}
|
2222
2280
|
};
|
2223
2281
|
|
2282
|
+
// src/types/locales.ts
|
2283
|
+
var LOCALE_DYNAMIC_INPUT_NAME = "locale";
|
2284
|
+
|
2224
2285
|
// src/utils/createApiEnhancer.ts
|
2225
2286
|
var createUniformApiEnhancer = ({ apiUrl }) => {
|
2226
2287
|
return async (message) => {
|
@@ -2252,7 +2313,8 @@ function convertEntryToPutEntry(entry) {
|
|
2252
2313
|
_id: entry.entry._id,
|
2253
2314
|
_name: entry.entry._name,
|
2254
2315
|
_slug: entry.entry._slug,
|
2255
|
-
fields: entry.entry.fields
|
2316
|
+
fields: entry.entry.fields,
|
2317
|
+
_locales: entry.entry._locales
|
2256
2318
|
},
|
2257
2319
|
state: entry.state,
|
2258
2320
|
projectId: entry.projectId
|
@@ -2585,6 +2647,8 @@ export {
|
|
2585
2647
|
IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
|
2586
2648
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2587
2649
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2650
|
+
LOCALE_DYNAMIC_INPUT_NAME,
|
2651
|
+
LocaleClient,
|
2588
2652
|
PLACEHOLDER_ID,
|
2589
2653
|
PromptClient,
|
2590
2654
|
RouteClient,
|
package/dist/index.js
CHANGED
@@ -286,7 +286,7 @@ __export(src_exports, {
|
|
286
286
|
ATTRIBUTE_PARAMETER_TYPE: () => ATTRIBUTE_PARAMETER_TYPE,
|
287
287
|
ATTRIBUTE_PARAMETER_VALUE: () => ATTRIBUTE_PARAMETER_VALUE,
|
288
288
|
ATTRIBUTE_PLACEHOLDER: () => ATTRIBUTE_PLACEHOLDER,
|
289
|
-
ApiClientError: () =>
|
289
|
+
ApiClientError: () => import_api11.ApiClientError,
|
290
290
|
BatchEntry: () => BatchEntry,
|
291
291
|
CANVAS_BLOCK_PARAM_TYPE: () => CANVAS_BLOCK_PARAM_TYPE,
|
292
292
|
CANVAS_DRAFT_STATE: () => CANVAS_DRAFT_STATE,
|
@@ -323,6 +323,8 @@ __export(src_exports, {
|
|
323
323
|
IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
|
324
324
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM: () => IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
325
325
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE: () => IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
326
|
+
LOCALE_DYNAMIC_INPUT_NAME: () => LOCALE_DYNAMIC_INPUT_NAME,
|
327
|
+
LocaleClient: () => LocaleClient,
|
326
328
|
PLACEHOLDER_ID: () => PLACEHOLDER_ID,
|
327
329
|
PromptClient: () => PromptClient,
|
328
330
|
RouteClient: () => RouteClient,
|
@@ -759,13 +761,15 @@ var unstable_CompositionRelationshipClient = class extends import_api4.ApiClient
|
|
759
761
|
super(options);
|
760
762
|
this.getDefinitionsRelationships = async ({
|
761
763
|
definitionIds,
|
762
|
-
withCompositions
|
764
|
+
withCompositions,
|
765
|
+
entityType = "composition"
|
763
766
|
}) => {
|
764
767
|
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
765
768
|
type: "definition",
|
766
769
|
projectId: this._options.projectId,
|
767
770
|
definitionIds: definitionIds.join(","),
|
768
|
-
withCompositions
|
771
|
+
withCompositions,
|
772
|
+
entityType
|
769
773
|
});
|
770
774
|
return this.apiClient(url);
|
771
775
|
};
|
@@ -1763,18 +1767,22 @@ function extractLocales({ component }) {
|
|
1763
1767
|
});
|
1764
1768
|
return variations;
|
1765
1769
|
}
|
1766
|
-
function localize({
|
1767
|
-
composition
|
1768
|
-
locale
|
1769
|
-
}) {
|
1770
|
-
walkNodeTree(composition, ({ type, node, actions }) => {
|
1770
|
+
function localize(options) {
|
1771
|
+
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1772
|
+
const locale = options.locale;
|
1773
|
+
walkNodeTree(nodes, ({ type, node, actions }) => {
|
1771
1774
|
if (type !== "component") {
|
1772
|
-
|
1775
|
+
if (typeof locale === "string") {
|
1776
|
+
localizeProperties(node.fields, locale);
|
1777
|
+
}
|
1773
1778
|
return;
|
1774
1779
|
}
|
1780
|
+
if (typeof locale === "string") {
|
1781
|
+
localizeProperties(getPropertiesValue(node), locale);
|
1782
|
+
}
|
1775
1783
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1776
1784
|
const locales = extractLocales({ component: node });
|
1777
|
-
const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
|
1785
|
+
const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1778
1786
|
let replaceComponent;
|
1779
1787
|
if (resolvedLocale) {
|
1780
1788
|
replaceComponent = locales[resolvedLocale];
|
@@ -1791,6 +1799,25 @@ function localize({
|
|
1791
1799
|
}
|
1792
1800
|
});
|
1793
1801
|
}
|
1802
|
+
function localizeProperties(properties, locale) {
|
1803
|
+
if (!properties) {
|
1804
|
+
return void 0;
|
1805
|
+
}
|
1806
|
+
Object.entries(properties).forEach(([key, property]) => {
|
1807
|
+
var _a;
|
1808
|
+
if (!locale) {
|
1809
|
+
delete property.locales;
|
1810
|
+
}
|
1811
|
+
const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
|
1812
|
+
if (currentLocaleValue !== void 0) {
|
1813
|
+
property.value = currentLocaleValue;
|
1814
|
+
}
|
1815
|
+
delete property.locales;
|
1816
|
+
if (property.value === void 0) {
|
1817
|
+
delete properties[key];
|
1818
|
+
}
|
1819
|
+
});
|
1820
|
+
}
|
1794
1821
|
|
1795
1822
|
// src/enhancement/UniqueBatchEntries.ts
|
1796
1823
|
var UniqueBatchEntries = class {
|
@@ -1937,6 +1964,39 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1937
1964
|
} while (componentQueue.length > 0);
|
1938
1965
|
}
|
1939
1966
|
|
1967
|
+
// src/LocaleClient.ts
|
1968
|
+
var import_api8 = require("@uniformdev/context/api");
|
1969
|
+
var localesUrl = "/api/v1/locales";
|
1970
|
+
var LocaleClient = class extends import_api8.ApiClient {
|
1971
|
+
constructor(options) {
|
1972
|
+
super(options);
|
1973
|
+
}
|
1974
|
+
/** Fetches all locales for a project */
|
1975
|
+
async get(options) {
|
1976
|
+
const { projectId } = this.options;
|
1977
|
+
const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
|
1978
|
+
return await this.apiClient(fetchUri);
|
1979
|
+
}
|
1980
|
+
/** Updates or creates (based on id) a locale */
|
1981
|
+
async upsert(body) {
|
1982
|
+
const fetchUri = this.createUrl(localesUrl);
|
1983
|
+
await this.apiClient(fetchUri, {
|
1984
|
+
method: "PUT",
|
1985
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1986
|
+
expectNoContent: true
|
1987
|
+
});
|
1988
|
+
}
|
1989
|
+
/** Deletes a locale */
|
1990
|
+
async remove(body) {
|
1991
|
+
const fetchUri = this.createUrl(localesUrl);
|
1992
|
+
await this.apiClient(fetchUri, {
|
1993
|
+
method: "DELETE",
|
1994
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1995
|
+
expectNoContent: true
|
1996
|
+
});
|
1997
|
+
}
|
1998
|
+
};
|
1999
|
+
|
1940
2000
|
// src/utils/hash.ts
|
1941
2001
|
var generateHash = ({
|
1942
2002
|
composition,
|
@@ -2294,9 +2354,9 @@ function subscribeToComposition({
|
|
2294
2354
|
}
|
2295
2355
|
|
2296
2356
|
// src/PromptClient.ts
|
2297
|
-
var
|
2357
|
+
var import_api9 = require("@uniformdev/context/api");
|
2298
2358
|
var PromptsUrl = "/api/v1/prompts";
|
2299
|
-
var PromptClient = class extends
|
2359
|
+
var PromptClient = class extends import_api9.ApiClient {
|
2300
2360
|
constructor(options) {
|
2301
2361
|
super(options);
|
2302
2362
|
}
|
@@ -2327,9 +2387,9 @@ var PromptClient = class extends import_api8.ApiClient {
|
|
2327
2387
|
};
|
2328
2388
|
|
2329
2389
|
// src/RouteClient.ts
|
2330
|
-
var
|
2390
|
+
var import_api10 = require("@uniformdev/context/api");
|
2331
2391
|
var ROUTE_URL = "/api/v1/route";
|
2332
|
-
var RouteClient = class extends
|
2392
|
+
var RouteClient = class extends import_api10.ApiClient {
|
2333
2393
|
constructor(options) {
|
2334
2394
|
var _a;
|
2335
2395
|
if (!options.limitPolicy) {
|
@@ -2346,6 +2406,9 @@ var RouteClient = class extends import_api9.ApiClient {
|
|
2346
2406
|
}
|
2347
2407
|
};
|
2348
2408
|
|
2409
|
+
// src/types/locales.ts
|
2410
|
+
var LOCALE_DYNAMIC_INPUT_NAME = "locale";
|
2411
|
+
|
2349
2412
|
// src/utils/createApiEnhancer.ts
|
2350
2413
|
var createUniformApiEnhancer = ({ apiUrl }) => {
|
2351
2414
|
return async (message) => {
|
@@ -2377,7 +2440,8 @@ function convertEntryToPutEntry(entry) {
|
|
2377
2440
|
_id: entry.entry._id,
|
2378
2441
|
_name: entry.entry._name,
|
2379
2442
|
_slug: entry.entry._slug,
|
2380
|
-
fields: entry.entry.fields
|
2443
|
+
fields: entry.entry.fields,
|
2444
|
+
_locales: entry.entry._locales
|
2381
2445
|
},
|
2382
2446
|
state: entry.state,
|
2383
2447
|
projectId: entry.projectId
|
@@ -2661,8 +2725,8 @@ function handleRichTextNodeBinding(object, options) {
|
|
2661
2725
|
}
|
2662
2726
|
|
2663
2727
|
// src/index.ts
|
2664
|
-
var
|
2665
|
-
var CanvasClientError =
|
2728
|
+
var import_api11 = require("@uniformdev/context/api");
|
2729
|
+
var CanvasClientError = import_api11.ApiClientError;
|
2666
2730
|
// Annotate the CommonJS export names for ESM import in node:
|
2667
2731
|
0 && (module.exports = {
|
2668
2732
|
ASSETS_SOURCE_CUSTOM_URL,
|
@@ -2711,6 +2775,8 @@ var CanvasClientError = import_api10.ApiClientError;
|
|
2711
2775
|
IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
|
2712
2776
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2713
2777
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2778
|
+
LOCALE_DYNAMIC_INPUT_NAME,
|
2779
|
+
LocaleClient,
|
2714
2780
|
PLACEHOLDER_ID,
|
2715
2781
|
PromptClient,
|
2716
2782
|
RouteClient,
|
package/dist/index.mjs
CHANGED
@@ -634,13 +634,15 @@ var unstable_CompositionRelationshipClient = class extends ApiClient3 {
|
|
634
634
|
super(options);
|
635
635
|
this.getDefinitionsRelationships = async ({
|
636
636
|
definitionIds,
|
637
|
-
withCompositions
|
637
|
+
withCompositions,
|
638
|
+
entityType = "composition"
|
638
639
|
}) => {
|
639
640
|
const url = this.createUrl(COMPOSITION_RELATIONSHIP_URL, {
|
640
641
|
type: "definition",
|
641
642
|
projectId: this._options.projectId,
|
642
643
|
definitionIds: definitionIds.join(","),
|
643
|
-
withCompositions
|
644
|
+
withCompositions,
|
645
|
+
entityType
|
644
646
|
});
|
645
647
|
return this.apiClient(url);
|
646
648
|
};
|
@@ -1638,18 +1640,22 @@ function extractLocales({ component }) {
|
|
1638
1640
|
});
|
1639
1641
|
return variations;
|
1640
1642
|
}
|
1641
|
-
function localize({
|
1642
|
-
composition
|
1643
|
-
locale
|
1644
|
-
}) {
|
1645
|
-
walkNodeTree(composition, ({ type, node, actions }) => {
|
1643
|
+
function localize(options) {
|
1644
|
+
const nodes = "nodes" in options ? options.nodes : options.composition;
|
1645
|
+
const locale = options.locale;
|
1646
|
+
walkNodeTree(nodes, ({ type, node, actions }) => {
|
1646
1647
|
if (type !== "component") {
|
1647
|
-
|
1648
|
+
if (typeof locale === "string") {
|
1649
|
+
localizeProperties(node.fields, locale);
|
1650
|
+
}
|
1648
1651
|
return;
|
1649
1652
|
}
|
1653
|
+
if (typeof locale === "string") {
|
1654
|
+
localizeProperties(getPropertiesValue(node), locale);
|
1655
|
+
}
|
1650
1656
|
if (node.type === CANVAS_LOCALIZATION_TYPE) {
|
1651
1657
|
const locales = extractLocales({ component: node });
|
1652
|
-
const resolvedLocale = typeof locale === "string" ? locale : locale({ component: node, locales });
|
1658
|
+
const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
|
1653
1659
|
let replaceComponent;
|
1654
1660
|
if (resolvedLocale) {
|
1655
1661
|
replaceComponent = locales[resolvedLocale];
|
@@ -1666,6 +1672,25 @@ function localize({
|
|
1666
1672
|
}
|
1667
1673
|
});
|
1668
1674
|
}
|
1675
|
+
function localizeProperties(properties, locale) {
|
1676
|
+
if (!properties) {
|
1677
|
+
return void 0;
|
1678
|
+
}
|
1679
|
+
Object.entries(properties).forEach(([key, property]) => {
|
1680
|
+
var _a;
|
1681
|
+
if (!locale) {
|
1682
|
+
delete property.locales;
|
1683
|
+
}
|
1684
|
+
const currentLocaleValue = locale ? (_a = property.locales) == null ? void 0 : _a[locale] : void 0;
|
1685
|
+
if (currentLocaleValue !== void 0) {
|
1686
|
+
property.value = currentLocaleValue;
|
1687
|
+
}
|
1688
|
+
delete property.locales;
|
1689
|
+
if (property.value === void 0) {
|
1690
|
+
delete properties[key];
|
1691
|
+
}
|
1692
|
+
});
|
1693
|
+
}
|
1669
1694
|
|
1670
1695
|
// src/enhancement/UniqueBatchEntries.ts
|
1671
1696
|
var UniqueBatchEntries = class {
|
@@ -1812,6 +1837,39 @@ function walkComponentTree(component, visitor, initialContext) {
|
|
1812
1837
|
} while (componentQueue.length > 0);
|
1813
1838
|
}
|
1814
1839
|
|
1840
|
+
// src/LocaleClient.ts
|
1841
|
+
import { ApiClient as ApiClient7 } from "@uniformdev/context/api";
|
1842
|
+
var localesUrl = "/api/v1/locales";
|
1843
|
+
var LocaleClient = class extends ApiClient7 {
|
1844
|
+
constructor(options) {
|
1845
|
+
super(options);
|
1846
|
+
}
|
1847
|
+
/** Fetches all locales for a project */
|
1848
|
+
async get(options) {
|
1849
|
+
const { projectId } = this.options;
|
1850
|
+
const fetchUri = this.createUrl(localesUrl, { ...options, projectId });
|
1851
|
+
return await this.apiClient(fetchUri);
|
1852
|
+
}
|
1853
|
+
/** Updates or creates (based on id) a locale */
|
1854
|
+
async upsert(body) {
|
1855
|
+
const fetchUri = this.createUrl(localesUrl);
|
1856
|
+
await this.apiClient(fetchUri, {
|
1857
|
+
method: "PUT",
|
1858
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1859
|
+
expectNoContent: true
|
1860
|
+
});
|
1861
|
+
}
|
1862
|
+
/** Deletes a locale */
|
1863
|
+
async remove(body) {
|
1864
|
+
const fetchUri = this.createUrl(localesUrl);
|
1865
|
+
await this.apiClient(fetchUri, {
|
1866
|
+
method: "DELETE",
|
1867
|
+
body: JSON.stringify({ ...body, projectId: this.options.projectId }),
|
1868
|
+
expectNoContent: true
|
1869
|
+
});
|
1870
|
+
}
|
1871
|
+
};
|
1872
|
+
|
1815
1873
|
// src/utils/hash.ts
|
1816
1874
|
var generateHash = ({
|
1817
1875
|
composition,
|
@@ -2169,9 +2227,9 @@ function subscribeToComposition({
|
|
2169
2227
|
}
|
2170
2228
|
|
2171
2229
|
// src/PromptClient.ts
|
2172
|
-
import { ApiClient as
|
2230
|
+
import { ApiClient as ApiClient8 } from "@uniformdev/context/api";
|
2173
2231
|
var PromptsUrl = "/api/v1/prompts";
|
2174
|
-
var PromptClient = class extends
|
2232
|
+
var PromptClient = class extends ApiClient8 {
|
2175
2233
|
constructor(options) {
|
2176
2234
|
super(options);
|
2177
2235
|
}
|
@@ -2202,9 +2260,9 @@ var PromptClient = class extends ApiClient7 {
|
|
2202
2260
|
};
|
2203
2261
|
|
2204
2262
|
// src/RouteClient.ts
|
2205
|
-
import { ApiClient as
|
2263
|
+
import { ApiClient as ApiClient9 } from "@uniformdev/context/api";
|
2206
2264
|
var ROUTE_URL = "/api/v1/route";
|
2207
|
-
var RouteClient = class extends
|
2265
|
+
var RouteClient = class extends ApiClient9 {
|
2208
2266
|
constructor(options) {
|
2209
2267
|
var _a;
|
2210
2268
|
if (!options.limitPolicy) {
|
@@ -2221,6 +2279,9 @@ var RouteClient = class extends ApiClient8 {
|
|
2221
2279
|
}
|
2222
2280
|
};
|
2223
2281
|
|
2282
|
+
// src/types/locales.ts
|
2283
|
+
var LOCALE_DYNAMIC_INPUT_NAME = "locale";
|
2284
|
+
|
2224
2285
|
// src/utils/createApiEnhancer.ts
|
2225
2286
|
var createUniformApiEnhancer = ({ apiUrl }) => {
|
2226
2287
|
return async (message) => {
|
@@ -2252,7 +2313,8 @@ function convertEntryToPutEntry(entry) {
|
|
2252
2313
|
_id: entry.entry._id,
|
2253
2314
|
_name: entry.entry._name,
|
2254
2315
|
_slug: entry.entry._slug,
|
2255
|
-
fields: entry.entry.fields
|
2316
|
+
fields: entry.entry.fields,
|
2317
|
+
_locales: entry.entry._locales
|
2256
2318
|
},
|
2257
2319
|
state: entry.state,
|
2258
2320
|
projectId: entry.projectId
|
@@ -2585,6 +2647,8 @@ export {
|
|
2585
2647
|
IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
|
2586
2648
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
2587
2649
|
IS_RENDERED_BY_UNIFORM_ATTRIBUTE,
|
2650
|
+
LOCALE_DYNAMIC_INPUT_NAME,
|
2651
|
+
LocaleClient,
|
2588
2652
|
PLACEHOLDER_ID,
|
2589
2653
|
PromptClient,
|
2590
2654
|
RouteClient,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.88.1-alpha.7+69b3ccba4",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -38,8 +38,8 @@
|
|
38
38
|
"pusher-js": "8.2.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "19.
|
42
|
-
"@uniformdev/context": "19.
|
41
|
+
"@uniformdev/assets": "19.88.1-alpha.7+69b3ccba4",
|
42
|
+
"@uniformdev/context": "19.88.1-alpha.7+69b3ccba4",
|
43
43
|
"immer": "10.0.3"
|
44
44
|
},
|
45
45
|
"files": [
|
@@ -48,5 +48,5 @@
|
|
48
48
|
"publishConfig": {
|
49
49
|
"access": "public"
|
50
50
|
},
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "69b3ccba4050c4ff412c4f226f54a36d74cf9a39"
|
52
52
|
}
|