Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7c0e7a9
Introduce Result, Record and Graph types mappping
bigmontz Nov 8, 2023
af6e4b9
Add global registry
bigmontz Nov 8, 2023
a1e57a6
sync deno
bigmontz Nov 8, 2023
b9b4d41
Documentation additions, import fixes and result.as fix
MaxAake Mar 10, 2025
23a912d
deno sync
MaxAake Mar 10, 2025
8cb52e5
mapper undef check
MaxAake Mar 10, 2025
b9235fb
deno sync
MaxAake Mar 10, 2025
22869f9
initialize mapper and add namemapping
MaxAake Mar 11, 2025
1b10520
deny sync
MaxAake Mar 11, 2025
32161bf
improved name mappers
MaxAake Mar 12, 2025
51cd52e
deno sync
MaxAake Mar 12, 2025
c3aa798
simplify name translations
MaxAake Mar 14, 2025
5e9322a
deno sync
MaxAake Mar 14, 2025
0705c5a
name mapping documentation
MaxAake Mar 17, 2025
3ff8edd
deno sync
MaxAake Mar 17, 2025
1b8ecbc
example test and fix to convention namecheck
MaxAake Mar 17, 2025
83ea763
license header
MaxAake Mar 17, 2025
5a678c8
unit tests for mapping
MaxAake Mar 18, 2025
a6ba1b2
integration test expansion
MaxAake Mar 24, 2025
6f1dcba
small doc changes and renaming hydrated
MaxAake Mar 26, 2025
e0d439c
remove global exports of mapping functions
MaxAake Mar 26, 2025
c39407a
hydrated renamed in examples testing
MaxAake Mar 28, 2025
ad476b6
Refactored Results
MaxAake Apr 1, 2025
53ceaa5
deno sync
MaxAake Apr 1, 2025
0590d8b
renaming and exporting fix
MaxAake Apr 10, 2025
ea13373
deno
MaxAake Apr 10, 2025
0c4f988
small naming conventions refactor
MaxAake Apr 15, 2025
6673b91
deno sync
MaxAake Apr 15, 2025
4c037dd
rename the mapping object for clarity
MaxAake Apr 16, 2025
e591df1
improved ROM object documentation
MaxAake Apr 22, 2025
c349228
deno sync
MaxAake Apr 22, 2025
9663b64
rename rulefactory object, introduce mapping decorators
MaxAake Jul 8, 2025
2e2295a
deno sync
MaxAake Jul 8, 2025
95fbed5
minor fixes after rebase
MaxAake Sep 5, 2025
ead6059
deno sync
MaxAake Sep 5, 2025
62b8aba
fixing up the decorators somewhat
MaxAake Sep 5, 2025
d0ff0ea
deno sync
MaxAake Sep 5, 2025
b781d20
polyfill decorators
MaxAake Sep 5, 2025
f4183fa
mark experimental features
MaxAake Sep 5, 2025
b5aec60
deno sync
MaxAake Sep 8, 2025
80ded01
fix some tests
MaxAake Sep 8, 2025
821f3ab
bookmarkmanager in test
MaxAake Sep 8, 2025
0224b19
Update record-object-mapping.test.js
MaxAake Sep 8, 2025
1b0ef7b
skip register test on browser
MaxAake Sep 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"type": "module",
"devDependencies": {
"@types/node": "^24.0.10",
"husky": "^8.0.3",
"lerna": "^4.0.0",
"lint-staged": "^14.0.0",
Expand Down
49 changes: 49 additions & 0 deletions packages/core/src/graph-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
import Integer from './integer'
import { stringify } from './json'
import { Rules, GenericConstructor, as } from './mapping.highlevel'

type StandardDate = Date
/**
Expand Down Expand Up @@ -82,6 +83,22 @@ class Node<T extends NumberOrInteger = Integer, P extends Properties = Propertie
this.elementId = _valueOrGetDefault(elementId, () => identity.toString())
}

/**
* Hydrates an object of a given type with the properties of the node
*
* @param {GenericConstructor<T> | Rules} constructorOrRules Contructor for the desired type or {@link Rules} for the hydration
* @param {Rules} [rules] {@link Rules} for the hydration
* @returns {T}
*/
as <T extends {} = Object>(rules: Rules): T
as <T extends {} = Object>(genericConstructor: GenericConstructor<T>): T
as <T extends {} = Object>(genericConstructor: GenericConstructor<T>, rules?: Rules): T
as <T extends {} = Object>(constructorOrRules: GenericConstructor<T> | Rules, rules?: Rules): T {
return as({
get: (key) => this.properties[key]
}, constructorOrRules, rules)
}

/**
* @ignore
*/
Expand Down Expand Up @@ -199,6 +216,22 @@ class Relationship<T extends NumberOrInteger = Integer, P extends Properties = P
this.endNodeElementId = _valueOrGetDefault(endNodeElementId, () => end.toString())
}

