memorysync-sdk 1.2.0 → 1.3.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.js CHANGED
@@ -21,13 +21,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AuthError: () => AuthError,
24
+ ConnectionOAuthNamespace: () => ConnectionOAuthNamespace,
25
+ ConnectionsNamespace: () => ConnectionsNamespace,
24
26
  ControlPlaneClient: () => ControlPlaneClient,
27
+ GoogleDriveNamespace: () => GoogleDriveNamespace,
28
+ GranolaNamespace: () => GranolaNamespace,
29
+ IntegrationsNamespace: () => IntegrationsNamespace,
25
30
  MemorySyncClient: () => MemorySyncClient,
26
31
  MemorySyncError: () => MemorySyncError,
27
32
  NotFoundError: () => NotFoundError,
33
+ ObjectsNamespace: () => ObjectsNamespace,
34
+ ProvidersNamespace: () => ProvidersNamespace,
28
35
  RateLimitError: () => RateLimitError,
36
+ S3Namespace: () => S3Namespace,
29
37
  ServerError: () => ServerError,
30
- ValidationError: () => ValidationError
38
+ SlackNamespace: () => SlackNamespace,
39
+ SyncJobsNamespace: () => SyncJobsNamespace,
40
+ ValidationError: () => ValidationError,
41
+ WebCrawlerNamespace: () => WebCrawlerNamespace
31
42
  });
32
43
  module.exports = __toCommonJS(index_exports);
33
44
 
@@ -73,6 +84,445 @@ var ServerError = class extends MemorySyncError {
73
84
  }
74
85
  };
75
86
 
