@hirely/sdk 1.0.1

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.
@@ -0,0 +1,151 @@
1
+ import type { HirelyConfig, HirelyPortfolio, HirelyMe, HirelyRequestOptions } from "./types.js";
2
+ import type { ProjectsResource } from "./resources/projects.js";
3
+ import type { WorkResource } from "./resources/work.js";
4
+ import type { EducationResource } from "./resources/education.js";
5
+ import type { SkillsResource } from "./resources/skills.js";
6
+ import type { CertificatesResource } from "./resources/certificates.js";
7
+ import type { ServicesResource } from "./resources/services.js";
8
+ import type { TestimonialsResource } from "./resources/testimonials.js";
9
+ import type { FaqsResource } from "./resources/faqs.js";
10
+ import type { ContactsResource } from "./resources/contacts.js";
11
+ import type { CvResource } from "./resources/cv.js";
12
+ /**
13
+ * The Hirely SDK client.
14
+ *
15
+ * Instantiate once with your public API key and use any method or
16
+ * resource to fetch your portfolio data from the Hirely API.
17
+ *
18
+ * @example Basic usage
19
+ * ```ts
20
+ * import Hirely from "@hirely/sdk";
21
+ *
22
+ * const hirely = new Hirely({
23
+ * apiKey: process.env.HIRELY_API_KEY!,
24
+ * });
25
+ *
26
+ * const portfolio = await hirely.get();
27
+ * const me = await hirely.me();
28
+ * const project = await hirely.projects.getBySlug("my-app");
29
+ * ```
30
+ *
31
+ * @example With caching and retries
32
+ * ```ts
33
+ * const hirely = new Hirely({
34
+ * apiKey: process.env.HIRELY_API_KEY!,
35
+ * timeout: 10_000,
36
+ * retries: 2,
37
+ * cache: { enabled: true, ttl: 300 },
38
+ * });
39
+ * ```
40
+ */
41
+ export default class Hirely {
42
+ /**
43
+ * Projects resource.
44
+ * - `hirely.projects()` — all public projects
45
+ * - `hirely.projects.getById(id)` — fetch by MongoDB ID
46
+ * - `hirely.projects.getBySlug(slug)` — fetch by URL slug
47
+ */
48
+ readonly projects: ProjectsResource;
49
+ /**
50
+ * Work experience resource.
51
+ * - `hirely.work()` — all work experience entries
52
+ * - `hirely.work.getById(id)` — fetch a single entry
53
+ */
54
+ readonly work: WorkResource;
55
+ /**
56
+ * Education resource.
57
+ * - `hirely.education()` — all education entries
58
+ * - `hirely.education.getById(id)` — fetch a single entry
59
+ */
60
+ readonly education: EducationResource;
61
+ /**
62
+ * Skills resource.
63
+ * - `hirely.skills()` — all skills
64
+ */
65
+ readonly skills: SkillsResource;
66
+ /**
67
+ * Certificates resource.
68
+ * - `hirely.certificates()` — all certificates
69
+ * - `hirely.certificates.getById(id)` — fetch a single certificate
70
+ */
71
+ readonly certificates: CertificatesResource;
72
+ /**
73
+ * Services resource.
74
+ * - `hirely.services()` — all public services
75
+ * - `hirely.services.getById(id)` — fetch a single service
76
+ */
77
+ readonly services: ServicesResource;
78
+ /**
79
+ * Testimonials resource (approved and public only).
80
+ * - `hirely.testimonials()` — all testimonials
81
+ * - `hirely.testimonials.getById(id)` — fetch a single testimonial
82
+ */
83
+ readonly testimonials: TestimonialsResource;
84
+ /**
85
+ * FAQ resource.
86
+ * - `hirely.faqs()` — all FAQ entries
87
+ * - `hirely.faqs.getById(id)` — fetch a single FAQ
88
+ */
89
+ readonly faqs: FaqsResource;
90
+ /**
91
+ * Contacts resource.
92
+ * - `hirely.contacts()` — public social links
93
+ */
94
+ readonly contacts: ContactsResource;
95
+ /**
96
+ * CV resource.
97
+ * - `hirely.cv()` — most recent public CV
98
+ */
99
+ readonly cv: CvResource;
100
+ constructor(config: HirelyConfig);
101
+ /**
102
+ * Fetches the complete public portfolio in a single request.
103
+ *
104
+ * Returns profile, projects, work, education, skills, certificates,
105
+ * services, testimonials, FAQs, contacts, and CV.
106
+ *
107
+ * @param options - Optional per-request options.
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * const portfolio = await hirely.get();
112
+ * console.log(portfolio.profile?.firstName);
113
+ * console.log(portfolio.projects.length);
114
+ * ```
115
+ *
116
+ * @example Next.js Server Component
117
+ * ```tsx
118
+ * export default async function Page() {
119
+ * const portfolio = await hirely.get();
120
+ * return (
121
+ * <main>
122
+ * <h1>{portfolio.profile?.firstName} {portfolio.profile?.lastName}</h1>
123
+ * {portfolio.projects.map((p) => (
124
+ * <article key={p._id}><h2>{p.title}</h2></article>
125
+ * ))}
126
+ * </main>
127
+ * );
128
+ * }
129
+ * ```
130
+ */
131
+ get(options?: HirelyRequestOptions): Promise<HirelyPortfolio>;
132
+ /**
133
+ * Fetches account information and the full public profile.
134
+ *
135
+ * Returns account-level data (username, email, role, plan) plus the
136
+ * complete profile (name, bio, avatar, location, birthday, etc.).
137
+ *
138
+ * @param options - Optional per-request options.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * const me = await hirely.me();
143
+ * console.log(me.userName); // "mahmoud"
144
+ * console.log(me.plan); // "pro"
145
+ * console.log(me.profile?.firstName); // "Mahmoud"
146
+ * console.log(me.profile?.positionName); // "Full-Stack Developer"
147
+ * console.log(me.profile?.avatar?.url); // "https://..."
148
+ * ```
149
+ */
150
+ me(options?: HirelyRequestOptions): Promise<HirelyMe>;
151
+ }
@@ -0,0 +1,8 @@
1
+ /** Default request timeout in milliseconds. */
2
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
3
+ /** Default number of retry attempts for transient errors. */
4
+ export declare const DEFAULT_RETRIES = 2;
5
+ /** HTTP status codes that trigger a retry. */
6
+ export declare const RETRYABLE_STATUS_CODES: Set<number>;
7
+ /** Maximum backoff delay between retries in milliseconds. */
8
+ export declare const MAX_BACKOFF_MS = 30000;
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Base class for all Hirely SDK errors.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { HirelyError } from "@hirely/sdk";
7
+ *
8
+ * try {
9
+ * await hirely.get();
10
+ * } catch (error) {
11
+ * if (error instanceof HirelyError) {
12
+ * console.error(error.status, error.message);
13
+ * }
14
+ * }
15
+ * ```
16
+ */
17
+ export declare class HirelyError extends Error {
18
+ /** HTTP status code (0 for network/timeout errors). */
19
+ readonly status: number;
20
+ /** Machine-readable error code. */
21
+ readonly code: string;
22
+ /** The request ID from the server, if available. */
23
+ readonly requestId?: string;
24
+ constructor(message: string, status: number, code?: string, requestId?: string);
25
+ }
26
+ /**
27
+ * Thrown when the API key is missing, invalid, or revoked (HTTP 401/403).
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { HirelyAuthenticationError } from "@hirely/sdk";
32
+ *
33
+ * try {
34
+ * await hirely.get();
35
+ * } catch (error) {
36
+ * if (error instanceof HirelyAuthenticationError) {
37
+ * console.error("Check your HIRELY_API_KEY.");
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ export declare class HirelyAuthenticationError extends HirelyError {
43
+ constructor(message?: string, status?: number, requestId?: string);
44
+ }
45
+ /**
46
+ * Thrown when a requested resource does not exist (HTTP 404).
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { HirelyNotFoundError } from "@hirely/sdk";
51
+ *
52
+ * try {
53
+ * const project = await hirely.projects.getBySlug("nonexistent");
54
+ * } catch (error) {
55
+ * if (error instanceof HirelyNotFoundError) {
56
+ * console.log("Project not found");
57
+ * }
58
+ * }
59
+ * ```
60
+ */
61
+ export declare class HirelyNotFoundError extends HirelyError {
62
+ constructor(message?: string, requestId?: string);
63
+ }
64
+ /**
65
+ * Thrown when a request fails validation (HTTP 400/422).
66
+ */
67
+ export declare class HirelyValidationError extends HirelyError {
68
+ constructor(message?: string, status?: number, requestId?: string);
69
+ }
70
+ /**
71
+ * Thrown when the API rate limit has been exceeded (HTTP 429).
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { HirelyRateLimitError } from "@hirely/sdk";
76
+ *
77
+ * try {
78
+ * await hirely.get();
79
+ * } catch (error) {
80
+ * if (error instanceof HirelyRateLimitError) {
81
+ * console.log(`Retry after ${error.retryAfter}s`);
82
+ * }
83
+ * }
84
+ * ```
85
+ */
86
+ export declare class HirelyRateLimitError extends HirelyError {
87
+ /** Seconds until the rate limit resets (from `Retry-After` header). */
88
+ readonly retryAfter?: number;
89
+ constructor(message?: string, retryAfter?: number, requestId?: string);
90
+ }
91
+ /**
92
+ * Thrown when a request exceeds the configured timeout.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const hirely = new Hirely({ apiKey, timeout: 5000 });
97
+ *
98
+ * try {
99
+ * await hirely.get();
100
+ * } catch (error) {
101
+ * if (error instanceof HirelyTimeoutError) {
102
+ * console.error("Request timed out after 5s");
103
+ * }
104
+ * }
105
+ * ```
106
+ */
107
+ export declare class HirelyTimeoutError extends HirelyError {
108
+ constructor(message?: string);
109
+ }
110
+ /**
111
+ * Thrown when the Hirely API returns a server-side error (HTTP 5xx).
112
+ */
113
+ export declare class HirelyServerError extends HirelyError {
114
+ constructor(message?: string, status?: number, requestId?: string);
115
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @hirely/sdk — Official JavaScript & TypeScript SDK for Hirely.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import Hirely from "@hirely/sdk";
7
+ *
8
+ * const hirely = new Hirely({ apiKey: process.env.HIRELY_API_KEY! });
9
+ *
10
+ * const portfolio = await hirely.get();
11
+ * const me = await hirely.me();
12
+ * const project = await hirely.projects.getBySlug("my-app");
13
+ * ```
14
+ *
15
+ * @module
16
+ */
17
+ export { default } from "./client.js";
18
+ export { default as Hirely } from "./client.js";
19
+ export { HirelyError, HirelyAuthenticationError, HirelyNotFoundError, HirelyValidationError, HirelyRateLimitError, HirelyTimeoutError, HirelyServerError, } from "./errors.js";
20
+ export type { HirelyConfig, HirelyCacheConfig, HirelyCache, HirelyRequestOptions, HirelyPortfolio, HirelyMe, HirelyProfile, HirelyProject, HirelyProjectMedia, HirelyWork, HirelyEducation, HirelySkill, HirelyCertificate, HirelyService, HirelyTestimonial, HirelyTestimonialClient, HirelyFaq, HirelyContact, HirелySocialLink, HirelyCV, } from "./types.js";
21
+ export type { ProjectsResource } from "./resources/projects.js";
22
+ export type { WorkResource } from "./resources/work.js";
23
+ export type { EducationResource } from "./resources/education.js";
24
+ export type { SkillsResource } from "./resources/skills.js";
25
+ export type { CertificatesResource } from "./resources/certificates.js";
26
+ export type { ServicesResource } from "./resources/services.js";
27
+ export type { TestimonialsResource } from "./resources/testimonials.js";
28
+ export type { FaqsResource } from "./resources/faqs.js";
29
+ export type { ContactsResource } from "./resources/contacts.js";
30
+ export type { CvResource } from "./resources/cv.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export{s as Hirely,c as HirelyAuthenticationError,l as HirelyError,y as HirelyNotFoundError,p as HirelyRateLimitError,a as HirelyServerError,H as HirelyTimeoutError,u as HirelyValidationError,o as default};
@@ -0,0 +1,25 @@
1
+ import type { HirelyCertificate, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching certificates and credentials.
4
+ *
5
+ * ```ts
6
+ * const certs = await hirely.certificates();
7
+ * const cert = await hirely.certificates.getById("665...");
8
+ * ```
9
+ */
10
+ export interface CertificatesResource {
11
+ /**
12
+ * Fetches all certificates, sorted by issue date descending.
13
+ *
14
+ * @param options - Optional per-request options.
15
+ */
16
+ (options?: HirelyRequestOptions): Promise<HirelyCertificate[]>;
17
+ /**
18
+ * Fetches a single certificate by its MongoDB ID.
19
+ *
20
+ * @param id - The certificate's `_id` string.
21
+ * @param options - Optional per-request options.
22
+ * @throws {HirelyNotFoundError} If no certificate with that ID exists.
23
+ */
24
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyCertificate>;
25
+ }
@@ -0,0 +1,15 @@
1
+ import type { HirelyContact, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching public contact information (social links).
4
+ *
5
+ * @returns The contact entry, or `null` if none has been set up.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const contact = await hirely.contacts();
10
+ * contact?.socialLinks?.forEach(link => {
11
+ * console.log(link.platform, link.url);
12
+ * });
13
+ * ```
14
+ */
15
+ export type ContactsResource = (options?: HirelyRequestOptions) => Promise<HirelyContact | null>;
@@ -0,0 +1,15 @@
1
+ import type { HirelyCV, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching the most recent public CV (résumé).
4
+ *
5
+ * @returns The CV with download URLs, or `null` if no public CV exists.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const cv = await hirely.cv();
10
+ * if (cv?.pdfUrl) {
11
+ * console.log("Download PDF:", cv.pdfUrl);
12
+ * }
13
+ * ```
14
+ */
15
+ export type CvResource = (options?: HirelyRequestOptions) => Promise<HirelyCV | null>;
@@ -0,0 +1,25 @@
1
+ import type { HirelyEducation, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching education history.
4
+ *
5
+ * ```ts
6
+ * const education = await hirely.education();
7
+ * const entry = await hirely.education.getById("665...");
8
+ * ```
9
+ */
10
+ export interface EducationResource {
11
+ /**
12
+ * Fetches all education entries, sorted by start date descending.
13
+ *
14
+ * @param options - Optional per-request options.
15
+ */
16
+ (options?: HirelyRequestOptions): Promise<HirelyEducation[]>;
17
+ /**
18
+ * Fetches a single education entry by its MongoDB ID.
19
+ *
20
+ * @param id - The education entry's `_id` string.
21
+ * @param options - Optional per-request options.
22
+ * @throws {HirelyNotFoundError} If no entry with that ID exists.
23
+ */
24
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyEducation>;
25
+ }
@@ -0,0 +1,25 @@
1
+ import type { HirelyFaq, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching FAQ entries.
4
+ *
5
+ * ```ts
6
+ * const faqs = await hirely.faqs();
7
+ * const faq = await hirely.faqs.getById("665...");
8
+ * ```
9
+ */
10
+ export interface FaqsResource {
11
+ /**
12
+ * Fetches all FAQ entries, sorted by creation date descending.
13
+ *
14
+ * @param options - Optional per-request options.
15
+ */
16
+ (options?: HirelyRequestOptions): Promise<HirelyFaq[]>;
17
+ /**
18
+ * Fetches a single FAQ entry by its MongoDB ID.
19
+ *
20
+ * @param id - The FAQ entry's `_id` string.
21
+ * @param options - Optional per-request options.
22
+ * @throws {HirelyNotFoundError} If no FAQ with that ID exists.
23
+ */
24
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyFaq>;
25
+ }
@@ -0,0 +1,51 @@
1
+ import type { HirelyProject, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching projects.
4
+ *
5
+ * ```ts
6
+ * const projects = await hirely.projects();
7
+ * const project = await hirely.projects.getById("665...");
8
+ * const project = await hirely.projects.getBySlug("my-app");
9
+ * ```
10
+ */
11
+ export interface ProjectsResource {
12
+ /**
13
+ * Fetches all public projects, sorted by featured then by creation date.
14
+ *
15
+ * @param options - Optional per-request options.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const projects = await hirely.projects();
20
+ * console.log(projects[0].title);
21
+ * ```
22
+ */
23
+ (options?: HirelyRequestOptions): Promise<HirelyProject[]>;
24
+ /**
25
+ * Fetches a single project by its MongoDB ID.
26
+ *
27
+ * @param id - The project's `_id` string.
28
+ * @param options - Optional per-request options.
29
+ * @throws {HirelyNotFoundError} If no project with that ID exists.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const project = await hirely.projects.getById("665f1a2b3c4d5e6f7a8b9c0d");
34
+ * ```
35
+ */
36
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyProject>;
37
+ /**
38
+ * Fetches a single project by its URL slug.
39
+ *
40
+ * @param slug - The project's slug (e.g. `"my-awesome-app"`).
41
+ * @param options - Optional per-request options.
42
+ * @throws {HirelyNotFoundError} If no project with that slug exists.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const project = await hirely.projects.getBySlug("my-awesome-app");
47
+ * console.log(project.technologies);
48
+ * ```
49
+ */
50
+ getBySlug(slug: string, options?: HirelyRequestOptions): Promise<HirelyProject>;
51
+ }
@@ -0,0 +1,25 @@
1
+ import type { HirelyService, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching services offered by the portfolio owner.
4
+ *
5
+ * ```ts
6
+ * const services = await hirely.services();
7
+ * const service = await hirely.services.getById("665...");
8
+ * ```
9
+ */
10
+ export interface ServicesResource {
11
+ /**
12
+ * Fetches all public services, sorted by creation date descending.
13
+ *
14
+ * @param options - Optional per-request options.
15
+ */
16
+ (options?: HirelyRequestOptions): Promise<HirelyService[]>;
17
+ /**
18
+ * Fetches a single service by its MongoDB ID.
19
+ *
20
+ * @param id - The service's `_id` string.
21
+ * @param options - Optional per-request options.
22
+ * @throws {HirelyNotFoundError} If no service with that ID exists.
23
+ */
24
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyService>;
25
+ }
@@ -0,0 +1,22 @@
1
+ import type { HirelySkill, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching skills.
4
+ *
5
+ * ```ts
6
+ * const skills = await hirely.skills();
7
+ * ```
8
+ */
9
+ export interface SkillsResource {
10
+ /**
11
+ * Fetches all skills, sorted by creation date descending.
12
+ *
13
+ * @param options - Optional per-request options.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const skills = await hirely.skills();
18
+ * const frontend = skills.filter(s => s.category === "Frontend");
19
+ * ```
20
+ */
21
+ (options?: HirelyRequestOptions): Promise<HirelySkill[]>;
22
+ }
@@ -0,0 +1,26 @@
1
+ import type { HirelyTestimonial, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching client testimonials.
4
+ * Only approved, public testimonials are returned.
5
+ *
6
+ * ```ts
7
+ * const testimonials = await hirely.testimonials();
8
+ * const testimonial = await hirely.testimonials.getById("665...");
9
+ * ```
10
+ */
11
+ export interface TestimonialsResource {
12
+ /**
13
+ * Fetches all approved public testimonials, sorted by creation date descending.
14
+ *
15
+ * @param options - Optional per-request options.
16
+ */
17
+ (options?: HirelyRequestOptions): Promise<HirelyTestimonial[]>;
18
+ /**
19
+ * Fetches a single testimonial by its MongoDB ID.
20
+ *
21
+ * @param id - The testimonial's `_id` string.
22
+ * @param options - Optional per-request options.
23
+ * @throws {HirelyNotFoundError} If no testimonial with that ID exists.
24
+ */
25
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyTestimonial>;
26
+ }
@@ -0,0 +1,31 @@
1
+ import type { HirelyWork, HirelyRequestOptions } from "../types.js";
2
+ /**
3
+ * A callable resource for fetching work experience.
4
+ *
5
+ * ```ts
6
+ * const work = await hirely.work();
7
+ * const job = await hirely.work.getById("665...");
8
+ * ```
9
+ */
10
+ export interface WorkResource {
11
+ /**
12
+ * Fetches all work experience entries, sorted by start date descending.
13
+ *
14
+ * @param options - Optional per-request options.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const jobs = await hirely.work();
19
+ * jobs.forEach(j => console.log(j.companyName, j.position));
20
+ * ```
21
+ */
22
+ (options?: HirelyRequestOptions): Promise<HirelyWork[]>;
23
+ /**
24
+ * Fetches a single work experience entry by its MongoDB ID.
25
+ *
26
+ * @param id - The work entry's `_id` string.
27
+ * @param options - Optional per-request options.
28
+ * @throws {HirelyNotFoundError} If no entry with that ID exists.
29
+ */
30
+ getById(id: string, options?: HirelyRequestOptions): Promise<HirelyWork>;
31
+ }