mindcache 3.1.0 → 3.2.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.
@@ -102,6 +102,8 @@ interface MindCacheCloudOptions {
102
102
  projectId?: string;
103
103
  /** API endpoint to fetch WS token (recommended for browser) */
104
104
  tokenEndpoint?: string;
105
+ /** Function to fetch token dynamically (overrides tokenEndpoint) */
106
+ tokenProvider?: () => Promise<string>;
105
107
  /** Direct API key (server-side only, never expose in browser!) */
106
108
  apiKey?: string;
107
109
  /** WebSocket base URL (defaults to production) */
@@ -218,6 +220,11 @@ declare class MindCache {
218
220
  getAll(): STM;
219
221
  get_value(key: string, _processingStack?: Set<string>): any;
220
222
  get_attributes(key: string): KeyAttributes | undefined;
223
+ /**
224
+ * Update only the attributes of a key without modifying the value.
225
+ * Useful for updating tags, permissions etc. on document type keys.
226
+ */
227
+ set_attributes(key: string, attributes: Partial<KeyAttributes>): void;
221
228
  set_value(key: string, value: any, attributes?: Partial<KeyAttributes>): void;
222
229
  delete_key(key: string): void;
223
230
  clear(): void;
@@ -102,6 +102,8 @@ interface MindCacheCloudOptions {
102
102
  projectId?: string;
103
103
  /** API endpoint to fetch WS token (recommended for browser) */
104
104
  tokenEndpoint?: string;
105
+ /** Function to fetch token dynamically (overrides tokenEndpoint) */
106
+ tokenProvider?: () => Promise<string>;
105
107
  /** Direct API key (server-side only, never expose in browser!) */
106
108
  apiKey?: string;
107
109
  /** WebSocket base URL (defaults to production) */
@@ -218,6 +220,11 @@ declare class MindCache {
218
220
  getAll(): STM;
219
221
  get_value(key: string, _processingStack?: Set<string>): any;
220
222
  get_attributes(key: string): KeyAttributes | undefined;
223
+ /**
224
+ * Update only the attributes of a key without modifying the value.
225
+ * Useful for updating tags, permissions etc. on document type keys.
226
+ */
227
+ set_attributes(key: string, attributes: Partial<KeyAttributes>): void;
221
228
  set_value(key: string, value: any, attributes?: Partial<KeyAttributes>): void;
222
229
  delete_key(key: string): void;
223
230
  clear(): void;
@@ -1,5 +1,5 @@
1
- import { M as MindCache, e as CloudConfig, C as CloudAdapter } from '../CloudAdapter-Bx-ITNdi.mjs';
2
- export { j as ClearOperation, g as CloudAdapterEvents, f as ConnectionState, i as DeleteOperation, O as Operation, h as SetOperation } from '../CloudAdapter-Bx-ITNdi.mjs';
1
+ import { M as MindCache, e as CloudConfig, C as CloudAdapter } from '../CloudAdapter-BcKF4Yaf.mjs';
2
+ export { j as ClearOperation, g as CloudAdapterEvents, f as ConnectionState, i as DeleteOperation, O as Operation, h as SetOperation } from '../CloudAdapter-BcKF4Yaf.mjs';
3
3
  import 'yjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { M as MindCache, e as CloudConfig, C as CloudAdapter } from '../CloudAdapter-Bx-ITNdi.js';
2
- export { j as ClearOperation, g as CloudAdapterEvents, f as ConnectionState, i as DeleteOperation, O as Operation, h as SetOperation } from '../CloudAdapter-Bx-ITNdi.js';
1
+ import { M as MindCache, e as CloudConfig, C as CloudAdapter } from '../CloudAdapter-BcKF4Yaf.js';
2
+ export { j as ClearOperation, g as CloudAdapterEvents, f as ConnectionState, i as DeleteOperation, O as Operation, h as SetOperation } from '../CloudAdapter-BcKF4Yaf.js';
3
3
  import 'yjs';
4
4
 
5
5
  /**
@@ -353,6 +353,8 @@ var init_CloudAdapter = __esm({
353
353
  } else if (msg.type === "auth_error" || msg.type === "error") {
354
354
  this._state = "error";
355
355
  this.emit("error", new Error(msg.error));
356
+ } else {
357
+ console.debug("MindCache Cloud: Received message type:", msg.type, msg);
356
358
  }
357
359
  } else {
358
360
  const encoder = encoding__namespace.createEncoder();
@@ -461,8 +463,6 @@ var MindCache = class {
461
463
  normalized.push("readonly");
462
464
  } else if (hasLLMWrite) {
463
465
  normalized.push("LLMWrite");
464
- } else {
465
- normalized.push("LLMWrite");
466
466
  }
467
467
  return normalized;
468
468
  }
@@ -685,14 +685,16 @@ var MindCache = class {
685
685
  }
686
686
  const CloudAdapter2 = await this._getCloudAdapterClass();
687
687
  if (!this._cloudConfig.baseUrl) ;
688
- const baseUrl = (this._cloudConfig.baseUrl || "https://api.mindcache.io").replace("https://", "wss://").replace("http://", "ws://");
688
+ const baseUrl = (this._cloudConfig.baseUrl || "https://api.mindcache.dev").replace("https://", "wss://").replace("http://", "ws://");
689
689
  const adapter = new CloudAdapter2({
690
690
  instanceId: this._cloudConfig.instanceId,
691
691
  projectId: this._cloudConfig.projectId || "default",
692
692
  baseUrl,
693
693
  apiKey: this._cloudConfig.apiKey
694
694
  });
695
- if (this._cloudConfig.tokenEndpoint) {
695
+ if (this._cloudConfig.tokenProvider) {
696
+ adapter.setTokenProvider(this._cloudConfig.tokenProvider);
697
+ } else if (this._cloudConfig.tokenEndpoint) {
696
698
  const tokenEndpoint = this._cloudConfig.tokenEndpoint;
697
699
  const instanceId = this._cloudConfig.instanceId;
698
700
  let resolvedBaseUrl;
@@ -936,6 +938,27 @@ var MindCache = class {
936
938
  const entryMap = this.rootMap.get(key);
937
939
  return entryMap ? entryMap.get("attributes") : void 0;
938
940
  }
941
+ /**
942
+ * Update only the attributes of a key without modifying the value.
943
+ * Useful for updating tags, permissions etc. on document type keys.
944
+ */
945
+ set_attributes(key, attributes) {
946
+ if (key === "$date" || key === "$time" || key === "$version") {
947
+ return;
948
+ }
949
+ const entryMap = this.rootMap.get(key);
950
+ if (!entryMap) {
951
+ return;
952
+ }
953
+ this.doc.transact(() => {
954
+ const existingAttrs = entryMap.get("attributes");
955
+ const mergedAttrs = { ...existingAttrs, ...attributes };
956
+ if (mergedAttrs.systemTags) {
957
+ mergedAttrs.systemTags = this.normalizeSystemTags(mergedAttrs.systemTags);
958
+ }
959
+ entryMap.set("attributes", mergedAttrs);
960
+ });
961
+ }
939
962
  set_value(key, value, attributes) {
940
963
  if (key === "$date" || key === "$time" || key === "$version") {
941
964
  return;