@yamato-daiwa/es-extensions 1.9.0-alpha.2 → 1.9.0-alpha.4
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/Distributable/cjs/DataMocking/LocalizableMocking/LocalizableEntitiesByIDsMap.js +20 -5
- package/Distributable/cjs/DataMocking/LocalizableMocking/LocalizableSampleDataRepository.js +4 -6
- package/Distributable/esm/DataMocking/LocalizableMocking/LocalizableEntitiesByIDsMap.d.ts +7 -2
- package/Distributable/esm/DataMocking/LocalizableMocking/LocalizableEntitiesByIDsMap.js +20 -5
- package/Distributable/esm/DataMocking/LocalizableMocking/LocalizableSampleDataRepository.js +4 -6
- package/package.json +6 -6
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class LocalizableEntitiesByIDsMap extends Map {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
getEntityID;
|
|
5
|
+
constructor({ initialEntitiesWithLocalizations, getEntityID }) {
|
|
6
|
+
super((initialEntitiesWithLocalizations ?? []).
|
|
7
|
+
map(({ entity, localizations }) => [
|
|
8
|
+
getEntityID(entity),
|
|
9
|
+
{
|
|
10
|
+
entity,
|
|
11
|
+
localizations
|
|
12
|
+
}
|
|
13
|
+
]));
|
|
14
|
+
this.getEntityID = getEntityID;
|
|
6
15
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
addEntityWithLocalization({ entity, localizations }) {
|
|
17
|
+
super.set(this.getEntityID(entity), {
|
|
18
|
+
entity,
|
|
19
|
+
localizations
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
addEntitiesWithLocalizations(entitiesWithLocalization) {
|
|
23
|
+
for (const { entity, localizations } of entitiesWithLocalization) {
|
|
24
|
+
this.set(this.getEntityID(entity), { entity, localizations });
|
|
10
25
|
}
|
|
11
26
|
}
|
|
12
27
|
}
|
|
@@ -31,12 +31,10 @@ class LocalizableSampleDataRepository {
|
|
|
31
31
|
if (mustCacheGeneratedSamples) {
|
|
32
32
|
this.cachedSamplesWithLocalizationsByHumanFriendlyIDs = samplesWithLocalizationsByHumanFriendlyIDs;
|
|
33
33
|
}
|
|
34
|
-
return new LocalizableEntitiesByIDsMap_1.default(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
entityWithLocalization
|
|
39
|
-
]));
|
|
34
|
+
return new LocalizableEntitiesByIDsMap_1.default({
|
|
35
|
+
getEntityID: this.getEntityID.bind(this),
|
|
36
|
+
initialEntitiesWithLocalizations: Object.values(samplesWithLocalizationsByHumanFriendlyIDs)
|
|
37
|
+
});
|
|
40
38
|
}
|
|
41
39
|
getExpectedBeInitializedSamplesWithLocalizationsByHumanFriendlyIDs() {
|
|
42
40
|
return this.cachedSamplesWithLocalizationsByHumanFriendlyIDs ??
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
declare class LocalizableEntitiesByIDsMap<Entity, EntityID extends string | number | bigint, Localization, LocalizationsKeys extends string> extends Map<EntityID, LocalizableEntitiesByIDsMap.EntityWithLocalizations<Entity, Localization, LocalizationsKeys>> {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
private readonly getEntityID;
|
|
3
|
+
constructor({ initialEntitiesWithLocalizations, getEntityID }: Readonly<{
|
|
4
|
+
initialEntitiesWithLocalizations?: ReadonlyArray<LocalizableEntitiesByIDsMap.EntityWithLocalizations<Entity, Localization, LocalizationsKeys>>;
|
|
5
|
+
getEntityID: (entity: Entity) => EntityID;
|
|
6
|
+
}>);
|
|
7
|
+
addEntityWithLocalization({ entity, localizations }: LocalizableEntitiesByIDsMap.EntityWithLocalizations<Entity, Localization, LocalizationsKeys>): void;
|
|
8
|
+
addEntitiesWithLocalizations(entitiesWithLocalization: ReadonlyArray<LocalizableEntitiesByIDsMap.EntityWithLocalizations<Entity, Localization, LocalizationsKeys>>): void;
|
|
4
9
|
}
|
|
5
10
|
declare namespace LocalizableEntitiesByIDsMap {
|
|
6
11
|
type EntityWithLocalizations<Entity, Localization, LocalizationsKeys extends string> = {
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
class LocalizableEntitiesByIDsMap extends Map {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
getEntityID;
|
|
3
|
+
constructor({ initialEntitiesWithLocalizations, getEntityID }) {
|
|
4
|
+
super((initialEntitiesWithLocalizations ?? []).
|
|
5
|
+
map(({ entity, localizations }) => [
|
|
6
|
+
getEntityID(entity),
|
|
7
|
+
{
|
|
8
|
+
entity,
|
|
9
|
+
localizations
|
|
10
|
+
}
|
|
11
|
+
]));
|
|
12
|
+
this.getEntityID = getEntityID;
|
|
4
13
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
addEntityWithLocalization({ entity, localizations }) {
|
|
15
|
+
super.set(this.getEntityID(entity), {
|
|
16
|
+
entity,
|
|
17
|
+
localizations
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
addEntitiesWithLocalizations(entitiesWithLocalization) {
|
|
21
|
+
for (const { entity, localizations } of entitiesWithLocalization) {
|
|
22
|
+
this.set(this.getEntityID(entity), { entity, localizations });
|
|
8
23
|
}
|
|
9
24
|
}
|
|
10
25
|
}
|
|
@@ -26,12 +26,10 @@ class LocalizableSampleDataRepository {
|
|
|
26
26
|
if (mustCacheGeneratedSamples) {
|
|
27
27
|
this.cachedSamplesWithLocalizationsByHumanFriendlyIDs = samplesWithLocalizationsByHumanFriendlyIDs;
|
|
28
28
|
}
|
|
29
|
-
return new LocalizableEntitiesByIDsMap(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
entityWithLocalization
|
|
34
|
-
]));
|
|
29
|
+
return new LocalizableEntitiesByIDsMap({
|
|
30
|
+
getEntityID: this.getEntityID.bind(this),
|
|
31
|
+
initialEntitiesWithLocalizations: Object.values(samplesWithLocalizationsByHumanFriendlyIDs)
|
|
32
|
+
});
|
|
35
33
|
}
|
|
36
34
|
getExpectedBeInitializedSamplesWithLocalizationsByHumanFriendlyIDs() {
|
|
37
35
|
return this.cachedSamplesWithLocalizationsByHumanFriendlyIDs ??
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamato-daiwa/es-extensions",
|
|
3
|
-
"version": "1.9.0-alpha.
|
|
3
|
+
"version": "1.9.0-alpha.4",
|
|
4
4
|
"description": "Helper functions and classes aimed to reduce the routine code. Build-in TypeScript type safety.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"Distributable"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"fundamental-constants": "0.
|
|
32
|
+
"fundamental-constants": "0.9.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "22.15.31",
|
|
36
|
-
"@yamato-daiwa/style_guides": "0.
|
|
36
|
+
"@yamato-daiwa/style_guides": "0.14.2",
|
|
37
37
|
"rimraf": "6.1.3",
|
|
38
38
|
"timezone-mock": "1.4.2",
|
|
39
|
-
"tsx": "4.
|
|
40
|
-
"typescript": "6.0.
|
|
39
|
+
"tsx": "4.22.0",
|
|
40
|
+
"typescript": "6.0.3"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"Check Types": "tsc -p tsconfig-cjs.json --noEmit",
|
|
44
44
|
"Lint": "eslint",
|
|
45
45
|
"Run Tests": "node --require tsx/cjs --test \"Tests/Automated/**/*.test.ts\"",
|
|
46
46
|
"Rebuild Distributable Without Preliminary Cleaning": "tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json",
|
|
47
|
-
"Rebuild Distributable": "rimraf Distributable && tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json",
|
|
47
|
+
"Rebuild Distributable": "rimraf --glob Distributable/* && tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json",
|
|
48
48
|
"Rebuild Distributable and Realize Alpha": "npm run \"Rebuild Distributable\" && npm publish --tag alpha",
|
|
49
49
|
"Rebuild Distributable and Realize RC": "npm run \"Rebuild Distributable\" && npm publish --tag rc"
|
|
50
50
|
},
|