@prodigio-io/sdk 1.0.0

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,94 @@
1
+ interface ProdigioConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ interface SalaryRange {
6
+ min: number;
7
+ max: number;
8
+ currency: string;
9
+ period: 'monthly' | 'yearly';
10
+ }
11
+ interface PoweredBy {
12
+ text: string;
13
+ url: string;
14
+ }
15
+ interface Job {
16
+ id: string;
17
+ title: string;
18
+ companyName: string;
19
+ department: string;
20
+ location: string;
21
+ type: 'full-time' | 'part-time' | 'contract';
22
+ status: 'active' | 'closed' | 'archived' | 'draft';
23
+ description: string;
24
+ requirements: string;
25
+ eligibilityCriteria?: string;
26
+ salaryRange: SalaryRange | null;
27
+ applicationDeadline: string | null;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ poweredBy: PoweredBy;
31
+ }
32
+ interface Applicant {
33
+ fullName: string;
34
+ email: string;
35
+ phone: string;
36
+ location?: string;
37
+ linkedin?: string;
38
+ }
39
+ interface CVInfo {
40
+ url: string;
41
+ fileName: string;
42
+ fileSize: number;
43
+ mimeType: string;
44
+ path?: string;
45
+ }
46
+ interface SubmitApplicationParams {
47
+ jobId: string;
48
+ applicant: Applicant;
49
+ cv: CVInfo;
50
+ coverLetter?: string;
51
+ achievements?: string[];
52
+ }
53
+ interface ApplicationResult {
54
+ id: string;
55
+ message: string;
56
+ scoringError: string | null;
57
+ }
58
+ interface UploadResult {
59
+ url: string;
60
+ fileName: string;
61
+ fileSize: number;
62
+ mimeType: string;
63
+ path: string;
64
+ }
65
+ interface ListJobsParams {
66
+ status?: 'active' | 'all';
67
+ department?: string;
68
+ }
69
+ declare class ProdigioError extends Error {
70
+ readonly status: number;
71
+ readonly code?: string | undefined;
72
+ constructor(message: string, status: number, code?: string | undefined);
73
+ }
74
+ declare class Prodigio {
75
+ private readonly apiKey;
76
+ private readonly baseUrl;
77
+ constructor(config: ProdigioConfig | string);
78
+ private get;
79
+ private post;
80
+ private postForm;
81
+ readonly jobs: {
82
+ list: (params?: ListJobsParams) => Promise<Job[]>;
83
+ get: (jobId: string) => Promise<Job>;
84
+ };
85
+ readonly upload: {
86
+ cv: (file: File | Blob, fileName?: string) => Promise<UploadResult>;
87
+ achievement: (file: File | Blob, fileName?: string) => Promise<UploadResult>;
88
+ };
89
+ readonly applications: {
90
+ submit: (params: SubmitApplicationParams) => Promise<ApplicationResult>;
91
+ };
92
+ }
93
+
94
+ export { type Applicant, type ApplicationResult, type CVInfo, type Job, type ListJobsParams, type PoweredBy, Prodigio, type ProdigioConfig, ProdigioError, type SalaryRange, type SubmitApplicationParams, type UploadResult, Prodigio as default };
@@ -0,0 +1,94 @@
1
+ interface ProdigioConfig {
2
+ apiKey: string;
3
+ baseUrl?: string;
4
+ }
5
+ interface SalaryRange {
6
+ min: number;
7
+ max: number;
8
+ currency: string;
9
+ period: 'monthly' | 'yearly';
10
+ }
11
+ interface PoweredBy {
12
+ text: string;
13
+ url: string;
14
+ }
15
+ interface Job {
16
+ id: string;
17
+ title: string;
18
+ companyName: string;
19
+ department: string;
20
+ location: string;
21
+ type: 'full-time' | 'part-time' | 'contract';
22
+ status: 'active' | 'closed' | 'archived' | 'draft';
23
+ description: string;
24
+ requirements: string;
25
+ eligibilityCriteria?: string;
26
+ salaryRange: SalaryRange | null;
27
+ applicationDeadline: string | null;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ poweredBy: PoweredBy;
31
+ }
32
+ interface Applicant {
33
+ fullName: string;
34
+ email: string;
35
+ phone: string;
36
+ location?: string;
37
+ linkedin?: string;
38
+ }
39
+ interface CVInfo {
40
+ url: string;
41
+ fileName: string;
42
+ fileSize: number;
43
+ mimeType: string;
44
+ path?: string;
45
+ }
46
+ interface SubmitApplicationParams {
47
+ jobId: string;
48
+ applicant: Applicant;
49
+ cv: CVInfo;
50
+ coverLetter?: string;
51
+ achievements?: string[];
52
+ }
53
+ interface ApplicationResult {
54
+ id: string;
55
+ message: string;
56
+ scoringError: string | null;
57
+ }
58
+ interface UploadResult {
59
+ url: string;
60
+ fileName: string;
61
+ fileSize: number;
62
+ mimeType: string;
63
+ path: string;
64
+ }
65
+ interface ListJobsParams {
66
+ status?: 'active' | 'all';
67
+ department?: string;
68
+ }
69
+ declare class ProdigioError extends Error {
70
+ readonly status: number;
71
+ readonly code?: string | undefined;
72
+ constructor(message: string, status: number, code?: string | undefined);
73
+ }
74
+ declare class Prodigio {
75
+ private readonly apiKey;
76
+ private readonly baseUrl;
77
+ constructor(config: ProdigioConfig | string);
78
+ private get;
79
+ private post;
80
+ private postForm;
81
+ readonly jobs: {
82
+ list: (params?: ListJobsParams) => Promise<Job[]>;
83
+ get: (jobId: string) => Promise<Job>;
84
+ };
85
+ readonly upload: {
86
+ cv: (file: File | Blob, fileName?: string) => Promise<UploadResult>;
87
+ achievement: (file: File | Blob, fileName?: string) => Promise<UploadResult>;
88
+ };
89
+ readonly applications: {
90
+ submit: (params: SubmitApplicationParams) => Promise<ApplicationResult>;
91
+ };
92
+ }
93
+
94
+ export { type Applicant, type ApplicationResult, type CVInfo, type Job, type ListJobsParams, type PoweredBy, Prodigio, type ProdigioConfig, ProdigioError, type SalaryRange, type SubmitApplicationParams, type UploadResult, Prodigio as default };
package/dist/index.js ADDED
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Prodigio: () => Prodigio,
24
+ ProdigioError: () => ProdigioError,
25
+ default: () => index_default
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var DEFAULT_BASE_URL = "https://hire.prodigio.io";
29
+ var ProdigioError = class extends Error {
30
+ constructor(message, status, code) {
31
+ super(message);
32
+ this.status = status;
33
+ this.code = code;
34
+ this.name = "ProdigioError";
35
+ }
36
+ };
37
+ var Prodigio = class {
38
+ constructor(config) {
39
+ // ── Jobs ──────────────────────────────────────────────────────────────────
40
+ this.jobs = {
41
+ list: (params) => {
42
+ const p = {};
43
+ if (params == null ? void 0 : params.status) p.status = params.status;
44
+ if (params == null ? void 0 : params.department) p.department = params.department;
45
+ return this.get("/api/jobs", p);
46
+ },
47
+ get: (jobId) => {
48
+ return this.get(`/api/jobs/${jobId}`);
49
+ }
50
+ };
51
+ // ── Uploads ───────────────────────────────────────────────────────────────
52
+ this.upload = {
53
+ cv: (file, fileName) => {
54
+ const form = new FormData();
55
+ form.append("file", file, fileName);
56
+ return this.postForm("/api/upload/cv", form);
57
+ },
58
+ achievement: (file, fileName) => {
59
+ const form = new FormData();
60
+ form.append("file", file, fileName);
61
+ return this.postForm("/api/upload/achievement", form);
62
+ }
63
+ };
64
+ // ── Applications ──────────────────────────────────────────────────────────
65
+ this.applications = {
66
+ submit: (params) => {
67
+ return this.post("/api/applications", params);
68
+ }
69
+ };
70
+ var _a;
71
+ if (typeof config === "string") {
72
+ this.apiKey = config;
73
+ this.baseUrl = DEFAULT_BASE_URL;
74
+ } else {
75
+ this.apiKey = config.apiKey;
76
+ this.baseUrl = (_a = config.baseUrl) != null ? _a : DEFAULT_BASE_URL;
77
+ }
78
+ }
79
+ async get(path, params) {
80
+ var _a;
81
+ const url = new URL(`${this.baseUrl}${path}`);
82
+ url.searchParams.set("key", this.apiKey);
83
+ if (params) {
84
+ for (const [k, v] of Object.entries(params)) {
85
+ if (v !== void 0) url.searchParams.set(k, v);
86
+ }
87
+ }
88
+ const res = await fetch(url.toString());
89
+ if (!res.ok) {
90
+ const body = await res.json().catch(() => ({}));
91
+ throw new ProdigioError((_a = body.error) != null ? _a : `Request failed: ${res.status}`, res.status);
92
+ }
93
+ return res.json();
94
+ }
95
+ async post(path, body) {
96
+ var _a;
97
+ const res = await fetch(`${this.baseUrl}${path}`, {
98
+ method: "POST",
99
+ headers: {
100
+ "Content-Type": "application/json",
101
+ "x-api-key": this.apiKey
102
+ },
103
+ body: JSON.stringify(body)
104
+ });
105
+ if (!res.ok) {
106
+ const resBody = await res.json().catch(() => ({}));
107
+ throw new ProdigioError((_a = resBody.error) != null ? _a : `Request failed: ${res.status}`, res.status);
108
+ }
109
+ return res.json();
110
+ }
111
+ async postForm(path, formData) {
112
+ var _a;
113
+ const url = new URL(`${this.baseUrl}${path}`);
114
+ url.searchParams.set("key", this.apiKey);
115
+ const res = await fetch(url.toString(), {
116
+ method: "POST",
117
+ body: formData
118
+ });
119
+ if (!res.ok) {
120
+ const body = await res.json().catch(() => ({}));
121
+ throw new ProdigioError((_a = body.error) != null ? _a : `Upload failed: ${res.status}`, res.status);
122
+ }
123
+ return res.json();
124
+ }
125
+ };
126
+ var index_default = Prodigio;
127
+ // Annotate the CommonJS export names for ESM import in node:
128
+ 0 && (module.exports = {
129
+ Prodigio,
130
+ ProdigioError
131
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,105 @@
1
+ // src/index.ts
2
+ var DEFAULT_BASE_URL = "https://hire.prodigio.io";
3
+ var ProdigioError = class extends Error {
4
+ constructor(message, status, code) {
5
+ super(message);
6
+ this.status = status;
7
+ this.code = code;
8
+ this.name = "ProdigioError";
9
+ }
10
+ };
11
+ var Prodigio = class {
12
+ constructor(config) {
13
+ // ── Jobs ──────────────────────────────────────────────────────────────────
14
+ this.jobs = {
15
+ list: (params) => {
16
+ const p = {};
17
+ if (params == null ? void 0 : params.status) p.status = params.status;
18
+ if (params == null ? void 0 : params.department) p.department = params.department;
19
+ return this.get("/api/jobs", p);
20
+ },
21
+ get: (jobId) => {
22
+ return this.get(`/api/jobs/${jobId}`);
23
+ }
24
+ };
25
+ // ── Uploads ───────────────────────────────────────────────────────────────
26
+ this.upload = {
27
+ cv: (file, fileName) => {
28
+ const form = new FormData();
29
+ form.append("file", file, fileName);
30
+ return this.postForm("/api/upload/cv", form);
31
+ },
32
+ achievement: (file, fileName) => {
33
+ const form = new FormData();
34
+ form.append("file", file, fileName);
35
+ return this.postForm("/api/upload/achievement", form);
36
+ }
37
+ };
38
+ // ── Applications ──────────────────────────────────────────────────────────
39
+ this.applications = {
40
+ submit: (params) => {
41
+ return this.post("/api/applications", params);
42
+ }
43
+ };
44
+ var _a;
45
+ if (typeof config === "string") {
46
+ this.apiKey = config;
47
+ this.baseUrl = DEFAULT_BASE_URL;
48
+ } else {
49
+ this.apiKey = config.apiKey;
50
+ this.baseUrl = (_a = config.baseUrl) != null ? _a : DEFAULT_BASE_URL;
51
+ }
52
+ }
53
+ async get(path, params) {
54
+ var _a;
55
+ const url = new URL(`${this.baseUrl}${path}`);
56
+ url.searchParams.set("key", this.apiKey);
57
+ if (params) {
58
+ for (const [k, v] of Object.entries(params)) {
59
+ if (v !== void 0) url.searchParams.set(k, v);
60
+ }
61
+ }
62
+ const res = await fetch(url.toString());
63
+ if (!res.ok) {
64
+ const body = await res.json().catch(() => ({}));
65
+ throw new ProdigioError((_a = body.error) != null ? _a : `Request failed: ${res.status}`, res.status);
66
+ }
67
+ return res.json();
68
+ }
69
+ async post(path, body) {
70
+ var _a;
71
+ const res = await fetch(`${this.baseUrl}${path}`, {
72
+ method: "POST",
73
+ headers: {
74
+ "Content-Type": "application/json",
75
+ "x-api-key": this.apiKey
76
+ },
77
+ body: JSON.stringify(body)
78
+ });
79
+ if (!res.ok) {
80
+ const resBody = await res.json().catch(() => ({}));
81
+ throw new ProdigioError((_a = resBody.error) != null ? _a : `Request failed: ${res.status}`, res.status);
82
+ }
83
+ return res.json();
84
+ }
85
+ async postForm(path, formData) {
86
+ var _a;
87
+ const url = new URL(`${this.baseUrl}${path}`);
88
+ url.searchParams.set("key", this.apiKey);
89
+ const res = await fetch(url.toString(), {
90
+ method: "POST",
91
+ body: formData
92
+ });
93
+ if (!res.ok) {
94
+ const body = await res.json().catch(() => ({}));
95
+ throw new ProdigioError((_a = body.error) != null ? _a : `Upload failed: ${res.status}`, res.status);
96
+ }
97
+ return res.json();
98
+ }
99
+ };
100
+ var index_default = Prodigio;
101
+ export {
102
+ Prodigio,
103
+ ProdigioError,
104
+ index_default as default
105
+ };
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@prodigio-io/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official JavaScript SDK for the Prodigio hiring API",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "scripts": {
17
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
18
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch"
19
+ },
20
+ "keywords": ["prodigio", "hiring", "jobs", "recruitment", "api"],
21
+ "license": "MIT",
22
+ "devDependencies": {
23
+ "tsup": "^8.0.0",
24
+ "typescript": "^5.0.0"
25
+ }
26
+ }