@in.pulse-crm/sdk 2.11.4 → 2.11.6
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/dist/files.client.js +36 -11
- package/dist/types/whatsapp.types.d.ts +9 -1
- package/package.json +1 -1
- package/src/files.client.ts +36 -11
- package/src/types/whatsapp.types.ts +35 -22
package/dist/files.client.js
CHANGED
|
@@ -43,19 +43,44 @@ class FilesClient extends api_client_1.default {
|
|
|
43
43
|
* @returns {Promise<File>} Os dados do arquivo enviado.
|
|
44
44
|
*/
|
|
45
45
|
async uploadFile(props) {
|
|
46
|
-
// Node: use 'form-data' (evita conflito de tipos com Blob)
|
|
47
46
|
const form = new form_data_1.default();
|
|
48
47
|
form.append("instance", props.instance);
|
|
49
|
-
form.append("dirType", props.dirType);
|
|
50
|
-
form.append("
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
form.append("dirType", String(props.dirType));
|
|
49
|
+
form.append("fileName", props.fileName);
|
|
50
|
+
const src = props.buffer;
|
|
51
|
+
let ab;
|
|
52
|
+
if (src instanceof ArrayBuffer) {
|
|
53
|
+
ab = src;
|
|
54
|
+
}
|
|
55
|
+
else if (typeof SharedArrayBuffer !== "undefined" && src instanceof SharedArrayBuffer) {
|
|
56
|
+
const view = new Uint8Array(src);
|
|
57
|
+
const copy = new Uint8Array(view.byteLength);
|
|
58
|
+
copy.set(view);
|
|
59
|
+
ab = copy.buffer;
|
|
60
|
+
}
|
|
61
|
+
else if (ArrayBuffer.isView(src)) {
|
|
62
|
+
const view = src;
|
|
63
|
+
const total = view.byteLength;
|
|
64
|
+
const offset = view.byteOffset ?? 0;
|
|
65
|
+
const backing = view.buffer;
|
|
66
|
+
if (typeof SharedArrayBuffer !== "undefined" && backing instanceof SharedArrayBuffer) {
|
|
67
|
+
const from = new Uint8Array(backing, offset, total);
|
|
68
|
+
const copy = new Uint8Array(total);
|
|
69
|
+
copy.set(from);
|
|
70
|
+
ab = copy.buffer;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
ab = backing.slice(offset, offset + total);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const u8 = Uint8Array.from(src);
|
|
78
|
+
ab = u8.buffer;
|
|
79
|
+
}
|
|
80
|
+
const blob = new Blob([ab], { type: props.mimeType || "application/octet-stream" });
|
|
81
|
+
form.append("file", blob, props.fileName);
|
|
82
|
+
const { data } = await this.ax.post("/api/files", form);
|
|
83
|
+
return data.data;
|
|
59
84
|
}
|
|
60
85
|
/**
|
|
61
86
|
* Deleta um arquivo pelo ID.
|
|
@@ -176,11 +176,19 @@ export interface PaginatedNotificationsResponse {
|
|
|
176
176
|
notifications: AppNotification[];
|
|
177
177
|
totalCount: number;
|
|
178
178
|
}
|
|
179
|
+
export type Frequency = 'ONCE' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
|
179
180
|
export interface AutomaticResponseSchedule {
|
|
180
181
|
id?: number;
|
|
181
|
-
|
|
182
|
+
frequency: Frequency;
|
|
183
|
+
daysOfWeek?: number[] | null;
|
|
184
|
+
dayOfMonth?: number | null;
|
|
185
|
+
month?: number | null;
|
|
186
|
+
startDate?: string | null;
|
|
187
|
+
endDate?: string | null;
|
|
182
188
|
startTime: string;
|
|
183
189
|
endTime: string;
|
|
190
|
+
timezone?: string | null;
|
|
191
|
+
dayOfWeek?: number | null;
|
|
184
192
|
}
|
|
185
193
|
export interface AutomaticResponseRule {
|
|
186
194
|
id: number;
|
package/package.json
CHANGED
package/src/files.client.ts
CHANGED
|
@@ -48,22 +48,47 @@ class FilesClient extends ApiClient {
|
|
|
48
48
|
* @returns {Promise<File>} Os dados do arquivo enviado.
|
|
49
49
|
*/
|
|
50
50
|
public async uploadFile(props: UploadFileOptions): Promise<File> {
|
|
51
|
-
// Node: use 'form-data' (evita conflito de tipos com Blob)
|
|
52
51
|
const form = new FormData();
|
|
53
52
|
form.append("instance", props.instance);
|
|
54
|
-
form.append("dirType", props.dirType);
|
|
53
|
+
form.append("dirType", String(props.dirType));
|
|
54
|
+
form.append("fileName", props.fileName);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
filename: props.fileName,
|
|
58
|
-
contentType: props.mimeType,
|
|
59
|
-
});
|
|
56
|
+
const src: any = props.buffer as any;
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
// deixe o boundary correto
|
|
63
|
-
headers: form.getHeaders(),
|
|
64
|
-
});
|
|
58
|
+
let ab: ArrayBuffer;
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
if (src instanceof ArrayBuffer) {
|
|
61
|
+
ab = src;
|
|
62
|
+
} else if (typeof SharedArrayBuffer !== "undefined" && src instanceof SharedArrayBuffer) {
|
|
63
|
+
const view = new Uint8Array(src);
|
|
64
|
+
const copy = new Uint8Array(view.byteLength);
|
|
65
|
+
copy.set(view);
|
|
66
|
+
ab = copy.buffer;
|
|
67
|
+
} else if (ArrayBuffer.isView(src)) {
|
|
68
|
+
const view = src as ArrayBufferView;
|
|
69
|
+
const total = view.byteLength;
|
|
70
|
+
const offset = (view as any).byteOffset ?? 0;
|
|
71
|
+
const backing: ArrayBufferLike = (view as any).buffer;
|
|
72
|
+
|
|
73
|
+
if (typeof SharedArrayBuffer !== "undefined" && backing instanceof SharedArrayBuffer) {
|
|
74
|
+
const from = new Uint8Array(backing, offset, total);
|
|
75
|
+
const copy = new Uint8Array(total);
|
|
76
|
+
copy.set(from);
|
|
77
|
+
ab = copy.buffer;
|
|
78
|
+
} else {
|
|
79
|
+
ab = (backing as ArrayBuffer).slice(offset, offset + total);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
const u8 = Uint8Array.from(src as ArrayLike<number>);
|
|
83
|
+
ab = u8.buffer;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const blob = new Blob([ab], { type: props.mimeType || "application/octet-stream" });
|
|
87
|
+
|
|
88
|
+
form.append("file", blob, props.fileName);
|
|
89
|
+
|
|
90
|
+
const { data } = await this.ax.post<DataResponse<File>>("/api/files", form);
|
|
91
|
+
return data.data;
|
|
67
92
|
}
|
|
68
93
|
|
|
69
94
|
/**
|
|
@@ -201,32 +201,45 @@ export interface PaginatedNotificationsResponse {
|
|
|
201
201
|
notifications: AppNotification[];
|
|
202
202
|
totalCount: number;
|
|
203
203
|
}
|
|
204
|
+
export type Frequency = 'ONCE' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
|
205
|
+
|
|
204
206
|
export interface AutomaticResponseSchedule {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
id?: number;
|
|
208
|
+
|
|
209
|
+
frequency: Frequency;
|
|
210
|
+
daysOfWeek?: number[] | null;
|
|
211
|
+
dayOfMonth?: number | null;
|
|
212
|
+
month?: number | null;
|
|
213
|
+
|
|
214
|
+
startDate?: string | null;
|
|
215
|
+
endDate?: string | null;
|
|
216
|
+
|
|
217
|
+
startTime: string;
|
|
218
|
+
endTime: string;
|
|
219
|
+
timezone?: string | null;
|
|
220
|
+
|
|
221
|
+
dayOfWeek?: number | null;
|
|
209
222
|
}
|
|
210
223
|
|
|
211
224
|
export interface AutomaticResponseRule {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
id: number;
|
|
226
|
+
name: string;
|
|
227
|
+
message: string;
|
|
228
|
+
isEnabled: boolean;
|
|
229
|
+
isGlobal: boolean;
|
|
230
|
+
cooldownSeconds: number;
|
|
231
|
+
fileId: number | null;
|
|
232
|
+
schedules: AutomaticResponseSchedule[];
|
|
233
|
+
userAssignments: { userId: number }[];
|
|
221
234
|
}
|
|
222
235
|
|
|
223
236
|
export interface AutomaticResponseRuleDTO {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
237
|
+
name: string;
|
|
238
|
+
message: string;
|
|
239
|
+
isEnabled: boolean;
|
|
240
|
+
isGlobal: boolean;
|
|
241
|
+
cooldownSeconds: number;
|
|
242
|
+
fileId?: number | null;
|
|
243
|
+
userIds: number[];
|
|
244
|
+
schedules: Omit<AutomaticResponseSchedule, "id">[];
|
|
245
|
+
}
|