@abcagency/hire-control-sdk 1.0.49 → 1.0.51

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.
@@ -1 +1,5 @@
1
- export const API_URL = "https://api.myhirecontrol.com";
1
+ export const API_URL =
2
+ process.env.NEXT_PUBLIC_API_URL || // for Next.js
3
+ process.env.VITE_API_URL || // for Vite
4
+ process.env.REACT_APP_API_URL || // for Create React App
5
+ "https://api.myhirecontrol.com";
@@ -0,0 +1,84 @@
1
+ import FetchHandler from "../handlers/fetchHandler";
2
+ import { JobListing } from "../types/JobListing";
3
+ import { API_URL } from "../constants/config";
4
+
5
+ const fetchHandler = new FetchHandler(API_URL);
6
+
7
+ class JobListingsController {
8
+ /**
9
+ * Get all job listings for the authenticated user's company.
10
+ * @param {string | null} authToken - Optional auth token.
11
+ * @returns {Promise<JobListing[]>} - A list of job listings.
12
+ */
13
+ async getJobListingsByCompany(
14
+ authToken: string | null = null
15
+ ): Promise<JobListing[]> {
16
+ return fetchHandler.get<JobListing[]>("/joblistings", true, authToken);
17
+ }
18
+
19
+ /**
20
+ * Get a specific job listing by ID.
21
+ * @param {string} id - The job listing ID.
22
+ * @param {string | null} authToken - Optional auth token.
23
+ * @returns {Promise<JobListing>} - The job listing data.
24
+ */
25
+ async getJobListingById(
26
+ id: string,
27
+ authToken: string | null = null
28
+ ): Promise<JobListing> {
29
+ return fetchHandler.get<JobListing>(`/joblistings/${id}`, true, authToken);
30
+ }
31
+
32
+ /**
33
+ * Create a new job listing.
34
+ * @param {JobListing} jobListing - The job listing data to create.
35
+ * @param {string | null} authToken - Optional auth token.
36
+ * @returns {Promise<JobListing>} - The newly created job listing data.
37
+ */
38
+ async createJobListing(
39
+ jobListing: JobListing,
40
+ authToken: string | null = null
41
+ ): Promise<JobListing> {
42
+ return fetchHandler.post<JobListing, JobListing>(
43
+ "/joblistings",
44
+ jobListing,
45
+ true,
46
+ authToken
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Update an existing job listing.
52
+ * @param {string} id - The job listing ID to update.
53
+ * @param {JobListing} jobListing - The updated job listing data.
54
+ * @param {string | null} authToken - Optional auth token.
55
+ * @returns {Promise<void>} - No return value.
56
+ */
57
+ async updateJobListing(
58
+ id: string,
59
+ jobListing: JobListing,
60
+ authToken: string | null = null
61
+ ): Promise<void> {
62
+ return fetchHandler.put<JobListing, void>(
63
+ `/joblistings/${id}`,
64
+ jobListing,
65
+ true,
66
+ authToken
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Delete an existing job listing.
72
+ * @param {string} id - The job listing ID to delete.
73
+ * @param {string | null} authToken - Optional auth token.
74
+ * @returns {Promise<void>} - No return value.
75
+ */
76
+ async deleteJobListing(
77
+ id: string,
78
+ authToken: string | null = null
79
+ ): Promise<void> {
80
+ return fetchHandler.delete(`/joblistings/${id}`, true, authToken);
81
+ }
82
+ }
83
+
84
+ export default new JobListingsController();
@@ -1 +1 @@
1
- export declare const API_URL = "https://api.myhirecontrol.com";
1
+ export declare const API_URL: string;
@@ -0,0 +1,40 @@
1
+ import { JobListing } from "../types/JobListing";
2
+ declare class JobListingsController {
3
+ /**
4
+ * Get all job listings for the authenticated user's company.
5
+ * @param {string | null} authToken - Optional auth token.
6
+ * @returns {Promise<JobListing[]>} - A list of job listings.
7
+ */
8
+ getJobListingsByCompany(authToken?: string | null): Promise<JobListing[]>;
9
+ /**
10
+ * Get a specific job listing by ID.
11
+ * @param {string} id - The job listing ID.
12
+ * @param {string | null} authToken - Optional auth token.
13
+ * @returns {Promise<JobListing>} - The job listing data.
14
+ */
15
+ getJobListingById(id: string, authToken?: string | null): Promise<JobListing>;
16
+ /**
17
+ * Create a new job listing.
18
+ * @param {JobListing} jobListing - The job listing data to create.
19
+ * @param {string | null} authToken - Optional auth token.
20
+ * @returns {Promise<JobListing>} - The newly created job listing data.
21
+ */
22
+ createJobListing(jobListing: JobListing, authToken?: string | null): Promise<JobListing>;
23
+ /**
24
+ * Update an existing job listing.
25
+ * @param {string} id - The job listing ID to update.
26
+ * @param {JobListing} jobListing - The updated job listing data.
27
+ * @param {string | null} authToken - Optional auth token.
28
+ * @returns {Promise<void>} - No return value.
29
+ */
30
+ updateJobListing(id: string, jobListing: JobListing, authToken?: string | null): Promise<void>;
31
+ /**
32
+ * Delete an existing job listing.
33
+ * @param {string} id - The job listing ID to delete.
34
+ * @param {string | null} authToken - Optional auth token.
35
+ * @returns {Promise<void>} - No return value.
36
+ */
37
+ deleteJobListing(id: string, authToken?: string | null): Promise<void>;
38
+ }
39
+ declare const _default: JobListingsController;
40
+ export default _default;
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib");class e{constructor(t){this.apiUrl=t,this.isLocalhost="undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)}getAuthToken(){return this.isLocalhost?sessionStorage.getItem("token"):null}get(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=!1,n=null){this.isLocalhost&&e&&!n&&(n=this.getAuthToken());const r={method:"GET",credentials:n?"omit":"include"};return e?this.fetchWithAuth(t,r,n):this.fetchWithoutAuth(t,r)}))}post(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=!1,r=null,i=!1){this.isLocalhost&&n&&!r&&(r=this.getAuthToken());const o=i,s={method:"POST",credentials:r?"omit":"include",headers:Object.assign(Object.assign({},r?{Authorization:`Bearer ${r}`}:{}),o?{}:{"Content-Type":"application/json"}),body:o?this.convertToFormData(e):JSON.stringify(e)};return n?this.fetchWithAuth(t,s,r):this.fetchWithoutAuth(t,s)}))}put(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=!1,r=null,i=!1){this.isLocalhost&&n&&!r&&(r=this.getAuthToken());const o=i,s={method:"PUT",credentials:r?"omit":"include",headers:Object.assign(Object.assign({},r?{Authorization:`Bearer ${r}`}:{}),o?{}:{"Content-Type":"application/json"}),body:o?this.convertToFormData(e):JSON.stringify(e)};return n?this.fetchWithAuth(t,s,r):this.fetchWithoutAuth(t,s)}))}delete(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=!1,n=null){this.isLocalhost&&e&&!n&&(n=this.getAuthToken());const r={method:"DELETE",credentials:n?"omit":"include"};return e?this.fetchWithAuth(t,r,n):this.fetchWithoutAuth(t,r)}))}getFile(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=!1,n=null){this.isLocalhost&&e&&!n&&(n=this.getAuthToken());const r={method:"GET",credentials:n?"omit":"include",headers:e&&n?{Authorization:`Bearer ${n}`}:{}},i=yield fetch(`${this.apiUrl}${t}`,r);if(!i.ok)throw new Error(`Failed to fetch file: ${i.statusText}`);return i.blob()}))}convertToFormData(t,e=new FormData,n=""){return t instanceof File?e.append(n||"file",t):"string"==typeof t||"number"==typeof t||"boolean"==typeof t?e.append(n,t.toString()):Array.isArray(t)?t.forEach(((t,r)=>{this.convertToFormData(t,e,`${n}[${r}]`)})):"object"==typeof t&&null!==t&&Object.keys(t).forEach((r=>{const i=t[r],o=n?`${n}.${r}`:r;this.convertToFormData(i,e,o)})),e}fetchWithoutAuth(e,n){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield fetch(`${this.apiUrl}${e}`,n);return this.handleResponse(t)}))}fetchWithAuth(e,n,r){return t.__awaiter(this,void 0,void 0,(function*(){r?(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:`Bearer ${r}`}),n.credentials="omit"):n.credentials="include";let t=yield fetch(`${this.apiUrl}${e}`,n);if(401===t.status){if(!(yield this.refreshToken()))throw{statusCode:t.status};this.isLocalhost&&(r=this.getAuthToken())&&(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:`Bearer ${r}`})),t=yield fetch(`${this.apiUrl}${e}`,n)}return this.handleResponse(t)}))}handleResponse(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!e.ok||!e.status.toString().startsWith("2")){let t=`Error: ${e.status} ${e.statusText}`;try{const n=yield e.json();console.log(n),n&&n.message&&(t=n.message)}catch(t){console.error("Failed to parse error response:",t)}throw{statusCode:e.status,errorMessage:t}}return 200===e.status?e.json():null}))}refreshToken(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isLocalhost){return!!(yield fetch(`${this.apiUrl}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).ok||(console.error("Failed to refresh token"),!1)}{const t=sessionStorage.getItem("refreshToken");if(!t)return!1;const e=yield fetch(`${this.apiUrl}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(!e.ok)return console.error("Failed to refresh token"),!1;try{const t=yield e.json();return t.token&&sessionStorage.setItem("token",t.token),t.refreshToken&&sessionStorage.setItem("refreshToken",t.refreshToken),!0}catch(t){return console.error("Failed to parse refresh token response:",t),!1}}}))}}const n="https://api.myhirecontrol.com",r=new e(n),i="undefined"!=typeof window&&"localhost"===window.location.hostname;var o=new class{login(e){return t.__awaiter(this,void 0,void 0,(function*(){return r.post("/auth/login",e,!1)}))}nextLogin(e){return t.__awaiter(this,void 0,void 0,(function*(){const t="/auth/nextLogin"+(i?"?localhost=true":""),n=yield r.post(t,e,!1);return n&&(sessionStorage.setItem("token",n.token),sessionStorage.setItem("refreshToken",n.refreshToken),sessionStorage.setItem("expiration",n.expiration)),n}))}refreshToken(e){return t.__awaiter(this,void 0,void 0,(function*(){const t="/auth/refresh"+(i?"?localhost=true":""),n=yield r.post(t,e,!1);return n&&(sessionStorage.setItem("token",n.token),sessionStorage.setItem("refreshToken",n.refreshToken),sessionStorage.setItem("expiration",n.expiration)),n}))}changeCompany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t="/auth/changeCompany"+(i?"?localhost=true":"");var n=yield r.post(t,e,!0);return n&&(sessionStorage.setItem("token",n.token),sessionStorage.setItem("refreshToken",n.refreshToken),sessionStorage.setItem("expiration",n.expiration)),n}))}register(e){return t.__awaiter(this,void 0,void 0,(function*(){return r.post("/auth/register",e,!1)}))}getCompanies(){return t.__awaiter(this,void 0,void 0,(function*(){return r.get("/auth/companies",!0)}))}getCompany(){return t.__awaiter(this,void 0,void 0,(function*(){return r.get("/auth/company",!0)}))}getRoles(){return t.__awaiter(this,void 0,void 0,(function*(){return r.get("/auth/roles",!0)}))}isAuthenticated(){return t.__awaiter(this,void 0,void 0,(function*(){try{return yield r.get("/auth/authenticated",!0)}catch(t){return!1}}))}getUser(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield r.get("/auth/user",!0,t)}catch(t){throw t}}))}logout(){return t.__awaiter(this,void 0,void 0,(function*(){try{const t=yield r.post("/auth/logout",{},!0);return sessionStorage.removeItem("token"),sessionStorage.removeItem("refreshToken"),sessionStorage.removeItem("expiration"),t}catch(t){throw t}}))}getPermissions(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield r.get("/auth/permissions",!0,t)}catch(t){throw t}}))}};const s=new e(n);var a=new class{getEvents(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return s.get("/events",!0,t)}))}getEvent(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.get(`/events/${t}`,!0,e)}))}getEventBySlug(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.get(`/events/details/${t}`,!0,e)}))}createEvent(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.post("/events",t,!0,e)}))}updateEvent(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return s.put(`/events/${t}`,e,!0,n)}))}deleteEvent(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.delete(`/events/${t}`,!0,e)}))}};const u=new e(n);var l=new class{getAllRolesWithClaims(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return u.get("/roles",!0,t)}))}addRole(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return u.post("/roles",t,!0,e)}))}updateRole(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return u.put(`/roles/${t}`,e,!0,n)}))}deleteRole(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return u.delete(`/roles/${t}`,!0,e)}))}};const d=new e(n);var c=new class{getAllUsers(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield d.get("/users",!0,t)}catch(t){throw t}}))}getUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield d.get(`/users/${t}`,!0,e)}catch(t){throw t}}))}createUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield d.post("/users",t,!0,e)}catch(t){throw t}}))}updateUser(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){try{yield d.put(`/users/${t}`,e,!0,n)}catch(t){throw t}}))}updateLoggedInUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{yield d.put("/users",t,!0,e)}catch(t){throw t}}))}deleteUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{yield d.delete(`/users/${t}`,!0,e)}catch(t){throw t}}))}};const h=new e(n);var p=new class{forgotPassword(e){return t.__awaiter(this,void 0,void 0,(function*(){try{return yield h.post("/account/forgotPassword",e,!1)}catch(t){throw t}}))}resetPasswordWithToken(e){return t.__awaiter(this,void 0,void 0,(function*(){try{return yield h.post("/account/resetPasswordWithToken",e,!1)}catch(t){throw t}}))}resetPassword(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield h.post("/account/resetPassword",t,!0,e)}catch(t){throw t}}))}};const g=new e(n);var f=new class{getMapConfig(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield g.get("/mapconfig",!0,t)}catch(t){throw t}}))}updateMapConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return g.put("/mapconfig",t,!0,e)}))}createMapConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return g.post("/mapconfig",t,!0,e)}))}};const w=new e(n);var _=new class{getAllPermissions(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return w.get("/permissions",!0,t)}))}};const m=new e(n);var v=new class{getClientAuthConfigById(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield m.get(`/clientAuthConfig/${t}`,!0,e)}catch(t){throw t}}))}getAllClientAuthConfigs(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield m.get("/clientAuthConfig",!0,t)}catch(t){throw t}}))}createClientAuthConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return m.post("/clientAuthConfig",t,!0,e)}))}updateClientAuthConfig(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return m.put(`/clientAuthConfig/${t}`,e,!0,n)}))}deleteClientAuthConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return m.delete(`/clientAuthConfig/${t}`,!0,e)}))}};const y=new e(n);var C=new class{getListings(){return t.__awaiter(this,arguments,void 0,(function*(t=null,e=null){try{const n=e?`?filterId=${encodeURIComponent(e)}`:"";return yield y.get(`/listings${n}`,!0,t)}catch(t){throw t}}))}getListingDetails(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield y.get(`/listings/${t}`,!0,e)}catch(t){throw t}}))}};const A=new e(n);var S=new class{uploadMedia(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return A.post("/media/upload",t,!0,e,!0)}))}uploadProfileImage(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return A.post("/media/upload-profile-image",t,!0,e,!0)}))}listMedia(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){const n=new URLSearchParams({folderKey:t});return A.get(`/media/list?${n.toString()}`,!0,e)}))}deleteMedia(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){const n=new URLSearchParams({key:t});return A.delete(`/media/delete?${n.toString()}`,!0,e)}))}};const T=new e(n);var $=new class{getFilters(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return T.get("/filters",!0,t)}))}getFilter(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return T.get(`/filters/${t}`,!0,e)}))}createFilter(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return T.post("/filters",t,!0,e)}))}updateFilter(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return T.put(`/filters/${t}`,e,!0,n)}))}deleteFilter(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return T.delete(`/filters/${t}`,!0,e)}))}};const k=new e(n);var L=new class{getAppendListings(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return k.get("/appendListings",!0,t)}))}getAppendListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.get(`/appendListings/${t}`,!0,e)}))}createAppendListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.post("/appendListings",t,!0,e)}))}updateAppendListing(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return k.put(`/appendListings/${t}`,e,!0,n)}))}deleteAppendListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.delete(`/appendListings/${t}`,!0,e)}))}};const b=new e(n);var x=new class{getForms(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return b.get("/forms",!0,t)}))}getForm(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return b.get(`/forms/${t}`,!0,e)}))}createForm(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return b.post("/forms",t,!0,e)}))}updateForm(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return b.put(`/forms/${t}`,e,!0,n)}))}deleteForm(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return b.delete(`/forms/${t}`,!0,e)}))}processFormRequest(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return b.post("/forms/jsonSchema",t,!0,e)}))}};const F=new e(n);var I=new class{submitFormSubmission(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return F.post("/formsubmission",t,!0,e)}))}getFormSubmissions(){return t.__awaiter(this,arguments,void 0,(function*(t=20,e=1,n=null,r=null,i=null,o=null,s=null){const a=new URLSearchParams({pageSize:t.toString(),pageNumber:e.toString()});return r&&a.append("status",r.toString()),n&&a.append("type",n),i&&a.append("from",i.toISOString()),o&&a.append("to",o.toISOString()),F.get(`/formsubmission?${a.toString()}`,!0,s)}))}exportFormSubmissionsCsv(){return t.__awaiter(this,arguments,void 0,(function*(t=20,e=1,n=null,r=null,i=null,o=null,s=null){const a=new URLSearchParams({pageSize:t.toString(),pageNumber:e.toString()});r&&a.append("status",r.toString()),n&&a.append("type",n),i&&a.append("from",i.toISOString()),o&&a.append("to",o.toISOString());const u=yield F.getFile(`/formsubmission/export-csv?${a.toString()}`,!0,s),l=window.URL.createObjectURL(u),d=document.createElement("a");d.href=l,d.download="form_submissions.csv",document.body.appendChild(d),d.click(),window.URL.revokeObjectURL(l),document.body.removeChild(d)}))}getFormSubmissionTypes(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return F.get("/formsubmission/types",!0,t)}))}};const P=new e(n);var R,U,E,j=new class{getCompanies(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return P.get("/companies",!0,t)}))}getCompany(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return P.get(`/companies/${t}`,!0,e)}))}createCompany(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return P.post("/companies",t,!0,e)}))}updateCompany(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return P.put(`/companies/${t}`,e,!0,n)}))}deleteCompany(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return P.delete(`/companies/${t}`,!0,e)}))}syncAllCompanies(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return P.get("/companies/syncall",!0,t)}))}};exports.EventType=void 0,(R=exports.EventType||(exports.EventType={}))[R.Virtual=0]="Virtual",R[R.InPerson=1]="InPerson",R[R.Hybrid=2]="Hybrid",exports.CallToActionType=void 0,(U=exports.CallToActionType||(exports.CallToActionType={}))[U.Button=0]="Button",U[U.Link=1]="Link",U[U.Download=2]="Download",U[U.HireControlRegistration=3]="HireControlRegistration",exports.FormSubmissionStatus=void 0,(E=exports.FormSubmissionStatus||(exports.FormSubmissionStatus={}))[E.Submitted=1]="Submitted",E[E.Hold=2]="Hold",E[E.Rejected=3]="Rejected",E[E.Sent=4]="Sent";const O={login:o.login,nextLogin:o.nextLogin,refreshToken:o.refreshToken,changeCompany:o.changeCompany,register:o.register,isAuthenticated:o.isAuthenticated,getCompany:o.getCompany,getCompanies:o.getCompanies,getRoles:o.getRoles,getPermissions:o.getPermissions,logout:o.logout,getUser:o.getUser},W={getAll:a.getEvents,get:a.getEvent,getBySlug:a.getEventBySlug,create:a.createEvent,update:a.updateEvent,delete:a.deleteEvent},M={get:l.getAllRolesWithClaims,create:l.addRole,update:l.updateRole,delete:l.deleteRole},B=c,D=C,z={resetPassword:p.resetPassword,resetPasswordWithToken:p.resetPasswordWithToken,forgotPassword:p.forgotPassword},H={get:f.getMapConfig,update:f.updateMapConfig,create:f.createMapConfig},N={get:v.getClientAuthConfigById,getAll:v.getAllClientAuthConfigs,update:v.updateClientAuthConfig,create:v.createClientAuthConfig,delete:v.deleteClientAuthConfig},J={upload:S.uploadMedia,uploadProfileImage:S.uploadProfileImage,get:S.listMedia,delete:S.deleteMedia},q={getList:$.getFilters,get:$.getFilter,update:$.updateFilter,create:$.createFilter,delete:$.deleteFilter},G={get:L.getAppendListings,getAppendListing:L.getAppendListing,create:L.createAppendListing,update:L.updateAppendListing,delete:L.deleteAppendListing},V={get:_.getAllPermissions},K={getAll:j.getCompanies,getById:j.getCompany,create:j.createCompany,update:j.updateCompany,delete:j.deleteCompany,sync:j.syncAllCompanies},Q=x,X=I,Y={auth:O,events:W,roles:M,users:B,account:z,mapConfig:H,permissions:V,clientAuthConfig:N,filters:q,listings:D,media:J,appendListings:G,forms:Q,formSubmissions:X,companies:K};exports.account=z,exports.appendListings=G,exports.auth=O,exports.clientAuthConfig=N,exports.companies=K,exports.default=Y,exports.events=W,exports.filters=q,exports.formSubmissions=X,exports.forms=Q,exports.listings=D,exports.mapConfig=H,exports.media=J,exports.permissions=V,exports.roles=M,exports.users=B;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib");class e{constructor(t){this.apiUrl=t,this.isLocalhost="undefined"!=typeof window&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname)}getAuthToken(){return this.isLocalhost?sessionStorage.getItem("token"):null}get(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=!1,n=null){this.isLocalhost&&e&&!n&&(n=this.getAuthToken());const r={method:"GET",credentials:n?"omit":"include"};return e?this.fetchWithAuth(t,r,n):this.fetchWithoutAuth(t,r)}))}post(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=!1,r=null,i=!1){this.isLocalhost&&n&&!r&&(r=this.getAuthToken());const o=i,s={method:"POST",credentials:r?"omit":"include",headers:Object.assign(Object.assign({},r?{Authorization:`Bearer ${r}`}:{}),o?{}:{"Content-Type":"application/json"}),body:o?this.convertToFormData(e):JSON.stringify(e)};return n?this.fetchWithAuth(t,s,r):this.fetchWithoutAuth(t,s)}))}put(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=!1,r=null,i=!1){this.isLocalhost&&n&&!r&&(r=this.getAuthToken());const o=i,s={method:"PUT",credentials:r?"omit":"include",headers:Object.assign(Object.assign({},r?{Authorization:`Bearer ${r}`}:{}),o?{}:{"Content-Type":"application/json"}),body:o?this.convertToFormData(e):JSON.stringify(e)};return n?this.fetchWithAuth(t,s,r):this.fetchWithoutAuth(t,s)}))}delete(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=!1,n=null){this.isLocalhost&&e&&!n&&(n=this.getAuthToken());const r={method:"DELETE",credentials:n?"omit":"include"};return e?this.fetchWithAuth(t,r,n):this.fetchWithoutAuth(t,r)}))}getFile(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=!1,n=null){this.isLocalhost&&e&&!n&&(n=this.getAuthToken());const r={method:"GET",credentials:n?"omit":"include",headers:e&&n?{Authorization:`Bearer ${n}`}:{}},i=yield fetch(`${this.apiUrl}${t}`,r);if(!i.ok)throw new Error(`Failed to fetch file: ${i.statusText}`);return i.blob()}))}convertToFormData(t,e=new FormData,n=""){return t instanceof File?e.append(n||"file",t):"string"==typeof t||"number"==typeof t||"boolean"==typeof t?e.append(n,t.toString()):Array.isArray(t)?t.forEach(((t,r)=>{this.convertToFormData(t,e,`${n}[${r}]`)})):"object"==typeof t&&null!==t&&Object.keys(t).forEach((r=>{const i=t[r],o=n?`${n}.${r}`:r;this.convertToFormData(i,e,o)})),e}fetchWithoutAuth(e,n){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield fetch(`${this.apiUrl}${e}`,n);return this.handleResponse(t)}))}fetchWithAuth(e,n,r){return t.__awaiter(this,void 0,void 0,(function*(){r?(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:`Bearer ${r}`}),n.credentials="omit"):n.credentials="include";let t=yield fetch(`${this.apiUrl}${e}`,n);if(401===t.status){if(!(yield this.refreshToken()))throw{statusCode:t.status};this.isLocalhost&&(r=this.getAuthToken())&&(n.headers=Object.assign(Object.assign({},n.headers),{Authorization:`Bearer ${r}`})),t=yield fetch(`${this.apiUrl}${e}`,n)}return this.handleResponse(t)}))}handleResponse(e){return t.__awaiter(this,void 0,void 0,(function*(){if(!e.ok||!e.status.toString().startsWith("2")){let t=`Error: ${e.status} ${e.statusText}`;try{const n=yield e.json();console.log(n),n&&n.message&&(t=n.message)}catch(t){console.error("Failed to parse error response:",t)}throw{statusCode:e.status,errorMessage:t}}return 200===e.status?e.json():null}))}refreshToken(){return t.__awaiter(this,void 0,void 0,(function*(){if(!this.isLocalhost){return!!(yield fetch(`${this.apiUrl}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).ok||(console.error("Failed to refresh token"),!1)}{const t=sessionStorage.getItem("refreshToken");if(!t)return!1;const e=yield fetch(`${this.apiUrl}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})});if(!e.ok)return console.error("Failed to refresh token"),!1;try{const t=yield e.json();return t.token&&sessionStorage.setItem("token",t.token),t.refreshToken&&sessionStorage.setItem("refreshToken",t.refreshToken),!0}catch(t){return console.error("Failed to parse refresh token response:",t),!1}}}))}}const n=process.env.NEXT_PUBLIC_API_URL||process.env.VITE_API_URL||process.env.REACT_APP_API_URL||"https://api.myhirecontrol.com",r=new e(n),i="undefined"!=typeof window&&"localhost"===window.location.hostname;var o=new class{login(e){return t.__awaiter(this,void 0,void 0,(function*(){return r.post("/auth/login",e,!1)}))}nextLogin(e){return t.__awaiter(this,void 0,void 0,(function*(){const t="/auth/nextLogin"+(i?"?localhost=true":""),n=yield r.post(t,e,!1);return n&&(sessionStorage.setItem("token",n.token),sessionStorage.setItem("refreshToken",n.refreshToken),sessionStorage.setItem("expiration",n.expiration)),n}))}refreshToken(e){return t.__awaiter(this,void 0,void 0,(function*(){const t="/auth/refresh"+(i?"?localhost=true":""),n=yield r.post(t,e,!1);return n&&(sessionStorage.setItem("token",n.token),sessionStorage.setItem("refreshToken",n.refreshToken),sessionStorage.setItem("expiration",n.expiration)),n}))}changeCompany(e){return t.__awaiter(this,void 0,void 0,(function*(){const t="/auth/changeCompany"+(i?"?localhost=true":"");var n=yield r.post(t,e,!0);return n&&(sessionStorage.setItem("token",n.token),sessionStorage.setItem("refreshToken",n.refreshToken),sessionStorage.setItem("expiration",n.expiration)),n}))}register(e){return t.__awaiter(this,void 0,void 0,(function*(){return r.post("/auth/register",e,!1)}))}getCompanies(){return t.__awaiter(this,void 0,void 0,(function*(){return r.get("/auth/companies",!0)}))}getCompany(){return t.__awaiter(this,void 0,void 0,(function*(){return r.get("/auth/company",!0)}))}getRoles(){return t.__awaiter(this,void 0,void 0,(function*(){return r.get("/auth/roles",!0)}))}isAuthenticated(){return t.__awaiter(this,void 0,void 0,(function*(){try{return yield r.get("/auth/authenticated",!0)}catch(t){return!1}}))}getUser(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield r.get("/auth/user",!0,t)}catch(t){throw t}}))}logout(){return t.__awaiter(this,void 0,void 0,(function*(){try{const t=yield r.post("/auth/logout",{},!0);return sessionStorage.removeItem("token"),sessionStorage.removeItem("refreshToken"),sessionStorage.removeItem("expiration"),t}catch(t){throw t}}))}getPermissions(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield r.get("/auth/permissions",!0,t)}catch(t){throw t}}))}};const s=new e(n);var a=new class{getEvents(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return s.get("/events",!0,t)}))}getEvent(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.get(`/events/${t}`,!0,e)}))}getEventBySlug(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.get(`/events/details/${t}`,!0,e)}))}createEvent(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.post("/events",t,!0,e)}))}updateEvent(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return s.put(`/events/${t}`,e,!0,n)}))}deleteEvent(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return s.delete(`/events/${t}`,!0,e)}))}};const u=new e(n);var l=new class{getAllRolesWithClaims(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return u.get("/roles",!0,t)}))}addRole(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return u.post("/roles",t,!0,e)}))}updateRole(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return u.put(`/roles/${t}`,e,!0,n)}))}deleteRole(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return u.delete(`/roles/${t}`,!0,e)}))}};const d=new e(n);var c=new class{getAllUsers(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield d.get("/users",!0,t)}catch(t){throw t}}))}getUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield d.get(`/users/${t}`,!0,e)}catch(t){throw t}}))}createUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield d.post("/users",t,!0,e)}catch(t){throw t}}))}updateUser(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){try{yield d.put(`/users/${t}`,e,!0,n)}catch(t){throw t}}))}updateLoggedInUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{yield d.put("/users",t,!0,e)}catch(t){throw t}}))}deleteUser(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{yield d.delete(`/users/${t}`,!0,e)}catch(t){throw t}}))}};const h=new e(n);var g=new class{forgotPassword(e){return t.__awaiter(this,void 0,void 0,(function*(){try{return yield h.post("/account/forgotPassword",e,!1)}catch(t){throw t}}))}resetPasswordWithToken(e){return t.__awaiter(this,void 0,void 0,(function*(){try{return yield h.post("/account/resetPasswordWithToken",e,!1)}catch(t){throw t}}))}resetPassword(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield h.post("/account/resetPassword",t,!0,e)}catch(t){throw t}}))}};const p=new e(n);var f=new class{getMapConfig(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield p.get("/mapconfig",!0,t)}catch(t){throw t}}))}updateMapConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return p.put("/mapconfig",t,!0,e)}))}createMapConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return p.post("/mapconfig",t,!0,e)}))}};const _=new e(n);var w=new class{getAllPermissions(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return _.get("/permissions",!0,t)}))}};const m=new e(n);var v=new class{getClientAuthConfigById(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield m.get(`/clientAuthConfig/${t}`,!0,e)}catch(t){throw t}}))}getAllClientAuthConfigs(){return t.__awaiter(this,arguments,void 0,(function*(t=null){try{return yield m.get("/clientAuthConfig",!0,t)}catch(t){throw t}}))}createClientAuthConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return m.post("/clientAuthConfig",t,!0,e)}))}updateClientAuthConfig(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return m.put(`/clientAuthConfig/${t}`,e,!0,n)}))}deleteClientAuthConfig(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return m.delete(`/clientAuthConfig/${t}`,!0,e)}))}};const y=new e(n);var C=new class{getListings(){return t.__awaiter(this,arguments,void 0,(function*(t=null,e=null){try{const n=e?`?filterId=${encodeURIComponent(e)}`:"";return yield y.get(`/listings${n}`,!0,t)}catch(t){throw t}}))}getListingDetails(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){try{return yield y.get(`/listings/${t}`,!0,e)}catch(t){throw t}}))}};const A=new e(n);var S=new class{uploadMedia(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return A.post("/media/upload",t,!0,e,!0)}))}uploadProfileImage(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return A.post("/media/upload-profile-image",t,!0,e,!0)}))}listMedia(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){const n=new URLSearchParams({folderKey:t});return A.get(`/media/list?${n.toString()}`,!0,e)}))}deleteMedia(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){const n=new URLSearchParams({key:t});return A.delete(`/media/delete?${n.toString()}`,!0,e)}))}};const L=new e(n);var b=new class{getFilters(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return L.get("/filters",!0,t)}))}getFilter(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return L.get(`/filters/${t}`,!0,e)}))}createFilter(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return L.post("/filters",t,!0,e)}))}updateFilter(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return L.put(`/filters/${t}`,e,!0,n)}))}deleteFilter(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return L.delete(`/filters/${t}`,!0,e)}))}};const T=new e(n);var $=new class{getAppendListings(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return T.get("/appendListings",!0,t)}))}getAppendListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return T.get(`/appendListings/${t}`,!0,e)}))}createAppendListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return T.post("/appendListings",t,!0,e)}))}updateAppendListing(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return T.put(`/appendListings/${t}`,e,!0,n)}))}deleteAppendListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return T.delete(`/appendListings/${t}`,!0,e)}))}};const k=new e(n);var x=new class{getForms(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return k.get("/forms",!0,t)}))}getForm(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.get(`/forms/${t}`,!0,e)}))}createForm(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.post("/forms",t,!0,e)}))}updateForm(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return k.put(`/forms/${t}`,e,!0,n)}))}deleteForm(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.delete(`/forms/${t}`,!0,e)}))}processFormRequest(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return k.post("/forms/jsonSchema",t,!0,e)}))}};const I=new e(n);var F=new class{submitFormSubmission(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return I.post("/formsubmission",t,!0,e)}))}getFormSubmissions(){return t.__awaiter(this,arguments,void 0,(function*(t=20,e=1,n=null,r=null,i=null,o=null,s=null){const a=new URLSearchParams({pageSize:t.toString(),pageNumber:e.toString()});return r&&a.append("status",r.toString()),n&&a.append("type",n),i&&a.append("from",i.toISOString()),o&&a.append("to",o.toISOString()),I.get(`/formsubmission?${a.toString()}`,!0,s)}))}exportFormSubmissionsCsv(){return t.__awaiter(this,arguments,void 0,(function*(t=20,e=1,n=null,r=null,i=null,o=null,s=null){const a=new URLSearchParams({pageSize:t.toString(),pageNumber:e.toString()});r&&a.append("status",r.toString()),n&&a.append("type",n),i&&a.append("from",i.toISOString()),o&&a.append("to",o.toISOString());const u=yield I.getFile(`/formsubmission/export-csv?${a.toString()}`,!0,s),l=window.URL.createObjectURL(u),d=document.createElement("a");d.href=l,d.download="form_submissions.csv",document.body.appendChild(d),d.click(),window.URL.revokeObjectURL(l),document.body.removeChild(d)}))}getFormSubmissionTypes(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return I.get("/formsubmission/types",!0,t)}))}};const P=new e(n);var R=new class{getCompanies(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return P.get("/companies",!0,t)}))}getCompany(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return P.get(`/companies/${t}`,!0,e)}))}createCompany(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return P.post("/companies",t,!0,e)}))}updateCompany(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return P.put(`/companies/${t}`,e,!0,n)}))}deleteCompany(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return P.delete(`/companies/${t}`,!0,e)}))}syncAllCompanies(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return P.get("/companies/syncall",!0,t)}))}};const j=new e(n);var U,E,O,B=new class{getJobListingsByCompany(){return t.__awaiter(this,arguments,void 0,(function*(t=null){return j.get("/joblistings",!0,t)}))}getJobListingById(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return j.get(`/joblistings/${t}`,!0,e)}))}createJobListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return j.post("/joblistings",t,!0,e)}))}updateJobListing(e,n){return t.__awaiter(this,arguments,void 0,(function*(t,e,n=null){return j.put(`/joblistings/${t}`,e,!0,n)}))}deleteJobListing(e){return t.__awaiter(this,arguments,void 0,(function*(t,e=null){return j.delete(`/joblistings/${t}`,!0,e)}))}};exports.EventType=void 0,(U=exports.EventType||(exports.EventType={}))[U.Virtual=0]="Virtual",U[U.InPerson=1]="InPerson",U[U.Hybrid=2]="Hybrid",exports.CallToActionType=void 0,(E=exports.CallToActionType||(exports.CallToActionType={}))[E.Button=0]="Button",E[E.Link=1]="Link",E[E.Download=2]="Download",E[E.HireControlRegistration=3]="HireControlRegistration",exports.FormSubmissionStatus=void 0,(O=exports.FormSubmissionStatus||(exports.FormSubmissionStatus={}))[O.Submitted=1]="Submitted",O[O.Hold=2]="Hold",O[O.Rejected=3]="Rejected",O[O.Sent=4]="Sent";const W={login:o.login,nextLogin:o.nextLogin,refreshToken:o.refreshToken,changeCompany:o.changeCompany,register:o.register,isAuthenticated:o.isAuthenticated,getCompany:o.getCompany,getCompanies:o.getCompanies,getRoles:o.getRoles,getPermissions:o.getPermissions,logout:o.logout,getUser:o.getUser},M={getAll:a.getEvents,get:a.getEvent,getBySlug:a.getEventBySlug,create:a.createEvent,update:a.updateEvent,delete:a.deleteEvent},J={get:l.getAllRolesWithClaims,create:l.addRole,update:l.updateRole,delete:l.deleteRole},D=c,z=C,H={resetPassword:g.resetPassword,resetPasswordWithToken:g.resetPasswordWithToken,forgotPassword:g.forgotPassword},N={get:f.getMapConfig,update:f.updateMapConfig,create:f.createMapConfig},V={get:v.getClientAuthConfigById,getAll:v.getAllClientAuthConfigs,update:v.updateClientAuthConfig,create:v.createClientAuthConfig,delete:v.deleteClientAuthConfig},q={upload:S.uploadMedia,uploadProfileImage:S.uploadProfileImage,get:S.listMedia,delete:S.deleteMedia},G={getList:b.getFilters,get:b.getFilter,update:b.updateFilter,create:b.createFilter,delete:b.deleteFilter},K={get:$.getAppendListings,getAppendListing:$.getAppendListing,create:$.createAppendListing,update:$.updateAppendListing,delete:$.deleteAppendListing},X={get:w.getAllPermissions},Q={getAll:R.getCompanies,getById:R.getCompany,create:R.createCompany,update:R.updateCompany,delete:R.deleteCompany,sync:R.syncAllCompanies},Y={getAll:B.getJobListingsByCompany,getById:B.getJobListingById,create:B.createJobListing,update:B.updateJobListing,delete:B.deleteJobListing},Z=x,tt=F,et={auth:W,events:M,roles:J,users:D,account:H,mapConfig:N,permissions:X,clientAuthConfig:V,filters:G,listings:z,media:q,appendListings:K,forms:Z,formSubmissions:tt,companies:Q,jobListings:Y};exports.account=H,exports.appendListings=K,exports.auth=W,exports.clientAuthConfig=V,exports.companies=Q,exports.default=et,exports.events=M,exports.filters=G,exports.formSubmissions=tt,exports.forms=Z,exports.jobListings=Y,exports.listings=z,exports.mapConfig=N,exports.media=q,exports.permissions=X,exports.roles=J,exports.users=D;
2
2
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ import AppendListing from "./types/appendListing";
14
14
  import Form from "./types/form";
