wabe 0.6.11 → 0.6.13
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/authentication/Session.d.ts +10 -12
- package/dist/authentication/cookies.d.ts +1 -0
- package/dist/authentication/index.d.ts +1 -0
- package/dist/authentication/interface.d.ts +20 -0
- package/dist/authentication/security.d.ts +18 -0
- package/dist/database/DatabaseController.d.ts +57 -3
- package/dist/database/interface.d.ts +5 -0
- package/dist/file/interface.d.ts +23 -0
- package/dist/file/security.d.ts +6 -0
- package/dist/graphql/GraphQLSchema.d.ts +1 -1
- package/dist/graphql/resolvers.d.ts +1 -0
- package/dist/hooks/protected.d.ts +3 -0
- package/dist/hooks/virtualFields.d.ts +3 -0
- package/dist/index.js +1757 -818
- package/dist/schema/Schema.d.ts +66 -7
- package/dist/server/index.d.ts +2 -1
- package/dist/server/routes/index.d.ts +4 -1
- package/dist/utils/database.d.ts +1 -0
- package/dist/utils/export.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +7 -4
- package/bucket/b.txt +0 -1
- package/dev/index.ts +0 -215
- package/generated/schema.graphql +0 -1892
- package/generated/wabe.ts +0 -439
- package/src/authentication/OTP.test.ts +0 -69
- package/src/authentication/OTP.ts +0 -64
- package/src/authentication/Session.test.ts +0 -629
- package/src/authentication/Session.ts +0 -493
- package/src/authentication/defaultAuthentication.ts +0 -209
- package/src/authentication/index.ts +0 -3
- package/src/authentication/interface.ts +0 -155
- package/src/authentication/oauth/GitHub.test.ts +0 -91
- package/src/authentication/oauth/GitHub.ts +0 -121
- package/src/authentication/oauth/Google.test.ts +0 -91
- package/src/authentication/oauth/Google.ts +0 -101
- package/src/authentication/oauth/Oauth2Client.test.ts +0 -219
- package/src/authentication/oauth/Oauth2Client.ts +0 -135
- package/src/authentication/oauth/index.ts +0 -2
- package/src/authentication/oauth/utils.test.ts +0 -33
- package/src/authentication/oauth/utils.ts +0 -27
- package/src/authentication/providers/EmailOTP.test.ts +0 -127
- package/src/authentication/providers/EmailOTP.ts +0 -84
- package/src/authentication/providers/EmailPassword.test.ts +0 -176
- package/src/authentication/providers/EmailPassword.ts +0 -116
- package/src/authentication/providers/EmailPasswordSRP.test.ts +0 -208
- package/src/authentication/providers/EmailPasswordSRP.ts +0 -179
- package/src/authentication/providers/GitHub.ts +0 -24
- package/src/authentication/providers/Google.ts +0 -24
- package/src/authentication/providers/OAuth.test.ts +0 -185
- package/src/authentication/providers/OAuth.ts +0 -106
- package/src/authentication/providers/PhonePassword.test.ts +0 -176
- package/src/authentication/providers/PhonePassword.ts +0 -115
- package/src/authentication/providers/QRCodeOTP.test.ts +0 -77
- package/src/authentication/providers/QRCodeOTP.ts +0 -58
- package/src/authentication/providers/index.ts +0 -6
- package/src/authentication/resolvers/refreshResolver.test.ts +0 -30
- package/src/authentication/resolvers/refreshResolver.ts +0 -19
- package/src/authentication/resolvers/signInWithResolver.inte.test.ts +0 -59
- package/src/authentication/resolvers/signInWithResolver.test.ts +0 -293
- package/src/authentication/resolvers/signInWithResolver.ts +0 -92
- package/src/authentication/resolvers/signOutResolver.test.ts +0 -38
- package/src/authentication/resolvers/signOutResolver.ts +0 -18
- package/src/authentication/resolvers/signUpWithResolver.test.ts +0 -180
- package/src/authentication/resolvers/signUpWithResolver.ts +0 -65
- package/src/authentication/resolvers/verifyChallenge.test.ts +0 -133
- package/src/authentication/resolvers/verifyChallenge.ts +0 -62
- package/src/authentication/roles.test.ts +0 -49
- package/src/authentication/roles.ts +0 -40
- package/src/authentication/utils.test.ts +0 -97
- package/src/authentication/utils.ts +0 -39
- package/src/cache/InMemoryCache.test.ts +0 -62
- package/src/cache/InMemoryCache.ts +0 -45
- package/src/cron/index.test.ts +0 -17
- package/src/cron/index.ts +0 -43
- package/src/database/DatabaseController.test.ts +0 -613
- package/src/database/DatabaseController.ts +0 -1007
- package/src/database/index.test.ts +0 -1372
- package/src/database/index.ts +0 -9
- package/src/database/interface.ts +0 -302
- package/src/email/DevAdapter.ts +0 -7
- package/src/email/EmailController.test.ts +0 -29
- package/src/email/EmailController.ts +0 -13
- package/src/email/index.ts +0 -2
- package/src/email/interface.ts +0 -36
- package/src/email/templates/sendOtpCode.ts +0 -120
- package/src/file/FileController.ts +0 -28
- package/src/file/FileDevAdapter.ts +0 -51
- package/src/file/hookDeleteFile.ts +0 -25
- package/src/file/hookReadFile.ts +0 -66
- package/src/file/hookUploadFile.ts +0 -50
- package/src/file/index.test.ts +0 -932
- package/src/file/index.ts +0 -2
- package/src/file/interface.ts +0 -39
- package/src/graphql/GraphQLSchema.test.ts +0 -4408
- package/src/graphql/GraphQLSchema.ts +0 -880
- package/src/graphql/index.ts +0 -2
- package/src/graphql/parseGraphqlSchema.ts +0 -85
- package/src/graphql/parser.test.ts +0 -203
- package/src/graphql/parser.ts +0 -542
- package/src/graphql/pointerAndRelationFunction.ts +0 -191
- package/src/graphql/resolvers.ts +0 -442
- package/src/graphql/tests/aggregation.test.ts +0 -1115
- package/src/graphql/tests/e2e.test.ts +0 -590
- package/src/graphql/tests/scalars.test.ts +0 -250
- package/src/graphql/types.ts +0 -227
- package/src/hooks/HookObject.test.ts +0 -122
- package/src/hooks/HookObject.ts +0 -165
- package/src/hooks/authentication.ts +0 -67
- package/src/hooks/createUser.test.ts +0 -77
- package/src/hooks/createUser.ts +0 -10
- package/src/hooks/defaultFields.test.ts +0 -176
- package/src/hooks/defaultFields.ts +0 -32
- package/src/hooks/deleteSession.test.ts +0 -181
- package/src/hooks/deleteSession.ts +0 -20
- package/src/hooks/hashFieldHook.test.ts +0 -152
- package/src/hooks/hashFieldHook.ts +0 -89
- package/src/hooks/index.test.ts +0 -258
- package/src/hooks/index.ts +0 -414
- package/src/hooks/permissions.test.ts +0 -412
- package/src/hooks/permissions.ts +0 -93
- package/src/hooks/protected.test.ts +0 -551
- package/src/hooks/protected.ts +0 -60
- package/src/hooks/searchableFields.test.ts +0 -147
- package/src/hooks/searchableFields.ts +0 -86
- package/src/hooks/session.test.ts +0 -134
- package/src/hooks/session.ts +0 -76
- package/src/hooks/setEmail.test.ts +0 -216
- package/src/hooks/setEmail.ts +0 -33
- package/src/hooks/setupAcl.test.ts +0 -618
- package/src/hooks/setupAcl.ts +0 -25
- package/src/index.ts +0 -9
- package/src/schema/Schema.test.ts +0 -482
- package/src/schema/Schema.ts +0 -757
- package/src/schema/defaultResolvers.ts +0 -93
- package/src/schema/index.ts +0 -1
- package/src/schema/resolvers/meResolver.test.ts +0 -62
- package/src/schema/resolvers/meResolver.ts +0 -10
- package/src/schema/resolvers/resetPassword.test.ts +0 -341
- package/src/schema/resolvers/resetPassword.ts +0 -63
- package/src/schema/resolvers/sendEmail.test.ts +0 -118
- package/src/schema/resolvers/sendEmail.ts +0 -21
- package/src/schema/resolvers/sendOtpCode.test.ts +0 -141
- package/src/schema/resolvers/sendOtpCode.ts +0 -52
- package/src/security.test.ts +0 -3434
- package/src/server/defaultSessionHandler.test.ts +0 -62
- package/src/server/defaultSessionHandler.ts +0 -105
- package/src/server/generateCodegen.ts +0 -433
- package/src/server/index.test.ts +0 -532
- package/src/server/index.ts +0 -334
- package/src/server/interface.ts +0 -11
- package/src/server/routes/authHandler.ts +0 -169
- package/src/server/routes/index.ts +0 -39
- package/src/utils/crypto.test.ts +0 -41
- package/src/utils/crypto.ts +0 -105
- package/src/utils/export.ts +0 -11
- package/src/utils/helper.ts +0 -204
- package/src/utils/index.test.ts +0 -11
- package/src/utils/index.ts +0 -189
- package/src/utils/preload.ts +0 -8
- package/src/utils/testHelper.ts +0 -116
- package/tsconfig.json +0 -32
package/src/graphql/index.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { GraphQLSchema } from 'graphql'
|
|
2
|
-
|
|
3
|
-
export interface GraphqlSchemaOutput {
|
|
4
|
-
input: Record<string, string>
|
|
5
|
-
output?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const _getQueryFields = (name: string, schema: GraphQLSchema): GraphqlSchemaOutput => {
|
|
9
|
-
const query = schema.getQueryType()?.getFields()[name]
|
|
10
|
-
|
|
11
|
-
if (!query) throw new Error('Type not found in schema')
|
|
12
|
-
|
|
13
|
-
const inputFields = query.args.reduce(
|
|
14
|
-
(acc, arg) => ({ ...acc, [arg.name]: arg.type.toString() }),
|
|
15
|
-
{},
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const outputFields = query.type.toString()
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
input: inputFields,
|
|
22
|
-
output: outputFields,
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const _getMutationFields = (name: string, schema: GraphQLSchema): GraphqlSchemaOutput => {
|
|
27
|
-
const mutation = schema.getMutationType()?.getFields()[name]
|
|
28
|
-
|
|
29
|
-
if (!mutation) throw new Error('Type not found in schema')
|
|
30
|
-
|
|
31
|
-
const inputFields = mutation.args.reduce(
|
|
32
|
-
(acc, arg) => ({ ...acc, [arg.name]: arg.type.toString() }),
|
|
33
|
-
{},
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
const outputFields = mutation.type.toString()
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
input: inputFields,
|
|
40
|
-
output: outputFields,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const _getTypeFields = (name: string, schema: GraphQLSchema): GraphqlSchemaOutput => {
|
|
45
|
-
const type = schema.getType(name)
|
|
46
|
-
|
|
47
|
-
if (!type) throw new Error('Type not found in schema')
|
|
48
|
-
|
|
49
|
-
// @ts-expect-error
|
|
50
|
-
const fields = (type?.getFields?.() || {}) as Record<string, any>
|
|
51
|
-
|
|
52
|
-
const formattedFields = Object.entries(fields).reduce(
|
|
53
|
-
(acc, [fieldName, fieldType]) => ({
|
|
54
|
-
...acc,
|
|
55
|
-
[fieldName]: fieldType.type.toString(),
|
|
56
|
-
}),
|
|
57
|
-
{},
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
input: formattedFields,
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const getTypeFromGraphQLSchema = ({
|
|
66
|
-
type,
|
|
67
|
-
name,
|
|
68
|
-
schema,
|
|
69
|
-
}: {
|
|
70
|
-
type: 'Type' | 'Query' | 'Mutation'
|
|
71
|
-
name: string
|
|
72
|
-
filter?: Array<string>
|
|
73
|
-
schema: GraphQLSchema
|
|
74
|
-
}): GraphqlSchemaOutput => {
|
|
75
|
-
switch (type) {
|
|
76
|
-
case 'Query':
|
|
77
|
-
return _getQueryFields(name, schema)
|
|
78
|
-
case 'Mutation':
|
|
79
|
-
return _getMutationFields(name, schema)
|
|
80
|
-
case 'Type':
|
|
81
|
-
return _getTypeFields(name, schema)
|
|
82
|
-
default:
|
|
83
|
-
throw new Error('Not implemented')
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test'
|
|
2
|
-
import { GraphqlParser } from './parser'
|
|
3
|
-
import { GraphQLNonNull, type GraphQLNullableType, GraphQLObjectType, GraphQLString } from 'graphql'
|
|
4
|
-
|
|
5
|
-
const deepCompareGraphQLObjects = (
|
|
6
|
-
obj1: GraphQLNullableType,
|
|
7
|
-
obj2: GraphQLNullableType,
|
|
8
|
-
): boolean => {
|
|
9
|
-
// Check if both objects are instances of GraphQLObjectType or GraphQLNonNull
|
|
10
|
-
if (
|
|
11
|
-
(!(obj1 instanceof GraphQLObjectType) && !(obj1 instanceof GraphQLNonNull)) ||
|
|
12
|
-
(!(obj2 instanceof GraphQLObjectType) && !(obj2 instanceof GraphQLNonNull))
|
|
13
|
-
)
|
|
14
|
-
return false
|
|
15
|
-
|
|
16
|
-
// Unwrap GraphQLNonNull if present
|
|
17
|
-
const unwrappedObj1 = obj1 instanceof GraphQLNonNull ? obj1.ofType : obj1
|
|
18
|
-
const unwrappedObj2 = obj2 instanceof GraphQLNonNull ? obj2.ofType : obj2
|
|
19
|
-
|
|
20
|
-
// Compare type name
|
|
21
|
-
if (unwrappedObj1.name !== unwrappedObj2.name) return false
|
|
22
|
-
|
|
23
|
-
// Compare description
|
|
24
|
-
if (unwrappedObj1.description !== unwrappedObj2.description) return false
|
|
25
|
-
|
|
26
|
-
// If both objects are GraphQLNonNull, recursively compare the wrapped types
|
|
27
|
-
if (obj1 instanceof GraphQLNonNull && obj2 instanceof GraphQLNonNull)
|
|
28
|
-
return deepCompareGraphQLObjects(unwrappedObj1, unwrappedObj2)
|
|
29
|
-
|
|
30
|
-
// If one object is GraphQLNonNull and the other is not, they are not equal
|
|
31
|
-
if (obj1 instanceof GraphQLNonNull || obj2 instanceof GraphQLNonNull) return false
|
|
32
|
-
|
|
33
|
-
// Compare fields if both objects are GraphQLObjectType
|
|
34
|
-
const fields1 = (obj1 as GraphQLObjectType).getFields()
|
|
35
|
-
const fields2 = (obj2 as GraphQLObjectType).getFields()
|
|
36
|
-
|
|
37
|
-
if (Object.keys(fields1).length !== Object.keys(fields2).length) return false
|
|
38
|
-
|
|
39
|
-
for (const fieldName in fields1) {
|
|
40
|
-
if (!fields2[fieldName]) return false
|
|
41
|
-
|
|
42
|
-
const field1 = fields1[fieldName]
|
|
43
|
-
const field2 = fields2[fieldName]
|
|
44
|
-
|
|
45
|
-
// Check field name
|
|
46
|
-
if (field1?.name !== field2?.name) return false
|
|
47
|
-
|
|
48
|
-
// Check field description
|
|
49
|
-
if (field1?.description !== field2?.description) return false
|
|
50
|
-
|
|
51
|
-
// Check field type
|
|
52
|
-
if (field1?.type.toString() !== field2?.type.toString()) return false
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return true
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
describe('WabeGraphqlParser', () => {
|
|
59
|
-
it('should parse a wabe object', () => {
|
|
60
|
-
const graphqlParser = GraphqlParser({
|
|
61
|
-
enums: [],
|
|
62
|
-
scalars: [],
|
|
63
|
-
})
|
|
64
|
-
const simpleObject = graphqlParser({
|
|
65
|
-
graphqlObjectType: {} as any,
|
|
66
|
-
schemaFields: {} as any,
|
|
67
|
-
allObjects: {} as any,
|
|
68
|
-
})._parseWabeObject({
|
|
69
|
-
description: 'A simple object',
|
|
70
|
-
required: true,
|
|
71
|
-
objectToParse: {
|
|
72
|
-
name: 'SimpleObject',
|
|
73
|
-
fields: {
|
|
74
|
-
name: { type: 'String', required: true },
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
nameOfTheObject: 'SimpleObject',
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const expectedObject = new GraphQLNonNull(
|
|
81
|
-
new GraphQLObjectType({
|
|
82
|
-
name: 'SimpleObject',
|
|
83
|
-
description: 'A simple object',
|
|
84
|
-
fields: {
|
|
85
|
-
name: {
|
|
86
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
expect(deepCompareGraphQLObjects(simpleObject, expectedObject)).toEqual(true)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should parse a recursive wabe object', () => {
|
|
96
|
-
const graphqlParser = GraphqlParser({
|
|
97
|
-
enums: [],
|
|
98
|
-
scalars: [],
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const recursiveObject = graphqlParser({
|
|
102
|
-
graphqlObjectType: {} as any,
|
|
103
|
-
schemaFields: {} as any,
|
|
104
|
-
allObjects: {} as any,
|
|
105
|
-
})._parseWabeObject({
|
|
106
|
-
description: 'A recursive object',
|
|
107
|
-
required: true,
|
|
108
|
-
objectToParse: {
|
|
109
|
-
name: 'RecursiveObject',
|
|
110
|
-
fields: {
|
|
111
|
-
subObject: {
|
|
112
|
-
type: 'Object',
|
|
113
|
-
object: {
|
|
114
|
-
name: 'SubObject',
|
|
115
|
-
fields: {
|
|
116
|
-
name: { type: 'String', required: true },
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
nameOfTheObject: 'RecursiveObject',
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
const expectedObject = new GraphQLNonNull(
|
|
126
|
-
new GraphQLObjectType({
|
|
127
|
-
name: 'RecursiveObject',
|
|
128
|
-
description: 'A recursive object',
|
|
129
|
-
fields: {
|
|
130
|
-
subObject: {
|
|
131
|
-
type: new GraphQLObjectType({
|
|
132
|
-
name: 'RecursiveObjectSubObject',
|
|
133
|
-
fields: {
|
|
134
|
-
name: {
|
|
135
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
}),
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
}),
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
expect(deepCompareGraphQLObjects(recursiveObject, expectedObject)).toEqual(true)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
it('should create an graphql object from simple object', () => {
|
|
148
|
-
const graphqlParser = GraphqlParser({
|
|
149
|
-
scalars: [],
|
|
150
|
-
enums: [],
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
const simpleObject = graphqlParser({
|
|
154
|
-
schemaFields: {
|
|
155
|
-
name: { type: 'String', required: true },
|
|
156
|
-
},
|
|
157
|
-
graphqlObjectType: 'Object',
|
|
158
|
-
allObjects: {},
|
|
159
|
-
}).getGraphqlFields('SimpleObject')
|
|
160
|
-
|
|
161
|
-
expect(simpleObject).toEqual({
|
|
162
|
-
name: {
|
|
163
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
164
|
-
},
|
|
165
|
-
} as any)
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('should create an graphql object from recursive object', () => {
|
|
169
|
-
const graphqlParser = GraphqlParser({
|
|
170
|
-
scalars: [],
|
|
171
|
-
enums: [],
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
const recursiveObject = graphqlParser({
|
|
175
|
-
schemaFields: {
|
|
176
|
-
subObject: {
|
|
177
|
-
type: 'Object',
|
|
178
|
-
object: {
|
|
179
|
-
name: 'SubObject',
|
|
180
|
-
fields: {
|
|
181
|
-
name: { type: 'String', required: true },
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
graphqlObjectType: 'Object',
|
|
187
|
-
allObjects: {},
|
|
188
|
-
}).getGraphqlFields('SimpleObject')
|
|
189
|
-
|
|
190
|
-
const expectedGraphqlObject = new GraphQLObjectType({
|
|
191
|
-
name: 'SimpleObjectSubObject',
|
|
192
|
-
fields: {
|
|
193
|
-
name: {
|
|
194
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
expect(
|
|
200
|
-
deepCompareGraphQLObjects(recursiveObject.subObject.type, expectedGraphqlObject),
|
|
201
|
-
).toEqual(true)
|
|
202
|
-
})
|
|
203
|
-
})
|