@happyvertical/smrt-sales 0.40.39 → 0.40.40

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": 1785462251168,
3
+ "timestamp": 1785468339934,
4
4
  "packageName": "@happyvertical/smrt-sales",
5
- "packageVersion": "0.40.39",
5
+ "packageVersion": "0.40.40",
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"
6310
- },
6311
- "tenant_id": {
6312
- "type": "UUID",
6313
- "referenceKind": "tenantId",
6314
- "notNull": false,
6315
- "unique": false
6316
- },
6317
- "opportunity_id": {
6318
- "type": "UUID",
6319
- "referenceKind": "foreignKey",
6320
- "notNull": true,
6321
- "unique": false
6322
- },
6323
- "target_kind": {
6324
- "type": "TEXT",
6325
- "notNull": true,
6326
- "unique": false,
6327
- "default": ""
6328
- },
6329
- "target_id": {
6330
- "type": "TEXT",
6331
- "notNull": true,
6332
- "unique": false,
6333
- "default": ""
6334
- },
6335
- "note": {
6336
- "type": "TEXT",
6337
- "notNull": false,
6338
- "unique": false,
6339
- "default": ""
6340
- },
6341
- "metadata": {
6342
- "type": "TEXT",
6343
- "notNull": false,
6344
- "unique": false,
6345
- "default": "{}"
6346
5666
  }
6347
5667
  },
6348
5668
  "indexes": [
6349
5669
  {
6350
- "name": "opportunity_conversions_id_idx",
5670
+ "name": "opportunity_collections_id_idx",
6351
5671
  "columns": [
6352
5672
  "id"
6353
5673
  ]
6354
5674
  },
6355
5675
  {
6356
- "name": "opportunity_conversions_opportunity_id_target_kind_idx",
5676
+ "name": "opportunity_collections_slug_context_idx",
6357
5677
  "columns": [
6358
- "opportunity_id",
6359
- "target_kind",
6360
- "target_id"
5678
+ "slug",
5679
+ "context"
6361
5680
  ],
6362
5681
  "unique": true
6363
5682
  }
6364
5683
  ],
6365
- "version": "82c29042"
5684
+ "version": "ebcdf63b"
6366
5685
  }
6367
5686
  },
6368
- "@happyvertical/smrt-sales:PipelineDefinition": {
6369
- "name": "pipelinedefinition",
6370
- "className": "PipelineDefinition",
6371
- "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
6372
- "collection": "pipelinedefinitions",
6373
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/PipelineDefinition.ts",
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",
6374
5693
  "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
5694
+ "fields": {},
5695
+ "methods": {
5696
+ "findByOpportunity": {
5697
+ "name": "findByOpportunity",
5698
+ "async": true,
5699
+ "parameters": [
5700
+ {
5701
+ "name": "opportunityId",
5702
+ "type": "string",
5703
+ "optional": false
6391
5704
  }
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"
5705
+ ],
5706
+ "returnType": "Promise<OpportunityConversion[]>",
5707
+ "isStatic": false,
5708
+ "isPublic": true
6416
5709
  },
6417
- "metadata": {
6418
- "type": "text",
6419
- "required": false,
6420
- "default": "{}"
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
6421
5723
  }
6422
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": {
5735
+ "type": "UUID",
5736
+ "primaryKey": true,
5737
+ "referenceKind": "id",
5738
+ "notNull": true
5739
+ },
5740
+ "slug": {
5741
+ "type": "TEXT",
5742
+ "notNull": true
5743
+ },
5744
+ "context": {
5745
+ "type": "TEXT",
5746
+ "notNull": true,
5747
+ "default": ""
5748
+ },
5749
+ "created_at": {
5750
+ "type": "TIMESTAMP",
5751
+ "notNull": true,
5752
+ "default": "current_timestamp"
5753
+ },
5754
+ "updated_at": {
5755
+ "type": "TIMESTAMP",
5756
+ "notNull": true,
5757
+ "default": "current_timestamp"
5758
+ }
5759
+ },
5760
+ "indexes": [
5761
+ {
5762
+ "name": "opportunity_conversion_collections_id_idx",
5763
+ "columns": [
5764
+ "id"
5765
+ ]
5766
+ },
5767
+ {
5768
+ "name": "opportunity_conversion_collections_slug_context_idx",
5769
+ "columns": [
5770
+ "slug",
5771
+ "context"
5772
+ ],
5773
+ "unique": true
5774
+ }
5775
+ ],
5776
+ "version": "7e30ff1b"
5777
+ }
5778
+ },
5779
+ "@happyvertical/smrt-sales:PipelineDefinitionCollection": {
5780
+ "name": "pipelinedefinitioncollection",
5781
+ "className": "PipelineDefinitionCollection",
5782
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
5783
+ "collection": "pipelinedefinitions",
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
- },
6464
- "mcp": {
6465
- "include": [
6466
- "list",
6467
- "get"
6468
- ]
6469
5823
  },
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
- },
6664
- "setMetadata": {
6665
- "name": "setMetadata",
6666
- "async": false,
5915
+ },
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,213 +5966,83 @@
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",
6895
- "isStatic": false,
6896
- "isPublic": true
6897
- },
6898
- "getMetadata": {
6899
- "name": "getMetadata",
6900
- "async": false,
6901
- "parameters": [],
6902
- "returnType": "Record<string>",
6903
- "isStatic": false,
6904
- "isPublic": true
6905
- },
6906
- "setMetadata": {
6907
- "name": "setMetadata",
6908
- "async": false,
5999
+ "findBySubject": {
6000
+ "name": "findBySubject",
6001
+ "async": true,
6909
6002
  "parameters": [
6910
6003
  {
6911
- "name": "metadata",
6912
- "type": "Record<string>",
6004
+ "name": "subjectKind",
6005
+ "type": "SalesActivitySubjectKind",
6006
+ "optional": false
6007
+ },
6008
+ {
6009
+ "name": "subjectId",
6010
+ "type": "string",
6913
6011
  "optional": false
6914
6012
  }
6915
6013
  ],
6916
- "returnType": "void",
6014
+ "returnType": "Promise<SalesActivity[]>",
6917
6015
  "isStatic": false,
6918
6016
  "isPublic": true
6919
- }
6920
- },
6921
- "decoratorConfig": {
6922
- "api": {
6923
- "include": [
6924
- "create",
6925
- "list",
6926
- "get"
6927
- ]
6928
- },
6929
- "mcp": {
6930
- "include": [
6931
- "list",
6932
- "create"
6933
- ]
6934
6017
  },
6935
- "cli": false,
6936
- "tenantScoped": {
6937
- "mode": "optional"
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[]>",
6034
+ "isStatic": false,
6035
+ "isPublic": true
6938
6036
  }
6939
6037
  },
