Skip to content

Commit

Permalink
refactor: update imports & packages based on the latest changes of …
Browse files Browse the repository at this point in the history
…`nanolib`
  • Loading branch information
mohammadhonarvar authored and alimd committed Oct 10, 2024
1 parent 22fceda commit ce990a2
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "5.6.2-sdk",
"version": "5.6.3-sdk",
"main": "./lib/typescript.js",
"type": "commonjs",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 6 additions & 8 deletions packages/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
10 changes: 4 additions & 6 deletions packages/engine/src/alwatr-nitrobase.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -79,7 +77,7 @@ export class AlwatrNitrobase {
/**
* Keep all loaded nitrobase file context loaded in memory.
*/
private cacheReferences__: Dictionary<DocumentReference | CollectionReference> = {};
private cacheReferences__: DictionaryReq<DocumentReference | CollectionReference> = {};

/**
* Constructs an AlwatrNitrobase instance with the provided configuration.
Expand Down Expand Up @@ -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));
}
Expand Down
6 changes: 2 additions & 4 deletions packages/engine/src/logger.ts
Original file line number Diff line number Diff line change
@@ -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__);
3 changes: 2 additions & 1 deletion packages/engine/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]
Expand Down
8 changes: 4 additions & 4 deletions packages/helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/nitrobase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 5 additions & 7 deletions packages/reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
13 changes: 5 additions & 8 deletions packages/reference/src/collection-reference.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createLogger} from '@alwatr/logger';
import {createLogger, delay} from '@alwatr/nanolib';
import {getStoreId, getStorePath} from '@alwatr/nitrobase-helper';
import {
StoreFileType,
Expand All @@ -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.
Expand Down Expand Up @@ -142,7 +139,7 @@ export class CollectionReference<TItem extends JsonObject = JsonObject> {
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;
}
Expand Down Expand Up @@ -588,10 +585,10 @@ export class CollectionReference<TItem extends JsonObject = JsonObject> {
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!
Expand Down
13 changes: 5 additions & 8 deletions packages/reference/src/document-reference.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -131,7 +128,7 @@ export class DocumentReference<TDoc extends JsonObject = JsonObject> {
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;
}
Expand Down Expand Up @@ -358,10 +355,10 @@ export class DocumentReference<TDoc extends JsonObject = JsonObject> {
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!
Expand Down
6 changes: 2 additions & 4 deletions packages/reference/src/logger.ts
Original file line number Diff line number Diff line change
@@ -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__);
3 changes: 2 additions & 1 deletion packages/reference/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]
Expand Down
8 changes: 4 additions & 4 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
9 changes: 3 additions & 6 deletions packages/types/src/main.ts
Original file line number Diff line number Diff line change
@@ -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 ***

Expand Down Expand Up @@ -265,4 +262,4 @@ export type CollectionItem<TData extends JsonObject = JsonObject> = {
/**
* Collection item context type.
*/
export type CollectionContext<T extends JsonObject = JsonObject> = StoreFileContext<Dictionary<CollectionItem<T>>>;
export type CollectionContext<T extends JsonObject = JsonObject> = StoreFileContext<DictionaryReq<CollectionItem<T>>>;
3 changes: 2 additions & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"]
}

0 comments on commit ce990a2

Please sign in to comment.