@crowdin/app-project-module 0.24.1 → 0.24.3

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.
@@ -370,19 +370,25 @@ export interface MessageResult<T> {
370
370
  message?: string;
371
371
  }
372
372
  export declare type TreeItem = File | Folder;
373
+ /**
374
+ * 0 - folder
375
+ * 1 - file
376
+ * 2 - branch
377
+ */
378
+ declare type IntegrationTreeElementType = '0' | '1' | '2';
373
379
  export interface File {
374
380
  id: string;
375
381
  name: string;
376
382
  type: SourceFilesModel.FileType;
377
383
  parentId?: string;
378
- nodeType?: string;
384
+ nodeType?: IntegrationTreeElementType;
379
385
  customContent?: string;
380
386
  }
381
387
  export interface Folder {
382
388
  id: string;
383
389
  name: string;
384
390
  parentId?: string;
385
- nodeType?: string;
391
+ nodeType?: IntegrationTreeElementType;
386
392
  customContent?: string;
387
393
  }
388
394
  export interface IntegrationRequest extends CrowdinClientRequest {
@@ -66,7 +66,7 @@ function prepareCrowdinClient(config, credentials) {
66
66
  expire: (new Date().getTime() / 1000 + newCredentials.expiresIn).toString(),
67
67
  type: credentials.type,
68
68
  });
69
- const token = (0, _1.decryptData)(config, credentials.accessToken);
69
+ const token = (0, _1.decryptData)(config, newCredentials.accessToken);
70
70
  return {
71
71
  client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.apiUrl }),
72
72
  token,
@@ -50,6 +50,7 @@ exports.getOauthRoute = getOauthRoute;
50
50
  function applyDefaults(config, integration) {
51
51
  if (!integration.getCrowdinFiles) {
52
52
  integration.getCrowdinFiles = (projectId, client, rootFolder) => __awaiter(this, void 0, void 0, function* () {
53
+ const allBranches = (yield client.sourceFilesApi.withFetchAll().listProjectBranches(projectId)).data.map((d) => d.data);
53
54
  let allDirectories;
54
55
  if (rootFolder) {
55
56
  allDirectories = (yield client.sourceFilesApi.withFetchAll().listProjectDirectories(projectId, {
@@ -67,7 +68,20 @@ function applyDefaults(config, integration) {
67
68
  (!rootFolder && !f.directoryId));
68
69
  const res = [];
69
70
  allDirectories.forEach((e) => {
70
- const parentId = rootFolder && e.directoryId === rootFolder.id ? undefined : e.directoryId;
71
+ let parentId = rootFolder && e.directoryId === rootFolder.id ? undefined : e.directoryId;
72
+ if (!parentId && e.branchId) {
73
+ const branch = allBranches.find((branch) => branch.id === e.branchId);
74
+ if (branch) {
75
+ parentId = branch.id;
76
+ if (!res.find((node) => node.id === branch.id.toString())) {
77
+ res.push({
78
+ id: branch.id.toString(),
79
+ name: branch.name,
80
+ nodeType: '2',
81
+ });
82
+ }
83
+ }
84
+ }
71
85
  res.push({
72
86
  id: e.id.toString(),
73
87
  parentId: parentId ? parentId.toString() : undefined,
@@ -75,7 +89,20 @@ function applyDefaults(config, integration) {
75
89
  });
76
90
  });
77
91
  files.forEach((e) => {
78
- const parentId = rootFolder && e.directoryId === rootFolder.id ? undefined : e.directoryId;
92
+ let parentId = rootFolder && e.directoryId === rootFolder.id ? undefined : e.directoryId;
93
+ if (!parentId && e.branchId) {
94
+ const branch = allBranches.find((branch) => branch.id === e.branchId);
95
+ if (branch) {
96
+ parentId = branch.id;
97
+ if (!res.find((node) => node.id === branch.id.toString())) {
98
+ res.push({
99
+ id: branch.id.toString(),
100
+ name: branch.name,
101
+ nodeType: '2',
102
+ });
103
+ }
104
+ }
105
+ }
79
106
  res.push({
80
107
  id: e.id.toString(),
81
108
  parentId: parentId ? parentId.toString() : undefined,
@@ -175,6 +175,7 @@
175
175
 
176
176
  const folderType = '0';
177
177
  const fileType = '1';
178
+ const branchType = '2';
178
179
 
179
180
  let project = {};
180
181
  let crowdinData = [];
@@ -409,10 +410,14 @@
409
410
  {{/if}}
410
411
  });
411
412
  }
413
+ {{else}}
414
+ const settingsModal = undefined;
412
415
  {{/if}}
413
416
 
414
417
  {{#if infoModal}}
415
418
  const infoModal = document.getElementById('info-modal');
419
+ {{else}}
420
+ const infoModal = undefined;
416
421
  {{/if}}
417
422
 
418
423
  document.addEventListener('keydown', (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.24.1",
3
+ "version": "0.24.3",
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",