@crowdin/app-project-module 0.96.3 → 0.98.0-cf-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 (79) hide show
  1. package/out/index.js +17 -6
  2. package/out/middlewares/integration-credentials.js +4 -1
  3. package/out/middlewares/render-ui-module.d.ts +3 -3
  4. package/out/middlewares/render-ui-module.js +9 -13
  5. package/out/middlewares/ui-module.js +4 -1
  6. package/out/modules/about.d.ts +1 -1
  7. package/out/modules/about.js +8 -2
  8. package/out/modules/ai-prompt-provider/index.js +4 -2
  9. package/out/modules/ai-provider/index.js +4 -2
  10. package/out/modules/ai-tools/index.js +1 -1
  11. package/out/modules/context-menu/index.js +2 -2
  12. package/out/modules/custom-mt/index.js +3 -1
  13. package/out/modules/custom-spell-check/index.js +4 -4
  14. package/out/modules/editor-right-panel/index.js +1 -1
  15. package/out/modules/external-qa-check/index.js +2 -2
  16. package/out/modules/integration/handlers/main.js +13 -1
  17. package/out/modules/integration/handlers/oauth-login.js +10 -2
  18. package/out/modules/integration/index.js +27 -21
  19. package/out/modules/integration/util/job.js +2 -4
  20. package/out/modules/integration/util/types.d.ts +2 -1
  21. package/out/modules/modal/index.js +2 -2
  22. package/out/modules/organization-menu/index.js +6 -4
  23. package/out/modules/organization-settings-menu/index.js +6 -4
  24. package/out/modules/profile-resources-menu/index.js +6 -4
  25. package/out/modules/profile-settings-menu/index.js +6 -4
  26. package/out/modules/project-menu/index.js +1 -1
  27. package/out/modules/project-menu-crowdsource/index.js +1 -1
  28. package/out/modules/project-reports/index.js +4 -2
  29. package/out/modules/project-tools/index.js +4 -2
  30. package/out/modules/workflow-step-type/index.js +3 -2
  31. package/out/storage/d1.d.ts +99 -0
  32. package/out/storage/d1.js +769 -0
  33. package/out/storage/index.d.ts +1 -0
  34. package/out/storage/index.js +8 -1
  35. package/out/storage/mysql.d.ts +1 -0
  36. package/out/storage/mysql.js +7 -1
  37. package/out/storage/postgre.d.ts +1 -0
  38. package/out/storage/postgre.js +2 -1
  39. package/out/storage/sqlite.d.ts +1 -0
  40. package/out/storage/sqlite.js +2 -1
  41. package/out/types.d.ts +10 -0
  42. package/out/util/index.d.ts +1 -0
  43. package/out/util/index.js +8 -2
  44. package/out/util/jsx-renderer.d.ts +6 -0
  45. package/out/util/jsx-renderer.js +13 -0
  46. package/out/util/static-files.d.ts +19 -0
  47. package/out/util/static-files.js +80 -0
  48. package/out/views/AboutPage.d.ts +9 -0
  49. package/out/views/AboutPage.js +79 -0
  50. package/out/views/ErrorPage.d.ts +18 -0
  51. package/out/views/ErrorPage.js +56 -0
  52. package/out/views/FormPage.d.ts +13 -0
  53. package/out/views/FormPage.js +27 -0
  54. package/out/views/InstallPage.d.ts +10 -0
  55. package/out/views/InstallPage.js +22 -0
  56. package/out/views/LoginPage.d.ts +33 -0
  57. package/out/views/LoginPage.js +199 -0
  58. package/out/views/MainPage.d.ts +79 -0
  59. package/out/views/MainPage.js +1613 -0
  60. package/out/views/OAuthPage.d.ts +7 -0
  61. package/out/views/OAuthPage.js +17 -0
  62. package/out/views/SubscriptionPage.d.ts +7 -0
  63. package/out/views/SubscriptionPage.js +26 -0
  64. package/out/views/index.d.ts +13 -0
  65. package/out/views/index.js +25 -0
  66. package/out/views/layout/Head.d.ts +9 -0
  67. package/out/views/layout/Head.js +54 -0
  68. package/package.json +12 -11
  69. package/out/util/handlebars.d.ts +0 -1
  70. package/out/util/handlebars.js +0 -46
  71. package/out/views/about.handlebars +0 -102
  72. package/out/views/error.handlebars +0 -54
  73. package/out/views/form.handlebars +0 -30
  74. package/out/views/install.handlebars +0 -16
  75. package/out/views/login.handlebars +0 -331
  76. package/out/views/main.handlebars +0 -1857
  77. package/out/views/oauth.handlebars +0 -11
  78. package/out/views/partials/head.handlebars +0 -53
  79. package/out/views/subscription.handlebars +0 -26
