@heymantle/core-api-client 0.1.15 → 0.1.17

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.js CHANGED
@@ -1912,6 +1912,32 @@ var DocsResource = class extends BaseResource {
1912
1912
  async getTree() {
1913
1913
  return this.get("/docs/tree");
1914
1914
  }
1915
+ // ========== Repositories ==========
1916
+ /**
1917
+ * List all doc repositories
1918
+ */
1919
+ async listRepositories(params) {
1920
+ const response = await this.get(
1921
+ "/docs/repositories",
1922
+ params
1923
+ );
1924
+ return {
1925
+ repositories: response.repositories || [],
1926
+ hasNextPage: response.hasNextPage || false,
1927
+ hasPreviousPage: response.hasPreviousPage || false,
1928
+ total: response.total,
1929
+ cursor: response.cursor
1930
+ };
1931
+ }
1932
+ /**
1933
+ * Retrieve a single doc repository
1934
+ */
1935
+ async retrieveRepository(repositoryId, params) {
1936
+ return this.get(
1937
+ `/docs/repositories/${repositoryId}`,
1938
+ params
1939
+ );
1940
+ }
1915
1941
  };
1916
1942
 
1917
1943
  // src/resources/entities.ts
@@ -1923,7 +1949,11 @@ var EntitiesResource = class extends BaseResource {
1923
1949
  async search(params) {
1924
1950
  const response = await this.get("/entities", params);
1925
1951
  return {
1926
- entities: response.entities || []
1952
+ entities: response.entities || [],
1953
+ hasNextPage: response.hasNextPage || false,
1954
+ hasPreviousPage: response.hasPreviousPage || false,
1955
+ total: response.total,
1956
+ cursor: response.cursor
1927
1957
  };
1928
1958
  }
1929
1959
  };
@@ -2097,6 +2127,237 @@ var ListsResource = class extends BaseResource {
2097
2127
  }
2098
2128
  };
2099
2129
 
