@happyvertical/smrt-sales 0.40.38 → 0.40.39

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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": "1.0.0",
3
- "timestamp": 1785455490864,
3
+ "timestamp": 1785462251168,
4
4
  "packageName": "@happyvertical/smrt-sales",
5
- "packageVersion": "0.40.38",
5
+ "packageVersion": "0.40.39",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-sales:AgreementExecutionCollection": {
8
8
  "name": "agreementexecutioncollection",
@@ -5444,94 +5444,222 @@
5444
5444
  "version": "aca82726"
5445
5445
  }
5446
5446
  },
5447
- "@happyvertical/smrt-sales:LeadCollection": {
5448
- "name": "leadcollection",
5449
- "className": "LeadCollection",
5450
- "qualifiedName": "@happyvertical/smrt-sales:LeadCollection",
5447
+ "@happyvertical/smrt-sales:Lead": {
5448
+ "name": "lead",
5449
+ "className": "Lead",
5450
+ "qualifiedName": "@happyvertical/smrt-sales:Lead",
5451
5451
  "collection": "leads",
5452
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/LeadCollection.ts",
5452
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/Lead.ts",
5453
5453
  "packageName": "@happyvertical/smrt-sales",
5454
- "fields": {},
5455
- "methods": {
5456
- "findByStatus": {
5457
- "name": "findByStatus",
5458
- "async": true,
5459
- "parameters": [
5460
- {
5461
- "name": "status",
5462
- "type": "LeadStatus",
5463
- "optional": false
5454
+ "fields": {
5455
+ "tenantId": {
5456
+ "type": "text",
5457
+ "required": false,
5458
+ "_meta": {
5459
+ "sqlType": "UUID",
5460
+ "nullable": true,
5461
+ "__tenancy": {
5462
+ "isTenantIdField": true,
5463
+ "autoFilter": true,
5464
+ "required": false,
5465
+ "autoPopulate": true,
5466
+ "nullable": true,
5467
+ "mode": "optional",
5468
+ "field": "tenantId",
5469
+ "allowSuperAdminBypass": false
5464
5470
  }
5465
- ],
5466
- "returnType": "Promise<Lead[]>",
5471
+ }
5472
+ },
5473
+ "name": {
5474
+ "type": "text",
5475
+ "required": true,
5476
+ "default": "",
5477
+ "_meta": {
5478
+ "required": true
5479
+ }
5480
+ },
5481
+ "contactName": {
5482
+ "type": "text",
5483
+ "required": false,
5484
+ "default": ""
5485
+ },
5486
+ "email": {
5487
+ "type": "text",
5488
+ "required": false,
5489
+ "default": ""
5490
+ },
5491
+ "phone": {
5492
+ "type": "text",
5493
+ "required": false,
5494
+ "default": ""
5495
+ },
5496
+ "organizationName": {
5497
+ "type": "text",
5498
+ "required": false,
5499
+ "default": ""
5500
+ },
5501
+ "profileId": {
5502
+ "type": "crossPackageRef",
5503
+ "required": false,
5504
+ "related": "@happyvertical/smrt-profiles:Profile"
5505
+ },
5506
+ "ownerRepId": {
5507
+ "type": "foreignKey",
5508
+ "required": false,
5509
+ "related": "SalesRepresentative"
5510
+ },
5511
+ "status": {
5512
+ "type": "text",
5513
+ "required": false,
5514
+ "default": "new"
5515
+ },
5516
+ "sourceKind": {
5517
+ "type": "text",
5518
+ "required": false,
5519
+ "default": ""
5520
+ },
5521
+ "sourceId": {
5522
+ "type": "text",
5523
+ "required": false,
5524
+ "default": ""
5525
+ },
5526
+ "acquisitionContext": {
5527
+ "type": "text",
5528
+ "required": false,
5529
+ "default": "{}"
5530
+ },
5531
+ "intakeRef": {
5532
+ "type": "text",
5533
+ "required": false,
5534
+ "default": ""
5535
+ },
5536
+ "mergedIntoId": {
5537
+ "type": "foreignKey",
5538
+ "required": false,
5539
+ "related": "Lead"
5540
+ },
5541
+ "qualifiedAt": {
5542
+ "type": "datetime",
5543
+ "required": false
5544
+ },
5545
+ "metadata": {
5546
+ "type": "text",
5547
+ "required": false,
5548
+ "default": "{}"
5549
+ }
5550
+ },
5551
+ "methods": {
5552
+ "isMerged": {
5553
+ "name": "isMerged",
5554
+ "async": false,
5555
+ "parameters": [],
5556
+ "returnType": "boolean",
5467
5557
  "isStatic": false,
5468
5558
  "isPublic": true
5469
5559
  },
5470
- "findByOwner": {
5471
- "name": "findByOwner",
5472
- "async": true,
5560
+ "isQualified": {
5561
+ "name": "isQualified",
5562
+ "async": false,
5563
+ "parameters": [],
5564
+ "returnType": "boolean",
5565
+ "isStatic": false,
5566
+ "isPublic": true
5567
+ },
5568
+ "getAcquisitionContext": {
5569
+ "name": "getAcquisitionContext",
5570
+ "async": false,
5571
+ "parameters": [],
5572
+ "returnType": "Record<string>",
5573
+ "isStatic": false,
5574
+ "isPublic": true
5575
+ },
5576
+ "setAcquisitionContext": {
5577
+ "name": "setAcquisitionContext",
5578
+ "async": false,
5473
5579
  "parameters": [
5474
5580
  {
5475
- "name": "ownerRepId",
5476
- "type": "string",
5581
+ "name": "context",
5582
+ "type": "Record<string>",
5477
5583
  "optional": false
5478
5584
  }
5479
5585
  ],
5480
- "returnType": "Promise<Lead[]>",
5586
+ "returnType": "void",
5481
5587
  "isStatic": false,
5482
5588
  "isPublic": true
5483
5589
  },
5484
- "qualify": {
5485
- "name": "qualify",
5486
- "async": true,
5590
+ "getMetadata": {
5591
+ "name": "getMetadata",
5592
+ "async": false,
5593
+ "parameters": [],
5594
+ "returnType": "Record<string>",
5595
+ "isStatic": false,
5596
+ "isPublic": true
5597
+ },
5598
+ "setMetadata": {
5599
+ "name": "setMetadata",
5600
+ "async": false,
5487
5601
  "parameters": [
5488
5602
  {
5489
- "name": "params",
5490
- "type": "QualifyLeadParams",
5603
+ "name": "metadata",
5604
+ "type": "Record<string>",
5491
5605
  "optional": false
5492
5606
  }
5493
5607
  ],
5494
- "returnType": "Promise<Opportunity>",
5608
+ "returnType": "void",
5495
5609
  "isStatic": false,
5496
5610
  "isPublic": true
5497
5611
  },
5498
- "mergeLeads": {
5499
- "name": "mergeLeads",
5612
+ "initialize": {
5613
+ "name": "initialize",
5500
5614
  "async": true,
5501
- "parameters": [
5502
- {
5503
- "name": "params",
5504
- "type": "MergeLeadsParams",
5505
- "optional": false
5506
- }
5507
- ],
5508
- "returnType": "Promise<MergeLeadsResult>",
5615
+ "parameters": [],
5616
+ "returnType": "Promise",
5509
5617
  "isStatic": false,
5510
5618
  "isPublic": true
5511
5619
  },
5512
- "activitiesIncludingMerged": {
5513
- "name": "activitiesIncludingMerged",
5620
+ "save": {
5621
+ "name": "save",
5514
5622
  "async": true,
5515
- "parameters": [
5516
- {
5517
- "name": "leadId",
5518
- "type": "string",
5519
- "optional": false
5520
- }
5521
- ],
5522
- "returnType": "Promise<SalesActivity[]>",
5623
+ "parameters": [],
5624
+ "returnType": "Promise",
5523
5625
  "isStatic": false,
5524
5626
  "isPublic": true
5525
5627
  }
5526
5628
  },
5527
- "decoratorConfig": {},
5528
- "extends": "SmrtCollection",
5529
- "extendsTypeArg": "Lead",
5530
- "exportName": "LeadCollection",
5531
- "collectionExportName": "LeadCollectionCollection",
5629
+ "decoratorConfig": {
5630
+ "api": {
5631
+ "include": [
5632
+ "list",
5633
+ "get",
5634
+ "create",
5635
+ "update"
5636
+ ]
5637
+ },
5638
+ "mcp": {
5639
+ "include": [
5640
+ "list",
5641
+ "get",
5642
+ "create"
5643
+ ]
5644
+ },
5645
+ "cli": true,
5646
+ "tenantScoped": {
5647
+ "mode": "optional"
5648
+ }
5649
+ },
5650
+ "extends": "SmrtObject",
5651
+ "exportName": "Lead",
5652
+ "collectionExportName": "LeadCollection",
5653
+ "validationRules": [
5654
+ {
5655
+ "field": "name",
5656
+ "rule": "required",
5657
+ "fieldType": "text"
5658
+ }
5659
+ ],
5532
5660
  "schema": {
5533
- "tableName": "lead_collections",
5534
- "ddl": "CREATE TABLE IF NOT EXISTS \"lead_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
5661
+ "tableName": "leads",
5662
+ "ddl": "CREATE TABLE IF NOT EXISTS \"leads\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT NOT NULL DEFAULT '',\n \"contact_name\" TEXT DEFAULT '',\n \"email\" TEXT DEFAULT '',\n \"phone\" TEXT DEFAULT '',\n \"organization_name\" TEXT DEFAULT '',\n \"profile_id\" UUID,\n \"owner_rep_id\" UUID,\n \"status\" TEXT DEFAULT 'new',\n \"source_kind\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"acquisition_context\" TEXT DEFAULT '{}',\n \"intake_ref\" TEXT DEFAULT '',\n \"merged_into_id\" UUID,\n \"qualified_at\" TIMESTAMP,\n \"metadata\" TEXT DEFAULT '{}'\n);",
5535
5663
  "columns": {
5536
5664
  "id": {
5537
5665
  "type": "UUID",
@@ -5557,87 +5685,603 @@
5557
5685
  "type": "TIMESTAMP",
5558
5686
  "notNull": true,
5559
5687
  "default": "current_timestamp"
5560
- }
5561
- },
5562
- "indexes": [
5563
- {
5564
- "name": "lead_collections_id_idx",
5565
- "columns": [
5566
- "id"
5567
- ]
5568
5688
  },
5569
- {
5570
- "name": "lead_collections_slug_context_idx",
5571
- "columns": [
5572
- "slug",
5573
- "context"
5574
- ],
5575
- "unique": true
5576
- }
5689
+ "tenant_id": {
5690
+ "type": "UUID",
5691
+ "referenceKind": "tenantId",
5692
+ "notNull": false,
5693
+ "unique": false
5694
+ },
5695
+ "name": {
5696
+ "type": "TEXT",
5697
+ "notNull": true,
5698
+ "unique": false,
5699
+ "default": ""
5700
+ },
5701
+ "contact_name": {
5702
+ "type": "TEXT",
5703
+ "notNull": false,
5704
+ "unique": false,
5705
+ "default": ""
5706
+ },
5707
+ "email": {
5708
+ "type": "TEXT",
5709
+ "notNull": false,
5710
+ "unique": false,
5711
+ "default": ""
5712
+ },
5713
+ "phone": {
5714
+ "type": "TEXT",
5715
+ "notNull": false,
5716
+ "unique": false,
5717
+ "default": ""
5718
+ },
5719
+ "organization_name": {
5720
+ "type": "TEXT",
5721
+ "notNull": false,
5722
+ "unique": false,
5723
+ "default": ""
5724
+ },
5725
+ "profile_id": {
5726
+ "type": "UUID",
5727
+ "referenceKind": "crossPackageRef",
5728
+ "notNull": false,
5729
+ "unique": false
5730
+ },
5731
+ "owner_rep_id": {
5732
+ "type": "UUID",
5733
+ "referenceKind": "foreignKey",
5734
+ "notNull": false,
5735
+ "unique": false
5736
+ },
5737
+ "status": {
5738
+ "type": "TEXT",
5739
+ "notNull": false,
5740
+ "unique": false,
5741
+ "default": "new"
5742
+ },
5743
+ "source_kind": {
5744
+ "type": "TEXT",
5745
+ "notNull": false,
5746
+ "unique": false,
5747
+ "default": ""
5748
+ },
5749
+ "source_id": {
5750
+ "type": "TEXT",
5751
+ "notNull": false,
5752
+ "unique": false,
5753
+ "default": ""
5754
+ },
5755
+ "acquisition_context": {
5756
+ "type": "TEXT",
5757
+ "notNull": false,
5758
+ "unique": false,
5759
+ "default": "{}"
5760
+ },
5761
+ "intake_ref": {
5762
+ "type": "TEXT",
5763
+ "notNull": false,
5764
+ "unique": false,
5765
+ "default": ""
5766
+ },
5767
+ "merged_into_id": {
5768
+ "type": "UUID",
5769
+ "referenceKind": "foreignKey",
5770
+ "notNull": false,
5771
+ "unique": false
5772
+ },
5773
+ "qualified_at": {
5774
+ "type": "TIMESTAMP",
5775
+ "notNull": false,
5776
+ "unique": false
5777
+ },
5778
+ "metadata": {
5779
+ "type": "TEXT",
5780
+ "notNull": false,
5781
+ "unique": false,
5782
+ "default": "{}"
5783
+ }
5784
+ },
5785
+ "indexes": [
5786
+ {
5787
+ "name": "leads_id_idx",
5788
+ "columns": [
5789
+ "id"
5790
+ ]
5791
+ },
5792
+ {
5793
+ "name": "leads_slug_context_idx",
5794
+ "columns": [
5795
+ "slug",
5796
+ "context"
5797
+ ],
5798
+ "unique": true
5799
+ }
5577
5800
  ],
5578
- "version": "0707eb13"
5801
+ "version": "a1c330c8"
5579
5802
  }
5580
5803
  },
5581
- "@happyvertical/smrt-sales:OpportunityCollection": {
5582
- "name": "opportunitycollection",
5583
- "className": "OpportunityCollection",
5584
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityCollection",
5804
+ "@happyvertical/smrt-sales:Opportunity": {
5805
+ "name": "opportunity",
5806
+ "className": "Opportunity",
5807
+ "qualifiedName": "@happyvertical/smrt-sales:Opportunity",
5585
5808
  "collection": "opportunities",
5586
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityCollection.ts",
5809
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/Opportunity.ts",
5587
5810
  "packageName": "@happyvertical/smrt-sales",
5588
- "fields": {},
5589
- "methods": {
5590
- "findByLead": {
5591
- "name": "findByLead",
5592
- "async": true,
5593
- "parameters": [
5594
- {
5595
- "name": "leadId",
5596
- "type": "string",
5597
- "optional": false
5811
+ "fields": {
5812
+ "tenantId": {
5813
+ "type": "text",
5814
+ "required": false,
5815
+ "_meta": {
5816
+ "sqlType": "UUID",
5817
+ "nullable": true,
5818
+ "__tenancy": {
5819
+ "isTenantIdField": true,
5820
+ "autoFilter": true,
5821
+ "required": false,
5822
+ "autoPopulate": true,
5823
+ "nullable": true,
5824
+ "mode": "optional",
5825
+ "field": "tenantId",
5826
+ "allowSuperAdminBypass": false
5598
5827
  }
5599
- ],
5600
- "returnType": "Promise<Opportunity[]>",
5828
+ }
5829
+ },
5830
+ "name": {
5831
+ "type": "text",
5832
+ "required": true,
5833
+ "default": "",
5834
+ "_meta": {
5835
+ "required": true
5836
+ }
5837
+ },
5838
+ "leadId": {
5839
+ "type": "foreignKey",
5840
+ "required": false,
5841
+ "related": "Lead"
5842
+ },
5843
+ "ownerRepId": {
5844
+ "type": "foreignKey",
5845
+ "required": false,
5846
+ "related": "SalesRepresentative"
5847
+ },
5848
+ "pipelineId": {
5849
+ "type": "foreignKey",
5850
+ "required": false,
5851
+ "related": "PipelineDefinition"
5852
+ },
5853
+ "stageId": {
5854
+ "type": "foreignKey",
5855
+ "required": false,
5856
+ "related": "PipelineStage"
5857
+ },
5858
+ "expectedValueCents": {
5859
+ "type": "integer",
5860
+ "required": false,
5861
+ "default": 0
5862
+ },
5863
+ "currency": {
5864
+ "type": "text",
5865
+ "required": false,
5866
+ "default": "USD"
5867
+ },
5868
+ "probability": {
5869
+ "type": "decimal",
5870
+ "required": false,
5871
+ "default": 0
5872
+ },
5873
+ "expectedCloseAt": {
5874
+ "type": "datetime",
5875
+ "required": false
5876
+ },
5877
+ "status": {
5878
+ "type": "text",
5879
+ "required": false,
5880
+ "default": "open"
5881
+ },
5882
+ "outcomeReason": {
5883
+ "type": "text",
5884
+ "required": false,
5885
+ "default": ""
5886
+ },
5887
+ "wonAt": {
5888
+ "type": "datetime",
5889
+ "required": false
5890
+ },
5891
+ "lostAt": {
5892
+ "type": "datetime",
5893
+ "required": false
5894
+ },
5895
+ "sourceKind": {
5896
+ "type": "text",
5897
+ "required": false,
5898
+ "default": ""
5899
+ },
5900
+ "sourceId": {
5901
+ "type": "text",
5902
+ "required": false,
5903
+ "default": ""
5904
+ },
5905
+ "metadata": {
5906
+ "type": "text",
5907
+ "required": false,
5908
+ "default": "{}"
5909
+ }
5910
+ },
5911
+ "methods": {
5912
+ "isOpen": {
5913
+ "name": "isOpen",
5914
+ "async": false,
5915
+ "parameters": [],
5916
+ "returnType": "boolean",
5601
5917
  "isStatic": false,
5602
5918
  "isPublic": true
5603
5919
  },
5604
- "findOpen": {
5605
- "name": "findOpen",
5606
- "async": true,
5607
- "parameters": [
5608
- {
5609
- "name": "pipelineId",
5610
- "type": "string",
5611
- "optional": true
5612
- }
5613
- ],
5614
- "returnType": "Promise<Opportunity[]>",
5920
+ "isClosed": {
5921
+ "name": "isClosed",
5922
+ "async": false,
5923
+ "parameters": [],
5924
+ "returnType": "boolean",
5925
+ "isStatic": false,
5926
+ "isPublic": true
5927
+ },
5928
+ "getMetadata": {
5929
+ "name": "getMetadata",
5930
+ "async": false,
5931
+ "parameters": [],
5932
+ "returnType": "Record<string>",
5933
+ "isStatic": false,
5934
+ "isPublic": true
5935
+ },
5936
+ "setMetadata": {
5937
+ "name": "setMetadata",
5938
+ "async": false,
5939
+ "parameters": [
5940
+ {
5941
+ "name": "metadata",
5942
+ "type": "Record<string>",
5943
+ "optional": false
5944
+ }
5945
+ ],
5946
+ "returnType": "void",
5947
+ "isStatic": false,
5948
+ "isPublic": true
5949
+ },
5950
+ "initialize": {
5951
+ "name": "initialize",
5952
+ "async": true,
5953
+ "parameters": [],
5954
+ "returnType": "Promise",
5955
+ "isStatic": false,
5956
+ "isPublic": true
5957
+ },
5958
+ "save": {
5959
+ "name": "save",
5960
+ "async": true,
5961
+ "parameters": [],
5962
+ "returnType": "Promise",
5963
+ "isStatic": false,
5964
+ "isPublic": true
5965
+ }
5966
+ },
5967
+ "decoratorConfig": {
5968
+ "api": {
5969
+ "include": [
5970
+ "list",
5971
+ "get",
5972
+ "create",
5973
+ "update"
5974
+ ]
5975
+ },
5976
+ "mcp": {
5977
+ "include": [
5978
+ "list",
5979
+ "get"
5980
+ ]
5981
+ },
5982
+ "cli": true,
5983
+ "tenantScoped": {
5984
+ "mode": "optional"
5985
+ }
5986
+ },
5987
+ "extends": "SmrtObject",
5988
+ "exportName": "Opportunity",
5989
+ "collectionExportName": "OpportunityCollection",
5990
+ "validationRules": [
5991
+ {
5992
+ "field": "name",
5993
+ "rule": "required",
5994
+ "fieldType": "text"
5995
+ }
5996
+ ],
5997
+ "schema": {
5998
+ "tableName": "opportunities",
5999
+ "ddl": "CREATE TABLE IF NOT EXISTS \"opportunities\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT NOT NULL DEFAULT '',\n \"lead_id\" UUID,\n \"owner_rep_id\" UUID,\n \"pipeline_id\" UUID,\n \"stage_id\" UUID,\n \"expected_value_cents\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"probability\" REAL DEFAULT 0,\n \"expected_close_at\" TIMESTAMP,\n \"status\" TEXT DEFAULT 'open',\n \"outcome_reason\" TEXT DEFAULT '',\n \"won_at\" TIMESTAMP,\n \"lost_at\" TIMESTAMP,\n \"source_kind\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
6000
+ "columns": {
6001
+ "id": {
6002
+ "type": "UUID",
6003
+ "primaryKey": true,
6004
+ "referenceKind": "id",
6005
+ "notNull": true
6006
+ },
6007
+ "slug": {
6008
+ "type": "TEXT",
6009
+ "notNull": true
6010
+ },
6011
+ "context": {
6012
+ "type": "TEXT",
6013
+ "notNull": true,
6014
+ "default": ""
6015
+ },
6016
+ "created_at": {
6017
+ "type": "TIMESTAMP",
6018
+ "notNull": true,
6019
+ "default": "current_timestamp"
6020
+ },
6021
+ "updated_at": {
6022
+ "type": "TIMESTAMP",
6023
+ "notNull": true,
6024
+ "default": "current_timestamp"
6025
+ },
6026
+ "tenant_id": {
6027
+ "type": "UUID",
6028
+ "referenceKind": "tenantId",
6029
+ "notNull": false,
6030
+ "unique": false
6031
+ },
6032
+ "name": {
6033
+ "type": "TEXT",
6034
+ "notNull": true,
6035
+ "unique": false,
6036
+ "default": ""
6037
+ },
6038
+ "lead_id": {
6039
+ "type": "UUID",
6040
+ "referenceKind": "foreignKey",
6041
+ "notNull": false,
6042
+ "unique": false
6043
+ },
6044
+ "owner_rep_id": {
6045
+ "type": "UUID",
6046
+ "referenceKind": "foreignKey",
6047
+ "notNull": false,
6048
+ "unique": false
6049
+ },
6050
+ "pipeline_id": {
6051
+ "type": "UUID",
6052
+ "referenceKind": "foreignKey",
6053
+ "notNull": false,
6054
+ "unique": false
6055
+ },
6056
+ "stage_id": {
6057
+ "type": "UUID",
6058
+ "referenceKind": "foreignKey",
6059
+ "notNull": false,
6060
+ "unique": false
6061
+ },
6062
+ "expected_value_cents": {
6063
+ "type": "INTEGER",
6064
+ "notNull": false,
6065
+ "unique": false,
6066
+ "default": 0
6067
+ },
6068
+ "currency": {
6069
+ "type": "TEXT",
6070
+ "notNull": false,
6071
+ "unique": false,
6072
+ "default": "USD"
6073
+ },
6074
+ "probability": {
6075
+ "type": "REAL",
6076
+ "notNull": false,
6077
+ "unique": false,
6078
+ "default": 0
6079
+ },
6080
+ "expected_close_at": {
6081
+ "type": "TIMESTAMP",
6082
+ "notNull": false,
6083
+ "unique": false
6084
+ },
6085
+ "status": {
6086
+ "type": "TEXT",
6087
+ "notNull": false,
6088
+ "unique": false,
6089
+ "default": "open"
6090
+ },
6091
+ "outcome_reason": {
6092
+ "type": "TEXT",
6093
+ "notNull": false,
6094
+ "unique": false,
6095
+ "default": ""
6096
+ },
6097
+ "won_at": {
6098
+ "type": "TIMESTAMP",
6099
+ "notNull": false,
6100
+ "unique": false
6101
+ },
6102
+ "lost_at": {
6103
+ "type": "TIMESTAMP",
6104
+ "notNull": false,
6105
+ "unique": false
6106
+ },
6107
+ "source_kind": {
6108
+ "type": "TEXT",
6109
+ "notNull": false,
6110
+ "unique": false,
6111
+ "default": ""
6112
+ },
6113
+ "source_id": {
6114
+ "type": "TEXT",
6115
+ "notNull": false,
6116
+ "unique": false,
6117
+ "default": ""
6118
+ },
6119
+ "metadata": {
6120
+ "type": "TEXT",
6121
+ "notNull": false,
6122
+ "unique": false,
6123
+ "default": "{}"
6124
+ }
6125
+ },
6126
+ "indexes": [
6127
+ {
6128
+ "name": "opportunities_id_idx",
6129
+ "columns": [
6130
+ "id"
6131
+ ]
6132
+ },
6133
+ {
6134
+ "name": "opportunities_slug_context_idx",
6135
+ "columns": [
6136
+ "slug",
6137
+ "context"
6138
+ ],
6139
+ "unique": true
6140
+ }
6141
+ ],
6142
+ "version": "a403c6cf"
6143
+ }
6144
+ },
6145
+ "@happyvertical/smrt-sales:OpportunityConversion": {
6146
+ "name": "opportunityconversion",
6147
+ "className": "OpportunityConversion",
6148
+ "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversion",
6149
+ "collection": "opportunityconversions",
6150
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/OpportunityConversion.ts",
6151
+ "packageName": "@happyvertical/smrt-sales",
6152
+ "fields": {
6153
+ "tenantId": {
6154
+ "type": "text",
6155
+ "required": false,
6156
+ "_meta": {
6157
+ "sqlType": "UUID",
6158
+ "nullable": true,
6159
+ "__tenancy": {
6160
+ "isTenantIdField": true,
6161
+ "autoFilter": true,
6162
+ "required": false,
6163
+ "autoPopulate": true,
6164
+ "nullable": true,
6165
+ "mode": "optional",
6166
+ "field": "tenantId",
6167
+ "allowSuperAdminBypass": false
6168
+ }
6169
+ }
6170
+ },
6171
+ "opportunityId": {
6172
+ "type": "foreignKey",
6173
+ "required": true,
6174
+ "related": "Opportunity",
6175
+ "_meta": {
6176
+ "required": true
6177
+ }
6178
+ },
6179
+ "targetKind": {
6180
+ "type": "text",
6181
+ "required": true,
6182
+ "default": "",
6183
+ "_meta": {
6184
+ "required": true
6185
+ }
6186
+ },
6187
+ "targetId": {
6188
+ "type": "text",
6189
+ "required": true,
6190
+ "default": "",
6191
+ "_meta": {
6192
+ "required": true
6193
+ }
6194
+ },
6195
+ "note": {
6196
+ "type": "text",
6197
+ "required": false,
6198
+ "default": ""
6199
+ },
6200
+ "metadata": {
6201
+ "type": "text",
6202
+ "required": false,
6203
+ "default": "{}"
6204
+ }
6205
+ },
6206
+ "methods": {
6207
+ "getMetadata": {
6208
+ "name": "getMetadata",
6209
+ "async": false,
6210
+ "parameters": [],
6211
+ "returnType": "Record<string>",
5615
6212
  "isStatic": false,
5616
6213
  "isPublic": true
5617
6214
  },
5618
- "moveToStage": {
5619
- "name": "moveToStage",
5620
- "async": true,
6215
+ "setMetadata": {
6216
+ "name": "setMetadata",
6217
+ "async": false,
5621
6218
  "parameters": [
5622
6219
  {
5623
- "name": "params",
5624
- "type": "MoveToStageParams",
6220
+ "name": "metadata",
6221
+ "type": "Record<string>",
5625
6222
  "optional": false
5626
6223
  }
5627
6224
  ],
5628
- "returnType": "Promise<Opportunity>",
6225
+ "returnType": "void",
6226
+ "isStatic": false,
6227
+ "isPublic": true
6228
+ },
6229
+ "save": {
6230
+ "name": "save",
6231
+ "async": true,
6232
+ "parameters": [],
6233
+ "returnType": "Promise",
5629
6234
  "isStatic": false,
5630
6235
  "isPublic": true
5631
6236
  }
5632
6237
  },
5633
- "decoratorConfig": {},
5634
- "extends": "SmrtCollection",
5635
- "extendsTypeArg": "Opportunity",
5636
- "exportName": "OpportunityCollection",
5637
- "collectionExportName": "OpportunityCollectionCollection",
6238
+ "decoratorConfig": {
6239
+ "api": {
6240
+ "include": [
6241
+ "list",
6242
+ "get",
6243
+ "create"
6244
+ ]
6245
+ },
6246
+ "mcp": {
6247
+ "include": [
6248
+ "list",
6249
+ "get"
6250
+ ]
6251
+ },
6252
+ "cli": false,
6253
+ "conflictColumns": [
6254
+ "opportunity_id",
6255
+ "target_kind",
6256
+ "target_id"
6257
+ ],
6258
+ "tenantScoped": {
6259
+ "mode": "optional"
6260
+ }
6261
+ },
6262
+ "extends": "SmrtObject",
6263
+ "exportName": "OpportunityConversion",
6264
+ "collectionExportName": "OpportunityConversionCollection",
6265
+ "validationRules": [
6266
+ {
6267
+ "field": "opportunityId",
6268
+ "rule": "required",
6269
+ "fieldType": "foreignKey"
6270
+ },
6271
+ {
6272
+ "field": "targetKind",
6273
+ "rule": "required",
6274
+ "fieldType": "text"
6275
+ },
6276
+ {
6277
+ "field": "targetId",
6278
+ "rule": "required",
6279
+ "fieldType": "text"
6280
+ }
6281
+ ],
5638
6282
  "schema": {
5639
- "tableName": "opportunity_collections",
5640
- "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6283
+ "tableName": "opportunity_conversions",
6284
+ "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_conversions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"opportunity_id\" UUID NOT NULL,\n \"target_kind\" TEXT NOT NULL DEFAULT '',\n \"target_id\" TEXT NOT NULL DEFAULT '',\n \"note\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
5641
6285
  "columns": {
5642
6286
  "id": {
5643
6287
  "type": "UUID",
@@ -5663,187 +6307,188 @@
5663
6307
  "type": "TIMESTAMP",
5664
6308
  "notNull": true,
5665
6309
  "default": "current_timestamp"
5666
- }
5667
- },
5668
- "indexes": [
5669
- {
5670
- "name": "opportunity_collections_id_idx",
5671
- "columns": [
5672
- "id"
5673
- ]
5674
6310
  },
5675
- {
5676
- "name": "opportunity_collections_slug_context_idx",
5677
- "columns": [
5678
- "slug",
5679
- "context"
5680
- ],
5681
- "unique": true
5682
- }
5683
- ],
5684
- "version": "ebcdf63b"
5685
- }
5686
- },
5687
- "@happyvertical/smrt-sales:OpportunityConversionCollection": {
5688
- "name": "opportunityconversioncollection",
5689
- "className": "OpportunityConversionCollection",
5690
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversionCollection",
5691
- "collection": "opportunityconversions",
5692
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityConversionCollection.ts",
5693
- "packageName": "@happyvertical/smrt-sales",
5694
- "fields": {},
5695
- "methods": {
5696
- "findByOpportunity": {
5697
- "name": "findByOpportunity",
5698
- "async": true,
5699
- "parameters": [
5700
- {
5701
- "name": "opportunityId",
5702
- "type": "string",
5703
- "optional": false
5704
- }
5705
- ],
5706
- "returnType": "Promise<OpportunityConversion[]>",
5707
- "isStatic": false,
5708
- "isPublic": true
5709
- },
5710
- "recordConversion": {
5711
- "name": "recordConversion",
5712
- "async": true,
5713
- "parameters": [
5714
- {
5715
- "name": "params",
5716
- "type": "RecordConversionParams",
5717
- "optional": false
5718
- }
5719
- ],
5720
- "returnType": "Promise<RecordConversionResult>",
5721
- "isStatic": false,
5722
- "isPublic": true
5723
- }
5724
- },
5725
- "decoratorConfig": {},
5726
- "extends": "SmrtCollection",
5727
- "extendsTypeArg": "OpportunityConversion",
5728
- "exportName": "OpportunityConversionCollection",
5729
- "collectionExportName": "OpportunityConversionCollectionCollection",
5730
- "schema": {
5731
- "tableName": "opportunity_conversion_collections",
5732
- "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_conversion_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
5733
- "columns": {
5734
- "id": {
6311
+ "tenant_id": {
5735
6312
  "type": "UUID",
5736
- "primaryKey": true,
5737
- "referenceKind": "id",
5738
- "notNull": true
6313
+ "referenceKind": "tenantId",
6314
+ "notNull": false,
6315
+ "unique": false
5739
6316
  },
5740
- "slug": {
5741
- "type": "TEXT",
5742
- "notNull": true
6317
+ "opportunity_id": {
6318
+ "type": "UUID",
6319
+ "referenceKind": "foreignKey",
6320
+ "notNull": true,
6321
+ "unique": false
5743
6322
  },
5744
- "context": {
6323
+ "target_kind": {
5745
6324
  "type": "TEXT",
5746
6325
  "notNull": true,
6326
+ "unique": false,
5747
6327
  "default": ""
5748
6328
  },
5749
- "created_at": {
5750
- "type": "TIMESTAMP",
6329
+ "target_id": {
6330
+ "type": "TEXT",
5751
6331
  "notNull": true,
5752
- "default": "current_timestamp"
6332
+ "unique": false,
6333
+ "default": ""
5753
6334
  },
5754
- "updated_at": {
5755
- "type": "TIMESTAMP",
5756
- "notNull": true,
5757
- "default": "current_timestamp"
6335
+ "note": {
6336
+ "type": "TEXT",
6337
+ "notNull": false,
6338
+ "unique": false,
6339
+ "default": ""
6340
+ },
6341
+ "metadata": {
6342
+ "type": "TEXT",
6343
+ "notNull": false,
6344
+ "unique": false,
6345
+ "default": "{}"
5758
6346
  }
5759
6347
  },
5760
6348
  "indexes": [
5761
6349
  {
5762
- "name": "opportunity_conversion_collections_id_idx",
6350
+ "name": "opportunity_conversions_id_idx",
5763
6351
  "columns": [
5764
6352
  "id"
5765
6353
  ]
5766
6354
  },
5767
6355
  {
5768
- "name": "opportunity_conversion_collections_slug_context_idx",
6356
+ "name": "opportunity_conversions_opportunity_id_target_kind_idx",
5769
6357
  "columns": [
5770
- "slug",
5771
- "context"
6358
+ "opportunity_id",
6359
+ "target_kind",
6360
+ "target_id"
5772
6361
  ],
5773
6362
  "unique": true
5774
6363
  }
5775
6364
  ],
5776
- "version": "7e30ff1b"
6365
+ "version": "82c29042"
5777
6366
  }
5778
6367
  },
5779
- "@happyvertical/smrt-sales:PipelineDefinitionCollection": {
5780
- "name": "pipelinedefinitioncollection",
5781
- "className": "PipelineDefinitionCollection",
5782
- "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
6368
+ "@happyvertical/smrt-sales:PipelineDefinition": {
6369
+ "name": "pipelinedefinition",
6370
+ "className": "PipelineDefinition",
6371
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
5783
6372
  "collection": "pipelinedefinitions",
5784
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineDefinitionCollection.ts",
6373
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineDefinition.ts",
5785
6374
  "packageName": "@happyvertical/smrt-sales",
5786
- "fields": {},
5787
- "methods": {
5788
- "findByKey": {
5789
- "name": "findByKey",
5790
- "async": true,
5791
- "parameters": [
5792
- {
5793
- "name": "key",
5794
- "type": "string",
5795
- "optional": false
6375
+ "fields": {
6376
+ "tenantId": {
6377
+ "type": "text",
6378
+ "required": false,
6379
+ "_meta": {
6380
+ "sqlType": "UUID",
6381
+ "nullable": true,
6382
+ "__tenancy": {
6383
+ "isTenantIdField": true,
6384
+ "autoFilter": true,
6385
+ "required": false,
6386
+ "autoPopulate": true,
6387
+ "nullable": true,
6388
+ "mode": "optional",
6389
+ "field": "tenantId",
6390
+ "allowSuperAdminBypass": false
5796
6391
  }
5797
- ],
5798
- "returnType": "Promise<PipelineDefinition | null>",
6392
+ }
6393
+ },
6394
+ "key": {
6395
+ "type": "text",
6396
+ "required": true,
6397
+ "default": "",
6398
+ "_meta": {
6399
+ "required": true
6400
+ }
6401
+ },
6402
+ "name": {
6403
+ "type": "text",
6404
+ "required": false,
6405
+ "default": ""
6406
+ },
6407
+ "isDefault": {
6408
+ "type": "boolean",
6409
+ "required": false,
6410
+ "default": false
6411
+ },
6412
+ "status": {
6413
+ "type": "text",
6414
+ "required": false,
6415
+ "default": "active"
6416
+ },
6417
+ "metadata": {
6418
+ "type": "text",
6419
+ "required": false,
6420
+ "default": "{}"
6421
+ }
6422
+ },
6423
+ "methods": {
6424
+ "isActive": {
6425
+ "name": "isActive",
6426
+ "async": false,
6427
+ "parameters": [],
6428
+ "returnType": "boolean",
5799
6429
  "isStatic": false,
5800
6430
  "isPublic": true
5801
6431
  },
5802
- "findDefault": {
5803
- "name": "findDefault",
5804
- "async": true,
6432
+ "getMetadata": {
6433
+ "name": "getMetadata",
6434
+ "async": false,
5805
6435
  "parameters": [],
5806
- "returnType": "Promise<PipelineDefinition | null>",
6436
+ "returnType": "Record<string>",
5807
6437
  "isStatic": false,
5808
6438
  "isPublic": true
5809
6439
  },
5810
- "getStages": {
5811
- "name": "getStages",
5812
- "async": true,
6440
+ "setMetadata": {
6441
+ "name": "setMetadata",
6442
+ "async": false,
5813
6443
  "parameters": [
5814
6444
  {
5815
- "name": "pipelineId",
5816
- "type": "string",
6445
+ "name": "metadata",
6446
+ "type": "Record<string>",
5817
6447
  "optional": false
5818
6448
  }
5819
6449
  ],
5820
- "returnType": "Promise<PipelineStage[]>",
6450
+ "returnType": "void",
5821
6451
  "isStatic": false,
5822
6452
  "isPublic": true
6453
+ }
6454
+ },
6455
+ "decoratorConfig": {
6456
+ "api": {
6457
+ "include": [
6458
+ "list",
6459
+ "get",
6460
+ "create",
6461
+ "update"
6462
+ ]
5823
6463
  },
5824
- "ensureDefaultPipeline": {
5825
- "name": "ensureDefaultPipeline",
5826
- "async": true,
5827
- "parameters": [
5828
- {
5829
- "name": "params",
5830
- "type": "EnsureDefaultPipelineParams",
5831
- "optional": true
5832
- }
5833
- ],
5834
- "returnType": "Promise<EnsureDefaultPipelineResult>",
5835
- "isStatic": false,
5836
- "isPublic": true
6464
+ "mcp": {
6465
+ "include": [
6466
+ "list",
6467
+ "get"
6468
+ ]
6469
+ },
6470
+ "cli": true,
6471
+ "conflictColumns": [
6472
+ "tenant_id",
6473
+ "key"
6474
+ ],
6475
+ "tenantScoped": {
6476
+ "mode": "optional"
5837
6477
  }
5838
6478
  },
5839
- "decoratorConfig": {},
5840
- "extends": "SmrtCollection",
5841
- "extendsTypeArg": "PipelineDefinition",
5842
- "exportName": "PipelineDefinitionCollection",
5843
- "collectionExportName": "PipelineDefinitionCollectionCollection",
6479
+ "extends": "SmrtObject",
6480
+ "exportName": "PipelineDefinition",
6481
+ "collectionExportName": "PipelineDefinitionCollection",
6482
+ "validationRules": [
6483
+ {
6484
+ "field": "key",
6485
+ "rule": "required",
6486
+ "fieldType": "text"
6487
+ }
6488
+ ],
5844
6489
  "schema": {
5845
- "tableName": "pipeline_definition_collections",
5846
- "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_definition_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6490
+ "tableName": "pipeline_definitions",
6491
+ "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_definitions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"key\" TEXT NOT NULL DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"is_default\" BOOLEAN DEFAULT FALSE,\n \"status\" TEXT DEFAULT 'active',\n \"metadata\" TEXT DEFAULT '{}'\n);",
5847
6492
  "columns": {
5848
6493
  "id": {
5849
6494
  "type": "UUID",
@@ -5869,78 +6514,210 @@
5869
6514
  "type": "TIMESTAMP",
5870
6515
  "notNull": true,
5871
6516
  "default": "current_timestamp"
6517
+ },
6518
+ "tenant_id": {
6519
+ "type": "UUID",
6520
+ "referenceKind": "tenantId",
6521
+ "notNull": false,
6522
+ "unique": false
6523
+ },
6524
+ "key": {
6525
+ "type": "TEXT",
6526
+ "notNull": true,
6527
+ "unique": false,
6528
+ "default": ""
6529
+ },
6530
+ "name": {
6531
+ "type": "TEXT",
6532
+ "notNull": false,
6533
+ "unique": false,
6534
+ "default": ""
6535
+ },
6536
+ "is_default": {
6537
+ "type": "BOOLEAN",
6538
+ "notNull": false,
6539
+ "unique": false,
6540
+ "default": false
6541
+ },
6542
+ "status": {
6543
+ "type": "TEXT",
6544
+ "notNull": false,
6545
+ "unique": false,
6546
+ "default": "active"
6547
+ },
6548
+ "metadata": {
6549
+ "type": "TEXT",
6550
+ "notNull": false,
6551
+ "unique": false,
6552
+ "default": "{}"
5872
6553
  }
5873
6554
  },
5874
6555
  "indexes": [
5875
6556
  {
5876
- "name": "pipeline_definition_collections_id_idx",
6557
+ "name": "pipeline_definitions_id_idx",
5877
6558
  "columns": [
5878
6559
  "id"
5879
6560
  ]
5880
6561
  },
5881
6562
  {
5882
- "name": "pipeline_definition_collections_slug_context_idx",
6563
+ "name": "pipeline_definitions_tenant_id_key_idx",
5883
6564
  "columns": [
5884
- "slug",
5885
- "context"
6565
+ "tenant_id",
6566
+ "key"
5886
6567
  ],
5887
6568
  "unique": true
5888
6569
  }
5889
6570
  ],
5890
- "version": "f85d1436"
6571
+ "version": "5e3ace6c"
5891
6572
  }
5892
6573
  },
5893
- "@happyvertical/smrt-sales:PipelineStageCollection": {
5894
- "name": "pipelinestagecollection",
5895
- "className": "PipelineStageCollection",
5896
- "qualifiedName": "@happyvertical/smrt-sales:PipelineStageCollection",
6574
+ "@happyvertical/smrt-sales:PipelineStage": {
6575
+ "name": "pipelinestage",
6576
+ "className": "PipelineStage",
6577
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineStage",
5897
6578
  "collection": "pipelinestages",
5898
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineStageCollection.ts",
6579
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineStage.ts",
5899
6580
  "packageName": "@happyvertical/smrt-sales",
5900
- "fields": {},
5901
- "methods": {
5902
- "findByPipeline": {
5903
- "name": "findByPipeline",
5904
- "async": true,
5905
- "parameters": [
5906
- {
5907
- "name": "pipelineId",
5908
- "type": "string",
5909
- "optional": false
6581
+ "fields": {
6582
+ "tenantId": {
6583
+ "type": "text",
6584
+ "required": false,
6585
+ "_meta": {
6586
+ "sqlType": "UUID",
6587
+ "nullable": true,
6588
+ "__tenancy": {
6589
+ "isTenantIdField": true,
6590
+ "autoFilter": true,
6591
+ "required": false,
6592
+ "autoPopulate": true,
6593
+ "nullable": true,
6594
+ "mode": "optional",
6595
+ "field": "tenantId",
6596
+ "allowSuperAdminBypass": false
5910
6597
  }
5911
- ],
5912
- "returnType": "Promise<PipelineStage[]>",
6598
+ }
6599
+ },
6600
+ "pipelineId": {
6601
+ "type": "foreignKey",
6602
+ "required": true,
6603
+ "related": "PipelineDefinition",
6604
+ "_meta": {
6605
+ "required": true
6606
+ }
6607
+ },
6608
+ "key": {
6609
+ "type": "text",
6610
+ "required": true,
6611
+ "default": "",
6612
+ "_meta": {
6613
+ "required": true
6614
+ }
6615
+ },
6616
+ "name": {
6617
+ "type": "text",
6618
+ "required": false,
6619
+ "default": ""
6620
+ },
6621
+ "sortOrder": {
6622
+ "type": "integer",
6623
+ "required": false,
6624
+ "default": 0
6625
+ },
6626
+ "probability": {
6627
+ "type": "decimal",
6628
+ "required": false,
6629
+ "default": 0
6630
+ },
6631
+ "isWon": {
6632
+ "type": "boolean",
6633
+ "required": false,
6634
+ "default": false
6635
+ },
6636
+ "isLost": {
6637
+ "type": "boolean",
6638
+ "required": false,
6639
+ "default": false
6640
+ },
6641
+ "metadata": {
6642
+ "type": "text",
6643
+ "required": false,
6644
+ "default": "{}"
6645
+ }
6646
+ },
6647
+ "methods": {
6648
+ "isTerminal": {
6649
+ "name": "isTerminal",
6650
+ "async": false,
6651
+ "parameters": [],
6652
+ "returnType": "boolean",
5913
6653
  "isStatic": false,
5914
6654
  "isPublic": true
5915
6655
  },
5916
- "findByKey": {
5917
- "name": "findByKey",
5918
- "async": true,
6656
+ "getMetadata": {
6657
+ "name": "getMetadata",
6658
+ "async": false,
6659
+ "parameters": [],
6660
+ "returnType": "Record<string>",
6661
+ "isStatic": false,
6662
+ "isPublic": true
6663
+ },
6664
+ "setMetadata": {
6665
+ "name": "setMetadata",
6666
+ "async": false,
5919
6667
  "parameters": [
5920
6668
  {
5921
- "name": "pipelineId",
5922
- "type": "string",
5923
- "optional": false
5924
- },
5925
- {
5926
- "name": "key",
5927
- "type": "string",
6669
+ "name": "metadata",
6670
+ "type": "Record<string>",
5928
6671
  "optional": false
5929
6672
  }
5930
6673
  ],
5931
- "returnType": "Promise<PipelineStage | null>",
6674
+ "returnType": "void",
5932
6675
  "isStatic": false,
5933
6676
  "isPublic": true
5934
6677
  }
5935
6678
  },
5936
- "decoratorConfig": {},
5937
- "extends": "SmrtCollection",
5938
- "extendsTypeArg": "PipelineStage",
5939
- "exportName": "PipelineStageCollection",
5940
- "collectionExportName": "PipelineStageCollectionCollection",
6679
+ "decoratorConfig": {
6680
+ "api": {
6681
+ "include": [
6682
+ "list",
6683
+ "get",
6684
+ "create",
6685
+ "update"
6686
+ ]
6687
+ },
6688
+ "mcp": {
6689
+ "include": [
6690
+ "list",
6691
+ "get"
6692
+ ]
6693
+ },
6694
+ "cli": false,
6695
+ "conflictColumns": [
6696
+ "pipeline_id",
6697
+ "key"
6698
+ ],
6699
+ "tenantScoped": {
6700
+ "mode": "optional"
6701
+ }
6702
+ },
6703
+ "extends": "SmrtObject",
6704
+ "exportName": "PipelineStage",
6705
+ "collectionExportName": "PipelineStageCollection",
6706
+ "validationRules": [
6707
+ {
6708
+ "field": "pipelineId",
6709
+ "rule": "required",
6710
+ "fieldType": "foreignKey"
6711
+ },
6712
+ {
6713
+ "field": "key",
6714
+ "rule": "required",
6715
+ "fieldType": "text"
6716
+ }
6717
+ ],
5941
6718
  "schema": {
5942
- "tableName": "pipeline_stage_collections",
5943
- "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_stage_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6719
+ "tableName": "pipeline_stages",
6720
+ "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_stages\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"pipeline_id\" UUID NOT NULL,\n \"key\" TEXT NOT NULL DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"sort_order\" INTEGER DEFAULT 0,\n \"probability\" REAL DEFAULT 0,\n \"is_won\" BOOLEAN DEFAULT FALSE,\n \"is_lost\" BOOLEAN DEFAULT FALSE,\n \"metadata\" TEXT DEFAULT '{}'\n);",
5944
6721
  "columns": {
5945
6722
  "id": {
5946
6723
  "type": "UUID",
@@ -5966,83 +6743,213 @@
5966
6743
  "type": "TIMESTAMP",
5967
6744
  "notNull": true,
5968
6745
  "default": "current_timestamp"
6746
+ },
6747
+ "tenant_id": {
6748
+ "type": "UUID",
6749
+ "referenceKind": "tenantId",
6750
+ "notNull": false,
6751
+ "unique": false
6752
+ },
6753
+ "pipeline_id": {
6754
+ "type": "UUID",
6755
+ "referenceKind": "foreignKey",
6756
+ "notNull": true,
6757
+ "unique": false
6758
+ },
6759
+ "key": {
6760
+ "type": "TEXT",
6761
+ "notNull": true,
6762
+ "unique": false,
6763
+ "default": ""
6764
+ },
6765
+ "name": {
6766
+ "type": "TEXT",
6767
+ "notNull": false,
6768
+ "unique": false,
6769
+ "default": ""
6770
+ },
6771
+ "sort_order": {
6772
+ "type": "INTEGER",
6773
+ "notNull": false,
6774
+ "unique": false,
6775
+ "default": 0
6776
+ },
6777
+ "probability": {
6778
+ "type": "REAL",
6779
+ "notNull": false,
6780
+ "unique": false,
6781
+ "default": 0
6782
+ },
6783
+ "is_won": {
6784
+ "type": "BOOLEAN",
6785
+ "notNull": false,
6786
+ "unique": false,
6787
+ "default": false
6788
+ },
6789
+ "is_lost": {
6790
+ "type": "BOOLEAN",
6791
+ "notNull": false,
6792
+ "unique": false,
6793
+ "default": false
6794
+ },
6795
+ "metadata": {
6796
+ "type": "TEXT",
6797
+ "notNull": false,
6798
+ "unique": false,
6799
+ "default": "{}"
5969
6800
  }
5970
6801
  },
5971
6802
  "indexes": [
5972
6803
  {
5973
- "name": "pipeline_stage_collections_id_idx",
6804
+ "name": "pipeline_stages_id_idx",
5974
6805
  "columns": [
5975
6806
  "id"
5976
6807
  ]
5977
6808
  },
5978
6809
  {
5979
- "name": "pipeline_stage_collections_slug_context_idx",
6810
+ "name": "pipeline_stages_pipeline_id_key_idx",
5980
6811
  "columns": [
5981
- "slug",
5982
- "context"
6812
+ "pipeline_id",
6813
+ "key"
5983
6814
  ],
5984
6815
  "unique": true
5985
6816
  }
5986
6817
  ],
5987
- "version": "72c2d7b3"
6818
+ "version": "bdb0cf4e"
5988
6819
  }
5989
6820
  },
5990
- "@happyvertical/smrt-sales:SalesActivityCollection": {
5991
- "name": "salesactivitycollection",
5992
- "className": "SalesActivityCollection",
5993
- "qualifiedName": "@happyvertical/smrt-sales:SalesActivityCollection",
6821
+ "@happyvertical/smrt-sales:SalesActivity": {
6822
+ "name": "salesactivity",
6823
+ "className": "SalesActivity",
6824
+ "qualifiedName": "@happyvertical/smrt-sales:SalesActivity",
5994
6825
  "collection": "salesactivities",
5995
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesActivityCollection.ts",
6826
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesActivity.ts",
5996
6827
  "packageName": "@happyvertical/smrt-sales",
5997
- "fields": {},
5998
- "methods": {
5999
- "findBySubject": {
6000
- "name": "findBySubject",
6001
- "async": true,
6002
- "parameters": [
6003
- {
6004
- "name": "subjectKind",
6005
- "type": "SalesActivitySubjectKind",
6006
- "optional": false
6007
- },
6008
- {
6009
- "name": "subjectId",
6010
- "type": "string",
6011
- "optional": false
6828
+ "fields": {
6829
+ "tenantId": {
6830
+ "type": "text",
6831
+ "required": false,
6832
+ "_meta": {
6833
+ "sqlType": "UUID",
6834
+ "nullable": true,
6835
+ "__tenancy": {
6836
+ "isTenantIdField": true,
6837
+ "autoFilter": true,
6838
+ "required": false,
6839
+ "autoPopulate": true,
6840
+ "nullable": true,
6841
+ "mode": "optional",
6842
+ "field": "tenantId",
6843
+ "allowSuperAdminBypass": false
6012
6844
  }
6013
- ],
6014
- "returnType": "Promise<SalesActivity[]>",
6845
+ }
6846
+ },
6847
+ "subjectKind": {
6848
+ "type": "text",
6849
+ "required": false,
6850
+ "default": "lead"
6851
+ },
6852
+ "subjectId": {
6853
+ "type": "text",
6854
+ "required": true,
6855
+ "default": "",
6856
+ "_meta": {
6857
+ "required": true
6858
+ }
6859
+ },
6860
+ "activityKind": {
6861
+ "type": "text",
6862
+ "required": false,
6863
+ "default": "note"
6864
+ },
6865
+ "summary": {
6866
+ "type": "text",
6867
+ "required": false,
6868
+ "default": ""
6869
+ },
6870
+ "dueAt": {
6871
+ "type": "datetime",
6872
+ "required": false
6873
+ },
6874
+ "completedAt": {
6875
+ "type": "datetime",
6876
+ "required": false
6877
+ },
6878
+ "actorProfileId": {
6879
+ "type": "crossPackageRef",
6880
+ "required": false,
6881
+ "related": "@happyvertical/smrt-profiles:Profile"
6882
+ },
6883
+ "metadata": {
6884
+ "type": "text",
6885
+ "required": false,
6886
+ "default": "{}"
6887
+ }
6888
+ },
6889
+ "methods": {
6890
+ "isOpenTask": {
6891
+ "name": "isOpenTask",
6892
+ "async": false,
6893
+ "parameters": [],
6894
+ "returnType": "boolean",
6015
6895
  "isStatic": false,
6016
6896
  "isPublic": true
6017
6897
  },
6018
- "findOpenTasks": {
6019
- "name": "findOpenTasks",
6020
- "async": true,
6898
+ "getMetadata": {
6899
+ "name": "getMetadata",
6900
+ "async": false,
6901
+ "parameters": [],
6902
+ "returnType": "Record<string>",
6903
+ "isStatic": false,
6904
+ "isPublic": true
6905
+ },
6906
+ "setMetadata": {
6907
+ "name": "setMetadata",
6908
+ "async": false,
6021
6909
  "parameters": [
6022
6910
  {
6023
- "name": "subjectKind",
6024
- "type": "SalesActivitySubjectKind",
6025
- "optional": false
6026
- },
6027
- {
6028
- "name": "subjectId",
6029
- "type": "string",
6911
+ "name": "metadata",
6912
+ "type": "Record<string>",
6030
6913
  "optional": false
6031
6914
  }
6032
6915
  ],
6033
- "returnType": "Promise<SalesActivity[]>",
6916
+ "returnType": "void",
6034
6917
  "isStatic": false,
6035
6918
  "isPublic": true
6036
6919
  }
6037
6920
  },
6038
- "decoratorConfig": {},
6039
- "extends": "SmrtCollection",
6040
- "extendsTypeArg": "SalesActivity",
6041
- "exportName": "SalesActivityCollection",
6042
- "collectionExportName": "SalesActivityCollectionCollection",
6921
+ "decoratorConfig": {
6922
+ "api": {
6923
+ "include": [
6924
+ "create",
6925
+ "list",
6926
+ "get"
6927
+ ]
6928
+ },
6929
+ "mcp": {
6930
+ "include": [
6931
+ "list",
6932
+ "create"
6933
+ ]
6934
+ },
6935
+ "cli": false,
6936
+ "tenantScoped": {
6937
+ "mode": "optional"
6938
+ }
6939
+ },
6940
+ "extends": "SmrtObject",
6941
+ "exportName": "SalesActivity",
6942
+ "collectionExportName": "SalesActivityCollection",
6943
+ "validationRules": [
6944
+ {
6945
+ "field": "subjectId",
6946
+ "rule": "required",
6947
+ "fieldType": "text"
6948
+ }
6949
+ ],
6043
6950
  "schema": {
6044
- "tableName": "sales_activity_collections",
6045
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activity_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6951
+ "tableName": "sales_activities",
6952
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activities\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"subject_kind\" TEXT DEFAULT 'lead',\n \"subject_id\" TEXT NOT NULL DEFAULT '',\n \"activity_kind\" TEXT DEFAULT 'note',\n \"summary\" TEXT DEFAULT '',\n \"due_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"actor_profile_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}'\n);",
6046
6953
  "columns": {
6047
6954
  "id": {
6048
6955
  "type": "UUID",
@@ -6068,103 +6975,69 @@
6068
6975
  "type": "TIMESTAMP",
6069
6976
  "notNull": true,
6070
6977
  "default": "current_timestamp"
6071
- }
6072
- },
6073
- "indexes": [
6074
- {
6075
- "name": "sales_activity_collections_id_idx",
6076
- "columns": [
6077
- "id"
6078
- ]
6079
6978
  },
6080
- {
6081
- "name": "sales_activity_collections_slug_context_idx",
6082
- "columns": [
6083
- "slug",
6084
- "context"
6085
- ],
6086
- "unique": true
6087
- }
6088
- ],
6089
- "version": "766a0235"
6090
- }
6091
- },
6092
- "@happyvertical/smrt-sales:SalesRepresentativeCollection": {
6093
- "name": "salesrepresentativecollection",
6094
- "className": "SalesRepresentativeCollection",
6095
- "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentativeCollection",
6096
- "collection": "salesrepresentatives",
6097
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesRepresentativeCollection.ts",
6098
- "packageName": "@happyvertical/smrt-sales",
6099
- "fields": {},
6100
- "methods": {
6101
- "findByProfile": {
6102
- "name": "findByProfile",
6103
- "async": true,
6104
- "parameters": [
6105
- {
6106
- "name": "profileId",
6107
- "type": "string",
6108
- "optional": false
6109
- }
6110
- ],
6111
- "returnType": "Promise<SalesRepresentative[]>",
6112
- "isStatic": false,
6113
- "isPublic": true
6114
- },
6115
- "findActive": {
6116
- "name": "findActive",
6117
- "async": true,
6118
- "parameters": [],
6119
- "returnType": "Promise<SalesRepresentative[]>",
6120
- "isStatic": false,
6121
- "isPublic": true
6122
- }
6123
- },
6124
- "decoratorConfig": {},
6125
- "extends": "SmrtCollection",
6126
- "extendsTypeArg": "SalesRepresentative",
6127
- "exportName": "SalesRepresentativeCollection",
6128
- "collectionExportName": "SalesRepresentativeCollectionCollection",
6129
- "schema": {
6130
- "tableName": "sales_representative_collections",
6131
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representative_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6132
- "columns": {
6133
- "id": {
6979
+ "tenant_id": {
6134
6980
  "type": "UUID",
6135
- "primaryKey": true,
6136
- "referenceKind": "id",
6137
- "notNull": true
6981
+ "referenceKind": "tenantId",
6982
+ "notNull": false,
6983
+ "unique": false
6138
6984
  },
6139
- "slug": {
6985
+ "subject_kind": {
6140
6986
  "type": "TEXT",
6141
- "notNull": true
6987
+ "notNull": false,
6988
+ "unique": false,
6989
+ "default": "lead"
6142
6990
  },
6143
- "context": {
6991
+ "subject_id": {
6144
6992
  "type": "TEXT",
6145
6993
  "notNull": true,
6994
+ "unique": false,
6146
6995
  "default": ""
6147
6996
  },
6148
- "created_at": {
6997
+ "activity_kind": {
6998
+ "type": "TEXT",
6999
+ "notNull": false,
7000
+ "unique": false,
7001
+ "default": "note"
7002
+ },
7003
+ "summary": {
7004
+ "type": "TEXT",
7005
+ "notNull": false,
7006
+ "unique": false,
7007
+ "default": ""
7008
+ },
7009
+ "due_at": {
6149
7010
  "type": "TIMESTAMP",
6150
- "notNull": true,
6151
- "default": "current_timestamp"
7011
+ "notNull": false,
7012
+ "unique": false
6152
7013
  },
6153
- "updated_at": {
7014
+ "completed_at": {
6154
7015
  "type": "TIMESTAMP",
6155
- "notNull": true,
6156
- "default": "current_timestamp"
7016
+ "notNull": false,
7017
+ "unique": false
7018
+ },
7019
+ "actor_profile_id": {
7020
+ "type": "UUID",
7021
+ "referenceKind": "crossPackageRef",
7022
+ "notNull": false,
7023
+ "unique": false
7024
+ },
7025
+ "metadata": {
7026
+ "type": "TEXT",
7027
+ "notNull": false,
7028
+ "unique": false,
7029
+ "default": "{}"
6157
7030
  }
6158
7031
  },
6159
7032
  "indexes": [
6160
7033
  {
6161
- "name": "sales_representative_collections_id_idx",
7034
+ "name": "sales_activities_id_idx",
6162
7035
  "columns": [
6163
7036
  "id"
6164
7037
  ]
6165
7038
  },
6166
7039
  {
6167
- "name": "sales_representative_collections_slug_context_idx",
7040
+ "name": "sales_activities_slug_context_idx",
6168
7041
  "columns": [
6169
7042
  "slug",
6170
7043
  "context"
@@ -6172,15 +7045,15 @@
6172
7045
  "unique": true
6173
7046
  }
6174
7047
  ],
6175
- "version": "6613c45d"
7048
+ "version": "b3173b53"
6176
7049
  }
6177
7050
  },
6178
- "@happyvertical/smrt-sales:Lead": {
6179
- "name": "lead",
6180
- "className": "Lead",
6181
- "qualifiedName": "@happyvertical/smrt-sales:Lead",
6182
- "collection": "leads",
6183
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/Lead.ts",
7051
+ "@happyvertical/smrt-sales:SalesRepresentative": {
7052
+ "name": "salesrepresentative",
7053
+ "className": "SalesRepresentative",
7054
+ "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
7055
+ "collection": "salesrepresentatives",
7056
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesRepresentative.ts",
6184
7057
  "packageName": "@happyvertical/smrt-sales",
6185
7058
  "fields": {
6186
7059
  "tenantId": {
@@ -6201,78 +7074,26 @@
6201
7074
  }
6202
7075
  }
6203
7076
  },
6204
- "name": {
6205
- "type": "text",
6206
- "required": true,
6207
- "default": "",
6208
- "_meta": {
6209
- "required": true
6210
- }
6211
- },
6212
- "contactName": {
6213
- "type": "text",
6214
- "required": false,
6215
- "default": ""
6216
- },
6217
- "email": {
6218
- "type": "text",
6219
- "required": false,
6220
- "default": ""
6221
- },
6222
- "phone": {
6223
- "type": "text",
6224
- "required": false,
6225
- "default": ""
6226
- },
6227
- "organizationName": {
6228
- "type": "text",
6229
- "required": false,
6230
- "default": ""
6231
- },
6232
7077
  "profileId": {
6233
7078
  "type": "crossPackageRef",
6234
7079
  "required": false,
6235
7080
  "related": "@happyvertical/smrt-profiles:Profile"
6236
7081
  },
6237
- "ownerRepId": {
7082
+ "earnerId": {
6238
7083
  "type": "foreignKey",
6239
7084
  "required": false,
6240
- "related": "SalesRepresentative"
7085
+ "related": "Earner"
6241
7086
  },
6242
7087
  "status": {
6243
7088
  "type": "text",
6244
7089
  "required": false,
6245
- "default": "new"
6246
- },
6247
- "sourceKind": {
6248
- "type": "text",
6249
- "required": false,
6250
- "default": ""
6251
- },
6252
- "sourceId": {
6253
- "type": "text",
6254
- "required": false,
6255
- "default": ""
6256
- },
6257
- "acquisitionContext": {
6258
- "type": "text",
6259
- "required": false,
6260
- "default": "{}"
7090
+ "default": "active"
6261
7091
  },
6262
- "intakeRef": {
7092
+ "title": {
6263
7093
  "type": "text",
6264
7094
  "required": false,
6265
7095
  "default": ""
6266
7096
  },
6267
- "mergedIntoId": {
6268
- "type": "foreignKey",
6269
- "required": false,
6270
- "related": "Lead"
6271
- },
6272
- "qualifiedAt": {
6273
- "type": "datetime",
6274
- "required": false
6275
- },
6276
7097
  "metadata": {
6277
7098
  "type": "text",
6278
7099
  "required": false,
@@ -6280,44 +7101,14 @@
6280
7101
  }
6281
7102
  },
6282
7103
  "methods": {
6283
- "isMerged": {
6284
- "name": "isMerged",
6285
- "async": false,
6286
- "parameters": [],
6287
- "returnType": "boolean",
6288
- "isStatic": false,
6289
- "isPublic": true
6290
- },
6291
- "isQualified": {
6292
- "name": "isQualified",
7104
+ "isActive": {
7105
+ "name": "isActive",
6293
7106
  "async": false,
6294
7107
  "parameters": [],
6295
7108
  "returnType": "boolean",
6296
7109
  "isStatic": false,
6297
7110
  "isPublic": true
6298
7111
  },
6299
- "getAcquisitionContext": {
6300
- "name": "getAcquisitionContext",
6301
- "async": false,
6302
- "parameters": [],
6303
- "returnType": "Record<string>",
6304
- "isStatic": false,
6305
- "isPublic": true
6306
- },
6307
- "setAcquisitionContext": {
6308
- "name": "setAcquisitionContext",
6309
- "async": false,
6310
- "parameters": [
6311
- {
6312
- "name": "context",
6313
- "type": "Record<string>",
6314
- "optional": false
6315
- }
6316
- ],
6317
- "returnType": "void",
6318
- "isStatic": false,
6319
- "isPublic": true
6320
- },
6321
7112
  "getMetadata": {
6322
7113
  "name": "getMetadata",
6323
7114
  "async": false,
@@ -6332,27 +7123,11 @@
6332
7123
  "parameters": [
6333
7124
  {
6334
7125
  "name": "metadata",
6335
- "type": "Record<string>",
6336
- "optional": false
6337
- }
6338
- ],
6339
- "returnType": "void",
6340
- "isStatic": false,
6341
- "isPublic": true
6342
- },
6343
- "initialize": {
6344
- "name": "initialize",
6345
- "async": true,
6346
- "parameters": [],
6347
- "returnType": "Promise",
6348
- "isStatic": false,
6349
- "isPublic": true
6350
- },
6351
- "save": {
6352
- "name": "save",
6353
- "async": true,
6354
- "parameters": [],
6355
- "returnType": "Promise",
7126
+ "type": "Record<string>",
7127
+ "optional": false
7128
+ }
7129
+ ],
7130
+ "returnType": "void",
6356
7131
  "isStatic": false,
6357
7132
  "isPublic": true
6358
7133
  }
@@ -6369,8 +7144,7 @@
6369
7144
  "mcp": {
6370
7145
  "include": [
6371
7146
  "list",
6372
- "get",
6373
- "create"
7147
+ "get"
6374
7148
  ]
6375
7149
  },
6376
7150
  "cli": true,
@@ -6379,18 +7153,11 @@
6379
7153
  }
6380
7154
  },
6381
7155
  "extends": "SmrtObject",
6382
- "exportName": "Lead",
6383
- "collectionExportName": "LeadCollection",
6384
- "validationRules": [
6385
- {
6386
- "field": "name",
6387
- "rule": "required",
6388
- "fieldType": "text"
6389
- }
6390
- ],
7156
+ "exportName": "SalesRepresentative",
7157
+ "collectionExportName": "SalesRepresentativeCollection",
6391
7158
  "schema": {
6392
- "tableName": "leads",
6393
- "ddl": "CREATE TABLE IF NOT EXISTS \"leads\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT NOT NULL DEFAULT '',\n \"contact_name\" TEXT DEFAULT '',\n \"email\" TEXT DEFAULT '',\n \"phone\" TEXT DEFAULT '',\n \"organization_name\" TEXT DEFAULT '',\n \"profile_id\" UUID,\n \"owner_rep_id\" UUID,\n \"status\" TEXT DEFAULT 'new',\n \"source_kind\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"acquisition_context\" TEXT DEFAULT '{}',\n \"intake_ref\" TEXT DEFAULT '',\n \"merged_into_id\" UUID,\n \"qualified_at\" TIMESTAMP,\n \"metadata\" TEXT DEFAULT '{}'\n);",
7159
+ "tableName": "sales_representatives",
7160
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representatives\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"profile_id\" UUID,\n \"earner_id\" UUID,\n \"status\" TEXT DEFAULT 'active',\n \"title\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
6394
7161
  "columns": {
6395
7162
  "id": {
6396
7163
  "type": "UUID",
@@ -6423,43 +7190,13 @@
6423
7190
  "notNull": false,
6424
7191
  "unique": false
6425
7192
  },
6426
- "name": {
6427
- "type": "TEXT",
6428
- "notNull": true,
6429
- "unique": false,
6430
- "default": ""
6431
- },
6432
- "contact_name": {
6433
- "type": "TEXT",
6434
- "notNull": false,
6435
- "unique": false,
6436
- "default": ""
6437
- },
6438
- "email": {
6439
- "type": "TEXT",
6440
- "notNull": false,
6441
- "unique": false,
6442
- "default": ""
6443
- },
6444
- "phone": {
6445
- "type": "TEXT",
6446
- "notNull": false,
6447
- "unique": false,
6448
- "default": ""
6449
- },
6450
- "organization_name": {
6451
- "type": "TEXT",
6452
- "notNull": false,
6453
- "unique": false,
6454
- "default": ""
6455
- },
6456
7193
  "profile_id": {
6457
7194
  "type": "UUID",
6458
7195
  "referenceKind": "crossPackageRef",
6459
7196
  "notNull": false,
6460
7197
  "unique": false
6461
7198
  },
6462
- "owner_rep_id": {
7199
+ "earner_id": {
6463
7200
  "type": "UUID",
6464
7201
  "referenceKind": "foreignKey",
6465
7202
  "notNull": false,
@@ -6469,43 +7206,14 @@
6469
7206
  "type": "TEXT",
6470
7207
  "notNull": false,
6471
7208
  "unique": false,
6472
- "default": "new"
6473
- },
6474
- "source_kind": {
6475
- "type": "TEXT",
6476
- "notNull": false,
6477
- "unique": false,
6478
- "default": ""
6479
- },
6480
- "source_id": {
6481
- "type": "TEXT",
6482
- "notNull": false,
6483
- "unique": false,
6484
- "default": ""
6485
- },
6486
- "acquisition_context": {
6487
- "type": "TEXT",
6488
- "notNull": false,
6489
- "unique": false,
6490
- "default": "{}"
7209
+ "default": "active"
6491
7210
  },
6492
- "intake_ref": {
7211
+ "title": {
6493
7212
  "type": "TEXT",
6494
7213
  "notNull": false,
6495
7214
  "unique": false,
6496
7215
  "default": ""
6497
7216
  },
6498
- "merged_into_id": {
6499
- "type": "UUID",
6500
- "referenceKind": "foreignKey",
6501
- "notNull": false,
6502
- "unique": false
6503
- },
6504
- "qualified_at": {
6505
- "type": "TIMESTAMP",
6506
- "notNull": false,
6507
- "unique": false
6508
- },
6509
7217
  "metadata": {
6510
7218
  "type": "TEXT",
6511
7219
  "notNull": false,
@@ -6515,13 +7223,13 @@
6515
7223
  },
6516
7224
  "indexes": [
6517
7225
  {
6518
- "name": "leads_id_idx",
7226
+ "name": "sales_representatives_id_idx",
6519
7227
  "columns": [
6520
7228
  "id"
6521
7229
  ]
6522
7230
  },
6523
7231
  {
6524
- "name": "leads_slug_context_idx",
7232
+ "name": "sales_representatives_slug_context_idx",
6525
7233
  "columns": [
6526
7234
  "slug",
6527
7235
  "context"
@@ -6529,205 +7237,97 @@
6529
7237
  "unique": true
6530
7238
  }
6531
7239
  ],
6532
- "version": "a1c330c8"
7240
+ "version": "7b67ed6e"
6533
7241
  }
6534
7242
  },
6535
- "@happyvertical/smrt-sales:Opportunity": {
6536
- "name": "opportunity",
6537
- "className": "Opportunity",
6538
- "qualifiedName": "@happyvertical/smrt-sales:Opportunity",
6539
- "collection": "opportunities",
6540
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/Opportunity.ts",
7243
+ "@happyvertical/smrt-sales:LeadCollection": {
7244
+ "name": "leadcollection",
7245
+ "className": "LeadCollection",
7246
+ "qualifiedName": "@happyvertical/smrt-sales:LeadCollection",
7247
+ "collection": "leads",
7248
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/LeadCollection.ts",
6541
7249
  "packageName": "@happyvertical/smrt-sales",
6542
- "fields": {
6543
- "tenantId": {
6544
- "type": "text",
6545
- "required": false,
6546
- "_meta": {
6547
- "sqlType": "UUID",
6548
- "nullable": true,
6549
- "__tenancy": {
6550
- "isTenantIdField": true,
6551
- "autoFilter": true,
6552
- "required": false,
6553
- "autoPopulate": true,
6554
- "nullable": true,
6555
- "mode": "optional",
6556
- "field": "tenantId",
6557
- "allowSuperAdminBypass": false
6558
- }
6559
- }
6560
- },
6561
- "name": {
6562
- "type": "text",
6563
- "required": true,
6564
- "default": "",
6565
- "_meta": {
6566
- "required": true
6567
- }
6568
- },
6569
- "leadId": {
6570
- "type": "foreignKey",
6571
- "required": false,
6572
- "related": "Lead"
6573
- },
6574
- "ownerRepId": {
6575
- "type": "foreignKey",
6576
- "required": false,
6577
- "related": "SalesRepresentative"
6578
- },
6579
- "pipelineId": {
6580
- "type": "foreignKey",
6581
- "required": false,
6582
- "related": "PipelineDefinition"
6583
- },
6584
- "stageId": {
6585
- "type": "foreignKey",
6586
- "required": false,
6587
- "related": "PipelineStage"
6588
- },
6589
- "expectedValueCents": {
6590
- "type": "integer",
6591
- "required": false,
6592
- "default": 0
6593
- },
6594
- "currency": {
6595
- "type": "text",
6596
- "required": false,
6597
- "default": "USD"
6598
- },
6599
- "probability": {
6600
- "type": "decimal",
6601
- "required": false,
6602
- "default": 0
6603
- },
6604
- "expectedCloseAt": {
6605
- "type": "datetime",
6606
- "required": false
6607
- },
6608
- "status": {
6609
- "type": "text",
6610
- "required": false,
6611
- "default": "open"
6612
- },
6613
- "outcomeReason": {
6614
- "type": "text",
6615
- "required": false,
6616
- "default": ""
6617
- },
6618
- "wonAt": {
6619
- "type": "datetime",
6620
- "required": false
6621
- },
6622
- "lostAt": {
6623
- "type": "datetime",
6624
- "required": false
6625
- },
6626
- "sourceKind": {
6627
- "type": "text",
6628
- "required": false,
6629
- "default": ""
6630
- },
6631
- "sourceId": {
6632
- "type": "text",
6633
- "required": false,
6634
- "default": ""
6635
- },
6636
- "metadata": {
6637
- "type": "text",
6638
- "required": false,
6639
- "default": "{}"
6640
- }
6641
- },
7250
+ "fields": {},
6642
7251
  "methods": {
6643
- "isOpen": {
6644
- "name": "isOpen",
6645
- "async": false,
6646
- "parameters": [],
6647
- "returnType": "boolean",
6648
- "isStatic": false,
6649
- "isPublic": true
6650
- },
6651
- "isClosed": {
6652
- "name": "isClosed",
6653
- "async": false,
6654
- "parameters": [],
6655
- "returnType": "boolean",
7252
+ "findByStatus": {
7253
+ "name": "findByStatus",
7254
+ "async": true,
7255
+ "parameters": [
7256
+ {
7257
+ "name": "status",
7258
+ "type": "LeadStatus",
7259
+ "optional": false
7260
+ }
7261
+ ],
7262
+ "returnType": "Promise<Lead[]>",
6656
7263
  "isStatic": false,
6657
7264
  "isPublic": true
6658
7265
  },
6659
- "getMetadata": {
6660
- "name": "getMetadata",
6661
- "async": false,
6662
- "parameters": [],
6663
- "returnType": "Record<string>",
7266
+ "findByOwner": {
7267
+ "name": "findByOwner",
7268
+ "async": true,
7269
+ "parameters": [
7270
+ {
7271
+ "name": "ownerRepId",
7272
+ "type": "string",
7273
+ "optional": false
7274
+ }
7275
+ ],
7276
+ "returnType": "Promise<Lead[]>",
6664
7277
  "isStatic": false,
6665
7278
  "isPublic": true
6666
7279
  },
6667
- "setMetadata": {
6668
- "name": "setMetadata",
6669
- "async": false,
7280
+ "qualify": {
7281
+ "name": "qualify",
7282
+ "async": true,
6670
7283
  "parameters": [
6671
7284
  {
6672
- "name": "metadata",
6673
- "type": "Record<string>",
7285
+ "name": "params",
7286
+ "type": "QualifyLeadParams",
6674
7287
  "optional": false
6675
7288
  }
6676
7289
  ],
6677
- "returnType": "void",
7290
+ "returnType": "Promise<Opportunity>",
6678
7291
  "isStatic": false,
6679
7292
  "isPublic": true
6680
7293
  },
6681
- "initialize": {
6682
- "name": "initialize",
7294
+ "mergeLeads": {
7295
+ "name": "mergeLeads",
6683
7296
  "async": true,
6684
- "parameters": [],
6685
- "returnType": "Promise",
7297
+ "parameters": [
7298
+ {
7299
+ "name": "params",
7300
+ "type": "MergeLeadsParams",
7301
+ "optional": false
7302
+ }
7303
+ ],
7304
+ "returnType": "Promise<MergeLeadsResult>",
6686
7305
  "isStatic": false,
6687
7306
  "isPublic": true
6688
7307
  },
6689
- "save": {
6690
- "name": "save",
7308
+ "activitiesIncludingMerged": {
7309
+ "name": "activitiesIncludingMerged",
6691
7310
  "async": true,
6692
- "parameters": [],
6693
- "returnType": "Promise",
7311
+ "parameters": [
7312
+ {
7313
+ "name": "leadId",
7314
+ "type": "string",
7315
+ "optional": false
7316
+ }
7317
+ ],
7318
+ "returnType": "Promise<SalesActivity[]>",
6694
7319
  "isStatic": false,
6695
7320
  "isPublic": true
6696
7321
  }
6697
7322
  },
6698
- "decoratorConfig": {
6699
- "api": {
6700
- "include": [
6701
- "list",
6702
- "get",
6703
- "create",
6704
- "update"
6705
- ]
6706
- },
6707
- "mcp": {
6708
- "include": [
6709
- "list",
6710
- "get"
6711
- ]
6712
- },
6713
- "cli": true,
6714
- "tenantScoped": {
6715
- "mode": "optional"
6716
- }
6717
- },
6718
- "extends": "SmrtObject",
6719
- "exportName": "Opportunity",
6720
- "collectionExportName": "OpportunityCollection",
6721
- "validationRules": [
6722
- {
6723
- "field": "name",
6724
- "rule": "required",
6725
- "fieldType": "text"
6726
- }
6727
- ],
7323
+ "decoratorConfig": {},
7324
+ "extends": "SmrtCollection",
7325
+ "extendsTypeArg": "Lead",
7326
+ "exportName": "LeadCollection",
7327
+ "collectionExportName": "LeadCollectionCollection",
6728
7328
  "schema": {
6729
- "tableName": "opportunities",
6730
- "ddl": "CREATE TABLE IF NOT EXISTS \"opportunities\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"name\" TEXT NOT NULL DEFAULT '',\n \"lead_id\" UUID,\n \"owner_rep_id\" UUID,\n \"pipeline_id\" UUID,\n \"stage_id\" UUID,\n \"expected_value_cents\" INTEGER DEFAULT 0,\n \"currency\" TEXT DEFAULT 'USD',\n \"probability\" REAL DEFAULT 0,\n \"expected_close_at\" TIMESTAMP,\n \"status\" TEXT DEFAULT 'open',\n \"outcome_reason\" TEXT DEFAULT '',\n \"won_at\" TIMESTAMP,\n \"lost_at\" TIMESTAMP,\n \"source_kind\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
7329
+ "tableName": "lead_collections",
7330
+ "ddl": "CREATE TABLE IF NOT EXISTS \"lead_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6731
7331
  "columns": {
6732
7332
  "id": {
6733
7333
  "type": "UUID",
@@ -6753,116 +7353,17 @@
6753
7353
  "type": "TIMESTAMP",
6754
7354
  "notNull": true,
6755
7355
  "default": "current_timestamp"
6756
- },
6757
- "tenant_id": {
6758
- "type": "UUID",
6759
- "referenceKind": "tenantId",
6760
- "notNull": false,
6761
- "unique": false
6762
- },
6763
- "name": {
6764
- "type": "TEXT",
6765
- "notNull": true,
6766
- "unique": false,
6767
- "default": ""
6768
- },
6769
- "lead_id": {
6770
- "type": "UUID",
6771
- "referenceKind": "foreignKey",
6772
- "notNull": false,
6773
- "unique": false
6774
- },
6775
- "owner_rep_id": {
6776
- "type": "UUID",
6777
- "referenceKind": "foreignKey",
6778
- "notNull": false,
6779
- "unique": false
6780
- },
6781
- "pipeline_id": {
6782
- "type": "UUID",
6783
- "referenceKind": "foreignKey",
6784
- "notNull": false,
6785
- "unique": false
6786
- },
6787
- "stage_id": {
6788
- "type": "UUID",
6789
- "referenceKind": "foreignKey",
6790
- "notNull": false,
6791
- "unique": false
6792
- },
6793
- "expected_value_cents": {
6794
- "type": "INTEGER",
6795
- "notNull": false,
6796
- "unique": false,
6797
- "default": 0
6798
- },
6799
- "currency": {
6800
- "type": "TEXT",
6801
- "notNull": false,
6802
- "unique": false,
6803
- "default": "USD"
6804
- },
6805
- "probability": {
6806
- "type": "REAL",
6807
- "notNull": false,
6808
- "unique": false,
6809
- "default": 0
6810
- },
6811
- "expected_close_at": {
6812
- "type": "TIMESTAMP",
6813
- "notNull": false,
6814
- "unique": false
6815
- },
6816
- "status": {
6817
- "type": "TEXT",
6818
- "notNull": false,
6819
- "unique": false,
6820
- "default": "open"
6821
- },
6822
- "outcome_reason": {
6823
- "type": "TEXT",
6824
- "notNull": false,
6825
- "unique": false,
6826
- "default": ""
6827
- },
6828
- "won_at": {
6829
- "type": "TIMESTAMP",
6830
- "notNull": false,
6831
- "unique": false
6832
- },
6833
- "lost_at": {
6834
- "type": "TIMESTAMP",
6835
- "notNull": false,
6836
- "unique": false
6837
- },
6838
- "source_kind": {
6839
- "type": "TEXT",
6840
- "notNull": false,
6841
- "unique": false,
6842
- "default": ""
6843
- },
6844
- "source_id": {
6845
- "type": "TEXT",
6846
- "notNull": false,
6847
- "unique": false,
6848
- "default": ""
6849
- },
6850
- "metadata": {
6851
- "type": "TEXT",
6852
- "notNull": false,
6853
- "unique": false,
6854
- "default": "{}"
6855
7356
  }
6856
7357
  },
6857
7358
  "indexes": [
6858
7359
  {
6859
- "name": "opportunities_id_idx",
7360
+ "name": "lead_collections_id_idx",
6860
7361
  "columns": [
6861
7362
  "id"
6862
7363
  ]
6863
7364
  },
6864
7365
  {
6865
- "name": "opportunities_slug_context_idx",
7366
+ "name": "lead_collections_slug_context_idx",
6866
7367
  "columns": [
6867
7368
  "slug",
6868
7369
  "context"
@@ -6870,149 +7371,69 @@
6870
7371
  "unique": true
6871
7372
  }
6872
7373
  ],
6873
- "version": "a403c6cf"
7374
+ "version": "0707eb13"
6874
7375
  }
6875
7376
  },
6876
- "@happyvertical/smrt-sales:OpportunityConversion": {
6877
- "name": "opportunityconversion",
6878
- "className": "OpportunityConversion",
6879
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversion",
6880
- "collection": "opportunityconversions",
6881
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/OpportunityConversion.ts",
7377
+ "@happyvertical/smrt-sales:OpportunityCollection": {
7378
+ "name": "opportunitycollection",
7379
+ "className": "OpportunityCollection",
7380
+ "qualifiedName": "@happyvertical/smrt-sales:OpportunityCollection",
7381
+ "collection": "opportunities",
7382
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityCollection.ts",
6882
7383
  "packageName": "@happyvertical/smrt-sales",
6883
- "fields": {
6884
- "tenantId": {
6885
- "type": "text",
6886
- "required": false,
6887
- "_meta": {
6888
- "sqlType": "UUID",
6889
- "nullable": true,
6890
- "__tenancy": {
6891
- "isTenantIdField": true,
6892
- "autoFilter": true,
6893
- "required": false,
6894
- "autoPopulate": true,
6895
- "nullable": true,
6896
- "mode": "optional",
6897
- "field": "tenantId",
6898
- "allowSuperAdminBypass": false
6899
- }
6900
- }
6901
- },
6902
- "opportunityId": {
6903
- "type": "foreignKey",
6904
- "required": true,
6905
- "related": "Opportunity",
6906
- "_meta": {
6907
- "required": true
6908
- }
6909
- },
6910
- "targetKind": {
6911
- "type": "text",
6912
- "required": true,
6913
- "default": "",
6914
- "_meta": {
6915
- "required": true
6916
- }
6917
- },
6918
- "targetId": {
6919
- "type": "text",
6920
- "required": true,
6921
- "default": "",
6922
- "_meta": {
6923
- "required": true
6924
- }
6925
- },
6926
- "note": {
6927
- "type": "text",
6928
- "required": false,
6929
- "default": ""
6930
- },
6931
- "metadata": {
6932
- "type": "text",
6933
- "required": false,
6934
- "default": "{}"
6935
- }
6936
- },
7384
+ "fields": {},
6937
7385
  "methods": {
6938
- "getMetadata": {
6939
- "name": "getMetadata",
6940
- "async": false,
6941
- "parameters": [],
6942
- "returnType": "Record<string>",
7386
+ "findByLead": {
7387
+ "name": "findByLead",
7388
+ "async": true,
7389
+ "parameters": [
7390
+ {
7391
+ "name": "leadId",
7392
+ "type": "string",
7393
+ "optional": false
7394
+ }
7395
+ ],
7396
+ "returnType": "Promise<Opportunity[]>",
6943
7397
  "isStatic": false,
6944
7398
  "isPublic": true
6945
7399
  },
6946
- "setMetadata": {
6947
- "name": "setMetadata",
6948
- "async": false,
7400
+ "findOpen": {
7401
+ "name": "findOpen",
7402
+ "async": true,
6949
7403
  "parameters": [
6950
7404
  {
6951
- "name": "metadata",
6952
- "type": "Record<string>",
6953
- "optional": false
7405
+ "name": "pipelineId",
7406
+ "type": "string",
7407
+ "optional": true
6954
7408
  }
6955
7409
  ],
6956
- "returnType": "void",
7410
+ "returnType": "Promise<Opportunity[]>",
6957
7411
  "isStatic": false,
6958
7412
  "isPublic": true
6959
7413
  },
6960
- "save": {
6961
- "name": "save",
7414
+ "moveToStage": {
7415
+ "name": "moveToStage",
6962
7416
  "async": true,
6963
- "parameters": [],
6964
- "returnType": "Promise",
7417
+ "parameters": [
7418
+ {
7419
+ "name": "params",
7420
+ "type": "MoveToStageParams",
7421
+ "optional": false
7422
+ }
7423
+ ],
7424
+ "returnType": "Promise<Opportunity>",
6965
7425
  "isStatic": false,
6966
7426
  "isPublic": true
6967
7427
  }
6968
7428
  },
6969
- "decoratorConfig": {
6970
- "api": {
6971
- "include": [
6972
- "list",
6973
- "get",
6974
- "create"
6975
- ]
6976
- },
6977
- "mcp": {
6978
- "include": [
6979
- "list",
6980
- "get"
6981
- ]
6982
- },
6983
- "cli": false,
6984
- "conflictColumns": [
6985
- "opportunity_id",
6986
- "target_kind",
6987
- "target_id"
6988
- ],
6989
- "tenantScoped": {
6990
- "mode": "optional"
6991
- }
6992
- },
6993
- "extends": "SmrtObject",
6994
- "exportName": "OpportunityConversion",
6995
- "collectionExportName": "OpportunityConversionCollection",
6996
- "validationRules": [
6997
- {
6998
- "field": "opportunityId",
6999
- "rule": "required",
7000
- "fieldType": "foreignKey"
7001
- },
7002
- {
7003
- "field": "targetKind",
7004
- "rule": "required",
7005
- "fieldType": "text"
7006
- },
7007
- {
7008
- "field": "targetId",
7009
- "rule": "required",
7010
- "fieldType": "text"
7011
- }
7012
- ],
7429
+ "decoratorConfig": {},
7430
+ "extends": "SmrtCollection",
7431
+ "extendsTypeArg": "Opportunity",
7432
+ "exportName": "OpportunityCollection",
7433
+ "collectionExportName": "OpportunityCollectionCollection",
7013
7434
  "schema": {
7014
- "tableName": "opportunity_conversions",
7015
- "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_conversions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"opportunity_id\" UUID NOT NULL,\n \"target_kind\" TEXT NOT NULL DEFAULT '',\n \"target_id\" TEXT NOT NULL DEFAULT '',\n \"note\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
7435
+ "tableName": "opportunity_collections",
7436
+ "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7016
7437
  "columns": {
7017
7438
  "id": {
7018
7439
  "type": "UUID",
@@ -7038,188 +7459,187 @@
7038
7459
  "type": "TIMESTAMP",
7039
7460
  "notNull": true,
7040
7461
  "default": "current_timestamp"
7041
- },
7042
- "tenant_id": {
7043
- "type": "UUID",
7044
- "referenceKind": "tenantId",
7045
- "notNull": false,
7046
- "unique": false
7047
- },
7048
- "opportunity_id": {
7049
- "type": "UUID",
7050
- "referenceKind": "foreignKey",
7051
- "notNull": true,
7052
- "unique": false
7053
- },
7054
- "target_kind": {
7055
- "type": "TEXT",
7056
- "notNull": true,
7057
- "unique": false,
7058
- "default": ""
7059
- },
7060
- "target_id": {
7061
- "type": "TEXT",
7062
- "notNull": true,
7063
- "unique": false,
7064
- "default": ""
7065
- },
7066
- "note": {
7067
- "type": "TEXT",
7068
- "notNull": false,
7069
- "unique": false,
7070
- "default": ""
7071
- },
7072
- "metadata": {
7073
- "type": "TEXT",
7074
- "notNull": false,
7075
- "unique": false,
7076
- "default": "{}"
7077
7462
  }
7078
7463
  },
7079
7464
  "indexes": [
7080
7465
  {
7081
- "name": "opportunity_conversions_id_idx",
7466
+ "name": "opportunity_collections_id_idx",
7082
7467
  "columns": [
7083
7468
  "id"
7084
7469
  ]
7085
7470
  },
7086
7471
  {
7087
- "name": "opportunity_conversions_opportunity_id_target_kind_idx",
7472
+ "name": "opportunity_collections_slug_context_idx",
7088
7473
  "columns": [
7089
- "opportunity_id",
7090
- "target_kind",
7091
- "target_id"
7474
+ "slug",
7475
+ "context"
7092
7476
  ],
7093
7477
  "unique": true
7094
7478
  }
7095
7479
  ],
7096
- "version": "82c29042"
7480
+ "version": "ebcdf63b"
7097
7481
  }
7098
7482
  },
7099
- "@happyvertical/smrt-sales:PipelineDefinition": {
7100
- "name": "pipelinedefinition",
7101
- "className": "PipelineDefinition",
7102
- "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
7103
- "collection": "pipelinedefinitions",
7104
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineDefinition.ts",
7483
+ "@happyvertical/smrt-sales:OpportunityConversionCollection": {
7484
+ "name": "opportunityconversioncollection",
7485
+ "className": "OpportunityConversionCollection",
7486
+ "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversionCollection",
7487
+ "collection": "opportunityconversions",
7488
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityConversionCollection.ts",
7105
7489
  "packageName": "@happyvertical/smrt-sales",
7106
- "fields": {
7107
- "tenantId": {
7108
- "type": "text",
7109
- "required": false,
7110
- "_meta": {
7111
- "sqlType": "UUID",
7112
- "nullable": true,
7113
- "__tenancy": {
7114
- "isTenantIdField": true,
7115
- "autoFilter": true,
7116
- "required": false,
7117
- "autoPopulate": true,
7118
- "nullable": true,
7119
- "mode": "optional",
7120
- "field": "tenantId",
7121
- "allowSuperAdminBypass": false
7490
+ "fields": {},
7491
+ "methods": {
7492
+ "findByOpportunity": {
7493
+ "name": "findByOpportunity",
7494
+ "async": true,
7495
+ "parameters": [
7496
+ {
7497
+ "name": "opportunityId",
7498
+ "type": "string",
7499
+ "optional": false
7122
7500
  }
7123
- }
7124
- },
7125
- "key": {
7126
- "type": "text",
7127
- "required": true,
7128
- "default": "",
7129
- "_meta": {
7130
- "required": true
7131
- }
7132
- },
7133
- "name": {
7134
- "type": "text",
7135
- "required": false,
7136
- "default": ""
7137
- },
7138
- "isDefault": {
7139
- "type": "boolean",
7140
- "required": false,
7141
- "default": false
7142
- },
7143
- "status": {
7144
- "type": "text",
7145
- "required": false,
7146
- "default": "active"
7501
+ ],
7502
+ "returnType": "Promise<OpportunityConversion[]>",
7503
+ "isStatic": false,
7504
+ "isPublic": true
7147
7505
  },
7148
- "metadata": {
7149
- "type": "text",
7150
- "required": false,
7151
- "default": "{}"
7506
+ "recordConversion": {
7507
+ "name": "recordConversion",
7508
+ "async": true,
7509
+ "parameters": [
7510
+ {
7511
+ "name": "params",
7512
+ "type": "RecordConversionParams",
7513
+ "optional": false
7514
+ }
7515
+ ],
7516
+ "returnType": "Promise<RecordConversionResult>",
7517
+ "isStatic": false,
7518
+ "isPublic": true
7152
7519
  }
7153
7520
  },
7521
+ "decoratorConfig": {},
7522
+ "extends": "SmrtCollection",
7523
+ "extendsTypeArg": "OpportunityConversion",
7524
+ "exportName": "OpportunityConversionCollection",
7525
+ "collectionExportName": "OpportunityConversionCollectionCollection",
7526
+ "schema": {
7527
+ "tableName": "opportunity_conversion_collections",
7528
+ "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_conversion_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7529
+ "columns": {
7530
+ "id": {
7531
+ "type": "UUID",
7532
+ "primaryKey": true,
7533
+ "referenceKind": "id",
7534
+ "notNull": true
7535
+ },
7536
+ "slug": {
7537
+ "type": "TEXT",
7538
+ "notNull": true
7539
+ },
7540
+ "context": {
7541
+ "type": "TEXT",
7542
+ "notNull": true,
7543
+ "default": ""
7544
+ },
7545
+ "created_at": {
7546
+ "type": "TIMESTAMP",
7547
+ "notNull": true,
7548
+ "default": "current_timestamp"
7549
+ },
7550
+ "updated_at": {
7551
+ "type": "TIMESTAMP",
7552
+ "notNull": true,
7553
+ "default": "current_timestamp"
7554
+ }
7555
+ },
7556
+ "indexes": [
7557
+ {
7558
+ "name": "opportunity_conversion_collections_id_idx",
7559
+ "columns": [
7560
+ "id"
7561
+ ]
7562
+ },
7563
+ {
7564
+ "name": "opportunity_conversion_collections_slug_context_idx",
7565
+ "columns": [
7566
+ "slug",
7567
+ "context"
7568
+ ],
7569
+ "unique": true
7570
+ }
7571
+ ],
7572
+ "version": "7e30ff1b"
7573
+ }
7574
+ },
7575
+ "@happyvertical/smrt-sales:PipelineDefinitionCollection": {
7576
+ "name": "pipelinedefinitioncollection",
7577
+ "className": "PipelineDefinitionCollection",
7578
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
7579
+ "collection": "pipelinedefinitions",
7580
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineDefinitionCollection.ts",
7581
+ "packageName": "@happyvertical/smrt-sales",
7582
+ "fields": {},
7154
7583
  "methods": {
7155
- "isActive": {
7156
- "name": "isActive",
7157
- "async": false,
7158
- "parameters": [],
7159
- "returnType": "boolean",
7584
+ "findByKey": {
7585
+ "name": "findByKey",
7586
+ "async": true,
7587
+ "parameters": [
7588
+ {
7589
+ "name": "key",
7590
+ "type": "string",
7591
+ "optional": false
7592
+ }
7593
+ ],
7594
+ "returnType": "Promise<PipelineDefinition | null>",
7160
7595
  "isStatic": false,
7161
7596
  "isPublic": true
7162
7597
  },
7163
- "getMetadata": {
7164
- "name": "getMetadata",
7165
- "async": false,
7598
+ "findDefault": {
7599
+ "name": "findDefault",
7600
+ "async": true,
7166
7601
  "parameters": [],
7167
- "returnType": "Record<string>",
7602
+ "returnType": "Promise<PipelineDefinition | null>",
7168
7603
  "isStatic": false,
7169
7604
  "isPublic": true
7170
7605
  },
7171
- "setMetadata": {
7172
- "name": "setMetadata",
7173
- "async": false,
7606
+ "getStages": {
7607
+ "name": "getStages",
7608
+ "async": true,
7174
7609
  "parameters": [
7175
7610
  {
7176
- "name": "metadata",
7177
- "type": "Record<string>",
7611
+ "name": "pipelineId",
7612
+ "type": "string",
7178
7613
  "optional": false
7179
7614
  }
7180
7615
  ],
7181
- "returnType": "void",
7616
+ "returnType": "Promise<PipelineStage[]>",
7182
7617
  "isStatic": false,
7183
7618
  "isPublic": true
7184
- }
7185
- },
7186
- "decoratorConfig": {
7187
- "api": {
7188
- "include": [
7189
- "list",
7190
- "get",
7191
- "create",
7192
- "update"
7193
- ]
7194
- },
7195
- "mcp": {
7196
- "include": [
7197
- "list",
7198
- "get"
7199
- ]
7200
7619
  },
7201
- "cli": true,
7202
- "conflictColumns": [
7203
- "tenant_id",
7204
- "key"
7205
- ],
7206
- "tenantScoped": {
7207
- "mode": "optional"
7620
+ "ensureDefaultPipeline": {
7621
+ "name": "ensureDefaultPipeline",
7622
+ "async": true,
7623
+ "parameters": [
7624
+ {
7625
+ "name": "params",
7626
+ "type": "EnsureDefaultPipelineParams",
7627
+ "optional": true
7628
+ }
7629
+ ],
7630
+ "returnType": "Promise<EnsureDefaultPipelineResult>",
7631
+ "isStatic": false,
7632
+ "isPublic": true
7208
7633
  }
7209
7634
  },
7210
- "extends": "SmrtObject",
7211
- "exportName": "PipelineDefinition",
7212
- "collectionExportName": "PipelineDefinitionCollection",
7213
- "validationRules": [
7214
- {
7215
- "field": "key",
7216
- "rule": "required",
7217
- "fieldType": "text"
7218
- }
7219
- ],
7635
+ "decoratorConfig": {},
7636
+ "extends": "SmrtCollection",
7637
+ "extendsTypeArg": "PipelineDefinition",
7638
+ "exportName": "PipelineDefinitionCollection",
7639
+ "collectionExportName": "PipelineDefinitionCollectionCollection",
7220
7640
  "schema": {
7221
- "tableName": "pipeline_definitions",
7222
- "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_definitions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"key\" TEXT NOT NULL DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"is_default\" BOOLEAN DEFAULT FALSE,\n \"status\" TEXT DEFAULT 'active',\n \"metadata\" TEXT DEFAULT '{}'\n);",
7641
+ "tableName": "pipeline_definition_collections",
7642
+ "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_definition_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7223
7643
  "columns": {
7224
7644
  "id": {
7225
7645
  "type": "UUID",
@@ -7245,210 +7665,78 @@
7245
7665
  "type": "TIMESTAMP",
7246
7666
  "notNull": true,
7247
7667
  "default": "current_timestamp"
7248
- },
7249
- "tenant_id": {
7250
- "type": "UUID",
7251
- "referenceKind": "tenantId",
7252
- "notNull": false,
7253
- "unique": false
7254
- },
7255
- "key": {
7256
- "type": "TEXT",
7257
- "notNull": true,
7258
- "unique": false,
7259
- "default": ""
7260
- },
7261
- "name": {
7262
- "type": "TEXT",
7263
- "notNull": false,
7264
- "unique": false,
7265
- "default": ""
7266
- },
7267
- "is_default": {
7268
- "type": "BOOLEAN",
7269
- "notNull": false,
7270
- "unique": false,
7271
- "default": false
7272
- },
7273
- "status": {
7274
- "type": "TEXT",
7275
- "notNull": false,
7276
- "unique": false,
7277
- "default": "active"
7278
- },
7279
- "metadata": {
7280
- "type": "TEXT",
7281
- "notNull": false,
7282
- "unique": false,
7283
- "default": "{}"
7284
7668
  }
7285
7669
  },
7286
7670
  "indexes": [
7287
7671
  {
7288
- "name": "pipeline_definitions_id_idx",
7672
+ "name": "pipeline_definition_collections_id_idx",
7289
7673
  "columns": [
7290
7674
  "id"
7291
7675
  ]
7292
7676
  },
7293
7677
  {
7294
- "name": "pipeline_definitions_tenant_id_key_idx",
7678
+ "name": "pipeline_definition_collections_slug_context_idx",
7295
7679
  "columns": [
7296
- "tenant_id",
7297
- "key"
7680
+ "slug",
7681
+ "context"
7298
7682
  ],
7299
7683
  "unique": true
7300
7684
  }
7301
7685
  ],
7302
- "version": "5e3ace6c"
7686
+ "version": "f85d1436"
7303
7687
  }
7304
7688
  },
7305
- "@happyvertical/smrt-sales:PipelineStage": {
7306
- "name": "pipelinestage",
7307
- "className": "PipelineStage",
7308
- "qualifiedName": "@happyvertical/smrt-sales:PipelineStage",
7689
+ "@happyvertical/smrt-sales:PipelineStageCollection": {
7690
+ "name": "pipelinestagecollection",
7691
+ "className": "PipelineStageCollection",
7692
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineStageCollection",
7309
7693
  "collection": "pipelinestages",
7310
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineStage.ts",
7694
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineStageCollection.ts",
7311
7695
  "packageName": "@happyvertical/smrt-sales",
7312
- "fields": {
7313
- "tenantId": {
7314
- "type": "text",
7315
- "required": false,
7316
- "_meta": {
7317
- "sqlType": "UUID",
7318
- "nullable": true,
7319
- "__tenancy": {
7320
- "isTenantIdField": true,
7321
- "autoFilter": true,
7322
- "required": false,
7323
- "autoPopulate": true,
7324
- "nullable": true,
7325
- "mode": "optional",
7326
- "field": "tenantId",
7327
- "allowSuperAdminBypass": false
7328
- }
7329
- }
7330
- },
7331
- "pipelineId": {
7332
- "type": "foreignKey",
7333
- "required": true,
7334
- "related": "PipelineDefinition",
7335
- "_meta": {
7336
- "required": true
7337
- }
7338
- },
7339
- "key": {
7340
- "type": "text",
7341
- "required": true,
7342
- "default": "",
7343
- "_meta": {
7344
- "required": true
7345
- }
7346
- },
7347
- "name": {
7348
- "type": "text",
7349
- "required": false,
7350
- "default": ""
7351
- },
7352
- "sortOrder": {
7353
- "type": "integer",
7354
- "required": false,
7355
- "default": 0
7356
- },
7357
- "probability": {
7358
- "type": "decimal",
7359
- "required": false,
7360
- "default": 0
7361
- },
7362
- "isWon": {
7363
- "type": "boolean",
7364
- "required": false,
7365
- "default": false
7366
- },
7367
- "isLost": {
7368
- "type": "boolean",
7369
- "required": false,
7370
- "default": false
7371
- },
7372
- "metadata": {
7373
- "type": "text",
7374
- "required": false,
7375
- "default": "{}"
7376
- }
7377
- },
7696
+ "fields": {},
7378
7697
  "methods": {
7379
- "isTerminal": {
7380
- "name": "isTerminal",
7381
- "async": false,
7382
- "parameters": [],
7383
- "returnType": "boolean",
7384
- "isStatic": false,
7385
- "isPublic": true
7386
- },
7387
- "getMetadata": {
7388
- "name": "getMetadata",
7389
- "async": false,
7390
- "parameters": [],
7391
- "returnType": "Record<string>",
7698
+ "findByPipeline": {
7699
+ "name": "findByPipeline",
7700
+ "async": true,
7701
+ "parameters": [
7702
+ {
7703
+ "name": "pipelineId",
7704
+ "type": "string",
7705
+ "optional": false
7706
+ }
7707
+ ],
7708
+ "returnType": "Promise<PipelineStage[]>",
7392
7709
  "isStatic": false,
7393
7710
  "isPublic": true
7394
7711
  },
7395
- "setMetadata": {
7396
- "name": "setMetadata",
7397
- "async": false,
7712
+ "findByKey": {
7713
+ "name": "findByKey",
7714
+ "async": true,
7398
7715
  "parameters": [
7399
7716
  {
7400
- "name": "metadata",
7401
- "type": "Record<string>",
7717
+ "name": "pipelineId",
7718
+ "type": "string",
7719
+ "optional": false
7720
+ },
7721
+ {
7722
+ "name": "key",
7723
+ "type": "string",
7402
7724
  "optional": false
7403
7725
  }
7404
7726
  ],
7405
- "returnType": "void",
7727
+ "returnType": "Promise<PipelineStage | null>",
7406
7728
  "isStatic": false,
7407
7729
  "isPublic": true
7408
7730
  }
7409
7731
  },
7410
- "decoratorConfig": {
7411
- "api": {
7412
- "include": [
7413
- "list",
7414
- "get",
7415
- "create",
7416
- "update"
7417
- ]
7418
- },
7419
- "mcp": {
7420
- "include": [
7421
- "list",
7422
- "get"
7423
- ]
7424
- },
7425
- "cli": false,
7426
- "conflictColumns": [
7427
- "pipeline_id",
7428
- "key"
7429
- ],
7430
- "tenantScoped": {
7431
- "mode": "optional"
7432
- }
7433
- },
7434
- "extends": "SmrtObject",
7435
- "exportName": "PipelineStage",
7436
- "collectionExportName": "PipelineStageCollection",
7437
- "validationRules": [
7438
- {
7439
- "field": "pipelineId",
7440
- "rule": "required",
7441
- "fieldType": "foreignKey"
7442
- },
7443
- {
7444
- "field": "key",
7445
- "rule": "required",
7446
- "fieldType": "text"
7447
- }
7448
- ],
7732
+ "decoratorConfig": {},
7733
+ "extends": "SmrtCollection",
7734
+ "extendsTypeArg": "PipelineStage",
7735
+ "exportName": "PipelineStageCollection",
7736
+ "collectionExportName": "PipelineStageCollectionCollection",
7449
7737
  "schema": {
7450
- "tableName": "pipeline_stages",
7451
- "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_stages\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"pipeline_id\" UUID NOT NULL,\n \"key\" TEXT NOT NULL DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"sort_order\" INTEGER DEFAULT 0,\n \"probability\" REAL DEFAULT 0,\n \"is_won\" BOOLEAN DEFAULT FALSE,\n \"is_lost\" BOOLEAN DEFAULT FALSE,\n \"metadata\" TEXT DEFAULT '{}'\n);",
7738
+ "tableName": "pipeline_stage_collections",
7739
+ "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_stage_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7452
7740
  "columns": {
7453
7741
  "id": {
7454
7742
  "type": "UUID",
@@ -7474,213 +7762,83 @@
7474
7762
  "type": "TIMESTAMP",
7475
7763
  "notNull": true,
7476
7764
  "default": "current_timestamp"
7477
- },
7478
- "tenant_id": {
7479
- "type": "UUID",
7480
- "referenceKind": "tenantId",
7481
- "notNull": false,
7482
- "unique": false
7483
- },
7484
- "pipeline_id": {
7485
- "type": "UUID",
7486
- "referenceKind": "foreignKey",
7487
- "notNull": true,
7488
- "unique": false
7489
- },
7490
- "key": {
7491
- "type": "TEXT",
7492
- "notNull": true,
7493
- "unique": false,
7494
- "default": ""
7495
- },
7496
- "name": {
7497
- "type": "TEXT",
7498
- "notNull": false,
7499
- "unique": false,
7500
- "default": ""
7501
- },
7502
- "sort_order": {
7503
- "type": "INTEGER",
7504
- "notNull": false,
7505
- "unique": false,
7506
- "default": 0
7507
- },
7508
- "probability": {
7509
- "type": "REAL",
7510
- "notNull": false,
7511
- "unique": false,
7512
- "default": 0
7513
- },
7514
- "is_won": {
7515
- "type": "BOOLEAN",
7516
- "notNull": false,
7517
- "unique": false,
7518
- "default": false
7519
- },
7520
- "is_lost": {
7521
- "type": "BOOLEAN",
7522
- "notNull": false,
7523
- "unique": false,
7524
- "default": false
7525
- },
7526
- "metadata": {
7527
- "type": "TEXT",
7528
- "notNull": false,
7529
- "unique": false,
7530
- "default": "{}"
7531
7765
  }
7532
7766
  },
7533
7767
  "indexes": [
7534
7768
  {
7535
- "name": "pipeline_stages_id_idx",
7769
+ "name": "pipeline_stage_collections_id_idx",
7536
7770
  "columns": [
7537
7771
  "id"
7538
7772
  ]
7539
7773
  },
7540
7774
  {
7541
- "name": "pipeline_stages_pipeline_id_key_idx",
7775
+ "name": "pipeline_stage_collections_slug_context_idx",
7542
7776
  "columns": [
7543
- "pipeline_id",
7544
- "key"
7777
+ "slug",
7778
+ "context"
7545
7779
  ],
7546
7780
  "unique": true
7547
7781
  }
7548
7782
  ],
7549
- "version": "bdb0cf4e"
7783
+ "version": "72c2d7b3"
7550
7784
  }
7551
7785
  },
7552
- "@happyvertical/smrt-sales:SalesActivity": {
7553
- "name": "salesactivity",
7554
- "className": "SalesActivity",
7555
- "qualifiedName": "@happyvertical/smrt-sales:SalesActivity",
7786
+ "@happyvertical/smrt-sales:SalesActivityCollection": {
7787
+ "name": "salesactivitycollection",
7788
+ "className": "SalesActivityCollection",
7789
+ "qualifiedName": "@happyvertical/smrt-sales:SalesActivityCollection",
7556
7790
  "collection": "salesactivities",
7557
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesActivity.ts",
7791
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesActivityCollection.ts",
7558
7792
  "packageName": "@happyvertical/smrt-sales",
7559
- "fields": {
7560
- "tenantId": {
7561
- "type": "text",
7562
- "required": false,
7563
- "_meta": {
7564
- "sqlType": "UUID",
7565
- "nullable": true,
7566
- "__tenancy": {
7567
- "isTenantIdField": true,
7568
- "autoFilter": true,
7569
- "required": false,
7570
- "autoPopulate": true,
7571
- "nullable": true,
7572
- "mode": "optional",
7573
- "field": "tenantId",
7574
- "allowSuperAdminBypass": false
7575
- }
7576
- }
7577
- },
7578
- "subjectKind": {
7579
- "type": "text",
7580
- "required": false,
7581
- "default": "lead"
7582
- },
7583
- "subjectId": {
7584
- "type": "text",
7585
- "required": true,
7586
- "default": "",
7587
- "_meta": {
7588
- "required": true
7589
- }
7590
- },
7591
- "activityKind": {
7592
- "type": "text",
7593
- "required": false,
7594
- "default": "note"
7595
- },
7596
- "summary": {
7597
- "type": "text",
7598
- "required": false,
7599
- "default": ""
7600
- },
7601
- "dueAt": {
7602
- "type": "datetime",
7603
- "required": false
7604
- },
7605
- "completedAt": {
7606
- "type": "datetime",
7607
- "required": false
7608
- },
7609
- "actorProfileId": {
7610
- "type": "crossPackageRef",
7611
- "required": false,
7612
- "related": "@happyvertical/smrt-profiles:Profile"
7613
- },
7614
- "metadata": {
7615
- "type": "text",
7616
- "required": false,
7617
- "default": "{}"
7618
- }
7619
- },
7793
+ "fields": {},
7620
7794
  "methods": {
7621
- "isOpenTask": {
7622
- "name": "isOpenTask",
7623
- "async": false,
7624
- "parameters": [],
7625
- "returnType": "boolean",
7626
- "isStatic": false,
7627
- "isPublic": true
7628
- },
7629
- "getMetadata": {
7630
- "name": "getMetadata",
7631
- "async": false,
7632
- "parameters": [],
7633
- "returnType": "Record<string>",
7634
- "isStatic": false,
7635
- "isPublic": true
7636
- },
7637
- "setMetadata": {
7638
- "name": "setMetadata",
7639
- "async": false,
7795
+ "findBySubject": {
7796
+ "name": "findBySubject",
7797
+ "async": true,
7640
7798
  "parameters": [
7641
7799
  {
7642
- "name": "metadata",
7643
- "type": "Record<string>",
7800
+ "name": "subjectKind",
7801
+ "type": "SalesActivitySubjectKind",
7802
+ "optional": false
7803
+ },
7804
+ {
7805
+ "name": "subjectId",
7806
+ "type": "string",
7644
7807
  "optional": false
7645
7808
  }
7646
7809
  ],
7647
- "returnType": "void",
7810
+ "returnType": "Promise<SalesActivity[]>",
7648
7811
  "isStatic": false,
7649
7812
  "isPublic": true
7650
- }
7651
- },
7652
- "decoratorConfig": {
7653
- "api": {
7654
- "include": [
7655
- "create",
7656
- "list",
7657
- "get"
7658
- ]
7659
- },
7660
- "mcp": {
7661
- "include": [
7662
- "list",
7663
- "create"
7664
- ]
7665
7813
  },
7666
- "cli": false,
7667
- "tenantScoped": {
7668
- "mode": "optional"
7814
+ "findOpenTasks": {
7815
+ "name": "findOpenTasks",
7816
+ "async": true,
7817
+ "parameters": [
7818
+ {
7819
+ "name": "subjectKind",
7820
+ "type": "SalesActivitySubjectKind",
7821
+ "optional": false
7822
+ },
7823
+ {
7824
+ "name": "subjectId",
7825
+ "type": "string",
7826
+ "optional": false
7827
+ }
7828
+ ],
7829
+ "returnType": "Promise<SalesActivity[]>",
7830
+ "isStatic": false,
7831
+ "isPublic": true
7669
7832
  }
7670
7833
  },
7671
- "extends": "SmrtObject",
7672
- "exportName": "SalesActivity",
7673
- "collectionExportName": "SalesActivityCollection",
7674
- "validationRules": [
7675
- {
7676
- "field": "subjectId",
7677
- "rule": "required",
7678
- "fieldType": "text"
7679
- }
7680
- ],
7834
+ "decoratorConfig": {},
7835
+ "extends": "SmrtCollection",
7836
+ "extendsTypeArg": "SalesActivity",
7837
+ "exportName": "SalesActivityCollection",
7838
+ "collectionExportName": "SalesActivityCollectionCollection",
7681
7839
  "schema": {
7682
- "tableName": "sales_activities",
7683
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activities\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"subject_kind\" TEXT DEFAULT 'lead',\n \"subject_id\" TEXT NOT NULL DEFAULT '',\n \"activity_kind\" TEXT DEFAULT 'note',\n \"summary\" TEXT DEFAULT '',\n \"due_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"actor_profile_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}'\n);",
7840
+ "tableName": "sales_activity_collections",
7841
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activity_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7684
7842
  "columns": {
7685
7843
  "id": {
7686
7844
  "type": "UUID",
@@ -7706,69 +7864,17 @@
7706
7864
  "type": "TIMESTAMP",
7707
7865
  "notNull": true,
7708
7866
  "default": "current_timestamp"
7709
- },
7710
- "tenant_id": {
7711
- "type": "UUID",
7712
- "referenceKind": "tenantId",
7713
- "notNull": false,
7714
- "unique": false
7715
- },
7716
- "subject_kind": {
7717
- "type": "TEXT",
7718
- "notNull": false,
7719
- "unique": false,
7720
- "default": "lead"
7721
- },
7722
- "subject_id": {
7723
- "type": "TEXT",
7724
- "notNull": true,
7725
- "unique": false,
7726
- "default": ""
7727
- },
7728
- "activity_kind": {
7729
- "type": "TEXT",
7730
- "notNull": false,
7731
- "unique": false,
7732
- "default": "note"
7733
- },
7734
- "summary": {
7735
- "type": "TEXT",
7736
- "notNull": false,
7737
- "unique": false,
7738
- "default": ""
7739
- },
7740
- "due_at": {
7741
- "type": "TIMESTAMP",
7742
- "notNull": false,
7743
- "unique": false
7744
- },
7745
- "completed_at": {
7746
- "type": "TIMESTAMP",
7747
- "notNull": false,
7748
- "unique": false
7749
- },
7750
- "actor_profile_id": {
7751
- "type": "UUID",
7752
- "referenceKind": "crossPackageRef",
7753
- "notNull": false,
7754
- "unique": false
7755
- },
7756
- "metadata": {
7757
- "type": "TEXT",
7758
- "notNull": false,
7759
- "unique": false,
7760
- "default": "{}"
7761
7867
  }
7762
7868
  },
7763
7869
  "indexes": [
7764
7870
  {
7765
- "name": "sales_activities_id_idx",
7871
+ "name": "sales_activity_collections_id_idx",
7766
7872
  "columns": [
7767
7873
  "id"
7768
7874
  ]
7769
7875
  },
7770
7876
  {
7771
- "name": "sales_activities_slug_context_idx",
7877
+ "name": "sales_activity_collections_slug_context_idx",
7772
7878
  "columns": [
7773
7879
  "slug",
7774
7880
  "context"
@@ -7776,119 +7882,49 @@
7776
7882
  "unique": true
7777
7883
  }
7778
7884
  ],
7779
- "version": "b3173b53"
7885
+ "version": "766a0235"
7780
7886
  }
7781
7887
  },
7782
- "@happyvertical/smrt-sales:SalesRepresentative": {
7783
- "name": "salesrepresentative",
7784
- "className": "SalesRepresentative",
7785
- "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
7888
+ "@happyvertical/smrt-sales:SalesRepresentativeCollection": {
7889
+ "name": "salesrepresentativecollection",
7890
+ "className": "SalesRepresentativeCollection",
7891
+ "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentativeCollection",
7786
7892
  "collection": "salesrepresentatives",
7787
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesRepresentative.ts",
7893
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesRepresentativeCollection.ts",
7788
7894
  "packageName": "@happyvertical/smrt-sales",
7789
- "fields": {
7790
- "tenantId": {
7791
- "type": "text",
7792
- "required": false,
7793
- "_meta": {
7794
- "sqlType": "UUID",
7795
- "nullable": true,
7796
- "__tenancy": {
7797
- "isTenantIdField": true,
7798
- "autoFilter": true,
7799
- "required": false,
7800
- "autoPopulate": true,
7801
- "nullable": true,
7802
- "mode": "optional",
7803
- "field": "tenantId",
7804
- "allowSuperAdminBypass": false
7805
- }
7806
- }
7807
- },
7808
- "profileId": {
7809
- "type": "crossPackageRef",
7810
- "required": false,
7811
- "related": "@happyvertical/smrt-profiles:Profile"
7812
- },
7813
- "earnerId": {
7814
- "type": "foreignKey",
7815
- "required": false,
7816
- "related": "Earner"
7817
- },
7818
- "status": {
7819
- "type": "text",
7820
- "required": false,
7821
- "default": "active"
7822
- },
7823
- "title": {
7824
- "type": "text",
7825
- "required": false,
7826
- "default": ""
7827
- },
7828
- "metadata": {
7829
- "type": "text",
7830
- "required": false,
7831
- "default": "{}"
7832
- }
7833
- },
7895
+ "fields": {},
7834
7896
  "methods": {
7835
- "isActive": {
7836
- "name": "isActive",
7837
- "async": false,
7838
- "parameters": [],
7839
- "returnType": "boolean",
7840
- "isStatic": false,
7841
- "isPublic": true
7842
- },
7843
- "getMetadata": {
7844
- "name": "getMetadata",
7845
- "async": false,
7846
- "parameters": [],
7847
- "returnType": "Record<string>",
7848
- "isStatic": false,
7849
- "isPublic": true
7850
- },
7851
- "setMetadata": {
7852
- "name": "setMetadata",
7853
- "async": false,
7897
+ "findByProfile": {
7898
+ "name": "findByProfile",
7899
+ "async": true,
7854
7900
  "parameters": [
7855
7901
  {
7856
- "name": "metadata",
7857
- "type": "Record<string>",
7902
+ "name": "profileId",
7903
+ "type": "string",
7858
7904
  "optional": false
7859
7905
  }
7860
7906
  ],
7861
- "returnType": "void",
7907
+ "returnType": "Promise<SalesRepresentative[]>",
7862
7908
  "isStatic": false,
7863
7909
  "isPublic": true
7864
- }
7865
- },
7866
- "decoratorConfig": {
7867
- "api": {
7868
- "include": [
7869
- "list",
7870
- "get",
7871
- "create",
7872
- "update"
7873
- ]
7874
- },
7875
- "mcp": {
7876
- "include": [
7877
- "list",
7878
- "get"
7879
- ]
7880
7910
  },
7881
- "cli": true,
7882
- "tenantScoped": {
7883
- "mode": "optional"
7911
+ "findActive": {
7912
+ "name": "findActive",
7913
+ "async": true,
7914
+ "parameters": [],
7915
+ "returnType": "Promise<SalesRepresentative[]>",
7916
+ "isStatic": false,
7917
+ "isPublic": true
7884
7918
  }
7885
7919
  },
7886
- "extends": "SmrtObject",
7887
- "exportName": "SalesRepresentative",
7888
- "collectionExportName": "SalesRepresentativeCollection",
7920
+ "decoratorConfig": {},
7921
+ "extends": "SmrtCollection",
7922
+ "extendsTypeArg": "SalesRepresentative",
7923
+ "exportName": "SalesRepresentativeCollection",
7924
+ "collectionExportName": "SalesRepresentativeCollectionCollection",
7889
7925
  "schema": {
7890
- "tableName": "sales_representatives",
7891
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representatives\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"profile_id\" UUID,\n \"earner_id\" UUID,\n \"status\" TEXT DEFAULT 'active',\n \"title\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
7926
+ "tableName": "sales_representative_collections",
7927
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representative_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7892
7928
  "columns": {
7893
7929
  "id": {
7894
7930
  "type": "UUID",
@@ -7914,53 +7950,17 @@
7914
7950
  "type": "TIMESTAMP",
7915
7951
  "notNull": true,
7916
7952
  "default": "current_timestamp"
7917
- },
7918
- "tenant_id": {
7919
- "type": "UUID",
7920
- "referenceKind": "tenantId",
7921
- "notNull": false,
7922
- "unique": false
7923
- },
7924
- "profile_id": {
7925
- "type": "UUID",
7926
- "referenceKind": "crossPackageRef",
7927
- "notNull": false,
7928
- "unique": false
7929
- },
7930
- "earner_id": {
7931
- "type": "UUID",
7932
- "referenceKind": "foreignKey",
7933
- "notNull": false,
7934
- "unique": false
7935
- },
7936
- "status": {
7937
- "type": "TEXT",
7938
- "notNull": false,
7939
- "unique": false,
7940
- "default": "active"
7941
- },
7942
- "title": {
7943
- "type": "TEXT",
7944
- "notNull": false,
7945
- "unique": false,
7946
- "default": ""
7947
- },
7948
- "metadata": {
7949
- "type": "TEXT",
7950
- "notNull": false,
7951
- "unique": false,
7952
- "default": "{}"
7953
7953
  }
7954
7954
  },
7955
7955
  "indexes": [
7956
7956
  {
7957
- "name": "sales_representatives_id_idx",
7957
+ "name": "sales_representative_collections_id_idx",
7958
7958
  "columns": [
7959
7959
  "id"
7960
7960
  ]
7961
7961
  },
7962
7962
  {
7963
- "name": "sales_representatives_slug_context_idx",
7963
+ "name": "sales_representative_collections_slug_context_idx",
7964
7964
  "columns": [
7965
7965
  "slug",
7966
7966
  "context"
@@ -7968,7 +7968,7 @@
7968
7968
  "unique": true
7969
7969
  }
7970
7970
  ],
7971
- "version": "7b67ed6e"
7971
+ "version": "6613c45d"
7972
7972
  }
7973
7973
  },
7974
7974
  "@happyvertical/smrt-sales:AttributionExceptionCollection": {