@@ -7,16 +7,18 @@ exports.register = void 0;
7
7
  const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
8
8
  const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
9
  const util_1 = require("../../util");
10
+ const static_files_1 = require("../../util/static-files");
10
11
  function register({ config, app }) {
12
+ var _a, _b;
11
13
  if (!config.profileSettingsMenu) {
12
14
  return;
13
15
  }
14
- app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/profile-settings'), (req, res) => { var _a; return res.sendFile(((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
+ app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/profile-settings'), (0, static_files_1.serveFile)(config, ((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath));
15
17
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
16
- app.use('/profile-settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileSettingsMenu.key }), (0, render_ui_module_1.default)(config.profileSettingsMenu));
18
+ app.use('/profile-settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileSettingsMenu.key }), (0, render_ui_module_1.default)(config.profileSettingsMenu, config));
17
19
  // TEMPORARY CODE: it needs to support old path
18
- app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings'), (req, res) => { var _a; return res.sendFile(((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
19
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized }), (0, render_ui_module_1.default)(config.profileSettingsMenu));
20
+ app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings'), (0, static_files_1.serveFile)(config, ((_b = config.profileSettingsMenu) === null || _b === void 0 ? void 0 : _b.imagePath) || config.imagePath));
21
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized }), (0, render_ui_module_1.default)(config.profileSettingsMenu, config));
20
22
  // END TEMPORARY CODE
21
23
  }
22
24
  exports.register = register;
@@ -12,6 +12,6 @@ function register({ config, app }) {
12
12
  return;
13
13
  }
14
14
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
- app.use('/project-menu', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectMenu.key }), (0, render_ui_module_1.default)(config.projectMenu));
15
+ app.use('/project-menu', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectMenu.key }), (0, render_ui_module_1.default)(config.projectMenu, config));
16
16
  }
17
17
  exports.register = register;
@@ -12,6 +12,6 @@ function register({ config, app }) {
12
12
  return;
13
13
  }
14
14
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
- app.use('/project-menu-crowdsource', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectMenuCrowdsource.key }), (0, render_ui_module_1.default)(config.projectMenuCrowdsource));
15
+ app.use('/project-menu-crowdsource', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectMenuCrowdsource.key }), (0, render_ui_module_1.default)(config.projectMenuCrowdsource, config));
16
16
  }
17
17
  exports.register = register;
@@ -7,12 +7,14 @@ exports.register = void 0;
7
7
  const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
8
8
  const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
9
  const util_1 = require("../../util");
10
+ const static_files_1 = require("../../util/static-files");
10
11
  function register({ config, app }) {
12
+ var _a;
11
13
  if (!config.projectReports) {
12
14
  return;
13
15
  }
14
16
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
- app.get((0, util_1.getLogoUrl)(config.projectReports, '/reports'), (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
- app.use('/reports', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectReports.key }), (0, render_ui_module_1.default)(config.projectReports));
17
+ app.get((0, util_1.getLogoUrl)(config.projectReports, '/reports'), (0, static_files_1.serveFile)(config, ((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath));
18
+ app.use('/reports', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectReports.key }), (0, render_ui_module_1.default)(config.projectReports, config));
17
19
  }
18
20
  exports.register = register;
@@ -7,12 +7,14 @@ exports.register = void 0;
7
7
  const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
8
8
  const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
9
  const util_1 = require("../../util");
10
+ const static_files_1 = require("../../util/static-files");
10
11
  function register({ config, app }) {
12
+ var _a;
11
13
  if (!config.projectTools) {
12
14
  return;
13
15
  }
14
16
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
- app.get((0, util_1.getLogoUrl)(config.projectTools, '/tools'), (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
- app.use('/tools', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectTools.key }), (0, render_ui_module_1.default)(config.projectTools));
17
+ app.get((0, util_1.getLogoUrl)(config.projectTools, '/tools'), (0, static_files_1.serveFile)(config, ((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath));
18
+ app.use('/tools', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.projectTools.key }), (0, render_ui_module_1.default)(config.projectTools, config));
17
19
  }
