@caruuto/caruuto-js 0.3.4 → 0.3.6
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 +8 -1
- package/lib/filters.js +6 -0
- package/lib/helpers.js +10 -0
- package/lib/terminators.js +42 -0
- package/package.json +1 -1
- package/x.js +17 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,14 @@ 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.
|
|
8
|
+
## 0.3.6 - 2024-09-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added `createToken` method for creating new tokens for reset password, etc.
|
|
13
|
+
- Added `verifyToken` method for verifying tokens created by `createToken`.
|
|
14
|
+
|
|
15
|
+
## 0.3.5 - 2024-05-08
|
|
9
16
|
|
|
10
17
|
### Fixed
|
|
11
18
|
|
package/lib/filters.js
CHANGED
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
|
})
|
package/lib/terminators.js
CHANGED
|
@@ -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
|
*
|
|
@@ -296,4 +297,45 @@ module.exports = function (CaruutoClient) {
|
|
|
296
297
|
|
|
297
298
|
return this._createRequestObject(requestPayload)
|
|
298
299
|
}
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
* Create a new token.
|
|
303
|
+
* @param {Object} data
|
|
304
|
+
* @api public
|
|
305
|
+
*/
|
|
306
|
+
CaruutoClient.prototype.createToken = function (data) {
|
|
307
|
+
this.endpoint = 'tokens'
|
|
308
|
+
|
|
309
|
+
const requestPayload = {
|
|
310
|
+
body: data,
|
|
311
|
+
method: 'POST',
|
|
312
|
+
uri: this._buildURL()
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
this._setHeader('content-type', 'application/json')
|
|
316
|
+
|
|
317
|
+
return this._createRequestObject(requestPayload)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/*
|
|
321
|
+
* Verify a token.
|
|
322
|
+
* @param {Object} data
|
|
323
|
+
* @api public
|
|
324
|
+
*/
|
|
325
|
+
CaruutoClient.prototype.verifyToken = function (token) {
|
|
326
|
+
this.endpoint = 'tokens'
|
|
327
|
+
|
|
328
|
+
const requestPayload = {
|
|
329
|
+
body: {
|
|
330
|
+
token,
|
|
331
|
+
verify: true
|
|
332
|
+
},
|
|
333
|
+
method: 'POST',
|
|
334
|
+
uri: this._buildURL()
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this._setHeader('content-type', 'application/json')
|
|
338
|
+
|
|
339
|
+
return this._createRequestObject(requestPayload)
|
|
340
|
+
}
|
|
299
341
|
}
|
package/package.json
CHANGED
package/x.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
const { createClient } = require('./index')
|
|
2
2
|
|
|
3
3
|
;(async () => {
|
|
4
|
-
const x = createClient('https://localcaruuto.com/api', '
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
|
|
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()
|
|
18
|
+
// console.log('y :>> ', y)
|
|
19
|
+
|
|
20
|
+
// const z = await x.createToken({
|
|
21
|
+
// email: 'jameslambie@gmail.com',
|
|
22
|
+
// type: 'RESET'
|
|
23
|
+
// })
|
|
24
|
+
const z = await x.verifyToken('q8ug8epjx5hzcg48ku')
|
|
25
|
+
console.log('z :>> ', z)
|
|
16
26
|
})()
|