@arcote.tech/arc 0.1.0 → 0.1.3
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/collection/collection.d.ts +12 -1
- package/dist/command/command.d.ts +11 -11
- package/dist/context/context.d.ts +7 -7
- package/dist/context/element.d.ts +26 -5
- package/dist/context/event.d.ts +12 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/simple-query.d.ts +33 -0
- package/dist/data-storage/data-storage-builder.d.ts +16 -0
- package/dist/data-storage/index.d.ts +2 -0
- package/dist/data-storage/query-processor.d.ts +22 -0
- package/dist/data-storage/store-state-authorized.d.ts +26 -0
- package/dist/db/sqliteAdapter.d.ts +3 -1
- package/dist/elements/blob.d.ts +79 -0
- package/dist/elements/boolean.d.ts +13 -2
- package/dist/elements/date.d.ts +1 -1
- package/dist/elements/file.d.ts +139 -0
- package/dist/elements/index.d.ts +3 -0
- package/dist/elements/object.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1098 -197
- package/dist/listener/index.d.ts +2 -0
- package/dist/listener/listener.d.ts +23 -0
- package/dist/model/model.d.ts +37 -16
- package/dist/tests/utils/test-model.d.ts +0 -1
- package/dist/view/index.d.ts +4 -0
- package/dist/view/queries/abstract-view-query.d.ts +20 -0
- package/dist/view/queries/find-one.d.ts +18 -0
- package/dist/view/queries/find.d.ts +20 -0
- package/dist/view/queries/index.d.ts +3 -0
- package/dist/view/query-builders/find-one.d.ts +13 -0
- package/dist/view/query-builders/find.d.ts +13 -0
- package/dist/view/query-builders/index.d.ts +2 -0
- package/dist/view/view.d.ts +24 -13
- package/package.json +11 -4
- package/dist/db/index-query.d.ts +0 -3
- package/dist/dist/index.d.ts +0 -513
- package/dist/elements/tests/example.d.ts +0 -6
- package/dist/elements/tests/test.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArcContextElementWithStore, type StoreSchema } from "../context/element";
|
|
1
|
+
import { ArcContextElementWithStore, type AuthContext, type AuthorizationRestrictions, type StoreSchema } from "../context/element";
|
|
2
2
|
import { type ArcIdAny } from "../elements/id";
|
|
3
3
|
import { type ArcObjectAny } from "../elements/object";
|
|
4
4
|
import { type $type, type DeepPartial, type objectUtil, type util } from "../utils";
|
|
@@ -32,8 +32,19 @@ export declare class ArcCollection<Name extends string, Id extends ArcIdAny, Sch
|
|
|
32
32
|
readonly id: Id;
|
|
33
33
|
readonly schema: Schema;
|
|
34
34
|
readonly options: ArcCollectionOptions<Id, Schema>;
|
|
35
|
+
private _restrictions?;
|
|
35
36
|
constructor(name: Name, id: Id, schema: Schema, options: ArcCollectionOptions<Id, Schema>);
|
|
36
37
|
storeSchema(): StoreSchema;
|
|
38
|
+
/**
|
|
39
|
+
* Default restrictions for collections - deny all by default
|
|
40
|
+
* Use the auth() method to define custom authorization logic
|
|
41
|
+
*/
|
|
42
|
+
restrictions(authContext: AuthContext): AuthorizationRestrictions;
|
|
43
|
+
/**
|
|
44
|
+
* Define custom authorization restrictions for this collection
|
|
45
|
+
* @param restrictionsFn - Function that takes auth context and returns restrictions
|
|
46
|
+
*/
|
|
47
|
+
auth(restrictionsFn: (authContext: AuthContext) => AuthorizationRestrictions): ArcCollection<Name, Id, Schema>;
|
|
37
48
|
serialize(data: objectUtil.simplify<{
|
|
38
49
|
_id: util.FirstArgument<Id["serialize"]>;
|
|
39
50
|
} & objectUtil.addQuestionMarks<util.FirstArgument<Schema["serialize"]>>>): objectUtil.simplify<{
|
|
@@ -2,28 +2,28 @@ import type { ArcCommandContext } from "../context";
|
|
|
2
2
|
import { ArcContextElement, type ArcContextElementAny } from "../context/element";
|
|
3
3
|
import { ArcObject, type ArcObjectAny, type ArcRawShape } from "../elements";
|
|
4
4
|
import type { $type } from "../utils";
|
|
5
|
-
export type ArcCommmandHandler<ContextElements extends ArcContextElementAny[], Params extends ArcObjectAny | null,
|
|
6
|
-
export declare class ArcCommand<Name extends string, Params extends ArcObjectAny | null,
|
|
5
|
+
export type ArcCommmandHandler<ContextElements extends ArcContextElementAny[], Params extends ArcObjectAny | null, Results extends ArcObjectAny[]> = (ctx: ArcCommandContext<ContextElements>, params: Params extends ArcObjectAny ? $type<Params> : null) => Promise<$type<Results[number]>> | $type<Results[number]>;
|
|
6
|
+
export declare class ArcCommand<Name extends string, Params extends ArcObjectAny | null, Results extends ArcObjectAny[], const Elements extends ArcContextElementAny[]> extends ArcContextElement<{
|
|
7
7
|
type: "execute";
|
|
8
8
|
params: Params;
|
|
9
|
-
result:
|
|
9
|
+
result: Results[number];
|
|
10
10
|
}, Name> {
|
|
11
11
|
readonly name: Name;
|
|
12
12
|
private _description?;
|
|
13
13
|
private _params?;
|
|
14
|
-
private
|
|
14
|
+
private _results?;
|
|
15
15
|
private _elements?;
|
|
16
16
|
private _handler?;
|
|
17
17
|
constructor(name: Name);
|
|
18
|
-
use<const E extends ArcContextElementAny[]>(elements: E): ArcCommand<Name, Params,
|
|
19
|
-
description(description: string): ArcCommand<Name, Params,
|
|
20
|
-
withParams<NewParams extends ArcRawShape>(schema: NewParams | ArcObject<NewParams>): ArcCommand<Name, ArcObject<NewParams>,
|
|
21
|
-
withResult<
|
|
22
|
-
handle(handler: ArcCommmandHandler<Elements, Params,
|
|
23
|
-
commandClient: (ctx: any) => (Params extends ArcObjectAny ? (params: $type<Params>) => Promise<$type<
|
|
18
|
+
use<const E extends ArcContextElementAny[]>(elements: E): ArcCommand<Name, Params, Results, E>;
|
|
19
|
+
description(description: string): ArcCommand<Name, Params, Results, Elements>;
|
|
20
|
+
withParams<NewParams extends ArcRawShape>(schema: NewParams | ArcObject<NewParams>): ArcCommand<Name, ArcObject<NewParams>, Results, Elements>;
|
|
21
|
+
withResult<NewResults extends ArcRawShape[]>(...schemas: NewResults): ArcCommand<Name, Params, { [K in keyof NewResults]: ArcObject<NewResults[K]>; }, Elements>;
|
|
22
|
+
handle(handler: ArcCommmandHandler<Elements, Params, Results> | false): ArcCommand<Name, Params, Results, Elements>;
|
|
23
|
+
commandClient: (ctx: any) => (Params extends ArcObjectAny ? (params: $type<Params>) => Promise<$type<Results[number]>> : () => Promise<$type<Results[number]>>) & {
|
|
24
24
|
params: Params;
|
|
25
25
|
};
|
|
26
26
|
private clone;
|
|
27
27
|
}
|
|
28
|
-
export declare function command<Name extends string>(name: Name): ArcCommand<Name, null, any, any[]>;
|
|
28
|
+
export declare function command<Name extends string>(name: Name): ArcCommand<Name, null, any[], any[]>;
|
|
29
29
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import type { DataStorage } from "../data-storage";
|
|
2
2
|
import type { objectUtil } from "../utils";
|
|
3
3
|
import type { CommandContext } from "./commands";
|
|
4
|
-
import type { ArcContextElement, ArcContextElementAny } from "./element";
|
|
4
|
+
import type { ArcContextElement, ArcContextElementAny, AuthContext, EventListener, PublishEventFunction } from "./element";
|
|
5
5
|
import type { QueryBuilderContext } from "./query-builder-context";
|
|
6
6
|
type Filter<T extends any[], Method extends keyof T[number]> = T extends [
|
|
7
7
|
infer First,
|
|
8
8
|
...infer Rest
|
|
9
9
|
] ? First[Method] extends (...args: any) => any ? [First, ...Filter<Rest, Method>] : Filter<Rest, Method> : [];
|
|
10
10
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
11
|
-
type ArcContextElementMethodReturnType<Elements extends ArcContextElementAny[], Method extends keyof Elements[number]> = UnionToIntersection<{
|
|
11
|
+
export type ArcContextElementMethodReturnType<Elements extends ArcContextElementAny[], Method extends keyof Elements[number]> = UnionToIntersection<{
|
|
12
12
|
[Element in Filter<Elements, Method>[number] as number]: {
|
|
13
13
|
[ElementName in Element["name"]]: Element[Method] extends (...args: any) => any ? ReturnType<Element[Method]> : undefined;
|
|
14
14
|
};
|
|
15
15
|
}[number]>;
|
|
16
16
|
export type ArcCommandContext<E extends ArcContextElementAny[]> = ArcContextElementMethodReturnType<E, "commandContext"> & {
|
|
17
|
-
$
|
|
17
|
+
$auth: AuthContext;
|
|
18
18
|
};
|
|
19
19
|
export type RemoveFalseAndResolvedPromiseFromArray<T extends any[]> = T extends [infer First, ...infer Rest] ? First extends false ? RemoveFalseAndResolvedPromiseFromArray<Rest> : First extends Promise<{
|
|
20
20
|
default: infer Inner;
|
|
21
21
|
}> ? RemoveFalseAndResolvedPromiseFromArray<[Inner, ...Rest]> : [First, ...RemoveFalseAndResolvedPromiseFromArray<Rest>] : [];
|
|
22
22
|
export declare class ArcContext<const E extends ArcContextElementAny[]> {
|
|
23
23
|
readonly elements: E;
|
|
24
|
-
private eventListeners;
|
|
25
24
|
constructor(elements: E);
|
|
25
|
+
getSyncListeners(eventType: string, authContext: AuthContext): EventListener<any>[];
|
|
26
|
+
getAsyncListeners(eventType: string, authContext: AuthContext): EventListener<any>[];
|
|
26
27
|
pipe<const NewElements extends (ArcContextElementAny | false | Promise<{
|
|
27
28
|
default: ArcContextElementAny;
|
|
28
29
|
}>)[]>(newElements: NewElements): ArcContext<[
|
|
29
30
|
...E,
|
|
30
31
|
...RemoveFalseAndResolvedPromiseFromArray<NewElements>
|
|
31
32
|
]>;
|
|
32
|
-
queryBuilder(queryContext: QueryBuilderContext): ArcContextElementMethodReturnType<E, "queryBuilder">;
|
|
33
|
-
commandContext(
|
|
34
|
-
commandsClient(client: string, queryContext: QueryBuilderContext, dataStorage: DataStorage, catchErrorCallback: (error: any) => void): ArcContextElementMethodReturnType<E, "commandClient">;
|
|
33
|
+
queryBuilder(queryContext: QueryBuilderContext, authContext: AuthContext): ArcContextElementMethodReturnType<E, "queryBuilder">;
|
|
34
|
+
commandContext(dataStorage: DataStorage, publishEvent: PublishEventFunction, authContext: AuthContext): ArcCommandContext<E>;
|
|
35
35
|
}
|
|
36
36
|
export type ArcContextAny = ArcContext<ArcContextElementAny[]>;
|
|
37
37
|
export type ElementEvents<Element extends ArcContextElementAny> = Element extends ArcContextElement<any> ? Element["$event"] : never;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { DataStorage } from "../data-storage";
|
|
2
|
+
import type { WhereCondition } from "../data-storage/types";
|
|
2
3
|
import type { QueryBuilderContext } from "./query-builder-context";
|
|
3
|
-
export type EventListener<Event> = (event: Event, dataStorage: DataStorage) => Promise<void>;
|
|
4
|
+
export type EventListener<Event> = (event: Event, dataStorage: DataStorage, publishEvent: PublishEventFunction) => Promise<void>;
|
|
5
|
+
export type PublishEventFunction = (event: any) => Promise<void>;
|
|
6
|
+
export type ListenerConfig = {
|
|
7
|
+
handler: EventListener<any>;
|
|
8
|
+
isAsync: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface AuthContext {
|
|
11
|
+
userId: string;
|
|
12
|
+
roles: string[];
|
|
13
|
+
}
|
|
14
|
+
export type AuthorizationRestrictions = {
|
|
15
|
+
default?: WhereCondition;
|
|
16
|
+
read?: boolean | WhereCondition;
|
|
17
|
+
write?: boolean | WhereCondition;
|
|
18
|
+
modify?: boolean | WhereCondition;
|
|
19
|
+
delete?: boolean | WhereCondition;
|
|
20
|
+
};
|
|
21
|
+
export type EventAuthorizationRestrictions = {
|
|
22
|
+
read?: boolean | WhereCondition;
|
|
23
|
+
write?: boolean | WhereCondition;
|
|
24
|
+
};
|
|
4
25
|
export type StoreColumn = {
|
|
5
26
|
name: string;
|
|
6
27
|
type: string;
|
|
@@ -28,10 +49,10 @@ export type StoreSchema = {
|
|
|
28
49
|
export declare abstract class ArcContextElement<const Event, const Name extends string | undefined = undefined> {
|
|
29
50
|
readonly $event: Event;
|
|
30
51
|
readonly name?: Name;
|
|
31
|
-
queryBuilder?(queryContext: QueryBuilderContext): any;
|
|
32
|
-
commandContext?: (dataStorage: DataStorage, publishEvent:
|
|
33
|
-
commandClient?: (commandContext: any) => (...args: any[]) => any;
|
|
34
|
-
observer?: () => Record<string,
|
|
52
|
+
queryBuilder?(queryContext: QueryBuilderContext, authContext: AuthContext): any;
|
|
53
|
+
commandContext?: (dataStorage: DataStorage, publishEvent: PublishEventFunction, authContext: AuthContext) => any;
|
|
54
|
+
commandClient?: (commandContext: any, authContext: AuthContext) => (...args: any[]) => any;
|
|
55
|
+
observer?: (authContext: AuthContext) => Record<string, ListenerConfig>;
|
|
35
56
|
}
|
|
36
57
|
export declare abstract class ArcContextElementWithStore<const Event, const Name extends string | undefined = undefined> extends ArcContextElement<Event, Name> {
|
|
37
58
|
abstract storeSchema(): StoreSchema;
|
package/dist/context/event.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataStorage } from "../data-storage";
|
|
2
2
|
import { ArcObject, type ArcObjectAny, type ArcRawShape } from "../elements/object";
|
|
3
3
|
import type { $type } from "../utils";
|
|
4
|
-
import { ArcContextElementWithStore, type StoreSchema } from "./element";
|
|
4
|
+
import { ArcContextElementWithStore, type AuthContext, type AuthorizationRestrictions, type EventAuthorizationRestrictions, type StoreSchema } from "./element";
|
|
5
5
|
export type EventMetadata = {
|
|
6
6
|
occurredAt: string;
|
|
7
7
|
createdBy?: {
|
|
@@ -15,8 +15,19 @@ export type EventMetadata = {
|
|
|
15
15
|
export declare class ArcEvent<const Name extends string, const PayloadShape extends ArcObjectAny | undefined> extends ArcContextElementWithStore<ArcEventInstance<ArcEvent<Name, PayloadShape>>, Name> {
|
|
16
16
|
readonly name: Name;
|
|
17
17
|
readonly payload: PayloadShape;
|
|
18
|
+
private _restrictions?;
|
|
18
19
|
storeSchema: () => StoreSchema;
|
|
19
20
|
constructor(name: Name, payload: PayloadShape);
|
|
21
|
+
/**
|
|
22
|
+
* Default restrictions for events - deny all operations except for system users
|
|
23
|
+
* Override using the auth() method to customize authorization
|
|
24
|
+
*/
|
|
25
|
+
restrictions(authContext: AuthContext): AuthorizationRestrictions;
|
|
26
|
+
/**
|
|
27
|
+
* Define custom authorization restrictions for this event (read and write only)
|
|
28
|
+
* @param restrictionsFn - Function that takes auth context and returns read/write restrictions
|
|
29
|
+
*/
|
|
30
|
+
auth(restrictionsFn: (authContext: AuthContext) => EventAuthorizationRestrictions): ArcEvent<Name, PayloadShape>;
|
|
20
31
|
commandContext: (dataStorage: DataStorage, publishEvent: (event: ArcEventInstance<ArcEvent<Name, PayloadShape>>) => Promise<void>) => {
|
|
21
32
|
emit: (payload: PayloadShape extends ArcObjectAny ? $type<PayloadShape> : undefined) => Promise<void>;
|
|
22
33
|
};
|
package/dist/context/index.d.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DataStorage } from "../data-storage";
|
|
2
|
+
import type { FindOptions } from "../data-storage/types";
|
|
3
|
+
export type QueryFunction<T> = (dataStorage: DataStorage) => (options: FindOptions<T>) => Promise<T[]>;
|
|
4
|
+
export type QueryFunctionOne<T> = (dataStorage: DataStorage) => (options: FindOptions<T>) => Promise<T | undefined>;
|
|
5
|
+
export type SimpleQueryListener<Result> = (result: Result) => void;
|
|
6
|
+
export declare class SimpleQueryResult<T> {
|
|
7
|
+
private data;
|
|
8
|
+
constructor(data: T);
|
|
9
|
+
get(): T;
|
|
10
|
+
exists(): boolean;
|
|
11
|
+
toArray(): (T & any[]) | never[];
|
|
12
|
+
map<U>(callbackfn: (value: any, index: number, array: any[]) => U): U[];
|
|
13
|
+
}
|
|
14
|
+
export declare class SimpleQuery<T> {
|
|
15
|
+
private queryFn;
|
|
16
|
+
private options;
|
|
17
|
+
private storeName;
|
|
18
|
+
private listeners;
|
|
19
|
+
private lastResult;
|
|
20
|
+
private resultIds;
|
|
21
|
+
constructor(queryFn: QueryFunction<T> | QueryFunctionOne<T>, options: FindOptions<T>, storeName: string);
|
|
22
|
+
run(dataStorage: DataStorage): Promise<SimpleQueryResult<T>>;
|
|
23
|
+
private updateResultIds;
|
|
24
|
+
getResultIds(): Set<string>;
|
|
25
|
+
getOptions(): FindOptions<T>;
|
|
26
|
+
getStoreName(): string;
|
|
27
|
+
subscribe(listener: SimpleQueryListener<SimpleQueryResult<T>>): void;
|
|
28
|
+
unsubscribe(listener: SimpleQueryListener<SimpleQueryResult<T>>): void;
|
|
29
|
+
updateResult(newResult: SimpleQueryResult<T>): void;
|
|
30
|
+
getLastResult(): SimpleQueryResult<T>;
|
|
31
|
+
getCacheKey(): string;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=simple-query.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArcContextAny } from "../context";
|
|
2
|
+
import type { AuthContext } from "../context/element";
|
|
3
|
+
import type { DatabaseAdapter } from "../db";
|
|
4
|
+
import type { RealTimeCommunicationAdapterFactory } from "../rtc/rtc";
|
|
5
|
+
import type { DataStorage } from "./data-storage.abstract";
|
|
6
|
+
export declare class DataStorageBuilder {
|
|
7
|
+
private dbAdapter;
|
|
8
|
+
private rtcAdapterFactory;
|
|
9
|
+
private arcContext;
|
|
10
|
+
constructor(dbAdapter: Promise<DatabaseAdapter> | DatabaseAdapter, rtcAdapterFactory: RealTimeCommunicationAdapterFactory, arcContext: ArcContextAny);
|
|
11
|
+
/**
|
|
12
|
+
* Create a DataStorage instance
|
|
13
|
+
*/
|
|
14
|
+
build(authContext: AuthContext): DataStorage;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=data-storage-builder.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from "./data-storage-forked";
|
|
2
2
|
export * from "./data-storage-master";
|
|
3
3
|
export * from "./data-storage.abstract";
|
|
4
|
+
export * from "./deep-merge";
|
|
4
5
|
export * from "./store-state-fork";
|
|
5
6
|
export * from "./store-state-master";
|
|
6
7
|
export * from "./store-state.abstract";
|
|
8
|
+
export type * from "./types";
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SimpleQuery } from "../context/simple-query";
|
|
2
|
+
import type { ListenerEvent } from "./data-storage.abstract";
|
|
3
|
+
import type { FindOptions } from "./types";
|
|
4
|
+
export type QueryRerunCallback = <T>(query: SimpleQuery<T>) => Promise<void>;
|
|
5
|
+
export declare class QueryProcessor {
|
|
6
|
+
private activeQueries;
|
|
7
|
+
private rerunCallback?;
|
|
8
|
+
setRerunCallback(callback: QueryRerunCallback): void;
|
|
9
|
+
registerQuery<T>(query: SimpleQuery<T>): void;
|
|
10
|
+
unregisterQuery<T>(query: SimpleQuery<T>): void;
|
|
11
|
+
processStoreChange<T extends {
|
|
12
|
+
_id: string;
|
|
13
|
+
}>(storeName: string, event: ListenerEvent<T>): void;
|
|
14
|
+
private processQueryChange;
|
|
15
|
+
private rerunQuery;
|
|
16
|
+
/**
|
|
17
|
+
* Check if an item matches the query conditions
|
|
18
|
+
* This is the filtering logic moved from find.ts and find-one.ts
|
|
19
|
+
*/
|
|
20
|
+
checkItemMatchesQuery<T>(item: T, options: FindOptions<T>): boolean;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=query-processor.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ArcContextAny } from "../context";
|
|
2
|
+
import type { AuthContext } from "../context/element";
|
|
3
|
+
import type { DataStorage, QueryListenerCallback, StoreStateChange } from "./data-storage.abstract";
|
|
4
|
+
import { StoreState } from "./store-state.abstract";
|
|
5
|
+
import type { FindOptions } from "./types";
|
|
6
|
+
export declare class AuthorizedStoreState<Item extends {
|
|
7
|
+
_id: string;
|
|
8
|
+
}> extends StoreState<Item> {
|
|
9
|
+
private arcContext;
|
|
10
|
+
private authContext;
|
|
11
|
+
constructor(storeName: string, dataStorage: DataStorage, arcContext: ArcContextAny, authContext: AuthContext, deserialize?: (data: any) => Item);
|
|
12
|
+
private getElementRestrictions;
|
|
13
|
+
private checkOperationPermission;
|
|
14
|
+
private applyAuthorizationFilter;
|
|
15
|
+
find(options: FindOptions<Item>, listener?: QueryListenerCallback<Item>): Promise<Item[]>;
|
|
16
|
+
applyChange(change: StoreStateChange<Item>): Promise<{
|
|
17
|
+
from: Item | null;
|
|
18
|
+
to: Item | null;
|
|
19
|
+
}>;
|
|
20
|
+
applyChanges(changes: StoreStateChange<Item>[]): Promise<void>;
|
|
21
|
+
applySerializedChanges(changes: StoreStateChange<Item>[]): Promise<{
|
|
22
|
+
from: Item | null;
|
|
23
|
+
to: Item | null;
|
|
24
|
+
}[]>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=store-state-authorized.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ArcContextAny } from "../context";
|
|
2
|
-
import type { StoreTable } from "../context/element";
|
|
2
|
+
import type { StoreColumn, StoreTable } from "../context/element";
|
|
3
3
|
import type { FindOptions, WhereCondition } from "../data-storage/types";
|
|
4
4
|
import type { DatabaseAdapter, DBAdapterFactory, ReadTransaction, ReadWriteTransaction } from "./interface";
|
|
5
5
|
export interface SQLiteDatabase {
|
|
@@ -9,6 +9,8 @@ declare class SQLiteReadTransaction implements ReadTransaction {
|
|
|
9
9
|
protected db: SQLiteDatabase;
|
|
10
10
|
protected tables: Map<string, StoreTable>;
|
|
11
11
|
constructor(db: SQLiteDatabase, tables: Map<string, StoreTable>);
|
|
12
|
+
protected deserializeValue(value: any, column: StoreColumn): any;
|
|
13
|
+
protected deserializeRow(row: any, table: StoreTable): any;
|
|
12
14
|
protected getId(store: string, id: any): any;
|
|
13
15
|
protected buildWhereClause(where?: WhereCondition): {
|
|
14
16
|
sql: string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { CheckFn, GetValidator, Validators } from "./abstract";
|
|
2
|
+
import { ArcPrimitive } from "./abstract-primitive";
|
|
3
|
+
declare const blobValidator: {
|
|
4
|
+
readonly name: "blob";
|
|
5
|
+
readonly validator: (value: any) => {
|
|
6
|
+
currentType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
7
|
+
expectedType: string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare class ArcBlob<V extends Validators = [typeof blobValidator]> extends ArcPrimitive<V, Blob> {
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Validate that the blob has a specific MIME type
|
|
14
|
+
*/
|
|
15
|
+
type(mimeType: string): ArcBlob<[...V, {
|
|
16
|
+
name: "type";
|
|
17
|
+
validator: (value: any) => {
|
|
18
|
+
currentType: string;
|
|
19
|
+
expectedType: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}]>;
|
|
22
|
+
/**
|
|
23
|
+
* Validate that the blob has one of the specified MIME types
|
|
24
|
+
*/
|
|
25
|
+
types(mimeTypes: string[]): ArcBlob<[...V, {
|
|
26
|
+
name: "types";
|
|
27
|
+
validator: (value: any) => {
|
|
28
|
+
currentType: string;
|
|
29
|
+
expectedTypes: string[];
|
|
30
|
+
} | undefined;
|
|
31
|
+
}]>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate minimum blob size in bytes
|
|
34
|
+
*/
|
|
35
|
+
minSize(bytes: number): ArcBlob<[...V, {
|
|
36
|
+
name: "minSize";
|
|
37
|
+
validator: (value: any) => {
|
|
38
|
+
currentSize: number;
|
|
39
|
+
minSize: number;
|
|
40
|
+
} | undefined;
|
|
41
|
+
}]>;
|
|
42
|
+
/**
|
|
43
|
+
* Validate maximum blob size in bytes
|
|
44
|
+
*/
|
|
45
|
+
maxSize(bytes: number): ArcBlob<[...V, {
|
|
46
|
+
name: "maxSize";
|
|
47
|
+
validator: (value: any) => {
|
|
48
|
+
currentSize: number;
|
|
49
|
+
maxSize: number;
|
|
50
|
+
} | undefined;
|
|
51
|
+
}]>;
|
|
52
|
+
/**
|
|
53
|
+
* Validate exact blob size in bytes
|
|
54
|
+
*/
|
|
55
|
+
size(bytes: number): ArcBlob<[...V, {
|
|
56
|
+
name: "size";
|
|
57
|
+
validator: (value: any) => {
|
|
58
|
+
currentSize: number;
|
|
59
|
+
expectedSize: number;
|
|
60
|
+
} | undefined;
|
|
61
|
+
}]>;
|
|
62
|
+
validation<Name extends string, Fn extends CheckFn<any>>(name: Name, validator: Fn): ArcBlob<GetValidator<import("./abstract").ArcAbstract<[...V, {
|
|
63
|
+
name: Name;
|
|
64
|
+
validator: Fn;
|
|
65
|
+
}]>>>;
|
|
66
|
+
/**
|
|
67
|
+
* Override parse to validate blob objects
|
|
68
|
+
*/
|
|
69
|
+
parse(value: any): Blob;
|
|
70
|
+
}
|
|
71
|
+
export declare function blob(): ArcBlob<[{
|
|
72
|
+
readonly name: "blob";
|
|
73
|
+
readonly validator: (value: any) => {
|
|
74
|
+
currentType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
75
|
+
expectedType: string;
|
|
76
|
+
} | undefined;
|
|
77
|
+
}]>;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import type { CheckFn, GetValidator, Validators } from "./abstract";
|
|
1
2
|
import { ArcPrimitive } from "./abstract-primitive";
|
|
2
|
-
export declare class ArcBoolean extends ArcPrimitive<
|
|
3
|
+
export declare class ArcBoolean<V extends Validators> extends ArcPrimitive<V, boolean> {
|
|
4
|
+
hasToBeTrue(): ArcBoolean<[...V, {
|
|
5
|
+
name: "hasToBeTrue";
|
|
6
|
+
validator: (value: any[]) => {
|
|
7
|
+
current: never;
|
|
8
|
+
} | undefined;
|
|
9
|
+
}]>;
|
|
10
|
+
validation<Name extends string, Fn extends CheckFn<any>>(name: Name, validator: Fn): ArcBoolean<GetValidator<import("./abstract").ArcAbstract<[...V, {
|
|
11
|
+
name: Name;
|
|
12
|
+
validator: Fn;
|
|
13
|
+
}]>>>;
|
|
3
14
|
}
|
|
4
|
-
export declare function boolean(): ArcBoolean
|
|
15
|
+
export declare function boolean(): ArcBoolean<Validators>;
|
|
5
16
|
//# sourceMappingURL=boolean.d.ts.map
|
package/dist/elements/date.d.ts
CHANGED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { CheckFn, GetValidator, Validators } from "./abstract";
|
|
2
|
+
import { ArcPrimitive } from "./abstract-primitive";
|
|
3
|
+
declare const fileValidator: {
|
|
4
|
+
readonly name: "file";
|
|
5
|
+
readonly validator: (value: any) => {
|
|
6
|
+
currentType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
7
|
+
expectedType: string;
|
|
8
|
+
} | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare class ArcFile<V extends Validators = [typeof fileValidator]> extends ArcPrimitive<V, File> {
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Validate that the file has a specific MIME type
|
|
14
|
+
*/
|
|
15
|
+
type(mimeType: string): ArcFile<[...V, {
|
|
16
|
+
name: "type";
|
|
17
|
+
validator: (value: any) => {
|
|
18
|
+
currentType: string;
|
|
19
|
+
expectedType: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}]>;
|
|
22
|
+
/**
|
|
23
|
+
* Validate that the file has one of the specified MIME types
|
|
24
|
+
*/
|
|
25
|
+
types(mimeTypes: string[]): ArcFile<[...V, {
|
|
26
|
+
name: "types";
|
|
27
|
+
validator: (value: any) => {
|
|
28
|
+
currentType: string;
|
|
29
|
+
expectedTypes: string[];
|
|
30
|
+
} | undefined;
|
|
31
|
+
}]>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate minimum file size in bytes
|
|
34
|
+
*/
|
|
35
|
+
minSize(bytes: number): ArcFile<[...V, {
|
|
36
|
+
name: "minSize";
|
|
37
|
+
validator: (value: any) => {
|
|
38
|
+
currentSize: number;
|
|
39
|
+
minSize: number;
|
|
40
|
+
} | undefined;
|
|
41
|
+
}]>;
|
|
42
|
+
/**
|
|
43
|
+
* Validate maximum file size in bytes
|
|
44
|
+
*/
|
|
45
|
+
maxSize(bytes: number): ArcFile<[...V, {
|
|
46
|
+
name: "maxSize";
|
|
47
|
+
validator: (value: any) => {
|
|
48
|
+
currentSize: number;
|
|
49
|
+
maxSize: number;
|
|
50
|
+
} | undefined;
|
|
51
|
+
}]>;
|
|
52
|
+
/**
|
|
53
|
+
* Validate exact file size in bytes
|
|
54
|
+
*/
|
|
55
|
+
size(bytes: number): ArcFile<[...V, {
|
|
56
|
+
name: "size";
|
|
57
|
+
validator: (value: any) => {
|
|
58
|
+
currentSize: number;
|
|
59
|
+
expectedSize: number;
|
|
60
|
+
} | undefined;
|
|
61
|
+
}]>;
|
|
62
|
+
/**
|
|
63
|
+
* Validate the file name
|
|
64
|
+
*/
|
|
65
|
+
name(expectedName: string): ArcFile<[...V, {
|
|
66
|
+
name: "name";
|
|
67
|
+
validator: (value: any) => {
|
|
68
|
+
currentName: string;
|
|
69
|
+
expectedName: string;
|
|
70
|
+
} | undefined;
|
|
71
|
+
}]>;
|
|
72
|
+
/**
|
|
73
|
+
* Validate the file name matches a pattern
|
|
74
|
+
*/
|
|
75
|
+
namePattern(pattern: RegExp): ArcFile<[...V, {
|
|
76
|
+
name: "namePattern";
|
|
77
|
+
validator: (value: any) => {
|
|
78
|
+
currentName: string;
|
|
79
|
+
pattern: string;
|
|
80
|
+
} | undefined;
|
|
81
|
+
}]>;
|
|
82
|
+
/**
|
|
83
|
+
* Validate file extension
|
|
84
|
+
*/
|
|
85
|
+
extension(ext: string): ArcFile<[...V, {
|
|
86
|
+
name: "extension";
|
|
87
|
+
validator: (value: any) => {
|
|
88
|
+
currentExtension: string | undefined;
|
|
89
|
+
expectedExtension: string;
|
|
90
|
+
} | undefined;
|
|
91
|
+
}]>;
|
|
92
|
+
/**
|
|
93
|
+
* Validate file has one of the specified extensions
|
|
94
|
+
*/
|
|
95
|
+
extensions(exts: string[]): ArcFile<[...V, {
|
|
96
|
+
name: "extensions";
|
|
97
|
+
validator: (value: any) => {
|
|
98
|
+
currentExtension: string | undefined;
|
|
99
|
+
expectedExtensions: string[];
|
|
100
|
+
} | undefined;
|
|
101
|
+
}]>;
|
|
102
|
+
/**
|
|
103
|
+
* Validate the file's last modified date
|
|
104
|
+
*/
|
|
105
|
+
lastModifiedAfter(date: Date): ArcFile<[...V, {
|
|
106
|
+
name: "lastModifiedAfter";
|
|
107
|
+
validator: (value: any) => {
|
|
108
|
+
currentLastModified: Date;
|
|
109
|
+
expectedAfter: Date;
|
|
110
|
+
} | undefined;
|
|
111
|
+
}]>;
|
|
112
|
+
/**
|
|
113
|
+
* Validate the file's last modified date
|
|
114
|
+
*/
|
|
115
|
+
lastModifiedBefore(date: Date): ArcFile<[...V, {
|
|
116
|
+
name: "lastModifiedBefore";
|
|
117
|
+
validator: (value: any) => {
|
|
118
|
+
currentLastModified: Date;
|
|
119
|
+
expectedBefore: Date;
|
|
120
|
+
} | undefined;
|
|
121
|
+
}]>;
|
|
122
|
+
validation<Name extends string, Fn extends CheckFn<any>>(name: Name, validator: Fn): ArcFile<GetValidator<import("./abstract").ArcAbstract<[...V, {
|
|
123
|
+
name: Name;
|
|
124
|
+
validator: Fn;
|
|
125
|
+
}]>>>;
|
|
126
|
+
/**
|
|
127
|
+
* Override parse to validate file objects
|
|
128
|
+
*/
|
|
129
|
+
parse(value: any): File;
|
|
130
|
+
}
|
|
131
|
+
export declare function file(): ArcFile<[{
|
|
132
|
+
readonly name: "file";
|
|
133
|
+
readonly validator: (value: any) => {
|
|
134
|
+
currentType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
135
|
+
expectedType: string;
|
|
136
|
+
} | undefined;
|
|
137
|
+
}]>;
|
|
138
|
+
export {};
|
|
139
|
+
//# sourceMappingURL=file.d.ts.map
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from "./array";
|
|
2
|
+
export * from "./blob";
|
|
2
3
|
export * from "./boolean";
|
|
3
4
|
export * from "./branded";
|
|
4
5
|
export * from "./class";
|
|
5
6
|
export * from "./date";
|
|
7
|
+
export * from "./element";
|
|
8
|
+
export * from "./file";
|
|
6
9
|
export * from "./id";
|
|
7
10
|
export * from "./number";
|
|
8
11
|
export * from "./object";
|
|
@@ -53,6 +53,13 @@ export declare class ArcObject<E extends ArcRawShape, V extends Validators = [
|
|
|
53
53
|
}>): {
|
|
54
54
|
[key in keyof E]: ReturnType<E[key]["serialize"]>;
|
|
55
55
|
};
|
|
56
|
+
validatePartial(value: Partial<{
|
|
57
|
+
[key in keyof E]: util.FirstArgument<E[key]["validate"]>;
|
|
58
|
+
}>): {
|
|
59
|
+
schema: {
|
|
60
|
+
[key in keyof E]: ReturnType<E[key]["validate"]>;
|
|
61
|
+
};
|
|
62
|
+
} | false;
|
|
56
63
|
pick<Keys extends keyof E>(...keys: Keys[]): ArcObject<Pick<E, Keys>, V>;
|
|
57
64
|
omit<Keys extends keyof E>(...keys: Keys[]): ArcObject<Omit<E, Keys>, V>;
|
|
58
65
|
entries(): [string, ArcElement][];
|