@abcagency/hire-control-sdk 1.1.1 → 1.1.3

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.
Files changed (36) hide show
  1. package/.gitattributes +1 -0
  2. package/constants/cms.ts +60 -0
  3. package/controllers/categoryListsController.ts +29 -4
  4. package/controllers/content/blocksController.ts +62 -4
  5. package/controllers/content/contentEntriesController.ts +31 -4
  6. package/controllers/jobListingsController.ts +36 -0
  7. package/dist/constants/cms.d.ts +53 -0
  8. package/dist/controllers/categoryListsController.d.ts +12 -3
  9. package/dist/controllers/content/blocksController.d.ts +10 -0
  10. package/dist/controllers/content/contentEntriesController.d.ts +9 -0
  11. package/dist/controllers/jobListingsController.d.ts +12 -0
  12. package/dist/handlers/normalize-casing.d.ts +1 -0
  13. package/dist/index.cjs.js +1 -1
  14. package/dist/index.d.ts +38 -4
  15. package/dist/types/JobListing.d.ts +1 -0
  16. package/dist/types/categoryList.d.ts +7 -2
  17. package/dist/types/content/blockUpdateImpact.d.ts +22 -0
  18. package/dist/types/content/model.d.ts +32 -0
  19. package/dist/types/hireControlConfig.d.ts +14 -0
  20. package/dist/types/listing.d.ts +3 -0
  21. package/dist/types/listingEntity.d.ts +3 -0
  22. package/dist/types/listingEntityMedia.d.ts +12 -0
  23. package/dist/types/mongoListingEntity.d.ts +3 -0
  24. package/handlers/fetchHandler.ts +27 -4
  25. package/handlers/normalize-casing.ts +36 -0
  26. package/index.ts +35 -2
  27. package/package.json +2 -1
  28. package/types/JobListing.ts +1 -0
  29. package/types/categoryList.ts +8 -2
  30. package/types/content/blockUpdateImpact.ts +24 -0
  31. package/types/content/model.ts +35 -0
  32. package/types/hireControlConfig.ts +16 -0
  33. package/types/listing.ts +4 -0
  34. package/types/listingEntity.ts +3 -0
  35. package/types/listingEntityMedia.ts +14 -0
  36. package/types/mongoListingEntity.ts +3 -0
package/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ * text=auto eol=lf
@@ -0,0 +1,60 @@
1
+ export const BLOCK_KEYS = {
2
+ HERO: "hero",
3
+ VIDEO_BLOCK: "videoBlock",
4
+ CONTENT_CARD: "contentCard",
5
+ ICON_CARD: "iconCard",
6
+ LIST: "list",
7
+ CONTAINER: "container",
8
+ ACCORDION: "accordion",
9
+ TESTIMONIAL: "testimonial",
10
+ LARGE_TITLE_BLOCK: "largeTitleBlock",
11
+ BUTTON: "button",
12
+ RECRUITER: "recruiter",
13
+ BLOBS: "blobs",
14
+ TITLE_MODULAR_CONTENT_COPY: "titleModularContentCopy",
15
+ INTRO_WITH_CONTENT_CARD: "introWithContentCard",
16
+ CALLOUT_CARD: "calloutCard",
17
+ } as const;
18
+
19
+ export const BLOCK_KEY_ALIASES: Record<string, string> = {
20
+ "testimonial-block": BLOCK_KEYS.TESTIMONIAL,
21
+ "button-block": BLOCK_KEYS.BUTTON,
22
+ "recruiter-block": BLOCK_KEYS.RECRUITER,
23
+ };
24
+
25
+ export const FIELD_TYPES = {
26
+ SINGLE_LINE_STRING: "SingleLineString",
27
+ MULTI_LINE_TEXT: "MultiLineText",
28
+ MULTIPLE_PARAGRAPH_TEXT: "MultipleParagraphText",
29
+ SLUG: "Slug",
30
+ STRUCTURED_TEXT: "StructuredText",
31
+ RICH_TEXT: "RichText",
32
+ INTEGER_NUMBER: "IntegerNumber",
33
+ FLOATING_POINT_NUMBER: "FloatingPointNumber",
34
+ BOOLEAN: "Boolean",
35
+ DATE: "Date",
36
+ DATE_TIME: "DateTime",
37
+ SINGLE_MEDIA: "SingleMedia",
38
+ MEDIA_GALLERY: "MediaGallery",
39
+ EXTERNAL_VIDEO: "ExternalVideo",
40
+ COLOR: "Color",
41
+ TAILWIND_COLOR_SELECTOR: "TailwindColorSelector",
42
+ SINGLE_LINK: "SingleLink",
43
+ MULTIPLE_LINKS: "MultipleLinks",
44
+ LOCATION: "Location",
45
+ JSON: "Json",
46
+ SEO: "Seo",
47
+ MODULAR_CONTENT: "ModularContent",
48
+ SINGLE_BLOCK: "SingleBlock",
49
+ JOB_FILTER: "JobFilter",
50
+ FORM: "Form",
51
+ SINGLE_CONTENT_REFERENCE: "SingleContentReference",
52
+ MULTIPLE_CONTENT_REFERENCE: "MultipleContentReference",
53
+ HIRE_CONTROL_MAP: "HireControlMap",
54
+ RECRUITER_SELECTOR: "RecruiterSelector",
55
+ TAGS: "Tags",
56
+ VARIANT_SELECTOR: "VariantSelector",
57
+ } as const;
58
+
59
+ export type BlockKey = (typeof BLOCK_KEYS)[keyof typeof BLOCK_KEYS];
60
+ export type FieldType = (typeof FIELD_TYPES)[keyof typeof FIELD_TYPES];
@@ -1,6 +1,9 @@
1
1
  import FetchHandler from "../handlers/fetchHandler";
