@contractspec/example.crm-pipeline 3.7.17 → 3.7.18
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.log +135 -135
- package/CHANGELOG.md +20 -0
- package/dist/browser/crm-pipeline.feature.js +1 -82
- package/dist/browser/deal/deal.enum.js +1 -18
- package/dist/browser/deal/deal.operation.js +1 -396
- package/dist/browser/deal/deal.schema.js +1 -141
- package/dist/browser/deal/deal.test-spec.js +1 -58
- package/dist/browser/deal/index.js +1 -408
- package/dist/browser/docs/crm-pipeline.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/entities/company.entity.js +1 -52
- package/dist/browser/entities/contact.entity.js +1 -66
- package/dist/browser/entities/deal.entity.js +1 -107
- package/dist/browser/entities/index.js +1 -343
- package/dist/browser/entities/task.entity.js +1 -99
- package/dist/browser/events/contact.event.js +1 -31
- package/dist/browser/events/deal.event.js +1 -101
- package/dist/browser/events/index.js +1 -158
- package/dist/browser/events/task.event.js +1 -28
- package/dist/browser/example.js +1 -39
- package/dist/browser/handlers/crm.handlers.js +2 -171
- package/dist/browser/handlers/deal.handlers.js +1 -293
- package/dist/browser/handlers/index.js +2 -467
- package/dist/browser/handlers/mock-data.js +1 -165
- package/dist/browser/index.js +8 -3461
- package/dist/browser/operations/index.js +1 -407
- package/dist/browser/presentations/dashboard.presentation.js +1 -55
- package/dist/browser/presentations/index.js +1 -290
- package/dist/browser/presentations/pipeline.presentation.js +1 -236
- package/dist/browser/seeders/index.js +1 -22
- package/dist/browser/ui/CrmDashboard.js +1 -1547
- package/dist/browser/ui/CrmDealCard.js +1 -50
- package/dist/browser/ui/CrmPipelineBoard.js +1 -160
- package/dist/browser/ui/hooks/index.js +1 -197
- package/dist/browser/ui/hooks/useDealList.js +1 -95
- package/dist/browser/ui/hooks/useDealMutations.js +1 -100
- package/dist/browser/ui/index.js +4 -2205
- package/dist/browser/ui/modals/CreateDealModal.js +1 -211
- package/dist/browser/ui/modals/DealActionsModal.js +1 -428
- package/dist/browser/ui/modals/index.js +1 -638
- package/dist/browser/ui/overlays/demo-overlays.js +1 -55
- package/dist/browser/ui/overlays/index.js +1 -55
- package/dist/browser/ui/renderers/index.js +4 -849
- package/dist/browser/ui/renderers/pipeline.markdown.js +4 -575
- package/dist/browser/ui/renderers/pipeline.renderer.js +1 -275
- package/dist/browser/ui/tables/DealListTab.js +1 -390
- package/dist/crm-pipeline.feature.js +1 -82
- package/dist/deal/deal.enum.js +1 -18
- package/dist/deal/deal.operation.js +1 -396
- package/dist/deal/deal.schema.js +1 -141
- package/dist/deal/deal.test-spec.js +1 -58
- package/dist/deal/index.js +1 -408
- package/dist/docs/crm-pipeline.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/entities/company.entity.js +1 -52
- package/dist/entities/contact.entity.js +1 -66
- package/dist/entities/deal.entity.js +1 -107
- package/dist/entities/index.js +1 -343
- package/dist/entities/task.entity.js +1 -99
- package/dist/events/contact.event.js +1 -31
- package/dist/events/deal.event.js +1 -101
- package/dist/events/index.js +1 -158
- package/dist/events/task.event.js +1 -28
- package/dist/example.js +1 -39
- package/dist/handlers/crm.handlers.js +2 -171
- package/dist/handlers/deal.handlers.js +1 -293
- package/dist/handlers/index.js +2 -467
- package/dist/handlers/mock-data.js +1 -165
- package/dist/index.js +8 -3461
- package/dist/node/crm-pipeline.feature.js +1 -82
- package/dist/node/deal/deal.enum.js +1 -18
- package/dist/node/deal/deal.operation.js +1 -396
- package/dist/node/deal/deal.schema.js +1 -141
- package/dist/node/deal/deal.test-spec.js +1 -58
- package/dist/node/deal/index.js +1 -408
- package/dist/node/docs/crm-pipeline.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/entities/company.entity.js +1 -52
- package/dist/node/entities/contact.entity.js +1 -66
- package/dist/node/entities/deal.entity.js +1 -107
- package/dist/node/entities/index.js +1 -343
- package/dist/node/entities/task.entity.js +1 -99
- package/dist/node/events/contact.event.js +1 -31
- package/dist/node/events/deal.event.js +1 -101
- package/dist/node/events/index.js +1 -158
- package/dist/node/events/task.event.js +1 -28
- package/dist/node/example.js +1 -39
- package/dist/node/handlers/crm.handlers.js +2 -171
- package/dist/node/handlers/deal.handlers.js +1 -293
- package/dist/node/handlers/index.js +2 -467
- package/dist/node/handlers/mock-data.js +1 -165
- package/dist/node/index.js +8 -3461
- package/dist/node/operations/index.js +1 -407
- package/dist/node/presentations/dashboard.presentation.js +1 -55
- package/dist/node/presentations/index.js +1 -290
- package/dist/node/presentations/pipeline.presentation.js +1 -236
- package/dist/node/seeders/index.js +1 -22
- package/dist/node/ui/CrmDashboard.js +1 -1547
- package/dist/node/ui/CrmDealCard.js +1 -50
- package/dist/node/ui/CrmPipelineBoard.js +1 -160
- package/dist/node/ui/hooks/index.js +1 -197
- package/dist/node/ui/hooks/useDealList.js +1 -95
- package/dist/node/ui/hooks/useDealMutations.js +1 -100
- package/dist/node/ui/index.js +4 -2205
- package/dist/node/ui/modals/CreateDealModal.js +1 -211
- package/dist/node/ui/modals/DealActionsModal.js +1 -428
- package/dist/node/ui/modals/index.js +1 -638
- package/dist/node/ui/overlays/demo-overlays.js +1 -55
- package/dist/node/ui/overlays/index.js +1 -55
- package/dist/node/ui/renderers/index.js +4 -849
- package/dist/node/ui/renderers/pipeline.markdown.js +4 -575
- package/dist/node/ui/renderers/pipeline.renderer.js +1 -275
- package/dist/node/ui/tables/DealListTab.js +1 -390
- package/dist/operations/index.js +1 -407
- package/dist/presentations/dashboard.presentation.js +1 -55
- package/dist/presentations/index.js +1 -290
- package/dist/presentations/pipeline.presentation.js +1 -236
- package/dist/seeders/index.js +1 -22
- package/dist/ui/CrmDashboard.js +1 -1547
- package/dist/ui/CrmDealCard.js +1 -50
- package/dist/ui/CrmPipelineBoard.js +1 -160
- package/dist/ui/hooks/index.js +1 -197
- package/dist/ui/hooks/useDealList.js +1 -95
- package/dist/ui/hooks/useDealMutations.js +1 -100
- package/dist/ui/index.js +4 -2205
- package/dist/ui/modals/CreateDealModal.js +1 -211
- package/dist/ui/modals/DealActionsModal.js +1 -428
- package/dist/ui/modals/index.js +1 -638
- package/dist/ui/overlays/demo-overlays.js +1 -55
- package/dist/ui/overlays/index.js +1 -55
- package/dist/ui/renderers/index.js +4 -849
- package/dist/ui/renderers/pipeline.markdown.js +4 -575
- package/dist/ui/renderers/pipeline.renderer.js +1 -275
- package/dist/ui/tables/DealListTab.js +1 -390
- package/package.json +13 -13
|
@@ -1,53 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
defineEntity,
|
|
5
|
-
defineEntityEnum,
|
|
6
|
-
field,
|
|
7
|
-
index
|
|
8
|
-
} from "@contractspec/lib.schema";
|
|
9
|
-
var CompanySizeEnum = defineEntityEnum({
|
|
10
|
-
name: "CompanySize",
|
|
11
|
-
values: ["STARTUP", "SMALL", "MEDIUM", "LARGE", "ENTERPRISE"],
|
|
12
|
-
schema: "crm",
|
|
13
|
-
description: "Size category of a company."
|
|
14
|
-
});
|
|
15
|
-
var CompanyEntity = defineEntity({
|
|
16
|
-
name: "Company",
|
|
17
|
-
description: "A company/organization in the CRM.",
|
|
18
|
-
schema: "crm",
|
|
19
|
-
map: "company",
|
|
20
|
-
fields: {
|
|
21
|
-
id: field.id({ description: "Unique company ID" }),
|
|
22
|
-
name: field.string({ description: "Company name" }),
|
|
23
|
-
domain: field.string({ isOptional: true, description: "Website domain" }),
|
|
24
|
-
website: field.url({ isOptional: true }),
|
|
25
|
-
industry: field.string({ isOptional: true }),
|
|
26
|
-
size: field.enum("CompanySize", { isOptional: true }),
|
|
27
|
-
employeeCount: field.int({ isOptional: true }),
|
|
28
|
-
annualRevenue: field.decimal({ isOptional: true }),
|
|
29
|
-
organizationId: field.foreignKey(),
|
|
30
|
-
ownerId: field.foreignKey({ description: "Account owner" }),
|
|
31
|
-
phone: field.string({ isOptional: true }),
|
|
32
|
-
email: field.email({ isOptional: true }),
|
|
33
|
-
address: field.string({ isOptional: true }),
|
|
34
|
-
city: field.string({ isOptional: true }),
|
|
35
|
-
state: field.string({ isOptional: true }),
|
|
36
|
-
country: field.string({ isOptional: true }),
|
|
37
|
-
postalCode: field.string({ isOptional: true }),
|
|
38
|
-
linkedInUrl: field.url({ isOptional: true }),
|
|
39
|
-
description: field.string({ isOptional: true }),
|
|
40
|
-
tags: field.string({ isArray: true }),
|
|
41
|
-
customFields: field.json({ isOptional: true }),
|
|
42
|
-
createdAt: field.createdAt(),
|
|
43
|
-
updatedAt: field.updatedAt(),
|
|
44
|
-
contacts: field.hasMany("Contact"),
|
|
45
|
-
deals: field.hasMany("Deal")
|
|
46
|
-
},
|
|
47
|
-
indexes: [index.on(["organizationId", "ownerId"]), index.on(["domain"])],
|
|
48
|
-
enums: [CompanySizeEnum]
|
|
49
|
-
});
|
|
50
|
-
export {
|
|
51
|
-
CompanySizeEnum,
|
|
52
|
-
CompanyEntity
|
|
53
|
-
};
|
|
2
|
+
import{defineEntity as q,defineEntityEnum as v,field as j,index as k}from"@contractspec/lib.schema";var D=v({name:"CompanySize",values:["STARTUP","SMALL","MEDIUM","LARGE","ENTERPRISE"],schema:"crm",description:"Size category of a company."}),G=q({name:"Company",description:"A company/organization in the CRM.",schema:"crm",map:"company",fields:{id:j.id({description:"Unique company ID"}),name:j.string({description:"Company name"}),domain:j.string({isOptional:!0,description:"Website domain"}),website:j.url({isOptional:!0}),industry:j.string({isOptional:!0}),size:j.enum("CompanySize",{isOptional:!0}),employeeCount:j.int({isOptional:!0}),annualRevenue:j.decimal({isOptional:!0}),organizationId:j.foreignKey(),ownerId:j.foreignKey({description:"Account owner"}),phone:j.string({isOptional:!0}),email:j.email({isOptional:!0}),address:j.string({isOptional:!0}),city:j.string({isOptional:!0}),state:j.string({isOptional:!0}),country:j.string({isOptional:!0}),postalCode:j.string({isOptional:!0}),linkedInUrl:j.url({isOptional:!0}),description:j.string({isOptional:!0}),tags:j.string({isArray:!0}),customFields:j.json({isOptional:!0}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),contacts:j.hasMany("Contact"),deals:j.hasMany("Deal")},indexes:[k.on(["organizationId","ownerId"]),k.on(["domain"])],enums:[D]});export{D as CompanySizeEnum,G as CompanyEntity};
|
|
@@ -1,67 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
defineEntity,
|
|
5
|
-
defineEntityEnum,
|
|
6
|
-
field,
|
|
7
|
-
index
|
|
8
|
-
} from "@contractspec/lib.schema";
|
|
9
|
-
var ContactStatusEnum = defineEntityEnum({
|
|
10
|
-
name: "ContactStatus",
|
|
11
|
-
values: ["LEAD", "PROSPECT", "CUSTOMER", "CHURNED", "ARCHIVED"],
|
|
12
|
-
schema: "crm",
|
|
13
|
-
description: "Status of a contact in the sales funnel."
|
|
14
|
-
});
|
|
15
|
-
var ContactEntity = defineEntity({
|
|
16
|
-
name: "Contact",
|
|
17
|
-
description: "An individual person in the CRM.",
|
|
18
|
-
schema: "crm",
|
|
19
|
-
map: "contact",
|
|
20
|
-
fields: {
|
|
21
|
-
id: field.id({ description: "Unique contact ID" }),
|
|
22
|
-
firstName: field.string({ description: "First name" }),
|
|
23
|
-
lastName: field.string({ description: "Last name" }),
|
|
24
|
-
email: field.email({ isOptional: true, isUnique: true }),
|
|
25
|
-
phone: field.string({ isOptional: true }),
|
|
26
|
-
companyId: field.string({
|
|
27
|
-
isOptional: true,
|
|
28
|
-
description: "Associated company"
|
|
29
|
-
}),
|
|
30
|
-
jobTitle: field.string({ isOptional: true }),
|
|
31
|
-
status: field.enum("ContactStatus", { default: "LEAD" }),
|
|
32
|
-
organizationId: field.foreignKey(),
|
|
33
|
-
ownerId: field.foreignKey({
|
|
34
|
-
description: "Sales rep who owns this contact"
|
|
35
|
-
}),
|
|
36
|
-
source: field.string({ isOptional: true, description: "Lead source" }),
|
|
37
|
-
linkedInUrl: field.url({ isOptional: true }),
|
|
38
|
-
twitterHandle: field.string({ isOptional: true }),
|
|
39
|
-
address: field.string({ isOptional: true }),
|
|
40
|
-
city: field.string({ isOptional: true }),
|
|
41
|
-
state: field.string({ isOptional: true }),
|
|
42
|
-
country: field.string({ isOptional: true }),
|
|
43
|
-
postalCode: field.string({ isOptional: true }),
|
|
44
|
-
notes: field.string({ isOptional: true }),
|
|
45
|
-
tags: field.string({ isArray: true }),
|
|
46
|
-
customFields: field.json({ isOptional: true }),
|
|
47
|
-
lastContactedAt: field.dateTime({ isOptional: true }),
|
|
48
|
-
nextFollowUpAt: field.dateTime({ isOptional: true }),
|
|
49
|
-
createdAt: field.createdAt(),
|
|
50
|
-
updatedAt: field.updatedAt(),
|
|
51
|
-
company: field.belongsTo("Company", ["companyId"], ["id"]),
|
|
52
|
-
deals: field.hasMany("Deal"),
|
|
53
|
-
tasks: field.hasMany("Task"),
|
|
54
|
-
activities: field.hasMany("Activity")
|
|
55
|
-
},
|
|
56
|
-
indexes: [
|
|
57
|
-
index.on(["organizationId", "status"]),
|
|
58
|
-
index.on(["organizationId", "ownerId"]),
|
|
59
|
-
index.on(["organizationId", "companyId"]),
|
|
60
|
-
index.on(["email"])
|
|
61
|
-
],
|
|
62
|
-
enums: [ContactStatusEnum]
|
|
63
|
-
});
|
|
64
|
-
export {
|
|
65
|
-
ContactStatusEnum,
|
|
66
|
-
ContactEntity
|
|
67
|
-
};
|
|
2
|
+
import{defineEntity as q,defineEntityEnum as z,field as j,index as k}from"@contractspec/lib.schema";var D=z({name:"ContactStatus",values:["LEAD","PROSPECT","CUSTOMER","CHURNED","ARCHIVED"],schema:"crm",description:"Status of a contact in the sales funnel."}),G=q({name:"Contact",description:"An individual person in the CRM.",schema:"crm",map:"contact",fields:{id:j.id({description:"Unique contact ID"}),firstName:j.string({description:"First name"}),lastName:j.string({description:"Last name"}),email:j.email({isOptional:!0,isUnique:!0}),phone:j.string({isOptional:!0}),companyId:j.string({isOptional:!0,description:"Associated company"}),jobTitle:j.string({isOptional:!0}),status:j.enum("ContactStatus",{default:"LEAD"}),organizationId:j.foreignKey(),ownerId:j.foreignKey({description:"Sales rep who owns this contact"}),source:j.string({isOptional:!0,description:"Lead source"}),linkedInUrl:j.url({isOptional:!0}),twitterHandle:j.string({isOptional:!0}),address:j.string({isOptional:!0}),city:j.string({isOptional:!0}),state:j.string({isOptional:!0}),country:j.string({isOptional:!0}),postalCode:j.string({isOptional:!0}),notes:j.string({isOptional:!0}),tags:j.string({isArray:!0}),customFields:j.json({isOptional:!0}),lastContactedAt:j.dateTime({isOptional:!0}),nextFollowUpAt:j.dateTime({isOptional:!0}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),company:j.belongsTo("Company",["companyId"],["id"]),deals:j.hasMany("Deal"),tasks:j.hasMany("Task"),activities:j.hasMany("Activity")},indexes:[k.on(["organizationId","status"]),k.on(["organizationId","ownerId"]),k.on(["organizationId","companyId"]),k.on(["email"])],enums:[D]});export{D as ContactStatusEnum,G as ContactEntity};
|
|
@@ -1,108 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
defineEntity,
|
|
5
|
-
defineEntityEnum,
|
|
6
|
-
field,
|
|
7
|
-
index
|
|
8
|
-
} from "@contractspec/lib.schema";
|
|
9
|
-
var DealStatusEnum = defineEntityEnum({
|
|
10
|
-
name: "DealStatus",
|
|
11
|
-
values: ["OPEN", "WON", "LOST", "STALE"],
|
|
12
|
-
schema: "crm",
|
|
13
|
-
description: "Status of a deal."
|
|
14
|
-
});
|
|
15
|
-
var PipelineEntity = defineEntity({
|
|
16
|
-
name: "Pipeline",
|
|
17
|
-
description: "A sales pipeline with stages.",
|
|
18
|
-
schema: "crm",
|
|
19
|
-
map: "pipeline",
|
|
20
|
-
fields: {
|
|
21
|
-
id: field.id(),
|
|
22
|
-
name: field.string({ description: "Pipeline name" }),
|
|
23
|
-
description: field.string({ isOptional: true }),
|
|
24
|
-
organizationId: field.foreignKey(),
|
|
25
|
-
isDefault: field.boolean({ default: false }),
|
|
26
|
-
createdAt: field.createdAt(),
|
|
27
|
-
updatedAt: field.updatedAt(),
|
|
28
|
-
stages: field.hasMany("Stage"),
|
|
29
|
-
deals: field.hasMany("Deal")
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
var StageEntity = defineEntity({
|
|
33
|
-
name: "Stage",
|
|
34
|
-
description: "A stage within a sales pipeline.",
|
|
35
|
-
schema: "crm",
|
|
36
|
-
map: "stage",
|
|
37
|
-
fields: {
|
|
38
|
-
id: field.id(),
|
|
39
|
-
name: field.string({ description: "Stage name" }),
|
|
40
|
-
pipelineId: field.foreignKey(),
|
|
41
|
-
position: field.int({ description: "Order in pipeline" }),
|
|
42
|
-
probability: field.int({
|
|
43
|
-
default: 0,
|
|
44
|
-
description: "Win probability (0-100)"
|
|
45
|
-
}),
|
|
46
|
-
isWonStage: field.boolean({ default: false }),
|
|
47
|
-
isLostStage: field.boolean({ default: false }),
|
|
48
|
-
color: field.string({
|
|
49
|
-
isOptional: true,
|
|
50
|
-
description: "Stage color for UI"
|
|
51
|
-
}),
|
|
52
|
-
createdAt: field.createdAt(),
|
|
53
|
-
updatedAt: field.updatedAt(),
|
|
54
|
-
pipeline: field.belongsTo("Pipeline", ["pipelineId"], ["id"], {
|
|
55
|
-
onDelete: "Cascade"
|
|
56
|
-
}),
|
|
57
|
-
deals: field.hasMany("Deal")
|
|
58
|
-
},
|
|
59
|
-
indexes: [index.on(["pipelineId", "position"])]
|
|
60
|
-
});
|
|
61
|
-
var DealEntity = defineEntity({
|
|
62
|
-
name: "Deal",
|
|
63
|
-
description: "A sales opportunity/deal.",
|
|
64
|
-
schema: "crm",
|
|
65
|
-
map: "deal",
|
|
66
|
-
fields: {
|
|
67
|
-
id: field.id({ description: "Unique deal ID" }),
|
|
68
|
-
name: field.string({ description: "Deal name" }),
|
|
69
|
-
value: field.decimal({ description: "Deal value" }),
|
|
70
|
-
currency: field.string({ default: '"USD"' }),
|
|
71
|
-
pipelineId: field.foreignKey(),
|
|
72
|
-
stageId: field.foreignKey(),
|
|
73
|
-
status: field.enum("DealStatus", { default: "OPEN" }),
|
|
74
|
-
contactId: field.string({ isOptional: true }),
|
|
75
|
-
companyId: field.string({ isOptional: true }),
|
|
76
|
-
organizationId: field.foreignKey(),
|
|
77
|
-
ownerId: field.foreignKey({ description: "Deal owner" }),
|
|
78
|
-
expectedCloseDate: field.dateTime({ isOptional: true }),
|
|
79
|
-
closedAt: field.dateTime({ isOptional: true }),
|
|
80
|
-
lostReason: field.string({ isOptional: true }),
|
|
81
|
-
wonSource: field.string({ isOptional: true }),
|
|
82
|
-
notes: field.string({ isOptional: true }),
|
|
83
|
-
tags: field.string({ isArray: true }),
|
|
84
|
-
customFields: field.json({ isOptional: true }),
|
|
85
|
-
stagePosition: field.int({ default: 0 }),
|
|
86
|
-
createdAt: field.createdAt(),
|
|
87
|
-
updatedAt: field.updatedAt(),
|
|
88
|
-
pipeline: field.belongsTo("Pipeline", ["pipelineId"], ["id"]),
|
|
89
|
-
stage: field.belongsTo("Stage", ["stageId"], ["id"]),
|
|
90
|
-
contact: field.belongsTo("Contact", ["contactId"], ["id"]),
|
|
91
|
-
company: field.belongsTo("Company", ["companyId"], ["id"]),
|
|
92
|
-
tasks: field.hasMany("Task"),
|
|
93
|
-
activities: field.hasMany("Activity")
|
|
94
|
-
},
|
|
95
|
-
indexes: [
|
|
96
|
-
index.on(["organizationId", "status"]),
|
|
97
|
-
index.on(["pipelineId", "stageId", "stagePosition"]),
|
|
98
|
-
index.on(["ownerId", "status"]),
|
|
99
|
-
index.on(["expectedCloseDate"])
|
|
100
|
-
],
|
|
101
|
-
enums: [DealStatusEnum]
|
|
102
|
-
});
|
|
103
|
-
export {
|
|
104
|
-
StageEntity,
|
|
105
|
-
PipelineEntity,
|
|
106
|
-
DealStatusEnum,
|
|
107
|
-
DealEntity
|
|
108
|
-
};
|
|
2
|
+
import{defineEntity as q,defineEntityEnum as v,field as j,index as k}from"@contractspec/lib.schema";var w=v({name:"DealStatus",values:["OPEN","WON","LOST","STALE"],schema:"crm",description:"Status of a deal."}),A=q({name:"Pipeline",description:"A sales pipeline with stages.",schema:"crm",map:"pipeline",fields:{id:j.id(),name:j.string({description:"Pipeline name"}),description:j.string({isOptional:!0}),organizationId:j.foreignKey(),isDefault:j.boolean({default:!1}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),stages:j.hasMany("Stage"),deals:j.hasMany("Deal")}}),B=q({name:"Stage",description:"A stage within a sales pipeline.",schema:"crm",map:"stage",fields:{id:j.id(),name:j.string({description:"Stage name"}),pipelineId:j.foreignKey(),position:j.int({description:"Order in pipeline"}),probability:j.int({default:0,description:"Win probability (0-100)"}),isWonStage:j.boolean({default:!1}),isLostStage:j.boolean({default:!1}),color:j.string({isOptional:!0,description:"Stage color for UI"}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),pipeline:j.belongsTo("Pipeline",["pipelineId"],["id"],{onDelete:"Cascade"}),deals:j.hasMany("Deal")},indexes:[k.on(["pipelineId","position"])]}),C=q({name:"Deal",description:"A sales opportunity/deal.",schema:"crm",map:"deal",fields:{id:j.id({description:"Unique deal ID"}),name:j.string({description:"Deal name"}),value:j.decimal({description:"Deal value"}),currency:j.string({default:'"USD"'}),pipelineId:j.foreignKey(),stageId:j.foreignKey(),status:j.enum("DealStatus",{default:"OPEN"}),contactId:j.string({isOptional:!0}),companyId:j.string({isOptional:!0}),organizationId:j.foreignKey(),ownerId:j.foreignKey({description:"Deal owner"}),expectedCloseDate:j.dateTime({isOptional:!0}),closedAt:j.dateTime({isOptional:!0}),lostReason:j.string({isOptional:!0}),wonSource:j.string({isOptional:!0}),notes:j.string({isOptional:!0}),tags:j.string({isArray:!0}),customFields:j.json({isOptional:!0}),stagePosition:j.int({default:0}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),pipeline:j.belongsTo("Pipeline",["pipelineId"],["id"]),stage:j.belongsTo("Stage",["stageId"],["id"]),contact:j.belongsTo("Contact",["contactId"],["id"]),company:j.belongsTo("Company",["companyId"],["id"]),tasks:j.hasMany("Task"),activities:j.hasMany("Activity")},indexes:[k.on(["organizationId","status"]),k.on(["pipelineId","stageId","stagePosition"]),k.on(["ownerId","status"]),k.on(["expectedCloseDate"])],enums:[w]});export{B as StageEntity,A as PipelineEntity,w as DealStatusEnum,C as DealEntity};
|
package/dist/entities/index.js
CHANGED
|
@@ -1,344 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
defineEntity,
|
|
5
|
-
defineEntityEnum,
|
|
6
|
-
field,
|
|
7
|
-
index
|
|
8
|
-
} from "@contractspec/lib.schema";
|
|
9
|
-
var CompanySizeEnum = defineEntityEnum({
|
|
10
|
-
name: "CompanySize",
|
|
11
|
-
values: ["STARTUP", "SMALL", "MEDIUM", "LARGE", "ENTERPRISE"],
|
|
12
|
-
schema: "crm",
|
|
13
|
-
description: "Size category of a company."
|
|
14
|
-
});
|
|
15
|
-
var CompanyEntity = defineEntity({
|
|
16
|
-
name: "Company",
|
|
17
|
-
description: "A company/organization in the CRM.",
|
|
18
|
-
schema: "crm",
|
|
19
|
-
map: "company",
|
|
20
|
-
fields: {
|
|
21
|
-
id: field.id({ description: "Unique company ID" }),
|
|
22
|
-
name: field.string({ description: "Company name" }),
|
|
23
|
-
domain: field.string({ isOptional: true, description: "Website domain" }),
|
|
24
|
-
website: field.url({ isOptional: true }),
|
|
25
|
-
industry: field.string({ isOptional: true }),
|
|
26
|
-
size: field.enum("CompanySize", { isOptional: true }),
|
|
27
|
-
employeeCount: field.int({ isOptional: true }),
|
|
28
|
-
annualRevenue: field.decimal({ isOptional: true }),
|
|
29
|
-
organizationId: field.foreignKey(),
|
|
30
|
-
ownerId: field.foreignKey({ description: "Account owner" }),
|
|
31
|
-
phone: field.string({ isOptional: true }),
|
|
32
|
-
email: field.email({ isOptional: true }),
|
|
33
|
-
address: field.string({ isOptional: true }),
|
|
34
|
-
city: field.string({ isOptional: true }),
|
|
35
|
-
state: field.string({ isOptional: true }),
|
|
36
|
-
country: field.string({ isOptional: true }),
|
|
37
|
-
postalCode: field.string({ isOptional: true }),
|
|
38
|
-
linkedInUrl: field.url({ isOptional: true }),
|
|
39
|
-
description: field.string({ isOptional: true }),
|
|
40
|
-
tags: field.string({ isArray: true }),
|
|
41
|
-
customFields: field.json({ isOptional: true }),
|
|
42
|
-
createdAt: field.createdAt(),
|
|
43
|
-
updatedAt: field.updatedAt(),
|
|
44
|
-
contacts: field.hasMany("Contact"),
|
|
45
|
-
deals: field.hasMany("Deal")
|
|
46
|
-
},
|
|
47
|
-
indexes: [index.on(["organizationId", "ownerId"]), index.on(["domain"])],
|
|
48
|
-
enums: [CompanySizeEnum]
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// src/entities/contact.entity.ts
|
|
52
|
-
import {
|
|
53
|
-
defineEntity as defineEntity2,
|
|
54
|
-
defineEntityEnum as defineEntityEnum2,
|
|
55
|
-
field as field2,
|
|
56
|
-
index as index2
|
|
57
|
-
} from "@contractspec/lib.schema";
|
|
58
|
-
var ContactStatusEnum = defineEntityEnum2({
|
|
59
|
-
name: "ContactStatus",
|
|
60
|
-
values: ["LEAD", "PROSPECT", "CUSTOMER", "CHURNED", "ARCHIVED"],
|
|
61
|
-
schema: "crm",
|
|
62
|
-
description: "Status of a contact in the sales funnel."
|
|
63
|
-
});
|
|
64
|
-
var ContactEntity = defineEntity2({
|
|
65
|
-
name: "Contact",
|
|
66
|
-
description: "An individual person in the CRM.",
|
|
67
|
-
schema: "crm",
|
|
68
|
-
map: "contact",
|
|
69
|
-
fields: {
|
|
70
|
-
id: field2.id({ description: "Unique contact ID" }),
|
|
71
|
-
firstName: field2.string({ description: "First name" }),
|
|
72
|
-
lastName: field2.string({ description: "Last name" }),
|
|
73
|
-
email: field2.email({ isOptional: true, isUnique: true }),
|
|
74
|
-
phone: field2.string({ isOptional: true }),
|
|
75
|
-
companyId: field2.string({
|
|
76
|
-
isOptional: true,
|
|
77
|
-
description: "Associated company"
|
|
78
|
-
}),
|
|
79
|
-
jobTitle: field2.string({ isOptional: true }),
|
|
80
|
-
status: field2.enum("ContactStatus", { default: "LEAD" }),
|
|
81
|
-
organizationId: field2.foreignKey(),
|
|
82
|
-
ownerId: field2.foreignKey({
|
|
83
|
-
description: "Sales rep who owns this contact"
|
|
84
|
-
}),
|
|
85
|
-
source: field2.string({ isOptional: true, description: "Lead source" }),
|
|
86
|
-
linkedInUrl: field2.url({ isOptional: true }),
|
|
87
|
-
twitterHandle: field2.string({ isOptional: true }),
|
|
88
|
-
address: field2.string({ isOptional: true }),
|
|
89
|
-
city: field2.string({ isOptional: true }),
|
|
90
|
-
state: field2.string({ isOptional: true }),
|
|
91
|
-
country: field2.string({ isOptional: true }),
|
|
92
|
-
postalCode: field2.string({ isOptional: true }),
|
|
93
|
-
notes: field2.string({ isOptional: true }),
|
|
94
|
-
tags: field2.string({ isArray: true }),
|
|
95
|
-
customFields: field2.json({ isOptional: true }),
|
|
96
|
-
lastContactedAt: field2.dateTime({ isOptional: true }),
|
|
97
|
-
nextFollowUpAt: field2.dateTime({ isOptional: true }),
|
|
98
|
-
createdAt: field2.createdAt(),
|
|
99
|
-
updatedAt: field2.updatedAt(),
|
|
100
|
-
company: field2.belongsTo("Company", ["companyId"], ["id"]),
|
|
101
|
-
deals: field2.hasMany("Deal"),
|
|
102
|
-
tasks: field2.hasMany("Task"),
|
|
103
|
-
activities: field2.hasMany("Activity")
|
|
104
|
-
},
|
|
105
|
-
indexes: [
|
|
106
|
-
index2.on(["organizationId", "status"]),
|
|
107
|
-
index2.on(["organizationId", "ownerId"]),
|
|
108
|
-
index2.on(["organizationId", "companyId"]),
|
|
109
|
-
index2.on(["email"])
|
|
110
|
-
],
|
|
111
|
-
enums: [ContactStatusEnum]
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// src/entities/deal.entity.ts
|
|
115
|
-
import {
|
|
116
|
-
defineEntity as defineEntity3,
|
|
117
|
-
defineEntityEnum as defineEntityEnum3,
|
|
118
|
-
field as field3,
|
|
119
|
-
index as index3
|
|
120
|
-
} from "@contractspec/lib.schema";
|
|
121
|
-
var DealStatusEnum = defineEntityEnum3({
|
|
122
|
-
name: "DealStatus",
|
|
123
|
-
values: ["OPEN", "WON", "LOST", "STALE"],
|
|
124
|
-
schema: "crm",
|
|
125
|
-
description: "Status of a deal."
|
|
126
|
-
});
|
|
127
|
-
var PipelineEntity = defineEntity3({
|
|
128
|
-
name: "Pipeline",
|
|
129
|
-
description: "A sales pipeline with stages.",
|
|
130
|
-
schema: "crm",
|
|
131
|
-
map: "pipeline",
|
|
132
|
-
fields: {
|
|
133
|
-
id: field3.id(),
|
|
134
|
-
name: field3.string({ description: "Pipeline name" }),
|
|
135
|
-
description: field3.string({ isOptional: true }),
|
|
136
|
-
organizationId: field3.foreignKey(),
|
|
137
|
-
isDefault: field3.boolean({ default: false }),
|
|
138
|
-
createdAt: field3.createdAt(),
|
|
139
|
-
updatedAt: field3.updatedAt(),
|
|
140
|
-
stages: field3.hasMany("Stage"),
|
|
141
|
-
deals: field3.hasMany("Deal")
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
var StageEntity = defineEntity3({
|
|
145
|
-
name: "Stage",
|
|
146
|
-
description: "A stage within a sales pipeline.",
|
|
147
|
-
schema: "crm",
|
|
148
|
-
map: "stage",
|
|
149
|
-
fields: {
|
|
150
|
-
id: field3.id(),
|
|
151
|
-
name: field3.string({ description: "Stage name" }),
|
|
152
|
-
pipelineId: field3.foreignKey(),
|
|
153
|
-
position: field3.int({ description: "Order in pipeline" }),
|
|
154
|
-
probability: field3.int({
|
|
155
|
-
default: 0,
|
|
156
|
-
description: "Win probability (0-100)"
|
|
157
|
-
}),
|
|
158
|
-
isWonStage: field3.boolean({ default: false }),
|
|
159
|
-
isLostStage: field3.boolean({ default: false }),
|
|
160
|
-
color: field3.string({
|
|
161
|
-
isOptional: true,
|
|
162
|
-
description: "Stage color for UI"
|
|
163
|
-
}),
|
|
164
|
-
createdAt: field3.createdAt(),
|
|
165
|
-
updatedAt: field3.updatedAt(),
|
|
166
|
-
pipeline: field3.belongsTo("Pipeline", ["pipelineId"], ["id"], {
|
|
167
|
-
onDelete: "Cascade"
|
|
168
|
-
}),
|
|
169
|
-
deals: field3.hasMany("Deal")
|
|
170
|
-
},
|
|
171
|
-
indexes: [index3.on(["pipelineId", "position"])]
|
|
172
|
-
});
|
|
173
|
-
var DealEntity = defineEntity3({
|
|
174
|
-
name: "Deal",
|
|
175
|
-
description: "A sales opportunity/deal.",
|
|
176
|
-
schema: "crm",
|
|
177
|
-
map: "deal",
|
|
178
|
-
fields: {
|
|
179
|
-
id: field3.id({ description: "Unique deal ID" }),
|
|
180
|
-
name: field3.string({ description: "Deal name" }),
|
|
181
|
-
value: field3.decimal({ description: "Deal value" }),
|
|
182
|
-
currency: field3.string({ default: '"USD"' }),
|
|
183
|
-
pipelineId: field3.foreignKey(),
|
|
184
|
-
stageId: field3.foreignKey(),
|
|
185
|
-
status: field3.enum("DealStatus", { default: "OPEN" }),
|
|
186
|
-
contactId: field3.string({ isOptional: true }),
|
|
187
|
-
companyId: field3.string({ isOptional: true }),
|
|
188
|
-
organizationId: field3.foreignKey(),
|
|
189
|
-
ownerId: field3.foreignKey({ description: "Deal owner" }),
|
|
190
|
-
expectedCloseDate: field3.dateTime({ isOptional: true }),
|
|
191
|
-
closedAt: field3.dateTime({ isOptional: true }),
|
|
192
|
-
lostReason: field3.string({ isOptional: true }),
|
|
193
|
-
wonSource: field3.string({ isOptional: true }),
|
|
194
|
-
notes: field3.string({ isOptional: true }),
|
|
195
|
-
tags: field3.string({ isArray: true }),
|
|
196
|
-
customFields: field3.json({ isOptional: true }),
|
|
197
|
-
stagePosition: field3.int({ default: 0 }),
|
|
198
|
-
createdAt: field3.createdAt(),
|
|
199
|
-
updatedAt: field3.updatedAt(),
|
|
200
|
-
pipeline: field3.belongsTo("Pipeline", ["pipelineId"], ["id"]),
|
|
201
|
-
stage: field3.belongsTo("Stage", ["stageId"], ["id"]),
|
|
202
|
-
contact: field3.belongsTo("Contact", ["contactId"], ["id"]),
|
|
203
|
-
company: field3.belongsTo("Company", ["companyId"], ["id"]),
|
|
204
|
-
tasks: field3.hasMany("Task"),
|
|
205
|
-
activities: field3.hasMany("Activity")
|
|
206
|
-
},
|
|
207
|
-
indexes: [
|
|
208
|
-
index3.on(["organizationId", "status"]),
|
|
209
|
-
index3.on(["pipelineId", "stageId", "stagePosition"]),
|
|
210
|
-
index3.on(["ownerId", "status"]),
|
|
211
|
-
index3.on(["expectedCloseDate"])
|
|
212
|
-
],
|
|
213
|
-
enums: [DealStatusEnum]
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// src/entities/task.entity.ts
|
|
217
|
-
import {
|
|
218
|
-
defineEntity as defineEntity4,
|
|
219
|
-
defineEntityEnum as defineEntityEnum4,
|
|
220
|
-
field as field4,
|
|
221
|
-
index as index4
|
|
222
|
-
} from "@contractspec/lib.schema";
|
|
223
|
-
var TaskTypeEnum = defineEntityEnum4({
|
|
224
|
-
name: "TaskType",
|
|
225
|
-
values: ["CALL", "EMAIL", "MEETING", "TODO", "FOLLOW_UP", "OTHER"],
|
|
226
|
-
schema: "crm",
|
|
227
|
-
description: "Type of CRM task."
|
|
228
|
-
});
|
|
229
|
-
var TaskPriorityEnum = defineEntityEnum4({
|
|
230
|
-
name: "TaskPriority",
|
|
231
|
-
values: ["LOW", "NORMAL", "HIGH", "URGENT"],
|
|
232
|
-
schema: "crm",
|
|
233
|
-
description: "Priority of a task."
|
|
234
|
-
});
|
|
235
|
-
var TaskStatusEnum = defineEntityEnum4({
|
|
236
|
-
name: "TaskStatus",
|
|
237
|
-
values: ["PENDING", "IN_PROGRESS", "COMPLETED", "CANCELLED"],
|
|
238
|
-
schema: "crm",
|
|
239
|
-
description: "Status of a task."
|
|
240
|
-
});
|
|
241
|
-
var TaskEntity = defineEntity4({
|
|
242
|
-
name: "Task",
|
|
243
|
-
description: "A task or follow-up activity.",
|
|
244
|
-
schema: "crm",
|
|
245
|
-
map: "task",
|
|
246
|
-
fields: {
|
|
247
|
-
id: field4.id(),
|
|
248
|
-
title: field4.string({ description: "Task title" }),
|
|
249
|
-
description: field4.string({ isOptional: true }),
|
|
250
|
-
type: field4.enum("TaskType", { default: "TODO" }),
|
|
251
|
-
priority: field4.enum("TaskPriority", { default: "NORMAL" }),
|
|
252
|
-
status: field4.enum("TaskStatus", { default: "PENDING" }),
|
|
253
|
-
dueDate: field4.dateTime({ isOptional: true }),
|
|
254
|
-
reminderAt: field4.dateTime({ isOptional: true }),
|
|
255
|
-
contactId: field4.string({ isOptional: true }),
|
|
256
|
-
dealId: field4.string({ isOptional: true }),
|
|
257
|
-
companyId: field4.string({ isOptional: true }),
|
|
258
|
-
organizationId: field4.foreignKey(),
|
|
259
|
-
assignedTo: field4.foreignKey({ description: "User assigned to this task" }),
|
|
260
|
-
createdBy: field4.foreignKey(),
|
|
261
|
-
completedAt: field4.dateTime({ isOptional: true }),
|
|
262
|
-
completedBy: field4.string({ isOptional: true }),
|
|
263
|
-
createdAt: field4.createdAt(),
|
|
264
|
-
updatedAt: field4.updatedAt(),
|
|
265
|
-
contact: field4.belongsTo("Contact", ["contactId"], ["id"]),
|
|
266
|
-
deal: field4.belongsTo("Deal", ["dealId"], ["id"]),
|
|
267
|
-
company: field4.belongsTo("Company", ["companyId"], ["id"])
|
|
268
|
-
},
|
|
269
|
-
indexes: [
|
|
270
|
-
index4.on(["organizationId", "assignedTo", "status"]),
|
|
271
|
-
index4.on(["dueDate", "status"]),
|
|
272
|
-
index4.on(["contactId"]),
|
|
273
|
-
index4.on(["dealId"])
|
|
274
|
-
],
|
|
275
|
-
enums: [TaskTypeEnum, TaskPriorityEnum, TaskStatusEnum]
|
|
276
|
-
});
|
|
277
|
-
var ActivityEntity = defineEntity4({
|
|
278
|
-
name: "Activity",
|
|
279
|
-
description: "An activity/interaction logged in the CRM.",
|
|
280
|
-
schema: "crm",
|
|
281
|
-
map: "activity",
|
|
282
|
-
fields: {
|
|
283
|
-
id: field4.id(),
|
|
284
|
-
type: field4.enum("TaskType"),
|
|
285
|
-
subject: field4.string(),
|
|
286
|
-
description: field4.string({ isOptional: true }),
|
|
287
|
-
contactId: field4.string({ isOptional: true }),
|
|
288
|
-
dealId: field4.string({ isOptional: true }),
|
|
289
|
-
companyId: field4.string({ isOptional: true }),
|
|
290
|
-
organizationId: field4.foreignKey(),
|
|
291
|
-
performedBy: field4.foreignKey(),
|
|
292
|
-
outcome: field4.string({ isOptional: true }),
|
|
293
|
-
occurredAt: field4.dateTime(),
|
|
294
|
-
duration: field4.int({
|
|
295
|
-
isOptional: true,
|
|
296
|
-
description: "Duration in minutes"
|
|
297
|
-
}),
|
|
298
|
-
createdAt: field4.createdAt(),
|
|
299
|
-
contact: field4.belongsTo("Contact", ["contactId"], ["id"]),
|
|
300
|
-
deal: field4.belongsTo("Deal", ["dealId"], ["id"]),
|
|
301
|
-
company: field4.belongsTo("Company", ["companyId"], ["id"])
|
|
302
|
-
},
|
|
303
|
-
indexes: [
|
|
304
|
-
index4.on(["contactId", "occurredAt"]),
|
|
305
|
-
index4.on(["dealId", "occurredAt"])
|
|
306
|
-
]
|
|
307
|
-
});
|
|
308
|
-
// src/entities/index.ts
|
|
309
|
-
var crmPipelineSchemaContribution = {
|
|
310
|
-
moduleId: "@contractspec/example.crm-pipeline",
|
|
311
|
-
entities: [
|
|
312
|
-
CompanyEntity,
|
|
313
|
-
ContactEntity,
|
|
314
|
-
DealEntity,
|
|
315
|
-
PipelineEntity,
|
|
316
|
-
StageEntity,
|
|
317
|
-
TaskEntity,
|
|
318
|
-
ActivityEntity
|
|
319
|
-
],
|
|
320
|
-
enums: [
|
|
321
|
-
CompanySizeEnum,
|
|
322
|
-
ContactStatusEnum,
|
|
323
|
-
DealStatusEnum,
|
|
324
|
-
TaskTypeEnum,
|
|
325
|
-
TaskPriorityEnum,
|
|
326
|
-
TaskStatusEnum
|
|
327
|
-
]
|
|
328
|
-
};
|
|
329
|
-
export {
|
|
330
|
-
crmPipelineSchemaContribution,
|
|
331
|
-
TaskTypeEnum,
|
|
332
|
-
TaskStatusEnum,
|
|
333
|
-
TaskPriorityEnum,
|
|
334
|
-
TaskEntity,
|
|
335
|
-
StageEntity,
|
|
336
|
-
PipelineEntity,
|
|
337
|
-
DealStatusEnum,
|
|
338
|
-
DealEntity,
|
|
339
|
-
ContactStatusEnum,
|
|
340
|
-
ContactEntity,
|
|
341
|
-
CompanySizeEnum,
|
|
342
|
-
CompanyEntity,
|
|
343
|
-
ActivityEntity
|
|
344
|
-
};
|
|
2
|
+
import{defineEntity as z,defineEntityEnum as O,field as G,index as $}from"@contractspec/lib.schema";var Q=O({name:"CompanySize",values:["STARTUP","SMALL","MEDIUM","LARGE","ENTERPRISE"],schema:"crm",description:"Size category of a company."}),I=z({name:"Company",description:"A company/organization in the CRM.",schema:"crm",map:"company",fields:{id:G.id({description:"Unique company ID"}),name:G.string({description:"Company name"}),domain:G.string({isOptional:!0,description:"Website domain"}),website:G.url({isOptional:!0}),industry:G.string({isOptional:!0}),size:G.enum("CompanySize",{isOptional:!0}),employeeCount:G.int({isOptional:!0}),annualRevenue:G.decimal({isOptional:!0}),organizationId:G.foreignKey(),ownerId:G.foreignKey({description:"Account owner"}),phone:G.string({isOptional:!0}),email:G.email({isOptional:!0}),address:G.string({isOptional:!0}),city:G.string({isOptional:!0}),state:G.string({isOptional:!0}),country:G.string({isOptional:!0}),postalCode:G.string({isOptional:!0}),linkedInUrl:G.url({isOptional:!0}),description:G.string({isOptional:!0}),tags:G.string({isArray:!0}),customFields:G.json({isOptional:!0}),createdAt:G.createdAt(),updatedAt:G.updatedAt(),contacts:G.hasMany("Contact"),deals:G.hasMany("Deal")},indexes:[$.on(["organizationId","ownerId"]),$.on(["domain"])],enums:[Q]});import{defineEntity as A,defineEntityEnum as P,field as F,index as L}from"@contractspec/lib.schema";var U=P({name:"ContactStatus",values:["LEAD","PROSPECT","CUSTOMER","CHURNED","ARCHIVED"],schema:"crm",description:"Status of a contact in the sales funnel."}),K=A({name:"Contact",description:"An individual person in the CRM.",schema:"crm",map:"contact",fields:{id:F.id({description:"Unique contact ID"}),firstName:F.string({description:"First name"}),lastName:F.string({description:"Last name"}),email:F.email({isOptional:!0,isUnique:!0}),phone:F.string({isOptional:!0}),companyId:F.string({isOptional:!0,description:"Associated company"}),jobTitle:F.string({isOptional:!0}),status:F.enum("ContactStatus",{default:"LEAD"}),organizationId:F.foreignKey(),ownerId:F.foreignKey({description:"Sales rep who owns this contact"}),source:F.string({isOptional:!0,description:"Lead source"}),linkedInUrl:F.url({isOptional:!0}),twitterHandle:F.string({isOptional:!0}),address:F.string({isOptional:!0}),city:F.string({isOptional:!0}),state:F.string({isOptional:!0}),country:F.string({isOptional:!0}),postalCode:F.string({isOptional:!0}),notes:F.string({isOptional:!0}),tags:F.string({isArray:!0}),customFields:F.json({isOptional:!0}),lastContactedAt:F.dateTime({isOptional:!0}),nextFollowUpAt:F.dateTime({isOptional:!0}),createdAt:F.createdAt(),updatedAt:F.updatedAt(),company:F.belongsTo("Company",["companyId"],["id"]),deals:F.hasMany("Deal"),tasks:F.hasMany("Task"),activities:F.hasMany("Activity")},indexes:[L.on(["organizationId","status"]),L.on(["organizationId","ownerId"]),L.on(["organizationId","companyId"]),L.on(["email"])],enums:[U]});import{defineEntity as V,defineEntityEnum as R,field as j,index as J}from"@contractspec/lib.schema";var W=R({name:"DealStatus",values:["OPEN","WON","LOST","STALE"],schema:"crm",description:"Status of a deal."}),M=V({name:"Pipeline",description:"A sales pipeline with stages.",schema:"crm",map:"pipeline",fields:{id:j.id(),name:j.string({description:"Pipeline name"}),description:j.string({isOptional:!0}),organizationId:j.foreignKey(),isDefault:j.boolean({default:!1}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),stages:j.hasMany("Stage"),deals:j.hasMany("Deal")}}),B=V({name:"Stage",description:"A stage within a sales pipeline.",schema:"crm",map:"stage",fields:{id:j.id(),name:j.string({description:"Stage name"}),pipelineId:j.foreignKey(),position:j.int({description:"Order in pipeline"}),probability:j.int({default:0,description:"Win probability (0-100)"}),isWonStage:j.boolean({default:!1}),isLostStage:j.boolean({default:!1}),color:j.string({isOptional:!0,description:"Stage color for UI"}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),pipeline:j.belongsTo("Pipeline",["pipelineId"],["id"],{onDelete:"Cascade"}),deals:j.hasMany("Deal")},indexes:[J.on(["pipelineId","position"])]}),N=V({name:"Deal",description:"A sales opportunity/deal.",schema:"crm",map:"deal",fields:{id:j.id({description:"Unique deal ID"}),name:j.string({description:"Deal name"}),value:j.decimal({description:"Deal value"}),currency:j.string({default:'"USD"'}),pipelineId:j.foreignKey(),stageId:j.foreignKey(),status:j.enum("DealStatus",{default:"OPEN"}),contactId:j.string({isOptional:!0}),companyId:j.string({isOptional:!0}),organizationId:j.foreignKey(),ownerId:j.foreignKey({description:"Deal owner"}),expectedCloseDate:j.dateTime({isOptional:!0}),closedAt:j.dateTime({isOptional:!0}),lostReason:j.string({isOptional:!0}),wonSource:j.string({isOptional:!0}),notes:j.string({isOptional:!0}),tags:j.string({isArray:!0}),customFields:j.json({isOptional:!0}),stagePosition:j.int({default:0}),createdAt:j.createdAt(),updatedAt:j.updatedAt(),pipeline:j.belongsTo("Pipeline",["pipelineId"],["id"]),stage:j.belongsTo("Stage",["stageId"],["id"]),contact:j.belongsTo("Contact",["contactId"],["id"]),company:j.belongsTo("Company",["companyId"],["id"]),tasks:j.hasMany("Task"),activities:j.hasMany("Activity")},indexes:[J.on(["organizationId","status"]),J.on(["pipelineId","stageId","stagePosition"]),J.on(["ownerId","status"]),J.on(["expectedCloseDate"])],enums:[W]});import{defineEntity as v,defineEntityEnum as X,field as q,index as H}from"@contractspec/lib.schema";var Y=X({name:"TaskType",values:["CALL","EMAIL","MEETING","TODO","FOLLOW_UP","OTHER"],schema:"crm",description:"Type of CRM task."}),Z=X({name:"TaskPriority",values:["LOW","NORMAL","HIGH","URGENT"],schema:"crm",description:"Priority of a task."}),_=X({name:"TaskStatus",values:["PENDING","IN_PROGRESS","COMPLETED","CANCELLED"],schema:"crm",description:"Status of a task."}),w=v({name:"Task",description:"A task or follow-up activity.",schema:"crm",map:"task",fields:{id:q.id(),title:q.string({description:"Task title"}),description:q.string({isOptional:!0}),type:q.enum("TaskType",{default:"TODO"}),priority:q.enum("TaskPriority",{default:"NORMAL"}),status:q.enum("TaskStatus",{default:"PENDING"}),dueDate:q.dateTime({isOptional:!0}),reminderAt:q.dateTime({isOptional:!0}),contactId:q.string({isOptional:!0}),dealId:q.string({isOptional:!0}),companyId:q.string({isOptional:!0}),organizationId:q.foreignKey(),assignedTo:q.foreignKey({description:"User assigned to this task"}),createdBy:q.foreignKey(),completedAt:q.dateTime({isOptional:!0}),completedBy:q.string({isOptional:!0}),createdAt:q.createdAt(),updatedAt:q.updatedAt(),contact:q.belongsTo("Contact",["contactId"],["id"]),deal:q.belongsTo("Deal",["dealId"],["id"]),company:q.belongsTo("Company",["companyId"],["id"])},indexes:[H.on(["organizationId","assignedTo","status"]),H.on(["dueDate","status"]),H.on(["contactId"]),H.on(["dealId"])],enums:[Y,Z,_]}),D=v({name:"Activity",description:"An activity/interaction logged in the CRM.",schema:"crm",map:"activity",fields:{id:q.id(),type:q.enum("TaskType"),subject:q.string(),description:q.string({isOptional:!0}),contactId:q.string({isOptional:!0}),dealId:q.string({isOptional:!0}),companyId:q.string({isOptional:!0}),organizationId:q.foreignKey(),performedBy:q.foreignKey(),outcome:q.string({isOptional:!0}),occurredAt:q.dateTime(),duration:q.int({isOptional:!0,description:"Duration in minutes"}),createdAt:q.createdAt(),contact:q.belongsTo("Contact",["contactId"],["id"]),deal:q.belongsTo("Deal",["dealId"],["id"]),company:q.belongsTo("Company",["companyId"],["id"])},indexes:[H.on(["contactId","occurredAt"]),H.on(["dealId","occurredAt"])]});var c={moduleId:"@contractspec/example.crm-pipeline",entities:[I,K,N,M,B,w,D],enums:[Q,U,W,Y,Z,_]};export{c as crmPipelineSchemaContribution,Y as TaskTypeEnum,_ as TaskStatusEnum,Z as TaskPriorityEnum,w as TaskEntity,B as StageEntity,M as PipelineEntity,W as DealStatusEnum,N as DealEntity,U as ContactStatusEnum,K as ContactEntity,Q as CompanySizeEnum,I as CompanyEntity,D as ActivityEntity};
|