pyrus-api 2.2.1 → 2.3.1

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.
@@ -176,6 +176,9 @@ function processFilters(filters) {
176
176
  return prev;
177
177
  }, {});
178
178
  }
179
+ function prepareHeadersForCatalogApiRequest(headers) {
180
+ return headers.map((header) => typeof header === "string" ? header : header.name);
181
+ }
179
182
 
180
183
  class ApiError extends Error {
181
184
  constructor({ code, error }) {
@@ -751,7 +754,8 @@ class CatalogsApi extends BaseApi {
751
754
  }
752
755
  sync(request) {
753
756
  return __awaiter(this, void 0, void 0, function* () {
754
- return yield this.fetchApi((yield this.getModulePath()) + `/${request.id}`, "POST", JSON.stringify(request));
757
+ const apiRequest = Object.assign(Object.assign({}, request), { catalog_headers: prepareHeadersForCatalogApiRequest(request.catalog_headers) });
758
+ return yield this.fetchApi((yield this.getModulePath()) + `/${request.id}`, "POST", JSON.stringify(apiRequest));
755
759
  });
756
760
  }
757
761
  }
@@ -1060,6 +1064,7 @@ exports.SendSmsError = SendSmsError;
1060
1064
  exports.SendSmsStatus = SendSmsStatus;
1061
1065
  exports.SourceType = SourceType;
1062
1066
  exports.fromJson = fromJson;
1067
+ exports.prepareHeadersForCatalogApiRequest = prepareHeadersForCatalogApiRequest;
1063
1068
  exports.toDateString = toDateString;
1064
1069
  exports.toDateTimeString = toDateTimeString;
1065
1070
  exports.toJson = toJson;
@@ -174,6 +174,9 @@ function processFilters(filters) {
174
174
  return prev;
175
175
  }, {});
176
176
  }
177
+ function prepareHeadersForCatalogApiRequest(headers) {
178
+ return headers.map((header) => typeof header === "string" ? header : header.name);
179
+ }
177
180
 
178
181
  class ApiError extends Error {
179
182
  constructor({ code, error }) {
@@ -749,7 +752,8 @@ class CatalogsApi extends BaseApi {
749
752
  }
750
753
  sync(request) {
751
754
  return __awaiter(this, void 0, void 0, function* () {
752
- return yield this.fetchApi((yield this.getModulePath()) + `/${request.id}`, "POST", JSON.stringify(request));
755
+ const apiRequest = Object.assign(Object.assign({}, request), { catalog_headers: prepareHeadersForCatalogApiRequest(request.catalog_headers) });
756
+ return yield this.fetchApi((yield this.getModulePath()) + `/${request.id}`, "POST", JSON.stringify(apiRequest));
753
757
  });
754
758
  }
755
759
  }
@@ -1042,4 +1046,4 @@ class PyrusApiClient extends BaseApi {
1042
1046
  }
1043
1047
  }
1044
1048
 
1045
- export { ActivityAction, ApiError, ApprovalChoice, CallEventType, ErrorCodeType, FilterMask, Flag, FormFieldType, ListType, OperatorId, PermissionLevel, PersonRights, PersonType, PyrusApiClient, SendSmsError, SendSmsStatus, SourceType, fromJson, toDateString, toDateTimeString, toJson, toTimeString };
1049
+ export { ActivityAction, ApiError, ApprovalChoice, CallEventType, ErrorCodeType, FilterMask, Flag, FormFieldType, ListType, OperatorId, PermissionLevel, PersonRights, PersonType, PyrusApiClient, SendSmsError, SendSmsStatus, SourceType, fromJson, prepareHeadersForCatalogApiRequest, toDateString, toDateTimeString, toJson, toTimeString };
@@ -13,11 +13,20 @@ declare module "pyrus-api" {
13
13
  operator_id: OperatorId;
14
14
  values: string[];
15
15
  };
16
+ export type CatalogHeader = {
17
+ name: string;
18
+ type: CatalogHeaderType;
19
+ };
20
+ enum CatalogHeaderType {
21
+ Text = "text",
22
+ Workflow = "workflow"
23
+ }
16
24
  export function toJson(obj: any): string;
17
25
  export function fromJson<T = any>(str: string): T;
18
26
  export function toDateTimeString(date: Date | string): string;
19
27
  export function toDateString(date: Date | string): string;
20
28
  export function toTimeString(date: Date | string): string;
29
+ export function prepareHeadersForCatalogApiRequest(headers: string[] | CatalogHeader[]): string[];
21
30
  export const ErrorCodeType: {
22
31
  readonly ServerError: "server_error";
23
32
  readonly AuthorizationError: "authorization_error";
@@ -662,6 +671,7 @@ declare module "pyrus-api" {
662
671
  parent_task_id?: number;
663
672
  last_note_id?: number;
664
673
  subject?: string;
674
+ current_step?: number;
665
675
  is_closed: boolean;
666
676
  };
667
677
  export type Role = {
@@ -1049,14 +1059,6 @@ declare module "pyrus-api" {
1049
1059
  export type CatalogsResponse = {
1050
1060
  catalogs: CatalogInfo[];
1051
1061
  };
1052
- export type CatalogHeader = {
1053
- name: string;
1054
- type: CatalogHeaderType;
1055
- };
1056
- enum CatalogHeaderType {
1057
- Text = "text",
1058
- Workflow = "workflow"
1059
- }
1060
1062
  export type CatalogItemResponse = CatalogItem & {
1061
1063
  item_id: number;
1062
1064
  };
@@ -1090,11 +1092,14 @@ declare module "pyrus-api" {
1090
1092
  name: string;
1091
1093
  source_type?: SourceType;
1092
1094
  };
1093
- export type SyncCatalogRequest = CatalogRequestBase & {
1095
+ export type SyncCatalogRequestApi = CatalogRequestBase & {
1094
1096
  id: number;
1095
1097
  apply: boolean;
1096
1098
  force_update_first_column?: boolean;
1097
1099
  };
1100
+ export type SyncCatalogRequest = Omit<SyncCatalogRequestApi, "catalog_headers"> & {
1101
+ catalog_headers: string[] | CatalogHeader[];
1102
+ };
1098
1103
  export type SyncCatalogResponse = {
1099
1104
  apply: boolean;
1100
1105
  added?: CatalogItemResponse[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyrus-api",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "description": "Pyrus API client for TypeScript",
5
5
  "repository": {
6
6
  "type": "git",