rystem.repository.client 0.2.2 → 0.2.3
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.
- package/lib/hooks/hooks.d.ts +6 -3
- package/lib/hooks/hooks.js +14 -2
- package/lib/index.d.ts +6 -5
- package/lib/index.js +4 -1
- package/lib/interfaces/ICommand.d.ts +6 -0
- package/lib/interfaces/IQuery.d.ts +5 -0
- package/lib/interfaces/IRepository.d.ts +4 -2
- package/lib/servicecollection/RepositoryServices.d.ts +7 -3
- package/lib/servicecollection/RepositoryServices.js +26 -0
- package/package.json +1 -1
package/lib/hooks/hooks.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ICommand } from "../interfaces/ICommand";
|
|
2
|
-
import { IQuery } from "../interfaces/IQuery";
|
|
3
|
-
import { IRepository } from "../interfaces/IRepository";
|
|
1
|
+
import { ICommand, ICommandPattern } from "../interfaces/ICommand";
|
|
2
|
+
import { IQuery, IQueryPattern } from "../interfaces/IQuery";
|
|
3
|
+
import { IRepository, IRepositoryPattern } from "../interfaces/IRepository";
|
|
4
4
|
export declare const useRepository: <T, TKey>(name: string) => IRepository<T, TKey>;
|
|
5
5
|
export declare const useCommand: <T, TKey>(name: string) => ICommand<T, TKey>;
|
|
6
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;
|
package/lib/hooks/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useQuery = exports.useCommand = exports.useRepository = void 0;
|
|
3
|
+
exports.useQueryPattern = exports.useCommandPattern = exports.useRepositoryPattern = exports.useQuery = exports.useCommand = exports.useRepository = void 0;
|
|
4
4
|
const RepositoryServices_1 = require("../servicecollection/RepositoryServices");
|
|
5
5
|
const useRepository = function (name) {
|
|
6
6
|
return RepositoryServices_1.RepositoryServices.Repository(name);
|
|
@@ -11,6 +11,18 @@ const useCommand = function (name) {
|
|
|
11
11
|
};
|
|
12
12
|
exports.useCommand = useCommand;
|
|
13
13
|
const useQuery = function (name) {
|
|
14
|
-
return RepositoryServices_1.RepositoryServices.
|
|
14
|
+
return RepositoryServices_1.RepositoryServices.Query(name);
|
|
15
15
|
};
|
|
16
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
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export type { BatchResult } from "./engine/batch/BatchResult";
|
|
2
|
-
export type { ICommand } from "./interfaces/ICommand";
|
|
3
|
-
export type { IQuery } from "./interfaces/IQuery";
|
|
4
|
-
export type { IRepository } from "./interfaces/IRepository";
|
|
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
5
|
export type { Entity } from "./models/Entity";
|
|
6
6
|
export type { State } from "./models/State";
|
|
7
7
|
export { RepositoryEndpoint } from "./models/RepositoryEndpoint";
|
|
8
8
|
export { RepositoryServices } from "./servicecollection/RepositoryServices";
|
|
9
|
-
export { RepositorySettings
|
|
10
|
-
export {
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useQuery = exports.useCommand = exports.useRepository = exports.RepositorySettings = exports.RepositoryServices = exports.RepositoryEndpoint = void 0;
|
|
3
|
+
exports.useQueryPattern = exports.useCommandPattern = exports.useRepositoryPattern = exports.useQuery = exports.useCommand = exports.useRepository = exports.RepositorySettings = exports.RepositoryServices = exports.RepositoryEndpoint = void 0;
|
|
4
4
|
var RepositoryEndpoint_1 = require("./models/RepositoryEndpoint");
|
|
5
5
|
Object.defineProperty(exports, "RepositoryEndpoint", { enumerable: true, get: function () { return RepositoryEndpoint_1.RepositoryEndpoint; } });
|
|
6
6
|
var RepositoryServices_1 = require("./servicecollection/RepositoryServices");
|
|
@@ -11,3 +11,6 @@ var hooks_1 = require("./hooks/hooks");
|
|
|
11
11
|
Object.defineProperty(exports, "useRepository", { enumerable: true, get: function () { return hooks_1.useRepository; } });
|
|
12
12
|
Object.defineProperty(exports, "useCommand", { enumerable: true, get: function () { return hooks_1.useCommand; } });
|
|
13
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; } });
|
|
@@ -6,3 +6,9 @@ export interface ICommand<T, TKey> {
|
|
|
6
6
|
delete(key: TKey): Promise<State<T, TKey>>;
|
|
7
7
|
batch(): BatchBuilder<T, TKey>;
|
|
8
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
|
+
}
|
|
@@ -5,3 +5,8 @@ export interface IQuery<T, TKey> {
|
|
|
5
5
|
exist(key: TKey): Promise<State<T, TKey>>;
|
|
6
6
|
query(): QueryBuilder<T, TKey>;
|
|
7
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
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ICommand } from "./ICommand";
|
|
2
|
-
import { IQuery } from "./IQuery";
|
|
1
|
+
import { ICommand, ICommandPattern } from "./ICommand";
|
|
2
|
+
import { IQuery, IQueryPattern } from "./IQuery";
|
|
3
3
|
export interface IRepository<T, TKey> extends IQuery<T, TKey>, ICommand<T, TKey> {
|
|
4
4
|
}
|
|
5
|
+
export interface IRepositoryPattern extends IQueryPattern, ICommandPattern {
|
|
6
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ICommand } from "../interfaces/ICommand";
|
|
2
|
-
import { IQuery } from "../interfaces/IQuery";
|
|
3
|
-
import { IRepository } from "../interfaces/IRepository";
|
|
1
|
+
import { ICommand, ICommandPattern } from "../interfaces/ICommand";
|
|
2
|
+
import { IQuery, IQueryPattern } from "../interfaces/IQuery";
|
|
3
|
+
import { IRepository, IRepositoryPattern } from "../interfaces/IRepository";
|
|
4
4
|
import { RepositorySettings } from "./RepositorySettings";
|
|
5
5
|
export declare class RepositoryServices {
|
|
6
6
|
private static instance;
|
|
@@ -11,6 +11,10 @@ export declare class RepositoryServices {
|
|
|
11
11
|
static Command<T, TKey>(name: string): ICommand<T, TKey>;
|
|
12
12
|
static Query<T, TKey>(name: string): IQuery<T, TKey>;
|
|
13
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;
|
|
14
18
|
static Create<T, TKey>(baseUri: string | null): RepositoryServices;
|
|
15
19
|
private AddRepository;
|
|
16
20
|
addRepository<T, TKey>(builder: (x: RepositorySettings) => void): this;
|
|
@@ -37,6 +37,32 @@ class RepositoryServices {
|
|
|
37
37
|
}
|
|
38
38
|
throw new Error(`${type} with '${name}' has a wrong setup.`);
|
|
39
39
|
}
|
|
40
|
+
static RepositoryPattern(name) {
|
|
41
|
+
return RepositoryServices.InstancePattern(name, RepositoryType.Repository);
|
|
42
|
+
}
|
|
43
|
+
static CommandPattern(name) {
|
|
44
|
+
return RepositoryServices.InstancePattern(name, RepositoryType.Command);
|
|
45
|
+
}
|
|
46
|
+
static QueryPattern(name) {
|
|
47
|
+
return RepositoryServices.InstancePattern(name, RepositoryType.Query);
|
|
48
|
+
}
|
|
49
|
+
static InstancePattern(name, type) {
|
|
50
|
+
if (!RepositoryServices.instance) {
|
|
51
|
+
RepositoryServices.instance = new RepositoryServices();
|
|
52
|
+
}
|
|
53
|
+
if (RepositoryServices.instance.repositories.has(name)) {
|
|
54
|
+
const wrapper = RepositoryServices.instance.repositories.get(name);
|
|
55
|
+
if (wrapper != undefined && wrapper.type == type) {
|
|
56
|
+
if (wrapper.type == RepositoryType.Repository)
|
|
57
|
+
return wrapper.repository;
|
|
58
|
+
else if (wrapper.type == RepositoryType.Command)
|
|
59
|
+
return wrapper.repository;
|
|
60
|
+
else
|
|
61
|
+
return wrapper.repository;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
throw new Error(`${type} with '${name}' has a wrong setup.`);
|
|
65
|
+
}
|
|
40
66
|
static Create(baseUri) {
|
|
41
67
|
if (!RepositoryServices.instance) {
|
|
42
68
|
RepositoryServices.instance = new RepositoryServices();
|
package/package.json
CHANGED