@cocreate/indexeddb 1.9.3 → 1.9.5

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.5](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.4...v1.9.5) (2023-05-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Refactor organization and user document creation ([1e55ba0](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/1e55ba0e8b8b5ff096cac98e64e4d13cac7572ee))
7
+ * Updated dependencies to the lastest versions ([476552a](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/476552a85e3a0e16ac4da1129ae710093d0c01d6))
8
+
9
+ ## [1.9.4](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.3...v1.9.4) (2023-05-19)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Refactor code to use a more descriptive variable name ([ac0883d](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/ac0883dfb73b2b58fc2d942d3eda8f374bc1d800))
15
+
1
16
  ## [1.9.3](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.2...v1.9.3) (2023-05-19)
2
17
 
3
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/indexeddb",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
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",
@@ -59,9 +59,9 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/docs": "^1.7.8",
63
- "@cocreate/hosting": "^1.10.0",
64
- "@cocreate/utils": "^1.20.6",
65
- "@cocreate/uuid": "^1.4.7"
62
+ "@cocreate/docs": "^1.7.11",
63
+ "@cocreate/hosting": "^1.10.3",
64
+ "@cocreate/utils": "^1.20.9",
65
+ "@cocreate/uuid": "^1.4.10"
66
66
  }
67
67
  }
package/src/index.js CHANGED
@@ -1021,7 +1021,7 @@ async function readDocs(data, database, collection, objectStore, direction) {
1021
1021
 
1022
1022
  async function generateDB(organization = { document: {} }, user = { document: {} }) {
1023
1023
  const organization_id = organization.document._id || ObjectId();
1024
- const primaryKey = organization.document.key || uuid.generate();
1024
+ const defaultKey = organization.document.key || uuid.generate();
1025
1025
  const user_id = user.document._id || ObjectId();
1026
1026
 
1027
1027
  let apiKey = await readDocument({ database: organization_id, collection: 'keys', organization_id })
@@ -1033,9 +1033,9 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1033
1033
  organization.database = organization_id
1034
1034
  organization.collection = 'organizations'
1035
1035
  organization.document._id = organization_id
1036
- organization.document.key = primaryKey
1037
- organization.document.name = organization.document.name || 'untitiled',
1038
- organization.organization_id = organization_id
1036
+ organization.document.key = defaultKey
1037
+ organization.document.name = organization.document.name || 'untitiled'
1038
+ organization.organization_id = organization_id
1039
1039
  createDocument(organization);
1040
1040
 
1041
1041
  // Create primary key
@@ -1045,22 +1045,10 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1045
1045
  document: {
1046
1046
  _id: ObjectId(),
1047
1047
  type: "key",
1048
- key: primaryKey,
1048
+ key: defaultKey,
1049
1049
  hosts: [
1050
1050
  "*"
1051
1051
  ],
1052
- collections: {
1053
- "organizations": ["read"],
1054
- "files": ["read"]
1055
- },
1056
- documents: {
1057
- "someid": {
1058
- "permissions": [""],
1059
- "fieldNames": {
1060
- "name": ["read"]
1061
- }
1062
- }
1063
- },
1064
1052
  actions: {
1065
1053
  "signIn": "",
1066
1054
  "signUp": "",
@@ -1068,8 +1056,7 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1068
1056
  "runIndustry": "",
1069
1057
  "sendgrid": ["sendEmail"]
1070
1058
  },
1071
- admin: "false",
1072
- primary: true,
1059
+ default: true
1073
1060
  },
1074
1061
  organization_id
1075
1062
  }
@@ -1079,11 +1066,10 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1079
1066
  user.database = organization_id
1080
1067
  user.collection = 'users'
1081
1068
  user.document._id = user_id
1082
- user.document.name = user.document.name || 'untitiled',
1083
- user.document.password = user.document.password || btoa('0000'),
1084
- user.document.connected_orgs = [organization_id],
1085
- user.document.current_org = organization_id,
1086
- user.organization_id = organization_id
1069
+ user.document.firstname = user.document.firstname || 'untitiled'
1070
+ user.document.lastname = user.document.lastname || 'untitiled'
1071
+ user.organization_id = organization_id
1072
+
1087
1073
  createDocument(user);
1088
1074
 
1089
1075
  // Create role permission
@@ -1095,14 +1081,8 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1095
1081
  _id: role_id,
1096
1082
  "type": "role",
1097
1083
  "name": "admin",
1098
- "collections": {
1099
- "*": ["*"]
1100
- },
1101
- "actions": {
1102
- "*": ""
1103
- },
1104
- "admin": "true",
1105
1084
  "hosts": ["*"],
1085
+ "admin": "true"
1106
1086
  },
1107
1087
  organization_id
1108
1088
  };
@@ -1114,9 +1094,11 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1114
1094
  collection: 'keys',
1115
1095
  document: {
1116
1096
  _id: ObjectId(),
1117
- "type": "user_id",
1097
+ "type": "user",
1118
1098
  "key": user_id,
1119
- "roles": [role_id]
1099
+ "roles": [role_id],
1100
+ "email": user.document.email,
1101
+ "password": user.document.password || btoa('0000')
1120
1102
  },
1121
1103
  organization_id
1122
1104
  };