diff --git a/.gitignore b/.gitignore index fbeabd3..922dcb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ yarn.lock -node_modules -coverage +/node_modules/ +/coverage/ diff --git a/coverage/clover.xml b/coverage/clover.xml deleted file mode 100644 index c52eb59..0000000 --- a/coverage/clover.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/coverage/coverage-final.json b/coverage/coverage-final.json deleted file mode 100644 index b92310e..0000000 --- a/coverage/coverage-final.json +++ /dev/null @@ -1,4 +0,0 @@ -{"/Users/ldemorais/Projects/integrations/strapi-test/src/plugins/orama-plugin-strapi/server/services/content-types.js": {"path":"/Users/ldemorais/Projects/integrations/strapi-test/src/plugins/orama-plugin-strapi/server/services/content-types.js","statementMap":{"0":{"start":{"line":3,"column":22},"end":{"line":18,"column":1}},"1":{"start":{"line":20,"column":31},"end":{"line":27,"column":1}},"2":{"start":{"line":21,"column":2},"end":{"line":26,"column":8}},"3":{"start":{"line":22,"column":4},"end":{"line":24,"column":5}},"4":{"start":{"line":23,"column":6},"end":{"line":23,"column":56}},"5":{"start":{"line":25,"column":4},"end":{"line":25,"column":20}},"6":{"start":{"line":29,"column":20},"end":{"line":31,"column":1}},"7":{"start":{"line":30,"column":2},"end":{"line":30,"column":77}},"8":{"start":{"line":33,"column":27},"end":{"line":33,"column":108}},"9":{"start":{"line":33,"column":42},"end":{"line":33,"column":108}},"10":{"start":{"line":35,"column":24},"end":{"line":39,"column":1}},"11":{"start":{"line":36,"column":2},"end":{"line":38,"column":3}},"12":{"start":{"line":41,"column":34},"end":{"line":47,"column":1}},"13":{"start":{"line":42,"column":2},"end":{"line":46,"column":3}},"14":{"start":{"line":49,"column":29},"end":{"line":56,"column":1}},"15":{"start":{"line":50,"column":2},"end":{"line":55,"column":8}},"16":{"start":{"line":51,"column":4},"end":{"line":53,"column":5}},"17":{"start":{"line":52,"column":57},"end":{"line":52,"column":60}},"18":{"start":{"line":54,"column":4},"end":{"line":54,"column":14}},"19":{"start":{"line":57,"column":35},"end":{"line":58,"column":113}},"20":{"start":{"line":58,"column":2},"end":{"line":58,"column":113}},"21":{"start":{"line":58,"column":56},"end":{"line":58,"column":103}},"22":{"start":{"line":60,"column":0},"end":{"line":154,"column":1}},"23":{"start":{"line":61,"column":2},"end":{"line":153,"column":3}},"24":{"start":{"line":63,"column":27},"end":{"line":65,"column":8}},"25":{"start":{"line":67,"column":6},"end":{"line":77,"column":9}},"26":{"start":{"line":67,"column":69},"end":{"line":77,"column":7}},"27":{"start":{"line":81,"column":32},"end":{"line":81,"column":75}},"28":{"start":{"line":82,"column":29},"end":{"line":82,"column":63}},"29":{"start":{"line":84,"column":6},"end":{"line":89,"column":8}},"30":{"start":{"line":93,"column":26},"end":{"line":93,"column":60}},"31":{"start":{"line":94,"column":18},"end":{"line":112,"column":12}},"32":{"start":{"line":95,"column":8},"end":{"line":109,"column":9}},"33":{"start":{"line":105,"column":10},"end":{"line":108,"column":12}},"34":{"start":{"line":111,"column":8},"end":{"line":111,"column":24}},"35":{"start":{"line":114,"column":6},"end":{"line":114,"column":16}},"36":{"start":{"line":118,"column":6},"end":{"line":123,"column":7}},"37":{"start":{"line":119,"column":8},"end":{"line":122,"column":10}},"38":{"start":{"line":125,"column":6},"end":{"line":125,"column":42}},"39":{"start":{"line":129,"column":6},"end":{"line":143,"column":12}},"40":{"start":{"line":130,"column":8},"end":{"line":141,"column":9}},"41":{"start":{"line":140,"column":10},"end":{"line":140,"column":62}},"42":{"start":{"line":142,"column":8},"end":{"line":142,"column":21}},"43":{"start":{"line":147,"column":26},"end":{"line":147,"column":60}},"44":{"start":{"line":148,"column":6},"end":{"line":151,"column":8}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":20,"column":31},"end":{"line":20,"column":32}},"loc":{"start":{"line":20,"column":53},"end":{"line":27,"column":1}},"line":20},"1":{"name":"(anonymous_1)","decl":{"start":{"line":21,"column":42},"end":{"line":21,"column":43}},"loc":{"start":{"line":21,"column":70},"end":{"line":26,"column":3}},"line":21},"2":{"name":"(anonymous_2)","decl":{"start":{"line":29,"column":20},"end":{"line":29,"column":21}},"loc":{"start":{"line":29,"column":30},"end":{"line":31,"column":1}},"line":29},"3":{"name":"(anonymous_3)","decl":{"start":{"line":33,"column":27},"end":{"line":33,"column":28}},"loc":{"start":{"line":33,"column":42},"end":{"line":33,"column":108}},"line":33},"4":{"name":"(anonymous_4)","decl":{"start":{"line":35,"column":24},"end":{"line":35,"column":25}},"loc":{"start":{"line":35,"column":62},"end":{"line":39,"column":1}},"line":35},"5":{"name":"(anonymous_5)","decl":{"start":{"line":41,"column":34},"end":{"line":41,"column":35}},"loc":{"start":{"line":41,"column":68},"end":{"line":47,"column":1}},"line":41},"6":{"name":"(anonymous_6)","decl":{"start":{"line":49,"column":29},"end":{"line":49,"column":30}},"loc":{"start":{"line":49,"column":56},"end":{"line":56,"column":1}},"line":49},"7":{"name":"(anonymous_7)","decl":{"start":{"line":50,"column":26},"end":{"line":50,"column":27}},"loc":{"start":{"line":50,"column":45},"end":{"line":55,"column":3}},"line":50},"8":{"name":"(anonymous_8)","decl":{"start":{"line":52,"column":48},"end":{"line":52,"column":49}},"loc":{"start":{"line":52,"column":57},"end":{"line":52,"column":60}},"line":52},"9":{"name":"(anonymous_9)","decl":{"start":{"line":57,"column":35},"end":{"line":57,"column":36}},"loc":{"start":{"line":58,"column":2},"end":{"line":58,"column":113}},"line":58},"10":{"name":"(anonymous_10)","decl":{"start":{"line":58,"column":32},"end":{"line":58,"column":33}},"loc":{"start":{"line":58,"column":56},"end":{"line":58,"column":103}},"line":58},"11":{"name":"(anonymous_11)","decl":{"start":{"line":60,"column":17},"end":{"line":60,"column":18}},"loc":{"start":{"line":60,"column":33},"end":{"line":154,"column":1}},"line":60},"12":{"name":"(anonymous_12)","decl":{"start":{"line":62,"column":4},"end":{"line":62,"column":5}},"loc":{"start":{"line":62,"column":22},"end":{"line":78,"column":5}},"line":62},"13":{"name":"(anonymous_13)","decl":{"start":{"line":67,"column":46},"end":{"line":67,"column":47}},"loc":{"start":{"line":67,"column":69},"end":{"line":77,"column":7}},"line":67},"14":{"name":"(anonymous_14)","decl":{"start":{"line":80,"column":4},"end":{"line":80,"column":5}},"loc":{"start":{"line":80,"column":86},"end":{"line":90,"column":5}},"line":80},"15":{"name":"(anonymous_15)","decl":{"start":{"line":92,"column":4},"end":{"line":92,"column":5}},"loc":{"start":{"line":92,"column":45},"end":{"line":115,"column":5}},"line":92},"16":{"name":"(anonymous_16)","decl":{"start":{"line":94,"column":64},"end":{"line":94,"column":65}},"loc":{"start":{"line":94,"column":112},"end":{"line":112,"column":7}},"line":94},"17":{"name":"(anonymous_17)","decl":{"start":{"line":117,"column":4},"end":{"line":117,"column":5}},"loc":{"start":{"line":117,"column":23},"end":{"line":126,"column":5}},"line":117},"18":{"name":"(anonymous_18)","decl":{"start":{"line":128,"column":4},"end":{"line":128,"column":5}},"loc":{"start":{"line":128,"column":74},"end":{"line":144,"column":5}},"line":128},"19":{"name":"(anonymous_19)","decl":{"start":{"line":129,"column":47},"end":{"line":129,"column":48}},"loc":{"start":{"line":129,"column":92},"end":{"line":143,"column":7}},"line":129},"20":{"name":"(anonymous_20)","decl":{"start":{"line":146,"column":4},"end":{"line":146,"column":5}},"loc":{"start":{"line":146,"column":63},"end":{"line":152,"column":5}},"line":146}},"branchMap":{"0":{"loc":{"start":{"line":22,"column":4},"end":{"line":24,"column":5}},"type":"if","locations":[{"start":{"line":22,"column":4},"end":{"line":24,"column":5}},{"start":{},"end":{}}],"line":22},"1":{"loc":{"start":{"line":37,"column":4},"end":{"line":37,"column":117}},"type":"binary-expr","locations":[{"start":{"line":37,"column":4},"end":{"line":37,"column":40}},{"start":{"line":37,"column":45},"end":{"line":37,"column":87}},{"start":{"line":37,"column":91},"end":{"line":37,"column":116}}],"line":37},"2":{"loc":{"start":{"line":43,"column":4},"end":{"line":45,"column":88}},"type":"binary-expr","locations":[{"start":{"line":43,"column":4},"end":{"line":43,"column":31}},{"start":{"line":44,"column":4},"end":{"line":44,"column":34}},{"start":{"line":45,"column":5},"end":{"line":45,"column":34}},{"start":{"line":45,"column":38},"end":{"line":45,"column":87}}],"line":43},"3":{"loc":{"start":{"line":58,"column":56},"end":{"line":58,"column":103}},"type":"cond-expr","locations":[{"start":{"line":58,"column":84},"end":{"line":58,"column":87}},{"start":{"line":58,"column":90},"end":{"line":58,"column":103}}],"line":58},"4":{"loc":{"start":{"line":80,"column":36},"end":{"line":80,"column":50}},"type":"default-arg","locations":[{"start":{"line":80,"column":48},"end":{"line":80,"column":50}}],"line":80},"5":{"loc":{"start":{"line":80,"column":60},"end":{"line":80,"column":70}},"type":"default-arg","locations":[{"start":{"line":80,"column":69},"end":{"line":80,"column":70}}],"line":80},"6":{"loc":{"start":{"line":80,"column":72},"end":{"line":80,"column":82}},"type":"default-arg","locations":[{"start":{"line":80,"column":80},"end":{"line":80,"column":82}}],"line":80},"7":{"loc":{"start":{"line":95,"column":8},"end":{"line":109,"column":9}},"type":"if","locations":[{"start":{"line":95,"column":8},"end":{"line":109,"column":9}},{"start":{},"end":{}}],"line":95},"8":{"loc":{"start":{"line":96,"column":10},"end":{"line":103,"column":12}},"type":"binary-expr","locations":[{"start":{"line":96,"column":10},"end":{"line":96,"column":44}},{"start":{"line":97,"column":10},"end":{"line":103,"column":12}}],"line":96},"9":{"loc":{"start":{"line":118,"column":6},"end":{"line":123,"column":7}},"type":"if","locations":[{"start":{"line":118,"column":6},"end":{"line":123,"column":7}},{"start":{},"end":{}}],"line":118},"10":{"loc":{"start":{"line":130,"column":8},"end":{"line":141,"column":9}},"type":"if","locations":[{"start":{"line":130,"column":8},"end":{"line":141,"column":9}},{"start":{},"end":{}}],"line":130}},"s":{"0":1,"1":1,"2":1,"3":3,"4":2,"5":3,"6":1,"7":16,"8":1,"9":16,"10":1,"11":6,"12":1,"13":16,"14":1,"15":2,"16":1,"17":1,"18":1,"19":1,"20":2,"21":3,"22":1,"23":1,"24":1,"25":1,"26":2,"27":2,"28":2,"29":2,"30":2,"31":2,"32":8,"33":2,"34":8,"35":2,"36":12,"37":2,"38":10,"39":4,"40":16,"41":12,"42":16,"43":2,"44":2},"f":{"0":1,"1":3,"2":16,"3":16,"4":6,"5":16,"6":2,"7":1,"8":1,"9":2,"10":3,"11":1,"12":1,"13":2,"14":2,"15":2,"16":8,"17":12,"18":4,"19":16,"20":2},"b":{"0":[2,1],"1":[6,6,6],"2":[16,16,14,4],"3":[1,2],"4":[0],"5":[0],"6":[0],"7":[2,6],"8":[8,2],"9":[2,10],"10":[12,4]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"bba5790e51ef00ec23c0d70a427387f809d56e6c"} -,"/Users/ldemorais/Projects/integrations/strapi-test/src/plugins/orama-plugin-strapi/server/services/orama-manager.js": {"path":"/Users/ldemorais/Projects/integrations/strapi-test/src/plugins/orama-plugin-strapi/server/services/orama-manager.js","statementMap":{"0":{"start":{"line":3,"column":25},"end":{"line":3,"column":54}},"1":{"start":{"line":4,"column":36},"end":{"line":4,"column":65}},"2":{"start":{"line":8,"column":4},"end":{"line":8,"column":24}},"3":{"start":{"line":9,"column":4},"end":{"line":9,"column":90}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":87}},"5":{"start":{"line":11,"column":4},"end":{"line":11,"column":78}},"6":{"start":{"line":13,"column":4},"end":{"line":13,"column":78}},"7":{"start":{"line":14,"column":4},"end":{"line":18,"column":5}},"8":{"start":{"line":22,"column":4},"end":{"line":25,"column":5}},"9":{"start":{"line":23,"column":6},"end":{"line":23,"column":51}},"10":{"start":{"line":24,"column":6},"end":{"line":24,"column":18}},"11":{"start":{"line":27,"column":4},"end":{"line":30,"column":5}},"12":{"start":{"line":28,"column":6},"end":{"line":28,"column":83}},"13":{"start":{"line":29,"column":6},"end":{"line":29,"column":18}},"14":{"start":{"line":32,"column":4},"end":{"line":37,"column":5}},"15":{"start":{"line":33,"column":6},"end":{"line":35,"column":7}},"16":{"start":{"line":36,"column":6},"end":{"line":36,"column":18}},"17":{"start":{"line":39,"column":4},"end":{"line":44,"column":5}},"18":{"start":{"line":40,"column":6},"end":{"line":42,"column":7}},"19":{"start":{"line":43,"column":6},"end":{"line":43,"column":18}},"20":{"start":{"line":46,"column":4},"end":{"line":46,"column":15}},"21":{"start":{"line":50,"column":4},"end":{"line":52,"column":6}},"22":{"start":{"line":56,"column":4},"end":{"line":58,"column":6}},"23":{"start":{"line":62,"column":4},"end":{"line":66,"column":6}},"24":{"start":{"line":70,"column":18},"end":{"line":70,"column":55}},"25":{"start":{"line":71,"column":19},"end":{"line":71,"column":39}},"26":{"start":{"line":73,"column":4},"end":{"line":73,"column":53}},"27":{"start":{"line":75,"column":4},"end":{"line":75,"column":17}},"28":{"start":{"line":79,"column":18},"end":{"line":79,"column":55}},"29":{"start":{"line":80,"column":4},"end":{"line":80,"column":35}},"30":{"start":{"line":84,"column":20},"end":{"line":89,"column":6}},"31":{"start":{"line":91,"column":4},"end":{"line":100,"column":5}},"32":{"start":{"line":92,"column":6},"end":{"line":97,"column":7}},"33":{"start":{"line":99,"column":6},"end":{"line":99,"column":71}},"34":{"start":{"line":102,"column":4},"end":{"line":102,"column":38}},"35":{"start":{"line":106,"column":18},"end":{"line":106,"column":55}},"36":{"start":{"line":107,"column":4},"end":{"line":107,"column":40}},"37":{"start":{"line":111,"column":18},"end":{"line":111,"column":55}},"38":{"start":{"line":112,"column":19},"end":{"line":112,"column":46}},"39":{"start":{"line":114,"column":4},"end":{"line":114,"column":106}},"40":{"start":{"line":114,"column":78},"end":{"line":114,"column":80}},"41":{"start":{"line":116,"column":4},"end":{"line":116,"column":17}},"42":{"start":{"line":120,"column":18},"end":{"line":120,"column":55}},"43":{"start":{"line":121,"column":19},"end":{"line":121,"column":46}},"44":{"start":{"line":123,"column":4},"end":{"line":123,"column":105}},"45":{"start":{"line":123,"column":77},"end":{"line":123,"column":79}},"46":{"start":{"line":125,"column":4},"end":{"line":125,"column":17}},"47":{"start":{"line":129,"column":18},"end":{"line":129,"column":55}},"48":{"start":{"line":130,"column":19},"end":{"line":130,"column":66}},"49":{"start":{"line":130,"column":62},"end":{"line":130,"column":64}},"50":{"start":{"line":132,"column":4},"end":{"line":132,"column":105}},"51":{"start":{"line":132,"column":77},"end":{"line":132,"column":79}},"52":{"start":{"line":134,"column":4},"end":{"line":134,"column":17}},"53":{"start":{"line":138,"column":4},"end":{"line":140,"column":5}},"54":{"start":{"line":139,"column":6},"end":{"line":139,"column":18}},"55":{"start":{"line":142,"column":46},"end":{"line":142,"column":52}},"56":{"start":{"line":144,"column":4},"end":{"line":144,"column":109}},"57":{"start":{"line":148,"column":23},"end":{"line":148,"column":63}},"58":{"start":{"line":150,"column":4},"end":{"line":152,"column":5}},"59":{"start":{"line":151,"column":6},"end":{"line":151,"column":12}},"60":{"start":{"line":154,"column":24},"end":{"line":157,"column":6}},"61":{"start":{"line":159,"column":4},"end":{"line":159,"column":42}},"62":{"start":{"line":161,"column":4},"end":{"line":161,"column":37}},"63":{"start":{"line":163,"column":4},"end":{"line":166,"column":6}},"64":{"start":{"line":168,"column":32},"end":{"line":168,"column":65}},"65":{"start":{"line":170,"column":4},"end":{"line":170,"column":43}},"66":{"start":{"line":172,"column":4},"end":{"line":172,"column":61}},"67":{"start":{"line":176,"column":4},"end":{"line":176,"column":36}},"68":{"start":{"line":180,"column":23},"end":{"line":180,"column":63}},"69":{"start":{"line":182,"column":4},"end":{"line":184,"column":5}},"70":{"start":{"line":186,"column":4},"end":{"line":188,"column":5}},"71":{"start":{"line":187,"column":6},"end":{"line":187,"column":12}},"72":{"start":{"line":190,"column":4},"end":{"line":190,"column":42}},"73":{"start":{"line":192,"column":4},"end":{"line":192,"column":43}},"74":{"start":{"line":194,"column":4},"end":{"line":194,"column":44}},"75":{"start":{"line":196,"column":4},"end":{"line":196,"column":102}},"76":{"start":{"line":200,"column":23},"end":{"line":200,"column":63}},"77":{"start":{"line":202,"column":4},"end":{"line":204,"column":5}},"78":{"start":{"line":203,"column":6},"end":{"line":203,"column":12}},"79":{"start":{"line":206,"column":4},"end":{"line":206,"column":111}},"80":{"start":{"line":208,"column":4},"end":{"line":208,"column":42}},"81":{"start":{"line":210,"column":4},"end":{"line":215,"column":8}},"82":{"start":{"line":217,"column":4},"end":{"line":217,"column":110}},"83":{"start":{"line":221,"column":23},"end":{"line":221,"column":63}},"84":{"start":{"line":223,"column":4},"end":{"line":225,"column":5}},"85":{"start":{"line":224,"column":6},"end":{"line":224,"column":12}},"86":{"start":{"line":227,"column":4},"end":{"line":229,"column":5}},"87":{"start":{"line":231,"column":4},"end":{"line":231,"column":42}},"88":{"start":{"line":233,"column":4},"end":{"line":233,"column":37}},"89":{"start":{"line":235,"column":32},"end":{"line":235,"column":65}},"90":{"start":{"line":237,"column":4},"end":{"line":237,"column":61}},"91":{"start":{"line":239,"column":4},"end":{"line":239,"column":115}},"92":{"start":{"line":243,"column":0},"end":{"line":246,"column":1}},"93":{"start":{"line":245,"column":27},"end":{"line":245,"column":55}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":7,"column":2},"end":{"line":7,"column":3}},"loc":{"start":{"line":7,"column":26},"end":{"line":19,"column":3}},"line":7},"1":{"name":"(anonymous_1)","decl":{"start":{"line":21,"column":2},"end":{"line":21,"column":3}},"loc":{"start":{"line":21,"column":23},"end":{"line":47,"column":3}},"line":21},"2":{"name":"(anonymous_2)","decl":{"start":{"line":49,"column":2},"end":{"line":49,"column":3}},"loc":{"start":{"line":49,"column":32},"end":{"line":53,"column":3}},"line":49},"3":{"name":"(anonymous_3)","decl":{"start":{"line":55,"column":2},"end":{"line":55,"column":3}},"loc":{"start":{"line":55,"column":36},"end":{"line":59,"column":3}},"line":55},"4":{"name":"(anonymous_4)","decl":{"start":{"line":61,"column":2},"end":{"line":61,"column":3}},"loc":{"start":{"line":61,"column":55},"end":{"line":67,"column":3}},"line":61},"5":{"name":"(anonymous_5)","decl":{"start":{"line":69,"column":2},"end":{"line":69,"column":3}},"loc":{"start":{"line":69,"column":38},"end":{"line":76,"column":3}},"line":69},"6":{"name":"(anonymous_6)","decl":{"start":{"line":78,"column":2},"end":{"line":78,"column":3}},"loc":{"start":{"line":78,"column":32},"end":{"line":81,"column":3}},"line":78},"7":{"name":"(anonymous_7)","decl":{"start":{"line":83,"column":2},"end":{"line":83,"column":3}},"loc":{"start":{"line":83,"column":43},"end":{"line":103,"column":3}},"line":83},"8":{"name":"(anonymous_8)","decl":{"start":{"line":105,"column":2},"end":{"line":105,"column":3}},"loc":{"start":{"line":105,"column":47},"end":{"line":108,"column":3}},"line":105},"9":{"name":"(anonymous_9)","decl":{"start":{"line":110,"column":2},"end":{"line":110,"column":3}},"loc":{"start":{"line":110,"column":42},"end":{"line":117,"column":3}},"line":110},"10":{"name":"(anonymous_10)","decl":{"start":{"line":114,"column":66},"end":{"line":114,"column":67}},"loc":{"start":{"line":114,"column":78},"end":{"line":114,"column":80}},"line":114},"11":{"name":"(anonymous_11)","decl":{"start":{"line":119,"column":2},"end":{"line":119,"column":3}},"loc":{"start":{"line":119,"column":42},"end":{"line":126,"column":3}},"line":119},"12":{"name":"(anonymous_12)","decl":{"start":{"line":123,"column":65},"end":{"line":123,"column":66}},"loc":{"start":{"line":123,"column":77},"end":{"line":123,"column":79}},"line":123},"13":{"name":"(anonymous_13)","decl":{"start":{"line":128,"column":2},"end":{"line":128,"column":3}},"loc":{"start":{"line":128,"column":42},"end":{"line":135,"column":3}},"line":128},"14":{"name":"(anonymous_14)","decl":{"start":{"line":130,"column":50},"end":{"line":130,"column":51}},"loc":{"start":{"line":130,"column":62},"end":{"line":130,"column":64}},"line":130},"15":{"name":"(anonymous_15)","decl":{"start":{"line":132,"column":65},"end":{"line":132,"column":66}},"loc":{"start":{"line":132,"column":77},"end":{"line":132,"column":79}},"line":132},"16":{"name":"(anonymous_16)","decl":{"start":{"line":137,"column":2},"end":{"line":137,"column":3}},"loc":{"start":{"line":137,"column":52},"end":{"line":145,"column":3}},"line":137},"17":{"name":"(anonymous_17)","decl":{"start":{"line":147,"column":2},"end":{"line":147,"column":3}},"loc":{"start":{"line":147,"column":30},"end":{"line":173,"column":3}},"line":147},"18":{"name":"(anonymous_18)","decl":{"start":{"line":175,"column":2},"end":{"line":175,"column":3}},"loc":{"start":{"line":175,"column":48},"end":{"line":177,"column":3}},"line":175},"19":{"name":"(anonymous_19)","decl":{"start":{"line":179,"column":2},"end":{"line":179,"column":3}},"loc":{"start":{"line":179,"column":28},"end":{"line":197,"column":3}},"line":179},"20":{"name":"(anonymous_20)","decl":{"start":{"line":199,"column":2},"end":{"line":199,"column":3}},"loc":{"start":{"line":199,"column":50},"end":{"line":218,"column":3}},"line":199},"21":{"name":"(anonymous_21)","decl":{"start":{"line":220,"column":2},"end":{"line":220,"column":3}},"loc":{"start":{"line":220,"column":39},"end":{"line":240,"column":3}},"line":220},"22":{"name":"(anonymous_22)","decl":{"start":{"line":245,"column":11},"end":{"line":245,"column":12}},"loc":{"start":{"line":245,"column":27},"end":{"line":245,"column":55}},"line":245}},"branchMap":{"0":{"loc":{"start":{"line":22,"column":4},"end":{"line":25,"column":5}},"type":"if","locations":[{"start":{"line":22,"column":4},"end":{"line":25,"column":5}},{"start":{},"end":{}}],"line":22},"1":{"loc":{"start":{"line":27,"column":4},"end":{"line":30,"column":5}},"type":"if","locations":[{"start":{"line":27,"column":4},"end":{"line":30,"column":5}},{"start":{},"end":{}}],"line":27},"2":{"loc":{"start":{"line":32,"column":4},"end":{"line":37,"column":5}},"type":"if","locations":[{"start":{"line":32,"column":4},"end":{"line":37,"column":5}},{"start":{},"end":{}}],"line":32},"3":{"loc":{"start":{"line":39,"column":4},"end":{"line":44,"column":5}},"type":"if","locations":[{"start":{"line":39,"column":4},"end":{"line":44,"column":5}},{"start":{},"end":{}}],"line":39},"4":{"loc":{"start":{"line":65,"column":10},"end":{"line":65,"column":48}},"type":"binary-expr","locations":[{"start":{"line":65,"column":10},"end":{"line":65,"column":25}},{"start":{"line":65,"column":29},"end":{"line":65,"column":48}}],"line":65},"5":{"loc":{"start":{"line":83,"column":31},"end":{"line":83,"column":41}},"type":"default-arg","locations":[{"start":{"line":83,"column":40},"end":{"line":83,"column":41}}],"line":83},"6":{"loc":{"start":{"line":91,"column":4},"end":{"line":100,"column":5}},"type":"if","locations":[{"start":{"line":91,"column":4},"end":{"line":100,"column":5}},{"start":{},"end":{}}],"line":91},"7":{"loc":{"start":{"line":138,"column":4},"end":{"line":140,"column":5}},"type":"if","locations":[{"start":{"line":138,"column":4},"end":{"line":140,"column":5}},{"start":{},"end":{}}],"line":138},"8":{"loc":{"start":{"line":138,"column":8},"end":{"line":138,"column":62}},"type":"binary-expr","locations":[{"start":{"line":138,"column":8},"end":{"line":138,"column":15}},{"start":{"line":138,"column":19},"end":{"line":138,"column":26}},{"start":{"line":138,"column":30},"end":{"line":138,"column":62}}],"line":138},"9":{"loc":{"start":{"line":150,"column":4},"end":{"line":152,"column":5}},"type":"if","locations":[{"start":{"line":150,"column":4},"end":{"line":152,"column":5}},{"start":{},"end":{}}],"line":150},"10":{"loc":{"start":{"line":186,"column":4},"end":{"line":188,"column":5}},"type":"if","locations":[{"start":{"line":186,"column":4},"end":{"line":188,"column":5}},{"start":{},"end":{}}],"line":186},"11":{"loc":{"start":{"line":202,"column":4},"end":{"line":204,"column":5}},"type":"if","locations":[{"start":{"line":202,"column":4},"end":{"line":204,"column":5}},{"start":{},"end":{}}],"line":202},"12":{"loc":{"start":{"line":223,"column":4},"end":{"line":225,"column":5}},"type":"if","locations":[{"start":{"line":223,"column":4},"end":{"line":225,"column":5}},{"start":{},"end":{}}],"line":223}},"s":{"0":1,"1":1,"2":20,"3":20,"4":20,"5":20,"6":20,"7":20,"8":6,"9":1,"10":1,"11":5,"12":1,"13":1,"14":4,"15":1,"16":1,"17":3,"18":1,"19":1,"20":2,"21":1,"22":1,"23":1,"24":2,"25":2,"26":2,"27":2,"28":1,"29":1,"30":2,"31":2,"32":1,"33":1,"34":1,"35":2,"36":2,"37":2,"38":2,"39":2,"40":2,"41":2,"42":2,"43":2,"44":2,"45":2,"46":2,"47":1,"48":1,"49":1,"50":1,"51":1,"52":1,"53":5,"54":2,"55":3,"56":3,"57":1,"58":1,"59":0,"60":1,"61":1,"62":1,"63":1,"64":1,"65":1,"66":1,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":1,"93":0},"f":{"0":20,"1":6,"2":1,"3":1,"4":1,"5":2,"6":1,"7":2,"8":2,"9":2,"10":2,"11":2,"12":2,"13":1,"14":1,"15":1,"16":5,"17":1,"18":0,"19":0,"20":0,"21":0,"22":0},"b":{"0":[1,5],"1":[1,4],"2":[1,3],"3":[1,2],"4":[1,1],"5":[1],"6":[1,1],"7":[2,3],"8":[5,5,4],"9":[0,1],"10":[0,0],"11":[0,0],"12":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"e7f64fdd3f0fc398634ff30f3c47605992873717"} -,"/Users/ldemorais/Projects/integrations/strapi-test/src/plugins/orama-plugin-strapi/utils/schema.js": {"path":"/Users/ldemorais/Projects/integrations/strapi-test/src/plugins/orama-plugin-strapi/utils/schema.js","statementMap":{"0":{"start":{"line":1,"column":32},"end":{"line":15,"column":1}},"1":{"start":{"line":2,"column":2},"end":{"line":14,"column":8}},"2":{"start":{"line":3,"column":4},"end":{"line":12,"column":5}},"3":{"start":{"line":4,"column":30},"end":{"line":4,"column":46}},"4":{"start":{"line":5,"column":6},"end":{"line":7,"column":7}},"5":{"start":{"line":6,"column":8},"end":{"line":6,"column":24}},"6":{"start":{"line":9,"column":6},"end":{"line":9,"column":48}},"7":{"start":{"line":11,"column":6},"end":{"line":11,"column":32}},"8":{"start":{"line":13,"column":4},"end":{"line":13,"column":14}},"9":{"start":{"line":17,"column":40},"end":{"line":26,"column":1}},"10":{"start":{"line":18,"column":2},"end":{"line":25,"column":8}},"11":{"start":{"line":19,"column":4},"end":{"line":23,"column":5}},"12":{"start":{"line":20,"column":6},"end":{"line":20,"column":78}},"13":{"start":{"line":20,"column":47},"end":{"line":20,"column":77}},"14":{"start":{"line":22,"column":6},"end":{"line":22,"column":24}},"15":{"start":{"line":24,"column":4},"end":{"line":24,"column":14}},"16":{"start":{"line":28,"column":0},"end":{"line":28,"column":77}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":1,"column":32},"end":{"line":1,"column":33}},"loc":{"start":{"line":1,"column":60},"end":{"line":15,"column":1}},"line":1},"1":{"name":"(anonymous_1)","decl":{"start":{"line":2,"column":27},"end":{"line":2,"column":28}},"loc":{"start":{"line":2,"column":43},"end":{"line":14,"column":3}},"line":2},"2":{"name":"(anonymous_2)","decl":{"start":{"line":17,"column":40},"end":{"line":17,"column":41}},"loc":{"start":{"line":17,"column":56},"end":{"line":26,"column":1}},"line":17},"3":{"name":"(anonymous_3)","decl":{"start":{"line":18,"column":39},"end":{"line":18,"column":40}},"loc":{"start":{"line":18,"column":72},"end":{"line":25,"column":3}},"line":18},"4":{"name":"(anonymous_4)","decl":{"start":{"line":20,"column":38},"end":{"line":20,"column":39}},"loc":{"start":{"line":20,"column":47},"end":{"line":20,"column":77}},"line":20}},"branchMap":{"0":{"loc":{"start":{"line":3,"column":4},"end":{"line":12,"column":5}},"type":"if","locations":[{"start":{"line":3,"column":4},"end":{"line":12,"column":5}},{"start":{"line":10,"column":11},"end":{"line":12,"column":5}}],"line":3},"1":{"loc":{"start":{"line":5,"column":6},"end":{"line":7,"column":7}},"type":"if","locations":[{"start":{"line":5,"column":6},"end":{"line":7,"column":7}},{"start":{},"end":{}}],"line":5},"2":{"loc":{"start":{"line":19,"column":4},"end":{"line":23,"column":5}},"type":"if","locations":[{"start":{"line":19,"column":4},"end":{"line":23,"column":5}},{"start":{"line":21,"column":11},"end":{"line":23,"column":5}}],"line":19}},"s":{"0":1,"1":1,"2":2,"3":0,"4":0,"5":0,"6":0,"7":2,"8":2,"9":1,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":1},"f":{"0":1,"1":2,"2":0,"3":0,"4":0},"b":{"0":[0,2],"1":[0,0],"2":[0,0]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"89e12d9bcecfa8816241c43f77ef283b899493f0"} -} diff --git a/coverage/lcov-report/base.css b/coverage/lcov-report/base.css deleted file mode 100644 index f418035..0000000 --- a/coverage/lcov-report/base.css +++ /dev/null @@ -1,224 +0,0 @@ -body, html { - margin:0; padding: 0; - height: 100%; -} -body { - font-family: Helvetica Neue, Helvetica, Arial; - font-size: 14px; - color:#333; -} -.small { font-size: 12px; } -*, *:after, *:before { - -webkit-box-sizing:border-box; - -moz-box-sizing:border-box; - box-sizing:border-box; - } -h1 { font-size: 20px; margin: 0;} -h2 { font-size: 14px; } -pre { - font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; - margin: 0; - padding: 0; - -moz-tab-size: 2; - -o-tab-size: 2; - tab-size: 2; -} -a { color:#0074D9; text-decoration:none; } -a:hover { text-decoration:underline; } -.strong { font-weight: bold; } -.space-top1 { padding: 10px 0 0 0; } -.pad2y { padding: 20px 0; } -.pad1y { padding: 10px 0; } -.pad2x { padding: 0 20px; } -.pad2 { padding: 20px; } -.pad1 { padding: 10px; } -.space-left2 { padding-left:55px; } -.space-right2 { padding-right:20px; } -.center { text-align:center; } -.clearfix { display:block; } -.clearfix:after { - content:''; - display:block; - height:0; - clear:both; - visibility:hidden; - } -.fl { float: left; } -@media only screen and (max-width:640px) { - .col3 { width:100%; max-width:100%; } - .hide-mobile { display:none!important; } -} - -.quiet { - color: #7f7f7f; - color: rgba(0,0,0,0.5); -} -.quiet a { opacity: 0.7; } - -.fraction { - font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; - font-size: 10px; - color: #555; - background: #E8E8E8; - padding: 4px 5px; - border-radius: 3px; - vertical-align: middle; -} - -div.path a:link, div.path a:visited { color: #333; } -table.coverage { - border-collapse: collapse; - margin: 10px 0 0 0; - padding: 0; -} - -table.coverage td { - margin: 0; - padding: 0; - vertical-align: top; -} -table.coverage td.line-count { - text-align: right; - padding: 0 5px 0 20px; -} -table.coverage td.line-coverage { - text-align: right; - padding-right: 10px; - min-width:20px; -} - -table.coverage td span.cline-any { - display: inline-block; - padding: 0 5px; - width: 100%; -} -.missing-if-branch { - display: inline-block; - margin-right: 5px; - border-radius: 3px; - position: relative; - padding: 0 4px; - background: #333; - color: yellow; -} - -.skip-if-branch { - display: none; - margin-right: 10px; - position: relative; - padding: 0 4px; - background: #ccc; - color: white; -} -.missing-if-branch .typ, .skip-if-branch .typ { - color: inherit !important; -} -.coverage-summary { - border-collapse: collapse; - width: 100%; -} -.coverage-summary tr { border-bottom: 1px solid #bbb; } -.keyline-all { border: 1px solid #ddd; } -.coverage-summary td, .coverage-summary th { padding: 10px; } -.coverage-summary tbody { border: 1px solid #bbb; } -.coverage-summary td { border-right: 1px solid #bbb; } -.coverage-summary td:last-child { border-right: none; } -.coverage-summary th { - text-align: left; - font-weight: normal; - white-space: nowrap; -} -.coverage-summary th.file { border-right: none !important; } -.coverage-summary th.pct { } -.coverage-summary th.pic, -.coverage-summary th.abs, -.coverage-summary td.pct, -.coverage-summary td.abs { text-align: right; } -.coverage-summary td.file { white-space: nowrap; } -.coverage-summary td.pic { min-width: 120px !important; } -.coverage-summary tfoot td { } - -.coverage-summary .sorter { - height: 10px; - width: 7px; - display: inline-block; - margin-left: 0.5em; - background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; -} -.coverage-summary .sorted .sorter { - background-position: 0 -20px; -} -.coverage-summary .sorted-desc .sorter { - background-position: 0 -10px; -} -.status-line { height: 10px; } -/* yellow */ -.cbranch-no { background: yellow !important; color: #111; } -/* dark red */ -.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } -.low .chart { border:1px solid #C21F39 } -.highlighted, -.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ - background: #C21F39 !important; -} -/* medium red */ -.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } -/* light red */ -.low, .cline-no { background:#FCE1E5 } -/* light green */ -.high, .cline-yes { background:rgb(230,245,208) } -/* medium green */ -.cstat-yes { background:rgb(161,215,106) } -/* dark green */ -.status-line.high, .high .cover-fill { background:rgb(77,146,33) } -.high .chart { border:1px solid rgb(77,146,33) } -/* dark yellow (gold) */ -.status-line.medium, .medium .cover-fill { background: #f9cd0b; } -.medium .chart { border:1px solid #f9cd0b; } -/* light yellow */ -.medium { background: #fff4c2; } - -.cstat-skip { background: #ddd; color: #111; } -.fstat-skip { background: #ddd; color: #111 !important; } -.cbranch-skip { background: #ddd !important; color: #111; } - -span.cline-neutral { background: #eaeaea; } - -.coverage-summary td.empty { - opacity: .5; - padding-top: 4px; - padding-bottom: 4px; - line-height: 1; - color: #888; -} - -.cover-fill, .cover-empty { - display:inline-block; - height: 12px; -} -.chart { - line-height: 0; -} -.cover-empty { - background: white; -} -.cover-full { - border-right: none !important; -} -pre.prettyprint { - border: none !important; - padding: 0 !important; - margin: 0 !important; -} -.com { color: #999 !important; } -.ignore-none { color: #999; font-weight: normal; } - -.wrapper { - min-height: 100%; - height: auto !important; - height: 100%; - margin: 0 auto -48px; -} -.footer, .push { - height: 48px; -} diff --git a/coverage/lcov-report/block-navigation.js b/coverage/lcov-report/block-navigation.js deleted file mode 100644 index cc12130..0000000 --- a/coverage/lcov-report/block-navigation.js +++ /dev/null @@ -1,87 +0,0 @@ -/* eslint-disable */ -var jumpToCode = (function init() { - // Classes of code we would like to highlight in the file view - var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; - - // Elements to highlight in the file listing view - var fileListingElements = ['td.pct.low']; - - // We don't want to select elements that are direct descendants of another match - var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` - - // Selecter that finds elements on the page to which we can jump - var selector = - fileListingElements.join(', ') + - ', ' + - notSelector + - missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` - - // The NodeList of matching elements - var missingCoverageElements = document.querySelectorAll(selector); - - var currentIndex; - - function toggleClass(index) { - missingCoverageElements - .item(currentIndex) - .classList.remove('highlighted'); - missingCoverageElements.item(index).classList.add('highlighted'); - } - - function makeCurrent(index) { - toggleClass(index); - currentIndex = index; - missingCoverageElements.item(index).scrollIntoView({ - behavior: 'smooth', - block: 'center', - inline: 'center' - }); - } - - function goToPrevious() { - var nextIndex = 0; - if (typeof currentIndex !== 'number' || currentIndex === 0) { - nextIndex = missingCoverageElements.length - 1; - } else if (missingCoverageElements.length > 1) { - nextIndex = currentIndex - 1; - } - - makeCurrent(nextIndex); - } - - function goToNext() { - var nextIndex = 0; - - if ( - typeof currentIndex === 'number' && - currentIndex < missingCoverageElements.length - 1 - ) { - nextIndex = currentIndex + 1; - } - - makeCurrent(nextIndex); - } - - return function jump(event) { - if ( - document.getElementById('fileSearch') === document.activeElement && - document.activeElement != null - ) { - // if we're currently focused on the search input, we don't want to navigate - return; - } - - switch (event.which) { - case 78: // n - case 74: // j - goToNext(); - break; - case 66: // b - case 75: // k - case 80: // p - goToPrevious(); - break; - } - }; -})(); -window.addEventListener('keydown', jumpToCode); diff --git a/coverage/lcov-report/content-types.js.html b/coverage/lcov-report/content-types.js.html deleted file mode 100644 index ee57c7c..0000000 --- a/coverage/lcov-report/content-types.js.html +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - Code coverage report for content-types.js - - - - - - - - - -
-
-

All files content-types.js

-
- -
- 100% - Statements - 45/45 -
- - -
- 86.36% - Branches - 19/22 -
- - -
- 100% - Functions - 21/21 -
- - -
- 100% - Lines - 42/42 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -3x -2x -  -3x -  -  -  -1x -16x -  -  -16x -  -1x -6x -  -  -  -  -1x -16x -  -  -  -  -  -  -1x -2x -1x -1x -  -1x -  -  -1x -3x -  -1x -1x -  -1x -  -  -  -2x -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -2x -  -2x -  -  -  -  -  -  -  -  -2x -2x -8x -  -  -  -  -  -  -  -  -  -2x -  -  -  -  -  -8x -  -  -2x -  -  -  -12x -2x -  -  -  -  -  -10x -  -  -  -4x -16x -  -  -  -  -  -  -  -  -  -12x -  -16x -  -  -  -  -2x -2x -  -  -  -  -  -  - 
'use strict'
- 
-const OramaTypesMap = {
-  string: 'string',
-  text: 'string',
-  email: 'string',
-  richtext: 'string',
-  boolean: 'boolean',
-  integer: 'number',
-  biginteger: 'number',
-  decimal: 'number',
-  float: 'number',
-  uid: 'string',
-  date: 'string',
-  time: 'string',
-  datetime: 'string',
-  enumeration: 'enum'
-}
- 
-const filterContentTypesAPIs = ({ contentTypes }) => {
-  return Object.keys(contentTypes).reduce((sanitized, contentType) => {
-    if (contentType.startsWith('api::')) {
-      sanitized[contentType] = contentTypes[contentType]
-    }
-    return sanitized
-  }, {})
-}
- 
-const isValidType = (type) => {
-  return !['component', 'media', 'blocks', 'json', 'password'].includes(type)
-}
- 
-const isIgnoredAttribute = (attribute) => ['publishedAt', 'createdAt', 'updatedAt'].includes(attribute.name)
- 
-const isValidRelation = ({ attribute, includedRelations }) => {
-  return (
-    attribute.target.startsWith('api::') && (includedRelations.includes(attribute.name) || includedRelations === '*')
-  )
-}
- 
-const shouldAttributeBeIncluded = (attribute, includedRelations) => {
-  return (
-    isValidType(attribute.type) &&
-    !isIgnoredAttribute(attribute) &&
-    (attribute.type !== 'relation' || isValidRelation({ attribute, includedRelations }))
-  )
-}
- 
-const getSelectedRelations = ({ schema, relations }) => {
-  return relations.reduce((acc, relation) => {
-    acc[relation] = {
-      select: Object.keys(schema[relation]).map((key) => key)
-    }
-    return acc
-  }, {})
-}
-const getSelectedFieldsConfigObj = (schema) =>
-  Object.entries(schema).reduce((acc, [key, value]) => (typeof value === 'object' ? acc : [...acc, key]), ['id'])
- 
-module.exports = ({ strapi }) => {
-  return {
-    getContentTypes() {
-      const contentTypes = filterContentTypesAPIs({
-        contentTypes: strapi.contentTypes
-      })
- 
-      return Object.entries(contentTypes).map(([contentType, c]) => ({
-        value: contentType,
-        label: c.info.displayName,
-        schema: this.getSchemaFromContentTypeAttributes({
-          attributes: c.attributes,
-          includedRelations: '*'
-        }),
-        availableRelations: this.getAvailableRelations({
-          contentTypeId: contentType
-        })
-      }))
-    },
- 
-    async getEntries({ contentType, relations = [], schema, offset = 0, limit = 50 }) {
-      const selectedRelations = getSelectedRelations({ schema, relations })
-      const selectedFields = getSelectedFieldsConfigObj(schema)
- 
-      return await strapi.query(contentType).findMany({
-        populate: selectedRelations,
-        select: selectedFields,
-        limit,
-        offset
-      })
-    },
- 
-    getAvailableRelations({ contentTypeId }) {
-      const contentType = strapi.contentTypes[contentTypeId]
-      const res = Object.entries(contentType.attributes).reduce((relations, [attributeName, attributeValue]) => {
-        if (
-          attributeValue.type === 'relation' &&
-          isValidRelation({
-            attribute: {
-              name: attributeName,
-              target: attributeValue.target
-            },
-            includedRelations: '*'
-          })
-        ) {
-          relations.push({
-            value: attributeName,
-            label: attributeValue.target
-          })
-        }
- 
-        return relations
-      }, [])
- 
-      return res
-    },
- 
-    getType(attribute) {
-      if (attribute.type === 'relation') {
-        return this.getContentTypeSchema({
-          contentTypeId: attribute.target,
-          includedRelations: []
-        })
-      }
- 
-      return OramaTypesMap[attribute.type]
-    },
- 
-    getSchemaFromContentTypeAttributes({ attributes, includedRelations }) {
-      return Object.entries(attributes).reduce((schema, [attributeName, attributeValue]) => {
-        if (
-          shouldAttributeBeIncluded(
-            {
-              type: attributeValue.type,
-              name: attributeName,
-              target: attributeValue.target
-            },
-            includedRelations
-          )
-        ) {
-          schema[attributeName] = this.getType(attributeValue)
-        }
-        return schema
-      }, {})
-    },
- 
-    getContentTypeSchema({ contentTypeId, includedRelations }) {
-      const contentType = strapi.contentTypes[contentTypeId]
-      return this.getSchemaFromContentTypeAttributes({
-        attributes: contentType.attributes,
-        includedRelations
-      })
-    }
-  }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/favicon.png b/coverage/lcov-report/favicon.png deleted file mode 100644 index c1525b8..0000000 Binary files a/coverage/lcov-report/favicon.png and /dev/null differ diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html deleted file mode 100644 index 4eb1c7d..0000000 --- a/coverage/lcov-report/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Code coverage report for All files - - - - - - - - - -
-
-

All files

-
- -
- 76.28% - Statements - 119/156 -
- - -
- 72.22% - Branches - 39/54 -
- - -
- 83.67% - Functions - 41/49 -
- - -
- 75.67% - Lines - 112/148 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
server/services -
-
80.57%112/13979.16%38/4888.63%39/4479.54%105/132
utils -
-
41.17%7/1716.66%1/640%2/543.75%7/16
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/prettify.css b/coverage/lcov-report/prettify.css deleted file mode 100644 index b317a7c..0000000 --- a/coverage/lcov-report/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/lcov-report/prettify.js b/coverage/lcov-report/prettify.js deleted file mode 100644 index b322523..0000000 --- a/coverage/lcov-report/prettify.js +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable */ -window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/lcov-report/server/services/content-types.js.html b/coverage/lcov-report/server/services/content-types.js.html deleted file mode 100644 index 6274b06..0000000 --- a/coverage/lcov-report/server/services/content-types.js.html +++ /dev/null @@ -1,547 +0,0 @@ - - - - - - Code coverage report for server/services/content-types.js - - - - - - - - - -
-
-

All files / server/services content-types.js

-
- -
- 100% - Statements - 45/45 -
- - -
- 86.36% - Branches - 19/22 -
- - -
- 100% - Functions - 21/21 -
- - -
- 100% - Lines - 42/42 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -1x -3x -2x -  -3x -  -  -  -1x -16x -  -  -16x -  -1x -6x -  -  -  -  -1x -16x -  -  -  -  -  -  -1x -2x -1x -1x -  -1x -  -  -1x -3x -  -1x -1x -  -1x -  -  -  -2x -  -  -  -  -  -  -  -  -  -  -  -  -  -2x -2x -  -2x -  -  -  -  -  -  -  -  -2x -2x -8x -  -  -  -  -  -  -  -  -  -2x -  -  -  -  -  -8x -  -  -2x -  -  -  -12x -2x -  -  -  -  -  -10x -  -  -  -4x -16x -  -  -  -  -  -  -  -  -  -12x -  -16x -  -  -  -  -2x -2x -  -  -  -  -  -  - 
'use strict'
- 
-const OramaTypesMap = {
-  string: 'string',
-  text: 'string',
-  email: 'string',
-  richtext: 'string',
-  boolean: 'boolean',
-  integer: 'number',
-  biginteger: 'number',
-  decimal: 'number',
-  float: 'number',
-  uid: 'string',
-  date: 'string',
-  time: 'string',
-  datetime: 'string',
-  enumeration: 'enum'
-}
- 
-const filterContentTypesAPIs = ({ contentTypes }) => {
-  return Object.keys(contentTypes).reduce((sanitized, contentType) => {
-    if (contentType.startsWith('api::')) {
-      sanitized[contentType] = contentTypes[contentType]
-    }
-    return sanitized
-  }, {})
-}
- 
-const isValidType = (type) => {
-  return !['component', 'media', 'blocks', 'json', 'password'].includes(type)
-}
- 
-const isIgnoredAttribute = (attribute) => ['publishedAt', 'createdAt', 'updatedAt'].includes(attribute.name)
- 
-const isValidRelation = ({ attribute, includedRelations }) => {
-  return (
-    attribute.target.startsWith('api::') && (includedRelations.includes(attribute.name) || includedRelations === '*')
-  )
-}
- 
-const shouldAttributeBeIncluded = (attribute, includedRelations) => {
-  return (
-    isValidType(attribute.type) &&
-    !isIgnoredAttribute(attribute) &&
-    (attribute.type !== 'relation' || isValidRelation({ attribute, includedRelations }))
-  )
-}
- 
-const getSelectedRelations = ({ schema, relations }) => {
-  return relations.reduce((acc, relation) => {
-    acc[relation] = {
-      select: Object.keys(schema[relation]).map((key) => key)
-    }
-    return acc
-  }, {})
-}
-const getSelectedFieldsConfigObj = (schema) =>
-  Object.entries(schema).reduce((acc, [key, value]) => (typeof value === 'object' ? acc : [...acc, key]), ['id'])
- 
-module.exports = ({ strapi }) => {
-  return {
-    getContentTypes() {
-      const contentTypes = filterContentTypesAPIs({
-        contentTypes: strapi.contentTypes
-      })
- 
-      return Object.entries(contentTypes).map(([contentType, c]) => ({
-        value: contentType,
-        label: c.info.displayName,
-        schema: this.getSchemaFromContentTypeAttributes({
-          attributes: c.attributes,
-          includedRelations: '*'
-        }),
-        availableRelations: this.getAvailableRelations({
-          contentTypeId: contentType
-        })
-      }))
-    },
- 
-    async getEntries({ contentType, relations = [], schema, offset = 0, limit = 50 }) {
-      const selectedRelations = getSelectedRelations({ schema, relations })
-      const selectedFields = getSelectedFieldsConfigObj(schema)
- 
-      return await strapi.query(contentType).findMany({
-        populate: selectedRelations,
-        select: selectedFields,
-        limit,
-        offset
-      })
-    },
- 
-    getAvailableRelations({ contentTypeId }) {
-      const contentType = strapi.contentTypes[contentTypeId]
-      const res = Object.entries(contentType.attributes).reduce((relations, [attributeName, attributeValue]) => {
-        if (
-          attributeValue.type === 'relation' &&
-          isValidRelation({
-            attribute: {
-              name: attributeName,
-              target: attributeValue.target
-            },
-            includedRelations: '*'
-          })
-        ) {
-          relations.push({
-            value: attributeName,
-            label: attributeValue.target
-          })
-        }
- 
-        return relations
-      }, [])
- 
-      return res
-    },
- 
-    getType(attribute) {
-      if (attribute.type === 'relation') {
-        return this.getContentTypeSchema({
-          contentTypeId: attribute.target,
-          includedRelations: []
-        })
-      }
- 
-      return OramaTypesMap[attribute.type]
-    },
- 
-    getSchemaFromContentTypeAttributes({ attributes, includedRelations }) {
-      return Object.entries(attributes).reduce((schema, [attributeName, attributeValue]) => {
-        if (
-          shouldAttributeBeIncluded(
-            {
-              type: attributeValue.type,
-              name: attributeName,
-              target: attributeValue.target
-            },
-            includedRelations
-          )
-        ) {
-          schema[attributeName] = this.getType(attributeValue)
-        }
-        return schema
-      }, {})
-    },
- 
-    getContentTypeSchema({ contentTypeId, includedRelations }) {
-      const contentType = strapi.contentTypes[contentTypeId]
-      return this.getSchemaFromContentTypeAttributes({
-        attributes: contentType.attributes,
-        includedRelations
-      })
-    }
-  }
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/server/services/index.html b/coverage/lcov-report/server/services/index.html deleted file mode 100644 index 3eaea20..0000000 --- a/coverage/lcov-report/server/services/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Code coverage report for server/services - - - - - - - - - -
-
-

All files server/services

-
- -
- 80.57% - Statements - 112/139 -
- - -
- 79.16% - Branches - 38/48 -
- - -
- 88.63% - Functions - 39/44 -
- - -
- 79.54% - Lines - 105/132 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
content-types.js -
-
100%45/4586.36%19/22100%21/21100%42/42
orama-manager.js -
-
71.27%67/9473.07%19/2678.26%18/2370%63/90
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/server/services/orama-manager.js.html b/coverage/lcov-report/server/services/orama-manager.js.html deleted file mode 100644 index 9da2061..0000000 --- a/coverage/lcov-report/server/services/orama-manager.js.html +++ /dev/null @@ -1,823 +0,0 @@ - - - - - - Code coverage report for server/services/orama-manager.js - - - - - - - - - -
-
-

All files / server/services orama-manager.js

-
- -
- 71.27% - Statements - 67/94 -
- - -
- 73.07% - Branches - 19/26 -
- - -
- 78.26% - Functions - 18/23 -
- - -
- 70% - Lines - 63/90 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 -180 -181 -182 -183 -184 -185 -186 -187 -188 -189 -190 -191 -192 -193 -194 -195 -196 -197 -198 -199 -200 -201 -202 -203 -204 -205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247  -  -1x -1x -  -  -  -20x -20x -20x -20x -  -20x -20x -  -  -  -  -  -  -  -6x -1x -1x -  -  -5x -1x -1x -  -  -4x -1x -  -  -1x -  -  -3x -1x -  -  -1x -  -  -2x -  -  -  -1x -  -  -  -  -  -1x -  -  -  -  -  -1x -  -  -  -  -  -  -  -2x -2x -  -2x -  -2x -  -  -  -1x -1x -  -  -  -2x -  -  -  -  -  -  -2x -1x -  -  -  -  -  -  -1x -  -  -1x -  -  -  -2x -2x -  -  -  -2x -2x -  -2x -  -2x -  -  -  -2x -2x -  -2x -  -2x -  -  -  -1x -1x -  -1x -  -1x -  -  -  -5x -2x -  -  -3x -  -3x -  -  -  -1x -  -1x -  -  -  -1x -  -  -  -  -1x -  -1x -  -1x -  -  -  -  -1x -  -1x -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -1x -  -  -  - 
"use strict"
- 
-const { CloudManager } = require("@oramacloud/client")
-const { getSchemaFromAttributes } = require("../../utils/schema")
- 
-class OramaManager {
-  constructor({ strapi }) {
-    this.strapi = strapi
-    this.contentTypesService = strapi.plugin("orama-cloud").service("contentTypesService")
-    this.collectionService = strapi.plugin("orama-cloud").service("collectionsService")
-    this.privateApiKey = strapi.config.get("plugin.orama-cloud.privateApiKey")
- 
-    this.oramaCloudManager = new CloudManager({ api_key: this.privateApiKey })
-    this.DocumentActionsMap = {
-      create: this.oramaInsert.bind(this),
-      update: this.oramaUpdate.bind(this),
-      delete: this.oramaDelete.bind(this)
-    }
-  }
- 
-  validate(collection) {
-    if (!collection) {
-      this.strapi.log.error(`Collection not found`)
-      return false
-    }
- 
-    if (!this.privateApiKey) {
-      this.strapi.log.error("Private API key is required to process index updates")
-      return false
-    }
- 
-    if (collection.status === "updating") {
-      this.strapi.log.debug(
-        `SKIP: Collection ${collection.entity} with indexId ${collection.indexId} is already updating`
-      )
-      return false
-    }
- 
-    if (collection.status === "updated") {
-      this.strapi.log.debug(
-        `SKIP: Collection ${collection.entity} with indexId ${collection.indexId} is already updated`
-      )
-      return false
-    }
- 
-    return true
-  }
- 
-  async setOutdated(collection) {
-    return await this.collectionService.updateWithoutHooks(collection.id, {
-      status: "outdated"
-    })
-  }
- 
-  async updatingStarted(collection) {
-    return await this.collectionService.updateWithoutHooks(collection.id, {
-      status: "updating"
-    })
-  }
- 
-  async updatingCompleted(collection, documents_count) {
-    return await this.collectionService.updateWithoutHooks(collection.id, {
-      status: "updated",
-      deployed_at: new Date().getTime(),
-      ...(documents_count && { documents_count })
-    })
-  }
- 
-  async oramaDeployIndex({ indexId }) {
-    const index = this.oramaCloudManager.index(indexId)
-    const result = await index.deploy()
- 
-    this.strapi.log.info(`Index ${indexId} deployed`)
- 
-    return result
-  }
- 
-  async resetIndex({ indexId }) {
-    const index = this.oramaCloudManager.index(indexId)
-    return await index.snapshot([])
-  }
- 
-  async bulkInsert(collection, offset = 0) {
-    const entries = await this.contentTypesService.getEntries({
-      contentType: collection.entity,
-      relations: collection.includedRelations,
-      schema: collection.schema,
-      offset
-    })
- 
-    if (entries.length > 0) {
-      await this.oramaInsert(
-        {
-          indexId: collection.indexId,
-          entries
-        }
-      )
- 
-      return await this.bulkInsert(collection, offset + entries.length)
-    }
- 
-    return { documents_count: offset }
-  }
- 
-  async oramaUpdateSchema({ indexId, schema }) {
-    const index = this.oramaCloudManager.index(indexId)
-    await index.updateSchema({ schema })
-  }
- 
-  async oramaInsert({ indexId, entries }) {
-    const index = this.oramaCloudManager.index(indexId)
-    const result = await index.insert(entries)
- 
-    this.strapi.log.info(`INSERT: documents with id ${entries.map(({ id }) => id)} into index ${indexId}`)
- 
-    return result
-  }
- 
-  async oramaUpdate({ indexId, entries }) {
-    const index = this.oramaCloudManager.index(indexId)
-    const result = await index.update(entries)
- 
-    this.strapi.log.info(`UPDATE: document with id ${entries.map(({ id }) => id)} into index ${indexId}`)
- 
-    return result
-  }
- 
-  async oramaDelete({ indexId, entries }) {
-    const index = this.oramaCloudManager.index(indexId)
-    const result = await index.delete(entries.map(({ id }) => id))
- 
-    this.strapi.log.info(`DELETE: document with id ${entries.map(({ id }) => id)} from index ${indexId}`)
- 
-    return result
-  }
- 
-  async handleDocument({ indexId, record, action }) {
-    if (!action || !record || !this.DocumentActionsMap[action]) {
-      return false
-    }
- 
-    const { createdBy, updatedBy, ...rest } = record
- 
-    return await this.DocumentActionsMap[action]({ indexId, entries: [{ ...rest, id: rest.id.toString() }] })
-  }
- 
-  async populateIndex({ id }) {
-    const collection = await this.collectionService.findOne(id)
- 
-    Iif (!this.validate(collection)) {
-      return
-    }
- 
-    const oramaSchema = getSchemaFromAttributes({
-      attributes: collection.searchableAttributes,
-      schema: collection.schema
-    })
- 
-    await this.updatingStarted(collection)
- 
-    await this.resetIndex(collection)
- 
-    await this.oramaUpdateSchema({
-      indexId: collection.indexId,
-      schema: oramaSchema
-    })
- 
-    const { documents_count } = await this.bulkInsert(collection)
- 
-    await this.oramaDeployIndex(collection)
- 
-    await this.updatingCompleted(collection, documents_count)
-  }
- 
-  async afterCollectionCreationOrUpdate({ id }) {
-    await this.populateIndex({ id })
-  }
- 
-  async deployIndex({ id }) {
-    const collection = await this.collectionService.findOne(id)
- 
-    this.strapi.log.debug(
-      `Processing scheduled index update for ${collection.entity} with indexId ${collection.indexId}`
-    )
- 
-    if (!this.validate(collection)) {
-      return
-    }
- 
-    await this.updatingStarted(collection)
- 
-    await this.oramaDeployIndex(collection)
- 
-    await this.updatingCompleted(collection)
- 
-    this.strapi.log.debug(`UPDATE: ${collection.entity} with indexId ${collection.indexId} completed`)
-  }
- 
-  async processLiveUpdate({ id }, record, action) {
-    const collection = await this.collectionService.findOne(id)
- 
-    if (!this.validate(collection)) {
-      return
-    }
- 
-    this.strapi.log.debug(`Processing live update for ${collection.entity} with indexId ${collection.indexId}`)
- 
-    await this.updatingStarted(collection)
- 
-    await this.handleDocument(
-      {
-        indexId: collection.indexId,
-        record,
-        action
-      })
- 
-    this.strapi.log.debug(`Live update for ${collection.entity} with indexId ${collection.indexId} completed`)
-  }
- 
-  async processScheduledUpdate({ id }) {
-    const collection = await this.collectionService.findOne(id)
- 
-    if (!this.validate(collection)) {
-      return
-    }
- 
-    this.strapi.log.debug(
-      `Processing scheduled index update for ${collection.entity} with indexId ${collection.indexId}`
-    )
- 
-    await this.updatingStarted(collection)
- 
-    await this.resetIndex(collection)
- 
-    const { documents_count } = await this.bulkInsert(collection)
- 
-    await this.updatingCompleted(collection, documents_count)
- 
-    this.strapi.log.debug(`Scheduled update for ${collection.entity} with indexId ${collection.indexId} completed`)
-  }
-}
- 
-module.exports = {
-  OramaManager,
-  service: ({ strapi }) => new OramaManager({ strapi })
-}
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/sort-arrow-sprite.png b/coverage/lcov-report/sort-arrow-sprite.png deleted file mode 100644 index 6ed6831..0000000 Binary files a/coverage/lcov-report/sort-arrow-sprite.png and /dev/null differ diff --git a/coverage/lcov-report/sorter.js b/coverage/lcov-report/sorter.js deleted file mode 100644 index 2bb296a..0000000 --- a/coverage/lcov-report/sorter.js +++ /dev/null @@ -1,196 +0,0 @@ -/* eslint-disable */ -var addSorting = (function() { - 'use strict'; - var cols, - currentSort = { - index: 0, - desc: false - }; - - // returns the summary table element - function getTable() { - return document.querySelector('.coverage-summary'); - } - // returns the thead element of the summary table - function getTableHeader() { - return getTable().querySelector('thead tr'); - } - // returns the tbody element of the summary table - function getTableBody() { - return getTable().querySelector('tbody'); - } - // returns the th element for nth column - function getNthColumn(n) { - return getTableHeader().querySelectorAll('th')[n]; - } - - function onFilterInput() { - const searchValue = document.getElementById('fileSearch').value; - const rows = document.getElementsByTagName('tbody')[0].children; - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - if ( - row.textContent - .toLowerCase() - .includes(searchValue.toLowerCase()) - ) { - row.style.display = ''; - } else { - row.style.display = 'none'; - } - } - } - - // loads the search box - function addSearchBox() { - var template = document.getElementById('filterTemplate'); - var templateClone = template.content.cloneNode(true); - templateClone.getElementById('fileSearch').oninput = onFilterInput; - template.parentElement.appendChild(templateClone); - } - - // loads all columns - function loadColumns() { - var colNodes = getTableHeader().querySelectorAll('th'), - colNode, - cols = [], - col, - i; - - for (i = 0; i < colNodes.length; i += 1) { - colNode = colNodes[i]; - col = { - key: colNode.getAttribute('data-col'), - sortable: !colNode.getAttribute('data-nosort'), - type: colNode.getAttribute('data-type') || 'string' - }; - cols.push(col); - if (col.sortable) { - col.defaultDescSort = col.type === 'number'; - colNode.innerHTML = - colNode.innerHTML + ''; - } - } - return cols; - } - // attaches a data attribute to every tr element with an object - // of data values keyed by column name - function loadRowData(tableRow) { - var tableCols = tableRow.querySelectorAll('td'), - colNode, - col, - data = {}, - i, - val; - for (i = 0; i < tableCols.length; i += 1) { - colNode = tableCols[i]; - col = cols[i]; - val = colNode.getAttribute('data-value'); - if (col.type === 'number') { - val = Number(val); - } - data[col.key] = val; - } - return data; - } - // loads all row data - function loadData() { - var rows = getTableBody().querySelectorAll('tr'), - i; - - for (i = 0; i < rows.length; i += 1) { - rows[i].data = loadRowData(rows[i]); - } - } - // sorts the table using the data for the ith column - function sortByIndex(index, desc) { - var key = cols[index].key, - sorter = function(a, b) { - a = a.data[key]; - b = b.data[key]; - return a < b ? -1 : a > b ? 1 : 0; - }, - finalSorter = sorter, - tableBody = document.querySelector('.coverage-summary tbody'), - rowNodes = tableBody.querySelectorAll('tr'), - rows = [], - i; - - if (desc) { - finalSorter = function(a, b) { - return -1 * sorter(a, b); - }; - } - - for (i = 0; i < rowNodes.length; i += 1) { - rows.push(rowNodes[i]); - tableBody.removeChild(rowNodes[i]); - } - - rows.sort(finalSorter); - - for (i = 0; i < rows.length; i += 1) { - tableBody.appendChild(rows[i]); - } - } - // removes sort indicators for current column being sorted - function removeSortIndicators() { - var col = getNthColumn(currentSort.index), - cls = col.className; - - cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); - col.className = cls; - } - // adds sort indicators for current column being sorted - function addSortIndicators() { - getNthColumn(currentSort.index).className += currentSort.desc - ? ' sorted-desc' - : ' sorted'; - } - // adds event listeners for all sorter widgets - function enableUI() { - var i, - el, - ithSorter = function ithSorter(i) { - var col = cols[i]; - - return function() { - var desc = col.defaultDescSort; - - if (currentSort.index === i) { - desc = !currentSort.desc; - } - sortByIndex(i, desc); - removeSortIndicators(); - currentSort.index = i; - currentSort.desc = desc; - addSortIndicators(); - }; - }; - for (i = 0; i < cols.length; i += 1) { - if (cols[i].sortable) { - // add the click event handler on the th so users - // dont have to click on those tiny arrows - el = getNthColumn(i).querySelector('.sorter').parentElement; - if (el.addEventListener) { - el.addEventListener('click', ithSorter(i)); - } else { - el.attachEvent('onclick', ithSorter(i)); - } - } - } - } - // adds sorting functionality to the UI - return function() { - if (!getTable()) { - return; - } - cols = loadColumns(); - loadData(); - addSearchBox(); - addSortIndicators(); - enableUI(); - }; -})(); - -window.addEventListener('load', addSorting); diff --git a/coverage/lcov-report/utils/index.html b/coverage/lcov-report/utils/index.html deleted file mode 100644 index d414755..0000000 --- a/coverage/lcov-report/utils/index.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - Code coverage report for utils - - - - - - - - - -
-
-

All files utils

-
- -
- 41.17% - Statements - 7/17 -
- - -
- 16.66% - Branches - 1/6 -
- - -
- 40% - Functions - 2/5 -
- - -
- 43.75% - Lines - 7/16 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileStatementsBranchesFunctionsLines
schema.js -
-
41.17%7/1716.66%1/640%2/543.75%7/16
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov-report/utils/schema.js.html b/coverage/lcov-report/utils/schema.js.html deleted file mode 100644 index e49b8c4..0000000 --- a/coverage/lcov-report/utils/schema.js.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - Code coverage report for utils/schema.js - - - - - - - - - -
-
-

All files / utils schema.js

-
- -
- 41.17% - Statements - 7/17 -
- - -
- 16.66% - Branches - 1/6 -
- - -
- 40% - Functions - 2/5 -
- - -
- 43.75% - Lines - 7/16 -
- - -
-

- Press n or j to go to the next uncovered block, b, p or k for the previous block. -

- -
-
-

-
1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -291x -1x -2x -  -  -  -  -  -  -  -2x -  -2x -  -  -  -1x -  -  -  -  -  -  -  -  -  -  -1x - 
const getSchemaFromAttributes = ({ attributes, schema }) => {
-  return attributes.reduce((acc, field) => {
-    Iif (field.includes('.')) {
-      const [parent, child] = field.split('.')
-      if (!acc[parent]) {
-        acc[parent] = {}
-      }
- 
-      acc[parent][child] = schema[parent][child]
-    } else {
-      acc[field] = schema[field]
-    }
-    return acc
-  }, {})
-}
- 
-const getSelectedAttributesFromSchema = ({ schema }) => {
-  return Object.entries(schema).reduce((acc, [fieldKey, fieldValue]) => {
-    if (typeof fieldValue === 'object') {
-      Object.keys(fieldValue).forEach((key) => acc.push(`${fieldKey}.${key}`))
-    } else {
-      acc.push(fieldKey)
-    }
-    return acc
-  }, [])
-}
- 
-module.exports = { getSchemaFromAttributes, getSelectedAttributesFromSchema }
- 
- -
-
- - - - - - - - \ No newline at end of file diff --git a/coverage/lcov.info b/coverage/lcov.info deleted file mode 100644 index 593e151..0000000 --- a/coverage/lcov.info +++ /dev/null @@ -1,327 +0,0 @@ -TN: -SF:server/services/content-types.js -FN:20,(anonymous_0) -FN:21,(anonymous_1) -FN:29,(anonymous_2) -FN:33,(anonymous_3) -FN:35,(anonymous_4) -FN:41,(anonymous_5) -FN:49,(anonymous_6) -FN:50,(anonymous_7) -FN:52,(anonymous_8) -FN:57,(anonymous_9) -FN:58,(anonymous_10) -FN:60,(anonymous_11) -FN:62,(anonymous_12) -FN:67,(anonymous_13) -FN:80,(anonymous_14) -FN:92,(anonymous_15) -FN:94,(anonymous_16) -FN:117,(anonymous_17) -FN:128,(anonymous_18) -FN:129,(anonymous_19) -FN:146,(anonymous_20) -FNF:21 -FNH:21 -FNDA:1,(anonymous_0) -FNDA:3,(anonymous_1) -FNDA:16,(anonymous_2) -FNDA:16,(anonymous_3) -FNDA:6,(anonymous_4) -FNDA:16,(anonymous_5) -FNDA:2,(anonymous_6) -FNDA:1,(anonymous_7) -FNDA:1,(anonymous_8) -FNDA:2,(anonymous_9) -FNDA:3,(anonymous_10) -FNDA:1,(anonymous_11) -FNDA:1,(anonymous_12) -FNDA:2,(anonymous_13) -FNDA:2,(anonymous_14) -FNDA:2,(anonymous_15) -FNDA:8,(anonymous_16) -FNDA:12,(anonymous_17) -FNDA:4,(anonymous_18) -FNDA:16,(anonymous_19) -FNDA:2,(anonymous_20) -DA:3,1 -DA:20,1 -DA:21,1 -DA:22,3 -DA:23,2 -DA:25,3 -DA:29,1 -DA:30,16 -DA:33,16 -DA:35,1 -DA:36,6 -DA:41,1 -DA:42,16 -DA:49,1 -DA:50,2 -DA:51,1 -DA:52,1 -DA:54,1 -DA:57,1 -DA:58,3 -DA:60,1 -DA:61,1 -DA:63,1 -DA:67,2 -DA:81,2 -DA:82,2 -DA:84,2 -DA:93,2 -DA:94,2 -DA:95,8 -DA:105,2 -DA:111,8 -DA:114,2 -DA:118,12 -DA:119,2 -DA:125,10 -DA:129,4 -DA:130,16 -DA:140,12 -DA:142,16 -DA:147,2 -DA:148,2 -LF:42 -LH:42 -BRDA:22,0,0,2 -BRDA:22,0,1,1 -BRDA:37,1,0,6 -BRDA:37,1,1,6 -BRDA:37,1,2,6 -BRDA:43,2,0,16 -BRDA:43,2,1,16 -BRDA:43,2,2,14 -BRDA:43,2,3,4 -BRDA:58,3,0,1 -BRDA:58,3,1,2 -BRDA:80,4,0,0 -BRDA:80,5,0,0 -BRDA:80,6,0,0 -BRDA:95,7,0,2 -BRDA:95,7,1,6 -BRDA:96,8,0,8 -BRDA:96,8,1,2 -BRDA:118,9,0,2 -BRDA:118,9,1,10 -BRDA:130,10,0,12 -BRDA:130,10,1,4 -BRF:22 -BRH:19 -end_of_record -TN: -SF:server/services/orama-manager.js -FN:7,(anonymous_0) -FN:21,(anonymous_1) -FN:49,(anonymous_2) -FN:55,(anonymous_3) -FN:61,(anonymous_4) -FN:69,(anonymous_5) -FN:78,(anonymous_6) -FN:83,(anonymous_7) -FN:105,(anonymous_8) -FN:110,(anonymous_9) -FN:114,(anonymous_10) -FN:119,(anonymous_11) -FN:123,(anonymous_12) -FN:128,(anonymous_13) -FN:130,(anonymous_14) -FN:132,(anonymous_15) -FN:137,(anonymous_16) -FN:147,(anonymous_17) -FN:175,(anonymous_18) -FN:179,(anonymous_19) -FN:199,(anonymous_20) -FN:220,(anonymous_21) -FN:245,(anonymous_22) -FNF:23 -FNH:18 -FNDA:20,(anonymous_0) -FNDA:6,(anonymous_1) -FNDA:1,(anonymous_2) -FNDA:1,(anonymous_3) -FNDA:1,(anonymous_4) -FNDA:2,(anonymous_5) -FNDA:1,(anonymous_6) -FNDA:2,(anonymous_7) -FNDA:2,(anonymous_8) -FNDA:2,(anonymous_9) -FNDA:2,(anonymous_10) -FNDA:2,(anonymous_11) -FNDA:2,(anonymous_12) -FNDA:1,(anonymous_13) -FNDA:1,(anonymous_14) -FNDA:1,(anonymous_15) -FNDA:5,(anonymous_16) -FNDA:1,(anonymous_17) -FNDA:0,(anonymous_18) -FNDA:0,(anonymous_19) -FNDA:0,(anonymous_20) -FNDA:0,(anonymous_21) -FNDA:0,(anonymous_22) -DA:3,1 -DA:4,1 -DA:8,20 -DA:9,20 -DA:10,20 -DA:11,20 -DA:13,20 -DA:14,20 -DA:22,6 -DA:23,1 -DA:24,1 -DA:27,5 -DA:28,1 -DA:29,1 -DA:32,4 -DA:33,1 -DA:36,1 -DA:39,3 -DA:40,1 -DA:43,1 -DA:46,2 -DA:50,1 -DA:56,1 -DA:62,1 -DA:70,2 -DA:71,2 -DA:73,2 -DA:75,2 -DA:79,1 -DA:80,1 -DA:84,2 -DA:91,2 -DA:92,1 -DA:99,1 -DA:102,1 -DA:106,2 -DA:107,2 -DA:111,2 -DA:112,2 -DA:114,2 -DA:116,2 -DA:120,2 -DA:121,2 -DA:123,2 -DA:125,2 -DA:129,1 -DA:130,1 -DA:132,1 -DA:134,1 -DA:138,5 -DA:139,2 -DA:142,3 -DA:144,3 -DA:148,1 -DA:150,1 -DA:151,0 -DA:154,1 -DA:159,1 -DA:161,1 -DA:163,1 -DA:168,1 -DA:170,1 -DA:172,1 -DA:176,0 -DA:180,0 -DA:182,0 -DA:186,0 -DA:187,0 -DA:190,0 -DA:192,0 -DA:194,0 -DA:196,0 -DA:200,0 -DA:202,0 -DA:203,0 -DA:206,0 -DA:208,0 -DA:210,0 -DA:217,0 -DA:221,0 -DA:223,0 -DA:224,0 -DA:227,0 -DA:231,0 -DA:233,0 -DA:235,0 -DA:237,0 -DA:239,0 -DA:243,1 -DA:245,0 -LF:90 -LH:63 -BRDA:22,0,0,1 -BRDA:22,0,1,5 -BRDA:27,1,0,1 -BRDA:27,1,1,4 -BRDA:32,2,0,1 -BRDA:32,2,1,3 -BRDA:39,3,0,1 -BRDA:39,3,1,2 -BRDA:65,4,0,1 -BRDA:65,4,1,1 -BRDA:83,5,0,1 -BRDA:91,6,0,1 -BRDA:91,6,1,1 -BRDA:138,7,0,2 -BRDA:138,7,1,3 -BRDA:138,8,0,5 -BRDA:138,8,1,5 -BRDA:138,8,2,4 -BRDA:150,9,0,0 -BRDA:150,9,1,1 -BRDA:186,10,0,0 -BRDA:186,10,1,0 -BRDA:202,11,0,0 -BRDA:202,11,1,0 -BRDA:223,12,0,0 -BRDA:223,12,1,0 -BRF:26 -BRH:19 -end_of_record -TN: -SF:utils/schema.js -FN:1,(anonymous_0) -FN:2,(anonymous_1) -FN:17,(anonymous_2) -FN:18,(anonymous_3) -FN:20,(anonymous_4) -FNF:5 -FNH:2 -FNDA:1,(anonymous_0) -FNDA:2,(anonymous_1) -FNDA:0,(anonymous_2) -FNDA:0,(anonymous_3) -FNDA:0,(anonymous_4) -DA:1,1 -DA:2,1 -DA:3,2 -DA:4,0 -DA:5,0 -DA:6,0 -DA:9,0 -DA:11,2 -DA:13,2 -DA:17,1 -DA:18,0 -DA:19,0 -DA:20,0 -DA:22,0 -DA:24,0 -DA:28,1 -LF:16 -LH:7 -BRDA:3,0,0,0 -BRDA:3,0,1,2 -BRDA:5,1,0,0 -BRDA:5,1,1,0 -BRDA:19,2,0,0 -BRDA:19,2,1,0 -BRF:6 -BRH:1 -end_of_record diff --git a/server/__mocks__/collection.js b/server/__mocks__/collection.js index fa548c9..8b09142 100644 --- a/server/__mocks__/collection.js +++ b/server/__mocks__/collection.js @@ -2,7 +2,20 @@ const mockCollection = { id: 1, entity: 'testEntity', indexId: 'testIndexId', - status: 'pending', + status: 'outdated', + searchableAttributes: ['name', 'description'], + schema: { + name: { type: 'string' }, + description: { type: 'string' } + }, + includedRelations: ['relation1', 'relation2'] +} + +const mockNotValidCollection = { + id: 1, + entity: 'testEntity', + indexId: 'testIndexId', + status: 'updating', searchableAttributes: ['name', 'description'], schema: { name: { type: 'string' }, @@ -12,5 +25,6 @@ const mockCollection = { } module.exports = { - mockCollection + mockCollection, + mockNotValidCollection } diff --git a/server/__tests__/services/content-types.test.js b/server/services/content-types.test.js similarity index 95% rename from server/__tests__/services/content-types.test.js rename to server/services/content-types.test.js index 39b95d3..567f5b3 100644 --- a/server/__tests__/services/content-types.test.js +++ b/server/services/content-types.test.js @@ -1,5 +1,5 @@ -const contentTypesServiceInit = require('../../services/content-types') -const { mockedContentTypes, expectedContentTypes } = require('../../__mocks__/content-types') +const contentTypesServiceInit = require('./content-types') +const { mockedContentTypes, expectedContentTypes } = require('../__mocks__/content-types') const strapi = { contentTypes: mockedContentTypes, diff --git a/server/services/orama-manager.js b/server/services/orama-manager.js index 9a610ee..4f3a49c 100644 --- a/server/services/orama-manager.js +++ b/server/services/orama-manager.js @@ -144,7 +144,7 @@ class OramaManager { return await this.DocumentActionsMap[action]({ indexId, entries: [{ ...rest, id: rest.id.toString() }] }) } - async populateIndex({ id }) { + async afterCollectionCreationOrUpdate({ id }) { const collection = await this.collectionService.findOne(id) if (!this.validate(collection)) { @@ -172,10 +172,6 @@ class OramaManager { await this.updatingCompleted(collection, documents_count) } - async afterCollectionCreationOrUpdate({ id }) { - await this.populateIndex({ id }) - } - async deployIndex({ id }) { const collection = await this.collectionService.findOne(id) @@ -207,13 +203,20 @@ class OramaManager { await this.updatingStarted(collection) - await this.handleDocument( + const handleDocumentResult = await this.handleDocument( { indexId: collection.indexId, record, action }) + if (!handleDocumentResult) { + await this.setOutdated(collection) + return + } + + await this.setOutdated(collection) + this.strapi.log.debug(`Live update for ${collection.entity} with indexId ${collection.indexId} completed`) } diff --git a/server/__tests__/services/orama-manager.test.js b/server/services/orama-manager.test.js similarity index 54% rename from server/__tests__/services/orama-manager.test.js rename to server/services/orama-manager.test.js index 825603b..68153ba 100644 --- a/server/__tests__/services/orama-manager.test.js +++ b/server/services/orama-manager.test.js @@ -1,7 +1,7 @@ -const { OramaManager } = require("../../services/orama-manager") +const { OramaManager } = require("./orama-manager") const { CloudManager } = require("@oramacloud/client") -const { mockCollection } = require("../../__mocks__/collection") -const { mockedTestRecord } = require("../../__mocks__/content-types") +const { mockCollection, mockNotValidCollection } = require("../__mocks__/collection") +const { mockedTestRecord } = require("../__mocks__/content-types") const strapi = { plugin: jest.fn().mockReturnThis(), @@ -25,7 +25,7 @@ const contentTypesService = { } const collectionService = { - findOne: jest.fn().mockReturnValue(mockCollection), + findOne: jest.fn(), updateWithoutHooks: jest.fn() } @@ -38,21 +38,12 @@ strapi.plugin.mockReturnValue({ const mockedBulkInsertResult = { documents_count: 1 } -/*const mockedIndexFn = jest.fn().mockReturnValue({ - updateSchema: jest.fn(), - insert: jest.fn().mockResolvedValue(true), - deploy: mockedDeployFn, -}) - -CloudManager.prototype.index = mockedIndexFn*/ - -afterEach(() => { - jest.restoreAllMocks() - jest.clearAllMocks() -}) - describe("OramaManager", () => { + let oramaManager + beforeEach(() => { + oramaManager = new OramaManager({ strapi }) + jest.spyOn(CloudManager.prototype, "constructor").mockImplementation(() => { }) @@ -60,10 +51,12 @@ describe("OramaManager", () => { updateSchema: jest.fn(), deploy: jest.fn(), snapshot: jest.fn(), - insert: jest.fn(), - delete: jest.fn(), - update: jest.fn(), + insert: jest.fn().mockResolvedValue(true), + delete: jest.fn().mockResolvedValue(true), + update: jest.fn().mockResolvedValue(true), }) + + collectionService.findOne.mockReturnValue(mockCollection) }) describe("validate", () => { @@ -72,7 +65,6 @@ describe("OramaManager", () => { }) it("should return false if collection is not found", () => { - const oramaManager = new OramaManager({ strapi }) const result = oramaManager.validate(null) expect(result).toBe(false) @@ -80,8 +72,8 @@ describe("OramaManager", () => { }) it("should return false if privateApiKey is not found", () => { - jest.spyOn(strapi.config, "get").mockReturnValue() - const oramaManager = new OramaManager({ strapi }) + jest.spyOn(strapi.config, "get").mockReturnValueOnce() + oramaManager = new OramaManager({ strapi }) const result = oramaManager.validate(mockCollection) expect(result).toBe(false) @@ -89,7 +81,6 @@ describe("OramaManager", () => { }) it("should return false if collection status is updating", () => { - const oramaManager = new OramaManager({ strapi }) const result = oramaManager.validate({ ...mockCollection, status: "updating" }) expect(result).toBe(false) @@ -97,7 +88,6 @@ describe("OramaManager", () => { }) it("should return false if collection status is updated", () => { - const oramaManager = new OramaManager({ strapi }) const result = oramaManager.validate({ ...mockCollection, status: "updated" }) expect(result).toBe(false) @@ -105,7 +95,6 @@ describe("OramaManager", () => { }) it("should return true if all validations pass", () => { - const oramaManager = new OramaManager({ strapi }) const result = oramaManager.validate(mockCollection) expect(result).toBe(true) @@ -115,7 +104,6 @@ describe("OramaManager", () => { describe("setOutdated", () => { it("should update collection status to outdated", async () => { - const oramaManager = new OramaManager({ strapi }) await oramaManager.setOutdated(mockCollection) expect(collectionService.updateWithoutHooks).toHaveBeenCalledWith(mockCollection.id, { @@ -126,7 +114,6 @@ describe("OramaManager", () => { describe("updatingStarted", () => { it("should update collection status to updating", async () => { - const oramaManager = new OramaManager({ strapi }) await oramaManager.updatingStarted(mockCollection) expect(collectionService.updateWithoutHooks).toHaveBeenCalledWith(mockCollection.id, { @@ -137,7 +124,6 @@ describe("OramaManager", () => { describe("updatingCompleted", () => { it("should update collection status to updated", async () => { - const oramaManager = new OramaManager({ strapi }) await oramaManager.updatingCompleted(mockCollection, 1) expect(collectionService.updateWithoutHooks).toHaveBeenCalledWith(mockCollection.id, { @@ -150,7 +136,6 @@ describe("OramaManager", () => { describe("oramaDeployIndex", () => { it("should deploy index", async () => { - const oramaManager = new OramaManager({ strapi }) const { deploy } = new CloudManager({ strapi }).index() await oramaManager.oramaDeployIndex(mockCollection) @@ -161,7 +146,6 @@ describe("OramaManager", () => { describe("resetIndex", () => { it("should reset index", async () => { - const oramaManager = new OramaManager({ strapi }) const { snapshot } = new CloudManager({ strapi }).index() await oramaManager.resetIndex(mockCollection) @@ -172,7 +156,6 @@ describe("OramaManager", () => { describe("bulkInsert", () => { it("should insert entries", async () => { - const oramaManager = new OramaManager({ strapi }) const oramaInsertSpy = jest.spyOn(oramaManager, "oramaInsert").mockResolvedValue() const bulkInsertSpy = jest.spyOn(oramaManager, "bulkInsert") @@ -189,7 +172,6 @@ describe("OramaManager", () => { describe("oramaUpdateSchema", () => { it("should update schema", async () => { - const oramaManager = new OramaManager({ strapi }) const { updateSchema } = new CloudManager({ strapi }).index() await oramaManager.oramaUpdateSchema(mockCollection) @@ -200,7 +182,6 @@ describe("OramaManager", () => { describe("oramaInsert", () => { it("should insert entries", async () => { - const oramaManager = new OramaManager({ strapi }) const { insert } = new CloudManager({ strapi }).index() await oramaManager.oramaInsert({ @@ -214,7 +195,6 @@ describe("OramaManager", () => { describe("oramaUpdate", () => { it("should update entries", async () => { - const oramaManager = new OramaManager({ strapi }) const { update } = new CloudManager({ strapi }).index() await oramaManager.oramaUpdate({ @@ -228,7 +208,6 @@ describe("OramaManager", () => { describe("handleDocument", () => { it("should return if action is not found", async () => { - const oramaManager = new OramaManager({ strapi }) const { insert } = new CloudManager({ strapi }).index() await oramaManager.handleDocument({ @@ -241,7 +220,6 @@ describe("OramaManager", () => { }) it("should return if record is not valid", async () => { - const oramaManager = new OramaManager({ strapi }) const { insert, update, delete: cloudManagerDelete } = new CloudManager({ strapi }).index() await oramaManager.handleDocument({ @@ -256,7 +234,6 @@ describe("OramaManager", () => { }) it("should return if action is create", async () => { - const oramaManager = new OramaManager({ strapi }) const { insert } = new CloudManager({ strapi }).index() await oramaManager.handleDocument({ @@ -269,7 +246,6 @@ describe("OramaManager", () => { }) it("should return if action is update", async () => { - const oramaManager = new OramaManager({ strapi }) const { update } = new CloudManager({ strapi }).index() await oramaManager.handleDocument({ @@ -282,7 +258,6 @@ describe("OramaManager", () => { }) it("should return if action is delete", async () => { - const oramaManager = new OramaManager({ strapi }) const { delete: deleteFn } = new CloudManager({ strapi }).index() await oramaManager.handleDocument({ @@ -295,105 +270,152 @@ describe("OramaManager", () => { }) }) - describe("populateIndex", () => { - it("should populate index", async () => { - const oramaManager = new OramaManager({ strapi }) - const { deploy, updateSchema } = new CloudManager({strapi}).index() - const updatingStartedSpy = jest.spyOn(oramaManager, "updatingStarted").mockResolvedValue() - const resetIndexSpy = jest.spyOn(oramaManager, "resetIndex").mockResolvedValue() - const bulkInsertSpy = jest.spyOn(oramaManager, "bulkInsert").mockReturnValue(mockedBulkInsertResult) - const updatingCompletedSpy = jest.spyOn(oramaManager, "updatingCompleted").mockResolvedValue() - - await oramaManager.populateIndex(mockCollection) - - expect(updatingStartedSpy).toHaveBeenCalledWith(mockCollection) - expect(resetIndexSpy).toHaveBeenCalledWith(mockCollection) - expect(updateSchema).toHaveBeenCalledWith({ - indexId: mockCollection.index, - schema: mockCollection.schema - }) - expect(deploy).toHaveBeenCalled() - expect(bulkInsertSpy).toHaveBeenCalledWith(mockCollection) - expect(updatingCompletedSpy).toHaveBeenCalledWith(mockCollection, mockedBulkInsertResult.documents_count) + describe("processCollection", () => { + let updatingStartedSpy, + oramaDeployIndexSpy, + resetIndexSpy, + bulkInsertSpy, + setOutdatedSpy, + handleDocumentSpy, + updatingCompletedSpy, + cloudManager; + + + beforeEach(() => { + jest.spyOn(oramaManager, "validate") + updatingStartedSpy = jest.spyOn(oramaManager, "updatingStarted").mockResolvedValue() + resetIndexSpy = jest.spyOn(oramaManager, "resetIndex").mockResolvedValue() + oramaDeployIndexSpy = jest.spyOn(oramaManager, "oramaDeployIndex").mockResolvedValue() + bulkInsertSpy = jest.spyOn(oramaManager, "bulkInsert").mockResolvedValue(mockedBulkInsertResult) + setOutdatedSpy = jest.spyOn(oramaManager, "setOutdated").mockResolvedValue() + handleDocumentSpy = jest.spyOn(oramaManager, "handleDocument") + updatingCompletedSpy = jest.spyOn(oramaManager, "updatingCompleted").mockResolvedValue() + cloudManager = new CloudManager({ strapi }).index() }) - }) - - /*describe('afterCollectionCreationOrUpdate', () => { - it('should populate index after creation', async () => { - const updatingStartedSpy = jest.spyOn(oramaManager, 'updatingStarted').mockResolvedValue() - const resetIndexSpy = jest.spyOn(oramaManager, 'resetIndex').mockResolvedValue() - const bulkInsertSpy = jest.spyOn(oramaManager, 'bulkInsert').mockReturnValue(mockedBulkInsertResult) - const deployIndexSpy = jest.spyOn(oramaManager, 'deployIndex') - const updatingCompletedSpy = jest.spyOn(oramaManager, 'updatingCompleted').mockResolvedValue() - - jest.spyOn(global.console, 'error') - - await oramaManager.afterCollectionCreationOrUpdate({ id: 1 }) - expect(updatingStartedSpy).toHaveBeenCalledTimes(1) - expect(resetIndexSpy).toHaveBeenCalledWith(mockCollection) - expect(bulkInsertSpy).toHaveBeenCalledWith(mockCollection) - expect(deployIndexSpy).toHaveBeenCalledWith(mockCollection) - expect(global.console.error).not.toHaveBeenCalled() - expect(updatingCompletedSpy).toHaveBeenCalledWith(mockCollection, mockedBulkInsertResult.documents_count) + describe("afterCollectionCreationOrUpdate", () => { + it("should populate index", async () => { + const { updateSchema, deploy } = cloudManager + + await oramaManager.afterCollectionCreationOrUpdate(mockCollection) + + expect(oramaManager.validate).toHaveBeenCalledWith(mockCollection) + expect(updatingStartedSpy).toHaveBeenCalledWith(mockCollection) + expect(resetIndexSpy).toHaveBeenCalledWith(mockCollection) + expect(updateSchema).toHaveBeenCalledWith({ + indexId: mockCollection.index, + schema: mockCollection.schema + }) + expect(oramaDeployIndexSpy).toHaveBeenCalled() + expect(bulkInsertSpy).toHaveBeenCalledWith(mockCollection) + expect(updatingCompletedSpy).toHaveBeenCalledWith(mockCollection, mockedBulkInsertResult.documents_count) + }) + it("should not populate if collection is not valid", async () => { + collectionService.findOne.mockReturnValueOnce(mockNotValidCollection) + const { updateSchema, deploy } = cloudManager + + const result = await oramaManager.afterCollectionCreationOrUpdate(mockNotValidCollection) + + expect(oramaManager.validate).toHaveBeenCalledWith(mockNotValidCollection) + expect(result).toBeUndefined() + expect(updatingStartedSpy).not.toHaveBeenCalled() + expect(resetIndexSpy).not.toHaveBeenCalled() + expect(updateSchema).not.toHaveBeenCalled() + expect(deploy).not.toHaveBeenCalled() + expect(bulkInsertSpy).not.toHaveBeenCalled() + expect(updatingCompletedSpy).not.toHaveBeenCalled() + }) }) - })*/ - /*describe("deployIndex", () => { - it("should deploy index", async () => { - const updatingStartedSpy = jest.spyOn(oramaManager, "updatingStarted").mockResolvedValue() - const oramaDeployIndexSpy = jest.spyOn(oramaManager, "oramaDeployIndex") - const updatingCompletedSpy = jest.spyOn(oramaManager, "updatingCompleted").mockResolvedValue() + describe("deployIndex", () => { + it("should deploy index", async () => { + await oramaManager.deployIndex(mockCollection) + + expect(oramaManager.validate).toHaveBeenCalledWith(mockCollection) + expect(updatingStartedSpy).toHaveBeenCalledWith(mockCollection) + expect(oramaDeployIndexSpy).toHaveBeenCalledWith(mockCollection) + expect(updatingCompletedSpy).toHaveBeenCalledWith(mockCollection) + }) + it("should not deploy index if collection is not valid", async () => { + collectionService.findOne.mockReturnValueOnce(mockNotValidCollection) - await oramaManager.deployIndex(mockCollection) + const result = await oramaManager.deployIndex(mockCollection) - expect(updatingStartedSpy).toHaveBeenCalled() - expect(oramaDeployIndexSpy).toHaveBeenCalledWith(mockCollection) - expect(updatingCompletedSpy).toHaveBeenCalledWith(mockCollection) + expect(oramaManager.validate).toHaveBeenCalledWith(mockNotValidCollection) + expect(result).toBeUndefined() + expect(updatingStartedSpy).not.toHaveBeenCalledWith() + expect(oramaDeployIndexSpy).not.toHaveBeenCalledWith() + expect(updatingCompletedSpy).not.toHaveBeenCalledWith() + }) }) - })*/ - - /*describe("processLiveUpdate", () => { - describe("should create a new change on Orama and change the collection status to outdated the index", () => { - it("should create an upsert change in case of record creation", async () => { - const updatingStartedSpy = jest.spyOn(oramaManager, "updatingStarted").mockResolvedValue() - const handleDocumentSpy = jest.spyOn(oramaManager, "handleDocument") - const oramaInsertSpy = jest.spyOn(oramaManager, "oramaInsert").mockResolvedValue() - const setOutdatedSpy = jest.spyOn(oramaManager, "setOutdated").mockResolvedValue() - await oramaManager.processLiveUpdate(mockCollection, mockedTestRecord, "create") + describe("processLiveUpdate", () => { + it("should process live update", async () => { + await oramaManager.processLiveUpdate({ id: 1 }, mockedTestRecord, "create") - expect(updatingStartedSpy).toHaveBeenCalled() + expect(oramaManager.validate).toHaveBeenCalledWith(mockCollection) + expect(updatingStartedSpy).toHaveBeenCalledWith(mockCollection) expect(handleDocumentSpy).toHaveBeenCalledWith({ indexId: mockCollection.indexId, record: mockedTestRecord, action: "create" - }, setOutdatedSpy) - expect(oramaInsertSpy).toHaveBeenCalledWith({ - indexId: mockCollection.indexId, - entries: [mockedTestRecord] - }, setOutdatedSpy) + }) + expect(setOutdatedSpy).toHaveBeenCalledWith(mockCollection) }) - it("should create an upsert change in case of update creation", async () => { - const updatingStartedSpy = jest.spyOn(oramaManager, "updatingStarted").mockResolvedValue() - const updatingCompleted = jest.spyOn(oramaManager, "updatingCompleted").mockResolvedValue() + it("should not process live update if collection is not valid", async () => { + collectionService.findOne.mockReturnValueOnce(mockNotValidCollection) - await oramaManager.processLiveUpdate(mockCollection, mockedTestRecord, 'create') + await oramaManager.processLiveUpdate({ id: 1 }, mockedTestRecord, "create") - expect(updatingStartedSpy).toHaveBeenCalled() - expect(updatingCompleted).toHaveBeenCalledWith(mockCollection) + expect(oramaManager.validate).toHaveBeenCalledWith(mockNotValidCollection) + expect(updatingStartedSpy).not.toHaveBeenCalled() + expect(handleDocumentSpy).not.toHaveBeenCalled() + expect(setOutdatedSpy).not.toHaveBeenCalled() }) - it("should create an upsert change in case of record deletion", async () => { - const updatingStartedSpy = jest.spyOn(oramaManager, "updatingStarted").mockResolvedValue() - const updatingCompleted = jest.spyOn(oramaManager, "updatingCompleted").mockResolvedValue() + it("should not process live update if record handling had any issues", async () => { + collectionService.findOne.mockReturnValueOnce(mockCollection) + + //Force handleDocument to reject + handleDocumentSpy.mockResolvedValueOnce(false) - await oramaManager.processLiveUpdate(mockCollection, mockedTestRecord, 'create') + await oramaManager.processLiveUpdate({ id: 1 }, mockedTestRecord, "create") + expect(oramaManager.validate).toHaveBeenCalledWith(mockCollection) expect(updatingStartedSpy).toHaveBeenCalled() - expect(updatingCompleted).toHaveBeenCalledWith(mockCollection) + expect(handleDocumentSpy).toHaveBeenCalled() + expect(setOutdatedSpy).toHaveBeenCalled() + }) + }) + + describe("processScheduledUpdate", () => { + it("should process scheduled update", async () => { + await oramaManager.processScheduledUpdate({ id: 1 }) + + expect(oramaManager.validate).toHaveBeenCalledWith(mockCollection) + expect(updatingStartedSpy).toHaveBeenCalledWith(mockCollection) + expect(resetIndexSpy).toHaveBeenCalledWith(mockCollection) + expect(bulkInsertSpy).toHaveBeenCalledWith(mockCollection) + expect(updatingCompletedSpy).toHaveBeenCalledWith(mockCollection, mockedBulkInsertResult.documents_count) + }) + + it("should not process scheduled update if collection is not valid", async () => { + collectionService.findOne.mockReturnValueOnce(mockNotValidCollection) + + await oramaManager.processScheduledUpdate({ id: 1 }) + + expect(oramaManager.validate).toHaveBeenCalledWith(mockNotValidCollection) + expect(updatingStartedSpy).not.toHaveBeenCalled() + expect(resetIndexSpy).not.toHaveBeenCalled() + expect(bulkInsertSpy).not.toHaveBeenCalled() + expect(updatingCompletedSpy).not.toHaveBeenCalled() }) }) - })*/ + }) + + afterEach(() => { + jest.restoreAllMocks() + jest.clearAllMocks() + }) }) diff --git a/utils/schema.test.js b/utils/schema.test.js new file mode 100644 index 0000000..4f81484 --- /dev/null +++ b/utils/schema.test.js @@ -0,0 +1,59 @@ +const { getSchemaFromAttributes, getSelectedAttributesFromSchema } = require('./schema'); + +describe('Schema Utils', () => { + describe('getSchemaFromAttributes', () => { + it('should return the correct schema for flat attributes', () => { + const attributes = ['name', 'age']; + const schema = { + name: { type: 'string' }, + age: { type: 'number' }, + address: { type: 'object' } + }; + const result = getSchemaFromAttributes({ attributes, schema }); + expect(result).toEqual({ + name: { type: 'string' }, + age: { type: 'number' } + }); + }); + + it('should return the correct schema for nested attributes', () => { + const attributes = ['address.city', 'address.zip']; + const schema = { + address: { + city: { type: 'string' }, + zip: { type: 'number' }, + street: { type: 'string' } + } + }; + const result = getSchemaFromAttributes({ attributes, schema }); + expect(result).toEqual({ + address: { + city: { type: 'string' }, + zip: { type: 'number' } + } + }); + }); + }); + + describe('getSelectedAttributesFromSchema', () => { + it('should return the correct list of attributes for flat schema', () => { + const schema = { + name: 'string', + age: 'number' + }; + const result = getSelectedAttributesFromSchema({ schema }); + expect(result).toEqual(['name', 'age']); + }); + + it('should return the correct list of attributes for nested schema', () => { + const schema = { + address: { + city: 'string', + zip: 'number' + } + }; + const result = getSelectedAttributesFromSchema({ schema }); + expect(result).toEqual(['address.city', 'address.zip']); + }); + }); +});