@routier/core 0.0.5 → 0.0.7

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 (63) hide show
  1. package/dist/capabilities/Capability.d.ts +11 -0
  2. package/dist/capabilities/PerformanceCapability.d.ts +13 -0
  3. package/dist/capabilities/TracingCapability.d.ts +11 -0
  4. package/dist/capabilities/index.d.ts +4 -0
  5. package/dist/capabilities/index.js +763 -0
  6. package/dist/capabilities/index.js.map +1 -0
  7. package/dist/capabilities/performance/PerformanceTracker.d.ts +11 -0
  8. package/dist/capabilities/tracing/CallTraceManager.d.ts +12 -0
  9. package/dist/capabilities/types.d.ts +17 -0
  10. package/dist/codegen/blocks.d.ts +8 -0
  11. package/dist/codegen/handlers/CompareIdsHandlerBuilder.d.ts +4 -0
  12. package/dist/codegen/handlers/compare/CompareArrayHandler.d.ts +6 -0
  13. package/dist/codegen/handlers/compare/CompareDateHandler.d.ts +6 -0
  14. package/dist/codegen/handlers/compareIds/CompareIdsKeyHandler.d.ts +6 -0
  15. package/dist/codegen/handlers/index.d.ts +1 -0
  16. package/dist/codegen/handlers/serialize/SerializeDateHandler.d.ts +2 -1
  17. package/dist/codegen/handlers/serialize/SerializeFunctionHandler.d.ts +6 -0
  18. package/dist/codegen/index.js +660 -0
  19. package/dist/codegen/index.js.map +1 -0
  20. package/dist/collections/index.js.map +1 -1
  21. package/dist/expressions/index.js +108 -19
  22. package/dist/expressions/index.js.map +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1406 -602
  25. package/dist/index.js.map +1 -1
  26. package/dist/pipeline/WorkPipeline.test.d.ts +1 -0
  27. package/dist/pipeline/index.js.map +1 -1
  28. package/dist/plugins/EphemeralDataPlugin.d.ts +2 -2
  29. package/dist/plugins/EphemeralDataPlugin.test.d.ts +1 -0
  30. package/dist/plugins/index.d.ts +0 -1
  31. package/dist/plugins/index.js +244 -483
  32. package/dist/plugins/index.js.map +1 -1
  33. package/dist/plugins/query/types.d.ts +5 -0
  34. package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +2 -1
  35. package/dist/plugins/replication/ReplicationDbPlugin.d.ts +2 -1
  36. package/dist/plugins/translators/DataTranslator.d.ts +3 -1
  37. package/dist/plugins/translators/JsonTranslator.d.ts +1 -0
  38. package/dist/plugins/translators/SqlTranslator.d.ts +1 -0
  39. package/dist/plugins/translators/TranslatedArrayValue.d.ts +6 -0
  40. package/dist/plugins/translators/TranslatedGroupValue.d.ts +6 -0
  41. package/dist/plugins/translators/TranslatedSingleValue.d.ts +6 -0
  42. package/dist/plugins/translators/index.d.ts +4 -0
  43. package/dist/plugins/translators/types.d.ts +10 -0
  44. package/dist/plugins/types.d.ts +2 -1
  45. package/dist/schema/PropertyInfo.d.ts +6 -1
  46. package/dist/schema/SchemaDefinition.d.ts +1 -1
  47. package/dist/schema/communication/broadcast.d.ts +3 -3
  48. package/dist/schema/index.js +508 -76
  49. package/dist/schema/index.js.map +1 -1
  50. package/dist/schema/property/modifiers/SchemaTracked.d.ts +3 -1
  51. package/dist/schema/table/SchemaComputed.d.ts +1 -1
  52. package/dist/schema/testSchemas.test.d.ts +60 -36
  53. package/dist/schema/types.d.ts +16 -1
  54. package/dist/utilities/index.js +145 -2
  55. package/dist/utilities/index.js.map +1 -1
  56. package/dist/utilities/strings.d.ts +34 -0
  57. package/dist/utilities/strings.test.d.ts +1 -0
  58. package/package.json +5 -1
  59. package/readme.md +1 -1
  60. package/dist/plugins/capabilities/DbPluginCapability.d.ts +0 -23
  61. package/dist/plugins/capabilities/index.d.ts +0 -2
  62. package/dist/plugins/capabilities/logging/DbPluginLoggingCapability.d.ts +0 -28
  63. package/dist/plugins/capabilities/logging/index.d.ts +0 -1
