proteum 1.0.2 → 2.0.0-1

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.
Files changed (185) hide show
  1. package/AGENTS.md +101 -0
  2. package/agents/codex/AGENTS.md +95 -0
  3. package/agents/codex/CODING_STYLE.md +71 -0
  4. package/agents/codex/agents.md.zip +0 -0
  5. package/agents/codex/client/AGENTS.md +102 -0
  6. package/agents/codex/client/pages/AGENTS.md +35 -0
  7. package/agents/codex/server/routes/AGENTS.md +12 -0
  8. package/agents/codex/server/services/AGENTS.md +137 -0
  9. package/agents/codex/tests/AGENTS.md +8 -0
  10. package/cli/app/config.ts +13 -11
  11. package/cli/app/index.ts +74 -82
  12. package/cli/bin.js +1 -1
  13. package/cli/commands/build.ts +51 -14
  14. package/cli/commands/check.ts +19 -0
  15. package/cli/commands/deploy/app.ts +4 -8
  16. package/cli/commands/deploy/web.ts +16 -20
  17. package/cli/commands/dev.ts +189 -64
  18. package/cli/commands/devEvents.ts +106 -0
  19. package/cli/commands/init.ts +63 -57
  20. package/cli/commands/lint.ts +21 -0
  21. package/cli/commands/refresh.ts +18 -0
  22. package/cli/commands/typecheck.ts +18 -0
  23. package/cli/compiler/client/identite.ts +80 -53
  24. package/cli/compiler/client/index.ts +139 -213
  25. package/cli/compiler/common/bundleAnalysis.ts +94 -0
  26. package/cli/compiler/common/clientManifest.ts +67 -0
  27. package/cli/compiler/common/controllers.ts +288 -0
  28. package/cli/compiler/common/files/autres.ts +7 -18
  29. package/cli/compiler/common/files/images.ts +40 -37
  30. package/cli/compiler/common/files/style.ts +11 -22
  31. package/cli/compiler/common/generatedRouteModules.ts +368 -0
  32. package/cli/compiler/common/index.ts +31 -65
  33. package/cli/compiler/common/loaders/forbid-ssr-import.js +13 -0
  34. package/cli/compiler/common/rspackAliases.ts +13 -0
  35. package/cli/compiler/common/scripts.ts +37 -0
  36. package/cli/compiler/index.ts +781 -230
  37. package/cli/compiler/server/index.ts +59 -75
  38. package/cli/compiler/writeIfChanged.ts +21 -0
  39. package/cli/index.ts +71 -72
  40. package/cli/paths.ts +51 -57
  41. package/cli/print.ts +17 -11
  42. package/cli/tsconfig.json +5 -4
  43. package/cli/utils/agents.ts +100 -0
  44. package/cli/utils/check.ts +71 -0
  45. package/cli/utils/index.ts +1 -3
  46. package/cli/utils/keyboard.ts +8 -25
  47. package/cli/utils/runProcess.ts +30 -0
  48. package/client/app/component.tsx +29 -29
  49. package/client/app/index.ts +36 -57
  50. package/client/app/service.ts +7 -12
  51. package/client/app.tsconfig.json +2 -2
  52. package/client/components/Dialog/Manager.ssr.tsx +40 -0
  53. package/client/components/Dialog/Manager.tsx +119 -150
  54. package/client/components/Dialog/status.tsx +3 -3
  55. package/client/components/index.ts +1 -1
  56. package/client/components/types.d.ts +1 -3
  57. package/client/dev/hmr.ts +65 -0
  58. package/client/global.d.ts +2 -2
  59. package/client/hooks.ts +6 -9
  60. package/client/index.ts +2 -1
  61. package/client/islands/index.ts +7 -0
  62. package/client/islands/useDeferredModule.ts +199 -0
  63. package/client/pages/_layout/index.tsx +4 -12
  64. package/client/pages/useHeader.tsx +14 -21
  65. package/client/router.ts +27 -0
  66. package/client/services/router/components/Link.tsx +34 -27
  67. package/client/services/router/components/Page.tsx +6 -14
  68. package/client/services/router/components/router.ssr.tsx +36 -0
  69. package/client/services/router/components/router.tsx +63 -83
  70. package/client/services/router/index.tsx +185 -220
  71. package/client/services/router/request/api.ts +97 -119
  72. package/client/services/router/request/history.ts +2 -2
  73. package/client/services/router/request/index.ts +13 -12
  74. package/client/services/router/request/multipart.ts +72 -62
  75. package/client/services/router/response/index.tsx +68 -61
  76. package/client/services/router/response/page.ts +28 -32
  77. package/client/utils/dom.ts +17 -33
  78. package/common/app/index.ts +3 -3
  79. package/common/data/chaines/index.ts +22 -23
  80. package/common/data/dates.ts +35 -70
  81. package/common/data/markdown.ts +42 -39
  82. package/common/dev/serverHotReload.ts +26 -0
  83. package/common/errors/index.tsx +110 -142
  84. package/common/router/contracts.ts +29 -0
  85. package/common/router/index.ts +89 -108
  86. package/common/router/layouts.ts +34 -47
  87. package/common/router/pageSetup.ts +50 -0
  88. package/common/router/register.ts +53 -24
  89. package/common/router/request/api.ts +30 -36
  90. package/common/router/request/index.ts +2 -8
  91. package/common/router/response/index.ts +8 -15
  92. package/common/router/response/page.ts +70 -58
  93. package/common/utils.ts +1 -1
  94. package/doc/TODO.md +1 -1
  95. package/eslint.js +62 -0
  96. package/package.json +14 -49
  97. package/prettier.config.cjs +9 -0
  98. package/scripts/cleanup-generated-controllers.ts +62 -0
  99. package/scripts/fix-reference-app-typing.ts +490 -0
  100. package/scripts/refactor-client-app-imports.ts +244 -0
  101. package/scripts/refactor-client-pages.ts +587 -0
  102. package/scripts/refactor-server-controllers.ts +470 -0
  103. package/scripts/refactor-server-runtime-aliases.ts +360 -0
  104. package/scripts/restore-client-app-import-files.ts +41 -0
  105. package/scripts/restore-files-from-git-head.ts +20 -0
  106. package/scripts/update-codex-agents.ts +35 -0
  107. package/server/app/commands.ts +35 -64
  108. package/server/app/container/config.ts +48 -59
  109. package/server/app/container/console/index.ts +202 -248
  110. package/server/app/container/index.ts +33 -71
  111. package/server/app/controller/index.ts +61 -0
  112. package/server/app/index.ts +39 -105
  113. package/server/app/service/container.ts +41 -42
  114. package/server/app/service/index.ts +120 -147
  115. package/server/context.ts +1 -1
  116. package/server/index.ts +25 -1
  117. package/server/services/auth/index.ts +75 -115
  118. package/server/services/auth/router/index.ts +31 -32
  119. package/server/services/auth/router/request.ts +14 -16
  120. package/server/services/cron/CronTask.ts +13 -26
  121. package/server/services/cron/index.ts +14 -36
  122. package/server/services/disks/driver.ts +40 -58
  123. package/server/services/disks/drivers/local/index.ts +79 -90
  124. package/server/services/disks/drivers/s3/index.ts +116 -163
  125. package/server/services/disks/index.ts +23 -38
  126. package/server/services/email/index.ts +45 -104
  127. package/server/services/email/utils.ts +14 -27
  128. package/server/services/fetch/index.ts +53 -85
  129. package/server/services/prisma/Facet.ts +39 -91
  130. package/server/services/prisma/index.ts +74 -110
  131. package/server/services/router/generatedRuntime.ts +29 -0
  132. package/server/services/router/http/index.ts +78 -73
  133. package/server/services/router/http/multipart.ts +19 -42
  134. package/server/services/router/index.ts +378 -365
  135. package/server/services/router/request/api.ts +26 -25
  136. package/server/services/router/request/index.ts +44 -51
  137. package/server/services/router/request/service.ts +7 -11
  138. package/server/services/router/request/validation/zod.ts +111 -148
  139. package/server/services/router/response/index.ts +110 -125
  140. package/server/services/router/response/mask/Filter.ts +31 -72
  141. package/server/services/router/response/mask/index.ts +8 -15
  142. package/server/services/router/response/mask/selecteurs.ts +11 -25
  143. package/server/services/router/response/page/clientManifest.ts +25 -0
  144. package/server/services/router/response/page/document.tsx +199 -127
  145. package/server/services/router/response/page/index.tsx +89 -94
  146. package/server/services/router/service.ts +13 -15
  147. package/server/services/schema/index.ts +17 -26
  148. package/server/services/schema/request.ts +19 -33
  149. package/server/services/schema/router/index.ts +8 -11
  150. package/server/services/security/encrypt/aes/index.ts +15 -35
  151. package/server/utils/slug.ts +29 -35
  152. package/skills/clean-project-code/SKILL.md +63 -0
  153. package/skills/clean-project-code/agents/openai.yaml +4 -0
  154. package/tsconfig.common.json +4 -3
  155. package/tsconfig.json +4 -1
  156. package/types/aliases.d.ts +17 -21
  157. package/types/controller-input.test.ts +48 -0
  158. package/types/express-extra.d.ts +6 -0
  159. package/types/global/constants.d.ts +13 -0
  160. package/types/global/express-extra.d.ts +6 -0
  161. package/types/global/modules.d.ts +13 -16
  162. package/types/global/utils.d.ts +17 -49
  163. package/types/global/vendors.d.ts +62 -0
  164. package/types/icons.d.ts +65 -1
  165. package/types/uuid.d.ts +3 -0
  166. package/types/vendors.d.ts +62 -0
  167. package/cli/compiler/common/babel/index.ts +0 -170
  168. package/cli/compiler/common/babel/plugins/index.ts +0 -0
  169. package/cli/compiler/common/babel/plugins/services.ts +0 -586
  170. package/cli/compiler/common/babel/routes/imports.ts +0 -127
  171. package/cli/compiler/common/babel/routes/routes.ts +0 -1130
  172. package/client/services/captcha/index.ts +0 -67
  173. package/client/services/socket/index.ts +0 -147
  174. package/common/data/rte/nodes.ts +0 -83
  175. package/common/data/stats.ts +0 -90
  176. package/common/utils/rte.ts +0 -183
  177. package/server/services/auth/old.ts +0 -277
  178. package/server/services/cache/commands.ts +0 -41
  179. package/server/services/cache/index.ts +0 -297
  180. package/server/services/cache/service.json +0 -6
  181. package/server/services/socket/index.ts +0 -162
  182. package/server/services/socket/scope.ts +0 -226
  183. package/server/services/socket/service.json +0 -6
  184. package/server/services_old/SocketClient.ts +0 -92
  185. package/server/services_old/Token.old.ts +0 -97
