@crowdin/app-project-module 0.24.3 → 0.25.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/README.md CHANGED
@@ -133,26 +133,26 @@ const configuration = {
133
133
  const directories = await client.sourceFilesApi
134
134
  .withFetchAll()
135
135
  .listProjectDirectories(projectId);
136
- const { folder, files } = await crowdinAppFunctions.getOrCreateFolder(
137
- directories.data.map((d) => d.data),
136
+ const { folder, files } = await crowdinAppFunctions.getOrCreateFolder({
137
+ directories: directories.data.map((d) => d.data),
138
138
  client,
139
139
  projectId,
140
- 'Folder from integration',
141
- rootFolder
142
- );
140
+ directoryName: 'Folder from integration',
141
+ parentDirectory: rootFolder
142
+ });
143
143
  const fileContent = {
144
144
  title: 'Hello World',
145
145
  };
146
- await crowdinAppFunctions.updateOrCreateFile(
146
+ await crowdinAppFunctions.updateOrCreateFile({
147
147
  client,
148
148
  projectId,
149
- 'integration.json',
150
- 'Sample file from integration',
151
- 'json',
152
- folder.id,
153
- fileContent,
154
- files.find((f) => f.name === 'integration.json'),
155
- );
149
+ name: 'integration.json',
150
+ title: 'Sample file from integration',
151
+ type: 'json',
152
+ directoryId: folder.id,
153
+ data: fileContent,
154
+ file: files.find((f) => f.name === 'integration.json'),
155
+ });
156
156
  return {
157
157
  message: 'Some message',
158
158
  };
@@ -163,13 +163,13 @@ const configuration = {
163
163
  const directories = await client.sourceFilesApi
164
164
  .withFetchAll()
165
165
  .listProjectDirectories(projectId);
166
- const { files } = await crowdinAppFunctions.getFolder(
167
- directories.data.map((d) => d.data),
166
+ const { files } = await crowdinAppFunctions.getFolder({
167
+ directories: directories.data.map((d) => d.data),
168
168
  client,
169
169
  projectId,
170
- 'Folder from integration',
171
- rootFolder
172
- );
170
+ directoryName: 'Folder from integration',
171
+ parentDirectory: rootFolder
172
+ });
173
173
  const file = files.find((f) => f.name === 'integration.json');
174
174
  if (file) {
175
175
  const translationsLink =
@@ -46,14 +46,27 @@ function fetchToken(config, event) {
46
46
  var _a, _b;
47
47
  return __awaiter(this, void 0, void 0, function* () {
48
48
  if (config.authenticationType === models_1.AuthenticationType.CODE) {
49
- const token = yield (0, crowdin_apps_functions_1.generateOAuthToken)(config.clientId, config.clientSecret, event.code || '', (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.accountUrl);
49
+ const token = yield (0, crowdin_apps_functions_1.generateOAuthToken)({
50
+ clientId: config.clientId,
51
+ clientSecret: config.clientSecret,
52
+ code: event.code || '',
53
+ url: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.accountUrl,
54
+ });
50
55
  return {
51
56
  accessToken: (0, util_1.encryptData)(config, token.accessToken),
52
57
  refreshToken: (0, util_1.encryptData)(config, token.refreshToken),
53
58
  expiresIn: token.expiresIn,
54
59
  };
55
60
  }
56
- const token = yield (0, crowdin_apps_functions_1.fetchAppToken)(config.identifier, event.appSecret, config.clientId, config.clientSecret, event.domain || '', event.userId, (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl);
61
+ const token = yield (0, crowdin_apps_functions_1.fetchAppToken)({
62
+ appId: config.identifier,
63
+ appSecret: event.appSecret,
64
+ clientId: config.clientId,
65
+ clientSecret: config.clientSecret,
66
+ domain: event.domain || '',
67
+ userId: event.userId,
68
+ url: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl,
69
+ });
57
70
  return {
58
71
  accessToken: (0, util_1.encryptData)(config, token.accessToken),
59
72
  expiresIn: token.expiresIn,
@@ -23,14 +23,27 @@ function refreshToken(config, credentials) {
23
23
  var _a, _b;
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  if (config.authenticationType === models_1.AuthenticationType.CODE) {
26
- const token = yield (0, crowdin_apps_functions_1.refreshOAuthToken)(config.clientId, config.clientSecret, (0, _1.decryptData)(config, credentials.refreshToken), (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.accountUrl);
26
+ const token = yield (0, crowdin_apps_functions_1.refreshOAuthToken)({
27
+ clientId: config.clientId,
28
+ clientSecret: config.clientSecret,
29
+ refreshToken: (0, _1.decryptData)(config, credentials.refreshToken),
30
+ url: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.accountUrl,
31
+ });
27
32
  return {
28
33
  accessToken: (0, _1.encryptData)(config, token.accessToken),
29
34
  refreshToken: (0, _1.encryptData)(config, token.refreshToken),
30
35
  expiresIn: token.expiresIn,
31
36
  };
32
37
  }
33
- const token = yield (0, crowdin_apps_functions_1.fetchAppToken)(config.identifier, credentials.appSecret, config.clientId, config.clientSecret, credentials.domain || '', credentials.userId, (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl);
38
+ const token = yield (0, crowdin_apps_functions_1.fetchAppToken)({
39
+ appId: config.identifier,
40
+ appSecret: credentials.appSecret,
41
+ clientId: config.clientId,
42
+ clientSecret: config.clientSecret,
43
+ domain: credentials.domain || '',
44
+ userId: credentials.userId,
45
+ url: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl,
46
+ });
34
47
  return {
35
48
  accessToken: (0, _1.encryptData)(config, token.accessToken),
36
49
  expiresIn: token.expiresIn,
@@ -37,7 +37,12 @@ function getRootFolder(config, integration, client, projectId) {
37
37
  }
38
38
  const folder = integration.appFolderName || config.name;
39
39
  const directories = (yield client.sourceFilesApi.withFetchAll().listProjectDirectories(projectId)).data.map((d) => d.data);
40
- const { folder: rootFolder } = yield crowdinAppFunctions.getOrCreateFolder(directories, client, projectId, folder);
40
+ const { folder: rootFolder } = yield crowdinAppFunctions.getOrCreateFolder({
41
+ directories,
42
+ client,
43
+ projectId,
44
+ directoryName: folder,
45
+ });
41
46
  return rootFolder;
42
47
  });
43
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.24.3",
3
+ "version": "0.25.0",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "test": "jest --config jestconfig.json"
14
14
  },
15
15
  "dependencies": {
16
- "@crowdin/crowdin-apps-functions": "~0.2.1",
16
+ "@crowdin/crowdin-apps-functions": "0.3.0",
17
17
  "@types/pg": "^8.6.5",
18
18
  "crypto-js": "^4.0.0",
19
19
  "express": "4.17.1",