@cargo-ai/api 1.0.1

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.
Files changed (95) hide show
  1. package/build/src/api/ai/index.d.ts +78 -0
  2. package/build/src/api/ai/index.d.ts.map +1 -0
  3. package/build/src/api/ai/index.js +530 -0
  4. package/build/src/api/billing/index.d.ts +25 -0
  5. package/build/src/api/billing/index.d.ts.map +1 -0
  6. package/build/src/api/billing/index.js +155 -0
  7. package/build/src/api/connection/index.d.ts +28 -0
  8. package/build/src/api/connection/index.d.ts.map +1 -0
  9. package/build/src/api/connection/index.js +172 -0
  10. package/build/src/api/expression/index.d.ts +26 -0
  11. package/build/src/api/expression/index.d.ts.map +1 -0
  12. package/build/src/api/expression/index.js +115 -0
  13. package/build/src/api/index.d.ts +72 -0
  14. package/build/src/api/index.d.ts.map +1 -0
  15. package/build/src/api/index.js +51 -0
  16. package/build/src/api/orchestration/index.d.ts +66 -0
  17. package/build/src/api/orchestration/index.d.ts.map +1 -0
  18. package/build/src/api/orchestration/index.js +625 -0
  19. package/build/src/api/revenueOrganization/index.d.ts +37 -0
  20. package/build/src/api/revenueOrganization/index.d.ts.map +1 -0
  21. package/build/src/api/revenueOrganization/index.js +241 -0
  22. package/build/src/api/segmentation/index.d.ts +28 -0
  23. package/build/src/api/segmentation/index.d.ts.map +1 -0
  24. package/build/src/api/segmentation/index.js +188 -0
  25. package/build/src/api/storage/index.d.ts +45 -0
  26. package/build/src/api/storage/index.d.ts.map +1 -0
  27. package/build/src/api/storage/index.js +402 -0
  28. package/build/src/api/systemOfRecordIntegration/index.d.ts +29 -0
  29. package/build/src/api/systemOfRecordIntegration/index.d.ts.map +1 -0
  30. package/build/src/api/systemOfRecordIntegration/index.js +151 -0
  31. package/build/src/api/userManagement/index.d.ts +14 -0
  32. package/build/src/api/userManagement/index.d.ts.map +1 -0
  33. package/build/src/api/userManagement/index.js +33 -0
  34. package/build/src/api/workspaceManagement/index.d.ts +43 -0
  35. package/build/src/api/workspaceManagement/index.d.ts.map +1 -0
  36. package/build/src/api/workspaceManagement/index.js +283 -0
  37. package/build/src/client.d.ts +5 -0
  38. package/build/src/client.d.ts.map +1 -0
  39. package/build/src/client.js +24 -0
  40. package/build/src/fetcher/client.d.ts +7 -0
  41. package/build/src/fetcher/client.d.ts.map +1 -0
  42. package/build/src/fetcher/client.js +9 -0
  43. package/build/src/fetcher/error.d.ts +101 -0
  44. package/build/src/fetcher/error.d.ts.map +1 -0
  45. package/build/src/fetcher/error.js +184 -0
  46. package/build/src/fetcher/fetcher.d.ts +12 -0
  47. package/build/src/fetcher/fetcher.d.ts.map +1 -0
  48. package/build/src/fetcher/fetcher.js +1 -0
  49. package/build/src/fetcher/index.d.ts +34 -0
  50. package/build/src/fetcher/index.d.ts.map +1 -0
  51. package/build/src/fetcher/index.js +78 -0
  52. package/build/src/index.d.ts +5 -0
  53. package/build/src/index.d.ts.map +1 -0
  54. package/build/src/index.js +3 -0
  55. package/build/src/store/ai.d.ts +481 -0
  56. package/build/src/store/ai.d.ts.map +1 -0
  57. package/build/src/store/ai.js +112 -0
  58. package/build/src/store/billing.d.ts +140 -0
  59. package/build/src/store/billing.d.ts.map +1 -0
  60. package/build/src/store/billing.js +62 -0
  61. package/build/src/store/connection.d.ts +183 -0
  62. package/build/src/store/connection.d.ts.map +1 -0
  63. package/build/src/store/connection.js +88 -0
  64. package/build/src/store/expression.d.ts +112 -0
  65. package/build/src/store/expression.d.ts.map +1 -0
  66. package/build/src/store/expression.js +27 -0
  67. package/build/src/store/index.d.ts +14 -0
  68. package/build/src/store/index.d.ts.map +1 -0
  69. package/build/src/store/index.js +25 -0
  70. package/build/src/store/orchestration.d.ts +942 -0
  71. package/build/src/store/orchestration.d.ts.map +1 -0
  72. package/build/src/store/orchestration.js +217 -0
  73. package/build/src/store/revenueOrganization.d.ts +201 -0
  74. package/build/src/store/revenueOrganization.d.ts.map +1 -0
  75. package/build/src/store/revenueOrganization.js +68 -0
  76. package/build/src/store/segmentation.d.ts +566 -0
  77. package/build/src/store/segmentation.d.ts.map +1 -0
  78. package/build/src/store/segmentation.js +103 -0
  79. package/build/src/store/storage.d.ts +1096 -0
  80. package/build/src/store/storage.d.ts.map +1 -0
  81. package/build/src/store/storage.js +174 -0
  82. package/build/src/store/systemOfRecordIntegration.d.ts +122 -0
  83. package/build/src/store/systemOfRecordIntegration.d.ts.map +1 -0
  84. package/build/src/store/systemOfRecordIntegration.js +53 -0
  85. package/build/src/store/userManagement.d.ts +34 -0
  86. package/build/src/store/userManagement.d.ts.map +1 -0
  87. package/build/src/store/userManagement.js +22 -0
  88. package/build/src/store/workspaceManagement.d.ts +215 -0
  89. package/build/src/store/workspaceManagement.d.ts.map +1 -0
  90. package/build/src/store/workspaceManagement.js +103 -0
  91. package/build/src/types.d.ts +6 -0
  92. package/build/src/types.d.ts.map +1 -0
  93. package/build/src/types.js +1 -0
  94. package/build/tsconfig.tsbuildinfo +1 -0
  95. package/package.json +45 -0
