@cocreate/indexeddb 1.9.5 → 1.10.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.10.1](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.10.0...v1.10.1) (2023-05-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([7b42dd5](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/7b42dd5af1970d4049243691a989d8258d0a7d15))
7
+
8
+ # [1.10.0](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.5...v1.10.0) (2023-05-21)
9
+
10
+
11
+ ### Features
12
+
13
+ * Add function to generate organization, user, keys, and roles ([b8b665f](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/b8b665fc83d23d31072f0121a749e41d9f1866ed))
14
+
1
15
  ## [1.9.5](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.4...v1.9.5) (2023-05-20)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/indexeddb",
3
- "version": "1.9.5",
3
+ "version": "1.10.1",
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,8 +59,8 @@
59
59
  "webpack-log": "^3.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@cocreate/docs": "^1.7.11",
63
- "@cocreate/hosting": "^1.10.3",
62
+ "@cocreate/docs": "^1.7.12",
63
+ "@cocreate/hosting": "^1.10.4",
64
64
  "@cocreate/utils": "^1.20.9",
65
65
  "@cocreate/uuid": "^1.4.10"
66
66
  }
package/src/index.js CHANGED
@@ -1033,12 +1033,20 @@ 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 = defaultKey
1037
1036
  organization.document.name = organization.document.name || 'untitiled'
1038
1037
  organization.organization_id = organization_id
1039
1038
  createDocument(organization);
1040
1039
 
1041
- // Create primary key
1040
+ // Create user
1041
+ user.database = organization_id
1042
+ user.collection = 'users'
1043
+ user.document._id = user_id
1044
+ user.document.firstname = user.document.firstname || 'untitiled'
1045
+ user.document.lastname = user.document.lastname || 'untitiled'
1046
+ user.organization_id = organization_id
1047
+ createDocument(user);
1048
+
1049
+ // Create default key
1042
1050
  let key = {
1043
1051
  database: organization_id,
1044
1052
  collection: 'keys',
@@ -1050,11 +1058,8 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1050
1058
  "*"
1051
1059
  ],
1052
1060
  actions: {
1053
- "signIn": "",
1054
- "signUp": "",
1055
- "createOrg": "",
1056
- "runIndustry": "",
1057
- "sendgrid": ["sendEmail"]
1061
+ signIn: "",
1062
+ signUp: ""
1058
1063
  },
1059
1064
  default: true
1060
1065
  },
@@ -1062,43 +1067,36 @@ async function generateDB(organization = { document: {} }, user = { document: {}
1062
1067
  }
1063
1068
  createDocument(key);
1064
1069
 
1065
- // Create user
1066
- user.database = organization_id
1067
- user.collection = 'users'
1068
- user.document._id = user_id
1069
- user.document.firstname = user.document.firstname || 'untitiled'
1070
- user.document.lastname = user.document.lastname || 'untitiled'
1071
- user.organization_id = organization_id
1072
-
1073
- createDocument(user);
1074
-
1075
- // Create role permission
1070
+ // Create role
1076
1071
  let role_id = ObjectId();
1077
1072
  let role = {
1078
1073
  database: organization_id,
1079
1074
  collection: 'keys',
1080
1075
  document: {
1081
1076
  _id: role_id,
1082
- "type": "role",
1083
- "name": "admin",
1084
- "hosts": ["*"],
1085
- "admin": "true"
1077
+ type: "role",
1078
+ name: "admin",
1079
+ hosts: ["*"],
1080
+ admin: "true"
1086
1081
  },
1087
1082
  organization_id
1088
1083
  };
1089
1084
  createDocument(role);
1090
1085
 
1091
- // Create user permission
1086
+ // Create user key
1092
1087
  let userKey = {
1093
1088
  database: organization_id,
1094
1089
  collection: 'keys',
1095
1090
  document: {
1096
1091
  _id: ObjectId(),
1097
- "type": "user",
1098
- "key": user_id,
1099
- "roles": [role_id],
1100
- "email": user.document.email,
1101
- "password": user.document.password || btoa('0000')
1092
+ type: "user",
1093
+ key: user_id,
1094
+ roles: [role_id],
1095
+ email: user.document.email,
1096
+ password: user.document.password || btoa('0000'),
1097
+ user: {
1098
+ collection: 'users' // could be any collection
1099
+ }
1102
1100
  },
1103
1101
  organization_id
1104
1102
  };