diff --git a/.komment/00000.json b/.komment/00000.json new file mode 100644 index 0000000..5f6ff73 --- /dev/null +++ b/.komment/00000.json @@ -0,0 +1,1027 @@ +[ + { + "name": "index.ts", + "path": "src/index.ts", + "content": { + "structured": { + "description": "A `DocumentStore` class for managing adding, retrieving, and updating documents in a specified folder. It includes functions for loading and summarizing documents, as well as methods for updating files and generating high-quality documentation. The code also uses various types and packages such as `PassType`, `GetRemote`, `StructuredFile`, and `Summarry`. Overall, the code provides a flexible and structured approach to managing and organizing documents.", + "items": [ + { + "id": "b3dde4d0-0c04-e6b8-f94b-b717b02da80a", + "ancestors": [], + "description": "Stores and manages code documentation, providing an interface for loading, updating, and querying the content.", + "interfaces": [ + "IDocumentStore" + ], + "superclass": null, + "is_abstract": false, + "fields": [ + { + "name": "CHUNK_SIZE", + "type_name": "number", + "description": "512 by default, which defines the size of each chunk in the code storage." + }, + { + "name": "namespace", + "type_name": "string", + "description": "Required. It provides a unique identifier for the code document store, which is used to generate high-quality documentation." + }, + { + "name": "meta", + "type_name": { + "full": "{\n version: string;\n created_at: Date;\n updated_at: Date;\n [key: string]: any;\n }", + "pattern": "object", + "sub": [ + { + "name": "version", + "type_name": "string", + "value": null, + "visibility": null, + "is_static": false, + "is_optional": false, + "is_readonly": false + }, + { + "name": "created_at", + "type_name": "Date", + "value": null, + "visibility": null, + "is_static": false, + "is_optional": false, + "is_readonly": false + }, + { + "name": "updated_at", + "type_name": "Date", + "value": null, + "visibility": null, + "is_static": false, + "is_optional": false, + "is_readonly": false + } + ] + }, + "description": "Used to store information about the document" + }, + { + "name": "metaTemplate", + "type_name": { + "pattern": "generic", + "full": "Record", + "name": "Record", + "by": [ + "string", + "any" + ] + }, + "description": "Used to provide information about the metadata of the document." + }, + { + "name": "lookup", + "type_name": "string[][]", + "description": "Used to store a list of file paths that correspond to chunks of code, keyed by chunk index." + }, + { + "name": "chunks", + "type_name": "StructuredFile[][]", + "description": "Used to store chunks of content." + }, + { + "name": "content", + "type_name": "StructuredFile[]", + "description": "Responsible for storing the contents of the document chunks in the internal array." + }, + { + "name": "status", + "type_name": { + "full": "{\n summary: boolean;\n chunks: boolean;\n }", + "pattern": "object", + "sub": [ + { + "name": "summary", + "type_name": "boolean", + "value": null, + "visibility": null, + "is_static": false, + "is_optional": false, + "is_readonly": false + }, + { + "name": "chunks", + "type_name": "boolean", + "value": null, + "visibility": null, + "is_static": false, + "is_optional": false, + "is_readonly": false + } + ] + }, + "description": "Used to track the state of the document store, including whether summary was last updated and whether chunks were loaded." + } + ], + "name": "DocumentStore", + "location": { + "start": 22, + "insert": 22, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "class", + "length": 352, + "docLength": null + }, + { + "id": "8708e7e0-9cfd-63bb-c744-97510241eaec", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Sets up various properties and variables required to store and manage documents, including the namespace, getRemote method, meta data, and chunk-related parameters.", + "params": [ + { + "name": "namespace", + "type_name": "string", + "optional": false, + "description": "Required for the construction of the Document Store constructor. It represents the unique name or identifier of the document store, which can be used to differentiate it from other document stores in a given environment.", + "default_value": null + }, + { + "name": "getRemote", + "type_name": "(...args: any[]) => Promise>", + "optional": false, + "description": "Used to retrieve data remotely.", + "default_value": null + }, + { + "name": "additionalMeta", + "type_name": "Record", + "optional": true, + "description": "Used to provide additional metadata for the document, such as version number or creation date.", + "default_value": "{}" + } + ], + "usage": { + "language": "typescript", + "code": "const namespace = \"my-namespace\";\nconst getRemoteMethod = async (...args) => { /* implementation of remote method */ };\nconst additionalMeta = { /* metadata object */ };\n\n// create a new instance of DocumentStore with the provided parameters\nconst documentStore = new DocumentStore(namespace, getRemoteMethod, additionalMeta);\n", + "description": "" + }, + "name": null, + "location": { + "start": 53, + "insert": 41, + "offset": " ", + "indent": 2, + "comment": { + "start": 40, + "end": 52 + } + }, + "item_type": "constructor", + "length": 26, + "docLength": 12 + }, + { + "id": "b532784a-8bc4-34bd-b845-b66a3613aa9e", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Updates the `updated_at` metadata field of an object, by setting it to the provided `Date` value.", + "params": [ + { + "name": "updated_at", + "default_value": null, + "optional": false, + "type_name": "Date", + "description": "Used to update the `updated_at` metadata of an object." + } + ], + "usage": { + "language": "typescript", + "code": "// Initialize DocumentStore with remote function and integration object\nconst documentStore = new DocumentStore(getRemote, integration);\n\n// Set updated at time\ndocumentStore.setUpdatedAt(new Date());\n", + "description": "" + }, + "name": "setUpdatedAt", + "location": { + "start": 87, + "insert": 80, + "offset": " ", + "indent": 2, + "comment": { + "start": 79, + "end": 86 + } + }, + "item_type": "function", + "length": 3, + "docLength": 7 + }, + { + "id": "47940390-1fbd-bea2-6840-795713d648e5", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Retrieves and updates the summary data for the documents stored in the local store, using remote information if available.", + "params": [], + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\ndocumentStore.loadSummary();\n", + "description": "" + }, + "name": "loadSummary", + "location": { + "start": 95, + "insert": 91, + "offset": " ", + "indent": 2, + "comment": { + "start": 90, + "end": 94 + } + }, + "item_type": "function", + "length": 32, + "docLength": 4 + }, + { + "id": "ad84e589-f4d3-dc8d-1945-6a28b1dade93", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a", + "47940390-1fbd-bea2-6840-795713d648e5" + ], + "description": "Updates the `this.meta` object's property values based on \nthe `summary.meta` object and an optional default value.", + "name": null, + "location": { + "start": 121, + "insert": 122, + "offset": " ", + "indent": 6, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 3, + "docLength": null + }, + { + "id": "12f01fee-84ea-94bd-f242-d6aebf66a20f", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Retrieves and loads chunks of data from the storage, based on their indices, and sets the `chunks` property to `true`.", + "params": [], + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\ndocumentStore.load().then(() => {\n // Use the loaded content here\n});\n", + "description": "" + }, + "name": "load", + "location": { + "start": 131, + "insert": 128, + "offset": " ", + "indent": 2, + "comment": { + "start": 127, + "end": 130 + } + }, + "item_type": "function", + "length": 12, + "docLength": 3 + }, + { + "id": "3b5d1e3f-968d-ed95-9447-ca0dd7bd38cc", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Updates the metadata of an object by merging the existing metadata with additional metadata provided as an argument.", + "params": [ + { + "name": "additionalMeta", + "default_value": null, + "optional": false, + "type_name": "Record", + "description": "Used to add or update metadata for the component." + } + ], + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\ndocumentStore.updateMetadata({ version: '1.0', created_at: new Date() });\n", + "description": "" + }, + "name": "updateMetadata", + "location": { + "start": 151, + "insert": 151, + "offset": " ", + "indent": 2, + "comment": null + }, + "item_type": "function", + "length": 6, + "docLength": null + }, + { + "id": "bb016c57-6713-9b8c-7a41-2301a0fc173b", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Loads a chunk of the document from the server and adds it to the document's content and chunks array if successful.", + "params": [ + { + "name": "chunkIndex", + "default_value": null, + "optional": false, + "type_name": "number", + "description": "Used to represent the index of the chunk being loaded, which serves as a reference for checking if the chunk has already been loaded or not." + } + ], + "returns": { + "type_name": "Promise", + "description": "Resolved when the chunk is loaded successfully, and rejected when there is an error." + }, + "usage": { + "language": "typescript", + "code": "const store = new DocumentStore(getRemote);\nconst chunkLoaded = await store.loadChunk(100);\n", + "description": "" + }, + "name": "loadChunk", + "location": { + "start": 175, + "insert": 164, + "offset": " ", + "indent": 2, + "comment": { + "start": 163, + "end": 174 + } + }, + "item_type": "function", + "length": 16, + "docLength": 11 + }, + { + "id": "87a9bdaf-5b4c-3dbd-d24b-004065eab39a", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Retrieves a file from the store based on its path, checking if it is already loaded and returning it if found, or loading it if necessary.", + "params": [ + { + "name": "path", + "default_value": null, + "optional": false, + "type_name": "string", + "description": "Used to represent the file path that needs to be retrieved." + } + ], + "returns": { + "type_name": "Promise", + "description": "A promise that resolves to a StructuredFile object or null if the file is not found in the specified chunk." + }, + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\ndocumentStore.CHUNK_SIZE = 10;\ndocumentStore.namespace = 'example';\nawait documentStore.loadSummary();\nconst structuredFile = await documentStore.getFile('path/to/file');\n", + "description": "" + }, + "name": "getFile", + "location": { + "start": 201, + "insert": 191, + "offset": " ", + "indent": 2, + "comment": { + "start": 190, + "end": 200 + } + }, + "item_type": "function", + "length": 23, + "docLength": 10 + }, + { + "id": "881a598d-88b7-a19d-4242-87421a2ee841", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Updates the lookup subtable based on the provided path. If the last subtable is full, create a new one; otherwise, append the path to the existing subtable.", + "params": [ + { + "name": "path", + "default_value": null, + "optional": false, + "type_name": "string", + "description": "Intended to represent a path to add to the end of the lookup table." + } + ], + "usage": { + "language": "typescript", + "code": "const docStore = new DocumentStore(getRemote, integration);\ndocStore.addToEndOfLookup(\"path\");\n", + "description": "" + }, + "name": "addToEndOfLookup", + "location": { + "start": 247, + "insert": 241, + "offset": " ", + "indent": 2, + "comment": { + "start": 240, + "end": 246 + } + }, + "item_type": "function", + "length": 11, + "docLength": 6 + }, + { + "id": "5a49562b-8589-0c99-944e-e80e82717313", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Adds a new file to the end of an array of chunks if the last one is full or if the current chunk is not full, and pushes it to the appropriate position in the chunk array.", + "params": [ + { + "name": "file", + "default_value": null, + "optional": false, + "type_name": "StructuredFile", + "description": "Passed to add a file to an array of files, called chunks, within a larger data structure." + } + ], + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\n// addToEndOfChunks(file)\ndocumentStore.addToEndOfChunks(structuredFile);\n\n", + "description": "" + }, + "name": "addToEndOfChunks", + "location": { + "start": 268, + "insert": 258, + "offset": " ", + "indent": 2, + "comment": { + "start": 257, + "end": 267 + } + }, + "item_type": "function", + "length": 11, + "docLength": 10 + }, + { + "id": "e9b6e47e-5590-5d85-b745-4c6cceae3657", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Adds a file to the collection of stored files. It first checks if the `status.chunks` property is set and if the input file exists at its path. If so, it updates the file in the collection and returns `true`. Otherwise, it appends the file to the end of the lookup table and chunks list and returns `true`.", + "params": [ + { + "name": "file", + "default_value": null, + "optional": false, + "type_name": "StructuredFile", + "description": "Used to represent a file that is being added to the content library." + } + ], + "returns": { + "type_name": "boolean", + "description": "`true` if the file was successfully added to the content, and `false` otherwise." + }, + "usage": { + "language": "typescript", + "code": "// Create new instance of DocumentStore\nconst documentStore = new DocumentStore(getRemote, integration);\n// Add file to store\ndocumentStore.addFile({\n path: \"path/to/file\",\n content: \"file content\"\n});\n// Update existing file in store\ndocumentStore.updateFile(\"existing-file\", {\n path: \"updated-file-path\",\n content: \"updated-file-content\"\n});\n", + "description": "" + }, + "name": "addFile", + "location": { + "start": 289, + "insert": 279, + "offset": " ", + "indent": 2, + "comment": { + "start": 278, + "end": 288 + } + }, + "item_type": "function", + "length": 20, + "docLength": 10 + }, + { + "id": "2b1d9107-8359-9abb-df42-c6b4e2ebf6ac", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Updates a file in the store by checking if it exists, loading it if necessary, and storing it in the appropriate chunk and index position.", + "params": [ + { + "name": "file", + "default_value": null, + "optional": false, + "type_name": "StructuredFile", + "description": "Used to represent a file that needs to be updated or added to the content library." + } + ], + "returns": { + "type_name": "Promise", + "description": "Whether the file was updated successfully or not." + }, + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\ndocumentStore.updateFile({\n path: \"path/to/file\",\n content: \"New content\"\n});\n", + "description": "" + }, + "name": "updateFile", + "location": { + "start": 319, + "insert": 309, + "offset": " ", + "indent": 2, + "comment": { + "start": 308, + "end": 318 + } + }, + "item_type": "function", + "length": 27, + "docLength": 10 + }, + { + "id": "d42d5f63-ba14-f592-9f49-57a104d8a3a5", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Returns an object containing `meta` and `lookup` properties, which are presumably used to summarize or represent the contents of the document store.", + "params": [], + "returns": { + "type_name": "Summary", + "description": "An object consisting of two properties: `meta` and `lookup`." + }, + "usage": { + "language": "typescript", + "code": "const documentStore = new DocumentStore(getRemote, integration);\ndocumentStore.outputSummary();\n", + "description": "" + }, + "name": "outputSummary", + "location": { + "start": 352, + "insert": 346, + "offset": " ", + "indent": 2, + "comment": { + "start": 345, + "end": 351 + } + }, + "item_type": "function", + "length": 6, + "docLength": 6 + }, + { + "id": "411bd430-23b2-c3b5-1048-a4206864644f", + "ancestors": [ + "b3dde4d0-0c04-e6b8-f94b-b717b02da80a" + ], + "description": "Generates an object with chunk-related metadata and content for each chunk in the document. The method iterates through the document's content, slices it into chunks, and assigns a unique identifier to each chunk.", + "params": [], + "returns": { + "type_name": "Record", + "description": "An object where each key is a chunk path and the corresponding value is the contents of that chunk." + }, + "usage": { + "language": "typescript", + "code": "const docStore = new DocumentStore({getRemote, integration});\nconst outputChunks = docStore.outputChunks();\n// Do something with the chunked content\n", + "description": "\nThe end user can then use the `outputChunks()` method to get the chunks of the content in the document store and process them as needed. The method returns a record that contains an entry for each chunk, where the key is the path of the chunk and the value is the chunk itself." + }, + "name": "outputChunks", + "location": { + "start": 364, + "insert": 358, + "offset": " ", + "indent": 2, + "comment": { + "start": 357, + "end": 363 + } + }, + "item_type": "function", + "length": 9, + "docLength": 6 + } + ] + } + } + }, + { + "name": "index.test.ts", + "path": "tests/index.test.ts", + "content": { + "structured": { + "description": "A `DocumentStore` class that manages a collection of files and their metadata. The class provides methods for loading, adding, updating, and retrieving files from the store. It also includes tests for various use cases, such as creating an empty store, setting the summary file path, loading a summary file, and adding or updating files in the store. The code uses the `StructuredFile` type and the `mockSummary` function to generate mock summaries of files.", + "items": [ + { + "id": "54784b16-dc93-1eaa-c648-e6a9113abc03", + "ancestors": [], + "description": "Resolves a promise containing metadata and lookup information for a mock API endpoint. The metadata includes creation and update timestamps, while the lookup array contains paths to two files in the `src/` directory: `index.js`, `database.js`, and `component/index.js`.", + "params": [], + "returns": { + "type_name": "Object", + "description": "A meta object containing creation and update timestamps and a list of pipelines, as well as a lookup array with paths to two files and one directory in the src directory." + }, + "usage": { + "language": "typescript", + "code": "const mockSummary = () => {\n return Promise.resolve({\n meta: {\n created_at: \"2024-04-08T13:50:02.790Z\",\n updated_at: \"2024-04-08T13:50:02.790Z\",\n pipelines: [\"cd1d3bab-03db-494c-9e03-16ee456964fb\"],\n },\n lookup: [[\"src/index.js\", \"src/database.js\"], [\"src/component/index.js\"]],\n });\n };\n", + "description": "" + }, + "name": "mockSummary", + "location": { + "start": 6, + "insert": 6, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "function", + "length": 9, + "docLength": null + }, + { + "id": "d2c09581-f2ac-5d81-1943-78c80aecfaf5", + "ancestors": [], + "description": "Takes a chunk path as input and returns a resolved promise of either the mock summary or a file from the chunks array depending on the chunk path provided.", + "params": [ + { + "name": "chunkPath", + "default_value": null, + "optional": false, + "type_name": "string", + "description": "Used to determine which mock file to return based on its path relative to the namespace prefix." + } + ], + "returns": { + "type_name": "Promise", + "description": "Resolved with either a mock summary or one of the chunks." + }, + "usage": { + "language": "typescript", + "code": "const chunkPath = `.${NAMESPACE}/00001.json`;\ngetFileMock(chunkPath).then((data) => {\n // data will contain the contents of the file located at chunkPath\n});\n", + "description": "" + }, + "name": "getFileMock", + "location": { + "start": 16, + "insert": 16, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "function", + "length": 12, + "docLength": null + }, + { + "id": "42ef8453-2d77-95a8-554a-205aaf438ac1", + "ancestors": [], + "description": "Returns an array of objects, each representing a file or directory within a project. The objects contain information about the file's name, path, and content, including a description.", + "params": [], + "returns": { + "type_name": "Object", + "description": "An array of objects representing files and their contents. Each object in the array has three properties: name, path, and content, where content is a JSON object containing a string value representing the file's contents." + }, + "usage": { + "language": "typescript", + "code": "const chunks = () => ({\n \"00000\": [\n {\n name: \"mock-1\",\n path: \"src/index.js\",\n content: {\n description: \"duck\",\n },\n },\n {\n name: \"mock-2\",\n path: \"src/database.js\",\n content: {\n description: \"duckDB\",\n },\n },\n ],\n \"00001\": [\n {\n name: \"mock-3\",\n path: \"src/component/index.js\",\n content: {\n description: \"Component Duck\",\n },\n },\n ],\n});\n", + "description": "" + }, + "name": "chunks", + "location": { + "start": 29, + "insert": 29, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "function", + "length": 27, + "docLength": null + }, + { + "id": "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae", + "ancestors": [], + "description": "Tests various features of a DocumentStore.", + "name": null, + "location": { + "start": 72, + "insert": 73, + "offset": " ", + "indent": 2, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 127, + "docLength": null + }, + { + "id": "e39cefa6-6f3c-11b0-a543-efb3ad18b4be", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "Creates an instance of `DocumentStore` and calls its `outputSummary()` method, which returns a summary of the document store's contents.", + "name": null, + "location": { + "start": 73, + "insert": 74, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 7, + "docLength": null + }, + { + "id": "5d73bcf9-32c3-e396-aa42-d33f685393c0", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "Creates a new instance of `DocumentStore`, passing the namespace as an argument, and resolves a promise to obtain the chunk summary path based on the namespace.", + "name": null, + "location": { + "start": 80, + "insert": 81, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 7, + "docLength": null + }, + { + "id": "5189ae6a-225a-cc8e-c848-8ee549f24403", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "Loads a summary file and returns a summary object containing two items in its `lookup` property.", + "name": null, + "location": { + "start": 87, + "insert": 88, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 9, + "docLength": null + }, + { + "id": "eb9de803-c44e-7086-3645-bb43e4ad1879", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "1) creates a new instance of `DocumentStore`, 2) sets its chunk size to 2, and 3) loads all chunks using the `load()` method, after which it verifies that both the summary and output chunks contain two elements each.", + "name": null, + "location": { + "start": 96, + "insert": 97, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 17, + "docLength": null + }, + { + "id": "34a3eb46-440e-0b81-494c-98661494aa51", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "1) creates a new instance of `DocumentStore`, 2) sets the chunk size to 2, and 3) retrieves the file at the specified path (\"src/database.js\") using the `getFile()` method.", + "name": null, + "location": { + "start": 113, + "insert": 114, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 12, + "docLength": null + }, + { + "id": "dbc7e254-f2d7-9fb6-074a-20cd2a79b475", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "* Creates a new instance of `DocumentStore` with a mock `getFile` method.\n* Calls the `getFile` method on the `DocumentStore` instance with the file path \"src/index.js\".\n* Expects an error to be thrown due to the absence of the `load` method call before accessing the file.", + "name": null, + "location": { + "start": 125, + "insert": 126, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 9, + "docLength": null + }, + { + "id": "a7776b74-8dea-0d9e-d04a-c5b55b6c07d9", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "Adds a new file to a store and retrieves it back for verification.", + "name": null, + "location": { + "start": 134, + "insert": 135, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 14, + "docLength": null + }, + { + "id": "7a4f7b46-c275-bc9c-0443-1eba61261138", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "1) creates a new `DocumentStore` instance, 2) sets its `CHUNK_SIZE` to a specific value, and 3) updates an existing file using the `updateFile()` method, followed by retrieving the file using the `getFile()` method and verifying its path.", + "name": null, + "location": { + "start": 148, + "insert": 149, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 14, + "docLength": null + }, + { + "id": "b7d35d2d-cc97-1da7-314c-29d5ed647f1f", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "1) creates a new instance of `DocumentStore`, 2) sets properties on that instance, and 3) updates an existing file in the store by providing the same path but different content description.", + "name": null, + "location": { + "start": 162, + "insert": 163, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 18, + "docLength": null + }, + { + "id": "6b9dcf34-3a0d-5681-4948-1f6642e76ff8", + "ancestors": [ + "16a9564b-c1ba-8f9a-ae4b-ecfee46661ae" + ], + "description": "Updates an existing file in a document store by adding new content and verifying if the updated file's description matches the expected value.", + "name": null, + "location": { + "start": 180, + "insert": 181, + "offset": " ", + "indent": 4, + "comment": null + }, + "item_type": "higher_order_invocation", + "length": 18, + "docLength": null + } + ] + } + } + }, + { + "name": "IDocumentStore.d.ts", + "path": "types/IDocumentStore.d.ts", + "content": { + "structured": { + "description": "An interface for a document store that includes several properties and methods: `CHUNK_SIZE`, `namespace`, `meta`, `lookup`, and `status`. The `CHUNK_SIZE` property sets the size of chunks used for storing documents, while the `namespace` property specifies the namespace for the document store. The `meta` property provides metadata for the document store, and the `lookup` property is an array of strings representing the paths to chunks containing documents. The `status` property contains two properties: `summary`, which indicates whether the document store has a summary available, and `chunks`, which indicates whether the document store has any chunks available.", + "items": [ + { + "id": "780ab884-af40-379b-1348-8337e3c66a94", + "ancestors": [], + "description": "Defines a set of properties and methods for storing and managing documents. It includes the document chunk size, namespace, metadata, and a lookup array. Additionally, it provides a status object with summary and chunks properties.", + "name": "IDocumentStore", + "location": { + "start": 3, + "insert": 3, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "interface", + "length": 10, + "docLength": null + } + ] + } + } + }, + { + "name": "Meta.d.ts", + "path": "types/Meta.d.ts", + "content": { + "structured": { + "description": "An interface called `Meta` that represents a metadata object. The interface has four properties: `version`, `created_at`, `updated_at`, and `[key: string]: any`. The `version` property is a string, while the `created_at` and `updated_at` properties are Date objects. The `any` key allows for any type of value to be stored in the object.", + "items": [ + { + "id": "1bc0b5a2-46e3-a68a-c040-e9d6b6976640", + "ancestors": [], + "description": "Defines an object with four properties: `version`, `createdAt`, `updatedAt`, and `[key: string]`. The `version` property is of type `string`, while the `createdAt` and `updatedAt` properties are of type `Date`. The `[key: string]` property is akin to an empty array, allowing any type of value to be stored within it.", + "name": "Meta", + "location": { + "start": 1, + "insert": 1, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "interface", + "length": 6, + "docLength": null + } + ] + } + } + }, + { + "name": "StructuredFile.d.ts", + "path": "types/StructuredFile.d.ts", + "content": { + "structured": { + "description": "An interface named StructuredFile that consists of three properties: name, path, and content. The interface represents a file with structured data, allowing for easy manipulation and storage. The content property can hold any type of data, and the other two properties provide information about the file's identity and location.", + "items": [ + { + "id": "2801a404-7bff-0c82-9643-0b8059ca5fcc", + "ancestors": [], + "description": "Defines a set of properties for a file, including its name, path, and contents.", + "name": "StructuredFile", + "location": { + "start": 1, + "insert": 1, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "interface", + "length": 5, + "docLength": null + } + ] + } + } + }, + { + "name": "Summary.d.ts", + "path": "types/Summary.d.ts", + "content": { + "structured": { + "description": "An interface Summary, which consists of three properties: meta, lookup, and chunks. The meta property is of type Meta, while the lookup property is an array of strings, representing a two-dimensional matrix. The chunks property is optional and represents a list of strings, likely used for chunking the input data.", + "items": [ + { + "id": "026a21ea-5807-858f-2b43-e6bd784ef8dc", + "ancestors": [], + "description": "Defines a set of properties: `meta`, `lookup`, and `chunks`. The `meta` property is an object with additional information about the summary, while the `lookup` property is an array of arrays representing the lookup tables for each chunk. The `chunks` property can optionally be defined as an array of strings, representing the chunks of data in the summary.", + "name": "Summary", + "location": { + "start": 3, + "insert": 3, + "offset": " ", + "indent": 0, + "comment": null + }, + "item_type": "interface", + "length": 5, + "docLength": null + } + ] + } + } + }, + { + "name": "jest.config.js", + "path": "jest.config.js", + "content": { + "structured": { + "description": "configuration options for Jest, a popular JavaScript testing framework. The `preset` option sets the Jest preset to use, in this case \"ts-jest\". The `testEnvironment` option specifies that Jest should run tests in a Node environment. Finally, the `testMatch` option specifies which files should be searched for test files, using glob syntax to match files with extensions \".test.ts\".", + "items": [] + } + } + } +] \ No newline at end of file diff --git a/.komment/komment.json b/.komment/komment.json new file mode 100644 index 0000000..7d35b3a --- /dev/null +++ b/.komment/komment.json @@ -0,0 +1,43 @@ +{ + "meta": { + "version": "1", + "updated_at": "2024-07-18T13:08:15.703Z", + "created_at": "2024-07-10T16:34:39.374Z", + "pipelines": [ + "c089e2e8-dd67-4bff-afef-c8f0f6b8a931", + "83f3455e-fd11-4539-9bc0-da663fa2c85d", + "18b02909-d08f-4b13-9964-3b4ee9ccbda8", + "7c8b9933-05d6-4176-b7aa-418bf1abbade", + "4857c9e7-9349-41a8-96c5-56be5ffb04cf", + "75505a3a-f1af-4ca1-9174-9b908cdee0e4", + "db654c98-5128-44f7-8691-252c69b9b5b7", + "fb518d01-fd0a-40bb-8d37-2ff5990c023b", + "49ec0772-f24b-4603-9a27-a31b96963bdf", + "e7cb8cbb-d12f-4f42-adcc-cdf3756c8071", + "ce9a50b9-f4ec-4487-80f0-aff229eec487", + "1f76280f-f42b-4585-ad9d-7178240fd285", + "ef450461-80fd-45dd-81f4-48c5335ad528", + "dbb10926-033f-4543-b4cc-bee6999543f8", + "521fe478-f3d3-4440-81b8-31b85cb89a46", + "bd56018a-a4ab-43de-aa64-a02ed61b32be", + "344dea1f-37c5-4706-b964-90ffeed56096", + "c355b024-a5e5-4eea-b745-fd2482d6e5c6", + "532c71df-781e-414b-98ad-8f67da7424a6", + "5c864a2d-0ee3-4c2e-8392-299b19565254", + "e47a1503-66d2-402a-a043-4b6b405c390f", + "8644b83e-a319-4f94-b5f8-b999ebf633bc", + "62f2bdd7-6e44-42b4-b522-4dce3d99e5aa" + ] + }, + "lookup": [ + [ + "src/index.ts", + "tests/index.test.ts", + "types/IDocumentStore.d.ts", + "types/Meta.d.ts", + "types/StructuredFile.d.ts", + "types/Summary.d.ts", + "jest.config.js" + ] + ] +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 4bb8303..b9f2b7a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,13 @@ import { Summary } from "../types/Summary"; const CHUNK_SIZE = 40; const DOCUMENT_STORE_VERSION = "1"; +/** + * @description Manages and organizes structured files, providing an interface to + * load, update, and retrieve files from a remote store, while also maintaining + * metadata and summaries for efficient storage and retrieval. + * + * @implements {IDocumentStore} + */ class DocumentStore implements IDocumentStore { CHUNK_SIZE: number; namespace: string; @@ -39,16 +46,17 @@ class DocumentStore implements IDocumentStore { }; /** - * @description Sets up an instance of a DocumentStore class with various parameters - * such as getRemote and metadata. It also initializes - * internal arrays and objects to store chunk data, content, and other meta information. + * @description Initializes an object with several properties, including namespace, + * remote data fetching function, and metadata. It also sets default values for chunk + * size, timestamps, and lookup table. The object is initialized with default metadata + * and status flags. * - * @param { (...args: any[]) => Promise> } getRemote - 3rd party library or service that provides the functionality - * for generating high-quality documentation. + * @param {string} namespace - Required. * - * @param { Integration } integration - Integration object that provides information - * about the integration of the code documentation with other systems or services. + * @param {(...args: any[]) => Promise>} getRemote - Responsible for + * fetching data remotely. * + * @param {Record} additionalMeta - Used to store custom metadata. */ constructor( namespace: string, @@ -78,19 +86,20 @@ class DocumentStore implements IDocumentStore { } /** - * @description Updates the `updated_at` field of an instance of the `Meta` class - * with the provided `updated_at` value. + * @description Updates the `updated_at` property within its `meta` object with a + * specified date. The method takes one argument, `updated_at`, which is expected to + * be an instance of Date. * - * @param { Date } updated_at - date and time when the document was last updated, - * which is then assigned to the `meta.updated_at` property of the document. + * @param {Date} updated_at - Intended to update a timestamp value. */ setUpdatedAt = (updated_at: Date) => { this.meta.updated_at = updated_at; }; /** - * @description Retrieves document summaries from a provider and updates local meta - * data based on the remote summary. + * @description Loads or updates a summary object from remote storage and merges it + * with local metadata. If no remote data exists, it creates a new default summary + * and populates the local metadata accordingly. */ loadSummary = async () => { let summary: Summary = { @@ -119,6 +128,7 @@ class DocumentStore implements IDocumentStore { this.meta.created_at = summary?.meta?.created_at || new Date(); this.meta.updated_at = summary?.meta?.updated_at || new Date(); Object.entries(this.metaTemplate).forEach(([key, value]) => { + // Updates meta values. this.meta[key] = summary?.meta?.[key] ?? value; }); this.lookup = summary.lookup || []; @@ -126,7 +136,8 @@ class DocumentStore implements IDocumentStore { }; /** - * Loads all files from the remote store + * @description Asynchronously loads document chunks into memory after verifying that + * the summary has been loaded, then sets the `chunks` status to true. */ load = async () => { if (!this.status.summary) { @@ -148,6 +159,13 @@ class DocumentStore implements IDocumentStore { getChunkSummaryPath = (): string => `.${this.namespace}/${this.namespace}.json`; + /** + * @description Merges additional metadata into the existing metadata, replacing any + * duplicate keys with the new values. The existing metadata is updated with the + * merged properties from the provided `additionalMeta` object. + * + * @param {Record} additionalMeta - Used to update metadata with new values. + */ updateMetadata = (additionalMeta: Record) => { this.meta = { ...this.meta, @@ -162,15 +180,14 @@ class DocumentStore implements IDocumentStore { this.chunks[chunkIndex]?.length > 0; /** - * @description Loads a chunk from a provider based on its key, concats it to the - * content, and stores it in the chunks array if successful. + * @description Asynchronously loads a chunk of structured data from a remote source + * and updates the local store's content and chunks cache if it has not already been + * loaded. * - * @param { number } chunkIndex - 0-based index of a particular chunk within the - * overall sequence of chunks being loaded, and is used to identify the specific chunk - * to be loaded or loaded previously. + * @param {number} chunkIndex - Used to identify a specific chunk of data. * - * @returns { Promise } a boolean value indicating whether the chunk was successfully - * loaded. + * @returns {Promise} A boolean indicating whether the chunk was loaded + * successfully or not. */ loadChunk = async (chunkIndex: number): Promise => { if (!this.isChunkLoaded(chunkIndex)) { @@ -189,14 +206,14 @@ class DocumentStore implements IDocumentStore { return true; }; /** - * @description Checks if a file is loaded, loads it if not, and returns the file's - * contents if found in the specified chunk. + * @description Retrieves a file from a structured storage system based on its path, + * returning it as a promise that resolves to either a `StructuredFile` object or + * null if the file is not found. * - * @param { string } path - file path to be looked up in the chunk, and it is used - * to determine the chunk index and file index within that chunk. + * @param {string} path - Intended to identify the file to retrieve. * - * @returns { object } a file object containing the path, name, and other properties - * of the requested file. + * @returns {Promise} A promise that resolves to either a + * StructuredFile object or null if the file is not found. */ getFile = async (path: string): Promise => { if (!this.status.summary) @@ -239,10 +256,11 @@ class DocumentStore implements IDocumentStore { this.lookup.findIndex((sub) => sub.includes(this.getFileHash(path))) > -1; /** - * @description Updates a subtable containing paths based on a new input path, adding - * it to either the end or within an existing subtable if necessary. + * @description Adds paths to its internal lookup table. If the last subtable is full, + * it creates a new one; otherwise, it appends the path to the existing subtable. + * This maintains an efficient data structure for subsequent operations. * - * @param { string } path - path of a file to be looked up in the code's lookup table. + * @param {string} path - Used to add to the lookup table. */ addToEndOfLookup = (path: string) => { // If the last lookup subtable is full, create a new one @@ -256,14 +274,11 @@ class DocumentStore implements IDocumentStore { } }; /** - * @description Manages the structure file's chunks, ensuring that each chunk contains - * only files of a certain size. If the last chunk is full or if the file to be added - * is too large for the remaining space in the previous chunk, a new chunk is created - * and the file is added to it. Otherwise, the file is added to the end of the previous - * chunk. + * @description Appends a file to the end of an existing chunk or creates a new chunk + * if the last one is full, thereby managing a collection of structured files divided + * into chunks of a fixed size (`this.CHUNK_SIZE`). * - * @param { StructuredFile } file - input file for which a chunk is being created or - * appended to an existing chunk. + * @param {StructuredFile} file - A file to be added. */ addToEndOfChunks = (file: StructuredFile) => { // If the last lookup subtable is full, create a new one @@ -277,14 +292,13 @@ class DocumentStore implements IDocumentStore { } }; /** - * @description Adds a file to the end of the lookup and chunks arrays, updating the - * file if it already exists, and pushing it to the content array. + * @description Adds a file to its content and updates its lookup and chunk data + * structures accordingly. If the file already exists, it attempts to update it; + * otherwise, it appends the file to the end of the data structures. * - * @param { StructuredFile } file - file to be added to the structured file, which - * includes its path. + * @param {StructuredFile} file - Required to add files. * - * @returns { boolean } a list of file objects that have been successfully added to - * the content and chunks arrays. + * @returns {boolean} True if a file was successfully added and false otherwise. */ addFile = (file: StructuredFile): boolean => { if (!this.status.chunks) throw Error("Must call .load before adding files"); @@ -307,14 +321,15 @@ class DocumentStore implements IDocumentStore { return true; }; /** - * @description Updates a file in a chunk by checking if it exists, loading it if - * necessary, and storing it in the appropriate index in the chunk. + * @description Updates a file's contents within a chunked storage system. If the + * file does not exist, it adds the file; otherwise, it updates the file's index and + * content, ensuring that the requested chunk is loaded if necessary. * - * @param { any } file - file to be added or updated in the chunks array, and its - * path is checked for existence before loading the chunk if it hasn't been loaded yet. + * @param {StructuredFile} file - Mandatory. * - * @returns { Promise } a reference to the updated file in the chunk, or `null` if the - * file does not exist. + * @returns {Promise} A promise that resolves to either true or false. True + * indicates successful file update and false indicates an error occurred during + * updating the file. */ updateFile = async (file: StructuredFile): Promise => { if (!this.status.chunks) @@ -344,10 +359,12 @@ class DocumentStore implements IDocumentStore { return true; }; /** - * @description Generates high-quality documentation for code by returning an object - * containing the `meta` and `lookup` properties. + * @description Returns an object containing summary data, specifically meta and + * lookup information from the class instance's properties. This allows for concise + * representation of key details. * - * @returns { summary } an object containing `meta` and `lookup` properties. + * @returns {Summary} An object with two properties: meta and lookup. Both properties + * are references to existing objects, specifically this.meta and this.lookup. */ outputSummary(): Summary { return { @@ -356,10 +373,13 @@ class DocumentStore implements IDocumentStore { }; } /** - * @description Generates a record of chunks of code based on the given content, using - * a specified chunk size and keying system. + * @description Splits a large content into smaller, fixed-size chunks and returns + * them as an object with chunk keys as properties and their corresponding values as + * contents. The chunk size is determined by the `CHUNK_SIZE` property of the class. * - * @returns { Record } a record of chunks extracted from the given content. + * @returns {Record} An object with key-value pairs where each key is a + * string and each value can be of any data type. The object represents a mapping + * between chunk keys and their corresponding content chunks. */ outputChunks(): Record { const outputs: Record = {}; diff --git a/tests/index.test.ts b/tests/index.test.ts index 9c9dfe9..3fc87cb 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -3,6 +3,16 @@ import DocumentStore from "../src/"; const NAMESPACE = "duck"; +/** + * @description Resolves a promise containing metadata and lookup information for a + * mock API endpoint. The metadata includes creation and update timestamps, while the + * lookup array contains paths to two files in the `src/` directory: `index.js`, + * `database.js`, and `component/index.js`. + * + * @returns {Object} A meta object containing creation and update timestamps and a + * list of pipelines, as well as a lookup array with paths to two files and one + * directory in the src directory. + */ const mockSummary = () => Promise.resolve({ meta: { @@ -13,6 +23,15 @@ const mockSummary = () => lookup: [["src/index.js", "src/database.js"], ["src/component/index.js"]], }); +/** + * @description Takes a chunk path as input and returns a resolved promise of either + * the mock summary or a file from the chunks array depending on the chunk path provided. + * + * @param {string} chunkPath - Used to determine which mock file to return based on + * its path relative to the namespace prefix. + * + * @returns {Promise} Resolved with either a mock summary or one of the chunks. + */ const getFileMock = (chunkPath: string) => { switch (chunkPath) { case `.${NAMESPACE}/${NAMESPACE}.json`: @@ -26,6 +45,15 @@ const getFileMock = (chunkPath: string) => { } }; +/** + * @description Returns an array of objects, each representing a file or directory + * within a project. The objects contain information about the file's name, path, and + * content, including a description. + * + * @returns {Object} An array of objects representing files and their contents. Each + * object in the array has three properties: name, path, and content, where content + * is a JSON object containing a string value representing the file's contents. + */ const chunks = () => ({ "00000": [ { @@ -70,7 +98,12 @@ const fileToUpdate: StructuredFile = { }; describe("DocumentStore", () => { + // Tests various features of a DocumentStore. + test("creates an empty DocumentStore", () => { + // Creates an instance of `DocumentStore` and calls its `outputSummary()` method, + // which returns a summary of the document store's contents. + const newDocumentStore = new DocumentStore(NAMESPACE, () => Promise.resolve({}), ); @@ -78,6 +111,9 @@ describe("DocumentStore", () => { expect(summary.lookup.length).toBe(0); }); test("sets the summary file path based on namespace", () => { + // Creates a new instance of `DocumentStore`, passing the namespace as an argument, + // and resolves a promise to obtain the chunk summary path based on the namespace. + const newDocumentStore = new DocumentStore(NAMESPACE, () => Promise.resolve({}), ); @@ -85,6 +121,9 @@ describe("DocumentStore", () => { expect(summaryPath).toBe(".duck/duck.json"); }); test("loads a summary file", async () => { + // Loads a summary file and returns a summary object containing two items in its + // `lookup` property. + const newDocumentStore = new DocumentStore(NAMESPACE, mockSummary, { pipelines: [], }); @@ -94,6 +133,10 @@ describe("DocumentStore", () => { expect(summary.lookup.length).toBe(2); }); test("loads all chunks", async () => { + // 1) creates a new instance of `DocumentStore`, 2) sets its chunk size to 2, and 3) + // loads all chunks using the `load()` method, after which it verifies that both the + // summary and output chunks contain two elements each. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); @@ -111,6 +154,10 @@ describe("DocumentStore", () => { expect(Object.keys(outputChunks).length).toBe(2); }); test("get file content by path", async () => { + // 1) creates a new instance of `DocumentStore`, 2) sets the chunk size to 2, and 3) + // retrieves the file at the specified path ("src/database.js") using the `getFile()` + // method. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); @@ -123,6 +170,11 @@ describe("DocumentStore", () => { expect(retrievedFile?.path).toBe(fileToGet); }); test("error is thrown if load isn't called before file access", async () => { + // * Creates a new instance of `DocumentStore` with a mock `getFile` method. + // * Calls the `getFile` method on the `DocumentStore` instance with the file path "src/index.js". + // * Expects an error to be thrown due to the absence of the `load` method call before + // accessing the file. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); @@ -132,6 +184,8 @@ describe("DocumentStore", () => { ).rejects.toThrow(Error); }); test("add a new file to the store", async () => { + // Adds a new file to a store and retrieves it back for verification. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); @@ -146,6 +200,10 @@ describe("DocumentStore", () => { expect(retrievedFile?.path).toBe(fileToGet); }); test("updating a non-existent file adds it to the store", async () => { + // 1) creates a new `DocumentStore` instance, 2) sets its `CHUNK_SIZE` to a specific + // value, and 3) updates an existing file using the `updateFile()` method, followed + // by retrieving the file using the `getFile()` method and verifying its path. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); @@ -160,6 +218,10 @@ describe("DocumentStore", () => { expect(retrievedFile?.path).toBe(fileToGet); }); test("update an existing file in the store", async () => { + // 1) creates a new instance of `DocumentStore`, 2) sets properties on that instance, + // and 3) updates an existing file in the store by providing the same path but different + // content description. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); @@ -178,6 +240,9 @@ describe("DocumentStore", () => { ); }); test("adding an existing file updates it in the store", async () => { + // Updates an existing file in a document store by adding new content and verifying + // if the updated file's description matches the expected value. + const newDocumentStore = new DocumentStore(NAMESPACE, getFileMock, { pipelines: [], }); diff --git a/types/IDocumentStore.d.ts b/types/IDocumentStore.d.ts index f5632e3..9de1139 100644 --- a/types/IDocumentStore.d.ts +++ b/types/IDocumentStore.d.ts @@ -1,5 +1,10 @@ import { Meta } from "./Meta"; +/** + * @description Defines a set of properties and methods for storing and managing + * documents. It includes the document chunk size, namespace, metadata, and a lookup + * array. Additionally, it provides a status object with summary and chunks properties. + */ export interface IDocumentStore { CHUNK_SIZE: number; namespace: string; diff --git a/types/Meta.d.ts b/types/Meta.d.ts index c935e20..61488b3 100644 --- a/types/Meta.d.ts +++ b/types/Meta.d.ts @@ -1,3 +1,10 @@ +/** + * @description Defines an object with four properties: `version`, `createdAt`, + * `updatedAt`, and `[key: string]`. The `version` property is of type `string`, while + * the `createdAt` and `updatedAt` properties are of type `Date`. The `[key: string]` + * property is akin to an empty array, allowing any type of value to be stored within + * it. + */ export interface Meta { version: string; created_at: Date; diff --git a/types/StructuredFile.d.ts b/types/StructuredFile.d.ts index 488eafb..6746bd8 100644 --- a/types/StructuredFile.d.ts +++ b/types/StructuredFile.d.ts @@ -1,3 +1,7 @@ +/** + * @description Defines a set of properties for a file, including its name, path, and + * contents. + */ export interface StructuredFile { name: string; path: string; diff --git a/types/Summary.d.ts b/types/Summary.d.ts index 63bb58c..8b74e32 100644 --- a/types/Summary.d.ts +++ b/types/Summary.d.ts @@ -1,5 +1,12 @@ import { Meta } from './Meta'; +/** + * @description Defines a set of properties: `meta`, `lookup`, and `chunks`. The + * `meta` property is an object with additional information about the summary, while + * the `lookup` property is an array of arrays representing the lookup tables for + * each chunk. The `chunks` property can optionally be defined as an array of strings, + * representing the chunks of data in the summary. + */ export interface Summary { meta: Meta; lookup: string[][];