shogun-core 3.3.7 → 3.3.8

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.
@@ -19,7 +19,7 @@ import { PluginManager } from "./managers/PluginManager";
19
19
  * @since 2.0.0
20
20
  */
21
21
  export declare class ShogunCore implements IShogunCore {
22
- static readonly API_VERSION = "^3.0.11";
22
+ static readonly API_VERSION = "^3.3.8";
23
23
  db: DataBase;
24
24
  storage: ShogunStorage;
25
25
  provider?: ethers.Provider;
@@ -1,5 +1,10 @@
1
1
  /**
2
- * Esempio semplice che mostra le differenze principali tra i metodi API
2
+ * Example showing how to use the simplified ShogunCore API
3
+ *
4
+ * The API has been streamlined:
5
+ * - AutoQuickStart: Quick initialization helper
6
+ * - api.database: Direct access to DataBase for basic operations (get, put, set, remove, auth)
7
+ * - api helper methods: High-level helpers for profile, settings, collections, and array utilities
3
8
  */
4
9
  declare function simpleAPITest(): Promise<void>;
5
10
  export { simpleAPITest };
@@ -1,11 +1,17 @@
1
1
  /**
2
- * Simplified API layer to reduce complexity for common use cases.
3
- * Provides quick-start methods that wrap the full DataBase functionality.
2
+ * Simplified API layer focused on valuable helper methods.
3
+ * Provides quick-start initialization and high-level convenience methods.
4
+ *
5
+ * For basic operations (get, put, set, remove, auth), use DataBase directly.
6
+ * This class provides:
7
+ * - Quick initialization helpers (QuickStart, AutoQuickStart)
8
+ * - Array/Object conversion utilities for GunDB
9
+ * - High-level user data helpers (profile, settings, collections)
4
10
  */
5
- import { GunMessageGet, GunMessagePut } from "gun";
6
11
  import { DataBase } from "./db";
7
12
  /**
8
- * Simple API wrapper that provides common operations with minimal complexity.
13
+ * Simple API wrapper that provides high-level helper methods.
14
+ * For basic operations, use the DataBase instance directly via the `database` property.
9
15
  */
10
16
  export declare class SimpleGunAPI {
11
17
  private db;
@@ -15,183 +21,40 @@ export declare class SimpleGunAPI {
15
21
  */
16
22
  constructor(db: DataBase);
17
23
  /**
18
- * Get data at a given path.
19
- * @param path The path to retrieve data from.
20
- * @returns The data at the path, or null if not found or on error.
24
+ * Get direct access to the DataBase instance for full control.
25
+ * Use this for basic operations like get, put, set, remove, login, etc.
21
26
  */
22
- get<T = unknown>(path: string): Promise<T | null>;
23
- /**
24
- * Get the Gun node at a given path for chaining operations.
25
- * @param path The path to the node.
26
- * @returns The Gun node.
27
- */
28
- getNode(path: string): any;
29
- /**
30
- * Get the Gun node at a given path for direct chaining.
31
- * @param path The path to the node.
32
- * @returns The Gun node.
33
- */
34
- node(path: string): any;
35
- /**
36
- * Get a chainable wrapper for a Gun node at a given path.
37
- * @param path The path to the node.
38
- * @returns An object with chainable methods: get, put, set, once, then, map.
39
- */
40
- chain(path: string): {
41
- get: (subPath: string) => GunMessageGet<any, any>;
42
- put: (data: any) => Promise<GunMessagePut>;
43
- set: (data: any) => Promise<GunMessagePut>;
44
- once: () => Promise<any>;
45
- then: () => Promise<any>;
46
- map: (callback: (value: any, key: string) => any) => any;
47
- };
48
- /**
49
- * Put data at a given path.
50
- * @param path The path to put data to.
51
- * @param data The data to put.
52
- * @returns The GunMessagePut result.
53
- */
54
- put<T = unknown>(path: string, data: T): Promise<GunMessagePut>;
55
- /**
56
- * Set data at a given path (alternative to put).
57
- * @param path The path to set data to.
58
- * @param data The data to set.
59
- * @returns The GunMessagePut result.
60
- */
61
- set<T = unknown>(path: string, data: T): Promise<GunMessagePut>;
62
- /**
63
- * Remove data at a given path.
64
- * @param path The path to remove data from.
65
- * @returns The GunMessagePut result.
66
- */
67
- remove(path: string): Promise<GunMessagePut>;
68
- /**
69
- * Log in a user.
70
- * @param username The username.
71
- * @param password The password.
72
- * @returns The user info if successful, or null.
73
- */
74
- login(username: string, password: string): Promise<{
75
- userPub: string;
76
- username: string;
77
- } | null>;
78
- /**
79
- * Sign up a new user.
80
- * @param username The username.
81
- * @param password The password.
82
- * @returns The user info if successful, or null.
83
- */
84
- signup(username: string, password: string): Promise<{
85
- userPub: string;
86
- username: string;
87
- } | null>;
88
- /**
89
- * Log out the current user.
90
- */
91
- logout(): void;
92
- /**
93
- * Check if a user is currently logged in.
94
- * @returns True if logged in, false otherwise.
95
- */
96
- isLoggedIn(): boolean;
97
- /**
98
- * Get user data at a given path (requires login).
99
- * @param path The path to the user data.
100
- * @returns The user data, or null if not found or on error.
101
- */
102
- getUserData<T = unknown>(path: string): Promise<T | null>;
103
- /**
104
- * Put user data at a given path (requires login).
105
- * @param path The path to put data to.
106
- * @param data The data to put.
107
- * @returns True if successful, false otherwise.
108
- */
109
- putUserData<T = unknown>(path: string, data: T): Promise<boolean>;
110
- /**
111
- * Set user data at a given path (alternative to put, requires login).
112
- * @param path The path to set data to.
113
- * @param data The data to set.
114
- * @returns True if successful, false otherwise.
115
- */
116
- setUserData<T = unknown>(path: string, data: T): Promise<boolean>;
117
- /**
118
- * Remove user data at a given path (requires login).
119
- * @param path The path to remove data from.
120
- * @returns True if successful, false otherwise.
121
- */
122
- removeUserData(path: string): Promise<boolean>;
27
+ get database(): DataBase;
123
28
  /**
124
29
  * Convert an array to an indexed object for GunDB storage.
30
+ * GunDB doesn't store arrays natively, so this converts them to objects indexed by ID.
125
31
  * Example: [{id: '1', ...}, {id: '2', ...}] => { "1": {...}, "2": {...} }
126
- * @param arr The array to convert.
127
- * @returns The indexed object.
128
- * @private
129
- */
130
- private getIndexedObjectFromArray;
131
- /**
132
- * Convert an indexed object back to an array.
133
- * Example: { "1": {...}, "2": {...} } => [{id: '1', ...}, {id: '2', ...}]
134
- * @param indexedObj The indexed object to convert.
135
- * @returns The array.
136
- * @private
137
- */
138
- private getArrayFromIndexedObject;
139
- /**
140
- * Convert an array to an indexed object for GunDB storage (public method).
141
- * @param arr The array to convert.
142
- * @returns The indexed object.
32
+ * @param arr The array to convert (each item must have an 'id' property).
33
+ * @returns The indexed object suitable for GunDB storage.
143
34
  */
144
35
  arrayToIndexedObject<T extends {
145
36
  id: string | number;
146
37
  }>(arr: T[]): Record<string, T>;
147
38
  /**
148
- * Convert an indexed object to an array (public method).
39
+ * Convert an indexed object back to an array.
40
+ * Reverses the arrayToIndexedObject conversion.
41
+ * Example: { "1": {...}, "2": {...} } => [{id: '1', ...}, {id: '2', ...}]
149
42
  * @param indexedObj The indexed object to convert.
150
- * @returns The array.
43
+ * @returns The array of items.
151
44
  */
152
45
  indexedObjectToArray<T>(indexedObj: Record<string, T> | null): T[];
153
46
  /**
154
- * Get the GunDB user node at a given path (requires login).
155
- * Useful for advanced operations that need direct GunDB node access.
156
- * @param path The path to the user node.
157
- * @returns The Gun node.
158
- * @throws If not logged in.
159
- */
160
- getUserNode(path: string): any;
161
- /**
162
- * Get the GunDB global node at a given path.
163
- * Useful for advanced operations that need direct GunDB node access.
164
- * @param path The path to the global node.
165
- * @returns The Gun node.
47
+ * Get all user data (returns user's entire data tree).
48
+ * Requires user to be logged in.
49
+ * @returns The complete user data tree, or null if not logged in or on error.
166
50
  */
167
- getGlobalNode(path: string): any;
168
- /**
169
- * Get the current user info.
170
- * @returns The current user info, or null if not logged in.
171
- */
172
- getCurrentUser(): {
173
- pub: string;
174
- username?: string;
175
- } | null;
176
- /**
177
- * Check if a user exists by alias.
178
- * @param alias The user alias.
179
- * @returns True if the user exists, false otherwise.
180
- */
181
- userExists(alias: string): Promise<boolean>;
182
- /**
183
- * Get user info by alias.
184
- * @param alias The user alias.
185
- * @returns The user info, or null if not found.
186
- */
187
- getUser(alias: string): Promise<{
188
- userPub: string;
189
- username: string;
190
- } | null>;
51
+ getAllUserData(): Promise<Record<string, unknown> | null>;
191
52
  /**
192
- * Advanced user space operations
53
+ * Update user profile with common fields.
54
+ * Provides a standardized location for user profile data.
55
+ * @param profileData Profile data to save (name, email, bio, avatar, etc.)
56
+ * @returns True if successful, false otherwise.
193
57
  */
194
- getAllUserData(): Promise<Record<string, unknown> | null>;
195
58
  updateProfile(profileData: {
196
59
  name?: string;
197
60
  email?: string;
@@ -199,14 +62,63 @@ export declare class SimpleGunAPI {
199
62
  avatar?: string;
200
63
  [key: string]: unknown;
201
64
  }): Promise<boolean>;
65
+ /**
66
+ * Get user profile data.
67
+ * @returns The user profile data, or null if not found or not logged in.
68
+ */
202
69
  getProfile(): Promise<Record<string, unknown> | null>;
70
+ /**
71
+ * Save user settings.
72
+ * Provides a standardized location for application settings.
73
+ * @param settings Settings object to save.
74
+ * @returns True if successful, false otherwise.
75
+ */
203
76
  saveSettings(settings: Record<string, unknown>): Promise<boolean>;
77
+ /**
78
+ * Get user settings.
79
+ * @returns The user settings, or null if not found or not logged in.
80
+ */
204
81
  getSettings(): Promise<Record<string, unknown> | null>;
82
+ /**
83
+ * Save user preferences.
84
+ * Provides a standardized location for user preferences (distinct from settings).
85
+ * @param preferences Preferences object to save.
86
+ * @returns True if successful, false otherwise.
87
+ */
205
88
  savePreferences(preferences: Record<string, unknown>): Promise<boolean>;
89
+ /**
90
+ * Get user preferences.
91
+ * @returns The user preferences, or null if not found or not logged in.
92
+ */
206
93
  getPreferences(): Promise<Record<string, unknown> | null>;
94
+ /**
95
+ * Create a user collection with initial items.
96
+ * Provides a standardized location for user collections.
97
+ * @param collectionName The name of the collection.
98
+ * @param items The initial items for the collection.
99
+ * @returns True if successful, false otherwise.
100
+ */
207
101
  createCollection<T = unknown>(collectionName: string, items: Record<string, T>): Promise<boolean>;
102
+ /**
103
+ * Add an item to a user collection.
104
+ * @param collectionName The name of the collection.
105
+ * @param itemId The ID of the item to add.
106
+ * @param item The item data.
107
+ * @returns True if successful, false otherwise.
108
+ */
208
109
  addToCollection<T = unknown>(collectionName: string, itemId: string, item: T): Promise<boolean>;
110
+ /**
111
+ * Get a user collection.
112
+ * @param collectionName The name of the collection.
113
+ * @returns The collection data, or null if not found or not logged in.
114
+ */
209
115
  getCollection(collectionName: string): Promise<Record<string, unknown> | null>;
116
+ /**
117
+ * Remove an item from a user collection.
118
+ * @param collectionName The name of the collection.
119
+ * @param itemId The ID of the item to remove.
120
+ * @returns True if successful, false otherwise.
121
+ */
210
122
  removeFromCollection(collectionName: string, itemId: string): Promise<boolean>;
211
123
  }
212
124
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shogun-core",
3
- "version": "3.3.7",
3
+ "version": "3.3.8",
4
4
  "description": "SHOGUN CORE - Core library for Shogun Ecosystem",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -50,22 +50,15 @@
50
50
  "author": "Scobru",
51
51
  "license": "MIT",
52
52
  "dependencies": {
53
- "@fluidkey/stealth-account-kit": "^1.1.0",
54
53
  "@noble/curves": "^1.9.1",
55
- "@scure/bip32": "^2.0.1",
56
54
  "assert": "^2.1.0",
57
- "base64url": "^3.0.1",
58
55
  "buffer": "^6.0.3",
59
56
  "constants-browserify": "^1.0.0",
60
57
  "crypto-browserify": "^3.12.0",
61
58
  "ethers": "^6.13.5",
62
59
  "gun": "git+https://github.com/amark/gun.git",
63
- "keccak256": "^1.0.6",
64
60
  "nostr-tools": "^2.15.0",
65
- "qs": "^6.14.0",
66
61
  "rxjs": "^7.8.2",
67
- "ts-node": "^10.9.2",
68
- "url": "^0.11.4",
69
62
  "uuid": "^11.1.0",
70
63
  "vm-browserify": "^1.1.2"
71
64
  },
@@ -1,273 +0,0 @@
1
- "use strict";
2
- /**
3
- * Esempio completo che mostra le differenze tra i vari metodi dell'API ShogunCore
4
- *
5
- * Questo esempio dimostra:
6
- * - get() vs getData() vs getNode() vs node() vs chain()
7
- * - put() vs set() vs putUserData() vs setUserData()
8
- * - remove() vs removeUserData()
9
- * - Operazioni globali vs operazioni utente
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.demonstrateAPIDifferences = demonstrateAPIDifferences;
13
- exports.showAPIDifferences = showAPIDifferences;
14
- const api_1 = require("../gundb/api");
15
- async function demonstrateAPIDifferences() {
16
- console.log("🚀 Iniziamo il test delle differenze API...\n");
17
- // 1. Setup iniziale
18
- const quickStart = new api_1.AutoQuickStart({
19
- peers: ["https://peer.wallie.io/gun"],
20
- appScope: "test-api",
21
- });
22
- await quickStart.init();
23
- const api = quickStart.api;
24
- console.log("✅ Setup completato\n");
25
- // 2. Test operazioni GLOBALI (senza autenticazione)
26
- console.log("📊 === TEST OPERAZIONI GLOBALI ===\n");
27
- // Test get() - restituisce dati direttamente o null
28
- console.log("🔍 Test get():");
29
- const globalData = await api.get("global/test");
30
- console.log('get("global/test"):', globalData); // null se non esiste
31
- // Test getNode() - restituisce nodo Gun per operazioni di chaining
32
- console.log("\n🔗 Test getNode():");
33
- const globalNode = api.getNode("global/test");
34
- console.log('getNode("global/test"):', typeof globalNode); // Gun node object
35
- // Test node() - alias di getNode()
36
- console.log("\n🔗 Test node():");
37
- const globalNode2 = api.node("global/test");
38
- console.log('node("global/test"):', typeof globalNode2); // Gun node object
39
- // Test chain() - wrapper con metodi di convenienza
40
- console.log("\n⛓️ Test chain():");
41
- const globalChain = api.chain("global/test");
42
- console.log('chain("global/test"):', Object.keys(globalChain)); // ['get', 'put', 'set', 'once', 'then', 'map']
43
- // Test put() vs set() - operazioni globali
44
- console.log("\n💾 Test put() vs set():");
45
- const testData = { message: "Hello Global!", timestamp: Date.now() };
46
- const putResult = await api.put("global/test", testData);
47
- console.log("put() result:", putResult); // boolean
48
- const setResult = await api.set("global/test2", {
49
- ...testData,
50
- method: "set",
51
- });
52
- console.log("set() result:", setResult); // boolean
53
- // Verifica che i dati siano stati salvati
54
- const retrievedData1 = await api.get("global/test");
55
- const retrievedData2 = await api.get("global/test2");
56
- console.log("Retrieved put data:", retrievedData1);
57
- console.log("Retrieved set data:", retrievedData2);
58
- // Test remove() - operazione globale
59
- console.log("\n🗑️ Test remove():");
60
- const removeResult = await api.remove("global/test2");
61
- console.log("remove() result:", removeResult); // boolean
62
- const removedData = await api.get("global/test2");
63
- console.log("Data after remove:", removedData); // null
64
- // 3. Test autenticazione
65
- console.log("\n\n🔐 === TEST AUTENTICAZIONE ===\n");
66
- const username = "testuser_" + Date.now();
67
- const password = "testpass123";
68
- // Test signup
69
- console.log("📝 Test signup():");
70
- const signupResult = await api.signup(username, password);
71
- console.log("signup result:", signupResult);
72
- if (signupResult) {
73
- console.log("✅ Utente creato:", signupResult.username);
74
- // Test login
75
- console.log("\n🔑 Test login():");
76
- const loginResult = await api.login(username, password);
77
- console.log("login result:", loginResult);
78
- if (loginResult) {
79
- console.log("✅ Login riuscito:", loginResult.username);
80
- // 4. Test operazioni UTENTE (con autenticazione)
81
- console.log("\n\n👤 === TEST OPERAZIONI UTENTE ===\n");
82
- // Test getUserData() - restituisce dati utente direttamente
83
- console.log("🔍 Test getUserData():");
84
- const userData = await api.getUserData("profile");
85
- console.log('getUserData("profile"):', userData); // null se non esiste
86
- // Test putUserData() vs setUserData() - operazioni utente
87
- console.log("\n💾 Test putUserData() vs setUserData():");
88
- const profileData = {
89
- name: "Test User",
90
- email: "test@example.com",
91
- bio: "Test bio",
92
- preferences: {
93
- theme: "dark",
94
- notifications: true,
95
- },
96
- };
97
- const putUserResult = await api.putUserData("profile", profileData);
98
- console.log("putUserData() result:", putUserResult); // boolean
99
- const settingsData = {
100
- language: "it",
101
- timezone: "Europe/Rome",
102
- privacy: "public",
103
- };
104
- const setUserResult = await api.setUserData("settings", settingsData);
105
- console.log("setUserData() result:", setUserResult); // boolean
106
- // Verifica che i dati utente siano stati salvati
107
- const retrievedProfile = await api.getUserData("profile");
108
- const retrievedSettings = await api.getUserData("settings");
109
- console.log("Retrieved profile:", retrievedProfile);
110
- console.log("Retrieved settings:", retrievedSettings);
111
- // Test getUserNode() - nodo utente per operazioni avanzate
112
- console.log("\n🔗 Test getUserNode():");
113
- try {
114
- const userNode = api.getUserNode("profile");
115
- console.log('getUserNode("profile"):', typeof userNode); // Gun node object
116
- }
117
- catch (error) {
118
- console.log("getUserNode error:", error.message);
119
- }
120
- // Test removeUserData() - rimozione dati utente
121
- console.log("\n🗑️ Test removeUserData():");
122
- const removeUserResult = await api.removeUserData("settings");
123
- console.log("removeUserData() result:", removeUserResult); // boolean
124
- const removedUserData = await api.getUserData("settings");
125
- console.log("User data after remove:", removedUserData); // null
126
- // 5. Test metodi di convenienza
127
- console.log("\n\n🛠️ === TEST METODI DI CONVENIENZA ===\n");
128
- // Test updateProfile()
129
- console.log("👤 Test updateProfile():");
130
- const profileUpdate = {
131
- name: "Updated Test User",
132
- bio: "Updated bio",
133
- avatar: "https://example.com/avatar.jpg",
134
- };
135
- const profileResult = await api.updateProfile(profileUpdate);
136
- console.log("updateProfile() result:", profileResult);
137
- const updatedProfile = await api.getProfile();
138
- console.log("Updated profile:", updatedProfile);
139
- // Test saveSettings()
140
- console.log("\n⚙️ Test saveSettings():");
141
- const settings = {
142
- theme: "light",
143
- language: "en",
144
- notifications: false,
145
- };
146
- const settingsResult = await api.saveSettings(settings);
147
- console.log("saveSettings() result:", settingsResult);
148
- const savedSettings = await api.getSettings();
149
- console.log("Saved settings:", savedSettings);
150
- // Test createCollection()
151
- console.log("\n📚 Test createCollection():");
152
- const todos = {
153
- "1": { id: "1", text: "Learn ShogunCore", completed: false },
154
- "2": { id: "2", text: "Build awesome app", completed: false },
155
- "3": { id: "3", text: "Deploy to production", completed: true },
156
- };
157
- const collectionResult = await api.createCollection("todos", todos);
158
- console.log("createCollection() result:", collectionResult);
159
- const todosCollection = await api.getCollection("todos");
160
- console.log("Todos collection:", todosCollection);
161
- // Test addToCollection()
162
- console.log("\n➕ Test addToCollection():");
163
- const newTodo = { id: "4", text: "Test API methods", completed: false };
164
- const addResult = await api.addToCollection("todos", "4", newTodo);
165
- console.log("addToCollection() result:", addResult);
166
- const updatedCollection = await api.getCollection("todos");
167
- console.log("Updated collection:", updatedCollection);
168
- // Test removeFromCollection()
169
- console.log("\n➖ Test removeFromCollection():");
170
- const removeFromCollectionResult = await api.removeFromCollection("todos", "3");
171
- console.log("removeFromCollection() result:", removeFromCollectionResult);
172
- const finalCollection = await api.getCollection("todos");
173
- console.log("Final collection:", finalCollection);
174
- // 6. Test utility methods
175
- console.log("\n\n🔧 === TEST METODI UTILITY ===\n");
176
- // Test getCurrentUser()
177
- console.log("👤 Test getCurrentUser():");
178
- const currentUser = api.getCurrentUser();
179
- console.log("Current user:", currentUser);
180
- // Test isLoggedIn()
181
- console.log("\n🔐 Test isLoggedIn():");
182
- const isLoggedIn = api.isLoggedIn();
183
- console.log("Is logged in:", isLoggedIn);
184
- // Test userExists()
185
- console.log("\n🔍 Test userExists():");
186
- const userExists = await api.userExists(username);
187
- console.log(`User ${username} exists:`, userExists);
188
- // Test getUser()
189
- console.log("\n👥 Test getUser():");
190
- const userInfo = await api.getUser(username);
191
- console.log("User info:", userInfo);
192
- // Test logout
193
- console.log("\n🚪 Test logout():");
194
- api.logout();
195
- const isLoggedInAfter = api.isLoggedIn();
196
- console.log("Is logged in after logout:", isLoggedInAfter);
197
- }
198
- else {
199
- console.log("❌ Login fallito");
200
- }
201
- }
202
- else {
203
- console.log("❌ Signup fallito");
204
- }
205
- // 7. Test array utilities
206
- console.log("\n\n📊 === TEST ARRAY UTILITIES ===\n");
207
- const testArray = [
208
- { id: "1", name: "Item 1", value: 100 },
209
- { id: "2", name: "Item 2", value: 200 },
210
- { id: "3", name: "Item 3", value: 300 },
211
- ];
212
- console.log("Original array:", testArray);
213
- // Test arrayToIndexedObject()
214
- const indexedObject = api.arrayToIndexedObject(testArray);
215
- console.log("Array to indexed object:", indexedObject);
216
- // Test indexedObjectToArray()
217
- const backToArray = api.indexedObjectToArray(indexedObject);
218
- console.log("Indexed object back to array:", backToArray);
219
- console.log("\n✅ Test completato!");
220
- }
221
- // Funzione per mostrare le differenze principali
222
- function showAPIDifferences() {
223
- console.log(`
224
- 📋 === RIEPILOGO DIFFERENZE API ===
225
-
226
- 🔍 METODI GET:
227
- • get(path) → Restituisce dati direttamente o null
228
- • getNode(path) → Restituisce nodo Gun per chaining (.map(), .on(), etc.)
229
- • node(path) → Alias di getNode()
230
- • chain(path) → Wrapper con metodi di convenienza (get, put, set, once, then, map)
231
- • getUserData(path) → Come get() ma per dati utente (richiede login)
232
-
233
- 💾 METODI PUT/SET:
234
- • put(path, data) → Salva dati globali, restituisce boolean
235
- • set(path, data) → Come put() ma con semantica diversa
236
- • putUserData(path, data) → Salva dati utente, restituisce boolean
237
- • setUserData(path, data) → Come putUserData() ma con semantica diversa
238
-
239
- 🗑️ METODI REMOVE:
240
- • remove(path) → Rimuove dati globali, restituisce boolean
241
- • removeUserData(path) → Rimuove dati utente, restituisce boolean
242
-
243
- 🔐 AUTENTICAZIONE:
244
- • signup(username, password) → Crea nuovo utente
245
- • login(username, password) → Autentica utente esistente
246
- • logout() → Disconnette utente
247
- • isLoggedIn() → Controlla se utente è autenticato
248
-
249
- 👤 UTILITY UTENTE:
250
- • getCurrentUser() → Info utente corrente
251
- • getUser(alias) → Info utente per alias
252
- • userExists(alias) → Controlla se utente esiste
253
-
254
- 🛠️ METODI DI CONVENIENZA:
255
- • updateProfile(data) → Aggiorna profilo utente
256
- • getProfile() → Ottiene profilo utente
257
- • saveSettings(data) → Salva impostazioni utente
258
- • getSettings() → Ottiene impostazioni utente
259
- • createCollection(name, items) → Crea collezione
260
- • addToCollection(name, id, item) → Aggiunge item a collezione
261
- • getCollection(name) → Ottiene collezione
262
- • removeFromCollection(name, id) → Rimuove item da collezione
263
-
264
- 📊 ARRAY UTILITIES:
265
- • arrayToIndexedObject(arr) → Converte array in oggetto indicizzato per GunDB
266
- • indexedObjectToArray(obj) → Converte oggetto indicizzato in array
267
- `);
268
- }
269
- // Esegui il test
270
- if (require.main === module) {
271
- showAPIDifferences();
272
- demonstrateAPIDifferences().catch(console.error);
273
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Esempio completo che mostra le differenze tra i vari metodi dell'API ShogunCore
3
- *
4
- * Questo esempio dimostra:
5
- * - get() vs getData() vs getNode() vs node() vs chain()
6
- * - put() vs set() vs putUserData() vs setUserData()
7
- * - remove() vs removeUserData()
8
- * - Operazioni globali vs operazioni utente
9
- */
10
- declare function demonstrateAPIDifferences(): Promise<void>;
11
- declare function showAPIDifferences(): void;
12
- export { demonstrateAPIDifferences, showAPIDifferences };