@cubicweb/client 1.0.3 → 1.0.4
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/Errors.d.ts +10 -0
- package/lib/Errors.d.ts.map +1 -0
- package/lib/Errors.js +25 -0
- package/lib/Errors.js.map +1 -0
- package/lib/api/Api.d.ts +27 -0
- package/lib/api/Api.d.ts.map +1 -0
- package/lib/api/Api.js +94 -0
- package/lib/api/Api.js.map +1 -0
- package/lib/api/Client.d.ts +11 -0
- package/lib/api/Client.d.ts.map +1 -0
- package/lib/api/Client.js +46 -0
- package/lib/api/Client.js.map +1 -0
- package/lib/api/Transaction.d.ts +15 -0
- package/lib/api/Transaction.d.ts.map +1 -0
- package/lib/api/Transaction.js +60 -0
- package/lib/api/Transaction.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +34 -0
- package/lib/index.js.map +1 -0
- package/lib/schema/Schema.d.ts +169 -0
- package/lib/schema/Schema.d.ts.map +1 -0
- package/lib/schema/Schema.js +269 -0
- package/lib/schema/Schema.js.map +1 -0
- package/lib/schema/SchemaJSON.d.ts +121 -0
- package/lib/schema/SchemaJSON.d.ts.map +1 -0
- package/lib/schema/SchemaJSON.js +3 -0
- package/lib/schema/SchemaJSON.js.map +1 -0
- package/package.json +1 -1
package/lib/Errors.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class InconsistentSchemaError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class RelationNotFoundError extends Error {
|
|
5
|
+
constructor(relationType: string, role: "object" | "subject", entityType: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class TransactionClosedError extends Error {
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAE5C,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,UAAU,EAAE,MAAM;CAOrB;AAED,qBAAa,sBAAuB,SAAQ,KAAK;;CAKhD"}
|
package/lib/Errors.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionClosedError = exports.RelationNotFoundError = exports.InconsistentSchemaError = void 0;
|
|
4
|
+
class InconsistentSchemaError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(`Inconsistent schema: ${message}`);
|
|
7
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.InconsistentSchemaError = InconsistentSchemaError;
|
|
11
|
+
class RelationNotFoundError extends Error {
|
|
12
|
+
constructor(relationType, role, entityType) {
|
|
13
|
+
super(`Relation Not Found: relation type ${relationType} with entity type ${entityType} as ${role} is not declared`);
|
|
14
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.RelationNotFoundError = RelationNotFoundError;
|
|
18
|
+
class TransactionClosedError extends Error {
|
|
19
|
+
constructor() {
|
|
20
|
+
super("Trying to use a closed transaction");
|
|
21
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.TransactionClosedError = TransactionClosedError;
|
|
25
|
+
//# sourceMappingURL=Errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AALD,0DAKC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,YACE,YAAoB,EACpB,IAA0B,EAC1B,UAAkB;QAElB,KAAK,CACH,qCAAqC,YAAY,qBAAqB,UAAU,OAAO,IAAI,kBAAkB,CAC9G,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAXD,sDAWC;AAED,MAAa,sBAAuB,SAAQ,KAAK;IAC/C;QACE,KAAK,CAAC,oCAAoC,CAAC,CAAC;QAC5C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AALD,wDAKC"}
|
package/lib/api/Api.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RawSchema } from "../schema/SchemaJSON";
|
|
2
|
+
export declare type RQLQuery = [string, RQLParams];
|
|
3
|
+
export interface RQLParams {
|
|
4
|
+
[key: string]: string | number;
|
|
5
|
+
}
|
|
6
|
+
export declare type RqlRow = Array<string | number | boolean | null>;
|
|
7
|
+
export declare type ResultSet = Array<RqlRow>;
|
|
8
|
+
export declare type ApiError = {
|
|
9
|
+
error: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type ApiErrorResponse = {
|
|
13
|
+
status: number;
|
|
14
|
+
} & ApiError;
|
|
15
|
+
export default class Api {
|
|
16
|
+
private apiUrl;
|
|
17
|
+
private transactionApiUrl;
|
|
18
|
+
constructor(apiUrl: string);
|
|
19
|
+
execute(query: string, params: RQLParams): Promise<ResultSet>;
|
|
20
|
+
schema(): Promise<RawSchema>;
|
|
21
|
+
transactionBegin(): Promise<Response>;
|
|
22
|
+
transactionExecute(uuid: string, query: string, params: RQLParams): Promise<ResultSet>;
|
|
23
|
+
transactionCommit(uuid: string): Promise<Response>;
|
|
24
|
+
transactionRollback(uuid: string): Promise<Response>;
|
|
25
|
+
}
|
|
26
|
+
export declare const fetchApi: (input: RequestInfo, init?: RequestInit | undefined) => Promise<ResultSet>;
|
|
27
|
+
//# sourceMappingURL=Api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,oBAAY,QAAQ,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,oBAAY,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;AAC7D,oBAAY,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACtC,oBAAY,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1D,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,QAAQ,CAAC;AAEb,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,MAAM,EAAE,MAAM;IAKpB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IAQxC,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC;IAM5B,gBAAgB;IAShB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IASjE,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAS9B,mBAAmB,CAAC,IAAI,EAAE,MAAM;CAQvC;AAED,eAAO,MAAM,QAAQ,UAAW,WAAW,uDAqB1C,CAAC"}
|
package/lib/api/Api.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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.fetchApi = void 0;
|
|
13
|
+
class Api {
|
|
14
|
+
constructor(apiUrl) {
|
|
15
|
+
this.apiUrl = `${apiUrl}/v1`;
|
|
16
|
+
this.transactionApiUrl = `${this.apiUrl}/transaction`;
|
|
17
|
+
}
|
|
18
|
+
execute(query, params) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
return (0, exports.fetchApi)(`${this.apiUrl}/rql`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
body: JSON.stringify({ query, params }),
|
|
23
|
+
credentials: "include", // FIXME is it secure?
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
schema() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const res = yield fetch(`${this.apiUrl}/schema`);
|
|
30
|
+
const schema = yield res.json();
|
|
31
|
+
return schema;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
transactionBegin() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const body = JSON.stringify({ action: "begin" });
|
|
37
|
+
return yield fetch(this.transactionApiUrl, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body,
|
|
40
|
+
credentials: "include",
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
transactionExecute(uuid, query, params) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const body = JSON.stringify({ action: "execute", uuid, query, params });
|
|
47
|
+
return (0, exports.fetchApi)(this.transactionApiUrl, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
body,
|
|
50
|
+
credentials: "include",
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
transactionCommit(uuid) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const body = JSON.stringify({ action: "commit", uuid });
|
|
57
|
+
return yield fetch(this.transactionApiUrl, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
body,
|
|
60
|
+
credentials: "include",
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
transactionRollback(uuid) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const body = JSON.stringify({ action: "commit", uuid });
|
|
67
|
+
return yield fetch(this.transactionApiUrl, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
body,
|
|
70
|
+
credentials: "include",
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = Api;
|
|
76
|
+
const fetchApi = (input, init) => {
|
|
77
|
+
return new Promise((resolve, reject) => fetch(input, init).then((response) => {
|
|
78
|
+
const status = response.status;
|
|
79
|
+
if (status === 200) {
|
|
80
|
+
response.json().then(resolve);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
response.json().then((data) => {
|
|
84
|
+
reject({
|
|
85
|
+
status,
|
|
86
|
+
error: data.error,
|
|
87
|
+
message: data.message,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
exports.fetchApi = fetchApi;
|
|
94
|
+
//# sourceMappingURL=Api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Api.js","sourceRoot":"","sources":["../../src/api/Api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAeA,MAAqB,GAAG;IAItB,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,GAAG,IAAI,CAAC,MAAM,cAAc,CAAC;IACxD,CAAC;IAEK,OAAO,CAAC,KAAa,EAAE,MAAiB;;YAC5C,OAAO,IAAA,gBAAQ,EAAC,GAAG,IAAI,CAAC,MAAM,MAAM,EAAE;gBACpC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;gBACvC,WAAW,EAAE,SAAS,EAAE,sBAAsB;aAC/C,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,MAAM;;YACV,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,SAAS,CAAC,CAAC;YACjD,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAChC,OAAO,MAAmB,CAAC;QAC7B,CAAC;KAAA;IAEK,gBAAgB;;YACpB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YACjD,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE;gBACzC,MAAM,EAAE,MAAM;gBACd,IAAI;gBACJ,WAAW,EAAE,SA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AC/B,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC/B;aAAM;YACL,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,IAAc,EAAE,EAAE;gBACtC,MAAM,CAAC;oBACL,MAAM;oBACN,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CACL,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,QAAQ,YAqBnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "../schema/Schema";
|
|
2
|
+
import { RQLParams } from "./Api";
|
|
3
|
+
import Transaction from "./Transaction";
|
|
4
|
+
export default class Client {
|
|
5
|
+
private api;
|
|
6
|
+
constructor(apiUrl: string);
|
|
7
|
+
execute(query: string, params?: RQLParams): Promise<import("./Api").ResultSet>;
|
|
8
|
+
schema(): Promise<Schema>;
|
|
9
|
+
transaction<T>(callback: (tr: Transaction) => Promise<T>): Promise<T>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,OAAO,CAAC,GAAG,CAAM;gBAEL,MAAM,EAAE,MAAM;IAIpB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,SAAc;IAI7C,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzB,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAS5E"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const Schema_1 = require("../schema/Schema");
|
|
16
|
+
const Api_1 = __importDefault(require("./Api"));
|
|
17
|
+
const Transaction_1 = __importDefault(require("./Transaction"));
|
|
18
|
+
class Client {
|
|
19
|
+
constructor(apiUrl) {
|
|
20
|
+
this.api = new Api_1.default(apiUrl);
|
|
21
|
+
}
|
|
22
|
+
execute(query, params = {}) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return yield this.api.execute(query, params);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
schema() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const schema = yield this.api.schema();
|
|
30
|
+
return new Schema_1.Schema(schema);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
transaction(callback) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const transaction = new Transaction_1.default(this.api);
|
|
36
|
+
yield transaction.begin();
|
|
37
|
+
const result = yield callback(transaction);
|
|
38
|
+
if (!transaction.isClosed()) {
|
|
39
|
+
transaction.commit();
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = Client;
|
|
46
|
+
//# sourceMappingURL=Client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../src/api/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6CAA0C;AAC1C,gDAAuC;AACvC,gEAAwC;AAExC,MAAqB,MAAM;IAGzB,YAAY,MAAc;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,aAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEK,OAAO,CAAC,KAAa,EAAE,SAAoB,EAAE;;YACjD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC;KAAA;IAEK,MAAM;;YACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YACvC,OAAO,IAAI,eAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;KAAA;IAEK,WAAW,CAAI,QAAyC;;YAC5D,MAAM,WAAW,GAAG,IAAI,qBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC9C,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC3C,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;gBAC3B,WAAW,CAAC,MAAM,EAAE,CAAC;aACtB;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AAzBD,yBAyBC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Api, { RQLParams } from "./Api";
|
|
2
|
+
export default class Transaction {
|
|
3
|
+
private api;
|
|
4
|
+
private _uuid;
|
|
5
|
+
private _closed;
|
|
6
|
+
constructor(api: Api);
|
|
7
|
+
isClosed(): boolean;
|
|
8
|
+
get uuid(): string | null;
|
|
9
|
+
begin(): Promise<void>;
|
|
10
|
+
execute(query: string, params?: RQLParams): Promise<import("./Api").ResultSet>;
|
|
11
|
+
commit(): Promise<void>;
|
|
12
|
+
rollback(): Promise<void>;
|
|
13
|
+
private preventUsageIfClosed;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,WAAW;IAIlB,OAAO,CAAC,GAAG;IAHvB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAAS;gBAEJ,GAAG,EAAE,GAAG;IAE5B,QAAQ;IAIR,IAAI,IAAI,kBAEP;IAEK,KAAK;IAOL,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,SAAc;IAK7C,MAAM;IAMN,QAAQ;IAMd,OAAO,CAAC,oBAAoB;CAK7B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
const Errors_1 = require("../Errors");
|
|
13
|
+
class Transaction {
|
|
14
|
+
constructor(api) {
|
|
15
|
+
this.api = api;
|
|
16
|
+
this._uuid = null;
|
|
17
|
+
this._closed = false;
|
|
18
|
+
}
|
|
19
|
+
isClosed() {
|
|
20
|
+
return this._closed;
|
|
21
|
+
}
|
|
22
|
+
get uuid() {
|
|
23
|
+
return this._uuid;
|
|
24
|
+
}
|
|
25
|
+
begin() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
this._closed = false;
|
|
28
|
+
const response = yield this.api.transactionBegin();
|
|
29
|
+
const json = yield response.json();
|
|
30
|
+
this._uuid = json;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
execute(query, params = {}) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
this.preventUsageIfClosed();
|
|
36
|
+
return yield this.api.transactionExecute(this.uuid, query, params);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
commit() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
this.preventUsageIfClosed();
|
|
42
|
+
yield this.api.transactionCommit(this.uuid);
|
|
43
|
+
this._closed = true;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
rollback() {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
this.preventUsageIfClosed();
|
|
49
|
+
yield this.api.transactionRollback(this.uuid);
|
|
50
|
+
this._closed = true;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
preventUsageIfClosed() {
|
|
54
|
+
if (this.isClosed()) {
|
|
55
|
+
throw new Errors_1.TransactionClosedError();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = Transaction;
|
|
60
|
+
//# sourceMappingURL=Transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/api/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAmD;AAGnD,MAAqB,WAAW;IAI9B,YAAoB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;QAHpB,UAAK,GAAkB,IAAI,CAAC;QAC5B,YAAO,GAAG,KAAK,CAAC;IAEO,CAAC;IAEhC,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEK,KAAK;;YACT,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YACnD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;KAAA;IAEK,OAAO,CAAC,KAAa,EAAE,SAAoB,EAAE;;YACjD,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;QACrE,CAAC;KAAA;IAEK,MAAM;;YACV,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;KAAA;IAEK,QAAQ;;YACZ,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;KAAA;IAEO,oBAAoB;QAC1B,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE;YACnB,MAAM,IAAI,+BAAsB,EAAE,CAAC;SACpC;IACH,CAAC;CACF;AA3CD,8BA2CC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { getLooseSchema, Schema, EntitySchema, RelationDefinitionSchema, } from "./schema/Schema";
|
|
2
|
+
export * from "./schema/SchemaJSON";
|
|
3
|
+
export * from "./Errors";
|
|
4
|
+
export { default as Client } from "./api/Client";
|
|
5
|
+
export { default as Api } from "./api/Api";
|
|
6
|
+
export { default as Transaction } from "./api/Transaction";
|
|
7
|
+
export { RQLQuery, RQLParams, RqlRow, ResultSet, ApiErrorResponse, } from "./api/Api";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,MAAM,EACN,YAAY,EACZ,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,gBAAgB,GACjB,MAAM,WAAW,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Transaction = exports.Api = exports.Client = exports.RelationDefinitionSchema = exports.EntitySchema = exports.Schema = exports.getLooseSchema = void 0;
|
|
21
|
+
var Schema_1 = require("./schema/Schema");
|
|
22
|
+
Object.defineProperty(exports, "getLooseSchema", { enumerable: true, get: function () { return Schema_1.getLooseSchema; } });
|
|
23
|
+
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return Schema_1.Schema; } });
|
|
24
|
+
Object.defineProperty(exports, "EntitySchema", { enumerable: true, get: function () { return Schema_1.EntitySchema; } });
|
|
25
|
+
Object.defineProperty(exports, "RelationDefinitionSchema", { enumerable: true, get: function () { return Schema_1.RelationDefinitionSchema; } });
|
|
26
|
+
__exportStar(require("./schema/SchemaJSON"), exports);
|
|
27
|
+
__exportStar(require("./Errors"), exports);
|
|
28
|
+
var Client_1 = require("./api/Client");
|
|
29
|
+
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return __importDefault(Client_1).default; } });
|
|
30
|
+
var Api_1 = require("./api/Api");
|
|
31
|
+
Object.defineProperty(exports, "Api", { enumerable: true, get: function () { return __importDefault(Api_1).default; } });
|
|
32
|
+
var Transaction_1 = require("./api/Transaction");
|
|
33
|
+
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return __importDefault(Transaction_1).default; } });
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AAJvB,wGAAA,cAAc,OAAA;AACd,gGAAA,MAAM,OAAA;AACN,sGAAA,YAAY,OAAA;AACZ,kHAAA,wBAAwB,OAAA;AAE1B,sDAAoC;AACpC,2CAAyB;AACzB,uCAAiD;AAAxC,iHAAA,OAAO,OAAU;AAC1B,iCAA2C;AAAlC,2GAAA,OAAO,OAAO;AACvB,iDAA2D;AAAlD,2HAAA,OAAO,OAAe"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Cardinality } from "..";
|
|
2
|
+
import { RawSchema, RelationDefinitionRawSchema, RelationDefinitionRawSchemaArray, EntityRawSchemaArray, EntityRawSchemaByType, IsLooseSchema, IsETypeInStrictSchema } from "./SchemaJSON";
|
|
3
|
+
declare const rawSchemaKey: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the given schema using loose typing.
|
|
6
|
+
* Can be useful when working for generic schemas
|
|
7
|
+
*
|
|
8
|
+
* @param schema The schema to create a loose type for
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const getLooseSchema: <E extends EntityRawSchemaArray = EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<E> = RelationDefinitionRawSchemaArray<E>>(schema: Schema<E, R>) => Schema<EntityRawSchemaArray, RelationDefinitionRawSchemaArray<EntityRawSchemaArray>>;
|
|
12
|
+
/**
|
|
13
|
+
* Wrapper around the raw JSON Schema
|
|
14
|
+
*/
|
|
15
|
+
export declare class Schema<E extends EntityRawSchemaArray = EntityRawSchemaArray, // List of all entities
|
|
16
|
+
R extends RelationDefinitionRawSchemaArray<E> = RelationDefinitionRawSchemaArray<E>> {
|
|
17
|
+
[rawSchemaKey]: RawSchema<E, R>;
|
|
18
|
+
constructor(rawSchema: RawSchema<E, R>);
|
|
19
|
+
get entities(): EntitySchema<E, R, E[number]>[];
|
|
20
|
+
get relationsDefinitions(): RelationDefinitionSchema<E, R, R[number]>[];
|
|
21
|
+
/**
|
|
22
|
+
* Returns the entity schema for the given entity type if it exists.
|
|
23
|
+
* When using TypeScript, this method can detect if the given type does not exist
|
|
24
|
+
* in the schema.
|
|
25
|
+
*
|
|
26
|
+
* @param entityType The entity type string
|
|
27
|
+
* @returns A new EntitySchema or null if the type does not exist
|
|
28
|
+
*/
|
|
29
|
+
getEntity<EType extends string>(entityType: EType): IsLooseSchema<E> extends true ? EntitySchema<E, R, E[number]> | null : IsETypeInStrictSchema<E, EType> extends true ? EntitySchema<E, R, EntityRawSchemaByType<E, EType>> : null;
|
|
30
|
+
/**
|
|
31
|
+
* Finds relations in the Schema matching the partial relation given
|
|
32
|
+
*
|
|
33
|
+
* @param matcher Partial relation definition to match against
|
|
34
|
+
* @returns Matched relation schema classes
|
|
35
|
+
*/
|
|
36
|
+
matchRelationDefinitions<M extends RelationDefinitionMatcher<E>>(matcher: M): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
37
|
+
subject: E[number]["type"];
|
|
38
|
+
}>>[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Wrapper around raw entities from the Schema
|
|
42
|
+
*/
|
|
43
|
+
export declare class EntitySchema<E extends EntityRawSchemaArray = EntityRawSchemaArray, // List of all entities
|
|
44
|
+
R extends RelationDefinitionRawSchemaArray<E> = RelationDefinitionRawSchemaArray<E>, // List of all relation defintions
|
|
45
|
+
ERawSchema extends E[number] = E[number]> {
|
|
46
|
+
private schema;
|
|
47
|
+
private entityRawSchema;
|
|
48
|
+
constructor(schema: Schema<E, R>, entityRawSchema: ERawSchema);
|
|
49
|
+
/**
|
|
50
|
+
* The type of the entity. This can also be referred to as the entity' name.
|
|
51
|
+
*/
|
|
52
|
+
get type(): ERawSchema["type"];
|
|
53
|
+
/**
|
|
54
|
+
* A short description which can be used as documentation for the entity.
|
|
55
|
+
*/
|
|
56
|
+
get description(): ERawSchema["description"];
|
|
57
|
+
/**
|
|
58
|
+
* True if the current entity is a primitive type such as string or int
|
|
59
|
+
*/
|
|
60
|
+
get final(): ERawSchema["final"];
|
|
61
|
+
/**
|
|
62
|
+
* Gets the list of relation definitions with this entity as subject
|
|
63
|
+
*/
|
|
64
|
+
get subjectRelationDefinitions(): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
65
|
+
subject: ERawSchema["type"];
|
|
66
|
+
}>>[];
|
|
67
|
+
/**
|
|
68
|
+
* Gets the list of relation definitions with this entity as object
|
|
69
|
+
*/
|
|
70
|
+
get objectRelationsDefinitions(): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
71
|
+
object: ERawSchema["type"];
|
|
72
|
+
}>>[];
|
|
73
|
+
/**
|
|
74
|
+
* Finds the first relation of the given type with this entity as subject
|
|
75
|
+
*
|
|
76
|
+
* @param relationType The relation type to find
|
|
77
|
+
* @throws RelationNotFoundError if the current entity is not a subject of the given relation
|
|
78
|
+
* @returns The found relation
|
|
79
|
+
*/
|
|
80
|
+
getSubjectRelationDefinition<RelationType extends MatchedRelationDefinition<E, R, {
|
|
81
|
+
subject: ERawSchema["type"];
|
|
82
|
+
}>["type"]>(relationType: RelationType): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
83
|
+
subject: ERawSchema["type"];
|
|
84
|
+
type: RelationType;
|
|
85
|
+
}>>;
|
|
86
|
+
/**
|
|
87
|
+
* Finds the first relation of the given type with this entity as object
|
|
88
|
+
*
|
|
89
|
+
* @param relationType The relation type to find
|
|
90
|
+
* @throws RelationNotFoundError if the current entity is not an object of the given relation
|
|
91
|
+
* @returns The found relation
|
|
92
|
+
*/
|
|
93
|
+
getObjectRelationDefinition<RelationType extends MatchedRelationDefinition<E, R, {
|
|
94
|
+
object: ERawSchema["type"];
|
|
95
|
+
}>["type"]>(relationType: RelationType): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, {
|
|
96
|
+
object: ERawSchema["type"];
|
|
97
|
+
type: RelationType;
|
|
98
|
+
}>>;
|
|
99
|
+
/**
|
|
100
|
+
* Gets the list of attributes names for this entity
|
|
101
|
+
*/
|
|
102
|
+
get attributes(): RelationDefinitionSchema<E, R, R[number]>[];
|
|
103
|
+
/**
|
|
104
|
+
* Checks whether the current entity is required for the given relation and role
|
|
105
|
+
*
|
|
106
|
+
* @param relationType The relation to check
|
|
107
|
+
* @param role The role for this entity in the given relation
|
|
108
|
+
* @returns True if this entity is required in the relation for the given role
|
|
109
|
+
*/
|
|
110
|
+
isRelationRequired<RelationType extends MatchedRelationDefinition<E, R, {
|
|
111
|
+
subject: ERawSchema["type"];
|
|
112
|
+
} | {
|
|
113
|
+
object: ERawSchema["type"];
|
|
114
|
+
}>["type"]>(relationType: RelationType, role: "subject" | "object"): boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Wrapper around raw relation definitions from the Schema
|
|
118
|
+
*/
|
|
119
|
+
export declare class RelationDefinitionSchema<E extends EntityRawSchemaArray = EntityRawSchemaArray, // List of all entities
|
|
120
|
+
R extends RelationDefinitionRawSchemaArray<E> = RelationDefinitionRawSchemaArray<E>, // List of all relation defintions
|
|
121
|
+
RDef extends R[number] = R[number]> {
|
|
122
|
+
private schema;
|
|
123
|
+
private relDef;
|
|
124
|
+
constructor(schema: Schema<E, R>, relDef: RDef);
|
|
125
|
+
/**
|
|
126
|
+
* The type of the relation. This can also be referred to as the relation's name.
|
|
127
|
+
*/
|
|
128
|
+
get type(): RDef["type"];
|
|
129
|
+
/**
|
|
130
|
+
* A short description which can be used as documentation for the relation.
|
|
131
|
+
*/
|
|
132
|
+
get description(): RDef["description"];
|
|
133
|
+
/**
|
|
134
|
+
* True if the object of the relation is a primitive type.
|
|
135
|
+
* In this case the relation iscalled an "attribute"
|
|
136
|
+
*/
|
|
137
|
+
get final(): RDef["final"];
|
|
138
|
+
/**
|
|
139
|
+
* The list of constraints if any. Only attributes (relations with final = true) have constraints.
|
|
140
|
+
* In other cases this returns null.
|
|
141
|
+
*/
|
|
142
|
+
get constraints(): RDef["constraints"];
|
|
143
|
+
/**
|
|
144
|
+
* The default value for this relation.
|
|
145
|
+
* It can be used when creating new relations if user did not enter a value (even if required).
|
|
146
|
+
*/
|
|
147
|
+
get default(): RDef extends {
|
|
148
|
+
default: infer V;
|
|
149
|
+
} ? V : undefined;
|
|
150
|
+
get cardinality(): RDef["cardinality"];
|
|
151
|
+
get subjectCardinality(): Cardinality;
|
|
152
|
+
get objectCardinality(): Cardinality;
|
|
153
|
+
/**
|
|
154
|
+
* Gets the entity associated to this relation's subject
|
|
155
|
+
*
|
|
156
|
+
* @throws InconsistentSchemaError if the relation's subject is not a valid entity
|
|
157
|
+
*/
|
|
158
|
+
get subject(): IsLooseSchema<E> extends true ? EntitySchema<E, R, E[number]> : EntitySchema<E, R, EntityRawSchemaByType<E, RDef["subject"]>>;
|
|
159
|
+
/**
|
|
160
|
+
* Gets the entity associated to this relation's object
|
|
161
|
+
*
|
|
162
|
+
* @throws InconsistentSchemaError if the relation's object is not a valid entity
|
|
163
|
+
*/
|
|
164
|
+
get object(): IsLooseSchema<E> extends true ? EntitySchema<E, R, E[number]> : EntitySchema<E, R, EntityRawSchemaByType<E, RDef["object"]>>;
|
|
165
|
+
}
|
|
166
|
+
export declare type RelationDefinitionMatcher<E extends EntityRawSchemaArray> = Partial<RelationDefinitionRawSchema<E>>;
|
|
167
|
+
export declare type MatchedRelationDefinition<E extends EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<EntityRawSchemaArray>, M extends RelationDefinitionMatcher<E>> = R[number] extends infer RDef ? (RDef extends M ? RDef : never) : never;
|
|
168
|
+
export {};
|
|
169
|
+
//# sourceMappingURL=Schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/schema/Schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAEjC,OAAO,EACL,SAAS,EACT,2BAA2B,EAC3B,gCAAgC,EAChC,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,QAAA,MAAM,YAAY,EAAE,OAAO,MAA2C,CAAC;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,4PAU1B,CAAC;AAEF;;GAEG;AACH,qBAAa,MAAM,CACjB,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,EAAE,uBAAuB;AAC9E,CAAC,SAAS,gCAAgC,CAAC,CAAC,CAAC,GAAG,gCAAgC,CAAC,CAAC,CAAC;IAEnF,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAEpB,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAItC,IAAI,QAAQ,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAI9C;IAED,IAAI,oBAAoB,IAAI,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAItE;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,SAAS,MAAM,EAC5B,UAAU,EAAE,KAAK,GAChB,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GAC5B,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,C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AAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAUhE;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GACvC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAC7B,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAU/D;CACF;AAYD,oBAAY,yBAAyB,CAAC,CAAC,SAAS,oBAAoB,IAAI,OAAO,CAC7E,2BAA2B,CAAC,CAAC,CAAC,CAC/B,CAAC;AAEF,oBAAY,yBAAyB,CACnC,CAAC,SAAS,oBAAoB,EAC9B,CAAC,SAAS,gCAAgC,CAAC,oBAAoB,CAAC,EAChE,CAAC,SAAS,yBAAyB,CAAC,CAAC,CAAC,IACpC,CAAC,CAAC,MAAM,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelationDefinitionSchema = exports.EntitySchema = exports.Schema = exports.getLooseSchema = void 0;
|
|
4
|
+
const Errors_1 = require("../Errors");
|
|
5
|
+
const rawSchemaKey = Symbol("Indexer of the rawSchema");
|
|
6
|
+
/**
|
|
7
|
+
* Returns the given schema using loose typing.
|
|
8
|
+
* Can be useful when working for generic schemas
|
|
9
|
+
*
|
|
10
|
+
* @param schema The schema to create a loose type for
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
const getLooseSchema = (schema) => {
|
|
14
|
+
return schema;
|
|
15
|
+
};
|
|
16
|
+
exports.getLooseSchema = getLooseSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Wrapper around the raw JSON Schema
|
|
19
|
+
*/
|
|
20
|
+
class Schema {
|
|
21
|
+
constructor(rawSchema) {
|
|
22
|
+
this[rawSchemaKey] = rawSchema;
|
|
23
|
+
}
|
|
24
|
+
get entities() {
|
|
25
|
+
return this[rawSchemaKey].entities.map((eSchema) => new EntitySchema(this, eSchema));
|
|
26
|
+
}
|
|
27
|
+
get relationsDefinitions() {
|
|
28
|
+
return this[rawSchemaKey].relations_definitions.map((rdefSchema) => new RelationDefinitionSchema(this, rdefSchema));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the entity schema for the given entity type if it exists.
|
|
32
|
+
* When using TypeScript, this method can detect if the given type does not exist
|
|
33
|
+
* in the schema.
|
|
34
|
+
*
|
|
35
|
+
* @param entityType The entity type string
|
|
36
|
+
* @returns A new EntitySchema or null if the type does not exist
|
|
37
|
+
*/
|
|
38
|
+
getEntity(entityType) {
|
|
39
|
+
const entityRawSchema = this[rawSchemaKey].entities.filter((eSchema) => eSchema.type === entityType)[0];
|
|
40
|
+
if (!entityRawSchema) {
|
|
41
|
+
// Is only null when the given type is not in the schema.
|
|
42
|
+
// Thus the return type will be (EntitySchema | null)
|
|
43
|
+
// but TypeScript does not understand this
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
return new EntitySchema(this, entityRawSchema);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Finds relations in the Schema matching the partial relation given
|
|
54
|
+
*
|
|
55
|
+
* @param matcher Partial relation definition to match against
|
|
56
|
+
* @returns Matched relation schema classes
|
|
57
|
+
*/
|
|
58
|
+
matchRelationDefinitions(matcher) {
|
|
59
|
+
const matchArray = this[rawSchemaKey].relations_definitions.filter((relDef) => {
|
|
60
|
+
for (const key of Object.keys(matcher)) {
|
|
61
|
+
if (matcher[key] !== relDef[key]) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
return matchArray.map((m) => new RelationDefinitionSchema(this, m));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.Schema = Schema;
|
|
71
|
+
/**
|
|
72
|
+
* Wrapper around raw entities from the Schema
|
|
73
|
+
*/
|
|
74
|
+
class EntitySchema {
|
|
75
|
+
constructor(schema, entityRawSchema) {
|
|
76
|
+
this.schema = schema;
|
|
77
|
+
this.entityRawSchema = entityRawSchema;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The type of the entity. This can also be referred to as the entity' name.
|
|
81
|
+
*/
|
|
82
|
+
get type() {
|
|
83
|
+
return this.entityRawSchema.type;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A short description which can be used as documentation for the entity.
|
|
87
|
+
*/
|
|
88
|
+
get description() {
|
|
89
|
+
return this.entityRawSchema.description;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* True if the current entity is a primitive type such as string or int
|
|
93
|
+
*/
|
|
94
|
+
get final() {
|
|
95
|
+
return this.entityRawSchema.final;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets the list of relation definitions with this entity as subject
|
|
99
|
+
*/
|
|
100
|
+
get subjectRelationDefinitions() {
|
|
101
|
+
return this.schema.matchRelationDefinitions({
|
|
102
|
+
subject: this.type,
|
|
103
|
+
final: false,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets the list of relation definitions with this entity as object
|
|
108
|
+
*/
|
|
109
|
+
get objectRelationsDefinitions() {
|
|
110
|
+
return this.schema.matchRelationDefinitions({
|
|
111
|
+
object: this.type,
|
|
112
|
+
final: false,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Finds the first relation of the given type with this entity as subject
|
|
117
|
+
*
|
|
118
|
+
* @param relationType The relation type to find
|
|
119
|
+
* @throws RelationNotFoundError if the current entity is not a subject of the given relation
|
|
120
|
+
* @returns The found relation
|
|
121
|
+
*/
|
|
122
|
+
getSubjectRelationDefinition(relationType) {
|
|
123
|
+
const resultArray = this.schema.matchRelationDefinitions({
|
|
124
|
+
subject: this.type,
|
|
125
|
+
type: relationType,
|
|
126
|
+
});
|
|
127
|
+
if (resultArray.length > 0) {
|
|
128
|
+
return resultArray[0];
|
|
129
|
+
}
|
|
130
|
+
throw new Errors_1.RelationNotFoundError(relationType, "subject", this.type);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Finds the first relation of the given type with this entity as object
|
|
134
|
+
*
|
|
135
|
+
* @param relationType The relation type to find
|
|
136
|
+
* @throws RelationNotFoundError if the current entity is not an object of the given relation
|
|
137
|
+
* @returns The found relation
|
|
138
|
+
*/
|
|
139
|
+
getObjectRelationDefinition(relationType) {
|
|
140
|
+
const resultArray = this.schema.matchRelationDefinitions({
|
|
141
|
+
object: this.type,
|
|
142
|
+
type: relationType,
|
|
143
|
+
});
|
|
144
|
+
if (resultArray.length > 0) {
|
|
145
|
+
return resultArray[0];
|
|
146
|
+
}
|
|
147
|
+
throw new Errors_1.RelationNotFoundError(relationType, "object", this.type);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Gets the list of attributes names for this entity
|
|
151
|
+
*/
|
|
152
|
+
get attributes() {
|
|
153
|
+
return this.schema.matchRelationDefinitions({
|
|
154
|
+
final: true,
|
|
155
|
+
subject: this.type,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Checks whether the current entity is required for the given relation and role
|
|
160
|
+
*
|
|
161
|
+
* @param relationType The relation to check
|
|
162
|
+
* @param role The role for this entity in the given relation
|
|
163
|
+
* @returns True if this entity is required in the relation for the given role
|
|
164
|
+
*/
|
|
165
|
+
isRelationRequired(relationType, role) {
|
|
166
|
+
let relation;
|
|
167
|
+
let cardinality;
|
|
168
|
+
if (role === "subject") {
|
|
169
|
+
relation = this.getSubjectRelationDefinition(relationType);
|
|
170
|
+
cardinality = relation.cardinality[0];
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
relation = this.getObjectRelationDefinition(relationType);
|
|
174
|
+
cardinality = relation.cardinality[1];
|
|
175
|
+
}
|
|
176
|
+
return cardinalityRequired(cardinality);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.EntitySchema = EntitySchema;
|
|
180
|
+
/**
|
|
181
|
+
* Wrapper around raw relation definitions from the Schema
|
|
182
|
+
*/
|
|
183
|
+
class RelationDefinitionSchema {
|
|
184
|
+
constructor(schema, relDef) {
|
|
185
|
+
this.schema = schema;
|
|
186
|
+
this.relDef = relDef;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The type of the relation. This can also be referred to as the relation's name.
|
|
190
|
+
*/
|
|
191
|
+
get type() {
|
|
192
|
+
return this.relDef.type;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* A short description which can be used as documentation for the relation.
|
|
196
|
+
*/
|
|
197
|
+
get description() {
|
|
198
|
+
return this.relDef.description;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* True if the object of the relation is a primitive type.
|
|
202
|
+
* In this case the relation iscalled an "attribute"
|
|
203
|
+
*/
|
|
204
|
+
get final() {
|
|
205
|
+
return this.relDef.final;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The list of constraints if any. Only attributes (relations with final = true) have constraints.
|
|
209
|
+
* In other cases this returns null.
|
|
210
|
+
*/
|
|
211
|
+
get constraints() {
|
|
212
|
+
return this.relDef.constraints;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The default value for this relation.
|
|
216
|
+
* It can be used when creating new relations if user did not enter a value (even if required).
|
|
217
|
+
*/
|
|
218
|
+
get default() {
|
|
219
|
+
return ("default" in this.relDef ? this.relDef.default : undefined);
|
|
220
|
+
}
|
|
221
|
+
get cardinality() {
|
|
222
|
+
return this.relDef.cardinality;
|
|
223
|
+
}
|
|
224
|
+
get subjectCardinality() {
|
|
225
|
+
return this.relDef.cardinality[0];
|
|
226
|
+
}
|
|
227
|
+
get objectCardinality() {
|
|
228
|
+
return this.relDef.cardinality[1];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Gets the entity associated to this relation's subject
|
|
232
|
+
*
|
|
233
|
+
* @throws InconsistentSchemaError if the relation's subject is not a valid entity
|
|
234
|
+
*/
|
|
235
|
+
get subject() {
|
|
236
|
+
const subjectSchema = this.schema.getEntity(this.relDef.subject);
|
|
237
|
+
if (subjectSchema === null) {
|
|
238
|
+
throw new Errors_1.InconsistentSchemaError(`entity type ${this.relDef.subject} used as subject of relation ${this.type} is not declared`);
|
|
239
|
+
}
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
return subjectSchema;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Gets the entity associated to this relation's object
|
|
246
|
+
*
|
|
247
|
+
* @throws InconsistentSchemaError if the relation's object is not a valid entity
|
|
248
|
+
*/
|
|
249
|
+
get object() {
|
|
250
|
+
const objectSchema = this.schema.getEntity(this.relDef.object);
|
|
251
|
+
if (objectSchema === null) {
|
|
252
|
+
throw new Errors_1.InconsistentSchemaError(`entity type ${this.relDef.object} used as object of relation ${this.type} is not declared`);
|
|
253
|
+
}
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
255
|
+
// @ts-ignore
|
|
256
|
+
return objectSchema;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
exports.RelationDefinitionSchema = RelationDefinitionSchema;
|
|
260
|
+
/**
|
|
261
|
+
* Checks if the given cardinality requires at least one entity to be present
|
|
262
|
+
*
|
|
263
|
+
* @param cardinality The cardinality to check
|
|
264
|
+
* @returns
|
|
265
|
+
*/
|
|
266
|
+
function cardinalityRequired(cardinality) {
|
|
267
|
+
return cardinality === "1" || cardinality === "+";
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=Schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../src/schema/Schema.ts"],"names":[],"mappings":";;;AACA,sCAA2E;AAW3E,MAAM,YAAY,GAAkB,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAEvE;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAI5B,MAAoB,EACpB,EAAE;IACF,OAAO,MAGN,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB;AAEF;;GAEG;AACH,MAAa,MAAM;IAMjB,YAAY,SAA0B;QACpC,IAAI,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,GAAG,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAC7C,CAAC;IACJ,CAAC;IAED,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,GAAG,CACjD,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,wBAAwB,CAAC,IAAI,EAAE,UAAU,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,SAAS,CACP,UAAiB;QAMjB,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,MAAM,CACxD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CACzC,CAAC,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,eAAe,EAAE;YACpB,yDAAyD;YACzD,qDAAqD;YACrD,0CAA0C;YAC1C,6DAA6D;YAC7D,aAAa;YACb,OA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CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAgB,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QAGT,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,aAAa,KAAK,IAAI,EAAE;YAC1B,MAAM,IAAI,gCAAuB,CAC/B,eAAe,IAAI,CAAC,MAAM,CAAC,OAAO,gCAAgC,IAAI,CAAC,IAAI,kBAAkB,CAC9F,CAAC;SACH;QACD,6DAA6D;QAC7D,aAAa;QACb,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QAGR,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/D,IAAI,YAAY,KAAK,IAAI,EAAE;YACzB,MAAM,IAAI,gCAAuB,CAC/B,eAAe,IAAI,CAAC,MAAM,CAAC,MAAM,+BAA+B,IAAI,CAAC,IAAI,kBAAkB,CAC5F,CAAC;SACH;QACD,6DAA6D;QAC7D,aAAa;QACb,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAlGD,4DAkGC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,WAAwB;IACnD,OAAO,WAAW,KAAK,GAAG,IAAI,WAAW,KAAK,GAAG,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
declare type ConstraintBase<T extends string, V extends Record<string, unknown> | null> = {
|
|
2
|
+
type: T;
|
|
3
|
+
value: V;
|
|
4
|
+
};
|
|
5
|
+
export declare type ConstraintOperator = ">" | ">=" | "<" | "<=";
|
|
6
|
+
declare type ConstraintMessage = string | null;
|
|
7
|
+
export declare type UniqueConstraint = ConstraintBase<"UniqueConstraint", null>;
|
|
8
|
+
export declare type SizeConstraint = ConstraintBase<"SizeConstraint", {
|
|
9
|
+
min: number | null;
|
|
10
|
+
max: number | null;
|
|
11
|
+
msg: ConstraintMessage;
|
|
12
|
+
}>;
|
|
13
|
+
export declare type RegexpConstraint = ConstraintBase<"RegexpConstraint", {
|
|
14
|
+
regexp: string;
|
|
15
|
+
flags: number;
|
|
16
|
+
msg: ConstraintMessage;
|
|
17
|
+
}>;
|
|
18
|
+
export declare type BoundaryConstraint = ConstraintBase<"BoundaryConstraint", {
|
|
19
|
+
boundary: number | null;
|
|
20
|
+
op: ConstraintOperator;
|
|
21
|
+
msg: ConstraintMessage;
|
|
22
|
+
}>;
|
|
23
|
+
export declare type IntervalBoundConstraint = ConstraintBase<"IntervalBoundConstraint", {
|
|
24
|
+
minvalue: number | null;
|
|
25
|
+
maxvalue: number | null;
|
|
26
|
+
msg: ConstraintMessage;
|
|
27
|
+
}>;
|
|
28
|
+
export declare type StaticVocabularyConstraint = ConstraintBase<"StaticVocabularyConstraint", {
|
|
29
|
+
values: string[];
|
|
30
|
+
msg: ConstraintMessage;
|
|
31
|
+
}>;
|
|
32
|
+
export declare type FormatConstraint = ConstraintBase<"FormatConstraint", {
|
|
33
|
+
values: ["text/rest", "text/markdown", "text/html", "text/plain"];
|
|
34
|
+
msg: ConstraintMessage;
|
|
35
|
+
}>;
|
|
36
|
+
export declare type Constraint = Readonly<UniqueConstraint | SizeConstraint | RegexpConstraint | BoundaryConstraint | IntervalBoundConstraint | StaticVocabularyConstraint | FormatConstraint>;
|
|
37
|
+
declare type BuildObjBase<T extends string> = {
|
|
38
|
+
object: T;
|
|
39
|
+
final: true;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
};
|
|
42
|
+
interface StringBuildObj extends BuildObjBase<"String"> {
|
|
43
|
+
default: string | null;
|
|
44
|
+
}
|
|
45
|
+
interface PasswordBuildObj extends BuildObjBase<"Password"> {
|
|
46
|
+
default: string | null;
|
|
47
|
+
}
|
|
48
|
+
interface BytesBuildObj extends BuildObjBase<"Bytes"> {
|
|
49
|
+
default: string | null;
|
|
50
|
+
}
|
|
51
|
+
interface IntBuildObj extends BuildObjBase<"Int"> {
|
|
52
|
+
default: number | null;
|
|
53
|
+
}
|
|
54
|
+
interface BigIntBuildObj extends BuildObjBase<"BigInt"> {
|
|
55
|
+
default: number | null;
|
|
56
|
+
}
|
|
57
|
+
interface FloatBuildObj extends BuildObjBase<"Float"> {
|
|
58
|
+
default: number | null;
|
|
59
|
+
}
|
|
60
|
+
interface BooleanBuildObj extends BuildObjBase<"Boolean"> {
|
|
61
|
+
default: boolean | null;
|
|
62
|
+
}
|
|
63
|
+
interface DecimalBuildObj extends BuildObjBase<"Decimal"> {
|
|
64
|
+
default: number | null;
|
|
65
|
+
}
|
|
66
|
+
interface DateBuildObj extends BuildObjBase<"Date"> {
|
|
67
|
+
default: unknown;
|
|
68
|
+
}
|
|
69
|
+
interface TimeBuildObj extends BuildObjBase<"Time"> {
|
|
70
|
+
default: unknown;
|
|
71
|
+
}
|
|
72
|
+
interface DatetimeBuildObj extends BuildObjBase<"Datetime"> {
|
|
73
|
+
default: Date | "NOW" | "TODAY" | null;
|
|
74
|
+
}
|
|
75
|
+
interface TZTimeBuildObj extends BuildObjBase<"TZTime"> {
|
|
76
|
+
default: unknown;
|
|
77
|
+
}
|
|
78
|
+
interface TZDatetimeBuildObj extends BuildObjBase<"TZDatetime"> {
|
|
79
|
+
default: unknown;
|
|
80
|
+
}
|
|
81
|
+
interface IntervalBuildObj extends BuildObjBase<"Interval"> {
|
|
82
|
+
default: unknown;
|
|
83
|
+
}
|
|
84
|
+
export declare type BuildObj = Readonly<StringBuildObj | PasswordBuildObj | BytesBuildObj | IntBuildObj | BigIntBuildObj | FloatBuildObj | BooleanBuildObj | DecimalBuildObj | DateBuildObj | TimeBuildObj | DatetimeBuildObj | TZTimeBuildObj | TZDatetimeBuildObj | IntervalBuildObj>;
|
|
85
|
+
export declare type Cardinality = "*" | "1" | "?" | "+";
|
|
86
|
+
export declare type CardinalityPair = `${Cardinality}${Cardinality}`;
|
|
87
|
+
export declare type EntityRawSchema = {
|
|
88
|
+
type: string;
|
|
89
|
+
final: boolean;
|
|
90
|
+
description: string;
|
|
91
|
+
};
|
|
92
|
+
export declare type EntityRawSchemaArray = ReadonlyArray<EntityRawSchema>;
|
|
93
|
+
export declare type RelationDefinitionRawSchema<ESchemas extends EntityRawSchemaArray, Final extends boolean = boolean> = Readonly<{
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
cardinality: CardinalityPair;
|
|
97
|
+
subject: ESchemas[number]["type"];
|
|
98
|
+
} & (Final extends true ? BuildObj & {
|
|
99
|
+
constraints: Constraint[];
|
|
100
|
+
} : {
|
|
101
|
+
object: EntityRawSchema["type"];
|
|
102
|
+
final: false;
|
|
103
|
+
constraints: null;
|
|
104
|
+
})>;
|
|
105
|
+
export declare type RelationDefinitionRawSchemaArray<ESchemas extends EntityRawSchemaArray> = ReadonlyArray<RelationDefinitionRawSchema<ESchemas, boolean>>;
|
|
106
|
+
export declare type RawSchema<E extends EntityRawSchemaArray = EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<E> = RelationDefinitionRawSchemaArray<E>> = {
|
|
107
|
+
entities: E;
|
|
108
|
+
relations_definitions: R;
|
|
109
|
+
};
|
|
110
|
+
export declare type IsLooseSchema<E extends EntityRawSchemaArray> = string extends E[number]["type"] ? true : false;
|
|
111
|
+
export declare type IsETypeInStrictSchema<E extends EntityRawSchemaArray, EType extends string> = EType extends E[number]["type"] ? true : false;
|
|
112
|
+
/**
|
|
113
|
+
* Type representing the entity's raw schema matching this type.
|
|
114
|
+
* This type only works for EntityRawSchemaArray with literals as "type" property.
|
|
115
|
+
*
|
|
116
|
+
**/
|
|
117
|
+
export declare type EntityRawSchemaByType<E extends EntityRawSchemaArray, T extends string> = E[number] extends infer ESchema ? ESchema extends {
|
|
118
|
+
type: T;
|
|
119
|
+
} ? ESchema : never : never;
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=SchemaJSON.d.ts.map
|
|
@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