From 865c085734595aadaae592ef5fb03fb8b23b01ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Barc=C3=A9los?= Date: Thu, 27 Jul 2023 10:20:50 +0200 Subject: [PATCH] Export `RecordShape` type (#1117) This type is the base type used to define the shape of the Record. Exporting this type enables user to use it for defining custom generic function to work with result and records without have to redefine the shape type. The type was renamed from `Dict` to `RecordShape` for having a more meaningful name for external consumers. --- packages/core/src/index.ts | 3 +- packages/core/src/record.ts | 18 +++++----- packages/core/src/result-eager.ts | 4 +-- packages/core/src/result-transformers.ts | 6 ++-- packages/core/src/result.ts | 34 +++++++++---------- packages/core/src/session.ts | 6 ++-- packages/core/src/transaction-managed.ts | 6 ++-- packages/core/src/transaction.ts | 4 +-- packages/core/test/driver.test.ts | 4 +-- packages/neo4j-driver-deno/lib/core/index.ts | 3 +- packages/neo4j-driver-deno/lib/core/record.ts | 18 +++++----- .../lib/core/result-eager.ts | 4 +-- .../lib/core/result-transformers.ts | 6 ++-- packages/neo4j-driver-deno/lib/core/result.ts | 34 +++++++++---------- .../neo4j-driver-deno/lib/core/session.ts | 6 ++-- .../lib/core/transaction-managed.ts | 6 ++-- .../neo4j-driver-deno/lib/core/transaction.ts | 4 +-- packages/neo4j-driver-deno/lib/mod.ts | 2 ++ packages/neo4j-driver-lite/src/index.ts | 2 ++ .../neo4j-driver-lite/test/unit/index.test.ts | 13 ++++++- .../neo4j-driver/test/types/export.test.ts | 6 ++++ packages/neo4j-driver/types/index.d.ts | 2 ++ 22 files changed, 108 insertions(+), 83 deletions(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 01672d3cc..34acbcc60 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -54,7 +54,7 @@ import { PathSegment, isPathSegment } from './graph-types' -import Record from './record' +import Record, { RecordShape } from './record' import { isPoint, Point } from './spatial-types' import ResultSummary, { queryType, @@ -259,6 +259,7 @@ export type { SessionConfig, QueryConfig, RoutingControl, + RecordShape, ResultTransformer, NotificationCategory, NotificationSeverityLevel, diff --git a/packages/core/src/record.ts b/packages/core/src/record.ts index e10a7bcc3..cac99dd01 100644 --- a/packages/core/src/record.ts +++ b/packages/core/src/record.ts @@ -19,27 +19,27 @@ import { newError } from './error' -type Dict = { +type RecordShape = { [K in Key]: Value } type Visitor< - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries > = MapVisitor type MapVisitor< ReturnType, - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries > = (value: Entries[Key], key: Key, record: Record) => ReturnType function generateFieldLookup< - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries, - FieldLookup extends Dict = Dict + FieldLookup extends RecordShape = RecordShape > (keys: Key[]): FieldLookup { - const lookup: Dict = {} + const lookup: RecordShape = {} keys.forEach((name, idx) => { lookup[name as string] = idx }) @@ -66,9 +66,9 @@ function generateFieldLookup< * @access public */ class Record< - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries, - FieldLookup extends Dict = Dict + FieldLookup extends RecordShape = RecordShape > { keys: Key[] length: number @@ -240,4 +240,4 @@ class Record< } export default Record -export type { Dict } +export type { RecordShape } diff --git a/packages/core/src/result-eager.ts b/packages/core/src/result-eager.ts index e4a9cf758..d9b02ac97 100644 --- a/packages/core/src/result-eager.ts +++ b/packages/core/src/result-eager.ts @@ -17,13 +17,13 @@ * limitations under the License. */ -import Record, { Dict } from './record' +import Record, { RecordShape } from './record' import ResultSummary from './result-summary' /** * Represents the fully streamed result */ -export default class EagerResult { +export default class EagerResult { keys: string[] records: Array> summary: ResultSummary diff --git a/packages/core/src/result-transformers.ts b/packages/core/src/result-transformers.ts index 8eee3007c..8dbc4e9e1 100644 --- a/packages/core/src/result-transformers.ts +++ b/packages/core/src/result-transformers.ts @@ -17,13 +17,13 @@ * limitations under the License. */ -import Record, { Dict } from './record' +import Record, { RecordShape } from './record' import Result from './result' import EagerResult from './result-eager' import ResultSummary from './result-summary' import { newError } from './error' -async function createEagerResultFromResult (result: Result): Promise> { +async function createEagerResultFromResult (result: Result): Promise> { const { summary, records } = await result const keys = await result.keys() return new EagerResult(keys, records, summary) @@ -59,7 +59,7 @@ class ResultTransformers { * * @returns {ResultTransformer>} The result transformer */ - eagerResultTransformer(): ResultTransformer> { + eagerResultTransformer(): ResultTransformer> { return createEagerResultFromResult } diff --git a/packages/core/src/result.ts b/packages/core/src/result.ts index 3e050a06d..8f3bfb627 100644 --- a/packages/core/src/result.ts +++ b/packages/core/src/result.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/promise-function-async */ import ResultSummary from './result-summary' -import Record, { Dict } from './record' +import Record, { RecordShape } from './record' import { Query, PeekableAsyncIterator } from './types' import { observer, util, connectionHolder } from './internal' import { newError, PROTOCOL_ERROR } from './error' @@ -56,8 +56,8 @@ const DEFAULT_ON_KEYS = (keys: string[]): void => {} * The query result is the combination of the {@link ResultSummary} and * the array {@link Record[]} produced by the query */ -interface QueryResult { - records: Array> +interface QueryResult { + records: Array> summary: ResultSummary } @@ -65,7 +65,7 @@ interface QueryResult { * Interface to observe updates on the Result which is being produced. * */ -interface ResultObserver { +interface ResultObserver { /** * Receive the keys present on the record whenever this information is available * @@ -77,7 +77,7 @@ interface ResultObserver { * Receive the each record present on the {@link @Result} * @param {Record} record The {@link Record} produced */ - onNext?: (record: Record) => void + onNext?: (record: Record) => void /** * Called when the result is fully received @@ -86,7 +86,7 @@ interface ResultObserver { onCompleted?: (summary: ResultSummary) => void /** - * Called when some error occurs during the result proccess or query execution + * Called when some error occurs during the result processing or query execution * @param {Error} error The error ocurred */ onError?: (error: Error) => void @@ -111,7 +111,7 @@ interface QueuedResultObserver extends ResultObserver { * Alternatively can be consumed lazily using {@link Result#subscribe} function. * @access public */ -class Result implements Promise> { +class Result implements Promise> { private readonly _stack: string | null private readonly _streamObserverPromise: Promise private _p: Promise | null @@ -212,12 +212,12 @@ class Result implements Promise> { + private _getOrCreatePromise (): Promise> { if (this._p == null) { this._p = new Promise((resolve, reject) => { - const records: Record[] = [] + const records: Array> = [] const observer = { - onNext: (record: Record) => { + onNext: (record: Record) => { records.push(record) }, onCompleted: (summary: ResultSummary) => { @@ -240,9 +240,9 @@ class Result implements Promise, ResultSummary>} The async iterator for the Results + * @returns {PeekableAsyncIterator, ResultSummary>} The async iterator for the Results */ - [Symbol.asyncIterator] (): PeekableAsyncIterator, ResultSummary> { + [Symbol.asyncIterator] (): PeekableAsyncIterator, ResultSummary> { if (!this.isOpen()) { const error = newError('Result is already consumed') return { @@ -345,9 +345,9 @@ class Result implements Promise, TResult2 = never>( + then, TResult2 = never>( onFulfilled?: - | ((value: QueryResult) => TResult1 | PromiseLike) + | ((value: QueryResult) => TResult1 | PromiseLike) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike) | null ): Promise { @@ -364,7 +364,7 @@ class Result implements Promise( onRejected?: ((reason: any) => TResult | PromiseLike) | null - ): Promise | TResult> { + ): Promise | TResult> { return this._getOrCreatePromise().catch(onRejected) } @@ -376,7 +376,7 @@ class Result implements Promise void) | null): Promise> { + finally (onfinally?: (() => void) | null): Promise> { return this._getOrCreatePromise().finally(onfinally) } @@ -391,7 +391,7 @@ class Result implements Promise): void { + subscribe (observer: ResultObserver): void { this._subscribe(observer) .catch(() => {}) } diff --git a/packages/core/src/session.ts b/packages/core/src/session.ts index b5479e29d..973edc73f 100644 --- a/packages/core/src/session.ts +++ b/packages/core/src/session.ts @@ -36,7 +36,7 @@ import { NumberOrInteger } from './graph-types' import TransactionPromise from './transaction-promise' import ManagedTransaction from './transaction-managed' import BookmarkManager from './bookmark-manager' -import { Dict } from './record' +import { RecordShape } from './record' import NotificationFilter from './notification-filter' import { Logger } from './internal/logger' @@ -171,11 +171,11 @@ class Session { * @param {TransactionConfig} [transactionConfig] - Configuration for the new auto-commit transaction. * @return {Result} New Result. */ - run ( + run ( query: Query, parameters?: any, transactionConfig?: TransactionConfig - ): Result { + ): Result { const { validatedQuery, params } = validateQueryAndParameters( query, parameters diff --git a/packages/core/src/transaction-managed.ts b/packages/core/src/transaction-managed.ts index e40206598..a6796b95f 100644 --- a/packages/core/src/transaction-managed.ts +++ b/packages/core/src/transaction-managed.ts @@ -20,9 +20,9 @@ import Result from './result' import Transaction from './transaction' import { Query } from './types' -import { Dict } from './record' +import { RecordShape } from './record' -type Run = (query: Query, parameters?: any) => Result +type Run = (query: Query, parameters?: any) => Result /** * Represents a transaction that is managed by the transaction executor. @@ -61,7 +61,7 @@ class ManagedTransaction { * @param {Object} parameters - Map with parameters to use in query * @return {Result} New Result */ - run (query: Query, parameters?: any): Result { + run (query: Query, parameters?: any): Result { return this._run(query, parameters) } } diff --git a/packages/core/src/transaction.ts b/packages/core/src/transaction.ts index ca0c95884..4fdc14f90 100644 --- a/packages/core/src/transaction.ts +++ b/packages/core/src/transaction.ts @@ -37,7 +37,7 @@ import { import { newError } from './error' import Result from './result' import { Query } from './types' -import { Dict } from './record' +import { RecordShape } from './record' import NotificationFilter from './notification-filter' /** @@ -183,7 +183,7 @@ class Transaction { * @param {Object} parameters - Map with parameters to use in query * @return {Result} New Result */ - run (query: Query, parameters?: any): Result { + run (query: Query, parameters?: any): Result { const { validatedQuery, params } = validateQueryAndParameters( query, parameters diff --git a/packages/core/test/driver.test.ts b/packages/core/test/driver.test.ts index 17d739c06..798e15468 100644 --- a/packages/core/test/driver.test.ts +++ b/packages/core/test/driver.test.ts @@ -25,7 +25,7 @@ import QueryExecutor from '../src/internal/query-executor' import { ConfiguredCustomResolver } from '../src/internal/resolver' import { LogLevel } from '../src/types' import resultTransformers from '../src/result-transformers' -import Record, { Dict } from '../src/record' +import Record, { RecordShape } from '../src/record' import { validNotificationFilters } from './utils/notification-filters.fixtures' describe('Driver', () => { @@ -543,7 +543,7 @@ describe('Driver', () => { await expect(output).rejects.toThrow(expectedError) }) - function extendsDefaultWith> (config: QueryConfig) { + function extendsDefaultWith> (config: QueryConfig) { return () => { const defaultConfig = { resultTransformer: resultTransformers.eagerResultTransformer(), diff --git a/packages/neo4j-driver-deno/lib/core/index.ts b/packages/neo4j-driver-deno/lib/core/index.ts index fb924bb29..5b5d1cd94 100644 --- a/packages/neo4j-driver-deno/lib/core/index.ts +++ b/packages/neo4j-driver-deno/lib/core/index.ts @@ -54,7 +54,7 @@ import { PathSegment, isPathSegment } from './graph-types.ts' -import Record from './record.ts' +import Record, { RecordShape } from './record.ts' import { isPoint, Point } from './spatial-types.ts' import ResultSummary, { queryType, @@ -259,6 +259,7 @@ export type { SessionConfig, QueryConfig, RoutingControl, + RecordShape, ResultTransformer, NotificationCategory, NotificationSeverityLevel, diff --git a/packages/neo4j-driver-deno/lib/core/record.ts b/packages/neo4j-driver-deno/lib/core/record.ts index 02a0a434e..71ba02742 100644 --- a/packages/neo4j-driver-deno/lib/core/record.ts +++ b/packages/neo4j-driver-deno/lib/core/record.ts @@ -19,27 +19,27 @@ import { newError } from './error.ts' -type Dict = { +type RecordShape = { [K in Key]: Value } type Visitor< - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries > = MapVisitor type MapVisitor< ReturnType, - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries > = (value: Entries[Key], key: Key, record: Record) => ReturnType function generateFieldLookup< - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries, - FieldLookup extends Dict = Dict + FieldLookup extends RecordShape = RecordShape > (keys: Key[]): FieldLookup { - const lookup: Dict = {} + const lookup: RecordShape = {} keys.forEach((name, idx) => { lookup[name as string] = idx }) @@ -66,9 +66,9 @@ function generateFieldLookup< * @access public */ class Record< - Entries extends Dict = Dict, + Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries, - FieldLookup extends Dict = Dict + FieldLookup extends RecordShape = RecordShape > { keys: Key[] length: number @@ -240,4 +240,4 @@ class Record< } export default Record -export type { Dict } +export type { RecordShape } diff --git a/packages/neo4j-driver-deno/lib/core/result-eager.ts b/packages/neo4j-driver-deno/lib/core/result-eager.ts index 5a4588d24..efcde39f4 100644 --- a/packages/neo4j-driver-deno/lib/core/result-eager.ts +++ b/packages/neo4j-driver-deno/lib/core/result-eager.ts @@ -17,13 +17,13 @@ * limitations under the License. */ -import Record, { Dict } from './record.ts' +import Record, { RecordShape } from './record.ts' import ResultSummary from './result-summary.ts' /** * Represents the fully streamed result */ -export default class EagerResult { +export default class EagerResult { keys: string[] records: Array> summary: ResultSummary diff --git a/packages/neo4j-driver-deno/lib/core/result-transformers.ts b/packages/neo4j-driver-deno/lib/core/result-transformers.ts index 7190589af..0ac8d94f6 100644 --- a/packages/neo4j-driver-deno/lib/core/result-transformers.ts +++ b/packages/neo4j-driver-deno/lib/core/result-transformers.ts @@ -17,13 +17,13 @@ * limitations under the License. */ -import Record, { Dict } from './record.ts' +import Record, { RecordShape } from './record.ts' import Result from './result.ts' import EagerResult from './result-eager.ts' import ResultSummary from './result-summary.ts' import { newError } from './error.ts' -async function createEagerResultFromResult (result: Result): Promise> { +async function createEagerResultFromResult (result: Result): Promise> { const { summary, records } = await result const keys = await result.keys() return new EagerResult(keys, records, summary) @@ -59,7 +59,7 @@ class ResultTransformers { * * @returns {ResultTransformer>} The result transformer */ - eagerResultTransformer(): ResultTransformer> { + eagerResultTransformer(): ResultTransformer> { return createEagerResultFromResult } diff --git a/packages/neo4j-driver-deno/lib/core/result.ts b/packages/neo4j-driver-deno/lib/core/result.ts index ab3e8a4df..06d879092 100644 --- a/packages/neo4j-driver-deno/lib/core/result.ts +++ b/packages/neo4j-driver-deno/lib/core/result.ts @@ -20,7 +20,7 @@ /* eslint-disable @typescript-eslint/promise-function-async */ import ResultSummary from './result-summary.ts' -import Record, { Dict } from './record.ts' +import Record, { RecordShape } from './record.ts' import { Query, PeekableAsyncIterator } from './types.ts' import { observer, util, connectionHolder } from './internal/index.ts' import { newError, PROTOCOL_ERROR } from './error.ts' @@ -56,8 +56,8 @@ const DEFAULT_ON_KEYS = (keys: string[]): void => {} * The query result is the combination of the {@link ResultSummary} and * the array {@link Record[]} produced by the query */ -interface QueryResult { - records: Array> +interface QueryResult { + records: Array> summary: ResultSummary } @@ -65,7 +65,7 @@ interface QueryResult { * Interface to observe updates on the Result which is being produced. * */ -interface ResultObserver { +interface ResultObserver { /** * Receive the keys present on the record whenever this information is available * @@ -77,7 +77,7 @@ interface ResultObserver { * Receive the each record present on the {@link @Result} * @param {Record} record The {@link Record} produced */ - onNext?: (record: Record) => void + onNext?: (record: Record) => void /** * Called when the result is fully received @@ -86,7 +86,7 @@ interface ResultObserver { onCompleted?: (summary: ResultSummary) => void /** - * Called when some error occurs during the result proccess or query execution + * Called when some error occurs during the result processing or query execution * @param {Error} error The error ocurred */ onError?: (error: Error) => void @@ -111,7 +111,7 @@ interface QueuedResultObserver extends ResultObserver { * Alternatively can be consumed lazily using {@link Result#subscribe} function. * @access public */ -class Result implements Promise> { +class Result implements Promise> { private readonly _stack: string | null private readonly _streamObserverPromise: Promise private _p: Promise | null @@ -212,12 +212,12 @@ class Result implements Promise> { + private _getOrCreatePromise (): Promise> { if (this._p == null) { this._p = new Promise((resolve, reject) => { - const records: Record[] = [] + const records: Array> = [] const observer = { - onNext: (record: Record) => { + onNext: (record: Record) => { records.push(record) }, onCompleted: (summary: ResultSummary) => { @@ -240,9 +240,9 @@ class Result implements Promise, ResultSummary>} The async iterator for the Results + * @returns {PeekableAsyncIterator, ResultSummary>} The async iterator for the Results */ - [Symbol.asyncIterator] (): PeekableAsyncIterator, ResultSummary> { + [Symbol.asyncIterator] (): PeekableAsyncIterator, ResultSummary> { if (!this.isOpen()) { const error = newError('Result is already consumed') return { @@ -345,9 +345,9 @@ class Result implements Promise, TResult2 = never>( + then, TResult2 = never>( onFulfilled?: - | ((value: QueryResult) => TResult1 | PromiseLike) + | ((value: QueryResult) => TResult1 | PromiseLike) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike) | null ): Promise { @@ -364,7 +364,7 @@ class Result implements Promise( onRejected?: ((reason: any) => TResult | PromiseLike) | null - ): Promise | TResult> { + ): Promise | TResult> { return this._getOrCreatePromise().catch(onRejected) } @@ -376,7 +376,7 @@ class Result implements Promise void) | null): Promise> { + finally (onfinally?: (() => void) | null): Promise> { return this._getOrCreatePromise().finally(onfinally) } @@ -391,7 +391,7 @@ class Result implements Promise): void { + subscribe (observer: ResultObserver): void { this._subscribe(observer) .catch(() => {}) } diff --git a/packages/neo4j-driver-deno/lib/core/session.ts b/packages/neo4j-driver-deno/lib/core/session.ts index 12d5269e9..386991b17 100644 --- a/packages/neo4j-driver-deno/lib/core/session.ts +++ b/packages/neo4j-driver-deno/lib/core/session.ts @@ -36,7 +36,7 @@ import { NumberOrInteger } from './graph-types.ts' import TransactionPromise from './transaction-promise.ts' import ManagedTransaction from './transaction-managed.ts' import BookmarkManager from './bookmark-manager.ts' -import { Dict } from './record.ts' +import { RecordShape } from './record.ts' import NotificationFilter from './notification-filter.ts' import { Logger } from './internal/logger.ts' @@ -171,11 +171,11 @@ class Session { * @param {TransactionConfig} [transactionConfig] - Configuration for the new auto-commit transaction. * @return {Result} New Result. */ - run ( + run ( query: Query, parameters?: any, transactionConfig?: TransactionConfig - ): Result { + ): Result { const { validatedQuery, params } = validateQueryAndParameters( query, parameters diff --git a/packages/neo4j-driver-deno/lib/core/transaction-managed.ts b/packages/neo4j-driver-deno/lib/core/transaction-managed.ts index b3283a2ff..e4220232a 100644 --- a/packages/neo4j-driver-deno/lib/core/transaction-managed.ts +++ b/packages/neo4j-driver-deno/lib/core/transaction-managed.ts @@ -20,9 +20,9 @@ import Result from './result.ts' import Transaction from './transaction.ts' import { Query } from './types.ts' -import { Dict } from './record.ts' +import { RecordShape } from './record.ts' -type Run = (query: Query, parameters?: any) => Result +type Run = (query: Query, parameters?: any) => Result /** * Represents a transaction that is managed by the transaction executor. @@ -61,7 +61,7 @@ class ManagedTransaction { * @param {Object} parameters - Map with parameters to use in query * @return {Result} New Result */ - run (query: Query, parameters?: any): Result { + run (query: Query, parameters?: any): Result { return this._run(query, parameters) } } diff --git a/packages/neo4j-driver-deno/lib/core/transaction.ts b/packages/neo4j-driver-deno/lib/core/transaction.ts index 91c786de2..8cfa651a5 100644 --- a/packages/neo4j-driver-deno/lib/core/transaction.ts +++ b/packages/neo4j-driver-deno/lib/core/transaction.ts @@ -37,7 +37,7 @@ import { import { newError } from './error.ts' import Result from './result.ts' import { Query } from './types.ts' -import { Dict } from './record.ts' +import { RecordShape } from './record.ts' import NotificationFilter from './notification-filter.ts' /** @@ -183,7 +183,7 @@ class Transaction { * @param {Object} parameters - Map with parameters to use in query * @return {Result} New Result */ - run (query: Query, parameters?: any): Result { + run (query: Query, parameters?: any): Result { const { validatedQuery, params } = validateQueryAndParameters( query, parameters diff --git a/packages/neo4j-driver-deno/lib/mod.ts b/packages/neo4j-driver-deno/lib/mod.ts index e0495cac0..2b919e5e3 100644 --- a/packages/neo4j-driver-deno/lib/mod.ts +++ b/packages/neo4j-driver-deno/lib/mod.ts @@ -80,6 +80,7 @@ import { QueryResult, QueryStatistics, Record, + RecordShape, Relationship, Result, ResultObserver, @@ -509,6 +510,7 @@ export type { SessionConfig, QueryConfig, RoutingControl, + RecordShape, ResultTransformer, NotificationCategory, NotificationSeverityLevel, diff --git a/packages/neo4j-driver-lite/src/index.ts b/packages/neo4j-driver-lite/src/index.ts index f3ec6ad10..7007e1cab 100644 --- a/packages/neo4j-driver-lite/src/index.ts +++ b/packages/neo4j-driver-lite/src/index.ts @@ -80,6 +80,7 @@ import { QueryResult, QueryStatistics, Record, + RecordShape, Relationship, Result, ResultObserver, @@ -508,6 +509,7 @@ export type { SessionConfig, QueryConfig, RoutingControl, + RecordShape, ResultTransformer, NotificationCategory, NotificationSeverityLevel, diff --git a/packages/neo4j-driver-lite/test/unit/index.test.ts b/packages/neo4j-driver-lite/test/unit/index.test.ts index 8542e88e9..f3a0134d5 100644 --- a/packages/neo4j-driver-lite/test/unit/index.test.ts +++ b/packages/neo4j-driver-lite/test/unit/index.test.ts @@ -56,7 +56,8 @@ import neo4j, { isRelationship, isPath, isPathSegment, - isUnboundRelationship + isUnboundRelationship, + RecordShape } from '../../' import { internal } from 'neo4j-driver-core' @@ -453,4 +454,14 @@ describe('index', () => { expect(neo4j.notificationFilterDisabledCategory.DEPRECATION).toBeDefined() expect(neo4j.notificationFilterDisabledCategory.GENERIC).toBeDefined() }) + + it('should export RecordShape', () => { + // just checking if record shape is exported correctly + const shape: RecordShape = { + a: 1234, + 2: '2' + } + + expect(shape).toBeDefined() + }) }) diff --git a/packages/neo4j-driver/test/types/export.test.ts b/packages/neo4j-driver/test/types/export.test.ts index d316d9dba..9cf8d109d 100644 --- a/packages/neo4j-driver/test/types/export.test.ts +++ b/packages/neo4j-driver/test/types/export.test.ts @@ -23,6 +23,7 @@ import { Bookmarks } from 'neo4j-driver-core/types/internal/bookmarks' import { ConnectionProvider, internal } from 'neo4j-driver-core' import driver, { DateTime, + RecordShape, RxSession, RxTransaction, RxResult, @@ -136,3 +137,8 @@ const instanceOfDriverRxSession: boolean = dummy instanceof driver.RxSession const instanceOfDriverRxTransaction: boolean = dummy instanceof driver.RxTransaction const instanceOfDriverRxManagedTransaction: boolean = dummy instanceof driver.RxManagedTransaction const instanceOfDriverRxResult: boolean = dummy instanceof driver.RxResult + +const recordShape: RecordShape = { + a: 1234, + 2: 'abc' +} diff --git a/packages/neo4j-driver/types/index.d.ts b/packages/neo4j-driver/types/index.d.ts index b8baf39af..e0f1489af 100644 --- a/packages/neo4j-driver/types/index.d.ts +++ b/packages/neo4j-driver/types/index.d.ts @@ -52,6 +52,7 @@ import { Relationship, UnboundRelationship, Record, + RecordShape, ResultSummary, Notification, NotificationPosition, @@ -367,6 +368,7 @@ export type { SessionConfig, QueryConfig, RoutingControl, + RecordShape, ResultTransformer, NotificationCategory, NotificationSeverityLevel,