@crowdin/app-project-module 0.95.2 → 0.96.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/out/modules/integration/handlers/crowdin-update.js +11 -0
- package/out/modules/integration/types.d.ts +1 -0
- package/out/modules/integration/util/files.js +17 -2
- package/out/modules/integration/util/job.js +2 -1
- package/out/modules/integration/util/snapshot.js +1 -1
- package/out/modules/integration/util/types.d.ts +3 -1
- package/out/modules/manifest.js +1 -2
- package/out/static/js/form.js +2 -2
- package/out/storage/mysql.d.ts +1 -1
- package/out/storage/mysql.js +9 -1
- package/out/storage/postgre.d.ts +1 -1
- package/out/storage/postgre.js +11 -4
- package/out/storage/sqlite.d.ts +1 -1
- package/out/storage/sqlite.js +10 -4
- package/out/util/connection.js +50 -36
- package/out/util/index.js +1 -1
- package/package.json +1 -1
|
@@ -74,6 +74,17 @@ function handle(config, integration) {
|
|
|
74
74
|
job,
|
|
75
75
|
excludedTargetLanguages: req.query.languages ? excludedTargetLanguages : undefined,
|
|
76
76
|
});
|
|
77
|
+
const currentJob = yield job.get();
|
|
78
|
+
if (currentJob && (currentJob === null || currentJob === void 0 ? void 0 : currentJob.errors)) {
|
|
79
|
+
const errors = JSON.parse(currentJob.errors);
|
|
80
|
+
yield (0, logger_1.handleUserError)({
|
|
81
|
+
action: 'Sync files to Crowdin',
|
|
82
|
+
error: errors,
|
|
83
|
+
crowdinId: req.crowdinContext.crowdinId,
|
|
84
|
+
clientId: req.crowdinContext.clientId,
|
|
85
|
+
});
|
|
86
|
+
throw errors.toString();
|
|
87
|
+
}
|
|
77
88
|
try {
|
|
78
89
|
yield (0, files_1.updateSyncedData)(req.crowdinContext.clientId, req.crowdinContext.crowdinId, payload, types_2.Provider.INTEGRATION);
|
|
79
90
|
}
|
|
@@ -46,11 +46,26 @@ function expandFilesTree(nodes, req, integration, job) {
|
|
|
46
46
|
const files = nodes.filter((file) => file.nodeType === undefined || file.nodeType === '1');
|
|
47
47
|
const folders = nodes.filter((folder) => folder.nodeType === '0' && !nodes.find((node) => node.parentId === folder.id));
|
|
48
48
|
for (const { id } of folders) {
|
|
49
|
-
|
|
49
|
+
let integrationData = [];
|
|
50
|
+
try {
|
|
51
|
+
integrationData = yield integration.getIntegrationFiles(req.integrationCredentials, req.integrationSettings, id);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
if (job) {
|
|
55
|
+
const currentJob = yield job.get();
|
|
56
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
57
|
+
const currentErrors = (currentJob === null || currentJob === void 0 ? void 0 : currentJob.errors) ? JSON.parse(currentJob.errors) : [];
|
|
58
|
+
const newErrors = [...currentErrors, errorMessage];
|
|
59
|
+
yield job.update({ errors: newErrors });
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
50
63
|
const integrationTreeItems = isExtendedResultType(integrationData)
|
|
51
64
|
? integrationData.data
|
|
52
65
|
: integrationData;
|
|
53
|
-
const checkNodes = integrationTreeItems
|
|
66
|
+
const checkNodes = integrationTreeItems
|
|
67
|
+
.filter((item) => item.id !== id)
|
|
68
|
+
.map((item) => (Object.assign(Object.assign({}, item), { nodeType: item.nodeType || ('type' in item ? '1' : '0') })));
|
|
54
69
|
const expandedResult = yield expandFilesTree(checkNodes, req, integration, job);
|
|
55
70
|
files.push(...expandedResult);
|
|
56
71
|
}
|
|
@@ -85,7 +85,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
|
|
|
85
85
|
return yield storage.getJob({ id: jobId });
|
|
86
86
|
});
|
|
87
87
|
},
|
|
88
|
-
update: function updateProgress({ progress, status, info, data, attempt }) {
|
|
88
|
+
update: function updateProgress({ progress, status, info, data, attempt, errors, }) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
const prevData = yield this.get();
|
|
91
91
|
if ((prevData === null || prevData === void 0 ? void 0 : prevData.status) === types_1.JobStatus.CANCELED) {
|
|
@@ -98,6 +98,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
|
|
|
98
98
|
info,
|
|
99
99
|
data: JSON.stringify(data),
|
|
100
100
|
attempt,
|
|
101
|
+
errors,
|
|
101
102
|
});
|
|
102
103
|
return { isCanceled: false };
|
|
103
104
|
});
|
|
@@ -38,7 +38,7 @@ function getTreeItems(integrationData) {
|
|
|
38
38
|
function getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, parentFiles) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
for (const file of parentFiles) {
|
|
41
|
-
if (!
|
|
41
|
+
if (!file.type) {
|
|
42
42
|
let childs = yield integration.getIntegrationFiles(integrationCredentials, integrationSettings, file.id, '', 0);
|
|
43
43
|
childs = getTreeItems(childs);
|
|
44
44
|
if (childs.length > 0) {
|
|
@@ -40,6 +40,7 @@ export interface Job {
|
|
|
40
40
|
eta?: number;
|
|
41
41
|
info?: string;
|
|
42
42
|
attempt?: number;
|
|
43
|
+
errors?: string;
|
|
43
44
|
}
|
|
44
45
|
export type GetJobParams = Pick<Job, 'id'>;
|
|
45
46
|
export type GetActiveJobsParams = Pick<Job, 'integrationId' | 'crowdinId'>;
|
|
@@ -51,6 +52,7 @@ export type UpdateJobParams = {
|
|
|
51
52
|
info?: string;
|
|
52
53
|
data?: string;
|
|
53
54
|
attempt?: number;
|
|
55
|
+
errors?: string[];
|
|
54
56
|
};
|
|
55
57
|
export type JobClient = {
|
|
56
58
|
get: () => Promise<Job | undefined>;
|
|
@@ -61,7 +63,7 @@ export type JobClient = {
|
|
|
61
63
|
markFilesAsUnsynced: MarkUnsyncedFiles;
|
|
62
64
|
unmarkFilesAsUnsynced: UnmarkUnsyncedFiles;
|
|
63
65
|
};
|
|
64
|
-
export type UpdateJobProgress = ({ progress, status, info, data, attempt, }: Omit<UpdateJobParams, 'id'>) => Promise<{
|
|
66
|
+
export type UpdateJobProgress = ({ progress, status, info, data, attempt, errors, }: Omit<UpdateJobParams, 'id'>) => Promise<{
|
|
65
67
|
isCanceled: boolean;
|
|
66
68
|
}>;
|
|
67
69
|
export interface GetAllNewFilesArgs {
|
package/out/modules/manifest.js
CHANGED
|
@@ -378,12 +378,11 @@ function handle(config) {
|
|
|
378
378
|
if (!(0, subscription_1.isAppFree)(config)) {
|
|
379
379
|
events['subscription_paid'] = '/subscription-paid';
|
|
380
380
|
}
|
|
381
|
-
const defaultScopes = config.projectIntegration ? [types_1.Scope.USERS, types_1.Scope.PROJECTS] : [types_1.Scope.PROJECTS];
|
|
382
381
|
return (_req, res) => {
|
|
383
382
|
const manifest = Object.assign(Object.assign(Object.assign(Object.assign({ identifier: config.identifier, name: config.name, logo: (0, util_1.getLogoUrl)(), baseUrl: config.baseUrl, authentication: {
|
|
384
383
|
type: config.authenticationType || types_1.AuthenticationType.APP,
|
|
385
384
|
clientId: config.clientId,
|
|
386
|
-
}, restrictAiToSameApp: config.restrictAiToSameApp }, (config.agent && { agent: config.agent })), { events, scopes: config.scopes ? config.scopes :
|
|
385
|
+
}, restrictAiToSameApp: config.restrictAiToSameApp }, (config.agent && { agent: config.agent })), { events, scopes: config.scopes ? config.scopes : [types_1.Scope.PROJECTS] }), (config.defaultPermissions && { default_permissions: config.defaultPermissions })), { modules });
|
|
387
386
|
res.send(manifest);
|
|
388
387
|
};
|
|
389
388
|
}
|