2130
+ // src/resources/journal-entries.ts
2131
+ var JournalEntriesResource = class extends BaseResource {
2132
+ /**
2133
+ * List journal entries with optional filters and pagination
2134
+ */
2135
+ async list(params) {
2136
+ const response = await this.get(
2137
+ "/journal_entries",
2138
+ params
2139
+ );
2140
+ return {
2141
+ journalEntries: response.journalEntries || [],
2142
+ hasNextPage: response.hasNextPage || false,
2143
+ hasPreviousPage: response.hasPreviousPage || false,
2144
+ total: response.total,
2145
+ cursor: response.cursor
2146
+ };
2147
+ }
2148
+ /**
2149
+ * Retrieve a single journal entry by ID
2150
+ */
2151
+ async retrieve(entryId) {
2152
+ return this.get(
2153
+ `/journal_entries/${entryId}`
2154
+ );
2155
+ }
2156
+ /**
2157
+ * Create a new journal entry
2158
+ */
2159
+ async create(data) {
2160
+ return this.post("/journal_entries", data);
2161
+ }
2162
+ /**
2163
+ * Update an existing journal entry
2164
+ */
2165
+ async update(entryId, data) {
2166
+ return this.put(
2167
+ `/journal_entries/${entryId}`,
2168
+ data
2169
+ );
2170
+ }
2171
+ /**
2172
+ * Delete a journal entry
2173
+ */
2174
+ async del(entryId) {
2175
+ return this._delete(`/journal_entries/${entryId}`);
2176
+ }
2177
+ };
2178
+
2179
+ // src/resources/email-unsubscribe-groups.ts
2180
+ var EmailUnsubscribeGroupsResource = class extends BaseResource {
2181
+ /**
2182
+ * List all email unsubscribe groups
2183
+ */
2184
+ async list(params) {
2185
+ const response = await this.get(
2186
+ "/email/unsubscribe_groups",
2187
+ params
2188
+ );
2189
+ return {
2190
+ unsubscribeGroups: response.unsubscribeGroups || [],
2191
+ hasNextPage: response.hasNextPage || false,
2192
+ hasPreviousPage: response.hasPreviousPage || false,
2193
+ total: response.total,
2194
+ cursor: response.cursor
2195
+ };
2196
+ }
2197
+ /**
2198
+ * Retrieve a single unsubscribe group
2199
+ */
2200
+ async retrieve(groupId) {
2201
+ return this.get(
2202
+ `/email/unsubscribe_groups/${groupId}`
2203
+ );
2204
+ }
2205
+ // ========== Members ==========
2206
+ /**
2207
+ * List members of an unsubscribe group
2208
+ */
2209
+ async listMembers(groupId, params) {
2210
+ const response = await this.get(
2211
+ `/email/unsubscribe_groups/${groupId}/members`,
2212
+ params
2213
+ );
2214
+ return {
2215
+ members: response.members || [],
2216
+ hasNextPage: response.hasNextPage || false,
2217
+ hasPreviousPage: response.hasPreviousPage || false,
2218
+ total: response.total,
2219
+ cursor: response.cursor
2220
+ };
2221
+ }
2222
+ /**
2223
+ * Add members to an unsubscribe group by email addresses
2224
+ */
2225
+ async addMembers(groupId, data) {
2226
+ return this.post(
2227
+ `/email/unsubscribe_groups/${groupId}/members`,
2228
+ data
2229
+ );
2230
+ }
2231
+ /**
2232
+ * Remove members from an unsubscribe group by email addresses
2233
+ */
2234
+ async removeMembers(groupId, data) {
2235
+ return this._delete(
2236
+ `/email/unsubscribe_groups/${groupId}/members?emails=${encodeURIComponent(data.emails.join(","))}`
2237
+ );
2238
+ }
2239
+ /**
2240
+ * Remove a single member from an unsubscribe group by member ID
2241
+ */
2242
+ async removeMember(groupId, memberId) {
2243
+ return this._delete(
2244
+ `/email/unsubscribe_groups/${groupId}/members/${memberId}`
2245
+ );
2246
+ }
2247
+ };
2248
+
2249
+ // src/resources/flow-extensions.ts
2250
+ var FlowExtensionsResource = class extends BaseResource {
2251
+ // ========== Actions ==========
2252
+ /**
2253
+ * List flow extension actions
2254
+ */
2255
+ async listActions(params) {
2256
+ const response = await this.get(
2257
+ "/flow/extensions/actions",
2258
+ params
2259
+ );
2260
+ return {
2261
+ actions: response.actions || [],
2262
+ hasNextPage: response.hasNextPage || false,
2263
+ hasPreviousPage: response.hasPreviousPage || false,
2264
+ total: response.total,
2265
+ cursor: response.cursor
2266
+ };
2267
+ }
2268
+ /**
2269
+ * Retrieve a single flow extension action
2270
+ */
2271
+ async retrieveAction(actionId) {
2272
+ return this.get(
2273
+ `/flow/extensions/actions/${actionId}`
2274
+ );
2275
+ }
2276
+ /**
2277
+ * Create a new flow extension action
2278
+ */
2279
+ async createAction(data) {
2280
+ return this.post(
2281
+ "/flow/extensions/actions",
2282
+ data
2283
+ );
2284
+ }
2285
+ /**
2286
+ * Update an existing flow extension action
2287
+ */
2288
+ async updateAction(actionId, data) {
2289
+ return this.put(
2290
+ `/flow/extensions/actions/${actionId}`,
2291
+ data
2292
+ );
2293
+ }
2294
+ /**
2295
+ * Delete a flow extension action
2296
+ */
2297
+ async deleteAction(actionId) {
2298
+ return this._delete(
2299
+ `/flow/extensions/actions/${actionId}`
2300
+ );
2301
+ }
2302
+ // ========== Action Runs ==========
2303
+ /**
2304
+ * Update a flow action run status
2305
+ * Used to report completion or failure of async action execution
2306
+ */
2307
+ async updateActionRun(runId, data) {
2308
+ return this.put(`/flow/actions/runs/${runId}`, data);
2309
+ }
2310
+ };
2311
+
2312
+ // src/resources/ai-agent-runs.ts
2313
+ var AIAgentRunsResource = class extends BaseResource {
2314
+ /**
2315
+ * Create a new AI agent run
2316
+ * Returns 202 Accepted as the run executes asynchronously
2317
+ * Poll the retrieve endpoint to check for completion
2318
+ */
2319
+ async create(agentId, data) {
2320
+ return this.post(
2321
+ `/ai/agents/${agentId}/runs`,
2322
+ data || {}
2323
+ );
2324
+ }
2325
+ /**
2326
+ * Retrieve the status and results of an AI agent run
2327
+ * Use this to poll for completion after creating a run
2328
+ */
2329
+ async retrieve(agentId, runId) {
2330
+ return this.get(
2331
+ `/ai/agents/${agentId}/runs/${runId}`
2332
+ );
2333
+ }
2334
+ /**
2335
+ * Create a run and poll until completion
2336
+ * Convenience method that handles the async polling pattern
2337
+ *
2338
+ * @param agentId - The ID of the AI agent
2339
+ * @param data - Optional parameters for the run
2340
+ * @param options - Polling options
2341
+ * @returns The completed agent run
2342
+ */
2343
+ async createAndWait(agentId, data, options) {
2344
+ const timeout = options?.timeout ?? 6e4;
2345
+ const pollInterval = options?.pollInterval ?? 1e3;
2346
+ const startTime = Date.now();
2347
+ const { run } = await this.create(agentId, data);
2348
+ while (Date.now() - startTime < timeout) {
2349
+ const { run: currentRun } = await this.retrieve(agentId, run.id);
2350
+ if (currentRun.status === "completed" || currentRun.status === "error") {
2351
+ return currentRun;
2352
+ }
2353
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
2354
+ }
2355
+ throw new Error(
2356
+ `Agent run ${run.id} did not complete within ${timeout}ms timeout`
2357
+ );
2358
+ }
2359
+ };
2360
+
2100
2361
  // src/client.ts
