rystem.repository.client 10.1.0-beta.3 → 11.0.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 (41) hide show
  1. package/lib/engine/Repository.d.ts +27 -0
  2. package/lib/engine/Repository.js +333 -0
  3. package/lib/engine/batch/Batch.d.ts +9 -0
  4. package/lib/engine/batch/Batch.js +17 -0
  5. package/lib/engine/batch/BatchBuilder.d.ts +13 -0
  6. package/lib/engine/batch/BatchBuilder.js +48 -0
  7. package/lib/engine/batch/BatchOperation.d.ts +12 -0
  8. package/lib/engine/batch/BatchOperation.js +16 -0
  9. package/lib/engine/batch/BatchResult.d.ts +13 -0
  10. package/lib/engine/batch/BatchResult.js +18 -0
  11. package/lib/engine/query/FilterOperationAsString.d.ts +5 -0
  12. package/lib/engine/query/FilterOperationAsString.js +2 -0
  13. package/lib/engine/query/FilterOperations.d.ts +11 -0
  14. package/lib/engine/query/FilterOperations.js +15 -0
  15. package/lib/engine/query/QueryBuilder.d.ts +25 -0
  16. package/lib/engine/query/QueryBuilder.js +116 -0
  17. package/lib/engine/query/SerializableFilter.d.ts +4 -0
  18. package/lib/engine/query/SerializableFilter.js +2 -0
  19. package/lib/engine/query/filter/WhereBuilder.d.ts +33 -0
  20. package/lib/engine/query/filter/WhereBuilder.js +170 -0
  21. package/lib/hooks/hooks.d.ts +9 -0
  22. package/lib/hooks/hooks.js +28 -0
  23. package/lib/index.d.ts +11 -0
  24. package/lib/index.js +16 -0
  25. package/lib/interfaces/ICommand.d.ts +14 -0
  26. package/lib/interfaces/ICommand.js +2 -0
  27. package/lib/interfaces/IQuery.d.ts +12 -0
  28. package/lib/interfaces/IQuery.js +2 -0
  29. package/lib/interfaces/IRepository.d.ts +6 -0
  30. package/lib/interfaces/IRepository.js +2 -0
  31. package/lib/models/Entity.d.ts +11 -0
  32. package/lib/models/Entity.js +20 -0
  33. package/lib/models/RepositoryEndpoint.d.ts +12 -0
  34. package/lib/models/RepositoryEndpoint.js +16 -0
  35. package/lib/models/State.d.ts +20 -0
  36. package/lib/models/State.js +26 -0
  37. package/lib/servicecollection/RepositoryServices.d.ts +23 -0
  38. package/lib/servicecollection/RepositoryServices.js +106 -0
  39. package/lib/servicecollection/RepositorySettings.d.ts +22 -0
  40. package/lib/servicecollection/RepositorySettings.js +58 -0
  41. package/package.json +10 -6
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryBuilder = void 0;
4
+ const RepositoryEndpoint_1 = require("../../models/RepositoryEndpoint");
5
+ const Repository_1 = require("../Repository");
6
+ const WhereBuilder_1 = require("./filter/WhereBuilder");
7
+ const FilterOperations_1 = require("./FilterOperations");
8
+ class QueryBuilder {
9
+ filters;
10
+ repository;
11
+ constructor(repository) {
12
+ this.filters = {
13
+ o: []
14
+ };
15
+ this.repository = repository;
16
+ }
17
+ where() {
18
+ return new WhereBuilder_1.WhereBuilder(this);
19
+ }
20
+ filter(predicate) {
21
+ this.filters.o.push({
22
+ q: FilterOperations_1.FilterOperations.Where,
23
+ v: predicate
24
+ });
25
+ return this;
26
+ }
27
+ top(value) {
28
+ this.filters.o.push({
29
+ q: FilterOperations_1.FilterOperations.Top,
30
+ v: value.toString()
31
+ });
32
+ return this;
33
+ }
34
+ skip(value) {
35
+ this.filters.o.push({
36
+ q: FilterOperations_1.FilterOperations.Skip,
37
+ v: value.toString()
38
+ });
39
+ return this;
40
+ }
41
+ orderBy(predicate) {
42
+ this.filters.o.push({
43
+ q: FilterOperations_1.FilterOperations.OrderBy,
44
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
45
+ });
46
+ return this;
47
+ }
48
+ orderByDescending(predicate) {
49
+ this.filters.o.push({
50
+ q: FilterOperations_1.FilterOperations.OrderByDescending,
51
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
52
+ });
53
+ return this;
54
+ }
55
+ thenBy(predicate) {
56
+ this.filters.o.push({
57
+ q: FilterOperations_1.FilterOperations.ThenBy,
58
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
59
+ });
60
+ return this;
61
+ }
62
+ thenByDescending(predicate) {
63
+ this.filters.o.push({
64
+ q: FilterOperations_1.FilterOperations.ThenByDescending,
65
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
66
+ });
67
+ return this;
68
+ }
69
+ execute() {
70
+ return this.repository.makeRequest(RepositoryEndpoint_1.RepositoryEndpoint.Query, `Query`, 'POST', this.filters, false, true, false, {
71
+ 'content-type': 'application/json;charset=UTF-8',
72
+ });
73
+ }
74
+ executeAsStream(entityReader, cancellationToken = null) {
75
+ return this.repository.makeRequestAsStream(RepositoryEndpoint_1.RepositoryEndpoint.QueryStream, `Query`, 'POST', entityReader, this.filters, false, true, false, {
76
+ 'content-type': 'application/json;charset=UTF-8',
77
+ }, cancellationToken);
78
+ }
79
+ count() {
80
+ return this.executeOperation("Count", "long");
81
+ }
82
+ max(predicate) {
83
+ this.filters.o.push({
84
+ q: FilterOperations_1.FilterOperations.Select,
85
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
86
+ });
87
+ return this.executeOperation("Max", "decimal");
88
+ }
89
+ min(predicate) {
90
+ this.filters.o.push({
91
+ q: FilterOperations_1.FilterOperations.Select,
92
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
93
+ });
94
+ return this.executeOperation("Min", "decimal");
95
+ }
96
+ average(predicate) {
97
+ this.filters.o.push({
98
+ q: FilterOperations_1.FilterOperations.Select,
99
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
100
+ });
101
+ return this.executeOperation("Average", "decimal");
102
+ }
103
+ sum(predicate) {
104
+ this.filters.o.push({
105
+ q: FilterOperations_1.FilterOperations.Select,
106
+ v: `_rystem => ${Repository_1.Repository.predicateAsString(predicate)}`
107
+ });
108
+ return this.executeOperation("Sum", "decimal");
109
+ }
110
+ executeOperation(operation, returnType) {
111
+ return this.repository.makeRequest(RepositoryEndpoint_1.RepositoryEndpoint.Operation, `Operation?op=${operation}&returnType=${returnType}`, 'POST', this.filters, false, true, true, {
112
+ 'content-type': 'application/json;charset=UTF-8',
113
+ });
114
+ }
115
+ }
116
+ exports.QueryBuilder = QueryBuilder;
@@ -0,0 +1,4 @@
1
+ import { FilterOperationAsString } from "./FilterOperationAsString";
2
+ export type SerializableFilter = {
3
+ o: Array<FilterOperationAsString>;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,33 @@
1
+ import { CancellationToken } from "typescript";
2
+ import { Entity } from "../../../models/Entity";
3
+ import { QueryBuilder } from "../QueryBuilder";
4
+ export declare class WhereBuilder<T, TKey> {
5
+ private roundBracketsCount;
6
+ private queryBuilder;
7
+ private query;
8
+ constructor(query: QueryBuilder<T, TKey>);
9
+ select(predicate: (value: T) => any): this;
10
+ private operator;
11
+ private valueAsString;
12
+ equal(value: any): this;
13
+ notEqual(value: any): this;
14
+ greaterThan(value: any): this;
15
+ greaterThanOrEqual(value: any): this;
16
+ lesserThan(value: any): this;
17
+ lesserThanOrEqual(value: any): this;
18
+ startsWith(value: any): this;
19
+ endsWith(value: any): this;
20
+ contains(value: any): this;
21
+ and(): this;
22
+ or(): this;
23
+ openRoundBracket(): this;
24
+ closeRoundBracket(): this;
25
+ build(): QueryBuilder<T, TKey>;
26
+ execute(): Promise<Array<Entity<T, TKey>>>;
27
+ executeAsStream(entityReader: (entity: Entity<T, TKey>) => void, cancellationToken?: CancellationToken | null): Promise<Array<Entity<T, TKey>>>;
28
+ count(): Promise<number>;
29
+ max(predicate: (value: T) => any): Promise<number>;
30
+ min(predicate: (value: T) => any): Promise<number>;
31
+ average(predicate: (value: T) => any): Promise<number>;
32
+ sum(predicate: (value: T) => any): Promise<number>;
33
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WhereBuilder = void 0;
4
+ const Repository_1 = require("../../Repository");
5
+ class WhereBuilder {
6
+ roundBracketsCount;
7
+ queryBuilder;
8
+ query;
9
+ constructor(query) {
10
+ this.roundBracketsCount = 0;
11
+ this.queryBuilder = new Array();
12
+ this.queryBuilder.push("_rystem => ");
13
+ this.query = query;
14
+ }
15
+ select(predicate) {
16
+ this.queryBuilder.push(Repository_1.Repository.predicateAsString(predicate));
17
+ return this;
18
+ }
19
+ operator(operation, value) {
20
+ switch (operation) {
21
+ case Operators.Equal:
22
+ this.queryBuilder.push(" == ");
23
+ this.queryBuilder.push(this.valueAsString(value));
24
+ break;
25
+ case Operators.NotEqual:
26
+ this.queryBuilder.push(" != ");
27
+ this.queryBuilder.push(this.valueAsString(value));
28
+ break;
29
+ case Operators.GreaterThan:
30
+ this.queryBuilder.push(" > ");
31
+ this.queryBuilder.push(this.valueAsString(value));
32
+ break;
33
+ case Operators.GreaterThanOrEqual:
34
+ this.queryBuilder.push(" >= ");
35
+ this.queryBuilder.push(this.valueAsString(value));
36
+ break;
37
+ case Operators.LesserThan:
38
+ this.queryBuilder.push(" < ");
39
+ this.queryBuilder.push(this.valueAsString(value));
40
+ break;
41
+ case Operators.LesserThanOrEqual:
42
+ this.queryBuilder.push(" <= ");
43
+ this.queryBuilder.push(this.valueAsString(value));
44
+ break;
45
+ case Operators.Contains:
46
+ this.queryBuilder.push(".Contains(");
47
+ this.queryBuilder.push(this.valueAsString(value));
48
+ this.queryBuilder.push(")");
49
+ break;
50
+ case Operators.StartsWith:
51
+ this.queryBuilder.push(".StartsWith(");
52
+ this.queryBuilder.push(this.valueAsString(value));
53
+ this.queryBuilder.push(")");
54
+ break;
55
+ case Operators.EndsWith:
56
+ this.queryBuilder.push(".EndsWith(");
57
+ this.queryBuilder.push(this.valueAsString(value));
58
+ this.queryBuilder.push(")");
59
+ break;
60
+ }
61
+ return this;
62
+ }
63
+ valueAsString(v) {
64
+ if (v != null) {
65
+ if (typeof v == 'number') {
66
+ return v.toString();
67
+ }
68
+ else {
69
+ return `"${v.toString()}"`;
70
+ }
71
+ }
72
+ else
73
+ return "null";
74
+ }
75
+ equal(value) {
76
+ return this
77
+ .operator(Operators.Equal, value);
78
+ }
79
+ notEqual(value) {
80
+ return this
81
+ .operator(Operators.NotEqual, value);
82
+ }
83
+ greaterThan(value) {
84
+ return this
85
+ .operator(Operators.GreaterThan, value);
86
+ }
87
+ greaterThanOrEqual(value) {
88
+ return this
89
+ .operator(Operators.GreaterThanOrEqual, value);
90
+ }
91
+ lesserThan(value) {
92
+ return this
93
+ .operator(Operators.LesserThan, value);
94
+ }
95
+ lesserThanOrEqual(value) {
96
+ return this
97
+ .operator(Operators.LesserThanOrEqual, value);
98
+ }
99
+ startsWith(value) {
100
+ return this
101
+ .operator(Operators.StartsWith, value);
102
+ }
103
+ endsWith(value) {
104
+ return this
105
+ .operator(Operators.EndsWith, value);
106
+ }
107
+ contains(value) {
108
+ return this
109
+ .operator(Operators.Contains, value);
110
+ }
111
+ and() {
112
+ this.queryBuilder.push(" && ");
113
+ return this;
114
+ }
115
+ or() {
116
+ this.queryBuilder.push(" || ");
117
+ return this;
118
+ }
119
+ openRoundBracket() {
120
+ this.queryBuilder.push("(");
121
+ this.roundBracketsCount++;
122
+ return this;
123
+ }
124
+ closeRoundBracket() {
125
+ this.queryBuilder.push(")");
126
+ this.roundBracketsCount--;
127
+ return this;
128
+ }
129
+ build() {
130
+ for (let i = 0; i < this.roundBracketsCount; i++) {
131
+ this.queryBuilder.push(")");
132
+ }
133
+ this.roundBracketsCount = 0;
134
+ return this.query.filter(this.queryBuilder.join(''));
135
+ }
136
+ execute() {
137
+ return this.build().execute();
138
+ }
139
+ executeAsStream(entityReader, cancellationToken = null) {
140
+ return this.build().executeAsStream(entityReader, cancellationToken);
141
+ }
142
+ count() {
143
+ return this.build().count();
144
+ }
145
+ max(predicate) {
146
+ return this.build().max(predicate);
147
+ }
148
+ min(predicate) {
149
+ return this.build().min(predicate);
150
+ }
151
+ average(predicate) {
152
+ return this.build().average(predicate);
153
+ }
154
+ sum(predicate) {
155
+ return this.build().sum(predicate);
156
+ }
157
+ }
158
+ exports.WhereBuilder = WhereBuilder;
159
+ var Operators;
160
+ (function (Operators) {
161
+ Operators[Operators["Equal"] = 1] = "Equal";
162
+ Operators[Operators["NotEqual"] = 2] = "NotEqual";
163
+ Operators[Operators["GreaterThan"] = 3] = "GreaterThan";
164
+ Operators[Operators["GreaterThanOrEqual"] = 4] = "GreaterThanOrEqual";
165
+ Operators[Operators["LesserThan"] = 5] = "LesserThan";
166
+ Operators[Operators["LesserThanOrEqual"] = 6] = "LesserThanOrEqual";
167
+ Operators[Operators["Contains"] = 7] = "Contains";
168
+ Operators[Operators["StartsWith"] = 8] = "StartsWith";
169
+ Operators[Operators["EndsWith"] = 9] = "EndsWith";
170
+ })(Operators || (Operators = {}));
@@ -0,0 +1,9 @@
1
+ import { ICommand, ICommandPattern } from "../interfaces/ICommand";
2
+ import { IQuery, IQueryPattern } from "../interfaces/IQuery";
3
+ import { IRepository, IRepositoryPattern } from "../interfaces/IRepository";
4
+ export declare const useRepository: <T, TKey>(name: string) => IRepository<T, TKey>;
5
+ export declare const useCommand: <T, TKey>(name: string) => ICommand<T, TKey>;
6
+ export declare const useQuery: <T, TKey>(name: string) => IQuery<T, TKey>;
7
+ export declare const useRepositoryPattern: (name: string) => IRepositoryPattern;
8
+ export declare const useCommandPattern: (name: string) => ICommandPattern;
9
+ export declare const useQueryPattern: (name: string) => IQueryPattern;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useQueryPattern = exports.useCommandPattern = exports.useRepositoryPattern = exports.useQuery = exports.useCommand = exports.useRepository = void 0;
4
+ const RepositoryServices_1 = require("../servicecollection/RepositoryServices");
5
+ const useRepository = function (name) {
6
+ return RepositoryServices_1.RepositoryServices.Repository(name);
7
+ };
8
+ exports.useRepository = useRepository;
9
+ const useCommand = function (name) {
10
+ return RepositoryServices_1.RepositoryServices.Command(name);
11
+ };
12
+ exports.useCommand = useCommand;
13
+ const useQuery = function (name) {
14
+ return RepositoryServices_1.RepositoryServices.Query(name);
15
+ };
16
+ exports.useQuery = useQuery;
17
+ const useRepositoryPattern = function (name) {
18
+ return RepositoryServices_1.RepositoryServices.RepositoryPattern(name);
19
+ };
20
+ exports.useRepositoryPattern = useRepositoryPattern;
21
+ const useCommandPattern = function (name) {
22
+ return RepositoryServices_1.RepositoryServices.CommandPattern(name);
23
+ };
24
+ exports.useCommandPattern = useCommandPattern;
25
+ const useQueryPattern = function (name) {
26
+ return RepositoryServices_1.RepositoryServices.QueryPattern(name);
27
+ };
28
+ exports.useQueryPattern = useQueryPattern;
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export type { BatchResult } from "./engine/batch/BatchResult";
2
+ export type { ICommand, ICommandPattern } from "./interfaces/ICommand";
3
+ export type { IQuery, IQueryPattern } from "./interfaces/IQuery";
4
+ export type { IRepository, IRepositoryPattern } from "./interfaces/IRepository";
5
+ export type { Entity } from "./models/Entity";
6
+ export type { State } from "./models/State";
7
+ export { RepositoryEndpoint } from "./models/RepositoryEndpoint";
8
+ export { RepositoryServices } from "./servicecollection/RepositoryServices";
9
+ export { RepositorySettings } from "./servicecollection/RepositorySettings";
10
+ export type { ITransformer } from "./servicecollection/RepositorySettings";
11
+ export { useRepository, useCommand, useQuery, useRepositoryPattern, useCommandPattern, useQueryPattern } from "./hooks/hooks";
package/lib/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useQueryPattern = exports.useCommandPattern = exports.useRepositoryPattern = exports.useQuery = exports.useCommand = exports.useRepository = exports.RepositorySettings = exports.RepositoryServices = exports.RepositoryEndpoint = void 0;
4
+ var RepositoryEndpoint_1 = require("./models/RepositoryEndpoint");
5
+ Object.defineProperty(exports, "RepositoryEndpoint", { enumerable: true, get: function () { return RepositoryEndpoint_1.RepositoryEndpoint; } });
6
+ var RepositoryServices_1 = require("./servicecollection/RepositoryServices");
7
+ Object.defineProperty(exports, "RepositoryServices", { enumerable: true, get: function () { return RepositoryServices_1.RepositoryServices; } });
8
+ var RepositorySettings_1 = require("./servicecollection/RepositorySettings");
9
+ Object.defineProperty(exports, "RepositorySettings", { enumerable: true, get: function () { return RepositorySettings_1.RepositorySettings; } });
10
+ var hooks_1 = require("./hooks/hooks");
11
+ Object.defineProperty(exports, "useRepository", { enumerable: true, get: function () { return hooks_1.useRepository; } });
12
+ Object.defineProperty(exports, "useCommand", { enumerable: true, get: function () { return hooks_1.useCommand; } });
13
+ Object.defineProperty(exports, "useQuery", { enumerable: true, get: function () { return hooks_1.useQuery; } });
14
+ Object.defineProperty(exports, "useRepositoryPattern", { enumerable: true, get: function () { return hooks_1.useRepositoryPattern; } });
15
+ Object.defineProperty(exports, "useCommandPattern", { enumerable: true, get: function () { return hooks_1.useCommandPattern; } });
16
+ Object.defineProperty(exports, "useQueryPattern", { enumerable: true, get: function () { return hooks_1.useQueryPattern; } });
@@ -0,0 +1,14 @@
1
+ import { BatchBuilder } from "../engine/batch/BatchBuilder";
2
+ import { State } from "../models/State";
3
+ export interface ICommand<T, TKey> {
4
+ insert(key: TKey, value: T): Promise<State<T, TKey>>;
5
+ update(key: TKey, value: T): Promise<State<T, TKey>>;
6
+ delete(key: TKey): Promise<State<T, TKey>>;
7
+ batch(): BatchBuilder<T, TKey>;
8
+ }
9
+ export interface ICommandPattern {
10
+ insert(key: any, value: any): Promise<State<any, any>>;
11
+ update(key: any, value: any): Promise<State<any, any>>;
12
+ delete(key: any): Promise<State<any, any>>;
13
+ batch(): BatchBuilder<any, any>;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { QueryBuilder } from "../engine/query/QueryBuilder";
2
+ import { State } from "../models/State";
3
+ export interface IQuery<T, TKey> {
4
+ get(key: TKey): Promise<T>;
5
+ exist(key: TKey): Promise<State<T, TKey>>;
6
+ query(): QueryBuilder<T, TKey>;
7
+ }
8
+ export interface IQueryPattern {
9
+ get(key: any): Promise<any>;
10
+ exist(key: any): Promise<State<any, any>>;
11
+ query(): QueryBuilder<any, any>;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { ICommand, ICommandPattern } from "./ICommand";
2
+ import { IQuery, IQueryPattern } from "./IQuery";
3
+ export interface IRepository<T, TKey> extends IQuery<T, TKey>, ICommand<T, TKey> {
4
+ }
5
+ export interface IRepositoryPattern extends IQueryPattern, ICommandPattern {
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ export type Entity<T, TKey> = {
2
+ value: T;
3
+ key: TKey;
4
+ };
5
+ export type SerializedEntity<T, TKey> = {
6
+ v: T;
7
+ k: TKey;
8
+ };
9
+ export declare function isEntity<T, TKey>(obj: any): obj is Entity<T, TKey>;
10
+ export declare function isSerializedEntity<T, TKey>(obj: any): obj is SerializedEntity<T, TKey>;
11
+ export declare function isSerializedEntityArray<T, TKey>(arr: any): arr is SerializedEntity<T, TKey>[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEntity = isEntity;
4
+ exports.isSerializedEntity = isSerializedEntity;
5
+ exports.isSerializedEntityArray = isSerializedEntityArray;
6
+ function isEntity(obj) {
7
+ return (typeof obj === 'object' &&
8
+ obj !== null &&
9
+ 'value' in obj &&
10
+ 'key' in obj);
11
+ }
12
+ function isSerializedEntity(obj) {
13
+ return (typeof obj === 'object' &&
14
+ obj !== null &&
15
+ 'v' in obj &&
16
+ 'k' in obj);
17
+ }
18
+ function isSerializedEntityArray(arr) {
19
+ return Array.isArray(arr) && arr.every(isSerializedEntity);
20
+ }
@@ -0,0 +1,12 @@
1
+ export declare enum RepositoryEndpoint {
2
+ Get = 1,
3
+ Exist = 2,
4
+ Query = 3,
5
+ QueryStream = 4,
6
+ Operation = 5,
7
+ Insert = 6,
8
+ Update = 7,
9
+ Delete = 8,
10
+ Batch = 9,
11
+ BatchStream = 10
12
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RepositoryEndpoint = void 0;
4
+ var RepositoryEndpoint;
5
+ (function (RepositoryEndpoint) {
6
+ RepositoryEndpoint[RepositoryEndpoint["Get"] = 1] = "Get";
7
+ RepositoryEndpoint[RepositoryEndpoint["Exist"] = 2] = "Exist";
8
+ RepositoryEndpoint[RepositoryEndpoint["Query"] = 3] = "Query";
9
+ RepositoryEndpoint[RepositoryEndpoint["QueryStream"] = 4] = "QueryStream";
10
+ RepositoryEndpoint[RepositoryEndpoint["Operation"] = 5] = "Operation";
11
+ RepositoryEndpoint[RepositoryEndpoint["Insert"] = 6] = "Insert";
12
+ RepositoryEndpoint[RepositoryEndpoint["Update"] = 7] = "Update";
13
+ RepositoryEndpoint[RepositoryEndpoint["Delete"] = 8] = "Delete";
14
+ RepositoryEndpoint[RepositoryEndpoint["Batch"] = 9] = "Batch";
15
+ RepositoryEndpoint[RepositoryEndpoint["BatchStream"] = 10] = "BatchStream";
16
+ })(RepositoryEndpoint || (exports.RepositoryEndpoint = RepositoryEndpoint = {}));
@@ -0,0 +1,20 @@
1
+ export type State<T, TKey> = {
2
+ isOk: boolean;
3
+ entity: {
4
+ key: TKey;
5
+ value: T;
6
+ };
7
+ code: number | null;
8
+ message: string | null;
9
+ };
10
+ export type SerializedState<T, TKey> = {
11
+ i: boolean;
12
+ e: {
13
+ k: TKey;
14
+ v: T;
15
+ };
16
+ c: number | null;
17
+ m: string | null;
18
+ };
19
+ export declare function isState<T, TKey>(obj: any): obj is State<T, TKey>;
20
+ export declare function isSerializedState<T, TKey>(obj: any): obj is SerializedState<T, TKey>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isState = isState;
4
+ exports.isSerializedState = isSerializedState;
5
+ function isState(obj) {
6
+ return (typeof obj === 'object' &&
7
+ obj !== null &&
8
+ typeof obj.isOk === 'boolean' &&
9
+ typeof obj.entity === 'object' &&
10
+ obj.entity !== null &&
11
+ 'key' in obj.entity &&
12
+ 'value' in obj.entity &&
13
+ ('code' in obj || obj.code === null) &&
14
+ ('message' in obj || obj.message === null));
15
+ }
16
+ function isSerializedState(obj) {
17
+ return (typeof obj === 'object' &&
18
+ obj !== null &&
19
+ typeof obj.i === 'boolean' &&
20
+ (obj.e === null || (typeof obj.e === 'object' &&
21
+ obj.e !== null &&
22
+ 'k' in obj.e &&
23
+ 'v' in obj.e)) &&
24
+ ('c' in obj || obj.c === null) &&
25
+ ('m' in obj || obj.m === null));
26
+ }
@@ -0,0 +1,23 @@
1
+ import { ICommand, ICommandPattern } from "../interfaces/ICommand";
2
+ import { IQuery, IQueryPattern } from "../interfaces/IQuery";
3
+ import { IRepository, IRepositoryPattern } from "../interfaces/IRepository";
4
+ import { RepositorySettings } from "./RepositorySettings";
5
+ export declare class RepositoryServices {
6
+ private static instance;
7
+ private repositories;
8
+ private baseUri;
9
+ private constructor();
10
+ static Repository<T, TKey>(name: string): IRepository<T, TKey>;
11
+ static Command<T, TKey>(name: string): ICommand<T, TKey>;
12
+ static Query<T, TKey>(name: string): IQuery<T, TKey>;
13
+ private static Instance;
14
+ static RepositoryPattern(name: string): IRepositoryPattern;
15
+ static CommandPattern(name: string): ICommandPattern;
16
+ static QueryPattern(name: string): IQueryPattern;
17
+ private static InstancePattern;
18
+ static Create<T, TKey>(baseUri: string | null): RepositoryServices;
19
+ private AddRepository;
20
+ addRepository<T, TKey>(builder: (x: RepositorySettings) => void): this;
21
+ addCommand<T, TKey>(builder: (x: RepositorySettings) => void): this;
22
+ addQuery<T, TKey>(builder: (x: RepositorySettings) => void): this;
23
+ }