@yandjin-mikro-orm/postgresql 6.1.4-rc-sti-changes-1
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/LICENSE +21 -0
- package/PostgreSqlConnection.d.ts +15 -0
- package/PostgreSqlConnection.js +162 -0
- package/PostgreSqlDriver.d.ts +6 -0
- package/PostgreSqlDriver.js +15 -0
- package/PostgreSqlExceptionConverter.d.ts +8 -0
- package/PostgreSqlExceptionConverter.js +45 -0
- package/PostgreSqlMikroORM.d.ts +19 -0
- package/PostgreSqlMikroORM.js +29 -0
- package/PostgreSqlPlatform.d.ts +96 -0
- package/PostgreSqlPlatform.js +314 -0
- package/PostgreSqlSchemaHelper.d.ts +44 -0
- package/PostgreSqlSchemaHelper.js +490 -0
- package/README.md +383 -0
- package/index.d.ts +8 -0
- package/index.js +27 -0
- package/index.mjs +221 -0
- package/package.json +73 -0
- package/types/FullTextType.d.ts +14 -0
- package/types/FullTextType.js +63 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +17 -0
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yandjin-mikro-orm/postgresql",
|
|
3
|
+
"version": "6.1.4-rc-sti-changes-1",
|
|
4
|
+
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "index.mjs",
|
|
7
|
+
"typings": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"default": "./index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": "./index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+ssh://git@github.com/mikro-orm/mikro-orm.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"orm",
|
|
24
|
+
"mongo",
|
|
25
|
+
"mongodb",
|
|
26
|
+
"mysql",
|
|
27
|
+
"mariadb",
|
|
28
|
+
"postgresql",
|
|
29
|
+
"sqlite",
|
|
30
|
+
"sqlite3",
|
|
31
|
+
"ts",
|
|
32
|
+
"typescript",
|
|
33
|
+
"js",
|
|
34
|
+
"javascript",
|
|
35
|
+
"entity",
|
|
36
|
+
"ddd",
|
|
37
|
+
"mikro-orm",
|
|
38
|
+
"unit-of-work",
|
|
39
|
+
"data-mapper",
|
|
40
|
+
"identity-map"
|
|
41
|
+
],
|
|
42
|
+
"author": "Martin Adámek",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/mikro-orm/mikro-orm/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://mikro-orm.io",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">= 18.12.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "yarn clean && yarn compile && yarn copy && yarn run -T gen-esm-wrapper index.js index.mjs",
|
|
53
|
+
"clean": "yarn run -T rimraf ./dist",
|
|
54
|
+
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
55
|
+
"copy": "node ../../scripts/copy.mjs"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@yandjin-mikro-orm/knex": "6.1.4-rc-sti-changes-1",
|
|
62
|
+
"pg": "8.12.0",
|
|
63
|
+
"postgres-array": "3.0.2",
|
|
64
|
+
"postgres-date": "2.1.0",
|
|
65
|
+
"postgres-interval": "4.0.2"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@yandjin-mikro-orm/core": "^6.1.4-rc-sti-changes-1"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@yandjin-mikro-orm/core": "^6.0.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Type, type TransformContext, type RawQueryFragment } from "@yandjin-mikro-orm/core";
|
|
2
|
+
import type { PostgreSqlPlatform } from "../PostgreSqlPlatform";
|
|
3
|
+
type FullTextWeight = "A" | "B" | "C" | "D";
|
|
4
|
+
export type WeightedFullTextValue = {
|
|
5
|
+
[K in FullTextWeight]?: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare class FullTextType extends Type<string | WeightedFullTextValue, string | null | RawQueryFragment> {
|
|
8
|
+
regconfig: string;
|
|
9
|
+
constructor(regconfig?: string);
|
|
10
|
+
compareAsType(): string;
|
|
11
|
+
getColumnType(): string;
|
|
12
|
+
convertToDatabaseValue(value: string | WeightedFullTextValue, platform: PostgreSqlPlatform, context?: TransformContext | boolean): string | null | RawQueryFragment;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FullTextType = void 0;
|
|
4
|
+
const core_1 = require("@yandjin-mikro-orm/core");
|
|
5
|
+
class FullTextType extends core_1.Type {
|
|
6
|
+
regconfig;
|
|
7
|
+
constructor(regconfig = "simple") {
|
|
8
|
+
super();
|
|
9
|
+
this.regconfig = regconfig;
|
|
10
|
+
}
|
|
11
|
+
compareAsType() {
|
|
12
|
+
return "string";
|
|
13
|
+
}
|
|
14
|
+
getColumnType() {
|
|
15
|
+
return "tsvector";
|
|
16
|
+
}
|
|
17
|
+
// Use convertToDatabaseValue to prepare insert queries as this method has
|
|
18
|
+
// access to the raw JS value. Return Knex#raw to prevent QueryBuilderHelper#mapData
|
|
19
|
+
// from sanitizing the returned chaing of SQL functions.
|
|
20
|
+
convertToDatabaseValue(value, platform, context) {
|
|
21
|
+
// Don't convert to values from select queries to the to_tsvector notation
|
|
22
|
+
// these should be compared as string using a special oparator or function
|
|
23
|
+
// this behaviour is defined in Platform#getFullTextWhereClause.
|
|
24
|
+
// This is always a string.
|
|
25
|
+
if (typeof context === "object" && context.fromQuery) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
// Null values should not be processed
|
|
29
|
+
if (!value) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
// the object from that looks like { A: 'test data', B: 'test data2' ... }
|
|
33
|
+
// must be converted to
|
|
34
|
+
// setweight(to_tsvector(regconfig, value), A) || setweight(to_tsvector(regconfig, value), B)... etc
|
|
35
|
+
// use Knex#raw to do binding of the values sanitization of the boundvalues
|
|
36
|
+
// as we return a raw string which should not be sanitzed anymore
|
|
37
|
+
if (typeof value === "object") {
|
|
38
|
+
const bindings = [];
|
|
39
|
+
const sqlParts = [];
|
|
40
|
+
for (const [weight, data] of Object.entries(value)) {
|
|
41
|
+
// Check whether the weight is valid according to Postgres,
|
|
42
|
+
// Postgres allows the weight to be upper and lowercase.
|
|
43
|
+
if (!["A", "B", "C", "D"].includes(weight.toUpperCase())) {
|
|
44
|
+
throw new Error("Weight should be one of A, B, C, D.");
|
|
45
|
+
}
|
|
46
|
+
// Ignore all values that are not a string
|
|
47
|
+
if (typeof data === "string") {
|
|
48
|
+
sqlParts.push("setweight(to_tsvector(?, ?), ?)");
|
|
49
|
+
bindings.push(this.regconfig, data, weight);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Return null if the object has no valid strings
|
|
53
|
+
if (sqlParts.length === 0) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
// Join all the `setweight` parts using the PostgreSQL tsvector `||` concatenation operator
|
|
57
|
+
return (0, core_1.raw)(sqlParts.join(" || "), bindings);
|
|
58
|
+
}
|
|
59
|
+
// if it's not an object, it is expected to be string which does not have to be wrapped in setweight.
|
|
60
|
+
return (0, core_1.raw)("to_tsvector(?, ?)", [this.regconfig, value]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.FullTextType = FullTextType;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FullTextType';
|
package/types/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./FullTextType"), exports);
|