apeframework 0.0.0-dev.3 → 0.0.0-dev.5
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/README.md +0 -14
- package/api/Api.d.ts +28 -0
- package/api/Api.js +72 -0
- package/api/Api.ts +104 -0
- package/api/Endpoint.d.ts +12 -0
- package/api/Endpoint.ts +16 -0
- package/api/ErrorHandler.d.ts +3 -0
- package/api/ErrorHandler.ts +11 -0
- package/api/Handler.d.ts +3 -0
- package/api/Handler.ts +10 -0
- package/api/Method.d.ts +8 -0
- package/api/Method.js +11 -0
- package/api/Method.ts +11 -0
- package/api/Schema.d.ts +9 -0
- package/api/Schema.ts +13 -0
- package/cipher/Cipher.js +2 -2
- package/cipher/Cipher.ts +2 -2
- package/cipher/errors/{CipherDecryptError.d.ts → DecryptError.d.ts} +2 -2
- package/cipher/errors/{CipherDecryptError.js → DecryptError.js} +3 -3
- package/cipher/errors/{CipherDecryptError.ts → DecryptError.ts} +2 -2
- package/cipher/errors/SecretLengthError.d.ts +5 -0
- package/{jwt/errors/JwtSecretLengthError.js → cipher/errors/SecretLengthError.js} +3 -3
- package/{jwt/errors/JwtSecretLengthError.ts → cipher/errors/SecretLengthError.ts} +2 -2
- package/cipher/validateSecretLength.js +2 -2
- package/cipher/validateSecretLength.ts +2 -2
- package/cli/utils/print.d.ts +2 -0
- package/cli/utils/{write.js → print.js} +3 -3
- package/cli/utils/print.ts +7 -0
- package/cli/utils/printLn.d.ts +2 -0
- package/cli/utils/{writeLn.js → printLn.js} +3 -3
- package/cli/utils/{writeLn.ts → printLn.ts} +2 -2
- package/{env/errors/EnvFileReadError.d.ts → config/errors/FileReadError.d.ts} +2 -2
- package/{tls/errors/TlsFileReadError.js → config/errors/FileReadError.js} +3 -3
- package/{env/errors/EnvFileReadError.ts → config/errors/FileReadError.ts} +2 -2
- package/config/errors/PropertyNameError.d.ts +5 -0
- package/config/errors/{ConfigPropertyNameError.js → PropertyNameError.js} +3 -3
- package/config/errors/{ConfigPropertyNameError.ts → PropertyNameError.ts} +2 -2
- package/config/errors/PropertyParseError.d.ts +5 -0
- package/config/errors/PropertyParseError.js +10 -0
- package/config/errors/PropertyParseError.ts +11 -0
- package/config/parseProperty.js +2 -2
- package/config/parseProperty.ts +2 -2
- package/config/readFile.js +4 -4
- package/config/readFile.ts +4 -4
- package/config/validatePropertyName.js +2 -2
- package/config/validatePropertyName.ts +2 -2
- package/{tls/errors/TlsFileReadError.d.ts → env/errors/FileReadError.d.ts} +2 -2
- package/env/errors/{EnvFileReadError.js → FileReadError.js} +3 -3
- package/{tls/errors/TlsFileReadError.ts → env/errors/FileReadError.ts} +2 -2
- package/env/readFile.js +3 -3
- package/env/readFile.ts +3 -3
- package/jwt/Jwt.d.ts +0 -6
- package/jwt/Jwt.js +8 -34
- package/jwt/Jwt.ts +8 -51
- package/jwt/Payload.d.ts +7 -3
- package/jwt/Payload.ts +7 -3
- package/jwt/errors/SecretLengthError.d.ts +5 -0
- package/{cipher/errors/CipherSecretLengthError.js → jwt/errors/SecretLengthError.js} +3 -3
- package/{cipher/errors/CipherSecretLengthError.ts → jwt/errors/SecretLengthError.ts} +2 -2
- package/jwt/validateSecretLength.js +2 -2
- package/jwt/validateSecretLength.ts +2 -2
- package/logger/Level.d.ts +7 -6
- package/logger/Level.js +7 -6
- package/logger/Level.ts +7 -6
- package/logger/Logger.d.ts +9 -9
- package/logger/Logger.js +4 -0
- package/logger/Logger.ts +15 -9
- package/logger/Severity.d.ts +6 -7
- package/logger/Severity.js +6 -7
- package/logger/Severity.ts +6 -7
- package/logger/adapters/file/FileLogger.d.ts +5 -5
- package/logger/adapters/file/FileLogger.js +17 -17
- package/logger/adapters/file/FileLogger.ts +19 -19
- package/logger/adapters/noop/NoopLogger.d.ts +2 -2
- package/logger/adapters/noop/NoopLogger.js +2 -1
- package/logger/adapters/noop/NoopLogger.ts +2 -2
- package/logger/adapters/stdio/StdioLogger.d.ts +5 -5
- package/logger/adapters/stdio/StdioLogger.js +19 -17
- package/logger/adapters/stdio/StdioLogger.ts +21 -19
- package/mailer/Event.d.ts +4 -4
- package/mailer/Event.ts +4 -4
- package/mailer/{EventLocation.d.ts → Location.d.ts} +2 -2
- package/mailer/Location.js +2 -0
- package/mailer/{EventLocation.ts → Location.ts} +2 -2
- package/mailer/Mailer.d.ts +5 -4
- package/mailer/Mailer.js +48 -0
- package/mailer/Mailer.ts +63 -4
- package/mailer/Method.d.ts +5 -0
- package/mailer/Method.js +8 -0
- package/mailer/{EventMethod.ts → Method.ts} +2 -2
- package/mailer/adapters/noop/NoopMailer.d.ts +3 -3
- package/mailer/adapters/noop/NoopMailer.js +3 -2
- package/mailer/adapters/noop/NoopMailer.ts +3 -3
- package/mailer/adapters/smtp/SmtpMailer.d.ts +3 -3
- package/mailer/adapters/smtp/SmtpMailer.js +4 -2
- package/mailer/adapters/smtp/SmtpMailer.ts +5 -3
- package/mailer/errors/AddressEmailError.d.ts +5 -0
- package/mailer/errors/{MailerAddressEmailError.js → AddressEmailError.js} +3 -3
- package/mailer/errors/{MailerAddressEmailError.ts → AddressEmailError.ts} +2 -2
- package/mailer/errors/EventAttachmentUrlError.d.ts +5 -0
- package/mailer/errors/{MailerEventAttachmentUrlError.js → EventAttachmentUrlError.js} +3 -3
- package/mailer/errors/{MailerEventAttachmentUrlError.ts → EventAttachmentUrlError.ts} +2 -2
- package/mailer/errors/{MailerEventGeolocationError.d.ts → EventGeolocationError.d.ts} +2 -2
- package/mailer/errors/{MailerEventGeolocationError.js → EventGeolocationError.js} +3 -3
- package/mailer/errors/{MailerEventGeolocationError.ts → EventGeolocationError.ts} +2 -2
- package/mailer/errors/EventUrlError.d.ts +5 -0
- package/mailer/errors/{MailerEventUrlError.js → EventUrlError.js} +3 -3
- package/mailer/errors/{MailerEventUrlError.ts → EventUrlError.ts} +2 -2
- package/mailer/errors/{MailerListUrlError.d.ts → ListUrlError.d.ts} +2 -2
- package/mailer/errors/{MailerListUrlError.js → ListUrlError.js} +3 -3
- package/mailer/errors/{MailerListUrlError.ts → ListUrlError.ts} +2 -2
- package/mailer/validateAddressEmail.js +2 -2
- package/mailer/validateAddressEmail.ts +2 -2
- package/mailer/validateEventAttachmentUrl.js +2 -2
- package/mailer/validateEventAttachmentUrl.ts +2 -2
- package/mailer/validateEventGeolocation.js +2 -2
- package/mailer/validateEventGeolocation.ts +2 -2
- package/mailer/validateEventUrl.js +2 -2
- package/mailer/validateEventUrl.ts +2 -2
- package/mailer/validateListUrl.js +2 -2
- package/mailer/validateListUrl.ts +2 -2
- package/package.json +1 -5
- package/parser/errors/{ParserInputError.d.ts → ParseError.d.ts} +2 -2
- package/parser/errors/ParseError.js +10 -0
- package/parser/errors/ParseError.ts +11 -0
- package/parser/factories/unit/createUnitParser.js +3 -3
- package/parser/factories/unit/createUnitParser.ts +3 -3
- package/parser/parseBoolean.js +2 -2
- package/parser/parseBoolean.ts +2 -2
- package/parser/parseInteger.js +3 -3
- package/parser/parseInteger.ts +3 -3
- package/parser/parseNumber.js +3 -3
- package/parser/parseNumber.ts +3 -3
- package/parser/parseString.js +2 -2
- package/parser/parseString.ts +2 -2
- package/pwd/errors/{PwdHashRoundsError.d.ts → HashRoundsError.d.ts} +2 -2
- package/pwd/errors/{PwdHashRoundsError.js → HashRoundsError.js} +3 -3
- package/pwd/errors/{PwdHashRoundsError.ts → HashRoundsError.ts} +2 -2
- package/pwd/validateHashRounds.js +2 -2
- package/pwd/validateHashRounds.ts +2 -2
- package/{config/errors/ConfigFileReadError.d.ts → tls/errors/FileReadError.d.ts} +2 -2
- package/{config/errors/ConfigFileReadError.js → tls/errors/FileReadError.js} +3 -3
- package/{config/errors/ConfigFileReadError.ts → tls/errors/FileReadError.ts} +2 -2
- package/tls/readFile.js +3 -3
- package/tls/readFile.ts +3 -3
- package/cipher/errors/CipherSecretLengthError.d.ts +0 -5
- package/cli/utils/write.d.ts +0 -2
- package/cli/utils/write.ts +0 -7
- package/cli/utils/writeLn.d.ts +0 -2
- package/config/errors/ConfigParseError.d.ts +0 -5
- package/config/errors/ConfigParseError.js +0 -10
- package/config/errors/ConfigParseError.ts +0 -11
- package/config/errors/ConfigPropertyNameError.d.ts +0 -5
- package/db/ColumnBuilder.d.ts +0 -13
- package/db/ColumnBuilder.js +0 -42
- package/db/ColumnBuilder.ts +0 -61
- package/db/Database.d.ts +0 -19
- package/db/Database.js +0 -49
- package/db/Database.ts +0 -74
- package/db/Driver.d.ts +0 -30
- package/db/Driver.ts +0 -33
- package/db/NullConstraint.d.ts +0 -2
- package/db/NullConstraint.ts +0 -5
- package/db/ReferentialAction.d.ts +0 -2
- package/db/ReferentialAction.ts +0 -5
- package/db/TableBuilder.d.ts +0 -49
- package/db/TableBuilder.js +0 -234
- package/db/TableBuilder.ts +0 -367
- package/db/adapters/mysql/createMysqlDatabase.d.ts +0 -12
- package/db/adapters/mysql/createMysqlDatabase.js +0 -32
- package/db/adapters/mysql/createMysqlDatabase.ts +0 -39
- package/db/adapters/mysql/driver.d.ts +0 -3
- package/db/adapters/mysql/driver.js +0 -43
- package/db/adapters/mysql/driver.ts +0 -45
- package/db/adapters/mysql/typeCast.d.ts +0 -2
- package/db/adapters/mysql/typeCast.js +0 -17
- package/db/adapters/mysql/typeCast.ts +0 -18
- package/db/adapters/postgres/driver.d.ts +0 -3
- package/db/adapters/postgres/driver.js +0 -43
- package/db/adapters/postgres/driver.ts +0 -45
- package/db/adapters/sqlite/driver.d.ts +0 -3
- package/db/adapters/sqlite/driver.js +0 -43
- package/db/adapters/sqlite/driver.ts +0 -45
- package/db/errors/DbColumnLengthError.d.ts +0 -5
- package/db/errors/DbColumnLengthError.js +0 -10
- package/db/errors/DbColumnLengthError.ts +0 -11
- package/db/errors/DbColumnMaxLengthError.d.ts +0 -5
- package/db/errors/DbColumnMaxLengthError.js +0 -10
- package/db/errors/DbColumnMaxLengthError.ts +0 -11
- package/db/errors/DbColumnPrecisionError.d.ts +0 -5
- package/db/errors/DbColumnPrecisionError.js +0 -10
- package/db/errors/DbColumnPrecisionError.ts +0 -11
- package/db/errors/DbColumnScaleError.d.ts +0 -5
- package/db/errors/DbColumnScaleError.js +0 -10
- package/db/errors/DbColumnScaleError.ts +0 -11
- package/db/getConstraintName.d.ts +0 -2
- package/db/getConstraintName.js +0 -15
- package/db/getConstraintName.ts +0 -18
- package/db/getReferentialActionSql.d.ts +0 -3
- package/db/getReferentialActionSql.js +0 -12
- package/db/getReferentialActionSql.ts +0 -17
- package/db/setNullConstraint.d.ts +0 -4
- package/db/setNullConstraint.js +0 -9
- package/db/setNullConstraint.ts +0 -15
- package/db/validateColumnLength.d.ts +0 -2
- package/db/validateColumnLength.js +0 -10
- package/db/validateColumnLength.ts +0 -11
- package/db/validateColumnMaxLength.d.ts +0 -2
- package/db/validateColumnMaxLength.js +0 -10
- package/db/validateColumnMaxLength.ts +0 -11
- package/db/validateColumnPrecision.d.ts +0 -2
- package/db/validateColumnPrecision.js +0 -14
- package/db/validateColumnPrecision.ts +0 -15
- package/jwt/errors/JwtSecretLengthError.d.ts +0 -5
- package/mailer/EventMethod.d.ts +0 -5
- package/mailer/EventMethod.js +0 -8
- package/mailer/errors/MailerAddressEmailError.d.ts +0 -5
- package/mailer/errors/MailerEventAttachmentUrlError.d.ts +0 -5
- package/mailer/errors/MailerEventUrlError.d.ts +0 -5
- package/parser/errors/ParserInputError.js +0 -10
- package/parser/errors/ParserInputError.ts +0 -11
- /package/{db/Driver.js → api/Endpoint.js} +0 -0
- /package/{db/NullConstraint.js → api/ErrorHandler.js} +0 -0
- /package/{db/ReferentialAction.js → api/Handler.js} +0 -0
- /package/{mailer/EventLocation.js → api/Schema.js} +0 -0
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import knex from 'knex'
|
|
2
|
-
import { getTls } from '../../../tls/getTls'
|
|
3
|
-
import { Database } from '../../Database'
|
|
4
|
-
import { driver } from './driver'
|
|
5
|
-
import { typeCast } from './typeCast'
|
|
6
|
-
import type { Tls } from '../../../tls/Tls'
|
|
7
|
-
|
|
8
|
-
const createMysqlDatabase = (params: {
|
|
9
|
-
host: string,
|
|
10
|
-
port: number,
|
|
11
|
-
tls?: Tls,
|
|
12
|
-
user: string,
|
|
13
|
-
password?: string,
|
|
14
|
-
database: string,
|
|
15
|
-
maxConnections?: number,
|
|
16
|
-
}): Database => {
|
|
17
|
-
return new Database(knex({
|
|
18
|
-
client: 'mysql2',
|
|
19
|
-
connection: {
|
|
20
|
-
host: params.host,
|
|
21
|
-
port: params.port,
|
|
22
|
-
ssl: getTls(params.tls),
|
|
23
|
-
user: params.user,
|
|
24
|
-
password: params.password,
|
|
25
|
-
database: params.database,
|
|
26
|
-
dateStrings: true,
|
|
27
|
-
typeCast,
|
|
28
|
-
},
|
|
29
|
-
pool: {
|
|
30
|
-
min: 0,
|
|
31
|
-
max: params.maxConnections,
|
|
32
|
-
},
|
|
33
|
-
useNullAsDefault: true,
|
|
34
|
-
}), driver)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
createMysqlDatabase,
|
|
39
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.driver = void 0;
|
|
4
|
-
const driver = {
|
|
5
|
-
dataType: {
|
|
6
|
-
boolean: 'BIT',
|
|
7
|
-
tinyInt: 'TINYINT',
|
|
8
|
-
smallInt: 'SMALLINT',
|
|
9
|
-
smallIntPrimaryAutoIncrement: 'SMALLINT PRIMARY KEY AUTO_INCREMENT',
|
|
10
|
-
int: 'INTEGER',
|
|
11
|
-
intPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTO_INCREMENT',
|
|
12
|
-
bigInt: 'BIGINT',
|
|
13
|
-
bigIntPrimaryAutoIncrement: 'BIGINT PRIMARY KEY AUTO_INCREMENT',
|
|
14
|
-
float: 'FLOAT',
|
|
15
|
-
double: 'DOUBLE',
|
|
16
|
-
numeric: (precision, scale) => {
|
|
17
|
-
return `NUMERIC(${precision}, ${scale})`;
|
|
18
|
-
},
|
|
19
|
-
char: (length) => {
|
|
20
|
-
return `CHAR(${length})`;
|
|
21
|
-
},
|
|
22
|
-
varChar: (maxLength) => {
|
|
23
|
-
return `VARCHAR(${maxLength})`;
|
|
24
|
-
},
|
|
25
|
-
tinyText: 'TINYTEXT',
|
|
26
|
-
text: 'TEXT',
|
|
27
|
-
longText: 'LONGTEXT',
|
|
28
|
-
binary: (length) => {
|
|
29
|
-
return `BINARY(${length})`;
|
|
30
|
-
},
|
|
31
|
-
varBinary: (maxLength) => {
|
|
32
|
-
return `VARBINARY(${maxLength})`;
|
|
33
|
-
},
|
|
34
|
-
tinyBlob: 'TINYBLOB',
|
|
35
|
-
blob: 'BLOB',
|
|
36
|
-
longBlob: 'LONGBLOB',
|
|
37
|
-
timestamp: 'TIMESTAMP(3)',
|
|
38
|
-
dateTime: 'DATETIME(3)',
|
|
39
|
-
date: 'DATE',
|
|
40
|
-
time: 'TIME(3)',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
exports.driver = driver;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Driver } from '../../Driver'
|
|
2
|
-
|
|
3
|
-
const driver: Driver = {
|
|
4
|
-
dataType: {
|
|
5
|
-
boolean: 'BIT',
|
|
6
|
-
tinyInt: 'TINYINT',
|
|
7
|
-
smallInt: 'SMALLINT',
|
|
8
|
-
smallIntPrimaryAutoIncrement: 'SMALLINT PRIMARY KEY AUTO_INCREMENT',
|
|
9
|
-
int: 'INTEGER',
|
|
10
|
-
intPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTO_INCREMENT',
|
|
11
|
-
bigInt: 'BIGINT',
|
|
12
|
-
bigIntPrimaryAutoIncrement: 'BIGINT PRIMARY KEY AUTO_INCREMENT',
|
|
13
|
-
float: 'FLOAT',
|
|
14
|
-
double: 'DOUBLE',
|
|
15
|
-
numeric: (precision: number, scale: number) => {
|
|
16
|
-
return `NUMERIC(${precision}, ${scale})`
|
|
17
|
-
},
|
|
18
|
-
char: (length: number) => {
|
|
19
|
-
return `CHAR(${length})`
|
|
20
|
-
},
|
|
21
|
-
varChar: (maxLength: number) => {
|
|
22
|
-
return `VARCHAR(${maxLength})`
|
|
23
|
-
},
|
|
24
|
-
tinyText: 'TINYTEXT',
|
|
25
|
-
text: 'TEXT',
|
|
26
|
-
longText: 'LONGTEXT',
|
|
27
|
-
binary: (length: number) => {
|
|
28
|
-
return `BINARY(${length})`
|
|
29
|
-
},
|
|
30
|
-
varBinary: (maxLength: number) => {
|
|
31
|
-
return `VARBINARY(${maxLength})`
|
|
32
|
-
},
|
|
33
|
-
tinyBlob: 'TINYBLOB',
|
|
34
|
-
blob: 'BLOB',
|
|
35
|
-
longBlob: 'LONGBLOB',
|
|
36
|
-
timestamp: 'TIMESTAMP(3)',
|
|
37
|
-
dateTime: 'DATETIME(3)',
|
|
38
|
-
date: 'DATE',
|
|
39
|
-
time: 'TIME(3)',
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
driver,
|
|
45
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.typeCast = void 0;
|
|
4
|
-
let value;
|
|
5
|
-
const typeCast = (field, next) => {
|
|
6
|
-
switch (field.type) {
|
|
7
|
-
case 'BIT':
|
|
8
|
-
value = field.buffer();
|
|
9
|
-
return value === null ? null : Boolean(value[0]);
|
|
10
|
-
case 'NEWDECIMAL':
|
|
11
|
-
value = field.string();
|
|
12
|
-
return value === null ? null : parseFloat(value);
|
|
13
|
-
default:
|
|
14
|
-
return next();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.typeCast = typeCast;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
let value: any
|
|
2
|
-
|
|
3
|
-
const typeCast = (field: any, next: any): any => {
|
|
4
|
-
switch (field.type) {
|
|
5
|
-
case 'BIT':
|
|
6
|
-
value = field.buffer()
|
|
7
|
-
return value === null ? null : Boolean(value[0])
|
|
8
|
-
case 'NEWDECIMAL':
|
|
9
|
-
value = field.string()
|
|
10
|
-
return value === null ? null : parseFloat(value)
|
|
11
|
-
default:
|
|
12
|
-
return next()
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
typeCast,
|
|
18
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.driver = void 0;
|
|
4
|
-
const driver = {
|
|
5
|
-
dataType: {
|
|
6
|
-
boolean: 'BOOLEAN',
|
|
7
|
-
tinyInt: 'SMALLINT',
|
|
8
|
-
smallInt: 'SMALLINT',
|
|
9
|
-
smallIntPrimaryAutoIncrement: 'SMALLSERIAL PRIMARY KEY',
|
|
10
|
-
int: 'INTEGER',
|
|
11
|
-
intPrimaryAutoIncrement: 'SERIAL PRIMARY KEY',
|
|
12
|
-
bigInt: 'BIGINT',
|
|
13
|
-
bigIntPrimaryAutoIncrement: 'BIGSERIAL PRIMARY KEY',
|
|
14
|
-
float: 'REAL',
|
|
15
|
-
double: 'DOUBLE PRECISION',
|
|
16
|
-
numeric: (precision, scale) => {
|
|
17
|
-
return `NUMERIC(${precision}, ${scale})`;
|
|
18
|
-
},
|
|
19
|
-
char: (length) => {
|
|
20
|
-
return `CHAR(${length})`;
|
|
21
|
-
},
|
|
22
|
-
varChar: (maxLength) => {
|
|
23
|
-
return `VARCHAR(${maxLength})`;
|
|
24
|
-
},
|
|
25
|
-
tinyText: 'TEXT',
|
|
26
|
-
text: 'TEXT',
|
|
27
|
-
longText: 'TEXT',
|
|
28
|
-
binary: () => {
|
|
29
|
-
return 'BYTEA';
|
|
30
|
-
},
|
|
31
|
-
varBinary: () => {
|
|
32
|
-
return 'BYTEA';
|
|
33
|
-
},
|
|
34
|
-
tinyBlob: 'BYTEA',
|
|
35
|
-
blob: 'BYTEA',
|
|
36
|
-
longBlob: 'BYTEA',
|
|
37
|
-
timestamp: 'TIMESTAMP(3)',
|
|
38
|
-
dateTime: 'TIMESTAMP(3)',
|
|
39
|
-
date: 'DATE',
|
|
40
|
-
time: 'TIME(3)',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
exports.driver = driver;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Driver } from '../../Driver'
|
|
2
|
-
|
|
3
|
-
const driver: Driver = {
|
|
4
|
-
dataType: {
|
|
5
|
-
boolean: 'BOOLEAN',
|
|
6
|
-
tinyInt: 'SMALLINT',
|
|
7
|
-
smallInt: 'SMALLINT',
|
|
8
|
-
smallIntPrimaryAutoIncrement: 'SMALLSERIAL PRIMARY KEY',
|
|
9
|
-
int: 'INTEGER',
|
|
10
|
-
intPrimaryAutoIncrement: 'SERIAL PRIMARY KEY',
|
|
11
|
-
bigInt: 'BIGINT',
|
|
12
|
-
bigIntPrimaryAutoIncrement: 'BIGSERIAL PRIMARY KEY',
|
|
13
|
-
float: 'REAL',
|
|
14
|
-
double: 'DOUBLE PRECISION',
|
|
15
|
-
numeric: (precision: number, scale: number) => {
|
|
16
|
-
return `NUMERIC(${precision}, ${scale})`
|
|
17
|
-
},
|
|
18
|
-
char: (length: number) => {
|
|
19
|
-
return `CHAR(${length})`
|
|
20
|
-
},
|
|
21
|
-
varChar: (maxLength: number) => {
|
|
22
|
-
return `VARCHAR(${maxLength})`
|
|
23
|
-
},
|
|
24
|
-
tinyText: 'TEXT',
|
|
25
|
-
text: 'TEXT',
|
|
26
|
-
longText: 'TEXT',
|
|
27
|
-
binary: () => {
|
|
28
|
-
return 'BYTEA'
|
|
29
|
-
},
|
|
30
|
-
varBinary: () => {
|
|
31
|
-
return 'BYTEA'
|
|
32
|
-
},
|
|
33
|
-
tinyBlob: 'BYTEA',
|
|
34
|
-
blob: 'BYTEA',
|
|
35
|
-
longBlob: 'BYTEA',
|
|
36
|
-
timestamp: 'TIMESTAMP(3)',
|
|
37
|
-
dateTime: 'TIMESTAMP(3)',
|
|
38
|
-
date: 'DATE',
|
|
39
|
-
time: 'TIME(3)',
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
driver,
|
|
45
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.driver = void 0;
|
|
4
|
-
const driver = {
|
|
5
|
-
dataType: {
|
|
6
|
-
boolean: 'INTEGER',
|
|
7
|
-
tinyInt: 'INTEGER',
|
|
8
|
-
smallInt: 'INTEGER',
|
|
9
|
-
smallIntPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
10
|
-
int: 'INTEGER',
|
|
11
|
-
intPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
12
|
-
bigInt: 'INTEGER',
|
|
13
|
-
bigIntPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
14
|
-
float: 'REAL',
|
|
15
|
-
double: 'REAL',
|
|
16
|
-
numeric: () => {
|
|
17
|
-
return 'NUMERIC';
|
|
18
|
-
},
|
|
19
|
-
char: () => {
|
|
20
|
-
return 'TEXT';
|
|
21
|
-
},
|
|
22
|
-
varChar: () => {
|
|
23
|
-
return 'TEXT';
|
|
24
|
-
},
|
|
25
|
-
tinyText: 'TEXT',
|
|
26
|
-
text: 'TEXT',
|
|
27
|
-
longText: 'TEXT',
|
|
28
|
-
binary: () => {
|
|
29
|
-
return 'BLOB';
|
|
30
|
-
},
|
|
31
|
-
varBinary: () => {
|
|
32
|
-
return 'BLOB';
|
|
33
|
-
},
|
|
34
|
-
tinyBlob: 'BLOB',
|
|
35
|
-
blob: 'BLOB',
|
|
36
|
-
longBlob: 'BLOB',
|
|
37
|
-
timestamp: 'TEXT',
|
|
38
|
-
dateTime: 'TEXT',
|
|
39
|
-
date: 'TEXT',
|
|
40
|
-
time: 'TEXT',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
exports.driver = driver;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { Driver } from '../../Driver'
|
|
2
|
-
|
|
3
|
-
const driver: Driver = {
|
|
4
|
-
dataType: {
|
|
5
|
-
boolean: 'INTEGER',
|
|
6
|
-
tinyInt: 'INTEGER',
|
|
7
|
-
smallInt: 'INTEGER',
|
|
8
|
-
smallIntPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
9
|
-
int: 'INTEGER',
|
|
10
|
-
intPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
11
|
-
bigInt: 'INTEGER',
|
|
12
|
-
bigIntPrimaryAutoIncrement: 'INTEGER PRIMARY KEY AUTOINCREMENT',
|
|
13
|
-
float: 'REAL',
|
|
14
|
-
double: 'REAL',
|
|
15
|
-
numeric: () => {
|
|
16
|
-
return 'NUMERIC'
|
|
17
|
-
},
|
|
18
|
-
char: () => {
|
|
19
|
-
return 'TEXT'
|
|
20
|
-
},
|
|
21
|
-
varChar: () => {
|
|
22
|
-
return 'TEXT'
|
|
23
|
-
},
|
|
24
|
-
tinyText: 'TEXT',
|
|
25
|
-
text: 'TEXT',
|
|
26
|
-
longText: 'TEXT',
|
|
27
|
-
binary: () => {
|
|
28
|
-
return 'BLOB'
|
|
29
|
-
},
|
|
30
|
-
varBinary: () => {
|
|
31
|
-
return 'BLOB'
|
|
32
|
-
},
|
|
33
|
-
tinyBlob: 'BLOB',
|
|
34
|
-
blob: 'BLOB',
|
|
35
|
-
longBlob: 'BLOB',
|
|
36
|
-
timestamp: 'TEXT',
|
|
37
|
-
dateTime: 'TEXT',
|
|
38
|
-
date: 'TEXT',
|
|
39
|
-
time: 'TEXT',
|
|
40
|
-
},
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
driver,
|
|
45
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DbColumnLengthError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class DbColumnLengthError extends BaseError_1.BaseError {
|
|
6
|
-
constructor(length) {
|
|
7
|
-
super(`invalid column length "${length}"`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.DbColumnLengthError = DbColumnLengthError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DbColumnMaxLengthError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class DbColumnMaxLengthError extends BaseError_1.BaseError {
|
|
6
|
-
constructor(maxLength) {
|
|
7
|
-
super(`invalid column max length "${maxLength}"`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.DbColumnMaxLengthError = DbColumnMaxLengthError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DbColumnPrecisionError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class DbColumnPrecisionError extends BaseError_1.BaseError {
|
|
6
|
-
constructor(precision) {
|
|
7
|
-
super(`invalid column precision "${precision}"`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.DbColumnPrecisionError = DbColumnPrecisionError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DbColumnScaleError = void 0;
|
|
4
|
-
const BaseError_1 = require("../../error/BaseError");
|
|
5
|
-
class DbColumnScaleError extends BaseError_1.BaseError {
|
|
6
|
-
constructor(scale) {
|
|
7
|
-
super(`invalid column scale "${scale}"`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.DbColumnScaleError = DbColumnScaleError;
|
package/db/getConstraintName.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getConstraintName = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const getConstraintName = (constraint, table, columns) => {
|
|
9
|
-
const hash = crypto_1.default
|
|
10
|
-
.createHash('md5')
|
|
11
|
-
.update([table, ...columns].join('_'))
|
|
12
|
-
.digest('hex');
|
|
13
|
-
return `${constraint}_${hash}`;
|
|
14
|
-
};
|
|
15
|
-
exports.getConstraintName = getConstraintName;
|
package/db/getConstraintName.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import crypto from 'crypto'
|
|
2
|
-
|
|
3
|
-
const getConstraintName = (
|
|
4
|
-
constraint: string,
|
|
5
|
-
table: string,
|
|
6
|
-
columns: string[],
|
|
7
|
-
): string => {
|
|
8
|
-
const hash = crypto
|
|
9
|
-
.createHash('md5')
|
|
10
|
-
.update([table, ...columns].join('_'))
|
|
11
|
-
.digest('hex')
|
|
12
|
-
|
|
13
|
-
return `${constraint}_${hash}`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
getConstraintName,
|
|
18
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReferentialActionSql = void 0;
|
|
4
|
-
const sql = {
|
|
5
|
-
cascade: 'CASCADE',
|
|
6
|
-
restrict: 'RESTRICT',
|
|
7
|
-
setNull: 'SET NULL',
|
|
8
|
-
};
|
|
9
|
-
const getReferentialActionSql = (referentialAction) => {
|
|
10
|
-
return sql[referentialAction];
|
|
11
|
-
};
|
|
12
|
-
exports.getReferentialActionSql = getReferentialActionSql;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ReferentialAction } from './ReferentialAction'
|
|
2
|
-
|
|
3
|
-
const sql: Record<ReferentialAction, string> = {
|
|
4
|
-
cascade: 'CASCADE',
|
|
5
|
-
restrict: 'RESTRICT',
|
|
6
|
-
setNull: 'SET NULL',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const getReferentialActionSql = (
|
|
10
|
-
referentialAction: ReferentialAction,
|
|
11
|
-
): string => {
|
|
12
|
-
return sql[referentialAction]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
getReferentialActionSql,
|
|
17
|
-
}
|
package/db/setNullConstraint.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setNullConstraint = void 0;
|
|
4
|
-
const setNullConstraint = (knexColumnBuilder, nullConstraint) => {
|
|
5
|
-
if (nullConstraint === 'notNull') {
|
|
6
|
-
knexColumnBuilder.notNullable();
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
exports.setNullConstraint = setNullConstraint;
|
package/db/setNullConstraint.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { NullConstraint } from './NullConstraint'
|
|
2
|
-
import type { Knex } from 'knex'
|
|
3
|
-
|
|
4
|
-
const setNullConstraint = (
|
|
5
|
-
knexColumnBuilder: Knex.ColumnBuilder,
|
|
6
|
-
nullConstraint: NullConstraint,
|
|
7
|
-
): void => {
|
|
8
|
-
if (nullConstraint === 'notNull') {
|
|
9
|
-
knexColumnBuilder.notNullable()
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
setNullConstraint,
|
|
15
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateColumnLength = void 0;
|
|
4
|
-
const DbColumnLengthError_1 = require("./errors/DbColumnLengthError");
|
|
5
|
-
const validateColumnLength = (length) => {
|
|
6
|
-
if (length < 1 || length > 255) {
|
|
7
|
-
throw new DbColumnLengthError_1.DbColumnLengthError(length);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.validateColumnLength = validateColumnLength;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateColumnMaxLength = void 0;
|
|
4
|
-
const DbColumnMaxLengthError_1 = require("./errors/DbColumnMaxLengthError");
|
|
5
|
-
const validateColumnMaxLength = (maxLength) => {
|
|
6
|
-
if (maxLength < 1 || maxLength > 65535) {
|
|
7
|
-
throw new DbColumnMaxLengthError_1.DbColumnMaxLengthError(maxLength);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
exports.validateColumnMaxLength = validateColumnMaxLength;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DbColumnMaxLengthError } from './errors/DbColumnMaxLengthError'
|
|
2
|
-
|
|
3
|
-
const validateColumnMaxLength = (maxLength: number): void => {
|
|
4
|
-
if (maxLength < 1 || maxLength > 65535) {
|
|
5
|
-
throw new DbColumnMaxLengthError(maxLength)
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
validateColumnMaxLength,
|
|
11
|
-
}
|