18
20
  exports.register = register;
@@ -11,6 +11,7 @@ const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-clie
11
11
  const step_settings_save_1 = __importDefault(require("./handlers/step-settings-save"));
12
12
  const delete_step_1 = __importDefault(require("./handlers/delete-step"));
13
13
  const util_2 = require("../../util");
14
+ const static_files_1 = require("../../util/static-files");
14
15
  function register({ config, app }) {
15
16
  if (!config.workflowStepType) {
16
17
  return;
@@ -42,10 +43,10 @@ function register({ config, app }) {
42
43
  }), (0, delete_step_1.default)(workflowStep));
43
44
  // END TEMPORARY CODE
44
45
  if (workflowStep.imagePath) {
45
- app.get((0, util_2.getLogoUrl)(workflowStep, `-${workflowStep.key}`), (req, res) => res.sendFile(workflowStep.imagePath || config.imagePath));
46
+ app.get((0, util_2.getLogoUrl)(workflowStep, `-${workflowStep.key}`), (0, static_files_1.serveFile)(config, workflowStep.imagePath || config.imagePath));
46
47
  }
47
48
  if (workflowStep.settingsUiModule) {
48
- app.use((0, util_1.getWorkflowStepUrl)('/workflow-step', workflowStep), (0, ui_module_1.default)({ config, moduleType: workflowStep.key }), (0, render_ui_module_1.default)(workflowStep.settingsUiModule));
49
+ app.use((0, util_1.getWorkflowStepUrl)('/workflow-step', workflowStep), (0, ui_module_1.default)({ config, moduleType: workflowStep.key }), (0, render_ui_module_1.default)(workflowStep.settingsUiModule, config));
49
50
  }
50
51
  }
51
52
  }
