parse-server 2.8.4 → 8.6.2

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 (240) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +929 -278
  4. package/lib/AccountLockout.js +47 -30
  5. package/lib/Adapters/AdapterLoader.js +21 -6
  6. package/lib/Adapters/Analytics/AnalyticsAdapter.js +15 -12
  7. package/lib/Adapters/Auth/AuthAdapter.js +116 -13
  8. package/lib/Adapters/Auth/BaseCodeAuthAdapter.js +99 -0
  9. package/lib/Adapters/Auth/OAuth1Client.js +27 -46
  10. package/lib/Adapters/Auth/apple.js +123 -0
  11. package/lib/Adapters/Auth/facebook.js +162 -35
  12. package/lib/Adapters/Auth/gcenter.js +217 -0
  13. package/lib/Adapters/Auth/github.js +118 -48
  14. package/lib/Adapters/Auth/google.js +160 -51
  15. package/lib/Adapters/Auth/gpgames.js +125 -0
  16. package/lib/Adapters/Auth/httpsRequest.js +6 -7
  17. package/lib/Adapters/Auth/index.js +170 -62
  18. package/lib/Adapters/Auth/instagram.js +114 -40
  19. package/lib/Adapters/Auth/janraincapture.js +52 -23
  20. package/lib/Adapters/Auth/janrainengage.js +19 -36
  21. package/lib/Adapters/Auth/keycloak.js +148 -0
  22. package/lib/Adapters/Auth/ldap.js +167 -0
  23. package/lib/Adapters/Auth/line.js +125 -0
  24. package/lib/Adapters/Auth/linkedin.js +111 -55
  25. package/lib/Adapters/Auth/meetup.js +24 -34
  26. package/lib/Adapters/Auth/mfa.js +324 -0
  27. package/lib/Adapters/Auth/microsoft.js +111 -0
  28. package/lib/Adapters/Auth/oauth2.js +97 -162
  29. package/lib/Adapters/Auth/phantauth.js +53 -0
  30. package/lib/Adapters/Auth/qq.js +108 -49
  31. package/lib/Adapters/Auth/spotify.js +107 -55
  32. package/lib/Adapters/Auth/twitter.js +188 -48
  33. package/lib/Adapters/Auth/utils.js +28 -0
  34. package/lib/Adapters/Auth/vkontakte.js +26 -39
  35. package/lib/Adapters/Auth/wechat.js +106 -44
  36. package/lib/Adapters/Auth/weibo.js +132 -58
  37. package/lib/Adapters/Cache/CacheAdapter.js +13 -8
  38. package/lib/Adapters/Cache/InMemoryCache.js +3 -13
  39. package/lib/Adapters/Cache/InMemoryCacheAdapter.js +5 -13
  40. package/lib/Adapters/Cache/LRUCache.js +13 -27
  41. package/lib/Adapters/Cache/NullCacheAdapter.js +3 -8
  42. package/lib/Adapters/Cache/RedisCacheAdapter.js +85 -76
  43. package/lib/Adapters/Cache/SchemaCache.js +25 -0
  44. package/lib/Adapters/Email/MailAdapter.js +10 -8
  45. package/lib/Adapters/Files/FilesAdapter.js +83 -25
  46. package/lib/Adapters/Files/GridFSBucketAdapter.js +231 -0
  47. package/lib/Adapters/Files/GridStoreAdapter.js +4 -91
  48. package/lib/Adapters/Logger/LoggerAdapter.js +18 -14
  49. package/lib/Adapters/Logger/WinstonLogger.js +69 -88
  50. package/lib/Adapters/Logger/WinstonLoggerAdapter.js +7 -16
  51. package/lib/Adapters/MessageQueue/EventEmitterMQ.js +8 -26
  52. package/lib/Adapters/PubSub/EventEmitterPubSub.js +12 -25
  53. package/lib/Adapters/PubSub/PubSubAdapter.js +34 -0
  54. package/lib/Adapters/PubSub/RedisPubSub.js +42 -19
  55. package/lib/Adapters/Push/PushAdapter.js +14 -7
  56. package/lib/Adapters/Storage/Mongo/MongoCollection.js +137 -45
  57. package/lib/Adapters/Storage/Mongo/MongoSchemaCollection.js +158 -63
  58. package/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js +320 -168
  59. package/lib/Adapters/Storage/Mongo/MongoTransform.js +279 -306
  60. package/lib/Adapters/Storage/Postgres/PostgresClient.js +14 -10
  61. package/lib/Adapters/Storage/Postgres/PostgresConfigParser.js +47 -21
  62. package/lib/Adapters/Storage/Postgres/PostgresStorageAdapter.js +854 -468
  63. package/lib/Adapters/Storage/Postgres/sql/index.js +4 -6
  64. package/lib/Adapters/Storage/StorageAdapter.js +1 -1
  65. package/lib/Adapters/WebSocketServer/WSAdapter.js +35 -0
  66. package/lib/Adapters/WebSocketServer/WSSAdapter.js +66 -0
  67. package/lib/Auth.js +488 -125
  68. package/lib/ClientSDK.js +2 -6
  69. package/lib/Config.js +525 -94
  70. package/lib/Controllers/AdaptableController.js +5 -25
  71. package/lib/Controllers/AnalyticsController.js +22 -23
  72. package/lib/Controllers/CacheController.js +10 -31
  73. package/lib/Controllers/DatabaseController.js +767 -313
  74. package/lib/Controllers/FilesController.js +49 -54
  75. package/lib/Controllers/HooksController.js +80 -84
  76. package/lib/Controllers/LiveQueryController.js +35 -22
  77. package/lib/Controllers/LoggerController.js +22 -58
  78. package/lib/Controllers/ParseGraphQLController.js +293 -0
  79. package/lib/Controllers/PushController.js +58 -49
  80. package/lib/Controllers/SchemaController.js +916 -422
  81. package/lib/Controllers/UserController.js +265 -180
  82. package/lib/Controllers/index.js +90 -125
  83. package/lib/Controllers/types.js +1 -1
  84. package/lib/Deprecator/Deprecations.js +30 -0
  85. package/lib/Deprecator/Deprecator.js +127 -0
  86. package/lib/Error.js +48 -0
  87. package/lib/GraphQL/ParseGraphQLSchema.js +375 -0
  88. package/lib/GraphQL/ParseGraphQLServer.js +214 -0
  89. package/lib/GraphQL/helpers/objectsMutations.js +30 -0
  90. package/lib/GraphQL/helpers/objectsQueries.js +246 -0
  91. package/lib/GraphQL/loaders/configMutations.js +87 -0
  92. package/lib/GraphQL/loaders/configQueries.js +79 -0
  93. package/lib/GraphQL/loaders/defaultGraphQLMutations.js +21 -0
  94. package/lib/GraphQL/loaders/defaultGraphQLQueries.js +23 -0
  95. package/lib/GraphQL/loaders/defaultGraphQLTypes.js +1098 -0
  96. package/lib/GraphQL/loaders/defaultRelaySchema.js +53 -0
  97. package/lib/GraphQL/loaders/filesMutations.js +107 -0
  98. package/lib/GraphQL/loaders/functionsMutations.js +78 -0
  99. package/lib/GraphQL/loaders/parseClassMutations.js +268 -0
  100. package/lib/GraphQL/loaders/parseClassQueries.js +127 -0
  101. package/lib/GraphQL/loaders/parseClassTypes.js +493 -0
  102. package/lib/GraphQL/loaders/schemaDirectives.js +62 -0
  103. package/lib/GraphQL/loaders/schemaMutations.js +162 -0
  104. package/lib/GraphQL/loaders/schemaQueries.js +81 -0
  105. package/lib/GraphQL/loaders/schemaTypes.js +341 -0
  106. package/lib/GraphQL/loaders/usersMutations.js +433 -0
  107. package/lib/GraphQL/loaders/usersQueries.js +90 -0
  108. package/lib/GraphQL/parseGraphQLUtils.js +63 -0
  109. package/lib/GraphQL/transformers/className.js +14 -0
  110. package/lib/GraphQL/transformers/constraintType.js +53 -0
  111. package/lib/GraphQL/transformers/inputType.js +51 -0
  112. package/lib/GraphQL/transformers/mutation.js +274 -0
  113. package/lib/GraphQL/transformers/outputType.js +51 -0
  114. package/lib/GraphQL/transformers/query.js +237 -0
  115. package/lib/GraphQL/transformers/schemaFields.js +99 -0
  116. package/lib/KeyPromiseQueue.js +48 -0
  117. package/lib/LiveQuery/Client.js +25 -33
  118. package/lib/LiveQuery/Id.js +2 -5
  119. package/lib/LiveQuery/ParseCloudCodePublisher.js +26 -23
  120. package/lib/LiveQuery/ParseLiveQueryServer.js +560 -285
  121. package/lib/LiveQuery/ParsePubSub.js +7 -16
  122. package/lib/LiveQuery/ParseWebSocketServer.js +42 -39
  123. package/lib/LiveQuery/QueryTools.js +76 -15
  124. package/lib/LiveQuery/RequestSchema.js +111 -97
  125. package/lib/LiveQuery/SessionTokenCache.js +23 -36
  126. package/lib/LiveQuery/Subscription.js +8 -17
  127. package/lib/LiveQuery/equalObjects.js +2 -3
  128. package/lib/Options/Definitions.js +1355 -382
  129. package/lib/Options/docs.js +301 -62
  130. package/lib/Options/index.js +11 -1
  131. package/lib/Options/parsers.js +14 -10
  132. package/lib/Page.js +44 -0
  133. package/lib/ParseMessageQueue.js +6 -13
  134. package/lib/ParseServer.js +474 -235
  135. package/lib/ParseServerRESTController.js +102 -40
  136. package/lib/PromiseRouter.js +39 -50
  137. package/lib/Push/PushQueue.js +24 -30
  138. package/lib/Push/PushWorker.js +32 -56
  139. package/lib/Push/utils.js +22 -35
  140. package/lib/RestQuery.js +361 -139
  141. package/lib/RestWrite.js +713 -344
  142. package/lib/Routers/AggregateRouter.js +97 -71
  143. package/lib/Routers/AnalyticsRouter.js +8 -14
  144. package/lib/Routers/AudiencesRouter.js +16 -35
  145. package/lib/Routers/ClassesRouter.js +86 -72
  146. package/lib/Routers/CloudCodeRouter.js +28 -37
  147. package/lib/Routers/FeaturesRouter.js +22 -25
  148. package/lib/Routers/FilesRouter.js +266 -171
  149. package/lib/Routers/FunctionsRouter.js +87 -103
  150. package/lib/Routers/GlobalConfigRouter.js +94 -33
  151. package/lib/Routers/GraphQLRouter.js +41 -0
  152. package/lib/Routers/HooksRouter.js +43 -47
  153. package/lib/Routers/IAPValidationRouter.js +57 -70
  154. package/lib/Routers/InstallationsRouter.js +17 -25
  155. package/lib/Routers/LogsRouter.js +10 -25
  156. package/lib/Routers/PagesRouter.js +647 -0
  157. package/lib/Routers/PublicAPIRouter.js +104 -112
  158. package/lib/Routers/PurgeRouter.js +19 -29
  159. package/lib/Routers/PushRouter.js +14 -28
  160. package/lib/Routers/RolesRouter.js +7 -14
  161. package/lib/Routers/SchemasRouter.js +63 -42
  162. package/lib/Routers/SecurityRouter.js +34 -0
  163. package/lib/Routers/SessionsRouter.js +25 -38
  164. package/lib/Routers/UsersRouter.js +463 -190
  165. package/lib/SchemaMigrations/DefinedSchemas.js +379 -0
  166. package/lib/SchemaMigrations/Migrations.js +30 -0
  167. package/lib/Security/Check.js +109 -0
  168. package/lib/Security/CheckGroup.js +44 -0
  169. package/lib/Security/CheckGroups/CheckGroupDatabase.js +44 -0
  170. package/lib/Security/CheckGroups/CheckGroupServerConfig.js +96 -0
  171. package/lib/Security/CheckGroups/CheckGroups.js +21 -0
  172. package/lib/Security/CheckRunner.js +213 -0
  173. package/lib/SharedRest.js +29 -0
  174. package/lib/StatusHandler.js +96 -93
  175. package/lib/TestUtils.js +70 -14
  176. package/lib/Utils.js +468 -0
  177. package/lib/batch.js +74 -40
  178. package/lib/cache.js +8 -8
  179. package/lib/cli/definitions/parse-live-query-server.js +4 -3
  180. package/lib/cli/definitions/parse-server.js +4 -3
  181. package/lib/cli/parse-live-query-server.js +9 -17
  182. package/lib/cli/parse-server.js +49 -47
  183. package/lib/cli/utils/commander.js +20 -29
  184. package/lib/cli/utils/runner.js +31 -32
  185. package/lib/cloud-code/Parse.Cloud.js +711 -36
  186. package/lib/cloud-code/Parse.Server.js +21 -0
  187. package/lib/cryptoUtils.js +6 -11
  188. package/lib/defaults.js +21 -15
  189. package/lib/deprecated.js +1 -1
  190. package/lib/index.js +78 -67
  191. package/lib/logger.js +12 -20
  192. package/lib/middlewares.js +484 -160
  193. package/lib/password.js +10 -6
  194. package/lib/request.js +175 -0
  195. package/lib/requiredParameter.js +4 -3
  196. package/lib/rest.js +157 -82
  197. package/lib/triggers.js +627 -185
  198. package/lib/vendor/README.md +3 -3
  199. package/lib/vendor/mongodbUrl.js +224 -137
  200. package/package.json +135 -57
  201. package/postinstall.js +38 -50
  202. package/public_html/invalid_verification_link.html +3 -3
  203. package/types/@types/@parse/fs-files-adapter/index.d.ts +5 -0
  204. package/types/@types/deepcopy/index.d.ts +5 -0
  205. package/types/LiveQuery/ParseLiveQueryServer.d.ts +40 -0
  206. package/types/Options/index.d.ts +301 -0
  207. package/types/ParseServer.d.ts +65 -0
  208. package/types/eslint.config.mjs +30 -0
  209. package/types/index.d.ts +21 -0
  210. package/types/logger.d.ts +2 -0
  211. package/types/tests.ts +44 -0
  212. package/types/tsconfig.json +24 -0
  213. package/CHANGELOG.md +0 -1246
  214. package/PATENTS +0 -37
  215. package/bin/dev +0 -37
  216. package/lib/.DS_Store +0 -0
  217. package/lib/Adapters/Auth/common.js +0 -2
  218. package/lib/Adapters/Auth/facebookaccountkit.js +0 -69
  219. package/lib/Controllers/SchemaCache.js +0 -97
  220. package/lib/LiveQuery/.DS_Store +0 -0
  221. package/lib/cli/utils/parsers.js +0 -77
  222. package/lib/cloud-code/.DS_Store +0 -0
  223. package/lib/cloud-code/HTTPResponse.js +0 -57
  224. package/lib/cloud-code/Untitled-1 +0 -123
  225. package/lib/cloud-code/httpRequest.js +0 -102
  226. package/lib/cloud-code/team.html +0 -123
  227. package/lib/graphql/ParseClass.js +0 -234
  228. package/lib/graphql/Schema.js +0 -197
  229. package/lib/graphql/index.js +0 -1
  230. package/lib/graphql/types/ACL.js +0 -35
  231. package/lib/graphql/types/Date.js +0 -25
  232. package/lib/graphql/types/File.js +0 -24
  233. package/lib/graphql/types/GeoPoint.js +0 -35
  234. package/lib/graphql/types/JSONObject.js +0 -30
  235. package/lib/graphql/types/NumberInput.js +0 -43
  236. package/lib/graphql/types/NumberQuery.js +0 -42
  237. package/lib/graphql/types/Pointer.js +0 -35
  238. package/lib/graphql/types/QueryConstraint.js +0 -61
  239. package/lib/graphql/types/StringQuery.js +0 -39
  240. package/lib/graphql/types/index.js +0 -110
