From 39929be8648d4f862877d892d294aa559047a894 Mon Sep 17 00:00:00 2001 From: Richard Rodger Date: Wed, 6 Sep 2023 02:00:39 +0100 Subject: [PATCH] v24.0.1 --- coverage/lcov.info | 205 +++++++++++++++++++++-------------------- dist/entity.d.ts | 5 +- dist/entity.js | 8 +- dist/entity.js.map | 2 +- package.json | 16 ++-- src/entity.ts | 11 ++- src/lib/make_entity.ts | 10 +- src/lib/store.ts | 4 +- test/entity.test.js | 38 ++++---- test/mem-ops.js | 2 +- 10 files changed, 164 insertions(+), 137 deletions(-) diff --git a/coverage/lcov.info b/coverage/lcov.info index b3d8b70..8af4b43 100644 --- a/coverage/lcov.info +++ b/coverage/lcov.info @@ -1,11 +1,11 @@ TN: SF:src/entity.ts FN:16,entity -FN:48,preload -FN:66,build_api_make -FN:68,entityAPI -FN:109,seneca.root.private$.exports.Entity.log$ -FN:133,generate_id +FN:53,preload +FN:71,build_api_make +FN:73,entityAPI +FN:114,seneca.root.private$.exports.Entity.log$ +FN:142,generate_id FNF:6 FNH:6 FNDA:49,entity @@ -32,11 +32,11 @@ DA:15,1 DA:16,49 DA:17,49 DA:18,49 -DA:19,1 -DA:20,1 -DA:21,1 -DA:22,1 -DA:23,1 +DA:19,49 +DA:20,49 +DA:21,49 +DA:22,49 +DA:23,49 DA:24,1 DA:25,1 DA:26,1 @@ -61,11 +61,11 @@ DA:44,1 DA:45,1 DA:46,1 DA:47,1 -DA:48,49 -DA:49,49 -DA:50,49 -DA:51,49 -DA:52,49 +DA:48,1 +DA:49,1 +DA:50,1 +DA:51,1 +DA:52,1 DA:53,49 DA:54,49 DA:55,49 @@ -80,36 +80,36 @@ DA:63,49 DA:64,49 DA:65,49 DA:66,49 -DA:67,98 -DA:68,98 -DA:69,216 -DA:70,216 -DA:71,216 +DA:67,49 +DA:68,49 +DA:69,49 +DA:70,49 +DA:71,49 DA:72,98 DA:73,98 -DA:74,98 -DA:75,49 -DA:76,49 -DA:77,49 -DA:78,49 -DA:79,49 +DA:74,216 +DA:75,216 +DA:76,216 +DA:77,98 +DA:78,98 +DA:79,98 DA:80,49 DA:81,49 -DA:82,46 -DA:83,46 +DA:82,49 +DA:83,49 DA:84,49 DA:85,49 -DA:86,46 +DA:86,49 DA:87,46 -DA:88,49 +DA:88,46 DA:89,49 -DA:90,46 +DA:90,49 DA:91,46 -DA:92,49 +DA:92,46 DA:93,49 DA:94,49 -DA:95,49 -DA:96,49 +DA:95,46 +DA:96,46 DA:97,49 DA:98,49 DA:99,49 @@ -122,7 +122,7 @@ DA:105,49 DA:106,49 DA:107,49 DA:108,49 -DA:109,1 +DA:109,49 DA:110,49 DA:111,49 DA:112,49 @@ -132,76 +132,85 @@ DA:115,49 DA:116,49 DA:117,49 DA:118,49 -DA:119,49 +DA:119,1 DA:120,49 DA:121,49 DA:122,49 DA:123,49 -DA:124,1 -DA:125,1 -DA:126,1 -DA:127,1 -DA:128,1 -DA:129,1 -DA:130,1 -DA:131,1 -DA:132,1 -DA:133,49 -DA:134,49 -DA:135,49 -DA:136,49 -DA:137,49 -DA:138,49 -DA:139,49 -DA:140,47 -DA:141,47 -DA:142,47 -DA:143,47 -DA:144,47 -DA:145,47 -DA:146,46 -DA:147,47 -DA:148,1 -DA:149,1 +DA:124,49 +DA:125,49 +DA:126,49 +DA:127,49 +DA:128,49 +DA:129,49 +DA:130,49 +DA:131,49 +DA:132,49 +DA:133,1 +DA:134,1 +DA:135,1 +DA:136,1 +DA:137,1 +DA:138,1 +DA:139,1 +DA:140,1 +DA:141,1 +DA:142,49 +DA:143,49 +DA:144,49 +DA:145,49 +DA:146,49 +DA:147,49 +DA:148,49 +DA:149,47 DA:150,47 -DA:151,49 -DA:152,49 -DA:153,49 -DA:154,1 -DA:155,1 -DA:156,1 +DA:151,47 +DA:152,47 +DA:153,47 +DA:154,47 +DA:155,46 +DA:156,47 DA:157,1 DA:158,1 -DA:159,1 -DA:160,1 -DA:161,1 -DA:162,1 -LF:162 -LH:162 +DA:159,47 +DA:160,49 +DA:161,49 +DA:162,49 +DA:163,1 +DA:164,1 +DA:165,1 +DA:166,1 +DA:167,1 +DA:168,1 +DA:169,1 +DA:170,1 +DA:171,1 +LF:171 +LH:171 BRDA:16,0,0,49 -BRDA:48,1,0,49 -BRDA:53,2,0,2 -BRDA:60,3,0,46 -BRDA:64,4,0,46 -BRDA:81,5,0,46 -BRDA:85,6,0,46 -BRDA:89,7,0,46 -BRDA:108,8,0,1 -BRDA:66,9,0,98 -BRDA:68,10,0,216 -BRDA:109,11,0,49 -BRDA:133,12,0,49 -BRDA:137,13,0,2 -BRDA:137,14,0,47 -BRDA:139,15,0,47 -BRDA:142,16,0,43 -BRDA:142,17,0,42 -BRDA:143,18,0,4 -BRDA:145,19,0,46 -BRDA:146,20,0,5 -BRDA:147,21,0,1 -BRDA:152,22,0,1 -BRDA:152,23,0,48 +BRDA:53,1,0,49 +BRDA:58,2,0,2 +BRDA:65,3,0,46 +BRDA:69,4,0,46 +BRDA:86,5,0,46 +BRDA:90,6,0,46 +BRDA:94,7,0,46 +BRDA:113,8,0,1 +BRDA:71,9,0,98 +BRDA:73,10,0,216 +BRDA:114,11,0,49 +BRDA:142,12,0,49 +BRDA:146,13,0,2 +BRDA:146,14,0,47 +BRDA:148,15,0,47 +BRDA:151,16,0,43 +BRDA:151,17,0,42 +BRDA:152,18,0,4 +BRDA:154,19,0,46 +BRDA:155,20,0,5 +BRDA:156,21,0,1 +BRDA:161,22,0,1 +BRDA:161,23,0,48 BRF:24 BRH:24 end_of_record @@ -1611,7 +1620,7 @@ DA:114,12 DA:115,12 DA:116,0 DA:117,0 -DA:118,12 +DA:118,55 DA:119,55 DA:120,55 DA:121,55 diff --git a/dist/entity.d.ts b/dist/entity.d.ts index a6acf50..37040ca 100644 --- a/dist/entity.d.ts +++ b/dist/entity.d.ts @@ -1,5 +1,7 @@ import { Entity } from './lib/make_entity'; -declare function entity(this: any, options: any): void; +declare function entity(this: any, _options: any): { + name: string; +}; declare namespace entity { var defaults: { mem_store: boolean; @@ -20,6 +22,7 @@ declare namespace entity { }; }; var preload: (this: any, context: any) => { + name: string; exports: { store: { cmds: string[]; diff --git a/dist/entity.js b/dist/entity.js index 8559c34..9150722 100644 --- a/dist/entity.js +++ b/dist/entity.js @@ -4,8 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); const make_entity_1 = require("./lib/make_entity"); const store_1 = require("./lib/store"); // Define the entity plugin. -function entity(options) { +function entity(_options) { // const seneca = this + return { + // Define name, as tools like rollup will rename this function, breaking stuff. + name: 'entity' + }; } entity.defaults = { mem_store: true, @@ -75,6 +79,8 @@ function preload(context) { }; } return { + // Define name, as tools like rollup will rename this function, breaking stuff. + name: 'entity', exports: { store: store, init: store.init, diff --git a/dist/entity.js.map b/dist/entity.js.map index 47e38b7..dcafe2c 100644 --- a/dist/entity.js.map +++ b/dist/entity.js.map @@ -1 +1 @@ -{"version":3,"file":"entity.js","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":";AAAA,gFAAgF;;AAShF,mDAAsD;AACtD,uCAAmC;AAInC,4BAA4B;AAC5B,SAAS,MAAM,CAAY,OAAY;IACrC,sBAAsB;AACxB,CAAC;AAGD,MAAM,CAAC,QAAQ,GAAG;IAChB,SAAS,EAAE,IAAI;IACf,WAAW;IAEX,WAAW,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;IAE9B,sCAAsC;IACtC,MAAM,EAAE;QACN,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,GAAG;KACd;IAED,GAAG,EAAE;QACH,MAAM,EAAE,KAAK;KACd;IAED,kBAAkB;IAElB,IAAI,EAAE;QACJ,6DAA6D;QAC7D,OAAO,EAAE,IAAI;KACd;CACF,CAAA;AAGD,0DAA0D;AAC1D,SAAS,OAAO,CAAY,OAAY;IACtC,MAAM,MAAM,GAAG,IAAI,CAAA;IAEnB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAE/B,MAAM,CAAC,IAAI,CAAC,UAAU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W,CAAY,GAAQ,EAAE,KAAU;IAClD,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAA;IAEzB,IAAI,MAAM,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAEzC,IAAI,IAAI,IAAI,MAAM,EAAE;QAClB,MAAM,MAAM,GACV,QAAQ,KAAK,OAAO,GAAG;YACrB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC;YAC/B,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAEvB,IAAI,MAAM,GAAG,EAAE,EAAE;YACf,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;SAC1E;aAAM;YACL,MAAM,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;SACjC;KACF;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;AAC3C,CAAC;AAKD,kBAAe,MAAM,CAAA;AAErB,IAAI,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE;IACnC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAA;CACxB"} \ No newline at end of file diff --git a/package.json b/package.json index 16a341d..257a749 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "seneca-entity", "main": "dist/entity.js", - "version": "24.0.0", + "version": "24.0.1", "type": "commonjs", "types": "dist/entity.d.ts", "description": "Entity plugin for seneca", @@ -50,20 +50,20 @@ "node": ">=14" }, "dependencies": { - "seneca-mem-store": "^8.2.0" + "seneca-mem-store": "^8.3.0" }, "peerDependencies": { "seneca": ">=3", "seneca-promisify": ">=3" }, "devDependencies": { - "@seneca/maintain": "^0.0.30", - "@types/jest": "^29.5.2", - "esbuild": "^0.18.10", + "@seneca/maintain": "^0.1.0", + "@types/jest": "^29.5.4", + "esbuild": "^0.19.2", "esbuild-jest": "^0.5.0", - "jest": "^29.5.0", - "prettier": "^2.8.8", + "jest": "^29.6.4", + "prettier": "^3.0.3", "seneca-msg-test": "^3.4.0", - "typescript": "^5.1.6" + "typescript": "^5.2.2" } } diff --git a/src/entity.ts b/src/entity.ts index f1cdc05..57c5b28 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -13,8 +13,13 @@ import { Store } from './lib/store' // Define the entity plugin. -function entity(this: any, options: any) { +function entity(this: any, _options: any) { // const seneca = this + + return { + // Define name, as tools like rollup will rename this function, breaking stuff. + name: 'entity' + } } @@ -114,6 +119,10 @@ function preload(this: any, context: any) { } return { + + // Define name, as tools like rollup will rename this function, breaking stuff. + name: 'entity', + exports: { store: store, init: store.init, diff --git a/src/lib/make_entity.ts b/src/lib/make_entity.ts index ff10793..6da11c4 100644 --- a/src/lib/make_entity.ts +++ b/src/lib/make_entity.ts @@ -585,7 +585,7 @@ function entityPromise(si: any, entmsg: any) { : out || (out = { entity$: null }) ).meta$ = meta) : null, - out) + out), ) }) }) @@ -666,7 +666,7 @@ function parsecanon(str: CanonSpec) { out.name = m[5] === '-' ? void 0 : m[5] } else { throw new Error( - `Invalid entity canon: ${str}; expected format: zone/base/name.` + `Invalid entity canon: ${str}; expected format: zone/base/name.`, ) } @@ -702,7 +702,7 @@ function handle_options(entopts: any, seneca: any): any { canon_str, hidden_fields, entopts, - Jsonic + Jsonic, ) }) } @@ -725,7 +725,7 @@ function make_toString( canon_str: string | undefined, hidden_fields_spec: any | undefined, opts: any | undefined, - Jsonic: any + Jsonic: any, ) { opts = opts || { jsonic: {} } @@ -773,7 +773,7 @@ function MakeEntity(canon: any, seneca: any, opts: any): Entity { undefined, undefined, undefined, - seneca.util.Jsonic + seneca.util.Jsonic, )) ).bind(ent) diff --git a/src/lib/store.ts b/src/lib/store.ts index 8153ce4..60c7386 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -115,7 +115,7 @@ function Store(plugin_opts: any) { } else { return closer.prior(close_args, done) } - } + }, ) } }) @@ -143,7 +143,7 @@ const Intern: any = { cmd: string, zone?: string, base?: string, - name?: string + name?: string, ) { const outfunc = function (this: any, msg: any, reply: any, meta: any) { if ('save' !== msg.cmd) { diff --git a/test/entity.test.js b/test/entity.test.js index a4c4c50..e4df95e 100644 --- a/test/entity.test.js +++ b/test/entity.test.js @@ -174,7 +174,7 @@ describe('entity', function () { id: 'e0', f0: 1, }) - } + }, ) .act( 'sys:entity,cmd:load,base:b0,name:n0', @@ -185,7 +185,7 @@ describe('entity', function () { id: 'e0', f0: 1, }) - } + }, ) .act( 'sys:entity,cmd:load,base:b0,name:n0', @@ -196,7 +196,7 @@ describe('entity', function () { id: 'e0', f0: 1, }) - } + }, ) .act( 'sys:entity,cmd:list,base:b0,name:n0', @@ -207,7 +207,7 @@ describe('entity', function () { id: 'e0', f0: 1, }) - } + }, ) // q wins over id @@ -220,7 +220,7 @@ describe('entity', function () { id: 'e0', f0: 1, }) - } + }, ) .act('sys:entity,cmd:remove,base:b0,name:n0', { id: 'e0' }) .act( @@ -228,14 +228,14 @@ describe('entity', function () { { id: 'e0' }, function (err, out) { expect(null == out).toBeTruthy() - } + }, ) .act( 'sys:entity,cmd:list,base:b0,name:n0', { q: { id: 'e0' } }, function (err, out) { expect(out.length).toEqual(0) - } + }, ) .ready(fin) @@ -271,7 +271,7 @@ describe('entity', function () { cmd: 'save', ent: { f0: 1 }, }, - fin + fin, ) }) @@ -549,10 +549,10 @@ describe('entity', function () { expect(',,foo').toEqual('' + foo.canon$({ array: true })) expect(',,foo').toEqual('' + foo.canon$({ array$: true })) expect("{ zone: undefined, base: undefined, name: 'foo' }").toEqual( - Util.inspect(foo.canon$({ object: true })) + Util.inspect(foo.canon$({ object: true })), ) expect( - "{ 'zone$': undefined, 'base$': undefined, 'name$': 'foo' }" + "{ 'zone$': undefined, 'base$': undefined, 'name$': 'foo' }", ).toEqual(Util.inspect(foo.canon$({ object$: true }))) expect(',,foo').toEqual('' + foo.canon$({})) @@ -638,13 +638,13 @@ describe('entity', function () { expect(f3.canon$({ isa: 'zoo/boo/foo' })).toBeTruthy() expect(f3.canon$({ isa: ['zoo', 'boo', 'foo'] })).toBeTruthy() expect( - f3.canon$({ isa: { zone: 'zoo', base: 'boo', name: 'foo' } }) + f3.canon$({ isa: { zone: 'zoo', base: 'boo', name: 'foo' } }), ).toBeTruthy() expect(!f3.canon$({ isa: 'zar/far/bar' })).toBeTruthy() expect(!f3.canon$({ isa: ['zar', 'far', 'bar'] })).toBeTruthy() expect( - !f3.canon$({ isa: { zone: 'zar', base: 'far', name: 'bar' } }) + !f3.canon$({ isa: { zone: 'zar', base: 'far', name: 'bar' } }), ).toBeTruthy() fin() @@ -660,7 +660,7 @@ describe('entity', function () { let db = await si.post('role:mem-store,cmd:dump') let t = Gex( - '{"undefined":{"a":{"*":{"entity$":"-/-/a","x":1,"id":"*"}}},"b":{"a":{"*":{"entity$":"-/b/a","x":2,"id":"*"},"*":{"entity$":"c/b/a","x":3,"id":"*"}}}}' + '{"undefined":{"a":{"*":{"entity$":"-/-/a","x":1,"id":"*"}}},"b":{"a":{"*":{"entity$":"-/b/a","x":2,"id":"*"},"*":{"entity$":"c/b/a","x":3,"id":"*"}}}}', ).on(JSON.stringify(db)) expect(t).toBeTruthy() @@ -671,8 +671,8 @@ describe('entity', function () { db = await si2.post('role:mem-store,cmd:dump') expect( Gex( - '{"undefined":{"a":{"*":{"entity$":"-/-/a","x":1,"id":"*"}}},"b":{"a":{"*":{"entity$":"-/b/a","x":2,"id":"*"},"*":{"entity$":"c/b/a","x":3,"id":"*"}}}}' - ).on(JSON.stringify(db)) + '{"undefined":{"a":{"*":{"entity$":"-/-/a","x":1,"id":"*"}}},"b":{"a":{"*":{"entity$":"-/b/a","x":2,"id":"*"},"*":{"entity$":"c/b/a","x":3,"id":"*"}}}}', + ).on(JSON.stringify(db)), ).toBeTruthy() let nx1 = await si2.entity('a').load$({ x: 1 }) @@ -714,7 +714,7 @@ describe('entity', function () { tmp.s0++ cb() }, - } + }, ) }) @@ -734,7 +734,7 @@ describe('entity', function () { tmp.s1++ cb() }, - } + }, ) }) @@ -754,7 +754,7 @@ describe('entity', function () { tmp.s2++ cb() }, - } + }, ) }) @@ -997,7 +997,7 @@ describe('entity', function () { expect(out.toString()).toEqual('$-/-/foo;id=a;{x:1}') expect('' + out).toEqual('$-/-/foo;id=a;{x:1}') expect(Util.inspect(out)).toEqual( - "Entity { 'entity$': '-/-/foo', x: 1, id: 'a' }" + "Entity { 'entity$': '-/-/foo', x: 1, id: 'a' }", ) }) diff --git a/test/mem-ops.js b/test/mem-ops.js index 80e33b4..9ae1352 100644 --- a/test/mem-ops.js +++ b/test/mem-ops.js @@ -98,7 +98,7 @@ module.exports = function make_test(si) { Assert.equal(1, list.length) si.close(fin) - } + }, ) }) })