@crowdin/app-project-module 3.0.1 → 3.2.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.
Files changed (28) hide show
  1. package/out/middlewares/crowdin-client.d.ts +4 -2
  2. package/out/middlewares/crowdin-client.js +51 -14
  3. package/out/middlewares/integration-credentials.js +34 -12
  4. package/out/modules/integration/handlers/crowdin-files.js +34 -1
  5. package/out/modules/integration/handlers/user-error-detail.d.ts +2 -0
  6. package/out/modules/integration/handlers/user-error-detail.js +48 -0
  7. package/out/modules/integration/handlers/user-errors.d.ts +6 -0
  8. package/out/modules/integration/handlers/user-errors.js +39 -17
  9. package/out/modules/integration/index.js +8 -0
  10. package/out/modules/integration/types.d.ts +1 -0
  11. package/out/static/ui/main.bundle.js +116 -55
  12. package/out/static/ui/main.bundle.js.map +1 -1
  13. package/out/storage/drizzle/d1/index.js +2 -1
  14. package/out/storage/drizzle/d1/migrations/user-errors-indexes.d.ts +7 -0
  15. package/out/storage/drizzle/d1/migrations/user-errors-indexes.js +27 -0
  16. package/out/storage/drizzle/index.d.ts +8 -1
  17. package/out/storage/drizzle/index.js +75 -4
  18. package/out/storage/drizzle/postgresql/migrations/0003_user_errors_pagination_index.sql +5 -0
  19. package/out/storage/drizzle/postgresql/migrations/meta/0003_snapshot.json +646 -0
  20. package/out/storage/drizzle/postgresql/migrations/meta/_journal.json +7 -0
  21. package/out/storage/drizzle/sqlite/migrations/0002_user_errors_indexes.sql +4 -0
  22. package/out/storage/drizzle/sqlite/migrations/meta/0002_snapshot.json +687 -0
  23. package/out/storage/drizzle/sqlite/migrations/meta/_journal.json +7 -0
  24. package/out/storage/types.d.ts +30 -0
  25. package/out/types.d.ts +1 -0
  26. package/out/util/connection.d.ts +5 -0
  27. package/out/util/connection.js +7 -0
  28. package/package.json +1 -1
@@ -13,6 +13,27 @@ export interface UserErrors {
13
13
  crowdinId: string;
14
14
  integrationId?: string;
15
15
  }
16
+ export interface UserErrorListItem {
17
+ id: number;
18
+ action: string;
19
+ message: string;
20
+ createdAt: string;
21
+ }
22
+ export interface UserErrorsFilter {
23
+ crowdinId: string;
24
+ integrationId?: string;
25
+ search?: string;
26
+ }
27
+ export interface GetUserErrorsParams extends UserErrorsFilter {
28
+ limit: number;
29
+ offset: number;
30
+ orderDirection?: 'asc' | 'desc';
31
+ }
32
+ export interface GetUserErrorParams {
33
+ id: number;
34
+ crowdinId: string;
35
+ integrationId?: string;
36
+ }
16
37
  export type DB_TYPE = 'sqlite' | 'postgresql' | 'd1';
17
38
  export type DRIZZLE_DB = SQLITE_DB | POSTGRESQL_DB | D1_DB;
18
39
  export interface Storage {
@@ -48,7 +69,16 @@ export interface Storage {
48
69
  getWebhooks(fileId: string, integrationId: string, crowdinId: string, provider: Provider): Promise<IntegrationWebhooks | undefined>;
49
70
  saveWebhooks(fileId: string, integrationId: string, crowdinId: string, provider: Provider): Promise<void>;
50
71
  deleteWebhooks(fileIds: string[], integrationId: string, crowdinId: string, provider: Provider): Promise<void>;
72
+ /**
73
+ * @deprecated loads every error log together with its full `data` payload, which can
74
+ * exhaust memory on large tables. Use {@link Storage.getUserErrors} together with
75
+ * {@link Storage.countUserErrors} for the list and {@link Storage.getUserError} for a
76
+ * single record.
77
+ */
51
78
  getAllUserErrors(crowdinId: string, integrationId?: string): Promise<UserErrors[] | undefined>;
79
+ getUserErrors(params: GetUserErrorsParams): Promise<UserErrorListItem[]>;
80
+ countUserErrors(params: UserErrorsFilter): Promise<number>;
81
+ getUserError(params: GetUserErrorParams): Promise<UserErrors | undefined>;
52
82
  saveUserError(action: string, message: string, data: string, createdAt: string, crowdinId: string, integrationId?: string): Promise<void>;
53
83
  deleteUserErrors(date: string, crowdinId: string, integrationId?: string): Promise<void>;
54
84
  deleteAllUsersErrorsOlderThan(date: string): Promise<void>;
package/out/types.d.ts CHANGED
@@ -408,6 +408,7 @@ export interface CrowdinClientRequest extends Request {
408
408
  logInfo: LogFunction;
409
409
  logError: LogErrorFunction;
410
410
  isApiCall?: boolean;
411
+ injectedIntegrationCredentials?: any;
411
412
  }
412
413
  export interface CrowdinCredentials {
413
414
  id: string;
@@ -17,5 +17,10 @@ export interface IntegrationAccessResult {
17
17
  clientId: string;
18
18
  ownerIds: number[];
19
19
  }
20
+ export declare function buildCrowdinClientFromPat({ config, token, organization, }: {
21
+ config: Config;
22
+ token: string;
23
+ organization?: string;
24
+ }): Promise<Crowdin>;
20
25
  export declare function resolveIntegrationAccess(clientId: string): Promise<IntegrationAccessResult>;
21
26
  export declare function prepareIntegrationCredentials(config: Config, integration: IntegrationLogic, integrationCredentials: IntegrationCredentials): Promise<any>;
@@ -46,6 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.prepareCrowdinClient = prepareCrowdinClient;
49
+ exports.buildCrowdinClientFromPat = buildCrowdinClientFromPat;
49
50
  exports.resolveIntegrationAccess = resolveIntegrationAccess;
50
51
  exports.prepareIntegrationCredentials = prepareIntegrationCredentials;
51
52
  const crowdin_api_client_1 = __importDefault(require("@crowdin/crowdin-api-client"));
@@ -256,6 +257,12 @@ function prepareCrowdinClient(_a) {
256
257
  };
257
258
  });
258
259
  }
260
+ function buildCrowdinClientFromPat(_a) {
261
+ return __awaiter(this, arguments, void 0, function* ({ config, token, organization, }) {
262
+ var _b;
263
+ return new crowdin_api_client_1.default({ token, organization, apiDomain: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.apiDomain });
264
+ });
265
+ }
259
266
  function resolveIntegrationAccess(clientId) {
260
267
  return __awaiter(this, void 0, void 0, function* () {
261
268
  const { organization, projectId, userId } = (0, token_1.parseCrowdinId)(clientId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "3.0.1",
3
+ "version": "3.2.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",