@@ -3,7 +3,7 @@
3
3
  ----------------------------------*/
4
4
 
5
5
  // Core
6
- import type { Application } from '@server/app';
6
+ import type { Application } from '@server/app/index';
7
7
  import Service from '@server/app/service';
8
8
  import { NotFound } from '@common/errors';
9
9
  import context from '@server/context';
@@ -20,25 +20,18 @@ export { default as CronTask } from './CronTask';
20
20
  - SERVICE CONFIG
21
21
  ----------------------------------*/
22
22
 
23
- export type Config = {
24
- debug?: boolean
25
- }
26
-
27
- export type Hooks = {
28
-
29
- }
23
+ export type Config = { debug?: boolean };
30
24
 
31
- export type Services = {
25
+ export type Hooks = {};
32
26
 
33
- }
27
+ export type Services = {};
34
28
 
35
29
  /*----------------------------------
36
30
  - CLASSE
37
31
  ----------------------------------*/
38
32
 
39
33
  export default class CronManager extends Service<Config, Hooks, Application, Application> {
40
-
41
- public static taches: { [nom: string]: CronTask } = {}
34
+ public static taches: { [nom: string]: CronTask } = {};
42
35
  public static timer: NodeJS.Timeout;
43
36
 
44
37
  /*----------------------------------
@@ -46,15 +39,10 @@ export default class CronManager extends Service<Config, Hooks, Application, App
46
39
  ----------------------------------*/
47
40
 
48
41
  public async ready() {
49
-
50
42
  clearInterval(CronManager.timer);
51
43
  CronManager.timer = setInterval(() => {
52
-
53
- for (const id in CronManager.taches)
54
- CronManager.taches[id].run();
55
-
44
+ for (const id in CronManager.taches) CronManager.taches[id].run();
56
45
  }, 10000);
57
-
58
46
  }
59
47
 
60
48
  /*----------------------------------
@@ -67,46 +55,36 @@ export default class CronManager extends Service<Config, Hooks, Application, App
67
55
  * @param frequence When to execute this task.
68
56
  * - Date: The date at which to execute this task (one time execution)
69
57
  * - string: Cron expression to define the interval for executing this task
70
- * @param run Function to run
58
+ * @param run Function to run
71
59
  * @param autoexec true to execute the task immediatly
72
60
  * @returns The CronTask that just have been created
73
61
  */
74
62
  public task(nom: string, frequence: TFrequence, run: TRunner, autoexec?: boolean) {
75
63
  return new Promise<CronTask>((resolve, reject) => {
76
64
  context.run({ channelType: 'cron', channelId: nom }, async () => {
77
-
78
65
  CronManager.taches[nom] = new CronTask(this, nom, frequence, run, autoexec);
79
66
 
80
- if (autoexec)
81
- await CronManager.taches[nom].run(true);
67
+ if (autoexec) await CronManager.taches[nom].run(true);
82
68
 
83
- resolve( CronManager.taches[nom] );
84
-
85
- })
69
+ resolve(CronManager.taches[nom]);
70
+ });
86
71
  });
