@crowdin/app-project-module 0.96.3 → 0.97.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.
@@ -104,7 +104,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
104
104
  });
105
105
  },
106
106
  type: jobType,
107
- fetchTranslation: ({ fileId, languageId }) => __awaiter(this, void 0, void 0, function* () {
107
+ fetchTranslation: ({ fileId, languageId, params }) => __awaiter(this, void 0, void 0, function* () {
108
108
  var _a, _b, _c;
109
109
  const translationCache = isDbStore
110
110
  ? yield storage.getFileTranslationCacheByLanguage({
@@ -140,9 +140,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
140
140
  let translation = null;
141
141
  try {
142
142
  (0, logger_1.log)(`Receiving translation for file ${fileId} in language ${languageId}`);
143
- translation = yield client.translationsApi.buildProjectFileTranslation(projectId, fileId, {
144
- targetLanguageId: languageId,
145
- }, (translationCache === null || translationCache === void 0 ? void 0 : translationCache.etag) && !forcePushTranslations ? translationCache === null || translationCache === void 0 ? void 0 : translationCache.etag : undefined);
143
+ translation = yield client.translationsApi.buildProjectFileTranslation(projectId, fileId, Object.assign({ targetLanguageId: languageId }, (params !== null && params !== void 0 ? params : {})), (translationCache === null || translationCache === void 0 ? void 0 : translationCache.etag) && !forcePushTranslations ? translationCache === null || translationCache === void 0 ? void 0 : translationCache.etag : undefined);
146
144
  return translation;
147
145
  }
148
146
  catch (e) {
@@ -84,9 +84,10 @@ export type SaveUploadedFileTranslation = ({ fileId, translationParams, }: {
84
84
  etag: string;
85
85
  }[];
86
86
  }) => Promise<void>;
87
- export type FetchTranslation = ({ fileId, languageId, }: {
87
+ export type FetchTranslation = ({ fileId, languageId, params, }: {
88
88
  fileId: number;
89
89
  languageId: string;
90
+ params?: Omit<TranslationsModel.BuildProjectFileTranslationRequest, 'targetLanguageId'>;
90
91
  }) => Promise<ResponseObject<TranslationsModel.BuildProjectFileTranslationResponse> | null>;
91
92
  export interface TranslationCache {
92
93
  integrationId: string;
@@ -76,6 +76,7 @@ export interface Storage {
76
76
  whereClause?: string;
77
77
  orderBy?: string;
78
78
  limit?: number;
79
+ offset?: number;
79
80
  distinct?: boolean;
80
81
  }, params?: any[]): Promise<any[]>;
81
82
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -97,6 +97,7 @@ export declare class MySQLStorage implements Storage {
97
97
  whereClause?: string;
98
98
  orderBy?: string;
99
99
  limit?: number;
100
+ offset?: number;
100
101
  distinct?: boolean;
101
102
  }, params?: any[]): Promise<any[]>;
102
103
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -873,7 +873,13 @@ class MySQLStorage {
873
873
  const distinctKeyword = options.distinct ? 'DISTINCT ' : '';
874
874
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
875
875
  const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
876
- const limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
876
+ let limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
877
+ if (!options.limit && options.offset) {
878
+ throw new Error('[selectRecords] Limit is required for pagination with MySQL');
879
+ }
880
+ else if (options.limit && options.offset) {
881
+ limitClause += ` OFFSET ${options.offset}`;
882
+ }
877
883
  const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
878
884
  return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
879
885
  const [rows] = yield connection.execute(query, params);
@@ -108,6 +108,7 @@ export declare class PostgreStorage implements Storage {
108
108
  whereClause?: string;
109
109
  orderBy?: string;
110
110
  limit?: number;
111
+ offset?: number;
111
112
  distinct?: boolean;
112
113
  }, params?: any[]): Promise<any[]>;
113
114
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -886,7 +886,8 @@ class PostgreStorage {
886
886
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
887
887
  const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
888
888
  const limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
889
- const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
889
+ const offsetClause = options.offset ? ` OFFSET ${options.offset}` : '';
890
+ const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause}${offsetClause};`;
890
891
  return this.executeQuery((client) => __awaiter(this, void 0, void 0, function* () {
891
892
  const res = yield client.query(query, params);
892
893
  return res.rows;
@@ -95,6 +95,7 @@ export declare class SQLiteStorage implements Storage {
95
95
  whereClause?: string;
96
96
  orderBy?: string;
97
97
  limit?: number;
98
+ offset?: number;
98
99
  distinct?: boolean;
99
100
  }, params?: any[]): Promise<any[]>;
100
101
  updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
@@ -745,7 +745,8 @@ class SQLiteStorage {
745
745
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
746
746
  const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
747
747
  const limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
748
- const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
748
+ const offsetClause = options.offset ? ` OFFSET ${options.offset}` : '';
749
+ const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause}${offsetClause};`;
749
750
  return this.each(query, params);
750
751
  });
751
752
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.96.3",
3
+ "version": "0.97.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",