Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use one-object argument instead of positional arguments for insertHandler #310

Open
FreePhoenix888 opened this issue Feb 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@FreePhoenix888
Copy link
Member

export const insertHandler = async (handleOperationTypeId: number, typeId: number, code: string, forceOwnerId?: number, supportsId?: number) => {
const syncTextFileTypeId = await deep.id('@deep-foundation/core', 'SyncTextFile');
const handlerJSFile = (await deep.insert({
type_id: syncTextFileTypeId,
}, { name: 'INSERT_HANDLER_JS_FILE' })).data[0];
const handlerJSFileValue = (await deep.insert({ link_id: handlerJSFile?.id, value: code }, { table: 'strings' })).data[0];
const handlerTypeId = await deep.id('@deep-foundation/core', 'Handler');
const handler = (await deep.insert({
from_id: supportsId || await deep.id('@deep-foundation/core', 'dockerSupportsJs'),
type_id: handlerTypeId,
to_id: handlerJSFile?.id,
}, { name: 'INSERT_HANDLER' })).data[0];
const containTypeId = await deep.id('@deep-foundation/core', 'Contain');
const ownerId = forceOwnerId || (await deep.id('deep', 'admin'));
const ownerContainHandler = (await deep.insert({
from_id: ownerId,
type_id: containTypeId,
to_id: handler?.id,
}, { name: 'INSERT_ADMIN_CONTAIN_HANDLER' })).data[0];
const handleOperation = (await deep.insert({
from_id: typeId,
type_id: handleOperationTypeId,
to_id: handler?.id,
}, { name: 'INSERT_INSERT_HANDLER' })).data[0];
return {
handlerId: handler?.id,
handleOperationId: handleOperation?.id,
handlerJSFileId: handlerJSFile?.id,
handlerJSFileValueId: handlerJSFileValue?.id,
ownerContainHandlerId: ownerContainHandler?.id,
};
};

Expected Using

insertHandler({
  handleOperationTypeId: 1,
  typeId: 2,
  code: 'myCode',
})

Current Using

insertHandler(1,2,'myCode')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant