@pdftron/collab-db-postgresql
Advanced tools
Comparing version 2.0.0 to 2.0.1-alpha.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CollabPostgres=t():e.CollabPostgres=t()}(global,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogger=t.LogLevels=t.LogTags=void 0;var s,i=o(n(4)),u=n(8);!function(e){e.STANDARD="STANDARD",e.ENTITY="ENTITY",e.QUERY="QUERY",e.MUTATION="MUTATION",e.RESPONSE="RESPONSE",e.AUTH="AUTH",e.CACHE="CACHE",e.CONNECTED_USERS="CONNECTED_USERS",e.SCROLL_SYNC="SCROLL_SYNC",e.USERNAMES="USERNAMES"}(t.LogTags||(t.LogTags={})),function(e){e.ERROR="error",e.WARN="warn",e.INFO="info",e.HTTP="http",e.VERBOSE="verbose",e.DEBUG="debug",e.SILLY="silly",e.NONE="none"}(s=t.LogLevels||(t.LogLevels={}));var c=i.default.createLogger({format:i.format.combine(i.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}))});t.setupLogger=function(e,t,n){e===s.NONE?c.silent=!0:((0,u.addConsoleTransport)(c,e,n),t&&t.length&&(0,u.addTransports)(c,t))},t.default=c},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getQuery=t.toUnixTimestampSelector=t.camelToSnake=t.keysToCamel=t.valueIn=t.getFilterQuery=t.whereAnd=t.Command=void 0;var a=r(n(2)),o=n(3);!function(e){e.Insert="INSERT",e.Update="UPDATE",e.Delete="DELETE"}(t.Command||(t.Command={}));t.whereAnd=function(e){var t=e.filter((function(e){return!!e}));return t.reduce((function(e,n,r){var a=r===t.length-1;return"".concat(e," ").concat(n," ").concat(a?"":"AND")}),"WHERE ")};t.getFilterQuery=function(e){return[e.createdBefore&&"".concat((0,t.toUnixTimestampSelector)("created_at")," < ").concat(e.createdBefore),e.createdAfter&&"".concat((0,t.toUnixTimestampSelector)("created_at")," > ").concat(e.createdAfter),e.updatedBefore&&"".concat((0,t.toUnixTimestampSelector)("updated_at")," < ").concat(e.updatedBefore),e.updatedAfter&&"".concat((0,t.toUnixTimestampSelector)("updated_at")," > ").concat(e.updatedAfter)]};t.valueIn=function(e,t){return"".concat(e," IN (").concat(t.reduce((function(e,n,r){var a=r===t.length-1?"":",";return"string"==typeof n?e+"'".concat(n,"'").concat(a):e+"".concat(n).concat(a)}),""),")")};var s=function(e){return Array.isArray(e)},i=function(e){return e===Object(e)&&!s(e)&&"function"!=typeof e&&!function(e){return e instanceof Date}(e)};t.keysToCamel=function(e){if(i(e)){var n={};return Object.keys(e).forEach((function(r){var a;n[(a=r,a.replace(/([-_][a-z])/gi,(function(e){return e.toUpperCase().replace("-","").replace("_","")})))]=(0,t.keysToCamel)(e[r])})),n}return s(e)?e.map((function(e){return(0,t.keysToCamel)(e)})):e};t.camelToSnake=function(e){return e.replace(/[\w]([A-Z])/g,(function(e){return e[0]+"_"+e[1]})).toLowerCase()};t.toUnixTimestampSelector=function(e){return"EXTRACT(epoch FROM date_trunc('milliseconds', ".concat(e,")) * 1000")};t.getQuery=function(e){var n=e.type,r=e.id,s=e.table,i=e.params,u=Object.keys(i),c=[],d=[],l=[],f=[],p=1;u.forEach((function(e){var r=i[e];if(void 0!==r){if(o.TimestampProperties.includes(e))if(o.NowTimestampProperties.includes(e))f.push(a.default.getNow());else try{var s=new Date(r);f.push(s.toISOString())}catch(t){throw new Error('Failed to parse date for "'.concat(e,'" - tried to convert ').concat(JSON.stringify(r)," to a date but could not."))}else f.push(r);c.push((0,t.camelToSnake)(e)),"INSERT"===n&&l.push("$".concat(p)),d.push("".concat((0,t.camelToSnake)(e)," = $").concat(p)),p+=1}}));var m=null;switch(n){case"INSERT":m="INSERT INTO ".concat(s," (").concat(c.join(", "),") VALUES(").concat(l.join(", "),") RETURNING *;");break;case"UPDATE":m="UPDATE ".concat(s," SET ").concat(d.join(", ")," WHERE id = '").concat(r,"' RETURNING *;");break;case"DELETE":m="DELETE FROM ".concat(s," WHERE ").concat(d.join(" AND ")," RETURNING id;")}return{text:m,values:f}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.indicator="NOW",this._current=function(){return"CURRENT_TIMESTAMP"}}return e.prototype.set=function(e){this._current=e},e.prototype.getNow=function(){return this._current()},e}();t.default=new r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringIdProperties=t.NowTimestampProperties=t.TimestampProperties=void 0,t.TimestampProperties=["createdAt","updatedAt","lastRead","annotationCreatedAt"],t.NowTimestampProperties=["createdAt","updatedAt","lastRead"],t.StringIdProperties=["id","userId","snapshotId","authorId","documentId","annotationId"]},function(e,t){e.exports=require("winston")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QueryType=t.UserTypes=t.UserStatus=void 0,function(e){e.Active="ACTIVE",e.Inactive="INACTIVE"}(t.UserStatus||(t.UserStatus={})),function(e){e.Anonymous="ANONYMOUS",e.Standard="STANDARD"}(t.UserTypes||(t.UserTypes={})),function(e){e.Single="SINGLE",e.Multiple="MULTIPLE"}(t.QueryType||(t.QueryType={}))},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},a=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&a(t,e,n);return o(t,e),t},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))},u=this&&this.__generator||function(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}},c=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return s},d=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))},l=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogTags=t.LogLevels=t.UserTypes=void 0;var f=n(1),p=l(n(7)).default.Client,m=s(n(0)),h=n(9),v=n(10),y=n(1),b=n(5),g=l(n(2)),_=n(3),I=function(){function e(e){var t=e.username,n=e.dbName,r=e.password,a=e.port,o=e.host,s=e.connectionString,i=e.ssl,u=e.statementTimeout,c=e.queryTimeout,d=void 0===c?5e3:c,l=e.idleInTransactionSessionTimeout,f=e.logLevel,h=e.filterLogsByTag,v=e.logTransports;(0,m.setupLogger)(f,v,h),m.default.info("CollabPostgresDB version ".concat("2.0.0")),g.default.set((function(){return"NOW()"})),this.dbClient=new p({user:t,database:n,password:r,port:a,host:o,connectionString:s,ssl:i,statement_timeout:u,query_timeout:d,idle_in_transaction_session_timeout:l}),this.dbConnected=!1}return e.prototype.setServer=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn("collabDB.setServer() is no longer required. You may remove this function call from your code.")},e.prototype.connectDB=function(){return i(this,void 0,void 0,(function(){var e;return u(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.dbClient.connect()];case 1:return t.sent(),this.dbConnected=!0,m.default.info("--\x3e Database connected"),[2];case 2:return e=t.sent(),m.default.error("--\x3e Database connection error",{meta:e.stack}),[3,3];case 3:return[2]}}))}))},e.prototype.disconnectDB=function(){return i(this,void 0,void 0,(function(){var e;return u(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.dbClient.end()];case 1:return t.sent(),this.dbConnected=!1,m.default.info("--\x3e Database disconnected"),[2];case 2:return e=t.sent(),m.default.error("--\x3e Database disconnection error",{meta:e.stack}),[3,3];case 3:return[2]}}))}))},e.prototype.getQueryResponse=function(e,t){var n,r=t.text;return null===(n=t.values)||void 0===n||n.forEach((function(e,t){var n=new RegExp("\\$".concat(t+1),"g");r=r.replace(n,e)})),this.dbConnected||(0,h.throwError)("Database Query","Database not connected, please do db.connectDB() first."),this.dbClient.query(t).then((function(e){var t=(0,y.keysToCamel)(e.rows);return t.forEach((function(e){e.id&&(e.id="".concat(e.id)),e.authorId&&(e.authorId="".concat(e.authorId)),e.documentId&&(e.documentId="".concat(e.documentId)),e.userId&&(e.userId="".concat(e.userId)),e.annotationId&&(e.annotationId="".concat(e.annotationId)),e.inReplyTo&&(e.inReplyTo="".concat(e.inReplyTo)),Object.keys(e).forEach((function(t){_.TimestampProperties.includes(t)&&(e[t]=new Date(e[t]).getTime())}))})),t}))},e.prototype.getUser=function(e){return i(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return(0,h.validateParams)("getUser(id)",{id:[e,"string"]}),t={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE id = $1 LIMIT 1",values:[e]},[4,this.getQueryResponse("getUser",t)];case 1:return[2,n.sent()[0]||null]}}))}))},e.prototype.getUserByEmail=function(e){return i(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return(0,h.validateParams)("getUserByEmail(email)",{email:[e,"string"]}),t={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE email = $1 LIMIT 1",values:[e]},[4,this.getQueryResponse("getUserByEmail",t)];case 1:return[2,n.sent()[0]||null]}}))}))},e.prototype.getUserByUsername=function(e){return i(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return(0,h.validateParams)("getUserByUsername(userName)",{userName:[e,"string"]}),t={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE user_name = $1 LIMIT 1",values:[e]},[4,this.getQueryResponse("getUserByUsername",t)];case 1:return[2,n.sent()[0]||null]}}))}))},e.prototype.getUsers=function(e){return i(this,void 0,void 0,(function(){var t,n;return u(this,(function(r){switch(r.label){case 0:return(0,h.validateParams)("getUsers(ids)",{ids:[e,"array"]}),t=e.map((function(e,t){return"$".concat(t+1)})).join(","),n={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE id in (".concat(t,")"),values:e},[4,this.getQueryResponse("getUsers",n)];case 1:return[2,r.sent()]}}))}))},e.prototype.createUser=function(e){return i(this,void 0,void 0,(function(){var t,n,a,o,s;return u(this,(function(i){switch(i.label){case 0:return(0,h.validateParams)("createUser(user)",{user:[e,"object"],"user.email":[e.email,"string"],"user.password":[e.password,"string"],"user.userName":[e.userName,"string",!1]}),t=Date.now(),[4,(0,v.generateId)()];case 1:n=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),a=r({id:n,type:b.UserTypes.Standard,createdAt:t,updatedAt:t},e),o=(0,y.getQuery)({type:y.Command.Insert,table:"users",params:a}),[4,this.getQueryResponse("createUser",o)];case 3:return i.sent(),[2,a];case 4:return s=i.sent(),(0,h.throwError)("db.createUser","Fail to generate id: ".concat(s)),[3,5];case 5:return[2]}}))}))},e.prototype.editUser=function(e){return i(this,void 0,void 0,(function(){var t,n;return u(this,(function(a){switch(a.label){case 0:return(0,h.validateParams)("editUser(user)",{user:[e,"object"],"user.id":[e.id,"string"],"user.email":[e.email,"string",!1],"user.password":[e.password,"string",!1],"user.userName":[e.userName,"string",!1]}),t=Date.now(),n=(0,y.getQuery)({type:y.Command.Update,id:e.id,table:"users",params:r(r({},e),{updatedAt:e.updatedAt||t})}),[4,this.getQueryResponse("editUser",n)];case 1:return[2,a.sent()[0]||null]}}))}))},e.prototype.getResolvers=function(){var e=this,t="id, user_name, email, type, created_at, updated_at";return{Query:{user:function(n){return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return e={text:"SELECT ".concat(t," FROM users WHERE id = $1 LIMIT 1"),values:[n]},[4,this.getQueryResponse("Query.user",e)];case 1:return[2,r.sent()[0]||null]}}))}))},userWithEmail:function(n){return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return e={text:"SELECT ".concat(t," FROM users WHERE email = $1 LIMIT 1"),values:[n]},[4,this.getQueryResponse("Query.userWithEmail",e)];case 1:return[2,r.sent()[0]||null]}}))}))},annotations:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h,v,b;return u(this,(function(u){switch(u.label){case 0:return e=t.ids,n=t.documentId,r=t.annotationIds,a=t.filters,o=void 0===a?{}:a,s=t.inReplyTo,i=t.pageNumbers,l=o.limit,p=o.orderBy,m=o.orderDirection,h=void 0===m?"DESC":m,v="\n SELECT ".concat("id, xfdf, annot_contents, author_id, annotation_id, document_id, page_number, in_reply_to, created_at, updated_at","\n FROM annotations\n ").concat((0,f.whereAnd)(d([e&&e.length&&(0,f.valueIn)("id",e),r&&r&&(0,f.valueIn)("annotation_id",r),n&&"document_id = '".concat(n,"'"),s&&"in_reply_to = '".concat(s,"'"),i&&i.length&&(0,f.valueIn)("page_number",i)],c((0,f.getFilterQuery)(o)),!1)),"\n "),p&&(v+=" ORDER BY ".concat((0,y.camelToSnake)(p)," ").concat(h)),l&&(v+=" LIMIT ".concat(l)),b={text:v},[4,this.getQueryResponse("Query.annotations",b)];case 1:return[2,u.sent()]}}))}))},documents:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h;return u(this,(function(u){switch(u.label){case 0:return e=t.ids,n=t.userId,r=t.filters,a=void 0===r?{}:r,o=t.isPublic,s=a.limit,i=a.orderBy,l=a.orderDirection,p=void 0===l?"DESC":l,m="\n SELECT ".concat("id, author_id, is_public, name, created_at, updated_at","\n FROM documents\n ").concat((0,f.whereAnd)(d([e&&e.length&&(0,f.valueIn)("id",e),o&&"is_public = true",n&&"id in (SELECT document_id FROM document_members WHERE user_id = '".concat(n,"')")],c((0,f.getFilterQuery)(a)),!1)),"\n "),i&&(m+=" ORDER BY ".concat((0,y.camelToSnake)(i)," ").concat(p)),s&&(m+=" LIMIT ".concat(s)),h={text:m},[4,this.getQueryResponse("Query.documents",h)];case 1:return[2,u.sent()]}}))}))},annotationMembers:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h,v;return u(this,(function(u){switch(u.label){case 0:return e=t.annotationId,n=t.ids,r=t.userId,a=t.filters,o=void 0===a?{}:a,s=t.documentId,i=o.limit,l=o.orderBy,p=o.orderDirection,m=void 0===p?"DESC":p,h="\n SELECT ".concat("id, user_id, document_id, annotation_id, last_read, updated_at, created_at, annotation_created_at","\n FROM annotation_members\n ").concat((0,f.whereAnd)(d([n&&n.length&&(0,f.valueIn)("id",n),e&&"annotation_id = '".concat(e,"'"),s&&"document_id = '".concat(s,"'"),r&&"user_id = '".concat(r,"'")],c((0,f.getFilterQuery)(o)),!1)),"\n "),l&&(h+=" ORDER BY ".concat((0,y.camelToSnake)(l)," ").concat(m)),i&&(h+=" LIMIT ".concat(i)),v={text:h},[4,this.getQueryResponse("Query.annotationMembers",v)];case 1:return[2,u.sent()]}}))}))},documentMembers:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h;return u(this,(function(u){switch(u.label){case 0:return e=t.documentId,n=t.userId,r=t.ids,a=t.filters,s=(o=void 0===a?{}:a).limit,i=o.orderBy,l=o.orderDirection,p=void 0===l?"DESC":l,m="\n SELECT ".concat("id, user_id, document_id, last_read, created_at, updated_at","\n FROM document_members\n ").concat((0,f.whereAnd)(d([r&&r.length&&(0,f.valueIn)("id",r),e&&"document_id = '".concat(e,"'"),n&&"user_id = '".concat(n,"'")],c((0,f.getFilterQuery)(o)),!1)),"\n "),i&&(m+=" ORDER BY ".concat((0,y.camelToSnake)(i)," ").concat(p)),s&&(m+=" LIMIT ".concat(s)),h={text:m},[4,this.getQueryResponse("Query.documentMembers",h)];case 1:return[2,u.sent()]}}))}))},mentions:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h;return u(this,(function(u){switch(u.label){case 0:return e=t.annotationId,n=t.userId,r=t.documentId,a=t.ids,o=t.filters,i=(s=void 0===o?{}:o).limit,l=s.orderBy,p=s.orderDirection,m="\n SELECT ".concat("id, user_id, annotation_id, document_id, created_at, updated_at","\n FROM mentions\n ").concat((0,f.whereAnd)(d([a&&a.length&&(0,f.valueIn)("id",a),r&&"document_id = '".concat(r,"'"),e&&"annotation_id = '".concat(e,"'"),n&&"user_id = '".concat(n,"'")],c((0,f.getFilterQuery)(s)),!1)),"\n "),l&&(m+=" ORDER BY ".concat((0,y.camelToSnake)(l)," ").concat(p)),i&&(m+=" LIMIT ".concat(i)),h={text:m},[4,this.getQueryResponse("Query.mentions",h)];case 1:return[2,u.sent()]}}))}))},annotationCount:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a;return u(this,(function(o){switch(o.label){case 0:return e=t.since,n=t.documentId,r={text:"SELECT COUNT(DISTINCT id) FROM annotations WHERE document_id = $1 AND ".concat((0,f.toUnixTimestampSelector)("created_at")," > $2 AND author_id IS NOT NULL"),values:[n,e]},[4,this.getQueryResponse("Query.annotationCount",r)];case 1:return a=o.sent(),[2,Number(a[0].count||0)]}}))}))},annotationMemberCount:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o;return u(this,(function(s){switch(s.label){case 0:return e=t.userId,n=t.documentId,r=t.since,a={text:"SELECT COUNT(DISTINCT id) FROM annotation_members WHERE document_id = $1 AND user_id = $2 AND ".concat((0,f.toUnixTimestampSelector)("annotation_created_at")," > $3"),values:[n,e,r]},[4,this.getQueryResponse("Query.annotationMemberCount",a)];case 1:return o=s.sent(),[2,Number(o[0].count||0)]}}))}))},snapshots:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m;return u(this,(function(u){switch(u.label){case 0:return e=t.ids,n=t.documentId,r=t.filters,o=(a=void 0===r?{}:r).limit,s=a.orderBy,i=a.orderDirection,l=void 0===i?"DESC":i,p="\n SELECT ".concat("id, author_id, document_id, xfdf, name, created_at, updated_at","\n FROM snapshots\n ").concat((0,f.whereAnd)(d([e&&e.length&&(0,f.valueIn)("id",e),n&&"document_id = '".concat(n,"'")],c((0,f.getFilterQuery)(a)),!1)),"\n "),s&&(p+=" ORDER BY ".concat((0,y.camelToSnake)(s)," ").concat(l)),o&&(p+=" LIMIT ".concat(o)),m={text:p},[4,this.getQueryResponse("Query.snapshots",m)];case 1:return[2,u.sent()]}}))}))},snapshotAssets:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a;return u(this,(function(o){switch(o.label){case 0:return e=t.ids,n=t.snapshotId,r="\n SELECT ".concat("id, snapshot_id, data, created_at, updated_at","\n FROM snapshot_assets\n ").concat((0,f.whereAnd)([e&&e.length&&(0,f.valueIn)("id",e),n&&"snapshot_id = '".concat(n,"'")]),"\n "),a={text:r},[4,this.getQueryResponse("Query.snapshotAsset",a)];case 1:return[2,o.sent()]}}))}))}},Mutation:{addUser:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return t.id?[3,2]:(e=t,[4,(0,v.generateId)()]);case 1:e.id=r.sent(),r.label=2;case 2:return n=(0,y.getQuery)({type:y.Command.Insert,table:"users",params:t}),[4,this.getQueryResponse("Mutation.addUser",n)];case 3:return[2,r.sent()[0]||null]}}))}))},addAnnotation:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d,l,f,p,m;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return p=u.sent(),[3,3];case 2:p=e,u.label=3;case 3:return n=p,r=t.xfdf,a=t.annotationId,o=t.documentId,s=t.pageNumber,i=t.createdAt,c=t.inReplyTo,d=t.authorId,l=t.updatedAt,f=t.annotContents,m=(0,y.getQuery)({type:y.Command.Insert,table:"annotations",params:{id:n,xfdf:r,annotContents:f,authorId:d,annotationId:a,documentId:o,pageNumber:s,createdAt:i,inReplyTo:c,updatedAt:l}}),[4,this.getQueryResponse("Mutation.addAnnotation",m)];case 4:return[2,u.sent()[0]||null]}}))}))},editAnnotation:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a,o,s;return u(this,(function(i){switch(i.label){case 0:return e=n.xfdf,r=n.pageNumber,a=n.updatedAt,o=n.annotContents,s=(0,y.getQuery)({type:y.Command.Update,id:t,table:"annotations",params:{xfdf:e,annotContents:o,pageNumber:r,updatedAt:a}}),[4,this.getQueryResponse("Mutation.editAnnotation",s)];case 1:return[2,i.sent()[0]||null]}}))}))},deleteAnnotation:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"annotations",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteAnnotation",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addDocument:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return c=u.sent(),[3,3];case 2:c=e,u.label=3;case 3:return n=c,r=t.authorId,a=t.isPublic,o=t.name,s=t.createdAt,i=t.updatedAt,d=(0,y.getQuery)({type:y.Command.Insert,table:"documents",params:{id:n,authorId:r,isPublic:a,name:o,createdAt:s,updatedAt:i}}),[4,this.getQueryResponse("Mutation.addDocument",d)];case 4:return[2,u.sent()[0]||null]}}))}))},editDocument:function(t,n){return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return e=(0,y.getQuery)({type:y.Command.Update,id:t,table:"documents",params:n}),[4,this.getQueryResponse("Mutation.editDocument",e)];case 1:return[2,r.sent()[0]||null]}}))}))},deleteDocument:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"documents",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteDocument",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addDocumentMember:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return c=u.sent(),[3,3];case 2:c=e,u.label=3;case 3:return n=c,r=t.userId,a=t.documentId,o=t.lastRead,s=t.createdAt,i=t.updatedAt,d=(0,y.getQuery)({type:y.Command.Insert,table:"document_members",params:{id:n,userId:r,documentId:a,lastRead:o,createdAt:s,updatedAt:i}}),[4,this.getQueryResponse("Mutation.addDocumentMember",d)];case 4:return[2,u.sent()[0]||null]}}))}))},editDocumentMember:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.lastRead,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"document_members",params:{lastRead:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editDocumentMember",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteDocumentMember:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"document_members",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteDocumentMember",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addAnnotationMember:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d,l,f;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return l=u.sent(),[3,3];case 2:l=e,u.label=3;case 3:return n=l,r=t.userId,a=t.documentId,o=t.annotationId,s=t.lastRead,i=t.annotationCreatedAt,c=t.createdAt,d=t.updatedAt,f=(0,y.getQuery)({type:y.Command.Insert,table:"annotation_members",params:{id:n,userId:r,documentId:a,annotationId:o,lastRead:s,annotationCreatedAt:i,createdAt:c,updatedAt:d}}),[4,this.getQueryResponse("Mutation.addAnnotationMember",f)];case 4:return[2,u.sent()[0]||null]}}))}))},editAnnotationMember:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.lastRead,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"annotation_members",params:{lastRead:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editAnnotationMember",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteAnnotationMember:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"annotation_members",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteAnnotationMember",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addMention:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return c=u.sent(),[3,3];case 2:c=e,u.label=3;case 3:return n=c,r=t.userId,a=t.documentId,o=t.annotationId,s=t.createdAt,i=t.updatedAt,d=(0,y.getQuery)({type:y.Command.Insert,table:"mentions",params:{id:n,userId:r,documentId:a,annotationId:o,createdAt:s,updatedAt:i}}),[4,this.getQueryResponse("Mutation.addMention",d)];case 4:return[2,u.sent()[0]||null]}}))}))},deleteMention:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"mentions",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteMention",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addSnapshot:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d,l;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return d=u.sent(),[3,3];case 2:d=e,u.label=3;case 3:return n=d,r=t.authorId,a=t.documentId,o=t.xfdf,s=t.name,i=t.createdAt,c=t.updatedAt,l=(0,y.getQuery)({type:y.Command.Insert,table:"snapshots",params:{id:n,authorId:r,documentId:a,xfdf:o,name:s,createdAt:i,updatedAt:c}}),[4,this.getQueryResponse("Mutation.addSnapshot",l)];case 4:return[2,u.sent()[0]||null]}}))}))},editSnapshot:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.name,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"snapshots",params:{name:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editSnapshot",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteSnapshot:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"snapshots",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteSnapshot",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addSnapshotAsset:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return i=u.sent(),[3,3];case 2:i=e,u.label=3;case 3:return n=i,r=t.snapshotId,a=t.data,o=t.createdAt,s=t.updatedAt,c=(0,y.getQuery)({type:y.Command.Insert,table:"snapshot_assets",params:{id:n,snapshotId:r,data:a,createdAt:o,updatedAt:s}}),[4,this.getQueryResponse("Mutation.addSnapshotAsset",c)];case 4:return[2,u.sent()[0]||null]}}))}))},editSnapshotAsset:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.snapshotId,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"snapshot_assets",params:{snapshotId:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editSnapshotAsset",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteSnapshotAsset:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"snapshot_assets",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteSnapshotAsset",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))}}}},e.LogLevels=m.LogLevels,e.LogTags=m.LogTags,e}();t.default=I;var E=n(5);Object.defineProperty(t,"UserTypes",{enumerable:!0,get:function(){return E.UserTypes}});var T=n(0);Object.defineProperty(t,"LogLevels",{enumerable:!0,get:function(){return T.LogLevels}}),Object.defineProperty(t,"LogTags",{enumerable:!0,get:function(){return T.LogTags}})},function(e,t){e.exports=require("pg")},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.addTransports=t.addConsoleTransport=void 0;var s=o(n(4)),i=n(0);t.addConsoleTransport=function(e,t,n){void 0===t&&(t=i.LogLevels.INFO),e.add(new s.default.transports.Console({level:t,format:s.format.combine((0,s.format)((function(e){return(!n||e.tag===n)&&e}))(),s.format.colorize(),s.format.printf((function(e){var t=u(e.message),n=e.tag?" [".concat(e.tag,"]"):"",r=u(e.meta);return"".concat(e.timestamp," ").concat(e.level).concat(n,": ").concat(t," ").concat(r)})),s.format.metadata({fillExcept:["message","level","timestamp","label"]}))}))};t.addTransports=function(e,t){t.forEach((function(t){return e.add(t)}))};var u=function(e){var t=e||"";return"object"==typeof e&&null!==e&&(t=JSON.stringify(e,null,2)),t}},function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return s},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.validateResolver=t.validateParams=t.throwError=t.ErrorCodes=void 0;var o=a(n(0));t.ErrorCodes={PERMISSION_ERROR:"PERMISSION_ERROR"};t.throwError=function(e,t,n){var r=t;throw"string"!=typeof r&&(r=t.message||t.toString()),r="".concat(e," - ").concat(r),o.default.error(r),n?new n(r):"string"!=typeof t?t:new Error(r)};t.validateParams=function(e,t){var n,a=function(t){var n="".concat(e,' - Paramater "').concat(t,'" is required');throw o.default.error(n),new Error(n)},s=function(t,n,r){var a="".concat(e,' - Parameter "').concat(t,'" expected type "').concat(r,'" but got "').concat(n,'"');throw o.default.error(a),new Error(a)};for(var i in t){var u=r(t[i],3),c=u[0],d=u[1],l=void 0===d?"any":d,f=u[2],p=void 0===f||f;if(null!=c&&""!==c){if("any"!==l){var m=typeof c;if("string"!==l){if("number"!==l){if("array"!==l){if("blob"!==l){if("boolean"!==l){if("object"!==l){if("function"!==l);else if(!(n=c)||"[object Function]"!=={}.toString.call(n))return s(i,m,l)}else if("object"!==m)return s(i,m,l)}else if("boolean"!==m)return s(i,m,l)}else if(!(c instanceof Blob))return s(i,m,l)}else if(!Array.isArray(c))return s(i,m,l)}else if("number"!==m)return s(i,m,l)}else if("string"!==m)return s(i,m,l)}}else if(p)return a(i)}};t.validateResolver=function(e,n){n||(0,t.throwError)(e,"Could not find resolvers for the ".concat(e,". Please make sure you provide resolvers for ").concat(e,"."))}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateId=t.setGenerator=void 0;var o=n(11),s=function(){return(0,o.v4)()};t.setGenerator=function(e){s=e};t.generateId=function(){return r(void 0,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,s()];case 1:return[2,e.sent()]}}))}))}},function(e,t){e.exports=require("uuid")}]).default})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CollabPostgres=t():e.CollabPostgres=t()}(global,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogger=t.LogLevels=t.LogTags=void 0;var s,i=o(n(4)),u=n(8);!function(e){e.STANDARD="STANDARD",e.ENTITY="ENTITY",e.QUERY="QUERY",e.MUTATION="MUTATION",e.RESPONSE="RESPONSE",e.AUTH="AUTH",e.CACHE="CACHE",e.CONNECTED_USERS="CONNECTED_USERS",e.SCROLL_SYNC="SCROLL_SYNC",e.USERNAMES="USERNAMES",e.ANNOTATION_SYNC="ANNOTATION_SYNC"}(t.LogTags||(t.LogTags={})),function(e){e.ERROR="error",e.WARN="warn",e.INFO="info",e.HTTP="http",e.VERBOSE="verbose",e.DEBUG="debug",e.SILLY="silly",e.NONE="none"}(s=t.LogLevels||(t.LogLevels={}));var c=i.default.createLogger({format:i.format.combine(i.format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}))});t.setupLogger=function(e,t,n){e===s.NONE?c.silent=!0:((0,u.addConsoleTransport)(c,e,n),t&&t.length&&(0,u.addTransports)(c,t))},t.default=c},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getQuery=t.toUnixTimestampSelector=t.camelToSnake=t.keysToCamel=t.valueIn=t.getFilterQuery=t.whereAnd=t.Command=void 0;var a=r(n(2)),o=n(3);!function(e){e.Insert="INSERT",e.Update="UPDATE",e.Delete="DELETE"}(t.Command||(t.Command={}));t.whereAnd=function(e){var t=e.filter((function(e){return!!e}));return t.reduce((function(e,n,r){var a=r===t.length-1;return"".concat(e," ").concat(n," ").concat(a?"":"AND")}),"WHERE ")};t.getFilterQuery=function(e){return[e.createdBefore&&"".concat((0,t.toUnixTimestampSelector)("created_at")," < ").concat(e.createdBefore),e.createdAfter&&"".concat((0,t.toUnixTimestampSelector)("created_at")," > ").concat(e.createdAfter),e.updatedBefore&&"".concat((0,t.toUnixTimestampSelector)("updated_at")," < ").concat(e.updatedBefore),e.updatedAfter&&"".concat((0,t.toUnixTimestampSelector)("updated_at")," > ").concat(e.updatedAfter)]};t.valueIn=function(e,t){return"".concat(e," IN (").concat(t.reduce((function(e,n,r){var a=r===t.length-1?"":",";return"string"==typeof n?e+"'".concat(n,"'").concat(a):e+"".concat(n).concat(a)}),""),")")};var s=function(e){return Array.isArray(e)},i=function(e){return e===Object(e)&&!s(e)&&"function"!=typeof e&&!function(e){return e instanceof Date}(e)};t.keysToCamel=function(e){if(i(e)){var n={};return Object.keys(e).forEach((function(r){var a;n[(a=r,a.replace(/([-_][a-z])/gi,(function(e){return e.toUpperCase().replace("-","").replace("_","")})))]=(0,t.keysToCamel)(e[r])})),n}return s(e)?e.map((function(e){return(0,t.keysToCamel)(e)})):e};t.camelToSnake=function(e){return e.replace(/[\w]([A-Z])/g,(function(e){return e[0]+"_"+e[1]})).toLowerCase()};t.toUnixTimestampSelector=function(e){return"EXTRACT(epoch FROM date_trunc('milliseconds', ".concat(e,")) * 1000")};t.getQuery=function(e){var n=e.type,r=e.id,s=e.table,i=e.params,u=Object.keys(i),c=[],d=[],l=[],f=[],p=1;u.forEach((function(e){var r=i[e];if(void 0!==r){if(o.TimestampProperties.includes(e))if(o.NowTimestampProperties.includes(e))f.push(a.default.getNow());else try{var s=new Date(r);f.push(s.toISOString())}catch(t){throw new Error('Failed to parse date for "'.concat(e,'" - tried to convert ').concat(JSON.stringify(r)," to a date but could not."))}else f.push(r);c.push((0,t.camelToSnake)(e)),"INSERT"===n&&l.push("$".concat(p)),d.push("".concat((0,t.camelToSnake)(e)," = $").concat(p)),p+=1}}));var m=null;switch(n){case"INSERT":m="INSERT INTO ".concat(s," (").concat(c.join(", "),") VALUES(").concat(l.join(", "),") RETURNING *;");break;case"UPDATE":m="UPDATE ".concat(s," SET ").concat(d.join(", ")," WHERE id = '").concat(r,"' RETURNING *;");break;case"DELETE":m="DELETE FROM ".concat(s," WHERE ").concat(d.join(" AND ")," RETURNING id;")}return{text:m,values:f}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.indicator="NOW",this._current=function(){return"CURRENT_TIMESTAMP"}}return e.prototype.set=function(e){this._current=e},e.prototype.getNow=function(){return this._current()},e}();t.default=new r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringIdProperties=t.NowTimestampProperties=t.TimestampProperties=void 0,t.TimestampProperties=["createdAt","updatedAt","lastRead","annotationCreatedAt"],t.NowTimestampProperties=["createdAt","updatedAt","lastRead"],t.StringIdProperties=["id","userId","snapshotId","authorId","documentId","annotationId"]},function(e,t){e.exports=require("winston")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QueryType=t.UserTypes=t.UserStatus=void 0,function(e){e.Active="ACTIVE",e.Inactive="INACTIVE"}(t.UserStatus||(t.UserStatus={})),function(e){e.Anonymous="ANONYMOUS",e.Standard="STANDARD"}(t.UserTypes||(t.UserTypes={})),function(e){e.Single="SINGLE",e.Multiple="MULTIPLE"}(t.QueryType||(t.QueryType={}))},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},a=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&a(t,e,n);return o(t,e),t},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))},u=this&&this.__generator||function(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}},c=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return s},d=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))},l=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogTags=t.LogLevels=t.UserTypes=void 0;var f=n(1),p=l(n(7)).default.Client,m=s(n(0)),h=n(9),v=n(10),y=n(1),b=n(5),g=l(n(2)),_=n(3),I=function(){function e(e){var t=e.username,n=e.dbName,r=e.password,a=e.port,o=e.host,s=e.connectionString,i=e.ssl,u=e.statementTimeout,c=e.queryTimeout,d=void 0===c?5e3:c,l=e.idleInTransactionSessionTimeout,f=e.logLevel,h=e.filterLogsByTag,v=e.logTransports;(0,m.setupLogger)(f,v,h),m.default.info("CollabPostgresDB version ".concat("2.0.1-alpha.0")),g.default.set((function(){return"NOW()"})),this.dbClient=new p({user:t,database:n,password:r,port:a,host:o,connectionString:s,ssl:i,statement_timeout:u,query_timeout:d,idle_in_transaction_session_timeout:l}),this.dbConnected=!1}return e.prototype.setServer=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];console.warn("collabDB.setServer() is no longer required. You may remove this function call from your code.")},e.prototype.connectDB=function(){return i(this,void 0,void 0,(function(){var e;return u(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.dbClient.connect()];case 1:return t.sent(),this.dbConnected=!0,m.default.info("--\x3e Database connected"),[2];case 2:return e=t.sent(),m.default.error("--\x3e Database connection error",{meta:e.stack}),[3,3];case 3:return[2]}}))}))},e.prototype.disconnectDB=function(){return i(this,void 0,void 0,(function(){var e;return u(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.dbClient.end()];case 1:return t.sent(),this.dbConnected=!1,m.default.info("--\x3e Database disconnected"),[2];case 2:return e=t.sent(),m.default.error("--\x3e Database disconnection error",{meta:e.stack}),[3,3];case 3:return[2]}}))}))},e.prototype.getQueryResponse=function(e,t){var n,r=t.text;return null===(n=t.values)||void 0===n||n.forEach((function(e,t){var n=new RegExp("\\$".concat(t+1),"g");r=r.replace(n,e)})),this.dbConnected||(0,h.throwError)("Database Query","Database not connected, please do db.connectDB() first."),this.dbClient.query(t).then((function(e){var t=(0,y.keysToCamel)(e.rows);return t.forEach((function(e){e.id&&(e.id="".concat(e.id)),e.authorId&&(e.authorId="".concat(e.authorId)),e.documentId&&(e.documentId="".concat(e.documentId)),e.userId&&(e.userId="".concat(e.userId)),e.annotationId&&(e.annotationId="".concat(e.annotationId)),e.inReplyTo&&(e.inReplyTo="".concat(e.inReplyTo)),Object.keys(e).forEach((function(t){_.TimestampProperties.includes(t)&&(e[t]=new Date(e[t]).getTime())}))})),t}))},e.prototype.getUser=function(e){return i(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return(0,h.validateParams)("getUser(id)",{id:[e,"string"]}),t={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE id = $1 LIMIT 1",values:[e]},[4,this.getQueryResponse("getUser",t)];case 1:return[2,n.sent()[0]||null]}}))}))},e.prototype.getUserByEmail=function(e){return i(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return(0,h.validateParams)("getUserByEmail(email)",{email:[e,"string"]}),t={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE email = $1 LIMIT 1",values:[e]},[4,this.getQueryResponse("getUserByEmail",t)];case 1:return[2,n.sent()[0]||null]}}))}))},e.prototype.getUserByUsername=function(e){return i(this,void 0,void 0,(function(){var t;return u(this,(function(n){switch(n.label){case 0:return(0,h.validateParams)("getUserByUsername(userName)",{userName:[e,"string"]}),t={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE user_name = $1 LIMIT 1",values:[e]},[4,this.getQueryResponse("getUserByUsername",t)];case 1:return[2,n.sent()[0]||null]}}))}))},e.prototype.getUsers=function(e){return i(this,void 0,void 0,(function(){var t,n;return u(this,(function(r){switch(r.label){case 0:return(0,h.validateParams)("getUsers(ids)",{ids:[e,"array"]}),t=e.map((function(e,t){return"$".concat(t+1)})).join(","),n={text:"SELECT id, user_name, email, password, status, type, custom_data, created_at, updated_at FROM users WHERE id in (".concat(t,")"),values:e},[4,this.getQueryResponse("getUsers",n)];case 1:return[2,r.sent()]}}))}))},e.prototype.createUser=function(e){return i(this,void 0,void 0,(function(){var t,n,a,o,s;return u(this,(function(i){switch(i.label){case 0:return(0,h.validateParams)("createUser(user)",{user:[e,"object"],"user.email":[e.email,"string"],"user.password":[e.password,"string"],"user.userName":[e.userName,"string",!1]}),t=Date.now(),[4,(0,v.generateId)()];case 1:n=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),a=r({id:n,type:b.UserTypes.Standard,createdAt:t,updatedAt:t},e),o=(0,y.getQuery)({type:y.Command.Insert,table:"users",params:a}),[4,this.getQueryResponse("createUser",o)];case 3:return i.sent(),[2,a];case 4:return s=i.sent(),(0,h.throwError)("db.createUser","Fail to generate id: ".concat(s)),[3,5];case 5:return[2]}}))}))},e.prototype.editUser=function(e){return i(this,void 0,void 0,(function(){var t,n;return u(this,(function(a){switch(a.label){case 0:return(0,h.validateParams)("editUser(user)",{user:[e,"object"],"user.id":[e.id,"string"],"user.email":[e.email,"string",!1],"user.password":[e.password,"string",!1],"user.userName":[e.userName,"string",!1]}),t=Date.now(),n=(0,y.getQuery)({type:y.Command.Update,id:e.id,table:"users",params:r(r({},e),{updatedAt:e.updatedAt||t})}),[4,this.getQueryResponse("editUser",n)];case 1:return[2,a.sent()[0]||null]}}))}))},e.prototype.getResolvers=function(){var e=this,t="id, user_name, email, type, created_at, updated_at";return{Query:{user:function(n){return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return e={text:"SELECT ".concat(t," FROM users WHERE id = $1 LIMIT 1"),values:[n]},[4,this.getQueryResponse("Query.user",e)];case 1:return[2,r.sent()[0]||null]}}))}))},userWithEmail:function(n){return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return e={text:"SELECT ".concat(t," FROM users WHERE email = $1 LIMIT 1"),values:[n]},[4,this.getQueryResponse("Query.userWithEmail",e)];case 1:return[2,r.sent()[0]||null]}}))}))},annotations:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h,v,b;return u(this,(function(u){switch(u.label){case 0:return e=t.ids,n=t.documentId,r=t.annotationIds,a=t.filters,o=void 0===a?{}:a,s=t.inReplyTo,i=t.pageNumbers,l=o.limit,p=o.orderBy,m=o.orderDirection,h=void 0===m?"DESC":m,v="\n SELECT ".concat("id, xfdf, annot_contents, author_id, annotation_id, document_id, page_number, in_reply_to, created_at, updated_at","\n FROM annotations\n ").concat((0,f.whereAnd)(d([e&&e.length&&(0,f.valueIn)("id",e),r&&r&&(0,f.valueIn)("annotation_id",r),n&&"document_id = '".concat(n,"'"),s&&"in_reply_to = '".concat(s,"'"),i&&i.length&&(0,f.valueIn)("page_number",i)],c((0,f.getFilterQuery)(o)),!1)),"\n "),p&&(v+=" ORDER BY ".concat((0,y.camelToSnake)(p)," ").concat(h)),l&&(v+=" LIMIT ".concat(l)),b={text:v},[4,this.getQueryResponse("Query.annotations",b)];case 1:return[2,u.sent()]}}))}))},documents:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h;return u(this,(function(u){switch(u.label){case 0:return e=t.ids,n=t.userId,r=t.filters,a=void 0===r?{}:r,o=t.isPublic,s=a.limit,i=a.orderBy,l=a.orderDirection,p=void 0===l?"DESC":l,m="\n SELECT ".concat("id, author_id, is_public, name, created_at, updated_at","\n FROM documents\n ").concat((0,f.whereAnd)(d([e&&e.length&&(0,f.valueIn)("id",e),o&&"is_public = true",n&&"id in (SELECT document_id FROM document_members WHERE user_id = '".concat(n,"')")],c((0,f.getFilterQuery)(a)),!1)),"\n "),i&&(m+=" ORDER BY ".concat((0,y.camelToSnake)(i)," ").concat(p)),s&&(m+=" LIMIT ".concat(s)),h={text:m},[4,this.getQueryResponse("Query.documents",h)];case 1:return[2,u.sent()]}}))}))},annotationMembers:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h,v;return u(this,(function(u){switch(u.label){case 0:return e=t.annotationId,n=t.ids,r=t.userId,a=t.filters,o=void 0===a?{}:a,s=t.documentId,i=o.limit,l=o.orderBy,p=o.orderDirection,m=void 0===p?"DESC":p,h="\n SELECT ".concat("id, user_id, document_id, annotation_id, last_read, updated_at, created_at, annotation_created_at","\n FROM annotation_members\n ").concat((0,f.whereAnd)(d([n&&n.length&&(0,f.valueIn)("id",n),e&&"annotation_id = '".concat(e,"'"),s&&"document_id = '".concat(s,"'"),r&&"user_id = '".concat(r,"'")],c((0,f.getFilterQuery)(o)),!1)),"\n "),l&&(h+=" ORDER BY ".concat((0,y.camelToSnake)(l)," ").concat(m)),i&&(h+=" LIMIT ".concat(i)),v={text:h},[4,this.getQueryResponse("Query.annotationMembers",v)];case 1:return[2,u.sent()]}}))}))},documentMembers:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h;return u(this,(function(u){switch(u.label){case 0:return e=t.documentId,n=t.userId,r=t.ids,a=t.filters,s=(o=void 0===a?{}:a).limit,i=o.orderBy,l=o.orderDirection,p=void 0===l?"DESC":l,m="\n SELECT ".concat("id, user_id, document_id, last_read, created_at, updated_at","\n FROM document_members\n ").concat((0,f.whereAnd)(d([r&&r.length&&(0,f.valueIn)("id",r),e&&"document_id = '".concat(e,"'"),n&&"user_id = '".concat(n,"'")],c((0,f.getFilterQuery)(o)),!1)),"\n "),i&&(m+=" ORDER BY ".concat((0,y.camelToSnake)(i)," ").concat(p)),s&&(m+=" LIMIT ".concat(s)),h={text:m},[4,this.getQueryResponse("Query.documentMembers",h)];case 1:return[2,u.sent()]}}))}))},mentions:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m,h;return u(this,(function(u){switch(u.label){case 0:return e=t.annotationId,n=t.userId,r=t.documentId,a=t.ids,o=t.filters,i=(s=void 0===o?{}:o).limit,l=s.orderBy,p=s.orderDirection,m="\n SELECT ".concat("id, user_id, annotation_id, document_id, created_at, updated_at","\n FROM mentions\n ").concat((0,f.whereAnd)(d([a&&a.length&&(0,f.valueIn)("id",a),r&&"document_id = '".concat(r,"'"),e&&"annotation_id = '".concat(e,"'"),n&&"user_id = '".concat(n,"'")],c((0,f.getFilterQuery)(s)),!1)),"\n "),l&&(m+=" ORDER BY ".concat((0,y.camelToSnake)(l)," ").concat(p)),i&&(m+=" LIMIT ".concat(i)),h={text:m},[4,this.getQueryResponse("Query.mentions",h)];case 1:return[2,u.sent()]}}))}))},annotationCount:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a;return u(this,(function(o){switch(o.label){case 0:return e=t.since,n=t.documentId,r={text:"SELECT COUNT(DISTINCT id) FROM annotations WHERE document_id = $1 AND ".concat((0,f.toUnixTimestampSelector)("created_at")," > $2 AND author_id IS NOT NULL"),values:[n,e]},[4,this.getQueryResponse("Query.annotationCount",r)];case 1:return a=o.sent(),[2,Number(a[0].count||0)]}}))}))},annotationMemberCount:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o;return u(this,(function(s){switch(s.label){case 0:return e=t.userId,n=t.documentId,r=t.since,a={text:"SELECT COUNT(DISTINCT id) FROM annotation_members WHERE document_id = $1 AND user_id = $2 AND ".concat((0,f.toUnixTimestampSelector)("annotation_created_at")," > $3"),values:[n,e,r]},[4,this.getQueryResponse("Query.annotationMemberCount",a)];case 1:return o=s.sent(),[2,Number(o[0].count||0)]}}))}))},snapshots:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,l,p,m;return u(this,(function(u){switch(u.label){case 0:return e=t.ids,n=t.documentId,r=t.filters,o=(a=void 0===r?{}:r).limit,s=a.orderBy,i=a.orderDirection,l=void 0===i?"DESC":i,p="\n SELECT ".concat("id, author_id, document_id, xfdf, name, created_at, updated_at","\n FROM snapshots\n ").concat((0,f.whereAnd)(d([e&&e.length&&(0,f.valueIn)("id",e),n&&"document_id = '".concat(n,"'")],c((0,f.getFilterQuery)(a)),!1)),"\n "),s&&(p+=" ORDER BY ".concat((0,y.camelToSnake)(s)," ").concat(l)),o&&(p+=" LIMIT ".concat(o)),m={text:p},[4,this.getQueryResponse("Query.snapshots",m)];case 1:return[2,u.sent()]}}))}))},snapshotAssets:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a;return u(this,(function(o){switch(o.label){case 0:return e=t.ids,n=t.snapshotId,r="\n SELECT ".concat("id, snapshot_id, data, created_at, updated_at","\n FROM snapshot_assets\n ").concat((0,f.whereAnd)([e&&e.length&&(0,f.valueIn)("id",e),n&&"snapshot_id = '".concat(n,"'")]),"\n "),a={text:r},[4,this.getQueryResponse("Query.snapshotAsset",a)];case 1:return[2,o.sent()]}}))}))}},Mutation:{addUser:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return t.id?[3,2]:(e=t,[4,(0,v.generateId)()]);case 1:e.id=r.sent(),r.label=2;case 2:return n=(0,y.getQuery)({type:y.Command.Insert,table:"users",params:t}),[4,this.getQueryResponse("Mutation.addUser",n)];case 3:return[2,r.sent()[0]||null]}}))}))},addAnnotation:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d,l,f,p,m;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return p=u.sent(),[3,3];case 2:p=e,u.label=3;case 3:return n=p,r=t.xfdf,a=t.annotationId,o=t.documentId,s=t.pageNumber,i=t.createdAt,c=t.inReplyTo,d=t.authorId,l=t.updatedAt,f=t.annotContents,m=(0,y.getQuery)({type:y.Command.Insert,table:"annotations",params:{id:n,xfdf:r,annotContents:f,authorId:d,annotationId:a,documentId:o,pageNumber:s,createdAt:i,inReplyTo:c,updatedAt:l}}),[4,this.getQueryResponse("Mutation.addAnnotation",m)];case 4:return[2,u.sent()[0]||null]}}))}))},editAnnotation:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a,o,s;return u(this,(function(i){switch(i.label){case 0:return e=n.xfdf,r=n.pageNumber,a=n.updatedAt,o=n.annotContents,s=(0,y.getQuery)({type:y.Command.Update,id:t,table:"annotations",params:{xfdf:e,annotContents:o,pageNumber:r,updatedAt:a}}),[4,this.getQueryResponse("Mutation.editAnnotation",s)];case 1:return[2,i.sent()[0]||null]}}))}))},deleteAnnotation:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"annotations",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteAnnotation",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addDocument:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return c=u.sent(),[3,3];case 2:c=e,u.label=3;case 3:return n=c,r=t.authorId,a=t.isPublic,o=t.name,s=t.createdAt,i=t.updatedAt,d=(0,y.getQuery)({type:y.Command.Insert,table:"documents",params:{id:n,authorId:r,isPublic:a,name:o,createdAt:s,updatedAt:i}}),[4,this.getQueryResponse("Mutation.addDocument",d)];case 4:return[2,u.sent()[0]||null]}}))}))},editDocument:function(t,n){return i(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return e=(0,y.getQuery)({type:y.Command.Update,id:t,table:"documents",params:n}),[4,this.getQueryResponse("Mutation.editDocument",e)];case 1:return[2,r.sent()[0]||null]}}))}))},deleteDocument:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"documents",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteDocument",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addDocumentMember:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return c=u.sent(),[3,3];case 2:c=e,u.label=3;case 3:return n=c,r=t.userId,a=t.documentId,o=t.lastRead,s=t.createdAt,i=t.updatedAt,d=(0,y.getQuery)({type:y.Command.Insert,table:"document_members",params:{id:n,userId:r,documentId:a,lastRead:o,createdAt:s,updatedAt:i}}),[4,this.getQueryResponse("Mutation.addDocumentMember",d)];case 4:return[2,u.sent()[0]||null]}}))}))},editDocumentMember:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.lastRead,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"document_members",params:{lastRead:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editDocumentMember",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteDocumentMember:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"document_members",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteDocumentMember",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addAnnotationMember:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d,l,f;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return l=u.sent(),[3,3];case 2:l=e,u.label=3;case 3:return n=l,r=t.userId,a=t.documentId,o=t.annotationId,s=t.lastRead,i=t.annotationCreatedAt,c=t.createdAt,d=t.updatedAt,f=(0,y.getQuery)({type:y.Command.Insert,table:"annotation_members",params:{id:n,userId:r,documentId:a,annotationId:o,lastRead:s,annotationCreatedAt:i,createdAt:c,updatedAt:d}}),[4,this.getQueryResponse("Mutation.addAnnotationMember",f)];case 4:return[2,u.sent()[0]||null]}}))}))},editAnnotationMember:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.lastRead,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"annotation_members",params:{lastRead:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editAnnotationMember",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteAnnotationMember:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"annotation_members",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteAnnotationMember",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addMention:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return c=u.sent(),[3,3];case 2:c=e,u.label=3;case 3:return n=c,r=t.userId,a=t.documentId,o=t.annotationId,s=t.createdAt,i=t.updatedAt,d=(0,y.getQuery)({type:y.Command.Insert,table:"mentions",params:{id:n,userId:r,documentId:a,annotationId:o,createdAt:s,updatedAt:i}}),[4,this.getQueryResponse("Mutation.addMention",d)];case 4:return[2,u.sent()[0]||null]}}))}))},deleteMention:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"mentions",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteMention",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addSnapshot:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c,d,l;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return d=u.sent(),[3,3];case 2:d=e,u.label=3;case 3:return n=d,r=t.authorId,a=t.documentId,o=t.xfdf,s=t.name,i=t.createdAt,c=t.updatedAt,l=(0,y.getQuery)({type:y.Command.Insert,table:"snapshots",params:{id:n,authorId:r,documentId:a,xfdf:o,name:s,createdAt:i,updatedAt:c}}),[4,this.getQueryResponse("Mutation.addSnapshot",l)];case 4:return[2,u.sent()[0]||null]}}))}))},editSnapshot:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.name,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"snapshots",params:{name:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editSnapshot",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteSnapshot:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"snapshots",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteSnapshot",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))},addSnapshotAsset:function(t){return i(e,void 0,void 0,(function(){var e,n,r,a,o,s,i,c;return u(this,(function(u){switch(u.label){case 0:return void 0!==(e=t.id)?[3,2]:[4,(0,v.generateId)()];case 1:return i=u.sent(),[3,3];case 2:i=e,u.label=3;case 3:return n=i,r=t.snapshotId,a=t.data,o=t.createdAt,s=t.updatedAt,c=(0,y.getQuery)({type:y.Command.Insert,table:"snapshot_assets",params:{id:n,snapshotId:r,data:a,createdAt:o,updatedAt:s}}),[4,this.getQueryResponse("Mutation.addSnapshotAsset",c)];case 4:return[2,u.sent()[0]||null]}}))}))},editSnapshotAsset:function(t,n){return i(e,void 0,void 0,(function(){var e,r,a;return u(this,(function(o){switch(o.label){case 0:return e=n.snapshotId,r=n.updatedAt,a=(0,y.getQuery)({type:y.Command.Update,id:t,table:"snapshot_assets",params:{snapshotId:e,updatedAt:r}}),[4,this.getQueryResponse("Mutation.editSnapshotAsset",a)];case 1:return[2,o.sent()[0]||null]}}))}))},deleteSnapshotAsset:function(t){return i(e,void 0,void 0,(function(){var e,n;return u(this,(function(a){switch(a.label){case 0:e=(0,y.getQuery)({type:y.Command.Delete,table:"snapshot_assets",params:{id:t}}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.getQueryResponse("Mutation.deleteSnapshotAsset",e)];case 2:return n=a.sent(),[2,r(r({},n[0]),{successful:!0})];case 3:return a.sent(),[2,{id:t,successful:!1}];case 4:return[2]}}))}))}}}},e.LogLevels=m.LogLevels,e.LogTags=m.LogTags,e}();t.default=I;var E=n(5);Object.defineProperty(t,"UserTypes",{enumerable:!0,get:function(){return E.UserTypes}});var T=n(0);Object.defineProperty(t,"LogLevels",{enumerable:!0,get:function(){return T.LogLevels}}),Object.defineProperty(t,"LogTags",{enumerable:!0,get:function(){return T.LogTags}})},function(e,t){e.exports=require("pg")},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.addTransports=t.addConsoleTransport=void 0;var s=o(n(4)),i=n(0);t.addConsoleTransport=function(e,t,n){void 0===t&&(t=i.LogLevels.INFO),e.add(new s.default.transports.Console({level:t,format:s.format.combine((0,s.format)((function(e){return(!n||e.tag===n)&&e}))(),s.format.colorize(),s.format.printf((function(e){var t=u(e.message),n=e.tag?" [".concat(e.tag,"]"):"",r=u(e.meta);return"".concat(e.timestamp," ").concat(e.level).concat(n,": ").concat(t," ").concat(r)})),s.format.metadata({fillExcept:["message","level","timestamp","label"]}))}))};t.addTransports=function(e,t){t.forEach((function(t){return e.add(t)}))};var u=function(e){var t=e||"";return"object"==typeof e&&null!==e&&(t=JSON.stringify(e,null,2)),t}},function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return s},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.validateResolver=t.validateParams=t.throwError=t.ErrorCodes=void 0;var o=a(n(0));t.ErrorCodes={PERMISSION_ERROR:"PERMISSION_ERROR"};t.throwError=function(e,t,n){var r=t;throw"string"!=typeof r&&(r=t.message||t.toString()),r="".concat(e," - ").concat(r),o.default.error(r),n?new n(r):"string"!=typeof t?t:new Error(r)};t.validateParams=function(e,t){var n,a=function(t){var n="".concat(e,' - Paramater "').concat(t,'" is required');throw o.default.error(n),new Error(n)},s=function(t,n,r){var a="".concat(e,' - Parameter "').concat(t,'" expected type "').concat(r,'" but got "').concat(n,'"');throw o.default.error(a),new Error(a)};for(var i in t){var u=r(t[i],3),c=u[0],d=u[1],l=void 0===d?"any":d,f=u[2],p=void 0===f||f;if(null!=c&&""!==c){if("any"!==l){var m=typeof c;if("string"!==l){if("number"!==l){if("array"!==l){if("blob"!==l){if("boolean"!==l){if("object"!==l){if("function"!==l);else if(!(n=c)||"[object Function]"!=={}.toString.call(n))return s(i,m,l)}else if("object"!==m)return s(i,m,l)}else if("boolean"!==m)return s(i,m,l)}else if(!(c instanceof Blob))return s(i,m,l)}else if(!Array.isArray(c))return s(i,m,l)}else if("number"!==m)return s(i,m,l)}else if("string"!==m)return s(i,m,l)}}else if(p)return a(i)}};t.validateResolver=function(e,n){n||(0,t.throwError)(e,"Could not find resolvers for the ".concat(e,". Please make sure you provide resolvers for ").concat(e,"."))}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(a,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function i(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}u((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(a=s.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateId=t.setGenerator=void 0;var o=n(11),s=function(){return(0,o.v4)()};t.setGenerator=function(e){s=e};t.generateId=function(){return r(void 0,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,s()];case 1:return[2,e.sent()]}}))}))}},function(e,t){e.exports=require("uuid")}]).default})); |
@@ -7,3 +7,3 @@ { | ||
"types": "types/packages/collab-db-postgresql/src/index.d.ts", | ||
"version": "2.0.0", | ||
"version": "2.0.1-alpha.0", | ||
"scripts": { | ||
@@ -35,3 +35,3 @@ "start-local-db": "node dist/scripts/start-local-db.js", | ||
}, | ||
"gitHead": "1233d8cb55114e09f86333f8b1f02c541ca2f6d9" | ||
"gitHead": "2b1829229d59d258100463ab56273fbaea213578" | ||
} |
import { PubSub } from 'graphql-subscriptions'; | ||
import { Document as ApolloDocument, InvitedUserInput, NewDocumentInput, NewAnnotationInput, ChangeEventTypes, DocumentSubscriptionEvent } from './../../../../types/resolvers-types'; | ||
import { Document as ApolloDocument, InvitedUserInput, NewDocumentInput, NewAnnotationInput, ChangeEventTypes, DocumentSubscriptionEvent, SyncResult } from './../../../../types/resolvers-types'; | ||
import { Base } from './Base'; | ||
@@ -51,4 +51,5 @@ import { Annotation } from './Annotation'; | ||
}>; | ||
syncAnnotations(xfdf: string): Promise<SyncResult>; | ||
static buildFromId(id: string, userId: string, from: string, context: Context): Promise<Document>; | ||
static create(document: NewDocumentInput, annots: NewAnnotationInput[], usersInvited: InvitedUserInput[], from: string, context: Context): Promise<Document>; | ||
} |
@@ -13,3 +13,4 @@ import { NewAnnotationInput } from '../../../../../types/resolvers-types'; | ||
}>; | ||
syncAnnotations: (p: any, args: any, context: Context) => Promise<import("../../../../../types/resolvers-types").SyncResult>; | ||
}; | ||
export default _default; |
@@ -96,2 +96,3 @@ declare const Mutation: { | ||
}>; | ||
syncAnnotations: (p: any, args: any, context: import("../../types/Context").Context) => Promise<import("../../../../../types/resolvers-types").SyncResult>; | ||
addUser: (p: any, args: any, context: any) => Promise<import("../../../../../types/resolvers-types").User>; | ||
@@ -98,0 +99,0 @@ loginAnonymous: (p: any, args: any, context: import("../../types/Context").Context) => Promise<{ |
@@ -11,2 +11,6 @@ import { XFDFFormats } from '../index'; | ||
export declare const parseAnnotPageNumberFromXFDF: (xfdf: string) => string; | ||
/** | ||
* Sets the author for a single XFDF string | ||
*/ | ||
export declare const setXFDFAuthor: (xfdf: string, userId: any) => string; | ||
export declare const commandToRaw: (input: string) => string; | ||
@@ -30,2 +34,3 @@ export declare const ensureRawXFDF: (input: string) => string; | ||
properties: Record<string, string | number>; | ||
xfdf: string; | ||
}; | ||
@@ -36,1 +41,2 @@ /** | ||
export declare const getXFDFMetadata: (xfdf: string) => XFDFMetadata[]; | ||
export declare const wrapAnnotationInXMLTags: (xfdf: string) => string; |
@@ -12,3 +12,4 @@ import winston from 'winston'; | ||
SCROLL_SYNC = "SCROLL_SYNC", | ||
USERNAMES = "USERNAMES" | ||
USERNAMES = "USERNAMES", | ||
ANNOTATION_SYNC = "ANNOTATION_SYNC" | ||
} | ||
@@ -15,0 +16,0 @@ export declare enum LogLevels { |
@@ -235,2 +235,3 @@ import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; | ||
copyAnnotations: Scalars['Boolean']; | ||
syncAnnotations?: Maybe<SyncResult>; | ||
addAnnotationMember: AnnotationMember; | ||
@@ -304,2 +305,6 @@ editAnnotationMember: AnnotationMember; | ||
}; | ||
export declare type MutationSyncAnnotationsArgs = { | ||
docId: Scalars['ID']; | ||
xfdf: Scalars['String']; | ||
}; | ||
export declare type MutationAddAnnotationMemberArgs = { | ||
@@ -659,2 +664,7 @@ input: NewAnnotationMemberInput; | ||
}; | ||
export declare type SyncResult = { | ||
__typename?: 'SyncResult'; | ||
added: Array<Annotation>; | ||
updated: Array<Annotation>; | ||
}; | ||
export declare type UpdateAnnotationMemberLastReadPayload = AnnotationMember | AnnotationNotFound | IgnoreMembership; | ||
@@ -784,2 +794,3 @@ export declare type User = { | ||
Subscription: ResolverTypeWrapper<{}>; | ||
SyncResult: ResolverTypeWrapper<SyncResult>; | ||
UpdateAnnotationMemberLastReadPayload: ResolversTypes['AnnotationMember'] | ResolversTypes['AnnotationNotFound'] | ResolversTypes['IgnoreMembership']; | ||
@@ -850,2 +861,3 @@ User: ResolverTypeWrapper<User>; | ||
Subscription: {}; | ||
SyncResult: SyncResult; | ||
UpdateAnnotationMemberLastReadPayload: ResolversParentTypes['AnnotationMember'] | ResolversParentTypes['AnnotationNotFound'] | ResolversParentTypes['IgnoreMembership']; | ||
@@ -999,2 +1011,3 @@ User: User; | ||
copyAnnotations?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationCopyAnnotationsArgs, 'fromDocId' | 'toDocId'>>; | ||
syncAnnotations?: Resolver<Maybe<ResolversTypes['SyncResult']>, ParentType, ContextType, RequireFields<MutationSyncAnnotationsArgs, 'docId' | 'xfdf'>>; | ||
addAnnotationMember?: Resolver<ResolversTypes['AnnotationMember'], ParentType, ContextType, RequireFields<MutationAddAnnotationMemberArgs, 'input'>>; | ||
@@ -1103,2 +1116,7 @@ editAnnotationMember?: Resolver<ResolversTypes['AnnotationMember'], ParentType, ContextType, RequireFields<MutationEditAnnotationMemberArgs, 'annotationId' | 'userId'>>; | ||
}>; | ||
export declare type SyncResultResolvers<ContextType = any, ParentType extends ResolversParentTypes['SyncResult'] = ResolversParentTypes['SyncResult']> = ResolversObject<{ | ||
added?: Resolver<Array<ResolversTypes['Annotation']>, ParentType, ContextType>; | ||
updated?: Resolver<Array<ResolversTypes['Annotation']>, ParentType, ContextType>; | ||
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; | ||
}>; | ||
export declare type UpdateAnnotationMemberLastReadPayloadResolvers<ContextType = any, ParentType extends ResolversParentTypes['UpdateAnnotationMemberLastReadPayload'] = ResolversParentTypes['UpdateAnnotationMemberLastReadPayload']> = ResolversObject<{ | ||
@@ -1149,2 +1167,3 @@ __resolveType: TypeResolveFn<'AnnotationMember' | 'AnnotationNotFound' | 'IgnoreMembership', ParentType, ContextType>; | ||
Subscription?: SubscriptionResolvers<ContextType>; | ||
SyncResult?: SyncResultResolvers<ContextType>; | ||
UpdateAnnotationMemberLastReadPayload?: UpdateAnnotationMemberLastReadPayloadResolvers<ContextType>; | ||
@@ -1151,0 +1170,0 @@ User?: UserResolvers<ContextType>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237715
93
4513
3