@medusajs/translation 2.12.4-preview-20251220032313 → 2.12.4-snapshot-20251218091536
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/loaders/config.d.ts +1 -2
- package/dist/loaders/config.d.ts.map +1 -1
- package/dist/loaders/config.js +2 -26
- package/dist/loaders/config.js.map +1 -1
- package/dist/loaders/defaults.d.ts.map +1 -1
- package/dist/loaders/defaults.js +1 -12
- package/dist/loaders/defaults.js.map +1 -1
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -3
- package/dist/models/index.js.map +1 -1
- package/dist/services/translation-module.d.ts +3 -14
- package/dist/services/translation-module.d.ts.map +1 -1
- package/dist/services/translation-module.js +16 -68
- package/dist/services/translation-module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/migrations/Migration20251218140235.d.ts +0 -6
- package/dist/migrations/Migration20251218140235.d.ts.map +0 -1
- package/dist/migrations/Migration20251218140235.js +0 -17
- package/dist/migrations/Migration20251218140235.js.map +0 -1
- package/dist/models/settings.d.ts +0 -17
- package/dist/models/settings.d.ts.map +0 -1
- package/dist/models/settings.js +0 -27
- package/dist/models/settings.js.map +0 -1
- package/dist/types/index.d.ts +0 -37
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/utils/filter-translation-fields.d.ts +0 -3
- package/dist/utils/filter-translation-fields.d.ts.map +0 -1
- package/dist/utils/filter-translation-fields.js +0 -22
- package/dist/utils/filter-translation-fields.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,MAAM,8BAA8B,CAAA;AAKnE,eAAO,MAAM,kBAAkB,gBAAgB,CAAA;;;;AAE/C,wBAGE"}
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TRANSLATION_MODULE = void 0;
|
|
7
|
-
require("./types");
|
|
8
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
9
7
|
const translation_module_1 = __importDefault(require("./services/translation-module"));
|
|
10
|
-
const config_1 = __importDefault(require("./loaders/config"));
|
|
11
8
|
const defaults_1 = __importDefault(require("./loaders/defaults"));
|
|
9
|
+
const config_1 = __importDefault(require("./loaders/config"));
|
|
10
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
12
11
|
exports.TRANSLATION_MODULE = "translation";
|
|
13
12
|
exports.default = (0, utils_1.Module)(exports.TRANSLATION_MODULE, {
|
|
14
13
|
service: translation_module_1.default,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAAmE;AACnE,kEAA6C;AAC7C,8DAAyC;AACzC,qDAAkD;AAErC,QAAA,kBAAkB,GAAG,aAAa,CAAA;AAE/C,kBAAe,IAAA,cAAM,EAAC,0BAAkB,EAAE;IACxC,OAAO,EAAE,4BAAwB;IACjC,OAAO,EAAE,CAAC,kBAAY,EAAE,gBAAU,CAAC;CACpC,CAAC,CAAA"}
|
package/dist/loaders/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LoaderOptions } from "@medusajs/framework/types";
|
|
2
|
-
|
|
3
|
-
declare const _default: ({ container, options, }: LoaderOptions<TranslationModuleOptions>) => Promise<void>;
|
|
2
|
+
declare const _default: ({ container }: LoaderOptions) => Promise<void>;
|
|
4
3
|
export default _default;
|
|
5
4
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/loaders/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/loaders/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;yBAKnC,eAAe,aAAa,KAAG,OAAO,CAAC,IAAI,CAAC;AAAlE,wBAKC"}
|
package/dist/loaders/config.js
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
4
3
|
const constants_1 = require("../utils/constants");
|
|
5
4
|
const awilix_1 = require("awilix");
|
|
6
5
|
const translatable_fields_1 = require("../utils/translatable-fields");
|
|
7
|
-
exports.default = async ({ container
|
|
8
|
-
|
|
9
|
-
const settingsService = container.resolve("translationSettingsService");
|
|
10
|
-
const mergedConfig = translatable_fields_1.translatableFieldsConfig;
|
|
11
|
-
const userProvidedFields = options?.entities ?? [];
|
|
12
|
-
for (const field of userProvidedFields) {
|
|
13
|
-
mergedConfig[field.type] ??= [];
|
|
14
|
-
mergedConfig[field.type] = Array.from(new Set([...(mergedConfig[field.type] ?? []), ...field.fields]));
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
const existingSettings = await settingsService.list({}, { select: ["id", "entity_type"] });
|
|
18
|
-
const existingByEntityType = new Map(existingSettings.map((s) => [s.entity_type, s.id]));
|
|
19
|
-
const settingsToUpsert = Object.entries(mergedConfig).map(([entityType, fields]) => {
|
|
20
|
-
const existingId = existingByEntityType.get(entityType);
|
|
21
|
-
return existingId
|
|
22
|
-
? { id: existingId, entity_type: entityType, fields }
|
|
23
|
-
: { entity_type: entityType, fields };
|
|
24
|
-
});
|
|
25
|
-
const resp = await settingsService.upsert(settingsToUpsert);
|
|
26
|
-
logger.debug(`Loaded ${resp.length} translation settings`);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
logger.warn(`Failed to load translation settings, skipping loader. Original error: ${error.message}`);
|
|
30
|
-
}
|
|
31
|
-
container.register(constants_1.TRANSLATABLE_FIELDS_CONFIG_KEY, (0, awilix_1.asValue)(mergedConfig));
|
|
6
|
+
exports.default = async ({ container }) => {
|
|
7
|
+
container.register(constants_1.TRANSLATABLE_FIELDS_CONFIG_KEY, (0, awilix_1.asValue)(translatable_fields_1.translatableFieldsConfig));
|
|
32
8
|
};
|
|
33
9
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/loaders/config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/loaders/config.ts"],"names":[],"mappings":";;AACA,gDAAiE;AACjE,mCAAgC;AAChC,sEAAuE;AAEvE,kBAAe,KAAK,EAAE,EAAE,SAAS,EAAiB,EAAiB,EAAE;IACnE,SAAS,CAAC,QAAQ,CAChB,0CAA8B,EAC9B,IAAA,gBAAO,EAAC,8CAAwB,CAAC,CAClC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/loaders/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGd,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/loaders/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAGd,MAAM,2BAA2B,CAAA;yBA6DZ,eAAe,aAAa,KAAG,OAAO,CAAC,IAAI,CAAC;AAAlE,wBAcC"}
|
package/dist/loaders/defaults.js
CHANGED
|
@@ -56,23 +56,12 @@ const defaultLocales = [
|
|
|
56
56
|
{ code: "zh-HK", name: "Chinese Traditional (Hong Kong)" },
|
|
57
57
|
{ code: "ja-JP", name: "Japanese (Japan)" },
|
|
58
58
|
{ code: "ko-KR", name: "Korean (South Korea)" },
|
|
59
|
-
{ code: "ka-GE", name: "Georgian (Georgia)" },
|
|
60
59
|
];
|
|
61
60
|
exports.default = async ({ container }) => {
|
|
62
61
|
const logger = container.resolve(utils_1.ContainerRegistrationKeys.LOGGER) ?? console;
|
|
63
62
|
const localeService_ = container.resolve("localeService");
|
|
64
63
|
try {
|
|
65
|
-
|
|
66
|
-
// The upsert method uses `id` as the key, so we need to include IDs for existing locales
|
|
67
|
-
const existingLocales = await localeService_.list({}, { select: ["id", "code"] });
|
|
68
|
-
const existingByCode = new Map(existingLocales.map((l) => [l.code, l.id]));
|
|
69
|
-
// Map default locales to include IDs for existing ones
|
|
70
|
-
const localesToUpsert = defaultLocales.map((locale) => {
|
|
71
|
-
const normalizedCode = (0, utils_1.normalizeLocale)(locale.code);
|
|
72
|
-
const existingId = existingByCode.get(normalizedCode);
|
|
73
|
-
return existingId ? { ...locale, id: existingId } : locale;
|
|
74
|
-
});
|
|
75
|
-
const resp = await localeService_.upsert(localesToUpsert);
|
|
64
|
+
const resp = await localeService_.upsert(defaultLocales);
|
|
76
65
|
logger.debug(`Loaded ${resp.length} locales`);
|
|
77
66
|
}
|
|
78
67
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/loaders/defaults.ts"],"names":[],"mappings":";;AAKA,
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/models/index.js
CHANGED
|
@@ -3,11 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Locale = exports.Translation = void 0;
|
|
7
7
|
var translation_1 = require("./translation");
|
|
8
8
|
Object.defineProperty(exports, "Translation", { enumerable: true, get: function () { return __importDefault(translation_1).default; } });
|
|
9
9
|
var locale_1 = require("./locale");
|
|
10
10
|
Object.defineProperty(exports, "Locale", { enumerable: true, get: function () { return __importDefault(locale_1).default; } });
|
|
11
|
-
var settings_1 = require("./settings");
|
|
12
|
-
Object.defineProperty(exports, "Settings", { enumerable: true, get: function () { return __importDefault(settings_1).default; } });
|
|
13
11
|
//# sourceMappingURL=index.js.map
|
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsD;AAA7C,2HAAA,OAAO,OAAe;AAC/B,mCAA4C;AAAnC,iHAAA,OAAO,OAAU
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsD;AAA7C,2HAAA,OAAO,OAAe;AAC/B,mCAA4C;AAAnC,iHAAA,OAAO,OAAU"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Context, CreateTranslationDTO, DAL, FilterableTranslationProps, FindConfig, ITranslationModuleService, ModulesSdkTypes, TranslationTypes } from "@medusajs/framework/types";
|
|
2
2
|
import Locale from "../models/locale";
|
|
3
3
|
import Translation from "../models/translation";
|
|
4
|
-
import Settings from "../models/settings";
|
|
5
4
|
import { TRANSLATABLE_FIELDS_CONFIG_KEY } from "../utils/constants";
|
|
6
5
|
type InjectedDependencies = {
|
|
7
6
|
baseRepository: DAL.RepositoryService;
|
|
8
7
|
translationService: ModulesSdkTypes.IMedusaInternalService<typeof Translation>;
|
|
9
8
|
localeService: ModulesSdkTypes.IMedusaInternalService<typeof Locale>;
|
|
10
|
-
translationSettingsService: ModulesSdkTypes.IMedusaInternalService<typeof Settings>;
|
|
11
9
|
[TRANSLATABLE_FIELDS_CONFIG_KEY]: Record<string, string[]>;
|
|
12
10
|
};
|
|
13
11
|
declare const TranslationModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<{
|
|
@@ -17,24 +15,14 @@ declare const TranslationModuleService_base: import("@medusajs/framework/utils")
|
|
|
17
15
|
Translation: {
|
|
18
16
|
dto: TranslationTypes.TranslationDTO;
|
|
19
17
|
};
|
|
20
|
-
TranslationSettings: {
|
|
21
|
-
dto: TranslationTypes.TranslationSettingsDTO;
|
|
22
|
-
};
|
|
23
18
|
}>;
|
|
24
19
|
export default class TranslationModuleService extends TranslationModuleService_base implements ITranslationModuleService {
|
|
25
20
|
protected baseRepository_: DAL.RepositoryService;
|
|
26
21
|
protected translationService_: ModulesSdkTypes.IMedusaInternalService<typeof Translation>;
|
|
27
22
|
protected localeService_: ModulesSdkTypes.IMedusaInternalService<typeof Locale>;
|
|
28
|
-
|
|
29
|
-
constructor({ baseRepository, translationService, localeService,
|
|
30
|
-
getTranslatableFields(entityType?: string, sharedContext?: Context): Promise<Record<string, string[]>>;
|
|
23
|
+
private readonly translatableFieldsConfig_;
|
|
24
|
+
constructor({ baseRepository, translationService, localeService, translatableFieldsConfig, }: InjectedDependencies);
|
|
31
25
|
static prepareFilters(filters: FilterableTranslationProps): FilterableTranslationProps;
|
|
32
|
-
retrieveTranslation(id: string, config?: FindConfig<TranslationTypes.TranslationDTO>, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO>;
|
|
33
|
-
/**
|
|
34
|
-
* Ensures the 'reference' field is included in the select config.
|
|
35
|
-
* This is needed for filtering translations by translatable fields.
|
|
36
|
-
*/
|
|
37
|
-
static ensureReferenceFieldInConfig(config: FindConfig<TranslationTypes.TranslationDTO>): FindConfig<TranslationTypes.TranslationDTO>;
|
|
38
26
|
listTranslations(filters?: FilterableTranslationProps, config?: FindConfig<TranslationTypes.TranslationDTO>, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO[]>;
|
|
39
27
|
listAndCountTranslations(filters?: FilterableTranslationProps, config?: FindConfig<TranslationTypes.TranslationDTO>, sharedContext?: Context): Promise<[TranslationTypes.TranslationDTO[], number]>;
|
|
40
28
|
createLocales(data: TranslationTypes.CreateLocaleDTO[], sharedContext?: Context): Promise<TranslationTypes.LocaleDTO[]>;
|
|
@@ -43,6 +31,7 @@ export default class TranslationModuleService extends TranslationModuleService_b
|
|
|
43
31
|
createTranslations(data: CreateTranslationDTO[], sharedContext?: Context): Promise<TranslationTypes.TranslationDTO[]>;
|
|
44
32
|
updateTranslations(data: TranslationTypes.UpdateTranslationDTO, sharedContext?: Context): Promise<TranslationTypes.TranslationDTO>;
|
|
45
33
|
updateTranslations(data: TranslationTypes.UpdateTranslationDTO[], sharedContext?: Context): Promise<TranslationTypes.TranslationDTO[]>;
|
|
34
|
+
getTranslatableFields(entityType?: string): Record<string, string[]>;
|
|
46
35
|
getStatistics(input: TranslationTypes.TranslationStatisticsInput, sharedContext?: Context): Promise<TranslationTypes.TranslationStatisticsOutput>;
|
|
47
36
|
}
|
|
48
37
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-module.d.ts","sourceRoot":"","sources":["../../src/services/translation-module.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,GAAG,EACH,0BAA0B,EAC1B,UAAU,EACV,yBAAyB,EAEzB,eAAe,EACf,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAUlC,OAAO,MAAM,MAAM,gBAAgB,CAAA;AACnC,OAAO,WAAW,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"translation-module.d.ts","sourceRoot":"","sources":["../../src/services/translation-module.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,oBAAoB,EACpB,GAAG,EACH,0BAA0B,EAC1B,UAAU,EACV,yBAAyB,EAEzB,eAAe,EACf,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAUlC,OAAO,MAAM,MAAM,gBAAgB,CAAA;AACnC,OAAO,WAAW,MAAM,qBAAqB,CAAA;AAE7C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAEjE,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,kBAAkB,EAAE,eAAe,CAAC,sBAAsB,CAAC,OAAO,WAAW,CAAC,CAAA;IAC9E,aAAa,EAAE,eAAe,CAAC,sBAAsB,CAAC,OAAO,MAAM,CAAC,CAAA;IACpE,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAC3D,CAAA;;YAIW;QACN,GAAG,EAAE,gBAAgB,CAAC,SAAS,CAAA;KAChC;iBACY;QACX,GAAG,EAAE,gBAAgB,CAAC,cAAc,CAAA;KACrC;;AAPL,MAAM,CAAC,OAAO,OAAO,wBACnB,SAAQ,6BAWR,YAAW,yBAAyB;IAEpC,SAAS,CAAC,eAAe,EAA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,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAkC7C,kBAAkB,CAChB,IAAI,EAAE,gBAAgB,CAAC,oBAAoB,EAC3C,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,gBAAgB,CAAC,cAAc,CAAC;IAE3C,kBAAkB,CAChB,IAAI,EAAE,gBAAgB,CAAC,oBAAoB,EAAE,EAC7C,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IA8D7C,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAQ9D,aAAa,CACjB,KAAK,EAAE,gBAAgB,CAAC,0BAA0B,EACjC,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,gBAAgB,CAAC,2BAA2B,CAAC;CA0GzD"}
|
|
@@ -20,29 +20,18 @@ const types_1 = require("@medusajs/framework/types");
|
|
|
20
20
|
const utils_1 = require("@medusajs/framework/utils");
|
|
21
21
|
const locale_1 = __importDefault(require("../models/locale"));
|
|
22
22
|
const translation_1 = __importDefault(require("../models/translation"));
|
|
23
|
-
const settings_1 = __importDefault(require("../models/settings"));
|
|
24
23
|
const compute_translated_field_count_1 = require("../utils/compute-translated-field-count");
|
|
25
24
|
const constants_1 = require("../utils/constants");
|
|
26
|
-
const filter_translation_fields_1 = require("../utils/filter-translation-fields");
|
|
27
25
|
class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
28
26
|
Locale: locale_1.default,
|
|
29
27
|
Translation: translation_1.default,
|
|
30
|
-
TranslationSettings: settings_1.default,
|
|
31
28
|
}) {
|
|
32
|
-
constructor({ baseRepository, translationService, localeService,
|
|
29
|
+
constructor({ baseRepository, translationService, localeService, translatableFieldsConfig, }) {
|
|
33
30
|
super(...arguments);
|
|
34
31
|
this.baseRepository_ = baseRepository;
|
|
35
32
|
this.translationService_ = translationService;
|
|
36
33
|
this.localeService_ = localeService;
|
|
37
|
-
this.
|
|
38
|
-
}
|
|
39
|
-
async getTranslatableFields(entityType, sharedContext = {}) {
|
|
40
|
-
const filters = entityType ? { entity_type: entityType } : {};
|
|
41
|
-
const settings = await this.settingsService_.list(filters, {}, sharedContext);
|
|
42
|
-
return settings.reduce((acc, setting) => {
|
|
43
|
-
acc[setting.entity_type] = setting.fields;
|
|
44
|
-
return acc;
|
|
45
|
-
}, {});
|
|
34
|
+
this.translatableFieldsConfig_ = translatableFieldsConfig;
|
|
46
35
|
}
|
|
47
36
|
static prepareFilters(filters) {
|
|
48
37
|
let { q, ...restFilters } = filters;
|
|
@@ -55,45 +44,17 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
55
44
|
return restFilters;
|
|
56
45
|
}
|
|
57
46
|
// @ts-expect-error
|
|
58
|
-
async retrieveTranslation(id, config = {}, sharedContext = {}) {
|
|
59
|
-
const configWithReference = TranslationModuleService.ensureReferenceFieldInConfig(config);
|
|
60
|
-
const result = await this.translationService_.retrieve(id, configWithReference, sharedContext);
|
|
61
|
-
const serialized = await this.baseRepository_.serialize(result);
|
|
62
|
-
const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
|
|
63
|
-
return (0, filter_translation_fields_1.filterTranslationFields)([serialized], translatableFieldsConfig)[0];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Ensures the 'reference' field is included in the select config.
|
|
67
|
-
* This is needed for filtering translations by translatable fields.
|
|
68
|
-
*/
|
|
69
|
-
static ensureReferenceFieldInConfig(config) {
|
|
70
|
-
if (!config?.select?.length) {
|
|
71
|
-
return config;
|
|
72
|
-
}
|
|
73
|
-
const select = config.select;
|
|
74
|
-
if (!select.includes("reference")) {
|
|
75
|
-
return { ...config, select: [...select, "reference"] };
|
|
76
|
-
}
|
|
77
|
-
return config;
|
|
78
|
-
}
|
|
79
|
-
// @ts-expect-error
|
|
80
47
|
async listTranslations(filters = {}, config = {}, sharedContext = {}) {
|
|
81
48
|
const preparedFilters = TranslationModuleService.prepareFilters(filters);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
const serialized = await this.baseRepository_.serialize(results);
|
|
85
|
-
const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
|
|
86
|
-
return (0, filter_translation_fields_1.filterTranslationFields)(serialized, translatableFieldsConfig);
|
|
49
|
+
const results = await this.translationService_.list(preparedFilters, config, sharedContext);
|
|
50
|
+
return await this.baseRepository_.serialize(results);
|
|
87
51
|
}
|
|
88
52
|
// @ts-expect-error
|
|
89
53
|
async listAndCountTranslations(filters = {}, config = {}, sharedContext = {}) {
|
|
90
54
|
const preparedFilters = TranslationModuleService.prepareFilters(filters);
|
|
91
|
-
const
|
|
92
|
-
const [results, count] = await this.translationService_.listAndCount(preparedFilters, configWithReference, sharedContext);
|
|
93
|
-
const serialized = await this.baseRepository_.serialize(results);
|
|
94
|
-
const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
|
|
55
|
+
const [results, count] = await this.translationService_.listAndCount(preparedFilters, config, sharedContext);
|
|
95
56
|
return [
|
|
96
|
-
|
|
57
|
+
await this.baseRepository_.serialize(results),
|
|
97
58
|
count,
|
|
98
59
|
];
|
|
99
60
|
}
|
|
@@ -111,11 +72,10 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
111
72
|
// @ts-expect-error
|
|
112
73
|
async createTranslations(data, sharedContext = {}) {
|
|
113
74
|
const dataArray = Array.isArray(data) ? data : [data];
|
|
114
|
-
const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
|
|
115
75
|
const normalizedData = dataArray.map((translation) => ({
|
|
116
76
|
...translation,
|
|
117
77
|
locale_code: (0, utils_1.normalizeLocale)(translation.locale_code),
|
|
118
|
-
translated_field_count: (0, compute_translated_field_count_1.computeTranslatedFieldCount)(translation.translations,
|
|
78
|
+
translated_field_count: (0, compute_translated_field_count_1.computeTranslatedFieldCount)(translation.translations, this.translatableFieldsConfig_[translation.reference]),
|
|
119
79
|
}));
|
|
120
80
|
const createdTranslations = await this.translationService_.create(normalizedData, sharedContext);
|
|
121
81
|
const serialized = await this.baseRepository_.serialize(createdTranslations);
|
|
@@ -134,11 +94,10 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
134
94
|
const existingTranslations = await this.translationService_.list({ id: idsNeedingReference }, { select: ["id", "reference"] }, sharedContext);
|
|
135
95
|
referenceMap = Object.fromEntries(existingTranslations.map((t) => [t.id, t.reference]));
|
|
136
96
|
}
|
|
137
|
-
const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
|
|
138
97
|
for (const update of dataArray) {
|
|
139
98
|
if (update.translations) {
|
|
140
99
|
const reference = update.reference || referenceMap[update.id];
|
|
141
|
-
update.translated_field_count = (0, compute_translated_field_count_1.computeTranslatedFieldCount)(update.translations,
|
|
100
|
+
update.translated_field_count = (0, compute_translated_field_count_1.computeTranslatedFieldCount)(update.translations, this.translatableFieldsConfig_[reference] || []);
|
|
142
101
|
}
|
|
143
102
|
}
|
|
144
103
|
}
|
|
@@ -146,6 +105,12 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
146
105
|
const serialized = await this.baseRepository_.serialize(updatedTranslations);
|
|
147
106
|
return Array.isArray(data) ? serialized : serialized[0];
|
|
148
107
|
}
|
|
108
|
+
getTranslatableFields(entityType) {
|
|
109
|
+
if (entityType) {
|
|
110
|
+
return { [entityType]: this.translatableFieldsConfig_[entityType] };
|
|
111
|
+
}
|
|
112
|
+
return this.translatableFieldsConfig_;
|
|
113
|
+
}
|
|
149
114
|
async getStatistics(input, sharedContext = {}) {
|
|
150
115
|
const { locales, entities } = input;
|
|
151
116
|
if (!locales || !locales.length) {
|
|
@@ -158,11 +123,10 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
158
123
|
const manager = (sharedContext.transactionManager ??
|
|
159
124
|
sharedContext.manager);
|
|
160
125
|
const knex = manager.getKnex();
|
|
161
|
-
const translatableFieldsConfig = await this.getTranslatableFields(undefined, sharedContext);
|
|
162
126
|
const result = {};
|
|
163
127
|
const entityTypes = [];
|
|
164
128
|
for (const entityType of Object.keys(entities)) {
|
|
165
|
-
const translatableFields =
|
|
129
|
+
const translatableFields = this.translatableFieldsConfig_[entityType];
|
|
166
130
|
if (!translatableFields || translatableFields.length === 0) {
|
|
167
131
|
result[entityType] = {
|
|
168
132
|
expected: 0,
|
|
@@ -193,7 +157,7 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
193
157
|
GROUP BY reference, locale_code
|
|
194
158
|
`, [entityTypes, normalizedLocales]);
|
|
195
159
|
for (const entityType of entityTypes) {
|
|
196
|
-
const translatableFields =
|
|
160
|
+
const translatableFields = this.translatableFieldsConfig_[entityType];
|
|
197
161
|
const fieldsPerEntity = translatableFields.length;
|
|
198
162
|
const entityCount = entities[entityType].count;
|
|
199
163
|
const expectedPerLocale = entityCount * fieldsPerEntity;
|
|
@@ -228,22 +192,6 @@ class TranslationModuleService extends (0, utils_1.MedusaService)({
|
|
|
228
192
|
}
|
|
229
193
|
}
|
|
230
194
|
exports.default = TranslationModuleService;
|
|
231
|
-
__decorate([
|
|
232
|
-
(0, utils_1.InjectManager)(),
|
|
233
|
-
__param(1, (0, utils_1.MedusaContext)()),
|
|
234
|
-
__metadata("design:type", Function),
|
|
235
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
236
|
-
__metadata("design:returntype", Promise)
|
|
237
|
-
], TranslationModuleService.prototype, "getTranslatableFields", null);
|
|
238
|
-
__decorate([
|
|
239
|
-
(0, utils_1.InjectManager)()
|
|
240
|
-
// @ts-expect-error
|
|
241
|
-
,
|
|
242
|
-
__param(2, (0, utils_1.MedusaContext)()),
|
|
243
|
-
__metadata("design:type", Function),
|
|
244
|
-
__metadata("design:paramtypes", [String, Object, Object]),
|
|
245
|
-
__metadata("design:returntype", Promise)
|
|
246
|
-
], TranslationModuleService.prototype, "retrieveTranslation", null);
|
|
247
195
|
__decorate([
|
|
248
196
|
(0, utils_1.InjectManager)()
|
|
249
197
|
// @ts-expect-error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-module.js","sourceRoot":"","sources":["../../src/services/translation-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6DAAwD;AACxD,qDAUkC;AAElC,qDAOkC;AAClC,4DAAmC;AACnC,sEAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"translation-module.js","sourceRoot":"","sources":["../../src/services/translation-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6DAAwD;AACxD,qDAUkC;AAElC,qDAOkC;AAClC,4DAAmC;AACnC,sEAA6C;AAC7C,0FAAmF;AACnF,gDAAiE;AASjE,MAAqB,wBACnB,SAAQ,IAAA,qBAAa,EAOlB;IACD,MAAM,EAAN,gBAAM;IACN,WAAW,EAAX,qBAAW;CACZ,CAAC;IAaF,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,wBAAwB,GACH;QACrB,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAA;QACrC,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC7C,IAAI,CAAC,cAAc,GAAG,aAAa,CAAA;QACnC,IAAI,CAAC,yBAAyB,GAAG,wBAAwB,CAAA;IAC3D,CAAC;IAED,MAAM,CAAC,cAAc,CACnB,OAAmC;QAEnC,IAAI,EAAE,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAA;QAEnC,IAAI,CAAC,EAAE,CAAC;YACN,WAAW,GAAG;gBACZ,GAAG,WAAW;gBACd,CAAC,IAAA,UAAG,EAAC,4BAA4B,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;aACpD,CAAA;QACH,CAAC;QAED,OAAO,WAAW,CAAA;IACpB,CAAC;IAIK,AADN,mBAAmB;IACnB,KAAK,CAAC,gBAAgB,CACpB,UAAs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mB;;IAIhB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;gEAajB;AAIK;IAFL,IAAA,qBAAa,GAAE;IAChB,mBAAmB;;IAIhB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;wEAgBjB;AAgBK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAGhB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;6DAiBjB;AAiBK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAGhB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;kEAwBjB;AAgBK;IAHL,IAAA,qBAAa,GAAE;IACf,IAAA,kBAAU,GAAE;IACb,mBAAmB;;IAKhB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;kEAmDjB;AAUK;IADL,IAAA,qBAAa,GAAE;IAGb,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;6DA0GjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/loaders/config.ts","../src/loaders/defaults.ts","../src/migrations/Migration20251208124155.ts","../src/migrations/Migration20251215083927.ts","../src/
|
|
1
|
+
{"root":["../src/index.ts","../src/loaders/config.ts","../src/loaders/defaults.ts","../src/migrations/Migration20251208124155.ts","../src/migrations/Migration20251215083927.ts","../src/models/index.ts","../src/models/locale.ts","../src/models/translation.ts","../src/services/translation-module.ts","../src/utils/compute-translated-field-count.ts","../src/utils/constants.ts","../src/utils/translatable-fields.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/translation",
|
|
3
|
-
"version": "2.12.4-
|
|
3
|
+
"version": "2.12.4-snapshot-20251218091536",
|
|
4
4
|
"description": "Medusa Translation module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"orm:cache:clear": "MIKRO_ORM_CLI_CONFIG=./mikro-orm.config.dev.ts MIKRO_ORM_ALLOW_GLOBAL_CLI=true medusa-mikro-orm cache:clear"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@medusajs/framework": "2.12.4-
|
|
40
|
-
"@medusajs/test-utils": "2.12.4-
|
|
39
|
+
"@medusajs/framework": "2.12.4-snapshot-20251218091536",
|
|
40
|
+
"@medusajs/test-utils": "2.12.4-snapshot-20251218091536"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@medusajs/framework": "2.12.4-
|
|
43
|
+
"@medusajs/framework": "2.12.4-snapshot-20251218091536"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20251218140235.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20251218140235.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAenB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Migration20251218140235 = void 0;
|
|
4
|
-
const migrations_1 = require("@medusajs/framework/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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20251218140235.js","sourceRoot":"","sources":["../../src/migrations/Migration20251218140235.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAEpE,MAAa,uBAAwB,SAAQ,sBAAS;IAC3C,KAAK,CAAC,EAAE;QACf,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;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,sDAAsD,CAAC,CAAA;IACrE,CAAC;CACF;AAnBD,0DAmBC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare const Settings: import("@medusajs/framework/utils").DmlEntity<import("@medusajs/framework/utils").DMLEntitySchemaBuilder<{
|
|
2
|
-
id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").IdProperty>;
|
|
3
|
-
/**
|
|
4
|
-
* The entity type that these settings apply to (e.g., "product", "product_variant").
|
|
5
|
-
*/
|
|
6
|
-
entity_type: import("@medusajs/framework/utils").TextProperty;
|
|
7
|
-
/**
|
|
8
|
-
* The translatable fields for this entity type.
|
|
9
|
-
* Array of field names that can be translated.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ["title", "description", "material"]
|
|
13
|
-
*/
|
|
14
|
-
fields: import("@medusajs/framework/utils").JSONProperty;
|
|
15
|
-
}>, "translation_settings">;
|
|
16
|
-
export default Settings;
|
|
17
|
-
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/models/settings.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,QAAQ;;IAGV;;OAEG;;IAEH;;;;;;OAMG;;2BAQH,CAAA;AAEJ,eAAe,QAAQ,CAAA"}
|
package/dist/models/settings.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("@medusajs/framework/utils");
|
|
4
|
-
const Settings = utils_1.model
|
|
5
|
-
.define("translation_settings", {
|
|
6
|
-
id: utils_1.model.id({ prefix: "trset" }).primaryKey(),
|
|
7
|
-
/**
|
|
8
|
-
* The entity type that these settings apply to (e.g., "product", "product_variant").
|
|
9
|
-
*/
|
|
10
|
-
entity_type: utils_1.model.text().searchable(),
|
|
11
|
-
/**
|
|
12
|
-
* The translatable fields for this entity type.
|
|
13
|
-
* Array of field names that can be translated.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ["title", "description", "material"]
|
|
17
|
-
*/
|
|
18
|
-
fields: utils_1.model.json(),
|
|
19
|
-
})
|
|
20
|
-
.indexes([
|
|
21
|
-
{
|
|
22
|
-
on: ["entity_type"],
|
|
23
|
-
unique: true,
|
|
24
|
-
},
|
|
25
|
-
]);
|
|
26
|
-
exports.default = Settings;
|
|
27
|
-
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/models/settings.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAM,QAAQ,GAAG,aAAK;KACnB,MAAM,CAAC,sBAAsB,EAAE;IAC9B,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE;IAC9C;;OAEG;IACH,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACtC;;;;;;OAMG;IACH,MAAM,EAAE,aAAK,CAAC,IAAI,EAAE;CACrB,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,aAAa,CAAC;QACnB,MAAM,EAAE,IAAI;KACb;CACF,CAAC,CAAA;AAEJ,kBAAe,QAAQ,CAAA"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { RemoteQueryEntryPoints } from "@medusajs/framework/types";
|
|
2
|
-
/**
|
|
3
|
-
* Extracts only the keys of T where the value is a string (or nullable string), the key
|
|
4
|
-
* is not __typename or id.
|
|
5
|
-
* This filters out relations and other non-string fields.
|
|
6
|
-
*/
|
|
7
|
-
type StringValuedKeys<T> = {
|
|
8
|
-
[K in keyof T]: K extends `${string}_id` ? never : "__typename" extends K ? never : "id" extends keyof K ? never : NonNullable<T[K]> extends string ? K : never;
|
|
9
|
-
}[keyof T];
|
|
10
|
-
/**
|
|
11
|
-
* A discriminated union of all possible entity configurations.
|
|
12
|
-
* When you specify a `type`, TypeScript will narrow `fields` to only
|
|
13
|
-
* the string-valued keys of that specific entity type.
|
|
14
|
-
*/
|
|
15
|
-
export type TranslatableEntityConfig = {
|
|
16
|
-
[K in keyof RemoteQueryEntryPoints]: {
|
|
17
|
-
type: K;
|
|
18
|
-
fields: StringValuedKeys<RemoteQueryEntryPoints[K]>[];
|
|
19
|
-
};
|
|
20
|
-
}[keyof RemoteQueryEntryPoints] | {
|
|
21
|
-
type: string;
|
|
22
|
-
fields: string[];
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Options for configuring the translation module.
|
|
26
|
-
*/
|
|
27
|
-
export type TranslationModuleOptions = {
|
|
28
|
-
entities?: TranslatableEntityConfig[];
|
|
29
|
-
};
|
|
30
|
-
declare module "@medusajs/types" {
|
|
31
|
-
interface ModuleOptions {
|
|
32
|
-
"@medusajs/translation": TranslationModuleOptions;
|
|
33
|
-
"@medusajs/medusa/translation": TranslationModuleOptions;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAElE;;;;GAIG;AACH,KAAK,gBAAgB,CAAC,CAAC,IAAI;KACxB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,MAAM,KAAK,GACpC,KAAK,GACL,YAAY,SAAS,CAAC,GACtB,KAAK,GACL,IAAI,SAAS,MAAM,CAAC,GACpB,KAAK,GACL,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAChC,CAAC,GACD,KAAK;CACV,CAAC,MAAM,CAAC,CAAC,CAAA;AAEV;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAChC;KACG,CAAC,IAAI,MAAM,sBAAsB,GAAG;QACnC,IAAI,EAAE,CAAC,CAAA;QACP,MAAM,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;KACtD;CACF,CAAC,MAAM,sBAAsB,CAAC,GAC/B;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AAEL;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,EAAE,wBAAwB,EAAE,CAAA;CACtC,CAAA;AAGD,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,aAAa;QACrB,uBAAuB,EAAE,wBAAwB,CAAA;QACjD,8BAA8B,EAAE,wBAAwB,CAAA;KACzD;CACF"}
|
package/dist/types/index.js
DELETED
package/dist/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { TranslationTypes } from "@medusajs/framework/types";
|
|
2
|
-
export declare function filterTranslationFields(translations: TranslationTypes.TranslationDTO[], translatableFieldsConfig: Record<string, string[]>): TranslationTypes.TranslationDTO[];
|
|
3
|
-
//# sourceMappingURL=filter-translation-fields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,2BAA2B,CAAA;AAE5D,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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|