@vulog/aima-document 1.1.22 → 1.1.24
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 +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +46 -5
- package/dist/index.mjs +43 -4
- package/package.json +3 -3
- package/src/createDocument.ts +28 -0
- package/src/index.ts +2 -0
- package/src/types.ts +6 -0
- package/src/updateDocument.ts +30 -0
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,10 @@ 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
|
+
};
|
|
41
|
+
type DocumentUpdate = DocumentCreate;
|
|
38
42
|
type DocumentByService = {
|
|
39
43
|
serviceId: string;
|
|
40
44
|
areMandatoryPresent: boolean;
|
|
@@ -52,6 +56,10 @@ type DocumentSummary = {
|
|
|
52
56
|
documentByFranchise: DocumentByFranchise[] | null;
|
|
53
57
|
};
|
|
54
58
|
|
|
59
|
+
declare const createDocument: (client: Client, userId: string, document: DocumentCreate) => Promise<DocumentFull>;
|
|
60
|
+
|
|
55
61
|
declare const getUserDocuments: (client: Client, userId: string) => Promise<DocumentSummary>;
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
declare const updateDocument: (client: Client, userId: string, documentId: number, document: DocumentUpdate) => Promise<DocumentFull>;
|
|
64
|
+
|
|
65
|
+
export { type DocumentByFranchise, type DocumentByService, type DocumentCreate, type DocumentFull, type DocumentSummary, type DocumentType, type DocumentUpdate, type FileUrl, createDocument, getUserDocuments, updateDocument };
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ 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
|
+
};
|
|
41
|
+
type DocumentUpdate = DocumentCreate;
|
|
38
42
|
type DocumentByService = {
|
|
39
43
|
serviceId: string;
|
|
40
44
|
areMandatoryPresent: boolean;
|
|
@@ -52,6 +56,10 @@ type DocumentSummary = {
|
|
|
52
56
|
documentByFranchise: DocumentByFranchise[] | null;
|
|
53
57
|
};
|
|
54
58
|
|
|
59
|
+
declare const createDocument: (client: Client, userId: string, document: DocumentCreate) => Promise<DocumentFull>;
|
|
60
|
+
|
|
55
61
|
declare const getUserDocuments: (client: Client, userId: string) => Promise<DocumentSummary>;
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
declare const updateDocument: (client: Client, userId: string, documentId: number, document: DocumentUpdate) => Promise<DocumentFull>;
|
|
64
|
+
|
|
65
|
+
export { type DocumentByFranchise, type DocumentByService, type DocumentCreate, type DocumentFull, type DocumentSummary, type DocumentType, type DocumentUpdate, type FileUrl, createDocument, getUserDocuments, updateDocument };
|
package/dist/index.js
CHANGED
|
@@ -20,25 +20,66 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
23
|
+
createDocument: () => createDocument,
|
|
24
|
+
getUserDocuments: () => getUserDocuments,
|
|
25
|
+
updateDocument: () => updateDocument
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(index_exports);
|
|
26
28
|
|
|
27
|
-
// src/
|
|
29
|
+
// src/createDocument.ts
|
|
28
30
|
var import_zod = require("zod");
|
|
29
31
|
var schema = import_zod.z.object({
|
|
30
|
-
userId: import_zod.z.string().
|
|
32
|
+
userId: import_zod.z.string().nonempty().uuid()
|
|
31
33
|
});
|
|
32
|
-
var
|
|
34
|
+
var createDocument = async (client, userId, document) => {
|
|
33
35
|
const result = schema.safeParse({ userId });
|
|
34
36
|
if (!result.success) {
|
|
35
37
|
throw new TypeError("Invalid args", {
|
|
36
38
|
cause: result.error.issues
|
|
37
39
|
});
|
|
38
40
|
}
|
|
41
|
+
return client.post(
|
|
42
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`,
|
|
43
|
+
document
|
|
44
|
+
).then(({ data }) => data);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/getUserDocuments.ts
|
|
48
|
+
var import_zod2 = require("zod");
|
|
49
|
+
var schema2 = import_zod2.z.object({
|
|
50
|
+
userId: import_zod2.z.string().trim().nonempty().uuid()
|
|
51
|
+
});
|
|
52
|
+
var getUserDocuments = async (client, userId) => {
|
|
53
|
+
const result = schema2.safeParse({ userId });
|
|
54
|
+
if (!result.success) {
|
|
55
|
+
throw new TypeError("Invalid args", {
|
|
56
|
+
cause: result.error.issues
|
|
57
|
+
});
|
|
58
|
+
}
|
|
39
59
|
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`).then(({ data }) => data);
|
|
40
60
|
};
|
|
61
|
+
|
|
62
|
+
// src/updateDocument.ts
|
|
63
|
+
var import_zod3 = require("zod");
|
|
64
|
+
var schema3 = import_zod3.z.object({
|
|
65
|
+
userId: import_zod3.z.string().nonempty().uuid(),
|
|
66
|
+
documentId: import_zod3.z.number().nonnegative().int()
|
|
67
|
+
});
|
|
68
|
+
var updateDocument = async (client, userId, documentId, document) => {
|
|
69
|
+
const result = schema3.safeParse({ userId, documentId });
|
|
70
|
+
if (!result.success) {
|
|
71
|
+
throw new TypeError("Invalid args", {
|
|
72
|
+
cause: result.error.issues
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return client.post(
|
|
76
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents/${documentId}`,
|
|
77
|
+
document
|
|
78
|
+
).then(({ data }) => data);
|
|
79
|
+
};
|
|
41
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
81
|
0 && (module.exports = {
|
|
43
|
-
|
|
82
|
+
createDocument,
|
|
83
|
+
getUserDocuments,
|
|
84
|
+
updateDocument
|
|
44
85
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,56 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/createDocument.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
var schema = z.object({
|
|
4
|
-
userId: z.string().
|
|
4
|
+
userId: z.string().nonempty().uuid()
|
|
5
5
|
});
|
|
6
|
-
var
|
|
6
|
+
var createDocument = async (client, userId, document) => {
|
|
7
7
|
const result = schema.safeParse({ userId });
|
|
8
8
|
if (!result.success) {
|
|
9
9
|
throw new TypeError("Invalid args", {
|
|
10
10
|
cause: result.error.issues
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
+
return client.post(
|
|
14
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`,
|
|
15
|
+
document
|
|
16
|
+
).then(({ data }) => data);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/getUserDocuments.ts
|
|
20
|
+
import { z as z2 } from "zod";
|
|
21
|
+
var schema2 = z2.object({
|
|
22
|
+
userId: z2.string().trim().nonempty().uuid()
|
|
23
|
+
});
|
|
24
|
+
var getUserDocuments = async (client, userId) => {
|
|
25
|
+
const result = schema2.safeParse({ userId });
|
|
26
|
+
if (!result.success) {
|
|
27
|
+
throw new TypeError("Invalid args", {
|
|
28
|
+
cause: result.error.issues
|
|
29
|
+
});
|
|
30
|
+
}
|
|
13
31
|
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`).then(({ data }) => data);
|
|
14
32
|
};
|
|
33
|
+
|
|
34
|
+
// src/updateDocument.ts
|
|
35
|
+
import { z as z3 } from "zod";
|
|
36
|
+
var schema3 = z3.object({
|
|
37
|
+
userId: z3.string().nonempty().uuid(),
|
|
38
|
+
documentId: z3.number().nonnegative().int()
|
|
39
|
+
});
|
|
40
|
+
var updateDocument = async (client, userId, documentId, document) => {
|
|
41
|
+
const result = schema3.safeParse({ userId, documentId });
|
|
42
|
+
if (!result.success) {
|
|
43
|
+
throw new TypeError("Invalid args", {
|
|
44
|
+
cause: result.error.issues
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return client.post(
|
|
48
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents/${documentId}`,
|
|
49
|
+
document
|
|
50
|
+
).then(({ data }) => data);
|
|
51
|
+
};
|
|
15
52
|
export {
|
|
16
|
-
|
|
53
|
+
createDocument,
|
|
54
|
+
getUserDocuments,
|
|
55
|
+
updateDocument
|
|
17
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-document",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.24",
|
|
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.
|
|
23
|
-
"@vulog/aima-core": "1.1.
|
|
22
|
+
"@vulog/aima-client": "1.1.24",
|
|
23
|
+
"@vulog/aima-core": "1.1.24"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"zod": "^3.24.1"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Client } from '@vulog/aima-client';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { DocumentCreate, DocumentFull } from './types';
|
|
5
|
+
|
|
6
|
+
const schema = z.object({
|
|
7
|
+
userId: z.string().nonempty().uuid(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const createDocument = async (
|
|
11
|
+
client: Client,
|
|
12
|
+
userId: string,
|
|
13
|
+
document: DocumentCreate
|
|
14
|
+
): Promise<DocumentFull> => {
|
|
15
|
+
const result = schema.safeParse({ userId });
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
throw new TypeError('Invalid args', {
|
|
18
|
+
cause: result.error.issues,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return client
|
|
23
|
+
.post<DocumentFull>(
|
|
24
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents`,
|
|
25
|
+
document
|
|
26
|
+
)
|
|
27
|
+
.then(({ data }) => data);
|
|
28
|
+
};
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -286,6 +286,12 @@ 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
|
+
|
|
293
|
+
export type DocumentUpdate = DocumentCreate;
|
|
294
|
+
|
|
289
295
|
export type DocumentByService = {
|
|
290
296
|
serviceId: string;
|
|
291
297
|
areMandatoryPresent: boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Client } from '@vulog/aima-client';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { DocumentUpdate, DocumentFull } from './types';
|
|
5
|
+
|
|
6
|
+
const schema = z.object({
|
|
7
|
+
userId: z.string().nonempty().uuid(),
|
|
8
|
+
documentId: z.number().nonnegative().int(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const updateDocument = async (
|
|
12
|
+
client: Client,
|
|
13
|
+
userId: string,
|
|
14
|
+
documentId: number,
|
|
15
|
+
document: DocumentUpdate
|
|
16
|
+
): Promise<DocumentFull> => {
|
|
17
|
+
const result = schema.safeParse({ userId, documentId });
|
|
18
|
+
if (!result.success) {
|
|
19
|
+
throw new TypeError('Invalid args', {
|
|
20
|
+
cause: result.error.issues,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return client
|
|
25
|
+
.post<DocumentFull>(
|
|
26
|
+
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/users/${userId}/documents/${documentId}`,
|
|
27
|
+
document
|
|
28
|
+
)
|
|
29
|
+
.then(({ data }) => data);
|
|
30
|
+
};
|