@@ -34,6 +34,11 @@ export type QueryOptionValueMap<T extends {}> = {
34
34
  selector: GenericFunction<T, any>;
35
35
  fields: QueryField[];
36
36
  };
37
+ group: {
38
+ selector: GenericFunction<T, any>;
39
+ key: QueryField;
40
+ fields: QueryField[];
41
+ };
37
42
  filter: {
38
43
  params?: {};
39
44
  filter: ParamsFilter<T, {}> | Filter<T>;
@@ -1,6 +1,7 @@
1
1
  import { PluginEventCallbackPartialResult, PluginEventCallbackResult } from '../../results';
2
2
  import { DbPluginBulkPersistEvent, DbPluginEvent, DbPluginQueryEvent, IDbPlugin, OptimisticReplicationPluginOptions } from '../types';
3
3
  import { BulkPersistResult } from '../../collections';
4
+ import { ITranslatedValue } from '../translators';
4
5
  export declare class OptimisticReplicationDbPlugin implements IDbPlugin {
5
6
  protected plugins: OptimisticReplicationPluginOptions;
6
7
  protected constructor(plugins: OptimisticReplicationPluginOptions);
@@ -15,7 +16,7 @@ export declare class OptimisticReplicationDbPlugin implements IDbPlugin {
15
16
  /**
16
17
  * Will query the read plugin if there is one, otherwise the source plugin will be queried
17
18
  */
18
- query<TEntity extends {}, TShape extends any = TEntity>(event: DbPluginQueryEvent<TEntity, TShape>, done: PluginEventCallbackResult<TShape>): void;
19
+ query<TEntity extends {}, TShape extends any = TEntity>(event: DbPluginQueryEvent<TEntity, TShape>, done: PluginEventCallbackResult<ITranslatedValue<TShape>>): void;
19
20
  destroy(event: DbPluginEvent, done: PluginEventCallbackResult<never>): void;
20
21
  bulkPersist(event: DbPluginBulkPersistEvent, done: PluginEventCallbackPartialResult<BulkPersistResult>): void;
21
22
  }
@@ -1,6 +1,7 @@
1
1
  import { PluginEventCallbackPartialResult, PluginEventCallbackResult } from '../../results';
2
2
  import { DbPluginBulkPersistEvent, DbPluginEvent, DbPluginQueryEvent, IDbPlugin, ReplicationPluginOptions } from '../types';
3
3
  import { BulkPersistResult } from '../../collections';
4
+ import { ITranslatedValue } from '../translators';
4
5
  export declare class ReplicationDbPlugin implements IDbPlugin {
5
6
  plugins: ReplicationPluginOptions;
6
7
  protected constructor(plugins: ReplicationPluginOptions);
@@ -15,7 +16,7 @@ export declare class ReplicationDbPlugin implements IDbPlugin {
15
16
  /**
16
17
  * Will query the read plugin if there is one, otherwise the source plugin will be queried
17
18
  */
18
- query<TEntity extends {}, TShape extends any = TEntity>(event: DbPluginQueryEvent<TEntity, TShape>, done: PluginEventCallbackResult<TShape>): void;
19
+ query<TEntity extends {}, TShape extends any = TEntity>(event: DbPluginQueryEvent<TEntity, TShape>, done: PluginEventCallbackResult<ITranslatedValue<TShape>>): void;
19
20
  destroy(event: DbPluginEvent, done: PluginEventCallbackResult<never>): void;
20
21
  bulkPersist(event: DbPluginBulkPersistEvent, done: PluginEventCallbackPartialResult<BulkPersistResult>): void;
21
22
  }
@@ -1,5 +1,6 @@
1
1
  import { QueryOption } from "../query/types";
2
2
  import { IQuery } from "../types";
3
+ import { ITranslatedValue } from "./types";
3
4
  export declare abstract class DataTranslator<TRoot extends {}, TShape> {
4
5
  protected query: IQuery<TRoot, TShape>;
5
6
  private functionMap;
@@ -14,5 +15,6 @@ export declare abstract class DataTranslator<TRoot extends {}, TShape> {
14
15
  abstract take(data: unknown, option: QueryOption<TShape, "take">): TShape;
15
16
  abstract sort(data: unknown, option: QueryOption<TShape, "sort">): TShape;
16
17
  abstract map(data: unknown, option: QueryOption<TShape, "map">): TShape;
17
- translate(data: unknown): TShape;
18
+ abstract group(data: unknown, option: QueryOption<TShape, "group">): TShape;
19
+ translate(data: unknown): ITranslatedValue<TShape>;
18
20
  }
@@ -3,6 +3,7 @@ import { QueryOption } from "../query/types";
3
3
  export declare class JsonTranslator<TRoot extends {}, TShape> extends DataTranslator<TRoot, TShape> {
4
4
  filter<TResult>(data: unknown, option: QueryOption<TShape, "filter">): TResult;
5
5
  map<T>(data: unknown, option: QueryOption<T, "map">): T;
6
+ group<T>(data: unknown, option: QueryOption<T, "group">): T;
6
7
  count<TResult extends number>(data: unknown, _: QueryOption<TShape, "count">): TResult;
7
8
  min<TResult extends string | number | Date>(data: unknown, _: QueryOption<TShape, "min">): TResult;
8
9
  max<TResult extends string | number | Date>(data: unknown, _: QueryOption<TShape, "max">): TResult;
@@ -11,5 +11,6 @@ export declare class SqlTranslator<TRoot extends {}, TShape> extends DataTransla
11
11
  skip(data: unknown, _: QueryOption<TShape, "skip">): TShape;
12
12
  take(data: unknown, _: QueryOption<TShape, "take">): TShape;
13
13
  sort(data: unknown, _: QueryOption<TShape, "sort">): TShape;
14
+ group<T>(data: unknown, option: QueryOption<T, "group">): T;
14
15
  map(data: unknown, option: QueryOption<TShape, "map">): TShape;
15
16
  }
@@ -0,0 +1,6 @@
1
+ import { ITranslatedValue } from './types';
2
+ export declare class TranslatedArrayValue<T> implements ITranslatedValue<T> {
3
+ readonly value: T;
4
+ constructor(value: unknown);
5
+ forEach(callback: (item: unknown) => unknown): void;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ITranslatedValue } from './types';
2
+ export declare class TranslatedGroupValue<T> implements ITranslatedValue<T> {
3
+ readonly value: T;
4
+ constructor(value: unknown);
5
+ forEach(callback: (item: unknown) => unknown): void;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ITranslatedValue } from './types';
2
+ export declare class TranslatedSingleValue<T> implements ITranslatedValue<T> {
3
+ value: T;
4
+ constructor(value: unknown);
5
+ forEach(callback: (item: unknown) => unknown): void;
6
+ }
@@ -1,3 +1,7 @@
1
1
  export * from './DataTranslator';
2
2
  export * from './JsonTranslator';
3
3
  export * from './SqlTranslator';
4
+ export * from './types';
5
+ export * from './TranslatedArrayValue';
6
+ export * from './TranslatedGroupValue';
7
+ export * from './TranslatedSingleValue';
@@ -0,0 +1,10 @@
1
+ export interface ITranslatedValue<T> {
2
+ readonly value: T;
3
+ /**
4
+ * Iterates over items in the collection, calling the callback for each item.
5
+ * If the callback returns a value, that value will replace the original item in the collection.
6
+ *
7
+ * @param callback Function called for each item. If it returns a value, that value replaces the original item.
8
+ */
9
+ forEach(callback: (item: unknown) => unknown): void;
10
+ }
@@ -2,6 +2,7 @@ import { PluginEventCallbackPartialResult, PluginEventCallbackResult } from "../
2
2
  import { QueryOptionsCollection } from "./query/QueryOptionsCollection";
3
3
  import { CompiledSchema, InferType } from '../schema';
4
4
  import { BulkPersistChanges, BulkPersistResult, SchemaCollection } from "../collections";
5
+ import { ITranslatedValue } from "./translators";
5
6
  /**
6
7
  * Interface for a database plugin, which provides query, destroy, and bulk operations.
7
8
  */
@@ -11,7 +12,7 @@ export interface IDbPlugin {
11
12
  * @param event The query event containing schema, parent, and query operation.
12
13
  * @param done Callback with the result or error.
13
14
  */
14
- query<TRoot extends {}, TShape extends any = TRoot>(event: DbPluginQueryEvent<TRoot, TShape>, done: PluginEventCallbackResult<TShape>): void;
15
+ query<TRoot extends {}, TShape extends any = TRoot>(event: DbPluginQueryEvent<TRoot, TShape>, done: PluginEventCallbackResult<ITranslatedValue<TShape>>): void;
15
16
  /**
16
17
  * Destroys or cleans up the plugin, closing connections or freeing resources.
17
18
  * @param done Callback with an optional error.
@@ -1,3 +1,4 @@
1
+ import { UnknownRecord } from '../utilities';
1
2
  import { SchemaBase } from './property/base/SchemaBase';
2
3
  import { DefaultValue, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes } from './types';
3
4
  /**
@@ -63,9 +64,12 @@ export declare class PropertyInfo<T extends {}> {
63
64
  * @returns {number} The number of parent properties above this property (0 for root).
64
65
  */
65
66
  get level(): number;
67
+ get isRenamed(): boolean;
68
+ get supportsDeserialization(): boolean;
66
69
  private _getPropertyChain;
67
70
  private _needsOptionalChaining;
68
71
  private _resolvePathArray;
72
+ getResolvedName(): string;
69
73
  /**
70
74
  * Returns an array of property names representing the path from the root to this property.
71
75
  *
@@ -96,7 +100,7 @@ export declare class PropertyInfo<T extends {}> {
96
100
  * @param instance The object instance to retrieve the value from.
97
101
  * @returns The value of the property, or null if not found.
98
102
  */
99
- getValue(instance: unknown): any;
103
+ getValue(instance: UnknownRecord): any;
100
104
  /**
101
105
  * Sets the value of this property on the given instance, creating intermediate objects as needed.
102
106
  *
@@ -115,6 +119,7 @@ export declare class PropertyInfo<T extends {}> {
115
119
  parent: string;
116
120
  assignmentType?: AssignmentType;
117
121
  useFromPropertyName?: boolean;
122
+ useRemappedName?: boolean;
118
123
  }): string;
119
124
  /**
120
125
  * Returns an assignment path string for this property, optionally starting from a parent variable name.
@@ -9,7 +9,7 @@ export declare class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {
9
9
  constructor(collectionName: string, schema: T);
10
10
  modify<R>(builder: (d: {
11
11
  function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: string, injected: I) => UU, injected?: I) => SchemaFunction<UU, I, "unmapped">;
12
- computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: string, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, "unmapped">;
12
+ computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: string, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, "computed" | "unmapped">;
13
13
  }) => R): SchemaDefinition<R & T>;
14
14
  private _iterate;
15
15
  private createChangeTracker;
@@ -1,9 +1,9 @@
1
- import { ISchemaSubscription, SchemaId, SubscriptionChanges } from "../types";
1
+ import { CompiledSchemaCore, ISchemaSubscription, SubscriptionChanges } from "../types";
2
2
  export declare class SchemaSubscription<T extends {}> implements ISchemaSubscription<T> {
3
3
  private readonly id;
4
- private readonly schemaId;
4
+ private readonly schema;
5
5
  private readonly createdAt;
6
- constructor(schemaId: SchemaId, signal?: AbortSignal);
6
+ constructor(schema: CompiledSchemaCore<T>, signal?: AbortSignal);
7
7
  send(changes: SubscriptionChanges<T>): void;
8
8
  onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;
9
9
  dispose(): void;