@happyvertical/smrt-sales 0.40.48 → 0.40.50

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": 1785787676930,
3
+ "timestamp": 1785810280905,
4
4
  "packageName": "@happyvertical/smrt-sales",
5
- "packageVersion": "0.40.48",
5
+ "packageVersion": "0.40.50",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-sales:AgreementExecutionCollection": {
8
8
  "name": "agreementexecutioncollection",
@@ -5444,222 +5444,94 @@
5444
5444
  "version": "aca82726"
5445
5445
  }
5446
5446
  },
5447
- "@happyvertical/smrt-sales:Lead": {
5448
- "name": "lead",
5449
- "className": "Lead",
5450
- "qualifiedName": "@happyvertical/smrt-sales:Lead",
5447
+ "@happyvertical/smrt-sales:LeadCollection": {
5448
+ "name": "leadcollection",
5449
+ "className": "LeadCollection",
5450
+ "qualifiedName": "@happyvertical/smrt-sales:LeadCollection",
5451
5451
  "collection": "leads",
5452
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/Lead.ts",
5452
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/LeadCollection.ts",
5453
5453
  "packageName": "@happyvertical/smrt-sales",
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
5470
- }
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
- },
5454
+ "fields": {},
5551
5455
  "methods": {
5552
- "isMerged": {
5553
- "name": "isMerged",
5554
- "async": false,
5555
- "parameters": [],
5556
- "returnType": "boolean",
5557
- "isStatic": false,
5558
- "isPublic": true
5559
- },
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,
5456
+ "findByStatus": {
5457
+ "name": "findByStatus",
5458
+ "async": true,
5579
5459
  "parameters": [
5580
5460
  {
5581
- "name": "context",
5582
- "type": "Record<string>",
5461
+ "name": "status",
5462
+ "type": "LeadStatus",
5583
5463
  "optional": false
5584
5464
  }
5585
5465
  ],
5586
- "returnType": "void",
5466
+ "returnType": "Promise<Lead[]>",
5587
5467
  "isStatic": false,
5588
5468
  "isPublic": true
5589
5469
  },
5590
- "getMetadata": {
5591
- "name": "getMetadata",
5592
- "async": false,
5593
- "parameters": [],
5594
- "returnType": "Record<string>",
5470
+ "findByOwner": {
5471
+ "name": "findByOwner",
5472
+ "async": true,
5473
+ "parameters": [
5474
+ {
5475
+ "name": "ownerRepId",
5476
+ "type": "string",
5477
+ "optional": false
5478
+ }
5479
+ ],
5480
+ "returnType": "Promise<Lead[]>",
5595
5481
  "isStatic": false,
5596
5482
  "isPublic": true
5597
5483
  },
5598
- "setMetadata": {
5599
- "name": "setMetadata",
5600
- "async": false,
5484
+ "qualify": {
5485
+ "name": "qualify",
5486
+ "async": true,
5601
5487
  "parameters": [
5602
5488
  {
5603
- "name": "metadata",
5604
- "type": "Record<string>",
5489
+ "name": "params",
5490
+ "type": "QualifyLeadParams",
5605
5491
  "optional": false
5606
5492
  }
5607
5493
  ],
5608
- "returnType": "void",
5494
+ "returnType": "Promise<Opportunity>",
5609
5495
  "isStatic": false,
5610
5496
  "isPublic": true
5611
5497
  },
5612
- "initialize": {
5613
- "name": "initialize",
5498
+ "mergeLeads": {
5499
+ "name": "mergeLeads",
5614
5500
  "async": true,
5615
- "parameters": [],
5616
- "returnType": "Promise",
5501
+ "parameters": [
5502
+ {
5503
+ "name": "params",
5504
+ "type": "MergeLeadsParams",
5505
+ "optional": false
5506
+ }
5507
+ ],
5508
+ "returnType": "Promise<MergeLeadsResult>",
5617
5509
  "isStatic": false,
5618
5510
  "isPublic": true
5619
5511
  },
5620
- "save": {
5621
- "name": "save",
5512
+ "activitiesIncludingMerged": {
5513
+ "name": "activitiesIncludingMerged",
5622
5514
  "async": true,
5623
- "parameters": [],
5624
- "returnType": "Promise",
5515
+ "parameters": [
5516
+ {
5517
+ "name": "leadId",
5518
+ "type": "string",
5519
+ "optional": false
5520
+ }
5521
+ ],
5522
+ "returnType": "Promise<SalesActivity[]>",
5625
5523
  "isStatic": false,
5626
5524
  "isPublic": true
5627
5525
  }
5628
5526
  },
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
- ],
5527
+ "decoratorConfig": {},
5528
+ "extends": "SmrtCollection",
5529
+ "extendsTypeArg": "Lead",
5530
+ "exportName": "LeadCollection",
5531
+ "collectionExportName": "LeadCollectionCollection",
5660
5532
  "schema": {
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);",
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);",
5663
5535
  "columns": {
5664
5536
  "id": {
5665
5537
  "type": "UUID",
@@ -5685,112 +5557,17 @@
5685
5557
  "type": "TIMESTAMP",
5686
5558
  "notNull": true,
5687
5559
  "default": "current_timestamp"
5688
- },
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
- ]
5560
+ }
5561
+ },
5562
+ "indexes": [
5563
+ {
5564
+ "name": "lead_collections_id_idx",
5565
+ "columns": [
5566
+ "id"
5567
+ ]
5791
5568
  },
5792
5569
  {
5793
- "name": "leads_slug_context_idx",
5570
+ "name": "lead_collections_slug_context_idx",
5794
5571
  "columns": [
5795
5572
  "slug",
5796
5573
  "context"
@@ -5798,490 +5575,69 @@
5798
5575
  "unique": true
5799
5576
  }
5800
5577
  ],
5801
- "version": "a1c330c8"
5578
+ "version": "0707eb13"
5802
5579
  }
5803
5580
  },
