Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DigiGov-OSS
AuditRecordDB
Commits
d27a1daf
Commit
d27a1daf
authored
Jan 13, 2022
by
Panagiotis Skarvelis
Browse files
remove experimental nececarity
parent
ebcf2efe
Changes
17
Hide whitespace changes
Inline
Side-by-side
dist/cjs/index.d.ts
View file @
d27a1daf
import
{
AuditRecord
}
from
'
./interfaces/index
'
;
import
{
AuditRecord
}
from
'
./interfaces/index
.js
'
;
/**
* @description Use this on your app to generate and log the audit record
* @coment This is the main function of the application
...
...
dist/cjs/index.js
View file @
d27a1daf
...
...
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
generateAuditRecord
=
void
0
;
const
protocol_1
=
__importDefault
(
require
(
"
./lib/protocol
"
));
const
sequence_1
=
__importDefault
(
require
(
"
./lib/sequence
"
));
const
db_1
=
__importDefault
(
require
(
"
./lib/db
"
));
const
FileEngine_1
=
__importDefault
(
require
(
"
./lib/FileEngine
"
));
const
protocol_
js_
1
=
__importDefault
(
require
(
"
./lib/protocol
.js
"
));
const
sequence_
js_
1
=
__importDefault
(
require
(
"
./lib/sequence
.js
"
));
const
db_
js_
1
=
__importDefault
(
require
(
"
./lib/db
.js
"
));
const
FileEngine_
js_
1
=
__importDefault
(
require
(
"
./lib/FileEngine
.js
"
));
/**
* @description Use this on your app to generate and log the audit record
* @coment This is the main function of the application
...
...
@@ -20,8 +20,8 @@ const FileEngine_1 = __importDefault(require("./lib/FileEngine"));
*/
const
generateAuditRecord
=
(
auditInit
,
storagePath
=
"
/tmp
"
)
=>
{
const
auditUnit
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditUnit
)
||
"
gov.gr
"
;
const
auditTransactionId
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditTransactionId
)
||
""
+
(
0
,
sequence_1
.
default
)(
storagePath
+
"
/sequence
"
,
storagePath
+
"
/sequence
"
);
const
auditProtocol
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditProtocol
)
||
(
0
,
protocol_1
.
default
)(
storagePath
);
const
auditTransactionId
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditTransactionId
)
||
""
+
(
0
,
sequence_
js_
1
.
default
)(
storagePath
+
"
/sequence
"
,
storagePath
+
"
/sequence
"
);
const
auditProtocol
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditProtocol
)
||
(
0
,
protocol_
js_
1
.
default
)(
storagePath
);
const
auditTransactionDate
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditTransactionDate
)
||
new
Date
().
toISOString
().
split
(
'
.
'
)[
0
]
+
"
Z
"
;
const
auditUserIp
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditUserIp
)
||
process
.
env
.
HOSTIP
||
"
127.0.0.1
"
;
const
auditUserId
=
(
auditInit
===
null
||
auditInit
===
void
0
?
void
0
:
auditInit
.
auditUserId
)
||
"
system
"
;
...
...
@@ -33,7 +33,7 @@ const generateAuditRecord = (auditInit, storagePath = "/tmp") => {
auditUserIp
,
auditUserId
};
const
dbEngine
=
new
db_1
.
default
(
new
FileEngine_1
.
default
(
storagePath
));
const
dbEngine
=
new
db_
js_
1
.
default
(
new
FileEngine_
js_
1
.
default
(
storagePath
));
try
{
return
dbEngine
.
put
(
auditRecord
);
}
...
...
dist/cjs/lib/FileEngine.d.ts
View file @
d27a1daf
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
.js
'
;
/**
* @description AuditEngine implementation
* @note This class is used to implement the methods that must be implemented by the AuditEngine
...
...
dist/cjs/lib/db.d.ts
View file @
d27a1daf
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
.js
'
;
/**
* @description AuditEngine implementation
* @note This class uses AuditEngine implemetations, look at FileEngine.ts for an example
...
...
dist/cjs/lib/protocol.js
View file @
d27a1daf
...
...
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
const
sequence_1
=
__importDefault
(
require
(
"
./sequence
"
));
const
sequence_
js_
1
=
__importDefault
(
require
(
"
./sequence
.js
"
));
/**
* Generate a new protocol number
* in the format sequence/date
...
...
@@ -14,7 +14,7 @@ const sequence_1 = __importDefault(require("./sequence"));
const
protocol
=
(
protocol_path
)
=>
{
const
protocol_date
=
new
Date
().
toISOString
().
split
(
'
T
'
)[
0
];
const
path
=
`
${
protocol_path
}
/
${
protocol_date
}
.protocol.sequence`
;
const
protocol_sequence
=
(
0
,
sequence_1
.
default
)(
path
,
path
);
//Protocol starts from 1 each day.
const
protocol_sequence
=
(
0
,
sequence_
js_
1
.
default
)(
path
,
path
);
//Protocol starts from 1 each day.
let
pn
=
protocol_sequence
+
"
/
"
+
protocol_date
;
return
pn
;
};
...
...
dist/esm/index.d.ts
View file @
d27a1daf
import
{
AuditRecord
}
from
'
./interfaces/index
'
;
import
{
AuditRecord
}
from
'
./interfaces/index
.js
'
;
/**
* @description Use this on your app to generate and log the audit record
* @coment This is the main function of the application
...
...
dist/esm/index.js
View file @
d27a1daf
import
protocol
from
'
./lib/protocol
'
;
import
sequence
from
'
./lib/sequence
'
;
import
db
from
'
./lib/db
'
;
import
FileEngine
from
'
./lib/FileEngine
'
;
import
protocol
from
'
./lib/protocol
.js
'
;
import
sequence
from
'
./lib/sequence
.js
'
;
import
db
from
'
./lib/db
.js
'
;
import
FileEngine
from
'
./lib/FileEngine
.js
'
;
/**
* @description Use this on your app to generate and log the audit record
* @coment This is the main function of the application
...
...
dist/esm/lib/FileEngine.d.ts
View file @
d27a1daf
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
.js
'
;
/**
* @description AuditEngine implementation
* @note This class is used to implement the methods that must be implemented by the AuditEngine
...
...
dist/esm/lib/db.d.ts
View file @
d27a1daf
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
.js
'
;
/**
* @description AuditEngine implementation
* @note This class uses AuditEngine implemetations, look at FileEngine.ts for an example
...
...
dist/esm/lib/protocol.js
View file @
d27a1daf
import
sequence
from
'
./sequence
'
;
import
sequence
from
'
./sequence
.js
'
;
/**
* Generate a new protocol number
* in the format sequence/date
...
...
package.json
View file @
d27a1daf
...
...
@@ -26,7 +26,7 @@
},
"scripts"
:
{
"test"
:
"node --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm ./test/test.ts"
,
"testesm"
:
"node
--experimental-specifier-resolution=node
./test/test.mjs"
,
"testesm"
:
"node ./test/test.mjs"
,
"testcjs"
:
"node ./test/test.cjs"
,
"build"
:
"rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig.commonjs.json && ./setType.sh"
},
...
...
src/index.ts
View file @
d27a1daf
import
protocol
from
'
./lib/protocol
'
import
sequence
from
'
./lib/sequence
'
;
import
db
from
'
./lib/db
'
;
import
{
AuditRecord
,
FS_ERROR
}
from
'
./interfaces/index
'
;
import
FileEngine
from
'
./lib/FileEngine
'
;
import
protocol
from
'
./lib/protocol
.js
'
import
sequence
from
'
./lib/sequence
.js
'
;
import
db
from
'
./lib/db
.js
'
;
import
{
AuditRecord
,
FS_ERROR
}
from
'
./interfaces/index
.js
'
;
import
FileEngine
from
'
./lib/FileEngine
.js
'
;
/**
* @description Use this on your app to generate and log the audit record
...
...
src/lib/FileEngine.ts
View file @
d27a1daf
//Use File System as DB storage
import
fs
from
'
fs
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
.js
'
;
/**
* @description AuditEngine implementation
...
...
src/lib/db.ts
View file @
d27a1daf
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
'
;
import
{
AuditRecord
,
AuditEngine
}
from
'
../interfaces/index
.js
'
;
/**
* @description AuditEngine implementation
...
...
src/lib/protocol.ts
View file @
d27a1daf
import
sequence
from
'
./sequence
'
;
import
sequence
from
'
./sequence
.js
'
;
/**
* Generate a new protocol number
...
...
src/lib/sequence.ts
View file @
d27a1daf
import
fs
from
'
fs
'
;
import
{
FS_ERROR
}
from
'
../interfaces/index
'
;
import
{
FS_ERROR
}
from
'
../interfaces/index
.js
'
;
const
LOCK_FILE_PATH
=
"
/tmp/sequence
"
const
SEQUENCE_FILE
=
"
/tmp/sequence
"
...
...
test/test.mjs
View file @
d27a1daf
import
{
generateAuditRecord
}
from
'
../dist/esm/index
'
import
{
generateAuditRecord
}
from
'
../dist/esm/index
.js
'
const
test
=
()
=>
{
const
ar
=
generateAuditRecord
(
undefined
,
"
/tmp
"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment