@etsoo/shared 1.1.19 → 1.1.20

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/README.md CHANGED
@@ -68,6 +68,7 @@ Data type definitions and type safe functions
68
68
  |IdType|Number and string combination id type|
69
69
  |IdItem|Item with id or id generator|
70
70
  |IdLabelItem|Item with id and label|
71
+ |KeyCollection|Key collection, like { key1: {}, key2: {} }|
71
72
  |Simple|Basic or basic array type|
72
73
  |SimpleEnum|Simple type enum|
73
74
  |SimpleNames|Simple type names|
@@ -120,6 +120,12 @@ export declare namespace DataTypes {
120
120
  type AddOrEditType<T, Editing extends boolean> = (Editing extends true ? T : Partial<T>) & {
121
121
  changedFields?: string[];
122
122
  };
123
+ /**
124
+ * Key collection, like { key1: {}, key2: {} }
125
+ */
126
+ type KeyCollection<K extends readonly string[], I extends {}> = {
127
+ [index in K[number]]: I;
128
+ };
123
129
  /**
124
130
  * Enum value type
125
131
  */
@@ -55,7 +55,13 @@ export declare namespace DomUtils {
55
55
  * @param culture Detected culture
56
56
  */
57
57
  const getCulture: (items: DataTypes.CultureDefinition[], culture: string) => Readonly<{
58
- readonly name: string;
58
+ readonly name: string; /**
59
+ * Cast data to target type
60
+ * @param source Source data
61
+ * @param template Template for generation
62
+ * @param keepSource Means even the template does not include the definition, still keep the item
63
+ * @returns Result
64
+ */
59
65
  readonly label: string;
60
66
  readonly resources: Readonly<DataTypes.StringRecord>;
61
67
  readonly compatibleName?: string[] | undefined;
@@ -120,6 +120,12 @@ export declare namespace DataTypes {
120
120
  type AddOrEditType<T, Editing extends boolean> = (Editing extends true ? T : Partial<T>) & {
121
121
  changedFields?: string[];
122
122
  };
123
+ /**
124
+ * Key collection, like { key1: {}, key2: {} }
125
+ */
126
+ type KeyCollection<K extends readonly string[], I extends {}> = {
127
+ [index in K[number]]: I;
128
+ };
123
129
  /**
124
130
  * Enum value type
125
131
  */
@@ -55,7 +55,13 @@ export declare namespace DomUtils {
55
55
  * @param culture Detected culture
56
56
  */
57
57
  const getCulture: (items: DataTypes.CultureDefinition[], culture: string) => Readonly<{
58
- readonly name: string;
58
+ readonly name: string; /**
59
+ * Cast data to target type
60
+ * @param source Source data
61
+ * @param template Template for generation
62
+ * @param keepSource Means even the template does not include the definition, still keep the item
63
+ * @returns Result
64
+ */
59
65
  readonly label: string;
60
66
  readonly resources: Readonly<DataTypes.StringRecord>;
61
67
  readonly compatibleName?: string[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
package/src/DataTypes.ts CHANGED
@@ -156,6 +156,13 @@ export namespace DataTypes {
156
156
  Editing extends boolean
157
157
  > = (Editing extends true ? T : Partial<T>) & { changedFields?: string[] };
158
158
 
159
+ /**
160
+ * Key collection, like { key1: {}, key2: {} }
161
+ */
162
+ export type KeyCollection<K extends readonly string[], I extends {}> = {
163
+ [index in K[number]]: I;
164
+ };
165
+
159
166
  /**
160
167
  * Enum value type
161
168
  */