@contractspec/example.crm-pipeline 1.44.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/.turbo/turbo-build$colon$bundle.log +97 -0
- package/.turbo/turbo-build.log +98 -0
- package/CHANGELOG.md +246 -0
- package/LICENSE +21 -0
- package/README.md +139 -0
- package/dist/crm-pipeline.feature.d.ts +12 -0
- package/dist/crm-pipeline.feature.d.ts.map +1 -0
- package/dist/crm-pipeline.feature.js +159 -0
- package/dist/crm-pipeline.feature.js.map +1 -0
- package/dist/deal/deal.enum.d.ts +14 -0
- package/dist/deal/deal.enum.d.ts.map +1 -0
- package/dist/deal/deal.enum.js +25 -0
- package/dist/deal/deal.enum.js.map +1 -0
- package/dist/deal/deal.operation.d.ts +513 -0
- package/dist/deal/deal.operation.d.ts.map +1 -0
- package/dist/deal/deal.operation.js +270 -0
- package/dist/deal/deal.operation.js.map +1 -0
- package/dist/deal/deal.schema.d.ts +300 -0
- package/dist/deal/deal.schema.d.ts.map +1 -0
- package/dist/deal/deal.schema.js +286 -0
- package/dist/deal/deal.schema.js.map +1 -0
- package/dist/deal/index.d.ts +4 -0
- package/dist/deal/index.js +5 -0
- package/dist/docs/crm-pipeline.docblock.d.ts +1 -0
- package/dist/docs/crm-pipeline.docblock.js +100 -0
- package/dist/docs/crm-pipeline.docblock.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/entities/company.entity.d.ts +40 -0
- package/dist/entities/company.entity.d.ts.map +1 -0
- package/dist/entities/company.entity.js +63 -0
- package/dist/entities/company.entity.js.map +1 -0
- package/dist/entities/contact.entity.d.ts +44 -0
- package/dist/entities/contact.entity.d.ts.map +1 -0
- package/dist/entities/contact.entity.js +78 -0
- package/dist/entities/contact.entity.js.map +1 -0
- package/dist/entities/deal.entity.d.ts +73 -0
- package/dist/entities/deal.entity.d.ts.map +1 -0
- package/dist/entities/deal.entity.js +120 -0
- package/dist/entities/deal.entity.js.map +1 -0
- package/dist/entities/index.d.ts +15 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +33 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/task.entity.d.ts +65 -0
- package/dist/entities/task.entity.d.ts.map +1 -0
- package/dist/entities/task.entity.js +129 -0
- package/dist/entities/task.entity.js.map +1 -0
- package/dist/events/contact.event.d.ts +29 -0
- package/dist/events/contact.event.d.ts.map +1 -0
- package/dist/events/contact.event.js +45 -0
- package/dist/events/contact.event.js.map +1 -0
- package/dist/events/deal.event.d.ts +111 -0
- package/dist/events/deal.event.d.ts.map +1 -0
- package/dist/events/deal.event.js +172 -0
- package/dist/events/deal.event.js.map +1 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +5 -0
- package/dist/events/task.event.d.ts +29 -0
- package/dist/events/task.event.d.ts.map +1 -0
- package/dist/events/task.event.js +45 -0
- package/dist/events/task.event.js.map +1 -0
- package/dist/example.d.ts +37 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +46 -0
- package/dist/example.js.map +1 -0
- package/dist/handlers/deal.handlers.d.ts +94 -0
- package/dist/handlers/deal.handlers.d.ts.map +1 -0
- package/dist/handlers/deal.handlers.js +120 -0
- package/dist/handlers/deal.handlers.js.map +1 -0
- package/dist/handlers/index.d.ts +3 -0
- package/dist/handlers/index.js +4 -0
- package/dist/handlers/mock-data.d.ts +49 -0
- package/dist/handlers/mock-data.d.ts.map +1 -0
- package/dist/handlers/mock-data.js +188 -0
- package/dist/handlers/mock-data.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/operations/index.d.ts +5 -0
- package/dist/operations/index.js +6 -0
- package/dist/presentations/dashboard.presentation.d.ts +15 -0
- package/dist/presentations/dashboard.presentation.d.ts.map +1 -0
- package/dist/presentations/dashboard.presentation.js +59 -0
- package/dist/presentations/dashboard.presentation.js.map +1 -0
- package/dist/presentations/index.d.ts +3 -0
- package/dist/presentations/index.js +4 -0
- package/dist/presentations/pipeline.presentation.d.ts +23 -0
- package/dist/presentations/pipeline.presentation.d.ts.map +1 -0
- package/dist/presentations/pipeline.presentation.js +119 -0
- package/dist/presentations/pipeline.presentation.js.map +1 -0
- package/example.ts +1 -0
- package/package.json +105 -0
- package/src/crm-pipeline.feature.ts +96 -0
- package/src/deal/deal.enum.ts +21 -0
- package/src/deal/deal.operation.ts +291 -0
- package/src/deal/deal.schema.ts +154 -0
- package/src/deal/index.ts +26 -0
- package/src/docs/crm-pipeline.docblock.ts +98 -0
- package/src/docs/index.ts +1 -0
- package/src/entities/company.entity.ts +77 -0
- package/src/entities/contact.entity.ts +93 -0
- package/src/entities/deal.entity.ts +160 -0
- package/src/entities/index.ts +45 -0
- package/src/entities/task.entity.ts +137 -0
- package/src/events/contact.event.ts +31 -0
- package/src/events/deal.event.ts +104 -0
- package/src/events/index.ts +3 -0
- package/src/events/task.event.ts +28 -0
- package/src/example.ts +30 -0
- package/src/handlers/deal.handlers.ts +253 -0
- package/src/handlers/index.ts +27 -0
- package/src/handlers/mock-data.ts +198 -0
- package/src/index.ts +31 -0
- package/src/operations/index.ts +20 -0
- package/src/presentations/dashboard.presentation.ts +60 -0
- package/src/presentations/index.ts +2 -0
- package/src/presentations/pipeline.presentation.ts +118 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +7 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/contact.entity.ts
|
|
4
|
+
/**
|
|
5
|
+
* Contact status enum.
|
|
6
|
+
*/
|
|
7
|
+
const ContactStatusEnum = defineEntityEnum({
|
|
8
|
+
name: "ContactStatus",
|
|
9
|
+
values: [
|
|
10
|
+
"LEAD",
|
|
11
|
+
"PROSPECT",
|
|
12
|
+
"CUSTOMER",
|
|
13
|
+
"CHURNED",
|
|
14
|
+
"ARCHIVED"
|
|
15
|
+
],
|
|
16
|
+
schema: "crm",
|
|
17
|
+
description: "Status of a contact in the sales funnel."
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Contact entity - individual person.
|
|
21
|
+
*/
|
|
22
|
+
const ContactEntity = defineEntity({
|
|
23
|
+
name: "Contact",
|
|
24
|
+
description: "An individual person in the CRM.",
|
|
25
|
+
schema: "crm",
|
|
26
|
+
map: "contact",
|
|
27
|
+
fields: {
|
|
28
|
+
id: field.id({ description: "Unique contact ID" }),
|
|
29
|
+
firstName: field.string({ description: "First name" }),
|
|
30
|
+
lastName: field.string({ description: "Last name" }),
|
|
31
|
+
email: field.email({
|
|
32
|
+
isOptional: true,
|
|
33
|
+
isUnique: true
|
|
34
|
+
}),
|
|
35
|
+
phone: field.string({ isOptional: true }),
|
|
36
|
+
companyId: field.string({
|
|
37
|
+
isOptional: true,
|
|
38
|
+
description: "Associated company"
|
|
39
|
+
}),
|
|
40
|
+
jobTitle: field.string({ isOptional: true }),
|
|
41
|
+
status: field.enum("ContactStatus", { default: "LEAD" }),
|
|
42
|
+
organizationId: field.foreignKey(),
|
|
43
|
+
ownerId: field.foreignKey({ description: "Sales rep who owns this contact" }),
|
|
44
|
+
source: field.string({
|
|
45
|
+
isOptional: true,
|
|
46
|
+
description: "Lead source"
|
|
47
|
+
}),
|
|
48
|
+
linkedInUrl: field.url({ isOptional: true }),
|
|
49
|
+
twitterHandle: field.string({ isOptional: true }),
|
|
50
|
+
address: field.string({ isOptional: true }),
|
|
51
|
+
city: field.string({ isOptional: true }),
|
|
52
|
+
state: field.string({ isOptional: true }),
|
|
53
|
+
country: field.string({ isOptional: true }),
|
|
54
|
+
postalCode: field.string({ isOptional: true }),
|
|
55
|
+
notes: field.string({ isOptional: true }),
|
|
56
|
+
tags: field.string({ isArray: true }),
|
|
57
|
+
customFields: field.json({ isOptional: true }),
|
|
58
|
+
lastContactedAt: field.dateTime({ isOptional: true }),
|
|
59
|
+
nextFollowUpAt: field.dateTime({ isOptional: true }),
|
|
60
|
+
createdAt: field.createdAt(),
|
|
61
|
+
updatedAt: field.updatedAt(),
|
|
62
|
+
company: field.belongsTo("Company", ["companyId"], ["id"]),
|
|
63
|
+
deals: field.hasMany("Deal"),
|
|
64
|
+
tasks: field.hasMany("Task"),
|
|
65
|
+
activities: field.hasMany("Activity")
|
|
66
|
+
},
|
|
67
|
+
indexes: [
|
|
68
|
+
index.on(["organizationId", "status"]),
|
|
69
|
+
index.on(["organizationId", "ownerId"]),
|
|
70
|
+
index.on(["organizationId", "companyId"]),
|
|
71
|
+
index.on(["email"])
|
|
72
|
+
],
|
|
73
|
+
enums: [ContactStatusEnum]
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { ContactEntity, ContactStatusEnum };
|
|
78
|
+
//# sourceMappingURL=contact.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.entity.js","names":[],"sources":["../../src/entities/contact.entity.ts"],"sourcesContent":["import {\n defineEntity,\n defineEntityEnum,\n field,\n index,\n} from '@contractspec/lib.schema';\n\n/**\n * Contact status enum.\n */\nexport const ContactStatusEnum = defineEntityEnum({\n name: 'ContactStatus',\n values: ['LEAD', 'PROSPECT', 'CUSTOMER', 'CHURNED', 'ARCHIVED'] as const,\n schema: 'crm',\n description: 'Status of a contact in the sales funnel.',\n});\n\n/**\n * Contact entity - individual person.\n */\nexport const ContactEntity = defineEntity({\n name: 'Contact',\n description: 'An individual person in the CRM.',\n schema: 'crm',\n map: 'contact',\n fields: {\n id: field.id({ description: 'Unique contact ID' }),\n\n // Basic info\n firstName: field.string({ description: 'First name' }),\n lastName: field.string({ description: 'Last name' }),\n email: field.email({ isOptional: true, isUnique: true }),\n phone: field.string({ isOptional: true }),\n\n // Company\n companyId: field.string({\n isOptional: true,\n description: 'Associated company',\n }),\n jobTitle: field.string({ isOptional: true }),\n\n // Status\n status: field.enum('ContactStatus', { default: 'LEAD' }),\n\n // Ownership\n organizationId: field.foreignKey(),\n ownerId: field.foreignKey({\n description: 'Sales rep who owns this contact',\n }),\n\n // Source\n source: field.string({ isOptional: true, description: 'Lead source' }),\n\n // Social\n linkedInUrl: field.url({ isOptional: true }),\n twitterHandle: field.string({ isOptional: true }),\n\n // Address\n address: field.string({ isOptional: true }),\n city: field.string({ isOptional: true }),\n state: field.string({ isOptional: true }),\n country: field.string({ isOptional: true }),\n postalCode: field.string({ isOptional: true }),\n\n // Notes\n notes: field.string({ isOptional: true }),\n tags: field.string({ isArray: true }),\n\n // Custom fields\n customFields: field.json({ isOptional: true }),\n\n // Engagement\n lastContactedAt: field.dateTime({ isOptional: true }),\n nextFollowUpAt: field.dateTime({ isOptional: true }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n company: field.belongsTo('Company', ['companyId'], ['id']),\n deals: field.hasMany('Deal'),\n tasks: field.hasMany('Task'),\n activities: field.hasMany('Activity'),\n },\n indexes: [\n index.on(['organizationId', 'status']),\n index.on(['organizationId', 'ownerId']),\n index.on(['organizationId', 'companyId']),\n index.on(['email']),\n ],\n enums: [ContactStatusEnum],\n});\n"],"mappings":";;;;;;AAUA,MAAa,oBAAoB,iBAAiB;CAChD,MAAM;CACN,QAAQ;EAAC;EAAQ;EAAY;EAAY;EAAW;EAAW;CAC/D,QAAQ;CACR,aAAa;CACd,CAAC;;;;AAKF,MAAa,gBAAgB,aAAa;CACxC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,GAAG,EAAE,aAAa,qBAAqB,CAAC;EAGlD,WAAW,MAAM,OAAO,EAAE,aAAa,cAAc,CAAC;EACtD,UAAU,MAAM,OAAO,EAAE,aAAa,aAAa,CAAC;EACpD,OAAO,MAAM,MAAM;GAAE,YAAY;GAAM,UAAU;GAAM,CAAC;EACxD,OAAO,MAAM,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B,UAAU,CAAC;EACvC,MAAM,GAAG,CAAC,kBAAkB,YAAY,CAAC;EACzC,MAAM,GAAG,CAAC,QAAQ,CAAC;EACpB;CACD,OAAO,CAAC,kBAAkB;CAC3B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as _contractspec_lib_schema256 from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/deal.entity.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Deal status enum.
|
|
6
|
+
*/
|
|
7
|
+
declare const DealStatusEnum: _contractspec_lib_schema256.EntityEnumDef;
|
|
8
|
+
/**
|
|
9
|
+
* Pipeline entity - sales pipeline definition.
|
|
10
|
+
*/
|
|
11
|
+
declare const PipelineEntity: _contractspec_lib_schema256.EntitySpec<{
|
|
12
|
+
id: _contractspec_lib_schema256.EntityScalarField;
|
|
13
|
+
name: _contractspec_lib_schema256.EntityScalarField;
|
|
14
|
+
description: _contractspec_lib_schema256.EntityScalarField;
|
|
15
|
+
organizationId: _contractspec_lib_schema256.EntityScalarField;
|
|
16
|
+
isDefault: _contractspec_lib_schema256.EntityScalarField;
|
|
17
|
+
createdAt: _contractspec_lib_schema256.EntityScalarField;
|
|
18
|
+
updatedAt: _contractspec_lib_schema256.EntityScalarField;
|
|
19
|
+
stages: _contractspec_lib_schema256.EntityRelationField;
|
|
20
|
+
deals: _contractspec_lib_schema256.EntityRelationField;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Stage entity - pipeline stage.
|
|
24
|
+
*/
|
|
25
|
+
declare const StageEntity: _contractspec_lib_schema256.EntitySpec<{
|
|
26
|
+
id: _contractspec_lib_schema256.EntityScalarField;
|
|
27
|
+
name: _contractspec_lib_schema256.EntityScalarField;
|
|
28
|
+
pipelineId: _contractspec_lib_schema256.EntityScalarField;
|
|
29
|
+
position: _contractspec_lib_schema256.EntityScalarField;
|
|
30
|
+
probability: _contractspec_lib_schema256.EntityScalarField;
|
|
31
|
+
isWonStage: _contractspec_lib_schema256.EntityScalarField;
|
|
32
|
+
isLostStage: _contractspec_lib_schema256.EntityScalarField;
|
|
33
|
+
color: _contractspec_lib_schema256.EntityScalarField;
|
|
34
|
+
createdAt: _contractspec_lib_schema256.EntityScalarField;
|
|
35
|
+
updatedAt: _contractspec_lib_schema256.EntityScalarField;
|
|
36
|
+
pipeline: _contractspec_lib_schema256.EntityRelationField;
|
|
37
|
+
deals: _contractspec_lib_schema256.EntityRelationField;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Deal entity - sales opportunity.
|
|
41
|
+
*/
|
|
42
|
+
declare const DealEntity: _contractspec_lib_schema256.EntitySpec<{
|
|
43
|
+
id: _contractspec_lib_schema256.EntityScalarField;
|
|
44
|
+
name: _contractspec_lib_schema256.EntityScalarField;
|
|
45
|
+
value: _contractspec_lib_schema256.EntityScalarField;
|
|
46
|
+
currency: _contractspec_lib_schema256.EntityScalarField;
|
|
47
|
+
pipelineId: _contractspec_lib_schema256.EntityScalarField;
|
|
48
|
+
stageId: _contractspec_lib_schema256.EntityScalarField;
|
|
49
|
+
status: _contractspec_lib_schema256.EntityEnumField;
|
|
50
|
+
contactId: _contractspec_lib_schema256.EntityScalarField;
|
|
51
|
+
companyId: _contractspec_lib_schema256.EntityScalarField;
|
|
52
|
+
organizationId: _contractspec_lib_schema256.EntityScalarField;
|
|
53
|
+
ownerId: _contractspec_lib_schema256.EntityScalarField;
|
|
54
|
+
expectedCloseDate: _contractspec_lib_schema256.EntityScalarField;
|
|
55
|
+
closedAt: _contractspec_lib_schema256.EntityScalarField;
|
|
56
|
+
lostReason: _contractspec_lib_schema256.EntityScalarField;
|
|
57
|
+
wonSource: _contractspec_lib_schema256.EntityScalarField;
|
|
58
|
+
notes: _contractspec_lib_schema256.EntityScalarField;
|
|
59
|
+
tags: _contractspec_lib_schema256.EntityScalarField;
|
|
60
|
+
customFields: _contractspec_lib_schema256.EntityScalarField;
|
|
61
|
+
stagePosition: _contractspec_lib_schema256.EntityScalarField;
|
|
62
|
+
createdAt: _contractspec_lib_schema256.EntityScalarField;
|
|
63
|
+
updatedAt: _contractspec_lib_schema256.EntityScalarField;
|
|
64
|
+
pipeline: _contractspec_lib_schema256.EntityRelationField;
|
|
65
|
+
stage: _contractspec_lib_schema256.EntityRelationField;
|
|
66
|
+
contact: _contractspec_lib_schema256.EntityRelationField;
|
|
67
|
+
company: _contractspec_lib_schema256.EntityRelationField;
|
|
68
|
+
tasks: _contractspec_lib_schema256.EntityRelationField;
|
|
69
|
+
activities: _contractspec_lib_schema256.EntityRelationField;
|
|
70
|
+
}>;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { DealEntity, DealStatusEnum, PipelineEntity, StageEntity };
|
|
73
|
+
//# sourceMappingURL=deal.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deal.entity.d.ts","names":[],"sources":["../../src/entities/deal.entity.ts"],"sourcesContent":[],"mappings":";;;;;;AAUa,cAAA,cAKX,EAAA,2BAAA,CALyB,aAKzB;AAKF;;;cAAa,4CAAc;MAwBzB,2BAAA,CAAA;;;;;;0DAxByB;EAAA,MAAA,iDAAA;EA6Bd,KAAA,iDAwCX;CAAA,CAAA;;;;cAxCW,yCAAW;MAwCtB,2BAAA,CAAA;;;;;;;sDAxCsB;EAAA,SAAA,+CAAA;EA6CX,SAAA,+CAiEX;EAAA,QAAA,iDAAA;;;;;;cAjEW,wCAAU;MAiErB,2BAAA,CAAA;;;;;;;;;;;;;;;;;;;;0DAjEqB;EAAA,QAAA,iDAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/deal.entity.ts
|
|
4
|
+
/**
|
|
5
|
+
* Deal status enum.
|
|
6
|
+
*/
|
|
7
|
+
const DealStatusEnum = defineEntityEnum({
|
|
8
|
+
name: "DealStatus",
|
|
9
|
+
values: [
|
|
10
|
+
"OPEN",
|
|
11
|
+
"WON",
|
|
12
|
+
"LOST",
|
|
13
|
+
"STALE"
|
|
14
|
+
],
|
|
15
|
+
schema: "crm",
|
|
16
|
+
description: "Status of a deal."
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Pipeline entity - sales pipeline definition.
|
|
20
|
+
*/
|
|
21
|
+
const PipelineEntity = defineEntity({
|
|
22
|
+
name: "Pipeline",
|
|
23
|
+
description: "A sales pipeline with stages.",
|
|
24
|
+
schema: "crm",
|
|
25
|
+
map: "pipeline",
|
|
26
|
+
fields: {
|
|
27
|
+
id: field.id(),
|
|
28
|
+
name: field.string({ description: "Pipeline name" }),
|
|
29
|
+
description: field.string({ isOptional: true }),
|
|
30
|
+
organizationId: field.foreignKey(),
|
|
31
|
+
isDefault: field.boolean({ default: false }),
|
|
32
|
+
createdAt: field.createdAt(),
|
|
33
|
+
updatedAt: field.updatedAt(),
|
|
34
|
+
stages: field.hasMany("Stage"),
|
|
35
|
+
deals: field.hasMany("Deal")
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Stage entity - pipeline stage.
|
|
40
|
+
*/
|
|
41
|
+
const StageEntity = defineEntity({
|
|
42
|
+
name: "Stage",
|
|
43
|
+
description: "A stage within a sales pipeline.",
|
|
44
|
+
schema: "crm",
|
|
45
|
+
map: "stage",
|
|
46
|
+
fields: {
|
|
47
|
+
id: field.id(),
|
|
48
|
+
name: field.string({ description: "Stage name" }),
|
|
49
|
+
pipelineId: field.foreignKey(),
|
|
50
|
+
position: field.int({ description: "Order in pipeline" }),
|
|
51
|
+
probability: field.int({
|
|
52
|
+
default: 0,
|
|
53
|
+
description: "Win probability (0-100)"
|
|
54
|
+
}),
|
|
55
|
+
isWonStage: field.boolean({ default: false }),
|
|
56
|
+
isLostStage: field.boolean({ default: false }),
|
|
57
|
+
color: field.string({
|
|
58
|
+
isOptional: true,
|
|
59
|
+
description: "Stage color for UI"
|
|
60
|
+
}),
|
|
61
|
+
createdAt: field.createdAt(),
|
|
62
|
+
updatedAt: field.updatedAt(),
|
|
63
|
+
pipeline: field.belongsTo("Pipeline", ["pipelineId"], ["id"], { onDelete: "Cascade" }),
|
|
64
|
+
deals: field.hasMany("Deal")
|
|
65
|
+
},
|
|
66
|
+
indexes: [index.on(["pipelineId", "position"])]
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Deal entity - sales opportunity.
|
|
70
|
+
*/
|
|
71
|
+
const DealEntity = defineEntity({
|
|
72
|
+
name: "Deal",
|
|
73
|
+
description: "A sales opportunity/deal.",
|
|
74
|
+
schema: "crm",
|
|
75
|
+
map: "deal",
|
|
76
|
+
fields: {
|
|
77
|
+
id: field.id({ description: "Unique deal ID" }),
|
|
78
|
+
name: field.string({ description: "Deal name" }),
|
|
79
|
+
value: field.decimal({ description: "Deal value" }),
|
|
80
|
+
currency: field.string({ default: "\"USD\"" }),
|
|
81
|
+
pipelineId: field.foreignKey(),
|
|
82
|
+
stageId: field.foreignKey(),
|
|
83
|
+
status: field.enum("DealStatus", { default: "OPEN" }),
|
|
84
|
+
contactId: field.string({ isOptional: true }),
|
|
85
|
+
companyId: field.string({ isOptional: true }),
|
|
86
|
+
organizationId: field.foreignKey(),
|
|
87
|
+
ownerId: field.foreignKey({ description: "Deal owner" }),
|
|
88
|
+
expectedCloseDate: field.dateTime({ isOptional: true }),
|
|
89
|
+
closedAt: field.dateTime({ isOptional: true }),
|
|
90
|
+
lostReason: field.string({ isOptional: true }),
|
|
91
|
+
wonSource: field.string({ isOptional: true }),
|
|
92
|
+
notes: field.string({ isOptional: true }),
|
|
93
|
+
tags: field.string({ isArray: true }),
|
|
94
|
+
customFields: field.json({ isOptional: true }),
|
|
95
|
+
stagePosition: field.int({ default: 0 }),
|
|
96
|
+
createdAt: field.createdAt(),
|
|
97
|
+
updatedAt: field.updatedAt(),
|
|
98
|
+
pipeline: field.belongsTo("Pipeline", ["pipelineId"], ["id"]),
|
|
99
|
+
stage: field.belongsTo("Stage", ["stageId"], ["id"]),
|
|
100
|
+
contact: field.belongsTo("Contact", ["contactId"], ["id"]),
|
|
101
|
+
company: field.belongsTo("Company", ["companyId"], ["id"]),
|
|
102
|
+
tasks: field.hasMany("Task"),
|
|
103
|
+
activities: field.hasMany("Activity")
|
|
104
|
+
},
|
|
105
|
+
indexes: [
|
|
106
|
+
index.on(["organizationId", "status"]),
|
|
107
|
+
index.on([
|
|
108
|
+
"pipelineId",
|
|
109
|
+
"stageId",
|
|
110
|
+
"stagePosition"
|
|
111
|
+
]),
|
|
112
|
+
index.on(["ownerId", "status"]),
|
|
113
|
+
index.on(["expectedCloseDate"])
|
|
114
|
+
],
|
|
115
|
+
enums: [DealStatusEnum]
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { DealEntity, DealStatusEnum, PipelineEntity, StageEntity };
|
|
120
|
+
//# sourceMappingURL=deal.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deal.entity.js","names":[],"sources":["../../src/entities/deal.entity.ts"],"sourcesContent":["import {\n defineEntity,\n defineEntityEnum,\n field,\n index,\n} from '@contractspec/lib.schema';\n\n/**\n * Deal status enum.\n */\nexport const DealStatusEnum = defineEntityEnum({\n name: 'DealStatus',\n values: ['OPEN', 'WON', 'LOST', 'STALE'] as const,\n schema: 'crm',\n description: 'Status of a deal.',\n});\n\n/**\n * Pipeline entity - sales pipeline definition.\n */\nexport const PipelineEntity = defineEntity({\n name: 'Pipeline',\n description: 'A sales pipeline with stages.',\n schema: 'crm',\n map: 'pipeline',\n fields: {\n id: field.id(),\n name: field.string({ description: 'Pipeline name' }),\n description: field.string({ isOptional: true }),\n\n // Ownership\n organizationId: field.foreignKey(),\n\n // Settings\n isDefault: field.boolean({ default: false }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n stages: field.hasMany('Stage'),\n deals: field.hasMany('Deal'),\n },\n});\n\n/**\n * Stage entity - pipeline stage.\n */\nexport const StageEntity = defineEntity({\n name: 'Stage',\n description: 'A stage within a sales pipeline.',\n schema: 'crm',\n map: 'stage',\n fields: {\n id: field.id(),\n name: field.string({ description: 'Stage name' }),\n pipelineId: field.foreignKey(),\n\n // Position\n position: field.int({ description: 'Order in pipeline' }),\n\n // Probability\n probability: field.int({\n default: 0,\n description: 'Win probability (0-100)',\n }),\n\n // Type\n isWonStage: field.boolean({ default: false }),\n isLostStage: field.boolean({ default: false }),\n\n // Settings\n color: field.string({\n isOptional: true,\n description: 'Stage color for UI',\n }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n pipeline: field.belongsTo('Pipeline', ['pipelineId'], ['id'], {\n onDelete: 'Cascade',\n }),\n deals: field.hasMany('Deal'),\n },\n indexes: [index.on(['pipelineId', 'position'])],\n});\n\n/**\n * Deal entity - sales opportunity.\n */\nexport const DealEntity = defineEntity({\n name: 'Deal',\n description: 'A sales opportunity/deal.',\n schema: 'crm',\n map: 'deal',\n fields: {\n id: field.id({ description: 'Unique deal ID' }),\n name: field.string({ description: 'Deal name' }),\n\n // Value\n value: field.decimal({ description: 'Deal value' }),\n currency: field.string({ default: '\"USD\"' }),\n\n // Pipeline\n pipelineId: field.foreignKey(),\n stageId: field.foreignKey(),\n\n // Status\n status: field.enum('DealStatus', { default: 'OPEN' }),\n\n // Associations\n contactId: field.string({ isOptional: true }),\n companyId: field.string({ isOptional: true }),\n\n // Ownership\n organizationId: field.foreignKey(),\n ownerId: field.foreignKey({ description: 'Deal owner' }),\n\n // Timeline\n expectedCloseDate: field.dateTime({ isOptional: true }),\n closedAt: field.dateTime({ isOptional: true }),\n\n // Tracking\n lostReason: field.string({ isOptional: true }),\n wonSource: field.string({ isOptional: true }),\n\n // Notes\n notes: field.string({ isOptional: true }),\n tags: field.string({ isArray: true }),\n\n // Custom fields\n customFields: field.json({ isOptional: true }),\n\n // Position in stage (for Kanban)\n stagePosition: field.int({ default: 0 }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n pipeline: field.belongsTo('Pipeline', ['pipelineId'], ['id']),\n stage: field.belongsTo('Stage', ['stageId'], ['id']),\n contact: field.belongsTo('Contact', ['contactId'], ['id']),\n company: field.belongsTo('Company', ['companyId'], ['id']),\n tasks: field.hasMany('Task'),\n activities: field.hasMany('Activity'),\n },\n indexes: [\n index.on(['organizationId', 'status']),\n index.on(['pipelineId', 'stageId', 'stagePosition']),\n index.on(['ownerId', 'status']),\n index.on(['expectedCloseDate']),\n ],\n enums: [DealStatusEnum],\n});\n"],"mappings":";;;;;;AAUA,MAAa,iBAAiB,iBAAiB;CAC7C,MAAM;CACN,QAAQ;EAAC;EAAQ;EAAO;EAAQ;EAAQ;CACxC,QAAQ;CACR,aAAa;CACd,CAAC;;;;AAKF,MAAa,iBAAiB,aAAa;CACzC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,IAAI;EACd,MAAM,MAAM,OAAO,EAAE,aAAa,iBAAiB,CAAC;EACpD,aAAa,MAAM,OAAO,EAAE,YAAY,MAAM,CAAC;EAG/C,gBAAgB,MAAM,YAAY;EAGlC,WAAW,MAAM,QAAQ,EAAE,SAAS,OAAO,CAAC;EAG5C,WAAW,MAAM,WAAW;EAC5B,WAAW,MAAM,WAAW;EAG5B,QAAQ,MAAM,QAAQ,QAAQ;EAC9B,OAAO,MAAM,QAAQ,OAAO;EAC7B;CACF,CAAC;;;;AAKF,MAAa,cAAc,aAAa;CACtC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,IAAI;EACd,MAAM,MAAM,OAAO,EAAE,aAAa,cAAc,CAAC;EACjD,YAAY,MAAM,YAAY;EAG9B,UAAU,MAAM,IAAI,EAAE,aAAa,qBAAqB,CAAC;EAGzD,aAAa,MAAM,IAAI;GACrB,SAAS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,MAAM,CAAC;EACzC,MAAM,MAAM,OAAO,EAAE,SAAS,MAAM,CAAC;EAGrC,cAAc,MAAM,KAAK,EAAE,YAAY,MAAM,CAAC;EAG9C,eAAe,MAAM,IAAI,EAAE,SAAS,GAAG,CAAC;EAGxC,WAAW,MAAM,WAAW;EAC5B,WAAW,MAAM,WAAW;EAG5B,UAAU,MAAM,UAAU,YAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC;EAC7D,OAAO,MAAM,UAAU,SAAS,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC;EACpD,SAAS,MAAM,UAAU,WAAW,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;EAC1D,SAAS,MAAM,UAAU,WAAW,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;EAC1D,OAAO,MAAM,QAAQ,OAAO;EAC5B,YAAY,MAAM,QAAQ,WAAW;EACtC;CACD,SAAS;EACP,MAAM,GAAG,CAAC,kBAAkB,SAAS,CAAC;EACtC,MAAM,GAAG;GAAC;GAAc;GAAW;GAAgB,CAAC;EACpD,MAAM,GAAG,CAAC,WAAW,SAAS,CAAC;EAC/B,MAAM,GAAG,CAAC,oBAAoB,CAAC;EAChC;CACD,OAAO,CAAC,eAAe;CACxB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CompanyEntity, CompanySizeEnum } from "./company.entity.js";
|
|
2
|
+
import { ContactEntity, ContactStatusEnum } from "./contact.entity.js";
|
|
3
|
+
import { DealEntity, DealStatusEnum, PipelineEntity, StageEntity } from "./deal.entity.js";
|
|
4
|
+
import { ActivityEntity, TaskEntity, TaskPriorityEnum, TaskStatusEnum, TaskTypeEnum } from "./task.entity.js";
|
|
5
|
+
import { ModuleSchemaContribution } from "@contractspec/lib.schema";
|
|
6
|
+
|
|
7
|
+
//#region src/entities/index.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* CRM Pipeline schema contribution.
|
|
11
|
+
*/
|
|
12
|
+
declare const crmPipelineSchemaContribution: ModuleSchemaContribution;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ActivityEntity, CompanyEntity, CompanySizeEnum, ContactEntity, ContactStatusEnum, DealEntity, DealStatusEnum, PipelineEntity, StageEntity, TaskEntity, TaskPriorityEnum, TaskStatusEnum, TaskTypeEnum, crmPipelineSchemaContribution };
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/entities/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAyBA;cAAa,+BAA+B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CompanyEntity, CompanySizeEnum } from "./company.entity.js";
|
|
2
|
+
import { ContactEntity, ContactStatusEnum } from "./contact.entity.js";
|
|
3
|
+
import { DealEntity, DealStatusEnum, PipelineEntity, StageEntity } from "./deal.entity.js";
|
|
4
|
+
import { ActivityEntity, TaskEntity, TaskPriorityEnum, TaskStatusEnum, TaskTypeEnum } from "./task.entity.js";
|
|
5
|
+
|
|
6
|
+
//#region src/entities/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* CRM Pipeline schema contribution.
|
|
9
|
+
*/
|
|
10
|
+
const crmPipelineSchemaContribution = {
|
|
11
|
+
moduleId: "@contractspec/example.crm-pipeline",
|
|
12
|
+
entities: [
|
|
13
|
+
CompanyEntity,
|
|
14
|
+
ContactEntity,
|
|
15
|
+
DealEntity,
|
|
16
|
+
PipelineEntity,
|
|
17
|
+
StageEntity,
|
|
18
|
+
TaskEntity,
|
|
19
|
+
ActivityEntity
|
|
20
|
+
],
|
|
21
|
+
enums: [
|
|
22
|
+
CompanySizeEnum,
|
|
23
|
+
ContactStatusEnum,
|
|
24
|
+
DealStatusEnum,
|
|
25
|
+
TaskTypeEnum,
|
|
26
|
+
TaskPriorityEnum,
|
|
27
|
+
TaskStatusEnum
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ActivityEntity, CompanyEntity, CompanySizeEnum, ContactEntity, ContactStatusEnum, DealEntity, DealStatusEnum, PipelineEntity, StageEntity, TaskEntity, TaskPriorityEnum, TaskStatusEnum, TaskTypeEnum, crmPipelineSchemaContribution };
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["crmPipelineSchemaContribution: ModuleSchemaContribution"],"sources":["../../src/entities/index.ts"],"sourcesContent":["export * from './company.entity';\nexport * from './contact.entity';\nexport * from './deal.entity';\nexport * from './task.entity';\n\nimport type { ModuleSchemaContribution } from '@contractspec/lib.schema';\nimport { CompanyEntity, CompanySizeEnum } from './company.entity';\nimport { ContactEntity, ContactStatusEnum } from './contact.entity';\nimport {\n DealEntity,\n PipelineEntity,\n StageEntity,\n DealStatusEnum,\n} from './deal.entity';\nimport {\n TaskEntity,\n ActivityEntity,\n TaskTypeEnum,\n TaskPriorityEnum,\n TaskStatusEnum,\n} from './task.entity';\n\n/**\n * CRM Pipeline schema contribution.\n */\nexport const crmPipelineSchemaContribution: ModuleSchemaContribution = {\n moduleId: '@contractspec/example.crm-pipeline',\n entities: [\n CompanyEntity,\n ContactEntity,\n DealEntity,\n PipelineEntity,\n StageEntity,\n TaskEntity,\n ActivityEntity,\n ],\n enums: [\n CompanySizeEnum,\n ContactStatusEnum,\n DealStatusEnum,\n TaskTypeEnum,\n TaskPriorityEnum,\n TaskStatusEnum,\n ],\n};\n"],"mappings":";;;;;;;;;AAyBA,MAAaA,gCAA0D;CACrE,UAAU;CACV,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as _contractspec_lib_schema308 from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/task.entity.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Task type enum.
|
|
6
|
+
*/
|
|
7
|
+
declare const TaskTypeEnum: _contractspec_lib_schema308.EntityEnumDef;
|
|
8
|
+
/**
|
|
9
|
+
* Task priority enum.
|
|
10
|
+
*/
|
|
11
|
+
declare const TaskPriorityEnum: _contractspec_lib_schema308.EntityEnumDef;
|
|
12
|
+
/**
|
|
13
|
+
* Task status enum.
|
|
14
|
+
*/
|
|
15
|
+
declare const TaskStatusEnum: _contractspec_lib_schema308.EntityEnumDef;
|
|
16
|
+
/**
|
|
17
|
+
* Task entity - follow-up activities.
|
|
18
|
+
*/
|
|
19
|
+
declare const TaskEntity: _contractspec_lib_schema308.EntitySpec<{
|
|
20
|
+
id: _contractspec_lib_schema308.EntityScalarField;
|
|
21
|
+
title: _contractspec_lib_schema308.EntityScalarField;
|
|
22
|
+
description: _contractspec_lib_schema308.EntityScalarField;
|
|
23
|
+
type: _contractspec_lib_schema308.EntityEnumField;
|
|
24
|
+
priority: _contractspec_lib_schema308.EntityEnumField;
|
|
25
|
+
status: _contractspec_lib_schema308.EntityEnumField;
|
|
26
|
+
dueDate: _contractspec_lib_schema308.EntityScalarField;
|
|
27
|
+
reminderAt: _contractspec_lib_schema308.EntityScalarField;
|
|
28
|
+
contactId: _contractspec_lib_schema308.EntityScalarField;
|
|
29
|
+
dealId: _contractspec_lib_schema308.EntityScalarField;
|
|
30
|
+
companyId: _contractspec_lib_schema308.EntityScalarField;
|
|
31
|
+
organizationId: _contractspec_lib_schema308.EntityScalarField;
|
|
32
|
+
assignedTo: _contractspec_lib_schema308.EntityScalarField;
|
|
33
|
+
createdBy: _contractspec_lib_schema308.EntityScalarField;
|
|
34
|
+
completedAt: _contractspec_lib_schema308.EntityScalarField;
|
|
35
|
+
completedBy: _contractspec_lib_schema308.EntityScalarField;
|
|
36
|
+
createdAt: _contractspec_lib_schema308.EntityScalarField;
|
|
37
|
+
updatedAt: _contractspec_lib_schema308.EntityScalarField;
|
|
38
|
+
contact: _contractspec_lib_schema308.EntityRelationField;
|
|
39
|
+
deal: _contractspec_lib_schema308.EntityRelationField;
|
|
40
|
+
company: _contractspec_lib_schema308.EntityRelationField;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Activity entity - interaction history.
|
|
44
|
+
*/
|
|
45
|
+
declare const ActivityEntity: _contractspec_lib_schema308.EntitySpec<{
|
|
46
|
+
id: _contractspec_lib_schema308.EntityScalarField;
|
|
47
|
+
type: _contractspec_lib_schema308.EntityEnumField;
|
|
48
|
+
subject: _contractspec_lib_schema308.EntityScalarField;
|
|
49
|
+
description: _contractspec_lib_schema308.EntityScalarField;
|
|
50
|
+
contactId: _contractspec_lib_schema308.EntityScalarField;
|
|
51
|
+
dealId: _contractspec_lib_schema308.EntityScalarField;
|
|
52
|
+
companyId: _contractspec_lib_schema308.EntityScalarField;
|
|
53
|
+
organizationId: _contractspec_lib_schema308.EntityScalarField;
|
|
54
|
+
performedBy: _contractspec_lib_schema308.EntityScalarField;
|
|
55
|
+
outcome: _contractspec_lib_schema308.EntityScalarField;
|
|
56
|
+
occurredAt: _contractspec_lib_schema308.EntityScalarField;
|
|
57
|
+
duration: _contractspec_lib_schema308.EntityScalarField;
|
|
58
|
+
createdAt: _contractspec_lib_schema308.EntityScalarField;
|
|
59
|
+
contact: _contractspec_lib_schema308.EntityRelationField;
|
|
60
|
+
deal: _contractspec_lib_schema308.EntityRelationField;
|
|
61
|
+
company: _contractspec_lib_schema308.EntityRelationField;
|
|
62
|
+
}>;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { ActivityEntity, TaskEntity, TaskPriorityEnum, TaskStatusEnum, TaskTypeEnum };
|
|
65
|
+
//# sourceMappingURL=task.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.entity.d.ts","names":[],"sources":["../../src/entities/task.entity.ts"],"sourcesContent":[],"mappings":";;;;;;AAUa,cAAA,YAKX,EAAA,2BAAA,CALuB,aAKvB;AAKF;AAUA;AAUA;AAiDE,cArEW,gBAqEX,EAhEA,2BAAA,CAL2B,aAqE3B;;;;cA3DW,gBAKX,2BAAA,CALyB;;;;cAUd,wCAAU;MAiDrB,2BAAA,CAAA;;;;;;;;;;;;2DAjDqB;EAAA,SAAA,+CAAA;EAsDV,WAAA,+CA0CX;EAAA,WAAA,+CAAA;;;;;;;;;;cA1CW,4CAAc;MA0CzB,2BAAA,CAAA;;;;;uDA1CyB;EAAA,SAAA,+CAAA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineEntity, defineEntityEnum, field, index } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/task.entity.ts
|
|
4
|
+
/**
|
|
5
|
+
* Task type enum.
|
|
6
|
+
*/
|
|
7
|
+
const TaskTypeEnum = defineEntityEnum({
|
|
8
|
+
name: "TaskType",
|
|
9
|
+
values: [
|
|
10
|
+
"CALL",
|
|
11
|
+
"EMAIL",
|
|
12
|
+
"MEETING",
|
|
13
|
+
"TODO",
|
|
14
|
+
"FOLLOW_UP",
|
|
15
|
+
"OTHER"
|
|
16
|
+
],
|
|
17
|
+
schema: "crm",
|
|
18
|
+
description: "Type of CRM task."
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Task priority enum.
|
|
22
|
+
*/
|
|
23
|
+
const TaskPriorityEnum = defineEntityEnum({
|
|
24
|
+
name: "TaskPriority",
|
|
25
|
+
values: [
|
|
26
|
+
"LOW",
|
|
27
|
+
"NORMAL",
|
|
28
|
+
"HIGH",
|
|
29
|
+
"URGENT"
|
|
30
|
+
],
|
|
31
|
+
schema: "crm",
|
|
32
|
+
description: "Priority of a task."
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Task status enum.
|
|
36
|
+
*/
|
|
37
|
+
const TaskStatusEnum = defineEntityEnum({
|
|
38
|
+
name: "TaskStatus",
|
|
39
|
+
values: [
|
|
40
|
+
"PENDING",
|
|
41
|
+
"IN_PROGRESS",
|
|
42
|
+
"COMPLETED",
|
|
43
|
+
"CANCELLED"
|
|
44
|
+
],
|
|
45
|
+
schema: "crm",
|
|
46
|
+
description: "Status of a task."
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Task entity - follow-up activities.
|
|
50
|
+
*/
|
|
51
|
+
const TaskEntity = defineEntity({
|
|
52
|
+
name: "Task",
|
|
53
|
+
description: "A task or follow-up activity.",
|
|
54
|
+
schema: "crm",
|
|
55
|
+
map: "task",
|
|
56
|
+
fields: {
|
|
57
|
+
id: field.id(),
|
|
58
|
+
title: field.string({ description: "Task title" }),
|
|
59
|
+
description: field.string({ isOptional: true }),
|
|
60
|
+
type: field.enum("TaskType", { default: "TODO" }),
|
|
61
|
+
priority: field.enum("TaskPriority", { default: "NORMAL" }),
|
|
62
|
+
status: field.enum("TaskStatus", { default: "PENDING" }),
|
|
63
|
+
dueDate: field.dateTime({ isOptional: true }),
|
|
64
|
+
reminderAt: field.dateTime({ isOptional: true }),
|
|
65
|
+
contactId: field.string({ isOptional: true }),
|
|
66
|
+
dealId: field.string({ isOptional: true }),
|
|
67
|
+
companyId: field.string({ isOptional: true }),
|
|
68
|
+
organizationId: field.foreignKey(),
|
|
69
|
+
assignedTo: field.foreignKey({ description: "User assigned to this task" }),
|
|
70
|
+
createdBy: field.foreignKey(),
|
|
71
|
+
completedAt: field.dateTime({ isOptional: true }),
|
|
72
|
+
completedBy: field.string({ isOptional: true }),
|
|
73
|
+
createdAt: field.createdAt(),
|
|
74
|
+
updatedAt: field.updatedAt(),
|
|
75
|
+
contact: field.belongsTo("Contact", ["contactId"], ["id"]),
|
|
76
|
+
deal: field.belongsTo("Deal", ["dealId"], ["id"]),
|
|
77
|
+
company: field.belongsTo("Company", ["companyId"], ["id"])
|
|
78
|
+
},
|
|
79
|
+
indexes: [
|
|
80
|
+
index.on([
|
|
81
|
+
"organizationId",
|
|
82
|
+
"assignedTo",
|
|
83
|
+
"status"
|
|
84
|
+
]),
|
|
85
|
+
index.on(["dueDate", "status"]),
|
|
86
|
+
index.on(["contactId"]),
|
|
87
|
+
index.on(["dealId"])
|
|
88
|
+
],
|
|
89
|
+
enums: [
|
|
90
|
+
TaskTypeEnum,
|
|
91
|
+
TaskPriorityEnum,
|
|
92
|
+
TaskStatusEnum
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Activity entity - interaction history.
|
|
97
|
+
*/
|
|
98
|
+
const ActivityEntity = defineEntity({
|
|
99
|
+
name: "Activity",
|
|
100
|
+
description: "An activity/interaction logged in the CRM.",
|
|
101
|
+
schema: "crm",
|
|
102
|
+
map: "activity",
|
|
103
|
+
fields: {
|
|
104
|
+
id: field.id(),
|
|
105
|
+
type: field.enum("TaskType"),
|
|
106
|
+
subject: field.string(),
|
|
107
|
+
description: field.string({ isOptional: true }),
|
|
108
|
+
contactId: field.string({ isOptional: true }),
|
|
109
|
+
dealId: field.string({ isOptional: true }),
|
|
110
|
+
companyId: field.string({ isOptional: true }),
|
|
111
|
+
organizationId: field.foreignKey(),
|
|
112
|
+
performedBy: field.foreignKey(),
|
|
113
|
+
outcome: field.string({ isOptional: true }),
|
|
114
|
+
occurredAt: field.dateTime(),
|
|
115
|
+
duration: field.int({
|
|
116
|
+
isOptional: true,
|
|
117
|
+
description: "Duration in minutes"
|
|
118
|
+
}),
|
|
119
|
+
createdAt: field.createdAt(),
|
|
120
|
+
contact: field.belongsTo("Contact", ["contactId"], ["id"]),
|
|
121
|
+
deal: field.belongsTo("Deal", ["dealId"], ["id"]),
|
|
122
|
+
company: field.belongsTo("Company", ["companyId"], ["id"])
|
|
123
|
+
},
|
|
124
|
+
indexes: [index.on(["contactId", "occurredAt"]), index.on(["dealId", "occurredAt"])]
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { ActivityEntity, TaskEntity, TaskPriorityEnum, TaskStatusEnum, TaskTypeEnum };
|
|
129
|
+
//# sourceMappingURL=task.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.entity.js","names":[],"sources":["../../src/entities/task.entity.ts"],"sourcesContent":["import {\n defineEntity,\n defineEntityEnum,\n field,\n index,\n} from '@contractspec/lib.schema';\n\n/**\n * Task type enum.\n */\nexport const TaskTypeEnum = defineEntityEnum({\n name: 'TaskType',\n values: ['CALL', 'EMAIL', 'MEETING', 'TODO', 'FOLLOW_UP', 'OTHER'] as const,\n schema: 'crm',\n description: 'Type of CRM task.',\n});\n\n/**\n * Task priority enum.\n */\nexport const TaskPriorityEnum = defineEntityEnum({\n name: 'TaskPriority',\n values: ['LOW', 'NORMAL', 'HIGH', 'URGENT'] as const,\n schema: 'crm',\n description: 'Priority of a task.',\n});\n\n/**\n * Task status enum.\n */\nexport const TaskStatusEnum = defineEntityEnum({\n name: 'TaskStatus',\n values: ['PENDING', 'IN_PROGRESS', 'COMPLETED', 'CANCELLED'] as const,\n schema: 'crm',\n description: 'Status of a task.',\n});\n\n/**\n * Task entity - follow-up activities.\n */\nexport const TaskEntity = defineEntity({\n name: 'Task',\n description: 'A task or follow-up activity.',\n schema: 'crm',\n map: 'task',\n fields: {\n id: field.id(),\n title: field.string({ description: 'Task title' }),\n description: field.string({ isOptional: true }),\n\n // Type and priority\n type: field.enum('TaskType', { default: 'TODO' }),\n priority: field.enum('TaskPriority', { default: 'NORMAL' }),\n status: field.enum('TaskStatus', { default: 'PENDING' }),\n\n // Schedule\n dueDate: field.dateTime({ isOptional: true }),\n reminderAt: field.dateTime({ isOptional: true }),\n\n // Associations (polymorphic)\n contactId: field.string({ isOptional: true }),\n dealId: field.string({ isOptional: true }),\n companyId: field.string({ isOptional: true }),\n\n // Ownership\n organizationId: field.foreignKey(),\n assignedTo: field.foreignKey({ description: 'User assigned to this task' }),\n createdBy: field.foreignKey(),\n\n // Completion\n completedAt: field.dateTime({ isOptional: true }),\n completedBy: field.string({ isOptional: true }),\n\n // Timestamps\n createdAt: field.createdAt(),\n updatedAt: field.updatedAt(),\n\n // Relations\n contact: field.belongsTo('Contact', ['contactId'], ['id']),\n deal: field.belongsTo('Deal', ['dealId'], ['id']),\n company: field.belongsTo('Company', ['companyId'], ['id']),\n },\n indexes: [\n index.on(['organizationId', 'assignedTo', 'status']),\n index.on(['dueDate', 'status']),\n index.on(['contactId']),\n index.on(['dealId']),\n ],\n enums: [TaskTypeEnum, TaskPriorityEnum, TaskStatusEnum],\n});\n\n/**\n * Activity entity - interaction history.\n */\nexport const ActivityEntity = defineEntity({\n name: 'Activity',\n description: 'An activity/interaction logged in the CRM.',\n schema: 'crm',\n map: 'activity',\n fields: {\n id: field.id(),\n type: field.enum('TaskType'),\n subject: field.string(),\n description: field.string({ isOptional: true }),\n\n // Associations\n contactId: field.string({ isOptional: true }),\n dealId: field.string({ isOptional: true }),\n companyId: field.string({ isOptional: true }),\n\n // Ownership\n organizationId: field.foreignKey(),\n performedBy: field.foreignKey(),\n\n // Outcome\n outcome: field.string({ isOptional: true }),\n\n // Timing\n occurredAt: field.dateTime(),\n duration: field.int({\n isOptional: true,\n description: 'Duration in minutes',\n }),\n\n // Timestamps\n createdAt: field.createdAt(),\n\n // Relations\n contact: field.belongsTo('Contact', ['contactId'], ['id']),\n deal: field.belongsTo('Deal', ['dealId'], ['id']),\n company: field.belongsTo('Company', ['companyId'], ['id']),\n },\n indexes: [\n index.on(['contactId', 'occurredAt']),\n index.on(['dealId', 'occurredAt']),\n ],\n});\n"],"mappings":";;;;;;AAUA,MAAa,eAAe,iBAAiB;CAC3C,MAAM;CACN,QAAQ;EAAC;EAAQ;EAAS;EAAW;EAAQ;EAAa;EAAQ;CAClE,QAAQ;CACR,aAAa;CACd,CAAC;;;;AAKF,MAAa,mBAAmB,iBAAiB;CAC/C,MAAM;CACN,QAAQ;EAAC;EAAO;EAAU;EAAQ;EAAS;CAC3C,QAAQ;CACR,aAAa;CACd,CAAC;;;;AAKF,MAAa,iBAAiB,iBAAiB;CAC7C,MAAM;CACN,QAAQ;EAAC;EAAW;EAAe;EAAa;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MAAM,GAAG,CAAC,YAAY,CAAC;EACvB,MAAM,GAAG,CAAC,SAAS,CAAC;EACrB;CACD,OAAO;EAAC;EAAc;EAAkB;EAAe;CACxD,CAAC;;;;AAKF,MAAa,iBAAiB,aAAa;CACzC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,IAAI,MAAM,IAAI;EACd,MAAM,MAAM,KAAK,WAAW;EAC5B,SAAS,MAAM,QAAQ;EACvB,aAAa,MAAM,OAAO,EAAE,YAAY,MAAM,CAAC;EAG/C,WAAW,MAAM,OAAO,EAAE,YAAY,MAAM,CAAC;EAC7C,QAAQ,MAAM,OAAO,EAAE,YAAY,MAAM,CAAC;EAC1C,WAAW,MAAM,OAAO,EAAE,YAAY,MAAM,CAAC;EAG7C,gBAAgB,MAAM,YAAY;EAClC,aAAa,MAAM,YAAY;EAG/B,SAAS,MAAM,OAAO,EAAE,YAAY,MAAM,CAAC;EAG3C,YAAY,MAAM,UAAU;EAC5B,UAAU,MAAM,IAAI;GAClB,YAAY;GACZ,aAAa;GACd,CAAC;EAGF,WAAW,MAAM,WAAW;EAG5B,SAAS,MAAM,UAAU,WAAW,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;EAC1D,MAAM,MAAM,UAAU,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC;EACjD,SAAS,MAAM,UAAU,WAAW,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;EAC3D;CACD,SAAS,CACP,MAAM,GAAG,CAAC,aAAa,aAAa,CAAC,EACrC,MAAM,GAAG,CAAC,UAAU,aAAa,CAAC,CACnC;CACF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as _contractspec_lib_schema350 from "@contractspec/lib.schema";
|
|
2
|
+
import * as _contractspec_lib_contracts4 from "@contractspec/lib.contracts";
|
|
3
|
+
|
|
4
|
+
//#region src/events/contact.event.d.ts
|
|
5
|
+
declare const ContactCreatedEvent: _contractspec_lib_contracts4.EventSpec<_contractspec_lib_schema350.SchemaModel<{
|
|
6
|
+
contactId: {
|
|
7
|
+
type: _contractspec_lib_schema350.FieldType<string, string>;
|
|
8
|
+
isOptional: false;
|
|
9
|
+
};
|
|
10
|
+
email: {
|
|
11
|
+
type: _contractspec_lib_schema350.FieldType<string, string>;
|
|
12
|
+
isOptional: true;
|
|
13
|
+
};
|
|
14
|
+
organizationId: {
|
|
15
|
+
type: _contractspec_lib_schema350.FieldType<string, string>;
|
|
16
|
+
isOptional: false;
|
|
17
|
+
};
|
|
18
|
+
ownerId: {
|
|
19
|
+
type: _contractspec_lib_schema350.FieldType<string, string>;
|
|
20
|
+
isOptional: false;
|
|
21
|
+
};
|
|
22
|
+
createdAt: {
|
|
23
|
+
type: _contractspec_lib_schema350.FieldType<Date, string>;
|
|
24
|
+
isOptional: false;
|
|
25
|
+
};
|
|
26
|
+
}>>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ContactCreatedEvent };
|
|
29
|
+
//# sourceMappingURL=contact.event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact.event.d.ts","names":[],"sources":["../../src/events/contact.event.ts"],"sourcesContent":[],"mappings":";;;;cAoBa,qBAAmB,4BAAA,CAAA,sCAAA;;UAU9B,2BAAA,CAAA;;EAVW,CAAA;EAUX,KAAA,EAAA;;;;;;;EAV8B,CAAA;EAAA,OAAA,EAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
2
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
3
|
+
|
|
4
|
+
//#region src/events/contact.event.ts
|
|
5
|
+
const ContactCreatedPayload = defineSchemaModel({
|
|
6
|
+
name: "ContactCreatedPayload",
|
|
7
|
+
description: "Payload when a contact is created",
|
|
8
|
+
fields: {
|
|
9
|
+
contactId: {
|
|
10
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
11
|
+
isOptional: false
|
|
12
|
+
},
|
|
13
|
+
email: {
|
|
14
|
+
type: ScalarTypeEnum.EmailAddress(),
|
|
15
|
+
isOptional: true
|
|
16
|
+
},
|
|
17
|
+
organizationId: {
|
|
18
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
19
|
+
isOptional: false
|
|
20
|
+
},
|
|
21
|
+
ownerId: {
|
|
22
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
23
|
+
isOptional: false
|
|
24
|
+
},
|
|
25
|
+
createdAt: {
|
|
26
|
+
type: ScalarTypeEnum.DateTime(),
|
|
27
|
+
isOptional: false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const ContactCreatedEvent = defineEvent({
|
|
32
|
+
meta: {
|
|
33
|
+
key: "contact.created",
|
|
34
|
+
version: 1,
|
|
35
|
+
description: "A new contact has been created.",
|
|
36
|
+
stability: "stable",
|
|
37
|
+
owners: ["@crm-team"],
|
|
38
|
+
tags: ["contact", "created"]
|
|
39
|
+
},
|
|
40
|
+
payload: ContactCreatedPayload
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { ContactCreatedEvent };
|
|
45
|
+
//# sourceMappingURL=contact.event.js.map
|