[
https://issues.apache.org/jira/browse/TINKERPOP-2492?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18142683#comment-18142683
]
ASF GitHub Bot commented on TINKERPOP-2492:
-------------------------------------------
xiazcy commented on code in PR #3785:
URL: https://github.com/apache/tinkerpop/pull/3785#discussion_r4532414046
##########
gremlin-js/gremlin-javascript/lib/process/traversal.ts:
##########
@@ -603,18 +596,18 @@ export class EnumValue {
}
}
-export const barrier = toEnum('Barrier', 'normSack');
-export const cardinality = toEnum('Cardinality', 'list set single');
-export const column = toEnum('Column', 'keys values');
-export const direction = toDirectionEnum('Direction', 'BOTH IN OUT from_ to');
-export const dt = toEnum('DT', 'second minute hour day');
-export const gType = toGTypeEnum('GType', 'bigDecimal bigInt binary boolean
byte char datetime double duration edge float graph int list long map null
number path property set short string tree uuid vertex vproperty');
-export const gryoVersion = toEnum('GryoVersion', 'V1_0 V3_0');
-export const merge = toEnum('Merge', 'onCreate onMatch outV inV');
-export const operator = toEnum('Operator', 'addAll and assign div max min
minus mult or sum sumLong');
-export const order = toEnum('Order', 'asc desc shuffle');
-export const pick = toEnum('Pick', 'any none unproductive');
-export const pop = toEnum('Pop', 'all first last mixed');
-export const scope = toEnum('Scope', 'global local');
-export const t = toEnum('T', 'id key label value');
-export const n = toEnum('N', 'byte_ short_ int_ long_ float_ double_ bigInt
bigDecimal');
+export const Barrier = toEnum('Barrier', ['normSack']);
+export const Cardinality = toEnum('Cardinality', ['list', 'set', 'single']);
+export const Column = toEnum('Column', ['keys', 'values']);
+export const Direction = toDirectionEnum('Direction');
+export const DT = toEnum('DT', ['second', 'minute', 'hour', 'day']);
+export const GType = toGTypeEnum('GType', ['bigDecimal', 'bigInt', 'binary',
'boolean', 'byte', 'char', 'datetime', 'double', 'duration', 'edge', 'float',
'graph', 'int', 'list', 'long', 'map', 'null', 'number', 'path', 'property',
'set', 'short', 'string', 'tree', 'uuid', 'vertex', 'vproperty']);
+export const GryoVersion = toEnum('GryoVersion', ['V1_0', 'V3_0']);
+export const Merge = toEnum('Merge', ['onCreate', 'onMatch', 'outV', 'inV']);
+export const Operator = toEnum('Operator', ['addAll', 'and', 'assign', 'div',
'max', 'min', 'minus', 'mult', 'or', 'sum', 'sumLong']);
+export const Order = toEnum('Order', ['asc', 'desc', 'shuffle']);
+export const Pick = toEnum('Pick', ['any', 'none', 'unproductive']);
+export const Pop = toEnum('Pop', ['all', 'first', 'last', 'mixed']);
+export const Scope = toEnum('Scope', ['global', 'local']);
+export const T = toEnum('T', ['id', 'key', 'label', 'value']);
+export const N = toEnum('N', ['byte_', 'short_', 'int_', 'long_', 'float_',
'double_', 'bigInt', 'bigDecimal']);
Review Comment:
This looks like a miss in the TypeScript files from before. `N` was replaced
by `GType`. Please delete `N` and remove it from the exports
(index.ts:34/161/269) , the docs (release-4.x.x.asciidoc:215)., enumNames
(exports-test.js:117) and generate.groovy:58.
##########
gremlin-js/gremlin-javascript/test/cucumber/feature-steps.js:
##########
Review Comment:
It looks like nothing calls `getSandbox`, and its Direction aliases (lines
432–433) are reversed. Can we delete it?
##########
gremlin-js/gremlin-javascript/lib/index.ts:
##########
@@ -38,77 +124,226 @@ import { HttpRequest } from './driver/http-request.js';
import { basic, sigv4 } from './driver/auth.js';
import AnonymousTraversalSource from './process/anonymous-traversal.js';
+const traversal = AnonymousTraversalSource.traversal;
+const auth = { basic, sigv4 };
+
+// Every public symbol is available as a named export of the package, e.g.
+// import { traversal, __, P, T, Order, DriverRemoteConnection } from
'gremlin';
+// and is also grouped under the driver, process and structure namespaces
below.
+export {
+ // driver
+ RemoteConnection,
+ RemoteStrategy,
+ RemoteTraversal,
+ ResponseError,
+ DriverRemoteConnection,
+ Client,
+ ResultSet,
+ HttpRequest,
+ auth,
+ // process
+ __,
+ AnonymousTraversalSource,
+ Barrier,
+ Cardinality,
+ CardinalityValue,
+ Column,
+ Direction,
+ DT,
+ EnumValue,
+ GraphTraversal,
+ GraphTraversalSource,
+ GremlinLang,
+ GType,
+ GValue,
+ IO,
+ Merge,
+ N,
+ Operator,
+ Order,
+ P,
+ Pick,
+ Pop,
+ Scope,
+ T,
+ TextP,
+ Traversal,
+ TraversalSideEffects,
+ TraversalStrategies,
+ TraversalStrategy,
+ Traverser,
+ traversal,
+ WithOptions,
+ // strategies
+ AdjacentToIncidentStrategy,
+ ByModulatorOptimizationStrategy,
+ ComputerFinalizationStrategy,
+ ComputerVerificationStrategy,
+ ConnectiveStrategy,
+ CountStrategy,
+ EarlyLimitStrategy,
+ EdgeLabelVerificationStrategy,
+ ElementIdStrategy,
+ FilterRankingStrategy,
+ GraphFilterStrategy,
+ HaltedTraverserStrategy,
+ IdentityRemovalStrategy,
+ IncidentToAdjacentStrategy,
+ InlineFilterStrategy,
+ LambdaRestrictionStrategy,
+ LazyBarrierStrategy,
+ MatchAlgorithmStrategy,
+ MatchPredicateStrategy,
+ MessagePassingReductionStrategy,
+ OptionsStrategy,
+ OrderLimitStrategy,
+ PartitionStrategy,
+ PathProcessorStrategy,
+ PathRetractionStrategy,
+ ProductiveByStrategy,
+ ProfileStrategy,
+ ReadOnlyStrategy,
+ ReferenceElementStrategy,
+ RepeatUnrollStrategy,
+ ReservedKeysVerificationStrategy,
+ SeedStrategy,
+ StandardVerificationStrategy,
+ SubgraphStrategy,
+ VertexProgramRestrictionStrategy,
+ VertexProgramStrategy,
+ // structure
+ CompositePDT,
+ Edge,
+ Graph,
+ Path,
+ PDTRegistry,
+ PrimitivePDT,
+ Property,
+ Tree,
+ Vertex,
+ VertexProperty,
+ Byte,
+ Double,
+ Float,
+ Int,
+ Long,
+ Short,
+ toByte,
+ toDouble,
+ toFloat,
+ toInt,
+ toLong,
+ toShort,
+ unwrap,
+};
+
export const driver = {
- RemoteConnection: rc.RemoteConnection,
- RemoteStrategy: rc.RemoteStrategy,
- RemoteTraversal: rc.RemoteTraversal,
+ RemoteConnection,
+ RemoteStrategy,
+ RemoteTraversal,
ResponseError,
DriverRemoteConnection,
Client,
ResultSet,
HttpRequest,
- auth: {
- basic,
- sigv4,
- },
+ auth,
};
export const process = {
- EnumValue: t.EnumValue,
- P: t.P,
- TextP: t.TextP,
- Traversal: t.Traversal,
- TraversalSideEffects: t.TraversalSideEffects,
- TraversalStrategies: strategiesModule.TraversalStrategies,
- TraversalStrategy: strategiesModule.TraversalStrategy,
- Traverser: t.Traverser,
- barrier: t.barrier,
- cardinality: t.cardinality,
- column: t.column,
- direction: t.direction,
- dt: t.dt,
- merge: t.merge,
- operator: t.operator,
- order: t.order,
- pick: t.pick,
- pop: t.pop,
- scope: t.scope,
- t: t.t,
- GraphTraversal: gt.GraphTraversal,
- GraphTraversalSource: gt.GraphTraversalSource,
- CardinalityValue: gt.CardinalityValue,
- statics: gt.statics,
+ __,
+ AnonymousTraversalSource,
+ Barrier,
+ Cardinality,
+ CardinalityValue,
+ Column,
+ Direction,
+ DT,
+ EnumValue,
+ GraphTraversal,
+ GraphTraversalSource,
GremlinLang,
+ GType,
GValue,
- traversal: AnonymousTraversalSource.traversal,
- AnonymousTraversalSource,
- withOptions: t.withOptions,
+ IO,
+ Merge,
+ N,
+ Operator,
+ Order,
+ P,
+ Pick,
+ Pop,
+ Scope,
+ T,
+ TextP,
+ Traversal,
+ TraversalSideEffects,
+ TraversalStrategies,
+ TraversalStrategy,
+ Traverser,
+ traversal,
+ WithOptions,
+ AdjacentToIncidentStrategy,
+ ByModulatorOptimizationStrategy,
+ ComputerFinalizationStrategy,
+ ComputerVerificationStrategy,
+ ConnectiveStrategy,
+ CountStrategy,
+ EarlyLimitStrategy,
+ EdgeLabelVerificationStrategy,
+ ElementIdStrategy,
+ FilterRankingStrategy,
+ GraphFilterStrategy,
+ HaltedTraverserStrategy,
+ IdentityRemovalStrategy,
+ IncidentToAdjacentStrategy,
+ InlineFilterStrategy,
+ LambdaRestrictionStrategy,
+ LazyBarrierStrategy,
+ MatchAlgorithmStrategy,
+ MatchPredicateStrategy,
+ MessagePassingReductionStrategy,
+ OptionsStrategy,
+ OrderLimitStrategy,
+ PartitionStrategy,
+ PathProcessorStrategy,
+ PathRetractionStrategy,
+ ProductiveByStrategy,
+ ProfileStrategy,
+ ReadOnlyStrategy,
+ ReferenceElementStrategy,
+ RepeatUnrollStrategy,
+ ReservedKeysVerificationStrategy,
+ SeedStrategy,
+ StandardVerificationStrategy,
+ SubgraphStrategy,
+ VertexProgramRestrictionStrategy,
+ VertexProgramStrategy,
};
export const structure = {
- Edge: graph.Edge,
- Graph: graph.Graph,
- Path: graph.Path,
- Tree: graph.Tree,
- Property: graph.Property,
- PrimitivePDT: graph.PrimitivePDT,
- CompositePDT: graph.CompositePDT,
+ CompositePDT,
+ Edge,
+ Graph,
+ Path,
PDTRegistry,
- Vertex: graph.Vertex,
- VertexProperty: graph.VertexProperty,
- toLong: utils.toLong,
- toInt: utils.toInt,
- toFloat: utils.toFloat,
- toDouble: utils.toDouble,
- toShort: utils.toShort,
- toByte: utils.toByte,
- Int: utils.Int,
- Float: utils.Float,
- Double: utils.Double,
- Short: utils.Short,
- Byte: utils.Byte,
- Long: utils.Long,
- unwrap: utils.unwrap,
+ PrimitivePDT,
+ Property,
+ Tree,
+ Vertex,
+ VertexProperty,
+ Byte,
+ Double,
+ Float,
+ Int,
+ Long,
+ Short,
+ toByte,
+ toDouble,
+ toFloat,
+ toInt,
+ toLong,
+ toShort,
+ unwrap,
};
export default { driver, process, structure };
Review Comment:
This PR adds flat named exports but leaves the default export as `{ driver,
process, structure }`. So `require('gremlin').T` now works while `import
gremlin from 'gremlin'; gremlin.T` is undefined. Is that difference intended,
or should the default export include the flat names too?
> Establish consistent naming principles for imports in gremlin-javascript
> ------------------------------------------------------------------------
>
> Key: TINKERPOP-2492
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2492
> Project: TinkerPop
> Issue Type: Improvement
> Components: javascript, translator
> Affects Versions: 3.4.9
> Reporter: Stephen Mallette
> Priority: Major
>
> Sometimes we alias enums and functions in gremlin-javascript to look like
> gremlin-groovy. Other times we keep in gremlin-javascript style. We need to
> establish a common expected look (presumably the correct way is to go with
> Javascript idioms) so that the {{JavascriptTranslator}} can produce the
> "right' output. Make sure all documentation is moved to whatever approach is
> taken.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)