@cocreate/indexeddb 1.9.5 → 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 +7 -0
- package/package.json +1 -1
- package/src/index.js +26 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
## [1.9.5](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.4...v1.9.5) (2023-05-20)
|
|
2
9
|
|
|
3
10
|
|
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.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
|
|
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
|
-
|
|
1054
|
-
|
|
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
|
|
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
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
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
|
|
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
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
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
|
};
|