@webresto/graphql 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/package.json +25 -8
  2. package/src/resolvers/cart.d.ts +4 -2
  3. package/src/resolvers/cart.ts +9 -4
  4. package/test/bootstrap.ts +33 -0
  5. package/test/fixture/.tmp/localDiskDb/archive.db +1 -0
  6. package/test/fixture/.tmp/localDiskDb/dish.db +1 -0
  7. package/test/fixture/.tmp/localDiskDb/dish_images__image_dish.db +1 -0
  8. package/test/fixture/.tmp/localDiskDb/group.db +1 -0
  9. package/test/fixture/.tmp/localDiskDb/group_images__image_group.db +1 -0
  10. package/test/fixture/.tmp/localDiskDb/image.db +1 -0
  11. package/test/fixture/.tmp/localDiskDb/maintenance.db +1 -0
  12. package/test/fixture/.tmp/localDiskDb/order.db +1 -0
  13. package/test/fixture/.tmp/localDiskDb/orderdish.db +1 -0
  14. package/test/fixture/.tmp/localDiskDb/paymentdocument.db +1 -0
  15. package/test/fixture/.tmp/localDiskDb/paymentmethod.db +2 -0
  16. package/test/fixture/.tmp/localDiskDb/place.db +1 -0
  17. package/test/fixture/.tmp/localDiskDb/settings.db +2 -0
  18. package/test/fixture/.tmp/localDiskDb/street.db +1 -0
  19. package/test/{fixtures/v0.12-app → fixture}/api/controllers/.gitkeep +0 -0
  20. package/test/{fixtures/v0.12-app → fixture}/api/models/.gitkeep +0 -0
  21. package/test/{fixtures/v0.12-app → fixture}/api/services/.gitkeep +0 -0
  22. package/test/{fixtures/v0.12-app/app.js → fixture/app-export.js} +73 -73
  23. package/test/fixture/app.js +56 -0
  24. package/test/fixture/config/adminpanel.js +3 -0
  25. package/test/fixture/config/connections.js +9 -0
  26. package/test/fixture/config/env/development.js +10 -0
  27. package/test/{fixtures/v0.12-app → fixture}/config/env/production.js +16 -16
  28. package/test/fixture/config/globals.js +16 -0
  29. package/test/{fixtures/v0.12-app → fixture}/config/hookTimeout.js +8 -8
  30. package/test/{fixtures/v0.12-app → fixture}/config/http.js +93 -93
  31. package/test/{fixtures/v0.12-app → fixture}/config/i18n.js +57 -57
  32. package/test/{fixtures/v0.12-app → fixture}/config/log.js +29 -29
  33. package/test/fixture/config/models.js +9 -0
  34. package/test/fixture/config/modulemanager.js +22 -0
  35. package/test/{fixtures/v0.12-app → fixture}/config/policies.js +51 -51
  36. package/test/{fixtures/v0.12-app → fixture}/config/routes.js +49 -49
  37. package/test/{fixtures/v0.12-app → fixture}/config/session.js +100 -100
  38. package/test/{fixtures/v0.12-app → fixture}/config/sockets.js +141 -141
  39. package/test/{fixtures/v0.12-app → fixture}/config/views.js +94 -94
  40. package/test/fixture/package-lock.json +9805 -0
  41. package/test/fixture/package.json +30 -0
  42. package/test/{fixtures/v0.12-app → fixture}/views/403.ejs +68 -68
  43. package/test/{fixtures/v0.12-app → fixture}/views/404.ejs +68 -68
  44. package/test/{fixtures/v0.12-app → fixture}/views/500.ejs +73 -73
  45. package/test/{fixtures/v0.12-app → fixture}/views/homepage.ejs +74 -74
  46. package/test/{fixtures/v0.12-app → fixture}/views/layout.ejs +91 -91
  47. package/test/unit/first.test.js +6 -8
  48. package/test/unit/first.test.ts +11 -0
  49. package/test/unit/sails_not_crash.test.ts +3 -0
  50. package/test.zip +0 -0
  51. package/test/fixtures/v0.12-app/.gitignore +0 -11
  52. package/test/fixtures/v0.12-app/.sailsrc +0 -11
  53. package/test/fixtures/v0.12-app/api/models/TestModel.js +0 -22
  54. package/test/fixtures/v0.12-app/api/responses/badRequest.js +0 -76
  55. package/test/fixtures/v0.12-app/api/responses/created.js +0 -60
  56. package/test/fixtures/v0.12-app/api/responses/forbidden.js +0 -89
  57. package/test/fixtures/v0.12-app/api/responses/notFound.js +0 -94
  58. package/test/fixtures/v0.12-app/api/responses/ok.js +0 -60
  59. package/test/fixtures/v0.12-app/api/responses/serverError.js +0 -89
  60. package/test/fixtures/v0.12-app/config/bootstrap.js +0 -6
  61. package/test/fixtures/v0.12-app/config/connections.js +0 -5
  62. package/test/fixtures/v0.12-app/config/cors.js +0 -78
  63. package/test/fixtures/v0.12-app/config/csrf.js +0 -64
  64. package/test/fixtures/v0.12-app/config/env/development.js +0 -10
  65. package/test/fixtures/v0.12-app/config/globals.js +0 -63
  66. package/test/fixtures/v0.12-app/config/models.js +0 -3
  67. package/test/fixtures/v0.12-app/config/restoapi.js +0 -3
  68. package/test/fixtures/v0.12-app/config/restocore.js +0 -39
  69. package/test/fixtures/v0.12-app/config/stateflow.js +0 -4
  70. package/test/fixtures/v0.12-app/package.json +0 -34
