UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

1,602 lines 1.28 MB
{ "type": "File", "start": 0, "end": 11155, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 384, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 11155, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 384, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 20, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 20 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 9, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 9 } }, "local": { "type": "Identifier", "start": 7, "end": 9, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 9 }, "identifierName": "fs" }, "name": "fs" } } ], "source": { "type": "StringLiteral", "start": 15, "end": 19, "loc": { "start": { "line": 1, "column": 15 }, "end": { "line": 1, "column": 19 } }, "extra": { "rawValue": "fs", "raw": "'fs'" }, "value": "fs" } }, { "type": "ImportDeclaration", "start": 21, "end": 45, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 24 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 28, "end": 32, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 11 } }, "local": { "type": "Identifier", "start": 28, "end": 32, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 11 }, "identifierName": "path" }, "name": "path" } } ], "source": { "type": "StringLiteral", "start": 38, "end": 44, "loc": { "start": { "line": 2, "column": 17 }, "end": { "line": 2, "column": 23 } }, "extra": { "rawValue": "path", "raw": "'path'" }, "value": "path" } }, { "type": "ImportDeclaration", "start": 46, "end": 73, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 27 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 53, "end": 58, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 } }, "local": { "type": "Identifier", "start": 53, "end": 58, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 }, "identifierName": "memFs" }, "name": "memFs" } } ], "source": { "type": "StringLiteral", "start": 64, "end": 72, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 26 } }, "extra": { "rawValue": "mem-fs", "raw": "'mem-fs'" }, "value": "mem-fs" } }, { "type": "ImportDeclaration", "start": 74, "end": 109, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 35 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 81, "end": 87, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 13 } }, "local": { "type": "Identifier", "start": 81, "end": 87, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 13 }, "identifierName": "editor" }, "name": "editor" } } ], "source": { "type": "StringLiteral", "start": 93, "end": 108, "loc": { "start": { "line": 4, "column": 19 }, "end": { "line": 4, "column": 34 } }, "extra": { "rawValue": "mem-fs-editor", "raw": "'mem-fs-editor'" }, "value": "mem-fs-editor" } }, { "type": "ImportDeclaration", "start": 110, "end": 141, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 31 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 119, "end": 126, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 16 } }, "imported": { "type": "Identifier", "start": 119, "end": 126, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 16 }, "identifierName": "Subject" }, "name": "Subject" }, "local": { "type": "Identifier", "start": 119, "end": 126, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 16 }, "identifierName": "Subject" }, "name": "Subject" } } ], "source": { "type": "StringLiteral", "start": 134, "end": 140, "loc": { "start": { "line": 5, "column": 24 }, "end": { "line": 5, "column": 30 } }, "extra": { "rawValue": "rxjs", "raw": "'rxjs'" }, "value": "rxjs" } }, { "type": "ImportDeclaration", "start": 143, "end": 223, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 80 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 152, "end": 178, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 35 } }, "imported": { "type": "Identifier", "start": 152, "end": 178, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 35 }, "identifierName": "defaultUserGeneratorConfig" }, "name": "defaultUserGeneratorConfig" }, "local": { "type": "Identifier", "start": 152, "end": 178, "loc": { "start": { "line": 7, "column": 9 }, "end": { "line": 7, "column": 35 }, "identifierName": "defaultUserGeneratorConfig" }, "name": "defaultUserGeneratorConfig" } }, { "type": "ImportSpecifier", "start": 180, "end": 200, "loc": { "start": { "line": 7, "column": 37 }, "end": { "line": 7, "column": 57 } }, "imported": { "type": "Identifier", "start": 180, "end": 200, "loc": { "start": { "line": 7, "column": 37 }, "end": { "line": 7, "column": 57 }, "identifierName": "systemSeederTemplate" }, "name": "systemSeederTemplate" }, "local": { "type": "Identifier", "start": 180, "end": 200, "loc": { "start": { "line": 7, "column": 37 }, "end": { "line": 7, "column": 57 }, "identifierName": "systemSeederTemplate" }, "name": "systemSeederTemplate" } } ], "source": { "type": "StringLiteral", "start": 208, "end": 222, "loc": { "start": { "line": 7, "column": 65 }, "end": { "line": 7, "column": 79 } }, "extra": { "rawValue": "../constants", "raw": "'../constants'" }, "value": "../constants" } }, { "type": "ImportDeclaration", "start": 224, "end": 255, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 31 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 231, "end": 237, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 13 } }, "local": { "type": "Identifier", "start": 231, "end": 237, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 13 }, "identifierName": "config" }, "name": "config" } } ], "source": { "type": "StringLiteral", "start": 243, "end": 254, "loc": { "start": { "line": 8, "column": 19 }, "end": { "line": 8, "column": 30 } }, "extra": { "rawValue": "../config", "raw": "'../config'" }, "value": "../config" } }, { "type": "ImportDeclaration", "start": 257, "end": 304, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 47 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 264, "end": 278, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 21 } }, "local": { "type": "Identifier", "start": 264, "end": 278, "loc": { "start": { "line": 10, "column": 7 }, "end": { "line": 10, "column": 21 }, "identifierName": "InstallerError" }, "name": "InstallerError" } } ], "source": { "type": "StringLiteral", "start": 284, "end": 303, "loc": { "start": { "line": 10, "column": 27 }, "end": { "line": 10, "column": 46 } }, "extra": { "rawValue": "./installer-error", "raw": "'./installer-error'" }, "value": "./installer-error" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * mongoose-data-seed installer\n *\n * @example\n * // create installer\n * const installer = new Installer({ seedersFolder: './seeders' });\n *\n * // run seeders\n * const observable = installer.install();\n *\n * // subscribe logger\n * observable.subscribe({\n * next({ type, payload }) {\n * switch (type) {\n * case Installer.operations.START:\n * console.log('Installer started!');\n * break;\n * case Installer.operations.SUCCESS:\n * console.log('Installer finished successfully!');\n * break;\n * }\n * },\n * error({ type, payload }) {\n * console.error(`Error: ${type}`);\n * console.error(payload.error);\n * }\n * });\n ", "start": 306, "end": 989, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 39, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 990, "end": 11154, "loc": { "start": { "line": 40, "column": 0 }, "end": { "line": 383, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 1005, "end": 11154, "loc": { "start": { "line": 40, "column": 15 }, "end": { "line": 383, "column": 1 } }, "id": { "type": "Identifier", "start": 1011, "end": 1020, "loc": { "start": { "line": 40, "column": 21 }, "end": { "line": 40, "column": 30 }, "identifierName": "Installer" }, "name": "Installer", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 1021, "end": 11154, "loc": { "start": { "line": 40, "column": 31 }, "end": { "line": 383, "column": 1 } }, "body": [ { "type": "ClassProperty", "start": 1601, "end": 2993, "loc": { "start": { "line": 55, "column": 2 }, "end": { "line": 85, "column": 4 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 1608, "end": 1618, "loc": { "start": { "line": 55, "column": 9 }, "end": { "line": 55, "column": 19 }, "identifierName": "operations" }, "name": "operations" }, "value": { "type": "ObjectExpression", "start": 1621, "end": 2992, "loc": { "start": { "line": 55, "column": 22 }, "end": { "line": 85, "column": 3 } }, "properties": [ { "type": "ObjectProperty", "start": 1627, "end": 1641, "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 56, "column": 18 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1627, "end": 1632, "loc": { "start": { "line": 56, "column": 4 }, "end": { "line": 56, "column": 9 }, "identifierName": "START" }, "name": "START" }, "value": { "type": "StringLiteral", "start": 1634, "end": 1641, "loc": { "start": { "line": 56, "column": 11 }, "end": { "line": 56, "column": 18 } }, "extra": { "rawValue": "START", "raw": "'START'" }, "value": "START" } }, { "type": "ObjectProperty", "start": 1647, "end": 1665, "loc": { "start": { "line": 57, "column": 4 }, "end": { "line": 57, "column": 22 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1647, "end": 1654, "loc": { "start": { "line": 57, "column": 4 }, "end": { "line": 57, "column": 11 }, "identifierName": "SUCCESS" }, "name": "SUCCESS" }, "value": { "type": "StringLiteral", "start": 1656, "end": 1665, "loc": { "start": { "line": 57, "column": 13 }, "end": { "line": 57, "column": 22 } }, "extra": { "rawValue": "SUCCESS", "raw": "'SUCCESS'" }, "value": "SUCCESS" } }, { "type": "ObjectProperty", "start": 1671, "end": 1685, "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 58, "column": 18 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1671, "end": 1676, "loc": { "start": { "line": 58, "column": 4 }, "end": { "line": 58, "column": 9 }, "identifierName": "ERROR" }, "name": "ERROR" }, "value": { "type": "StringLiteral", "start": 1678, "end": 1685, "loc": { "start": { "line": 58, "column": 11 }, "end": { "line": 58, "column": 18 } }, "extra": { "rawValue": "ERROR", "raw": "'ERROR'" }, "value": "ERROR" } }, { "type": "ObjectProperty", "start": 1692, "end": 1762, "loc": { "start": { "line": 60, "column": 4 }, "end": { "line": 60, "column": 74 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1692, "end": 1725, "loc": { "start": { "line": 60, "column": 4 }, "end": { "line": 60, "column": 37 }, "identifierName": "WRITE_USER_GENERETOR_CONFIG_START" }, "name": "WRITE_USER_GENERETOR_CONFIG_START" }, "value": { "type": "StringLiteral", "start": 1727, "end": 1762, "loc": { "start": { "line": 60, "column": 39 }, "end": { "line": 60, "column": 74 } }, "extra": { "rawValue": "WRITE_USER_GENERETOR_CONFIG_START", "raw": "'WRITE_USER_GENERETOR_CONFIG_START'" }, "value": "WRITE_USER_GENERETOR_CONFIG_START" } }, { "type": "ObjectProperty", "start": 1768, "end": 1842, "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 61, "column": 78 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1768, "end": 1803, "loc": { "start": { "line": 61, "column": 4 }, "end": { "line": 61, "column": 39 }, "identifierName": "WRITE_USER_GENERETOR_CONFIG_SUCCESS" }, "name": "WRITE_USER_GENERETOR_CONFIG_SUCCESS" }, "value": { "type": "StringLiteral", "start": 1805, "end": 1842, "loc": { "start": { "line": 61, "column": 41 }, "end": { "line": 61, "column": 78 } }, "extra": { "rawValue": "WRITE_USER_GENERETOR_CONFIG_SUCCESS", "raw": "'WRITE_USER_GENERETOR_CONFIG_SUCCESS'" }, "value": "WRITE_USER_GENERETOR_CONFIG_SUCCESS" } }, { "type": "ObjectProperty", "start": 1848, "end": 1918, "loc": { "start": { "line": 62, "column": 4 }, "end": { "line": 62, "column": 74 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1848, "end": 1881, "loc": { "start": { "line": 62, "column": 4 }, "end": { "line": 62, "column": 37 }, "identifierName": "WRITE_USER_GENERETOR_CONFIG_ERROR" }, "name": "WRITE_USER_GENERETOR_CONFIG_ERROR" }, "value": { "type": "StringLiteral", "start": 1883, "end": 1918, "loc": { "start": { "line": 62, "column": 39 }, "end": { "line": 62, "column": 74 } }, "extra": { "rawValue": "WRITE_USER_GENERETOR_CONFIG_ERROR", "raw": "'WRITE_USER_GENERETOR_CONFIG_ERROR'" }, "value": "WRITE_USER_GENERETOR_CONFIG_ERROR" } }, { "type": "ObjectProperty", "start": 1925, "end": 2015, "loc": { "start": { "line": 64, "column": 4 }, "end": { "line": 65, "column": 48 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1925, "end": 1965, "loc": { "start": { "line": 64, "column": 4 }, "end": { "line": 64, "column": 44 }, "identifierName": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_START" }, "name": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_START" }, "value": { "type": "StringLiteral", "start": 1973, "end": 2015, "loc": { "start": { "line": 65, "column": 6 }, "end": { "line": 65, "column": 48 } }, "extra": { "rawValue": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_START", "raw": "'CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_START'" }, "value": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_START" } }, { "type": "ObjectProperty", "start": 2021, "end": 2115, "loc": { "start": { "line": 66, "column": 4 }, "end": { "line": 67, "column": 50 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2021, "end": 2063, "loc": { "start": { "line": 66, "column": 4 }, "end": { "line": 66, "column": 46 }, "identifierName": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SUCCESS" }, "name": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SUCCESS" }, "value": { "type": "StringLiteral", "start": 2071, "end": 2115, "loc": { "start": { "line": 67, "column": 6 }, "end": { "line": 67, "column": 50 } }, "extra": { "rawValue": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SUCCESS", "raw": "'CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SUCCESS'" }, "value": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SUCCESS" } }, { "type": "ObjectProperty", "start": 2121, "end": 2211, "loc": { "start": { "line": 68, "column": 4 }, "end": { "line": 69, "column": 48 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2121, "end": 2161, "loc": { "start": { "line": 68, "column": 4 }, "end": { "line": 68, "column": 44 }, "identifierName": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_ERROR" }, "name": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_ERROR" }, "value": { "type": "StringLiteral", "start": 2169, "end": 2211, "loc": { "start": { "line": 69, "column": 6 }, "end": { "line": 69, "column": 48 } }, "extra": { "rawValue": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_ERROR", "raw": "'CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_ERROR'" }, "value": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_ERROR" } }, { "type": "ObjectProperty", "start": 2217, "end": 2329, "loc": { "start": { "line": 70, "column": 4 }, "end": { "line": 71, "column": 59 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2217, "end": 2268, "loc": { "start": { "line": 70, "column": 4 }, "end": { "line": 70, "column": 55 }, "identifierName": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_FILE_EXISTS" }, "name": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_FILE_EXISTS" }, "value": { "type": "StringLiteral", "start": 2276, "end": 2329, "loc": { "start": { "line": 71, "column": 6 }, "end": { "line": 71, "column": 59 } }, "extra": { "rawValue": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_FILE_EXISTS", "raw": "'CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_FILE_EXISTS'" }, "value": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_FILE_EXISTS" } }, { "type": "ObjectProperty", "start": 2335, "end": 2443, "loc": { "start": { "line": 72, "column": 4 }, "end": { "line": 73, "column": 57 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2335, "end": 2384, "loc": { "start": { "line": 72, "column": 4 }, "end": { "line": 72, "column": 53 }, "identifierName": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_NO_CUSTOM" }, "name": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_NO_CUSTOM" }, "value": { "type": "StringLiteral", "start": 2392, "end": 2443, "loc": { "start": { "line": 73, "column": 6 }, "end": { "line": 73, "column": 57 } }, "extra": { "rawValue": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_NO_CUSTOM", "raw": "'CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_NO_CUSTOM'" }, "value": "CREATE_CUSTOM_SEEDER_TEMPLATE_FILE_SKIP_NO_CUSTOM" } }, { "type": "ObjectProperty", "start": 2450, "end": 2508, "loc": { "start": { "line": 75, "column": 4 }, "end": { "line": 75, "column": 62 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2450, "end": 2477, "loc": { "start": { "line": 75, "column": 4 }, "end": { "line": 75, "column": 31 }, "identifierName": "CREATE_SEEDERS_FOLDER_START" }, "name": "CREATE_SEEDERS_FOLDER_START" }, "value": { "type": "StringLiteral", "start": 2479, "end": 2508, "loc": { "start": { "line": 75, "column": 33 }, "end": { "line": 75, "column": 62 } }, "extra": { "rawValue": "CREATE_SEEDERS_FOLDER_START", "raw": "'CREATE_SEEDERS_FOLDER_START'" }, "value": "CREATE_SEEDERS_FOLDER_START" } }, { "type": "ObjectProperty", "start": 2514, "end": 2576, "loc": { "start": { "line": 76, "column": 4 }, "end": { "line": 76, "column": 66 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2514, "end": 2543, "loc": { "start": { "line": 76, "column": 4 }, "end": { "line": 76, "column": 33 }, "identifierName": "CREATE_SEEDERS_FOLDER_SUCCESS" }, "name": "CREATE_SEEDERS_FOLDER_SUCCESS" }, "value": { "type": "StringLiteral", "start": 2545, "end": 2576, "loc": { "start": { "line": 76, "column": 35 }, "end": { "line": 76, "column": 66 } }, "extra": { "rawValue": "CREATE_SEEDERS_FOLDER_SUCCESS", "raw": "'CREATE_SEEDERS_FOLDER_SUCCESS'" }, "value": "CREATE_SEEDERS_FOLDER_SUCCESS" } }, { "type": "ObjectProperty", "start": 2582, "end": 2640, "loc": { "start": { "line": 77, "column": 4 }, "end": { "line": 77, "column": 62 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2582, "end": 2609, "loc": { "start": { "line": 77, "column": 4 }, "end": { "line": 77, "column": 31 }, "identifierName": "CREATE_SEEDERS_FOLDER_ERROR" }, "name": "CREATE_SEEDERS_FOLDER_ERROR" }, "value": { "type": "StringLiteral", "start": 2611, "end": 2640, "loc": { "start": { "line": 77, "column": 33 }, "end": { "line": 77, "column": 62 } }, "extra": { "rawValue": "CREATE_SEEDERS_FOLDER_ERROR", "raw": "'CREATE_SEEDERS_FOLDER_ERROR'" }, "value": "CREATE_SEEDERS_FOLDER_ERROR" } }, { "type": "ObjectProperty", "start": 2646, "end": 2736, "loc": { "start": { "line": 78, "column": 4 }, "end": { "line": 79, "column": 48 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 2646, "end": 2686, "loc": { "start": { "line": 78, "column": 4 }, "end": { "line": 78, "column": 44 }, "identifierName": "CREATE_SEEDERS_FOLDER_SKIP_FOLDER_EXISTS" }, "name": "CREATE_SEEDERS_FOLDER_SKIP_FOLDER_EXISTS" }, "value": { "type": "StringLiteral", "start": 2694, "end": 2736, "loc":