Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(protocol): add protocol package (#6816)
白熱0da09ac9ca43
diff --git a/common/shared/package.json b/common/shared/package.jsonindex 636b1c661d..737041d413 100644--- a/common/shared/package.json+++ b/common/shared/package.json@@ -53,7 +53,7 @@"@types/fs-extra": "^11.0.4","@univerjs/icons": "^1.1.1","@univerjs/icons-svg": "^1.1.1",- "@univerjs/protocol": "0.1.49",+ "@univerjs/protocol": "workspace:*","typescript": "^6.0.2","vue-tsc": "^3.2.6"}diff --git a/common/shared/tsdown/configs/umd.ts b/common/shared/tsdown/configs/umd.tsindex c98a97664b..340623f489 100644--- a/common/shared/tsdown/configs/umd.ts+++ b/common/shared/tsdown/configs/umd.ts@@ -55,7 +55,7 @@ function resolveUmdGlobal(source: string) {}if (source.startsWith('@univerjs')) {- if (source === '@univerjs/protocol' || source === '@univerjs/icons') {+ if (source === '@univerjs/icons') {return null;}diff --git a/common/shared/tsdown/utils/cleanup-pkg.ts b/common/shared/tsdown/utils/cleanup-pkg.tsindex a8a2cf7242..f911e1d84b 100644--- a/common/shared/tsdown/utils/cleanup-pkg.ts+++ b/common/shared/tsdown/utils/cleanup-pkg.ts@@ -46,7 +46,7 @@ interface IDerivedDependencyGroups {const SOURCE_EXTS = new Set(['.ts', '.tsx']);const TEST_FILE_RE = /\.(spec|test)\.[cm]?tsx?$/;-const IMMUTABLE_MANAGED_DEPENDENCIES = new Set(['@univerjs/icons', '@univerjs/icons-svg', '@univerjs/protocol']);+const IMMUTABLE_MANAGED_DEPENDENCIES = new Set(['@univerjs/icons', '@univerjs/icons-svg']);function filterPackageName(packageName: string): string {if (packageName.startsWith('@univerjs/')) {diff --git a/packages/core/package.json b/packages/core/package.jsonindex 351ce1f4e4..67c5a7be6d 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -74,7 +74,7 @@"rxjs": ">=7.0.0"},"dependencies": {- "@univerjs/protocol": "0.1.49",+ "@univerjs/protocol": "workspace:*","@univerjs/themes": "workspace:*","@wendellhu/redi": "1.1.1","async-lock": "^1.4.1",diff --git a/packages/core/src/services/authz-io/authz-io-local.service.ts b/packages/core/src/services/authz-io/authz-io-local.service.tsindex 71b6d625d0..46e4531176 100644--- a/packages/core/src/services/authz-io/authz-io-local.service.ts+++ b/packages/core/src/services/authz-io/authz-io-local.service.ts@@ -14,7 +14,21 @@* limitations under the License.*/-import type { IActionInfo, IAllowedRequest, IBatchAllowedResponse, ICollaborator, ICreateRequest, ICreateRequest_SelectRangeObject, IListPermPointRequest, IPermissionPoint, IPutCollaboratorsRequest, IUnitRoleKV, IUpdatePermPointRequest, UnitAction, UnitObject } from '@univerjs/protocol';+import type {+ IActionInfo,+ IAllowedRequest,+ IBatchAllowedResponse,+ ICollaborator,+ ICreateRequest,+ ICreateRequestSelectRangeObject,+ IListPermPointRequest,+ IPermissionPoint,+ IPutCollaboratorsRequest,+ IUnitRoleKV,+ IUpdatePermPointRequest,+ UnitAction,+ UnitObject,+} from '@univerjs/protocol';import type { IAuthzIoService } from './type';import { ObjectScope, UnitRole } from '@univerjs/protocol';import { Inject } from '../../common/di';@@ -33,7 +47,7 @@ interface IPermissionData {name: string;unitID: string;strategies: Array<{ action: UnitAction; role: UnitRole }>;- selectRangeObject?: ICreateRequest_SelectRangeObject;+ selectRangeObject?: ICreateRequestSelectRangeObject;}/**diff --git a/packages/data-validation/package.json b/packages/data-validation/package.jsonindex becf61a106..b4e6369861 100644--- a/packages/data-validation/package.json+++ b/packages/data-validation/package.json@@ -67,7 +67,7 @@},"devDependencies": {"@univerjs-infra/shared": "workspace:*",- "@univerjs/protocol": "0.1.49",+ "@univerjs/protocol": "workspace:*","@univerjs/sheets": "workspace:*","rxjs": "^7.8.2","typescript": "^6.0.2",diff --git a/packages/protocol/README.md b/packages/protocol/README.mdnew file mode 100644index 0000000000..b27acdd3a6--- /dev/null+++ b/packages/protocol/README.md@@ -0,0 +1 @@+# @univerjs/protocldiff --git a/packages/protocol/package.json b/packages/protocol/package.jsonnew file mode 100644index 0000000000..3cb4dff6c0--- /dev/null+++ b/packages/protocol/package.json@@ -0,0 +1,70 @@+{+ "name": "@univerjs/protocol",+ "version": "0.20.1",+ "private": false,+ "author": "DreamNum <[email protected]>",+ "license": "Apache-2.0",+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/univer"+ },+ "homepage": "https://univer.ai",+ "repository": {+ "type": "git",+ "url": "https://github.com/dream-num/univer"+ },+ "bugs": {+ "url": "https://github.com/dream-num/univer/issues"+ },+ "keywords": [+ "univer"+ ],+ "exports": {+ ".": "./src/index.ts",+ "./*": "./src/*"+ },+ "main": "./src/index.ts",+ "types": "./lib/types/index.d.ts",+ "publishConfig": {+ "access": "public",+ "main": "./lib/es/index.js",+ "module": "./lib/es/index.js",+ "exports": {+ ".": {+ "import": "./lib/es/index.js",+ "require": "./lib/cjs/index.js",+ "types": "./lib/types/index.d.ts"+ },+ "./*": {+ "import": "./lib/es/*",+ "require": "./lib/cjs/*",+ "types": "./lib/types/index.d.ts"+ },+ "./lib/*": "./lib/*"+ }+ },+ "directories": {+ "lib": "lib"+ },+ "files": [+ "lib"+ ],+ "scripts": {+ "test": "vitest run",+ "test:watch": "vitest",+ "coverage": "vitest run --coverage",+ "typecheck": "tsc --noEmit",+ "build:bundle": "univer-cli build",+ "build:types": "tsc -p tsconfig.node.json",+ "build": "pnpm run build:bundle && pnpm run build:types"+ },+ "dependencies": {+ "@grpc/grpc-js": "^1.14.3"+ },+ "devDependencies": {+ "@univerjs-infra/shared": "workspace:*",+ "rxjs": "^7.8.2",+ "typescript": "^6.0.2",+ "vitest": "^4.1.4"+ }+}diff --git a/packages/protocol/src/index.ts b/packages/protocol/src/index.tsnew file mode 100644index 0000000000..b971c3b855--- /dev/null+++ b/packages/protocol/src/index.ts@@ -0,0 +1,242 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export type {+ IDeserializedSheetBlock,+ IGetDeserializedSheetBlockResponse,+} from './other/sheet-block';++export type {+ IChangeset,+ ICommand,+ IMutation,+} from './ts/univer/changeset';+export {+ CommentSolvedStatus,+ CommentUpdateEventType,+ type ICollaMsg,+ type ICollaMsgErrorEvent,+ type ICollaMsgJoin,+ type ICollaMsgLeave,+ type ICommentUpdate,+ type ILiveShareNewHost,+ type ILiveShareOperation,+ type ILiveShareOperationOperation,+ type ILiveShareRequestHost,+ type ILiveShareTerminate,+ type IShouldCloseConn,+ type IUniscriptRun,+ type IUpdateCursor,+ type IUpdatePermissionObj,+} from './ts/univer/colla-msg';+export {+ ErrorCode,+ type IError,+} from './ts/univer/constants/errors';+export { UniverType } from './ts/univer/constants/univer';++export type { IDocumentMeta } from './ts/univer/doc';+export {+ CellType,+ type IInitialSheet,+ type IRow,+ type IRowCell,+} from './ts/univer/initial-sheet';+export type {+ IUnitRoleKV,+} from './ts/univer/permission';+export {+ ObjectScope,+ UnitAction,+ UnitObject,+ UnitRole,+} from './ts/univer/permission';+export type { IRange } from './ts/univer/range';++export type {+ ISnapshot,+ ITableInfo,+} from './ts/univer/snapshot';++export {+ CellValueType,+ type ICellData,+ type ISheetBlock,+ type ISheetBlockMeta,+ type IWorkbookMeta,+ type IWorksheetMeta,+} from './ts/univer/workbook';++export type {+ IRecord,+} from './ts/univercloud/stats/v1/stats';++export {+ IRecordType,+} from './ts/univercloud/stats/v1/stats';++export {+ type IApplyRequest,+ type IApplyResponse,+ type ICreateUnitRequest,+ type ICreateUnitResponse,+ type IDirectWriteRequest,+ type IDirectWriteResponse,+ type IDisposeRequest,+ type IDisposeResponse,+ type IEnsureSnapshotRequest,+ type IEnsureSnapshotResponse,+ type IForkUnitRequest,+ type IForkUnitResponse,+ type IGetUnitRawContentRequest,+ type IGetUnitRawContentResponse,+ type IPreloadUnitRequest,+ type IPreloadUnitResponse,+ type IWorkbookCreateMeta,+} from './ts/univerpro/v1/apply';++export {+ type ICollaborationHelperService,+ type ICreateLatestSnapshotInBackgroundRequest,+ type ICreateLatestSnapshotInBackgroundResponse,+} from './ts/univerpro/v1/helper';++export type {+ IComputeRequest,+ IComputeResponse,+ IGetPreprocessRangesRequest,+ IGetPreprocessRangesResponse,+ IGetValuesRequest,+ IGetValuesResponse,+ ITableInfoList,+} from './ts/univerpro/v1/ssc';++export type {+ IGetSSRRequest,+ IGetSSRResponse,+} from './ts/univerpro/v1/ssr';++export type {+ IAccessKeyService,+} from './ts/universer/v1/access-key';++export type {+ IActionInfo,+ IAllowedRequest,+ IAllowedResponse,+ IAuthzService,+ IBatchAllowedResponse,+ ICollaborator,+ ICreateCollaboratorRequest,+ ICreateRequest,+ ICreateRequestSelectRangeObject,+ ICreateResponse,+ IDeleteCollaboratorRequest,+ IDeleteCollaboratorResponse,+ IListCollaboratorRequest,+ IListCollaboratorResponse,+ IListPermPointRequest,+ IListPermPointResponse,+ IListRolesRequest,+ IListRolesResponse,+ IPermissionPoint,+ IPutCollaboratorsRequest,+ IPutCollaboratorsResponse,+ IUpdateCollaboratorRequest,+ IUpdateCollaboratorResponse,+ IUpdatePermPointRequest,+} from './ts/universer/v1/authz';++export {+ CmdRspCode,+ CombCmd,+ type ICombJoinRequest,+ type ICombJoinResponse,+ type ICombLeaveRequest,+ type ICombService,+ type IMember,+ type INewChangesRequest,+ type INewChangesResponse,+} from './ts/universer/v1/comb';++export type {+ IAddCommentRequest,+ IAddCommentResponse,+ IDeleteCommentRequest,+ IDeleteCommentResponse,+ IEditCommentRequest,+ IEditCommentResponse,+ IListCommentsRequest,+ IListCommentsResponse,+ IReply,+ IReplyCommentRequest,+ IReplyCommentResponse,+ ISolvedCommentRequest,+ ISolvedCommentResponse,+ IThread,+} from './ts/universer/v1/comment';++export {+ FileSource,+ type IFileService,+ type IFileUploadRequest,+} from './ts/universer/v1/file';++export type {+ ICreateHistoryRequest,+ ICreateHistoryResponse,+ IGetHistoryCsRequest,+ IGetHistoryCsResponse,+ IHistoryService,+} from './ts/universer/v1/history';++export type {+ IGetUserLicenseResponse,+ ILicenseService,+} from './ts/universer/v1/license';++export {+ type ICopyFileMetaRequest,+ type ICopyFileMetaResponse,+ type IFetchMissingChangesetsRequest,+ type IFetchMissingChangesetsResponse,+ type IGetLatestCsReqIdBySidRequest,+ type IGetLatestCsReqIdBySidResponse,+ type IGetResourcesRequest,+ type IGetResourcesResponse,+ type IGetSheetBlockRequest,+ type IGetSheetBlockResponse,+ type IGetUnitOnRevRequest,+ type IGetUnitOnRevResponse,+ type IReportUnitRoutingStatsRequest,+ type IReportUnitRoutingStatsResponse,+ type ISaveChangesetRequest,+ type ISaveChangesetResponse,+ type ISaveSheetBlockRequest,+ type ISaveSheetBlockResponse,+ type ISaveSnapshotRequest,+ type ISaveSnapshotResponse,+ type ISnapshotService,+} from './ts/universer/v1/snapshot';++export type {+ IGetSessionTicketResponse,+ IGetUserResponse,+ IListUsersResponse,+ IUser,+} from './ts/universer/v1/user';++export { isError } from './utils';diff --git a/packages/protocol/src/other/sheet-block.ts b/packages/protocol/src/other/sheet-block.tsnew file mode 100644index 0000000000..40ee6e3003--- /dev/null+++ b/packages/protocol/src/other/sheet-block.ts@@ -0,0 +1,30 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IError } from '../ts/univer/constants/errors';++export interface IGetDeserializedSheetBlockResponse {+ error: IError | undefined;+ block: IDeserializedSheetBlock | undefined;+}++export interface IDeserializedSheetBlock {+ /** block id, generate by backend server */+ id: string;+ startRow: number;+ endRow: number;+ data: object;+}diff --git a/packages/protocol/src/ts/univer/changeset.ts b/packages/protocol/src/ts/univer/changeset.tsnew file mode 100644index 0000000000..67303cba11--- /dev/null+++ b/packages/protocol/src/ts/univer/changeset.ts@@ -0,0 +1,59 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { UniverType } from './constants/univer';++/** It should be the same as `ICommandInfo` in the frontend. */+export interface IMutation {+ /** ID of the mutation */+ id: string;+ /** serialized params */+ data: string;+}++/** It should be the same as `ICommand` in the frontend. */+export interface ICommand {+ /** ID of the command */+ id: string;+ /** serizlized params */+ data: string;+}++export interface IChangeset {+ /** unitID of the Univer document */+ unitID: string;+ type: UniverType;+ baseRev: number;+ revision: number;+ userID: string;+ mutations: IMutation[];+ memberID: string;+ /** sid works with reqId, represent the id of a unit edit session */+ sid?:+ | string+ | undefined;+ /** reqId works with sid, should be monotonically increasing and begin with 1 in the same edit session */+ reqId?:+ | number+ | undefined;+ /** mutationSize is the size of all mutations in bytes */+ mutationSize?:+ | number+ | undefined;+ /** additionalFields is a reserved field for future use */+ additionalFields?: string | undefined;+ createTime?: number | undefined;+}diff --git a/packages/protocol/src/ts/univer/colla-msg.ts b/packages/protocol/src/ts/univer/colla-msg.tsnew file mode 100644index 0000000000..41552d0bc0--- /dev/null+++ b/packages/protocol/src/ts/univer/colla-msg.ts@@ -0,0 +1,216 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IChangeset } from './changeset';+import type { IUnitPermissionStrategy, IUser, ObjectScope, UnitRole, UnitShareScope } from './permission';++export interface ICollaMsg {+ eventID: string;+ joinEvent?: ICollaMsgJoin | undefined;+ leaveEvent?: ICollaMsgLeave | undefined;+ newCsEvent?: INewChangesets | undefined;+ csAckEvent?: IChangesetAck | undefined;+ csRejEvent?: IChangesetRej | undefined;+ updateCursorEvent?: IUpdateCursor | undefined;+ liveShareRequestHost?: ILiveShareRequestHost | undefined;+ liveShareNewHost?: ILiveShareNewHost | undefined;+ liveShareOperation?: ILiveShareOperation | undefined;+ liveShareTerminate?: ILiveShareTerminate | undefined;+ errorEvent?: ICollaMsgErrorEvent | undefined;+ permissionRejEvent?:+ | IPermissionRej+ | undefined;+ /** eventID: "should_close_conn" */+ shouldCloseConn?: IShouldCloseConn | undefined;+ commentUpdateEvent?:+ | ICommentUpdate+ | undefined;+ /** envntID: "update_collaborator" */+ updateCollaboratorEvent?:+ | IUpdateCollaborator+ | undefined;+ /** eventID: "update_permission_obj" */+ updatePermissionObjEvent?:+ | IUpdatePermissionObj+ | undefined;+ /** eventID: "changeset_should_retry" */+ csShouldRetryEvent?:+ | IChangesetShouldRetry+ | undefined;+ /** eventID: "uniscript.run" */+ uniscriptRunEvent?: IUniscriptRun | undefined;+}++export interface ICollaMsgJoin {+ memberID: string;+ name: string;+ avatar: string;+}++export interface ICollaMsgLeave {+ memberID: string;+ name: string;+}++interface INewChangesets {+ cs: IChangeset | undefined;+}++interface IChangesetAck {+ cs: IChangeset | undefined;+}++interface IChangesetRej {+ cs: IChangeset | undefined;+}++interface IChangesetShouldRetry {+ cs: IChangeset | undefined;+}++export interface IUpdateCursor {+ unitID: string;+ /**+ * IMember ID of the user in the collaboration session.+ * If a user open a document multi times, there will be different memberIDs.+ */+ memberID: string;+ selection: string;+}++export interface ILiveShareRequestHost {+ unitID: string;+ userID: string;+}++export interface ILiveShareNewHost {+ presenter: string;+ unitID: string;+ userID: string;+}++export interface ILiveShareOperation {+ unitID: string;+ presenter: string;+ /** key is Operation.id */+ operations: { [key: string]: ILiveShareOperationOperation };+}++export interface ILiveShareOperationOperation {+ id: string;+ params?: string | undefined;+}++export interface ILiveShareTerminate {+ unitID: string;+}++/** define msg for errors */+export interface ICollaMsgErrorEvent {+ code: number;+ reason: string;+}++interface IPermissionRej {+ cs: IChangeset | undefined;+}++export interface ICommentUpdate {+ memberId: string;+ userId: string;+ unitId: string;+ threadId: string;+ type: CommentUpdateEventType;+ replyId?:+ | string+ | undefined;+ /** Set when solve or reopen Otherwise, it will be null */+ solved?:+ | CommentSolvedStatus+ | undefined;+ /** Set when edit or new comment reply. Otherwise, it will be null */+ content?:+ | string+ | undefined;+ /** Set true when Create or Edit comment. Otherwise, it will be null */+ createTimestamp?: string | undefined;+ user?: IUser | undefined;+}++export enum CommentSolvedStatus {+ OpenOrReOpen = 0,+ Solved = 1,+ UNRECOGNIZED = -1,+}++export enum CommentUpdateEventType {+ Unknown = 0,+ Add = 1,+ Reply = 2,+ Edit = 3,+ Delete = 4,+ Solve = 5,+ UNRECOGNIZED = -1,+}++export interface IShouldCloseConn {+ /** enum, ["logout", "roleChange"] */+ reason: string;+}++interface IUpdateCollaborator {+ role: UnitRole;+ /** enum, ["update", "delete"] */+ operation: string;+ userId: string;+}++export interface IUpdatePermissionObj {+ objectId: string;+ strategies: IUnitPermissionStrategy[];+ share: IUpdatePermissionObjShare | undefined;+ scope: IUpdatePermissionObjScope | undefined;+}++interface IUpdatePermissionObjShare {+ scope: UnitShareScope;+ role: UnitRole;+}++interface IUpdatePermissionObjScope {+ edit: ObjectScope;+ read: ObjectScope;+}++export interface IUniscriptRun {+ /** name of uniscript */+ name: string;+ /** content of uniscirpt */+ script: string;+ /** id of uniscript */+ scriptId: string;+ function: string;+ /**+ * argsOfFunction is a json string, it should be a list of arguments+ * e.g. '[123, "hello", true, {"a": 1, "b": 2}]'+ */+ argsOfFunction?:+ | string+ | undefined;+ /** executionId for script logs record. */+ executionId: string;+ compiledScript: string;+}diff --git a/packages/protocol/src/ts/univer/constants/errors.ts b/packages/protocol/src/ts/univer/constants/errors.tsnew file mode 100644index 0000000000..eb399433dc--- /dev/null+++ b/packages/protocol/src/ts/univer/constants/errors.ts@@ -0,0 +1,139 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum ErrorCode {+ /** UNDEFINED - general codes */+ UNDEFINED = 0,+ OK = 1,+ INTERNAL_ERROR = 2,+ PERMISSION_DENIED = 3,+ NOT_FOUND = 4,+ UNAUTHENTICATED = 5,+ ALREADY_EXISTS = 6,+ INVALID_ARGUMENT = 7,+ TOO_MANY_REQUESTS = 8,+ COMPLETION_FINISHED = 9,+ /** LOGIN_FAILED - login */+ LOGIN_FAILED = 10,+ MOBILE_VERIFY_CODE_MISMATCH = 11,+ MOBILE_VERIFY_CODE_NOT_FOUND_OR_EXPIRED = 12,+ EMAIL_VERIFY_CODE_MISMATCH = 13,+ EMAIL_VERIFY_CODE_NOT_FOUND_OR_EXPIRED = 14,+ AUTHORIZE_CODE_ILLEGAL = 15,+ LOGIN_TOKEN_PROCESSING_FAILED = 16,+ /** CURRENT_STATUS_CANNOT_OPERATE - biz cmn codes with 100 shift */+ CURRENT_STATUS_CANNOT_OPERATE = 100,+ ERROR_AGAIN = 101,+ /** USER_NOT_FOUND - user codes with 200 shift */+ USER_NOT_FOUND = 201,+ USER_IS_ANONYMOUS = 202,+ /** CHANGESET_REVISION_CONFILICT - changeset codes with 5000 shift */+ CHANGESET_REVISION_CONFILICT = 5001,+ /** SNAPSHOT_INVALID_SNAPSHOT - snapshotError codes with 6000 shift */+ SNAPSHOT_INVALID_SNAPSHOT = 6001,+ SNAPSHOT_HAS_BEEN_REMOVED = 6002,+ ENSURE_SNAPSHOT_EXECUTION = 6003,+ /** APPLY_REJECT - apply service codes with 7000 shift */+ APPLY_REJECT = 7001,+ /** APPLY_NON_SEQUENTIAL_REVISION - apply service expects sequential revisions, otherwise return this code */+ APPLY_NON_SEQUENTIAL_REVISION = 7002,+ /** APPLY_REVISION_CONFILICT - save changeset failed because of revision exists */+ APPLY_REVISION_CONFILICT = 7003,+ /** APPLY_PERMISSION_DENIED - apply failed because of the user permission denied */+ APPLY_PERMISSION_DENIED = 7004,+ /** APPLY_DUPLICATED - if the changeset has been applied before, return this code */+ APPLY_DUPLICATED = 7005,+ /** CONNECTOR_DATA_TOO_LARGE - connector codes with 8000 shift */+ CONNECTOR_DATA_TOO_LARGE = 8001,+ /** LICENSE_MAX_UNITS_EXCEEDED - license code with 9000 shift */+ LICENSE_MAX_UNITS_EXCEEDED = 9001,+ LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED = 9002,+ LICENSE_IMPORT_SIZE_EXCEEDED = 9003,+ LICENSE_EXPORT_SIZE_EXCEEDED = 9004,+ /** LICENSE_DISTRO_REJECTED - the feature not allowed for the distro */+ LICENSE_DISTRO_REJECTED = 9005,+ /** YUUMI_UNABLE_LOAD_URL - yuumi */+ YUUMI_UNABLE_LOAD_URL = 10001,+ YUUMI_URL_COL_OUT_OF_RANGE = 10002,+ YUUMI_RATE_OVER_LIMIT = 10003,+ YUUMI_SUBSCRIPTION_NOT_FOUND = 10004,+ /** YUUMI_NO_CUBOID_FOR_QUESTION - yuumi AI */+ YUUMI_NO_CUBOID_FOR_QUESTION = 10010,+ YUUMI_ASYNCIO_CANCELLED = 10011,+ YUUMI_TABLE_NOT_FOUND_IN_UNIT = 10012,+ YUUMI_ALL_TABLES_IS_INVALID = 10013,+ YUUMI_PROMPT_MAX_TOKENS_EXCEEDED = 10014,+ YUUMI_AI_RUN_FAILED = 10015,+ YUUMI_CONNECTOR_URL_NOT_FOUND = 10016,+ /** PY_RUNTIME_SCRIPT_ERROR - py-runtime */+ PY_RUNTIME_SCRIPT_ERROR = 11001,+ /** INVITE_CODE_HAS_BEEN_UES - invite-code */+ INVITE_CODE_HAS_BEEN_UES = 12001,+ INVALID_INVITE_CODE = 12002,+ INVITE_CODE_REQUIRED = 12003,+ USER_NOT_INVITED_CODE = 12004,+ INVITE_CODE_ALREADY_BOUND = 12005,+ /** WECHAT_HAS_BEEN_BOUND - user profile */+ WECHAT_HAS_BEEN_BOUND = 13001,+ MOBILE_HAS_BEEN_BOUND = 13002,+ EMAIL_HAS_BEEN_BOUND = 13003,+ /** ENTITLE_CAN_NOT_BUY_LOWER_OTP - entitlement domain errors */+ ENTITLE_CAN_NOT_BUY_LOWER_OTP = 14001,+ /** ENTITLE_UPDOWN_GRADE_NOT_SUPPORT - subscription upgrade/downgrade is not supported */+ ENTITLE_UPDOWN_GRADE_NOT_SUPPORT = 14002,+ /** ENTITLE_DUP_SUBSCRIPTION - duplicate subscription */+ ENTITLE_DUP_SUBSCRIPTION = 14003,+ /** PAYMENT_CHANNEL_NOT_SUPPORT - payment channel is not supported */+ PAYMENT_CHANNEL_NOT_SUPPORT = 14004,+ /** ENTITLE_INVALID_COUPON_CODE - invalid coupon code */+ ENTITLE_INVALID_COUPON_CODE = 14005,+ /** ENTITLE_COUPON_EXPIRED - coupon expired */+ ENTITLE_COUPON_EXPIRED = 14006,+ /** ENTITLE_COUPON_USED_UP - coupon used up */+ ENTITLE_COUPON_USED_UP = 14007,+ /** ENTITLE_USE_COUPON_NOT_1ST_TRADE - not the first purchase, cannot use coupon */+ ENTITLE_USE_COUPON_NOT_1ST_TRADE = 14008,+ /** ENTITLE_CHAT_LIMIT_EXCEED - chat rate limit exceeded */+ ENTITLE_CHAT_LIMIT_EXCEED = 14101,+ /** ENTITLE_REPORT_LIMIT_EXCEED - report rate limit exceeded */+ ENTITLE_REPORT_LIMIT_EXCEED = 14102,+ /** ENTITLE_INSUFFICIENT_QUOTA - insufficient quota */+ ENTITLE_INSUFFICIENT_QUOTA = 14103,+ /** ENTITLE_NEED_BILLING_ADDRESS - billing address required */+ ENTITLE_NEED_BILLING_ADDRESS = 14301,+ /** REDEMPTION_INVALID_CODE - redemption code domain errors */+ REDEMPTION_INVALID_CODE = 15001,+ /** REDEMPTION_CODE_INACTIVE - code inactive */+ REDEMPTION_CODE_INACTIVE = 15002,+ /** REDEMPTION_CODE_FULLY_REDEEMED - fully redeemed */+ REDEMPTION_CODE_FULLY_REDEEMED = 15003,+ /** REDEMPTION_CODE_NOT_STARTED - not started yet */+ REDEMPTION_CODE_NOT_STARTED = 15004,+ /** REDEMPTION_USER_NOT_ELIGIBLE - user not eligible */+ REDEMPTION_USER_NOT_ELIGIBLE = 15005,+ /** REDEMPTION_USER_REDEEM_TIMES_EXCEED - user redemption limit exceeded */+ REDEMPTION_USER_REDEEM_TIMES_EXCEED = 15006,+ /** REDEMPTION_CODE_HAS_BEEN_CREATED - redemption code already exists */+ REDEMPTION_CODE_HAS_BEEN_CREATED = 15007,+ /** DATA_SOURCE_TOO_LARGE - data source errors */+ DATA_SOURCE_TOO_LARGE = 16001,+ UNRECOGNIZED = -1,+}++export interface IError {+ code: ErrorCode;+ message: string;+}diff --git a/packages/protocol/src/ts/univer/constants/univer.ts b/packages/protocol/src/ts/univer/constants/univer.tsnew file mode 100644index 0000000000..852d878234--- /dev/null+++ b/packages/protocol/src/ts/univer/constants/univer.ts@@ -0,0 +1,24 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum UniverType {+ UNIVER_UNKNOWN = 0,+ UNIVER_DOC = 1,+ UNIVER_SHEET = 2,+ UNIVER_SLIDE = 3,+ UNIVER_PROJECT = 4,+ UNRECOGNIZED = -1,+}diff --git a/packages/protocol/src/ts/univer/doc.ts b/packages/protocol/src/ts/univer/doc.tsnew file mode 100644index 0000000000..73651ec082--- /dev/null+++ b/packages/protocol/src/ts/univer/doc.ts@@ -0,0 +1,28 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IResource } from './resource';++export interface IDocumentMeta {+ unitID: string;+ rev: number;+ creator: string;+ name: string;+ /** The key is sheet id */+ resources: IResource[];+ /** The original meta data in JSON format. */+ originalMeta: Uint8Array;+}diff --git a/packages/protocol/src/ts/univer/drawing.ts b/packages/protocol/src/ts/univer/drawing.tsnew file mode 100644index 0000000000..de9b969535--- /dev/null+++ b/packages/protocol/src/ts/univer/drawing.ts@@ -0,0 +1,22 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export interface IDrawingMeta {+ unitID: string;+ name: string;+ /** The original meta data in JSON format. */+ originalMeta: Uint8Array;+}diff --git a/packages/protocol/src/ts/univer/initial-sheet.ts b/packages/protocol/src/ts/univer/initial-sheet.tsnew file mode 100644index 0000000000..3e7f8a958b--- /dev/null+++ b/packages/protocol/src/ts/univer/initial-sheet.ts@@ -0,0 +1,50 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum CellType {+ UNDEFINED = 0,+ TEXT = 1,+ URL = 2,+ IMAGE = 3,+ UNRECOGNIZED = -1,+}++export interface IInitialSheet {+ sheetName: string;+ columnName: string[];+ rows: IRow[];+ /** If true, do not apply filter plugin */+ disableFilter?: boolean | undefined;+}++export interface IRowCell {+ type: CellType;+ text: string;+ url: string;+ /** Optional style information */+ style?: IStyle | undefined;+}++interface IStyle {+ /** Background color */+ bg: string;+ /** Text color */+ cl: string;+}++export interface IRow {+ cells: IRowCell[];+}diff --git a/packages/protocol/src/ts/univer/permission.ts b/packages/protocol/src/ts/univer/permission.tsnew file mode 100644index 0000000000..b122afad82--- /dev/null+++ b/packages/protocol/src/ts/univer/permission.ts@@ -0,0 +1,139 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum UnitAction {+ View = 0,+ Edit = 1,+ ManageCollaborator = 2,+ Print = 3,+ /** Duplicate - create a copy */+ Duplicate = 4,+ Comment = 5,+ Copy = 6,+ Share = 7,+ Export = 8,+ /** @deprecated */+ MoveWorksheet = 9,+ /** @deprecated */+ DeleteWorksheet = 10,+ /** @deprecated */+ HideWorksheet = 11,+ /** @deprecated */+ RenameWorksheet = 12,+ /** @deprecated */+ CreateWorksheet = 13,+ /** @deprecated */+ SetWorksheetStyle = 14,+ /** @deprecated */+ EditWorksheetCell = 15,+ InsertHyperlink = 16,+ Sort = 17,+ Filter = 18,+ PivotTable = 19,+ /** @deprecated */+ FloatImg = 20,+ /** @deprecated */+ IHistory = 21,+ /**+ * RwHgtClWdt - row height, column width+ *+ * @deprecated+ */+ RwHgtClWdt = 22,+ /**+ * ViemRwHgtClWdt - row height, column width in view mode+ *+ * @deprecated+ */+ ViemRwHgtClWdt = 23,+ /**+ * ViewFilter - filter in view mode+ *+ * @deprecated+ */+ ViewFilter = 24,+ MoveSheet = 25,+ /** DeleteSheet - delete the sub sheet */+ DeleteSheet = 26,+ HideSheet = 27,+ CopySheet = 28,+ RenameSheet = 29,+ CreateSheet = 30,+ SelectProtectedCells = 31,+ SelectUnProtectedCells = 32,+ SetCellStyle = 33,+ SetCellValue = 34,+ SetRowStyle = 35,+ SetColumnStyle = 36,+ InsertRow = 37,+ InsertColumn = 38,+ DeleteRow = 39,+ DeleteColumn = 40,+ EditExtraObject = 41,+ /** Delete - delete the unit file */+ Delete = 42,+ RecoverHistory = 43,+ ViewHistory = 44,+ CreatePermissionObject = 45,+ UNRECOGNIZED = -1,+}++export enum UnitRole {+ Reader = 0,+ Editor = 1,+ Owner = 2,+ UNRECOGNIZED = -1,+}++export enum UnitObject {+ Unkonwn = 0,+ Workbook = 1,+ Worksheet = 2,+ SelectRange = 3,+ Document = 4,+ Slide = 5,+ UNRECOGNIZED = -1,+}++export enum UnitShareScope {+ Private = 0,+ Public = 1,+ Organization = 2,+ UNRECOGNIZED = -1,+}++export enum ObjectScope {+ SomeCollaborator = 0,+ AllCollaborator = 1,+ OneSelf = 2,+ UNRECOGNIZED = -1,+}++export interface IUnitRoleKV {+ role: UnitRole;+ name: string;+}++export interface IUnitPermissionStrategy {+ role: UnitRole;+ action: UnitAction;+}++export interface IUser {+ userID: string;+ name: string;+ avatar: string;+}diff --git a/packages/protocol/src/ts/univer/range.ts b/packages/protocol/src/ts/univer/range.tsnew file mode 100644index 0000000000..e2ee493a17--- /dev/null+++ b/packages/protocol/src/ts/univer/range.ts@@ -0,0 +1,24 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export interface IRange {+ startRow: number;+ endRow: number;+ startColumn: number;+ endColumn: number;+ unitId?: string | undefined;+ sheetId?: string | undefined;+}diff --git a/packages/protocol/src/ts/univer/resource.ts b/packages/protocol/src/ts/univer/resource.tsnew file mode 100644index 0000000000..f3a2131ee9--- /dev/null+++ b/packages/protocol/src/ts/univer/resource.ts@@ -0,0 +1,21 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export interface IResource {+ id?: string | undefined;+ name: string;+ data: string;+}diff --git a/packages/protocol/src/ts/univer/snapshot.ts b/packages/protocol/src/ts/univer/snapshot.tsnew file mode 100644index 0000000000..26d03075ae--- /dev/null+++ b/packages/protocol/src/ts/univer/snapshot.ts@@ -0,0 +1,36 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { UniverType } from './constants/univer';+import type { IDocumentMeta } from './doc';+import type { IWorkbookMeta } from './workbook';++export interface ISnapshot {+ /** unitID of the Univer document */+ unitID: string;+ type: UniverType;+ rev: number;+ workbook: IWorkbookMeta | undefined;+ doc: IDocumentMeta | undefined;+}++export interface ITableInfo {+ /** json:ITableInfo */+ meta: Uint8Array;+ dataPath: string;+ /** A matrix of values in JSON format. use in IGetPreprocessRangesResponse */+ data?: string | undefined;+}diff --git a/packages/protocol/src/ts/univer/unit-template.ts b/packages/protocol/src/ts/univer/unit-template.tsnew file mode 100644index 0000000000..57521574ff--- /dev/null+++ b/packages/protocol/src/ts/univer/unit-template.ts@@ -0,0 +1,24 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++/** ICustomCellTemplate is the template used for make some drawing on sheet, like draw a cute mario XD. */+export interface ICustomCellTemplate {+ rowCount: number;+ colCount: number;+ rowHeight: number;+ colWidth: number;+ showGridlines: number;+}diff --git a/packages/protocol/src/ts/univer/univer-file.ts b/packages/protocol/src/ts/univer/univer-file.tsnew file mode 100644index 0000000000..b77830aa1c--- /dev/null+++ b/packages/protocol/src/ts/univer/univer-file.ts@@ -0,0 +1,29 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { UniverType } from './constants/univer';+import type { IDocumentMeta } from './doc';+import type { IDrawingMeta } from './drawing';+import type { IWorkbookMeta } from './workbook';++export interface IUnit {+ unitID: string;+ name: string;+ type: UniverType;+ workbook?: IWorkbookMeta | undefined;+ document?: IDocumentMeta | undefined;+ drawing?: IDrawingMeta | undefined;+}diff --git a/packages/protocol/src/ts/univer/workbook.ts b/packages/protocol/src/ts/univer/workbook.tsnew file mode 100644index 0000000000..d4bef82d1e--- /dev/null+++ b/packages/protocol/src/ts/univer/workbook.ts@@ -0,0 +1,100 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IDocumentMeta } from './doc';+import type { IResource } from './resource';++export enum CellValueType {+ UNKNOWN = 0,+ STRING = 1,+ NUMBER = 2,+ BOOLEAN = 3,+ FORCE_STRING = 4,+ UNRECOGNIZED = -1,+}++export interface IWorksheetMeta {+ type: number;+ id: string;+ name: string;+ rowCount: number;+ columnCount: number;+ /** The original meta data in JSON format. Cell data is excluded. */+ originalMeta: Uint8Array;+}++export interface IWorkbookMeta {+ unitID: string;+ rev: number;+ creator: string;+ name: string;+ sheetOrder: string[];+ /** The key is sheet id */+ sheets: { [key: string]: IWorksheetMeta };+ /**+ * Questions: should snapshot server read the celldata?+ * map<string, univer.IResource> resources = 8; // The key is sheet id+ */+ resources: IResource[];+ /** The key is sheet id */+ blockMeta: { [key: string]: ISheetBlockMeta };+ /** The original meta data in JSON format. Cell data is excluded. */+ originalMeta: Uint8Array;+}++interface ICellValue {+ strV?: string | undefined;+ numV?: number | undefined;+ boolV?: boolean | undefined;+}++/** Represents the data for a cell. */+export interface ICellData {+ /** The value of the cell. */+ v:+ | ICellValue+ | undefined;+ /** The type of the cell value. */+ t: CellValueType;+ /** univer doc */+ p:+ | IDocumentMeta+ | undefined;+ /** style */+ s: string;+ /** formula */+ f: string;+ /** formula refId */+ si: string;+ /** formula ref, e.g. "A1:B2", reversed for array formulas */+ ref: string;+ /** New Excel formulas need to add prefixes for differentiation, e.g., _xlfn._xlws. _xlfn. _xlws. _xludf. */+ xf: string;+}++export interface ISheetBlock {+ /** block id, generate by backend server */+ id: string;+ startRow: number;+ endRow: number;+ data: Uint8Array;+}++export interface ISheetBlockMeta {+ sheetID: string;+ /** sheet block ids */+ blocks: string[];+}diff --git a/packages/protocol/src/ts/univercloud/stats/v1/stats.ts b/packages/protocol/src/ts/univercloud/stats/v1/stats.tsnew file mode 100644index 0000000000..d25ba286fd--- /dev/null+++ b/packages/protocol/src/ts/univercloud/stats/v1/stats.ts@@ -0,0 +1,34 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export enum IRecordType {+ /** Unknown - don't use */+ Unknown = 0,+ Colla = 1,+ Import = 2,+ Export = 3,+ ICreateUnit = 4,+ UNRECOGNIZED = -1,+}++export interface IRecord {+ /** name: key */+ k: IRecordType;+ /** name: label */+ l: { [key: string]: string };+ /** name: value */+ v: number;+}diff --git a/packages/protocol/src/ts/univerpro/v1/apply.ts b/packages/protocol/src/ts/univerpro/v1/apply.tsnew file mode 100644index 0000000000..7399ea7a2b--- /dev/null+++ b/packages/protocol/src/ts/univerpro/v1/apply.ts@@ -0,0 +1,157 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IChangeset, ICommand, IMutation } from '../../univer/changeset';+import type { IError } from '../../univer/constants/errors';+import type { UniverType } from '../../univer/constants/univer';+import type { IInitialSheet } from '../../univer/initial-sheet';+import type { ISnapshot } from '../../univer/snapshot';+import type { ICustomCellTemplate } from '../../univer/unit-template';++export interface IForkUnitRequest {+ sourceUnitId: string;+ targetUnitId: string;+ type: UniverType;+}++export interface IForkUnitResponse {+ error: IError | undefined;+ snapshot: ISnapshot | undefined;+}++export interface IGetUnitRawContentRequest {+ unitID: string;+ type: UniverType;+ subUnitID: string;+}++export interface IGetUnitRawContentResponse {+ error: IError | undefined;+ initialSheet: IInitialSheet | undefined;+ dataStream: string;+}++/** The meta required to create a new unit. */+export interface IWorkbookCreateMeta {+ /**+ * If you want to create an empty sheet, make this undefined or a empty+ * string.+ */+ templateID?:+ | string+ | undefined;+ /** Name of the unit. It should be localized. */+ name: string;+ /** Locale of the unit. */+ locale: string;+ customCell?:+ | ICustomCellTemplate+ | undefined;+ /** Other meta in the future. */+ docContent: string;+}++export interface ICreateUnitRequest {+ unitID: string;+ type: UniverType;+ name: string;+ creator: string;+ /** If `type` is UniverType.UNIVER_SHEEET, this is requried. */+ workbookMeta?:+ | IWorkbookCreateMeta+ | undefined;+ /** Other meta for other types of univer. */+ initialSheets: IInitialSheet[];+ workbookDataJson: string;+}++export interface ICreateUnitResponse {+ error: IError | undefined;+ sheetOrder: string[];+}++/**+ * IApplyRequest is almost the same as a IChangeset.+ * See `changeset.proto` for details.+ */+export interface IApplyRequest {+ unitID: string;+ type: UniverType;+ /** changeset to apply */+ changeset:+ | IChangeset+ | undefined;+ /** changsetset to fast forward to, these cs has been applied to the document */+ fastForward: IChangeset[];+}++export interface IApplyResponse {+ error:+ | IError+ | undefined;+ /** The revision of the document right now */+ revision: number;+}++export interface IDirectWriteRequest {+ unitID: string;+ type: UniverType;+ body: IDirectWriteBody | undefined;+ userID: string;+}++interface IDirectWriteBody {+ unitID: string;+ type: UniverType;+ userID: string;+ /** ICommand to be executed. Not that you must provide a on of commands or mutations, not both. */+ commands: ICommand[];+ /** ICommand to be executed. Not that you must provide a on of commands or mutations, not both. */+ mutations: IMutation[];+}++export interface IDirectWriteResponse {+ error: IError | undefined;+ revision: number;+}++export interface IDisposeRequest {+ unitID: string;+}++export interface IDisposeResponse {+ error: IError | undefined;+}++export interface IEnsureSnapshotRequest {+ unitID: string;+ type: UniverType;+ revision: number;+}++export interface IEnsureSnapshotResponse {+ error: IError | undefined;+ snapshot: ISnapshot | undefined;+}++export interface IPreloadUnitRequest {+ unitID: string;+ type: UniverType;+}++export interface IPreloadUnitResponse {+ error: IError | undefined;+}diff --git a/packages/protocol/src/ts/univerpro/v1/helper.ts b/packages/protocol/src/ts/univerpro/v1/helper.tsnew file mode 100644index 0000000000..bbe2fe54a4--- /dev/null+++ b/packages/protocol/src/ts/univerpro/v1/helper.ts@@ -0,0 +1,43 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IError } from '../../univer/constants/errors';+import type { UniverType } from '../../univer/constants/univer';+import type { IEnsureSnapshotRequest, IEnsureSnapshotResponse } from './apply';++export interface ICreateLatestSnapshotInBackgroundRequest {+ unitID: string;+ type: UniverType;+}++export interface ICreateLatestSnapshotInBackgroundResponse {+ error: IError | undefined;+}++export interface ICollaborationHelperService {+ /**+ * Ensure the snapshot at a given number would be saved to the snapshot service+ * without fetching it back. Normally used for background saving.+ */+ CreateLatestSnapshotInBackground(+ request: ICreateLatestSnapshotInBackgroundRequest,+ metadata?: Metadata,+ ): Observable<ICreateLatestSnapshotInBackgroundResponse>;+ /** from IApplyService */+ EnsureSnapshot(request: IEnsureSnapshotRequest, metadata?: Metadata): Observable<IEnsureSnapshotResponse>;+}diff --git a/packages/protocol/src/ts/univerpro/v1/ssc.ts b/packages/protocol/src/ts/univerpro/v1/ssc.tsnew file mode 100644index 0000000000..4d0cd8beed--- /dev/null+++ b/packages/protocol/src/ts/univerpro/v1/ssc.ts@@ -0,0 +1,81 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IError } from '../../univer/constants/errors';+import type { IRange } from '../../univer/range';+import type { ITableInfo } from '../../univer/snapshot';+import type { ISheetBlockMeta } from '../../univer/workbook';++export enum responseDataMode {+ /** none - no data, default */+ none = 0,+ /** all - all data */+ all = 1,+ /** sample - sample data */+ sample = 2,+ UNRECOGNIZED = -1,+}++export interface IGetPreprocessRangesRequest {+ unitId: string;+ rev: number;+ /** use string, see responseDataMode enum, default is "none" */+ responseDataMode?: string | undefined;+}++export interface ITableInfoList {+ tableInfos: ITableInfo[];+}++export interface IGetPreprocessRangesResponse {+ error: IError | undefined;+ tableInfo: { [key: string]: ITableInfoList };+}++export interface IGetValuesRequest {+ workbookId: string;+ worksheetId: string;+ range: IRange | undefined;+}++export interface IGetValuesResponse {+ error:+ | IError+ | undefined;+ /** A matrix of values in JSON format. */+ value: string;+}++export interface IComputeRequest {+ /** The id of the unit to be computed. */+ workbookId: string;+ /**+ * The revision of the unit to be computed. If not specified or set to 0, the SSC service+ * will fetch the latest version at the request time.+ */+ revision: number;+ /** Timeout in milliseconds. Default is 30s. */+ timeout: number;+}++export interface IComputeResponse {+ error:+ | IError+ | undefined;+ /** Of which revision the unit is processed on. */+ revision: number;+ sscBlock: { [key: string]: ISheetBlockMeta };+}diff --git a/packages/protocol/src/ts/univerpro/v1/ssr.ts b/packages/protocol/src/ts/univerpro/v1/ssr.tsnew file mode 100644index 0000000000..2923498c8d--- /dev/null+++ b/packages/protocol/src/ts/univerpro/v1/ssr.ts@@ -0,0 +1,33 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IError } from '../../univer/constants/errors';+import type { UniverType } from '../../univer/constants/univer';++export interface IGetSSRRequest {+ unitId: string;+ type: UniverType;+ /** It is the id of a worksheet for Univer Sheet, or the id of a page for Univer Slide. */+ subUnitId: string;+}++export interface IGetSSRResponse {+ error:+ | IError+ | undefined;+ /** PNG Image encoded in base64 format. */+ imageEncoded: string;+}diff --git a/packages/protocol/src/ts/universer/v1/access-key.ts b/packages/protocol/src/ts/universer/v1/access-key.tsnew file mode 100644index 0000000000..1d01849f02--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/access-key.ts@@ -0,0 +1,59 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IError } from '../../univer/constants/errors';++interface IAccessKey {+ recordId: string;+ accessKey: string;+ createdAt: number;+ agent: boolean;+ description: string;+}++interface ICreateAccessKeyRequest {+ agent: boolean;+ description?: string | undefined;+}++interface ICreateAccessKeyResponse {+ error: IError | undefined;+ accessKey: IAccessKey | undefined;+}++interface IListAccessKeysRequest {+}++interface IListAccessKeysResponse {+ error: IError | undefined;+ accessKeys: IAccessKey[];+}++interface IDeleteAccessKeyRequest {+ recordId: string;+}++interface IDeleteAccessKeyResponse {+ error: IError | undefined;+}++export interface IAccessKeyService {+ CreateAccessKey(request: ICreateAccessKeyRequest, metadata?: Metadata): Observable<ICreateAccessKeyResponse>;+ ListAccessKeys(request: IListAccessKeysRequest, metadata?: Metadata): Observable<IListAccessKeysResponse>;+ DeleteAccessKey(request: IDeleteAccessKeyRequest, metadata?: Metadata): Observable<IDeleteAccessKeyResponse>;+}diff --git a/packages/protocol/src/ts/universer/v1/authz.ts b/packages/protocol/src/ts/universer/v1/authz.tsnew file mode 100644index 0000000000..add1d18360--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/authz.ts@@ -0,0 +1,244 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IError } from '../../univer/constants/errors';+import type {+ IUnitPermissionStrategy,+ IUnitRoleKV,+ IUser,+ ObjectScope,+ UnitAction,+ UnitObject,+ UnitRole,+ UnitShareScope,+} from '../../univer/permission';++export interface ICollaborator {+ id: string;+ role: UnitRole;+ subject: IUser | undefined;+}++interface IObjScope {+ edit: ObjectScope;+ read: ObjectScope;+}++export interface IPermissionPoint {+ objectID: string;+ unitID: string;+ objectType: UnitObject;+ name: string;+ /** @deprecated */+ shareOn: boolean;+ shareRole: UnitRole;+ creator: IUser | undefined;+ strategies: IUnitPermissionStrategy[];+ actions: IActionInfo[];+ shareScope: UnitShareScope;+ scope: IObjScope | undefined;+}++export interface ICreateRequest {+ objectType: UnitObject;+ selectRangeObject?: ICreateRequestSelectRangeObject | undefined;+ worksheetObject?: ICreateRequestWorksheetObject | undefined;+}++export interface ICreateRequestSelectRangeObject {+ collaborators: ICollaborator[];+ unitID: string;+ name: string;+ scope: IObjScope | undefined;+}++interface ICreateRequestWorksheetObject {+ collaborators: ICollaborator[];+ unitID: string;+ name: string;+ strategies: IUnitPermissionStrategy[];+ scope: IObjScope | undefined;+}++export interface ICreateResponse {+ error: IError | undefined;+ objectID: string;+}++export interface IUpdatePermPointRequest {+ objectType: UnitObject;+ objectID: string;+ unitID: string;+ share: IUpdatePermPointRequestShare | undefined;+ name: string;+ strategies: IUnitPermissionStrategy[];+ scope: IObjScope | undefined;+ collaborators: IUpdatePermPointRequestCollaborators | undefined;+}++interface IUpdatePermPointRequestShare {+ /** @deprecated */+ on: boolean;+ role: UnitRole;+ scope: UnitShareScope;+}++interface IUpdatePermPointRequestCollaborators {+ collaborators: ICollaborator[];+}++interface IUpdatePermPointResponse {+ error: IError | undefined;+}++export interface IListPermPointRequest {+ unitID: string;+ objectIDs: string[];+ actions: UnitAction[];+}++export interface IListPermPointResponse {+ error: IError | undefined;+ objects: IPermissionPoint[];+}++export interface ICreateCollaboratorRequest {+ objectID: string;+ unitID: string;+ collaborators: ICollaborator[];+}++interface ICreateCollaboratorResponse {+ error: IError | undefined;+}++export interface IUpdateCollaboratorRequest {+ objectID: string;+ unitID: string;+ collaborator: ICollaborator | undefined;+}++export interface IUpdateCollaboratorResponse {+ error: IError | undefined;+}++export interface IDeleteCollaboratorRequest {+ objectID: string;+ unitID: string;+ collaboratorID: string;+}++export interface IDeleteCollaboratorResponse {+ error: IError | undefined;+}++export interface IListCollaboratorRequest {+ objectID: string;+ unitID: string;+}++export interface IListCollaboratorResponse {+ error: IError | undefined;+ collaborators: ICollaborator[];+ cfgEnableObjInherit: boolean;+}++export interface IPutCollaboratorsRequest {+ objectID: string;+ unitID: string;+ collaborators: ICollaborator[];+}++export interface IPutCollaboratorsResponse {+ error: IError | undefined;+}++export interface IAllowedRequest {+ objectID: string;+ objectType: UnitObject;+ unitID: string;+ actions: UnitAction[];+}++export interface IActionInfo {+ action?: UnitAction | undefined;+ allowed?: boolean | undefined;+}++export interface IAllowedResponse {+ error: IError | undefined;+ actions: IActionInfo[];+}++interface IBatchAllowedRequest {+ requests: IAllowedRequest[];+}++interface IObjectActionInfo {+ unitID: string;+ objectID: string;+ actions: IActionInfo[];+}++export interface IBatchAllowedResponse {+ error: IError | undefined;+ objectActions: IObjectActionInfo[];+}++export interface IListRolesRequest {+ objectType: UnitObject;+}++export interface IListRolesResponse {+ error: IError | undefined;+ roles: IUnitRoleKV[];+ actions: UnitAction[];+ defaultStrategies: IUnitPermissionStrategy[];+}++export interface IAuthzService {+ /** create a permission mount point for specified type of object */+ Create(request: ICreateRequest, metadata?: Metadata): Observable<ICreateResponse>;+ /**+ * update a permission mount point+ * selectrange and worksheet may not used if unit record the permission point in mutation by itself.+ * workbook and document use it to set share mode.+ */+ Update(request: IUpdatePermPointRequest, metadata?: Metadata): Observable<IUpdatePermPointResponse>;+ /**+ * list all permission mount points for unit+ * it may not used if unit record the permission point in mutation by itself+ */+ List(request: IListPermPointRequest, metadata?: Metadata): Observable<IListPermPointResponse>;+ /** request a couple of actions, return the allowed actions */+ Allowed(request: IAllowedRequest, metadata?: Metadata): Observable<IAllowedResponse>;+ /** barch check if the actions are allowed */+ BatchAllowed(request: IBatchAllowedRequest, metadata?: Metadata): Observable<IBatchAllowedResponse>;+ /** list object roles for specified object */+ ListRoles(request: IListRolesRequest, metadata?: Metadata): Observable<IListRolesResponse>;+ /** new collaborator for specified object */+ CreateCollaborator(request: ICreateCollaboratorRequest, metadata?: Metadata): Observable<ICreateCollaboratorResponse>;+ /** list all collaborators for specified object */+ ListCollaborators(request: IListCollaboratorRequest, metadata?: Metadata): Observable<IListCollaboratorResponse>;+ /** update collaborator for specified object */+ IUpdateCollaborator(request: IUpdateCollaboratorRequest, metadata?: Metadata): Observable<IUpdateCollaboratorResponse>;+ /** delete collaborator for specified object */+ DeleteCollaborator(request: IDeleteCollaboratorRequest, metadata?: Metadata): Observable<IDeleteCollaboratorResponse>;+ /** put collaborators for specified object */+ PutCollaborators(request: IPutCollaboratorsRequest, metadata?: Metadata): Observable<IPutCollaboratorsResponse>;+}diff --git a/packages/protocol/src/ts/universer/v1/comb.ts b/packages/protocol/src/ts/universer/v1/comb.tsnew file mode 100644index 0000000000..7b928cb9a6--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/comb.ts@@ -0,0 +1,129 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IChangeset } from '../../univer/changeset';+import type { IError } from '../../univer/constants/errors';+import type { UniverType } from '../../univer/constants/univer';++interface IEmpty {+}++/** more details: https://c3fgartrp2.feishu.cn/docx/OS47dk8BCo1ZeKxXiNvcDLuZn2g#PymGdupuyoYfvTxv1EBciV7in9b */+export enum CombCmd {+ /** UNKNOWN_CMD - unknown cmd */+ UNKNOWN_CMD = 0,+ /** HELLO - call hello to get comb info, this is essential after you connect to the server */+ HELLO = 1,+ /** JOIN - call join to join couple of rooms */+ JOIN = 2,+ /** LEAVE - call leave to leave a room */+ LEAVE = 3,+ /** INGEST - call ingest to broadcast a message to a room */+ INGEST = 4,+ /** HEARTBEAT - call heartbeat to keep the connection alive */+ HEARTBEAT = 5,+ /**+ * RECV - RECV not a cmd actually, you never call a RECV cmd.+ * when you receive a message from comb(may be created by another user), the cmd will be RECV+ */+ RECV = 6,+ UNRECOGNIZED = -1,+}++export enum CmdRspCode {+ UNKNOWN_CODE = 0,+ OK = 1,+ FAIL = 2,+ /**+ * JOIN_ROOM_FULL - 1000~1999 room related+ * max room member reached+ */+ JOIN_ROOM_FULL = 1001,+ /** JOIN_ROOM_NOT_EXISTS - the specified room does not exists */+ JOIN_ROOM_NOT_EXISTS = 1002,+ /** JOIN_ROOM_PERMISSION_DENIED - has no permission to join the room */+ JOIN_ROOM_PERMISSION_DENIED = 1003,+ /** GLOBAL_ROOMS_CNT_EXCEEDS - global live collaboration rooms count exceeds */+ GLOBAL_ROOMS_CNT_EXCEEDS = 1004,+ UNRECOGNIZED = -1,+}++interface IBroadcastRequest {+ roomID: string;+ message: string;+}++export interface INewChangesRequest {+ unitID: string;+ memberID: string;+ type: UniverType;+ changeset: IChangeset | undefined;+}++export interface INewChangesResponse {+ error: IError | undefined;+}++interface ICombJoinInfo {+ roomID: string;+ /** extra args for joining the room */+ args: string;+}++export interface ICombJoinRequest {+ rooms: ICombJoinInfo[];+}++export interface ICombJoinResponse {+ roomInfos: { [key: string]: ICombJoinResponseRoomInfo };+}++interface ICombJoinResponseRoomInfo {+ roomID: string;+ members: IMember[];+}++export interface ICombLeaveRequest {+ roomID: string;+ /** extra args for leaving the room */+ args: string;+}++export interface IMember {+ memberID: string;+ name: string;+ avatar?: string | undefined;+}++interface IRule {+ /** exclude member */+ excludeMember: string[];+ /** only member */+ onlyMember: string[];+ tunnel: IRuleTunnel | undefined;+}++interface IRuleTunnel {+ name: string;+ value: string;+}++export interface ICombService {+ NewChanges(request: INewChangesRequest, metadata?: Metadata): Observable<INewChangesResponse>;+ Broadcast(request: IBroadcastRequest, metadata?: Metadata): Observable<IEmpty>;+}diff --git a/packages/protocol/src/ts/universer/v1/comment.ts b/packages/protocol/src/ts/universer/v1/comment.tsnew file mode 100644index 0000000000..75e6ad2113--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/comment.ts@@ -0,0 +1,104 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { CommentSolvedStatus } from '../../univer/colla-msg';+import type { IError } from '../../univer/constants/errors';+import type { IUser } from '../../univer/permission';++export interface IReply {+ threadId: string;+ replyId: string;+ content: string;+ userId: string;+ createTimestamp: number;+}++export interface IThread {+ threadId: string;+ solved: CommentSolvedStatus;+ replies: IReply[];+}++export interface IAddCommentRequest {+ memberId: string;+ unitId: string;+ content: string;+ mention: string[];+}++export interface IAddCommentResponse {+ error: IError | undefined;+ comment: IThread | undefined;+}++export interface IListCommentsRequest {+ unitId: string;+ threadId: string[];+}++export interface IListCommentsResponse {+ error: IError | undefined;+ comments: { [key: string]: IThread };+ users: { [key: string]: IUser };+}++export interface IReplyCommentRequest {+ memberId: string;+ unitId: string;+ threadId: string;+ content: string;+ mention: string[];+}++export interface IReplyCommentResponse {+ error: IError | undefined;+ reply: IReply | undefined;+}++export interface ISolvedCommentRequest {+ memberId: string;+ unitId: string;+ threadId: string;+ solved: CommentSolvedStatus;+}++export interface ISolvedCommentResponse {+ error: IError | undefined;+}++export interface IEditCommentRequest {+ memberId: string;+ unitId: string;+ threadId: string;+ replyId: string;+ content: string;+ mention: string[];+}++export interface IEditCommentResponse {+ error: IError | undefined;+}++export interface IDeleteCommentRequest {+ memberId: string;+ unitId: string;+ threadId: string;+ replyId?: string | undefined;+}++export interface IDeleteCommentResponse {+ error: IError | undefined;+}diff --git a/packages/protocol/src/ts/universer/v1/file.ts b/packages/protocol/src/ts/universer/v1/file.tsnew file mode 100644index 0000000000..1880854f66--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/file.ts@@ -0,0 +1,144 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IError } from '../../univer/constants/errors';++export enum FileSource {+ Undefined = 0,+ /** HttpImport - assign UserID */+ HttpImport = 1,+ /** HttpExport - assign UserID */+ HttpExport = 2,+ /** UnitEmbedded - assign UnitID */+ UnitEmbedded = 3,+ /** UnitSnapshot - assign UnitID */+ UnitSnapshot = 4,+ /** UserProfileImg - assign UserID */+ UserProfileImg = 5,+ /** ClipsheetFragments - assign UserID, fragmented file will be deleted after 30 days */+ ClipsheetFragments = 6,+ /** LLMInputData - assign UserID */+ LLMInputData = 7,+ UNRECOGNIZED = -1,+}++enum DownloadUrlMode {+ Default = 0,+ UseProxy = 1,+ UseDirect = 2,+ UNRECOGNIZED = -1,+}++interface ISignUrlRequest {+ fileID: string;+}++interface ISignUrlResponse {+ error: IError | undefined;+ url: string;+ mode: DownloadUrlMode;+}++interface IUploadFileRequestMeta {+ fileName: string;+ fileHash: string;+ fileSize: number;+ source: FileSource;+ assign: string;+}++export interface IFileUploadRequest {+ data?: Uint8Array | undefined;+ meta?: IUploadFileRequestMeta | undefined;+}++interface IUploadResponse {+ error: IError | undefined;+ fileID: string;+}++interface ISetUniverGoJsonRequest {+ jsonObj: string;+}++interface ISetUniverGoJsonResponse {+ error: IError | undefined;+}++interface IGetUniverGoJsonRequest {+}++interface IGetUniverGoJsonResponse {+ error: IError | undefined;+ jsonObj: string;+}++interface IPutTemplateResourceRequest {+ fileName: string;+}++interface IPutTemplateResourceResponse {+ error: IError | undefined;+ signUrl: string;+}++interface IPutFileByIdRequest {+ data?: Uint8Array | undefined;+ meta?: IPutFileByIdMeta | undefined;+}++interface IPutFileByIdMeta {+ fileId: string;+ fileSize: number;+}++interface IPutFileByIdResponse {+ error: IError | undefined;+ fileId: string;+}++interface ISignPutUrlRequest {+ fileSize: number;+ name?: string | undefined;+ source: FileSource;+}++interface ISignPutUrlResponse {+ error: IError | undefined;+ fileId: string;+ putUrl: string;+}++interface IDeleteFileByIdRequest {+ fileId: string;+}++interface IDeleteFileByIdResponse {+ error: IError | undefined;+}++export interface IFileService {+ SignUrl(request: ISignUrlRequest, metadata?: Metadata): Observable<ISignUrlResponse>;+ SignPutUrl(request: ISignPutUrlRequest, metadata?: Metadata): Observable<ISignPutUrlResponse>;+ Upload(request: Observable<IFileUploadRequest>, metadata?: Metadata): Observable<IUploadResponse>;+ SetUniverGoJson(request: ISetUniverGoJsonRequest, metadata?: Metadata): Observable<ISetUniverGoJsonResponse>;+ GetUniverGoJson(request: IGetUniverGoJsonRequest, metadata?: Metadata): Observable<IGetUniverGoJsonResponse>;+ PutTemplateResouce(request: IPutTemplateResourceRequest, metadata?: Metadata): Observable<IPutTemplateResourceResponse>;+ PutFileById(request: Observable<IPutFileByIdRequest>, metadata?: Metadata): Observable<IPutFileByIdResponse>;+ DeleteFileById(request: IDeleteFileByIdRequest, metadata?: Metadata): Observable<IDeleteFileByIdResponse>;+}diff --git a/packages/protocol/src/ts/universer/v1/history.ts b/packages/protocol/src/ts/universer/v1/history.tsnew file mode 100644index 0000000000..3238f10f95--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/history.ts@@ -0,0 +1,121 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IChangeset } from '../../univer/changeset';+import type { IError } from '../../univer/constants/errors';+import type { UniverType } from '../../univer/constants/univer';+import type { IUser } from '../../univer/permission';++enum IHistoryOrigin {+ HISTORY_ORIGIN_UNSPECIFIED = 0,+ HISTORY_ORIGIN_USER = 1,+ HISTORY_ORIGIN_CHARACTER = 2,+ UNRECOGNIZED = -1,+}++export interface ICreateHistoryRequest {+ unitId: string;+ subUnitId: string;+ type: UniverType;+ revision: number;+ additionalFields?: string | undefined;+}++export interface ICreateHistoryResponse {+ error: IError | undefined;+}++interface IHistory {+ /** @deprecated */+ userId: string;+ unitId: string;+ command: string[];+ createTime: string;+ recoverTime: string;+ startRevision: number;+ endRevision: number;+ /** additionalFields is a reserved field for future use */+ additionalFields?: string | undefined;+ origin?: IHistoryOrigin | undefined;+ startRevCreateTime: number;+ endRevCreateTime: number;+ userIds: string[];+}++interface IHistoryListRequest {+ length: number;+ lastLabel: string;+ unitId: string;+ origin?:+ | IHistoryOrigin+ | undefined;+ /** @deprecated */+ userId?: string | undefined;+ userIds: string[];+}++interface IHistoryEntities {+ datas: { [key: string]: IHistory };+ users: { [key: string]: IUser };+}++interface IHistoryListResponse {+ error: IError | undefined;+ hasMore: boolean;+ lastLabel: string;+ entities: IHistoryEntities | undefined;+ historyIds: string[];+}++interface IListHistoryCreatorsRequest {+ unitId: string;+}++interface IListHistoryCreatorsResponse {+ error: IError | undefined;+ creators: IListHistoryCreatorsResponseCreator[];+}++interface IListHistoryCreatorsResponseCreator {+ userId: string;+ name: string;+ avatar: string;+ origins: IHistoryOrigin[];+}++export interface IGetHistoryCsRequest {+ unitId: string;+ startRevision: number;+ endRevision: number;+}++export interface IGetHistoryCsResponse {+ error: IError | undefined;+ changesets: IChangeset[];+ users: { [key: string]: IUser };+}++export interface IHistoryService {+ GetHistoryList(request: IHistoryListRequest, metadata?: Metadata): Observable<IHistoryListResponse>;+ CreateHistory(request: ICreateHistoryRequest, metadata?: Metadata): Observable<ICreateHistoryResponse>;+ ListHistoryCreators(+ request: IListHistoryCreatorsRequest,+ metadata?: Metadata,+ ): Observable<IListHistoryCreatorsResponse>;+ GetHistoryCs(request: IGetHistoryCsRequest, metadata?: Metadata): Observable<IGetHistoryCsResponse>;+}diff --git a/packages/protocol/src/ts/universer/v1/license.ts b/packages/protocol/src/ts/universer/v1/license.tsnew file mode 100644index 0000000000..ae482146b7--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/license.ts@@ -0,0 +1,105 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IError } from '../../univer/constants/errors';++interface IStartFormulaTaskRequest {+ /** Task ID */+ taskId: string;+}++interface IStartFormulaTaskResponse {+ error: IError | undefined;+ limitInfo: IFormulaLimitInfo | undefined;+}++interface IGetFormulaLimitStatusRequest {+ /** Task ID */+ taskId: string;+}++interface IGetFormulaLimitStatusResponse {+ error: IError | undefined;+ limitInfo: IFormulaLimitInfo | undefined;+}++interface IReleaseFormulaTaskRequest {+ /** Task ID, used to identify the task to be released */+ taskId: string;+}++interface IReleaseFormulaTaskResponse {+ error: IError | undefined;+ limitInfo: IFormulaLimitInfo | undefined;+}++interface IFormulaLimitInfo {+ /** Maximum limit */+ maxFormulaLimit: number;+ /** Current usage */+ currentUsage: number;+ /** Available slots (maxFormulaLimit - currentUsage) */+ availableSlots: number;+ /** Whether execution permission has been granted */+ granted: boolean;+}++interface IGetLicenseQuotasRequest {+ data: string;+}++interface IGetLicenseQuotasResponse {+ error: IError | undefined;+ data: string;+}++interface IGetUserLicenseRequest {+}++export interface IGetUserLicenseResponse {+ error: IError | undefined;+ license: string;+ /**+ * deprecated license key+ *+ * @deprecated+ */+ key: string;+ /** license id */+ id1: string;+ /** user id */+ id2: string;+ /** license type */+ type: string;+ /** true - report /false - not report */+ isReport: boolean;+}++export interface ILicenseService {+ GetQuotas(request: IGetLicenseQuotasRequest, metadata?: Metadata): Observable<IGetLicenseQuotasResponse>;+ GetLicense(request: IGetUserLicenseRequest, metadata?: Metadata): Observable<IGetUserLicenseResponse>;+ /** Start task, apply for formula limit */+ StartFormulaTask(request: IStartFormulaTaskRequest, metadata?: Metadata): Observable<IStartFormulaTaskResponse>;+ /** Get formula limit status */+ GetFormulaLimitStatus(+ request: IGetFormulaLimitStatusRequest,+ metadata?: Metadata,+ ): Observable<IGetFormulaLimitStatusResponse>;+ /** Release formula limit (call after execution is complete) */+ ReleaseFormulaTask(request: IReleaseFormulaTaskRequest, metadata?: Metadata): Observable<IReleaseFormulaTaskResponse>;+}diff --git a/packages/protocol/src/ts/universer/v1/snapshot.ts b/packages/protocol/src/ts/universer/v1/snapshot.tsnew file mode 100644index 0000000000..4ab3dbee5c--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/snapshot.ts@@ -0,0 +1,388 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { Metadata } from '@grpc/grpc-js';+import type { Observable } from 'rxjs';+import type { IChangeset, ICommand, IMutation } from '../../univer/changeset';+import type { IError } from '../../univer/constants/errors';+import type { UniverType } from '../../univer/constants/univer';+import type { IInitialSheet } from '../../univer/initial-sheet';+import type { IResource } from '../../univer/resource';+import type { ISnapshot, ITableInfo } from '../../univer/snapshot';+import type { ICustomCellTemplate } from '../../univer/unit-template';+import type { IUnit } from '../../univer/univer-file';+import type { ISheetBlock, ISheetBlockMeta } from '../../univer/workbook';++interface IGetSnapshotMetaWithPreCalculatedRequest {+ /** The id of the unit to be computed. */+ workbookId: string;+ /**+ * The revision of the unit to be computed. If not specified or set to 0, the SSC service+ * will fetch the latest version at the request time.+ */+ revision: number;+}++interface IGetSnapshotMetaWithPreCalculatedResponse {+ error:+ | IError+ | undefined;+ /** Of which revision the unit is processed on. */+ revision: number;+ sscBlock: { [key: string]: ISheetBlockMeta };+}++interface IGetUnitMetaRequest {+ unitId: string;+}++interface IGetUnitMetaResponse {+ error: IError | undefined;+ unitId: string;+ name: string;+ creator: string;+ type: UniverType;+ createTime: string;+ updateTime: string;+}++interface IGetSheetTableInfoRequest {+ unitID: string;+ type: UniverType;+}++interface IGetSheetTableInfoResponse {+ error: IError | undefined;+ unitName: string;+ table: ISheetTable | undefined;+}++interface IGetSheetTableRequest {+ unitID: string;+ type: UniverType;+ tableId: string;+}++interface IGetSheetTableResponse {+ error: IError | undefined;+ tableData: Uint8Array;+}++export interface IForkUnitRequest {+ unitId: string;+ type: UniverType;+}++export interface IForkUnitResponse {+ error: IError | undefined;+ unitId: string;+}++export interface ICopyFileMetaRequest {+ fileMetaId: string;+}++export interface ICopyFileMetaResponse {+ error: IError | undefined;+ fileMetaId: string;+}++export interface IDirectWriteRequest {+ unitID: string;+ type: UniverType;+ commands: ICommand[];+ mutations: IMutation[];+}++export interface IDirectWriteResponse {+ error: IError | undefined;+ revision: number;+}++export interface IEnsureSnapshotRequest {+ unitID: string;+ type: UniverType;+ revision: number;+}++export interface IEnsureSnapshotResponse {+ error: IError | undefined;+ snapshot: ISnapshot | undefined;+}++interface IUpdateUnitRequest {+ type: UniverType;+ unitId: string;+ name: string;+ memberId: string;+}++interface IUpdateUnitResponse {+ error: IError | undefined;+}++export interface ICreateUnitRequest {+ type: UniverType;+ name: string;+ creator: string;+ locale: string;+ snapshot: ISnapshot | undefined;+ templateID: string;+ customCell?: ICustomCellTemplate | undefined;+ initialSheets: IInitialSheet[];+ docContent: string;+ preCreateUnitId: string;+ workbookDataJson: string;+ /** univer ai for exchange */+ table?:+ | ISheetTable+ | undefined;+ /** used for integration with customer system */+ idempotencyKey?:+ | string+ | undefined;+ /** used for integration with customer system, just store and pass through */+ metaData?: string | undefined;+}++export interface ICreateUnitResponse {+ error: IError | undefined;+ unitID: string;+ sheetOrder: string[];+}++export interface ISaveChangesetRequest {+ changeset: IChangeset | undefined;+ type: UniverType;+ originChangeset: IChangeset | undefined;+}++export interface ISaveChangesetResponse {+ error:+ | IError+ | undefined;+ /** concurrent is the changesets need to follow up. */+ concurrent: IChangeset[];+}++export interface IGetLatestCsReqIdBySidRequest {+ sid: string;+ unitID: string;+ userID: string;+}++export interface IGetLatestCsReqIdBySidResponse {+ /** set to default -1 if has no sid yet */+ latestReqID: number;+ error: IError | undefined;+}++export interface IFetchMissingChangesetsRequest {+ /** unitID of the Univer document */+ unitID: string;+ type: UniverType;+ /** exclude from revision, will return (from, latest] */+ from: number;+ /** include to revision, if to == 0 , will return (from, +inf] */+ to: number;+}++export interface IFetchMissingChangesetsResponse {+ error: IError | undefined;+ changesets: IChangeset[];+ latestRevision?: number | undefined;+}++export interface ISaveSnapshotRequest {+ unitID: string;+ type: UniverType;+ snapshot: ISnapshot | undefined;+}++export interface ISaveSnapshotResponse {+ error: IError | undefined;+}++interface IGetSnapshotRequest {+ unitID: string;+ type: UniverType;+ revision: number;+}++interface IGetSnapshotResponse {+ error: IError | undefined;+ snapshot: ISnapshot | undefined;+}++interface IGetLatestSnapshotRevisionRequest {+ unitID: string;+ type: UniverType;+}++interface IGetLatestSnapshotRevisionResponse {+ error: IError | undefined;+ latestRevision: number;+}++export interface IGetUnitOnRevRequest {+ unitID: string;+ type: UniverType;+ revision: number;+}++export interface IGetUnitOnRevResponse {+ error:+ | IError+ | undefined;+ /** the snapshot closest to revision */+ snapshot:+ | ISnapshot+ | undefined;+ /** the changesets need to follow up */+ changesets: IChangeset[];+}++export interface ISaveSheetBlockRequest {+ unitID: string;+ type: UniverType;+ /** no data */+ block: ISheetBlock | undefined;+ fileID?: string | undefined;+}++export interface ISaveSheetBlockResponse {+ error: IError | undefined;+ blockID: string;+}++export interface IGetSheetBlockRequest {+ unitID: string;+ type: UniverType;+ /** string sheetID = 3; */+ blockID: string;+}++export interface IGetSheetBlockResponse {+ error: IError | undefined;+ block: ISheetBlock | undefined;+}++export interface IGetResourcesRequest {+ unitID: string;+ type: UniverType;+ resourceIDs: string[];+}++export interface IGetResourcesResponse {+ error:+ | IError+ | undefined;+ /** key is resource id */+ resources: { [key: string]: IResource };+}++interface IListUnitsRequest {+ type: UniverType;+ nextCursor: string;+}++interface IListUnitsResponse {+ error: IError | undefined;+ units: IUnit[];+ nextCursor: string;+}++interface IDeleteUnitsRequest {+ unitIds: string[];+}++interface IDeleteUnitsResponse {+ error: IError | undefined;+}++interface ISheetTable {+ /** key: table-id */+ tables: { [key: string]: ITableInfo };+}++export interface IReportUnitRoutingStatsRequest {+ unitId: string;+ estimatedCells?:+ | number+ | undefined;+ /** precision: seconds */+ snapshotTime?:+ | number+ | undefined;+ /** precision: seconds, report in import scene. */+ importTime?: number | undefined;+}++export interface IReportUnitRoutingStatsResponse {+ error: IError | undefined;+}++export interface ISnapshotService {+ ICreateUnit(request: ICreateUnitRequest, metadata?: Metadata): Observable<ICreateUnitResponse>;+ UpdateUnit(request: IUpdateUnitRequest, metadata?: Metadata): Observable<IUpdateUnitResponse>;+ ListUnits(request: IListUnitsRequest, metadata?: Metadata): Observable<IListUnitsResponse>;+ DeleteUnits(request: IDeleteUnitsRequest, metadata?: Metadata): Observable<IDeleteUnitsResponse>;+ SaveChangeset(request: ISaveChangesetRequest, metadata?: Metadata): Observable<ISaveChangesetResponse>;+ GetLatestCsReqIdBySid(+ request: IGetLatestCsReqIdBySidRequest,+ metadata?: Metadata,+ ): Observable<IGetLatestCsReqIdBySidResponse>;+ FetchMissingChangesets(+ request: IFetchMissingChangesetsRequest,+ metadata?: Metadata,+ ): Observable<IFetchMissingChangesetsResponse>;+ /**+ * Save a snapshot to the database. If the snapshot of the unit at a given revision is already+ * saved, the request will be ignored.+ */+ SaveSnapshot(request: ISaveSnapshotRequest, metadata?: Metadata): Observable<ISaveSnapshotResponse>;+ /** Update a snapshot to the database. */+ UpdateSnapshot(request: ISaveSnapshotRequest, metadata?: Metadata): Observable<ISaveSnapshotResponse>;+ GetSnapshot(request: IGetSnapshotRequest, metadata?: Metadata): Observable<IGetSnapshotResponse>;+ GetLatestSnapshotRevision(+ request: IGetLatestSnapshotRevisionRequest,+ metadata?: Metadata,+ ): Observable<IGetLatestSnapshotRevisionResponse>;+ SaveSheetBlock(request: ISaveSheetBlockRequest, metadata?: Metadata): Observable<ISaveSheetBlockResponse>;+ GetSheetBlock(request: IGetSheetBlockRequest, metadata?: Metadata): Observable<IGetSheetBlockResponse>;+ GetUnitOnRev(request: IGetUnitOnRevRequest, metadata?: Metadata): Observable<IGetUnitOnRevResponse>;+ GetResources(request: IGetResourcesRequest, metadata?: Metadata): Observable<IGetResourcesResponse>;+ EnsureSnapshot(request: IEnsureSnapshotRequest, metadata?: Metadata): Observable<IEnsureSnapshotResponse>;+ /** Directly write a changeset with a user's identification to the document. */+ DirectWrite(request: IDirectWriteRequest, metadata?: Metadata): Observable<IDirectWriteResponse>;+ CopyFileMeta(request: ICopyFileMetaRequest, metadata?: Metadata): Observable<ICopyFileMetaResponse>;+ ForkUnit(request: IForkUnitRequest, metadata?: Metadata): Observable<IForkUnitResponse>;+ /** get table info */+ GetSheetTableInfo(request: IGetSheetTableInfoRequest, metadata?: Metadata): Observable<IGetSheetTableInfoResponse>;+ /** get table data */+ GetSheetTable(request: IGetSheetTableRequest, metadata?: Metadata): Observable<IGetSheetTableResponse>;+ /** get unit meta */+ GetUnitMeta(request: IGetUnitMetaRequest, metadata?: Metadata): Observable<IGetUnitMetaResponse>;+ /** Get formula calculation results */+ GetSnapshotMetaWithPreCalculated(+ request: IGetSnapshotMetaWithPreCalculatedRequest,+ metadata?: Metadata,+ ): Observable<IGetSnapshotMetaWithPreCalculatedResponse>;+ ReportUnitRoutingStats(+ request: IReportUnitRoutingStatsRequest,+ metadata?: Metadata,+ ): Observable<IReportUnitRoutingStatsResponse>;+}diff --git a/packages/protocol/src/ts/universer/v1/user.ts b/packages/protocol/src/ts/universer/v1/user.tsnew file mode 100644index 0000000000..7cdd9c7ca1--- /dev/null+++ b/packages/protocol/src/ts/universer/v1/user.ts@@ -0,0 +1,52 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IError } from '../../univer/constants/errors';++export interface IUser {+ userID: string;+ name: string;+ avatar: string;+ anonymous: boolean;+ canBindAnonymous: boolean;+ phone: string;+ email: string;+ createTimestamp: number;+}++interface IWechatUserInfo {+ nickName: string;+ avatarUrl: string;+}++export interface IGetUserResponse {+ error: IError | undefined;+ user:+ | IUser+ | undefined;+ /** wechat data */+ wechat: IWechatUserInfo | undefined;+}++export interface IListUsersResponse {+ error: IError | undefined;+ users: IUser[];+}++export interface IGetSessionTicketResponse {+ error: IError | undefined;+ ticket: string;+}diff --git a/packages/protocol/src/utils.ts b/packages/protocol/src/utils.tsnew file mode 100644index 0000000000..d040011454--- /dev/null+++ b/packages/protocol/src/utils.ts@@ -0,0 +1,35 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { IError } from './ts/univer/constants/errors';+import { ErrorCode } from './ts/univer/constants/errors';++/**+ * To examine if a response is an error.+ *+ * @param error error interface+ * @returns if the response is an error+ */+export function isError(error?: IError) {+ // WTF: sometimes returns from Universer does not have error.code+ // WTF: error code from HTTP is a string not a number+ // @ts-expect-error error code from HTTP is a string not a number+ if (error && error.code && error.code !== ErrorCode.OK && error.code !== 'OK') {+ return true;+ }++ return false;+}diff --git a/packages/protocol/tsconfig.json b/packages/protocol/tsconfig.jsonnew file mode 100644index 0000000000..d4f9172636--- /dev/null+++ b/packages/protocol/tsconfig.json@@ -0,0 +1,8 @@+{+ "extends": "@univerjs-infra/shared/tsconfigs/base",+ "compilerOptions": {+ "rootDir": "src",+ "outDir": "lib/types"+ },+ "include": ["src"]+}diff --git a/packages/protocol/tsconfig.node.json b/packages/protocol/tsconfig.node.jsonnew file mode 100644index 0000000000..2abfa07367--- /dev/null+++ b/packages/protocol/tsconfig.node.json@@ -0,0 +1,18 @@+{+ "extends": "@univerjs-infra/shared/tsconfigs/node",+ "compilerOptions": {+ "rootDir": "src",+ "declaration": true,+ "emitDeclarationOnly": true,+ "noEmit": false,+ "outDir": "lib/types"+ },+ "include": [+ "src"+ ],+ "exclude": [+ "src/**/__tests__/**",+ "src/**/*.spec.ts",+ "src/**/*.test.ts"+ ]+}diff --git a/packages/protocol/vitest.config.ts b/packages/protocol/vitest.config.tsnew file mode 100644index 0000000000..af97c6d7a2--- /dev/null+++ b/packages/protocol/vitest.config.ts@@ -0,0 +1,3 @@+import createConfig from '@univerjs-infra/shared/vitest';++export default createConfig();diff --git a/packages/sheets-data-validation/package.json b/packages/sheets-data-validation/package.jsonindex cd69f8ae58..3f329c2bd3 100644--- a/packages/sheets-data-validation/package.json+++ b/packages/sheets-data-validation/package.json@@ -78,7 +78,7 @@"@univerjs/core": "workspace:*","@univerjs/data-validation": "workspace:*","@univerjs/engine-formula": "workspace:*",- "@univerjs/protocol": "0.1.49",+ "@univerjs/protocol": "workspace:*","@univerjs/sheets": "workspace:*","@univerjs/sheets-formula": "workspace:*"},diff --git a/packages/sheets-ui/package.json b/packages/sheets-ui/package.jsonindex 57e341c73b..3c3aeac213 100644--- a/packages/sheets-ui/package.json+++ b/packages/sheets-ui/package.json@@ -88,7 +88,7 @@"@univerjs/engine-formula": "workspace:*","@univerjs/engine-render": "workspace:*","@univerjs/icons": "^1.1.1",- "@univerjs/protocol": "0.1.49",+ "@univerjs/protocol": "workspace:*","@univerjs/sheets": "workspace:*","@univerjs/telemetry": "workspace:*","@univerjs/ui": "workspace:*"diff --git a/packages/sheets/package.json b/packages/sheets/package.jsonindex b076e83cbd..948b7b407d 100644--- a/packages/sheets/package.json+++ b/packages/sheets/package.json@@ -83,7 +83,7 @@"@univerjs/core": "workspace:*","@univerjs/engine-formula": "workspace:*","@univerjs/engine-render": "workspace:*",- "@univerjs/protocol": "0.1.49",+ "@univerjs/protocol": "workspace:*","@univerjs/rpc": "workspace:*"},"devDependencies": {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d573205628..321ef68c61 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -385,8 +385,8 @@ importers:specifier: ^1.1.1version: 1.1.1'@univerjs/protocol':- specifier: 0.1.49- version: 0.1.49+ specifier: workspace:*+ version: link:../../packages/protocoltypescript:specifier: ^6.0.2version: 6.0.2@@ -772,8 +772,8 @@ importers:packages/core:dependencies:'@univerjs/protocol':- specifier: 0.1.49- version: 0.1.49+ specifier: workspace:*+ version: link:../protocol'@univerjs/themes':specifier: workspace:*version: link:../themes@@ -837,8 +837,8 @@ importers:specifier: workspace:*version: link:../../common/shared'@univerjs/protocol':- specifier: 0.1.49- version: 0.1.49+ specifier: workspace:*+ version: link:../protocol'@univerjs/sheets':specifier: workspace:*version: link:../sheets@@ -1486,6 +1486,25 @@ importers:specifier: ^4.1.4version: 4.1.4(@types/[email protected])(@vitest/[email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+ packages/protocol:+ dependencies:+ '@grpc/grpc-js':+ specifier: ^1.14.3+ version: 1.14.3+ devDependencies:+ '@univerjs-infra/shared':+ specifier: workspace:*+ version: link:../../common/shared+ rxjs:+ specifier: ^7.8.2+ version: 7.8.2+ typescript:+ specifier: ^6.0.2+ version: 6.0.2+ vitest:+ specifier: ^4.1.4+ version: 4.1.4(@types/[email protected])(@vitest/[email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))+packages/rpc:dependencies:'@univerjs/core':@@ -1539,8 +1558,8 @@ importers:specifier: workspace:*version: link:../engine-render'@univerjs/protocol':- specifier: 0.1.49- version: 0.1.49+ specifier: workspace:*+ version: link:../protocol'@univerjs/rpc':specifier: workspace:*version: link:../rpc@@ -1708,8 +1727,8 @@ importers:specifier: workspace:*version: link:../engine-formula'@univerjs/protocol':- specifier: 0.1.49- version: 0.1.49+ specifier: workspace:*+ version: link:../protocol'@univerjs/sheets':specifier: workspace:*version: link:../sheets@@ -2618,8 +2637,8 @@ importers:specifier: ^1.1.1'@univerjs/protocol':- specifier: 0.1.49- version: 0.1.49+ specifier: workspace:*+ version: link:../protocol'@univerjs/sheets':specifier: workspace:*version: link:../sheets@@ -4280,6 +4299,15 @@ packages:'@floating-ui/[email protected]':resolution: {integrity: sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==}+ '@grpc/[email protected]':+ resolution: {integrity: sha512-Iq8QQQ/7X3Sac15oB6p0FmUg/klxQvXLeileoqrTRGJYLV+/9tubbr9ipz0GKHjmXVsgFPo/+W+2cA8eNcR+XA==}+ engines: {node: '>=12.10.0'}++ '@grpc/[email protected]':+ resolution: {integrity: sha512-rc1hOQtjIWGxcxpb9aHAfLpIctjEnsDehj0DAiVfBlmT84uvR0uUtN2hEi/ecvWVjXUGf5qPF4qEgiLOx1YIMQ==}+ engines: {node: '>=6'}+ hasBin: true+'@humanfs/[email protected]':resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==}engines: {node: '>=18.18.0'}@@ -4493,6 +4521,9 @@ packages:'@jridgewell/[email protected]':resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}+ '@js-sdsl/[email protected]':+ resolution: {integrity: sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==}+'@lit-labs/[email protected]':resolution: {integrity: sha512-HLomZXMmrCFHSRKESF5vklAKsDY7/fsT/ZhqCu3V0UoW/Qbv8wxmO4W9bx4KnCCF2Zak4yuk+AGraK/bPmI4kA==}@@ -4833,6 +4864,36 @@ packages:'@posthog/[email protected]':resolution: {integrity: sha512-h2FO7ut/BbfwpAXWpwdDHTzQgUo9ibDFEs6ZO+3cI3KPWQt5XwczK1OLAuPprcjm8T/jl0SH8jSFo5XdU4RbTg==}+ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==}++ '@protobufjs/[email protected]':+ resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==}+'@quansync/[email protected]':resolution: {integrity: sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ==}@@ -6156,9 +6217,6 @@ packages:react: 19.2.5react-dom: 19.2.5- '@univerjs/[email protected]':- resolution: {integrity: sha512-xVKSmSCQTElzozs8+zCWDdx3OJU7u/s/O25r7h9r9/Xot5tr0yTOwdjeEpjwjUCn1L1e67iBPKLkqegq9h4U/Q==}-'@valibot/[email protected]':resolution: {integrity: sha512-d6rYyK5KVa2XdqamWgZ4/Nr+cXhxjy7lmpe6Iajw15J/jmU+gyxl2IEd1Otg1d7Rl3gOQL5reulnSypzBtYy1A==}peerDependencies:@@ -8838,6 +8896,9 @@ packages:resolution: {integrity: sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w==}engines: {node: '>=18'}+ resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==}+resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}@@ -9837,6 +9898,10 @@ packages:resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}+ resolution: {integrity: sha512-3wY1AxV+VBNW8Yypfd1yQY9pXnqTAN+KwQxL8iYm3/BjKYMNg4i0owhEe26PWDOMaIrzeeF98Lqd5NGz4omiIg==}+ engines: {node: '>=12.0.0'}+resolution: {integrity: sha512-hHVTzba3wboROl0/aWRRG9dMytgH6ow//STBZh43l/wQgmMhYhOFi0EHWAPtoCz9IAUymsyP0TSBHkhgMEGNnQ==}@@ -12541,6 +12606,18 @@ snapshots:'@floating-ui/[email protected]': {}+ '@grpc/[email protected]':+ dependencies:+ '@grpc/proto-loader': 0.8.0+ '@js-sdsl/ordered-map': 4.4.2++ '@grpc/[email protected]':+ dependencies:+ lodash.camelcase: 4.3.0+ long: 5.3.2+ protobufjs: 7.5.5+ yargs: 17.7.2+'@humanfs/[email protected]': {}'@humanfs/[email protected]':@@ -12756,6 +12833,8 @@ snapshots:'@jridgewell/resolve-uri': 3.1.2'@jridgewell/sourcemap-codec': 1.5.5+ '@js-sdsl/[email protected]': {}+'@lit-labs/[email protected]': {}'@lit/[email protected](@types/[email protected])':@@ -13005,6 +13084,29 @@ snapshots:'@posthog/[email protected]': {}+ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]':+ dependencies:+ '@protobufjs/aspromise': 1.1.2+ '@protobufjs/inquire': 1.1.0++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}++ '@protobufjs/[email protected]': {}+'@quansync/[email protected]':dependencies:quansync: 1.0.0@@ -14246,8 +14348,6 @@ snapshots:react: 19.2.5react-dom: 19.2.5([email protected])- '@univerjs/[email protected]': {}-dependencies:valibot: 1.3.1([email protected])@@ -17268,6 +17368,8 @@ snapshots:strip-ansi: 7.2.0wrap-ansi: 9.0.2+ [email protected]: {}+@@ -18505,6 +18607,21 @@ snapshots:object-assign: 4.1.1react-is: 16.13.1+ dependencies:+ '@protobufjs/aspromise': 1.1.2+ '@protobufjs/base64': 1.1.2+ '@protobufjs/codegen': 2.0.4+ '@protobufjs/eventemitter': 1.1.0+ '@protobufjs/fetch': 1.1.0+ '@protobufjs/float': 1.0.2+ '@protobufjs/inquire': 1.1.0+ '@protobufjs/path': 1.1.2+ '@protobufjs/pool': 1.1.0+ '@protobufjs/utf8': 1.1.0+ '@types/node': 25.6.0+ long: 5.3.2+