@cocreate/organizations 1.29.0 → 1.30.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/.github/workflows/automated.yml +5 -6
- package/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/client.js +37 -9
- package/src/server.js +98 -5
|
@@ -22,13 +22,13 @@ jobs:
|
|
|
22
22
|
runs-on: ubuntu-latest
|
|
23
23
|
steps:
|
|
24
24
|
- name: Checkout
|
|
25
|
-
uses: actions/checkout@
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
26
|
- name: Setup Node.js
|
|
27
|
-
uses: actions/setup-node@
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
28
|
with:
|
|
29
|
-
node-version:
|
|
29
|
+
node-version: 22 # Required for the latest semantic-release plugins
|
|
30
30
|
- name: Semantic Release
|
|
31
|
-
uses: cycjimmy/semantic-release-action@
|
|
31
|
+
uses: cycjimmy/semantic-release-action@v4 # Update to v4 for better Node 20+ support
|
|
32
32
|
id: semantic
|
|
33
33
|
with:
|
|
34
34
|
extra_plugins: |
|
|
@@ -36,9 +36,8 @@ jobs:
|
|
|
36
36
|
@semantic-release/git
|
|
37
37
|
@semantic-release/github
|
|
38
38
|
env:
|
|
39
|
-
GITHUB_TOKEN: "${{ secrets.
|
|
39
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Use the built-in token if possible
|
|
40
40
|
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
41
41
|
outputs:
|
|
42
42
|
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
43
43
|
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
44
|
-
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.30.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.30.0...v1.30.1) (2026-02-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update amin key ([2d92d4c](https://github.com/CoCreate-app/CoCreate-organizations/commit/2d92d4c18cb6cf3e79894f986e142fc7dcee51d2))
|
|
7
|
+
* update worklow ([4c1dd50](https://github.com/CoCreate-app/CoCreate-organizations/commit/4c1dd50724a8eff8ea0052875eb5c7ffb28cd369))
|
|
8
|
+
|
|
9
|
+
# [1.30.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.29.0...v1.30.0) (2025-09-20)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add createEnvironment function and enhance createEnvironments handling ([d8e28f9](https://github.com/CoCreate-app/CoCreate-organizations/commit/d8e28f9ef032783f73e31a1a811643cb49a3c32e))
|
|
15
|
+
|
|
1
16
|
# [1.29.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.28.5...v1.29.0) (2025-09-07)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -50,15 +50,7 @@ async function generateDB(organization = {}, user = {}, key = []) {
|
|
|
50
50
|
_id: Crud.ObjectId().toString(),
|
|
51
51
|
type: "key",
|
|
52
52
|
key: uuid.generate(),
|
|
53
|
-
|
|
54
|
-
object: {
|
|
55
|
-
"*": {
|
|
56
|
-
$array: {
|
|
57
|
-
files: true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
53
|
+
admin: "true"
|
|
62
54
|
};
|
|
63
55
|
|
|
64
56
|
// Create role
|
|
@@ -285,6 +277,35 @@ async function create(action) {
|
|
|
285
277
|
);
|
|
286
278
|
}
|
|
287
279
|
|
|
280
|
+
async function createEnvironment(action) {
|
|
281
|
+
let form = action.form;
|
|
282
|
+
if (!form) return;
|
|
283
|
+
|
|
284
|
+
let organization = form.querySelector("#organization");
|
|
285
|
+
if (organization) {
|
|
286
|
+
organization = organization.value;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
let hostname = form.querySelector("#hostname");
|
|
290
|
+
if (hostname) {
|
|
291
|
+
hostname = hostname.value;
|
|
292
|
+
hostname = ["dev." + hostname, "test." + hostname];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let response = await Crud.socket.send({
|
|
296
|
+
method: "createEnvironments",
|
|
297
|
+
organization,
|
|
298
|
+
hostname,
|
|
299
|
+
broadcastBrowser: false
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
action.element.dispatchEvent(
|
|
303
|
+
new CustomEvent("createdEnvironments", {
|
|
304
|
+
detail: response
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
288
309
|
Action.init({
|
|
289
310
|
name: "createOrganization",
|
|
290
311
|
endEvent: "createdOrganization",
|
|
@@ -292,5 +313,12 @@ Action.init({
|
|
|
292
313
|
create(action);
|
|
293
314
|
}
|
|
294
315
|
});
|
|
316
|
+
Action.init({
|
|
317
|
+
name: "createEnvironments",
|
|
318
|
+
endEvent: "createdEnvironments",
|
|
319
|
+
callback: (action) => {
|
|
320
|
+
createEnvironment(action);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
295
323
|
|
|
296
324
|
export default { generateDB, create, get };
|
package/src/server.js
CHANGED
|
@@ -15,6 +15,9 @@ class CoCreateOrganization {
|
|
|
15
15
|
this.wsManager.on("createOrganization", (data) =>
|
|
16
16
|
this.createOrganization(data)
|
|
17
17
|
);
|
|
18
|
+
this.wsManager.on("createEnvironments", (data) =>
|
|
19
|
+
this.createEnvironments(data)
|
|
20
|
+
);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -42,10 +45,10 @@ class CoCreateOrganization {
|
|
|
42
45
|
);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
if (!key || !Array.isArray(key) || key.length
|
|
48
|
+
if (!key || !Array.isArray(key) || key.length < 4) {
|
|
46
49
|
this.errorHandler(
|
|
47
50
|
data,
|
|
48
|
-
"invalid_key: An array of
|
|
51
|
+
"invalid_key: An array of 4 keys is required with type key, user and role."
|
|
49
52
|
);
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -55,12 +58,13 @@ class CoCreateOrganization {
|
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
const Data = {};
|
|
58
|
-
Data.method = "object.
|
|
61
|
+
Data.method = "object.update";
|
|
59
62
|
Data.host = organization.host[0].name;
|
|
60
|
-
Data.database = [organization._id
|
|
63
|
+
Data.database = [organization._id];
|
|
61
64
|
Data.organization_id = organization._id;
|
|
62
|
-
|
|
65
|
+
Data.upsert = true;
|
|
63
66
|
if (organization) {
|
|
67
|
+
organization.organization_id = organization._id;
|
|
64
68
|
const response = await this.crud.send({
|
|
65
69
|
...Data,
|
|
66
70
|
array: "organizations",
|
|
@@ -71,6 +75,7 @@ class CoCreateOrganization {
|
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
if (user) {
|
|
78
|
+
user.organization_id = organization._id;
|
|
74
79
|
const response = await this.crud.send({
|
|
75
80
|
...Data,
|
|
76
81
|
array: "users",
|
|
@@ -82,6 +87,9 @@ class CoCreateOrganization {
|
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
if (key) {
|
|
90
|
+
key.forEach(k => {
|
|
91
|
+
k.organization_id = organization._id;
|
|
92
|
+
});
|
|
85
93
|
const response = await this.crud.send({
|
|
86
94
|
...Data,
|
|
87
95
|
array: "keys",
|
|
@@ -105,6 +113,91 @@ class CoCreateOrganization {
|
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
|
|
116
|
+
async createEnvironments(data) {
|
|
117
|
+
try {
|
|
118
|
+
let { organization, hostname } = data;
|
|
119
|
+
|
|
120
|
+
if (!organization) {
|
|
121
|
+
this.errorHandler(
|
|
122
|
+
data,
|
|
123
|
+
"Missing required field: 'organization'. Please provide the organization object to create an organization."
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (!hostname) {
|
|
127
|
+
this.errorHandler(
|
|
128
|
+
data,
|
|
129
|
+
"Missing required field: 'hostname'. Please provide the hostname to create an organization."
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// If there are validation errors, include them in the response and send immediately
|
|
134
|
+
if (data.success === false) {
|
|
135
|
+
return this.wsManager.send(data);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const Data = {};
|
|
139
|
+
Data.method = "object.read";
|
|
140
|
+
Data.host = hostname;
|
|
141
|
+
Data.organization_id = organization;
|
|
142
|
+
Data.$filter = { limit: 0 };
|
|
143
|
+
|
|
144
|
+
let organizations = await this.crud.send({
|
|
145
|
+
...Data,
|
|
146
|
+
array: "organizations",
|
|
147
|
+
object: []
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (organizations.error) {
|
|
151
|
+
this.errorHandler(data, organizations.error);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let users = await this.crud.send({
|
|
155
|
+
...Data,
|
|
156
|
+
array: "users",
|
|
157
|
+
object: []
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
if (users.error) {
|
|
161
|
+
this.errorHandler(data, users.error);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
let keys = await this.crud.send({
|
|
165
|
+
...Data,
|
|
166
|
+
array: "keys",
|
|
167
|
+
object: []
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (keys.error) {
|
|
171
|
+
this.errorHandler(data, keys.error);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
for (let host of hostname) {
|
|
175
|
+
organizations.method = "object.create";
|
|
176
|
+
organizations.host = host;
|
|
177
|
+
organizations = await this.crud.send(organizations);
|
|
178
|
+
|
|
179
|
+
users.method = "object.create";
|
|
180
|
+
users.host = host;
|
|
181
|
+
users = await this.crud.send(users);
|
|
182
|
+
|
|
183
|
+
keys.method = "object.create";
|
|
184
|
+
keys.host = host;
|
|
185
|
+
keys = await this.crud.send(keys);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (data.success !== false) {
|
|
189
|
+
data.success = true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.wsManager.send(data);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if (data.socket) {
|
|
195
|
+
this.errorHandler(data, error);
|
|
196
|
+
this.wsManager.send(data);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
108
201
|
errorHandler(data, error) {
|
|
109
202
|
data.success = false;
|
|
110
203
|
this.crud.errorHandler(data, error);
|