wabe 0.5.13 → 0.5.14
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/index.d.ts +41 -40
- package/dist/index.js +220 -272
- package/generated/schema.graphql +18 -18
- package/generated/wabe.ts +18 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -398,9 +398,9 @@ export interface DeleteObjectsOptions<T extends WabeTypes, K extends keyof T["ty
|
|
|
398
398
|
first?: number;
|
|
399
399
|
context: WabeContext<any>;
|
|
400
400
|
}
|
|
401
|
-
export type OutputType<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> = Pick<T["types"][K], U> & {
|
|
401
|
+
export type OutputType<T extends WabeTypes, K extends keyof T["types"], U extends keyof T["types"][K]> = (Pick<T["types"][K], U> & {
|
|
402
402
|
id: string;
|
|
403
|
-
};
|
|
403
|
+
}) | null;
|
|
404
404
|
export interface DatabaseAdapter<T extends WabeTypes> {
|
|
405
405
|
connect(): Promise<any>;
|
|
406
406
|
close(): Promise<any>;
|
|
@@ -409,10 +409,18 @@ export interface DatabaseAdapter<T extends WabeTypes> {
|
|
|
409
409
|
count<T extends WabeTypes, K extends keyof T["types"]>(params: CountOptions<T, K>): Promise<number>;
|
|
410
410
|
getObject<K extends keyof T["types"], U extends keyof T["types"][K]>(params: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
411
411
|
getObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
412
|
-
createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: CreateObjectOptions<T, K, U, W>): Promise<
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
412
|
+
createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: CreateObjectOptions<T, K, U, W>): Promise<{
|
|
413
|
+
id: string;
|
|
414
|
+
}>;
|
|
415
|
+
createObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>(params: CreateObjectsOptions<T, K, U, W, X>): Promise<Array<{
|
|
416
|
+
id: string;
|
|
417
|
+
}>>;
|
|
418
|
+
updateObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: UpdateObjectOptions<T, K, U, W>): Promise<{
|
|
419
|
+
id: string;
|
|
420
|
+
}>;
|
|
421
|
+
updateObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>(params: UpdateObjectsOptions<T, K, U, W, X>): Promise<Array<{
|
|
422
|
+
id: string;
|
|
423
|
+
}>>;
|
|
416
424
|
deleteObject<K extends keyof T["types"], U extends keyof T["types"][K]>(params: DeleteObjectOptions<T, K, U>): Promise<void>;
|
|
417
425
|
deleteObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: DeleteObjectsOptions<T, K, U, W>): Promise<void>;
|
|
418
426
|
}
|
|
@@ -430,30 +438,21 @@ export declare class MongoAdapter<T extends WabeTypes> implements DatabaseAdapte
|
|
|
430
438
|
clearDatabase(): Promise<void>;
|
|
431
439
|
getObject<K extends keyof T["types"], U extends keyof T["types"][K]>(params: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
432
440
|
getObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: GetObjectsOptions<T, K, U, W>): Promise<OutputType<T, K, W>[]>;
|
|
433
|
-
createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: CreateObjectOptions<T, K, U, W>): Promise<
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
441
|
+
createObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: CreateObjectOptions<T, K, U, W>): Promise<{
|
|
442
|
+
id: string;
|
|
443
|
+
}>;
|
|
444
|
+
createObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>(params: CreateObjectsOptions<T, K, U, W, X>): Promise<{
|
|
445
|
+
id: string;
|
|
446
|
+
}[]>;
|
|
447
|
+
updateObject<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K]>(params: UpdateObjectOptions<T, K, U, W>): Promise<{
|
|
448
|
+
id: string;
|
|
449
|
+
}>;
|
|
450
|
+
updateObjects<K extends keyof T["types"], U extends keyof T["types"][K], W extends keyof T["types"][K], X extends keyof T["types"][K]>(params: UpdateObjectsOptions<T, K, U, W, X>): Promise<{
|
|
451
|
+
id: any;
|
|
452
|
+
}[]>;
|
|
437
453
|
deleteObject<K extends keyof T["types"], U extends keyof T["types"][K]>(params: DeleteObjectOptions<T, K, U>): Promise<void>;
|
|
438
454
|
deleteObjects<K extends keyof T["types"], U extends keyof T["types"][U], W extends keyof T["types"][U]>(params: DeleteObjectsOptions<T, K, U, W>): Promise<void>;
|
|
439
455
|
}
|
|
440
|
-
export interface InMemoryCacheOptions {
|
|
441
|
-
/**
|
|
442
|
-
* Interval in ms to clear the cache
|
|
443
|
-
*/
|
|
444
|
-
interval: number;
|
|
445
|
-
}
|
|
446
|
-
declare class InMemoryCache<T> {
|
|
447
|
-
private options;
|
|
448
|
-
private store;
|
|
449
|
-
intervalId: Timer | undefined;
|
|
450
|
-
constructor(options: InMemoryCacheOptions);
|
|
451
|
-
_init(): void;
|
|
452
|
-
set(key: string, value: T): void;
|
|
453
|
-
get(key: string): T | undefined;
|
|
454
|
-
clear(): void;
|
|
455
|
-
stop(): void;
|
|
456
|
-
}
|
|
457
456
|
export type PointerObject = Record<string, {
|
|
458
457
|
pointerClass?: string;
|
|
459
458
|
fieldsOfPointerClass: Array<string>;
|
|
@@ -464,11 +463,7 @@ export interface PointerFields {
|
|
|
464
463
|
}
|
|
465
464
|
export declare class DatabaseController<T extends WabeTypes> {
|
|
466
465
|
adapter: DatabaseAdapter<T>;
|
|
467
|
-
inMemoryCache: InMemoryCache<OutputType<T, any, any> | undefined>;
|
|
468
466
|
constructor(adapter: DatabaseAdapter<T>);
|
|
469
|
-
connect(): Promise<any>;
|
|
470
|
-
close(): Promise<any>;
|
|
471
|
-
createClassIfNotExist(className: string, context: WabeContext<T>): Promise<any>;
|
|
472
467
|
_getPointerObject(className: keyof T["types"], fields: string[], context: WabeContext<T>): PointerFields;
|
|
473
468
|
_isRelationField<K extends keyof T["types"]>(originClassName: K, context: WabeContext<T>, pointerClassName?: string): boolean | undefined;
|
|
474
469
|
_isPointerField<K extends keyof T["types"]>(originClassName: K, context: WabeContext<T>, pointerClassName?: string): boolean | undefined;
|
|
@@ -634,7 +629,9 @@ export declare class DatabaseController<T extends WabeTypes> {
|
|
|
634
629
|
AND?: WhereType<T, U>[] | undefined;
|
|
635
630
|
}>;
|
|
636
631
|
_buildWhereWithACL<K extends keyof T["types"]>(where: WhereType<T, K>, context: WabeContext<T>, operation: "write" | "read"): WhereType<T, K>;
|
|
637
|
-
|
|
632
|
+
connect(): Promise<any>;
|
|
633
|
+
close(): Promise<any>;
|
|
634
|
+
createClassIfNotExist(className: string, context: WabeContext<T>): Promise<any>;
|
|
638
635
|
count<K extends keyof T["types"]>(params: CountOptions<T, K>): Promise<number>;
|
|
639
636
|
clearDatabase(): Promise<void>;
|
|
640
637
|
getObject<K extends keyof T["types"], U extends keyof T["types"][K]>({ fields, className, context, skipHooks, id, where, }: GetObjectOptions<T, K, U>): Promise<OutputType<T, K, U>>;
|
|
@@ -686,15 +683,16 @@ export declare const initializeHook: <T extends WabeTypes, K extends keyof T["ty
|
|
|
686
683
|
newData?: MutationData<DevWabeTypes, any, any>;
|
|
687
684
|
context: WabeContext<any>;
|
|
688
685
|
}) => {
|
|
689
|
-
runOnSingleObject: (
|
|
686
|
+
runOnSingleObject: (options: {
|
|
690
687
|
operationType: OperationType;
|
|
691
688
|
id?: string;
|
|
692
|
-
|
|
689
|
+
originalObject?: OutputType<DevWabeTypes, any, any>;
|
|
693
690
|
}) => Promise<MutationData<T, K, any>>;
|
|
694
|
-
runOnMultipleObjects: (
|
|
691
|
+
runOnMultipleObjects: (options: {
|
|
695
692
|
operationType: OperationType;
|
|
696
693
|
where?: WhereType<any, any>;
|
|
697
|
-
|
|
694
|
+
ids?: string[];
|
|
695
|
+
originalObjects?: OutputType<DevWabeTypes, any, any>[];
|
|
698
696
|
}) => Promise<{
|
|
699
697
|
objects: never[];
|
|
700
698
|
newData: MutationData<DevWabeTypes, any, any>[];
|
|
@@ -709,18 +707,21 @@ declare class HookObject<T extends WabeTypes, K extends keyof WabeTypes["types"]
|
|
|
709
707
|
private newData;
|
|
710
708
|
private operationType;
|
|
711
709
|
context: WabeContext<T>;
|
|
712
|
-
object:
|
|
713
|
-
|
|
710
|
+
object: OutputType<T, K, keyof T["types"][K]>;
|
|
711
|
+
originalObject: OutputType<T, K, keyof T["types"][K]> | undefined;
|
|
712
|
+
constructor({ newData, className, operationType, context, object, originalObject, }: {
|
|
714
713
|
className: K;
|
|
715
714
|
newData?: MutationData<T, K, keyof T["types"][K]>;
|
|
716
715
|
operationType: OperationType;
|
|
717
716
|
context: WabeContext<T>;
|
|
718
|
-
object:
|
|
717
|
+
object: OutputType<T, K, keyof T["types"][K]>;
|
|
718
|
+
originalObject?: OutputType<T, K, keyof T["types"][K]>;
|
|
719
719
|
});
|
|
720
720
|
getUser(): User | null | undefined;
|
|
721
|
-
|
|
721
|
+
isFieldUpdated(field: keyof T["types"][K]): boolean | undefined;
|
|
722
722
|
upsertNewData(field: keyof T["types"][K], value: any): void;
|
|
723
723
|
getNewData(): MutationData<T, K, keyof T["types"][K]>;
|
|
724
|
+
fetch(): Promise<OutputType<T, K, keyof T["types"][K]>>;
|
|
724
725
|
}
|
|
725
726
|
export type WabePrimaryTypes = "String" | "Int" | "Float" | "Boolean" | "Email" | "Date" | "File";
|
|
726
727
|
export type WabeCustomTypes = "Array" | "Object";
|