package/package.json CHANGED
@@ -10,6 +10,27 @@
10
10
  "graphql": "^15.5.0",
11
11
  "waterline-criteria": "^2.0.0"
12
12
  },
13
+ "devDependencies": {
14
+ "@42pub/typed-sails": "^1.0.0",
15
+ "@types/bluebird": "^3.5.32",
16
+ "@types/bluebird-global": "^3.5.12",
17
+ "@types/body-parser": "^1.19.0",
18
+ "@types/chai": "^4.2.11",
19
+ "@types/express": "^4.17.7",
20
+ "@types/faker": "^4.1.12",
21
+ "@types/lodash": "^4.14.157",
22
+ "@types/mocha": "^8.0.2",
23
+ "@types/node": "^14.14.35",
24
+ "@types/uuid": "^8.0.0",
25
+ "@types/waterline": "^0.13.4",
26
+ "@webresto/core": "^1.0.0",
27
+ "chai": "^4.2.0",
28
+ "dotenv": "^16.0.0",
29
+ "faker": "^4.1.0",
30
+ "mocha": "^8.1.1",
31
+ "ts-node": "^10.7.0",
32
+ "typescript": "^3.9.7"
33
+ },
13
34
  "deprecated": false,
14
35
  "description": "Webresto graphql api",
15
36
  "directories": {
@@ -35,13 +56,9 @@
35
56
  },
36
57
  "scripts": {
37
58
  "gendoc": "apidoc -o apidoc/ && apidoc-markdown2 -p apidoc -o docs/api.md",
38
- "test": "echo \"Error: no test specified\" && exit 1",
39
- "test:js": "mocha test/_bootstrap.js test/**/*.test.js",
40
- "test:init": "cd ./test/fixtures/v0.12-app && npm i --no-package-lock --prefix ./ && cd -"
59
+ "test": "mocha -r ts-node/register test/bootstrap.ts './test/{,!(fixture)/**}/*.test.ts' --exit",
60
+ "test:js": "mocha test/bootstrap.js './test/{,!(fixture)/**}/*.test.js' --exit",
61
+ "test:init": "cd ./test/fixture && npm i --no-package-lock --prefix ./ && cd -"
41
62
  },
42
- "version": "1.3.0",
43
- "devDependencies": {
44
- "@types/node": "^14.14.35",
45
- "@webresto/core": "^1.0.0"
46
- }
63
+ "version": "1.3.1"
47
64
  }