87
-
88
72
  }
89
73
 
90
74
  public async exec(nom: string) {
91
-
92
75
  const tache = CronManager.taches[nom];
93
76
 
94
- if (tache === undefined)
95
- throw new NotFound("Tâche NotFound: " + nom);
77
+ if (tache === undefined) throw new NotFound('Tâche NotFound: ' + nom);
96
78
 
97
79
  await tache.run(true);
98
-
99
80
  }
100
81
  public get(): typeof CronManager.taches;
101
82
  public get(name: string): CronTask;
102
83
  public get(name?: string): CronTask | typeof CronManager.taches {
103
-
104
- if (name === undefined)
105
- return CronManager.taches;
84
+ if (name === undefined) return CronManager.taches;
106
85
 
107
86
  const cron = CronManager.taches[name];
108
- if (cron === undefined)
109
- throw new Error(`L'instance de la tâche cron ${name} n'a pas été trouvée`);
87
+ if (cron === undefined) throw new Error(`L'instance de la tâche cron ${name} n'a pas été trouvée`);
110
88
  return cron;
111
89
  }
112
- }
90
+ }
@@ -3,51 +3,35 @@
3
3
  ----------------------------------*/
4
4
 
5
5
  // Core
6
- import type { Application } from '@server/app';
7
- import Service from '@server/app/service';
6
+ import type { Application } from '@server/app/index';
7
+ import Service, { TSetupConfig } from '@server/app/service';
8
8
 
