@routier/core 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +88 -438
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +94 -443
  6. package/dist/index.js.map +1 -1
  7. package/dist/plugins/TelemetryDbPlugin.d.ts +43 -0
  8. package/dist/plugins/index.cjs +82 -1
  9. package/dist/plugins/index.cjs.map +1 -1
  10. package/dist/plugins/index.d.ts +2 -0
  11. package/dist/plugins/index.js +88 -3
  12. package/dist/plugins/index.js.map +1 -1
  13. package/dist/plugins/resultShape.d.ts +35 -0
  14. package/dist/transfer/ChunkEncoder.d.ts +60 -0
  15. package/dist/transfer/decoder.d.ts +29 -0
  16. package/dist/transfer/fillers.d.ts +36 -0
  17. package/dist/transfer/index.cjs +873 -0
  18. package/dist/transfer/index.cjs.map +1 -0
  19. package/dist/transfer/index.d.ts +47 -0
  20. package/dist/transfer/index.js +872 -0
  21. package/dist/transfer/index.js.map +1 -0
  22. package/dist/transfer/plan.d.ts +94 -0
  23. package/dist/transfer/types.d.ts +138 -0
  24. package/package.json +9 -9
  25. package/dist/capabilities/Capability.d.ts +0 -11
  26. package/dist/capabilities/PerformanceCapability.d.ts +0 -13
  27. package/dist/capabilities/TracingCapability.d.ts +0 -11
  28. package/dist/capabilities/index.cjs +0 -820
  29. package/dist/capabilities/index.cjs.map +0 -1
  30. package/dist/capabilities/index.d.ts +0 -4
  31. package/dist/capabilities/index.js +0 -808
  32. package/dist/capabilities/index.js.map +0 -1
  33. package/dist/capabilities/performance/PerformanceTracker.d.ts +0 -11
  34. package/dist/capabilities/tracing/CallTraceManager.d.ts +0 -12
  35. package/dist/capabilities/types.d.ts +0 -17
@@ -1,9 +1,11 @@
1
1
  export * from './types';
2
+ export * from './resultShape';
2
3
  export * from './translators';
3
4
  export * from './query';
4
5
  export * from './wire';
5
6
  export * from './ConcurrencyDbPlugin';
6
7
  export * from './EphemeralDataPlugin';
7
8
  export * from './RetryDbPlugin';
9
+ export * from './TelemetryDbPlugin';
8
10
  export * from './CacheDbPlugin';
9
11
  export * from './BatchingDbPlugin';