5804
- "@happyvertical/smrt-sales:Opportunity": {
5805
- "name": "opportunity",
5806
- "className": "Opportunity",
5807
- "qualifiedName": "@happyvertical/smrt-sales:Opportunity",
5581
+ "@happyvertical/smrt-sales:OpportunityCollection": {
5582
+ "name": "opportunitycollection",
5583
+ "className": "OpportunityCollection",
5584
+ "qualifiedName": "@happyvertical/smrt-sales:OpportunityCollection",
5808
5585
  "collection": "opportunities",
5809
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/Opportunity.ts",
5586
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityCollection.ts",
5810
5587
  "packageName": "@happyvertical/smrt-sales",
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
5827
- }
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
- },
5588
+ "fields": {},
5911
5589
  "methods": {
5912
- "isOpen": {
5913
- "name": "isOpen",
5914
- "async": false,
5915
- "parameters": [],
5916
- "returnType": "boolean",
5917
- "isStatic": false,
5918
- "isPublic": true
5919
- },
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,
5590
+ "findByLead": {
5591
+ "name": "findByLead",
5592
+ "async": true,
5939
5593
  "parameters": [
5940
5594
  {
5941
- "name": "metadata",
5942
- "type": "Record<string>",
5595
+ "name": "leadId",
5596
+ "type": "string",
5943
5597
  "optional": false
5944
5598
  }
5945
5599
  ],
5946
- "returnType": "void",
5947
- "isStatic": false,
5948
- "isPublic": true
5949
- },
5950
- "initialize": {
5951
- "name": "initialize",
5952
- "async": true,
5953
- "parameters": [],
5954
- "returnType": "Promise",
5600
+ "returnType": "Promise<Opportunity[]>",
5955
5601
  "isStatic": false,
5956
5602
  "isPublic": true
5957
5603
  },
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>",
6212
- "isStatic": false,
6213
- "isPublic": true
6214
- },
6215
- "setMetadata": {
6216
- "name": "setMetadata",
6217
- "async": false,
5604
+ "findOpen": {
5605
+ "name": "findOpen",
5606
+ "async": true,
6218
5607
  "parameters": [
6219
5608
  {
6220
- "name": "metadata",
6221
- "type": "Record<string>",
6222
- "optional": false
5609
+ "name": "pipelineId",
5610
+ "type": "string",
5611
+ "optional": true
6223
5612
  }
6224
5613
  ],
6225
- "returnType": "void",
5614
+ "returnType": "Promise<Opportunity[]>",
6226
5615
  "isStatic": false,
6227
5616
  "isPublic": true
6228
5617
  },
6229
- "save": {
6230
- "name": "save",
5618
+ "moveToStage": {
5619
+ "name": "moveToStage",
6231
5620
  "async": true,
6232
- "parameters": [],
6233
- "returnType": "Promise",
5621
+ "parameters": [
5622
+ {
5623
+ "name": "params",
5624
+ "type": "MoveToStageParams",
5625
+ "optional": false
5626
+ }
5627
+ ],
5628
+ "returnType": "Promise<Opportunity>",
6234
5629
  "isStatic": false,
6235
5630
  "isPublic": true
6236
5631
  }
6237
5632
  },
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
- ],
5633
+ "decoratorConfig": {},
5634
+ "extends": "SmrtCollection",
5635
+ "extendsTypeArg": "Opportunity",
5636
+ "exportName": "OpportunityCollection",
5637
+ "collectionExportName": "OpportunityCollectionCollection",
6282
5638
  "schema": {
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);",
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);",
6285
5641
  "columns": {
6286
5642
  "id": {
6287
5643
  "type": "UUID",
@@ -6307,188 +5663,187 @@
6307
5663
  "type": "TIMESTAMP",
6308
5664
  "notNull": true,
6309
5665
  "default": "current_timestamp"
5666
+ }
5667
+ },
5668
+ "indexes": [
5669
+ {
5670
+ "name": "opportunity_collections_id_idx",
5671
+ "columns": [
5672
+ "id"
5673
+ ]
6310
5674
  },
6311
- "tenant_id": {
6312
- "type": "UUID",
6313
- "referenceKind": "tenantId",
6314
- "notNull": false,
6315
- "unique": false
6316
- },
6317
- "opportunity_id": {
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": {
6318
5735
  "type": "UUID",
6319
- "referenceKind": "foreignKey",
6320
- "notNull": true,
6321
- "unique": false
5736
+ "primaryKey": true,
5737
+ "referenceKind": "id",
5738
+ "notNull": true
6322
5739
  },
6323
- "target_kind": {
5740
+ "slug": {
6324
5741
  "type": "TEXT",
6325
- "notNull": true,
6326
- "unique": false,
6327
- "default": ""
5742
+ "notNull": true
6328
5743
  },
6329
- "target_id": {
5744
+ "context": {
6330
5745
  "type": "TEXT",
6331
5746
  "notNull": true,
6332
- "unique": false,
6333
5747
  "default": ""
6334
5748
  },
6335
- "note": {
6336
- "type": "TEXT",
6337
- "notNull": false,
6338
- "unique": false,
6339
- "default": ""
5749
+ "created_at": {
5750
+ "type": "TIMESTAMP",
5751
+ "notNull": true,
5752
+ "default": "current_timestamp"
6340
5753
  },
6341
- "metadata": {
6342
- "type": "TEXT",
6343
- "notNull": false,
6344
- "unique": false,
6345
- "default": "{}"
5754
+ "updated_at": {
5755
+ "type": "TIMESTAMP",
5756
+ "notNull": true,
5757
+ "default": "current_timestamp"
6346
5758
  }
6347
5759
  },
6348
5760
  "indexes": [
6349
5761
  {
6350
- "name": "opportunity_conversions_id_idx",
5762
+ "name": "opportunity_conversion_collections_id_idx",
6351
5763
  "columns": [
6352
5764
  "id"
6353
5765
  ]
6354
5766
  },
6355
5767
  {
6356
- "name": "opportunity_conversions_opportunity_id_target_kind_idx",
5768
+ "name": "opportunity_conversion_collections_slug_context_idx",
6357
5769
  "columns": [
6358
- "opportunity_id",
6359
- "target_kind",
6360
- "target_id"
5770
+ "slug",
5771
+ "context"
6361
5772
  ],
6362
5773
  "unique": true
6363
5774
  }
6364
5775
  ],
6365
- "version": "82c29042"
5776
+ "version": "7e30ff1b"
6366
5777
  }
6367
5778
  },
6368
- "@happyvertical/smrt-sales:PipelineDefinition": {
6369
- "name": "pipelinedefinition",
6370
- "className": "PipelineDefinition",
6371
- "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
5779
+ "@happyvertical/smrt-sales:PipelineDefinitionCollection": {
5780
+ "name": "pipelinedefinitioncollection",
5781
+ "className": "PipelineDefinitionCollection",
5782
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
6372
5783
  "collection": "pipelinedefinitions",
6373
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineDefinition.ts",
6374
- "packageName": "@happyvertical/smrt-sales",
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
6391
- }
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
- },
5784
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineDefinitionCollection.ts",
5785
+ "packageName": "@happyvertical/smrt-sales",
5786
+ "fields": {},
6423
5787
  "methods": {
6424
- "isActive": {
6425
- "name": "isActive",
6426
- "async": false,
6427
- "parameters": [],
6428
- "returnType": "boolean",
5788
+ "findByKey": {
5789
+ "name": "findByKey",
5790
+ "async": true,
5791
+ "parameters": [
5792
+ {
5793
+ "name": "key",
5794
+ "type": "string",
5795
+ "optional": false
5796
+ }
5797
+ ],
5798
+ "returnType": "Promise<PipelineDefinition | null>",
6429
5799
  "isStatic": false,
6430
5800
  "isPublic": true
6431
5801
  },
6432
- "getMetadata": {
6433
- "name": "getMetadata",
6434
- "async": false,
5802
+ "findDefault": {
5803
+ "name": "findDefault",
5804
+ "async": true,
6435
5805
  "parameters": [],
6436
- "returnType": "Record<string>",
5806
+ "returnType": "Promise<PipelineDefinition | null>",
6437
5807
  "isStatic": false,
6438
5808
  "isPublic": true
6439
5809
  },
6440
- "setMetadata": {
6441
- "name": "setMetadata",
6442
- "async": false,
5810
+ "getStages": {
5811
+ "name": "getStages",
5812
+ "async": true,
6443
5813
  "parameters": [
6444
5814
  {
6445
- "name": "metadata",
6446
- "type": "Record<string>",
5815
+ "name": "pipelineId",
5816
+ "type": "string",
6447
5817
  "optional": false
6448
5818
  }
6449
5819
  ],
6450
- "returnType": "void",
5820
+ "returnType": "Promise<PipelineStage[]>",
6451
5821
  "isStatic": false,
6452
5822
  "isPublic": true
6453
- }
6454
- },
6455
- "decoratorConfig": {
6456
- "api": {
6457
- "include": [
6458
- "list",
6459
- "get",
6460
- "create",
6461
- "update"
6462
- ]
6463
5823
  },
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"
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
6477
5837
  }
6478
5838
  },
6479
- "extends": "SmrtObject",
6480
- "exportName": "PipelineDefinition",
6481
- "collectionExportName": "PipelineDefinitionCollection",
6482
- "validationRules": [
6483
- {
6484
- "field": "key",
6485
- "rule": "required",
6486
- "fieldType": "text"
6487
- }
6488
- ],
5839
+ "decoratorConfig": {},
5840
+ "extends": "SmrtCollection",
5841
+ "extendsTypeArg": "PipelineDefinition",
5842
+ "exportName": "PipelineDefinitionCollection",
5843
+ "collectionExportName": "PipelineDefinitionCollectionCollection",
6489
5844
  "schema": {
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);",
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);",
6492
5847
  "columns": {
6493
5848
  "id": {
6494
5849
  "type": "UUID",
@@ -6514,210 +5869,78 @@
6514
5869
  "type": "TIMESTAMP",
6515
5870
  "notNull": true,
6516
5871
  "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": "{}"
6553
5872
  }
6554
5873
  },
6555
5874
  "indexes": [
6556
5875
  {
6557
- "name": "pipeline_definitions_id_idx",
5876
+ "name": "pipeline_definition_collections_id_idx",
6558
5877
  "columns": [
6559
5878
  "id"
6560
5879
  ]
6561
5880
  },
6562
5881
  {
6563
- "name": "pipeline_definitions_tenant_id_key_idx",
5882
+ "name": "pipeline_definition_collections_slug_context_idx",
6564
5883
  "columns": [
6565
- "tenant_id",
6566
- "key"
5884
+ "slug",
5885
+ "context"
6567
5886
  ],
6568
5887
  "unique": true
6569
5888
  }
6570
5889
  ],
6571
- "version": "5e3ace6c"
5890
+ "version": "f85d1436"
6572
5891
  }
6573
5892
  },
6574
- "@happyvertical/smrt-sales:PipelineStage": {
6575
- "name": "pipelinestage",
6576
- "className": "PipelineStage",
6577
- "qualifiedName": "@happyvertical/smrt-sales:PipelineStage",
5893
+ "@happyvertical/smrt-sales:PipelineStageCollection": {
5894
+ "name": "pipelinestagecollection",
5895
+ "className": "PipelineStageCollection",
5896
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineStageCollection",
6578
5897
  "collection": "pipelinestages",
6579
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineStage.ts",
5898
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineStageCollection.ts",
6580
5899
  "packageName": "@happyvertical/smrt-sales",
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
6597
- }
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
- },
5900
+ "fields": {},
6647
5901
  "methods": {
6648
- "isTerminal": {
6649
- "name": "isTerminal",
6650
- "async": false,
6651
- "parameters": [],
6652
- "returnType": "boolean",
6653
- "isStatic": false,
6654
- "isPublic": true
6655
- },
6656
- "getMetadata": {
6657
- "name": "getMetadata",
6658
- "async": false,
6659
- "parameters": [],
6660
- "returnType": "Record<string>",
5902
+ "findByPipeline": {
5903
+ "name": "findByPipeline",
5904
+ "async": true,
5905
+ "parameters": [
5906
+ {
5907
+ "name": "pipelineId",
5908
+ "type": "string",
5909
+ "optional": false
5910
+ }
5911
+ ],
5912
+ "returnType": "Promise<PipelineStage[]>",
6661
5913
  "isStatic": false,
6662
5914
  "isPublic": true
6663
5915
  },
6664
- "setMetadata": {
6665
- "name": "setMetadata",
6666
- "async": false,
5916
+ "findByKey": {
5917
+ "name": "findByKey",
5918
+ "async": true,
6667
5919
  "parameters": [
6668
5920
  {
6669
- "name": "metadata",
6670
- "type": "Record<string>",
5921
+ "name": "pipelineId",
5922
+ "type": "string",
5923
+ "optional": false
5924
+ },
5925
+ {
5926
+ "name": "key",
5927
+ "type": "string",
6671
5928
  "optional": false
6672
5929
  }
6673
5930
  ],
6674
- "returnType": "void",
5931
+ "returnType": "Promise<PipelineStage | null>",
6675
5932
  "isStatic": false,
6676
5933
  "isPublic": true
6677
5934
  }
6678
5935
  },
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
- ],
5936
+ "decoratorConfig": {},
5937
+ "extends": "SmrtCollection",
5938
+ "extendsTypeArg": "PipelineStage",
5939
+ "exportName": "PipelineStageCollection",
5940
+ "collectionExportName": "PipelineStageCollectionCollection",
6718
5941
  "schema": {
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);",
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);",
6721
5944
  "columns": {
6722
5945
  "id": {
6723
5946
  "type": "UUID",
@@ -6743,221 +5966,169 @@
6743
5966
  "type": "TIMESTAMP",
6744
5967
  "notNull": true,
6745
5968
  "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": "{}"
6800
5969
  }
6801
5970
  },
6802
5971
  "indexes": [
6803
5972
  {
6804
- "name": "pipeline_stages_id_idx",
5973
+ "name": "pipeline_stage_collections_id_idx",
6805
5974
  "columns": [
6806
5975
  "id"
6807
5976
  ]
6808
5977
  },
6809
5978
  {
6810
- "name": "pipeline_stages_pipeline_id_key_idx",
5979
+ "name": "pipeline_stage_collections_slug_context_idx",
6811
5980
  "columns": [
6812
- "pipeline_id",
6813
- "key"
5981
+ "slug",
5982
+ "context"
6814
5983
  ],
6815
5984
  "unique": true
6816
5985
  }
6817
5986
  ],
6818
- "version": "bdb0cf4e"
5987
+ "version": "72c2d7b3"
6819
5988
  }