9
9
  /*----------------------------------
10
10
  - CONFIG
11
11
  ----------------------------------*/
12
12
 
13
- export type THooks = {
13
+ export type THooks = {};
14
14
 
15
- }
16
-
17
- export type Services = {
18
-
19
- }
15
+ export type Services = {};
20
16
 
21
17
  /*----------------------------------
22
18
  - TYPE
23
19
  ----------------------------------*/
24
20
 
25
21
  export type TDrivercnfig = {
22
+ debug: boolean;
26
23
 
27
- debug: boolean,
24
+ rootDir: string;
25
+ buckets: { [id: string]: string };
26
+ };
28
27
 
29
- rootDir: string,
30
- buckets: {
31
- [id: string]: string
32
- }
33
- }
28
+ export type SourceFile = { name: string; path: string; modified: number; parentFolder: string; source: string };
34
29
 
35
- export type SourceFile = {
36
- name: string,
37
- path: string,
38
- modified: number,
39
- parentFolder: string,
40
- source: string
41
- }
30
+ export type TOutputFileOptions = { encoding: string };
42
31
 
43
- export type TOutputFileOptions = {
44
- encoding: string
45
- }
32
+ export type TReadFileOptions = { encoding?: 'string' | 'buffer'; withMetas?: boolean };
46
33
 
