@jsb188/mday 1.1.2
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/package.json +142 -0
- package/src/constants/agentMemory.ts +166 -0
- package/src/constants/agentNote.ts +212 -0
- package/src/constants/aiChat.ts +10 -0
- package/src/constants/billing.ts +126 -0
- package/src/constants/campaign.ts +236 -0
- package/src/constants/contact.ts +72 -0
- package/src/constants/csvExport.ts +133 -0
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/dataTableFieldTypes.generated.ts +59 -0
- package/src/constants/docAccess.ts +33 -0
- package/src/constants/dt.ts +234 -0
- package/src/constants/email.ts +146 -0
- package/src/constants/fieldDoc.ts +104 -0
- package/src/constants/graphqlReactivity.ts +196 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +13 -0
- package/src/constants/log.ts +21 -0
- package/src/constants/logDisplay/README.md +88 -0
- package/src/constants/logDisplay/defaults.ts +39 -0
- package/src/constants/logDisplay/index.ts +27 -0
- package/src/constants/logDisplay/operations/arable.ts +16 -0
- package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
- package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
- package/src/constants/logDisplay/shared/accounting.ts +13 -0
- package/src/constants/logDisplay/shared/interactions.ts +13 -0
- package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
- package/src/constants/logTaxonomy.generated.ts +2199 -0
- package/src/constants/noteDoc.ts +77 -0
- package/src/constants/organization.ts +60 -0
- package/src/constants/pageRoute.ts +23 -0
- package/src/constants/qrCode.ts +30 -0
- package/src/constants/sheet.ts +132 -0
- package/src/constants/sms.ts +18 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +85 -0
- package/src/constants/usage.ts +82 -0
- package/src/constants/workflowSteps.ts +60 -0
- package/src/schemas/editLogEntry.ts +879 -0
- package/src/schemas/inboundContact.ts +77 -0
- package/src/schemas/logsQuery.ts +93 -0
- package/src/types/account.d.ts +81 -0
- package/src/types/agentMemory.d.ts +100 -0
- package/src/types/agentNote.d.ts +441 -0
- package/src/types/billing.d.ts +537 -0
- package/src/types/campaign.d.ts +1533 -0
- package/src/types/contact.d.ts +15 -0
- package/src/types/csvExport.d.ts +213 -0
- package/src/types/dataAnalysis.d.ts +44 -0
- package/src/types/dataTable.d.ts +159 -0
- package/src/types/definitionElement.d.ts +35 -0
- package/src/types/docAccess.d.ts +96 -0
- package/src/types/dt.d.ts +257 -0
- package/src/types/email.d.ts +231 -0
- package/src/types/emailReplyReport.d.ts +76 -0
- package/src/types/fieldDoc.d.ts +702 -0
- package/src/types/fieldDocContract.d.ts +90 -0
- package/src/types/inboundContact.d.ts +65 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +338 -0
- package/src/types/logDisplay.types.ts +85 -0
- package/src/types/organization.d.ts +350 -0
- package/src/types/pageRoute.d.ts +48 -0
- package/src/types/qrCode.d.ts +96 -0
- package/src/types/richText.d.ts +81 -0
- package/src/types/sheet.d.ts +847 -0
- package/src/types/sms.d.ts +38 -0
- package/src/types/storage.d.ts +481 -0
- package/src/types/usage.d.ts +106 -0
- package/src/types/workflow.d.ts +435 -0
- package/src/utils/agentMemory.ts +15 -0
- package/src/utils/agentNote.ts +850 -0
- package/src/utils/aiChat.ts +43 -0
- package/src/utils/aiChatWork.ts +64 -0
- package/src/utils/billing.ts +37 -0
- package/src/utils/campaign.ts +1173 -0
- package/src/utils/campaignAI.ts +72 -0
- package/src/utils/campaignAccess.ts +239 -0
- package/src/utils/campaignEmail.ts +601 -0
- package/src/utils/campaignEmailCompiler.ts +372 -0
- package/src/utils/campaignEmailImages.ts +60 -0
- package/src/utils/campaignEmailStyles.ts +544 -0
- package/src/utils/campaignLifecycle.ts +104 -0
- package/src/utils/campaignPreview.ts +285 -0
- package/src/utils/contact.ts +50 -0
- package/src/utils/csvExport.ts +19 -0
- package/src/utils/dataTable.ts +311 -0
- package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
- package/src/utils/dataTableRelativeDate.ts +447 -0
- package/src/utils/definitionElement.ts +84 -0
- package/src/utils/docAccess.ts +383 -0
- package/src/utils/documentName.ts +53 -0
- package/src/utils/email.ts +379 -0
- package/src/utils/emailReplyReport.test.ts +187 -0
- package/src/utils/emailReplyReport.ts +143 -0
- package/src/utils/fieldDoc.ts +157 -0
- package/src/utils/fieldDocAnswers.ts +128 -0
- package/src/utils/fieldDocDefaults.ts +36 -0
- package/src/utils/fieldDocProgram.ts +36 -0
- package/src/utils/fieldDocSummary.ts +30 -0
- package/src/utils/log.ts +357 -0
- package/src/utils/logDisplay.helpers.ts +177 -0
- package/src/utils/logDisplay.ts +87 -0
- package/src/utils/logRegistryValue.ts +90 -0
- package/src/utils/logStoreRead.ts +262 -0
- package/src/utils/logTaxonomy.helpers.ts +17 -0
- package/src/utils/logTaxonomy.ts +76 -0
- package/src/utils/logTaxonomyDisplay.ts +395 -0
- package/src/utils/noteDoc.ts +609 -0
- package/src/utils/organization.ts +669 -0
- package/src/utils/pageRoute.ts +71 -0
- package/src/utils/qrCode.helpers.ts +189 -0
- package/src/utils/qrCode.test.ts +519 -0
- package/src/utils/qrCode.ts +273 -0
- package/src/utils/richTextHTML.ts +385 -0
- package/src/utils/sheet.ts +262 -0
- package/src/utils/sheetAxisMove.ts +616 -0
- package/src/utils/sheetBootstrap.ts +1402 -0
- package/src/utils/sheetCellLiteral.ts +101 -0
- package/src/utils/sheetCommand.ts +358 -0
- package/src/utils/sheetDesign.ts +705 -0
- package/src/utils/sheetExport.ts +186 -0
- package/src/utils/sheetFeatureReference.ts +183 -0
- package/src/utils/sheetFormulaArgs.ts +168 -0
- package/src/utils/sheetFormulaCompile.ts +475 -0
- package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
- package/src/utils/sheetFormulaCriteria.ts +656 -0
- package/src/utils/sheetFormulaDate.ts +444 -0
- package/src/utils/sheetFormulaEvaluation.ts +899 -0
- package/src/utils/sheetFormulaEvaluator.ts +997 -0
- package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
- package/src/utils/sheetFormulaLogical.ts +116 -0
- package/src/utils/sheetFormulaLookup.ts +488 -0
- package/src/utils/sheetFormulaMath.ts +48 -0
- package/src/utils/sheetFormulaParser.ts +729 -0
- package/src/utils/sheetFormulaRange.ts +330 -0
- package/src/utils/sheetFormulaReference.ts +703 -0
- package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
- package/src/utils/sheetFormulaReferenceDates.ts +237 -0
- package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
- package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
- package/src/utils/sheetFormulaReferenceMath.ts +95 -0
- package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
- package/src/utils/sheetFormulaReferenceText.ts +462 -0
- package/src/utils/sheetFormulaSyntax.ts +1027 -0
- package/src/utils/sheetFormulaText.ts +430 -0
- package/src/utils/sheetJournal.ts +200 -0
- package/src/utils/sheetNumberFormat.ts +1012 -0
- package/src/utils/sheetPreview.ts +68 -0
- package/src/utils/sheetSequence.ts +118 -0
- package/src/utils/sheetSnapshot.ts +739 -0
- package/src/utils/sheetStructureEdit.ts +914 -0
- package/src/utils/sheetStructureReferences.ts +389 -0
- package/src/utils/square.ts +32 -0
- package/src/utils/storage.ts +198 -0
- package/src/utils/table-route.ts +262 -0
- package/src/utils/time.ts +12 -0
- package/src/utils/workflow.ts +506 -0
- package/src/utils/workflowLogFingerprint.ts +302 -0
- package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
- package/src/utils/workflowProgress.ts +280 -0
- package/src/utils/workflowTriggers.ts +61 -0
- package/tests/agentNote.test.ts +395 -0
- package/tests/campaignAI.test.ts +119 -0
- package/tests/campaignAccess.test.ts +239 -0
- package/tests/campaignEmail.test.ts +441 -0
- package/tests/campaignLifecycle.test.ts +134 -0
- package/tests/campaignPublication.test.ts +309 -0
- package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
- package/tests/dataTableRelativeDate.test.ts +412 -0
- package/tests/docAccess.test.ts +525 -0
- package/tests/editLogEntry.test.ts +112 -0
- package/tests/email.test.ts +39 -0
- package/tests/fieldDocProgram.test.ts +114 -0
- package/tests/logDisplay.fixtures.ts +67 -0
- package/tests/logDisplay.test.ts +227 -0
- package/tests/noteDoc.test.ts +514 -0
- package/tests/richTextHTML.test.ts +185 -0
- package/tests/sheetAxisMove.test.ts +352 -0
- package/tests/sheetBootstrap.test.ts +1967 -0
- package/tests/sheetFeatureReference.test.ts +22 -0
- package/tests/sheetFormulaCriteria.test.ts +269 -0
- package/tests/sheetFormulaEvaluator.test.ts +468 -0
- package/tests/sheetFormulaFunctions.test.ts +538 -0
- package/tests/sheetFormulaLanguage.test.ts +361 -0
- package/tests/sheetFormulaParity.fixtures.ts +872 -0
- package/tests/sheetFormulaParity.test.ts +188 -0
- package/tests/sheetFormulaRange.test.ts +167 -0
- package/tests/sheetFormulaReference.test.ts +78 -0
- package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
- package/tests/sheetFormulaTextDate.test.ts +512 -0
- package/tests/sheetSequence.test.ts +22 -0
- package/tests/sheetSnapshot.test.ts +134 -0
- package/tests/sheetStructureEdit.test.ts +537 -0
- package/tests/sheetStructureReferences.test.ts +589 -0
- package/tests/workflowLifecycleStatus.test.ts +60 -0
- package/tests/workflowLogFingerprint.test.ts +203 -0
- package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
- package/tests/workflowProgress.test.ts +180 -0
- package/tests/workflowTriggers.test.ts +29 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import type { InboundContactGQL } from '../types/inboundContact.d.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Length values for validation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MIN_LEN_VALUES = {
|
|
9
|
+
email: 100,
|
|
10
|
+
memory: 750,
|
|
11
|
+
personName: 120,
|
|
12
|
+
phone: 40,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Schema; Edit inbound contact
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export function makeEditInboundContactSchema(
|
|
20
|
+
formId: string,
|
|
21
|
+
focusedName: string,
|
|
22
|
+
formValues: Partial<InboundContactGQL>, // always append with "|| nodeData"
|
|
23
|
+
) {
|
|
24
|
+
return {
|
|
25
|
+
listData: [
|
|
26
|
+
{
|
|
27
|
+
__type: 'input',
|
|
28
|
+
item: {
|
|
29
|
+
name: 'personName',
|
|
30
|
+
maxLength: MIN_LEN_VALUES.personName,
|
|
31
|
+
label: i18n.t('c.name'),
|
|
32
|
+
placeholder: formValues.personName || '',
|
|
33
|
+
autoComplete: 'off',
|
|
34
|
+
focused: focusedName === formId + '_personName',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
__type: 'input',
|
|
39
|
+
item: {
|
|
40
|
+
name: 'email',
|
|
41
|
+
maxLength: MIN_LEN_VALUES.email,
|
|
42
|
+
label: i18n.t('c.email'),
|
|
43
|
+
placeholder: formValues.email || '',
|
|
44
|
+
autoComplete: 'off',
|
|
45
|
+
type: 'email',
|
|
46
|
+
focused: focusedName === formId + '_email',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
__type: 'input',
|
|
51
|
+
item: {
|
|
52
|
+
name: 'phone',
|
|
53
|
+
maxLength: MIN_LEN_VALUES.phone,
|
|
54
|
+
label: i18n.t('c.phone'),
|
|
55
|
+
placeholder: formValues.phone || '',
|
|
56
|
+
autoComplete: 'off',
|
|
57
|
+
type: 'tel',
|
|
58
|
+
focused: focusedName === formId + '_phone',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
__type: 'textarea',
|
|
63
|
+
item: {
|
|
64
|
+
name: 'memory',
|
|
65
|
+
maxLength: MIN_LEN_VALUES.memory,
|
|
66
|
+
label: i18n.t('c.memories'),
|
|
67
|
+
description: i18n.t('c.ai_memories_desc'),
|
|
68
|
+
placeholder: formValues.memory || '',
|
|
69
|
+
autoComplete: 'off',
|
|
70
|
+
minHeight: 80,
|
|
71
|
+
focused: focusedName === formId + '_memory',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
rules: [],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { isFutureCalDate, isValidCalDate } from '@jsb188/app/utils/datetime.ts';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import {
|
|
4
|
+
LOG_ANY_ACTIVITY_ENUMS,
|
|
5
|
+
LOG_ANY_TYPE_ENUMS,
|
|
6
|
+
LOG_SORT_ENUMS,
|
|
7
|
+
LOG_TYPES_BY_OPERATION,
|
|
8
|
+
} from '../constants/log.ts';
|
|
9
|
+
import type { FilterLogEntriesArgs, LogTypeEnum } from '../types/log.d.ts';
|
|
10
|
+
import type { OrganizationOperationEnum } from '../types/organization.d.ts';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Zod schema for query params to filter
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const FilterLogEntriesSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
siteId: z.string().optional().nullable(),
|
|
19
|
+
preset: z.string().optional().nullable(),
|
|
20
|
+
types: z.array(z.enum(LOG_ANY_TYPE_ENUMS)).nullable(),
|
|
21
|
+
activities: z.array(z.enum(LOG_ANY_ACTIVITY_ENUMS)).optional().nullable(),
|
|
22
|
+
startDate: z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((sd) => isValidCalDate(sd), { message: 'START_DATE_INVALID' })
|
|
25
|
+
.refine((sd) => !isFutureCalDate(sd, 1), {
|
|
26
|
+
message: 'START_DATE_FUTURE_NOT_ALLOWED',
|
|
27
|
+
})
|
|
28
|
+
.nullable(),
|
|
29
|
+
endDate: z
|
|
30
|
+
.string()
|
|
31
|
+
.refine((ed) => isValidCalDate(ed), { message: 'END_DATE_INVALID' })
|
|
32
|
+
.nullable(),
|
|
33
|
+
query: z.string().nullable(),
|
|
34
|
+
})
|
|
35
|
+
.refine(
|
|
36
|
+
(data) => {
|
|
37
|
+
if (!data.endDate) {
|
|
38
|
+
// No need to validate if endDate is not provided
|
|
39
|
+
return true;
|
|
40
|
+
} else if (!data.startDate) {
|
|
41
|
+
// If endDate is provided, startDate is required
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
// End date must be after or equal to start date
|
|
45
|
+
return data.endDate >= data.startDate;
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
message: 'END_DATE_MUST_BE_AFTER_START_DATE',
|
|
49
|
+
path: ['endDate'], // where to attach the error
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Convert list of digits to log type enums
|
|
55
|
+
* @param operationType - The type of operation for organization
|
|
56
|
+
* @param types - Comma-separated string of digits representing log types
|
|
57
|
+
* @returns Array of log type enums or null
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
export function convertDigitsToLogTypes(
|
|
61
|
+
operationType: OrganizationOperationEnum | null,
|
|
62
|
+
typesStr?: string | null,
|
|
63
|
+
) {
|
|
64
|
+
if (!operationType || !typesStr) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const logTypes = LOG_TYPES_BY_OPERATION[operationType] as LogTypeEnum[];
|
|
69
|
+
if (!logTypes) {
|
|
70
|
+
console.warn(`No log types found for operation type: ${operationType}`);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return logTypes
|
|
75
|
+
.map((type: LogTypeEnum, i: number) => {
|
|
76
|
+
const value = typesStr.charAt(i);
|
|
77
|
+
if (value === '1') {
|
|
78
|
+
return type;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
})
|
|
82
|
+
.filter(Boolean) as FilterLogEntriesArgs['types'];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get Sort enum value from URL
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
export function getLogSorValueFromURL(searchQuery: string) {
|
|
90
|
+
const urlParams = new URLSearchParams(searchQuery);
|
|
91
|
+
const sortIndex = urlParams.get('s');
|
|
92
|
+
return LOG_SORT_ENUMS[Number(sortIndex) - 1] || null;
|
|
93
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
OrganizationACL,
|
|
3
|
+
OrganizationRoleEnum,
|
|
4
|
+
} from './organization.d.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Account; phone
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface AccountPhoneObj {
|
|
11
|
+
id: number;
|
|
12
|
+
number: string;
|
|
13
|
+
verified: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Account
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export interface AccountObj {
|
|
21
|
+
id: number | bigint;
|
|
22
|
+
readableId?: string | null;
|
|
23
|
+
settings: Record<string, any>;
|
|
24
|
+
profile: Partial<{
|
|
25
|
+
firstName: string;
|
|
26
|
+
lastName: string;
|
|
27
|
+
storageId: number | null;
|
|
28
|
+
// phone: AccountPhoneObj | null; // ?? This is a coding mistake, I think
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface AccountData {
|
|
33
|
+
__table: 'accounts';
|
|
34
|
+
|
|
35
|
+
id: number | bigint;
|
|
36
|
+
readableId?: string | null;
|
|
37
|
+
settings: Record<string, any>;
|
|
38
|
+
|
|
39
|
+
profile: {
|
|
40
|
+
__table: 'account_profiles';
|
|
41
|
+
id: number | bigint;
|
|
42
|
+
firstName: string;
|
|
43
|
+
lastName: string;
|
|
44
|
+
storageId: number | bigint | null;
|
|
45
|
+
};
|
|
46
|
+
phone: {
|
|
47
|
+
__table: 'account_phones';
|
|
48
|
+
id: number;
|
|
49
|
+
number: string;
|
|
50
|
+
verified: boolean;
|
|
51
|
+
banned: boolean;
|
|
52
|
+
editAt: Date;
|
|
53
|
+
};
|
|
54
|
+
email: {
|
|
55
|
+
__table: 'account_emails';
|
|
56
|
+
id: number;
|
|
57
|
+
address: string;
|
|
58
|
+
verified: boolean;
|
|
59
|
+
banned: boolean;
|
|
60
|
+
editAt: Date;
|
|
61
|
+
};
|
|
62
|
+
createdAt: Date;
|
|
63
|
+
updatedAt: Date;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Account with membership
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
export interface AccountMembershipData {
|
|
71
|
+
id: number;
|
|
72
|
+
accountId: number;
|
|
73
|
+
organizationId: number;
|
|
74
|
+
role: OrganizationRoleEnum;
|
|
75
|
+
acl: OrganizationACL;
|
|
76
|
+
notes?: string;
|
|
77
|
+
primary: boolean;
|
|
78
|
+
createdAt: Date;
|
|
79
|
+
updatedAt: Date;
|
|
80
|
+
account: AccountData;
|
|
81
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AGENT_MEMORY_CATEGORY_ENUMS,
|
|
3
|
+
AGENT_MEMORY_CREATED_VIA_ENUMS,
|
|
4
|
+
AGENT_MEMORY_SCOPE_ENUMS,
|
|
5
|
+
AGENT_MEMORY_STATUS_ENUMS,
|
|
6
|
+
AGENT_MEMORY_SURFACE_ENUMS,
|
|
7
|
+
} from '../constants/agentMemory.ts';
|
|
8
|
+
|
|
9
|
+
export type AgentMemoryScopeEnum = (typeof AGENT_MEMORY_SCOPE_ENUMS)[number];
|
|
10
|
+
export type AgentMemoryCategoryEnum = (typeof AGENT_MEMORY_CATEGORY_ENUMS)[number];
|
|
11
|
+
export type AgentMemoryStatusEnum = (typeof AGENT_MEMORY_STATUS_ENUMS)[number];
|
|
12
|
+
export type AgentMemoryCreatedViaEnum = (typeof AGENT_MEMORY_CREATED_VIA_ENUMS)[number];
|
|
13
|
+
export type AgentMemorySurfaceEnum = (typeof AGENT_MEMORY_SURFACE_ENUMS)[number];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* One remembered fact.
|
|
17
|
+
*
|
|
18
|
+
* Exactly one subject column is set per scope: "accountId" for ACCOUNT,
|
|
19
|
+
* "counterpartyId" for COUNTERPARTY, neither for ORGANIZATION.
|
|
20
|
+
*
|
|
21
|
+
* "createdByCounterpartyId" marks an externally-authored row (an inbound email
|
|
22
|
+
* sender); the database constrains such a row to be COUNTERPARTY-scoped about
|
|
23
|
+
* that same counterparty.
|
|
24
|
+
*/
|
|
25
|
+
export interface AgentMemoryData {
|
|
26
|
+
__table: 'agent_memories';
|
|
27
|
+
id: bigint;
|
|
28
|
+
organizationId: bigint;
|
|
29
|
+
scope: AgentMemoryScopeEnum;
|
|
30
|
+
accountId: bigint | null;
|
|
31
|
+
counterpartyId: bigint | null;
|
|
32
|
+
category: AgentMemoryCategoryEnum;
|
|
33
|
+
surface: AgentMemorySurfaceEnum[] | null;
|
|
34
|
+
surfaceKey: string | null;
|
|
35
|
+
key: string;
|
|
36
|
+
content: string;
|
|
37
|
+
status: AgentMemoryStatusEnum;
|
|
38
|
+
permanent: boolean;
|
|
39
|
+
observedCount: number;
|
|
40
|
+
createdByAccountId: bigint | null;
|
|
41
|
+
createdByCounterpartyId: bigint | null;
|
|
42
|
+
createdVia: AgentMemoryCreatedViaEnum;
|
|
43
|
+
sourceMessageId: string | null;
|
|
44
|
+
updatedByAccountId: bigint | null;
|
|
45
|
+
expiresAt: Date | null;
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
updatedAt: Date;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* One human-manageable memory with serialized subject identifiers and display names.
|
|
52
|
+
*/
|
|
53
|
+
export interface AgentMemoryGQL {
|
|
54
|
+
id: string;
|
|
55
|
+
organizationId: string;
|
|
56
|
+
scope: AgentMemoryScopeEnum;
|
|
57
|
+
accountId: string | null;
|
|
58
|
+
accountName?: string | null;
|
|
59
|
+
counterpartyId: string | null;
|
|
60
|
+
inboundContactId?: string | null;
|
|
61
|
+
counterpartyName?: string | null;
|
|
62
|
+
category: AgentMemoryCategoryEnum;
|
|
63
|
+
content: string;
|
|
64
|
+
status: AgentMemoryStatusEnum;
|
|
65
|
+
permanent: boolean;
|
|
66
|
+
surface: AgentMemorySurfaceEnum[] | null;
|
|
67
|
+
surfaceKey: string | null;
|
|
68
|
+
createdVia: AgentMemoryCreatedViaEnum;
|
|
69
|
+
createdByName?: string | null;
|
|
70
|
+
sourceMessageId?: string | null;
|
|
71
|
+
sourceInboundEmailId?: string | null;
|
|
72
|
+
createdAt?: string | null;
|
|
73
|
+
updatedAt?: string | null;
|
|
74
|
+
expiresAt?: string | null;
|
|
75
|
+
__deleted?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Immutable per-log provenance snapshot stored on logs."appliedMemories".
|
|
80
|
+
*
|
|
81
|
+
* "content" is a verbatim copy of what the rule said at write time, resolved
|
|
82
|
+
* by the server from the structured context captured for that provider request
|
|
83
|
+
* - never from model-supplied text. Private ACCOUNT memories are omitted from
|
|
84
|
+
* shared log provenance. "reasoning" is model-generated and can be
|
|
85
|
+
* confabulated; it is a debugging aid, not evidence.
|
|
86
|
+
*/
|
|
87
|
+
export interface AppliedMemorySnapshotItem {
|
|
88
|
+
id: number;
|
|
89
|
+
// Verbatim copy of what the rule said in the exact structured context
|
|
90
|
+
// captured for the provider request. Scope is deliberately absent from this
|
|
91
|
+
// v1 log snapshot even though the request-scoped context retains it; ACCOUNT
|
|
92
|
+
// memories are never copied into this shared snapshot.
|
|
93
|
+
content: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface AppliedMemoriesSnapshot {
|
|
97
|
+
v: 1;
|
|
98
|
+
reasoning?: string | null;
|
|
99
|
+
memories: AppliedMemorySnapshotItem[];
|
|
100
|
+
}
|