@@ -1,197 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLParseSchema = undefined;
7
-
8
- var _ParseClass = require('./ParseClass');
9
-
10
- var _graphql = require('graphql');
11
-
12
- var _rest = require('../rest');
13
-
14
- var _rest2 = _interopRequireDefault(_rest);
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- // Flatten all graphQL selections to the dot notation.
19
- function reduceSelections(selections) {
20
- return selections.reduce((memo, selection) => {
21
- const value = selection.name.value;
22
- if (selection.selectionSet === null) {
23
- memo.push(value);
24
- } else {
25
- // Get the sub seletions and add on current key
26
- const subSelections = reduceSelections(selection.selectionSet.selections);
27
- memo = memo.concat(subSelections.map(key => {
28
- return value + '.' + key;
29
- }));
30
- }
31
- return memo;
32
- }, []);
33
- }
34
-
35
- // Get the selections for the 1st node in a array of . separated keys
36
- function getSelections(info) {
37
- const node = info.fieldNodes[0];
38
- return reduceSelections(node.selectionSet.selections);
39
- }
40
-
41
- function getQueryOptions(info) {
42
- const selectedKeys = getSelections(info);
43
- const keys = selectedKeys.join(',');
44
- return {
45
- keys,
46
- include: keys
47
- };
48
- }
49
-
50
- function injectClassName(className, result) {
51
- if (Array.isArray(result)) {
52
- return result.map(injectClassName(className));
53
- }
54
- return Object.assign({ className }, result);
55
- }
56
-
57
- function toGraphQLResult(className, singleResult) {
58
- return restResult => {
59
- const results = restResult.results;
60
- if (singleResult) {
61
- return injectClassName(className, results[0]);
62
- }
63
- return injectClassName(className, results);
64
- };
65
- }
66
-
67
- // Runs a find against the rest API
68
- function runFind(context, info, className, where) {
69
- const options = getQueryOptions(info);
70
- return _rest2.default.find(context.config, context.auth, className, where, options).then(toGraphQLResult(className));
71
- }
72
-
73
- // runs a get against the rest API
74
- function runGet(context, info, className, objectId) {
75
- const options = getQueryOptions(info);
76
- return _rest2.default.get(context.config, context.auth, className, objectId, options).then(toGraphQLResult(className, true));
77
- }
78
-
79
- class GraphQLParseSchema {
80
-
81
- constructor(schema, applicationId) {
82
- this.schema = schema;
83
- this.applicationId = applicationId;
84
- this.types = {};
85
- }
86
-
87
- Schema() {
88
- return new _graphql.GraphQLSchema({
89
- query: this.Query(),
90
- mutation: this.Mutation()
91
- });
92
- }
93
-
94
- Query() {
95
- const MainSchemaOptions = {
96
- name: 'ParseSchema',
97
- description: `The full parse schema`,
98
- fields: {}
99
- };
100
- Object.keys(this.schema).forEach(className => {
101
- const {
102
- queryType, objectType
103
- } = (0, _ParseClass.loadClass)(className, this.schema);
104
-
105
- MainSchemaOptions.fields[className] = {
106
- type: new _graphql.GraphQLList(objectType),
107
- description: `Use this endpoint to get or query ${className} objects`,
108
- args: {
109
- objectId: { type: _graphql.GraphQLID, name: 'objectId' },
110
- where: { type: queryType }
111
- },
112
- resolve: (root, args, context, info) => {
113
- // Get the selections
114
- let query = {};
115
- if (args.where) {
116
- query = Object.assign(query, args.where);
117
- }
118
- if (args.objectId) {
119
- query = Object.assign(query, { objectId: args.objectId });
120
- }
121
- return runFind(context, info, className, query);
122
- }
123
- };
124
- });
125
- MainSchemaOptions.fields['ParseObject'] = { type: _ParseClass.ParseObject };
126
- return new _graphql.GraphQLObjectType(MainSchemaOptions);
127
- }
128
-
129
- Mutation() {
130
- const MainSchemaMutationOptions = {
131
- name: 'ParseSchemaMutation',
132
- fields: {}
133
- // TODO: Refactor FunctionRouter to extract (as it's a new entry)
134
- // TODO: Implement Functions as mutations
135
-
136
- };Object.keys(this.schema).forEach(className => {
137
- const {
138
- inputType, objectType, updateType
139
- } = (0, _ParseClass.loadClass)(className, this.schema);
140
-
141
- MainSchemaMutationOptions.fields['create' + className] = {
142
- type: objectType,
143
- fields: objectType.fields,
144
- description: `use this method to create a new ${className}`,
145
- args: { input: { type: inputType } },
146
- name: 'create',
147
- resolve: (root, args, context, info) => {
148
- return _rest2.default.create(context.config, context.auth, className, args).then(res => {
149
- // Run find to match graphQL style
150
- return runGet(context, info, className, res.response.objectId);
151
- });
152
- }
153
- };
154
-
155
- MainSchemaMutationOptions.fields['update' + className] = {
156
- type: objectType,
157
- description: `use this method to update an existing ${className}`,
158
- args: {
159
- objectId: { type: new _graphql.GraphQLNonNull(_graphql.GraphQLID), name: 'objectId' },
160
- input: { type: updateType }
161
- },
162
- name: 'update',
163
- resolve: (root, args, context, info) => {
164
- const objectId = args.objectId;
165
- const input = args.input;
166
- return _rest2.default.update(context.config, context.auth, className, objectId, input).then(() => {
167
- // Run find to match graphQL style
168
- return runGet(context, info, className, objectId);
169
- });
170
- }
171
- };
172
-
173
- MainSchemaMutationOptions.fields['destroy' + className] = {
174
- type: _graphql.GraphQLID,
175
- description: `use this method to update delete an existing ${className}`,
176
- args: {
177
- objectId: { type: new _graphql.GraphQLNonNull(_graphql.GraphQLID), name: 'objectId' }
178
- },
179
- name: 'destroy',
180
- resolve: (root, args, context) => {
181
- return _rest2.default.del(context.config, context.auth, className, args.objectId).then(() => {
182
- return args.objectId;
183
- });
184
- }
185
- };
186
- });
187
- return new _graphql.GraphQLObjectType(MainSchemaMutationOptions);
188
- }
189
-
190
- Root() {
191
- return Object.keys(this.schema).reduce((memo, className) => {
192
- memo[className] = {};
193
- return memo;
194
- }, {});
195
- }
196
- }
197
- exports.GraphQLParseSchema = GraphQLParseSchema;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLACLInput = exports.GraphQLACL = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const GraphQLACL = exports.GraphQLACL = new _graphql.GraphQLScalarType({
11
- name: 'ACL',
12
- fields: {
13
- read: {
14
- type: new _graphql.GraphQLList(_graphql.GraphQLString),
15
- name: 'read',
16
- description: 'Read access for the object'
17
- },
18
- write: {
19
- type: new _graphql.GraphQLList(_graphql.GraphQLString),
20
- name: 'write',
21
- description: 'Write access for the object'
22
- }
23
- },
24
- serialize: () => {
25
- throw "not implemented";
26
- },
27
- parseValue: () => {
28
- throw "not implemented";
29
- },
30
- parseLiteral: () => {
31
- throw "not implemented";
32
- }
33
- });
34
-
35
- const GraphQLACLInput = exports.GraphQLACLInput = GraphQLACL;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLDate = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- // http://graphql.org/graphql-js/type/#graphqlscalartype
11
- const GraphQLDate = exports.GraphQLDate = new _graphql.GraphQLScalarType({
12
- name: 'Date',
13
- serialize: obj => {
14
- if (typeof a === 'string') {
15
- return new Date(obj);
16
- }
17
- return obj;
18
- },
19
- parseValue: () => {
20
- throw "Date parseValue not implemented";
21
- },
22
- parseLiteral: () => {
23
- throw "Date parseLiteral not implemented";
24
- }
25
- });
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLFile = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const GraphQLFile = exports.GraphQLFile = new _graphql.GraphQLObjectType({
11
- name: 'File',
12
- fields: {
13
- name: {
14
- type: _graphql.GraphQLString,
15
- name: 'name',
16
- description: 'name of the file'
17
- },
18
- url: {
19
- type: _graphql.GraphQLString,
20
- name: 'url',
21
- description: 'url of the file'
22
- }
23
- }
24
- });
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLGeoPointInput = exports.GraphQLGeoPoint = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const GraphQLGeoPoint = exports.GraphQLGeoPoint = new _graphql.GraphQLScalarType({
11
- name: 'GeoPoint',
12
- fields: {
13
- latitude: {
14
- type: _graphql.GraphQLFloat,
15
- name: 'latitude',
16
- description: 'laititude of the point, in degrees'
17
- },
18
- longitude: {
19
- type: _graphql.GraphQLFloat,
20
- name: 'latitude',
21
- description: 'latitude of the point, in degrees'
22
- }
23
- },
24
- serialize: () => {
25
- throw "not implemented";
26
- },
27
- parseValue: () => {
28
- throw "not implemented";
29
- },
30
- parseLiteral: () => {
31
- throw "not implemented";
32
- }
33
- });
34
-
35
- const GraphQLGeoPointInput = exports.GraphQLGeoPointInput = GraphQLGeoPoint;
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLJSONObject = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- // http://graphql.org/graphql-js/type/#graphqlscalartype
11
- const GraphQLJSONObject = exports.GraphQLJSONObject = new _graphql.GraphQLScalarType({
12
- name: 'JSONObject',
13
- serialize: () => {
14
- throw "JSONObject serialize not implemented";
15
- },
16
- parseValue: () => {
17
- throw "JSONObject parseValue not implemented";
18
- },
19
- parseLiteral: litteral => {
20
- return litteral.fields.reduce((memo, field) => {
21
- const value = field.value;
22
- if (value.kind == 'IntValue') {
23
- memo[field.name.value] = parseInt(value.value, 10);
24
- } else {
25
- memo[field.name.value] = value.value;
26
- }
27
- return memo;
28
- }, {});
29
- }
30
- });
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NumberInput = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const NumberInput = exports.NumberInput = new _graphql.GraphQLScalarType({
11
- name: 'NumberInput',
12
- description: `Input for number
13
- Supported schemas:
14
-
15
- - key: 1
16
- - key: {increment: 1}
17
- `,
18
- serialize: () => {
19
- throw "NumberInput serialize not implemented";
20
- },
21
- parseValue: () => {
22
- throw "NumberInput parseValue not implemented";
23
- },
24
- parseLiteral: ast => {
25
- if (ast.kind == _graphql.Kind.OBJECT) {
26
- const fields = ast.fields;
27
- if (fields.length != 1) {
28
- throw 'Invalid NUmberInput';
29
- }
30
- const field = fields[0];
31
- const operator = field.name.value;
32
- if (operator != "increment") {
33
- throw `the ${operator} operator is not supported`;
34
- }
35
- const value = field.value.value;
36
- return { "__op": "Increment", "amount": parseFloat(value) };
37
- } else if (ast.kind == _graphql.Kind.INT || ast.kind == _graphql.Kind.FLOAT) {
38
- return parseFloat(ast.value);
39
- } else {
40
- throw 'Invalid literal for NumberInput';
41
- }
42
- }
43
- });
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NumberQuery = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const NumberQuery = exports.NumberQuery = new _graphql.GraphQLScalarType({
11
- name: 'NumberQuery',
12
- description: `Queries for number values
13
- Supported constraints:
14
-
15
- - key: 1
16
- - key: {$lt: 1} # less than
17
- - key: {$gt: 1} # greater than
18
- - key: {$lte: 1} # less than or equal
19
- - key: {$gte: 1} # greater than or equal
20
- `,
21
- serialize: () => {
22
- throw "NumberQuery serialize not implemented";
23
- },
24
- parseValue: () => {
25
- throw "NumberQuery parseValue not implemented";
26
- },
27
- parseLiteral: ast => {
28
- if (ast.kind == _graphql.Kind.OBJECT) {
29
- const fields = ast.fields;
30
- return fields.reduce((memo, field) => {
31
- const operator = field.name.value;
32
- const value = field.value.value;
33
- memo['$' + operator] = parseFloat(value);
34
- return memo;
35
- }, {});
36
- } else if (ast.kind == _graphql.Kind.INT || ast.kind == _graphql.Kind.FLOAT) {
37
- return parseFloat(ast.value);
38
- } else {
39
- throw 'Invalid literal for NumberQuery';
40
- }
41
- }
42
- });
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLPointerInput = exports.GraphQLPointer = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const GraphQLPointer = exports.GraphQLPointer = new _graphql.GraphQLScalarType({
11
- name: 'Pointer',
12
- fields: {
13
- objectId: {
14
- type: _graphql.GraphQLID,
15
- name: 'objectId',
16
- description: 'pointer\'s objectId'
17
- },
18
- className: {
19
- type: _graphql.GraphQLString,
20
- name: 'className',
21
- description: 'pointer\'s className'
22
- }
23
- },
24
- serialize: () => {
25
- throw "serialize not implemented";
26
- },
27
- parseValue: () => {
28
- throw "parseValue not implemented";
29
- },
30
- parseLiteral: litteral => {
31
- return { objectId: litteral.value };
32
- }
33
- });
34
-
35
- const GraphQLPointerInput = exports.GraphQLPointerInput = GraphQLPointer;
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.QueryConstraint = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const supportedOperators = ['$eq', '$ne', '$in', '$nin', '$exists', '$select', '$dontSelect'];
11
-
12
- const QueryConstraint = exports.QueryConstraint = new _graphql.GraphQLScalarType({
13
- name: 'QueryConstraint',
14
- description: `Generic Query Constraint
15
- Supported constraints:
16
-
17
- Equal To:
18
- - key: "value"
19
- - key: {$eq: "value"}
20
-
21
- Not Equal To
22
- - key: {$ne: "value"}
23
-
24
- Contained in:
25
- - key: {$in: ["value1", "value2"]}
26
- Not Contained in:
27
- - key: {$nin: ["value1", "value2"]}
28
-
29
- Exists:
30
- - key: {$exists: true}
31
-
32
- This matches a value for a key in the result of a different query
33
- - key: {$select: {"query": {"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}
34
-
35
- Requires that a key’s value not match a value for a key in the result of a different query
36
- - key: {$dontSelect: {"query": {"className":"Team","where":{"winPct":{"$gt":0.5}}},"key":"city"}}}
37
- `,
38
- serialize: () => {
39
- throw "StringQuery serialize not implemented";
40
- },
41
- parseValue: () => {
42
- throw "StringQuery parseValue not implemented";
43
- },
44
- parseLiteral: ast => {
45
- if (ast.kind == _graphql.Kind.OBJECT) {
46
- const fields = ast.fields;
47
- return fields.reduce((memo, field) => {
48
- const operator = field.name.value;
49
- if (supportedOperators.indexOf('$' + operator) > -1) {
50
- const value = field.value.value;
51
- memo['$' + operator] = value;
52
- }
53
- return memo;
54
- }, {});
55
- } else if (ast.kind == _graphql.Kind.STRING) {
56
- return ast.value;
57
- } else {
58
- throw 'Invalid literal for StringQuery';
59
- }
60
- }
61
- });
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.StringQuery = undefined;
7
-
8
- var _graphql = require('graphql');
9
-
10
- const StringQuery = exports.StringQuery = new _graphql.GraphQLScalarType({
11
- name: 'StringQuery',
12
- description: `Query constraint on string parameters
13
- Supported constraints:
14
-
15
- - key: "value"
16
- - key: {$regex: "value"}
17
- `,
18
- serialize: () => {
19
- throw "StringQuery serialize not implemented";
20
- },
21
- parseValue: () => {
22
- throw "StringQuery parseValue not implemented";
23
- },
24
- parseLiteral: ast => {
25
- if (ast.kind == _graphql.Kind.OBJECT) {
26
- const fields = ast.fields;
27
- return fields.reduce((memo, field) => {
28
- const operator = field.name.value;
29
- const value = field.value.value;
30
- memo['$' + operator] = value;
31
- return memo;
32
- }, {});
33
- } else if (ast.kind == _graphql.Kind.STRING) {
34
- return ast.value;
35
- } else {
36
- throw 'Invalid literal for StringQuery';
37
- }
38
- }
39
- });
@@ -1,110 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.GraphQLJSONObject = exports.GraphQLPointer = exports.GraphQLDate = exports.GraphQLFile = exports.GraphQLGeoPointInput = exports.GraphQLGeoPoint = exports.GraphQLACLInput = exports.GraphQLACL = undefined;
7
- exports.type = type;
8
- exports.inputType = inputType;
9
- exports.queryType = queryType;
10
-
11
- var _graphql = require('graphql');
12
-
13
- var _ACL = require('./ACL');
14
-
15
- var _GeoPoint = require('./GeoPoint');
16
-
17
- var _File = require('./File');
18
-
19
- var _Date = require('./Date');
20
-
21
- var _Pointer = require('./Pointer');
22
-
23
- var _JSONObject = require('./JSONObject');
24
-
25
- var _StringQuery = require('./StringQuery');
26
-
27
- var _NumberQuery = require('./NumberQuery');
28
-
29
- var _NumberInput = require('./NumberInput');
30
-
31
- exports.GraphQLACL = _ACL.GraphQLACL;
32
- exports.GraphQLACLInput = _ACL.GraphQLACLInput;
33
- exports.GraphQLGeoPoint = _GeoPoint.GraphQLGeoPoint;
34
- exports.GraphQLGeoPointInput = _GeoPoint.GraphQLGeoPointInput;
35
- exports.GraphQLFile = _File.GraphQLFile;
36
- exports.GraphQLDate = _Date.GraphQLDate;
37
- exports.GraphQLPointer = _Pointer.GraphQLPointer;
38
- exports.GraphQLJSONObject = _JSONObject.GraphQLJSONObject;
39
- function type(fieldName, field) {
40
- if (fieldName === 'objectId') {
41
- return new _graphql.GraphQLNonNull(_graphql.GraphQLID);
42
- }
43
- const type = field.type;
44
- if (type == 'String') {
45
- return _graphql.GraphQLString;
46
- }if (type == 'Number') {
47
- return _graphql.GraphQLFloat;
48
- }if (type == 'Boolean') {
49
- return _graphql.GraphQLBoolean;
50
- }if (type == 'GeoPoint') {
51
- return _GeoPoint.GraphQLGeoPoint;
52
- }if (type == 'File') {
53
- return _File.GraphQLFile;
54
- } else if (type == 'ACL') {
55
- return _ACL.GraphQLACL;
56
- } else if (type == 'Date') {
57
- return _Date.GraphQLDate;
58
- } else if (type == 'Pointer') {
59
- return _Pointer.GraphQLPointer;
60
- }
61
- }
62
-
63
- function inputType(fieldName, field) {
64
- if (fieldName === 'objectId') {
65
- return new _graphql.GraphQLNonNull(_graphql.GraphQLID);
66
- }
67
- const type = field.type;
68
- if (type == 'String') {
69
- return _graphql.GraphQLString;
70
- }if (type == 'Number') {
71
- return _NumberInput.NumberInput;
72
- }if (type == 'Boolean') {
73
- return _graphql.GraphQLBoolean;
74
- }if (type == 'GeoPoint') {
75
- return _GeoPoint.GraphQLGeoPointInput;
76
- }if (type == 'File') {
77
- return _File.GraphQLFile;
78
- } else if (type == 'ACL') {
79
- return _ACL.GraphQLACLInput;
80
- } else if (type == 'Date') {
81
- return _Date.GraphQLDate;
82
- } else if (type == 'Pointer') {
83
- return _Pointer.GraphQLPointerInput;
84
- }
85
- }
86
-
87
- function queryType(fieldName, field) {
88
- if (fieldName === 'objectId') {
89
- return new _graphql.GraphQLNonNull(_graphql.GraphQLID);
90
- }
91
- const type = field.type;
92
- if (type == 'String') {
93
- return _StringQuery.StringQuery;
94
- }if (type == 'Number') {
95
- return _NumberQuery.NumberQuery;
96
- }if (type == 'Boolean') {
97
- return _graphql.GraphQLBoolean;
98
- }if (type == 'GeoPoint') {
99
- return _GeoPoint.GraphQLGeoPointInput;
100
- }if (type == 'File') {
101
- return _File.GraphQLFile;
102
- } else if (type == 'ACL') {
103
- // cannot query on ACL!
104
- return;
105
- } else if (type == 'Date') {
106
- return _Date.GraphQLDate;
107
- } else if (type == 'Pointer') {
108
- return _Pointer.GraphQLPointerInput;
109
- }
110
- }