@solibo/solibo-query 1.53.9 → 1.54.0-feature-utility-usage-e65c08f-1795009420051-SNAPSHOT
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/api/commands/conversation/createPublicConversationMessageWithInlineImages.d.ts +59 -0
- package/dist/api/commands/conversation/createPublicConversationMessageWithInlineImages.js +122 -0
- package/dist/api/commands/conversation/publicUploadDocumentToConversation.d.ts +21 -2
- package/dist/api/commands/conversation/publicUploadDocumentToConversation.js +31 -5
- package/dist/api/commands/document/integratedDocumentMutations.d.ts +15 -1
- package/dist/api/commands/document/integratedDocumentMutations.js +18 -1
- package/dist/api/commands/invoicing/creditInvoices.d.ts +18 -0
- package/dist/api/commands/invoicing/creditInvoices.js +56 -0
- package/dist/api/commands/section/importSectionsForOnboardingCompany.d.ts +18 -0
- package/dist/api/commands/section/importSectionsForOnboardingCompany.js +26 -0
- package/dist/api/queries/invoicing/paymentAllocation.d.ts +11 -1
- package/dist/api/queries/invoicing/paymentAllocation.js +18 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CreateMessageCommandProps, Id, SdkInput } from "@solibo/solibo-sdk";
|
|
2
|
+
import { SoliboClient } from "@solibo/solibo-sdk/core";
|
|
3
|
+
import type { QueryClient } from "@tanstack/query-core";
|
|
4
|
+
import type { UploadProgressListener } from "../../documentApi.js";
|
|
5
|
+
/**
|
|
6
|
+
* An open-page message whose content embeds pasted images. Each image sits in
|
|
7
|
+
* the content as a slot marker, `<img data-solibo-document-slot="{slot}">`
|
|
8
|
+
* (what `inlineDocumentImageSlot` and the editor emit), and `inlineImages`
|
|
9
|
+
* holds the file for each slot.
|
|
10
|
+
*/
|
|
11
|
+
export interface PublicConversationMessageWithInlineImagesParams {
|
|
12
|
+
companySlug: string;
|
|
13
|
+
conversationId: Id;
|
|
14
|
+
content: string;
|
|
15
|
+
inlineImages?: Readonly<Record<string, File>> | ReadonlyMap<string, File> | null | undefined;
|
|
16
|
+
/** The rest of the message command; `content` comes from `content` above. */
|
|
17
|
+
cmd?: Omit<SdkInput<CreateMessageCommandProps>, "content">;
|
|
18
|
+
onUploadProgress?: UploadProgressListener;
|
|
19
|
+
}
|
|
20
|
+
export interface PublicConversationMessageWithInlineImagesResult {
|
|
21
|
+
/** The content as sent, with every slot marker replaced by its document id. */
|
|
22
|
+
content: string;
|
|
23
|
+
/** The document id each slot's image was uploaded as. */
|
|
24
|
+
documentIds: Map<string, bigint>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when a pasted image could not be uploaded, or the backend did not
|
|
28
|
+
* name the document an upload created. No message was sent; the images this
|
|
29
|
+
* attempt uploaded were deleted again where possible (`rollbackFailures`
|
|
30
|
+
* lists the ones that were not).
|
|
31
|
+
*/
|
|
32
|
+
export declare class PublicConversationInlineImageUploadError extends Error {
|
|
33
|
+
readonly slot: string;
|
|
34
|
+
readonly rollbackFailures: readonly string[];
|
|
35
|
+
constructor(slot: string, message: string, rollbackFailures: readonly string[], options?: {
|
|
36
|
+
cause?: unknown;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** The slots `content` references, in order of first appearance. */
|
|
40
|
+
export declare function inlineDocumentSlots(content: string): string[];
|
|
41
|
+
/**
|
|
42
|
+
* Replaces each `data-solibo-document-slot="{slot}"` in `content` with
|
|
43
|
+
* `data-solibo-document-id="{id}"`. A slot without an id is left as it is.
|
|
44
|
+
*/
|
|
45
|
+
export declare function replaceInlineDocumentSlots(content: string, documentIds: ReadonlyMap<string, Id>): string;
|
|
46
|
+
/**
|
|
47
|
+
* Sends an open-page message with pasted images: uploads each image the
|
|
48
|
+
* content references through the open-page upload, replaces its slot marker
|
|
49
|
+
* with `data-solibo-document-id="{id}"`, then posts the message. Images in
|
|
50
|
+
* `inlineImages` that the content does not reference are not uploaded; a slot
|
|
51
|
+
* the content references without an image fails before anything is uploaded.
|
|
52
|
+
* When the message itself fails, the uploaded images stay on the conversation.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createPublicConversationMessageWithInlineImages(sdk: SoliboClient, params: PublicConversationMessageWithInlineImagesParams): Promise<PublicConversationMessageWithInlineImagesResult>;
|
|
55
|
+
export declare function createPublicConversationMessageWithInlineImagesMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
56
|
+
mutationFn: (params: PublicConversationMessageWithInlineImagesParams) => Promise<PublicConversationMessageWithInlineImagesResult>;
|
|
57
|
+
onSuccess: (_: unknown, params: PublicConversationMessageWithInlineImagesParams) => Promise<void>;
|
|
58
|
+
onError: (_: unknown, params: PublicConversationMessageWithInlineImagesParams) => Promise<void>;
|
|
59
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createMessagePublicConversation, deleteDocumentPublicConversation, } from "@solibo/solibo-sdk/conversations/operations";
|
|
2
|
+
import { createUploadGroupId } from "../../../utils/uploadGroupId.js";
|
|
3
|
+
import { conversationKeys } from "../../queries/conversation/conversations.js";
|
|
4
|
+
import { uploadPublicConversationDocument } from "./publicUploadDocumentToConversation.js";
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when a pasted image could not be uploaded, or the backend did not
|
|
7
|
+
* name the document an upload created. No message was sent; the images this
|
|
8
|
+
* attempt uploaded were deleted again where possible (`rollbackFailures`
|
|
9
|
+
* lists the ones that were not).
|
|
10
|
+
*/
|
|
11
|
+
export class PublicConversationInlineImageUploadError extends Error {
|
|
12
|
+
constructor(slot, message, rollbackFailures, options) {
|
|
13
|
+
super(message, options);
|
|
14
|
+
this.name = "PublicConversationInlineImageUploadError";
|
|
15
|
+
this.slot = slot;
|
|
16
|
+
this.rollbackFailures = rollbackFailures;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const SLOT_ATTRIBUTE = /data-solibo-document-slot\s*=\s*(["'])(.*?)\1/g;
|
|
20
|
+
function decodeAttribute(value) {
|
|
21
|
+
return value
|
|
22
|
+
.replace(/"/g, '"')
|
|
23
|
+
.replace(/'|'/g, "'")
|
|
24
|
+
.replace(/</g, "<")
|
|
25
|
+
.replace(/>/g, ">")
|
|
26
|
+
.replace(/&/g, "&");
|
|
27
|
+
}
|
|
28
|
+
/** The slots `content` references, in order of first appearance. */
|
|
29
|
+
export function inlineDocumentSlots(content) {
|
|
30
|
+
const slots = new Set();
|
|
31
|
+
for (const match of content.matchAll(SLOT_ATTRIBUTE)) {
|
|
32
|
+
slots.add(decodeAttribute(match[2]));
|
|
33
|
+
}
|
|
34
|
+
return [...slots];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Replaces each `data-solibo-document-slot="{slot}"` in `content` with
|
|
38
|
+
* `data-solibo-document-id="{id}"`. A slot without an id is left as it is.
|
|
39
|
+
*/
|
|
40
|
+
export function replaceInlineDocumentSlots(content, documentIds) {
|
|
41
|
+
return content.replace(SLOT_ATTRIBUTE, (marker, _quote, slot) => {
|
|
42
|
+
const documentId = documentIds.get(decodeAttribute(slot));
|
|
43
|
+
return documentId == null
|
|
44
|
+
? marker
|
|
45
|
+
: `data-solibo-document-id="${BigInt(documentId).toString()}"`;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function toImageMap(images) {
|
|
49
|
+
if (images == null)
|
|
50
|
+
return new Map();
|
|
51
|
+
if (images instanceof Map)
|
|
52
|
+
return new Map(images);
|
|
53
|
+
return new Map(Object.entries(images));
|
|
54
|
+
}
|
|
55
|
+
async function uploadInlineImages(sdk, params, slots, images) {
|
|
56
|
+
const uploadGroupId = createUploadGroupId();
|
|
57
|
+
const results = await Promise.allSettled(slots.map(async (slot) => {
|
|
58
|
+
const { documentId } = await uploadPublicConversationDocument(sdk, {
|
|
59
|
+
companySlug: params.companySlug,
|
|
60
|
+
conversationId: params.conversationId,
|
|
61
|
+
file: images.get(slot),
|
|
62
|
+
uploadGroupId,
|
|
63
|
+
onUploadProgress: params.onUploadProgress,
|
|
64
|
+
});
|
|
65
|
+
if (documentId == null) {
|
|
66
|
+
throw new Error("The upload response did not name the created document (X-Document-Id)");
|
|
67
|
+
}
|
|
68
|
+
return documentId;
|
|
69
|
+
}));
|
|
70
|
+
const documentIds = new Map();
|
|
71
|
+
results.forEach((result, index) => {
|
|
72
|
+
if (result.status === "fulfilled")
|
|
73
|
+
documentIds.set(slots[index], result.value);
|
|
74
|
+
});
|
|
75
|
+
const failedIndex = results.findIndex(({ status }) => status === "rejected");
|
|
76
|
+
if (failedIndex < 0)
|
|
77
|
+
return documentIds;
|
|
78
|
+
const failure = results[failedIndex].reason;
|
|
79
|
+
const rollbackFailures = (await Promise.allSettled([...documentIds.values()].map((documentId) => deleteDocumentPublicConversation(sdk, {
|
|
80
|
+
companySlug: params.companySlug,
|
|
81
|
+
conversationId: params.conversationId,
|
|
82
|
+
documentId,
|
|
83
|
+
}).then(() => undefined, (error) => `${documentId}: ${error instanceof Error ? error.message : String(error)}`)))).flatMap((result) => result.status === "fulfilled" && result.value != null ? [result.value] : []);
|
|
84
|
+
const slot = slots[failedIndex];
|
|
85
|
+
throw new PublicConversationInlineImageUploadError(slot, `Could not upload the image for slot "${slot}": ${failure instanceof Error ? failure.message : String(failure)}`, rollbackFailures, { cause: failure });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sends an open-page message with pasted images: uploads each image the
|
|
89
|
+
* content references through the open-page upload, replaces its slot marker
|
|
90
|
+
* with `data-solibo-document-id="{id}"`, then posts the message. Images in
|
|
91
|
+
* `inlineImages` that the content does not reference are not uploaded; a slot
|
|
92
|
+
* the content references without an image fails before anything is uploaded.
|
|
93
|
+
* When the message itself fails, the uploaded images stay on the conversation.
|
|
94
|
+
*/
|
|
95
|
+
export async function createPublicConversationMessageWithInlineImages(sdk, params) {
|
|
96
|
+
const images = toImageMap(params.inlineImages);
|
|
97
|
+
const slots = inlineDocumentSlots(params.content);
|
|
98
|
+
const missing = slots.filter((slot) => !images.has(slot));
|
|
99
|
+
if (missing.length > 0) {
|
|
100
|
+
throw new Error(`The message references inline image slots without a file: ${missing.join(", ")}`);
|
|
101
|
+
}
|
|
102
|
+
const documentIds = slots.length > 0
|
|
103
|
+
? await uploadInlineImages(sdk, params, slots, images)
|
|
104
|
+
: new Map();
|
|
105
|
+
const content = replaceInlineDocumentSlots(params.content, documentIds);
|
|
106
|
+
await createMessagePublicConversation(sdk, {
|
|
107
|
+
companySlug: params.companySlug,
|
|
108
|
+
conversationId: params.conversationId,
|
|
109
|
+
input: { ...params.cmd, content },
|
|
110
|
+
});
|
|
111
|
+
return { content, documentIds };
|
|
112
|
+
}
|
|
113
|
+
export function createPublicConversationMessageWithInlineImagesMutationOptions(sdk, queryClient) {
|
|
114
|
+
const invalidate = (_, params) => queryClient.invalidateQueries({
|
|
115
|
+
queryKey: [conversationKeys.public(params.conversationId)],
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
mutationFn: (params) => createPublicConversationMessageWithInlineImages(sdk, params),
|
|
119
|
+
onSuccess: invalidate,
|
|
120
|
+
onError: invalidate,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -20,8 +20,27 @@ export interface DeletePublicConversationDocumentParams {
|
|
|
20
20
|
documentId: Id;
|
|
21
21
|
redirect?: boolean;
|
|
22
22
|
}
|
|
23
|
+
/** The header the open-page upload names the document it created in. */
|
|
24
|
+
export declare const PUBLIC_DOCUMENT_ID_HEADER = "X-Document-Id";
|
|
25
|
+
/**
|
|
26
|
+
* What an open-page upload resolves to. `documentId` is the created
|
|
27
|
+
* document's id from the `X-Document-Id` response header, or `null` when the
|
|
28
|
+
* backend did not send it (a backend older than the header).
|
|
29
|
+
*/
|
|
30
|
+
export interface PublicConversationDocumentUploadResult {
|
|
31
|
+
documentId: bigint | null;
|
|
32
|
+
}
|
|
33
|
+
/** Reads the created document's id from an open-page upload response. */
|
|
34
|
+
export declare function publicUploadDocumentId(headers: ReadonlyMap<string, readonly string[]> | null | undefined): bigint | null;
|
|
35
|
+
/**
|
|
36
|
+
* Uploads one file through the open-page upload and resolves to the created
|
|
37
|
+
* document's id. `uploadGroupId` groups several uploads into one batch.
|
|
38
|
+
*/
|
|
39
|
+
export declare function uploadPublicConversationDocument(sdk: SoliboClient, params: PublicDocumentUploadToConversationParams & {
|
|
40
|
+
uploadGroupId?: string;
|
|
41
|
+
}): Promise<PublicConversationDocumentUploadResult>;
|
|
23
42
|
export declare function publicUploadDocumentToConversationMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
24
|
-
mutationFn: (params: PublicDocumentUploadToConversationParams) => Promise<
|
|
43
|
+
mutationFn: (params: PublicDocumentUploadToConversationParams) => Promise<PublicConversationDocumentUploadResult>;
|
|
25
44
|
onSuccess: (_: any, params: any) => Promise<void>;
|
|
26
45
|
};
|
|
27
46
|
export declare function deletePublicConversationDocumentMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
@@ -29,6 +48,6 @@ export declare function deletePublicConversationDocumentMutationOptions(sdk: Sol
|
|
|
29
48
|
onSuccess: (_: any, params: any) => Promise<void>;
|
|
30
49
|
};
|
|
31
50
|
export declare function multiUploadPublicDocumentToConversationMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
32
|
-
mutationFn: (params: MultiPublicDocumentUploadParams) => Promise<PromiseSettledResult<
|
|
51
|
+
mutationFn: (params: MultiPublicDocumentUploadParams) => Promise<PromiseSettledResult<PublicConversationDocumentUploadResult>[]>;
|
|
33
52
|
onSuccess: (_: any, params: any) => Promise<void>;
|
|
34
53
|
};
|
|
@@ -2,23 +2,49 @@ import { createUploadGroupId } from "../../../utils/uploadGroupId.js";
|
|
|
2
2
|
import { completeSignedUpload, toUploadBinaryRequest, uploadClient, } from "../../documentApi.js";
|
|
3
3
|
import { conversationKeys } from "../../queries/conversation/conversations.js";
|
|
4
4
|
import { createDocumentPublicConversationOperation, deleteDocumentPublicConversation, } from "@solibo/solibo-sdk/conversations/operations";
|
|
5
|
-
|
|
5
|
+
/** The header the open-page upload names the document it created in. */
|
|
6
|
+
export const PUBLIC_DOCUMENT_ID_HEADER = "X-Document-Id";
|
|
7
|
+
/** The value of `name` in `headers`, matched case-insensitively. */
|
|
8
|
+
function headerValue(headers, name) {
|
|
9
|
+
if (!headers)
|
|
10
|
+
return undefined;
|
|
11
|
+
const wanted = name.toLowerCase();
|
|
12
|
+
for (const [key, values] of headers.entries()) {
|
|
13
|
+
if (key.toLowerCase() === wanted) {
|
|
14
|
+
return values.find((value) => value.trim() !== "")?.trim();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Reads the created document's id from an open-page upload response. */
|
|
20
|
+
export function publicUploadDocumentId(headers) {
|
|
21
|
+
const value = headerValue(headers, PUBLIC_DOCUMENT_ID_HEADER);
|
|
22
|
+
if (value == null || !/^\d+$/.test(value))
|
|
23
|
+
return null;
|
|
24
|
+
return BigInt(value);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Uploads one file through the open-page upload and resolves to the created
|
|
28
|
+
* document's id. `uploadGroupId` groups several uploads into one batch.
|
|
29
|
+
*/
|
|
30
|
+
export function uploadPublicConversationDocument(sdk, params) {
|
|
6
31
|
return toUploadBinaryRequest({
|
|
7
32
|
file: params.file,
|
|
8
33
|
onUploadProgress: params.onUploadProgress,
|
|
9
34
|
}).then(async (uploadRequest) => {
|
|
10
35
|
const response = await createDocumentPublicConversationOperation(uploadClient(sdk, uploadRequest), params.companySlug, BigInt(params.conversationId).valueOf(), params.uploadGroupId);
|
|
11
|
-
const
|
|
36
|
+
const documentId = publicUploadDocumentId(response.headers);
|
|
37
|
+
await response.body();
|
|
12
38
|
await completeSignedUpload(sdk, response, uploadRequest, {
|
|
13
39
|
file: params.file,
|
|
14
40
|
onUploadProgress: params.onUploadProgress,
|
|
15
41
|
});
|
|
16
|
-
return
|
|
42
|
+
return { documentId };
|
|
17
43
|
});
|
|
18
44
|
}
|
|
19
45
|
export function publicUploadDocumentToConversationMutationOptions(sdk, queryClient) {
|
|
20
46
|
return {
|
|
21
|
-
mutationFn: (params) =>
|
|
47
|
+
mutationFn: (params) => uploadPublicConversationDocument(sdk, params),
|
|
22
48
|
onSuccess: (_, params) => queryClient.invalidateQueries({
|
|
23
49
|
queryKey: [conversationKeys.public(params.conversationId)],
|
|
24
50
|
}),
|
|
@@ -42,7 +68,7 @@ export function multiUploadPublicDocumentToConversationMutationOptions(sdk, quer
|
|
|
42
68
|
mutationFn: (params) => {
|
|
43
69
|
const files = Array.from(params.fileList);
|
|
44
70
|
const uploadGroupId = createUploadGroupId();
|
|
45
|
-
return Promise.allSettled(files.map((file) =>
|
|
71
|
+
return Promise.allSettled(files.map((file) => uploadPublicConversationDocument(sdk, {
|
|
46
72
|
companySlug: params.companySlug,
|
|
47
73
|
conversationId: params.conversationId,
|
|
48
74
|
file: file,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateConversationCommandProps, CreateMessageCommandProps, CreateCommunicationCommentCommandProps, CreateNewsletterCommandProps, CreateNeighborhoodGroupCommandProps, CreateNeighborhoodPostCommandProps, CreatePostCommandProps, Id, SdkInput, UpdateConversationCommandProps, UpdateNewsletterCommandProps, UpdateCommunicationCommentCommandProps, UpdateNeighborhoodGroupCommandProps, UpdateNeighborhoodPostCommandProps, UpdatePostCommandProps } from "@solibo/solibo-sdk";
|
|
1
|
+
import type { CreateConversationCommandProps, CreateInternalMessageCommandProps, CreateMessageCommandProps, CreateCommunicationCommentCommandProps, CreateNewsletterCommandProps, CreateNeighborhoodGroupCommandProps, CreateNeighborhoodPostCommandProps, CreatePostCommandProps, Id, SdkInput, UpdateConversationCommandProps, UpdateNewsletterCommandProps, UpdateCommunicationCommentCommandProps, UpdateNeighborhoodGroupCommandProps, UpdateNeighborhoodPostCommandProps, UpdatePostCommandProps } from "@solibo/solibo-sdk";
|
|
2
2
|
import { SoliboClient } from "@solibo/solibo-sdk/core";
|
|
3
3
|
import type { QueryClient } from "@tanstack/query-core";
|
|
4
4
|
import type { IntegratedDocumentSources } from "../../integratedDocumentApi.js";
|
|
@@ -58,6 +58,16 @@ export interface ConversationMessageParams extends IntegratedDocumentSources {
|
|
|
58
58
|
command: SdkInput<CreateMessageCommandProps>;
|
|
59
59
|
idempotencyKey?: string;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* An internal (staff only) message with documents. The documents it uploads
|
|
63
|
+
* are internal: only the internal chat shows them.
|
|
64
|
+
*/
|
|
65
|
+
export interface ConversationInternalMessageParams extends Omit<IntegratedDocumentSources, "image"> {
|
|
66
|
+
companyId: Id;
|
|
67
|
+
conversationId: Id;
|
|
68
|
+
command: SdkInput<CreateInternalMessageCommandProps>;
|
|
69
|
+
idempotencyKey?: string;
|
|
70
|
+
}
|
|
61
71
|
export interface NeighborhoodPostCreateParams extends IntegratedDocumentSources {
|
|
62
72
|
companyId: Id;
|
|
63
73
|
groupId?: Id | null | undefined;
|
|
@@ -135,6 +145,10 @@ export declare function createConversationMessageWithDocumentsMutationOptions(sd
|
|
|
135
145
|
mutationFn: (params: ConversationMessageParams) => Promise<unknown>;
|
|
136
146
|
onSuccess: (_: unknown, params: ConversationMessageParams) => Promise<[void, void, void, void]>;
|
|
137
147
|
};
|
|
148
|
+
export declare function createConversationInternalMessageWithDocumentsMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
149
|
+
mutationFn: (params: ConversationInternalMessageParams) => Promise<unknown>;
|
|
150
|
+
onSuccess: (_: unknown, params: ConversationInternalMessageParams) => Promise<[void, void]>;
|
|
151
|
+
};
|
|
138
152
|
export declare function createNeighborhoodGroupWithDocumentsMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
139
153
|
mutationFn: (params: NeighborhoodGroupCreateParams) => Promise<unknown>;
|
|
140
154
|
onSuccess: (_: unknown, params: NeighborhoodGroupCreateParams) => Promise<[void, ...void[], void]>;
|
|
@@ -2,7 +2,7 @@ import { integratedDocumentsOf, } from "@solibo/solibo-sdk/interop";
|
|
|
2
2
|
import { CreatePostCommand, UpdatePostCommand, } from "@solibo/solibo-sdk/homepage/operations";
|
|
3
3
|
import { CreateNewsletterCommand, UpdateNewsletterCommand, } from "@solibo/solibo-sdk/communication/operations";
|
|
4
4
|
import { CreateCommunicationCommentCommand, CreateNeighborhoodGroupCommand, CreateNeighborhoodPostCommand, UpdateCommunicationCommentCommand, UpdateNeighborhoodGroupCommand, UpdateNeighborhoodPostCommand, } from "@solibo/solibo-sdk/residentCommunication/operations";
|
|
5
|
-
import { CreateConversationCommand, CreateMessageCommand, UpdateConversationCommand, } from "@solibo/solibo-sdk/conversations/operations";
|
|
5
|
+
import { CreateConversationCommand, CreateInternalMessageCommand, CreateMessageCommand, UpdateConversationCommand, } from "@solibo/solibo-sdk/conversations/operations";
|
|
6
6
|
import { fromKt, toKtProps } from "../../../utils/kt-bridge.js";
|
|
7
7
|
import { prepareIntegratedDocumentSources } from "../../integratedDocumentApi.js";
|
|
8
8
|
import { communicationKeys } from "../../queries/communication/newsletters.js";
|
|
@@ -192,6 +192,23 @@ export function createConversationMessageWithDocumentsMutationOptions(sdk, query
|
|
|
192
192
|
]),
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
+
// @openapi-operation finalizeIntegratedConversationInternalMessage
|
|
196
|
+
export function createConversationInternalMessageWithDocumentsMutationOptions(sdk, queryClient) {
|
|
197
|
+
return {
|
|
198
|
+
mutationFn: async (params) => {
|
|
199
|
+
const documents = await prepareIntegratedDocumentSources(params);
|
|
200
|
+
return integratedDocuments(sdk)
|
|
201
|
+
.createConversationInternalMessage(BigInt(params.companyId).valueOf(), BigInt(params.conversationId).valueOf(), new CreateInternalMessageCommand(toKtProps(params.command)), documents.attachments, documents.inlineDocuments, params.idempotencyKey, documents.onUploadProgress)
|
|
202
|
+
.then(fromKt);
|
|
203
|
+
},
|
|
204
|
+
onSuccess: (_, params) => Promise.all([
|
|
205
|
+
queryClient.invalidateQueries({
|
|
206
|
+
queryKey: [conversationKeys.detail(params.conversationId)],
|
|
207
|
+
}),
|
|
208
|
+
queryClient.invalidateQueries({ queryKey: [documentKeys.all] }),
|
|
209
|
+
]),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
195
212
|
function invalidateResidentDocuments(queryClient, homepage, companyId, postId) {
|
|
196
213
|
return Promise.all([
|
|
197
214
|
queryClient.invalidateQueries({
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CreditInvoicesCommandProps, Id, SdkInput } from "@solibo/solibo-sdk";
|
|
2
|
+
import { SoliboClient } from "@solibo/solibo-sdk/core";
|
|
3
|
+
import type { QueryClient } from "@tanstack/query-core";
|
|
4
|
+
export type CreditInvoicesParams = {
|
|
5
|
+
companyId: Id;
|
|
6
|
+
cmd: SdkInput<CreditInvoicesCommandProps>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Credits up to 200 invoices of a company in one request, each as `createCreditNoteMutationOptions`
|
|
10
|
+
* would. The result answers every invoice on its own, in request order: `refusal` when it was
|
|
11
|
+
* refused before anything was queued, otherwise `result`. Resending the same command answers the
|
|
12
|
+
* credits that already exist instead of issuing them again.
|
|
13
|
+
*/
|
|
14
|
+
export declare function creditInvoicesMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
15
|
+
mutationFn: (params: CreditInvoicesParams) => Promise<import("@solibo/solibo-sdk").CreditInvoicesResult>;
|
|
16
|
+
onSuccess: (_: unknown, params: CreditInvoicesParams) => Promise<[void, void, void, ...void[]]>;
|
|
17
|
+
onError: (_: unknown, params: CreditInvoicesParams) => Promise<[void, ...void[]]>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { invoicingKeys } from "../../queries/invoicing/invoicingKeys.js";
|
|
2
|
+
import { toKeyId } from "../../../utils/kt-bridge.js";
|
|
3
|
+
import { creditInvoices } from "@solibo/solibo-sdk/invoicing/operations";
|
|
4
|
+
function creditedInvoiceIds(params) {
|
|
5
|
+
return [...new Set(params.cmd.invoices.map((item) => item.invoiceId))];
|
|
6
|
+
}
|
|
7
|
+
function creditedCustomerIds(params) {
|
|
8
|
+
const byKey = new Map();
|
|
9
|
+
for (const item of params.cmd.invoices)
|
|
10
|
+
byKey.set(toKeyId(item.customerId), item.customerId);
|
|
11
|
+
return [...byKey.values()];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Credits up to 200 invoices of a company in one request, each as `createCreditNoteMutationOptions`
|
|
15
|
+
* would. The result answers every invoice on its own, in request order: `refusal` when it was
|
|
16
|
+
* refused before anything was queued, otherwise `result`. Resending the same command answers the
|
|
17
|
+
* credits that already exist instead of issuing them again.
|
|
18
|
+
*/
|
|
19
|
+
export function creditInvoicesMutationOptions(sdk, queryClient) {
|
|
20
|
+
return {
|
|
21
|
+
mutationFn: (params) => creditInvoices(sdk, {
|
|
22
|
+
companyId: params.companyId,
|
|
23
|
+
input: params.cmd,
|
|
24
|
+
}),
|
|
25
|
+
onSuccess: (_, params) => Promise.all([
|
|
26
|
+
queryClient.invalidateQueries({
|
|
27
|
+
queryKey: [invoicingKeys.historicInvoices(params.companyId)],
|
|
28
|
+
exact: false,
|
|
29
|
+
}),
|
|
30
|
+
queryClient.invalidateQueries({
|
|
31
|
+
queryKey: [invoicingKeys.historicInvoicesForCompanies()],
|
|
32
|
+
}),
|
|
33
|
+
queryClient.invalidateQueries({
|
|
34
|
+
queryKey: [invoicingKeys.sectionInvoices(params.companyId)],
|
|
35
|
+
}),
|
|
36
|
+
...creditedCustomerIds(params).map((customerId) => queryClient.invalidateQueries({
|
|
37
|
+
queryKey: [
|
|
38
|
+
invoicingKeys.customerInvoices(params.companyId, customerId),
|
|
39
|
+
],
|
|
40
|
+
})),
|
|
41
|
+
...creditedInvoiceIds(params).map((invoiceId) => queryClient.invalidateQueries({
|
|
42
|
+
queryKey: [invoicingKeys.creditNotes(params.companyId, invoiceId)],
|
|
43
|
+
})),
|
|
44
|
+
]),
|
|
45
|
+
// A failed batch may still have queued some credits.
|
|
46
|
+
onError: (_, params) => Promise.all([
|
|
47
|
+
queryClient.invalidateQueries({
|
|
48
|
+
queryKey: [invoicingKeys.historicInvoices(params.companyId)],
|
|
49
|
+
exact: false,
|
|
50
|
+
}),
|
|
51
|
+
...creditedInvoiceIds(params).map((invoiceId) => queryClient.invalidateQueries({
|
|
52
|
+
queryKey: [invoicingKeys.creditNotes(params.companyId, invoiceId)],
|
|
53
|
+
})),
|
|
54
|
+
]),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Id } from "@solibo/solibo-sdk";
|
|
2
|
+
import { SoliboClient } from "@solibo/solibo-sdk/core";
|
|
3
|
+
import type { QueryClient } from "@tanstack/query-core";
|
|
4
|
+
/**
|
|
5
|
+
* Imports sections, addresses, parking spaces and storage rooms into an onboarding, imported or
|
|
6
|
+
* active company. Existing rows are never changed; the backend refuses the whole import with 422
|
|
7
|
+
* when a bolignr is already in use.
|
|
8
|
+
*/
|
|
9
|
+
export declare function importSectionsForOnboardingCompanyMutationOptions(sdk: SoliboClient, queryClient: QueryClient): {
|
|
10
|
+
mutationFn: (params: {
|
|
11
|
+
companyId: Id;
|
|
12
|
+
csv: string;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
onSuccess: (_: unknown, params: {
|
|
15
|
+
companyId: Id;
|
|
16
|
+
csv: string;
|
|
17
|
+
}) => Promise<[void[], void]>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { companyKeys } from "../../queries/company/companies.js";
|
|
2
|
+
import { invalidateResidentSectionCaches } from "../residentsAndSections/cacheInvalidation.js";
|
|
3
|
+
import { importSectionsForOnboardingCompany } from "@solibo/solibo-sdk/sections/operations";
|
|
4
|
+
/**
|
|
5
|
+
* Imports sections, addresses, parking spaces and storage rooms into an onboarding, imported or
|
|
6
|
+
* active company. Existing rows are never changed; the backend refuses the whole import with 422
|
|
7
|
+
* when a bolignr is already in use.
|
|
8
|
+
*/
|
|
9
|
+
export function importSectionsForOnboardingCompanyMutationOptions(sdk, queryClient) {
|
|
10
|
+
return {
|
|
11
|
+
mutationFn: (params) => importSectionsForOnboardingCompany(sdk, {
|
|
12
|
+
companyId: params.companyId,
|
|
13
|
+
input: params.csv,
|
|
14
|
+
}),
|
|
15
|
+
onSuccess: (_, params) => Promise.all([
|
|
16
|
+
invalidateResidentSectionCaches(queryClient, {
|
|
17
|
+
companyId: params.companyId,
|
|
18
|
+
includeParkingSpaces: true,
|
|
19
|
+
includeStorageRooms: true,
|
|
20
|
+
}),
|
|
21
|
+
queryClient.invalidateQueries({
|
|
22
|
+
queryKey: [companyKeys.addresses(params.companyId)],
|
|
23
|
+
}),
|
|
24
|
+
]),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SoliboClient } from "@solibo/solibo-sdk/core";
|
|
2
|
-
import { indexPaymentSourcesForCompanies, indexCompanyPaymentSources, showCompanyPaymentSourceReadStatus, showCompanyPaymentSource, indexCompanyPaymentSourceHistory, indexCompanyPaymentSourceInvoiceCandidates } from "@solibo/solibo-sdk/paymentAllocation/operations";
|
|
2
|
+
import { indexPaymentSourcesForCompanies, indexCompanyPaymentSources, showCompanyPaymentSourceReadStatus, showCompanyPaymentSource, indexCompanyPaymentSourceHistory, indexCompanyPaymentSourceInvoiceCandidates, showCompanyPaymentSourceKidInvoice } from "@solibo/solibo-sdk/paymentAllocation/operations";
|
|
3
3
|
import { nextPageParam, prevPageParam } from "../../../utils/pageUtils.js";
|
|
4
4
|
export type IndexPaymentSourcesForCompaniesParams = Parameters<typeof indexPaymentSourcesForCompanies>[1];
|
|
5
5
|
export type IndexCompanyPaymentSourcesParams = Parameters<typeof indexCompanyPaymentSources>[1];
|
|
@@ -7,6 +7,7 @@ export type ShowCompanyPaymentSourceReadStatusParams = Parameters<typeof showCom
|
|
|
7
7
|
export type ShowCompanyPaymentSourceParams = Parameters<typeof showCompanyPaymentSource>[1];
|
|
8
8
|
export type IndexCompanyPaymentSourceHistoryParams = Parameters<typeof indexCompanyPaymentSourceHistory>[1];
|
|
9
9
|
export type IndexCompanyPaymentSourceInvoiceCandidatesParams = Parameters<typeof indexCompanyPaymentSourceInvoiceCandidates>[1];
|
|
10
|
+
export type ShowCompanyPaymentSourceKidInvoiceParams = Parameters<typeof showCompanyPaymentSourceKidInvoice>[1];
|
|
10
11
|
export declare const paymentAllocationKeys: {
|
|
11
12
|
all: readonly ["invoicing", "paymentAllocation"];
|
|
12
13
|
indexPaymentSourcesForCompanies: (params?: IndexPaymentSourcesForCompaniesParams) => readonly ["invoicing", "paymentAllocation", "indexPaymentSourcesForCompanies", unknown];
|
|
@@ -15,6 +16,7 @@ export declare const paymentAllocationKeys: {
|
|
|
15
16
|
showCompanyPaymentSource: (params?: ShowCompanyPaymentSourceParams) => readonly ["invoicing", "paymentAllocation", "showCompanyPaymentSource", unknown];
|
|
16
17
|
indexCompanyPaymentSourceHistory: (params?: IndexCompanyPaymentSourceHistoryParams) => readonly ["invoicing", "paymentAllocation", "indexCompanyPaymentSourceHistory", unknown];
|
|
17
18
|
indexCompanyPaymentSourceInvoiceCandidates: (params?: IndexCompanyPaymentSourceInvoiceCandidatesParams) => readonly ["invoicing", "paymentAllocation", "indexCompanyPaymentSourceInvoiceCandidates", unknown];
|
|
19
|
+
showCompanyPaymentSourceKidInvoice: (params?: ShowCompanyPaymentSourceKidInvoiceParams) => readonly ["invoicing", "paymentAllocation", "showCompanyPaymentSourceKidInvoice", unknown];
|
|
18
20
|
};
|
|
19
21
|
export declare function indexPaymentSourcesForCompaniesQueryOptions(sdk: SoliboClient, params: IndexPaymentSourcesForCompaniesParams): {
|
|
20
22
|
initialPageParam: string | undefined;
|
|
@@ -55,3 +57,11 @@ export declare function indexCompanyPaymentSourceInvoiceCandidatesQueryOptions(s
|
|
|
55
57
|
getNextPageParam: typeof nextPageParam;
|
|
56
58
|
getPreviousPageParam: typeof prevPageParam;
|
|
57
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* The invoice a payment's KID names, with how and when it was closed. `invoice` is null when the
|
|
62
|
+
* KID names no invoice.
|
|
63
|
+
*/
|
|
64
|
+
export declare function showCompanyPaymentSourceKidInvoiceQueryOptions(sdk: SoliboClient, params: ShowCompanyPaymentSourceKidInvoiceParams): {
|
|
65
|
+
queryKey: (readonly ["invoicing", "paymentAllocation", "showCompanyPaymentSourceKidInvoice", unknown])[];
|
|
66
|
+
queryFn: () => Promise<import("@solibo/solibo-sdk").PaymentSourceKidInvoiceResponse>;
|
|
67
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { indexPaymentSourcesForCompanies, indexCompanyPaymentSources, showCompanyPaymentSourceReadStatus, showCompanyPaymentSource, indexCompanyPaymentSourceHistory, indexCompanyPaymentSourceInvoiceCandidates, } from "@solibo/solibo-sdk/paymentAllocation/operations";
|
|
1
|
+
import { indexPaymentSourcesForCompanies, indexCompanyPaymentSources, showCompanyPaymentSourceReadStatus, showCompanyPaymentSource, indexCompanyPaymentSourceHistory, indexCompanyPaymentSourceInvoiceCandidates, showCompanyPaymentSourceKidInvoice, } from "@solibo/solibo-sdk/paymentAllocation/operations";
|
|
2
2
|
import { nextPageParam, prevPageParam } from "../../../utils/pageUtils.js";
|
|
3
3
|
import { trimTrailingUndefined } from "../../../utils/queryKeys.js";
|
|
4
4
|
import { financeQueryIdentity } from "./financeQueryIdentity.js";
|
|
@@ -34,6 +34,11 @@ export const paymentAllocationKeys = {
|
|
|
34
34
|
"indexCompanyPaymentSourceInvoiceCandidates",
|
|
35
35
|
params === undefined ? undefined : financeQueryIdentity(params),
|
|
36
36
|
]),
|
|
37
|
+
showCompanyPaymentSourceKidInvoice: (params) => trimTrailingUndefined([
|
|
38
|
+
...paymentAllocationKeys.all,
|
|
39
|
+
"showCompanyPaymentSourceKidInvoice",
|
|
40
|
+
params === undefined ? undefined : financeQueryIdentity(params),
|
|
41
|
+
]),
|
|
37
42
|
};
|
|
38
43
|
export function indexPaymentSourcesForCompaniesQueryOptions(sdk, params) {
|
|
39
44
|
return {
|
|
@@ -87,3 +92,15 @@ export function indexCompanyPaymentSourceInvoiceCandidatesQueryOptions(sdk, para
|
|
|
87
92
|
getPreviousPageParam: prevPageParam,
|
|
88
93
|
};
|
|
89
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The invoice a payment's KID names, with how and when it was closed. `invoice` is null when the
|
|
97
|
+
* KID names no invoice.
|
|
98
|
+
*/
|
|
99
|
+
export function showCompanyPaymentSourceKidInvoiceQueryOptions(sdk, params) {
|
|
100
|
+
return {
|
|
101
|
+
queryKey: [
|
|
102
|
+
paymentAllocationKeys.showCompanyPaymentSourceKidInvoice(params),
|
|
103
|
+
],
|
|
104
|
+
queryFn: () => showCompanyPaymentSourceKidInvoice(sdk, params),
|
|
105
|
+
};
|
|
106
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export * from "./api/commands/conversation/createInquiry.js";
|
|
|
64
64
|
export * from "./api/commands/conversation/createInquiryOpen.js";
|
|
65
65
|
export * from "./api/commands/conversation/createInternalConversationMessage.js";
|
|
66
66
|
export * from "./api/commands/conversation/createPublicConversationMessage.js";
|
|
67
|
+
export * from "./api/commands/conversation/createPublicConversationMessageWithInlineImages.js";
|
|
67
68
|
export * from "./api/commands/conversation/deleteConversation.js";
|
|
68
69
|
export * from "./api/commands/conversation/deleteConversationCategory.js";
|
|
69
70
|
export * from "./api/commands/conversation/deleteConversationParticipant.js";
|
|
@@ -124,6 +125,7 @@ export * from "./api/commands/invoicing/closeInvoice.js";
|
|
|
124
125
|
export * from "./api/commands/invoicing/createAdhocLinesForCompany.js";
|
|
125
126
|
export * from "./api/commands/invoicing/createAllocationKey.js";
|
|
126
127
|
export * from "./api/commands/invoicing/createCreditNote.js";
|
|
128
|
+
export * from "./api/commands/invoicing/creditInvoices.js";
|
|
127
129
|
export * from "./api/commands/invoicing/createCustomer.js";
|
|
128
130
|
export * from "./api/commands/invoicing/createCustomerById.js";
|
|
129
131
|
export * from "./api/commands/invoicing/createCustomerComment.js";
|
|
@@ -240,6 +242,7 @@ export * from "./api/commands/scopedContact/updateScopedContact.js";
|
|
|
240
242
|
export * from "./api/commands/section/assignParkingSpaceToSection.js";
|
|
241
243
|
export * from "./api/commands/section/assignStorageRoomToSection.js";
|
|
242
244
|
export * from "./api/commands/section/createSection.js";
|
|
245
|
+
export * from "./api/commands/section/importSectionsForOnboardingCompany.js";
|
|
243
246
|
export * from "./api/commands/section/createSectionStatus.js";
|
|
244
247
|
export * from "./api/commands/section/createSubSection.js";
|
|
245
248
|
export * from "./api/commands/section/deleteSection.js";
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ export * from "./api/commands/conversation/createInquiry.js";
|
|
|
60
60
|
export * from "./api/commands/conversation/createInquiryOpen.js";
|
|
61
61
|
export * from "./api/commands/conversation/createInternalConversationMessage.js";
|
|
62
62
|
export * from "./api/commands/conversation/createPublicConversationMessage.js";
|
|
63
|
+
export * from "./api/commands/conversation/createPublicConversationMessageWithInlineImages.js";
|
|
63
64
|
export * from "./api/commands/conversation/deleteConversation.js";
|
|
64
65
|
export * from "./api/commands/conversation/deleteConversationCategory.js";
|
|
65
66
|
export * from "./api/commands/conversation/deleteConversationParticipant.js";
|
|
@@ -120,6 +121,7 @@ export * from "./api/commands/invoicing/closeInvoice.js";
|
|
|
120
121
|
export * from "./api/commands/invoicing/createAdhocLinesForCompany.js";
|
|
121
122
|
export * from "./api/commands/invoicing/createAllocationKey.js";
|
|
122
123
|
export * from "./api/commands/invoicing/createCreditNote.js";
|
|
124
|
+
export * from "./api/commands/invoicing/creditInvoices.js";
|
|
123
125
|
export * from "./api/commands/invoicing/createCustomer.js";
|
|
124
126
|
export * from "./api/commands/invoicing/createCustomerById.js";
|
|
125
127
|
export * from "./api/commands/invoicing/createCustomerComment.js";
|
|
@@ -236,6 +238,7 @@ export * from "./api/commands/scopedContact/updateScopedContact.js";
|
|
|
236
238
|
export * from "./api/commands/section/assignParkingSpaceToSection.js";
|
|
237
239
|
export * from "./api/commands/section/assignStorageRoomToSection.js";
|
|
238
240
|
export * from "./api/commands/section/createSection.js";
|
|
241
|
+
export * from "./api/commands/section/importSectionsForOnboardingCompany.js";
|
|
239
242
|
export * from "./api/commands/section/createSectionStatus.js";
|
|
240
243
|
export * from "./api/commands/section/createSubSection.js";
|
|
241
244
|
export * from "./api/commands/section/deleteSection.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solibo/solibo-query",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.54.0-feature-utility-usage-e65c08f-1795009420051-SNAPSHOT",
|
|
4
4
|
"description": "Framework-agnostic TanStack Query options for the Solibo Home SDK. Solibo Home is the platform for owning and managing homes in Norway.",
|
|
5
5
|
"homepage": "https://sdk.solibo.no",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"buffer": "^6.0.3",
|
|
42
42
|
"hash-wasm": "^4.12.0",
|
|
43
43
|
"mime-types": "^3.0.2",
|
|
44
|
-
"@solibo/solibo-sdk": "1.
|
|
44
|
+
"@solibo/solibo-sdk": "1.54.0-feature-utility-usage-e65c08f-1795009420051-SNAPSHOT"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@eslint/js": "^10.0.1",
|