Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(type): AlwatrDocumentStorage type with AlwatrServiceResponseSuccessWithMeta #961

Merged
merged 2 commits into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions core/type/src/service-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export interface AlwatrServiceResponseFailed extends StringifyableRecord {
data?: never;
}

export interface AlwatrServiceResponseSuccess<TData extends StringifyableRecord> extends StringifyableRecord {
export interface AlwatrServiceResponseSuccess<TData extends StringifyableRecord = StringifyableRecord>
extends StringifyableRecord {
ok: true;
statusCode?: number;
errorCode?: never;
Expand All @@ -23,8 +24,8 @@ export interface AlwatrServiceResponseSuccess<TData extends StringifyableRecord>
}

export interface AlwatrServiceResponseSuccessWithMeta<
TData extends StringifyableRecord,
TMeta extends StringifyableRecord
TData extends StringifyableRecord = StringifyableRecord,
TMeta extends StringifyableRecord = StringifyableRecord
> extends StringifyableRecord {
ok: true;
statusCode?: number;
Expand All @@ -33,7 +34,10 @@ export interface AlwatrServiceResponseSuccessWithMeta<
data: TData;
}

export type AlwatrServiceResponse<TData extends StringifyableRecord, TMeta extends StringifyableRecord> =
export type AlwatrServiceResponse<
TData extends StringifyableRecord = StringifyableRecord,
TMeta extends StringifyableRecord = StringifyableRecord
> =
| AlwatrServiceResponseSuccess<TData>
| AlwatrServiceResponseSuccessWithMeta<TData, TMeta>
| AlwatrServiceResponseFailed;
8 changes: 3 additions & 5 deletions core/type/src/storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {AlwatrServiceResponseSuccessWithMeta} from './service-response.js';
import {StringifyableRecord} from './type-helper.js';

export interface AlwatrDocumentObject extends StringifyableRecord {
Expand All @@ -22,8 +23,5 @@ export interface AlwatrStorageMeta extends StringifyableRecord {
// 'statusCode' | 'errorCode'
// >;

export interface AlwatrDocumentStorage<T extends AlwatrDocumentObject> extends StringifyableRecord {
ok: true;
data: Record<string, T>;
meta: AlwatrStorageMeta;
}
export type AlwatrDocumentStorage<T extends AlwatrDocumentObject = AlwatrDocumentObject> =
AlwatrServiceResponseSuccessWithMeta<Record<string, T>, AlwatrStorageMeta>;