@@ -38,8 +38,9 @@ declare const _default: {
38
38
  deliveryItem: any;
39
39
  deliveryCost: number;
40
40
  totalWeight: number;
41
- total: number;
42
41
  trifleFrom: number;
42
+ bonusesTotal: number;
43
+ total: number;
43
44
  orderTotal: number;
44
45
  discountTotal: number;
45
46
  orderDate: string;
@@ -108,8 +109,9 @@ declare const _default: {
108
109
  deliveryItem: any;
109
110
  deliveryCost: number;
110
111
  totalWeight: number;
111
- total: number;
112
112
  trifleFrom: number;
113
+ bonusesTotal: number;
114
+ total: number;
113
115
  orderTotal: number;
114
116
  discountTotal: number;
115
117
  orderDate: string;
@@ -126,7 +126,8 @@ export default {
126
126
  args.replace,
127
127
  args.orderDishId
128
128
  );
129
- return await Order.countCart(order);
129
+ await Order.countCart(order);
130
+ return await Order.populate(order.id);
130
131
  },
131
132
  },
132
133
  orderRemoveDish: {
@@ -150,7 +151,8 @@ export default {
150
151
  const orderDish = await OrderDish.findOne({ id: args.orderDishId });
151
152
 
152
153
  await Order.removeDish(order.id, orderDish, args.amount, false);
153
- return await Order.countCart(order);
154
+ await Order.countCart(order);
155
+ return await Order.populate(order.id);
154
156
  },
155
157
  },
156
158
  orderSetDishAmount: {
@@ -187,7 +189,8 @@ export default {
187
189
  );
188
190
 
189
191
  await Order.setCount(order.id, dish, args.amount);
190
- return await Order.countCart(order);
192
+ await Order.countCart(order);
193
+ return await Order.populate(order.id);
191
194
  },
192
195
  },
193
196
  orderSetDishComment: {
@@ -223,7 +226,8 @@ export default {
223
226
  }
224
227
 
225
228
  await order.setComment(dish, comment);
226
- return await Order.countCart(order);
229
+ await Order.countCart(order);
230
+ return await Order.populate(order.id);
227
231
  },
228
232
  },
229
233
 
@@ -234,6 +238,7 @@ export default {
234
238
  let order = args.order;
235
239
  if (!order.id) throw "order.id field is required"
236
240
  await Order.update({id: order.id}, {trifleFrom: order.trifleFrom})
241
+ await Order.populate(order.id);
237
242
  return await Order.populate(order.id);
238
243
  },
239
244
  },