15
15
  import FormSubmission, { FormSubmissionStatus } from "./types/formSubmission";
16
16
  import ResultsWrapper from "./types/resultsWrapper";
17
+ import { JobListing } from "./types/JobListing";
17
18
  export declare const auth: {
18
19
  login: (clientLogInRequest: import("./types/clientLoginRequest").default) => Promise<any>;
19
20
  nextLogin: (credentials: import("./types/credentials").default) => Promise<any>;
@@ -96,6 +97,13 @@ export declare const companies: {
96
97
  delete: (id: string, authToken?: string | null) => Promise<void>;
97
98
  sync: (authToken?: string | null) => Promise<void>;
98
99
  };
100
+ export declare const jobListings: {
101
+ getAll: (authToken?: string | null) => Promise<JobListingDto[]>;
102
+ getById: (id: string, authToken?: string | null) => Promise<JobListingDto>;
103
+ create: (jobListing: JobListingDto, authToken?: string | null) => Promise<JobListingDto>;
104
+ update: (id: string, jobListing: JobListingDto, authToken?: string | null) => Promise<void>;
105
+ delete: (id: string, authToken?: string | null) => Promise<void>;
106
+ };
99
107
  export declare const forms: {
100
108
  getForms(authToken?: string | null): Promise<Form[]>;
101
109
  getForm(id: string, authToken?: string | null): Promise<Form>;
@@ -110,7 +118,7 @@ export declare const formSubmissions: {
110
118
  exportFormSubmissionsCsv(pageSize?: number, pageNumber?: number, type?: string | null, status?: FormSubmissionStatus | null, from?: Date | null, to?: Date | null, authToken?: string | null): Promise<void>;
111
119
  getFormSubmissionTypes(authToken?: string | null): Promise<string[]>;
112
120
  };
113
- export type { Register, User, Role, HireControlConfig, ClientAuthConfig, Event, Listing, EventDates, EventDateType, EventInstance, MediaType, Filters, AppendListing, Form, FormSubmission, ResultsWrapper, Company, };
121
+ export type { Register, User, Role, HireControlConfig, ClientAuthConfig, Event, Listing, EventDates, EventDateType, EventInstance, MediaType, Filters, AppendListing, Form, FormSubmission, ResultsWrapper, Company, JobListing, };
114
122
  export { EventType, CallToActionType, FormSubmissionStatus };
115
123
  declare const hcApi: {
116
124
  auth: {
@@ -209,5 +217,12 @@ declare const hcApi: {
209
217
  delete: (id: string, authToken?: string | null) => Promise<void>;
210
218
  sync: (authToken?: string | null) => Promise<void>;
211
219
  };
220
+ jobListings: {
221
+ getAll: (authToken?: string | null) => Promise<JobListingDto[]>;
222
+ getById: (id: string, authToken?: string | null) => Promise<JobListingDto>;
223
+ create: (jobListing: JobListingDto, authToken?: string | null) => Promise<JobListingDto>;
224
+ update: (id: string, jobListing: JobListingDto, authToken?: string | null) => Promise<void>;
225
+ delete: (id: string, authToken?: string | null) => Promise<void>;
226
+ };
212
227
  };
213
228
  export default hcApi;
@@ -0,0 +1,83 @@
1
+ export type JobListing = {
2
+ id: string;
3
+ companyId: string;
4
+ uniqueId: string | null;
5
+ dateCreated: string;
6
+ dateLastEdited: string;
7
+ slug: string | null;
8
+ fields: JobFields | null;
9
+ customFields: Array<CustomField>;
10
+ descriptions: Array<JobDescription>;
11
+ versionData: VersionData | null;
12
+ eoeStatement: string | null;
13
+ status: JobStatus;
14
+ };
15
+ type JobFields = {
16
+ position: string | null;
17
+ category: string | null;
18
+ categoryClass: string | null;
19
+ cityState: string | null;
20
+ city: string | null;
21
+ state: string | null;
22
+ shift: string | null;
23
+ schedule: string | null;
24
+ posted: string | null;
25
+ subTitle: string | null;
26
+ education: string | null;
27
+ entityId: number;
28
+ entityName: string | null;
29
+ bonus: boolean;
30
+ remote: boolean;
31
+ applyUrl: string | null;
32
+ applyOnline: boolean;
33
+ detailsUrl: string | null;
34
+ displayOnSite: boolean;
35
+ easyApply: boolean;
36
+ recruiterId: string | null;
37
+ displayRecruiter: boolean;
38
+ dateCreated: string;
39
+ dateLastEdited: string | null;
40
+ };
41
+ type CustomField = {
42
+ id: string | null;
43
+ name: string | null;
44
+ value: any | null;
45
+ };
46
+ type JobDescription = {
47
+ id: string | null;
48
+ name: string | null;
49
+ content: string | null;
50
+ versions: Array<JobDescriptionVersion>;
51
+ };
52
+ type JobDescriptionVersion = {
53
+ id: number;
54
+ timestamp: string;
55
+ source: string | null;
56
+ user: string | null;
57
+ content: string | null;
58
+ needsApproval: boolean;
59
+ };
60
+ type VersionData = {
61
+ fieldVersions: Record<string, Array<FieldVersion>>;
62
+ auditTrail: Array<AuditTrailEntry>;
63
+ };
64
+ type FieldVersion = {
65
+ value: any | null;
66
+ timestamp: string;
67
+ source: string | null;
68
+ user: string | null;
69
+ needsApproval: boolean;
70
+ };
71
+ type AuditTrailEntry = {
72
+ timestamp: string;
73
+ action: string | null;
74
+ user: string | null;
75
+ details: string | null;
76
+ source: string | null;
77
+ };
78
+ declare enum JobStatus {
79
+ UpdatedByFeed = 0,
80
+ PendingReview = 1,
81
+ EditedByHireControl = 2
82
+ }
83
+ export {};
package/index.ts CHANGED
@@ -16,6 +16,7 @@ import appendListingsController from "./controllers/appendListingsController";
16
16
  import formsController from "./controllers/formsController";
17
17
  import formSubmissionController from "./controllers/formSubmissionsController";
18
18
  import CompaniesController from "./controllers/companiesController";
19
+ import JobListingsController from "./controllers/jobListingsController";
19
20
 
20
21
  import Company from "./types/company";
21
22
  import Register from "./types/register";
@@ -37,6 +38,7 @@ import AppendListing from "./types/appendListing";
37
38
  import Form from "./types/form";
38
39
  import FormSubmission, { FormSubmissionStatus } from "./types/formSubmission";
39
40
  import ResultsWrapper from "./types/resultsWrapper";
41
+ import { JobListing } from "./types/JobListing";
40
42
 
41
43
  export const auth = {
42
44
  login: authController.login,
@@ -128,6 +130,14 @@ export const companies = {
128
130
  sync: CompaniesController.syncAllCompanies,
129
131
  };
130
132
 
133
+ export const jobListings = {
134
+ getAll: JobListingsController.getJobListingsByCompany,
135
+ getById: JobListingsController.getJobListingById,
136
+ create: JobListingsController.createJobListing,
137
+ update: JobListingsController.updateJobListing,
138
+ delete: JobListingsController.deleteJobListing,
139
+ };
140
+
131
141
  export const forms = formsController;
132
142
  export const formSubmissions = formSubmissionController;
133
143
  //types
@@ -149,6 +159,7 @@ export type {
149
159
  FormSubmission,
150
160
  ResultsWrapper,
151
161
  Company,
162
+ JobListing,
152
163
  };
153
164
 
154
165
  export { EventType, CallToActionType, FormSubmissionStatus };
@@ -169,6 +180,7 @@ const hcApi = {
169
180
  forms,
170
181
  formSubmissions,
171
182
  companies,
183
+ jobListings,
172
184
  };
173
185
 
174
186
  export default hcApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcagency/hire-control-sdk",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,90 @@
1
+ export type JobListing = {
2
+ id: string
3
+ companyId: string
4
+ uniqueId: string | null
5
+ dateCreated: string
6
+ dateLastEdited: string
7
+ slug: string | null
8
+ fields: JobFields | null
9
+ customFields: Array<CustomField>
10
+ descriptions: Array<JobDescription>
11
+ versionData: VersionData | null
12
+ eoeStatement: string | null
13
+ status: JobStatus
14
+ }
15
+
16
+ type JobFields = {
17
+ position: string | null
18
+ category: string | null
19
+ categoryClass: string | null
20
+ cityState: string | null
21
+ city: string | null
22
+ state: string | null
23
+ shift: string | null
24
+ schedule: string | null
25
+ posted: string | null
26
+ subTitle: string | null
27
+ education: string | null
28
+ entityId: number
29
+ entityName: string | null
30
+ bonus: boolean
31
+ remote: boolean
32
+ applyUrl: string | null
33
+ applyOnline: boolean
34
+ detailsUrl: string | null
35
+ displayOnSite: boolean
36
+ easyApply: boolean
37
+ recruiterId: string | null
38
+ displayRecruiter: boolean
39
+ dateCreated: string
40
+ dateLastEdited: string | null
41
+ }
42
+
43
+ type CustomField = {
44
+ id: string | null
45
+ name: string | null
46
+ value: any | null
47
+ }
48
+
49
+ type JobDescription = {
50
+ id: string | null
51
+ name: string | null
52
+ content: string | null
53
+ versions: Array<JobDescriptionVersion>
54
+ }
55
+
56
+ type JobDescriptionVersion = {
57
+ id: number
58
+ timestamp: string
59
+ source: string | null
60
+ user: string | null
61
+ content: string | null
62
+ needsApproval: boolean
63
+ }
64
+
65
+ type VersionData = {
66
+ fieldVersions: Record<string, Array<FieldVersion>>
67
+ auditTrail: Array<AuditTrailEntry>
68
+ }
69
+
70
+ type FieldVersion = {
71
+ value: any | null
72
+ timestamp: string
73
+ source: string | null
74
+ user: string | null
75
+ needsApproval: boolean
76
+ }
77
+
78
+ type AuditTrailEntry = {
79
+ timestamp: string
80
+ action: string | null
81
+ user: string | null
82
+ details: string | null
83
+ source: string | null
84
+ }
85
+
86
+ enum JobStatus {
87
+ UpdatedByFeed = 0,
88
+ PendingReview = 1,
89
+ EditedByHireControl = 2,
90
+ }