sanity 5.29.0-next.7 → 5.29.0-next.8
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/lib/_chunks-es/version.js +2 -2
- package/lib/index.js +70 -41
- package/lib/index.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "5.29.0-next.
|
|
1
|
+
var version = "5.29.0-next.8+472c314f72";
|
|
2
2
|
let buildVersion;
|
|
3
3
|
try {
|
|
4
4
|
buildVersion = process.env.PKG_BUILD_VERSION;
|
|
@@ -7,7 +7,7 @@ try {
|
|
|
7
7
|
try {
|
|
8
8
|
buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
|
|
9
9
|
// and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
|
|
10
|
-
"5.29.0-next.
|
|
10
|
+
"5.29.0-next.8+472c314f72";
|
|
11
11
|
} catch {
|
|
12
12
|
}
|
|
13
13
|
const SANITY_VERSION = buildVersion || `${version}-dev`;
|
package/lib/index.js
CHANGED
|
@@ -81387,26 +81387,84 @@ const TASKS_NAME = "sanity/tasks", tasks = definePlugin({
|
|
|
81387
81387
|
locale: "en-US",
|
|
81388
81388
|
namespace: variantsLocaleNamespace,
|
|
81389
81389
|
resources: () => import("./_chunks-es/resources7.js")
|
|
81390
|
-
}, VARIANT_DOCUMENT_TYPE = "system.variant", VARIANT_DOCUMENTS_PATH = "variants", VARIANTS_STUDIO_CLIENT_OPTIONS = {
|
|
81390
|
+
}, VARIANT_DOCUMENT_TYPE = "system.variant", VARIANT_DOCUMENTS_PATH = "_.variants", VARIANTS_STUDIO_CLIENT_OPTIONS = {
|
|
81391
81391
|
// TBD; using today for now
|
|
81392
81392
|
apiVersion: "X"
|
|
81393
|
-
}
|
|
81393
|
+
}, VARIANT_ID_PREFIX = `${VARIANT_DOCUMENTS_PATH}.`;
|
|
81394
|
+
function getVariantId(variantDocumentId) {
|
|
81395
|
+
return variantDocumentId.startsWith(VARIANT_ID_PREFIX) ? variantDocumentId.slice(VARIANT_ID_PREFIX.length) : variantDocumentId;
|
|
81396
|
+
}
|
|
81397
|
+
function getVariantTitle(variant) {
|
|
81398
|
+
const title = variant.metadata?.title;
|
|
81399
|
+
return typeof title == "string" && title.trim() ? title : getVariantId(variant._id);
|
|
81400
|
+
}
|
|
81401
|
+
function getVariantConditionsText(conditions) {
|
|
81402
|
+
return Object.entries(conditions).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(", ");
|
|
81403
|
+
}
|
|
81404
|
+
function decodeVariantIdFromRoute(variantIdRaw) {
|
|
81405
|
+
if (!variantIdRaw)
|
|
81406
|
+
return;
|
|
81407
|
+
let decoded;
|
|
81408
|
+
try {
|
|
81409
|
+
decoded = decodeURIComponent(variantIdRaw);
|
|
81410
|
+
} catch {
|
|
81411
|
+
decoded = variantIdRaw;
|
|
81412
|
+
}
|
|
81413
|
+
return decoded.startsWith(`${VARIANT_ID_PREFIX}`) ? decoded : `${VARIANT_ID_PREFIX}${decoded}`;
|
|
81414
|
+
}
|
|
81415
|
+
function getVariantDescription(variant) {
|
|
81416
|
+
const description = variant.metadata?.description;
|
|
81417
|
+
return !Array.isArray(description) || !description.every(isPortableTextBlock) ? "" : toPlainText(description).trim();
|
|
81418
|
+
}
|
|
81419
|
+
function filterVariantsForSearch(variants2, searchTerm) {
|
|
81420
|
+
const normalizedSearchTerm = searchTerm.trim().toLowerCase();
|
|
81421
|
+
return normalizedSearchTerm ? variants2.filter((variant) => [getVariantTitle(variant), getVariantId(variant._id), ...Object.entries(variant.conditions).flat()].some((value) => value.toLowerCase().includes(normalizedSearchTerm))) : variants2;
|
|
81422
|
+
}
|
|
81394
81423
|
function createVariantOperationsStore(options) {
|
|
81395
|
-
const
|
|
81396
|
-
client
|
|
81397
|
-
} = options;
|
|
81424
|
+
const client = options.client;
|
|
81398
81425
|
return {
|
|
81399
|
-
createVariant: (variant) =>
|
|
81400
|
-
|
|
81401
|
-
|
|
81426
|
+
createVariant: async (variant) => {
|
|
81427
|
+
const action = {
|
|
81428
|
+
actionType: "sanity.action.variant.definition.create",
|
|
81429
|
+
variantId: getVariantId(variant._id),
|
|
81430
|
+
conditions: variant.conditions,
|
|
81431
|
+
priority: variant.priority,
|
|
81432
|
+
...variant.metadata ? {
|
|
81433
|
+
metadata: variant.metadata
|
|
81434
|
+
} : {}
|
|
81435
|
+
};
|
|
81436
|
+
return await client.action(action, {
|
|
81437
|
+
tag: "variants.create"
|
|
81438
|
+
});
|
|
81439
|
+
},
|
|
81440
|
+
updateVariant: async (variant) => {
|
|
81441
|
+
const variantId = getVariantId(variant._id), setPayload = {
|
|
81402
81442
|
conditions: variant.conditions,
|
|
81403
81443
|
priority: variant.priority
|
|
81404
81444
|
};
|
|
81405
81445
|
variant.metadata && (setPayload.metadata = variant.metadata);
|
|
81406
|
-
const patch2 =
|
|
81407
|
-
|
|
81446
|
+
const patch2 = {
|
|
81447
|
+
set: setPayload
|
|
81448
|
+
};
|
|
81449
|
+
variant.metadata || (patch2.unset = ["metadata"]);
|
|
81450
|
+
const action = {
|
|
81451
|
+
actionType: "sanity.action.variant.definition.edit",
|
|
81452
|
+
variantId,
|
|
81453
|
+
patch: patch2
|
|
81454
|
+
};
|
|
81455
|
+
return await client.action(action, {
|
|
81456
|
+
tag: "variants.edit"
|
|
81457
|
+
});
|
|
81408
81458
|
},
|
|
81409
|
-
deleteVariant: (
|
|
81459
|
+
deleteVariant: async (variantIdOrDocumentId) => {
|
|
81460
|
+
const action = {
|
|
81461
|
+
actionType: "sanity.action.variant.definition.delete",
|
|
81462
|
+
variantId: getVariantId(variantIdOrDocumentId)
|
|
81463
|
+
};
|
|
81464
|
+
return await client.action(action, {
|
|
81465
|
+
tag: "variants.delete"
|
|
81466
|
+
});
|
|
81467
|
+
}
|
|
81410
81468
|
};
|
|
81411
81469
|
}
|
|
81412
81470
|
function useVariantOperations() {
|
|
@@ -81822,6 +81880,7 @@ const SORT_FIELD = "_createdAt", SORT_ORDER = "desc", QUERY_SORT_ORDER = `order(
|
|
|
81822
81880
|
_rev,
|
|
81823
81881
|
_createdAt,
|
|
81824
81882
|
_updatedAt,
|
|
81883
|
+
name,
|
|
81825
81884
|
conditions,
|
|
81826
81885
|
"priority": coalesce(priority, 0),
|
|
81827
81886
|
metadata,
|
|
@@ -81894,36 +81953,6 @@ function useAllVariants() {
|
|
|
81894
81953
|
loading: t2
|
|
81895
81954
|
}, $[3] = error, $[4] = t0, $[5] = t2, $[6] = variants2, $[7] = t3) : t3 = $[7], t3;
|
|
81896
81955
|
}
|
|
81897
|
-
const VARIANT_ID_PREFIX = `${VARIANT_DOCUMENTS_PATH}.`;
|
|
81898
|
-
function getVariantId(variantDocumentId) {
|
|
81899
|
-
return variantDocumentId.startsWith(VARIANT_ID_PREFIX) ? variantDocumentId.slice(VARIANT_ID_PREFIX.length) : variantDocumentId;
|
|
81900
|
-
}
|
|
81901
|
-
function getVariantTitle(variant) {
|
|
81902
|
-
const title = variant.metadata?.title;
|
|
81903
|
-
return typeof title == "string" && title.trim() ? title : getVariantId(variant._id);
|
|
81904
|
-
}
|
|
81905
|
-
function getVariantConditionsText(conditions) {
|
|
81906
|
-
return Object.entries(conditions).map(([key, value]) => `${key}: ${JSON.stringify(value)}`).join(", ");
|
|
81907
|
-
}
|
|
81908
|
-
function decodeVariantIdFromRoute(variantIdRaw) {
|
|
81909
|
-
if (!variantIdRaw)
|
|
81910
|
-
return;
|
|
81911
|
-
let decoded;
|
|
81912
|
-
try {
|
|
81913
|
-
decoded = decodeURIComponent(variantIdRaw);
|
|
81914
|
-
} catch {
|
|
81915
|
-
decoded = variantIdRaw;
|
|
81916
|
-
}
|
|
81917
|
-
return decoded.startsWith(`${VARIANT_ID_PREFIX}`) ? decoded : `${VARIANT_ID_PREFIX}${decoded}`;
|
|
81918
|
-
}
|
|
81919
|
-
function getVariantDescription(variant) {
|
|
81920
|
-
const description = variant.metadata?.description;
|
|
81921
|
-
return !Array.isArray(description) || !description.every(isPortableTextBlock) ? "" : toPlainText(description).trim();
|
|
81922
|
-
}
|
|
81923
|
-
function filterVariantsForSearch(variants2, searchTerm) {
|
|
81924
|
-
const normalizedSearchTerm = searchTerm.trim().toLowerCase();
|
|
81925
|
-
return normalizedSearchTerm ? variants2.filter((variant) => [getVariantTitle(variant), getVariantId(variant._id), ...Object.entries(variant.conditions).flat()].some((value) => value.toLowerCase().includes(normalizedSearchTerm))) : variants2;
|
|
81926
|
-
}
|
|
81927
81956
|
function VariantDetailMenuButton(t0) {
|
|
81928
81957
|
const $ = c(21), {
|
|
81929
81958
|
variant
|