@etohq/translation 1.5.5-next-20260317140633

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +8 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/joiner-config.d.ts +3 -0
  8. package/dist/joiner-config.d.ts.map +1 -0
  9. package/dist/joiner-config.js +7 -0
  10. package/dist/joiner-config.js.map +1 -0
  11. package/dist/migrations/Migration20251208124155.d.ts +6 -0
  12. package/dist/migrations/Migration20251208124155.d.ts.map +1 -0
  13. package/dist/migrations/Migration20251208124155.js +26 -0
  14. package/dist/migrations/Migration20251208124155.js.map +1 -0
  15. package/dist/migrations/Migration20251215083927.d.ts +6 -0
  16. package/dist/migrations/Migration20251215083927.d.ts.map +1 -0
  17. package/dist/migrations/Migration20251215083927.js +14 -0
  18. package/dist/migrations/Migration20251215083927.js.map +1 -0
  19. package/dist/migrations/Migration20251218140235.d.ts +6 -0
  20. package/dist/migrations/Migration20251218140235.d.ts.map +1 -0
  21. package/dist/migrations/Migration20251218140235.js +17 -0
  22. package/dist/migrations/Migration20251218140235.js.map +1 -0
  23. package/dist/migrations/Migration20260108122757.d.ts +6 -0
  24. package/dist/migrations/Migration20260108122757.d.ts.map +1 -0
  25. package/dist/migrations/Migration20260108122757.js +14 -0
  26. package/dist/migrations/Migration20260108122757.js.map +1 -0
  27. package/dist/models/index.d.ts +4 -0
  28. package/dist/models/index.d.ts.map +1 -0
  29. package/dist/models/index.js +13 -0
  30. package/dist/models/index.js.map +1 -0
  31. package/dist/models/locale.d.ts +7 -0
  32. package/dist/models/locale.d.ts.map +1 -0
  33. package/dist/models/locale.js +17 -0
  34. package/dist/models/locale.js.map +1 -0
  35. package/dist/models/settings.d.ts +8 -0
  36. package/dist/models/settings.d.ts.map +1 -0
  37. package/dist/models/settings.js +18 -0
  38. package/dist/models/settings.js.map +1 -0
  39. package/dist/models/translation.d.ts +10 -0
  40. package/dist/models/translation.d.ts.map +1 -0
  41. package/dist/models/translation.js +32 -0
  42. package/dist/models/translation.js.map +1 -0
  43. package/dist/services/index.d.ts +2 -0
  44. package/dist/services/index.d.ts.map +1 -0
  45. package/dist/services/index.js +9 -0
  46. package/dist/services/index.js.map +1 -0
  47. package/dist/services/translation-module-service.d.ts +55 -0
  48. package/dist/services/translation-module-service.d.ts.map +1 -0
  49. package/dist/services/translation-module-service.js +442 -0
  50. package/dist/services/translation-module-service.js.map +1 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -0
  52. package/dist/utils/compute-translated-field-count.d.ts +2 -0
  53. package/dist/utils/compute-translated-field-count.d.ts.map +1 -0
  54. package/dist/utils/compute-translated-field-count.js +13 -0
  55. package/dist/utils/compute-translated-field-count.js.map +1 -0
  56. package/dist/utils/filter-translation-fields.d.ts +3 -0
  57. package/dist/utils/filter-translation-fields.d.ts.map +1 -0
  58. package/dist/utils/filter-translation-fields.js +22 -0
  59. package/dist/utils/filter-translation-fields.js.map +1 -0
  60. package/dist/utils/index.d.ts +3 -0
  61. package/dist/utils/index.d.ts.map +1 -0
  62. package/dist/utils/index.js +19 -0
  63. package/dist/utils/index.js.map +1 -0
  64. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Etohq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Translation Module
