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 CHANGED
@@ -64,8 +64,20 @@ declare class SlackNamespace extends Namespace {
64
64
  availableChannels(connectionId: string, query?: Json): Promise<Json>;
65
65
  /** Channels currently selected for syncing. */
66
66
  channels(connectionId: string): Promise<Json>;
67
- /** Select channels for syncing. */
68
- addChannels(connectionId: string, channelIds: string[]): Promise<Json>;
67
+ /**
68
+ * Select channels for syncing.
69
+ *
70
+ * Accepts bare channel ids, which is the common case, or objects carrying the
71
+ * name and type across so the server does not have to look them up again:
72
+ *
73
+ * ```ts
74
+ * await client.connections.slack.addChannels("c1", ["C0123", "C0456"]);
75
+ * await client.connections.slack.addChannels("c1", [
76
+ * { id: "C0123", name: "support", is_private: false },
77
+ * ]);
78
+ * ```
79
+ */
80
+ addChannels(connectionId: string, channels: Array<string | Json>): Promise<Json>;
69
81
  /** Stop syncing one channel. */
70
82
  removeChannel(connectionId: string, channelId: string): Promise<Json>;
71
83
  /**
@@ -100,15 +112,38 @@ declare class S3Namespace extends Namespace {
100
112
  availablePrefixes(connectionId: string, query?: Json): Promise<Json>;
101
113
  /** Prefixes currently selected for syncing. */
102
114
  prefixes(connectionId: string): Promise<Json>;
103
- /** Select prefixes for syncing. */
104
- addPrefixes(connectionId: string, prefixes: string[]): Promise<Json>;
105
115
  /**
106
- * Stop syncing the given prefixes.
116
+ * Select prefixes for syncing.
117
+ *
118
+ * Accepts bare prefixes, or objects carrying `bucket` and `label`:
119
+ *
120
+ * ```ts
121
+ * await client.connections.s3.addPrefixes("c1", ["handbook/", "policies/"]);
122
+ * await client.connections.s3.addPrefixes("c1", [
123
+ * { prefix: "handbook/", label: "Handbook" },
124
+ * ]);
125
+ * ```
126
+ *
127
+ * An empty string means the bucket root. The bucket defaults to the one the
128
+ * connection's credentials were validated against, and the API rejects any
129
+ * other bucket rather than indexing one nobody proved access to.
130
+ */
131
+ addPrefixes(connectionId: string, prefixes: Array<string | Json>): Promise<Json>;
132
+ /**
133
+ * Revoke one prefix approval, optionally purging what it produced.
134
+ *
135
+ * The prefix travels as a query parameter, not in the body and not as a path
136
+ * segment: prefixes contain slashes, which a path segment cannot carry
137
+ * unambiguously, and this endpoint reads no body at all.
107
138
  *
108
- * The prefixes travel in the body rather than the path because they contain
109
- * slashes, which is why this DELETE carries one.
139
+ * Pass `purge: true` to also delete the memories already derived from the
140
+ * prefix. The default leaves them in place, so revoking an approval does not
141
+ * silently destroy knowledge.
110
142
  */
111
- removePrefixes(connectionId: string, prefixes: string[]): Promise<Json>;
143
+ removePrefix(connectionId: string, prefix?: string, options?: {
144
+ bucket?: string;
145
+ purge?: boolean;
146
+ }): Promise<Json>;
112
147
  /** Keys and patterns this connection will never sync. */
113
148
  exclusionPolicy(connectionId: string): Promise<Json>;
114
149
  /** Replace this connection's additions to the exclusion policy. */
@@ -134,8 +169,14 @@ declare class GranolaNamespace extends Namespace {
134
169
  identities(connectionId: string): Promise<Json>;
135
170
  /** Map a participant to a MemorySync end user. */
136
171
  linkIdentity(connectionId: string, body: Json): Promise<Json>;
137
- /** Move an existing mapping to a different end user. */
138
- relinkIdentity(connectionId: string, body: Json): Promise<Json>;
172
+ /**
173
+ * Re-run identity matching for this connection.
174
+ *
175
+ * Takes no arguments: the route reads no body and re-matches the whole roster.
176
+ * `body` is kept optional only so a forward-compatible field can be passed
177
+ * once the route grows one.
178
+ */
179
+ relinkIdentity(connectionId: string, body?: Json): Promise<Json>;
139
180
  /** Effective Granola settings for this connection. */
140
181
  settings(connectionId: string): Promise<Json>;
141
182
  /** Update Granola settings for this connection. */
@@ -171,6 +212,12 @@ declare class ConnectionsNamespace extends Namespace {
171
212
  /** One connection, including its status and last sync. */
172
213
  get(connectionId: string): Promise<Json>;
173
214
  /** Connect a provider that authenticates with an API key or bot token. */
215
+ /**
216
+ * Connect a provider that authenticates with an API key or bot token.
217
+ *
218
+ * The wire field is `provider_id`; the argument is named `provider` because
219
+ * that is what the rest of this namespace calls it.
220
+ */
174
221
  createWithApiKey(provider: string, apiKey: string, body?: Json): Promise<Json>;
175
222
  /** Connect a provider that needs a credential bundle, such as S3 keys. */
176
223
  createWithCredentials(provider: string, credentials: Json, body?: Json): Promise<Json>;
package/dist/index.d.ts CHANGED
@@ -64,8 +64,20 @@ declare class SlackNamespace extends Namespace {
64
64
  availableChannels(connectionId: string, query?: Json): Promise<Json>;
65
65
  /** Channels currently selected for syncing. */
66
66
  channels(connectionId: string): Promise<Json>;
67
- /** Select channels for syncing. */
68
- addChannels(connectionId: string, channelIds: string[]): Promise<Json>;
67
+ /**
68
+ * Select channels for syncing.
69
+ *
70
+ * Accepts bare channel ids, which is the common case, or objects carrying the
71
+ * name and type across so the server does not have to look them up again:
72
+ *
73
+ * ```ts
74
+ * await client.connections.slack.addChannels("c1", ["C0123", "C0456"]);
75
+ * await client.connections.slack.addChannels("c1", [
76
+ * { id: "C0123", name: "support", is_private: false },
77
+ * ]);
78
+ * ```
79
+ */
80
+ addChannels(connectionId: string, channels: Array<string | Json>): Promise<Json>;
69
81
  /** Stop syncing one channel. */
70
82
  removeChannel(connectionId: string, channelId: string): Promise<Json>;
71
83
  /**
@@ -100,15 +112,38 @@ declare class S3Namespace extends Namespace {
100
112
  availablePrefixes(connectionId: string, query?: Json): Promise<Json>;
101
113
  /** Prefixes currently selected for syncing. */
102
114
  prefixes(connectionId: string): Promise<Json>;
103
- /** Select prefixes for syncing. */
104
- addPrefixes(connectionId: string, prefixes: string[]): Promise<Json>;
105
115
  /**
106
- * Stop syncing the given prefixes.
116
+ * Select prefixes for syncing.
117
+ *
118
+ * Accepts bare prefixes, or objects carrying `bucket` and `label`:
119
+ *
120
+ * ```ts
121
+ * await client.connections.s3.addPrefixes("c1", ["handbook/", "policies/"]);
122
+ * await client.connections.s3.addPrefixes("c1", [
123
+ * { prefix: "handbook/", label: "Handbook" },
124
+ * ]);
125
+ * ```
126
+ *
127
+ * An empty string means the bucket root. The bucket defaults to the one the
128
+ * connection's credentials were validated against, and the API rejects any
129
+ * other bucket rather than indexing one nobody proved access to.
130
+ */
131
+ addPrefixes(connectionId: string, prefixes: Array<string | Json>): Promise<Json>;
132
+ /**
133
+ * Revoke one prefix approval, optionally purging what it produced.
134
+ *
135
+ * The prefix travels as a query parameter, not in the body and not as a path
136
+ * segment: prefixes contain slashes, which a path segment cannot carry
137
+ * unambiguously, and this endpoint reads no body at all.
107
138
  *
108
- * The prefixes travel in the body rather than the path because they contain
109
- * slashes, which is why this DELETE carries one.
139
+ * Pass `purge: true` to also delete the memories already derived from the
140
+ * prefix. The default leaves them in place, so revoking an approval does not
141
+ * silently destroy knowledge.
110
142
  */
111
- removePrefixes(connectionId: string, prefixes: string[]): Promise<Json>;
143
+ removePrefix(connectionId: string, prefix?: string, options?: {
144
+ bucket?: string;
145
+ purge?: boolean;
146
+ }): Promise<Json>;
112
147
  /** Keys and patterns this connection will never sync. */
113
148
  exclusionPolicy(connectionId: string): Promise<Json>;
114
149
  /** Replace this connection's additions to the exclusion policy. */
@@ -134,8 +169,14 @@ declare class GranolaNamespace extends Namespace {
134
169
  identities(connectionId: string): Promise<Json>;
135
170
  /** Map a participant to a MemorySync end user. */
136
171
  linkIdentity(connectionId: string, body: Json): Promise<Json>;
137
- /** Move an existing mapping to a different end user. */
138
- relinkIdentity(connectionId: string, body: Json): Promise<Json>;
172
+ /**
173
+ * Re-run identity matching for this connection.
174
+ *
175
+ * Takes no arguments: the route reads no body and re-matches the whole roster.
176
+ * `body` is kept optional only so a forward-compatible field can be passed
177
+ * once the route grows one.
178
+ */
179
+ relinkIdentity(connectionId: string, body?: Json): Promise<Json>;
139
180
  /** Effective Granola settings for this connection. */
140
181
  settings(connectionId: string): Promise<Json>;
141
182
  /** Update Granola settings for this connection. */
@@ -171,6 +212,12 @@ declare class ConnectionsNamespace extends Namespace {
171
212
  /** One connection, including its status and last sync. */
172
213
  get(connectionId: string): Promise<Json>;
173
214
  /** Connect a provider that authenticates with an API key or bot token. */
215
+ /**
216
+ * Connect a provider that authenticates with an API key or bot token.
217
+ *
218
+ * The wire field is `provider_id`; the argument is named `provider` because
219
+ * that is what the rest of this namespace calls it.
220
+ */
174
221
  createWithApiKey(provider: string, apiKey: string, body?: Json): Promise<Json>;
175
222
  /** Connect a provider that needs a credential bundle, such as S3 keys. */
176
223
  createWithCredentials(provider: string, credentials: Json, body?: Json): Promise<Json>;
package/dist/index.js CHANGED
@@ -90,6 +90,9 @@ var V1 = "/api/v1/integrations";
90
90
  function seg(value) {
91
91
  return encodeURIComponent(String(value));
92
92
  }
93
+ function asItem(value, key) {
94
+ return typeof value === "string" ? { [key]: value } : value;
95
+ }
93
96
  var Namespace = class {
94
97
  constructor(request) {
95
98
  this.req = request;
@@ -109,10 +112,22 @@ var SlackNamespace = class extends Namespace {
109
112
  channels(connectionId) {
110
113
  return this.req("GET", `${V2}/connections/${seg(connectionId)}/slack/channels`);
111
114
  }
112
- /** Select channels for syncing. */
113
- addChannels(connectionId, channelIds) {
115
+ /**
116
+ * Select channels for syncing.
117
+ *
118
+ * Accepts bare channel ids, which is the common case, or objects carrying the
119
+ * name and type across so the server does not have to look them up again:
120
+ *
121
+ * ```ts
122
+ * await client.connections.slack.addChannels("c1", ["C0123", "C0456"]);
123
+ * await client.connections.slack.addChannels("c1", [
124
+ * { id: "C0123", name: "support", is_private: false },
125
+ * ]);
126
+ * ```
127
+ */
128
+ addChannels(connectionId, channels) {
114
129
  return this.req("POST", `${V2}/connections/${seg(connectionId)}/slack/channels`, {
115
- body: { channel_ids: channelIds }
130
+ body: { channels: channels.map((c) => asItem(c, "id")) }
116
131
  });
117
132
  }
118
133
  /** Stop syncing one channel. */
@@ -179,22 +194,42 @@ var S3Namespace = class extends Namespace {
179
194
  prefixes(connectionId) {
180
195
  return this.req("GET", `${V2}/connections/${seg(connectionId)}/s3/prefixes`);
181
196
  }
182
- /** Select prefixes for syncing. */
197
+ /**
198
+ * Select prefixes for syncing.
199
+ *
200
+ * Accepts bare prefixes, or objects carrying `bucket` and `label`:
201
+ *
202
+ * ```ts
203
+ * await client.connections.s3.addPrefixes("c1", ["handbook/", "policies/"]);
204
+ * await client.connections.s3.addPrefixes("c1", [
205
+ * { prefix: "handbook/", label: "Handbook" },
206
+ * ]);
207
+ * ```
208
+ *
209
+ * An empty string means the bucket root. The bucket defaults to the one the
210
+ * connection's credentials were validated against, and the API rejects any
211
+ * other bucket rather than indexing one nobody proved access to.
212
+ */
183
213
  addPrefixes(connectionId, prefixes) {
184
214
  return this.req("POST", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, {
185
- body: { prefixes }
215
+ body: { prefixes: prefixes.map((p) => asItem(p, "prefix")) }
186
216
  });
187
217
  }
188
218
  /**
189
- * Stop syncing the given prefixes.
219
+ * Revoke one prefix approval, optionally purging what it produced.
190
220
  *
191
- * The prefixes travel in the body rather than the path because they contain
192
- * slashes, which is why this DELETE carries one.
221
+ * The prefix travels as a query parameter, not in the body and not as a path
222
+ * segment: prefixes contain slashes, which a path segment cannot carry
223
+ * unambiguously, and this endpoint reads no body at all.
224
+ *
225
+ * Pass `purge: true` to also delete the memories already derived from the
226
+ * prefix. The default leaves them in place, so revoking an approval does not
227
+ * silently destroy knowledge.
193
228
  */
194
- removePrefixes(connectionId, prefixes) {
195
- return this.req("DELETE", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, {
196
- body: { prefixes }
197
- });
229
+ removePrefix(connectionId, prefix = "", options = {}) {
230
+ const query = { prefix, purge: options.purge ?? false };
231
+ if (options.bucket !== void 0) query.bucket = options.bucket;
232
+ return this.req("DELETE", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, { query });
198
233
  }
199
234
  /** Keys and patterns this connection will never sync. */
200
235
  exclusionPolicy(connectionId) {
@@ -249,9 +284,18 @@ var GranolaNamespace = class extends Namespace {
249
284
  linkIdentity(connectionId, body) {
250
285
  return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/identities/link`, { body });
251
286
  }
252
- /** Move an existing mapping to a different end user. */
253
- relinkIdentity(connectionId, body) {
254
- return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/identities/relink`, { body });
287
+ /**
288
+ * Re-run identity matching for this connection.
289
+ *
290
+ * Takes no arguments: the route reads no body and re-matches the whole roster.
291
+ * `body` is kept optional only so a forward-compatible field can be passed
292
+ * once the route grows one.
293
+ */
294
+ relinkIdentity(connectionId, body = {}) {
295
+ const hasFields = Object.keys(body).length > 0;
296
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/identities/relink`, {
297
+ body: hasFields ? body : void 0
298
+ });
255
299
  }
256
300
  /** Effective Granola settings for this connection. */
257
301
  settings(connectionId) {
@@ -272,7 +316,9 @@ var ConnectionOAuthNamespace = class extends Namespace {
272
316
  * back — not your backend. Poll {@link status} to find out how it went.
273
317
  */
274
318
  initiate(provider, body = {}) {
275
- return this.req("POST", `${V2}/oauth/initiate`, { body: { provider, ...body } });
319
+ return this.req("POST", `${V2}/oauth/initiate`, {
320
+ body: { provider_id: provider, ...body }
321
+ });
276
322
  }
277
323
  /** Where an in-flight OAuth connection got to. */
278
324
  status(query) {
@@ -297,15 +343,21 @@ var ConnectionsNamespace = class extends Namespace {
297
343
  return this.req("GET", `${V2}/connections/${seg(connectionId)}`);
298
344
  }
299
345
  /** Connect a provider that authenticates with an API key or bot token. */
346
+ /**
347
+ * Connect a provider that authenticates with an API key or bot token.
348
+ *
349
+ * The wire field is `provider_id`; the argument is named `provider` because
350
+ * that is what the rest of this namespace calls it.
351
+ */
300
352
  createWithApiKey(provider, apiKey, body = {}) {
301
353
  return this.req("POST", `${V2}/connections/api-key`, {
302
- body: { provider, api_key: apiKey, ...body }
354
+ body: { provider_id: provider, api_key: apiKey, ...body }
303
355
  });
304
356
  }
305
357
  /** Connect a provider that needs a credential bundle, such as S3 keys. */
306
358
  createWithCredentials(provider, credentials, body = {}) {
307
359
  return this.req("POST", `${V2}/connections/credentials`, {
308
- body: { provider, credentials, ...body }
360
+ body: { provider_id: provider, credentials, ...body }
309
361
  });
310
362
  }
311
363
  /** Change a connection's name, schedule or settings. */
@@ -524,7 +576,7 @@ var IntegrationsNamespace = class extends Namespace {
524
576
  };
525
577
 
526
578
  // src/control-plane.ts
527
- var SDK_VERSION = "1.1.1";
579
+ var SDK_VERSION = "1.4.0";
528
580
  function safeJson(text) {
529
581
  try {
530
582
  return JSON.parse(text);
@@ -950,7 +1002,7 @@ var ControlPlaneClient = class {
950
1002
  };
951
1003
 
952
1004
  // src/index.ts
953
- var SDK_VERSION2 = "1.3.0";
1005
+ var SDK_VERSION2 = "1.4.0";
954
1006
  function camelToSnakeKey(key) {
955
1007
  return key.replace(/([A-Z])/g, "_$1").toLowerCase();
956
1008
  }