cliodot 1.2.2 → 1.2.4

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 (147) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/dist/AuthAppClient.d.ts +1 -0
  4. package/dist/AuthAppClient.d.ts.map +1 -1
  5. package/dist/AuthAppClient.js +199 -1
  6. package/dist/CommercialAppClient.d.ts +178 -0
  7. package/dist/CommercialAppClient.d.ts.map +1 -0
  8. package/dist/CommercialAppClient.js +576 -0
  9. package/dist/ConnectorBuilder.js +104 -1
  10. package/dist/Events.d.ts +2 -0
  11. package/dist/Events.d.ts.map +1 -1
  12. package/dist/Events.js +325 -1
  13. package/dist/Flosync.js +296 -1
  14. package/dist/FlosyncClient.js +429 -1
  15. package/dist/FunctionBuilder.js +65 -1
  16. package/dist/IdentityAppClient.d.ts +23 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -0
  18. package/dist/IdentityAppClient.js +197 -0
  19. package/dist/MemoryAppClient.d.ts +28 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -0
  21. package/dist/MemoryAppClient.js +149 -0
  22. package/dist/MemoryClient.d.ts +8 -0
  23. package/dist/MemoryClient.d.ts.map +1 -0
  24. package/dist/MemoryClient.js +20 -0
  25. package/dist/OAuthAppClient.d.ts +1 -0
  26. package/dist/OAuthAppClient.d.ts.map +1 -1
  27. package/dist/OAuthAppClient.js +269 -1
  28. package/dist/ProviderServicesClient.d.ts +24 -0
  29. package/dist/ProviderServicesClient.d.ts.map +1 -0
  30. package/dist/ProviderServicesClient.js +158 -0
  31. package/dist/Surface.d.ts +2 -0
  32. package/dist/Surface.d.ts.map +1 -1
  33. package/dist/Surface.js +255 -1
  34. package/dist/ValidatorBuilder.js +24 -1
  35. package/dist/Webhooks.d.ts +20 -0
  36. package/dist/Webhooks.d.ts.map +1 -0
  37. package/dist/Webhooks.js +61 -0
  38. package/dist/WorkflowBuilder.js +279 -1
  39. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  40. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  41. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  42. package/dist/__tests__/Events.test.js +191 -1
  43. package/dist/__tests__/IdentityAppClient.test.d.ts +2 -0
  44. package/dist/__tests__/IdentityAppClient.test.d.ts.map +1 -0
  45. package/dist/__tests__/IdentityAppClient.test.js +232 -0
  46. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  47. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  48. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  49. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  50. package/dist/__tests__/Surface.test.js +150 -1
  51. package/dist/__tests__/errors.test.js +54 -1
  52. package/dist/__tests__/function.test.js +58 -1
  53. package/dist/__tests__/helpers.d.ts +5 -0
  54. package/dist/__tests__/helpers.d.ts.map +1 -0
  55. package/dist/__tests__/helpers.js +10 -0
  56. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  57. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  58. package/dist/__tests__/localhost-lookup.test.js +26 -0
  59. package/dist/__tests__/parse-api-error.test.js +26 -1
  60. package/dist/__tests__/runner.test.js +156 -1
  61. package/dist/connectors/builtin.js +354 -1
  62. package/dist/connectors/registry.js +300 -1
  63. package/dist/decorators/build.js +105 -1
  64. package/dist/decorators/connector.js +56 -1
  65. package/dist/decorators/index.js +34 -1
  66. package/dist/decorators/metadata.js +338 -1
  67. package/dist/decorators/steps.js +220 -1
  68. package/dist/decorators/workflow.js +52 -1
  69. package/dist/errors.js +76 -1
  70. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  71. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  73. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  74. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  75. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  76. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  77. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  78. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  79. package/dist/http/cliodot-request.d.ts +35 -0
  80. package/dist/http/cliodot-request.d.ts.map +1 -0
  81. package/dist/http/cliodot-request.js +105 -0
  82. package/dist/http/cliodot-result.d.ts +40 -0
  83. package/dist/http/cliodot-result.d.ts.map +1 -0
  84. package/dist/http/cliodot-result.js +139 -0
  85. package/dist/http/create-client.d.ts +3 -0
  86. package/dist/http/create-client.d.ts.map +1 -0
  87. package/dist/http/create-client.js +14 -0
  88. package/dist/http/events-instance-id.d.ts +11 -0
  89. package/dist/http/events-instance-id.d.ts.map +1 -0
  90. package/dist/http/events-instance-id.js +86 -0
  91. package/dist/http/localhost-lookup.d.ts +12 -0
  92. package/dist/http/localhost-lookup.d.ts.map +1 -0
  93. package/dist/http/localhost-lookup.js +67 -0
  94. package/dist/http/parse-api-error.js +56 -1
  95. package/dist/http/sanitize-execution-headers.js +79 -1
  96. package/dist/identity-offline-verify.d.ts +6 -0
  97. package/dist/identity-offline-verify.d.ts.map +1 -0
  98. package/dist/identity-offline-verify.js +174 -0
  99. package/dist/identity-token-cache.d.ts +6 -0
  100. package/dist/identity-token-cache.d.ts.map +1 -0
  101. package/dist/identity-token-cache.js +51 -0
  102. package/dist/index.d.ts +10 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +108 -1
  105. package/dist/runner/ProcessorEngine.js +1311 -1
  106. package/dist/runner/connector.executor.js +1786 -1
  107. package/dist/runner/utilities/math.executor.js +153 -1
  108. package/dist/runner/utilities/random.executor.js +151 -1
  109. package/dist/runner/utilities/string.executor.js +825 -1
  110. package/dist/template.js +127 -1
  111. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  112. package/dist/transformers/WorkflowTransformer.js +189 -1
  113. package/dist/types/auth-app.api.d.ts +2 -0
  114. package/dist/types/auth-app.api.d.ts.map +1 -1
  115. package/dist/types/auth-app.api.js +2 -1
  116. package/dist/types/builtin.js +2 -1
  117. package/dist/types/client.api.js +2 -1
  118. package/dist/types/commercial-app.api.d.ts +963 -0
  119. package/dist/types/commercial-app.api.d.ts.map +1 -0
  120. package/dist/types/commercial-app.api.js +2 -0
  121. package/dist/types/connector.js +2 -1
  122. package/dist/types/context.js +2 -1
  123. package/dist/types/event-app.api.d.ts +8 -0
  124. package/dist/types/event-app.api.d.ts.map +1 -1
  125. package/dist/types/event-app.api.js +2 -1
  126. package/dist/types/function.js +2 -1
  127. package/dist/types/identity-app.api.d.ts +99 -0
  128. package/dist/types/identity-app.api.d.ts.map +1 -0
  129. package/dist/types/identity-app.api.js +2 -0
  130. package/dist/types/index.js +23 -1
  131. package/dist/types/memory-app.api.d.ts +140 -0
  132. package/dist/types/memory-app.api.d.ts.map +1 -0
  133. package/dist/types/memory-app.api.js +2 -0
  134. package/dist/types/oauth-app.api.d.ts +2 -0
  135. package/dist/types/oauth-app.api.d.ts.map +1 -1
  136. package/dist/types/oauth-app.api.js +105 -1
  137. package/dist/types/provider-services.api.d.ts +98 -0
  138. package/dist/types/provider-services.api.d.ts.map +1 -0
  139. package/dist/types/provider-services.api.js +2 -0
  140. package/dist/types/validator.js +2 -1
  141. package/dist/types/webhook-app.api.d.ts +2 -0
  142. package/dist/types/webhook-app.api.d.ts.map +1 -0
  143. package/dist/types/webhook-app.api.js +2 -0
  144. package/dist/types/workflow.js +33 -1
  145. package/dist/validators/validators.js +478 -1
  146. package/dist/variable.js +37 -1
  147. package/package.json +3 -2
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IdentityAppClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const errors_1 = require("./errors");
9
+ const parse_api_error_1 = require("./http/parse-api-error");
10
+ const cliodot_request_1 = require("./http/cliodot-request");
11
+ function trimBaseUrl(url) {
12
+ return url.trim().replace(/\/+$/, "");
13
+ }
14
+ function resolveInternalProviderId(name) {
15
+ const trimmed = name.trim();
16
+ if (!trimmed) {
17
+ throw new errors_1.CliodotApiError("provider requires a non-empty Identity App id");
18
+ }
19
+ if (trimmed.startsWith("ext:") || trimmed.startsWith("ext_")) {
20
+ throw new errors_1.CliodotApiError("provider() resolves internal Identity Apps only; use extProvider() for external profiles");
21
+ }
22
+ return trimmed;
23
+ }
24
+ function resolveExternalProviderId(name) {
25
+ const trimmed = name.trim();
26
+ if (!trimmed) {
27
+ throw new errors_1.CliodotApiError("extProvider requires a non-empty profile slug or id");
28
+ }
29
+ if (trimmed.startsWith("ext:") || trimmed.startsWith("ext_")) {
30
+ return trimmed;
31
+ }
32
+ return `ext:${trimmed}`;
33
+ }
34
+ class IdentityAppClient {
35
+ constructor(config) {
36
+ if (!config.baseUrl?.trim()) {
37
+ throw new errors_1.CliodotApiError("IdentityAppClient requires baseUrl");
38
+ }
39
+ if (!config.appId?.trim()) {
40
+ throw new errors_1.CliodotApiError("IdentityAppClient requires appId");
41
+ }
42
+ this.baseUrl = trimBaseUrl(config.baseUrl);
43
+ this.appId = config.appId.trim();
44
+ this.apiKey =
45
+ config.apiKey?.trim() || config.appApiKey?.trim() || undefined;
46
+ this.appSecret = config.appSecret?.trim() || undefined;
47
+ this.environment = config.environment;
48
+ this.debug = config.debug ?? false;
49
+ this.axios = axios_1.default.create({
50
+ baseURL: `${this.baseUrl}/identity`,
51
+ timeout: config.timeoutMs ?? 30000,
52
+ headers: { "Content-Type": "application/json" },
53
+ });
54
+ }
55
+ me() {
56
+ return this.request("GET", "/v1/me");
57
+ }
58
+ authenticate(input) {
59
+ if (!input?.target_app_id?.trim()) {
60
+ throw new errors_1.CliodotApiError("authenticate requires target_app_id");
61
+ }
62
+ const body = {
63
+ target_app_id: input.target_app_id.trim(),
64
+ };
65
+ if (input.scopes !== undefined) {
66
+ body.scopes = input.scopes;
67
+ }
68
+ return this.request("POST", "/v1/authenticate", body);
69
+ }
70
+ verify(input) {
71
+ if (!input?.access_token?.trim()) {
72
+ throw new errors_1.CliodotApiError("verify requires access_token");
73
+ }
74
+ const body = {
75
+ access_token: input.access_token.trim(),
76
+ };
77
+ if (input.required_scopes !== undefined) {
78
+ body.required_scopes = input.required_scopes;
79
+ }
80
+ const target = input.target_app_id?.trim();
81
+ if (target) {
82
+ return this.request("POST", `/v1/apps/${encodeURIComponent(target)}/verify`, body);
83
+ }
84
+ return this.request("POST", "/v1/verify", body);
85
+ }
86
+ refresh(input) {
87
+ if (!input?.refresh_token?.trim()) {
88
+ throw new errors_1.CliodotApiError("refresh requires refresh_token");
89
+ }
90
+ return this.request("POST", "/v1/token/refresh", {
91
+ refresh_token: input.refresh_token.trim(),
92
+ });
93
+ }
94
+ revoke(input) {
95
+ const access = input?.access_token?.trim();
96
+ const refresh = input?.refresh_token?.trim();
97
+ if (!access && !refresh) {
98
+ throw new errors_1.CliodotApiError("revoke requires access_token or refresh_token");
99
+ }
100
+ const body = {};
101
+ if (access)
102
+ body.access_token = access;
103
+ if (refresh)
104
+ body.refresh_token = refresh;
105
+ return this.request("POST", "/v1/token/revoke", body);
106
+ }
107
+ async getJwks(appId) {
108
+ if (!appId?.trim()) {
109
+ throw new errors_1.CliodotApiError("getJwks requires appId");
110
+ }
111
+ try {
112
+ const { data } = await this.axios({
113
+ method: "GET",
114
+ url: `/v1/apps/${encodeURIComponent(appId.trim())}/jwks.json`,
115
+ });
116
+ if (data?.ok === false) {
117
+ throw new errors_1.CliodotApiError((0, parse_api_error_1.parseApiErrorMessage)(data) || "JWKS request failed", {
118
+ data,
119
+ code: (0, parse_api_error_1.parseApiErrorCode)(data),
120
+ });
121
+ }
122
+ return data;
123
+ }
124
+ catch (err) {
125
+ if (err instanceof errors_1.CliodotApiError)
126
+ throw err;
127
+ throw (0, errors_1.cliodotApiErrorFromAxios)(err, `Request failed: GET jwks`);
128
+ }
129
+ }
130
+ provider(name) {
131
+ const target_app_id = resolveInternalProviderId(name);
132
+ return this.buildProviderHandle(target_app_id);
133
+ }
134
+ extProvider(name) {
135
+ const target_app_id = resolveExternalProviderId(name);
136
+ return this.buildProviderHandle(target_app_id);
137
+ }
138
+ buildProviderHandle(target_app_id) {
139
+ return {
140
+ target_app_id,
141
+ authenticate: (scopes) => {
142
+ const input = { target_app_id };
143
+ if (scopes !== undefined)
144
+ input.scopes = scopes;
145
+ return this.authenticate(input);
146
+ },
147
+ verify: (accessToken, required_scopes) => {
148
+ const input = {
149
+ access_token: accessToken,
150
+ target_app_id,
151
+ };
152
+ if (required_scopes !== undefined) {
153
+ input.required_scopes = required_scopes;
154
+ }
155
+ return this.verify(input);
156
+ },
157
+ refresh: (refreshToken) => this.refresh({ refresh_token: refreshToken }),
158
+ };
159
+ }
160
+ buildAuthHeaders() {
161
+ const headers = (0, cliodot_request_1.applyEnvironmentHeader)({
162
+ "x-cliodot-app-id": this.appId,
163
+ }, this.environment);
164
+ if (this.apiKey) {
165
+ headers.Authorization = `Bearer ${this.apiKey}`;
166
+ return headers;
167
+ }
168
+ if (this.appSecret) {
169
+ headers["x-cliodot-app-secret"] = this.appSecret;
170
+ return headers;
171
+ }
172
+ throw new errors_1.CliodotApiError("Identity app credentials required (apiKey/appApiKey or appSecret)");
173
+ }
174
+ async request(method, path, body) {
175
+ try {
176
+ const { data } = await this.axios({
177
+ method,
178
+ url: path,
179
+ headers: this.buildAuthHeaders(),
180
+ data: body,
181
+ });
182
+ if (data?.ok === false) {
183
+ throw new errors_1.CliodotApiError((0, parse_api_error_1.parseApiErrorMessage)(data) || "Identity request failed", {
184
+ data,
185
+ code: (0, parse_api_error_1.parseApiErrorCode)(data),
186
+ });
187
+ }
188
+ return data;
189
+ }
190
+ catch (err) {
191
+ if (err instanceof errors_1.CliodotApiError)
192
+ throw err;
193
+ throw (0, errors_1.cliodotApiErrorFromAxios)(err, `Request failed: ${method} ${path}`);
194
+ }
195
+ }
196
+ }
197
+ exports.IdentityAppClient = IdentityAppClient;
@@ -0,0 +1,28 @@
1
+ import type { MemoryAddressInput, MemoryAppClientApi, MemoryAppClientConfig, MemoryDeleteInput, MemoryFindInput, MemoryFindResponse, MemoryObject, MemorySearchInput, MemorySearchResponse, MemoryStoreInput, MemoryStoreManyInput, MemoryStoreManyResponse, MemoryStoreResponse, MemoryUpdateInput } from "./types/memory-app.api";
2
+ export declare class MemoryAppClient implements MemoryAppClientApi {
3
+ private readonly baseUrl;
4
+ private readonly appId;
5
+ private readonly apiKey?;
6
+ private readonly appSecret?;
7
+ private readonly environment?;
8
+ private readonly axios;
9
+ readonly debug: boolean;
10
+ constructor(config: MemoryAppClientConfig);
11
+ store(input: MemoryStoreInput): Promise<MemoryStoreResponse>;
12
+ storeMany(input: MemoryStoreManyInput): Promise<MemoryStoreManyResponse>;
13
+ get(input: MemoryAddressInput): Promise<{
14
+ ok: true;
15
+ object: MemoryObject;
16
+ }>;
17
+ update(input: MemoryUpdateInput): Promise<MemoryStoreResponse>;
18
+ delete(input: MemoryDeleteInput): Promise<{
19
+ ok: true;
20
+ deleted: boolean;
21
+ mode: "soft" | "permanent";
22
+ }>;
23
+ find(input: MemoryFindInput): Promise<MemoryFindResponse>;
24
+ search(input: MemorySearchInput): Promise<MemorySearchResponse>;
25
+ private buildAuthHeaders;
26
+ private request;
27
+ }
28
+ //# sourceMappingURL=MemoryAppClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryAppClient.d.ts","sourceRoot":"","sources":["../src/MemoryAppClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EAC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Module) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MemoryAppClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const errors_1 = require("./errors");
9
+ const parse_api_error_1 = require("./http/parse-api-error");
10
+ const cliodot_request_1 = require("./http/cliodot-request");
11
+ function trimBaseUrl(url) {
12
+ return url.trim().replace(/\/+$/, "");
13
+ }
14
+ class MemoryAppClient {
15
+ constructor(config) {
16
+ if (!config.baseUrl?.trim()) {
17
+ throw new errors_1.CliodotApiError("MemoryAppClient requires baseUrl");
18
+ }
19
+ if (!config.appId?.trim()) {
20
+ throw new errors_1.CliodotApiError("MemoryAppClient requires appId");
21
+ }
22
+ this.baseUrl = trimBaseUrl(config.baseUrl);
23
+ this.appId = config.appId.trim();
24
+ this.apiKey =
25
+ config.apiKey?.trim() || config.appApiKey?.trim() || undefined;
26
+ this.appSecret = config.appSecret?.trim() || undefined;
27
+ this.environment = config.environment;
28
+ this.debug = config.debug ?? false;
29
+ this.axios = axios_1.default.create({
30
+ baseURL: `${this.baseUrl}/memory`,
31
+ timeout: 60000,
32
+ headers: { "Content-Type": "application/json" },
33
+ });
34
+ }
35
+ store(input) {
36
+ if (!input?.collection?.trim()) {
37
+ throw new errors_1.CliodotApiError("collection is required");
38
+ }
39
+ if (input.content === undefined) {
40
+ throw new errors_1.CliodotApiError("content is required");
41
+ }
42
+ return this.request("POST", "/v1/store", {
43
+ ...input,
44
+ collection: input.collection.trim(),
45
+ });
46
+ }
47
+ storeMany(input) {
48
+ if (!input?.collection?.trim()) {
49
+ throw new errors_1.CliodotApiError("collection is required");
50
+ }
51
+ if (!Array.isArray(input.items) || input.items.length === 0) {
52
+ throw new errors_1.CliodotApiError("items is required");
53
+ }
54
+ return this.request("POST", "/v1/store-many", {
55
+ collection: input.collection.trim(),
56
+ items: input.items,
57
+ });
58
+ }
59
+ get(input) {
60
+ if (!input?.collection?.trim() || !input?.id?.trim()) {
61
+ throw new errors_1.CliodotApiError("collection and id are required");
62
+ }
63
+ return this.request("POST", "/v1/get", {
64
+ collection: input.collection.trim(),
65
+ id: input.id.trim(),
66
+ });
67
+ }
68
+ update(input) {
69
+ if (!input?.collection?.trim() || !input?.id?.trim()) {
70
+ throw new errors_1.CliodotApiError("collection and id are required");
71
+ }
72
+ return this.request("POST", "/v1/update", {
73
+ collection: input.collection.trim(),
74
+ id: input.id.trim(),
75
+ content: input.content,
76
+ type: input.type,
77
+ title: input.title,
78
+ metadata: input.metadata,
79
+ tags: input.tags,
80
+ source: input.source,
81
+ async: input.async,
82
+ });
83
+ }
84
+ delete(input) {
85
+ if (!input?.collection?.trim() || !input?.id?.trim()) {
86
+ throw new errors_1.CliodotApiError("collection and id are required");
87
+ }
88
+ return this.request("POST", "/v1/delete", {
89
+ collection: input.collection.trim(),
90
+ id: input.id.trim(),
91
+ mode: input.mode || "soft",
92
+ });
93
+ }
94
+ find(input) {
95
+ if (!input?.collection?.trim()) {
96
+ throw new errors_1.CliodotApiError("collection is required");
97
+ }
98
+ return this.request("POST", "/v1/find", {
99
+ collection: input.collection.trim(),
100
+ filter: input.filter,
101
+ type: input.type,
102
+ tags: input.tags,
103
+ metadata: input.metadata,
104
+ limit: input.limit,
105
+ offset: input.offset,
106
+ });
107
+ }
108
+ search(input) {
109
+ return this.request("POST", "/v1/search", input);
110
+ }
111
+ buildAuthHeaders() {
112
+ const headers = (0, cliodot_request_1.applyEnvironmentHeader)({
113
+ "x-cliodot-app-id": this.appId,
114
+ }, this.environment);
115
+ if (this.apiKey) {
116
+ headers.Authorization = `Bearer ${this.apiKey}`;
117
+ return headers;
118
+ }
119
+ if (this.appSecret) {
120
+ headers["x-cliodot-app-secret"] = this.appSecret;
121
+ return headers;
122
+ }
123
+ throw new errors_1.CliodotApiError("MemoryAppClient credentials required (apiKey/appApiKey or appSecret)");
124
+ }
125
+ async request(method, path, body) {
126
+ try {
127
+ const { data } = await this.axios({
128
+ method,
129
+ url: path,
130
+ headers: this.buildAuthHeaders(),
131
+ data: body,
132
+ });
133
+ if (data?.ok === false) {
134
+ throw new errors_1.CliodotApiError((0, parse_api_error_1.parseApiErrorMessage)(data) || "Memory request failed", {
135
+ data,
136
+ code: (0, parse_api_error_1.parseApiErrorCode)(data),
137
+ });
138
+ }
139
+ return data;
140
+ }
141
+ catch (err) {
142
+ if (err instanceof errors_1.CliodotApiError) {
143
+ throw err;
144
+ }
145
+ throw (0, errors_1.cliodotApiErrorFromAxios)(err, `Request failed: ${method} ${path}`);
146
+ }
147
+ }
148
+ }
149
+ exports.MemoryAppClient = MemoryAppClient;
@@ -0,0 +1,8 @@
1
+ import { MemoryAppClient } from "./MemoryAppClient";
2
+ import type { MemoryClientApi, MemoryClientConfig, MemoryCrossSearchInput, MemorySearchInput, MemorySearchResponse } from "./types/memory-app.api";
3
+ export declare class MemoryClient extends MemoryAppClient implements MemoryClientApi {
4
+ constructor(config: MemoryClientConfig);
5
+ search(input: MemorySearchInput): Promise<MemorySearchResponse>;
6
+ searchCross(input: MemoryCrossSearchInput): Promise<MemorySearchResponse>;
7
+ }
8
+ //# sourceMappingURL=MemoryClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryClient.d.ts","sourceRoot":"","sources":["../src/MemoryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAGhC,qBAAa,YAAa,SAAQ,eAAgB,YAAW,eAAe;gBAC9D,MAAM,EAAE,kBAAkB;IAItC,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI/D,WAAW,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAM1E"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemoryClient = void 0;
4
+ const MemoryAppClient_1 = require("./MemoryAppClient");
5
+ const errors_1 = require("./errors");
6
+ class MemoryClient extends MemoryAppClient_1.MemoryAppClient {
7
+ constructor(config) {
8
+ super(config);
9
+ }
10
+ search(input) {
11
+ return super.search(input);
12
+ }
13
+ searchCross(input) {
14
+ if (!input?.apps?.length && !input?.group?.trim()) {
15
+ throw new errors_1.CliodotApiError("apps[] or group is required");
16
+ }
17
+ return this.search(input);
18
+ }
19
+ }
20
+ exports.MemoryClient = MemoryClient;
@@ -4,6 +4,7 @@ export declare class OAuthAppClient {
4
4
  private readonly appId;
5
5
  private readonly appApiKey?;
6
6
  private readonly appSecret?;
7
+ private readonly environment?;
7
8
  private readonly axios;
8
9
  readonly debug: boolean;
9
10
  constructor(config: OAuthAppClientConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"OAuthAppClient.d.ts","sourceRoot":"","sources":["../src/OAuthAppClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EACpB,eAAe,EAOf,mBAAmB,EAEnB,kBAAkB,EAClB,qBAAqB,EAKtB,MAAM,uBAAuB,CAAC;AAwF/B,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,SAAgB,KAAK,EAAE,OAAO,CAAC;gBAEnB,MAAM,EAAE,oBAAoB;IAmBxC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;YAaT,OAAO;IA+CrB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAqE/B;IAEI,QAAQ,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAA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