6940
- "extends": "SmrtObject",
6941
- "exportName": "SalesActivity",
6942
- "collectionExportName": "SalesActivityCollection",
6943
- "validationRules": [
6944
- {
6945
- "field": "subjectId",
6946
- "rule": "required",
6947
- "fieldType": "text"
6948
- }
6949
- ],
6038
+ "decoratorConfig": {},
6039
+ "extends": "SmrtCollection",
6040
+ "extendsTypeArg": "SalesActivity",
6041
+ "exportName": "SalesActivityCollection",
6042
+ "collectionExportName": "SalesActivityCollectionCollection",
6950
6043
  "schema": {
6951
- "tableName": "sales_activities",
6952
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activities\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"subject_kind\" TEXT DEFAULT 'lead',\n \"subject_id\" TEXT NOT NULL DEFAULT '',\n \"activity_kind\" TEXT DEFAULT 'note',\n \"summary\" TEXT DEFAULT '',\n \"due_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"actor_profile_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}'\n);",
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);",
6953
6046
  "columns": {
6954
6047
  "id": {
6955
6048
  "type": "UUID",
@@ -6975,69 +6068,103 @@
6975
6068
  "type": "TIMESTAMP",
6976
6069
  "notNull": true,
6977
6070
  "default": "current_timestamp"
6071
+ }
6072
+ },
6073
+ "indexes": [
6074
+ {
6075
+ "name": "sales_activity_collections_id_idx",
6076
+ "columns": [
6077
+ "id"
6078
+ ]
6978
6079
  },
6979
- "tenant_id": {
6080
+ {
6081
+ "name": "sales_activity_collections_slug_context_idx",
6082
+ "columns": [
6083
+ "slug",
6084
+ "context"
6085
+ ],
6086
+ "unique": true
6087
+ }
6088
+ ],
6089
+ "version": "766a0235"
6090
+ }
6091
+ },
6092
+ "@happyvertical/smrt-sales:SalesRepresentativeCollection": {
6093
+ "name": "salesrepresentativecollection",
6094
+ "className": "SalesRepresentativeCollection",
6095
+ "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentativeCollection",
6096
+ "collection": "salesrepresentatives",
6097
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesRepresentativeCollection.ts",
6098
+ "packageName": "@happyvertical/smrt-sales",
6099
+ "fields": {},
6100
+ "methods": {
6101
+ "findByProfile": {
6102
+ "name": "findByProfile",
6103
+ "async": true,
6104
+ "parameters": [
6105
+ {
6106
+ "name": "profileId",
6107
+ "type": "string",
6108
+ "optional": false
6109
+ }
6110
+ ],
6111
+ "returnType": "Promise<SalesRepresentative[]>",
6112
+ "isStatic": false,
6113
+ "isPublic": true
6114
+ },
6115
+ "findActive": {
6116
+ "name": "findActive",
6117
+ "async": true,
6118
+ "parameters": [],
6119
+ "returnType": "Promise<SalesRepresentative[]>",
6120
+ "isStatic": false,
6121
+ "isPublic": true
6122
+ }
6123
+ },
6124
+ "decoratorConfig": {},
6125
+ "extends": "SmrtCollection",
6126
+ "extendsTypeArg": "SalesRepresentative",
6127
+ "exportName": "SalesRepresentativeCollection",
6128
+ "collectionExportName": "SalesRepresentativeCollectionCollection",
6129
+ "schema": {
6130
+ "tableName": "sales_representative_collections",
6131
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representative_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
6132
+ "columns": {
6133
+ "id": {
6980
6134
  "type": "UUID",
6981
- "referenceKind": "tenantId",
6982
- "notNull": false,
6983
- "unique": false
6135
+ "primaryKey": true,
6136
+ "referenceKind": "id",
6137
+ "notNull": true
6984
6138
  },
6985
- "subject_kind": {
6139
+ "slug": {
6986
6140
  "type": "TEXT",
6987
- "notNull": false,
6988
- "unique": false,
6989
- "default": "lead"
6141
+ "notNull": true
6990
6142
  },
6991
- "subject_id": {
6143
+ "context": {
6992
6144
  "type": "TEXT",
6993
6145
  "notNull": true,
6994
- "unique": false,
6995
- "default": ""
6996
- },
6997
- "activity_kind": {
6998
- "type": "TEXT",
6999
- "notNull": false,
7000
- "unique": false,
7001
- "default": "note"
7002
- },
7003
- "summary": {
7004
- "type": "TEXT",
7005
- "notNull": false,
7006
- "unique": false,
7007
6146
  "default": ""
7008
6147
  },
7009
- "due_at": {
6148
+ "created_at": {
7010
6149
  "type": "TIMESTAMP",
7011
- "notNull": false,
7012
- "unique": false
6150
+ "notNull": true,
6151
+ "default": "current_timestamp"
7013
6152
  },
7014
- "completed_at": {
6153
+ "updated_at": {
7015
6154
  "type": "TIMESTAMP",
7016
- "notNull": false,
7017
- "unique": false
7018
- },
7019
- "actor_profile_id": {
7020
- "type": "UUID",
7021
- "referenceKind": "crossPackageRef",
7022
- "notNull": false,
7023
- "unique": false
7024
- },
7025
- "metadata": {
7026
- "type": "TEXT",
7027
- "notNull": false,
7028
- "unique": false,
7029
- "default": "{}"
6155
+ "notNull": true,
6156
+ "default": "current_timestamp"
7030
6157
  }
7031
6158
  },
7032
6159
  "indexes": [
7033
6160
  {
7034
- "name": "sales_activities_id_idx",
6161
+ "name": "sales_representative_collections_id_idx",
7035
6162
  "columns": [
7036
6163
  "id"
7037
6164
  ]
7038
6165
  },
7039
6166
  {
7040
- "name": "sales_activities_slug_context_idx",
6167
+ "name": "sales_representative_collections_slug_context_idx",
7041
6168
  "columns": [
7042
6169
  "slug",
7043
6170
  "context"
@@ -7045,15 +6172,15 @@
7045
6172
  "unique": true
7046
6173
  }
7047
6174
  ],
7048
- "version": "b3173b53"
6175
+ "version": "6613c45d"
7049
6176
  }
7050
6177
  },
7051
- "@happyvertical/smrt-sales:SalesRepresentative": {
7052
- "name": "salesrepresentative",
7053
- "className": "SalesRepresentative",
7054
- "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
7055
- "collection": "salesrepresentatives",
7056
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesRepresentative.ts",
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",
7057
6184
  "packageName": "@happyvertical/smrt-sales",
7058
6185
  "fields": {
7059
6186
  "tenantId": {
@@ -7074,26 +6201,78 @@
7074
6201
  }
7075
6202
  }
7076
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
+ },
7077
6232
  "profileId": {
7078
6233
  "type": "crossPackageRef",
7079
6234
  "required": false,
7080
6235
  "related": "@happyvertical/smrt-profiles:Profile"
7081
6236
  },
7082
- "earnerId": {
6237
+ "ownerRepId": {
7083
6238
  "type": "foreignKey",
7084
6239
  "required": false,
7085
- "related": "Earner"
6240
+ "related": "SalesRepresentative"
7086
6241
  },
7087
6242
  "status": {
7088
6243
  "type": "text",
7089
6244
  "required": false,
7090
- "default": "active"
6245
+ "default": "new"
7091
6246
  },
7092
- "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": {
7093
6263
  "type": "text",
7094
6264
  "required": false,
7095
6265
  "default": ""
7096
6266
  },
6267
+ "mergedIntoId": {
6268
+ "type": "foreignKey",
6269
+ "required": false,
6270
+ "related": "Lead"
6271
+ },
6272
+ "qualifiedAt": {
6273
+ "type": "datetime",
6274
+ "required": false
6275
+ },
7097
6276
  "metadata": {
7098
6277
  "type": "text",
7099
6278
  "required": false,
@@ -7101,14 +6280,44 @@
7101
6280
  }
7102
6281
  },
7103
6282
  "methods": {
7104
- "isActive": {
7105
- "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",
7106
6293
  "async": false,
7107
6294
  "parameters": [],
7108
6295
  "returnType": "boolean",
7109
6296
  "isStatic": false,
7110
6297
  "isPublic": true
7111
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
+ },
7112
6321
  "getMetadata": {
7113
6322
  "name": "getMetadata",
7114
6323
  "async": false,
@@ -7130,6 +6339,22 @@
7130
6339
  "returnType": "void",
7131
6340
  "isStatic": false,
7132
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
7133
6358
  }
7134
6359
  },
7135
6360
  "decoratorConfig": {
@@ -7144,7 +6369,8 @@
7144
6369
  "mcp": {
7145
6370
  "include": [
7146
6371
  "list",
7147
- "get"
6372
+ "get",
6373
+ "create"
7148
6374
  ]
7149
6375
  },
7150
6376
  "cli": true,
@@ -7153,11 +6379,18 @@
7153
6379
  }
7154
6380
  },
7155
6381
  "extends": "SmrtObject",
7156
- "exportName": "SalesRepresentative",
7157
- "collectionExportName": "SalesRepresentativeCollection",
6382
+ "exportName": "Lead",
6383
+ "collectionExportName": "LeadCollection",
6384
+ "validationRules": [
6385
+ {
6386
+ "field": "name",
6387
+ "rule": "required",
6388
+ "fieldType": "text"
6389
+ }
6390
+ ],
7158
6391
  "schema": {
7159
- "tableName": "sales_representatives",
7160
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representatives\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"profile_id\" UUID,\n \"earner_id\" UUID,\n \"status\" TEXT DEFAULT 'active',\n \"title\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
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);",
7161
6394
  "columns": {
7162
6395
  "id": {
7163
6396
  "type": "UUID",
@@ -7190,13 +6423,43 @@
7190
6423
  "notNull": false,
7191
6424
  "unique": false
7192
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
+ },
7193
6456
  "profile_id": {
7194
6457
  "type": "UUID",
7195
6458
  "referenceKind": "crossPackageRef",
7196
6459
  "notNull": false,
7197
6460
  "unique": false
7198
6461
  },
7199
- "earner_id": {
6462
+ "owner_rep_id": {
7200
6463
  "type": "UUID",
7201
6464
  "referenceKind": "foreignKey",
7202
6465
  "notNull": false,
@@ -7206,14 +6469,43 @@
7206
6469
  "type": "TEXT",
7207
6470
  "notNull": false,
7208
6471
  "unique": false,
7209
- "default": "active"
6472
+ "default": "new"
7210
6473
  },
7211
- "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": {
7212
6493
  "type": "TEXT",
7213
6494
  "notNull": false,
7214
6495
  "unique": false,
7215
6496
  "default": ""
7216
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
+ },
7217
6509
  "metadata": {
7218
6510
  "type": "TEXT",
7219
6511
  "notNull": false,
@@ -7223,13 +6515,13 @@
7223
6515
  },
7224
6516
  "indexes": [
7225
6517
  {
7226
- "name": "sales_representatives_id_idx",
6518
+ "name": "leads_id_idx",
7227
6519
  "columns": [
7228
6520
  "id"
7229
6521
  ]
7230
6522
  },
7231
6523
  {
7232
- "name": "sales_representatives_slug_context_idx",
6524
+ "name": "leads_slug_context_idx",
7233
6525
  "columns": [
7234
6526
  "slug",
7235
6527
  "context"
@@ -7237,97 +6529,205 @@
7237
6529
  "unique": true
7238
6530
  }
7239
6531
  ],
7240
- "version": "7b67ed6e"
6532
+ "version": "a1c330c8"
7241
6533
  }
7242
6534
  },
7243
- "@happyvertical/smrt-sales:LeadCollection": {
7244
- "name": "leadcollection",
7245
- "className": "LeadCollection",
7246
- "qualifiedName": "@happyvertical/smrt-sales:LeadCollection",
7247
- "collection": "leads",
7248
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/LeadCollection.ts",
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",
7249
6541
  "packageName": "@happyvertical/smrt-sales",
7250
- "fields": {},
7251
- "methods": {
7252
- "findByStatus": {
7253
- "name": "findByStatus",
7254
- "async": true,
7255
- "parameters": [
7256
- {
7257
- "name": "status",
7258
- "type": "LeadStatus",
7259
- "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
7260
6558
  }
7261
- ],
7262
- "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",
7263
6648
  "isStatic": false,
7264
6649
  "isPublic": true
7265
6650
  },
7266
- "findByOwner": {
7267
- "name": "findByOwner",
7268
- "async": true,
7269
- "parameters": [
7270
- {
7271
- "name": "ownerRepId",
7272
- "type": "string",
7273
- "optional": false
7274
- }
7275
- ],
7276
- "returnType": "Promise<Lead[]>",
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>",
7277
6664
  "isStatic": false,
7278
6665
  "isPublic": true
7279
6666
  },
7280
- "qualify": {
7281
- "name": "qualify",
7282
- "async": true,
6667
+ "setMetadata": {
6668
+ "name": "setMetadata",
6669
+ "async": false,
7283
6670
  "parameters": [
7284
6671
  {
7285
- "name": "params",
7286
- "type": "QualifyLeadParams",
6672
+ "name": "metadata",
6673
+ "type": "Record<string>",
7287
6674
  "optional": false
7288
6675
  }
7289
6676
  ],
7290
- "returnType": "Promise<Opportunity>",
6677
+ "returnType": "void",
7291
6678
  "isStatic": false,
7292
6679
  "isPublic": true
7293
6680
  },
7294
- "mergeLeads": {
7295
- "name": "mergeLeads",
6681
+ "initialize": {
6682
+ "name": "initialize",
7296
6683
  "async": true,
7297
- "parameters": [
7298
- {
7299
- "name": "params",
7300
- "type": "MergeLeadsParams",
7301
- "optional": false
7302
- }
7303
- ],
7304
- "returnType": "Promise<MergeLeadsResult>",
6684
+ "parameters": [],
6685
+ "returnType": "Promise",
7305
6686
  "isStatic": false,
7306
6687
  "isPublic": true
7307
6688
  },
7308
- "activitiesIncludingMerged": {
7309
- "name": "activitiesIncludingMerged",
6689
+ "save": {
6690
+ "name": "save",
7310
6691
  "async": true,
7311
- "parameters": [
7312
- {
7313
- "name": "leadId",
7314
- "type": "string",
7315
- "optional": false
7316
- }
7317
- ],
7318
- "returnType": "Promise<SalesActivity[]>",
6692
+ "parameters": [],
6693
+ "returnType": "Promise",
7319
6694
  "isStatic": false,
7320
6695
  "isPublic": true
7321
6696
  }
7322
6697
  },
7323
- "decoratorConfig": {},
7324
- "extends": "SmrtCollection",
7325
- "extendsTypeArg": "Lead",
7326
- "exportName": "LeadCollection",
7327
- "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
+ ],
7328
6728
  "schema": {
7329
- "tableName": "lead_collections",
7330
- "ddl": "CREATE TABLE IF NOT EXISTS \"lead_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
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);",
7331
6731
  "columns": {
7332
6732
  "id": {
7333
6733
  "type": "UUID",
@@ -7353,123 +6753,116 @@
7353
6753
  "type": "TIMESTAMP",
7354
6754
  "notNull": true,
7355
6755
  "default": "current_timestamp"
7356
- }
7357
- },
7358
- "indexes": [
7359
- {
7360
- "name": "lead_collections_id_idx",
7361
- "columns": [
7362
- "id"
7363
- ]
7364
6756
  },
7365
- {
7366
- "name": "lead_collections_slug_context_idx",
7367
- "columns": [
7368
- "slug",
7369
- "context"
7370
- ],
7371
- "unique": true
7372
- }
7373
- ],
7374
- "version": "0707eb13"
7375
- }
7376
- },
7377
- "@happyvertical/smrt-sales:OpportunityCollection": {
7378
- "name": "opportunitycollection",
7379
- "className": "OpportunityCollection",
7380
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityCollection",
7381
- "collection": "opportunities",
7382
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/OpportunityCollection.ts",
7383
- "packageName": "@happyvertical/smrt-sales",
7384
- "fields": {},
7385
- "methods": {
7386
- "findByLead": {
7387
- "name": "findByLead",
7388
- "async": true,
7389
- "parameters": [
7390
- {
7391
- "name": "leadId",
7392
- "type": "string",
7393
- "optional": false
7394
- }
7395
- ],
7396
- "returnType": "Promise<Opportunity[]>",
7397
- "isStatic": false,
7398
- "isPublic": true
7399
- },
7400
- "findOpen": {
7401
- "name": "findOpen",
7402
- "async": true,
7403
- "parameters": [
7404
- {
7405
- "name": "pipelineId",
7406
- "type": "string",
7407
- "optional": true
7408
- }
7409
- ],
7410
- "returnType": "Promise<Opportunity[]>",
7411
- "isStatic": false,
7412
- "isPublic": true
7413
- },
7414
- "moveToStage": {
7415
- "name": "moveToStage",
7416
- "async": true,
7417
- "parameters": [
7418
- {
7419
- "name": "params",
7420
- "type": "MoveToStageParams",
7421
- "optional": false
7422
- }
7423
- ],
7424
- "returnType": "Promise<Opportunity>",
7425
- "isStatic": false,
7426
- "isPublic": true
7427
- }
7428
- },
7429
- "decoratorConfig": {},
7430
- "extends": "SmrtCollection",
7431
- "extendsTypeArg": "Opportunity",
7432
- "exportName": "OpportunityCollection",
7433
- "collectionExportName": "OpportunityCollectionCollection",
7434
- "schema": {
7435
- "tableName": "opportunity_collections",
7436
- "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7437
- "columns": {
7438
- "id": {
6757
+ "tenant_id": {
7439
6758
  "type": "UUID",
7440
- "primaryKey": true,
7441
- "referenceKind": "id",
7442
- "notNull": true
6759
+ "referenceKind": "tenantId",
6760
+ "notNull": false,
6761
+ "unique": false
7443
6762
  },
7444
- "slug": {
6763
+ "name": {
7445
6764
  "type": "TEXT",
7446
- "notNull": true
6765
+ "notNull": true,
6766
+ "unique": false,
6767
+ "default": ""
7447
6768
  },
7448
- "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": {
7449
6800
  "type": "TEXT",
7450
- "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,
6826
+ "default": ""
6827
+ },
6828
+ "won_at": {
6829
+ "type": "TIMESTAMP",
6830
+ "notNull": false,
6831
+ "unique": false
6832
+ },
6833
+ "lost_at": {
6834
+ "type": "TIMESTAMP",
6835
+ "notNull": false,
6836
+ "unique": false
6837
+ },
6838
+ "source_kind": {
6839
+ "type": "TEXT",
6840
+ "notNull": false,
6841
+ "unique": false,
6842
+ "default": ""
6843
+ },
6844
+ "source_id": {
6845
+ "type": "TEXT",
6846
+ "notNull": false,
6847
+ "unique": false,
7451
6848
  "default": ""
7452
6849
  },
7453
- "created_at": {
7454
- "type": "TIMESTAMP",
7455
- "notNull": true,
7456
- "default": "current_timestamp"
7457
- },
7458
- "updated_at": {
7459
- "type": "TIMESTAMP",
7460
- "notNull": true,
7461
- "default": "current_timestamp"
6850
+ "metadata": {
6851
+ "type": "TEXT",
6852
+ "notNull": false,
6853
+ "unique": false,
6854
+ "default": "{}"
7462
6855
  }
7463
6856
  },
7464
6857
  "indexes": [
7465
6858
  {
7466
- "name": "opportunity_collections_id_idx",
6859
+ "name": "opportunities_id_idx",
7467
6860
  "columns": [
7468
6861
  "id"
7469
6862
  ]
7470
6863
  },
7471
6864
  {
7472
- "name": "opportunity_collections_slug_context_idx",
6865
+ "name": "opportunities_slug_context_idx",
7473
6866
  "columns": [
7474
6867
  "slug",
7475
6868
  "context"
@@ -7477,55 +6870,149 @@
7477
6870
  "unique": true
7478
6871
  }
7479
6872
  ],
7480
- "version": "ebcdf63b"
6873
+ "version": "a403c6cf"
7481
6874
  }
7482
6875
  },
7483
- "@happyvertical/smrt-sales:OpportunityConversionCollection": {
7484
- "name": "opportunityconversioncollection",
7485
- "className": "OpportunityConversionCollection",
7486
- "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversionCollection",
6876
+ "@happyvertical/smrt-sales:OpportunityConversion": {
6877
+ "name": "opportunityconversion",
6878
+ "className": "OpportunityConversion",
6879
+ "qualifiedName": "@happyvertical/smrt-sales:OpportunityConversion",
7487
6880
  "collection": "opportunityconversions",
7488
- "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",
7489
6882
  "packageName": "@happyvertical/smrt-sales",
7490
- "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
+ },
7491
6937
  "methods": {
7492
- "findByOpportunity": {
7493
- "name": "findByOpportunity",
7494
- "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,
7495
6949
  "parameters": [
7496
6950
  {
7497
- "name": "opportunityId",
7498
- "type": "string",
6951
+ "name": "metadata",
6952
+ "type": "Record<string>",
7499
6953
  "optional": false
7500
6954
  }
7501
6955
  ],
7502
- "returnType": "Promise<OpportunityConversion[]>",
6956
+ "returnType": "void",
7503
6957
  "isStatic": false,
7504
6958
  "isPublic": true
7505
6959
  },
7506
- "recordConversion": {
7507
- "name": "recordConversion",
6960
+ "save": {
6961
+ "name": "save",
7508
6962
  "async": true,
7509
- "parameters": [
7510
- {
7511
- "name": "params",
7512
- "type": "RecordConversionParams",
7513
- "optional": false
7514
- }
7515
- ],
7516
- "returnType": "Promise<RecordConversionResult>",
6963
+ "parameters": [],
6964
+ "returnType": "Promise",
7517
6965
  "isStatic": false,
7518
6966
  "isPublic": true
7519
6967
  }
7520
6968
  },
7521
- "decoratorConfig": {},
7522
- "extends": "SmrtCollection",
7523
- "extendsTypeArg": "OpportunityConversion",
7524
- "exportName": "OpportunityConversionCollection",
7525
- "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
+ ],
7526
7013
  "schema": {
7527
- "tableName": "opportunity_conversion_collections",
7528
- "ddl": "CREATE TABLE IF NOT EXISTS \"opportunity_conversion_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
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);",
7529
7016
  "columns": {
7530
7017
  "id": {
7531
7018
  "type": "UUID",
@@ -7551,95 +7038,188 @@
7551
7038
  "type": "TIMESTAMP",
7552
7039
  "notNull": true,
7553
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": "{}"
7554
7077
  }
7555
7078
  },
7556
7079
  "indexes": [
7557
7080
  {
7558
- "name": "opportunity_conversion_collections_id_idx",
7081
+ "name": "opportunity_conversions_id_idx",
7559
7082
  "columns": [
7560
7083
  "id"
7561
7084
  ]
7562
7085
  },
7563
7086
  {
7564
- "name": "opportunity_conversion_collections_slug_context_idx",
7087
+ "name": "opportunity_conversions_opportunity_id_target_kind_idx",
7565
7088
  "columns": [
7566
- "slug",
7567
- "context"
7089
+ "opportunity_id",
7090
+ "target_kind",
7091
+ "target_id"
7568
7092
  ],
7569
7093
  "unique": true
7570
7094
  }
7571
7095
  ],
7572
- "version": "7e30ff1b"
7096
+ "version": "82c29042"
7573
7097
  }
7574
7098
  },
7575
- "@happyvertical/smrt-sales:PipelineDefinitionCollection": {
7576
- "name": "pipelinedefinitioncollection",
7577
- "className": "PipelineDefinitionCollection",
7578
- "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinitionCollection",
7099
+ "@happyvertical/smrt-sales:PipelineDefinition": {
7100
+ "name": "pipelinedefinition",
7101
+ "className": "PipelineDefinition",
7102
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineDefinition",
7579
7103
  "collection": "pipelinedefinitions",
7580
- "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",
7581
7105
  "packageName": "@happyvertical/smrt-sales",
7582
- "fields": {},
7583
- "methods": {
7584
- "findByKey": {
7585
- "name": "findByKey",
7586
- "async": true,
7587
- "parameters": [
7588
- {
7589
- "name": "key",
7590
- "type": "string",
7591
- "optional": false
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
7592
7122
  }
7593
- ],
7594
- "returnType": "Promise<PipelineDefinition | null>",
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
+ },
7154
+ "methods": {
7155
+ "isActive": {
7156
+ "name": "isActive",
7157
+ "async": false,
7158
+ "parameters": [],
7159
+ "returnType": "boolean",
7595
7160
  "isStatic": false,
7596
7161
  "isPublic": true
7597
7162
  },
7598
- "findDefault": {
7599
- "name": "findDefault",
7600
- "async": true,
7163
+ "getMetadata": {
7164
+ "name": "getMetadata",
7165
+ "async": false,
7601
7166
  "parameters": [],
7602
- "returnType": "Promise<PipelineDefinition | null>",
7167
+ "returnType": "Record<string>",
7603
7168
  "isStatic": false,
7604
7169
  "isPublic": true
7605
7170
  },
7606
- "getStages": {
7607
- "name": "getStages",
7608
- "async": true,
7171
+ "setMetadata": {
7172
+ "name": "setMetadata",
7173
+ "async": false,
7609
7174
  "parameters": [
7610
7175
  {
7611
- "name": "pipelineId",
7612
- "type": "string",
7176
+ "name": "metadata",
7177
+ "type": "Record<string>",
7613
7178
  "optional": false
7614
7179
  }
7615
7180
  ],
7616
- "returnType": "Promise<PipelineStage[]>",
7181
+ "returnType": "void",
7617
7182
  "isStatic": false,
7618
7183
  "isPublic": true
7184
+ }
7185
+ },
7186
+ "decoratorConfig": {
7187
+ "api": {
7188
+ "include": [
7189
+ "list",
7190
+ "get",
7191
+ "create",
7192
+ "update"
7193
+ ]
7619
7194
  },
7620
- "ensureDefaultPipeline": {
7621
- "name": "ensureDefaultPipeline",
7622
- "async": true,
7623
- "parameters": [
7624
- {
7625
- "name": "params",
7626
- "type": "EnsureDefaultPipelineParams",
7627
- "optional": true
7628
- }
7629
- ],
7630
- "returnType": "Promise<EnsureDefaultPipelineResult>",
7631
- "isStatic": false,
7632
- "isPublic": true
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"
7633
7208
  }
7634
7209
  },
7635
- "decoratorConfig": {},
7636
- "extends": "SmrtCollection",
7637
- "extendsTypeArg": "PipelineDefinition",
7638
- "exportName": "PipelineDefinitionCollection",
7639
- "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
+ ],
7640
7220
  "schema": {
7641
- "tableName": "pipeline_definition_collections",
7642
- "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_definition_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
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);",
7643
7223
  "columns": {
7644
7224
  "id": {
7645
7225
  "type": "UUID",
@@ -7665,78 +7245,210 @@
7665
7245
  "type": "TIMESTAMP",
7666
7246
  "notNull": true,
7667
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": "{}"
7668
7284
  }
7669
7285
  },
7670
7286
  "indexes": [
7671
7287
  {
7672
- "name": "pipeline_definition_collections_id_idx",
7288
+ "name": "pipeline_definitions_id_idx",
7673
7289
  "columns": [
7674
7290
  "id"
7675
7291
  ]
7676
7292
  },
7677
7293
  {
7678
- "name": "pipeline_definition_collections_slug_context_idx",
7294
+ "name": "pipeline_definitions_tenant_id_key_idx",
7679
7295
  "columns": [
7680
- "slug",
7681
- "context"
7296
+ "tenant_id",
7297
+ "key"
7682
7298
  ],
7683
7299
  "unique": true
7684
7300
  }
7685
7301
  ],
7686
- "version": "f85d1436"
7302
+ "version": "5e3ace6c"
7687
7303
  }
7688
7304
  },
7689
- "@happyvertical/smrt-sales:PipelineStageCollection": {
7690
- "name": "pipelinestagecollection",
7691
- "className": "PipelineStageCollection",
7692
- "qualifiedName": "@happyvertical/smrt-sales:PipelineStageCollection",
7305
+ "@happyvertical/smrt-sales:PipelineStage": {
7306
+ "name": "pipelinestage",
7307
+ "className": "PipelineStage",
7308
+ "qualifiedName": "@happyvertical/smrt-sales:PipelineStage",
7693
7309
  "collection": "pipelinestages",
7694
- "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",
7695
7311
  "packageName": "@happyvertical/smrt-sales",
7696
- "fields": {},
7697
- "methods": {
7698
- "findByPipeline": {
7699
- "name": "findByPipeline",
7700
- "async": true,
7701
- "parameters": [
7702
- {
7703
- "name": "pipelineId",
7704
- "type": "string",
7705
- "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
7706
7328
  }
7707
- ],
7708
- "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",
7384
+ "isStatic": false,
7385
+ "isPublic": true
7386
+ },
7387
+ "getMetadata": {
7388
+ "name": "getMetadata",
7389
+ "async": false,
7390
+ "parameters": [],
7391
+ "returnType": "Record<string>",
7709
7392
  "isStatic": false,
7710
7393
  "isPublic": true
7711
7394
  },
7712
- "findByKey": {
7713
- "name": "findByKey",
7714
- "async": true,
7395
+ "setMetadata": {
7396
+ "name": "setMetadata",
7397
+ "async": false,
7715
7398
  "parameters": [
7716
7399
  {
7717
- "name": "pipelineId",
7718
- "type": "string",
7719
- "optional": false
7720
- },
7721
- {
7722
- "name": "key",
7723
- "type": "string",
7400
+ "name": "metadata",
7401
+ "type": "Record<string>",
7724
7402
  "optional": false
7725
7403
  }
7726
7404
  ],
7727
- "returnType": "Promise<PipelineStage | null>",
7405
+ "returnType": "void",
7728
7406
  "isStatic": false,
7729
7407
  "isPublic": true
7730
7408
  }
7731
7409
  },
7732
- "decoratorConfig": {},
7733
- "extends": "SmrtCollection",
7734
- "extendsTypeArg": "PipelineStage",
7735
- "exportName": "PipelineStageCollection",
7736
- "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
+ ],
7737
7449
  "schema": {
7738
- "tableName": "pipeline_stage_collections",
7739
- "ddl": "CREATE TABLE IF NOT EXISTS \"pipeline_stage_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
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);",
7740
7452
  "columns": {
7741
7453
  "id": {
7742
7454
  "type": "UUID",
@@ -7762,83 +7474,213 @@
7762
7474
  "type": "TIMESTAMP",
7763
7475
  "notNull": true,
7764
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": "{}"
7765
7531
  }
7766
7532
  },
7767
7533
  "indexes": [
7768
7534
  {
7769
- "name": "pipeline_stage_collections_id_idx",
7535
+ "name": "pipeline_stages_id_idx",
7770
7536
  "columns": [
7771
7537
  "id"
7772
7538
  ]
7773
7539
  },
7774
7540
  {
7775
- "name": "pipeline_stage_collections_slug_context_idx",
7541
+ "name": "pipeline_stages_pipeline_id_key_idx",
7776
7542
  "columns": [
7777
- "slug",
7778
- "context"
7543
+ "pipeline_id",
7544
+ "key"
7779
7545
  ],
7780
7546
  "unique": true
7781
7547
  }
7782
7548
  ],
7783
- "version": "72c2d7b3"
7549
+ "version": "bdb0cf4e"
7784
7550
  }
7785
7551
  },
7786
- "@happyvertical/smrt-sales:SalesActivityCollection": {
7787
- "name": "salesactivitycollection",
7788
- "className": "SalesActivityCollection",
7789
- "qualifiedName": "@happyvertical/smrt-sales:SalesActivityCollection",
7552
+ "@happyvertical/smrt-sales:SalesActivity": {
7553
+ "name": "salesactivity",
7554
+ "className": "SalesActivity",
7555
+ "qualifiedName": "@happyvertical/smrt-sales:SalesActivity",
7790
7556
  "collection": "salesactivities",
7791
- "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",
7792
7558
  "packageName": "@happyvertical/smrt-sales",
7793
- "fields": {},
7794
- "methods": {
7795
- "findBySubject": {
7796
- "name": "findBySubject",
7797
- "async": true,
7798
- "parameters": [
7799
- {
7800
- "name": "subjectKind",
7801
- "type": "SalesActivitySubjectKind",
7802
- "optional": false
7803
- },
7804
- {
7805
- "name": "subjectId",
7806
- "type": "string",
7807
- "optional": false
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
7808
7575
  }
7809
- ],
7810
- "returnType": "Promise<SalesActivity[]>",
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
+ },
7620
+ "methods": {
7621
+ "isOpenTask": {
7622
+ "name": "isOpenTask",
7623
+ "async": false,
7624
+ "parameters": [],
7625
+ "returnType": "boolean",
7811
7626
  "isStatic": false,
7812
7627
  "isPublic": true
7813
7628
  },
7814
- "findOpenTasks": {
7815
- "name": "findOpenTasks",
7816
- "async": true,
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,
7817
7640
  "parameters": [
7818
7641
  {
7819
- "name": "subjectKind",
7820
- "type": "SalesActivitySubjectKind",
7821
- "optional": false
7822
- },
7823
- {
7824
- "name": "subjectId",
7825
- "type": "string",
7642
+ "name": "metadata",
7643
+ "type": "Record<string>",
7826
7644
  "optional": false
7827
7645
  }
7828
7646
  ],
7829
- "returnType": "Promise<SalesActivity[]>",
7647
+ "returnType": "void",
7830
7648
  "isStatic": false,
7831
7649
  "isPublic": true
7832
7650
  }
7833
7651
  },
7834
- "decoratorConfig": {},
7835
- "extends": "SmrtCollection",
7836
- "extendsTypeArg": "SalesActivity",
7837
- "exportName": "SalesActivityCollection",
7838
- "collectionExportName": "SalesActivityCollectionCollection",
7652
+ "decoratorConfig": {
7653
+ "api": {
7654
+ "include": [
7655
+ "create",
7656
+ "list",
7657
+ "get"
7658
+ ]
7659
+ },
7660
+ "mcp": {
7661
+ "include": [
7662
+ "list",
7663
+ "create"
7664
+ ]
7665
+ },
7666
+ "cli": false,
7667
+ "tenantScoped": {
7668
+ "mode": "optional"
7669
+ }
7670
+ },
7671
+ "extends": "SmrtObject",
7672
+ "exportName": "SalesActivity",
7673
+ "collectionExportName": "SalesActivityCollection",
7674
+ "validationRules": [
7675
+ {
7676
+ "field": "subjectId",
7677
+ "rule": "required",
7678
+ "fieldType": "text"
7679
+ }
7680
+ ],
7839
7681
  "schema": {
7840
- "tableName": "sales_activity_collections",
7841
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activity_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7682
+ "tableName": "sales_activities",
7683
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_activities\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"subject_kind\" TEXT DEFAULT 'lead',\n \"subject_id\" TEXT NOT NULL DEFAULT '',\n \"activity_kind\" TEXT DEFAULT 'note',\n \"summary\" TEXT DEFAULT '',\n \"due_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"actor_profile_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}'\n);",
7842
7684
  "columns": {
7843
7685
  "id": {
7844
7686
  "type": "UUID",
@@ -7864,17 +7706,69 @@
7864
7706
  "type": "TIMESTAMP",
7865
7707
  "notNull": true,
7866
7708
  "default": "current_timestamp"
7709
+ },
7710
+ "tenant_id": {
7711
+ "type": "UUID",
7712
+ "referenceKind": "tenantId",
7713
+ "notNull": false,
7714
+ "unique": false
7715
+ },
7716
+ "subject_kind": {
7717
+ "type": "TEXT",
7718
+ "notNull": false,
7719
+ "unique": false,
7720
+ "default": "lead"
7721
+ },
7722
+ "subject_id": {
7723
+ "type": "TEXT",
7724
+ "notNull": true,
7725
+ "unique": false,
7726
+ "default": ""
7727
+ },
7728
+ "activity_kind": {
7729
+ "type": "TEXT",
7730
+ "notNull": false,
7731
+ "unique": false,
7732
+ "default": "note"
7733
+ },
7734
+ "summary": {
7735
+ "type": "TEXT",
7736
+ "notNull": false,
7737
+ "unique": false,
7738
+ "default": ""
7739
+ },
7740
+ "due_at": {
7741
+ "type": "TIMESTAMP",
7742
+ "notNull": false,
7743
+ "unique": false
7744
+ },
7745
+ "completed_at": {
7746
+ "type": "TIMESTAMP",
7747
+ "notNull": false,
7748
+ "unique": false
7749
+ },
7750
+ "actor_profile_id": {
7751
+ "type": "UUID",
7752
+ "referenceKind": "crossPackageRef",
7753
+ "notNull": false,
7754
+ "unique": false
7755
+ },
7756
+ "metadata": {
7757
+ "type": "TEXT",
7758
+ "notNull": false,
7759
+ "unique": false,
7760
+ "default": "{}"
7867
7761
  }
7868
7762
  },
7869
7763
  "indexes": [
7870
7764
  {
7871
- "name": "sales_activity_collections_id_idx",
7765
+ "name": "sales_activities_id_idx",
7872
7766
  "columns": [
7873
7767
  "id"
7874
7768
  ]
7875
7769
  },
7876
7770
  {
7877
- "name": "sales_activity_collections_slug_context_idx",
7771
+ "name": "sales_activities_slug_context_idx",
7878
7772
  "columns": [
7879
7773
  "slug",
7880
7774
  "context"
@@ -7882,49 +7776,119 @@
7882
7776
  "unique": true
7883
7777
  }
7884
7778
  ],
7885
- "version": "766a0235"
7779
+ "version": "b3173b53"
7886
7780
  }
7887
7781
  },
7888
- "@happyvertical/smrt-sales:SalesRepresentativeCollection": {
7889
- "name": "salesrepresentativecollection",
7890
- "className": "SalesRepresentativeCollection",
7891
- "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentativeCollection",
7782
+ "@happyvertical/smrt-sales:SalesRepresentative": {
7783
+ "name": "salesrepresentative",
7784
+ "className": "SalesRepresentative",
7785
+ "qualifiedName": "@happyvertical/smrt-sales:SalesRepresentative",
7892
7786
  "collection": "salesrepresentatives",
7893
- "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/collections/SalesRepresentativeCollection.ts",
7787
+ "filePath": "/home/runner/_work/smrt/smrt/packages/sales/src/crm/models/SalesRepresentative.ts",
7894
7788
  "packageName": "@happyvertical/smrt-sales",
7895
- "fields": {},
7789
+ "fields": {
7790
+ "tenantId": {
7791
+ "type": "text",
7792
+ "required": false,
7793
+ "_meta": {
7794
+ "sqlType": "UUID",
7795
+ "nullable": true,
7796
+ "__tenancy": {
7797
+ "isTenantIdField": true,
7798
+ "autoFilter": true,
7799
+ "required": false,
7800
+ "autoPopulate": true,
7801
+ "nullable": true,
7802
+ "mode": "optional",
7803
+ "field": "tenantId",
7804
+ "allowSuperAdminBypass": false
7805
+ }
7806
+ }
7807
+ },
7808
+ "profileId": {
7809
+ "type": "crossPackageRef",
7810
+ "required": false,
7811
+ "related": "@happyvertical/smrt-profiles:Profile"
7812
+ },
7813
+ "earnerId": {
7814
+ "type": "foreignKey",
7815
+ "required": false,
7816
+ "related": "Earner"
7817
+ },
7818
+ "status": {
7819
+ "type": "text",
7820
+ "required": false,
7821
+ "default": "active"
7822
+ },
7823
+ "title": {
7824
+ "type": "text",
7825
+ "required": false,
7826
+ "default": ""
7827
+ },
7828
+ "metadata": {
7829
+ "type": "text",
7830
+ "required": false,
7831
+ "default": "{}"
7832
+ }
7833
+ },
7896
7834
  "methods": {
7897
- "findByProfile": {
7898
- "name": "findByProfile",
7899
- "async": true,
7835
+ "isActive": {
7836
+ "name": "isActive",
7837
+ "async": false,
7838
+ "parameters": [],
7839
+ "returnType": "boolean",
7840
+ "isStatic": false,
7841
+ "isPublic": true
7842
+ },
7843
+ "getMetadata": {
7844
+ "name": "getMetadata",
7845
+ "async": false,
7846
+ "parameters": [],
7847
+ "returnType": "Record<string>",
7848
+ "isStatic": false,
7849
+ "isPublic": true
7850
+ },
7851
+ "setMetadata": {
7852
+ "name": "setMetadata",
7853
+ "async": false,
7900
7854
  "parameters": [
7901
7855
  {
7902
- "name": "profileId",
7903
- "type": "string",
7856
+ "name": "metadata",
7857
+ "type": "Record<string>",
7904
7858
  "optional": false
7905
7859
  }
7906
7860
  ],
7907
- "returnType": "Promise<SalesRepresentative[]>",
7861
+ "returnType": "void",
7908
7862
  "isStatic": false,
7909
7863
  "isPublic": true
7864
+ }
7865
+ },
7866
+ "decoratorConfig": {
7867
+ "api": {
7868
+ "include": [
7869
+ "list",
7870
+ "get",
7871
+ "create",
7872
+ "update"
7873
+ ]
7910
7874
  },
7911
- "findActive": {
7912
- "name": "findActive",
7913
- "async": true,
7914
- "parameters": [],
7915
- "returnType": "Promise<SalesRepresentative[]>",
7916
- "isStatic": false,
7917
- "isPublic": true
7875
+ "mcp": {
7876
+ "include": [
7877
+ "list",
7878
+ "get"
7879
+ ]
7880
+ },
7881
+ "cli": true,
7882
+ "tenantScoped": {
7883
+ "mode": "optional"
7918
7884
  }
7919
7885
  },
7920
- "decoratorConfig": {},
7921
- "extends": "SmrtCollection",
7922
- "extendsTypeArg": "SalesRepresentative",
7923
- "exportName": "SalesRepresentativeCollection",
7924
- "collectionExportName": "SalesRepresentativeCollectionCollection",
7886
+ "extends": "SmrtObject",
7887
+ "exportName": "SalesRepresentative",
7888
+ "collectionExportName": "SalesRepresentativeCollection",
7925
7889
  "schema": {
7926
- "tableName": "sales_representative_collections",
7927
- "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representative_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
7890
+ "tableName": "sales_representatives",
7891
+ "ddl": "CREATE TABLE IF NOT EXISTS \"sales_representatives\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"profile_id\" UUID,\n \"earner_id\" UUID,\n \"status\" TEXT DEFAULT 'active',\n \"title\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
7928
7892
  "columns": {
7929
7893
  "id": {
7930
7894
  "type": "UUID",
@@ -7950,17 +7914,53 @@
7950
7914
  "type": "TIMESTAMP",
7951
7915
  "notNull": true,
7952
7916
  "default": "current_timestamp"
7917
+ },
7918
+ "tenant_id": {
7919
+ "type": "UUID",
7920
+ "referenceKind": "tenantId",
7921
+ "notNull": false,
7922
+ "unique": false
7923
+ },
7924
+ "profile_id": {
7925
+ "type": "UUID",
7926
+ "referenceKind": "crossPackageRef",
7927
+ "notNull": false,
7928
+ "unique": false
7929
+ },
7930
+ "earner_id": {
7931
+ "type": "UUID",
7932
+ "referenceKind": "foreignKey",
7933
+ "notNull": false,
7934
+ "unique": false
7935
+ },
7936
+ "status": {
7937
+ "type": "TEXT",
7938
+ "notNull": false,
7939
+ "unique": false,
7940
+ "default": "active"
7941
+ },
7942
+ "title": {
7943
+ "type": "TEXT",
7944
+ "notNull": false,
7945
+ "unique": false,
7946
+ "default": ""
7947
+ },
7948
+ "metadata": {
7949
+ "type": "TEXT",
7950
+ "notNull": false,
7951
+ "unique": false,
7952
+ "default": "{}"
7953
7953
  }
7954
7954
  },
7955
7955
  "indexes": [
7956
7956
  {
7957
- "name": "sales_representative_collections_id_idx",
7957
+ "name": "sales_representatives_id_idx",
7958
7958
  "columns": [
7959
7959
  "id"
7960
7960
  ]
7961
7961
  },
7962
7962
  {
7963
- "name": "sales_representative_collections_slug_context_idx",
7963
+ "name": "sales_representatives_slug_context_idx",
7964
7964
  "columns": [
7965
7965
  "slug",
7966
7966
  "context"
@@ -7968,7 +7968,7 @@
7968
7968
  "unique": true
7969
7969
  }
7970
7970
  ],
7971
- "version": "6613c45d"
7971
+ "version": "7b67ed6e"
7972
7972
  }
7973
7973
  },
7974
7974
  "@happyvertical/smrt-sales:AttributionExceptionCollection": {