@@ -3045,13 +3045,14 @@ var __webpack_exports__ = {};
3045
3045
  __webpack_require__.d(__webpack_exports__, {
3046
3046
  jO: () => (/* reexport */ TupleTranslator),
3047
3047
  Mr: () => (/* reexport */ deserializeBulkPersist),
3048
- ae: () => (/* reexport */ explainQuery),
3049
3048
  bX: () => (/* reexport */ ConcurrencyDbPlugin),
3049
+ ae: () => (/* reexport */ explainQuery),
3050
3050
  _b: () => (/* reexport */ DEFAULT_SEMI_JOIN_KEY_THRESHOLD),
3051
3051
  pt: () => (/* reexport */ types_QueryOrdering),
3052
3052
  Ib: () => (/* reexport */ TranslatedSingleValue),
3053
3053
  RK: () => (/* reexport */ distinctJoinKeys),
3054
3054
  Bg: () => (/* reexport */ hashJoin),
3055
+ _1: () => (/* reexport */ mappedResultColumns),
3055
3056
  iG: () => (/* reexport */ nearestBy),
3056
3057
  qy: () => (/* reexport */ readJoinKey),
3057
3058
  yR: () => (/* reexport */ serializePersistResult),
@@ -3060,9 +3061,10 @@ __webpack_require__.d(__webpack_exports__, {
3060
3061
  d0: () => (/* reexport */ JsonTranslator),
3061
3062
  PP: () => (/* reexport */ splitSendableOptions),
3062
3063
  f2: () => (/* reexport */ TranslatedGroupValue),
3063
- __: () => (/* reexport */ toEntityShape),
3064
+ wN: () => (/* reexport */ collectingSink),
3064
3065
  QB: () => (/* reexport */ RetryDbPlugin),
3065
3066
  m6: () => (/* reexport */ executeJoin),
3067
+ __: () => (/* reexport */ toEntityShape),
3066
3068
  VW: () => (/* reexport */ applyInnerOptions),
3067
3069
  Jd: () => (/* reexport */ EphemeralDataPlugin),
3068
3070
  Pl: () => (/* reexport */ deserializePersistResult),
@@ -3076,15 +3078,29 @@ __webpack_require__.d(__webpack_exports__, {
3076
3078
  lA: () => (/* reexport */ semiJoinFilter),
3077
3079
  kX: () => (/* reexport */ BatchingDbPlugin),
3078
3080
  DF: () => (/* reexport */ SqlTranslator),
3081
+ qj: () => (/* reexport */ loggerSink),
3079
3082
  gH: () => (/* reexport */ MEMORY_EXECUTION_EXPLANATIONS),
3080
3083
  BL: () => (/* reexport */ serializeQueryOptions),
3081
3084
  Kg: () => (/* reexport */ withExecutedQueries),
3082
3085
  xw: () => (/* reexport */ TranslatedArrayValue),
3083
3086
  zH: () => (/* reexport */ joinInPlugin),
3087
+ Pr: () => (/* reexport */ TelemetryDbPlugin),
3084
3088
  XK: () => (/* reexport */ Query),
3085
3089
  jE: () => (/* reexport */ EXECUTED_QUERIES_UNSUPPORTED)
3086
3090
  });
3087
3091
 
3092
+ ;// CONCATENATED MODULE: ./src/plugins/resultShape.ts
3093
+ /**
3094
+ * The columns a `map` projection selects.
3095
+ *
3096
+ * Named by `sourceName`, which is what the statement actually emits; the rename to
3097
+ * `destinationName` happens in the translator, after the rows come back. A field with no
3098
+ * `property` is an expression.
3099
+ */ const mappedResultColumns = (fields)=>fields.map((field)=>({
3100
+ name: field.sourceName,
3101
+ property: field.property ?? null
3102
+ }));
3103
+
3088
3104
  ;// CONCATENATED MODULE: ./src/plugins/translators/TranslatedArrayValue.ts
3089
3105
  class TranslatedArrayValue {
3090
3106
  value;
@@ -6066,6 +6082,69 @@ class RetryDbPlugin {
6066
6082
  }
6067
6083
  }
6068
6084
 
6085
+ ;// CONCATENATED MODULE: ./src/plugins/TelemetryDbPlugin.ts
6086
+
6087
+ /** Default sink: writes through the levelled logger, so ROUTIER_LOG_LEVEL governs it. */ const loggerSink = ()=>(e)=>{
6088
+ const line = `[routier] ${e.operation} ${e.schemas.join(",")} ${e.durationMs.toFixed(1)}ms`;
6089
+ if (e.ok === "error") {
6090
+ logger/* .logger.error */.vF.error(line, e.error);
6091
+ return;
6092
+ }
6093
+ logger/* .logger.info */.vF.info(line);
6094
+ };
6095
+ /** Pushes every event into `into`. For tests and custom buffering. */ const collectingSink = (into)=>(e)=>{
6096
+ into.push(e);
6097
+ };
6098
+ class TelemetryDbPlugin {
6099
+ plugin;
6100
+ onEvent;
6101
+ constructor(plugin, options = {}){
6102
+ this.plugin = plugin;
6103
+ this.onEvent = options.onEvent ?? loggerSink();
6104
+ }
6105
+ get databaseName() {
6106
+ return this.plugin.databaseName;
6107
+ }
6108
+ query(event, done) {
6109
+ const start = performance.now();
6110
+ this.plugin.query(event, (result)=>{
6111
+ this.emit("query", event, result, start);
6112
+ done(result);
6113
+ });
6114
+ }
6115
+ bulkPersist(event, done) {
6116
+ const start = performance.now();
6117
+ this.plugin.bulkPersist(event, (result)=>{
6118
+ this.emit("bulkPersist", event, result, start);
6119
+ done(result);
6120
+ });
6121
+ }
6122
+ destroy(event, done) {
6123
+ const start = performance.now();
6124
+ this.plugin.destroy(event, (result)=>{
6125
+ this.emit("destroy", event, result, start);
6126
+ done(result);
6127
+ });
6128
+ }
6129
+ emit(operation, event, result, start) {
6130
+ try {
6131
+ this.onEvent({
6132
+ operation,
6133
+ eventId: event.id,
6134
+ source: event.source,
6135
+ schemas: [
6136
+ ...event.schemas.values()
6137
+ ].map((s)=>s.collectionName),
6138
+ durationMs: performance.now() - start,
6139
+ ok: result.ok,
6140
+ error: result.ok === "success" ? undefined : result.error
6141
+ });
6142
+ } catch {
6143
+ // A broken sink must never fail the data operation.
6144
+ }
6145
+ }
6146
+ }
6147
+
6069
6148
  ;// CONCATENATED MODULE: ./src/plugins/CacheDbPlugin.ts
6070
6149
 
6071
6150
  /**
@@ -6529,6 +6608,8 @@ const DEFAULT_MAX_BATCH_SIZE = 100;
6529
6608
 
6530
6609
 
6531
6610
 
6611
+
6612
+
6532
6613
  })();
6533
6614
 
6534
6615
  var __webpack_exports__BatchingDbPlugin = __webpack_exports__.kX;
@@ -6545,11 +6626,13 @@ var __webpack_exports__QueryOptionsCollection = __webpack_exports__.HM;
6545
6626
  var __webpack_exports__QueryOrdering = __webpack_exports__.pt;
6546
6627
  var __webpack_exports__RetryDbPlugin = __webpack_exports__.QB;
6547
6628
  var __webpack_exports__SqlTranslator = __webpack_exports__.DF;
6629
+ var __webpack_exports__TelemetryDbPlugin = __webpack_exports__.Pr;
6548
6630
  var __webpack_exports__TranslatedArrayValue = __webpack_exports__.xw;
6549
6631
  var __webpack_exports__TranslatedGroupValue = __webpack_exports__.f2;
6550
6632
  var __webpack_exports__TranslatedSingleValue = __webpack_exports__.Ib;
6551
6633
  var __webpack_exports__TupleTranslator = __webpack_exports__.jO;
6552
6634
  var __webpack_exports__applyInnerOptions = __webpack_exports__.VW;
6635
+ var __webpack_exports__collectingSink = __webpack_exports__.wN;
6553
6636
  var __webpack_exports__cosineDistance = __webpack_exports__.lO;
6554
6637
  var __webpack_exports__createRequestHandler = __webpack_exports__.KB;
6555
6638
  var __webpack_exports__deserializeBulkPersist = __webpack_exports__.Mr;
@@ -6562,6 +6645,8 @@ var __webpack_exports__formatExplanation = __webpack_exports__.vZ;
6562
6645
  var __webpack_exports__hashJoin = __webpack_exports__.Bg;
6563
6646
  var __webpack_exports__joinInPlugin = __webpack_exports__.zH;
6564
6647
  var __webpack_exports__loadJoinInnerSide = __webpack_exports__.as;
6648
+ var __webpack_exports__loggerSink = __webpack_exports__.qj;
6649
+ var __webpack_exports__mappedResultColumns = __webpack_exports__._1;
6565
6650
  var __webpack_exports__nearestBy = __webpack_exports__.iG;
6566
6651
  var __webpack_exports__readJoinKey = __webpack_exports__.qy;
6567
6652
  var __webpack_exports__semiJoinFilter = __webpack_exports__.lA;
@@ -6571,6 +6656,6 @@ var __webpack_exports__serializeQueryOptions = __webpack_exports__.BL;
6571
6656
  var __webpack_exports__splitSendableOptions = __webpack_exports__.PP;
6572
6657
  var __webpack_exports__toEntityShape = __webpack_exports__.__;
6573
6658
  var __webpack_exports__withExecutedQueries = __webpack_exports__.Kg;
6574
- export { __webpack_exports__BatchingDbPlugin as BatchingDbPlugin, __webpack_exports__CacheDbPlugin as CacheDbPlugin, __webpack_exports__ConcurrencyDbPlugin as ConcurrencyDbPlugin, __webpack_exports__DEFAULT_SEMI_JOIN_KEY_THRESHOLD as DEFAULT_SEMI_JOIN_KEY_THRESHOLD, __webpack_exports__DataTranslator as DataTranslator, __webpack_exports__EXECUTED_QUERIES_UNSUPPORTED as EXECUTED_QUERIES_UNSUPPORTED, __webpack_exports__EphemeralDataPlugin as EphemeralDataPlugin, __webpack_exports__JsonTranslator as JsonTranslator, __webpack_exports__MEMORY_EXECUTION_EXPLANATIONS as MEMORY_EXECUTION_EXPLANATIONS, __webpack_exports__Query as Query, __webpack_exports__QueryOptionsCollection as QueryOptionsCollection, __webpack_exports__QueryOrdering as QueryOrdering, __webpack_exports__RetryDbPlugin as RetryDbPlugin, __webpack_exports__SqlTranslator as SqlTranslator, __webpack_exports__TranslatedArrayValue as TranslatedArrayValue, __webpack_exports__TranslatedGroupValue as TranslatedGroupValue, __webpack_exports__TranslatedSingleValue as TranslatedSingleValue, __webpack_exports__TupleTranslator as TupleTranslator, __webpack_exports__applyInnerOptions as applyInnerOptions, __webpack_exports__cosineDistance as cosineDistance, __webpack_exports__createRequestHandler as createRequestHandler, __webpack_exports__deserializeBulkPersist as deserializeBulkPersist, __webpack_exports__deserializePersistResult as deserializePersistResult, __webpack_exports__deserializeQueryOptions as deserializeQueryOptions, __webpack_exports__distinctJoinKeys as distinctJoinKeys, __webpack_exports__executeJoin as executeJoin, __webpack_exports__explainQuery as explainQuery, __webpack_exports__formatExplanation as formatExplanation, __webpack_exports__hashJoin as hashJoin, __webpack_exports__joinInPlugin as joinInPlugin, __webpack_exports__loadJoinInnerSide as loadJoinInnerSide, __webpack_exports__nearestBy as nearestBy, __webpack_exports__readJoinKey as readJoinKey, __webpack_exports__semiJoinFilter as semiJoinFilter, __webpack_exports__serializeBulkPersist as serializeBulkPersist, __webpack_exports__serializePersistResult as serializePersistResult, __webpack_exports__serializeQueryOptions as serializeQueryOptions, __webpack_exports__splitSendableOptions as splitSendableOptions, __webpack_exports__toEntityShape as toEntityShape, __webpack_exports__withExecutedQueries as withExecutedQueries };
6659
+ export { __webpack_exports__BatchingDbPlugin as BatchingDbPlugin, __webpack_exports__CacheDbPlugin as CacheDbPlugin, __webpack_exports__ConcurrencyDbPlugin as ConcurrencyDbPlugin, __webpack_exports__DEFAULT_SEMI_JOIN_KEY_THRESHOLD as DEFAULT_SEMI_JOIN_KEY_THRESHOLD, __webpack_exports__DataTranslator as DataTranslator, __webpack_exports__EXECUTED_QUERIES_UNSUPPORTED as EXECUTED_QUERIES_UNSUPPORTED, __webpack_exports__EphemeralDataPlugin as EphemeralDataPlugin, __webpack_exports__JsonTranslator as JsonTranslator, __webpack_exports__MEMORY_EXECUTION_EXPLANATIONS as MEMORY_EXECUTION_EXPLANATIONS, __webpack_exports__Query as Query, __webpack_exports__QueryOptionsCollection as QueryOptionsCollection, __webpack_exports__QueryOrdering as QueryOrdering, __webpack_exports__RetryDbPlugin as RetryDbPlugin, __webpack_exports__SqlTranslator as SqlTranslator, __webpack_exports__TelemetryDbPlugin as TelemetryDbPlugin, __webpack_exports__TranslatedArrayValue as TranslatedArrayValue, __webpack_exports__TranslatedGroupValue as TranslatedGroupValue, __webpack_exports__TranslatedSingleValue as TranslatedSingleValue, __webpack_exports__TupleTranslator as TupleTranslator, __webpack_exports__applyInnerOptions as applyInnerOptions, __webpack_exports__collectingSink as collectingSink, __webpack_exports__cosineDistance as cosineDistance, __webpack_exports__createRequestHandler as createRequestHandler, __webpack_exports__deserializeBulkPersist as deserializeBulkPersist, __webpack_exports__deserializePersistResult as deserializePersistResult, __webpack_exports__deserializeQueryOptions as deserializeQueryOptions, __webpack_exports__distinctJoinKeys as distinctJoinKeys, __webpack_exports__executeJoin as executeJoin, __webpack_exports__explainQuery as explainQuery, __webpack_exports__formatExplanation as formatExplanation, __webpack_exports__hashJoin as hashJoin, __webpack_exports__joinInPlugin as joinInPlugin, __webpack_exports__loadJoinInnerSide as loadJoinInnerSide, __webpack_exports__loggerSink as loggerSink, __webpack_exports__mappedResultColumns as mappedResultColumns, __webpack_exports__nearestBy as nearestBy, __webpack_exports__readJoinKey as readJoinKey, __webpack_exports__semiJoinFilter as semiJoinFilter, __webpack_exports__serializeBulkPersist as serializeBulkPersist, __webpack_exports__serializePersistResult as serializePersistResult, __webpack_exports__serializeQueryOptions as serializeQueryOptions, __webpack_exports__splitSendableOptions as splitSendableOptions, __webpack_exports__toEntityShape as toEntityShape, __webpack_exports__withExecutedQueries as withExecutedQueries };
6575
6660
 
6576
6661
  //# sourceMappingURL=index.js.map