@vived/host 4.11.1 → 4.12.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/cjs/Apps/Factories/AppsFeatureFactory.js +2 -3
- package/dist/cjs/Apps/Factories/AppsFeatureFactory.js.map +1 -1
- package/dist/cjs/Assets/Controllers/fetchAssetFile.js +42 -0
- package/dist/cjs/Assets/Controllers/fetchAssetFile.js.map +1 -0
- package/dist/cjs/Assets/Controllers/index.js +1 -0
- package/dist/cjs/Assets/Controllers/index.js.map +1 -1
- package/dist/cjs/Assets/Factories/AssetsFactory.js +8 -19
- package/dist/cjs/Assets/Factories/AssetsFactory.js.map +1 -1
- package/dist/cjs/Assets/UCs/GetAssetBlobURLUC.js +8 -1
- package/dist/cjs/Assets/UCs/GetAssetBlobURLUC.js.map +1 -1
- package/dist/cjs/Cache/Factories/CacheFeatureFactory.js +51 -0
- package/dist/cjs/Cache/Factories/CacheFeatureFactory.js.map +1 -0
- package/dist/cjs/Cache/Factories/index.js +1 -0
- package/dist/cjs/Cache/Factories/index.js.map +1 -1
- package/dist/esm/Apps/Factories/AppsFeatureFactory.js +2 -3
- package/dist/esm/Apps/Factories/AppsFeatureFactory.js.map +1 -1
- package/dist/esm/Assets/Controllers/fetchAssetFile.js +39 -0
- package/dist/esm/Assets/Controllers/fetchAssetFile.js.map +1 -0
- package/dist/esm/Assets/Controllers/index.js +1 -0
- package/dist/esm/Assets/Controllers/index.js.map +1 -1
- package/dist/esm/Assets/Factories/AssetsFactory.js +11 -22
- package/dist/esm/Assets/Factories/AssetsFactory.js.map +1 -1
- package/dist/esm/Assets/UCs/GetAssetBlobURLUC.js +8 -1
- package/dist/esm/Assets/UCs/GetAssetBlobURLUC.js.map +1 -1
- package/dist/esm/Cache/Factories/CacheFeatureFactory.js +47 -0
- package/dist/esm/Cache/Factories/CacheFeatureFactory.js.map +1 -0
- package/dist/esm/Cache/Factories/index.js +1 -0
- package/dist/esm/Cache/Factories/index.js.map +1 -1
- package/dist/types/Apps/Factories/AppsFeatureFactory.d.ts +0 -1
- package/dist/types/Apps/Factories/AppsFeatureFactory.d.ts.map +1 -1
- package/dist/types/Assets/Controllers/fetchAssetFile.d.ts +32 -0
- package/dist/types/Assets/Controllers/fetchAssetFile.d.ts.map +1 -0
- package/dist/types/Assets/Controllers/index.d.ts +1 -0
- package/dist/types/Assets/Controllers/index.d.ts.map +1 -1
- package/dist/types/Assets/Factories/AssetsFactory.d.ts +0 -3
- package/dist/types/Assets/Factories/AssetsFactory.d.ts.map +1 -1
- package/dist/types/Assets/UCs/GetAssetBlobURLUC.d.ts +2 -1
- package/dist/types/Assets/UCs/GetAssetBlobURLUC.d.ts.map +1 -1
- package/dist/types/Cache/Factories/CacheFeatureFactory.d.ts +27 -0
- package/dist/types/Cache/Factories/CacheFeatureFactory.d.ts.map +1 -0
- package/dist/types/Cache/Factories/index.d.ts +1 -0
- package/dist/types/Cache/Factories/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -19,9 +19,8 @@ class AppsFeatureFactory extends core_1.DomainFactory {
|
|
|
19
19
|
* Sets up all entities required for the Apps system
|
|
20
20
|
*/
|
|
21
21
|
setupEntities() {
|
|
22
|
-
this.appRepoAO = this.appObjects.getOrCreate("App Repository");
|
|
23
22
|
// Initialize entities
|
|
24
|
-
(0, Entities_1.makeAppRepo)(this.
|
|
23
|
+
(0, Entities_1.makeAppRepo)(this.appObject);
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* Sets up all use cases for the Apps system
|
|
@@ -35,7 +34,7 @@ class AppsFeatureFactory extends core_1.DomainFactory {
|
|
|
35
34
|
*/
|
|
36
35
|
setupPMs() {
|
|
37
36
|
// App Repository PMs
|
|
38
|
-
(0, PMs_1.makeAppsListPM)(this.
|
|
37
|
+
(0, PMs_1.makeAppsListPM)(this.appObject);
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
* Performs any final setup operations after all components are initialized
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppsFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Apps/Factories/AppsFeatureFactory.ts"],"names":[],"mappings":";;;AAAA,sCAAuD;AACvD,0CAAyD;AACzD,gCAAmD;AAEnD;;;;GAIG;AACH,MAAa,kBAAmB,SAAQ,oBAAa;
|
|
1
|
+
{"version":3,"file":"AppsFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Apps/Factories/AppsFeatureFactory.ts"],"names":[],"mappings":";;;AAAA,sCAAuD;AACvD,0CAAyD;AACzD,gCAAmD;AAEnD;;;;GAIG;AACH,MAAa,kBAAmB,SAAQ,oBAAa;IAInD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QAJnB,+BAA+B;QACtB,gBAAW,GAAG,oBAAoB,CAAC;IAI5C,CAAC;IAED;;OAEG;IACH,aAAa;QACX,sBAAsB;QACtB,IAAA,sBAAW,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,+DAA+D;QAC/D,0EAA0E;IAC5E,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,qBAAqB;QACrB,IAAA,oBAAc,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,wCAAwC;IAC1C,CAAC;CACF;AAtCD,gDAsCC","sourcesContent":["import { AppObject, DomainFactory } from \"@vived/core\";\r\nimport { makeAppEntity, makeAppRepo } from \"../Entities\";\r\nimport { makeAppPM, makeAppsListPM } from \"../PMs\";\r\n\r\n/**\r\n * Factory responsible for setting up the Apps domain components.\r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Apps functionality.\r\n */\r\nexport class AppsFeatureFactory extends DomainFactory {\r\n // Unique name for this factory\r\n readonly factoryName = \"AppsFeatureFactory\";\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n\r\n /**\r\n * Sets up all entities required for the Apps system\r\n */\r\n setupEntities(): void {\r\n // Initialize entities\r\n makeAppRepo(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all use cases for the Apps system\r\n */\r\n setupUCs(): void {\r\n // Note: App UCs have complex dependencies and should be set up\r\n // separately to avoid circular dependencies during factory initialization\r\n }\r\n\r\n /**\r\n * Sets up all presentation managers for the Apps system\r\n */\r\n setupPMs(): void {\r\n // App Repository PMs\r\n makeAppsListPM(this.appObject);\r\n }\r\n\r\n /**\r\n * Performs any final setup operations after all components are initialized\r\n */\r\n finalSetup(): void {\r\n // No additional setup required for apps\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* fetchAssetFile.ts
|
|
4
|
+
*
|
|
5
|
+
* This controller function retrieves an asset file as a File object,
|
|
6
|
+
* handling caching and error management for file access operations.
|
|
7
|
+
*
|
|
8
|
+
* Key Concepts:
|
|
9
|
+
* - Retrieves asset files as File objects for download or processing
|
|
10
|
+
* - Uses GetAssetFileUC to handle caching and file retrieval logic
|
|
11
|
+
* - Provides error handling for missing components
|
|
12
|
+
* - Coordinates with asset file management workflows
|
|
13
|
+
*
|
|
14
|
+
* Usage Patterns:
|
|
15
|
+
* - Called from UI components when users need asset file access
|
|
16
|
+
* - Used in asset management workflows for file processing
|
|
17
|
+
* - Integrated with download and preview functionality
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.fetchAssetFile = fetchAssetFile;
|
|
21
|
+
const GetAssetFileUC_1 = require("../UCs/GetAssetFileUC");
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves an asset file as a File object.
|
|
24
|
+
*
|
|
25
|
+
* This function provides a controller-level interface for asset file retrieval.
|
|
26
|
+
* It handles the complete file access workflow including caching optimization,
|
|
27
|
+
* error handling, and returns a File object ready for use in web applications.
|
|
28
|
+
*
|
|
29
|
+
* @param assetID - The unique identifier of the asset whose file should be retrieved
|
|
30
|
+
* @param appObjects - Repository for accessing asset-related app objects and components
|
|
31
|
+
* @returns Promise<File> - A promise that resolves to the File object for the asset,
|
|
32
|
+
* or undefined if the operation cannot be completed
|
|
33
|
+
*/
|
|
34
|
+
function fetchAssetFile(assetID, appObjects) {
|
|
35
|
+
const uc = GetAssetFileUC_1.GetAssetFileUC.get(appObjects);
|
|
36
|
+
if (!uc) {
|
|
37
|
+
appObjects.submitWarning("fetchAssetFile", "Unable to find GetAssetFileUC");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return uc.getAssetFile(assetID);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=fetchAssetFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAssetFile.js","sourceRoot":"","sources":["../../../../src/Assets/Controllers/fetchAssetFile.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAiBH,wCAWC;AAzBD,0DAAuD;AAEvD;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAC5B,OAAe,EACf,UAAyB;IAEzB,MAAM,EAAE,GAAG,+BAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,UAAU,CAAC,aAAa,CAAC,gBAAgB,EAAE,+BAA+B,CAAC,CAAC;QAC5E,OAAO;IACT,CAAC;IAED,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\r\n * fetchAssetFile.ts\r\n *\r\n * This controller function retrieves an asset file as a File object,\r\n * handling caching and error management for file access operations.\r\n *\r\n * Key Concepts:\r\n * - Retrieves asset files as File objects for download or processing\r\n * - Uses GetAssetFileUC to handle caching and file retrieval logic\r\n * - Provides error handling for missing components\r\n * - Coordinates with asset file management workflows\r\n *\r\n * Usage Patterns:\r\n * - Called from UI components when users need asset file access\r\n * - Used in asset management workflows for file processing\r\n * - Integrated with download and preview functionality\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { GetAssetFileUC } from \"../UCs/GetAssetFileUC\";\r\n\r\n/**\r\n * Retrieves an asset file as a File object.\r\n *\r\n * This function provides a controller-level interface for asset file retrieval.\r\n * It handles the complete file access workflow including caching optimization,\r\n * error handling, and returns a File object ready for use in web applications.\r\n *\r\n * @param assetID - The unique identifier of the asset whose file should be retrieved\r\n * @param appObjects - Repository for accessing asset-related app objects and components\r\n * @returns Promise<File> - A promise that resolves to the File object for the asset,\r\n * or undefined if the operation cannot be completed\r\n */\r\nexport function fetchAssetFile(\r\n assetID: string,\r\n appObjects: AppObjectRepo\r\n): Promise<File> | undefined {\r\n const uc = GetAssetFileUC.get(appObjects);\r\n if (!uc) {\r\n appObjects.submitWarning(\"fetchAssetFile\", \"Unable to find GetAssetFileUC\");\r\n return;\r\n }\r\n\r\n return uc.getAssetFile(assetID);\r\n}\r\n"]}
|
|
@@ -37,6 +37,7 @@ __exportStar(require("./archiveAsset"), exports);
|
|
|
37
37
|
__exportStar(require("./deleteAsset"), exports);
|
|
38
38
|
__exportStar(require("./downloadAssetFile"), exports);
|
|
39
39
|
__exportStar(require("./editAppAsset"), exports);
|
|
40
|
+
__exportStar(require("./fetchAssetFile"), exports);
|
|
40
41
|
__exportStar(require("./getAppAssets"), exports);
|
|
41
42
|
__exportStar(require("./newAppAsset"), exports);
|
|
42
43
|
__exportStar(require("./toggleShowArchivedAssets"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Assets/Controllers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,gDAA8B;AAC9B,sDAAoC;AACpC,iDAA+B;AAC/B,iDAA+B;AAC/B,gDAA8B;AAC9B,6DAA2C;AAC3C,uDAAqC;AACrC,oDAAkC","sourcesContent":["/**\r\n * Assets Controllers Index\r\n *\r\n * This module exports all controller functions for the Assets feature.\r\n * Controllers provide simple, stateless functions that serve as entry points\r\n * for asset-related operations from UI components and external systems.\r\n *\r\n * Key Concepts:\r\n * - Controllers act as the interface layer between UI components and business logic\r\n * - Each controller function handles a specific asset operation\r\n * - Controllers delegate to Use Cases (UCs) for actual business logic implementation\r\n * - Error handling and validation are performed at the controller level\r\n *\r\n * Available Operations:\r\n * - Asset lifecycle: create, edit, delete, archive\r\n * - File management: upload, download, update\r\n * - Collection management: get app assets, toggle archived visibility\r\n * - Metadata management: update asset information\r\n */\r\n\r\nexport * from \"./archiveAsset\";\r\nexport * from \"./deleteAsset\";\r\nexport * from \"./downloadAssetFile\";\r\nexport * from \"./editAppAsset\";\r\nexport * from \"./getAppAssets\";\r\nexport * from \"./newAppAsset\";\r\nexport * from \"./toggleShowArchivedAssets\";\r\nexport * from \"./updateAppAssetMeta\";\r\nexport * from \"./updateAssetFile\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Assets/Controllers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,gDAA8B;AAC9B,sDAAoC;AACpC,iDAA+B;AAC/B,mDAAiC;AACjC,iDAA+B;AAC/B,gDAA8B;AAC9B,6DAA2C;AAC3C,uDAAqC;AACrC,oDAAkC","sourcesContent":["/**\r\n * Assets Controllers Index\r\n *\r\n * This module exports all controller functions for the Assets feature.\r\n * Controllers provide simple, stateless functions that serve as entry points\r\n * for asset-related operations from UI components and external systems.\r\n *\r\n * Key Concepts:\r\n * - Controllers act as the interface layer between UI components and business logic\r\n * - Each controller function handles a specific asset operation\r\n * - Controllers delegate to Use Cases (UCs) for actual business logic implementation\r\n * - Error handling and validation are performed at the controller level\r\n *\r\n * Available Operations:\r\n * - Asset lifecycle: create, edit, delete, archive\r\n * - File management: upload, download, update\r\n * - Collection management: get app assets, toggle archived visibility\r\n * - Metadata management: update asset information\r\n */\r\n\r\nexport * from \"./archiveAsset\";\r\nexport * from \"./deleteAsset\";\r\nexport * from \"./downloadAssetFile\";\r\nexport * from \"./editAppAsset\";\r\nexport * from \"./fetchAssetFile\";\r\nexport * from \"./getAppAssets\";\r\nexport * from \"./newAppAsset\";\r\nexport * from \"./toggleShowArchivedAssets\";\r\nexport * from \"./updateAppAssetMeta\";\r\nexport * from \"./updateAssetFile\";\r\n"]}
|
|
@@ -20,12 +20,9 @@ class AssetsFactory extends core_1.DomainFactory {
|
|
|
20
20
|
* Sets up all entities required for the Assets system
|
|
21
21
|
*/
|
|
22
22
|
setupEntities() {
|
|
23
|
-
this.assetRepoAO = this.appObjects.getOrCreate("Asset Repository");
|
|
24
|
-
this.appAssetsAO = this.appObjects.getOrCreate("App Assets");
|
|
25
23
|
// Initialize entities
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
(0, Entities_1.makeAppAssets)(this.appAssetsAO);
|
|
24
|
+
const assetRepo = (0, Entities_1.makeAssetRepo)(this.appObject);
|
|
25
|
+
assetRepo.assetFactory = this.makeAssetFactory();
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
31
28
|
* Creates an asset factory function that properly initializes assets with all required components
|
|
@@ -40,7 +37,6 @@ class AssetsFactory extends core_1.DomainFactory {
|
|
|
40
37
|
(0, UCs_1.makeDeleteAssetUC)(ao);
|
|
41
38
|
(0, UCs_1.makeDownloadAssetFileUC)(ao);
|
|
42
39
|
(0, UCs_1.makeUpdateAssetFileUC)(ao);
|
|
43
|
-
(0, UCs_1.makeUpdateAppAssetMetaUC)(ao);
|
|
44
40
|
// PMs for each asset
|
|
45
41
|
(0, PMs_1.makeAssetPM)(ao);
|
|
46
42
|
(0, PMs_1.makeAssetFilePM)(ao);
|
|
@@ -52,24 +48,17 @@ class AssetsFactory extends core_1.DomainFactory {
|
|
|
52
48
|
*/
|
|
53
49
|
setupUCs() {
|
|
54
50
|
// Repository UCs
|
|
55
|
-
(0, UCs_1.
|
|
56
|
-
(0, UCs_1.
|
|
57
|
-
(0, UCs_1.
|
|
58
|
-
(0, UCs_1.
|
|
59
|
-
(0, UCs_1.
|
|
60
|
-
(0, UCs_1.makeNewAssetUC)(this.assetRepoAO);
|
|
61
|
-
// App Assets UCs
|
|
62
|
-
(0, UCs_1.makeNewAppAssetUC)(this.appAssetsAO);
|
|
63
|
-
(0, UCs_1.makeGetAppAssetUC)(this.appAssetsAO);
|
|
51
|
+
(0, UCs_1.makeGetAssetBlobURLUC)(this.appObject);
|
|
52
|
+
(0, UCs_1.makeGetAssetFileUC)(this.appObject);
|
|
53
|
+
(0, UCs_1.makeGetAssetUC)(this.appObject);
|
|
54
|
+
(0, UCs_1.makePrefetchAssets)(this.appObject);
|
|
55
|
+
(0, UCs_1.makeNewAssetUC)(this.appObject);
|
|
64
56
|
}
|
|
65
57
|
/**
|
|
66
58
|
* Sets up all presentation managers for the Assets system
|
|
67
59
|
*/
|
|
68
60
|
setupPMs() {
|
|
69
|
-
//
|
|
70
|
-
(0, PMs_1.makeAppAssetListPM)(this.appAssetsAO);
|
|
71
|
-
(0, PMs_1.makeShowArchivedAppAssetPM)(this.appAssetsAO);
|
|
72
|
-
(0, PMs_1.makeEditingAppAssetPM)(this.appAssetsAO);
|
|
61
|
+
// No PMs needed for core asset functionality
|
|
73
62
|
}
|
|
74
63
|
/**
|
|
75
64
|
* Performs any final setup operations after all components are initialized
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsFactory.js","sourceRoot":"","sources":["../../../../src/Assets/Factories/AssetsFactory.ts"],"names":[],"mappings":";;;AAAA,sCAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"AssetsFactory.js","sourceRoot":"","sources":["../../../../src/Assets/Factories/AssetsFactory.ts"],"names":[],"mappings":";;;AAAA,sCAAsE;AACtE,0CAIqB;AACrB,gCAGgB;AAChB,gCAUgB;AAEhB;;;;GAIG;AACH,MAAa,aAAc,SAAQ,oBAAa;IAI9C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C/C,CAAC;IAED;;OAEG;IACH,UAAU;QACR,0CAA0C;IAC5C,CAAC;CACF;AAlED,sCAkEC","sourcesContent":["import { AppObject, AppObjectRepo, DomainFactory } from \"@vived/core\";\r\nimport {\r\n AssetEntity,\r\n makeAssetEntity,\r\n makeAssetRepo\r\n} from \"../Entities\";\r\nimport {\r\n makeAssetFilePM,\r\n makeAssetPM\r\n} from \"../PMs\";\r\nimport {\r\n makeArchiveAssetUC,\r\n makeDeleteAssetUC,\r\n makeDownloadAssetFileUC,\r\n makeGetAssetBlobURLUC,\r\n makeGetAssetFileUC,\r\n makeGetAssetUC,\r\n makeNewAssetUC,\r\n makePrefetchAssets,\r\n makeUpdateAssetFileUC\r\n} from \"../UCs\";\r\n\r\n/**\r\n * Factory responsible for setting up the Assets domain components.\r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Assets functionality.\r\n */\r\nexport class AssetsFactory extends DomainFactory {\r\n // Unique name for this factory\r\n readonly factoryName = \"AssetsFactory\";\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n\r\n /**\r\n * Sets up all entities required for the Assets system\r\n */\r\n setupEntities(): void {\r\n // Initialize entities\r\n const assetRepo = makeAssetRepo(this.appObject);\r\n assetRepo.assetFactory = this.makeAssetFactory();\r\n }\r\n\r\n /**\r\n * Creates an asset factory function that properly initializes assets with all required components\r\n */\r\n private makeAssetFactory() {\r\n return (id: string): AssetEntity => {\r\n const ao = this.appObjects.getOrCreate(id);\r\n\r\n // Entities\r\n const entity = makeAssetEntity(ao);\r\n\r\n // UCs for each asset\r\n makeArchiveAssetUC(ao);\r\n makeDeleteAssetUC(ao);\r\n makeDownloadAssetFileUC(ao);\r\n makeUpdateAssetFileUC(ao);\r\n\r\n // PMs for each asset\r\n makeAssetPM(ao);\r\n makeAssetFilePM(ao);\r\n\r\n return entity;\r\n };\r\n }\r\n\r\n /**\r\n * Sets up all use cases for the Assets system\r\n */\r\n setupUCs(): void {\r\n // Repository UCs\r\n makeGetAssetBlobURLUC(this.appObject);\r\n makeGetAssetFileUC(this.appObject);\r\n makeGetAssetUC(this.appObject);\r\n makePrefetchAssets(this.appObject);\r\n makeNewAssetUC(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all presentation managers for the Assets system\r\n */\r\n setupPMs(): void {\r\n // No PMs needed for core asset functionality\r\n }\r\n\r\n /**\r\n * Performs any final setup operations after all components are initialized\r\n */\r\n finalSetup(): void {\r\n // No additional setup required for assets\r\n }\r\n}\r\n"]}
|
|
@@ -107,9 +107,10 @@ class GetAssetBlobURLUCImp extends GetAssetBlobURLUC {
|
|
|
107
107
|
* population of higher-level caches for future access optimization.
|
|
108
108
|
*
|
|
109
109
|
* @param assetID - The unique identifier of the asset
|
|
110
|
+
* @param useCache - Optional flag to control caching behavior (defaults to true)
|
|
110
111
|
* @returns Promise resolving to a blob URL for the asset file
|
|
111
112
|
*/
|
|
112
|
-
this.getAssetBlobURL = (assetID) => {
|
|
113
|
+
this.getAssetBlobURL = (assetID, useCache = true) => {
|
|
113
114
|
const assetRepo = this.assetRepo;
|
|
114
115
|
const getAsset = this.getAsset;
|
|
115
116
|
const fetchAssetFile = this.fetchAssetFile;
|
|
@@ -118,6 +119,12 @@ class GetAssetBlobURLUCImp extends GetAssetBlobURLUC {
|
|
|
118
119
|
if (!assetRepo || !getAsset || !fetchAssetFile) {
|
|
119
120
|
return Promise.reject();
|
|
120
121
|
}
|
|
122
|
+
// If cache is disabled, skip all cache checks and go directly to API
|
|
123
|
+
if (!useCache) {
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
this.fetchAssetNormally(assetID, resolve, reject);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
121
128
|
// Level 1: Check memory cache (existing entities with blob URLs)
|
|
122
129
|
const existing = assetRepo.get(assetID);
|
|
123
130
|
if (existing && existing.blobURL) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetAssetBlobURLUC.js","sourceRoot":"","sources":["../../../../src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AC3B,YAAY,CAAC,cAAc,GAAG,KAAK,CAAC;oBAEpC,wDAAwD;oBACxD,IAAI,iBAAiB,EAAE,CAAC;wBACtB,iBAAiB,CACf,OAAO,EACP,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EACrC,IAAI,CAAC,IAAI,CACV,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;4BACZ,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;wBACnD,CAAC,CAAC,CAAC;oBACL,CAAC;oBAED,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBACzB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;wBAC9B,OAAO;oBACT,CAAC;gBACH,CAAC;gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;gBAClB,gDAAgD;gBAChD,IAAI,YAAY,EAAE,CAAC;oBACjB,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;oBAC5B,YAAY,CAAC,cAAc,GAAG,KAAK,CAAC;gBACtC,CAAC;gBACD,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QASA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * GetAssetBlobURLUC.ts\r\n *\r\n * This use case provides optimized asset file retrieval with caching support,\r\n * returning blob URLs for immediate use in web applications.\r\n *\r\n * Key Concepts:\r\n * - Provides blob URLs for asset files with multi-level caching optimization\r\n * - Checks memory cache (existing entities) first for immediate access\r\n * - Falls back to persistent cache (IndexedDB/localStorage) for faster retrieval\r\n * - Finally fetches from remote API when cache misses occur\r\n * - Manages fetch state indicators for UI feedback\r\n * - Automatically stores fetched files in cache for future access\r\n *\r\n * Usage Patterns:\r\n * - Singleton use case accessed through static get() method\r\n * - Called with asset ID to retrieve blob URL for display or download\r\n * - Handles async operations with comprehensive error handling\r\n * - Optimizes performance through multi-level caching strategy\r\n */\r\n\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"@vived/core\";\r\nimport { FetchAssetFileFromAPIUC } from \"../../VivedAPI\";\r\nimport { GetAssetFromCacheUC, StoreAssetInCacheUC } from \"../../Cache\";\r\nimport { AssetEntity } from \"../Entities/AssetEntity\";\r\nimport { AssetRepo } from \"../Entities/AssetRepo\";\r\nimport { GetAssetUC } from \"./GetAssetUC\";\r\n\r\n/**\r\n * GetAssetBlobURLUC handles optimized retrieval of asset files as blob URLs.\r\n *\r\n * This singleton use case implements a multi-level caching strategy to minimize\r\n * network requests and provide fast access to asset files for web applications.\r\n */\r\nexport abstract class GetAssetBlobURLUC extends AppObjectUC {\r\n /** Static type identifier for component registration */\r\n static type = \"GetAssetBlobURLUC\";\r\n\r\n /**\r\n * Retrieves a blob URL for the specified asset file.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @returns Promise resolving to a blob URL for immediate use\r\n */\r\n abstract getAssetBlobURL(assetID: string): Promise<string>;\r\n\r\n /**\r\n * Retrieves the singleton GetAssetBlobURLUC instance.\r\n *\r\n * @param appObjects - Repository for accessing the singleton component\r\n * @returns GetAssetBlobURLUC instance or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): GetAssetBlobURLUC | undefined {\r\n return getSingletonComponent<GetAssetBlobURLUC>(\r\n GetAssetBlobURLUC.type,\r\n appObjects\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new GetAssetBlobURLUC instance.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n * @returns A new GetAssetBlobURLUC implementation instance\r\n */\r\nexport function makeGetAssetBlobURLUC(appObject: AppObject): GetAssetBlobURLUC {\r\n return new GetAssetBlobURLUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Private implementation of GetAssetBlobURLUC with multi-level caching strategy.\r\n *\r\n * Key Implementation Details:\r\n * - Implements three-tier caching: memory (entities), persistent cache, and remote API\r\n * - Manages fetch state indicators for user feedback during operations\r\n * - Automatically caches fetched files for future access optimization\r\n * - Handles cache failures gracefully with fallback to direct API access\r\n * - Converts between Blob and File objects for compatibility\r\n * - Provides detailed error handling and logging for debugging\r\n */\r\nclass GetAssetBlobURLUCImp extends GetAssetBlobURLUC {\r\n /** Gets the asset repository for entity management and lookup */\r\n private get assetRepo() {\r\n return this.getCachedSingleton<AssetRepo>(AssetRepo.type);\r\n }\r\n\r\n /** Gets the API use case for fetching asset files from remote sources */\r\n private get fetchAssetFile() {\r\n return this.getCachedSingleton<FetchAssetFileFromAPIUC>(\r\n FetchAssetFileFromAPIUC.type\r\n )?.doFetch;\r\n }\r\n\r\n /** Gets the use case for retrieving asset metadata */\r\n private get getAsset() {\r\n return this.getCachedSingleton<GetAssetUC>(GetAssetUC.type)?.getAsset;\r\n }\r\n\r\n /** Gets the use case for retrieving assets from persistent cache */\r\n private get getAssetFromCache() {\r\n return this.getCachedSingleton<GetAssetFromCacheUC>(\r\n GetAssetFromCacheUC.type\r\n )?.getAsset;\r\n }\r\n\r\n /** Gets the use case for storing assets in persistent cache */\r\n private get storeAssetInCache() {\r\n return this.getCachedSingleton<StoreAssetInCacheUC>(\r\n StoreAssetInCacheUC.type\r\n )?.storeAsset;\r\n }\r\n\r\n /**\r\n * Retrieves an asset blob URL using optimized multi-level caching.\r\n *\r\n * This method implements a three-tier caching strategy:\r\n * 1. Memory cache: Check if asset entity already has a blob URL\r\n * 2. Persistent cache: Check IndexedDB/localStorage for cached file\r\n * 3. Remote API: Fetch from backend as last resort\r\n *\r\n * Each level provides progressively better performance, with automatic\r\n * population of higher-level caches for future access optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @returns Promise resolving to a blob URL for the asset file\r\n */\r\n getAssetBlobURL = (assetID: string): Promise<string> => {\r\n const assetRepo = this.assetRepo;\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const getAssetFromCache = this.getAssetFromCache;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!assetRepo || !getAsset || !fetchAssetFile) {\r\n return Promise.reject();\r\n }\r\n\r\n // Level 1: Check memory cache (existing entities with blob URLs)\r\n const existing = assetRepo.get(assetID);\r\n if (existing && existing.blobURL) {\r\n return Promise.resolve(existing.blobURL);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n // Level 2: Check persistent cache\r\n if (getAssetFromCache) {\r\n getAssetFromCache(assetID)\r\n .then((cachedBlob) => {\r\n if (cachedBlob) {\r\n // Asset found in cache, get metadata and create file\r\n return getAsset(assetID).then((asset) => {\r\n fetchedAsset = asset;\r\n const filename = asset.filename || \"cached-asset\";\r\n return new File([cachedBlob], filename, {\r\n type: cachedBlob.type\r\n });\r\n });\r\n } else {\r\n // Level 3: Fetch from remote API\r\n return getAsset(assetID).then((asset) => {\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n });\r\n }\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future access (if not from cache already)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Cache error, fallback to normal flow\r\n this.warn(`Cache error or fetch error: ${e.message}`);\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n });\r\n } else {\r\n // No cache available, use direct API access\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Helper method for direct asset fetching without cache support.\r\n *\r\n * This method handles the direct API fetch workflow when caching\r\n * is not available or has failed. It still attempts to store the\r\n * result in cache for future optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param resolve - Success callback with blob URL\r\n * @param reject - Error callback with error details\r\n */\r\n private fetchAssetNormally = (\r\n assetID: string,\r\n resolve: (blobURL: string) => void,\r\n reject: (error: Error) => void\r\n ): void => {\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!getAsset || !fetchAssetFile) {\r\n reject(new Error(\"Required dependencies not found\"));\r\n return;\r\n }\r\n\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n getAsset(assetID)\r\n .then((asset) => {\r\n // Set loading state for UI feedback\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future optimization (if available)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Handle fetch errors with proper state cleanup\r\n if (fetchedAsset) {\r\n fetchedAsset.fetchError = e;\r\n fetchedAsset.isFetchingFile = false;\r\n }\r\n reject(e);\r\n });\r\n };\r\n\r\n /**\r\n * Initializes the GetAssetBlobURLUC and registers it as a singleton.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, GetAssetBlobURLUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GetAssetBlobURLUC.js","sourceRoot":"","sources":["../../../../src/Assets/UCs/GetAssetBlobURLUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAwDH,sDAEC;AAxDD,sCAKqB;AACrB,6CAAyD;AACzD,uCAAuE;AAEvE,qDAAkD;AAClD,6CAA0C;AAE1C;;;;;GAKG;AACH,MAAsB,iBAAkB,SAAQ,kBAAW;IAgBzD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAC1B,iBAAiB,CAAC,IAAI,EACtB,UAAU,CACX,CAAC;IACJ,CAAC;;AA3BH,8CA4BC;AA3BC,wDAAwD;AACjD,sBAAI,GAAG,mBAAmB,CAAC;AA4BpC;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,SAAoB;IACxD,OAAO,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,oBAAqB,SAAQ,iBAAiB;IAClD,iEAAiE;IACjE,IAAY,SAAS;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAY,qBAAS,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,yEAAyE;IACzE,IAAY,cAAc;QACxB,OAAO,IAAI,CAAC,kBAAkB,CAC5B,kCAAuB,CAAC,IAAI,CAC7B,EAAE,OAAO,CAAC;IACb,CAAC;IAED,sDAAsD;IACtD,IAAY,QAAQ;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAa,uBAAU,CAAC,IAAI,CAAC,EAAE,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,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;oBAC5B,YAAY,CAAC,cAAc,GAAG,KAAK,CAAC;gBACtC,CAAC;gBACD,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QASA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * GetAssetBlobURLUC.ts\r\n *\r\n * This use case provides optimized asset file retrieval with caching support,\r\n * returning blob URLs for immediate use in web applications.\r\n *\r\n * Key Concepts:\r\n * - Provides blob URLs for asset files with multi-level caching optimization\r\n * - Checks memory cache (existing entities) first for immediate access\r\n * - Falls back to persistent cache (IndexedDB/localStorage) for faster retrieval\r\n * - Finally fetches from remote API when cache misses occur\r\n * - Manages fetch state indicators for UI feedback\r\n * - Automatically stores fetched files in cache for future access\r\n *\r\n * Usage Patterns:\r\n * - Singleton use case accessed through static get() method\r\n * - Called with asset ID to retrieve blob URL for display or download\r\n * - Handles async operations with comprehensive error handling\r\n * - Optimizes performance through multi-level caching strategy\r\n */\r\n\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"@vived/core\";\r\nimport { FetchAssetFileFromAPIUC } from \"../../VivedAPI\";\r\nimport { GetAssetFromCacheUC, StoreAssetInCacheUC } from \"../../Cache\";\r\nimport { AssetEntity } from \"../Entities/AssetEntity\";\r\nimport { AssetRepo } from \"../Entities/AssetRepo\";\r\nimport { GetAssetUC } from \"./GetAssetUC\";\r\n\r\n/**\r\n * GetAssetBlobURLUC handles optimized retrieval of asset files as blob URLs.\r\n *\r\n * This singleton use case implements a multi-level caching strategy to minimize\r\n * network requests and provide fast access to asset files for web applications.\r\n */\r\nexport abstract class GetAssetBlobURLUC extends AppObjectUC {\r\n /** Static type identifier for component registration */\r\n static type = \"GetAssetBlobURLUC\";\r\n\r\n /**\r\n * Retrieves a blob URL for the specified asset file.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param useCache - Optional flag to control caching behavior (defaults to true)\r\n * @returns Promise resolving to a blob URL for immediate use\r\n */\r\n abstract getAssetBlobURL(\r\n assetID: string,\r\n useCache?: boolean\r\n ): Promise<string>;\r\n\r\n /**\r\n * Retrieves the singleton GetAssetBlobURLUC instance.\r\n *\r\n * @param appObjects - Repository for accessing the singleton component\r\n * @returns GetAssetBlobURLUC instance or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): GetAssetBlobURLUC | undefined {\r\n return getSingletonComponent<GetAssetBlobURLUC>(\r\n GetAssetBlobURLUC.type,\r\n appObjects\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new GetAssetBlobURLUC instance.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n * @returns A new GetAssetBlobURLUC implementation instance\r\n */\r\nexport function makeGetAssetBlobURLUC(appObject: AppObject): GetAssetBlobURLUC {\r\n return new GetAssetBlobURLUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Private implementation of GetAssetBlobURLUC with multi-level caching strategy.\r\n *\r\n * Key Implementation Details:\r\n * - Implements three-tier caching: memory (entities), persistent cache, and remote API\r\n * - Manages fetch state indicators for user feedback during operations\r\n * - Automatically caches fetched files for future access optimization\r\n * - Handles cache failures gracefully with fallback to direct API access\r\n * - Converts between Blob and File objects for compatibility\r\n * - Provides detailed error handling and logging for debugging\r\n */\r\nclass GetAssetBlobURLUCImp extends GetAssetBlobURLUC {\r\n /** Gets the asset repository for entity management and lookup */\r\n private get assetRepo() {\r\n return this.getCachedSingleton<AssetRepo>(AssetRepo.type);\r\n }\r\n\r\n /** Gets the API use case for fetching asset files from remote sources */\r\n private get fetchAssetFile() {\r\n return this.getCachedSingleton<FetchAssetFileFromAPIUC>(\r\n FetchAssetFileFromAPIUC.type\r\n )?.doFetch;\r\n }\r\n\r\n /** Gets the use case for retrieving asset metadata */\r\n private get getAsset() {\r\n return this.getCachedSingleton<GetAssetUC>(GetAssetUC.type)?.getAsset;\r\n }\r\n\r\n /** Gets the use case for retrieving assets from persistent cache */\r\n private get getAssetFromCache() {\r\n return this.getCachedSingleton<GetAssetFromCacheUC>(\r\n GetAssetFromCacheUC.type\r\n )?.getAsset;\r\n }\r\n\r\n /** Gets the use case for storing assets in persistent cache */\r\n private get storeAssetInCache() {\r\n return this.getCachedSingleton<StoreAssetInCacheUC>(\r\n StoreAssetInCacheUC.type\r\n )?.storeAsset;\r\n }\r\n\r\n /**\r\n * Retrieves an asset blob URL using optimized multi-level caching.\r\n *\r\n * This method implements a three-tier caching strategy:\r\n * 1. Memory cache: Check if asset entity already has a blob URL\r\n * 2. Persistent cache: Check IndexedDB/localStorage for cached file\r\n * 3. Remote API: Fetch from backend as last resort\r\n *\r\n * Each level provides progressively better performance, with automatic\r\n * population of higher-level caches for future access optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param useCache - Optional flag to control caching behavior (defaults to true)\r\n * @returns Promise resolving to a blob URL for the asset file\r\n */\r\n getAssetBlobURL = (\r\n assetID: string,\r\n useCache: boolean = true\r\n ): Promise<string> => {\r\n const assetRepo = this.assetRepo;\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const getAssetFromCache = this.getAssetFromCache;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!assetRepo || !getAsset || !fetchAssetFile) {\r\n return Promise.reject();\r\n }\r\n\r\n // If cache is disabled, skip all cache checks and go directly to API\r\n if (!useCache) {\r\n return new Promise((resolve, reject) => {\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n });\r\n }\r\n\r\n // Level 1: Check memory cache (existing entities with blob URLs)\r\n const existing = assetRepo.get(assetID);\r\n if (existing && existing.blobURL) {\r\n return Promise.resolve(existing.blobURL);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n // Level 2: Check persistent cache\r\n if (getAssetFromCache) {\r\n getAssetFromCache(assetID)\r\n .then((cachedBlob) => {\r\n if (cachedBlob) {\r\n // Asset found in cache, get metadata and create file\r\n return getAsset(assetID).then((asset) => {\r\n fetchedAsset = asset;\r\n const filename = asset.filename || \"cached-asset\";\r\n return new File([cachedBlob], filename, {\r\n type: cachedBlob.type\r\n });\r\n });\r\n } else {\r\n // Level 3: Fetch from remote API\r\n return getAsset(assetID).then((asset) => {\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n });\r\n }\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future access (if not from cache already)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Cache error, fallback to normal flow\r\n this.warn(`Cache error or fetch error: ${e.message}`);\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n });\r\n } else {\r\n // No cache available, use direct API access\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Helper method for direct asset fetching without cache support.\r\n *\r\n * This method handles the direct API fetch workflow when caching\r\n * is not available or has failed. It still attempts to store the\r\n * result in cache for future optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param resolve - Success callback with blob URL\r\n * @param reject - Error callback with error details\r\n */\r\n private fetchAssetNormally = (\r\n assetID: string,\r\n resolve: (blobURL: string) => void,\r\n reject: (error: Error) => void\r\n ): void => {\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!getAsset || !fetchAssetFile) {\r\n reject(new Error(\"Required dependencies not found\"));\r\n return;\r\n }\r\n\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n getAsset(assetID)\r\n .then((asset) => {\r\n // Set loading state for UI feedback\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future optimization (if available)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Handle fetch errors with proper state cleanup\r\n if (fetchedAsset) {\r\n fetchedAsset.fetchError = e;\r\n fetchedAsset.isFetchingFile = false;\r\n }\r\n reject(e);\r\n });\r\n };\r\n\r\n /**\r\n * Initializes the GetAssetBlobURLUC and registers it as a singleton.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, GetAssetBlobURLUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheFeatureFactory = void 0;
|
|
4
|
+
const core_1 = require("@vived/core");
|
|
5
|
+
const Entities_1 = require("../Entities");
|
|
6
|
+
const UCs_1 = require("../UCs");
|
|
7
|
+
/**
|
|
8
|
+
* Factory responsible for setting up the Cache domain components.
|
|
9
|
+
* This factory initializes all entities, use cases, and presentation models
|
|
10
|
+
* required for the Cache functionality.
|
|
11
|
+
*/
|
|
12
|
+
class CacheFeatureFactory extends core_1.DomainFactory {
|
|
13
|
+
constructor(appObject) {
|
|
14
|
+
super(appObject);
|
|
15
|
+
// Unique name for this factory
|
|
16
|
+
this.factoryName = "CacheFeatureFactory";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets up all entities required for the Cache system
|
|
20
|
+
*/
|
|
21
|
+
setupEntities() {
|
|
22
|
+
// Initialize entities
|
|
23
|
+
(0, Entities_1.makeCacheEntity)(this.appObject);
|
|
24
|
+
(0, Entities_1.makeScriptCacheEntity)(this.appObject);
|
|
25
|
+
(0, Entities_1.makeAssetCacheEntity)(this.appObject);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sets up all use cases for the Cache system
|
|
29
|
+
*/
|
|
30
|
+
setupUCs() {
|
|
31
|
+
// Cache use cases
|
|
32
|
+
(0, UCs_1.makeGetScriptFromCacheUC)(this.appObject);
|
|
33
|
+
(0, UCs_1.makeStoreScriptInCacheUC)(this.appObject);
|
|
34
|
+
(0, UCs_1.makeGetAssetFromCacheUC)(this.appObject);
|
|
35
|
+
(0, UCs_1.makeStoreAssetInCacheUC)(this.appObject);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sets up all presentation managers for the Cache system
|
|
39
|
+
*/
|
|
40
|
+
setupPMs() {
|
|
41
|
+
// No presentation managers exist for the Cache system
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Performs any final setup operations after all components are initialized
|
|
45
|
+
*/
|
|
46
|
+
finalSetup() {
|
|
47
|
+
// No additional setup required for cache
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.CacheFeatureFactory = CacheFeatureFactory;
|
|
51
|
+
//# sourceMappingURL=CacheFeatureFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Cache/Factories/CacheFeatureFactory.ts"],"names":[],"mappings":";;;AAAA,sCAAuD;AACvD,0CAIqB;AACrB,gCAKgB;AAEhB;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,oBAAa;IAIpD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QAJnB,+BAA+B;QACtB,gBAAW,GAAG,qBAAqB,CAAC;IAI7C,CAAC;IAED;;OAEG;IACH,aAAa;QACX,sBAAsB;QACtB,IAAA,0BAAe,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,IAAA,gCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,IAAA,+BAAoB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,kBAAkB;QAClB,IAAA,8BAAwB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,IAAA,8BAAwB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,IAAA,6BAAuB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,IAAA,6BAAuB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,sDAAsD;IACxD,CAAC;IAED;;OAEG;IACH,UAAU;QACR,yCAAyC;IAC3C,CAAC;CACF;AA1CD,kDA0CC","sourcesContent":["import { AppObject, DomainFactory } from \"@vived/core\";\r\nimport {\r\n makeCacheEntity,\r\n makeAssetCacheEntity,\r\n makeScriptCacheEntity\r\n} from \"../Entities\";\r\nimport {\r\n makeGetAssetFromCacheUC,\r\n makeGetScriptFromCacheUC,\r\n makeStoreAssetInCacheUC,\r\n makeStoreScriptInCacheUC\r\n} from \"../UCs\";\r\n\r\n/**\r\n * Factory responsible for setting up the Cache domain components.\r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Cache functionality.\r\n */\r\nexport class CacheFeatureFactory extends DomainFactory {\r\n // Unique name for this factory\r\n readonly factoryName = \"CacheFeatureFactory\";\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n\r\n /**\r\n * Sets up all entities required for the Cache system\r\n */\r\n setupEntities(): void {\r\n // Initialize entities\r\n makeCacheEntity(this.appObject);\r\n makeScriptCacheEntity(this.appObject);\r\n makeAssetCacheEntity(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all use cases for the Cache system\r\n */\r\n setupUCs(): void {\r\n // Cache use cases\r\n makeGetScriptFromCacheUC(this.appObject);\r\n makeStoreScriptInCacheUC(this.appObject);\r\n makeGetAssetFromCacheUC(this.appObject);\r\n makeStoreAssetInCacheUC(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all presentation managers for the Cache system\r\n */\r\n setupPMs(): void {\r\n // No presentation managers exist for the Cache system\r\n }\r\n\r\n /**\r\n * Performs any final setup operations after all components are initialized\r\n */\r\n finalSetup(): void {\r\n // No additional setup required for cache\r\n }\r\n}\r\n"]}
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./setupCache"), exports);
|
|
18
|
+
__exportStar(require("./CacheFeatureFactory"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Cache/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B","sourcesContent":["export * from \"./setupCache\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Cache/Factories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,wDAAsC","sourcesContent":["export * from \"./setupCache\";\r\nexport * from \"./CacheFeatureFactory\";\r\n"]}
|
|
@@ -16,9 +16,8 @@ export class AppsFeatureFactory extends DomainFactory {
|
|
|
16
16
|
* Sets up all entities required for the Apps system
|
|
17
17
|
*/
|
|
18
18
|
setupEntities() {
|
|
19
|
-
this.appRepoAO = this.appObjects.getOrCreate("App Repository");
|
|
20
19
|
// Initialize entities
|
|
21
|
-
makeAppRepo(this.
|
|
20
|
+
makeAppRepo(this.appObject);
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
23
|
* Sets up all use cases for the Apps system
|
|
@@ -32,7 +31,7 @@ export class AppsFeatureFactory extends DomainFactory {
|
|
|
32
31
|
*/
|
|
33
32
|
setupPMs() {
|
|
34
33
|
// App Repository PMs
|
|
35
|
-
makeAppsListPM(this.
|
|
34
|
+
makeAppsListPM(this.appObject);
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* Performs any final setup operations after all components are initialized
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppsFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Apps/Factories/AppsFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAiB,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAa,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,aAAa;
|
|
1
|
+
{"version":3,"file":"AppsFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Apps/Factories/AppsFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAiB,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAa,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IAInD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QAJnB,+BAA+B;QACtB,gBAAW,GAAG,oBAAoB,CAAC;IAI5C,CAAC;IAED;;OAEG;IACH,aAAa;QACX,sBAAsB;QACtB,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,+DAA+D;QAC/D,0EAA0E;IAC5E,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,qBAAqB;QACrB,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,wCAAwC;IAC1C,CAAC;CACF","sourcesContent":["import { AppObject, DomainFactory } from \"@vived/core\";\r\nimport { makeAppEntity, makeAppRepo } from \"../Entities\";\r\nimport { makeAppPM, makeAppsListPM } from \"../PMs\";\r\n\r\n/**\r\n * Factory responsible for setting up the Apps domain components.\r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Apps functionality.\r\n */\r\nexport class AppsFeatureFactory extends DomainFactory {\r\n // Unique name for this factory\r\n readonly factoryName = \"AppsFeatureFactory\";\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n\r\n /**\r\n * Sets up all entities required for the Apps system\r\n */\r\n setupEntities(): void {\r\n // Initialize entities\r\n makeAppRepo(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all use cases for the Apps system\r\n */\r\n setupUCs(): void {\r\n // Note: App UCs have complex dependencies and should be set up\r\n // separately to avoid circular dependencies during factory initialization\r\n }\r\n\r\n /**\r\n * Sets up all presentation managers for the Apps system\r\n */\r\n setupPMs(): void {\r\n // App Repository PMs\r\n makeAppsListPM(this.appObject);\r\n }\r\n\r\n /**\r\n * Performs any final setup operations after all components are initialized\r\n */\r\n finalSetup(): void {\r\n // No additional setup required for apps\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fetchAssetFile.ts
|
|
3
|
+
*
|
|
4
|
+
* This controller function retrieves an asset file as a File object,
|
|
5
|
+
* handling caching and error management for file access operations.
|
|
6
|
+
*
|
|
7
|
+
* Key Concepts:
|
|
8
|
+
* - Retrieves asset files as File objects for download or processing
|
|
9
|
+
* - Uses GetAssetFileUC to handle caching and file retrieval logic
|
|
10
|
+
* - Provides error handling for missing components
|
|
11
|
+
* - Coordinates with asset file management workflows
|
|
12
|
+
*
|
|
13
|
+
* Usage Patterns:
|
|
14
|
+
* - Called from UI components when users need asset file access
|
|
15
|
+
* - Used in asset management workflows for file processing
|
|
16
|
+
* - Integrated with download and preview functionality
|
|
17
|
+
*/
|
|
18
|
+
import { GetAssetFileUC } from "../UCs/GetAssetFileUC";
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves an asset file as a File object.
|
|
21
|
+
*
|
|
22
|
+
* This function provides a controller-level interface for asset file retrieval.
|
|
23
|
+
* It handles the complete file access workflow including caching optimization,
|
|
24
|
+
* error handling, and returns a File object ready for use in web applications.
|
|
25
|
+
*
|
|
26
|
+
* @param assetID - The unique identifier of the asset whose file should be retrieved
|
|
27
|
+
* @param appObjects - Repository for accessing asset-related app objects and components
|
|
28
|
+
* @returns Promise<File> - A promise that resolves to the File object for the asset,
|
|
29
|
+
* or undefined if the operation cannot be completed
|
|
30
|
+
*/
|
|
31
|
+
export function fetchAssetFile(assetID, appObjects) {
|
|
32
|
+
const uc = GetAssetFileUC.get(appObjects);
|
|
33
|
+
if (!uc) {
|
|
34
|
+
appObjects.submitWarning("fetchAssetFile", "Unable to find GetAssetFileUC");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return uc.getAssetFile(assetID);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=fetchAssetFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAssetFile.js","sourceRoot":"","sources":["../../../../src/Assets/Controllers/fetchAssetFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAe,EACf,UAAyB;IAEzB,MAAM,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1C,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,UAAU,CAAC,aAAa,CAAC,gBAAgB,EAAE,+BAA+B,CAAC,CAAC;QAC5E,OAAO;IACT,CAAC;IAED,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\r\n * fetchAssetFile.ts\r\n *\r\n * This controller function retrieves an asset file as a File object,\r\n * handling caching and error management for file access operations.\r\n *\r\n * Key Concepts:\r\n * - Retrieves asset files as File objects for download or processing\r\n * - Uses GetAssetFileUC to handle caching and file retrieval logic\r\n * - Provides error handling for missing components\r\n * - Coordinates with asset file management workflows\r\n *\r\n * Usage Patterns:\r\n * - Called from UI components when users need asset file access\r\n * - Used in asset management workflows for file processing\r\n * - Integrated with download and preview functionality\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { GetAssetFileUC } from \"../UCs/GetAssetFileUC\";\r\n\r\n/**\r\n * Retrieves an asset file as a File object.\r\n *\r\n * This function provides a controller-level interface for asset file retrieval.\r\n * It handles the complete file access workflow including caching optimization,\r\n * error handling, and returns a File object ready for use in web applications.\r\n *\r\n * @param assetID - The unique identifier of the asset whose file should be retrieved\r\n * @param appObjects - Repository for accessing asset-related app objects and components\r\n * @returns Promise<File> - A promise that resolves to the File object for the asset,\r\n * or undefined if the operation cannot be completed\r\n */\r\nexport function fetchAssetFile(\r\n assetID: string,\r\n appObjects: AppObjectRepo\r\n): Promise<File> | undefined {\r\n const uc = GetAssetFileUC.get(appObjects);\r\n if (!uc) {\r\n appObjects.submitWarning(\"fetchAssetFile\", \"Unable to find GetAssetFileUC\");\r\n return;\r\n }\r\n\r\n return uc.getAssetFile(assetID);\r\n}\r\n"]}
|
|
@@ -21,6 +21,7 @@ export * from "./archiveAsset";
|
|
|
21
21
|
export * from "./deleteAsset";
|
|
22
22
|
export * from "./downloadAssetFile";
|
|
23
23
|
export * from "./editAppAsset";
|
|
24
|
+
export * from "./fetchAssetFile";
|
|
24
25
|
export * from "./getAppAssets";
|
|
25
26
|
export * from "./newAppAsset";
|
|
26
27
|
export * from "./toggleShowArchivedAssets";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Assets/Controllers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC","sourcesContent":["/**\r\n * Assets Controllers Index\r\n *\r\n * This module exports all controller functions for the Assets feature.\r\n * Controllers provide simple, stateless functions that serve as entry points\r\n * for asset-related operations from UI components and external systems.\r\n *\r\n * Key Concepts:\r\n * - Controllers act as the interface layer between UI components and business logic\r\n * - Each controller function handles a specific asset operation\r\n * - Controllers delegate to Use Cases (UCs) for actual business logic implementation\r\n * - Error handling and validation are performed at the controller level\r\n *\r\n * Available Operations:\r\n * - Asset lifecycle: create, edit, delete, archive\r\n * - File management: upload, download, update\r\n * - Collection management: get app assets, toggle archived visibility\r\n * - Metadata management: update asset information\r\n */\r\n\r\nexport * from \"./archiveAsset\";\r\nexport * from \"./deleteAsset\";\r\nexport * from \"./downloadAssetFile\";\r\nexport * from \"./editAppAsset\";\r\nexport * from \"./getAppAssets\";\r\nexport * from \"./newAppAsset\";\r\nexport * from \"./toggleShowArchivedAssets\";\r\nexport * from \"./updateAppAssetMeta\";\r\nexport * from \"./updateAssetFile\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Assets/Controllers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC","sourcesContent":["/**\r\n * Assets Controllers Index\r\n *\r\n * This module exports all controller functions for the Assets feature.\r\n * Controllers provide simple, stateless functions that serve as entry points\r\n * for asset-related operations from UI components and external systems.\r\n *\r\n * Key Concepts:\r\n * - Controllers act as the interface layer between UI components and business logic\r\n * - Each controller function handles a specific asset operation\r\n * - Controllers delegate to Use Cases (UCs) for actual business logic implementation\r\n * - Error handling and validation are performed at the controller level\r\n *\r\n * Available Operations:\r\n * - Asset lifecycle: create, edit, delete, archive\r\n * - File management: upload, download, update\r\n * - Collection management: get app assets, toggle archived visibility\r\n * - Metadata management: update asset information\r\n */\r\n\r\nexport * from \"./archiveAsset\";\r\nexport * from \"./deleteAsset\";\r\nexport * from \"./downloadAssetFile\";\r\nexport * from \"./editAppAsset\";\r\nexport * from \"./fetchAssetFile\";\r\nexport * from \"./getAppAssets\";\r\nexport * from \"./newAppAsset\";\r\nexport * from \"./toggleShowArchivedAssets\";\r\nexport * from \"./updateAppAssetMeta\";\r\nexport * from \"./updateAssetFile\";\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DomainFactory } from "@vived/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { makeArchiveAssetUC, makeDeleteAssetUC, makeDownloadAssetFileUC,
|
|
2
|
+
import { makeAssetEntity, makeAssetRepo } from "../Entities";
|
|
3
|
+
import { makeAssetFilePM, makeAssetPM } from "../PMs";
|
|
4
|
+
import { makeArchiveAssetUC, makeDeleteAssetUC, makeDownloadAssetFileUC, makeGetAssetBlobURLUC, makeGetAssetFileUC, makeGetAssetUC, makeNewAssetUC, makePrefetchAssets, makeUpdateAssetFileUC } from "../UCs";
|
|
5
5
|
/**
|
|
6
6
|
* Factory responsible for setting up the Assets domain components.
|
|
7
7
|
* This factory initializes all entities, use cases, and presentation models
|
|
@@ -17,12 +17,9 @@ export class AssetsFactory extends DomainFactory {
|
|
|
17
17
|
* Sets up all entities required for the Assets system
|
|
18
18
|
*/
|
|
19
19
|
setupEntities() {
|
|
20
|
-
this.assetRepoAO = this.appObjects.getOrCreate("Asset Repository");
|
|
21
|
-
this.appAssetsAO = this.appObjects.getOrCreate("App Assets");
|
|
22
20
|
// Initialize entities
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
makeAppAssets(this.appAssetsAO);
|
|
21
|
+
const assetRepo = makeAssetRepo(this.appObject);
|
|
22
|
+
assetRepo.assetFactory = this.makeAssetFactory();
|
|
26
23
|
}
|
|
27
24
|
/**
|
|
28
25
|
* Creates an asset factory function that properly initializes assets with all required components
|
|
@@ -37,7 +34,6 @@ export class AssetsFactory extends DomainFactory {
|
|
|
37
34
|
makeDeleteAssetUC(ao);
|
|
38
35
|
makeDownloadAssetFileUC(ao);
|
|
39
36
|
makeUpdateAssetFileUC(ao);
|
|
40
|
-
makeUpdateAppAssetMetaUC(ao);
|
|
41
37
|
// PMs for each asset
|
|
42
38
|
makeAssetPM(ao);
|
|
43
39
|
makeAssetFilePM(ao);
|
|
@@ -49,24 +45,17 @@ export class AssetsFactory extends DomainFactory {
|
|
|
49
45
|
*/
|
|
50
46
|
setupUCs() {
|
|
51
47
|
// Repository UCs
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
makeNewAssetUC(this.assetRepoAO);
|
|
58
|
-
// App Assets UCs
|
|
59
|
-
makeNewAppAssetUC(this.appAssetsAO);
|
|
60
|
-
makeGetAppAssetUC(this.appAssetsAO);
|
|
48
|
+
makeGetAssetBlobURLUC(this.appObject);
|
|
49
|
+
makeGetAssetFileUC(this.appObject);
|
|
50
|
+
makeGetAssetUC(this.appObject);
|
|
51
|
+
makePrefetchAssets(this.appObject);
|
|
52
|
+
makeNewAssetUC(this.appObject);
|
|
61
53
|
}
|
|
62
54
|
/**
|
|
63
55
|
* Sets up all presentation managers for the Assets system
|
|
64
56
|
*/
|
|
65
57
|
setupPMs() {
|
|
66
|
-
//
|
|
67
|
-
makeAppAssetListPM(this.appAssetsAO);
|
|
68
|
-
makeShowArchivedAppAssetPM(this.appAssetsAO);
|
|
69
|
-
makeEditingAppAssetPM(this.appAssetsAO);
|
|
58
|
+
// No PMs needed for core asset functionality
|
|
70
59
|
}
|
|
71
60
|
/**
|
|
72
61
|
* Performs any final setup operations after all components are initialized
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsFactory.js","sourceRoot":"","sources":["../../../../src/Assets/Factories/AssetsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAEL,
|
|
1
|
+
{"version":3,"file":"AssetsFactory.js","sourceRoot":"","sources":["../../../../src/Assets/Factories/AssetsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAEL,eAAe,EACf,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,WAAW,EACZ,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,QAAQ,CAAC;AAEhB;;;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R,0CAA0C;IAC5C,CAAC;CACF","sourcesContent":["import { AppObject, AppObjectRepo, DomainFactory } from \"@vived/core\";\r\nimport {\r\n AssetEntity,\r\n makeAssetEntity,\r\n makeAssetRepo\r\n} from \"../Entities\";\r\nimport {\r\n makeAssetFilePM,\r\n makeAssetPM\r\n} from \"../PMs\";\r\nimport {\r\n makeArchiveAssetUC,\r\n makeDeleteAssetUC,\r\n makeDownloadAssetFileUC,\r\n makeGetAssetBlobURLUC,\r\n makeGetAssetFileUC,\r\n makeGetAssetUC,\r\n makeNewAssetUC,\r\n makePrefetchAssets,\r\n makeUpdateAssetFileUC\r\n} from \"../UCs\";\r\n\r\n/**\r\n * Factory responsible for setting up the Assets domain components.\r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Assets functionality.\r\n */\r\nexport class AssetsFactory extends DomainFactory {\r\n // Unique name for this factory\r\n readonly factoryName = \"AssetsFactory\";\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n\r\n /**\r\n * Sets up all entities required for the Assets system\r\n */\r\n setupEntities(): void {\r\n // Initialize entities\r\n const assetRepo = makeAssetRepo(this.appObject);\r\n assetRepo.assetFactory = this.makeAssetFactory();\r\n }\r\n\r\n /**\r\n * Creates an asset factory function that properly initializes assets with all required components\r\n */\r\n private makeAssetFactory() {\r\n return (id: string): AssetEntity => {\r\n const ao = this.appObjects.getOrCreate(id);\r\n\r\n // Entities\r\n const entity = makeAssetEntity(ao);\r\n\r\n // UCs for each asset\r\n makeArchiveAssetUC(ao);\r\n makeDeleteAssetUC(ao);\r\n makeDownloadAssetFileUC(ao);\r\n makeUpdateAssetFileUC(ao);\r\n\r\n // PMs for each asset\r\n makeAssetPM(ao);\r\n makeAssetFilePM(ao);\r\n\r\n return entity;\r\n };\r\n }\r\n\r\n /**\r\n * Sets up all use cases for the Assets system\r\n */\r\n setupUCs(): void {\r\n // Repository UCs\r\n makeGetAssetBlobURLUC(this.appObject);\r\n makeGetAssetFileUC(this.appObject);\r\n makeGetAssetUC(this.appObject);\r\n makePrefetchAssets(this.appObject);\r\n makeNewAssetUC(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all presentation managers for the Assets system\r\n */\r\n setupPMs(): void {\r\n // No PMs needed for core asset functionality\r\n }\r\n\r\n /**\r\n * Performs any final setup operations after all components are initialized\r\n */\r\n finalSetup(): void {\r\n // No additional setup required for assets\r\n }\r\n}\r\n"]}
|
|
@@ -102,9 +102,10 @@ class GetAssetBlobURLUCImp extends GetAssetBlobURLUC {
|
|
|
102
102
|
* population of higher-level caches for future access optimization.
|
|
103
103
|
*
|
|
104
104
|
* @param assetID - The unique identifier of the asset
|
|
105
|
+
* @param useCache - Optional flag to control caching behavior (defaults to true)
|
|
105
106
|
* @returns Promise resolving to a blob URL for the asset file
|
|
106
107
|
*/
|
|
107
|
-
this.getAssetBlobURL = (assetID) => {
|
|
108
|
+
this.getAssetBlobURL = (assetID, useCache = true) => {
|
|
108
109
|
const assetRepo = this.assetRepo;
|
|
109
110
|
const getAsset = this.getAsset;
|
|
110
111
|
const fetchAssetFile = this.fetchAssetFile;
|
|
@@ -113,6 +114,12 @@ class GetAssetBlobURLUCImp extends GetAssetBlobURLUC {
|
|
|
113
114
|
if (!assetRepo || !getAsset || !fetchAssetFile) {
|
|
114
115
|
return Promise.reject();
|
|
115
116
|
}
|
|
117
|
+
// If cache is disabled, skip all cache checks and go directly to API
|
|
118
|
+
if (!useCache) {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
this.fetchAssetNormally(assetID, resolve, reject);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
116
123
|
// Level 1: Check memory cache (existing entities with blob URLs)
|
|
117
124
|
const existing = assetRepo.get(assetID);
|
|
118
125
|
if (existing && existing.blobURL) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetAssetBlobURLUC.js","sourceRoot":"","sources":["../../../../src/Assets/UCs/GetAssetBlobURLUC.ts"],"names":[],"mappings":"AAAA;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AC,CAAC,IAAI,EAAE,EAAE;gBACb,IAAI,YAAY,EAAE,CAAC;oBACjB,oCAAoC;oBACpC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC3B,YAAY,CAAC,cAAc,GAAG,KAAK,CAAC;oBAEpC,wDAAwD;oBACxD,IAAI,iBAAiB,EAAE,CAAC;wBACtB,iBAAiB,CACf,OAAO,EACP,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EACrC,IAAI,CAAC,IAAI,CACV,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;4BACZ,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;wBACnD,CAAC,CAAC,CAAC;oBACL,CAAC;oBAED,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBACzB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;wBAC9B,OAAO;oBACT,CAAC;gBACH,CAAC;gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;gBAClB,gDAAgD;gBAChD,IAAI,YAAY,EAAE,CAAC;oBACjB,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;oBAC5B,YAAY,CAAC,cAAc,GAAG,KAAK,CAAC;gBACtC,CAAC;gBACD,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QASA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * GetAssetBlobURLUC.ts\r\n *\r\n * This use case provides optimized asset file retrieval with caching support,\r\n * returning blob URLs for immediate use in web applications.\r\n *\r\n * Key Concepts:\r\n * - Provides blob URLs for asset files with multi-level caching optimization\r\n * - Checks memory cache (existing entities) first for immediate access\r\n * - Falls back to persistent cache (IndexedDB/localStorage) for faster retrieval\r\n * - Finally fetches from remote API when cache misses occur\r\n * - Manages fetch state indicators for UI feedback\r\n * - Automatically stores fetched files in cache for future access\r\n *\r\n * Usage Patterns:\r\n * - Singleton use case accessed through static get() method\r\n * - Called with asset ID to retrieve blob URL for display or download\r\n * - Handles async operations with comprehensive error handling\r\n * - Optimizes performance through multi-level caching strategy\r\n */\r\n\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"@vived/core\";\r\nimport { FetchAssetFileFromAPIUC } from \"../../VivedAPI\";\r\nimport { GetAssetFromCacheUC, StoreAssetInCacheUC } from \"../../Cache\";\r\nimport { AssetEntity } from \"../Entities/AssetEntity\";\r\nimport { AssetRepo } from \"../Entities/AssetRepo\";\r\nimport { GetAssetUC } from \"./GetAssetUC\";\r\n\r\n/**\r\n * GetAssetBlobURLUC handles optimized retrieval of asset files as blob URLs.\r\n *\r\n * This singleton use case implements a multi-level caching strategy to minimize\r\n * network requests and provide fast access to asset files for web applications.\r\n */\r\nexport abstract class GetAssetBlobURLUC extends AppObjectUC {\r\n /** Static type identifier for component registration */\r\n static type = \"GetAssetBlobURLUC\";\r\n\r\n /**\r\n * Retrieves a blob URL for the specified asset file.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @returns Promise resolving to a blob URL for immediate use\r\n */\r\n abstract getAssetBlobURL(assetID: string): Promise<string>;\r\n\r\n /**\r\n * Retrieves the singleton GetAssetBlobURLUC instance.\r\n *\r\n * @param appObjects - Repository for accessing the singleton component\r\n * @returns GetAssetBlobURLUC instance or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): GetAssetBlobURLUC | undefined {\r\n return getSingletonComponent<GetAssetBlobURLUC>(\r\n GetAssetBlobURLUC.type,\r\n appObjects\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new GetAssetBlobURLUC instance.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n * @returns A new GetAssetBlobURLUC implementation instance\r\n */\r\nexport function makeGetAssetBlobURLUC(appObject: AppObject): GetAssetBlobURLUC {\r\n return new GetAssetBlobURLUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Private implementation of GetAssetBlobURLUC with multi-level caching strategy.\r\n *\r\n * Key Implementation Details:\r\n * - Implements three-tier caching: memory (entities), persistent cache, and remote API\r\n * - Manages fetch state indicators for user feedback during operations\r\n * - Automatically caches fetched files for future access optimization\r\n * - Handles cache failures gracefully with fallback to direct API access\r\n * - Converts between Blob and File objects for compatibility\r\n * - Provides detailed error handling and logging for debugging\r\n */\r\nclass GetAssetBlobURLUCImp extends GetAssetBlobURLUC {\r\n /** Gets the asset repository for entity management and lookup */\r\n private get assetRepo() {\r\n return this.getCachedSingleton<AssetRepo>(AssetRepo.type);\r\n }\r\n\r\n /** Gets the API use case for fetching asset files from remote sources */\r\n private get fetchAssetFile() {\r\n return this.getCachedSingleton<FetchAssetFileFromAPIUC>(\r\n FetchAssetFileFromAPIUC.type\r\n )?.doFetch;\r\n }\r\n\r\n /** Gets the use case for retrieving asset metadata */\r\n private get getAsset() {\r\n return this.getCachedSingleton<GetAssetUC>(GetAssetUC.type)?.getAsset;\r\n }\r\n\r\n /** Gets the use case for retrieving assets from persistent cache */\r\n private get getAssetFromCache() {\r\n return this.getCachedSingleton<GetAssetFromCacheUC>(\r\n GetAssetFromCacheUC.type\r\n )?.getAsset;\r\n }\r\n\r\n /** Gets the use case for storing assets in persistent cache */\r\n private get storeAssetInCache() {\r\n return this.getCachedSingleton<StoreAssetInCacheUC>(\r\n StoreAssetInCacheUC.type\r\n )?.storeAsset;\r\n }\r\n\r\n /**\r\n * Retrieves an asset blob URL using optimized multi-level caching.\r\n *\r\n * This method implements a three-tier caching strategy:\r\n * 1. Memory cache: Check if asset entity already has a blob URL\r\n * 2. Persistent cache: Check IndexedDB/localStorage for cached file\r\n * 3. Remote API: Fetch from backend as last resort\r\n *\r\n * Each level provides progressively better performance, with automatic\r\n * population of higher-level caches for future access optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @returns Promise resolving to a blob URL for the asset file\r\n */\r\n getAssetBlobURL = (assetID: string): Promise<string> => {\r\n const assetRepo = this.assetRepo;\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const getAssetFromCache = this.getAssetFromCache;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!assetRepo || !getAsset || !fetchAssetFile) {\r\n return Promise.reject();\r\n }\r\n\r\n // Level 1: Check memory cache (existing entities with blob URLs)\r\n const existing = assetRepo.get(assetID);\r\n if (existing && existing.blobURL) {\r\n return Promise.resolve(existing.blobURL);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n // Level 2: Check persistent cache\r\n if (getAssetFromCache) {\r\n getAssetFromCache(assetID)\r\n .then((cachedBlob) => {\r\n if (cachedBlob) {\r\n // Asset found in cache, get metadata and create file\r\n return getAsset(assetID).then((asset) => {\r\n fetchedAsset = asset;\r\n const filename = asset.filename || \"cached-asset\";\r\n return new File([cachedBlob], filename, {\r\n type: cachedBlob.type\r\n });\r\n });\r\n } else {\r\n // Level 3: Fetch from remote API\r\n return getAsset(assetID).then((asset) => {\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n });\r\n }\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future access (if not from cache already)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Cache error, fallback to normal flow\r\n this.warn(`Cache error or fetch error: ${e.message}`);\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n });\r\n } else {\r\n // No cache available, use direct API access\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Helper method for direct asset fetching without cache support.\r\n *\r\n * This method handles the direct API fetch workflow when caching\r\n * is not available or has failed. It still attempts to store the\r\n * result in cache for future optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param resolve - Success callback with blob URL\r\n * @param reject - Error callback with error details\r\n */\r\n private fetchAssetNormally = (\r\n assetID: string,\r\n resolve: (blobURL: string) => void,\r\n reject: (error: Error) => void\r\n ): void => {\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!getAsset || !fetchAssetFile) {\r\n reject(new Error(\"Required dependencies not found\"));\r\n return;\r\n }\r\n\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n getAsset(assetID)\r\n .then((asset) => {\r\n // Set loading state for UI feedback\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future optimization (if available)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Handle fetch errors with proper state cleanup\r\n if (fetchedAsset) {\r\n fetchedAsset.fetchError = e;\r\n fetchedAsset.isFetchingFile = false;\r\n }\r\n reject(e);\r\n });\r\n };\r\n\r\n /**\r\n * Initializes the GetAssetBlobURLUC and registers it as a singleton.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, GetAssetBlobURLUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GetAssetBlobURLUC.js","sourceRoot":"","sources":["../../../../src/Assets/UCs/GetAssetBlobURLUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,qBAAqB,EAGrB,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAgB,iBAAkB,SAAQ,WAAW;IAgBzD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,qBAAqB,CAC1B,iBAAiB,CAAC,IAAI,EACtB,UAAU,CACX,CAAC;IACJ,CAAC;;AA1BD,wDAAwD;AACjD,sBAAI,GAAG,mBAAmB,CAAC;AA4BpC;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAoB;IACxD,OAAO,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,oBAAqB,SAAQ,iBAAiB;IAClD,iEAAiE;IACjE,IAAY,SAAS;QACnB,OAAO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AAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBACzB,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;wBAC9B,OAAO;oBACT,CAAC;gBACH,CAAC;gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;gBAClB,gDAAgD;gBAChD,IAAI,YAAY,EAAE,CAAC;oBACjB,YAAY,CAAC,UAAU,GAAG,CAAC,CAAC;oBAC5B,YAAY,CAAC,cAAc,GAAG,KAAK,CAAC;gBACtC,CAAC;gBACD,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QASA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * GetAssetBlobURLUC.ts\r\n *\r\n * This use case provides optimized asset file retrieval with caching support,\r\n * returning blob URLs for immediate use in web applications.\r\n *\r\n * Key Concepts:\r\n * - Provides blob URLs for asset files with multi-level caching optimization\r\n * - Checks memory cache (existing entities) first for immediate access\r\n * - Falls back to persistent cache (IndexedDB/localStorage) for faster retrieval\r\n * - Finally fetches from remote API when cache misses occur\r\n * - Manages fetch state indicators for UI feedback\r\n * - Automatically stores fetched files in cache for future access\r\n *\r\n * Usage Patterns:\r\n * - Singleton use case accessed through static get() method\r\n * - Called with asset ID to retrieve blob URL for display or download\r\n * - Handles async operations with comprehensive error handling\r\n * - Optimizes performance through multi-level caching strategy\r\n */\r\n\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"@vived/core\";\r\nimport { FetchAssetFileFromAPIUC } from \"../../VivedAPI\";\r\nimport { GetAssetFromCacheUC, StoreAssetInCacheUC } from \"../../Cache\";\r\nimport { AssetEntity } from \"../Entities/AssetEntity\";\r\nimport { AssetRepo } from \"../Entities/AssetRepo\";\r\nimport { GetAssetUC } from \"./GetAssetUC\";\r\n\r\n/**\r\n * GetAssetBlobURLUC handles optimized retrieval of asset files as blob URLs.\r\n *\r\n * This singleton use case implements a multi-level caching strategy to minimize\r\n * network requests and provide fast access to asset files for web applications.\r\n */\r\nexport abstract class GetAssetBlobURLUC extends AppObjectUC {\r\n /** Static type identifier for component registration */\r\n static type = \"GetAssetBlobURLUC\";\r\n\r\n /**\r\n * Retrieves a blob URL for the specified asset file.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param useCache - Optional flag to control caching behavior (defaults to true)\r\n * @returns Promise resolving to a blob URL for immediate use\r\n */\r\n abstract getAssetBlobURL(\r\n assetID: string,\r\n useCache?: boolean\r\n ): Promise<string>;\r\n\r\n /**\r\n * Retrieves the singleton GetAssetBlobURLUC instance.\r\n *\r\n * @param appObjects - Repository for accessing the singleton component\r\n * @returns GetAssetBlobURLUC instance or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): GetAssetBlobURLUC | undefined {\r\n return getSingletonComponent<GetAssetBlobURLUC>(\r\n GetAssetBlobURLUC.type,\r\n appObjects\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new GetAssetBlobURLUC instance.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n * @returns A new GetAssetBlobURLUC implementation instance\r\n */\r\nexport function makeGetAssetBlobURLUC(appObject: AppObject): GetAssetBlobURLUC {\r\n return new GetAssetBlobURLUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Private implementation of GetAssetBlobURLUC with multi-level caching strategy.\r\n *\r\n * Key Implementation Details:\r\n * - Implements three-tier caching: memory (entities), persistent cache, and remote API\r\n * - Manages fetch state indicators for user feedback during operations\r\n * - Automatically caches fetched files for future access optimization\r\n * - Handles cache failures gracefully with fallback to direct API access\r\n * - Converts between Blob and File objects for compatibility\r\n * - Provides detailed error handling and logging for debugging\r\n */\r\nclass GetAssetBlobURLUCImp extends GetAssetBlobURLUC {\r\n /** Gets the asset repository for entity management and lookup */\r\n private get assetRepo() {\r\n return this.getCachedSingleton<AssetRepo>(AssetRepo.type);\r\n }\r\n\r\n /** Gets the API use case for fetching asset files from remote sources */\r\n private get fetchAssetFile() {\r\n return this.getCachedSingleton<FetchAssetFileFromAPIUC>(\r\n FetchAssetFileFromAPIUC.type\r\n )?.doFetch;\r\n }\r\n\r\n /** Gets the use case for retrieving asset metadata */\r\n private get getAsset() {\r\n return this.getCachedSingleton<GetAssetUC>(GetAssetUC.type)?.getAsset;\r\n }\r\n\r\n /** Gets the use case for retrieving assets from persistent cache */\r\n private get getAssetFromCache() {\r\n return this.getCachedSingleton<GetAssetFromCacheUC>(\r\n GetAssetFromCacheUC.type\r\n )?.getAsset;\r\n }\r\n\r\n /** Gets the use case for storing assets in persistent cache */\r\n private get storeAssetInCache() {\r\n return this.getCachedSingleton<StoreAssetInCacheUC>(\r\n StoreAssetInCacheUC.type\r\n )?.storeAsset;\r\n }\r\n\r\n /**\r\n * Retrieves an asset blob URL using optimized multi-level caching.\r\n *\r\n * This method implements a three-tier caching strategy:\r\n * 1. Memory cache: Check if asset entity already has a blob URL\r\n * 2. Persistent cache: Check IndexedDB/localStorage for cached file\r\n * 3. Remote API: Fetch from backend as last resort\r\n *\r\n * Each level provides progressively better performance, with automatic\r\n * population of higher-level caches for future access optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param useCache - Optional flag to control caching behavior (defaults to true)\r\n * @returns Promise resolving to a blob URL for the asset file\r\n */\r\n getAssetBlobURL = (\r\n assetID: string,\r\n useCache: boolean = true\r\n ): Promise<string> => {\r\n const assetRepo = this.assetRepo;\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const getAssetFromCache = this.getAssetFromCache;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!assetRepo || !getAsset || !fetchAssetFile) {\r\n return Promise.reject();\r\n }\r\n\r\n // If cache is disabled, skip all cache checks and go directly to API\r\n if (!useCache) {\r\n return new Promise((resolve, reject) => {\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n });\r\n }\r\n\r\n // Level 1: Check memory cache (existing entities with blob URLs)\r\n const existing = assetRepo.get(assetID);\r\n if (existing && existing.blobURL) {\r\n return Promise.resolve(existing.blobURL);\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n // Level 2: Check persistent cache\r\n if (getAssetFromCache) {\r\n getAssetFromCache(assetID)\r\n .then((cachedBlob) => {\r\n if (cachedBlob) {\r\n // Asset found in cache, get metadata and create file\r\n return getAsset(assetID).then((asset) => {\r\n fetchedAsset = asset;\r\n const filename = asset.filename || \"cached-asset\";\r\n return new File([cachedBlob], filename, {\r\n type: cachedBlob.type\r\n });\r\n });\r\n } else {\r\n // Level 3: Fetch from remote API\r\n return getAsset(assetID).then((asset) => {\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n });\r\n }\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future access (if not from cache already)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Cache error, fallback to normal flow\r\n this.warn(`Cache error or fetch error: ${e.message}`);\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n });\r\n } else {\r\n // No cache available, use direct API access\r\n this.fetchAssetNormally(assetID, resolve, reject);\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Helper method for direct asset fetching without cache support.\r\n *\r\n * This method handles the direct API fetch workflow when caching\r\n * is not available or has failed. It still attempts to store the\r\n * result in cache for future optimization.\r\n *\r\n * @param assetID - The unique identifier of the asset\r\n * @param resolve - Success callback with blob URL\r\n * @param reject - Error callback with error details\r\n */\r\n private fetchAssetNormally = (\r\n assetID: string,\r\n resolve: (blobURL: string) => void,\r\n reject: (error: Error) => void\r\n ): void => {\r\n const getAsset = this.getAsset;\r\n const fetchAssetFile = this.fetchAssetFile;\r\n const storeAssetInCache = this.storeAssetInCache;\r\n\r\n if (!getAsset || !fetchAssetFile) {\r\n reject(new Error(\"Required dependencies not found\"));\r\n return;\r\n }\r\n\r\n let fetchedAsset: AssetEntity | undefined;\r\n\r\n getAsset(assetID)\r\n .then((asset) => {\r\n // Set loading state for UI feedback\r\n asset.isFetchingFile = true;\r\n asset.fetchError = undefined;\r\n fetchedAsset = asset;\r\n return fetchAssetFile(asset);\r\n })\r\n .then((file) => {\r\n if (fetchedAsset) {\r\n // Create blob URL and update entity\r\n fetchedAsset.setFile(file);\r\n fetchedAsset.isFetchingFile = false;\r\n\r\n // Store in cache for future optimization (if available)\r\n if (storeAssetInCache) {\r\n storeAssetInCache(\r\n assetID,\r\n new Blob([file], { type: file.type }),\r\n file.type\r\n ).catch((e) => {\r\n this.warn(`Failed to cache asset: ${e.message}`);\r\n });\r\n }\r\n\r\n if (fetchedAsset.blobURL) {\r\n resolve(fetchedAsset.blobURL);\r\n return;\r\n }\r\n }\r\n reject(new Error(\"Blob URL is empty\"));\r\n })\r\n .catch((e: Error) => {\r\n // Handle fetch errors with proper state cleanup\r\n if (fetchedAsset) {\r\n fetchedAsset.fetchError = e;\r\n fetchedAsset.isFetchingFile = false;\r\n }\r\n reject(e);\r\n });\r\n };\r\n\r\n /**\r\n * Initializes the GetAssetBlobURLUC and registers it as a singleton.\r\n *\r\n * @param appObject - The AppObject that will host this singleton use case\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, GetAssetBlobURLUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DomainFactory } from "@vived/core";
|
|
2
|
+
import { makeCacheEntity, makeAssetCacheEntity, makeScriptCacheEntity } from "../Entities";
|
|
3
|
+
import { makeGetAssetFromCacheUC, makeGetScriptFromCacheUC, makeStoreAssetInCacheUC, makeStoreScriptInCacheUC } from "../UCs";
|
|
4
|
+
/**
|
|
5
|
+
* Factory responsible for setting up the Cache domain components.
|
|
6
|
+
* This factory initializes all entities, use cases, and presentation models
|
|
7
|
+
* required for the Cache functionality.
|
|
8
|
+
*/
|
|
9
|
+
export class CacheFeatureFactory extends DomainFactory {
|
|
10
|
+
constructor(appObject) {
|
|
11
|
+
super(appObject);
|
|
12
|
+
// Unique name for this factory
|
|
13
|
+
this.factoryName = "CacheFeatureFactory";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Sets up all entities required for the Cache system
|
|
17
|
+
*/
|
|
18
|
+
setupEntities() {
|
|
19
|
+
// Initialize entities
|
|
20
|
+
makeCacheEntity(this.appObject);
|
|
21
|
+
makeScriptCacheEntity(this.appObject);
|
|
22
|
+
makeAssetCacheEntity(this.appObject);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets up all use cases for the Cache system
|
|
26
|
+
*/
|
|
27
|
+
setupUCs() {
|
|
28
|
+
// Cache use cases
|
|
29
|
+
makeGetScriptFromCacheUC(this.appObject);
|
|
30
|
+
makeStoreScriptInCacheUC(this.appObject);
|
|
31
|
+
makeGetAssetFromCacheUC(this.appObject);
|
|
32
|
+
makeStoreAssetInCacheUC(this.appObject);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets up all presentation managers for the Cache system
|
|
36
|
+
*/
|
|
37
|
+
setupPMs() {
|
|
38
|
+
// No presentation managers exist for the Cache system
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Performs any final setup operations after all components are initialized
|
|
42
|
+
*/
|
|
43
|
+
finalSetup() {
|
|
44
|
+
// No additional setup required for cache
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=CacheFeatureFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheFeatureFactory.js","sourceRoot":"","sources":["../../../../src/Cache/Factories/CacheFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,QAAQ,CAAC;AAEhB;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IAIpD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QAJnB,+BAA+B;QACtB,gBAAW,GAAG,qBAAqB,CAAC;IAI7C,CAAC;IAED;;OAEG;IACH,aAAa;QACX,sBAAsB;QACtB,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,kBAAkB;QAClB,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,sDAAsD;IACxD,CAAC;IAED;;OAEG;IACH,UAAU;QACR,yCAAyC;IAC3C,CAAC;CACF","sourcesContent":["import { AppObject, DomainFactory } from \"@vived/core\";\r\nimport {\r\n makeCacheEntity,\r\n makeAssetCacheEntity,\r\n makeScriptCacheEntity\r\n} from \"../Entities\";\r\nimport {\r\n makeGetAssetFromCacheUC,\r\n makeGetScriptFromCacheUC,\r\n makeStoreAssetInCacheUC,\r\n makeStoreScriptInCacheUC\r\n} from \"../UCs\";\r\n\r\n/**\r\n * Factory responsible for setting up the Cache domain components.\r\n * This factory initializes all entities, use cases, and presentation models\r\n * required for the Cache functionality.\r\n */\r\nexport class CacheFeatureFactory extends DomainFactory {\r\n // Unique name for this factory\r\n readonly factoryName = \"CacheFeatureFactory\";\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject);\r\n }\r\n\r\n /**\r\n * Sets up all entities required for the Cache system\r\n */\r\n setupEntities(): void {\r\n // Initialize entities\r\n makeCacheEntity(this.appObject);\r\n makeScriptCacheEntity(this.appObject);\r\n makeAssetCacheEntity(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all use cases for the Cache system\r\n */\r\n setupUCs(): void {\r\n // Cache use cases\r\n makeGetScriptFromCacheUC(this.appObject);\r\n makeStoreScriptInCacheUC(this.appObject);\r\n makeGetAssetFromCacheUC(this.appObject);\r\n makeStoreAssetInCacheUC(this.appObject);\r\n }\r\n\r\n /**\r\n * Sets up all presentation managers for the Cache system\r\n */\r\n setupPMs(): void {\r\n // No presentation managers exist for the Cache system\r\n }\r\n\r\n /**\r\n * Performs any final setup operations after all components are initialized\r\n */\r\n finalSetup(): void {\r\n // No additional setup required for cache\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Cache/Factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./setupCache\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Cache/Factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"./setupCache\";\r\nexport * from \"./CacheFeatureFactory\";\r\n"]}
|
|
@@ -6,7 +6,6 @@ import { AppObject, DomainFactory } from "@vived/core";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class AppsFeatureFactory extends DomainFactory {
|
|
8
8
|
readonly factoryName = "AppsFeatureFactory";
|
|
9
|
-
private appRepoAO;
|
|
10
9
|
constructor(appObject: AppObject);
|
|
11
10
|
/**
|
|
12
11
|
* Sets up all entities required for the Apps system
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppsFeatureFactory.d.ts","sourceRoot":"","sources":["../../../../src/Apps/Factories/AppsFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIvD;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;IAEnD,QAAQ,CAAC,WAAW,wBAAwB;
|
|
1
|
+
{"version":3,"file":"AppsFeatureFactory.d.ts","sourceRoot":"","sources":["../../../../src/Apps/Factories/AppsFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIvD;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;IAEnD,QAAQ,CAAC,WAAW,wBAAwB;gBAEhC,SAAS,EAAE,SAAS;IAIhC;;OAEG;IACH,aAAa,IAAI,IAAI;IAKrB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fetchAssetFile.ts
|
|
3
|
+
*
|
|
4
|
+
* This controller function retrieves an asset file as a File object,
|
|
5
|
+
* handling caching and error management for file access operations.
|
|
6
|
+
*
|
|
7
|
+
* Key Concepts:
|
|
8
|
+
* - Retrieves asset files as File objects for download or processing
|
|
9
|
+
* - Uses GetAssetFileUC to handle caching and file retrieval logic
|
|
10
|
+
* - Provides error handling for missing components
|
|
11
|
+
* - Coordinates with asset file management workflows
|
|
12
|
+
*
|
|
13
|
+
* Usage Patterns:
|
|
14
|
+
* - Called from UI components when users need asset file access
|
|
15
|
+
* - Used in asset management workflows for file processing
|
|
16
|
+
* - Integrated with download and preview functionality
|
|
17
|
+
*/
|
|
18
|
+
import { AppObjectRepo } from "@vived/core";
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves an asset file as a File object.
|
|
21
|
+
*
|
|
22
|
+
* This function provides a controller-level interface for asset file retrieval.
|
|
23
|
+
* It handles the complete file access workflow including caching optimization,
|
|
24
|
+
* error handling, and returns a File object ready for use in web applications.
|
|
25
|
+
*
|
|
26
|
+
* @param assetID - The unique identifier of the asset whose file should be retrieved
|
|
27
|
+
* @param appObjects - Repository for accessing asset-related app objects and components
|
|
28
|
+
* @returns Promise<File> - A promise that resolves to the File object for the asset,
|
|
29
|
+
* or undefined if the operation cannot be completed
|
|
30
|
+
*/
|
|
31
|
+
export declare function fetchAssetFile(assetID: string, appObjects: AppObjectRepo): Promise<File> | undefined;
|
|
32
|
+
//# sourceMappingURL=fetchAssetFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAssetFile.d.ts","sourceRoot":"","sources":["../../../../src/Assets/Controllers/fetchAssetFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAQ3B"}
|
|
@@ -21,6 +21,7 @@ export * from "./archiveAsset";
|
|
|
21
21
|
export * from "./deleteAsset";
|
|
22
22
|
export * from "./downloadAssetFile";
|
|
23
23
|
export * from "./editAppAsset";
|
|
24
|
+
export * from "./fetchAssetFile";
|
|
24
25
|
export * from "./getAppAssets";
|
|
25
26
|
export * from "./newAppAsset";
|
|
26
27
|
export * from "./toggleShowArchivedAssets";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Assets/Controllers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Assets/Controllers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
|
@@ -6,9 +6,6 @@ import { AppObject, DomainFactory } from "@vived/core";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class AssetsFactory extends DomainFactory {
|
|
8
8
|
readonly factoryName = "AssetsFactory";
|
|
9
|
-
private assetRepoAO;
|
|
10
|
-
private appAssetsAO;
|
|
11
|
-
private assetRepo;
|
|
12
9
|
constructor(appObject: AppObject);
|
|
13
10
|
/**
|
|
14
11
|
* Sets up all entities required for the Assets system
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsFactory.d.ts","sourceRoot":"","sources":["../../../../src/Assets/Factories/AssetsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"AssetsFactory.d.ts","sourceRoot":"","sources":["../../../../src/Assets/Factories/AssetsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,aAAa,EAAE,MAAM,aAAa,CAAC;AAsBtE;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAE9C,QAAQ,CAAC,WAAW,mBAAmB;gBAE3B,SAAS,EAAE,SAAS;IAIhC;;OAEG;IACH,aAAa,IAAI,IAAI;IAMrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAShB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB"}
|
|
@@ -32,9 +32,10 @@ export declare abstract class GetAssetBlobURLUC extends AppObjectUC {
|
|
|
32
32
|
* Retrieves a blob URL for the specified asset file.
|
|
33
33
|
*
|
|
34
34
|
* @param assetID - The unique identifier of the asset
|
|
35
|
+
* @param useCache - Optional flag to control caching behavior (defaults to true)
|
|
35
36
|
* @returns Promise resolving to a blob URL for immediate use
|
|
36
37
|
*/
|
|
37
|
-
abstract getAssetBlobURL(assetID: string): Promise<string>;
|
|
38
|
+
abstract getAssetBlobURL(assetID: string, useCache?: boolean): Promise<string>;
|
|
38
39
|
/**
|
|
39
40
|
* Retrieves the singleton GetAssetBlobURLUC instance.
|
|
40
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetAssetBlobURLUC.d.ts","sourceRoot":"","sources":["../../../../src/Assets/UCs/GetAssetBlobURLUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAEL,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAOrB;;;;;GAKG;AACH,8BAAsB,iBAAkB,SAAQ,WAAW;IACzD,wDAAwD;IACxD,MAAM,CAAC,IAAI,SAAuB;IAElC
|
|
1
|
+
{"version":3,"file":"GetAssetBlobURLUC.d.ts","sourceRoot":"","sources":["../../../../src/Assets/UCs/GetAssetBlobURLUC.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAEL,SAAS,EACT,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAOrB;;;;;GAKG;AACH,8BAAsB,iBAAkB,SAAQ,WAAW;IACzD,wDAAwD;IACxD,MAAM,CAAC,IAAI,SAAuB;IAElC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CACtB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,MAAM,CAAC;IAElB;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,GAAG,iBAAiB,GAAG,SAAS;CAMrE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,iBAAiB,CAE7E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppObject, DomainFactory } from "@vived/core";
|
|
2
|
+
/**
|
|
3
|
+
* Factory responsible for setting up the Cache domain components.
|
|
4
|
+
* This factory initializes all entities, use cases, and presentation models
|
|
5
|
+
* required for the Cache functionality.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CacheFeatureFactory extends DomainFactory {
|
|
8
|
+
readonly factoryName = "CacheFeatureFactory";
|
|
9
|
+
constructor(appObject: AppObject);
|
|
10
|
+
/**
|
|
11
|
+
* Sets up all entities required for the Cache system
|
|
12
|
+
*/
|
|
13
|
+
setupEntities(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Sets up all use cases for the Cache system
|
|
16
|
+
*/
|
|
17
|
+
setupUCs(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Sets up all presentation managers for the Cache system
|
|
20
|
+
*/
|
|
21
|
+
setupPMs(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Performs any final setup operations after all components are initialized
|
|
24
|
+
*/
|
|
25
|
+
finalSetup(): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=CacheFeatureFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheFeatureFactory.d.ts","sourceRoot":"","sources":["../../../../src/Cache/Factories/CacheFeatureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAavD;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;IAEpD,QAAQ,CAAC,WAAW,yBAAyB;gBAEjC,SAAS,EAAE,SAAS;IAIhC;;OAEG;IACH,aAAa,IAAI,IAAI;IAOrB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAQhB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Cache/Factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Cache/Factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC"}
|