@newpeak/barista-cli 0.2.312 → 0.2.313

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.
@@ -13040,6 +13040,81 @@ export const apiClient = {
13040
13040
  }
13041
13041
  },
13042
13042
  /// ========== DocumentController — save document metadata ==========
13043
+ /**
13044
+ * List document categories (code + name), used to resolve a category code.
13045
+ * GET /api/enterprise/document/category/list
13046
+ */
13047
+ async documentCategoryList(environment, tenant) {
13048
+ try {
13049
+ const token = await tokenManager.getToken({ service: 'liberica', environment, tenant });
13050
+ if (!token)
13051
+ return { success: false, error: { code: 'NO_TOKEN', message: 'Not logged in' } };
13052
+ const client = createAPIClient('liberica', environment, tenant);
13053
+ client.setAuthToken(token);
13054
+ const response = await client.getClient().get('/api/enterprise/document/category/list');
13055
+ const body = response.data;
13056
+ if (body && body.code === '00000')
13057
+ return { success: true, data: body.data };
13058
+ return {
13059
+ success: false,
13060
+ error: { code: body?.code || 'UNKNOWN', message: JSON.stringify(body?.data) || 'List categories failed' },
13061
+ };
13062
+ }
13063
+ catch (error) {
13064
+ return extractApiError(error);
13065
+ }
13066
+ },
13067
+ /**
13068
+ * List documents (optionally filtered by category).
13069
+ * GET /api/enterprise/document/page
13070
+ */
13071
+ async documentPage(environment, tenant, params) {
13072
+ try {
13073
+ const token = await tokenManager.getToken({ service: 'liberica', environment, tenant });
13074
+ if (!token)
13075
+ return { success: false, error: { code: 'NO_TOKEN', message: 'Not logged in' } };
13076
+ const client = createAPIClient('liberica', environment, tenant);
13077
+ client.setAuthToken(token);
13078
+ const query = {};
13079
+ if (params.categoryCode)
13080
+ query.categoryCode = params.categoryCode;
13081
+ if (params.fileName)
13082
+ query.fileName = params.fileName;
13083
+ query.pageNo = params.pageNo ?? 1;
13084
+ query.pageSize = params.pageSize ?? 20;
13085
+ const response = await client.getClient().get('/api/enterprise/document/page', { params: query });
13086
+ const body = response.data;
13087
+ if (body && body.code === '00000')
13088
+ return { success: true, data: body.data };
13089
+ return {
13090
+ success: false,
13091
+ error: { code: body?.code || 'UNKNOWN', message: JSON.stringify(body?.data) || 'List documents failed' },
13092
+ };
13093
+ }
13094
+ catch (error) {
13095
+ return extractApiError(error);
13096
+ }
13097
+ },
13098
+ /**
13099
+ * Download a document as raw bytes (images come back verbatim).
13100
+ * GET /api/enterprise/document/download
13101
+ */
13102
+ async downloadDocument(environment, tenant, documentId) {
13103
+ try {
13104
+ const token = await tokenManager.getToken({ service: 'liberica', environment, tenant });
13105
+ if (!token)
13106
+ return { success: false, error: { code: 'NO_TOKEN', message: 'Not logged in' } };
13107
+ const client = createAPIClient('liberica', environment, tenant);
13108
+ client.setAuthToken(token);
13109
+ const response = await client
13110
+ .getClient()
13111
+ .get('/api/enterprise/document/download', { params: { documentId }, responseType: 'arraybuffer' });
13112
+ return { success: true, data: Buffer.from(response.data) };
13113
+ }
13114
+ catch (error) {
13115
+ return extractApiError(error);
13116
+ }
13117
+ },
13043
13118
  /**
13044
13119
  * Save a document record associating an uploaded file with a category.
13045
13120
  * POST /api/enterprise/document/save