@caruuto/caruuto-js 0.9.0 → 0.9.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.
package/index.js CHANGED
@@ -3,6 +3,7 @@ const CaruutoClient = function (caruutoUrl, caruutoApiKey, options = {}) {
3
3
  this.options.caruutoUrl = caruutoUrl
4
4
  .replace(/\/api\/?$/, '')
5
5
  .replace(/\/$/, '')
6
+ + '/api'
6
7
  this.options.caruutoApiKey = caruutoApiKey
7
8
 
8
9
  this.options.version = '1'
@@ -28,7 +28,7 @@ module.exports = function (CaruutoClient, clientInstance) {
28
28
  const body = buildRequestBody(opts, false)
29
29
  const response = await doFetch(
30
30
  this,
31
- `${this.options.caruutoUrl}/api/ai/external`,
31
+ `${this.options.caruutoUrl}/ai/external`,
32
32
  body
33
33
  )
34
34
  return response.status === 204 ? undefined : response.json()
@@ -49,7 +49,7 @@ module.exports = function (CaruutoClient, clientInstance) {
49
49
  const body = buildRequestBody(opts, true)
50
50
  const response = await doFetch(
51
51
  this,
52
- `${this.options.caruutoUrl}/api/ai/external`,
52
+ `${this.options.caruutoUrl}/ai/external`,
53
53
  body
54
54
  )
55
55
 
@@ -117,7 +117,7 @@ module.exports = function (CaruutoClient, clientInstance) {
117
117
  throw new Error('projectId is required')
118
118
  }
119
119
 
120
- const url = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/end`
120
+ const url = `${this.options.caruutoUrl}/ai/conversations/${conversationId}/end`
121
121
  const response = await doFetch(this, url, { project_id: projectId })
122
122
  return response.json()
123
123
  }.bind(clientInstance),
@@ -167,7 +167,7 @@ module.exports = function (CaruutoClient, clientInstance) {
167
167
 
168
168
  const response = await doFetch(
169
169
  this,
170
- `${this.options.caruutoUrl}/api/ai/context`,
170
+ `${this.options.caruutoUrl}/ai/context`,
171
171
  body
172
172
  )
173
173
  return response.json()
@@ -228,7 +228,7 @@ module.exports = function (CaruutoClient, clientInstance) {
228
228
  if (!sourceId) throw new Error('sourceId is required')
229
229
  if (!projectId) throw new Error('projectId is required')
230
230
 
231
- const url = `${this.options.caruutoUrl}/api/ai/conversations/${sourceId}/fork`
231
+ const url = `${this.options.caruutoUrl}/ai/conversations/${sourceId}/fork`
232
232
  const response = await doFetch(this, url, {
233
233
  project_id: projectId,
234
234
  source
@@ -244,7 +244,7 @@ module.exports = function (CaruutoClient, clientInstance) {
244
244
  if (!conversationId) throw new Error('conversationId is required')
245
245
  if (!projectId) throw new Error('projectId is required')
246
246
 
247
- const url = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/share`
247
+ const url = `${this.options.caruutoUrl}/ai/conversations/${conversationId}/share`
248
248
  const response = await doFetch(this, url, {
249
249
  project_id: projectId,
250
250
  visibility
@@ -264,7 +264,7 @@ module.exports = function (CaruutoClient, clientInstance) {
264
264
  if (!conversationId) throw new Error('conversationId is required')
265
265
 
266
266
  const fetch = this.options.fetch || undici.fetch
267
- const url = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/public`
267
+ const url = `${this.options.caruutoUrl}/ai/conversations/${conversationId}/public`
268
268
 
269
269
  const response = await fetch(url, { method: 'GET' })
270
270
 
@@ -292,7 +292,7 @@ module.exports = function (CaruutoClient, clientInstance) {
292
292
 
293
293
  const url = `${
294
294
  this.options.caruutoUrl
295
- }/api/ai/conversations/${conversationId}?project_id=${encodeURIComponent(
295
+ }/ai/conversations/${conversationId}?project_id=${encodeURIComponent(
296
296
  projectId
297
297
  )}`
298
298
  const response = await doGet(this, url)
@@ -334,7 +334,7 @@ module.exports = function (CaruutoClient, clientInstance) {
334
334
  if (leadEmail) body.lead_email = leadEmail
335
335
  if (leadName) body.lead_name = leadName
336
336
 
337
- const url = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/turn`
337
+ const url = `${this.options.caruutoUrl}/ai/conversations/${conversationId}/turn`
338
338
  const response = await doFetch(this, url, body)
339
339
  return response.json()
340
340
  }.bind(clientInstance),
@@ -377,7 +377,7 @@ module.exports = function (CaruutoClient, clientInstance) {
377
377
  if (linkLabel) body.link_label = linkLabel
378
378
  if (messageIndex !== undefined) body.message_index = messageIndex
379
379
 
380
- const trackUrl = `${this.options.caruutoUrl}/api/ai/conversations/${conversationId}/link-click`
380
+ const trackUrl = `${this.options.caruutoUrl}/ai/conversations/${conversationId}/link-click`
381
381
  const response = await doFetch(this, trackUrl, body)
382
382
  return response.json()
383
383
  }.bind(clientInstance)
package/lib/helpers.js CHANGED
@@ -59,7 +59,7 @@ module.exports = function (CaruutoClient) {
59
59
  }
60
60
 
61
61
  if (options.collections) {
62
- url = this.options.caruutoUrl + '/api/contentTypes'
62
+ url = this.options.caruutoUrl + '/contentTypes'
63
63
  }
64
64
 
65
65
  if (this.count) {
@@ -128,7 +128,7 @@ module.exports = function (CaruutoClient) {
128
128
 
129
129
  const requestPayload = {
130
130
  method: 'POST',
131
- uri: this.options.caruutoUrl + '/api/media/upload'
131
+ uri: this.options.caruutoUrl + '/media/upload'
132
132
  }
133
133
 
134
134
  const formData = new FormData()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caruuto/caruuto-js",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "A high-level library for interacting with Caruuto",
5
5
  "exports": "./index.js",
6
6
  "scripts": {