@duplojs/agents-kit 0.1.0-beta.8 → 0.1.0-beta.9

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 (83) hide show
  1. package/docs/API/10-lang/10-common/10-asyncLoop.ts +4 -6
  2. package/docs/API/10-lang/10-common/10-asyncLoopAccumulator.ts +40 -0
  3. package/docs/API/10-lang/10-common/10-loop.ts +5 -7
  4. package/docs/API/10-lang/10-common/10-loopAccumulator.ts +35 -0
  5. package/docs/API/10-lang/10-common/10-loopAccumulatorFrom.ts +29 -0
  6. package/docs/API/10-lang/10-common/index.llms.md +14 -2
  7. package/docs/API/10-lang/10-generator/10-asyncLoop.ts +11 -20
  8. package/docs/API/10-lang/10-generator/10-asyncLoopAccumulator.ts +40 -0
  9. package/docs/API/10-lang/10-generator/10-loop.ts +11 -20
  10. package/docs/API/10-lang/10-generator/10-loopAccumulator.ts +33 -0
  11. package/docs/API/10-lang/10-generator/10-loopAccumulatorFrom.ts +30 -0
  12. package/docs/API/10-lang/10-generator/index.llms.md +14 -2
  13. package/docs/API/20-server/10-file/10-appendFile.ts +50 -0
  14. package/docs/API/20-server/10-file/10-appendTextFile.ts +49 -0
  15. package/docs/API/20-server/10-file/10-copy.ts +50 -0
  16. package/docs/API/20-server/10-file/10-createEntryInterface.ts +13 -0
  17. package/docs/API/20-server/10-file/10-createFileInterface.ts +22 -0
  18. package/docs/API/20-server/10-file/10-createFolderInterface.ts +20 -0
  19. package/docs/API/20-server/10-file/10-createUnknownEntryInterface.ts +13 -0
  20. package/docs/API/20-server/10-file/10-ensureDirectory.ts +39 -0
  21. package/docs/API/20-server/10-file/10-ensureFile.ts +40 -0
  22. package/docs/API/20-server/10-file/10-exists.ts +36 -0
  23. package/docs/API/20-server/10-file/10-link.ts +51 -0
  24. package/docs/API/20-server/10-file/10-linkStat.ts +37 -0
  25. package/docs/API/20-server/10-file/10-makeDirectory.ts +41 -0
  26. package/docs/API/20-server/10-file/10-makeTemporaryDirectory.ts +35 -0
  27. package/docs/API/20-server/10-file/10-makeTemporaryFile.ts +40 -0
  28. package/docs/API/20-server/10-file/10-move.ts +51 -0
  29. package/docs/API/20-server/10-file/10-readDirectory.ts +52 -0
  30. package/docs/API/20-server/10-file/10-readFile.ts +38 -0
  31. package/docs/API/20-server/10-file/10-readJsonFile.ts +38 -0
  32. package/docs/API/20-server/10-file/10-readLink.ts +37 -0
  33. package/docs/API/20-server/10-file/10-readTextFile.ts +38 -0
  34. package/docs/API/20-server/10-file/10-realPath.ts +36 -0
  35. package/docs/API/20-server/10-file/10-relocate.ts +51 -0
  36. package/docs/API/20-server/10-file/10-remove.ts +40 -0
  37. package/docs/API/20-server/10-file/10-rename.ts +43 -0
  38. package/docs/API/20-server/10-file/10-setMode.ts +37 -0
  39. package/docs/API/20-server/10-file/10-setOwner.ts +38 -0
  40. package/docs/API/20-server/10-file/10-setTime.ts +42 -0
  41. package/docs/API/20-server/10-file/10-stat.ts +37 -0
  42. package/docs/API/20-server/10-file/10-symlink.ts +49 -0
  43. package/docs/API/20-server/10-file/10-truncate.ts +41 -0
  44. package/docs/API/20-server/10-file/10-walkDirectory.ts +75 -0
  45. package/docs/API/20-server/10-file/10-writeFile.ts +50 -0
  46. package/docs/API/20-server/10-file/10-writeJsonFile.ts +41 -0
  47. package/docs/API/20-server/10-file/10-writeTextFile.ts +49 -0
  48. package/docs/API/20-server/10-file/index.llms.md +144 -0
  49. package/docs/API/20-server/10-file/index.md +3 -0
  50. package/docs/API/20-server/20-common/10-environmentVariable.ts +57 -0
  51. package/docs/API/20-server/20-common/10-environmentVariableOrThrow.ts +21 -0
  52. package/docs/API/20-server/20-common/10-exitProcess.ts +9 -0
  53. package/docs/API/20-server/20-common/10-getCurrentDirectoryName.ts +10 -0
  54. package/docs/API/20-server/20-common/10-getCurrentWorkDirectory.ts +10 -0
  55. package/docs/API/20-server/20-common/10-getCurrentWorkDirectoryOrThrow.ts +10 -0
  56. package/docs/API/20-server/20-common/10-getProcessArguments.ts +10 -0
  57. package/docs/API/20-server/20-common/10-setCurrentWorkingDirectory.ts +14 -0
  58. package/docs/API/20-server/20-common/10-setCurrentWorkingDirectoryOrThrow.ts +12 -0
  59. package/docs/API/20-server/20-common/index.llms.md +40 -0
  60. package/docs/API/20-server/20-common/index.md +3 -0
  61. package/docs/API/20-server/30-dataStructure/10-file.ts +14 -0
  62. package/docs/API/20-server/30-dataStructure/10-fileExist.ts +27 -0
  63. package/docs/API/20-server/30-dataStructure/10-folder.ts +14 -0
  64. package/docs/API/20-server/30-dataStructure/10-folderExist.ts +14 -0
  65. package/docs/API/20-server/30-dataStructure/10-mimeType.ts +14 -0
  66. package/docs/API/20-server/30-dataStructure/10-size.ts +32 -0
  67. package/docs/API/20-server/30-dataStructure/index.llms.md +28 -0
  68. package/docs/API/20-server/30-dataStructure/index.md +3 -0
  69. package/docs/API/20-server/40-command/10-create.ts +39 -0
  70. package/docs/API/20-server/40-command/10-createArgument.ts +39 -0
  71. package/docs/API/20-server/40-command/10-createArrayOption.ts +36 -0
  72. package/docs/API/20-server/40-command/10-createBooleanOption.ts +28 -0
  73. package/docs/API/20-server/40-command/10-createOption.ts +46 -0
  74. package/docs/API/20-server/40-command/10-exec.ts +51 -0
  75. package/docs/API/20-server/40-command/10-execOptions.ts +30 -0
  76. package/docs/API/20-server/40-command/index.llms.md +32 -0
  77. package/docs/API/20-server/40-command/index.md +3 -0
  78. package/docs/API/20-server/index.md +3 -0
  79. package/docs/API.llms.md +20 -0
  80. package/package.json +14 -14
  81. package/skills/fundamental/SKILL.md +3 -1
  82. package/skills/fundamental/references/examples/iterations.ts +26 -13
  83. package/skills/fundamental/references/iterations.md +5 -1
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @title DSFile.createFolderInterface
3
+ *
4
+ * Construire une référence de dossier sans accès au disque.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+
9
+ declare const path: string & DPath.Path;
10
+
11
+ const entry = DSFile.createFolderInterface(path);
12
+
13
+ // La construction ne vérifie ni l’existence ni la nature de la ressource.
14
+
15
+ // Ces méthodes consultent le système de fichiers et retournent un Either.
16
+ const children = await entry.getChildren();
17
+ const traversal = await entry.walk({ recursive: true });
18
+
19
+ // Un déplacement ou renommage réussi retourne une nouvelle interface ;
20
+ // la référence initiale conserve son ancien chemin.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @title DSFile.createUnknownEntryInterface
3
+ *
4
+ * Construire une référence d’entrée de type inconnu sans accès au disque.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+
9
+ declare const path: string & DPath.Path;
10
+
11
+ const entry = DSFile.createUnknownEntryInterface(path);
12
+
13
+ // La construction ne vérifie ni l’existence ni la nature de la ressource.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @title DSFile.ensureDirectory
3
+ *
4
+ * Créer un dossier et ses parents si nécessaire.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.ensureDirectory(path);
14
+
15
+ // La réussite confirme que le dossier a été assuré.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-ensure-directory-permission-denied": () => "access-denied",
25
+ "file-system-ensure-directory-no-space": () => "no-space",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-ensure-directory-permission-denied
33
+ // file-system-ensure-directory-not-directory
34
+ // file-system-ensure-directory-no-space
35
+ // file-system-ensure-directory-read-only
36
+ // file-system-ensure-directory-invalid-argument
37
+ // file-system-ensure-directory-too-many-open-files
38
+ // file-system-ensure-directory-busy
39
+ // file-system-ensure-directory-error
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @title DSFile.ensureFile
3
+ *
4
+ * Créer un fichier absent sans tronquer un fichier existant.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.ensureFile(path);
14
+
15
+ // Le dossier parent doit déjà exister.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-ensure-file-permission-denied": () => "access-denied",
25
+ "file-system-ensure-file-no-space": () => "no-space",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-ensure-file-permission-denied
33
+ // file-system-ensure-file-is-directory
34
+ // file-system-ensure-file-not-directory
35
+ // file-system-ensure-file-no-space
36
+ // file-system-ensure-file-read-only
37
+ // file-system-ensure-file-invalid-argument
38
+ // file-system-ensure-file-too-many-open-files
39
+ // file-system-ensure-file-busy
40
+ // file-system-ensure-file-error
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @title DSFile.exists
3
+ *
4
+ * Vérifier l’accès à une entrée du système de fichiers.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.exists(path);
14
+
15
+ // Le résultat est un Either : un échec ne signifie pas nécessairement que l’entrée est absente.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-exists-not-found": () => "missing",
25
+ "file-system-exists-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-exists-not-found
33
+ // file-system-exists-permission-denied
34
+ // file-system-exists-not-directory
35
+ // file-system-exists-too-many-open-files
36
+ // file-system-exists-error
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @title DSFile.link
3
+ *
4
+ * Créer un lien physique vers une entrée existante.
5
+ */
6
+ import * as DCommon from "@duplojs/lang/common";
7
+ import type * as DPath from "@duplojs/lang/path";
8
+ import * as DSFile from "@duplojs/server/file";
9
+ import * as DEither from "@duplojs/lang/either";
10
+ import * as DPattern from "@duplojs/lang/pattern";
11
+
12
+ declare const source: string & DPath.Path;
13
+ declare const destination: string & DPath.Path;
14
+
15
+ // Appel direct
16
+ const result = await DSFile.link(source, destination);
17
+
18
+ // Forme curifiée
19
+ const pipedResult = await DCommon.pipe(
20
+ source,
21
+ DSFile.link(destination),
22
+ );
23
+
24
+ // Les résultats dépendent de l'état du système de fichiers et peuvent échouer.
25
+
26
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
27
+ if (DEither.isLeft(result)) {
28
+ const error = DEither.unwrapLeft(result);
29
+
30
+ const diagnosis = DPattern.matchWithErrorOtherwise(
31
+ error,
32
+ {
33
+ "file-system-link-not-found": () => "missing",
34
+ "file-system-link-permission-denied": () => "access-denied",
35
+ },
36
+ (otherError) => otherError,
37
+ );
38
+ }
39
+
40
+ // Identifiants d’erreur déclarés pour cette opération :
41
+ // file-system-link-not-found
42
+ // file-system-link-permission-denied
43
+ // file-system-link-already-exists
44
+ // file-system-link-not-directory
45
+ // file-system-link-no-space
46
+ // file-system-link-read-only
47
+ // file-system-link-invalid-argument
48
+ // file-system-link-too-many-open-files
49
+ // file-system-link-busy
50
+ // file-system-link-cross-device
51
+ // file-system-link-error
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @title DSFile.linkStat
3
+ *
4
+ * Lire les métadonnées d’un lien lui-même.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.linkStat(path);
14
+
15
+ // Contrairement à stat, cette opération inspecte le lien symbolique lui-même.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-link-stat-not-found": () => "missing",
25
+ "file-system-link-stat-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-link-stat-not-found
33
+ // file-system-link-stat-permission-denied
34
+ // file-system-link-stat-not-directory
35
+ // file-system-link-stat-too-many-open-files
36
+ // file-system-link-stat-busy
37
+ // file-system-link-stat-error
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @title DSFile.makeDirectory
3
+ *
4
+ * Créer un dossier, éventuellement avec ses parents.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.makeDirectory(path, { recursive: true });
14
+
15
+ // Le Left décrit un éventuel échec de création.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-make-directory-not-found": () => "missing",
25
+ "file-system-make-directory-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-make-directory-not-found
33
+ // file-system-make-directory-permission-denied
34
+ // file-system-make-directory-already-exists
35
+ // file-system-make-directory-not-directory
36
+ // file-system-make-directory-no-space
37
+ // file-system-make-directory-read-only
38
+ // file-system-make-directory-invalid-argument
39
+ // file-system-make-directory-too-many-open-files
40
+ // file-system-make-directory-busy
41
+ // file-system-make-directory-error
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @title DSFile.makeTemporaryDirectory
3
+ *
4
+ * Créer un dossier temporaire avec un préfixe.
5
+ */
6
+ import * as DSFile from "@duplojs/server/file";
7
+ import * as DEither from "@duplojs/lang/either";
8
+ import * as DPattern from "@duplojs/lang/pattern";
9
+
10
+ const result = await DSFile.makeTemporaryDirectory("export-");
11
+
12
+ // La position et le nom obtenus dépendent du runtime et du préfixe.
13
+
14
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
15
+ if (DEither.isLeft(result)) {
16
+ const error = DEither.unwrapLeft(result);
17
+
18
+ const diagnosis = DPattern.matchWithErrorOtherwise(
19
+ error,
20
+ {
21
+ "file-system-make-temporary-directory-permission-denied": () => "access-denied",
22
+ "file-system-make-temporary-directory-no-space": () => "no-space",
23
+ },
24
+ (otherError) => otherError,
25
+ );
26
+ }
27
+
28
+ // Identifiants d’erreur déclarés pour cette opération :
29
+ // file-system-make-temporary-directory-permission-denied
30
+ // file-system-make-temporary-directory-not-directory
31
+ // file-system-make-temporary-directory-no-space
32
+ // file-system-make-temporary-directory-read-only
33
+ // file-system-make-temporary-directory-invalid-argument
34
+ // file-system-make-temporary-directory-too-many-open-files
35
+ // file-system-make-temporary-directory-error
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @title DSFile.makeTemporaryFile
3
+ *
4
+ * Créer un fichier temporaire avec préfixe et suffixe.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const prefix: string & DPath.Segment;
12
+ declare const suffix: string & DPath.Segment;
13
+
14
+ const result = await DSFile.makeTemporaryFile(prefix, suffix);
15
+
16
+ // Le Right porte le chemin créé ; le Left porte l’erreur de création.
17
+
18
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
19
+ if (DEither.isLeft(result)) {
20
+ const error = DEither.unwrapLeft(result);
21
+
22
+ const diagnosis = DPattern.matchWithErrorOtherwise(
23
+ error,
24
+ {
25
+ "file-system-make-temporary-file-permission-denied": () => "access-denied",
26
+ "file-system-make-temporary-file-already-exists": () => "already-exists",
27
+ },
28
+ (otherError) => otherError,
29
+ );
30
+ }
31
+
32
+ // Identifiants d’erreur déclarés pour cette opération :
33
+ // file-system-make-temporary-file-permission-denied
34
+ // file-system-make-temporary-file-already-exists
35
+ // file-system-make-temporary-file-not-directory
36
+ // file-system-make-temporary-file-no-space
37
+ // file-system-make-temporary-file-read-only
38
+ // file-system-make-temporary-file-invalid-argument
39
+ // file-system-make-temporary-file-too-many-open-files
40
+ // file-system-make-temporary-file-error
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @title DSFile.move
3
+ *
4
+ * Déplacer une ressource vers un chemin de destination.
5
+ */
6
+ import * as DCommon from "@duplojs/lang/common";
7
+ import type * as DPath from "@duplojs/lang/path";
8
+ import * as DSFile from "@duplojs/server/file";
9
+ import * as DEither from "@duplojs/lang/either";
10
+ import * as DPattern from "@duplojs/lang/pattern";
11
+
12
+ declare const source: string & DPath.Path;
13
+ declare const destination: string & DPath.Path;
14
+
15
+ // Appel direct
16
+ const result = await DSFile.move(source, destination);
17
+
18
+ // Forme curifiée
19
+ const pipedResult = await DCommon.pipe(
20
+ source,
21
+ DSFile.move(destination),
22
+ );
23
+
24
+ // Les résultats dépendent de l'état du système de fichiers et peuvent échouer.
25
+
26
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
27
+ if (DEither.isLeft(result)) {
28
+ const error = DEither.unwrapLeft(result);
29
+
30
+ const diagnosis = DPattern.matchWithErrorOtherwise(
31
+ error,
32
+ {
33
+ "file-system-move-not-found": () => "missing",
34
+ "file-system-move-permission-denied": () => "access-denied",
35
+ },
36
+ (otherError) => otherError,
37
+ );
38
+ }
39
+
40
+ // Identifiants d’erreur déclarés pour cette opération :
41
+ // file-system-move-not-found
42
+ // file-system-move-permission-denied
43
+ // file-system-move-already-exists
44
+ // file-system-move-is-directory
45
+ // file-system-move-not-directory
46
+ // file-system-move-directory-not-empty
47
+ // file-system-move-read-only
48
+ // file-system-move-invalid-argument
49
+ // file-system-move-busy
50
+ // file-system-move-cross-device
51
+ // file-system-move-error
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @title DSFile.readDirectory
3
+ *
4
+ * Lister les chemins d’un dossier avec récursivité et résolution absolue optionnelles.
5
+ */
6
+ import type * as DCommon from "@duplojs/lang/common";
7
+ import type * as DPath from "@duplojs/lang/path";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+ import * as DSFile from "@duplojs/server/file";
11
+
12
+ declare const directory: string & DPath.Path;
13
+
14
+ const result = await DSFile.readDirectory(
15
+ directory,
16
+ {
17
+ recursive: true,
18
+ absolute: true,
19
+ },
20
+ );
21
+
22
+ if (DEither.isRight(result)) {
23
+ const paths = DEither.unwrapRight(result);
24
+
25
+ type _CheckPaths = DCommon.ExpectType<
26
+ typeof paths,
27
+ readonly (string & DPath.Path & DPath.Absolute)[],
28
+ "strict"
29
+ >;
30
+ } else {
31
+ const error = DEither.unwrapLeft(result);
32
+
33
+ const diagnosis = DPattern.matchWithErrorOtherwise(
34
+ error,
35
+ {
36
+ "file-system-read-directory-not-found": () => "missing-directory",
37
+ "file-system-read-directory-permission-denied": () => "access-denied",
38
+ "file-system-read-directory-not-directory": () => "not-a-directory",
39
+ },
40
+ (otherError) => otherError,
41
+ );
42
+ }
43
+
44
+ // Sans absolute, les chemins sont relatifs au dossier lu.
45
+
46
+ // Identifiants d’erreur déclarés pour cette opération :
47
+ // file-system-read-directory-not-found
48
+ // file-system-read-directory-permission-denied
49
+ // file-system-read-directory-not-directory
50
+ // file-system-read-directory-too-many-open-files
51
+ // file-system-read-directory-busy
52
+ // file-system-read-directory-error
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @title DSFile.readFile
3
+ *
4
+ * Lire les octets d’un fichier.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.readFile(path);
14
+
15
+ // Le Right porte les octets lus ; le Left décrit l’échec d’accès.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-read-file-not-found": () => "missing",
25
+ "file-system-read-file-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-read-file-not-found
33
+ // file-system-read-file-permission-denied
34
+ // file-system-read-file-is-directory
35
+ // file-system-read-file-not-directory
36
+ // file-system-read-file-too-many-open-files
37
+ // file-system-read-file-busy
38
+ // file-system-read-file-error
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @title DSFile.readJsonFile
3
+ *
4
+ * Lire et analyser un fichier JSON.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.readJsonFile(path);
14
+
15
+ // Le JSON obtenu doit encore être validé selon le contrat applicatif.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-read-json-file-not-found": () => "missing",
25
+ "file-system-read-json-file-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-read-json-file-not-found
33
+ // file-system-read-json-file-permission-denied
34
+ // file-system-read-json-file-is-directory
35
+ // file-system-read-json-file-not-directory
36
+ // file-system-read-json-file-too-many-open-files
37
+ // file-system-read-json-file-busy
38
+ // file-system-read-json-file-error
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @title DSFile.readLink
3
+ *
4
+ * Lire la cible d’un lien symbolique.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.readLink(path);
14
+
15
+ // Le résultat dépend de la cible enregistrée sur le système de fichiers.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-read-link-not-found": () => "missing",
25
+ "file-system-read-link-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-read-link-not-found
33
+ // file-system-read-link-permission-denied
34
+ // file-system-read-link-invalid-argument
35
+ // file-system-read-link-not-directory
36
+ // file-system-read-link-too-many-open-files
37
+ // file-system-read-link-error
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @title DSFile.readTextFile
3
+ *
4
+ * Lire le contenu UTF-8 d'un fichier et distinguer les erreurs d'accès.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DEither from "@duplojs/lang/either";
8
+ import * as DPattern from "@duplojs/lang/pattern";
9
+ import * as DSFile from "@duplojs/server/file";
10
+
11
+ declare const configurationPath: string & DPath.Path;
12
+
13
+ const result = await DSFile.readTextFile(configurationPath);
14
+
15
+ if (DEither.isRight(result)) {
16
+ // Le contenu dépend du fichier au moment de la lecture.
17
+ const text = DEither.unwrapRight(result);
18
+ } else {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-read-text-file-not-found": () => "missing-configuration",
25
+ "file-system-read-text-file-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-read-text-file-not-found
33
+ // file-system-read-text-file-permission-denied
34
+ // file-system-read-text-file-is-directory
35
+ // file-system-read-text-file-not-directory
36
+ // file-system-read-text-file-too-many-open-files
37
+ // file-system-read-text-file-busy
38
+ // file-system-read-text-file-error
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @title DSFile.realPath
3
+ *
4
+ * Résoudre le chemin réel d’une entrée.
5
+ */
6
+ import type * as DPath from "@duplojs/lang/path";
7
+ import * as DSFile from "@duplojs/server/file";
8
+ import * as DEither from "@duplojs/lang/either";
9
+ import * as DPattern from "@duplojs/lang/pattern";
10
+
11
+ declare const path: string & DPath.Path;
12
+
13
+ const result = await DSFile.realPath(path);
14
+
15
+ // Le résultat dépend de l’état du système de fichiers et des liens.
16
+
17
+ // L’information du Left identifie l’opération ; sa valeur précise la cause.
18
+ if (DEither.isLeft(result)) {
19
+ const error = DEither.unwrapLeft(result);
20
+
21
+ const diagnosis = DPattern.matchWithErrorOtherwise(
22
+ error,
23
+ {
24
+ "file-system-real-path-not-found": () => "missing",
25
+ "file-system-real-path-permission-denied": () => "access-denied",
26
+ },
27
+ (otherError) => otherError,
28
+ );
29
+ }
30
+
31
+ // Identifiants d’erreur déclarés pour cette opération :
32
+ // file-system-real-path-not-found
33
+ // file-system-real-path-permission-denied
34
+ // file-system-real-path-not-directory
35
+ // file-system-real-path-too-many-open-files
36
+ // file-system-real-path-error