diff --git a/.gitignore b/.gitignore index 3f67ebd7..8e80f365 100644 --- a/.gitignore +++ b/.gitignore @@ -117,4 +117,5 @@ circuit-cache/ #private npm-token .npmrc -package-lock.json \ No newline at end of file +package-lock.json +public/ \ No newline at end of file diff --git a/package.json b/package.json index 26091aa7..bcc20c7d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "clean": "find $(pwd) -name 'node_modules' -type d -exec rm -rf {} \\; || true && find $(pwd) -name 'build' -type d -exec rm -rf {} \\; || true", "build": "yarn workspaces run build", "clean-build": "yarn clean && yarn && yarn build", - "generate-docs": "spectaql spectaql-config.yml" + "gen:doc": "spectaql spectaql-config.yml" }, "packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610", "devDependencies": { diff --git a/packages/api/package.json b/packages/api/package.json index 881f4dab..b3425753 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -18,8 +18,9 @@ "license": "Apache-2.0", "description": "", "dependencies": { - "@apollo/client": "^3.10.6", - "@zkdb/common": "^0.1.1" + "@apollo/client": "^3.12.4", + "@zkdb/common": "^0.1.1", + "react": "^19.0.0" }, "peerDependencies": { "graphql": "^16.10.0" diff --git a/packages/api/rollup.config.js b/packages/api/rollup.config.js index 024ae066..cf65cad3 100644 --- a/packages/api/rollup.config.js +++ b/packages/api/rollup.config.js @@ -14,7 +14,6 @@ export default { plugins: [ alias({ entries: [ - { find: "@", replacement: "src" }, { find: "@authentication", replacement: "src/authentication" }, { find: "@graphql", replacement: "src/graphql" }, { find: "@utils", replacement: "src/utils" }, diff --git a/packages/api/src/graphql/client.ts b/packages/api/src/graphql/client.ts index a1b76d63..ef9ca819 100644 --- a/packages/api/src/graphql/client.ts +++ b/packages/api/src/graphql/client.ts @@ -11,12 +11,8 @@ import { collection } from "./collection"; import { collectionIndex } from "./collection-index"; import { database } from "./database"; import { document } from "./document"; -import { environment } from "./environment"; import { group } from "./group"; import { merkle } from "./merkle"; -import { metadata } from "./metadata"; -import { ownership } from "./ownership"; -import { permission } from "./permission"; import { proof } from "./proof"; import { rollup } from "./rollup"; import { transaction } from "./transaction"; @@ -30,14 +26,10 @@ export interface IApiClient { doc: ReturnType; user: ReturnType; group: ReturnType; - ownership: ReturnType; - permission: ReturnType; merkle: ReturnType; proof: ReturnType; transaction: ReturnType; rollup: ReturnType; - environment: ReturnType; - metadata: ReturnType; } export class ApiClient { @@ -118,14 +110,10 @@ export class ApiClient { doc: document(api.apollo), user: user(api.apollo), group: group(api.apollo), - ownership: ownership(api.apollo), - permission: permission(api.apollo), merkle: merkle(api.apollo), proof: proof(api.apollo), transaction: transaction(api.apollo), rollup: rollup(api.apollo), - environment: environment(api.apollo), - metadata: metadata(api.#client), }; } } diff --git a/packages/api/src/graphql/collection-index.ts b/packages/api/src/graphql/collection-index.ts index 212c86c6..ccbe53b1 100644 --- a/packages/api/src/graphql/collection-index.ts +++ b/packages/api/src/graphql/collection-index.ts @@ -1,7 +1,10 @@ import { gql } from "@apollo/client"; import { TIndexCreateRequest, + TIndexCreateResponse, + TIndexDropReponse, TIndexDropRequest, + TIndexExistReponse, TIndexExistRequest, TIndexListRequest, TIndexListResponse, @@ -12,73 +15,74 @@ import { TApolloClient, } from "./common"; -const COLLECTION_INDEX_CREATE = gql` - mutation IndexCreate( - $databaseName: String! - $collectionName: String! - $index: [IndexInput!]! - ) { - indexCreate( - databaseName: $databaseName - collectionName: $collectionName - index: $index - ) - } -`; - -const COLLECTION_INDEX_DELETE = gql` - mutation IndexDrop( - $databaseName: String! - $collectionName: String! - $indexName: String! - ) { - indexDrop( - databaseName: $databaseName - collectionName: $collectionName - indexName: $indexName - ) - } -`; - -const COLLECTION_INDEX_EXIST = gql` - query IndexExist( - $databaseName: String! - $collectionName: String! - $indexName: String! - ) { - indexExist( - databaseName: $databaseName - collectionName: $collectionName - indexName: $indexName - ) - } -`; - -const COLLECTION_INDEX_LIST = gql` - query IndexList($databaseName: String!, $collectionName: String!) { - indexList(databaseName: $databaseName, collectionName: $collectionName) - } -`; - export const collectionIndex = (client: TApolloClient) => ({ - create: createMutateFunction< - boolean, - TIndexCreateRequest, - { indexCreate: boolean } - >(client, COLLECTION_INDEX_CREATE, (data) => data.indexCreate), - drop: createMutateFunction< - boolean, - TIndexDropRequest, - { indexDrop: boolean } - >(client, COLLECTION_INDEX_DELETE, (data) => data.indexDrop), - exist: createQueryFunction< - boolean, - TIndexExistRequest, - { indexExist: boolean } - >(client, COLLECTION_INDEX_EXIST, (data) => data.indexExist), - list: createQueryFunction< - string[], - TIndexListRequest, - { indexList: TIndexListResponse } - >(client, COLLECTION_INDEX_LIST, (data) => data.indexList), + indexCreate: createMutateFunction( + client, + gql` + mutation indexCreate( + $databaseName: String! + $collectionName: String! + $index: JSON! + ) { + indexCreate( + databaseName: $databaseName + collectionName: $collectionName + index: $index + ) + } + `, + (data) => data.indexCreate + ), + indexDrop: createMutateFunction( + client, + gql` + mutation indexDrop( + $databaseName: String! + $collectionName: String! + $indexName: String! + ) { + indexDrop( + databaseName: $databaseName + collectionName: $collectionName + indexName: $indexName + ) + } + `, + (data) => data.indexDrop + ), + indexExist: createQueryFunction( + client, + gql` + query indexExist( + $databaseName: String! + $collectionName: String! + $indexName: String! + ) { + indexExist( + databaseName: $databaseName + collectionName: $collectionName + indexName: $indexName + ) + } + `, + (data) => data.indexExist + ), + indexList: createQueryFunction( + client, + gql` + query indexList($databaseName: String!, $collectionName: String!) { + indexList( + databaseName: $databaseName + collectionName: $collectionName + ) { + indexName + size + access + property + createdAt + } + } + `, + (data) => data.indexList + ), }); diff --git a/packages/api/src/graphql/collection.ts b/packages/api/src/graphql/collection.ts index 4611973d..26527351 100644 --- a/packages/api/src/graphql/collection.ts +++ b/packages/api/src/graphql/collection.ts @@ -1,10 +1,13 @@ import { gql } from "@apollo/client"; import { - TCollection, TCollectionCreateRequest, + TCollectionCreateResponse, + TCollectionExistRequest, + TCollectionExistResponse, TCollectionListRequest, TCollectionListResponse, - TCollectionRequest, + TCollectionMetadataRequest, + TCollectionMetadataResponse, } from "@zkdb/common"; import { createMutateFunction, @@ -12,69 +15,96 @@ import { TApolloClient, } from "./common"; -const COLLECTION_CREATE = gql` - mutation CollectionCreate( - $databaseName: String! - $collectionName: String! - $schema: [SchemaFieldInput!]! - $groupName: String - $index: [IndexInput] - $permission: Number - ) { - collectionCreate( - databaseName: $databaseName - collectionName: $collectionName - groupName: $groupName - schema: $schema - index: $index - permission: $permission - ) - } -`; - -const COLLECTION_EXIST = gql` - query CollectionExist($databaseName: String!, $collectionName: String!) { - collectionExist( - databaseName: $databaseName - collectionName: $collectionName - ) - } -`; - -const COLLECTION_LIST = gql` - query CollectionList($databaseName: String!) { - collectionList(databaseName: $databaseName) { - name - index - schema { - order - name - kind - indexed - } - ownership { - userName - groupName - permission - } - } - } -`; - export const collection = (client: TApolloClient) => ({ - create: createMutateFunction< - boolean, + collectionCreate: createMutateFunction< TCollectionCreateRequest, - { collectionCreate: boolean } - >(client, COLLECTION_CREATE, (data) => data.collectionCreate), - exist: createQueryFunction< - boolean, - TCollectionRequest, - { collectionExist: boolean } - >(client, COLLECTION_EXIST, (data) => data.collectionExist), - list: createQueryFunction< - TCollection[], + TCollectionCreateResponse + >( + client, + gql` + mutation collectionCreate( + $databaseName: String! + $collectionName: String! + $schema: [SchemaFieldInput!]! + $group: String + $permission: Int + ) { + collectionCreate( + databaseName: $databaseName + collectionName: $collectionName + schema: $schema + group: $group + permission: $permission + ) + } + `, + (data) => data.collectionCreate + ), + collectionExist: createQueryFunction< + TCollectionExistRequest, + TCollectionExistResponse + >( + client, + gql` + query collectionExist($databaseName: String!, $collectionName: String!) { + collectionExist( + databaseName: $databaseName + collectionName: $collectionName + ) + } + `, + (data) => data.collectionExist + ), + collectionList: createQueryFunction< TCollectionListRequest, - { collectionList: TCollectionListResponse } - >(client, COLLECTION_LIST, (data) => data.collectionList), + TCollectionListResponse + >( + client, + gql` + query collectionList($databaseName: String!) { + collectionList(databaseName: $databaseName) { + collectionName + schema { + ...SchemaFieldOutputFragment + } + metadata { + ...OwnershipAndPermissionFragment + } + sizeOnDisk + createdAt + updatedAt + } + } + `, + (data) => data.collectionList + ), + collectionMetadata: createQueryFunction< + TCollectionMetadataRequest, + TCollectionMetadataResponse + >( + client, + gql` + query collectionMetadata( + $databaseName: String! + $collectionName: String! + ) { + collectionMetadata( + databaseName: $databaseName + collectionName: $collectionName + ) { + collectionName + schema { + ...SchemaFieldOutputFragment + } + metadata { + ...OwnershipAndPermissionFragment + } + sizeOnDisk + createdAt + updatedAt + } + } + `, + (data) => data.collectionMetadata + ), }); diff --git a/packages/api/src/graphql/common.ts b/packages/api/src/graphql/common.ts index 47d8e541..fadd7796 100644 --- a/packages/api/src/graphql/common.ts +++ b/packages/api/src/graphql/common.ts @@ -1,23 +1,22 @@ -import * as pkg from "@apollo/client"; +import { OperationVariables, ApolloClient, DocumentNode } from "@apollo/client"; import { GraphQLResult } from "@utils"; export type TAsyncGraphQLResult = Promise>; -export type TOperationVariables = pkg.OperationVariables; +export type TOperationVariables = OperationVariables; -export type TApolloClient = pkg.ApolloClient; +export type TApolloClient = ApolloClient; /** * Creates a query function that executes a GraphQL query and processes the result. * - * @template T - The type of the processed result. * @template Req - The type of the request variables. Defaults to `any`. * @template Res - The type of the response data. Defaults to `any`. * * @param {any} query - The GraphQL query to be executed. - * @param {(data: Res) => T | any} postProcess - A function to process the result of the query. + * @param {(data: any) => Res} postProcess - A function to process the result of the query. * - * @returns {TAsyncGraphQLResult} A promise that resolves to a `GraphQLResult` containing the processed result. + * @returns {TAsyncGraphQLResult} A promise that resolves to a `GraphQLResult` containing the processed result. * * @example * ```typescript @@ -43,12 +42,12 @@ export type TApolloClient = pkg.ApolloClient; * }); * ``` */ -export const createQueryFunction = ( +export const createQueryFunction = ( client: TApolloClient, - query: any, - postProcess: (data: Res) => T | any + query: DocumentNode, + postProcess: (data: any) => Res | any ) => { - return async (variables: Req | undefined): Promise> => { + return async (variables: Req | undefined): TAsyncGraphQLResult => { try { const { data, errors } = await client.query< Res, @@ -58,12 +57,11 @@ export const createQueryFunction = ( variables: variables as any, }); if (!errors && data) { - return GraphQLResult.wrap(postProcess(data)); - } else { - return GraphQLResult.wrap( - errors ?? new Error("Unknown error, unable to perform query") - ); + return GraphQLResult.wrap(postProcess(data as Res)); } + return GraphQLResult.wrap( + errors ?? new Error("Unknown error, unable to perform query") + ); } catch (error: any) { return GraphQLResult.wrap(error); } @@ -73,21 +71,20 @@ export const createQueryFunction = ( /** * Creates a mutation function that executes a GraphQL mutation and processes the result. * - * @template T - The type of the processed result. * @template Req - The type of the request variables. Defaults to `any`. * @template Res - The type of the response data. Defaults to `any`. * * @param {any} mutation - The GraphQL mutation to be executed. - * @param {(data: Res) => T | any} postProcess - A function to process the result of the mutation. + * @param {(data: any) => Res } postProcess - A function to process the result of the mutation. * - * @returns {TAsyncGraphQLResult} - A promise that resolves to a wrapped GraphQL result. + * @returns {TAsyncGraphQLResult} - A promise that resolves to a wrapped GraphQL result. */ -export const createMutateFunction = ( +export const createMutateFunction = ( client: TApolloClient, - mutation: any, - postProcess: (data: Res) => T | any + mutation: DocumentNode, + postProcess: (data: any) => Res | any ) => { - return async (variables: Req | undefined): Promise> => { + return async (variables: Req | undefined): TAsyncGraphQLResult => { try { const { data, errors } = await client.mutate< Res, @@ -99,7 +96,7 @@ export const createMutateFunction = ( if (!errors && data) { return GraphQLResult.wrap(postProcess(data)); } else { - return GraphQLResult.wrap( + return GraphQLResult.wrap( errors ?? new Error("Unknown error, unable to perform query") ); } diff --git a/packages/api/src/graphql/database.ts b/packages/api/src/graphql/database.ts index 379dacdc..a53ce363 100644 --- a/packages/api/src/graphql/database.ts +++ b/packages/api/src/graphql/database.ts @@ -1,11 +1,18 @@ import { gql } from "@apollo/client"; import { - TDatabaseChangeOwnerRequest, - TDatabaseCreateRequest, + TDatabaseDeployRequest, + TDatabaseDeployResponse, + TDatabaseEnvironmentRequest, + TDatabaseEnvironmentResponse, + TDatabaseExistRequest, + TDatabaseExistResponse, + TDatabaseInfoRequest, + TDatabaseInfoResponse, TDatabaseListRequest, TDatabaseListResponse, TDatabaseRequest, - TMetadataDatabase, + TDatabaseStatsRequest, + TDatabaseStatsResponse, } from "@zkdb/common"; import { createMutateFunction, @@ -13,99 +20,90 @@ import { TApolloClient, } from "./common.js"; -const DATABASE_CHANGE_OWNER = gql` - mutation DbChangeOwner($databaseName: String!, $newOwner: String!) { - dbChangeOwner(databaseName: $databaseName, newOwner: $newOwner) - } -`; - -const DATABASE_CREATE = gql` - mutation DbCreate($databaseName: String!, $merkleHeight: Int!) { - dbCreate(databaseName: $databaseName, merkleHeight: $merkleHeight) - } -`; - -const DATABASE_SETTING = gql` - query GetDbSetting($databaseName: String!) { - dbSetting(databaseName: $databaseName) { - merkleHeight - publicKey - databaseOwner - } - } -`; - -const DATABASE_STATUS = gql` - query GetDbStats($databaseName: String!) { - dbStats(databaseName: $databaseName) - } -`; - -const DATABASE_LIST = gql` - query GetDbList($query: JSON, $pagination: PaginationInput) { - dbList(query: $query, pagination: $pagination) { - totalSize - offset - data { - databaseName - databaseOwner - databaseSize - merkleHeight - appPublicKey - collection { - name - index - schema { - order - name - kind - indexed - } - ownership { - userName - groupName - permission - } +export const database = (client: TApolloClient) => ({ + dbCreate: createMutateFunction( + client, + gql` + mutation dbCreate($databaseName: String!, $merkleHeight: Int!) { + dbCreate(databaseName: $databaseName, merkleHeight: $merkleHeight) + } + `, + (data) => data.dbCreate + ), + dbDeploy: createMutateFunction< + TDatabaseDeployRequest, + TDatabaseDeployResponse + >( + client, + gql` + mutation dbDeploy($databaseName: String!, $appPublicKey: String!) { + dbDeploy(databaseName: $databaseName, appPublicKey: $appPublicKey) + } + `, + (data) => data.dbDeploy + ), + dbEnvironment: createQueryFunction< + TDatabaseEnvironmentRequest, + TDatabaseEnvironmentResponse + >( + client, + gql` + query dbEnvironment { + dbEnvironment { + networkId + networkUrl } } - } - } -`; - -const DATABASE_EXIST = gql` - query GetDbExisted($databaseName: String!) { - dbExist(databaseName: $databaseName) - } -`; -export const database = (client: TApolloClient) => ({ - transferOwnership: createMutateFunction< - boolean, - TDatabaseChangeOwnerRequest, - { dbChangeOwner: boolean } - >(client, DATABASE_CHANGE_OWNER, (data) => data.dbChangeOwner), - create: createMutateFunction< - boolean, - TDatabaseCreateRequest, - { dbCreate: boolean } - >(client, DATABASE_CREATE, (data) => data.dbCreate), - metadata: createQueryFunction< - TMetadataDatabase, - TDatabaseRequest, - { metadata: TMetadataDatabase } - >(client, DATABASE_SETTING, (data) => data.metadata), - status: createQueryFunction( + `, + (data) => data.dbList.dbEnvironment + ), + dbExist: createQueryFunction( client, - DATABASE_STATUS, - (data) => data.dbStats + gql` + query dbExist($databaseName: String!) { + dbExist(databaseName: $databaseName) + } + `, + (data) => data.dbList.dbExist + ), + dbInfo: createQueryFunction( + client, + gql` + query dbInfo($databaseName: String!) { + dbInfo(databaseName: $databaseName) { + databaseName + databaseOwner + merkleHeight + appPublicKey + sizeOnDisk + deployStatus + } + } + `, + (data) => data.dbInfo ), - list: createQueryFunction< - TDatabaseListResponse, - TDatabaseListRequest, - { dbList: TDatabaseListResponse } - >(client, DATABASE_LIST, (data) => data.dbList.data), - exist: createQueryFunction( + dbList: createQueryFunction( client, - DATABASE_EXIST, - (data) => data.dbExist + gql` + query dbList($query: JSON, $pagination: PaginationInput) { + dbList(query: $query, pagination: $pagination) { + data { + ...MetadataDatabaseFragment + } + total + offset + } + } + `, + (data) => data.dbList + ), + dbStats: createQueryFunction( + client, + gql` + query dbStats($databaseName: String!) { + dbStats(databaseName: $databaseName) + } + `, + (data) => data.dbStats ), }); diff --git a/packages/api/src/graphql/document.ts b/packages/api/src/graphql/document.ts index 10a6133c..fe9db300 100644 --- a/packages/api/src/graphql/document.ts +++ b/packages/api/src/graphql/document.ts @@ -1,14 +1,15 @@ import { gql } from "@apollo/client"; import { TDocumentCreateRequest, + TDocumentCreateResponse, + TDocumentDropRequest, + TDocumentDropResponse, TDocumentFindRequest, - TDocumentHistoryGetRequest, - TDocumentListFindRequest, - TDocumentListFindResponse, - TDocumentReadResponse, - TDocumentResponse, + TDocumentFindResponse, TDocumentUpdateRequest, - TSingleDocumentHistory, + TDocumentUpdateResponse, + TDocumentMetadataRequest, + TDocumentMetadataResponse, } from "@zkdb/common"; import { createMutateFunction, @@ -16,171 +17,164 @@ import { TApolloClient, } from "./common"; -const DOCUMENT_DELETE = gql` - mutation DocumentDrop( - $databaseName: String! - $collectionName: String! - $documentQuery: JSON! - ) { - documentDrop( - databaseName: $databaseName - collectionName: $collectionName - documentQuery: $documentQuery - ) { - isLeft - sibling - } - } -`; - -const DOCUMENT_CREATE = gql` - input DocumentRecordInput { - name: String! - kind: String! - value: String! - } - - mutation DocumentCreate( - $databaseName: String! - $collectionName: String! - $documentRecord: [DocumentRecordInput!]! - $documentPermission: Number - ) { - documentCreate( - databaseName: $databaseName - collectionName: $collectionName - documentRecord: $documentRecord - documentPermission: $documentPermission - ) { - isLeft - sibling - } - } -`; - -const DOCUMENT_UPDATE = gql` - mutation DocumentUpdate( - $databaseName: String! - $collectionName: String! - $documentQuery: JSON! - $documentRecord: [DocumentRecordInput!]! - ) { - documentUpdate( - databaseName: $databaseName - collectionName: $collectionName - documentQuery: $documentQuery - documentRecord: $documentRecord - ) { - isLeft - sibling - } - } -`; - -const DOCUMENT_FIND_ONE = gql` - query DocumentFind( - $databaseName: String! - $collectionName: String! - $documentQuery: JSON! - ) { - documentFind( - databaseName: $databaseName - collectionName: $collectionName - documentQuery: $documentQuery - ) { - docId - field { - name - kind - value +export const document = (client: TApolloClient) => ({ + documentCreate: createMutateFunction< + TDocumentCreateRequest, + TDocumentCreateResponse + >( + client, + gql` + mutation documentCreate( + $databaseName: String! + $collectionName: String! + $document: JSON! + $documentPermission: Int + ) { + documentCreate( + databaseName: $databaseName + collectionName: $collectionName + document: $document + documentPermission: $documentPermission + ) { + merkleProof { + ...MerkleProofFragment + } + docId + acknowledged + } } - createdAt - } - } -`; - -const DOCUMENT_FIND_MANY = gql` - query DocumentsFind( - $databaseName: String! - $collectionName: String! - $documentQuery: JSON! - $pagination: PaginationInput - ) { - documentsFind( - databaseName: $databaseName - collectionName: $collectionName - documentQuery: $documentQuery - pagination: $pagination - ) { - totalSize - offset - data { - docId - field { - name - kind - value + `, + (data) => data.documentCreate + ), + documentDrop: createMutateFunction< + TDocumentDropRequest, + TDocumentDropResponse + >( + client, + gql` + mutation documentDrop( + $databaseName: String! + $collectionName: String! + $docId: String! + ) { + documentDrop( + databaseName: $databaseName + collectionName: $collectionName + docId: $docId + ) { + isLeft + sibling } - createdAt } - } - } -`; - -const DOCUMENT_HISTORY = gql` - query HistoryDocumentGet( - $databaseName: String! - $collectionName: String! - $docId: String! - ) { - historyDocumentGet( - databaseName: $databaseName - collectionName: $collectionName - docId: $docId - ) { - docId - documents { - docId - fields { - name - kind - value + `, + (data) => data.documentDrop + ), + documentUpdate: createMutateFunction< + TDocumentUpdateRequest, + TDocumentUpdateResponse + >( + client, + gql` + mutation documentUpdate( + $databaseName: String! + $collectionName: String! + $docId: String! + $document: JSON! + ) { + documentUpdate( + databaseName: $databaseName + collectionName: $collectionName + docId: $docId + document: $document + ) { + isLeft + sibling } - createdAt } - } - } -`; - -export const document = (client: TApolloClient) => ({ - drop: createMutateFunction< - TDocumentResponse, + `, + (data) => data.documentUpdate + ), + documentFind: createQueryFunction< TDocumentFindRequest, - { documentDrop: TDocumentResponse } - >(client, DOCUMENT_DELETE, (data) => data.documentDrop), - create: createMutateFunction< - TDocumentResponse, - TDocumentCreateRequest, - { documentCreate: TDocumentResponse } - >(client, DOCUMENT_CREATE, (data) => data.documentCreate), - update: createMutateFunction< - TDocumentResponse, - TDocumentUpdateRequest, - { documentUpdate: TDocumentResponse } - >(client, DOCUMENT_UPDATE, (data) => data.documentUpdate), - findOne: createQueryFunction< - TDocumentReadResponse | null, - { databaseName: string; collectionName: string; documentQuery: any }, - { documentFind: TDocumentReadResponse | null } - >(client, DOCUMENT_FIND_ONE, (data) => data.documentFind), - findMany: createQueryFunction< - TDocumentListFindResponse, - TDocumentListFindRequest, - { documentsFind: TDocumentListFindResponse } - >(client, DOCUMENT_FIND_MANY, (data) => data.documentsFind.data), - history: createQueryFunction< - TSingleDocumentHistory, - TDocumentHistoryGetRequest, - { historyDocumentGet: TSingleDocumentHistory } - >(client, DOCUMENT_HISTORY, (data) => data.historyDocumentGet), + TDocumentFindResponse + >( + client, + gql` + query documentFind( + $databaseName: String! + $collectionName: String! + $query: JSON + $pagination: PaginationInput + ) { + documentFind( + databaseName: $databaseName + collectionName: $collectionName + query: $query + pagination: $pagination + ) { + data { + ...DocumentResponseFragment + } + total + offset + } + } + `, + (data) => data.documentFind + ), + documentHistoryFind: createQueryFunction< + TDocumentFindRequest, + TDocumentFindResponse + >( + client, + gql` + query documentHistoryFind( + $databaseName: String! + $collectionName: String! + $docId: String! + $pagination: PaginationInput + ) { + documentHistoryFind( + databaseName: $databaseName + collectionName: $collectionName + docId: $docId + pagination: $pagination + ) { + data { + ...DocumentRevisionResponseFragment + } + total + offset + } + } + `, + (data) => data.documentHistoryFind + ), + documentMetadata: createQueryFunction< + TDocumentMetadataRequest, + TDocumentMetadataResponse + >( + client, + gql` + query documentMetadata( + $databaseName: String! + $collectionName: String! + $docId: String! + ) { + documentMetadata( + databaseName: $databaseName + collectionName: $collectionName + docId: $docId + ) { + owner + group + permission + collectionName + docId + merkleIndex + } + } + `, + (data) => data.documentMetadata + ), }); diff --git a/packages/api/src/graphql/environment.ts b/packages/api/src/graphql/environment.ts deleted file mode 100644 index 00983703..00000000 --- a/packages/api/src/graphql/environment.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { gql } from "@apollo/client"; -import { TEnvironment } from "@zkdb/common"; -import { createQueryFunction, TApolloClient } from "./common.js"; - -const ENVIRONMENT_GET = gql` - query GetEnvironment { - getEnvironment { - networkId - networkUrl - } - } -`; - -export const environment = (client: TApolloClient) => ({ - getEnvironment: createQueryFunction< - TEnvironment, - undefined, - { getEnvironment: TEnvironment } - >(client, ENVIRONMENT_GET, (data) => data.getEnvironment), -}); diff --git a/packages/api/src/graphql/group.ts b/packages/api/src/graphql/group.ts index 87dc4aa2..ff6c4bc5 100644 --- a/packages/api/src/graphql/group.ts +++ b/packages/api/src/graphql/group.ts @@ -1,13 +1,19 @@ import { gql } from "@apollo/client"; import { TGroupAddUserListRequest, + TGroupAddUserListResponse, TGroupCreateRequest, - TGroupInfoDetailRequest, - TGroupInfoDetailResponse, + TGroupCreateResponse, + TGroupDetailRequest, + TGroupDetailResponse, TGroupListAllRequest, TGroupListAllResponse, - TGroupRemoveUsersRequest, + TGroupListByUserRequest, + TGroupListByUserResponse, + TGroupRemoveUserListRequest, + TGroupRemoveUserListResponse, TGroupUpdateRequest, + TGroupUpdateResponse, } from "@zkdb/common"; import { createMutateFunction, @@ -16,124 +22,125 @@ import { } from "./common"; export const group = (client: TApolloClient) => ({ - addUser: createMutateFunction< - boolean, + groupAddUser: createMutateFunction< TGroupAddUserListRequest, - { groupAddUsers: boolean } + TGroupAddUserListResponse >( client, gql` - mutation GroupAddUsers( + mutation groupAddUser( $databaseName: String! $groupName: String! - $userNames: [String!]! + $listUser: [String!]! ) { - groupAddUsers( + groupAddUser( databaseName: $databaseName groupName: $groupName - userNames: $userNames + listUser: $listUser ) } `, - (data) => data.groupAddUsers + (data) => data.groupAddUser ), - update: createMutateFunction< - boolean, - TGroupUpdateRequest, - { groupUpdate: boolean } - >( + groupCreate: createMutateFunction( client, gql` - mutation GroupChangeDescription( + mutation groupCreate( $databaseName: String! $groupName: String! - $groupDescription: String! + $groupDescription: String ) { - groupChangeDescription( + groupCreate( databaseName: $databaseName groupName: $groupName groupDescription: $groupDescription ) } `, - (data) => data.groupUpdate + (data) => data.groupCreate ), - create: createMutateFunction< - boolean, - TGroupCreateRequest, - { groupCreate: boolean } + groupRemoveUser: createMutateFunction< + TGroupRemoveUserListRequest, + TGroupRemoveUserListResponse >( client, gql` - mutation GroupCreate( + mutation groupRemoveUser( $databaseName: String! $groupName: String! - $groupDescription: String + $listUser: [String!]! ) { - groupCreate( + groupRemoveUser( databaseName: $databaseName groupName: $groupName - groupDescription: $groupDescription + listUser: $listUser ) } `, - (data) => data.groupCreate + (data) => data.groupRemoveUser ), - removeUser: createMutateFunction< - boolean, - TGroupRemoveUsersRequest, - { groupRemoveUsers: boolean } - >( + groupUpdate: createMutateFunction( client, gql` - mutation GroupRemoveUsers( + mutation groupUpdate( $databaseName: String! $groupName: String! - $userNames: [String!]! + $newGroupName: String + $newGroupDescription: String ) { - groupRemoveUsers( + groupUpdate( databaseName: $databaseName groupName: $groupName - userNames: $userNames + newGroupName: $newGroupName + newGroupDescription: $newGroupDescription ) } `, - (data) => data.groupRemoveUsers + (data) => data.groupUpdate ), - info: createQueryFunction< - TGroupInfoDetailRequest, - { databaseName: string; groupName: string }, - { groupInfo: TGroupInfoDetailResponse } - >( + groupDetail: createQueryFunction( client, gql` - mutation GroupInfo($databaseName: String!, $groupName: String!) { - groupInfo(databaseName: $databaseName, groupName: $groupName) + query groupDetail($databaseName: String!, $groupName: String!) { + groupDetail(databaseName: $databaseName, groupName: $groupName) { + groupName + groupDescription + createdBy + updatedAt + createdAt + listUser { + ...GroupUserInfoFragment + } + } } `, - (data) => data.groupInfo + (data) => data.groupDetail ), - list: createQueryFunction< - TGroupListAllResponse, + groupListAll: createQueryFunction< TGroupListAllRequest, - { groupListAll: TGroupListAllResponse } + TGroupListAllResponse >( client, gql` - query GroupListAll($databaseName: String!) { - groupListAll(databaseName: $databaseName) + query groupListAll($databaseName: String!) { + groupListAll(databaseName: $databaseName) { + groupName + groupDescription + createdBy + updatedAt + createdAt + } } `, (data) => data.groupListAll ), - listUser: createQueryFunction< - string[], - { databaseName: string; userName: string }, - { groupListByUser: string[] } + groupListByUser: createQueryFunction< + TGroupListByUserRequest, + TGroupListByUserResponse >( client, gql` - query GroupListByUser($databaseName: String!, $userName: String!) { + query groupListByUser($databaseName: String!, $userName: String!) { groupListByUser(databaseName: $databaseName, userName: $userName) } `, diff --git a/packages/api/src/graphql/merkle.ts b/packages/api/src/graphql/merkle.ts index e04ac410..fd9372d3 100644 --- a/packages/api/src/graphql/merkle.ts +++ b/packages/api/src/graphql/merkle.ts @@ -1,31 +1,135 @@ import { gql } from "@apollo/client"; -import { TDatabaseRequest, TMerkleProof } from "@zkdb/common"; +import { + TDatabaseRequest, + TMerkleProof, + TMerkleTreeInfoRequest, + TMerkleTreeInfoResponse, + TMerkleTreeNodeChildrenRequest, + TMerkleTreeNodeChildrenResponse, + TMerkleTreeNodeListByLevelRequest, + TMerkleTreeNodeListByLevelResponse, + TMerkleTreeNodePathRequest, + TMerkleTreeNodePathResponse, + TMerkleTreeProofByDocIdRequest, + TMerkleTreeProofByDocIdResponse, + TMerkleTreeProofByIndexRequest, + TMerkleTreeProofByIndexResponse, +} from "@zkdb/common"; import { createQueryFunction, TApolloClient } from "./common"; export const merkle = (client: TApolloClient) => ({ - root: createQueryFunction( + merkleNodeByLevel: createQueryFunction< + TMerkleTreeNodeListByLevelRequest, + TMerkleTreeNodeListByLevelResponse + >( + client, + gql` + query merkleNodeByLevel( + $databaseName: String! + $level: Int! + $pagination: PaginationInput + ) { + merkleNodeByLevel( + databaseName: $databaseName + level: $level + pagination: $pagination + ) { + data { + ...MerkleNodeFragment + } + totalSize + offset + } + } + `, + (data) => data.merkleNodeByLevel + ), + merkleNodeChildren: createQueryFunction< + TMerkleTreeNodeChildrenRequest, + TMerkleTreeNodeChildrenResponse + >( + client, + gql` + query merkleNodeChildren( + $databaseName: String! + $level: Int! + $index: String! + ) { + merkleNodeChildren( + databaseName: $databaseName + level: $level + index: $index + ) { + index + level + hash + empty + } + } + `, + (data) => data.merkleNodeChildren + ), + merkleNodePath: createQueryFunction< + TMerkleTreeNodePathRequest, + TMerkleTreeNodePathResponse + >( + client, + gql` + query merkleNodePath($databaseName: String!, $docId: String!) { + merkleNodePath(databaseName: $databaseName, docId: $docId) { + index + level + hash + witness + target + } + } + `, + (data) => data.merkleNodePath + ), + merkleProof: createQueryFunction< + TMerkleTreeProofByIndexRequest, + TMerkleTreeProofByIndexResponse + >( client, gql` - query GetRoot($databaseName: String!) { - getRoot(databaseName: $databaseName) + query merkleProof($databaseName: String!, $index: String!) { + merkleProof(databaseName: $databaseName, index: $index) { + isLeft + sibling + } } `, - (data) => data.getRoot + (data) => data.merkleProof ), - witness: createQueryFunction< - TMerkleProof[], - { databaseName: string; docId: string }, - { getWitnessByDocument: TMerkleProof[] } + merkleProofDocId: createQueryFunction< + TMerkleTreeProofByDocIdRequest, + TMerkleTreeProofByDocIdResponse >( client, gql` - query GetWitness($databaseName: String!, $docId: String!) { - getWitnessByDocument(databaseName: $databaseName, docId: $docId) { + query merkleProofDocId($databaseName: String!, $docId: String!) { + merkleProofDocId(databaseName: $databaseName, docId: $docId) { isLeft sibling } } `, - (data) => data.getWitnessByDocument + (data) => data.merkleProofDocId + ), + merkleTreeInfo: createQueryFunction< + TMerkleTreeInfoRequest, + TMerkleTreeInfoResponse + >( + client, + gql` + query merkleTreeInfo($databaseName: String!) { + merkleTreeInfo(databaseName: $databaseName) { + merkleRoot + merkleHeight + } + } + `, + (data) => data.merkleTreeInfo ), }); diff --git a/packages/api/src/graphql/metadata.ts b/packages/api/src/graphql/metadata.ts deleted file mode 100644 index 2ff34139..00000000 --- a/packages/api/src/graphql/metadata.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { gql } from "@apollo/client"; -import { - TCollectionMetadata, - TCollectionMetadataRequest, - TDocumentMetadata, - TDocumentMetadataRequest, -} from "@zkdb/common"; -import { createQueryFunction, TApolloClient } from "./common"; - -// TODO: Finish when serverless done -const METADATA_DOCUMENT = gql``; - -const METADATA_COLLECTION = gql``; - -export const metadata = (client: TApolloClient) => ({ - document: createQueryFunction< - TDocumentMetadata, - TDocumentMetadataRequest, - { documentMetadata: TDocumentMetadata } - >(client, METADATA_DOCUMENT, (data) => data), - collection: createQueryFunction< - TCollectionMetadata, - TCollectionMetadataRequest, - { collectionMetadata: TCollectionMetadata } - >(client, METADATA_COLLECTION, (data) => data), -}); diff --git a/packages/api/src/graphql/ownership.ts b/packages/api/src/graphql/ownership.ts deleted file mode 100644 index 9849b092..00000000 --- a/packages/api/src/graphql/ownership.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { gql } from "@apollo/client"; -import { TOwnershipDocumentOwnRequest } from "@zkdb/common"; -import { createMutateFunction, TApolloClient } from "./common"; - -export const ownership = (client: TApolloClient) => ({ - setOwnership: createMutateFunction< - boolean, - TOwnershipDocumentOwnRequest, - { permissionOwn: boolean } - >( - client, - gql` - mutation PermissionOwn( - $databaseName: String! - $collection: String! - $docId: String - $grouping: PermissionGroup! - $newOwner: String! - ) { - permissionOwn( - databaseName: $databaseName - collection: $collection - docId: $docId - grouping: $grouping - newOwner: $newOwner - ) { - userName - groupName - } - } - `, - (data) => data.permissionOwn - ), -}); diff --git a/packages/api/src/graphql/permission.ts b/packages/api/src/graphql/permission.ts deleted file mode 100644 index 8cca6eca..00000000 --- a/packages/api/src/graphql/permission.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { gql } from "@apollo/client"; -import { TMetadataBasic } from "@zkdb/common"; -import { - createMutateFunction, - createQueryFunction, - TApolloClient, -} from "./common"; - -export const permission = (client: TApolloClient) => ({ - set: createMutateFunction< - boolean, - TMetadataBasic, - { permissionSet: boolean } - >( - client, - gql` - mutation PermissionSet( - $databaseName: String! - $collectionName: String! - $docId: String - $permission: Number! - ) { - permissionSet( - databaseName: $databaseName - collectionName: $collectionName - docId: $docId - permission: $permission - ) { - userName - groupName - permission - } - } - `, - (data) => data.permissionSet - ), -}); diff --git a/packages/api/src/graphql/proof.ts b/packages/api/src/graphql/proof.ts index 50480143..a5abafa0 100644 --- a/packages/api/src/graphql/proof.ts +++ b/packages/api/src/graphql/proof.ts @@ -1,50 +1,59 @@ import { gql } from "@apollo/client"; import { - EProofStatusDocument, - TDatabaseRequest, - TProofDocumentRequest, - TZKDatabaseProof, + TProofStatusDatabaseRequest, + TProofStatusDatabaseResponse, + TProofStatusDocumentRequest, + TProofStatusDocumentResponse, + TZkProofRequest, + TZkProofResponse, } from "@zkdb/common"; import { createQueryFunction, TApolloClient } from "./common"; export const proof = (client: TApolloClient) => ({ - status: createQueryFunction< - EProofStatusDocument, - TProofDocumentRequest, - { getProofStatus: EProofStatusDocument } + proof: createQueryFunction( + client, + gql` + query proof($databaseName: String!) { + proof(databaseName: $databaseName) { + publicInput + publicOutput + maxProofsVerified + proof + } + } + `, + (data) => data.proof + ), + proofStatusDatabase: createQueryFunction< + TProofStatusDatabaseRequest, + TProofStatusDatabaseResponse >( client, gql` - query GetProofStatus( + query proofStatusDatabase($databaseName: String!) { + proofStatusDatabase(databaseName: $databaseName) + } + `, + (data) => data.proofStatusDatabase + ), + proofStatusDocument: createQueryFunction< + TProofStatusDocumentRequest, + TProofStatusDocumentResponse + >( + client, + gql` + query proofStatusDocument( $databaseName: String! $collectionName: String! - $docId: String! + $docId: String ) { - getProofStatus( + proofStatusDocument( databaseName: $databaseName collectionName: $collectionName docId: $docId ) } `, - (data) => data.getProofStatus - ), - get: createQueryFunction< - TZKDatabaseProof, - TDatabaseRequest, - { getProof: TZKDatabaseProof } - >( - client, - gql` - query GetProof($databaseName: String!) { - getProof(databaseName: $databaseName) { - publicInput - publicOutput - maxProofsVerified - proof - } - } - `, - (data) => data.getProof + (data) => data.proofStatusDocument ), }); diff --git a/packages/api/src/graphql/rollup.ts b/packages/api/src/graphql/rollup.ts index 6a509e64..800efa01 100644 --- a/packages/api/src/graphql/rollup.ts +++ b/packages/api/src/graphql/rollup.ts @@ -1,41 +1,41 @@ import { gql } from "@apollo/client"; -import { RollUpData, TDatabaseRequest } from "@zkdb/common"; +import { + TRollUpCreateRequest, + TRollUpCreateResponse, + TRollupHistoryRequest, + TRollUpHistoryResponse, +} from "@zkdb/common"; import { createMutateFunction, TApolloClient } from "./common.js"; -const ROLLUP_CREATE = gql` - mutation RollupCreate($databaseName: String!) { - rollupCreate(databaseName: $databaseName) - } -`; - -const ROLLUP_HISTORY = gql` - mutation RollupHistory($databaseName: String!) { - rollupHistory(databaseName: $databaseName) { - state - extraData - history { - databaseName - transactionType - txHash - status - merkletreeRoot - merkletreeRootPrevious - createdAt - updatedAt - error - } - } - } -`; export const rollup = (client: TApolloClient) => ({ rollupCreate: createMutateFunction< - boolean, - TDatabaseRequest, - { rollUpCreate: boolean } - >(client, ROLLUP_CREATE, (data) => data.rollUpCreate), + TRollUpCreateRequest, + TRollUpCreateResponse + >( + client, + gql` + mutation rollupCreate($databaseName: String!) { + rollupCreate(databaseName: $databaseName) + } + `, + (data) => data.rollupCreate + ), rollupHistory: createMutateFunction< - RollUpData, - TDatabaseRequest, - { rollUpHistory: RollUpData } - >(client, ROLLUP_HISTORY, (data) => data.rollUpHistory), + TRollupHistoryRequest, + TRollUpHistoryResponse + >( + client, + gql` + mutation rollupHistory($databaseName: String!) { + rollupHistory(databaseName: $databaseName) { + state + extraData + history { + ...RollUpHistoryItemFragment + } + } + } + `, + (data) => data.rollUpHistory + ), }); diff --git a/packages/api/src/graphql/transaction.ts b/packages/api/src/graphql/transaction.ts index 2a66cc1b..ca31d353 100644 --- a/packages/api/src/graphql/transaction.ts +++ b/packages/api/src/graphql/transaction.ts @@ -1,8 +1,11 @@ import { gql } from "@apollo/client"; import { - TTransactionWithId, - TTransactionSignRequest, - TTransactionRequest, + TTransactionDeployEnqueueRequest, + TTransactionDeployEnqueueResponse, + TTransactionDraftRequest, + TTransactionDraftResponse, + TTransactionSubmitRequest, + TTransactionSubmitResponse, } from "@zkdb/common"; import { @@ -11,49 +14,65 @@ import { TApolloClient, } from "./common.js"; -const TRANSACTION_DRAFT = gql` - query TransactionDraft( - $databaseName: String! - $transactionType: TransactionType! - ) { - transactionDraft( - databaseName: $databaseName - transactionType: $transactionType - ) { - transactionObjectId - databaseName - transactionType - status - transactionRaw - txHash - error - } - } -`; - -const TRANSACTION_CONFIRM = gql` - mutation TransactionConfirm( - $databaseName: String! - $transactionObjectId: String! - $txHash: String! - ) { - transactionConfirm( - databaseName: $databaseName - transactionObjectId: $transactionObjectId - txHash: $txHash - ) - } -`; - export const transaction = (client: TApolloClient) => ({ + transactionSubmit: createMutateFunction< + TTransactionSubmitRequest, + TTransactionSubmitResponse + >( + client, + gql` + mutation transactionSubmit( + $databaseName: String! + $transactionObjectId: String! + $txHash: String! + ) { + transactionSubmit( + databaseName: $databaseName + transactionObjectId: $transactionObjectId + txHash: $txHash + ) + } + `, + (data) => data.transactionSubmit + ), + transactionDeployEnqueue: createMutateFunction< + TTransactionDeployEnqueueRequest, + TTransactionDeployEnqueueResponse + >( + client, + gql` + mutation transactionDeployEnqueue($databaseName: String!) { + transactionDeployEnqueue(databaseName: $databaseName) + } + `, + (data) => data.transactionDeployEnqueue + ), transactionDraft: createQueryFunction< - TTransactionWithId, - TTransactionRequest, - { transactionDraft: TTransactionWithId } - >(client, TRANSACTION_DRAFT, (data) => data.transactionDraft), - transactionConfirm: createMutateFunction< - boolean, - TTransactionSignRequest, - { confirmTransaction: boolean } - >(client, TRANSACTION_CONFIRM, (data) => data.confirmTransaction), + TTransactionDraftRequest, + TTransactionDraftResponse + >( + client, + gql` + query transactionDraft( + $databaseName: String! + $transactionType: TransactionType! + ) { + transactionDraft( + databaseName: $databaseName + transactionType: $transactionType + ) { + transactionObjectId + databaseName + transactionType + status + transactionRaw + txHash + error + createdAt + updatedAt + } + } + `, + (data) => data.transactionDraft + ), }); diff --git a/packages/api/src/graphql/user.ts b/packages/api/src/graphql/user.ts index 4b45efc9..723aab54 100644 --- a/packages/api/src/graphql/user.ts +++ b/packages/api/src/graphql/user.ts @@ -1,8 +1,15 @@ import { gql } from "@apollo/client"; import { + TUserEcdsaChallengeRequest, + TUserEcdsaChallengeResponse, TUserFindRequest, TUserFindResponse, + TUserMeRequest, + TUserMeResponse, TUserSignInRequest, + TUserSignInResponse, + TUserSignOutRequest, + TUserSignOutResponse, TUserSignUpRequest, TUserSignUpResponse, } from "@zkdb/common"; @@ -12,121 +19,88 @@ import { TApolloClient, } from "./common"; -/** - * Represents the record of a user sign-in. - * - * @typedef {Object} TUserSignInRecord - * @property {string} userName - The username of the user. - * @property {string} email - The email address of the user. - * @property {string} accessToken - The access token provided upon sign-in. - * @property {JSON} userData - Additional user data in JSON format. - * @property {string} publicKey - The public key associated with the user. - */ -export type TUserSignInRecord = { - userName: string; - email: string; - accessToken: string; - userData: any; - publicKey: string; -}; - -/** - * Represents the response received after a user sign-in operation. - * - * @typedef {Object} TUserSignInResponse - * @property {TUserSignInRecord} userSignIn - The record containing user sign-in details. - */ -export type TUserSignInResponse = { - userSignIn: TUserSignInRecord; -}; - -const USER_SIGN_IN = gql` - mutation UserSignIn($proof: ProofInput!) { - userSignIn(proof: $proof) { - userName - accessToken - userData - publicKey - } - } -`; - -const USER_SIGN_OUT = gql` - mutation UserSignOut { - userSignOut - } -`; - -const USER_SIGN_UP = gql` - mutation UserSignUp($signUp: SignUp!, $proof: ProofInput!) { - userSignUp(signUp: $signUp, proof: $proof) { - userName - email - publicKey - } - } -`; - -const USER_FIND = gql` - query FindUser($query: JSON, $pagination: PaginationInput) { - findUser(query: $query, pagination: $pagination) { - totalSize - offset - data { - email - publicKey - userName - } - } - } -`; - -const USER_INFO = gql` - query UserSignInData { - userSignInData { - userName - accessToken - userData - publicKey - } - } -`; - -const ECDSA = gql` - mutation UserGetEcdsaChallenge { - userGetEcdsaChallenge - } -`; - export const user = (client: TApolloClient) => ({ - signIn: createMutateFunction< - TUserSignInResponse, - TUserSignInRequest, - { userSignIn: TUserSignInResponse } - >(client, USER_SIGN_IN, (data) => data.userSignIn), - signOut: createMutateFunction( + userSignIn: createMutateFunction( + client, + gql` + mutation userSignIn($proof: ProofInput!) { + userSignIn(proof: $proof) { + userName + accessToken + userData + publicKey + email + } + } + `, + (data) => data.userSignIn + ), + userSignOut: createMutateFunction( client, - USER_SIGN_OUT, + gql` + mutation userSignOut { + userSignOut + } + `, (data) => data.userSignOut ), - signUp: createMutateFunction< - TUserSignUpResponse, - TUserSignUpRequest, - { userSignUp: TUserSignUpResponse } - >(client, USER_SIGN_UP, (data) => data.userSignUp), - ecdsa: createMutateFunction< - string, - undefined, - { userGetEcdsaChallenge: string } - >(client, ECDSA, (data) => data.userGetEcdsaChallenge), - findMany: createQueryFunction< - TUserFindResponse, - TUserFindRequest, - { findUser: TUserFindResponse } - >(client, USER_FIND, (data) => data.findUser), - userInfo: createQueryFunction< - TUserSignInRecord, - undefined, - TUserSignInResponse - >(client, USER_INFO, (data) => data.userSignIn), + userSignUp: createMutateFunction( + client, + gql` + mutation userSignUp($newUser: SignUpInput!, $proof: ProofInput!) { + userSignUp(newUser: $newUser, proof: $proof) { + userName + email + userData + publicKey + activated + createdAt + updatedAt + } + } + `, + (data) => data.userSignUp + ), + userEcdsaChallenge: createMutateFunction< + TUserEcdsaChallengeRequest, + TUserEcdsaChallengeResponse + >( + client, + gql` + mutation userEcdsaChallenge { + userEcdsaChallenge + } + `, + (data) => data.userEcdsaChallenge + ), + userFind: createQueryFunction( + client, + gql` + query userFind($query: UserFindQueryInput, $pagination: PaginationInput) { + userFind(query: $query, pagination: $pagination) { + data { + ...UserFragment + } + total + offset + } + } + `, + (data) => data.userFind + ), + userMe: createQueryFunction( + client, + gql` + query userMe { + userMe { + userName + accessToken + userData + publicKey + email + } + } + `, + (data) => data.userMe + ), }); diff --git a/packages/api/src/utils/environment.ts b/packages/api/src/utils/environment.ts deleted file mode 100644 index 01210e9b..00000000 --- a/packages/api/src/utils/environment.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ApolloClient, InMemoryCache } from "@apollo/client"; -import { TEnvironment } from "@zkdb/common"; -import { environment } from "../graphql/environment"; - -export const getNetworkEnvironment = async ( - uri: string -): Promise => { - const api = new ApolloClient({ uri, cache: new InMemoryCache() }); - const result = await environment(api).getEnvironment(undefined); - return result.unwrap(); -}; diff --git a/packages/api/src/utils/index.ts b/packages/api/src/utils/index.ts index 1731de74..fe95415f 100644 --- a/packages/api/src/utils/index.ts +++ b/packages/api/src/utils/index.ts @@ -1,3 +1,2 @@ export * from "./result"; export * from "./constant"; -export * from "./environment"; diff --git a/packages/common/package.json b/packages/common/package.json index c3d5cece..8ceb7554 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@zkdb/common", - "version": "0.1.1", + "version": "0.1.2", "description": "zkDatabase for the future of Web3", "author": "chiro@orochi.network", "license": "Apache-2.0", @@ -60,7 +60,6 @@ "o1js": "^1.9.1" }, "dependencies": { - "@zkdb/permission": "^0.1.6" - }, - "devDependencies": {} + "@zkdb/permission": "^0.1.7" + } } diff --git a/packages/common/src/types/collection.ts b/packages/common/src/types/collection.ts index 98d06d20..4e3d40b6 100644 --- a/packages/common/src/types/collection.ts +++ b/packages/common/src/types/collection.ts @@ -1,5 +1,5 @@ import { OwnershipAndPermission } from '@zkdb/permission'; -import { IndexDirection } from 'mongodb'; +import type { IndexDirection } from 'mongodb'; import { TPickAlter } from './common.js'; import { TDatabaseRequest } from './database.js'; import { TCollectionMetadata } from './metadata.js'; @@ -115,6 +115,3 @@ export type TIndexExistReponse = boolean; export type TIndexDropRequest = Omit; export type TIndexDropReponse = boolean; - -// Index detail -export type TIndexDetailRequest = TIndexRequest; diff --git a/packages/common/src/types/common.ts b/packages/common/src/types/common.ts index d031e9b8..8a0ce636 100644 --- a/packages/common/src/types/common.ts +++ b/packages/common/src/types/common.ts @@ -1,5 +1,5 @@ import { Request } from 'express'; -import { ObjectId } from 'mongodb'; +import type { ObjectId } from 'mongodb'; import { TPagination } from './pagination'; type TDbRecordBasic = { diff --git a/packages/common/src/types/database.ts b/packages/common/src/types/database.ts index 434a8966..4091b06f 100644 --- a/packages/common/src/types/database.ts +++ b/packages/common/src/types/database.ts @@ -1,4 +1,5 @@ import { TDbRecord, TPickOptional } from './common.js'; +import { TEnvironment } from './environment.js'; import { TPagination, TPaginationReturn } from './pagination.js'; import { ETransactionStatus } from './transaction.js'; @@ -61,10 +62,10 @@ export type TDatabaseRequest = Pick; export type TDatabaseResponse = TMetadataDatabase; // Database update deploy -export type TDatabaseUpdateDeployedRequest = TDatabaseRequest & +export type TDatabaseDeployRequest = TDatabaseRequest & Pick; -export type TDatabaseUpdateDeployedResponse = boolean; +export type TDatabaseDeployResponse = boolean; // Database list export type TDatabaseListRequest = { @@ -88,4 +89,22 @@ export type TDatabaseFindByIndexRequest = TDatabaseRequest & { index: number; }; +// Database exist +export type TDatabaseEnvironmentRequest = void; + +export type TDatabaseEnvironmentResponse = TEnvironment; + +// Database exist +export type TDatabaseExistRequest = TDatabaseRequest; + export type TDatabaseExistResponse = boolean; + +// Database info +export type TDatabaseInfoRequest = TDatabaseRequest; + +export type TDatabaseInfoResponse = TMetadataDatabaseDetail; + +// Database stats +export type TDatabaseStatsRequest = TDatabaseRequest; + +export type TDatabaseStatsResponse = unknown; diff --git a/packages/common/src/types/document.ts b/packages/common/src/types/document.ts index b3d6a934..c788c711 100644 --- a/packages/common/src/types/document.ts +++ b/packages/common/src/types/document.ts @@ -1,4 +1,4 @@ -import { ObjectId } from 'mongodb'; +import type { ObjectId } from 'mongodb'; import { TContractSchemaField } from '../schema.js'; import { TDbRecord, TNullable } from './common.js'; import { TMerkleProof } from './merkle-tree.js'; diff --git a/packages/common/src/types/environment.ts b/packages/common/src/types/environment.ts index 6bc77ace..3d1251fa 100644 --- a/packages/common/src/types/environment.ts +++ b/packages/common/src/types/environment.ts @@ -1,5 +1,6 @@ -import { NetworkId } from 'o1js'; +import { ENetworkId } from './database'; + export type TEnvironment = { - networkId: NetworkId; + networkId: ENetworkId; networkUrl: string; }; diff --git a/packages/common/src/types/group.ts b/packages/common/src/types/group.ts index 2c6cd78e..b1469f4c 100644 --- a/packages/common/src/types/group.ts +++ b/packages/common/src/types/group.ts @@ -1,4 +1,4 @@ -import { ObjectId, WithoutId } from 'mongodb'; +import type { ObjectId, WithoutId } from 'mongodb'; import { TDbRecord } from './common.js'; import { TDatabaseRequest, TMetadataDatabase } from './database.js'; import { TUser, TUserRecord } from './user.js'; @@ -74,9 +74,9 @@ export type TGroupListAllRequest = TDatabaseRequest; export type TGroupListAllResponse = WithoutId[]; -export type TGroupInfoDetailRequest = TGroupRequest; +export type TGroupDetailRequest = TGroupRequest; -export type TGroupInfoDetailResponse = TGroupDetail; +export type TGroupDetailResponse = TGroupDetail; export type TGroupCreateRequest = TDatabaseRequest & Pick; diff --git a/packages/common/src/types/merkle-tree.ts b/packages/common/src/types/merkle-tree.ts index 5c762fb0..5bfe4d56 100644 --- a/packages/common/src/types/merkle-tree.ts +++ b/packages/common/src/types/merkle-tree.ts @@ -1,4 +1,4 @@ -import { Field } from 'o1js'; +import type { Field } from 'o1js'; import { TDatabaseRequest } from './database.js'; import { TPagination, TPaginationReturn } from './pagination.js'; import { TDbRecord } from './common.js'; diff --git a/packages/common/src/types/proof.ts b/packages/common/src/types/proof.ts index aedac0b5..bda7cfa1 100644 --- a/packages/common/src/types/proof.ts +++ b/packages/common/src/types/proof.ts @@ -1,4 +1,4 @@ -import { JsonProof } from 'o1js'; +import type { JsonProof } from 'o1js'; import { TCollectionRequest } from './collection.js'; import { TDbRecord } from './common.js'; import { TDatabaseRequest } from './database.js'; diff --git a/packages/common/src/types/rollup.ts b/packages/common/src/types/rollup.ts index a38a7fd2..358ab77c 100644 --- a/packages/common/src/types/rollup.ts +++ b/packages/common/src/types/rollup.ts @@ -1,4 +1,4 @@ -import { ObjectId, WithoutId } from 'mongodb'; +import type { ObjectId, WithoutId } from 'mongodb'; import { TDbRecord } from './common'; import { TTransaction, TTransactionRecord } from './transaction'; import { TDatabaseRequest } from './database'; diff --git a/packages/common/src/types/transaction.ts b/packages/common/src/types/transaction.ts index 23164e1c..d8abd59d 100644 --- a/packages/common/src/types/transaction.ts +++ b/packages/common/src/types/transaction.ts @@ -1,4 +1,4 @@ -import { ObjectId, WithoutId } from 'mongodb'; +import type { ObjectId, WithoutId } from 'mongodb'; import { TDbRecord } from './common.js'; import { TDatabaseRequest } from './database.js'; @@ -68,21 +68,15 @@ export type TTransactionRecord = TDbRecord; /** * Transaction request - * @typedef TTransactionRequest + * @typedef TTransactionDraftRequest * @param {string} TDatabaseRequest.databaseName - Database name * @param {ETransactionType} transactionType - Transaction type */ -export type TTransactionRequest = TDatabaseRequest & { +export type TTransactionDraftRequest = TDatabaseRequest & { transactionType: ETransactionType; }; -/** - * Transaction response - * @typedef TTransactionResponse - * @property {TTransaction} transaction (Rollup or Deploy) - * @property {string} _id - Primary key of the transaction - */ -export type TTransactionWithId = WithoutId & { +export type TTransactionDraftResponse = WithoutId & { _id: string; }; @@ -122,3 +116,8 @@ export type TTransactionQueue = Pick< transactionObjectId: ObjectId; payerAddress: string; }; + +// Transaction deploy enqueue +export type TTransactionDeployEnqueueRequest = TDatabaseRequest; + +export type TTransactionDeployEnqueueResponse = string; diff --git a/packages/common/src/types/user.ts b/packages/common/src/types/user.ts index 339e7793..c4aa3bf1 100644 --- a/packages/common/src/types/user.ts +++ b/packages/common/src/types/user.ts @@ -1,4 +1,4 @@ -import { WithoutId } from 'mongodb'; +import type { WithoutId } from 'mongodb'; import { TDbRecord } from './common.js'; import { TPagination, TPaginationReturn } from './pagination.js'; import { TMinaSignature } from './proof.js'; @@ -61,3 +61,13 @@ export type TUserMeResponse = Pick< TUser, 'email' | 'publicKey' | 'userData' | 'userName' >; + +// User sign out +export type TUserSignOutRequest = void; + +export type TUserSignOutResponse = boolean; + +// User ECDSA challenge +export type TUserEcdsaChallengeRequest = void; + +export type TUserEcdsaChallengeResponse = string; diff --git a/packages/permission/package.json b/packages/permission/package.json index 8efacead..79650648 100644 --- a/packages/permission/package.json +++ b/packages/permission/package.json @@ -1,6 +1,6 @@ { "name": "@zkdb/permission", - "version": "0.1.6", + "version": "0.1.7", "description": "zkDatabase for the future of Web3", "author": "chiro@orochi.network", "license": "Apache-2.0", diff --git a/packages/serverless/package.json b/packages/serverless/package.json index 589ef843..1163d821 100644 --- a/packages/serverless/package.json +++ b/packages/serverless/package.json @@ -52,7 +52,7 @@ "@orochi-network/framework": "^2.3.19", "@orochi-network/utilities": "^0.2.42", "@zkdb/common": "^0.1.1", - "@zkdb/permission": "^0.1.6", + "@zkdb/permission": "^0.1.7", "@zkdb/smart-contract": "^1.1.7", "@zkdb/storage": "^1.1.2", "axios": "1.7.9", diff --git a/packages/serverless/src/apollo/app/database.ts b/packages/serverless/src/apollo/app/database.ts index 3c7628f5..e9ee81cc 100644 --- a/packages/serverless/src/apollo/app/database.ts +++ b/packages/serverless/src/apollo/app/database.ts @@ -8,8 +8,8 @@ import { TDatabaseListResponse, TDatabaseRequest, TDatabaseResponse, - TDatabaseUpdateDeployedRequest, - TDatabaseUpdateDeployedResponse, + TDatabaseDeployRequest, + TDatabaseDeployResponse, databaseName, merkleHeight, pagination, @@ -46,7 +46,7 @@ export const typeDefsDatabase = gql` databaseOwner: String! merkleHeight: Int! appPublicKey: String! - databaseSize: Int + sizeOnDisk: Int deployStatus: TransactionStatus! } @@ -97,11 +97,10 @@ export const JOI_DATABASE_CREATE = Joi.object({ merkleHeight, }); -export const JOI_DATABASE_UPDATE_DEPLOY = - Joi.object({ - databaseName, - appPublicKey: publicKey, - }); +export const JOI_DATABASE_UPDATE_DEPLOY = Joi.object({ + databaseName, + appPublicKey: publicKey, +}); // Query const dbStats = publicWrapper( @@ -146,8 +145,8 @@ const dbInfo = publicWrapper( ); const dbDeploy = authorizeWrapper< - TDatabaseUpdateDeployedRequest, - TDatabaseUpdateDeployedResponse + TDatabaseDeployRequest, + TDatabaseDeployResponse >( JOI_DATABASE_UPDATE_DEPLOY, async (_root, { databaseName, appPublicKey }, _) => diff --git a/packages/serverless/src/apollo/app/group.ts b/packages/serverless/src/apollo/app/group.ts index 0939a764..5f4d86e5 100644 --- a/packages/serverless/src/apollo/app/group.ts +++ b/packages/serverless/src/apollo/app/group.ts @@ -6,8 +6,8 @@ import { TGroupAddUserListResponse, TGroupCreateRequest, TGroupCreateResponse, - TGroupInfoDetailRequest, - TGroupInfoDetailResponse, + TGroupDetailRequest, + TGroupDetailResponse, TGroupListAllRequest, TGroupListAllResponse, TGroupListByUserRequest, @@ -108,7 +108,7 @@ export const JOI_GROUP_UPDATE = Joi.object({ newGroupDescription: groupDescription(false), }); -export const JOI_GROUP_DETAIL = Joi.object({ +export const JOI_GROUP_DETAIL = Joi.object({ databaseName, groupName, }); @@ -150,11 +150,10 @@ const groupListByUser = publicWrapper< new ModelUserGroup(databaseName).listGroupByUserName(userName) ); -const groupDetail = publicWrapper< - TGroupInfoDetailRequest, - TGroupInfoDetailResponse ->(JOI_GROUP_DETAIL, async (_root, { databaseName, groupName }) => - Group.detail({ databaseName, groupName }) +const groupDetail = publicWrapper( + JOI_GROUP_DETAIL, + async (_root, { databaseName, groupName }) => + Group.detail({ databaseName, groupName }) ); const groupUpdate = authorizeWrapper( diff --git a/packages/serverless/src/apollo/app/transaction.ts b/packages/serverless/src/apollo/app/transaction.ts index 5b2bbfc3..6690ce16 100644 --- a/packages/serverless/src/apollo/app/transaction.ts +++ b/packages/serverless/src/apollo/app/transaction.ts @@ -3,12 +3,13 @@ import { gql } from '@helper'; import { databaseName, ETransactionType, - TDatabaseRequest, transactionType, - TTransactionRequest, + TTransactionDeployEnqueueRequest, + TTransactionDeployEnqueueResponse, + TTransactionDraftRequest, + TTransactionDraftResponse, TTransactionSubmitRequest, TTransactionSubmitResponse, - TTransactionWithId, } from '@zkdb/common'; import { withTransaction } from '@zkdb/storage'; import GraphQLJSON from 'graphql-type-json'; @@ -52,14 +53,14 @@ export const typeDefsTransaction = gql` `; const transactionDraft = authorizeWrapper< - TTransactionRequest, - TTransactionWithId + TTransactionDraftRequest, + TTransactionDraftResponse >( Joi.object({ databaseName, transactionType, }), - async (_root: unknown, args: TTransactionRequest, ctx) => { + async (_root, args, ctx) => { const transaction = await Transaction.draft( args.databaseName, ctx.userName, @@ -73,11 +74,14 @@ const transactionDraft = authorizeWrapper< } ); -const transactionDeployEnqueue = authorizeWrapper( +const transactionDeployEnqueue = authorizeWrapper< + TTransactionDeployEnqueueRequest, + TTransactionDeployEnqueueResponse +>( Joi.object({ databaseName, }), - async (_root: unknown, args: TDatabaseRequest, ctx) => + async (_root, args, ctx) => withTransaction(async (session) => ( await Transaction.enqueue( @@ -99,7 +103,7 @@ const transactionSubmit = authorizeWrapper< transactionObjectId: Joi.string().required(), txHash: Joi.string().required(), }), - async (_root: unknown, args, ctx) => + async (_root, args, ctx) => Transaction.submit( args.databaseName, ctx.userName, diff --git a/packages/serverless/src/domain/use-case/transaction.ts b/packages/serverless/src/domain/use-case/transaction.ts index ffbb39a7..deaa76a2 100644 --- a/packages/serverless/src/domain/use-case/transaction.ts +++ b/packages/serverless/src/domain/use-case/transaction.ts @@ -4,8 +4,7 @@ import { FixedFloat } from '@orochi-network/utilities'; import { ETransactionStatus, ETransactionType, - TDbRecord, - TTransaction, + TTransactionRecord, } from '@zkdb/common'; import { MinaNetwork } from '@zkdb/smart-contract'; import { ModelMetadataDatabase, ModelTransaction } from '@zkdb/storage'; @@ -125,7 +124,7 @@ export class Transaction { actor: string, transactionType: ETransactionType, session?: ClientSession - ): Promise> { + ): Promise { await Database.ownershipCheck(databaseName, actor, session); const imUser = new ModelUser(); diff --git a/packages/serverless/tsconfig.json b/packages/serverless/tsconfig.json index efb2f517..e31e25b6 100644 --- a/packages/serverless/tsconfig.json +++ b/packages/serverless/tsconfig.json @@ -11,7 +11,8 @@ "emitDecoratorMetadata": true, "strictPropertyInitialization": false, "noFallthroughCasesInSwitch": true, - "types": ["node", "jest"], + // Removed types jest + "types": ["node"], "composite": true, "declarationMap": false, "preserveSymlinks": true, @@ -26,7 +27,7 @@ }, // For jest + o1js Schema to work // https://github.com/o1-labs/o1js/issues/1380#issuecomment-1902038952 - "useDefineForClassFields": false + // "useDefineForClassFields": false }, "include": ["**/*.ts"], "exclude": ["build", "node_modules", "typechain/**/*.ts", "test/**/*.test.ts"] diff --git a/spectaql-config.yml b/spectaql-config.yml index 7577bc8e..3f4db36c 100644 --- a/spectaql-config.yml +++ b/spectaql-config.yml @@ -1,14 +1,14 @@ info: - title: 'zkDatabase API Documentation' - description: 'This is the documentation for zkDatabase API.' - version: '1.0.0' + title: "zkDatabase API Documentation" + description: "This is the documentation for zkDatabase API." + version: "1.0.0" introspection: - url: 'http://localhost:4000/graphql' + url: "http://zkdb-serverless.zenfactory.org/graphql" output: - directory: './docs' + directory: "./docs" theme: logo: - url: 'https://your-company-logo-url.com/logo.png' + url: "https://avatars.githubusercontent.com/u/94106298?s=200&v=4" diff --git a/yarn.lock b/yarn.lock index 677e1857..32027333 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,10 +27,10 @@ resolved "https://registry.yarnpkg.com/@apollo/cache-control-types/-/cache-control-types-1.0.3.tgz#5da62cf64c3b4419dabfef4536b57a40c8ff0b47" integrity sha512-F17/vCp7QVwom9eG7ToauIKdAxpSoadsJnqIfyryLFSkLSOEqu+eC5Z3N8OXcUVStuOMcNHlyraRsA6rRICu4g== -"@apollo/client@^3.10.6": - version "3.12.3" - resolved "https://registry.yarnpkg.com/@apollo/client/-/client-3.12.3.tgz#0d252749baad8328e06883fe118dc7e73e3bbb1f" - integrity sha512-KZ5zymRdb8bMbGUb1wP2U04ff7qIGgaC1BCdCVC+IPFiXkxEhHBc5fDEQOwAUT+vUo9KbBh3g7QK/JCOswn59w== +"@apollo/client@^3.12.4": + version "3.12.4" + resolved "https://registry.yarnpkg.com/@apollo/client/-/client-3.12.4.tgz#d8b5753459dfb5642129247c02956fe5b5ad8f11" + integrity sha512-S/eC9jxEW9Jg1BjD6AZonE1fHxYuvC3gFHop8FRQkUdeK63MmBD5r0DOrN2WlJbwha1MSD6A97OwXwjaujEQpA== dependencies: "@graphql-typed-document-node/core" "^3.1.1" "@wry/caches" "^1.0.0" @@ -2647,6 +2647,11 @@ dependencies: tslib "^2.3.0" +"@zkdb/permission@0.1.6": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@zkdb/permission/-/permission-0.1.6.tgz#bf8cbd3510db6f7c6490e6baaafd81d63f272dd9" + integrity sha512-vuVMpqDOfIXwi+jYlNWjoQeclW8af5w35z5/48tIl8ktmP7PNY+Jh0N+6r3sJ1yAPWM5/Xo3fnmD7Ts1uWQpmg== + abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" @@ -7524,6 +7529,11 @@ react-is@^18.0.0: resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#e83557dc12eae63a99e003a46388b1dcbb44db7e" integrity sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg== +react@^19.0.0: + version "19.0.0" + resolved "https://registry.yarnpkg.com/react/-/react-19.0.0.tgz#6e1969251b9f108870aa4bff37a0ce9ddfaaabdd" + integrity sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ== + readable-stream@^2.2.2: version "2.3.8" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" @@ -8188,16 +8198,7 @@ string-template@~0.2.1: resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add" integrity sha512-Yptehjogou2xm4UJbxJ4CxgZx12HBfeystp0y3x7s4Dj32ltVVG1Gg8YhKjHZkHicuKpZX/ffilA8505VbUbpw== -"string-width-cjs@npm:string-width@^4.2.0": - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -8266,7 +8267,7 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -8280,13 +8281,6 @@ strip-ansi@^3.0.0: dependencies: ansi-regex "^2.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -8925,7 +8919,7 @@ wordwrap@^1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -8943,15 +8937,6 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"