@papr/memory 1.9.0 → 1.10.0
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 +15 -0
- package/README.md +17 -19
- package/client.d.mts +19 -7
- package/client.d.mts.map +1 -1
- package/client.d.ts +19 -7
- package/client.d.ts.map +1 -1
- package/client.js +24 -11
- package/client.js.map +1 -1
- package/client.mjs +24 -11
- package/client.mjs.map +1 -1
- package/internal/request-options.d.mts +42 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +42 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/internal/uploads.js +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +4 -3
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +4 -3
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.d.mts.map +1 -1
- package/internal/utils/path.d.ts.map +1 -1
- package/internal/utils/path.js +26 -5
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +26 -5
- package/internal/utils/path.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/feedback.d.mts +333 -0
- package/resources/feedback.d.mts.map +1 -0
- package/resources/feedback.d.ts +333 -0
- package/resources/feedback.d.ts.map +1 -0
- package/resources/feedback.js +108 -0
- package/resources/feedback.js.map +1 -0
- package/resources/feedback.mjs +104 -0
- package/resources/feedback.mjs.map +1 -0
- package/resources/index.d.mts +2 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/memory.d.mts +48 -11
- package/resources/memory.d.mts.map +1 -1
- package/resources/memory.d.ts +48 -11
- package/resources/memory.d.ts.map +1 -1
- package/resources/memory.js +11 -0
- package/resources/memory.js.map +1 -1
- package/resources/memory.mjs +11 -0
- package/resources/memory.mjs.map +1 -1
- package/resources/user.d.mts +24 -88
- package/resources/user.d.mts.map +1 -1
- package/resources/user.d.ts +24 -88
- package/resources/user.d.ts.map +1 -1
- package/resources/user.js +17 -56
- package/resources/user.js.map +1 -1
- package/resources/user.mjs +17 -56
- package/resources/user.mjs.map +1 -1
- package/src/client.ts +55 -16
- package/src/internal/request-options.ts +53 -0
- package/src/internal/uploads.ts +1 -1
- package/src/internal/utils/log.ts +3 -2
- package/src/internal/utils/path.ts +32 -7
- package/src/resources/feedback.ts +424 -0
- package/src/resources/index.ts +9 -1
- package/src/resources/memory.ts +44 -11
- package/src/resources/user.ts +29 -130
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/resources/user.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.User = void 0;
|
|
5
5
|
const resource_1 = require("../core/resource.js");
|
|
6
|
-
const headers_1 = require("../internal/headers.js");
|
|
7
6
|
const path_1 = require("../internal/utils/path.js");
|
|
8
7
|
class User extends resource_1.APIResource {
|
|
9
8
|
/**
|
|
@@ -13,53 +12,33 @@ class User extends resource_1.APIResource {
|
|
|
13
12
|
* ```ts
|
|
14
13
|
* const userResponse = await client.user.create({
|
|
15
14
|
* external_id: 'user123',
|
|
16
|
-
* 'X-API-Key': 'X-API-Key',
|
|
17
15
|
* });
|
|
18
16
|
* ```
|
|
19
17
|
*/
|
|
20
|
-
create(
|
|
21
|
-
|
|
22
|
-
return this._client.post('/v1/user', {
|
|
23
|
-
body,
|
|
24
|
-
...options,
|
|
25
|
-
headers: (0, headers_1.buildHeaders)([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
26
|
-
});
|
|
18
|
+
create(body, options) {
|
|
19
|
+
return this._client.post('/v1/user', { body, ...options });
|
|
27
20
|
}
|
|
28
21
|
/**
|
|
29
22
|
* Update user details by user_id (\_User.objectId) and developer association
|
|
30
23
|
*
|
|
31
24
|
* @example
|
|
32
25
|
* ```ts
|
|
33
|
-
* const userResponse = await client.user.update('user_id'
|
|
34
|
-
* 'X-API-Key': 'X-API-Key',
|
|
35
|
-
* });
|
|
26
|
+
* const userResponse = await client.user.update('user_id');
|
|
36
27
|
* ```
|
|
37
28
|
*/
|
|
38
|
-
update(userID,
|
|
39
|
-
|
|
40
|
-
return this._client.put((0, path_1.path) `/v1/user/${userID}`, {
|
|
41
|
-
body,
|
|
42
|
-
...options,
|
|
43
|
-
headers: (0, headers_1.buildHeaders)([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
44
|
-
});
|
|
29
|
+
update(userID, body, options) {
|
|
30
|
+
return this._client.put((0, path_1.path) `/v1/user/${userID}`, { body, ...options });
|
|
45
31
|
}
|
|
46
32
|
/**
|
|
47
33
|
* List users for a developer
|
|
48
34
|
*
|
|
49
35
|
* @example
|
|
50
36
|
* ```ts
|
|
51
|
-
* const users = await client.user.list(
|
|
52
|
-
* 'X-API-Key': 'X-API-Key',
|
|
53
|
-
* });
|
|
37
|
+
* const users = await client.user.list();
|
|
54
38
|
* ```
|
|
55
39
|
*/
|
|
56
|
-
list(
|
|
57
|
-
|
|
58
|
-
return this._client.get('/v1/user', {
|
|
59
|
-
query,
|
|
60
|
-
...options,
|
|
61
|
-
headers: (0, headers_1.buildHeaders)([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
62
|
-
});
|
|
40
|
+
list(query = {}, options) {
|
|
41
|
+
return this._client.get('/v1/user', { query, ...options });
|
|
63
42
|
}
|
|
64
43
|
/**
|
|
65
44
|
* Delete user association with developer and the user itself by , assume external
|
|
@@ -67,18 +46,12 @@ class User extends resource_1.APIResource {
|
|
|
67
46
|
*
|
|
68
47
|
* @example
|
|
69
48
|
* ```ts
|
|
70
|
-
* const user = await client.user.delete('user_id'
|
|
71
|
-
* 'X-API-Key': 'X-API-Key',
|
|
72
|
-
* });
|
|
49
|
+
* const user = await client.user.delete('user_id');
|
|
73
50
|
* ```
|
|
74
51
|
*/
|
|
75
|
-
delete(userID, params, options) {
|
|
76
|
-
const {
|
|
77
|
-
return this._client.delete((0, path_1.path) `/v1/user/${userID}`, {
|
|
78
|
-
query: { is_external },
|
|
79
|
-
...options,
|
|
80
|
-
headers: (0, headers_1.buildHeaders)([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
81
|
-
});
|
|
52
|
+
delete(userID, params = {}, options) {
|
|
53
|
+
const { is_external } = params ?? {};
|
|
54
|
+
return this._client.delete((0, path_1.path) `/v1/user/${userID}`, { query: { is_external }, ...options });
|
|
82
55
|
}
|
|
83
56
|
/**
|
|
84
57
|
* Create multiple users or link existing users to developer, and add each to the
|
|
@@ -88,34 +61,22 @@ class User extends resource_1.APIResource {
|
|
|
88
61
|
* ```ts
|
|
89
62
|
* const response = await client.user.createBatch({
|
|
90
63
|
* users: [{ external_id: 'user123' }],
|
|
91
|
-
* 'X-API-Key': 'X-API-Key',
|
|
92
64
|
* });
|
|
93
65
|
* ```
|
|
94
66
|
*/
|
|
95
|
-
createBatch(
|
|
96
|
-
|
|
97
|
-
return this._client.post('/v1/user/batch', {
|
|
98
|
-
body,
|
|
99
|
-
...options,
|
|
100
|
-
headers: (0, headers_1.buildHeaders)([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
101
|
-
});
|
|
67
|
+
createBatch(body, options) {
|
|
68
|
+
return this._client.post('/v1/user/batch', { body, ...options });
|
|
102
69
|
}
|
|
103
70
|
/**
|
|
104
71
|
* Get user details by user_id (\_User.objectId) and developer association
|
|
105
72
|
*
|
|
106
73
|
* @example
|
|
107
74
|
* ```ts
|
|
108
|
-
* const userResponse = await client.user.get('user_id'
|
|
109
|
-
* 'X-API-Key': 'X-API-Key',
|
|
110
|
-
* });
|
|
75
|
+
* const userResponse = await client.user.get('user_id');
|
|
111
76
|
* ```
|
|
112
77
|
*/
|
|
113
|
-
get(userID,
|
|
114
|
-
|
|
115
|
-
return this._client.get((0, path_1.path) `/v1/user/${userID}`, {
|
|
116
|
-
...options,
|
|
117
|
-
headers: (0, headers_1.buildHeaders)([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
118
|
-
});
|
|
78
|
+
get(userID, options) {
|
|
79
|
+
return this._client.get((0, path_1.path) `/v1/user/${userID}`, options);
|
|
119
80
|
}
|
|
120
81
|
}
|
|
121
82
|
exports.User = User;
|
package/resources/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../src/resources/user.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../src/resources/user.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,oDAA8C;AAE9C,MAAa,IAAK,SAAQ,sBAAW;IACnC;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAsB,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAc,EAAE,IAAsB,EAAE,OAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,YAAY,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CACF,QAA2C,EAAE,EAC7C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CACJ,MAAc,EACd,SAA8C,EAAE,EAChD,OAAwB;QAExB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAA,WAAI,EAAA,YAAY,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;;;;;;;;OAUG;IACH,WAAW,CAAC,IAA2B,EAAE,OAAwB;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,MAAc,EAAE,OAAwB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,YAAY,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;CACF;AAtFD,oBAsFC"}
|
package/resources/user.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { APIResource } from "../core/resource.mjs";
|
|
3
|
-
import { buildHeaders } from "../internal/headers.mjs";
|
|
4
3
|
import { path } from "../internal/utils/path.mjs";
|
|
5
4
|
export class User extends APIResource {
|
|
6
5
|
/**
|
|
@@ -10,53 +9,33 @@ export class User extends APIResource {
|
|
|
10
9
|
* ```ts
|
|
11
10
|
* const userResponse = await client.user.create({
|
|
12
11
|
* external_id: 'user123',
|
|
13
|
-
* 'X-API-Key': 'X-API-Key',
|
|
14
12
|
* });
|
|
15
13
|
* ```
|
|
16
14
|
*/
|
|
17
|
-
create(
|
|
18
|
-
|
|
19
|
-
return this._client.post('/v1/user', {
|
|
20
|
-
body,
|
|
21
|
-
...options,
|
|
22
|
-
headers: buildHeaders([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
23
|
-
});
|
|
15
|
+
create(body, options) {
|
|
16
|
+
return this._client.post('/v1/user', { body, ...options });
|
|
24
17
|
}
|
|
25
18
|
/**
|
|
26
19
|
* Update user details by user_id (\_User.objectId) and developer association
|
|
27
20
|
*
|
|
28
21
|
* @example
|
|
29
22
|
* ```ts
|
|
30
|
-
* const userResponse = await client.user.update('user_id'
|
|
31
|
-
* 'X-API-Key': 'X-API-Key',
|
|
32
|
-
* });
|
|
23
|
+
* const userResponse = await client.user.update('user_id');
|
|
33
24
|
* ```
|
|
34
25
|
*/
|
|
35
|
-
update(userID,
|
|
36
|
-
|
|
37
|
-
return this._client.put(path `/v1/user/${userID}`, {
|
|
38
|
-
body,
|
|
39
|
-
...options,
|
|
40
|
-
headers: buildHeaders([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
41
|
-
});
|
|
26
|
+
update(userID, body, options) {
|
|
27
|
+
return this._client.put(path `/v1/user/${userID}`, { body, ...options });
|
|
42
28
|
}
|
|
43
29
|
/**
|
|
44
30
|
* List users for a developer
|
|
45
31
|
*
|
|
46
32
|
* @example
|
|
47
33
|
* ```ts
|
|
48
|
-
* const users = await client.user.list(
|
|
49
|
-
* 'X-API-Key': 'X-API-Key',
|
|
50
|
-
* });
|
|
34
|
+
* const users = await client.user.list();
|
|
51
35
|
* ```
|
|
52
36
|
*/
|
|
53
|
-
list(
|
|
54
|
-
|
|
55
|
-
return this._client.get('/v1/user', {
|
|
56
|
-
query,
|
|
57
|
-
...options,
|
|
58
|
-
headers: buildHeaders([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
59
|
-
});
|
|
37
|
+
list(query = {}, options) {
|
|
38
|
+
return this._client.get('/v1/user', { query, ...options });
|
|
60
39
|
}
|
|
61
40
|
/**
|
|
62
41
|
* Delete user association with developer and the user itself by , assume external
|
|
@@ -64,18 +43,12 @@ export class User extends APIResource {
|
|
|
64
43
|
*
|
|
65
44
|
* @example
|
|
66
45
|
* ```ts
|
|
67
|
-
* const user = await client.user.delete('user_id'
|
|
68
|
-
* 'X-API-Key': 'X-API-Key',
|
|
69
|
-
* });
|
|
46
|
+
* const user = await client.user.delete('user_id');
|
|
70
47
|
* ```
|
|
71
48
|
*/
|
|
72
|
-
delete(userID, params, options) {
|
|
73
|
-
const {
|
|
74
|
-
return this._client.delete(path `/v1/user/${userID}`, {
|
|
75
|
-
query: { is_external },
|
|
76
|
-
...options,
|
|
77
|
-
headers: buildHeaders([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
78
|
-
});
|
|
49
|
+
delete(userID, params = {}, options) {
|
|
50
|
+
const { is_external } = params ?? {};
|
|
51
|
+
return this._client.delete(path `/v1/user/${userID}`, { query: { is_external }, ...options });
|
|
79
52
|
}
|
|
80
53
|
/**
|
|
81
54
|
* Create multiple users or link existing users to developer, and add each to the
|
|
@@ -85,34 +58,22 @@ export class User extends APIResource {
|
|
|
85
58
|
* ```ts
|
|
86
59
|
* const response = await client.user.createBatch({
|
|
87
60
|
* users: [{ external_id: 'user123' }],
|
|
88
|
-
* 'X-API-Key': 'X-API-Key',
|
|
89
61
|
* });
|
|
90
62
|
* ```
|
|
91
63
|
*/
|
|
92
|
-
createBatch(
|
|
93
|
-
|
|
94
|
-
return this._client.post('/v1/user/batch', {
|
|
95
|
-
body,
|
|
96
|
-
...options,
|
|
97
|
-
headers: buildHeaders([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
98
|
-
});
|
|
64
|
+
createBatch(body, options) {
|
|
65
|
+
return this._client.post('/v1/user/batch', { body, ...options });
|
|
99
66
|
}
|
|
100
67
|
/**
|
|
101
68
|
* Get user details by user_id (\_User.objectId) and developer association
|
|
102
69
|
*
|
|
103
70
|
* @example
|
|
104
71
|
* ```ts
|
|
105
|
-
* const userResponse = await client.user.get('user_id'
|
|
106
|
-
* 'X-API-Key': 'X-API-Key',
|
|
107
|
-
* });
|
|
72
|
+
* const userResponse = await client.user.get('user_id');
|
|
108
73
|
* ```
|
|
109
74
|
*/
|
|
110
|
-
get(userID,
|
|
111
|
-
|
|
112
|
-
return this._client.get(path `/v1/user/${userID}`, {
|
|
113
|
-
...options,
|
|
114
|
-
headers: buildHeaders([{ 'X-API-Key': xAPIKey }, options?.headers]),
|
|
115
|
-
});
|
|
75
|
+
get(userID, options) {
|
|
76
|
+
return this._client.get(path `/v1/user/${userID}`, options);
|
|
116
77
|
}
|
|
117
78
|
}
|
|
118
79
|
//# sourceMappingURL=user.mjs.map
|
package/resources/user.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.mjs","sourceRoot":"","sources":["../src/resources/user.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"user.mjs","sourceRoot":"","sources":["../src/resources/user.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAIf,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAsB,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAc,EAAE,IAAsB,EAAE,OAAwB;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,YAAY,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CACF,QAA2C,EAAE,EAC7C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CACJ,MAAc,EACd,SAA8C,EAAE,EAChD,OAAwB;QAExB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAA,YAAY,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;;;;;;;;OAUG;IACH,WAAW,CAAC,IAA2B,EAAE,OAAwB;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;OAOG;IACH,GAAG,CAAC,MAAc,EAAE,OAAwB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,YAAY,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
package/src/client.ts
CHANGED
|
@@ -16,6 +16,15 @@ import * as Errors from './core/error';
|
|
|
16
16
|
import * as Uploads from './core/uploads';
|
|
17
17
|
import * as API from './resources/index';
|
|
18
18
|
import { APIPromise } from './core/api-promise';
|
|
19
|
+
import {
|
|
20
|
+
BatchRequest,
|
|
21
|
+
BatchResponse,
|
|
22
|
+
Feedback,
|
|
23
|
+
FeedbackRequest,
|
|
24
|
+
FeedbackResponse,
|
|
25
|
+
FeedbackSubmitBatchParams,
|
|
26
|
+
FeedbackSubmitParams,
|
|
27
|
+
} from './resources/feedback';
|
|
19
28
|
import {
|
|
20
29
|
AddMemory,
|
|
21
30
|
AddMemoryResponse,
|
|
@@ -41,7 +50,6 @@ import {
|
|
|
41
50
|
UserCreateParams,
|
|
42
51
|
UserDeleteParams,
|
|
43
52
|
UserDeleteResponse,
|
|
44
|
-
UserGetParams,
|
|
45
53
|
UserListParams,
|
|
46
54
|
UserListResponse,
|
|
47
55
|
UserResponse,
|
|
@@ -65,7 +73,12 @@ export interface ClientOptions {
|
|
|
65
73
|
/**
|
|
66
74
|
* Defaults to process.env['PAPR_MEMORY_API_KEY'].
|
|
67
75
|
*/
|
|
68
|
-
|
|
76
|
+
xAPIKey?: string | undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Defaults to process.env['PAPR_MEMORY_Session_Token'].
|
|
80
|
+
*/
|
|
81
|
+
xSessionToken?: string | null | undefined;
|
|
69
82
|
|
|
70
83
|
/**
|
|
71
84
|
* Defaults to process.env['PAPR_MEMORY_BEARER_TOKEN'].
|
|
@@ -85,6 +98,8 @@ export interface ClientOptions {
|
|
|
85
98
|
*
|
|
86
99
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
87
100
|
* much longer than this timeout before the promise succeeds or fails.
|
|
101
|
+
*
|
|
102
|
+
* @unit milliseconds
|
|
88
103
|
*/
|
|
89
104
|
timeout?: number | undefined;
|
|
90
105
|
/**
|
|
@@ -143,7 +158,8 @@ export interface ClientOptions {
|
|
|
143
158
|
* API Client for interfacing with the Papr API.
|
|
144
159
|
*/
|
|
145
160
|
export class Papr {
|
|
146
|
-
|
|
161
|
+
xAPIKey: string;
|
|
162
|
+
xSessionToken: string | null;
|
|
147
163
|
bearerToken: string | null;
|
|
148
164
|
|
|
149
165
|
baseURL: string;
|
|
@@ -161,7 +177,8 @@ export class Papr {
|
|
|
161
177
|
/**
|
|
162
178
|
* API Client for interfacing with the Papr API.
|
|
163
179
|
*
|
|
164
|
-
* @param {string | undefined} [opts.
|
|
180
|
+
* @param {string | undefined} [opts.xAPIKey=process.env['PAPR_MEMORY_API_KEY'] ?? undefined]
|
|
181
|
+
* @param {string | null | undefined} [opts.xSessionToken=process.env['PAPR_MEMORY_Session_Token'] ?? null]
|
|
165
182
|
* @param {string | null | undefined} [opts.bearerToken=process.env['PAPR_MEMORY_BEARER_TOKEN'] ?? null]
|
|
166
183
|
* @param {string} [opts.baseURL=process.env['PAPR_BASE_URL'] ?? https://memory.papr.ai] - Override the default base URL for the API.
|
|
167
184
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
@@ -173,18 +190,20 @@ export class Papr {
|
|
|
173
190
|
*/
|
|
174
191
|
constructor({
|
|
175
192
|
baseURL = readEnv('PAPR_BASE_URL'),
|
|
176
|
-
|
|
193
|
+
xAPIKey = readEnv('PAPR_MEMORY_API_KEY'),
|
|
194
|
+
xSessionToken = readEnv('PAPR_MEMORY_Session_Token') ?? null,
|
|
177
195
|
bearerToken = readEnv('PAPR_MEMORY_BEARER_TOKEN') ?? null,
|
|
178
196
|
...opts
|
|
179
197
|
}: ClientOptions = {}) {
|
|
180
|
-
if (
|
|
198
|
+
if (xAPIKey === undefined) {
|
|
181
199
|
throw new Errors.PaprError(
|
|
182
|
-
"The PAPR_MEMORY_API_KEY environment variable is missing or empty; either provide it, or instantiate the Papr client with an
|
|
200
|
+
"The PAPR_MEMORY_API_KEY environment variable is missing or empty; either provide it, or instantiate the Papr client with an xAPIKey option, like new Papr({ xAPIKey: 'My X API Key' }).",
|
|
183
201
|
);
|
|
184
202
|
}
|
|
185
203
|
|
|
186
204
|
const options: ClientOptions = {
|
|
187
|
-
|
|
205
|
+
xAPIKey,
|
|
206
|
+
xSessionToken,
|
|
188
207
|
bearerToken,
|
|
189
208
|
...opts,
|
|
190
209
|
baseURL: baseURL || `https://memory.papr.ai`,
|
|
@@ -207,7 +226,8 @@ export class Papr {
|
|
|
207
226
|
|
|
208
227
|
this._options = options;
|
|
209
228
|
|
|
210
|
-
this.
|
|
229
|
+
this.xAPIKey = xAPIKey;
|
|
230
|
+
this.xSessionToken = xSessionToken;
|
|
211
231
|
this.bearerToken = bearerToken;
|
|
212
232
|
}
|
|
213
233
|
|
|
@@ -224,7 +244,8 @@ export class Papr {
|
|
|
224
244
|
logLevel: this.logLevel,
|
|
225
245
|
fetch: this.fetch,
|
|
226
246
|
fetchOptions: this.fetchOptions,
|
|
227
|
-
|
|
247
|
+
xAPIKey: this.xAPIKey,
|
|
248
|
+
xSessionToken: this.xSessionToken,
|
|
228
249
|
bearerToken: this.bearerToken,
|
|
229
250
|
...options,
|
|
230
251
|
});
|
|
@@ -246,11 +267,7 @@ export class Papr {
|
|
|
246
267
|
}
|
|
247
268
|
|
|
248
269
|
protected authHeaders(opts: FinalRequestOptions): NullableHeaders | undefined {
|
|
249
|
-
return buildHeaders([this.
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
protected apiKeyHeaderAuth(opts: FinalRequestOptions): NullableHeaders | undefined {
|
|
253
|
-
return buildHeaders([{ 'X-Session-Token': this.apiKey }]);
|
|
270
|
+
return buildHeaders([this.bearerAuth(opts), this.xSessionTokenAuth(opts), this.xAPIKeyAuth(opts)]);
|
|
254
271
|
}
|
|
255
272
|
|
|
256
273
|
protected bearerAuth(opts: FinalRequestOptions): NullableHeaders | undefined {
|
|
@@ -260,6 +277,17 @@ export class Papr {
|
|
|
260
277
|
return buildHeaders([{ Authorization: `Bearer ${this.bearerToken}` }]);
|
|
261
278
|
}
|
|
262
279
|
|
|
280
|
+
protected xSessionTokenAuth(opts: FinalRequestOptions): NullableHeaders | undefined {
|
|
281
|
+
if (this.xSessionToken == null) {
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
return buildHeaders([{ 'X-Session-Token': this.xSessionToken }]);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
protected xAPIKeyAuth(opts: FinalRequestOptions): NullableHeaders | undefined {
|
|
288
|
+
return buildHeaders([{ 'X-API-Key': this.xAPIKey }]);
|
|
289
|
+
}
|
|
290
|
+
|
|
263
291
|
/**
|
|
264
292
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
265
293
|
*/
|
|
@@ -764,9 +792,11 @@ export class Papr {
|
|
|
764
792
|
|
|
765
793
|
user: API.User = new API.User(this);
|
|
766
794
|
memory: API.Memory = new API.Memory(this);
|
|
795
|
+
feedback: API.Feedback = new API.Feedback(this);
|
|
767
796
|
}
|
|
768
797
|
Papr.User = User;
|
|
769
798
|
Papr.Memory = Memory;
|
|
799
|
+
Papr.Feedback = Feedback;
|
|
770
800
|
export declare namespace Papr {
|
|
771
801
|
export type RequestOptions = Opts.RequestOptions;
|
|
772
802
|
|
|
@@ -782,7 +812,6 @@ export declare namespace Papr {
|
|
|
782
812
|
type UserListParams as UserListParams,
|
|
783
813
|
type UserDeleteParams as UserDeleteParams,
|
|
784
814
|
type UserCreateBatchParams as UserCreateBatchParams,
|
|
785
|
-
type UserGetParams as UserGetParams,
|
|
786
815
|
};
|
|
787
816
|
|
|
788
817
|
export {
|
|
@@ -803,4 +832,14 @@ export declare namespace Papr {
|
|
|
803
832
|
type MemoryAddBatchParams as MemoryAddBatchParams,
|
|
804
833
|
type MemorySearchParams as MemorySearchParams,
|
|
805
834
|
};
|
|
835
|
+
|
|
836
|
+
export {
|
|
837
|
+
Feedback as Feedback,
|
|
838
|
+
type BatchRequest as BatchRequest,
|
|
839
|
+
type BatchResponse as BatchResponse,
|
|
840
|
+
type FeedbackRequest as FeedbackRequest,
|
|
841
|
+
type FeedbackResponse as FeedbackResponse,
|
|
842
|
+
type FeedbackSubmitParams as FeedbackSubmitParams,
|
|
843
|
+
type FeedbackSubmitBatchParams as FeedbackSubmitBatchParams,
|
|
844
|
+
};
|
|
806
845
|
}
|
|
@@ -9,17 +9,70 @@ import { type HeadersLike } from './headers';
|
|
|
9
9
|
export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
|
|
10
10
|
|
|
11
11
|
export type RequestOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
|
|
14
|
+
*/
|
|
12
15
|
method?: HTTPMethod;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The URL path for the request.
|
|
19
|
+
*
|
|
20
|
+
* @example "/v1/foo"
|
|
21
|
+
*/
|
|
13
22
|
path?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Query parameters to include in the request URL.
|
|
26
|
+
*/
|
|
14
27
|
query?: object | undefined | null;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The request body. Can be a string, JSON object, FormData, or other supported types.
|
|
31
|
+
*/
|
|
15
32
|
body?: unknown;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
|
|
36
|
+
*/
|
|
16
37
|
headers?: HeadersLike;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
41
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
42
|
+
*
|
|
43
|
+
* @default 2
|
|
44
|
+
*/
|
|
17
45
|
maxRetries?: number;
|
|
46
|
+
|
|
18
47
|
stream?: boolean | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
51
|
+
* from the server before timing out a single request.
|
|
52
|
+
*
|
|
53
|
+
* @unit milliseconds
|
|
54
|
+
*/
|
|
19
55
|
timeout?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Additional `RequestInit` options to be passed to the underlying `fetch` call.
|
|
59
|
+
* These options will be merged with the client's default fetch options.
|
|
60
|
+
*/
|
|
20
61
|
fetchOptions?: MergedRequestInit;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* An AbortSignal that can be used to cancel the request.
|
|
65
|
+
*/
|
|
21
66
|
signal?: AbortSignal | undefined | null;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A unique key for this request to enable idempotency.
|
|
70
|
+
*/
|
|
22
71
|
idempotencyKey?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Override the default base URL for this specific request.
|
|
75
|
+
*/
|
|
23
76
|
defaultBaseURL?: string | undefined;
|
|
24
77
|
|
|
25
78
|
__binaryResponse?: boolean | undefined;
|
package/src/internal/uploads.ts
CHANGED
|
@@ -90,7 +90,7 @@ export const multipartFormRequestOptions = async (
|
|
|
90
90
|
return { ...opts, body: await createForm(opts.body, fetch) };
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
const supportsFormDataMap =
|
|
93
|
+
const supportsFormDataMap = /* @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>();
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* node-fetch doesn't support the global FormData object in recent node versions. Instead of sending
|
|
@@ -58,7 +58,7 @@ const noopLogger = {
|
|
|
58
58
|
debug: noop,
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
let cachedLoggers =
|
|
61
|
+
let cachedLoggers = /* @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
|
|
62
62
|
|
|
63
63
|
export function loggerFor(client: Papr): Logger {
|
|
64
64
|
const logger = client.logger;
|
|
@@ -106,8 +106,9 @@ export const formatRequestDetails = (details: {
|
|
|
106
106
|
([name, value]) => [
|
|
107
107
|
name,
|
|
108
108
|
(
|
|
109
|
-
name.toLowerCase() === 'x-session-token' ||
|
|
110
109
|
name.toLowerCase() === 'authorization' ||
|
|
110
|
+
name.toLowerCase() === 'x-session-token' ||
|
|
111
|
+
name.toLowerCase() === 'x-api-key' ||
|
|
111
112
|
name.toLowerCase() === 'cookie' ||
|
|
112
113
|
name.toLowerCase() === 'set-cookie'
|
|
113
114
|
) ?
|
|
@@ -12,25 +12,43 @@ export function encodeURIPath(str: string) {
|
|
|
12
12
|
return str.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
16
|
+
|
|
15
17
|
export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
16
18
|
function path(statics: readonly string[], ...params: readonly unknown[]): string {
|
|
17
19
|
// If there are no params, no processing is needed.
|
|
18
20
|
if (statics.length === 1) return statics[0]!;
|
|
19
21
|
|
|
20
22
|
let postPath = false;
|
|
23
|
+
const invalidSegments = [];
|
|
21
24
|
const path = statics.reduce((previousValue, currentValue, index) => {
|
|
22
25
|
if (/[?#]/.test(currentValue)) {
|
|
23
26
|
postPath = true;
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const value = params[index];
|
|
29
|
+
let encoded = (postPath ? encodeURIComponent : pathEncoder)('' + value);
|
|
30
|
+
if (
|
|
31
|
+
index !== params.length &&
|
|
32
|
+
(value == null ||
|
|
33
|
+
(typeof value === 'object' &&
|
|
34
|
+
// handle values from other realms
|
|
35
|
+
value.toString ===
|
|
36
|
+
Object.getPrototypeOf(Object.getPrototypeOf((value as any).hasOwnProperty ?? EMPTY) ?? EMPTY)
|
|
37
|
+
?.toString))
|
|
38
|
+
) {
|
|
39
|
+
encoded = value + '';
|
|
40
|
+
invalidSegments.push({
|
|
41
|
+
start: previousValue.length + currentValue.length,
|
|
42
|
+
length: encoded.length,
|
|
43
|
+
error: `Value of type ${Object.prototype.toString
|
|
44
|
+
.call(value)
|
|
45
|
+
.slice(8, -1)} is not a valid path parameter`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return previousValue + currentValue + (index === params.length ? '' : encoded);
|
|
30
49
|
}, '');
|
|
31
50
|
|
|
32
51
|
const pathOnly = path.split(/[?#]/, 1)[0]!;
|
|
33
|
-
const invalidSegments = [];
|
|
34
52
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
35
53
|
let match;
|
|
36
54
|
|
|
@@ -39,9 +57,12 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
39
57
|
invalidSegments.push({
|
|
40
58
|
start: match.index,
|
|
41
59
|
length: match[0].length,
|
|
60
|
+
error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
|
|
42
61
|
});
|
|
43
62
|
}
|
|
44
63
|
|
|
64
|
+
invalidSegments.sort((a, b) => a.start - b.start);
|
|
65
|
+
|
|
45
66
|
if (invalidSegments.length > 0) {
|
|
46
67
|
let lastEnd = 0;
|
|
47
68
|
const underline = invalidSegments.reduce((acc, segment) => {
|
|
@@ -51,7 +72,11 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
|
|
|
51
72
|
return acc + spaces + arrows;
|
|
52
73
|
}, '');
|
|
53
74
|
|
|
54
|
-
throw new PaprError(
|
|
75
|
+
throw new PaprError(
|
|
76
|
+
`Path parameters result in path with invalid segments:\n${invalidSegments
|
|
77
|
+
.map((e) => e.error)
|
|
78
|
+
.join('\n')}\n${path}\n${underline}`,
|
|
79
|
+
);
|
|
55
80
|
}
|
|
56
81
|
|
|
57
82
|
return path;
|