微调了upload接口的逻辑
This commit is contained in:
parent
4e6eec9c38
commit
cefe8fc20e
|
|
@ -1,2 +1,2 @@
|
|||
declare const checkers: (import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "applicationPassport", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>>)[];
|
||||
declare const checkers: (import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "address", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "application", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "applicationPassport", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "token", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "user", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "mobile", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "message", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../oak-app-domain").EntityDict, "parasite", import("..").RuntimeCxt<import("../oak-app-domain").EntityDict>>)[];
|
||||
export default checkers;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "article", true, {
|
||||
articleMenuId: string | undefined;
|
||||
onChildEditArticleChange: (data: string) => void;
|
||||
show: "edit" | "doc" | "preview";
|
||||
show: "preview" | "edit" | "doc";
|
||||
getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void;
|
||||
breadcrumbItems: string[];
|
||||
drawerOpen: boolean;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
onRemove: () => void;
|
||||
onUpdateName: (name: string) => Promise<void>;
|
||||
onChildEditArticleChange: (data: string) => void;
|
||||
show: "edit" | "doc" | "preview";
|
||||
show: "preview" | "edit" | "doc";
|
||||
getBreadcrumbItemsByParent: (breadcrumbItems: string[]) => void;
|
||||
breadItems: string[];
|
||||
drawerOpen: boolean;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
entityId: string;
|
||||
parentId: string | undefined;
|
||||
onGrandChildEditArticleChange: (data: string) => void;
|
||||
show: "edit" | "doc" | "preview";
|
||||
show: "preview" | "edit" | "doc";
|
||||
articleMenuId: string;
|
||||
articleId: string;
|
||||
getBreadcrumbItems: (breadcrumbItems: string[]) => void;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "articleMenu", true, {
|
||||
entity: string;
|
||||
entityId: string;
|
||||
show: "edit" | "doc" | "preview";
|
||||
show: "preview" | "edit" | "doc";
|
||||
articleMenuId: string;
|
||||
articleId: string;
|
||||
tocPosition: "none" | "left" | "right";
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import { ReactComponentProps } from 'oak-frontend-base';
|
|||
import { ECode } from '../../../types/ErrorPage';
|
||||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
|
||||
code: ECode;
|
||||
title?: string;
|
||||
desc?: string;
|
||||
title?: string | undefined;
|
||||
desc?: string | undefined;
|
||||
children?: React.ReactNode;
|
||||
icon?: React.ReactNode;
|
||||
}>) => React.ReactElement;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Style } from '../../../../types/Style';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, false, {
|
||||
style: Style;
|
||||
entity: "application" | "platform" | "system";
|
||||
entity: "application" | "system" | "platform";
|
||||
entityId: string;
|
||||
name: string;
|
||||
}>) => React.ReactElement;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Config } from '../../../types/Config';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, false, {
|
||||
config: Config;
|
||||
entity: "platform" | "system";
|
||||
entity: "system" | "platform";
|
||||
name: string;
|
||||
entityId: string;
|
||||
}>) => React.ReactElement;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/// <reference types="react" />
|
||||
import { EntityDict } from '../../../oak-app-domain';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { ReactComponentProps } from 'oak-frontend-base/lib/types/Page';
|
||||
|
|
@ -8,14 +9,31 @@ type AfterCommit = (() => void) | undefined;
|
|||
type BeforeCommit = (() => boolean | undefined | Promise<boolean | undefined>) | undefined;
|
||||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
entity: keyof ED2;
|
||||
action?: string;
|
||||
action?: string | undefined;
|
||||
size?: ButtonProps['size'] | AmButtonProps['size'];
|
||||
block?: boolean;
|
||||
block?: boolean | undefined;
|
||||
type?: ButtonProps['type'] | AmButtonProps['type'];
|
||||
executeText?: string;
|
||||
buttonProps?: ButtonProps & AmButtonProps;
|
||||
executeText?: string | undefined;
|
||||
buttonProps?: (ButtonProps & {
|
||||
color?: "default" | "success" | "primary" | "warning" | "danger" | undefined;
|
||||
fill?: "solid" | "outline" | "none" | undefined;
|
||||
size?: "mini" | "small" | "middle" | "large" | undefined;
|
||||
block?: boolean | undefined;
|
||||
loading?: boolean | "auto" | undefined;
|
||||
loadingText?: string | undefined;
|
||||
loadingIcon?: import("react").ReactNode;
|
||||
disabled?: boolean | undefined;
|
||||
onClick?: ((event: import("react").MouseEvent<HTMLButtonElement, MouseEvent>) => unknown) | undefined;
|
||||
type?: "submit" | "reset" | "button" | undefined;
|
||||
shape?: "default" | "rounded" | "rectangular" | undefined;
|
||||
children?: import("react").ReactNode;
|
||||
} & Pick<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, "id" | "onMouseDown" | "onMouseUp" | "onTouchStart" | "onTouchEnd"> & {
|
||||
className?: string | undefined;
|
||||
style?: (import("react").CSSProperties & Partial<Record<"--text-color" | "--background-color" | "--border-radius" | "--border-width" | "--border-style" | "--border-color", string>>) | undefined;
|
||||
tabIndex?: number | undefined;
|
||||
} & import("react").AriaAttributes) | undefined;
|
||||
afterCommit?: AfterCommit;
|
||||
beforeCommit?: BeforeCommit;
|
||||
messageProps?: MessageProps | boolean;
|
||||
messageProps?: boolean | MessageProps | undefined;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export default OakComponent({
|
|||
if (['local', 'failed'].includes(state)) {
|
||||
promises.push((async () => {
|
||||
try {
|
||||
await this.features.extraFile.upload(id, entity);
|
||||
await this.features.extraFile.upload(id);
|
||||
}
|
||||
catch (err) {
|
||||
failureIds.push(id);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
tag2: string;
|
||||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
style?: string;
|
||||
style?: string | undefined;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
entityId: string;
|
||||
theme: Theme;
|
||||
children?: React.ReactNode;
|
||||
style?: string;
|
||||
style?: string | undefined;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { EntityDict } from '../../../oak-app-domain';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "userEntityGrant", false, {
|
||||
picker: ((props: {
|
||||
disabled?: boolean;
|
||||
disabled?: boolean | undefined;
|
||||
entity: keyof EntityDict;
|
||||
entityFilter: object;
|
||||
relationIds: string[];
|
||||
|
|
@ -9,8 +9,8 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
ruleOnRow: EntityDict['userEntityGrant']['OpSchema']['ruleOnRow'];
|
||||
onPickRelations: (ids: string[]) => void;
|
||||
onPickRows: (ids: string[]) => void;
|
||||
pickedRowIds?: string[];
|
||||
pickedRelationIds?: string[];
|
||||
pickedRowIds?: string[] | undefined;
|
||||
pickedRelationIds?: string[] | undefined;
|
||||
oakPath: string;
|
||||
}) => React.ReactElement) | undefined;
|
||||
hideInfo: boolean;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
entity: keyof EntityDict;
|
||||
entityFilter: any;
|
||||
relationIds: string[];
|
||||
rule: "single" | "all" | "free";
|
||||
ruleOnRow: "single" | "all" | "free";
|
||||
rule: "all" | "single" | "free";
|
||||
ruleOnRow: "all" | "single" | "free";
|
||||
onPickRelations: (ids: string[]) => void;
|
||||
onPickRows: (ids: string[]) => void;
|
||||
pickedRowIds: string[] | undefined;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
claimUrl: string;
|
||||
qrCodeType: QrCodeType;
|
||||
multiple: boolean;
|
||||
rule: "single" | "all" | "free";
|
||||
ruleOnRow: "single" | "all" | "free";
|
||||
rule: "all" | "single" | "free";
|
||||
ruleOnRow: "all" | "single" | "free";
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { ReactComponentProps } from 'oak-frontend-base';
|
|||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
redirectToAfterConfirm: ED2['userEntityGrant']['Schema']['redirectTo'];
|
||||
redirectToAfterConfirm: ED2["userEntityGrant"]["Schema"]["redirectTo"];
|
||||
qrCodeType: string;
|
||||
showTitle: true;
|
||||
showBack: false;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
relations: EntityDict['relation']['OpSchema'][];
|
||||
passwordRequire?: boolean;
|
||||
allowUpdateName?: boolean;
|
||||
allowUpdateNickname?: boolean;
|
||||
passwordRequire?: boolean | undefined;
|
||||
allowUpdateName?: boolean | undefined;
|
||||
allowUpdateNickname?: boolean | undefined;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
|||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
allowUpdateName?: boolean;
|
||||
allowUpdateNickname?: boolean;
|
||||
allowUpdateName?: boolean | undefined;
|
||||
allowUpdateNickname?: boolean | undefined;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { ReactComponentProps } from 'oak-frontend-base';
|
|||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
redirectToAfterConfirm: ED2['userEntityGrant']['Schema']['redirectTo'];
|
||||
redirectToAfterConfirm: ED2["userEntityGrant"]["Schema"]["redirectTo"];
|
||||
qrCodeType: QrCodeType;
|
||||
type: EntityDict['userEntityGrant']['Schema']['type'];
|
||||
relations: EntityDict['relation']['OpSchema'][];
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
|||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
redirectToAfterConfirm: ED2['userEntityGrant']['Schema']['redirectTo'];
|
||||
redirectToAfterConfirm: ED2["userEntityGrant"]["Schema"]["redirectTo"];
|
||||
claimUrl: string;
|
||||
qrCodeType: string;
|
||||
passwordRequire?: boolean;
|
||||
allowUpdateName?: boolean;
|
||||
allowUpdateNickname?: boolean;
|
||||
passwordRequire?: boolean | undefined;
|
||||
allowUpdateName?: boolean | undefined;
|
||||
allowUpdateNickname?: boolean | undefined;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export declare class ExtraFile<ED extends EntityDict> extends Feature {
|
|||
registerCos(clazzes: Array<new () => Cos<ED>>): void;
|
||||
addLocalFile(id: string, file: File | string): void;
|
||||
removeLocalFiles(ids: string[]): void;
|
||||
upload(id: string, entity: keyof ED): Promise<void>;
|
||||
upload(id: string): Promise<void>;
|
||||
getUrl(extraFile?: EntityDict['extraFile']['OpSchema'] | EntityDict['extraFile']['Schema'] | null, style?: string): string;
|
||||
getFileState(id: string): {
|
||||
state: FileState;
|
||||
|
|
|
|||
|
|
@ -31,42 +31,39 @@ export class ExtraFile extends Feature {
|
|||
ids.forEach((id) => unset(this.files, id));
|
||||
this.publish();
|
||||
}
|
||||
async upload(id, entity) {
|
||||
async upload(id) {
|
||||
/**
|
||||
* 这个函数假设了前台知道后台会产生modi的行为和数据结构,不是很好的设计
|
||||
*/
|
||||
const { toModi } = this.cache.getSchema()[entity];
|
||||
let modiEntityId = '';
|
||||
const getExtraFileData = () => {
|
||||
if (toModi) {
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
data: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: entity,
|
||||
targetEntity: 'extraFile',
|
||||
action: 'create',
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
},
|
||||
});
|
||||
modiEntityId = modi.entityId;
|
||||
return modi.data;
|
||||
const [extraFile] = this.cache.get('extraFile', {
|
||||
data: extraFileProjection,
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
if (extraFile) {
|
||||
return extraFile;
|
||||
}
|
||||
else {
|
||||
const [extraFile] = this.cache.get('extraFile', {
|
||||
data: extraFileProjection,
|
||||
// 否则再去modi中查看
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
data: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
},
|
||||
filter: {
|
||||
targetEntity: 'extraFile',
|
||||
action: 'create',
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
return extraFile;
|
||||
}
|
||||
},
|
||||
});
|
||||
modiEntityId = modi.entityId;
|
||||
return modi.data;
|
||||
};
|
||||
const extraFile = getExtraFileData();
|
||||
assert(extraFile && extraFile.uploadState === 'uploading');
|
||||
|
|
@ -99,30 +96,10 @@ export class ExtraFile extends Feature {
|
|||
id,
|
||||
},
|
||||
};
|
||||
if (toModi) {
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'modi',
|
||||
operation: {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
entity: entity,
|
||||
entityId: modiEntityId,
|
||||
data: operation.data,
|
||||
action: 'update',
|
||||
filter: operation.filter,
|
||||
targetEntity: 'extraFile',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
operation,
|
||||
});
|
||||
}
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
operation,
|
||||
});
|
||||
};
|
||||
await informServer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
export declare namespace RelationId {
|
||||
const enum Session {
|
||||
Partner = "session-partner"
|
||||
}
|
||||
const enum ToDo {
|
||||
Collaborator = "toDo-collaborator"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export {};
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
declare const _default: (import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "system", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "passport", import("..").BRC<import("../oak-app-domain").EntityDict>>)[];
|
||||
declare const _default: (import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "message", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "address", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "application", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "article", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "articleMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "extraFile", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "user", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "userEntityGrant", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatQrCode", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "notification", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatLogin", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "parasite", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "sessionMessage", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMenu", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatPublicTag", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "wechatMpJump", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "system", import("..").BRC<import("../oak-app-domain").EntityDict>> | import("oak-domain/lib/types").Trigger<import("../oak-app-domain").EntityDict, "passport", import("..").BRC<import("../oak-app-domain").EntityDict>>)[];
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export declare function createToDo<ED extends EntityDict & BaseEntityDict, T ext
|
|||
redirectTo: EntityDict['toDo']['OpSchema']['redirectTo'];
|
||||
entity: any;
|
||||
entityId: string;
|
||||
}, userIds?: string[]): Promise<0 | 1>;
|
||||
}, userIds?: string[]): Promise<1 | 0>;
|
||||
/**
|
||||
* 完成todo例程,当在entity对象上进行action操作时(操作条件是filter),将对应的todo完成
|
||||
* 必须在entity的action的后trigger中调用
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export declare class ExtraFile<ED extends EntityDict> extends Feature {
|
|||
registerCos(clazzes: Array<new () => Cos<ED>>): void;
|
||||
addLocalFile(id: string, file: File | string): void;
|
||||
removeLocalFiles(ids: string[]): void;
|
||||
upload(id: string, entity: keyof ED): Promise<void>;
|
||||
upload(id: string): Promise<void>;
|
||||
getUrl(extraFile?: EntityDict['extraFile']['OpSchema'] | EntityDict['extraFile']['Schema'] | null, style?: string): string;
|
||||
getFileState(id: string): {
|
||||
state: FileState;
|
||||
|
|
|
|||
|
|
@ -34,42 +34,39 @@ class ExtraFile extends Feature_1.Feature {
|
|||
ids.forEach((id) => (0, lodash_1.unset)(this.files, id));
|
||||
this.publish();
|
||||
}
|
||||
async upload(id, entity) {
|
||||
async upload(id) {
|
||||
/**
|
||||
* 这个函数假设了前台知道后台会产生modi的行为和数据结构,不是很好的设计
|
||||
*/
|
||||
const { toModi } = this.cache.getSchema()[entity];
|
||||
let modiEntityId = '';
|
||||
const getExtraFileData = () => {
|
||||
if (toModi) {
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
data: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: entity,
|
||||
targetEntity: 'extraFile',
|
||||
action: 'create',
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
},
|
||||
});
|
||||
modiEntityId = modi.entityId;
|
||||
return modi.data;
|
||||
const [extraFile] = this.cache.get('extraFile', {
|
||||
data: Projection_1.extraFileProjection,
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
if (extraFile) {
|
||||
return extraFile;
|
||||
}
|
||||
else {
|
||||
const [extraFile] = this.cache.get('extraFile', {
|
||||
data: Projection_1.extraFileProjection,
|
||||
// 否则再去modi中查看
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
data: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
},
|
||||
filter: {
|
||||
targetEntity: 'extraFile',
|
||||
action: 'create',
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
return extraFile;
|
||||
}
|
||||
},
|
||||
});
|
||||
modiEntityId = modi.entityId;
|
||||
return modi.data;
|
||||
};
|
||||
const extraFile = getExtraFileData();
|
||||
(0, assert_1.assert)(extraFile && extraFile.uploadState === 'uploading');
|
||||
|
|
@ -102,30 +99,10 @@ class ExtraFile extends Feature_1.Feature {
|
|||
id,
|
||||
},
|
||||
};
|
||||
if (toModi) {
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'modi',
|
||||
operation: {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
entity: entity,
|
||||
entityId: modiEntityId,
|
||||
data: operation.data,
|
||||
action: 'update',
|
||||
filter: operation.filter,
|
||||
targetEntity: 'extraFile',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
operation,
|
||||
});
|
||||
}
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
operation,
|
||||
});
|
||||
};
|
||||
await informServer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
export declare namespace RelationId {
|
||||
const enum Session {
|
||||
Partner = "session-partner"
|
||||
}
|
||||
const enum ToDo {
|
||||
Collaborator = "toDo-collaborator"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
|
|
@ -139,10 +139,7 @@ export default OakComponent({
|
|||
promises.push(
|
||||
(async () => {
|
||||
try {
|
||||
await this.features.extraFile.upload(
|
||||
id,
|
||||
entity
|
||||
);
|
||||
await this.features.extraFile.upload(id);
|
||||
} catch (err) {
|
||||
failureIds.push(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,41 +51,40 @@ export class ExtraFile<ED extends EntityDict> extends Feature {
|
|||
this.publish();
|
||||
}
|
||||
|
||||
async upload(id: string, entity: keyof ED) {
|
||||
async upload(id: string) {
|
||||
/**
|
||||
* 这个函数假设了前台知道后台会产生modi的行为和数据结构,不是很好的设计
|
||||
*/
|
||||
const { toModi } = this.cache.getSchema()[entity];
|
||||
let modiEntityId = '';
|
||||
const getExtraFileData = () => {
|
||||
if (toModi) {
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
data: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
},
|
||||
filter: {
|
||||
entity: entity as string,
|
||||
targetEntity: 'extraFile',
|
||||
action: 'create',
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
},
|
||||
});
|
||||
modiEntityId = modi.entityId!;
|
||||
return modi.data as ED['extraFile']['OpSchema'];
|
||||
} else {
|
||||
const [extraFile] = this.cache.get('extraFile', {
|
||||
data: extraFileProjection,
|
||||
const [extraFile] = this.cache.get('extraFile', {
|
||||
data: extraFileProjection,
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
if (extraFile) {
|
||||
return extraFile;
|
||||
}
|
||||
|
||||
// 否则再去modi中查看
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
data: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
},
|
||||
filter: {
|
||||
targetEntity: 'extraFile',
|
||||
action: 'create',
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
return extraFile as ED['extraFile']['OpSchema'];
|
||||
}
|
||||
},
|
||||
});
|
||||
modiEntityId = modi.entityId!;
|
||||
return modi.data as ED['extraFile']['OpSchema'];
|
||||
};
|
||||
|
||||
const extraFile = getExtraFileData();
|
||||
|
|
@ -125,29 +124,10 @@ export class ExtraFile<ED extends EntityDict> extends Feature {
|
|||
id,
|
||||
},
|
||||
} as ED['extraFile']['Operation'];
|
||||
if (toModi) {
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'modi',
|
||||
operation: {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: await generateNewIdAsync(),
|
||||
entity: entity as string,
|
||||
entityId: modiEntityId,
|
||||
data: operation.data,
|
||||
action: 'update',
|
||||
filter: operation.filter,
|
||||
targetEntity: 'extraFile',
|
||||
},
|
||||
} as ED['modi']['Operation'],
|
||||
});
|
||||
} else {
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
operation,
|
||||
});
|
||||
}
|
||||
await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
operation,
|
||||
});
|
||||
};
|
||||
await informServer();
|
||||
}
|
||||
|
|
@ -196,9 +176,9 @@ export class ExtraFile<ED extends EntityDict> extends Feature {
|
|||
|
||||
getFileState(id: string):
|
||||
| {
|
||||
state: FileState;
|
||||
percentage?: number;
|
||||
}
|
||||
state: FileState;
|
||||
percentage?: number;
|
||||
}
|
||||
| undefined {
|
||||
if (this.files[id]) {
|
||||
return this.files[id];
|
||||
|
|
|
|||
Loading…
Reference in New Issue