@webresto/graphql 1.3.0 → 1.3.3
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/package.json +25 -8
- package/src/additionalResolvers.js +1 -1
- package/src/additionalResolvers.ts +1 -1
- package/src/graphql.js +40 -22
- package/src/graphql.ts +42 -25
- package/src/resolvers/cart.d.ts +229 -9
- package/src/resolvers/cart.js +27 -7
- package/src/resolvers/cart.ts +29 -8
- package/src/resolvers/checkout.ts +1 -0
- package/test/{_bootstrap.js → bootstrap.js} +6 -7
- package/test/bootstrap.ts +36 -0
- package/test/fixture/.sailsrc +14 -0
- package/test/{fixtures/v0.12-app → fixture}/api/controllers/.gitkeep +0 -0
- package/test/{fixtures/v0.12-app → fixture}/api/models/.gitkeep +0 -0
- package/test/{fixtures/v0.12-app → fixture}/api/services/.gitkeep +0 -0
- package/test/{fixtures/v0.12-app/app.js → fixture/app-export.js} +2 -2
- package/test/fixture/app.js +56 -0
- package/test/fixture/config/adminpanel.js +25 -0
- package/test/fixture/config/bootstrap.js +161 -0
- package/test/fixture/config/connections.js +9 -0
- package/test/fixture/config/env/development.js +10 -0
- package/test/{fixtures/v0.12-app → fixture}/config/env/production.js +5 -5
- package/test/fixture/config/globals.js +16 -0
- package/test/{fixtures/v0.12-app → fixture}/config/hookTimeout.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/http.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/i18n.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/log.js +1 -1
- package/test/fixture/config/models.js +9 -0
- package/test/fixture/config/modulemanager.js +22 -0
- package/test/{fixtures/v0.12-app → fixture}/config/policies.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/routes.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/session.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/sockets.js +0 -0
- package/test/{fixtures/v0.12-app → fixture}/config/views.js +0 -0
- package/test/fixture/hacks/waterline.js +39 -0
- package/test/fixture/package.json +33 -0
- package/test/fixture/seeds/dish.json +37042 -0
- package/test/fixture/seeds/group.json +1418 -0
- package/test/fixture/seeds/iikoDiscount.json +365 -0
- package/test/{fixtures/v0.12-app → fixture}/views/403.ejs +0 -0
- package/test/{fixtures/v0.12-app → fixture}/views/404.ejs +0 -0
- package/test/{fixtures/v0.12-app → fixture}/views/500.ejs +0 -0
- package/test/{fixtures/v0.12-app → fixture}/views/homepage.ejs +0 -0
- package/test/{fixtures/v0.12-app → fixture}/views/layout.ejs +0 -0
- package/test/integration/graphql.test.js +11 -0
- package/test/integration/graphql.test.ts +15 -0
- package/test/{unit → integration}/sails_not_crash.test.js +0 -0
- package/test/integration/sails_not_crash.test.ts +3 -0
- package/test/unit/first.test.js +6 -8
- package/test/unit/first.test.ts +11 -0
- package/test/fixtures/v0.12-app/.gitignore +0 -11
- package/test/fixtures/v0.12-app/.sailsrc +0 -11
- package/test/fixtures/v0.12-app/api/models/TestModel.js +0 -22
- package/test/fixtures/v0.12-app/api/responses/badRequest.js +0 -76
- package/test/fixtures/v0.12-app/api/responses/created.js +0 -60
- package/test/fixtures/v0.12-app/api/responses/forbidden.js +0 -89
- package/test/fixtures/v0.12-app/api/responses/notFound.js +0 -94
- package/test/fixtures/v0.12-app/api/responses/ok.js +0 -60
- package/test/fixtures/v0.12-app/api/responses/serverError.js +0 -89
- package/test/fixtures/v0.12-app/config/bootstrap.js +0 -6
- package/test/fixtures/v0.12-app/config/connections.js +0 -5
- package/test/fixtures/v0.12-app/config/cors.js +0 -78
- package/test/fixtures/v0.12-app/config/csrf.js +0 -64
- package/test/fixtures/v0.12-app/config/env/development.js +0 -10
- package/test/fixtures/v0.12-app/config/globals.js +0 -63
- package/test/fixtures/v0.12-app/config/models.js +0 -3
- package/test/fixtures/v0.12-app/config/restoapi.js +0 -3
- package/test/fixtures/v0.12-app/config/restocore.js +0 -39
- package/test/fixtures/v0.12-app/config/stateflow.js +0 -4
- package/test/fixtures/v0.12-app/package.json +0 -34
    
        package/src/resolvers/cart.ts
    CHANGED
    
    | @@ -32,7 +32,10 @@ export default { | |
| 32 32 | 
             
                      );
         | 