47
- export type TReadFileOptions = {
48
- encoding?: 'string'|'buffer',
49
- withMetas?: boolean
50
- }
34
+ type TBucketNameFromConfig<TConfig extends TDrivercnfig> = Extract<keyof TConfig['buckets'], string>;
51
35
 
52
36
  /*----------------------------------
53
37
  - CLASS
@@ -55,49 +39,47 @@ export type TReadFileOptions = {
55
39
 
56
40
  export default abstract class FsDriver<
57
41
  Config extends TDrivercnfig = TDrivercnfig,
58
- TBucketName = keyof Config["buckets"]
42
+ TBucketName extends TBucketNameFromConfig<Config> = TBucketNameFromConfig<Config>,
59
43
  > extends Service<Config, {}, Application, Application> {
60
-
61
- public constructor( config: Config, app: Application ) {
44
+ public constructor(config: TSetupConfig<Config>, app: Application) {
62
45
  super(app, config, app);
63
46
  }
64
47
 
65
48
  public abstract mount(): Promise<void>;
66
49
 
67
- public abstract getFileUrl(
68
- bucketName: TBucketName,
69
- filename: string
70
- ): string;
71
-
72
- public abstract readDir( bucketName: TBucketName, dirname?: string ): Promise<SourceFile[]>;
50
+ public abstract getFileUrl(bucketName: TBucketName, filename: string): string;
73
51
 
74
- public abstract readFile(
75
- bucketName: TBucketName,
76
- filename: string,
77
- options: TReadFileOptions
78
- ): Promise<Buffer>;
52
+ public abstract readDir(bucketName: TBucketName, dirname?: string): Promise<SourceFile[]>;
79
53
 
80
- public abstract createReadStream( bucketName: TBucketName, filename: string );
54
+ public abstract readFile(
55
+ bucketName: TBucketName,
56
+ filename: string,
57
+ options?: TReadFileOptions,
58
+ ): Promise<Buffer | string>;
81
59
 
82
- public abstract exists( bucketName: TBucketName, filename: string ): Promise<boolean>;
60
+ public abstract createReadStream(bucketName: TBucketName, filename: string): unknown;
83
61
 
84
- public abstract move( bucketName: TBucketName, source: string, destination: string, options: { overwrite?: boolean }): Promise<void>;
62
+ public abstract exists(bucketName: TBucketName, filename: string): Promise<boolean>;
85
63
 
86
- public abstract outputFile(
87
- bucketName: TBucketName,
88
- filename: string,
89
- content: string | Buffer,
90
- options?: TOutputFileOptions
91
- ): Promise<{
92
- path: string
93
- }>;
64
+ public abstract move(
65
+ bucketName: TBucketName,
66
+ source: string,
67
+ destination: string,
68
+ options: { overwrite?: boolean },
69
+ ): Promise<void>;
94
70
 
95
- public abstract readJSON( bucketName: TBucketName, filename: string ): Promise<any>;
71
+ public abstract outputFile(
72
+ bucketName: TBucketName,
73
+ filename: string,
74
+ content: string | Buffer,
75
+ options?: TOutputFileOptions,
76
+ ): Promise<{ path: string }>;
96
77
 
97
- public abstract delete( bucketName: TBucketName, filename: string ): Promise<boolean>;
78
+ public abstract readJSON(bucketName: TBucketName, filename: string): Promise<any>;
98
79
 
99
- public abstract deleteDir( bucketName: TBucketName, dirname: string ): Promise<boolean>;
80
+ public abstract delete(bucketName: TBucketName, filename: string): Promise<boolean>;
100
81
 
101
- public abstract unmount(): Promise<void>;
82
+ public abstract deleteDir(bucketName: TBucketName, dirname: string): Promise<boolean>;
102
83
 
103
- }
84
+ public abstract unmount(): Promise<void>;
85
+ }
@@ -16,7 +16,7 @@ import fs from 'fs-extra';
16
16
  import AppContainer from '@server/app/container';
17
17
 
18
18
  // Specific
19
- import DiskDriver, { TDrivercnfig, SourceFile, TOutputFileOptions } from '../../driver';
19
+ import DiskDriver, { TDrivercnfig, SourceFile, TOutputFileOptions, TReadFileOptions } from '../../driver';
20
20
 
21
21
  /*----------------------------------
22
22
  - CONFIG
@@ -26,163 +26,152 @@ import DiskDriver, { TDrivercnfig, SourceFile, TOutputFileOptions } from '../../
26
26
  - TYPES
27
27
  ----------------------------------*/
