@vinnuvinod/amc-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.
package/dist/amc.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { AMCClient } from "./client";
2
+ import { CreateAMCRequest, UpdateAMCRequest } from "./types";
3
+ export declare class AMCService {
4
+ private client;
5
+ constructor(client: AMCClient);
6
+ create(payload: CreateAMCRequest): Promise<import("axios").AxiosResponse<any, any, {}>>;
7
+ update(amcId: number, payload: UpdateAMCRequest): Promise<import("axios").AxiosResponse<any, any, {}>>;
8
+ delete(amcId: number): Promise<import("axios").AxiosResponse<any, any, {}>>;
9
+ getAll(params?: {
10
+ page?: number;
11
+ limit?: number;
12
+ search?: string;
13
+ status?: string;
14
+ project_ids: number[];
15
+ }): Promise<import("axios").AxiosResponse<any, any, {}>>;
16
+ getByClient(clientId: number, params?: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
17
+ }
package/dist/amc.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AMCService = void 0;
4
+ const validators_1 = require("./validators");
5
+ class AMCService {
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ create(payload) {
10
+ (0, validators_1.validateCreateAMC)(payload);
11
+ return this.client.http.post("/amc", payload);
12
+ }
13
+ update(amcId, payload) {
14
+ (0, validators_1.validateUpdateAMC)(payload);
15
+ return this.client.http.put(`/amc/${amcId}`, payload);
16
+ }
17
+ delete(amcId) {
18
+ return this.client.http.delete(`/amc/${amcId}`);
19
+ }
20
+ getAll(params) {
21
+ return this.client.http.get("/amc", {
22
+ params: {
23
+ ...params,
24
+ project_ids: JSON.stringify((params === null || params === void 0 ? void 0 : params.project_ids) || []),
25
+ },
26
+ });
27
+ }
28
+ getByClient(clientId, params) {
29
+ return this.client.http.get(`/amc/client/${clientId}`, { params });
30
+ }
31
+ }
32
+ exports.AMCService = AMCService;
@@ -0,0 +1,9 @@
1
+ import { AxiosInstance } from "axios";
2
+ export interface AMCClientConfig {
3
+ baseURL: string;
4
+ projectToken: string;
5
+ }
6
+ export declare class AMCClient {
7
+ http: AxiosInstance;
8
+ constructor(config: AMCClientConfig);
9
+ }
package/dist/client.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AMCClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class AMCClient {
9
+ constructor(config) {
10
+ this.http = axios_1.default.create({
11
+ baseURL: config.baseURL,
12
+ headers: {
13
+ "x-project-token": config.projectToken,
14
+ },
15
+ });
16
+ this.http.interceptors.response.use((res) => res.data, (error) => {
17
+ var _a, _b;
18
+ const message = ((_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || error.message || "API Error";
19
+ return Promise.reject(new Error(message));
20
+ });
21
+ }
22
+ }
23
+ exports.AMCClient = AMCClient;
@@ -0,0 +1,4 @@
1
+ export declare const AMCPriorities: readonly ["CRITICAL", "MAJOR", "MODERATE", "MINOR"];
2
+ export declare const AMCStatuses: readonly ["PENDING", "STARTED", "COMPLETED", "CANCELLED"];
3
+ export type AMCPriority = (typeof AMCPriorities)[number];
4
+ export type AMCStatus = (typeof AMCStatuses)[number];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AMCStatuses = exports.AMCPriorities = void 0;
4
+ exports.AMCPriorities = [
5
+ "CRITICAL",
6
+ "MAJOR",
7
+ "MODERATE",
8
+ "MINOR",
9
+ ];
10
+ exports.AMCStatuses = [
11
+ "PENDING",
12
+ "STARTED",
13
+ "COMPLETED",
14
+ "CANCELLED",
15
+ ];
@@ -0,0 +1,10 @@
1
+ import { AMCClient } from "./client";
2
+ export declare class EmployeeService {
3
+ private client;
4
+ constructor(client: AMCClient);
5
+ list(params?: {
6
+ page?: number;
7
+ limit?: number;
8
+ search?: string;
9
+ }): Promise<import("axios").AxiosResponse<any, any, {}>>;
10
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmployeeService = void 0;
4
+ class EmployeeService {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ list(params) {
9
+ return this.client.http.get("/employees", { params });
10
+ }
11
+ }
12
+ exports.EmployeeService = EmployeeService;
@@ -0,0 +1,9 @@
1
+ import { AMCClientConfig } from "./client";
2
+ import { AMCService } from "./amc";
3
+ import { EmployeeService } from "./employees";
4
+ export declare class AMCSDK {
5
+ amc: AMCService;
6
+ employees: EmployeeService;
7
+ constructor(config: AMCClientConfig);
8
+ }
9
+ export * from "./client";
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.AMCSDK = void 0;
18
+ const client_1 = require("./client");
19
+ const amc_1 = require("./amc");
20
+ const employees_1 = require("./employees");
21
+ class AMCSDK {
22
+ constructor(config) {
23
+ const client = new client_1.AMCClient(config);
24
+ this.amc = new amc_1.AMCService(client);
25
+ this.employees = new employees_1.EmployeeService(client);
26
+ }
27
+ }
28
+ exports.AMCSDK = AMCSDK;
29
+ __exportStar(require("./client"), exports);
@@ -0,0 +1,15 @@
1
+ import { AMCPriority, AMCStatus } from "./constants";
2
+ export interface CreateAMCRequest {
3
+ title: string;
4
+ description?: string;
5
+ assignees: number[];
6
+ priority: AMCPriority;
7
+ }
8
+ export interface UpdateAMCRequest {
9
+ title?: string;
10
+ description?: string;
11
+ hours?: number;
12
+ status?: AMCStatus;
13
+ assignees?: number[];
14
+ priority?: AMCPriority;
15
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { CreateAMCRequest, UpdateAMCRequest } from "./types";
2
+ export declare const validateCreateAMC: (payload: CreateAMCRequest) => void;
3
+ export declare const validateUpdateAMC: (payload: UpdateAMCRequest) => void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateUpdateAMC = exports.validateCreateAMC = void 0;
4
+ const constants_1 = require("./constants");
5
+ const isValidEnum = (value, list) => list.includes(value);
6
+ const validateCreateAMC = (payload) => {
7
+ var _a;
8
+ if (!((_a = payload.title) === null || _a === void 0 ? void 0 : _a.trim())) {
9
+ throw new Error("AMC title is required");
10
+ }
11
+ if (!Array.isArray(payload.assignees) || payload.assignees.length === 0) {
12
+ throw new Error("At least one assignee is required");
13
+ }
14
+ if (!isValidEnum(payload.priority, constants_1.AMCPriorities)) {
15
+ throw new Error(`Invalid priority. Allowed: ${constants_1.AMCPriorities.join(", ")}`);
16
+ }
17
+ };
18
+ exports.validateCreateAMC = validateCreateAMC;
19
+ const validateUpdateAMC = (payload) => {
20
+ if (payload.priority && !isValidEnum(payload.priority, constants_1.AMCPriorities)) {
21
+ throw new Error(`Invalid priority. Allowed: ${constants_1.AMCPriorities.join(", ")}`);
22
+ }
23
+ if (payload.status && !isValidEnum(payload.status, constants_1.AMCStatuses)) {
24
+ throw new Error(`Invalid status. Allowed: ${constants_1.AMCStatuses.join(", ")}`);
25
+ }
26
+ if (payload.status === "COMPLETED" &&
27
+ (payload.hours === undefined || payload.hours < 0)) {
28
+ throw new Error("Hours must be provided when status is COMPLETED");
29
+ }
30
+ };
31
+ exports.validateUpdateAMC = validateUpdateAMC;
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@vinnuvinod/amc-sdk",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "description": "",
17
+ "dependencies": {
18
+ "axios": "^1.13.2"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^25.0.3",
22
+ "typescript": "^5.9.3"
23
+ }
24
+ }