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