memorysync-sdk 1.3.0 → 1.4.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/dist/index.d.mts +57 -10
- package/dist/index.d.ts +57 -10
- package/dist/index.js +72 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +49 -49
package/dist/index.mjs
CHANGED
|
@@ -46,6 +46,9 @@ var V1 = "/api/v1/integrations";
|
|
|
46
46
|
function seg(value) {
|
|
47
47
|
return encodeURIComponent(String(value));
|
|
48
48
|
}
|
|
49
|
+
function asItem(value, key) {
|
|
50
|
+
return typeof value === "string" ? { [key]: value } : value;
|
|
51
|
+
}
|
|
49
52
|
var Namespace = class {
|
|
50
53
|
constructor(request) {
|
|
51
54
|
this.req = request;
|
|
@@ -65,10 +68,22 @@ var SlackNamespace = class extends Namespace {
|
|
|
65
68
|
channels(connectionId) {
|
|
66
69
|
return this.req("GET", `${V2}/connections/${seg(connectionId)}/slack/channels`);
|
|
67
70
|
}
|
|
68
|
-
/**
|
|
69
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Select channels for syncing.
|
|
73
|
+
*
|
|
74
|
+
* Accepts bare channel ids, which is the common case, or objects carrying the
|
|
75
|
+
* name and type across so the server does not have to look them up again:
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* await client.connections.slack.addChannels("c1", ["C0123", "C0456"]);
|
|
79
|
+
* await client.connections.slack.addChannels("c1", [
|
|
80
|
+
* { id: "C0123", name: "support", is_private: false },
|
|
81
|
+
* ]);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
addChannels(connectionId, channels) {
|
|
70
85
|
return this.req("POST", `${V2}/connections/${seg(connectionId)}/slack/channels`, {
|
|
71
|
-
body: {
|
|
86
|
+
body: { channels: channels.map((c) => asItem(c, "id")) }
|
|
72
87
|
});
|
|
73
88
|
}
|
|
74
89
|
/** Stop syncing one channel. */
|
|
@@ -135,22 +150,42 @@ var S3Namespace = class extends Namespace {
|
|
|
135
150
|
prefixes(connectionId) {
|
|
136
151
|
return this.req("GET", `${V2}/connections/${seg(connectionId)}/s3/prefixes`);
|
|
137
152
|
}
|
|
138
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Select prefixes for syncing.
|
|
155
|
+
*
|
|
156
|
+
* Accepts bare prefixes, or objects carrying `bucket` and `label`:
|
|
157
|
+
*
|
|
158
|
+
* ```ts
|
|
159
|
+
* await client.connections.s3.addPrefixes("c1", ["handbook/", "policies/"]);
|
|
160
|
+
* await client.connections.s3.addPrefixes("c1", [
|
|
161
|
+
* { prefix: "handbook/", label: "Handbook" },
|
|
162
|
+
* ]);
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* An empty string means the bucket root. The bucket defaults to the one the
|
|
166
|
+
* connection's credentials were validated against, and the API rejects any
|
|
167
|
+
* other bucket rather than indexing one nobody proved access to.
|
|
168
|
+
*/
|
|
139
169
|
addPrefixes(connectionId, prefixes) {
|
|
140
170
|
return this.req("POST", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, {
|
|
141
|
-
body: { prefixes }
|
|
171
|
+
body: { prefixes: prefixes.map((p) => asItem(p, "prefix")) }
|
|
142
172
|
});
|
|
143
173
|
}
|
|
144
174
|
/**
|
|
145
|
-
*
|
|
175
|
+
* Revoke one prefix approval, optionally purging what it produced.
|
|
146
176
|
*
|
|
147
|
-
* The
|
|
148
|
-
* slashes, which
|
|
177
|
+
* The prefix travels as a query parameter, not in the body and not as a path
|
|
178
|
+
* segment: prefixes contain slashes, which a path segment cannot carry
|
|
179
|
+
* unambiguously, and this endpoint reads no body at all.
|
|
180
|
+
*
|
|
181
|
+
* Pass `purge: true` to also delete the memories already derived from the
|
|
182
|
+
* prefix. The default leaves them in place, so revoking an approval does not
|
|
183
|
+
* silently destroy knowledge.
|
|
149
184
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
185
|
+
removePrefix(connectionId, prefix = "", options = {}) {
|
|
186
|
+
const query = { prefix, purge: options.purge ?? false };
|
|
187
|
+
if (options.bucket !== void 0) query.bucket = options.bucket;
|
|
188
|
+
return this.req("DELETE", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, { query });
|
|
154
189
|
}
|
|
155
190
|
/** Keys and patterns this connection will never sync. */
|
|
156
191
|
exclusionPolicy(connectionId) {
|
|
@@ -205,9 +240,18 @@ var GranolaNamespace = class extends Namespace {
|
|
|
205
240
|
linkIdentity(connectionId, body) {
|
|
206
241
|
return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/identities/link`, { body });
|
|
207
242
|
}
|
|
208
|
-
/**
|
|
209
|
-
|
|
210
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Re-run identity matching for this connection.
|
|
245
|
+
*
|
|
246
|
+
* Takes no arguments: the route reads no body and re-matches the whole roster.
|
|
247
|
+
* `body` is kept optional only so a forward-compatible field can be passed
|
|
248
|
+
* once the route grows one.
|
|
249
|
+
*/
|
|
250
|
+
relinkIdentity(connectionId, body = {}) {
|
|
251
|
+
const hasFields = Object.keys(body).length > 0;
|
|
252
|
+
return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/identities/relink`, {
|
|
253
|
+
body: hasFields ? body : void 0
|
|
254
|
+
});
|
|
211
255
|
}
|
|
212
256
|
/** Effective Granola settings for this connection. */
|
|
213
257
|
settings(connectionId) {
|
|
@@ -228,7 +272,9 @@ var ConnectionOAuthNamespace = class extends Namespace {
|
|
|
228
272
|
* back — not your backend. Poll {@link status} to find out how it went.
|
|
229
273
|
*/
|
|
230
274
|
initiate(provider, body = {}) {
|
|
231
|
-
return this.req("POST", `${V2}/oauth/initiate`, {
|
|
275
|
+
return this.req("POST", `${V2}/oauth/initiate`, {
|
|
276
|
+
body: { provider_id: provider, ...body }
|
|
277
|
+
});
|
|
232
278
|
}
|
|
233
279
|
/** Where an in-flight OAuth connection got to. */
|
|
234
280
|
status(query) {
|
|
@@ -253,15 +299,21 @@ var ConnectionsNamespace = class extends Namespace {
|
|
|
253
299
|
return this.req("GET", `${V2}/connections/${seg(connectionId)}`);
|
|
254
300
|
}
|
|
255
301
|
/** Connect a provider that authenticates with an API key or bot token. */
|
|
302
|
+
/**
|
|
303
|
+
* Connect a provider that authenticates with an API key or bot token.
|
|
304
|
+
*
|
|
305
|
+
* The wire field is `provider_id`; the argument is named `provider` because
|
|
306
|
+
* that is what the rest of this namespace calls it.
|
|
307
|
+
*/
|
|
256
308
|
createWithApiKey(provider, apiKey, body = {}) {
|
|
257
309
|
return this.req("POST", `${V2}/connections/api-key`, {
|
|
258
|
-
body: { provider, api_key: apiKey, ...body }
|
|
310
|
+
body: { provider_id: provider, api_key: apiKey, ...body }
|
|
259
311
|
});
|
|
260
312
|
}
|
|
261
313
|
/** Connect a provider that needs a credential bundle, such as S3 keys. */
|
|
262
314
|
createWithCredentials(provider, credentials, body = {}) {
|
|
263
315
|
return this.req("POST", `${V2}/connections/credentials`, {
|
|
264
|
-
body: { provider, credentials, ...body }
|
|
316
|
+
body: { provider_id: provider, credentials, ...body }
|
|
265
317
|
});
|
|
266
318
|
}
|
|
267
319
|
/** Change a connection's name, schedule or settings. */
|
|
@@ -480,7 +532,7 @@ var IntegrationsNamespace = class extends Namespace {
|
|
|
480
532
|
};
|
|
481
533
|
|
|
482
534
|
// src/control-plane.ts
|
|
483
|
-
var SDK_VERSION = "1.
|
|
535
|
+
var SDK_VERSION = "1.4.0";
|
|
484
536
|
function safeJson(text) {
|
|
485
537
|
try {
|
|
486
538
|
return JSON.parse(text);
|
|
@@ -906,7 +958,7 @@ var ControlPlaneClient = class {
|
|
|
906
958
|
};
|
|
907
959
|
|
|
908
960
|
// src/index.ts
|
|
909
|
-
var SDK_VERSION2 = "1.
|
|
961
|
+
var SDK_VERSION2 = "1.4.0";
|
|
910
962
|
function camelToSnakeKey(key) {
|
|
911
963
|
return key.replace(/([A-Z])/g, "_$1").toLowerCase();
|
|
912
964
|
}
|