wabe 0.6.3 → 0.6.5
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/README.md +2 -1
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/interface.d.ts +9 -0
- package/dist/authentication/OTP.d.ts +8 -0
- package/dist/authentication/Session.d.ts +21 -0
- package/dist/authentication/defaultAuthentication.d.ts +3 -0
- package/dist/authentication/index.d.ts +2 -0
- package/dist/authentication/interface.d.ts +118 -0
- package/dist/authentication/oauth/GitHub.d.ts +13 -0
- package/dist/authentication/oauth/Google.d.ts +13 -0
- package/dist/authentication/oauth/Oauth2Client.d.ts +33 -0
- package/dist/authentication/oauth/index.d.ts +2 -0
- package/dist/authentication/oauth/utils.d.ts +14 -0
- package/dist/authentication/providers/EmailOTP.d.ts +11 -0
- package/dist/authentication/providers/EmailPassword.d.ts +13 -0
- package/dist/authentication/providers/GitHub.d.ts +12 -0
- package/dist/authentication/providers/Google.d.ts +12 -0
- package/dist/authentication/providers/OAuth.d.ts +6 -0
- package/dist/authentication/providers/PhonePassword.d.ts +13 -0
- package/dist/authentication/providers/index.d.ts +5 -0
- package/dist/authentication/resolvers/refreshResolver.d.ts +1 -0
- package/dist/authentication/resolvers/signInWithResolver.d.ts +1 -0
- package/dist/authentication/resolvers/signOutResolver.d.ts +1 -0
- package/dist/authentication/resolvers/signUpWithResolver.d.ts +1 -0
- package/dist/authentication/resolvers/verifyChallenge.d.ts +1 -0
- package/dist/authentication/roles.d.ts +1 -0
- package/dist/authentication/srp/processSRPChallenge.d.ts +1 -0
- package/dist/authentication/srp/signInWithSRP.d.ts +1 -0
- package/dist/authentication/srp/signUpWithSRP.d.ts +1 -0
- package/dist/authentication/utils.d.ts +8 -0
- package/dist/cron/index.d.ts +32 -0
- package/dist/database/adapters/MongoAdapter.d.ts +64 -0
- package/dist/database/adapters/adaptersInterface.d.ts +263 -0
- package/dist/database/adapters/index.d.ts +2 -0
- package/dist/database/controllers/DatabaseController.d.ts +90 -0
- package/dist/database/controllers/index.d.ts +1 -0
- package/dist/database/index.d.ts +10 -0
- package/dist/email/DevAdapter.d.ts +4 -0
- package/dist/email/EmailController.d.ts +6 -0
- package/dist/email/index.d.ts +2 -0
- package/dist/email/interface.d.ts +35 -0
- package/dist/email/templates/sendOtpCode.d.ts +1 -0
- package/dist/files/FileController.d.ts +10 -0
- package/dist/files/FileDevAdapter.d.ts +8 -0
- package/dist/files/hookDeleteFile.d.ts +1 -0
- package/dist/files/hookReadFile.d.ts +1 -0
- package/dist/files/hookUploadFile.d.ts +2 -0
- package/dist/files/index.d.ts +2 -0
- package/dist/files/interface.d.ts +30 -0
- package/dist/graphql/GraphQLSchema.d.ts +75 -0
- package/dist/graphql/index.d.ts +2 -0
- package/dist/graphql/parser.d.ts +38 -0
- package/dist/graphql/pointerAndRelationFunction.d.ts +20 -0
- package/dist/graphql/resolvers.d.ts +20 -0
- package/dist/graphql/types.d.ts +18 -0
- package/dist/hooks/HookObject.d.ts +39 -0
- package/dist/hooks/authentication.d.ts +2 -0
- package/dist/hooks/defaultFields.d.ts +3 -0
- package/dist/hooks/deleteSession.d.ts +1 -0
- package/dist/hooks/index.d.ts +41 -0
- package/dist/hooks/permissions.d.ts +6 -0
- package/dist/hooks/protected.d.ts +3 -0
- package/dist/hooks/searchableFields.d.ts +3 -0
- package/dist/hooks/session.d.ts +3 -0
- package/dist/hooks/setEmail.d.ts +2 -0
- package/dist/hooks/setupAcl.d.ts +2 -0
- package/dist/index.d.ts +11 -1459
- package/dist/index.js +486 -76812
- package/dist/payment/DevAdapter.d.ts +17 -0
- package/dist/payment/PaymentController.d.ts +19 -0
- package/dist/payment/index.d.ts +2 -0
- package/dist/payment/interface.d.ts +235 -0
- package/dist/schema/Schema.d.ts +164 -0
- package/dist/schema/defaultResolvers.d.ts +7 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/resolvers/meResolver.d.ts +1 -0
- package/dist/schema/resolvers/resetPassword.d.ts +1 -0
- package/dist/schema/resolvers/sendEmail.d.ts +1 -0
- package/dist/schema/resolvers/sendOtpCode.d.ts +1 -0
- package/dist/server/defaultHandlers.d.ts +1 -0
- package/dist/server/generateCodegen.d.ts +1 -0
- package/dist/server/index.d.ts +77 -0
- package/dist/server/routes/authHandler.d.ts +2 -0
- package/dist/server/routes/index.d.ts +8 -0
- package/dist/utils/export.d.ts +2 -0
- package/dist/utils/helper.d.ts +21 -0
- package/dist/utils/index.d.ts +17 -0
- package/generated/schema.graphql +126 -21
- package/generated/wabe.ts +135 -25
- package/package.json +8 -7
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PaymentAdapter } from "./interface";
|
|
2
|
+
export declare class PaymentDevAdapter implements PaymentAdapter {
|
|
3
|
+
adapter: {};
|
|
4
|
+
getCustomerById();
|
|
5
|
+
deleteCoupon();
|
|
6
|
+
updatePromotionCode();
|
|
7
|
+
createCoupon();
|
|
8
|
+
createPromotionCode();
|
|
9
|
+
validateWebhook();
|
|
10
|
+
createCustomer();
|
|
11
|
+
createPayment();
|
|
12
|
+
cancelSubscription();
|
|
13
|
+
getInvoices();
|
|
14
|
+
getTotalRevenue();
|
|
15
|
+
getAllTransactions();
|
|
16
|
+
getHypotheticalSubscriptionRevenue();
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CancelSubscriptionOptions, CreateCustomerOptions, CreatePaymentOptions, GetInvoicesOptions, PaymentAdapter, PaymentConfig, GetTotalRevenueOptions, GetAllTransactionsOptions, GetCustomerByIdOptions, CreateCouponOptions, CreatePromotionCodeOptions, DeleteCouponOptions, UpdatePromotionCodeOptions } from "./interface";
|
|
2
|
+
export declare class PaymentController implements PaymentAdapter {
|
|
3
|
+
adapter: PaymentAdapter;
|
|
4
|
+
private config;
|
|
5
|
+
constructor(paymentConfig: PaymentConfig);
|
|
6
|
+
deleteCoupon(options: DeleteCouponOptions);
|
|
7
|
+
updatePromotionCode(options: UpdatePromotionCodeOptions);
|
|
8
|
+
createCoupon(options: CreateCouponOptions);
|
|
9
|
+
createPromotionCode(options: CreatePromotionCodeOptions);
|
|
10
|
+
getCustomerById(options: GetCustomerByIdOptions);
|
|
11
|
+
validateWebhook(ctx: any);
|
|
12
|
+
createCustomer(options: CreateCustomerOptions);
|
|
13
|
+
createPayment(options: Omit<CreatePaymentOptions, "currency" | "paymentMethod">);
|
|
14
|
+
cancelSubscription(options: CancelSubscriptionOptions);
|
|
15
|
+
getInvoices(options: GetInvoicesOptions);
|
|
16
|
+
getTotalRevenue(options: GetTotalRevenueOptions);
|
|
17
|
+
getAllTransactions(options: GetAllTransactionsOptions);
|
|
18
|
+
getHypotheticalSubscriptionRevenue();
|
|
19
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { Context } from "wobe";
|
|
2
|
+
export declare enum Currency {
|
|
3
|
+
EUR = "eur",
|
|
4
|
+
USD = "usd",
|
|
5
|
+
}
|
|
6
|
+
export type Address = {
|
|
7
|
+
city: string
|
|
8
|
+
country: string
|
|
9
|
+
line1: string
|
|
10
|
+
line2: string
|
|
11
|
+
postalCode: string
|
|
12
|
+
state: string
|
|
13
|
+
};
|
|
14
|
+
export declare enum PaymentMode {
|
|
15
|
+
payment = "payment",
|
|
16
|
+
subscription = "subscription",
|
|
17
|
+
}
|
|
18
|
+
export type PaymentMethod = "card" | "paypal" | "link" | "sepa_debit" | "revolut_pay" | "us_bank_account";
|
|
19
|
+
export declare enum PaymentReccuringInterval {
|
|
20
|
+
Month = "month",
|
|
21
|
+
Year = "year",
|
|
22
|
+
}
|
|
23
|
+
export type Product = {
|
|
24
|
+
name: string
|
|
25
|
+
unitAmount: number
|
|
26
|
+
quantity: number
|
|
27
|
+
};
|
|
28
|
+
export interface OnPaymentSucceedOptions {
|
|
29
|
+
createdAt: number;
|
|
30
|
+
amount: number;
|
|
31
|
+
customerEmail: string | null;
|
|
32
|
+
currency: string;
|
|
33
|
+
paymentMethodTypes: Array<string>;
|
|
34
|
+
}
|
|
35
|
+
export interface OnPaymentFailedOptions {
|
|
36
|
+
createdAt: number;
|
|
37
|
+
amount: number;
|
|
38
|
+
paymentMethodTypes: Array<string>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* PaymentConfig
|
|
42
|
+
* @property adapter - The payment adapter
|
|
43
|
+
* @property supportedPaymentMethods - The supported payment methods
|
|
44
|
+
* @property currency - The currency
|
|
45
|
+
*/
|
|
46
|
+
export interface PaymentConfig {
|
|
47
|
+
adapter: PaymentAdapter;
|
|
48
|
+
supportedPaymentMethods: Array<PaymentMethod>;
|
|
49
|
+
currency: Currency;
|
|
50
|
+
}
|
|
51
|
+
export type Invoice = {
|
|
52
|
+
amountDue: number
|
|
53
|
+
amountPaid: number
|
|
54
|
+
currency: Currency
|
|
55
|
+
id: string
|
|
56
|
+
created: number
|
|
57
|
+
invoiceUrl: string
|
|
58
|
+
isPaid: boolean
|
|
59
|
+
};
|
|
60
|
+
export type Transaction = {
|
|
61
|
+
customerEmail: string
|
|
62
|
+
amount: number
|
|
63
|
+
currency: Currency
|
|
64
|
+
created: number
|
|
65
|
+
isSubscription: boolean
|
|
66
|
+
reccuringInterval?: "month" | "year"
|
|
67
|
+
};
|
|
68
|
+
export type CreateCustomerOptions = {
|
|
69
|
+
customerName?: string
|
|
70
|
+
customerEmail: string
|
|
71
|
+
customerPhone?: string
|
|
72
|
+
address: Address
|
|
73
|
+
paymentMethod: PaymentMethod
|
|
74
|
+
};
|
|
75
|
+
export type CreatePaymentOptions = {
|
|
76
|
+
currency: Currency
|
|
77
|
+
customerEmail?: string
|
|
78
|
+
products: Array<Product>
|
|
79
|
+
paymentMethod: Array<PaymentMethod>
|
|
80
|
+
paymentMode: PaymentMode
|
|
81
|
+
successUrl: string
|
|
82
|
+
cancelUrl: string
|
|
83
|
+
automaticTax?: boolean
|
|
84
|
+
recurringInterval?: "month" | "year"
|
|
85
|
+
createInvoice?: boolean
|
|
86
|
+
allowPromotionCode?: boolean
|
|
87
|
+
promotionCodeId?: string
|
|
88
|
+
couponCodeId?: string
|
|
89
|
+
};
|
|
90
|
+
export type InitWebhookOptions = {
|
|
91
|
+
webhookUrl: string
|
|
92
|
+
};
|
|
93
|
+
export type CancelSubscriptionOptions = {
|
|
94
|
+
email: string
|
|
95
|
+
};
|
|
96
|
+
export type GetInvoicesOptions = {
|
|
97
|
+
email: string
|
|
98
|
+
};
|
|
99
|
+
export type GetTotalRevenueOptions = {
|
|
100
|
+
startRangeTimestamp?: number
|
|
101
|
+
endRangeTimestamp?: number
|
|
102
|
+
charge: "net" | "gross"
|
|
103
|
+
};
|
|
104
|
+
export type GetAllTransactionsOptions = {
|
|
105
|
+
startRangeTimestamp?: number
|
|
106
|
+
endRangeTimestamp?: number
|
|
107
|
+
first?: number
|
|
108
|
+
};
|
|
109
|
+
export type GetCustomerByIdOptions = {
|
|
110
|
+
id: string
|
|
111
|
+
};
|
|
112
|
+
export type ValidateWebhookOptions = {
|
|
113
|
+
ctx: Context
|
|
114
|
+
endpointSecret: string
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* ValidateWebhookOutput
|
|
118
|
+
* @property valid - Whether the webhook is valid or not
|
|
119
|
+
* @property payload - The payload of the webhook
|
|
120
|
+
*/
|
|
121
|
+
export type ValidateWebhookOutput = {
|
|
122
|
+
isValid: boolean
|
|
123
|
+
type: string
|
|
124
|
+
payload: any | null
|
|
125
|
+
};
|
|
126
|
+
export type InitWebhookOutput = {
|
|
127
|
+
webhookId: string
|
|
128
|
+
endpointSecret: string
|
|
129
|
+
};
|
|
130
|
+
export type CreateCouponOptions = {
|
|
131
|
+
amountOff?: number
|
|
132
|
+
currency?: Currency
|
|
133
|
+
duration?: "forever" | "once" | "repeating"
|
|
134
|
+
durationInMonths?: number
|
|
135
|
+
name?: string
|
|
136
|
+
percentOff?: number
|
|
137
|
+
maxRedemptions?: number
|
|
138
|
+
};
|
|
139
|
+
export type CreatePromotionCodeOptions = {
|
|
140
|
+
couponId: string
|
|
141
|
+
code?: string
|
|
142
|
+
active?: boolean
|
|
143
|
+
maxRedemptions?: number
|
|
144
|
+
};
|
|
145
|
+
export type DeleteCouponOptions = {
|
|
146
|
+
id: string
|
|
147
|
+
};
|
|
148
|
+
export type UpdatePromotionCodeOptions = {
|
|
149
|
+
id: string
|
|
150
|
+
active: boolean
|
|
151
|
+
};
|
|
152
|
+
export interface PaymentAdapter {
|
|
153
|
+
/**
|
|
154
|
+
* Delete a coupon
|
|
155
|
+
* @param options DeleteCouponOptions
|
|
156
|
+
*/
|
|
157
|
+
deleteCoupon: (options: DeleteCouponOptions) => Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Create a coupon
|
|
160
|
+
* @param options CreateCouponOptions
|
|
161
|
+
* @returns id The coupon id
|
|
162
|
+
*/
|
|
163
|
+
createCoupon: (options: CreateCouponOptions) => Promise<{
|
|
164
|
+
code: string
|
|
165
|
+
id: string
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Disable a promotion code
|
|
169
|
+
* @param options DeletePromotionCodeOptions
|
|
170
|
+
*/
|
|
171
|
+
updatePromotionCode: (options: UpdatePromotionCodeOptions) => Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Create a promotion code from a coupon
|
|
174
|
+
* @param options CreatePromotionCodeOptions
|
|
175
|
+
* @returns code, id The promotion code and the stripe id
|
|
176
|
+
*/
|
|
177
|
+
createPromotionCode: (options: CreatePromotionCodeOptions) => Promise<{
|
|
178
|
+
id: string
|
|
179
|
+
code: string
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Get a customer by id
|
|
183
|
+
* @param id The customer id
|
|
184
|
+
* @returns The customer
|
|
185
|
+
*/
|
|
186
|
+
getCustomerById: (options: GetCustomerByIdOptions) => Promise<{
|
|
187
|
+
email: string | null
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Create a customer
|
|
191
|
+
* @param options CreateCustomerOptions
|
|
192
|
+
* @returns The customer email
|
|
193
|
+
*/
|
|
194
|
+
createCustomer: (options: CreateCustomerOptions) => Promise<string>;
|
|
195
|
+
/**
|
|
196
|
+
* Create a payment
|
|
197
|
+
* @param options CreatePaymentOptions
|
|
198
|
+
* @returns The payment url
|
|
199
|
+
*/
|
|
200
|
+
createPayment: (options: CreatePaymentOptions) => Promise<string>;
|
|
201
|
+
/**
|
|
202
|
+
* Cancel a subscription
|
|
203
|
+
* @param options The customer email to cancel the subscription
|
|
204
|
+
*/
|
|
205
|
+
cancelSubscription: (options: CancelSubscriptionOptions) => Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Get invoices
|
|
208
|
+
* @param options The customer email to get the invoices
|
|
209
|
+
* @returns The invoices of a customer
|
|
210
|
+
*/
|
|
211
|
+
getInvoices: (options: GetInvoicesOptions) => Promise<Invoice[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Get total revenue
|
|
214
|
+
* @param options The type of charge (net or gross) and the start and end range timestamps to get the total revenue
|
|
215
|
+
* @returns The total amount
|
|
216
|
+
*/
|
|
217
|
+
getTotalRevenue: (options: GetTotalRevenueOptions) => Promise<number>;
|
|
218
|
+
/**
|
|
219
|
+
* Get the list of all transactions
|
|
220
|
+
* @param options The start and end range timestamps to get the transactions
|
|
221
|
+
* @returns The list of transactions
|
|
222
|
+
*/
|
|
223
|
+
getAllTransactions: (options: GetAllTransactionsOptions) => Promise<Transaction[]>;
|
|
224
|
+
/**
|
|
225
|
+
* Get the hypothetical revenue of subscriptions
|
|
226
|
+
* @returns The hypothetical revenue of subscriptions
|
|
227
|
+
*/
|
|
228
|
+
getHypotheticalSubscriptionRevenue: () => Promise<number>;
|
|
229
|
+
/**
|
|
230
|
+
* Check if the request on webhook is from a valid provier
|
|
231
|
+
* @param ctx The Wobe context of the request
|
|
232
|
+
* @returns True if the request is from a valid provider, false otherwise
|
|
233
|
+
*/
|
|
234
|
+
validateWebhook: (options: ValidateWebhookOptions) => Promise<ValidateWebhookOutput>;
|
|
235
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { WabeConfig, WabeTypes } from "../server";
|
|
2
|
+
import type { HookObject } from "../hooks/HookObject";
|
|
3
|
+
export type WabePrimaryTypes = "String" | "Int" | "Float" | "Boolean" | "Email" | "Phone" | "Date" | "File";
|
|
4
|
+
export type WabeCustomTypes = "Array" | "Object";
|
|
5
|
+
export type WabeRelationTypes = "Pointer" | "Relation";
|
|
6
|
+
type WabeFieldTypes = WabeCustomTypes | WabePrimaryTypes | WabeRelationTypes;
|
|
7
|
+
export type WabeObject<T extends WabeTypes> = {
|
|
8
|
+
name: string
|
|
9
|
+
fields: SchemaFields<T>
|
|
10
|
+
description?: string
|
|
11
|
+
required?: boolean
|
|
12
|
+
};
|
|
13
|
+
type FieldBase<T extends WabeTypes> = {
|
|
14
|
+
required?: boolean
|
|
15
|
+
description?: string
|
|
16
|
+
protected?: {
|
|
17
|
+
authorizedRoles: Array<T["enums"]["RoleEnum"] | "rootOnly">
|
|
18
|
+
protectedOperations: Array<"create" | "read" | "update">
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
type TypeFieldBase<
|
|
22
|
+
U,
|
|
23
|
+
K extends WabeFieldTypes
|
|
24
|
+
> = {
|
|
25
|
+
type: K
|
|
26
|
+
defaultValue?: U
|
|
27
|
+
};
|
|
28
|
+
type TypeFieldArray<T extends WabeTypes> = {
|
|
29
|
+
type: "Array"
|
|
30
|
+
requiredValue?: boolean
|
|
31
|
+
defaultValue?: any[]
|
|
32
|
+
} & ({
|
|
33
|
+
typeValue: WabePrimaryTypes
|
|
34
|
+
} | {
|
|
35
|
+
typeValue: "Object"
|
|
36
|
+
object: WabeObject<T>
|
|
37
|
+
});
|
|
38
|
+
type TypeFieldObject<T extends WabeTypes> = {
|
|
39
|
+
type: "Object"
|
|
40
|
+
object: WabeObject<T>
|
|
41
|
+
defaultValue?: any
|
|
42
|
+
};
|
|
43
|
+
type TypeFieldPointer<T extends WabeTypes> = {
|
|
44
|
+
type: "Pointer"
|
|
45
|
+
class: keyof T["types"]
|
|
46
|
+
};
|
|
47
|
+
type TypeFieldRelation<T extends WabeTypes> = {
|
|
48
|
+
type: "Relation"
|
|
49
|
+
class: keyof T["types"]
|
|
50
|
+
};
|
|
51
|
+
type TypeFieldFile = {
|
|
52
|
+
type: "File"
|
|
53
|
+
};
|
|
54
|
+
type TypeFieldCustomScalars<T extends WabeTypes> = {
|
|
55
|
+
type: T["scalars"]
|
|
56
|
+
required?: boolean
|
|
57
|
+
defaultValue?: any
|
|
58
|
+
};
|
|
59
|
+
type TypeFieldCustomEnums<T extends WabeTypes> = {
|
|
60
|
+
type: keyof T["enums"]
|
|
61
|
+
defaultValue?: any
|
|
62
|
+
};
|
|
63
|
+
export type TypeField<T extends WabeTypes> = (TypeFieldBase<string, "String"> | TypeFieldBase<number, "Int"> | TypeFieldBase<number, "Float"> | TypeFieldBase<boolean, "Boolean"> | TypeFieldBase<Date, "Date"> | TypeFieldBase<string, "Email"> | TypeFieldBase<string, "Phone"> | TypeFieldArray<T> | TypeFieldObject<T> | TypeFieldPointer<T> | TypeFieldRelation<T> | TypeFieldFile | TypeFieldCustomScalars<T> | TypeFieldCustomEnums<T>) & FieldBase<T>;
|
|
64
|
+
export type SchemaFields<T extends WabeTypes> = Record<string, TypeField<T>>;
|
|
65
|
+
export type ResolverType<T extends WabeTypes> = {
|
|
66
|
+
required?: boolean
|
|
67
|
+
description?: string
|
|
68
|
+
resolve: (...args: any) => any
|
|
69
|
+
} & ({
|
|
70
|
+
type: WabePrimaryTypes | T["enums"] | T["scalars"]
|
|
71
|
+
} | {
|
|
72
|
+
type: "Object"
|
|
73
|
+
outputObject: ClassInterface<T>
|
|
74
|
+
} | {
|
|
75
|
+
type: "Array"
|
|
76
|
+
typeValue: WabePrimaryTypes
|
|
77
|
+
typeValueRequired?: boolean
|
|
78
|
+
} | {
|
|
79
|
+
type: "Array"
|
|
80
|
+
typeValue: "Object"
|
|
81
|
+
outputObject: ClassInterface<T>
|
|
82
|
+
typeValueRequired?: boolean
|
|
83
|
+
});
|
|
84
|
+
export type QueryResolver<T extends WabeTypes> = {
|
|
85
|
+
args?: SchemaFields<T>
|
|
86
|
+
} & ResolverType<T>;
|
|
87
|
+
export type MutationResolver<T extends WabeTypes> = {
|
|
88
|
+
args?: {
|
|
89
|
+
input: SchemaFields<T>
|
|
90
|
+
}
|
|
91
|
+
} & ResolverType<T>;
|
|
92
|
+
export type TypeResolver<T extends WabeTypes> = {
|
|
93
|
+
queries?: {
|
|
94
|
+
[key: string]: QueryResolver<T>
|
|
95
|
+
}
|
|
96
|
+
mutations?: {
|
|
97
|
+
[key: string]: MutationResolver<T>
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export type PermissionsOperations = "create" | "read" | "update" | "delete";
|
|
101
|
+
export interface PermissionProperties<T extends WabeTypes> {
|
|
102
|
+
requireAuthentication?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* An empty array means that none role is authorized (except root client)
|
|
105
|
+
*/
|
|
106
|
+
authorizedRoles?: Array<T["enums"]["RoleEnum"] | "everyone">;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* ACL properties
|
|
110
|
+
* Callback to define the ACL object before insert of the object in the database
|
|
111
|
+
* Can be done with a beforeCreate hook but for simplicity we can define it here
|
|
112
|
+
*/
|
|
113
|
+
export type ACLProperties = (hookObject: HookObject<any, any>) => void | Promise<void>;
|
|
114
|
+
export type ClassPermissions<T extends WabeTypes> = Partial<Record<PermissionsOperations, PermissionProperties<T>> & {
|
|
115
|
+
acl: ACLProperties
|
|
116
|
+
}>;
|
|
117
|
+
export type SearchableFields = Array<string>;
|
|
118
|
+
export type ClassIndexes = Array<{
|
|
119
|
+
field: string
|
|
120
|
+
order: "ASC" | "DESC"
|
|
121
|
+
unique?: boolean
|
|
122
|
+
}>;
|
|
123
|
+
export interface ClassInterface<T extends WabeTypes> {
|
|
124
|
+
name: string;
|
|
125
|
+
fields: SchemaFields<T>;
|
|
126
|
+
description?: string;
|
|
127
|
+
permissions?: ClassPermissions<T>;
|
|
128
|
+
searchableFields?: SearchableFields;
|
|
129
|
+
indexes?: ClassIndexes;
|
|
130
|
+
}
|
|
131
|
+
export interface ScalarInterface {
|
|
132
|
+
name: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
parseValue?: (value: any) => any;
|
|
135
|
+
serialize?: (value: any) => any;
|
|
136
|
+
parseLiteral?: (ast: any) => any;
|
|
137
|
+
}
|
|
138
|
+
export interface EnumInterface {
|
|
139
|
+
name: string;
|
|
140
|
+
values: Record<string, string>;
|
|
141
|
+
description?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface SchemaInterface<T extends WabeTypes> {
|
|
144
|
+
classes?: ClassInterface<T>[];
|
|
145
|
+
scalars?: ScalarInterface[];
|
|
146
|
+
enums?: EnumInterface[];
|
|
147
|
+
resolvers?: TypeResolver<T>;
|
|
148
|
+
}
|
|
149
|
+
export declare class Schema<T extends WabeTypes> {
|
|
150
|
+
schema: SchemaInterface<T>;
|
|
151
|
+
private config;
|
|
152
|
+
constructor(config: WabeConfig<T>);
|
|
153
|
+
defaultEnum(): EnumInterface[];
|
|
154
|
+
mergeResolvers(defaultResolvers: TypeResolver<T>): TypeResolver<T>;
|
|
155
|
+
defaultResolvers(): TypeResolver<T>;
|
|
156
|
+
sessionClass(): ClassInterface<T>;
|
|
157
|
+
roleClass(): ClassInterface<T>;
|
|
158
|
+
internalConfigClass(): ClassInterface<T>;
|
|
159
|
+
userClass(): ClassInterface<T>;
|
|
160
|
+
defaultFields(): SchemaFields<T>;
|
|
161
|
+
mergeClass(newClass: ClassInterface<T>[]): ClassInterface<T>[];
|
|
162
|
+
defaultClass(schema?: SchemaInterface<T>): ClassInterface<T>[];
|
|
163
|
+
}
|
|
164
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Schema";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const meResolver: unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resetPasswordResolver: unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sendEmailResolver: unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sendOtpCodeResolver: unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defaultSessionHandler: unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateCodegen: unknown;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { DatabaseConfig } from "../database";
|
|
2
|
+
import { DatabaseController } from "../database/controllers/DatabaseController";
|
|
3
|
+
import { type SchemaInterface } from "../schema/Schema";
|
|
4
|
+
import { GraphQLSchema } from "graphql";
|
|
5
|
+
import type { AuthenticationConfig } from "../authentication/interface";
|
|
6
|
+
import { type WabeRoute } from "./routes";
|
|
7
|
+
import { type Hook } from "../hooks";
|
|
8
|
+
import { generateCodegen } from "./generateCodegen";
|
|
9
|
+
import { Wobe } from "wobe";
|
|
10
|
+
import type { Context, CorsOptions, RateLimitOptions } from "wobe";
|
|
11
|
+
import type { WabeContext } from "./interface";
|
|
12
|
+
import type { FileConfig } from "../files";
|
|
13
|
+
import type { EmailConfig } from "../email";
|
|
14
|
+
import { EmailController } from "../email/EmailController";
|
|
15
|
+
import type { PaymentConfig } from "../payment/interface";
|
|
16
|
+
import { PaymentController } from "../payment/PaymentController";
|
|
17
|
+
import type { AIConfig } from "../ai";
|
|
18
|
+
import { FileController } from "../files/FileController";
|
|
19
|
+
import type { CronConfig } from "../cron";
|
|
20
|
+
type SecurityConfig = {
|
|
21
|
+
corsOptions?: CorsOptions
|
|
22
|
+
rateLimit?: RateLimitOptions
|
|
23
|
+
maskErrorMessage?: boolean
|
|
24
|
+
};
|
|
25
|
+
export interface WabeConfig<T extends WabeTypes> {
|
|
26
|
+
port: number;
|
|
27
|
+
isProduction: boolean;
|
|
28
|
+
hostname?: string;
|
|
29
|
+
security?: SecurityConfig;
|
|
30
|
+
schema?: SchemaInterface<T>;
|
|
31
|
+
graphqlSchema?: GraphQLSchema;
|
|
32
|
+
database: DatabaseConfig;
|
|
33
|
+
codegen?: {
|
|
34
|
+
enabled: true
|
|
35
|
+
path: string
|
|
36
|
+
} | {
|
|
37
|
+
enabled?: false
|
|
38
|
+
};
|
|
39
|
+
authentication?: AuthenticationConfig<T>;
|
|
40
|
+
routes?: WabeRoute[];
|
|
41
|
+
rootKey: string;
|
|
42
|
+
hooks?: Hook<T, any>[];
|
|
43
|
+
email?: EmailConfig;
|
|
44
|
+
payment?: PaymentConfig;
|
|
45
|
+
ai?: AIConfig;
|
|
46
|
+
file?: FileConfig;
|
|
47
|
+
crons?: CronConfig<T>;
|
|
48
|
+
}
|
|
49
|
+
export type WabeTypes = {
|
|
50
|
+
types: Record<any, any>
|
|
51
|
+
where: Record<any, any>
|
|
52
|
+
scalars: string
|
|
53
|
+
enums: Record<any, any>
|
|
54
|
+
};
|
|
55
|
+
export type WobeCustomContext<T extends WabeTypes> = Context & {
|
|
56
|
+
wabe: WabeContext<T>
|
|
57
|
+
};
|
|
58
|
+
type WabeControllers<T extends WabeTypes> = {
|
|
59
|
+
database: DatabaseController<T>
|
|
60
|
+
email?: EmailController
|
|
61
|
+
payment?: PaymentController
|
|
62
|
+
file?: FileController
|
|
63
|
+
};
|
|
64
|
+
export declare class Wabe<T extends WabeTypes> {
|
|
65
|
+
server: Wobe<WobeCustomContext<T>>;
|
|
66
|
+
config: WabeConfig<T>;
|
|
67
|
+
controllers: WabeControllers<T>;
|
|
68
|
+
constructor({ isProduction, port, hostname, security, schema, database, authentication, rootKey, codegen, hooks, file, email, payment, routes, crons }: WabeConfig<T>);
|
|
69
|
+
loadCrons();
|
|
70
|
+
loadRoleEnum();
|
|
71
|
+
loadAuthenticationMethods();
|
|
72
|
+
loadHooks();
|
|
73
|
+
loadRoutes();
|
|
74
|
+
start();
|
|
75
|
+
close();
|
|
76
|
+
}
|
|
77
|
+
export { generateCodegen };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type WobeHandler } from "wobe";
|
|
2
|
+
import type { WobeCustomContext } from "..";
|
|
3
|
+
export interface WabeRoute {
|
|
4
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
5
|
+
path: string;
|
|
6
|
+
handler: WobeHandler<WobeCustomContext<any>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const defaultRoutes: (devDirectory: string) => WabeRoute[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GraphQLClient } from "graphql-request";
|
|
2
|
+
import { type WabeSchemaWhereTypes, type WabeSchemaEnums, type WabeSchemaScalars, type WabeSchemaTypes } from "../../generated/wabe";
|
|
3
|
+
import { Wabe, type WabeTypes } from "../server";
|
|
4
|
+
export interface DevWabeTypes extends WabeTypes {
|
|
5
|
+
types: WabeSchemaTypes;
|
|
6
|
+
scalars: WabeSchemaScalars;
|
|
7
|
+
enums: WabeSchemaEnums;
|
|
8
|
+
where: WabeSchemaWhereTypes;
|
|
9
|
+
}
|
|
10
|
+
export declare const firstLetterUpperCase: (str: string) => string;
|
|
11
|
+
export declare const notEmpty: <T>(value: T | null | undefined) => value is T;
|
|
12
|
+
export declare const getGraphqlClient: (port: number) => GraphQLClient;
|
|
13
|
+
export declare const getAnonymousClient: (port: number) => GraphQLClient;
|
|
14
|
+
export declare const getUserClient: (port: number, accessToken: string) => GraphQLClient;
|
|
15
|
+
export declare const getAdminUserClient: (port: number, wabe: Wabe<DevWabeTypes>, { email, password }: {
|
|
16
|
+
email: string
|
|
17
|
+
password: string
|
|
18
|
+
}) => Promise<GraphQLClient>;
|
|
19
|
+
export declare const setupTests: unknown;
|
|
20
|
+
export declare const closeTests: unknown;
|
|
21
|
+
export declare const createUserAndUpdateRole: unknown;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ClassInterface } from "../schema";
|
|
2
|
+
import type { WabeTypes, WabeConfig } from "../server";
|
|
3
|
+
export declare const firstLetterInUpperCase: unknown;
|
|
4
|
+
export declare const firstLetterInLowerCase: unknown;
|
|
5
|
+
export declare const getClassFromClassName: <T extends WabeTypes>(className: string, config: WabeConfig<any>) => ClassInterface<T>;
|
|
6
|
+
export declare const getCookieInRequestHeaders: unknown;
|
|
7
|
+
/**
|
|
8
|
+
* This apply the following transformations on string:
|
|
9
|
+
* - lowercase
|
|
10
|
+
* - normalize with NFD
|
|
11
|
+
* - remove diacritics and accents characters
|
|
12
|
+
* - replace matching abbreviation with long version (if disableAbbrevations is not set)
|
|
13
|
+
* - replace 2 or more spaces by one
|
|
14
|
+
* - replace all non alpha characters by a space
|
|
15
|
+
* - trim
|
|
16
|
+
*/
|
|
17
|
+
export declare const tokenize: unknown;
|