@oada/list-lib
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -170,3 +170,3 @@ "use strict"; | ||
//persistInterval: this.#resume ? persistInterval : 0, | ||
conn: __classPrivateFieldGet(this, _conn), | ||
conn: __classPrivateFieldGet(this, _resume) ? __classPrivateFieldGet(this, _conn) : undefined, | ||
path, | ||
@@ -451,5 +451,4 @@ tree, | ||
// Setup watch on the path | ||
const { rev } = __classPrivateFieldGet(this, _meta); | ||
if (__classPrivateFieldGet(this, _resume)) { | ||
trace(`Resuming watch from rev ${rev}`); | ||
trace('Resuming watch from rev %d', __classPrivateFieldGet(this, _meta).rev); | ||
} | ||
@@ -460,3 +459,3 @@ // Queue to handle changes in order | ||
path, | ||
rev: __classPrivateFieldGet(this, _resume) ? __classPrivateFieldGet(this, _meta).rev : rev, | ||
rev: __classPrivateFieldGet(this, _resume) ? __classPrivateFieldGet(this, _meta).rev : undefined, | ||
type: 'tree', | ||
@@ -463,0 +462,0 @@ watchCallback: (changes) => changeQueue.add(async () => { |
@@ -71,13 +71,14 @@ "use strict"; | ||
__classPrivateFieldSet(this, _timeout, setTimeout(async () => { | ||
var _a; | ||
await __classPrivateFieldGet(this, _wait); | ||
trace('Recording rev %d', __classPrivateFieldGet(this, _rev)); | ||
__classPrivateFieldSet(this, _wait, __classPrivateFieldGet(this, _conn).put({ | ||
__classPrivateFieldSet(this, _wait, Promise.resolve((_a = __classPrivateFieldGet(this, _conn)) === null || _a === void 0 ? void 0 : _a.put({ | ||
path: __classPrivateFieldGet(this, _path), | ||
tree: __classPrivateFieldGet(this, _tree), | ||
data: { rev: __classPrivateFieldGet(this, _rev) }, | ||
})); | ||
}))); | ||
}, 100)); | ||
} | ||
get rev() { | ||
return __classPrivateFieldGet(this, _rev); | ||
return __classPrivateFieldGet(this, _rev) + ''; | ||
} | ||
@@ -96,2 +97,3 @@ set rev(rev) { | ||
async setHandled(path, item) { | ||
var _a, _b; | ||
if (item) { | ||
@@ -101,11 +103,11 @@ // Merge with current info | ||
json_pointer_1.default.set(data, `/handled${path}`, item); | ||
await __classPrivateFieldGet(this, _conn).put({ | ||
await ((_a = __classPrivateFieldGet(this, _conn)) === null || _a === void 0 ? void 0 : _a.put({ | ||
path: __classPrivateFieldGet(this, _path), | ||
tree: __classPrivateFieldGet(this, _tree), | ||
data: data, | ||
}); | ||
})); | ||
} | ||
else { | ||
// Unset info? | ||
await __classPrivateFieldGet(this, _conn).delete({ path: path_1.join(__classPrivateFieldGet(this, _path), 'handled', path) }); | ||
await ((_b = __classPrivateFieldGet(this, _conn)) === null || _b === void 0 ? void 0 : _b.delete({ path: path_1.join(__classPrivateFieldGet(this, _path), 'handled', path) })); | ||
} | ||
@@ -120,2 +122,5 @@ //this.#updated = true; | ||
async handled(path) { | ||
if (!__classPrivateFieldGet(this, _conn)) { | ||
return undefined; | ||
} | ||
try { | ||
@@ -139,2 +144,7 @@ const { data } = await __classPrivateFieldGet(this, _conn).get({ | ||
try { | ||
if (!__classPrivateFieldGet(this, _conn)) { | ||
__classPrivateFieldSet(this, _rev, undefined); | ||
__classPrivateFieldGet(this, _done).call(this); | ||
return false; | ||
} | ||
// Try to get our metadata about this list | ||
@@ -141,0 +151,0 @@ try { |
{ | ||
"name": "@oada/list-lib", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "Library for processing items in an OADA list", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -294,3 +294,3 @@ import { join } from 'path'; | ||
//persistInterval: this.#resume ? persistInterval : 0, | ||
conn: this.#conn, | ||
conn: this.#resume ? this.#conn : undefined, | ||
path, | ||
@@ -614,5 +614,4 @@ tree, | ||
// Setup watch on the path | ||
const { rev } = this.#meta; | ||
if (this.#resume) { | ||
trace(`Resuming watch from rev ${rev}`); | ||
trace('Resuming watch from rev %d', this.#meta.rev); | ||
} | ||
@@ -623,3 +622,3 @@ // Queue to handle changes in order | ||
path, | ||
rev: this.#resume ? this.#meta.rev : rev, | ||
rev: this.#resume ? this.#meta.rev : undefined, | ||
type: 'tree', | ||
@@ -626,0 +625,0 @@ watchCallback: (changes) => |
@@ -54,6 +54,6 @@ import { join } from 'path'; | ||
*/ | ||
#rev = '0'; | ||
#rev? = '0'; | ||
// Where to store state | ||
#conn; | ||
#conn?; | ||
#path; | ||
@@ -67,3 +67,3 @@ #tree?: object; | ||
get rev(): string { | ||
return this.#rev; | ||
return this.#rev + ''; | ||
} | ||
@@ -89,3 +89,3 @@ set rev(rev) { | ||
await this.#conn.put({ | ||
await this.#conn?.put({ | ||
path: this.#path, | ||
@@ -97,3 +97,3 @@ tree: this.#tree, | ||
// Unset info? | ||
await this.#conn.delete({ path: join(this.#path, 'handled', path) }); | ||
await this.#conn?.delete({ path: join(this.#path, 'handled', path) }); | ||
} | ||
@@ -109,2 +109,6 @@ //this.#updated = true; | ||
async handled(path: string): Promise<Item | undefined> { | ||
if (!this.#conn) { | ||
return undefined; | ||
} | ||
try { | ||
@@ -133,5 +137,5 @@ const { data } = await this.#conn.get({ | ||
*/ | ||
tree: object | undefined; | ||
tree?: object; | ||
name: string; | ||
conn: Conn; | ||
conn?: Conn; | ||
}) { | ||
@@ -164,7 +168,9 @@ this.#conn = conn; | ||
trace('Recording rev %d', this.#rev); | ||
this.#wait = this.#conn.put({ | ||
path: this.#path, | ||
tree: this.#tree, | ||
data: { rev: this.#rev }, | ||
}); | ||
this.#wait = Promise.resolve( | ||
this.#conn?.put({ | ||
path: this.#path, | ||
tree: this.#tree, | ||
data: { rev: this.#rev } as any, | ||
}) | ||
); | ||
}, 100); | ||
@@ -181,2 +187,7 @@ } | ||
try { | ||
if (!this.#conn) { | ||
this.#rev = undefined; | ||
this.#done(); | ||
return false; | ||
} | ||
// Try to get our metadata about this list | ||
@@ -208,3 +219,3 @@ try { | ||
rev: this.#rev, | ||
}, | ||
} as any, | ||
}); | ||
@@ -211,0 +222,0 @@ this.#done(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125980
39
2760