@cocreate/organizations 1.30.1 → 1.31.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.
@@ -1,8 +1,10 @@
1
1
  name: Automated Workflow
2
+
2
3
  on:
3
4
  push:
4
5
  branches:
5
6
  - master
7
+
6
8
  jobs:
7
9
  about:
8
10
  runs-on: ubuntu-latest
@@ -18,26 +20,37 @@ jobs:
18
20
  with:
19
21
  direction: overwrite-github
20
22
  githubToken: "${{ secrets.GITHUB }}"
23
+
21
24
  release:
22
25
  runs-on: ubuntu-latest
23
26
  steps:
24
27
  - name: Checkout
25
28
  uses: actions/checkout@v4
29
+ with:
30
+ fetch-depth: 0 # Required so semantic-release can trace git tags/history
31
+
26
32
  - name: Setup Node.js
27
33
  uses: actions/setup-node@v4
28
34
  with:
29
- node-version: 22 # Required for the latest semantic-release plugins
30
- - name: Semantic Release
31
- uses: cycjimmy/semantic-release-action@v4 # Update to v4 for better Node 20+ support
32
- id: semantic
33
- with:
34
- extra_plugins: |
35
- @semantic-release/changelog
35
+ node-version: 22
36
+
37
+ - name: Install Semantic Release & Plugins
38
+ # Installs semantic-release and its plugins on the runner
39
+ run: |
40
+ npm install -g semantic-release \
41
+ @semantic-release/changelog \
42
+ @semantic-release/npm \
43
+ @semantic-release/github \
36
44
  @semantic-release/git
37
- @semantic-release/github
45
+
46
+ - name: Run Semantic Release (Native)
47
+ id: semantic
48
+ # This will automatically pick up your export default config file in the repository root
49
+ run: npx semantic-release
38
50
  env:
39
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" # Use the built-in token if possible
51
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
40
52
  NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
53
+
41
54
  outputs:
42
55
  new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
43
- new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
56
+ new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
@@ -14,8 +14,7 @@ jobs:
14
14
  env:
15
15
  DRY_RUN: ${{ github.event.inputs.dry_run }}
16
16
  GITHUB_TOKEN: "${{ secrets.GITHUB }}"
17
- NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
18
-
17
+
19
18
  steps:
20
19
  - name: Checkout
