wabe 0.5.12 → 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 +66 -47
- package/dist/index.js +222 -274
- 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";
|
|
@@ -1208,7 +1209,10 @@ export interface PaymentAdapter {
|
|
|
1208
1209
|
* @param options CreateCouponOptions
|
|
1209
1210
|
* @returns id The coupon id
|
|
1210
1211
|
*/
|
|
1211
|
-
createCoupon: (options: CreateCouponOptions) => Promise<
|
|
1212
|
+
createCoupon: (options: CreateCouponOptions) => Promise<{
|
|
1213
|
+
code: string;
|
|
1214
|
+
id: string;
|
|
1215
|
+
}>;
|
|
1212
1216
|
/**
|
|
1213
1217
|
* Disable a promotion code
|
|
1214
1218
|
* @param options DeletePromotionCodeOptions
|
|
@@ -1217,9 +1221,12 @@ export interface PaymentAdapter {
|
|
|
1217
1221
|
/**
|
|
1218
1222
|
* Create a promotion code from a coupon
|
|
1219
1223
|
* @param options CreatePromotionCodeOptions
|
|
1220
|
-
* @returns code The promotion code
|
|
1224
|
+
* @returns code, id The promotion code and the stripe id
|
|
1221
1225
|
*/
|
|
1222
|
-
createPromotionCode: (options: CreatePromotionCodeOptions) => Promise<
|
|
1226
|
+
createPromotionCode: (options: CreatePromotionCodeOptions) => Promise<{
|
|
1227
|
+
id: string;
|
|
1228
|
+
code: string;
|
|
1229
|
+
}>;
|
|
1223
1230
|
/**
|
|
1224
1231
|
* Get a customer by id
|
|
1225
1232
|
* @param id The customer id
|
|
@@ -1281,8 +1288,14 @@ declare class PaymentController implements PaymentAdapter {
|
|
|
1281
1288
|
constructor(paymentConfig: PaymentConfig);
|
|
1282
1289
|
deleteCoupon(options: DeleteCouponOptions): Promise<void>;
|
|
1283
1290
|
updatePromotionCode(options: UpdatePromotionCodeOptions): Promise<void>;
|
|
1284
|
-
createCoupon(options: CreateCouponOptions): Promise<
|
|
1285
|
-
|
|
1291
|
+
createCoupon(options: CreateCouponOptions): Promise<{
|
|
1292
|
+
code: string;
|
|
1293
|
+
id: string;
|
|
1294
|
+
}>;
|
|
1295
|
+
createPromotionCode(options: CreatePromotionCodeOptions): Promise<{
|
|
1296
|
+
id: string;
|
|
1297
|
+
code: string;
|
|
1298
|
+
}>;
|
|
1286
1299
|
getCustomerById(options: GetCustomerByIdOptions): Promise<{
|
|
1287
1300
|
email: string | null;
|
|
1288
1301
|
}>;
|
|
@@ -1427,8 +1440,14 @@ export declare class PaymentDevAdapter implements PaymentAdapter {
|
|
|
1427
1440
|
}>;
|
|
1428
1441
|
deleteCoupon(): Promise<void>;
|
|
1429
1442
|
updatePromotionCode(): Promise<void>;
|
|
1430
|
-
createCoupon(): Promise<
|
|
1431
|
-
|
|
1443
|
+
createCoupon(): Promise<{
|
|
1444
|
+
code: string;
|
|
1445
|
+
id: string;
|
|
1446
|
+
}>;
|
|
1447
|
+
createPromotionCode(): Promise<{
|
|
1448
|
+
code: string;
|
|
1449
|
+
id: string;
|
|
1450
|
+
}>;
|
|
1432
1451
|
validateWebhook(): Promise<{
|
|
1433
1452
|
isValid: boolean;
|
|
1434
1453
|
payload: {};
|