2
+
3
+ The Translation module stores localized field values for resources and exposes APIs to list, create, and query translations, along with translation settings and statistics.
4
+
5
+ ## Translatable fields source of truth
6
+
7
+ Translatable fields are declared in DML models using `.translatable()` (for example `model.text().translatable()`).
8
+
9
+ On application start, the module syncs `translation_settings` based on the currently registered translatable entities and fields.
10
+
11
+ ## Notes
12
+
13
+ - Translations are filtered to only include fields marked translatable for the entity type.
14
+ - `translated_field_count` is maintained for efficient statistics aggregation.
15
+
@@ -0,0 +1,6 @@
1
+ import { TranslationModuleService } from "./services";
2
+ declare const _default: import("@etohq/types").ModuleExports<typeof TranslationModuleService> & {
3
+ linkable: Record<string, any>;
4
+ };
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;;;;AAEpD,wBAEE"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@etohq/framework/utils");
4
+ const _services_1 = require("./services");
5
+ exports.default = (0, utils_1.Module)(utils_1.Modules.TRANSLATION, {
6
+ service: _services_1.TranslationModuleService,
7
+ });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,kDAAwD;AACxD,yCAAoD;AAEpD,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,WAAW,EAAE;IACzC,OAAO,EAAE,oCAAwB;CAClC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const joinerConfig: Omit<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@etohq/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
2
+ export default joinerConfig;
3
+ //# sourceMappingURL=joiner-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iOAA0C,CAAA;AAEnE,eAAe,YAAY,CAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.joinerConfig = void 0;
4
+ const utils_1 = require("@etohq/framework/utils");
5
+ exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.TRANSLATION);
6
+ exports.default = exports.joinerConfig;
7
+ //# sourceMappingURL=joiner-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joiner-config.js","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":";;;AAAA,kDAAoE;AAEvD,QAAA,YAAY,GAAG,IAAA,0BAAkB,EAAC,eAAO,CAAC,WAAW,CAAC,CAAA;AAEnE,kBAAe,oBAAY,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20251208124155 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20251208124155.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20251208124155.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20251208124155.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20251208124155 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20251208124155 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`alter table if exists "translation" drop constraint if exists "translation_reference_id_locale_code_unique";`);
8
+ this.addSql(`alter table if exists "locale" drop constraint if exists "locale_code_unique";`);
9
+ this.addSql(`create table if not exists "locale" ("id" text not null, "code" text not null, "name" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "locale_pkey" primary key ("id"));`);
10
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_locale_deleted_at" ON "locale" ("deleted_at") WHERE deleted_at IS NULL;`);
11
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_locale_code_unique" ON "locale" ("code") WHERE deleted_at IS NULL;`);
12
+ this.addSql(`create table if not exists "translation" ("id" text not null, "reference_id" text not null, "reference" text not null, "locale_code" text not null, "translations" jsonb not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "translation_pkey" primary key ("id"));`);
13
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_translation_deleted_at" ON "translation" ("deleted_at") WHERE deleted_at IS NULL;`);
14
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_translation_reference_id_locale_code_unique" ON "translation" ("reference_id", "locale_code") WHERE deleted_at IS NULL;`);
15
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_translation_reference_id_reference_locale_code" ON "translation" ("reference_id", "reference", "locale_code") WHERE deleted_at IS NULL;`);
16
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_translation_reference_locale_code" ON "translation" ("reference", "locale_code") WHERE deleted_at IS NULL;`);
17
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_translation_reference_id_reference" ON "translation" ("reference_id", "reference") WHERE deleted_at IS NULL;`);
18
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_translation_locale_code" ON "translation" ("locale_code") WHERE deleted_at IS NULL;`);
19
+ }
20
+ async down() {
21
+ this.addSql(`drop table if exists "locale" cascade;`);
22
+ this.addSql(`drop table if exists "translation" cascade;`);
23
+ }
24
+ }
25
+ exports.Migration20251208124155 = Migration20251208124155;
26
+ //# sourceMappingURL=Migration20251208124155.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20251208124155.js","sourceRoot":"","sources":["../../src/migrations/Migration20251208124155.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,8GAA8G,CAC/G,CAAA;QACD,IAAI,CAAC,MAAM,CACT,gFAAgF,CACjF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,qRAAqR,CACtR,CAAA;QACD,IAAI,CAAC,MAAM,CACT,yGAAyG,CAC1G,CAAA;QACD,IAAI,CAAC,MAAM,CACT,2GAA2G,CAC5G,CAAA;QAED,IAAI,CAAC,MAAM,CACT,wWAAwW,CACzW,CAAA;QACD,IAAI,CAAC,MAAM,CACT,mHAAmH,CACpH,CAAA;QACD,IAAI,CAAC,MAAM,CACT,gKAAgK,CACjK,CAAA;QACD,IAAI,CAAC,MAAM,CACT,yKAAyK,CAC1K,CAAA;QACD,IAAI,CAAC,MAAM,CACT,4IAA4I,CAC7I,CAAA;QACD,IAAI,CAAC,MAAM,CACT,8IAA8I,CAC/I,CAAA;QACD,IAAI,CAAC,MAAM,CACT,qHAAqH,CACtH,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAA;QACrD,IAAI,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAA;IAC5D,CAAC;CACF;AA7CD,0DA6CC"}
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20251215083927 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20251215083927.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20251215083927.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20251215083927.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20251215083927 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20251215083927 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`alter table if exists "translation" add column if not exists "translated_field_count" integer not null default 0;`);
8
+ }
9
+ async down() {
10
+ this.addSql(`alter table if exists "translation" drop column if exists "translated_field_count";`);
11
+ }
12
+ }
13
+ exports.Migration20251215083927 = Migration20251215083927;
14
+ //# sourceMappingURL=Migration20251215083927.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20251215083927.js","sourceRoot":"","sources":["../../src/migrations/Migration20251215083927.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,mHAAmH,CACpH,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT,qFAAqF,CACtF,CAAA;IACH,CAAC;CACF;AAZD,0DAYC"}
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20251218140235 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20251218140235.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20251218140235.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20251218140235.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAenB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20251218140235 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20251218140235 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`alter table if exists "translation_settings" drop constraint if exists "translation_settings_entity_type_unique";`);
8
+ this.addSql(`create table if not exists "translation_settings" ("id" text not null, "entity_type" text not null, "fields" jsonb not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "translation_settings_pkey" primary key ("id"));`);
9
+ this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_translation_settings_deleted_at" ON "translation_settings" ("deleted_at") WHERE deleted_at IS NULL;`);
10
+ this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_translation_settings_entity_type_unique" ON "translation_settings" ("entity_type") WHERE deleted_at IS NULL;`);
11
+ }
12
+ async down() {
13
+ this.addSql(`drop table if exists "translation_settings" cascade;`);
14
+ }
15
+ }
16
+ exports.Migration20251218140235 = Migration20251218140235;
17
+ //# sourceMappingURL=Migration20251218140235.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20251218140235.js","sourceRoot":"","sources":["../../src/migrations/Migration20251218140235.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,mHAAmH,CACpH,CAAA;QACD,IAAI,CAAC,MAAM,CACT,2TAA2T,CAC5T,CAAA;QACD,IAAI,CAAC,MAAM,CACT,qIAAqI,CACtI,CAAA;QACD,IAAI,CAAC,MAAM,CACT,qJAAqJ,CACtJ,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CAAC,sDAAsD,CAAC,CAAA;IACrE,CAAC;CACF;AAnBD,0DAmBC"}
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20260108122757 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20260108122757.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20260108122757.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20260108122757.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20260108122757 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20260108122757 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`alter table if exists "translation_settings" add column if not exists "is_active" boolean not null default true;`);
8
+ }
9
+ async down() {
10
+ this.addSql(`alter table if exists "translation_settings" drop column if exists "is_active";`);
11
+ }
12
+ }
13
+ exports.Migration20260108122757 = Migration20260108122757;
14
+ //# sourceMappingURL=Migration20260108122757.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20260108122757.js","sourceRoot":"","sources":["../../src/migrations/Migration20260108122757.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,kHAAkH,CACnH,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT,iFAAiF,CAClF,CAAA;IACH,CAAC;CACF;AAZD,0DAYC"}
@@ -0,0 +1,4 @@
1
+ export { default as Locale } from "./locale";
2
+ export { default as Translation } from "./translation";
3
+ export { default as TranslationSettings } from "./settings";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TranslationSettings = exports.Translation = exports.Locale = void 0;
7
+ var locale_1 = require("./locale");
8
+ Object.defineProperty(exports, "Locale", { enumerable: true, get: function () { return __importDefault(locale_1).default; } });
9
+ var translation_1 = require("./translation");
10
+ Object.defineProperty(exports, "Translation", { enumerable: true, get: function () { return __importDefault(translation_1).default; } });
11
+ var settings_1 = require("./settings");
12
+ Object.defineProperty(exports, "TranslationSettings", { enumerable: true, get: function () { return __importDefault(settings_1).default; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA4C;AAAnC,iHAAA,OAAO,OAAU;AAC1B,6CAAsD;AAA7C,2HAAA,OAAO,OAAe;AAC/B,uCAA2D;AAAlD,gIAAA,OAAO,OAAuB"}
@@ -0,0 +1,7 @@
1
+ declare const Locale: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
2
+ id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
3
+ code: import("@etohq/framework/utils").TextProperty;
4
+ name: import("@etohq/framework/utils").TextProperty;
5
+ }>, "locale">;
6
+ export default Locale;
7
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/models/locale.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM;;;;aAWR,CAAA;AAEJ,eAAe,MAAM,CAAA"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@etohq/framework/utils");
4
+ const Locale = utils_1.model
5
+ .define("locale", {
6
+ id: utils_1.model.id({ prefix: "loc" }).primaryKey(),
7
+ code: utils_1.model.text().searchable(),
8
+ name: utils_1.model.text().searchable(),
9
+ })
10
+ .indexes([
11
+ {
12
+ on: ["code"],
13
+ unique: true,
14
+ },
15
+ ]);
16
+ exports.default = Locale;
17
+ //# sourceMappingURL=locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/models/locale.ts"],"names":[],"mappings":";;AAAA,kDAA8C;AAE9C,MAAM,MAAM,GAAG,aAAK;KACjB,MAAM,CAAC,QAAQ,EAAE;IAChB,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE;IAC5C,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IAC/B,IAAI,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;CAChC,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,MAAM,EAAE,IAAI;KACb;CACF,CAAC,CAAA;AAEJ,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,8 @@
1
+ declare const TranslationSettings: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
2
+ id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
3
+ entity_type: import("@etohq/framework/utils").TextProperty;
4
+ fields: import("@etohq/framework/utils").JSONProperty;
5
+ is_active: import("@etohq/framework/utils").BooleanProperty;
6
+ }>, "translation_settings">;
7
+ export default TranslationSettings;
8
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/models/settings.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,mBAAmB;;;;;2BAYrB,CAAA;AAEJ,eAAe,mBAAmB,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@etohq/framework/utils");
4
+ const TranslationSettings = utils_1.model
5
+ .define("translation_settings", {
6
+ id: utils_1.model.id({ prefix: "trset" }).primaryKey(),
7
+ entity_type: utils_1.model.text().searchable(),
8
+ fields: utils_1.model.json(),
9
+ is_active: utils_1.model.boolean().default(true),
10
+ })
11
+ .indexes([
12
+ {
13
+ on: ["entity_type"],
14
+ unique: true,
15
+ },
16
+ ]);
17
+ exports.default = TranslationSettings;
18
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/models/settings.ts"],"names":[],"mappings":";;AAAA,kDAA8C;AAE9C,MAAM,mBAAmB,GAAG,aAAK;KAC9B,MAAM,CAAC,sBAAsB,EAAE;IAC9B,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE;IAC9C,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACtC,MAAM,EAAE,aAAK,CAAC,IAAI,EAAE;IACpB,SAAS,EAAE,aAAK,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CACzC,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,aAAa,CAAC;QACnB,MAAM,EAAE,IAAI;KACb;CACF,CAAC,CAAA;AAEJ,kBAAe,mBAAmB,CAAA"}
@@ -0,0 +1,10 @@
1
+ declare const Translation: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
2
+ id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").IdProperty>;
3
+ reference_id: import("@etohq/framework/utils").TextProperty;
4
+ reference: import("@etohq/framework/utils").TextProperty;
5
+ locale_code: import("@etohq/framework/utils").TextProperty;
6
+ translations: import("@etohq/framework/utils").JSONProperty;
7
+ translated_field_count: import("@etohq/framework/utils").NumberProperty;
8
+ }>, "translation">;
9
+ export default Translation;
10
+ //# sourceMappingURL=translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/models/translation.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW;;;;;;;kBA0Bb,CAAA;AAEJ,eAAe,WAAW,CAAA"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@etohq/framework/utils");
4
+ const Translation = utils_1.model
5
+ .define("translation", {
6
+ id: utils_1.model.id({ prefix: "trans" }).primaryKey(),
7
+ reference_id: utils_1.model.text().searchable(),
8
+ reference: utils_1.model.text().searchable(),
9
+ locale_code: utils_1.model.text().searchable(),
10
+ translations: utils_1.model.json(),
11
+ translated_field_count: utils_1.model.number().default(0),
12
+ })
13
+ .indexes([
14
+ {
15
+ on: ["reference_id", "locale_code"],
16
+ unique: true,
17
+ },
18
+ {
19
+ on: ["reference_id", "reference", "locale_code"],
20
+ },
21
+ {
22
+ on: ["reference", "locale_code"],
23
+ },
24
+ {
25
+ on: ["reference_id", "reference"],
26
+ },
27
+ {
28
+ on: ["locale_code"],
29
+ },
30
+ ]);
31
+ exports.default = Translation;
32
+ //# sourceMappingURL=translation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.js","sourceRoot":"","sources":["../../src/models/translation.ts"],"names":[],"mappings":";;AAAA,kDAA8C;AAE9C,MAAM,WAAW,GAAG,aAAK;KACtB,MAAM,CAAC,aAAa,EAAE;IACrB,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE;IAC9C,YAAY,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACvC,SAAS,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACpC,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACtC,YAAY,EAAE,aAAK,CAAC,IAAI,EAAE;IAC1B,sBAAsB,EAAE,aAAK,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CAClD,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,cAAc,EAAE,aAAa,CAAC;QACnC,MAAM,EAAE,IAAI;KACb;IACD;QACE,EAAE,EAAE,CAAC,cAAc,EAAE,WAAW,EAAE,aAAa,CAAC;KACjD;IACD;QACE,EAAE,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC;KACjC;IACD;QACE,EAAE,EAAE,CAAC,cAAc,EAAE,WAAW,CAAC;KAClC;IACD;QACE,EAAE,EAAE,CAAC,aAAa,CAAC;KACpB;CACF,CAAC,CAAA;AAEJ,kBAAe,WAAW,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { default as TranslationModuleService } from "./translation-module-service";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TranslationModuleService = void 0;
7
+ var translation_module_service_1 = require("./translation-module-service");
8
+ Object.defineProperty(exports, "TranslationModuleService", { enumerable: true, get: function () { return __importDefault(translation_module_service_1).default; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAkF;AAAzE,uJAAA,OAAO,OAA4B"}
@@ -0,0 +1,55 @@
1
+ import { Context, CreateTranslationDTO, CreateTranslationSettingsDTO, DAL, FilterableTranslationProps, FindConfig, ITranslationModuleService, ModulesSdkTypes, TranslationTypes, UpdateTranslationSettingsDTO } from "@etohq/framework/types";
2
+ import { Locale, Translation, TranslationSettings } from "../models";
3
+ type InjectedDependencies = {
4
+ baseRepository: DAL.RepositoryService;
5
+ translationService: ModulesSdkTypes.IEtoInternalService<typeof Translation>;
6
+ localeService: ModulesSdkTypes.IEtoInternalService<typeof Locale>;
7
+ translationSettingsService: ModulesSdkTypes.IEtoInternalService<typeof TranslationSettings>;
8
+ };
9
+ declare const TranslationModuleService_base: import("@etohq/framework/utils").EtoServiceReturnType<{
10
+ Locale: {
11
+ dto: TranslationTypes.LocaleDTO;
12
+ };
13
+ Translation: {
14
+ dto: TranslationTypes.TranslationDTO;
15
+ };
16
+ TranslationSettings: {
17
+ dto: TranslationTypes.TranslationSettingsDTO;
18
+ };
19
+ }>;
20
+ export default class TranslationModuleService extends TranslationModuleService_base implements ITranslationModuleService {
21
+ protected baseRepository_: DAL.RepositoryService;
22
+ protected translationService_: ModulesSdkTypes.IEtoInternalService<typeof Translation>;
23
+ protected localeService_: ModulesSdkTypes.IEtoInternalService<typeof Locale>;
24
+ protected settingsService_: ModulesSdkTypes.IEtoInternalService<typeof TranslationSettings>;
25
+ constructor({ baseRepository, translationService, localeService, translationSettingsService, }: InjectedDependencies);
26
+ __joinerConfig(): Omit<ModulesSdkTypes.ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<ModulesSdkTypes.ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
27
+ __hooks: {
28
+ onApplicationStart: () => Promise<void>;
29
+ };
30
+ protected onApplicationStart_(): Promise<void>;
31
+ getTranslatableFields(entityType?: string, sharedContext?: Context): Promise<Record<string, string[]>>;
32
+ getInactiveTranslatableFields(entityType?: string, sharedContext?: Context): Promise<Record<string, string[]>>;
33
+ static prepareFilters(filters: FilterableTranslationProps): FilterableTranslationProps;
34
+ static ensureReferenceFieldInConfig(config: FindConfig<TranslationTypes.TranslationDTO>): FindConfig<TranslationTypes.TranslationDTO>;
35
+ retrieveTranslation(id: string, config?: FindConfig<TranslationTypes.TranslationDTO>, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO>;
36
+ listTranslations(filters?: FilterableTranslationProps, config?: FindConfig<TranslationTypes.TranslationDTO>, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO[]>;
37
+ listAndCountTranslations(filters?: FilterableTranslationProps, config?: FindConfig<TranslationTypes.TranslationDTO>, sharedContext?: Context): Promise<[TranslationTypes.TranslationDTO[], number]>;
38
+ createLocales(data: TranslationTypes.CreateLocaleDTO[], sharedContext?: Context): Promise<TranslationTypes.LocaleDTO[]>;
39
+ createLocales(data: TranslationTypes.CreateLocaleDTO, sharedContext?: Context): Promise<TranslationTypes.LocaleDTO>;
40
+ createTranslations(data: CreateTranslationDTO, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO>;
41
+ createTranslations(data: CreateTranslationDTO[], sharedContext?: Context): Promise<TranslationTypes.TranslationDTO[]>;
42
+ updateTranslations(data: TranslationTypes.UpdateTranslationDTO, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO>;
43
+ updateTranslations(data: TranslationTypes.UpdateTranslationDTO[], sharedContext?: Context): Promise<TranslationTypes.TranslationDTO[]>;
44
+ createTranslationSettings(data: CreateTranslationSettingsDTO[] | CreateTranslationSettingsDTO, sharedContext?: Context): Promise<TranslationTypes.TranslationSettingsDTO | TranslationTypes.TranslationSettingsDTO[]>;
45
+ updateTranslationSettings(data: UpdateTranslationSettingsDTO | UpdateTranslationSettingsDTO[], sharedContext?: Context): Promise<TranslationTypes.TranslationSettingsDTO | TranslationTypes.TranslationSettingsDTO[]>;
46
+ getStatistics(input: TranslationTypes.TranslationStatisticsInput, sharedContext?: Context): Promise<TranslationTypes.TranslationStatisticsOutput>;
47
+ static validateSettings(dataToValidate: (CreateTranslationSettingsDTO | (UpdateTranslationSettingsDTO & {
48
+ entity_type: string;
49
+ }))[]): void;
50
+ protected ensureEntityType_(settings: (CreateTranslationSettingsDTO | UpdateTranslationSettingsDTO)[], sharedContext?: Context): Promise<(CreateTranslationSettingsDTO | (UpdateTranslationSettingsDTO & {
51
+ entity_type: string;
52
+ }))[]>;
53
+ }
54
+ export {};
55
+ //# sourceMappingURL=translation-module-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-module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iB,CAC/B,QAAQ,EAAE,CAAC,4BAA4B,GAAG,4BAA4B,CAAC,EAAE,EAC3D,aAAa,GAAE,OAAY,GACxC,OAAO,CACR,CACI,4BAA4B,GAC5B,CAAC,4BAA4B,GAAG;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAC3D,EAAE,CACJ;CAyBF"}
@@ -0,0 +1,442 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const core_1 = require("@etohq/framework/mikro-orm/core");
16
+ const types_1 = require("@etohq/framework/types");
17
+ const utils_1 = require("@etohq/framework/utils");
18
+ const _models_1 = require("../models");
19
+ const _utils_1 = require("../utils");
20
+ const joiner_config_1 = require("../joiner-config");
21
+ class TranslationModuleService extends (0, utils_1.EtoService)({
22
+ Locale: _models_1.Locale,
23
+ Translation: _models_1.Translation,
24
+ TranslationSettings: _models_1.TranslationSettings,
25
+ }) {
26
+ constructor({ baseRepository, translationService, localeService, translationSettingsService, }) {
27
+ // @ts-ignore
28
+ super(...arguments);
29
+ this.__hooks = {
30
+ onApplicationStart: async () => {
31
+ return this.onApplicationStart_();
32
+ },
33
+ };
34
+ this.baseRepository_ = baseRepository;
35
+ this.translationService_ = translationService;
36
+ this.localeService_ = localeService;
37
+ this.settingsService_ = translationSettingsService;
38
+ }
39
+ __joinerConfig() {
40
+ return joiner_config_1.joinerConfig;
41
+ }
42
+ async onApplicationStart_() {
43
+ const translatableEntities = utils_1.DmlEntity.getTranslatableEntities();
44
+ const translatableEntitiesSet = new Set(translatableEntities.map((entity) => (0, utils_1.toSnakeCase)(entity.entity)));
45
+ const currentTranslationSettings = await this.settingsService_.list();
46
+ const currentTranslationSettingsSet = new Set(currentTranslationSettings.map((setting) => setting.entity_type));
47
+ const settingsToUpsert = [];
48
+ for (const setting of currentTranslationSettings) {
49
+ if (!translatableEntitiesSet.has(setting.entity_type) && setting.is_active) {
50
+ settingsToUpsert.push({ id: setting.id, is_active: false });
51
+ }
52
+ }
53
+ for (const entity of translatableEntities) {
54
+ const snakeCaseEntityType = (0, utils_1.toSnakeCase)(entity.entity);
55
+ if (!currentTranslationSettingsSet.has(snakeCaseEntityType)) {
56
+ settingsToUpsert.push({
57
+ entity_type: snakeCaseEntityType,
58
+ fields: entity.fields,
59
+ });
60
+ }
61
+ }
62
+ await this.settingsService_.upsert(settingsToUpsert);
63
+ }
64
+ async getTranslatableFields(entityType, sharedContext = {}) {
65
+ const filters = entityType ? { entity_type: entityType } : {};
66
+ const settings = await this.settingsService_.list(filters, {}, sharedContext);
67
+ return settings.reduce((acc, setting) => {
68
+ acc[setting.entity_type] = setting.is_active
69
+ ? setting.fields
70
+ : [];
71
+ return acc;
72
+ }, {});
73
+ }
74
+ async getInactiveTranslatableFields(entityType, sharedContext = {}) {
75
+ const translatableFields = await this.getTranslatableFields(entityType, sharedContext);
76
+ return Object.entries(translatableFields).reduce((acc, [type, fields]) => {
77
+ const entity = utils_1.DmlEntity.getTranslatableEntities().find((ent) => (0, utils_1.toSnakeCase)(ent.entity) === type);
78
+ if (!entity) {
79
+ return acc;
80
+ }
81
+ acc[type] = (0, utils_1.arrayDifference)(entity.fields, fields);
82
+ return acc;
83
+ }, {});
84
+ }
85
+ static prepareFilters(filters) {
86
+ const { q, ...restFilters } = filters;
87
+ if (q) {
88
+ return {
89
+ ...restFilters,
90
+ [(0, core_1.raw)(`translations::text ILIKE ?`, [`%${q}%`])]: [],
91
+ };
92
+ }
93
+ return restFilters;
94
+ }
95
+ static ensureReferenceFieldInConfig(config) {
96
+ if (!config?.select?.length) {
97
+ return config;
98
+ }
99
+ const select = config.select;
100
+ if (!select.includes("reference")) {
101
+ return { ...config, select: [...select, "reference"] };
102
+ }
103
+ return config;
104
+ }
105
+ // @ts-expect-error
106
+ async retrieveTranslation(id, config = {}, sharedContext = {}) {
107
+ const configWithReference = TranslationModuleService.ensureReferenceFieldInConfig(config);
108
+ const result = await this.translationService_.retrieve(id, configWithReference, sharedContext);
109
+ const serialized = await this.baseRepository_.serialize(result);
110
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
111
+ return (0, _utils_1.filterTranslationFields)([serialized], translatableFieldsConfig)[0];
112
+ }
113
+ // @ts-expect-error
114
+ async listTranslations(filters = {}, config = {}, sharedContext = {}) {
115
+ const preparedFilters = TranslationModuleService.prepareFilters(filters);
116
+ const configWithReference = TranslationModuleService.ensureReferenceFieldInConfig(config);
117
+ const results = await this.translationService_.list(preparedFilters, configWithReference, sharedContext);
118
+ const serialized = await this.baseRepository_.serialize(results);
119
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
120
+ return (0, _utils_1.filterTranslationFields)(serialized, translatableFieldsConfig);
121
+ }
122
+ // @ts-expect-error
123
+ async listAndCountTranslations(filters = {}, config = {}, sharedContext = {}) {
124
+ const preparedFilters = TranslationModuleService.prepareFilters(filters);
125
+ const configWithReference = TranslationModuleService.ensureReferenceFieldInConfig(config);
126
+ const [results, count] = await this.translationService_.listAndCount(preparedFilters, configWithReference, sharedContext);
127
+ const serialized = await this.baseRepository_.serialize(results);
128
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
129
+ return [(0, _utils_1.filterTranslationFields)(serialized, translatableFieldsConfig), count];
130
+ }
131
+ // @ts-expect-error
132
+ async createLocales(data, sharedContext = {}) {
133
+ const dataArray = Array.isArray(data) ? data : [data];
134
+ const normalizedData = dataArray.map((locale) => ({
135
+ ...locale,
136
+ code: (0, utils_1.normalizeLocale)(locale.code),
137
+ }));
138
+ const createdLocales = await this.localeService_.create(normalizedData, sharedContext);
139
+ const serialized = await this.baseRepository_.serialize(createdLocales);
140
+ return Array.isArray(data) ? serialized : serialized[0];
141
+ }
142
+ // @ts-expect-error
143
+ async createTranslations(data, sharedContext = {}) {
144
+ const dataArray = Array.isArray(data) ? data : [data];
145
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
146
+ const normalizedData = dataArray.map((translation) => ({
147
+ ...translation,
148
+ locale_code: (0, utils_1.normalizeLocale)(translation.locale_code),
149
+ translated_field_count: (0, _utils_1.computeTranslatedFieldCount)(translation.translations, translatableFieldsConfig[translation.reference]),
150
+ }));
151
+ const createdTranslations = await this.translationService_.create(normalizedData, sharedContext);
152
+ const serialized = await this.baseRepository_.serialize(createdTranslations);
153
+ return Array.isArray(data) ? serialized : serialized[0];
154
+ }
155
+ // @ts-expect-error
156
+ async updateTranslations(data, sharedContext = {}) {
157
+ const dataArray = (Array.isArray(data) ? data : [data]);
158
+ const updatesWithTranslations = dataArray.filter((d) => d.translations);
159
+ if (updatesWithTranslations.length) {
160
+ const idsNeedingReference = updatesWithTranslations
161
+ .filter((d) => !d.reference)
162
+ .map((d) => d.id);
163
+ let referenceMap = {};
164
+ if (idsNeedingReference.length) {
165
+ const existingTranslations = await this.translationService_.list({ id: idsNeedingReference }, { select: ["id", "reference"] }, sharedContext);
166
+ referenceMap = Object.fromEntries(existingTranslations.map((t) => [t.id, t.reference]));
167
+ }
168
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
169
+ for (const update of dataArray) {
170
+ if (update.translations) {
171
+ const reference = update.reference || referenceMap[update.id];
172
+ update.translated_field_count = (0, _utils_1.computeTranslatedFieldCount)(update.translations, translatableFieldsConfig[reference] || []);
173
+ }
174
+ }
175
+ }
176
+ const updatedTranslations = await this.translationService_.update(dataArray, sharedContext);
177
+ const serialized = await this.baseRepository_.serialize(updatedTranslations);
178
+ return Array.isArray(data) ? serialized : serialized[0];
179
+ }
180
+ // @ts-expect-error
181
+ async createTranslationSettings(data, sharedContext = {}) {
182
+ const dataArray = Array.isArray(data) ? data : [data];
183
+ const normalizedData = await this.ensureEntityType_(dataArray, sharedContext);
184
+ TranslationModuleService.validateSettings(normalizedData);
185
+ // @ts-expect-error TS can't match union type to overloads
186
+ return await super.createTranslationSettings(data, sharedContext);
187
+ }
188
+ // @ts-expect-error
189
+ async updateTranslationSettings(data, sharedContext = {}) {
190
+ const dataArray = Array.isArray(data) ? data : [data];
191
+ const normalizedData = await this.ensureEntityType_(dataArray, sharedContext);
192
+ TranslationModuleService.validateSettings(normalizedData);
193
+ const updatedSettings = await this.settingsService_.update(data, sharedContext);
194
+ const entityTypes = [...new Set(normalizedData.map((s) => s.entity_type))];
195
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
196
+ const translations = await this.translationService_.list({
197
+ reference: entityTypes,
198
+ });
199
+ const toUpdate = translations.map((translation) => ({
200
+ id: translation.id,
201
+ translated_field_count: (0, _utils_1.computeTranslatedFieldCount)(translation.translations, translatableFieldsConfig[translation.reference] ?? []),
202
+ }));
203
+ if (toUpdate.length) {
204
+ await this.translationService_.update(toUpdate, sharedContext);
205
+ }
206
+ const serialized = await this.baseRepository_.serialize(updatedSettings);
207
+ return Array.isArray(data) ? serialized : serialized[0];
208
+ }
209
+ async getStatistics(input, sharedContext = {}) {
210
+ const { locales, entities } = input;
211
+ if (!locales || !locales.length) {
212
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "At least one locale must be provided");
213
+ }
214
+ if (!entities || !Object.keys(entities).length) {
215
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "At least one entity type must be provided");
216
+ }
217
+ const normalizedLocales = locales.map(utils_1.normalizeLocale);
218
+ const manager = (sharedContext.transactionManager ??
219
+ sharedContext.manager);
220
+ const knex = manager.getKnex();
221
+ const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
222
+ const result = {};
223
+ const entityTypes = [];
224
+ for (const entityType of Object.keys(entities)) {
225
+ const translatableFields = translatableFieldsConfig[entityType];
226
+ if (!translatableFields || translatableFields.length === 0) {
227
+ result[entityType] = {
228
+ expected: 0,
229
+ translated: 0,
230
+ missing: 0,
231
+ by_locale: Object.fromEntries(normalizedLocales.map((locale) => [
232
+ locale,
233
+ { expected: 0, translated: 0, missing: 0 },
234
+ ])),
235
+ };
236
+ }
237
+ else {
238
+ entityTypes.push(entityType);
239
+ }
240
+ }
241
+ if (!entityTypes.length) {
242
+ return result;
243
+ }
244
+ const { rows } = await knex.raw(`
245
+ SELECT
246
+ reference,
247
+ locale_code,
248
+ COALESCE(SUM(translated_field_count), 0)::int AS translated_field_count
249
+ FROM translation
250
+ WHERE reference = ANY(?)
251
+ AND locale_code = ANY(?)
252
+ AND deleted_at IS NULL
253
+ GROUP BY reference, locale_code
254
+ `, [entityTypes, normalizedLocales]);
255
+ for (const entityType of entityTypes) {
256
+ const translatableFields = translatableFieldsConfig[entityType];
257
+ const fieldsPerEntity = translatableFields.length;
258
+ const entityCount = entities[entityType].count;
259
+ const expectedPerLocale = entityCount * fieldsPerEntity;
260
+ result[entityType] = {
261
+ expected: expectedPerLocale * normalizedLocales.length,
262
+ translated: 0,
263
+ missing: expectedPerLocale * normalizedLocales.length,
264
+ by_locale: Object.fromEntries(normalizedLocales.map((locale) => [
265
+ locale,
266
+ {
267
+ expected: expectedPerLocale,
268
+ translated: 0,
269
+ missing: expectedPerLocale,
270
+ },
271
+ ])),
272
+ };
273
+ }
274
+ for (const row of rows) {
275
+ const entityType = row.reference;
276
+ const localeCode = row.locale_code;
277
+ const translatedCount = parseInt(row.translated_field_count, 10) || 0;
278
+ result[entityType].by_locale[localeCode].translated = translatedCount;
279
+ result[entityType].by_locale[localeCode].missing =
280
+ result[entityType].by_locale[localeCode].expected - translatedCount;
281
+ result[entityType].translated += translatedCount;
282
+ }
283
+ for (const entityType of entityTypes) {
284
+ result[entityType].missing =
285
+ result[entityType].expected - result[entityType].translated;
286
+ }
287
+ return result;
288
+ }
289
+ static validateSettings(dataToValidate) {
290
+ const translatableEntities = utils_1.DmlEntity.getTranslatableEntities();
291
+ const translatableEntitiesMap = new Map(translatableEntities.map((entity) => [(0, utils_1.toSnakeCase)(entity.entity), entity]));
292
+ const invalidSettings = [];
293
+ for (const item of dataToValidate) {
294
+ const entityType = item.entity_type;
295
+ const entity = translatableEntitiesMap.get(entityType);
296
+ if (!entity) {
297
+ invalidSettings.push({ entity_type: entityType, is_invalid_entity: true });
298
+ }
299
+ else {
300
+ const invalidFields = (0, utils_1.arrayDifference)(item.fields ?? [], entity.fields);
301
+ if (invalidFields.length) {
302
+ invalidSettings.push({
303
+ entity_type: entityType,
304
+ is_invalid_entity: false,
305
+ invalidFields,
306
+ });
307
+ }
308
+ }
309
+ }
310
+ if (invalidSettings.length) {
311
+ throw new utils_1.EtoError(utils_1.EtoError.Types.INVALID_DATA, "Invalid translation settings:\n" +
312
+ invalidSettings
313
+ .map((setting) => {
314
+ return `- ${setting.entity_type} ${setting.is_invalid_entity
315
+ ? "is not a translatable entity"
316
+ : `doesn't have the following fields set as translatable: ${setting.invalidFields?.join(", ")}`}`;
317
+ })
318
+ .join("\n"));
319
+ }
320
+ }
321
+ async ensureEntityType_(settings, sharedContext = {}) {
322
+ const idsNeedingResolution = settings
323
+ .filter((setting) => !setting.entity_type && "id" in setting)
324
+ .map((setting) => setting.id);
325
+ let entityTypeMap = {};
326
+ if (idsNeedingResolution.length) {
327
+ const existingSettings = await this.settingsService_.list({ id: idsNeedingResolution }, { select: ["id", "entity_type"] }, sharedContext);
328
+ entityTypeMap = Object.fromEntries(existingSettings.map((s) => [s.id, s.entity_type]));
329
+ }
330
+ return settings.map((setting) => {
331
+ const entityType = setting.entity_type ||
332
+ entityTypeMap[setting.id];
333
+ return { ...setting, entity_type: entityType };
334
+ });
335
+ }
336
+ }
337
+ exports.default = TranslationModuleService;
338
+ __decorate([
339
+ (0, utils_1.InjectManager)(),
340
+ __param(1, (0, utils_1.EtoContext)()),
341
+ __metadata("design:type", Function),
342
+ __metadata("design:paramtypes", [String, Object]),
343
+ __metadata("design:returntype", Promise)
344
+ ], TranslationModuleService.prototype, "getTranslatableFields", null);
345
+ __decorate([
346
+ (0, utils_1.InjectManager)(),
347
+ __param(1, (0, utils_1.EtoContext)()),
348
+ __metadata("design:type", Function),
349
+ __metadata("design:paramtypes", [String, Object]),
350
+ __metadata("design:returntype", Promise)
351
+ ], TranslationModuleService.prototype, "getInactiveTranslatableFields", null);
352
+ __decorate([
353
+ (0, utils_1.InjectManager)()
354
+ // @ts-expect-error
355
+ ,
356
+ __param(2, (0, utils_1.EtoContext)()),
357
+ __metadata("design:type", Function),
358
+ __metadata("design:paramtypes", [String, Object, Object]),
359
+ __metadata("design:returntype", Promise)
360
+ ], TranslationModuleService.prototype, "retrieveTranslation", null);
361
+ __decorate([
362
+ (0, utils_1.InjectManager)()
363
+ // @ts-expect-error
364
+ ,
365
+ __param(2, (0, utils_1.EtoContext)()),
366
+ __metadata("design:type", Function),
367
+ __metadata("design:paramtypes", [Object, Object, Object]),
368
+ __metadata("design:returntype", Promise)
369
+ ], TranslationModuleService.prototype, "listTranslations", null);
370
+ __decorate([
371
+ (0, utils_1.InjectManager)()
372
+ // @ts-expect-error
373
+ ,
374
+ __param(2, (0, utils_1.EtoContext)()),
375
+ __metadata("design:type", Function),
376
+ __metadata("design:paramtypes", [Object, Object, Object]),
377
+ __metadata("design:returntype", Promise)
378
+ ], TranslationModuleService.prototype, "listAndCountTranslations", null);
379
+ __decorate([
380
+ (0, utils_1.InjectManager)(),
381
+ (0, utils_1.EmitEvents)()
382
+ // @ts-expect-error
383
+ ,
384
+ __param(1, (0, utils_1.EtoContext)()),
385
+ __metadata("design:type", Function),
386
+ __metadata("design:paramtypes", [Object, Object]),
387
+ __metadata("design:returntype", Promise)
388
+ ], TranslationModuleService.prototype, "createLocales", null);
389
+ __decorate([
390
+ (0, utils_1.InjectManager)(),
391
+ (0, utils_1.EmitEvents)()
392
+ // @ts-expect-error
393
+ ,
394
+ __param(1, (0, utils_1.EtoContext)()),
395
+ __metadata("design:type", Function),
396
+ __metadata("design:paramtypes", [Object, Object]),
397
+ __metadata("design:returntype", Promise)
398
+ ], TranslationModuleService.prototype, "createTranslations", null);
399
+ __decorate([
400
+ (0, utils_1.InjectManager)(),
401
+ (0, utils_1.EmitEvents)()
402
+ // @ts-expect-error
403
+ ,
404
+ __param(1, (0, utils_1.EtoContext)()),
405
+ __metadata("design:type", Function),
406
+ __metadata("design:paramtypes", [Object, Object]),
407
+ __metadata("design:returntype", Promise)
408
+ ], TranslationModuleService.prototype, "updateTranslations", null);
409
+ __decorate([
410
+ (0, utils_1.InjectManager)(),
411
+ (0, utils_1.EmitEvents)()
412
+ // @ts-expect-error
413
+ ,
414
+ __param(1, (0, utils_1.EtoContext)()),
415
+ __metadata("design:type", Function),
416
+ __metadata("design:paramtypes", [Object, Object]),
417
+ __metadata("design:returntype", Promise)
418
+ ], TranslationModuleService.prototype, "createTranslationSettings", null);
419
+ __decorate([
420
+ (0, utils_1.InjectManager)(),
421
+ (0, utils_1.EmitEvents)()
422
+ // @ts-expect-error
423
+ ,
424
+ __param(1, (0, utils_1.EtoContext)()),
425
+ __metadata("design:type", Function),
426
+ __metadata("design:paramtypes", [Object, Object]),
427
+ __metadata("design:returntype", Promise)
428
+ ], TranslationModuleService.prototype, "updateTranslationSettings", null);
429
+ __decorate([
430
+ (0, utils_1.InjectManager)(),
431
+ __param(1, (0, utils_1.EtoContext)()),
432
+ __metadata("design:type", Function),
433
+ __metadata("design:paramtypes", [Object, Object]),
434
+ __metadata("design:returntype", Promise)
435
+ ], TranslationModuleService.prototype, "getStatistics", null);
436
+ __decorate([
437
+ __param(1, (0, utils_1.EtoContext)()),
438
+ __metadata("design:type", Function),
439
+ __metadata("design:paramtypes", [Array, Object]),
440
+ __metadata("design:returntype", Promise)
441
+ ], TranslationModuleService.prototype, "ensureEntityType_", null);
442
+ //# sourceMappingURL=translation-module-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-module-service.js","sourceRoot":"","sources":["../../src/services/translation-module-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,0DAAqD;AAErD,kDAY+B;AAC/B,kDAU+B;AAC/B,qCAAkE;AAClE,mCAA6E;AAC7E,oDAA+C;AAe/C,MAAqB,wBACnB,SAAQ,IAAA,kBAAU,EAIf;IACD,MAAM,EAAN,gBAAM;IACN,WAAW,EAAX,qBAAW;IACX,mBAAmB,EAAnB,6BAAmB;CACpB,CAAC;IAYF,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,0BAA0B,GACL;QACrB,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QAWrB,YAAO,GAAG;YACR,kBAAkB,EAAE,KAAK,IAAI,EAAE;gBAC7B,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAA;YACnC,CAAC;SACF,CAAA;QAdC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAA;QACrC,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC7C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAA;QACnC,IAAI,CAAC,gBAAgB,GAAG,0BAA0B,CAAA;IACpD,CAAC;IAED,cAAc;QACZ,OAAO,4BAAY,CAAA;IACrB,CAAC;IAQS,KAAK,CAAC,mBAAmB;QACjC,MAAM,oBAAoB,GAAG,iBAAS,CAAC,uBAAuB,EAAE,CAAA;QAChE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CACrC,oBAAoB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,mBAAW,EAA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;IAChB,mBAAmB;;IAIhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;gEAqBd;AAIK;IAFL,IAAA,qBAAa,GAAE;IAChB,mBAAmB;;IAIhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;wEAqBd;AAUK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAGhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;6DAiBd;AAUK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAGhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;kEA2Bd;AAUK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAKhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;kEAkDd;AAKK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAGhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;yEAWd;AAKK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAGhB,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;yEA0Cd;AAGK;IADL,IAAA,qBAAa,GAAE;IAGb,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;6DA+Gd;AAwDe;IAEb,WAAA,IAAA,kBAAU,GAAE,CAAA;;;;iEA8Bd"}
@@ -0,0 +1 @@
1
+ {"root":["../src/index.ts","../src/joiner-config.ts","../src/migrations/migration20251208124155.ts","../src/migrations/migration20251215083927.ts","../src/migrations/migration20251218140235.ts","../src/migrations/migration20260108122757.ts","../src/models/index.ts","../src/models/locale.ts","../src/models/settings.ts","../src/models/translation.ts","../src/services/index.ts","../src/services/translation-module-service.ts","../src/utils/compute-translated-field-count.ts","../src/utils/filter-translation-fields.ts","../src/utils/index.ts"],"version":"5.8.3"}
@@ -0,0 +1,2 @@
1
+ export declare function computeTranslatedFieldCount(translations: Record<string, unknown> | undefined | null, translatableFields: string[] | undefined | null): number;
2
+ //# sourceMappingURL=compute-translated-field-count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-translated-field-count.d.ts","sourceRoot":"","sources":["../../src/utils/compute-translated-field-count.ts"],"names":[],"mappings":"AAAA,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,EACxD,kBAAkB,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,GAC9C,MAAM,CASR"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeTranslatedFieldCount = computeTranslatedFieldCount;
4
+ function computeTranslatedFieldCount(translations, translatableFields) {
5
+ if (!translations || !translatableFields?.length) {
6
+ return 0;
7
+ }
8
+ return translatableFields.filter((field) => {
9
+ const value = translations[field];
10
+ return value != null && value !== "" && value !== "null";
11
+ }).length;
12
+ }
13
+ //# sourceMappingURL=compute-translated-field-count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-translated-field-count.js","sourceRoot":"","sources":["../../src/utils/compute-translated-field-count.ts"],"names":[],"mappings":";;AAAA,kEAYC;AAZD,SAAgB,2BAA2B,CACzC,YAAwD,EACxD,kBAA+C;IAE/C,IAAI,CAAC,YAAY,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QACjD,OAAO,CAAC,CAAA;IACV,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACzC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;QACjC,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,MAAM,CAAA;IAC1D,CAAC,CAAC,CAAC,MAAM,CAAA;AACX,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { TranslationTypes } from "@etohq/framework/types";
2
+ export declare function filterTranslationFields(translations: TranslationTypes.TranslationDTO[], translatableFieldsConfig: Record<string, string[]>): TranslationTypes.TranslationDTO[];
3
+ //# sourceMappingURL=filter-translation-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-translation-fields.d.ts","sourceRoot":"","sources":["../../src/utils/filter-translation-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,gBAAgB,CAAC,cAAc,EAAE,EAC/C,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GACjD,gBAAgB,CAAC,cAAc,EAAE,CAuBnC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterTranslationFields = filterTranslationFields;
4
+ function filterTranslationFields(translations, translatableFieldsConfig) {
5
+ return translations.map((translation) => {
6
+ const allowedFields = translatableFieldsConfig[translation.reference];
7
+ if (!allowedFields?.length) {
8
+ translation.translations = {};
9
+ return translation;
10
+ }
11
+ const filteredTranslations = {};
12
+ for (const field of allowedFields) {
13
+ if (translation.translations &&
14
+ field in translation.translations) {
15
+ filteredTranslations[field] = translation.translations[field];
16
+ }
17
+ }
18
+ translation.translations = filteredTranslations;
19
+ return translation;
20
+ });
21
+ }
22
+ //# sourceMappingURL=filter-translation-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-translation-fields.js","sourceRoot":"","sources":["../../src/utils/filter-translation-fields.ts"],"names":[],"mappings":";;AAEA,0DA0BC;AA1BD,SAAgB,uBAAuB,CACrC,YAA+C,EAC/C,wBAAkD;IAElD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QACtC,MAAM,aAAa,GAAG,wBAAwB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QACrE,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;YAC3B,WAAW,CAAC,YAAY,GAAG,EAAE,CAAA;YAC7B,OAAO,WAAW,CAAA;QACpB,CAAC;QAED,MAAM,oBAAoB,GAA4B,EAAE,CAAA;QACxD,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAClC,IACE,WAAW,CAAC,YAAY;gBACxB,KAAK,IAAK,WAAW,CAAC,YAAwC,EAC9D,CAAC;gBACD,oBAAoB,CAAC,KAAK,CAAC,GACzB,WAAW,CAAC,YACb,CAAC,KAAK,CAAC,CAAA;YACV,CAAC;QACH,CAAC;QAED,WAAW,CAAC,YAAY,GAAG,oBAAoB,CAAA;QAC/C,OAAO,WAAW,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./compute-translated-field-count";
2
+ export * from "./filter-translation-fields";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./compute-translated-field-count"), exports);
18
+ __exportStar(require("./filter-translation-fields"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAgD;AAChD,8DAA2C"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@etohq/translation",
3
+ "version": "1.5.5-next-20260317140633",
4
+ "description": "Eto Translation module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "!dist/**/__tests__",
10
+ "!dist/**/__mocks__",
11
+ "!dist/**/__fixtures__"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/etohq/eto",
19
+ "directory": "packages/core/modules/translation"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "author": "Eto",
25
+ "license": "MIT",
26
+ "devDependencies": {
27
+ "@mikro-orm/cli": "6.4.3",
28
+ "@swc/core": "1.7.28",
29
+ "@swc/jest": "0.2.36",
30
+ "@types/jest": "29.5.14",
31
+ "jest": "29.7.0",
32
+ "rimraf": "5.0.2",
33
+ "tsc-alias": "1.8.6",
34
+ "typescript": "5.8.3",
35
+ "@etohq/test-utils": "1.5.5-next-20260317140633"
36
+ },
37
+ "dependencies": {
38
+ "@mikro-orm/core": "6.4.3",
39
+ "@mikro-orm/migrations": "6.4.3",
40
+ "@mikro-orm/postgresql": "6.4.3",
41
+ "awilix": "8.0.1",
42
+ "@etohq/framework": "1.5.5-next-20260317140633"
43
+ },
44
+ "scripts": {
45
+ "watch": "tsc --build --watch",
46
+ "watch:test": "tsc --build tsconfig.spec.json --watch",
47
+ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
48
+ "build": "rimraf dist && tsc --build && npm run resolve:aliases",
49
+ "test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
50
+ "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
51
+ "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create --initial",
52
+ "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create",
53
+ "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:up",
54
+ "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm cache:clear"
55
+ }
56
+ }