@vigneshreddy/cms-sdk 1.0.2 → 1.0.4

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.
@@ -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,26 +1,30 @@
1
1
  {
2
2
  "name": "@vigneshreddy/cms-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Official TypeScript SDK for CutMeShort CMS API",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
7
  "type": "commonjs",
8
8
  "exports": {
9
9
  ".": {
10
- "require": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
10
+ "require": "./dist/src/index.js",
11
+ "import": "./dist/src/index.js",
12
+ "types": "./dist/src/index.d.ts"
12
13
  },
13
14
  "./client": {
14
- "require": "./dist/client.js",
15
- "types": "./dist/client.d.ts"
15
+ "require": "./dist/src/client.js",
16
+ "import": "./dist/src/client.js",
17
+ "types": "./dist/src/client.d.ts"
16
18
  },
17
19
  "./errors": {
18
- "require": "./dist/errors/index.js",
19
- "types": "./dist/errors/index.d.ts"
20
+ "require": "./dist/src/errors/index.js",
21
+ "import": "./dist/src/errors/index.js",
22
+ "types": "./dist/src/errors/index.d.ts"
20
23
  },
21
24
  "./funcs": {
22
- "require": "./dist/funcs/index.js",
23
- "types": "./dist/funcs/index.d.ts"
25
+ "require": "./dist/src/funcs/index.js",
26
+ "import": "./dist/src/funcs/index.js",
27
+ "types": "./dist/src/funcs/index.d.ts"
24
28
  }
25
29
  },
26
30
  "files": [