@cocreate/indexeddb 1.9.0 → 1.9.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [1.9.2](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.1...v1.9.2) (2023-05-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * apikey renamed to key ([67e767f](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/67e767ffd5b91e07d233d2e9f78cc7ee12052589))
7
+ * apikey renamed to key ([cb135a8](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/cb135a8742e6e4a92a15c8d10404e39d47995cf1))
8
+
9
+ ## [1.9.1](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.0...v1.9.1) (2023-05-10)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * duplicate keys ([e87668f](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/e87668f17412e08a1497a53acbf7ba8592b53756))
15
+
1
16
  # [1.9.0](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.8.7...v1.9.0) (2023-05-10)
2
17
 
3
18
 
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  "config": {
3
3
  "organization_id": "5ff747727005da1c272740ab",
4
- "apiKey": "2061acef-0451-4545-f754-60cf8160",
4
+ "key": "2061acef-0451-4545-f754-60cf8160",
5
5
  "host": "general.cocreate.app"
6
6
  },
7
7
  "sources": [
package/docs/index.html CHANGED
@@ -93,7 +93,7 @@
93
93
  </div>
94
94
  <script>
95
95
  var CoCreateConfig = {
96
- apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
96
+ key: '2061acef-0451-4545-f754-60cf8160',
97
97
  organization_id: '5ff747727005da1c272740ab'
98
98
  }
99
99
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/indexeddb",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "description": "A simple indexeddb component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "indexeddb",
package/src/index.js CHANGED
@@ -1016,10 +1016,14 @@ async function readDocs(data, database, collection, objectStore, direction) {
1016
1016
  });
1017
1017
  }
1018
1018
 
1019
- function generateDB(organization = {document: {}}, user = {document: {}}) {
1020
- const organization_id = organization._id || ObjectId();
1021
- const primaryKey = organization.key || uuid.generate();
1022
- const user_id = user._id || ObjectId();
1019
+ async function generateDB(organization = {document: {}}, user = {document: {}}) {
1020
+ const organization_id = organization.document._id || ObjectId();
1021
+ const primaryKey = organization.document.key || uuid.generate();
1022
+ const user_id = user.document._id || ObjectId();
1023
+
1024
+ let apiKey = await readDocument({database: organization_id, collection: 'keys', organization_id})
1025
+ if (apiKey && apiKey.document && apiKey.document[0])
1026
+ return
1023
1027
 
1024
1028
  try {
1025
1029
  // Create organization
@@ -1037,7 +1041,7 @@ function generateDB(organization = {document: {}}, user = {document: {}}) {
1037
1041
  collection: 'keys',
1038
1042
  document: {
1039
1043
  _id: ObjectId(),
1040
- type: "apikey",
1044
+ type: "key",
1041
1045
  key: primaryKey,
1042
1046
  hosts: [
1043
1047
  "*"