@localazy/strapi-plugin 0.1.13-rc.5 → 0.1.13-rc.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.
@@ -200,16 +200,14 @@ function GlobalSettings() {
200
200
  <Option value="updated">{t("plugin_settings.editing_data_entry")}</Option>
201
201
  </Select>
202
202
  {/* Deprecate source keys on deletion */}
203
- <div style={{ display: "none" }}>
204
- <br /><br />
205
- <ToggleInput
206
- label={t("plugin_settings.deprecate_source_keys_on_delete")}
207
- hint={t("plugin_settings.deprecate_source_keys_on_delete_info")}
208
- offLabel={t("plugin_settings.off")}
209
- onLabel={t("plugin_settings.on")}
210
- checked={typeof formModel?.upload?.allowDeprecate === "boolean" ? formModel.upload.allowDeprecate : false}
211
- onChange={e => patchFormModel("upload.allowDeprecate", e.target.checked)} />
212
- </div>
203
+ <br /><br />
204
+ <ToggleInput
205
+ label={t("plugin_settings.deprecate_source_keys_on_delete")}
206
+ hint={t("plugin_settings.deprecate_source_keys_on_delete_info")}
207
+ offLabel={t("plugin_settings.off")}
208
+ onLabel={t("plugin_settings.on")}
209
+ checked={typeof formModel?.upload?.allowDeprecate === "boolean" ? formModel.upload.allowDeprecate : false}
210
+ onChange={e => patchFormModel("upload.allowDeprecate", e.target.checked)} />
213
211
  <br /><br />
214
212
  <Divider />
215
213
  {/* Download Settings */}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localazy/strapi-plugin",
3
- "version": "0.1.13-rc.5",
3
+ "version": "0.1.13-rc.7",
4
4
  "description": "The official Strapi Plugin by Localazy.",
5
5
  "strapi": {
6
6
  "name": "localazy",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@david-vaclavek/deep-keys": "^0.5.0",
42
- "@localazy/ts-api": "^1.0.12",
42
+ "@localazy/ts-api": "^1.0.13",
43
43
  "i18next": "^22.4.9",
44
44
  "isomorphic-fetch": "^3.0.0",
45
45
  "js-cookie": "^3.0.1",
@@ -66,5 +66,8 @@
66
66
  "engines": {
67
67
  "node": ">=14.19.1 <=18.x.x",
68
68
  "npm": ">=6.0.0"
69
+ },
70
+ "browser": {
71
+ "crypto": false
69
72
  }
70
73
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  const deepPopulateHook = require('./lifecycles/deep-populate-hook');
4
4
  const uploadEventEntryToLocalazyHook = require('./lifecycles/upload-event-entry-to-localazy-hook');
5
+ const deprecateEventEntryInLocalazyHook = require('./lifecycles/deprecate-event-entry-in-localazy-hook');
5
6
  const RequestInitiatorHelper = require('./utils/request-initiator-helper');
6
7
 
7
8
  module.exports = ({ strapi }) => {
@@ -34,6 +35,24 @@ module.exports = ({ strapi }) => {
34
35
  break;
35
36
  }
36
37
  }
38
+ case 'beforeDeleteMany':
39
+ case 'beforeDelete': {
40
+ try {
41
+ if (requestInitiatorHelper.isInitiatedByLocalazyWebhook() || requestInitiatorHelper.isInitiatedByLocalazyPluginUI()) {
42
+ break;
43
+ }
44
+
45
+ // have to await here
46
+ const result = await deprecateEventEntryInLocalazyHook(event);
47
+ if (typeof result !== 'undefined') {
48
+ strapi.log.info(`${action} hook result: ${JSON.stringify(result)}`);
49
+ }
50
+ } catch (e) {
51
+ strapi.log.error(e);
52
+ } finally {
53
+ break;
54
+ }
55
+ }
37
56
  default:
38
57
  break;
39
58
  }
@@ -12,4 +12,5 @@ module.exports = {
12
12
  LOCALAZY_DEFAULT_LOCALE: "en",
13
13
  LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
14
14
  LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
15
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: true,
15
16
  };
@@ -11,5 +11,6 @@ module.exports = {
11
11
  LOCALAZY_DEFAULT_FILE_EXTENSION: "",
12
12
  LOCALAZY_DEFAULT_LOCALE: "",
13
13
  LOCALAZY_API_USER_JWT_COOKIE_NAME: "",
14
- LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
14
+ LOCALAZY_API_USER_COOKIE_EXPIRATION: -1,
15
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: false,
15
16
  };
@@ -12,4 +12,5 @@ module.exports = {
12
12
  LOCALAZY_DEFAULT_LOCALE: "en",
13
13
  LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
14
14
  LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
15
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: false,
15
16
  };
@@ -13,4 +13,5 @@ module.exports = {
13
13
  LOCALAZY_DEFAULT_LOCALE: "en",
14
14
  LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
15
15
  LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
16
+ LOCALAZY_PUBLIC_API_LIFTED_LIMITS: true,
16
17
  };
@@ -177,11 +177,12 @@ module.exports = {
177
177
  locale,
178
178
  chunks
179
179
  );
180
+ // Use `deprecate: "file"` if there is one chunk of transferred data only!
181
+ const hasMoreTransferFilesChunks = importFile.length > 1;
182
+ const uploadConfig = !hasMoreTransferFilesChunks ? { deprecate: "file" } : {};
180
183
  await LocalazyUploadService.upload(
181
184
  importFile,
182
- // {
183
- // deprecate: "file"
184
- // }
185
+ uploadConfig
185
186
  );
186
187
 
187
188
  ctx.body = {
@@ -4,6 +4,7 @@
4
4
 
5
5
  const getLocalazyApi = require("../utils/get-localazy-api");
6
6
  const delay = require("../utils/delay");
7
+ const config = require("../config").default;
7
8
 
8
9
  module.exports = ({ strapi }) => ({
9
10
  /**
@@ -45,15 +46,21 @@ module.exports = ({ strapi }) => ({
45
46
  }
46
47
  },
47
48
 
48
- splitToChunks(data, CHUNK_LIMIT = 1000) {
49
+ /**
50
+ * Check Directus for the Lifted Limits OAuth Apps IDs
51
+ */
52
+ CHUNK_LIMIT: config.LOCALAZY_PUBLIC_API_LIFTED_LIMITS ? 99900 : 9990,
53
+
54
+ splitToChunks(data, CHUNK_LIMIT = null) {
49
55
  const chunks = [];
50
56
  const keys = Object.keys(data);
51
57
  const keysCount = keys.length;
52
- const chunksCount = Math.ceil(keysCount / CHUNK_LIMIT);
58
+ const localChunkLimit = CHUNK_LIMIT || this.CHUNK_LIMIT;
59
+ const chunksCount = Math.ceil(keysCount / localChunkLimit);
53
60
  for (let i = 0; i < chunksCount; i += 1) {
54
61
  const chunkStrings = {};
55
- const from = CHUNK_LIMIT * i;
56
- const to = CHUNK_LIMIT * (i + 1);
62
+ const from = localChunkLimit * i;
63
+ const to = localChunkLimit * (i + 1);
57
64
 
58
65
  const currentKeys = keys.slice(from, to);
59
66
  currentKeys.forEach((key) => {
@@ -1,33 +0,0 @@
1
- import {
2
- ApolloClient,
3
- HttpLink,
4
- ApolloLink,
5
- InMemoryCache,
6
- } from "@apollo/client";
7
- import Cookies from "js-cookie";
8
-
9
- const createClient = () => {
10
- const httpLink = new HttpLink({ uri: process.env.STRAPI_ADMIN_GRAPHQL_URL });
11
-
12
- const authLink = new ApolloLink((operation, forward) => {
13
- // Retrieve the authorization token from local storage.
14
- const token = Cookies.get('LOCALAZY-API-USER-JWT');
15
-
16
- // Use the setContext method to set the HTTP headers.
17
- operation.setContext({
18
- headers: {
19
- 'Authorization': token ? `Bearer ${token}` : ''
20
- }
21
- });
22
-
23
- // Call the next link in the middleware chain.
24
- return forward(operation);
25
- });
26
-
27
- return new ApolloClient({
28
- link: authLink.concat(httpLink),
29
- cache: new InMemoryCache()
30
- });
31
- }
32
-
33
- export default createClient;