forked from Ivasoft/mattermost-mobile
* update dependencies * update dependencies * feedback review * update @mattermost/react-native-turbo-mailer
293 lines
13 KiB
Diff
293 lines
13 KiB
Diff
diff --git a/node_modules/@nozbe/watermelondb/Database/index.js b/node_modules/@nozbe/watermelondb/Database/index.js
|
|
index 8d71c6f..9ad75d6 100644
|
|
--- a/node_modules/@nozbe/watermelondb/Database/index.js
|
|
+++ b/node_modules/@nozbe/watermelondb/Database/index.js
|
|
@@ -126,6 +126,10 @@ var Database = /*#__PURE__*/function () {
|
|
// subsequent changes to the record don't trip up the invariant
|
|
// TODO: What if this fails?
|
|
record._preparedState = null;
|
|
+
|
|
+ if ('update' === preparedState) {
|
|
+ record.__original = null;
|
|
+ }
|
|
}
|
|
|
|
if (!changeNotifications[table]) {
|
|
diff --git a/node_modules/@nozbe/watermelondb/DatabaseProvider/index.d.ts b/node_modules/@nozbe/watermelondb/DatabaseProvider/index.d.ts
|
|
index 7c00164..10e5388 100644
|
|
--- a/node_modules/@nozbe/watermelondb/DatabaseProvider/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/DatabaseProvider/index.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
-import { ElementType, ReactNode } from 'react'
|
|
+import React, { ReactNode } from 'react'
|
|
import Database from '../Database'
|
|
import { Provider } from './DatabaseContext'
|
|
|
|
@@ -11,7 +11,7 @@ export type Props = {
|
|
* Database provider to create the database context
|
|
* to allow child components to consume the database without prop drilling
|
|
*/
|
|
-declare function DatabaseProvider({ children, database }: Props): ElementType<Provider>
|
|
+declare function DatabaseProvider({ children, database }: Props): JSX.Element
|
|
|
|
export { default as withDatabase } from './withDatabase'
|
|
export { default as DatabaseContext, DatabaseConsumer } from './DatabaseContext'
|
|
diff --git a/node_modules/@nozbe/watermelondb/DatabaseProvider/withDatabase.d.ts b/node_modules/@nozbe/watermelondb/DatabaseProvider/withDatabase.d.ts
|
|
index b29d8aa..b70faa9 100644
|
|
--- a/node_modules/@nozbe/watermelondb/DatabaseProvider/withDatabase.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/DatabaseProvider/withDatabase.d.ts
|
|
@@ -1,4 +1,5 @@
|
|
-import { ComponentType } from 'react'
|
|
+import type { NonReactStatics } from 'hoist-non-react-statics'
|
|
+import React, { ComponentType } from 'react'
|
|
import type Database from '../Database'
|
|
import { DatabaseConsumer } from './DatabaseContext'
|
|
|
|
@@ -8,4 +9,4 @@ type WithDatabaseProps<T> = T & {
|
|
// HoC to inject the database into the props of consumers
|
|
export default function withDatabase<T>(
|
|
Component: ComponentType<WithDatabaseProps<T>>,
|
|
-): DatabaseConsumer
|
|
+): React.FunctionComponent<Omit<T, 'database'>> & NonReactStatics<T>
|
|
diff --git a/node_modules/@nozbe/watermelondb/Model/index.d.ts b/node_modules/@nozbe/watermelondb/Model/index.d.ts
|
|
index 43cd902..baefb53 100644
|
|
--- a/node_modules/@nozbe/watermelondb/Model/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/Model/index.d.ts
|
|
@@ -52,14 +52,16 @@ export default class Model {
|
|
// someTask.update(task => {
|
|
// task.name = 'New name'
|
|
// })
|
|
- update(recordUpdater: (this) => void): Promise<this>
|
|
+ update(recordUpdater: (record: this) => void): Promise<this>
|
|
|
|
// Prepares an update to the database (using passed function).
|
|
// Touches `updatedAt` if available.
|
|
//
|
|
// After preparing an update, you must execute it synchronously using
|
|
// database.batch()
|
|
- prepareUpdate(recordUpdater: (this) => void): this
|
|
+ prepareUpdate(recordUpdater: (record: this) => void): this
|
|
+
|
|
+ cancelPrepareUpdate(): void
|
|
|
|
prepareMarkAsDeleted(): this
|
|
|
|
diff --git a/node_modules/@nozbe/watermelondb/Model/index.js b/node_modules/@nozbe/watermelondb/Model/index.js
|
|
index b0e3a83..47313d4 100644
|
|
--- a/node_modules/@nozbe/watermelondb/Model/index.js
|
|
+++ b/node_modules/@nozbe/watermelondb/Model/index.js
|
|
@@ -81,7 +81,7 @@ var Model = /*#__PURE__*/function () {
|
|
_proto.prepareUpdate = function prepareUpdate(recordUpdater = _noop.default) {
|
|
var _this = this;
|
|
|
|
- (0, _invariant.default)(!this._preparedState, "Cannot update a record with pending changes");
|
|
+ (0, _invariant.default)(!this._preparedState, "Cannot update a record with pending changes in table " + _this.table);
|
|
|
|
this.__ensureNotDisposable("Model.prepareUpdate()");
|
|
|
|
@@ -92,6 +92,7 @@ var Model = /*#__PURE__*/function () {
|
|
} // Perform updates
|
|
|
|
|
|
+ this.__original = Object.assign({}, this._raw);
|
|
(0, _ensureSync.default)(recordUpdater(this));
|
|
this._isEditing = false;
|
|
this._preparedState = 'update'; // TODO: `process.nextTick` doesn't work on React Native
|
|
@@ -107,6 +108,18 @@ var Model = /*#__PURE__*/function () {
|
|
return this;
|
|
};
|
|
|
|
+ _proto.cancelPrepareUpdate = function cancelPrepareUpdate() {
|
|
+ if ('test' !== process.env.NODE_ENV && 'undefined' !== typeof process && process) {
|
|
+ (0, _invariant.default)('update' !== _this._preparedState, "Cannot cancel an update on a model that has not been prepared in table " + this.table);
|
|
+ }
|
|
+ this.__changes = null;
|
|
+ this._preparedState = null;
|
|
+ if (this.__original) {
|
|
+ this._raw = this.__original;
|
|
+ }
|
|
+ this.__original = undefined;
|
|
+ };
|
|
+
|
|
_proto.prepareMarkAsDeleted = function prepareMarkAsDeleted() {
|
|
(0, _invariant.default)(!this._preparedState, "Cannot mark a record with pending changes as deleted");
|
|
|
|
diff --git a/node_modules/@nozbe/watermelondb/Query/index.d.ts b/node_modules/@nozbe/watermelondb/Query/index.d.ts
|
|
index eb2bd84..eb02824 100644
|
|
--- a/node_modules/@nozbe/watermelondb/Query/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/Query/index.d.ts
|
|
@@ -73,7 +73,7 @@ export default class Query<Record extends Model> {
|
|
|
|
// Emits the number of matching records, then emits a new count every time it changes
|
|
// Note: By default, the Observable is throttled!
|
|
- observeCount(isThrottled: boolean): Observable<number>
|
|
+ observeCount(isThrottled?: boolean): Observable<number>
|
|
|
|
// Queries database and returns an array with IDs of matching records
|
|
fetchIds(): Promise<RecordId[]>
|
|
diff --git a/node_modules/@nozbe/watermelondb/QueryDescription/index.d.ts b/node_modules/@nozbe/watermelondb/QueryDescription/index.d.ts
|
|
index cf2e1e0..6910974 100644
|
|
--- a/node_modules/@nozbe/watermelondb/QueryDescription/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/QueryDescription/index.d.ts
|
|
@@ -193,7 +193,7 @@ export function and(...clauses: Where[]): And
|
|
|
|
export function or(...clauses: Where[]): Or
|
|
|
|
-export function sortBy(sortColumn: ColumnName, sortOrder: SortOrder): SortBy
|
|
+export function sortBy(sortColumn: ColumnName, sortOrder?: SortOrder): SortBy
|
|
|
|
export function take(count: number): Take
|
|
|
|
@@ -230,7 +230,7 @@ export function experimentalJoinTables(tables: TableName<any>[]): JoinTables
|
|
|
|
export function experimentalNestedJoin(from: TableName<any>, to: TableName<any>): NestedJoinTable
|
|
|
|
-export function unsafeSqlQuery(sql: string, values: Value[]): SqlQuery
|
|
+export function unsafeSqlQuery(sql: string, values?: Value[]): SqlQuery
|
|
|
|
// const extractClauses: (clauses: Clause[]) => QueryDescription;
|
|
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/children/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/children/index.d.ts
|
|
index 53d3daf..b26a60a 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/children/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/children/index.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
import { TableName } from '../../Schema'
|
|
|
|
-type children = (childTable: TableName<any>) => PropertyDecorator
|
|
+const children = (childTable: TableName<any>) => PropertyDecorator
|
|
export default children
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/date/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/date/index.d.ts
|
|
index 10381e6..020654e 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/date/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/date/index.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
import { ColumnName } from '../../Schema'
|
|
|
|
-type date = (columnName: ColumnName) => PropertyDecorator
|
|
+const date = (columnName: ColumnName) => PropertyDecorator
|
|
export default date
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/field/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/field/index.d.ts
|
|
index 87625ac..520f15e 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/field/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/field/index.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
import { ColumnName } from '../../Schema'
|
|
|
|
-type field = (columnName: ColumnName) => PropertyDecorator
|
|
+const field = (columnName: ColumnName) => PropertyDecorator
|
|
export default field
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/immutableRelation/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/immutableRelation/index.d.ts
|
|
index 6a7e860..529bcd9 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/immutableRelation/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/immutableRelation/index.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
import { ColumnName, TableName } from '../../Schema'
|
|
|
|
-type immutableRelation = (
|
|
+const immutableRelation = (
|
|
relationTable: TableName<any>,
|
|
relationIdColumn: ColumnName,
|
|
) => PropertyDecorator
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/json/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/json/index.d.ts
|
|
index 55de0d8..4aae413 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/json/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/json/index.d.ts
|
|
@@ -3,6 +3,6 @@ import Model from '../../Model'
|
|
|
|
type Sanitizer = (source: any, model?: Model) => any
|
|
|
|
-type json = (rawFieldName: ColumnName, sanitizer: Sanitizer) => PropertyDecorator
|
|
+const json = (rawFieldName: ColumnName, sanitizer: Sanitizer) => PropertyDecorator
|
|
|
|
export default json
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/relation/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/relation/index.d.ts
|
|
index 9fea99e..ef7baae 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/relation/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/relation/index.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
import { ColumnName, TableName } from '../../Schema'
|
|
import { Options } from '../../Relation'
|
|
|
|
-type relation = (
|
|
+const relation = (
|
|
relationTable: TableName<any>,
|
|
relationIdColumn: ColumnName,
|
|
options?: Options,
|
|
diff --git a/node_modules/@nozbe/watermelondb/decorators/text/index.d.ts b/node_modules/@nozbe/watermelondb/decorators/text/index.d.ts
|
|
index 330f187..334adbd 100644
|
|
--- a/node_modules/@nozbe/watermelondb/decorators/text/index.d.ts
|
|
+++ b/node_modules/@nozbe/watermelondb/decorators/text/index.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
import { ColumnName } from '../../Schema'
|
|
|
|
-type text = (columnName: ColumnName) => PropertyDecorator
|
|
+const text = (columnName: ColumnName) => PropertyDecorator
|
|
|
|
export default text
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt b/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
|
|
index ca31e20..b45c753 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
|
|
+++ b/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
|
|
@@ -22,6 +22,21 @@ class Database(
|
|
if (name == ":memory:" || name.contains("mode=memory")) {
|
|
context.cacheDir.delete()
|
|
File(context.cacheDir, name).path
|
|
+ } else if (name.contains("/") || name.contains("file")) {
|
|
+ // Extracts the database name from the path
|
|
+ val dbName = name.substringAfterLast("/")
|
|
+
|
|
+ // Extracts the real path where the *.db file will be created
|
|
+ val truePath = name.substringAfterLast("file://").substringBeforeLast("/")
|
|
+
|
|
+ // Creates the directory
|
|
+ if (!truePath.contains("databases")) {
|
|
+ val fileObj = File(truePath, "databases")
|
|
+ fileObj.mkdir()
|
|
+ File("${truePath}/databases", dbName).path
|
|
+ } else {
|
|
+ File(truePath, dbName).path
|
|
+ }
|
|
} else {
|
|
// On some systems there is some kind of lock on `/databases` folder ¯\_(ツ)_/¯
|
|
context.getDatabasePath("$name.db").path.replace("/databases", "")
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Database.cpp b/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
|
|
index 1a1cabf..01bbb2b 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
|
|
+++ b/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
|
|
@@ -54,6 +54,7 @@ void Database::destroy() {
|
|
const std::lock_guard<std::mutex> lock(mutex_);
|
|
|
|
if (isDestroyed_) {
|
|
+ db_->markAsDestroyed();
|
|
return;
|
|
}
|
|
isDestroyed_ = true;
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
|
|
index e740c29..6963734 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
|
|
+++ b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
|
|
@@ -67,6 +67,10 @@ void SqliteDb::destroy() {
|
|
}
|
|
}
|
|
|
|
+void SqliteDb::markAsDestroyed() {
|
|
+ isDestroyed_ = true;
|
|
+}
|
|
+
|
|
SqliteDb::~SqliteDb() {
|
|
destroy();
|
|
}
|
|
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
|
|
index 22cffa7..4b74a7f 100644
|
|
--- a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
|
|
+++ b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
|
|
@@ -11,6 +11,7 @@ public:
|
|
SqliteDb(std::string path);
|
|
~SqliteDb();
|
|
void destroy();
|
|
+ void markAsDestroyed();
|
|
|
|
sqlite3 *sqlite;
|
|
|