| 33 33 | 
             
                      order = await getNewCart(args.orderId);
         | 
| 34 34 | 
             
                    }
         | 
| 35 | 
            -
             | 
| 35 | 
            +
             | 
| 36 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 37 | 
            +
                    getEmitter().emit("http-api:before-response-order", fullOrder);
         | 
| 38 | 
            +
                    return fullOrder
         | 
| 36 39 | 
             
                  },
         | 
| 37 40 | 
             
                },
         | 
| 38 41 | 
             
              },
         | 
| @@ -95,7 +98,11 @@ export default { | |
| 95 98 | 
             
                      args.replace,
         | 
| 96 99 | 
             
                      args.orderDishId
         | 
| 97 100 | 
             
                    );
         | 
| 98 | 
            -
                     | 
| 101 | 
            +
                    await Order.countCart(order);
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 104 | 
            +
                    getEmitter().emit("http-api:before-response-order-add-dish", fullOrder);
         | 
| 105 | 
            +
                    return fullOrder
         | 
| 99 106 | 
             
                  },
         | 
| 100 107 | 
             
                },
         | 
| 101 108 | 
             
                orderReplaceDish: {
         | 
| @@ -126,7 +133,10 @@ export default { | |
| 126 133 | 
             
                      args.replace,
         | 
| 127 134 | 
             
                      args.orderDishId
         | 
| 128 135 | 
             
                    );
         | 
| 129 | 
            -
                     | 
| 136 | 
            +
                    await Order.countCart(order);
         | 
| 137 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 138 | 
            +
                    getEmitter().emit("http-api:before-response-order-replace-dish", fullOrder);
         | 
| 139 | 
            +
                    return fullOrder
         | 
| 130 140 | 
             
                  },
         | 
| 131 141 | 
             
                },
         | 
| 132 142 | 
             
                orderRemoveDish: {
         | 
| @@ -150,7 +160,10 @@ export default { | |
| 150 160 | 
             
                    const orderDish = await OrderDish.findOne({ id: args.orderDishId });
         | 
| 151 161 |  | 
| 152 162 | 
             
                    await Order.removeDish(order.id, orderDish, args.amount, false);
         | 
| 153 | 
            -
                     | 
| 163 | 
            +
                    await Order.countCart(order);
         | 
| 164 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 165 | 
            +
                    getEmitter().emit("http-api:before-response-order-remove-dish", fullOrder);
         | 
| 166 | 
            +
                    return fullOrder
         | 
| 154 167 | 
             
                  },
         | 
| 155 168 | 
             
                },
         | 
| 156 169 | 
             
                orderSetDishAmount: {
         | 
| @@ -187,7 +200,10 @@ export default { | |
| 187 200 | 
             
                      );
         | 
| 188 201 |  | 
| 189 202 | 
             
                    await Order.setCount(order.id, dish, args.amount);
         | 
| 190 | 
            -
                     | 
| 203 | 
            +
                    await Order.countCart(order);
         | 
| 204 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 205 | 
            +
                    getEmitter().emit("http-api:before-response-order-set-dish-amount", fullOrder);
         | 
| 206 | 
            +
                    return fullOrder
         | 
| 191 207 | 
             
                  },
         | 
| 192 208 | 
             
                },
         | 
