@alwatr/nitrobase-reference
Version:
Nitrobase is a blazingly fast, lightweight database built on JSON. It stores data entirely in memory for lightning-quick access, while also providing a JSON file backup for persistence. You can easily serve your data over the web using our high-performanc
8 lines (7 loc) • 46.6 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../src/collection-reference.ts", "../src/logger.ts", "../src/document-reference.ts"],
"sourcesContent": ["import {createLogger, delay} from '@alwatr/nanolib';\nimport {getStoreId, getStorePath} from '@alwatr/nitrobase-helper';\nimport {\n StoreFileType,\n StoreFileExtension,\n type StoreFileId,\n type CollectionContext,\n type CollectionItem,\n type CollectionItemMeta,\n type StoreFileMeta,\n} from '@alwatr/nitrobase-types';\n\nimport {logger} from './logger.js';\n\n__dev_mode__: logger.logFileModule?.('collection-reference');\n\n/**\n * Represents a reference to a collection of the AlwatrNitrobase.\n * Provides methods to interact with the collection, such as retrieving, creating, updating, and deleting items.\n *\n * @template TItem - The data type of the collection items.\n */\nexport class CollectionReference<TItem extends JsonObject = JsonObject> {\n /**\n * Alwatr nitrobase engine version string.\n */\n static readonly version = __package_version__;\n\n /**\n * Alwatr nitrobase engine file format version number.\n */\n static readonly fileFormatVersion = 3;\n\n /**\n * Creates new CollectionReference instance from stat.\n *\n * @param stat the collection stat.\n * @param initialData the collection data.\n * @param updatedCallback the callback to invoke when the collection changed.\n * @template TItem The collection item data type.\n * @returns A new collection reference class.\n */\n static newRefFromData<TItem extends JsonObject>(\n stat: StoreFileId,\n updatedCallback: (from: CollectionReference<TItem>) => void,\n debugDomain?: string,\n ): CollectionReference<TItem> {\n logger.logMethodArgs?.('col.newRefFromData', stat);\n\n const now = Date.now();\n const initialContext: CollectionContext<TItem> = {\n ok: true,\n meta: {\n ...stat,\n rev: 1,\n updated: now,\n created: now,\n lastAutoId: 0,\n type: StoreFileType.Collection,\n extension: StoreFileExtension.Json,\n fv: CollectionReference.fileFormatVersion,\n extra: {},\n },\n data: {},\n };\n\n return new CollectionReference(initialContext, updatedCallback, debugDomain);\n }\n\n /**\n * Creates new CollectionReference instance from CollectionContext.\n *\n * @param context the collection context.\n * @param updatedCallback the callback to invoke when the collection changed.\n * @template TItem The collection item data type.\n * @returns A new collection reference class.\n */\n static newRefFromContext<TItem extends JsonObject>(\n context: CollectionContext<TItem>,\n updatedCallback: (from: CollectionReference<TItem>) => void,\n debugDomain?: string,\n ): CollectionReference<TItem> {\n logger.logMethodArgs?.('col.newRefFromContext', context.meta);\n return new CollectionReference(context, updatedCallback, debugDomain);\n }\n\n /**\n * Validates the collection context and try to migrate it to the latest version.\n */\n private validateContext__(): void {\n this.logger__.logMethod?.('validateContext__');\n\n if (this.context__.ok !== true) {\n this.logger__.accident?.('validateContext__', 'store_not_ok');\n throw new Error('store_not_ok', {cause: {context: this.context__}});\n }\n\n if (this.context__.meta === undefined) {\n this.logger__.accident?.('validateContext__', 'store_meta_undefined');\n throw new Error('store_meta_undefined', {cause: {context: this.context__}});\n }\n\n if (this.context__.meta.type !== StoreFileType.Collection) {\n this.logger__.accident?.('validateContext__', 'collection_type_invalid', this.context__.meta);\n throw new Error('collection_type_invalid', {cause: this.context__.meta});\n }\n\n if (this.context__.meta.fv !== CollectionReference.fileFormatVersion) {\n this.logger__.incident?.('validateContext__', 'store_file_version_incompatible', {\n old: this.context__.meta.fv,\n new: CollectionReference.fileFormatVersion,\n });\n this.migrateContext__();\n }\n }\n\n /**\n * Migrate the collection context to the latest.\n */\n private migrateContext__(): void {\n if (this.context__.meta.fv === CollectionReference.fileFormatVersion) return;\n\n this.logger__.logMethod?.('migrateContext__');\n\n if (this.context__.meta.fv > CollectionReference.fileFormatVersion) {\n this.logger__.accident('migrateContext__', 'store_version_incompatible', this.context__.meta);\n throw new Error('store_version_incompatible', {cause: this.context__.meta});\n }\n\n if (this.context__.meta.fv === 1) {\n // migrate from v1 to v2\n // this.context__.meta.schemaVer = 0\n this.context__.meta.fv = 2;\n }\n\n if (this.context__.meta.fv === 2) {\n // migrate from v1 to v3\n if (this.context__.meta.schemaVer === undefined || this.context__.meta.schemaVer === 0) {\n this.context__.meta.schemaVer = 1;\n }\n delete (this.context__.meta as DictionaryOpt)['ver'];\n this.context__.meta.extra ??= {};\n this.context__.meta.fv = 3;\n }\n\n this.updated__();\n }\n\n /**\n * The ID of the collection nitrobase file.\n */\n readonly id: string;\n\n /**\n * The location path of the collection nitrobase file.\n */\n readonly path: string;\n\n /**\n * Indicates whether the collection has unsaved changes.\n */\n hasUnprocessedChanges_ = false;\n\n /**\n * Logger instance for this collection.\n */\n private logger__;\n\n /**\n * Collection reference have methods to get, set, update and save the Alwatr Nitrobase Collection.\n * This class is dummy in saving and loading the collection from file.\n * It's the responsibility of the Alwatr Nitrobase to save and load the collection.\n *\n * @param context__ Collection's context filled from the Alwatr Nitrobase (parent).\n * @param updatedCallback__ updated callback to invoke when the collection is updated from the Alwatr Nitrobase (parent).\n * @template TItem - Items data type.\n * @example\n * ```typescript\n * const collectionRef = alwatrStore.col('blog/posts');\n * ```\n */\n constructor(\n private context__: CollectionContext<TItem>,\n private updatedCallback__: (from: CollectionReference<TItem>) => void,\n debugDomain?: string,\n ) {\n this.id = getStoreId(this.context__.meta);\n this.path = getStorePath(this.context__.meta);\n\n debugDomain ??= this.id.slice(0, 20);\n this.logger__ = createLogger(`col:${debugDomain}`);\n\n this.logger__.logMethodArgs?.('new', {id: this.id});\n\n this.validateContext__();\n }\n\n /**\n * Get nitrobase schema version\n *\n * @returns nitrobase schema version\n */\n get schemaVer(): number {\n return this.context__.meta.schemaVer ?? 1;\n }\n\n /**\n * Set nitrobase schema version for migrate\n */\n set schemaVer(ver: number) {\n this.logger__.logMethodArgs?.('set schemaVer', {old: this.context__.meta.schemaVer, new: ver});\n this.context__.meta.schemaVer = ver;\n this.updated__();\n }\n\n /**\n * Indicates whether the collection data is frozen and cannot be saved.\n */\n private _freeze = false;\n\n /**\n * Gets the freeze status of the collection data.\n *\n * @returns `true` if the collection data is frozen, `false` otherwise.\n *\n * @example\n * ```typescript\n * const isFrozen = collectionRef.freeze;\n * console.log(isFrozen); // Output: false\n * ```\n */\n get freeze(): boolean {\n return this._freeze;\n }\n\n /**\n * Sets the freeze status of the collection data.\n *\n * @param value - The freeze status to set.\n *\n * @example\n * ```typescript\n * collectionRef.freeze = true;\n * console.log(collectionRef.freeze); // Output: true\n * ```\n */\n set freeze(value: boolean) {\n this.logger__.logMethodArgs?.('freeze changed', {value});\n this._freeze = value;\n }\n\n /**\n * Checks if an item exists in the collection.\n *\n * @param itemId - The ID of the item.\n * @returns `true` if the item with the given ID exists in the collection, `false` otherwise.\n *\n * @example\n * ```typescript\n * const doesExist = collectionRef.hasItem('item1');\n *\n * if (doesExist) {\n * collectionRef.addItem('item1', { key: 'value' });\n * }\n * ```\n */\n hasItem(itemId: string | number): boolean {\n const exists = Object.hasOwn(this.context__.data, itemId);\n this.logger__.logMethodFull?.('hasItem', itemId, exists);\n return exists;\n }\n\n /**\n * Retrieves the metadata of the nitrobase file.\n *\n * @returns The metadata of the nitrobase file.\n *\n * @example\n * ```typescript\n * const metadata = collectionRef.getStoreMeta();\n * ```\n */\n getStoreMeta(): Readonly<StoreFileMeta> {\n this.logger__.logMethod?.('getStoreMeta');\n return this.context__.meta;\n }\n\n /**\n * Retrieves an item from the collection. If the item does not exist, an error is thrown.\n *\n * @param itemId - The ID of the item.\n * @returns The item with the given ID.\n */\n private item__(itemId: string | number): CollectionItem<TItem> {\n const item = this.context__.data[itemId];\n if (item === undefined) {\n this.logger__.accident('item__', 'collection_item_not_found', {itemId});\n throw new Error('collection_item_not_found', {cause: {itemId}});\n }\n return item;\n }\n\n /**\n * Retrieves an item's metadata from the collection. If the item does not exist, an error is thrown.\n *\n * @param itemId - The ID of the item.\n * @returns The metadata of the item with the given ID.\n * @example\n * ```typescript\n * const itemMeta = collectionRef.getItemMeta('item1');\n * ```\n */\n getItemMeta(itemId: string | number): Readonly<CollectionItemMeta> {\n const meta = this.item__(itemId).meta;\n this.logger__.logMethodFull?.('getItemMeta', itemId, meta);\n return meta;\n }\n\n /**\n * Retrieves an item's data from the collection. If the item does not exist, an error is thrown.\n *\n * @param itemId - The ID of the item.\n * @returns The data of the item with the given ID.\n *\n * @example\n * ```typescript\n * const itemData = collectionRef.getItemData('item1');\n * ```\n */\n getItemData(itemId: string | number): TItem {\n this.logger__.logMethodArgs?.('getItemData', itemId);\n return this.item__(itemId).data;\n }\n\n /**\n * Direct access to an item.\n * If the item does not exist, `undefined` is returned.\n * **USE WITH CAUTION!**\n *\n * @param itemId - The ID of the item.\n * @returns The data of the item with the given ID or `undefined` if the item does not exist.\n *\n * @example\n * ```typescript\n * collectionRef.getItemContext_('item1')?.data.name = 'test2';\n * ```\n */\n getItemContext_(itemId: string | number): CollectionItem<TItem> | undefined {\n this.logger__.logMethodArgs?.('getItemContext_', itemId);\n return this.context__.data[itemId];\n }\n\n /**\n * Add a new item to the collection.\n * If an item with the given ID already exists, an error is thrown.\n *\n * @param itemId - The ID of the item to create.\n * @param data - The initial data of the item.\n *\n * @example\n * ```typescript\n * collectionRef.addItem('item1', { key: 'value' });\n * ```\n */\n addItem(itemId: string | number, data: TItem): void {\n this.logger__.logMethodArgs?.('addItem', {itemId, data});\n if (this.hasItem(itemId)) {\n this.logger__.accident('addItem', 'collection_item_exist', {itemId});\n throw new Error('collection_item_exist', {cause: {itemId}});\n }\n\n const now = Date.now();\n\n this.context__.data[itemId] = {\n meta: {\n id: itemId,\n // other prop calc in updateMeta__\n rev: 0,\n created: now,\n updated: now,\n },\n data,\n };\n this.updated__(itemId);\n }\n\n /**\n * Appends the given data to the collection with auto increment ID.\n *\n * @param data - The data to append.\n * @returns The ID of the appended item.\n *\n * @example\n * ```typescript\n * const newId = collectionRef.appendItem({ key: 'value' });\n * ```\n */\n appendItem(data: TItem): string | number {\n this.logger__.logMethodArgs?.('appendItem', data);\n const id = this.nextAutoIncrementId__();\n this.addItem(id, data);\n return id;\n }\n\n /**\n * Removes an item from the collection.\n *\n * @param itemId - The ID of the item to delete.\n *\n * @example\n * ```typescript\n * collectionRef.removeItem('item1');\n * collectionRef.hasItem('item1'); // Output: false\n * ```\n */\n removeItem(itemId: string | number): void {\n this.logger__.logMethodArgs?.('removeItem', itemId);\n delete this.context__.data[itemId];\n this.updated__();\n }\n\n /**\n * Sets an item's data in the collection. Replaces the item's data with the given data.\n *\n * @param itemId - The ID of the item to set.\n * @param data - The data to set for the item.\n *\n * @example\n * ```typescript\n * collectionRef.replaceItemData('item1', { a: 1, b: 2, c: 3 });\n * ```\n */\n replaceItemData(itemId: string | number, data: TItem): void {\n this.logger__.logMethodArgs?.('replaceItemData', {itemId, data});\n (this.item__(itemId).data as unknown) = data;\n this.updated__(itemId);\n }\n\n /**\n * Updates an item in the collection by merging a partial update into the item's data.\n *\n * @param itemId - The ID of the item to update.\n * @param data - The part of data to merge into the item's data.\n *\n * @example\n * ```typescript\n * collectionRef.mergeItemData(itemId, partialUpdate);\n * ```\n */\n mergeItemData(itemId: string | number, data: Partial<TItem>): void {\n this.logger__.logMethodArgs?.('mergeItemData', {itemId, data});\n Object.assign(this.item__(itemId).data, data);\n this.updated__(itemId);\n }\n\n /**\n * Requests the Alwatr Nitrobase to save the collection.\n * Saving may take some time in Alwatr Nitrobase due to the use of throttling.\n *\n * @example\n * ```typescript\n * collectionRef.save();\n * ```\n */\n save(itemId: string | number | null): void {\n this.logger__.logMethod?.('save');\n this.updated__(itemId, false);\n }\n\n /**\n * Requests the Alwatr Nitrobase to save the collection immediately.\n *\n * @example\n * ```typescript\n * collectionRef.saveImmediate();\n * ```\n */\n saveImmediate(itemId: string | number | null): void {\n this.logger__.logMethod?.('saveImmediate');\n this.updated__(itemId, true);\n }\n\n /**\n * Retrieves the IDs of all items in the collection in array.\n * Impact performance if the collection is large, use `ids()` instead.\n *\n * @returns Array of IDs of all items in the collection.\n * @example\n * ```typescript\n * const ids = collectionRef.keys();\n * ```\n */\n keys(): string[] {\n this.logger__.logMethod?.('keys');\n return Object.keys(this.context__.data);\n }\n\n /**\n * Retrieves all items in the collection in array.\n * Impact performance if the collection is large, use `items()` instead.\n *\n * @returns Array of all items in the collection.\n * @example\n * ```typescript\n * const items = collectionRef.values();\n * console.log('meta: %o', items[0].meta);\n * console.log('data: %o', items[0].data);\n * ```\n */\n values(): CollectionItem<TItem>[] {\n this.logger__.logMethod?.('values');\n return Object.values(this.context__.data);\n }\n\n /**\n * Retrieves the IDs of all items in the collection.\n * Use this method instead of `keys()` if the collection is large.\n * This method is a generator and can be used in `for...of` loops.\n * @returns Generator of IDs of all items in the collection.\n * @example\n * ```typescript\n * for (const id of collectionRef.ids()) {\n * const doc = collectionRef.get(id);\n * }\n * ```\n */\n *ids(): Generator<string, void, void> {\n this.logger__.logMethod?.('ids');\n for (const id in this.context__.data) {\n yield id;\n }\n }\n\n /**\n * Retrieves all items in the collection.\n * Use this method instead of `values()` if the collection is large.\n * This method is a generator and can be used in `for...of` loops.\n * @returns Generator of all items in the collection.\n * @example\n * ```typescript\n * for (const item of collectionRef.items()) {\n * console.log(item.data);\n * }\n */\n *items(): Generator<CollectionItem<TItem>, void, void> {\n this.logger__.logMethod?.('items');\n for (const id in this.context__.data) {\n yield this.context__.data[id];\n }\n }\n\n /**\n * Retrieves the full context of the collection.\n *\n * @returns The full context of the collection.\n *\n * @example\n * ```typescript\n * const context = collectionRef.getFullContext_();\n * ```\n */\n getFullContext_(): Readonly<CollectionContext<TItem>> {\n this.logger__.logMethod?.('getFullContext_');\n return this.context__;\n }\n\n updateDelayed_ = false;\n\n /**\n * Update the document metadata and invoke the updated callback.\n * This method is throttled to prevent multiple updates in a short time.\n *\n * @param itemId - The ID of the item to update.\n */\n private async updated__(itemId: string | number | null = null, immediate = false): Promise<void> {\n this.logger__.logMethodArgs?.('updated__', {id: itemId, immediate, delayed: this.updateDelayed_});\n\n this.hasUnprocessedChanges_ = true;\n if (itemId !== null) this.refreshMeta_(itemId); // meta must updated per item\n\n if (immediate === false && this.updateDelayed_ === true) return;\n // else\n\n this.updateDelayed_ = true;\n\n if (immediate === true || this.context__.meta.changeDebounce === undefined) {\n await delay.immediate();\n }\n else {\n await delay.by(this.context__.meta.changeDebounce);\n }\n\n if (this.updateDelayed_ !== true) return; // another parallel update finished!\n this.updateDelayed_ = false;\n\n if (itemId === null) this.refreshMeta_(itemId); // root meta not updated for null\n\n if (this._freeze === true) return; // prevent save if frozen\n this.updatedCallback__(this);\n }\n\n /**\n * Refresh/recalculate the collection's metadata timestamp and revision.\n *\n * @param itemId - The ID of the item to update.\n */\n protected refreshMeta_(itemId: string | number | null): void {\n this.logger__.logMethodArgs?.('refreshMeta_', {id: itemId});\n const now = Date.now();\n this.context__.meta.rev++;\n this.context__.meta.updated = now;\n if (itemId !== null) {\n const itemMeta = this.item__(itemId).meta;\n itemMeta.rev++;\n itemMeta.updated = now;\n }\n }\n\n /**\n * Generates the next auto increment ID.\n *\n * @returns The next auto increment ID.\n * @example\n * ```typescript\n * const nextId = this.nextAutoIncrementId_();\n * ```\n */\n private nextAutoIncrementId__(): number {\n this.logger__.logMethod?.('nextAutoIncrementId__');\n const meta = this.context__.meta as Required<StoreFileMeta>;\n do {\n meta.lastAutoId++;\n } while (meta.lastAutoId in this.context__.data);\n return meta.lastAutoId;\n }\n\n /**\n * Retrieves the collection's extra metadata.\n *\n * @returns The collection's extra metadata.\n *\n * @example\n * ```typescript\n * const colExtraMeta = collectionRef.getExtraMeta();\n * ```\n */\n getExtraMeta<T extends JsonObject>(): T {\n this.logger__.logMethod?.('getExtraMeta');\n return this.context__.meta.extra as T;\n }\n\n /**\n * Sets/replace the collection's extra metadata.\n *\n * @param extraMeta The new collection's extra metadata.\n *\n * @example\n * ```typescript\n * collectionRef.replaceExtraMeta({ a: 1, b: 2, c: 3 });\n * ```\n */\n replaceExtraMeta<T extends JsonObject>(extraMeta: T): void {\n this.logger__.logMethodArgs?.('replaceExtraMeta', extraMeta);\n this.context__.meta.extra = extraMeta;\n this.updated__();\n }\n\n /**\n * Updates collection's extra metadata by merging a partial update.\n *\n * @param extraMeta The part of extra metadata to merge into the collection's extra metadata.\n *\n * @example\n * ```typescript\n * collectionRef.mergeExtraMeta({ c: 4 });\n * ```\n */\n mergeExtraMeta<T extends JsonObject>(extraMeta: Partial<T>): void {\n this.logger__.logMethodArgs?.('mergeExtraMeta', extraMeta);\n Object.assign(this.context__.meta.extra, extraMeta);\n this.updated__();\n }\n}\n", "import {createLogger, packageTracer} from '@alwatr/nanolib';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\nexport const logger = /* #__PURE__ */ createLogger(__package_name__);\n", "import {createLogger, delay} from '@alwatr/nanolib';\nimport {getStoreId, getStorePath} from '@alwatr/nitrobase-helper';\nimport {StoreFileType, StoreFileExtension, type StoreFileId, type DocumentContext, type StoreFileMeta} from '@alwatr/nitrobase-types';\n\nimport {logger} from './logger.js';\n\n__dev_mode__: logger.logFileModule?.('document-reference');\n\n/**\n * Represents a reference to a document of the AlwatrNitrobase.\n * Provides methods to interact with the document, such as get, set, update and save.\n */\nexport class DocumentReference<TDoc extends JsonObject = JsonObject> {\n /**\n * Alwatr nitrobase engine version string.\n */\n static readonly version = __package_version__;\n\n /**\n * Alwatr nitrobase engine file format version number.\n */\n static readonly fileFormatVersion = 3;\n\n /**\n * Creates new DocumentReference instance from stat and initial data.\n *\n * @param statId the document stat.\n * @param data the document data.\n * @param updatedCallback the callback to invoke when the document changed.\n * @template TDoc The document data type.\n * @returns A new document reference class.\n */\n static newRefFromData<TDoc extends JsonObject>(\n statId: StoreFileId,\n data: TDoc,\n updatedCallback: (from: DocumentReference<TDoc>) => unknown,\n debugDomain?: string,\n ): DocumentReference<TDoc> {\n logger.logMethodArgs?.('doc.newRefFromData', statId);\n\n const now = Date.now();\n const initialContext: DocumentContext<TDoc> = {\n ok: true,\n meta: {\n ...statId,\n rev: 1,\n updated: now,\n created: now,\n type: StoreFileType.Document,\n extension: StoreFileExtension.Json,\n fv: DocumentReference.fileFormatVersion,\n extra: {},\n },\n data,\n };\n\n return new DocumentReference(initialContext, updatedCallback, debugDomain);\n }\n\n /**\n * Creates new DocumentReference instance from DocumentContext.\n *\n * @param context the document context.\n * @param updatedCallback the callback to invoke when the document changed.\n * @template TDoc The document data type.\n * @returns A new document reference class.\n */\n static newRefFromContext<TDoc extends JsonObject>(\n context: DocumentContext<TDoc>,\n updatedCallback: (from: DocumentReference<TDoc>) => unknown,\n debugDomain?: string,\n ): DocumentReference<TDoc> {\n logger.logMethodArgs?.('doc.newRefFromContext', context.meta);\n return new DocumentReference(context, updatedCallback, debugDomain);\n }\n\n /**\n * Validates the document context and try to migrate it to the latest version.\n */\n private validateContext__(): void {\n this.logger__.logMethod?.('validateContext__');\n\n if (this.context__.ok !== true) {\n this.logger__.accident?.('validateContext__', 'store_not_ok');\n throw new Error('store_not_ok', {cause: {context: this.context__}});\n }\n\n if (this.context__.meta === undefined) {\n this.logger__.accident?.('validateContext__', 'store_meta_undefined');\n throw new Error('store_meta_undefined', {cause: {context: this.context__}});\n }\n\n if (this.context__.meta.type !== StoreFileType.Document) {\n this.logger__.accident?.('validateContext__', 'document_type_invalid', this.context__.meta);\n throw new Error('document_type_invalid', {cause: this.context__.meta});\n }\n\n if (this.context__.meta.fv !== DocumentReference.fileFormatVersion) {\n this.logger__.incident?.('validateContext__', 'store_file_version_incompatible', {\n old: this.context__.meta.fv,\n new: DocumentReference.fileFormatVersion,\n });\n this.migrateContext__();\n }\n }\n\n /**\n * Migrate the document context to the latest.\n */\n private migrateContext__(): void {\n if (this.context__.meta.fv === DocumentReference.fileFormatVersion) return;\n\n this.logger__.logMethod?.('migrateContext__');\n\n if (this.context__.meta.fv > DocumentReference.fileFormatVersion) {\n this.logger__.accident('migrateContext__', 'store_version_incompatible', this.context__.meta);\n throw new Error('store_version_incompatible', {cause: this.context__.meta});\n }\n\n if (this.context__.meta.fv === 1) {\n // migrate from v1 to v2\n // this.context__.meta.schemaVer = 0\n this.context__.meta.fv = 2;\n }\n\n if (this.context__.meta.fv === 2) {\n // migrate from v1 to v3\n if (this.context__.meta.schemaVer === undefined || this.context__.meta.schemaVer === 0) {\n this.context__.meta.schemaVer = 1;\n }\n delete (this.context__.meta as DictionaryOpt)['ver'];\n this.context__.meta.extra ??= {};\n this.context__.meta.fv = 3;\n }\n\n this.updated__();\n }\n\n /**\n * The ID of the document nitrobase file.\n */\n readonly id: string;\n\n /**\n * The location path of the document nitrobase file.\n */\n readonly path: string;\n\n /**\n * Indicates whether the document has unsaved changes.\n */\n hasUnprocessedChanges_ = false;\n\n /**\n * Logger instance for this document.\n */\n private logger__;\n\n /**\n * Create a new document reference.\n * Document reference have methods to get, set, update and save the AlwatrNitrobase Document.\n *\n * @param context__ Document's context filled from the Alwatr Nitrobase (parent).\n * @param updatedCallback__ updated callback to invoke when the document is updated from the Alwatr Nitrobase (parent).\n * @template TDoc The document data type.\n */\n constructor(\n private readonly context__: DocumentContext<TDoc>,\n private readonly updatedCallback__: (from: DocumentReference<TDoc>) => unknown,\n debugDomain?: string,\n ) {\n this.id = getStoreId(this.context__.meta);\n this.path = getStorePath(this.context__.meta);\n\n debugDomain ??= this.id.slice(0, 20);\n this.logger__ = createLogger(`doc:${debugDomain}`);\n\n this.logger__.logMethodArgs?.('new', {path: this.path});\n\n this.validateContext__();\n }\n\n /**\n * Get nitrobase schema version\n *\n * @returns nitrobase schema version\n */\n get schemaVer(): number {\n return this.context__.meta.schemaVer ?? 1;\n }\n\n /**\n * Set nitrobase schema version for migrate\n */\n set schemaVer(ver: number) {\n this.logger__.logMethodArgs?.('set schemaVer', {old: this.context__.meta.schemaVer, new: ver});\n this.context__.meta.schemaVer = ver;\n this.updated__();\n }\n\n /**\n * Indicates whether the document data is frozen and cannot be saved.\n */\n private _freeze = false;\n\n /**\n * Gets the freeze status of the document data.\n *\n * @returns `true` if the document data is frozen, `false` otherwise.\n *\n * @example\n * ```typescript\n * const isFrozen = documentRef.freeze;\n * console.log(isFrozen); // Output: false\n * ```\n */\n get freeze(): boolean {\n return this._freeze;\n }\n\n /**\n * Sets the freeze status of the document data.\n *\n * @param value - The freeze status to set.\n *\n * @example\n * ```typescript\n * documentRef.freeze = true;\n * console.log(documentRef.freeze); // Output: true\n * ```\n */\n set freeze(value: boolean) {\n this.logger__.logMethodArgs?.('freeze changed', {value});\n this._freeze = value;\n }\n\n /**\n * Retrieves the document's data.\n *\n * @returns The document's data.\n *\n * @example\n * ```typescript\n * const documentData = documentRef.getData();\n * ```\n */\n getData(): TDoc {\n this.logger__.logMethod?.('getData');\n return this.context__.data;\n }\n\n /**\n * Retrieves the document's metadata.\n *\n * @returns The document's metadata.\n *\n * @example\n * ```typescript\n * const documentMeta = documentRef.getStoreMeta();\n * ```\n */\n getStoreMeta(): Readonly<StoreFileMeta> {\n this.logger__.logMethod?.('getStoreMeta');\n return this.context__.meta;\n }\n\n /**\n * Sets the document's data. replacing the existing data.\n *\n * @param data The new document data.\n *\n * @example\n * ```typescript\n * documentRef.replaceData({ a: 1, b: 2, c: 3 });\n * ```\n */\n replaceData(data: TDoc): void {\n this.logger__.logMethodArgs?.('replaceData', data);\n (this.context__.data as unknown) = data;\n this.updated__();\n }\n\n /**\n * Updates document's data by merging a partial update into the document's data.\n *\n * @param data The part of data to merge into the document's data.\n *\n * @example\n * ```typescript\n * documentRef.mergeData({ c: 4 });\n * ```\n */\n mergeData(data: Partial<TDoc>): void {\n this.logger__.logMethodArgs?.('mergeData', data);\n Object.assign(this.context__.data, data);\n this.updated__();\n }\n\n /**\n * Requests the Alwatr Nitrobase to save the document.\n * Saving may take some time in Alwatr Nitrobase due to the use of throttling.\n *\n * @example\n * ```typescript\n * documentRef.save();\n * ```\n */\n save(): void {\n this.logger__.logMethod?.('save');\n this.updated__();\n }\n\n /**\n * Requests the Alwatr Nitrobase to save the document immediately.\n *\n * @example\n * ```typescript\n * documentRef.saveImmediate();\n * ```\n */\n saveImmediate(): void {\n this.logger__.logMethod?.('saveImmediate');\n this.updated__(/* immediate: */ true);\n }\n\n /**\n * Retrieves the full context of the document.\n *\n * @returns The full context of the document.\n *\n * @example\n * ```typescript\n * const context = documentRef.getFullContext_();\n * ```\n */\n getFullContext_(): Readonly<DocumentContext<TDoc>> {\n this.logger__.logMethod?.('getFullContext_');\n return this.context__;\n }\n\n updateDelayed_ = false;\n\n /**\n * Update the document metadata and invoke the updated callback.\n * This method is throttled to prevent multiple updates in a short time.\n */\n private async updated__(immediate = false): Promise<void> {\n this.logger__.logMethodArgs?.('updated__', {immediate, delayed: this.updateDelayed_});\n\n this.hasUnprocessedChanges_ = true;\n\n if (immediate !== true && this.updateDelayed_ === true) return;\n // else\n\n this.updateDelayed_ = true;\n\n if (immediate === true || this.context__.meta.changeDebounce === undefined) {\n await delay.immediate();\n }\n else {\n await delay.by(this.context__.meta.changeDebounce);\n }\n\n if (this.updateDelayed_ !== true) return; // another parallel update finished!\n this.updateDelayed_ = false;\n\n this.refreshMetadata_();\n\n if (this._freeze === true) return; // prevent save if frozen\n this.updatedCallback__(this);\n }\n\n /**\n * Refresh/recalculate the document's metadata timestamp and revision.\n */\n protected refreshMetadata_(): void {\n this.logger__.logMethod?.('refreshMetadata_');\n this.context__.meta.updated = Date.now();\n this.context__.meta.rev++;\n }\n\n /**\n * Retrieves the document's extra metadata.\n *\n * @returns The document's extra metadata.\n *\n * @example\n * ```typescript\n * const colExtraMeta = documentRef.getExtraMeta();\n * ```\n */\n getExtraMeta<T extends JsonObject>(): T {\n this.logger__.logMethod?.('getExtraMeta');\n return this.context__.meta.extra as T;\n }\n\n /**\n * Sets/replace the document's extra metadata.\n *\n * @param extraMeta The new document's extra metadata.\n *\n * @example\n * ```typescript\n * documentRef.replaceExtraMeta({ a: 1, b: 2, c: 3 });\n * ```\n */\n replaceExtraMeta<T extends JsonObject>(extraMeta: T): void {\n this.logger__.logMethodArgs?.('replaceExtraMeta', extraMeta);\n this.context__.meta.extra = extraMeta;\n this.updated__();\n }\n\n /**\n * Updates document's extra metadata by merging a partial update.\n *\n * @param extraMeta The part of extra metadata to merge into the document's extra metadata.\n *\n * @example\n * ```typescript\n * documentRef.mergeExtraMeta({ c: 4 });\n * ```\n */\n mergeExtraMeta<T extends JsonObject>(extraMeta: Partial<T>): void {\n this.logger__.logMethodArgs?.('mergeExtraMeta', extraMeta);\n Object.assign(this.context__.meta.extra, extraMeta);\n this.updated__();\n }\n}\n"],
"mappings": ";;;AAAA,SAAQ,gBAAAA,eAAc,aAAY;AAClC,SAAQ,YAAY,oBAAmB;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OAMK;;;ACVP,SAAQ,cAAc,qBAAoB;AAE1C,aAAc,eAAc,IAAI,+BAAkB,OAAmB;AAE9D,IAAM,SAAyB,6BAAa,6BAAgB;;;ADUnE,aAAc,QAAO,gBAAgB,sBAAsB;AAQpD,IAAM,uBAAN,MAAM,qBAA2D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+JtE,YACU,WACA,mBACR,aACA;AAHQ;AACA;AAtBV;AAAA;AAAA;AAAA,kCAAyB;AAyDzB;AAAA;AAAA;AAAA,SAAQ,UAAU;AA4VlB,0BAAiB;AA5Xf,SAAK,KAAK,WAAW,KAAK,UAAU,IAAI;AACxC,SAAK,OAAO,aAAa,KAAK,UAAU,IAAI;AAE5C,kCAAgB,KAAK,GAAG,MAAM,GAAG,EAAE;AACnC,SAAK,WAAWC,cAAa,OAAO,WAAW,EAAE;AAEjD,SAAK,SAAS,gBAAgB,OAAO,EAAC,IAAI,KAAK,GAAE,CAAC;AAElD,SAAK,kBAAkB;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAzJA,OAAO,eACL,MACA,iBACA,aAC4B;AAC5B,WAAO,gBAAgB,sBAAsB,IAAI;AAEjD,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,iBAA2C;AAAA,MAC/C,IAAI;AAAA,MACJ,MAAM;AAAA,QACJ,GAAG;AAAA,QACH,KAAK;AAAA,QACL,SAAS;AAAA,QACT,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,MAAM,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AK,UAAU,KAAK,IAAI;AACvC,SAAK,UAAU,KAAK;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,eAAwC;AACtC,SAAK,SAAS,YAAY,cAAc;AACxC,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,iBAAuC,WAAoB;AACzD,SAAK,SAAS,gBAAgB,oBAAoB,SAAS;AAC3D,SAAK,UAAU,KAAK,QAAQ;AAC5B,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,eAAqC,WAA6B;AAChE,SAAK,SAAS,gBAAgB,kBAAkB,SAAS;AACzD,WAAO,OAAO,KAAK,UAAU,KAAK,OAAO,SAAS;AAClD,SAAK,UAAU;AAAA,EACjB;AACF;AAAA;AAAA;AAAA;AA/Za,mBAIK,UAAU;AAAA;AAAA;AAAA;AAJf,mBASK,oBAAoB;AAT/B,IAAM,oBAAN;",
"names": ["createLogger", "createLogger", "createLogger", "delay", "getStoreId", "getStorePath", "StoreFileType", "StoreFileExtension", "getStoreId", "getStorePath", "createLogger", "StoreFileType", "StoreFileExtension", "delay"]
}