@contractspec/example.crm-pipeline 1.57.0 → 1.58.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.log +148 -164
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +20 -0
- package/dist/browser/crm-pipeline.feature.js +75 -0
- package/dist/browser/deal/deal.enum.js +18 -0
- package/dist/browser/deal/deal.operation.js +396 -0
- package/dist/browser/deal/deal.schema.js +141 -0
- package/dist/browser/deal/deal.test-spec.js +58 -0
- package/dist/browser/deal/index.js +408 -0
- package/dist/browser/docs/crm-pipeline.docblock.js +113 -0
- package/dist/browser/docs/index.js +113 -0
- package/dist/browser/entities/company.entity.js +52 -0
- package/dist/browser/entities/contact.entity.js +66 -0
- package/dist/browser/entities/deal.entity.js +107 -0
- package/dist/browser/entities/index.js +343 -0
- package/dist/browser/entities/task.entity.js +99 -0
- package/dist/browser/events/contact.event.js +31 -0
- package/dist/browser/events/deal.event.js +101 -0
- package/dist/browser/events/index.js +158 -0
- package/dist/browser/events/task.event.js +28 -0
- package/dist/browser/example.js +39 -0
- package/dist/browser/handlers/crm.handlers.js +160 -0
- package/dist/browser/handlers/deal.handlers.js +293 -0
- package/dist/browser/handlers/index.js +456 -0
- package/dist/browser/handlers/mock-data.js +165 -0
- package/dist/browser/index.js +3279 -0
- package/dist/browser/operations/index.js +407 -0
- package/dist/browser/presentations/dashboard.presentation.js +52 -0
- package/dist/browser/presentations/index.js +284 -0
- package/dist/browser/presentations/pipeline.presentation.js +233 -0
- package/dist/browser/seeders/index.js +22 -0
- package/dist/browser/shared/overlay-types.js +0 -0
- package/dist/browser/ui/CrmDashboard.js +1325 -0
- package/dist/browser/ui/CrmDealCard.js +50 -0
- package/dist/browser/ui/CrmPipelineBoard.js +160 -0
- package/dist/browser/ui/hooks/index.js +186 -0
- package/dist/browser/ui/hooks/useDealList.js +84 -0
- package/dist/browser/ui/hooks/useDealMutations.js +100 -0
- package/dist/browser/ui/index.js +1972 -0
- package/dist/browser/ui/modals/CreateDealModal.js +211 -0
- package/dist/browser/ui/modals/DealActionsModal.js +428 -0
- package/dist/browser/ui/modals/index.js +638 -0
- package/dist/browser/ui/overlays/demo-overlays.js +55 -0
- package/dist/browser/ui/overlays/index.js +55 -0
- package/dist/browser/ui/renderers/index.js +827 -0
- package/dist/browser/ui/renderers/pipeline.markdown.js +564 -0
- package/dist/browser/ui/renderers/pipeline.renderer.js +264 -0
- package/dist/crm-pipeline.feature.d.ts +1 -6
- package/dist/crm-pipeline.feature.d.ts.map +1 -1
- package/dist/crm-pipeline.feature.js +74 -164
- package/dist/deal/deal.enum.d.ts +2 -7
- package/dist/deal/deal.enum.d.ts.map +1 -1
- package/dist/deal/deal.enum.js +16 -22
- package/dist/deal/deal.operation.d.ts +444 -450
- package/dist/deal/deal.operation.d.ts.map +1 -1
- package/dist/deal/deal.operation.js +390 -263
- package/dist/deal/deal.schema.d.ts +251 -256
- package/dist/deal/deal.schema.d.ts.map +1 -1
- package/dist/deal/deal.schema.js +131 -275
- package/dist/deal/deal.test-spec.d.ts +2 -7
- package/dist/deal/deal.test-spec.d.ts.map +1 -1
- package/dist/deal/deal.test-spec.js +56 -62
- package/dist/deal/index.d.ts +7 -4
- package/dist/deal/index.d.ts.map +1 -0
- package/dist/deal/index.js +408 -4
- package/dist/docs/crm-pipeline.docblock.d.ts +2 -1
- package/dist/docs/crm-pipeline.docblock.d.ts.map +1 -0
- package/dist/docs/crm-pipeline.docblock.js +45 -51
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +114 -1
- package/dist/entities/company.entity.d.ts +27 -32
- package/dist/entities/company.entity.d.ts.map +1 -1
- package/dist/entities/company.entity.js +51 -61
- package/dist/entities/contact.entity.d.ts +31 -36
- package/dist/entities/contact.entity.d.ts.map +1 -1
- package/dist/entities/contact.entity.js +65 -76
- package/dist/entities/deal.entity.d.ts +52 -57
- package/dist/entities/deal.entity.d.ts.map +1 -1
- package/dist/entities/deal.entity.js +104 -116
- package/dist/entities/index.d.ts +6 -10
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +342 -31
- package/dist/entities/task.entity.d.ts +42 -47
- package/dist/entities/task.entity.d.ts.map +1 -1
- package/dist/entities/task.entity.js +95 -124
- package/dist/events/contact.event.d.ts +21 -27
- package/dist/events/contact.event.d.ts.map +1 -1
- package/dist/events/contact.event.js +29 -42
- package/dist/events/deal.event.d.ts +100 -106
- package/dist/events/deal.event.d.ts.map +1 -1
- package/dist/events/deal.event.js +93 -163
- package/dist/events/index.d.ts +4 -4
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +158 -4
- package/dist/events/task.event.d.ts +21 -27
- package/dist/events/task.event.d.ts.map +1 -1
- package/dist/events/task.event.js +26 -42
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +38 -50
- package/dist/handlers/crm.handlers.d.ts +80 -78
- package/dist/handlers/crm.handlers.d.ts.map +1 -1
- package/dist/handlers/crm.handlers.js +155 -166
- package/dist/handlers/deal.handlers.d.ts +58 -63
- package/dist/handlers/deal.handlers.d.ts.map +1 -1
- package/dist/handlers/deal.handlers.js +279 -105
- package/dist/handlers/index.d.ts +10 -4
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +456 -4
- package/dist/handlers/mock-data.d.ts +38 -41
- package/dist/handlers/mock-data.d.ts.map +1 -1
- package/dist/handlers/mock-data.js +162 -184
- package/dist/index.d.ts +13 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3277 -53
- package/dist/node/crm-pipeline.feature.js +75 -0
- package/dist/node/deal/deal.enum.js +18 -0
- package/dist/node/deal/deal.operation.js +396 -0
- package/dist/node/deal/deal.schema.js +141 -0
- package/dist/node/deal/deal.test-spec.js +58 -0
- package/dist/node/deal/index.js +408 -0
- package/dist/node/docs/crm-pipeline.docblock.js +113 -0
- package/dist/node/docs/index.js +113 -0
- package/dist/node/entities/company.entity.js +52 -0
- package/dist/node/entities/contact.entity.js +66 -0
- package/dist/node/entities/deal.entity.js +107 -0
- package/dist/node/entities/index.js +343 -0
- package/dist/node/entities/task.entity.js +99 -0
- package/dist/node/events/contact.event.js +31 -0
- package/dist/node/events/deal.event.js +101 -0
- package/dist/node/events/index.js +158 -0
- package/dist/node/events/task.event.js +28 -0
- package/dist/node/example.js +39 -0
- package/dist/node/handlers/crm.handlers.js +160 -0
- package/dist/node/handlers/deal.handlers.js +293 -0
- package/dist/node/handlers/index.js +456 -0
- package/dist/node/handlers/mock-data.js +165 -0
- package/dist/node/index.js +3279 -0
- package/dist/node/operations/index.js +407 -0
- package/dist/node/presentations/dashboard.presentation.js +52 -0
- package/dist/node/presentations/index.js +284 -0
- package/dist/node/presentations/pipeline.presentation.js +233 -0
- package/dist/node/seeders/index.js +22 -0
- package/dist/node/shared/overlay-types.js +0 -0
- package/dist/node/ui/CrmDashboard.js +1325 -0
- package/dist/node/ui/CrmDealCard.js +50 -0
- package/dist/node/ui/CrmPipelineBoard.js +160 -0
- package/dist/node/ui/hooks/index.js +186 -0
- package/dist/node/ui/hooks/useDealList.js +84 -0
- package/dist/node/ui/hooks/useDealMutations.js +100 -0
- package/dist/node/ui/index.js +1972 -0
- package/dist/node/ui/modals/CreateDealModal.js +211 -0
- package/dist/node/ui/modals/DealActionsModal.js +428 -0
- package/dist/node/ui/modals/index.js +638 -0
- package/dist/node/ui/overlays/demo-overlays.js +55 -0
- package/dist/node/ui/overlays/index.js +55 -0
- package/dist/node/ui/renderers/index.js +827 -0
- package/dist/node/ui/renderers/pipeline.markdown.js +564 -0
- package/dist/node/ui/renderers/pipeline.renderer.js +264 -0
- package/dist/operations/index.d.ts +2 -5
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +407 -5
- package/dist/presentations/dashboard.presentation.d.ts +2 -7
- package/dist/presentations/dashboard.presentation.d.ts.map +1 -1
- package/dist/presentations/dashboard.presentation.js +51 -60
- package/dist/presentations/index.d.ts +3 -3
- package/dist/presentations/index.d.ts.map +1 -0
- package/dist/presentations/index.js +284 -3
- package/dist/presentations/pipeline.presentation.d.ts +4 -9
- package/dist/presentations/pipeline.presentation.d.ts.map +1 -1
- package/dist/presentations/pipeline.presentation.js +228 -116
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +21 -45
- package/dist/shared/overlay-types.d.ts +25 -28
- package/dist/shared/overlay-types.d.ts.map +1 -1
- package/dist/shared/overlay-types.js +1 -0
- package/dist/ui/CrmDashboard.d.ts +1 -6
- package/dist/ui/CrmDashboard.d.ts.map +1 -1
- package/dist/ui/CrmDashboard.js +1318 -296
- package/dist/ui/CrmDealCard.d.ts +8 -12
- package/dist/ui/CrmDealCard.d.ts.map +1 -1
- package/dist/ui/CrmDealCard.js +47 -45
- package/dist/ui/CrmPipelineBoard.d.ts +11 -20
- package/dist/ui/CrmPipelineBoard.d.ts.map +1 -1
- package/dist/ui/CrmPipelineBoard.js +157 -94
- package/dist/ui/hooks/index.d.ts +3 -3
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +185 -4
- package/dist/ui/hooks/useDealList.d.ts +28 -32
- package/dist/ui/hooks/useDealList.d.ts.map +1 -1
- package/dist/ui/hooks/useDealList.js +81 -90
- package/dist/ui/hooks/useDealMutations.d.ts +18 -22
- package/dist/ui/hooks/useDealMutations.d.ts.map +1 -1
- package/dist/ui/hooks/useDealMutations.js +97 -155
- package/dist/ui/index.d.ts +8 -14
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1973 -15
- package/dist/ui/modals/CreateDealModal.d.ts +19 -29
- package/dist/ui/modals/CreateDealModal.d.ts.map +1 -1
- package/dist/ui/modals/CreateDealModal.js +209 -180
- package/dist/ui/modals/DealActionsModal.d.ts +31 -44
- package/dist/ui/modals/DealActionsModal.d.ts.map +1 -1
- package/dist/ui/modals/DealActionsModal.js +424 -367
- package/dist/ui/modals/index.d.ts +3 -3
- package/dist/ui/modals/index.d.ts.map +1 -0
- package/dist/ui/modals/index.js +638 -3
- package/dist/ui/overlays/demo-overlays.d.ts +10 -8
- package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
- package/dist/ui/overlays/demo-overlays.js +54 -66
- package/dist/ui/overlays/index.d.ts +2 -2
- package/dist/ui/overlays/index.d.ts.map +1 -0
- package/dist/ui/overlays/index.js +56 -3
- package/dist/ui/renderers/index.d.ts +3 -3
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +827 -3
- package/dist/ui/renderers/pipeline.markdown.d.ts +12 -11
- package/dist/ui/renderers/pipeline.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/pipeline.markdown.js +560 -114
- package/dist/ui/renderers/pipeline.renderer.d.ts +9 -7
- package/dist/ui/renderers/pipeline.renderer.d.ts.map +1 -1
- package/dist/ui/renderers/pipeline.renderer.js +261 -24
- package/package.json +476 -90
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -164
- package/dist/crm-pipeline.feature.js.map +0 -1
- package/dist/deal/deal.enum.js.map +0 -1
- package/dist/deal/deal.operation.js.map +0 -1
- package/dist/deal/deal.schema.js.map +0 -1
- package/dist/deal/deal.test-spec.js.map +0 -1
- package/dist/docs/crm-pipeline.docblock.js.map +0 -1
- package/dist/entities/company.entity.js.map +0 -1
- package/dist/entities/contact.entity.js.map +0 -1
- package/dist/entities/deal.entity.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/task.entity.js.map +0 -1
- package/dist/events/contact.event.js.map +0 -1
- package/dist/events/deal.event.js.map +0 -1
- package/dist/events/task.event.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/crm.handlers.js.map +0 -1
- package/dist/handlers/deal.handlers.js.map +0 -1
- package/dist/handlers/mock-data.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/presentations/dashboard.presentation.js.map +0 -1
- package/dist/presentations/pipeline.presentation.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/ui/CrmDashboard.js.map +0 -1
- package/dist/ui/CrmDealCard.js.map +0 -1
- package/dist/ui/CrmPipelineBoard.js.map +0 -1
- package/dist/ui/hooks/useDealList.js.map +0 -1
- package/dist/ui/hooks/useDealMutations.js.map +0 -1
- package/dist/ui/modals/CreateDealModal.js.map +0 -1
- package/dist/ui/modals/DealActionsModal.js.map +0 -1
- package/dist/ui/overlays/demo-overlays.js.map +0 -1
- package/dist/ui/renderers/pipeline.markdown.js.map +0 -1
- package/dist/ui/renderers/pipeline.renderer.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// src/events/deal.event.ts
|
|
2
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
4
|
+
var DealCreatedPayload = defineSchemaModel({
|
|
5
|
+
name: "DealCreatedPayload",
|
|
6
|
+
description: "Payload when a deal is created",
|
|
7
|
+
fields: {
|
|
8
|
+
dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
11
|
+
pipelineId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
stageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
13
|
+
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
var DealMovedPayload = defineSchemaModel({
|
|
18
|
+
name: "DealMovedEventPayload",
|
|
19
|
+
description: "Payload when a deal is moved to another stage",
|
|
20
|
+
fields: {
|
|
21
|
+
dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
22
|
+
fromStageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
23
|
+
toStageId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
24
|
+
movedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
25
|
+
movedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var DealWonPayload = defineSchemaModel({
|
|
29
|
+
name: "DealWonEventPayload",
|
|
30
|
+
description: "Payload when a deal is won",
|
|
31
|
+
fields: {
|
|
32
|
+
dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
33
|
+
value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
34
|
+
currency: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
35
|
+
contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
36
|
+
companyId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
37
|
+
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
38
|
+
wonAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var DealLostPayload = defineSchemaModel({
|
|
42
|
+
name: "DealLostEventPayload",
|
|
43
|
+
description: "Payload when a deal is lost",
|
|
44
|
+
fields: {
|
|
45
|
+
dealId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
46
|
+
value: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
|
|
47
|
+
reason: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
48
|
+
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
49
|
+
lostAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var DealCreatedEvent = defineEvent({
|
|
53
|
+
meta: {
|
|
54
|
+
key: "deal.created",
|
|
55
|
+
version: "1.0.0",
|
|
56
|
+
description: "A new deal has been created.",
|
|
57
|
+
stability: "stable",
|
|
58
|
+
owners: ["@crm-team"],
|
|
59
|
+
tags: ["deal", "created"]
|
|
60
|
+
},
|
|
61
|
+
payload: DealCreatedPayload
|
|
62
|
+
});
|
|
63
|
+
var DealMovedEvent = defineEvent({
|
|
64
|
+
meta: {
|
|
65
|
+
key: "deal.moved",
|
|
66
|
+
version: "1.0.0",
|
|
67
|
+
description: "A deal has been moved to a different stage.",
|
|
68
|
+
stability: "stable",
|
|
69
|
+
owners: ["@crm-team"],
|
|
70
|
+
tags: ["deal", "moved"]
|
|
71
|
+
},
|
|
72
|
+
payload: DealMovedPayload
|
|
73
|
+
});
|
|
74
|
+
var DealWonEvent = defineEvent({
|
|
75
|
+
meta: {
|
|
76
|
+
key: "deal.won",
|
|
77
|
+
version: "1.0.0",
|
|
78
|
+
description: "A deal has been won.",
|
|
79
|
+
stability: "stable",
|
|
80
|
+
owners: ["@crm-team"],
|
|
81
|
+
tags: ["deal", "won"]
|
|
82
|
+
},
|
|
83
|
+
payload: DealWonPayload
|
|
84
|
+
});
|
|
85
|
+
var DealLostEvent = defineEvent({
|
|
86
|
+
meta: {
|
|
87
|
+
key: "deal.lost",
|
|
88
|
+
version: "1.0.0",
|
|
89
|
+
description: "A deal has been lost.",
|
|
90
|
+
stability: "stable",
|
|
91
|
+
owners: ["@crm-team"],
|
|
92
|
+
tags: ["deal", "lost"]
|
|
93
|
+
},
|
|
94
|
+
payload: DealLostPayload
|
|
95
|
+
});
|
|
96
|
+
export {
|
|
97
|
+
DealWonEvent,
|
|
98
|
+
DealMovedEvent,
|
|
99
|
+
DealLostEvent,
|
|
100
|
+
DealCreatedEvent
|
|
101
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// src/events/contact.event.ts
|
|
2
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
4
|
+
var ContactCreatedPayload = defineSchemaModel({
|
|
5
|
+
name: "ContactCreatedPayload",
|
|
6
|
+
description: "Payload when a contact is created",
|
|
7
|
+
fields: {
|
|
8
|
+
contactId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
email: { type: ScalarTypeEnum.EmailAddress(), isOptional: true },
|
|
10
|
+
organizationId: {
|
|
11
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
12
|
+
isOptional: false
|
|
13
|
+
},
|
|
14
|
+
ownerId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
15
|
+
createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var ContactCreatedEvent = defineEvent({
|
|
19
|
+
meta: {
|
|
20
|
+
key: "contact.created",
|
|
21
|
+
version: "1.0.0",
|
|
22
|
+
description: "A new contact has been created.",
|
|
23
|
+
stability: "stable",
|
|
24
|
+
owners: ["@crm-team"],
|
|
25
|
+
tags: ["contact", "created"]
|
|
26
|
+
},
|
|
27
|
+
payload: ContactCreatedPayload
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// src/events/deal.event.ts
|
|
31
|
+
import { ScalarTypeEnum as ScalarTypeEnum2, defineSchemaModel as defineSchemaModel2 } from "@contractspec/lib.schema";
|
|
32
|
+
import { defineEvent as defineEvent2 } from "@contractspec/lib.contracts";
|
|
33
|
+
var DealCreatedPayload = defineSchemaModel2({
|
|
34
|
+
name: "DealCreatedPayload",
|
|
35
|
+
description: "Payload when a deal is created",
|
|
36
|
+
fields: {
|
|
37
|
+
dealId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
38
|
+
name: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
39
|
+
value: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
|
|
40
|
+
pipelineId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
41
|
+
stageId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
42
|
+
ownerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
43
|
+
createdAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var DealMovedPayload = defineSchemaModel2({
|
|
47
|
+
name: "DealMovedEventPayload",
|
|
48
|
+
description: "Payload when a deal is moved to another stage",
|
|
49
|
+
fields: {
|
|
50
|
+
dealId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
51
|
+
fromStageId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
52
|
+
toStageId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
53
|
+
movedBy: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
54
|
+
movedAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
var DealWonPayload = defineSchemaModel2({
|
|
58
|
+
name: "DealWonEventPayload",
|
|
59
|
+
description: "Payload when a deal is won",
|
|
60
|
+
fields: {
|
|
61
|
+
dealId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
62
|
+
value: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
|
|
63
|
+
currency: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
64
|
+
contactId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
65
|
+
companyId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: true },
|
|
66
|
+
ownerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
67
|
+
wonAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
var DealLostPayload = defineSchemaModel2({
|
|
71
|
+
name: "DealLostEventPayload",
|
|
72
|
+
description: "Payload when a deal is lost",
|
|
73
|
+
fields: {
|
|
74
|
+
dealId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
75
|
+
value: { type: ScalarTypeEnum2.Float_unsecure(), isOptional: false },
|
|
76
|
+
reason: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
77
|
+
ownerId: { type: ScalarTypeEnum2.String_unsecure(), isOptional: false },
|
|
78
|
+
lostAt: { type: ScalarTypeEnum2.DateTime(), isOptional: false }
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
var DealCreatedEvent = defineEvent2({
|
|
82
|
+
meta: {
|
|
83
|
+
key: "deal.created",
|
|
84
|
+
version: "1.0.0",
|
|
85
|
+
description: "A new deal has been created.",
|
|
86
|
+
stability: "stable",
|
|
87
|
+
owners: ["@crm-team"],
|
|
88
|
+
tags: ["deal", "created"]
|
|
89
|
+
},
|
|
90
|
+
payload: DealCreatedPayload
|
|
91
|
+
});
|
|
92
|
+
var DealMovedEvent = defineEvent2({
|
|
93
|
+
meta: {
|
|
94
|
+
key: "deal.moved",
|
|
95
|
+
version: "1.0.0",
|
|
96
|
+
description: "A deal has been moved to a different stage.",
|
|
97
|
+
stability: "stable",
|
|
98
|
+
owners: ["@crm-team"],
|
|
99
|
+
tags: ["deal", "moved"]
|
|
100
|
+
},
|
|
101
|
+
payload: DealMovedPayload
|
|
102
|
+
});
|
|
103
|
+
var DealWonEvent = defineEvent2({
|
|
104
|
+
meta: {
|
|
105
|
+
key: "deal.won",
|
|
106
|
+
version: "1.0.0",
|
|
107
|
+
description: "A deal has been won.",
|
|
108
|
+
stability: "stable",
|
|
109
|
+
owners: ["@crm-team"],
|
|
110
|
+
tags: ["deal", "won"]
|
|
111
|
+
},
|
|
112
|
+
payload: DealWonPayload
|
|
113
|
+
});
|
|
114
|
+
var DealLostEvent = defineEvent2({
|
|
115
|
+
meta: {
|
|
116
|
+
key: "deal.lost",
|
|
117
|
+
version: "1.0.0",
|
|
118
|
+
description: "A deal has been lost.",
|
|
119
|
+
stability: "stable",
|
|
120
|
+
owners: ["@crm-team"],
|
|
121
|
+
tags: ["deal", "lost"]
|
|
122
|
+
},
|
|
123
|
+
payload: DealLostPayload
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/events/task.event.ts
|
|
127
|
+
import { ScalarTypeEnum as ScalarTypeEnum3, defineSchemaModel as defineSchemaModel3 } from "@contractspec/lib.schema";
|
|
128
|
+
import { defineEvent as defineEvent3 } from "@contractspec/lib.contracts";
|
|
129
|
+
var TaskCompletedPayload = defineSchemaModel3({
|
|
130
|
+
name: "TaskCompletedPayload",
|
|
131
|
+
description: "Payload when a task is completed",
|
|
132
|
+
fields: {
|
|
133
|
+
taskId: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
134
|
+
type: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
135
|
+
assignedTo: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
136
|
+
completedBy: { type: ScalarTypeEnum3.String_unsecure(), isOptional: false },
|
|
137
|
+
completedAt: { type: ScalarTypeEnum3.DateTime(), isOptional: false }
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
var TaskCompletedEvent = defineEvent3({
|
|
141
|
+
meta: {
|
|
142
|
+
key: "task.completed",
|
|
143
|
+
version: "1.0.0",
|
|
144
|
+
description: "A task has been completed.",
|
|
145
|
+
stability: "stable",
|
|
146
|
+
owners: ["@crm-team"],
|
|
147
|
+
tags: ["task", "lifecycle"]
|
|
148
|
+
},
|
|
149
|
+
payload: TaskCompletedPayload
|
|
150
|
+
});
|
|
151
|
+
export {
|
|
152
|
+
TaskCompletedEvent,
|
|
153
|
+
DealWonEvent,
|
|
154
|
+
DealMovedEvent,
|
|
155
|
+
DealLostEvent,
|
|
156
|
+
DealCreatedEvent,
|
|
157
|
+
ContactCreatedEvent
|
|
158
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/events/task.event.ts
|
|
2
|
+
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
4
|
+
var TaskCompletedPayload = defineSchemaModel({
|
|
5
|
+
name: "TaskCompletedPayload",
|
|
6
|
+
description: "Payload when a task is completed",
|
|
7
|
+
fields: {
|
|
8
|
+
taskId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
9
|
+
type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
10
|
+
assignedTo: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
11
|
+
completedBy: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
12
|
+
completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var TaskCompletedEvent = defineEvent({
|
|
16
|
+
meta: {
|
|
17
|
+
key: "task.completed",
|
|
18
|
+
version: "1.0.0",
|
|
19
|
+
description: "A task has been completed.",
|
|
20
|
+
stability: "stable",
|
|
21
|
+
owners: ["@crm-team"],
|
|
22
|
+
tags: ["task", "lifecycle"]
|
|
23
|
+
},
|
|
24
|
+
payload: TaskCompletedPayload
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
TaskCompletedEvent
|
|
28
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/example.ts
|
|
2
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
3
|
+
var example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: "crm-pipeline",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
title: "CRM Pipeline",
|
|
8
|
+
description: "Sales CRM with contacts, companies, deals, pipelines, and tasks.",
|
|
9
|
+
kind: "template",
|
|
10
|
+
visibility: "public",
|
|
11
|
+
stability: "experimental",
|
|
12
|
+
owners: ["@platform.core"],
|
|
13
|
+
tags: ["crm", "sales", "pipeline", "deals"]
|
|
14
|
+
},
|
|
15
|
+
docs: {
|
|
16
|
+
rootDocId: "docs.examples.crm-pipeline"
|
|
17
|
+
},
|
|
18
|
+
entrypoints: {
|
|
19
|
+
packageName: "@contractspec/example.crm-pipeline",
|
|
20
|
+
feature: "./feature",
|
|
21
|
+
contracts: "./contracts",
|
|
22
|
+
presentations: "./presentations",
|
|
23
|
+
handlers: "./handlers",
|
|
24
|
+
docs: "./docs"
|
|
25
|
+
},
|
|
26
|
+
surfaces: {
|
|
27
|
+
templates: true,
|
|
28
|
+
sandbox: {
|
|
29
|
+
enabled: true,
|
|
30
|
+
modes: ["playground", "specs", "builder", "markdown", "evolution"]
|
|
31
|
+
},
|
|
32
|
+
studio: { enabled: true, installable: true },
|
|
33
|
+
mcp: { enabled: true }
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var example_default = example;
|
|
37
|
+
export {
|
|
38
|
+
example_default as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// src/handlers/crm.handlers.ts
|
|
2
|
+
import { web } from "@contractspec/lib.runtime-sandbox";
|
|
3
|
+
var { generateId } = web;
|
|
4
|
+
function rowToDeal(row) {
|
|
5
|
+
return {
|
|
6
|
+
id: row.id,
|
|
7
|
+
projectId: row.projectId,
|
|
8
|
+
name: row.name,
|
|
9
|
+
value: row.value,
|
|
10
|
+
currency: row.currency,
|
|
11
|
+
pipelineId: row.pipelineId,
|
|
12
|
+
stageId: row.stageId,
|
|
13
|
+
status: row.status,
|
|
14
|
+
contactId: row.contactId ?? undefined,
|
|
15
|
+
companyId: row.companyId ?? undefined,
|
|
16
|
+
ownerId: row.ownerId,
|
|
17
|
+
expectedCloseDate: row.expectedCloseDate ? new Date(row.expectedCloseDate) : undefined,
|
|
18
|
+
wonSource: row.wonSource ?? undefined,
|
|
19
|
+
lostReason: row.lostReason ?? undefined,
|
|
20
|
+
notes: row.notes ?? undefined,
|
|
21
|
+
createdAt: new Date(row.createdAt),
|
|
22
|
+
updatedAt: new Date(row.updatedAt)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createCrmHandlers(db) {
|
|
26
|
+
async function listDeals(input) {
|
|
27
|
+
const {
|
|
28
|
+
projectId,
|
|
29
|
+
pipelineId,
|
|
30
|
+
stageId,
|
|
31
|
+
status,
|
|
32
|
+
ownerId,
|
|
33
|
+
search,
|
|
34
|
+
limit = 20,
|
|
35
|
+
offset = 0
|
|
36
|
+
} = input;
|
|
37
|
+
let whereClause = "WHERE projectId = ?";
|
|
38
|
+
const params = [projectId];
|
|
39
|
+
if (pipelineId) {
|
|
40
|
+
whereClause += " AND pipelineId = ?";
|
|
41
|
+
params.push(pipelineId);
|
|
42
|
+
}
|
|
43
|
+
if (stageId) {
|
|
44
|
+
whereClause += " AND stageId = ?";
|
|
45
|
+
params.push(stageId);
|
|
46
|
+
}
|
|
47
|
+
if (status && status !== "all") {
|
|
48
|
+
whereClause += " AND status = ?";
|
|
49
|
+
params.push(status);
|
|
50
|
+
}
|
|
51
|
+
if (ownerId) {
|
|
52
|
+
whereClause += " AND ownerId = ?";
|
|
53
|
+
params.push(ownerId);
|
|
54
|
+
}
|
|
55
|
+
if (search) {
|
|
56
|
+
whereClause += " AND name LIKE ?";
|
|
57
|
+
params.push(`%${search}%`);
|
|
58
|
+
}
|
|
59
|
+
const countResult = (await db.query(`SELECT COUNT(*) as count FROM crm_deal ${whereClause}`, params)).rows;
|
|
60
|
+
const total = countResult[0]?.count ?? 0;
|
|
61
|
+
const valueResult = (await db.query(`SELECT COALESCE(SUM(value), 0) as total FROM crm_deal ${whereClause}`, params)).rows;
|
|
62
|
+
const totalValue = valueResult[0]?.total ?? 0;
|
|
63
|
+
const dealRows = (await db.query(`SELECT * FROM crm_deal ${whereClause} ORDER BY value DESC LIMIT ? OFFSET ?`, [...params, limit, offset])).rows;
|
|
64
|
+
return {
|
|
65
|
+
deals: dealRows.map(rowToDeal),
|
|
66
|
+
total,
|
|
67
|
+
totalValue
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function createDeal(input, context) {
|
|
71
|
+
const id = generateId("deal");
|
|
72
|
+
const now = new Date().toISOString();
|
|
73
|
+
await db.execute(`INSERT INTO crm_deal (id, projectId, pipelineId, stageId, name, value, currency, status, contactId, companyId, ownerId, expectedCloseDate, createdAt, updatedAt)
|
|
74
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
75
|
+
id,
|
|
76
|
+
context.projectId,
|
|
77
|
+
input.pipelineId,
|
|
78
|
+
input.stageId,
|
|
79
|
+
input.name,
|
|
80
|
+
input.value,
|
|
81
|
+
input.currency ?? "USD",
|
|
82
|
+
"OPEN",
|
|
83
|
+
input.contactId ?? null,
|
|
84
|
+
input.companyId ?? null,
|
|
85
|
+
context.ownerId,
|
|
86
|
+
input.expectedCloseDate?.toISOString() ?? null,
|
|
87
|
+
now,
|
|
88
|
+
now
|
|
89
|
+
]);
|
|
90
|
+
const rows = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [id])).rows;
|
|
91
|
+
if (!rows[0]) {
|
|
92
|
+
throw new Error("Failed to create deal");
|
|
93
|
+
}
|
|
94
|
+
return rowToDeal(rows[0]);
|
|
95
|
+
}
|
|
96
|
+
async function moveDeal(input) {
|
|
97
|
+
const now = new Date().toISOString();
|
|
98
|
+
const existing = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [input.dealId])).rows;
|
|
99
|
+
if (!existing[0]) {
|
|
100
|
+
throw new Error("NOT_FOUND");
|
|
101
|
+
}
|
|
102
|
+
const stage = (await db.query(`SELECT * FROM crm_stage WHERE id = ?`, [input.stageId])).rows;
|
|
103
|
+
if (!stage[0]) {
|
|
104
|
+
throw new Error("INVALID_STAGE");
|
|
105
|
+
}
|
|
106
|
+
await db.execute(`UPDATE crm_deal SET stageId = ?, updatedAt = ? WHERE id = ?`, [input.stageId, now, input.dealId]);
|
|
107
|
+
const rows = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [input.dealId])).rows;
|
|
108
|
+
return rowToDeal(rows[0]);
|
|
109
|
+
}
|
|
110
|
+
async function winDeal(input) {
|
|
111
|
+
const now = new Date().toISOString();
|
|
112
|
+
const existing = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [input.dealId])).rows;
|
|
113
|
+
if (!existing[0]) {
|
|
114
|
+
throw new Error("NOT_FOUND");
|
|
115
|
+
}
|
|
116
|
+
await db.execute(`UPDATE crm_deal SET status = 'WON', wonSource = ?, notes = ?, updatedAt = ? WHERE id = ?`, [input.wonSource ?? null, input.notes ?? null, now, input.dealId]);
|
|
117
|
+
const rows = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [input.dealId])).rows;
|
|
118
|
+
return rowToDeal(rows[0]);
|
|
119
|
+
}
|
|
120
|
+
async function loseDeal(input) {
|
|
121
|
+
const now = new Date().toISOString();
|
|
122
|
+
const existing = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [input.dealId])).rows;
|
|
123
|
+
if (!existing[0]) {
|
|
124
|
+
throw new Error("NOT_FOUND");
|
|
125
|
+
}
|
|
126
|
+
await db.execute(`UPDATE crm_deal SET status = 'LOST', lostReason = ?, notes = ?, updatedAt = ? WHERE id = ?`, [input.lostReason, input.notes ?? null, now, input.dealId]);
|
|
127
|
+
const rows = (await db.query(`SELECT * FROM crm_deal WHERE id = ?`, [input.dealId])).rows;
|
|
128
|
+
return rowToDeal(rows[0]);
|
|
129
|
+
}
|
|
130
|
+
async function getDealsByStage(input) {
|
|
131
|
+
const deals = (await db.query(`SELECT * FROM crm_deal WHERE projectId = ? AND pipelineId = ? AND status = 'OPEN' ORDER BY value DESC`, [input.projectId, input.pipelineId])).rows;
|
|
132
|
+
const stages = (await db.query(`SELECT * FROM crm_stage WHERE pipelineId = ? ORDER BY position`, [input.pipelineId])).rows;
|
|
133
|
+
const grouped = {};
|
|
134
|
+
for (const stage of stages) {
|
|
135
|
+
grouped[stage.id] = deals.filter((d) => d.stageId === stage.id).map(rowToDeal);
|
|
136
|
+
}
|
|
137
|
+
return grouped;
|
|
138
|
+
}
|
|
139
|
+
async function getPipelineStages(input) {
|
|
140
|
+
const rows = (await db.query(`SELECT * FROM crm_stage WHERE pipelineId = ? ORDER BY position`, [input.pipelineId])).rows;
|
|
141
|
+
return rows.map((row) => ({
|
|
142
|
+
id: row.id,
|
|
143
|
+
pipelineId: row.pipelineId,
|
|
144
|
+
name: row.name,
|
|
145
|
+
position: row.position
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
listDeals,
|
|
150
|
+
createDeal,
|
|
151
|
+
moveDeal,
|
|
152
|
+
winDeal,
|
|
153
|
+
loseDeal,
|
|
154
|
+
getDealsByStage,
|
|
155
|
+
getPipelineStages
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
createCrmHandlers
|
|
160
|
+
};
|