| 193 209 | 
             
                orderSetDishComment: {
         | 
| @@ -223,8 +239,10 @@ export default { | |
| 223 239 | 
             
                    }
         | 
| 224 240 |  | 
| 225 241 | 
             
                    await order.setComment(dish, comment);
         | 
| 226 | 
            -
                     | 
| 227 | 
            -
             | 
| 242 | 
            +
                    await Order.countCart(order);
         | 
| 243 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 244 | 
            +
                    getEmitter().emit("http-api:before-response-order-set-dish-comment", fullOrder);
         | 
| 245 | 
            +
                    return fullOrder      },
         | 
| 228 246 | 
             
                },
         | 
| 229 247 |  | 
| 230 248 | 
             
                orderUpdate: {
         | 
| @@ -234,7 +252,10 @@ export default { | |
| 234 252 | 
             
                    let order = args.order;
         | 
| 235 253 | 
             
                    if (!order.id) throw "order.id field is required"
         | 
| 236 254 | 
             
                    await Order.update({id: order.id}, {trifleFrom: order.trifleFrom})
         | 
| 237 | 
            -
                     | 
| 255 | 
            +
                    await Order.populate(order.id);
         | 
| 256 | 
            +
                    let fullOrder = await Order.populate(order.id);
         | 
| 257 | 
            +
                    getEmitter().emit("http-api:before-response-order-update", fullOrder);
         | 
| 258 | 
            +
                    return fullOrder   
         | 
| 238 259 | 
             
                  },
         | 
| 239 260 | 
             
                },
         | 
| 240 261 | 
             
              },
         | 
| @@ -1,15 +1,17 @@ | |
| 1 1 | 
             
            "use strict";
         | 
| 2 2 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 3 3 | 
             
            require("mocha");
         | 
| 4 | 
            -
             | 
| 4 | 
            +
            require("dotenv").config();
         | 
| 5 | 
            +
            var Sails = require("./fixture/node_modules/sails").Sails;
         | 
| 6 | 
            +
            process.env.DEV = "TRUE";
         | 
| 7 | 
            +
            process.env.LOG_LEVEL = 'silent';
         | 
| 5 8 | 
             
            before(function (done) {
         | 
| 6 | 
            -
                 | 
| 9 | 
            +
                require("./fixture/app-export");
         | 
| 7 10 | 
             
                this.timeout(50000);
         | 
| 8 | 
            -
                Sails().lift( | 
| 11 | 
            +
                Sails().lift({}, function (err, _sails) {
         | 
| 9 12 | 
             
                    if (err)
         | 
| 10 13 | 
             
                        return done(err);
         | 
| 11 14 | 
             
                    global.sails = _sails;
         | 
| 12 | 
            -
                    // console.log(_sails);
         | 
| 13 15 | 
             
                    return done();
         | 
| 14 16 | 
             
                });
         | 
| 15 17 | 
             
            });
         | 
| @@ -18,12 +20,9 @@ after(function (done) { | |
| 18 20 | 
             
                    return global.sails.lower(function (err) {
         | 
| 19 21 | 
             
                        if (err) {
         | 
| 20 22 | 
             
                            done();
         | 
| 21 | 
            -
                            return process.exit(2);
         | 
| 22 23 | 
             
                        }
         | 
| 23 24 | 
             
                        done();
         | 
| 24 | 
            -
                        return process.exit(0);
         | 
| 25 25 | 
             
                    });
         | 
| 26 26 | 
             
                }
         | 
| 27 27 | 
             
                done();
         | 
| 28 | 
            -
                return process.exit(2);
         | 
| 29 28 | 
             
            });
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            import "mocha";
         | 
| 2 | 
            +
            require("dotenv").config();
         | 
| 3 | 
            +
            var Sails = require("./fixture/node_modules/sails").Sails;
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            process.env.DEV = "TRUE"
         | 
