@procedures/fs 0.2.3 → 0.3.0

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 (54) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +73 -1
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/handlers.d.ts +40 -0
  5. package/dist/handlers.d.ts.map +1 -0
  6. package/dist/handlers.js +163 -0
  7. package/dist/handlers.js.map +1 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/module.d.ts +23 -2
  13. package/dist/module.d.ts.map +1 -1
  14. package/dist/module.js +94 -3
  15. package/dist/module.js.map +1 -1
  16. package/dist/procedures/fs/hash.d.ts +12 -0
  17. package/dist/procedures/fs/hash.d.ts.map +1 -0
  18. package/dist/procedures/fs/hash.js +23 -0
  19. package/dist/procedures/fs/hash.js.map +1 -0
  20. package/dist/procedures/fs/index.d.ts +4 -0
  21. package/dist/procedures/fs/index.d.ts.map +1 -1
  22. package/dist/procedures/fs/index.js +4 -0
  23. package/dist/procedures/fs/index.js.map +1 -1
  24. package/dist/procedures/fs/temp.d.ts +14 -0
  25. package/dist/procedures/fs/temp.d.ts.map +1 -0
  26. package/dist/procedures/fs/temp.js +20 -0
  27. package/dist/procedures/fs/temp.js.map +1 -0
  28. package/dist/procedures/fs/watch.d.ts +14 -0
  29. package/dist/procedures/fs/watch.d.ts.map +1 -0
  30. package/dist/procedures/fs/watch.js +26 -0
  31. package/dist/procedures/fs/watch.js.map +1 -0
  32. package/dist/procedures/fs/write-json.d.ts +12 -0
  33. package/dist/procedures/fs/write-json.d.ts.map +1 -0
  34. package/dist/procedures/fs/write-json.js +33 -0
  35. package/dist/procedures/fs/write-json.js.map +1 -0
  36. package/dist/root.d.ts +52 -0
  37. package/dist/root.d.ts.map +1 -0
  38. package/dist/root.js +129 -0
  39. package/dist/root.js.map +1 -0
  40. package/dist/types.d.ts +55 -0
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/types.js +37 -0
  43. package/dist/types.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/handlers.ts +214 -0
  46. package/src/index.ts +2 -0
  47. package/src/module.ts +127 -4
  48. package/src/procedures/fs/hash.ts +25 -0
  49. package/src/procedures/fs/index.ts +4 -0
  50. package/src/procedures/fs/temp.ts +22 -0
  51. package/src/procedures/fs/watch.ts +26 -0
  52. package/src/procedures/fs/write-json.ts +32 -0
  53. package/src/root.ts +139 -0
  54. package/src/types.ts +106 -0
package/src/types.ts CHANGED
@@ -405,3 +405,109 @@ export const ReadJsonOutputSchema: z.ZodType<ReadJsonOutput> = z.looseObject({
405
405
  data: z.unknown().describe("The parsed JSON value"),
406
406
  stats: StatOutputSchema.describe("The stats of the file"),
407
407
  });
408
+
409
+
410
+ // =============================================================================
411
+ // fs.write.json, fs.hash, fs.temp and fs.watch (roadmap R44)
412
+ // =============================================================================
413
+
414
+ export interface FsWriteJsonInput {
415
+ /** The path of the file */
416
+ path: string;
417
+ /** The value to write (required: null writes null) */
418
+ value: unknown;
419
+ /** The spaces of the indent (default 2) */
420
+ indent?: number | undefined;
421
+ }
422
+
423
+ export interface FsWriteJsonOutput {
424
+ path: string;
425
+ bytesWritten: number;
426
+ }
427
+
428
+ export const FsWriteJsonInputSchema: z.ZodType<FsWriteJsonInput> = z.object({
429
+ path: z.string().describe("The path of the file"),
430
+ value: z.unknown().describe("The value to write as JSON"),
431
+ indent: z.number().int().min(0).max(10).optional().describe("The spaces of the indent (default 2)"),
432
+ });
433
+
434
+ export const FsWriteJsonOutputSchema: z.ZodType<FsWriteJsonOutput> = z.looseObject({
435
+ path: z.string().describe("The path of the file"),
436
+ bytesWritten: z.number().describe("The bytes of the file"),
437
+ });
438
+
439
+ export type HashAlgorithm = "sha256" | "sha512" | "sha1" | "md5";
440
+
441
+ export interface FsHashInput {
442
+ path: string;
443
+ /** The algorithm (default sha256) */
444
+ algorithm?: HashAlgorithm | undefined;
445
+ }
446
+
447
+ export interface FsHashOutput {
448
+ path: string;
449
+ algorithm: HashAlgorithm;
450
+ /** The hash, as hexadecimal text */
451
+ hash: string;
452
+ /** The bytes of the file */
453
+ size: number;
454
+ }
455
+
456
+ export const FsHashInputSchema: z.ZodType<FsHashInput> = z.object({
457
+ path: z.string().describe("The path of the file"),
458
+ algorithm: z.enum(["sha256", "sha512", "sha1", "md5"]).optional().describe("The algorithm (default sha256)"),
459
+ });
460
+
461
+ export const FsHashOutputSchema: z.ZodType<FsHashOutput> = z.looseObject({
462
+ path: z.string().describe("The path of the file"),
463
+ algorithm: z.enum(["sha256", "sha512", "sha1", "md5"]).describe("The algorithm"),
464
+ hash: z.string().describe("The hash, as hexadecimal text"),
465
+ size: z.number().describe("The bytes of the file"),
466
+ });
467
+
468
+ export interface FsTempInput {
469
+ /** The start of the name of the folder (default "procedures-") */
470
+ prefix?: string | undefined;
471
+ }
472
+
473
+ export interface FsTempOutput {
474
+ /** The path of the new folder */
475
+ path: string;
476
+ }
477
+
478
+ export const FsTempInputSchema: z.ZodType<FsTempInput> = z.object({
479
+ prefix: z
480
+ .string()
481
+ .regex(/^[A-Za-z0-9._-]{0,40}$/, "letters, digits, dot, underscore and hyphen only")
482
+ .optional()
483
+ .describe('The start of the name of the folder (default "procedures-")'),
484
+ });
485
+
486
+ export const FsTempOutputSchema: z.ZodType<FsTempOutput> = z.looseObject({
487
+ path: z.string().describe("The path of the new folder"),
488
+ });
489
+
490
+ export interface FsWatchInput {
491
+ /** The file or folder to watch */
492
+ path: string;
493
+ /** Also the changes in the subfolders */
494
+ recursive?: boolean | undefined;
495
+ }
496
+
497
+ /** One change: an item of the stream of fs.watch. */
498
+ export interface FsWatchOutput {
499
+ /** "rename" for a file that appears or goes away, "change" for a change of its content */
500
+ event: "rename" | "change";
501
+ /** The name of the file, relative to the path, when the platform gives it */
502
+ filename: string | null;
503
+ }
504
+
505
+ export const FsWatchInputSchema: z.ZodType<FsWatchInput> = z.object({
506
+ path: z.string().describe("The file or folder to watch"),
507
+ recursive: z.boolean().optional().describe("Also the changes in the subfolders"),
508
+ });
509
+
510
+ export const FsWatchOutputSchema: z.ZodType<FsWatchOutput> = z.looseObject({
511
+ event: z.enum(["rename", "change"]).describe('"rename" for a file that appears or goes away, "change" for its content'),
512
+ filename: z.string().nullable().describe("The name of the file, relative to the path, when the platform gives it"),
513
+ });