@vigneshreddy/cms-sdk 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -10,7 +10,7 @@ This SDK is:
10
10
  ## Install
11
11
 
12
12
  ```bash
13
- npm install @vignesh/cms-sdk
13
+ npm install @vigneshreddy/cms-sdk
14
14
  ```
15
15
 
16
16
  ## Runtime requirements
@@ -37,7 +37,7 @@ global.Response = Response as any;
37
37
  Create the client once and reuse it across calls.
38
38
 
39
39
  ```ts
40
- import { CMS } from "@vignesh/cms-sdk";
40
+ import { CMS } from "@vigneshreddy/cms-sdk";
41
41
 
42
42
  const sdk = new CMS({
43
43
  apiKey: process.env.CMS_API_KEY!,
@@ -50,7 +50,7 @@ const sdk = new CMS({
50
50
  ### Class-based usage (throws on error)
51
51
 
52
52
  ```ts
53
- import { CMS } from "@vignesh/cms-sdk";
53
+ import { CMS } from "@vigneshreddy/cms-sdk";
54
54
 
55
55
  const sdk = new CMS({ apiKey: "sk_live_123" });
56
56
 
@@ -66,7 +66,7 @@ console.log("Lead response:", leadResponse);
66
66
  ### Functional helper (Result pattern)
67
67
 
68
68
  ```ts
69
- import { CMS, trackLead } from "@vignesh/cms-sdk";
69
+ import { CMS, trackLead } from "@vigneshreddy/cms-sdk";
70
70
 
71
71
  const sdk = new CMS({ apiKey: "sk_live_123" });
72
72
 
@@ -88,7 +88,7 @@ if (res.ok) {
88
88
  ### Class-based usage (throws on error)
89
89
 
90
90
  ```ts
91
- import { CMS } from "@vignesh/cms-sdk";
91
+ import { CMS } from "@vigneshreddy/cms-sdk";
92
92
 
93
93
  const sdk = new CMS({ apiKey: "sk_live_123" });
94
94
 