| 6 | 
            +
            process.env.LOG_LEVEL= 'silent'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            before(function (done) {
         | 
| 9 | 
            +
              require("./fixture/app-export");
         | 
| 10 | 
            +
              this.timeout(50000);
         | 
| 11 | 
            +
              Sails().lift({}, function (err: any, _sails: any) {
         | 
| 12 | 
            +
                if (err) return done(err);
         | 
| 13 | 
            +
                global.sails = _sails;
         | 
| 14 | 
            +
                return done();
         | 
| 15 | 
            +
              });
         | 
| 16 | 
            +
            });
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            after(function (done) {
         | 
| 19 | 
            +
              if (global.sails) {
         | 
| 20 | 
            +
                return global.sails.lower(function (err) {
         | 
| 21 | 
            +
                  if (err) {
         | 
| 22 | 
            +
                    done();
         | 
| 23 | 
            +
                  }
         | 
| 24 | 
            +
                  done();
         | 
| 25 | 
            +
                });
         | 
| 26 | 
            +
              }
         | 
| 27 | 
            +
              done();
         | 
| 28 | 
            +
            });
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            declare global {
         | 
| 31 | 
            +
              namespace NodeJS {
         | 
| 32 | 
            +
                interface Global {
         | 
| 33 | 
            +
                  sails: any;
         | 
| 34 | 
            +
                }
         | 
| 35 | 
            +
              }
         | 
| 36 | 
            +
            }
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -45,7 +45,7 @@ try { | |
| 45 45 | 
             
              rc = require('rc');
         | 
| 46 46 | 
             
            } catch (e0) {
         | 
| 47 47 | 
             
              try {
         | 
| 48 | 
            -
                rc = require('sails/ | 
| 48 | 
            +
                rc = require('sails/accessible/rc');
         | 
| 49 49 | 
             
              } catch (e1) {
         | 
| 50 50 | 
             
                console.error('Could not find dependency: `rc`.');
         | 
| 51 51 | 
             
                console.error('Your `.sailsrc` file(s) will be ignored.');
         | 
| @@ -70,4 +70,4 @@ try { | |
| 70 70 | 
             
            module.exports = {
         | 
| 71 71 | 
             
              sails: sails,
         | 
| 72 72 | 
             
              rc: rc('sails')
         | 
| 73 | 
            -
            } | 
| 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,25 @@ | |
| 1 | 
            +
            'use strict';
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            setTimeout(() => {
         | 
| 5 | 
            +
                sails.after(["hook:orm:loaded"], () => {
         | 
| 6 | 
            +
                    Object.keys(sails.models).forEach((modelname) => {
         | 
| 7 | 
            +
                        let modelName = sails.models[modelname].globalId;
         | 
| 8 | 
            +
                        sails.config.adminpanel.instances["dev" + modelName] = {
         | 
| 9 | 
            +
                            title: "dev" + modelName,
         | 
| 10 | 
            +
                            icon: 'cube',
         | 
| 11 | 
            +
                            model: modelName,
         | 
| 12 | 
            +
                            fields: {
         | 
| 13 | 
            +
                                createdAt: false,
         | 
| 14 | 
            +
                                updatedAt: false
         | 
| 15 | 
            +
                            }
         | 
| 16 | 
            +
                        };
         | 
| 17 | 
            +
                    });
         | 
| 18 | 
            +
                });
         | 
| 19 | 
            +
            }, 5000);
         | 
| 20 | 
            +
             | 
| 21 | 
            +
             | 
| 22 | 
            +
            module.exports.adminpanel = {
         | 
| 23 | 
            +
                instances: {
         | 
| 24 | 
            +
                }
         | 
| 25 | 
            +
            };
         | 
| @@ -0,0 +1,161 @@ | |
| 1 | 
            +
            maintenanceSeed = [
         | 
| 2 | 
            +
              {
         | 
| 3 | 
            +
                id: "maintenance1",
         | 
| 4 | 
            +
                title: "Сайт временно не работает",
         | 
| 5 | 
            +
                description: "<div>\r\n<p>По техническим причинам доставка сейчас не осуществляется</p>\r\n</div>",
         | 
| 6 | 
            +
                enable: false,
         | 
| 7 | 
            +
                startDate: "2019-12-31T21:00:00.000Z",
         | 
| 8 | 
            +
                stopDate: "2020-12-31T21:00:00.000Z",
         | 
| 9 | 
            +
              },
         | 
| 10 | 
            +
            ];
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            const fs = require("fs");
         | 
| 13 | 
            +
            const path = require("path");
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            module.exports.bootstrap = async function () {
         | 
| 16 | 
            +
              sails.config.paths.app = process.cwd();
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              /**
         | 
| 19 | 
            +
               * # Bootsrap seeds from seeds folder
         | 
| 20 | 
            +
               * Magic: filename.json where filename is model name
         | 
| 21 | 
            +
               */
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              if (sails.config.models.migrate === "drop" || process.env.FORCE_SEED === "TRUE") {
         | 
| 24 | 
            +
                sails.log.info("Seeding 🌱 process start")
         | 
| 25 | 
            +
                try {
         | 
| 26 | 
            +
                  let seedsDir = process.env.SEED_PATH ? process.env.SEED_PATH : __dirname + "/../seeds/";
         | 
| 27 | 
            +
                  // load JSON data
         | 
| 28 | 
            +
                  let seeds = fs.readdirSync(seedsDir).filter(function (file) {
         | 
| 29 | 
            +
                    return path.extname(file).toLowerCase() === ".json";
         | 
| 30 | 
            +
                  });
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  for await (let seed of seeds) {
         | 
| 33 | 
            +
                    try {
         | 
| 34 | 
            +
                      let seedFile = seedsDir + seed;
         | 
| 35 | 
            +
                      let model = seed.split(".")[0].toLowerCase();
         | 
| 36 | 
            +
                      let json_seed_data = require(seedFile);
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                      sails.log.info("🌱 Bootstrap > Seed for model: ", model);
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                      if (sails.models[model]) {
         | 
| 41 | 
            +
                        await sails.models[model].destroy({}).fetch();
         | 
| 42 | 
            +
                        if (Array.isArray(json_seed_data)) {
         | 
| 43 | 
            +
                          for await (seed_item of json_seed_data) {
         | 
| 44 | 
            +
                            cleanSeedItem(seed_item);
         | 
| 45 | 
            +
                            await sails.models[model].create(seed_item).fetch();
         | 
| 46 | 
            +
                          }
         | 
| 47 | 
            +
                          sails.log.debug(`🌱 Bootstrap seed ${model}: > count: ${json_seed_data.length}`);
         | 
| 48 | 
            +
                        } else {
         | 
| 49 | 
            +
                          sails.log.debug(`🌱 Bootstrap seed ${model}: > one item`);
         | 
| 50 | 
            +
                          cleanSeedItem(seed_item);
         | 
| 51 | 
            +
                          await sails.models[model].create(json_seed_data).fetch();
         | 
| 52 | 
            +
                        }
         | 
| 53 | 
            +
                        sails.log.info(`Bootstrap seed model: > ${model} was seeded, count: ${json_seed_data.length}`);
         | 
| 54 | 
            +
                      } else {
         | 
| 55 | 
            +
                        sails.log.warn(`Bootstrap seed model: > ${model} SKIPED (model not present in sails)`);
         | 
| 56 | 
            +
                      }
         | 
| 57 | 
            +
                    } catch (error) {
         | 
| 58 | 
            +
                      sails.log.error(`🌱 Seeding error: ${error}`);
         | 
| 59 | 
            +
                    }
         | 
| 60 | 
            +
                  }
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  // Load JS files
         | 
| 63 | 
            +
                  seeds = fs.readdirSync(seedsDir).filter(function (file) {
         | 
| 64 | 
            +
                    return path.extname(file).toLowerCase() === ".js";
         | 
| 65 | 
            +
                  });
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  /**
         | 
| 68 | 
            +
                   * If file .queue exist then sort seedqueue by this file
         | 
| 69 | 
            +
                   */
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  if (fs.existsSync(seedsDir + ".queue")) {
         | 
| 72 | 
            +
                    var queuelist = fs
         | 
| 73 | 
            +
                      .readFileSync(seedsDir + ".queue")
         | 
| 74 | 
            +
                      .toString()
         | 
| 75 | 
            +
                      .split("\n");
         | 
| 76 | 
            +
                    let _seeds = [...seeds];
         | 
| 77 | 
            +
                    seeds = [];
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                    // Build head loadlist of js seeds files
         | 
| 80 | 
            +
                    queuelist.forEach((qItem) => {
         | 
| 81 | 
            +
                      _seeds.forEach((sItem) => {
         | 
| 82 | 
            +
                        if (sItem.includes(qItem) && !isCommented(qItem)) {
         | 
| 83 | 
            +
                          seeds.push(sItem);
         | 
| 84 | 
            +
                        }
         | 
| 85 | 
            +
                      });
         | 
| 86 | 
            +
                    });
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                    // Build foot
         | 
| 89 | 
            +
                    seeds = [...seeds, ..._seeds.filter((n) => !seeds.includes(n))];
         | 
| 90 | 
            +
                  }
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  for await (let seed of seeds) {
         | 
| 93 | 
            +
                    let seedFile = seedsDir + seed;
         | 
| 94 | 
            +
                    if (fs.existsSync(seedFile)) {
         | 
| 95 | 
            +
                      let bootstrap_model_seed = require(seedFile);
         | 
| 96 | 
            +
                      await bootstrap_model_seed.default(sails);
         | 
| 97 | 
            +
                    }
         | 
| 98 | 
            +
                  }
         | 
| 99 | 
            +
                } catch (error) {
         | 
| 100 | 
            +
                  console.error("Bootstrap seeds error: > ", error);
         | 
| 101 | 
            +
                }
         | 
| 102 | 
            +
              }
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              await Settings.set("enableIikoSimpleDiscounts", true);
         | 
| 105 | 
            +
              //////////////////////////////////////////////////////////
         | 
| 106 | 
            +
             | 
| 107 | 
            +
              setTimeout(() => {
         | 
| 108 | 
            +
                console.log("ADMINPANEL", sails.config.adminpanel.instances.discount)
         | 
| 109 | 
            +
              }, 10000)
         | 
| 110 | 
            +
             | 
| 111 | 
            +
              if (sails.config.models.migrate === "drop") {
         | 
| 112 | 
            +
                // create init params for webresto
         | 
| 113 | 
            +
                try {
         | 
| 114 | 
            +
                  if ((await Maintenance.count()) === 0) {
         | 
| 115 | 
            +
                    sails.log.verbose("BOOTSTRAP > Start Import Maintenance SEED");
         | 
| 116 | 
            +
                    await Maintenance.createEach(maintenanceSeed).fetch();
         | 
| 117 | 
            +
                  }
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                  process.env.TZ = (await Settings.use("timezone")) ? await Settings.use("timezone") : process.env.TZ;
         | 
| 120 | 
            +
             | 
| 121 | 
            +
                  return
         | 
| 122 | 
            +
                } catch (error) {
         | 
| 123 | 
            +
                  console.log(error);
         | 
| 124 | 
            +
                }
         | 
| 125 | 
            +
              } else {
         | 
| 126 | 
            +
                process.env.TZ = (await Settings.use("timezone")) ? await Settings.use("timezone") : process.env.TZ;
         | 
| 127 | 
            +
                return
         | 
| 128 | 
            +
              }
         | 
| 129 | 
            +
              return
         | 
| 130 | 
            +
            };
         | 
| 131 | 
            +
             | 
| 132 | 
            +
            function isCommented(str) {
         | 
| 133 | 
            +
              return (Boolean(str) && (
         | 
| 134 | 
            +
                str
         | 
| 135 | 
            +
                  .split(" ")
         | 
| 136 | 
            +
                  .filter((a) => {
         | 
| 137 | 
            +
                    return Boolean(a);
         | 
| 138 | 
            +
                  })[0]
         | 
| 139 | 
            +
                  .charAt(0) === "#"
         | 
| 140 | 
            +
              ));
         | 
| 141 | 
            +
            }
         | 
| 142 | 
            +
             | 
| 143 | 
            +
             | 
| 144 | 
            +
            function cleanSeedItem(item) {
         | 
| 145 | 
            +
             | 
| 146 | 
            +
              if(item.createdAt) delete(item.createdAt)
         | 
| 147 | 
            +
              if(item.updatedAt) delete(item.updatedAt)
         | 
| 148 | 
            +
              if(typeof item.id === "number") delete(item.id)
         | 
| 149 | 
            +
             | 
| 150 | 
            +
              for (const [key, value] of Object.entries(item)) {
         | 
| 151 | 
            +
                if (value === null || value === undefined)  {
         | 
| 152 | 
            +
                  delete(item[key])
         | 
| 153 | 
            +
                } else {
         | 
| 154 | 
            +
                  try {
         | 
| 155 | 
            +
                    let json_value = JSON.parse(value);
         | 
| 156 | 
            +
                    item[key] = json_value
         | 
| 157 | 
            +
                  } catch (e) {
         | 
| 158 | 
            +
                  }
         | 
| 159 | 
            +
                }
         | 
| 160 | 
            +
              }
         | 
| 161 | 
            +
            }
         | 
| @@ -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 | 
            +
            };
         | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            module.exports = {
         | 
| 2 | 
            -
              models: {
         | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
              },
         | 
| 2 | 
            +
              // models: {
         | 
| 3 | 
            +
              //   connection: 'postgres',
         | 
| 4 | 
            +
              //   migrate: 'safe'
         | 
| 5 | 
            +
              // },
         | 
| 6 6 | 
             
              adminpanel:{
         | 
| 7 7 | 
             
                auth: true
         | 
| 8 8 | 
             
              },
         | 
| @@ -11,6 +11,6 @@ module.exports = { | |
| 11 11 | 
             
              },
         | 
| 12 12 | 
             
              port: process.env.PORT === undefined ? 42772 : process.env.PORT,
         | 
| 13 13 | 
             
              log: {
         | 
| 14 | 
            -
               level: " | 
| 14 | 
            +
               level: "verbose"
         | 
| 15 15 | 
             
              }
         | 
| 16 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 | 
            +
            };
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module.exports.modulemanager = {
         | 
| 2 | 
            +
                navbar: [
         | 
| 3 | 
            +
                    {
         | 
| 4 | 
            +
                        id: "1",
         | 
| 5 | 
            +
                        name: "Мои модули",
         | 
| 6 | 
            +
                        link: `/admin/modules/my`,
         | 
| 7 | 
            +
                        icon: "home"
         | 
| 8 | 
            +
                    },
         | 
| 9 | 
            +
                    {
         | 
| 10 | 
            +
                        id: "2",
         | 
| 11 | 
            +
                        name: "Обновления",
         | 
| 12 | 
            +
                        link: `/admin/modules/updates`,
         | 
| 13 | 
            +
                        icon: "cloud-download-alt"
         | 
| 14 | 
            +
                    },
         | 
| 15 | 
            +
                    {
         | 
| 16 | 
            +
                        id: "3",
         | 
| 17 | 
            +
                        name: "Маркетплейс",
         | 
| 18 | 
            +
                        link: `/admin/modules/market`,
         | 
| 19 | 
            +
                        icon: "shopping-order"
         | 
| 20 | 
            +
                    }
         | 
| 21 | 
            +
                ]
         | 
| 22 | 
            +
            }
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            /**
         | 
| 2 | 
            +
             * WRONG SAILS HACK
         | 
| 3 | 
            +
             */
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            console.warn("WRONG SAILS HACK v0.2");
         | 
| 6 | 
            +
            let PWD = process.cwd()
         | 
| 7 | 
            +
            const replace = require("replace-in-file");
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            /**
         | 
| 10 | 
            +
             * 1.
         | 
| 11 | 
            +
             * Patch for allow unknow types
         | 
| 12 | 
            +
             * bash equals: find $PWD/node_modules/waterline-schema/ -type f -print0 | xargs -0 sed -i 's|if (_.indexOf(validProperties, propertyName) < 0) {|if (false) {|g'
         | 
| 13 | 
            +
             */
         | 
| 14 | 
            +
            console.log(PWD + "/../**/sails-hook-orm/lib/validate-model-def.js",);
         | 
| 15 | 
            +
            const results = replace.sync({
         | 
| 16 | 
            +
              files: [
         | 
| 17 | 
            +
                //for test system
         | 
| 18 | 
            +
                PWD + "/../**/sails-hook-orm/lib/validate-model-def.js", 
         | 
| 19 | 
            +
                PWD + "/../**/waterline-schema/schema.js",
         | 
| 20 | 
            +
                PWD + "/../**/sails-disk/index.js",
         | 
| 21 | 
            +
                PWD + "/../**/query/private/normalize-value-to-set.js", 
         | 
| 22 | 
            +
             
         | 
| 23 | 
            +
              ], 
         | 
| 24 | 
            +
              from: [
         | 
| 25 | 
            +
                "(_.isFunction(val.defaultsTo))",
         | 
| 26 | 
            +
                "(_.indexOf(validProperties, propertyName) < 0)",
         | 
| 27 | 
            +
                "(_.has(attribute, 'defaultsTo') && _.isNull(attribute.defaultsTo))",
         | 
| 28 | 
            +
                "(_.has(primaryKeyAttribute, 'defaultsTo') && !_.isUndefined(primaryKeyAttribute, 'defaultsTo'))",
         | 
| 29 | 
            +
                "(attribute.required && _.has(attribute, 'defaultsTo') && !_.isUndefined(attribute, 'defaultsTo'))",
         | 
| 30 | 
            +
                "(_.has(attribute, 'defaultsTo'))",
         | 
| 31 | 
            +
                "(isProvidingNullForIncompatibleOptionalAttr)",
         | 
| 32 | 
            +
                "(primaryKeyAttr.required !== true && (!primaryKeyAttr.autoMigrations || primaryKeyAttr.autoMigrations.autoIncrement !== true))"
         | 
| 33 | 
            +
              ],
         | 
| 34 | 
            +
              to: "(false)",
         | 
| 35 | 
            +
            });
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            console.log(results);
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            // Stranger things
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "name": "test-app",
         | 
| 3 | 
            +
              "private": true,
         | 
| 4 | 
            +
              "version": "0.0.0",
         | 
| 5 | 
            +
              "description": "Sails test application",
         | 
| 6 | 
            +
              "keywords": [],
         | 
| 7 | 
            +
              "dependencies": {
         | 
| 8 | 
            +
                "@webresto/core": "file:../../node_modules/@webresto/core",
         | 
| 9 | 
            +
                "@webresto/graphql": "file:../..",
         | 
| 10 | 
            +
                "@webresto/worktime": "file:../../node_modules/@webresto/worktime",
         | 
| 11 | 
            +
                "replace-in-file": "^6.3.2",
         | 
| 12 | 
            +
                "include-all": "^1.0.8",
         | 
| 13 | 
            +
                "rc": "^1.0.1",
         | 
| 14 | 
            +
                "request": "^2.88.2",
         | 
| 15 | 
            +
                "sails": "^1.5.0",
         | 
| 16 | 
            +
                "sails-hook-orm": "^2.1.1",
         | 
| 17 | 
            +
                "sails-hook-stateflow": "^1.0.6",
         | 
| 18 | 
            +
                "connect-flash": "^0.1.1",
         | 
| 19 | 
            +
                "sails-memory": "^0.10.7"
         | 
| 20 | 
            +
              },
         | 
| 21 | 
            +
              "scripts": {
         | 
| 22 | 
            +
                "debug": "node debug app.js",
         | 
| 23 | 
            +
                "start": "node app.js",
         | 
| 24 | 
            +
                "postinstall": "node ./hacks/waterline.js"
         | 
| 25 | 
            +
              },
         | 
| 26 | 
            +
              "main": "app.js",
         | 
| 27 | 
            +
              "repository": {
         | 
| 28 | 
            +
                "type": "git",
         | 
| 29 | 
            +
                "url": "git://github.com/webresto/app.git"
         | 
| 30 | 
            +
              },
         | 
| 31 | 
            +
              "author": "webresto",
         | 
| 32 | 
            +
              "license": "MIT"
         | 
| 33 | 
            +
            }
         |