87
+ // src/connections.ts
88
+ var V2 = "/api/v2/integrations";
89
+ var V1 = "/api/v1/integrations";
90
+ function seg(value) {
91
+ return encodeURIComponent(String(value));
92
+ }
93
+ var Namespace = class {
94
+ constructor(request) {
95
+ this.req = request;
96
+ }
97
+ };
98
+ var SlackNamespace = class extends Namespace {
99
+ /**
100
+ * Channels the app can see and could be added.
101
+ *
102
+ * Private channels appear only where the deployment allows them *and* a human
103
+ * has invited the app, so this never widens what someone already granted.
104
+ */
105
+ availableChannels(connectionId, query) {
106
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/slack/available-channels`, { query });
107
+ }
108
+ /** Channels currently selected for syncing. */
109
+ channels(connectionId) {
110
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/slack/channels`);
111
+ }
112
+ /** Select channels for syncing. */
113
+ addChannels(connectionId, channelIds) {
114
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/slack/channels`, {
115
+ body: { channel_ids: channelIds }
116
+ });
117
+ }
118
+ /** Stop syncing one channel. */
119
+ removeChannel(connectionId, channelId) {
120
+ return this.req(
121
+ "DELETE",
122
+ `${V2}/connections/${seg(connectionId)}/slack/channels/${seg(channelId)}`
123
+ );
124
+ }
125
+ /**
126
+ * Channels this connection will never sync.
127
+ *
128
+ * The deployment-wide floor cannot be removed here; a tenant may only add to it.
129
+ */
130
+ exclusionPolicy(connectionId) {
131
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/slack/exclusion-policy`);
132
+ }
133
+ /** Replace this connection's additions to the exclusion policy. */
134
+ setExclusionPolicy(connectionId, policy) {
135
+ return this.req("PUT", `${V2}/connections/${seg(connectionId)}/slack/exclusion-policy`, {
136
+ body: policy
137
+ });
138
+ }
139
+ /** Slack users seen on this connection and who they map to. */
140
+ identities(connectionId) {
141
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/slack/identities`);
142
+ }
143
+ /** Map a Slack user to a MemorySync end user. */
144
+ linkIdentity(connectionId, body) {
145
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/slack/identities/link`, { body });
146
+ }
147
+ /** Re-read the Slack member list and refresh the identity table. */
148
+ syncIdentities(connectionId) {
149
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/slack/identities/sync`);
150
+ }
151
+ };
152
+ var GoogleDriveNamespace = class extends Namespace {
153
+ /** Config for rendering Google's own file picker in your UI. */
154
+ pickerConfig(connectionId) {
155
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/gdrive/picker-config`);
156
+ }
157
+ /** Files and folders selected for syncing. */
158
+ resources(connectionId, query) {
159
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/gdrive/resources`, { query });
160
+ }
161
+ /** Select files or folders for syncing. */
162
+ addResources(connectionId, body) {
163
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/gdrive/resources`, { body });
164
+ }
165
+ /** Stop syncing one file or folder. */
166
+ removeResource(connectionId, resourceId) {
167
+ return this.req(
168
+ "DELETE",
169
+ `${V2}/connections/${seg(connectionId)}/gdrive/resources/${seg(resourceId)}`
170
+ );
171
+ }
172
+ };
173
+ var S3Namespace = class extends Namespace {
174
+ /** Prefixes visible in the bucket that could be added. */
175
+ availablePrefixes(connectionId, query) {
176
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/s3/available-prefixes`, { query });
177
+ }
178
+ /** Prefixes currently selected for syncing. */
179
+ prefixes(connectionId) {
180
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/s3/prefixes`);
181
+ }
182
+ /** Select prefixes for syncing. */
183
+ addPrefixes(connectionId, prefixes) {
184
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, {
185
+ body: { prefixes }
186
+ });
187
+ }
188
+ /**
189
+ * Stop syncing the given prefixes.
190
+ *
191
+ * The prefixes travel in the body rather than the path because they contain
192
+ * slashes, which is why this DELETE carries one.
193
+ */
194
+ removePrefixes(connectionId, prefixes) {
195
+ return this.req("DELETE", `${V2}/connections/${seg(connectionId)}/s3/prefixes`, {
196
+ body: { prefixes }
197
+ });
198
+ }
199
+ /** Keys and patterns this connection will never sync. */
200
+ exclusionPolicy(connectionId) {
201
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/s3/exclusion-policy`);
202
+ }
203
+ /** Replace this connection's additions to the exclusion policy. */
204
+ setExclusionPolicy(connectionId, policy) {
205
+ return this.req("PUT", `${V2}/connections/${seg(connectionId)}/s3/exclusion-policy`, {
206
+ body: policy
207
+ });
208
+ }
209
+ /** Effective S3 settings, including the per-object size ceiling. */
210
+ settings(connectionId) {
211
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/s3/settings`);
212
+ }
213
+ };
214
+ var GranolaNamespace = class extends Namespace {
215
+ /** Folders that could be added. */
216
+ availableFolders(connectionId, query) {
217
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/granola/available-folders`, { query });
218
+ }
219
+ /** Folders currently selected for syncing. */
220
+ folders(connectionId) {
221
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/granola/folders`);
222
+ }
223
+ /** Select folders for syncing. */
224
+ addFolders(connectionId, body) {
225
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/folders`, { body });
226
+ }
227
+ /** Stop syncing one folder. */
228
+ removeFolder(connectionId, folderId) {
229
+ return this.req(
230
+ "DELETE",
231
+ `${V2}/connections/${seg(connectionId)}/granola/folders/${seg(folderId)}`
232
+ );
233
+ }
234
+ /** Folders and meetings this connection will never sync. */
235
+ exclusionPolicy(connectionId) {
236
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/granola/exclusion-policy`);
237
+ }
238
+ /** Replace this connection's additions to the exclusion policy. */
239
+ setExclusionPolicy(connectionId, policy) {
240
+ return this.req("PUT", `${V2}/connections/${seg(connectionId)}/granola/exclusion-policy`, {
241
+ body: policy
242
+ });
243
+ }
244
+ /** Meeting participants seen on this connection and who they map to. */
245
+ identities(connectionId) {
246
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/granola/identities`);
247
+ }
248
+ /** Map a participant to a MemorySync end user. */
249
+ linkIdentity(connectionId, body) {
250
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/granola/identities/link`, { body });
251
+ }
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 });
255
+ }
256
+ /** Effective Granola settings for this connection. */
257
+ settings(connectionId) {
258
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/granola/settings`);
259
+ }
260
+ /** Update Granola settings for this connection. */
261
+ setSettings(connectionId, settings) {
262
+ return this.req("PUT", `${V2}/connections/${seg(connectionId)}/granola/settings`, {
263
+ body: settings
264
+ });
265
+ }
266
+ };
267
+ var ConnectionOAuthNamespace = class extends Namespace {
268
+ /**
269
+ * Begin an OAuth connection and get the URL to send the user to.
270
+ *
271
+ * The user completes consent in a browser and the provider calls the platform
272
+ * back — not your backend. Poll {@link status} to find out how it went.
273
+ */
274
+ initiate(provider, body = {}) {
275
+ return this.req("POST", `${V2}/oauth/initiate`, { body: { provider, ...body } });
276
+ }
277
+ /** Where an in-flight OAuth connection got to. */
278
+ status(query) {
279
+ return this.req("GET", `${V2}/oauth/status`, { query });
280
+ }
281
+ };
282
+ var ConnectionsNamespace = class extends Namespace {
283
+ constructor(request) {
284
+ super(request);
285
+ this.slack = new SlackNamespace(request);
286
+ this.gdrive = new GoogleDriveNamespace(request);
287
+ this.s3 = new S3Namespace(request);
288
+ this.granola = new GranolaNamespace(request);
289
+ this.oauth = new ConnectionOAuthNamespace(request);
290
+ }
291
+ /** Every connection in this organization. */
292
+ list(query) {
293
+ return this.req("GET", `${V2}/connections`, { query });
294
+ }
295
+ /** One connection, including its status and last sync. */
296
+ get(connectionId) {
297
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}`);
298
+ }
299
+ /** Connect a provider that authenticates with an API key or bot token. */
300
+ createWithApiKey(provider, apiKey, body = {}) {
301
+ return this.req("POST", `${V2}/connections/api-key`, {
302
+ body: { provider, api_key: apiKey, ...body }
303
+ });
304
+ }
305
+ /** Connect a provider that needs a credential bundle, such as S3 keys. */
306
+ createWithCredentials(provider, credentials, body = {}) {
307
+ return this.req("POST", `${V2}/connections/credentials`, {
308
+ body: { provider, credentials, ...body }
309
+ });
310
+ }
311
+ /** Change a connection's name, schedule or settings. */
312
+ update(connectionId, body) {
313
+ return this.req("PATCH", `${V2}/connections/${seg(connectionId)}`, { body });
314
+ }
315
+ /**
316
+ * Remove a connection.
317
+ *
318
+ * Stops future syncing. Memories already extracted are left in place — use
319
+ * {@link purge} for those, so disconnecting never silently deletes knowledge
320
+ * someone still depends on.
321
+ */
322
+ delete(connectionId) {
323
+ return this.req("DELETE", `${V2}/connections/${seg(connectionId)}`);
324
+ }
325
+ /** Re-authorise a connection whose credentials expired or were revoked. */
326
+ reconnect(connectionId, body = {}) {
327
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/reconnect`, { body });
328
+ }
329
+ /**
330
+ * Delete the memories this connection produced.
331
+ *
332
+ * Separate from {@link delete} on purpose: removing a connection and removing
333
+ * what it taught you are different decisions.
334
+ */
335
+ purge(connectionId, body = {}) {
336
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/purge`, { body });
337
+ }
338
+ /** Current and recent sync state for a connection. */
339
+ syncStatus(connectionId) {
340
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/sync`);
341
+ }
342
+ /** Start a sync now instead of waiting for the schedule. */
343
+ triggerSync(connectionId, body = {}) {
344
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/sync`, { body });
345
+ }
346
+ /** Objects a connection has ingested — files, messages, meetings. */
347
+ objects(connectionId, query) {
348
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/objects`, { query });
349
+ }
350
+ /** Object listing with richer filtering and paging than {@link objects}. */
351
+ objectsV2(connectionId, query) {
352
+ return this.req("GET", `${V2}/connections/${seg(connectionId)}/objects/v2`, { query });
353
+ }
354
+ /** Apply one action to many objects — pause, resume, re-extract. */
355
+ bulkObjectAction(connectionId, body) {
356
+ return this.req("POST", `${V2}/connections/${seg(connectionId)}/objects/bulk`, { body });
357
+ }
358
+ /** Connector totals: connections, objects synced, memories produced. */
359
+ stats(query) {
360
+ return this.req("GET", `${V2}/stats`, { query });
361
+ }
362
+ /** Audit trail of connector activity. */
363
+ auditLogs(query) {
364
+ return this.req("GET", `${V2}/audit-logs`, { query });
365
+ }
366
+ };
367
+ var ObjectsNamespace = class extends Namespace {
368
+ /** Metadata and sync state for one object. */
369
+ get(objectId) {
370
+ return this.req("GET", `${V2}/objects/${seg(objectId)}`);
371
+ }
372
+ /** What extraction made of this object. */
373
+ analysis(objectId) {
374
+ return this.req("GET", `${V2}/objects/${seg(objectId)}/analysis`);
375
+ }
376
+ /** Every action taken on this object. */
377
+ audit(objectId, query) {
378
+ return this.req("GET", `${V2}/objects/${seg(objectId)}/audit`, { query });
379
+ }
380
+ /** Versions of this object seen across syncs. */
381
+ history(objectId, query) {
382
+ return this.req("GET", `${V2}/objects/${seg(objectId)}/history`, { query });
383
+ }
384
+ /** Which memories this object produced, and whether extraction finished. */
385
+ memoryStatus(objectId) {
386
+ return this.req("GET", `${V2}/objects/${seg(objectId)}/memory-status`);
387
+ }
388
+ /** Row and column statistics for spreadsheet-shaped objects. */
389
+ structuredStats(objectId) {
390
+ return this.req("GET", `${V2}/objects/${seg(objectId)}/structured-stats`);
391
+ }
392
+ /** Score this object for extraction worthiness without extracting. */
393
+ evaluate(objectId, body = {}) {
394
+ return this.req("POST", `${V2}/objects/${seg(objectId)}/evaluate`, { body });
395
+ }
396
+ /** Stop re-syncing this object, leaving its memories in place. */
397
+ pause(objectId) {
398
+ return this.req("POST", `${V2}/objects/${seg(objectId)}/pause`);
399
+ }
400
+ /** Resume syncing a paused object. */
401
+ resume(objectId) {
402
+ return this.req("POST", `${V2}/objects/${seg(objectId)}/resume`);
403
+ }
404
+ /**
405
+ * Run extraction again over content already fetched.
406
+ *
407
+ * Counts against the plan's add allowance, exactly like the first extraction,
408
+ * because it creates memories the same way.
409
+ */
410
+ reextract(objectId, body = {}) {
411
+ return this.req("POST", `${V2}/objects/${seg(objectId)}/reextract`, { body });
412
+ }
413
+ /** Fetch this object from the provider again, then extract. */
414
+ resync(objectId, body = {}) {
415
+ return this.req("POST", `${V2}/objects/${seg(objectId)}/resync`, { body });
416
+ }
417
+ /** Remove the memories this object produced, keeping the object record. */
418
+ deleteMemories(objectId, query) {
419
+ return this.req("DELETE", `${V2}/objects/${seg(objectId)}/memories`, { query });
420
+ }
421
+ };
422
+ var ProvidersNamespace = class extends Namespace {
423
+ /** Every available provider and what it needs to connect. */
424
+ list(query) {
425
+ return this.req("GET", `${V2}/providers`, { query });
426
+ }
427
+ /** One provider's capabilities, scopes and settings schema. */
428
+ get(providerId) {
429
+ return this.req("GET", `${V2}/providers/${seg(providerId)}`);
430
+ }
431
+ };
432
+ var SyncJobsNamespace = class extends Namespace {
433
+ /** Progress and outcome of one sync run. */
434
+ get(jobId) {
435
+ return this.req("GET", `${V2}/sync-jobs/${seg(jobId)}`);
436
+ }
437
+ /** Stop a running sync. Objects already ingested are kept. */
438
+ cancel(jobId, body = {}) {
439
+ return this.req("POST", `${V2}/sync-jobs/${seg(jobId)}/cancel`, { body });
440
+ }
441
+ };
442
+ var WebCrawlerNamespace = class extends Namespace {
443
+ /** Check a URL is reachable and crawlable before committing to a job. */
444
+ validate(url, body = {}) {
445
+ return this.req("POST", `${V1}/web-crawler/validate`, { body: { url, ...body } });
446
+ }
447
+ /**
448
+ * Start a crawl. Returns a job to poll.
449
+ *
450
+ * Crawling only fetches and stores page content. Nothing becomes a memory until
451
+ * you call {@link importJob}, so a large crawl cannot quietly consume your add
452
+ * allowance.
453
+ */
454
+ crawl(url, body = {}) {
455
+ return this.req("POST", `${V1}/web-crawler/crawl`, { body: { url, ...body } });
456
+ }
457
+ /** Crawl jobs for this organization. */
458
+ jobs(query) {
459
+ return this.req("GET", `${V1}/web-crawler/jobs`, { query });
460
+ }
461
+ /** One crawl job's status and progress. */
462
+ job(jobId) {
463
+ return this.req("GET", `${V1}/web-crawler/jobs/${seg(jobId)}`);
464
+ }
465
+ /** Stop a running crawl. Pages already fetched are kept. */
466
+ cancelJob(jobId) {
467
+ return this.req("POST", `${V1}/web-crawler/jobs/${seg(jobId)}/cancel`);
468
+ }
469
+ /** Delete a crawl job and its fetched pages. */
470
+ deleteJob(jobId) {
471
+ return this.req("DELETE", `${V1}/web-crawler/jobs/${seg(jobId)}`);
472
+ }
473
+ /** Pages a crawl fetched, before any import. */
474
+ jobContent(jobId, query) {
475
+ return this.req("GET", `${V1}/web-crawler/jobs/${seg(jobId)}/content`, { query });
476
+ }
477
+ /** Page counts, byte totals and error breakdown for a crawl. */
478
+ jobStatistics(jobId) {
479
+ return this.req("GET", `${V1}/web-crawler/jobs/${seg(jobId)}/statistics`);
480
+ }
481
+ /**
482
+ * Turn a completed crawl's pages into memories.
483
+ *
484
+ * This is the step that creates memories, so this is the step that is billed —
485
+ * one unit per memory created, like every other ingestion path.
486
+ */
487
+ importJob(jobId, body = {}) {
488
+ return this.req("POST", `${V1}/web-crawler/jobs/${seg(jobId)}/import`, { body });
489
+ }
490
+ /** Crawls running right now. */
491
+ active() {
492
+ return this.req("GET", `${V1}/web-crawler/active`);
493
+ }
494
+ /** Crawler limits in force: depth, page ceiling, rate, timeouts. */
495
+ config() {
496
+ return this.req("GET", `${V1}/web-crawler/config`);
497
+ }
498
+ };
499
+ var IntegrationsNamespace = class extends Namespace {
500
+ constructor(request) {
501
+ super(request);
502
+ this.webCrawler = new WebCrawlerNamespace(request);
503
+ }
504
+ /** Every integration this deployment offers, for building a picker UI. */
505
+ catalog(query) {
506
+ return this.req("GET", `${V1}/catalog`, { query });
507
+ }
508
+ /** Integrations currently connected. Older view of `connections.list()`. */
509
+ connected(query) {
510
+ return this.req("GET", `${V1}/connected`, { query });
511
+ }
512
+ /** Legacy integration counters. Prefer `connections.stats()`. */
513
+ stats(query) {
514
+ return this.req("GET", `${V1}/stats`, { query });
515
+ }
516
+ /** Update a legacy integration record. */
517
+ update(integrationId, body) {
518
+ return this.req("PATCH", `${V1}/${seg(integrationId)}`, { body });
519
+ }
520
+ /** Delete a legacy integration record. */
521
+ delete(integrationId) {
522
+ return this.req("DELETE", `${V1}/${seg(integrationId)}`);
523
+ }
524
+ };
525
+
76
526
  // src/control-plane.ts
77
527
  var SDK_VERSION = "1.1.1";
78
528
  function safeJson(text) {
@@ -500,7 +950,7 @@ var ControlPlaneClient = class {
500
950
  };
501
951
 
502
952
  // src/index.ts
503
- var SDK_VERSION2 = "1.2.0";
953
+ var SDK_VERSION2 = "1.3.0";
504
954
  function camelToSnakeKey(key) {
505
955
  return key.replace(/([A-Z])/g, "_$1").toLowerCase();
506
956
  }
@@ -590,6 +1040,12 @@ var MemorySyncClient = class {
590
1040
  throw new Error("No fetch implementation available. Pass `fetch` in config or use Node 18+.");
591
1041
  }
592
1042
  this.fetchImpl = f;
1043
+ const request = (method, path, options) => this.request(method, path, options ?? {});
1044
+ this.connections = new ConnectionsNamespace(request);
1045
+ this.objects = new ObjectsNamespace(request);
1046
+ this.providers = new ProvidersNamespace(request);
1047
+ this.syncJobs = new SyncJobsNamespace(request);
1048
+ this.integrations = new IntegrationsNamespace(request);
593
1049
  }
594
1050
  headers(extra = {}) {
595
1051
  const h = {
@@ -1194,12 +1650,23 @@ function toOntology(raw) {
1194
1650
  // Annotate the CommonJS export names for ESM import in node:
1195
1651
  0 && (module.exports = {
1196
1652
  AuthError,
1653
+ ConnectionOAuthNamespace,
1654
+ ConnectionsNamespace,
1197
1655
  ControlPlaneClient,
1656
+ GoogleDriveNamespace,
1657
+ GranolaNamespace,
1658
+ IntegrationsNamespace,
1198
1659
  MemorySyncClient,
1199
1660
  MemorySyncError,
1200
1661
  NotFoundError,
1662
+ ObjectsNamespace,
1663
+ ProvidersNamespace,
1201
1664
  RateLimitError,
1665
+ S3Namespace,
1202
1666
  ServerError,
1203
- ValidationError
1667
+ SlackNamespace,
1668
+ SyncJobsNamespace,
1669
+ ValidationError,
1670
+ WebCrawlerNamespace
1204
1671
  });
1205
1672
  //# sourceMappingURL=index.js.map