@memnexus-ai/typescript-sdk 1.17.1 → 1.20.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -23,6 +23,7 @@ __export(index_exports, {
23
23
  ApiKeysService: () => ApiKeysService,
24
24
  ArtifactsService: () => ArtifactsService,
25
25
  BehaviorService: () => BehaviorService,
26
+ BillingService: () => BillingService,
26
27
  CommunitiesService: () => CommunitiesService,
27
28
  ContentType: () => ContentType,
28
29
  ConversationsService: () => ConversationsService,
@@ -44,9 +45,12 @@ __export(index_exports, {
44
45
  batchGetMemoriesMeta: () => batchGetMemoriesMeta,
45
46
  batchGetMemoriesRequest: () => batchGetMemoriesRequest,
46
47
  batchGetMemoriesResponse: () => batchGetMemoriesResponse,
48
+ billingOverview: () => billingOverview,
49
+ checkoutSessionResponse: () => checkoutSessionResponse,
47
50
  community: () => community,
48
51
  conversation: () => conversation,
49
52
  createArtifactRequest: () => createArtifactRequest,
53
+ createCheckoutSessionRequest: () => createCheckoutSessionRequest,
50
54
  createConversationRequest: () => createConversationRequest,
51
55
  createFactRequest: () => createFactRequest,
52
56
  createMemoryRelationshipRequest: () => createMemoryRelationshipRequest,
@@ -54,6 +58,7 @@ __export(index_exports, {
54
58
  createMemoryResponse: () => createMemoryResponse,
55
59
  createMemoryResponseMeta: () => createMemoryResponseMeta,
56
60
  createNarrativeRequest: () => createNarrativeRequest,
61
+ createPortalSessionRequest: () => createPortalSessionRequest,
57
62
  default: () => index_default,
58
63
  entity: () => entity,
59
64
  error: () => error,
@@ -64,7 +69,10 @@ __export(index_exports, {
64
69
  graphRAGQueryRequest: () => graphRAGQueryRequest,
65
70
  graphRAGQueryResponse: () => graphRAGQueryResponse,
66
71
  healthCheck: () => healthCheck,
72
+ invoice: () => invoice,
73
+ listInvoicesResponse: () => listInvoicesResponse,
67
74
  listNarrativesResponse: () => listNarrativesResponse,
75
+ listPaymentMethodsResponse: () => listPaymentMethodsResponse,
68
76
  memory: () => memory,
69
77
  memoryRelationship: () => memoryRelationship,
70
78
  memoryRelationshipsResponse: () => memoryRelationshipsResponse,
@@ -74,11 +82,14 @@ __export(index_exports, {
74
82
  narrativeTimelineResponse: () => narrativeTimelineResponse,
75
83
  pagination: () => pagination,
76
84
  pattern: () => pattern,
85
+ paymentMethod: () => paymentMethod,
86
+ portalSessionResponse: () => portalSessionResponse,
77
87
  relatedMemoryResult: () => relatedMemoryResult,
78
88
  searchRequest: () => searchRequest,
79
89
  searchResponse: () => searchResponse,
80
90
  searchResult: () => searchResult,
81
91
  serviceCheck: () => serviceCheck,
92
+ subscription: () => subscription,
82
93
  temporalMetadata: () => temporalMetadata,
83
94
  topic: () => topic,
84
95
  topicReference: () => topicReference,
@@ -827,6 +838,289 @@ var ArtifactsService = class extends BaseService {
827
838
  }
828
839
  };
829
840
 
841
+ // src/services/billing-service.ts
842
+ var BillingService = class extends BaseService {
843
+ /**
844
+ * Get billing overview
845
+ * Get subscription, payment method, and upcoming invoice information
846
+ */
847
+ async getBillingOverview() {
848
+ const request = new Request({
849
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
850
+ method: "GET",
851
+ path: "/api/billing/overview",
852
+ config: this.config,
853
+ retry: {
854
+ attempts: 3,
855
+ delayMs: 150,
856
+ maxDelayMs: 5e3,
857
+ jitterMs: 50,
858
+ backoffFactor: 2
859
+ }
860
+ });
861
+ return this.client.call(request);
862
+ }
863
+ /**
864
+ * Create checkout session
865
+ * Create a Stripe checkout session for subscription upgrade
866
+ * @param body - Request body
867
+ */
868
+ async createCheckoutSession(body) {
869
+ const request = new Request({
870
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
871
+ method: "POST",
872
+ path: "/api/billing/checkout",
873
+ config: this.config,
874
+ retry: {
875
+ attempts: 3,
876
+ delayMs: 150,
877
+ maxDelayMs: 5e3,
878
+ jitterMs: 50,
879
+ backoffFactor: 2
880
+ }
881
+ });
882
+ if (body !== void 0) {
883
+ request.addBody(body);
884
+ }
885
+ return this.client.call(request);
886
+ }
887
+ /**
888
+ * Create billing portal session
889
+ * Create a Stripe billing portal session for managing subscription
890
+ * @param body - Request body
891
+ */
892
+ async createPortalSession(body) {
893
+ const request = new Request({
894
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
895
+ method: "POST",
896
+ path: "/api/billing/portal",
897
+ config: this.config,
898
+ retry: {
899
+ attempts: 3,
900
+ delayMs: 150,
901
+ maxDelayMs: 5e3,
902
+ jitterMs: 50,
903
+ backoffFactor: 2
904
+ }
905
+ });
906
+ if (body !== void 0) {
907
+ request.addBody(body);
908
+ }
909
+ return this.client.call(request);
910
+ }
911
+ /**
912
+ * Get current subscription
913
+ * Get the current subscription details for the authenticated user
914
+ */
915
+ async getSubscription() {
916
+ const request = new Request({
917
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
918
+ method: "GET",
919
+ path: "/api/billing/subscription",
920
+ config: this.config,
921
+ retry: {
922
+ attempts: 3,
923
+ delayMs: 150,
924
+ maxDelayMs: 5e3,
925
+ jitterMs: 50,
926
+ backoffFactor: 2
927
+ }
928
+ });
929
+ return this.client.call(request);
930
+ }
931
+ /**
932
+ * Cancel subscription
933
+ * Cancel the current subscription at the end of the billing period
934
+ * @param body - Request body
935
+ */
936
+ async cancelSubscription(options) {
937
+ const request = new Request({
938
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
939
+ method: "POST",
940
+ path: "/api/billing/subscription/cancel",
941
+ config: this.config,
942
+ retry: {
943
+ attempts: 3,
944
+ delayMs: 150,
945
+ maxDelayMs: 5e3,
946
+ jitterMs: 50,
947
+ backoffFactor: 2
948
+ }
949
+ });
950
+ if (options?.body !== void 0) {
951
+ request.addBody(options?.body);
952
+ }
953
+ return this.client.call(request);
954
+ }
955
+ /**
956
+ * Reactivate subscription
957
+ * Reactivate a subscription that was scheduled for cancellation
958
+ * @param body - Request body
959
+ */
960
+ async reactivateSubscription(options) {
961
+ const request = new Request({
962
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
963
+ method: "POST",
964
+ path: "/api/billing/subscription/reactivate",
965
+ config: this.config,
966
+ retry: {
967
+ attempts: 3,
968
+ delayMs: 150,
969
+ maxDelayMs: 5e3,
970
+ jitterMs: 50,
971
+ backoffFactor: 2
972
+ }
973
+ });
974
+ if (options?.body !== void 0) {
975
+ request.addBody(options?.body);
976
+ }
977
+ return this.client.call(request);
978
+ }
979
+ /**
980
+ * List invoices
981
+ * Get a list of invoices for the authenticated user
982
+ * @param limit - Maximum number of invoices to return
983
+ */
984
+ async listInvoices(options) {
985
+ const request = new Request({
986
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
987
+ method: "GET",
988
+ path: "/api/billing/invoices",
989
+ config: this.config,
990
+ retry: {
991
+ attempts: 3,
992
+ delayMs: 150,
993
+ maxDelayMs: 5e3,
994
+ jitterMs: 50,
995
+ backoffFactor: 2
996
+ }
997
+ });
998
+ if (options?.limit !== void 0) {
999
+ request.addQueryParam("limit", {
1000
+ key: "limit",
1001
+ value: options.limit,
1002
+ explode: false,
1003
+ encode: true,
1004
+ style: "form",
1005
+ isLimit: true,
1006
+ isOffset: false,
1007
+ isCursor: false
1008
+ });
1009
+ }
1010
+ return this.client.call(request);
1011
+ }
1012
+ /**
1013
+ * List payment methods
1014
+ * Get a list of payment methods for the authenticated user
1015
+ */
1016
+ async listPaymentMethods() {
1017
+ const request = new Request({
1018
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
1019
+ method: "GET",
1020
+ path: "/api/billing/payment-methods",
1021
+ config: this.config,
1022
+ retry: {
1023
+ attempts: 3,
1024
+ delayMs: 150,
1025
+ maxDelayMs: 5e3,
1026
+ jitterMs: 50,
1027
+ backoffFactor: 2
1028
+ }
1029
+ });
1030
+ return this.client.call(request);
1031
+ }
1032
+ /**
1033
+ * Set default payment method
1034
+ * Set a payment method as the default for future payments
1035
+ * @param id - The payment method ID
1036
+ * @param body - Request body
1037
+ */
1038
+ async setDefaultPaymentMethod(id, options) {
1039
+ const request = new Request({
1040
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
1041
+ method: "POST",
1042
+ path: "/api/billing/payment-methods/{id}/default",
1043
+ config: this.config,
1044
+ retry: {
1045
+ attempts: 3,
1046
+ delayMs: 150,
1047
+ maxDelayMs: 5e3,
1048
+ jitterMs: 50,
1049
+ backoffFactor: 2
1050
+ }
1051
+ });
1052
+ request.addPathParam("id", {
1053
+ key: "id",
1054
+ value: id,
1055
+ explode: false,
1056
+ encode: true,
1057
+ style: "simple",
1058
+ isLimit: false,
1059
+ isOffset: false,
1060
+ isCursor: false
1061
+ });
1062
+ if (options?.body !== void 0) {
1063
+ request.addBody(options?.body);
1064
+ }
1065
+ return this.client.call(request);
1066
+ }
1067
+ /**
1068
+ * Delete payment method
1069
+ * Remove a payment method from the account
1070
+ * @param id - The payment method ID
1071
+ */
1072
+ async deletePaymentMethod(id) {
1073
+ const request = new Request({
1074
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
1075
+ method: "DELETE",
1076
+ path: "/api/billing/payment-methods/{id}",
1077
+ config: this.config,
1078
+ retry: {
1079
+ attempts: 3,
1080
+ delayMs: 150,
1081
+ maxDelayMs: 5e3,
1082
+ jitterMs: 50,
1083
+ backoffFactor: 2
1084
+ }
1085
+ });
1086
+ request.addPathParam("id", {
1087
+ key: "id",
1088
+ value: id,
1089
+ explode: false,
1090
+ encode: true,
1091
+ style: "simple",
1092
+ isLimit: false,
1093
+ isOffset: false,
1094
+ isCursor: false
1095
+ });
1096
+ return this.client.call(request);
1097
+ }
1098
+ /**
1099
+ * Stripe webhook endpoint
1100
+ * Receive and process Stripe webhook events
1101
+ * @param body - Request body
1102
+ */
1103
+ async stripeWebhook(body) {
1104
+ const request = new Request({
1105
+ baseUrl: this.config.baseUrl || "http://localhost:3000",
1106
+ method: "POST",
1107
+ path: "/api/billing/webhooks",
1108
+ config: this.config,
1109
+ retry: {
1110
+ attempts: 3,
1111
+ delayMs: 150,
1112
+ maxDelayMs: 5e3,
1113
+ jitterMs: 50,
1114
+ backoffFactor: 2
1115
+ }
1116
+ });
1117
+ if (body !== void 0) {
1118
+ request.addBody(body);
1119
+ }
1120
+ return this.client.call(request);
1121
+ }
1122
+ };
1123
+
830
1124
  // src/services/conversations-service.ts
831
1125
  var ConversationsService = class extends BaseService {
832
1126
  /**
@@ -4321,6 +4615,143 @@ var userUsage = import_zod.z.object({
4321
4615
  periodStart: import_zod.z.string().datetime(),
4322
4616
  periodEnd: import_zod.z.string().datetime()
4323
4617
  });
4618
+ var subscription = import_zod.z.object({
4619
+ /** Stripe subscription ID */
4620
+ id: import_zod.z.string(),
4621
+ /** Current subscription status */
4622
+ status: import_zod.z.enum(["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"]),
4623
+ /** Plan type */
4624
+ plan: import_zod.z.enum(["free", "pro", "enterprise"]),
4625
+ /** Current period start date */
4626
+ currentPeriodStart: import_zod.z.string().datetime(),
4627
+ /** Current period end date */
4628
+ currentPeriodEnd: import_zod.z.string().datetime(),
4629
+ /** Whether subscription cancels at period end */
4630
+ cancelAtPeriodEnd: import_zod.z.boolean(),
4631
+ /** When subscription was canceled */
4632
+ canceledAt: import_zod.z.string().datetime().nullable()
4633
+ });
4634
+ var invoice = import_zod.z.object({
4635
+ /** Stripe invoice ID */
4636
+ id: import_zod.z.string(),
4637
+ /** Invoice number */
4638
+ number: import_zod.z.string().nullable(),
4639
+ /** Invoice status */
4640
+ status: import_zod.z.enum(["draft", "open", "paid", "uncollectible", "void"]),
4641
+ /** Amount due in cents */
4642
+ amountDue: import_zod.z.number(),
4643
+ /** Amount paid in cents */
4644
+ amountPaid: import_zod.z.number(),
4645
+ /** Three-letter ISO currency code */
4646
+ currency: import_zod.z.string(),
4647
+ /** Start of billing period */
4648
+ periodStart: import_zod.z.string().datetime(),
4649
+ /** End of billing period */
4650
+ periodEnd: import_zod.z.string().datetime(),
4651
+ /** When invoice was created */
4652
+ created: import_zod.z.string().datetime(),
4653
+ /** URL to view invoice */
4654
+ hostedInvoiceUrl: import_zod.z.string().url().nullable(),
4655
+ /** URL to download invoice PDF */
4656
+ invoicePdf: import_zod.z.string().url().nullable()
4657
+ });
4658
+ var paymentMethod = import_zod.z.object({
4659
+ /** Stripe payment method ID */
4660
+ id: import_zod.z.string(),
4661
+ /** Payment method type (card, etc.) */
4662
+ type: import_zod.z.string(),
4663
+ /** Card details if type is card */
4664
+ card: import_zod.z.object({
4665
+ /** Card brand (visa, mastercard, etc.) */
4666
+ brand: import_zod.z.string(),
4667
+ /** Last 4 digits of card */
4668
+ last4: import_zod.z.string(),
4669
+ /** Expiration month */
4670
+ expMonth: import_zod.z.number(),
4671
+ /** Expiration year */
4672
+ expYear: import_zod.z.number()
4673
+ }).nullable(),
4674
+ /** Whether this is the default payment method */
4675
+ isDefault: import_zod.z.boolean()
4676
+ });
4677
+ var billingOverview = import_zod.z.object({
4678
+ subscription: import_zod.z.object({
4679
+ /** Stripe subscription ID */
4680
+ id: import_zod.z.string(),
4681
+ /** Current subscription status */
4682
+ status: import_zod.z.enum(["active", "canceled", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"]),
4683
+ /** Plan type */
4684
+ plan: import_zod.z.enum(["free", "pro", "enterprise"]),
4685
+ /** Current period start date */
4686
+ currentPeriodStart: import_zod.z.string().datetime(),
4687
+ /** Current period end date */
4688
+ currentPeriodEnd: import_zod.z.string().datetime(),
4689
+ /** Whether subscription cancels at period end */
4690
+ cancelAtPeriodEnd: import_zod.z.boolean(),
4691
+ /** When subscription was canceled */
4692
+ canceledAt: import_zod.z.string().datetime().nullable()
4693
+ }),
4694
+ defaultPaymentMethod: import_zod.z.object({
4695
+ /** Stripe payment method ID */
4696
+ id: import_zod.z.string(),
4697
+ /** Payment method type (card, etc.) */
4698
+ type: import_zod.z.string(),
4699
+ /** Card details if type is card */
4700
+ card: import_zod.z.object({
4701
+ /** Card brand (visa, mastercard, etc.) */
4702
+ brand: import_zod.z.string(),
4703
+ /** Last 4 digits of card */
4704
+ last4: import_zod.z.string(),
4705
+ /** Expiration month */
4706
+ expMonth: import_zod.z.number(),
4707
+ /** Expiration year */
4708
+ expYear: import_zod.z.number()
4709
+ }).nullable(),
4710
+ /** Whether this is the default payment method */
4711
+ isDefault: import_zod.z.boolean()
4712
+ }),
4713
+ /** Upcoming invoice preview */
4714
+ upcomingInvoice: import_zod.z.object({
4715
+ /** Amount due in cents */
4716
+ amountDue: import_zod.z.number(),
4717
+ /** Currency code */
4718
+ currency: import_zod.z.string(),
4719
+ /** Next billing date */
4720
+ periodEnd: import_zod.z.string().datetime()
4721
+ }).nullable()
4722
+ });
4723
+ var createCheckoutSessionRequest = import_zod.z.object({
4724
+ /** Stripe price ID (defaults to Pro price) */
4725
+ priceId: import_zod.z.string().optional(),
4726
+ /** URL to redirect after successful checkout */
4727
+ successUrl: import_zod.z.string().url(),
4728
+ /** URL to redirect if checkout is canceled */
4729
+ cancelUrl: import_zod.z.string().url()
4730
+ });
4731
+ var checkoutSessionResponse = import_zod.z.object({
4732
+ /** Stripe checkout session ID */
4733
+ sessionId: import_zod.z.string(),
4734
+ /** URL to redirect user to Stripe checkout */
4735
+ url: import_zod.z.string().url()
4736
+ });
4737
+ var createPortalSessionRequest = import_zod.z.object({
4738
+ /** URL to redirect after leaving the portal */
4739
+ returnUrl: import_zod.z.string().url()
4740
+ });
4741
+ var portalSessionResponse = import_zod.z.object({
4742
+ /** URL to redirect user to Stripe billing portal */
4743
+ url: import_zod.z.string().url()
4744
+ });
4745
+ var listInvoicesResponse = import_zod.z.lazy(() => import_zod.z.object({
4746
+ /** List of invoices */
4747
+ data: import_zod.z.array(invoice),
4748
+ /** Whether there are more invoices */
4749
+ hasMore: import_zod.z.boolean()
4750
+ }));
4751
+ var listPaymentMethodsResponse = import_zod.z.lazy(() => import_zod.z.object({
4752
+ /** List of payment methods */
4753
+ data: import_zod.z.array(paymentMethod)
4754
+ }));
4324
4755
 
4325
4756
  // src/index.ts
4326
4757
  var Memnexus = class {
@@ -4329,6 +4760,8 @@ var Memnexus = class {
4329
4760
  apiKeys;
4330
4761
  /** Artifact storage and retrieval endpoints operations */
4331
4762
  artifacts;
4763
+ /** Subscription billing and payment management endpoints operations */
4764
+ billing;
4332
4765
  /** Conversation tracking and analysis endpoints operations */
4333
4766
  conversations;
4334
4767
  /** Fact extraction and management endpoints operations */
@@ -4364,6 +4797,7 @@ var Memnexus = class {
4364
4797
  };
4365
4798
  this.apiKeys = new ApiKeysService(this.config);
4366
4799
  this.artifacts = new ArtifactsService(this.config);
4800
+ this.billing = new BillingService(this.config);
4367
4801
  this.conversations = new ConversationsService(this.config);
4368
4802
  this.facts = new FactsService(this.config);
4369
4803
  this.graphrag = new GraphragService(this.config);
@@ -4385,6 +4819,7 @@ var Memnexus = class {
4385
4819
  this.config.token = token;
4386
4820
  this.apiKeys.token = token;
4387
4821
  this.artifacts.token = token;
4822
+ this.billing.token = token;
4388
4823
  this.conversations.token = token;
4389
4824
  this.facts.token = token;
4390
4825
  this.graphrag.token = token;
@@ -4406,6 +4841,7 @@ var Memnexus = class {
4406
4841
  this.config.baseUrl = baseUrl;
4407
4842
  this.apiKeys.baseUrl = baseUrl;
4408
4843
  this.artifacts.baseUrl = baseUrl;
4844
+ this.billing.baseUrl = baseUrl;
4409
4845
  this.conversations.baseUrl = baseUrl;
4410
4846
  this.facts.baseUrl = baseUrl;
4411
4847
  this.graphrag.baseUrl = baseUrl;
@@ -4427,6 +4863,7 @@ var Memnexus = class {
4427
4863
  this.config.environment = environment;
4428
4864
  this.apiKeys.environment = environment;
4429
4865
  this.artifacts.environment = environment;
4866
+ this.billing.environment = environment;
4430
4867
  this.conversations.environment = environment;
4431
4868
  this.facts.environment = environment;
4432
4869
  this.graphrag.environment = environment;
@@ -4447,6 +4884,7 @@ var index_default = Memnexus;
4447
4884
  ApiKeysService,
4448
4885
  ArtifactsService,
4449
4886
  BehaviorService,
4887
+ BillingService,
4450
4888
  CommunitiesService,
4451
4889
  ContentType,
4452
4890
  ConversationsService,
@@ -4468,9 +4906,12 @@ var index_default = Memnexus;
4468
4906
  batchGetMemoriesMeta,
4469
4907
  batchGetMemoriesRequest,
4470
4908
  batchGetMemoriesResponse,
4909
+ billingOverview,
4910
+ checkoutSessionResponse,
4471
4911
  community,
4472
4912
  conversation,
4473
4913
  createArtifactRequest,
4914
+ createCheckoutSessionRequest,
4474
4915
  createConversationRequest,
4475
4916
  createFactRequest,
4476
4917
  createMemoryRelationshipRequest,
@@ -4478,6 +4919,7 @@ var index_default = Memnexus;
4478
4919
  createMemoryResponse,
4479
4920
  createMemoryResponseMeta,
4480
4921
  createNarrativeRequest,
4922
+ createPortalSessionRequest,
4481
4923
  entity,
4482
4924
  error,
4483
4925
  fact,
@@ -4487,7 +4929,10 @@ var index_default = Memnexus;
4487
4929
  graphRAGQueryRequest,
4488
4930
  graphRAGQueryResponse,
4489
4931
  healthCheck,
4932
+ invoice,
4933
+ listInvoicesResponse,
4490
4934
  listNarrativesResponse,
4935
+ listPaymentMethodsResponse,
4491
4936
  memory,
4492
4937
  memoryRelationship,
4493
4938
  memoryRelationshipsResponse,
@@ -4497,11 +4942,14 @@ var index_default = Memnexus;
4497
4942
  narrativeTimelineResponse,
4498
4943
  pagination,
4499
4944
  pattern,
4945
+ paymentMethod,
4946
+ portalSessionResponse,
4500
4947
  relatedMemoryResult,
4501
4948
  searchRequest,
4502
4949
  searchResponse,
4503
4950
  searchResult,
4504
4951
  serviceCheck,
4952
+ subscription,
4505
4953
  temporalMetadata,
4506
4954
  topic,
4507
4955
  topicReference,