@opencxh/domain 1.278.0 → 1.280.0
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/entities/activity/index.d.ts +1 -0
- package/dist/entities/activity/resource-activity.d.ts +33 -0
- package/dist/entities/activity/types.d.ts +1 -1
- package/dist/entities/catalog/types.d.ts +5 -0
- package/dist/entities/company/types.d.ts +3 -0
- package/dist/entities/crm-activity/index.d.ts +43 -0
- package/dist/entities/time-entry/billing.d.ts +20 -0
- package/dist/entities/time-entry/billing.test.d.ts +1 -0
- package/dist/entities/time-entry/index.d.ts +1 -0
- package/dist/entities/time-entry/types.d.ts +5 -0
- package/dist/entities/transaction/types.d.ts +5 -0
- package/dist/entities/work/activity.d.ts +11 -35
- package/dist/index.cjs +16 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1239 -1189
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactionSummary } from '../reaction/types';
|
|
2
|
+
/**
|
|
3
|
+
* A feed row that hangs on something other than an interaction — a work item, a contact.
|
|
4
|
+
*
|
|
5
|
+
* Comms' `Activity` requires `interactionId` everywhere, so every other feed mirrors it minus the
|
|
6
|
+
* interaction fields. This is that mirror once, as a type only: each app keeps its own entity.
|
|
7
|
+
* The shape is what `wakesAssignment` and `buildTriggerVars` read structurally.
|
|
8
|
+
*/
|
|
9
|
+
export interface ResourceActivity<TType extends string, TPayload> {
|
|
10
|
+
id: string;
|
|
11
|
+
organizationId: string;
|
|
12
|
+
type: TType;
|
|
13
|
+
author: {
|
|
14
|
+
type: "user" | "system" | "app";
|
|
15
|
+
id?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Always `"internal"`. Never `"inbound"`: rule 1 of `wakesAssignment` treats inbound as
|
|
20
|
+
* "the customer answered" and would wake every waiting assignment on the row's subject.
|
|
21
|
+
*/
|
|
22
|
+
direction: "internal";
|
|
23
|
+
/** The activity this one answers — same one-level thread as comms' `BaseActivity.parentId`. */
|
|
24
|
+
parentId?: string;
|
|
25
|
+
payload: TPayload;
|
|
26
|
+
/**
|
|
27
|
+
* The emoji on this row, as the list route projects them. Read-only and never stored on the
|
|
28
|
+
* row — see `BaseActivity.reactions` and the generic store in the communication app.
|
|
29
|
+
*/
|
|
30
|
+
reactions?: ReactionSummary[];
|
|
31
|
+
createdAt?: number;
|
|
32
|
+
updatedAt?: number;
|
|
33
|
+
}
|
|
@@ -5,7 +5,7 @@ import { ReactionSummary } from '../reaction/types';
|
|
|
5
5
|
export type CallStatus = "new" | "connecting" | "ringing" | "connected" | "held" | "ended" | "failed";
|
|
6
6
|
export type CallDirection = "inbound" | "outbound";
|
|
7
7
|
export type CallType = "audio" | "video" | "data" | "screen-share";
|
|
8
|
-
export type ActivityType = "VOICE_CALL_STARTED" | "VOICE_CALL_ANSWERED" | "VOICE_CALL_HOLD" | "VOICE_CALL_UNHOLD" | "VOICE_CALL_ENDED" | "VOICE_CALL_MISSED" | "VOICE_CALL_VOICEMAIL" | "VIDEO_CALL_STARTED" | "VIDEO_CALL_ANSWERED" | "VIDEO_CALL_HOLD" | "VIDEO_CALL_UNHOLD" | "VIDEO_CALL_ENDED" | "VIDEO_CALL_MISSED" | "EMAIL_RECEIVED" | "EMAIL_SENT" | "CHAT_MESSAGE_SENT" | "CHAT_MESSAGE_RECEIVED" | "CHAT_MEMBER_JOINED" | "CHAT_MEMBER_LEFT" | "CHAT_RENAMED" | "CHAT_CALL_STARTED" | "CHAT_CALL_ENDED" | "CHAT_EVENT" | "AI_MESSAGE_ADDED" | "AI_ACTION_PROPOSED" | "PLAYBOOK_STARTED" | "PLAYBOOK_COMPLETED" | "PLAYBOOK_ESCALATED" | "AGENT_DELEGATED" | "AGENT_ANSWERED" | "MEETING_SCHEDULED" | "MEETING_STARTED" | "MEETING_ENDED" | "MEETING_PARTICIPANT_JOINED" | "MEETING_PARTICIPANT_LEFT" | "COMMENT_ADDED" | "FILE_UPLOADED" | "INTERACTION_CREATED" | "INTERACTION_STATUS_CHANGED" | "INTERACTION_ASSIGNED" | "SLA_BREACHED" | "VOICE_CALL_FAILED" | "VIDEO_CALL_FAILED" | "TRANSCRIPT_ADDED" | "WORK_COMMENT_ADDED" | "WORK_ITEM_ASSIGNED" | "WORK_ITEM_STATUS_CHANGED";
|
|
8
|
+
export type ActivityType = "VOICE_CALL_STARTED" | "VOICE_CALL_ANSWERED" | "VOICE_CALL_HOLD" | "VOICE_CALL_UNHOLD" | "VOICE_CALL_ENDED" | "VOICE_CALL_MISSED" | "VOICE_CALL_VOICEMAIL" | "VIDEO_CALL_STARTED" | "VIDEO_CALL_ANSWERED" | "VIDEO_CALL_HOLD" | "VIDEO_CALL_UNHOLD" | "VIDEO_CALL_ENDED" | "VIDEO_CALL_MISSED" | "EMAIL_RECEIVED" | "EMAIL_SENT" | "CHAT_MESSAGE_SENT" | "CHAT_MESSAGE_RECEIVED" | "CHAT_MEMBER_JOINED" | "CHAT_MEMBER_LEFT" | "CHAT_RENAMED" | "CHAT_CALL_STARTED" | "CHAT_CALL_ENDED" | "CHAT_EVENT" | "AI_MESSAGE_ADDED" | "AI_ACTION_PROPOSED" | "PLAYBOOK_STARTED" | "PLAYBOOK_COMPLETED" | "PLAYBOOK_ESCALATED" | "AGENT_DELEGATED" | "AGENT_ANSWERED" | "MEETING_SCHEDULED" | "MEETING_STARTED" | "MEETING_ENDED" | "MEETING_PARTICIPANT_JOINED" | "MEETING_PARTICIPANT_LEFT" | "COMMENT_ADDED" | "FILE_UPLOADED" | "INTERACTION_CREATED" | "INTERACTION_STATUS_CHANGED" | "INTERACTION_ASSIGNED" | "SLA_BREACHED" | "VOICE_CALL_FAILED" | "VIDEO_CALL_FAILED" | "TRANSCRIPT_ADDED" | "WORK_COMMENT_ADDED" | "WORK_ITEM_ASSIGNED" | "WORK_ITEM_STATUS_CHANGED" | "CRM_NOTE_ADDED" | "CRM_CALL_LOGGED" | "CRM_STAGE_CHANGED";
|
|
9
9
|
export interface Attachment {
|
|
10
10
|
id: string;
|
|
11
11
|
filename: string;
|
|
@@ -39,6 +39,11 @@ export interface Product {
|
|
|
39
39
|
ledgerCategoryKey?: string;
|
|
40
40
|
/** References to this product elsewhere (`moneybird:412`). A reference, never a copy. */
|
|
41
41
|
externalIds?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Hours booked on this `WorkType.key` are invoiced as this product. Here and not on the work
|
|
44
|
+
* type: time must not know sales, and several products may share one type (junior/senior).
|
|
45
|
+
*/
|
|
46
|
+
workTypeKey?: string;
|
|
42
47
|
/** See {@link FIXED_UNITS}. Drives the form and the word after the quantity. */
|
|
43
48
|
unitKey: string;
|
|
44
49
|
/** Key into the organisation's VAT table, never the percentage itself. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PostalAddress } from '../organization/types';
|
|
2
|
+
import { LifecycleStage } from '../contact/lifecycle';
|
|
2
3
|
import { OwnerScope } from '../scope/types';
|
|
3
4
|
/** Same meaning as {@link ContactOrigin}: `shadow` is a lazily cached hit, a landed row is `own`. */
|
|
4
5
|
export type CompanyOrigin = "own" | "shadow";
|
|
@@ -43,6 +44,8 @@ export interface Company {
|
|
|
43
44
|
ownerScope: OwnerScope;
|
|
44
45
|
source: CompanySource;
|
|
45
46
|
origin?: CompanyOrigin;
|
|
47
|
+
/** Where the organisation stands with us; independent of its contacts' own stages. */
|
|
48
|
+
lifecycleStage?: LifecycleStage;
|
|
46
49
|
/** The group this company belongs to. One level up per row; a cycle is refused on write. */
|
|
47
50
|
parentCompanyId?: string;
|
|
48
51
|
/**
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ResourceActivity } from '../activity/resource-activity';
|
|
2
|
+
import { LifecycleStage } from '../contact/lifecycle';
|
|
3
|
+
/**
|
|
4
|
+
* The feed under a contact or a company: notes, logged calls, stage changes.
|
|
5
|
+
*
|
|
6
|
+
* The work-activity pattern (`entities/work/activity.ts`), keyed on the record's scope key
|
|
7
|
+
* (`contact:<id>`, `company:<id>`) instead of an item id. The type names are crm's own — reusing
|
|
8
|
+
* comms' `COMMENT_ADDED` would fire every comms playbook trigger on a crm note.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CRM_NOTE_ADDED = "CRM_NOTE_ADDED";
|
|
11
|
+
/** The scope kind of one feed row, `crm_activity:<id>` — what the reaction store asks about. */
|
|
12
|
+
export declare const CRM_ACTIVITY_SCOPE_KIND = "crm_activity";
|
|
13
|
+
/** A call or meeting that happened outside the system, written down afterwards. */
|
|
14
|
+
export declare const CRM_CALL_LOGGED = "CRM_CALL_LOGGED";
|
|
15
|
+
/** History, not content: written by the update routes, never editable. */
|
|
16
|
+
export declare const CRM_STAGE_CHANGED = "CRM_STAGE_CHANGED";
|
|
17
|
+
export type CrmActivityType = typeof CRM_NOTE_ADDED | typeof CRM_CALL_LOGGED | typeof CRM_STAGE_CHANGED;
|
|
18
|
+
export declare const CRM_CALL_CHANNELS: readonly ["phone", "meeting", "video"];
|
|
19
|
+
export type CrmCallChannel = (typeof CRM_CALL_CHANNELS)[number];
|
|
20
|
+
export declare const CRM_CALL_OUTCOMES: readonly ["callback", "interested", "no_answer", "not_interested"];
|
|
21
|
+
export type CrmCallOutcome = (typeof CRM_CALL_OUTCOMES)[number];
|
|
22
|
+
export interface CrmCall {
|
|
23
|
+
channel: CrmCallChannel;
|
|
24
|
+
/** When the call happened, not when it was logged. The timeline sorts on this. */
|
|
25
|
+
at: number;
|
|
26
|
+
durationMin?: number;
|
|
27
|
+
outcome?: CrmCallOutcome;
|
|
28
|
+
}
|
|
29
|
+
export interface CrmActivity extends ResourceActivity<CrmActivityType, {
|
|
30
|
+
text?: string;
|
|
31
|
+
html?: string;
|
|
32
|
+
mentions?: string[];
|
|
33
|
+
call?: CrmCall;
|
|
34
|
+
fromStage?: LifecycleStage;
|
|
35
|
+
toStage?: LifecycleStage;
|
|
36
|
+
}> {
|
|
37
|
+
/** `contact:<id>` or `company:<id>`. */
|
|
38
|
+
record: string;
|
|
39
|
+
}
|
|
40
|
+
/** Rows a person wrote, and may therefore edit or delete. A stage row is history. */
|
|
41
|
+
export declare const isAuthoredCrmActivity: (type: string) => boolean;
|
|
42
|
+
/** Where the timeline puts the row: a call at the moment it happened, the rest when written. */
|
|
43
|
+
export declare const crmActivityAt: (activity: CrmActivity) => number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TimeEntry } from './types';
|
|
2
|
+
/** Booked hours that become one invoice line: one work type on one subject. */
|
|
3
|
+
export interface BillableTimeGroup {
|
|
4
|
+
/** `WorkType.key`; absent = booked without a type, which no product can carry. */
|
|
5
|
+
workType?: string;
|
|
6
|
+
scopeKey?: string;
|
|
7
|
+
scopeLabel?: string;
|
|
8
|
+
seconds: number;
|
|
9
|
+
/** Hours, two decimals — what goes on the line as `quantity`. */
|
|
10
|
+
hours: number;
|
|
11
|
+
entryIds: string[];
|
|
12
|
+
/** Epoch ms of the first and last entry, for the line's description. */
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Group billable entries per work type × subject, in the order they were first booked.
|
|
18
|
+
* `durationSeconds` is the booked duration, so rounding has already been applied per entry.
|
|
19
|
+
*/
|
|
20
|
+
export declare function billableTimeGroups(entries: readonly TimeEntry[]): BillableTimeGroup[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -69,6 +69,11 @@ export interface TimeEntry {
|
|
|
69
69
|
workType?: string;
|
|
70
70
|
note?: string;
|
|
71
71
|
source: TimeEntrySource;
|
|
72
|
+
/**
|
|
73
|
+
* The invoice (a sales transaction id) this entry is on, draft included. Set by sales only;
|
|
74
|
+
* while set, the entry cannot be edited or deleted — that is what stops billing it twice.
|
|
75
|
+
*/
|
|
76
|
+
invoicedTransactionId?: string;
|
|
72
77
|
createdAt?: number;
|
|
73
78
|
updatedAt?: number;
|
|
74
79
|
}
|
|
@@ -177,6 +177,11 @@ export interface TransactionLine {
|
|
|
177
177
|
* booked against, not what the customer reads.
|
|
178
178
|
*/
|
|
179
179
|
dealItemId?: string;
|
|
180
|
+
/**
|
|
181
|
+
* The time entries this line bills. Sales stamps exactly this set onto them on every save, so
|
|
182
|
+
* the line — not the entry — is the source of truth. Never copied to a new document.
|
|
183
|
+
*/
|
|
184
|
+
timeEntryIds?: string[];
|
|
180
185
|
/**
|
|
181
186
|
* An option: priced and shown, but **not** in the total.
|
|
182
187
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResourceActivity } from '../activity/resource-activity';
|
|
2
2
|
import { WorkStatusCategory } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* The activity feed under a work item.
|
|
@@ -22,39 +22,15 @@ export declare const WORK_ITEM_ASSIGNED = "WORK_ITEM_ASSIGNED";
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const WORK_ITEM_STATUS_CHANGED = "WORK_ITEM_STATUS_CHANGED";
|
|
24
24
|
export type WorkActivityType = typeof WORK_COMMENT_ADDED | typeof WORK_ITEM_ASSIGNED | typeof WORK_ITEM_STATUS_CHANGED;
|
|
25
|
-
export interface WorkActivity {
|
|
26
|
-
id: string;
|
|
27
|
-
organizationId: string;
|
|
28
|
-
itemId: string;
|
|
29
|
-
type: WorkActivityType;
|
|
30
|
-
author: {
|
|
31
|
-
type: "user" | "system" | "app";
|
|
32
|
-
id?: string;
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Always `"internal"`. Never `"inbound"`: rule 1 of `wakesAssignment` treats inbound as
|
|
37
|
-
* "the customer answered" and would wake every waiting assignment on the item.
|
|
38
|
-
*/
|
|
39
|
-
direction: "internal";
|
|
40
|
-
/** The activity this one answers — same one-level thread as comms' `BaseActivity.parentId`. */
|
|
41
|
-
parentId?: string;
|
|
25
|
+
export interface WorkActivity extends ResourceActivity<WorkActivityType, {
|
|
42
26
|
/** `html` is the composer's markup for a comment; `text` stays the plain reading of it. */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The emoji on this comment, as the list route projects them. Read-only and never stored
|
|
54
|
-
* on the row — see `BaseActivity.reactions`, which this mirrors, and the generic store in
|
|
55
|
-
* the communication app that both read from.
|
|
56
|
-
*/
|
|
57
|
-
reactions?: ReactionSummary[];
|
|
58
|
-
createdAt?: number;
|
|
59
|
-
updatedAt?: number;
|
|
27
|
+
text?: string;
|
|
28
|
+
html?: string;
|
|
29
|
+
mentions?: string[];
|
|
30
|
+
assigneeId?: string;
|
|
31
|
+
fromStatus?: string;
|
|
32
|
+
toStatus?: string;
|
|
33
|
+
toCategory?: WorkStatusCategory;
|
|
34
|
+
}> {
|
|
35
|
+
itemId: string;
|
|
60
36
|
}
|