@localazy/strapi-plugin 0.1.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/.babelrc +7 -0
- package/.eslintrc +7 -0
- package/.github/workflows/.build.yml +39 -0
- package/.nvmrc +1 -0
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/admin/src/.eslintrc +3 -0
- package/admin/src/components/Initializer/index.js +26 -0
- package/admin/src/components/PluginIcon/index.js +14 -0
- package/admin/src/i18n.js +37 -0
- package/admin/src/index.js +106 -0
- package/admin/src/modules/@common/components/Icons/Localazy/index.js +12 -0
- package/admin/src/modules/@common/components/SideNav/index.js +46 -0
- package/admin/src/modules/@common/components/TransferReport/index.js +54 -0
- package/admin/src/modules/@common/locale/en.js +13 -0
- package/admin/src/modules/@common/services/i18n-service.js +15 -0
- package/admin/src/modules/@common/services/project-service.js +15 -0
- package/admin/src/modules/@common/services/user-service.js +38 -0
- package/admin/src/modules/@common/utils/are-locales-compatible.js +42 -0
- package/admin/src/modules/@common/utils/functions/flatten-deep.js +23 -0
- package/admin/src/modules/@common/utils/get-default-locale.js +32 -0
- package/admin/src/modules/@common/utils/get-header-subtitle.js +21 -0
- package/admin/src/modules/@common/utils/get-header-title.js +24 -0
- package/admin/src/modules/@common/utils/get-nav.js +35 -0
- package/admin/src/modules/@common/utils/history.js +6 -0
- package/admin/src/modules/@common/utils/is-plugin-route.js +15 -0
- package/admin/src/modules/@common/utils/iso-locales-utils.js +15 -0
- package/admin/src/modules/@common/utils/redirect-to-plugin-route.js +22 -0
- package/admin/src/modules/@common/utils/sort-by-model-name.js +10 -0
- package/admin/src/modules/localazy-download/locale/en.js +20 -0
- package/admin/src/modules/localazy-download/services/localazy-download-service.js +16 -0
- package/admin/src/modules/localazy-upload/components/ReadDocsButton.js +21 -0
- package/admin/src/modules/localazy-upload/locale/en.js +18 -0
- package/admin/src/modules/localazy-upload/services/localazy-upload-service.js +16 -0
- package/admin/src/modules/login/components/LoginButton/index.js +56 -0
- package/admin/src/modules/login/components/LogoutButton/index.js +50 -0
- package/admin/src/modules/login/locale/en.js +7 -0
- package/admin/src/modules/login/services/localazy-login-service.js +29 -0
- package/admin/src/modules/plugin-settings/components/ContentTransferSetup/index.js +292 -0
- package/admin/src/modules/plugin-settings/components/Tree/index.js +120 -0
- package/admin/src/modules/plugin-settings/components/TreeItem/index.js +48 -0
- package/admin/src/modules/plugin-settings/functions/build-content-transfer-setup-schema.js +71 -0
- package/admin/src/modules/plugin-settings/functions/has-model-changed.js +85 -0
- package/admin/src/modules/plugin-settings/locale/en.js +19 -0
- package/admin/src/modules/plugin-settings/services/plugin-settings-service.js +32 -0
- package/admin/src/modules/plugin-settings/services/strapi-model-service.js +26 -0
- package/admin/src/modules/plugin-settings/utils/__tests__/get-models-tree.test.js +135 -0
- package/admin/src/modules/plugin-settings/utils/array-of-models-to-object.js +6 -0
- package/admin/src/modules/plugin-settings/utils/find-model-value-by-key.js +8 -0
- package/admin/src/modules/plugin-settings/utils/get-filtered-models-schemas.js +34 -0
- package/admin/src/modules/plugin-settings/utils/get-models-tree.js +73 -0
- package/admin/src/modules/settings/components/OverviewItem/index.js +44 -0
- package/admin/src/modules/settings/components/OverviewItemLink/index.js +34 -0
- package/admin/src/modules/settings/components/PrerequisitiesInfo/index.js +30 -0
- package/admin/src/modules/settings/locale/en.js +13 -0
- package/admin/src/modules/user/model/localazy-identity.js +14 -0
- package/admin/src/modules/user/services/localazy-user-service.js +38 -0
- package/admin/src/pages/App/index.js +152 -0
- package/admin/src/pages/Download/index.js +179 -0
- package/admin/src/pages/Index/index.js +8 -0
- package/admin/src/pages/Login/index.js +94 -0
- package/admin/src/pages/PluginSettings/index.js +42 -0
- package/admin/src/pages/Settings/index.js +120 -0
- package/admin/src/pages/Upload/index.js +187 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/plugins/apolloClient.js +33 -0
- package/admin/src/state/localazy-identity.js +29 -0
- package/admin/src/tests/fixtures/all-models.js +877 -0
- package/admin/src/tests/fixtures/restaurant-model.js +230 -0
- package/admin/src/translations/en.json +4 -0
- package/admin/src/translations/fr.json +1 -0
- package/admin/src/utils/createAxiosInstance.js +52 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/jest.config.js +0 -0
- package/package.json +60 -0
- package/server/bootstrap.js +5 -0
- package/server/config/development/index.js +15 -0
- package/server/config/example/index.js +15 -0
- package/server/config/index.js +15 -0
- package/server/config/production/index.js +16 -0
- package/server/config/schema.graphql.js +21 -0
- package/server/content-types/index.js +3 -0
- package/server/controllers/index.js +19 -0
- package/server/controllers/localazy-auth-controller.js +46 -0
- package/server/controllers/localazy-project-controller.js +21 -0
- package/server/controllers/localazy-transfer-controller.js +469 -0
- package/server/controllers/localazy-user-controller.js +24 -0
- package/server/controllers/my-controller.js +10 -0
- package/server/controllers/plugin-settings-controller.js +17 -0
- package/server/controllers/strapi-controller.js +16 -0
- package/server/db/model/content-transfer-setup.js +13 -0
- package/server/db/model/localazy-user.js +23 -0
- package/server/db/model/utils/get-strapi-store.js +9 -0
- package/server/destroy.js +5 -0
- package/server/index.js +25 -0
- package/server/middlewares/index.js +3 -0
- package/server/policies/index.js +3 -0
- package/server/register.js +5 -0
- package/server/routes/index.js +26 -0
- package/server/routes/localazy-auth.js +22 -0
- package/server/routes/localazy-project.js +14 -0
- package/server/routes/localazy-transfer.js +22 -0
- package/server/routes/localazy-user.js +30 -0
- package/server/routes/plugin-settings.js +22 -0
- package/server/routes/strapi.js +22 -0
- package/server/services/index.js +21 -0
- package/server/services/localazy-auth-service.js +38 -0
- package/server/services/localazy-download-service.js +54 -0
- package/server/services/localazy-pubapi-service.js +47 -0
- package/server/services/localazy-upload-service.js +95 -0
- package/server/services/localazy-user-service.js +29 -0
- package/server/services/plugin-settings-service.js +30 -0
- package/server/services/strapi-i18n-service.js +132 -0
- package/server/services/strapi-service.js +23 -0
- package/server/tests/fixtures/all-models-with-multimedia.js +1064 -0
- package/server/tests/fixtures/all-models.js +869 -0
- package/server/tests/fixtures/collection-flattened.js +76 -0
- package/server/tests/fixtures/restaurant-flattened.js +46 -0
- package/server/tests/fixtures/restaurant-model.js +230 -0
- package/server/tests/fixtures/restaurants-entries.js +152 -0
- package/server/tests/fixtures/restaurants-pick-paths.js +15 -0
- package/server/tests/fixtures/strapi-book-with-multimedia-components-cs.js +31 -0
- package/server/tests/fixtures/stringified-book-cs.js +3 -0
- package/server/tests/fixtures/stringified-book-with-multimedia-components-cs.js +3 -0
- package/server/tests/fixtures/stringified-restaurant-cs.js +3 -0
- package/server/tests/fixtures/stringified-restaurant-de.js +5 -0
- package/server/utils/__tests__/build-populate.test.js +85 -0
- package/server/utils/__tests__/flatten-object.test.js +171 -0
- package/server/utils/__tests__/get-models-tree.test.js +170 -0
- package/server/utils/__tests__/parsed-localazy-entry-to-create-entry.test.js +153 -0
- package/server/utils/__tests__/parsed-localazy-entry-to-update-entry.test.js +172 -0
- package/server/utils/__tests__/pick-entries.test.js +83 -0
- package/server/utils/build-populate.js +43 -0
- package/server/utils/delay.js +6 -0
- package/server/utils/flatten-object.js +52 -0
- package/server/utils/get-localazy-api.js +22 -0
- package/server/utils/get-main-keys-of-nested-array-objects.js +5 -0
- package/server/utils/get-models-tree.js +43 -0
- package/server/utils/intl-display-name.js +7 -0
- package/server/utils/is-generally-applicable-content-type.js +33 -0
- package/server/utils/is-localazy-applicable-content-type.js +36 -0
- package/server/utils/iso-locales-utils.js +22 -0
- package/server/utils/objectivise-entry.js +41 -0
- package/server/utils/omit-deep.js +17 -0
- package/server/utils/parsed-localazy-entry-to-create-entry.js +115 -0
- package/server/utils/parsed-localazy-entry-to-update-entry.js +31 -0
- package/server/utils/pick-entries.js +14 -0
- package/server/utils/transfer-setup-utils.js +39 -0
- package/strapi-admin.js +14 -0
- package/strapi-server.js +5 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
kind: "collectionType",
|
|
3
|
+
collectionName: "restaurants",
|
|
4
|
+
info: {
|
|
5
|
+
singularName: "restaurant",
|
|
6
|
+
pluralName: "restaurants",
|
|
7
|
+
displayName: "Restaurant",
|
|
8
|
+
description: "",
|
|
9
|
+
},
|
|
10
|
+
options: {
|
|
11
|
+
draftAndPublish: true,
|
|
12
|
+
},
|
|
13
|
+
pluginOptions: {
|
|
14
|
+
i18n: {
|
|
15
|
+
localized: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
attributes: {
|
|
19
|
+
title: {
|
|
20
|
+
pluginOptions: {
|
|
21
|
+
i18n: {
|
|
22
|
+
localized: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
type: "string",
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
description: {
|
|
29
|
+
pluginOptions: {
|
|
30
|
+
i18n: {
|
|
31
|
+
localized: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
type: "text",
|
|
35
|
+
},
|
|
36
|
+
books: {
|
|
37
|
+
type: "relation",
|
|
38
|
+
relation: "oneToMany",
|
|
39
|
+
target: "api::book.book",
|
|
40
|
+
},
|
|
41
|
+
recipes: {
|
|
42
|
+
type: "component",
|
|
43
|
+
repeatable: true,
|
|
44
|
+
pluginOptions: {
|
|
45
|
+
i18n: {
|
|
46
|
+
localized: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
component: "food.recipe",
|
|
50
|
+
},
|
|
51
|
+
descs: {
|
|
52
|
+
type: "component",
|
|
53
|
+
repeatable: false,
|
|
54
|
+
pluginOptions: {
|
|
55
|
+
i18n: {
|
|
56
|
+
localized: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
component: "food.pub-component-1",
|
|
60
|
+
},
|
|
61
|
+
street: {
|
|
62
|
+
pluginOptions: {
|
|
63
|
+
i18n: {
|
|
64
|
+
localized: true,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
type: "string",
|
|
68
|
+
},
|
|
69
|
+
city: {
|
|
70
|
+
pluginOptions: {
|
|
71
|
+
i18n: {
|
|
72
|
+
localized: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
type: "string",
|
|
76
|
+
},
|
|
77
|
+
country: {
|
|
78
|
+
pluginOptions: {
|
|
79
|
+
i18n: {
|
|
80
|
+
localized: true,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
type: "string",
|
|
84
|
+
},
|
|
85
|
+
createdAt: {
|
|
86
|
+
type: "datetime",
|
|
87
|
+
},
|
|
88
|
+
updatedAt: {
|
|
89
|
+
type: "datetime",
|
|
90
|
+
},
|
|
91
|
+
publishedAt: {
|
|
92
|
+
type: "datetime",
|
|
93
|
+
configurable: false,
|
|
94
|
+
writable: true,
|
|
95
|
+
visible: false,
|
|
96
|
+
},
|
|
97
|
+
createdBy: {
|
|
98
|
+
type: "relation",
|
|
99
|
+
relation: "oneToOne",
|
|
100
|
+
target: "admin::user",
|
|
101
|
+
configurable: false,
|
|
102
|
+
writable: false,
|
|
103
|
+
visible: false,
|
|
104
|
+
useJoinTable: false,
|
|
105
|
+
private: true,
|
|
106
|
+
},
|
|
107
|
+
updatedBy: {
|
|
108
|
+
type: "relation",
|
|
109
|
+
relation: "oneToOne",
|
|
110
|
+
target: "admin::user",
|
|
111
|
+
configurable: false,
|
|
112
|
+
writable: false,
|
|
113
|
+
visible: false,
|
|
114
|
+
useJoinTable: false,
|
|
115
|
+
private: true,
|
|
116
|
+
},
|
|
117
|
+
localizations: {
|
|
118
|
+
writable: true,
|
|
119
|
+
private: false,
|
|
120
|
+
configurable: false,
|
|
121
|
+
visible: false,
|
|
122
|
+
type: "relation",
|
|
123
|
+
relation: "oneToMany",
|
|
124
|
+
target: "api::restaurant.restaurant",
|
|
125
|
+
},
|
|
126
|
+
locale: {
|
|
127
|
+
writable: true,
|
|
128
|
+
private: false,
|
|
129
|
+
configurable: false,
|
|
130
|
+
visible: false,
|
|
131
|
+
type: "string",
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
__schema__: {
|
|
135
|
+
collectionName: "restaurants",
|
|
136
|
+
info: {
|
|
137
|
+
singularName: "restaurant",
|
|
138
|
+
pluralName: "restaurants",
|
|
139
|
+
displayName: "Restaurant",
|
|
140
|
+
description: "",
|
|
141
|
+
},
|
|
142
|
+
options: {
|
|
143
|
+
draftAndPublish: true,
|
|
144
|
+
},
|
|
145
|
+
pluginOptions: {
|
|
146
|
+
i18n: {
|
|
147
|
+
localized: true,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
attributes: {
|
|
151
|
+
title: {
|
|
152
|
+
pluginOptions: {
|
|
153
|
+
i18n: {
|
|
154
|
+
localized: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
type: "string",
|
|
158
|
+
required: true,
|
|
159
|
+
},
|
|
160
|
+
description: {
|
|
161
|
+
pluginOptions: {
|
|
162
|
+
i18n: {
|
|
163
|
+
localized: true,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
type: "text",
|
|
167
|
+
},
|
|
168
|
+
books: {
|
|
169
|
+
type: "relation",
|
|
170
|
+
relation: "oneToMany",
|
|
171
|
+
target: "api::book.book",
|
|
172
|
+
},
|
|
173
|
+
recipes: {
|
|
174
|
+
type: "component",
|
|
175
|
+
repeatable: true,
|
|
176
|
+
pluginOptions: {
|
|
177
|
+
i18n: {
|
|
178
|
+
localized: true,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
component: "food.recipe",
|
|
182
|
+
},
|
|
183
|
+
descs: {
|
|
184
|
+
type: "component",
|
|
185
|
+
repeatable: false,
|
|
186
|
+
pluginOptions: {
|
|
187
|
+
i18n: {
|
|
188
|
+
localized: true,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
component: "food.pub-component-1",
|
|
192
|
+
},
|
|
193
|
+
street: {
|
|
194
|
+
pluginOptions: {
|
|
195
|
+
i18n: {
|
|
196
|
+
localized: true,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
type: "string",
|
|
200
|
+
},
|
|
201
|
+
city: {
|
|
202
|
+
pluginOptions: {
|
|
203
|
+
i18n: {
|
|
204
|
+
localized: true,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
type: "string",
|
|
208
|
+
},
|
|
209
|
+
country: {
|
|
210
|
+
pluginOptions: {
|
|
211
|
+
i18n: {
|
|
212
|
+
localized: true,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
type: "string",
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
kind: "collectionType",
|
|
219
|
+
},
|
|
220
|
+
modelType: "contentType",
|
|
221
|
+
modelName: "restaurant",
|
|
222
|
+
connection: "default",
|
|
223
|
+
uid: "api::restaurant.restaurant",
|
|
224
|
+
apiName: "restaurant",
|
|
225
|
+
globalId: "Restaurant",
|
|
226
|
+
actions: {},
|
|
227
|
+
lifecycles: {},
|
|
228
|
+
singularName: "restaurant",
|
|
229
|
+
tableName: "restaurants",
|
|
230
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* axios with a custom config.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import axios from "axios";
|
|
6
|
+
import { auth } from "@strapi/helper-plugin";
|
|
7
|
+
import pluginId from "../pluginId";
|
|
8
|
+
|
|
9
|
+
const BASE_PLUGIN_PATH = `/${pluginId}`;
|
|
10
|
+
|
|
11
|
+
const createAxiosInstance = (baseUrl = null) => {
|
|
12
|
+
if (baseUrl === null) {
|
|
13
|
+
baseUrl = `${BASE_PLUGIN_PATH}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const instance = axios.create({
|
|
17
|
+
baseURL: baseUrl,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
instance.interceptors.request.use(
|
|
21
|
+
async (config) => {
|
|
22
|
+
config.headers = {
|
|
23
|
+
Authorization: `Bearer ${auth.getToken()}`,
|
|
24
|
+
Accept: "application/json",
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return config;
|
|
29
|
+
},
|
|
30
|
+
(error) => {
|
|
31
|
+
Promise.reject(error);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
instance.interceptors.response.use(
|
|
36
|
+
(response) => response,
|
|
37
|
+
(error) => {
|
|
38
|
+
// whatever you want to do with the error
|
|
39
|
+
if (error.response?.status === 401) {
|
|
40
|
+
// force-logout from the app
|
|
41
|
+
auth.clearAppStorage();
|
|
42
|
+
window.location.reload();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return instance;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default createAxiosInstance;
|
package/jest.config.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@localazy/strapi-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The official Strapi Plugin by Localazy.",
|
|
5
|
+
"strapi": {
|
|
6
|
+
"name": "localazy",
|
|
7
|
+
"description": "The official Strapi Plugin by Localazy",
|
|
8
|
+
"kind": "plugin"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git@github.com:localazy/strapi-plugin.git"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "jest --config ./jest.config.js",
|
|
16
|
+
"test:watch": "jest --watch --config ./jest.config.js"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@localazy/ts-api": "^1.0.6",
|
|
20
|
+
"@strapi/design-system": "^1.0.0",
|
|
21
|
+
"@strapi/icons": "^1.0.0",
|
|
22
|
+
"deep-keys": "^0.5.0",
|
|
23
|
+
"i18next": "^21.6.13",
|
|
24
|
+
"isomorphic-fetch": "^3.0.0",
|
|
25
|
+
"js-cookie": "^3.0.1",
|
|
26
|
+
"lodash": "^4.17.21",
|
|
27
|
+
"module-alias": "^2.2.2",
|
|
28
|
+
"react-hooks-global-state": "^1.0.2",
|
|
29
|
+
"react-i18next": "^11.15.5",
|
|
30
|
+
"styled-components": "^5.3.3"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@strapi/strapi": "^4.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@babel/plugin-transform-modules-commonjs": "^7.17.7",
|
|
37
|
+
"@strapi-community/eslint-config": "^0.2.0",
|
|
38
|
+
"@strapi-community/eslint-config-admin": "^0.2.0",
|
|
39
|
+
"eslint": "^8.11.0",
|
|
40
|
+
"eslint-plugin-jest": "^26.1.3",
|
|
41
|
+
"jest": "^27.5.1"
|
|
42
|
+
},
|
|
43
|
+
"author": {
|
|
44
|
+
"name": "David Vaclavek",
|
|
45
|
+
"email": "david@localazy.com",
|
|
46
|
+
"url": "https://localazy.com"
|
|
47
|
+
},
|
|
48
|
+
"maintainers": [
|
|
49
|
+
{
|
|
50
|
+
"name": "David Vaclavek",
|
|
51
|
+
"email": "david@localazy.com",
|
|
52
|
+
"url": "https://localazy.com"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=12.x.x <=16.x.x",
|
|
57
|
+
"npm": ">=6.0.0"
|
|
58
|
+
},
|
|
59
|
+
"license": "MIT"
|
|
60
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
LOCALAZY_OAUTH_URL: "https://testing.localazy.com/oauth/authorize",
|
|
5
|
+
LOCALAZY_OAUTH_APP_CLIENT_ID: "18503917571895066465",
|
|
6
|
+
LOCALAZY_PLUGIN_CONNECTOR_API_URL: "http://localhost:3000",
|
|
7
|
+
LOCALAZY_PUBLIC_API_URL: "https://testing.localazy.com/pubapi",
|
|
8
|
+
LOCALAZY_PLUGIN_ID: "1",
|
|
9
|
+
LOCALAZY_DEFAULT_FILE_NAME: "strapi.json",
|
|
10
|
+
LOCALAZY_DEFAULT_FILE_PATH: "",
|
|
11
|
+
LOCALAZY_DEFAULT_FILE_EXTENSION: "json",
|
|
12
|
+
LOCALAZY_DEFAULT_LOCALE: "en",
|
|
13
|
+
LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
|
|
14
|
+
LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
LOCALAZY_OAUTH_URL: "",
|
|
5
|
+
LOCALAZY_OAUTH_APP_CLIENT_ID: "",
|
|
6
|
+
LOCALAZY_PLUGIN_CONNECTOR_API_URL: "",
|
|
7
|
+
LOCALAZY_PUBLIC_API_URL: "",
|
|
8
|
+
LOCALAZY_PLUGIN_ID: "",
|
|
9
|
+
LOCALAZY_DEFAULT_FILE_NAME: "",
|
|
10
|
+
LOCALAZY_DEFAULT_FILE_PATH: "",
|
|
11
|
+
LOCALAZY_DEFAULT_FILE_EXTENSION: "",
|
|
12
|
+
LOCALAZY_DEFAULT_LOCALE: "",
|
|
13
|
+
LOCALAZY_API_USER_JWT_COOKIE_NAME: "",
|
|
14
|
+
LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// depending on the STRAPI_ADMIN_LOCALAZY_ENV, use the correct config
|
|
4
|
+
const config =
|
|
5
|
+
process.env.STRAPI_ADMIN_LOCALAZY_ENV === "development"
|
|
6
|
+
? require("./development/index")
|
|
7
|
+
: require("./production/index");
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
default: {
|
|
11
|
+
// Default plugin configuration, merged with the user configuration
|
|
12
|
+
...(config || {}),
|
|
13
|
+
},
|
|
14
|
+
validator() {},
|
|
15
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
LOCALAZY_OAUTH_URL: "https://localazy.com/oauth/authorize",
|
|
5
|
+
LOCALAZY_OAUTH_APP_CLIENT_ID: "18395772851999073783",
|
|
6
|
+
LOCALAZY_PLUGIN_CONNECTOR_API_URL:
|
|
7
|
+
"https://plugins.localazy.com/generic-connector",
|
|
8
|
+
LOCALAZY_PUBLIC_API_URL: "https://api.localazy.com",
|
|
9
|
+
LOCALAZY_PLUGIN_ID: "1",
|
|
10
|
+
LOCALAZY_DEFAULT_FILE_NAME: "strapi.json",
|
|
11
|
+
LOCALAZY_DEFAULT_FILE_PATH: "",
|
|
12
|
+
LOCALAZY_DEFAULT_FILE_EXTENSION: "json",
|
|
13
|
+
LOCALAZY_DEFAULT_LOCALE: "en",
|
|
14
|
+
LOCALAZY_API_USER_JWT_COOKIE_NAME: "LOCALAZY-API-USER-JWT",
|
|
15
|
+
LOCALAZY_API_USER_COOKIE_EXPIRATION: 7,
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
type: {
|
|
3
|
+
Job: false
|
|
4
|
+
},
|
|
5
|
+
query: `
|
|
6
|
+
jobs (sort: String, limit: Int, start: Int, where: JSON): [Job!]!
|
|
7
|
+
jobBySlug (slug: String!, publicationState: PublicationState): Job
|
|
8
|
+
`,
|
|
9
|
+
resolver: {
|
|
10
|
+
Query: {
|
|
11
|
+
jobs: {
|
|
12
|
+
description: "Return all job",
|
|
13
|
+
resolver: "application::job.job.findGQL"
|
|
14
|
+
},
|
|
15
|
+
jobBySlug: {
|
|
16
|
+
description: "Return job by slug",
|
|
17
|
+
resolver: "application::job.job.findOneBySlug"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const myController = require("./my-controller");
|
|
4
|
+
const localazyUserController = require("./localazy-user-controller");
|
|
5
|
+
const localazyAuthController = require("./localazy-auth-controller");
|
|
6
|
+
const strapiController = require("./strapi-controller");
|
|
7
|
+
const pluginSettingsController = require("./plugin-settings-controller");
|
|
8
|
+
const localazyTransferController = require("./localazy-transfer-controller");
|
|
9
|
+
const localazyProjectController = require("./localazy-project-controller");
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
myController,
|
|
13
|
+
localazyUserController,
|
|
14
|
+
localazyAuthController,
|
|
15
|
+
strapiController,
|
|
16
|
+
pluginSettingsController,
|
|
17
|
+
localazyTransferController,
|
|
18
|
+
localazyProjectController,
|
|
19
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async generateKeys(ctx) {
|
|
5
|
+
ctx.body = await strapi
|
|
6
|
+
.plugin("localazy")
|
|
7
|
+
.service("localazyAuthService")
|
|
8
|
+
.generateKeys();
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
async continuousPoll(ctx) {
|
|
12
|
+
const POLLING_LIMIT = 60;
|
|
13
|
+
const INTERVAL_PERIOD = 2000; // ms
|
|
14
|
+
const localazyAuthService = strapi
|
|
15
|
+
.plugin("localazy")
|
|
16
|
+
.service("localazyAuthService");
|
|
17
|
+
|
|
18
|
+
let counter = 1;
|
|
19
|
+
const { readKey } = ctx.query;
|
|
20
|
+
let result = await localazyAuthService.completeLogin(readKey);
|
|
21
|
+
|
|
22
|
+
let data = {
|
|
23
|
+
success: false,
|
|
24
|
+
};
|
|
25
|
+
if (!result.completed) {
|
|
26
|
+
data = await new Promise((resolve, reject) => {
|
|
27
|
+
const pollInterval = setInterval(async () => {
|
|
28
|
+
result = await localazyAuthService.completeLogin(readKey);
|
|
29
|
+
|
|
30
|
+
if (result.completed) {
|
|
31
|
+
clearInterval(pollInterval);
|
|
32
|
+
resolve(result.data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
counter += 1;
|
|
36
|
+
if (counter >= POLLING_LIMIT) {
|
|
37
|
+
clearInterval(pollInterval);
|
|
38
|
+
reject(new Error("Sign in attempts timed out."));
|
|
39
|
+
}
|
|
40
|
+
}, INTERVAL_PERIOD);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ctx.body = data;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
async getConnectedProject(ctx) {
|
|
5
|
+
const LocalazyUserService = strapi
|
|
6
|
+
.plugin("localazy")
|
|
7
|
+
.service("localazyUserService");
|
|
8
|
+
const LocalazyPubApiService = strapi
|
|
9
|
+
.plugin("localazy")
|
|
10
|
+
.service("localazyPubApiService");
|
|
11
|
+
|
|
12
|
+
const user = await LocalazyUserService.getUser();
|
|
13
|
+
const project = await LocalazyPubApiService.getProject(
|
|
14
|
+
user.project.id,
|
|
15
|
+
true,
|
|
16
|
+
true
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
ctx.body = project;
|
|
20
|
+
},
|
|
21
|
+
};
|