@medyll/idae-idbql 0.177.0 → 0.178.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,20 @@
1
+ /**
2
+ * Utility type to expand a type's properties for better type inference and hover display.
3
+ * @template T - The type to expand.
4
+ */
1
5
  export type ExpandProps<T> = T extends infer O ? {
2
6
  [K in keyof O]: O[K];
3
7
  } : never;
8
+ /**
9
+ * Enumeration of primitive field types supported by the schema system.
10
+ * Used for type-safe field declarations in collection templates.
11
+ */
4
12
  export declare enum enumPrimitive {
5
13
  id = "id",
6
14
  any = "any",
7
15
  date = "date",
8
16
  text = "text",
9
- number = "number",// IdbqModelCollectionTemplate
17
+ number = "number",
10
18
  boolean = "boolean",
11
19
  datetime = "datetime",
12
20
  url = "url",
@@ -15,24 +23,84 @@ export declare enum enumPrimitive {
15
23
  time = "time",
16
24
  password = "password"
17
25
  }
26
+ /**
27
+ * Enumeration of special field properties for schema fields.
28
+ * - private: Field is internal and not exposed externally.
29
+ * - readonly: Field cannot be modified after creation.
30
+ * - required: Field must be present in the data model.
31
+ */
18
32
  export declare enum TplProperties {
19
33
  private = "private",
20
34
  readonly = "readonly",
21
35
  required = "required"
22
36
  }
37
+ /**
38
+ * Recursively generates all possible space-separated combinations of a set of string literals.
39
+ * Used to create all valid combinations of field properties (e.g., 'private readonly', etc).
40
+ * @template T - The set of string literals to combine.
41
+ * @template U - The set of remaining string literals (for recursion).
42
+ */
23
43
  export type CombineElements<T extends string, U extends string = T> = T | (T extends any ? `${T} ${CombineElements<Exclude<U, T>>}` : never);
24
- export type CombinedArgs = CombineElements<TplProperties>;
44
+ /**
45
+ * Utility type to force TypeScript to expand a union or intersection for better hover display.
46
+ * @template T - The type to expand.
47
+ */
48
+ type Expand<T> = T extends infer O ? {
49
+ [K in keyof O]: O[K];
50
+ } : never;
51
+ /**
52
+ * All valid combinations of TplProperties, including single and multi-property combinations.
53
+ * Used for field argument validation and schema typing.
54
+ */
55
+ export type CombinedArgs = Expand<keyof typeof TplProperties | CombineElements<keyof typeof TplProperties>>;
56
+ /**
57
+ * Utility type to represent array or object wrappers for a given primitive type string.
58
+ * E.g., 'array-of-text', 'object-number'.
59
+ * @template T - The base type string.
60
+ */
25
61
  export type IdbObjectify<T extends string> = `array-of-${T}` | `object-${T}`;
62
+ /**
63
+ * Represents the fields of a collection template as a mapping from field name to type string.
64
+ */
26
65
  export type TplCollectionFields = Record<string, string>;
66
+ /**
67
+ * Represents all valid primitive field type strings for a collection field.
68
+ * Includes enumPrimitive keys, text variants, dot-paths, and foreign key references.
69
+ * @template T - (Unused, for future extension)
70
+ */
27
71
  export type TplFieldPrimitive<T = {}> = keyof typeof enumPrimitive | `text-${'tiny' | 'short' | 'medium' | 'long' | 'area'}` | `${string}.${string}` | `fk-${string}.${string}`;
72
+ /**
73
+ * Represents object or array wrappers for primitive field types.
74
+ */
28
75
  export type TplObjectFieldPrimitive = IdbObjectify<TplFieldPrimitive>;
76
+ /**
77
+ * Represents a foreign key field type string (e.g., 'fk-users.id').
78
+ */
29
79
  export type TplFieldFk = `fk-${string}.${string}`;
80
+ /**
81
+ * Represents object or array wrappers for foreign key field types.
82
+ */
30
83
  export type TplFkObject = IdbObjectify<TplFieldFk>;
84
+ /**
85
+ * Union of all valid field type strings for a collection field, including primitives, objects, and foreign keys.
86
+ */
31
87
  export type TplTypes = TplFieldPrimitive | TplObjectFieldPrimitive | TplFieldFk | TplFkObject;
88
+ /**
89
+ * Represents a field type string with property arguments, e.g., 'text (readonly required)'.
90
+ */
32
91
  export type TplFieldArgs = `${TplTypes} (${CombinedArgs})`;
33
- /** rules */
92
+ /**
93
+ * Represents the allowed rules for a field: either a type string or a type string with arguments.
94
+ */
34
95
  export type TplFieldRules = TplFieldArgs | TplTypes;
96
+ /**
97
+ * Alias for TplFieldRules, used for clarity in some contexts.
98
+ */
35
99
  export type TplFieldType = TplFieldArgs | TplTypes;
100
+ /**
101
+ * Helper type for schema/field construction utilities.
102
+ * Used internally for dynamic schema building and validation.
103
+ */
36
104
  export type IDbForge = {
37
105
  collection?: TplCollectionName;
38
106
  fieldName?: keyof TplFields;
@@ -41,23 +109,65 @@ export type IDbForge = {
41
109
  fieldArgs?: [keyof typeof TplProperties] | undefined;
42
110
  is: any;
43
111
  };
112
+ /**
113
+ * Main model type for describing the schema of an IndexedDB database.
114
+ * Maps collection names to their CollectionModel definitions.
115
+ * @template T - The shape of the collections in the database.
116
+ */
44
117
  export type IdbqModel<T = Record<string, Record<string, any>>> = {
45
118
  readonly [K in keyof T]: CollectionModel<T[K]>;
46
119
  };
120
+ /**
121
+ * Type alias for a collection name in the schema model.
122
+ */
47
123
  export type TplCollectionName<T = TplCollectionFields> = keyof IdbqModel<T>;
124
+ /**
125
+ * Type alias for the template property of a CollectionModel.
126
+ */
48
127
  export type Tpl<T = TplCollectionFields> = CollectionModel<T>['template'];
128
+ /**
129
+ * Type alias for the fields property of a CollectionModel's template.
130
+ */
49
131
  export type TplFields<T = TplCollectionFields> = CollectionModel<T>['template']['fields'];
132
+ /**
133
+ * Describes the structure and metadata for a single collection in the database schema.
134
+ * Includes keyPath, TypeScript type, and template (fields, indexes, FKs, etc).
135
+ * @template T - The shape of the collection's fields.
136
+ */
50
137
  export type CollectionModel<T = TplCollectionFields> = {
138
+ /**
139
+ * The key path (primary key) for the collection in IndexedDB.
140
+ */
51
141
  keyPath: string | any;
52
- /** @deprecated use ts instead */
142
+ /**
143
+ * @deprecated Use 'ts' instead for type safety.
144
+ */
53
145
  model: any;
146
+ /**
147
+ * The TypeScript type representing the collection's data shape.
148
+ */
54
149
  ts: any;
150
+ /**
151
+ * Template metadata for the collection: fields, indexes, presentation, and foreign keys.
152
+ */
55
153
  template: {
154
+ /**
155
+ * The main index field for the collection.
156
+ */
56
157
  index: string;
158
+ /**
159
+ * Presentation string for UI or display purposes (combination of field names).
160
+ */
57
161
  presentation: CombineElements<Extract<keyof CollectionModel<T>['ts'], string>>;
162
+ /**
163
+ * Field definitions for the collection.
164
+ */
58
165
  fields: {
59
166
  [K in keyof T]: TplFieldRules;
60
167
  };
168
+ /**
169
+ * Foreign key definitions for the collection.
170
+ */
61
171
  fks: {
62
172
  [K in TplCollectionName]?: {
63
173
  code: K;
@@ -67,3 +177,4 @@ export type CollectionModel<T = TplCollectionFields> = {
67
177
  };
68
178
  };
69
179
  };
180
+ export {};
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Enumeration of primitive field types supported by the schema system.
3
+ * Used for type-safe field declarations in collection templates.
4
+ */
1
5
  export var enumPrimitive;
2
6
  (function (enumPrimitive) {
3
7
  enumPrimitive["id"] = "id";
@@ -13,6 +17,12 @@ export var enumPrimitive;
13
17
  enumPrimitive["time"] = "time";
14
18
  enumPrimitive["password"] = "password";
15
19
  })(enumPrimitive || (enumPrimitive = {}));
20
+ /**
21
+ * Enumeration of special field properties for schema fields.
22
+ * - private: Field is internal and not exposed externally.
23
+ * - readonly: Field cannot be modified after creation.
24
+ * - required: Field must be present in the data model.
25
+ */
16
26
  export var TplProperties;
17
27
  (function (TplProperties) {
18
28
  TplProperties["private"] = "private";
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export * from './state/idbstate.svelte.js';
2
2
  export * from './state/idbqlEvent.svelte.js';
3
3
  export * from './scripts/types.js';
4
- export * from './path/pathResolver.js';
5
4
  export * from './idbqlCore/types.js';
6
5
  export * from './idbqlCore/idbqlSchema.js';
7
6
  export * from './idbqlCore/idbqlCore.js';
7
+ export * from './path/pathResolver.js';
8
8
  export * from './collection/collection.svelte.js';
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  export * from './state/idbstate.svelte.js';
3
3
  export * from './state/idbqlEvent.svelte.js';
4
4
  export * from './scripts/types.js';
5
- export * from './path/pathResolver.js';
6
5
  export * from './idbqlCore/types.js';
7
6
  export * from './idbqlCore/idbqlSchema.js';
8
7
  export * from './idbqlCore/idbqlCore.js';
8
+ export * from './path/pathResolver.js';
9
9
  export * from './collection/collection.svelte.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@medyll/idae-idbql",
3
3
  "scope": "@medyll",
4
- "version": "0.177.0",
4
+ "version": "0.178.0",
5
5
  "description": "A powerful and flexible IndexedDB query library for TypeScript and JavaScript applications, offering a MongoDB-like query interface, strong TypeScript support, reactive state management, and easy integration with front-end frameworks like Svelte.",
6
6
  "exports": {
7
7
  ".": {
@@ -31,7 +31,7 @@
31
31
  "typescript": "^5.8.3",
32
32
  "vite": "^6.3.2",
33
33
  "@medyll/idae-prettier-config": "1.2.1",
34
- "@medyll/idae-query": "0.178.0"
34
+ "@medyll/idae-query": "0.179.0"
35
35
  },
36
36
  "svelte": "./dist/index.js",
37
37
  "types": "./dist/index.d.ts",