@nlabs/reaktor 0.10.9 → 1.2.1
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/LICENSE +201 -0
- package/README.md +1296 -110
- package/lib/actions/apps.d.ts +2 -3
- package/lib/actions/apps.d.ts.map +1 -1
- package/lib/actions/apps.js +126 -126
- package/lib/actions/connections.d.ts +4 -4
- package/lib/actions/connections.d.ts.map +1 -1
- package/lib/actions/connections.js +80 -14
- package/lib/actions/content.d.ts +1 -1
- package/lib/actions/content.d.ts.map +1 -1
- package/lib/actions/content.js +92 -119
- package/lib/actions/conversations.d.ts +4 -3
- package/lib/actions/conversations.d.ts.map +1 -1
- package/lib/actions/conversations.js +84 -80
- package/lib/actions/crud.d.ts +59 -0
- package/lib/actions/crud.d.ts.map +1 -0
- package/lib/actions/crud.js +413 -0
- package/lib/actions/dynamodb.js +2 -2
- package/lib/actions/email.js +1 -1
- package/lib/actions/files.d.ts +3 -3
- package/lib/actions/files.d.ts.map +1 -1
- package/lib/actions/files.js +9 -19
- package/lib/actions/groups.d.ts +11 -7
- package/lib/actions/groups.d.ts.map +1 -1
- package/lib/actions/groups.js +103 -90
- package/lib/actions/images.d.ts +9 -8
- package/lib/actions/images.d.ts.map +1 -1
- package/lib/actions/images.js +487 -268
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.d.ts.map +1 -1
- package/lib/actions/index.js +2 -1
- package/lib/actions/ios.js +8 -8
- package/lib/actions/locations.d.ts +1 -0
- package/lib/actions/locations.d.ts.map +1 -1
- package/lib/actions/locations.js +102 -68
- package/lib/actions/messages.d.ts.map +1 -1
- package/lib/actions/messages.js +124 -30
- package/lib/actions/notifications.d.ts +2 -2
- package/lib/actions/notifications.d.ts.map +1 -1
- package/lib/actions/notifications.js +6 -6
- package/lib/actions/payments.d.ts +3 -0
- package/lib/actions/payments.d.ts.map +1 -1
- package/lib/actions/payments.js +207 -5
- package/lib/actions/personas.d.ts +35 -0
- package/lib/actions/personas.d.ts.map +1 -0
- package/lib/actions/personas.js +615 -0
- package/lib/actions/posts.d.ts +14 -9
- package/lib/actions/posts.d.ts.map +1 -1
- package/lib/actions/posts.js +398 -390
- package/lib/actions/query.d.ts +24 -0
- package/lib/actions/query.d.ts.map +1 -0
- package/lib/actions/query.js +97 -0
- package/lib/actions/reactions.d.ts +16 -3
- package/lib/actions/reactions.d.ts.map +1 -1
- package/lib/actions/reactions.js +532 -162
- package/lib/actions/s3.d.ts +8 -1
- package/lib/actions/s3.d.ts.map +1 -1
- package/lib/actions/s3.js +54 -33
- package/lib/actions/search.d.ts +9 -0
- package/lib/actions/search.d.ts.map +1 -1
- package/lib/actions/search.js +59 -43
- package/lib/actions/sms.js +1 -1
- package/lib/actions/statistics.d.ts.map +1 -1
- package/lib/actions/statistics.js +5 -14
- package/lib/actions/subscriptions.d.ts +11 -2
- package/lib/actions/subscriptions.d.ts.map +1 -1
- package/lib/actions/subscriptions.js +399 -105
- package/lib/actions/tags.d.ts +23 -12
- package/lib/actions/tags.d.ts.map +1 -1
- package/lib/actions/tags.js +197 -148
- package/lib/actions/users.d.ts +21 -25
- package/lib/actions/users.d.ts.map +1 -1
- package/lib/actions/users.js +352 -217
- package/lib/actions/videos.d.ts +28 -8
- package/lib/actions/videos.d.ts.map +1 -1
- package/lib/actions/videos.js +852 -77
- package/lib/actions/websockets.d.ts +1 -1
- package/lib/actions/websockets.d.ts.map +1 -1
- package/lib/actions/websockets.js +6 -6
- package/lib/adapters/arangoAdapter.d.ts.map +1 -1
- package/lib/adapters/arangoAdapter.js +3 -5
- package/lib/adapters/contentAdapter.d.ts.map +1 -1
- package/lib/adapters/contentAdapter.js +13 -21
- package/lib/adapters/fileAdapter.d.ts.map +1 -1
- package/lib/adapters/fileAdapter.js +4 -5
- package/lib/adapters/imageAdapter.d.ts.map +1 -1
- package/lib/adapters/imageAdapter.js +3 -5
- package/lib/adapters/messageAdapter.d.ts.map +1 -1
- package/lib/adapters/messageAdapter.js +24 -5
- package/lib/adapters/postAdapter.d.ts.map +1 -1
- package/lib/adapters/postAdapter.js +35 -6
- package/lib/adapters/reaktorAdapter.d.ts.map +1 -1
- package/lib/adapters/reaktorAdapter.js +7 -7
- package/lib/adapters/tagAdapter.d.ts.map +1 -1
- package/lib/adapters/tagAdapter.js +2 -3
- package/lib/adapters/userAdapter.d.ts +1 -0
- package/lib/adapters/userAdapter.d.ts.map +1 -1
- package/lib/adapters/userAdapter.js +52 -19
- package/lib/config.d.ts +1 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +14 -17
- package/lib/constants/collections.d.ts +71 -0
- package/lib/constants/collections.d.ts.map +1 -0
- package/lib/constants/collections.js +63 -0
- package/lib/handlers/graphqlHandler.d.ts +33 -2
- package/lib/handlers/graphqlHandler.d.ts.map +1 -1
- package/lib/handlers/graphqlHandler.js +85 -17
- package/lib/index.d.ts +6 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -2
- package/lib/lambdas/actions/websockets.d.ts +7 -5
- package/lib/lambdas/actions/websockets.d.ts.map +1 -1
- package/lib/lambdas/actions/websockets.js +82 -62
- package/lib/lambdas/connection.d.ts +30 -4
- package/lib/lambdas/connection.d.ts.map +1 -1
- package/lib/lambdas/connection.js +248 -31
- package/lib/lambdas/utils/websocket.d.ts +22 -4
- package/lib/lambdas/utils/websocket.d.ts.map +1 -1
- package/lib/lambdas/utils/websocket.js +41 -49
- package/lib/mocks/image.d.ts.map +1 -1
- package/lib/mocks/image.js +3 -2
- package/lib/mocks/user.d.ts +1 -1
- package/lib/mocks/user.d.ts.map +1 -1
- package/lib/mocks/user.js +6 -11
- package/lib/mocks/video.d.ts.map +1 -1
- package/lib/mocks/video.js +3 -2
- package/lib/mutations/{content.d.ts → content/content.d.ts} +1 -1
- package/lib/mutations/content/content.d.ts.map +1 -0
- package/lib/mutations/content/content.js +27 -0
- package/lib/mutations/events/events.d.ts +3 -0
- package/lib/mutations/events/events.d.ts.map +1 -0
- package/lib/mutations/events/events.js +225 -0
- package/lib/mutations/groups/groups.d.ts +2 -0
- package/lib/mutations/groups/groups.d.ts.map +1 -0
- package/lib/mutations/groups/groups.js +50 -0
- package/lib/mutations/images/images.d.ts +2 -0
- package/lib/mutations/images/images.d.ts.map +1 -0
- package/lib/mutations/images/images.js +31 -0
- package/lib/mutations/index.d.ts +16 -11
- package/lib/mutations/index.d.ts.map +1 -1
- package/lib/mutations/index.js +133 -24
- package/lib/mutations/{locations.d.ts → locations/locations.d.ts} +1 -1
- package/lib/mutations/locations/locations.d.ts.map +1 -0
- package/lib/mutations/locations/locations.js +22 -0
- package/lib/mutations/messages/messages.d.ts +2 -0
- package/lib/mutations/messages/messages.d.ts.map +1 -0
- package/lib/mutations/messages/messages.js +67 -0
- package/lib/mutations/personas/personas.d.ts +3 -0
- package/lib/mutations/personas/personas.d.ts.map +1 -0
- package/lib/mutations/personas/personas.js +110 -0
- package/lib/mutations/{posts.d.ts → posts/posts.d.ts} +1 -1
- package/lib/mutations/posts/posts.d.ts.map +1 -0
- package/lib/mutations/posts/posts.js +31 -0
- package/lib/mutations/reactions/reactions.d.ts +2 -0
- package/lib/mutations/reactions/reactions.d.ts.map +1 -0
- package/lib/mutations/reactions/reactions.js +88 -0
- package/lib/mutations/{statistics.d.ts → statistics/statistics.d.ts} +1 -1
- package/lib/mutations/statistics/statistics.d.ts.map +1 -0
- package/lib/mutations/statistics/statistics.js +17 -0
- package/lib/mutations/{subscriptions.d.ts → subscriptions/subscriptions.d.ts} +1 -1
- package/lib/mutations/subscriptions/subscriptions.d.ts.map +1 -0
- package/lib/mutations/subscriptions/subscriptions.js +41 -0
- package/lib/mutations/tags/tags.d.ts +2 -0
- package/lib/mutations/tags/tags.d.ts.map +1 -0
- package/lib/mutations/tags/tags.js +115 -0
- package/lib/mutations/users/users.d.ts.map +1 -0
- package/lib/mutations/users/users.js +165 -0
- package/lib/mutations/videos/videos.d.ts +2 -0
- package/lib/mutations/videos/videos.d.ts.map +1 -0
- package/lib/mutations/videos/videos.js +98 -0
- package/lib/objectTypes/app.d.ts.map +1 -1
- package/lib/objectTypes/app.js +53 -29
- package/lib/objectTypes/bankAccount.d.ts.map +1 -1
- package/lib/objectTypes/bankAccount.js +30 -17
- package/lib/objectTypes/connection.d.ts.map +1 -1
- package/lib/objectTypes/connection.js +8 -6
- package/lib/objectTypes/content.d.ts.map +1 -1
- package/lib/objectTypes/content.js +38 -21
- package/lib/objectTypes/conversation.d.ts.map +1 -1
- package/lib/objectTypes/conversation.js +35 -15
- package/lib/objectTypes/creditCard.d.ts +1 -1
- package/lib/objectTypes/creditCard.d.ts.map +1 -1
- package/lib/objectTypes/creditCard.js +21 -26
- package/lib/objectTypes/document.d.ts.map +1 -1
- package/lib/objectTypes/document.js +8 -5
- package/lib/objectTypes/error.d.ts.map +1 -1
- package/lib/objectTypes/error.js +10 -7
- package/lib/objectTypes/event.d.ts +5 -0
- package/lib/objectTypes/event.d.ts.map +1 -0
- package/lib/objectTypes/event.js +265 -0
- package/lib/objectTypes/external.d.ts.map +1 -1
- package/lib/objectTypes/external.js +18 -11
- package/lib/objectTypes/file.d.ts.map +1 -1
- package/lib/objectTypes/file.js +38 -21
- package/lib/objectTypes/filter.d.ts.map +1 -1
- package/lib/objectTypes/filter.js +8 -6
- package/lib/objectTypes/group.d.ts.map +1 -1
- package/lib/objectTypes/group.js +68 -25
- package/lib/objectTypes/iapSubscription.d.ts.map +1 -1
- package/lib/objectTypes/iapSubscription.js +6 -5
- package/lib/objectTypes/image.d.ts.map +1 -1
- package/lib/objectTypes/image.js +138 -29
- package/lib/objectTypes/index.d.ts +3 -2
- package/lib/objectTypes/index.d.ts.map +1 -1
- package/lib/objectTypes/index.js +4 -3
- package/lib/objectTypes/location.d.ts.map +1 -1
- package/lib/objectTypes/location.js +55 -24
- package/lib/objectTypes/message.d.ts.map +1 -1
- package/lib/objectTypes/message.js +81 -27
- package/lib/objectTypes/passcode.d.ts.map +1 -1
- package/lib/objectTypes/passcode.js +4 -5
- package/lib/objectTypes/persona.d.ts +4 -0
- package/lib/objectTypes/persona.d.ts.map +1 -0
- package/lib/objectTypes/persona.js +250 -0
- package/lib/objectTypes/plan.d.ts.map +1 -1
- package/lib/objectTypes/plan.js +57 -21
- package/lib/objectTypes/post.d.ts.map +1 -1
- package/lib/objectTypes/post.js +89 -27
- package/lib/objectTypes/query.d.ts +10 -0
- package/lib/objectTypes/query.d.ts.map +1 -0
- package/lib/objectTypes/query.js +176 -0
- package/lib/objectTypes/reaction.d.ts.map +1 -1
- package/lib/objectTypes/reaction.js +28 -8
- package/lib/objectTypes/relation.d.ts.map +1 -1
- package/lib/objectTypes/relation.js +5 -6
- package/lib/objectTypes/search.d.ts.map +1 -1
- package/lib/objectTypes/search.js +16 -10
- package/lib/objectTypes/statistics.d.ts.map +1 -1
- package/lib/objectTypes/statistics.js +4 -4
- package/lib/objectTypes/subscription.d.ts.map +1 -1
- package/lib/objectTypes/subscription.js +69 -28
- package/lib/objectTypes/tag.d.ts.map +1 -1
- package/lib/objectTypes/tag.js +24 -11
- package/lib/objectTypes/user.d.ts.map +1 -1
- package/lib/objectTypes/user.js +296 -65
- package/lib/objectTypes/video.d.ts +10 -0
- package/lib/objectTypes/video.d.ts.map +1 -0
- package/lib/objectTypes/video.js +383 -0
- package/lib/queries/{content.d.ts → content/content.d.ts} +1 -1
- package/lib/queries/content/content.d.ts.map +1 -0
- package/lib/queries/content/content.js +55 -0
- package/lib/queries/events/events.d.ts +3 -0
- package/lib/queries/events/events.d.ts.map +1 -0
- package/lib/queries/events/events.js +113 -0
- package/lib/queries/groups/groups.d.ts +2 -0
- package/lib/queries/groups/groups.d.ts.map +1 -0
- package/lib/queries/groups/groups.js +49 -0
- package/lib/queries/images/images.d.ts +2 -0
- package/lib/queries/images/images.d.ts.map +1 -0
- package/lib/queries/images/images.js +98 -0
- package/lib/queries/index.d.ts +17 -10
- package/lib/queries/index.d.ts.map +1 -1
- package/lib/queries/index.js +147 -22
- package/lib/queries/{locations.d.ts → locations/locations.d.ts} +1 -1
- package/lib/queries/locations/locations.d.ts.map +1 -0
- package/lib/queries/locations/locations.js +37 -0
- package/lib/queries/messages/messages.d.ts +2 -0
- package/lib/queries/messages/messages.d.ts.map +1 -0
- package/lib/queries/messages/messages.js +66 -0
- package/lib/queries/personas/personas.d.ts +2 -0
- package/lib/queries/personas/personas.d.ts.map +1 -0
- package/lib/queries/personas/personas.js +66 -0
- package/lib/queries/{posts.d.ts → posts/posts.d.ts} +1 -1
- package/lib/queries/posts/posts.d.ts.map +1 -0
- package/lib/queries/posts/posts.js +157 -0
- package/lib/queries/query/query.d.ts +3 -0
- package/lib/queries/query/query.d.ts.map +1 -0
- package/lib/queries/query/query.js +52 -0
- package/lib/queries/reactions/reactions.d.ts +2 -0
- package/lib/queries/reactions/reactions.d.ts.map +1 -0
- package/lib/queries/reactions/reactions.js +94 -0
- package/lib/queries/{statistics.d.ts → statistics/statistics.d.ts} +1 -1
- package/lib/queries/statistics/statistics.d.ts.map +1 -0
- package/lib/queries/statistics/statistics.js +17 -0
- package/lib/queries/subscriptions/subscriptions.d.ts +2 -0
- package/lib/queries/subscriptions/subscriptions.d.ts.map +1 -0
- package/lib/queries/subscriptions/subscriptions.js +48 -0
- package/lib/queries/{tags.d.ts → tags/tags.d.ts} +1 -1
- package/lib/queries/tags/tags.d.ts.map +1 -0
- package/lib/queries/tags/tags.js +55 -0
- package/lib/queries/users/users.d.ts.map +1 -0
- package/lib/queries/users/users.js +56 -0
- package/lib/queries/videos/videos.d.ts +2 -0
- package/lib/queries/videos/videos.d.ts.map +1 -0
- package/lib/queries/videos/videos.js +58 -0
- package/lib/templates/email/welcome.d.ts +1 -1
- package/lib/templates/email/welcome.js +2 -2
- package/lib/templates/sms/welcome.d.ts +1 -1
- package/lib/templates/sms/welcome.js +2 -2
- package/lib/types/arangodb.types.d.ts +42 -1
- package/lib/types/arangodb.types.d.ts.map +1 -1
- package/lib/types/arangodb.types.js +1 -1
- package/lib/types/connections.types.d.ts +7 -0
- package/lib/types/connections.types.d.ts.map +1 -1
- package/lib/types/connections.types.js +5 -2
- package/lib/types/conversations.types.d.ts +1 -0
- package/lib/types/conversations.types.d.ts.map +1 -1
- package/lib/types/conversations.types.js +1 -1
- package/lib/types/images.types.d.ts +11 -1
- package/lib/types/images.types.d.ts.map +1 -1
- package/lib/types/images.types.js +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +2 -2
- package/lib/types/locations.types.d.ts +1 -0
- package/lib/types/locations.types.d.ts.map +1 -1
- package/lib/types/locations.types.js +1 -1
- package/lib/types/messages.types.d.ts +4 -1
- package/lib/types/messages.types.d.ts.map +1 -1
- package/lib/types/messages.types.js +1 -1
- package/lib/types/payments.types.d.ts +6 -0
- package/lib/types/payments.types.d.ts.map +1 -1
- package/lib/types/payments.types.js +1 -1
- package/lib/types/personas.types.d.ts +33 -0
- package/lib/types/personas.types.d.ts.map +1 -0
- package/lib/types/personas.types.js +3 -0
- package/lib/types/posts.types.d.ts +5 -1
- package/lib/types/posts.types.d.ts.map +1 -1
- package/lib/types/posts.types.js +1 -1
- package/lib/types/users.types.d.ts +24 -12
- package/lib/types/users.types.d.ts.map +1 -1
- package/lib/types/users.types.js +1 -1
- package/lib/types/videos.types.d.ts +38 -0
- package/lib/types/videos.types.d.ts.map +1 -1
- package/lib/types/videos.types.js +1 -1
- package/lib/types/websockets.types.d.ts +21 -0
- package/lib/types/websockets.types.d.ts.map +1 -1
- package/lib/types/websockets.types.js +1 -1
- package/lib/upload.d.ts +12 -0
- package/lib/upload.d.ts.map +1 -0
- package/lib/upload.js +177 -0
- package/lib/utils/aqlHelpers.d.ts +56 -0
- package/lib/utils/aqlHelpers.d.ts.map +1 -0
- package/lib/utils/aqlHelpers.js +205 -0
- package/lib/utils/arangodbUtils.js +2 -2
- package/lib/utils/authUtils.d.ts +1 -1
- package/lib/utils/authUtils.d.ts.map +1 -1
- package/lib/utils/authUtils.js +8 -4
- package/lib/utils/awsUtils.d.ts +6 -0
- package/lib/utils/awsUtils.d.ts.map +1 -0
- package/lib/utils/awsUtils.js +23 -0
- package/lib/utils/collectionRegistry.d.ts +58 -0
- package/lib/utils/collectionRegistry.d.ts.map +1 -0
- package/lib/utils/collectionRegistry.js +160 -0
- package/lib/utils/dbI18n.example.js +4 -4
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/queryBuilder.d.ts +31 -0
- package/lib/utils/queryBuilder.d.ts.map +1 -0
- package/lib/utils/queryBuilder.js +245 -0
- package/lib/utils/schemaUtils.d.ts +6 -0
- package/lib/utils/schemaUtils.d.ts.map +1 -0
- package/lib/utils/schemaUtils.js +96 -0
- package/lib/utils/sessionUtils.d.ts +8 -1
- package/lib/utils/sessionUtils.d.ts.map +1 -1
- package/lib/utils/sessionUtils.js +4 -2
- package/lib/utils/stripeUtils.d.ts +1 -1
- package/lib/utils/stripeUtils.js +2 -2
- package/lib/utils/testUtils.d.ts +3 -7
- package/lib/utils/testUtils.d.ts.map +1 -1
- package/lib/utils/testUtils.js +10 -2
- package/lib/utils/translationQueue.example.js +4 -4
- package/lib/videoProcessing.d.ts +29 -0
- package/lib/videoProcessing.d.ts.map +1 -0
- package/lib/videoProcessing.js +66 -0
- package/package.json +69 -42
- package/lib/actions/profiles.d.ts +0 -5
- package/lib/actions/profiles.d.ts.map +0 -1
- package/lib/actions/profiles.js +0 -58
- package/lib/mutations/content.d.ts.map +0 -1
- package/lib/mutations/content.js +0 -27
- package/lib/mutations/locations.d.ts.map +0 -1
- package/lib/mutations/locations.js +0 -22
- package/lib/mutations/messages.d.ts +0 -3
- package/lib/mutations/messages.d.ts.map +0 -1
- package/lib/mutations/messages.js +0 -75
- package/lib/mutations/posts.d.ts.map +0 -1
- package/lib/mutations/posts.js +0 -31
- package/lib/mutations/profiles.d.ts +0 -3
- package/lib/mutations/profiles.d.ts.map +0 -1
- package/lib/mutations/profiles.js +0 -78
- package/lib/mutations/reactions.d.ts +0 -3
- package/lib/mutations/reactions.d.ts.map +0 -1
- package/lib/mutations/reactions.js +0 -29
- package/lib/mutations/statistics.d.ts.map +0 -1
- package/lib/mutations/statistics.js +0 -17
- package/lib/mutations/subscriptions.d.ts.map +0 -1
- package/lib/mutations/subscriptions.js +0 -38
- package/lib/mutations/tags.d.ts +0 -3
- package/lib/mutations/tags.d.ts.map +0 -1
- package/lib/mutations/tags.js +0 -109
- package/lib/mutations/users.d.ts.map +0 -1
- package/lib/mutations/users.js +0 -129
- package/lib/objectTypes/profile.d.ts +0 -4
- package/lib/objectTypes/profile.d.ts.map +0 -1
- package/lib/objectTypes/profile.js +0 -68
- package/lib/queries/content.d.ts.map +0 -1
- package/lib/queries/content.js +0 -50
- package/lib/queries/locations.d.ts.map +0 -1
- package/lib/queries/locations.js +0 -23
- package/lib/queries/messages.d.ts +0 -3
- package/lib/queries/messages.d.ts.map +0 -1
- package/lib/queries/messages.js +0 -35
- package/lib/queries/posts.d.ts.map +0 -1
- package/lib/queries/posts.js +0 -154
- package/lib/queries/reactions.d.ts +0 -3
- package/lib/queries/reactions.d.ts.map +0 -1
- package/lib/queries/reactions.js +0 -34
- package/lib/queries/statistics.d.ts.map +0 -1
- package/lib/queries/statistics.js +0 -17
- package/lib/queries/subscriptions.d.ts +0 -3
- package/lib/queries/subscriptions.d.ts.map +0 -1
- package/lib/queries/subscriptions.js +0 -21
- package/lib/queries/tags.d.ts.map +0 -1
- package/lib/queries/tags.js +0 -56
- package/lib/queries/users.d.ts.map +0 -1
- package/lib/queries/users.js +0 -39
- package/lib/types/profiles.types.d.ts +0 -21
- package/lib/types/profiles.types.d.ts.map +0 -1
- package/lib/types/profiles.types.js +0 -3
- /package/lib/mutations/{users.d.ts → users/users.d.ts} +0 -0
- /package/lib/queries/{users.d.ts → users/users.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
Reaktor
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
-
A
|
|
4
|
+
A powerful GraphQL API framework built with TypeScript, ArangoDB, and AWS Lambda. Reaktor provides a complete backend solution for social platforms with user management, posts, messaging, reactions, and more.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **GraphQL API** - Built with graphql-compose for type-safe schema composition
|
|
9
|
+
- **ArangoDB** - High-performance multi-model database with graph capabilities
|
|
10
|
+
- **TypeScript** - Full type safety throughout the codebase
|
|
11
|
+
- **Modular Architecture** - Clean separation of concerns with actions, adapters, and utilities
|
|
12
|
+
- **Zod Validation** - Runtime type checking and data validation
|
|
13
|
+
- **JWT Authentication** - Secure session management
|
|
14
|
+
- **AWS Lambda Ready** - Serverless deployment support
|
|
15
|
+
- **Comprehensive Testing** - Jest-based testing with utilities
|
|
16
|
+
- **Internationalization** - Database-driven i18n system
|
|
5
17
|
|
|
6
18
|
Peer Dependencies
|
|
7
19
|
----------------
|
|
@@ -20,10 +32,92 @@ Getting Started
|
|
|
20
32
|
|
|
21
33
|
```shell
|
|
22
34
|
$ npm install # Install Node modules listed in ./package.json (may take a while the first time)
|
|
23
|
-
$ npm
|
|
24
|
-
$
|
|
35
|
+
$ npm run build # Compile TypeScript
|
|
36
|
+
$ npm test # Run tests
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For detailed setup instructions, see [Development Guide](./docs/DEVELOPMENT.md).
|
|
40
|
+
|
|
41
|
+
## Architecture
|
|
42
|
+
|
|
43
|
+
Reaktor follows a clean, layered architecture designed for maintainability and scalability:
|
|
44
|
+
|
|
45
|
+
### New Modular Structure
|
|
46
|
+
|
|
47
|
+
The codebase has been refactored to follow modern patterns:
|
|
48
|
+
|
|
49
|
+
- **Shared Utilities**: Common functionality extracted into reusable utility functions
|
|
50
|
+
- **Single-Responsibility Functions**: Actions are broken down into focused, composable functions
|
|
51
|
+
- **Type Safety**: Comprehensive TypeScript types and Zod validation throughout
|
|
52
|
+
- **Consistent Error Handling**: Standardized error logging and exception handling
|
|
53
|
+
- **Constants Over Magic Strings**: Centralized constants for collections, edges, and enums
|
|
54
|
+
|
|
55
|
+
### Query Builder System
|
|
56
|
+
|
|
57
|
+
Reaktor provides a flexible query system built on ArangoDB's AQL:
|
|
58
|
+
|
|
59
|
+
- **Composable Queries**: Build complex queries from simple building blocks
|
|
60
|
+
- **Type-Safe Parameters**: All queries use parameterization to prevent injection attacks
|
|
61
|
+
- **Flexible Filtering**: Filter by any field including custom properties
|
|
62
|
+
- **Advanced Operators**: Support for comparison, string, and array operators
|
|
63
|
+
- **Nested Conditions**: Complex AND/OR logic for sophisticated queries
|
|
64
|
+
|
|
65
|
+
See [Query System Documentation](./docs/QUERY_SYSTEM.md) for detailed examples.
|
|
66
|
+
|
|
67
|
+
### Refactored Action Pattern
|
|
68
|
+
|
|
69
|
+
Actions now follow a consistent, maintainable pattern:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
export const addPost = async (context: ApiContext, input: PostInputType): Promise<PostType> => {
|
|
73
|
+
// Validate and parse input
|
|
74
|
+
const parsedPost = parseAndPreparePost(input, context.session.userId);
|
|
75
|
+
|
|
76
|
+
// Perform database operation
|
|
77
|
+
const savedPost = await insertPost(context, parsedPost);
|
|
78
|
+
|
|
79
|
+
// Handle related operations
|
|
80
|
+
return await handleTagsForPost(context, savedPost, input.tags);
|
|
81
|
+
};
|
|
25
82
|
```
|
|
26
83
|
|
|
84
|
+
**Benefits**:
|
|
85
|
+
- Easier to test and maintain
|
|
86
|
+
- Clear separation of concerns
|
|
87
|
+
- Reusable helper functions
|
|
88
|
+
- Consistent error handling
|
|
89
|
+
|
|
90
|
+
### Layer Architecture
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
94
|
+
│ GraphQL Layer │
|
|
95
|
+
│ (queries/, mutations/, objectTypes/) │
|
|
96
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
97
|
+
│
|
|
98
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
99
|
+
│ Actions Layer │
|
|
100
|
+
│ (actions/) - Domain-specific business logic │
|
|
101
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
102
|
+
│
|
|
103
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
104
|
+
│ Adapters Layer │
|
|
105
|
+
│ (adapters/) - Data transformation & validation │
|
|
106
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
107
|
+
│
|
|
108
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
109
|
+
│ Utilities Layer │
|
|
110
|
+
│ (utils/) - Shared helpers & database utilities │
|
|
111
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
112
|
+
│
|
|
113
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
114
|
+
│ ArangoDB Database │
|
|
115
|
+
│ Collections & Edges - Document and graph storage │
|
|
116
|
+
└─────────────────────────────────────────────────────────────┘
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For comprehensive architecture documentation, see [Architecture Guide](./docs/ARCHITECTURE.md).
|
|
120
|
+
|
|
27
121
|
Usage
|
|
28
122
|
-----
|
|
29
123
|
|
|
@@ -50,171 +144,1263 @@ Get a copy of the latest database data from the production database and save to
|
|
|
50
144
|
|
|
51
145
|
### Configuration
|
|
52
146
|
|
|
53
|
-
Basic project configuration can be found in `~/src/config.
|
|
147
|
+
Basic project configuration can be found in `~/src/config.ts`. The configuration system supports environment-based settings and can be customized via environment variables.
|
|
148
|
+
|
|
149
|
+
#### Required Environment Variables
|
|
150
|
+
|
|
151
|
+
- `SESSION_SECRET` - **Required** - Secret key used for JWT token signing and verification. This must be set for authentication to work.
|
|
152
|
+
|
|
153
|
+
**Example:**
|
|
154
|
+
```bash
|
|
155
|
+
export SESSION_SECRET="your-secret-key-here"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### ArangoDB Configuration
|
|
159
|
+
|
|
160
|
+
The ArangoDB connection can be configured using the following environment variables:
|
|
161
|
+
|
|
162
|
+
- `ARANGODB_URL` - The ArangoDB server URL (default: `http://localhost`)
|
|
163
|
+
- `ARANGODB_PORT` - The ArangoDB server port (default: `8529`)
|
|
164
|
+
- `ARANGODB_DATABASE` - The database name (default: `reaktor`)
|
|
165
|
+
- `ARANGODB_USERNAME` - The database username (default: `root`)
|
|
166
|
+
- `ARANGODB_PASSWORD` - The database password (default: `password`)
|
|
167
|
+
|
|
168
|
+
**Example:**
|
|
169
|
+
```bash
|
|
170
|
+
export SESSION_SECRET="your-secret-key-here"
|
|
171
|
+
export ARANGODB_URL="http://my-arango-server"
|
|
172
|
+
export ARANGODB_PORT="8530"
|
|
173
|
+
export ARANGODB_DATABASE="my-database"
|
|
174
|
+
export ARANGODB_USERNAME="myuser"
|
|
175
|
+
export ARANGODB_PASSWORD="mypassword"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The configuration is environment-aware and supports `local`, `development`, `test`, and `production` environments. The active environment is determined by the `NODE_ENV` or `stage` environment variable.
|
|
179
|
+
|
|
180
|
+
#### Programmatic Configuration
|
|
181
|
+
|
|
182
|
+
You can also override configuration programmatically using the `Config.set()` method:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import {Config} from '@nlabs/reaktor';
|
|
186
|
+
|
|
187
|
+
Config.set({
|
|
188
|
+
arangodb: {
|
|
189
|
+
url: 'http://custom-server',
|
|
190
|
+
port: '8530',
|
|
191
|
+
database: 'custom-db'
|
|
192
|
+
}
|
|
193
|
+
}, 'development');
|
|
194
|
+
```
|
|
54
195
|
|
|
55
196
|
Structure
|
|
56
197
|
---------
|
|
57
198
|
|
|
58
|
-
|
|
199
|
+
Reaktor follows a modular, domain-driven structure optimized for GraphQL API development:
|
|
59
200
|
|
|
60
201
|
```
|
|
61
|
-
|
|
62
|
-
├──
|
|
63
|
-
├──
|
|
64
|
-
│ ├──
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
└──
|
|
68
|
-
├──
|
|
69
|
-
├──
|
|
70
|
-
├──
|
|
71
|
-
|
|
72
|
-
├──
|
|
73
|
-
|
|
74
|
-
├──
|
|
75
|
-
├──
|
|
76
|
-
|
|
202
|
+
└── src
|
|
203
|
+
├── actions/ # Business logic for each domain (refactored & modular)
|
|
204
|
+
│ ├── users.ts # User management actions
|
|
205
|
+
│ ├── posts.ts # Post management actions
|
|
206
|
+
│ ├── groups.ts # Group management actions
|
|
207
|
+
│ ├── reactions.ts # Reaction handling
|
|
208
|
+
│ └── ... # Other domain actions
|
|
209
|
+
├── adapters/ # Data transformation and parsing with Zod
|
|
210
|
+
│ ├── userAdapter.ts # User data validation
|
|
211
|
+
│ ├── postAdapter.ts # Post data validation
|
|
212
|
+
│ └── ... # Other adapters
|
|
213
|
+
├── handlers/ # Request handlers
|
|
214
|
+
│ └── graphqlHandler.ts # GraphQL request processing
|
|
215
|
+
├── mutations/ # GraphQL mutations
|
|
216
|
+
│ ├── users.ts # User mutations
|
|
217
|
+
│ ├── posts.ts # Post mutations
|
|
218
|
+
│ └── ... # Other mutations
|
|
219
|
+
├── objectTypes/ # GraphQL type definitions
|
|
220
|
+
│ ├── user.ts # User type schema
|
|
221
|
+
│ ├── post.ts # Post type schema
|
|
222
|
+
│ └── ... # Other type definitions
|
|
223
|
+
├── queries/ # GraphQL query resolvers
|
|
224
|
+
│ ├── users/ # User queries
|
|
225
|
+
│ ├── posts/ # Post queries
|
|
226
|
+
│ └── ... # Other queries
|
|
227
|
+
├── types/ # TypeScript type definitions
|
|
228
|
+
│ ├── users.types.ts # User interfaces
|
|
229
|
+
│ ├── posts.types.ts # Post interfaces
|
|
230
|
+
│ └── ... # Other type definitions
|
|
231
|
+
├── utils/ # Shared utilities (EXPANDED)
|
|
232
|
+
│ ├── arangodbUtils.ts # Database connection & helpers
|
|
233
|
+
│ ├── sessionUtils.ts # JWT authentication
|
|
234
|
+
│ ├── analyticsUtils.ts # Error logging & monitoring
|
|
235
|
+
│ ├── schemaUtils.ts # GraphQL schema utilities
|
|
236
|
+
│ ├── testUtils.ts # Testing helpers
|
|
237
|
+
│ └── ... # Other utilities
|
|
238
|
+
├── config.ts # Environment configuration
|
|
239
|
+
└── index.ts # Main entry point
|
|
77
240
|
```
|
|
78
241
|
|
|
79
|
-
###
|
|
242
|
+
### Key Directories
|
|
80
243
|
|
|
81
|
-
**
|
|
244
|
+
- **actions/**: Domain-specific business logic with single-responsibility functions
|
|
245
|
+
- **adapters/**: Zod-based validation and data transformation layer
|
|
246
|
+
- **handlers/**: Request entry points (GraphQL, Lambda)
|
|
247
|
+
- **mutations/**: GraphQL mutation resolvers
|
|
248
|
+
- **queries/**: GraphQL query resolvers organized by domain
|
|
249
|
+
- **objectTypes/**: GraphQL type schemas with graphql-compose
|
|
250
|
+
- **types/**: TypeScript interfaces and type definitions
|
|
251
|
+
- **utils/**: Shared utilities for database, auth, logging, etc.
|
|
82
252
|
|
|
83
|
-
|
|
253
|
+
## Flexible Query System
|
|
84
254
|
|
|
85
|
-
|
|
86
|
-
-------
|
|
255
|
+
Reaktor includes a powerful, flexible query system that allows you to search and filter any collection by any property, including custom document fields.
|
|
87
256
|
|
|
88
|
-
###
|
|
89
|
-
|
|
257
|
+
### Basic Query
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
// Get posts by filters
|
|
261
|
+
const aqlQry = aql`
|
|
262
|
+
FOR p IN posts
|
|
263
|
+
FILTER p.type == ${'event'}
|
|
264
|
+
FILTER p.privacy == ${'public'}
|
|
265
|
+
SORT p.added DESC
|
|
266
|
+
LIMIT 0, 20
|
|
267
|
+
RETURN p
|
|
268
|
+
`;
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Advanced Filtering
|
|
272
|
+
|
|
273
|
+
**Nested Conditions (OR/AND):**
|
|
274
|
+
```typescript
|
|
275
|
+
const aqlQry = aql`
|
|
276
|
+
FOR p IN posts
|
|
277
|
+
FILTER p.type == 'post'
|
|
278
|
+
FILTER (p.userId == ${userId} OR p.privacy == 'public')
|
|
279
|
+
SORT p.added DESC
|
|
280
|
+
LIMIT 0, 20
|
|
281
|
+
RETURN p
|
|
282
|
+
`;
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Custom Properties:**
|
|
286
|
+
```typescript
|
|
287
|
+
const aqlQry = aql`
|
|
288
|
+
FOR p IN posts
|
|
289
|
+
FILTER p.customStatus == 'active'
|
|
290
|
+
FILTER p.customPriority > 5
|
|
291
|
+
RETURN p
|
|
292
|
+
`;
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Available Operators:**
|
|
296
|
+
- `==` - Equal
|
|
297
|
+
- `!=` - Not equal
|
|
298
|
+
- `>` - Greater than
|
|
299
|
+
- `>=` - Greater than or equal
|
|
300
|
+
- `<` - Less than
|
|
301
|
+
- `<=` - Less than or equal
|
|
302
|
+
- `LIKE` - Pattern matching (use with wildcards)
|
|
303
|
+
- `CONTAINS` - String contains
|
|
304
|
+
- `IN` - Value in array
|
|
305
|
+
- `NOT IN` - Value not in array
|
|
306
|
+
|
|
307
|
+
### Multi-Collection Search
|
|
308
|
+
|
|
309
|
+
Search across multiple collections:
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
import {searchContent} from './src/actions/search.js';
|
|
313
|
+
|
|
314
|
+
const searchResults = await searchContent(context, {
|
|
315
|
+
query: 'nodejs conference',
|
|
316
|
+
collections: ['posts', 'users', 'groups'],
|
|
317
|
+
limit: { from: 0, to: 50 }
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### GraphQL Query
|
|
322
|
+
|
|
323
|
+
```graphql
|
|
324
|
+
query {
|
|
325
|
+
posts(
|
|
326
|
+
type: "event"
|
|
327
|
+
privacy: "public"
|
|
328
|
+
from: 0
|
|
329
|
+
to: 20
|
|
330
|
+
sort: "added"
|
|
331
|
+
direction: "DESC"
|
|
332
|
+
) {
|
|
333
|
+
_key
|
|
334
|
+
content
|
|
335
|
+
type
|
|
336
|
+
privacy
|
|
337
|
+
added
|
|
338
|
+
user {
|
|
339
|
+
name
|
|
340
|
+
avatar
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
For complete query system documentation, see [Query System Guide](./docs/QUERY_SYSTEM.md).
|
|
347
|
+
|
|
348
|
+
## Architecture Patterns
|
|
349
|
+
|
|
350
|
+
### Shared AQL Helpers
|
|
351
|
+
|
|
352
|
+
Common AQL query patterns are implemented as reusable functions in action files:
|
|
90
353
|
|
|
91
|
-
|
|
92
|
-
|
|
354
|
+
```typescript
|
|
355
|
+
// Example: Building distance queries
|
|
356
|
+
const buildDistanceQuery = (lat: number, lng: number): string =>
|
|
357
|
+
`LET distance = DISTANCE(
|
|
358
|
+
${lat},
|
|
359
|
+
${lng},
|
|
360
|
+
NOT_NULL(p.latitude, 0),
|
|
361
|
+
NOT_NULL(p.longitude, 0))
|
|
362
|
+
`;
|
|
93
363
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
364
|
+
// Example: Building reaction count queries
|
|
365
|
+
const buildReactionCountQuery = (reactionName: string): string =>
|
|
366
|
+
`LET ${reactionName}Count = FIRST(
|
|
367
|
+
FOR post, r IN INBOUND p._id hasReaction
|
|
368
|
+
FILTER r.name == "${reactionName}"
|
|
369
|
+
COLLECT WITH COUNT INTO count
|
|
370
|
+
RETURN count
|
|
371
|
+
)`;
|
|
102
372
|
```
|
|
103
373
|
|
|
104
|
-
###
|
|
105
|
-
As mentioned in features, the default Webpack configuration provides some globals and aliases to make your life easier. These can be used as such:
|
|
374
|
+
### Error Handling
|
|
106
375
|
|
|
107
|
-
|
|
108
|
-
import MyComponent from '../../components/my-component'; // without alias
|
|
109
|
-
import MyComponent from 'components/my-component'; // with alias
|
|
376
|
+
All actions use consistent error handling:
|
|
110
377
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
378
|
+
```typescript
|
|
379
|
+
import { logError, logException } from './src/utils/analyticsUtils.js';
|
|
380
|
+
|
|
381
|
+
try {
|
|
382
|
+
// Database operation
|
|
383
|
+
const result = await performDatabaseOperation();
|
|
384
|
+
return result;
|
|
385
|
+
} catch (error) {
|
|
386
|
+
logError({
|
|
387
|
+
action: 'functionName',
|
|
388
|
+
category: 'domain',
|
|
389
|
+
label: ErrorTypes.DATABASE_ERROR
|
|
390
|
+
}, error, context);
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
123
393
|
```
|
|
124
394
|
|
|
125
|
-
###
|
|
395
|
+
### Constants
|
|
396
|
+
|
|
397
|
+
Use constants instead of magic strings:
|
|
126
398
|
|
|
127
|
-
|
|
128
|
-
|
|
399
|
+
```typescript
|
|
400
|
+
// Collection names
|
|
401
|
+
const COLLECTIONS = {
|
|
402
|
+
POSTS: 'posts',
|
|
403
|
+
USERS: 'users',
|
|
404
|
+
GROUPS: 'groups'
|
|
405
|
+
} as const;
|
|
129
406
|
|
|
130
|
-
|
|
131
|
-
|
|
407
|
+
// Edge names
|
|
408
|
+
const EDGES = {
|
|
409
|
+
HAS_REACTION: 'hasReaction',
|
|
410
|
+
HAS_CONNECTION: 'hasConnection',
|
|
411
|
+
IS_TAGGED: 'isTagged'
|
|
412
|
+
} as const;
|
|
132
413
|
|
|
133
|
-
|
|
134
|
-
|
|
414
|
+
// Privacy levels
|
|
415
|
+
export const PrivacyLevel = {
|
|
416
|
+
PUBLIC: 'public',
|
|
417
|
+
PRIVATE: 'private',
|
|
418
|
+
GROUP: 'group'
|
|
419
|
+
} as const;
|
|
420
|
+
|
|
421
|
+
// Use in queries
|
|
422
|
+
const aqlQry = aql`
|
|
423
|
+
FOR p IN ${COLLECTIONS.POSTS}
|
|
424
|
+
FOR r IN INBOUND p._id ${EDGES.HAS_REACTION}
|
|
425
|
+
FILTER r.name == 'like'
|
|
426
|
+
RETURN p
|
|
427
|
+
`;
|
|
428
|
+
```
|
|
135
429
|
|
|
136
|
-
|
|
137
|
-
------
|
|
430
|
+
### Modular Functions
|
|
138
431
|
|
|
139
|
-
|
|
432
|
+
Functions are now single-responsibility and composable:
|
|
140
433
|
|
|
141
|
-
```
|
|
142
|
-
//
|
|
143
|
-
|
|
434
|
+
```typescript
|
|
435
|
+
// Before: One large function
|
|
436
|
+
export const addPost = async (context, input) => {
|
|
437
|
+
// 100+ lines of mixed logic
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// After: Composed of smaller functions
|
|
441
|
+
export const addPost = async (context: ApiContext, input: PostInputType): Promise<PostType> => {
|
|
442
|
+
const parsedPost = parseAndPreparePost(input, context.session.userId);
|
|
443
|
+
const savedPost = await insertPost(context, parsedPost);
|
|
444
|
+
return await handleTagsForPost(context, savedPost, input.tags);
|
|
445
|
+
};
|
|
144
446
|
```
|
|
145
447
|
|
|
146
|
-
|
|
448
|
+
## Migration Guide
|
|
449
|
+
|
|
450
|
+
### From Old to New Structure
|
|
147
451
|
|
|
148
|
-
|
|
149
|
-
// current path: ~/src/styles/some/nested/style.scss
|
|
150
|
-
// what used to be this:
|
|
151
|
-
@import '../../base';
|
|
452
|
+
The refactoring maintains backward compatibility while introducing better patterns and utilities.
|
|
152
453
|
|
|
153
|
-
|
|
154
|
-
|
|
454
|
+
**Old way (manual query building):**
|
|
455
|
+
```typescript
|
|
456
|
+
// Manual string concatenation (avoid this)
|
|
457
|
+
const aqlQry = `FOR p IN posts
|
|
458
|
+
FILTER p.type == "${type}" && p.privacy == "public"
|
|
459
|
+
RETURN p`;
|
|
155
460
|
```
|
|
156
461
|
|
|
462
|
+
**New way (parameterized queries):**
|
|
463
|
+
```typescript
|
|
464
|
+
// Use AQL template literals for safety
|
|
465
|
+
import {aql} from 'arangojs';
|
|
466
|
+
|
|
467
|
+
const aqlQry = aql`
|
|
468
|
+
FOR p IN posts
|
|
469
|
+
FILTER p.type == ${type}
|
|
470
|
+
FILTER p.privacy == 'public'
|
|
471
|
+
RETURN p
|
|
472
|
+
`;
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
**Using helper functions:**
|
|
476
|
+
```typescript
|
|
477
|
+
// Leverage existing action functions
|
|
478
|
+
import {getPostsByLatest} from './src/actions/posts.js';
|
|
479
|
+
|
|
480
|
+
const results = await getPostsByLatest(context, {
|
|
481
|
+
type: type,
|
|
482
|
+
privacy: 'public',
|
|
483
|
+
from: 0,
|
|
484
|
+
to: 20
|
|
485
|
+
});
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Breaking Changes
|
|
489
|
+
|
|
490
|
+
**None!** All existing functions maintain backward compatibility. The refactoring improves internal structure without changing public APIs.
|
|
491
|
+
|
|
492
|
+
### Best Practices
|
|
493
|
+
|
|
494
|
+
1. **Use parameterized queries**: Always use `aql` template literals
|
|
495
|
+
2. **Leverage adapters**: Parse data with Zod schemas for validation
|
|
496
|
+
3. **Use constants**: Define collection/edge names as constants
|
|
497
|
+
4. **Error handling**: Use `logError()` and `logException()` consistently
|
|
498
|
+
5. **Type safety**: Specify TypeScript types for all functions
|
|
499
|
+
|
|
157
500
|
Database
|
|
158
501
|
-------
|
|
159
|
-
- Install the latest
|
|
160
|
-
- Create the database `reaktor
|
|
161
|
-
-
|
|
502
|
+
- Install the latest [ArangoDB binary](https://www.arangodb.com/download/) for your platform.
|
|
503
|
+
- Create the database `reaktor` (for development) and `reaktor-test` (for testing).
|
|
504
|
+
- Configure connection in `.env` file (see Configuration section above).
|
|
162
505
|
|
|
163
|
-
|
|
164
|
-
|
|
506
|
+
**Environment setup:**
|
|
507
|
+
```bash
|
|
508
|
+
# In .env file
|
|
509
|
+
ARANGODB_URL=http://localhost
|
|
510
|
+
ARANGODB_PORT=8529
|
|
511
|
+
ARANGODB_DATABASE=reaktor
|
|
512
|
+
ARANGODB_USERNAME=root
|
|
513
|
+
ARANGODB_PASSWORD=password
|
|
165
514
|
```
|
|
166
515
|
|
|
167
516
|
Testing
|
|
168
517
|
-------
|
|
169
518
|
|
|
170
|
-
|
|
519
|
+
Reaktor uses Jest for testing with comprehensive test utilities.
|
|
171
520
|
|
|
172
|
-
|
|
173
|
-
|
|
521
|
+
### Running Tests
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
# Run all tests
|
|
525
|
+
npm test
|
|
526
|
+
|
|
527
|
+
# Run tests in watch mode
|
|
528
|
+
npm test -- --watch
|
|
529
|
+
|
|
530
|
+
# Run specific test file
|
|
531
|
+
npm test -- src/actions/users.test.ts
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Writing Tests
|
|
535
|
+
|
|
536
|
+
Use the provided test utilities for consistent test data:
|
|
537
|
+
|
|
538
|
+
```typescript
|
|
539
|
+
import {describe, it, expect, beforeAll} from '@jest/globals';
|
|
540
|
+
import {createMockContext, createMockUser} from '../utils/testUtils.js';
|
|
541
|
+
import {addUser, getUser} from './users.js';
|
|
542
|
+
|
|
543
|
+
describe('User Actions', () => {
|
|
544
|
+
let context;
|
|
545
|
+
|
|
546
|
+
beforeAll(() => {
|
|
547
|
+
context = createMockContext();
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it('should create and retrieve a user', async () => {
|
|
551
|
+
const userData = createMockUser({email: 'test@example.com'});
|
|
552
|
+
const created = await addUser(context, userData);
|
|
553
|
+
|
|
554
|
+
expect(created.email).toBe('test@example.com');
|
|
555
|
+
|
|
556
|
+
const retrieved = await getUser(context, created._key);
|
|
557
|
+
expect(retrieved?._key).toBe(created._key);
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
See [Test Utilities Guide](./TEST_UTILITIES_GUIDE.md) for detailed documentation on test helpers.
|
|
563
|
+
|
|
564
|
+
## Available Action Functions
|
|
565
|
+
|
|
566
|
+
All action functions have been refactored for better modularity and maintainability. Common patterns are now extracted into shared utilities.
|
|
567
|
+
|
|
568
|
+
### Posts
|
|
569
|
+
|
|
570
|
+
```typescript
|
|
571
|
+
import {
|
|
572
|
+
addPost,
|
|
573
|
+
updatePost,
|
|
574
|
+
deletePost,
|
|
575
|
+
getPost,
|
|
576
|
+
getPostsByLatest,
|
|
577
|
+
getPostsByReactions,
|
|
578
|
+
getPostsByTags,
|
|
579
|
+
getPostsByUser,
|
|
580
|
+
getPostsByArea
|
|
581
|
+
} from './src/actions/posts.js';
|
|
582
|
+
|
|
583
|
+
// Add a post
|
|
584
|
+
const newPost = await addPost(context, {
|
|
585
|
+
content: 'Hello World',
|
|
586
|
+
type: 'post',
|
|
587
|
+
privacy: 'public',
|
|
588
|
+
tags: [{name: 'nodejs'}]
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
// Get posts by user
|
|
592
|
+
const userPosts = await getPostsByUser(context, userId, {
|
|
593
|
+
from: 0,
|
|
594
|
+
to: 20
|
|
595
|
+
});
|
|
174
596
|
|
|
175
|
-
|
|
597
|
+
// Get posts by location
|
|
598
|
+
const nearbyPosts = await getPostsByArea(context, {
|
|
599
|
+
latitude: 37.7749,
|
|
600
|
+
longitude: -122.4194,
|
|
601
|
+
radius: 50, // km
|
|
602
|
+
from: 0,
|
|
603
|
+
to: 20
|
|
604
|
+
});
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
### Reactions
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
import {
|
|
611
|
+
addReaction,
|
|
612
|
+
deleteReaction,
|
|
613
|
+
getReactionCount,
|
|
614
|
+
getReactionsByItem,
|
|
615
|
+
hasReaction
|
|
616
|
+
} from './src/actions/reactions.js';
|
|
617
|
+
|
|
618
|
+
// Add a reaction
|
|
619
|
+
await addReaction(context, 'posts/123', {
|
|
620
|
+
name: 'like',
|
|
621
|
+
value: '1'
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// Get reaction counts
|
|
625
|
+
const counts = await getReactionCount(context, 'posts/123', {
|
|
626
|
+
reactionName: 'like'
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// Check if user has reacted
|
|
630
|
+
const liked = await hasReaction(context, 'posts/123', 'like');
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
### Users
|
|
634
|
+
|
|
635
|
+
```typescript
|
|
636
|
+
import {
|
|
637
|
+
getUser,
|
|
638
|
+
getUserList,
|
|
639
|
+
addUser,
|
|
640
|
+
updateUser,
|
|
641
|
+
signIn,
|
|
642
|
+
signOut,
|
|
643
|
+
getUsersByLatest,
|
|
644
|
+
getUsersByTags,
|
|
645
|
+
getSessionUser
|
|
646
|
+
} from './src/actions/users.js';
|
|
647
|
+
|
|
648
|
+
// Get users with filters
|
|
649
|
+
const users = await getUserList(context, {
|
|
650
|
+
from: 0,
|
|
651
|
+
to: 20
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
// Sign in
|
|
655
|
+
const authResult = await signIn(context, {
|
|
656
|
+
email: 'user@example.com',
|
|
657
|
+
password: 'password123'
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
// Get current user from session
|
|
661
|
+
const currentUser = await getSessionUser(context, authToken);
|
|
662
|
+
```
|
|
176
663
|
|
|
177
|
-
|
|
178
|
-
import { createConstants } from 'utils';
|
|
664
|
+
### Groups
|
|
179
665
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
666
|
+
```typescript
|
|
667
|
+
import {
|
|
668
|
+
getGroupList,
|
|
669
|
+
getGroupListByUser,
|
|
670
|
+
getGroupListByTags,
|
|
671
|
+
getGroupById,
|
|
672
|
+
addGroup,
|
|
673
|
+
updateGroup,
|
|
674
|
+
deleteGroup
|
|
675
|
+
} from './src/actions/groups.js';
|
|
676
|
+
|
|
677
|
+
// Get groups
|
|
678
|
+
const groups = await getGroupList(context, {
|
|
679
|
+
from: 0,
|
|
680
|
+
to: 20
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
// Get user's groups
|
|
684
|
+
const userGroups = await getGroupListByUser(context, userId, {
|
|
685
|
+
from: 0,
|
|
686
|
+
to: 20
|
|
687
|
+
});
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
### Tags
|
|
691
|
+
|
|
692
|
+
```typescript
|
|
693
|
+
import {
|
|
694
|
+
getTags,
|
|
695
|
+
getTagsByItem,
|
|
696
|
+
addTag,
|
|
697
|
+
addTagToItem,
|
|
698
|
+
updateTag,
|
|
699
|
+
deleteTag,
|
|
700
|
+
extractTags
|
|
701
|
+
} from './src/actions/tags.js';
|
|
702
|
+
|
|
703
|
+
// Add tags to an item
|
|
704
|
+
await addTagToItem(context, 'posts/123', [
|
|
705
|
+
{name: 'nodejs'},
|
|
706
|
+
{name: 'javascript'}
|
|
707
|
+
]);
|
|
708
|
+
|
|
709
|
+
// Extract tags from text
|
|
710
|
+
const extractedTags = await extractTags(context, 'Learning #nodejs and #graphql');
|
|
185
711
|
```
|
|
186
712
|
|
|
187
|
-
|
|
713
|
+
### Messages & Conversations
|
|
714
|
+
|
|
715
|
+
```typescript
|
|
716
|
+
import {
|
|
717
|
+
getConversations,
|
|
718
|
+
getConversation,
|
|
719
|
+
addDirectConversation,
|
|
720
|
+
addUserToConversation
|
|
721
|
+
} from './src/actions/conversations.js';
|
|
722
|
+
|
|
723
|
+
// Get user's conversations
|
|
724
|
+
const conversations = await getConversations(context, {
|
|
725
|
+
from: 0,
|
|
726
|
+
to: 20
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
// Start a direct conversation
|
|
730
|
+
const conversation = await addDirectConversation(context, {
|
|
731
|
+
userId: otherUserId,
|
|
732
|
+
content: 'Hello!'
|
|
733
|
+
});
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
*See individual action files in `src/actions/` for complete API documentation and available options.*
|
|
737
|
+
|
|
738
|
+
GraphQL Schema Utilities
|
|
739
|
+
------------------------
|
|
740
|
+
|
|
741
|
+
The `src/utils/schemaUtils.ts` file provides utilities for working with GraphQL schemas programmatically. These utilities help generate custom GraphQL schema definitions from existing Reaktor types.
|
|
188
742
|
|
|
189
|
-
|
|
190
|
-
import { TODO_CREATE } from 'constants/todo';
|
|
743
|
+
### `composeSchemaFromTypes(types: any[]): string`
|
|
191
744
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
745
|
+
Composes a GraphQL schema string from an array of GraphQL types that support the `toSDL()` method.
|
|
746
|
+
|
|
747
|
+
**Parameters:**
|
|
748
|
+
- `types` - Array of GraphQL types with `toSDL()` method
|
|
749
|
+
|
|
750
|
+
**Returns:** A string containing the concatenated GraphQL schema definitions
|
|
751
|
+
|
|
752
|
+
**Example:**
|
|
753
|
+
```typescript
|
|
754
|
+
import {composeSchemaFromTypes} from 'utils/schemaUtils';
|
|
755
|
+
import {UserType, PostType} from './types';
|
|
756
|
+
|
|
757
|
+
const schema = composeSchemaFromTypes([UserType, PostType]);
|
|
758
|
+
console.log(schema);
|
|
759
|
+
// Output: "type User { ... }\ntype Post { ... }"
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### `getReaktorMutationFields(fieldNames: string[]): string`
|
|
763
|
+
|
|
764
|
+
Extracts and formats GraphQL mutation field definitions from the Reaktor user mutations schema.
|
|
765
|
+
|
|
766
|
+
**Parameters:**
|
|
767
|
+
- `fieldNames` - Array of mutation field names to extract
|
|
768
|
+
|
|
769
|
+
**Returns:** A formatted string containing the GraphQL field definitions with arguments and return types
|
|
770
|
+
|
|
771
|
+
**Example:**
|
|
772
|
+
```typescript
|
|
773
|
+
import {getReaktorMutationFields} from 'utils/schemaUtils';
|
|
774
|
+
|
|
775
|
+
const fields = getReaktorMutationFields(['signIn', 'signUp']);
|
|
776
|
+
console.log(fields);
|
|
777
|
+
// Output:
|
|
778
|
+
// signIn(email: String!, password: String!): AuthResponse
|
|
779
|
+
// signUp(email: String!, password: String!, username: String): User
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
### `getReaktorQueryFields(fieldNames: string[]): string`
|
|
783
|
+
|
|
784
|
+
Extracts and formats GraphQL query field definitions from the Reaktor user queries schema.
|
|
785
|
+
|
|
786
|
+
**Parameters:**
|
|
787
|
+
- `fieldNames` - Array of query field names to extract
|
|
788
|
+
|
|
789
|
+
**Returns:** A formatted string containing the GraphQL field definitions with arguments and return types
|
|
790
|
+
|
|
791
|
+
**Example:**
|
|
792
|
+
```typescript
|
|
793
|
+
import {getReaktorQueryFields} from 'utils/schemaUtils';
|
|
794
|
+
|
|
795
|
+
const fields = getReaktorQueryFields(['getUser', 'listPosts']);
|
|
796
|
+
console.log(fields);
|
|
797
|
+
// Output:
|
|
798
|
+
// getUser(id: ID!): User
|
|
799
|
+
// listPosts(limit: Int, offset: Int): [Post]
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
### `buildCustomMutations(fieldNames: string[]): string`
|
|
803
|
+
|
|
804
|
+
Builds a complete GraphQL Mutation type definition from selected Reaktor mutation fields.
|
|
805
|
+
|
|
806
|
+
**Parameters:**
|
|
807
|
+
- `fieldNames` - Array of mutation field names to include in the type
|
|
808
|
+
|
|
809
|
+
**Returns:** A complete GraphQL Mutation type definition as a string
|
|
810
|
+
|
|
811
|
+
**Example:**
|
|
812
|
+
```typescript
|
|
813
|
+
import {buildCustomMutations} from 'utils/schemaUtils';
|
|
814
|
+
|
|
815
|
+
const mutationType = buildCustomMutations(['signIn', 'signUp']);
|
|
816
|
+
console.log(mutationType);
|
|
817
|
+
// Output:
|
|
818
|
+
// type Mutation {
|
|
819
|
+
// signIn(email: String!, password: String!): AuthResponse
|
|
820
|
+
// signUp(email: String!, password: String!, username: String): User
|
|
821
|
+
// }
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
### `buildCustomQueries(fieldNames: string[]): string`
|
|
825
|
+
|
|
826
|
+
Builds a complete GraphQL Query type definition from selected Reaktor query fields.
|
|
827
|
+
|
|
828
|
+
**Parameters:**
|
|
829
|
+
- `fieldNames` - Array of query field names to include in the type
|
|
830
|
+
|
|
831
|
+
**Returns:** A complete GraphQL Query type definition as a string
|
|
832
|
+
|
|
833
|
+
**Example:**
|
|
834
|
+
```typescript
|
|
835
|
+
import {buildCustomQueries} from 'utils/schemaUtils';
|
|
836
|
+
|
|
837
|
+
const queryType = buildCustomQueries(['getUser', 'listPosts']);
|
|
838
|
+
console.log(queryType);
|
|
839
|
+
// Output:
|
|
840
|
+
// type Query {
|
|
841
|
+
// getUser(id: ID!): User
|
|
842
|
+
// listPosts(limit: Int, offset: Int): [Post]
|
|
843
|
+
// }
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
These utilities are particularly useful when you need to generate custom GraphQL schemas programmatically, such as for API documentation, schema stitching, or creating federated GraphQL services.
|
|
847
|
+
|
|
848
|
+
## GraphQL Handler Usage
|
|
849
|
+
|
|
850
|
+
### Using `createGraphqlHandler`
|
|
851
|
+
|
|
852
|
+
The `createGraphqlHandler` function is the main entry point for handling GraphQL requests in Reaktor. It builds the GraphQL context, applies middleware, and executes queries/mutations using your composed schema.
|
|
853
|
+
|
|
854
|
+
Source of truth:
|
|
855
|
+
- Implementation: [`src/handlers/graphqlHandler.ts`](./src/handlers/graphqlHandler.ts)
|
|
856
|
+
- Architecture notes: [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md)
|
|
857
|
+
|
|
858
|
+
#### Example Usage
|
|
859
|
+
|
|
860
|
+
```typescript
|
|
861
|
+
import {createGraphqlHandler} from './src/handlers/graphqlHandler.js';
|
|
862
|
+
|
|
863
|
+
// Create a handler instance with default Reaktor schema
|
|
864
|
+
const handler = createGraphqlHandler({
|
|
865
|
+
context: {}
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
// Use in an AWS Lambda or Express route
|
|
869
|
+
export const lambdaHandler = async (event) => {
|
|
870
|
+
return await handler(event);
|
|
195
871
|
};
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
#### Custom Composer / Extensions
|
|
875
|
+
|
|
876
|
+
```typescript
|
|
877
|
+
import {SchemaComposer} from 'graphql-compose';
|
|
878
|
+
import {createGraphqlHandler} from './src/handlers/graphqlHandler.js';
|
|
879
|
+
|
|
880
|
+
const appComposer = new SchemaComposer();
|
|
881
|
+
|
|
882
|
+
const handler = createGraphqlHandler({
|
|
883
|
+
composer: appComposer,
|
|
884
|
+
context: {},
|
|
885
|
+
extraQueries: {
|
|
886
|
+
appHealth: {
|
|
887
|
+
type: 'Boolean!',
|
|
888
|
+
resolve: () => true
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
extraMutations: {},
|
|
892
|
+
middleware: []
|
|
893
|
+
});
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
#### How Context Works
|
|
897
|
+
- The handler builds a context object for each request, including config, session, and request data.
|
|
898
|
+
- This context is passed to all resolvers as the third argument.
|
|
899
|
+
- You can customize context by passing initial values with `createGraphqlHandler({context})`.
|
|
900
|
+
|
|
901
|
+
#### Typical Integration
|
|
902
|
+
- For AWS Lambda: export the handler and wire it to API Gateway events.
|
|
903
|
+
- For Express: call the handler with the request event object.
|
|
904
|
+
|
|
905
|
+
See [`src/handlers/graphqlHandler.ts`](./src/handlers/graphqlHandler.ts) for implementation details.
|
|
906
|
+
|
|
907
|
+
## Available Action Functions
|
|
908
|
+
|
|
909
|
+
Below is a list of available functions for each main action group. These can be used in resolvers, business logic, or for direct API calls.
|
|
910
|
+
|
|
911
|
+
### Users
|
|
912
|
+
- createToken
|
|
913
|
+
- getUserOptional
|
|
914
|
+
- parseUserOptions
|
|
915
|
+
- addUser
|
|
916
|
+
- updateUser
|
|
917
|
+
- forgotPassword
|
|
918
|
+
- resetPassword
|
|
919
|
+
- confirmCode
|
|
920
|
+
- deleteUser
|
|
921
|
+
- deactivateUser
|
|
922
|
+
- getDisplayName
|
|
923
|
+
- getSessionUser
|
|
924
|
+
- getUser
|
|
925
|
+
- getUsers
|
|
926
|
+
- getUsersByReactions
|
|
927
|
+
- getUsersByTags
|
|
928
|
+
- getUsersByLatest
|
|
929
|
+
- getUsersByConnection
|
|
930
|
+
- refreshSession
|
|
931
|
+
- signIn
|
|
932
|
+
- signOut
|
|
933
|
+
- getActiveUserCount
|
|
934
|
+
- getUserByToken
|
|
935
|
+
|
|
936
|
+
### Groups
|
|
937
|
+
- getGroupList
|
|
938
|
+
- getGroupListByUser
|
|
939
|
+
- getGroupListByTags
|
|
940
|
+
- getGroupById
|
|
941
|
+
- getGroupDetails
|
|
942
|
+
- createGroupEdge
|
|
943
|
+
- addGroup
|
|
944
|
+
- updateGroup
|
|
945
|
+
- deleteGroup
|
|
946
|
+
- getGroupsByReaction
|
|
947
|
+
- isGrouped
|
|
948
|
+
|
|
949
|
+
### Posts
|
|
950
|
+
- parsePostOptions
|
|
951
|
+
- getPostOptional
|
|
952
|
+
- getPost
|
|
953
|
+
- getPostsByArea
|
|
954
|
+
- getPostsByLatest
|
|
955
|
+
- getPostsByReactions
|
|
956
|
+
- getPostsByTags
|
|
957
|
+
- getPostsByUser
|
|
958
|
+
- getPostComments
|
|
959
|
+
- addPost
|
|
960
|
+
- updatePost
|
|
961
|
+
- deletePost
|
|
962
|
+
- createPostEdge
|
|
963
|
+
|
|
964
|
+
### Tags
|
|
965
|
+
- getTags
|
|
966
|
+
- getTagsByItem
|
|
967
|
+
- getTag
|
|
968
|
+
- getTagsByName
|
|
969
|
+
- addTag
|
|
970
|
+
- addTagToItem
|
|
971
|
+
- updateTag
|
|
972
|
+
- deleteTag
|
|
973
|
+
- deleteTagFromEdge
|
|
974
|
+
- deleteTagFromItem
|
|
975
|
+
- extractTags
|
|
976
|
+
- updateTagsInItem
|
|
977
|
+
|
|
978
|
+
### Conversations
|
|
979
|
+
- parseConversationOptions
|
|
980
|
+
- getConversations
|
|
981
|
+
- getDirectConversation
|
|
982
|
+
- addDirectConversation
|
|
983
|
+
- getConnectionUsers
|
|
984
|
+
- getConversationUsers
|
|
985
|
+
- getConversation
|
|
986
|
+
- updateConversation
|
|
987
|
+
- addUserToConversation
|
|
988
|
+
- deleteUserFromConversation
|
|
989
|
+
|
|
990
|
+
### Reactions
|
|
991
|
+
- parseReactionOptions
|
|
992
|
+
- addReaction
|
|
993
|
+
- deleteReaction
|
|
994
|
+
- deleteReactionByItem
|
|
995
|
+
- updateReaction
|
|
996
|
+
- getReactionCount
|
|
997
|
+
- getReactionCountByUser
|
|
998
|
+
- getGroupUsersByReaction
|
|
999
|
+
- getReactionsByItem
|
|
1000
|
+
- getItemsByReaction
|
|
1001
|
+
- hasReaction
|
|
1002
|
+
|
|
1003
|
+
### Notifications
|
|
1004
|
+
- getApnProvider
|
|
1005
|
+
- pushNotification
|
|
1006
|
+
- clearBadges
|
|
1007
|
+
|
|
1008
|
+
### Images
|
|
1009
|
+
- parseImageOptions
|
|
1010
|
+
- getImageOptional
|
|
1011
|
+
- getImagesByUser
|
|
1012
|
+
- getImageCountByItem
|
|
1013
|
+
- getImagesByItem
|
|
1014
|
+
- getImagesByGroup
|
|
1015
|
+
- getImagesByReactions
|
|
1016
|
+
- getImage
|
|
1017
|
+
- getPathUserImages
|
|
1018
|
+
- getAppImageUrl
|
|
1019
|
+
- getImageUrl
|
|
1020
|
+
- resizeSaveImage
|
|
1021
|
+
- addImage
|
|
1022
|
+
- addImageEdge
|
|
1023
|
+
- updateImage
|
|
1024
|
+
- deleteImage
|
|
1025
|
+
|
|
1026
|
+
## Flexible Query System
|
|
1027
|
+
|
|
1028
|
+
Reaktor provides a comprehensive, flexible search and filtering system that allows querying any collection by any property, including custom document properties. This system is built with security, performance, and type safety in mind.
|
|
1029
|
+
|
|
1030
|
+
### Overview
|
|
1031
|
+
|
|
1032
|
+
The flexible query system consists of:
|
|
1033
|
+
- **Query Builder** (`src/utils/queryBuilder.ts`) - Type-safe query construction
|
|
1034
|
+
- **AQL Helpers** (`src/utils/aqlHelpers.ts`) - Secure AQL generation utilities
|
|
1035
|
+
- **Query Actions** (`src/actions/query.ts`) - Business logic for executing queries
|
|
1036
|
+
- **GraphQL Resolvers** (`src/queries/query/query.ts`) - GraphQL API endpoints
|
|
1037
|
+
|
|
1038
|
+
### Features
|
|
1039
|
+
|
|
1040
|
+
- ✅ Dynamic filter construction for any collection
|
|
1041
|
+
- ✅ Multiple comparison operators: `==`, `!=`, `>`, `>=`, `<`, `<=`, `LIKE`, `IN`, `NOT IN`, `CONTAINS`
|
|
1042
|
+
- ✅ Nested AND/OR conditions
|
|
1043
|
+
- ✅ Custom property filtering (for documents with dynamic fields)
|
|
1044
|
+
- ✅ Full-text search across multiple collections
|
|
1045
|
+
- ✅ Sorting and pagination
|
|
1046
|
+
- ✅ Type-safe filter definitions
|
|
1047
|
+
- ✅ AQL injection prevention
|
|
1048
|
+
- ✅ Aggregation operations (COUNT, SUM, AVG, MIN, MAX)
|
|
1049
|
+
|
|
1050
|
+
### Basic Query Example
|
|
1051
|
+
|
|
1052
|
+
```typescript
|
|
1053
|
+
import {executeQuery} from '@nlabs/reaktor';
|
|
1054
|
+
|
|
1055
|
+
// Find all active posts from the last 24 hours
|
|
1056
|
+
const results = await executeQuery(context, {
|
|
1057
|
+
collection: 'posts',
|
|
1058
|
+
filters: {
|
|
1059
|
+
logic: 'AND',
|
|
1060
|
+
conditions: [
|
|
1061
|
+
{ field: 'status', operator: '==', value: 'active' },
|
|
1062
|
+
{ field: 'added', operator: '>', value: Date.now() - 86400000 }
|
|
1063
|
+
]
|
|
1064
|
+
},
|
|
1065
|
+
sort: [{ field: 'added', direction: 'DESC' }],
|
|
1066
|
+
limit: { from: 0, to: 20 }
|
|
1067
|
+
});
|
|
1068
|
+
```
|
|
196
1069
|
|
|
197
|
-
|
|
198
|
-
const handler = handlers[action.type];
|
|
1070
|
+
### GraphQL Query Example
|
|
199
1071
|
|
|
200
|
-
|
|
1072
|
+
```graphql
|
|
1073
|
+
query {
|
|
1074
|
+
query {
|
|
1075
|
+
query(options: {
|
|
1076
|
+
collection: "posts",
|
|
1077
|
+
filters: {
|
|
1078
|
+
logic: "AND",
|
|
1079
|
+
conditions: [
|
|
1080
|
+
{ field: "status", operator: "==", value: "published" },
|
|
1081
|
+
{ field: "type", operator: "IN", value: ["article", "blog"] }
|
|
1082
|
+
]
|
|
1083
|
+
},
|
|
1084
|
+
sort: [{ field: "added", direction: "DESC" }],
|
|
1085
|
+
limit: { from: 0, to: 10 }
|
|
1086
|
+
})
|
|
1087
|
+
}
|
|
201
1088
|
}
|
|
202
1089
|
```
|
|
203
1090
|
|
|
204
|
-
|
|
1091
|
+
### Available Operators
|
|
1092
|
+
|
|
1093
|
+
#### Comparison Operators
|
|
1094
|
+
- `==` - Equal to
|
|
1095
|
+
- `!=` - Not equal to
|
|
1096
|
+
- `>` - Greater than
|
|
1097
|
+
- `>=` - Greater than or equal to
|
|
1098
|
+
- `<` - Less than
|
|
1099
|
+
- `<=` - Less than or equal to
|
|
205
1100
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
1101
|
+
#### String Operators
|
|
1102
|
+
- `LIKE` - Pattern matching (supports wildcards with `%`)
|
|
1103
|
+
- `CONTAINS` - Contains substring (case-insensitive by default)
|
|
209
1104
|
|
|
210
|
-
|
|
1105
|
+
#### Array Operators
|
|
1106
|
+
- `IN` - Value exists in array
|
|
1107
|
+
- `NOT IN` - Value does not exist in array
|
|
211
1108
|
|
|
212
|
-
|
|
213
|
-
|
|
1109
|
+
### Complex Filter Example
|
|
1110
|
+
|
|
1111
|
+
```typescript
|
|
1112
|
+
// Find posts that are either:
|
|
1113
|
+
// - Events happening in the next week
|
|
1114
|
+
// - Articles published in the last month
|
|
1115
|
+
const results = await executeQuery(context, {
|
|
1116
|
+
collection: 'posts',
|
|
1117
|
+
filters: {
|
|
1118
|
+
logic: 'OR',
|
|
1119
|
+
conditions: [
|
|
1120
|
+
{
|
|
1121
|
+
logic: 'AND',
|
|
1122
|
+
conditions: [
|
|
1123
|
+
{ field: 'type', operator: '==', value: 'event' },
|
|
1124
|
+
{ field: 'eventDate', operator: '>', value: Date.now() },
|
|
1125
|
+
{ field: 'eventDate', operator: '<', value: Date.now() + 7 * 86400000 }
|
|
1126
|
+
]
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
logic: 'AND',
|
|
1130
|
+
conditions: [
|
|
1131
|
+
{ field: 'type', operator: '==', value: 'article' },
|
|
1132
|
+
{ field: 'publishedAt', operator: '>', value: Date.now() - 30 * 86400000 }
|
|
1133
|
+
]
|
|
1134
|
+
}
|
|
1135
|
+
]
|
|
1136
|
+
},
|
|
1137
|
+
sort: [{ field: 'added', direction: 'DESC' }],
|
|
1138
|
+
limit: { from: 0, to: 50 }
|
|
214
1139
|
});
|
|
215
1140
|
```
|
|
216
1141
|
|
|
217
|
-
|
|
218
|
-
|
|
1142
|
+
### Multi-Collection Search
|
|
1143
|
+
|
|
1144
|
+
Search across multiple collections with a single query:
|
|
1145
|
+
|
|
1146
|
+
```typescript
|
|
1147
|
+
import {executeSearch} from '@nlabs/reaktor';
|
|
1148
|
+
|
|
1149
|
+
const searchResults = await executeSearch(context, {
|
|
1150
|
+
collections: ['posts', 'users', 'groups'],
|
|
1151
|
+
query: 'nodejs',
|
|
1152
|
+
searchFields: ['name', 'content', 'description'],
|
|
1153
|
+
filters: {
|
|
1154
|
+
logic: 'AND',
|
|
1155
|
+
conditions: [
|
|
1156
|
+
{ field: 'status', operator: '==', value: 'active' }
|
|
1157
|
+
]
|
|
1158
|
+
},
|
|
1159
|
+
limit: { from: 0, to: 50 }
|
|
1160
|
+
});
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
### Aggregation Operations
|
|
1164
|
+
|
|
1165
|
+
Perform aggregations on any collection:
|
|
1166
|
+
|
|
1167
|
+
```typescript
|
|
1168
|
+
import {executeAggregation} from '@nlabs/reaktor';
|
|
1169
|
+
|
|
1170
|
+
// Count active users
|
|
1171
|
+
const userCount = await executeAggregation(context, {
|
|
1172
|
+
collection: 'users',
|
|
1173
|
+
type: 'COUNT',
|
|
1174
|
+
filters: {
|
|
1175
|
+
logic: 'AND',
|
|
1176
|
+
conditions: [
|
|
1177
|
+
{ field: 'status', operator: '==', value: 'active' }
|
|
1178
|
+
]
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
|
|
1182
|
+
// Calculate total revenue
|
|
1183
|
+
const totalRevenue = await executeAggregation(context, {
|
|
1184
|
+
collection: 'payments',
|
|
1185
|
+
type: 'SUM',
|
|
1186
|
+
field: 'amount',
|
|
1187
|
+
filters: {
|
|
1188
|
+
logic: 'AND',
|
|
1189
|
+
conditions: [
|
|
1190
|
+
{ field: 'status', operator: '==', value: 'completed' }
|
|
1191
|
+
]
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
|
|
1195
|
+
// Get average rating
|
|
1196
|
+
const avgRating = await executeAggregation(context, {
|
|
1197
|
+
collection: 'reviews',
|
|
1198
|
+
type: 'AVG',
|
|
1199
|
+
field: 'rating'
|
|
1200
|
+
});
|
|
1201
|
+
```
|
|
1202
|
+
|
|
1203
|
+
### Custom Property Filtering
|
|
1204
|
+
|
|
1205
|
+
Query documents with dynamic/custom fields:
|
|
1206
|
+
|
|
1207
|
+
```typescript
|
|
1208
|
+
const results = await executeQuery(context, {
|
|
1209
|
+
collection: 'posts',
|
|
1210
|
+
filters: {
|
|
1211
|
+
logic: 'AND',
|
|
1212
|
+
conditions: [
|
|
1213
|
+
{ field: 'type', operator: '==', value: 'event' },
|
|
1214
|
+
{ field: 'customField.status', operator: '==', value: 'confirmed' },
|
|
1215
|
+
{ field: 'customField.capacity', operator: '>=', value: 100 }
|
|
1216
|
+
]
|
|
1217
|
+
},
|
|
1218
|
+
includeCustomFields: true
|
|
1219
|
+
});
|
|
1220
|
+
```
|
|
1221
|
+
|
|
1222
|
+
### Field Selection
|
|
1223
|
+
|
|
1224
|
+
Return only specific fields to optimize performance:
|
|
1225
|
+
|
|
1226
|
+
```typescript
|
|
1227
|
+
const results = await executeQuery(context, {
|
|
1228
|
+
collection: 'users',
|
|
1229
|
+
fields: ['_id', 'name', 'email', 'status'],
|
|
1230
|
+
filters: {
|
|
1231
|
+
logic: 'AND',
|
|
1232
|
+
conditions: [
|
|
1233
|
+
{ field: 'status', operator: '==', value: 'active' }
|
|
1234
|
+
]
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
### Performance Tips
|
|
1240
|
+
|
|
1241
|
+
1. **Use Indexes** - Ensure your ArangoDB collections have appropriate indexes for frequently filtered fields
|
|
1242
|
+
2. **Limit Results** - Always use pagination to avoid loading large datasets
|
|
1243
|
+
3. **Select Fields** - Use the `fields` parameter to return only needed data
|
|
1244
|
+
4. **Filter Early** - Apply filters before sorting for better performance
|
|
1245
|
+
5. **Avoid LIKE** - Use CONTAINS or full-text search when possible
|
|
1246
|
+
|
|
1247
|
+
```typescript
|
|
1248
|
+
// Good - Efficient with indexes
|
|
1249
|
+
{
|
|
1250
|
+
collection: 'posts',
|
|
1251
|
+
filters: {
|
|
1252
|
+
logic: 'AND',
|
|
1253
|
+
conditions: [
|
|
1254
|
+
{ field: 'status', operator: '==', value: 'active' },
|
|
1255
|
+
{ field: 'added', operator: '>', value: timestamp }
|
|
1256
|
+
]
|
|
1257
|
+
},
|
|
1258
|
+
fields: ['_id', 'title', 'added'],
|
|
1259
|
+
limit: { from: 0, to: 20 }
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// Avoid - Slower without proper indexes
|
|
1263
|
+
{
|
|
1264
|
+
collection: 'posts',
|
|
1265
|
+
filters: {
|
|
1266
|
+
logic: 'AND',
|
|
1267
|
+
conditions: [
|
|
1268
|
+
{ field: 'content', operator: 'LIKE', value: '%search%' }
|
|
1269
|
+
]
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
```
|
|
1273
|
+
|
|
1274
|
+
### Error Handling
|
|
1275
|
+
|
|
1276
|
+
All query functions throw descriptive errors:
|
|
1277
|
+
|
|
1278
|
+
```typescript
|
|
1279
|
+
try {
|
|
1280
|
+
const results = await executeQuery(context, options);
|
|
1281
|
+
} catch (error) {
|
|
1282
|
+
// Error types:
|
|
1283
|
+
// - Invalid collection name
|
|
1284
|
+
// - Invalid field name
|
|
1285
|
+
// - Invalid operator
|
|
1286
|
+
// - Database connection error
|
|
1287
|
+
// - Query execution error
|
|
1288
|
+
console.error('Query failed:', error.message);
|
|
1289
|
+
}
|
|
1290
|
+
```
|
|
1291
|
+
|
|
1292
|
+
### Common Use Cases
|
|
1293
|
+
|
|
1294
|
+
#### 1. Search Users by Multiple Criteria
|
|
1295
|
+
```typescript
|
|
1296
|
+
const users = await executeQuery(context, {
|
|
1297
|
+
collection: 'users',
|
|
1298
|
+
filters: {
|
|
1299
|
+
logic: 'AND',
|
|
1300
|
+
conditions: [
|
|
1301
|
+
{ field: 'status', operator: '==', value: 'active' },
|
|
1302
|
+
{ field: 'age', operator: '>=', value: 18 },
|
|
1303
|
+
{ field: 'role', operator: 'IN', value: ['admin', 'moderator'] }
|
|
1304
|
+
]
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
#### 2. Find Recent Posts with Tags
|
|
1310
|
+
```typescript
|
|
1311
|
+
const posts = await executeQuery(context, {
|
|
1312
|
+
collection: 'posts',
|
|
1313
|
+
filters: {
|
|
1314
|
+
logic: 'AND',
|
|
1315
|
+
conditions: [
|
|
1316
|
+
{ field: 'added', operator: '>', value: Date.now() - 7 * 86400000 },
|
|
1317
|
+
{ field: 'tags', operator: 'CONTAINS', value: 'javascript' }
|
|
1318
|
+
]
|
|
1319
|
+
},
|
|
1320
|
+
sort: [{ field: 'added', direction: 'DESC' }],
|
|
1321
|
+
limit: { from: 0, to: 10 }
|
|
1322
|
+
});
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
#### 3. Case-Insensitive Email Search
|
|
1326
|
+
```typescript
|
|
1327
|
+
const users = await executeQuery(context, {
|
|
1328
|
+
collection: 'users',
|
|
1329
|
+
filters: {
|
|
1330
|
+
logic: 'AND',
|
|
1331
|
+
conditions: [
|
|
1332
|
+
{
|
|
1333
|
+
field: 'email',
|
|
1334
|
+
operator: 'CONTAINS',
|
|
1335
|
+
value: 'example.com',
|
|
1336
|
+
caseSensitive: false
|
|
1337
|
+
}
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
### API Reference
|
|
1344
|
+
|
|
1345
|
+
#### `executeQuery(context, options)`
|
|
1346
|
+
Execute a flexible query on any collection.
|
|
1347
|
+
|
|
1348
|
+
**Parameters:**
|
|
1349
|
+
- `context: ApiContext` - API context with session and database info
|
|
1350
|
+
- `options: QueryOptions` - Query configuration
|
|
1351
|
+
|
|
1352
|
+
**Returns:** `Promise<any[]>` - Array of matching documents
|
|
1353
|
+
|
|
1354
|
+
#### `executeSearch(context, options)`
|
|
1355
|
+
Perform multi-collection search.
|
|
1356
|
+
|
|
1357
|
+
**Parameters:**
|
|
1358
|
+
- `context: ApiContext` - API context
|
|
1359
|
+
- `options: SearchOptions` - Search configuration
|
|
1360
|
+
|
|
1361
|
+
**Returns:** `Promise<any[]>` - Array of search results
|
|
1362
|
+
|
|
1363
|
+
#### `executeAggregation(context, options)`
|
|
1364
|
+
Execute aggregation operations.
|
|
1365
|
+
|
|
1366
|
+
**Parameters:**
|
|
1367
|
+
- `context: ApiContext` - API context
|
|
1368
|
+
- `options: AggregationOptions` - Aggregation configuration
|
|
1369
|
+
|
|
1370
|
+
**Returns:** `Promise<any>` - Aggregation result
|
|
1371
|
+
|
|
1372
|
+
For more details, see the TypeScript definitions in `src/types/arangodb.types.ts`.
|
|
1373
|
+
|
|
1374
|
+
Refer to the respective files in `src/actions/` for full function signatures and usage details.
|
|
1375
|
+
|
|
1376
|
+
## Documentation
|
|
1377
|
+
|
|
1378
|
+
For comprehensive guides and detailed documentation, see:
|
|
1379
|
+
|
|
1380
|
+
- **[Architecture Guide](./docs/ARCHITECTURE.md)** - System overview, data flow, security model, and extension points
|
|
1381
|
+
- **[Query System Guide](./docs/QUERY_SYSTEM.md)** - Complete query system documentation with examples and best practices
|
|
1382
|
+
- **[Development Guide](./docs/DEVELOPMENT.md)** - Setup instructions, coding patterns, and contribution guidelines
|
|
1383
|
+
- **[Database i18n Guide](./DATABASE_I18N_GUIDE.md)** - Internationalization system documentation
|
|
1384
|
+
- **[Test Utilities Guide](./TEST_UTILITIES_GUIDE.md)** - Testing patterns and helper functions
|
|
1385
|
+
|
|
1386
|
+
## Additional Resources
|
|
1387
|
+
|
|
1388
|
+
- [ArangoDB Documentation](https://www.arangodb.com/docs/)
|
|
1389
|
+
- [GraphQL Compose Documentation](https://graphql-compose.github.io/)
|
|
1390
|
+
- [TypeScript Handbook](https://www.typescriptlang.org/docs/)
|
|
1391
|
+
- [Zod Documentation](https://zod.dev/)
|
|
1392
|
+
|
|
1393
|
+
## Contributing
|
|
1394
|
+
|
|
1395
|
+
1. Fork the repository
|
|
1396
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
1397
|
+
3. Follow the coding conventions in [Development Guide](./docs/DEVELOPMENT.md)
|
|
1398
|
+
4. Write tests for new functionality
|
|
1399
|
+
5. Ensure all tests pass (`npm test`)
|
|
1400
|
+
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
1401
|
+
7. Push to the branch (`git push origin feature/amazing-feature`)
|
|
1402
|
+
8. Open a Pull Request
|
|
1403
|
+
|
|
1404
|
+
## License
|
|
219
1405
|
|
|
220
|
-
|
|
1406
|
+
See the LICENSE file for license rights and limitations (Apache-2.0).
|