2101
2362
  var MantleCoreClient = class {
2102
2363
  constructor(config) {
@@ -2151,6 +2412,10 @@ var MantleCoreClient = class {
2151
2412
  this.customData = new CustomDataResource(this);
2152
2413
  this.timelineComments = new TimelineCommentsResource(this);
2153
2414
  this.lists = new ListsResource(this);
2415
+ this.journalEntries = new JournalEntriesResource(this);
2416
+ this.emailUnsubscribeGroups = new EmailUnsubscribeGroupsResource(this);
2417
+ this.flowExtensions = new FlowExtensionsResource(this);
2418
+ this.aiAgentRuns = new AIAgentRunsResource(this);
2154
2419
  }
2155
2420
  /**
2156
2421
  * Register a middleware function
package/dist/index.mjs CHANGED
@@ -1846,6 +1846,32 @@ var DocsResource = class extends BaseResource {
1846
1846
  async getTree() {
1847
1847
  return this.get("/docs/tree");
1848
1848
  }
1849
+ // ========== Repositories ==========
1850
+ /**
1851
+ * List all doc repositories
1852
+ */
1853
+ async listRepositories(params) {
1854
+ const response = await this.get(
1855
+ "/docs/repositories",
1856
+ params
1857
+ );
1858
+ return {
1859
+ repositories: response.repositories || [],
1860
+ hasNextPage: response.hasNextPage || false,
1861
+ hasPreviousPage: response.hasPreviousPage || false,
1862
+ total: response.total,
1863
+ cursor: response.cursor
1864
+ };
1865
+ }
1866
+ /**
1867
+ * Retrieve a single doc repository
1868
+ */
1869
+ async retrieveRepository(repositoryId, params) {
1870
+ return this.get(
1871
+ `/docs/repositories/${repositoryId}`,
1872
+ params
1873
+ );
1874
+ }
1849
1875
  };
1850
1876
 
1851
1877
  // src/resources/entities.ts
@@ -1857,7 +1883,11 @@ var EntitiesResource = class extends BaseResource {
1857
1883
  async search(params) {
1858
1884
  const response = await this.get("/entities", params);
1859
1885
  return {
1860
- entities: response.entities || []
1886
+ entities: response.entities || [],
1887
+ hasNextPage: response.hasNextPage || false,
1888
+ hasPreviousPage: response.hasPreviousPage || false,
1889
+ total: response.total,
1890
+ cursor: response.cursor
1861
1891
  };
1862
1892
  }
1863
1893
  };
@@ -2031,6 +2061,237 @@ var ListsResource = class extends BaseResource {
2031
2061
  }
2032
2062
  };
2033
2063
 
