diff --git a/package-lock.json b/package-lock.json index 260d846..6ac4863 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1516,6 +1516,11 @@ "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, + "bulk-replace": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/bulk-replace/-/bulk-replace-0.0.1.tgz", + "integrity": "sha1-8JVoKolqvUs9ngjeQJzCIuIT+d0=" + }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -4982,6 +4987,14 @@ "sntp": "1.0.9" } }, + "hepburn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hepburn/-/hepburn-1.0.0.tgz", + "integrity": "sha1-Sc6GKUKndXDNT1yP4QC4XZQsths=", + "requires": { + "bulk-replace": "0.0.1" + } + }, "highlight.js": { "version": "9.12.0", "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", @@ -6899,6 +6912,11 @@ } } }, + "keypress": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/keypress/-/keypress-0.1.0.tgz", + "integrity": "sha1-SjGI1CkbZrT2XtuZ+AaqmuKTWSo=" + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -7245,6 +7263,16 @@ "immediate": "3.0.6" } }, + "limax": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/limax/-/limax-1.6.0.tgz", + "integrity": "sha1-mWFjKRx+jG591bQ4wBkLaWIvGzM=", + "requires": { + "hepburn": "1.0.0", + "pinyin": "2.8.3", + "speakingurl": "14.0.1" + } + }, "lint-staged": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-7.0.0.tgz", @@ -9042,6 +9070,23 @@ "integrity": "sha1-h6kGXNs1XTGC2PlM4RGIuCXGijs=", "dev": true }, + "nodejieba": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/nodejieba/-/nodejieba-2.2.5.tgz", + "integrity": "sha1-ghRBpoP60l69LI3eFAHdQ9vrAno=", + "optional": true, + "requires": { + "nan": "2.3.5" + }, + "dependencies": { + "nan": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.3.5.tgz", + "integrity": "sha1-gioNwmYpDOTNOhIoLKPn42Rmigg=", + "optional": true + } + } + }, "noop-logger": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", @@ -9147,8 +9192,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "object-copy": { "version": "0.1.0", @@ -9624,6 +9668,26 @@ "pinkie": "2.0.4" } }, + "pinyin": { + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/pinyin/-/pinyin-2.8.3.tgz", + "integrity": "sha1-MBzLQ1jM/oAlI8S9ZAphK+5NfEs=", + "requires": { + "commander": "1.1.1", + "nodejieba": "2.2.5", + "object-assign": "4.1.1" + }, + "dependencies": { + "commander": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-1.1.1.tgz", + "integrity": "sha1-UNFlGGiuYOzP8KLZ80WVN2vGsEE=", + "requires": { + "keypress": "0.1.0" + } + } + } + }, "pkg-dir": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", @@ -10971,13 +11035,13 @@ } }, "rollup-plugin-typescript2": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.12.0.tgz", - "integrity": "sha512-UvHzfJyBWyV+d4Av7FG79PTipIK1VrNQoDrNWszAYd7i/ZcCfBg3rPkPiK9Z+WEHXeWBbCnxJlSqR2zKWgEkiw==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.13.0.tgz", + "integrity": "sha512-E+NgtKWuT7QaQAjWz9KKFqC+aoBRR9HeiN/N2EJcAzGggqpcK+jLJGeqnyq+/g0ptaVQCzkyDGhqG0skSn4JHg==", "dev": true, "requires": { "fs-extra": "5.0.0", - "resolve": "1.6.0", + "resolve": "1.7.1", "rollup-pluginutils": "2.0.1", "tslib": "1.9.0" }, @@ -11003,9 +11067,9 @@ } }, "resolve": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.6.0.tgz", - "integrity": "sha512-mw7JQNu5ExIkcw4LPih0owX/TZXjD/ZUF/ZQ/pDnkw3ZKhDcZZw5klmBlj6gVMwjQ3Pz5Jgu7F3d0jcDVuEWdw==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", + "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -11425,14 +11489,6 @@ "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", "dev": true }, - "slug": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/slug/-/slug-0.9.1.tgz", - "integrity": "sha1-rwj2CKfBFRa2F3iqgA3OhMUYz9o=", - "requires": { - "unicode": "10.0.0" - } - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -11663,6 +11719,11 @@ "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", "dev": true }, + "speakingurl": { + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz", + "integrity": "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==" + }, "split": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", @@ -13370,11 +13431,6 @@ "dev": true, "optional": true }, - "unicode": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/unicode/-/unicode-10.0.0.tgz", - "integrity": "sha1-5dUcHbk7bHGguHngsMSvfm/faI4=" - }, "union-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", diff --git a/package.json b/package.json index d2bc31b..b6de0a7 100644 --- a/package.json +++ b/package.json @@ -110,6 +110,6 @@ "validate-commit-msg": "^2.12.2" }, "dependencies": { - "slug": "^0.9.1" + "limax": "^1.6.0" } } diff --git a/src/decorators/SlothEntity.ts b/src/decorators/SlothEntity.ts index 19842fd..57d2614 100644 --- a/src/decorators/SlothEntity.ts +++ b/src/decorators/SlothEntity.ts @@ -1,11 +1,12 @@ import BaseEntity from '../models/BaseEntity' import SlothData from '../models/SlothData' -import slug from 'slug' import StaticData from '../models/StaticData' import PouchFactory from '../models/PouchFactory' import EntityConstructor from '../helpers/EntityConstructor' import getProtoData from '../utils/getProtoData' +const slug = require('limax') + /** * This decorator is used to mark classes that will be an entity, a document * This function, by extending the constructor and defining this.sloth property diff --git a/test/integration/Album.test.ts b/test/integration/Album.test.ts index f1179f3..cd97514 100644 --- a/test/integration/Album.test.ts +++ b/test/integration/Album.test.ts @@ -23,7 +23,7 @@ test('generate uri', async () => { artist: flatbushZombies._id }) - expect(betterOffDead._id).toBe('library/Flatbush-Zombies/BetterOffDead') + expect(betterOffDead._id).toBe('library/flatbush-zombies/betteroffdead') }) test('updated uri', async () => { @@ -37,11 +37,11 @@ test('updated uri', async () => { name: 'BetterOffDead', artist: 'library/flatbush' }) - expect(betterOffDead._id).toBe('library/flatbush/BetterOffDead') + expect(betterOffDead._id).toBe('library/flatbush/betteroffdead') - betterOffDead.artist = 'library/Flatbush-Zombies' + betterOffDead.artist = 'library/flatbush-zombies' - expect(betterOffDead._id).toBe('library/Flatbush-Zombies/BetterOffDead') + expect(betterOffDead._id).toBe('library/flatbush-zombies/betteroffdead') }) test('remove parent if last child is removed', async () => { @@ -61,22 +61,22 @@ test('remove parent if last child is removed', async () => { await betterOffDead.save() - expect(await db.get('library/Flatbush-Zombies/BetterOffDead')).toMatchObject({ - _id: 'library/Flatbush-Zombies/BetterOffDead', - artist: 'library/Flatbush-Zombies' + expect(await db.get('library/flatbush-zombies/betteroffdead')).toMatchObject({ + _id: 'library/flatbush-zombies/betteroffdead', + artist: 'library/flatbush-zombies' }) - expect(await db.get('library/Flatbush-Zombies')).toMatchObject({ - _id: 'library/Flatbush-Zombies', + expect(await db.get('library/flatbush-zombies')).toMatchObject({ + _id: 'library/flatbush-zombies', name: 'Flatbush Zombies' }) await betterOffDead.remove() - await expect(db.get('library/Flatbush-Zombies')).rejects.toMatchObject({ + await expect(db.get('library/flatbush-zombies')).rejects.toMatchObject({ message: 'missing' }) await expect( - db.get('library/Flatbush-Zombies/BetterOffDead') + db.get('library/flatbush-zombies/betteroffdead') ).rejects.toMatchObject({ message: 'missing' }) }) @@ -104,39 +104,39 @@ test('doesnt remove parent if still has children', async () => { await vacationInHell.save() - expect(await db.get('library/Flatbush-Zombies/BetterOffDead')).toMatchObject({ - _id: 'library/Flatbush-Zombies/BetterOffDead', - artist: 'library/Flatbush-Zombies' + expect(await db.get('library/flatbush-zombies/betteroffdead')).toMatchObject({ + _id: 'library/flatbush-zombies/betteroffdead', + artist: 'library/flatbush-zombies' }) expect( - await db.get('library/Flatbush-Zombies/Vacation-In-Hell') + await db.get('library/flatbush-zombies/vacation-in-hell') ).toMatchObject({ - _id: 'library/Flatbush-Zombies/Vacation-In-Hell', - artist: 'library/Flatbush-Zombies' + _id: 'library/flatbush-zombies/vacation-in-hell', + artist: 'library/flatbush-zombies' }) - expect(await db.get('library/Flatbush-Zombies')).toMatchObject({ - _id: 'library/Flatbush-Zombies', + expect(await db.get('library/flatbush-zombies')).toMatchObject({ + _id: 'library/flatbush-zombies', name: 'Flatbush Zombies' }) await betterOffDead.remove() expect( - await db.get('library/Flatbush-Zombies/Vacation-In-Hell') + await db.get('library/flatbush-zombies/vacation-in-hell') ).toMatchObject({ - _id: 'library/Flatbush-Zombies/Vacation-In-Hell', - artist: 'library/Flatbush-Zombies' + _id: 'library/flatbush-zombies/vacation-in-hell', + artist: 'library/flatbush-zombies' }) - expect(await db.get('library/Flatbush-Zombies')).toMatchObject({ - _id: 'library/Flatbush-Zombies', + expect(await db.get('library/flatbush-zombies')).toMatchObject({ + _id: 'library/flatbush-zombies', name: 'Flatbush Zombies' }) await expect( - db.get('library/Flatbush-Zombies/BetterOffDead') + db.get('library/flatbush-zombies/betteroffdead') ).rejects.toMatchObject({ message: 'missing' }) }) @@ -157,6 +157,6 @@ test('rels.artist - maps with artist', async () => { const flatbush = await betterOffDead.rels.artist(factory) - expect(flatbush._id).toBe('library/Flatbush-Zombies') + expect(flatbush._id).toBe('library/flatbush-zombies') expect(flatbush.name).toBe('Flatbush Zombies') }) diff --git a/test/integration/object.test.ts b/test/integration/object.test.ts index 745ebd9..2ab98ff 100644 --- a/test/integration/object.test.ts +++ b/test/integration/object.test.ts @@ -49,7 +49,7 @@ describe('nested objects', () => { barz: 'foobarbarz' } }) - expect(await factory('foos').get('foos/Foobar')).toMatchObject({ + expect(await factory('foos').get('foos/foobar')).toMatchObject({ name: 'Foobar', foo: { bar: 'foobar', @@ -59,7 +59,7 @@ describe('nested objects', () => { }) test('get a document with a nested doc', async () => { - const { foo } = await Foo.findById(factory, 'foos/Foobar') + const { foo } = await Foo.findById(factory, 'foos/foobar') expect(foo).toEqual({ bar: 'foobar', barz: 'foobarbarz' @@ -67,7 +67,7 @@ describe('nested objects', () => { }) test('update a document with a nested doc', async () => { - const foo = await Foo.findById(factory, 'foos/Foobar') + const foo = await Foo.findById(factory, 'foos/foobar') foo.foo = { bar: 'bar', barz: 'barz' } @@ -78,7 +78,7 @@ describe('nested objects', () => { await foo.save() - expect(await factory('foos').get('foos/Foobar')).toMatchObject({ + expect(await factory('foos').get('foos/foobar')).toMatchObject({ name: 'Foobar', foo: { bar: 'bar', diff --git a/test/unit/decorators/SlothURI.test.ts b/test/unit/decorators/SlothURI.test.ts index 74e1951..ebf8744 100644 --- a/test/unit/decorators/SlothURI.test.ts +++ b/test/unit/decorators/SlothURI.test.ts @@ -1,6 +1,6 @@ import SlothURI from '../../../src/decorators/SlothURI' import emptyProtoData from '../../utils/emptyProtoData' -import slug from 'slug' +const slug = require('limax') test('SlothURI - returns correct url', () => { const object = {