@adaas/a-concept 0.1.28 → 0.1.30
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/LICENSE +10 -19
- package/README.md +13 -8
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +233 -22
- package/dist/index.d.ts +233 -22
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -16
- package/src/global/A-Fragment/A-Fragment.class.ts +281 -26
- package/src/global/A-Fragment/A-Fragment.types.ts +2 -2
- package/tests/A-Fragment.test.ts +290 -0
package/dist/index.d.mts
CHANGED
|
@@ -1186,7 +1186,7 @@ declare class A_Stage {
|
|
|
1186
1186
|
* @param step
|
|
1187
1187
|
* @returns
|
|
1188
1188
|
*/
|
|
1189
|
-
protected getStepArgs(scope: A_Scope, step: A_TYPES__A_StageStep): Promise<(A_Container | A_Component | A_Entity<any, A_TYPES__Entity_Serialized> | A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any>[]> | A_Feature<A_TYPES__FeatureAvailableComponents> | A_Fragment<any> | A_TYPES__ScopeResolvableComponents[] | undefined)[]>;
|
|
1189
|
+
protected getStepArgs(scope: A_Scope, step: A_TYPES__A_StageStep): Promise<(A_Container | A_Component | A_Entity<any, A_TYPES__Entity_Serialized> | A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any, any>[]> | A_Feature<A_TYPES__FeatureAvailableComponents> | A_Fragment<any, any> | A_TYPES__ScopeResolvableComponents[] | undefined)[]>;
|
|
1190
1190
|
/**
|
|
1191
1191
|
* Resolves the component of the step
|
|
1192
1192
|
*
|
|
@@ -2172,7 +2172,7 @@ declare class A_Concept<_Imports extends A_Container[] = A_Container[]> {
|
|
|
2172
2172
|
/**
|
|
2173
2173
|
* The primary Root scope of the concept.
|
|
2174
2174
|
*/
|
|
2175
|
-
get scope(): A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any>[]>;
|
|
2175
|
+
get scope(): A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any, any>[]>;
|
|
2176
2176
|
/**
|
|
2177
2177
|
* Register a class or value in the concept scope.
|
|
2178
2178
|
*/
|
|
@@ -2227,39 +2227,250 @@ declare class A_Concept<_Imports extends A_Container[] = A_Container[]> {
|
|
|
2227
2227
|
container: _Imports[number]): Promise<void>;
|
|
2228
2228
|
}
|
|
2229
2229
|
|
|
2230
|
-
|
|
2230
|
+
/**
|
|
2231
|
+
* A_Fragment is a core architectural component that represents a singleton execution context
|
|
2232
|
+
* within the A-Concept framework. It serves as a shared memory container that can be passed
|
|
2233
|
+
* between Components, Entities, and Commands throughout the application pipeline.
|
|
2234
|
+
*
|
|
2235
|
+
* Key Features:
|
|
2236
|
+
* - Singleton pattern: Only one instance per fragment type per scope
|
|
2237
|
+
* - Meta storage: Built-in key-value storage for pipeline data
|
|
2238
|
+
* - Type-safe: Full TypeScript generics support for meta items and serialization
|
|
2239
|
+
* - Serializable: Can be converted to JSON for persistence or transmission
|
|
2240
|
+
*
|
|
2241
|
+
* @template _MetaItems - Type definition for the meta storage structure
|
|
2242
|
+
* @template _SerializedType - Type definition for the serialized output format
|
|
2243
|
+
*
|
|
2244
|
+
* @example
|
|
2245
|
+
* ```typescript
|
|
2246
|
+
* // Basic usage with typed meta
|
|
2247
|
+
* class UserFragment extends A_Fragment<{ userId: string; role: string }> {
|
|
2248
|
+
* constructor() {
|
|
2249
|
+
* super({ name: 'UserFragment' });
|
|
2250
|
+
* }
|
|
2251
|
+
* }
|
|
2252
|
+
*
|
|
2253
|
+
* // Custom serialization
|
|
2254
|
+
* class SessionFragment extends A_Fragment<
|
|
2255
|
+
* { sessionId: string; timestamp: number },
|
|
2256
|
+
* { name: string; sessionData: string }
|
|
2257
|
+
* > {
|
|
2258
|
+
* toJSON() {
|
|
2259
|
+
* return {
|
|
2260
|
+
* name: this.name,
|
|
2261
|
+
* sessionData: `${this.get('sessionId')}-${this.get('timestamp')}`
|
|
2262
|
+
* };
|
|
2263
|
+
* }
|
|
2264
|
+
* }
|
|
2265
|
+
* ```
|
|
2266
|
+
*/
|
|
2267
|
+
declare class A_Fragment<_MetaItems extends Record<string, any> = any, _SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized & _MetaItems> {
|
|
2231
2268
|
/**
|
|
2232
|
-
*
|
|
2269
|
+
* The unique identifier/name for this fragment instance.
|
|
2270
|
+
* Used for identification and debugging purposes.
|
|
2233
2271
|
*/
|
|
2234
|
-
|
|
2272
|
+
protected _name: string;
|
|
2235
2273
|
/**
|
|
2236
|
-
*
|
|
2274
|
+
* Internal meta storage using A_Meta for type-safe key-value operations.
|
|
2275
|
+
* This stores all the fragment's runtime data that can be accessed and modified
|
|
2276
|
+
* throughout the execution pipeline.
|
|
2237
2277
|
*/
|
|
2238
|
-
protected _meta: A_Meta<
|
|
2278
|
+
protected _meta: A_Meta<_MetaItems>;
|
|
2239
2279
|
/**
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2280
|
+
* Creates a new A_Fragment instance.
|
|
2281
|
+
*
|
|
2282
|
+
* A_Fragment implements the singleton pattern for execution contexts, allowing
|
|
2283
|
+
* shared state management across different parts of the application pipeline.
|
|
2284
|
+
* Each fragment serves as a memory container that can store typed data and be
|
|
2285
|
+
* serialized for persistence or transmission.
|
|
2243
2286
|
*
|
|
2287
|
+
* Key Benefits:
|
|
2288
|
+
* - Centralized state management for related operations
|
|
2289
|
+
* - Type-safe meta operations with full IntelliSense support
|
|
2290
|
+
* - Serialization support for data persistence
|
|
2291
|
+
* - Singleton pattern ensures consistent state within scope
|
|
2244
2292
|
*
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
2293
|
+
* @param params - Initialization parameters
|
|
2294
|
+
* @param params.name - Optional custom name for the fragment (defaults to class name)
|
|
2295
|
+
*
|
|
2296
|
+
* @example
|
|
2297
|
+
* ```typescript
|
|
2298
|
+
* const fragment = new A_Fragment<{ userId: string }>({
|
|
2299
|
+
* name: 'UserSessionFragment'
|
|
2300
|
+
* });
|
|
2301
|
+
* fragment.set('userId', '12345');
|
|
2302
|
+
* ```
|
|
2247
2303
|
*/
|
|
2248
2304
|
constructor(params?: Partial<A_TYPES__Fragment_Init>);
|
|
2249
2305
|
/**
|
|
2250
|
-
*
|
|
2306
|
+
* Gets the fragment's unique name/identifier.
|
|
2251
2307
|
*
|
|
2252
|
-
* @returns
|
|
2308
|
+
* @returns The fragment name
|
|
2253
2309
|
*/
|
|
2254
|
-
get
|
|
2310
|
+
get name(): string;
|
|
2255
2311
|
/**
|
|
2256
|
-
*
|
|
2312
|
+
* Gets direct access to the underlying Meta object for advanced meta operations.
|
|
2257
2313
|
*
|
|
2258
|
-
*
|
|
2314
|
+
* Use this when you need to perform bulk operations or access Meta-specific methods.
|
|
2315
|
+
* For simple get/set operations, prefer using the direct methods on the fragment.
|
|
2316
|
+
*
|
|
2317
|
+
* @returns The Meta instance containing the fragment's meta
|
|
2318
|
+
*
|
|
2319
|
+
* @example
|
|
2320
|
+
* ```typescript
|
|
2321
|
+
* const fragment = new A_Fragment<{ users: string[], count: number }>();
|
|
2322
|
+
*
|
|
2323
|
+
* // Advanced operations using meta
|
|
2324
|
+
* fragment.meta.setMultiple({
|
|
2325
|
+
* users: ['alice', 'bob'],
|
|
2326
|
+
* count: 2
|
|
2327
|
+
* });
|
|
2328
|
+
*
|
|
2329
|
+
* // Get all keys
|
|
2330
|
+
* const keys = fragment.meta.keys();
|
|
2331
|
+
* ```
|
|
2259
2332
|
*/
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2333
|
+
get meta(): A_Meta<_MetaItems>;
|
|
2334
|
+
/**
|
|
2335
|
+
* Checks if a specific meta key exists in the fragment.
|
|
2336
|
+
*
|
|
2337
|
+
* @param param - The key to check for existence
|
|
2338
|
+
* @returns True if the key exists, false otherwise
|
|
2339
|
+
*
|
|
2340
|
+
* @example
|
|
2341
|
+
* ```typescript
|
|
2342
|
+
* if (fragment.has('userId')) {
|
|
2343
|
+
* console.log('User ID is set');
|
|
2344
|
+
* }
|
|
2345
|
+
* ```
|
|
2346
|
+
*/
|
|
2347
|
+
has(param: keyof _MetaItems): boolean;
|
|
2348
|
+
/**
|
|
2349
|
+
* Retrieves a value from the fragment's meta.
|
|
2350
|
+
*
|
|
2351
|
+
* @param param - The key to retrieve
|
|
2352
|
+
* @returns The value associated with the key, or undefined if not found
|
|
2353
|
+
*
|
|
2354
|
+
* @example
|
|
2355
|
+
* ```typescript
|
|
2356
|
+
* const userId = fragment.get('userId');
|
|
2357
|
+
* if (userId) {
|
|
2358
|
+
* console.log(`Current user: ${userId}`);
|
|
2359
|
+
* }
|
|
2360
|
+
* ```
|
|
2361
|
+
*/
|
|
2362
|
+
get<K extends keyof _MetaItems>(param: K): _MetaItems[K] | undefined;
|
|
2363
|
+
/**
|
|
2364
|
+
* Stores a value in the fragment's meta.
|
|
2365
|
+
*
|
|
2366
|
+
* @param param - The key to store the value under
|
|
2367
|
+
* @param value - The value to store
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* ```typescript
|
|
2371
|
+
* fragment.set('userId', '12345');
|
|
2372
|
+
* fragment.set('role', 'admin');
|
|
2373
|
+
* ```
|
|
2374
|
+
*/
|
|
2375
|
+
set<K extends keyof _MetaItems>(param: K, value: _MetaItems[K]): void;
|
|
2376
|
+
/**
|
|
2377
|
+
* Removes a specific key from the fragment's meta.
|
|
2378
|
+
*
|
|
2379
|
+
* @param param - The key to remove
|
|
2380
|
+
*
|
|
2381
|
+
* @example
|
|
2382
|
+
* ```typescript
|
|
2383
|
+
* fragment.drop('temporaryData');
|
|
2384
|
+
* ```
|
|
2385
|
+
*/
|
|
2386
|
+
drop(param: keyof _MetaItems): void;
|
|
2387
|
+
/**
|
|
2388
|
+
* Clears all data from the fragment's meta.
|
|
2389
|
+
*
|
|
2390
|
+
* Use with caution as this will remove all stored data in the fragment.
|
|
2391
|
+
*
|
|
2392
|
+
* @example
|
|
2393
|
+
* ```typescript
|
|
2394
|
+
* fragment.clear(); // All meta data is now gone
|
|
2395
|
+
* ```
|
|
2396
|
+
*/
|
|
2397
|
+
clear(): void;
|
|
2398
|
+
/**
|
|
2399
|
+
* Gets the number of items stored in the fragment's meta.
|
|
2400
|
+
*
|
|
2401
|
+
* @returns The count of stored meta items
|
|
2402
|
+
*
|
|
2403
|
+
* @example
|
|
2404
|
+
* ```typescript
|
|
2405
|
+
* console.log(`Fragment contains ${fragment.size()} items`);
|
|
2406
|
+
* ```
|
|
2407
|
+
*/
|
|
2408
|
+
size(): number;
|
|
2409
|
+
/**
|
|
2410
|
+
* Gets all keys currently stored in the fragment's meta.
|
|
2411
|
+
*
|
|
2412
|
+
* @returns Array of all meta keys
|
|
2413
|
+
*
|
|
2414
|
+
* @example
|
|
2415
|
+
* ```typescript
|
|
2416
|
+
* const keys = fragment.keys();
|
|
2417
|
+
* console.log('Stored keys:', keys);
|
|
2418
|
+
* ```
|
|
2419
|
+
*/
|
|
2420
|
+
keys(): (keyof _MetaItems)[];
|
|
2421
|
+
/**
|
|
2422
|
+
* Sets multiple values at once in the fragment's meta.
|
|
2423
|
+
*
|
|
2424
|
+
* @param data - Object containing key-value pairs to set
|
|
2425
|
+
*
|
|
2426
|
+
* @example
|
|
2427
|
+
* ```typescript
|
|
2428
|
+
* fragment.setMultiple({
|
|
2429
|
+
* userId: '12345',
|
|
2430
|
+
* role: 'admin',
|
|
2431
|
+
* lastLogin: new Date()
|
|
2432
|
+
* });
|
|
2433
|
+
* ```
|
|
2434
|
+
*/
|
|
2435
|
+
setMultiple(data: A_TYPES__DeepPartial<_MetaItems>): void;
|
|
2436
|
+
/**
|
|
2437
|
+
* Creates a shallow copy of the fragment with the same meta data.
|
|
2438
|
+
*
|
|
2439
|
+
* @param newName - Optional new name for the cloned fragment
|
|
2440
|
+
* @returns A new fragment instance with copied meta
|
|
2441
|
+
*
|
|
2442
|
+
* @example
|
|
2443
|
+
* ```typescript
|
|
2444
|
+
* const original = new A_Fragment<{ data: string }>({ name: 'original' });
|
|
2445
|
+
* original.set('data', 'test');
|
|
2446
|
+
*
|
|
2447
|
+
* const clone = original.clone('cloned');
|
|
2448
|
+
* console.log(clone.get('data')); // 'test'
|
|
2449
|
+
* ```
|
|
2450
|
+
*/
|
|
2451
|
+
clone(newName?: string): A_Fragment<_MetaItems, _SerializedType>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Serializes the fragment to a JSON-compatible object.
|
|
2454
|
+
*
|
|
2455
|
+
* This method combines the fragment's name with all meta data to create
|
|
2456
|
+
* a serializable representation. The return type is determined by the
|
|
2457
|
+
* _SerializedType generic parameter, allowing for custom serialization formats.
|
|
2458
|
+
*
|
|
2459
|
+
* @returns A serialized representation of the fragment
|
|
2460
|
+
*
|
|
2461
|
+
* @example
|
|
2462
|
+
* ```typescript
|
|
2463
|
+
* const fragment = new A_Fragment<{ userId: string, role: string }>({
|
|
2464
|
+
* name: 'UserFragment'
|
|
2465
|
+
* });
|
|
2466
|
+
* fragment.set('userId', '12345');
|
|
2467
|
+
* fragment.set('role', 'admin');
|
|
2468
|
+
*
|
|
2469
|
+
* const json = fragment.toJSON();
|
|
2470
|
+
* // Result: { name: 'UserFragment', userId: '12345', role: 'admin' }
|
|
2471
|
+
* ```
|
|
2472
|
+
*/
|
|
2473
|
+
toJSON(): _SerializedType;
|
|
2263
2474
|
}
|
|
2264
2475
|
|
|
2265
2476
|
/**
|
|
@@ -2278,9 +2489,9 @@ type A_TYPES__Fragment_Init = {
|
|
|
2278
2489
|
*/
|
|
2279
2490
|
type A_TYPES__Fragment_Serialized = {
|
|
2280
2491
|
/**
|
|
2281
|
-
* The
|
|
2492
|
+
* The Name of the fragment
|
|
2282
2493
|
*/
|
|
2283
|
-
|
|
2494
|
+
name: string;
|
|
2284
2495
|
};
|
|
2285
2496
|
|
|
2286
2497
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1186,7 +1186,7 @@ declare class A_Stage {
|
|
|
1186
1186
|
* @param step
|
|
1187
1187
|
* @returns
|
|
1188
1188
|
*/
|
|
1189
|
-
protected getStepArgs(scope: A_Scope, step: A_TYPES__A_StageStep): Promise<(A_Container | A_Component | A_Entity<any, A_TYPES__Entity_Serialized> | A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any>[]> | A_Feature<A_TYPES__FeatureAvailableComponents> | A_Fragment<any> | A_TYPES__ScopeResolvableComponents[] | undefined)[]>;
|
|
1189
|
+
protected getStepArgs(scope: A_Scope, step: A_TYPES__A_StageStep): Promise<(A_Container | A_Component | A_Entity<any, A_TYPES__Entity_Serialized> | A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any, any>[]> | A_Feature<A_TYPES__FeatureAvailableComponents> | A_Fragment<any, any> | A_TYPES__ScopeResolvableComponents[] | undefined)[]>;
|
|
1190
1190
|
/**
|
|
1191
1191
|
* Resolves the component of the step
|
|
1192
1192
|
*
|
|
@@ -2172,7 +2172,7 @@ declare class A_Concept<_Imports extends A_Container[] = A_Container[]> {
|
|
|
2172
2172
|
/**
|
|
2173
2173
|
* The primary Root scope of the concept.
|
|
2174
2174
|
*/
|
|
2175
|
-
get scope(): A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any>[]>;
|
|
2175
|
+
get scope(): A_Scope<A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<any, any>[]>;
|
|
2176
2176
|
/**
|
|
2177
2177
|
* Register a class or value in the concept scope.
|
|
2178
2178
|
*/
|
|
@@ -2227,39 +2227,250 @@ declare class A_Concept<_Imports extends A_Container[] = A_Container[]> {
|
|
|
2227
2227
|
container: _Imports[number]): Promise<void>;
|
|
2228
2228
|
}
|
|
2229
2229
|
|
|
2230
|
-
|
|
2230
|
+
/**
|
|
2231
|
+
* A_Fragment is a core architectural component that represents a singleton execution context
|
|
2232
|
+
* within the A-Concept framework. It serves as a shared memory container that can be passed
|
|
2233
|
+
* between Components, Entities, and Commands throughout the application pipeline.
|
|
2234
|
+
*
|
|
2235
|
+
* Key Features:
|
|
2236
|
+
* - Singleton pattern: Only one instance per fragment type per scope
|
|
2237
|
+
* - Meta storage: Built-in key-value storage for pipeline data
|
|
2238
|
+
* - Type-safe: Full TypeScript generics support for meta items and serialization
|
|
2239
|
+
* - Serializable: Can be converted to JSON for persistence or transmission
|
|
2240
|
+
*
|
|
2241
|
+
* @template _MetaItems - Type definition for the meta storage structure
|
|
2242
|
+
* @template _SerializedType - Type definition for the serialized output format
|
|
2243
|
+
*
|
|
2244
|
+
* @example
|
|
2245
|
+
* ```typescript
|
|
2246
|
+
* // Basic usage with typed meta
|
|
2247
|
+
* class UserFragment extends A_Fragment<{ userId: string; role: string }> {
|
|
2248
|
+
* constructor() {
|
|
2249
|
+
* super({ name: 'UserFragment' });
|
|
2250
|
+
* }
|
|
2251
|
+
* }
|
|
2252
|
+
*
|
|
2253
|
+
* // Custom serialization
|
|
2254
|
+
* class SessionFragment extends A_Fragment<
|
|
2255
|
+
* { sessionId: string; timestamp: number },
|
|
2256
|
+
* { name: string; sessionData: string }
|
|
2257
|
+
* > {
|
|
2258
|
+
* toJSON() {
|
|
2259
|
+
* return {
|
|
2260
|
+
* name: this.name,
|
|
2261
|
+
* sessionData: `${this.get('sessionId')}-${this.get('timestamp')}`
|
|
2262
|
+
* };
|
|
2263
|
+
* }
|
|
2264
|
+
* }
|
|
2265
|
+
* ```
|
|
2266
|
+
*/
|
|
2267
|
+
declare class A_Fragment<_MetaItems extends Record<string, any> = any, _SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized & _MetaItems> {
|
|
2231
2268
|
/**
|
|
2232
|
-
*
|
|
2269
|
+
* The unique identifier/name for this fragment instance.
|
|
2270
|
+
* Used for identification and debugging purposes.
|
|
2233
2271
|
*/
|
|
2234
|
-
|
|
2272
|
+
protected _name: string;
|
|
2235
2273
|
/**
|
|
2236
|
-
*
|
|
2274
|
+
* Internal meta storage using A_Meta for type-safe key-value operations.
|
|
2275
|
+
* This stores all the fragment's runtime data that can be accessed and modified
|
|
2276
|
+
* throughout the execution pipeline.
|
|
2237
2277
|
*/
|
|
2238
|
-
protected _meta: A_Meta<
|
|
2278
|
+
protected _meta: A_Meta<_MetaItems>;
|
|
2239
2279
|
/**
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2280
|
+
* Creates a new A_Fragment instance.
|
|
2281
|
+
*
|
|
2282
|
+
* A_Fragment implements the singleton pattern for execution contexts, allowing
|
|
2283
|
+
* shared state management across different parts of the application pipeline.
|
|
2284
|
+
* Each fragment serves as a memory container that can store typed data and be
|
|
2285
|
+
* serialized for persistence or transmission.
|
|
2243
2286
|
*
|
|
2287
|
+
* Key Benefits:
|
|
2288
|
+
* - Centralized state management for related operations
|
|
2289
|
+
* - Type-safe meta operations with full IntelliSense support
|
|
2290
|
+
* - Serialization support for data persistence
|
|
2291
|
+
* - Singleton pattern ensures consistent state within scope
|
|
2244
2292
|
*
|
|
2245
|
-
*
|
|
2246
|
-
*
|
|
2293
|
+
* @param params - Initialization parameters
|
|
2294
|
+
* @param params.name - Optional custom name for the fragment (defaults to class name)
|
|
2295
|
+
*
|
|
2296
|
+
* @example
|
|
2297
|
+
* ```typescript
|
|
2298
|
+
* const fragment = new A_Fragment<{ userId: string }>({
|
|
2299
|
+
* name: 'UserSessionFragment'
|
|
2300
|
+
* });
|
|
2301
|
+
* fragment.set('userId', '12345');
|
|
2302
|
+
* ```
|
|
2247
2303
|
*/
|
|
2248
2304
|
constructor(params?: Partial<A_TYPES__Fragment_Init>);
|
|
2249
2305
|
/**
|
|
2250
|
-
*
|
|
2306
|
+
* Gets the fragment's unique name/identifier.
|
|
2251
2307
|
*
|
|
2252
|
-
* @returns
|
|
2308
|
+
* @returns The fragment name
|
|
2253
2309
|
*/
|
|
2254
|
-
get
|
|
2310
|
+
get name(): string;
|
|
2255
2311
|
/**
|
|
2256
|
-
*
|
|
2312
|
+
* Gets direct access to the underlying Meta object for advanced meta operations.
|
|
2257
2313
|
*
|
|
2258
|
-
*
|
|
2314
|
+
* Use this when you need to perform bulk operations or access Meta-specific methods.
|
|
2315
|
+
* For simple get/set operations, prefer using the direct methods on the fragment.
|
|
2316
|
+
*
|
|
2317
|
+
* @returns The Meta instance containing the fragment's meta
|
|
2318
|
+
*
|
|
2319
|
+
* @example
|
|
2320
|
+
* ```typescript
|
|
2321
|
+
* const fragment = new A_Fragment<{ users: string[], count: number }>();
|
|
2322
|
+
*
|
|
2323
|
+
* // Advanced operations using meta
|
|
2324
|
+
* fragment.meta.setMultiple({
|
|
2325
|
+
* users: ['alice', 'bob'],
|
|
2326
|
+
* count: 2
|
|
2327
|
+
* });
|
|
2328
|
+
*
|
|
2329
|
+
* // Get all keys
|
|
2330
|
+
* const keys = fragment.meta.keys();
|
|
2331
|
+
* ```
|
|
2259
2332
|
*/
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2333
|
+
get meta(): A_Meta<_MetaItems>;
|
|
2334
|
+
/**
|
|
2335
|
+
* Checks if a specific meta key exists in the fragment.
|
|
2336
|
+
*
|
|
2337
|
+
* @param param - The key to check for existence
|
|
2338
|
+
* @returns True if the key exists, false otherwise
|
|
2339
|
+
*
|
|
2340
|
+
* @example
|
|
2341
|
+
* ```typescript
|
|
2342
|
+
* if (fragment.has('userId')) {
|
|
2343
|
+
* console.log('User ID is set');
|
|
2344
|
+
* }
|
|
2345
|
+
* ```
|
|
2346
|
+
*/
|
|
2347
|
+
has(param: keyof _MetaItems): boolean;
|
|
2348
|
+
/**
|
|
2349
|
+
* Retrieves a value from the fragment's meta.
|
|
2350
|
+
*
|
|
2351
|
+
* @param param - The key to retrieve
|
|
2352
|
+
* @returns The value associated with the key, or undefined if not found
|
|
2353
|
+
*
|
|
2354
|
+
* @example
|
|
2355
|
+
* ```typescript
|
|
2356
|
+
* const userId = fragment.get('userId');
|
|
2357
|
+
* if (userId) {
|
|
2358
|
+
* console.log(`Current user: ${userId}`);
|
|
2359
|
+
* }
|
|
2360
|
+
* ```
|
|
2361
|
+
*/
|
|
2362
|
+
get<K extends keyof _MetaItems>(param: K): _MetaItems[K] | undefined;
|
|
2363
|
+
/**
|
|
2364
|
+
* Stores a value in the fragment's meta.
|
|
2365
|
+
*
|
|
2366
|
+
* @param param - The key to store the value under
|
|
2367
|
+
* @param value - The value to store
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* ```typescript
|
|
2371
|
+
* fragment.set('userId', '12345');
|
|
2372
|
+
* fragment.set('role', 'admin');
|
|
2373
|
+
* ```
|
|
2374
|
+
*/
|
|
2375
|
+
set<K extends keyof _MetaItems>(param: K, value: _MetaItems[K]): void;
|
|
2376
|
+
/**
|
|
2377
|
+
* Removes a specific key from the fragment's meta.
|
|
2378
|
+
*
|
|
2379
|
+
* @param param - The key to remove
|
|
2380
|
+
*
|
|
2381
|
+
* @example
|
|
2382
|
+
* ```typescript
|
|
2383
|
+
* fragment.drop('temporaryData');
|
|
2384
|
+
* ```
|
|
2385
|
+
*/
|
|
2386
|
+
drop(param: keyof _MetaItems): void;
|
|
2387
|
+
/**
|
|
2388
|
+
* Clears all data from the fragment's meta.
|
|
2389
|
+
*
|
|
2390
|
+
* Use with caution as this will remove all stored data in the fragment.
|
|
2391
|
+
*
|
|
2392
|
+
* @example
|
|
2393
|
+
* ```typescript
|
|
2394
|
+
* fragment.clear(); // All meta data is now gone
|
|
2395
|
+
* ```
|
|
2396
|
+
*/
|
|
2397
|
+
clear(): void;
|
|
2398
|
+
/**
|
|
2399
|
+
* Gets the number of items stored in the fragment's meta.
|
|
2400
|
+
*
|
|
2401
|
+
* @returns The count of stored meta items
|
|
2402
|
+
*
|
|
2403
|
+
* @example
|
|
2404
|
+
* ```typescript
|
|
2405
|
+
* console.log(`Fragment contains ${fragment.size()} items`);
|
|
2406
|
+
* ```
|
|
2407
|
+
*/
|
|
2408
|
+
size(): number;
|
|
2409
|
+
/**
|
|
2410
|
+
* Gets all keys currently stored in the fragment's meta.
|
|
2411
|
+
*
|
|
2412
|
+
* @returns Array of all meta keys
|
|
2413
|
+
*
|
|
2414
|
+
* @example
|
|
2415
|
+
* ```typescript
|
|
2416
|
+
* const keys = fragment.keys();
|
|
2417
|
+
* console.log('Stored keys:', keys);
|
|
2418
|
+
* ```
|
|
2419
|
+
*/
|
|
2420
|
+
keys(): (keyof _MetaItems)[];
|
|
2421
|
+
/**
|
|
2422
|
+
* Sets multiple values at once in the fragment's meta.
|
|
2423
|
+
*
|
|
2424
|
+
* @param data - Object containing key-value pairs to set
|
|
2425
|
+
*
|
|
2426
|
+
* @example
|
|
2427
|
+
* ```typescript
|
|
2428
|
+
* fragment.setMultiple({
|
|
2429
|
+
* userId: '12345',
|
|
2430
|
+
* role: 'admin',
|
|
2431
|
+
* lastLogin: new Date()
|
|
2432
|
+
* });
|
|
2433
|
+
* ```
|
|
2434
|
+
*/
|
|
2435
|
+
setMultiple(data: A_TYPES__DeepPartial<_MetaItems>): void;
|
|
2436
|
+
/**
|
|
2437
|
+
* Creates a shallow copy of the fragment with the same meta data.
|
|
2438
|
+
*
|
|
2439
|
+
* @param newName - Optional new name for the cloned fragment
|
|
2440
|
+
* @returns A new fragment instance with copied meta
|
|
2441
|
+
*
|
|
2442
|
+
* @example
|
|
2443
|
+
* ```typescript
|
|
2444
|
+
* const original = new A_Fragment<{ data: string }>({ name: 'original' });
|
|
2445
|
+
* original.set('data', 'test');
|
|
2446
|
+
*
|
|
2447
|
+
* const clone = original.clone('cloned');
|
|
2448
|
+
* console.log(clone.get('data')); // 'test'
|
|
2449
|
+
* ```
|
|
2450
|
+
*/
|
|
2451
|
+
clone(newName?: string): A_Fragment<_MetaItems, _SerializedType>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Serializes the fragment to a JSON-compatible object.
|
|
2454
|
+
*
|
|
2455
|
+
* This method combines the fragment's name with all meta data to create
|
|
2456
|
+
* a serializable representation. The return type is determined by the
|
|
2457
|
+
* _SerializedType generic parameter, allowing for custom serialization formats.
|
|
2458
|
+
*
|
|
2459
|
+
* @returns A serialized representation of the fragment
|
|
2460
|
+
*
|
|
2461
|
+
* @example
|
|
2462
|
+
* ```typescript
|
|
2463
|
+
* const fragment = new A_Fragment<{ userId: string, role: string }>({
|
|
2464
|
+
* name: 'UserFragment'
|
|
2465
|
+
* });
|
|
2466
|
+
* fragment.set('userId', '12345');
|
|
2467
|
+
* fragment.set('role', 'admin');
|
|
2468
|
+
*
|
|
2469
|
+
* const json = fragment.toJSON();
|
|
2470
|
+
* // Result: { name: 'UserFragment', userId: '12345', role: 'admin' }
|
|
2471
|
+
* ```
|
|
2472
|
+
*/
|
|
2473
|
+
toJSON(): _SerializedType;
|
|
2263
2474
|
}
|
|
2264
2475
|
|
|
2265
2476
|
/**
|
|
@@ -2278,9 +2489,9 @@ type A_TYPES__Fragment_Init = {
|
|
|
2278
2489
|
*/
|
|
2279
2490
|
type A_TYPES__Fragment_Serialized = {
|
|
2280
2491
|
/**
|
|
2281
|
-
* The
|
|
2492
|
+
* The Name of the fragment
|
|
2282
2493
|
*/
|
|
2283
|
-
|
|
2494
|
+
name: string;
|
|
2284
2495
|
};
|
|
2285
2496
|
|
|
2286
2497
|
/**
|