wabe 0.6.12 → 0.6.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.
Files changed (156) hide show
  1. package/dist/database/DatabaseController.d.ts +2 -0
  2. package/dist/file/FileDevAdapter.d.ts +1 -0
  3. package/dist/graphql/pointerAndRelationFunction.d.ts +6 -0
  4. package/dist/index.js +3827 -3541
  5. package/dist/schema/Schema.d.ts +2 -2
  6. package/dist/server/generateCodegen.d.ts +10 -0
  7. package/dist/server/index.d.ts +2 -1
  8. package/dist/utils/objectKeys.d.ts +1 -0
  9. package/package.json +7 -4
  10. package/dev/index.ts +0 -215
  11. package/dist/schema/resolvers/sendEmail.d.ts +0 -1
  12. package/generated/schema.graphql +0 -1945
  13. package/generated/wabe.ts +0 -448
  14. package/src/authentication/OTP.test.ts +0 -69
  15. package/src/authentication/OTP.ts +0 -64
  16. package/src/authentication/Session.test.ts +0 -629
  17. package/src/authentication/Session.ts +0 -517
  18. package/src/authentication/cookies.ts +0 -10
  19. package/src/authentication/defaultAuthentication.ts +0 -209
  20. package/src/authentication/index.ts +0 -4
  21. package/src/authentication/interface.ts +0 -177
  22. package/src/authentication/oauth/GitHub.test.ts +0 -91
  23. package/src/authentication/oauth/GitHub.ts +0 -121
  24. package/src/authentication/oauth/Google.test.ts +0 -91
  25. package/src/authentication/oauth/Google.ts +0 -101
  26. package/src/authentication/oauth/Oauth2Client.test.ts +0 -219
  27. package/src/authentication/oauth/Oauth2Client.ts +0 -135
  28. package/src/authentication/oauth/index.ts +0 -2
  29. package/src/authentication/oauth/utils.test.ts +0 -33
  30. package/src/authentication/oauth/utils.ts +0 -27
  31. package/src/authentication/providers/EmailOTP.test.ts +0 -127
  32. package/src/authentication/providers/EmailOTP.ts +0 -95
  33. package/src/authentication/providers/EmailPassword.test.ts +0 -263
  34. package/src/authentication/providers/EmailPassword.ts +0 -138
  35. package/src/authentication/providers/EmailPasswordSRP.test.ts +0 -208
  36. package/src/authentication/providers/EmailPasswordSRP.ts +0 -191
  37. package/src/authentication/providers/GitHub.ts +0 -24
  38. package/src/authentication/providers/Google.ts +0 -24
  39. package/src/authentication/providers/OAuth.test.ts +0 -185
  40. package/src/authentication/providers/OAuth.ts +0 -106
  41. package/src/authentication/providers/PhonePassword.test.ts +0 -221
  42. package/src/authentication/providers/PhonePassword.ts +0 -136
  43. package/src/authentication/providers/QRCodeOTP.test.ts +0 -77
  44. package/src/authentication/providers/QRCodeOTP.ts +0 -69
  45. package/src/authentication/providers/index.ts +0 -6
  46. package/src/authentication/resolvers/refreshResolver.test.ts +0 -30
  47. package/src/authentication/resolvers/refreshResolver.ts +0 -19
  48. package/src/authentication/resolvers/signInWithResolver.inte.test.ts +0 -59
  49. package/src/authentication/resolvers/signInWithResolver.test.ts +0 -306
  50. package/src/authentication/resolvers/signInWithResolver.ts +0 -106
  51. package/src/authentication/resolvers/signOutResolver.test.ts +0 -38
  52. package/src/authentication/resolvers/signOutResolver.ts +0 -18
  53. package/src/authentication/resolvers/signUpWithResolver.test.ts +0 -180
  54. package/src/authentication/resolvers/signUpWithResolver.ts +0 -68
  55. package/src/authentication/resolvers/verifyChallenge.test.ts +0 -230
  56. package/src/authentication/resolvers/verifyChallenge.ts +0 -78
  57. package/src/authentication/roles.test.ts +0 -49
  58. package/src/authentication/roles.ts +0 -40
  59. package/src/authentication/security.ts +0 -278
  60. package/src/authentication/utils.test.ts +0 -97
  61. package/src/authentication/utils.ts +0 -39
  62. package/src/cache/InMemoryCache.test.ts +0 -62
  63. package/src/cache/InMemoryCache.ts +0 -45
  64. package/src/cron/index.test.ts +0 -17
  65. package/src/cron/index.ts +0 -43
  66. package/src/database/DatabaseController.test.ts +0 -613
  67. package/src/database/DatabaseController.ts +0 -1415
  68. package/src/database/index.test.ts +0 -1551
  69. package/src/database/index.ts +0 -9
  70. package/src/database/interface.ts +0 -308
  71. package/src/email/DevAdapter.ts +0 -7
  72. package/src/email/EmailController.test.ts +0 -29
  73. package/src/email/EmailController.ts +0 -13
  74. package/src/email/index.ts +0 -2
  75. package/src/email/interface.ts +0 -36
  76. package/src/email/templates/sendOtpCode.ts +0 -120
  77. package/src/file/FileController.ts +0 -28
  78. package/src/file/FileDevAdapter.ts +0 -51
  79. package/src/file/hookDeleteFile.ts +0 -25
  80. package/src/file/hookReadFile.ts +0 -66
  81. package/src/file/hookUploadFile.ts +0 -52
  82. package/src/file/index.test.ts +0 -1031
  83. package/src/file/index.ts +0 -2
  84. package/src/file/interface.ts +0 -63
  85. package/src/file/security.ts +0 -156
  86. package/src/graphql/GraphQLSchema.test.ts +0 -5099
  87. package/src/graphql/GraphQLSchema.ts +0 -886
  88. package/src/graphql/index.ts +0 -2
  89. package/src/graphql/parseGraphqlSchema.ts +0 -85
  90. package/src/graphql/parser.test.ts +0 -203
  91. package/src/graphql/parser.ts +0 -707
  92. package/src/graphql/pointerAndRelationFunction.ts +0 -191
  93. package/src/graphql/resolvers.ts +0 -464
  94. package/src/graphql/tests/aggregation.test.ts +0 -1115
  95. package/src/graphql/tests/e2e.test.ts +0 -590
  96. package/src/graphql/tests/scalars.test.ts +0 -250
  97. package/src/graphql/types.ts +0 -227
  98. package/src/hooks/HookObject.test.ts +0 -122
  99. package/src/hooks/HookObject.ts +0 -165
  100. package/src/hooks/authentication.ts +0 -67
  101. package/src/hooks/createUser.test.ts +0 -77
  102. package/src/hooks/createUser.ts +0 -10
  103. package/src/hooks/defaultFields.test.ts +0 -176
  104. package/src/hooks/defaultFields.ts +0 -32
  105. package/src/hooks/deleteSession.test.ts +0 -181
  106. package/src/hooks/deleteSession.ts +0 -20
  107. package/src/hooks/hashFieldHook.test.ts +0 -152
  108. package/src/hooks/hashFieldHook.ts +0 -89
  109. package/src/hooks/index.test.ts +0 -258
  110. package/src/hooks/index.ts +0 -420
  111. package/src/hooks/permissions.test.ts +0 -412
  112. package/src/hooks/permissions.ts +0 -93
  113. package/src/hooks/protected.test.ts +0 -551
  114. package/src/hooks/protected.ts +0 -74
  115. package/src/hooks/searchableFields.test.ts +0 -147
  116. package/src/hooks/searchableFields.ts +0 -86
  117. package/src/hooks/session.test.ts +0 -134
  118. package/src/hooks/session.ts +0 -76
  119. package/src/hooks/setEmail.test.ts +0 -216
  120. package/src/hooks/setEmail.ts +0 -33
  121. package/src/hooks/setupAcl.test.ts +0 -618
  122. package/src/hooks/setupAcl.ts +0 -25
  123. package/src/hooks/virtualFields.test.ts +0 -228
  124. package/src/hooks/virtualFields.ts +0 -48
  125. package/src/index.ts +0 -9
  126. package/src/schema/Schema.test.ts +0 -482
  127. package/src/schema/Schema.ts +0 -839
  128. package/src/schema/defaultResolvers.ts +0 -93
  129. package/src/schema/index.ts +0 -1
  130. package/src/schema/resolvers/meResolver.test.ts +0 -62
  131. package/src/schema/resolvers/meResolver.ts +0 -10
  132. package/src/schema/resolvers/resetPassword.test.ts +0 -341
  133. package/src/schema/resolvers/resetPassword.ts +0 -63
  134. package/src/schema/resolvers/sendEmail.test.ts +0 -118
  135. package/src/schema/resolvers/sendEmail.ts +0 -21
  136. package/src/schema/resolvers/sendOtpCode.test.ts +0 -141
  137. package/src/schema/resolvers/sendOtpCode.ts +0 -52
  138. package/src/security.test.ts +0 -4136
  139. package/src/server/defaultSessionHandler.test.ts +0 -62
  140. package/src/server/defaultSessionHandler.ts +0 -104
  141. package/src/server/generateCodegen.ts +0 -433
  142. package/src/server/index.test.ts +0 -843
  143. package/src/server/index.ts +0 -336
  144. package/src/server/interface.ts +0 -11
  145. package/src/server/routes/authHandler.ts +0 -171
  146. package/src/server/routes/index.ts +0 -48
  147. package/src/utils/crypto.test.ts +0 -41
  148. package/src/utils/crypto.ts +0 -105
  149. package/src/utils/database.ts +0 -8
  150. package/src/utils/export.ts +0 -12
  151. package/src/utils/helper.ts +0 -204
  152. package/src/utils/index.test.ts +0 -11
  153. package/src/utils/index.ts +0 -196
  154. package/src/utils/preload.ts +0 -8
  155. package/src/utils/testHelper.ts +0 -124
  156. package/tsconfig.json +0 -32
@@ -1,2 +0,0 @@
1
- export * from './types'
2
- export * from './GraphQLSchema'
@@ -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
- })