/**
* Hydrates an object of a given type with the properties of the relationship
*
* @param {GenericConstructor<T> | Rules} constructorOrRules Contructor for the desired type or {@link Rules} for the hydration
* @param {Rules} [rules] {@link Rules} for the hydration
* @returns {T}
*/
as <T extends {} = Object>(rules: Rules): T
as <T extends {} = Object>(genericConstructor: GenericConstructor<T>): T
as <T extends {} = Object>(genericConstructor: GenericConstructor<T>, rules?: Rules): T
as <T extends {} = Object>(constructorOrRules: GenericConstructor<T> | Rules, rules?: Rules): T {
return as({
get: (key) => this.properties[key]
}, constructorOrRules, rules)
}

/**
* @ignore
*/
Expand Down Expand Up @@ -320,6 +353,22 @@ class UnboundRelationship<T extends NumberOrInteger = Integer, P extends Propert
)
}

/**
* Hydrates an object of a given type with the properties of the relationship
*
* @param {GenericConstructor<T> | Rules} constructorOrRules Contructor for the desired type or {@link Rules} for the hydration
* @param {Rules} [rules] {@link Rules} for the hydration
* @returns {T}
*/
as <T extends {} = Object>(rules: Rules): T
as <T extends {} = Object>(genericConstructor: GenericConstructor<T>): T
as <T extends {} = Object>(genericConstructor: GenericConstructor<T>, rules?: Rules): T
as <T extends {} = Object>(constructorOrRules: GenericConstructor<T> | Rules, rules?: Rules): T {
return as({
get: (key) => this.properties[key]
}, constructorOrRules, rules)
}

/**
* @ignore
*/
Expand Down
23 changes: 19 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import NotificationFilter, {
notificationFilterMinimumSeverityLevel,
NotificationFilterMinimumSeverityLevel
} from './notification-filter'
import Result, { QueryResult, ResultObserver } from './result'
import Result, { MappedQueryResult, QueryResult, ResultObserver } from './result'
import EagerResult from './result-eager'
import ConnectionProvider, { Releasable } from './connection-provider'
import Connection from './connection'
Expand All @@ -103,6 +103,10 @@ import resultTransformers, { ResultTransformer } from './result-transformers'
import ClientCertificate, { clientCertificateProviders, ClientCertificateProvider, ClientCertificateProviders, RotatingClientCertificateProvider, resolveCertificateProvider } from './client-certificate'
import * as internal from './internal' // todo: removed afterwards
import Vector, { VectorType, vector } from './vector'
import { StandardCase } from './mapping.nameconventions'
import { Rule, Rules, RecordObjectMapping } from './mapping.highlevel'
import { rule } from './mapping.rulesfactories'
import mappingDecorators from './mapping.decorators'

/**
* Object containing string constants representing predefined {@link Neo4jError} codes.
Expand Down Expand Up @@ -189,7 +193,11 @@ const forExport = {
notificationFilterDisabledClassification,
notificationFilterMinimumSeverityLevel,
clientCertificateProviders,
resolveCertificateProvider
resolveCertificateProvider,
rule,
mappingDecorators,
RecordObjectMapping,
StandardCase
}

export {
Expand Down Expand Up @@ -269,14 +277,19 @@ export {
clientCertificateProviders,
resolveCertificateProvider,
Vector,
vector
vector,
rule,
mappingDecorators,
RecordObjectMapping,
StandardCase
}

export type {
StandardDate,
NumberOrInteger,
NotificationPosition,
QueryResult,
MappedQueryResult,
ResultObserver,
TransactionConfig,
BookmarkManager,
Expand All @@ -301,7 +314,9 @@ export type {
ClientCertificateProvider,
ClientCertificateProviders,
RotatingClientCertificateProvider,
VectorType
VectorType,
Rule,
Rules
}

export default forExport
3 changes: 2 additions & 1 deletion packages/core/src/internal/observers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import Record from '../record'
import { GenericResultObserver } from '../result'
import ResultSummary from '../result-summary'

interface StreamObserver {
Expand Down Expand Up @@ -115,7 +116,7 @@ export interface ResultStreamObserver extends StreamObserver {
* @param {function(metadata: Object)} observer.onCompleted - Handle stream tail, the summary.
* @param {function(error: Object)} observer.onError - Handle errors, should always be provided.
*/
subscribe: (observer: ResultObserver) => void
subscribe: (observer: GenericResultObserver<any>) => void
}

export class CompletedObserver implements ResultStreamObserver {
Expand Down
Loading