@magentrix-corp/magentrix-sdk 1.0.4 → 1.0.6

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,31 @@
1
+ import { RequestMethod } from './enums';
2
+ import { MagentrixConfig, SessionInfo } from './interfaces';
3
+ export declare class MagentrixClient {
4
+ private config;
5
+ private sessionInfo;
6
+ private restVersion;
7
+ constructor(config: MagentrixConfig);
8
+ createSession(refreshToken?: string): Promise<SessionInfo>;
9
+ query(query: string): Promise<any>;
10
+ execute(path: string, model?: any, method?: RequestMethod): Promise<any>;
11
+ retrieve(id: string): Promise<any>;
12
+ create(entityName: string, data: any): Promise<any>;
13
+ edit(entityName: string, data: any): Promise<any>;
14
+ upsert(entityName: string, data: any): Promise<any>;
15
+ delete(entityName: string, id: string, permanent?: boolean): Promise<any>;
16
+ deleteMany(entityName: string, ids: string[], permanent?: boolean): Promise<any>;
17
+ private convertToEncodedKeyValuePairs;
18
+ private getData;
19
+ private postData;
20
+ private patchData;
21
+ private putData;
22
+ private deleteData;
23
+ private getRequestOptions;
24
+ private handleAuthError;
25
+ private getFullUrl;
26
+ private fillIdsOnCreate;
27
+ private throwError;
28
+ private isForbidden;
29
+ private isValidSession;
30
+ private ensureValidSession;
31
+ }
@@ -0,0 +1,13 @@
1
+ export declare enum RequestMethod {
2
+ get = "GET",
3
+ post = "POST",
4
+ put = "PUT",
5
+ patch = "PATCH",
6
+ delete = "DELETE"
7
+ }
8
+ export declare enum ContentType {
9
+ json = "application/json",
10
+ form_url_encoded = "application/x-www-form-urlencoded",
11
+ xml = "application/xml",
12
+ text = "text/plain"
13
+ }
@@ -0,0 +1,9 @@
1
+ export declare class MagentrixError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class DatabaseError extends Error {
5
+ errors: any[];
6
+ constructor(message: string, errors?: any[]);
7
+ getErrors(): any[];
8
+ hasErrors(): boolean;
9
+ }
@@ -0,0 +1,15 @@
1
+ export interface MagentrixConfig {
2
+ /** Base URL of your Magentrix instance (e.g., 'https://your-instance.magentrix.com') */
3
+ baseUrl: string;
4
+ /** Optional: Bearer token for authentication if you already have one */
5
+ refreshToken?: string;
6
+ isDevMode?: boolean;
7
+ /** Optional: Callback function invoked when the session expires */
8
+ onSessionExpired?: () => Promise<void> | void;
9
+ /** Optional: Global error handler for all API errors */
10
+ onError?: (error: any) => void;
11
+ }
12
+ export interface SessionInfo {
13
+ token: string;
14
+ expires_in: number;
15
+ }
@@ -0,0 +1,4 @@
1
+ export { MagentrixClient } from './helpers/MagentrixClient';
2
+ export { MagentrixError, DatabaseError } from './helpers/errors';
3
+ export { RequestMethod, ContentType } from './helpers/enums';
4
+ export type { MagentrixConfig, SessionInfo } from './helpers/interfaces';
@@ -0,0 +1,31 @@
1
+ import { RequestMethod } from './enums';
2
+ import { MagentrixConfig, SessionInfo } from './interfaces';
3
+ export declare class MagentrixClient {
4
+ private config;
5
+ private sessionInfo;
6
+ private restVersion;
7
+ constructor(config: MagentrixConfig);
8
+ createSession(refreshToken?: string): Promise<SessionInfo>;
9
+ query(query: string): Promise<any>;
10
+ execute(path: string, model?: any, method?: RequestMethod): Promise<any>;
11
+ retrieve(id: string): Promise<any>;
12
+ create(entityName: string, data: any): Promise<any>;
13
+ edit(entityName: string, data: any): Promise<any>;
14
+ upsert(entityName: string, data: any): Promise<any>;
15
+ delete(entityName: string, id: string, permanent?: boolean): Promise<any>;
16
+ deleteMany(entityName: string, ids: string[], permanent?: boolean): Promise<any>;
17
+ private convertToEncodedKeyValuePairs;
18
+ private getData;
19
+ private postData;
20
+ private patchData;
21
+ private putData;
22
+ private deleteData;
23
+ private getRequestOptions;
24
+ private handleAuthError;
25
+ private getFullUrl;
26
+ private fillIdsOnCreate;
27
+ private throwError;
28
+ private isForbidden;
29
+ private isValidSession;
30
+ private ensureValidSession;
31
+ }
@@ -0,0 +1,13 @@
1
+ export declare enum RequestMethod {
2
+ get = "GET",
3
+ post = "POST",
4
+ put = "PUT",
5
+ patch = "PATCH",
6
+ delete = "DELETE"
7
+ }
8
+ export declare enum ContentType {
9
+ json = "application/json",
10
+ form_url_encoded = "application/x-www-form-urlencoded",
11
+ xml = "application/xml",
12
+ text = "text/plain"
13
+ }
@@ -0,0 +1,9 @@
1
+ export declare class MagentrixError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class DatabaseError extends Error {
5
+ errors: any[];
6
+ constructor(message: string, errors?: any[]);
7
+ getErrors(): any[];
8
+ hasErrors(): boolean;
9
+ }
@@ -0,0 +1,15 @@
1
+ export interface MagentrixConfig {
2
+ /** Base URL of your Magentrix instance (e.g., 'https://your-instance.magentrix.com') */
3
+ baseUrl: string;
4
+ /** Optional: Bearer token for authentication if you already have one */
5
+ refreshToken?: string;
6
+ isDevMode?: boolean;
7
+ /** Optional: Callback function invoked when the session expires */
8
+ onSessionExpired?: () => Promise<void> | void;
9
+ /** Optional: Global error handler for all API errors */
10
+ onError?: (error: any) => void;
11
+ }
12
+ export interface SessionInfo {
13
+ token: string;
14
+ expires_in: number;
15
+ }
@@ -0,0 +1,4 @@
1
+ export { MagentrixClient } from './helpers/MagentrixClient';
2
+ export { MagentrixError, DatabaseError } from './helpers/errors';
3
+ export { RequestMethod, ContentType } from './helpers/enums';
4
+ export type { MagentrixConfig, SessionInfo } from './helpers/interfaces';
@@ -0,0 +1,5 @@
1
+ import { MagentrixConfig } from "../helpers/interfaces";
2
+ import { MagentrixClient } from "../helpers/MagentrixClient";
3
+ export declare function useMagentrixSdk(): {
4
+ getInstance: (config: MagentrixConfig) => MagentrixClient;
5
+ };
@@ -0,0 +1,5 @@
1
+ import { MagentrixConfig } from "../helpers/interfaces";
2
+ import { MagentrixClient } from "../helpers/MagentrixClient";
3
+ export declare function useMagentrixSdk(): {
4
+ getInstance: (config: MagentrixConfig) => MagentrixClient;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magentrix-corp/magentrix-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "TypeScript SDK for Magentrix APIs with dual authentication modes, automatic session management, CRUD operations, and Vue 3 integration",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",