@localazy/strapi-plugin 1.0.1 → 1.0.4

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/README.md CHANGED
@@ -65,6 +65,8 @@ localazy: {
65
65
  */
66
66
  populateDefaultDepth?: number, // default is 5
67
67
  populateMaxDepth?: number, // default is 10
68
+ skipCreatorFields?: boolean, // default is false
69
+ enableSocketIO?: boolean, // default is true
68
70
  },
69
71
  },
70
72
  ```
@@ -811,7 +811,7 @@ var merge = createAssigner(function(object, source, srcIndex) {
811
811
  baseMerge(object, source, srcIndex);
812
812
  });
813
813
  const name = "@localazy/strapi-plugin";
814
- const version$1 = "1.0.1";
814
+ const version$1 = "1.0.4";
815
815
  const description = "The official Strapi Plugin by Localazy.";
816
816
  const keywords = [
817
817
  "strapi",
@@ -885,7 +885,7 @@ const dependencies = {
885
885
  const devDependencies = {
886
886
  "@david-vaclavek/deep-keys": "^0.5.0",
887
887
  "@localazy/api-client": "^2.1.6",
888
- "@localazy/conventional-changelog-preset": "^1.2.9",
888
+ "@localazy/conventional-changelog-preset": "^1.2.12",
889
889
  "@localazy/generic-connector-client": "^0.3.0",
890
890
  "@strapi/design-system": "^2.0.0-rc.14",
891
891
  "@strapi/icons": "^2.0.0-rc.14",
@@ -21684,17 +21684,19 @@ const bootstrap = ({ strapi: strapi2 }) => {
21684
21684
  }
21685
21685
  }
21686
21686
  });
21687
- process.nextTick(async () => {
21688
- const io2 = new Server2(strapi2.server.httpServer, {
21689
- cors: {
21690
- origin: "*",
21691
- methods: ["GET", "POST"]
21692
- },
21693
- // this must be a constructor
21694
- wsEngine: require$$8.WebSocketServer
21687
+ if (strapi2.plugin(PLUGIN_NAME)?.config("enableSocketIO", true)) {
21688
+ process.nextTick(async () => {
21689
+ const io2 = new Server2(strapi2.server.httpServer, {
21690
+ cors: {
21691
+ origin: "*",
21692
+ methods: ["GET", "POST"]
21693
+ },
21694
+ // this must be a constructor
21695
+ wsEngine: require$$8.WebSocketServer
21696
+ });
21697
+ strapi2.StrapIO = io2;
21695
21698
  });
21696
- strapi2.StrapIO = io2;
21697
- });
21699
+ }
21698
21700
  };
21699
21701
  const destroy = ({ strapi: strapi2 }) => {
21700
21702
  };
@@ -26003,21 +26005,48 @@ const parsedLocalazyEntryToUpdateEntry = async (allModels, localazyEntry, fullyP
26003
26005
  );
26004
26006
  return populatedEntry;
26005
26007
  };
26006
- const dropPropertyDeep = (obj, propertyName, isRoot = true) => {
26008
+ const isMediaObject = (obj) => {
26009
+ if (typeof obj !== "object" || obj === null) return false;
26010
+ return "url" in obj && "name" in obj && "ext" in obj && ("mime" in obj || "mimeType" in obj) && typeof obj.url === "string" && typeof obj.name === "string" && typeof obj.ext === "string";
26011
+ };
26012
+ const dropPropertyDeepWithSkip = (obj, propertyName, isRoot = true, skipPredicates = []) => {
26007
26013
  if (Array.isArray(obj)) {
26008
- return obj.filter((item) => isRoot || !(typeof item === "object" && item !== null && propertyName in item)).map((item) => typeof item === "object" && item !== null ? dropPropertyDeep(item, propertyName, false) : item);
26014
+ return obj.filter((item) => {
26015
+ if (skipPredicates.length > 0) {
26016
+ return true;
26017
+ }
26018
+ return isRoot || !(typeof item === "object" && item !== null && propertyName in item);
26019
+ }).map(
26020
+ (item) => typeof item === "object" && item !== null ? dropPropertyDeepWithSkip(item, propertyName, false, skipPredicates) : item
26021
+ );
26009
26022
  }
26010
26023
  if (typeof obj === "object" && obj !== null) {
26024
+ const shouldSkip = skipPredicates.some((predicate) => predicate(obj));
26025
+ if (shouldSkip) {
26026
+ const result2 = {};
26027
+ for (const key in obj) {
26028
+ if (key === propertyName) {
26029
+ result2[key] = obj[key];
26030
+ } else {
26031
+ result2[key] = typeof obj[key] === "object" && obj[key] !== null ? dropPropertyDeepWithSkip(obj[key], propertyName, false, skipPredicates) : obj[key];
26032
+ }
26033
+ }
26034
+ return result2;
26035
+ }
26011
26036
  const result = {};
26012
26037
  for (const key in obj) {
26013
- if (isRoot || !(propertyName in obj)) {
26014
- result[key] = typeof obj[key] === "object" && obj[key] !== null ? dropPropertyDeep(obj[key], propertyName, false) : obj[key];
26038
+ if (key === propertyName && !isRoot) {
26039
+ continue;
26015
26040
  }
26041
+ result[key] = typeof obj[key] === "object" && obj[key] !== null ? dropPropertyDeepWithSkip(obj[key], propertyName, false, skipPredicates) : obj[key];
26016
26042
  }
26017
26043
  return result;
26018
26044
  }
26019
26045
  return obj;
26020
26046
  };
26047
+ const dropDocumentIdExceptMedia = (obj) => {
26048
+ return dropPropertyDeepWithSkip(obj, "documentId", true, [isMediaObject]);
26049
+ };
26021
26050
  const StrapiLocalazyI18nService = ({ strapi: strapi2 }) => ({
26022
26051
  async createEntry(uid, strapiContentTypesModels, translatedModel, baseEntry, isoStrapi) {
26023
26052
  const StrapiI18nService2 = getStrapiI18nService();
@@ -26030,7 +26059,7 @@ const StrapiLocalazyI18nService = ({ strapi: strapi2 }) => ({
26030
26059
  );
26031
26060
  const omitKeys = ["locale", "localizations", "createdAt", "createdBy", "updatedAt", "updatedBy", "publishedAt"];
26032
26061
  let filteredBaseEntry = omitDeep(baseEntry, omitKeys);
26033
- filteredBaseEntry = dropPropertyDeep(filteredBaseEntry, "documentId");
26062
+ filteredBaseEntry = dropDocumentIdExceptMedia(filteredBaseEntry);
26034
26063
  let mergedCreateEntry = {};
26035
26064
  merge(mergedCreateEntry, filteredBaseEntry, createEntry);
26036
26065
  mergedCreateEntry = omitDeep(mergedCreateEntry, omitKeys);
@@ -798,7 +798,7 @@ var merge = createAssigner(function(object, source, srcIndex) {
798
798
  baseMerge(object, source, srcIndex);
799
799
  });
800
800
  const name = "@localazy/strapi-plugin";
801
- const version$1 = "1.0.1";
801
+ const version$1 = "1.0.4";
802
802
  const description = "The official Strapi Plugin by Localazy.";
803
803
  const keywords = [
804
804
  "strapi",
@@ -872,7 +872,7 @@ const dependencies = {
872
872
  const devDependencies = {
873
873
  "@david-vaclavek/deep-keys": "^0.5.0",
874
874
  "@localazy/api-client": "^2.1.6",
875
- "@localazy/conventional-changelog-preset": "^1.2.9",
875
+ "@localazy/conventional-changelog-preset": "^1.2.12",
876
876
  "@localazy/generic-connector-client": "^0.3.0",
877
877
  "@strapi/design-system": "^2.0.0-rc.14",
878
878
  "@strapi/icons": "^2.0.0-rc.14",
@@ -21671,17 +21671,19 @@ const bootstrap = ({ strapi: strapi2 }) => {
21671
21671
  }
21672
21672
  }
21673
21673
  });
21674
- process.nextTick(async () => {
21675
- const io2 = new Server2(strapi2.server.httpServer, {
21676
- cors: {
21677
- origin: "*",
21678
- methods: ["GET", "POST"]
21679
- },
21680
- // this must be a constructor
21681
- wsEngine: WebSocketServer
21674
+ if (strapi2.plugin(PLUGIN_NAME)?.config("enableSocketIO", true)) {
21675
+ process.nextTick(async () => {
21676
+ const io2 = new Server2(strapi2.server.httpServer, {
21677
+ cors: {
21678
+ origin: "*",
21679
+ methods: ["GET", "POST"]
21680
+ },
21681
+ // this must be a constructor
21682
+ wsEngine: WebSocketServer
21683
+ });
21684
+ strapi2.StrapIO = io2;
21682
21685
  });
21683
- strapi2.StrapIO = io2;
21684
- });
21686
+ }
21685
21687
  };
21686
21688
  const destroy = ({ strapi: strapi2 }) => {
21687
21689
  };
@@ -25990,21 +25992,48 @@ const parsedLocalazyEntryToUpdateEntry = async (allModels, localazyEntry, fullyP
25990
25992
  );
25991
25993
  return populatedEntry;
25992
25994
  };
25993
- const dropPropertyDeep = (obj, propertyName, isRoot = true) => {
25995
+ const isMediaObject = (obj) => {
25996
+ if (typeof obj !== "object" || obj === null) return false;
25997
+ return "url" in obj && "name" in obj && "ext" in obj && ("mime" in obj || "mimeType" in obj) && typeof obj.url === "string" && typeof obj.name === "string" && typeof obj.ext === "string";
25998
+ };
25999
+ const dropPropertyDeepWithSkip = (obj, propertyName, isRoot = true, skipPredicates = []) => {
25994
26000
  if (Array.isArray(obj)) {
25995
- return obj.filter((item) => isRoot || !(typeof item === "object" && item !== null && propertyName in item)).map((item) => typeof item === "object" && item !== null ? dropPropertyDeep(item, propertyName, false) : item);
26001
+ return obj.filter((item) => {
26002
+ if (skipPredicates.length > 0) {
26003
+ return true;
26004
+ }
26005
+ return isRoot || !(typeof item === "object" && item !== null && propertyName in item);
26006
+ }).map(
26007
+ (item) => typeof item === "object" && item !== null ? dropPropertyDeepWithSkip(item, propertyName, false, skipPredicates) : item
26008
+ );
25996
26009
  }
25997
26010
  if (typeof obj === "object" && obj !== null) {
26011
+ const shouldSkip = skipPredicates.some((predicate) => predicate(obj));
26012
+ if (shouldSkip) {
26013
+ const result2 = {};
26014
+ for (const key in obj) {
26015
+ if (key === propertyName) {
26016
+ result2[key] = obj[key];
26017
+ } else {
26018
+ result2[key] = typeof obj[key] === "object" && obj[key] !== null ? dropPropertyDeepWithSkip(obj[key], propertyName, false, skipPredicates) : obj[key];
26019
+ }
26020
+ }
26021
+ return result2;
26022
+ }
25998
26023
  const result = {};
25999
26024
  for (const key in obj) {
26000
- if (isRoot || !(propertyName in obj)) {
26001
- result[key] = typeof obj[key] === "object" && obj[key] !== null ? dropPropertyDeep(obj[key], propertyName, false) : obj[key];
26025
+ if (key === propertyName && !isRoot) {
26026
+ continue;
26002
26027
  }
26028
+ result[key] = typeof obj[key] === "object" && obj[key] !== null ? dropPropertyDeepWithSkip(obj[key], propertyName, false, skipPredicates) : obj[key];
26003
26029
  }
26004
26030
  return result;
26005
26031
  }
26006
26032
  return obj;
26007
26033
  };
26034
+ const dropDocumentIdExceptMedia = (obj) => {
26035
+ return dropPropertyDeepWithSkip(obj, "documentId", true, [isMediaObject]);
26036
+ };
26008
26037
  const StrapiLocalazyI18nService = ({ strapi: strapi2 }) => ({
26009
26038
  async createEntry(uid, strapiContentTypesModels, translatedModel, baseEntry, isoStrapi) {
26010
26039
  const StrapiI18nService2 = getStrapiI18nService();
@@ -26017,7 +26046,7 @@ const StrapiLocalazyI18nService = ({ strapi: strapi2 }) => ({
26017
26046
  );
26018
26047
  const omitKeys = ["locale", "localizations", "createdAt", "createdBy", "updatedAt", "updatedBy", "publishedAt"];
26019
26048
  let filteredBaseEntry = omitDeep(baseEntry, omitKeys);
26020
- filteredBaseEntry = dropPropertyDeep(filteredBaseEntry, "documentId");
26049
+ filteredBaseEntry = dropDocumentIdExceptMedia(filteredBaseEntry);
26021
26050
  let mergedCreateEntry = {};
26022
26051
  merge(mergedCreateEntry, filteredBaseEntry, createEntry);
26023
26052
  mergedCreateEntry = omitDeep(mergedCreateEntry, omitKeys);
@@ -1 +1,3 @@
1
1
  export declare const dropPropertyDeep: (obj: any, propertyName: string, isRoot?: boolean) => any;
2
+ export declare const dropPropertyDeepWithSkip: (obj: any, propertyName: string, isRoot?: boolean, skipPredicates?: ((obj: any) => boolean)[]) => any;
3
+ export declare const dropDocumentIdExceptMedia: (obj: any) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localazy/strapi-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "The official Strapi Plugin by Localazy.",
5
5
  "keywords": [
6
6
  "strapi",
@@ -80,7 +80,7 @@
80
80
  "devDependencies": {
81
81
  "@david-vaclavek/deep-keys": "^0.5.0",
82
82
  "@localazy/api-client": "^2.1.6",
83
- "@localazy/conventional-changelog-preset": "^1.2.9",
83
+ "@localazy/conventional-changelog-preset": "^1.2.12",
84
84
  "@localazy/generic-connector-client": "^0.3.0",
85
85
  "@strapi/design-system": "^2.0.0-rc.14",
86
86
  "@strapi/icons": "^2.0.0-rc.14",