-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from upperdo/develop
feat: added DebugBar and Services Models
- Loading branch information
Showing
28 changed files
with
715 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
PUBLIC_APPWRITE_ENDPOINT="http://localhost/" | ||
PUBLIC_APPWRITE_API_VERSION="v1" | ||
PUBLIC_APPWRITE_PROJECT_ID="your-project-id" | ||
PUBLIC_SELECTED_PLATFORM="appwrite" | ||
PUBLIC_SELECTED_PLATFORM="appwrite" | ||
PUBLIC_DEBUG= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Handle } from "@sveltejs/kit"; | ||
import type { DebugStoreData } from "$lib/ui/widgets/debug-bar/types"; | ||
import { getMemoryUsageInMB } from "$lib/ui/widgets/debug-bar/utils/getMemoryUsageInMb"; | ||
|
||
export const handle: Handle = async ({ event, resolve }) => { | ||
|
||
const memoryUsage = getMemoryUsageInMB(); | ||
|
||
return resolve(event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Base class for document models. | ||
*/ | ||
class BaseDocumentModel { | ||
/** | ||
* The unique identifier for the document. | ||
*/ | ||
$id!: string; | ||
|
||
/** | ||
* The collection to which the document belongs. | ||
*/ | ||
$collectionId!: string; | ||
|
||
/** | ||
* The database to which the document belongs. | ||
*/ | ||
$databaseId!: string; | ||
|
||
/** | ||
* The creation date and time of the document. | ||
*/ | ||
$createdAt!: string; | ||
|
||
/** | ||
* The last update date and time of the document. | ||
*/ | ||
$updatedAt!: string; | ||
|
||
/** | ||
* Document permissions lists. | ||
*/ | ||
$permissions!: string[]; | ||
|
||
/** | ||
* Create a new BaseDocumentModel instance. | ||
* @param data - Partial data for initializing the document model. | ||
*/ | ||
constructor(data: Partial<BaseDocumentModel>) { | ||
Object.assign(this, data); | ||
} | ||
} | ||
|
||
/** | ||
* Class for document models with additional properties. | ||
* @template T - The type for additional properties. | ||
*/ | ||
class DocumentModel<T> extends BaseDocumentModel { | ||
|
||
/** | ||
* Create a new DocumentModel instance. | ||
* @param data - Data for initializing the document model, including additional properties. | ||
*/ | ||
constructor(data: T & Partial<BaseDocumentModel>) { | ||
super(data); | ||
Object.assign(this, data); | ||
//this.atrribures = data; | ||
} | ||
} | ||
|
||
/** | ||
* Convert the DocumentModel to a plain object without the DocumentModel wrapper. | ||
* @returns {object} - The plain object with document properties. | ||
*/ | ||
function toPlainObject<T>(documentModel: DocumentModel<T>): Omit<DocumentModel<T>, 'toPlainObject'> { | ||
const { ...rest } = documentModel; | ||
return rest; | ||
} | ||
|
||
/** | ||
* Create a new document model. | ||
* @template T - The type for additional properties. | ||
* @param data - Data for initializing the document model, including additional properties. | ||
* @returns A DocumentModel Object. | ||
*/ | ||
function createDocumentModel<T extends Partial<BaseDocumentModel>>(data: T) { | ||
const documentModel = new DocumentModel<T>(data); | ||
|
||
return toPlainObject(documentModel); | ||
} | ||
|
||
|
||
|
||
export { DocumentModel, createDocumentModel, toPlainObject }; |
Oops, something went wrong.