From ce990a2fedc5545e971c3bb6e58b55bfba8c0bd9 Mon Sep 17 00:00:00 2001 From: Mohammad Honarvar Date: Thu, 10 Oct 2024 18:26:24 +0330 Subject: [PATCH] refactor: update `import`s & packages based on the latest changes of `nanolib` --- .yarn/sdks/typescript/package.json | 2 +- package.json | 2 +- packages/engine/package.json | 14 ++++++-------- packages/engine/src/alwatr-nitrobase.ts | 10 ++++------ packages/engine/src/logger.ts | 6 ++---- packages/engine/tsconfig.json | 3 ++- packages/helper/package.json | 8 ++++---- packages/nitrobase/package.json | 6 +++--- packages/reference/package.json | 12 +++++------- packages/reference/src/collection-reference.ts | 13 +++++-------- packages/reference/src/document-reference.ts | 13 +++++-------- packages/reference/src/logger.ts | 6 ++---- packages/reference/tsconfig.json | 3 ++- packages/types/package.json | 8 ++++---- packages/types/src/main.ts | 9 +++------ packages/types/tsconfig.json | 3 ++- 16 files changed, 51 insertions(+), 67 deletions(-) diff --git a/.yarn/sdks/typescript/package.json b/.yarn/sdks/typescript/package.json index 31a62a80..a9c9401b 100644 --- a/.yarn/sdks/typescript/package.json +++ b/.yarn/sdks/typescript/package.json @@ -1,6 +1,6 @@ { "name": "typescript", - "version": "5.6.2-sdk", + "version": "5.6.3-sdk", "main": "./lib/typescript.js", "type": "commonjs", "bin": { diff --git a/package.json b/package.json index 0c69a66e..eaea2a42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "publish": "lerna publish from-package" }, "devDependencies": { - "@alwatr/eslint-config": "^1.2.8", + "@alwatr/eslint-config": "^1.2.9", "@alwatr/prettier-config": "^1.0.5", "@lerna-lite/changed": "^3.9.3", "@lerna-lite/cli": "^3.9.3", diff --git a/packages/engine/package.json b/packages/engine/package.json index 44013056..25d13eaa 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -60,20 +60,18 @@ "clean": "rm -rfv dist *.tsbuildinfo" }, "dependencies": { - "@alwatr/exit-hook": "^1.1.1", - "@alwatr/flat-string": "^1.1.1", - "@alwatr/logger": "^4.0.1", + "@alwatr/exit-hook": "^1.1.2", + "@alwatr/nanolib": "^1.0.2", "@alwatr/nitrobase-helper": "workspace:^", "@alwatr/nitrobase-reference": "workspace:^", "@alwatr/nitrobase-types": "workspace:^", - "@alwatr/node-fs": "^1.1.1", - "@alwatr/wait": "^1.1.16" + "@alwatr/node-fs": "^1.1.2" }, "devDependencies": { - "@alwatr/nano-build": "^1.5.0", + "@alwatr/nano-build": "^1.6.0", "@alwatr/prettier-config": "^1.0.5", - "@alwatr/tsconfig-base": "^1.3.0", - "@alwatr/type-helper": "^2.0.0", + "@alwatr/tsconfig-base": "^1.3.1", + "@alwatr/type-helper": "^2.0.1", "@types/node": "^22.7.5", "typescript": "^5.6.3" } diff --git a/packages/engine/src/alwatr-nitrobase.ts b/packages/engine/src/alwatr-nitrobase.ts index 3736aefb..6b2f48c8 100644 --- a/packages/engine/src/alwatr-nitrobase.ts +++ b/packages/engine/src/alwatr-nitrobase.ts @@ -1,4 +1,5 @@ import {exitHook} from '@alwatr/exit-hook'; +import {delay} from '@alwatr/nanolib'; import {getStoreId, getStorePath} from '@alwatr/nitrobase-helper'; import {CollectionReference, DocumentReference} from '@alwatr/nitrobase-reference'; import { @@ -13,13 +14,10 @@ import { type CollectionItem, } from '@alwatr/nitrobase-types'; import {existsSync, readJson, resolve, unlink, writeJson} from '@alwatr/node-fs'; -import {waitForTimeout} from '@alwatr/wait'; import {logger} from './logger.js'; -import type {Dictionary, JsonObject} from '@alwatr/type-helper'; - -logger.logModule?.('alwatr-nitrobase'); +logger.logFileModule?.('alwatr-nitrobase'); /** * AlwatrNitrobase configuration. @@ -79,7 +77,7 @@ export class AlwatrNitrobase { /** * Keep all loaded nitrobase file context loaded in memory. */ - private cacheReferences__: Dictionary = {}; + private cacheReferences__: DictionaryReq = {}; /** * Constructs an AlwatrNitrobase instance with the provided configuration. @@ -377,7 +375,7 @@ export class AlwatrNitrobase { } const path = getStorePath(this.rootDb__.getItemData(id_)); this.rootDb__.removeItem(id_); - await waitForTimeout(0); + await delay.by(0); try { await unlink(resolve(this.config__.rootPath, path)); } diff --git a/packages/engine/src/logger.ts b/packages/engine/src/logger.ts index 10fb0e0f..dff36d9a 100644 --- a/packages/engine/src/logger.ts +++ b/packages/engine/src/logger.ts @@ -1,5 +1,3 @@ -import {definePackage} from '@alwatr/logger'; +import {createLogger} from '@alwatr/nanolib'; -import type {} from '@alwatr/nano-build'; - -export const logger = definePackage('@alwatr/nitrobase-engine', __package_version__); +export const logger = createLogger(__package_name__); diff --git a/packages/engine/tsconfig.json b/packages/engine/tsconfig.json index 33d74856..6b1648c8 100644 --- a/packages/engine/tsconfig.json +++ b/packages/engine/tsconfig.json @@ -4,7 +4,8 @@ "rootDir": "src", "outDir": "dist", "emitDeclarationOnly": true, - "composite": true + "composite": true, + "types": ["@alwatr/nano-build", "@alwatr/type-helper"] }, "include": ["src/**/*.ts"], "references": [{"path": "../types"}, {"path": "../reference"}, {"path": "../helper"}] diff --git a/packages/helper/package.json b/packages/helper/package.json index 1a8339d0..bd70db4b 100644 --- a/packages/helper/package.json +++ b/packages/helper/package.json @@ -60,14 +60,14 @@ "clean": "rm -rfv dist *.tsbuildinfo" }, "dependencies": { - "@alwatr/flat-string": "^1.1.1", + "@alwatr/flat-string": "^1.1.2", "@alwatr/nitrobase-types": "workspace:^" }, "devDependencies": { - "@alwatr/logger": "^4.0.1", - "@alwatr/nano-build": "^1.5.0", + "@alwatr/logger": "^4.0.2", + "@alwatr/nano-build": "^1.6.0", "@alwatr/prettier-config": "^1.0.5", - "@alwatr/tsconfig-base": "^1.3.0", + "@alwatr/tsconfig-base": "^1.3.1", "@alwatr/wait": "^1.1.16", "@types/node": "^22.7.5", "typescript": "^5.6.3" diff --git a/packages/nitrobase/package.json b/packages/nitrobase/package.json index e52ea8a6..11268c89 100644 --- a/packages/nitrobase/package.json +++ b/packages/nitrobase/package.json @@ -66,10 +66,10 @@ "@alwatr/nitrobase-types": "workspace:^" }, "devDependencies": { - "@alwatr/logger": "^4.0.1", - "@alwatr/nano-build": "^1.5.0", + "@alwatr/logger": "^4.0.2", + "@alwatr/nano-build": "^1.6.0", "@alwatr/prettier-config": "^1.0.5", - "@alwatr/tsconfig-base": "^1.3.0", + "@alwatr/tsconfig-base": "^1.3.1", "@alwatr/wait": "^1.1.16", "@types/node": "^22.7.5", "typescript": "^5.6.3" diff --git a/packages/reference/package.json b/packages/reference/package.json index 3ce77e0a..eb8d401f 100644 --- a/packages/reference/package.json +++ b/packages/reference/package.json @@ -60,17 +60,15 @@ "clean": "rm -rfv dist *.tsbuildinfo" }, "dependencies": { - "@alwatr/flat-string": "^1.1.1", - "@alwatr/logger": "^4.0.1", + "@alwatr/nanolib": "^1.0.2", "@alwatr/nitrobase-helper": "workspace:^", - "@alwatr/nitrobase-types": "workspace:^", - "@alwatr/wait": "^1.1.16" + "@alwatr/nitrobase-types": "workspace:^" }, "devDependencies": { - "@alwatr/nano-build": "^1.5.0", + "@alwatr/nano-build": "^1.6.0", "@alwatr/prettier-config": "^1.0.5", - "@alwatr/tsconfig-base": "^1.3.0", - "@alwatr/type-helper": "^2.0.0", + "@alwatr/tsconfig-base": "^1.3.1", + "@alwatr/type-helper": "^2.0.1", "@types/node": "^22.7.5", "typescript": "^5.6.3" } diff --git a/packages/reference/src/collection-reference.ts b/packages/reference/src/collection-reference.ts index 90466717..315e6bf4 100644 --- a/packages/reference/src/collection-reference.ts +++ b/packages/reference/src/collection-reference.ts @@ -1,4 +1,4 @@ -import {createLogger} from '@alwatr/logger'; +import {createLogger, delay} from '@alwatr/nanolib'; import {getStoreId, getStorePath} from '@alwatr/nitrobase-helper'; import { StoreFileType, @@ -9,13 +9,10 @@ import { type CollectionItemMeta, type StoreFileMeta, } from '@alwatr/nitrobase-types'; -import {waitForImmediate, waitForTimeout} from '@alwatr/wait'; import {logger} from './logger.js'; -import type {Dictionary, JsonObject} from '@alwatr/type-helper'; - -logger.logModule?.('collection-reference'); +logger.logFileModule?.('collection-reference'); /** * Represents a reference to a collection of the AlwatrNitrobase. @@ -142,7 +139,7 @@ export class CollectionReference { if (this.context__.meta.schemaVer === undefined || this.context__.meta.schemaVer === 0) { this.context__.meta.schemaVer = 1; } - delete (this.context__.meta as Dictionary)['ver']; + delete (this.context__.meta as DictionaryOpt)['ver']; this.context__.meta.extra ??= {}; this.context__.meta.fv = 3; } @@ -588,10 +585,10 @@ export class CollectionReference { this.updateDelayed_ = true; if (immediate === true || this.context__.meta.changeDebounce === undefined) { - await waitForImmediate(); + await delay.immediate(); } else { - await waitForTimeout(this.context__.meta.changeDebounce); + await delay.by(this.context__.meta.changeDebounce); } if (this.updateDelayed_ !== true) return; // another parallel update finished! diff --git a/packages/reference/src/document-reference.ts b/packages/reference/src/document-reference.ts index 561c0d1b..17f24d77 100644 --- a/packages/reference/src/document-reference.ts +++ b/packages/reference/src/document-reference.ts @@ -1,13 +1,10 @@ -import {createLogger} from '@alwatr/logger'; +import {createLogger, delay} from '@alwatr/nanolib'; import {getStoreId, getStorePath} from '@alwatr/nitrobase-helper'; import {StoreFileType, StoreFileExtension, type StoreFileId, type DocumentContext, type StoreFileMeta} from '@alwatr/nitrobase-types'; -import {waitForImmediate, waitForTimeout} from '@alwatr/wait'; import {logger} from './logger.js'; -import type {Dictionary, JsonObject} from '@alwatr/type-helper'; - -logger.logModule?.('document-reference'); +logger.logFileModule?.('document-reference'); /** * Represents a reference to a document of the AlwatrNitrobase. @@ -131,7 +128,7 @@ export class DocumentReference { if (this.context__.meta.schemaVer === undefined || this.context__.meta.schemaVer === 0) { this.context__.meta.schemaVer = 1; } - delete (this.context__.meta as Dictionary)['ver']; + delete (this.context__.meta as DictionaryOpt)['ver']; this.context__.meta.extra ??= {}; this.context__.meta.fv = 3; } @@ -358,10 +355,10 @@ export class DocumentReference { this.updateDelayed_ = true; if (immediate === true || this.context__.meta.changeDebounce === undefined) { - await waitForImmediate(); + await delay.immediate(); } else { - await waitForTimeout(this.context__.meta.changeDebounce); + await delay.by(this.context__.meta.changeDebounce); } if (this.updateDelayed_ !== true) return; // another parallel update finished! diff --git a/packages/reference/src/logger.ts b/packages/reference/src/logger.ts index 2fde5790..dff36d9a 100644 --- a/packages/reference/src/logger.ts +++ b/packages/reference/src/logger.ts @@ -1,5 +1,3 @@ -import {definePackage} from '@alwatr/logger'; +import {createLogger} from '@alwatr/nanolib'; -import type {} from '@alwatr/nano-build'; - -export const logger = definePackage('@alwatr/nitrobase-reference', __package_version__); +export const logger = createLogger(__package_name__); diff --git a/packages/reference/tsconfig.json b/packages/reference/tsconfig.json index 7367de35..1fc5d404 100644 --- a/packages/reference/tsconfig.json +++ b/packages/reference/tsconfig.json @@ -4,7 +4,8 @@ "rootDir": "src", "outDir": "dist", "emitDeclarationOnly": true, - "composite": true + "composite": true, + "types": ["@alwatr/nano-build", "@alwatr/type-helper"] }, "include": ["src/**/*.ts", "src/util.ts"], "references": [{"path": "../types"}, {"path": "../helper"}] diff --git a/packages/types/package.json b/packages/types/package.json index f803443d..a319a771 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -60,13 +60,13 @@ "clean": "rm -rfv dist *.tsbuildinfo" }, "dependencies": { - "@alwatr/dedupe": "^1.1.1" + "@alwatr/nanolib": "^1.0.2" }, "devDependencies": { - "@alwatr/nano-build": "^1.5.0", + "@alwatr/nano-build": "^1.6.0", "@alwatr/prettier-config": "^1.0.5", - "@alwatr/tsconfig-base": "^1.3.0", - "@alwatr/type-helper": "^2.0.0", + "@alwatr/tsconfig-base": "^1.3.1", + "@alwatr/type-helper": "^2.0.1", "@types/node": "^22.7.5", "typescript": "^5.6.3" } diff --git a/packages/types/src/main.ts b/packages/types/src/main.ts index e1b7aacd..a105ddf9 100644 --- a/packages/types/src/main.ts +++ b/packages/types/src/main.ts @@ -1,9 +1,6 @@ -import {definePackage} from '@alwatr/dedupe'; +import {packageTracer} from '@alwatr/nanolib'; -import type {} from '@alwatr/nano-build'; -import type {Dictionary, JsonObject} from '@alwatr/type-helper'; - -definePackage('@alwatr/nitrobase-types', __package_version__); +packageTracer.add(__package_name__, __package_version__); // *** Nitrobase File *** @@ -265,4 +262,4 @@ export type CollectionItem = { /** * Collection item context type. */ -export type CollectionContext = StoreFileContext>>; +export type CollectionContext = StoreFileContext>>; diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index 44fe3592..156d0231 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -4,7 +4,8 @@ "rootDir": "src", "outDir": "dist", "emitDeclarationOnly": true, - "composite": true + "composite": true, + "types": ["@alwatr/nano-build", "@alwatr/type-helper"] }, "include": ["src/**/*.ts"] }