@@ -0,0 +1,155 @@
1
+ import { getErrorWithReasonErrorMessage } from "../../fetcher/index.js";
2
+ import { Billing } from "../../store/index.js";
3
+ export const buildBillingApi = ({ fetcher, }) => {
4
+ async function getSubscription() {
5
+ const result = await fetcher.fetch({
6
+ method: "get",
7
+ endpoint: "billing/subscriptions",
8
+ });
9
+ return result;
10
+ }
11
+ async function getInvoices() {
12
+ const result = await fetcher.fetch({
13
+ method: "get",
14
+ endpoint: "billing/subscriptions/invoices",
15
+ });
16
+ return result;
17
+ }
18
+ async function getCreditCard() {
19
+ const result = await fetcher.fetch({
20
+ method: "get",
21
+ endpoint: "billing/subscriptions/creditCard",
22
+ });
23
+ return result;
24
+ }
25
+ async function createSetupIntent() {
26
+ const result = await fetcher.fetch({
27
+ method: "post",
28
+ endpoint: "billing/subscriptions/setupIntent",
29
+ });
30
+ return result;
31
+ }
32
+ async function updatePaymentMethod(payload) {
33
+ try {
34
+ await fetcher.fetch({
35
+ method: "put",
36
+ endpoint: "billing/subscriptions/paymentMethod",
37
+ payload,
38
+ });
39
+ }
40
+ catch (error) {
41
+ throw getErrorWithReasonErrorMessage(error, Billing.Api.zodCreatePortalSessionErrorReason, {
42
+ subscriptionNotFound: "Subscription not found",
43
+ });
44
+ }
45
+ }
46
+ async function createPortalSession() {
47
+ try {
48
+ const result = await fetcher.fetch({
49
+ method: "post",
50
+ endpoint: "billing/subscriptions/portalSessions",
51
+ });
52
+ return result;
53
+ }
54
+ catch (error) {
55
+ throw getErrorWithReasonErrorMessage(error, Billing.Api.zodCreatePortalSessionErrorReason, {
56
+ subscriptionNotFound: "Subscription not found",
57
+ });
58
+ }
59
+ }
60
+ async function createStripeCreditsCheckoutSession() {
61
+ try {
62
+ const result = await fetcher.fetch({
63
+ method: "post",
64
+ endpoint: "billing/subscriptions/creditsCheckoutSessions",
65
+ });
66
+ return result;
67
+ }
68
+ catch (error) {
69
+ throw getErrorWithReasonErrorMessage(error, Billing.Api.zodCreateStripeCreditsCheckoutSessionErrorReason, {
70
+ subscriptionNotFound: "Subscription not found",
71
+ failedToCreateCheckoutSession: "Could not start checkout session",
72
+ });
73
+ }
74
+ }
75
+ async function updatePlan(payload) {
76
+ try {
77
+ const result = await fetcher.fetch({
78
+ method: "put",
79
+ endpoint: "billing/subscriptions/plan",
80
+ payload,
81
+ });
82
+ return result;
83
+ }
84
+ catch (error) {
85
+ throw getErrorWithReasonErrorMessage(error, Billing.Api.zodUpdatePlanResultErrorReason, {
86
+ subscriptionNotFound: "Subscription not found",
87
+ customerNotFound: "Customer not found",
88
+ paymentMethodNotFound: "Default payment method not found",
89
+ scheduleSubscriptionChangeFailed: "Could not schedule subscription change",
90
+ subscriptionNotElligible: "Subscription not elligible for updates",
91
+ subscriptionAlreadyInUpdateState: "An update of your subscription is already in progress",
92
+ customerNotMigratedToOrb: "Subscription has not yet been migrated to usage-based pricing",
93
+ });
94
+ }
95
+ }
96
+ async function updateTopup(payload) {
97
+ try {
98
+ const result = await fetcher.fetch({
99
+ method: "put",
100
+ endpoint: "billing/subscriptions/topup",
101
+ payload,
102
+ });
103
+ return result;
104
+ }
105
+ catch (error) {
106
+ throw getErrorWithReasonErrorMessage(error, Billing.Api.zodUpdateTopupResultErrorReason, {
107
+ subscriptionNotFound: "Subscription not found",
108
+ customerNotFound: "Customer not found",
109
+ paymentMethodNotFound: "Default payment method not found",
110
+ subscriptionNotElligible: "Subscription not elligible for updates",
111
+ customerNotMigratedToOrb: "Subscription has not yet been migrated to usage-based pricing",
112
+ });
113
+ }
114
+ }
115
+ async function updateCreditsOverageBehaviors(payload) {
116
+ try {
117
+ await fetcher.fetch({
118
+ method: "put",
119
+ endpoint: "billing/subscriptions/creditsOverageBehaviors",
120
+ payload,
121
+ });
122
+ }
123
+ catch (error) {
124
+ throw getErrorWithReasonErrorMessage(error, Billing.Api.zodUpdateCreditsOverageBehaviorsResultErrorReason, {
125
+ subscriptionNotFound: "Subscription not found",
126
+ subscriptionNotEnterprise: "Credits overage behavior is only available for enterprise subscriptions",
127
+ });
128
+ }
129
+ }
130
+ async function getUsageMetrics(payload) {
131
+ const result = await fetcher.fetch({
132
+ method: "get",
133
+ endpoint: "billing/usage/metrics",
134
+ params: payload,
135
+ });
136
+ return result;
137
+ }
138
+ return {
139
+ usage: {
140
+ getMetrics: getUsageMetrics,
141
+ },
142
+ subscription: {
143
+ get: getSubscription,
144
+ getInvoices,
145
+ getCreditCard,
146
+ createSetupIntent,
147
+ updatePaymentMethod,
148
+ createPortalSession,
149
+ createStripeCreditsCheckoutSession,
150
+ updatePlan,
151
+ updateTopup,
152
+ updateCreditsOverageBehaviors,
153
+ },
154
+ };
155
+ };
@@ -0,0 +1,28 @@
1
+ import type { Fetcher } from "../../fetcher/index.js";
2
+ import { Connection } from "../../store/index.js";
3
+ interface ConnectionApiDependencies {
4
+ fetcher: Fetcher;
5
+ }
6
+ export interface ConnectionApi {
7
+ connector: {
8
+ autocomplete: (payload: Connection.Api.ConnectorAutocompletePayload) => Promise<Connection.Api.ConnectorAutocompleteResult>;
9
+ getDynamicSchema: (payload: Connection.Api.GetConnectorDynamicSchemaPayload) => Promise<Connection.Api.GetConnectorDynamicSchemaResult>;
10
+ getLanguageModels: (payload: Connection.Api.GetConnectorLanguageModelsPayload) => Promise<Connection.Api.GetConnectorLanguageModelsResult>;
11
+ create: (payload: Connection.Api.CreateConnectorPayload) => Promise<Connection.Api.CreateConnectorResult>;
12
+ all: () => Promise<Connection.Api.AllConnectorsResult>;
13
+ remove: (uuid: string) => Promise<void>;
14
+ update: (payload: Connection.Api.UpdateConnectorPayload) => Promise<Connection.Api.UpdateConnectorResult>;
15
+ existsBySlug: (payload: Connection.Api.ConnectorExistsBySlugPayload) => Promise<Connection.Api.ConnectorExistsBySlugResult>;
16
+ };
17
+ integration: {
18
+ getDocumentation: (slug: string) => Promise<string>;
19
+ all: () => Promise<Connection.Api.AllIntegrationsResult>;
20
+ completeOauth(payload: Connection.Api.CompleteIntegrationOauthPayload): Promise<Connection.Api.CompleteIntegrationOauthResult>;
21
+ };
22
+ nativeIntegration: {
23
+ get: () => Promise<Connection.Api.GetNativeIntegrationResult>;
24
+ };
25
+ }
26
+ export declare const buildConnectionApi: ({ fetcher, }: ConnectionApiDependencies) => ConnectionApi;
27
+ export {};
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE;QACT,YAAY,EAAE,CACZ,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,4BAA4B,KACjD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzD,gBAAgB,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C;KAC/D,CAAC;CACH;AAED,eAAO,MAAM,kBAAkB,iBAE5B,yBAAyB,KAAG,aAgP9B,CAAC"}
@@ -0,0 +1,172 @@
1
+ import { getErrorWithReasonErrorMessage } from "../../fetcher/index.js";
2
+ import { Connection } from "../../store/index.js";
3
+ export const buildConnectionApi = ({ fetcher, }) => {
4
+ async function autocompleteConnector(payload) {
5
+ const { connectorUuid, ...other } = payload;
6
+ try {
7
+ const result = await fetcher.fetch({
8
+ method: "post",
9
+ endpoint: `connection/connectors/${connectorUuid}/autocomplete`,
10
+ payload: other,
11
+ });
12
+ return result;
13
+ }
14
+ catch (error) {
15
+ throw getErrorWithReasonErrorMessage(error, Connection.Api.zodConnectorAutocompleteErrorReason, {
16
+ connectorNotFound: "Connector not found",
17
+ failedToGetIntegration: "Integration is not available",
18
+ failedToGetIntegrationAutocomplete: "Failed to get integration autocomplete",
19
+ });
20
+ }
21
+ }
22
+ async function getConnectorDynamicSchema(payload) {
23
+ const { connectorUuid, slug, ...other } = payload;
24
+ try {
25
+ const result = await fetcher.fetch({
26
+ method: "post",
27
+ endpoint: `connection/connectors/${connectorUuid}/dynamicSchemas/${slug}`,
28
+ payload: other,
29
+ });
30
+ return result;
31
+ }
32
+ catch (error) {
33
+ throw getErrorWithReasonErrorMessage(error, Connection.Api.zodGetConnectorDynamicSchemaErrorReason, {
34
+ connectorNotFound: "Connector not found",
35
+ failedToGetIntegration: "Integration is not available",
36
+ });
37
+ }
38
+ }
39
+ async function getConnectorLanguageModels(payload) {
40
+ const { connectorUuid } = payload;
41
+ try {
42
+ const result = await fetcher.fetch({
43
+ method: "get",
44
+ endpoint: `connection/connectors/${connectorUuid}/languageModels`,
45
+ });
46
+ return result;
47
+ }
48
+ catch (error) {
49
+ throw getErrorWithReasonErrorMessage(error, Connection.Api.zodGetConnectorLanguageModelsErrorReason, {
50
+ connectorNotFound: "Connector not found",
51
+ integrationNotFound: "Integration not found",
52
+ languageModelsNotSupported: "Language models are not supported for this integration",
53
+ failedToGetLanguageModels: "Failed to get language models",
54
+ });
55
+ }
56
+ }
57
+ async function createConnector(payload) {
58
+ try {
59
+ const result = await fetcher.fetch({
60
+ method: "post",
61
+ endpoint: "connection/connectors",
62
+ payload,
63
+ });
64
+ return result;
65
+ }
66
+ catch (error) {
67
+ throw getErrorWithReasonErrorMessage(error, Connection.Api.zodCreateConnectorErrorReason, {
68
+ unauthenticated: "Unauthenticated",
69
+ integrationNotFound: "Integration not found",
70
+ invalidConfig: "Invalid configuration",
71
+ });
72
+ }
73
+ }
74
+ async function allConnectors() {
75
+ const result = await fetcher.fetch({
76
+ method: "get",
77
+ endpoint: "connection/connectors/list",
78
+ });
79
+ return result;
80
+ }
81
+ async function removeConnector(uuid) {
82
+ try {
83
+ await fetcher.fetch({
84
+ method: "delete",
85
+ endpoint: `connection/connectors/${uuid}`,
86
+ });
87
+ }
88
+ catch (error) {
89
+ throw getErrorWithReasonErrorMessage(error, Connection.Api.zodRemoveConnectorErrorReason, {
90
+ connectorNotFound: "Connector not found",
91
+ connectorIsUsedInWorkflows: "Connector is used in some workflows",
92
+ connectorIsUsedInModels: "Connector is used in some models",
93
+ });
94
+ }
95
+ }
96
+ async function updateConnector(payload) {
97
+ const { uuid, ...other } = payload;
98
+ try {
99
+ const result = await fetcher.fetch({
100
+ method: "put",
101
+ endpoint: `connection/connectors/${uuid}`,
102
+ payload: other,
103
+ });
104
+ return result;
105
+ }
106
+ catch (error) {
107
+ throw getErrorWithReasonErrorMessage(error, Connection.Api.zodUpdateConnectorErrorReason, {
108
+ connectorNotFound: "Connector not found",
109
+ invalidConfig: "Invalid configuration",
110
+ integrationNotFound: "Integration not found",
111
+ unauthenticated: "Unauthenticated",
112
+ });
113
+ }
114
+ }
115
+ async function connectorExistsBySlug(payload) {
116
+ const { slug } = payload;
117
+ const result = await fetcher.fetch({
118
+ method: "get",
119
+ endpoint: `connection/connectors/existsBySlug`,
120
+ params: { slug },
121
+ });
122
+ return result;
123
+ }
124
+ async function completeIntegrationOauth(payload) {
125
+ const { slug, ...other } = payload;
126
+ const result = await fetcher.fetch({
127
+ method: "post",
128
+ endpoint: `connection/integrations/${slug}/completeOauth`,
129
+ payload: other,
130
+ });
131
+ return result;
132
+ }
133
+ async function getNativeIntegration() {
134
+ const result = await fetcher.fetch({
135
+ method: "get",
136
+ endpoint: "/connection/nativeIntegrations",
137
+ });
138
+ return result;
139
+ }
140
+ return {
141
+ connector: {
142
+ autocomplete: autocompleteConnector,
143
+ getDynamicSchema: getConnectorDynamicSchema,
144
+ getLanguageModels: getConnectorLanguageModels,
145
+ create: createConnector,
146
+ all: allConnectors,
147
+ remove: removeConnector,
148
+ update: updateConnector,
149
+ existsBySlug: connectorExistsBySlug,
150
+ },
151
+ integration: {
152
+ all: async () => {
153
+ const result = await fetcher.fetch({
154
+ method: "get",
155
+ endpoint: "connection/integrations/list",
156
+ });
157
+ return result;
158
+ },
159
+ getDocumentation: async (slug) => {
160
+ const result = await fetcher.fetch({
161
+ method: "get",
162
+ endpoint: `connection/integrations/${slug}/documentation`,
163
+ });
164
+ return result.replaceAll("./", `${fetcher.baseUrl}/v1/connection/integrations/${slug}/documentation/`);
165
+ },
166
+ completeOauth: completeIntegrationOauth,
167
+ },
168
+ nativeIntegration: {
169
+ get: getNativeIntegration,
170
+ },
171
+ };
172
+ };
@@ -0,0 +1,26 @@
1
+ import type { Fetcher } from "../../fetcher/index.js";
2
+ import { Expression } from "../../store/index.js";
3
+ interface ExpressionApiDependencies {
4
+ fetcher: Fetcher;
5
+ }
6
+ export interface ExpressionApi {
7
+ favoriteRecipe: {
8
+ create(payload: Expression.Api.CreateFavoriteRecipePayload): Promise<Expression.Api.CreateFavoriteRecipeResult>;
9
+ delete(payload: Expression.Api.DeleteFavoriteRecipePayload): Promise<Expression.Api.DeleteFavoriteRecipeResult>;
10
+ };
11
+ recipe: {
12
+ create(payload: Expression.Api.CreateRecipePayload): Promise<Expression.Api.CreateRecipeResult>;
13
+ createNewVersion(payload: Expression.Api.CreateNewRecipeVersionPayload): Promise<Expression.Api.CreateNewRecipeVersionResult>;
14
+ get(uuidOrShortId: string, version: number): Promise<Expression.Api.GetRecipeResult>;
15
+ getLastVersion(uuidOrShortId: string): Promise<Expression.Api.GetRecipeResult>;
16
+ list(payload: Expression.Api.ListRecipesPayload): Promise<Expression.Api.ListRecipesResult>;
17
+ archive(uuid: string): Promise<void>;
18
+ };
19
+ expression: {
20
+ evaluate(payload: Expression.Api.EvaluateExpressionPayload): Promise<Expression.Api.EvaluateExpressionResult>;
21
+ generate(payload: Expression.Api.GenerateExpressionPayload): Promise<Expression.Api.GenerateExpressionResult>;
22
+ };
23
+ }
24
+ export declare const buildExpressionApi: ({ fetcher, }: ExpressionApiDependencies) => ExpressionApi;
25
+ export {};
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/expression/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE;QACd,MAAM,CACJ,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,2BAA2B,GAClD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACtD,MAAM,CACJ,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,2BAA2B,GAClD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;KACvD,CAAC;IACF,MAAM,EAAE;QACN,MAAM,CACJ,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,mBAAmB,GAC1C,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAC9C,gBAAgB,CACd,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,6BAA6B,GACpD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxD,GAAG,CACD,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC3C,cAAc,CACZ,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC3C,IAAI,CACF,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,kBAAkB,GACzC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACtC,CAAC;IACF,UAAU,EAAE;QACV,QAAQ,CACN,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,yBAAyB,GAChD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACpD,QAAQ,CACN,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,yBAAyB,GAChD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;KACrD,CAAC;CACH;AAED,eAAO,MAAM,kBAAkB,iBAE5B,yBAAyB,KAAG,aA6J9B,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { getErrorWithReasonErrorMessage } from "../../fetcher/index.js";
2
+ import { Expression } from "../../store/index.js";
3
+ export const buildExpressionApi = ({ fetcher, }) => {
4
+ async function evaluateExpression(payload) {
5
+ const result = await fetcher.fetch({
6
+ method: "post",
7
+ endpoint: "expression/expressions/evaluate",
8
+ payload,
9
+ });
10
+ return result;
11
+ }
12
+ async function generateExpression(payload) {
13
+ const result = await fetcher.fetch({
14
+ method: "post",
15
+ endpoint: "expression/expressions/generate",
16
+ payload,
17
+ });
18
+ return result;
19
+ }
20
+ async function createRecipe(payload) {
21
+ const result = await fetcher.fetch({
22
+ method: "post",
23
+ endpoint: "expression/recipes",
24
+ payload,
25
+ });
26
+ return result;
27
+ }
28
+ async function createFavoriteRecipe(payload) {
29
+ const result = await fetcher.fetch({
30
+ method: "post",
31
+ endpoint: "expression/favoriteRecipes",
32
+ payload,
33
+ });
34
+ return result;
35
+ }
36
+ async function createNewRecipeVersion(payload) {
37
+ const { uuid, ...other } = payload;
38
+ try {
39
+ const result = await fetcher.fetch({
40
+ method: "post",
41
+ endpoint: `expression/recipes/${uuid}`,
42
+ payload: other,
43
+ });
44
+ return result;
45
+ }
46
+ catch (error) {
47
+ throw getErrorWithReasonErrorMessage(error, Expression.Api.zodCreateNewRecipeVersionErrorReason, {
48
+ recipeNotFound: "The recipe was not found.",
49
+ });
50
+ }
51
+ }
52
+ async function getRecipe(uuidOrShortId, version) {
53
+ const result = await fetcher.fetch({
54
+ method: "get",
55
+ endpoint: `expression/recipes/${uuidOrShortId}/${version}`,
56
+ });
57
+ return result;
58
+ }
59
+ async function getLastRecipeVersion(uuidOrShortId) {
60
+ const result = await fetcher.fetch({
61
+ method: "get",
62
+ endpoint: `expression/recipes/${uuidOrShortId}/last`,
63
+ });
64
+ return result;
65
+ }
66
+ async function listRecipes(payload) {
67
+ const result = await fetcher.fetch({
68
+ method: "get",
69
+ endpoint: "expression/recipes/list",
70
+ params: payload,
71
+ });
72
+ return result;
73
+ }
74
+ async function archiveRecipe(uuidOrShortId) {
75
+ const result = await fetcher.fetch({
76
+ method: "put",
77
+ endpoint: `expression/recipes/${uuidOrShortId}/archive`,
78
+ });
79
+ return result;
80
+ }
81
+ async function deleteFavoriteRecipe(payload) {
82
+ try {
83
+ const result = await fetcher.fetch({
84
+ method: "delete",
85
+ endpoint: `expression/favoriteRecipes/${payload.recipeUuid}/`,
86
+ });
87
+ return result;
88
+ }
89
+ catch (error) {
90
+ throw getErrorWithReasonErrorMessage(error, Expression.Api.zodDeleteFavoriteRecipeErrorReason, {
91
+ alreadyArchived: "The recipe is already archived.",
92
+ recipeDoesNotBelongsToWorkspace: "You cannot delete a recipe that is not yours.",
93
+ recipeNotFound: "The recipe was not found.",
94
+ });
95
+ }
96
+ }
97
+ return {
98
+ favoriteRecipe: {
99
+ create: createFavoriteRecipe,
100
+ delete: deleteFavoriteRecipe,
101
+ },
102
+ recipe: {
103
+ archive: archiveRecipe,
104
+ list: listRecipes,
105
+ get: getRecipe,
106
+ getLastVersion: getLastRecipeVersion,
107
+ create: createRecipe,
108
+ createNewVersion: createNewRecipeVersion,
109
+ },
110
+ expression: {
111
+ evaluate: evaluateExpression,
112
+ generate: generateExpression,
113
+ },
114
+ };
115
+ };
@@ -0,0 +1,72 @@
1
+ import type { Ai, Billing, Connection, Orchestration, RevenueOrganization, Segmentation, Storage, SystemOfRecordIntegration, WorkspaceManagement } from "../store/index.js";
2
+ import type { BackendToFrontend } from "../types.js";
3
+ import type { AiApi } from "./ai/index.js";
4
+ import type { BillingApi } from "./billing/index.js";
5
+ import type { ConnectionApi } from "./connection/index.js";
6
+ import type { ExpressionApi } from "./expression/index.js";
7
+ import type { OrchestrationApi } from "./orchestration/index.js";
8
+ import type { RevenueOrganizationApi } from "./revenueOrganization/index.js";
9
+ import type { SegmentationApi } from "./segmentation/index.js";
10
+ import type { StorageApi } from "./storage/index.js";
11
+ import type { SystemOfRecordIntegrationApi } from "./systemOfRecordIntegration/index.js";
12
+ import type { UserManagementApi } from "./userManagement/index.js";
13
+ import type { WorkspaceManagementApi } from "./workspaceManagement/index.js";
14
+ export * from "./ai/index.js";
15
+ export * from "./billing/index.js";
16
+ export * from "./connection/index.js";
17
+ export * from "./expression/index.js";
18
+ export * from "./orchestration/index.js";
19
+ export * from "./revenueOrganization/index.js";
20
+ export * from "./segmentation/index.js";
21
+ export * from "./storage/index.js";
22
+ export * from "./systemOfRecordIntegration/index.js";
23
+ export * from "./workspaceManagement/index.js";
24
+ export interface ApiDependencies {
25
+ baseUrl: string;
26
+ workspaceUuid?: string;
27
+ getAccessToken?: (refresh?: boolean | undefined) => Promise<string>;
28
+ }
29
+ export interface Api {
30
+ getInitialisation(): Promise<BackendToFrontend<InitialisationResult>>;
31
+ workspaceManagement: WorkspaceManagementApi;
32
+ revenueOrganization: RevenueOrganizationApi;
33
+ segmentation: SegmentationApi;
34
+ billing: BillingApi;
35
+ storage: StorageApi;
36
+ connection: ConnectionApi;
37
+ expression: ExpressionApi;
38
+ systemOfRecordIntegration: SystemOfRecordIntegrationApi;
39
+ orchestration: OrchestrationApi;
40
+ userManagement: UserManagementApi;
41
+ ai: AiApi;
42
+ }
43
+ export type InitialisationResult = {
44
+ mcpServers: Ai.McpServer[];
45
+ agents: Ai.Agent[];
46
+ members: RevenueOrganization.Member[];
47
+ capacities: RevenueOrganization.Capacity[];
48
+ territories: RevenueOrganization.Territory[];
49
+ user: WorkspaceManagement.User;
50
+ users: WorkspaceManagement.User[];
51
+ tokens: WorkspaceManagement.Token[];
52
+ roles: WorkspaceManagement.Role[];
53
+ folders: WorkspaceManagement.Folder[];
54
+ workspace: WorkspaceManagement.Workspace;
55
+ datasets: Storage.Dataset[];
56
+ models: Storage.Model[];
57
+ relationships: Storage.Relationship[];
58
+ connectors: Connection.Connector[];
59
+ segments: Segmentation.Segment[];
60
+ workflows: Orchestration.Workflow[];
61
+ plays: Orchestration.Play[];
62
+ tools: Orchestration.Tool[];
63
+ templates: Array<Orchestration.Template | Ai.Template>;
64
+ systemOfRecords: SystemOfRecordIntegration.SystemOfRecord[];
65
+ nativeIntegration: Connection.NativeIntegration;
66
+ integrations: Connection.Integration[];
67
+ clients: SystemOfRecordIntegration.Client[];
68
+ subscription: Billing.EnrichedSubscription;
69
+ files: Ai.File[];
70
+ };
71
+ export declare const buildApi: (dependencies: ApiDependencies) => Api;
72
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,EAAE,EACF,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;IACtC,UAAU,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC;IACnC,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;IACjC,SAAS,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC;IACpC,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC;IAC5B,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC;IAC5B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;IACvD,eAAe,EAAE,yBAAyB,CAAC,cAAc,EAAE,CAAC;IAC5D,iBAAiB,EAAE,UAAU,CAAC,iBAAiB,CAAC;IAChD,YAAY,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;IACvC,OAAO,EAAE,yBAAyB,CAAC,MAAM,EAAE,CAAC;IAC5C,YAAY,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAC3C,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,QAAQ,iBAAkB,eAAe,KAAG,GAgCxD,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { buildFetcher } from "../fetcher/index.js";
2
+ import { buildAiApi } from "./ai/index.js";
3
+ import { buildBillingApi } from "./billing/index.js";
4
+ import { buildConnectionApi } from "./connection/index.js";
5
+ import { buildExpressionApi } from "./expression/index.js";
6
+ import { buildOrchestrationApi } from "./orchestration/index.js";
7
+ import { buildRevenueOrganizationApi } from "./revenueOrganization/index.js";
8
+ import { buildSegmentationApi } from "./segmentation/index.js";
9
+ import { buildStorageApi } from "./storage/index.js";
10
+ import { buildSystemOfRecordIntegrationApi } from "./systemOfRecordIntegration/index.js";
11
+ import { buildUserManagementApi } from "./userManagement/index.js";
12
+ import { buildWorkspaceManagementApi } from "./workspaceManagement/index.js";
13
+ export * from "./ai/index.js";
14
+ export * from "./billing/index.js";
15
+ export * from "./connection/index.js";
16
+ export * from "./expression/index.js";
17
+ export * from "./orchestration/index.js";
18
+ export * from "./revenueOrganization/index.js";
19
+ export * from "./segmentation/index.js";
20
+ export * from "./storage/index.js";
21
+ export * from "./systemOfRecordIntegration/index.js";
22
+ export * from "./workspaceManagement/index.js";
23
+ export const buildApi = (dependencies) => {
24
+ const { workspaceUuid, getAccessToken, baseUrl } = dependencies;
25
+ const fetcher = buildFetcher({
26
+ baseUrl,
27
+ workspaceUuid,
28
+ getAccessToken,
29
+ });
30
+ async function getInitialisation() {
31
+ const result = await fetcher.fetch({
32
+ method: "get",
33
+ endpoint: "/initWorkspace",
34
+ });
35
+ return result;
36
+ }
37
+ return {
38
+ getInitialisation,
39
+ revenueOrganization: buildRevenueOrganizationApi({ fetcher }),
40
+ workspaceManagement: buildWorkspaceManagementApi({ fetcher }),
41
+ segmentation: buildSegmentationApi({ fetcher }),
42
+ billing: buildBillingApi({ fetcher }),
43
+ storage: buildStorageApi({ fetcher }),
44
+ connection: buildConnectionApi({ fetcher }),
45
+ expression: buildExpressionApi({ fetcher }),
46
+ systemOfRecordIntegration: buildSystemOfRecordIntegrationApi({ fetcher }),
47
+ orchestration: buildOrchestrationApi({ fetcher }),
48
+ userManagement: buildUserManagementApi({ fetcher }),
49
+ ai: buildAiApi({ fetcher }),
50
+ };
51
+ };