@@ -0,0 +1,99 @@
1
+ import type { D1Database } from '@cloudflare/workers-types';
2
+ import { Storage } from '.';
3
+ import { CrowdinCredentials } from '../types';
4
+ import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
5
+ import { CreateJobParams, GetActiveJobsParams, GetJobParams, GetFileTranslationCacheByLanguageParams, Job, TranslationCache, UpdateJobParams, UpdateTranslationCacheParams, GetFileTranslationCache, UnsyncedFiles, GetUnsyncedFiles, IntegrationSyncedData } from '../modules/integration/util/types';
6
+ import { UserErrors } from './types';
7
+ export interface D1StorageConfig {
8
+ /**
9
+ * Cloudflare D1 database binding
10
+ * This should be passed from env.DB in Workers/Pages Functions
11
+ */
12
+ database: D1Database;
13
+ }
14
+ export declare class D1Storage implements Storage {
15
+ private db;
16
+ private migrated;
17
+ tables: {
18
+ crowdin_credentials: string;
19
+ integration_credentials: string;
20
+ sync_settings: string;
21
+ app_metadata: string;
22
+ files_snapshot: string;
23
+ webhooks: string;
24
+ user_errors: string;
25
+ integration_settings: string;
26
+ job: string;
27
+ translation_file_cache: string;
28
+ unsynced_files: string;
29
+ synced_data: string;
30
+ };
31
+ constructor(config: D1StorageConfig);
32
+ ensureMigrated(): Promise<void>;
33
+ migrate(): Promise<void>;
34
+ saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
35
+ updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
36
+ getCrowdinCredentials(id: string): Promise<CrowdinCredentials | undefined>;
37
+ getAllCrowdinCredentials(): Promise<CrowdinCredentials[]>;
38
+ deleteCrowdinCredentials(id: string): Promise<void>;
39
+ saveIntegrationCredentials(id: string, credentials: any, crowdinId: string): Promise<void>;
40
+ updateIntegrationCredentials(id: string, credentials: any): Promise<void>;
41
+ updateIntegrationManagers(id: string, managers: any): Promise<void>;
42
+ getIntegrationCredentials(id: string): Promise<IntegrationCredentials | undefined>;
43
+ getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
44
+ deleteIntegrationCredentials(id: string): Promise<void>;
45
+ deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
46
+ saveMetadata(id: string, metadata: any, crowdinId: string): Promise<void>;
47
+ updateMetadata(id: string, metadata: any, crowdinId: string): Promise<void>;
48
+ getMetadata(id: string): Promise<any>;
49
+ getAllMetadata(): Promise<any[]>;
50
+ deleteMetadata(id: string): Promise<void>;
51
+ getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
52
+ getSyncSettingsBySchedule(type: string, schedule: string): Promise<IntegrationSyncSettings[]>;
53
+ saveSyncSettings(files: any, integrationId: string, crowdinId: string, type: string, provider: string): Promise<void>;
54
+ updateSyncSettings(files: any, integrationId: string, crowdinId: string, type: string, provider: string): Promise<void>;
55
+ getSyncSettings(integrationId: string, crowdinId: string, type: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
56
+ saveFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
57
+ updateFilesSnapshot(files: any, integrationId: string, crowdinId: string, provider: string): Promise<void>;
58
+ getFilesSnapshot(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationFilesSnapshot | undefined>;
59
+ getAllWebhooks(integrationId: string, crowdinId: string, provider: string): Promise<IntegrationWebhooks[] | undefined>;
60
+ getWebhooks(fileId: string, integrationId: string, crowdinId: string, provider: string): Promise<IntegrationWebhooks | undefined>;
61
+ saveWebhooks(fileId: string, integrationId: string, crowdinId: string, provider: string): Promise<void>;
62
+ deleteWebhooks(fileIds: any[], integrationId: string, crowdinId: string, provider: string): Promise<void>;
63
+ getAllUserErrors(crowdinId: string, integrationId?: string): Promise<UserErrors[] | undefined>;
64
+ saveUserError(action: string, message: string, data: any, createdAt: string, crowdinId: string, integrationId?: string): Promise<void>;
65
+ deleteUserErrors(date: string, crowdinId: string, integrationId?: string): Promise<void>;
66
+ deleteAllUsersErrorsOlderThan(date: string): Promise<void>;
67
+ saveIntegrationConfig(integrationId: string, crowdinId: string, config: any): Promise<void>;
68
+ getAllIntegrationConfigs(crowdinId: string): Promise<IntegrationConfig[]>;
69
+ getIntegrationConfig(integrationId: string): Promise<IntegrationConfig | undefined>;
70
+ updateIntegrationConfig(integrationId: string, config: any): Promise<void>;
71
+ createJob(params: CreateJobParams): Promise<string>;
72
+ updateJob(params: UpdateJobParams): Promise<void>;
73
+ getJob(params: GetJobParams): Promise<Job | undefined>;
74
+ getActiveJobs(params: GetActiveJobsParams): Promise<Job[] | undefined>;
75
+ deleteFinishedJobs(): Promise<void>;
76
+ getAllInProgressJobs(): Promise<Job[] | undefined>;
77
+ saveTranslationCache(params: TranslationCache): Promise<void>;
78
+ getFileTranslationCache(params: GetFileTranslationCache): Promise<TranslationCache[] | undefined>;
79
+ getFileTranslationCacheByLanguage(params: GetFileTranslationCacheByLanguageParams): Promise<TranslationCache | undefined>;
80
+ updateTranslationCache(params: UpdateTranslationCacheParams): Promise<void>;
81
+ saveUnsyncedFiles(params: UnsyncedFiles): Promise<void>;
82
+ updateUnsyncedFiles(params: UnsyncedFiles): Promise<void>;
83
+ getUnsyncedFiles(params: GetUnsyncedFiles): Promise<UnsyncedFiles | undefined>;
84
+ registerCustomTable(tableName: string, schema: Record<string, string>): Promise<void>;
85
+ insertRecord(tableName: string, data: Record<string, any>): Promise<void>;
86
+ selectRecords(tableName: string, options?: {
87
+ columns?: string[];
88
+ whereClause?: string;
89
+ orderBy?: string;
90
+ limit?: number;
91
+ offset?: number;
92
+ distinct?: boolean;
93
+ }, params?: any[]): Promise<any[]>;
94
+ updateRecord(tableName: string, data: Record<string, any>, whereClause: string, params?: any[]): Promise<void>;
95
+ deleteRecord(tableName: string, whereClause: string, params?: any[]): Promise<void>;
96
+ saveSyncedData(files: any, integrationId: string, crowdinId: string, type: string): Promise<void>;
97
+ updateSyncedData(files: any, integrationId: string, crowdinId: string, type: string): Promise<void>;
98
+ getSyncedData(integrationId: string, crowdinId: string, type: string): Promise<IntegrationSyncedData | undefined>;
99
+ }