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

Logger package #91

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
41df399
Initial commit
FreePhoenix888 Oct 19, 2022
7e19e10
Pass all args to insertHandler
FreePhoenix888 Oct 19, 2022
46fe1be
Add LogObject and Logtype
FreePhoenix888 Oct 19, 2022
5fe00e0
Add typeId to names
FreePhoenix888 Oct 19, 2022
916b993
Fix typo
FreePhoenix888 Oct 19, 2022
7a49b0b
Fix typo
FreePhoenix888 Oct 19, 2022
f13f819
Fix typo
FreePhoenix888 Oct 19, 2022
91940d2
Revert "Fix typo"
FreePhoenix888 Oct 19, 2022
096aa85
Fix typo
FreePhoenix888 Oct 19, 2022
6f75760
Add typeTypeId
FreePhoenix888 Oct 19, 2022
6926da7
Fix typo
FreePhoenix888 Oct 19, 2022
572280f
Fix typo
FreePhoenix888 Oct 19, 2022
2a5a68d
Add containTypeId, insert package
FreePhoenix888 Oct 19, 2022
a6b358a
Add packageTypeId
FreePhoenix888 Oct 19, 2022
aecebad
Fix typo
FreePhoenix888 Oct 19, 2022
40f7d86
Get types
FreePhoenix888 Oct 19, 2022
9bd64f6
Add types, fix typos
FreePhoenix888 Oct 19, 2022
69710a8
Fix typo
FreePhoenix888 Oct 19, 2022
387d3de
Add types, fix typos
FreePhoenix888 Oct 19, 2022
6037227
Get more types
FreePhoenix888 Oct 19, 2022
c8a287f
Add tests, update names, update handlers
FreePhoenix888 Oct 20, 2022
a5ac2bc
Use spaces
FreePhoenix888 Oct 23, 2022
36dffb4
Merge branch 'main' into logger
FreePhoenix888 Oct 30, 2022
3ec8ce1
Temporarily try to use async handler
FreePhoenix888 Oct 30, 2022
aff4e54
Remove unused code
FreePhoenix888 Oct 30, 2022
19d34f2
Install dotenv-expand
FreePhoenix888 Oct 30, 2022
c14d587
Update draft
FreePhoenix888 Nov 28, 2022
db4a1dc
Make Insert handler workable, fix typos
FreePhoenix888 Nov 30, 2022
9683e59
Make logger workable
FreePhoenix888 Dec 8, 2022
f60799e
Remove unused code
FreePhoenix888 Dec 8, 2022
4e8e220
Format
FreePhoenix888 Dec 8, 2022
3703eb8
Revert "Format"
FreePhoenix888 Dec 8, 2022
0a15b88
Format
FreePhoenix888 Dec 8, 2022
666448c
Store package name in the global const
FreePhoenix888 Dec 8, 2022
c707711
Rename LogObject to LogLink
FreePhoenix888 Dec 10, 2022
eade45b
Rename LogObject to LogLink
FreePhoenix888 Dec 10, 2022
0486ed2
Add logSubjectTypeId
FreePhoenix888 Dec 10, 2022
70d13c6
Rename TypeId -> TypeLinkId
FreePhoenix888 Dec 10, 2022
3bac268
Make code more readable
FreePhoenix888 Dec 10, 2022
3f21766
TypeId -> TypeLinkId
FreePhoenix888 Dec 10, 2022
7266b89
Add handlerTypeLinkId const
FreePhoenix888 Dec 10, 2022
22374b9
Change insertHandler
FreePhoenix888 Dec 10, 2022
7d358ee
Update handlers
FreePhoenix888 Dec 11, 2022
0a934d2
Merge branch 'main' into logger
FreePhoenix888 Dec 14, 2022
6ab078b
Merge branch 'main' into logger
FreePhoenix888 Dec 16, 2022
0ae8c4c
Update logger
FreePhoenix888 Dec 17, 2022
701b5cb
Update hanlers
FreePhoenix888 Dec 20, 2022
4aed4f7
Update handler
FreePhoenix888 Mar 17, 2023
ed731e9
Update reserve links count
FreePhoenix888 Mar 17, 2023
7aa7930
Rename to insert handler
FreePhoenix888 Mar 17, 2023
9eae290
Use any type
FreePhoenix888 Mar 17, 2023
ba4cfaa
Add update handler
FreePhoenix888 Mar 17, 2023
08a8c45
Use update handler
FreePhoenix888 Mar 17, 2023
75377fe
Merge branch 'main' into logger
FreePhoenix888 Apr 2, 2023
29fc543
Update logger
FreePhoenix888 Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions deep-packages/insertHandler.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const insertHandler = async ({deep,fileTypeLinkId, fileName, handlerName, handleName, triggerTypeLinkId, code, supportsId, handleOperationTypeLinkId, containTypeLinkId, packageId, handlerTypeLinkId}) => {
return await deep.insert({
type_id: fileTypeLinkId,
in: {
data: [
{
type_id: containTypeLinkId,
from_id: packageId, // before created package
string: { data: { value: fileName } },
},
{
from_id: supportsId,
type_id: handlerTypeLinkId,
in: {
data: [
{
type_id: containTypeLinkId,
from_id: packageId, // before created package
string: { data: { value: handlerName } },
},
{
type_id: handleOperationTypeLinkId,
from_id: triggerTypeLinkId,
in: {
data: [
{
type_id: containTypeLinkId,
from_id: packageId, // before created package
string: { data: { value: handleName } },
},
],
},
},
],
},
},
],
},
string: {
data: {
value: code,
},
},
});
};