@@ -0,0 +1,33 @@
1
+ import "mocha";
2
+ require("dotenv").config();
3
+ var Sails = require("./fixture/node_modules/sails").Sails;
4
+
5
+ before(function (done) {
6
+ require("./fixture/app-export");
7
+ this.timeout(50000);
8
+ Sails().lift({}, function (err: any, _sails: any) {
9
+ if (err) return done(err);
10
+ global.sails = _sails;
11
+ return done();
12
+ });
13
+ });
14
+
15
+ after(function (done) {
16
+ if (global.sails) {
17
+ return global.sails.lower(function (err) {
18
+ if (err) {
19
+ done();
20
+ }
21
+ done();
22
+ });
23
+ }
24
+ done();
25
+ });
26
+
27
+ declare global {
28
+ namespace NodeJS {
29
+ interface Global {
30
+ sails: any;
31
+ }
32
+ }
33
+ }
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1,2 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
2
+ {"$$indexCreated":{"fieldName":"adapter","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -0,0 +1,2 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
2
+ {"$$indexCreated":{"fieldName":"key","unique":true,"sparse":false}}
@@ -0,0 +1 @@
1
+ {"$$indexCreated":{"fieldName":"id","unique":true,"sparse":false}}
@@ -1,73 +1,73 @@
1
- /**
2
- * app.js
3
- *
4
- * Use `app.js` to run your app without `sails lift`.
5
- * To start the server, run: `node app.js`.
6
- *
7
- * This is handy in situations where the sails CLI is not relevant or useful.
8
- *
9
- * For example:
10
- * => `node app.js`
11
- * => `forever start app.js`
12
- * => `node debug app.js`
13
- * => `modulus deploy`
14
- * => `heroku scale`
15
- *
16
- *
17
- * The same command-line arguments are supported, e.g.:
18
- * `node app.js --silent --port=80 --prod`
19
- */
20
-
21
-
22
- // Ensure we're in the project directory, so cwd-relative paths work as expected
23
- // no matter where we actually lift from.
24
- // > Note: This is not required in order to lift, but it is a convenient default.
25
- process.chdir(__dirname);
26
-
27
- // Attempt to import `sails`.
28
- var sails;
29
- try {
30
- sails = require('sails');
31
- } catch (e) {
32
- console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
33
- console.error('To do that, run `npm install sails`');
34
- console.error('');
35
- console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
36
- console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
37
- console.error('but if it doesn\'t, the app will run with the global sails instead!');
38
- return;
39
- }
40
-
41
- // --•
42
- // Try to get `rc` dependency (for loading `.sailsrc` files).
43
- var rc;
44
- try {
45
- rc = require('rc');
46
- } catch (e0) {
47
- try {
48
- rc = require('sails/node_modules/rc');
49
- } catch (e1) {
50
- console.error('Could not find dependency: `rc`.');
51
- console.error('Your `.sailsrc` file(s) will be ignored.');
52
- console.error('To resolve this, run:');
53
- console.error('npm install rc --save');
54
- rc = function () { return {}; };
55
- }
56
- }
57
-
58
-
59
-
60
- // function sails() {
61
- // return new Promise(function (resolve, reject) {
62
- // sails.lift(rc('sails'), (err, _sails) => {
63
- // if (err) { return done(err); }
64
- // resolve(_sails);
65
- // });
66
- // })
67
- // }
68
-
69
-
70
- module.exports = {
71
- sails: sails,
72
- rc: rc('sails')
73
- }
1
+ /**
2
+ * app.js
3
+ *
4
+ * Use `app.js` to run your app without `sails lift`.
5
+ * To start the server, run: `node app.js`.
6
+ *
7
+ * This is handy in situations where the sails CLI is not relevant or useful.
8
+ *
9
+ * For example:
10
+ * => `node app.js`
11
+ * => `forever start app.js`
12
+ * => `node debug app.js`
13
+ * => `modulus deploy`
14
+ * => `heroku scale`
15
+ *
16
+ *
17
+ * The same command-line arguments are supported, e.g.:
18
+ * `node app.js --silent --port=80 --prod`
19
+ */
20
+
21
+
22
+ // Ensure we're in the project directory, so cwd-relative paths work as expected
23
+ // no matter where we actually lift from.
24
+ // > Note: This is not required in order to lift, but it is a convenient default.
25
+ process.chdir(__dirname);
26
+
27
+ // Attempt to import `sails`.
28
+ var sails;
29
+ try {
30
+ sails = require('sails');
31
+ } catch (e) {
32
+ console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
33
+ console.error('To do that, run `npm install sails`');
34
+ console.error('');
35
+ console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
36
+ console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
37
+ console.error('but if it doesn\'t, the app will run with the global sails instead!');
38
+ return;
39
+ }
40
+
41
+ // --•
42
+ // Try to get `rc` dependency (for loading `.sailsrc` files).
43
+ var rc;
44
+ try {
45
+ rc = require('rc');
46
+ } catch (e0) {
47
+ try {
48
+ rc = require('sails/accessible/rc');
49
+ } catch (e1) {
50
+ console.error('Could not find dependency: `rc`.');
51
+ console.error('Your `.sailsrc` file(s) will be ignored.');
52
+ console.error('To resolve this, run:');
53
+ console.error('npm install rc --save');
54
+ rc = function () { return {}; };
55
+ }
56
+ }
57
+
58
+
59
+
60
+ // function sails() {
61
+ // return new Promise(function (resolve, reject) {
62
+ // sails.lift(rc('sails'), (err, _sails) => {
63
+ // if (err) { return done(err); }
64
+ // resolve(_sails);
65
+ // });
66
+ // })
67
+ // }
68
+
69
+
70
+ module.exports = {
71
+ sails: sails,
72
+ rc: rc('sails')
73
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * app.js
3
+ *
4
+ * Use `app.js` to run your app without `sails lift`.
5
+ * To start the server, run: `node app.js`.
6
+ *
7
+ * This is handy in situations where the sails CLI is not relevant or useful,
8
+ * such as when you deploy to a server, or a PaaS like Heroku.
9
+ *
10
+ * For example:
11
+ * => `node app.js`
12
+ * => `npm start`
13
+ * => `forever start app.js`
14
+ * => `node debug app.js`
15
+ *
16
+ * The same command-line arguments and env vars are supported, e.g.:
17
+ * `NODE_ENV=production node app.js --port=80 --verbose`
18
+ *
19
+ * For more information see:
20
+ * https://sailsjs.com/anatomy/app.js
21
+ */
22
+
23
+
24
+ // Ensure we're in the project directory, so cwd-relative paths work as expected
25
+ // no matter where we actually lift from.
26
+ // > Note: This is not required in order to lift, but it is a convenient default.
27
+ process.chdir(__dirname);
28
+
29
+ process.env.DEV = "TRUE";
30
+
31
+
32
+ // Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
33
+ var sails;
34
+ var rc;
35
+ try {
36
+ sails = require('sails');
37
+ rc = require('sails/accessible/rc');
38
+ } catch (err) {
39
+ console.error('Encountered an error when attempting to require(\'sails\'):');
40
+ console.error(err.stack);
41
+ console.error('--');
42
+ console.error('To run an app using `node app.js`, you need to have Sails installed');
43
+ console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re');
44
+ console.error('in the same directory as your app and run `npm install`.');
45
+ console.error();
46
+ console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can');
47
+ console.error('also run this app with `sails lift`. Running with `sails lift` will');
48
+ console.error('not run this file (`app.js`), but it will do exactly the same thing.');
49
+ console.error('(It even uses your app directory\'s local Sails install, if possible.)');
50
+ return;
51
+ }//-•
52
+
53
+ console.log(rc('sails'))
54
+
55
+ // Start server
56
+ sails.lift(rc('sails'));
@@ -0,0 +1,3 @@
1
+ module.exports.adminpanel = {
2
+ // auth: true
3
+ }
@@ -0,0 +1,9 @@
1
+ module.exports.connections = {
2
+ // postgres: {
3
+ // adapter: 'sails-postgresql',
4
+ // host: process.env.PG_HOST === undefined ? '127.0.0.1' : process.env.PG_HOST,
5
+ // user: process.env.PG_USER === undefined ? 'postgres' : process.env.PG_USER,
6
+ // password: process.env.PG_PASSWORD === undefined ? 'postgres' : process.env.PG_PASSWORD,
7
+ // database: process.env.PG_DATABASE === undefined ? 'testdb' : process.env.PG_DATABASE
8
+ // }
9
+ };
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ // models: {
3
+ // connection: 'postgres'
4
+
5
+ // },
6
+ port: process.env.PORT === undefined ? 42772 : process.env.PORT,
7
+ log: {
8
+ level: process.env.LOG_LEVEL === undefined ? 'verbose' : process.env.PORT
9
+ }
10
+ };
@@ -1,16 +1,16 @@
1
- module.exports = {
2
- models: {
3
- connection: 'memory',
4
- migrate: 'safe'
5
- },
6
- adminpanel:{
7
- auth: true
8
- },
9
- log: {
10
- level: 'info'
11
- },
12
- port: process.env.PORT === undefined ? 42772 : process.env.PORT,
13
- log: {
14
- level: "silent"
15
- }
16
- };
1
+ module.exports = {
2
+ // models: {
3
+ // connection: 'postgres',
4
+ // migrate: 'safe'
5
+ // },
6
+ adminpanel:{
7
+ auth: true
8
+ },
9
+ log: {
10
+ level: 'info'
11
+ },
12
+ port: process.env.PORT === undefined ? 42772 : process.env.PORT,
13
+ log: {
14
+ level: "verbose"
15
+ }
16
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * THIS FILE WAS ADDED AUTOMATICALLY by the Sails 1.0 app migration tool.
3
+ * The original file was backed up as `config/globals-old.js.txt`
4
+ */
5
+
6
+ module.exports.globals = {
7
+
8
+ _: require('lodash'),
9
+
10
+ async: require('async'),
11
+
12
+ models: true,
13
+
14
+ sails: true
15
+
16
+ };
@@ -1,8 +1,8 @@
1
- module.exports.orm = {
2
- _hookTimeout: 100000000
3
- };
4
-
5
- module.exports.pubsub = {
6
- _hookTimeout: 100000000
7
- };
8
-
1
+ module.exports.orm = {
2
+ _hookTimeout: 100000000
3
+ };
4
+
5
+ module.exports.pubsub = {
6
+ _hookTimeout: 100000000
7
+ };
8
+