Update pg-promise to the latest version 🚀 (#5857)
* fix(package): update pg-promise to version 9.0.0 * chore(package): update lockfile package-lock.json * remove es6 generators
This commit is contained in:
committed by
peril-parse-community[bot]
parent
8c321ed750
commit
80bb2b6389
28
package-lock.json
generated
28
package-lock.json
generated
@@ -2082,9 +2082,9 @@
|
||||
}
|
||||
},
|
||||
"assert-options": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/assert-options/-/assert-options-0.1.3.tgz",
|
||||
"integrity": "sha512-DXrZ5WkCv/igD+H8OmeUTl9k0pBhYSTdyA7DRZoSJERCzQ8Z2v85yDjkhYVnHUOeCXGfCNKaogRbLWQsIQbtpg=="
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/assert-options/-/assert-options-0.4.0.tgz",
|
||||
"integrity": "sha512-HukncCp5jpMpKE4vcxH/YrmoJUDTtjpITOdw2OR1yDjhbecUf6EJn/xRPN73ykuvDGRLmAD7OL92zhvMO3nnTA=="
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
@@ -8959,9 +8959,9 @@
|
||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||
},
|
||||
"pg": {
|
||||
"version": "7.11.0",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-7.11.0.tgz",
|
||||
"integrity": "sha512-YO4V7vCmEMGoF390LJaFaohWNKaA2ayoQOEZmiHVcAUF+YsRThpf/TaKCgSvsSE7cDm37Q/Cy3Gz41xiX/XjTw==",
|
||||
"version": "7.12.0",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-7.12.0.tgz",
|
||||
"integrity": "sha512-q54Ic0oBXfDZMwheP8ALeUX32TUXvF7SNgAlZjyhkDuFCJkQCgcLBz0Be5uOrAj3ljSok/CI9lRbYzEko0z1Zw==",
|
||||
"requires": {
|
||||
"buffer-writer": "2.0.0",
|
||||
"packet-reader": "1.0.0",
|
||||
@@ -8995,18 +8995,18 @@
|
||||
"integrity": "sha512-8aZ9xdx7Pe/ppFYVOqvU5KgmM6ttXjaBlsl9Y8yzrUH4xSNVucJKKOwm4Y4H+LCvzZGjZIm4Rkf2Ajt5ixtkBQ=="
|
||||
},
|
||||
"pg-pool": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.6.tgz",
|
||||
"integrity": "sha512-hod2zYQxM8Gt482q+qONGTYcg/qVcV32VHVPtktbBJs0us3Dj7xibISw0BAAXVMCzt8A/jhfJvpZaxUlqtqs0g=="
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-2.0.7.tgz",
|
||||
"integrity": "sha512-UiJyO5B9zZpu32GSlP0tXy8J2NsJ9EFGFfz5v6PSbdz/1hBLX1rNiiy5+mAm5iJJYwfCv4A0EBcQLGWwjbpzZw=="
|
||||
},
|
||||
"pg-promise": {
|
||||
"version": "8.7.5",
|
||||
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-8.7.5.tgz",
|
||||
"integrity": "sha512-r/OmS1b1i0nA0KHqlbcAoMLoNo3EGUdcZxaseyXnHrzepcS8ciK516Lw6/lIb6AeWI85ZOBSNdiPlw22xoFx3A==",
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-9.0.0.tgz",
|
||||
"integrity": "sha512-l8ZKzbxqBHSg+Z1Q1AXv+nPfK0OEpBiqOqIQyQdrfUPyjT2fHwkB+kQCzZ+4Phjh5Z2sAa8la4sRHvEke/P//g==",
|
||||
"requires": {
|
||||
"assert-options": "0.1.3",
|
||||
"assert-options": "0.4.0",
|
||||
"manakin": "0.5.2",
|
||||
"pg": "7.11.0",
|
||||
"pg": "7.12.0",
|
||||
"pg-minify": "1.4.1",
|
||||
"spex": "2.2.0"
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
"mongodb": "3.2.7",
|
||||
"node-rsa": "1.0.5",
|
||||
"parse": "2.5.1",
|
||||
"pg-promise": "8.7.5",
|
||||
"pg-promise": "9.0.0",
|
||||
"redis": "2.8.0",
|
||||
"semver": "6.3.0",
|
||||
"subscriptions-transport-ws": "0.9.16",
|
||||
|
||||
@@ -830,15 +830,15 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
|
||||
setClassLevelPermissions(className: string, CLPs: any) {
|
||||
const self = this;
|
||||
return this._client.task('set-class-level-permissions', function*(t) {
|
||||
yield self._ensureSchemaCollectionExists(t);
|
||||
return this._client.task('set-class-level-permissions', async (t) => {
|
||||
await self._ensureSchemaCollectionExists(t);
|
||||
const values = [
|
||||
className,
|
||||
'schema',
|
||||
'classLevelPermissions',
|
||||
JSON.stringify(CLPs),
|
||||
];
|
||||
yield t.none(
|
||||
await t.none(
|
||||
`UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className"=$1`,
|
||||
values
|
||||
);
|
||||
@@ -895,15 +895,15 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
});
|
||||
}
|
||||
});
|
||||
return conn.tx('set-indexes-with-schema-format', function*(t) {
|
||||
return conn.tx('set-indexes-with-schema-format', async (t) => {
|
||||
if (insertedIndexes.length > 0) {
|
||||
yield self.createIndexes(className, insertedIndexes, t);
|
||||
await self.createIndexes(className, insertedIndexes, t);
|
||||
}
|
||||
if (deletedIndexes.length > 0) {
|
||||
yield self.dropIndexes(className, deletedIndexes, t);
|
||||
await self.dropIndexes(className, deletedIndexes, t);
|
||||
}
|
||||
yield self._ensureSchemaCollectionExists(t);
|
||||
yield t.none(
|
||||
await self._ensureSchemaCollectionExists(t);
|
||||
await t.none(
|
||||
'UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className"=$1',
|
||||
[className, 'schema', 'indexes', JSON.stringify(existingIndexes)]
|
||||
);
|
||||
@@ -991,17 +991,17 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
const values = [className, ...valuesArray];
|
||||
|
||||
debug(qs, values);
|
||||
return conn.task('create-table', function*(t) {
|
||||
return conn.task('create-table', async (t) => {
|
||||
try {
|
||||
yield self._ensureSchemaCollectionExists(t);
|
||||
yield t.none(qs, values);
|
||||
await self._ensureSchemaCollectionExists(t);
|
||||
await t.none(qs, values);
|
||||
} catch (error) {
|
||||
if (error.code !== PostgresDuplicateRelationError) {
|
||||
throw error;
|
||||
}
|
||||
// ELSE: Table already exists, must have been created by a different request. Ignore the error.
|
||||
}
|
||||
yield t.tx('create-table-tx', tx => {
|
||||
await t.tx('create-table-tx', tx => {
|
||||
return tx.batch(
|
||||
relations.map(fieldName => {
|
||||
return tx.none(
|
||||
@@ -1019,8 +1019,8 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
conn = conn || this._client;
|
||||
const self = this;
|
||||
|
||||
return conn.tx('schema-upgrade', function*(t) {
|
||||
const columns = yield t.map(
|
||||
return conn.tx('schema-upgrade', async (t) => {
|
||||
const columns = await t.map(
|
||||
'SELECT column_name FROM information_schema.columns WHERE table_name = $<className>',
|
||||
{ className },
|
||||
a => a.column_name
|
||||
@@ -1036,7 +1036,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
)
|
||||
);
|
||||
|
||||
yield t.batch(newColumns);
|
||||
await t.batch(newColumns);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1050,10 +1050,10 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
debug('addFieldIfNotExists', { className, fieldName, type });
|
||||
conn = conn || this._client;
|
||||
const self = this;
|
||||
return conn.tx('add-field-if-not-exists', function*(t) {
|
||||
return conn.tx('add-field-if-not-exists', async (t) => {
|
||||
if (type.type !== 'Relation') {
|
||||
try {
|
||||
yield t.none(
|
||||
await t.none(
|
||||
'ALTER TABLE $<className:name> ADD COLUMN $<fieldName:name> $<postgresType:raw>',
|
||||
{
|
||||
className,
|
||||
@@ -1063,7 +1063,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
);
|
||||
} catch (error) {
|
||||
if (error.code === PostgresRelationDoesNotExistError) {
|
||||
return yield self.createClass(
|
||||
return await self.createClass(
|
||||
className,
|
||||
{ fields: { [fieldName]: type } },
|
||||
t
|
||||
@@ -1075,13 +1075,13 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
// Column already exists, created by other request. Carry on to see if it's the right type.
|
||||
}
|
||||
} else {
|
||||
yield t.none(
|
||||
await t.none(
|
||||
'CREATE TABLE IF NOT EXISTS $<joinTable:name> ("relatedId" varChar(120), "owningId" varChar(120), PRIMARY KEY("relatedId", "owningId") )',
|
||||
{ joinTable: `_Join:${fieldName}:${className}` }
|
||||
);
|
||||
}
|
||||
|
||||
const result = yield t.any(
|
||||
const result = await t.any(
|
||||
'SELECT "schema" FROM "_SCHEMA" WHERE "className" = $<className> and ("schema"::json->\'fields\'->$<fieldName>) is not null',
|
||||
{ className, fieldName }
|
||||
);
|
||||
@@ -1090,7 +1090,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
throw 'Attempted to add a field that already exists';
|
||||
} else {
|
||||
const path = `{fields,${fieldName}}`;
|
||||
yield t.none(
|
||||
await t.none(
|
||||
'UPDATE "_SCHEMA" SET "schema"=jsonb_set("schema", $<path>, $<type>) WHERE "className"=$<className>',
|
||||
{ path, type, className }
|
||||
);
|
||||
@@ -1120,9 +1120,9 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
debug('deleteAllClasses');
|
||||
|
||||
return this._client
|
||||
.task('delete-all-classes', function*(t) {
|
||||
.task('delete-all-classes', async (t) => {
|
||||
try {
|
||||
const results = yield t.any('SELECT * FROM "_SCHEMA"');
|
||||
const results = await t.any('SELECT * FROM "_SCHEMA"');
|
||||
const joins = results.reduce((list: Array<string>, schema: any) => {
|
||||
return list.concat(joinTablesForSchema(schema.schema));
|
||||
}, []);
|
||||
@@ -1142,7 +1142,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
query: 'DROP TABLE IF EXISTS $<className:name>',
|
||||
values: { className },
|
||||
}));
|
||||
yield t.tx(tx => tx.none(helpers.concat(queries)));
|
||||
await t.tx(tx => tx.none(helpers.concat(queries)));
|
||||
} catch (error) {
|
||||
if (error.code !== PostgresRelationDoesNotExistError) {
|
||||
throw error;
|
||||
@@ -1190,13 +1190,13 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
})
|
||||
.join(', DROP COLUMN');
|
||||
|
||||
return this._client.tx('delete-fields', function*(t) {
|
||||
yield t.none(
|
||||
return this._client.tx('delete-fields', async (t) => {
|
||||
await t.none(
|
||||
'UPDATE "_SCHEMA" SET "schema"=$<schema> WHERE "className"=$<className>',
|
||||
{ schema, className }
|
||||
);
|
||||
if (values.length > 1) {
|
||||
yield t.none(`ALTER TABLE $1:name DROP COLUMN ${columns}`, values);
|
||||
await t.none(`ALTER TABLE $1:name DROP COLUMN ${columns}`, values);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1206,9 +1206,9 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
// rejection reason are TBD.
|
||||
getAllClasses() {
|
||||
const self = this;
|
||||
return this._client.task('get-all-classes', function*(t) {
|
||||
yield self._ensureSchemaCollectionExists(t);
|
||||
return yield t.map('SELECT * FROM "_SCHEMA"', null, row =>
|
||||
return this._client.task('get-all-classes', async (t) => {
|
||||
await self._ensureSchemaCollectionExists(t);
|
||||
return await t.map('SELECT * FROM "_SCHEMA"', null, row =>
|
||||
toParseSchema({ className: row.className, ...row.schema })
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user