2064
+ // src/resources/journal-entries.ts
2065
+ var JournalEntriesResource = class extends BaseResource {
2066
+ /**
2067
+ * List journal entries with optional filters and pagination
2068
+ */
2069
+ async list(params) {
2070
+ const response = await this.get(
2071
+ "/journal_entries",
2072
+ params
2073
+ );
2074
+ return {
2075
+ journalEntries: response.journalEntries || [],
2076
+ hasNextPage: response.hasNextPage || false,
2077
+ hasPreviousPage: response.hasPreviousPage || false,
2078
+ total: response.total,
2079
+ cursor: response.cursor
2080
+ };
2081
+ }
2082
+ /**
2083
+ * Retrieve a single journal entry by ID
2084
+ */
2085
+ async retrieve(entryId) {
2086
+ return this.get(
2087
+ `/journal_entries/${entryId}`
2088
+ );
2089
+ }
2090
+ /**
2091
+ * Create a new journal entry
2092
+ */
2093
+ async create(data) {
2094
+ return this.post("/journal_entries", data);
2095
+ }
2096
+ /**
2097
+ * Update an existing journal entry
2098
+ */
2099
+ async update(entryId, data) {
2100
+ return this.put(
2101
+ `/journal_entries/${entryId}`,
2102
+ data
2103
+ );
2104
+ }
2105
+ /**
2106
+ * Delete a journal entry
2107
+ */
2108
+ async del(entryId) {
2109
+ return this._delete(`/journal_entries/${entryId}`);
2110
+ }
2111
+ };
2112
+
2113
+ // src/resources/email-unsubscribe-groups.ts
2114
+ var EmailUnsubscribeGroupsResource = class extends BaseResource {
2115
+ /**
2116
+ * List all email unsubscribe groups
2117
+ */
2118
+ async list(params) {
2119
+ const response = await this.get(
2120
+ "/email/unsubscribe_groups",
2121
+ params
2122
+ );
2123
+ return {
2124
+ unsubscribeGroups: response.unsubscribeGroups || [],
2125
+ hasNextPage: response.hasNextPage || false,
2126
+ hasPreviousPage: response.hasPreviousPage || false,
2127
+ total: response.total,
2128
+ cursor: response.cursor
2129
+ };
2130
+ }
2131
+ /**
2132
+ * Retrieve a single unsubscribe group
2133
+ */
2134
+ async retrieve(groupId) {
2135
+ return this.get(
2136
+ `/email/unsubscribe_groups/${groupId}`
2137
+ );
2138
+ }
2139
+ // ========== Members ==========
2140
+ /**
2141
+ * List members of an unsubscribe group
2142
+ */
2143
+ async listMembers(groupId, params) {
2144
+ const response = await this.get(
2145
+ `/email/unsubscribe_groups/${groupId}/members`,
2146
+ params
2147
+ );
2148
+ return {
2149
+ members: response.members || [],
2150
+ hasNextPage: response.hasNextPage || false,
2151
+ hasPreviousPage: response.hasPreviousPage || false,
2152
+ total: response.total,
2153
+ cursor: response.cursor
2154
+ };
2155
+ }
2156
+ /**
2157
+ * Add members to an unsubscribe group by email addresses
2158
+ */
2159
+ async addMembers(groupId, data) {
2160
+ return this.post(
2161
+ `/email/unsubscribe_groups/${groupId}/members`,
2162
+ data
2163
+ );
2164
+ }
2165
+ /**
2166
+ * Remove members from an unsubscribe group by email addresses
2167
+ */
2168
+ async removeMembers(groupId, data) {
2169
+ return this._delete(
2170
+ `/email/unsubscribe_groups/${groupId}/members?emails=${encodeURIComponent(data.emails.join(","))}`
2171
+ );
2172
+ }
2173
+ /**
2174
+ * Remove a single member from an unsubscribe group by member ID
2175
+ */
2176
+ async removeMember(groupId, memberId) {
2177
+ return this._delete(
2178
+ `/email/unsubscribe_groups/${groupId}/members/${memberId}`
2179
+ );
2180
+ }
2181
+ };
2182
+
2183
+ // src/resources/flow-extensions.ts
2184
+ var FlowExtensionsResource = class extends BaseResource {
2185
+ // ========== Actions ==========
2186
+ /**
2187
+ * List flow extension actions
2188
+ */
2189
+ async listActions(params) {
2190
+ const response = await this.get(
2191
+ "/flow/extensions/actions",
2192
+ params
2193
+ );
2194
+ return {
2195
+ actions: response.actions || [],
2196
+ hasNextPage: response.hasNextPage || false,
2197
+ hasPreviousPage: response.hasPreviousPage || false,
2198
+ total: response.total,
2199
+ cursor: response.cursor
2200
+ };
2201
+ }
2202
+ /**
2203
+ * Retrieve a single flow extension action
2204
+ */
2205
+ async retrieveAction(actionId) {
2206
+ return this.get(
2207
+ `/flow/extensions/actions/${actionId}`
2208
+ );
2209
+ }
2210
+ /**
2211
+ * Create a new flow extension action
2212
+ */
2213
+ async createAction(data) {
2214
+ return this.post(
2215
+ "/flow/extensions/actions",
2216
+ data
2217
+ );
2218
+ }
2219
+ /**
2220
+ * Update an existing flow extension action
2221
+ */
2222
+ async updateAction(actionId, data) {
2223
+ return this.put(
2224
+ `/flow/extensions/actions/${actionId}`,
2225
+ data
2226
+ );
2227
+ }
2228
+ /**
2229
+ * Delete a flow extension action
2230
+ */
2231
+ async deleteAction(actionId) {
2232
+ return this._delete(
2233
+ `/flow/extensions/actions/${actionId}`
2234
+ );
2235
+ }
2236
+ // ========== Action Runs ==========
2237
+ /**
2238
+ * Update a flow action run status
2239
+ * Used to report completion or failure of async action execution
2240
+ */
2241
+ async updateActionRun(runId, data) {
2242
+ return this.put(`/flow/actions/runs/${runId}`, data);
2243
+ }
2244
+ };
2245
+
2246
+ // src/resources/ai-agent-runs.ts
2247
+ var AIAgentRunsResource = class extends BaseResource {
2248
+ /**
2249
+ * Create a new AI agent run
2250
+ * Returns 202 Accepted as the run executes asynchronously
2251
+ * Poll the retrieve endpoint to check for completion
2252
+ */
2253
+ async create(agentId, data) {
2254
+ return this.post(
2255
+ `/ai/agents/${agentId}/runs`,
2256
+ data || {}
2257
+ );
2258
+ }
2259
+ /**
2260
+ * Retrieve the status and results of an AI agent run
2261
+ * Use this to poll for completion after creating a run
2262
+ */
2263
+ async retrieve(agentId, runId) {
2264
+ return this.get(
2265
+ `/ai/agents/${agentId}/runs/${runId}`
2266
+ );
2267
+ }
2268
+ /**
2269
+ * Create a run and poll until completion
2270
+ * Convenience method that handles the async polling pattern
2271
+ *
2272
+ * @param agentId - The ID of the AI agent
2273
+ * @param data - Optional parameters for the run
2274
+ * @param options - Polling options
2275
+ * @returns The completed agent run
2276
+ */
2277
+ async createAndWait(agentId, data, options) {
2278
+ const timeout = options?.timeout ?? 6e4;
2279
+ const pollInterval = options?.pollInterval ?? 1e3;
2280
+ const startTime = Date.now();
2281
+ const { run } = await this.create(agentId, data);
2282
+ while (Date.now() - startTime < timeout) {
2283
+ const { run: currentRun } = await this.retrieve(agentId, run.id);
2284
+ if (currentRun.status === "completed" || currentRun.status === "error") {
2285
+ return currentRun;
2286
+ }
2287
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
2288
+ }
2289
+ throw new Error(
2290
+ `Agent run ${run.id} did not complete within ${timeout}ms timeout`
2291
+ );
2292
+ }
2293
+ };
2294
+
2034
2295
  // src/client.ts
2035
2296
  var MantleCoreClient = class {
2036
2297
  constructor(config) {
@@ -2085,6 +2346,10 @@ var MantleCoreClient = class {
2085
2346
  this.customData = new CustomDataResource(this);
2086
2347
  this.timelineComments = new TimelineCommentsResource(this);
2087
2348
  this.lists = new ListsResource(this);
2349
+ this.journalEntries = new JournalEntriesResource(this);
2350
+ this.emailUnsubscribeGroups = new EmailUnsubscribeGroupsResource(this);
2351
+ this.flowExtensions = new FlowExtensionsResource(this);
2352
+ this.aiAgentRuns = new AIAgentRunsResource(this);
2088
2353
  }
2089
2354
  /**
2090
2355
  * Register a middleware function
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heymantle/core-api-client",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "TypeScript SDK for the Mantle Core API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",