2
2
  import { API_URL } from "../constants/config";
3
- import CategoryListDto, { AddValueRequest } from "../types/categoryList";
3
+ import CategoryListDto, {
4
+ AddValueRequest,
5
+ CategoryListValueDto,
6
+ } from "../types/categoryList";
4
7
 
5
8
  const fetchHandler = new FetchHandler(API_URL);
6
9
 
@@ -181,22 +184,44 @@ class CategoryListsController {
181
184
  /**
182
185
  * Update values in a category list.
183
186
  * @param {string} id - The category list ID.
184
- * @param {Record<string, string>} values - The values to update.
187
+ * @param {Record<string, CategoryListDto["values"][string]>} values - The values to update.
185
188
  * @param {string | null} authToken - Optional auth token.
186
189
  * @returns {Promise<CategoryListDto>} - The updated category list data.
187
190
  */
188
191
  async updateValues(
189
192
  id: string,
190
- values: Record<string, string>,
193
+ values: Record<string, CategoryListDto["values"][string]>,
191
194
  authToken: string | null = null
192
195
  ): Promise<CategoryListDto> {
193
- return fetchHandler.put<Record<string, string>, CategoryListDto>(
196
+ return fetchHandler.put<Record<string, CategoryListDto["values"][string]>, CategoryListDto>(
194
197
  `/categorylist/${id}/values`,
195
198
  values,
196
199
  true,
197
200
  authToken
198
201
  );
199
202
  }
203
+
204
+ /**
205
+ * Update a single value in a category list.
206
+ * @param {string} id - The category list ID.
207
+ * @param {string} key - The value key to update.
208
+ * @param {CategoryListValueDto} value - The value payload.
209
+ * @param {string | null} authToken - Optional auth token.
210
+ * @returns {Promise<CategoryListDto>} - The updated category list data.
211
+ */
212
+ async updateValue(
213
+ id: string,
214
+ key: string,
215
+ value: CategoryListValueDto,
216
+ authToken: string | null = null
217
+ ): Promise<CategoryListDto> {
218
+ return fetchHandler.put<CategoryListValueDto, CategoryListDto>(
219
+ `/categorylist/${id}/values/${encodeURIComponent(key)}`,
220
+ value,
221
+ true,
222
+ authToken
223
+ );
224
+ }
200
225
  }
201
226
 
202
227
  export default new CategoryListsController();
@@ -1,5 +1,10 @@
1
1
  import FetchHandler from "../../handlers/fetchHandler";
2
+ import { normalizeToCamelCase } from "../../handlers/normalize-casing";
2
3
  import Block from "../../types/content/block";
4
+ import {
5
+ BlockUpdateImpact,
6
+ BlockFieldMigration,
7
+ } from "../../types/content/blockUpdateImpact";
3
8
  import { API_URL } from "../../constants/config";
4
9
 
5
10
  const fetchHandler = new FetchHandler(API_URL);
@@ -11,7 +16,8 @@ class BlocksController {
11
16
  * @returns {Promise<Block[]>} - A list of blocks.
12
17
  */
13
18
  async getBlocks(authToken: string | null = null): Promise<Block[]> {
14
- return fetchHandler.get<Block[]>("/block", true, authToken);
19
+ const response = await fetchHandler.get<Block[]>("/block", true, authToken);
20
+ return normalizeToCamelCase(response);
15
21
  }
16
22
 
17
23
  /**
@@ -21,7 +27,8 @@ class BlocksController {
21
27
  * @returns {Promise<Block>} - The block data.
22
28
  */
23
29
  async getBlock(id: string, authToken: string | null = null): Promise<Block> {
24
- return fetchHandler.get<Block>(`/block/${id}`, true, authToken);
30
+ const response = await fetchHandler.get<Block>(`/block/${id}`, true, authToken);
31
+ return normalizeToCamelCase(response);
25
32
  }
26
33
 
27
34
  /**
@@ -34,7 +41,13 @@ class BlocksController {
34
41
  block: Block,
35
42
  authToken: string | null = null
36
43
  ): Promise<Block> {
37
- return fetchHandler.post<Block, Block>("/block", block, true, authToken);
44
+ const response = await fetchHandler.post<Block, Block>(
45
+ "/block",
46
+ block,
47
+ true,
48
+ authToken
49
+ );
50
+ return normalizeToCamelCase(response);
38
51
  }
39
52
 
40
53
  /**
@@ -57,6 +70,46 @@ class BlocksController {
57
70
  );
58
71
  }
59
72
 
73
+ /**
74
+ * Update an existing block and apply optional field migrations.
75
+ * Backward compatible with the legacy PUT body.
76
+ */
77
+ async updateBlockWithMigrations(
78
+ id: string,
79
+ block: Block,
80
+ fieldMigrations: BlockFieldMigration[] = [],
81
+ authToken: string | null = null
82
+ ): Promise<void> {
83
+ const payload =
84
+ fieldMigrations.length > 0
85
+ ? { block, fieldMigrations }
86
+ : block;
87
+
88
+ return fetchHandler.put<typeof payload, void>(
89
+ `/block/${id}`,
90
+ payload,
91
+ true,
92
+ authToken
93
+ );
94
+ }
95
+
96
+ /**
97
+ * Preview the impact of updating a block definition before saving it.
98
+ */
99
+ async previewBlockUpdate(
100
+ id: string,
101
+ block: Block,
102
+ authToken: string | null = null
103
+ ): Promise<BlockUpdateImpact> {
104
+ const response = await fetchHandler.post<Block, BlockUpdateImpact>(
105
+ `/block/${id}/preview-update`,
106
+ block,
107
+ true,
108
+ authToken
109
+ );
110
+ return normalizeToCamelCase(response);
111
+ }
112
+
60
113
  /**
61
114
  * Delete an existing block.
62
115
  * @param {string} id - The block ID to delete.
@@ -76,7 +129,12 @@ class BlocksController {
76
129
  * @returns {Promise<Block[]>} - A list of template blocks.
77
130
  */
78
131
  async getTemplateBlocks(authToken: string | null = null): Promise<Block[]> {
79
- return fetchHandler.get<Block[]>("/block/template-blocks", true, authToken);
132
+ const response = await fetchHandler.get<Block[]>(
133
+ "/block/template-blocks",
134
+ true,
135
+ authToken
136
+ );
137
+ return normalizeToCamelCase(response);
80
138
  }
81
139
  }
82
140
 
@@ -1,4 +1,5 @@
1
1
  import FetchHandler from "../../handlers/fetchHandler";
2
+ import { normalizeToCamelCase } from "../../handlers/normalize-casing";
2
3
  import ContentEntry from "../../types/content/contentEntry";
3
4
  import Status from "../../types/content/status";
4
5
  import { API_URL } from "../../constants/config";
@@ -22,7 +23,8 @@ class ContentEntriesController {
22
23
  if (statusFilter !== null) {
23
24
  url += `&statusFilter=${statusFilter}`;
24
25
  }
25
- return fetchHandler.get<ContentEntry[]>(url, true, authToken);
26
+ const response = await fetchHandler.get<ContentEntry[]>(url, true, authToken);
27
+ return normalizeToCamelCase(response);
26
28
  }
27
29
 
28
30
  /**
@@ -41,7 +43,30 @@ class ContentEntriesController {
41
43
  if (statusFilter !== null) {
42
44
  url += `?statusFilter=${statusFilter}`;
43
45
  }
44
- return fetchHandler.get<ContentEntry>(url, true, authToken);
46
+ const response = await fetchHandler.get<ContentEntry>(url, true, authToken);
47
+ return normalizeToCamelCase(response);
48
+ }
49
+
50
+ /**
51
+ * Get a specific content entry by content model ID + slug.
52
+ * @param {string} contentId - The content model ID.
53
+ * @param {string} slug - The entry slug.
54
+ * @param {Status | null} statusFilter - Optional status filter.
55
+ * @param {string | null} authToken - Optional auth token.
56
+ * @returns {Promise<ContentEntry>} - The content entry data.
57
+ */
58
+ async getContentEntryBySlug(
59
+ contentId: string,
60
+ slug: string,
61
+ statusFilter: Status | null = null,
62
+ authToken: string | null = null,
63
+ ): Promise<ContentEntry> {
64
+ let url = `/contententry/by-slug?contentId=${encodeURIComponent(contentId)}&slug=${encodeURIComponent(slug)}`;
65
+ if (statusFilter !== null) {
66
+ url += `&statusFilter=${statusFilter}`;
67
+ }
68
+ const response = await fetchHandler.get<ContentEntry>(url, true, authToken);
69
+ return normalizeToCamelCase(response);
45
70
  }
46
71
 
47
72
  /**
@@ -54,12 +79,13 @@ class ContentEntriesController {
54
79
  entry: ContentEntry,
55
80
  authToken: string | null = null,
56
81
  ): Promise<ContentEntry> {
57
- return fetchHandler.post<ContentEntry, ContentEntry>(
82
+ const response = await fetchHandler.post<ContentEntry, ContentEntry>(
58
83
  "/contententry",
59
84
  entry,
60
85
  true,
61
86
  authToken,
62
87
  );
88
+ return normalizeToCamelCase(response);
63
89
  }
64
90
 
65
91
  /**
@@ -105,11 +131,12 @@ class ContentEntriesController {
105
131
  id: string,
106
132
  authToken: string | null = null,
107
133
  ): Promise<ContentEntry[]> {
108
- return fetchHandler.get<ContentEntry[]>(
134
+ const response = await fetchHandler.get<ContentEntry[]>(
109
135
  `/contententry/${id}/versions`,
110
136
  true,
111
137
  authToken,
112
138
  );
139
+ return normalizeToCamelCase(response);
113
140
  }
114
141
 
115
142
  /**
@@ -8,6 +8,42 @@ const fetchHandler = new FetchHandler(API_URL);
8
8
  * Controller for handling job listing API requests.
9
9
  */
10
10
  class JobListingsController {
11
+ async updateFieldVersionApproval(
12
+ id: string,
13
+ payload: {
14
+ fieldPath: string;
15
+ timestamp?: string;
16
+ listingVersionNumber?: number;
17
+ needsApproval: boolean;
18
+ },
19
+ authToken: string | null = null
20
+ ): Promise<void> {
21
+ return fetchHandler.patch<typeof payload, void>(
22
+ `/joblistings/${id}/field-version-approval`,
23
+ payload,
24
+ true,
25
+ authToken
26
+ );
27
+ }
28
+
29
+ async updateDescriptionVersionApproval(
30
+ id: string,
31
+ payload: {
32
+ descriptionId: string;
33
+ versionId?: number;
34
+ listingVersionNumber?: number;
35
+ needsApproval: boolean;
36
+ },
37
+ authToken: string | null = null
38
+ ): Promise<void> {
39
+ return fetchHandler.patch<typeof payload, void>(
40
+ `/joblistings/${id}/description-version-approval`,
41
+ payload,
42
+ true,
43
+ authToken
44
+ );
45
+ }
46
+
11
47
  /**
12
48
  * [GET /joblistings]
13
49
  * Get all job listings for the authenticated user's company.
@@ -0,0 +1,53 @@
1
+ export declare const BLOCK_KEYS: {
2
+ readonly HERO: "hero";
3
+ readonly VIDEO_BLOCK: "videoBlock";
4
+ readonly CONTENT_CARD: "contentCard";
5
+ readonly ICON_CARD: "iconCard";
6
+ readonly LIST: "list";
7
+ readonly CONTAINER: "container";
8
+ readonly ACCORDION: "accordion";
9
+ readonly TESTIMONIAL: "testimonial";
10
+ readonly LARGE_TITLE_BLOCK: "largeTitleBlock";
11
+ readonly BUTTON: "button";
12
+ readonly RECRUITER: "recruiter";
13
+ readonly BLOBS: "blobs";
14
+ readonly TITLE_MODULAR_CONTENT_COPY: "titleModularContentCopy";
15
+ readonly INTRO_WITH_CONTENT_CARD: "introWithContentCard";
16
+ readonly CALLOUT_CARD: "calloutCard";
17
+ };
18
+ export declare const BLOCK_KEY_ALIASES: Record<string, string>;
19
+ export declare const FIELD_TYPES: {
20
+ readonly SINGLE_LINE_STRING: "SingleLineString";
21
+ readonly MULTI_LINE_TEXT: "MultiLineText";
22
+ readonly MULTIPLE_PARAGRAPH_TEXT: "MultipleParagraphText";
23
+ readonly SLUG: "Slug";
24
+ readonly STRUCTURED_TEXT: "StructuredText";
25
+ readonly RICH_TEXT: "RichText";
26
+ readonly INTEGER_NUMBER: "IntegerNumber";
27
+ readonly FLOATING_POINT_NUMBER: "FloatingPointNumber";
28
+ readonly BOOLEAN: "Boolean";
29
+ readonly DATE: "Date";
30
+ readonly DATE_TIME: "DateTime";
31
+ readonly SINGLE_MEDIA: "SingleMedia";
32
+ readonly MEDIA_GALLERY: "MediaGallery";
33
+ readonly EXTERNAL_VIDEO: "ExternalVideo";
34
+ readonly COLOR: "Color";
35
+ readonly TAILWIND_COLOR_SELECTOR: "TailwindColorSelector";
36
+ readonly SINGLE_LINK: "SingleLink";
37
+ readonly MULTIPLE_LINKS: "MultipleLinks";
38
+ readonly LOCATION: "Location";
39
+ readonly JSON: "Json";
40
+ readonly SEO: "Seo";
41
+ readonly MODULAR_CONTENT: "ModularContent";
42
+ readonly SINGLE_BLOCK: "SingleBlock";
43
+ readonly JOB_FILTER: "JobFilter";
44
+ readonly FORM: "Form";
45
+ readonly SINGLE_CONTENT_REFERENCE: "SingleContentReference";
46
+ readonly MULTIPLE_CONTENT_REFERENCE: "MultipleContentReference";
47
+ readonly HIRE_CONTROL_MAP: "HireControlMap";
48
+ readonly RECRUITER_SELECTOR: "RecruiterSelector";
49
+ readonly TAGS: "Tags";
50
+ readonly VARIANT_SELECTOR: "VariantSelector";
51
+ };
52
+ export type BlockKey = (typeof BLOCK_KEYS)[keyof typeof BLOCK_KEYS];
53
+ export type FieldType = (typeof FIELD_TYPES)[keyof typeof FIELD_TYPES];
@@ -1,4 +1,4 @@
1
- import CategoryListDto, { AddValueRequest } from "../types/categoryList";
1
+ import CategoryListDto, { AddValueRequest, CategoryListValueDto } from "../types/categoryList";
2
2
  declare class CategoryListsController {
3
3
  /**
4
4
  * Get all category lists for the authenticated user's company.
@@ -75,11 +75,20 @@ declare class CategoryListsController {
75
75
  /**
76
76
  * Update values in a category list.
77
77
  * @param {string} id - The category list ID.
78
- * @param {Record<string, string>} values - The values to update.
78
+ * @param {Record<string, CategoryListDto["values"][string]>} values - The values to update.
79
79
  * @param {string | null} authToken - Optional auth token.
80
80
  * @returns {Promise<CategoryListDto>} - The updated category list data.
81
81
  */
82
- updateValues(id: string, values: Record<string, string>, authToken?: string | null): Promise<CategoryListDto>;
82
+ updateValues(id: string, values: Record<string, CategoryListDto["values"][string]>, authToken?: string | null): Promise<CategoryListDto>;
83
+ /**
84
+ * Update a single value in a category list.
85
+ * @param {string} id - The category list ID.
86
+ * @param {string} key - The value key to update.
87
+ * @param {CategoryListValueDto} value - The value payload.
88
+ * @param {string | null} authToken - Optional auth token.
89
+ * @returns {Promise<CategoryListDto>} - The updated category list data.
90
+ */
91
+ updateValue(id: string, key: string, value: CategoryListValueDto, authToken?: string | null): Promise<CategoryListDto>;
83
92
  }
84
93
  declare const _default: CategoryListsController;
85
94
  export default _default;
@@ -1,4 +1,5 @@
1
1
  import Block from "../../types/content/block";
2
+ import { BlockUpdateImpact, BlockFieldMigration } from "../../types/content/blockUpdateImpact";
2
3
  declare class BlocksController {
3
4
  /**
4
5
  * Get all blocks for the current company.
@@ -28,6 +29,15 @@ declare class BlocksController {
28
29
  * @returns {Promise<void>} - No return value.
29
30
  */
30
31
  updateBlock(id: string, block: Block, authToken?: string | null): Promise<void>;
32
+ /**
33
+ * Update an existing block and apply optional field migrations.
34
+ * Backward compatible with the legacy PUT body.
35
+ */
36
+ updateBlockWithMigrations(id: string, block: Block, fieldMigrations?: BlockFieldMigration[], authToken?: string | null): Promise<void>;
37
+ /**
38
+ * Preview the impact of updating a block definition before saving it.
39
+ */
40
+ previewBlockUpdate(id: string, block: Block, authToken?: string | null): Promise<BlockUpdateImpact>;
31
41
  /**
32
42
  * Delete an existing block.
33
43
  * @param {string} id - The block ID to delete.
@@ -17,6 +17,15 @@ declare class ContentEntriesController {
17
17
  * @returns {Promise<ContentEntry>} - The content entry data.
18
18
  */
19
19
  getContentEntry(id: string, statusFilter?: Status | null, authToken?: string | null): Promise<ContentEntry>;
20
+ /**
21
+ * Get a specific content entry by content model ID + slug.
22
+ * @param {string} contentId - The content model ID.
23
+ * @param {string} slug - The entry slug.
24
+ * @param {Status | null} statusFilter - Optional status filter.
25
+ * @param {string | null} authToken - Optional auth token.
26
+ * @returns {Promise<ContentEntry>} - The content entry data.
27
+ */
28
+ getContentEntryBySlug(contentId: string, slug: string, statusFilter?: Status | null, authToken?: string | null): Promise<ContentEntry>;
20
29
  /**
21
30
  * Create a new content entry.
22
31
  * @param {ContentEntry} entry - The content entry data to create.
@@ -3,6 +3,18 @@ import { type JobListing } from "../types/JobListing";
3
3
  * Controller for handling job listing API requests.
4
4
  */
5
5
  declare class JobListingsController {
6
+ updateFieldVersionApproval(id: string, payload: {
7
+ fieldPath: string;
8
+ timestamp?: string;
9
+ listingVersionNumber?: number;
10
+ needsApproval: boolean;
11
+ }, authToken?: string | null): Promise<void>;
12
+ updateDescriptionVersionApproval(id: string, payload: {
13
+ descriptionId: string;
14
+ versionId?: number;
15
+ listingVersionNumber?: number;
16
+ needsApproval: boolean;
17
+ }, authToken?: string | null): Promise<void>;
6
18
  /**
7
19
  * [GET /joblistings]
8
20
  * Get all job listings for the authenticated user's company.
@@ -0,0 +1 @@
1
+ export declare const normalizeToCamelCase: <T>(value: T) => T;