backlib 0.4.0-SNAPSHOT.1 → 0.4.0-SNAPSHOT.2

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Tracker to determine if a decorator is on the leaf"est" method of the class hierarchy.
3
+ */
4
+ export declare function newLeafTracer(): LeafTracer;
5
+ /**
6
+ * Ter
7
+ */
8
+ declare class LeafTracer {
9
+ private dic;
10
+ /** Returns true if this method is the leaf most method annotatio traced by this tracer */
11
+ trace(objectClass: Function, targetClass: Function, propertyKey: string): boolean;
12
+ }
13
+ export {};
package/dist/fs.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Options } from 'fast-glob';
2
+ /**
3
+ * Simplified and sorted glob function (using fast-glob) for one or more pattern from current directory or a optional cwd one.
4
+ *
5
+ * Note 1: The result will be sorted by natural directory/subdir/filename order (as a would a recursive walk)
6
+ * Note 2: When `cwd` in options, it is added to the file path i.e. `pathJoin(cwd, path)`
7
+ *
8
+ * @returns always sorted result return Promise<string[]>
9
+ */
10
+ export declare function glob(pattern: string | string[], cwdOrFastGlobOptions?: string | Options): Promise<string[]>;
11
+ /** Remove one or more files. Resolved the number of names removed */
12
+ export declare function saferRemove(names: string | string[], cwd?: string): Promise<string[]>;
@@ -0,0 +1,4 @@
1
+ export * from './decorator-leaf-tracer.js';
2
+ export * from './fs.js';
3
+ export * from './log.js';
4
+ export * from './utils.js';
package/dist/log.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ interface LogOptions<R> {
2
+ writers: LogWriter<R>[];
3
+ }
4
+ /**
5
+ * Base Log class that handle the base log management logic.
6
+ */
7
+ export declare class BaseLog<R> {
8
+ private logWriters;
9
+ constructor(opts: LogOptions<R>);
10
+ log(rec: R): Promise<void>;
11
+ }
12
+ export interface LogWriter<R> {
13
+ readonly name: string;
14
+ writeRec?(rec: R): Promise<void>;
15
+ }
16
+ /** processing file, if return true, then file will be assumed to be full processed, and will be deleted */
17
+ export declare type FileProcessor = (file: string) => Promise<boolean>;
18
+ /** Record serializer to string, which will be appended to the file. If null, record will be skipped */
19
+ export declare type RecordSerializer<R> = (rec: R) => string | null;
20
+ interface FileLogWriterOptions<R> {
21
+ /** name of the logWriter, will be used as prefix */
22
+ name: string;
23
+ /** Local directory in which the logs files will be saved */
24
+ dir: string;
25
+ /** maxCount of record before file is uploaded to destination */
26
+ maxCount: number;
27
+ /** max time (in ms) before file is uploaded to destination (which ever comes first with maxCount) */
28
+ maxTime: number;
29
+ fileProcessor?: FileProcessor;
30
+ recordSerializer?: RecordSerializer<R>;
31
+ }
32
+ export declare class FileLogWriter<R> implements LogWriter<R> {
33
+ readonly name: string;
34
+ private dir;
35
+ private maxCount;
36
+ private maxTime;
37
+ private fileProcessor?;
38
+ private recordSerializer;
39
+ private _init;
40
+ private _rev;
41
+ private count;
42
+ private nextUpload;
43
+ private lastUpload?;
44
+ private file?;
45
+ constructor(opts: FileLogWriterOptions<R>);
46
+ private init;
47
+ /** Update the revision file */
48
+ private rev;
49
+ /** IMPLEMENTATION of the FileWriter interface */
50
+ writeRec(rec: R): Promise<void>;
51
+ private endFile;
52
+ }
53
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Promise a message and return the trimmed entered value */
2
+ export declare function prompt(message: string): Promise<unknown>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backlib",
3
3
  "type": "module",
4
- "version": "0.4.0-SNAPSHOT.1",
4
+ "version": "0.4.0-SNAPSHOT.2",
5
5
  "description": "Minimalist library for backend services",
6
6
  "main": "dist/index.js",
7
7
  "typings": "dist/index.d.ts",