wabe 0.5.1 → 0.5.2

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.
@@ -79,6 +79,18 @@ export declare enum AuthenticationProvider {
79
79
  export declare enum SecondaryFactor {
80
80
  EmailOtp = "EmailOTP"
81
81
  }
82
+ export declare enum PaymentMode {
83
+ Payment = "payment",
84
+ Subscription = "subscription"
85
+ }
86
+ export declare enum PaymentReccuringInterval {
87
+ Month = "month",
88
+ Year = "year"
89
+ }
90
+ export declare enum Currency {
91
+ Eur = "eur",
92
+ Usd = "usd"
93
+ }
82
94
  /** User class */
83
95
  export type User = {
84
96
  __typename?: 'User';
@@ -519,6 +531,8 @@ export type Query = {
519
531
  /** Hello world description */
520
532
  helloWorld?: Maybe<Scalars['String']['output']>;
521
533
  me?: Maybe<MeOutput>;
534
+ /** Get invoices of a customer */
535
+ getInvoices: Array<Maybe<Invoice>>;
522
536
  };
523
537
  export type QueryUserArgs = {
524
538
  id?: InputMaybe<Scalars['ID']['input']>;
@@ -555,6 +569,9 @@ export type QueryRolesArgs = {
555
569
  export type QueryHelloWorldArgs = {
556
570
  name: Scalars['String']['input'];
557
571
  };
572
+ export type QueryGetInvoicesArgs = {
573
+ email: Scalars['Email']['input'];
574
+ };
558
575
  /** User class */
559
576
  export type UserWhereInput = {
560
577
  id?: InputMaybe<IdWhereInput>;
@@ -788,6 +805,16 @@ export type MeOutput = {
788
805
  __typename?: 'MeOutput';
789
806
  user?: Maybe<User>;
790
807
  };
808
+ export type Invoice = {
809
+ __typename?: 'Invoice';
810
+ amountDue: Scalars['Int']['output'];
811
+ amountPaid: Scalars['Int']['output'];
812
+ currency: Currency;
813
+ id: Scalars['String']['output'];
814
+ created: Scalars['Int']['output'];
815
+ invoiceUrl: Scalars['String']['output'];
816
+ isPaid: Scalars['Boolean']['output'];
817
+ };
791
818
  export type Mutation = {
792
819
  __typename?: 'Mutation';
793
820
  /** User class */
@@ -823,6 +850,9 @@ export type Mutation = {
823
850
  createMutation: Scalars['Boolean']['output'];
824
851
  customMutation?: Maybe<Scalars['Int']['output']>;
825
852
  secondCustomMutation?: Maybe<Scalars['Int']['output']>;
853
+ /** Create a payment with the payment provider. Returns the url to redirect the user to pay */
854
+ createPayment?: Maybe<Scalars['String']['output']>;
855
+ cancelSubscription?: Maybe<Scalars['Boolean']['output']>;
826
856
  /** Send basic email with text and html, returns the id of the email */
827
857
  sendEmail?: Maybe<Scalars['String']['output']>;
828
858
  signInWith?: Maybe<SignInWithOutput>;
@@ -912,6 +942,12 @@ export type MutationCustomMutationArgs = {
912
942
  export type MutationSecondCustomMutationArgs = {
913
943
  input: SecondCustomMutationInput;
914
944
  };
945
+ export type MutationCreatePaymentArgs = {
946
+ input: CreatePaymentInput;
947
+ };
948
+ export type MutationCancelSubscriptionArgs = {
949
+ input: CancelSubscriptionInput;
950
+ };
915
951
  export type MutationSendEmailArgs = {
916
952
  input: SendEmailInput;
917
953
  };
@@ -1209,6 +1245,23 @@ export type SecondCustomMutationSumInput = {
1209
1245
  a: Scalars['Int']['input'];
1210
1246
  b: Scalars['Int']['input'];
1211
1247
  };
1248
+ export type CreatePaymentInput = {
1249
+ customerEmail?: InputMaybe<Scalars['Email']['input']>;
1250
+ paymentMode: PaymentMode;
1251
+ successUrl: Scalars['String']['input'];
1252
+ cancelUrl: Scalars['String']['input'];
1253
+ products: Array<InputMaybe<CreatePaymentProductInput>>;
1254
+ automaticTax?: InputMaybe<Scalars['Boolean']['input']>;
1255
+ recurringInterval?: InputMaybe<PaymentReccuringInterval>;
1256
+ };
1257
+ export type CreatePaymentProductInput = {
1258
+ name: Scalars['String']['input'];
1259
+ unitAmount: Scalars['Int']['input'];
1260
+ quantity: Scalars['Int']['input'];
1261
+ };
1262
+ export type CancelSubscriptionInput = {
1263
+ email: Scalars['Email']['input'];
1264
+ };
1212
1265
  export type SendEmailInput = {
1213
1266
  from: Scalars['String']['input'];
1214
1267
  to: Array<Scalars['String']['input']>;
@@ -1290,7 +1343,7 @@ export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, st
1290
1343
  export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
1291
1344
  export type Sdk = ReturnType<typeof getSdk>;
1292
1345
  export type WabeSchemaScalars = "Phone";
1293
- export type WabeSchemaEnums = "AuthenticationProvider" | "SecondaryFactor";
1346
+ export type WabeSchemaEnums = "AuthenticationProvider" | "SecondaryFactor" | "PaymentMode" | "PaymentReccuringInterval" | "Currency";
1294
1347
  export type WabeSchemaTypes = {
1295
1348
  User: User;
1296
1349
  Post: Post;
package/dist/index.d.ts CHANGED
@@ -259,7 +259,7 @@ export type SignUpWithAuthenticationOtpInput = {
259
259
  code?: InputMaybe<Scalars["String"]["input"]>;
260
260
  };
261
261
  export type WabeSchemaScalars = "Phone";
262
- export type WabeSchemaEnums = "AuthenticationProvider" | "SecondaryFactor";
262
+ export type WabeSchemaEnums = "AuthenticationProvider" | "SecondaryFactor" | "PaymentMode" | "PaymentReccuringInterval" | "Currency";
263
263
  export type WabeSchemaTypes = {
264
264
  User: User;
265
265
  Post: Post;
@@ -541,10 +541,9 @@ export type TypeFieldCustomEnums<T extends WabeTypes> = {
541
541
  };
542
542
  export type TypeField<T extends WabeTypes> = TypeFieldBase<string, "String"> | TypeFieldBase<number, "Int"> | TypeFieldBase<number, "Float"> | TypeFieldBase<boolean, "Boolean"> | TypeFieldBase<Date, "Date"> | TypeFieldBase<string, "Email"> | TypeFieldArray<T> | TypeFieldObject<T> | TypeFieldPointer<T> | TypeFieldRelation<T> | TypeFieldFile | TypeFieldCustomScalars<T> | TypeFieldCustomEnums<T>;
543
543
  export type SchemaFields<T extends WabeTypes> = Record<string, TypeField<T>>;
544
- export type QueryResolver<T extends WabeTypes> = {
544
+ export type ResolverType<T extends WabeTypes> = {
545
545
  required?: boolean;
546
546
  description?: string;
547
- args?: SchemaFields<T>;
548
547
  resolve: (...args: any) => any;
549
548
  } & ({
550
549
  type: WabePrimaryTypes;
@@ -554,23 +553,21 @@ export type QueryResolver<T extends WabeTypes> = {
554
553
  } | {
555
554
  type: "Array";
556
555
  typeValue: WabePrimaryTypes;
556
+ typeValueRequired?: boolean;
557
+ } | {
558
+ type: "Array";
559
+ typeValue: "Object";
560
+ outputObject: ClassInterface<T>;
561
+ typeValueRequired?: boolean;
557
562
  });
563
+ export type QueryResolver<T extends WabeTypes> = {
564
+ args?: SchemaFields<T>;
565
+ } & ResolverType<T>;
558
566
  export type MutationResolver<T extends WabeTypes> = {
559
- required?: boolean;
560
- description?: string;
561
567
  args?: {
562
568
  input: SchemaFields<T>;
563
569
  };
564
- resolve: (...args: any) => any;
565
- } & ({
566
- type: WabePrimaryTypes;
567
- } | {
568
- type: "Object";
569
- outputObject: ClassInterface<T>;
570
- } | {
571
- type: "Array";
572
- typeValue: WabePrimaryTypes;
573
- });
570
+ } & ResolverType<T>;
574
571
  export type TypeResolver<T extends WabeTypes> = {
575
572
  queries?: {
576
573
  [key: string]: QueryResolver<T>;
@@ -825,6 +822,104 @@ declare class EmailController implements EmailAdapter {
825
822
  constructor(adapter: EmailAdapter);
826
823
  send(options: EmailSendOptions): Promise<string>;
827
824
  }
825
+ export declare enum Currency {
826
+ EUR = "eur",
827
+ USD = "usd"
828
+ }
829
+ export type Address = {
830
+ city: string;
831
+ country: string;
832
+ line1: string;
833
+ line2: string;
834
+ postalCode: string;
835
+ state: string;
836
+ };
837
+ export declare enum PaymentMode {
838
+ Payment = "payment",
839
+ Subscription = "subscription"
840
+ }
841
+ export type PaymentMethod = "card" | "paypal" | "link" | "sepa_debit" | "revolut_pay" | "us_bank_account";
842
+ export declare enum PaymentReccuringInterval {
843
+ Month = "month",
844
+ Year = "year"
845
+ }
846
+ export type Product = {
847
+ name: string;
848
+ unitAmount: number;
849
+ quantity: number;
850
+ };
851
+ export interface PaymentConfig {
852
+ adapter: PaymentAdapter;
853
+ supportedPaymentMethods: Array<PaymentMethod>;
854
+ currency: Currency;
855
+ }
856
+ export type Invoice = {
857
+ amountDue: number;
858
+ amountPaid: number;
859
+ currency: Currency;
860
+ id: string;
861
+ created: number;
862
+ invoiceUrl: string;
863
+ isPaid: boolean;
864
+ };
865
+ export type CreateCustomerOptions = {
866
+ customerName?: string;
867
+ customerEmail: string;
868
+ customerPhone?: string;
869
+ address: Address;
870
+ paymentMethod: PaymentMethod;
871
+ };
872
+ export type CreatePaymentOptions = {
873
+ currency: Currency;
874
+ customerEmail: string;
875
+ products: Array<Product>;
876
+ paymentMethod: Array<PaymentMethod>;
877
+ paymentMode: PaymentMode;
878
+ successUrl: string;
879
+ cancelUrl: string;
880
+ automaticTax?: boolean;
881
+ recurringInterval?: "month" | "year";
882
+ };
883
+ export type CancelSubscriptionOptions = {
884
+ email: string;
885
+ };
886
+ export type GetInvoicesOptions = {
887
+ email: string;
888
+ };
889
+ export interface PaymentAdapter {
890
+ /**
891
+ * Create a customer
892
+ * @param options CreateCustomerOptions
893
+ * @returns The customer email
894
+ */
895
+ createCustomer: (options: CreateCustomerOptions) => Promise<string>;
896
+ /**
897
+ * Create a payment
898
+ * @param options CreatePaymentOptions
899
+ * @returns The payment url
900
+ */
901
+ createPayment: (options: CreatePaymentOptions) => Promise<string>;
902
+ /**
903
+ * Cancel a subscription
904
+ * @param options The customer email to cancel the subscription
905
+ */
906
+ cancelSubscription: (options: CancelSubscriptionOptions) => Promise<void>;
907
+ /**
908
+ * Get invoices
909
+ * @param options The customer email to get the invoices
910
+ * @returns The invoices of a customer
911
+ */
912
+ getInvoices: (options: GetInvoicesOptions) => Promise<Invoice[]>;
913
+ }
914
+ declare class PaymentController implements PaymentAdapter {
915
+ private adapter;
916
+ private config;
917
+ constructor(paymentConfig: PaymentConfig);
918
+ createCustomer(options: CreateCustomerOptions): Promise<string>;
919
+ createPayment(options: Omit<CreatePaymentOptions, "currency" | "paymentMethod">): Promise<string>;
920
+ cancelSubscription(options: CancelSubscriptionOptions): Promise<void>;
921
+ getInvoices(options: GetInvoicesOptions): Promise<Invoice[]>;
922
+ }
828
923
  export interface WabeConfig<T extends WabeTypes> {
829
924
  port: number;
830
925
  schema?: SchemaInterface<T>;
@@ -840,6 +935,7 @@ export interface WabeConfig<T extends WabeTypes> {
840
935
  rootKey: string;
841
936
  hooks?: Hook<any>[];
842
937
  email?: EmailConfig;
938
+ payment?: PaymentConfig;
843
939
  file?: FileConfig;
844
940
  }
845
941
  export type WabeTypes = {
@@ -853,12 +949,13 @@ export type WobeCustomContext<T extends WabeTypes> = {
853
949
  export type WabeControllers<T extends WabeTypes> = {
854
950
  database: DatabaseController<T>;
855
951
  email?: EmailController;
952
+ payment?: PaymentController;
856
953
  };
857
954
  export declare class Wabe<T extends WabeTypes> {
858
955
  server: Wobe<WobeCustomContext<T>>;
859
956
  config: WabeConfig<T>;
860
957
  controllers: WabeControllers<T>;
861
- constructor({ port, schema, database, authentication, rootKey, codegen, hooks, file, email, routes, }: WabeConfig<T>);
958
+ constructor({ port, schema, database, authentication, rootKey, codegen, hooks, file, email, payment, routes, }: WabeConfig<T>);
862
959
  loadAuthenticationMethods(): void;
863
960
  loadHooks(): void;
864
961
  loadDefaultRoutes(): void;