storyblok 3.33.0 → 3.33.2

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +33 -1
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -1967,6 +1967,17 @@ const createContentList$1 = (content, key) => {
1967
1967
  else
1968
1968
  return !isEmpty$3(content) ? [content] : [];
1969
1969
  };
1970
+ const getSpaceInternalTags = (client, spaceId) => {
1971
+ return client.get(`spaces/${spaceId}/internal_tags`).then((response) => response.data.internal_tags || []);
1972
+ };
1973
+ const createComponentInternalTag = (client, spaceId, tag) => {
1974
+ return client.post(`spaces/${spaceId}/internal_tags`, {
1975
+ internal_tag: {
1976
+ name: tag.name,
1977
+ object_type: "component"
1978
+ }
1979
+ }).then((response) => response.data.internal_tag || {}).catch((error) => Promise.reject(error));
1980
+ };
1970
1981
  const pushComponents = async (api, { source, presetsSource }) => {
1971
1982
  try {
1972
1983
  const rawComponents = await getDataFromPath$1(source);
@@ -2024,7 +2035,9 @@ const pushComponentsGroups = async (api, group) => {
2024
2035
  }
2025
2036
  };
2026
2037
  const push = async (api, components, componentsGroups = [], presets = []) => {
2027
- const presetsLib = new PresetsLib({ oauthToken: api.accessToken, targetSpaceId: api.spaceId });
2038
+ const targetSpaceId = api.spaceId;
2039
+ const presetsLib = new PresetsLib({ oauthToken: api.accessToken, targetSpaceId });
2040
+ const apiClient = api.getClient();
2028
2041
  try {
2029
2042
  const componentGroupsTree = buildComponentsGroupsTree(componentsGroups);
2030
2043
  for (const rootComponent of componentGroupsTree) {
@@ -2042,6 +2055,25 @@ const push = async (api, components, componentsGroups = [], presets = []) => {
2042
2055
  components[i].component_group_uuid = groupData.uuid;
2043
2056
  delete components[i].component_group_name;
2044
2057
  }
2058
+ const { internal_tags_list, internal_tag_ids } = components[i];
2059
+ const existingTags = await getSpaceInternalTags(apiClient, targetSpaceId);
2060
+ let processedInternalTagsIds = [];
2061
+ if (internal_tags_list.length > 0) {
2062
+ await internal_tags_list.forEach(async (tag) => {
2063
+ const existingTag = existingTags.find(({ name }) => tag.name === name);
2064
+ if (!existingTag) {
2065
+ try {
2066
+ const response = await createComponentInternalTag(apiClient, targetSpaceId, tag);
2067
+ processedInternalTagsIds.push(response.id);
2068
+ } catch (e) {
2069
+ console.error(chalk.red("X") + ` Internal tag ${tag} creation failed: ${e.message}`);
2070
+ }
2071
+ } else {
2072
+ processedInternalTagsIds.push(existingTag.id);
2073
+ }
2074
+ });
2075
+ }
2076
+ components[i].internal_tag_ids = processedInternalTagsIds || internal_tag_ids;
2045
2077
  const schema = components[i].schema;
2046
2078
  if (schema) {
2047
2079
  Object.keys(schema).forEach((field) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storyblok",
3
- "version": "3.33.0",
3
+ "version": "3.33.2",
4
4
  "description": "A simple CLI to start Storyblok from your command line.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,7 +50,7 @@
50
50
  "p-series": "^2.1.0",
51
51
  "path": "^0.12.7",
52
52
  "simple-uuid": "^0.0.1",
53
- "storyblok-js-client": "^6.7.1",
53
+ "storyblok-js-client": "^6.9.1",
54
54
  "update-notifier": "^5.1.0",
55
55
  "xml-js": "^1.6.11"
56
56
  },