@vigneshreddy/cms-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/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/src/client.d.ts +46 -0
- package/dist/src/client.js +109 -0
- package/dist/src/errors/base.d.ts +21 -0
- package/dist/src/errors/base.js +19 -0
- package/dist/src/errors/index.d.ts +3 -0
- package/dist/src/errors/index.js +22 -0
- package/dist/src/errors/specific.d.ts +43 -0
- package/dist/src/errors/specific.js +118 -0
- package/dist/src/errors.d.ts +8 -0
- package/dist/src/errors.js +60 -0
- package/dist/src/funcs/index.d.ts +2 -0
- package/dist/src/funcs/index.js +7 -0
- package/dist/src/funcs/trackLead.d.ts +36 -0
- package/dist/src/funcs/trackLead.js +47 -0
- package/dist/src/funcs/trackSale.d.ts +38 -0
- package/dist/src/funcs/trackSale.js +49 -0
- package/dist/src/generated/api.d.ts +131 -0
- package/dist/src/generated/api.js +244 -0
- package/dist/src/generated/base.d.ts +57 -0
- package/dist/src/generated/base.js +52 -0
- package/dist/src/generated/common.d.ts +31 -0
- package/dist/src/generated/common.js +116 -0
- package/dist/src/generated/configuration.d.ts +98 -0
- package/dist/src/generated/configuration.js +49 -0
- package/dist/src/generated/index.d.ts +4 -0
- package/dist/src/generated/index.js +20 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +34 -0
- package/dist/src/types/result.d.ts +22 -0
- package/dist/src/types/result.js +16 -0
- package/package.json +66 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* CMS API
|
|
6
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.operationServerMap = exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
17
|
+
exports.BASE_PATH = "https://www.cutmeshort.com/api".replace(/\/+$/, "");
|
|
18
|
+
exports.COLLECTION_FORMATS = {
|
|
19
|
+
csv: ",",
|
|
20
|
+
ssv: " ",
|
|
21
|
+
tsv: "\t",
|
|
22
|
+
pipes: "|",
|
|
23
|
+
};
|
|
24
|
+
class BaseAPI {
|
|
25
|
+
/**
|
|
26
|
+
* Minimal base class that stores configuration and basePath.
|
|
27
|
+
* Concrete API classes are responsible for performing requests using
|
|
28
|
+
* the global `fetch` (or any polyfill provided by the consumer).
|
|
29
|
+
*/
|
|
30
|
+
constructor(configuration, basePath = exports.BASE_PATH) {
|
|
31
|
+
var _a;
|
|
32
|
+
this.basePath = exports.BASE_PATH;
|
|
33
|
+
if (configuration) {
|
|
34
|
+
this.configuration = configuration;
|
|
35
|
+
this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.basePath = basePath;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.BaseAPI = BaseAPI;
|
|
43
|
+
;
|
|
44
|
+
class RequiredError extends Error {
|
|
45
|
+
constructor(field, msg) {
|
|
46
|
+
super(msg);
|
|
47
|
+
this.field = field;
|
|
48
|
+
this.name = "RequiredError";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.RequiredError = RequiredError;
|
|
52
|
+
exports.operationServerMap = {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS API
|
|
3
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { Configuration } from "./configuration";
|
|
13
|
+
export declare const DUMMY_BASE_URL = "https://example.com";
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @throws {RequiredError}
|
|
17
|
+
*/
|
|
18
|
+
export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
|
|
19
|
+
export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
|
|
20
|
+
export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
|
|
21
|
+
export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
|
|
22
|
+
export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
|
|
23
|
+
export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
|
|
26
|
+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
|
|
27
|
+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
|
|
28
|
+
*/
|
|
29
|
+
export declare const replaceWithSerializableTypeIfNeeded: (key: string, value: any) => any;
|
|
30
|
+
export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
|
|
31
|
+
export declare const toPathString: (url: URL) => string;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* CMS API
|
|
6
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0.0
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.toPathString = exports.serializeDataIfNeeded = exports.replaceWithSerializableTypeIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
|
|
17
|
+
const base_1 = require("./base");
|
|
18
|
+
exports.DUMMY_BASE_URL = 'https://example.com';
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @throws {RequiredError}
|
|
22
|
+
*/
|
|
23
|
+
const assertParamExists = function (functionName, paramName, paramValue) {
|
|
24
|
+
if (paramValue === null || paramValue === undefined) {
|
|
25
|
+
throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.assertParamExists = assertParamExists;
|
|
29
|
+
const setApiKeyToObject = async function (object, keyParamName, configuration) {
|
|
30
|
+
if (configuration && configuration.apiKey) {
|
|
31
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
32
|
+
? await configuration.apiKey(keyParamName)
|
|
33
|
+
: await configuration.apiKey;
|
|
34
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.setApiKeyToObject = setApiKeyToObject;
|
|
38
|
+
const setBasicAuthToObject = function (object, configuration) {
|
|
39
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
40
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.setBasicAuthToObject = setBasicAuthToObject;
|
|
44
|
+
const setBearerAuthToObject = async function (object, configuration) {
|
|
45
|
+
if (configuration && configuration.accessToken) {
|
|
46
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
47
|
+
? await configuration.accessToken()
|
|
48
|
+
: await configuration.accessToken;
|
|
49
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.setBearerAuthToObject = setBearerAuthToObject;
|
|
53
|
+
const setOAuthToObject = async function (object, name, scopes, configuration) {
|
|
54
|
+
if (configuration && configuration.accessToken) {
|
|
55
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
56
|
+
? await configuration.accessToken(name, scopes)
|
|
57
|
+
: await configuration.accessToken;
|
|
58
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.setOAuthToObject = setOAuthToObject;
|
|
62
|
+
function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
63
|
+
if (parameter == null)
|
|
64
|
+
return;
|
|
65
|
+
if (typeof parameter === "object") {
|
|
66
|
+
if (Array.isArray(parameter) || parameter instanceof Set) {
|
|
67
|
+
parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (urlSearchParams.has(key)) {
|
|
75
|
+
urlSearchParams.append(key, parameter);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
urlSearchParams.set(key, parameter);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const setSearchParams = function (url, ...objects) {
|
|
83
|
+
const searchParams = new URLSearchParams(url.search);
|
|
84
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
85
|
+
url.search = searchParams.toString();
|
|
86
|
+
};
|
|
87
|
+
exports.setSearchParams = setSearchParams;
|
|
88
|
+
/**
|
|
89
|
+
* JSON serialization helper function which replaces instances of unserializable types with serializable ones.
|
|
90
|
+
* This function will run for every key-value pair encountered by JSON.stringify while traversing an object.
|
|
91
|
+
* Converting a set to a string will return an empty object, so an intermediate conversion to an array is required.
|
|
92
|
+
*/
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
const replaceWithSerializableTypeIfNeeded = function (key, value) {
|
|
95
|
+
if (value instanceof Set) {
|
|
96
|
+
return Array.from(value);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.replaceWithSerializableTypeIfNeeded = replaceWithSerializableTypeIfNeeded;
|
|
103
|
+
const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
104
|
+
const nonString = typeof value !== 'string';
|
|
105
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
106
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
107
|
+
: nonString;
|
|
108
|
+
return needsSerialization
|
|
109
|
+
? JSON.stringify(value !== undefined ? value : {}, exports.replaceWithSerializableTypeIfNeeded)
|
|
110
|
+
: (value || "");
|
|
111
|
+
};
|
|
112
|
+
exports.serializeDataIfNeeded = serializeDataIfNeeded;
|
|
113
|
+
const toPathString = function (url) {
|
|
114
|
+
return url.pathname + url.search + url.hash;
|
|
115
|
+
};
|
|
116
|
+
exports.toPathString = toPathString;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS API
|
|
3
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
interface AWSv4Configuration {
|
|
13
|
+
options?: {
|
|
14
|
+
region?: string;
|
|
15
|
+
service?: string;
|
|
16
|
+
};
|
|
17
|
+
credentials?: {
|
|
18
|
+
accessKeyId?: string;
|
|
19
|
+
secretAccessKey?: string;
|
|
20
|
+
sessionToken?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface ConfigurationParameters {
|
|
24
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
25
|
+
username?: string;
|
|
26
|
+
password?: string;
|
|
27
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
28
|
+
awsv4?: AWSv4Configuration;
|
|
29
|
+
basePath?: string;
|
|
30
|
+
serverIndex?: number;
|
|
31
|
+
baseOptions?: any;
|
|
32
|
+
formDataCtor?: new () => any;
|
|
33
|
+
}
|
|
34
|
+
export declare class Configuration {
|
|
35
|
+
/**
|
|
36
|
+
* parameter for apiKey security
|
|
37
|
+
* @param name security name
|
|
38
|
+
*/
|
|
39
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
40
|
+
/**
|
|
41
|
+
* parameter for basic security
|
|
42
|
+
*/
|
|
43
|
+
username?: string;
|
|
44
|
+
/**
|
|
45
|
+
* parameter for basic security
|
|
46
|
+
*/
|
|
47
|
+
password?: string;
|
|
48
|
+
/**
|
|
49
|
+
* parameter for oauth2 security
|
|
50
|
+
* @param name security name
|
|
51
|
+
* @param scopes oauth2 scope
|
|
52
|
+
*/
|
|
53
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
54
|
+
/**
|
|
55
|
+
* parameter for aws4 signature security
|
|
56
|
+
* @param {Object} AWS4Signature - AWS4 Signature security
|
|
57
|
+
* @param {string} options.region - aws region
|
|
58
|
+
* @param {string} options.service - name of the service.
|
|
59
|
+
* @param {string} credentials.accessKeyId - aws access key id
|
|
60
|
+
* @param {string} credentials.secretAccessKey - aws access key
|
|
61
|
+
* @param {string} credentials.sessionToken - aws session token
|
|
62
|
+
* @memberof Configuration
|
|
63
|
+
*/
|
|
64
|
+
awsv4?: AWSv4Configuration;
|
|
65
|
+
/**
|
|
66
|
+
* override base path
|
|
67
|
+
*/
|
|
68
|
+
basePath?: string;
|
|
69
|
+
/**
|
|
70
|
+
* override server index
|
|
71
|
+
*/
|
|
72
|
+
serverIndex?: number;
|
|
73
|
+
/**
|
|
74
|
+
* base options for axios calls
|
|
75
|
+
*/
|
|
76
|
+
baseOptions?: any;
|
|
77
|
+
/**
|
|
78
|
+
* The FormData constructor that will be used to create multipart form data
|
|
79
|
+
* requests. You can inject this here so that execution environments that
|
|
80
|
+
* do not support the FormData class can still run the generated client.
|
|
81
|
+
*
|
|
82
|
+
* @type {new () => FormData}
|
|
83
|
+
*/
|
|
84
|
+
formDataCtor?: new () => any;
|
|
85
|
+
constructor(param?: ConfigurationParameters);
|
|
86
|
+
/**
|
|
87
|
+
* Check if the given MIME is a JSON MIME.
|
|
88
|
+
* JSON MIME examples:
|
|
89
|
+
* application/json
|
|
90
|
+
* application/json; charset=UTF8
|
|
91
|
+
* APPLICATION/JSON
|
|
92
|
+
* application/vnd.company+json
|
|
93
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
94
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
95
|
+
*/
|
|
96
|
+
isJsonMime(mime: string): boolean;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* CMS API
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Configuration = void 0;
|
|
16
|
+
class Configuration {
|
|
17
|
+
constructor(param = {}) {
|
|
18
|
+
var _a;
|
|
19
|
+
this.apiKey = param.apiKey;
|
|
20
|
+
this.username = param.username;
|
|
21
|
+
this.password = param.password;
|
|
22
|
+
this.accessToken = param.accessToken;
|
|
23
|
+
this.awsv4 = param.awsv4;
|
|
24
|
+
this.basePath = param.basePath;
|
|
25
|
+
this.serverIndex = param.serverIndex;
|
|
26
|
+
this.baseOptions = {
|
|
27
|
+
...param.baseOptions,
|
|
28
|
+
headers: {
|
|
29
|
+
...(_a = param.baseOptions) === null || _a === void 0 ? void 0 : _a.headers,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
this.formDataCtor = param.formDataCtor;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if the given MIME is a JSON MIME.
|
|
36
|
+
* JSON MIME examples:
|
|
37
|
+
* application/json
|
|
38
|
+
* application/json; charset=UTF8
|
|
39
|
+
* APPLICATION/JSON
|
|
40
|
+
* application/vnd.company+json
|
|
41
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
42
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
isJsonMime(mime) {
|
|
45
|
+
const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
46
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.Configuration = Configuration;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./base"), exports);
|
|
19
|
+
__exportStar(require("./common"), exports);
|
|
20
|
+
__exportStar(require("./configuration"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CMS, type CMSConfig, type RequestOptions } from "./client";
|
|
2
|
+
export { CMSAPIError, handleApiError } from "./errors";
|
|
3
|
+
export * from "./errors/index";
|
|
4
|
+
export { trackLead, trackSale, type TrackLeadError, type TrackSaleError } from "./funcs";
|
|
5
|
+
export { ok, err, type Result } from "./types/result";
|
|
6
|
+
export type { TrackLeadRequest, TrackSaleRequest, TrackResponse, } from "./generated/api";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/index.ts
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.err = exports.ok = exports.trackSale = exports.trackLead = exports.handleApiError = exports.CMSAPIError = exports.CMS = void 0;
|
|
19
|
+
// Main client
|
|
20
|
+
var client_1 = require("./client");
|
|
21
|
+
Object.defineProperty(exports, "CMS", { enumerable: true, get: function () { return client_1.CMS; } });
|
|
22
|
+
// Errors
|
|
23
|
+
var errors_1 = require("./errors");
|
|
24
|
+
Object.defineProperty(exports, "CMSAPIError", { enumerable: true, get: function () { return errors_1.CMSAPIError; } });
|
|
25
|
+
Object.defineProperty(exports, "handleApiError", { enumerable: true, get: function () { return errors_1.handleApiError; } });
|
|
26
|
+
__exportStar(require("./errors/index"), exports);
|
|
27
|
+
// Functional helpers (Result pattern)
|
|
28
|
+
var funcs_1 = require("./funcs");
|
|
29
|
+
Object.defineProperty(exports, "trackLead", { enumerable: true, get: function () { return funcs_1.trackLead; } });
|
|
30
|
+
Object.defineProperty(exports, "trackSale", { enumerable: true, get: function () { return funcs_1.trackSale; } });
|
|
31
|
+
// Result type utilities
|
|
32
|
+
var result_1 = require("./types/result");
|
|
33
|
+
Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return result_1.ok; } });
|
|
34
|
+
Object.defineProperty(exports, "err", { enumerable: true, get: function () { return result_1.err; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result type for functional error handling.
|
|
3
|
+
* Inspired by Rust's Result<T, E> and functional programming patterns.
|
|
4
|
+
*
|
|
5
|
+
* This allows methods to return success/error states without throwing exceptions,
|
|
6
|
+
* making error handling explicit and type-safe.
|
|
7
|
+
*/
|
|
8
|
+
export type Result<T, E = Error> = {
|
|
9
|
+
ok: true;
|
|
10
|
+
value: T;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: E;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Creates a successful Result
|
|
17
|
+
*/
|
|
18
|
+
export declare function ok<T>(value: T): Result<T, never>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates an error Result
|
|
21
|
+
*/
|
|
22
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ok = ok;
|
|
4
|
+
exports.err = err;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a successful Result
|
|
7
|
+
*/
|
|
8
|
+
function ok(value) {
|
|
9
|
+
return { ok: true, value };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates an error Result
|
|
13
|
+
*/
|
|
14
|
+
function err(error) {
|
|
15
|
+
return { ok: false, error };
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vigneshreddy/cms-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official TypeScript SDK for CutMeShort CMS API",
|
|
5
|
+
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
|
|
9
|
+
"type": "commonjs",
|
|
10
|
+
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./client": {
|
|
17
|
+
"require": "./dist/client.js",
|
|
18
|
+
"types": "./dist/client.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./errors": {
|
|
21
|
+
"require": "./dist/errors/index.js",
|
|
22
|
+
"types": "./dist/errors/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./funcs": {
|
|
25
|
+
"require": "./dist/funcs/index.js",
|
|
26
|
+
"types": "./dist/funcs/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"test": "vitest"
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
"keywords": [
|
|
40
|
+
"cutmeshort",
|
|
41
|
+
"cms",
|
|
42
|
+
"sdk",
|
|
43
|
+
"typescript",
|
|
44
|
+
"api"
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "https://github.com/YOUR_USERNAME/cms-sdk"
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
"homepage": "https://github.com/YOUR_USERNAME/cms-sdk#readme",
|
|
53
|
+
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
"author": "Vignesh Reddy",
|
|
59
|
+
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"typescript": "^5.7.0",
|
|
64
|
+
"vitest": "^4.0.18"
|
|
65
|
+
}
|
|
66
|
+
}
|