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