重新定义了operationResult
This commit is contained in:
parent
135d8ac69f
commit
acb7423780
|
|
@ -75,10 +75,29 @@ export declare type DeduceRemoveOperationData<SH extends EntityShape> = {
|
|||
};
|
||||
export declare type DeduceRemoveOperation<SH extends EntityShape> = Operation<'remove', DeduceRemoveOperationData<SH>, DeduceFilter<SH>>;
|
||||
export declare type DeduceOperation<SH extends EntityShape> = DeduceCreateOperation<SH> | DeduceUpdateOperation<SH> | DeduceRemoveOperation<SH> | DeduceSelection<SH>;
|
||||
declare type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 'c';
|
||||
e: T;
|
||||
d: ED[T]['OpSchema'];
|
||||
};
|
||||
declare type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 'u';
|
||||
e: T;
|
||||
d: ED[T]['OpSchema'];
|
||||
f?: DeduceFilter<ED[T]>;
|
||||
};
|
||||
declare type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 'r';
|
||||
e: T;
|
||||
f?: DeduceFilter<ED[T]>;
|
||||
};
|
||||
declare type SelectOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 's';
|
||||
e: T;
|
||||
d: Array<ED[T]['OpSchema']>;
|
||||
};
|
||||
export interface OperationResult<ED extends EntityDict> {
|
||||
operations?: {
|
||||
[T in keyof ED]?: Array<ED[keyof ED]['Operation']>;
|
||||
};
|
||||
operations: Array<CreateOpResult<ED, keyof ED> | UpdateOpResult<ED, keyof ED> | RemoveOpResult<ED, keyof ED> | SelectOpResult<ED, keyof ED>>;
|
||||
ids?: string[];
|
||||
stats?: 'todo';
|
||||
errors?: Array<{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { EntityDef, EntityShape } from './Entity';
|
||||
import { EntityDict, EntityShape } from './Entity';
|
||||
import { DataType, DataTypeParams } from './schema/DataTypes';
|
||||
import { TriggerDataAttribute, TriggerTimestampAttribute } from './Trigger';
|
||||
export declare type Ref = 'ref';
|
||||
|
|
@ -45,10 +45,7 @@ export interface StorageDesc<SH extends EntityShape> {
|
|||
config?: EntityConfig;
|
||||
view?: true;
|
||||
}
|
||||
declare type EntityDomain = {
|
||||
[K: string]: EntityDef;
|
||||
};
|
||||
export declare type StorageSchema<ED extends EntityDomain> = {
|
||||
export declare type StorageSchema<ED extends EntityDict> = {
|
||||
[K in keyof ED]: StorageDesc<ED[K]['OpSchema']>;
|
||||
};
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -102,10 +102,33 @@ export type DeduceRemoveOperation<SH extends EntityShape> = Operation<'remove',
|
|||
|
||||
export type DeduceOperation<SH extends EntityShape> = DeduceCreateOperation<SH> | DeduceUpdateOperation<SH> | DeduceRemoveOperation<SH> | DeduceSelection<SH>;
|
||||
|
||||
type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 'c';
|
||||
e: T;
|
||||
d: ED[T]['OpSchema'];
|
||||
};
|
||||
|
||||
type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 'u',
|
||||
e: T;
|
||||
d: ED[T]['OpSchema'];
|
||||
f?: DeduceFilter<ED[T]>;
|
||||
};
|
||||
|
||||
type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 'r',
|
||||
e: T;
|
||||
f?: DeduceFilter<ED[T]>;
|
||||
};
|
||||
|
||||
type SelectOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
a: 's',
|
||||
e: T;
|
||||
d: Array<ED[T]['OpSchema']>;
|
||||
}
|
||||
|
||||
export interface OperationResult<ED extends EntityDict> {
|
||||
operations?: { // cud返回的结果,select返回create
|
||||
[T in keyof ED]?: Array<ED[keyof ED]['Operation']>;
|
||||
}; // create/update/remove返回的动作结果
|
||||
operations: Array<CreateOpResult<ED, keyof ED> | UpdateOpResult<ED, keyof ED> | RemoveOpResult<ED, keyof ED> | SelectOpResult<ED, keyof ED>>; // create/update/remove返回的动作结果
|
||||
ids?: string[];
|
||||
stats?: 'todo';
|
||||
errors?: Array<{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { EntityDef, EntityShape } from './Entity';
|
||||
import { EntityDict, EntityShape } from './Entity';
|
||||
import { DataType, DataTypeParams } from './schema/DataTypes';
|
||||
import { TriggerDataAttribute, TriggerTimestampAttribute } from './Trigger';
|
||||
export type Ref = 'ref';
|
||||
|
|
@ -57,10 +57,7 @@ export interface StorageDesc<SH extends EntityShape> {
|
|||
view?: true;
|
||||
}
|
||||
|
||||
type EntityDomain = {
|
||||
[K: string]: EntityDef;
|
||||
};
|
||||
|
||||
export type StorageSchema<ED extends EntityDomain> = {
|
||||
export type StorageSchema<ED extends EntityDict> = {
|
||||
[K in keyof ED]: StorageDesc<ED[K]['OpSchema']>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue