snapshot of https://github.com/dream-num/univer.git (dev, 2026-09-16; blobs > 131072B omitted)
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-16 05:09:45 +05:00
commit bcf6ef63ad
7118 changed files with 1236854 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
# @univerjs/protocol
[![npm version](https://img.shields.io/npm/v/@univerjs/protocol?style=flat-square)](https://npmjs.com/package/@univerjs/protocol)
[![license](https://img.shields.io/npm/l/@univerjs/protocol?style=flat-square)](https://npmjs.com/package/@univerjs/protocol)
[![downloads](https://img.shields.io/npm/dm/@univerjs/protocol?style=flat-square)](https://npmjs.com/package/@univerjs/protocol)
`@univerjs/protocol` contains shared protocol types, generated service interfaces, and data contracts used across Univer packages.
## Package Overview
| Package | UMD global | CSS | Locales | Facade entry |
| --- | --- | :---: | :---: | :---: |
| `@univerjs/protocol` | `UniverProtocol` | No | No | No |
## Installation
```sh
pnpm add @univerjs/protocol
# or
npm install @univerjs/protocol
```
Keep all `@univerjs/*` packages on the same version.
## Usage
```ts
import type { IWorkbookMeta } from '@univerjs/protocol';
```
## Resources
- [Documentation](https://docs.univer.ai)
- [NPM package](https://npmjs.com/package/@univerjs/protocol)
- [GitHub repository](https://github.com/dream-num/univer)

View File

@@ -0,0 +1,75 @@
{
"name": "@univerjs/protocol",
"version": "1.0.0-rc.0",
"private": false,
"description": "Shared protocol types, generated service interfaces, and data contracts for Univer.",
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
"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",
"protocol",
"types",
"grpc",
"contracts"
],
"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.4"
},
"devDependencies": {
"@univerjs-infra/shared": "workspace:*",
"rxjs": "^7.8.2",
"typescript": "^6.0.3",
"vitest": "^5.0.0"
}
}

View File

@@ -0,0 +1,220 @@
/**
* 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 { IBoardMeta } from './ts/univer/board';
export type {
IChangeset,
ICommand,
IMutation,
} from './ts/univer/changeset';
export { CommentSolvedStatus, CommentUpdateEventType } from './ts/univer/colla-msg';
export type {
ICollaMsg,
ICollaMsgErrorEvent,
ICollaMsgJoin,
ICollaMsgLeave,
ICommentUpdate,
ILiveShareNewHost,
ILiveShareOperation,
ILiveShareOperationOperation,
ILiveShareRequestHost,
ILiveShareTerminate,
IShouldCloseConn,
IUniscriptRun,
IUpdateCursor,
IUpdatePermissionObj,
} from './ts/univer/colla-msg';
export { ErrorCode } from './ts/univer/constants/errors';
export type { IError } from './ts/univer/constants/errors';
export { UniverType } from './ts/univer/constants/univer';
export type { IDocumentMeta } from './ts/univer/doc';
export { CellType } from './ts/univer/initial-sheet';
export type { IInitialSheet, IRow, IRowCell } from './ts/univer/initial-sheet';
export type { IPdfAssetRef, IPdfMeta } from './ts/univer/pdf';
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 { ISlideMeta } from './ts/univer/slide';
export type {
ISnapshot,
ITableInfo,
} from './ts/univer/snapshot';
export type { IUnit } from './ts/univer/univer-file';
export { CellValueType } from './ts/univer/workbook';
export type { ICellData, ISheetBlock, ISheetBlockMeta, IWorkbookMeta, 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 } from './ts/universer/v1/comb';
export type {
ICombJoinRequest,
ICombJoinResponse,
ICombLeaveRequest,
ICombService,
IMember,
INewChangesRequest,
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 } from './ts/universer/v1/file';
export type { IFileService, 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 IDeleteUnitsRequest,
type IDeleteUnitsResponse,
type IFetchMissingChangesetsRequest,
type IFetchMissingChangesetsResponse,
type IGetLatestCsReqIdBySidRequest,
type IGetLatestCsReqIdBySidResponse,
type IGetResourcesRequest,
type IGetResourcesResponse,
type IGetSheetBlockRequest,
type IGetSheetBlockResponse,
type IGetUnitOnRevRequest,
type IGetUnitOnRevResponse,
type IListUnitsRequest,
type IListUnitsResponse,
type IMGetChangesetsByRevisionRequest,
type IMGetChangesetsByRevisionResponse,
type IMGetUnitMetaRequest,
type IMGetUnitMetaResponse,
type IRecoverUnitsRequest,
type IRecoverUnitsResponse,
type IReportUnitRoutingStatsRequest,
type IReportUnitRoutingStatsResponse,
type ISaveChangesetRequest,
type ISaveChangesetResponse,
type ISaveSheetBlockRequest,
type ISaveSheetBlockResponse,
type ISaveSnapshotRequest,
type ISaveSnapshotResponse,
type ISnapshotService,
type IUnitMeta,
} from './ts/universer/v1/snapshot';
export type {
IGetSessionTicketResponse,
IGetUserResponse,
IListUsersResponse,
IMigrateRequest,
IMigrateResponse,
IUser,
} from './ts/universer/v1/user';
export { isError } from './utils';

View File

@@ -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;
}

View File

@@ -0,0 +1,27 @@
/**
* 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 IBoardMeta {
unitID: string;
rev: number;
creator: string;
name: string;
resources: IResource[];
/** The original meta data in JSON format. */
originalMeta: Uint8Array;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,217 @@
/**
* 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;
userID: 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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,27 @@
/**
* 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,
UNIVER_BASE = 5,
UNIVER_BOARD = 6,
UNIVER_PDF = 7,
UNRECOGNIZED = -1,
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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[];
}

View File

@@ -0,0 +1,41 @@
/**
* 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 IPdfAssetRef {
assetId: string;
kind: string;
fileId: string;
mimeType: string;
size: number;
}
export interface IPdfMeta {
unitID: string;
rev: number;
creator: string;
name: string;
sourcePdfFileId?: string | undefined;
modelJsonFileId?: string | undefined;
decodeManifestFileId?: string | undefined;
pdfModelSchema?: string | undefined;
pdfModelSchemaVersion?: number | undefined;
decoderKind?: string | undefined;
decoderVersion?: string | undefined;
assets?: IPdfAssetRef[] | undefined;
editorStateJsonFileId?: string | undefined;
exportPatchJsonFileId?: string | undefined;
originalMeta: Uint8Array;
}

View File

@@ -0,0 +1,154 @@
/**
* 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,
Base = 6,
Board = 7,
Pdf = 8,
DocumentSection = 9,
DocumentParagraph = 10,
DocumentEntity = 11,
SlidePage = 12,
SlideElement = 13,
SlideMaster = 14,
BaseTable = 15,
BaseField = 16,
BaseRecord = 17,
BaseView = 18,
BaseDashboard = 19,
BoardElement = 20,
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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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 ISlideMeta {
unitID: string;
rev: number;
creator: string;
name: string;
resources: IResource[];
/** The original meta data in JSON format. */
originalMeta: Uint8Array;
}

View File

@@ -0,0 +1,42 @@
/**
* 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 { IBoardMeta } from './board';
import type { UniverType } from './constants/univer';
import type { IDocumentMeta } from './doc';
import type { IPdfMeta } from './pdf';
import type { ISlideMeta } from './slide';
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;
slide: ISlideMeta | undefined;
board: IBoardMeta | undefined;
pdf?: IPdfMeta | undefined;
}
export interface ITableInfo {
/** json:ITableInfo */
meta: Uint8Array;
dataPath: string;
/** A matrix of values in JSON format. use in IGetPreprocessRangesResponse */
data?: string | undefined;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,31 @@
/**
* 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 { IPdfMeta } from './pdf';
import type { IWorkbookMeta } from './workbook';
export interface IUnit {
unitID: string;
name: string;
type: UniverType;
workbook?: IWorkbookMeta | undefined;
document?: IDocumentMeta | undefined;
drawing?: IDrawingMeta | undefined;
pdf?: IPdfMeta | undefined;
}

View File

@@ -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[];
}

View File

@@ -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;
}

View File

@@ -0,0 +1,159 @@
/**
* 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;
/** two types: traditional and modern, default is modern */
docType?: string | undefined;
}
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;
}

View File

@@ -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>;
}

View File

@@ -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 };
}

View File

@@ -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;
}

View File

@@ -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>;
}

View File

@@ -0,0 +1,257 @@
/**
* 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;
/** Mirror these optional oneof payloads in univer-protocol before enabling the corresponding product. */
documentObject?: ICreateRequestPermissionObject | undefined;
slideObject?: ICreateRequestPermissionObject | undefined;
baseObject?: ICreateRequestPermissionObject | undefined;
boardObject?: ICreateRequestPermissionObject | undefined;
}
interface ICreateRequestPermissionObject {
collaborators: ICollaborator[];
unitID: string;
name: string;
strategies: IUnitPermissionStrategy[];
scope: IObjScope | 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 */
UpdateCollaborator(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>;
}

View File

@@ -0,0 +1,130 @@
/**
* 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;
userID: string;
}
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>;
}

View File

@@ -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;
}

View File

@@ -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>;
}

View File

@@ -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>;
}

View File

@@ -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>;
}

View File

@@ -0,0 +1,438 @@
/**
* 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;
}
export interface IMGetUnitMetaRequest {
unitIds: string[];
}
export interface IMGetUnitMetaResponse {
error: IError | undefined;
metas: { [key: string]: IUnitMeta };
}
export interface IUnitMeta {
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;
assign: 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;
/** two types: traditional and modern, default is modern */
docType?: string | 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 IMGetChangesetsByRevisionRequest {
unitId: string;
revisions: number[];
}
export interface IMGetChangesetsByRevisionResponse {
error: IError | undefined;
changesets: IChangeset[];
}
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 };
}
export interface IListUnitsRequest {
type: UniverType;
nextCursor: string;
}
export interface IListUnitsResponse {
error: IError | undefined;
units: IUnit[];
nextCursor: string;
}
export interface IDeleteUnitsRequest {
unitIds: string[];
/** if true, delete the unit permanently, otherwise just mark as deleted */
hardDelete: boolean;
}
export interface IDeleteUnitsResponse {
error: IError | undefined;
}
export interface IRecoverUnitsRequest {
unitIds: string[];
}
export interface IRecoverUnitsResponse {
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>;
RecoverUnits(request: IRecoverUnitsRequest, metadata?: Metadata): Observable<IRecoverUnitsResponse>;
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>;
MGetChangesetsByRevision(
request: IMGetChangesetsByRevisionRequest,
metadata?: Metadata,
): Observable<IMGetChangesetsByRevisionResponse>;
MGetUnitMeta(
request: IMGetUnitMetaRequest,
metadata?: Metadata,
): Observable<IMGetUnitMetaResponse>;
}

View File

@@ -0,0 +1,61 @@
/**
* 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;
}
export interface IMigrateRequest {
fromUserId: string;
toUserId: string;
}
export interface IMigrateResponse {
error: IError | undefined;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,8 @@
{
"extends": "@univerjs-infra/shared/tsconfigs/base",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/types"
},
"include": ["src"]
}

View File

@@ -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"
]
}

View File

@@ -0,0 +1,3 @@
import createConfig from '@univerjs-infra/shared/vitest';
export default createConfig();