@cocreate/indexeddb 1.9.4 → 1.10.0
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 +15 -0
- package/package.json +1 -1
- package/src/index.js +29 -49
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [1.10.0](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.5...v1.10.0) (2023-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add function to generate organization, user, keys, and roles ([b8b665f](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/b8b665fc83d23d31072f0121a749e41d9f1866ed))
|
|
7
|
+
|
|
8
|
+
## [1.9.5](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.4...v1.9.5) (2023-05-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Refactor organization and user document creation ([1e55ba0](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/1e55ba0e8b8b5ff096cac98e64e4d13cac7572ee))
|
|
14
|
+
* Updated dependencies to the lastest versions ([476552a](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/476552a85e3a0e16ac4da1129ae710093d0c01d6))
|
|
15
|
+
|
|
1
16
|
## [1.9.4](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.3...v1.9.4) (2023-05-19)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
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.
|
|
1037
|
-
organization.
|
|
1038
|
-
organization.organization_id = organization_id
|
|
1036
|
+
organization.document.name = organization.document.name || 'untitiled'
|
|
1037
|
+
organization.organization_id = organization_id
|
|
1039
1038
|
createDocument(organization);
|
|
1040
1039
|
|
|
1041
|
-
// Create
|
|
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',
|
|
@@ -1049,74 +1057,46 @@ async function generateDB(organization = { document: {} }, user = { document: {}
|
|
|
1049
1057
|
hosts: [
|
|
1050
1058
|
"*"
|
|
1051
1059
|
],
|
|
1052
|
-
collections: {
|
|
1053
|
-
"organizations": ["read"],
|
|
1054
|
-
"files": ["read"]
|
|
1055
|
-
},
|
|
1056
|
-
documents: {
|
|
1057
|
-
"someid": {
|
|
1058
|
-
"permissions": [""],
|
|
1059
|
-
"fieldNames": {
|
|
1060
|
-
"name": ["read"]
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
},
|
|
1064
1060
|
actions: {
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
"createOrg": "",
|
|
1068
|
-
"runIndustry": "",
|
|
1069
|
-
"sendgrid": ["sendEmail"]
|
|
1061
|
+
signIn: "",
|
|
1062
|
+
signUp: ""
|
|
1070
1063
|
},
|
|
1071
|
-
|
|
1072
|
-
default: true,
|
|
1064
|
+
default: true
|
|
1073
1065
|
},
|
|
1074
1066
|
organization_id
|
|
1075
1067
|
}
|
|
1076
1068
|
createDocument(key);
|
|
1077
1069
|
|
|
1078
|
-
// Create
|
|
1079
|
-
user.database = organization_id
|
|
1080
|
-
user.collection = 'users'
|
|
1081
|
-
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
|
|
1087
|
-
createDocument(user);
|
|
1088
|
-
|
|
1089
|
-
// Create role permission
|
|
1070
|
+
// Create role
|
|
1090
1071
|
let role_id = ObjectId();
|
|
1091
1072
|
let role = {
|
|
1092
1073
|
database: organization_id,
|
|
1093
1074
|
collection: 'keys',
|
|
1094
1075
|
document: {
|
|
1095
1076
|
_id: role_id,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
"
|
|
1099
|
-
|
|
1100
|
-
},
|
|
1101
|
-
"actions": {
|
|
1102
|
-
"*": ""
|
|
1103
|
-
},
|
|
1104
|
-
"admin": "true",
|
|
1105
|
-
"hosts": ["*"],
|
|
1077
|
+
type: "role",
|
|
1078
|
+
name: "admin",
|
|
1079
|
+
hosts: ["*"],
|
|
1080
|
+
admin: "true"
|
|
1106
1081
|
},
|
|
1107
1082
|
organization_id
|
|
1108
1083
|
};
|
|
1109
1084
|
createDocument(role);
|
|
1110
1085
|
|
|
1111
|
-
// Create user
|
|
1086
|
+
// Create user key
|
|
1112
1087
|
let userKey = {
|
|
1113
1088
|
database: organization_id,
|
|
1114
1089
|
collection: 'keys',
|
|
1115
1090
|
document: {
|
|
1116
1091
|
_id: ObjectId(),
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
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
|
+
}
|
|
1120
1100
|
},
|
|
1121
1101
|
organization_id
|
|
1122
1102
|
};
|