@quatrain/core 1.0.0-beta24 → 1.0.0-beta26
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/Core.d.ts +0 -12
- package/lib/Core.js +0 -16
- package/lib/components/AbstractObject.d.ts +1 -1
- package/lib/components/BaseObjectCore.d.ts +5 -46
- package/lib/components/BaseObjectCore.js +46 -65
- package/lib/components/DataObject.d.ts +2 -7
- package/lib/components/DataObject.js +10 -42
- package/lib/components/ObjectUri.d.ts +3 -3
- package/lib/components/ObjectUri.js +1 -3
- package/lib/components/index.d.ts +1 -3
- package/lib/components/index.js +1 -8
- package/lib/index.d.ts +4 -16
- package/lib/index.js +6 -35
- package/lib/properties/CollectionProperty.d.ts +1 -16
- package/lib/properties/CollectionProperty.js +0 -41
- package/lib/properties/ObjectProperty.d.ts +6 -0
- package/lib/properties/ObjectProperty.js +12 -5
- package/package.json +1 -1
- package/lib/Auth.d.ts +0 -25
- package/lib/Auth.js +0 -9
- package/lib/Backend copy.d.ts +0 -39
- package/lib/Backend copy.js +0 -11
- package/lib/Backend.d.ts +0 -39
- package/lib/Backend.js +0 -11
- package/lib/Storage.d.ts +0 -13
- package/lib/Storage.js +0 -2
- package/lib/authentication/AbstractAuthAdapter.d.ts +0 -18
- package/lib/authentication/AbstractAuthAdapter.js +0 -23
- package/lib/authentication/AuthenticationError.d.ts +0 -2
- package/lib/authentication/AuthenticationError.js +0 -6
- package/lib/authentication/index.d.ts +0 -4
- package/lib/authentication/index.js +0 -7
- package/lib/authentication/middlewares/AbstractAuthMiddleware.d.ts +0 -0
- package/lib/authentication/middlewares/AbstractAuthMiddleware.js +0 -1
- package/lib/authentication/middlewares/AuthMiddleware.d.ts +0 -5
- package/lib/authentication/middlewares/AuthMiddleware.js +0 -2
- package/lib/authentication/types/AuthInterface.d.ts +0 -9
- package/lib/authentication/types/AuthInterface.js +0 -2
- package/lib/backends/AbstractAdapter.d.ts +0 -45
- package/lib/backends/AbstractAdapter.js +0 -86
- package/lib/backends/BackendError.d.ts +0 -2
- package/lib/backends/BackendError.js +0 -6
- package/lib/backends/Filter.d.ts +0 -17
- package/lib/backends/Filter.js +0 -14
- package/lib/backends/FilterOperators.d.ts +0 -13
- package/lib/backends/FilterOperators.js +0 -16
- package/lib/backends/Filters.d.ts +0 -11
- package/lib/backends/Filters.js +0 -14
- package/lib/backends/Limits.d.ts +0 -9
- package/lib/backends/Limits.js +0 -10
- package/lib/backends/MockAdapter.d.ts +0 -25
- package/lib/backends/MockAdapter.js +0 -189
- package/lib/backends/NotFoundError.d.ts +0 -2
- package/lib/backends/NotFoundError.js +0 -6
- package/lib/backends/Query.d.ts +0 -56
- package/lib/backends/Query.js +0 -129
- package/lib/backends/SortAndLimit.d.ts +0 -11
- package/lib/backends/SortAndLimit.js +0 -11
- package/lib/backends/Sorting.d.ts +0 -9
- package/lib/backends/Sorting.js +0 -10
- package/lib/backends/index.d.ts +0 -12
- package/lib/backends/index.js +0 -46
- package/lib/backends/middlewares/AbstractMiddleware.d.ts +0 -0
- package/lib/backends/middlewares/AbstractMiddleware.js +0 -1
- package/lib/backends/middlewares/InjectKeywordsMiddleware.d.ts +0 -9
- package/lib/backends/middlewares/InjectKeywordsMiddleware.js +0 -47
- package/lib/backends/middlewares/InjectMetaMiddleware.d.ts +0 -13
- package/lib/backends/middlewares/InjectMetaMiddleware.js +0 -33
- package/lib/backends/middlewares/Middleware.d.ts +0 -5
- package/lib/backends/middlewares/Middleware.js +0 -2
- package/lib/backends/middlewares/types/MiddlewareParams.d.ts +0 -3
- package/lib/backends/middlewares/types/MiddlewareParams.js +0 -2
- package/lib/backends/types/BackendInterface.d.ts +0 -13
- package/lib/backends/types/BackendInterface.js +0 -2
- package/lib/backends/types/CollectionHierarchy.d.ts +0 -3
- package/lib/backends/types/CollectionHierarchy.js +0 -6
- package/lib/components/BaseRepository.d.ts +0 -25
- package/lib/components/BaseRepository.js +0 -138
- package/lib/components/EntityRepository.d.ts +0 -6
- package/lib/components/EntityRepository.js +0 -14
- package/lib/components/UserRepository.d.ts +0 -7
- package/lib/components/UserRepository.js +0 -36
- package/lib/components/types/RepositoryClass.d.ts +0 -40
- package/lib/components/types/RepositoryClass.js +0 -2
- package/lib/properties/ObjectProperty copy.d.ts +0 -16
- package/lib/properties/ObjectProperty copy.js +0 -85
- package/lib/storages/AbstractStorageAdapter.d.ts +0 -23
- package/lib/storages/AbstractStorageAdapter.js +0 -13
- package/lib/storages/StorageAdapterInterface.d.ts +0 -20
- package/lib/storages/StorageAdapterInterface.js +0 -2
- package/lib/storages/index.d.ts +0 -9
- package/lib/storages/index.js +0 -17
- package/lib/storages/types/BlobMediaType.d.ts +0 -8
- package/lib/storages/types/BlobMediaType.js +0 -2
- package/lib/storages/types/BlobType.d.ts +0 -6
- package/lib/storages/types/BlobType.js +0 -2
- package/lib/storages/types/DownloadFileMetaType.d.ts +0 -4
- package/lib/storages/types/DownloadFileMetaType.js +0 -2
- package/lib/storages/types/FileResponseLink.d.ts +0 -7
- package/lib/storages/types/FileResponseLink.js +0 -2
- package/lib/storages/types/FileResponseUrl.d.ts +0 -4
- package/lib/storages/types/FileResponseUrl.js +0 -2
- package/lib/storages/types/FileType.d.ts +0 -15
- package/lib/storages/types/FileType.js +0 -2
- package/lib/storages/types.d.ts +0 -5
- package/lib/storages/types.js +0 -2
- package/lib/utils/DataGenerator.d.ts +0 -9
- package/lib/utils/DataGenerator.js +0 -102
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -5
- package/lib/wrappers/cloud/AbstractCloudWrapper.d.ts +0 -4
- package/lib/wrappers/cloud/AbstractCloudWrapper.js +0 -9
- package/lib/wrappers/cloud/types/DatabaseTriggerType.d.ts +0 -8
- package/lib/wrappers/cloud/types/DatabaseTriggerType.js +0 -2
package/lib/backends/Filter.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BaseObjectCore } from '../components';
|
|
2
|
-
import { FilterOperatorType } from './FilterOperators';
|
|
3
|
-
export type FilterValueType<T extends BaseObjectCore> = T | number | string | string[] | null;
|
|
4
|
-
export interface FilterType {
|
|
5
|
-
prop: string;
|
|
6
|
-
operator: FilterOperatorType | undefined;
|
|
7
|
-
value: FilterValueType<any>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Filter object
|
|
11
|
-
*/
|
|
12
|
-
export declare class Filter implements FilterType {
|
|
13
|
-
prop: string;
|
|
14
|
-
operator: FilterOperatorType;
|
|
15
|
-
value: FilterValueType<any>;
|
|
16
|
-
constructor(prop: string, value: FilterValueType<any>, operator?: FilterOperatorType);
|
|
17
|
-
}
|
package/lib/backends/Filter.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Filter = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Filter object
|
|
6
|
-
*/
|
|
7
|
-
class Filter {
|
|
8
|
-
constructor(prop, value, operator = 'equals') {
|
|
9
|
-
this.prop = prop;
|
|
10
|
-
this.operator = operator;
|
|
11
|
-
this.value = value;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.Filter = Filter;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare enum FilterOperator {
|
|
2
|
-
equals = 0,
|
|
3
|
-
notEquals = 1,
|
|
4
|
-
greater = 2,
|
|
5
|
-
greaterOrEquals = 3,
|
|
6
|
-
lower = 4,
|
|
7
|
-
lowerOrEquals = 5,
|
|
8
|
-
contains = 6,
|
|
9
|
-
notContains = 7,
|
|
10
|
-
containsAll = 8,
|
|
11
|
-
containsAny = 9
|
|
12
|
-
}
|
|
13
|
-
export type FilterOperatorType = 'equals' | 'notEquals' | 'greater' | 'greaterOrEquals' | 'lower' | 'lowerOrEquals' | 'contains' | 'notContains' | 'containsAll' | 'containsAny';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilterOperator = void 0;
|
|
4
|
-
var FilterOperator;
|
|
5
|
-
(function (FilterOperator) {
|
|
6
|
-
FilterOperator[FilterOperator["equals"] = 0] = "equals";
|
|
7
|
-
FilterOperator[FilterOperator["notEquals"] = 1] = "notEquals";
|
|
8
|
-
FilterOperator[FilterOperator["greater"] = 2] = "greater";
|
|
9
|
-
FilterOperator[FilterOperator["greaterOrEquals"] = 3] = "greaterOrEquals";
|
|
10
|
-
FilterOperator[FilterOperator["lower"] = 4] = "lower";
|
|
11
|
-
FilterOperator[FilterOperator["lowerOrEquals"] = 5] = "lowerOrEquals";
|
|
12
|
-
FilterOperator[FilterOperator["contains"] = 6] = "contains";
|
|
13
|
-
FilterOperator[FilterOperator["notContains"] = 7] = "notContains";
|
|
14
|
-
FilterOperator[FilterOperator["containsAll"] = 8] = "containsAll";
|
|
15
|
-
FilterOperator[FilterOperator["containsAny"] = 9] = "containsAny";
|
|
16
|
-
})(FilterOperator || (exports.FilterOperator = FilterOperator = {}));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Filter } from './Filter';
|
|
2
|
-
export interface FiltersType {
|
|
3
|
-
or?: Filter[];
|
|
4
|
-
and?: Filter[];
|
|
5
|
-
base?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare class Filters implements FiltersType {
|
|
8
|
-
or?: Filter[];
|
|
9
|
-
and?: Filter[];
|
|
10
|
-
constructor(or?: Filter[], and?: Filter[]);
|
|
11
|
-
}
|
package/lib/backends/Filters.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Filters = void 0;
|
|
4
|
-
class Filters {
|
|
5
|
-
constructor(or, and) {
|
|
6
|
-
if (or) {
|
|
7
|
-
this.or = or;
|
|
8
|
-
}
|
|
9
|
-
if (and) {
|
|
10
|
-
this.and = and;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.Filters = Filters;
|
package/lib/backends/Limits.d.ts
DELETED
package/lib/backends/Limits.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { DataObjectClass } from '../components/types/DataObjectClass';
|
|
2
|
-
import { QueryResultType } from './Query';
|
|
3
|
-
import { Filter } from './Filter';
|
|
4
|
-
import { Filters } from './Filters';
|
|
5
|
-
import { SortAndLimit } from './SortAndLimit';
|
|
6
|
-
import { AbstractAdapter } from './AbstractAdapter';
|
|
7
|
-
import { BackendInterface } from './types/BackendInterface';
|
|
8
|
-
import { BackendRecordType } from '../Backend';
|
|
9
|
-
export declare class MockAdapter extends AbstractAdapter implements BackendInterface {
|
|
10
|
-
protected static _fixtures: any;
|
|
11
|
-
/**
|
|
12
|
-
* Inject fixtures data to backend adapter
|
|
13
|
-
* @param data BackendRecordType
|
|
14
|
-
*/
|
|
15
|
-
static inject(data: BackendRecordType): void;
|
|
16
|
-
static dao2backend(data: BackendRecordType): Promise<any>;
|
|
17
|
-
static getFixtures(): any[];
|
|
18
|
-
static getFixture(key: string): any;
|
|
19
|
-
create(dataObject: DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
20
|
-
read(dataObject: DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
21
|
-
update(dataObject: DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
22
|
-
delete(dataObject: DataObjectClass<any>): Promise<DataObjectClass<any>>;
|
|
23
|
-
deleteCollection(collection: string, batchSize?: number | undefined): Promise<void>;
|
|
24
|
-
find(dataObject: DataObjectClass<any>, filters?: Filters | Filter[] | undefined, pagination?: SortAndLimit | undefined): Promise<QueryResultType<DataObjectClass<any>>>;
|
|
25
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MockAdapter = void 0;
|
|
13
|
-
const Core_1 = require("../Core");
|
|
14
|
-
const ObjectUri_1 = require("../components/ObjectUri");
|
|
15
|
-
const faker_1 = require("@faker-js/faker");
|
|
16
|
-
const BackendError_1 = require("./BackendError");
|
|
17
|
-
const ResourcesErrors_1 = require("../common/ResourcesErrors");
|
|
18
|
-
const AbstractAdapter_1 = require("./AbstractAdapter");
|
|
19
|
-
class MockAdapter extends AbstractAdapter_1.AbstractAdapter {
|
|
20
|
-
/**
|
|
21
|
-
* Inject fixtures data to backend adapter
|
|
22
|
-
* @param data BackendRecordType
|
|
23
|
-
*/
|
|
24
|
-
static inject(data) {
|
|
25
|
-
if (data.path) {
|
|
26
|
-
MockAdapter._fixtures[data.path] = this.dao2backend(data);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw new Error(`Can't inject data without a path`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
static dao2backend(data) {
|
|
33
|
-
const processed = {};
|
|
34
|
-
Object.keys(data).forEach((key) => {
|
|
35
|
-
if (data[key] !== null &&
|
|
36
|
-
typeof data[key] === 'object' &&
|
|
37
|
-
data[key].name === 'BaseObject') {
|
|
38
|
-
processed[key] = data[key].dataObject.uri.toReference();
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
processed[key] = data[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
return processed;
|
|
45
|
-
}
|
|
46
|
-
static getFixtures() {
|
|
47
|
-
return MockAdapter._fixtures;
|
|
48
|
-
}
|
|
49
|
-
static getFixture(key) {
|
|
50
|
-
return MockAdapter._fixtures[key];
|
|
51
|
-
}
|
|
52
|
-
create(dataObject) {
|
|
53
|
-
const uri = `${this.getCollection(dataObject)}/${faker_1.faker.random.alphaNumeric(12)}`;
|
|
54
|
-
dataObject.uri = new ObjectUri_1.ObjectUri(uri);
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
try {
|
|
57
|
-
MockAdapter.inject(Object.assign(Object.assign({}, dataObject.toJSON()), { uid: uri, path: uri }));
|
|
58
|
-
resolve(dataObject);
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
reject(new BackendError_1.BackendError(err.message));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
read(dataObject) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const path = dataObject.path;
|
|
69
|
-
const data = MockAdapter._fixtures[path];
|
|
70
|
-
if (data === undefined) {
|
|
71
|
-
reject(new ResourcesErrors_1.NotFoundError(`[Mock] No data for ${path}`));
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
this.log(`[DAO] Populating ${dataObject.path}`);
|
|
75
|
-
resolve(yield dataObject.populate(data));
|
|
76
|
-
}));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
update(dataObject) {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const path = dataObject.path;
|
|
83
|
-
const data = MockAdapter._fixtures[path];
|
|
84
|
-
if (data === undefined) {
|
|
85
|
-
reject(new ResourcesErrors_1.NotFoundError(`[Mock] No data for ${path}`));
|
|
86
|
-
}
|
|
87
|
-
this.log(`[DAO] Updating ${dataObject.path}`);
|
|
88
|
-
MockAdapter._fixtures[path] = Object.assign(Object.assign({}, data), dataObject.toJSON());
|
|
89
|
-
resolve(dataObject);
|
|
90
|
-
}));
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
delete(dataObject) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
return new Promise((resolve, reject) => {
|
|
96
|
-
const path = dataObject.path;
|
|
97
|
-
const data = MockAdapter._fixtures[path];
|
|
98
|
-
if (data === undefined) {
|
|
99
|
-
reject(new ResourcesErrors_1.NotFoundError(`[Mock] No data for ${path}`));
|
|
100
|
-
}
|
|
101
|
-
delete MockAdapter._fixtures[dataObject.path];
|
|
102
|
-
dataObject.uri = new ObjectUri_1.ObjectUri();
|
|
103
|
-
resolve(dataObject);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
deleteCollection(collection, batchSize) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
for (let key in MockAdapter._fixtures) {
|
|
110
|
-
if (key.startsWith(`${collection}/`)) {
|
|
111
|
-
delete MockAdapter._fixtures[key];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return new Promise(() => null);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
find(dataObject, filters = undefined, pagination = undefined) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
const limit = (pagination === null || pagination === void 0 ? void 0 : pagination.limits.batch) || 1e10;
|
|
120
|
-
let items = [];
|
|
121
|
-
const collection = this.getCollection(dataObject);
|
|
122
|
-
// TODO filter only records matchinf collection
|
|
123
|
-
for (let key in MockAdapter.getFixtures()) {
|
|
124
|
-
let keep = true;
|
|
125
|
-
if (key.startsWith(`${collection}/`) && items.length <= limit) {
|
|
126
|
-
const dao = yield dataObject.clone(MockAdapter.getFixture(key));
|
|
127
|
-
if (filters) {
|
|
128
|
-
if (Array.isArray(filters)) {
|
|
129
|
-
filters.forEach((filter) => {
|
|
130
|
-
const prop = dao.get(filter.prop);
|
|
131
|
-
if (typeof prop === 'undefined') {
|
|
132
|
-
keep = false;
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const val = prop.val();
|
|
136
|
-
if (typeof prop === 'object') {
|
|
137
|
-
if (prop.constructor.name === 'ObjectProperty') {
|
|
138
|
-
if (filter.value instanceof ObjectUri_1.ObjectUri &&
|
|
139
|
-
val &&
|
|
140
|
-
val.ref !== filter.value.path) {
|
|
141
|
-
keep = false;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else if (prop.constructor.name === 'CollectionProperty') {
|
|
146
|
-
if (filter.value instanceof ObjectUri_1.ObjectUri &&
|
|
147
|
-
prop.val() !== filter.value.path) {
|
|
148
|
-
keep = false;
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else if (val !== filter.value) {
|
|
153
|
-
keep = false;
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
if (prop.val() !== filter.value) {
|
|
159
|
-
keep = false;
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (keep) {
|
|
167
|
-
dao.uri = new ObjectUri_1.ObjectUri(key);
|
|
168
|
-
items.push(dao);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (pagination && pagination.sortings.length > 0) {
|
|
173
|
-
items = items.sort((a, b) => Number(a.val(pagination.sortings[0].prop) >
|
|
174
|
-
b.val(pagination.sortings[0].prop)));
|
|
175
|
-
}
|
|
176
|
-
return {
|
|
177
|
-
items,
|
|
178
|
-
meta: {
|
|
179
|
-
count: 100,
|
|
180
|
-
offset: (pagination === null || pagination === void 0 ? void 0 : pagination.limits.offset) || 0,
|
|
181
|
-
batch: (pagination === null || pagination === void 0 ? void 0 : pagination.limits.batch) || 10,
|
|
182
|
-
executionTime: Core_1.Core.timestamp(),
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exports.MockAdapter = MockAdapter;
|
|
189
|
-
MockAdapter._fixtures = {};
|
package/lib/backends/Query.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Filter } from './Filter';
|
|
2
|
-
import { Limits } from './Limits';
|
|
3
|
-
import { Sorting } from './Sorting';
|
|
4
|
-
import { SortAndLimit } from './SortAndLimit';
|
|
5
|
-
import { BackendInterface } from './types/BackendInterface';
|
|
6
|
-
import { DataObjectClass, ObjectUri } from '../components';
|
|
7
|
-
import { BaseObjectCore } from '../components/BaseObjectCore';
|
|
8
|
-
export declare const AS_OBJECTURIS = "objectUris";
|
|
9
|
-
export declare const AS_DATAOBJECTS = "dataObjects";
|
|
10
|
-
export declare const AS_INSTANCES = "classInstances";
|
|
11
|
-
export type OperatorKeys = 'equals' | 'notEquals' | 'greater' | 'greaterOrEquals' | 'lower' | 'lowerOrEquals' | 'contains' | 'notContains' | 'containsAll' | 'containsAny';
|
|
12
|
-
export type QueryMetaType = {
|
|
13
|
-
count: number;
|
|
14
|
-
offset: number;
|
|
15
|
-
batch: number;
|
|
16
|
-
executionTime: string | number;
|
|
17
|
-
sortField?: string;
|
|
18
|
-
sortOrder?: 'asc' | 'desc';
|
|
19
|
-
debug?: any;
|
|
20
|
-
};
|
|
21
|
-
export type QueryResultType<T> = {
|
|
22
|
-
items: Array<T>;
|
|
23
|
-
meta: QueryMetaType;
|
|
24
|
-
};
|
|
25
|
-
export declare enum returnAs {
|
|
26
|
-
AS_OBJECTURIS = "objectUris",
|
|
27
|
-
AS_DATAOBJECTS = "dataObjects",
|
|
28
|
-
AS_INSTANCES = "classInstances",
|
|
29
|
-
AS_IS = "asIs"
|
|
30
|
-
}
|
|
31
|
-
export declare class Query<T extends typeof BaseObjectCore> {
|
|
32
|
-
protected _obj: T;
|
|
33
|
-
protected _parent: T | undefined;
|
|
34
|
-
filters: Filter[];
|
|
35
|
-
sortings: Sorting[];
|
|
36
|
-
limits: Limits;
|
|
37
|
-
meta: any;
|
|
38
|
-
constructor(obj: T, parent?: T);
|
|
39
|
-
get obj(): T;
|
|
40
|
-
get parent(): T | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Declare query parent record
|
|
43
|
-
* This may be need in some NoSQL backend to query subcollections
|
|
44
|
-
*/
|
|
45
|
-
set parent(parent: T | undefined);
|
|
46
|
-
where(param: Filter | string | any, value?: any, operator?: OperatorKeys): this;
|
|
47
|
-
sortBy(param: Sorting | string, order?: any): this;
|
|
48
|
-
setLimits(limits: Limits): this;
|
|
49
|
-
offset(offset?: number): this;
|
|
50
|
-
batch(batch?: number): this;
|
|
51
|
-
get sortAndLimit(): SortAndLimit;
|
|
52
|
-
fetch(backend?: BackendInterface): Promise<QueryResultType<DataObjectClass<any>>>;
|
|
53
|
-
fetchAsUri(backend?: BackendInterface): Promise<QueryResultType<ObjectUri>>;
|
|
54
|
-
fetchAsInstances(backend?: BackendInterface): Promise<QueryResultType<T>>;
|
|
55
|
-
execute(as?: returnAs, backend?: BackendInterface): Promise<QueryResultType<any>>;
|
|
56
|
-
}
|
package/lib/backends/Query.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Query = exports.returnAs = exports.AS_INSTANCES = exports.AS_DATAOBJECTS = exports.AS_OBJECTURIS = void 0;
|
|
13
|
-
const Filter_1 = require("./Filter");
|
|
14
|
-
const Limits_1 = require("./Limits");
|
|
15
|
-
const Sorting_1 = require("./Sorting");
|
|
16
|
-
const SortAndLimit_1 = require("./SortAndLimit");
|
|
17
|
-
const Core_1 = require("../Core");
|
|
18
|
-
exports.AS_OBJECTURIS = 'objectUris';
|
|
19
|
-
exports.AS_DATAOBJECTS = 'dataObjects';
|
|
20
|
-
exports.AS_INSTANCES = 'classInstances';
|
|
21
|
-
var returnAs;
|
|
22
|
-
(function (returnAs) {
|
|
23
|
-
returnAs["AS_OBJECTURIS"] = "objectUris";
|
|
24
|
-
returnAs["AS_DATAOBJECTS"] = "dataObjects";
|
|
25
|
-
returnAs["AS_INSTANCES"] = "classInstances";
|
|
26
|
-
returnAs["AS_IS"] = "asIs";
|
|
27
|
-
})(returnAs || (exports.returnAs = returnAs = {}));
|
|
28
|
-
class Query {
|
|
29
|
-
constructor(obj, parent) {
|
|
30
|
-
this._obj = obj;
|
|
31
|
-
this._parent = parent;
|
|
32
|
-
this.filters = [];
|
|
33
|
-
this.sortings = [];
|
|
34
|
-
this.limits = new Limits_1.Limits();
|
|
35
|
-
this.meta = {};
|
|
36
|
-
}
|
|
37
|
-
get obj() {
|
|
38
|
-
return this._obj;
|
|
39
|
-
}
|
|
40
|
-
get parent() {
|
|
41
|
-
return this._parent;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Declare query parent record
|
|
45
|
-
* This may be need in some NoSQL backend to query subcollections
|
|
46
|
-
*/
|
|
47
|
-
set parent(parent) {
|
|
48
|
-
this._parent = parent;
|
|
49
|
-
}
|
|
50
|
-
where(param, value = null, operator = 'equals') {
|
|
51
|
-
if (typeof param == 'object') {
|
|
52
|
-
this.filters.push(param);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
if (operator === 'equals' && Array.isArray(value)) {
|
|
56
|
-
// auto-convert operator if value is an array
|
|
57
|
-
operator = 'contains';
|
|
58
|
-
}
|
|
59
|
-
this.filters.push(new Filter_1.Filter(param, value, operator));
|
|
60
|
-
}
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
sortBy(param, order = 'asc') {
|
|
64
|
-
if (typeof param == 'object') {
|
|
65
|
-
this.sortings.push(param);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.sortings.push(new Sorting_1.Sorting(param, order));
|
|
69
|
-
}
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
setLimits(limits) {
|
|
73
|
-
this.limits = limits;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
offset(offset = 0) {
|
|
77
|
-
this.limits.offset = offset;
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
batch(batch = 10) {
|
|
81
|
-
this.limits.batch = batch;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
get sortAndLimit() {
|
|
85
|
-
return new SortAndLimit_1.SortAndLimit(this.sortings, this.limits);
|
|
86
|
-
}
|
|
87
|
-
fetch(backend = Core_1.Core.getBackend()) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
return backend.query(this);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
fetchAsUri(backend = Core_1.Core.getBackend()) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const { items, meta } = yield this.fetch(backend);
|
|
95
|
-
return { items: yield Promise.all(items.map((dao) => dao.uri)), meta };
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
fetchAsInstances(backend = Core_1.Core.getBackend()) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const { items, meta } = yield this.fetch(backend);
|
|
101
|
-
const instances = [];
|
|
102
|
-
for (const item of items) {
|
|
103
|
-
instances.push(this._obj.fromDataObject(item));
|
|
104
|
-
}
|
|
105
|
-
return { items: instances, meta };
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
execute(as = returnAs.AS_DATAOBJECTS, backend = Core_1.Core.getBackend(this._obj.DEFAULT_BACKEND)) {
|
|
109
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
try {
|
|
111
|
-
switch (as) {
|
|
112
|
-
case exports.AS_DATAOBJECTS:
|
|
113
|
-
return yield this.fetch(backend);
|
|
114
|
-
case exports.AS_OBJECTURIS:
|
|
115
|
-
return yield this.fetchAsUri(backend);
|
|
116
|
-
case exports.AS_INSTANCES:
|
|
117
|
-
return yield this.fetchAsInstances(backend);
|
|
118
|
-
default:
|
|
119
|
-
throw new Error(`Unknown output mode`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
console.log(err);
|
|
124
|
-
throw err;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.Query = Query;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Limits } from './Limits';
|
|
2
|
-
import { Sorting } from './Sorting';
|
|
3
|
-
export interface SortAndLimitType {
|
|
4
|
-
sortings: Sorting[];
|
|
5
|
-
limits: Limits;
|
|
6
|
-
}
|
|
7
|
-
export declare class SortAndLimit implements SortAndLimitType {
|
|
8
|
-
sortings: Sorting[];
|
|
9
|
-
limits: Limits;
|
|
10
|
-
constructor(sortings?: Sorting[], limits?: Limits | undefined);
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SortAndLimit = void 0;
|
|
4
|
-
const Limits_1 = require("./Limits");
|
|
5
|
-
class SortAndLimit {
|
|
6
|
-
constructor(sortings = [], limits = undefined) {
|
|
7
|
-
this.sortings = sortings;
|
|
8
|
-
this.limits = limits || new Limits_1.Limits();
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.SortAndLimit = SortAndLimit;
|
package/lib/backends/Sorting.js
DELETED
package/lib/backends/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbstractAdapter } from './AbstractAdapter';
|
|
2
|
-
import { MockAdapter } from './MockAdapter';
|
|
3
|
-
import { BackendError } from './BackendError';
|
|
4
|
-
import { BackendInterface } from './types/BackendInterface';
|
|
5
|
-
import * as CollectionHierarchy from './types/CollectionHierarchy';
|
|
6
|
-
import { Query, QueryResultType, QueryMetaType } from './Query';
|
|
7
|
-
import { Filter } from './Filter';
|
|
8
|
-
import { Filters } from './Filters';
|
|
9
|
-
import { Sorting } from './Sorting';
|
|
10
|
-
import { Limits } from './Limits';
|
|
11
|
-
import { SortAndLimit } from './SortAndLimit';
|
|
12
|
-
export { BackendInterface, AbstractAdapter, BackendError, MockAdapter, Query, QueryResultType, QueryMetaType, Filter, Filters, Sorting, Limits, SortAndLimit, CollectionHierarchy, };
|
package/lib/backends/index.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CollectionHierarchy = exports.SortAndLimit = exports.Limits = exports.Sorting = exports.Filters = exports.Filter = exports.Query = exports.MockAdapter = exports.BackendError = exports.AbstractAdapter = void 0;
|
|
27
|
-
const AbstractAdapter_1 = require("./AbstractAdapter");
|
|
28
|
-
Object.defineProperty(exports, "AbstractAdapter", { enumerable: true, get: function () { return AbstractAdapter_1.AbstractAdapter; } });
|
|
29
|
-
const MockAdapter_1 = require("./MockAdapter");
|
|
30
|
-
Object.defineProperty(exports, "MockAdapter", { enumerable: true, get: function () { return MockAdapter_1.MockAdapter; } });
|
|
31
|
-
const BackendError_1 = require("./BackendError");
|
|
32
|
-
Object.defineProperty(exports, "BackendError", { enumerable: true, get: function () { return BackendError_1.BackendError; } });
|
|
33
|
-
const CollectionHierarchy = __importStar(require("./types/CollectionHierarchy"));
|
|
34
|
-
exports.CollectionHierarchy = CollectionHierarchy;
|
|
35
|
-
const Query_1 = require("./Query");
|
|
36
|
-
Object.defineProperty(exports, "Query", { enumerable: true, get: function () { return Query_1.Query; } });
|
|
37
|
-
const Filter_1 = require("./Filter");
|
|
38
|
-
Object.defineProperty(exports, "Filter", { enumerable: true, get: function () { return Filter_1.Filter; } });
|
|
39
|
-
const Filters_1 = require("./Filters");
|
|
40
|
-
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return Filters_1.Filters; } });
|
|
41
|
-
const Sorting_1 = require("./Sorting");
|
|
42
|
-
Object.defineProperty(exports, "Sorting", { enumerable: true, get: function () { return Sorting_1.Sorting; } });
|
|
43
|
-
const Limits_1 = require("./Limits");
|
|
44
|
-
Object.defineProperty(exports, "Limits", { enumerable: true, get: function () { return Limits_1.Limits; } });
|
|
45
|
-
const SortAndLimit_1 = require("./SortAndLimit");
|
|
46
|
-
Object.defineProperty(exports, "SortAndLimit", { enumerable: true, get: function () { return SortAndLimit_1.SortAndLimit; } });
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DataObjectClass } from '../../components';
|
|
2
|
-
import { BackendAction } from '../../Backend';
|
|
3
|
-
import BackendMiddleware from './Middleware';
|
|
4
|
-
export interface InjectKeywordsMiddlewareParams {
|
|
5
|
-
}
|
|
6
|
-
export declare class InjectKeywordsMiddleware implements BackendMiddleware {
|
|
7
|
-
execute(dataObject: DataObjectClass<any>, action: BackendAction): void;
|
|
8
|
-
protected _createKeywords(dataObject: DataObjectClass<any>): string[];
|
|
9
|
-
}
|