6820
5989
  },
6821
- "@happyvertical/smrt-sales:SalesActivity": {
6822
- "name": "salesactivity",
6823
- "className": "SalesActivity",
6824
- "qualifiedName": "@happyvertical/smrt-sales:SalesActivity",
5990
+ "@happyvertical/smrt-sales:SalesActivityCollection": {
5991
+ "name": "salesactivitycollection",
5992
+ "className": "SalesActivityCollection",
5993
+ "qualifiedName": "@happyvertical/smrt-sales:SalesActivityCollection",
6825
5994
  "collection": "salesactivities",
6826
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesActivity.ts",
5995
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesActivityCollection.ts",
6827
5996
  "packageName": "@happyvertical/smrt-sales",
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
6844
- }
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
- },
5997
+ "fields": {},
6889
5998
  "methods": {
6890
- "isOpenTask": {
6891
- "name": "isOpenTask",
6892
- "async": false,
6893
- "parameters": [],
6894
- "returnType": "boolean",
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
6012
+ }
6013
+ ],
6014
+ "returnType": "Promise<SalesActivity[]>",
6895
6015
  "isStatic": false,
6896
6016
  "isPublic": true
6897
6017
  },
6898
- "getMetadata": {
6899
- "name": "getMetadata",
6900
- "async": false,
6901
- "parameters": [],
6902
- "returnType": "Record<string>",
6018
+ "findOpenTasks": {
6019
+ "name": "findOpenTasks",
6020
+ "async": true,
6021
+ "parameters": [
6022
+ {
6023
+ "name": "subjectKind",
6024
+ "type": "SalesActivitySubjectKind",
6025
+ "optional": false
6026
+ },
6027
+ {
6028
+ "name": "subjectId",
6029
+ "type": "string",
6030
+ "optional": false
6031
+ }
6032
+ ],
6033
+ "returnType": "Promise<SalesActivity[]>",
6903
6034
  "isStatic": false,
6904
6035
  "isPublic": true
6036
+ }
6037
+ },
6038
+ "decoratorConfig": {},
6039
+ "extends": "SmrtCollection",
6040
+ "extendsTypeArg": "SalesActivity",
6041
+ "exportName": "SalesActivityCollection",
6042
+ "collectionExportName": "SalesActivityCollectionCollection",
6043
+ "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);",
6046
+ "columns": {
6047
+ "id": {
6048
+ "type": "UUID",
6049
+ "primaryKey": true,
6050
+ "referenceKind": "id",
6051
+ "notNull": true
6052
+ },
6053
+ "slug": {
6054
+ "type": "TEXT",
6055
+ "notNull": true
6056
+ },
6057
+ "context": {
6058
+ "type": "TEXT",
6059
+ "notNull": true,
6060
+ "default": ""
6061
+ },
6062
+ "created_at": {
6063
+ "type": "TIMESTAMP",
6064
+ "notNull": true,
6065
+ "default": "current_timestamp"
6066
+ },
6067
+ "updated_at": {
6068
+ "type": "TIMESTAMP",
6069
+ "notNull": true,
6070
+ "default": "current_timestamp"
6071
+ }
6905
6072
  },