21
20
  uses: actions/checkout@v3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.31.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.31.0...v1.31.1) (2026-07-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependencies ([e32e8ce](https://github.com/CoCreate-app/CoCreate-organizations/commit/e32e8cee1d79a769caca30cbfee40b3fa155da20))
7
+
8
+ # [1.31.0](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.30.2...v1.31.0) (2026-07-17)
9
+
10
+
11
+ ### Features
12
+
13
+ * update automated workflow and release configuration for improved semantic release handling ([e7006af](https://github.com/CoCreate-app/CoCreate-organizations/commit/e7006afb922df914e900f8226217319b141b0c97))
14
+
15
+ ## [1.30.2](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.30.1...v1.30.2) (2026-07-14)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bump package versions ([5f537d5](https://github.com/CoCreate-app/CoCreate-organizations/commit/5f537d503b73450a82261b90f6c8d3c13823b991))
21
+ * remove unnecessary console logs in init function for cleaner output ([a313733](https://github.com/CoCreate-app/CoCreate-organizations/commit/a313733c05bdd7e0acfdf340fd5d9606569585e1))
22
+ * removed post install and add add packages to apprved list ([bfaaab9](https://github.com/CoCreate-app/CoCreate-organizations/commit/bfaaab9f43ebd206d381eb4f69f50a3e593b321d))
23
+ * root factory variable Module ([efad9c8](https://github.com/CoCreate-app/CoCreate-organizations/commit/efad9c80ba24e1f23d0043d82b8430221c91a9e1))
24
+ * root factory variable Module ([5d7adfe](https://github.com/CoCreate-app/CoCreate-organizations/commit/5d7adfed55c0babb462a01bef76d0392ef963f98))
25
+ * semantic version handling ([d7db5e3](https://github.com/CoCreate-app/CoCreate-organizations/commit/d7db5e316322d36cba2a2b77f556db471d23b843))
26
+ * update module export to ES6 syntax in release.config.js ([2fc0b31](https://github.com/CoCreate-app/CoCreate-organizations/commit/2fc0b312a4402c901ed6dd8050dfee513bf6e70d))
27
+ * update package.json to use ESM and restructure server/client entry points ([4705c17](https://github.com/CoCreate-app/CoCreate-organizations/commit/4705c17f683add25d260912182884e7b4616bc61))
28
+
1
29
  ## [1.30.1](https://github.com/CoCreate-app/CoCreate-organizations/compare/v1.30.0...v1.30.1) (2026-02-04)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/organizations",
3
- "version": "1.30.1",
3
+ "version": "1.31.1",
4
4
  "description": "A simple organizations component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "organizations",
@@ -16,10 +16,9 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "start": "npx webpack --config webpack.config.js",
20
- "build": "npx webpack --mode=production --config webpack.config.js",
21
- "dev": "npx webpack --config webpack.config.js --watch",
22
- "postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
19
+ "start": "webpack --config webpack.config.js",
20
+ "build": "webpack --mode=production --config webpack.config.js",
21
+ "dev": "webpack --config webpack.config.js --watch"
23
22
  },
24
23
  "repository": {
25
24
  "type": "git",
@@ -35,20 +34,42 @@
35
34
  "type": "GitHub Sponsors ❤",
36
35
  "url": "https://github.com/sponsors/CoCreate-app"
37
36
  },
38
- "main": "./src/index.js",
39
- "devDependencies": {
40
- "css-loader": "^5.1.3",
41
- "esbuild": "^0.25.2",
42
- "esbuild-loader": "^4.3.0",
43
- "mini-css-extract-plugin": "^1.5.0",
44
- "webpack": "^5.24.4",
45
- "webpack-cli": "^4.5.0",
46
- "webpack-log": "^3.0.1"
37
+ "type": "module",
38
+ "main": "./src/server.js",
39
+ "browser": "./src/client.js",
40
+ "exports": {
41
+ ".": {
42
+ "node": "./src/server.js",
43
+ "deno": "./src/server.js",
44
+ "browser": "./src/client.js",
45
+ "default": "./src/server.js"
46
+ }
47
47
  },
48
48
  "dependencies": {
49
- "@cocreate/actions": "^1.21.1",
50
- "@cocreate/config": "^1.13.1",
51
- "@cocreate/crud-client": "^1.34.2",
52
- "@cocreate/elements": "^1.42.1"
49
+ "@cocreate/actions": "^1.22.1",
50
+ "@cocreate/config": "^1.14.0",
51
+ "@cocreate/crud-client": "^1.35.0",
52
+ "@cocreate/elements": "^1.43.0"
53
+ },
54
+ "devDependencies": {
55
+ "@cocreate/webpack": "^1.6.0"
56
+ },
57
+ "allowScripts": {
58
+ "@cocreate/actions@1.21.4": true,
59
+ "@cocreate/api@1.22.5": true,
60
+ "@cocreate/config@1.13.4": true,
61
+ "@cocreate/crud-client@1.34.6": true,
62
+ "@cocreate/element-prototype@1.31.4": true,
63
+ "@cocreate/elements@1.42.9": true,
64
+ "@cocreate/filter@1.33.6": true,
65
+ "@cocreate/indexeddb@1.23.4": true,
66
+ "@cocreate/local-storage@1.16.5": true,
67
+ "@cocreate/observer@1.19.0": true,
68
+ "@cocreate/organizations@1.30.1": true,
69
+ "@cocreate/render@1.46.1": true,
70
+ "@cocreate/socket-client@1.40.5": true,
71
+ "@cocreate/utils@1.42.2": true,
72
+ "@cocreate/uuid@1.12.4": true,
73
+ "@cocreate/webpack@1.4.3": true
53
74
  }
54
75
  }
package/release.config.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  dryRun: false,
3
3
  branches: ["master"],
4
4
  plugins: [
@@ -10,12 +10,20 @@ module.exports = {
10
10
  changelogFile: "CHANGELOG.md",
11
11
  },
12
12
  ],
13
- "@semantic-release/npm",
14
- "@semantic-release/github",
13
+ "@semantic-release/npm",
15
14
  [
16
- "@semantic-release/git",
15
+ "@semantic-release/github",
17
16
  {
17
+ successComment: false,
18
+ failTitle: false,
19
+ },
20
+ ],
21
+ [
22
+ "@semantic-release/git",
23
+ {
24
+ // Only stage and commit the changelog and package.json
18
25
  assets: ["CHANGELOG.md", "package.json"],
26
+ message: "chore(release): ${nextRelease.version} [skip ci]",
19
27
  },
20
28
  ],
21
29
  ],
package/src/server.js CHANGED
@@ -1,207 +1,266 @@
1
- class CoCreateOrganization {
2
- constructor(crud) {
3
- this.wsManager = crud.wsManager;
4
- this.crud = crud;
5
- this.platformSocket = {
6
- config: {
7
- organization_id: process.env.organization_id
8
- }
9
- };
10
- this.init();
11
- }
12
-
13
- init() {
14
- if (this.wsManager) {
15
- this.wsManager.on("createOrganization", (data) =>
16
- this.createOrganization(data)
17
- );
18
- this.wsManager.on("createEnvironments", (data) =>
19
- this.createEnvironments(data)
20
- );
21
- }
22
- }
23
-
24
- async createOrganization(data) {
25
- try {
26
- const { organization, user, key } = data;
27
-
28
- if (
29
- !organization ||
30
- !organization._id ||
31
- !organization.host ||
32
- !organization.host[0] ||
33
- !organization.host[0].name
34
- ) {
35
- this.errorHandler(
36
- data,
37
- "invalid_organization: missing required organization fields"
38
- );
39
- }
40
-
41
- if (!user || !user._id || !user.email || !user.password) {
42
- this.errorHandler(
43
- data,
44
- "invalid_user: missing required user fields"
45
- );
46
- }
47
-
48
- if (!key || !Array.isArray(key) || key.length < 4) {
49
- this.errorHandler(
50
- data,
51
- "invalid_key: An array of 4 keys is required with type key, user and role."
52
- );
53
- }
54
-
55
- // If there are validation errors, include them in the response and send immediately
56
- if (data.success === false) {
57
- return this.wsManager.send(data);
58
- }
59
-
60
- const Data = {};
61
- Data.method = "object.update";
62
- Data.host = organization.host[0].name;
63
- Data.database = [organization._id];
64
- Data.organization_id = organization._id;
65
- Data.upsert = true;
66
- if (organization) {
67
- organization.organization_id = organization._id;
68
- const response = await this.crud.send({
69
- ...Data,
70
- array: "organizations",
71
- object: organization
72
- });
73
- if (response.error) {
74
- this.errorHandler(data, response.error);
75
- }
76
- }
77
- if (user) {
78
- user.organization_id = organization._id;
79
- const response = await this.crud.send({
80
- ...Data,
81
- array: "users",
82
- object: user
83
- });
84
- if (response.error) {
85
- this.errorHandler(data, response.error);
86
- }
87
- }
88
-
89
- if (key) {
90
- key.forEach(k => {
91
- k.organization_id = organization._id;
92
- });
93
- const response = await this.crud.send({
94
- ...Data,
95
- array: "keys",
96
- object: key
97
- });
98
- if (response.error) {
99
- this.errorHandler(data, response.error);
100
- }
101
- }
102
-
103
- if (data.success !== false) {
104
- data.success = true;
105
- }
106
-
107
- this.wsManager.send(data);
108
- } catch (error) {
109
- if (data.socket) {
110
- this.errorHandler(data, error);
111
- this.wsManager.send(data);
112
- }
113
- }
114
- }
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
-
201
- errorHandler(data, error) {
202
- data.success = false;
203
- this.crud.errorHandler(data, error);
204
- }
1
+ /********************************************************************************
2
+ * Copyright (C) 2023 CoCreate and Contributors.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Affero General Public License as published
6
+ * by the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ *
17
+ ********************************************************************************/
18
+
19
+ // Commercial Licensing Information:
20
+ // For commercial use of this software without the copyleft provisions of the AGPLv3,
21
+ // you must obtain a commercial license from CoCreate LLC.
22
+ // For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
23
+
24
+ import server from '@cocreate/server';
25
+
26
+ // ==========================================
27
+ // Module-Level Sandbox State (ESM Singleton Container)
28
+ // ==========================================
29
+ const platformSocket = {
30
+ config: {
31
+ organization_id: process.env.organization_id
32
+ }
33
+ };
34
+
35
+ /**
36
+ * Standard error state structure normalization helper.
37
+ */
38
+ function errorHandler(data, error) {
39
+ data.success = false;
40
+ if (server && server.crud) {
41
+ server.crud.errorHandler(data, error);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Validates, formats, and executes concurrent database creations for a new tenant organization,
47
+ * user account, and baseline authorization key sets.
48
+ */
49
+ async function createOrganization(data) {
50
+ try {
51
+ const { organization, user, key } = data;
52
+
53
+ if (
54
+ !organization ||
55
+ !organization._id ||
56
+ !organization.host ||
57
+ !organization.host[0] ||
58
+ !organization.host[0].name
59
+ ) {
60
+ errorHandler(
61
+ data,
62
+ "invalid_organization: missing required organization fields"
63
+ );
64
+ }
65
+
66
+ if (!user || !user._id || !user.email || !user.password) {
67
+ errorHandler(
68
+ data,
69
+ "invalid_user: missing required user fields"
70
+ );
71
+ }
72
+
73
+ if (!key || !Array.isArray(key) || key.length < 4) {
74
+ errorHandler(
75
+ data,
76
+ "invalid_key: An array of 4 keys is required with type key, user and role."
77
+ );
78
+ }
79
+
80
+ // If there are validation errors, include them in the response and send immediately
81
+ if (data.success === false) {
82
+ if (server && server.wsManager) {
83
+ return server.wsManager.send(data);
84
+ }
85
+ return;
86
+ }
87
+
88
+ const Data = {};
89
+ Data.method = "object.update";
90
+ Data.host = organization.host[0].name;
91
+ Data.database = [organization._id];
92
+ Data.organization_id = organization._id;
93
+ Data.upsert = true;
94
+
95
+ if (organization && server && server.crud) {
96
+ organization.organization_id = organization._id;
97
+ const response = await server.crud.send({
98
+ ...Data,
99
+ array: "organizations",
100
+ object: organization
101
+ });
102
+ if (response.error) {
103
+ errorHandler(data, response.error);
104
+ }
105
+ }
106
+
107
+ if (user && server && server.crud) {
108
+ user.organization_id = organization._id;
109
+ const response = await server.crud.send({
110
+ ...Data,
111
+ array: "users",
112
+ object: user
113
+ });
114
+ if (response.error) {
115
+ errorHandler(data, response.error);
116
+ }
117
+ }
118
+
119
+ if (key && server && server.crud) {
120
+ key.forEach(k => {
121
+ k.organization_id = organization._id;
122
+ });
123
+ const response = await server.crud.send({
124
+ ...Data,
125
+ array: "keys",
126
+ object: key
127
+ });
128
+ if (response.error) {
129
+ errorHandler(data, response.error);
130
+ }
131
+ }
132
+
133
+ if (data.success !== false) {
134
+ data.success = true;
135
+ }
136
+
137
+ if (server && server.wsManager) {
138
+ server.wsManager.send(data);
139
+ }
140
+ } catch (error) {
141
+ if (data.socket) {
142
+ errorHandler(data, error);
143
+ if (server && server.wsManager) {
144
+ server.wsManager.send(data);
145
+ }
146
+ }
147
+ }
205
148
  }
206
149
 
207
- module.exports = CoCreateOrganization;
150
+ /**
151
+ * Orchestrates multi-tenant database clone mappings and environment setup across specific domain hosts.
152
+ */
153
+ async function createEnvironments(data) {
154
+ try {
155
+ let { organization, hostname } = data;
156
+
157
+ if (!organization) {
158
+ errorHandler(
159
+ data,
160
+ "Missing required field: 'organization'. Please provide the organization object to create an organization."
161
+ );
162
+ }
163
+ if (!hostname) {
164
+ errorHandler(
165
+ data,
166
+ "Missing required field: 'hostname'. Please provide the hostname to create an organization."
167
+ );
168
+ }
169
+
170
+ // If there are validation errors, include them in the response and send immediately
171
+ if (data.success === false) {
172
+ if (server && server.wsManager) {
173
+ return server.wsManager.send(data);
174
+ }
175
+ return;
176
+ }
177
+
178
+ const Data = {};
179
+ Data.method = "object.read";
180
+ Data.host = hostname;
181
+ Data.organization_id = organization;
182
+ Data.$filter = { limit: 0 };
183
+
184
+ if (server && server.crud) {
185
+ let organizations = await server.crud.send({
186
+ ...Data,
187
+ array: "organizations",
188
+ object: []
189
+ });
190
+
191
+ if (organizations.error) {
192
+ errorHandler(data, organizations.error);
193
+ }
194
+
195
+ let users = await server.crud.send({
196
+ ...Data,
197
+ array: "users",
198
+ object: []
199
+ });
200
+
201
+ if (users.error) {
202
+ errorHandler(data, users.error);
203
+ }
204
+
205
+ let keys = await server.crud.send({
206
+ ...Data,
207
+ array: "keys",
208
+ object: []
209
+ });
210
+
211
+ if (keys.error) {
212
+ errorHandler(data, keys.error);
213
+ }
214
+
215
+ for (let host of hostname) {
216
+ organizations.method = "object.create";
217
+ organizations.host = host;
218
+ organizations = await server.crud.send(organizations);
219
+
220
+ users.method = "object.create";
221
+ users.host = host;
222
+ users = await server.crud.send(users);
223
+
224
+ keys.method = "object.create";
225
+ keys.host = host;
226
+ keys = await server.crud.send(keys);
227
+ }
228
+ }
229
+
230
+ if (data.success !== false) {
231
+ data.success = true;
232
+ }
233
+
234
+ if (server && server.wsManager) {
235
+ server.wsManager.send(data);
236
+ }
237
+ } catch (error) {
238
+ if (data.socket) {
239
+ errorHandler(data, error);
240
+ if (server && server.wsManager) {
241
+ server.wsManager.send(data);
242
+ }
243
+ }
244
+ }
245
+ }
246
+
247
+ /**
248
+ * Auto-initialization loop.
249
+ * Silently polls to verify that the unified server orchestrator is fully loaded,
250
+ * and that both the database (crud) and socket manager (wsManager) have completed
251
+ * their initial handshakes, then attaches active organization creation listeners.
252
+ */
253
+ function init() {
254
+ if (server && server.isInitialized && server.crud && server.wsManager) {
255
+ server.wsManager.on("createOrganization", (data) => createOrganization(data));
256
+ server.wsManager.on("createEnvironments", (data) => createEnvironments(data));
257
+ } else {
258
+ // If the shared WebSocket manager has not yet populated, check again in 500ms
259
+ setTimeout(init, 500);
260
+ }
261
+ }
262
+
263
+ // Auto-execute initialization instantly upon module load
264
+ init();
265
+
266
+ export default init;
package/src/index.js DELETED
@@ -1,14 +0,0 @@
1
- (function (root, factory) {
2
- if (typeof define === 'function' && define.amd) {
3
- define(["./client"], function(CoCreateOrganization) {
4
- return factory(CoCreateOrganization)
5
- });
6
- } else if (typeof module === 'object' && module.exports) {
7
- const CoCreateOrganization = require("./server.js")
8
- module.exports = factory(CoCreateOrganization);
9
- } else {
10
- root.returnExports = factory(root["./client.js"]);
11
- }
12
- }(typeof self !== 'undefined' ? self : this, function (CoCreateOrganization) {
13
- return CoCreateOrganization;
14
- }));