@timesheet/sdk
Version:
Official TypeScript SDK for the Timesheet API
4 lines (3 loc) • 43.9 kB
JavaScript
;var Ee=Object.create;var ie=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,Ie=Object.prototype.hasOwnProperty;var De=(o,e)=>{for(var t in e)ie(o,t,{get:e[t],enumerable:!0})},Pe=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ke(e))!Ie.call(o,s)&&s!==t&&ie(o,s,{get:()=>e[s],enumerable:!(r=$e(e,s))||r.enumerable});return o};var P=(o,e,t)=>(t=o!=null?Ee(Ue(o)):{},Pe(e||!o||!o.__esModule?ie(t,"default",{value:o,enumerable:!0}):t,o)),Ne=o=>Pe(ie({},"__esModule",{value:!0}),o);var Le={};De(Le,{AbsenceResource:()=>W,AbsenceTypeResource:()=>B,ApiClient:()=>x,ApiKeyAuth:()=>re,AutomationResource:()=>O,ContractResource:()=>H,ContractTemplateResource:()=>K,DocumentReportResource:()=>V,DocumentResource:()=>z,EventResource:()=>j,ExpenseReportResource:()=>G,ExpenseResource:()=>D,ExportResource:()=>Z,NavigablePage:()=>c,NoteReportResource:()=>Y,NoteResource:()=>N,OAuth21Auth:()=>de,OAuth2Auth:()=>v,OAuthDiscovery:()=>se,OrganizationResource:()=>w,PauseResource:()=>q,ProfileResource:()=>M,ProjectResource:()=>$,RateResource:()=>U,ReportsClient:()=>X,Resource:()=>n,RetryConfig:()=>oe,SettingsResource:()=>S,TagResource:()=>I,TaskReportResource:()=>J,TaskResource:()=>k,TeamResource:()=>E,TimerResource:()=>_,TimesheetApiError:()=>l,TimesheetAuthError:()=>ee,TimesheetClient:()=>pe,TimesheetRateLimitError:()=>te,TodoResource:()=>L,WebhookEvents:()=>Me,WebhookResource:()=>F,combineWebhookEvents:()=>Se,createClient:()=>_e,discoverOAuth:()=>qe,generateCodeChallenge:()=>Te,generateCodeVerifier:()=>ye,generatePkceCodePair:()=>he,getDefaultDiscovery:()=>xe,isValidCodeVerifier:()=>me});module.exports=Ne(Le);var C=P(require("axios"));var l=class o extends Error{constructor(e,t,r,s){let i=t?s?`${e} (HTTP ${t}, Code: ${s})`:`${e} (HTTP ${t})`:e;super(i),this.name="TimesheetApiError",this.statusCode=t,this.responseBody=r,this.errorCode=s,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,o)}};var ee=class extends l{constructor(e,t=401,r){super(e,t,r,"authentication_error"),this.name="TimesheetAuthError"}};var te=class extends l{constructor(e,t){super(e,429,void 0,"rate_limit_exceeded"),this.name="TimesheetRateLimitError",this.retryAfter=t}getRetryAfterDate(){if(!this.retryAfter)return null;let e=Number(this.retryAfter);if(!isNaN(e))return new Date(e*1e3);let t=new Date(this.retryAfter);return isNaN(t.getTime())?null:t}};var fe="1.2.0";var x=class{constructor(e){this.config=e,this.httpClient=e.httpClient||C.default.create({baseURL:e.baseUrl,timeout:3e4,headers:{"User-Agent":`Timesheet-TypeScript-SDK/${fe}`,"Content-Type":"application/json"}}),this.httpClient.interceptors.request.use(async t=>{if(t.url!=="/oauth/token"&&this.config.authentication){let r=await this.config.authentication.getAuthHeaders();if(r)for(let[s,i]of Object.entries(r))t.headers.set(s,i)}return t})}async request(e){let t=null,r=this.config.retryConfig;for(let s=0;s<=r.maxRetries;s++)try{return(await this.httpClient.request(e)).data}catch(i){if(t=i,C.default.isAxiosError(i)&&i.response?.status===401){let p=i.response.data;throw new ee(p?.message||"Authentication failed",401,JSON.stringify(p))}if(C.default.isAxiosError(i)&&i.response?.status===429){let p=i.response.headers["retry-after"];throw new te("Rate limit exceeded",p)}let m=C.default.isAxiosError(i)?i.response?.status:void 0;if(s<r.maxRetries&&m&&r.retryableStatusCodes.includes(m)){let p=Math.min(r.initialDelay*Math.pow(r.backoffMultiplier,s),r.maxDelay);await this.sleep(p);continue}if(C.default.isAxiosError(i)){let p=i.response?.data;throw new l(p?.message||i.message,i.response?.status,JSON.stringify(p),p?.code)}else throw i instanceof Error?new l(i.message):new l("Unknown error occurred")}throw t||new Error("Unknown error")}async get(e,t){return this.request({method:"GET",url:e,params:t})}async post(e,t,r){return this.request({method:"POST",url:e,data:t,params:r})}async put(e,t,r){return this.request({method:"PUT",url:e,data:t,params:r})}async delete(e,t,r){return this.request({method:"DELETE",url:e,data:r,params:t})}async postMultipart(e,t){return this.request({method:"POST",url:e,data:t,headers:{"Content-Type":"multipart/form-data"}})}sleep(e){return new Promise(t=>setTimeout(t,e))}getBaseUrl(){return this.config.baseUrl}async getAuthHeaders(){if(this.config.authentication)return this.config.authentication.getAuthHeaders()}};var re=class{constructor(e){this.apiKey=e;if(e===null)throw new Error("API key cannot be null");if(e===void 0)throw new Error("API key cannot be undefined");if(!e)throw new Error("API key cannot be empty");if(typeof e!="string")throw new Error("API key must be a string");if(e.trim().length===0)throw new Error("API key cannot be empty or whitespace");if(!this.isValidFormat(e))throw new Error("Invalid API key format")}isValidFormat(e){return/^ts_[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/.test(e)}applyAuth(e){e.headers||(e.headers={}),e.headers.Authorization=`ApiKey ${this.apiKey}`}needsRefresh(){return!1}async refresh(){throw new Error("API keys cannot be refreshed")}async getAuthHeaders(){return{Authorization:`ApiKey ${this.apiKey}`}}isValid(){return typeof this.apiKey=="string"&&this.apiKey.trim().length>0&&this.isValidFormat(this.apiKey)}};var ce=P(require("axios")),be=P(require("jsonwebtoken")),y=class y{constructor(e,t,r){t&&r?(this.clientId=e,this.clientSecret=t,this.refreshToken=r,this.accessToken=""):(this.accessToken=e,this.parseTokenExpiry())}applyAuth(e){e.headers||(e.headers={}),e.headers.Authorization=`Bearer ${this.accessToken}`}needsRefresh(){return this.refreshToken&&!this.accessToken?!0:!this.refreshToken||!this.tokenExpiry?!1:new Date(Date.now()+300*1e3)>=this.tokenExpiry}async refresh(){if(!this.refreshToken)throw new Error("Cannot refresh without refresh token");if(this.refreshPromise)return this.refreshPromise;this.refreshPromise=this.performRefresh();try{await this.refreshPromise}finally{this.refreshPromise=void 0}}async performRefresh(){try{let e=await ce.default.post(y.TOKEN_ENDPOINT,new URLSearchParams({grant_type:"refresh_token",refresh_token:this.refreshToken,client_id:this.clientId,client_secret:this.clientSecret}),{headers:{"Content-Type":"application/x-www-form-urlencoded"}});this.accessToken=e.data.access_token,e.data.refresh_token&&(this.refreshToken=e.data.refresh_token),this.parseTokenExpiry()}catch(e){let t=e instanceof Error?e.message:"Unknown error";throw new Error(`Failed to refresh OAuth2 token: ${t}`)}}async getAuthHeaders(){return this.needsRefresh()&&await this.refresh(),{Authorization:`Bearer ${this.accessToken}`}}static async fromAuthorizationCode(e,t,r,s){try{let i=await ce.default.post(y.TOKEN_ENDPOINT,new URLSearchParams({grant_type:"authorization_code",code:r,redirect_uri:s,client_id:e,client_secret:t}),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}),m=i.data.access_token,p=i.data.refresh_token;return p?new y(e,t,p):new y(m)}catch(i){let m=i instanceof Error?i.message:"Unknown error";throw new Error(`Failed to exchange authorization code: ${m}`)}}static buildAuthorizationUrl(e,t,r){let s=new URLSearchParams({client_id:e,redirect_uri:t,response_type:"code"});return r&&s.append("state",r),`https://api.timesheet.io/oauth2/auth?${s.toString()}`}parseTokenExpiry(){try{let e=be.default.decode(this.accessToken);e&&e.exp&&(this.tokenExpiry=new Date(e.exp*1e3))}catch{this.tokenExpiry=new Date(Date.now()+3600*1e3)}}};y.TOKEN_ENDPOINT="https://api.timesheet.io/oauth2/token";var v=y;var ue=P(require("axios")),Ce=P(require("jsonwebtoken"));var ne=require("crypto");function ye(o=64){if(o<43||o>128)throw new Error("Code verifier length must be between 43 and 128 characters");let e=(0,ne.randomBytes)(Math.ceil(o*3/4));return Re(e).slice(0,o)}function Te(o,e="S256"){if(e==="plain")return o;let t=(0,ne.createHash)("sha256").update(o,"ascii").digest();return Re(t)}function he(o="S256",e=64){let t=ye(e),r=Te(t,o);return{codeVerifier:t,codeChallenge:r,codeChallengeMethod:o}}function me(o){return o.length<43||o.length>128?!1:/^[A-Za-z0-9\-._~]+$/.test(o)}function Re(o){return o.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var f=class f{constructor(e){if(typeof e=="string")this.accessToken=e,this.tokenEndpoint=f.DEFAULT_TOKEN_ENDPOINT,this.parseTokenExpiry();else{let t=e;this.clientId=t.clientId,this.clientSecret=t.clientSecret,this.refreshToken=t.refreshToken,this.resource=t.resource,this.tokenEndpoint=t.tokenEndpoint??f.DEFAULT_TOKEN_ENDPOINT,this.accessToken=""}}applyAuth(e){e.headers||(e.headers={}),e.headers.Authorization=`Bearer ${this.accessToken}`}needsRefresh(){return this.refreshToken&&!this.accessToken?!0:!this.refreshToken||!this.tokenExpiry?!1:new Date(Date.now()+300*1e3)>=this.tokenExpiry}async refresh(){if(!this.refreshToken)throw new Error("Cannot refresh without refresh token");if(this.refreshPromise)return this.refreshPromise;this.refreshPromise=this.performRefresh();try{await this.refreshPromise}finally{this.refreshPromise=void 0}}async performRefresh(){try{let e=new URLSearchParams({grant_type:"refresh_token",refresh_token:this.refreshToken,client_id:this.clientId});this.clientSecret&&e.append("client_secret",this.clientSecret),this.resource&&e.append("resource",this.resource);let t=await ue.default.post(this.tokenEndpoint,e,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});this.accessToken=t.data.access_token,t.data.refresh_token&&(this.refreshToken=t.data.refresh_token),this.parseTokenExpiry()}catch(e){let t=e instanceof Error?e.message:"Unknown error";throw new Error(`Failed to refresh OAuth 2.1 token: ${t}`)}}async getAuthHeaders(){return this.needsRefresh()&&await this.refresh(),{Authorization:`Bearer ${this.accessToken}`}}static async fromAuthorizationCode(e){let{clientId:t,clientSecret:r,authorizationCode:s,redirectUri:i,codeVerifier:m,resource:p,tokenEndpoint:g}=e,h=g??f.DEFAULT_TOKEN_ENDPOINT;if(!me(m))throw new Error("Invalid code verifier: must be 43-128 characters using only A-Z, a-z, 0-9, -, ., _, ~");try{let u=new URLSearchParams({grant_type:"authorization_code",code:s,redirect_uri:i,client_id:t,code_verifier:m});r&&u.append("client_secret",r),p&&u.append("resource",p);let d=await ue.default.post(h,u,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}),Q=d.data.access_token,R=d.data.refresh_token;return R?new f({clientId:t,clientSecret:r,refreshToken:R,resource:p,tokenEndpoint:h}):new f(Q)}catch(u){let d=u instanceof Error?u.message:"Unknown error";throw new Error(`Failed to exchange authorization code: ${d}`)}}static buildAuthorizationUrl(e){let{clientId:t,redirectUri:r,codeChallenge:s,codeChallengeMethod:i="S256",state:m,scope:p,resource:g,authorizationEndpoint:h}=e,u=h??f.DEFAULT_AUTH_ENDPOINT,d=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:r,code_challenge:s,code_challenge_method:i});return m&&d.append("state",m),p&&d.append("scope",p),g&&d.append("resource",g),`${u}?${d.toString()}`}static generatePkce(e="S256"){return he(e)}parseTokenExpiry(){try{let e=Ce.default.decode(this.accessToken);e&&e.exp&&(this.tokenExpiry=new Date(e.exp*1e3))}catch{this.tokenExpiry=new Date(Date.now()+3600*1e3)}}};f.DEFAULT_TOKEN_ENDPOINT="https://api.timesheet.io/oauth2/token",f.DEFAULT_AUTH_ENDPOINT="https://api.timesheet.io/oauth2/auth";var de=f;var ae=P(require("axios")),A=class A{constructor(e={}){this.cache=new Map;this.options={cacheTtl:e.cacheTtl??A.DEFAULT_CACHE_TTL,timeout:e.timeout??A.DEFAULT_TIMEOUT,fetchOpenIdConfig:e.fetchOpenIdConfig??!1,fetchProtectedResource:e.fetchProtectedResource??!1}}async discover(e){let t=this.normalizeIssuerUrl(e),r=this.getCached(t);if(r)return r;let s=await this.fetchAuthorizationServerMetadata(t),i={issuer:s.issuer,authorizationServer:s,fetchedAt:new Date};if(this.options.fetchOpenIdConfig)try{i.openIdConfiguration=await this.fetchOpenIdConfiguration(t)}catch{}if(this.options.fetchProtectedResource)try{i.protectedResource=await this.fetchProtectedResourceMetadata(t)}catch{}return this.setCache(t,i),i}async fetchAuthorizationServerMetadata(e){let t=`${this.normalizeIssuerUrl(e)}/.well-known/oauth-authorization-server`;try{let r=await ae.default.get(t,{timeout:this.options.timeout,headers:{Accept:"application/json"}});return this.validateAuthorizationServerMetadata(r.data),r.data}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new Error(`Failed to fetch authorization server metadata from ${t}: ${s}`)}}async fetchOpenIdConfiguration(e){let t=`${this.normalizeIssuerUrl(e)}/.well-known/openid-configuration`;try{let r=await ae.default.get(t,{timeout:this.options.timeout,headers:{Accept:"application/json"}});return this.validateOpenIdConfiguration(r.data),r.data}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new Error(`Failed to fetch OpenID configuration from ${t}: ${s}`)}}async fetchProtectedResourceMetadata(e){let t=`${this.normalizeIssuerUrl(e)}/.well-known/oauth-protected-resource`;try{let r=await ae.default.get(t,{timeout:this.options.timeout,headers:{Accept:"application/json"}});return this.validateProtectedResourceMetadata(r.data),r.data}catch(r){let s=r instanceof Error?r.message:"Unknown error";throw new Error(`Failed to fetch protected resource metadata from ${t}: ${s}`)}}clearCache(){this.cache.clear()}clearCacheForIssuer(e){this.cache.delete(this.normalizeIssuerUrl(e))}isCached(e){return this.getCached(this.normalizeIssuerUrl(e))!==null}normalizeIssuerUrl(e){return e.replace(/\/+$/,"")}getCached(e){let t=this.cache.get(e);return t?new Date>=t.expiresAt?(this.cache.delete(e),null):t.result:null}setCache(e,t){let r=new Date(Date.now()+this.options.cacheTtl);this.cache.set(e,{result:t,expiresAt:r})}validateAuthorizationServerMetadata(e){if(!e.issuer)throw new Error("Authorization server metadata missing required field: issuer");if(!e.authorization_endpoint)throw new Error("Authorization server metadata missing required field: authorization_endpoint");if(!e.token_endpoint)throw new Error("Authorization server metadata missing required field: token_endpoint");if(!e.response_types_supported||e.response_types_supported.length===0)throw new Error("Authorization server metadata missing required field: response_types_supported")}validateOpenIdConfiguration(e){if(!e.issuer)throw new Error("OpenID configuration missing required field: issuer");if(!e.authorization_endpoint)throw new Error("OpenID configuration missing required field: authorization_endpoint");if(!e.token_endpoint)throw new Error("OpenID configuration missing required field: token_endpoint");if(!e.jwks_uri)throw new Error("OpenID configuration missing required field: jwks_uri")}validateProtectedResourceMetadata(e){if(!e.resource)throw new Error("Protected resource metadata missing required field: resource");if(!e.authorization_servers||e.authorization_servers.length===0)throw new Error("Protected resource metadata missing required field: authorization_servers")}};A.DEFAULT_CACHE_TTL=3600*1e3,A.DEFAULT_TIMEOUT=1e4;var se=A,le=null;function xe(){return le||(le=new se),le}async function qe(o,e){return(e?new se(e):xe()).discover(o)}var oe=class o{constructor(e={}){this.maxRetries=e.maxRetries??3,this.initialDelay=e.initialDelay??100,this.maxDelay=e.maxDelay??1e4,this.backoffMultiplier=e.backoffMultiplier??2,this.retryableStatusCodes=e.retryableStatusCodes??[429,502,503,504]}static default(){return new o}};var c=class{constructor(e,t){this.items=e.items,this.params=e.params,this.nextPageLoader=t}get totalPages(){return Math.ceil((this.params?.count||0)/(this.params?.limit||25))}get hasNextPage(){return(this.params?.page||1)<this.totalPages}async nextPage(){if(!this.hasNextPage)throw new Error("No more pages available");if(!this.nextPageLoader)throw new Error("Next page loader not configured");return this.nextPageLoader((this.params.page||1)+1)}async*[Symbol.asyncIterator](){let e=this;for(;;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage()}}async toArray(){let e=[];for await(let t of this)e.push(t);return e}};var Me={TEAM_CREATE:"team.create",TEAM_UPDATE:"team.update",PROJECT_CREATE:"project.create",PROJECT_UPDATE:"project.update",TODO_CREATE:"todo.create",TODO_UPDATE:"todo.update",TASK_CREATE:"task.create",TASK_UPDATE:"task.update",TAG_CREATE:"tag.create",TAG_UPDATE:"tag.update",RATE_CREATE:"rate.create",RATE_UPDATE:"rate.update",TIMER_START:"timer.start",TIMER_STOP:"timer.stop",TIMER_PAUSE:"timer.pause",TIMER_RESUME:"timer.resume"};function Se(...o){return o.join(",")}var n=class{constructor(e,t){this.http=e;typeof t=="string"?this.basePath=t:this.basePath=t.basePath}createNavigablePage(e,t){return new c(e,t)}};var w=class extends n{constructor(e){super(e,"/v1/organizations")}async list(e){let t=e?{sort:e.sort,order:e.order,page:e.page,limit:e.limit,permission:e.permission}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}async listMembers(e,t){let r=await this.http.post(`${this.basePath}/${encodeURIComponent(e)}/members/list`,t);return this.createNavigablePage(r,s=>this.listMembers(e,{...t,page:s}))}async getMember(e,t){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`)}async addMember(e,t){return this.http.post(`${this.basePath}/${encodeURIComponent(e)}/members`,t)}async updateMember(e,t,r){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,r)}async removeMember(e,t){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`)}async removeInvitedMember(e,t){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}/invited`)}};var E=class extends n{constructor(e){super(e,"/v1/teams")}async list(e){let t=e?{sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}async listMembers(e,t){let r=await this.http.post(`${this.basePath}/${e}/members/list`,t);return this.createNavigablePage(r,s=>this.listMembers(e,{...t,page:s}))}async getMember(e,t){return this.http.get(`${this.basePath}/${e}/members/${t}`)}async getColleagues(e){let t=await this.http.post(`${this.basePath}/getColleagues`,e);return this.createNavigablePage(t,r=>this.getColleagues({...e,page:r}))}async addMember(e,t){return this.http.post(`${this.basePath}/${e}/members`,t)}async updateMember(e,t,r){return this.http.put(`${this.basePath}/${e}/members/${t}`,r)}async removeMember(e,t){return this.http.delete(`${this.basePath}/${e}/members/${t}`)}async removeInvitedMember(e,t){return this.http.delete(`${this.basePath}/${e}/members/${t}/invited`)}async getMemberStatus(e){let t=await this.http.post(`${this.basePath}/getMemberStatus`,e);return this.createNavigablePage(t,r=>this.getMemberStatus({...e,page:r}))}};var $=class extends n{constructor(e){super(e,"/v1/projects")}async list(e){let t=e?{teamId:e.teamId,status:e.status,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}async listMembers(e,t){let r=await this.http.post(`${this.basePath}/${encodeURIComponent(e)}/members/list`,t);return this.createNavigablePage(r,s=>this.listMembers(e,{...t,page:s}))}async addMember(e,t){return this.http.post(`${this.basePath}/${encodeURIComponent(e)}/members`,t)}async getMember(e,t){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`)}async updateMember(e,t,r){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,r)}async updateMembers(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}/members`,t)}async removeMember(e,t){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`)}async batchAddMembers(e,t){return this.http.post(`${this.basePath}/${encodeURIComponent(e)}/members/batch`,t)}async batchRemoveMembers(e,t){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}/members/batch`,void 0,t)}};var T=P(require("dayjs")),ve=P(require("dayjs/plugin/utc")),Ae=P(require("dayjs/plugin/timezone")),we=P(require("dayjs/plugin/customParseFormat"));T.default.extend(ve.default);T.default.extend(Ae.default);T.default.extend(we.default);var Oe="YYYY-MM-DDTHH:mm:ssZ",ze=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}$/,a={isValidTimestampFormat(o){return ze.test(o)},formatTimestamp(o){return typeof o=="string"&&this.isValidTimestampFormat(o)?o:(0,T.default)(o||new Date).format(Oe)},parseTimestamp(o){return(0,T.default)(o).toDate()},formatDate(o){return(0,T.default)(o||new Date).format("YYYY-MM-DD")},now(){return this.formatTimestamp()}};var k=class extends n{constructor(e){super(e,"/v1/tasks")}async list(e){let t=e?{sort:e.sort,order:e.order,page:e.page,limit:e.limit,organizationId:e.organizationId}:void 0,r=await this.http.get(this.basePath,t);return this.createNavigablePage(r,s=>this.list({...e,page:s}))}async create(e){let t={...e,startDateTime:a.formatTimestamp(e.startDateTime),endDateTime:e.endDateTime?a.formatTimestamp(e.endDateTime):void 0};return this.http.post(this.basePath,t)}async update(e,t){let r={...t,startDateTime:t.startDateTime?a.formatTimestamp(t.startDateTime):void 0,endDateTime:t.endDateTime?a.formatTimestamp(t.endDateTime):void 0};return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,r)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}async statistics(e){return this.http.post(`${this.basePath}/statistics`,e)}async updateStatus(e){return this.http.put(`${this.basePath}/updateStatus`,e)}async updateTimes(e){let t={...e,start:a.formatTimestamp(e.start),end:a.formatTimestamp(e.end)};return this.http.put(`${this.basePath}/updateTimes`,t)}async print(e){return this.http.request({method:"GET",url:`${this.basePath}/print/${encodeURIComponent(e)}`,responseType:"arraybuffer"})}};var U=class extends n{constructor(e){super(e,"/v1/rates")}async list(e){let t=e?{teamId:e.teamId,projectId:e.projectId,status:e.status,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var I=class extends n{constructor(e){super(e,"/v1/tags")}async list(e){let t=e?{teamId:e.teamId,projectId:e.projectId,status:e.status,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return this.createNavigablePage(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var D=class extends n{constructor(e){super(e,"/v1/expenses")}async list(e){let t=e?{taskId:e.taskId,filter:e.filter,sort:e.sort,order:e.order,page:e.page,limit:e.limit,organizationId:e.organizationId}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){let t={...e,dateTime:a.formatTimestamp(e.dateTime)};return this.http.post(this.basePath,t)}async update(e,t){let r={...t,dateTime:t.dateTime?a.formatTimestamp(t.dateTime):void 0};return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,r)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}async updateStatus(e){return this.http.put(`${this.basePath}/updateStatus`,e)}async uploadFile(e,t){let r=new FormData;return r.append("file",t.file,t.fileName),this.http.postMultipart(`${this.basePath}/${encodeURIComponent(e)}/file`,r)}async createWithFile(e){let{file:t,...r}=e,s={...r,dateTime:a.formatTimestamp(r.dateTime)},i=new FormData;return i.append("data",new Blob([JSON.stringify(s)],{type:"application/json"})),t&&i.append("file",t.file,t.fileName),this.http.postMultipart(`${this.basePath}/with-file`,i)}async getFileUrl(e){return this.http.get(`${this.basePath}/getFileUrl/${encodeURIComponent(e)}`)}};var N=class extends n{constructor(e){super(e,"/v1/notes")}async list(e){let t=e?{taskId:e.taskId,sort:e.sort,order:e.order,page:e.page,limit:e.limit,organizationId:e.organizationId}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){let t={...e,dateTime:a.formatTimestamp(e.dateTime)};return this.http.post(this.basePath,t)}async update(e,t){let r={...t,dateTime:a.formatTimestamp(t.dateTime)};return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,r)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}async uploadFile(e,t){let r=new FormData;return r.append("file",t.file,t.fileName),this.http.postMultipart(`${this.basePath}/${encodeURIComponent(e)}/file`,r)}async createWithFile(e){let{file:t,...r}=e,s={...r,dateTime:a.formatTimestamp(r.dateTime)},i=new FormData;return i.append("data",new Blob([JSON.stringify(s)],{type:"application/json"})),t&&i.append("file",t.file,t.fileName),this.http.postMultipart(`${this.basePath}/with-file`,i)}async getFileUrl(e){return this.http.get(`${this.basePath}/getFileUrl/${encodeURIComponent(e)}`)}};var q=class extends n{constructor(e){super(e,"/v1/pauses")}async list(e){let t=e?{taskId:e.taskId,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){let t={...e,startDateTime:a.formatTimestamp(e.startDateTime),endDateTime:a.formatTimestamp(e.endDateTime)};return this.http.post(this.basePath,t)}async update(e,t){let r={...t,startDateTime:a.formatTimestamp(t.startDateTime),endDateTime:a.formatTimestamp(t.endDateTime)};return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,r)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var M=class{constructor(e){this.http=e}async getProfile(){return this.http.get("/v1/profiles/me")}async updateProfile(e){return this.http.put("/v1/profiles/me",e)}};var S=class{constructor(e){this.http=e}async get(){return this.http.get("/v1/settings")}async update(e){return this.http.put("/v1/settings",e)}};var O=class extends n{constructor(e){super(e,"/v1/automations")}async list(e){let t=e?{projectId:e.projectId,status:e.status,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var z=class extends n{constructor(e){super(e,"/v1/documents")}async list(e){let t=e?{organizationId:e.organizationId,type:e.type,status:e.status,template:e.template,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var _=class{constructor(e){this.http=e}async get(){return this.http.get("/v1/timer")}async start(e){let t={...e,startDateTime:e.startDateTime?a.formatTimestamp(e.startDateTime):a.formatTimestamp()};return this.http.post("/v1/timer/start",t)}async stop(e){let t=e?{...e,endDateTime:e.endDateTime?a.formatTimestamp(e.endDateTime):a.formatTimestamp()}:{endDateTime:a.formatTimestamp()};return this.http.post("/v1/timer/stop",t)}async pause(e){let t=e?{...e,startDateTime:e.startDateTime?a.formatTimestamp(e.startDateTime):a.formatTimestamp()}:{startDateTime:a.formatTimestamp()};return this.http.post("/v1/timer/pause",t)}async resume(e){let t=e?{...e,endDateTime:e.endDateTime?a.formatTimestamp(e.endDateTime):a.formatTimestamp()}:{endDateTime:a.formatTimestamp()};return this.http.post("/v1/timer/resume",t)}async update(e){let t={...e,startDateTime:e.startDateTime?a.formatTimestamp(e.startDateTime):void 0};return this.http.put("/v1/timer/update",t)}};var L=class extends n{constructor(e){super(e,"/v1/todos")}async list(e){let t=e?{projectId:e.projectId,status:e.status,sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return this.createNavigablePage(r,s=>this.list({...e,page:s}))}async create(e){let t={...e,dueDate:e.dueDate?a.formatTimestamp(e.dueDate):void 0};return this.http.post(this.basePath,t)}async update(e,t){let r={...t,dueDate:t.dueDate?a.formatTimestamp(t.dueDate):void 0};return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,r)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var F=class extends n{constructor(e){super(e,"/v1/webhooks")}async list(e){let t=e?{sort:e.sort,order:e.order,page:e.page,limit:e.limit}:void 0,r=await this.http.get(this.basePath,t);return new c(r,s=>this.list({...e,page:s}))}async create(e){return this.http.post(this.basePath,e)}async update(e,t){return this.http.put(`${this.basePath}/${encodeURIComponent(e)}`,t)}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async delete(e){return this.http.delete(`${this.basePath}/${encodeURIComponent(e)}`)}async search(e){let t=await this.http.post(`${this.basePath}/search`,e);return this.createNavigablePage(t,r=>this.search({...e,page:r}))}};var j=class extends n{constructor(e){super(e,"/v1/events")}async getStatus(){return this.http.get(`${this.basePath}/status`)}getStreamUrl(){return`${this.http.getBaseUrl()}${this.basePath}/stream`}async subscribe(e){let t=this.getStreamUrl(),s={Accept:"text/event-stream","Cache-Control":"no-cache",...await this.http.getAuthHeaders()},i=new AbortController,m=!1,p=new Map,g={close:()=>{m=!1,i.abort(),e.onClose?.()},get isConnected(){return m},on:(h,u)=>{p.has(h)||p.set(h,new Set),p.get(h).add(u)},off:(h,u)=>{p.get(h)?.delete(u)}};return this.connectSse(t,s,i.signal,{...e,onConnected:h=>{m=!0,e.onConnected?.(h)},onEvent:h=>{e.onEvent?.(h),p.get(h.event)?.forEach(d=>d(h))},onError:h=>{e.onError?.(h),p.get("error")?.forEach(d=>d(h))},onClose:()=>{m=!1,e.onClose?.()}}),g}async connectSse(e,t,r,s){try{let i=await fetch(e,{method:"GET",headers:t,signal:r});if(!i.ok)throw new Error(`SSE connection failed: ${i.status} ${i.statusText}`);if(!i.body)throw new Error("SSE response has no body");let m=i.body.getReader(),p=new TextDecoder,g="",h="",u="",d="",Q=!1;for(;!Q;){let R=await m.read();if(Q=R.done,Q||!R.value){s.onClose?.();break}g+=p.decode(R.value,{stream:!0});let ge=g.split(`
`);g=ge.pop()||"";for(let b of ge)b.startsWith("event:")?h=b.slice(6).trim():b.startsWith("data:")?u=b.slice(5).trim():b.startsWith("id:")?d=b.slice(3).trim():b===""&&(u&&this.processEvent(h,u,d,s),h="",u="",d="")}}catch(i){if(r.aborted)return;s.onError?.(i)}}processEvent(e,t,r,s){try{let i=JSON.parse(t);if(e==="connected"){let m=i;s.onConnected?.(m.connectionId)}else s.onEvent?.(i)}catch{s.onError?.(new Error(`Failed to parse event data: ${t}`))}}};var W=class extends n{constructor(e){super(e,"/v1/organizations")}orgPath(e){return`${this.basePath}/${encodeURIComponent(e)}/absences`}async list(e,t){let r=t?{contractId:t.contractId,page:t.page,limit:t.limit}:void 0,s=await this.http.get(this.orgPath(e),r);return this.createNavigablePage(s,i=>this.list(e,{...t,page:i}))}async search(e,t){let r=await this.http.post(`${this.orgPath(e)}/search`,t);return this.createNavigablePage(r,s=>this.search(e,{...t,page:s}))}async create(e,t){return this.http.post(this.orgPath(e),t)}async get(e,t){return this.http.get(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}async update(e,t,r){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}`,r)}async delete(e,t){return this.http.delete(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}async approve(e,t){return this.http.post(`${this.orgPath(e)}/${encodeURIComponent(t)}/approve`)}async reject(e,t,r){return this.http.post(`${this.orgPath(e)}/${encodeURIComponent(t)}/reject`,r)}async cancel(e,t,r){return this.http.post(`${this.orgPath(e)}/${encodeURIComponent(t)}/cancel`,r)}};var B=class extends n{constructor(e){super(e,"/v1/organizations")}orgPath(e){return`${this.basePath}/${encodeURIComponent(e)}/absence-types`}async list(e,t){let r=t?{sort:t.sort,order:t.order,page:t.page,limit:t.limit}:void 0,s=await this.http.get(this.orgPath(e),r);return this.createNavigablePage(s,i=>this.list(e,{...t,page:i}))}async create(e,t){return this.http.post(this.orgPath(e),t)}async get(e,t){return this.http.get(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}async update(e,t,r){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}`,r)}async delete(e,t){return this.http.delete(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}};var H=class extends n{constructor(e){super(e,"/v1/organizations")}orgPath(e){return`${this.basePath}/${encodeURIComponent(e)}/contracts`}async list(e,t){let r=t?{user:t.user,status:t.status,search:t.search,sort:t.sort,order:t.order,page:t.page,limit:t.limit}:void 0,s=await this.http.get(this.orgPath(e),r);return this.createNavigablePage(s,i=>this.list(e,{...t,page:i}))}async create(e,t){return this.http.post(this.orgPath(e),t)}async get(e,t){return this.http.get(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}async update(e,t,r){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}`,r)}async delete(e,t){return this.http.delete(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}async activate(e,t){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}/activate`)}async suspend(e,t){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}/suspend`)}async reactivate(e,t){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}/reactivate`)}async terminate(e,t){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}/terminate`)}};var K=class extends n{constructor(e){super(e,"/v1/organizations")}orgPath(e){return`${this.basePath}/${encodeURIComponent(e)}/contract-templates`}async list(e,t){let r=t?{sort:t.sort,order:t.order,page:t.page,limit:t.limit}:void 0,s=await this.http.get(this.orgPath(e),r);return this.createNavigablePage(s,i=>this.list(e,{...t,page:i}))}async create(e,t){return this.http.post(this.orgPath(e),t)}async get(e,t){return this.http.get(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}async update(e,t,r){return this.http.put(`${this.orgPath(e)}/${encodeURIComponent(t)}`,r)}async delete(e,t){return this.http.delete(`${this.orgPath(e)}/${encodeURIComponent(t)}`)}};var V=class extends n{constructor(e){super(e,"/v1/documents")}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async getPdf(e){return this.http.request({method:"GET",url:`${this.basePath}/${encodeURIComponent(e)}/pdf`,responseType:"arraybuffer"})}async getXml(e){return this.http.request({method:"GET",url:`${this.basePath}/${encodeURIComponent(e)}/xml`,headers:{Accept:"application/xml"}})}};var J=class extends n{constructor(e){super(e,"/v1/tasks")}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async getPdf(e){return this.http.request({method:"GET",url:`${this.basePath}/${encodeURIComponent(e)}/pdf`,responseType:"arraybuffer"})}};var G=class extends n{constructor(e){super(e,"/v1/expenses")}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async getPdf(e){return this.http.request({method:"GET",url:`${this.basePath}/${encodeURIComponent(e)}/pdf`,responseType:"arraybuffer"})}};var Y=class extends n{constructor(e){super(e,"/v1/notes")}async get(e){return this.http.get(`${this.basePath}/${encodeURIComponent(e)}`)}async getPdf(e){return this.http.request({method:"GET",url:`${this.basePath}/${encodeURIComponent(e)}/pdf`,responseType:"arraybuffer"})}};var Z=class extends n{constructor(e){super(e,"/v1/export")}async generate(e){return this.http.post(`${this.basePath}/data`,e)}async send(e){return this.http.post(`${this.basePath}/send`,e)}async generateFromTemplate(e){return this.http.request({method:"POST",url:`${this.basePath}/from-template`,data:e,responseType:"arraybuffer"})}async getFields(e){return this.http.get(`${this.basePath}/fields`,e?{scope:e}:void 0)}async getReportTypes(){return this.http.get(`${this.basePath}/report-types`)}async listTemplates(e){let t=await this.http.get(`${this.basePath}/templates`,e);return new c(t,r=>this.listTemplates({...e,page:r}))}async searchTemplates(e){let t=await this.http.post(`${this.basePath}/templates/search`,e);return this.createNavigablePage(t,r=>this.searchTemplates({...e,page:r}))}async createTemplate(e){let t=await this.http.post(`${this.basePath}/templates`,e);return this.normalizeTemplate(t)}async getTemplate(e){return this.http.get(`${this.basePath}/templates/${encodeURIComponent(e)}`)}async updateTemplate(e,t){let r=await this.http.put(`${this.basePath}/templates/${encodeURIComponent(e)}`,t);return this.normalizeTemplate(r)}normalizeTemplate(e){let t=r=>{if(Array.isArray(r))return r;if(typeof r=="string"&&r.length>0)try{let s=JSON.parse(r);return Array.isArray(s)?s:void 0}catch{return}};return{...e,teamIds:t(e.teamIds),projectIds:t(e.projectIds),userIds:t(e.userIds),tagIds:t(e.tagIds),exportedFields:t(e.exportedFields)}}async deleteTemplate(e){return this.http.delete(`${this.basePath}/templates/${encodeURIComponent(e)}`)}async listCustomFields(e){return this.http.get(`${this.basePath}/custom-fields`,e?{scope:e}:void 0)}async createCustomField(e){return this.http.post(`${this.basePath}/custom-fields`,e)}async getCustomField(e){return this.http.get(`${this.basePath}/custom-fields/${encodeURIComponent(e)}`)}async updateCustomField(e,t){return this.http.put(`${this.basePath}/custom-fields/${encodeURIComponent(e)}`,t)}async deleteCustomField(e){return this.http.delete(`${this.basePath}/custom-fields/${encodeURIComponent(e)}`)}};var X=class{constructor(e){this.documents=new V(e),this.tasks=new J(e),this.expenses=new G(e),this.notes=new Y(e),this.export=new Z(e)}};var pe=class{constructor(e){let t=this.createAuthentication(e),r=e.retryConfig||oe.default(),s={baseUrl:e.baseUrl||"https://api.timesheet.io",authentication:t,retryConfig:r,httpClient:e.httpClient};this.apiClient=new x(s);let i={baseUrl:e.reportsBaseUrl||"https://reports.timesheet.io",authentication:t,retryConfig:r,httpClient:e.reportsHttpClient};this.reportsApiClient=new x(i),this.organizations=new w(this.apiClient),this.teams=new E(this.apiClient),this.projects=new $(this.apiClient),this.tasks=new k(this.apiClient),this.rates=new U(this.apiClient),this.tags=new I(this.apiClient),this.expenses=new D(this.apiClient),this.notes=new N(this.apiClient),this.pauses=new q(this.apiClient),this.profile=new M(this.apiClient),this.settings=new S(this.apiClient),this.automations=new O(this.apiClient),this.documents=new z(this.apiClient),this.timer=new _(this.apiClient),this.todos=new L(this.apiClient),this.webhooks=new F(this.apiClient),this.events=new j(this.apiClient),this.absences=new W(this.apiClient),this.absenceTypes=new B(this.apiClient),this.contracts=new H(this.apiClient),this.contractTemplates=new K(this.apiClient),this.reports=new X(this.reportsApiClient)}createAuthentication(e){if(e.apiKey)return new re(e.apiKey);if(e.oauth2Token)return new v(e.oauth2Token);if(e.oauth2)return new v(e.oauth2.clientId,e.oauth2.clientSecret,e.oauth2.refreshToken);if(e.authentication)return e.authentication;throw new Error("Authentication must be configured")}};function _e(o){return new pe(o)}0&&(module.exports={AbsenceResource,AbsenceTypeResource,ApiClient,ApiKeyAuth,AutomationResource,ContractResource,ContractTemplateResource,DocumentReportResource,DocumentResource,EventResource,ExpenseReportResource,ExpenseResource,ExportResource,NavigablePage,NoteReportResource,NoteResource,OAuth21Auth,OAuth2Auth,OAuthDiscovery,OrganizationResource,PauseResource,ProfileResource,ProjectResource,RateResource,ReportsClient,Resource,RetryConfig,SettingsResource,TagResource,TaskReportResource,TaskResource,TeamResource,TimerResource,TimesheetApiError,TimesheetAuthError,TimesheetClient,TimesheetRateLimitError,TodoResource,WebhookEvents,WebhookResource,combineWebhookEvents,createClient,discoverOAuth,generateCodeChallenge,generateCodeVerifier,generatePkceCodePair,getDefaultDiscovery,isValidCodeVerifier});
//# sourceMappingURL=index.js.map