UNPKG

@vulog/aima-document

Version:

83 lines (78 loc) 2.88 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { createOrUpdateDocument: () => createOrUpdateDocument, getUserDocuments: () => getUserDocuments, updateDocumentStatus: () => updateDocumentStatus }); module.exports = __toCommonJS(index_exports); // src/createOrUpdateDocument.ts var import_zod = require("zod"); var schema = import_zod.z.object({ userId: import_zod.z.string().nonempty().uuid() }); var createOrUpdateDocument = async (client, userId, document) => { const result = schema.safeParse({ userId }); if (!result.success) { throw new TypeError("Invalid args", { cause: result.error.issues }); } return client.post( `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`, document ).then(({ data }) => data); }; // src/getUserDocuments.ts var import_zod2 = require("zod"); var schema2 = import_zod2.z.object({ userId: import_zod2.z.string().trim().nonempty().uuid() }); var getUserDocuments = async (client, userId) => { const result = schema2.safeParse({ userId }); if (!result.success) { throw new TypeError("Invalid args", { cause: result.error.issues }); } return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`).then(({ data }) => data); }; // src/updateDocumentStatus.ts var import_zod3 = require("zod"); var schema3 = import_zod3.z.object({ userId: import_zod3.z.string().nonempty().uuid(), documentId: import_zod3.z.number().nonnegative().int() }); var updateDocumentStatus = async (client, userId, documentId, document) => { const result = schema3.safeParse({ userId, documentId }); if (!result.success) { throw new TypeError("Invalid args", { cause: result.error.issues }); } return client.put(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/documents/${documentId}`, document).then(({ data }) => data); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createOrUpdateDocument, getUserDocuments, updateDocumentStatus });