@cocreate/industry
Advanced tools
Comparing version 1.11.31 to 1.12.0
@@ -0,1 +1,17 @@ | ||
# [1.12.0](https://github.com/CoCreate-app/CoCreate-industry/compare/v1.11.31...v1.12.0) (2023-08-16) | ||
### Bug Fixes | ||
* Add @cocreate/utils ([f43ebb2](https://github.com/CoCreate-app/CoCreate-industry/commit/f43ebb28a694f4dc3c706dba5f555d125a8e0835)) | ||
* crud attributes renamed ([3a343ad](https://github.com/CoCreate-app/CoCreate-industry/commit/3a343ad40dcf34576dc5b12e166c3881b0ea877e)) | ||
* replace -target -selector ([ebb4a5a](https://github.com/CoCreate-app/CoCreate-industry/commit/ebb4a5aa0f94f149838b89464e7cbea4e4733569)) | ||
* updated actions callback data object ([8c07c6b](https://github.com/CoCreate-app/CoCreate-industry/commit/8c07c6bb47472a60621cc32a7c4e15091a97b41f)) | ||
* webpack.config and package.json make use of mode=production instead of process.env ([486d49b](https://github.com/CoCreate-app/CoCreate-industry/commit/486d49b14e68192ef5161a6abd10cf2736ade8bf)) | ||
### Features | ||
* name attribute and variable renamed to key ([e81565b](https://github.com/CoCreate-app/CoCreate-industry/commit/e81565b7a04cd5b51672c68b91a5d72bfa7307c9)) | ||
## [1.11.31](https://github.com/CoCreate-app/CoCreate-industry/compare/v1.11.30...v1.11.31) (2023-06-14) | ||
@@ -2,0 +18,0 @@ |
@@ -7,4 +7,4 @@ module.exports = { | ||
{ | ||
"collection": "files", | ||
"document": { | ||
"array": "files", | ||
"object": { | ||
"_id": "60135ece86c0ba24512cca3e", | ||
@@ -11,0 +11,0 @@ "name": "index.html", |
{ | ||
"name": "@cocreate/industry", | ||
"version": "1.11.31", | ||
"version": "1.12.0", | ||
"description": "An Exhaustive business app template based on vanilla javascript similar to a website template featuring websites, specialty crm, email templates for creating complex business workspace/shell. Easily configured using HTML5 attributes and/or JavaScript API.", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"start": "npx webpack --config webpack.config.js", | ||
"build": "NODE_ENV=production npx webpack --config webpack.config.js", | ||
"build": "npx webpack --mode=production --config webpack.config.js", | ||
"dev": "npx webpack --config webpack.config.js --watch", | ||
@@ -62,6 +62,7 @@ "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); } }\"" | ||
"dependencies": { | ||
"@cocreate/actions": "^1.8.31", | ||
"@cocreate/crud-client": "^1.21.23", | ||
"@cocreate/element-prototype": "^1.8.29" | ||
"@cocreate/actions": "^1.8.32", | ||
"@cocreate/crud-client": "^1.21.24", | ||
"@cocreate/element-prototype": "^1.8.30", | ||
"@cocreate/utils": "^1.21.16" | ||
} | ||
} |
import crud from '@cocreate/crud-client'; | ||
import '@cocreate/element-prototype'; | ||
import action from '@cocreate/actions'; | ||
import { checkValue } from '@cocreate/utils'; | ||
const CoCreateIndustry = { | ||
init: function() { | ||
crud.listen('createIndustry', function(data) { | ||
document.dispatchEvent(new CustomEvent('createIndustry', { | ||
detail: data | ||
})); | ||
}); | ||
init: function () { | ||
crud.listen('deleteIndustry', function(data) { | ||
document.dispatchEvent(new CustomEvent('deleteIndustry', { | ||
detail: data | ||
})); | ||
}); | ||
crud.listen('createIndustry', function (data) { | ||
document.dispatchEvent(new CustomEvent('createIndustry', { | ||
detail: data | ||
})); | ||
}); | ||
crud.listen('runIndustry', function(data) { | ||
document.dispatchEvent(new CustomEvent('runIndustry', { | ||
detail: data | ||
})); | ||
}); | ||
}, | ||
createIndustry: function(btn) { | ||
let form = btn.closest("form"); | ||
if (!form) return; | ||
let elements = form.querySelectorAll("[collection='industries'][name]"); | ||
let data = {}; | ||
elements.forEach(el => { | ||
let name = el.getAttribute('name'); | ||
let value = el.getValue(); | ||
if (!name || !value) return; | ||
data[name] = value; | ||
}); | ||
crud.listen('deleteIndustry', function (data) { | ||
document.dispatchEvent(new CustomEvent('deleteIndustry', { | ||
detail: data | ||
})); | ||
}); | ||
let industry_id = btn.getAttribute('industry_id'); | ||
if (!industry_id) { | ||
let el = btn.closest('[collection="industries"]') | ||
if (el) | ||
industry_id = el.getAttribute('document_id') | ||
} | ||
console.log('industry_id', industry_id) | ||
crud.listen('runIndustry', function (data) { | ||
document.dispatchEvent(new CustomEvent('runIndustry', { | ||
detail: data | ||
})); | ||
}); | ||
data['organization_id'] = CoCreateConfig.organization_id; | ||
// return; | ||
crud.socket.send('createIndustry', { | ||
key: CoCreateConfig.key, | ||
organization_id: CoCreateConfig.organization_id, | ||
db: CoCreateConfig.organization_id, | ||
collection: 'industries', | ||
industry_id, | ||
data, | ||
broadcastBrowser: false | ||
}); | ||
}, | ||
}, | ||
deleteIndustry: function(btn) { | ||
let industry_id = btn.getAttribute('industry_id'); | ||
if (!industry_id) { | ||
let el = btn.closest('[collection="industries"]') | ||
if (el) | ||
industry_id = el.getAttribute('document_id') | ||
else return; | ||
} | ||
crud.socket.send('deleteIndustry', { | ||
key: CoCreateConfig.key, | ||
organization_id: CoCreateConfig.organization_id, | ||
collection: 'industries', | ||
industry_id: industry_id, | ||
broadcastBrowser: false | ||
}); | ||
createIndustry: function (btn) { | ||
let form = btn.closest("form"); | ||
if (!form) return; | ||
document.dispatchEvent(new CustomEvent('deletedIndustry', { | ||
detail: {} | ||
})); | ||
}, | ||
let elements = form.querySelectorAll("[array='industries'][key]"); | ||
deleteIndustries: function(btn) { | ||
const dataTemplateid = btn.getAttribute('template_id'); | ||
if (!dataTemplateid) return; | ||
let data = {}; | ||
elements.forEach(el => { | ||
let key = el.getAttribute('key'); | ||
let value = el.getValue(); | ||
if (!key || !value) return; | ||
data[key] = value; | ||
}); | ||
const selectedEls = document.querySelectorAll(`.selected[templateid="${dataTemplateid}"]`); | ||
let industry_id = btn.getAttribute('industry_id'); | ||
if (!industry_id) { | ||
let el = btn.closest('[array="industries"]') | ||
if (el) | ||
industry_id = el.getAttribute('object') | ||
} | ||
console.log('industry_id', industry_id) | ||
selectedEls.forEach((el) => { | ||
let industry_id = el.getAttribute('document_id'); | ||
data['organization_id'] = CoCreateConfig.organization_id; | ||
if (crud.checkValue(industry_id)) { | ||
crud.socket.send('deleteIndustry', { | ||
key: CoCreateConfig.key, | ||
organization_id: CoCreateConfig.organization_id, | ||
collection: 'industries', | ||
industry_id: industry_id, | ||
}); | ||
} | ||
}); | ||
// return; | ||
crud.socket.send({ | ||
method: 'createIndustry', | ||
key: CoCreateConfig.key, | ||
organization_id: CoCreateConfig.organization_id, | ||
db: CoCreateConfig.organization_id, | ||
array: 'industries', | ||
industry_id, | ||
data, | ||
broadcastBrowser: false | ||
}); | ||
}, | ||
document.dispatchEvent(new CustomEvent('deletedIndustries', { | ||
detail: {} | ||
})); | ||
}, | ||
deleteIndustry: function (btn) { | ||
let industry_id = btn.getAttribute('industry_id'); | ||
if (!industry_id) { | ||
let el = btn.closest('[array="industries"]') | ||
if (el) | ||
industry_id = el.getAttribute('object') | ||
else return; | ||
} | ||
runIndustry: function(btn) { | ||
const form = btn.closest('form'); | ||
if (!form) return; | ||
const industrySelect = form.querySelector("cocreate-select[name='industry']"); | ||
if (industrySelect) { | ||
const industry_id = industrySelect.selectedOptions[0].getAttribute('value'); | ||
const newOrgId = industrySelect.getAttribute('document_id'); | ||
if (industry_id && newOrgId) { | ||
console.log('config', CoCreateConfig) | ||
crud.socket.send('runIndustry', { | ||
key: crud.socket.config.key, | ||
organization_id: crud.socket.config.organization_id, | ||
industry_id: industry_id, | ||
newOrg_id: newOrgId, | ||
broadcastBrowser: false | ||
// db: config.organization_id | ||
}); | ||
} | ||
} | ||
}, | ||
crud.socket.send({ | ||
method: 'deleteIndustry', | ||
key: CoCreateConfig.key, | ||
organization_id: CoCreateConfig.organization_id, | ||
array: 'industries', | ||
industry_id: industry_id, | ||
broadcastBrowser: false | ||
}); | ||
document.dispatchEvent(new CustomEvent('deletedIndustry', { | ||
detail: {} | ||
})); | ||
}, | ||
deleteIndustries: function (btn) { | ||
const dataTemplateid = btn.getAttribute('template_id'); | ||
if (!dataTemplateid) return; | ||
const selectedEls = document.querySelectorAll(`.selected[templateid="${dataTemplateid}"]`); | ||
selectedEls.forEach((el) => { | ||
let industry_id = el.getAttribute('object'); | ||
if (checkValue(industry_id)) { | ||
crud.socket.send({ | ||
method: 'deleteIndustry', | ||
key: CoCreateConfig.key, | ||
organization_id: CoCreateConfig.organization_id, | ||
array: 'industries', | ||
industry_id: industry_id, | ||
}); | ||
} | ||
}); | ||
document.dispatchEvent(new CustomEvent('deletedIndustries', { | ||
detail: {} | ||
})); | ||
}, | ||
runIndustry: function (btn) { | ||
const form = btn.closest('form'); | ||
if (!form) return; | ||
const industrySelect = form.querySelector("cocreate-select[key='industry']"); | ||
if (industrySelect) { | ||
const industry_id = industrySelect.selectedOptions[0].getAttribute('value'); | ||
const newOrgId = industrySelect.getAttribute('object'); | ||
if (industry_id && newOrgId) { | ||
console.log('config', CoCreateConfig) | ||
crud.socket.send({ | ||
method: 'runIndustry', | ||
key: crud.socket.config.key, | ||
organization_id: crud.socket.config.organization_id, | ||
industry_id: industry_id, | ||
newOrg_id: newOrgId, | ||
broadcastBrowser: false | ||
// db: config.organization_id | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
action.init({ | ||
name: "runIndustry", | ||
endEvent: "runIndustry", | ||
callback: (btn, data) => { | ||
CoCreateIndustry.runIndustry(btn); | ||
}, | ||
name: "runIndustry", | ||
endEvent: "runIndustry", | ||
callback: (data) => { | ||
CoCreateIndustry.runIndustry(data.element); | ||
}, | ||
}); | ||
action.init({ | ||
name: "createIndustry", | ||
endEvent: "createdIndustry", | ||
callback: (btn, data) => { | ||
CoCreateIndustry.createIndustry(btn); | ||
}, | ||
name: "createIndustry", | ||
endEvent: "createdIndustry", | ||
callback: (data) => { | ||
CoCreateIndustry.createIndustry(data.element); | ||
}, | ||
}); | ||
action.init({ | ||
name: "deleteIndustry", | ||
endEvent: "deletedIndustry", | ||
callback: (btn, data) => { | ||
CoCreateIndustry.deleteIndustry(btn); | ||
}, | ||
name: "deleteIndustry", | ||
endEvent: "deletedIndustry", | ||
callback: (data) => { | ||
CoCreateIndustry.deleteIndustry(data.element); | ||
}, | ||
}); | ||
action.init({ | ||
name: "deleteIndustries", | ||
endEvent: "deletedIndustries", | ||
callback: (btn, data) => { | ||
CoCreateIndustry.deleteIndustries(btn); | ||
}, | ||
name: "deleteIndustries", | ||
endEvent: "deletedIndustries", | ||
callback: (data) => { | ||
CoCreateIndustry.deleteIndustries(data.element); | ||
}, | ||
}); | ||
@@ -167,0 +172,0 @@ |
@@ -25,16 +25,17 @@ class CoCreateIndustry { | ||
let orgDocument = await this.crud.readDocument({ | ||
let orgObject = await this.crud.send({ | ||
method: 'read.object', | ||
database: organization_id, | ||
collection: 'organizations', | ||
document: { _id: organization_id }, | ||
array: 'organizations', | ||
object: { _id: organization_id }, | ||
organization_id | ||
}) | ||
orgDocument = orgDocument.document[0] | ||
orgObject = orgObject.object[0] | ||
let subdomain = orgDocument && orgDocument.host ? orgDocument.host[0] : ""; | ||
let subdomain = orgObject && orgObject.host ? orgObject.host[0] : ""; | ||
let update = { | ||
database: organization_id, | ||
collection: data.collection, | ||
document: { | ||
array: data.array, | ||
object: { | ||
...data.data, | ||
@@ -44,3 +45,3 @@ organization_data: { | ||
organization_id, | ||
key: orgDocument.key | ||
key: orgObject.key | ||
} | ||
@@ -53,22 +54,24 @@ }, | ||
if (industry_id) { | ||
update.document._id = industry_id | ||
insertResult = await this.crud.updateDocument(update) | ||
update.method = 'update.object' | ||
update.object._id = industry_id | ||
insertResult = await this.crud.send(update) | ||
await this.deleteIndustryDocuments(socket, data) | ||
await this.deleteIndustryObjects(socket, data) | ||
console.log('deleting') | ||
} else { | ||
insertResult = await this.crud.createDocument(update); | ||
industry_id = `${insertResult.document[0]._id}`; | ||
update.method = 'create.object' | ||
insertResult = await this.crud.send(update); | ||
industry_id = `${insertResult.object[0]._id}`; | ||
} | ||
//. create inustryDocuments | ||
const exclusion_collections = ["users", "organizations", "industries", "industry_documents", "crdt-transactions", "metrics"]; | ||
let collections = await this.crud.readCollection({ database: organization_id, organization_id }) | ||
collections = collections.collection | ||
for (let i = 0; i < collections.length; i++) { | ||
let collection = collections[i].name; | ||
if (exclusion_collections.indexOf(collection) > -1) { | ||
//. create inustryObjects | ||
const exclusion_arrays = ["users", "organizations", "industries", "industry_objects", "crdt-transactions", "metrics"]; | ||
let arrays = await this.crud.send({ method: 'readCollection', database: organization_id, organization_id }) | ||
arrays = arrays.array | ||
for (let i = 0; i < arrays.length; i++) { | ||
let array = arrays[i].name; | ||
if (exclusion_arrays.indexOf(array) > -1) { | ||
continue; | ||
} | ||
await self.createIndustryDocuments(collection, industry_id, organization_id, db); | ||
await self.createIndustryObjects(array, industry_id, organization_id, db); | ||
} | ||
@@ -78,5 +81,6 @@ | ||
const response = { | ||
'method': 'createIndustry', | ||
'storage': data['storage'], | ||
'collection': data.collection, | ||
'document_id': industry_id, | ||
'array': data.array, | ||
'object': industry_id, | ||
'organization_id': organization_id, | ||
@@ -87,5 +91,6 @@ 'industry_id': industry_id, | ||
} | ||
self.wsManager.send(socket, response); | ||
self.wsManager.send(socket, 'createIndustry', response); | ||
self.broadcast('createDocument', socket, response) | ||
response.method = 'create.object' | ||
self.broadcast(socket, response) | ||
@@ -97,7 +102,8 @@ } catch (error) { | ||
async createIndustryDocuments(collectionName, industryId, organizationId, targetDB) { | ||
async createIndustryObjects(arrayName, industryId, organizationId, targetDB) { | ||
try { | ||
const query = { | ||
method: 'read.object', | ||
database: organizationId, | ||
collection: collectionName, | ||
array: arrayName, | ||
organization_id: organizationId | ||
@@ -107,19 +113,20 @@ } | ||
// TODO: support for opening cursor with crud? | ||
// const documentCursor = collection.find(query); | ||
// await documentCursor.forEach(async (document) => { | ||
// const objectCursor = array.find(query); | ||
// await objectCursor.forEach(async (object) => { | ||
const documents = await this.crud.readDocument(query); | ||
for (let document of documents.document) { | ||
let documentId = document['_id'].toString(); | ||
const objects = await this.crud.send(query); | ||
for (let object of objects.object) { | ||
let objectId = object['_id'].toString(); | ||
delete document['_id']; | ||
delete object['_id']; | ||
let Data = { | ||
method: 'update.object', | ||
database: targetDB, | ||
collection: 'industry_documents', | ||
document: { | ||
array: 'industry_objects', | ||
object: { | ||
industry_data: { | ||
document_id: documentId, | ||
object: objectId, | ||
industry_id: industryId, | ||
collection: collectionName | ||
array: arrayName | ||
} | ||
@@ -129,5 +136,5 @@ }, | ||
query: [ | ||
{ name: "industry_data.document_id", value: documentId, operator: '$eq' }, | ||
{ name: "industry_data.industry_id", value: industryId, operator: '$eq' }, | ||
{ name: "industry_data.collection", value: collectionName, operator: '$eq' } | ||
{ key: "industry_data.object", value: objectId, operator: '$eq' }, | ||
{ key: "industry_data.industry_id", value: industryId, operator: '$eq' }, | ||
{ key: "industry_data.array", value: arrayName, operator: '$eq' } | ||
] | ||
@@ -139,3 +146,3 @@ }, | ||
this.crud.updateDocument(Data) | ||
this.crud.send(Data) | ||
} | ||
@@ -151,9 +158,9 @@ } | ||
const self = this; | ||
this.crud.deleteDocument({ ...data, collection: 'industries', document: { _id: data["industry_id"] } }).then((data) => { | ||
let response = { document_id: data["industry_id"], ...data } | ||
self.broadcast('deleteDocument', socket, response) | ||
this.crud.send({ ...data, method: 'delete.object', array: 'industries', object: { _id: data["industry_id"] } }).then((data) => { | ||
let response = { object: data["industry_id"], ...data } | ||
self.broadcast(socket, response) | ||
}) | ||
await this.deleteIndustryDocuments(socket, data) | ||
this.wsManager.send(socket, 'deleteIndustry', { ...response }); | ||
await this.deleteIndustryObjects(socket, data) | ||
this.wsManager.send(socket, { ...response, method: 'deleteIndustry' }); | ||
} catch (error) { | ||
@@ -164,10 +171,11 @@ console.log(error) | ||
async deleteIndustryDocuments(socket, data) { | ||
async deleteIndustryObjects(socket, data) { | ||
try { | ||
const self = this; | ||
let Data = { | ||
collection: 'industry_documents', | ||
method: 'delete.object', | ||
array: 'industry_objects', | ||
filter: { | ||
query: [ | ||
{ name: "industry_data.industry_id", value: data.industry_id, operator: '$eq' }, | ||
{ key: "industry_data.industry_id", value: data.industry_id, operator: '$eq' }, | ||
] | ||
@@ -178,4 +186,4 @@ }, | ||
this.crud.deleteDocument(Data).then((data) => { | ||
self.broadcast('deleteDocument', socket, data) | ||
this.crud.send(Data).then((data) => { | ||
self.broadcast(socket, data) | ||
}) | ||
@@ -193,4 +201,4 @@ } catch (error) { | ||
let industry = await this.crud.readDocument({ collection: 'industries', document: { _id: industry_id }, organization_id }) | ||
industry = industry.document[0] | ||
let industry = await this.crud.send({ method: 'read.object', array: 'industries', object: { _id: industry_id }, organization_id }) | ||
industry = industry.object[0] | ||
@@ -202,15 +210,16 @@ let error = null; | ||
} else { | ||
let newOrgDocument = await this.crud.readDocument({ collection: 'organizations', document: { _id: newOrg_id }, organization_id }) | ||
newOrgDocument = newOrgDocument.document[0] | ||
if (!newOrgDocument) { | ||
let newOrgObject = await this.crud.send({ method: 'read.object', array: 'organizations', object: { _id: newOrg_id }, organization_id }) | ||
newOrgObject = newOrgObject.object[0] | ||
if (!newOrgObject) { | ||
error = "Can't get organization"; | ||
} else { | ||
let new_subdomain = newOrgDocument && newOrgDocument.host ? newOrgDocument.host[0] : ""; | ||
await this.createEmptyDocumentsFromIndustry( | ||
let new_subdomain = newOrgObject && newOrgobject.host ? newOrgObject.host[0] : ""; | ||
await this.createEmptyObjectsFromIndustry( | ||
industry_id, | ||
newOrgDocument, | ||
newOrgObject, | ||
industry.organization_data || {}, | ||
new_subdomain | ||
); | ||
this.wsManager.send(socket, 'runIndustry', { | ||
this.wsManager.send(socket, { | ||
method: 'runIndustry', | ||
error: false, | ||
@@ -224,3 +233,4 @@ message: "successfuly", | ||
if (error) { | ||
this.wsManager.send(socket, 'runIndustry', { | ||
this.wsManager.send(socket, { | ||
method: 'runIndustry', | ||
error: true, | ||
@@ -234,3 +244,3 @@ message: error, | ||
async createEmptyDocumentsFromIndustry(industry_id, newOrg, orgData, new_subdomain) { | ||
async createEmptyObjectsFromIndustry(industry_id, newOrg, orgData, new_subdomain) { | ||
const newOrgId = newOrg._id.toString(); | ||
@@ -244,36 +254,36 @@ const newOrgKey = newOrg.key; | ||
let data = await this.crud.readDocument({ collection: 'industry_documents', filter: { query: [{ name: "industry_data.industry_id", value: industry_id, operator: '$eq' }] }, organization_id }) | ||
let data = await this.crud.send({ method: 'read.object', array: 'industry_objects', filter: { query: [{ key: "industry_data.industry_id", value: industry_id, operator: '$eq' }] }, organization_id }) | ||
// TODO: support for opening cursor with crud? | ||
// let documentCursor = industryDocumentsCollection.find({"industry_data.industry_id" : industry_id}) | ||
// while(await documentCursor.hasNext()) { | ||
// let document = await documentCursor.next(); | ||
for (let document of data.document) { | ||
const { collection, document_id } = document.industry_data || {} | ||
if (!collection || !document_id) { | ||
// let objectCursor = industryobjectsCollection.find({"industry_data.industry_id" : industry_id}) | ||
// while(await objectCursor.hasNext()) { | ||
// let object = await objectCursor.next(); | ||
for (let object of data.object) { | ||
const { array, object } = object.industry_data || {} | ||
if (!array || !object) { | ||
continue; | ||
} | ||
document['_id'] = this.crud.ObjectId() | ||
document['organization_id'] = newOrgId; | ||
object['_id'] = this.crud.ObjectId() | ||
object['organization_id'] = newOrgId; | ||
delete document['storage']; | ||
delete document['database']; | ||
delete document['collection']; | ||
delete document['industry_data']; | ||
delete object['storage']; | ||
delete object['database']; | ||
delete object['array']; | ||
delete object['industry_data']; | ||
//. replace subdomain | ||
for (let field in document) { | ||
for (let field in object) { | ||
if (field != '_id' && field != 'organization_id') { | ||
if (document_id && document['_id']) { | ||
document[field] = self.replaceContent(document[field], document_id, document['_id']); | ||
if (object && object['_id']) { | ||
object[field] = self.replaceContent(object[field], object, object['_id']); | ||
} | ||
if (subdomain && new_subdomain) { | ||
document[field] = self.replaceContent(document[field], subdomain, new_subdomain); | ||
object[field] = self.replaceContent(object[field], subdomain, new_subdomain); | ||
} | ||
if (newOrgId && organization_id) { | ||
document[field] = self.replaceContent(document[field], organization_id, newOrgId); | ||
object[field] = self.replaceContent(object[field], organization_id, newOrgId); | ||
} | ||
if (newOrgKey && key) { | ||
document[field] = self.replaceContent(document[field], key, newOrgKey); | ||
object[field] = self.replaceContent(object[field], key, newOrgKey); | ||
} | ||
@@ -283,3 +293,3 @@ } | ||
await this.crud.createDocument({ collection, document, organization_id: newOrgId }) | ||
await this.crud.send({ method: 'create.object', array, object, organization_id: newOrgId }) | ||
} | ||
@@ -303,4 +313,4 @@ return | ||
broadcast(component, socket, response) { | ||
this.wsManager.broadcast(socket, component, response); | ||
broadcast(socket, response) { | ||
this.wsManager.broadcast(socket, response); | ||
} | ||
@@ -307,0 +317,0 @@ } |
const path = require("path") | ||
const TerserPlugin = require("terser-webpack-plugin") | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin") | ||
let isProduction = process.env.NODE_ENV === "production" | ||
const { CleanWebpackPlugin } = require("clean-webpack-plugin") | ||
module.exports = { | ||
entry: { | ||
"CoCreate-industry": "./src/index.js", | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: isProduction ? "[name].min.js" : "[name].js", | ||
libraryTarget: "umd", | ||
libraryExport: "default", | ||
library: ["CoCreate", "industry"], | ||
globalObject: "this", | ||
}, | ||
module.exports = (env, argv) => { | ||
let isProduction = false | ||
if (argv.mode === 'production') | ||
isProduction = true | ||
plugins: [ | ||
new CleanWebpackPlugin(), | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
}), | ||
], | ||
// Default mode for Webpack is production. | ||
// Depending on mode Webpack will apply different things | ||
// on final bundle. For now we don't need production's JavaScript | ||
// minifying and other thing so let's set mode to development | ||
mode: isProduction ? "production" : "development", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.js$/, | ||
exclude: /(node_modules)/, | ||
use: { | ||
loader: "babel-loader", | ||
options: { | ||
plugins: ["@babel/plugin-transform-modules-commonjs"], | ||
}, | ||
const config = { | ||
entry: { | ||
"CoCreate-industry": "./src/index.js", | ||
}, | ||
}, | ||
{ | ||
test: /.css$/i, | ||
use: [ | ||
{ loader: "style-loader", options: { injectType: "linkTag" } }, | ||
"file-loader", | ||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: isProduction ? "[name].min.js" : "[name].js", | ||
libraryTarget: "umd", | ||
libraryExport: "default", | ||
library: ["CoCreate", "industry"], | ||
globalObject: "this", | ||
}, | ||
plugins: [ | ||
new CleanWebpackPlugin(), | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css", | ||
}), | ||
], | ||
}, | ||
], | ||
}, | ||
// Default mode for Webpack is production. | ||
// Depending on mode Webpack will apply different things | ||
// on final bundle. For now we don't need production's JavaScript | ||
// minifying and other thing so let's set mode to development | ||
mode: isProduction ? "production" : "development", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.js$/, | ||
exclude: /(node_modules)/, | ||
use: { | ||
loader: "babel-loader", | ||
options: { | ||
plugins: ["@babel/plugin-transform-modules-commonjs"], | ||
}, | ||
}, | ||
}, | ||
{ | ||
test: /.css$/i, | ||
use: [ | ||
{ loader: "style-loader", options: { injectType: "linkTag" } }, | ||
"file-loader", | ||
], | ||
}, | ||
], | ||
}, | ||
// add source map | ||
...(isProduction ? {} : { devtool: "eval-source-map" }), | ||
// add source map | ||
...(isProduction ? {} : { devtool: "eval-source-map" }), | ||
optimization: { | ||
minimize: true, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
extractComments: true, | ||
// cache: true, | ||
parallel: true, | ||
// sourceMap: true, // Must be set to true if using source-maps in production | ||
terserOptions: { | ||
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions | ||
// extractComments: 'all', | ||
compress: { | ||
drop_console: true, | ||
}, | ||
optimization: { | ||
minimize: true, | ||
minimizer: [ | ||
new TerserPlugin({ | ||
extractComments: true, | ||
// cache: true, | ||
parallel: true, | ||
// sourceMap: true, // Must be set to true if using source-maps in production | ||
terserOptions: { | ||
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions | ||
// extractComments: 'all', | ||
compress: { | ||
drop_console: true, | ||
}, | ||
}, | ||
}), | ||
], | ||
splitChunks: { | ||
chunks: "all", | ||
minSize: 200, | ||
// maxSize: 99999, | ||
//minChunks: 1, | ||
cacheGroups: { | ||
defaultVendors: false, | ||
}, | ||
}, | ||
}, | ||
}), | ||
], | ||
splitChunks: { | ||
chunks: "all", | ||
minSize: 200, | ||
// maxSize: 99999, | ||
//minChunks: 1, | ||
cacheGroups: { | ||
defaultVendors: false, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
return config | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
121172
545
0
4