exports.insertHandler = insertHandler;
85 changes: 85 additions & 0 deletions deep-packages/insertNotificationHandler.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const insertNotificationHandler = async ({deep, notificationPort, notificationRoute, portTypeId, routerListeningTypeId, routerTypeId, routerStringUseTypeId, routeTypeId, handleRouteTypeId, handlerTypeId, supportsId, containTypeId, adminId, fileTypeId, handlerName, code}) => {
return await deep.insert(
{
type_id: portTypeId,
number: {
data: { value: notificationPort },
},
in: {
data: {
type_id: routerListeningTypeId,
from: {
data: {
type_id: routerTypeId,
in: {
data: {
type_id: routerStringUseTypeId,
string: {
data: {
value:
notificationRoute,
},
},
from: {
data: {
type_id: routeTypeId,
out: {
data: {
type_id: handleRouteTypeId,
to: {
data: {
type_id: handlerTypeId,
from_id: supportsId,
in: {
data: {
type_id: containTypeId,
// from_id: deep.linkId,
from_id: adminId,
string: {
data: {
value: handlerName,
},
},
},
},
to: {
data: {
type_id: fileTypeId,
string: {
data: {
value: code,
},
},
in: {
data: {
type_id: containTypeId,
from_id: packageId,
string: {
data: {
value: handlerName,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
},
{
name: 'INSERT_HANDLE_ROUTE_HIERARCHICAL',
}
)
}

exports.insertNotificationHandler = insertNotificationHandler;
3 changes: 3 additions & 0 deletions deep-packages/sleep.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

exports.sleep = sleep;
66 changes: 66 additions & 0 deletions insert-handler.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
({ deep, data: { newLink, triggeredByLinkId } }) => {
const timestamp = Date.now();

const containTypeLinkId = deep.id('@deep-foundation/core', 'Contain');

const reservedIds = deep.reserve(2);

const logLinkInsertData = {
id: reservedIds[0],
type_id: deep.id("@deep-foundation/logger", "LogLink"),
...(newLink.from_id && {from_id: newLink.from_id}),
...(newLink.to_id && {from_id: newLink.to_id}),
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};

const logInsertInsertData = {
id: reservedIds[1],
type_id: deep.id("@deep-foundation/logger", "LogInsert"),
from_id: logLinkInsertData.id,
to_id: newLink.id,
number: timestamp, // TODO: number field must be of type MutationInsertLink or smth like this, but not number. Issue: https://github.com/deep-foundation/deeplinks/issues/80
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};

const logTypeLinkInsertData = {
type_id: deep.id("@deep-foundation/logger", "LogType"),
from_id: logLinkInsertData.id,
to_id: newLink.type_id,
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};

const logSubjectLinkInsertData = {
type_id: deep.id("@deep-foundation/logger", "LogSubject"),
from_id: triggeredByLinkId,
to_id: logInsertInsertData.id,
in: {
data: {
type_id: containTypeLinkId,
from_id: triggeredByLinkId,
},
},
};

deep.insert([
logLinkInsertData,
logInsertInsertData,
logTypeLinkInsertData,
logSubjectLinkInsertData,
logSubjectLinkInsertData
])
}
Loading