cityworks 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/dist/case_workflow.d.ts +154 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.m.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/case_workflow.ts +377 -0
package/dist/index.modern.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"reversible-map";class t{constructor(e,t,s){this.name=void 0,this.code=void 0,this.message=void 0,this.info=void 0,this.name="Cityworks Exception",this.code=e,this.message=t,void 0!==s&&(this.info=JSON.stringify(s))}}const s=require("lodash");class r{constructor(e){this.cw=void 0,this.cw=e}notifications(){return new Promise((e,t)=>{this.cw.runRequest("General/ActivityNotification/User",{}).then(t=>{e(t.Value)})})}amIWatching(e,s){return new Promise((r,n)=>{let i={null:0,case:1,task:2};void 0===i[e]?n(new t(1,"Activity type provided does not exist.",{provided:e,potential_activities:i})):this.cw.runRequest("General/ActivityNotification/UserWatching",{ActivityType:i[e],ActivityId:s}).then(e=>{r(e.Value)}).catch(e=>{n(new t(2,"Unknown error."))})})}quickSearch(e){return new Promise((t,s)=>{this.cw.runRequest("General/QuickSearch/QuickSearch",{QuickSearchText:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getActivityMetadataByIds(e,r){return new Promise((n,i)=>{let a=["INSPECTION","REQUEST","WORKORDER"];-1==s.indexOf(a,r)&&i(new t(2,"TableName provided does not exist or is mispelled.",{provided:r,available:a})),this.cw.runRequest("General/CwMetaData/ByTableNameSids",{Ids:e,TableName:r}).then(e=>{console.log(e),n(e.Value)}).catch(e=>{i(e)})})}getWOEntityCostSummary(e){return new Promise((t,s)=>{this.cw.runRequest("General/CostSummary/WorkOrderEntity",{ObjectIds:e}).then(e=>{console.log(e),t(e.Value)}).catch(e=>{s(e)})})}searchWOEntityCostSummary(e){return new Promise((t,s)=>{this.cw.runRequest("General/CostSummary/WorkOrderEntitySearch",{SearchId:e}).then(e=>{console.log(e),t(e.Value)}).catch(e=>{s(e)})})}}const n=require("lodash");class i{constructor(t){this.activityTypes=void 0,this.linkTypes=void 0,this.cw=void 0,this.cw=t,this.activityTypes=new e,this.activityTypes.set("null",0),this.activityTypes.set("case",1),this.activityTypes.set("inspection",2),this.activityTypes.set("request",3),this.activityTypes.set("workorder",4),this.activityTypes.set("wipcase",5),this.linkTypes=new e,this.linkTypes.set("null",0),this.linkTypes.set("parent",1),this.linkTypes.set("related",2)}add(e,s,r,n,i="related"){return new Promise((a,o)=>{this.activityTypes.has(e)||o(new t(1,"Source type not found.",{provided:e,options:this.activityTypes})),this.activityTypes.has(r)||o(new t(2,"Destination type not found.",{provided:r,options:this.activityTypes})),this.linkTypes.has(i)||o(new t(3,"Link type not found.",{provided:i,options:this.linkTypes}));let u={SourceType:this.activityTypes.get(e),SourceSid:s,DestType:this.activityTypes.get(r),DestSid:n,LinkType:this.linkTypes.get(i)};this.cw.runRequest("General/ActivityLink/Add",u).then(e=>{a(e.Value)})})}get(e,s){return new Promise((r,i)=>{this.activityTypes.has(e)||i(new t(4,"Activity type not found.",{provided:e,options:this.activityTypes}));let a={ActivityType:this.activityTypes.get(e),ActivitySids:s},o=this;this.cw.runRequest("General/ActivityLink/ByActivitySids",a).then(e=>{let t=new Array;n.forEach(e.Value,(e,s)=>{e.DestType=o.activityTypes.get(e.DestType),e.SourceType=o.activityTypes.get(e.SourceType),e.LinkType=o.linkTypes.get(e.LinkType),t.push(e)}),r(t)})})}clone(e,s,r,n){return new Promise((i,a)=>{this.activityTypes.has(e)||a(new t(1,"Source type not found.",{provided:e,options:this.activityTypes})),this.activityTypes.has(r)||a(new t(1,"Destination type not found.",{provided:r,options:this.activityTypes}));let o={SourceActivityType:this.activityTypes.get(e),SourceActivitySid:s,DestinationActivityType:this.activityTypes.get(r),DestinationActivitySid:n};this.cw.runRequest("General/ActivityLink/CloneByActivitySid",o).then(e=>{i(e.Value)})})}delete(e){return new Promise((t,s)=>{this.cw.runRequest("General/ActivityLink/Delete",{ActivityLinkId:e}).then(e=>{t(e.Value)})})}remove(e,s,r,n,i="related"){return new Promise((a,o)=>{this.activityTypes.has(e)||o(new t(1,"Source type not found.",{provided:e,options:this.activityTypes})),this.activityTypes.has(r)||o(new t(1,"Destination type not found.",{provided:r,options:this.activityTypes})),this.linkTypes.has(i)||o(new t(1,"Link type not found.",{provided:i,options:this.linkTypes}));let u={SourceType:this.activityTypes.get(e),SourceSid:s,DestType:this.activityTypes.get(r),DestSid:n,LinkType:this.linkTypes.get(i)};this.cw.runRequest("General/ActivityLink/Remove",u).then(e=>{a(e.Value)})})}}require("lodash");class a{constructor(e){this.cw=void 0,this.cw=e}getConfig(e,t,s=!0,r=[]){return new Promise((t,s)=>{e=e.toLowerCase(),this.cw.runRequest("Gis/MapService/Domain",{}).then(e=>{t(e.Value)})})}domain(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/Domain",{}).then(t=>{e(t.Value)})})}downloadMobile(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/DownloadMobileMapCache",{}).then(t=>{e(t.Value)})})}initialExtent(){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/InitialExtent",{}).then(t=>{e(t.Value)})})}request(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/ServiceRequestConfiguration",{}).then(t=>{e(t.Value)})})}inspection(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/InspectionConfiguration",{}).then(t=>{e(t.Value)})})}workOrder(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/WorkOrderConfiguration",{}).then(t=>{e(t.Value)})})}user(e=[],t=!0,s=!0,r=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/User",{}).then(t=>{e(t.Value)})})}selectedEntities(){return new Promise((e,t)=>{this.cw.runRequest("General/AppData/SelectedEntities",{}).then(t=>{e(t.Value)})})}}const o=require("lodash");class u{constructor(e){this.cw=void 0,this.status=void 0,this.hook_types=void 0,this.cw=e,this.status={Pending:0,Processing:1,Complete:2,Failed:3},this.hook_types={Unknown:0,ActivityUpdate:1,Email:2,WebHook:3}}processMessages(e,t=!1){return new Promise((s,r)=>{this.cw.runRequest("General/WebHookEvent/ProcessMessages",{Ids:e,Delete:t}).then(e=>{})})}get(e,s,r=15){return new Promise((n,i)=>{void 0===this.status[s]&&i(new t(1,"Status provided does not exist or is mispelled.",{provided:s,available:this.status})),this.cw.runRequest("General/MessageQueue/ByIds",{Ids:e,MaxCount:void 0!==r?r:15,Status:this.status[s]}).then(e=>{})})}delete(e,s,r){return new Promise((n,i)=>{void 0===this.status[s]&&i(new t(2,"Status provided does not exist or is mispelled.",{provided:s,available:this.status})),this.cw.runRequest("General/MessageQueue/Delete",{Ids:e,Status:this.status[s],HoursToKeep:r}).then(e=>{})})}preferences(){return new Promise((e,t)=>{this.cw.runRequest("General/MessageQueue/Preferences",{}).then(e=>{})})}search(e,s){let r;return new Promise((n,i)=>{void 0!==e.status&&void 0===this.status[e.status]?i(new t(3,"Status provided does not exist or is mispelled.",{provided:e.status,available:this.status})):void 0!==e.status&&void 0!==this.status[e.status]&&(r.Status=this.status[e.status]),void 0!==s&&(r.MaxResults=s);let a=["Id","HookId","HookType","Result","DateCreatedBegin","DateCreatedEnd","DateUpdatedBegin","DateUpdatedEnd"],u=["Status","MaxResults"];o.forEach(e,(e,s)=>{-1!=o.indexOf(a,s)&&-1==o.indexOf(u,s)?r[s]=e:-1==o.indexOf(u,s)&&i(new t(4,"Provided parameter does not exist or is mispelled.",{provided:s,value:e,available:o.concat(a,u)}))}),this.cw.runRequest("General/MessageQueue/Search",r).then(e=>{void 0===e.Value&&(e.Value=[]),n(e.Value)})})}update(e){let s;return new Promise((r,n)=>{void 0!==e.status&&void 0===this.status[e.status]?n(new t(3,"Status provided does not exist or is mispelled.",{provided:e.status,available:this.status})):void 0!==e.status&&void 0!==this.status[e.status]&&(s.Status=this.status[e.status]),void 0!==e.hook_types&&void 0===this.hook_types[e.hook_types]?n(new t(3,"Status provided does not exist or is mispelled.",{provided:e.hook_types,available:this.hook_types})):void 0!==e.hook_types&&void 0!==this.hook_types[e.hook_types]&&(s.HookType=this.hook_types[e.hook_types]);let i=["Id","HookId","Packet","Result"],a=["Status","HookType"];o.forEach(e,(e,r)=>{-1!=o.indexOf(i,r)&&-1==o.indexOf(a,r)?s[r]=e:-1==o.indexOf(a,r)&&n(new t(5,"Provided parameter does not exist or is mispelled.",{provided:r,value:e,available:o.concat(i,a)}))}),this.cw.runRequest("General/MessageQueue/Update",s).then(e=>{void 0===e.Value&&(e.Value=[]),r(e.Value)})})}updateMessageStatus(e,s,r){return new Promise((n,i)=>{void 0===this.status[s]&&i(new t(2,"Status provided does not exist or is mispelled.",{provided:s,available:this.status})),this.cw.runRequest("General/MessageQueue/UpdateMessageStatus",{Ids:e,Status:this.status[s],HoursToKeep:r}).then(e=>{})})}getWebooks(e){return new Promise((t,s)=>{this.cw.runRequest("General/MessageQueue/WebHooks",{HookIds:e}).then(e=>{})})}}require("lodash");class c{constructor(e){this.cw=void 0,this.cw=e}}require("lodash");class d{constructor(e){this.cw=void 0,this.cw=e}}const h=require("lodash");class l{constructor(e){this.cw=void 0,this.admin=void 0,this.cw=e,this.admin=new d(e)}create(e){return new Promise((s,r)=>{h.has(e,"ProblemSid")?this.cw.runRequest("Ams/ServiceRequest/Create",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(2,"ProblemSid must be provided.",{provided:e}))})}update(e){return new Promise((s,r)=>{h.has(e,"RequestId")?this.cw.runRequest("Ams/ServiceRequest/Update",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(3,"RequestId must be provided.",{provided:e}))})}move(e,s,r,n,i){return new Promise((a,o)=>{h.has(n,"WKID")||h.has(n,"WKT")||o(new t(6,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={RequestId:e,X:s,Y:r};void 0!==i&&h.set(u,"Z",i);var c=h.merge(u,n);this.cw.runRequest("Ams/ServiceRequest/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}changeProblem(e,t){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/ChangeProblem",{RequestId:e,ProblemSid:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getById(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ById",{RequestId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getByIds(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ByIds",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getAuditLog(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/AuditLog",{RequestId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getCustomFields(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/CustomFields",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}changeCustomFieldCategory(e,t){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/ChangeCustomFieldCategory",{RequestIds:e,CategoryId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}comment(e,t){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/AddComments",{RequestId:e,Comments:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}cancel(e,t,s){return new Promise((r,n)=>{var i={RequestIds:e};void 0!==t&&h.set(i,"CancelReason",t),void 0!==s&&h.set(i,"DateCancelled",s),this.cw.runRequest("Ams/ServiceRequest/Cancel",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}uncancel(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/Uncancel",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}close(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/Close",{RequestIds:e}).then(e=>{e.Status>0?r(new t(5,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}reopen(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ReOpen",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}delete(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/Delete",{RequestIds:e}).then(e=>{e.Status>0?r(new t(4,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}search(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchObject(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/SearchObject",{RequestId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}createSearchDefinition(e,t,s,r=!0,n=!0){return new Promise((s,i)=>{var a=e;h.isString(t)&&(h.set(a,"SearchName",t),h.set(a,"SaveDefinition",r),h.set(a,"EnableEurl",n)),this.cw.runRequest("Ams/ServiceRequest/CreateSearchDefinition",a).then(e=>{s(e.Value)}).catch(e=>{i(e)})})}getProblemNodes(e,t=!1,s,r=!1){return new Promise((n,i)=>{var a={DomainId:e,IncludeCancelled:r,ViewOnly:t};null!=s&&h.has(s,"DisplayTextMode")&&(h.set(a,"DisplayTextMode",h.get(s,"DisplayTextMode")),"CD"==h.get(s,"DisplayTextMode")&&h.has(s,"DisplayTextDelimeter")&&h.set(a,"DisplayTextDelimeter",h.get(s,"DisplayTextDelimeter"))),this.cw.runRequest("Ams/ServiceRequest/ProblemNodes",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getProblems(e=!1,t=!0,s){return new Promise((r,n)=>{var i={ForPublicOnly:e,OnlyActiveTemplates:t};void 0!==s&&h.set(i,"DomainIds",s),this.cw.runRequest("Ams/ServiceRequest/Problems",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getProblemsByKeywords(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ProblemsByKeywords",{Keywords:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getPriorities(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/Priorities",{ProblemSids:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getCustomFieldTemplate(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/TemplateCustomFields",{ProblemSids:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getQASettings(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/QA",{ProblemSids:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getProblemLeaf(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ProblemLeafBySid",{ProblemSid:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getStatuses(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/DefaultStatus",{DomainIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getEmployeeLists(e,s){return new Promise((r,n)=>{var i={DomainId:s};h.includes(["DispatchTo","SubmitTo"],e)?this.cw.runRequest(`Ams/ServiceRequest/${e}`,i).then(e=>{r(e.Value)}).catch(e=>{n(e)}):n(new t(2,"listType must be either SubmitTo or DispatchTo.",{provided:e}))})}getDispatchTos(e){return this.getEmployeeLists("DispatchTo",e)}getSubmitTos(e){return this.getEmployeeLists("SubmitTo",e)}streetCodes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/ServiceRequest/AllStreetCode",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getTemplatesById(e,t,s){return new Promise((e,r)=>{var n={ProblemSids:null};void 0!==t&&h.set(n,"MinimumDateModified",t),void 0!==s&&h.set(n,"MaximumDateModified",s),this.cw.runRequest("Ams/ServiceRequestTemplate/ByIds",n).then(t=>{e(t.Value)}).catch(e=>{r(e)})})}createTemplateSearchDefinition(e,t,s,r=!0){return new Promise((s,n)=>{var i=e;h.isString(t)&&(h.set(i,"SearchName",t),h.set(i,"SaveDefinition",r)),this.cw.runRequest("Ams/ServiceRequestTemplate/CreateSearchDefinition",i).then(e=>{s(e.Value)}).catch(e=>{n(e)})})}getTemplateQAs(e,t,s){return new Promise((e,t)=>{this.cw.runRequest("Ams/ServiceRequestTemplate/QA",{ProblemSids:null}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchTemplates(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequestTemplate/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getTemplates(e,t=!1,s=!1,r,n){return new Promise((i,a)=>{var o={CanCreate:t,IncludeInactiveIf:s};void 0!==e&&h.set(o,"TemplateIds",e),void 0!==r&&h.set(o,"MinimumDateModified",r),void 0!==n&&h.set(o,"MaximumDateModified",n),this.cw.runRequest("Ams/ServiceRequestTemplate/Templates",o).then(e=>{i(e.Value)}).catch(e=>{a(e)})})}getWOTemplates(e,t=!1){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequestTemplate/WorkOrderTemplates",{ProblemSids:e,IncludeInactive:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}}require("lodash");class m{constructor(e){this.cw=void 0,this.cw=e}}const w=require("lodash");class p{constructor(e){this.cw=void 0,this.admin=void 0,this.cw=e,this.admin=new m(e)}create(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")?this.cw.runRequest("Ams/Inspection/Create",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromEntities(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")?this.cw.runRequest("Ams/Inspection/CreateFromEntities",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromParent(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")&&w.has(e,"InspectionId")?this.cw.runRequest("Ams/Inspection/CreateFromParent",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromServiceRequest(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")&&w.has(e,"RequestId")?this.cw.runRequest("Ams/Inspection/CreateFromServiceRequest",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromWorkOrder(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")&&w.has(e,"WorkOrderSid")?this.cw.runRequest("Ams/Inspection/CreateFromWorkOrder",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}update(e){return new Promise((s,r)=>new Promise((s,r)=>{w.has(e,"InspectionId")?this.cw.runRequest("Ams/Inspection/Update",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"InspectionId must be provided.",{provided:e}))}))}getById(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/ById",{InspectionId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getByIds(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/ByIds",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}cancel(e,t,s){return new Promise((r,n)=>{var i={InspectionIds:e};void 0!==t&&(i.CancelReason=t),void 0!==s&&(i.DateCancelled=s),this.cw.runRequest("Ams/Inspection/Cancel",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}uncancel(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Uncancel",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}close(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Close",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}reopen(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Reopen",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}delete(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Delete",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}search(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchObject(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/SearchObject",{InspectionId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}statuses(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/Statuses",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}submitTos(e=!1,t){return new Promise((s,r)=>{var n={};e&&(n.IncludeInactiveEmployees=!0),void 0!==t&&(n.DomainIds=t),this.cw.runRequest("Ams/Inspection/SubmitTos",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}connectAsset(e,t,s=!0,r={}){return new Promise((s,n)=>{var i={InspectionId:t};w.has(e,"EntityType")&&w.has(e,"EntityUid")?(i.EntityType=e.EntityType,i.EntityUid=e.EntityUid):w.has(e,"Entity")&&(i.Entity=e.Entity),w.has(r,"Facility_Id")&&(i.Facility_Id=r.Facility_Id),w.has(r,"Level_Id")&&(i.Level_Id=r.Level_Id),this.cw.runRequest("Ams/Inspection/AddEntity",i).then(e=>{s(e.Value)}).catch(e=>{n(e)})})}getAnswers(e){return new Promise((t,s)=>{var r={};0==e.length?r.InspectionId=e[0]:r.InspectionIds=e,this.cw.runRequest("Ams/Inspection/Answers",r).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getAuditLog(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/AuditLog",{InspectionId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}createSearchDefinition(e,t,s,r=!0,n=!0){return new Promise((s,i)=>{var a=e;w.isString(t)&&(w.set(a,"SearchName",t),w.set(a,"SaveDefinition",r),w.set(a,"EnableEurl",n)),this.cw.runRequest("Ams/Inspection/CreateSearchDefinition",a).then(e=>{s(e.Value)}).catch(e=>{i(e)})})}getCycleFrom(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/CycleFrom",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleIntervals(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/CycleIntervals",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleTypes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/CycleTypes",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getDistricts(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/Districts",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getEmployeeLists(e,s=!1,r){return new Promise((n,i)=>{var a={IncludeInactiveEmployees:s};void 0!==r&&null!=r&&w.set(a,"DomainIds",r),"SubmitTos"!=e?i(new t(2,'listType must be "SubmitTos".',{provided:e})):this.cw.runRequest(`Ams/Inspection/${e}`,a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getSubmitTos(e=!1,t){return this.getEmployeeLists("SubmitTos",e,t)}move(e,s,r,n,i){return new Promise((a,o)=>{w.has(n,"WKID")||w.has(n,"WKT")||o(new t(3,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={InspectionId:e,X:s,Y:r};void 0!==i&&w.set(u,"Z",i);var c=w.merge(u,n);this.cw.runRequest("Ams/Inspection/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}getTemplates(e,t,s){return new Promise((r,n)=>{var i={};void 0!==e&&(i.EntityTypes=e),i.CanCreate=void 0===t||t,"object"==typeof s&&w.forIn(s,(e,t)=>{i[t]=e}),this.cw.runRequest("Ams/InspectionTemplate/Templates",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getTemplatesByIds(e,t){return new Promise((s,r)=>{var n={InspTemplateIds:e};"object"==typeof t&&w.forIn(t,(e,t)=>{n[t]=e}),this.cw.runRequest("Ams/InspectionTemplate/ByIds",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getTemplateEntityTypes(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/InspectionTemplate/EntityTypes",{InspTemplateIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getQA(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/InspectionTemplate/QA",{InspTemplateIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getQConditions(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/InspectionTemplate/QuestionConditions",{InspTemplateIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteAttachments(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/DeleteInspectionAttachments",{AttachmentIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}downloadAttachment(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/DownloadInspectionAttachment",{AttachmentId:e}).then(e=>{}).catch(e=>{s(e)})})}getAttachmentById(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/InspectionAttachmentById",{AttachmentId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getAttachments(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/InspectionAttachments",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}}require("lodash");class y{constructor(e){this.cw=void 0,this.cw=e}}const v=require("lodash");class I{constructor(e){this.cw=void 0,this.admin=void 0,this.cw=e,this.admin=new y(e)}create(e,s,r){return new Promise((n,i)=>{if(v.has(e,"WOTemplateId")&&v.has(e,"EntityType")){var a=e;void 0===s||null==s||v.has(a,"InspectionIds")||v.set(a,"InspectionIds",s),void 0===r||null==r||v.has(a,"RequestIds")||v.set(a,"RequestIds",r),this.cw.runRequest("Ams/WorkOrder/Create",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})}else i(new t(2,"WOTemplateId & EntityType must be provided.",{provided:e}))})}createFromParent(e,s,r=!0){return new Promise((r,n)=>{if(v.has(e,"WOTemplateId")&&v.has(e,"EntityType")){var i=e;v.isString(s)?v.set(i,"WorkOrderId",s):v.set(i,"WorkOrderSid",s),this.cw.runRequest("Ams/WorkOrder/Create",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})}else n(new t(2,"WOTemplateId & EntityType must be provided.",{provided:e}))})}update(e){return new Promise((s,r)=>{v.has(e,"WorkOrderSid")||v.has(e,"WorkOrderId")?this.cw.runRequest("Ams/WorkOrder/Update",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(3,"WorkOrderId or WorkOrderSid must be provided.",{provided:e}))})}combine(e,s,r=!0){return new Promise((n,i)=>{this.cw.runRequest("Ams/WorkOrder/Combine",{CancelCombinedWorkOrders:r,ToWorkOrderId:s,FromWorkOrderIds:e}).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}move(e,s,r,n,i){return new Promise((a,o)=>{v.has(n,"WKID")||v.has(n,"WKT")||o(new t(6,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={WorkOrderId:e,X:s,Y:r};void 0!==i&&v.set(u,"z",i);var c=v.merge(u,n);this.cw.runRequest("Ams/WorkOrder/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}getById(e,t=!0){return new Promise((t,s)=>{var r={};if(v.isString(e)){v.set(r,"WorkOrderId",e);var n="Ams/WorkOrder/ById"}else v.set(r,"WorkOrderSid",e),n="Ams/WorkOrder/BySid";this.cw.runRequest(n,r).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getByIds(e){return new Promise((s,r)=>{var n={};if(0==e.length)r(new t(10,"No workorder S/IDs were provided.",{workorderSId:e}));else{var i="Ams/WorkOrder/ByIds";v.isString(e[0])?(v.set(n,"WorkOrderIds",e),i="Ams/WorkOrder/ByIds"):v.isNumber(e[0])?(v.set(n,"WorkOrderSids",e),i="Ams/WorkOrder/BySids"):r(new t(9,"No workorder S/IDs were provided.",{workorderSId:e})),this.cw.runRequest(i,n).then(e=>{s(e.Value)}).catch(e=>{r(e)})}})}getInstructions(e){return new Promise((s,r)=>{var n={};if(0==e.length)r(new t(10,"No workorder S/IDs were provided.",{workorderSId:e}));else{var i="Ams/WorkOrder/ByIds";v.isString(e[0])?(v.set(n,"WorkOrderIds",e),i="Ams/WorkOrder/InstructionsByWorkOrderIds"):v.isNumber(e[0])?(v.set(n,"WorkOrderSids",e),i="Ams/WorkOrder/InstructionsByWorkOrderSids"):r(new t(9,"No workorder S/IDs were provided.",{workorderSId:e})),this.cw.runRequest(i,n).then(e=>{s(e.Value)}).catch(e=>{r(e)})}})}getAuditLog(e){return new Promise((s,r)=>{var n={};v.isString(e)?v.set(n,"WorkOrderId",e):v.isNumber(e)?v.set(n,"WorkOrderSid",e):r(new t(9,"Workorder S/IDs was not provided.",{workorderSId:e})),this.cw.runRequest("Ams/WorkOrder/AuditLog",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getCustomFieldValues(e){return new Promise((s,r)=>{var n={},i="Ams/WorkOrder/CustomFields";v.isString(e[0])?(v.set(n,"WorkOrderIds",e),i="Ams/WorkOrder/CustomFields"):v.isNumber(e[0])?(v.set(n,"WorkOrderSids",e),i="Ams/WorkOrder/CustomFieldsByWorkOrderSids"):r(new t(9,"No workorder S/IDs were provided.",{workorderSIds:e})),this.cw.runRequest(i,n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}comment(e,s){return new Promise((r,n)=>{var i={Comments:s};v.isString(e)?v.set(i,"WorkOrderId",e):v.isNumber(e)?v.set(i,"WorkOrderSid",e):n(new t(9,"Workorder S/IDs was not provided.",{workorderSId:e})),this.cw.runRequest("Ams/WorkOrder/AddComments",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getEntities(e,s=!0){return new Promise((r,n)=>{var i={GetGisData:s};0==e.length?n(new t(11,"No workorder S/IDs were provided.",{workorderSId:e})):v.isString(e[0])?v.set(i,"WorkOrderIds",e):v.isNumber(e[0])?v.set(i,"WorkOrderSids",e):n(new t(12,"No workorder S/IDs were provided.",{workorderSId:e})),this.cw.runRequest("Ams/WorkOrder/Entities",i).then(e=>{e.Status>0?n(new t(4,e.Message,{response:e})):r(e.Value)}).catch(e=>{n(e)})})}addEntities(e,s,r=!0){return new Promise((n,i)=>{var a={UpdateXY:r};v.isString(e)?v.set(a,"WorkOrderId",e):v.set(a,"WorkOrderSid",e),v.has(s,"Facility_Id")&&v.set(a,"Facility_Id",v.get(s,"Facility_Id")),v.has(s,"Level_Id")&&v.set(a,"Level_Id",v.get(s,"Level_Id")),v.has(s,"EntityUids")&&v.has(s,"EntityType")?(v.set(a,"EntityUids",v.get(s,"EntityUids")),v.set(a,"EntityType",v.get(s,"EntityType"))):i(new t(7,"No entity info was provided.",{workorderSId:e,entityInfo:s})),this.cw.runRequest("Ams/WorkOrder/AddEntities",a).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}updateEntity(e,s,r=!1){return new Promise((n,i)=>{var a={WorkComplete:r};v.isString(e)?v.set(a,"WorkOrderId",e):v.set(a,"WorkOrderSid",e),v.has(s,"Facility_Id")&&v.set(a,"Facility_Id",v.get(s,"Facility_Id")),v.has(s,"Level_Id")&&v.set(a,"Level_Id",v.get(s,"Level_Id")),v.has(s,"EntityUids")&&v.has(s,"EntityType")?(v.set(a,"EntityUid",v.get(s,"EntityUid")),v.set(a,"EntityType",v.get(s,"EntityType"))):i(new t(7,"No entity info was provided.",{workorderSId:e,entityInfo:s})),this.cw.runRequest("Ams/WorkOrder/UpdateEntity",a).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}removeEntities(e,s,r=!0){return new Promise((n,i)=>{var a={UpdateXY:r};v.isString(e)?v.set(a,"WorkOrderId",e):v.set(a,"WorkOrderSid",e),v.has(s,"ObjectIds")?v.set(a,"ObjectIds",v.get(s,"ObjectIds")):v.has(s,"EntityUids")&&v.has(s,"EntityType")?(v.set(a,"EntityUids",v.get(s,"EntityUids")),v.set(a,"EntityType",v.get(s,"EntityType"))):i(new t(8,"No entity info was provided.",{workorderSId:e,entityInfo:s})),this.cw.runRequest("Ams/WorkOrder/RemoveEntities",a).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}cancel(e,t,s){return new Promise((r,n)=>{var i={WorkOrderIds:e};void 0!==t&&v.set(i,"CancelReason",t),void 0!==s&&v.set(i,"DateCancelled",s),this.cw.runRequest("Ams/WorkOrder/Cancel",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}uncancel(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/WorkOrder/Uncancel",{WorkOrderIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}close(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/WorkOrder/Close",{WorkOrderIds:e}).then(e=>{e.Status>0?r(new t(5,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}reopen(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/WorkOrder/ReOpen",{WorkOrderIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}delete(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/WorkOrder/Delete",{WorkOrderIds:e}).then(e=>{e.Status>0?r(new t(4,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}getWOsByEntities(e,s,r,n=!0){return new Promise((i,a)=>{var o={};void 0!==r&&v.merge(o,r),v.has(o,"EntityType")||v.set(o,"EntityType",e),v.has(o,"EntityUids")||v.set(o,"EntityUids",s);var u="Ams/WorkOrder/SearchForSids";n||(u="Ams/WorkOrder/Search"),this.cw.runRequest(u,o).then(e=>{e.Status>0?a(new t(4,e.Message,{response:e})):i(e.Value)}).catch(e=>{a(e)})})}getSearchList(e){return new Promise((s,r)=>{var n={};v.set(n,"WorkOrderId",e),this.cw.runRequest("Ams/WorkOrder/SearchObject",n).then(e=>{e.Status>0?r(new t(4,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}getEmployeeLists(e,s=!1,r){return new Promise((n,i)=>{var a={IncludeInactiveEmployees:s};void 0!==r&&null!=r&&v.set(a,"DomainIds",r),v.includes(["Supervisors","SubmitTos"],e)?this.cw.runRequest(`Ams/WorkOrder/${e}`,a).then(e=>{n(e.Value)}).catch(e=>{i(e)}):i(new t(2,"listType must be either SubmitTos or Supervisors.",{provided:e}))})}getSubmitTos(e=!1,t){return this.getEmployeeLists("SubmitTos",e,t)}getSupervisors(e=!1,t){return this.getEmployeeLists("Supervisors",e,t)}getStatuses(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Statuses",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCategories(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Categories",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getPriorities(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Priorities",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleFrom(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/CycleFrom",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleIntervals(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/CycleIntervals",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleTypes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/CycleTypes",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getStages(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Stages",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getExpenseTypes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/ExpenseTypes",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}}require("lodash");class P{constructor(e){this.cw=void 0,this.cw=e}}const R=require("lodash");class T{constructor(e){this.cw=void 0,this.cw=e}addFee(e,t,s){return new Promise((r,n)=>{var i=R.merge({CaObjectId:e,FeeSetupId:t},s);this.cw.runRequest("Pll/CaseFees/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}addPayment(e,t){return new Promise((s,r)=>{var n=R.merge({CaObjectId:e},t);this.cw.runRequest("Pll/CasePayment/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addRefund(e,t,s){return new Promise((r,n)=>{this.cw.runRequest("Pll/CasePaymentRefund/Add",{CaPaymentId:e,RefundAmount:t,Comments:s}).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}addDepositPayment(e,t){return new Promise((s,r)=>{var n=R.merge({CaDepositId:e},t);this.cw.runRequest("Pll/CasePayment/AddDeposit",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addDeposit(e,t,s,r){return new Promise((n,i)=>{var a={CaObjectId:e,DepositId:t};void 0!==s&&R.set(a,"Amount",s),void 0!==r&&R.set(a,"CommentText",r),this.cw.runRequest("CaseDeposit/Add",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}addInstrument(e,t,s,r,n){return new Promise((i,a)=>{var o=R.merge({CaObjectId:e,InstTypeId:t,Amount:s,DateExpire:r},n);this.cw.runRequest("Pll/CaseInstrument/Add",o).then(e=>{i(e.Value)}).catch(e=>{a(e)})})}updateFee(e,t){return new Promise((s,r)=>{var n=R.merge({CaFeeId:e},t);this.cw.runRequest("Pll/CaseFees/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}voidRefund(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CasePaymentRefund/Update",{CaPaymentRefundId:e,Voided:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addDefaultFees(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CaseFees/AddDefault",{CaObjectId:e,BusCaseId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addDefaultDeposits(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CaseDeposit/AddDefault",{CaObjectId:e,BusCaseId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getFees(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseFees/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getDeposits(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDeposit/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getPayments(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePayment/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getInstruments(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteFee(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseFees/Delete",{CaFeeId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteFeesByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseFees/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deletePayment(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePayment/Delete",{CaFeeId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteRefund(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePaymentRefund/Delete",{CaPaymentRefundId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deletePaymentsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePayment/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteDeposit(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDeposit/Delete",{CaDepositId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteDepositsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDeposit/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteInstrument(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/Delete",{CaInstrumentId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteInstrumentsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchFees(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaFeeId","CaObjectId","FeeCode","FeeDesc"]).length&&r(new t(4,"At least one of the attributes (CaFeeId, CaObjectId, FeeCode, FeeDesc) must be defined.")),this.cw.runRequest("Pll/CaseFees/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchPayments(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaPaymentId","CommentText","FeeAmount","FeeCode","FeeDesc","PaymentAccount","PaymentAmount","TenderType"]).length&&r(new t(5,"At least one of the attributes (CaPaymentId, CommentText, FeeAmount, FeeCode, FeeDesc, PaymentAccount, PaymentAmount, TenderType) must be defined.")),this.cw.runRequest("Pll/CasePayment/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchRefunds(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaPaymentId","CaPaymentRefundId","Comments","RefundAmount"]).length&&r(new t(6,"At least one of the attributes (CaPaymentId, CaPaymentRefundId, Comments, RefundAmount) must be defined.")),this.cw.runRequest("Pll/CasePayment/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchDeposits(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaDepositId","CaObjectId","DepositCode","DepositDesc"]).length&&r(new t(1,"At least one of the arguments (CaDepositId, CaObjectId, DepositCode, DepositDesc) must be defined.")),this.cw.runRequest("Pll/CaseDeposit/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getAllFeeTemplates(){return new Promise((e,t)=>{this.cw.runRequest("Pll/FeeSetup/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchFeeTemplates(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["FeeSetupId","FeeTypeId","FeeCode","FeeDesc","AccountCode"]).length&&r(new t(7,"At least one of the arguments (FeeSetupId, FeeTypeId, FeeCode, FeeDesc, AccountCode) must be defined.")),this.cw.runRequest("Pll/FeeSetup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchCaseInstruments(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["AddressLine1","Amount","CaInstrumentId","CityName","CommentText","Company","ContactEmail","ContactName","ContactPhone","CountryCode","InstTypeId","SerialNumber","StateCode","ZipCode"]).length&&r(new t(9,"At least one of the arguments (AddressLine1, Amount, CaInstrumentId, CityName, CommentText, Company, ContactEmail, ContactName, ContactPhone, CountryCode, InstTypeId, SerialNumber, StateCode, ZipCode) must be defined.")),this.cw.runRequest("Pll/CaseInstrument/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getInstrumentList(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/GetList",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}addCaseInstrumentRelease(e,s,r,n,i,a){return new Promise((o,u)=>{var c={CaInstrumentId:e,DateReleased:r,ReleasedBy:s};void 0===i&&null==i||void 0===n&&null==n?void 0!==i&&null!=i?R.set(c,"PercentReleased",i):void 0!==n&&null!=n&&R.set(c,"AmountReleased",n):u(new t(2,"Either amountReleased or percentReleased must be specified.")),void 0!==a&&R.set(c,"CommentText",a),this.cw.runRequest("Pll/CaseInstReleases/Add",c).then(e=>{o(e.Value)}).catch(e=>{u(e)})})}deleteCaseInstrumentRelease(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstReleases/Delete",{CaInstReleasesId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchCaseInstrumentReleases(e){return new Promise((s,r)=>{var n=e;0==R.intersectionBy(e,["AmountReleased","CaInstReleasesId","CaInstrumentId","CommentText","PercentReleased","ReleasedBy"]).length&&r(new t(3,"At least one of the attributes (AmountReleased, CaInstReleasesId, CaInstrumentId, CommentText, PercentReleased, ReleasedBy) must be defined.")),this.cw.runRequest("Pll/CaseInstReleases/Search",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}fees(){return new Promise((e,t)=>{this.cw.runRequest("Pll/FeeSetup/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchAvailableFees(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["AccountCode","FeeCode","FeeDesc","FeeSetupId","FeeTypeId"]).length&&r(new t(8,"At least one of the attributes (AccountCode, FeeCode, FeeDesc, FeeSetupId, FeeTypeId) must be defined.")),this.cw.runRequest("Pll/FeeSetup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getTenderTypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/TenderType/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addTenderType(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TenderType/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateTenderType(e,t){return new Promise((s,r)=>{var n=R.merge({TenderTypeId:e},t);this.cw.runRequest("Pll/TenderType/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}}require("lodash");class q{constructor(e){this.cw=void 0,this.cw=e}}const C=require("lodash");class g{constructor(e){this.cw=void 0,this.cw=e}addBusinessCaseTemplate(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/BusinessCase/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateBusinessCaseTemplate(e,t){return new Promise((s,r)=>{var n=C.merge({BusCaseId:e},t);this.cw.runRequest("Pll/BusinessCase/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getBusinessCaseTemplates(){return new Promise((e,t)=>{this.cw.runRequest("Pll/BusinessCase/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addCaseType(e,t,s){return new Promise((r,n)=>{var i=C.merge({CaseType:e,CaseTypeDesciption:t},s);this.cw.runRequest("Pll/CaseType/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}updateCaseType(e,t){return new Promise((s,r)=>{var n=C.merge({CaseTypeId:e},t);this.cw.runRequest("Pll/CaseType/GetList",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getCaseTypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/CaseType/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchCaseTypeIDs(e){return new Promise((s,r)=>{0==C.intersectionBy(e,["CaseType","CaseTypeDesc","CaseTypeId"]).length&&r(new t(2,"At least one of the attributes (CaFeeId, CaObjectId, FeeCode, FeeDesc) must be defined.")),this.cw.runRequest("Pll/CaseType/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchCaseTypeObjects(e){return new Promise((s,r)=>{0==C.intersectionBy(e,["CaseType","CaseTypeDesc","CaseTypeId"]).length&&r(new t(3,"At least one of the attributes (CaseType, CaseTypeDesc, CaseTypeId) must be defined.")),this.cw.runRequest("Pll/CaseType/SearchObject",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addSubtype(e,t,s){return new Promise((r,n)=>{var i=C.merge({SubType:e,SubTypeDesc:t},s);this.cw.runRequest("Pll/SubType/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}updateSubtype(e,t){return new Promise((s,r)=>{var n=C.merge({SubTypeId:e},t);this.cw.runRequest("Pll/SubType/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getSubtypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/SubType/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getFees(){return new Promise((e,t)=>{this.cw.runRequest("Pll/FeeSetup/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchFees(e){return new Promise((s,r)=>{0==C.intersectionBy(e,["AccountCode","FeeCode","FeeDesc","FeeSetupId","FeeTypeId"]).length&&r(new t(4,"At least one of the attributes (AccountCode, FeeCode, FeeDesc, FeeSetupId, FeeTypeId) must be defined.")),this.cw.runRequest("Pll/FeeSetup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getExpirations(){return new Promise((e,t)=>{this.cw.runRequest("Pll/ExpirationType/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addExpiration(e){return new Promise((s,r)=>{C.has(e,"OrgId")&&C.has(e,"ExpirationTypeDesc")||r(new t(5,"OrgId and ExpirationTypeDesc must both be defined.")),this.cw.runRequest("Pll/ExpirationType/Add",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getDeposits(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Deposit/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchDeposits(e){return new Promise((s,r)=>{0==C.intersectionBy(e,["AccountCode","DepositCode","DepositDesc","DepositId","DepositTypeId"]).length&&r(new t(4,"At least one of the attributes (AccountCode, DepositCode, DepositDesc, DepositId, DepositTypeId) must be defined.")),this.cw.runRequest("Pll/Deposit/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getDisciplines(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Discipline/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addDepartment(e,t,s){return new Promise((r,n)=>{var i=C.merge({DepartmentCode:e,DepartmentName:t},s);this.cw.runRequest("Pll/Department/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getDepartments(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Department/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addDivision(e,t,s){return new Promise((r,n)=>{var i=C.merge({DepartmentId:e,DivisionName:t},s);this.cw.runRequest("Pll/Division/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getDivisions(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Division/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addHoliday(e,t,s){return new Promise((r,n)=>{var i={HolidayDate:e,HolidayDesc:t};void 0!==s&&C.set(i,"HalfDayFlag",s),this.cw.runRequest("Pll/Holiday/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}deleteHoliday(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/Holiday/Delete",{HolidayId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getHolidays(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Holiday/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addInspectionTimeBlock(e,t,s,r){return new Promise((n,i)=>{var a={LabelText:e,StartTime:t,EndTime:s};void 0!==r&&C.set(a,"InspTimeBlocksDetails",r),this.cw.runRequest("Pll/InspectionTimeBlock/Add",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getInspectionTimeBlocks(){return new Promise((e,t)=>{this.cw.runRequest("Pll/InspectionTimeBlock/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getNotificationCases(){return new Promise((e,t)=>{this.cw.runRequest("Pll/NotificationCase/GetNotificationCaseList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getNotificationTypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/NotificationType/GetNotificationTypeList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addNumberingGroup(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/NumberingGroup/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateNumberingGroup(e,t){return new Promise((s,r)=>{var n=C.merge({NumberingGroupId:e},t);this.cw.runRequest("Pll/NumberingGroup/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getNumberingGroups(){return new Promise((e,t)=>{this.cw.runRequest("Pll/NumberingGroup/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addPerson(e,t){return new Promise((s,r)=>{var n=C.merge(t,{Name:e});this.cw.runRequest("Pll/People/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getPeople(){return new Promise((e,t)=>{this.cw.runRequest("Pll/People/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addPeopleRole(e,t){return new Promise((s,r)=>{var n=C.merge(t,{RoleCode:e});this.cw.runRequest("Pll/People/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getPeopleRoles(){return new Promise((e,t)=>{this.cw.runRequest("Pll/PeopleRole/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addTaskResultDetail(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultDetail/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateTaskResultDetail(e,t){return new Promise((s,r)=>{var n=C.merge(t,{ResultDetailId:e});this.cw.runRequest("Pll/TaskResultDetail/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getTaskResultDetails(){return new Promise((e,t)=>{this.cw.runRequest("Pll/TaskResultDetail/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addTaskResultFeeInsert(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteTaskResultFeeInsert(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/Delete",{TaskResultFeeInsertId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteTaskResultFeeInsertByTaskId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/DeleteByTaskId",{TaskId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateTaskResultFeeInsert(e,t,s,r){return new Promise((n,i)=>{var a={TaskResultFeeInsertId:e,TaskId:t,TaskResultId:s};void 0!==r&&C.set(a,"FeeSetupId",r),this.cw.runRequest("Pll/TaskResultFeeInsert/Update",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getTaskResultFeeInsert(){return new Promise((e,t)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}}const S=require("lodash");class k{constructor(e){this.cw=void 0,this.data=void 0,this.workflow=void 0,this.financial=void 0,this.admin=void 0,this.cw=e,this.data=new P(e),this.workflow=new q(e),this.financial=new T(e),this.admin=new g(e)}create(e,t,s){return new Promise((r,n)=>{var i=S.merge({CaseTypeId:e,SubTypeId:t},s);this.cw.runRequest("Pll/Case/Create",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}createChild(e,t,s){return new Promise((r,n)=>{var i=S.merge({BusCaseId:e,ParentCaObjectId:t},s);this.cw.runRequest("Pll/Case/CreateChild",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}createFromRequest(e,t,s,r){return new Promise((n,i)=>{var a=S.merge({CaseTypeId:e,SubTypeId:t,ServiceRequestId:s},r);this.cw.runRequest("Pll/CaseObject/CreateCaseFromServiceRequest",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}update(e,t){return new Promise((s,r)=>{var n=S.merge({CaObjectId:e},t);this.cw.runRequest("Pll/CaseObject/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getByIds(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseObject/ByIds",{CaObjectIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}search(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseObject/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}move(e,s,r,n,i){return new Promise((a,o)=>{S.has(n,"WKID")||S.has(n,"WKT")||o(new t(1,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={CaObjectId:e,X:s,Y:r};void 0!==i&&S.set(u,"Z",i);var c=S.merge(u,n);this.cw.runRequest("Pll/CaseObject/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}delete(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseObject/DeleteCase",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}}const A=require("https"),V=require("querystring"),b=require("lodash");module.exports=class{constructor(e,t,s){this.base_url=void 0,this.Token=void 0,this.login=void 0,this.password=void 0,this.gisToken=void 0,this.gisTokenUrl=void 0,this.settings=void 0,this.error=void 0,this.general=void 0,this.activity_link=void 0,this.message_queue=void 0,this.gis=void 0,this.search=void 0,this.request=void 0,this.inspection=void 0,this.workorder=void 0,this.case=void 0,this.extensions=void 0,this.features=void 0,this.potential_loads=void 0,this.base_url="cityworksonline",this.extensions={UnknownExtension:0,CwAnalytics:1,WebHooks:2,PLLPublicApp:3,ActivityUpdate:4,SingleSignOn:5},this.features={UnknownFeature:0,ViewInspections:1,EditInspections:2,ViewServiceRequest:3,EditServiceRequest:4,ViewWorkOrder:5,EditWorkOrder:6,EquipmentCheckOut:7,OfficeField:8,Respond:9,Eurl:10,PaverInterface:11,Contracts:12,Storeroom:13,PLL:14,Cw4XL:15,TableEditor:16,CCTVInterface:17,MobileAndroid:18,MobileiOS:19,PerformanceBudgeting:20,Insights:21,RespondCase:22,RespondInspection:23,RespondServiceRequest:24,RespondTaskManager:25,RespondWorkOrder:26,Workload:27,OpX:28,TrimbleUnityMobile:29,TrimbleVegetationManager:30},this.settings={path:"cityworks",secure:!0,expires:null,default_domain:null},this.potential_loads=["general","activity_link","message_queue","gis","search","request","case","case_financial"],void 0!==e&&this.configure(e,t,s)}configure(e,t,s){if(this.base_url=void 0!==e?e:"cityworksonline",this.settings={path:"cityworks",secure:!0,expires:null,default_domain:null},void 0!==t&&b.forEach(t,(e,t)=>{void 0!==this.settings[t]&&(this.settings[t]=e)}),void 0===s)this.general=new r(this),this.activity_link=new i(this),this.message_queue=new u(this),this.request=new l(this),this.inspection=new p(this),this.workorder=new I(this),this.case=new k(this);else{let e=this;b.forEach(this.potential_loads,function(t){switch(t){case"general":e.general=new r(e);break;case"activity_link":e.activity_link=new i(e);break;case"message_queue":e.message_queue=new u(e);break;case"gis":e.gis=new a(e);break;case"search":e.search=new c(e);break;case"request":e.request=new l(e);break;case"case":e.case=new k(e);break;case"inspection":e.inspection=new p(e);break;case"workorder":e.workorder=new I(e)}})}}runRequest(e,s){return new Promise((r,n)=>{let i={};i.data=JSON.stringify(s),void 0!==this.Token&&""!=this.Token&&"General/Authentication/CityworksOnlineAuthenticate"!=e&&"General/Authentication/Authenticate"!=e&&(i.token=this.Token);let a={hostname:this.base_url,port:443,path:"/"+this.settings.path+"/services/"+e,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(V.stringify(i))},timeout:1e7},o=A.request(a,e=>{let s="";e.on("error",function(e){console.log(e,"Caught on error"),n(new t(13,"Unknown error.",e))}),e.on("data",function(e){s+=e}),e.on("end",function(){try{if(null==(JSON.stringify(s)+"[test string]").match(/\<h2\>Object\ moved\ to/)){var e=JSON.parse(s);void 0===e?n(new t(10,"No response received from Cityworks API.")):void 0!==e&&void 0!==e.Value?r(e):n(new t(3,"Unknown error.",{options:a,postedData:i,api_returned_string:e}))}else n(new t(1,"Error parsing JSON. Cityworks returned HTML.",{response:s}))}catch(e){e instanceof SyntaxError?(console.log("try/catch error on JSON"),n(new t(1,"Error parsing JSON.",{error:e}))):(console.log("try/catch error on JSON"),n(new t(1,"Error parsing JSON.")))}})});o.write(V.stringify(i)),o.end()})}authenticate(e,s){return new Promise((r,n)=>{let i="General/Authentication/Authenticate";"cityworksonline"==this.base_url&&(i="General/Authentication/CityworksOnlineAuthenticate"),this.runRequest(i,{LoginName:e,Password:s}).then(i=>{i.Status>0?n(new t(10,i.Message)):void 0!==i.Value&&void 0!==i.Value.Token?(this.login=e,this.password=s,this.Token=i.Value.Token,r(!0)):n(new t(11,"Unknown Error"))}).catch(e=>{n(e)})})}authenticateWithGISToken(e,t,s,r){return this.login=e,this.gisToken=t,this.gisTokenUrl=s,void 0!==r&&(r=12096e5),new Promise((e,t)=>{this.runRequest("General/Authentication/AuthenticateGisToken",{LoginName:this.login,GisToken:this.gisToken,GisTokenUrl:this.gisTokenUrl,Expires:r}).then(t=>{void 0!==t.Status&&t.Status>0||(void 0!==t.Value&&void 0!==t.Value.Token?(this.Token=t.Value.Token,e(!0)):e(!1))}).catch(e=>{throw e})})}validateToken(e,t){return new Promise((s,r)=>{this.runRequest("General/Authentication/Validate",{Token:e}).then(r=>{r.Status>0?s(!1):(t&&(this.Token=e),s(r.Value))}).catch(e=>{throw e})})}setToken(e){return""!=e&&null!=e&&(this.Token=e,!0)}getToken(){return""!=this.Token&&null!=this.Token&&this.Token}revokeToken(e){return new Promise((t,s)=>{this.runRequest("General/Token/RevokeUser",{RevokeDate:e}).then(e=>{t(!(void 0!==e.Status&&e.Status>0))}).catch(e=>{throw e})})}getLocalizationSettings(){return new Promise((e,t)=>{this.runRequest("General/Localization/LocalizationSettings",{}).then(t=>{e(t.Value)})})}getTimezoneOptions(){return new Promise((e,t)=>{this.runRequest("General/Localization/TimeZones",{}).then(t=>{e(t.Value)})})}getCurrentLocation(){return new Promise((e,t)=>{this.runRequest("General/AppData/CurrentLocation",{}).then(t=>{e(t.Value)})})}licensedApiCheck(e,t){return new Promise((s,r)=>{this.runRequest("General/AppData/SelectedEntities",{Area:e,Service:t}).then(e=>{s(e.Value)})})}licensedExtensionCheck(e){return new Promise((s,r)=>{void 0===this.extensions[e]&&r(new t(4,"Extension provided does not exist or is mispelled.",{provided:e,available:this.extensions})),this.runRequest("General/Authorization/LicensedExtensionCheck",{Extension:this.extensions[e]}).then(e=>{s(e.Value)})})}licensedExtensionsCheck(e){return new Promise((s,r)=>{var n={Extensions:[]};b.forEach(e,e=>{void 0===this.extensions[e]?r(new t(5,"Extension provided does not exist or is mispelled.",{provided:e,available:this.extensions})):n.Extensions.push(this.extensions[e])}),this.runRequest("General/Authorization/LicensedExtensionsCheck",n).then(e=>{let n={},i=b.invert(this.extensions);b.forEach(e,(e,s)=>{void 0===i[e]?r(new t(6,"Extension index provided does not exist or isn't configured properly.",{provided_num_returned:e,available:this.extensions})):n[i[e]]=s}),s(n)})})}licensedFeatureCheck(e){return new Promise((s,r)=>{void 0===this.features[e]&&r(new t(7,"Feature provided does not exist or is mispelled.",{provided:e,available:this.features})),this.runRequest("General/Authorization/LicensedFeatureCheck",{Feature:this.features[e]}).then(e=>{s(e.Value)})})}licensedFeaturesCheck(e){return new Promise((s,r)=>{var n={Features:[]};b.forEach(e,e=>{void 0===this.features[e]?r(new t(8,"Feature provided does not exist or is mispelled.",{provided:e,available:this.features})):n.Features.push(this.features[e])}),this.runRequest("General/Authorization/LicensedFeaturesCheck",n).then(e=>{let n={},i=b.invert(this.features);b.forEach(e.Value,(e,s)=>{void 0===i[e]?r(new t(9,"Feature index provided does not exist or isn't configured properly.",{provided:e,available:i})):n[i[e]]=s}),s(n)})})}licensedServicesCheck(e){return new Promise((t,s)=>{this.runRequest("General/Authorization/LicensedServicesCheck",{Services:e}).then(e=>{t(e.Value)})})}cityworksOnlineSites(e,t){return new Promise((s,r)=>{this.runRequest("General/Authentication/CityworksOnlineSites",{LoginName:void 0!==e?e:this.login,Password:void 0!==t?t:this.password}).then(e=>{s(e.Value)})})}domains(){return new Promise((e,t)=>{this.runRequest("General/Authentication/Domains",{}).then(t=>{e(t.Value)})})}user(e){return new Promise((t,s)=>{this.runRequest("General/Authentication/User",{LoginName:void 0!==e?e:this.login}).then(e=>{t(e.Value)})})}version(){return new Promise((e,t)=>{this.runRequest("General/Authentication/Version",{}).then(t=>{e(t.Value)})})}};
|
|
1
|
+
import e from"reversible-map";class t{constructor(e,t,s){this.name=void 0,this.code=void 0,this.message=void 0,this.info=void 0,this.name="Cityworks Exception",this.code=e,this.message=t,void 0!==s&&(this.info=JSON.stringify(s))}}const s=require("lodash");class r{constructor(e){this.cw=void 0,this.cw=e}notifications(){return new Promise((e,t)=>{this.cw.runRequest("General/ActivityNotification/User",{}).then(t=>{e(t.Value)})})}amIWatching(e,s){return new Promise((r,n)=>{let i={null:0,case:1,task:2};void 0===i[e]?n(new t(1,"Activity type provided does not exist.",{provided:e,potential_activities:i})):this.cw.runRequest("General/ActivityNotification/UserWatching",{ActivityType:i[e],ActivityId:s}).then(e=>{r(e.Value)}).catch(e=>{n(new t(2,"Unknown error."))})})}quickSearch(e){return new Promise((t,s)=>{this.cw.runRequest("General/QuickSearch/QuickSearch",{QuickSearchText:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getActivityMetadataByIds(e,r){return new Promise((n,i)=>{let a=["INSPECTION","REQUEST","WORKORDER"];-1==s.indexOf(a,r)&&i(new t(2,"TableName provided does not exist or is mispelled.",{provided:r,available:a})),this.cw.runRequest("General/CwMetaData/ByTableNameSids",{Ids:e,TableName:r}).then(e=>{console.log(e),n(e.Value)}).catch(e=>{i(e)})})}getWOEntityCostSummary(e){return new Promise((t,s)=>{this.cw.runRequest("General/CostSummary/WorkOrderEntity",{ObjectIds:e}).then(e=>{console.log(e),t(e.Value)}).catch(e=>{s(e)})})}searchWOEntityCostSummary(e){return new Promise((t,s)=>{this.cw.runRequest("General/CostSummary/WorkOrderEntitySearch",{SearchId:e}).then(e=>{console.log(e),t(e.Value)}).catch(e=>{s(e)})})}}const n=require("lodash");class i{constructor(t){this.activityTypes=void 0,this.linkTypes=void 0,this.cw=void 0,this.cw=t,this.activityTypes=new e,this.activityTypes.set("null",0),this.activityTypes.set("case",1),this.activityTypes.set("inspection",2),this.activityTypes.set("request",3),this.activityTypes.set("workorder",4),this.activityTypes.set("wipcase",5),this.linkTypes=new e,this.linkTypes.set("null",0),this.linkTypes.set("parent",1),this.linkTypes.set("related",2)}add(e,s,r,n,i="related"){return new Promise((a,o)=>{this.activityTypes.has(e)||o(new t(1,"Source type not found.",{provided:e,options:this.activityTypes})),this.activityTypes.has(r)||o(new t(2,"Destination type not found.",{provided:r,options:this.activityTypes})),this.linkTypes.has(i)||o(new t(3,"Link type not found.",{provided:i,options:this.linkTypes}));let u={SourceType:this.activityTypes.get(e),SourceSid:s,DestType:this.activityTypes.get(r),DestSid:n,LinkType:this.linkTypes.get(i)};this.cw.runRequest("General/ActivityLink/Add",u).then(e=>{a(e.Value)})})}get(e,s){return new Promise((r,i)=>{this.activityTypes.has(e)||i(new t(4,"Activity type not found.",{provided:e,options:this.activityTypes}));let a={ActivityType:this.activityTypes.get(e),ActivitySids:s},o=this;this.cw.runRequest("General/ActivityLink/ByActivitySids",a).then(e=>{let t=new Array;n.forEach(e.Value,(e,s)=>{e.DestType=o.activityTypes.get(e.DestType),e.SourceType=o.activityTypes.get(e.SourceType),e.LinkType=o.linkTypes.get(e.LinkType),t.push(e)}),r(t)})})}clone(e,s,r,n){return new Promise((i,a)=>{this.activityTypes.has(e)||a(new t(1,"Source type not found.",{provided:e,options:this.activityTypes})),this.activityTypes.has(r)||a(new t(1,"Destination type not found.",{provided:r,options:this.activityTypes}));let o={SourceActivityType:this.activityTypes.get(e),SourceActivitySid:s,DestinationActivityType:this.activityTypes.get(r),DestinationActivitySid:n};this.cw.runRequest("General/ActivityLink/CloneByActivitySid",o).then(e=>{i(e.Value)})})}delete(e){return new Promise((t,s)=>{this.cw.runRequest("General/ActivityLink/Delete",{ActivityLinkId:e}).then(e=>{t(e.Value)})})}remove(e,s,r,n,i="related"){return new Promise((a,o)=>{this.activityTypes.has(e)||o(new t(1,"Source type not found.",{provided:e,options:this.activityTypes})),this.activityTypes.has(r)||o(new t(1,"Destination type not found.",{provided:r,options:this.activityTypes})),this.linkTypes.has(i)||o(new t(1,"Link type not found.",{provided:i,options:this.linkTypes}));let u={SourceType:this.activityTypes.get(e),SourceSid:s,DestType:this.activityTypes.get(r),DestSid:n,LinkType:this.linkTypes.get(i)};this.cw.runRequest("General/ActivityLink/Remove",u).then(e=>{a(e.Value)})})}}require("lodash");class a{constructor(e){this.cw=void 0,this.cw=e}getConfig(e,t,s=!0,r=[]){return new Promise((t,s)=>{e=e.toLowerCase(),this.cw.runRequest("Gis/MapService/Domain",{}).then(e=>{t(e.Value)})})}domain(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/Domain",{}).then(t=>{e(t.Value)})})}downloadMobile(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/DownloadMobileMapCache",{}).then(t=>{e(t.Value)})})}initialExtent(){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/InitialExtent",{}).then(t=>{e(t.Value)})})}request(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/ServiceRequestConfiguration",{}).then(t=>{e(t.Value)})})}inspection(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/InspectionConfiguration",{}).then(t=>{e(t.Value)})})}workOrder(e,t=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/WorkOrderConfiguration",{}).then(t=>{e(t.Value)})})}user(e=[],t=!0,s=!0,r=!0){return new Promise((e,t)=>{this.cw.runRequest("Gis/MapService/User",{}).then(t=>{e(t.Value)})})}selectedEntities(){return new Promise((e,t)=>{this.cw.runRequest("General/AppData/SelectedEntities",{}).then(t=>{e(t.Value)})})}}const o=require("lodash");class u{constructor(e){this.cw=void 0,this.status=void 0,this.hook_types=void 0,this.cw=e,this.status={Pending:0,Processing:1,Complete:2,Failed:3},this.hook_types={Unknown:0,ActivityUpdate:1,Email:2,WebHook:3}}processMessages(e,t=!1){return new Promise((s,r)=>{this.cw.runRequest("General/WebHookEvent/ProcessMessages",{Ids:e,Delete:t}).then(e=>{})})}get(e,s,r=15){return new Promise((n,i)=>{void 0===this.status[s]&&i(new t(1,"Status provided does not exist or is mispelled.",{provided:s,available:this.status})),this.cw.runRequest("General/MessageQueue/ByIds",{Ids:e,MaxCount:void 0!==r?r:15,Status:this.status[s]}).then(e=>{})})}delete(e,s,r){return new Promise((n,i)=>{void 0===this.status[s]&&i(new t(2,"Status provided does not exist or is mispelled.",{provided:s,available:this.status})),this.cw.runRequest("General/MessageQueue/Delete",{Ids:e,Status:this.status[s],HoursToKeep:r}).then(e=>{})})}preferences(){return new Promise((e,t)=>{this.cw.runRequest("General/MessageQueue/Preferences",{}).then(e=>{})})}search(e,s){let r;return new Promise((n,i)=>{void 0!==e.status&&void 0===this.status[e.status]?i(new t(3,"Status provided does not exist or is mispelled.",{provided:e.status,available:this.status})):void 0!==e.status&&void 0!==this.status[e.status]&&(r.Status=this.status[e.status]),void 0!==s&&(r.MaxResults=s);let a=["Id","HookId","HookType","Result","DateCreatedBegin","DateCreatedEnd","DateUpdatedBegin","DateUpdatedEnd"],u=["Status","MaxResults"];o.forEach(e,(e,s)=>{-1!=o.indexOf(a,s)&&-1==o.indexOf(u,s)?r[s]=e:-1==o.indexOf(u,s)&&i(new t(4,"Provided parameter does not exist or is mispelled.",{provided:s,value:e,available:o.concat(a,u)}))}),this.cw.runRequest("General/MessageQueue/Search",r).then(e=>{void 0===e.Value&&(e.Value=[]),n(e.Value)})})}update(e){let s;return new Promise((r,n)=>{void 0!==e.status&&void 0===this.status[e.status]?n(new t(3,"Status provided does not exist or is mispelled.",{provided:e.status,available:this.status})):void 0!==e.status&&void 0!==this.status[e.status]&&(s.Status=this.status[e.status]),void 0!==e.hook_types&&void 0===this.hook_types[e.hook_types]?n(new t(3,"Status provided does not exist or is mispelled.",{provided:e.hook_types,available:this.hook_types})):void 0!==e.hook_types&&void 0!==this.hook_types[e.hook_types]&&(s.HookType=this.hook_types[e.hook_types]);let i=["Id","HookId","Packet","Result"],a=["Status","HookType"];o.forEach(e,(e,r)=>{-1!=o.indexOf(i,r)&&-1==o.indexOf(a,r)?s[r]=e:-1==o.indexOf(a,r)&&n(new t(5,"Provided parameter does not exist or is mispelled.",{provided:r,value:e,available:o.concat(i,a)}))}),this.cw.runRequest("General/MessageQueue/Update",s).then(e=>{void 0===e.Value&&(e.Value=[]),r(e.Value)})})}updateMessageStatus(e,s,r){return new Promise((n,i)=>{void 0===this.status[s]&&i(new t(2,"Status provided does not exist or is mispelled.",{provided:s,available:this.status})),this.cw.runRequest("General/MessageQueue/UpdateMessageStatus",{Ids:e,Status:this.status[s],HoursToKeep:r}).then(e=>{})})}getWebooks(e){return new Promise((t,s)=>{this.cw.runRequest("General/MessageQueue/WebHooks",{HookIds:e}).then(e=>{})})}}require("lodash");class c{constructor(e){this.cw=void 0,this.cw=e}}require("lodash");class d{constructor(e){this.cw=void 0,this.cw=e}}const h=require("lodash");class l{constructor(e){this.cw=void 0,this.admin=void 0,this.cw=e,this.admin=new d(e)}create(e){return new Promise((s,r)=>{h.has(e,"ProblemSid")?this.cw.runRequest("Ams/ServiceRequest/Create",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(2,"ProblemSid must be provided.",{provided:e}))})}update(e){return new Promise((s,r)=>{h.has(e,"RequestId")?this.cw.runRequest("Ams/ServiceRequest/Update",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(3,"RequestId must be provided.",{provided:e}))})}move(e,s,r,n,i){return new Promise((a,o)=>{h.has(n,"WKID")||h.has(n,"WKT")||o(new t(6,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={RequestId:e,X:s,Y:r};void 0!==i&&h.set(u,"Z",i);var c=h.merge(u,n);this.cw.runRequest("Ams/ServiceRequest/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}changeProblem(e,t){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/ChangeProblem",{RequestId:e,ProblemSid:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getById(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ById",{RequestId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getByIds(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ByIds",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getAuditLog(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/AuditLog",{RequestId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getCustomFields(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/CustomFields",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}changeCustomFieldCategory(e,t){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/ChangeCustomFieldCategory",{RequestIds:e,CategoryId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}comment(e,t){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/AddComments",{RequestId:e,Comments:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}cancel(e,t,s){return new Promise((r,n)=>{var i={RequestIds:e};void 0!==t&&h.set(i,"CancelReason",t),void 0!==s&&h.set(i,"DateCancelled",s),this.cw.runRequest("Ams/ServiceRequest/Cancel",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}uncancel(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/Uncancel",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}close(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/Close",{RequestIds:e}).then(e=>{e.Status>0?r(new t(5,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}reopen(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ReOpen",{RequestIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}delete(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequest/Delete",{RequestIds:e}).then(e=>{e.Status>0?r(new t(4,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}search(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchObject(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/SearchObject",{RequestId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}createSearchDefinition(e,t,s,r=!0,n=!0){return new Promise((s,i)=>{var a=e;h.isString(t)&&(h.set(a,"SearchName",t),h.set(a,"SaveDefinition",r),h.set(a,"EnableEurl",n)),this.cw.runRequest("Ams/ServiceRequest/CreateSearchDefinition",a).then(e=>{s(e.Value)}).catch(e=>{i(e)})})}getProblemNodes(e,t=!1,s,r=!1){return new Promise((n,i)=>{var a={DomainId:e,IncludeCancelled:r,ViewOnly:t};null!=s&&h.has(s,"DisplayTextMode")&&(h.set(a,"DisplayTextMode",h.get(s,"DisplayTextMode")),"CD"==h.get(s,"DisplayTextMode")&&h.has(s,"DisplayTextDelimeter")&&h.set(a,"DisplayTextDelimeter",h.get(s,"DisplayTextDelimeter"))),this.cw.runRequest("Ams/ServiceRequest/ProblemNodes",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getProblems(e=!1,t=!0,s){return new Promise((r,n)=>{var i={ForPublicOnly:e,OnlyActiveTemplates:t};void 0!==s&&h.set(i,"DomainIds",s),this.cw.runRequest("Ams/ServiceRequest/Problems",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getProblemsByKeywords(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ProblemsByKeywords",{Keywords:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getPriorities(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/Priorities",{ProblemSids:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getCustomFieldTemplate(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/TemplateCustomFields",{ProblemSids:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getQASettings(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/QA",{ProblemSids:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getProblemLeaf(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/ProblemLeafBySid",{ProblemSid:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getStatuses(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/DefaultStatus",{DomainIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getEmployeeLists(e,s){return new Promise((r,n)=>{var i={DomainId:s};h.includes(["DispatchTo","SubmitTo"],e)?this.cw.runRequest(`Ams/ServiceRequest/${e}`,i).then(e=>{r(e.Value)}).catch(e=>{n(e)}):n(new t(2,"listType must be either SubmitTo or DispatchTo.",{provided:e}))})}getDispatchTos(e){return this.getEmployeeLists("DispatchTo",e)}getSubmitTos(e){return this.getEmployeeLists("SubmitTo",e)}streetCodes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/ServiceRequest/AllStreetCode",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getTemplatesById(e,t,s){return new Promise((e,r)=>{var n={ProblemSids:null};void 0!==t&&h.set(n,"MinimumDateModified",t),void 0!==s&&h.set(n,"MaximumDateModified",s),this.cw.runRequest("Ams/ServiceRequestTemplate/ByIds",n).then(t=>{e(t.Value)}).catch(e=>{r(e)})})}createTemplateSearchDefinition(e,t,s,r=!0){return new Promise((s,n)=>{var i=e;h.isString(t)&&(h.set(i,"SearchName",t),h.set(i,"SaveDefinition",r)),this.cw.runRequest("Ams/ServiceRequestTemplate/CreateSearchDefinition",i).then(e=>{s(e.Value)}).catch(e=>{n(e)})})}getTemplateQAs(e,t,s){return new Promise((e,t)=>{this.cw.runRequest("Ams/ServiceRequestTemplate/QA",{ProblemSids:null}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchTemplates(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequestTemplate/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getTemplates(e,t=!1,s=!1,r,n){return new Promise((i,a)=>{var o={CanCreate:t,IncludeInactiveIf:s};void 0!==e&&h.set(o,"TemplateIds",e),void 0!==r&&h.set(o,"MinimumDateModified",r),void 0!==n&&h.set(o,"MaximumDateModified",n),this.cw.runRequest("Ams/ServiceRequestTemplate/Templates",o).then(e=>{i(e.Value)}).catch(e=>{a(e)})})}getWOTemplates(e,t=!1){return new Promise((s,r)=>{this.cw.runRequest("Ams/ServiceRequestTemplate/WorkOrderTemplates",{ProblemSids:e,IncludeInactive:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}}require("lodash");class m{constructor(e){this.cw=void 0,this.cw=e}}const w=require("lodash");class p{constructor(e){this.cw=void 0,this.admin=void 0,this.cw=e,this.admin=new m(e)}create(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")?this.cw.runRequest("Ams/Inspection/Create",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromEntities(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")?this.cw.runRequest("Ams/Inspection/CreateFromEntities",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromParent(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")&&w.has(e,"InspectionId")?this.cw.runRequest("Ams/Inspection/CreateFromParent",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromServiceRequest(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")&&w.has(e,"RequestId")?this.cw.runRequest("Ams/Inspection/CreateFromServiceRequest",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}createFromWorkOrder(e){return new Promise((s,r)=>{w.has(e,"EntityType")&&w.has(e,"InspTemplateId")&&w.has(e,"WorkOrderSid")?this.cw.runRequest("Ams/Inspection/CreateFromWorkOrder",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"EntityType and InspTemplateId properties must be provided.",{provided:e}))})}update(e){return new Promise((s,r)=>new Promise((s,r)=>{w.has(e,"InspectionId")?this.cw.runRequest("Ams/Inspection/Update",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(1,"InspectionId must be provided.",{provided:e}))}))}getById(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/ById",{InspectionId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getByIds(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/ByIds",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}cancel(e,t,s){return new Promise((r,n)=>{var i={InspectionIds:e};void 0!==t&&(i.CancelReason=t),void 0!==s&&(i.DateCancelled=s),this.cw.runRequest("Ams/Inspection/Cancel",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}uncancel(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Uncancel",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}close(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Close",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}reopen(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Reopen",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}delete(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Delete",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}search(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchObject(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/ServiceRequest/SearchObject",{InspectionId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}statuses(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/Statuses",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}submitTos(e=!1,t){return new Promise((s,r)=>{var n={};e&&(n.IncludeInactiveEmployees=!0),void 0!==t&&(n.DomainIds=t),this.cw.runRequest("Ams/Inspection/SubmitTos",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}connectAsset(e,t,s=!0,r={}){return new Promise((s,n)=>{var i={InspectionId:t};w.has(e,"EntityType")&&w.has(e,"EntityUid")?(i.EntityType=e.EntityType,i.EntityUid=e.EntityUid):w.has(e,"Entity")&&(i.Entity=e.Entity),w.has(r,"Facility_Id")&&(i.Facility_Id=r.Facility_Id),w.has(r,"Level_Id")&&(i.Level_Id=r.Level_Id),this.cw.runRequest("Ams/Inspection/AddEntity",i).then(e=>{s(e.Value)}).catch(e=>{n(e)})})}getAnswers(e){return new Promise((t,s)=>{var r={};0==e.length?r.InspectionId=e[0]:r.InspectionIds=e,this.cw.runRequest("Ams/Inspection/Answers",r).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getAuditLog(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Inspection/AuditLog",{InspectionId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}createSearchDefinition(e,t,s,r=!0,n=!0){return new Promise((s,i)=>{var a=e;w.isString(t)&&(w.set(a,"SearchName",t),w.set(a,"SaveDefinition",r),w.set(a,"EnableEurl",n)),this.cw.runRequest("Ams/Inspection/CreateSearchDefinition",a).then(e=>{s(e.Value)}).catch(e=>{i(e)})})}getCycleFrom(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/CycleFrom",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleIntervals(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/CycleIntervals",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleTypes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/CycleTypes",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getDistricts(){return new Promise((e,t)=>{this.cw.runRequest("Ams/Inspection/Districts",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getEmployeeLists(e,s=!1,r){return new Promise((n,i)=>{var a={IncludeInactiveEmployees:s};void 0!==r&&null!=r&&w.set(a,"DomainIds",r),"SubmitTos"!=e?i(new t(2,'listType must be "SubmitTos".',{provided:e})):this.cw.runRequest(`Ams/Inspection/${e}`,a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getSubmitTos(e=!1,t){return this.getEmployeeLists("SubmitTos",e,t)}move(e,s,r,n,i){return new Promise((a,o)=>{w.has(n,"WKID")||w.has(n,"WKT")||o(new t(3,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={InspectionId:e,X:s,Y:r};void 0!==i&&w.set(u,"Z",i);var c=w.merge(u,n);this.cw.runRequest("Ams/Inspection/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}getTemplates(e,t,s){return new Promise((r,n)=>{var i={};void 0!==e&&(i.EntityTypes=e),i.CanCreate=void 0===t||t,"object"==typeof s&&w.forIn(s,(e,t)=>{i[t]=e}),this.cw.runRequest("Ams/InspectionTemplate/Templates",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getTemplatesByIds(e,t){return new Promise((s,r)=>{var n={InspTemplateIds:e};"object"==typeof t&&w.forIn(t,(e,t)=>{n[t]=e}),this.cw.runRequest("Ams/InspectionTemplate/ByIds",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getTemplateEntityTypes(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/InspectionTemplate/EntityTypes",{InspTemplateIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getQA(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/InspectionTemplate/QA",{InspTemplateIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getQConditions(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/InspectionTemplate/QuestionConditions",{InspTemplateIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteAttachments(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/DeleteInspectionAttachments",{AttachmentIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}downloadAttachment(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/DownloadInspectionAttachment",{AttachmentId:e}).then(e=>{}).catch(e=>{s(e)})})}getAttachmentById(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/InspectionAttachmentById",{AttachmentId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getAttachments(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/Attachments/InspectionAttachments",{InspectionIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}}require("lodash");class y{constructor(e){this.cw=void 0,this.cw=e}}const I=require("lodash");class v{constructor(e){this.cw=void 0,this.admin=void 0,this.cw=e,this.admin=new y(e)}create(e,s,r){return new Promise((n,i)=>{if(I.has(e,"WOTemplateId")&&I.has(e,"EntityType")){var a=e;void 0===s||null==s||I.has(a,"InspectionIds")||I.set(a,"InspectionIds",s),void 0===r||null==r||I.has(a,"RequestIds")||I.set(a,"RequestIds",r),this.cw.runRequest("Ams/WorkOrder/Create",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})}else i(new t(2,"WOTemplateId & EntityType must be provided.",{provided:e}))})}createFromParent(e,s,r=!0){return new Promise((r,n)=>{if(I.has(e,"WOTemplateId")&&I.has(e,"EntityType")){var i=e;I.isString(s)?I.set(i,"WorkOrderId",s):I.set(i,"WorkOrderSid",s),this.cw.runRequest("Ams/WorkOrder/Create",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})}else n(new t(2,"WOTemplateId & EntityType must be provided.",{provided:e}))})}update(e){return new Promise((s,r)=>{I.has(e,"WorkOrderSid")||I.has(e,"WorkOrderId")?this.cw.runRequest("Ams/WorkOrder/Update",e).then(e=>{s(e.Value)}).catch(e=>{r(e)}):r(new t(3,"WorkOrderId or WorkOrderSid must be provided.",{provided:e}))})}combine(e,s,r=!0){return new Promise((n,i)=>{this.cw.runRequest("Ams/WorkOrder/Combine",{CancelCombinedWorkOrders:r,ToWorkOrderId:s,FromWorkOrderIds:e}).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}move(e,s,r,n,i){return new Promise((a,o)=>{I.has(n,"WKID")||I.has(n,"WKT")||o(new t(6,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={WorkOrderId:e,X:s,Y:r};void 0!==i&&I.set(u,"z",i);var c=I.merge(u,n);this.cw.runRequest("Ams/WorkOrder/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}getById(e,t=!0){return new Promise((t,s)=>{var r={};if(I.isString(e)){I.set(r,"WorkOrderId",e);var n="Ams/WorkOrder/ById"}else I.set(r,"WorkOrderSid",e),n="Ams/WorkOrder/BySid";this.cw.runRequest(n,r).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getByIds(e){return new Promise((s,r)=>{var n={};if(0==e.length)r(new t(10,"No workorder S/IDs were provided.",{workorderSId:e}));else{var i="Ams/WorkOrder/ByIds";I.isString(e[0])?(I.set(n,"WorkOrderIds",e),i="Ams/WorkOrder/ByIds"):I.isNumber(e[0])?(I.set(n,"WorkOrderSids",e),i="Ams/WorkOrder/BySids"):r(new t(9,"No workorder S/IDs were provided.",{workorderSId:e})),this.cw.runRequest(i,n).then(e=>{s(e.Value)}).catch(e=>{r(e)})}})}getInstructions(e){return new Promise((s,r)=>{var n={};if(0==e.length)r(new t(10,"No workorder S/IDs were provided.",{workorderSId:e}));else{var i="Ams/WorkOrder/ByIds";I.isString(e[0])?(I.set(n,"WorkOrderIds",e),i="Ams/WorkOrder/InstructionsByWorkOrderIds"):I.isNumber(e[0])?(I.set(n,"WorkOrderSids",e),i="Ams/WorkOrder/InstructionsByWorkOrderSids"):r(new t(9,"No workorder S/IDs were provided.",{workorderSId:e})),this.cw.runRequest(i,n).then(e=>{s(e.Value)}).catch(e=>{r(e)})}})}getAuditLog(e){return new Promise((s,r)=>{var n={};I.isString(e)?I.set(n,"WorkOrderId",e):I.isNumber(e)?I.set(n,"WorkOrderSid",e):r(new t(9,"Workorder S/IDs was not provided.",{workorderSId:e})),this.cw.runRequest("Ams/WorkOrder/AuditLog",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getCustomFieldValues(e){return new Promise((s,r)=>{var n={},i="Ams/WorkOrder/CustomFields";I.isString(e[0])?(I.set(n,"WorkOrderIds",e),i="Ams/WorkOrder/CustomFields"):I.isNumber(e[0])?(I.set(n,"WorkOrderSids",e),i="Ams/WorkOrder/CustomFieldsByWorkOrderSids"):r(new t(9,"No workorder S/IDs were provided.",{workorderSIds:e})),this.cw.runRequest(i,n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}comment(e,s){return new Promise((r,n)=>{var i={Comments:s};I.isString(e)?I.set(i,"WorkOrderId",e):I.isNumber(e)?I.set(i,"WorkOrderSid",e):n(new t(9,"Workorder S/IDs was not provided.",{workorderSId:e})),this.cw.runRequest("Ams/WorkOrder/AddComments",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getEntities(e,s=!0){return new Promise((r,n)=>{var i={GetGisData:s};0==e.length?n(new t(11,"No workorder S/IDs were provided.",{workorderSId:e})):I.isString(e[0])?I.set(i,"WorkOrderIds",e):I.isNumber(e[0])?I.set(i,"WorkOrderSids",e):n(new t(12,"No workorder S/IDs were provided.",{workorderSId:e})),this.cw.runRequest("Ams/WorkOrder/Entities",i).then(e=>{e.Status>0?n(new t(4,e.Message,{response:e})):r(e.Value)}).catch(e=>{n(e)})})}addEntities(e,s,r=!0){return new Promise((n,i)=>{var a={UpdateXY:r};I.isString(e)?I.set(a,"WorkOrderId",e):I.set(a,"WorkOrderSid",e),I.has(s,"Facility_Id")&&I.set(a,"Facility_Id",I.get(s,"Facility_Id")),I.has(s,"Level_Id")&&I.set(a,"Level_Id",I.get(s,"Level_Id")),I.has(s,"EntityUids")&&I.has(s,"EntityType")?(I.set(a,"EntityUids",I.get(s,"EntityUids")),I.set(a,"EntityType",I.get(s,"EntityType"))):i(new t(7,"No entity info was provided.",{workorderSId:e,entityInfo:s})),this.cw.runRequest("Ams/WorkOrder/AddEntities",a).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}updateEntity(e,s,r=!1){return new Promise((n,i)=>{var a={WorkComplete:r};I.isString(e)?I.set(a,"WorkOrderId",e):I.set(a,"WorkOrderSid",e),I.has(s,"Facility_Id")&&I.set(a,"Facility_Id",I.get(s,"Facility_Id")),I.has(s,"Level_Id")&&I.set(a,"Level_Id",I.get(s,"Level_Id")),I.has(s,"EntityUids")&&I.has(s,"EntityType")?(I.set(a,"EntityUid",I.get(s,"EntityUid")),I.set(a,"EntityType",I.get(s,"EntityType"))):i(new t(7,"No entity info was provided.",{workorderSId:e,entityInfo:s})),this.cw.runRequest("Ams/WorkOrder/UpdateEntity",a).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}removeEntities(e,s,r=!0){return new Promise((n,i)=>{var a={UpdateXY:r};I.isString(e)?I.set(a,"WorkOrderId",e):I.set(a,"WorkOrderSid",e),I.has(s,"ObjectIds")?I.set(a,"ObjectIds",I.get(s,"ObjectIds")):I.has(s,"EntityUids")&&I.has(s,"EntityType")?(I.set(a,"EntityUids",I.get(s,"EntityUids")),I.set(a,"EntityType",I.get(s,"EntityType"))):i(new t(8,"No entity info was provided.",{workorderSId:e,entityInfo:s})),this.cw.runRequest("Ams/WorkOrder/RemoveEntities",a).then(e=>{e.Status>0?i(new t(4,e.Message,{response:e})):n(e.Value)}).catch(e=>{i(e)})})}cancel(e,t,s){return new Promise((r,n)=>{var i={WorkOrderIds:e};void 0!==t&&I.set(i,"CancelReason",t),void 0!==s&&I.set(i,"DateCancelled",s),this.cw.runRequest("Ams/WorkOrder/Cancel",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}uncancel(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/WorkOrder/Uncancel",{WorkOrderIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}close(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/WorkOrder/Close",{WorkOrderIds:e}).then(e=>{e.Status>0?r(new t(5,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}reopen(e){return new Promise((t,s)=>{this.cw.runRequest("Ams/WorkOrder/ReOpen",{WorkOrderIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}delete(e){return new Promise((s,r)=>{this.cw.runRequest("Ams/WorkOrder/Delete",{WorkOrderIds:e}).then(e=>{e.Status>0?r(new t(4,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}getWOsByEntities(e,s,r,n=!0){return new Promise((i,a)=>{var o={};void 0!==r&&I.merge(o,r),I.has(o,"EntityType")||I.set(o,"EntityType",e),I.has(o,"EntityUids")||I.set(o,"EntityUids",s);var u="Ams/WorkOrder/SearchForSids";n||(u="Ams/WorkOrder/Search"),this.cw.runRequest(u,o).then(e=>{e.Status>0?a(new t(4,e.Message,{response:e})):i(e.Value)}).catch(e=>{a(e)})})}getSearchList(e){return new Promise((s,r)=>{var n={};I.set(n,"WorkOrderId",e),this.cw.runRequest("Ams/WorkOrder/SearchObject",n).then(e=>{e.Status>0?r(new t(4,e.Message,{response:e})):s(e.Value)}).catch(e=>{r(e)})})}getEmployeeLists(e,s=!1,r){return new Promise((n,i)=>{var a={IncludeInactiveEmployees:s};void 0!==r&&null!=r&&I.set(a,"DomainIds",r),I.includes(["Supervisors","SubmitTos"],e)?this.cw.runRequest(`Ams/WorkOrder/${e}`,a).then(e=>{n(e.Value)}).catch(e=>{i(e)}):i(new t(2,"listType must be either SubmitTos or Supervisors.",{provided:e}))})}getSubmitTos(e=!1,t){return this.getEmployeeLists("SubmitTos",e,t)}getSupervisors(e=!1,t){return this.getEmployeeLists("Supervisors",e,t)}getStatuses(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Statuses",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCategories(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Categories",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getPriorities(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Priorities",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleFrom(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/CycleFrom",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleIntervals(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/CycleIntervals",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getCycleTypes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/CycleTypes",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getStages(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/Stages",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getExpenseTypes(){return new Promise((e,t)=>{this.cw.runRequest("Ams/WorkOrder/ExpenseTypes",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}}require("lodash");class P{constructor(e){this.cw=void 0,this.cw=e}}const R=require("lodash");class C{constructor(e){this.cw=void 0,this.cw=e}addFee(e,t,s){return new Promise((r,n)=>{var i=R.merge({CaObjectId:e,FeeSetupId:t},s);this.cw.runRequest("Pll/CaseFees/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}addPayment(e,t){return new Promise((s,r)=>{var n=R.merge({CaObjectId:e},t);this.cw.runRequest("Pll/CasePayment/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addRefund(e,t,s){return new Promise((r,n)=>{this.cw.runRequest("Pll/CasePaymentRefund/Add",{CaPaymentId:e,RefundAmount:t,Comments:s}).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}addDepositPayment(e,t){return new Promise((s,r)=>{var n=R.merge({CaDepositId:e},t);this.cw.runRequest("Pll/CasePayment/AddDeposit",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addDeposit(e,t,s,r){return new Promise((n,i)=>{var a={CaObjectId:e,DepositId:t};void 0!==s&&R.set(a,"Amount",s),void 0!==r&&R.set(a,"CommentText",r),this.cw.runRequest("CaseDeposit/Add",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}addInstrument(e,t,s,r,n){return new Promise((i,a)=>{var o=R.merge({CaObjectId:e,InstTypeId:t,Amount:s,DateExpire:r},n);this.cw.runRequest("Pll/CaseInstrument/Add",o).then(e=>{i(e.Value)}).catch(e=>{a(e)})})}updateFee(e,t){return new Promise((s,r)=>{var n=R.merge({CaFeeId:e},t);this.cw.runRequest("Pll/CaseFees/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}voidRefund(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CasePaymentRefund/Update",{CaPaymentRefundId:e,Voided:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addDefaultFees(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CaseFees/AddDefault",{CaObjectId:e,BusCaseId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addDefaultDeposits(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CaseDeposit/AddDefault",{CaObjectId:e,BusCaseId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getFees(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseFees/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getDeposits(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDeposit/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getPayments(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePayment/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getInstruments(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteFee(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseFees/Delete",{CaFeeId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteFeesByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseFees/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deletePayment(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePayment/Delete",{CaFeeId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteRefund(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePaymentRefund/Delete",{CaPaymentRefundId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deletePaymentsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CasePayment/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteDeposit(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDeposit/Delete",{CaDepositId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteDepositsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDeposit/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteInstrument(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/Delete",{CaInstrumentId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteInstrumentsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchFees(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaFeeId","CaObjectId","FeeCode","FeeDesc"]).length&&r(new t(4,"At least one of the attributes (CaFeeId, CaObjectId, FeeCode, FeeDesc) must be defined.")),this.cw.runRequest("Pll/CaseFees/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchPayments(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaPaymentId","CommentText","FeeAmount","FeeCode","FeeDesc","PaymentAccount","PaymentAmount","TenderType"]).length&&r(new t(5,"At least one of the attributes (CaPaymentId, CommentText, FeeAmount, FeeCode, FeeDesc, PaymentAccount, PaymentAmount, TenderType) must be defined.")),this.cw.runRequest("Pll/CasePayment/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchRefunds(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaPaymentId","CaPaymentRefundId","Comments","RefundAmount"]).length&&r(new t(6,"At least one of the attributes (CaPaymentId, CaPaymentRefundId, Comments, RefundAmount) must be defined.")),this.cw.runRequest("Pll/CasePayment/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchDeposits(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["CaDepositId","CaObjectId","DepositCode","DepositDesc"]).length&&r(new t(1,"At least one of the arguments (CaDepositId, CaObjectId, DepositCode, DepositDesc) must be defined.")),this.cw.runRequest("Pll/CaseDeposit/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getAllFeeTemplates(){return new Promise((e,t)=>{this.cw.runRequest("Pll/FeeSetup/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchFeeTemplates(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["FeeSetupId","FeeTypeId","FeeCode","FeeDesc","AccountCode"]).length&&r(new t(7,"At least one of the arguments (FeeSetupId, FeeTypeId, FeeCode, FeeDesc, AccountCode) must be defined.")),this.cw.runRequest("Pll/FeeSetup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchCaseInstruments(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["AddressLine1","Amount","CaInstrumentId","CityName","CommentText","Company","ContactEmail","ContactName","ContactPhone","CountryCode","InstTypeId","SerialNumber","StateCode","ZipCode"]).length&&r(new t(9,"At least one of the arguments (AddressLine1, Amount, CaInstrumentId, CityName, CommentText, Company, ContactEmail, ContactName, ContactPhone, CountryCode, InstTypeId, SerialNumber, StateCode, ZipCode) must be defined.")),this.cw.runRequest("Pll/CaseInstrument/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getInstrumentList(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstrument/GetList",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}addCaseInstrumentRelease(e,s,r,n,i,a){return new Promise((o,u)=>{var c={CaInstrumentId:e,DateReleased:r,ReleasedBy:s};void 0===i&&null==i||void 0===n&&null==n?void 0!==i&&null!=i?R.set(c,"PercentReleased",i):void 0!==n&&null!=n&&R.set(c,"AmountReleased",n):u(new t(2,"Either amountReleased or percentReleased must be specified.")),void 0!==a&&R.set(c,"CommentText",a),this.cw.runRequest("Pll/CaseInstReleases/Add",c).then(e=>{o(e.Value)}).catch(e=>{u(e)})})}deleteCaseInstrumentRelease(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseInstReleases/Delete",{CaInstReleasesId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchCaseInstrumentReleases(e){return new Promise((s,r)=>{var n=e;0==R.intersectionBy(e,["AmountReleased","CaInstReleasesId","CaInstrumentId","CommentText","PercentReleased","ReleasedBy"]).length&&r(new t(3,"At least one of the attributes (AmountReleased, CaInstReleasesId, CaInstrumentId, CommentText, PercentReleased, ReleasedBy) must be defined.")),this.cw.runRequest("Pll/CaseInstReleases/Search",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}fees(){return new Promise((e,t)=>{this.cw.runRequest("Pll/FeeSetup/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchAvailableFees(e){return new Promise((s,r)=>{0==R.intersectionBy(e,["AccountCode","FeeCode","FeeDesc","FeeSetupId","FeeTypeId"]).length&&r(new t(8,"At least one of the attributes (AccountCode, FeeCode, FeeDesc, FeeSetupId, FeeTypeId) must be defined.")),this.cw.runRequest("Pll/FeeSetup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getTenderTypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/TenderType/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addTenderType(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TenderType/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateTenderType(e,t){return new Promise((s,r)=>{var n=R.merge({TenderTypeId:e},t);this.cw.runRequest("Pll/TenderType/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}}const q=require("lodash");class T{constructor(e){this.cw=void 0,this.cw=e}addGroup(e,t,s,r){return new Promise((n,i)=>{var a={CaObjectId:e,CaseDataGroupId:t,GroupCode:s};void 0!==r&&(a=q.merge(a,r)),this.cw.runRequest("Pll/CaseDataGroup/Add",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}addDefaultGroups(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CaseDataGroup/AddDefault",{CaObjectId:e,BusCaseId:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}wipAddDetail(e,t,s,r,n,i){return new Promise((a,o)=>{var u=q.merge({CaseDataDetailId:e,CaDataGroupId:t,ColumnSequence:s,DetailCode:r,DetailSequence:n},i);this.cw.runRequest("Pll/CaseDataGroup/Add",u).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}getGroupsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDataGroup/ByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteGroupsByCaseId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDataGroup/DeleteByCaObjectId",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchForGroups(e){return new Promise((s,r)=>{0==q.intersectionBy(e,["CaDataGroupId","CaseDataGroupId","GroupCode","GroupDesc","GroupSum","SumFlag"]).length&&r(new t(2,"At least one of the attributes (CaDataGroupId, CaseDataGroupId, GroupCode, GroupDesc, GroupSum, SumFlag) must be defined.")),this.cw.runRequest("Pll/CaseDataGroup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}checkGIS(e,s,r){return new Promise((n,i)=>{var a={EntityType:e,EntityUid:s};q.has(r,"CaObjectId")?q.set(a,"CaObjectId",q.get(r,"CaObjectId")):q.has(r,"CaseDataGroupId")?q.set(a,"CaseDataGroupId",q.get(r,"CaseDataGroupId")):i(new t(1,"Either CaObjectId or CaseDataGroupId is required.",{provided:r})),q.has(r,"CaseDataDetailId")&&q.set(a,"CaseDataDetailId",q.get(r,"CaseDataDetailId")),this.cw.runRequest("Pll/CaseDataGroup/CheckGISChanges",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}updateGroupsFromAsset(e,t,s,r){return new Promise((n,i)=>{var a={CaObjectId:e,EntityType:t,EntityUid:s};void 0!==r&&q.set(a,"CaDataGroupId",r),this.cw.runRequest("Pll/CaseDataGroup/UpdateFromAsset",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}addDetail(e,t,s){return new Promise((r,n)=>{var i={CaDataGroupId:e,CaseDataDetailId:t};void 0!==s&&(i=q.merge(i,s)),this.cw.runRequest("Pll/CaseDataDetail/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}updateDetail(e,t){return new Promise((s,r)=>{var n={CaDataDetailId:e};void 0!==t&&(n=q.merge(n,t)),this.cw.runRequest("Pll/CaseDataDetail/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}lockDetail(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDataDetail/UpdateLock",{CaDataDetailId:e,Lock:!0}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}unlockDetail(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDataDetail/UpdateLock",{CaDataDetailId:e,Lock:!1}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}addListValue(e,t){return new Promise((s,r)=>{this.cw.runRequest("Pll/CaseDataListValues/Add",{CaDataDetailId:e,ListValue:t}).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}deleteListValue(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseDataListValues/Delete",{CaDataDetailId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}searchForListValueIds(e){return new Promise((s,r)=>{0==q.intersectionBy(e,["CaDataDetailId","CaDataListId","ListValue"]).length&&r(new t(3,"At least one of the attributes (CaDataDetailId, CaDataListId, ListValue) must be defined.")),this.cw.runRequest("Pll/CaseDataGroup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchForListValueObjects(e){return new Promise((s,r)=>{0==q.intersectionBy(e,["CaDataDetailId","CaDataListId","ListValue"]).length&&r(new t(3,"At least one of the attributes (CaDataDetailId, CaDataListId, ListValue) must be defined.")),this.cw.runRequest("Pll/CaseDataGroup/SearchObject",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}}const g=require("lodash");class S{constructor(e){this.cw=void 0,this.cw=e}addBusinessCaseTemplate(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/BusinessCase/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateBusinessCaseTemplate(e,t){return new Promise((s,r)=>{var n=g.merge({BusCaseId:e},t);this.cw.runRequest("Pll/BusinessCase/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getBusinessCaseTemplates(){return new Promise((e,t)=>{this.cw.runRequest("Pll/BusinessCase/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addCaseType(e,t,s){return new Promise((r,n)=>{var i=g.merge({CaseType:e,CaseTypeDesciption:t},s);this.cw.runRequest("Pll/CaseType/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}updateCaseType(e,t){return new Promise((s,r)=>{var n=g.merge({CaseTypeId:e},t);this.cw.runRequest("Pll/CaseType/GetList",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getCaseTypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/CaseType/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchCaseTypeIDs(e){return new Promise((s,r)=>{0==g.intersectionBy(e,["CaseType","CaseTypeDesc","CaseTypeId"]).length&&r(new t(2,"At least one of the attributes (CaFeeId, CaObjectId, FeeCode, FeeDesc) must be defined.")),this.cw.runRequest("Pll/CaseType/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}searchCaseTypeObjects(e){return new Promise((s,r)=>{0==g.intersectionBy(e,["CaseType","CaseTypeDesc","CaseTypeId"]).length&&r(new t(3,"At least one of the attributes (CaseType, CaseTypeDesc, CaseTypeId) must be defined.")),this.cw.runRequest("Pll/CaseType/SearchObject",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}addSubtype(e,t,s){return new Promise((r,n)=>{var i=g.merge({SubType:e,SubTypeDesc:t},s);this.cw.runRequest("Pll/SubType/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}updateSubtype(e,t){return new Promise((s,r)=>{var n=g.merge({SubTypeId:e},t);this.cw.runRequest("Pll/SubType/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getSubtypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/SubType/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getFees(){return new Promise((e,t)=>{this.cw.runRequest("Pll/FeeSetup/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchFees(e){return new Promise((s,r)=>{0==g.intersectionBy(e,["AccountCode","FeeCode","FeeDesc","FeeSetupId","FeeTypeId"]).length&&r(new t(4,"At least one of the attributes (AccountCode, FeeCode, FeeDesc, FeeSetupId, FeeTypeId) must be defined.")),this.cw.runRequest("Pll/FeeSetup/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getExpirations(){return new Promise((e,t)=>{this.cw.runRequest("Pll/ExpirationType/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addExpiration(e){return new Promise((s,r)=>{g.has(e,"OrgId")&&g.has(e,"ExpirationTypeDesc")||r(new t(5,"OrgId and ExpirationTypeDesc must both be defined.")),this.cw.runRequest("Pll/ExpirationType/Add",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getDeposits(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Deposit/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}searchDeposits(e){return new Promise((s,r)=>{0==g.intersectionBy(e,["AccountCode","DepositCode","DepositDesc","DepositId","DepositTypeId"]).length&&r(new t(4,"At least one of the attributes (AccountCode, DepositCode, DepositDesc, DepositId, DepositTypeId) must be defined.")),this.cw.runRequest("Pll/Deposit/Search",e).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getDisciplines(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Discipline/All",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addDepartment(e,t,s){return new Promise((r,n)=>{var i=g.merge({DepartmentCode:e,DepartmentName:t},s);this.cw.runRequest("Pll/Department/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getDepartments(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Department/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addDivision(e,t,s){return new Promise((r,n)=>{var i=g.merge({DepartmentId:e,DivisionName:t},s);this.cw.runRequest("Pll/Division/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}getDivisions(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Division/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addHoliday(e,t,s){return new Promise((r,n)=>{var i={HolidayDate:e,HolidayDesc:t};void 0!==s&&g.set(i,"HalfDayFlag",s),this.cw.runRequest("Pll/Holiday/Add",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}deleteHoliday(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/Holiday/Delete",{HolidayId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}getHolidays(){return new Promise((e,t)=>{this.cw.runRequest("Pll/Holiday/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addInspectionTimeBlock(e,t,s,r){return new Promise((n,i)=>{var a={LabelText:e,StartTime:t,EndTime:s};void 0!==r&&g.set(a,"InspTimeBlocksDetails",r),this.cw.runRequest("Pll/InspectionTimeBlock/Add",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getInspectionTimeBlocks(){return new Promise((e,t)=>{this.cw.runRequest("Pll/InspectionTimeBlock/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getNotificationCases(){return new Promise((e,t)=>{this.cw.runRequest("Pll/NotificationCase/GetNotificationCaseList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}getNotificationTypes(){return new Promise((e,t)=>{this.cw.runRequest("Pll/NotificationType/GetNotificationTypeList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addNumberingGroup(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/NumberingGroup/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateNumberingGroup(e,t){return new Promise((s,r)=>{var n=g.merge({NumberingGroupId:e},t);this.cw.runRequest("Pll/NumberingGroup/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getNumberingGroups(){return new Promise((e,t)=>{this.cw.runRequest("Pll/NumberingGroup/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addPerson(e,t){return new Promise((s,r)=>{var n=g.merge(t,{Name:e});this.cw.runRequest("Pll/People/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getPeople(){return new Promise((e,t)=>{this.cw.runRequest("Pll/People/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addPeopleRole(e,t){return new Promise((s,r)=>{var n=g.merge(t,{RoleCode:e});this.cw.runRequest("Pll/People/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getPeopleRoles(){return new Promise((e,t)=>{this.cw.runRequest("Pll/PeopleRole/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addTaskResultDetail(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultDetail/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateTaskResultDetail(e,t){return new Promise((s,r)=>{var n=g.merge(t,{ResultDetailId:e});this.cw.runRequest("Pll/TaskResultDetail/Add",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getTaskResultDetails(){return new Promise((e,t)=>{this.cw.runRequest("Pll/TaskResultDetail/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}addTaskResultFeeInsert(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/Add",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteTaskResultFeeInsert(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/Delete",{TaskResultFeeInsertId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}deleteTaskResultFeeInsertByTaskId(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/DeleteByTaskId",{TaskId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}updateTaskResultFeeInsert(e,t,s,r){return new Promise((n,i)=>{var a={TaskResultFeeInsertId:e,TaskId:t,TaskResultId:s};void 0!==r&&g.set(a,"FeeSetupId",r),this.cw.runRequest("Pll/TaskResultFeeInsert/Update",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}getTaskResultFeeInsert(){return new Promise((e,t)=>{this.cw.runRequest("Pll/TaskResultFeeInsert/GetList",{}).then(t=>{e(t.Value)}).catch(e=>{t(e)})})}}const k=require("lodash");class A{constructor(e){this.cw=void 0,this.data=void 0,this.workflow=void 0,this.financial=void 0,this.admin=void 0,this.cw=e,this.data=new P(e),this.workflow=new T(e),this.financial=new C(e),this.admin=new S(e)}create(e,t,s){return new Promise((r,n)=>{var i=k.merge({CaseTypeId:e,SubTypeId:t},s);this.cw.runRequest("Pll/Case/Create",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}createChild(e,t,s){return new Promise((r,n)=>{var i=k.merge({BusCaseId:e,ParentCaObjectId:t},s);this.cw.runRequest("Pll/Case/CreateChild",i).then(e=>{r(e.Value)}).catch(e=>{n(e)})})}createFromRequest(e,t,s,r){return new Promise((n,i)=>{var a=k.merge({CaseTypeId:e,SubTypeId:t,ServiceRequestId:s},r);this.cw.runRequest("Pll/CaseObject/CreateCaseFromServiceRequest",a).then(e=>{n(e.Value)}).catch(e=>{i(e)})})}update(e,t){return new Promise((s,r)=>{var n=k.merge({CaObjectId:e},t);this.cw.runRequest("Pll/CaseObject/Update",n).then(e=>{s(e.Value)}).catch(e=>{r(e)})})}getByIds(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseObject/ByIds",{CaObjectIds:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}search(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseObject/Search",e).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}move(e,s,r,n,i){return new Promise((a,o)=>{k.has(n,"WKID")||k.has(n,"WKT")||o(new t(1,"You must provide either the WKID or WKT for the x/y coordinates.",{projection:n}));var u={CaObjectId:e,X:s,Y:r};void 0!==i&&k.set(u,"Z",i);var c=k.merge(u,n);this.cw.runRequest("Pll/CaseObject/Move",c).then(e=>{a(e.Value)}).catch(e=>{o(e)})})}delete(e){return new Promise((t,s)=>{this.cw.runRequest("Pll/CaseObject/DeleteCase",{CaObjectId:e}).then(e=>{t(e.Value)}).catch(e=>{s(e)})})}}const V=require("https"),D=require("querystring"),b=require("lodash");module.exports=class{constructor(e,t,s){this.base_url=void 0,this.Token=void 0,this.login=void 0,this.password=void 0,this.gisToken=void 0,this.gisTokenUrl=void 0,this.settings=void 0,this.error=void 0,this.general=void 0,this.activity_link=void 0,this.message_queue=void 0,this.gis=void 0,this.search=void 0,this.request=void 0,this.inspection=void 0,this.workorder=void 0,this.case=void 0,this.extensions=void 0,this.features=void 0,this.potential_loads=void 0,this.base_url="cityworksonline",this.extensions={UnknownExtension:0,CwAnalytics:1,WebHooks:2,PLLPublicApp:3,ActivityUpdate:4,SingleSignOn:5},this.features={UnknownFeature:0,ViewInspections:1,EditInspections:2,ViewServiceRequest:3,EditServiceRequest:4,ViewWorkOrder:5,EditWorkOrder:6,EquipmentCheckOut:7,OfficeField:8,Respond:9,Eurl:10,PaverInterface:11,Contracts:12,Storeroom:13,PLL:14,Cw4XL:15,TableEditor:16,CCTVInterface:17,MobileAndroid:18,MobileiOS:19,PerformanceBudgeting:20,Insights:21,RespondCase:22,RespondInspection:23,RespondServiceRequest:24,RespondTaskManager:25,RespondWorkOrder:26,Workload:27,OpX:28,TrimbleUnityMobile:29,TrimbleVegetationManager:30},this.settings={path:"cityworks",secure:!0,expires:null,default_domain:null},this.potential_loads=["general","activity_link","message_queue","gis","search","request","case","case_financial"],void 0!==e&&this.configure(e,t,s)}configure(e,t,s){if(this.base_url=void 0!==e?e:"cityworksonline",this.settings={path:"cityworks",secure:!0,expires:null,default_domain:null},void 0!==t&&b.forEach(t,(e,t)=>{void 0!==this.settings[t]&&(this.settings[t]=e)}),void 0===s)this.general=new r(this),this.activity_link=new i(this),this.message_queue=new u(this),this.request=new l(this),this.inspection=new p(this),this.workorder=new v(this),this.case=new A(this);else{let e=this;b.forEach(this.potential_loads,function(t){switch(t){case"general":e.general=new r(e);break;case"activity_link":e.activity_link=new i(e);break;case"message_queue":e.message_queue=new u(e);break;case"gis":e.gis=new a(e);break;case"search":e.search=new c(e);break;case"request":e.request=new l(e);break;case"case":e.case=new A(e);break;case"inspection":e.inspection=new p(e);break;case"workorder":e.workorder=new v(e)}})}}runRequest(e,s){return new Promise((r,n)=>{let i={};i.data=JSON.stringify(s),void 0!==this.Token&&""!=this.Token&&"General/Authentication/CityworksOnlineAuthenticate"!=e&&"General/Authentication/Authenticate"!=e&&(i.token=this.Token);let a={hostname:this.base_url,port:443,path:"/"+this.settings.path+"/services/"+e,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":Buffer.byteLength(D.stringify(i))},timeout:1e7},o=V.request(a,e=>{let s="";e.on("error",function(e){console.log(e,"Caught on error"),n(new t(13,"Unknown error.",e))}),e.on("data",function(e){s+=e}),e.on("end",function(){try{if(null==(JSON.stringify(s)+"[test string]").match(/\<h2\>Object\ moved\ to/)){var e=JSON.parse(s);void 0===e?n(new t(10,"No response received from Cityworks API.")):void 0!==e&&void 0!==e.Value?r(e):n(new t(3,"Unknown error.",{options:a,postedData:i,api_returned_string:e}))}else n(new t(1,"Error parsing JSON. Cityworks returned HTML.",{response:s}))}catch(e){e instanceof SyntaxError?(console.log("try/catch error on JSON"),n(new t(1,"Error parsing JSON.",{error:e}))):(console.log("try/catch error on JSON"),n(new t(1,"Error parsing JSON.")))}})});o.write(D.stringify(i)),o.end()})}authenticate(e,s){return new Promise((r,n)=>{let i="General/Authentication/Authenticate";"cityworksonline"==this.base_url&&(i="General/Authentication/CityworksOnlineAuthenticate"),this.runRequest(i,{LoginName:e,Password:s}).then(i=>{i.Status>0?n(new t(10,i.Message)):void 0!==i.Value&&void 0!==i.Value.Token?(this.login=e,this.password=s,this.Token=i.Value.Token,r(!0)):n(new t(11,"Unknown Error"))}).catch(e=>{n(e)})})}authenticateWithGISToken(e,t,s,r){return this.login=e,this.gisToken=t,this.gisTokenUrl=s,void 0!==r&&(r=12096e5),new Promise((e,t)=>{this.runRequest("General/Authentication/AuthenticateGisToken",{LoginName:this.login,GisToken:this.gisToken,GisTokenUrl:this.gisTokenUrl,Expires:r}).then(t=>{void 0!==t.Status&&t.Status>0||(void 0!==t.Value&&void 0!==t.Value.Token?(this.Token=t.Value.Token,e(!0)):e(!1))}).catch(e=>{throw e})})}validateToken(e,t){return new Promise((s,r)=>{this.runRequest("General/Authentication/Validate",{Token:e}).then(r=>{r.Status>0?s(!1):(t&&(this.Token=e),s(r.Value))}).catch(e=>{throw e})})}setToken(e){return""!=e&&null!=e&&(this.Token=e,!0)}getToken(){return""!=this.Token&&null!=this.Token&&this.Token}revokeToken(e){return new Promise((t,s)=>{this.runRequest("General/Token/RevokeUser",{RevokeDate:e}).then(e=>{t(!(void 0!==e.Status&&e.Status>0))}).catch(e=>{throw e})})}getLocalizationSettings(){return new Promise((e,t)=>{this.runRequest("General/Localization/LocalizationSettings",{}).then(t=>{e(t.Value)})})}getTimezoneOptions(){return new Promise((e,t)=>{this.runRequest("General/Localization/TimeZones",{}).then(t=>{e(t.Value)})})}getCurrentLocation(){return new Promise((e,t)=>{this.runRequest("General/AppData/CurrentLocation",{}).then(t=>{e(t.Value)})})}licensedApiCheck(e,t){return new Promise((s,r)=>{this.runRequest("General/AppData/SelectedEntities",{Area:e,Service:t}).then(e=>{s(e.Value)})})}licensedExtensionCheck(e){return new Promise((s,r)=>{void 0===this.extensions[e]&&r(new t(4,"Extension provided does not exist or is mispelled.",{provided:e,available:this.extensions})),this.runRequest("General/Authorization/LicensedExtensionCheck",{Extension:this.extensions[e]}).then(e=>{s(e.Value)})})}licensedExtensionsCheck(e){return new Promise((s,r)=>{var n={Extensions:[]};b.forEach(e,e=>{void 0===this.extensions[e]?r(new t(5,"Extension provided does not exist or is mispelled.",{provided:e,available:this.extensions})):n.Extensions.push(this.extensions[e])}),this.runRequest("General/Authorization/LicensedExtensionsCheck",n).then(e=>{let n={},i=b.invert(this.extensions);b.forEach(e,(e,s)=>{void 0===i[e]?r(new t(6,"Extension index provided does not exist or isn't configured properly.",{provided_num_returned:e,available:this.extensions})):n[i[e]]=s}),s(n)})})}licensedFeatureCheck(e){return new Promise((s,r)=>{void 0===this.features[e]&&r(new t(7,"Feature provided does not exist or is mispelled.",{provided:e,available:this.features})),this.runRequest("General/Authorization/LicensedFeatureCheck",{Feature:this.features[e]}).then(e=>{s(e.Value)})})}licensedFeaturesCheck(e){return new Promise((s,r)=>{var n={Features:[]};b.forEach(e,e=>{void 0===this.features[e]?r(new t(8,"Feature provided does not exist or is mispelled.",{provided:e,available:this.features})):n.Features.push(this.features[e])}),this.runRequest("General/Authorization/LicensedFeaturesCheck",n).then(e=>{let n={},i=b.invert(this.features);b.forEach(e.Value,(e,s)=>{void 0===i[e]?r(new t(9,"Feature index provided does not exist or isn't configured properly.",{provided:e,available:i})):n[i[e]]=s}),s(n)})})}licensedServicesCheck(e){return new Promise((t,s)=>{this.runRequest("General/Authorization/LicensedServicesCheck",{Services:e}).then(e=>{t(e.Value)})})}cityworksOnlineSites(e,t){return new Promise((s,r)=>{this.runRequest("General/Authentication/CityworksOnlineSites",{LoginName:void 0!==e?e:this.login,Password:void 0!==t?t:this.password}).then(e=>{s(e.Value)})})}domains(){return new Promise((e,t)=>{this.runRequest("General/Authentication/Domains",{}).then(t=>{e(t.Value)})})}user(e){return new Promise((t,s)=>{this.runRequest("General/Authentication/User",{LoginName:void 0!==e?e:this.login}).then(e=>{t(e.Value)})})}version(){return new Promise((e,t)=>{this.runRequest("General/Authentication/Version",{}).then(t=>{e(t.Value)})})}};
|
|
2
2
|
//# sourceMappingURL=index.modern.js.map
|