@caruuto/caruuto-js 0.3.3 → 0.3.5

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/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## 0.3.4 - 2024-05-08
9
+
10
+ ### Fixed
11
+
12
+ - Added encoding package referenced by node-fetch to remove console warning:
13
+
14
+ ```
15
+ warn - ../caruuto-js/node_modules/node-fetch/lib/index.js
16
+ Module not found: Can't resolve 'encoding' in '../caruuto-js/node_modules/node-fetch/lib'
17
+ ```
18
+
8
19
  ## 0.3.1 - 2024-01-16
9
20
 
10
21
  ### Fixed
package/lib/filters.js CHANGED
@@ -53,6 +53,12 @@ module.exports = function (CaruutoClient) {
53
53
  return this
54
54
  }
55
55
 
56
+ CaruutoClient.prototype.search = function ({ phrase }) {
57
+ this.searchPhrase = phrase
58
+
59
+ return this
60
+ }
61
+
56
62
  /**
57
63
  * Select a field to sort on and the sort direction
58
64
  *
package/lib/helpers.js CHANGED
@@ -51,6 +51,8 @@ module.exports = function (CaruutoClient) {
51
51
  (typeof this.mediaBucket === 'string' ? '/' + this.mediaBucket : '')
52
52
  } else if (this.collection) {
53
53
  url += '/' + options.version + '/' + this.collection
54
+ } else if (this.searchPhrase) {
55
+ url += '/' + options.version
54
56
  } else {
55
57
  url +=
56
58
  '/' +
@@ -93,6 +95,10 @@ module.exports = function (CaruutoClient) {
93
95
  url += '/' + options.id
94
96
  }
95
97
 
98
+ if (this.searchPhrase) {
99
+ url += '/search'
100
+ }
101
+
96
102
  if (options.useParams) {
97
103
  const params = {}
98
104
 
@@ -124,6 +130,10 @@ module.exports = function (CaruutoClient) {
124
130
  params.sort = JSON.stringify(this.sort)
125
131
  }
126
132
 
133
+ if (this.searchPhrase) {
134
+ params.phrase = this.searchPhrase
135
+ }
136
+
127
137
  const paramsStr = querystring.stringify(params, {
128
138
  encode: false
129
139
  })
@@ -163,6 +163,7 @@ module.exports = function (CaruutoClient) {
163
163
  uri: this._buildURL({ status: true })
164
164
  })
165
165
  }
166
+
166
167
  /**
167
168
  * Update the documents affect by the saved query
168
169
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caruuto/caruuto-js",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "A high-level library for interacting with Caruuto",
5
5
  "exports": "./index.js",
6
6
  "scripts": {
@@ -10,8 +10,9 @@
10
10
  "author": "Jim Lambie <jim@27.works>",
11
11
  "license": "GPL",
12
12
  "dependencies": {
13
- "cross-fetch": "^3.1.6",
13
+ "cross-fetch": "^4.0.0",
14
14
  "debug": "^2.6.1",
15
+ "encoding": "^0.1.13",
15
16
  "got": "^11.0.0",
16
17
  "mocha": "^10.2.0",
17
18
  "query-string": "5.0.1"
package/x.js CHANGED
@@ -1,16 +1,19 @@
1
1
  const { createClient } = require('./index')
2
2
 
3
3
  ;(async () => {
4
- const x = createClient('https://localcaruuto.com/api', 'apiKey-xyz')
4
+ const x = createClient('https://localcaruuto.com/api', '12345678900987654321')
5
5
 
6
6
  // const signedUrl = await x.inMedia('radical').getSignedUrl('test.jpg')
7
7
 
8
8
  // console.log(signedUrl)
9
9
 
10
- const y = await x.insertDataPoint({
11
- memberId: '0bcdd373-fbb6-4998-b0ed-57c842709acc',
12
- optionId: '10',
13
- questionId: 'f373b0a2-9c87-41f1-af49-f643da8f836c'
14
- })
10
+ // const y = await x.insertDataPoint({
11
+ // memberId: '0bcdd373-fbb6-4998-b0ed-57c842709acc',
12
+ // optionId: '10',
13
+ // questionId: 'f373b0a2-9c87-41f1-af49-f643da8f836c'
14
+ // })
15
+
16
+ x.search({ phrase: 'grower' })
17
+ const y = await x.find()
15
18
  console.log('y :>> ', y)
16
19
  })()