@happyvertical/smrt-sales 0.40.47 → 0.40.48

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