diff --git a/debug.js.map b/debug.js.map index 468d250..c47794b 100644 --- a/debug.js.map +++ b/debug.js.map @@ -1 +1 @@ -{"version":3,"sources":["debug.js"],"names":[],"mappings":";;;;;;;;;;;;kBAEe;MAAC,6DAAK;SAAiB,0CAAyB,IAAzB;CAAvB","file":"debug.js","sourcesContent":["import debug from 'debug';\n\nexport default (name='time-stamp') => debug(`loopback:mixins:${name}`);\n"],"sourceRoot":"/Users/clarkbw/src/pi/loopback-ds-timestamp-mixin/es6"} \ No newline at end of file +{"version":3,"sources":["debug.js"],"names":[],"mappings":";;;;;;AAAA;;;;;;kBAEe;MAAC,6DAAK;SAAiB,0CAAyB,IAAzB;CAAvB","file":"debug.js","sourcesContent":["import debug from 'debug';\n\nexport default (name='time-stamp') => debug(`loopback:mixins:${name}`);\n"],"sourceRoot":"/Users/clarkbw/src/pi/loopback-ds-timestamp-mixin/es6"} \ No newline at end of file diff --git a/index.js.map b/index.js.map index 6ef1e31..92629a2 100644 --- a/index.js.map +++ b/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;kBAGe,qBAAU,UAAC,GAAD,EAAS;AAChC,MAAI,QAAJ,CAAa,YAAb,CAA0B,MAA1B,CAAiC,MAAjC,CAAwC,WAAxC,uBADgC;CAAT,EAEtB,uGAFY;;;AAIf,OAAO,OAAP,GAAiB,QAAQ,OAAR","file":"index.js","sourcesContent":["import { deprecate } from 'util';\nimport timestamp from './time-stamp';\n\nexport default deprecate((app) => {\n app.loopback.modelBuilder.mixins.define('TimeStamp', timestamp);\n}, 'DEPRECATED: Use mixinSources, see https://github.com/clarkbw/loopback-ds-timestamp-mixin#mixinsources');\n\nmodule.exports = exports.default;\n"],"sourceRoot":"/Users/clarkbw/src/pi/loopback-ds-timestamp-mixin/es6"} \ No newline at end of file +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;AAAA;;AACA;;;;;;kBAEe,qBAAU,UAAC,GAAD,EAAS;AAChC,MAAI,QAAJ,CAAa,YAAb,CAA0B,MAA1B,CAAiC,MAAjC,CAAwC,WAAxC,uBADgC;CAAT,EAEtB,uGAFY;;;AAIf,OAAO,OAAP,GAAiB,QAAQ,OAAR","file":"index.js","sourcesContent":["import { deprecate } from 'util';\nimport timestamp from './time-stamp';\n\nexport default deprecate((app) => {\n app.loopback.modelBuilder.mixins.define('TimeStamp', timestamp);\n}, 'DEPRECATED: Use mixinSources, see https://github.com/clarkbw/loopback-ds-timestamp-mixin#mixinsources');\n\nmodule.exports = exports.default;\n"],"sourceRoot":"/Users/clarkbw/src/pi/loopback-ds-timestamp-mixin/es6"} \ No newline at end of file diff --git a/package.json b/package.json index 31109aa..8548003 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "babel-core": "latest", "babel-plugin-transform-es2015-modules-commonjs": "^6.3.16", "babel-plugin-transform-object-assign": "latest", + "babel-preset-es2015": "latest", "coveralls": "latest", "gulp": "latest", "gulp-babel": "latest", diff --git a/time-stamp.js.map b/time-stamp.js.map index 3cc9498..7557496 100644 --- a/time-stamp.js.map +++ b/time-stamp.js.map @@ -1 +1 @@ -{"version":3,"sources":["time-stamp.js"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,IAAM,QAAQ,sBAAR;;kBAES,UAAC,KAAD,EAAyB;MAAjB,gEAAU,kBAAO;;;AAEtC,QAAM,8BAAN,EAAsC,MAAM,SAAN,CAAtC,CAFsC;;AAItC,YAAU,SAAc,EAAC,WAAW,WAAX,EAAwB,WAAW,WAAX,EAAwB,UAAU,IAAV,EAA/D,EAAgF,OAAhF,CAAV,CAJsC;;AAMtC,QAAM,SAAN,EAAiB,OAAjB,EANsC;;AAQtC,QAAM,+BAAN,EAAuC,MAAM,QAAN,CAAe,cAAf,CAAvC,CARsC;AAStC,MAAI,MAAM,QAAN,CAAe,cAAf,IAAiC,QAAQ,QAAR,EAAkB;AACrD,YAAQ,IAAR,CAAa,+FAAb,EADqD;GAAvD;AAGA,QAAM,QAAN,CAAe,cAAf,GAAgC,KAAhC,CAZsC;;AActC,QAAM,cAAN,CAAqB,QAAQ,SAAR,EAAmB,EAAC,MAAM,IAAN,EAAY,UAAU,QAAQ,QAAR,EAAkB,WAAW,KAAX,EAAjF,EAdsC;AAetC,QAAM,cAAN,CAAqB,QAAQ,SAAR,EAAmB,EAAC,MAAM,IAAN,EAAY,UAAU,QAAQ,QAAR,EAA/D,EAfsC;;AAiBtC,QAAM,OAAN,CAAc,aAAd,EAA6B,UAAC,GAAD,EAAM,IAAN,EAAe;AAC1C,UAAM,aAAN,EAAqB,IAAI,OAAJ,CAArB,CAD0C;AAE1C,QAAI,IAAI,OAAJ,IAAe,IAAI,OAAJ,CAAY,aAAZ,EAA2B;AAAE,aAAO,MAAP,CAAF;KAA9C;AACA,QAAI,IAAI,QAAJ,EAAc;AAChB,YAAM,uBAAN,EAA+B,IAAI,KAAJ,CAAU,SAAV,EAAqB,QAAQ,SAAR,EAAmB,IAAI,QAAJ,CAAa,EAAb,CAAvE,CADgB;AAEhB,UAAI,QAAJ,CAAa,QAAQ,SAAR,CAAb,GAAkC,IAAI,IAAJ,EAAlC,CAFgB;KAAlB,MAGO;AACL,YAAM,iCAAN,EAAyC,IAAI,KAAJ,CAAU,eAAV,EAA2B,QAAQ,SAAR,EAAmB,IAAI,KAAJ,CAAvF,CADK;AAEL,UAAI,IAAJ,CAAS,QAAQ,SAAR,CAAT,GAA8B,IAAI,IAAJ,EAA9B,CAFK;KAHP;AAOA,WAV0C;GAAf,CAA7B,CAjBsC;CAAzB;;AAgCf,OAAO,OAAP,GAAiB,QAAQ,OAAR","file":"time-stamp.js","sourcesContent":["import _debug from './debug';\nconst debug = _debug();\n\nexport default (Model, options = {}) => {\n\n debug('TimeStamp mixin for Model %s', Model.modelName);\n\n options = Object.assign({createdAt: 'createdAt', updatedAt: 'updatedAt', required: true}, options);\n\n debug('options', options);\n\n debug('Model.settings.validateUpsert', Model.settings.validateUpsert);\n if (Model.settings.validateUpsert && options.required) {\n console.warn('TimeStamp mixin requires validateUpsert be false. See @clarkbw/loopback-ds-timestamp-mixin#10');\n }\n Model.settings.validateUpsert = false;\n\n Model.defineProperty(options.createdAt, {type: Date, required: options.required, defaultFn: 'now'});\n Model.defineProperty(options.updatedAt, {type: Date, required: options.required});\n\n Model.observe('before save', (ctx, next) => {\n debug('ctx.options', ctx.options);\n if (ctx.options && ctx.options.skipUpdatedAt) { return next(); }\n if (ctx.instance) {\n debug('%s.%s before save: %s', ctx.Model.modelName, options.updatedAt, ctx.instance.id);\n ctx.instance[options.updatedAt] = new Date();\n } else {\n debug('%s.%s before update matching %j', ctx.Model.pluralModelName, options.updatedAt, ctx.where);\n ctx.data[options.updatedAt] = new Date();\n }\n next();\n });\n\n};\n\nmodule.exports = exports.default;\n"],"sourceRoot":"/Users/clarkbw/src/pi/loopback-ds-timestamp-mixin/es6"} \ No newline at end of file +{"version":3,"sources":["time-stamp.js"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;AACA,IAAM,QAAQ,sBAAR;;kBAES,UAAC,KAAD,EAAyB;MAAjB,gEAAU,kBAAO;;;AAEtC,QAAM,8BAAN,EAAsC,MAAM,SAAN,CAAtC,CAFsC;;AAItC,YAAU,SAAc,EAAC,WAAW,WAAX,EAAwB,WAAW,WAAX,EAAwB,UAAU,IAAV,EAA/D,EAAgF,OAAhF,CAAV,CAJsC;;AAMtC,QAAM,SAAN,EAAiB,OAAjB,EANsC;;AAQtC,QAAM,+BAAN,EAAuC,MAAM,QAAN,CAAe,cAAf,CAAvC,CARsC;AAStC,MAAI,MAAM,QAAN,CAAe,cAAf,IAAiC,QAAQ,QAAR,EAAkB;AACrD,YAAQ,IAAR,CAAa,+FAAb,EADqD;GAAvD;AAGA,QAAM,QAAN,CAAe,cAAf,GAAgC,KAAhC,CAZsC;;AActC,QAAM,cAAN,CAAqB,QAAQ,SAAR,EAAmB,EAAC,MAAM,IAAN,EAAY,UAAU,QAAQ,QAAR,EAAkB,WAAW,KAAX,EAAjF,EAdsC;AAetC,QAAM,cAAN,CAAqB,QAAQ,SAAR,EAAmB,EAAC,MAAM,IAAN,EAAY,UAAU,QAAQ,QAAR,EAA/D,EAfsC;;AAiBtC,QAAM,OAAN,CAAc,aAAd,EAA6B,UAAC,GAAD,EAAM,IAAN,EAAe;AAC1C,UAAM,aAAN,EAAqB,IAAI,OAAJ,CAArB,CAD0C;AAE1C,QAAI,IAAI,OAAJ,IAAe,IAAI,OAAJ,CAAY,aAAZ,EAA2B;AAAE,aAAO,MAAP,CAAF;KAA9C;AACA,QAAI,IAAI,QAAJ,EAAc;AAChB,YAAM,uBAAN,EAA+B,IAAI,KAAJ,CAAU,SAAV,EAAqB,QAAQ,SAAR,EAAmB,IAAI,QAAJ,CAAa,EAAb,CAAvE,CADgB;AAEhB,UAAI,QAAJ,CAAa,QAAQ,SAAR,CAAb,GAAkC,IAAI,IAAJ,EAAlC,CAFgB;KAAlB,MAGO;AACL,YAAM,iCAAN,EAAyC,IAAI,KAAJ,CAAU,eAAV,EAA2B,QAAQ,SAAR,EAAmB,IAAI,KAAJ,CAAvF,CADK;AAEL,UAAI,IAAJ,CAAS,QAAQ,SAAR,CAAT,GAA8B,IAAI,IAAJ,EAA9B,CAFK;KAHP;AAOA,WAV0C;GAAf,CAA7B,CAjBsC;CAAzB;;AAgCf,OAAO,OAAP,GAAiB,QAAQ,OAAR","file":"time-stamp.js","sourcesContent":["import _debug from './debug';\nconst debug = _debug();\n\nexport default (Model, options = {}) => {\n\n debug('TimeStamp mixin for Model %s', Model.modelName);\n\n options = Object.assign({createdAt: 'createdAt', updatedAt: 'updatedAt', required: true}, options);\n\n debug('options', options);\n\n debug('Model.settings.validateUpsert', Model.settings.validateUpsert);\n if (Model.settings.validateUpsert && options.required) {\n console.warn('TimeStamp mixin requires validateUpsert be false. See @clarkbw/loopback-ds-timestamp-mixin#10');\n }\n Model.settings.validateUpsert = false;\n\n Model.defineProperty(options.createdAt, {type: Date, required: options.required, defaultFn: 'now'});\n Model.defineProperty(options.updatedAt, {type: Date, required: options.required});\n\n Model.observe('before save', (ctx, next) => {\n debug('ctx.options', ctx.options);\n if (ctx.options && ctx.options.skipUpdatedAt) { return next(); }\n if (ctx.instance) {\n debug('%s.%s before save: %s', ctx.Model.modelName, options.updatedAt, ctx.instance.id);\n ctx.instance[options.updatedAt] = new Date();\n } else {\n debug('%s.%s before update matching %j', ctx.Model.pluralModelName, options.updatedAt, ctx.where);\n ctx.data[options.updatedAt] = new Date();\n }\n next();\n });\n\n};\n\nmodule.exports = exports.default;\n"],"sourceRoot":"/Users/clarkbw/src/pi/loopback-ds-timestamp-mixin/es6"} \ No newline at end of file