@vulog/aima-document 1.1.22 → 1.1.23

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/index.d.mts CHANGED
@@ -35,6 +35,9 @@ type DocumentFull = {
35
35
  issuingDate: string;
36
36
  dlClass: string;
37
37
  };
38
+ type DocumentCreate = Partial<Omit<DocumentFull, 'id' | 'fleetId' | 'documentType' | 'files' | 'uploadUrls'>> & {
39
+ documentType: string;
40
+ };
38
41
  type DocumentByService = {
39
42
  serviceId: string;
40
43
  areMandatoryPresent: boolean;
@@ -52,6 +55,8 @@ type DocumentSummary = {
52
55
  documentByFranchise: DocumentByFranchise[] | null;
53
56
  };
54
57
 
58
+ declare const createDocument: (client: Client, userId: string, document: DocumentCreate) => Promise<DocumentFull>;
59
+
55
60
  declare const getUserDocuments: (client: Client, userId: string) => Promise<DocumentSummary>;
56
61
 
57
- export { type DocumentByFranchise, type DocumentByService, type DocumentFull, type DocumentSummary, type DocumentType, type FileUrl, getUserDocuments };
62
+ export { type DocumentByFranchise, type DocumentByService, type DocumentCreate, type DocumentFull, type DocumentSummary, type DocumentType, type FileUrl, createDocument, getUserDocuments };
package/dist/index.d.ts CHANGED
@@ -35,6 +35,9 @@ type DocumentFull = {
35
35
  issuingDate: string;
36
36
  dlClass: string;
37
37
  };
38
+ type DocumentCreate = Partial<Omit<DocumentFull, 'id' | 'fleetId' | 'documentType' | 'files' | 'uploadUrls'>> & {
39
+ documentType: string;
40
+ };
38
41
  type DocumentByService = {
39
42
  serviceId: string;
40
43
  areMandatoryPresent: boolean;
@@ -52,6 +55,8 @@ type DocumentSummary = {
52
55
  documentByFranchise: DocumentByFranchise[] | null;
53
56
  };
54
57
 
58
+ declare const createDocument: (client: Client, userId: string, document: DocumentCreate) => Promise<DocumentFull>;
59
+
55
60
  declare const getUserDocuments: (client: Client, userId: string) => Promise<DocumentSummary>;
56
61
 
57
- export { type DocumentByFranchise, type DocumentByService, type DocumentFull, type DocumentSummary, type DocumentType, type FileUrl, getUserDocuments };
62
+ export { type DocumentByFranchise, type DocumentByService, type DocumentCreate, type DocumentFull, type DocumentSummary, type DocumentType, type FileUrl, createDocument, getUserDocuments };
package/dist/index.js CHANGED
@@ -20,14 +20,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ createDocument: () => createDocument,
23
24
  getUserDocuments: () => getUserDocuments
24
25
  });
25
26
  module.exports = __toCommonJS(index_exports);
26
27
 
27
- // src/getUserDocuments.ts
28
+ // src/createDocument.ts
28
29
  var import_zod = require("zod");
29
- var schema = import_zod.z.object({
30
- userId: import_zod.z.string().trim().nonempty().uuid()
30
+ var createDocument = async (client, userId, document) => {
31
+ const result = import_zod.z.string().nonempty().uuid().safeParse({ userId });
32
+ if (!result.success) {
33
+ throw new TypeError("Invalid args", {
34
+ cause: result.error.issues
35
+ });
36
+ }
37
+ return client.post(
38
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`,
39
+ document
40
+ ).then(({ data }) => data);
41
+ };
42
+
43
+ // src/getUserDocuments.ts
44
+ var import_zod2 = require("zod");
45
+ var schema = import_zod2.z.object({
46
+ userId: import_zod2.z.string().trim().nonempty().uuid()
31
47
  });
32
48
  var getUserDocuments = async (client, userId) => {
33
49
  const result = schema.safeParse({ userId });
@@ -40,5 +56,6 @@ var getUserDocuments = async (client, userId) => {
40
56
  };
41
57
  // Annotate the CommonJS export names for ESM import in node:
42
58
  0 && (module.exports = {
59
+ createDocument,
43
60
  getUserDocuments
44
61
  });
package/dist/index.mjs CHANGED
@@ -1,7 +1,22 @@
1
- // src/getUserDocuments.ts
1
+ // src/createDocument.ts
2
2
  import { z } from "zod";
3
- var schema = z.object({
4
- userId: z.string().trim().nonempty().uuid()
3
+ var createDocument = async (client, userId, document) => {
4
+ const result = z.string().nonempty().uuid().safeParse({ userId });
5
+ if (!result.success) {
6
+ throw new TypeError("Invalid args", {
7
+ cause: result.error.issues
8
+ });
9
+ }
10
+ return client.post(
11
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`,
12
+ document
13
+ ).then(({ data }) => data);
14
+ };
15
+
16
+ // src/getUserDocuments.ts
17
+ import { z as z2 } from "zod";
18
+ var schema = z2.object({
19
+ userId: z2.string().trim().nonempty().uuid()
5
20
  });
6
21
  var getUserDocuments = async (client, userId) => {
7
22
  const result = schema.safeParse({ userId });
@@ -13,5 +28,6 @@ var getUserDocuments = async (client, userId) => {
13
28
  return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`).then(({ data }) => data);
14
29
  };
15
30
  export {
31
+ createDocument,
16
32
  getUserDocuments
17
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulog/aima-document",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "author": "Vulog",
20
20
  "license": "ISC",
21
21
  "dependencies": {
22
- "@vulog/aima-client": "1.1.22",
23
- "@vulog/aima-core": "1.1.22"
22
+ "@vulog/aima-client": "1.1.23",
23
+ "@vulog/aima-core": "1.1.23"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "zod": "^3.24.1"
@@ -0,0 +1,24 @@
1
+ import { Client } from '@vulog/aima-client';
2
+ import { z } from 'zod';
3
+
4
+ import { DocumentCreate, DocumentFull } from './types';
5
+
6
+ export const createDocument = async (
7
+ client: Client,
8
+ userId: string,
9
+ document: DocumentCreate
10
+ ): Promise<DocumentFull> => {
11
+ const result = z.string().nonempty().uuid().safeParse({ userId });
12
+ if (!result.success) {
13
+ throw new TypeError('Invalid args', {
14
+ cause: result.error.issues,
15
+ });
16
+ }
17
+
18
+ return client
19
+ .post<DocumentFull>(
20
+ `/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`,
21
+ document
22
+ )
23
+ .then(({ data }) => data);
24
+ };
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './createDocument';
1
2
  export * from './getUserDocuments';
2
3
  export * from './types';
package/src/types.ts CHANGED
@@ -286,6 +286,10 @@ export type DocumentFull = {
286
286
  dlClass: string;
287
287
  };
288
288
 
289
+ export type DocumentCreate = Partial<Omit<DocumentFull, 'id' | 'fleetId' | 'documentType' | 'files' | 'uploadUrls'>> & {
290
+ documentType: string;
291
+ };
292
+
289
293
  export type DocumentByService = {
290
294
  serviceId: string;
291
295
  areMandatoryPresent: boolean;