6906
- "setMetadata": {
6907
- "name": "setMetadata",
6908
- "async": false,
6073
+ "indexes": [
6074
+ {
6075
+ "name": "sales_activity_collections_id_idx",
6076
+ "columns": [
6077
+ "id"
6078
+ ]
6079
+ },
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,
6909
6104
  "parameters": [
6910
6105
  {
6911
- "name": "metadata",
6912
- "type": "Record<string>",
6106
+ "name": "profileId",
6107
+ "type": "string",
6913
6108
  "optional": false
6914
6109
  }
6915
6110
  ],
6916
- "returnType": "void",
6111
+ "returnType": "Promise<SalesRepresentative[]>",
6917
6112
  "isStatic": false,
6918
6113
  "isPublic": true
6919
6114
  },
6920
- "save": {
6921
- "name": "save",
6115
+ "findActive": {
6116
+ "name": "findActive",
6922
6117
  "async": true,
6923
6118
  "parameters": [],
6924
- "returnType": "Promise",
6119
+ "returnType": "Promise<SalesRepresentative[]>",
6925
6120
  "isStatic": false,
6926
6121
  "isPublic": true
6927
6122
  }
6928
6123
  },
6929
- "decoratorConfig": {
6930
- "api": {
6931
- "include": [
6932
- "create",
6933
- "list",
6934
- "get"
6935
- ]
6936
- },
6937
- "mcp": {
6938
- "include": [
6939
- "list",
6940
- "create"
6941
- ]
6942
- },
6943
- "cli": false,
6944
- "tenantScoped": {
6945
- "mode": "optional"
6946
- }
6947
- },
6948
- "extends": "SmrtObject",
6949
- "exportName": "SalesActivity",
6950
- "collectionExportName": "SalesActivityCollection",
6951
- "validationRules": [
6952
- {
6953
- "field": "subjectId",
6954
- "rule": "required",
6955
- "fieldType": "text"
6956
- }
6957
- ],
6124
+ "decoratorConfig": {},
6125
+ "extends": "SmrtCollection",
6126
+ "extendsTypeArg": "SalesRepresentative",
6127
+ "exportName": "SalesRepresentativeCollection",
6128
+ "collectionExportName": "SalesRepresentativeCollectionCollection",
6958
6129
  "schema": {
6959
- "tableName": "sales_activities",
6960
- "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);",
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);",
6961
6132
  "columns": {
6962
6133
  "id": {
6963
6134
  "type": "UUID",
@@ -6983,69 +6154,17 @@
6983
6154
  "type": "TIMESTAMP",
6984
6155
  "notNull": true,
6985
6156
  "default": "current_timestamp"
6986
- },
6987
- "tenant_id": {
6988
- "type": "UUID",
6989
- "referenceKind": "tenantId",
6990
- "notNull": false,
6991
- "unique": false
6992
- },
6993
- "subject_kind": {
6994
- "type": "TEXT",
6995
- "notNull": false,
6996
- "unique": false,
6997
- "default": "lead"
6998
- },
6999
- "subject_id": {
7000
- "type": "TEXT",
7001
- "notNull": true,
7002
- "unique": false,
7003
- "default": ""
7004
- },
7005
- "activity_kind": {
7006
- "type": "TEXT",
7007
- "notNull": false,
7008
- "unique": false,
7009
- "default": "note"
7010
- },
7011
- "summary": {
7012
- "type": "TEXT",
7013
- "notNull": false,
7014
- "unique": false,
7015
- "default": ""
7016
- },
7017
- "due_at": {
7018
- "type": "TIMESTAMP",
7019
- "notNull": false,
7020
- "unique": false
7021
- },
7022
- "completed_at": {
7023
- "type": "TIMESTAMP",
7024
- "notNull": false,
7025
- "unique": false
7026
- },
7027
- "actor_profile_id": {
7028
- "type": "UUID",
7029
- "referenceKind": "crossPackageRef",
7030
- "notNull": false,
7031
- "unique": false
7032
- },
7033
- "metadata": {
7034
- "type": "TEXT",
7035
- "notNull": false,
7036
- "unique": false,
7037
- "default": "{}"
7038
6157
  }
7039
6158
  },
7040
6159
  "indexes": [
7041
6160
  {
7042
- "name": "sales_activities_id_idx",
6161
+ "name": "sales_representative_collections_id_idx",
7043
6162
  "columns": [
7044
6163
  "id"
7045
6164
  ]
7046
6165
  },
7047
6166
  {
7048
- "name": "sales_activities_slug_context_idx",
6167
+ "name": "sales_representative_collections_slug_context_idx",
7049
6168
  "columns": [
7050
6169
  "slug",
7051
6170
  "context"
@@ -7053,15 +6172,15 @@
7053
6172
  "unique": true
7054
6173
  }
7055
6174
  ],
7056
- "version": "b3173b53"
6175
+ "version": "6613c45d"
7057
6176
  }
7058
6177
  },
7059
- "@happyvertical/smrt-sales:SalesRepresentative": {
7060
- "name": "salesrepresentative",
7061
- "className": "SalesRepresentative",
7062
- "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
7063
- "collection": "salesrepresentatives",
7064
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesRepresentative.ts",
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",
7065
6184
  "packageName": "@happyvertical/smrt-sales",
7066
6185
  "fields": {
7067
6186
  "tenantId": {
@@ -7082,26 +6201,78 @@
7082
6201
  }
7083
6202
  }
7084
6203
  },
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
+ },
7085
6232
  "profileId": {
7086
6233
  "type": "crossPackageRef",
7087
6234
  "required": false,
7088
6235
  "related": "@happyvertical/smrt-profiles:Profile"
7089
6236
  },
7090
- "earnerId": {
6237
+ "ownerRepId": {
7091
6238
  "type": "foreignKey",
7092
6239
  "required": false,
7093
- "related": "Earner"
6240
+ "related": "SalesRepresentative"
7094
6241
  },
7095
6242
  "status": {
7096
6243
  "type": "text",
7097
6244
  "required": false,
7098
- "default": "active"
6245
+ "default": "new"
7099
6246
  },
7100
- "title": {
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": "{}"
6261
+ },
6262
+ "intakeRef": {
7101
6263
  "type": "text",
7102
6264
  "required": false,
7103
6265
  "default": ""
7104
6266
  },
6267
+ "mergedIntoId": {
6268
+ "type": "foreignKey",
6269
+ "required": false,
6270
+ "related": "Lead"
6271
+ },
6272
+ "qualifiedAt": {
6273
+ "type": "datetime",
6274
+ "required": false
6275
+ },
7105
6276
  "metadata": {
7106
6277
  "type": "text",
7107
6278
  "required": false,
@@ -7109,14 +6280,44 @@
7109
6280
  }
7110
6281
  },
7111
6282
  "methods": {
7112
- "isActive": {
7113
- "name": "isActive",
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",
7114
6293
  "async": false,
7115
6294
  "parameters": [],
7116
6295
  "returnType": "boolean",
7117
6296
  "isStatic": false,
7118
6297
  "isPublic": true
7119
6298
  },
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
+ },
7120
6321
  "getMetadata": {
7121
6322
  "name": "getMetadata",
7122
6323
  "async": false,
@@ -7138,6 +6339,22 @@
7138
6339
  "returnType": "void",
7139
6340
  "isStatic": false,
7140
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",
6356
+ "isStatic": false,
6357
+ "isPublic": true
7141
6358
  }
7142
6359
  },
7143
6360
  "decoratorConfig": {
@@ -7152,7 +6369,8 @@
7152
6369
  "mcp": {
7153
6370
  "include": [
7154
6371
  "list",
7155
- "get"
6372
+ "get",
6373
+ "create"
7156
6374
  ]
7157
6375
  },
7158
6376
  "cli": true,
@@ -7161,11 +6379,18 @@
7161
6379
  }
7162
6380
  },
7163
6381
  "extends": "SmrtObject",
7164
- "exportName": "SalesRepresentative",
7165
- "collectionExportName": "SalesRepresentativeCollection",
6382
+ "exportName": "Lead",
6383
+ "collectionExportName": "LeadCollection",
6384
+ "validationRules": [
6385
+ {
6386
+ "field": "name",
6387
+ "rule": "required",
6388
+ "fieldType": "text"
6389
+ }
6390
+ ],
7166
6391
  "schema": {
7167
- "tableName": "sales_representatives",
7168
- "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);",
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);",
7169
6394
  "columns": {
7170
6395
  "id": {
7171
6396
  "type": "UUID",
@@ -7198,13 +6423,43 @@
7198
6423
  "notNull": false,
7199
6424
  "unique": false
7200
6425
  },
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
+ },
7201
6456
  "profile_id": {
7202
6457
  "type": "UUID",
7203
6458
  "referenceKind": "crossPackageRef",
7204
6459
  "notNull": false,
7205
6460
  "unique": false
7206
6461
  },
7207
- "earner_id": {
6462
+ "owner_rep_id": {
7208
6463
  "type": "UUID",
7209
6464
  "referenceKind": "foreignKey",
7210
6465
  "notNull": false,
@@ -7214,14 +6469,43 @@
7214
6469
  "type": "TEXT",
7215
6470
  "notNull": false,
7216
6471
  "unique": false,
7217
- "default": "active"
6472
+ "default": "new"
7218
6473
  },
7219
- "title": {
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": "{}"
6491
+ },
6492
+ "intake_ref": {
7220
6493
  "type": "TEXT",
7221
6494
  "notNull": false,
7222
6495
  "unique": false,
7223
6496
  "default": ""
7224
6497
  },
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
+ },
7225
6509
  "metadata": {
7226
6510
  "type": "TEXT",
7227
6511
  "notNull": false,
@@ -7231,13 +6515,13 @@
7231
6515
  },
7232
6516
  "indexes": [
7233
6517
  {
7234
- "name": "sales_representatives_id_idx",
6518
+ "name": "leads_id_idx",
7235
6519
  "columns": [
7236
6520
  "id"
7237
6521
  ]
7238
6522
  },
7239
6523
  {
7240
- "name": "sales_representatives_slug_context_idx",
6524
+ "name": "leads_slug_context_idx",
7241
6525
  "columns": [
7242
6526
  "slug",
7243
6527
  "context"
@@ -7245,97 +6529,205 @@
7245
6529
  "unique": true
7246
6530
  }
7247
6531
  ],
7248
- "version": "7b67ed6e"
6532
+ "version": "a1c330c8"
7249
6533
  }
7250
6534
  },
