@buley/dash 0.0.30 → 2.1.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/README.md +82 -65
- package/dist/src/engine/ai.d.ts +10 -0
- package/dist/src/engine/ai.js +46 -0
- package/dist/src/engine/sqlite.d.ts +31 -0
- package/dist/src/engine/sqlite.js +255 -0
- package/dist/src/engine/vec_extension.d.ts +5 -0
- package/dist/src/engine/vec_extension.js +10 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/mcp/server.d.ts +8 -0
- package/dist/src/mcp/server.js +87 -0
- package/dist/src/reactivity/signal.d.ts +3 -0
- package/dist/src/reactivity/signal.js +31 -0
- package/dist/src/sync/backup.d.ts +12 -0
- package/dist/src/sync/backup.js +44 -0
- package/dist/src/sync/connection.d.ts +16 -0
- package/dist/src/sync/connection.js +29 -0
- package/dist/src/sync/provider.d.ts +11 -0
- package/dist/src/sync/provider.js +67 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +33 -31
- package/.coveralls.yml +0 -1
- package/.github/workflows/opencommit.yml +0 -33
- package/.github/workflows/testing.yml +0 -20
- package/.gitmodules +0 -0
- package/behaviors/cache.dev.js +0 -282
- package/behaviors/changes.dev.js +0 -337
- package/behaviors/collect.dev.js +0 -40
- package/behaviors/examples/async.dev.js +0 -17
- package/behaviors/firebase.dev.js +0 -283
- package/behaviors/live.dev.js +0 -67
- package/behaviors/map.dev.js +0 -54
- package/behaviors/mapreduce.dev.js +0 -68
- package/behaviors/match.dev.js +0 -66
- package/behaviors/patch.dev.js +0 -69
- package/behaviors/rest.dev.js +0 -340
- package/behaviors/shorthand.dev.js +0 -59
- package/behaviors/stats.dev.js +0 -672
- package/dist/behaviors/index.js +0 -142
- package/dist/database/index.js +0 -76
- package/dist/databases/index.js +0 -121
- package/dist/entry/index.js +0 -166
- package/dist/index.js +0 -93
- package/dist/indexes/index.js +0 -153
- package/dist/store/index.js +0 -97
- package/dist/stores/index.js +0 -90
- package/dist/utilities/index.js +0 -174
- package/documentation/database/closing.md +0 -3
- package/documentation/database/getting.md +0 -1
- package/documentation/database/opening.md +0 -5
- package/documentation/database/removing.md +0 -3
- package/documentation/databases.md +0 -21
- package/documentation/entries.md +0 -13
- package/documentation/entry/adding.md +0 -1
- package/documentation/entry/getting.md +0 -4
- package/documentation/entry/putting.md +0 -0
- package/documentation/entry/removing.md +0 -3
- package/documentation/entry/updating.md +0 -0
- package/documentation/general/security.md +0 -10
- package/documentation/general/transaction/requests.md +0 -3
- package/documentation/general/transactions.md +0 -5
- package/documentation/index/creating.md +0 -1
- package/documentation/index/getting.md +0 -1
- package/documentation/index/iterating.md +0 -1
- package/documentation/index/removing.md +0 -1
- package/documentation/indexes.md +0 -3
- package/documentation/key/cursors.md +0 -5
- package/documentation/key/range/bounds.md +0 -11
- package/documentation/key/range/direction.md +0 -1
- package/documentation/key/ranges.md +0 -3
- package/documentation/keys.md +0 -12
- package/documentation/objectstore/clearing.md +0 -1
- package/documentation/objectstore/creating.md +0 -1
- package/documentation/objectstore/getting.md +0 -1
- package/documentation/objectstore/iteration.md +0 -1
- package/documentation/objectstore/removing.md +0 -1
- package/documentation/overview.md +0 -5
- package/documentation/stores.md +0 -13
- package/jest.config.js +0 -12
- package/src/behaviors/index.ts +0 -140
- package/src/database/index.ts +0 -81
- package/src/databases/index.ts +0 -127
- package/src/entry/index.ts +0 -183
- package/src/index/index.ts +0 -61
- package/src/index.ts +0 -96
- package/src/indexes/index.ts +0 -151
- package/src/store/index.ts +0 -102
- package/src/stores/index.ts +0 -90
- package/src/utilities/index.ts +0 -349
- package/tests/behaviors/behaviors.spec.ts +0 -123
- package/tests/database/database.spec.ts +0 -177
- package/tests/databases/databases.spec.ts +0 -199
- package/tests/entry/entry.spec.ts +0 -252
- package/tests/index/index.spec.ts +0 -94
- package/tests/indexes/indexes.spec.ts +0 -203
- package/tests/store/store.spec.ts +0 -164
- package/tests/stores/stores.spec.ts +0 -148
- package/tests/utilities/clone.spec.ts +0 -48
- package/tests/utilities/cloneError.spec.ts +0 -33
- package/tests/utilities/contains.spec.ts +0 -28
- package/tests/utilities/exists.spec.ts +0 -21
- package/tests/utilities/is.spec.ts +0 -37
- package/tests/utilities/isArray.spec.ts +0 -21
- package/tests/utilities/isBoolean.spec.ts +0 -23
- package/tests/utilities/isEmpty.spec.ts +0 -45
- package/tests/utilities/isFunction.spec.ts +0 -30
- package/tests/utilities/isNumber.spec.ts +0 -29
- package/tests/utilities/isObject.spec.ts +0 -42
- package/tests/utilities/isRegEx.spec.ts +0 -33
- package/tests/utilities/isString.spec.ts +0 -25
- package/tests/utilities/isnt.spec.ts +0 -50
- package/tests/utilities/randomId.spec.ts +0 -39
- package/tests/utilities/safeApply.spec.ts +0 -49
- package/tests/utilities/safeEach.spec.ts +0 -38
- package/tests/utilities/safeIterate.spec.ts +0 -47
- package/tsconfig.json +0 -16
package/dist/behaviors/index.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.behaviorMethods = void 0;
|
|
15
|
-
/**
|
|
16
|
-
* Behavior methods
|
|
17
|
-
* @module behaviors
|
|
18
|
-
*/
|
|
19
|
-
var utilities_1 = require("./../utilities");
|
|
20
|
-
var behaviorFilters = [];
|
|
21
|
-
var behaviorActions = [];
|
|
22
|
-
var behaviorContext = {
|
|
23
|
-
clone: utilities_1.clone,
|
|
24
|
-
contains: utilities_1.contains,
|
|
25
|
-
exists: utilities_1.exists,
|
|
26
|
-
is: utilities_1.is,
|
|
27
|
-
isEmpty: utilities_1.isEmpty,
|
|
28
|
-
isnt: utilities_1.isnt,
|
|
29
|
-
isArray: utilities_1.isArray,
|
|
30
|
-
isBoolean: utilities_1.isBoolean,
|
|
31
|
-
isRegEx: utilities_1.isRegEx,
|
|
32
|
-
isFunction: utilities_1.isFunction,
|
|
33
|
-
isObject: utilities_1.isObject,
|
|
34
|
-
isNumber: utilities_1.isNumber,
|
|
35
|
-
isString: utilities_1.isString,
|
|
36
|
-
apply: utilities_1.safeApply,
|
|
37
|
-
each: utilities_1.safeEach,
|
|
38
|
-
iterate: utilities_1.safeIterate,
|
|
39
|
-
random: utilities_1.randomId,
|
|
40
|
-
api: {}
|
|
41
|
-
};
|
|
42
|
-
// Methods for managing streams of deferred objects
|
|
43
|
-
exports.behaviorMethods = {
|
|
44
|
-
/**
|
|
45
|
-
* Retrieves all behaviors.
|
|
46
|
-
* @param get_ctx The context object.
|
|
47
|
-
* @returns Promise<DashContext>
|
|
48
|
-
*/
|
|
49
|
-
get: function (get_ctx) {
|
|
50
|
-
return new Promise(function (resolve, reject) {
|
|
51
|
-
var _a;
|
|
52
|
-
try {
|
|
53
|
-
get_ctx.behaviors = (_a = get_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.indexNames;
|
|
54
|
-
(0, utilities_1.safeApply)(get_ctx.on_success, [get_ctx]);
|
|
55
|
-
resolve(get_ctx);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
get_ctx.error = (0, utilities_1.cloneError)(error);
|
|
59
|
-
(0, utilities_1.safeApply)(get_ctx.on_error, [get_ctx]);
|
|
60
|
-
reject(get_ctx);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* Adds a new behavior.
|
|
66
|
-
* @param add_ctx The context object.
|
|
67
|
-
* @returns Promise<DashContext>
|
|
68
|
-
*/
|
|
69
|
-
add: function (influence) {
|
|
70
|
-
if (Array.isArray(influence)) {
|
|
71
|
-
if (typeof influence[0] === 'function') {
|
|
72
|
-
behaviorFilters.push(influence[0]);
|
|
73
|
-
}
|
|
74
|
-
if (typeof influence[1] === 'function') {
|
|
75
|
-
behaviorActions.push(influence[1]);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (typeof influence === 'function') {
|
|
79
|
-
behaviorFilters.push(influence);
|
|
80
|
-
behaviorActions.push(influence);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
/**
|
|
84
|
-
* Removes a behavior.
|
|
85
|
-
* @param remove_ctx The context object.
|
|
86
|
-
* @returns Promise<DashContext>
|
|
87
|
-
*/
|
|
88
|
-
process: function (ctx, slug, method) {
|
|
89
|
-
return new Promise(function (resolve, reject) {
|
|
90
|
-
var count = 0;
|
|
91
|
-
var response;
|
|
92
|
-
var promisesChain = Promise.resolve(ctx); // Initial promise chain starts with the context
|
|
93
|
-
// Iterate over the behavior filters and chain them
|
|
94
|
-
(0, utilities_1.safeEach)(behaviorFilters, function (filter) {
|
|
95
|
-
promisesChain = promisesChain.then(function (context) {
|
|
96
|
-
response = (0, utilities_1.safeApply)(filter, [{ type: slug, method: method, context: context, priority: ++count }], behaviorContext);
|
|
97
|
-
return response.context || context; // Chain the next context
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
// After all filters have been processed, resolve or reject based on the final state
|
|
101
|
-
promisesChain
|
|
102
|
-
.then(function (finalContext) {
|
|
103
|
-
resolve(finalContext); // Resolve the final context
|
|
104
|
-
})
|
|
105
|
-
.catch(function (errorContext) {
|
|
106
|
-
reject(errorContext); // Reject with the error context if any filter failed
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
/**
|
|
111
|
-
* Applies user-defined behaviors to a context.
|
|
112
|
-
* @param ctx The context object.
|
|
113
|
-
* @param slug The slug.
|
|
114
|
-
* @param method The method.
|
|
115
|
-
* @param initialPromise The initial promise.
|
|
116
|
-
* @returns Promise<DashContext>
|
|
117
|
-
*/
|
|
118
|
-
applyBehaviors: function (ctx, slug, method, initialPromise) {
|
|
119
|
-
var count = 0;
|
|
120
|
-
return new Promise(function (resolve, reject) {
|
|
121
|
-
var promisesChain = initialPromise || Promise.resolve(ctx); // Start the promise chain with the initial promise or the context
|
|
122
|
-
// Iterate over the behavior actions and chain them using Promises
|
|
123
|
-
(0, utilities_1.safeEach)(behaviorActions, function (action) {
|
|
124
|
-
promisesChain = promisesChain.then(function (context) {
|
|
125
|
-
var response = (0, utilities_1.safeApply)(action, [{ type: slug, method: method, context: context, priority: ++count }], behaviorContext);
|
|
126
|
-
ctx = response.context || ctx; // Update the context if it's modified
|
|
127
|
-
slug = response.type || slug; // Update the slug if modified
|
|
128
|
-
return ctx;
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
// After chaining all actions, resolve or reject based on the final context
|
|
132
|
-
promisesChain
|
|
133
|
-
.then(function (finalContext) {
|
|
134
|
-
resolve(finalContext); // Resolve with the final context
|
|
135
|
-
})
|
|
136
|
-
.catch(function (errorContext) {
|
|
137
|
-
reject(errorContext); // Reject with the error context if any action failed
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
exports.default = __assign(__assign({}, exports.behaviorMethods), { behaviorFilters: behaviorFilters, behaviorActions: behaviorActions });
|
package/dist/database/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.databaseMethods = void 0;
|
|
4
|
-
var utilities_1 = require("../utilities");
|
|
5
|
-
exports.databaseMethods = {
|
|
6
|
-
get: function (get_ctx) {
|
|
7
|
-
return new Promise(function (resolve, reject) {
|
|
8
|
-
var _a;
|
|
9
|
-
var request = (_a = get_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.get(get_ctx.key);
|
|
10
|
-
if (!request) {
|
|
11
|
-
get_ctx.error = { message: 'Invalid object store', name: 'DashError' };
|
|
12
|
-
reject(get_ctx);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
request.onsuccess = function (event) {
|
|
16
|
-
var result = event.target.result;
|
|
17
|
-
if (!result) {
|
|
18
|
-
get_ctx.error = { message: 'missing', name: 'DashNoEntry' };
|
|
19
|
-
reject(get_ctx);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
get_ctx.entry = result;
|
|
23
|
-
resolve(get_ctx);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
request.onerror = function (event) {
|
|
27
|
-
var error = event.target.error;
|
|
28
|
-
get_ctx.error = error ? (0, utilities_1.cloneError)(error) : { message: 'Unknown error', name: 'DashError' };
|
|
29
|
-
reject(get_ctx);
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
put: function (put_ctx) {
|
|
34
|
-
return new Promise(function (resolve, reject) {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
var request = (0, utilities_1.exists)(put_ctx.key)
|
|
37
|
-
? (_a = put_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.put(put_ctx.data, put_ctx.key)
|
|
38
|
-
: (_b = put_ctx.objectstore) === null || _b === void 0 ? void 0 : _b.put(put_ctx.data);
|
|
39
|
-
if (!request) {
|
|
40
|
-
put_ctx.error = { message: 'Invalid object store', name: 'DashError' };
|
|
41
|
-
reject(put_ctx);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
request.onsuccess = function (event) {
|
|
45
|
-
put_ctx.key = event.target.result;
|
|
46
|
-
put_ctx.entry = put_ctx.data;
|
|
47
|
-
resolve(put_ctx);
|
|
48
|
-
};
|
|
49
|
-
request.onerror = function (event) {
|
|
50
|
-
var error = event.target.error;
|
|
51
|
-
put_ctx.error = error ? (0, utilities_1.cloneError)(error) : { message: 'Unknown error', name: 'DashError' };
|
|
52
|
-
reject(put_ctx);
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
remove: function (remove_ctx) {
|
|
57
|
-
return new Promise(function (resolve, reject) {
|
|
58
|
-
var _a;
|
|
59
|
-
var request = (_a = remove_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.delete(remove_ctx.key);
|
|
60
|
-
if (!request) {
|
|
61
|
-
remove_ctx.error = { message: 'Invalid object store', name: 'DashError' };
|
|
62
|
-
reject(remove_ctx);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
request.onsuccess = function () {
|
|
66
|
-
resolve(remove_ctx);
|
|
67
|
-
};
|
|
68
|
-
request.onerror = function (event) {
|
|
69
|
-
var error = event.target.error;
|
|
70
|
-
remove_ctx.error = error ? (0, utilities_1.cloneError)(error) : { message: 'Unknown error', name: 'DashError' };
|
|
71
|
-
reject(remove_ctx);
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
exports.default = exports.databaseMethods;
|
package/dist/databases/index.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Databases module.
|
|
4
|
-
* @module databases
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.databasesMethods = void 0;
|
|
8
|
-
var utilities_1 = require("../utilities");
|
|
9
|
-
// Database methods
|
|
10
|
-
exports.databasesMethods = {
|
|
11
|
-
/**
|
|
12
|
-
* Gets all databases.
|
|
13
|
-
* @param get_ctx The context object.
|
|
14
|
-
* @returns Promise<DashContext>
|
|
15
|
-
*/
|
|
16
|
-
get: function (get_ctx) {
|
|
17
|
-
return new Promise(function (resolve, reject) {
|
|
18
|
-
try {
|
|
19
|
-
get_ctx.databases = indexedDB.databases();
|
|
20
|
-
(0, utilities_1.safeApply)(get_ctx.on_success, [get_ctx]);
|
|
21
|
-
resolve(get_ctx);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
// Capture the error in the context object
|
|
25
|
-
get_ctx.error = error;
|
|
26
|
-
(0, utilities_1.safeApply)(get_ctx.on_error, [get_ctx]);
|
|
27
|
-
reject(get_ctx);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Opens a database.
|
|
33
|
-
* @param open_ctx The context object.
|
|
34
|
-
* @returns Promise<DashContext>
|
|
35
|
-
*/
|
|
36
|
-
open: function (open_ctx) {
|
|
37
|
-
return new Promise(function (resolve, reject) {
|
|
38
|
-
var request = indexedDB.open(open_ctx.database, open_ctx.version);
|
|
39
|
-
// Handle success
|
|
40
|
-
request.addEventListener('success', function (event) {
|
|
41
|
-
open_ctx.db = event.target.result;
|
|
42
|
-
resolve(open_ctx);
|
|
43
|
-
});
|
|
44
|
-
// Handle upgradeneeded event (used for setting up new object stores or changing version)
|
|
45
|
-
request.addEventListener('upgradeneeded', function (event) {
|
|
46
|
-
open_ctx.db = event.target.result;
|
|
47
|
-
if (open_ctx.on_upgrade_needed) {
|
|
48
|
-
(0, utilities_1.safeApply)(open_ctx.on_upgrade_needed, [open_ctx]);
|
|
49
|
-
}
|
|
50
|
-
resolve(open_ctx);
|
|
51
|
-
});
|
|
52
|
-
// Handle errors
|
|
53
|
-
request.addEventListener('error', function (event) {
|
|
54
|
-
open_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
55
|
-
reject(open_ctx);
|
|
56
|
-
});
|
|
57
|
-
// Handle blocked (when another connection keeps the database from opening)
|
|
58
|
-
request.addEventListener('blocked', function (event) {
|
|
59
|
-
if (open_ctx.on_blocked) {
|
|
60
|
-
(0, utilities_1.safeApply)(open_ctx.on_blocked, [open_ctx]);
|
|
61
|
-
}
|
|
62
|
-
reject(open_ctx);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
/**
|
|
67
|
-
* Deletes a database.
|
|
68
|
-
* @param delete_ctx The context object.
|
|
69
|
-
* @returns Promise<DashContext>
|
|
70
|
-
*/
|
|
71
|
-
delete: function (delete_ctx) {
|
|
72
|
-
return new Promise(function (resolve, reject) {
|
|
73
|
-
var request = indexedDB.deleteDatabase(delete_ctx.database);
|
|
74
|
-
request.addEventListener('success', function () {
|
|
75
|
-
resolve(delete_ctx);
|
|
76
|
-
});
|
|
77
|
-
request.addEventListener('error', function (event) {
|
|
78
|
-
delete_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
79
|
-
reject(delete_ctx);
|
|
80
|
-
});
|
|
81
|
-
request.addEventListener('blocked', function (event) {
|
|
82
|
-
if (delete_ctx.on_blocked) {
|
|
83
|
-
(0, utilities_1.safeApply)(delete_ctx.on_blocked, [delete_ctx]);
|
|
84
|
-
}
|
|
85
|
-
reject(delete_ctx);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
/**
|
|
90
|
-
* Closes a database.
|
|
91
|
-
* @param close_ctx The context object.
|
|
92
|
-
* @returns Promise<DashContext>
|
|
93
|
-
*/
|
|
94
|
-
close: function (close_ctx) {
|
|
95
|
-
return new Promise(function (resolve) {
|
|
96
|
-
if (close_ctx.db) {
|
|
97
|
-
close_ctx.db.close();
|
|
98
|
-
}
|
|
99
|
-
resolve(close_ctx);
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* Lists all databases.
|
|
104
|
-
* @returns Promise<IDBDatabaseInfo[]>
|
|
105
|
-
*/
|
|
106
|
-
listAll: function () {
|
|
107
|
-
return new Promise(function (resolve, reject) {
|
|
108
|
-
if ('databases' in indexedDB && typeof indexedDB.databases === 'function') {
|
|
109
|
-
indexedDB.databases().then(function (databases) {
|
|
110
|
-
resolve(databases);
|
|
111
|
-
}).catch(function (error) {
|
|
112
|
-
reject(error);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
reject(new Error("The `databases` method is not supported in this browser."));
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
exports.default = exports.databasesMethods;
|
package/dist/entry/index.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Entry methods
|
|
4
|
-
* @module entry
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.entryMethods = void 0;
|
|
8
|
-
var utilities_1 = require("../utilities");
|
|
9
|
-
// Entry methods
|
|
10
|
-
exports.entryMethods = {
|
|
11
|
-
/**
|
|
12
|
-
* Add an entry.
|
|
13
|
-
* @param add_ctx
|
|
14
|
-
* @returns Promise<DashContext>
|
|
15
|
-
*/
|
|
16
|
-
add: function (add_ctx) {
|
|
17
|
-
return new Promise(function (resolve, reject) {
|
|
18
|
-
var _a;
|
|
19
|
-
var request = (_a = add_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.add(add_ctx.data, add_ctx.key);
|
|
20
|
-
if (!request) {
|
|
21
|
-
add_ctx.error = { message: "Request object is null", name: "DashRequestError" };
|
|
22
|
-
return reject(add_ctx);
|
|
23
|
-
}
|
|
24
|
-
request.addEventListener('success', function () {
|
|
25
|
-
add_ctx.key = request.result;
|
|
26
|
-
add_ctx.entry = add_ctx.data;
|
|
27
|
-
resolve(add_ctx);
|
|
28
|
-
});
|
|
29
|
-
request.addEventListener('error', function (event) {
|
|
30
|
-
add_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
31
|
-
reject(add_ctx);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Get an entry.
|
|
37
|
-
* @param get_ctx
|
|
38
|
-
* @returns Promise<DashContext>
|
|
39
|
-
*/
|
|
40
|
-
get: function (get_ctx) {
|
|
41
|
-
return new Promise(function (resolve, reject) {
|
|
42
|
-
var request;
|
|
43
|
-
if (get_ctx.index && get_ctx.objectstore && typeof get_ctx.objectstore.index === 'function') {
|
|
44
|
-
var index = get_ctx.objectstore.index(get_ctx.index);
|
|
45
|
-
if (index && typeof index.get === 'function') {
|
|
46
|
-
request = index.get(get_ctx.key);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
get_ctx.error = { message: 'Invalid index or get method', name: 'DashInvalidIndex' };
|
|
50
|
-
return reject(get_ctx);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else if (get_ctx.objectstore && typeof get_ctx.objectstore.get === 'function') {
|
|
54
|
-
request = get_ctx.objectstore.get(get_ctx.key);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
get_ctx.error = { message: 'Invalid objectstore or get method', name: 'DashInvalidObjectStore' };
|
|
58
|
-
return reject(get_ctx);
|
|
59
|
-
}
|
|
60
|
-
if (!request) {
|
|
61
|
-
get_ctx.error = { message: "Request object is null", name: "DashRequestError" };
|
|
62
|
-
return reject(get_ctx);
|
|
63
|
-
}
|
|
64
|
-
request.addEventListener('success', function () {
|
|
65
|
-
get_ctx.entry = request.result;
|
|
66
|
-
resolve(get_ctx);
|
|
67
|
-
});
|
|
68
|
-
request.addEventListener('error', function (event) {
|
|
69
|
-
get_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
70
|
-
reject(get_ctx);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* Put an entry.
|
|
76
|
-
* @param put_ctx
|
|
77
|
-
* @returns Promise<DashContext>
|
|
78
|
-
*/
|
|
79
|
-
put: function (put_ctx) {
|
|
80
|
-
return new Promise(function (resolve, reject) {
|
|
81
|
-
var _a;
|
|
82
|
-
var request = (_a = put_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.put(put_ctx.data, put_ctx.key);
|
|
83
|
-
if (!request) {
|
|
84
|
-
put_ctx.error = { message: "Request object is null", name: "DashRequestError" };
|
|
85
|
-
return reject(put_ctx);
|
|
86
|
-
}
|
|
87
|
-
request.addEventListener('success', function () {
|
|
88
|
-
put_ctx.entry = put_ctx.data;
|
|
89
|
-
resolve(put_ctx);
|
|
90
|
-
});
|
|
91
|
-
request.addEventListener('error', function (event) {
|
|
92
|
-
put_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
93
|
-
reject(put_ctx);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
/**
|
|
98
|
-
* Remove an entry.
|
|
99
|
-
* @param remove_ctx
|
|
100
|
-
* @returns Promise<DashContext>
|
|
101
|
-
*/
|
|
102
|
-
remove: function (remove_ctx) {
|
|
103
|
-
return new Promise(function (resolve, reject) {
|
|
104
|
-
var _a;
|
|
105
|
-
var request = (_a = remove_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.delete(remove_ctx.key);
|
|
106
|
-
if (!request) {
|
|
107
|
-
remove_ctx.error = { message: "Request object is null", name: "DashRequestError" };
|
|
108
|
-
return reject(remove_ctx);
|
|
109
|
-
}
|
|
110
|
-
request.addEventListener('success', function () {
|
|
111
|
-
resolve(remove_ctx);
|
|
112
|
-
});
|
|
113
|
-
request.addEventListener('error', function (event) {
|
|
114
|
-
remove_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
115
|
-
reject(remove_ctx);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
/**
|
|
120
|
-
* Update an entry.
|
|
121
|
-
* @param update_ctx
|
|
122
|
-
* @returns Promise<DashContext>
|
|
123
|
-
*/
|
|
124
|
-
update: function (update_ctx) {
|
|
125
|
-
return new Promise(function (resolve, reject) {
|
|
126
|
-
var _a;
|
|
127
|
-
var request = (_a = update_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.put(update_ctx.data, update_ctx.key);
|
|
128
|
-
if (!request) {
|
|
129
|
-
update_ctx.error = { message: "Request object is null", name: "DashRequestError" };
|
|
130
|
-
return reject(update_ctx);
|
|
131
|
-
}
|
|
132
|
-
request.addEventListener('success', function () {
|
|
133
|
-
update_ctx.entry = update_ctx.data;
|
|
134
|
-
resolve(update_ctx);
|
|
135
|
-
});
|
|
136
|
-
request.addEventListener('error', function (event) {
|
|
137
|
-
update_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
138
|
-
reject(update_ctx);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
/**
|
|
143
|
-
* Count entries.
|
|
144
|
-
* @param count_ctx
|
|
145
|
-
* @returns Promise<DashContext>
|
|
146
|
-
*/
|
|
147
|
-
count: function (count_ctx) {
|
|
148
|
-
return new Promise(function (resolve, reject) {
|
|
149
|
-
var _a;
|
|
150
|
-
var request = (_a = count_ctx.objectstore) === null || _a === void 0 ? void 0 : _a.count(count_ctx.range);
|
|
151
|
-
if (!request) {
|
|
152
|
-
count_ctx.error = { message: "Request object is null", name: "DashRequestError" };
|
|
153
|
-
return reject(count_ctx);
|
|
154
|
-
}
|
|
155
|
-
request.addEventListener('success', function () {
|
|
156
|
-
count_ctx.amount = request.result;
|
|
157
|
-
resolve(count_ctx);
|
|
158
|
-
});
|
|
159
|
-
request.addEventListener('error', function (event) {
|
|
160
|
-
count_ctx.error = (0, utilities_1.cloneError)(event.target.error);
|
|
161
|
-
reject(count_ctx);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
exports.default = exports.entryMethods;
|
package/dist/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
▀██ ▀██
|
|
4
|
-
▄▄ ██ ▄▄▄▄ ▄▄▄▄ ██ ▄▄
|
|
5
|
-
▄▀ ▀██ ▀▀ ▄██ ██▄ ▀ ██▀ ██
|
|
6
|
-
█▄ ██ ▄█▀ ██ ▄ ▀█▄▄ ██ ██
|
|
7
|
-
▀█▄▄▀██▄ ▀█▄▄▀█▀ █▀▄▄█▀ ▄██▄ ██▄
|
|
8
|
-
|
|
9
|
-
Dash is a simple, lightweight wrapper around the IndexedDB API.
|
|
10
|
-
There are four main modules: database, store, index, and entry.
|
|
11
|
-
Each module has a get, put, and remove method.
|
|
12
|
-
The library is designed to be used in a promise chain.
|
|
13
|
-
|
|
14
|
-
Version -> 0.0.1
|
|
15
|
-
Repo -> http://github.com/buley/dash
|
|
16
|
-
Author -> Taylor Buley (@taylorbuley)
|
|
17
|
-
Copyright -> (c) 2011-2024 Taylor Buley
|
|
18
|
-
License -> MIT (https://opensource.org/licenses/MIT)
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
// Databases
|
|
22
|
-
var database_1 = require("./database");
|
|
23
|
-
var databases_1 = require("./databases");
|
|
24
|
-
// Stores
|
|
25
|
-
var store_1 = require("./store");
|
|
26
|
-
var stores_1 = require("./stores");
|
|
27
|
-
// Entries
|
|
28
|
-
var entry_1 = require("./entry");
|
|
29
|
-
var indexes_1 = require("./indexes");
|
|
30
|
-
// Behaviors
|
|
31
|
-
var behaviors_1 = require("./behaviors");
|
|
32
|
-
var dash = (function (internal) {
|
|
33
|
-
'use strict';
|
|
34
|
-
var Public = {};
|
|
35
|
-
var names = [];
|
|
36
|
-
var name;
|
|
37
|
-
// Function to safely iterate over internal API and build the Public API
|
|
38
|
-
function safeIterate(obj, callback) {
|
|
39
|
-
for (var key in obj) {
|
|
40
|
-
if (obj.hasOwnProperty(key)) {
|
|
41
|
-
callback(key, obj[key]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// Function to wrap each request (assuming wrapRequest provides promise handling or similar)
|
|
46
|
-
function wrapRequest(fnref, sig) {
|
|
47
|
-
return function () {
|
|
48
|
-
var args = [];
|
|
49
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
50
|
-
args[_i] = arguments[_i];
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
return fnref.apply(null, args);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
console.error("Error in ".concat(sig, ":"), error);
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
// Iterate over the internal API object and construct the Public API
|
|
62
|
-
safeIterate(internal, function (sig, fnref) {
|
|
63
|
-
names = sig.split('.');
|
|
64
|
-
name = names[0];
|
|
65
|
-
Public[name] = Public[name] || {};
|
|
66
|
-
Public[name][names[1]] = wrapRequest(fnref, sig);
|
|
67
|
-
});
|
|
68
|
-
return Public;
|
|
69
|
-
})({
|
|
70
|
-
'add.entry': entry_1.default.put,
|
|
71
|
-
'add.behavior': behaviors_1.default.add,
|
|
72
|
-
'clear.store': store_1.default.clear,
|
|
73
|
-
'count.entries': entry_1.default.count,
|
|
74
|
-
'get.behaviors': behaviors_1.default.get,
|
|
75
|
-
'get.database': database_1.default.get,
|
|
76
|
-
'get.databases': databases_1.default.get,
|
|
77
|
-
'get.store': store_1.default.get,
|
|
78
|
-
'get.stores': stores_1.default.get,
|
|
79
|
-
//'get.index': indexMethods.get,
|
|
80
|
-
'get.indexes': indexes_1.default.get,
|
|
81
|
-
'get.entries': entry_1.default.get,
|
|
82
|
-
'get.entry': entry_1.default.get,
|
|
83
|
-
'remove.database': database_1.default.remove,
|
|
84
|
-
'remove.entries': entry_1.default.remove,
|
|
85
|
-
//'remove.index': indexMethods.remove,
|
|
86
|
-
'remove.entry': entry_1.default.remove,
|
|
87
|
-
'remove.store': store_1.default.remove,
|
|
88
|
-
'update.entries': entry_1.default.update,
|
|
89
|
-
'update.entry': entry_1.default.put,
|
|
90
|
-
'$$': behaviors_1.default.process
|
|
91
|
-
});
|
|
92
|
-
// Export the dash library
|
|
93
|
-
exports.default = dash;
|