├── localTypes ├── json.d.ts └── vorpal.d.ts ├── typings.json ├── ReadMe.docx ├── ReadMe.pdf ├── images ├── cloud-upload.png └── cloud-download.png ├── src ├── json.d.ts ├── spec │ └── support │ │ └── jasmine.json ├── Watcher.ts ├── Notify.ts ├── Debug.ts ├── Conflict.ts ├── NowFiles.ts ├── SyncMode.ts ├── NowTables.ts ├── FileCache.ts ├── NowApplications.ts ├── Connection.ts ├── AppWatcher.ts ├── Options.ts └── UXsyncNowREST.ts ├── rest ├── rest-client.env.json └── get-requests.http ├── global ├── Scripted REST Resource │ ├── checkUser.js │ ├── getApplicationFileChanges.js │ ├── getTables.js │ ├── getApplications.js │ ├── getApplicationRecords.js │ ├── getFile.js │ ├── saveFile.js │ └── getApplicationFiles.js └── Script Include │ ├── UXCRC32.js │ └── UXsyncNow.js ├── .gitignore ├── tsconfig.json ├── karma.conf.js ├── dist ├── Notify.js.map ├── Watcher.js.map ├── Notify.js ├── Watcher.js ├── Debug.js.map ├── Conflict.js.map ├── NowFiles.js.map ├── NowTables.js.map ├── Debug.js ├── NowApplications.js.map ├── Conflict.js ├── SyncMode.js.map ├── FileCache.js.map ├── NowFiles.js ├── NowTables.js ├── Connection.js.map ├── AppWatcher.js.map ├── FileCache.js ├── SyncMode.js ├── Options.js.map ├── NowApplications.js ├── Connection.js ├── AppWatcher.js ├── UXsyncNowREST.js.map ├── Options.js ├── NowFile.js.map ├── uxsyncnow.js.map └── UXsyncNowREST.js ├── gruntfile.js ├── package.json └── CHANGELOG.md /localTypes/json.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodets", 3 | "dependencies": {} 4 | } 5 | -------------------------------------------------------------------------------- /ReadMe.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReedOwens/UXsyncNow/HEAD/ReadMe.docx -------------------------------------------------------------------------------- /ReadMe.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReedOwens/UXsyncNow/HEAD/ReadMe.pdf -------------------------------------------------------------------------------- /images/cloud-upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReedOwens/UXsyncNow/HEAD/images/cloud-upload.png -------------------------------------------------------------------------------- /src/json.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.json" { 2 | const value: any; 3 | export default value; 4 | } -------------------------------------------------------------------------------- /images/cloud-download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReedOwens/UXsyncNow/HEAD/images/cloud-download.png -------------------------------------------------------------------------------- /rest/rest-client.env.json: -------------------------------------------------------------------------------- 1 | { 2 | "development": { 3 | "protocol": "https", 4 | "host": "dev12345.service-now.com", 5 | "username": "admin", 6 | "password": "admin" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /global/Scripted REST Resource/checkUser.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | 3 | var uxsyncnow = new UXsyncNow(); 4 | 5 | return(uxsyncnow.validUserDetail()); 6 | 7 | })(request, response); -------------------------------------------------------------------------------- /src/spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "spec_files": [ 4 | "**/*[sS]pec.js" 5 | ], 6 | "helpers": [ 7 | "helpers/**/*.js" 8 | ], 9 | "stopSpecOnExpectationFailure": false, 10 | "random": false 11 | } 12 | -------------------------------------------------------------------------------- /global/Scripted REST Resource/getApplicationFileChanges.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | //var table = request.queryParams.table; 3 | 4 | //var tu = new x_uxs_uxsheets.tableUtils(); 5 | //var refs = tu.getRelatedLists(table); 6 | return refs; 7 | })(request, response); -------------------------------------------------------------------------------- /global/Scripted REST Resource/getTables.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | var uxsyncnow = new UXsyncNow(); 3 | 4 | if (!uxsyncnow.validUser()) { 5 | return ({status: "ERROR", message: "Invalid User"}) 6 | } 7 | 8 | return uxsyncnow.getTables(); 9 | })(request, response); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #OS junk files 2 | [Tt]humbs.db 3 | *.DS_Store 4 | .* 5 | node_modules/* 6 | !.gitignore 7 | npm-debug.log 8 | docs 9 | wijmo-amd-src 10 | wijmo-amd-min 11 | src/**/*.js 12 | src/**/*.map 13 | 14 | typings 15 | .sync_data 16 | 17 | *.log 18 | *.lock 19 | build 20 | test*/ 21 | old/ 22 | uxsyncnow-config-*.json 23 | .uxsyncnow* 24 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolveJsonModule": true, 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "module": "commonjs", 6 | "noImplicitAny": false, 7 | "outDir": "dist", 8 | "target": "ES5", 9 | "sourceMap": true, 10 | "types" : [ 11 | "jasmine" 12 | ] 13 | }, 14 | "include": [ 15 | "src/**/*" 16 | ], 17 | "exclude": [ 18 | "node_modules" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function(config) { 2 | config.set({ 3 | 4 | frameworks: ["jasmine", "karma-typescript"], 5 | 6 | files: [ 7 | { pattern: "src/**/*.ts" } 8 | ], 9 | 10 | preprocessors: { 11 | "**/*.ts": ["karma-typescript"] 12 | }, 13 | 14 | reporters: ["dots", "karma-typescript"], 15 | 16 | browsers: ["PhantomJS"] 17 | }); 18 | }; 19 | -------------------------------------------------------------------------------- /global/Scripted REST Resource/getApplications.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | //var table = request.queryParams.table; 3 | 4 | //var tu = new x_uxs_uxsheets.tableUtils(); 5 | //var refs = tu.getRelatedLists(table); 6 | var uxsyncnow = new UXsyncNow(); 7 | 8 | if (!uxsyncnow.validUser()) { 9 | return ({status: "ERROR", message: "Invalid User"}) 10 | } 11 | 12 | return uxsyncnow.getApplications(); 13 | })(request, response); 14 | -------------------------------------------------------------------------------- /dist/Notify.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Notify.js","sourceRoot":"","sources":["../src/Notify.ts"],"names":[],"mappings":";;AAAA,wCAA0C;AAC1C,2BAA6B;AAG7B;IAAA;IAuBA,CAAC;IApBU,cAAO,GAAd,UAAe,GAAW,EAAE,KAAmB,EAAE,IAAyB;QAA9C,sBAAA,EAAA,mBAAmB;QAAE,qBAAA,EAAA,yBAAyB;QACtE,IAAI,MAAM,CAAC,YAAY,EAAE;YACrB,QAAQ,CAAC,MAAM,CACX;gBACI,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,GAAG;gBACZ,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC;aAChD,EACD,UAAC,GAAG,EAAE,QAAQ;gBACV,uBAAuB;YAC3B,CAAC,CACJ,CAAC;SACL;IACL,CAAC;IAED,sBAAW,qBAAW;aAAtB,UAAwB,KAAc;YAClC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;QAChC,CAAC;;;OAAA;IArBc,mBAAY,GAAG,KAAK,CAAC;IAsBxC,aAAC;CAAA,AAvBD,IAuBC;AAvBY,wBAAM"} -------------------------------------------------------------------------------- /gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | "use strict"; 3 | 4 | grunt.initConfig({ 5 | ts: { 6 | app: { 7 | files: [{ 8 | src: ["src/\*\*/\*.ts", "!src/.baseDir.ts"], 9 | dest: "./dist" 10 | }], 11 | options: { 12 | module: "commonjs", 13 | target: "es6", 14 | sourceMap: false 15 | } 16 | } 17 | }, 18 | watch: { 19 | ts: { 20 | files: ["src/\*\*/\*.ts"], 21 | tasks: ["ts"] 22 | } 23 | } 24 | }); 25 | 26 | grunt.loadNpmTasks("grunt-contrib-copy"); 27 | grunt.loadNpmTasks("grunt-contrib-watch"); 28 | grunt.loadNpmTasks("grunt-ts"); 29 | 30 | grunt.registerTask("default", [ 31 | "ts" 32 | ]); 33 | 34 | }; 35 | -------------------------------------------------------------------------------- /global/Scripted REST Resource/getApplicationRecords.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | var uxsyncnow = new UXsyncNow(); 3 | 4 | if (!uxsyncnow.validUser()) { 5 | return ({status: "ERROR", message: "Invalid User"}); 6 | } 7 | 8 | var json = new global.JSON(); 9 | 10 | var o = json.decode(request.body.dataString); 11 | if (o) { 12 | var app = o['application']; 13 | if (!app ) { 14 | return ({status: "Error", error_message: "Missing application"}); 15 | } 16 | uxsyncnow.getApplicationExtendedTables(); 17 | return uxsyncnow.getAppRecords(app); 18 | } 19 | return ({status: "ERROR", error_message: "No params passed in PUT body."}); 20 | })(request, response); -------------------------------------------------------------------------------- /src/Watcher.ts: -------------------------------------------------------------------------------- 1 | import * as chokidar from 'chokidar' 2 | 3 | export class Watcher { 4 | private static singleton: Watcher = null; 5 | private watcher: any; 6 | 7 | constructor(persist = true) { 8 | this.watcher = chokidar.watch('', {persistent: persist}); 9 | }; 10 | 11 | set onChange(value: any) { 12 | this.watcher.on('change', value); 13 | } 14 | 15 | static getWatcher(): Watcher { 16 | if (Watcher.singleton === null) { 17 | Watcher.singleton = new Watcher(); 18 | } 19 | return Watcher.singleton; 20 | } 21 | 22 | add(file: string) { 23 | this.watcher.add(file); 24 | } 25 | 26 | remove(file: string) { 27 | this.watcher.unwatch(file); 28 | } 29 | 30 | close() { 31 | this.watcher.close(); 32 | } 33 | } -------------------------------------------------------------------------------- /dist/Watcher.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Watcher.js","sourceRoot":"","sources":["../src/Watcher.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AAEpC;IAII,iBAAY,OAAc;QAAd,wBAAA,EAAA,cAAc;QACtB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,CAAC,CAAC;IAC7D,CAAC;IAAA,CAAC;IAEF,sBAAI,6BAAQ;aAAZ,UAAa,KAAU;YACnB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;;;OAAA;IAEM,kBAAU,GAAjB;QACI,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE;YAC5B,OAAO,CAAC,SAAS,GAAG,IAAI,OAAO,EAAE,CAAC;SACrC;QACD,OAAO,OAAO,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED,qBAAG,GAAH,UAAI,IAAY;QACZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,wBAAM,GAAN,UAAO,IAAY;QACf,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,uBAAK,GAAL;QACI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IA5Bc,iBAAS,GAAY,IAAI,CAAC;IA6B7C,cAAC;CAAA,AA9BD,IA8BC;AA9BY,0BAAO"} -------------------------------------------------------------------------------- /global/Scripted REST Resource/getFile.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | var uxsyncnow = new UXsyncNow(); 3 | 4 | if (!uxsyncnow.validUser()) { 5 | return ({status: "ERROR", message: "Invalid User"}); 6 | } 7 | 8 | var json = new global.JSON(); 9 | 10 | var o = json.decode(request.body.dataString); 11 | if (o) { 12 | var table = o['table']; 13 | var sys_id = o['sys_id']; 14 | var fields = o['fields']; 15 | if (!table || !sys_id || !fields) { 16 | return ({status: "Error", error_message: "Missing table, sys_id, or fields"}); 17 | } 18 | return uxsyncnow.getFile(table, sys_id, fields); 19 | } 20 | return ({status: "ERROR", error_message: "No params passed in PUT body."}); 21 | })(request, response); -------------------------------------------------------------------------------- /src/Notify.ts: -------------------------------------------------------------------------------- 1 | import * as notifier from 'node-notifier'; 2 | import * as path from 'path'; 3 | 4 | 5 | export class Notify { 6 | private static _showMessage = false; 7 | 8 | static message(msg: string, title = "UXsyncNow", icon = 'cloud-upload.png') { 9 | if (Notify._showMessage) { 10 | notifier.notify( 11 | { 12 | title: title, 13 | message: msg, 14 | wait: false, 15 | sound: true, 16 | icon: path.join(__dirname, '../images', icon) 17 | }, 18 | (err, response) => { 19 | // Handle any responses 20 | } 21 | ); 22 | } 23 | } 24 | 25 | static set showMessage( value: boolean ) { 26 | Notify._showMessage = value; 27 | } 28 | } -------------------------------------------------------------------------------- /global/Scripted REST Resource/saveFile.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | var uxsyncnow = new UXsyncNow(); 3 | 4 | if (!uxsyncnow.validUser()) { 5 | return ({status: "ERROR", message: "Invalid User"}) 6 | } 7 | 8 | var json = new global.JSON(); 9 | 10 | var o = json.decode(request.body.dataString); 11 | if (o) { 12 | var now = new GlideDateTime(); 13 | 14 | var table = o['table']; 15 | var sys_id = o['sys_id']; 16 | var field = o['field']; 17 | var content = o['content']; 18 | if (!table || !sys_id || !field || !content) { 19 | return ({status: "Error",error: "table, sys_id, field, and content must be provided"}); 20 | } 21 | var result = uxsyncnow.saveApplicationFile(table ,sys_id ,field, content); 22 | if (result === null) { 23 | return { status: "ERROR", message: "Record with field doesn't exist."}; 24 | } 25 | return ({status: "SUCCESS", result: result, now: now.getNumericValue() }); 26 | } 27 | })(request, response); -------------------------------------------------------------------------------- /global/Scripted REST Resource/getApplicationFiles.js: -------------------------------------------------------------------------------- 1 | (function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) { 2 | //var table = request.queryParams.table; 3 | var uxsyncnow = new UXsyncNow(); 4 | 5 | if (!uxsyncnow.validUser()) { 6 | return uxsyncnow.validUserDetail(); 7 | // return ({status: "ERROR", message: "Invalid User"}) 8 | } 9 | 10 | var json = new global.JSON(); 11 | 12 | var o = json.decode(request.body.dataString); 13 | if (o) { 14 | var now = new GlideDateTime(); 15 | 16 | var app = o['application']; 17 | var since = o['since']; 18 | var tables = o['tables']; 19 | // return( { app: app, tables: tables}); 20 | if (!app || !tables) { 21 | return ({status: "Error",error_message: "An application and tables must be provided."}); 22 | } 23 | var list = uxsyncnow.getApplicationFiles(app,tables,since); 24 | return ({status: "SUCCESS", files: list, now: now.getNumericValue() }); 25 | } 26 | return ({status: "ERROR", error_message: "No params passed in PUT body."}); 27 | })(request, response); 28 | -------------------------------------------------------------------------------- /dist/Notify.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var notifier = require("node-notifier"); 4 | var path = require("path"); 5 | var Notify = /** @class */ (function () { 6 | function Notify() { 7 | } 8 | Notify.message = function (msg, title, icon) { 9 | if (title === void 0) { title = "UXsyncNow"; } 10 | if (icon === void 0) { icon = 'cloud-upload.png'; } 11 | if (Notify._showMessage) { 12 | notifier.notify({ 13 | title: title, 14 | message: msg, 15 | wait: false, 16 | sound: true, 17 | icon: path.join(__dirname, '../images', icon) 18 | }, function (err, response) { 19 | // Handle any responses 20 | }); 21 | } 22 | }; 23 | Object.defineProperty(Notify, "showMessage", { 24 | set: function (value) { 25 | Notify._showMessage = value; 26 | }, 27 | enumerable: true, 28 | configurable: true 29 | }); 30 | Notify._showMessage = false; 31 | return Notify; 32 | }()); 33 | exports.Notify = Notify; 34 | //# sourceMappingURL=Notify.js.map -------------------------------------------------------------------------------- /dist/Watcher.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var chokidar = require("chokidar"); 4 | var Watcher = /** @class */ (function () { 5 | function Watcher(persist) { 6 | if (persist === void 0) { persist = true; } 7 | this.watcher = chokidar.watch('', { persistent: persist }); 8 | } 9 | ; 10 | Object.defineProperty(Watcher.prototype, "onChange", { 11 | set: function (value) { 12 | this.watcher.on('change', value); 13 | }, 14 | enumerable: true, 15 | configurable: true 16 | }); 17 | Watcher.getWatcher = function () { 18 | if (Watcher.singleton === null) { 19 | Watcher.singleton = new Watcher(); 20 | } 21 | return Watcher.singleton; 22 | }; 23 | Watcher.prototype.add = function (file) { 24 | this.watcher.add(file); 25 | }; 26 | Watcher.prototype.remove = function (file) { 27 | this.watcher.unwatch(file); 28 | }; 29 | Watcher.prototype.close = function () { 30 | this.watcher.close(); 31 | }; 32 | Watcher.singleton = null; 33 | return Watcher; 34 | }()); 35 | exports.Watcher = Watcher; 36 | //# sourceMappingURL=Watcher.js.map -------------------------------------------------------------------------------- /dist/Debug.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Debug.js","sourceRoot":"","sources":["../src/Debug.ts"],"names":[],"mappings":";;AAAA,iCAAoC;AAEpC;IA8CI,eAAoB,IAAmB;QAAnB,qBAAA,EAAA,YAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;QACnC,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAG;YACpC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC3B;IACL,CAAC;IA5CD,sBAAW,eAAM;aAAjB;YACI,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;aAED,UAAkB,KAAU;YACxB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC;;;OAJA;IAMD,sBAAW,cAAK;aAAhB;YACI,OAAO,IAAI,CAAC,MAAM,CAAC;QACvB,CAAC;aAED,UAAiB,KAAa;YAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACxB,CAAC;;;OAJA;IAMD,sBAAW,cAAK;aAAhB;YACI,IAAI,KAAK,GAAa,cAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1C,OAAO,KAAK,CAAC;QACjB,CAAC;;;OAAA;IAEM,iBAAW,GAAlB;QACI,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;IACvB,CAAC;IAEM,YAAM,GAAb,UAAc,IAAW;QACrB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,mBAAG,GAAH,UAAI,GAAU,EAAE,KAAgB;QAAhB,sBAAA,EAAA,SAAgB;QAC5B,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE;YACtB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;gBAChE,OAAO;YACX,IAAI,KAAK,CAAC,MAAM;gBACZ,KAAK,CAAC,MAAM,CAAC,GAAG,CAAE,eAAM,CAAC,IAAI,CAAC,IAAI,EAAC,EAAE,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;;gBAErD,OAAO,CAAC,GAAG,CAAE,eAAM,CAAC,IAAI,CAAC,IAAI,EAAC,EAAE,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC;SACvD;IACL,CAAC;IA3Cc,YAAM,GAAU,CAAC,CAAC;IAClB,aAAO,GAAO,IAAI,CAAC;IACnB,aAAO,GAAa,EAAE,CAAC;IACvB,YAAM,GAAa,EAAE,CAAC;IA+CzC,YAAC;CAAA,AAnDD,IAmDC;AAnDY,sBAAK"} -------------------------------------------------------------------------------- /dist/Conflict.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Conflict.js","sourceRoot":"","sources":["../src/Conflict.ts"],"names":[],"mappings":";;AAEA,iCAAqC;AAErC,IAAY,YAIX;AAJD,WAAY,YAAY;IACpB,+CAAI,CAAA;IACJ,+CAAI,CAAA;IACJ,iDAAK,C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AAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;oBACzB,MAAM;gBACV,KAAK,YAAY,CAAC,KAAK;oBACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;aACjC;YACD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;SAC1B;IAGL,CAAC;IAjDF,yCAAyC;IACxB,oBAAU,GAAc,IAAI,CAAC;IAiDjD,gBAAC;CAAA,AAnDD,IAmDC;AAnDY,8BAAS"} -------------------------------------------------------------------------------- /src/Debug.ts: -------------------------------------------------------------------------------- 1 | import {padEnd,clone} from 'lodash'; 2 | 3 | export class Debug { 4 | private static _level:number = 0; 5 | private static _vorpal:any = null; 6 | private static _filter: string[] = []; 7 | private static _areas: string[] = []; 8 | 9 | static get vorpal(): any { 10 | return this._vorpal; 11 | } 12 | 13 | static set vorpal(value: any) { 14 | this._vorpal = value; 15 | } 16 | 17 | static get level(): number { 18 | return this._level; 19 | } 20 | 21 | static set level(value: number) { 22 | this._level = value; 23 | } 24 | 25 | static get areas():string [] { 26 | let areas:string [] = clone(Debug._areas); 27 | return areas; 28 | } 29 | 30 | static resetFilter() { 31 | Debug._filter = []; 32 | } 33 | 34 | static filter(area:string) { 35 | Debug._filter.push(area); 36 | } 37 | 38 | log(msg:string, level:number = 1 ) { 39 | if (level <= Debug.level) { 40 | if (Debug._filter.length>0 && Debug._filter.indexOf(this.area)=== -1) 41 | return; 42 | if (Debug.vorpal) 43 | Debug.vorpal.log( padEnd(this.area,15) + ": " + msg); 44 | else 45 | console.log( padEnd(this.area,15) + ": " + msg); 46 | } 47 | } 48 | 49 | constructor(private area:string = 'gen') { 50 | if (Debug._areas.indexOf(area) === -1 ) { 51 | Debug._areas.push(area); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /rest/get-requests.http: -------------------------------------------------------------------------------- 1 | GET http://{{host}}/api/global/uxsyncnow/getApplications 2 | Accept: */* 3 | Cache-Control: no-cache 4 | Authorization: Basic {{username}} {{password}} 5 | 6 | ### 7 | GET http://{{host}}/api/global/uxsyncnow/getTables 8 | Accept: */* 9 | Cache-Control: no-cache 10 | Authorization: Basic {{username}} {{password}} 11 | 12 | ### 13 | GET http://{{host}}/api/global/uxsyncnow/getApplications 14 | Accept: */* 15 | Cache-Control: no-cache 16 | Authorization: Basic {{username}} {{password}} 17 | 18 | > {% 19 | client.test("Result option exists", function() { 20 | client.assert(response.body.hasOwnProperty("result"), "Cannot find result option in response"); 21 | }); 22 | 23 | client.test("Did we get apps", function() { 24 | var apps = response.body.result; 25 | client.assert(apps.length >0 , "No applications found"); 26 | }); 27 | 28 | client.test("Apps have all keys", function() { 29 | var apps = response.body.result; 30 | var app = apps.shift(); 31 | client.assert(app.hasOwnProperty("name"), "App is missing name"); 32 | client.assert(app.hasOwnProperty("active"), "App is missing active"); 33 | client.assert(app.hasOwnProperty("scope"), "App is missing sys_id"); 34 | client.assert(app.hasOwnProperty("short_description"), "App is missing short_description"); 35 | client.assert(app.hasOwnProperty("version"), "App is missing version"); 36 | 37 | client.assert(apps.length >0 , "No applications found"); 38 | }); 39 | 40 | %} 41 | 42 | ### 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/Conflict.ts: -------------------------------------------------------------------------------- 1 | import {Debug} from "./Debug"; 2 | import {NowFile} from "./NowFile"; 3 | import {findIndex,map} from "lodash"; 4 | 5 | export enum IResolveMode { 6 | PULL, 7 | PUSH, 8 | MERGE 9 | } 10 | 11 | export class Conflicts { 12 | // private debug = new Debug("Conflict"); 13 | private static _singleTon: Conflicts = null; 14 | private _list: NowFile[] = []; 15 | 16 | constructor() { 17 | if( Conflicts._singleTon ) return Conflicts._singleTon; 18 | Conflicts._singleTon = this; 19 | } 20 | 21 | get length(): number { 22 | return this._list.length; 23 | } 24 | 25 | add( file: NowFile ) { 26 | this._list.push(file); 27 | } 28 | 29 | remove( file: NowFile ) { 30 | let i = findIndex(this._list, file); 31 | if (i>=0) { 32 | this._list.splice(i,1); 33 | } 34 | } 35 | 36 | asArray(key = 'fileName'): string[] { 37 | return map(this._list, key); 38 | } 39 | 40 | get list(): NowFile[] { 41 | return this._list; 42 | } 43 | 44 | resolve(file: NowFile, mode: IResolveMode) { 45 | let i = findIndex(this._list, file); 46 | if (i>=0) { 47 | switch (mode) { 48 | case IResolveMode.PULL: 49 | this._list[i].pullFile(); 50 | break; 51 | case IResolveMode.PUSH: 52 | this._list[i].pushFile(); 53 | break; 54 | case IResolveMode.MERGE: 55 | this._list[i].mergeFile(); 56 | } 57 | this._list.splice(i,1); 58 | } 59 | 60 | 61 | } 62 | } -------------------------------------------------------------------------------- /dist/NowFiles.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"NowFiles.js","sourceRoot":"","sources":["../src/NowFiles.ts"],"names":[],"mappings":";;AACA,iCAA0C;AAC1C,iCAA8B;AAE9B;IAKI;QAJQ,UAAK,GAAG,IAAI,aAAK,CAAC,UAAU,CAAC,CAAC;QAEtC,UAAK,GAAc,EAAE,CAAC;QAGlB,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;YAC1B,QAAQ,CAAC,cAAc,GAAG,IAAI,CAAC;SAClC;QACD,OAAO,QAAQ,CAAC,cAAc,CAAC;IACnC,CAAC;IAED,sBAAG,GAAH,UAAI,IAAa;QACb,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAO,IAAI,CAAC,QAAU,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,yBAAM,GAAN,UAAO,IAAa;QAChB,IAAI,KAAK,GAAG,kBAAS,CAAC,IAAI,CAAC,KAAK,EAAC,IAAI,CAAC,CAAC;QACvC,IAAI,KAAK,IAAE,CAAC,EAAE;YACV,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAY,IAAM,CAAC,CAAC;YACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,E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I,GAAG;oBAAE,OAAO,GAAG,CAAC;aACvB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,eAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,4BAAQ"} -------------------------------------------------------------------------------- /dist/NowTables.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"NowTables.js","sourceRoot":"","sources":["../src/NowTables.ts"],"names":[],"mappings":";;AAAA,kCAAqC;AACrC,qCAAkC;AAElC,iDAA8C;AAoB9C;IAkBI;QALQ,YAAO,GAAG,EAAE,CAAC;QACb,oBAAe,GAAG,EAAE,CAAC;QACrB,0BAAqB,GAAG,EAAE,CAAC;QAI/B,IAAI,OAAO,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;QACvE,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;IAChC,CAAC;IAvBD,sBAAI,qCAAc;aAAlB;YACI,OAAO,IAAI,CAAC,eAAe,CAAC;QAChC,CAAC;;;OAAA;IAED,sBAAI,2CAAoB;aAAxB;YACI,OAAO,IAAI,CAAC,qBAAqB,CAAC;QACtC,CAAC;;;OAAA;IAED,sBAAI,6BAAM;aAAV;YACI,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;;;OAAA;IAeM,sBAAY,GAAnB;QACI,IAAI,SAAS,CAAC,UAAU,KAAK,IAAI;YAC7B,IAAI,SAAS,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC,UAAU,CAAA;IAC/B,CAAC;IAGD,2BAAO,GAAP;QACI,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,IAAI,aAAa,GAAG,EAAE,CAAC;QACvB,IAAI,OAAO,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QACnC,IAAI,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAEnD,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;YACxC,IAAI,GAAG,GAAG,6BAAa,CAAC,gBAAgB,EAAE,CAAC;YAC3C,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAC,MAAM;gBACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;gBAC7B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;gBAC9C,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,sBAAsB,CAAC;gBAC3D,IAAI,OAAO,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;gBACnC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACnC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBACpD,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;gBACjE,OAAO,CAAC,IAAI,EAAE,CAAC;gBACf,OAAO,EAAE,CAAC;YACd,CAAC,EACD,UAAC,GAAG;gBACA,OAAO,CAAC,GAAG,CAAC,WAAW,EAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,EAAE,CAAA;YACZ,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC;IA1Cc,oBAAU,GAAc,IAAI,CAAC;IA+DhD,gBAAC;CAAA,AA/ED,IA+EC;AA/EY,8BAAS"} -------------------------------------------------------------------------------- /dist/Debug.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var lodash_1 = require("lodash"); 4 | var Debug = /** @class */ (function () { 5 | function Debug(area) { 6 | if (area === void 0) { area = 'gen'; } 7 | this.area = area; 8 | if (Debug._areas.indexOf(area) === -1) { 9 | Debug._areas.push(area); 10 | } 11 | } 12 | Object.defineProperty(Debug, "vorpal", { 13 | get: function () { 14 | return this._vorpal; 15 | }, 16 | set: function (value) { 17 | this._vorpal = value; 18 | }, 19 | enumerable: true, 20 | configurable: true 21 | }); 22 | Object.defineProperty(Debug, "level", { 23 | get: function () { 24 | return this._level; 25 | }, 26 | set: function (value) { 27 | this._level = value; 28 | }, 29 | enumerable: true, 30 | configurable: true 31 | }); 32 | Object.defineProperty(Debug, "areas", { 33 | get: function () { 34 | var areas = lodash_1.clone(Debug._areas); 35 | return areas; 36 | }, 37 | enumerable: true, 38 | configurable: true 39 | }); 40 | Debug.resetFilter = function () { 41 | Debug._filter = []; 42 | }; 43 | Debug.filter = function (area) { 44 | Debug._filter.push(area); 45 | }; 46 | Debug.prototype.log = function (msg, level) { 47 | if (level === void 0) { level = 1; } 48 | if (level <= Debug.level) { 49 | if (Debug._filter.length > 0 && Debug._filter.indexOf(this.area) === -1) 50 | return; 51 | if (Debug.vorpal) 52 | Debug.vorpal.log(lodash_1.padEnd(this.area, 15) + ": " + msg); 53 | else 54 | console.log(lodash_1.padEnd(this.area, 15) + ": " + msg); 55 | } 56 | }; 57 | Debug._level = 0; 58 | Debug._vorpal = null; 59 | Debug._filter = []; 60 | Debug._areas = []; 61 | return Debug; 62 | }()); 63 | exports.Debug = Debug; 64 | //# sourceMappingURL=Debug.js.map -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uxsyncnow", 3 | "version": "1.0.1", 4 | "description": "UXstorm's ServiceNow file synchronizer / development tool", 5 | "main": "uxsyncnow.js", 6 | "scripts": { 7 | "test": "karma start", 8 | "build": "echo 'Installing' && tsc && (echo '#!/usr/bin/env node' >dist/uxsyncnowcli && cat dist/uxsyncnow.js >> dist/uxsyncnowcli)" 9 | }, 10 | "bin": { 11 | "uxsyncnow": "dist/uxsyncnowcli" 12 | }, 13 | "keywords": [ 14 | "servicenow", 15 | "uxstorm", 16 | "filesync", 17 | "sync" 18 | ], 19 | "bugs": { 20 | "url": "https://github.com/ReedOwens/UXsyncNow/issues" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/ReedOwens/UXsyncNow.git" 25 | }, 26 | "author": "Reed Owens (http://uxstorm.com)", 27 | "license": "AGPL-3.0+", 28 | "dependencies": { 29 | "bluebird": "^3.5.1", 30 | "bottleneck": "^1.16.0", 31 | "chokidar": "^2.0.2", 32 | "crypto-js": "^3.1.9-1", 33 | "jsonfile": "^4.0.0", 34 | "lodash": "^4.17.15", 35 | "minimist": "^1.2.5", 36 | "mkdirp": "^0.5.1", 37 | "node-notifier": "^5.2.1", 38 | "unirest": "^0.6.0", 39 | "vorpal": "^1.12.0", 40 | "vorpal-log": "^1.1.0" 41 | }, 42 | "devDependencies": { 43 | "@types/bluebird": "^3.5.16", 44 | "@types/chokidar": "^1.7.5", 45 | "@types/crypto-js": "^3.1.39", 46 | "@types/jasmine": "^2.8.2", 47 | "@types/jsonfile": "^4.0.0", 48 | "@types/lodash": "^4.14.106", 49 | "@types/minimist": "^1.2.0", 50 | "@types/mkdirp": "^0.5.1", 51 | "@types/node": "^8.0.53", 52 | "@types/node-notifier": "^0.0.28", 53 | "grunt": "^1.1.0", 54 | "grunt-contrib-copy": "^1.0.0", 55 | "grunt-contrib-watch": "^1.1.0", 56 | "grunt-ts": "^6.0.0-beta.22", 57 | "jasmine": "^2.8.0", 58 | "jasmine-core": "^2.8.0", 59 | "jasmine-node": "^1.14.5", 60 | "karma": "^1.7.1", 61 | "karma-jasmine": "^1.1.0", 62 | "karma-phantomjs-launcher": "^1.0.4", 63 | "karma-typescript": "^3.0.8", 64 | "phantomjs": "^2.1.7", 65 | "typescript": "^2.3.2", 66 | "typings": "^2.1.1" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/NowFiles.ts: -------------------------------------------------------------------------------- 1 | import {NowFile} from "./NowFile"; 2 | import {findIndex, forEach} from "lodash"; 3 | import {Debug} from "./Debug"; 4 | 5 | export class NowFiles { 6 | private debug = new Debug('NowFiles'); 7 | static filesSingleton: NowFiles; 8 | files: NowFile[] = []; 9 | 10 | constructor() { 11 | if (!NowFiles.filesSingleton) { 12 | NowFiles.filesSingleton = this; 13 | } 14 | return NowFiles.filesSingleton; 15 | } 16 | 17 | add(file: NowFile) { 18 | this.debug.log(`Add ${file.fileName}`); 19 | this.files.push(file); 20 | } 21 | 22 | remove(file: NowFile) { 23 | let index = findIndex(this.files,file); 24 | if (index>=0) { 25 | this.debug.log(`Removing ${file}`); 26 | this.files.splice(index,1); 27 | } 28 | } 29 | 30 | clear() { 31 | this.files = []; 32 | } 33 | 34 | paths(): string[] { 35 | let names: string[] = []; 36 | forEach(this.files, (file) => names.push(file.fileName)); 37 | names.sort(); 38 | return names; 39 | } 40 | 41 | find(value: any, key = "fileName"): NowFile { 42 | for (let i = 0; i < this.files.length; i++) { 43 | let file = this.files[i]; 44 | if (typeof value === "string") { 45 | if (typeof file[key] !== "undefined") { 46 | if (file[key] === value) return file; 47 | } 48 | } else if (typeof value === "object") { 49 | let res: NowFile = null; 50 | for (let k in value) { 51 | // console.log("type " + file[k] + " is " + typeof file[k]); 52 | if (typeof file[k] !== "undefined") { 53 | if (file[k] === value[k]) { 54 | res = file; 55 | } else { 56 | res = null; 57 | break; // Don't go anymore 58 | } 59 | } 60 | } 61 | if (res) return res; 62 | } 63 | } 64 | return null; 65 | } 66 | } -------------------------------------------------------------------------------- /dist/NowApplications.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"NowApplications.js","sourceRoot":"","sources":["../src/NowApplications.ts"],"names":[],"mappings":";;AAAA,kCAAqC;AACrC,qCAAkC;AAClC,0BAA6B;AAC7B,iDAA8C;AAC9C,iCAA8B;AAW9B;IAUI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AAA,AArHD,IAqHC;AArHY,0CAAe"} -------------------------------------------------------------------------------- /global/Script Include/UXCRC32.js: -------------------------------------------------------------------------------- 1 | var UXCRC32 = Class.create(); 2 | UXCRC32.prototype = { 3 | initialize: function () { 4 | if (!UXCRC32.table) { 5 | UXCRC32.reversedPolynomial = 0xEDB88320; 6 | UXCRC32.crc32_initial = 0xFFFFFFFF; 7 | UXCRC32.table = this.crc32_generate(UXCRC32.reversedPolynomial); 8 | } 9 | }, 10 | crc32_generate: function (reversedPolynomial) { 11 | var table = []; 12 | var i, j, n; 13 | 14 | for (i = 0; i < 256; i++) { 15 | n = i; 16 | for (j = 8; j > 0; j--) { 17 | if ((n & 1) === 1) { 18 | n = (n >>> 1) ^ reversedPolynomial; 19 | } else { 20 | n = n >>> 1; 21 | } 22 | } 23 | table[i] = n; 24 | } 25 | 26 | return table; 27 | }, 28 | crc32_add_byte: function (table, crc2, byte2) { 29 | crc2 = (crc2 >>> 8) ^ table[(byte2) ^ (crc2 & 0x000000FF)]; 30 | return crc2; 31 | }, 32 | crc32_final: function (crc) { 33 | crc = ~crc; 34 | crc = (crc < 0) ? (0xFFFFFFFF + crc + 1) : crc; 35 | return crc; 36 | }, 37 | 38 | crc32_compute_string: function (reversedPolynomial, str) { 39 | var table = this.crc32_generate(reversedPolynomial); 40 | var i; 41 | 42 | var crc = UXCRC32.crc32_initial; 43 | 44 | for (i = 0; i < str.length; i++) 45 | crc = this.crc32_add_byte(table, crc, str.charCodeAt(i)); 46 | 47 | crc = this.crc32_final(crc); 48 | return crc; 49 | }, 50 | computeString: function (str) { 51 | var table = UXCRC32.table; 52 | var crc = 0; 53 | var i; 54 | 55 | crc = UXCRC32.crc32_initial; 56 | 57 | for (i = 0; i < str.length; i++) 58 | crc = this.crc32_add_byte(table, crc, str.charCodeAt(i)); 59 | 60 | crc = this.crc32_final(crc); 61 | return this.toHex(crc); 62 | }, 63 | toHex: function (value, len) { 64 | if (typeof (len) === 'undefined') len = 8; 65 | var num = value < 0 ? (0xFFFFFFFF + value + 1) : value; 66 | var hex = num.toString(16).toUpperCase(); 67 | var pad = hex.length < len ? len - hex.length : 0; 68 | return "0".repeat(pad) + hex; 69 | }, 70 | 71 | type: "UXCRC32" 72 | }; 73 | -------------------------------------------------------------------------------- /dist/Conflict.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var lodash_1 = require("lodash"); 4 | var IResolveMode; 5 | (function (IResolveMode) { 6 | IResolveMode[IResolveMode["PULL"] = 0] = "PULL"; 7 | IResolveMode[IResolveMode["PUSH"] = 1] = "PUSH"; 8 | IResolveMode[IResolveMode["MERGE"] = 2] = "MERGE"; 9 | })(IResolveMode = exports.IResolveMode || (exports.IResolveMode = {})); 10 | var Conflicts = /** @class */ (function () { 11 | function Conflicts() { 12 | this._list = []; 13 | if (Conflicts._singleTon) 14 | return Conflicts._singleTon; 15 | Conflicts._singleTon = this; 16 | } 17 | Object.defineProperty(Conflicts.prototype, "length", { 18 | get: function () { 19 | return this._list.length; 20 | }, 21 | enumerable: true, 22 | configurable: true 23 | }); 24 | Conflicts.prototype.add = function (file) { 25 | this._list.push(file); 26 | }; 27 | Conflicts.prototype.remove = function (file) { 28 | var i = lodash_1.findIndex(this._list, file); 29 | if (i >= 0) { 30 | this._list.splice(i, 1); 31 | } 32 | }; 33 | Conflicts.prototype.asArray = function (key) { 34 | if (key === void 0) { key = 'fileName'; } 35 | return lodash_1.map(this._list, key); 36 | }; 37 | Object.defineProperty(Conflicts.prototype, "list", { 38 | get: function () { 39 | return this._list; 40 | }, 41 | enumerable: true, 42 | configurable: true 43 | }); 44 | Conflicts.prototype.resolve = function (file, mode) { 45 | var i = lodash_1.findIndex(this._list, file); 46 | if (i >= 0) { 47 | switch (mode) { 48 | case IResolveMode.PULL: 49 | this._list[i].pullFile(); 50 | break; 51 | case IResolveMode.PUSH: 52 | this._list[i].pushFile(); 53 | break; 54 | case IResolveMode.MERGE: 55 | this._list[i].mergeFile(); 56 | } 57 | this._list.splice(i, 1); 58 | } 59 | }; 60 | // private debug = new Debug("Conflict"); 61 | Conflicts._singleTon = null; 62 | return Conflicts; 63 | }()); 64 | exports.Conflicts = Conflicts; 65 | //# sourceMappingURL=Conflict.js.map -------------------------------------------------------------------------------- /dist/SyncMode.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"SyncMode.js","sourceRoot":"","sources":["../src/SyncMode.ts"],"names":[],"mappings":";;AAAA,iCAA8B;AAE9B,IAAY,IAMX;AAND,WAAY,IAAI;IACZ,+BAAM,CAAA;IACN,+BAAM,CAAA;IACN,iCAAO,CAAA;IACP,uCAAU,CAAA;IACV,+BAAM,CAAA;AACV,CAAC,EANW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAMf;AAED;;GAEG;AACH;IAyGI;;;;OAIG;IACH;QAlGQ,UAAK,GAAS,IAAI,CAAC,IAAI,CAAC;QAUxB,UAAK,GAAY,KAAK,CAAC;QAUvB,cAAS,GAAS,IAAI,CAAC,IAAI,CAAC;QAU5B,gBAAW,GAAW,CAAC,CAAC;QAUxB,mBAAc,GAAW,CAAC,CAAC;QAyB3B,cAAS,GAAQ,IAAI,CAAC;QAkC1B,IAAI,QAAQ,CAAC,UAAU,KAAK,IAAI,EAAE;YAC9B,OAAO,QAAQ,CAAC,UAAU,CAAC;SAC9B;QACD,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;IAC/B,CAAC;IA/GD,sBAAW,qBAAS;aAApB;YACI,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;aAED,UAAqB,KAAe;YAChC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAC5B,CAAC;;;OAJA;IAQD,sBAAI,0BAAI;aAAR;YACI,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;aAED,UAAS,KAAW;YAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACvB,CAAC;;;OAJA;IAQD,sBAAI,0BAAI;aAAR;YACI,O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nB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QAC3B,CAAC;;;OAJA;IAMM,oBAAW,GAAlB;QACI,IAAI,QAAQ,CAAC,UAAU,KAAK,IAAI,EAAE;YAC9B,QAAQ,CAAC,UAAU,GAAG,IAAI,QAAQ,EAAE,CAAC;SACxC;QACD,OAAO,QAAQ,CAAC,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,4BAAS,GAAT,UAAU,UAAkB,EAAE,QAAa;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAC1B,CAAC;IAtGc,cAAK,GAAG,IAAI,aAAK,CAAC,UAAU,CAAC,CAAC;IAC9B,mBAAU,GAAa,IAAI,CAAC;IAkH/C,eAAC;CAAA,AApHD,IAoHC;AApHY,4BAAQ"} -------------------------------------------------------------------------------- /dist/FileCache.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"FileCache.js","sourceRoot":"","sources":["../src/FileCache.ts"],"names":[],"mappings":";;AAAA,uBAA0B;AAC1B,mCAAsC;AACtC,qCAAkC;AASrB,QAAA,MAAM,GAAG,CAAC,CAAC,CAAC;AAEzB;IAOI;QAHQ,eAAU,GAAG,EAAE,CAAC;QAChB,UAAK,GAAG,EAAE,CAAC;QAIf,IAAI,SAAS,CAAC,SAAS,KAAK,IAAI,EAAE;YAC9B,OAAO,SAAS,CAAC,SAAS,CAAA;SAC7B;QAED,IAAI,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QAE5B,IAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,IAAM,UAAU,GAAG,iBAAiB,CAAC;QAErC,IAAI,CAAC,UAAU,GAAG,SAAS,GAAG,GAAG,GAAG,UAAU,CAAC;QAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC1B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EAAE,UAAU,EAAE,cAAM,EAAE,UAAU,EAAE,cAAM,EAAC,CAAA;SACzF;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,0BAAM,GAAN,UAAO,IAAY;QACf,OAAO,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,wBAAI,GAAJ;QACI,IAAI;YACA,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,EAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAC,CAAC,CAAC;SACjF;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,kCAAkC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACpB;IACL,CAAC;IAED,wBAAI,GAAJ;QACI,IAAI;YACA,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACvD;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,iCAAiC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YACjE,OAAO,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACpB;IACL,CAAC;IAxGc,mBAAS,GAAc,IAAI,CAAC;IAyG/C,gBAAC;CAAA,AA1GD,IA0GC;AA1GY,8BAAS"} -------------------------------------------------------------------------------- /dist/NowFiles.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var lodash_1 = require("lodash"); 4 | var Debug_1 = require("./Debug"); 5 | var NowFiles = /** @class */ (function () { 6 | function NowFiles() { 7 | this.debug = new Debug_1.Debug('NowFiles'); 8 | this.files = []; 9 | if (!NowFiles.filesSingleton) { 10 | NowFiles.filesSingleton = this; 11 | } 12 | return NowFiles.filesSingleton; 13 | } 14 | NowFiles.prototype.add = function (file) { 15 | this.debug.log("Add " + file.fileName); 16 | this.files.push(file); 17 | }; 18 | NowFiles.prototype.remove = function (file) { 19 | var index = lodash_1.findIndex(this.files, file); 20 | if (index >= 0) { 21 | this.debug.log("Removing " + file); 22 | this.files.splice(index, 1); 23 | } 24 | }; 25 | NowFiles.prototype.clear = function () { 26 | this.files = []; 27 | }; 28 | NowFiles.prototype.paths = function () { 29 | var names = []; 30 | lodash_1.forEach(this.files, function (file) { return names.push(file.fileName); }); 31 | names.sort(); 32 | return names; 33 | }; 34 | NowFiles.prototype.find = function (value, key) { 35 | if (key === void 0) { key = "fileName"; } 36 | for (var i = 0; i < this.files.length; i++) { 37 | var file = this.files[i]; 38 | if (typeof value === "string") { 39 | if (typeof file[key] !== "undefined") { 40 | if (file[key] === value) 41 | return file; 42 | } 43 | } 44 | else if (typeof value === "object") { 45 | var res = null; 46 | for (var k in value) { 47 | // console.log("type " + file[k] + " is " + typeof file[k]); 48 | if (typeof file[k] !== "undefined") { 49 | if (file[k] === value[k]) { 50 | res = file; 51 | } 52 | else { 53 | res = null; 54 | break; // Don't go anymore 55 | } 56 | } 57 | } 58 | if (res) 59 | return res; 60 | } 61 | } 62 | return null; 63 | }; 64 | return NowFiles; 65 | }()); 66 | exports.NowFiles = NowFiles; 67 | //# sourceMappingURL=NowFiles.js.map -------------------------------------------------------------------------------- /dist/NowTables.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Promise = require("bluebird"); 4 | var Options_1 = require("./Options"); 5 | var UXsyncNowREST_1 = require("./UXsyncNowREST"); 6 | var NowTables = /** @class */ (function () { 7 | function NowTables() { 8 | this._tables = {}; 9 | this._tablesUnmapped = {}; 10 | this._tablesNonApplication = {}; 11 | var options = Options_1.Options.getOptions(); 12 | this._tables = options.get('tables', {}); 13 | this._tablesUnmapped = options.get('tables_unmapped', {}); 14 | this._tablesNonApplication = options.get('tables_non_application', {}); 15 | NowTables._singleton = this; 16 | } 17 | Object.defineProperty(NowTables.prototype, "tablesUnmapped", { 18 | get: function () { 19 | return this._tablesUnmapped; 20 | }, 21 | enumerable: true, 22 | configurable: true 23 | }); 24 | Object.defineProperty(NowTables.prototype, "tablesNonApplication", { 25 | get: function () { 26 | return this._tablesNonApplication; 27 | }, 28 | enumerable: true, 29 | configurable: true 30 | }); 31 | Object.defineProperty(NowTables.prototype, "tables", { 32 | get: function () { 33 | return this._tables; 34 | }, 35 | enumerable: true, 36 | configurable: true 37 | }); 38 | NowTables.getNowTables = function () { 39 | if (NowTables._singleton === null) 40 | new NowTables(); 41 | return NowTables._singleton; 42 | }; 43 | NowTables.prototype.refresh = function () { 44 | var self = this; 45 | var table_errors = []; 46 | var table_display = {}; 47 | var options = Options_1.Options.getOptions(); 48 | var table_ignore = options.get('table_ignore', []); 49 | return new Promise(function (resolve, reject) { 50 | var api = UXsyncNowREST_1.UXsyncNowREST.getUXsyncNowREST(); 51 | api.getTables().then(function (result) { 52 | self._tables = result.tables; 53 | self._tablesUnmapped = result.tables_unmapped; 54 | self._tablesNonApplication = result.tables_non_application; 55 | var options = Options_1.Options.getOptions(); 56 | options.set('tables', self._tables); 57 | options.set('tables_unmapped', self._tablesUnmapped); 58 | options.set('tables_non_application', self._tablesNonApplication); 59 | options.save(); 60 | resolve(); 61 | }, function (err) { 62 | console.log("Got error", err); 63 | reject(); 64 | }); 65 | }); 66 | }; 67 | NowTables._singleton = null; 68 | return NowTables; 69 | }()); 70 | exports.NowTables = NowTables; 71 | //# sourceMappingURL=NowTables.js.map -------------------------------------------------------------------------------- /src/SyncMode.ts: -------------------------------------------------------------------------------- 1 | import {Debug} from "./Debug"; 2 | 3 | export enum Sync { 4 | "PULL", 5 | "PUSH", 6 | "LOCAL", 7 | "INSTANCE", 8 | "SYNC" 9 | } 10 | 11 | /** 12 | * Type of Sync 13 | */ 14 | export class SyncMode { 15 | private static debug = new Debug('SyncMode'); 16 | private static _singleton: SyncMode = null; 17 | 18 | static get singleton(): SyncMode { 19 | return this._singleton; 20 | } 21 | 22 | static set singleton(value: SyncMode) { 23 | this._singleton = value; 24 | } 25 | 26 | private _mode: Sync = Sync.SYNC; 27 | 28 | get mode(): Sync { 29 | return this._mode; 30 | } 31 | 32 | set mode(value: Sync) { 33 | this._mode = value; 34 | } 35 | 36 | private _init: boolean = false; 37 | 38 | get init(): boolean { 39 | return this._init; 40 | } 41 | 42 | set init(value: boolean) { 43 | this._init = value; 44 | } 45 | 46 | private _initMode: Sync = Sync.PULL; 47 | 48 | get initMode(): Sync { 49 | return this._initMode; 50 | } 51 | 52 | set initMode(value: Sync) { 53 | this._initMode = value; 54 | } 55 | 56 | private _filesToGet: number = 0; 57 | 58 | get filesToGet(): number { 59 | return this._filesToGet; 60 | } 61 | 62 | set filesToGet(value: number) { 63 | this._filesToGet = value; 64 | } 65 | 66 | private _filesReceived: number = 0; 67 | 68 | get filesReceived(): number { 69 | return this._filesReceived; 70 | } 71 | 72 | set filesReceived(value: number) { 73 | this._filesReceived = value; 74 | if (!this.init) { 75 | return; 76 | } 77 | SyncMode.debug.log(`FilesReceived: ${this._filesReceived} out of ${this._filesToGet} init: ${this.init}`); 78 | 79 | if (this._filesReceived >= this._filesToGet) { 80 | SyncMode.debug.log( 81 | `Received last file ${value} looking for ${this._filesToGet}` 82 | ); 83 | if (this.whenDone) { 84 | SyncMode.debug.log("Calling WhenDone"); 85 | this.whenDone(); 86 | } 87 | this.init = false; 88 | } 89 | } 90 | 91 | private _whenDone: any = null; 92 | 93 | get whenDone(): any { 94 | return this._whenDone; 95 | } 96 | 97 | set whenDone(value: any) { 98 | this._whenDone = value; 99 | } 100 | 101 | static getSyncMode(): SyncMode { 102 | if (SyncMode._singleton === null) { 103 | SyncMode._singleton = new SyncMode(); 104 | } 105 | return SyncMode._singleton; 106 | } 107 | 108 | /** 109 | * 110 | * @param {number} filesToGet 111 | * @param whenDone 112 | */ 113 | setupPull(filesToGet: number, whenDone: any) { 114 | this.filesToGet = filesToGet; 115 | this._whenDone = whenDone; 116 | this.mode = Sync.PULL; 117 | } 118 | 119 | /** 120 | * Singleton constructor. 121 | * 122 | * @returns {SyncMode} 123 | */ 124 | constructor() { 125 | if (SyncMode._singleton !== null) { 126 | return SyncMode._singleton; 127 | } 128 | SyncMode._singleton = this; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | ## 1.0 3 | ### BREAKING CHANGES 4 | **table_dir** and **multifile** options defaults will change the names and directories that the synced files are stored. 5 | Because of this you need to do one of the following: 6 | 7 | * Keep same functionality of .9 Release 8 | * Before upgrade ensure your filesystem and instance are in sync. 9 | * Upgrade **uxsyncnow** and Load/Preview/and Commit the Updateset on your Instance 10 | * run **uxsyncnow** with with new --noinit option and setup options to mimic .9 release behavior 11 | ```bash 12 | $ uxsyncnow --noinit 13 | Reading config file: uxsyncnow-config-dev.json 14 | You are connected but no synchronization is started. Use command 'sync' to start synchronization. 15 | uxsyncnow: refresh tables 16 | uxsyncnow: set option table_dir name 17 | uxsyncnow: set option multifile flat 18 | uxsyncnow: sync 19 | ``` 20 | * Switch to the new directory and file format. 21 | * Before upgrade ensure your filesystem and instance are in sync. 22 | * Upgrade **uxsyncnow** and Load/Preview/and Commit the Updateset on your Instance 23 | * Remove all .uxsyncnow-??? cache directories 24 | * **If the files are under source control don't do this step**. Remove the directory where your files from the Instance are synced. 25 | * run **uxsyncnow** with with new --noinit option to refresh tables to have the table labels retrieved. If you don't do this then the new method to create the table directories with their labels will not work. 26 | ```bash 27 | $ uxsyncnow --noinit 28 | Reading config file: uxsyncnow-config-dev.json 29 | You are connected but no synchronization is started. Use command 'sync' to start synchronization. 30 | uxsyncnow: refresh tables 31 | uxsyncnow: sync 32 | ``` 33 | * If your files were under source control 34 | * Determine how to "rename" a file in your source control system. You will have both the old and new directory structure with the "history" on the old file items. The Source System must see the files as a move to the new path and name. 35 | * After everything is "moved", then ensure that there are no "old" files or directories 36 | 37 | 38 | ### New features 39 | * Table directories will be the label for the table instead of the database name. For instance **sys_script** will be **Business Rules**. 40 | * If a table has multiple fields that are "files" then there are two new modes to handle the files. **record** and **field**, both will create directories under the table directory and organize the different files. 41 | * New command line option **--noinit** added 42 | * New option added to handle Table Directory naming (**table_dir**). 43 | * New option added to handle Multiple Fields (**multifile**). 44 | * With new UpdateSet 45 | * Two new "blank" templates are added to ignore sys_policy and business rule templates that are "blank" templates and have data but have not been changed on the instance. 46 | * Ignore the message field on sys_scipt table as a "file." The message is an html_text field that is shown to the user if the show message field is checked. This field is not a large HTML field to be under control and is now ignored. 47 | 48 | ### Bugs Fixed 49 | 50 | * \#17 Some files are created that should not be because the initial "blank" value contains text 51 | * \#14 Add option to connect without syncing enhancement 52 | * \#9 Service Portal widgets do not sync correctly enhancement 53 | * \#15 Collapse "file" field from name if it is the only one for the table -------------------------------------------------------------------------------- /dist/Connection.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Connection.js","sourceRoot":"","sources":["../src/Connection.ts"],"names":[],"mappings":";;AAAA,iCAAmC;AACnC,qCAAkC;AAClC,kCAAqC;AAErC,IAAI,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEvC;;GAEG;AAEH;IAmCI;;;;OAIG;IACH,uBAAY,QAAgB;QACxB,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC;QAE/B,IAAI,aAAa,CAAC,QAAQ,KAAK,IAAI;YAC/B,aAAa,CAAC,QAAQ,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QAClD,IAAI,aAAa,CAAC,QAAQ,KAAK,IAAI;YAC/B,aAAa,CAAC,eAAe,EAAE,CAAC;QACpC,IAAI,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC;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C;IACrB,sBAAQ,GAAY,IAAI,CAAC;IAkI5C,oBAAC;CAAA,AAzID,IAyIC;AAzIY,sCAAa"} -------------------------------------------------------------------------------- /src/NowTables.ts: -------------------------------------------------------------------------------- 1 | import Promise = require('bluebird'); 2 | import {Options} from "./Options"; 3 | import * as _ from "lodash"; 4 | import {UXsyncNowREST} from "./UXsyncNowREST"; 5 | 6 | export interface IFieldDef { 7 | name:string, 8 | table:string, 9 | label:string, 10 | type:string, 11 | scope:string, 12 | scope_id:string, 13 | fileName?:string, // Override for the standard file name 14 | dir?:string // Override for the standard directory 15 | } 16 | 17 | export interface ITableDef { 18 | key:string, 19 | name:string, 20 | fields: IFieldDef[], 21 | label?:string 22 | } 23 | 24 | export class NowTables { 25 | get tablesUnmapped(): {} { 26 | return this._tablesUnmapped; 27 | } 28 | 29 | get tablesNonApplication(): {} { 30 | return this._tablesNonApplication; 31 | } 32 | 33 | get tables(): {} { 34 | return this._tables; 35 | } 36 | 37 | private _tables = {}; 38 | private _tablesUnmapped = {}; 39 | private _tablesNonApplication = {}; 40 | private static _singleton: NowTables = null; 41 | 42 | constructor() { 43 | let options = Options.getOptions(); 44 | this._tables = options.get('tables', {}); 45 | this._tablesUnmapped = options.get('tables_unmapped', {}); 46 | this._tablesNonApplication = options.get('tables_non_application', {}); 47 | NowTables._singleton = this; 48 | } 49 | 50 | static getNowTables(): NowTables { 51 | if (NowTables._singleton === null) 52 | new NowTables(); 53 | return NowTables._singleton 54 | } 55 | 56 | 57 | refresh(): Promise { 58 | let self = this; 59 | let table_errors = []; 60 | let table_display = {}; 61 | let options = Options.getOptions(); 62 | let table_ignore = options.get('table_ignore', []); 63 | 64 | return new Promise(function (resolve, reject) { 65 | let api = UXsyncNowREST.getUXsyncNowREST(); 66 | api.getTables().then((result) => { 67 | self._tables = result.tables; 68 | self._tablesUnmapped = result.tables_unmapped; 69 | self._tablesNonApplication = result.tables_non_application; 70 | let options = Options.getOptions(); 71 | options.set('tables',self._tables); 72 | options.set('tables_unmapped',self._tablesUnmapped); 73 | options.set('tables_non_application',self._tablesNonApplication); 74 | options.save(); 75 | resolve(); 76 | }, 77 | (err) => { 78 | console.log("Got error",err); 79 | reject() 80 | }); 81 | }); 82 | } 83 | /* 84 | list():string { 85 | let ret = ""; 86 | let tables = this._tables; 87 | _.each(tables,(table:IRESTTableDef,) => { 88 | ret += `${table.name} (${table.key}) 89 | ---------------------------------------------------------------------- 90 | `; 91 | _.each(table.fields, (field:IRestFieldDef) => { 92 | ret += ' ' + 93 | _.padEnd(field.name, 20) + ' ' + 94 | _.padEnd(field.label, 20) + ' ' + 95 | _.padEnd(field.type, 20) + "\n"; 96 | }); 97 | ret += "\n"; 98 | }); 99 | return ret; 100 | } 101 | 102 | */ 103 | } -------------------------------------------------------------------------------- /src/FileCache.ts: -------------------------------------------------------------------------------- 1 | import fs = require('fs'); 2 | import jsonfile = require('jsonfile'); 3 | import {Options} from "./Options"; 4 | 5 | export interface IFileCache { 6 | serverCRC: number; 7 | clientCRC: number; 8 | serverSync: number; 9 | clientSync: number; 10 | } 11 | 12 | export const IGNORE = -1; 13 | 14 | export class FileCache { 15 | private static singleton: FileCache = null; 16 | 17 | 18 | private configFile = ''; 19 | private files = {}; 20 | 21 | constructor() { 22 | 23 | if (FileCache.singleton !== null) { 24 | return FileCache.singleton 25 | } 26 | 27 | let options = new Options(); 28 | 29 | const configDir = options.configDir; 30 | const configFile = "file_cache.json"; 31 | 32 | this.configFile = configDir + '/' + configFile; 33 | if (fs.existsSync(configDir)) { 34 | let stat = fs.statSync(configDir); 35 | if (stat.isDirectory()) { 36 | // Directory exists. Check for exiting configuration 37 | if (fs.existsSync(this.configFile)) { 38 | this.read(); 39 | } else { 40 | this.save(); 41 | } 42 | } else { 43 | console.log(configDir + " is not a directory. Please correct and run again"); 44 | process.exit(-1); 45 | } 46 | } else { 47 | fs.mkdirSync(configDir); 48 | this.save(); 49 | } 50 | 51 | FileCache.singleton = this; 52 | } 53 | 54 | /** 55 | * Returns the singleton object of the Options class. 56 | * 57 | * @param {string} baseDir 58 | * @returns {Options} 59 | */ 60 | static getFileCache(): FileCache { 61 | if (FileCache.singleton == null) 62 | FileCache.singleton = new FileCache(); 63 | return (FileCache.singleton) 64 | } 65 | 66 | /** 67 | * Sets an option value 68 | * 69 | * @param {string} name 70 | * @param value 71 | */ 72 | 73 | set(name: string, value: IFileCache) { 74 | this.files[name] = value; 75 | this.save(); 76 | } 77 | 78 | /** 79 | * Gets the value of an option. If **defaultValue** is provided and the option doesn't 80 | * exist, then defaultValue is return. If the option doesn't exist and no defaultValue 81 | * is provided then null is returned. 82 | * 83 | * @param {string} name 84 | * @param defaultValue 85 | * @returns {any} 86 | */ 87 | 88 | get(name: string, defaultValue = true): IFileCache { 89 | if (typeof this.files[name] !== 'undefined') 90 | return this.files[name]; 91 | if (defaultValue) { 92 | return { serverCRC: IGNORE, clientCRC: IGNORE, serverSync: IGNORE, clientSync: IGNORE} 93 | } 94 | return null; 95 | } 96 | 97 | exists(name: string): boolean { 98 | return (typeof this.files[name] !== 'undefined'); 99 | } 100 | 101 | save() { 102 | try { 103 | jsonfile.writeFileSync(this.configFile, this.files, {spaces: 2, EOL: '\r\n'}); 104 | } catch (err) { 105 | console.log("Could not write FileCache file: " + this.configFile); 106 | console.log('' + err); 107 | process.exit(-1); 108 | } 109 | } 110 | 111 | read() { 112 | try { 113 | this.files = jsonfile.readFileSync(this.configFile); 114 | } catch (err) { 115 | console.log("Could not read FileCache file: " + this.configFile); 116 | console.log('' + err); 117 | process.exit(-1); 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /dist/AppWatcher.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"AppWatcher.js","sourceRoot":"","sources":["../src/AppWatcher.ts"],"names":[],"mappings":";;AAAA,uCAA0C;AAC1C,qCAAkC;AAClC,qCAAkC;AAClC,uCAAoC;AACpC,iDAA8C;AAC9C,qCAAkC;AAClC,iCAA+B;AAC/B,mCAAgC;AAChC,iCAA8B;AAe9B;I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AAI,CAAC,KAAK;4BACrB,SAAS,EAAE,GAAG;yBACjB,CAAC,CAAC;wBACH,IAAI,CAAC,EAAE;4BACH,oCAAoC;4BACpC,CAAC,CAAC,gBAAgB,EAAE,CAAC;4BACrB,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC;4BACf,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;yBACjC;6BAAM;4BACH,uBAAuB;4BACvB,IAAI,GAAC,GAAG,IAAI,iBAAO,CACf,KAAI,CAAC,OAAO,EACZ,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,IAAI,EACT,GAAG,EACH,MAAM,EACN,KAAI,CAAC,GAAG,CACX,CAAC;4BACF,IAAI,KAAI,CAAC,KAAK,EAAE;gCACZ,GAAC,CAAC,KAAK,EAAE,CAAC;6BACb;yBAEJ;qBACJ;iBACJ;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACX,CAAC;IAED,4BAAO,GAAP;QACI,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SACxB;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAChC;IACL,CAAC;IACL,iBAAC;AAAD,CAAC,AA/ID,IA+IC;AA/IY,gCAAU"} -------------------------------------------------------------------------------- /dist/FileCache.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var fs = require("fs"); 4 | var jsonfile = require("jsonfile"); 5 | var Options_1 = require("./Options"); 6 | exports.IGNORE = -1; 7 | var FileCache = /** @class */ (function () { 8 | function FileCache() { 9 | this.configFile = ''; 10 | this.files = {}; 11 | if (FileCache.singleton !== null) { 12 | return FileCache.singleton; 13 | } 14 | var options = new Options_1.Options(); 15 | var configDir = options.configDir; 16 | var configFile = "file_cache.json"; 17 | this.configFile = configDir + '/' + configFile; 18 | if (fs.existsSync(configDir)) { 19 | var stat = fs.statSync(configDir); 20 | if (stat.isDirectory()) { 21 | // Directory exists. Check for exiting configuration 22 | if (fs.existsSync(this.configFile)) { 23 | this.read(); 24 | } 25 | else { 26 | this.save(); 27 | } 28 | } 29 | else { 30 | console.log(configDir + " is not a directory. Please correct and run again"); 31 | process.exit(-1); 32 | } 33 | } 34 | else { 35 | fs.mkdirSync(configDir); 36 | this.save(); 37 | } 38 | FileCache.singleton = this; 39 | } 40 | /** 41 | * Returns the singleton object of the Options class. 42 | * 43 | * @param {string} baseDir 44 | * @returns {Options} 45 | */ 46 | FileCache.getFileCache = function () { 47 | if (FileCache.singleton == null) 48 | FileCache.singleton = new FileCache(); 49 | return (FileCache.singleton); 50 | }; 51 | /** 52 | * Sets an option value 53 | * 54 | * @param {string} name 55 | * @param value 56 | */ 57 | FileCache.prototype.set = function (name, value) { 58 | this.files[name] = value; 59 | this.save(); 60 | }; 61 | /** 62 | * Gets the value of an option. If **defaultValue** is provided and the option doesn't 63 | * exist, then defaultValue is return. If the option doesn't exist and no defaultValue 64 | * is provided then null is returned. 65 | * 66 | * @param {string} name 67 | * @param defaultValue 68 | * @returns {any} 69 | */ 70 | FileCache.prototype.get = function (name, defaultValue) { 71 | if (defaultValue === void 0) { defaultValue = true; } 72 | if (typeof this.files[name] !== 'undefined') 73 | return this.files[name]; 74 | if (defaultValue) { 75 | return { serverCRC: exports.IGNORE, clientCRC: exports.IGNORE, serverSync: exports.IGNORE, clientSync: exports.IGNORE }; 76 | } 77 | return null; 78 | }; 79 | FileCache.prototype.exists = function (name) { 80 | return (typeof this.files[name] !== 'undefined'); 81 | }; 82 | FileCache.prototype.save = function () { 83 | try { 84 | jsonfile.writeFileSync(this.configFile, this.files, { spaces: 2, EOL: '\r\n' }); 85 | } 86 | catch (err) { 87 | console.log("Could not write FileCache file: " + this.configFile); 88 | console.log('' + err); 89 | process.exit(-1); 90 | } 91 | }; 92 | FileCache.prototype.read = function () { 93 | try { 94 | this.files = jsonfile.readFileSync(this.configFile); 95 | } 96 | catch (err) { 97 | console.log("Could not read FileCache file: " + this.configFile); 98 | console.log('' + err); 99 | process.exit(-1); 100 | } 101 | }; 102 | FileCache.singleton = null; 103 | return FileCache; 104 | }()); 105 | exports.FileCache = FileCache; 106 | //# sourceMappingURL=FileCache.js.map -------------------------------------------------------------------------------- /dist/SyncMode.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Debug_1 = require("./Debug"); 4 | var Sync; 5 | (function (Sync) { 6 | Sync[Sync["PULL"] = 0] = "PULL"; 7 | Sync[Sync["PUSH"] = 1] = "PUSH"; 8 | Sync[Sync["LOCAL"] = 2] = "LOCAL"; 9 | Sync[Sync["INSTANCE"] = 3] = "INSTANCE"; 10 | Sync[Sync["SYNC"] = 4] = "SYNC"; 11 | })(Sync = exports.Sync || (exports.Sync = {})); 12 | /** 13 | * Type of Sync 14 | */ 15 | var SyncMode = /** @class */ (function () { 16 | /** 17 | * Singleton constructor. 18 | * 19 | * @returns {SyncMode} 20 | */ 21 | function SyncMode() { 22 | this._mode = Sync.SYNC; 23 | this._init = false; 24 | this._initMode = Sync.PULL; 25 | this._filesToGet = 0; 26 | this._filesReceived = 0; 27 | this._whenDone = null; 28 | if (SyncMode._singleton !== null) { 29 | return SyncMode._singleton; 30 | } 31 | SyncMode._singleton = this; 32 | } 33 | Object.defineProperty(SyncMode, "singleton", { 34 | get: function () { 35 | return this._singleton; 36 | }, 37 | set: function (value) { 38 | this._singleton = value; 39 | }, 40 | enumerable: true, 41 | configurable: true 42 | }); 43 | Object.defineProperty(SyncMode.prototype, "mode", { 44 | get: function () { 45 | return this._mode; 46 | }, 47 | set: function (value) { 48 | this._mode = value; 49 | }, 50 | enumerable: true, 51 | configurable: true 52 | }); 53 | Object.defineProperty(SyncMode.prototype, "init", { 54 | get: function () { 55 | return this._init; 56 | }, 57 | set: function (value) { 58 | this._init = value; 59 | }, 60 | enumerable: true, 61 | configurable: true 62 | }); 63 | Object.defineProperty(SyncMode.prototype, "initMode", { 64 | get: function () { 65 | return this._initMode; 66 | }, 67 | set: function (value) { 68 | this._initMode = value; 69 | }, 70 | enumerable: true, 71 | configurable: true 72 | }); 73 | Object.defineProperty(SyncMode.prototype, "filesToGet", { 74 | get: function () { 75 | return this._filesToGet; 76 | }, 77 | set: function (value) { 78 | this._filesToGet = value; 79 | }, 80 | enumerable: true, 81 | configurable: true 82 | }); 83 | Object.defineProperty(SyncMode.prototype, "filesReceived", { 84 | get: function () { 85 | return this._filesReceived; 86 | }, 87 | set: function (value) { 88 | this._filesReceived = value; 89 | if (!this.init) { 90 | return; 91 | } 92 | SyncMode.debug.log("FilesReceived: " + this._filesReceived + " out of " + this._filesToGet + " init: " + this.init); 93 | if (this._filesReceived >= this._filesToGet) { 94 | SyncMode.debug.log("Received last file " + value + " looking for " + this._filesToGet); 95 | if (this.whenDone) { 96 | SyncMode.debug.log("Calling WhenDone"); 97 | this.whenDone(); 98 | } 99 | this.init = false; 100 | } 101 | }, 102 | enumerable: true, 103 | configurable: true 104 | }); 105 | Object.defineProperty(SyncMode.prototype, "whenDone", { 106 | get: function () { 107 | return this._whenDone; 108 | }, 109 | set: function (value) { 110 | this._whenDone = value; 111 | }, 112 | enumerable: true, 113 | configurable: true 114 | }); 115 | SyncMode.getSyncMode = function () { 116 | if (SyncMode._singleton === null) { 117 | SyncMode._singleton = new SyncMode(); 118 | } 119 | return SyncMode._singleton; 120 | }; 121 | /** 122 | * 123 | * @param {number} filesToGet 124 | * @param whenDone 125 | */ 126 | SyncMode.prototype.setupPull = function (filesToGet, whenDone) { 127 | this.filesToGet = filesToGet; 128 | this._whenDone = whenDone; 129 | this.mode = Sync.PULL; 130 | }; 131 | SyncMode.debug = new Debug_1.Debug('SyncMode'); 132 | SyncMode._singleton = null; 133 | return SyncMode; 134 | }()); 135 | exports.SyncMode = SyncMode; 136 | //# sourceMappingURL=SyncMode.js.map -------------------------------------------------------------------------------- /dist/Options.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Options.js","sourceRoot":"","sources":["../src/Options.ts"],"names":[],"mappings":";;AAAA,uBAAwB;AACxB,mCAAqC;AACrC,0BAA4B;AAC5B,2BAA6B;AAC7B,oCAAsC;AAEtC;IAoDI,iBAAY,OAAsB,EAAE,IAAoB;QAA5C,wBAAA,EAAA,cAAsB;QAAE,qBAAA,EAAA,YAAoB;QAlDhD,YAAO,GAAQ;YACnB,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE,EAAE;YACZ,YAAY,EAAE,EAAE;YAChB,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,KAAK;YACf,cAAc,EAAE,CAAC;YACjB,eAAe,EAAE,CAAC;YAClB,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,OAAO;YAClB,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,EAAE;YACjB,aAAa,EAAE,EAAE;SACpB,CAAC;QAEM,UAAK,GAAG;YACZ,IAAI,EACA,uEAAuE;YAC3E,QAAQ,EACJ,wEAAwE;YAC5E,IAAI,EACA,wIAAwI;YAC5I,GAAG,EAAE,iCAAiC;YACtC,IAAI,EAAE,iDAAiD;YACvD,QAAQ,EAAE,gEAAgE;YAC1E,KAAK,EACD,8FAA8F;YAClG,cAAc,EACV,kEAAkE;YACtE,eAAe,EACX,yEAAyE;YAC7E,OAAO,EACH,gGAAgG;YACpG,QAAQ,EACJ,yGAAyG;YAC7G,SAAS,EAAE,0GAA0G;YACrH,SAAS,EACL,yOAAyO;SAChP,CAAC;QAEM,eAAU,GAAG,EAAE,CAAC;QAChB,kBAAa,GAAG,EAAE,CAAC;QAuCnB,eAAU,GAAG,EAAE,CAAC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,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAClE,4DAA4D;SAC/D;QACD,GAAG,CAAC,yCAAyC,CAAC,CAAC;QAC/C,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE;YAC3B,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC/B,IAAI,MAAM,KAAK,KAAK,EAAE;gBAClB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;oBACtB,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;iBACnC;aACJ;iBAAM,IAAI,MAAM,IAAI,UAAU,EAAE;gBAC7B,GAAG,GAAG,WAAW,CAAC;aACrB;YACD,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;YACnD,8CAA8C;SACjD;IACL,CAAC;IAED,yBAAO,GAAP;QACI,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,sBAAI,GAAJ,UAAK,MAAc;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IA1Nc,iBAAS,GAAY,IAAI,CAAC;IA2N7C,cAAC;CAAA,AA5ND,IA4NC;AA5NY,0BAAO"} -------------------------------------------------------------------------------- /src/NowApplications.ts: -------------------------------------------------------------------------------- 1 | import Promise = require('bluebird'); 2 | import {Options} from "./Options"; 3 | import _ = require('lodash'); 4 | import {UXsyncNowREST} from "./UXsyncNowREST"; 5 | import {Debug} from "./Debug"; 6 | 7 | export interface ApplicationDef { 8 | id: number, 9 | sys_id: string, 10 | version: string, 11 | short_description: string, 12 | scope: string, 13 | name: string 14 | } 15 | 16 | export class NowApplications { 17 | private debug:Debug = new Debug("NowApplications"); 18 | 19 | get applications(): {name?:ApplicationDef} { 20 | return this._applications; 21 | } 22 | 23 | private _applications:{name?:ApplicationDef} = {}; 24 | private static _singleton: NowApplications = null; 25 | 26 | constructor() { 27 | let options = Options.getOptions(); 28 | this._applications = options.get('applications', {}); 29 | NowApplications._singleton = this; 30 | } 31 | 32 | find(name:string) : ApplicationDef { 33 | return _.find(this._applications, ['name', name]) 34 | } 35 | 36 | findBy(pred:string, value:any) { 37 | //prioritize exact matches 38 | let key = _.find(this._applications, function(app){ 39 | return app[pred].toString().toLowerCase() === value.toString().toLowerCase(); 40 | }); 41 | if(!key){ 42 | key = _.find(this._applications, function(app){ 43 | return app[pred].toString().toLowerCase().indexOf(value.toString().toLowerCase()) > -1; 44 | }); 45 | } 46 | return key; 47 | } 48 | 49 | static getNowApplications(): NowApplications { 50 | if (NowApplications._singleton === null) 51 | new NowApplications(); 52 | return NowApplications._singleton; 53 | } 54 | 55 | refresh(): Promise { 56 | let debug = this.debug; 57 | let self = this; 58 | return new Promise(function (resolve, reject) { 59 | UXsyncNowREST.getUXsyncNowREST().getApplications() 60 | .then((apps:{name:ApplicationDef}) => { 61 | debug.log("Got Refresh response"); 62 | self._applications = _.clone(apps); 63 | let options = Options.getOptions(); 64 | options.set("applications", _.clone(apps)); 65 | options.save(); 66 | resolve(); 67 | }) 68 | .error((err) => reject(err)) 69 | }); 70 | } 71 | /* 72 | refresh(): Promise { 73 | let self = this; 74 | return new Promise(function (resolve, reject) { 75 | 76 | function handleGetApps(data: any) { 77 | 78 | let apps = {}; 79 | 80 | if (data.error) { 81 | console.log("GOT ERROR in retrieving applications"); 82 | if (data.error) console.log("Error: " + data.error); 83 | } 84 | let num = 1; 85 | if (data.body && data.body.result) { 86 | var items = data.body.result; 87 | for (let i in items) { 88 | let item = items[i]; 89 | let sys_id = item['sys_id'] || ''; 90 | let name = item['name']; 91 | let short_description = item['short_description']; 92 | let version = item['version']; 93 | let scope = item['scope']; 94 | console.log("Found scope of " + scope); 95 | apps[name] = { 96 | id: num++, 97 | sys_id: sys_id, 98 | version: version, 99 | short_description: short_description, 100 | scope: scope, 101 | name: name 102 | }; 103 | } 104 | self._applications = apps; 105 | let options = Options.getOptions(); 106 | options.set("applications", apps); 107 | options.save(); 108 | } else { 109 | console.log("Error"); 110 | if (data.error) console.log("Error Message : "); 111 | reject(); 112 | } 113 | resolve(); 114 | } 115 | 116 | let connection = NowConnection.getConnection(); 117 | connection.queryWithCallback('/api/now/table/sys_app', '', handleGetApps); 118 | }); 119 | } 120 | */ 121 | 122 | 123 | asArray(prop?: string): string[] { 124 | let apps = []; 125 | for (let a in this._applications) { 126 | if (prop) 127 | apps.push(this._applications[a][prop]); 128 | else 129 | apps.push(a); 130 | } 131 | return apps; 132 | } 133 | } -------------------------------------------------------------------------------- /dist/NowApplications.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Promise = require("bluebird"); 4 | var Options_1 = require("./Options"); 5 | var _ = require("lodash"); 6 | var UXsyncNowREST_1 = require("./UXsyncNowREST"); 7 | var Debug_1 = require("./Debug"); 8 | var NowApplications = /** @class */ (function () { 9 | function NowApplications() { 10 | this.debug = new Debug_1.Debug("NowApplications"); 11 | this._applications = {}; 12 | var options = Options_1.Options.getOptions(); 13 | this._applications = options.get('applications', {}); 14 | NowApplications._singleton = this; 15 | } 16 | Object.defineProperty(NowApplications.prototype, "applications", { 17 | get: function () { 18 | return this._applications; 19 | }, 20 | enumerable: true, 21 | configurable: true 22 | }); 23 | NowApplications.prototype.find = function (name) { 24 | return _.find(this._applications, ['name', name]); 25 | }; 26 | NowApplications.prototype.findBy = function (pred, value) { 27 | //prioritize exact matches 28 | var key = _.find(this._applications, function (app) { 29 | return app[pred].toString().toLowerCase() === value.toString().toLowerCase(); 30 | }); 31 | if (!key) { 32 | key = _.find(this._applications, function (app) { 33 | return app[pred].toString().toLowerCase().indexOf(value.toString().toLowerCase()) > -1; 34 | }); 35 | } 36 | return key; 37 | }; 38 | NowApplications.getNowApplications = function () { 39 | if (NowApplications._singleton === null) 40 | new NowApplications(); 41 | return NowApplications._singleton; 42 | }; 43 | NowApplications.prototype.refresh = function () { 44 | var debug = this.debug; 45 | var self = this; 46 | return new Promise(function (resolve, reject) { 47 | UXsyncNowREST_1.UXsyncNowREST.getUXsyncNowREST().getApplications() 48 | .then(function (apps) { 49 | debug.log("Got Refresh response"); 50 | self._applications = _.clone(apps); 51 | var options = Options_1.Options.getOptions(); 52 | options.set("applications", _.clone(apps)); 53 | options.save(); 54 | resolve(); 55 | }) 56 | .error(function (err) { return reject(err); }); 57 | }); 58 | }; 59 | /* 60 | refresh(): Promise { 61 | let self = this; 62 | return new Promise(function (resolve, reject) { 63 | 64 | function handleGetApps(data: any) { 65 | 66 | let apps = {}; 67 | 68 | if (data.error) { 69 | console.log("GOT ERROR in retrieving applications"); 70 | if (data.error) console.log("Error: " + data.error); 71 | } 72 | let num = 1; 73 | if (data.body && data.body.result) { 74 | var items = data.body.result; 75 | for (let i in items) { 76 | let item = items[i]; 77 | let sys_id = item['sys_id'] || ''; 78 | let name = item['name']; 79 | let short_description = item['short_description']; 80 | let version = item['version']; 81 | let scope = item['scope']; 82 | console.log("Found scope of " + scope); 83 | apps[name] = { 84 | id: num++, 85 | sys_id: sys_id, 86 | version: version, 87 | short_description: short_description, 88 | scope: scope, 89 | name: name 90 | }; 91 | } 92 | self._applications = apps; 93 | let options = Options.getOptions(); 94 | options.set("applications", apps); 95 | options.save(); 96 | } else { 97 | console.log("Error"); 98 | if (data.error) console.log("Error Message : "); 99 | reject(); 100 | } 101 | resolve(); 102 | } 103 | 104 | let connection = NowConnection.getConnection(); 105 | connection.queryWithCallback('/api/now/table/sys_app', '', handleGetApps); 106 | }); 107 | } 108 | */ 109 | NowApplications.prototype.asArray = function (prop) { 110 | var apps = []; 111 | for (var a in this._applications) { 112 | if (prop) 113 | apps.push(this._applications[a][prop]); 114 | else 115 | apps.push(a); 116 | } 117 | return apps; 118 | }; 119 | NowApplications._singleton = null; 120 | return NowApplications; 121 | }()); 122 | exports.NowApplications = NowApplications; 123 | //# sourceMappingURL=NowApplications.js.map -------------------------------------------------------------------------------- /src/Connection.ts: -------------------------------------------------------------------------------- 1 | import * as unirest from "unirest"; 2 | import {Options} from "./Options"; 3 | import Promise = require('bluebird'); 4 | 5 | let Bottleneck = require('bottleneck'); 6 | 7 | /** 8 | * Class to manage the ServiceNow connections 9 | */ 10 | 11 | export class NowConnection { 12 | private url: string; 13 | private base: unirest.Request; 14 | private basePut: unirest.Request; 15 | 16 | private static singleton: NowConnection = null; 17 | private static _limiter: any = null; 18 | private static _options: Options = null; 19 | 20 | /** 21 | * Gets the singleton instance of NowConnection 22 | * 23 | * @returns {NowConnection} 24 | */ 25 | static getConnection(): NowConnection { 26 | if (NowConnection.singleton === null) 27 | new NowConnection(''); 28 | return NowConnection.singleton; 29 | } 30 | 31 | /** 32 | * Resets the connection. All the communications go through a Bottleneck limiter to ensure 33 | * that the ServiceNow instance doesn't receive too many requests at a time 34 | */ 35 | static resetConnection() { 36 | NowConnection.getConnection(); 37 | let options = NowConnection._options; 38 | let connections = options.get('connection_max',0); 39 | let time = options.get('connection_wait', 0); 40 | if (NowConnection._limiter === null) { 41 | NowConnection._limiter = new Bottleneck(connections,time); 42 | } 43 | 44 | } 45 | 46 | /** 47 | * Creates the NowConnection class. An endPoint must be provided to the ServiceNow instance.. 48 | * 49 | * @param {string} endPoint 50 | */ 51 | constructor(endPoint: string) { 52 | NowConnection.singleton = this; 53 | 54 | if (NowConnection._options === null) 55 | NowConnection._options = Options.getOptions(); 56 | if (NowConnection._limiter === null) 57 | NowConnection.resetConnection(); 58 | let options = NowConnection._options; 59 | this.url = options.get("protocol") + '://' + options.get('host'); 60 | let auth = { 61 | user: options.get('user'), 62 | password: options.get('password'), 63 | sendImmediately: true 64 | }; 65 | 66 | this.base = unirest.get(this.url + endPoint) 67 | .headers({ 68 | 'Accept': 'application/json', 69 | 'User-Agent': 'Unirest Node.js' 70 | }) 71 | .type('json') 72 | // .proxy('http://127.0.0.1:8888') 73 | // .strictSSL(false) 74 | .auth(auth) 75 | .pool({ maxSockets: 5}) 76 | .strictSSL(false); 77 | 78 | this.basePut = unirest.put(this.url + endPoint) 79 | .headers({ 80 | 'Accept': 'application/json', 81 | 'User-Agent': 'Unirest Node.js' 82 | }) 83 | .type('json') 84 | // .proxy('http://127.0.0.1:8888') 85 | // .strictSSL(false) 86 | .auth(auth) 87 | .pool({ maxSockets: 5}) 88 | .strictSSL(false); 89 | 90 | let proxy = options.get('proxy'); 91 | if (proxy != '') { 92 | this.base = this.base.proxy(proxy); 93 | this.basePut = this.basePut.proxy(proxy); 94 | 95 | } 96 | } 97 | 98 | queryp(endPoint: string, qstring: string ): Promise { 99 | let self = this; 100 | return new Promise(function(resolve,reject){ 101 | self.queryWithCallback(endPoint,qstring, (data) =>{ 102 | resolve(data); 103 | }) 104 | }) 105 | } 106 | 107 | queryWithCallback(endPoint: string, qstring: string, callback: any) { 108 | let msg = this.base.url(this.url + endPoint) 109 | .query({"sysparm_query": qstring}); 110 | 111 | NowConnection._limiter.submit(this._send, this.base, this.url + endPoint, qstring, callback) 112 | 113 | 114 | /* 115 | NowConnection._limiter.submit(this.base.url(this.url + endPoint) 116 | .query({"sysparm_query": qstring}) 117 | .end(callback)); 118 | */ 119 | } 120 | 121 | putp(endPoint: string, body:any ): Promise { 122 | let self = this; 123 | return new Promise(function(resolve,reject){ 124 | self.putWithCallback(endPoint,body, (data) =>{ 125 | resolve(data); 126 | }) 127 | }) 128 | } 129 | 130 | putWithCallback(endPoint: string, data: any, callback: any) { 131 | let msg = this.base.url(this.url + endPoint); 132 | 133 | NowConnection._limiter.submit(this._put, this.basePut, this.url + endPoint, data, callback) 134 | 135 | } 136 | 137 | private _send(base: unirest, endPoint: string, qstring: string, callback: any) { 138 | base.url(endPoint) 139 | .query({"sysparm_query": qstring}) 140 | .end(callback); 141 | } 142 | 143 | private _put(base: unirest, endPoint: string, data: any, callback: any) { 144 | base.url(endPoint) 145 | .send(data) 146 | .end(callback); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /dist/Connection.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var unirest = require("unirest"); 4 | var Options_1 = require("./Options"); 5 | var Promise = require("bluebird"); 6 | var Bottleneck = require('bottleneck'); 7 | /** 8 | * Class to manage the ServiceNow connections 9 | */ 10 | var NowConnection = /** @class */ (function () { 11 | /** 12 | * Creates the NowConnection class. An endPoint must be provided to the ServiceNow instance.. 13 | * 14 | * @param {string} endPoint 15 | */ 16 | function NowConnection(endPoint) { 17 | NowConnection.singleton = this; 18 | if (NowConnection._options === null) 19 | NowConnection._options = Options_1.Options.getOptions(); 20 | if (NowConnection._limiter === null) 21 | NowConnection.resetConnection(); 22 | var options = NowConnection._options; 23 | this.url = options.get("protocol") + '://' + options.get('host'); 24 | var auth = { 25 | user: options.get('user'), 26 | password: options.get('password'), 27 | sendImmediately: true 28 | }; 29 | this.base = unirest.get(this.url + endPoint) 30 | .headers({ 31 | 'Accept': 'application/json', 32 | 'User-Agent': 'Unirest Node.js' 33 | }) 34 | .type('json') 35 | // .proxy('http://127.0.0.1:8888') 36 | // .strictSSL(false) 37 | .auth(auth) 38 | .pool({ maxSockets: 5 }) 39 | .strictSSL(false); 40 | this.basePut = unirest.put(this.url + endPoint) 41 | .headers({ 42 | 'Accept': 'application/json', 43 | 'User-Agent': 'Unirest Node.js' 44 | }) 45 | .type('json') 46 | // .proxy('http://127.0.0.1:8888') 47 | // .strictSSL(false) 48 | .auth(auth) 49 | .pool({ maxSockets: 5 }) 50 | .strictSSL(false); 51 | var proxy = options.get('proxy'); 52 | if (proxy != '') { 53 | this.base = this.base.proxy(proxy); 54 | this.basePut = this.basePut.proxy(proxy); 55 | } 56 | } 57 | /** 58 | * Gets the singleton instance of NowConnection 59 | * 60 | * @returns {NowConnection} 61 | */ 62 | NowConnection.getConnection = function () { 63 | if (NowConnection.singleton === null) 64 | new NowConnection(''); 65 | return NowConnection.singleton; 66 | }; 67 | /** 68 | * Resets the connection. All the communications go through a Bottleneck limiter to ensure 69 | * that the ServiceNow instance doesn't receive too many requests at a time 70 | */ 71 | NowConnection.resetConnection = function () { 72 | NowConnection.getConnection(); 73 | var options = NowConnection._options; 74 | var connections = options.get('connection_max', 0); 75 | var time = options.get('connection_wait', 0); 76 | if (NowConnection._limiter === null) { 77 | NowConnection._limiter = new Bottleneck(connections, time); 78 | } 79 | }; 80 | NowConnection.prototype.queryp = function (endPoint, qstring) { 81 | var self = this; 82 | return new Promise(function (resolve, reject) { 83 | self.queryWithCallback(endPoint, qstring, function (data) { 84 | resolve(data); 85 | }); 86 | }); 87 | }; 88 | NowConnection.prototype.queryWithCallback = function (endPoint, qstring, callback) { 89 | var msg = this.base.url(this.url + endPoint) 90 | .query({ "sysparm_query": qstring }); 91 | NowConnection._limiter.submit(this._send, this.base, this.url + endPoint, qstring, callback); 92 | /* 93 | NowConnection._limiter.submit(this.base.url(this.url + endPoint) 94 | .query({"sysparm_query": qstring}) 95 | .end(callback)); 96 | */ 97 | }; 98 | NowConnection.prototype.putp = function (endPoint, body) { 99 | var self = this; 100 | return new Promise(function (resolve, reject) { 101 | self.putWithCallback(endPoint, body, function (data) { 102 | resolve(data); 103 | }); 104 | }); 105 | }; 106 | NowConnection.prototype.putWithCallback = function (endPoint, data, callback) { 107 | var msg = this.base.url(this.url + endPoint); 108 | NowConnection._limiter.submit(this._put, this.basePut, this.url + endPoint, data, callback); 109 | }; 110 | NowConnection.prototype._send = function (base, endPoint, qstring, callback) { 111 | base.url(endPoint) 112 | .query({ "sysparm_query": qstring }) 113 | .end(callback); 114 | }; 115 | NowConnection.prototype._put = function (base, endPoint, data, callback) { 116 | base.url(endPoint) 117 | .send(data) 118 | .end(callback); 119 | }; 120 | NowConnection.singleton = null; 121 | NowConnection._limiter = null; 122 | NowConnection._options = null; 123 | return NowConnection; 124 | }()); 125 | exports.NowConnection = NowConnection; 126 | //# sourceMappingURL=Connection.js.map -------------------------------------------------------------------------------- /dist/AppWatcher.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var SyncMode_1 = require("./SyncMode"); 4 | var Options_1 = require("./Options"); 5 | var Watcher_1 = require("./Watcher"); 6 | var NowFiles_1 = require("./NowFiles"); 7 | var UXsyncNowREST_1 = require("./UXsyncNowREST"); 8 | var NowFile_1 = require("./NowFile"); 9 | var lodash_1 = require("lodash"); 10 | var Notify_1 = require("./Notify"); 11 | var Debug_1 = require("./Debug"); 12 | var AppWatcher = /** @class */ (function () { 13 | /** 14 | * Sets up an Application Watcher for the specified application. 15 | * 16 | * If *pullOnly* is not specified, then the application will setup 17 | * a file watcher to watch all the files synced. Also a timer 18 | * will be created to check for any application file changes on the 19 | * instance. 20 | * 21 | * @param {string} app 22 | * @param {string} appName 23 | * @param {IAppWatcher} options 24 | */ 25 | function AppWatcher(app, appName, options, whenDone) { 26 | var _this = this; 27 | this.app = app; 28 | this.appName = appName; 29 | this.debug = new Debug_1.Debug('AppWatcher'); 30 | this.options = new Options_1.Options(); 31 | this.tables = this.options.get('tables', {}); 32 | this.watcher = null; 33 | this.watch = false; 34 | this.api = UXsyncNowREST_1.UXsyncNowREST.getUXsyncNowREST(); 35 | this.pull = SyncMode_1.SyncMode.getSyncMode(); 36 | this.pull.init = true; 37 | if (typeof options.sync !== 'undefined') { 38 | this.pull.initMode = options.sync; 39 | } 40 | else { 41 | this.pull.initMode = SyncMode_1.Sync.SYNC; 42 | } 43 | this.debug.log("App: " + app + " name: " + appName + " sync: " + this.pull.initMode); 44 | this.watch = options.pullOnly ? false : true; 45 | // If this is not a pull only run, then setup the interval pull from instance 46 | // and the file watcher 47 | if (this.watch) { 48 | this.debug.log('Setting up watch'); 49 | var ms_1 = options.interval ? options.interval : 30000; 50 | this.pull.whenDone = function () { 51 | _this.debug.log('Got all the files'); 52 | // When the initial pull is done, setup the timer to pull 53 | // from the instance 54 | Notify_1.Notify.showMessage = true; 55 | _this.interval = setInterval(function () { return _this.pullFromInstance(); }, ms_1); 56 | if (whenDone) { 57 | _this.debug.log("Calling WhenDone"); 58 | whenDone(); 59 | } 60 | }; 61 | this.watcher = Watcher_1.Watcher.getWatcher(); 62 | var files_1 = new NowFiles_1.NowFiles(); 63 | this.watcher.onChange = function (file) { 64 | var f = files_1.find(file); 65 | if (f) { 66 | f.processLocalFile(); 67 | f.processInstance("local"); 68 | } 69 | }; 70 | } 71 | else { 72 | this.pull.whenDone = function () { 73 | _this.debug.log("The initial pull is done"); 74 | if (whenDone) { 75 | _this.debug.log("Calling WhenDone"); 76 | whenDone(); 77 | } 78 | }; 79 | } 80 | this.pullFromInstance(); 81 | } 82 | AppWatcher.prototype.close = function () { 83 | if (this.watch) { 84 | this.watcher.close(); 85 | } 86 | }; 87 | /** 88 | * Pull application files from the instance. 89 | */ 90 | AppWatcher.prototype.pullFromInstance = function () { 91 | var _this = this; 92 | this.debug.log('Pull from instance', 2); 93 | this.api.getApplicationFiles(this.tables, this.app, this.now) 94 | .then(function (result) { 95 | _this.now = parseInt(result.now, 10); 96 | if (_this.pull.init) { 97 | _this.pull.filesToGet += result.files.length; 98 | } 99 | lodash_1.forEach(result.files, function (file) { 100 | if (file.fields) { 101 | var files = new NowFiles_1.NowFiles(); 102 | if (_this.pull.init) { 103 | _this.pull.filesToGet += file.fields.length - 1; // Handle if there are more than 1 field in a record 104 | } 105 | for (var i = 0; i < file.fields.length; i++) { 106 | var fld = file.fields[i]; 107 | var fldcrc = parseInt(file.crc[i], 10); 108 | // new NowFile(appName, file.table, file.sys_id, file.name, fld, parseInt(fldcrc, 10),parseInt(result.now)); 109 | // console.log('Got file ' + fld) 110 | var f = files.find({ 111 | recordID: file.sys_id, 112 | tableName: file.table, 113 | fieldName: fld 114 | }); 115 | if (f) { 116 | //console.log("Found one in cache"); 117 | f.processLocalFile(); 118 | f.crc = fldcrc; 119 | f.processInstance("instance"); 120 | } 121 | else { 122 | // New file on instance 123 | var f_1 = new NowFile_1.NowFile(_this.appName, file.table, file.sys_id, file.name, fld, fldcrc, _this.now); 124 | if (_this.watch) { 125 | f_1.watch(); 126 | } 127 | } 128 | } 129 | } 130 | }); 131 | }); 132 | }; 133 | AppWatcher.prototype.destroy = function () { 134 | if (this.watcher) { 135 | this.watcher.close(); 136 | } 137 | if (this.interval) { 138 | clearInterval(this.interval); 139 | } 140 | }; 141 | return AppWatcher; 142 | }()); 143 | exports.AppWatcher = AppWatcher; 144 | //# sourceMappingURL=AppWatcher.js.map -------------------------------------------------------------------------------- /src/AppWatcher.ts: -------------------------------------------------------------------------------- 1 | import {Sync, SyncMode} from "./SyncMode"; 2 | import {Options} from "./Options"; 3 | import {Watcher} from "./Watcher"; 4 | import {NowFiles} from "./NowFiles"; 5 | import {UXsyncNowREST} from "./UXsyncNowREST"; 6 | import {NowFile} from "./NowFile"; 7 | import {forEach} from 'lodash'; 8 | import {Notify} from "./Notify"; 9 | import {Debug} from "./Debug"; 10 | 11 | /** 12 | * IAppWatcher 13 | * 14 | * *sync* -- Sync type 15 | * *interval* -- Interval in ms to check the instance for changes 16 | * *pullOnly* -- If set, then only pull and sync changes with the Instance and don't watch for changes 17 | */ 18 | export interface IAppWatcher { 19 | sync?: Sync; 20 | interval?: number; 21 | pullOnly?: boolean; 22 | } 23 | 24 | export class AppWatcher { 25 | private debug = new Debug('AppWatcher'); 26 | private interval: any; 27 | private options = new Options(); 28 | private tables = this.options.get( 'tables', {} ); 29 | private watcher: Watcher = null; 30 | private watch = false; 31 | private api = UXsyncNowREST.getUXsyncNowREST(); 32 | private now: number; 33 | private pull: SyncMode; 34 | 35 | /** 36 | * Sets up an Application Watcher for the specified application. 37 | * 38 | * If *pullOnly* is not specified, then the application will setup 39 | * a file watcher to watch all the files synced. Also a timer 40 | * will be created to check for any application file changes on the 41 | * instance. 42 | * 43 | * @param {string} app 44 | * @param {string} appName 45 | * @param {IAppWatcher} options 46 | */ 47 | constructor(private app: string, private appName: string, options: IAppWatcher, whenDone?: any) { 48 | this.pull = SyncMode.getSyncMode(); 49 | this.pull.init = true; 50 | if (typeof options.sync !== 'undefined') { 51 | this.pull.initMode = options.sync; 52 | } else { 53 | this.pull.initMode = Sync.SYNC; 54 | } 55 | 56 | this.debug.log(`App: ${app} name: ${appName} sync: ${this.pull.initMode}`); 57 | this.watch = options.pullOnly ? false : true; 58 | 59 | // If this is not a pull only run, then setup the interval pull from instance 60 | // and the file watcher 61 | if (this.watch) { 62 | this.debug.log('Setting up watch'); 63 | const ms = options.interval ? options.interval : 30000; 64 | this.pull.whenDone = () => { 65 | this.debug.log('Got all the files'); 66 | // When the initial pull is done, setup the timer to pull 67 | // from the instance 68 | Notify.showMessage = true; 69 | this.interval = setInterval(() => this.pullFromInstance(), ms); 70 | if (whenDone) { 71 | this.debug.log("Calling WhenDone"); 72 | whenDone(); 73 | } 74 | }; 75 | this.watcher = Watcher.getWatcher(); 76 | let files = new NowFiles(); 77 | this.watcher.onChange = file => { 78 | let f = files.find(file); 79 | if (f) { 80 | f.processLocalFile(); 81 | f.processInstance("local"); 82 | } 83 | }; 84 | } else { 85 | this.pull.whenDone = () => { 86 | this.debug.log("The initial pull is done"); 87 | if (whenDone) { 88 | this.debug.log("Calling WhenDone"); 89 | whenDone(); 90 | } 91 | }; 92 | } 93 | this.pullFromInstance(); 94 | } 95 | 96 | close() { 97 | if (this.watch) { 98 | this.watcher.close(); 99 | } 100 | } 101 | /** 102 | * Pull application files from the instance. 103 | */ 104 | private pullFromInstance() { 105 | this.debug.log('Pull from instance',2); 106 | this.api.getApplicationFiles(this.tables, this.app, this.now) 107 | .then(result => { 108 | this.now = parseInt(result.now, 10); 109 | 110 | if (this.pull.init) { 111 | this.pull.filesToGet += result.files.length; 112 | } 113 | 114 | forEach(result.files, file => { 115 | if (file.fields) { 116 | let files = new NowFiles(); 117 | 118 | if (this.pull.init) { 119 | this.pull.filesToGet += file.fields.length - 1; // Handle if there are more than 1 field in a record 120 | } 121 | 122 | for (let i = 0; i < file.fields.length; i++) { 123 | let fld = file.fields[i]; 124 | let fldcrc = parseInt(file.crc[i], 10); 125 | // new NowFile(appName, file.table, file.sys_id, file.name, fld, parseInt(fldcrc, 10),parseInt(result.now)); 126 | // console.log('Got file ' + fld) 127 | let f = files.find({ 128 | recordID: file.sys_id, 129 | tableName: file.table, 130 | fieldName: fld 131 | }); 132 | if (f) { 133 | //console.log("Found one in cache"); 134 | f.processLocalFile(); 135 | f.crc = fldcrc; 136 | f.processInstance("instance"); 137 | } else { 138 | // New file on instance 139 | let f = new NowFile( 140 | this.appName, 141 | file.table, 142 | file.sys_id, 143 | file.name, 144 | fld, 145 | fldcrc, 146 | this.now 147 | ); 148 | if (this.watch) { 149 | f.watch(); 150 | } 151 | 152 | } 153 | } 154 | } 155 | }); 156 | }); 157 | } 158 | 159 | destroy() { 160 | if (this.watcher) { 161 | this.watcher.close(); 162 | } 163 | if (this.interval) { 164 | clearInterval(this.interval); 165 | } 166 | } 167 | } -------------------------------------------------------------------------------- /src/Options.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs" 2 | import * as jsonfile from "jsonfile"; 3 | import * as _ from "lodash"; 4 | import * as path from "path"; 5 | import * as CryptoJS from "crypto-js"; 6 | 7 | export class Options { 8 | private static singleton: Options = null; 9 | private options: any = { 10 | host: "", 11 | protocol: "https", 12 | port: 0, 13 | user: "", 14 | password: "", 15 | applications: [], 16 | app: "", 17 | app_sys_id: "", 18 | proxy: "", 19 | interval: 30000, 20 | connection_max: 0, 21 | connection_wait: 0, 22 | multifile: "record", 23 | table_dir: "label", 24 | top_dir: "", 25 | table_ignore: [], 26 | table_error: [], 27 | file_override: [], 28 | table_display: {} 29 | }; 30 | 31 | private _help = { 32 | host: 33 | "Hostname of the ServiceNow Instance. Example dev2000.service-now.com", 34 | protocol: 35 | "HTTP protocol to use. It is either HTTPS or HTTP. Defaults to HTTPS", 36 | port: 37 | "If the instance is not on the standard HTTP/HTTPS port, specify the port with this option. a Value of 0 means to use the default port", 38 | app: "Name of the application to sync", 39 | user: "User name to connect to the ServiceNow Instance", 40 | password: "The ServiceNow user password to use to connect to the Instance", 41 | proxy: 42 | "If your connection requires the use of an HTTP proxy, set this value to your required proxy.", 43 | connection_max: 44 | "Maximum amount of connections to your instance. 0 is unlimited.", 45 | connection_wait: 46 | "Time in milliseconds to wait between each connection to your instance. ", 47 | top_dir: 48 | "The top directory where all the applications that are synced will be stored in the filesystem.", 49 | interval: 50 | "The interval in ms between checking the instance for any file changes. Default is 30000 or 30 seconds.", 51 | table_dir: "If the table directory should be the label or name (db name). Default is label. Set to label or name.", 52 | multifile: 53 | "How to handle records with multiple files. flat for the flat method. record to have all files under a directory with the record name. field to have a directory per field name and the files in that directory with the record name." 54 | }; 55 | 56 | private configFile = ""; 57 | private configFileDir = ""; 58 | 59 | constructor(baseDir: string = "./", type: string = "dev") { 60 | if (Options.singleton !== null) { 61 | return Options.singleton; 62 | } 63 | 64 | // const configDir = baseDir; 65 | this.configFileDir = baseDir; 66 | const configFile = `uxsyncnow-config-${type}.json`; 67 | this._configDir = path.normalize(baseDir + path.sep + `.uxsyncnow-${type}`); 68 | 69 | this.configFile = path.normalize(this.configFileDir + "/" + configFile); 70 | if (fs.existsSync(this.configFileDir)) { 71 | let stat = fs.statSync(this.configFileDir); 72 | if (stat.isDirectory()) { 73 | // Directory exists. Check for exiting configuration 74 | if (fs.existsSync(this.configFile)) { 75 | this.read(); 76 | } else { 77 | //console.log("Creating config file with defaults"); 78 | this.save(); 79 | } 80 | } else { 81 | console.log( 82 | this.configFileDir + 83 | " is not a directory. Please correct and run again" 84 | ); 85 | process.exit(-1); 86 | } 87 | } else { 88 | //console.log("Creating config file with defaults"); 89 | fs.mkdirSync(this.configFileDir); 90 | this.save(); 91 | } 92 | 93 | Options.singleton = this; 94 | } 95 | 96 | private _configDir = ""; 97 | 98 | get configDir(): string { 99 | return this._configDir; 100 | } 101 | 102 | /** 103 | * Returns the singleton object of the Options class. 104 | * 105 | * @param {string} baseDir 106 | * @returns {Options} 107 | */ 108 | static getOptions(baseDir: string = "./"): Options { 109 | if (Options.singleton == null) Options.singleton = new Options(baseDir); 110 | return Options.singleton; 111 | } 112 | 113 | /** 114 | * Sets an option value 115 | * 116 | * password is encrypted 117 | * interval can not be set to a value < 1000ms 118 | * 119 | * @param {string} name 120 | * @param value 121 | */ 122 | 123 | set(name: string, value: any) { 124 | let v = value; 125 | switch (name) { 126 | case "password" : 127 | // Handle encryption of password 128 | v = CryptoJS.AES.encrypt(value, '1N33dUX5t0rm!').toString(); 129 | break; 130 | case "interval" : 131 | try { 132 | let i = parseInt(value); 133 | if (i < 1000) { 134 | v = "1000"; 135 | } 136 | } catch (e) {} 137 | break; 138 | } 139 | this.options[name] = v; 140 | } 141 | 142 | /** 143 | * Gets the value of an option. If **defaultValue** is provided and the option doesn't 144 | * exist, then defaultValue is return. If the option doesn't exist and no defaultValue 145 | * is provided then null is returned. 146 | * 147 | * password is decrypted before passing back. 148 | * 149 | * @param {string} name 150 | * @param defaultValue 151 | * @returns {any} 152 | */ 153 | 154 | get(name: string, defaultValue?: any): any { 155 | if (typeof this.options[name] !== "undefined") { 156 | let v = this.options[name]; 157 | switch (name) { 158 | case "password" : 159 | let bytes = CryptoJS.AES.decrypt(v, '1N33dUX5t0rm!'); 160 | v = bytes.toString(CryptoJS.enc.Utf8); 161 | break; 162 | } 163 | return v; 164 | } 165 | if (typeof defaultValue === "undefined") return null; 166 | return defaultValue; 167 | } 168 | 169 | save() { 170 | try { 171 | jsonfile.writeFileSync(this.configFile, this.options, { 172 | spaces: 2, 173 | 'flag': 'w', 174 | EOL: "\r\n" 175 | }); 176 | } catch (err) { 177 | console.log("Could not write config file: " + this.configFile); 178 | console.log("" + err); 179 | process.exit(-1); 180 | } 181 | } 182 | 183 | read() { 184 | try { 185 | console.log("Reading config file: " + this.configFile); 186 | this.options = jsonfile.readFileSync(this.configFile); 187 | } catch (err) { 188 | console.log("Could not read config file: " + this.configFile); 189 | console.log("" + err); 190 | process.exit(-1); 191 | } 192 | } 193 | 194 | show(log?: any) { 195 | const optionCols = 16; 196 | 197 | if (!log) log = console.log; 198 | 199 | for (let option in this._help) { 200 | log(_.padEnd(option, optionCols, " ") + " " + this._help[option]); 201 | // log(`${option} --- ${this._help[option]}`); 202 | } 203 | log("-------------------------------------\n"); 204 | for (let option in this._help) { 205 | let val = this.options[option]; 206 | if (option === "app") { 207 | if (this.options[option]) { 208 | val = this.options[option].name; 209 | } 210 | } else if (option == "password") { 211 | val = "*********"; 212 | } 213 | log(_.padEnd(option, optionCols, " ") + " " + val); 214 | // log(`${option} : ${this.options[option]}`); 215 | } 216 | } 217 | 218 | asArray(): string[] { 219 | let list = []; 220 | for (let option in this._help) list.push(option); 221 | return list; 222 | } 223 | 224 | help(option: string): string { 225 | return this._help[option] || ""; 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /dist/UXsyncNowREST.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"UXsyncNowREST.js","sourceRoot":"","sources":["../src/UXsyncNowREST.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAC3C,qCAAkC;AAClC,0BAA6B;AAC7B,kCAAqC;AAGrC,iCAA8B;AAE9B,IAAM,QAAQ,GAAG,uBAAuB,CAAC;AAoCzC;IA+FI;QA9FQ,gBAAW,GAAkB,IAAI,CAAC;QAClC,aAAQ,GAAY,IAAI,CAAC;QACzB,eAAU,GAAY,KAAK,CAAC;QAC5B,kBAAa,GAAW,EAAE,CAAC;QAG3B,UAAK,GAAG,IAAI,aAAK,CAAC,eAAe,CAAC,CAAC;QAyFvC,IAAI,CAAC,QAAQ,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,0BAAa,CAAC,aAAa,EAAE,CAAC;Q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AAC,OAAO,CAAC,CAAC,CAAC;oBAC9B,OAAO;iBACV;gBACD,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;gBACtC,MAAM,EAAE,CAAC;YACb,CAAC,CAAC,CAAC;QAEX,CAAC,CAAC,CAAC;IACP,CAAC;IAnSc,wBAAU,GAAkB,IAAI,CAAC;IAoSpD,oBAAC;CAAA,AAzSD,IAySC;AAzSY,sCAAa"} -------------------------------------------------------------------------------- /dist/Options.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var fs = require("fs"); 4 | var jsonfile = require("jsonfile"); 5 | var _ = require("lodash"); 6 | var path = require("path"); 7 | var CryptoJS = require("crypto-js"); 8 | var Options = /** @class */ (function () { 9 | function Options(baseDir, type) { 10 | if (baseDir === void 0) { baseDir = "./"; } 11 | if (type === void 0) { type = "dev"; } 12 | this.options = { 13 | host: "", 14 | protocol: "https", 15 | port: 0, 16 | user: "", 17 | password: "", 18 | applications: [], 19 | app: "", 20 | app_sys_id: "", 21 | proxy: "", 22 | interval: 30000, 23 | connection_max: 0, 24 | connection_wait: 0, 25 | multifile: "record", 26 | table_dir: "label", 27 | top_dir: "", 28 | table_ignore: [], 29 | table_error: [], 30 | file_override: [], 31 | table_display: {} 32 | }; 33 | this._help = { 34 | host: "Hostname of the ServiceNow Instance. Example dev2000.service-now.com", 35 | protocol: "HTTP protocol to use. It is either HTTPS or HTTP. Defaults to HTTPS", 36 | port: "If the instance is not on the standard HTTP/HTTPS port, specify the port with this option. a Value of 0 means to use the default port", 37 | app: "Name of the application to sync", 38 | user: "User name to connect to the ServiceNow Instance", 39 | password: "The ServiceNow user password to use to connect to the Instance", 40 | proxy: "If your connection requires the use of an HTTP proxy, set this value to your required proxy.", 41 | connection_max: "Maximum amount of connections to your instance. 0 is unlimited.", 42 | connection_wait: "Time in milliseconds to wait between each connection to your instance. ", 43 | top_dir: "The top directory where all the applications that are synced will be stored in the filesystem.", 44 | interval: "The interval in ms between checking the instance for any file changes. Default is 30000 or 30 seconds.", 45 | table_dir: "If the table directory should be the label or name (db name). Default is label. Set to label or name.", 46 | multifile: "How to handle records with multiple files. flat for the flat method. record to have all files under a directory with the record name. field to have a directory per field name and the files in that directory with the record name." 47 | }; 48 | this.configFile = ""; 49 | this.configFileDir = ""; 50 | this._configDir = ""; 51 | if (Options.singleton !== null) { 52 | return Options.singleton; 53 | } 54 | // const configDir = baseDir; 55 | this.configFileDir = baseDir; 56 | var configFile = "uxsyncnow-config-" + type + ".json"; 57 | this._configDir = path.normalize(baseDir + path.sep + (".uxsyncnow-" + type)); 58 | this.configFile = path.normalize(this.configFileDir + "/" + configFile); 59 | if (fs.existsSync(this.configFileDir)) { 60 | var stat = fs.statSync(this.configFileDir); 61 | if (stat.isDirectory()) { 62 | // Directory exists. Check for exiting configuration 63 | if (fs.existsSync(this.configFile)) { 64 | this.read(); 65 | } 66 | else { 67 | //console.log("Creating config file with defaults"); 68 | this.save(); 69 | } 70 | } 71 | else { 72 | console.log(this.configFileDir + 73 | " is not a directory. Please correct and run again"); 74 | process.exit(-1); 75 | } 76 | } 77 | else { 78 | //console.log("Creating config file with defaults"); 79 | fs.mkdirSync(this.configFileDir); 80 | this.save(); 81 | } 82 | Options.singleton = this; 83 | } 84 | Object.defineProperty(Options.prototype, "configDir", { 85 | get: function () { 86 | return this._configDir; 87 | }, 88 | enumerable: true, 89 | configurable: true 90 | }); 91 | /** 92 | * Returns the singleton object of the Options class. 93 | * 94 | * @param {string} baseDir 95 | * @returns {Options} 96 | */ 97 | Options.getOptions = function (baseDir) { 98 | if (baseDir === void 0) { baseDir = "./"; } 99 | if (Options.singleton == null) 100 | Options.singleton = new Options(baseDir); 101 | return Options.singleton; 102 | }; 103 | /** 104 | * Sets an option value 105 | * 106 | * password is encrypted 107 | * interval can not be set to a value < 1000ms 108 | * 109 | * @param {string} name 110 | * @param value 111 | */ 112 | Options.prototype.set = function (name, value) { 113 | var v = value; 114 | switch (name) { 115 | case "password": 116 | // Handle encryption of password 117 | v = CryptoJS.AES.encrypt(value, '1N33dUX5t0rm!').toString(); 118 | break; 119 | case "interval": 120 | try { 121 | var i = parseInt(value); 122 | if (i < 1000) { 123 | v = "1000"; 124 | } 125 | } 126 | catch (e) { } 127 | break; 128 | } 129 | this.options[name] = v; 130 | }; 131 | /** 132 | * Gets the value of an option. If **defaultValue** is provided and the option doesn't 133 | * exist, then defaultValue is return. If the option doesn't exist and no defaultValue 134 | * is provided then null is returned. 135 | * 136 | * password is decrypted before passing back. 137 | * 138 | * @param {string} name 139 | * @param defaultValue 140 | * @returns {any} 141 | */ 142 | Options.prototype.get = function (name, defaultValue) { 143 | if (typeof this.options[name] !== "undefined") { 144 | var v = this.options[name]; 145 | switch (name) { 146 | case "password": 147 | var bytes = CryptoJS.AES.decrypt(v, '1N33dUX5t0rm!'); 148 | v = bytes.toString(CryptoJS.enc.Utf8); 149 | break; 150 | } 151 | return v; 152 | } 153 | if (typeof defaultValue === "undefined") 154 | return null; 155 | return defaultValue; 156 | }; 157 | Options.prototype.save = function () { 158 | try { 159 | jsonfile.writeFileSync(this.configFile, this.options, { 160 | spaces: 2, 161 | 'flag': 'w', 162 | EOL: "\r\n" 163 | }); 164 | } 165 | catch (err) { 166 | console.log("Could not write config file: " + this.configFile); 167 | console.log("" + err); 168 | process.exit(-1); 169 | } 170 | }; 171 | Options.prototype.read = function () { 172 | try { 173 | console.log("Reading config file: " + this.configFile); 174 | this.options = jsonfile.readFileSync(this.configFile); 175 | } 176 | catch (err) { 177 | console.log("Could not read config file: " + this.configFile); 178 | console.log("" + err); 179 | process.exit(-1); 180 | } 181 | }; 182 | Options.prototype.show = function (log) { 183 | var optionCols = 16; 184 | if (!log) 185 | log = console.log; 186 | for (var option in this._help) { 187 | log(_.padEnd(option, optionCols, " ") + " " + this._help[option]); 188 | // log(`${option} --- ${this._help[option]}`); 189 | } 190 | log("-------------------------------------\n"); 191 | for (var option in this._help) { 192 | var val = this.options[option]; 193 | if (option === "app") { 194 | if (this.options[option]) { 195 | val = this.options[option].name; 196 | } 197 | } 198 | else if (option == "password") { 199 | val = "*********"; 200 | } 201 | log(_.padEnd(option, optionCols, " ") + " " + val); 202 | // log(`${option} : ${this.options[option]}`); 203 | } 204 | }; 205 | Options.prototype.asArray = function () { 206 | var list = []; 207 | for (var option in this._help) 208 | list.push(option); 209 | return list; 210 | }; 211 | Options.prototype.help = function (option) { 212 | return this._help[option] || ""; 213 | }; 214 | Options.singleton = null; 215 | return Options; 216 | }()); 217 | exports.Options = Options; 218 | //# sourceMappingURL=Options.js.map -------------------------------------------------------------------------------- /localTypes/vorpal.d.ts: -------------------------------------------------------------------------------- 1 | export = vorpal; 2 | 3 | declare class vorpal { 4 | constructor(); 5 | 6 | CmdHistoryExtension(): void; 7 | 8 | catch(name: any, desc: any, opts: any): any; 9 | 10 | command(name: any, desc: any, opts: any): any; 11 | 12 | default(name: any, desc: any, opts: any): any; 13 | 14 | delimiter(str: any): any; 15 | 16 | exec(cmd: any, args: any, cb: any): any; 17 | 18 | execSync(cmd: any, options: any): any; 19 | 20 | exit(options: any): void; 21 | 22 | find(name: any): any; 23 | 24 | getSessionById(id: any): any; 25 | 26 | help(fn: any): void; 27 | 28 | hide(): any; 29 | 30 | history(id: any): any; 31 | 32 | historyStoragePath(path: any): any; 33 | 34 | hook(fn: any): any; 35 | 36 | localStorage(id: any): any; 37 | 38 | log(...args: any[]): any; 39 | 40 | mode(name: any, desc: any, opts: any): any; 41 | 42 | parse(argv: any, options: any): any; 43 | 44 | pipe(fn: any): any; 45 | 46 | prompt(...args: any[]): any; 47 | 48 | show(): any; 49 | 50 | sigint(fn: any): any; 51 | 52 | use(commands: any, options: any): any; 53 | 54 | version(version: any): any; 55 | 56 | } 57 | 58 | declare namespace vorpal { 59 | namespace prototype { 60 | class CmdHistoryExtension { 61 | constructor(); 62 | 63 | clear(): void; 64 | 65 | enterMode(): void; 66 | 67 | exitMode(): void; 68 | 69 | getNextHistory(): any; 70 | 71 | getPreviousHistory(): any; 72 | 73 | newCommand(cmd: any): void; 74 | 75 | peek(depth: any): any; 76 | 77 | setId(id: any): void; 78 | 79 | setStoragePath(path: any): void; 80 | 81 | } 82 | 83 | const activeCommand: any; 84 | 85 | const domain: any; 86 | 87 | function addListener(type: any, listener: any): any; 88 | 89 | function command(name: any, desc: any, opts: any): any; 90 | 91 | function delimiter(str: any): any; 92 | 93 | function emit(type: any, ...args: any[]): any; 94 | 95 | function eventNames(): any; 96 | 97 | function exec(cmd: any, args: any, cb: any): any; 98 | 99 | function execSync(cmd: any, options: any): any; 100 | 101 | function exit(options: any): void; 102 | 103 | function find(name: any): any; 104 | 105 | function getMaxListeners(): any; 106 | 107 | function getSessionById(id: any): any; 108 | 109 | function help(fn: any): void; 110 | 111 | function hide(): any; 112 | 113 | function history(id: any): any; 114 | 115 | function historyStoragePath(path: any): any; 116 | 117 | function hook(fn: any): any; 118 | 119 | function listenerCount(type: any): any; 120 | 121 | function listeners(type: any): any; 122 | 123 | function localStorage(id: any): any; 124 | 125 | function log(...args: any[]): any; 126 | 127 | function mode(name: any, desc: any, opts: any): any; 128 | 129 | function on(type: any, listener: any): any; 130 | 131 | function once(type: any, listener: any): any; 132 | 133 | function parse(argv: any, options: any): any; 134 | 135 | function pipe(fn: any): any; 136 | 137 | function prependListener(type: any, listener: any): any; 138 | 139 | function prependOnceListener(type: any, listener: any): any; 140 | 141 | function prompt(...args: any[]): any; 142 | 143 | function removeAllListeners(type: any, ...args: any[]): any; 144 | 145 | function removeListener(type: any, listener: any): any; 146 | 147 | function setMaxListeners(n: any): any; 148 | 149 | function show(): any; 150 | 151 | function sigint(fn: any): any; 152 | 153 | function use(commands: any, options: any): any; 154 | 155 | function version(version: any): any; 156 | 157 | namespace CmdHistoryExtension { 158 | namespace prototype { 159 | function clear(): void; 160 | 161 | function enterMode(): void; 162 | 163 | function exitMode(): void; 164 | 165 | function getNextHistory(): any; 166 | 167 | function getPreviousHistory(): any; 168 | 169 | function newCommand(cmd: any): void; 170 | 171 | function peek(depth: any): any; 172 | 173 | function setId(id: any): void; 174 | 175 | function setStoragePath(path: any): void; 176 | 177 | namespace clear { 178 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.clear 179 | const prototype: any; 180 | 181 | } 182 | 183 | namespace enterMode { 184 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.enterMode 185 | const prototype: any; 186 | 187 | } 188 | 189 | namespace exitMode { 190 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.exitMode 191 | const prototype: any; 192 | 193 | } 194 | 195 | namespace getNextHistory { 196 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.getNextHistory 197 | const prototype: any; 198 | 199 | } 200 | 201 | namespace getPreviousHistory { 202 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.getPreviousHistory 203 | const prototype: any; 204 | 205 | } 206 | 207 | namespace newCommand { 208 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.newCommand 209 | const prototype: any; 210 | 211 | } 212 | 213 | namespace peek { 214 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.peek 215 | const prototype: any; 216 | 217 | } 218 | 219 | namespace setId { 220 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.setId 221 | const prototype: any; 222 | 223 | } 224 | 225 | namespace setStoragePath { 226 | // Too-deep object hierarchy from vorpal.prototype.CmdHistoryExtension.prototype.setStoragePath 227 | const prototype: any; 228 | 229 | } 230 | 231 | } 232 | 233 | } 234 | 235 | namespace addListener { 236 | const prototype: { 237 | }; 238 | 239 | } 240 | 241 | namespace command { 242 | const prototype: { 243 | }; 244 | 245 | } 246 | 247 | namespace delimiter { 248 | const prototype: { 249 | }; 250 | 251 | } 252 | 253 | namespace emit { 254 | const prototype: { 255 | }; 256 | 257 | } 258 | 259 | namespace eventNames { 260 | const prototype: { 261 | }; 262 | 263 | } 264 | 265 | namespace exec { 266 | const prototype: { 267 | }; 268 | 269 | } 270 | 271 | namespace execSync { 272 | const prototype: { 273 | }; 274 | 275 | } 276 | 277 | namespace exit { 278 | const prototype: { 279 | }; 280 | 281 | } 282 | 283 | namespace find { 284 | const prototype: { 285 | }; 286 | 287 | } 288 | 289 | namespace getMaxListeners { 290 | const prototype: { 291 | }; 292 | 293 | } 294 | 295 | namespace getSessionById { 296 | const prototype: { 297 | }; 298 | 299 | } 300 | 301 | namespace help { 302 | const prototype: { 303 | }; 304 | 305 | } 306 | 307 | namespace hide { 308 | const prototype: { 309 | }; 310 | 311 | } 312 | 313 | namespace history { 314 | const prototype: { 315 | }; 316 | 317 | } 318 | 319 | namespace historyStoragePath { 320 | const prototype: { 321 | }; 322 | 323 | } 324 | 325 | namespace hook { 326 | const prototype: { 327 | }; 328 | 329 | } 330 | 331 | namespace listenerCount { 332 | const prototype: { 333 | }; 334 | 335 | } 336 | 337 | namespace listeners { 338 | const prototype: { 339 | }; 340 | 341 | } 342 | 343 | namespace localStorage { 344 | const prototype: { 345 | }; 346 | 347 | } 348 | 349 | namespace log { 350 | const prototype: { 351 | }; 352 | 353 | } 354 | 355 | namespace mode { 356 | const prototype: { 357 | }; 358 | 359 | } 360 | 361 | namespace on { 362 | const prototype: { 363 | }; 364 | 365 | } 366 | 367 | namespace once { 368 | const prototype: { 369 | }; 370 | 371 | } 372 | 373 | namespace parse { 374 | const prototype: { 375 | }; 376 | 377 | } 378 | 379 | namespace pipe { 380 | const prototype: { 381 | }; 382 | 383 | } 384 | 385 | namespace prependListener { 386 | const prototype: { 387 | }; 388 | 389 | } 390 | 391 | namespace prependOnceListener { 392 | const prototype: { 393 | }; 394 | 395 | } 396 | 397 | namespace prompt { 398 | const prototype: { 399 | }; 400 | 401 | } 402 | 403 | namespace removeAllListeners { 404 | const prototype: { 405 | }; 406 | 407 | } 408 | 409 | namespace removeListener { 410 | const prototype: { 411 | }; 412 | 413 | } 414 | 415 | namespace setMaxListeners { 416 | const prototype: { 417 | }; 418 | 419 | } 420 | 421 | namespace show { 422 | const prototype: { 423 | }; 424 | 425 | } 426 | 427 | namespace sigint { 428 | const prototype: { 429 | }; 430 | 431 | } 432 | 433 | namespace use { 434 | const prototype: { 435 | }; 436 | 437 | } 438 | 439 | namespace version { 440 | const prototype: { 441 | }; 442 | 443 | } 444 | 445 | } 446 | 447 | } 448 | 449 | 450 | -------------------------------------------------------------------------------- /dist/NowFile.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"NowFile.js","sourceRoot":"","sources":["../src/NowFile.ts"],"names":[],"mappings":";;AAAA,yCAA8C;AAC9C,qCAAkC;AAClC,qCAAkC;AAClC,uCAA0C;AAC1C,uBAAyB;AACzB,mCAAgC;AAChC,iDAA8C;AAC9C,2BAA6B;AAE7B,uCAAoC;AACpC,iCAA2B;AAC3B,+BAAiC;AACjC,iCAA8B;AAC9B,uCAAqC;AAErC,IAAM,UAAU,GAAG;IACf,aAAa,EAAE,MAAM;IACrB,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,MAAM;IACZ,eAAe,EAAE,MAAM;IACvB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,IAAI;IACnB,GAAG,EAAE,KAAK;CACb,CAAC;AAEF;IASI,iBACY,gBAAwB,EACxB,UAAkB,EAClB,SAAiB,EACjB,WAAmB,EACnB,UAAkB,EAC1B,WAAoB,EACpB,GAAY;QAEZ,iBAAiB;QACjB,kFAAkF;QAClF,qFAAqF;QACrF,2EAA2E;QAXnE,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,eAAU,GAAV,UAAU,CAAQ;QAClB,cAAS,GAAT,SAAS,CAAQ;QACjB,gBAAW,GAAX,WAAW,CAAQ;QACnB,eAAU,GAAV,UAAU,CAAQ;QAZtB,aAAQ,GAAG,CAAC,CAAC;QACb,gBAAW,GAAG,KAAK,CAAC;QACpB,kBAA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AI,GAAG,UAAU,CAAC;QAEtB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YACpC,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI;gBACA,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;SAC5E;QACD,OAAO,IAAI,KAAK,CAAC,CAAC;IACtB,CAAC;IAEO,yBAAO,GAAf,UAAgB,GAAW;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IAEK,6BAAW,GAAnB;QACI,qGAAqG;IACzG,CAAC;IAEO,4BAAU,GAAlB,UAAmB,GAAW;QAC1B,IAAI,CAAC,aAAa,IAAI,GAAG,CAAC;QAC1B,IAAI,IAAI,CAAC,aAAa,GAAG,CAAC,EAAE;YACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAC3B;IACL,CAAC;IAlgBc,aAAK,GAAG,IAAI,aAAK,CAAC,SAAS,CAAC,CAAC;IAmgBhD,cAAC;CAAA,AApgBD,IAogBC;AApgBY,0BAAO"} -------------------------------------------------------------------------------- /dist/uxsyncnow.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"uxsyncnow.js","sourceRoot":"","sources":["../src/uxsyncnow.ts"],"names":[],"mappings":";;AAAA,qCAAkC;AAClC,qDAAkD;AAClD,kCAAoC;AACpC,iDAAuF;AACvF,yCAAsC;AACtC,iCAA8B;AAC9B,yCAAsC;AACtC,2CAAwC;AACxC,uCAAgC;AAChC,mCAAqC;AACrC,uCAAoC;AACpC,qCAAkC;AAClC,2BAA6B;AAC7B,u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,CAAC;YACf,CAAC,CAAC,CAAC;YAEP,MAAM;iBACD,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC;iBAC/C,MAAM,CAAC,UAAU,IAAI,EAAE,QAAQ;gBAC5B,IAAI,KAAK,GAAG,aAAK,CAAC,KAAK,CAAC;gBACxB,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9C,QAAQ,EAAE,CAAC;YACf,CAAC,CAAC,CAAC;YAEP,MAAM;iBACD,SAAS,CAAC,aAAa,CAAC;iBACxB,IAAI,EAAE,CAAC;SACf;IACL,CAAC,CAAC,CAAC;CACV"} -------------------------------------------------------------------------------- /dist/UXsyncNowREST.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var Connection_1 = require("./Connection"); 4 | var Options_1 = require("./Options"); 5 | var _ = require("lodash"); 6 | var Promise = require("bluebird"); 7 | var Debug_1 = require("./Debug"); 8 | var ENDPOINT = "/api/global/uxsyncnow"; 9 | var UXsyncNowREST = /** @class */ (function () { 10 | function UXsyncNowREST() { 11 | this._connection = null; 12 | this._options = null; 13 | this._connected = false; 14 | this._errorMessage = ""; 15 | this.debug = new Debug_1.Debug("UXsyncNowREST"); 16 | this._options = Options_1.Options.getOptions(); 17 | this._connection = Connection_1.NowConnection.getConnection(); 18 | UXsyncNowREST._singleton = this; 19 | } 20 | Object.defineProperty(UXsyncNowREST.prototype, "connected", { 21 | get: function () { 22 | return this._connected; 23 | }, 24 | enumerable: true, 25 | configurable: true 26 | }); 27 | Object.defineProperty(UXsyncNowREST.prototype, "errorMessage", { 28 | get: function () { 29 | return this._errorMessage; 30 | }, 31 | enumerable: true, 32 | configurable: true 33 | }); 34 | UXsyncNowREST.getUXsyncNowREST = function () { 35 | if (UXsyncNowREST._singleton === null) 36 | new UXsyncNowREST(); 37 | return UXsyncNowREST._singleton; 38 | }; 39 | UXsyncNowREST.prototype.init = function () { 40 | var _this = this; 41 | var debug = this.debug; 42 | return (new Promise(function (resolve) { 43 | var valid = true; 44 | var message = []; 45 | var self = _this; 46 | _.each(['host', 'protocol', 'user', 'password'], function (name) { 47 | if (_this._options.get(name, '') === '') { 48 | valid = false; 49 | message.push(name + " is not defined"); 50 | } 51 | }); 52 | if (valid) { 53 | // Ok have enough for the valid connection 54 | _this._connection = new Connection_1.NowConnection(ENDPOINT); 55 | // Now check the API. 56 | _this._connection.queryp(ENDPOINT + "/checkUser", "") 57 | .then(function (data) { 58 | var body = (data.body); 59 | if (body) { 60 | if (typeof body["error"] !== 'undefined') { 61 | // Got an error object 62 | _this._errorMessage = body.error.message; 63 | _this._connected = false; 64 | if (_this._errorMessage.indexOf("User Not Authenticated") >= 0) { 65 | _this._errorMessage = 'Either the username or password is incorrect'; 66 | } 67 | if (_this._errorMessage.indexOf("Requested URI does not represent any resource:") >= 0) { 68 | _this._errorMessage = "Instance does not contain UXsyncNow REST services. Is the UXsyncNow Application installed on the instance?\nYou can download the UpdateSet from https://share.servicenow.com/app.do#/detailV2/c0076b7fdb4157401afe13141b9619f0/overview"; 69 | } 70 | // todo: Check for other errors 71 | resolve(); 72 | return; 73 | } 74 | if (body.result) { 75 | var ret = body.result; 76 | if (ret.result === 'ERROR') { 77 | _this._connected = false; 78 | _this._errorMessage = ret.message; 79 | } 80 | else { 81 | _this._connected = (ret.result === "SUCCESS"); 82 | _this._errorMessage = ret.errorMessage; 83 | } 84 | } 85 | else { 86 | _this._connected = false; 87 | _this._errorMessage = "Instance returned no result information"; 88 | } 89 | } 90 | else { 91 | _this._connected = false; 92 | _this._errorMessage = "Instance returned no information"; 93 | } 94 | resolve(); 95 | return; 96 | }) 97 | .error(function (reason) { 98 | // console.log("Error received " + reason); 99 | // console.log(reason); 100 | _this._connected = false; 101 | _this._errorMessage = reason; 102 | resolve(); 103 | return; 104 | }); 105 | } 106 | else { 107 | _this._connected = false; 108 | _this._errorMessage = message.join('\n'); 109 | resolve(); 110 | } 111 | })); 112 | }; 113 | UXsyncNowREST.prototype.getApplications = function () { 114 | var _this = this; 115 | var debug = this.debug; 116 | return new Promise(function (resolve, reject) { 117 | debug.log("Getting Applications"); 118 | if (!_this._connected) { 119 | debug.log("Not connected"); 120 | reject(); 121 | } 122 | var connection = Connection_1.NowConnection.getConnection(); 123 | connection.queryp(ENDPOINT + "/getApplications", '') 124 | .then(function (data) { 125 | var apps = {}; 126 | debug.log("Got applications response"); 127 | if (data.error) { 128 | console.log("GOT ERROR in retrieving applications"); 129 | if (data.error) 130 | console.log("Error: " + data.error); 131 | reject(); 132 | return; 133 | } 134 | var num = 1; 135 | if (data.body && data.body.result) { 136 | var items = data.body.result; 137 | for (var i in items) { 138 | var item = items[i]; 139 | var sys_id = item['sys_id'] || ''; 140 | var name_1 = item['name']; 141 | var short_description = item['short_description']; 142 | var version = item['version']; 143 | var scope = item['scope']; 144 | apps[name_1] = { 145 | id: num++, 146 | sys_id: sys_id, 147 | version: version, 148 | short_description: short_description, 149 | scope: scope, 150 | name: name_1 151 | }; 152 | } 153 | debug.log("Got " + num + " applications"); 154 | } 155 | resolve(apps); 156 | }); 157 | }); 158 | }; 159 | UXsyncNowREST.prototype.saveFile = function (table, sys_id, field, content) { 160 | var _this = this; 161 | var debug = this.debug; 162 | return new Promise(function (resolve, reject) { 163 | if (!_this._connected) { 164 | debug.log("Not connected"); 165 | reject(); 166 | } 167 | var body = { 168 | table: table, 169 | sys_id: sys_id, 170 | field: field, 171 | content: content 172 | }; 173 | var connection = Connection_1.NowConnection.getConnection(); 174 | debug.log("Calling Save File " + table + " , " + sys_id + " + " + field); 175 | connection.putp(ENDPOINT + "/saveFile", body) 176 | .then(function (data) { 177 | if (data.error) { 178 | console.log("GOT ERROR in retrieving applications"); 179 | if (data.error) 180 | console.log("Error: " + data.error); 181 | reject(); 182 | return; 183 | } 184 | if (data.body && data.body.result) { 185 | resolve(_.clone(data.body.result)); 186 | } 187 | else 188 | reject(); 189 | }); 190 | }); 191 | }; 192 | UXsyncNowREST.prototype.getTables = function () { 193 | var _this = this; 194 | return new Promise(function (resolve, reject) { 195 | if (!_this._connected) 196 | reject(); 197 | var connection = Connection_1.NowConnection.getConnection(); 198 | connection.queryp(ENDPOINT + "/getTables", '') 199 | .then(function (data) { 200 | var tables = {}; 201 | if (data.error) { 202 | console.log("GOT ERROR in retrieving tables"); 203 | if (data.error) 204 | console.log("Error: " + data.error); 205 | reject(); 206 | } 207 | if (data.body && data.body.result) { 208 | resolve(_.cloneDeep(data.body.result)); 209 | return; 210 | } 211 | console.log("Error no body returned"); 212 | reject(); 213 | }); 214 | }); 215 | }; 216 | UXsyncNowREST.prototype.getApplicationFiles = function (tables, app, since) { 217 | var _this = this; 218 | return new Promise(function (resolve, reject) { 219 | if (!_this._connected) 220 | reject(); 221 | var body = { 222 | tables: tables, 223 | application: app, 224 | since: '' 225 | }; 226 | if (since) 227 | body.since = since + ''; 228 | var connection = Connection_1.NowConnection.getConnection(); 229 | connection.putp(ENDPOINT + "/getApplicationFiles", body) 230 | .then(function (data) { 231 | if (data.error) { 232 | console.log("GOT ERROR in retrieving changed files"); 233 | if (data.error) 234 | console.log("Error: " + data.error); 235 | reject(); 236 | } 237 | if (data.body && data.body.result) { 238 | var ret = { 239 | now: '', 240 | files: [] 241 | }; 242 | var files = []; 243 | var results = data.body.result; 244 | var cfiles = results.files; 245 | if (typeof results.now !== 'undefined') 246 | ret.now = results.now; 247 | for (var i = 0; i < cfiles.length; i++) { 248 | var f = cfiles[i]; 249 | files.push({ 250 | table: f[0], 251 | sys_id: f[1], 252 | name: f[2], 253 | lastChanged: f[3], 254 | owner: f[4], 255 | fields: _.clone(f[5]), 256 | crc: _.clone(f[6]) 257 | }); 258 | } 259 | ret.files = files; 260 | resolve(ret); 261 | return; 262 | } 263 | console.log("Error no body returned"); 264 | reject(); 265 | }); 266 | }); 267 | }; 268 | UXsyncNowREST.prototype.getFile = function (table, sys_id, fields) { 269 | var _this = this; 270 | return new Promise(function (resolve, reject) { 271 | if (!_this._connected) 272 | reject(' not connected '); 273 | var flds = typeof fields === 'string' ? [fields] : fields; 274 | var body = { 275 | table: table, 276 | sys_id: sys_id, 277 | fields: flds 278 | }; 279 | _this.debug.log('GET FILE ' + table + +' ' + fields); 280 | var connection = Connection_1.NowConnection.getConnection(); 281 | connection.putp(ENDPOINT + "/getFile", body) 282 | .then(function (data) { 283 | if (data.error) { 284 | console.log("GOT ERROR in retrieving file"); 285 | if (data.error) 286 | console.log("Error: " + data.error); 287 | reject(); 288 | return; 289 | } 290 | if (data.body && data.body.result) { 291 | var results = data.body.result; 292 | var cfiles = results.files; 293 | if (typeof cfiles === 'undefined') { 294 | resolve({}); 295 | return; 296 | } 297 | resolve(_.cloneDeep(results)); 298 | return; 299 | } 300 | console.log("Error no body returned"); 301 | reject(); 302 | }); 303 | }); 304 | }; 305 | UXsyncNowREST._singleton = null; 306 | return UXsyncNowREST; 307 | }()); 308 | exports.UXsyncNowREST = UXsyncNowREST; 309 | //# sourceMappingURL=UXsyncNowREST.js.map -------------------------------------------------------------------------------- /src/UXsyncNowREST.ts: -------------------------------------------------------------------------------- 1 | import {NowConnection} from "./Connection"; 2 | import {Options} from "./Options"; 3 | import _ = require('lodash'); 4 | import Promise = require('bluebird'); 5 | import {ApplicationDef} from "./NowApplications"; 6 | import {ITableDef} from "./NowTables"; 7 | import {Debug} from "./Debug"; 8 | 9 | const ENDPOINT = "/api/global/uxsyncnow"; 10 | export interface IRestFieldDef { 11 | name: string, 12 | table: string, 13 | label: string, 14 | type: string, 15 | scope: string, 16 | scope_id: string 17 | } 18 | 19 | export interface IRESTTableDef { 20 | key:string, 21 | name: string, 22 | fields: IRestFieldDef[] 23 | } 24 | 25 | export interface IRESTable { 26 | [name:string] : IRESTTableDef 27 | } 28 | 29 | export interface IRESTTableResult { 30 | tables : IRESTable, 31 | tables_unmapped : IRESTable, 32 | tables_non_application : IRESTable 33 | } 34 | 35 | export interface IRESTFile { 36 | table:string, 37 | sys_id:string, 38 | name:string, 39 | lastChanged:string, 40 | owner:string, 41 | fields:string[], 42 | crc:string[] 43 | } 44 | 45 | export class UXsyncNowREST { 46 | private _connection: NowConnection = null; 47 | private _options: Options = null; 48 | private _connected: boolean = false; 49 | private _errorMessage: string = ""; 50 | private static _singleton: UXsyncNowREST = null; 51 | 52 | private debug = new Debug("UXsyncNowREST"); 53 | 54 | get connected(): boolean { 55 | return this._connected; 56 | } 57 | 58 | get errorMessage(): string { 59 | return this._errorMessage; 60 | } 61 | 62 | static getUXsyncNowREST(): UXsyncNowREST { 63 | if (UXsyncNowREST._singleton === null) 64 | new UXsyncNowREST(); 65 | return UXsyncNowREST._singleton; 66 | } 67 | 68 | init(): Promise { 69 | let debug = this.debug; 70 | return ( new Promise((resolve) => { 71 | let valid = true; 72 | let message = []; 73 | let self = this; 74 | _.each(['host', 'protocol', 'user', 'password'], (name) => { 75 | if (this._options.get(name, '') === '') { 76 | valid = false; 77 | message.push(`${name} is not defined`); 78 | } 79 | }); 80 | if (valid) { 81 | // Ok have enough for the valid connection 82 | this._connection = new NowConnection(ENDPOINT); 83 | 84 | // Now check the API. 85 | this._connection.queryp(ENDPOINT + "/checkUser", "") 86 | .then((data: any) => { 87 | let body = (data.body); 88 | if (body) { 89 | if (typeof body["error"] !== 'undefined') { 90 | // Got an error object 91 | this._errorMessage = body.error.message; 92 | this._connected = false; 93 | 94 | if (this._errorMessage.indexOf("User Not Authenticated") >= 0) { 95 | this._errorMessage = 'Either the username or password is incorrect'; 96 | } 97 | if (this._errorMessage.indexOf("Requested URI does not represent any resource:") >= 0) { 98 | this._errorMessage = "Instance does not contain UXsyncNow REST services. Is the UXsyncNow Application installed on the instance?\nYou can download the UpdateSet from https://share.servicenow.com/app.do#/detailV2/c0076b7fdb4157401afe13141b9619f0/overview"; 99 | } 100 | // todo: Check for other errors 101 | resolve(); 102 | return; 103 | } 104 | if (body.result) { 105 | let ret = body.result; 106 | if (ret.result === 'ERROR') { 107 | this._connected = false; 108 | this._errorMessage = ret.message; 109 | } else { 110 | this._connected = (ret.result === "SUCCESS"); 111 | this._errorMessage = ret.errorMessage; 112 | } 113 | } else { 114 | this._connected = false; 115 | this._errorMessage = "Instance returned no result information"; 116 | } 117 | } else { 118 | this._connected = false; 119 | this._errorMessage = "Instance returned no information"; 120 | } 121 | resolve(); 122 | return; 123 | }) 124 | .error((reason) => { 125 | // console.log("Error received " + reason); 126 | // console.log(reason); 127 | this._connected = false; 128 | this._errorMessage = reason; 129 | resolve(); 130 | return; 131 | }); 132 | } else { 133 | this._connected = false; 134 | this._errorMessage = message.join('\n'); 135 | resolve(); 136 | } 137 | })); 138 | } 139 | 140 | constructor() { 141 | this._options = Options.getOptions(); 142 | this._connection = NowConnection.getConnection(); 143 | UXsyncNowREST._singleton = this; 144 | } 145 | 146 | getApplications(): Promise<{ [name:string] : ApplicationDef }> { 147 | let debug = this.debug; 148 | return new Promise((resolve, reject) => { 149 | debug.log("Getting Applications"); 150 | if (!this._connected) { 151 | debug.log("Not connected"); 152 | reject(); 153 | } 154 | 155 | let connection = NowConnection.getConnection(); 156 | connection.queryp(ENDPOINT + "/getApplications", '') 157 | .then(function (data: any) { 158 | let apps: { [name:string] : ApplicationDef } = {}; 159 | 160 | debug.log("Got applications response"); 161 | if (data.error) { 162 | console.log("GOT ERROR in retrieving applications"); 163 | if (data.error) console.log("Error: " + data.error); 164 | reject(); 165 | return; 166 | } 167 | let num = 1; 168 | if (data.body && data.body.result) { 169 | var items = data.body.result; 170 | for (let i in items) { 171 | let item = items[i]; 172 | let sys_id = item['sys_id'] || ''; 173 | let name = item['name']; 174 | let short_description = item['short_description']; 175 | let version = item['version']; 176 | let scope = item['scope']; 177 | apps[name] = { 178 | id: num++, 179 | sys_id: sys_id, 180 | version: version, 181 | short_description: short_description, 182 | scope: scope, 183 | name: name 184 | }; 185 | } 186 | debug.log(`Got ${num} applications`) 187 | } 188 | resolve(apps); 189 | }); 190 | }); 191 | } 192 | 193 | saveFile(table: string, sys_id: string, field: string, content: string): Promise { 194 | let debug = this.debug; 195 | 196 | return new Promise((resolve, reject) => { 197 | if (!this._connected) { 198 | debug.log("Not connected"); 199 | reject(); 200 | } 201 | let body = { 202 | table : table, 203 | sys_id : sys_id, 204 | field: field, 205 | content: content 206 | }; 207 | let connection = NowConnection.getConnection(); 208 | debug.log(`Calling Save File ${table} , ${sys_id} + ${field}`); 209 | 210 | connection.putp(ENDPOINT + "/saveFile", body) 211 | .then(function (data: any) { 212 | 213 | if (data.error) { 214 | console.log("GOT ERROR in retrieving applications"); 215 | if (data.error) console.log("Error: " + data.error); 216 | reject(); 217 | return; 218 | } 219 | if (data.body && data.body.result) { 220 | resolve(_.clone(data.body.result)); 221 | } else reject(); 222 | }); 223 | }); 224 | } 225 | 226 | getTables(): Promise { 227 | return new Promise((resolve, reject) => { 228 | if (!this._connected) reject(); 229 | 230 | let connection = NowConnection.getConnection(); 231 | connection.queryp(ENDPOINT + "/getTables", '') 232 | .then(function (data: any) { 233 | let tables = {}; 234 | if (data.error) { 235 | console.log("GOT ERROR in retrieving tables"); 236 | if (data.error) console.log("Error: " + data.error); 237 | reject(); 238 | } 239 | if (data.body && data.body.result) { 240 | resolve (_.cloneDeep(data.body.result)); 241 | return; 242 | } 243 | console.log("Error no body returned"); 244 | reject(); 245 | 246 | }); 247 | }); 248 | } 249 | 250 | getApplicationFiles(tables:any,app:string,since?:number):Promise { 251 | return new Promise((resolve, reject) => { 252 | if (!this._connected) reject(); 253 | 254 | let body = { 255 | tables : tables, 256 | application: app, 257 | since : '' 258 | }; 259 | if (since) body.since = since + ''; 260 | 261 | let connection = NowConnection.getConnection(); 262 | connection.putp(ENDPOINT + "/getApplicationFiles", body) 263 | .then(function (data: any) { 264 | 265 | if (data.error) { 266 | console.log("GOT ERROR in retrieving changed files"); 267 | if (data.error) console.log("Error: " + data.error); 268 | reject(); 269 | } 270 | if (data.body && data.body.result) { 271 | let ret:IRESTApplicationFiles = { 272 | now: '', 273 | files: [] 274 | }; 275 | let files:IRESTFile[] = []; 276 | let results= data.body.result; 277 | let cfiles= results.files; 278 | if (typeof results.now !== 'undefined') 279 | ret.now = results.now; 280 | 281 | for (let i=0; i { 305 | return new Promise((resolve, reject) => { 306 | if (!this._connected) reject( ' not connected '); 307 | 308 | let flds = typeof fields === 'string' ? [fields] : fields; 309 | let body = { 310 | table : table, 311 | sys_id : sys_id, 312 | fields: flds 313 | }; 314 | this.debug.log('GET FILE ' + table + + ' ' + fields ) 315 | let connection = NowConnection.getConnection(); 316 | connection.putp(ENDPOINT + "/getFile", body) 317 | .then(function (data: any) { 318 | 319 | if (data.error) { 320 | console.log("GOT ERROR in retrieving file"); 321 | if (data.error) console.log("Error: " + data.error); 322 | reject(); 323 | return; 324 | } 325 | if (data.body && data.body.result) { 326 | let results= data.body.result; 327 | let cfiles= results.files; 328 | if (typeof cfiles === 'undefined') { 329 | resolve({}); 330 | return; 331 | } 332 | 333 | resolve(_.cloneDeep(results)); 334 | return; 335 | } 336 | console.log("Error no body returned"); 337 | reject(); 338 | }); 339 | 340 | }); 341 | } 342 | } 343 | export interface IRESTApplicationFiles { 344 | now:string, 345 | files:IRESTFile[] 346 | } 347 | 348 | export interface IRESTFile { 349 | table:string, 350 | sys_id:string, 351 | name:string, 352 | lastChanged:string, 353 | owner:string, 354 | fields:string[] 355 | } -------------------------------------------------------------------------------- /global/Script Include/UXsyncNow.js: -------------------------------------------------------------------------------- 1 | var UXsyncNow = Class.create(); 2 | UXsyncNow.prototype = { 3 | initialize: function () { 4 | this.ignoreFields = ['sys_updated_on']; 5 | }, 6 | getApplications: function () { 7 | var gr = new GlideRecord('sys_app'); 8 | var tables = []; 9 | 10 | gr.query(); 11 | while (gr.next()) { 12 | tables.push({ 13 | name: gr.name + "", 14 | active: gr.active, 15 | scope: gr.scope + "", 16 | sys_id: gr.sys_id + "", 17 | short_description: gr.short_description + "", 18 | version: gr.version + "" 19 | }) 20 | } 21 | return tables; 22 | }, 23 | getTables: getTables = function () { 24 | function inTables(tableHash, name) { 25 | for (var table in tableHash) if (table === name) return true; 26 | return false; 27 | } 28 | 29 | function hasScope(table) { 30 | var gr = new GlideRecord(table); 31 | gr.initialize(); 32 | var fields = gr.getFields(); 33 | for (var i = 0; i < fields.size(); i++) { 34 | var glideElement = fields.get(i); 35 | if (glideElement.getName() === 'sys_scope') return true; 36 | } 37 | return false; 38 | } 39 | 40 | function hasName(table) { 41 | var gr = new GlideRecord(table); 42 | gr.initialize(); 43 | var fields = gr.getFields(); 44 | for (var i = 0; i < fields.size(); i++) { 45 | var glideElement = fields.get(i); 46 | if (glideElement.getName() === 'name') return true; 47 | } 48 | return false; 49 | } 50 | 51 | //var ignoreTables=['sys_dictionary','sys_ui_policy', 'sys_security_acl']; 52 | var ignoreTables = ['sys_dictionary']; 53 | var ignoreFields = { 54 | 'sys_script' : ['message'] 55 | }; 56 | var tables = {}; 57 | var unmappedTables = {}; 58 | var nonApplicationTables = {}; 59 | var gr = new GlideRecord('sys_dictionary'); 60 | gr.addEncodedQuery("internal_type=html_template" + 61 | "^ORinternal_type=html_script" + 62 | "^ORinternal_type=html" + 63 | "^ORinternal_type=translated_html" + 64 | "^ORinternal_type=css" + 65 | "^ORinternal_type=json" + 66 | "^ORinternal_type=script" + 67 | "^ORinternal_type=script_plain" + 68 | "^ORinternal_type=script_server" + 69 | "^ORinternal_type=xml"); 70 | gr.query(); 71 | var numOfFields = 0; 72 | while (gr.next()) { 73 | numOfFields++; 74 | var field = { 75 | name: gr.element + "", 76 | table: gr.name + "", 77 | label: gr.column_label + "", 78 | type: gr.internal_type + "", 79 | scope: gr.sys_scope.getDisplayValue(), 80 | scope_id: gr.sys_scope + "" 81 | }; 82 | if (ignoreFields[field.table] !== undefined) { 83 | var ifields = ignoreFields[field.table]; 84 | var ifound = false; 85 | for (var j=0; j=', d); 175 | } 176 | gr.query(); 177 | while (gr.next()) { 178 | var nonBlankFields = []; 179 | var crc = []; 180 | for (var i = 0; i < fields.length; i++) { 181 | // if (gr[fields[i].name].getDisplayValue() != '') { 182 | if (!this.isBlank(gr[fields[i].name].getDisplayValue(), fields[i].type)) { 183 | // have content 184 | nonBlankFields.push(fields[i].name); 185 | crc.push(this.crc(gr[fields[i].name].getDisplayValue())); 186 | } 187 | } 188 | if (nonBlankFields.length > 0) 189 | files.push([table + "", gr.sys_id + '', gr.getDisplayValue(), gr.sys_updated_on, gr.sys_updated_by, nonBlankFields, crc]); 190 | } 191 | } 192 | return files; 193 | }, 194 | getBlankTemplates: function (type) { 195 | if (type === 'script' || type === 'script_plain' || type === 'script_server') { 196 | return [ 197 | "function onCondition() {\n" + 198 | "\n" + 199 | "}", 200 | // For business rules 201 | "(function executeRule(current, previous /*null when async*/) {\n" + 202 | "\n" + 203 | "\t// Add your code here\n" + 204 | "\n" + 205 | "})(current, previous);" 206 | ] 207 | } 208 | return []; 209 | }, 210 | isBlank: function (value, type) { 211 | // Check for fields with blank values so we know they have no data in them. 212 | // Some fields have data but are "blank" templates. We should ignore them too 213 | 214 | if (value === "") return true; 215 | var blanks = this.getBlankTemplates(type); 216 | for (var i = 0; i < blanks.length; i++) 217 | if (blanks[i] === value) { 218 | return true; 219 | } 220 | return false; 221 | }, 222 | validUserDetail: function () { 223 | var result = "SUCCESS"; 224 | var message = ""; 225 | var user = gs.getUser(); 226 | var roles = user.getRoles().toArray(); 227 | var admin = false; 228 | var uxsyncnow_user = false; 229 | var userName = user.getFullName() + ""; 230 | for (var i = 0; i < roles.length; i++) { 231 | if (roles[i] + "" === "admin") admin = true; 232 | if (roles[i] + "" === "uxsyncnow_user") uxsyncnow_user = true; 233 | } 234 | 235 | if (!admin) { 236 | result = "ERROR"; 237 | message += " does not have role : admin\n"; 238 | } 239 | 240 | if (!uxsyncnow_user) { 241 | result = "ERROR"; 242 | message += " does not have role : uxsyncnow_user\n" + gs.getUserDisplayName() + " Current roles : " + roles.join(','); 243 | } 244 | 245 | if (result === "SUCCESS") { 246 | message = "User is properly configured"; 247 | } 248 | 249 | if (result === "ERROR") { 250 | message = "User " + userName + "\n" + message; 251 | } 252 | 253 | var ret = {result: result, message: message}; 254 | return ret; 255 | }, 256 | validUser: function () { 257 | return (this.validUserDetail().result === 'SUCCESS'); 258 | }, 259 | getFile: function (table, sys_id, fields) { 260 | var files = {}; 261 | var gr = new GlideRecord(table); 262 | gr.get(sys_id); 263 | if (!gr) 264 | return ({status: "ERROR", error_message: "Could not find record " + table + ":" + sys_id}); 265 | 266 | for (var i = 0; i < fields.length; i++) { 267 | field = fields[i]; 268 | files[field] = gr.getValue(field); 269 | } 270 | var now = new GlideDateTime(); 271 | return ({ 272 | status: "SUCCESS", 273 | files: files, 274 | last: gr.sys_updated_on.getDisplayValue(), 275 | now: now.getNumericValue() 276 | }); 277 | }, 278 | /** 279 | * 280 | * Javascript crc32 281 | * http://www.webtoolkit.info/ 282 | * 283 | **/ 284 | crcOld: function (str) { 285 | function Utf8Encode(string) { 286 | string = string.replace(/\r\n/g, "\n"); 287 | var utftext = ""; 288 | for (var n = 0; n < string.length; n++) { 289 | var c = string.charCodeAt(n); 290 | if (c < 128) { 291 | utftext += String.fromCharCode(c); 292 | } 293 | else if ((c > 127) && (c < 2048)) { 294 | utftext += String.fromCharCode((c >> 6) | 192); 295 | utftext += String.fromCharCode((c & 63) | 128); 296 | } 297 | else { 298 | utftext += String.fromCharCode((c >> 12) | 224); 299 | utftext += String.fromCharCode(((c >> 6) & 63) | 128); 300 | utftext += String.fromCharCode((c & 63) | 128); 301 | } 302 | } 303 | return utftext; 304 | } 305 | 306 | str = Utf8Encode(str); 307 | var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"; 308 | var crc = 0; 309 | var x = 0; 310 | var y = 0; 311 | crc = crc ^ (-1); 312 | for (var i = 0, iTop = str.length; i < iTop; i++) { 313 | y = (crc ^ str.charCodeAt(i)) & 0xFF; 314 | x = parseInt(table.substr(y * 9, 8), 16); 315 | 316 | crc = (crc >>> 8) ^ x; 317 | } 318 | return crc ^ (-1); 319 | }, 320 | crc: function (str) { 321 | /*jshint bitwise:false */ 322 | var i, l, 323 | hval = 0x811c9dc5; 324 | 325 | for (i = 0, l = str.length; i < l; i++) { 326 | hval ^= str.charCodeAt(i); 327 | hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24); 328 | } 329 | return hval >>> 0; 330 | }, 331 | saveApplicationFile: function (table, sys_id, field, content) { 332 | var gr = new GlideRecord(table); 333 | if (gr.get(sys_id)) { 334 | gr[field] = content; 335 | gr.update(); 336 | return this.crc(content); 337 | } else { 338 | // Cant find record. Return error as we don't create records 339 | return null; 340 | } 341 | }, 342 | 343 | getApplicationExtendedTables: function () { 344 | var table = new TableUtils('sys_metadata'); 345 | var ret = table.getTableExtensions(); 346 | var size = ret.size(); 347 | 348 | var tbls = []; 349 | 350 | for (var i = 0; i < size; i++) { tbls.push(ret.get(i) + '') } 351 | 352 | this.tables = tbls; 353 | 354 | return tbls; 355 | }, 356 | getRecordCRC: function (gr) { 357 | var flds = {}; 358 | var str = ''; 359 | var fields = gr.getFields(); 360 | var crc32 = new UXCRC32(); 361 | for (var i = 0; i < fields.size(); i++) { 362 | var glideElement = fields.get(i); 363 | if (glideElement.hasValue()) { 364 | flds[glideElement.getName()] = crc32.computeString(glideElement + ''); 365 | str += glideElement.getName() + ':' + glideElement; 366 | } 367 | } 368 | var record = {record: crc32.computeString(str), fields: flds}; 369 | return record; 370 | }, 371 | getAppRecords: function (application) { 372 | var appGr = new GlideRecord('sys_app'); 373 | var version = 'unknown'; 374 | if (appGr.get(application)) { 375 | version = appGr.version + ''; 376 | } 377 | var records = []; 378 | for (var i = 0; i < this.tables.length; i++) { 379 | var table = this.tables[i]; 380 | var gr = new GlideRecord(table); 381 | gr.addQuery('sys_scope', '=', application); 382 | gr.query(); 383 | while (gr.next()) { 384 | var record = { 385 | table: table, 386 | sys_id: gr.sys_id + '', 387 | display: gr.getDisplayValue(), 388 | crc: this.getRecordCRC(gr), 389 | references: this.getReferenceFields(gr) 390 | }; 391 | records.push(record); 392 | } 393 | } 394 | return {version: version, records: records }; 395 | }, 396 | 397 | getReferenceFields: function(current) { 398 | var table = current.getTableName(); 399 | var fields = {}; 400 | 401 | var gr = new GlideRecord('sys_dictionary'); 402 | gr.addQuery('name', '=',table); 403 | gr.addQuery('internal_type', '=', 'reference'); 404 | gr.query(); 405 | while (gr.next()) { 406 | var name = gr.element + ''; 407 | var field = { 408 | name: name, 409 | display: gr.column_label + '', 410 | reference: current[name].sys_id + '', 411 | reference_table: gr.reference + '' 412 | }; 413 | fields[name] = field; 414 | } 415 | return fields; 416 | }, 417 | type: 'UXsyncNow' 418 | }; 419 | --------------------------------------------------------------------------------