@or-sdk/sku-builder 2.1.0 → 2.1.1-beta.4012.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.
@@ -1,89 +1,13 @@
1
1
  import { AxiosError, Base } from '@or-sdk/base';
2
2
  import { Mapping, Options, SkuBuilderConfig } from './types';
3
- /**
4
- * OneReach SkuBuilder service
5
- * ## Installation:
6
- * ```
7
- * $ npm i @or-sdk/sku-builder
8
- * ```
9
- */
10
3
  export declare class SkuBuilder extends Base {
11
4
  private readonly userToken?;
12
5
  private readonly billingApiUrl?;
13
6
  private mapping;
14
7
  private withApiErrorLog;
15
- /**
16
- * @param {SkuBuilderConfig} [params]
17
- * Configuration parameters for the SkuBuilder.
18
- *
19
- * @param {string} [params.token]
20
- * The account token for authentication.
21
- *
22
- * @param {string} [params.billingApiUrl]
23
- * The URL for the billing API.
24
- *
25
- * @param {string} [params.discoveryUrl]
26
- * The URL for the discovery service.
27
- *
28
- * @param {Array<Mapping>} [params.mapping]
29
- * Optional mapping configurations.
30
- * In case this parameter empty SDK gets all mappings and apply it authomaticaly
31
- *
32
- * @param {boolean} [params.withApiErrorLog]
33
- * Flag to enable API error logging.
34
- *
35
- * @example
36
- * ```typescript
37
- * import { SkuBuilder } from '@or-sdk/sku-builder'
38
- * const skuBuilder = new SkuBuilder({
39
- * token: 'my-account-token-string',
40
- * billingApiUrl: 'https://billing.ops-dev.api.onereach.ai',
41
- * discoveryUrl: 'http://example.billing.ops-dev/endpoint',
42
- * mapping: 'array-of-mapping-collections'
43
- * });
44
- * ```
45
- */
46
8
  constructor(params?: SkuBuilderConfig);
47
- /**
48
- * The method gets SKU mapping collections.
49
- *
50
- * @returns {Array<Mapping>} array of mapping collections
51
- */
52
9
  getMapping(): Promise<Mapping[]>;
53
- /**
54
- * Generates SKUs for incoming events.
55
- * This function processes an array of incoming event objects, all of which should belong to the same
56
- * type (`type`). Based on the `type`, the function determines the appropriate SKU generation
57
- * logic. It then extends each event object with generated SKU identifiers and associated amount properties.
58
- *
59
- * @param {Array<Object>} payload
60
- * An array of incoming event objects. Each event should conform to the expected structure based on the `type`.
61
- * All events in the array must belong to the same category or type as specified by `type`.
62
- *
63
- * @param {type} type
64
- * A string representing the type or category of the events. This parameter dictates the SKU generation strategy.
65
- * Examples might include `"flow-processing"`, `"executable"`, `"text-messaging"`, etc.
66
- *
67
- * @param {Object} [options={}]
68
- * Optional parameters to control the flow processing behavior. These options can customize how SKUs are generated
69
- * or how the events are processed. If not provided, default processing rules will apply.
70
- *
71
- * @property {boolean} [options.isProcessingSegment=false]
72
- * Determines whether each SKU should be generated in segements. By defult each SKU are generating in minutes.
73
- *
74
- * @returns {Array<Object>}
75
- * Returns a new array of event objects, each extended with the following additional properties:
76
- *
77
- * - `SKU` (string): The generated SKU identifier for the event.
78
- * - `Amount` (number): The calculated amount associated with the SKU, based on event data and processing rules.
79
- */
80
10
  makeSku<T extends Record<string, unknown>>(payload: T[], type: string, options?: Options): Promise<(Record<"SKU" | "Amount", unknown> & T)[]>;
81
- /**
82
- * Parses an AxiosError and returns a standardized Error object.
83
- *
84
- * @param {AxiosError} e - The AxiosError instance to be parsed.
85
- * @returns {Error} A new Error object containing the error code, message, and stack trace.
86
- */
87
11
  parseError(e: AxiosError): Error;
88
12
  private logApiError;
89
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SkuBuilder.d.ts","sourceRoot":"","sources":["../../src/SkuBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAS,MAAM,cAAc,CAAC;AAKvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAwB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAInF;;;;;;GAMG;AACH,qBAAa,UAAW,SAAQ,IAAI;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAS;IACxC,OAAO,CAAC,OAAO,CAAwB;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ata?: object;
9
9
  };
10
10
  export type SkuBuilderConfig = {
11
- /**
12
- * Token
13
- */
14
11
  token?: Token;
15
- /**
16
- * URL of Billing Api
17
- */
18
12
  billingApiUrl?: string;
19
- /**
20
- * Service discovery URL
21
- */
22
13
  discoveryUrl?: string;
23
- /**
24
- * If true, the API error details like request url, params and body,
25
- * will be outputted to console
26
- */
27
14
  withApiErrorLog?: boolean;
28
- /**
29
- * SKU mapping
30
- */
31
15
  mapping?: Array<Mapping>;
32
16
  };
33
17
  export type Options = {
@@ -48,9 +32,6 @@ export declare enum CategoryNamespace {
48
32
  STORAGE_GENERAL = "storage-general",
49
33
  STORAGE_WEAVIATE = "storage-weaviate"
50
34
  }
51
- /**
52
- * @deprecated use CategoryNamespace
53
- */
54
35
  export declare enum UsageQueryType {
55
36
  FLOW_PROCESSING = "processing-flow",
56
37
  VOICE_PROCESSING = "processing-voice",
@@ -63,16 +44,10 @@ export declare enum UsageQueryType {
63
44
  WEAVIATE_STORAGE = "storage-weaviate",
64
45
  GENERAL_STORAGE = "storage-general"
65
46
  }
66
- /**
67
- * @deprecated use CategoryNamespace
68
- */
69
47
  export declare enum UsageResourcesQueryType {
70
48
  USER = "user",
71
49
  IDENTIFIER = "identifier"
72
50
  }
73
- /**
74
- * @deprecated use CategoryNamespace
75
- */
76
51
  export type QueryType = UsageQueryType | UsageResourcesQueryType;
77
52
  export type PaginatedResponseDto<T> = {
78
53
  total: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MA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gB,qBAAqC;IACrD,eAAe,oBAAoC;CACpD;AAKD,oBAAY,uBAAuB;IACjC,IAAI,SAAyB;IAC7B,UAAU,eAA+B;CAC1C;AAKD,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,uBAAuB,CAAC;AAEjE,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,CAAC;CACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@or-sdk/sku-builder",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-beta.4012.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -21,7 +21,7 @@
21
21
  "test:watch": "vitest --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@or-sdk/base": "^0.43.0",
24
+ "@or-sdk/base": "^0.44.0-beta.4012.0",
25
25
  "lodash.clonedeep": "^4.5.0"
26
26
  },
27
27
  "devDependencies": {
@@ -32,6 +32,5 @@
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
- },
36
- "gitHead": "ce62679c119c54ef41fd0d8f7084c563c3b21b24"
35
+ }
37
36
  }