28
28
 
29
- export type TConfig = TDrivercnfig & {
30
-
31
- }
29
+ export type TConfig = TDrivercnfig & {};
32
30
 
33
31
  /*----------------------------------
34
32
  - SERVICE
35
33
  ----------------------------------*/
36
34
  export default class LocalFS<
37
35
  Config extends TConfig = TConfig,
38
- TBucketName = keyof Config["buckets"]
39
- > extends DiskDriver<TConfig> {
40
-
36
+ TBucketName extends Extract<keyof Config['buckets'], string> = Extract<keyof Config['buckets'], string>,
37
+ > extends DiskDriver<Config, TBucketName> {
41
38
  public rootDir = AppContainer.path.var;
42
39
 
43
- public async mount() {
44
-
40
+ private getBucketDir(bucketName: TBucketName) {
41
+ const bucketDir = this.config.buckets[bucketName];
42
+ if (bucketDir === undefined) throw new Error(`Bucket "${bucketName}" not found in configuration`);
43
+ return bucketDir;
45
44
  }
46
45
 
47
- public async unmount() {
46
+ public async mount() {}
48
47
 
49
- }
48
+ public async unmount() {}
50
49
 
51
50
  /*----------------------------------
52
51
  - ACTIONS
53
52
  ----------------------------------*/
54
53
 
55
- public getFileUrl(
56
- bucketName: TBucketName,
57
- filename: string
58
- ) {
59
- const bucketDir = this.config.buckets[bucketName];
60
- const fullPath = path.join( this.rootDir, bucketDir, filename || '.' );
54
+ public getFileUrl(bucketName: TBucketName, filename: string) {
55
+ const bucketDir = this.getBucketDir(bucketName);
56
+ const fullPath = path.join(this.rootDir, bucketDir, filename || '.');
61
57
  return fullPath;
62
58
  }
63
59
 
64
- public async readDir( bucketName: TBucketName, dirname?: string ) {
60
+ public async readDir(bucketName: TBucketName, dirname?: string) {
61
+ const bucketDir = this.getBucketDir(bucketName);
65
62
 
66
- const bucketDir = this.config.buckets[bucketName];
67
-
68
- const fullPath = path.join( this.rootDir, bucketDir, dirname || '.' );
63
+ const fullPath = path.join(this.rootDir, bucketDir, dirname || '.');
69
64
 
70
65
  // Combine the files list of all source directory
71
66
  const files: SourceFile[] = [];
72
- const sources = fs.readdirSync( fullPath, { withFileTypes: true });
67
+ const sources = fs.readdirSync(fullPath, { withFileTypes: true });
73
68
  for (const source of sources) {
74
-
75
- if (!source.isDirectory())
76
- continue;
69
+ if (!source.isDirectory()) continue;
77
70
 
78
71
  const parentFolder = source.name;
79
- const csvFiles = fs.readdirSync(
80
- path.join( fullPath, parentFolder ),
81
- { withFileTypes: true }
82
- );
72
+ const csvFiles = fs.readdirSync(path.join(fullPath, parentFolder), { withFileTypes: true });
83
73
 
84
74
  for (const file of csvFiles) {
75
+ if (!file.isFile() || !file.name.endsWith('.csv')) continue;
85
76
 
86
- if (!file.isFile() || !file.name.endsWith('.csv'))
87
- continue;
88
-
89
- const relPath = path.join( source.name, file.name );
90
- const fullpath = path.join( fullPath, relPath );
77
+ const relPath = path.join(source.name, file.name);
78
+ const fullpath = path.join(fullPath, relPath);
91
79
  const stats = fs.statSync(fullpath);
92
80
 
93
- const rowsCount = fs.readFileSync( fullpath, 'utf-8').split('\n').length - 1;
81
+ const rowsCount = fs.readFileSync(fullpath, 'utf-8').split('\n').length - 1;
94
82
 
95
- const name = dayjs(stats.mtime).format('DD/MM HH:mm:ss')
96
- + ' : ' + path.join( source.name, file.name )
97
- + ' : ' + rowsCount + ' contacts'
98
-
99
- files.push({
100
- name,
101
- path: relPath,
102
- parentFolder,
103
- source: source.name,
104
- modified: stats.mtimeMs
105
- });
83
+ const name =
84
+ dayjs(stats.mtime).format('DD/MM HH:mm:ss') +
85
+ ' : ' +
86
+ path.join(source.name, file.name) +
87
+ ' : ' +
88
+ rowsCount +
89
+ ' contacts';
106
90
 
91
+ files.push({ name, path: relPath, parentFolder, source: source.name, modified: stats.mtimeMs });
107
92
  }
108
93
  }
109
-
94
+
110
95
  this.config.debug && console.log(`readDir ${fullPath}: ${files.length} objects`);
111
96
  return files;
112
97
  }
113
98
 
114
- public async readFile( bucketName: TBucketName, filename: string ) {
115
-
116
- const bucketDir = this.config.buckets[bucketName];
117
- const fullPath = path.join( this.rootDir, bucketDir, filename );
99
+ public async readFile(bucketName: TBucketName, filename: string, options: TReadFileOptions = {}) {
100
+ const bucketDir = this.getBucketDir(bucketName);
101
+ const fullPath = path.join(this.rootDir, bucketDir, filename);
118
102
 
119
103
  this.config.debug && console.log(`readFile ${fullPath}`);
120
- return fs.readFileSync( fullPath );
104
+ return options.encoding === 'string' ? fs.readFileSync(fullPath, 'utf8') : fs.readFileSync(fullPath);
121
105
  }
122
106
 
123
- public createReadStream( bucketName: TBucketName, filename: string ) {
124
-
125
- const bucketDir = this.config.buckets[bucketName];
126
- const fullPath = path.join( this.rootDir, bucketDir, filename );
107
+ public createReadStream(bucketName: TBucketName, filename: string) {
108
+ const bucketDir = this.getBucketDir(bucketName);
109
+ const fullPath = path.join(this.rootDir, bucketDir, filename);
127
110
 
128
111
  this.config.debug && console.log(`createReadStream ${fullPath}`);
129
- return fs.createReadStream( fullPath );
112
+ return fs.createReadStream(fullPath);
130
113
  }
131
114
 
132
- public async exists( bucketName: TBucketName, filename: string ) {
133
-
134
- const bucketDir = this.config.buckets[bucketName];
135
- const fullPath = path.join( this.rootDir, bucketDir, filename );
115
+ public async exists(bucketName: TBucketName, filename: string) {
116
+ const bucketDir = this.getBucketDir(bucketName);
117
+ const fullPath = path.join(this.rootDir, bucketDir, filename);
136
118
 
137
119
  this.config.debug && console.log(`exists ${fullPath}`);
138
- return fs.existsSync( fullPath );
120
+ return fs.existsSync(fullPath);
139
121
  }
140
122
 
141
- public async move( bucketName: TBucketName, source: string, destination: string, options: { overwrite?: boolean } = {}) {
142
-
143
- const bucketDir = this.config.buckets[bucketName];
144
- const fullPathSource = path.join( this.rootDir, bucketDir, source );
145
- const fullPathDestination = path.join( this.rootDir, bucketDir, destination );
123
+ public async move(
124
+ bucketName: TBucketName,
125
+ source: string,
126
+ destination: string,
127
+ options: { overwrite?: boolean } = {},
128
+ ) {
129
+ const bucketDir = this.getBucketDir(bucketName);
130
+ const fullPathSource = path.join(this.rootDir, bucketDir, source);
131
+ const fullPathDestination = path.join(this.rootDir, bucketDir, destination);
146
132
 
147
133
  this.config.debug && console.log(`move ${fullPathSource} to ${fullPathDestination}`);
148
134
  return fs.moveSync(fullPathSource, fullPathDestination, options);
149
135
  }
150
136
 
151
- public async outputFile(
152
- bucketName: TBucketName,
153
- filename: string,
154
- content: string | Buffer,
155
- options?: TOutputFileOptions
137
+ public async outputFile(
138
+ bucketName: TBucketName,
139
+ filename: string,
140
+ content: string | Buffer,
141
+ options?: TOutputFileOptions,
156
142
  ) {
157
-
158
- const bucketDir = this.config.buckets[bucketName];
159
- const fullPath = path.join( this.rootDir, bucketDir, filename );
143
+ const bucketDir = this.getBucketDir(bucketName);
144
+ const fullPath = path.join(this.rootDir, bucketDir, filename);
160
145
  this.config.debug && console.log(`outputFile`, fullPath);
161
146
 
162
- fs.outputFileSync( fullPath, content, options );
147
+ fs.outputFileSync(fullPath, content, options);
163
148
 
164
- return {
165
- path: fullPath
166
- }
149
+ return { path: fullPath };
167
150
  }
168
151
 
169
- public async readJSON( bucketName: TBucketName, filename: string ) {
170
-
171
- const bucketDir = this.config.buckets[bucketName];
172
- const fullPath = path.join( this.rootDir, bucketDir, filename );
152
+ public async readJSON(bucketName: TBucketName, filename: string) {
153
+ const bucketDir = this.getBucketDir(bucketName);
154
+ const fullPath = path.join(this.rootDir, bucketDir, filename);
173
155
 
174
156
  this.config.debug && console.log(`readJSON ${fullPath}`);
175
- return fs.readJsonSync( fullPath );
157
+ return fs.readJsonSync(fullPath);
176
158
  }
177
159
 
178
- public async delete( bucketName: TBucketName, filename: string ) {
179
-
180
- const bucketDir = this.config.buckets[bucketName];
181
- const fullPath = path.join( this.rootDir, bucketDir, filename );
160
+ public async delete(bucketName: TBucketName, filename: string) {
161
+ const bucketDir = this.getBucketDir(bucketName);
162
+ const fullPath = path.join(this.rootDir, bucketDir, filename);
182
163
 
183
164
  this.config.debug && console.log(`delete ${fullPath}`);
184
- fs.removeSync( fullPath );
165
+ fs.removeSync(fullPath);
185
166
  return true;
186
167
  }
187
168
 
188
- }
169
+ public async deleteDir(bucketName: TBucketName, dirname: string) {
170
+ const bucketDir = this.getBucketDir(bucketName);
171
+ const fullPath = path.join(this.rootDir, bucketDir, dirname);
172
+
173
+ this.config.debug && console.log(`deleteDir ${fullPath}`);
174
+ fs.removeSync(fullPath);
175
+ return true;
176
+ }
177
+ }