@vived/host 4.11.0 → 4.11.1

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.
Files changed (77) hide show
  1. package/dist/cjs/Apps/Entities/AppEntity.js +75 -14
  2. package/dist/cjs/Apps/Entities/AppEntity.js.map +1 -1
  3. package/dist/cjs/Apps/Factories/AppsFeatureFactory.js +48 -0
  4. package/dist/cjs/Apps/Factories/AppsFeatureFactory.js.map +1 -0
  5. package/dist/cjs/Apps/Factories/index.js +18 -0
  6. package/dist/cjs/Apps/Factories/index.js.map +1 -0
  7. package/dist/cjs/Apps/index.js +1 -0
  8. package/dist/cjs/Apps/index.js.map +1 -1
  9. package/dist/cjs/VivedAPI/Adapters/apiStageAdapter.js.map +1 -1
  10. package/dist/cjs/VivedAPI/Adapters/index.js.map +1 -1
  11. package/dist/cjs/VivedAPI/Adapters/userTokenAdapter.js.map +1 -1
  12. package/dist/cjs/VivedAPI/Controllers/index.js.map +1 -1
  13. package/dist/cjs/VivedAPI/Controllers/loginUser.js.map +1 -1
  14. package/dist/cjs/VivedAPI/Controllers/logoutUser.js.map +1 -1
  15. package/dist/cjs/VivedAPI/Controllers/setApiStage.js.map +1 -1
  16. package/dist/cjs/VivedAPI/Entities/VivedAPIEntity.js.map +1 -1
  17. package/dist/cjs/VivedAPI/Entities/index.js.map +1 -1
  18. package/dist/cjs/VivedAPI/Factories/index.js.map +1 -1
  19. package/dist/cjs/VivedAPI/Factories/setupVivedAPIForSandbox.js.map +1 -1
  20. package/dist/cjs/VivedAPI/Mocks/MockJsonRequestUC.js.map +1 -1
  21. package/dist/cjs/VivedAPI/Mocks/index.js.map +1 -1
  22. package/dist/cjs/VivedAPI/PMs/ApiStagePM.js.map +1 -1
  23. package/dist/cjs/VivedAPI/PMs/UserTokenPM.js.map +1 -1
  24. package/dist/cjs/VivedAPI/PMs/index.js.map +1 -1
  25. package/dist/cjs/VivedAPI/UCs/BasicFetchUC.js.map +1 -1
  26. package/dist/cjs/VivedAPI/UCs/BlobRequestUC.js.map +1 -1
  27. package/dist/cjs/VivedAPI/UCs/DeleteAssetOnAPIUC.js.map +1 -1
  28. package/dist/cjs/VivedAPI/UCs/FileUploadUC.js.map +1 -1
  29. package/dist/cjs/VivedAPI/UCs/JsonRequestUC.js.map +1 -1
  30. package/dist/cjs/VivedAPI/UCs/PostNewAssetUC.js.map +1 -1
  31. package/dist/cjs/VivedAPI/UCs/SignedAuthTokenUC.js.map +1 -1
  32. package/dist/cjs/VivedAPI/UCs/UserAuthUC.js.map +1 -1
  33. package/dist/cjs/VivedAPI/UCs/index.js.map +1 -1
  34. package/dist/cjs/VivedAPI/index.js.map +1 -1
  35. package/dist/esm/Apps/Entities/AppEntity.js +75 -14
  36. package/dist/esm/Apps/Entities/AppEntity.js.map +1 -1
  37. package/dist/esm/Apps/Factories/AppsFeatureFactory.js +44 -0
  38. package/dist/esm/Apps/Factories/AppsFeatureFactory.js.map +1 -0
  39. package/dist/esm/Apps/Factories/index.js +2 -0
  40. package/dist/esm/Apps/Factories/index.js.map +1 -0
  41. package/dist/esm/Apps/index.js +1 -0
  42. package/dist/esm/Apps/index.js.map +1 -1
  43. package/dist/esm/VivedAPI/Adapters/apiStageAdapter.js.map +1 -1
  44. package/dist/esm/VivedAPI/Adapters/index.js.map +1 -1
  45. package/dist/esm/VivedAPI/Adapters/userTokenAdapter.js.map +1 -1
  46. package/dist/esm/VivedAPI/Controllers/index.js.map +1 -1
  47. package/dist/esm/VivedAPI/Controllers/loginUser.js.map +1 -1
  48. package/dist/esm/VivedAPI/Controllers/logoutUser.js.map +1 -1
  49. package/dist/esm/VivedAPI/Controllers/setApiStage.js.map +1 -1
  50. package/dist/esm/VivedAPI/Entities/VivedAPIEntity.js.map +1 -1
  51. package/dist/esm/VivedAPI/Entities/index.js.map +1 -1
  52. package/dist/esm/VivedAPI/Factories/index.js.map +1 -1
  53. package/dist/esm/VivedAPI/Factories/setupVivedAPIForSandbox.js.map +1 -1
  54. package/dist/esm/VivedAPI/Mocks/MockJsonRequestUC.js.map +1 -1
  55. package/dist/esm/VivedAPI/Mocks/index.js.map +1 -1
  56. package/dist/esm/VivedAPI/PMs/ApiStagePM.js.map +1 -1
  57. package/dist/esm/VivedAPI/PMs/UserTokenPM.js.map +1 -1
  58. package/dist/esm/VivedAPI/PMs/index.js.map +1 -1
  59. package/dist/esm/VivedAPI/UCs/BasicFetchUC.js.map +1 -1
  60. package/dist/esm/VivedAPI/UCs/BlobRequestUC.js.map +1 -1
  61. package/dist/esm/VivedAPI/UCs/DeleteAssetOnAPIUC.js.map +1 -1
  62. package/dist/esm/VivedAPI/UCs/FileUploadUC.js.map +1 -1
  63. package/dist/esm/VivedAPI/UCs/JsonRequestUC.js.map +1 -1
  64. package/dist/esm/VivedAPI/UCs/PostNewAssetUC.js.map +1 -1
  65. package/dist/esm/VivedAPI/UCs/SignedAuthTokenUC.js.map +1 -1
  66. package/dist/esm/VivedAPI/UCs/UserAuthUC.js.map +1 -1
  67. package/dist/esm/VivedAPI/UCs/index.js.map +1 -1
  68. package/dist/esm/VivedAPI/index.js.map +1 -1
  69. package/dist/types/Apps/Entities/AppEntity.d.ts +40 -1
  70. package/dist/types/Apps/Entities/AppEntity.d.ts.map +1 -1
  71. package/dist/types/Apps/Factories/AppsFeatureFactory.d.ts +28 -0
  72. package/dist/types/Apps/Factories/AppsFeatureFactory.d.ts.map +1 -0
  73. package/dist/types/Apps/Factories/index.d.ts +2 -0
  74. package/dist/types/Apps/Factories/index.d.ts.map +1 -0
  75. package/dist/types/Apps/index.d.ts +1 -0
  76. package/dist/types/Apps/index.d.ts.map +1 -1
  77. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteAssetOnAPIUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/DeleteAssetOnAPIUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA0CH,wDAIC;AA5CD,sCAKqB;AACrB,+DAA4D;AA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AAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,YAAY,EAAE;qBACX,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;oBACd,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;oBAE7D,MAAM,OAAO,GAAuB;wBAClC,MAAM,EAAE,QAAQ;wBAChB,OAAO,EAAE;4BACP,aAAa,EAAE,SAAS,GAAG,KAAK;yBACjC;qBACF,CAAC;oBAEF,OAAO,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACzC,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBACV,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBACX,MAAM,CAAC,CAAC,CAAC,CAAC;oBACV,OAAO;gBACT,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAIA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * DeleteAssetOnAPIUC.ts\r\n * \r\n * This file defines the Use Case for deleting assets via the VIVED API.\r\n * DeleteAssetOnAPIUC handles the workflow of removing asset records from\r\n * the backend storage system through authenticated API requests.\r\n * \r\n * Key concepts:\r\n * - Orchestrates asset deletion through API endpoints\r\n * - Manages authentication tokens for authorized deletion requests\r\n * - Coordinates between JsonRequestUC and SignedAuthTokenUC\r\n * - Handles error cases and provides feedback for deletion operations\r\n * - Ensures proper cleanup of asset data and metadata\r\n * \r\n * Usage pattern:\r\n * 1. Get a UC instance using DeleteAssetOnAPIUC.get(appObjects) or makeDeleteAssetOnAPIUC\r\n * 2. Call doDelete with the asset ID to remove\r\n * 3. Handle the returned Promise for deletion completion\r\n * 4. UC manages authentication and API communication details\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 { VivedAPIEntity } from \"../Entities/VivedAPIEntity\";\r\nimport { JsonRequestUC, RequestJSONOptions } from \"./JsonRequestUC\";\r\nimport { SignedAuthTokenUC } from \"./SignedAuthTokenUC\";\r\n\r\n/**\r\n * DeleteAssetOnAPIUC provides functionality for deleting assets via API.\r\n * Abstract class that defines the interface for asset deletion operations.\r\n */\r\nexport abstract class DeleteAssetOnAPIUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"DeleteAssetOnAPIUC\";\r\n\r\n /**\r\n * Deletes an asset from the API by its ID\r\n * @param assetID The unique identifier of the asset to delete\r\n * @returns Promise that resolves when deletion is complete\r\n */\r\n abstract doDelete(assetID: string): Promise<void>;\r\n\r\n /**\r\n * Retrieves a DeleteAssetOnAPIUC component from an AppObject\r\n * @param appObjects The AppObjectRepo to get the component from\r\n * @returns The DeleteAssetOnAPIUC component or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): DeleteAssetOnAPIUC | undefined {\r\n return getSingletonComponent(DeleteAssetOnAPIUC.type, appObjects);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new DeleteAssetOnAPIUC instance\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new DeleteAssetOnAPIUC instance\r\n */\r\nexport function makeDeleteAssetOnAPIUC(\r\n appObject: AppObject\r\n): DeleteAssetOnAPIUC {\r\n return new DeleteAssetUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of DeleteAssetOnAPIUC\r\n * This private class handles the actual asset deletion workflow\r\n */\r\nclass DeleteAssetUCImp extends DeleteAssetOnAPIUC {\r\n private get jsonRequester() {\r\n return this.getCachedSingleton<JsonRequestUC>(JsonRequestUC.type)\r\n ?.doRequest;\r\n }\r\n\r\n private get getAuthToken() {\r\n return this.getCachedSingleton<SignedAuthTokenUC>(SignedAuthTokenUC.type)\r\n ?.getAuthToken;\r\n }\r\n\r\n private get vivedAPI() {\r\n return this.getCachedSingleton<VivedAPIEntity>(VivedAPIEntity.type);\r\n }\r\n\r\n doDelete = (assetID: string): Promise<void> => {\r\n const getAuthToken = this.getAuthToken;\r\n const vivedAPI = this.vivedAPI;\r\n const jsonRequester = this.jsonRequester;\r\n\r\n if (!getAuthToken || !vivedAPI || !jsonRequester) {\r\n return Promise.reject();\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n getAuthToken()\r\n .then((token) => {\r\n const postURL = vivedAPI.getEndpointURL(`assets/${assetID}`);\r\n\r\n const options: RequestJSONOptions = {\r\n method: \"DELETE\",\r\n headers: {\r\n Authorization: \"Bearer \" + token\r\n }\r\n };\r\n\r\n return jsonRequester(postURL, options);\r\n })\r\n .then((_) => {\r\n resolve();\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n return;\r\n });\r\n });\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, DeleteAssetOnAPIUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DeleteAssetOnAPIUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/DeleteAssetOnAPIUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA0CH,wDAIC;AA5CD,sCAKqB;AACrB,+DAA4D;AAC5D,mDAAoE;AACpE,2DAAwD;AAExD;;;GAGG;AACH,MAAsB,kBAAmB,SAAQ,kBAAW;IAW1D;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC;;AAlBH,gDAmBC;AAlBC,gDAAgD;AACzC,uBAAI,GAAG,oBAAoB,CAAC;AAmBrC;;;;GAIG;AACH,SAAgB,sBAAsB,CACpC,SAAoB;IAEpB,OAAO,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG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E,EAAE;oBACV,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBACX,MAAM,CAAC,CAAC,CAAC,CAAC;oBACV,OAAO;gBACT,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAIA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * DeleteAssetOnAPIUC.ts\r\n *\r\n * This file defines the Use Case for deleting assets via the VIVED API.\r\n * DeleteAssetOnAPIUC handles the workflow of removing asset records from\r\n * the backend storage system through authenticated API requests.\r\n *\r\n * Key concepts:\r\n * - Orchestrates asset deletion through API endpoints\r\n * - Manages authentication tokens for authorized deletion requests\r\n * - Coordinates between JsonRequestUC and SignedAuthTokenUC\r\n * - Handles error cases and provides feedback for deletion operations\r\n * - Ensures proper cleanup of asset data and metadata\r\n *\r\n * Usage pattern:\r\n * 1. Get a UC instance using DeleteAssetOnAPIUC.get(appObjects) or makeDeleteAssetOnAPIUC\r\n * 2. Call doDelete with the asset ID to remove\r\n * 3. Handle the returned Promise for deletion completion\r\n * 4. UC manages authentication and API communication details\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 { VivedAPIEntity } from \"../Entities/VivedAPIEntity\";\r\nimport { JsonRequestUC, RequestJSONOptions } from \"./JsonRequestUC\";\r\nimport { SignedAuthTokenUC } from \"./SignedAuthTokenUC\";\r\n\r\n/**\r\n * DeleteAssetOnAPIUC provides functionality for deleting assets via API.\r\n * Abstract class that defines the interface for asset deletion operations.\r\n */\r\nexport abstract class DeleteAssetOnAPIUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"DeleteAssetOnAPIUC\";\r\n\r\n /**\r\n * Deletes an asset from the API by its ID\r\n * @param assetID The unique identifier of the asset to delete\r\n * @returns Promise that resolves when deletion is complete\r\n */\r\n abstract doDelete(assetID: string): Promise<void>;\r\n\r\n /**\r\n * Retrieves a DeleteAssetOnAPIUC component from an AppObject\r\n * @param appObjects The AppObjectRepo to get the component from\r\n * @returns The DeleteAssetOnAPIUC component or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): DeleteAssetOnAPIUC | undefined {\r\n return getSingletonComponent(DeleteAssetOnAPIUC.type, appObjects);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new DeleteAssetOnAPIUC instance\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new DeleteAssetOnAPIUC instance\r\n */\r\nexport function makeDeleteAssetOnAPIUC(\r\n appObject: AppObject\r\n): DeleteAssetOnAPIUC {\r\n return new DeleteAssetUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of DeleteAssetOnAPIUC\r\n * This private class handles the actual asset deletion workflow\r\n */\r\nclass DeleteAssetUCImp extends DeleteAssetOnAPIUC {\r\n private get jsonRequester() {\r\n return this.getCachedSingleton<JsonRequestUC>(JsonRequestUC.type)\r\n ?.doRequest;\r\n }\r\n\r\n private get getAuthToken() {\r\n return this.getCachedSingleton<SignedAuthTokenUC>(SignedAuthTokenUC.type)\r\n ?.getAuthToken;\r\n }\r\n\r\n private get vivedAPI() {\r\n return this.getCachedSingleton<VivedAPIEntity>(VivedAPIEntity.type);\r\n }\r\n\r\n doDelete = (assetID: string): Promise<void> => {\r\n const getAuthToken = this.getAuthToken;\r\n const vivedAPI = this.vivedAPI;\r\n const jsonRequester = this.jsonRequester;\r\n\r\n if (!getAuthToken || !vivedAPI || !jsonRequester) {\r\n return Promise.reject();\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n getAuthToken()\r\n .then((token) => {\r\n const postURL = vivedAPI.getEndpointURL(`assets/${assetID}`);\r\n\r\n const options: RequestJSONOptions = {\r\n method: \"DELETE\",\r\n headers: {\r\n Authorization: \"Bearer \" + token\r\n }\r\n };\r\n\r\n return jsonRequester(postURL, options);\r\n })\r\n .then((_) => {\r\n resolve();\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n return;\r\n });\r\n });\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, DeleteAssetOnAPIUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploadUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/FileUploadUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA0CH,4CAEC;AA1CD,sCAKqB;AACrB,+DAA4D;AAC5D,iDAAiE;AACjE,mDAAgD;AAEhD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,kBAAW;IAWpD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC9D,CAAC;;AAlBH,oCAmBC;AAlBC,gDAAgD;AACzC,iBAAI,GAAG,cAAc,CAAC;AAmB/B;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,SAAoB;IACnD,OAAO,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,eAAgB,SAAQ,YAAY;IACxC,IAAY,QAAQ;QAClB,OAAO,IAAI,CAAC,kBAAkB,CAAiB,+BAAc,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,kBAAkB,CAAgB,6BAAa,CAAC,IAAI,CAAC;YAC/D,EAAE,SAAS,CAAC;IAChB,CAAC;IAED,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,kBAAkB,CAAe,2BAAY,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC7E,CAAC;IAmCD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,YAAY,C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the Use Case for uploading files to the VIVED API.\r\n * FileUploadUC handles the process of uploading file data to storage endpoints,\r\n * managing multipart form data and upload progress.\r\n * \r\n * Key concepts:\r\n * - Abstract UC defining the interface for file upload operations\r\n * - Handles file upload workflows with progress tracking\r\n * - Coordinates with BasicFetchUC for HTTP transport\r\n * - Manages multipart form data encoding and transmission\r\n * - Provides error handling for upload failures\r\n * \r\n * Usage pattern:\r\n * 1. Get a UC instance using FileUploadUC.get(appObjects) or makeFileUploadUC\r\n * 2. Call doUpload with File object to upload\r\n * 3. Handle the returned Promise for upload completion\r\n * 4. UC manages the HTTP upload mechanics and error handling\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 { VivedAPIEntity } from \"../Entities/VivedAPIEntity\";\r\nimport { BasicFetchOptions, BasicFetchUC } from \"./BasicFetchUC\";\r\nimport { JsonRequestUC } from \"./JsonRequestUC\";\r\n\r\n/**\r\n * FileUploadUC provides functionality for uploading files to APIs.\r\n * Abstract class that defines the interface for file upload operations.\r\n */\r\nexport abstract class FileUploadUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"FileUploadUC\";\r\n\r\n /**\r\n * Uploads a file to the configured API endpoint\r\n * @param file The File object to upload\r\n * @returns Promise that resolves when upload is complete\r\n */\r\n abstract doUpload(file: File): Promise<void>;\r\n\r\n /**\r\n * Retrieves a FileUploadUC component from an AppObject\r\n * @param appObjects The AppObjectRepo to get the component from\r\n * @returns The FileUploadUC component or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): FileUploadUC | undefined {\r\n return getSingletonComponent(FileUploadUC.type, appObjects);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new FileUploadUC instance\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new FileUploadUC instance\r\n */\r\nexport function makeFileUploadUC(appObject: AppObject): FileUploadUC {\r\n return new FileUploadUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of FileUploadUC\r\n * This private class handles the actual file upload mechanics\r\n */\r\nclass FileUploadUCImp extends FileUploadUC {\r\n private get vivedAPI(): VivedAPIEntity | undefined {\r\n return this.getCachedSingleton<VivedAPIEntity>(VivedAPIEntity.type);\r\n }\r\n\r\n private get requestJSON() {\r\n return this.getCachedSingleton<JsonRequestUC>(JsonRequestUC.type)\r\n ?.doRequest;\r\n }\r\n\r\n private get basicFetch() {\r\n return this.getCachedSingleton<BasicFetchUC>(BasicFetchUC.type)?.doRequest;\r\n }\r\n\r\n doUpload = (file: File): Promise<void> => {\r\n const vivedAPI = this.vivedAPI;\r\n const requestJSON = this.requestJSON;\r\n const basicFetch = this.basicFetch;\r\n\r\n if (!vivedAPI || !requestJSON || !basicFetch) {\r\n return Promise.reject();\r\n }\r\n return new Promise<void>((resolve, reject) => {\r\n const getUploadURL = vivedAPI.getEndpointURL(\r\n `upload/large/DataVariants/${file.name}`\r\n );\r\n\r\n requestJSON(getUploadURL)\r\n .then((uploadURL) => {\r\n const url = new URL(uploadURL as string);\r\n const options: BasicFetchOptions = {\r\n method: \"PUT\",\r\n body: file\r\n };\r\n\r\n return basicFetch(url, options);\r\n })\r\n .then((_) => {\r\n resolve();\r\n })\r\n .catch((e: Error) => {\r\n this.warn(e.message);\r\n reject(e);\r\n });\r\n });\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, FileUploadUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FileUploadUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/FileUploadUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA0CH,4CAEC;AA1CD,sCAKqB;AACrB,+DAA4D;AAC5D,iDAAiE;AACjE,mDAAgD;AAEhD;;;GAGG;AACH,MAAsB,YAAa,SAAQ,kBAAW;IAWpD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAA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AC,YAAY,CAAC;qBACtB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;oBAClB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAmB,CAAC,CAAC;oBACzC,MAAM,OAAO,GAAsB;wBACjC,MAAM,EAAE,KAAK;wBACb,IAAI,EAAE,IAAI;qBACX,CAAC;oBAEF,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBAClC,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBACV,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;oBAClB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;oBACrB,MAAM,CAAC,CAAC,CAAC,CAAC;gBACZ,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAIA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * FileUploadUC.ts\r\n *\r\n * This file defines the Use Case for uploading files to the VIVED API.\r\n * FileUploadUC handles the process of uploading file data to storage endpoints,\r\n * managing multipart form data and upload progress.\r\n *\r\n * Key concepts:\r\n * - Abstract UC defining the interface for file upload operations\r\n * - Handles file upload workflows with progress tracking\r\n * - Coordinates with BasicFetchUC for HTTP transport\r\n * - Manages multipart form data encoding and transmission\r\n * - Provides error handling for upload failures\r\n *\r\n * Usage pattern:\r\n * 1. Get a UC instance using FileUploadUC.get(appObjects) or makeFileUploadUC\r\n * 2. Call doUpload with File object to upload\r\n * 3. Handle the returned Promise for upload completion\r\n * 4. UC manages the HTTP upload mechanics and error handling\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 { VivedAPIEntity } from \"../Entities/VivedAPIEntity\";\r\nimport { BasicFetchOptions, BasicFetchUC } from \"./BasicFetchUC\";\r\nimport { JsonRequestUC } from \"./JsonRequestUC\";\r\n\r\n/**\r\n * FileUploadUC provides functionality for uploading files to APIs.\r\n * Abstract class that defines the interface for file upload operations.\r\n */\r\nexport abstract class FileUploadUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"FileUploadUC\";\r\n\r\n /**\r\n * Uploads a file to the configured API endpoint\r\n * @param file The File object to upload\r\n * @returns Promise that resolves when upload is complete\r\n */\r\n abstract doUpload(file: File): Promise<void>;\r\n\r\n /**\r\n * Retrieves a FileUploadUC component from an AppObject\r\n * @param appObjects The AppObjectRepo to get the component from\r\n * @returns The FileUploadUC component or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): FileUploadUC | undefined {\r\n return getSingletonComponent(FileUploadUC.type, appObjects);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new FileUploadUC instance\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new FileUploadUC instance\r\n */\r\nexport function makeFileUploadUC(appObject: AppObject): FileUploadUC {\r\n return new FileUploadUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of FileUploadUC\r\n * This private class handles the actual file upload mechanics\r\n */\r\nclass FileUploadUCImp extends FileUploadUC {\r\n private get vivedAPI(): VivedAPIEntity | undefined {\r\n return this.getCachedSingleton<VivedAPIEntity>(VivedAPIEntity.type);\r\n }\r\n\r\n private get requestJSON() {\r\n return this.getCachedSingleton<JsonRequestUC>(JsonRequestUC.type)\r\n ?.doRequest;\r\n }\r\n\r\n private get basicFetch() {\r\n return this.getCachedSingleton<BasicFetchUC>(BasicFetchUC.type)?.doRequest;\r\n }\r\n\r\n doUpload = (file: File): Promise<void> => {\r\n const vivedAPI = this.vivedAPI;\r\n const requestJSON = this.requestJSON;\r\n const basicFetch = this.basicFetch;\r\n\r\n if (!vivedAPI || !requestJSON || !basicFetch) {\r\n return Promise.reject();\r\n }\r\n return new Promise<void>((resolve, reject) => {\r\n const getUploadURL = vivedAPI.getEndpointURL(\r\n `upload/large/DataVariants/${file.name}`\r\n );\r\n\r\n requestJSON(getUploadURL)\r\n .then((uploadURL) => {\r\n const url = new URL(uploadURL as string);\r\n const options: BasicFetchOptions = {\r\n method: \"PUT\",\r\n body: file\r\n };\r\n\r\n return basicFetch(url, options);\r\n })\r\n .then((_) => {\r\n resolve();\r\n })\r\n .catch((e: Error) => {\r\n this.warn(e.message);\r\n reject(e);\r\n });\r\n });\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, FileUploadUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"JsonRequestUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/JsonRequestUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,sCAKqB;AAgBrB;;;GAGG;AACH,MAAsB,aAAc,SAAQ,kBAAW;IAYrD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC/D,CAAC;;AAnBH,sCAoBC;AAnBC,gDAAgD;AACzC,kBAAI,GAAG,eAAe,CAAC","sourcesContent":["/**\r\n * JsonRequestUC.ts\r\n * \r\n * This file defines the core Use Case for making JSON HTTP requests to APIs.\r\n * JsonRequestUC provides a standardized interface for HTTP operations with JSON payloads,\r\n * supporting various HTTP methods and request configurations.\r\n * \r\n * Key concepts:\r\n * - Abstract UC defining the interface for JSON HTTP requests\r\n * - Supports GET, POST, PUT, PATCH, DELETE HTTP methods\r\n * - Handles request headers, parameters, and body data\r\n * - Returns Promise-based responses for async operations\r\n * - Implements singleton pattern for system-wide request handling\r\n * \r\n * Usage pattern:\r\n * 1. Get the singleton UC using JsonRequestUC.get(appObjects)\r\n * 2. Call doRequest with URL and request options\r\n * 3. Handle the returned Promise with response data or errors\r\n * 4. Use with VivedAPIEntity to construct endpoint URLs\r\n */\r\n\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"@vived/core\";\r\n\r\n/**\r\n * Configuration options for JSON HTTP requests\r\n */\r\nexport interface RequestJSONOptions {\r\n /** HTTP headers to include in the request */\r\n headers?: any;\r\n /** HTTP method for the request */\r\n method: \"GET\" | \"PATCH\" | \"POST\" | \"PUT\" | \"DELETE\" | undefined;\r\n /** URL parameters to include in the request */\r\n params?: any;\r\n /** Request body data for POST/PUT/PATCH requests */\r\n body?: any;\r\n}\r\n\r\n/**\r\n * JsonRequestUC provides functionality for making JSON HTTP requests.\r\n * Abstract class that defines the interface for HTTP operations with JSON payloads.\r\n */\r\nexport abstract class JsonRequestUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"JsonRequestUC\";\r\n\r\n /**\r\n * Performs a JSON HTTP request to the specified URL\r\n * @param url The target URL for the request\r\n * @param options Optional configuration for the request\r\n * @returns Promise resolving to the response data\r\n */\r\n abstract doRequest(url: URL, options?: RequestJSONOptions): Promise<any>;\r\n\r\n /**\r\n * Retrieves the singleton JsonRequestUC from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The JsonRequestUC singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): JsonRequestUC | undefined {\r\n return getSingletonComponent(JsonRequestUC.type, appObjects);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"JsonRequestUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/JsonRequestUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,sCAKqB;AAgBrB;;;GAGG;AACH,MAAsB,aAAc,SAAQ,kBAAW;IAYrD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC/D,CAAC;;AAnBH,sCAoBC;AAnBC,gDAAgD;AACzC,kBAAI,GAAG,eAAe,CAAC","sourcesContent":["/**\r\n * JsonRequestUC.ts\r\n *\r\n * This file defines the core Use Case for making JSON HTTP requests to APIs.\r\n * JsonRequestUC provides a standardized interface for HTTP operations with JSON payloads,\r\n * supporting various HTTP methods and request configurations.\r\n *\r\n * Key concepts:\r\n * - Abstract UC defining the interface for JSON HTTP requests\r\n * - Supports GET, POST, PUT, PATCH, DELETE HTTP methods\r\n * - Handles request headers, parameters, and body data\r\n * - Returns Promise-based responses for async operations\r\n * - Implements singleton pattern for system-wide request handling\r\n *\r\n * Usage pattern:\r\n * 1. Get the singleton UC using JsonRequestUC.get(appObjects)\r\n * 2. Call doRequest with URL and request options\r\n * 3. Handle the returned Promise with response data or errors\r\n * 4. Use with VivedAPIEntity to construct endpoint URLs\r\n */\r\n\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC\r\n} from \"@vived/core\";\r\n\r\n/**\r\n * Configuration options for JSON HTTP requests\r\n */\r\nexport interface RequestJSONOptions {\r\n /** HTTP headers to include in the request */\r\n headers?: any;\r\n /** HTTP method for the request */\r\n method: \"GET\" | \"PATCH\" | \"POST\" | \"PUT\" | \"DELETE\" | undefined;\r\n /** URL parameters to include in the request */\r\n params?: any;\r\n /** Request body data for POST/PUT/PATCH requests */\r\n body?: any;\r\n}\r\n\r\n/**\r\n * JsonRequestUC provides functionality for making JSON HTTP requests.\r\n * Abstract class that defines the interface for HTTP operations with JSON payloads.\r\n */\r\nexport abstract class JsonRequestUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"JsonRequestUC\";\r\n\r\n /**\r\n * Performs a JSON HTTP request to the specified URL\r\n * @param url The target URL for the request\r\n * @param options Optional configuration for the request\r\n * @returns Promise resolving to the response data\r\n */\r\n abstract doRequest(url: URL, options?: RequestJSONOptions): Promise<any>;\r\n\r\n /**\r\n * Retrieves the singleton JsonRequestUC from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The JsonRequestUC singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): JsonRequestUC | undefined {\r\n return getSingletonComponent(JsonRequestUC.type, appObjects);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"PostNewAssetUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/PostNewAssetUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAoEH,gDAEC;AApED,sCAMqB;AACrB,+DAA4D;AAC5D,iDAA8C;AAC9C,mDAAoE;AACpE,2DAAwD;AA0BxD;;;GAGG;AACH,MAAsB,cAAe,SAAQ,kBAAW;IAWtD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;;AAlBH,wCAmBC;AAlBC,gDAAgD;AACzC,mBAAI,GAAG,gBAAgB,CAAC;AAmBjC;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,SAAoB;IACrD,OAAO,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,iBAAkB,SAAQ,cAAc;IAC5C,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,kBAAkB,CAAgB,6BAAa,CAAC,IAAI,CAAC;YAC/D,EAAE,SAAS,CAAC;IAChB,CAAC;IAED,IAAY,kBAAkB;QAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAoB,qCAAiB,CAAC,IAAI,CAAC;YACvE,EAAE,YAAY,CAAC;IACnB,CAAC;IAED,IAAY,YAAY;QACtB,OAAO,IAAI,CAAC,kBAAkB,CAAe,2BAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAC5E,CAAC;IAED,IAAY,QAAQ;Q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C9B,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;oBACd,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;oBAElD,MAAM,IAAI,GAAG;wBACX,OAAO,EAAE,OAAO;wBAChB,IAAI;wBACJ,WAAW;wBACX,QAAQ;qBACT,CAAC;oBAEF,MAAM,OAAO,GAAuB;wBAClC,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC1B,OAAO,EAAE;4BACP,aAAa,EAAE,SAAS,GAAG,KAAK;yBACjC;qBACF,CAAC;oBAEF,OAAO,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACzC,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;oBACf,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;oBACzB,OAAO,CAAC;wBACN,EAAE,EAAE,OAAO;wBACX,QAAQ;qBACT,CAAC,CAAC;gBACL,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBACX,MAAM,CAAC,CAAC,CAAC,CAAC;oBACV,OAAO;gBACT,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAIA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * PostNewAssetUC.ts\r\n * \r\n * This file defines the Use Case for creating new assets via the VIVED API.\r\n * PostNewAssetUC handles the complete workflow of uploading asset files and\r\n * creating asset metadata records through API requests.\r\n * \r\n * Key concepts:\r\n * - Orchestrates file upload and metadata creation for new assets\r\n * - Handles multipart file uploads with asset information\r\n * - Manages authentication tokens and API endpoints\r\n * - Coordinates between multiple UCs (JsonRequest, FileUpload, SignedAuthToken)\r\n * - Returns asset creation response with generated IDs\r\n * \r\n * Usage pattern:\r\n * 1. Get a UC instance using PostNewAssetUC.get(appObjects) or makePostNewAssetUC\r\n * 2. Call doPost with asset data including file and metadata\r\n * 3. Handle the returned Promise with asset creation response\r\n * 4. UC will coordinate authentication, file upload, and API requests\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC,\r\n generateUniqueID,\r\n getSingletonComponent\r\n} from \"@vived/core\";\r\nimport { VivedAPIEntity } from \"../Entities/VivedAPIEntity\";\r\nimport { FileUploadUC } from \"./FileUploadUC\";\r\nimport { JsonRequestUC, RequestJSONOptions } from \"./JsonRequestUC\";\r\nimport { SignedAuthTokenUC } from \"./SignedAuthTokenUC\";\r\n\r\n/**\r\n * Data transfer object for new asset creation requests\r\n */\r\nexport interface NewAssetApiDto {\r\n /** Display name for the new asset */\r\n name: string;\r\n /** Description text for the asset */\r\n description: string;\r\n /** ID of the user who will own this asset */\r\n ownerID: string;\r\n /** File object containing the asset data */\r\n file: File;\r\n}\r\n\r\n/**\r\n * Response data transfer object for successful asset creation\r\n */\r\nexport interface NewAssetResponseDTO {\r\n /** Unique identifier assigned to the new asset */\r\n id: string;\r\n /** Final filename used for the stored asset file */\r\n filename: string;\r\n}\r\n\r\n/**\r\n * PostNewAssetUC provides functionality for creating new assets via API.\r\n * Abstract class that defines the interface for asset creation operations.\r\n */\r\nexport abstract class PostNewAssetUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"PostNewAssetUC\";\r\n\r\n /**\r\n * Creates a new asset by uploading file and metadata to the API\r\n * @param data The asset creation data including file and metadata\r\n * @returns Promise resolving to the new asset response with ID and filename\r\n */\r\n abstract doPost(data: NewAssetApiDto): Promise<NewAssetResponseDTO>;\r\n\r\n /**\r\n * Retrieves a PostNewAssetUC component from an AppObject\r\n * @param appObjects The AppObjectRepo to get the component from\r\n * @returns The PostNewAssetUC component or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): PostNewAssetUC | undefined {\r\n return getSingletonComponent(PostNewAssetUC.type, appObjects);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new PostNewAssetUC instance\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new PostNewAssetUC instance\r\n */\r\nexport function makePostNewAssetUC(appObject: AppObject): PostNewAssetUC {\r\n return new PostNewAssetUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of PostNewAssetUC\r\n * This private class handles the actual asset creation workflow\r\n */\r\nclass PostNewAssetUCImp extends PostNewAssetUC {\r\n private get jsonRequester() {\r\n return this.getCachedSingleton<JsonRequestUC>(JsonRequestUC.type)\r\n ?.doRequest;\r\n }\r\n\r\n private get getPlayerAuthToken() {\r\n return this.getCachedSingleton<SignedAuthTokenUC>(SignedAuthTokenUC.type)\r\n ?.getAuthToken;\r\n }\r\n\r\n private get fileUploader() {\r\n return this.getCachedSingleton<FileUploadUC>(FileUploadUC.type)?.doUpload;\r\n }\r\n\r\n private get vivedAPI() {\r\n return this.getCachedSingleton<VivedAPIEntity>(VivedAPIEntity.type);\r\n }\r\n\r\n doPost = (data: NewAssetApiDto): Promise<NewAssetResponseDTO> => {\r\n const fileUploader = this.fileUploader;\r\n const getPlayerAuthToken = this.getPlayerAuthToken;\r\n const vivedAPI = this.vivedAPI;\r\n const jsonRequester = this.jsonRequester;\r\n\r\n if (!fileUploader || !getPlayerAuthToken || !vivedAPI || !jsonRequester) {\r\n return Promise.reject();\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const { description, file, name, ownerID } = data;\r\n let assetId: string;\r\n\r\n const nameSplits = file.name.split(\".\");\r\n const extension = nameSplits[nameSplits.length - 1];\r\n const filename = `${generateUniqueID()}.${extension}`;\r\n const assetFile = new File([file], filename, {\r\n lastModified: Date.now()\r\n });\r\n\r\n fileUploader(assetFile)\r\n .then((_) => {\r\n return getPlayerAuthToken();\r\n })\r\n .then((token) => {\r\n const postURL = vivedAPI.getEndpointURL(\"assets\");\r\n\r\n const body = {\r\n ownerId: ownerID,\r\n name,\r\n description,\r\n filename\r\n };\r\n\r\n const options: RequestJSONOptions = {\r\n method: \"POST\",\r\n body: JSON.stringify(body),\r\n headers: {\r\n Authorization: \"Bearer \" + token\r\n }\r\n };\r\n\r\n return jsonRequester(postURL, options);\r\n })\r\n .then((result) => {\r\n assetId = result.assetId;\r\n resolve({\r\n id: assetId,\r\n filename\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n return;\r\n });\r\n });\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, PostNewAssetUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PostNewAssetUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/PostNewAssetUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAoEH,gDAEC;AApED,sCAMqB;AACrB,+DAA4D;AAC5D,iDAA8C;AAC9C,mDAAoE;AACpE,2DAAwD;AA0BxD;;;GAGG;AACH,MAAsB,cAAe,SAAQ,kBAAW;IAWtD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;;AAlBH,wCAmBC;AAlBC,gDAAgD;AACzC,mBAAI,GAAG,gBAAgB,CAAC;AAmBjC;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,SAAoB;IACrD,OAAO,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,iBAAkB,SAAQ,cAAc;IAC5C,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,kBAAkB,CAAgB,6BAAa,CAAC,IAAI,CAAC;YAC/D,EAAE,SAAS,CAAC;IAChB,CAAC;IAED,IAAY,kBAAkB;QAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAoB,qCAAiB,CAAC,IAAI,CAAC;YACvE,EAAE,YAAY,CAAC;IACnB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AG,EAAE;iBACzB,CAAC,CAAC;gBAEH,YAAY,CAAC,SAAS,CAAC;qBACpB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBACV,OAAO,kBAAkB,EAAE,CAAC;gBAC9B,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;oBACd,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;oBAElD,MAAM,IAAI,GAAG;wBACX,OAAO,EAAE,OAAO;wBAChB,IAAI;wBACJ,WAAW;wBACX,QAAQ;qBACT,CAAC;oBAEF,MAAM,OAAO,GAAuB;wBAClC,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC1B,OAAO,EAAE;4BACP,aAAa,EAAE,SAAS,GAAG,KAAK;yBACjC;qBACF,CAAC;oBAEF,OAAO,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACzC,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;oBACf,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;oBACzB,OAAO,CAAC;wBACN,EAAE,EAAE,OAAO;wBACX,QAAQ;qBACT,CAAC,CAAC;gBACL,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBACX,MAAM,CAAC,CAAC,CAAC,CAAC;oBACV,OAAO;gBACT,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAIA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["/**\r\n * PostNewAssetUC.ts\r\n *\r\n * This file defines the Use Case for creating new assets via the VIVED API.\r\n * PostNewAssetUC handles the complete workflow of uploading asset files and\r\n * creating asset metadata records through API requests.\r\n *\r\n * Key concepts:\r\n * - Orchestrates file upload and metadata creation for new assets\r\n * - Handles multipart file uploads with asset information\r\n * - Manages authentication tokens and API endpoints\r\n * - Coordinates between multiple UCs (JsonRequest, FileUpload, SignedAuthToken)\r\n * - Returns asset creation response with generated IDs\r\n *\r\n * Usage pattern:\r\n * 1. Get a UC instance using PostNewAssetUC.get(appObjects) or makePostNewAssetUC\r\n * 2. Call doPost with asset data including file and metadata\r\n * 3. Handle the returned Promise with asset creation response\r\n * 4. UC will coordinate authentication, file upload, and API requests\r\n */\r\n\r\nimport {\r\n AppObject,\r\n AppObjectRepo,\r\n AppObjectUC,\r\n generateUniqueID,\r\n getSingletonComponent\r\n} from \"@vived/core\";\r\nimport { VivedAPIEntity } from \"../Entities/VivedAPIEntity\";\r\nimport { FileUploadUC } from \"./FileUploadUC\";\r\nimport { JsonRequestUC, RequestJSONOptions } from \"./JsonRequestUC\";\r\nimport { SignedAuthTokenUC } from \"./SignedAuthTokenUC\";\r\n\r\n/**\r\n * Data transfer object for new asset creation requests\r\n */\r\nexport interface NewAssetApiDto {\r\n /** Display name for the new asset */\r\n name: string;\r\n /** Description text for the asset */\r\n description: string;\r\n /** ID of the user who will own this asset */\r\n ownerID: string;\r\n /** File object containing the asset data */\r\n file: File;\r\n}\r\n\r\n/**\r\n * Response data transfer object for successful asset creation\r\n */\r\nexport interface NewAssetResponseDTO {\r\n /** Unique identifier assigned to the new asset */\r\n id: string;\r\n /** Final filename used for the stored asset file */\r\n filename: string;\r\n}\r\n\r\n/**\r\n * PostNewAssetUC provides functionality for creating new assets via API.\r\n * Abstract class that defines the interface for asset creation operations.\r\n */\r\nexport abstract class PostNewAssetUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"PostNewAssetUC\";\r\n\r\n /**\r\n * Creates a new asset by uploading file and metadata to the API\r\n * @param data The asset creation data including file and metadata\r\n * @returns Promise resolving to the new asset response with ID and filename\r\n */\r\n abstract doPost(data: NewAssetApiDto): Promise<NewAssetResponseDTO>;\r\n\r\n /**\r\n * Retrieves a PostNewAssetUC component from an AppObject\r\n * @param appObjects The AppObjectRepo to get the component from\r\n * @returns The PostNewAssetUC component or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): PostNewAssetUC | undefined {\r\n return getSingletonComponent(PostNewAssetUC.type, appObjects);\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a new PostNewAssetUC instance\r\n * @param appObject The AppObject to attach the UC to\r\n * @returns A new PostNewAssetUC instance\r\n */\r\nexport function makePostNewAssetUC(appObject: AppObject): PostNewAssetUC {\r\n return new PostNewAssetUCImp(appObject);\r\n}\r\n\r\n/**\r\n * Concrete implementation of PostNewAssetUC\r\n * This private class handles the actual asset creation workflow\r\n */\r\nclass PostNewAssetUCImp extends PostNewAssetUC {\r\n private get jsonRequester() {\r\n return this.getCachedSingleton<JsonRequestUC>(JsonRequestUC.type)\r\n ?.doRequest;\r\n }\r\n\r\n private get getPlayerAuthToken() {\r\n return this.getCachedSingleton<SignedAuthTokenUC>(SignedAuthTokenUC.type)\r\n ?.getAuthToken;\r\n }\r\n\r\n private get fileUploader() {\r\n return this.getCachedSingleton<FileUploadUC>(FileUploadUC.type)?.doUpload;\r\n }\r\n\r\n private get vivedAPI() {\r\n return this.getCachedSingleton<VivedAPIEntity>(VivedAPIEntity.type);\r\n }\r\n\r\n doPost = (data: NewAssetApiDto): Promise<NewAssetResponseDTO> => {\r\n const fileUploader = this.fileUploader;\r\n const getPlayerAuthToken = this.getPlayerAuthToken;\r\n const vivedAPI = this.vivedAPI;\r\n const jsonRequester = this.jsonRequester;\r\n\r\n if (!fileUploader || !getPlayerAuthToken || !vivedAPI || !jsonRequester) {\r\n return Promise.reject();\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const { description, file, name, ownerID } = data;\r\n let assetId: string;\r\n\r\n const nameSplits = file.name.split(\".\");\r\n const extension = nameSplits[nameSplits.length - 1];\r\n const filename = `${generateUniqueID()}.${extension}`;\r\n const assetFile = new File([file], filename, {\r\n lastModified: Date.now()\r\n });\r\n\r\n fileUploader(assetFile)\r\n .then((_) => {\r\n return getPlayerAuthToken();\r\n })\r\n .then((token) => {\r\n const postURL = vivedAPI.getEndpointURL(\"assets\");\r\n\r\n const body = {\r\n ownerId: ownerID,\r\n name,\r\n description,\r\n filename\r\n };\r\n\r\n const options: RequestJSONOptions = {\r\n method: \"POST\",\r\n body: JSON.stringify(body),\r\n headers: {\r\n Authorization: \"Bearer \" + token\r\n }\r\n };\r\n\r\n return jsonRequester(postURL, options);\r\n })\r\n .then((result) => {\r\n assetId = result.assetId;\r\n resolve({\r\n id: assetId,\r\n filename\r\n });\r\n })\r\n .catch((e) => {\r\n reject(e);\r\n return;\r\n });\r\n });\r\n };\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, PostNewAssetUC.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SignedAuthTokenUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/SignedAuthTokenUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,sCAAgF;AAEhF;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,kBAAW;IAUzD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;;AAjBH,8CAkBC;AAjBC,gDAAgD;AACzC,sBAAI,GAAG,mBAAmB,CAAC","sourcesContent":["/**\r\n * SignedAuthTokenUC.ts\r\n * \r\n * This file defines the Use Case for retrieving signed authentication tokens.\r\n * SignedAuthTokenUC provides functionality for obtaining JWT or signed tokens\r\n * used to authenticate API requests with the VIVED backend services.\r\n * \r\n * Key concepts:\r\n * - Abstract UC defining the interface for authentication token retrieval\r\n * - Handles token generation, validation, and renewal workflows\r\n * - Provides secure access to authentication credentials\r\n * - Implements singleton pattern for system-wide token management\r\n * - Returns promises for async token operations\r\n * \r\n * Usage pattern:\r\n * 1. Get the singleton UC using SignedAuthTokenUC.get(appObjects)\r\n * 2. Call getAuthToken to retrieve current valid authentication token\r\n * 3. Handle the returned Promise with token string or errors\r\n * 4. Use token for authorizing subsequent API requests\r\n */\r\n\r\nimport { AppObjectRepo, AppObjectUC, getSingletonComponent } from \"@vived/core\";\r\n\r\n/**\r\n * SignedAuthTokenUC provides functionality for retrieving authentication tokens.\r\n * Abstract class that defines the interface for authentication token operations.\r\n */\r\nexport abstract class SignedAuthTokenUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"SignedAuthTokenUC\";\r\n\r\n /**\r\n * Retrieves a valid signed authentication token\r\n * @returns Promise resolving to the authentication token string\r\n */\r\n abstract getAuthToken(): Promise<string>;\r\n\r\n /**\r\n * Retrieves the singleton SignedAuthTokenUC from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The SignedAuthTokenUC singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): SignedAuthTokenUC | undefined {\r\n return getSingletonComponent(SignedAuthTokenUC.type, appObjects);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SignedAuthTokenUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/SignedAuthTokenUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,sCAAgF;AAEhF;;;GAGG;AACH,MAAsB,iBAAkB,SAAQ,kBAAW;IAUzD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;;AAjBH,8CAkBC;AAjBC,gDAAgD;AACzC,sBAAI,GAAG,mBAAmB,CAAC","sourcesContent":["/**\r\n * SignedAuthTokenUC.ts\r\n *\r\n * This file defines the Use Case for retrieving signed authentication tokens.\r\n * SignedAuthTokenUC provides functionality for obtaining JWT or signed tokens\r\n * used to authenticate API requests with the VIVED backend services.\r\n *\r\n * Key concepts:\r\n * - Abstract UC defining the interface for authentication token retrieval\r\n * - Handles token generation, validation, and renewal workflows\r\n * - Provides secure access to authentication credentials\r\n * - Implements singleton pattern for system-wide token management\r\n * - Returns promises for async token operations\r\n *\r\n * Usage pattern:\r\n * 1. Get the singleton UC using SignedAuthTokenUC.get(appObjects)\r\n * 2. Call getAuthToken to retrieve current valid authentication token\r\n * 3. Handle the returned Promise with token string or errors\r\n * 4. Use token for authorizing subsequent API requests\r\n */\r\n\r\nimport { AppObjectRepo, AppObjectUC, getSingletonComponent } from \"@vived/core\";\r\n\r\n/**\r\n * SignedAuthTokenUC provides functionality for retrieving authentication tokens.\r\n * Abstract class that defines the interface for authentication token operations.\r\n */\r\nexport abstract class SignedAuthTokenUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"SignedAuthTokenUC\";\r\n\r\n /**\r\n * Retrieves a valid signed authentication token\r\n * @returns Promise resolving to the authentication token string\r\n */\r\n abstract getAuthToken(): Promise<string>;\r\n\r\n /**\r\n * Retrieves the singleton SignedAuthTokenUC from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The SignedAuthTokenUC singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): SignedAuthTokenUC | undefined {\r\n return getSingletonComponent(SignedAuthTokenUC.type, appObjects);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UserAuthUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/UserAuthUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,sCAAgF;AAEhF;;;GAGG;AACH,MAAsB,UAAW,SAAQ,kBAAW;IAwBlD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;;AA/BH,gCAgCC;AA/BC,gDAAgD;AACzC,eAAI,GAAG,YAAY,CAAC","sourcesContent":["/**\r\n * UserAuthUC.ts\r\n * \r\n * This file defines the Use Case for user authentication operations.\r\n * UserAuthUC provides functionality for managing user login, logout, and\r\n * authentication refresh workflows with the VIVED API services.\r\n * \r\n * Key concepts:\r\n * - Abstract UC defining the interface for user authentication operations\r\n * - Handles login with username/password credentials\r\n * - Manages logout and session termination\r\n * - Provides authentication refresh for token renewal\r\n * - Implements singleton pattern for system-wide authentication management\r\n * - Coordinates with VivedAPIEntity for token storage\r\n * \r\n * Usage pattern:\r\n * 1. Get the singleton UC using UserAuthUC.get(appObjects)\r\n * 2. Call login with user credentials for authentication\r\n * 3. Use logout to terminate user sessions\r\n * 4. Call refreshAuthenticatedUser to renew authentication tokens\r\n */\r\n\r\nimport { getSingletonComponent, AppObjectRepo, AppObjectUC } from \"@vived/core\";\r\n\r\n/**\r\n * UserAuthUC provides functionality for user authentication operations.\r\n * Abstract class that defines the interface for login, logout, and token refresh operations.\r\n */\r\nexport abstract class UserAuthUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"UserAuthUC\";\r\n\r\n /**\r\n * Authenticates a user with username and password credentials\r\n * @param username The user's login username\r\n * @param password The user's login password\r\n * @returns Promise that resolves when login is complete\r\n */\r\n abstract login(username: string, password: string): Promise<void>;\r\n \r\n /**\r\n * Logs out the current user and terminates the session\r\n * @returns Promise that resolves when logout is complete\r\n */\r\n abstract logout(): Promise<void>;\r\n \r\n /**\r\n * Refreshes the current user's authentication token\r\n * @returns Promise that resolves when token refresh is complete\r\n */\r\n abstract refreshAuthenticatedUser(): Promise<void>;\r\n\r\n /**\r\n * Retrieves the singleton UserAuthUC from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The UserAuthUC singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): UserAuthUC | undefined {\r\n return getSingletonComponent(UserAuthUC.type, appObjects);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"UserAuthUC.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/UserAuthUC.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,sCAAgF;AAEhF;;;GAGG;AACH,MAAsB,UAAW,SAAQ,kBAAW;IAwBlD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,UAAyB;QAClC,OAAO,IAAA,4BAAqB,EAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;;AA/BH,gCAgCC;AA/BC,gDAAgD;AACzC,eAAI,GAAG,YAAY,CAAC","sourcesContent":["/**\r\n * UserAuthUC.ts\r\n *\r\n * This file defines the Use Case for user authentication operations.\r\n * UserAuthUC provides functionality for managing user login, logout, and\r\n * authentication refresh workflows with the VIVED API services.\r\n *\r\n * Key concepts:\r\n * - Abstract UC defining the interface for user authentication operations\r\n * - Handles login with username/password credentials\r\n * - Manages logout and session termination\r\n * - Provides authentication refresh for token renewal\r\n * - Implements singleton pattern for system-wide authentication management\r\n * - Coordinates with VivedAPIEntity for token storage\r\n *\r\n * Usage pattern:\r\n * 1. Get the singleton UC using UserAuthUC.get(appObjects)\r\n * 2. Call login with user credentials for authentication\r\n * 3. Use logout to terminate user sessions\r\n * 4. Call refreshAuthenticatedUser to renew authentication tokens\r\n */\r\n\r\nimport { getSingletonComponent, AppObjectRepo, AppObjectUC } from \"@vived/core\";\r\n\r\n/**\r\n * UserAuthUC provides functionality for user authentication operations.\r\n * Abstract class that defines the interface for login, logout, and token refresh operations.\r\n */\r\nexport abstract class UserAuthUC extends AppObjectUC {\r\n /** Unique type identifier for this component */\r\n static type = \"UserAuthUC\";\r\n\r\n /**\r\n * Authenticates a user with username and password credentials\r\n * @param username The user's login username\r\n * @param password The user's login password\r\n * @returns Promise that resolves when login is complete\r\n */\r\n abstract login(username: string, password: string): Promise<void>;\r\n\r\n /**\r\n * Logs out the current user and terminates the session\r\n * @returns Promise that resolves when logout is complete\r\n */\r\n abstract logout(): Promise<void>;\r\n\r\n /**\r\n * Refreshes the current user's authentication token\r\n * @returns Promise that resolves when token refresh is complete\r\n */\r\n abstract refreshAuthenticatedUser(): Promise<void>;\r\n\r\n /**\r\n * Retrieves the singleton UserAuthUC from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The UserAuthUC singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): UserAuthUC | undefined {\r\n return getSingletonComponent(UserAuthUC.type, appObjects);\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,kDAAgC;AAChC,uDAAqC;AACrC,4DAA0C;AAC1C,4DAA0C;AAC1C,iDAA+B;AAC/B,oDAAkC;AAClC,+DAA6C;AAC7C,kDAAgC;AAChC,qDAAmC;AACnC,2DAAyC;AACzC,qDAAmC;AACnC,iDAA+B;AAC/B,mDAAiC;AACjC,sDAAoC;AACpC,+CAA6B","sourcesContent":["/**\r\n * VivedAPI Use Cases Index\r\n * \r\n * This module exports all use case classes for the VivedAPI feature.\r\n * Use cases contain the business logic for API operations and coordinate\r\n * between entities, external services, and user interface components.\r\n * \r\n * Key Concepts:\r\n * - Use cases implement specific API operations and workflows\r\n * - They coordinate between entities, HTTP requests, and authentication\r\n * - Each UC handles validation, error management, and API communication\r\n * - Some UCs manage singleton operations, others handle per-request workflows\r\n * - UCs provide clean interfaces for controllers and other components\r\n * \r\n * Available Use Cases:\r\n * - HTTP Operations: BasicFetchUC, JsonRequestUC, BlobRequestUC\r\n * - Authentication: SignedAuthTokenUC, UserAuthUC\r\n * - File Management: FileUploadUC, FetchAssetFileFromAPIUC, PatchAssetFileUC\r\n * - Asset Operations: PostNewAssetUC, DeleteAssetOnAPIUC, GetAssetsForOwnerFromAPIUC\r\n * - Asset Metadata: FetchAssetMetaFromAPIUC, PatchAssetMetaUC, PatchAssetIsArchivedUC\r\n * - App Management: GetAppFromAPIUC\r\n * - Asset Updates: PatchAssetUC\r\n */\r\n\r\nexport * from \"./BasicFetchUC\";\r\nexport * from \"./BlobRequestUC\";\r\nexport * from \"./DeleteAssetOnAPIUC\";\r\nexport * from \"./FetchAssetFileFromAPIUC\";\r\nexport * from \"./FetchAssetMetaFromAPIUC\";\r\nexport * from \"./FileUploadUC\";\r\nexport * from \"./GetAppFromAPIUC\";\r\nexport * from \"./GetAssetsForOwnerFromAPIUC\";\r\nexport * from \"./JsonRequestUC\";\r\nexport * from \"./PatchAssetFileUC\";\r\nexport * from \"./PatchAssetIsArchivedUC\";\r\nexport * from \"./PatchAssetMetaUC\";\r\nexport * from \"./PatchAssetUC\";\r\nexport * from \"./PostNewAssetUC\";\r\nexport * from \"./SignedAuthTokenUC\";\r\nexport * from \"./UserAuthUC\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/VivedAPI/UCs/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,kDAAgC;AAChC,uDAAqC;AACrC,4DAA0C;AAC1C,4DAA0C;AAC1C,iDAA+B;AAC/B,oDAAkC;AAClC,+DAA6C;AAC7C,kDAAgC;AAChC,qDAAmC;AACnC,2DAAyC;AACzC,qDAAmC;AACnC,iDAA+B;AAC/B,mDAAiC;AACjC,sDAAoC;AACpC,+CAA6B","sourcesContent":["/**\r\n * VivedAPI Use Cases Index\r\n *\r\n * This module exports all use case classes for the VivedAPI feature.\r\n * Use cases contain the business logic for API operations and coordinate\r\n * between entities, external services, and user interface components.\r\n *\r\n * Key Concepts:\r\n * - Use cases implement specific API operations and workflows\r\n * - They coordinate between entities, HTTP requests, and authentication\r\n * - Each UC handles validation, error management, and API communication\r\n * - Some UCs manage singleton operations, others handle per-request workflows\r\n * - UCs provide clean interfaces for controllers and other components\r\n *\r\n * Available Use Cases:\r\n * - HTTP Operations: BasicFetchUC, JsonRequestUC, BlobRequestUC\r\n * - Authentication: SignedAuthTokenUC, UserAuthUC\r\n * - File Management: FileUploadUC, FetchAssetFileFromAPIUC, PatchAssetFileUC\r\n * - Asset Operations: PostNewAssetUC, DeleteAssetOnAPIUC, GetAssetsForOwnerFromAPIUC\r\n * - Asset Metadata: FetchAssetMetaFromAPIUC, PatchAssetMetaUC, PatchAssetIsArchivedUC\r\n * - App Management: GetAppFromAPIUC\r\n * - Asset Updates: PatchAssetUC\r\n */\r\n\r\nexport * from \"./BasicFetchUC\";\r\nexport * from \"./BlobRequestUC\";\r\nexport * from \"./DeleteAssetOnAPIUC\";\r\nexport * from \"./FetchAssetFileFromAPIUC\";\r\nexport * from \"./FetchAssetMetaFromAPIUC\";\r\nexport * from \"./FileUploadUC\";\r\nexport * from \"./GetAppFromAPIUC\";\r\nexport * from \"./GetAssetsForOwnerFromAPIUC\";\r\nexport * from \"./JsonRequestUC\";\r\nexport * from \"./PatchAssetFileUC\";\r\nexport * from \"./PatchAssetIsArchivedUC\";\r\nexport * from \"./PatchAssetMetaUC\";\r\nexport * from \"./PatchAssetUC\";\r\nexport * from \"./PostNewAssetUC\";\r\nexport * from \"./SignedAuthTokenUC\";\r\nexport * from \"./UserAuthUC\";\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VivedAPI/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,8CAA4B;AAC5B,0CAAwB;AACxB,wCAAsB;AACtB,wCAAsB","sourcesContent":["/**\r\n * VivedAPI Feature Index\r\n * \r\n * This module serves as the main entry point for the VivedAPI feature, providing\r\n * centralized access to all API-related components and functionality.\r\n * \r\n * The VivedAPI feature handles communication with VIVED backend services,\r\n * including authentication, asset management, and application data synchronization.\r\n * \r\n * Key Concepts:\r\n * - Provides unified API communication infrastructure for the host application\r\n * - Manages authentication tokens and user sessions\r\n * - Handles file uploads, downloads, and asset operations\r\n * - Supports multiple API environments (Production, Staging, Development, Local)\r\n * - Implements clean architecture patterns with separation of concerns\r\n * \r\n * Architecture Components:\r\n * - Entities: Core business objects for API configuration and state management\r\n * - Use Cases: Business logic for API operations and workflows\r\n * - Presentation Managers: Bridge between domain logic and UI components\r\n * - Controllers: Handle user inputs and coordinate feature operations\r\n * - Adapters: Interface with external UI frameworks and libraries\r\n * - Factories: Component creation and feature setup utilities\r\n * - Mocks: Test doubles for development and testing scenarios\r\n */\r\n\r\nexport * from \"./Adapters\";\r\nexport * from \"./Controllers\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Factories\";\r\nexport * from \"./Mocks\";\r\nexport * from \"./PMs\";\r\nexport * from \"./UCs\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/VivedAPI/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,gDAA8B;AAC9B,6CAA2B;AAC3B,8CAA4B;AAC5B,0CAAwB;AACxB,wCAAsB;AACtB,wCAAsB","sourcesContent":["/**\r\n * VivedAPI Feature Index\r\n *\r\n * This module serves as the main entry point for the VivedAPI feature, providing\r\n * centralized access to all API-related components and functionality.\r\n *\r\n * The VivedAPI feature handles communication with VIVED backend services,\r\n * including authentication, asset management, and application data synchronization.\r\n *\r\n * Key Concepts:\r\n * - Provides unified API communication infrastructure for the host application\r\n * - Manages authentication tokens and user sessions\r\n * - Handles file uploads, downloads, and asset operations\r\n * - Supports multiple API environments (Production, Staging, Development, Local)\r\n * - Implements clean architecture patterns with separation of concerns\r\n *\r\n * Architecture Components:\r\n * - Entities: Core business objects for API configuration and state management\r\n * - Use Cases: Business logic for API operations and workflows\r\n * - Presentation Managers: Bridge between domain logic and UI components\r\n * - Controllers: Handle user inputs and coordinate feature operations\r\n * - Adapters: Interface with external UI frameworks and libraries\r\n * - Factories: Component creation and feature setup utilities\r\n * - Mocks: Test doubles for development and testing scenarios\r\n */\r\n\r\nexport * from \"./Adapters\";\r\nexport * from \"./Controllers\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Factories\";\r\nexport * from \"./Mocks\";\r\nexport * from \"./PMs\";\r\nexport * from \"./UCs\";\r\n"]}
@@ -24,14 +24,75 @@ export var AppState;
24
24
  * @extends AppObjectEntity from @vived/core
25
25
  */
26
26
  export class AppEntity extends AppObjectEntity {
27
- static get(id, appObjects) {
27
+ /**
28
+ * Retrieves an AppEntity from a specific AppObject
29
+ * @param appObj - The AppObject to retrieve the AppEntity from
30
+ * @returns The AppEntity instance if found, undefined otherwise
31
+ * @throws Error if appObj is null or undefined
32
+ * @example
33
+ * ```typescript
34
+ * const appObject = appObjects.getOrCreate("myApp");
35
+ * const appEntity = AppEntity.get(appObject);
36
+ * ```
37
+ */
38
+ static get(appObj) {
39
+ if (!appObj) {
40
+ throw new Error("AppObject cannot be null or undefined");
41
+ }
42
+ return appObj.getComponent(AppEntity.type);
43
+ }
44
+ /**
45
+ * Retrieves an AppEntity by ID from the AppObjectRepo
46
+ * @param id - The unique identifier of the app
47
+ * @param appObjects - The AppObjectRepo to search within
48
+ * @returns The AppEntity instance if found, undefined otherwise
49
+ * @throws Error if id is empty or appObjects is null
50
+ * @example
51
+ * ```typescript
52
+ * const appEntity = AppEntity.getById("myAppId", appObjects);
53
+ * if (appEntity) {
54
+ * console.log(`Found app: ${appEntity.name}`);
55
+ * }
56
+ * ```
57
+ */
58
+ static getById(id, appObjects) {
59
+ if (!id) {
60
+ throw new Error("ID cannot be empty");
61
+ }
62
+ if (!appObjects) {
63
+ throw new Error("AppObjectRepo cannot be null or undefined");
64
+ }
28
65
  const ao = appObjects.get(id);
29
66
  if (!ao) {
30
- appObjects.submitWarning("AppEntity.get", `Unable to find app object by ID: ${id}`);
67
+ appObjects.submitWarning("AppEntity.getById", `Unable to find app object by ID: ${id}`);
31
68
  return;
32
69
  }
33
70
  return ao.getComponent(AppEntity.type);
34
71
  }
72
+ /**
73
+ * Safely creates an AppEntity if it doesn't already exist on the AppObject
74
+ * @param appObject - The AppObject to add the AppEntity to
75
+ * @returns The AppEntity instance (existing or newly created)
76
+ * @throws Error if appObject is null or undefined
77
+ * @example
78
+ * ```typescript
79
+ * const appObject = appObjects.getOrCreate("newApp");
80
+ * const appEntity = AppEntity.addIfMissing(appObject);
81
+ * // appEntity is guaranteed to exist
82
+ * ```
83
+ */
84
+ static addIfMissing(appObject) {
85
+ if (!appObject) {
86
+ throw new Error("AppObject cannot be null or undefined");
87
+ }
88
+ // Check if AppEntity already exists
89
+ const existingEntity = appObject.getComponent(AppEntity.type);
90
+ if (existingEntity) {
91
+ return existingEntity;
92
+ }
93
+ // Create new AppEntity if it doesn't exist
94
+ return makeAppEntity(appObject);
95
+ }
35
96
  }
36
97
  /** Type identifier for the AppEntity component */
37
98
  AppEntity.type = "AppEntity";
@@ -49,29 +110,29 @@ class AppEntityImp extends AppEntity {
49
110
  return this.appObject.id;
50
111
  }
51
112
  get name() {
52
- return this._memoizedName.val;
113
+ return this.memoizedName.val;
53
114
  }
54
115
  set name(val) {
55
- this._memoizedName.val = val;
116
+ this.memoizedName.val = val;
56
117
  }
57
118
  get description() {
58
- return this._memoizedDescription.val;
119
+ return this.memoizedDescription.val;
59
120
  }
60
121
  set description(val) {
61
- this._memoizedDescription.val = val;
122
+ this.memoizedDescription.val = val;
62
123
  }
63
124
  get image_url() {
64
- return this._memoizedImageUrl.val;
125
+ return this.memoizedImageUrl.val;
65
126
  }
66
127
  set image_url(val) {
67
- this._memoizedImageUrl.val = val;
128
+ this.memoizedImageUrl.val = val;
68
129
  }
69
130
  get imageAssetId() {
70
- const value = this._memoizedImageAssetId.val;
131
+ const value = this.memoizedImageAssetId.val;
71
132
  return value === "" ? undefined : value;
72
133
  }
73
134
  set imageAssetId(val) {
74
- this._memoizedImageAssetId.val = val ?? "";
135
+ this.memoizedImageAssetId.val = val ?? "";
75
136
  }
76
137
  get latestVersion() {
77
138
  return Version.GetLatest(this.versions);
@@ -125,10 +186,10 @@ class AppEntityImp extends AppEntity {
125
186
  }
126
187
  constructor(appObject) {
127
188
  super(appObject, AppEntity.type);
128
- this._memoizedName = new MemoizedString("", this.notifyOnChange);
129
- this._memoizedDescription = new MemoizedString("", this.notifyOnChange);
130
- this._memoizedImageUrl = new MemoizedString("", this.notifyOnChange);
131
- this._memoizedImageAssetId = new MemoizedString("", this.notifyOnChange);
189
+ this.memoizedName = new MemoizedString("", this.notifyOnChange);
190
+ this.memoizedDescription = new MemoizedString("", this.notifyOnChange);
191
+ this.memoizedImageUrl = new MemoizedString("", this.notifyOnChange);
192
+ this.memoizedImageAssetId = new MemoizedString("", this.notifyOnChange);
132
193
  this.versions = [];
133
194
  this._state = AppState.INIT;
134
195
  this._assignedToOwner = false;
@@ -1 +1 @@
1
- {"version":3,"file":"AppEntity.js","sourceRoot":"","sources":["../../../../src/Apps/Entities/AppEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEf,OAAO,EACP,cAAc,EACf,MAAM,aAAa,CAAC;AAErB;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,+BAAmB,CAAA;IACnB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED;;;;;;;GAOG;AACH,MAAM,OAAgB,SAAU,SAAQ,eAAe;IAIrD,MAAM,CAAC,GAAG,CAAC,EAAU,EAAE,UAAyB;QAC9C,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,aAAa,CACtB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,GAAuB;QACtC,IAAI,IAAI,CAAC,SAAS,KAAK,GAAG;YAAE,OAAO;QAEnC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IACD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QApH3B,kBAAa,GAAmB,IAAI,cAAc,CACxD,EAAE,EACF,IAAI,CAAC,cAAc,CACpB,CAAC;QAUM,yBAAoB,GAAmB,IAAI,cAAc,CAC/D,EAAE,EACF,IAAI,CAAC,cAAc,CACpB,CAAC;QAUM,sBAAiB,GAAmB,IAAI,cAAc,CAC5D,EAAE,EACF,IAAI,CAAC,cAAc,CACpB,CAAC;QAUM,0BAAqB,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAW5E,aAAQ,GAAc,EAAE,CAAC;QA0BjB,WAAM,GAAa,QAAQ,CAAC,IAAI,CAAC;QASjC,qBAAgB,GAAY,KAAK,CAAC;QAa1C,WAAM,GAAa,EAAE,CAAC;IAmBtB,CAAC;CACF","sourcesContent":["import {\n AppObject,\n AppObjectEntity,\n AppObjectRepo,\n Version,\n MemoizedString\n} from \"@vived/core\";\n\n/**\n * Enum representing the possible states of an application\n *\n * @enum {string}\n * @property {string} INIT - Initial state before app loading starts\n * @property {string} LOADING - App is currently loading resources\n * @property {string} READY - App is loaded and ready to use\n * @property {string} ERROR - App encountered an error during loading\n */\nexport enum AppState {\n INIT = \"INIT\",\n LOADING = \"LOADING\",\n READY = \"READY\",\n ERROR = \"ERROR\"\n}\n\n/**\n * AppEntity - Core entity representing an application in the system\n *\n * This abstract class defines the properties and behaviors of an application.\n * It manages app state, versioning, mounting status, and error handling.\n *\n * @extends AppObjectEntity from @vived/core\n */\nexport abstract class AppEntity extends AppObjectEntity {\n /** Type identifier for the AppEntity component */\n static type = \"AppEntity\";\n\n static get(id: string, appObjects: AppObjectRepo) {\n const ao = appObjects.get(id);\n if (!ao) {\n appObjects.submitWarning(\n \"AppEntity.get\",\n `Unable to find app object by ID: ${id}`\n );\n return;\n }\n\n return ao.getComponent<AppEntity>(AppEntity.type);\n }\n\n abstract get id(): string;\n abstract name: string;\n abstract description: string;\n abstract image_url: string;\n abstract imageAssetId: string | undefined;\n abstract versions: Version[];\n abstract get latestVersion(): Version | undefined;\n abstract errorMessage?: string;\n abstract get hasError(): boolean;\n abstract state: AppState;\n abstract assignedToOwner: boolean;\n\n abstract get isMounted(): boolean;\n abstract appAssetFolderURL?: string;\n abstract get updateIsAvailable(): boolean | undefined;\n abstract styles: string[];\n abstract mountedVersion: Version | undefined;\n}\n\n/**\n * Factory function to create a new AppEntity instance\n *\n * @param appObject - The app object to attach the entity to\n * @returns A concrete implementation of AppEntity\n */\nexport function makeAppEntity(appObject: AppObject): AppEntity {\n return new AppEntityImp(appObject);\n}\n\nclass AppEntityImp extends AppEntity {\n get id() {\n return this.appObject.id;\n }\n\n private _memoizedName: MemoizedString = new MemoizedString(\n \"\",\n this.notifyOnChange\n );\n\n get name(): string {\n return this._memoizedName.val;\n }\n\n set name(val: string) {\n this._memoizedName.val = val;\n }\n\n private _memoizedDescription: MemoizedString = new MemoizedString(\n \"\",\n this.notifyOnChange\n );\n\n get description(): string {\n return this._memoizedDescription.val;\n }\n\n set description(val: string) {\n this._memoizedDescription.val = val;\n }\n\n private _memoizedImageUrl: MemoizedString = new MemoizedString(\n \"\",\n this.notifyOnChange\n );\n\n get image_url(): string {\n return this._memoizedImageUrl.val;\n }\n\n set image_url(val: string) {\n this._memoizedImageUrl.val = val;\n }\n\n private _memoizedImageAssetId = new MemoizedString(\"\", this.notifyOnChange);\n\n get imageAssetId(): string | undefined {\n const value = this._memoizedImageAssetId.val;\n return value === \"\" ? undefined : value;\n }\n\n set imageAssetId(val: string | undefined) {\n this._memoizedImageAssetId.val = val ?? \"\";\n }\n\n versions: Version[] = [];\n\n get latestVersion(): Version | undefined {\n return Version.GetLatest(this.versions);\n }\n\n private _mountedVersion: Version | undefined;\n get mountedVersion() {\n return this._mountedVersion;\n }\n set mountedVersion(val: Version | undefined) {\n if (this._mountedVersion === val) return;\n\n this._mountedVersion = val;\n this.notifyOnChange();\n }\n\n get updateIsAvailable(): boolean | undefined {\n if (this._mountedVersion === undefined) return undefined;\n if (this.latestVersion === undefined) return undefined;\n\n return Version.AreEqual(this._mountedVersion, this.latestVersion)\n ? false\n : true;\n }\n\n private _state: AppState = AppState.INIT;\n get state() {\n return this._state;\n }\n set state(val: AppState) {\n this._state = val;\n this.notifyOnChange();\n }\n\n private _assignedToOwner: boolean = false;\n get assignedToOwner(): boolean {\n return this._assignedToOwner;\n }\n set assignedToOwner(val: boolean) {\n this._assignedToOwner = val;\n this.notifyOnChange();\n }\n\n get isMounted(): boolean {\n return this._mountedVersion === undefined ? false : true;\n }\n\n styles: string[] = [];\n appAssetFolderURL: string | undefined;\n\n private _errorMsg?: string;\n get errorMessage() {\n return this._errorMsg;\n }\n set errorMessage(val: string | undefined) {\n if (this._errorMsg === val) return;\n\n this._errorMsg = val;\n this.notifyOnChange();\n }\n get hasError(): boolean {\n return this._errorMsg === undefined ? false : true;\n }\n\n constructor(appObject: AppObject) {\n super(appObject, AppEntity.type);\n }\n}\n"]}
1
+ {"version":3,"file":"AppEntity.js","sourceRoot":"","sources":["../../../../src/Apps/Entities/AppEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEf,OAAO,EACP,cAAc,EACf,MAAM,aAAa,CAAC;AAErB;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,+BAAmB,CAAA;IACnB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,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,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IACD,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC;IAED,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QApH3B,iBAAY,GAAmB,IAAI,cAAc,CACvD,EAAE,EACF,IAAI,CAAC,cAAc,CACpB,CAAC;QAUM,wBAAmB,GAAmB,IAAI,cAAc,CAC9D,EAAE,EACF,IAAI,CAAC,cAAc,CACpB,CAAC;QAUM,qBAAgB,GAAmB,IAAI,cAAc,CAC3D,EAAE,EACF,IAAI,CAAC,cAAc,CACpB,CAAC;QAUM,yBAAoB,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAW3E,aAAQ,GAAc,EAAE,CAAC;QA0BjB,WAAM,GAAa,QAAQ,CAAC,IAAI,CAAC;QASjC,qBAAgB,GAAY,KAAK,CAAC;QAa1C,WAAM,GAAa,EAAE,CAAC;IAmBtB,CAAC;CACF","sourcesContent":["import {\r\n AppObject,\r\n AppObjectEntity,\r\n AppObjectRepo,\r\n Version,\r\n MemoizedString\r\n} from \"@vived/core\";\r\n\r\n/**\r\n * Enum representing the possible states of an application\r\n *\r\n * @enum {string}\r\n * @property {string} INIT - Initial state before app loading starts\r\n * @property {string} LOADING - App is currently loading resources\r\n * @property {string} READY - App is loaded and ready to use\r\n * @property {string} ERROR - App encountered an error during loading\r\n */\r\nexport enum AppState {\r\n INIT = \"INIT\",\r\n LOADING = \"LOADING\",\r\n READY = \"READY\",\r\n ERROR = \"ERROR\"\r\n}\r\n\r\n/**\r\n * AppEntity - Core entity representing an application in the system\r\n *\r\n * This abstract class defines the properties and behaviors of an application.\r\n * It manages app state, versioning, mounting status, and error handling.\r\n *\r\n * @extends AppObjectEntity from @vived/core\r\n */\r\nexport abstract class AppEntity extends AppObjectEntity {\r\n /** Type identifier for the AppEntity component */\r\n static type = \"AppEntity\";\r\n\r\n /**\r\n * Retrieves an AppEntity from a specific AppObject\r\n * @param appObj - The AppObject to retrieve the AppEntity from\r\n * @returns The AppEntity instance if found, undefined otherwise\r\n * @throws Error if appObj is null or undefined\r\n * @example\r\n * ```typescript\r\n * const appObject = appObjects.getOrCreate(\"myApp\");\r\n * const appEntity = AppEntity.get(appObject);\r\n * ```\r\n */\r\n static get(appObj: AppObject): AppEntity | undefined {\r\n if (!appObj) {\r\n throw new Error(\"AppObject cannot be null or undefined\");\r\n }\r\n return appObj.getComponent<AppEntity>(AppEntity.type);\r\n }\r\n\r\n /**\r\n * Retrieves an AppEntity by ID from the AppObjectRepo\r\n * @param id - The unique identifier of the app\r\n * @param appObjects - The AppObjectRepo to search within\r\n * @returns The AppEntity instance if found, undefined otherwise\r\n * @throws Error if id is empty or appObjects is null\r\n * @example\r\n * ```typescript\r\n * const appEntity = AppEntity.getById(\"myAppId\", appObjects);\r\n * if (appEntity) {\r\n * console.log(`Found app: ${appEntity.name}`);\r\n * }\r\n * ```\r\n */\r\n static getById(id: string, appObjects: AppObjectRepo): AppEntity | undefined {\r\n if (!id) {\r\n throw new Error(\"ID cannot be empty\");\r\n }\r\n if (!appObjects) {\r\n throw new Error(\"AppObjectRepo cannot be null or undefined\");\r\n }\r\n\r\n const ao = appObjects.get(id);\r\n if (!ao) {\r\n appObjects.submitWarning(\r\n \"AppEntity.getById\",\r\n `Unable to find app object by ID: ${id}`\r\n );\r\n return;\r\n }\r\n\r\n return ao.getComponent<AppEntity>(AppEntity.type);\r\n }\r\n\r\n /**\r\n * Safely creates an AppEntity if it doesn't already exist on the AppObject\r\n * @param appObject - The AppObject to add the AppEntity to\r\n * @returns The AppEntity instance (existing or newly created)\r\n * @throws Error if appObject is null or undefined\r\n * @example\r\n * ```typescript\r\n * const appObject = appObjects.getOrCreate(\"newApp\");\r\n * const appEntity = AppEntity.addIfMissing(appObject);\r\n * // appEntity is guaranteed to exist\r\n * ```\r\n */\r\n static addIfMissing(appObject: AppObject): AppEntity {\r\n if (!appObject) {\r\n throw new Error(\"AppObject cannot be null or undefined\");\r\n }\r\n\r\n // Check if AppEntity already exists\r\n const existingEntity = appObject.getComponent<AppEntity>(AppEntity.type);\r\n if (existingEntity) {\r\n return existingEntity;\r\n }\r\n\r\n // Create new AppEntity if it doesn't exist\r\n return makeAppEntity(appObject);\r\n }\r\n\r\n abstract get id(): string;\r\n abstract name: string;\r\n abstract description: string;\r\n abstract image_url: string;\r\n abstract imageAssetId: string | undefined;\r\n abstract versions: Version[];\r\n abstract get latestVersion(): Version | undefined;\r\n abstract errorMessage?: string;\r\n abstract get hasError(): boolean;\r\n abstract state: AppState;\r\n abstract assignedToOwner: boolean;\r\n\r\n abstract get isMounted(): boolean;\r\n abstract appAssetFolderURL?: string;\r\n abstract get updateIsAvailable(): boolean | undefined;\r\n abstract styles: string[];\r\n abstract mountedVersion: Version | undefined;\r\n}\r\n\r\n/**\r\n * Factory function to create a new AppEntity instance\r\n *\r\n * @param appObject - The app object to attach the entity to\r\n * @returns A concrete implementation of AppEntity\r\n */\r\nexport function makeAppEntity(appObject: AppObject): AppEntity {\r\n return new AppEntityImp(appObject);\r\n}\r\n\r\nclass AppEntityImp extends AppEntity {\r\n get id() {\r\n return this.appObject.id;\r\n }\r\n\r\n private memoizedName: MemoizedString = new MemoizedString(\r\n \"\",\r\n this.notifyOnChange\r\n );\r\n\r\n get name(): string {\r\n return this.memoizedName.val;\r\n }\r\n\r\n set name(val: string) {\r\n this.memoizedName.val = val;\r\n }\r\n\r\n private memoizedDescription: MemoizedString = new MemoizedString(\r\n \"\",\r\n this.notifyOnChange\r\n );\r\n\r\n get description(): string {\r\n return this.memoizedDescription.val;\r\n }\r\n\r\n set description(val: string) {\r\n this.memoizedDescription.val = val;\r\n }\r\n\r\n private memoizedImageUrl: MemoizedString = new MemoizedString(\r\n \"\",\r\n this.notifyOnChange\r\n );\r\n\r\n get image_url(): string {\r\n return this.memoizedImageUrl.val;\r\n }\r\n\r\n set image_url(val: string) {\r\n this.memoizedImageUrl.val = val;\r\n }\r\n\r\n private memoizedImageAssetId = new MemoizedString(\"\", this.notifyOnChange);\r\n\r\n get imageAssetId(): string | undefined {\r\n const value = this.memoizedImageAssetId.val;\r\n return value === \"\" ? undefined : value;\r\n }\r\n\r\n set imageAssetId(val: string | undefined) {\r\n this.memoizedImageAssetId.val = val ?? \"\";\r\n }\r\n\r\n versions: Version[] = [];\r\n\r\n get latestVersion(): Version | undefined {\r\n return Version.GetLatest(this.versions);\r\n }\r\n\r\n private _mountedVersion: Version | undefined;\r\n get mountedVersion() {\r\n return this._mountedVersion;\r\n }\r\n set mountedVersion(val: Version | undefined) {\r\n if (this._mountedVersion === val) return;\r\n\r\n this._mountedVersion = val;\r\n this.notifyOnChange();\r\n }\r\n\r\n get updateIsAvailable(): boolean | undefined {\r\n if (this._mountedVersion === undefined) return undefined;\r\n if (this.latestVersion === undefined) return undefined;\r\n\r\n return Version.AreEqual(this._mountedVersion, this.latestVersion)\r\n ? false\r\n : true;\r\n }\r\n\r\n private _state: AppState = AppState.INIT;\r\n get state() {\r\n return this._state;\r\n }\r\n set state(val: AppState) {\r\n this._state = val;\r\n this.notifyOnChange();\r\n }\r\n\r\n private _assignedToOwner: boolean = false;\r\n get assignedToOwner(): boolean {\r\n return this._assignedToOwner;\r\n }\r\n set assignedToOwner(val: boolean) {\r\n this._assignedToOwner = val;\r\n this.notifyOnChange();\r\n }\r\n\r\n get isMounted(): boolean {\r\n return this._mountedVersion === undefined ? false : true;\r\n }\r\n\r\n styles: string[] = [];\r\n appAssetFolderURL: string | undefined;\r\n\r\n private _errorMsg?: string;\r\n get errorMessage() {\r\n return this._errorMsg;\r\n }\r\n set errorMessage(val: string | undefined) {\r\n if (this._errorMsg === val) return;\r\n\r\n this._errorMsg = val;\r\n this.notifyOnChange();\r\n }\r\n get hasError(): boolean {\r\n return this._errorMsg === undefined ? false : true;\r\n }\r\n\r\n constructor(appObject: AppObject) {\r\n super(appObject, AppEntity.type);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,44 @@
1
+ import { DomainFactory } from "@vived/core";
2
+ import { makeAppRepo } from "../Entities";
3
+ import { makeAppsListPM } from "../PMs";
4
+ /**
5
+ * Factory responsible for setting up the Apps domain components.
6
+ * This factory initializes all entities, use cases, and presentation models
7
+ * required for the Apps functionality.
8
+ */
9
+ export class AppsFeatureFactory extends DomainFactory {
10
+ constructor(appObject) {
11
+ super(appObject);
12
+ // Unique name for this factory
13
+ this.factoryName = "AppsFeatureFactory";
14
+ }
15
+ /**
16
+ * Sets up all entities required for the Apps system
17
+ */
18
+ setupEntities() {
19
+ this.appRepoAO = this.appObjects.getOrCreate("App Repository");
20
+ // Initialize entities
21
+ makeAppRepo(this.appRepoAO);
22
+ }
23
+ /**
24
+ * Sets up all use cases for the Apps system
25
+ */
26
+ setupUCs() {
27
+ // Note: App UCs have complex dependencies and should be set up
28
+ // separately to avoid circular dependencies during factory initialization
29
+ }
30
+ /**
31
+ * Sets up all presentation managers for the Apps system
32
+ */
33
+ setupPMs() {
34
+ // App Repository PMs
35
+ makeAppsListPM(this.appRepoAO);
36
+ }
37
+ /**
38
+ * Performs any final setup operations after all components are initialized
39
+ */
40
+ finalSetup() {
41
+ // No additional setup required for apps
42
+ }
43
+ }
44
+ //# sourceMappingURL=AppsFeatureFactory.js.map
@@ -0,0 +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;IAOnD,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,CAAC,CAAC;QAPnB,+BAA+B;QACtB,gBAAW,GAAG,oBAAoB,CAAC;IAO5C,CAAC;IAED;;OAEG;IACH,aAAa;QACX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAE/D,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 // Store references to key AppObjects needed across setup phases\r\n private appRepoAO!: AppObject;\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 this.appRepoAO = this.appObjects.getOrCreate(\"App Repository\");\r\n\r\n // Initialize entities\r\n makeAppRepo(this.appRepoAO);\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.appRepoAO);\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,2 @@
1
+ export * from "./AppsFeatureFactory";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Apps/Factories/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./AppsFeatureFactory\";\r\n"]}
@@ -20,6 +20,7 @@
20
20
  export * from "./Adapters";
21
21
  export * from "./Controllers";
22
22
  export * from "./Entities";
23
+ export * from "./Factories";
23
24
  export * from "./Mocks";
24
25
  export * from "./PMs";
25
26
  export * from "./UCs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Apps/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC","sourcesContent":["/**\n * Apps Module - Core module for managing application lifecycle in the VIVED Learning platform\n *\n * This module handles app loading, mounting, starting, stopping, and state management.\n * It follows a clean architecture pattern with the following layers:\n *\n * - Entities: Core domain models (AppEntity, AppRepo)\n * - PMs (Presentation Models): Business logic and state management\n * - UCs (Use Cases): Implementation of specific operations\n * - Adapters: Connect PMs to UI components\n * - Controllers: Entry points for UI interactions\n *\n * To use this module, typically you would:\n * 1. Load an app using the AppEntity\n * 2. Mount the app using MounterUC\n * 3. Start the app using StartAppUC\n * 4. Manage app state via the AppPM or ActiveAppPM\n * 5. Stop the app using StopAppUC when done\n */\n\nexport * from \"./Adapters\";\nexport * from \"./Controllers\";\nexport * from \"./Entities\";\nexport * from \"./Mocks\";\nexport * from \"./PMs\";\nexport * from \"./UCs\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Apps/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC","sourcesContent":["/**\r\n * Apps Module - Core module for managing application lifecycle in the VIVED Learning platform\r\n *\r\n * This module handles app loading, mounting, starting, stopping, and state management.\r\n * It follows a clean architecture pattern with the following layers:\r\n *\r\n * - Entities: Core domain models (AppEntity, AppRepo)\r\n * - PMs (Presentation Models): Business logic and state management\r\n * - UCs (Use Cases): Implementation of specific operations\r\n * - Adapters: Connect PMs to UI components\r\n * - Controllers: Entry points for UI interactions\r\n *\r\n * To use this module, typically you would:\r\n * 1. Load an app using the AppEntity\r\n * 2. Mount the app using MounterUC\r\n * 3. Start the app using StartAppUC\r\n * 4. Manage app state via the AppPM or ActiveAppPM\r\n * 5. Stop the app using StopAppUC when done\r\n */\r\n\r\nexport * from \"./Adapters\";\r\nexport * from \"./Controllers\";\r\nexport * from \"./Entities\";\r\nexport * from \"./Factories\";\r\nexport * from \"./Mocks\";\r\nexport * from \"./PMs\";\r\nexport * from \"./UCs\";\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"apiStageAdapter.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Adapters/apiStageAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,6DAA6D;IAC7D,SAAS,EAAE,QAAQ,CAAC,UAAU;IAE9B;;;;OAIG;IACH,SAAS,EAAE,CAAC,UAAyB,EAAE,KAA6B,EAAE,EAAE;QACtE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,WAAW,EAAE,CAAC,UAAyB,EAAE,KAA6B,EAAE,EAAE;QACxE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF,CAAC","sourcesContent":["/**\r\n * apiStageAdapter.ts\r\n * \r\n * This file defines an adapter for connecting API stage presentation logic to UI frameworks.\r\n * The apiStageAdapter provides a standardized interface for binding API stage configuration\r\n * to view components, handling subscriptions and view model updates.\r\n * \r\n * Key concepts:\r\n * - Adapter implements SingletonPmAdapter interface for UI framework integration\r\n * - Manages subscription lifecycle for view components\r\n * - Provides default view model values for initialization\r\n * - Handles error cases when presentation manager is unavailable\r\n * - Enables reactive UI updates when API stage configuration changes\r\n * \r\n * Usage pattern:\r\n * 1. UI frameworks use this adapter to bind to API stage state\r\n * 2. Adapter manages PM subscriptions and view function callbacks\r\n * 3. View components receive API stage updates automatically\r\n * 4. Proper cleanup handled through unsubscribe mechanism\r\n */\r\n\r\nimport { AppObjectRepo, SingletonPmAdapter } from \"@vived/core\";\r\nimport { APIStage } from \"../Entities\";\r\nimport { ApiStagePM } from \"../PMs/ApiStagePM\";\r\n\r\n/**\r\n * Adapter for connecting API stage presentation logic to UI frameworks.\r\n * Implements SingletonPmAdapter to provide standardized view binding for API stage configuration.\r\n */\r\nexport const apiStageAdapter: SingletonPmAdapter<APIStage> = {\r\n /** Default view model value used when PM is not available */\r\n defaultVM: APIStage.PRODUCTION,\r\n \r\n /**\r\n * Subscribes a view function to receive API stage updates\r\n * @param appObjects The AppObjectRepo containing the ApiStagePM\r\n * @param setVM Callback function to update the view with new API stage values\r\n */\r\n subscribe: (appObjects: AppObjectRepo, setVM: (vm: APIStage) => void) => {\r\n const pm = ApiStagePM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"apiStageAdapter\", \"Unable to find ApiStagePM\");\r\n return;\r\n }\r\n pm.addView(setVM);\r\n },\r\n \r\n /**\r\n * Unsubscribes a view function from API stage updates\r\n * @param appObjects The AppObjectRepo containing the ApiStagePM\r\n * @param setVM Callback function to remove from view updates\r\n */\r\n unsubscribe: (appObjects: AppObjectRepo, setVM: (vm: APIStage) => void) => {\r\n const pm = ApiStagePM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"apiStageAdapter\", \"Unable to find ApiStagePM\");\r\n return;\r\n }\r\n pm.removeView(setVM);\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"apiStageAdapter.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Adapters/apiStageAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,6DAA6D;IAC7D,SAAS,EAAE,QAAQ,CAAC,UAAU;IAE9B;;;;OAIG;IACH,SAAS,EAAE,CAAC,UAAyB,EAAE,KAA6B,EAAE,EAAE;QACtE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,WAAW,EAAE,CAAC,UAAyB,EAAE,KAA6B,EAAE,EAAE;QACxE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF,CAAC","sourcesContent":["/**\r\n * apiStageAdapter.ts\r\n *\r\n * This file defines an adapter for connecting API stage presentation logic to UI frameworks.\r\n * The apiStageAdapter provides a standardized interface for binding API stage configuration\r\n * to view components, handling subscriptions and view model updates.\r\n *\r\n * Key concepts:\r\n * - Adapter implements SingletonPmAdapter interface for UI framework integration\r\n * - Manages subscription lifecycle for view components\r\n * - Provides default view model values for initialization\r\n * - Handles error cases when presentation manager is unavailable\r\n * - Enables reactive UI updates when API stage configuration changes\r\n *\r\n * Usage pattern:\r\n * 1. UI frameworks use this adapter to bind to API stage state\r\n * 2. Adapter manages PM subscriptions and view function callbacks\r\n * 3. View components receive API stage updates automatically\r\n * 4. Proper cleanup handled through unsubscribe mechanism\r\n */\r\n\r\nimport { AppObjectRepo, SingletonPmAdapter } from \"@vived/core\";\r\nimport { APIStage } from \"../Entities\";\r\nimport { ApiStagePM } from \"../PMs/ApiStagePM\";\r\n\r\n/**\r\n * Adapter for connecting API stage presentation logic to UI frameworks.\r\n * Implements SingletonPmAdapter to provide standardized view binding for API stage configuration.\r\n */\r\nexport const apiStageAdapter: SingletonPmAdapter<APIStage> = {\r\n /** Default view model value used when PM is not available */\r\n defaultVM: APIStage.PRODUCTION,\r\n\r\n /**\r\n * Subscribes a view function to receive API stage updates\r\n * @param appObjects The AppObjectRepo containing the ApiStagePM\r\n * @param setVM Callback function to update the view with new API stage values\r\n */\r\n subscribe: (appObjects: AppObjectRepo, setVM: (vm: APIStage) => void) => {\r\n const pm = ApiStagePM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"apiStageAdapter\", \"Unable to find ApiStagePM\");\r\n return;\r\n }\r\n pm.addView(setVM);\r\n },\r\n\r\n /**\r\n * Unsubscribes a view function from API stage updates\r\n * @param appObjects The AppObjectRepo containing the ApiStagePM\r\n * @param setVM Callback function to remove from view updates\r\n */\r\n unsubscribe: (appObjects: AppObjectRepo, setVM: (vm: APIStage) => void) => {\r\n const pm = ApiStagePM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"apiStageAdapter\", \"Unable to find ApiStagePM\");\r\n return;\r\n }\r\n pm.removeView(setVM);\r\n }\r\n};\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC","sourcesContent":["/**\r\n * VivedAPI Adapters Index\r\n * \r\n * This module exports all adapter objects for the VivedAPI feature.\r\n * Adapters provide standardized interfaces for connecting presentation managers\r\n * to various UI frameworks and libraries, handling subscription lifecycles\r\n * and view model synchronization.\r\n * \r\n * Key Concepts:\r\n * - Adapters implement framework-specific integration patterns\r\n * - They manage subscription and unsubscription to presentation manager updates\r\n * - Adapters provide default view model values for initialization\r\n * - They handle error cases when presentation managers are unavailable\r\n * - Adapters enable reactive UI updates across different frontend technologies\r\n * \r\n * Available Adapters:\r\n * - apiStageAdapter: Connects API stage configuration to UI components\r\n * - userTokenAdapter: Connects user authentication token state to UI displays\r\n */\r\n\r\nexport * from \"./apiStageAdapter\";\r\nexport * from \"./userTokenAdapter\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC","sourcesContent":["/**\r\n * VivedAPI Adapters Index\r\n *\r\n * This module exports all adapter objects for the VivedAPI feature.\r\n * Adapters provide standardized interfaces for connecting presentation managers\r\n * to various UI frameworks and libraries, handling subscription lifecycles\r\n * and view model synchronization.\r\n *\r\n * Key Concepts:\r\n * - Adapters implement framework-specific integration patterns\r\n * - They manage subscription and unsubscription to presentation manager updates\r\n * - Adapters provide default view model values for initialization\r\n * - They handle error cases when presentation managers are unavailable\r\n * - Adapters enable reactive UI updates across different frontend technologies\r\n *\r\n * Available Adapters:\r\n * - apiStageAdapter: Connects API stage configuration to UI components\r\n * - userTokenAdapter: Connects user authentication token state to UI displays\r\n */\r\n\r\nexport * from \"./apiStageAdapter\";\r\nexport * from \"./userTokenAdapter\";\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"userTokenAdapter.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Adapters/userTokenAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,6DAA6D;IAC7D,SAAS,EAAE,EAAE;IAEb;;;;OAIG;IACH,SAAS,EAAE,CAAC,UAAyB,EAAE,KAA2B,EAAE,EAAE;QACpE,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,WAAW,EAAE,CAAC,UAAyB,EAAE,KAA2B,EAAE,EAAE;QACtE,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF,CAAC","sourcesContent":["/**\r\n * userTokenAdapter.ts\r\n * \r\n * This file defines an adapter for connecting user token presentation logic to UI frameworks.\r\n * The userTokenAdapter provides a standardized interface for binding user authentication\r\n * token state to view components, handling subscriptions and view model updates.\r\n * \r\n * Key concepts:\r\n * - Adapter implements SingletonPmAdapter interface for UI framework integration\r\n * - Manages subscription lifecycle for view components displaying user tokens\r\n * - Provides default view model values for initialization (empty string)\r\n * - Handles error cases when presentation manager is unavailable\r\n * - Enables reactive UI updates when user authentication token changes\r\n * \r\n * Usage pattern:\r\n * 1. UI frameworks use this adapter to bind to user token state\r\n * 2. Adapter manages PM subscriptions and view function callbacks\r\n * 3. View components receive token updates automatically\r\n * 4. Proper cleanup handled through unsubscribe mechanism\r\n */\r\n\r\nimport { AppObjectRepo, SingletonPmAdapter } from \"@vived/core\";\r\nimport { UserTokenPM } from \"../PMs/UserTokenPM\";\r\n\r\n/**\r\n * Adapter for connecting user token presentation logic to UI frameworks.\r\n * Implements SingletonPmAdapter to provide standardized view binding for user authentication tokens.\r\n */\r\nexport const userTokenAdapter: SingletonPmAdapter<string> = {\r\n /** Default view model value used when PM is not available */\r\n defaultVM: \"\",\r\n \r\n /**\r\n * Subscribes a view function to receive user token updates\r\n * @param appObjects The AppObjectRepo containing the UserTokenPM\r\n * @param setVM Callback function to update the view with new token values\r\n */\r\n subscribe: (appObjects: AppObjectRepo, setVM: (vm: string) => void) => {\r\n const pm = UserTokenPM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"userTokenAdapter\", \"Unable to find UserTokenPM\");\r\n return;\r\n }\r\n pm.addView(setVM);\r\n },\r\n \r\n /**\r\n * Unsubscribes a view function from user token updates\r\n * @param appObjects The AppObjectRepo containing the UserTokenPM\r\n * @param setVM Callback function to remove from view updates\r\n */\r\n unsubscribe: (appObjects: AppObjectRepo, setVM: (vm: string) => void) => {\r\n const pm = UserTokenPM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"userTokenAdapter\", \"Unable to find UserTokenPM\");\r\n return;\r\n }\r\n pm.removeView(setVM);\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"userTokenAdapter.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Adapters/userTokenAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA+B;IAC1D,6DAA6D;IAC7D,SAAS,EAAE,EAAE;IAEb;;;;OAIG;IACH,SAAS,EAAE,CAAC,UAAyB,EAAE,KAA2B,EAAE,EAAE;QACpE,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,WAAW,EAAE,CAAC,UAAyB,EAAE,KAA2B,EAAE,EAAE;QACtE,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,UAAU,CAAC,WAAW,CAAC,kBAAkB,EAAE,4BAA4B,CAAC,CAAC;YACzE,OAAO;QACT,CAAC;QACD,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF,CAAC","sourcesContent":["/**\r\n * userTokenAdapter.ts\r\n *\r\n * This file defines an adapter for connecting user token presentation logic to UI frameworks.\r\n * The userTokenAdapter provides a standardized interface for binding user authentication\r\n * token state to view components, handling subscriptions and view model updates.\r\n *\r\n * Key concepts:\r\n * - Adapter implements SingletonPmAdapter interface for UI framework integration\r\n * - Manages subscription lifecycle for view components displaying user tokens\r\n * - Provides default view model values for initialization (empty string)\r\n * - Handles error cases when presentation manager is unavailable\r\n * - Enables reactive UI updates when user authentication token changes\r\n *\r\n * Usage pattern:\r\n * 1. UI frameworks use this adapter to bind to user token state\r\n * 2. Adapter manages PM subscriptions and view function callbacks\r\n * 3. View components receive token updates automatically\r\n * 4. Proper cleanup handled through unsubscribe mechanism\r\n */\r\n\r\nimport { AppObjectRepo, SingletonPmAdapter } from \"@vived/core\";\r\nimport { UserTokenPM } from \"../PMs/UserTokenPM\";\r\n\r\n/**\r\n * Adapter for connecting user token presentation logic to UI frameworks.\r\n * Implements SingletonPmAdapter to provide standardized view binding for user authentication tokens.\r\n */\r\nexport const userTokenAdapter: SingletonPmAdapter<string> = {\r\n /** Default view model value used when PM is not available */\r\n defaultVM: \"\",\r\n\r\n /**\r\n * Subscribes a view function to receive user token updates\r\n * @param appObjects The AppObjectRepo containing the UserTokenPM\r\n * @param setVM Callback function to update the view with new token values\r\n */\r\n subscribe: (appObjects: AppObjectRepo, setVM: (vm: string) => void) => {\r\n const pm = UserTokenPM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"userTokenAdapter\", \"Unable to find UserTokenPM\");\r\n return;\r\n }\r\n pm.addView(setVM);\r\n },\r\n\r\n /**\r\n * Unsubscribes a view function from user token updates\r\n * @param appObjects The AppObjectRepo containing the UserTokenPM\r\n * @param setVM Callback function to remove from view updates\r\n */\r\n unsubscribe: (appObjects: AppObjectRepo, setVM: (vm: string) => void) => {\r\n const pm = UserTokenPM.get(appObjects);\r\n if (!pm) {\r\n appObjects.submitError(\"userTokenAdapter\", \"Unable to find UserTokenPM\");\r\n return;\r\n }\r\n pm.removeView(setVM);\r\n }\r\n};\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC","sourcesContent":["/**\r\n * VivedAPI Controllers Index\r\n * \r\n * This module exports all controller functions for the VivedAPI feature.\r\n * Controllers handle user input and coordinate operations between UI components\r\n * and the underlying business logic components.\r\n * \r\n * Key Concepts:\r\n * - Controllers provide simple function interfaces for common operations\r\n * - They validate inputs and handle error cases appropriately\r\n * - Controllers coordinate between use cases, entities, and external systems\r\n * - They serve as the primary interface for UI framework integration\r\n * - Error handling and logging are managed at the controller level\r\n * \r\n * Available Controllers:\r\n * - User Authentication: loginUser, logoutUser, refreshAuthenticatedUser\r\n * - API Configuration: setApiStage\r\n */\r\n\r\nexport * from \"./loginUser\";\r\nexport * from \"./logoutUser\";\r\nexport * from \"./refreshAuthenticatedUser\";\r\nexport * from \"./setApiStage\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC","sourcesContent":["/**\r\n * VivedAPI Controllers Index\r\n *\r\n * This module exports all controller functions for the VivedAPI feature.\r\n * Controllers handle user input and coordinate operations between UI components\r\n * and the underlying business logic components.\r\n *\r\n * Key Concepts:\r\n * - Controllers provide simple function interfaces for common operations\r\n * - They validate inputs and handle error cases appropriately\r\n * - Controllers coordinate between use cases, entities, and external systems\r\n * - They serve as the primary interface for UI framework integration\r\n * - Error handling and logging are managed at the controller level\r\n *\r\n * Available Controllers:\r\n * - User Authentication: loginUser, logoutUser, refreshAuthenticatedUser\r\n * - API Configuration: setApiStage\r\n */\r\n\r\nexport * from \"./loginUser\";\r\nexport * from \"./logoutUser\";\r\nexport * from \"./refreshAuthenticatedUser\";\r\nexport * from \"./setApiStage\";\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"loginUser.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/loginUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,QAAgB,EAChB,UAAyB;IAEzB,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEtC,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,2BAA2B,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\r\n * loginUser.ts\r\n * \r\n * This file defines a controller function for user authentication login operations.\r\n * The loginUser controller provides a simple interface for authenticating users\r\n * with username and password credentials through the VIVED API.\r\n * \r\n * Key concepts:\r\n * - Controller functions handle user input and direct authentication operations\r\n * - Validates UserAuthUC existence before performing login operations\r\n * - Provides error handling and warning messages for missing components\r\n * - Returns promises for async authentication workflows\r\n * - Coordinates with UserAuthUC for actual authentication logic\r\n * \r\n * Usage pattern:\r\n * 1. Call loginUser with credentials and appObjects repository\r\n * 2. Controller validates UC existence and initiates login workflow\r\n * 3. Handle returned Promise for authentication success or failure\r\n * 4. Error handling provides feedback if authentication UC is unavailable\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { UserAuthUC } from \"../UCs\";\r\n\r\n/**\r\n * Authenticates a user with username and password credentials\r\n * @param userName The user's login username\r\n * @param password The user's login password\r\n * @param appObjects The AppObjectRepo containing the UserAuthUC\r\n * @returns Promise that resolves when login is complete or rejects on error\r\n */\r\nexport function loginUser(\r\n userName: string,\r\n password: string,\r\n appObjects: AppObjectRepo\r\n): Promise<void> {\r\n const uc = UserAuthUC.get(appObjects);\r\n\r\n if (uc) {\r\n return uc.login(userName, password);\r\n } else {\r\n appObjects.submitWarning(\"loginUser\", \"Unable to find UserAuthUC\");\r\n return Promise.reject(new Error(\"Unable to find UserAuthUC\"));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"loginUser.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/loginUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,QAAgB,EAChB,UAAyB;IAEzB,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEtC,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,aAAa,CAAC,WAAW,EAAE,2BAA2B,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\r\n * loginUser.ts\r\n *\r\n * This file defines a controller function for user authentication login operations.\r\n * The loginUser controller provides a simple interface for authenticating users\r\n * with username and password credentials through the VIVED API.\r\n *\r\n * Key concepts:\r\n * - Controller functions handle user input and direct authentication operations\r\n * - Validates UserAuthUC existence before performing login operations\r\n * - Provides error handling and warning messages for missing components\r\n * - Returns promises for async authentication workflows\r\n * - Coordinates with UserAuthUC for actual authentication logic\r\n *\r\n * Usage pattern:\r\n * 1. Call loginUser with credentials and appObjects repository\r\n * 2. Controller validates UC existence and initiates login workflow\r\n * 3. Handle returned Promise for authentication success or failure\r\n * 4. Error handling provides feedback if authentication UC is unavailable\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { UserAuthUC } from \"../UCs\";\r\n\r\n/**\r\n * Authenticates a user with username and password credentials\r\n * @param userName The user's login username\r\n * @param password The user's login password\r\n * @param appObjects The AppObjectRepo containing the UserAuthUC\r\n * @returns Promise that resolves when login is complete or rejects on error\r\n */\r\nexport function loginUser(\r\n userName: string,\r\n password: string,\r\n appObjects: AppObjectRepo\r\n): Promise<void> {\r\n const uc = UserAuthUC.get(appObjects);\r\n\r\n if (uc) {\r\n return uc.login(userName, password);\r\n } else {\r\n appObjects.submitWarning(\"loginUser\", \"Unable to find UserAuthUC\");\r\n return Promise.reject(new Error(\"Unable to find UserAuthUC\"));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"logoutUser.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/logoutUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,UAAyB;IAClD,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEtC,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,aAAa,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\r\n * logoutUser.ts\r\n * \r\n * This file defines a controller function for user logout operations.\r\n * The logoutUser controller provides a simple interface for terminating user\r\n * sessions and clearing authentication state through the VIVED API.\r\n * \r\n * Key concepts:\r\n * - Controller functions handle user input and direct logout operations\r\n * - Validates UserAuthUC existence before performing logout operations\r\n * - Provides error handling and warning messages for missing components\r\n * - Returns promises for async logout workflows\r\n * - Coordinates with UserAuthUC for actual logout logic\r\n * \r\n * Usage pattern:\r\n * 1. Call logoutUser with appObjects repository\r\n * 2. Controller validates UC existence and initiates logout workflow\r\n * 3. Handle returned Promise for logout success or failure\r\n * 4. Error handling provides feedback if authentication UC is unavailable\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { UserAuthUC } from \"../UCs\";\r\n\r\n/**\r\n * Logs out the current user and terminates the session\r\n * @param appObjects The AppObjectRepo containing the UserAuthUC\r\n * @returns Promise that resolves when logout is complete or rejects on error\r\n */\r\nexport function logoutUser(appObjects: AppObjectRepo): Promise<void> {\r\n const uc = UserAuthUC.get(appObjects);\r\n\r\n if (uc) {\r\n return uc.logout();\r\n } else {\r\n appObjects.submitWarning(\"logoutUser\", \"Unable to find UserAuthUC\");\r\n return Promise.reject(new Error(\"Unable to find UserAuthUC\"));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"logoutUser.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/logoutUser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,UAAyB;IAClD,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAEtC,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,aAAa,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\r\n * logoutUser.ts\r\n *\r\n * This file defines a controller function for user logout operations.\r\n * The logoutUser controller provides a simple interface for terminating user\r\n * sessions and clearing authentication state through the VIVED API.\r\n *\r\n * Key concepts:\r\n * - Controller functions handle user input and direct logout operations\r\n * - Validates UserAuthUC existence before performing logout operations\r\n * - Provides error handling and warning messages for missing components\r\n * - Returns promises for async logout workflows\r\n * - Coordinates with UserAuthUC for actual logout logic\r\n *\r\n * Usage pattern:\r\n * 1. Call logoutUser with appObjects repository\r\n * 2. Controller validates UC existence and initiates logout workflow\r\n * 3. Handle returned Promise for logout success or failure\r\n * 4. Error handling provides feedback if authentication UC is unavailable\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { UserAuthUC } from \"../UCs\";\r\n\r\n/**\r\n * Logs out the current user and terminates the session\r\n * @param appObjects The AppObjectRepo containing the UserAuthUC\r\n * @returns Promise that resolves when logout is complete or rejects on error\r\n */\r\nexport function logoutUser(appObjects: AppObjectRepo): Promise<void> {\r\n const uc = UserAuthUC.get(appObjects);\r\n\r\n if (uc) {\r\n return uc.logout();\r\n } else {\r\n appObjects.submitWarning(\"logoutUser\", \"Unable to find UserAuthUC\");\r\n return Promise.reject(new Error(\"Unable to find UserAuthUC\"));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"setApiStage.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/setApiStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAY,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAe,EAAE,UAAyB;IACpE,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,aAAa,CAAC,aAAa,EAAE,+BAA+B,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["/**\r\n * setApiStage.ts\r\n * \r\n * This file defines a controller function for setting the API stage configuration.\r\n * The setApiStage controller provides a simple interface for changing the API environment\r\n * that the application communicates with.\r\n * \r\n * Key concepts:\r\n * - Controller functions handle user input and direct operations\r\n * - Validates entity existence before performing operations\r\n * - Provides error handling and warning messages for missing components\r\n * - Updates the VivedAPIEntity singleton with new stage configuration\r\n * - Triggers change notifications to update dependent components\r\n * \r\n * Usage pattern:\r\n * 1. Call setApiStage with desired stage and appObjects repository\r\n * 2. Controller validates entity existence and updates configuration\r\n * 3. Change notifications propagate to PMs and UI components\r\n * 4. Error handling provides feedback if entity is not available\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { APIStage, VivedAPIEntity } from \"../Entities\";\r\n\r\n/**\r\n * Sets the API stage configuration for the application\r\n * @param stage The APIStage to set as the current environment\r\n * @param appObjects The AppObjectRepo containing the VivedAPIEntity singleton\r\n */\r\nexport function setApiStage(stage: APIStage, appObjects: AppObjectRepo) {\r\n const sandbox = VivedAPIEntity.get(appObjects);\r\n if (sandbox) {\r\n sandbox.apiStage = stage;\r\n } else {\r\n appObjects.submitWarning(\"setApiStage\", \"Unable to find VivedAPIEntity\");\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"setApiStage.js","sourceRoot":"","sources":["../../../../src/VivedAPI/Controllers/setApiStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAY,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAe,EAAE,UAAyB;IACpE,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC3B,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,aAAa,CAAC,aAAa,EAAE,+BAA+B,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["/**\r\n * setApiStage.ts\r\n *\r\n * This file defines a controller function for setting the API stage configuration.\r\n * The setApiStage controller provides a simple interface for changing the API environment\r\n * that the application communicates with.\r\n *\r\n * Key concepts:\r\n * - Controller functions handle user input and direct operations\r\n * - Validates entity existence before performing operations\r\n * - Provides error handling and warning messages for missing components\r\n * - Updates the VivedAPIEntity singleton with new stage configuration\r\n * - Triggers change notifications to update dependent components\r\n *\r\n * Usage pattern:\r\n * 1. Call setApiStage with desired stage and appObjects repository\r\n * 2. Controller validates entity existence and updates configuration\r\n * 3. Change notifications propagate to PMs and UI components\r\n * 4. Error handling provides feedback if entity is not available\r\n */\r\n\r\nimport { AppObjectRepo } from \"@vived/core\";\r\nimport { APIStage, VivedAPIEntity } from \"../Entities\";\r\n\r\n/**\r\n * Sets the API stage configuration for the application\r\n * @param stage The APIStage to set as the current environment\r\n * @param appObjects The AppObjectRepo containing the VivedAPIEntity singleton\r\n */\r\nexport function setApiStage(stage: APIStage, appObjects: AppObjectRepo) {\r\n const sandbox = VivedAPIEntity.get(appObjects);\r\n if (sandbox) {\r\n sandbox.apiStage = stage;\r\n } else {\r\n appObjects.submitWarning(\"setApiStage\", \"Unable to find VivedAPIEntity\");\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"VivedAP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AAC;QAC9C,CAAC;QACD,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAcD;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS,CAAC,GAAW;QACvB,IAAI,CAAC,iBAAiB,CAAC,GAAG,GAAG,GAAG,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;QAjFxC,8BAA8B;QAC9B,kBAAa,GAAG,+BAA+B,CAAC;QAChD,2BAA2B;QAC3B,eAAU,GAAG,uCAAuC,CAAC;QACrD,+BAA+B;QAC/B,mBAAc,GAAG,oCAAoC,CAAC;QACtD,qCAAqC;QACrC,aAAQ,GAAG,uBAAuB,CAAC;QAEnC,kDAAkD;QAC1C,qBAAgB,GAAG,IAAI,cAAc,CAC3C,QAAQ,CAAC,UAAU,EACnB,IAAI,CAAC,cAAc,CACpB,CAAC;QAmCF;;;;WAIG;QACH,mBAAc,GAAG,CAAC,QAAgB,EAAO,EAAE;YACzC,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF,kEAAkE;QAC1D,sBAAiB,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAwBtE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;;AA/FD,gDAAgD;AACzC,mBAAI,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["/**\r\n * VivedAPIEntity.ts\r\n * \r\n * This file defines the core entity for managing VIVED API configuration and authentication.\r\n * The VivedAPIEntity acts as a singleton component that centralizes API communication settings,\r\n * including environment-specific base URLs and user authentication tokens.\r\n * \r\n * Key concepts:\r\n * - Manages API stage configuration (Production, Staging, Development, Local)\r\n * - Stores and tracks user authentication tokens\r\n * - Provides environment-specific base URLs for API requests\r\n * - Notifies observers when API settings change\r\n * - Implements singleton pattern for system-wide API configuration\r\n * \r\n * Usage pattern:\r\n * 1. Get the singleton entity using VivedAPIEntity.get(appObjects)\r\n * 2. Configure API stage and user token as needed\r\n * 3. Use baseUrl and getEndpointURL for API requests\r\n * 4. Register change observers to react to configuration updates\r\n */\r\n\r\nimport { MemoizedString } from \"@vived/core\";\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectEntity,\r\n AppObjectRepo\r\n} from \"@vived/core\";\r\n\r\n/**\r\n * Enum representing different API environment stages\r\n */\r\nexport enum APIStage {\r\n /** Production environment with live data */\r\n PRODUCTION = \"Production\",\r\n /** Staging environment for pre-production testing */\r\n STAGING = \"Staging\",\r\n /** Development environment for testing */\r\n DEVELOPMENT = \"Development\",\r\n /** Local development environment */\r\n LOCAL = \"LOCAL\"\r\n}\r\n\r\n/**\r\n * VivedAPIEntity manages API configuration and authentication state.\r\n * This singleton entity provides centralized access to API settings including\r\n * environment-specific URLs and user authentication tokens.\r\n */\r\nexport class VivedAPIEntity extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static type = \"VivedAPIEntity\";\r\n\r\n /**\r\n * Retrieves the singleton VivedAPIEntity from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The VivedAPIEntity singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): VivedAPIEntity | undefined {\r\n return getSingletonComponent(VivedAPIEntity.type, appObjects);\r\n }\r\n\r\n /** Production API base URL */\r\n productionURL = \"https://api.vivedlearning.com\";\r\n /** Staging API base URL */\r\n stagingURL = \"https://api-staging.vivedlearning.com\";\r\n /** Development API base URL */\r\n developmentURL = \"https://api-test.vivedlearning.com\";\r\n /** Local development API base URL */\r\n localURL = \"http://localhost:3001\";\r\n\r\n /** Memoized API stage that notifies on changes */\r\n private memoizedApiState = new MemoizedString(\r\n APIStage.PRODUCTION,\r\n this.notifyOnChange\r\n );\r\n\r\n /**\r\n * Gets the current API stage\r\n * @returns The current APIStage\r\n */\r\n get apiStage() {\r\n return this.memoizedApiState.val as APIStage;\r\n }\r\n \r\n /**\r\n * Sets the API stage and notifies observers of the change\r\n * @param apiState The new APIStage to set\r\n */\r\n set apiStage(apiState: APIStage) {\r\n this.memoizedApiState.val = apiState;\r\n }\r\n\r\n /**\r\n * Gets the base URL for the current API stage\r\n * @returns The base URL string for the current environment\r\n */\r\n get baseUrl(): string {\r\n if (this.memoizedApiState.val === APIStage.PRODUCTION) {\r\n return \"https://api.vivedlearning.com\";\r\n }\r\n if (this.memoizedApiState.val === APIStage.STAGING) {\r\n return \"https://api-staging.vivedlearning.com\";\r\n }\r\n if (this.memoizedApiState.val === APIStage.DEVELOPMENT) {\r\n return \"https://api-test.vivedlearning.com\";\r\n }\r\n return \"http://localhost:3001\";\r\n }\r\n\r\n /**\r\n * Constructs a complete endpoint URL using the current base URL\r\n * @param endpoint The endpoint path to append to the base URL\r\n * @returns A URL object representing the complete endpoint URL\r\n */\r\n getEndpointURL = (endpoint: string): URL => {\r\n return new URL(endpoint, this.baseUrl);\r\n };\r\n\r\n /** Memoized user authentication token that notifies on changes */\r\n private memoizedUserToken = new MemoizedString(\"\", this.notifyOnChange);\r\n \r\n /**\r\n * Gets the current user authentication token\r\n * @returns The current user token string\r\n */\r\n get userToken(): string {\r\n return this.memoizedUserToken.val;\r\n }\r\n \r\n /**\r\n * Sets the user authentication token and notifies observers\r\n * @param val The new user token to set\r\n */\r\n set userToken(val: string) {\r\n this.memoizedUserToken.val = val;\r\n }\r\n\r\n /**\r\n * Constructs a new VivedAPIEntity and registers it as a singleton\r\n * @param appObject The AppObject this entity belongs to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, VivedAPIEntity.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"VivedAPIEntity.js","sourceRoot":"","sources":["../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AO,uBAAuB,CAAC;IACjC,CAAC;IAcD;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS,CAAC,GAAW;QACvB,IAAI,CAAC,iBAAiB,CAAC,GAAG,GAAG,GAAG,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;QAjFxC,8BAA8B;QAC9B,kBAAa,GAAG,+BAA+B,CAAC;QAChD,2BAA2B;QAC3B,eAAU,GAAG,uCAAuC,CAAC;QACrD,+BAA+B;QAC/B,mBAAc,GAAG,oCAAoC,CAAC;QACtD,qCAAqC;QACrC,aAAQ,GAAG,uBAAuB,CAAC;QAEnC,kDAAkD;QAC1C,qBAAgB,GAAG,IAAI,cAAc,CAC3C,QAAQ,CAAC,UAAU,EACnB,IAAI,CAAC,cAAc,CACpB,CAAC;QAmCF;;;;WAIG;QACH,mBAAc,GAAG,CAAC,QAAgB,EAAO,EAAE;YACzC,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF,kEAAkE;QAC1D,sBAAiB,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAwBtE,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;;AA/FD,gDAAgD;AACzC,mBAAI,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["/**\r\n * VivedAPIEntity.ts\r\n *\r\n * This file defines the core entity for managing VIVED API configuration and authentication.\r\n * The VivedAPIEntity acts as a singleton component that centralizes API communication settings,\r\n * including environment-specific base URLs and user authentication tokens.\r\n *\r\n * Key concepts:\r\n * - Manages API stage configuration (Production, Staging, Development, Local)\r\n * - Stores and tracks user authentication tokens\r\n * - Provides environment-specific base URLs for API requests\r\n * - Notifies observers when API settings change\r\n * - Implements singleton pattern for system-wide API configuration\r\n *\r\n * Usage pattern:\r\n * 1. Get the singleton entity using VivedAPIEntity.get(appObjects)\r\n * 2. Configure API stage and user token as needed\r\n * 3. Use baseUrl and getEndpointURL for API requests\r\n * 4. Register change observers to react to configuration updates\r\n */\r\n\r\nimport { MemoizedString } from \"@vived/core\";\r\nimport {\r\n getSingletonComponent,\r\n AppObject,\r\n AppObjectEntity,\r\n AppObjectRepo\r\n} from \"@vived/core\";\r\n\r\n/**\r\n * Enum representing different API environment stages\r\n */\r\nexport enum APIStage {\r\n /** Production environment with live data */\r\n PRODUCTION = \"Production\",\r\n /** Staging environment for pre-production testing */\r\n STAGING = \"Staging\",\r\n /** Development environment for testing */\r\n DEVELOPMENT = \"Development\",\r\n /** Local development environment */\r\n LOCAL = \"LOCAL\"\r\n}\r\n\r\n/**\r\n * VivedAPIEntity manages API configuration and authentication state.\r\n * This singleton entity provides centralized access to API settings including\r\n * environment-specific URLs and user authentication tokens.\r\n */\r\nexport class VivedAPIEntity extends AppObjectEntity {\r\n /** Unique type identifier for this component */\r\n static type = \"VivedAPIEntity\";\r\n\r\n /**\r\n * Retrieves the singleton VivedAPIEntity from the app objects repository\r\n * @param appObjects The AppObjectRepo to get the singleton from\r\n * @returns The VivedAPIEntity singleton or undefined if not found\r\n */\r\n static get(appObjects: AppObjectRepo): VivedAPIEntity | undefined {\r\n return getSingletonComponent(VivedAPIEntity.type, appObjects);\r\n }\r\n\r\n /** Production API base URL */\r\n productionURL = \"https://api.vivedlearning.com\";\r\n /** Staging API base URL */\r\n stagingURL = \"https://api-staging.vivedlearning.com\";\r\n /** Development API base URL */\r\n developmentURL = \"https://api-test.vivedlearning.com\";\r\n /** Local development API base URL */\r\n localURL = \"http://localhost:3001\";\r\n\r\n /** Memoized API stage that notifies on changes */\r\n private memoizedApiState = new MemoizedString(\r\n APIStage.PRODUCTION,\r\n this.notifyOnChange\r\n );\r\n\r\n /**\r\n * Gets the current API stage\r\n * @returns The current APIStage\r\n */\r\n get apiStage() {\r\n return this.memoizedApiState.val as APIStage;\r\n }\r\n\r\n /**\r\n * Sets the API stage and notifies observers of the change\r\n * @param apiState The new APIStage to set\r\n */\r\n set apiStage(apiState: APIStage) {\r\n this.memoizedApiState.val = apiState;\r\n }\r\n\r\n /**\r\n * Gets the base URL for the current API stage\r\n * @returns The base URL string for the current environment\r\n */\r\n get baseUrl(): string {\r\n if (this.memoizedApiState.val === APIStage.PRODUCTION) {\r\n return \"https://api.vivedlearning.com\";\r\n }\r\n if (this.memoizedApiState.val === APIStage.STAGING) {\r\n return \"https://api-staging.vivedlearning.com\";\r\n }\r\n if (this.memoizedApiState.val === APIStage.DEVELOPMENT) {\r\n return \"https://api-test.vivedlearning.com\";\r\n }\r\n return \"http://localhost:3001\";\r\n }\r\n\r\n /**\r\n * Constructs a complete endpoint URL using the current base URL\r\n * @param endpoint The endpoint path to append to the base URL\r\n * @returns A URL object representing the complete endpoint URL\r\n */\r\n getEndpointURL = (endpoint: string): URL => {\r\n return new URL(endpoint, this.baseUrl);\r\n };\r\n\r\n /** Memoized user authentication token that notifies on changes */\r\n private memoizedUserToken = new MemoizedString(\"\", this.notifyOnChange);\r\n\r\n /**\r\n * Gets the current user authentication token\r\n * @returns The current user token string\r\n */\r\n get userToken(): string {\r\n return this.memoizedUserToken.val;\r\n }\r\n\r\n /**\r\n * Sets the user authentication token and notifies observers\r\n * @param val The new user token to set\r\n */\r\n set userToken(val: string) {\r\n this.memoizedUserToken.val = val;\r\n }\r\n\r\n /**\r\n * Constructs a new VivedAPIEntity and registers it as a singleton\r\n * @param appObject The AppObject this entity belongs to\r\n */\r\n constructor(appObject: AppObject) {\r\n super(appObject, VivedAPIEntity.type);\r\n this.appObjects.registerSingleton(this);\r\n }\r\n}\r\n"]}