@@ -150,7 +150,7 @@ export interface CMSConfig {
150
150
  You can override retries and timeout on a single request.
151
151
 
152
152
  ```ts
153
- import { CMS } from "@vignesh/cms-sdk";
153
+ import { CMS } from "@vigneshreddy/cms-sdk";
154
154
 
155
155
  const sdk = new CMS({ apiKey: "sk_live_123" });
156
156
 
@@ -172,7 +172,7 @@ await sdk.trackLead(
172
172
  All thrown errors from class-based methods are normalized as `CMSAPIError` or its specific subclasses.
173
173
 
174
174
  ```ts
175
- import { CMS, CMSAPIError } from "@vignesh/cms-sdk";
175
+ import { CMS, CMSAPIError } from "@vigneshreddy/cms-sdk";
176
176
 
177
177
  const sdk = new CMS({ apiKey: "sk_live_123" });
178
178
 
@@ -198,10 +198,10 @@ try {
198
198
  ## Exports
199
199
 
200
200
  ```ts
201
- import { CMS } from "@vignesh/cms-sdk";
202
- import { trackLead, trackSale } from "@vignesh/cms-sdk";
203
- import { CMSAPIError } from "@vignesh/cms-sdk";
204
- import type { TrackLeadRequest, TrackSaleRequest, TrackResponse } from "@vignesh/cms-sdk";
201
+ import { CMS } from "@vigneshreddy/cms-sdk";
202
+ import { trackLead, trackSale } from "@vigneshreddy/cms-sdk";
203
+ import { CMSAPIError } from "@vigneshreddy/cms-sdk";
204
+ import type { TrackLeadRequest, TrackSaleRequest, TrackResponse } from "@vigneshreddy/cms-sdk";
205
205
  ```
206
206
 
207
207
  ## Security
@@ -1,16 +1,25 @@
1
1
  import { CMS } from "../client";
2
- import type { TrackLeadRequest, TrackResponse } from "../generated/api";
2
+ import type { TrackResponse } from "../generated/api";
3
3
  import { Result } from "../types/result";
4
4
  import { CMSAPIError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, BadGatewayError, ServiceUnavailableError, GatewayTimeoutError } from "../errors";
5
5
  export type TrackLeadError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | ConflictError | UnprocessableEntityError | RateLimitError | InternalServerError | BadGatewayError | ServiceUnavailableError | GatewayTimeoutError | CMSAPIError;
6
+ export type LeadPayload = Record<string, unknown>;
6
7
  /**
7
8
  * Track a lead for a short link.
8
9
  *
9
10
  * Functional helper that returns a Result instead of throwing.
10
11
  * This allows for explicit error handling without try/catch.
11
12
  *
13
+ * This helper automatically wraps the user-provided data so that the
14
+ * underlying SDK receives:
15
+ *
16
+ * {
17
+ * type: "lead",
18
+ * lead: { ...userData }
19
+ * }
20
+ *
12
21
  * @param client - The CMSSDK instance
13
- * @param request - The track lead request payload
22
+ * @param leadData - Arbitrary user-provided lead data
14
23
  * @returns A Result containing either the TrackResponse or an error
15
24
  *
16
25
  * @example
@@ -33,4 +42,4 @@ export type TrackLeadError = BadRequestError | UnauthorizedError | ForbiddenErro
33
42
  * }
34
43
  * ```
35
44
  */
36
- export declare function trackLead(client: CMS, request: TrackLeadRequest): Promise<Result<TrackResponse, TrackLeadError>>;
45
+ export declare function trackLead(client: CMS, leadData: LeadPayload): Promise<Result<TrackResponse, TrackLeadError>>;
@@ -9,8 +9,16 @@ const errors_1 = require("../errors");
9
9
  * Functional helper that returns a Result instead of throwing.
10
10
  * This allows for explicit error handling without try/catch.
11
11
  *
12
+ * This helper automatically wraps the user-provided data so that the
13
+ * underlying SDK receives:
14
+ *
15
+ * {
16
+ * type: "lead",
17
+ * lead: { ...userData }
18
+ * }
19
+ *
12
20
  * @param client - The CMSSDK instance
13
- * @param request - The track lead request payload
21
+ * @param leadData - Arbitrary user-provided lead data
14
22
  * @returns A Result containing either the TrackResponse or an error
15
23
  *
16
24
  * @example
@@ -33,9 +41,13 @@ const errors_1 = require("../errors");
33
41
  * }
34
42
  * ```
35
43
  */
36
- async function trackLead(client, request) {
44
+ async function trackLead(client, leadData) {
37
45
  try {
38
- const value = await client.trackLead(request);
46
+ const payload = {
47
+ type: "lead",
48
+ lead: leadData,
49
+ };
50
+ const value = await client.trackLead(payload);
39
51
  return (0, result_1.ok)(value);
40
52
  }
41
53
  catch (error) {
@@ -1,16 +1,25 @@
1
1
  import { CMS } from "../client";
2
- import type { TrackSaleRequest, TrackResponse } from "../generated/api";
2
+ import type { TrackResponse } from "../generated/api";
3
3
  import { Result } from "../types/result";
4
4
  import { CMSAPIError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, BadGatewayError, ServiceUnavailableError, GatewayTimeoutError } from "../errors";
5
5
  export type TrackSaleError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | ConflictError | UnprocessableEntityError | RateLimitError | InternalServerError | BadGatewayError | ServiceUnavailableError | GatewayTimeoutError | CMSAPIError;
6
+ export type SalePayload = Record<string, unknown>;
6
7
  /**
7
8
  * Track a sale for a short link.
8
9
  *
9
10
  * Functional helper that returns a Result instead of throwing.
10
11
  * This allows for explicit error handling without try/catch.
11
12
  *
13
+ * This helper automatically wraps the user-provided data so that the
14
+ * underlying SDK receives:
15
+ *
16
+ * {
17
+ * type: "sale",
18
+ * sale: { ...userData }
19
+ * }
20
+ *
12
21
  * @param client - The CMSSDK instance
13
- * @param request - The track sale request payload
22
+ * @param saleData - Arbitrary user-provided sale data
14
23
  * @returns A Result containing either the TrackResponse or an error
15
24
  *
16
25
  * @example
@@ -35,4 +44,4 @@ export type TrackSaleError = BadRequestError | UnauthorizedError | ForbiddenErro
35
44
  * }
36
45
  * ```
37
46
  */
38
- export declare function trackSale(client: CMS, request: TrackSaleRequest): Promise<Result<TrackResponse, TrackSaleError>>;
47
+ export declare function trackSale(client: CMS, saleData: SalePayload): Promise<Result<TrackResponse, TrackSaleError>>;
@@ -9,8 +9,16 @@ const errors_1 = require("../errors");
9
9
  * Functional helper that returns a Result instead of throwing.
10
10
  * This allows for explicit error handling without try/catch.
11
11
  *
12
+ * This helper automatically wraps the user-provided data so that the
13
+ * underlying SDK receives:
14
+ *
15
+ * {
16
+ * type: "sale",
17
+ * sale: { ...userData }
18
+ * }
19
+ *
12
20
  * @param client - The CMSSDK instance
13
- * @param request - The track sale request payload
21
+ * @param saleData - Arbitrary user-provided sale data
14
22
  * @returns A Result containing either the TrackResponse or an error
15
23
  *
16
24
  * @example
@@ -35,9 +43,13 @@ const errors_1 = require("../errors");
35
43
  * }
36
44
  * ```
37
45
  */
38
- async function trackSale(client, request) {
46
+ async function trackSale(client, saleData) {
39
47
  try {
40
- const value = await client.trackSale(request);
48
+ const payload = {
49
+ type: "sale",
50
+ sale: saleData,
51
+ };
52
+ const value = await client.trackSale(payload);
41
53
  return (0, result_1.ok)(value);
42
54
  }
43
55
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vigneshreddy/cms-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Official TypeScript SDK for CutMeShort CMS API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",