@newpeak/barista-cli 0.2.194 → 0.2.196

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.
@@ -11505,6 +11505,44 @@ export const apiClient = {
11505
11505
  return extractApiError(error);
11506
11506
  }
11507
11507
  },
11508
+ async uploadDocument(environment, tenant, filePath, categoryCode, businessData, remark, timeout) {
11509
+ try {
11510
+ const token = await tokenManager.getToken({ service: 'liberica', environment, tenant });
11511
+ if (!token)
11512
+ return { success: false, error: { code: 'NO_TOKEN', message: 'Not logged in' } };
11513
+ const client = createAPIClient('liberica', environment, tenant);
11514
+ client.setAuthToken(token);
11515
+ const { createReadStream } = await import('node:fs');
11516
+ const { basename } = await import('node:path');
11517
+ const FormData = (await import('form-data')).default;
11518
+ const formData = new FormData();
11519
+ formData.append('file', createReadStream(filePath), basename(filePath));
11520
+ if (categoryCode)
11521
+ formData.append('categoryCode', categoryCode);
11522
+ if (businessData)
11523
+ formData.append('businessData', businessData);
11524
+ if (remark)
11525
+ formData.append('remark', remark);
11526
+ const axiosConfig = {
11527
+ headers: formData.getHeaders(),
11528
+ };
11529
+ if (timeout !== undefined) {
11530
+ axiosConfig.timeout = timeout;
11531
+ }
11532
+ const response = await client.getClient().post('/api/enterprise/document/upload', formData, axiosConfig);
11533
+ const body = response.data;
11534
+ if (body && body.code === '00000') {
11535
+ return { success: true, data: body.data };
11536
+ }
11537
+ return {
11538
+ success: false,
11539
+ error: { code: body?.code || 'UNKNOWN', message: JSON.stringify(body?.data) || 'Upload failed' },
11540
+ };
11541
+ }
11542
+ catch (error) {
11543
+ return extractApiError(error);
11544
+ }
11545
+ },
11508
11546
  async uploadSysFile(environment, tenant, filePath, secretFlag = 'N', timeout) {
11509
11547
  try {
11510
11548
  const token = await tokenManager.getToken({ service: 'liberica', environment, tenant });