@arcote.tech/arc 0.0.22 → 0.0.23
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.
|
@@ -3,6 +3,7 @@ import type { ArcIdAny } from "../elements/id";
|
|
|
3
3
|
import { type ArcObjectAny } from "../elements/object";
|
|
4
4
|
import { objectUtil, type DeepPartial, type util } from "../utils";
|
|
5
5
|
import type { DataStorage } from "../data-storage";
|
|
6
|
+
import type { IndexQueryArgument } from "../db";
|
|
6
7
|
import { ArcAllItemsQueryBuilder } from "./query-builders/all-items";
|
|
7
8
|
import { ArcIndexedItemsQueryBuilder } from "./query-builders/indexed";
|
|
8
9
|
import { ArcOneItemQueryBuilder } from "./query-builders/one-item";
|
|
@@ -27,6 +28,11 @@ type CollectionCommandContext<Id extends ArcIdAny, Schema extends ArcObjectAny>
|
|
|
27
28
|
edit: (id: util.GetType<Id>, editCallback: (item: Deserialize<Id, Schema>) => Promise<void> | void) => Promise<void>;
|
|
28
29
|
modify: (id: util.GetType<Id>, data: objectUtil.addQuestionMarks<DeepPartial<util.FirstArgument<Schema["serialize"]>>>) => Promise<any>;
|
|
29
30
|
};
|
|
31
|
+
type IndexValue<Schema extends ArcObjectAny, Indexes extends keyof ReturnType<Schema["deserialize"]>, I extends {
|
|
32
|
+
[name: string]: Indexes[];
|
|
33
|
+
}, func extends keyof I> = {
|
|
34
|
+
[Key in I[func][number]]: util.GetType<Schema>[Key];
|
|
35
|
+
};
|
|
30
36
|
export declare class ArcCollection<Name extends string, Id extends ArcIdAny, Schema extends ArcObjectAny> extends ArcContextElement<{
|
|
31
37
|
type: "delete";
|
|
32
38
|
from: CollectionItem<ArcCollection<Name, Id, Schema>>;
|
|
@@ -68,14 +74,10 @@ export declare class ArcIndexedCollection<Name extends string, Id extends ArcIdA
|
|
|
68
74
|
readonly indexes: I;
|
|
69
75
|
constructor(name: Name, id: Id, schema: Schema, options: ArcCollectionOptions<Id, Schema>, indexes: I);
|
|
70
76
|
commandContext(dataStorage: DataStorage, publishEvent: (event: this["$event"]) => Promise<void>): CollectionCommandContext<Id, Schema> & {
|
|
71
|
-
[func in keyof I]: (args:
|
|
72
|
-
[Key in I[func][number]]: util.GetType<Schema>[Key];
|
|
73
|
-
}) => Deserialize<Id, Schema>[];
|
|
77
|
+
[func in keyof I]: (args: IndexValue<Schema, Indexes, I, func>) => Deserialize<Id, Schema>[];
|
|
74
78
|
};
|
|
75
79
|
queryBuilder(): CollectionQueryBuilder<ArcCollection<Name, Id, Schema>> & {
|
|
76
|
-
[func in keyof I]: (args:
|
|
77
|
-
[Key in I[func][number]]: util.GetType<Schema>[Key];
|
|
78
|
-
}) => ArcIndexedItemsQueryBuilder<ArcIndexedCollection<Name, Id, Schema, Indexes, I>>;
|
|
80
|
+
[func in keyof I]: (args: objectUtil.simplify<IndexQueryArgument<objectUtil.simplify<IndexValue<Schema, Indexes, I, func>>>>) => ArcIndexedItemsQueryBuilder<ArcIndexedCollection<Name, Id, Schema, Indexes, I>>;
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
83
|
export type ArcCollectionAny = ArcCollection<any, any, any>;
|
package/dist/db/interface.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import type { ArcContextAny } from "../context";
|
|
2
|
+
export type IndexQueryArgument<T> = T | ({
|
|
3
|
+
$gt?: T;
|
|
4
|
+
$gte?: T;
|
|
5
|
+
$lt?: T;
|
|
6
|
+
$lte?: T;
|
|
7
|
+
} & ({
|
|
8
|
+
$gt: T;
|
|
9
|
+
} | {
|
|
10
|
+
$gte: T;
|
|
11
|
+
} | {
|
|
12
|
+
$lt: T;
|
|
13
|
+
} | {
|
|
14
|
+
$lte: T;
|
|
15
|
+
}));
|
|
2
16
|
export interface ReadTransaction {
|
|
3
17
|
findById(store: string, id: any): Promise<any | undefined>;
|
|
4
|
-
findByIndex(store: string, index: string, data: any): Promise<any[]>;
|
|
18
|
+
findByIndex(store: string, index: string, data: IndexQueryArgument<any>): Promise<any[]>;
|
|
5
19
|
findAll(store: string): Promise<any[]>;
|
|
6
20
|
}
|
|
7
21
|
export interface ReadWriteTransaction extends ReadTransaction {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.23",
|
|
8
8
|
"private": false,
|
|
9
9
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
10
10
|
"description": "Arc is a framework designed to align code closely with business logic, streamlining development and enhancing productivity.",
|