@webitel/api-services 0.1.19 → 0.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/api-services",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "make-all": "npm run gen:api && npm version patch && (npm run build:types || true) && (npm run format:all || true) && npm run publish-lib",
@@ -80,6 +80,10 @@
80
80
  "types": "./types/utils/index.d.ts",
81
81
  "import": "./src/utils/index.ts"
82
82
  },
83
+ "./scripts": {
84
+ "types": "./types/scripts/index.d.ts",
85
+ "import": "./src/scripts/index.ts"
86
+ },
83
87
  "./gen/utils": {
84
88
  "types": "./types/utils/gen/index.d.ts",
85
89
  "import": "./src/utils/gen/index.ts"
@@ -0,0 +1,11 @@
1
+ const valuePrefix = 'rdt'; /* stands for relative datetime */
2
+
3
+ export const RelativeDatetimeValue = {
4
+ Today: `${valuePrefix}_today`,
5
+ ThisWeek: `${valuePrefix}_this_week`,
6
+ ThisMonth: `${valuePrefix}_this_month`,
7
+ Custom: `${valuePrefix}_custom`,
8
+ } as const;
9
+
10
+ export type RelativeDatetimeValue =
11
+ (typeof RelativeDatetimeValue)[keyof typeof RelativeDatetimeValue];
@@ -1,3 +1,4 @@
1
1
  import { ChatGatewayProvider } from './ChatGatewayProvider/ChatGatewayPrivider';
2
+ import { RelativeDatetimeValue } from './RelativeDatetimeValue/RelativeDatetimeValue';
2
3
 
3
- export { ChatGatewayProvider };
4
+ export { ChatGatewayProvider, RelativeDatetimeValue };
@@ -0,0 +1,36 @@
1
+ import type { DownloadFileOptions } from './types/downloadFile.types';
2
+
3
+ const downloadFile = ({
4
+ response,
5
+ fileFormat,
6
+ filename,
7
+ mimetype = null,
8
+ }: DownloadFileOptions) => {
9
+ const blob = new Blob(
10
+ [
11
+ response.data,
12
+ ],
13
+ {
14
+ type:
15
+ mimetype ||
16
+ response.headers?.['content-type'] ||
17
+ 'application/octet-stream',
18
+ },
19
+ );
20
+
21
+ const url = window.URL.createObjectURL(blob);
22
+ const link = document.createElement('a');
23
+
24
+ link.href = url;
25
+ link.download = filename
26
+ ? `${filename}.${fileFormat}`
27
+ : `${response.headers?.['Content-Disposition']}.${fileFormat}`;
28
+
29
+ document.body.appendChild(link);
30
+ link.click();
31
+ link.remove();
32
+
33
+ window.URL.revokeObjectURL(url);
34
+ };
35
+
36
+ export default downloadFile;
@@ -0,0 +1,8 @@
1
+ import type { FileFormat } from './fileFormat.types';
2
+
3
+ export interface DownloadFileOptions {
4
+ response: any;
5
+ fileFormat: FileFormat;
6
+ filename?: string;
7
+ mimetype?: string;
8
+ }
@@ -0,0 +1,4 @@
1
+ export enum FileFormat {
2
+ CSV = 'csv',
3
+ XLSX = 'xlsx',
4
+ }
@@ -1,3 +1,4 @@
1
1
  import convertDuration from './convertDuration/convertDuration';
2
+ import downloadFile from './downloadFile/downloadFile';
2
3
 
3
- export { convertDuration };
4
+ export { convertDuration, downloadFile };
@@ -0,0 +1,7 @@
1
+ export declare const RelativeDatetimeValue: {
2
+ readonly Today: "rdt_today";
3
+ readonly ThisWeek: "rdt_this_week";
4
+ readonly ThisMonth: "rdt_this_month";
5
+ readonly Custom: "rdt_custom";
6
+ };
7
+ export type RelativeDatetimeValue = (typeof RelativeDatetimeValue)[keyof typeof RelativeDatetimeValue];
@@ -1,2 +1,3 @@
1
1
  import { ChatGatewayProvider } from './ChatGatewayProvider/ChatGatewayPrivider';
2
- export { ChatGatewayProvider };
2
+ import { RelativeDatetimeValue } from './RelativeDatetimeValue/RelativeDatetimeValue';
3
+ export { ChatGatewayProvider, RelativeDatetimeValue };
@@ -0,0 +1,3 @@
1
+ import type { DownloadFileOptions } from './types/downloadFile.types';
2
+ declare const downloadFile: ({ response, fileFormat, filename, mimetype, }: DownloadFileOptions) => void;
3
+ export default downloadFile;
@@ -0,0 +1,7 @@
1
+ import type { FileFormat } from './fileFormat.types';
2
+ export interface DownloadFileOptions {
3
+ response: any;
4
+ fileFormat: FileFormat;
5
+ filename?: string;
6
+ mimetype?: string;
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare enum FileFormat {
2
+ CSV = "csv",
3
+ XLSX = "xlsx"
4
+ }
@@ -1,2 +1,3 @@
1
1
  import convertDuration from './convertDuration/convertDuration';
2
- export { convertDuration };
2
+ import downloadFile from './downloadFile/downloadFile';
3
+ export { convertDuration, downloadFile };