7251
- "@happyvertical/smrt-sales:LeadCollection": {
7252
- "name": "leadcollection",
7253
- "className": "LeadCollection",
7254
- "qualifiedName": "@happyvertical/smrt-sales:LeadCollection",
7255
- "collection": "leads",
7256
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/LeadCollection.ts",
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",
7257
6541
  "packageName": "@happyvertical/smrt-sales",
7258
- "fields": {},
7259
- "methods": {
7260
- "findByStatus": {
7261
- "name": "findByStatus",
7262
- "async": true,
7263
- "parameters": [
7264
- {
7265
- "name": "status",
7266
- "type": "LeadStatus",
7267
- "optional": false
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
7268
6558
  }
7269
- ],
7270
- "returnType": "Promise<Lead[]>",
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
+ },
6642
+ "methods": {
6643
+ "isOpen": {
6644
+ "name": "isOpen",
6645
+ "async": false,
6646
+ "parameters": [],
6647
+ "returnType": "boolean",
7271
6648
  "isStatic": false,
7272
6649
  "isPublic": true
7273
6650
  },
7274
- "findByOwner": {
7275
- "name": "findByOwner",
7276
- "async": true,
7277
- "parameters": [
7278
- {
7279
- "name": "ownerRepId",
7280
- "type": "string",
7281
- "optional": false
7282
- }
7283
- ],
7284
- "returnType": "Promise<Lead[]>",
6651
+ "isClosed": {
6652
+ "name": "isClosed",
6653
+ "async": false,
6654
+ "parameters": [],
6655
+ "returnType": "boolean",
6656
+ "isStatic": false,
6657
+ "isPublic": true
6658
+ },
6659
+ "getMetadata": {
6660
+ "name": "getMetadata",
6661
+ "async": false,
6662
+ "parameters": [],
6663
+ "returnType": "Record<string>",
7285
6664
  "isStatic": false,
7286
6665
  "isPublic": true
7287
6666
  },
7288
- "qualify": {
7289
- "name": "qualify",
7290
- "async": true,
6667
+ "setMetadata": {
6668
+ "name": "setMetadata",
6669
+ "async": false,
7291
6670
  "parameters": [
7292
6671
  {
7293
- "name": "params",
7294
- "type": "QualifyLeadParams",
6672
+ "name": "metadata",
6673
+ "type": "Record<string>",
7295
6674
  "optional": false
7296
6675
  }
7297
6676
  ],
7298
- "returnType": "Promise<Opportunity>",
6677
+ "returnType": "void",
7299
6678
  "isStatic": false,
7300
6679
  "isPublic": true
7301
6680
  },
7302
- "mergeLeads": {
7303
- "name": "mergeLeads",
6681
+ "initialize": {
6682
+ "name": "initialize",
7304
6683
  "async": true,
7305
- "parameters": [
7306
- {
7307
- "name": "params",
7308
- "type": "MergeLeadsParams",
7309
- "optional": false
7310
- }
7311
- ],
7312
- "returnType": "Promise<MergeLeadsResult>",
6684
+ "parameters": [],
6685
+ "returnType": "Promise",
7313
6686
  "isStatic": false,
7314
6687
  "isPublic": true
7315
6688
  },
7316
- "activitiesIncludingMerged": {
7317
- "name": "activitiesIncludingMerged",
6689
+ "save": {
6690
+ "name": "save",
7318
6691
  "async": true,
7319
- "parameters": [
7320
- {
7321
- "name": "leadId",
7322
- "type": "string",
7323
- "optional": false
7324
- }
7325
- ],
7326
- "returnType": "Promise<SalesActivity[]>",
6692
+ "parameters": [],
6693
+ "returnType": "Promise",
7327
6694
  "isStatic": false,
7328
6695
  "isPublic": true
7329
6696
  }
7330
6697
  },
7331
- "decoratorConfig": {},
7332
- "extends": "SmrtCollection",
7333
- "extendsTypeArg": "Lead",
7334
- "exportName": "LeadCollection",
7335
- "collectionExportName": "LeadCollectionCollection",
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
+ ],
7336
6728
  "schema": {
7337
- "tableName": "lead_collections",
7338
- "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);",
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);",
7339
6731
  "columns": {
7340
6732
  "id": {
7341
6733
  "type": "UUID",
@@ -7361,123 +6753,116 @@
7361
6753
  "type": "TIMESTAMP",
7362
6754
  "notNull": true,
7363
6755
  "default": "current_timestamp"
7364
- }
7365
- },
7366
- "indexes": [
7367
- {
7368
- "name": "lead_collections_id_idx",
7369
- "columns": [
7370
- "id"
7371
- ]
7372
6756
  },
7373
- {
7374
- "name": "lead_collections_slug_context_idx",
7375
- "columns": [
7376
- "slug",
7377
- "context"
7378
- ],
7379
- "unique": true
7380
- }
7381
- ],
7382
- "version": "0707eb13"
7383
- }
7384
- },
7385
- "@happyvertical/smrt-sales:OpportunityCollection": {
7386
- "name": "opportunitycollection",
7387
- "className": "OpportunityCollection",
7388
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityCollection",
7389
- "collection": "opportunities",
7390
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityCollection.ts",
7391
- "packageName": "@happyvertical/smrt-sales",
7392
- "fields": {},
7393
- "methods": {
7394
- "findByLead": {
7395
- "name": "findByLead",
7396
- "async": true,
7397
- "parameters": [
7398
- {
7399
- "name": "leadId",
7400
- "type": "string",
7401
- "optional": false
7402
- }
7403
- ],
7404
- "returnType": "Promise<Opportunity[]>",
7405
- "isStatic": false,
7406
- "isPublic": true
7407
- },
7408
- "findOpen": {
7409
- "name": "findOpen",
7410
- "async": true,
7411
- "parameters": [
7412
- {
7413
- "name": "pipelineId",
7414
- "type": "string",
7415
- "optional": true
7416
- }
7417
- ],
7418
- "returnType": "Promise<Opportunity[]>",
7419
- "isStatic": false,
7420
- "isPublic": true
7421
- },
7422
- "moveToStage": {
7423
- "name": "moveToStage",
7424
- "async": true,
7425
- "parameters": [
7426
- {
7427
- "name": "params",
7428
- "type": "MoveToStageParams",
7429
- "optional": false
7430
- }
7431
- ],
7432
- "returnType": "Promise<Opportunity>",
7433
- "isStatic": false,
7434
- "isPublic": true
7435
- }
7436
- },
7437
- "decoratorConfig": {},
7438
- "extends": "SmrtCollection",
7439
- "extendsTypeArg": "Opportunity",
7440
- "exportName": "OpportunityCollection",
7441
- "collectionExportName": "OpportunityCollectionCollection",
7442
- "schema": {
7443
- "tableName": "opportunity_collections",
7444
- "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);",
7445
- "columns": {
7446
- "id": {
6757
+ "tenant_id": {
7447
6758
  "type": "UUID",
7448
- "primaryKey": true,
7449
- "referenceKind": "id",
7450
- "notNull": true
6759
+ "referenceKind": "tenantId",
6760
+ "notNull": false,
6761
+ "unique": false
7451
6762
  },
7452
- "slug": {
6763
+ "name": {
7453
6764
  "type": "TEXT",
7454
- "notNull": true
6765
+ "notNull": true,
6766
+ "unique": false,
6767
+ "default": ""
7455
6768
  },
7456
- "context": {
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": {
7457
6800
  "type": "TEXT",
7458
- "notNull": true,
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,
7459
6826
  "default": ""
7460
6827
  },
7461
- "created_at": {
6828
+ "won_at": {
7462
6829
  "type": "TIMESTAMP",
7463
- "notNull": true,
7464
- "default": "current_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": ""
7465
6849
  },
7466
- "updated_at": {
7467
- "type": "TIMESTAMP",
7468
- "notNull": true,
7469
- "default": "current_timestamp"
6850
+ "metadata": {
6851
+ "type": "TEXT",
6852
+ "notNull": false,
6853
+ "unique": false,
6854
+ "default": "{}"
7470
6855
  }
7471
6856
  },
7472
6857
  "indexes": [
7473
6858
  {
7474
- "name": "opportunity_collections_id_idx",
6859
+ "name": "opportunities_id_idx",
7475
6860
  "columns": [
7476
6861
  "id"
7477
6862
  ]
7478
6863
  },
7479
6864
  {
7480
- "name": "opportunity_collections_slug_context_idx",
6865
+ "name": "opportunities_slug_context_idx",
7481
6866
  "columns": [
7482
6867
  "slug",
7483
6868
  "context"
@@ -7485,55 +6870,149 @@
7485
6870
  "unique": true
7486
6871
  }
7487
6872
  ],
7488
- "version": "ebcdf63b"
6873
+ "version": "a403c6cf"
7489
6874
  }
7490
6875
  },
7491
- "@happyvertical/smrt-sales:OpportunityConversionCollection": {
7492
- "name": "opportunityconversioncollection",
7493
- "className": "OpportunityConversionCollection",
7494
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversionCollection",
6876
+ "@happyvertical/smrt-sales:OpportunityConversion": {
6877
+ "name": "opportunityconversion",
6878
+ "className": "OpportunityConversion",
6879
+ "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversion",
7495
6880
  "collection": "opportunityconversions",
7496
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityConversionCollection.ts",
6881
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/OpportunityConversion.ts",
7497
6882
  "packageName": "@happyvertical/smrt-sales",
7498
- "fields": {},
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
+ },
7499
6937
  "methods": {
7500
- "findByOpportunity": {
7501
- "name": "findByOpportunity",
7502
- "async": true,
6938
+ "getMetadata": {
6939
+ "name": "getMetadata",
6940
+ "async": false,
6941
+ "parameters": [],
6942
+ "returnType": "Record<string>",
6943
+ "isStatic": false,
6944
+ "isPublic": true
6945
+ },
6946
+ "setMetadata": {
6947
+ "name": "setMetadata",
6948
+ "async": false,
7503
6949
  "parameters": [
7504
6950
  {
7505
- "name": "opportunityId",
7506
- "type": "string",
6951
+ "name": "metadata",
6952
+ "type": "Record<string>",
7507
6953
  "optional": false
7508
6954
  }
7509
6955
  ],
7510
- "returnType": "Promise<OpportunityConversion[]>",
6956
+ "returnType": "void",
7511
6957
  "isStatic": false,
7512
6958
  "isPublic": true
7513
6959
  },
7514
- "recordConversion": {
7515
- "name": "recordConversion",
6960
+ "save": {
6961
+ "name": "save",
7516
6962
  "async": true,
7517
- "parameters": [
7518
- {
7519
- "name": "params",
7520
- "type": "RecordConversionParams",
7521
- "optional": false
7522
- }
7523
- ],
7524
- "returnType": "Promise<RecordConversionResult>",
6963
+ "parameters": [],
6964
+ "returnType": "Promise",
7525
6965
  "isStatic": false,
7526
6966
  "isPublic": true
7527
6967
  }
7528
6968
  },
7529
- "decoratorConfig": {},
7530
- "extends": "SmrtCollection",
7531
- "extendsTypeArg": "OpportunityConversion",
7532
- "exportName": "OpportunityConversionCollection",
7533
- "collectionExportName": "OpportunityConversionCollectionCollection",
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
+ ],
7534
7013
  "schema": {
7535
- "tableName": "opportunity_conversion_collections",
7536
- "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);",
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);",
7537
7016
  "columns": {
7538
7017
  "id": {
7539
7018
  "type": "UUID",
@@ -7559,95 +7038,188 @@
7559
7038
  "type": "TIMESTAMP",
7560
7039
  "notNull": true,
7561
7040
  "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": "{}"
7562
7077
  }
7563
7078
  },
7564
7079
  "indexes": [
7565
7080
  {
7566
- "name": "opportunity_conversion_collections_id_idx",
7081
+ "name": "opportunity_conversions_id_idx",
7567
7082
  "columns": [
7568
7083
  "id"
7569
7084
  ]
7570
7085
  },
7571
7086
  {
7572
- "name": "opportunity_conversion_collections_slug_context_idx",
7087
+ "name": "opportunity_conversions_opportunity_id_target_kind_idx",
7573
7088
  "columns": [
7574
- "slug",
7575
- "context"
7089
+ "opportunity_id",
7090
+ "target_kind",
7091
+ "target_id"
7576
7092
  ],
7577
7093
  "unique": true
7578
7094
  }
7579
7095
  ],
7580
- "version": "7e30ff1b"
7096
+ "version": "82c29042"
7581
7097
  }
7582
7098
  },
7583
- "@happyvertical/smrt-sales:PipelineDefinitionCollection": {
7584
- "name": "pipelinedefinitioncollection",
7585
- "className": "PipelineDefinitionCollection",
7586
- "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
7099
+ "@happyvertical/smrt-sales:PipelineDefinition": {
7100
+ "name": "pipelinedefinition",
7101
+ "className": "PipelineDefinition",
7102
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
7587
7103
  "collection": "pipelinedefinitions",
7588
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineDefinitionCollection.ts",
7104
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineDefinition.ts",
7589
7105
  "packageName": "@happyvertical/smrt-sales",
7590
- "fields": {},
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
7122
+ }
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"
7147
+ },
7148
+ "metadata": {
7149
+ "type": "text",
7150
+ "required": false,
7151
+ "default": "{}"
7152
+ }
7153
+ },
7591
7154
  "methods": {
7592
- "findByKey": {
7593
- "name": "findByKey",
7594
- "async": true,
7595
- "parameters": [
7596
- {
7597
- "name": "key",
7598
- "type": "string",
7599
- "optional": false
7600
- }
7601
- ],
7602
- "returnType": "Promise<PipelineDefinition | null>",
7155
+ "isActive": {
7156
+ "name": "isActive",
7157
+ "async": false,
7158
+ "parameters": [],
7159
+ "returnType": "boolean",
7603
7160
  "isStatic": false,
7604
7161
  "isPublic": true
7605
7162
  },
7606
- "findDefault": {
7607
- "name": "findDefault",
7608
- "async": true,
7163
+ "getMetadata": {
7164
+ "name": "getMetadata",
7165
+ "async": false,
7609
7166
  "parameters": [],
7610
- "returnType": "Promise<PipelineDefinition | null>",
7167
+ "returnType": "Record<string>",
7611
7168
  "isStatic": false,
7612
7169
  "isPublic": true
7613
7170
  },
7614
- "getStages": {
7615
- "name": "getStages",
7616
- "async": true,
7171
+ "setMetadata": {
7172
+ "name": "setMetadata",
7173
+ "async": false,
7617
7174
  "parameters": [
7618
7175
  {
7619
- "name": "pipelineId",
7620
- "type": "string",
7176
+ "name": "metadata",
7177
+ "type": "Record<string>",
7621
7178
  "optional": false
7622
7179
  }
7623
7180
  ],
7624
- "returnType": "Promise<PipelineStage[]>",
7181
+ "returnType": "void",
7625
7182
  "isStatic": false,
7626
7183
  "isPublic": true
7184
+ }
7185
+ },
7186
+ "decoratorConfig": {
7187
+ "api": {
7188
+ "include": [
7189
+ "list",
7190
+ "get",
7191
+ "create",
7192
+ "update"
7193
+ ]
7627
7194
  },
7628
- "ensureDefaultPipeline": {
7629
- "name": "ensureDefaultPipeline",
7630
- "async": true,
7631
- "parameters": [
7632
- {
7633
- "name": "params",
7634
- "type": "EnsureDefaultPipelineParams",
7635
- "optional": true
7636
- }
7637
- ],
7638
- "returnType": "Promise<EnsureDefaultPipelineResult>",
7639
- "isStatic": false,
7640
- "isPublic": true
7195
+ "mcp": {
7196
+ "include": [
7197
+ "list",
7198
+ "get"
7199
+ ]
7200
+ },
7201
+ "cli": true,
7202
+ "conflictColumns": [
7203
+ "tenant_id",
7204
+ "key"
7205
+ ],
7206
+ "tenantScoped": {
7207
+ "mode": "optional"
7641
7208
  }
7642
7209
  },
7643
- "decoratorConfig": {},
7644
- "extends": "SmrtCollection",
7645
- "extendsTypeArg": "PipelineDefinition",
7646
- "exportName": "PipelineDefinitionCollection",
7647
- "collectionExportName": "PipelineDefinitionCollectionCollection",
7210
+ "extends": "SmrtObject",
7211
+ "exportName": "PipelineDefinition",
7212
+ "collectionExportName": "PipelineDefinitionCollection",
7213
+ "validationRules": [
7214
+ {
7215
+ "field": "key",
7216
+ "rule": "required",
7217
+ "fieldType": "text"
7218
+ }
7219
+ ],
7648
7220
  "schema": {
7649
- "tableName": "pipeline_definition_collections",
7650
- "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);",
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);",
7651
7223
  "columns": {
7652
7224
  "id": {
7653
7225
  "type": "UUID",
@@ -7673,78 +7245,210 @@
7673
7245
  "type": "TIMESTAMP",
7674
7246
  "notNull": true,
7675
7247
  "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": "{}"
7676
7284
  }
7677
7285
  },
7678
7286
  "indexes": [
7679
7287
  {
7680
- "name": "pipeline_definition_collections_id_idx",
7288
+ "name": "pipeline_definitions_id_idx",
7681
7289
  "columns": [
7682
7290
  "id"
7683
7291
  ]
7684
7292
  },
7685
7293
  {
7686
- "name": "pipeline_definition_collections_slug_context_idx",
7294
+ "name": "pipeline_definitions_tenant_id_key_idx",
7687
7295
  "columns": [
7688
- "slug",
7689
- "context"
7296
+ "tenant_id",
7297
+ "key"
7690
7298
  ],
7691
7299
  "unique": true
7692
7300
  }
7693
7301
  ],
7694
- "version": "f85d1436"
7302
+ "version": "5e3ace6c"
7695
7303
  }
7696
7304
  },
7697
- "@happyvertical/smrt-sales:PipelineStageCollection": {
7698
- "name": "pipelinestagecollection",
7699
- "className": "PipelineStageCollection",
7700
- "qualifiedName": "@happyvertical/smrt-sales:PipelineStageCollection",
7305
+ "@happyvertical/smrt-sales:PipelineStage": {
7306
+ "name": "pipelinestage",
7307
+ "className": "PipelineStage",
7308
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineStage",
7701
7309
  "collection": "pipelinestages",
7702
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/PipelineStageCollection.ts",
7310
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineStage.ts",
7703
7311
  "packageName": "@happyvertical/smrt-sales",
7704
- "fields": {},
7705
- "methods": {
7706
- "findByPipeline": {
7707
- "name": "findByPipeline",
7708
- "async": true,
7709
- "parameters": [
7710
- {
7711
- "name": "pipelineId",
7712
- "type": "string",
7713
- "optional": false
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
7714
7328
  }
7715
- ],
7716
- "returnType": "Promise<PipelineStage[]>",
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
+ },
7378
+ "methods": {
7379
+ "isTerminal": {
7380
+ "name": "isTerminal",
7381
+ "async": false,
7382
+ "parameters": [],
7383
+ "returnType": "boolean",
7717
7384
  "isStatic": false,
7718
7385
  "isPublic": true
7719
7386
  },
7720
- "findByKey": {
7721
- "name": "findByKey",
7722
- "async": true,
7387
+ "getMetadata": {
7388
+ "name": "getMetadata",
7389
+ "async": false,
7390
+ "parameters": [],
7391
+ "returnType": "Record<string>",
7392
+ "isStatic": false,
7393
+ "isPublic": true
7394
+ },
7395
+ "setMetadata": {
7396
+ "name": "setMetadata",
7397
+ "async": false,
7723
7398
  "parameters": [
7724
7399
  {
7725
- "name": "pipelineId",
7726
- "type": "string",
7727
- "optional": false
7728
- },
7729
- {
7730
- "name": "key",
7731
- "type": "string",
7400
+ "name": "metadata",
7401
+ "type": "Record<string>",
7732
7402
  "optional": false
7733
7403
  }
7734
7404
  ],
7735
- "returnType": "Promise<PipelineStage | null>",
7405
+ "returnType": "void",
7736
7406
  "isStatic": false,
7737
7407
  "isPublic": true
7738
7408
  }
7739
7409
  },
7740
- "decoratorConfig": {},
7741
- "extends": "SmrtCollection",
7742
- "extendsTypeArg": "PipelineStage",
7743
- "exportName": "PipelineStageCollection",
7744
- "collectionExportName": "PipelineStageCollectionCollection",
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
+ ],
7745
7449
  "schema": {
7746
- "tableName": "pipeline_stage_collections",
7747
- "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);",
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);",
7748
7452
  "columns": {
7749
7453
  "id": {
7750
7454
  "type": "UUID",
@@ -7770,83 +7474,221 @@
7770
7474
  "type": "TIMESTAMP",
7771
7475
  "notNull": true,
7772
7476
  "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": "{}"
7773
7531
  }
7774
7532
  },
7775
7533
  "indexes": [
7776
7534
  {
7777
- "name": "pipeline_stage_collections_id_idx",
7535
+ "name": "pipeline_stages_id_idx",
7778
7536
  "columns": [
7779
7537
  "id"
7780
7538
  ]
7781
7539
  },
7782
7540
  {
7783
- "name": "pipeline_stage_collections_slug_context_idx",
7541
+ "name": "pipeline_stages_pipeline_id_key_idx",
7784
7542
  "columns": [
7785
- "slug",
7786
- "context"
7543
+ "pipeline_id",
7544
+ "key"
7787
7545
  ],
7788
7546
  "unique": true
7789
7547
  }
7790
7548
  ],
7791
- "version": "72c2d7b3"
7549
+ "version": "bdb0cf4e"
7792
7550
  }
7793
7551
  },
7794
- "@happyvertical/smrt-sales:SalesActivityCollection": {
7795
- "name": "salesactivitycollection",
7796
- "className": "SalesActivityCollection",
7797
- "qualifiedName": "@happyvertical/smrt-sales:SalesActivityCollection",
7552
+ "@happyvertical/smrt-sales:SalesActivity": {
7553
+ "name": "salesactivity",
7554
+ "className": "SalesActivity",
7555
+ "qualifiedName": "@happyvertical/smrt-sales:SalesActivity",
7798
7556
  "collection": "salesactivities",
7799
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesActivityCollection.ts",
7557
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesActivity.ts",
7800
7558
  "packageName": "@happyvertical/smrt-sales",
7801
- "fields": {},
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
+ },
7802
7620
  "methods": {
7803
- "findBySubject": {
7804
- "name": "findBySubject",
7805
- "async": true,
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,
7806
7640
  "parameters": [
7807
7641
  {
7808
- "name": "subjectKind",
7809
- "type": "SalesActivitySubjectKind",
7810
- "optional": false
7811
- },
7812
- {
7813
- "name": "subjectId",
7814
- "type": "string",
7642
+ "name": "metadata",
7643
+ "type": "Record<string>",
7815
7644
  "optional": false
7816
7645
  }
7817
7646
  ],
7818
- "returnType": "Promise<SalesActivity[]>",
7647
+ "returnType": "void",
7819
7648
  "isStatic": false,
7820
7649
  "isPublic": true
7821
7650
  },
7822
- "findOpenTasks": {
7823
- "name": "findOpenTasks",
7651
+ "save": {
7652
+ "name": "save",
7824
7653
  "async": true,
7825
- "parameters": [
7826
- {
7827
- "name": "subjectKind",
7828
- "type": "SalesActivitySubjectKind",
7829
- "optional": false
7830
- },
7831
- {
7832
- "name": "subjectId",
7833
- "type": "string",
7834
- "optional": false
7835
- }
7836
- ],
7837
- "returnType": "Promise<SalesActivity[]>",
7654
+ "parameters": [],
7655
+ "returnType": "Promise",
7838
7656
  "isStatic": false,
7839
7657
  "isPublic": true
7840
7658
  }
7841
7659
  },
7842
- "decoratorConfig": {},
7843
- "extends": "SmrtCollection",
7844
- "extendsTypeArg": "SalesActivity",
7845
- "exportName": "SalesActivityCollection",
7846
- "collectionExportName": "SalesActivityCollectionCollection",
7660
+ "decoratorConfig": {
7661
+ "api": {
7662
+ "include": [
7663
+ "create",
7664
+ "list",
7665
+ "get"
7666
+ ]
7667
+ },
7668
+ "mcp": {
7669
+ "include": [
7670
+ "list",
7671
+ "create"
7672
+ ]
7673
+ },
7674
+ "cli": false,
7675
+ "tenantScoped": {
7676
+ "mode": "optional"
7677
+ }
7678
+ },
7679
+ "extends": "SmrtObject",
7680
+ "exportName": "SalesActivity",
7681
+ "collectionExportName": "SalesActivityCollection",
7682
+ "validationRules": [
7683
+ {
7684
+ "field": "subjectId",
7685
+ "rule": "required",
7686
+ "fieldType": "text"
7687
+ }
7688
+ ],
7847
7689
  "schema": {
7848
- "tableName": "sales_activity_collections",
7849
- "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);",
7690
+ "tableName": "sales_activities",
7691
+ "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);",
7850
7692
  "columns": {
7851
7693
  "id": {
7852
7694
  "type": "UUID",
@@ -7872,17 +7714,69 @@
7872
7714
  "type": "TIMESTAMP",
7873
7715
  "notNull": true,
7874
7716
  "default": "current_timestamp"
7717
+ },
7718
+ "tenant_id": {
7719
+ "type": "UUID",
7720
+ "referenceKind": "tenantId",
7721
+ "notNull": false,
7722
+ "unique": false
7723
+ },
7724
+ "subject_kind": {
7725
+ "type": "TEXT",
7726
+ "notNull": false,
7727
+ "unique": false,
7728
+ "default": "lead"
7729
+ },
7730
+ "subject_id": {
7731
+ "type": "TEXT",
7732
+ "notNull": true,
7733
+ "unique": false,
7734
+ "default": ""
7735
+ },
7736
+ "activity_kind": {
7737
+ "type": "TEXT",
7738
+ "notNull": false,
7739
+ "unique": false,
7740
+ "default": "note"
7741
+ },
7742
+ "summary": {
7743
+ "type": "TEXT",
7744
+ "notNull": false,
7745
+ "unique": false,
7746
+ "default": ""
7747
+ },
7748
+ "due_at": {
7749
+ "type": "TIMESTAMP",
7750
+ "notNull": false,
7751
+ "unique": false
7752
+ },
7753
+ "completed_at": {
7754
+ "type": "TIMESTAMP",
7755
+ "notNull": false,
7756
+ "unique": false
7757
+ },
7758
+ "actor_profile_id": {
7759
+ "type": "UUID",
7760
+ "referenceKind": "crossPackageRef",
7761
+ "notNull": false,
7762
+ "unique": false
7763
+ },
7764
+ "metadata": {
7765
+ "type": "TEXT",
7766
+ "notNull": false,
7767
+ "unique": false,
7768
+ "default": "{}"
7875
7769
  }
7876
7770
  },
7877
7771
  "indexes": [
7878
7772
  {
7879
- "name": "sales_activity_collections_id_idx",
7773
+ "name": "sales_activities_id_idx",
7880
7774
  "columns": [
7881
7775
  "id"
7882
7776
  ]
7883
7777
  },
7884
7778
  {
7885
- "name": "sales_activity_collections_slug_context_idx",
7779
+ "name": "sales_activities_slug_context_idx",
7886
7780
  "columns": [
7887
7781
  "slug",
7888
7782
  "context"
@@ -7890,49 +7784,119 @@
7890
7784
  "unique": true
7891
7785
  }
7892
7786
  ],
7893
- "version": "766a0235"
7787
+ "version": "b3173b53"
7894
7788
  }
7895
7789
  },
7896
- "@happyvertical/smrt-sales:SalesRepresentativeCollection": {
7897
- "name": "salesrepresentativecollection",
7898
- "className": "SalesRepresentativeCollection",
7899
- "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentativeCollection",
7790
+ "@happyvertical/smrt-sales:SalesRepresentative": {
7791
+ "name": "salesrepresentative",
7792
+ "className": "SalesRepresentative",
7793
+ "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
7900
7794
  "collection": "salesrepresentatives",
7901
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesRepresentativeCollection.ts",
7795
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesRepresentative.ts",
7902
7796
  "packageName": "@happyvertical/smrt-sales",
7903
- "fields": {},
7797
+ "fields": {
7798
+ "tenantId": {
7799
+ "type": "text",
7800
+ "required": false,
7801
+ "_meta": {
7802
+ "sqlType": "UUID",
7803
+ "nullable": true,
7804
+ "__tenancy": {
7805
+ "isTenantIdField": true,
7806
+ "autoFilter": true,
7807
+ "required": false,
7808
+ "autoPopulate": true,
7809
+ "nullable": true,
7810
+ "mode": "optional",
7811
+ "field": "tenantId",
7812
+ "allowSuperAdminBypass": false
7813
+ }
7814
+ }
7815
+ },
7816
+ "profileId": {
7817
+ "type": "crossPackageRef",
7818
+ "required": false,
7819
+ "related": "@happyvertical/smrt-profiles:Profile"
7820
+ },
7821
+ "earnerId": {
7822
+ "type": "foreignKey",
7823
+ "required": false,
7824
+ "related": "Earner"
7825
+ },
7826
+ "status": {
7827
+ "type": "text",
7828
+ "required": false,
7829
+ "default": "active"
7830
+ },
7831
+ "title": {
7832
+ "type": "text",
7833
+ "required": false,
7834
+ "default": ""
7835
+ },
7836
+ "metadata": {
7837
+ "type": "text",
7838
+ "required": false,
7839
+ "default": "{}"
7840
+ }
7841
+ },
7904
7842
  "methods": {
7905
- "findByProfile": {
7906
- "name": "findByProfile",
7907
- "async": true,
7843
+ "isActive": {
7844
+ "name": "isActive",
7845
+ "async": false,
7846
+ "parameters": [],
7847
+ "returnType": "boolean",
7848
+ "isStatic": false,
7849
+ "isPublic": true
7850
+ },
7851
+ "getMetadata": {
7852
+ "name": "getMetadata",
7853
+ "async": false,
7854
+ "parameters": [],
7855
+ "returnType": "Record<string>",
7856
+ "isStatic": false,
7857
+ "isPublic": true
7858
+ },
7859
+ "setMetadata": {
7860
+ "name": "setMetadata",
7861
+ "async": false,
7908
7862
  "parameters": [
7909
7863
  {
7910
- "name": "profileId",
7911
- "type": "string",
7864
+ "name": "metadata",
7865
+ "type": "Record<string>",
7912
7866
  "optional": false
7913
7867
  }
7914
7868
  ],
7915
- "returnType": "Promise<SalesRepresentative[]>",
7869
+ "returnType": "void",
7916
7870
  "isStatic": false,
7917
7871
  "isPublic": true
7872
+ }
7873
+ },
7874
+ "decoratorConfig": {
7875
+ "api": {
7876
+ "include": [
7877
+ "list",
7878
+ "get",
7879
+ "create",
7880
+ "update"
7881
+ ]
7918
7882
  },
7919
- "findActive": {
7920
- "name": "findActive",
7921
- "async": true,
7922
- "parameters": [],
7923
- "returnType": "Promise<SalesRepresentative[]>",
7924
- "isStatic": false,
7925
- "isPublic": true
7883
+ "mcp": {
7884
+ "include": [
7885
+ "list",
7886
+ "get"
7887
+ ]
7888
+ },
7889
+ "cli": true,
7890
+ "tenantScoped": {
7891
+ "mode": "optional"
7926
7892
  }
7927
7893
  },
7928
- "decoratorConfig": {},
7929
- "extends": "SmrtCollection",
7930
- "extendsTypeArg": "SalesRepresentative",
7931
- "exportName": "SalesRepresentativeCollection",
7932
- "collectionExportName": "SalesRepresentativeCollectionCollection",
7894
+ "extends": "SmrtObject",
7895
+ "exportName": "SalesRepresentative",
7896
+ "collectionExportName": "SalesRepresentativeCollection",
7933
7897
  "schema": {
7934
- "tableName": "sales_representative_collections",
7935
- "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);",
7898
+ "tableName": "sales_representatives",
7899
+ "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);",
7936
7900
  "columns": {
7937
7901
  "id": {
7938
7902
  "type": "UUID",
@@ -7958,17 +7922,53 @@
7958
7922
  "type": "TIMESTAMP",
7959
7923
  "notNull": true,
7960
7924
  "default": "current_timestamp"
7925
+ },
7926
+ "tenant_id": {
7927
+ "type": "UUID",
7928
+ "referenceKind": "tenantId",
7929
+ "notNull": false,
7930
+ "unique": false
7931
+ },
7932
+ "profile_id": {
7933
+ "type": "UUID",
7934
+ "referenceKind": "crossPackageRef",
7935
+ "notNull": false,
7936
+ "unique": false
7937
+ },
7938
+ "earner_id": {
7939
+ "type": "UUID",
7940
+ "referenceKind": "foreignKey",
7941
+ "notNull": false,
7942
+ "unique": false
7943
+ },
7944
+ "status": {
7945
+ "type": "TEXT",
7946
+ "notNull": false,
7947
+ "unique": false,
7948
+ "default": "active"
7949
+ },
7950
+ "title": {
7951
+ "type": "TEXT",
7952
+ "notNull": false,
7953
+ "unique": false,
7954
+ "default": ""
7955
+ },
7956
+ "metadata": {
7957
+ "type": "TEXT",
7958
+ "notNull": false,
7959
+ "unique": false,
7960
+ "default": "{}"
7961
7961
  }
7962
7962
  },
7963
7963
  "indexes": [
7964
7964
  {
7965
- "name": "sales_representative_collections_id_idx",
7965
+ "name": "sales_representatives_id_idx",
7966
7966
  "columns": [
7967
7967
  "id"
7968
7968
  ]
7969
7969
  },
7970
7970
  {
7971
- "name": "sales_representative_collections_slug_context_idx",
7971
+ "name": "sales_representatives_slug_context_idx",
7972
7972
  "columns": [
7973
7973
  "slug",
7974
7974
  "context"
@@ -7976,7 +7976,7 @@
7976
7976
  "unique": true
7977
7977
  }
7978
7978
  ],
7979
- "version": "6613c45d"
7979
+ "version": "7b67ed6e"
7980
7980
  }
7981
7981
  },
7982
7982
  "@happyvertical/smrt-sales:AttributionExceptionCollection": {