@cmssy/next 2.6.0 → 2.7.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/index.cjs +12 -2
- package/dist/index.js +12 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1587,10 +1587,10 @@ function createCmssyAuthMiddleware(config) {
|
|
|
1587
1587
|
return refreshed;
|
|
1588
1588
|
};
|
|
1589
1589
|
}
|
|
1590
|
-
var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $limit: Int, $offset: Int, $sort: String) {
|
|
1590
|
+
var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $locale: String, $limit: Int, $offset: Int, $sort: String) {
|
|
1591
1591
|
public {
|
|
1592
1592
|
model {
|
|
1593
|
-
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, limit: $limit, offset: $offset, sort: $sort) {
|
|
1593
|
+
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, locale: $locale, limit: $limit, offset: $offset, sort: $sort) {
|
|
1594
1594
|
total
|
|
1595
1595
|
hasMore
|
|
1596
1596
|
items {
|
|
@@ -1603,8 +1603,16 @@ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!,
|
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
1605
|
}`;
|
|
1606
|
+
async function requestLocale(config) {
|
|
1607
|
+
try {
|
|
1608
|
+
return await getCmssyLocale(config);
|
|
1609
|
+
} catch {
|
|
1610
|
+
return null;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1606
1613
|
async function fetchProducts(config, options) {
|
|
1607
1614
|
const workspaceId = await react.resolveWorkspaceId(config);
|
|
1615
|
+
const locale = options.locale ?? await requestLocale(config);
|
|
1608
1616
|
const data = await react.graphqlRequest(
|
|
1609
1617
|
config,
|
|
1610
1618
|
PRODUCTS_QUERY,
|
|
@@ -1613,6 +1621,7 @@ async function fetchProducts(config, options) {
|
|
|
1613
1621
|
modelSlug: options.modelSlug,
|
|
1614
1622
|
filter: options.filter ?? {},
|
|
1615
1623
|
stockState: options.stockState ?? null,
|
|
1624
|
+
locale,
|
|
1616
1625
|
limit: options.limit ?? 50,
|
|
1617
1626
|
offset: options.offset ?? 0,
|
|
1618
1627
|
sort: options.sort ?? null
|
|
@@ -1626,6 +1635,7 @@ async function fetchProduct(config, options) {
|
|
|
1626
1635
|
const page = await fetchProducts(config, {
|
|
1627
1636
|
modelSlug: options.modelSlug,
|
|
1628
1637
|
filter: { [options.slugField ?? "slug"]: options.slug },
|
|
1638
|
+
locale: options.locale,
|
|
1629
1639
|
limit: 1
|
|
1630
1640
|
});
|
|
1631
1641
|
return page.items[0] ?? null;
|
package/dist/index.js
CHANGED
|
@@ -1586,10 +1586,10 @@ function createCmssyAuthMiddleware(config) {
|
|
|
1586
1586
|
return refreshed;
|
|
1587
1587
|
};
|
|
1588
1588
|
}
|
|
1589
|
-
var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $limit: Int, $offset: Int, $sort: String) {
|
|
1589
|
+
var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $locale: String, $limit: Int, $offset: Int, $sort: String) {
|
|
1590
1590
|
public {
|
|
1591
1591
|
model {
|
|
1592
|
-
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, limit: $limit, offset: $offset, sort: $sort) {
|
|
1592
|
+
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, locale: $locale, limit: $limit, offset: $offset, sort: $sort) {
|
|
1593
1593
|
total
|
|
1594
1594
|
hasMore
|
|
1595
1595
|
items {
|
|
@@ -1602,8 +1602,16 @@ var PRODUCTS_QUERY = `query Products($workspaceId: String!, $modelSlug: String!,
|
|
|
1602
1602
|
}
|
|
1603
1603
|
}
|
|
1604
1604
|
}`;
|
|
1605
|
+
async function requestLocale(config) {
|
|
1606
|
+
try {
|
|
1607
|
+
return await getCmssyLocale(config);
|
|
1608
|
+
} catch {
|
|
1609
|
+
return null;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1605
1612
|
async function fetchProducts(config, options) {
|
|
1606
1613
|
const workspaceId = await resolveWorkspaceId(config);
|
|
1614
|
+
const locale = options.locale ?? await requestLocale(config);
|
|
1607
1615
|
const data = await graphqlRequest(
|
|
1608
1616
|
config,
|
|
1609
1617
|
PRODUCTS_QUERY,
|
|
@@ -1612,6 +1620,7 @@ async function fetchProducts(config, options) {
|
|
|
1612
1620
|
modelSlug: options.modelSlug,
|
|
1613
1621
|
filter: options.filter ?? {},
|
|
1614
1622
|
stockState: options.stockState ?? null,
|
|
1623
|
+
locale,
|
|
1615
1624
|
limit: options.limit ?? 50,
|
|
1616
1625
|
offset: options.offset ?? 0,
|
|
1617
1626
|
sort: options.sort ?? null
|
|
@@ -1625,6 +1634,7 @@ async function fetchProduct(config, options) {
|
|
|
1625
1634
|
const page = await fetchProducts(config, {
|
|
1626
1635
|
modelSlug: options.modelSlug,
|
|
1627
1636
|
filter: { [options.slugField ?? "slug"]: options.slug },
|
|
1637
|
+
locale: options.locale,
|
|
1628
1638
|
limit: 1
|
|
1629
1639
|
});
|
|
1630
1640
|
return page.items[0] ?? null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"tsup": "^8.3.0",
|
|
56
56
|
"typescript": "^5.6.0",
|
|
57
57
|
"vitest": "^2.1.0",
|
|
58
|
-
"@cmssy/react": "2.
|
|
58
|
+
"@cmssy/react": "2.7.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"jose": "^6.2.3",
|
|
62
|
-
"@cmssy/types": "0.
|
|
62
|
+
"@cmssy/types": "0.27.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsup",
|