@spinajs/fs 2.0.180 → 2.0.182

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 (73) hide show
  1. package/lib/cjs/cli/rm.d.ts +11 -11
  2. package/lib/cjs/cli/rm.js +28 -28
  3. package/lib/cjs/cli/rm.js.map +1 -1
  4. package/lib/cjs/cli/stat.d.ts +10 -10
  5. package/lib/cjs/cli/stat.js +26 -26
  6. package/lib/cjs/cli/stat.js.map +1 -1
  7. package/lib/cjs/config/fs.d.ts +33 -16
  8. package/lib/cjs/config/fs.d.ts.map +1 -1
  9. package/lib/cjs/config/fs.js +50 -36
  10. package/lib/cjs/config/fs.js.map +1 -1
  11. package/lib/cjs/decorators.d.ts +7 -7
  12. package/lib/cjs/decorators.js +23 -23
  13. package/lib/cjs/file-hasher.d.ts +12 -8
  14. package/lib/cjs/file-hasher.d.ts.map +1 -1
  15. package/lib/cjs/file-hasher.js +51 -42
  16. package/lib/cjs/file-hasher.js.map +1 -1
  17. package/lib/cjs/file-info.d.ts +10 -10
  18. package/lib/cjs/file-info.js +124 -124
  19. package/lib/cjs/file-info.js.map +1 -1
  20. package/lib/cjs/index.d.ts +10 -10
  21. package/lib/cjs/index.d.ts.map +1 -1
  22. package/lib/cjs/index.js +72 -71
  23. package/lib/cjs/index.js.map +1 -1
  24. package/lib/cjs/interfaces.d.ts +180 -157
  25. package/lib/cjs/interfaces.d.ts.map +1 -1
  26. package/lib/cjs/interfaces.js +44 -33
  27. package/lib/cjs/interfaces.js.map +1 -1
  28. package/lib/cjs/local-provider.d.ts +96 -100
  29. package/lib/cjs/local-provider.d.ts.map +1 -1
  30. package/lib/cjs/local-provider.js +321 -278
  31. package/lib/cjs/local-provider.js.map +1 -1
  32. package/lib/cjs/local-temp-provider.d.ts +18 -18
  33. package/lib/cjs/local-temp-provider.d.ts.map +1 -1
  34. package/lib/cjs/local-temp-provider.js +59 -54
  35. package/lib/cjs/local-temp-provider.js.map +1 -1
  36. package/lib/mjs/cli/rm.d.ts +11 -11
  37. package/lib/mjs/cli/rm.js +25 -25
  38. package/lib/mjs/cli/rm.js.map +1 -1
  39. package/lib/mjs/cli/stat.d.ts +10 -10
  40. package/lib/mjs/cli/stat.js +23 -23
  41. package/lib/mjs/cli/stat.js.map +1 -1
  42. package/lib/mjs/config/fs.d.ts +33 -16
  43. package/lib/mjs/config/fs.d.ts.map +1 -1
  44. package/lib/mjs/config/fs.js +48 -34
  45. package/lib/mjs/config/fs.js.map +1 -1
  46. package/lib/mjs/decorators.d.ts +7 -7
  47. package/lib/mjs/decorators.js +19 -19
  48. package/lib/mjs/file-hasher.d.ts +12 -8
  49. package/lib/mjs/file-hasher.d.ts.map +1 -1
  50. package/lib/mjs/file-hasher.js +45 -36
  51. package/lib/mjs/file-hasher.js.map +1 -1
  52. package/lib/mjs/file-info.d.ts +10 -10
  53. package/lib/mjs/file-info.js +121 -121
  54. package/lib/mjs/file-info.js.map +1 -1
  55. package/lib/mjs/index.d.ts +10 -10
  56. package/lib/mjs/index.d.ts.map +1 -1
  57. package/lib/mjs/index.js +55 -54
  58. package/lib/mjs/index.js.map +1 -1
  59. package/lib/mjs/interfaces.d.ts +180 -157
  60. package/lib/mjs/interfaces.d.ts.map +1 -1
  61. package/lib/mjs/interfaces.js +38 -27
  62. package/lib/mjs/interfaces.js.map +1 -1
  63. package/lib/mjs/local-provider.d.ts +96 -100
  64. package/lib/mjs/local-provider.d.ts.map +1 -1
  65. package/lib/mjs/local-provider.js +315 -272
  66. package/lib/mjs/local-provider.js.map +1 -1
  67. package/lib/mjs/local-temp-provider.d.ts +18 -18
  68. package/lib/mjs/local-temp-provider.d.ts.map +1 -1
  69. package/lib/mjs/local-temp-provider.js +56 -51
  70. package/lib/mjs/local-temp-provider.js.map +1 -1
  71. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  72. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  73. package/package.json +6 -2
@@ -1,158 +1,181 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
- import { AsyncService, IInstanceCheck, IMappableService } from '@spinajs/di';
5
- import { ReadStream, WriteStream } from 'fs';
6
- import { DateTime } from 'luxon';
7
- import { PassThrough } from 'stream';
8
- export interface IProviderConfiguration {
9
- name: string;
10
- service: string;
11
- }
12
- export interface IFsConfiguration {
13
- defaultProvider: string;
14
- providers: IProviderConfiguration[];
15
- }
16
- export interface IStat {
17
- IsDirectory?: boolean;
18
- IsFile?: boolean;
19
- Size?: number;
20
- AccessTime?: DateTime;
21
- ModifiedTime?: DateTime;
22
- CreationTime?: DateTime;
23
- AdditionalData?: unknown;
24
- }
25
- export interface IFileInfo {
26
- /**
27
- * Size in bytes
28
- */
29
- FileSize: number;
30
- Height?: number;
31
- Width?: number;
32
- Duration?: number;
33
- FrameCount?: number;
34
- FrameRate?: number;
35
- Bitrate?: number;
36
- Codec?: string;
37
- LineCount?: number;
38
- Encoding?: string;
39
- MimeType?: string;
40
- WordCount?: number;
41
- AccessDate?: DateTime;
42
- ModificationDate?: DateTime;
43
- CreationDate?: DateTime;
44
- /**
45
- * Raw unprocessed data obtained from file info
46
- */
47
- Raw?: {};
48
- }
49
- export interface IFsLocalOptions {
50
- /**
51
- * Full path to local directory where files are hold.
52
- * All paths will be relative to this directory
53
- */
54
- basePath: string;
55
- /**
56
- * Instance name of this filesystem. Used to share fs instances.
57
- */
58
- name: string;
59
- }
60
- export interface IFsLocalTempOptions extends IFsLocalOptions {
61
- /**
62
- * Should cleanup of old temp files be enabled
63
- */
64
- cleanup: boolean;
65
- /**
66
- * Cleanup interval in seconds
67
- * Default is 10 minutes
68
- */
69
- cleanupInterval: number;
70
- /**
71
- * Max temp file age in seconds. Older thant this will be deleted.
72
- * Default is 1 hour
73
- */
74
- maxFileAge: number;
75
- }
76
- export interface IZipResult {
77
- asFilePath(): string;
78
- asStream(): ReadStream;
79
- asBase64(): string;
80
- }
81
- export declare abstract class fs extends AsyncService implements IMappableService, IInstanceCheck {
82
- get ServiceName(): string;
83
- __checkInstance__(creationOptions: any): boolean;
84
- abstract Name: string;
85
- /**
86
- * Downloads file to local storage and returns path to it.
87
- * If used on local storage provider eg. hard drive it only returns full path to file
88
- *
89
- * On remote storage provivers eg. amazon s3 - it tries to download it to local disk first and returns
90
- * full path.
91
- *
92
- * Returns local path to file
93
- *
94
- * @param path path to download
95
- */
96
- abstract download(path: string): Promise<string>;
97
- /**
98
- * Copies local file into fs
99
- *
100
- * @param srcPath source path ( full absolute path eg. file from local disk )
101
- * @param destPath dest path ( relative to base path of provider )
102
- */
103
- abstract upload(srcPath: string, destPath?: string): Promise<void>;
104
- /**
105
- *
106
- * Returns full LOCAL path to file
107
- *
108
- * @param path path to resolve
109
- */
110
- abstract resolvePath(path: string): string;
111
- abstract read(path: string, encoding?: BufferEncoding): Promise<string | Buffer>;
112
- abstract readStream(path: string, encoding?: BufferEncoding): Promise<ReadStream>;
113
- abstract write(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
114
- abstract writeStream(path: string, encoding?: BufferEncoding): Promise<WriteStream | PassThrough>;
115
- abstract writeStream(path: string, readStream: ReadStream, encoding?: BufferEncoding): Promise<WriteStream | PassThrough | void>;
116
- abstract exists(path: string): Promise<boolean>;
117
- abstract dirExists(path: string): Promise<boolean>;
118
- abstract copy(path: string, dest: string): Promise<void>;
119
- abstract move(oldPath: string, newPath: string): Promise<void>;
120
- abstract rename(oldPath: string, newPath: string): Promise<void>;
121
- abstract unlink(path: string, downloaded?: boolean): Promise<void>;
122
- abstract rm(path: string): Promise<void>;
123
- abstract mkdir(path: string): Promise<void>;
124
- abstract stat(path: string): Promise<IStat>;
125
- abstract list(path: string): Promise<string[]>;
126
- abstract tmppath(): string;
127
- abstract append(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
128
- /**
129
- *
130
- * Compress specified file or dir in provided path. If
131
- * Dir is compressed recursively
132
- *
133
- * @param path - path to zip
134
- */
135
- abstract zip(path: string): Promise<IZipResult>;
136
- /**
137
- * Decompress given file to destination path
138
- *
139
- * @param path path to zip file
140
- * @param destPath path to destination dir
141
- */
142
- abstract unzip(srcPath: string, destPath: string): Promise<void>;
143
- tmpname(): string;
144
- }
145
- /**
146
- * File information service, obtain file props, metadata etc.
147
- * Eg. movie resolution, image, codec etc. if possible
148
- */
149
- export declare abstract class FileInfoService {
150
- abstract getInfo(pathToFile: string): Promise<IFileInfo>;
151
- }
152
- /**
153
- * File hasher, to create unique hash for file
154
- */
155
- export declare abstract class FileHasher {
156
- abstract hash(pathToFile: string): Promise<string>;
157
- }
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ /// <reference types="node" resolution-mode="require"/>
5
+ import { AsyncService, IInstanceCheck, IMappableService } from '@spinajs/di';
6
+ import { ReadStream, WriteStream } from 'fs';
7
+ import { DateTime } from 'luxon';
8
+ import { PassThrough } from 'stream';
9
+ export interface IProviderConfiguration {
10
+ name: string;
11
+ service: string;
12
+ }
13
+ export interface IFsConfiguration {
14
+ defaultProvider: string;
15
+ providers: IProviderConfiguration[];
16
+ }
17
+ export interface IStat {
18
+ IsDirectory?: boolean;
19
+ IsFile?: boolean;
20
+ Size?: number;
21
+ AccessTime?: DateTime;
22
+ ModifiedTime?: DateTime;
23
+ CreationTime?: DateTime;
24
+ AdditionalData?: unknown;
25
+ }
26
+ export interface IFileInfo {
27
+ /**
28
+ * Size in bytes
29
+ */
30
+ FileSize: number;
31
+ Height?: number;
32
+ Width?: number;
33
+ Duration?: number;
34
+ FrameCount?: number;
35
+ FrameRate?: number;
36
+ Bitrate?: number;
37
+ Codec?: string;
38
+ LineCount?: number;
39
+ Encoding?: string;
40
+ MimeType?: string;
41
+ WordCount?: number;
42
+ AccessDate?: DateTime;
43
+ ModificationDate?: DateTime;
44
+ CreationDate?: DateTime;
45
+ /**
46
+ * Raw unprocessed data obtained from file info
47
+ */
48
+ Raw?: {};
49
+ }
50
+ export interface IFsLocalOptions {
51
+ /**
52
+ * Full path to local directory where files are hold.
53
+ * All paths will be relative to this directory
54
+ *
55
+ * If path is not provided, it will behave like normal nodejs fs functions
56
+ */
57
+ basePath?: string;
58
+ /**
59
+ * Instance name of this filesystem. Used to share fs instances.
60
+ */
61
+ name: string;
62
+ }
63
+ export interface IFsLocalTempOptions extends IFsLocalOptions {
64
+ /**
65
+ * Should cleanup of old temp files be enabled
66
+ */
67
+ cleanup: boolean;
68
+ /**
69
+ * Cleanup interval in seconds
70
+ * Default is 10 minutes
71
+ */
72
+ cleanupInterval: number;
73
+ /**
74
+ * Max temp file age in seconds. Older thant this will be deleted.
75
+ * Default is 1 hour
76
+ */
77
+ maxFileAge: number;
78
+ }
79
+ export interface IZipResult {
80
+ /**
81
+ * Destination filesystem ( default is fs-temp for zipped files)
82
+ */
83
+ fs: fs;
84
+ asFilePath(): string;
85
+ asStream(): ReadStream;
86
+ asBase64(): string;
87
+ unlink(): void;
88
+ }
89
+ export declare abstract class fs extends AsyncService implements IMappableService, IInstanceCheck {
90
+ get ServiceName(): string;
91
+ __checkInstance__(creationOptions: any): boolean;
92
+ abstract Name: string;
93
+ /**
94
+ * Downloads file to local storage and returns path to it.
95
+ * If used on local storage provider eg. hard drive it only returns full path to file
96
+ *
97
+ * On remote storage provivers eg. amazon s3 - it tries to download it to local disk first and returns
98
+ * full path.
99
+ *
100
+ * Returns local path to file
101
+ *
102
+ * @param path path to download
103
+ */
104
+ abstract download(path: string): Promise<string>;
105
+ /**
106
+ * Copies local file into fs
107
+ *
108
+ * @param srcPath source path ( full absolute path eg. file from local disk )
109
+ * @param destPath dest path ( relative to base path of provider )
110
+ */
111
+ abstract upload(srcPath: string, destPath?: string): Promise<void>;
112
+ /**
113
+ *
114
+ * Returns hash of file
115
+ *
116
+ * @param srcPath file to calculate hash
117
+ * @param algo optional hash alghoritm, default is md5
118
+ */
119
+ hash(path: string, algo?: string): Promise<string>;
120
+ /**
121
+ *
122
+ * Returns full LOCAL path to file
123
+ *
124
+ * @param path path to resolve
125
+ */
126
+ abstract resolvePath(path: string): string;
127
+ abstract read(path: string, encoding?: BufferEncoding): Promise<string | Buffer>;
128
+ abstract readStream(path: string, encoding?: BufferEncoding): Promise<NodeJS.ReadableStream>;
129
+ abstract write(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
130
+ abstract writeStream(path: string, encoding?: BufferEncoding): Promise<WriteStream | PassThrough>;
131
+ abstract writeStream(path: string, readStream: NodeJS.ReadableStream | BufferEncoding, encoding?: BufferEncoding): Promise<WriteStream | PassThrough>;
132
+ abstract exists(path: string): Promise<boolean>;
133
+ abstract dirExists(path: string): Promise<boolean>;
134
+ abstract copy(path: string, dest: string, dstFs?: fs): Promise<void>;
135
+ abstract move(oldPath: string, newPath: string, dstFs?: fs): Promise<void>;
136
+ abstract rename(oldPath: string, newPath: string): Promise<void>;
137
+ abstract rm(path: string): Promise<void>;
138
+ abstract mkdir(path: string): Promise<void>;
139
+ abstract stat(path: string): Promise<IStat>;
140
+ abstract list(path: string): Promise<string[]>;
141
+ abstract tmppath(): string;
142
+ abstract append(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
143
+ /**
144
+ *
145
+ * Compress specified file or dir in provided path. If
146
+ * Dir is compressed recursively
147
+ *
148
+ * @param path - path to zip
149
+ * @param dstFile - destination file name
150
+ */
151
+ abstract zip(path: string | string[], dstFs?: fs, dstFile?: string): Promise<IZipResult>;
152
+ /**
153
+ * Decompress given file to destination path
154
+ *
155
+ * @param path path to zip file
156
+ * @param destPath path to destination dir
157
+ */
158
+ abstract unzip(srcPath: string, destPath: string, dstFs?: fs): Promise<void>;
159
+ /**
160
+ *
161
+ * Checks if given path is dir
162
+ *
163
+ * @param path path to check
164
+ */
165
+ abstract isDir(path: string): Promise<boolean>;
166
+ tmpname(): string;
167
+ }
168
+ /**
169
+ * File information service, obtain file props, metadata etc.
170
+ * Eg. movie resolution, image, codec etc. if possible
171
+ */
172
+ export declare abstract class FileInfoService {
173
+ abstract getInfo(pathToFile: string): Promise<IFileInfo>;
174
+ }
175
+ /**
176
+ * File hasher, to create unique hash for file
177
+ */
178
+ export declare abstract class FileHasher {
179
+ abstract hash(pathToFile: string): Promise<string>;
180
+ }
158
181
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";;;AACA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,KAAK;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB;;OAEG;IAEH,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAA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U,CAAC;IAE/F;;;;;OAKG;aACa,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnF;;;;;OAKG;aACa,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAE9C,OAAO;CAGf;AAED;;;GAGG;AACH,8BAAsB,eAAe;aACnB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAChE;AAED;;GAEG;AACH,8BAAsB,UAAU;aACd,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAC1D"}
@@ -1,28 +1,39 @@
1
- /* eslint-disable security/detect-non-literal-fs-filename */
2
- import { AsyncService } from '@spinajs/di';
3
- import { v4 as uuidv4 } from 'uuid';
4
- export class fs extends AsyncService {
5
- get ServiceName() {
6
- return this.Name;
7
- }
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- __checkInstance__(creationOptions) {
10
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
11
- return this.Name === creationOptions[0].name;
12
- }
13
- tmpname() {
14
- return uuidv4();
15
- }
16
- }
17
- /**
18
- * File information service, obtain file props, metadata etc.
19
- * Eg. movie resolution, image, codec etc. if possible
20
- */
21
- export class FileInfoService {
22
- }
23
- /**
24
- * File hasher, to create unique hash for file
25
- */
26
- export class FileHasher {
27
- }
1
+ /* eslint-disable security/detect-non-literal-fs-filename */
2
+ import { AsyncService, DI } from '@spinajs/di';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ export class fs extends AsyncService {
5
+ get ServiceName() {
6
+ return this.Name;
7
+ }
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ __checkInstance__(creationOptions) {
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
11
+ return this.Name === creationOptions[0].name;
12
+ }
13
+ /**
14
+ *
15
+ * Returns hash of file
16
+ *
17
+ * @param srcPath file to calculate hash
18
+ * @param algo optional hash alghoritm, default is md5
19
+ */
20
+ async hash(path, algo) {
21
+ const hasher = DI.resolve(FileHasher, [algo]);
22
+ return hasher.hash(this.resolvePath(path));
23
+ }
24
+ tmpname() {
25
+ return uuidv4();
26
+ }
27
+ }
28
+ /**
29
+ * File information service, obtain file props, metadata etc.
30
+ * Eg. movie resolution, image, codec etc. if possible
31
+ */
32
+ export class FileInfoService {
33
+ }
34
+ /**
35
+ * File hasher, to create unique hash for file
36
+ */
37
+ export class FileHasher {
38
+ }
28
39
  //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,YAAY,EAAoC,MAAM,aAAa,CAAC;AAI7E,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AA0FpC,MAAM,OAAgB,EAAG,SAAQ,YAAY;IAC3C,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,8DAA8D;IACvD,iBAAiB,CAAC,eAAoB;QAC3C,sEAAsE;QACtE,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/C,CAAC;IAuEM,OAAO;QACZ,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,eAAe;CAEpC;AAED;;GAEG;AACH,MAAM,OAAgB,UAAU;CAE/B"}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,YAAY,EAAE,EAAE,EAAoC,MAAM,aAAa,CAAC;AAIjF,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAyGpC,MAAM,OAAgB,EAAG,SAAQ,YAAY;IAC3C,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,8DAA8D;IACvD,iBAAiB,CAAC,eAAoB;QAC3C,sEAAsE;QACtE,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/C,CAAC;IAyBC;;;;;;KAMC;IACI,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAa;QAC3C,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAa,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;IAuDM,OAAO;QACZ,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAgB,eAAe;CAEpC;AAED;;GAEG;AACH,MAAM,OAAgB,UAAU;CAE/B"}
@@ -1,101 +1,97 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { ReadStream } from 'fs';
4
- import { fs, IFsLocalOptions, IStat, IZipResult } from './interfaces.js';
5
- import { Log } from '@spinajs/log-common';
6
- /**
7
- * Abstract layer for file operations.
8
- * Basic implementation is just wrapper for native node fs functions
9
- *
10
- * It allows to wrap other libs eg. aws s3, ftp
11
- * and inject it into code without changing logic that use them.
12
- *
13
- * TODO: map errors to some kind of common errors shared with other implementations
14
- */
15
- export declare class fsNative<T extends IFsLocalOptions> extends fs {
16
- Options: T;
17
- protected Logger: Log;
18
- /**
19
- * Name of provider. We can have multiple providers of the same type but with different options.
20
- * Also used in InjectService decorator for mapping
21
- */
22
- get Name(): string;
23
- constructor(Options: T);
24
- resolve(): Promise<void>;
25
- /**
26
- *
27
- * Tries to download file to local filesystem, then returns local filesystem path.
28
- * Native implementation simply returns local path and does nothing.
29
- *
30
- * @param path - file to download
31
- */
32
- download(path: string): Promise<string>;
33
- upload(srcPath: string, destPath?: string): Promise<void>;
34
- /**
35
- * read all content of file
36
- */
37
- read(path: string, encoding?: BufferEncoding): Promise<string | Buffer>;
38
- readStream(path: string, encoding?: BufferEncoding): Promise<ReadStream>;
39
- /**
40
- * Write to file string or buffer
41
- */
42
- write(path: string, data: string | Buffer, encoding: BufferEncoding): Promise<void>;
43
- append(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
44
- writeStream(path: string, rStream?: BufferEncoding | ReadStream, encoding?: BufferEncoding): Promise<import("fs").WriteStream>;
45
- /**
46
- * Checks if file existst
47
- * @param path - path to check
48
- */
49
- exists(path: string): Promise<boolean>;
50
- dirExists(path: string): Promise<boolean>;
51
- /**
52
- * Copy file to another location
53
- * @param path - src path
54
- * @param dest - dest path
55
- */
56
- copy(path: string, dest: string): Promise<void>;
57
- /**
58
- * Copy file to another location and deletes src file
59
- */
60
- move(oldPath: string, newPath: string): Promise<void>;
61
- /**
62
- * Change name of a file
63
- */
64
- rename(oldPath: string, newPath: string): Promise<void>;
65
- /**
66
- * Deletes file permanently
67
- *
68
- * @param path - path to file that will be deleted
69
- * @param onlyTemp - remote filesystems need to download file before, if so, calling unlink with this flag removes only local temp file after we finished processing
70
- */
71
- unlink(path: string, onlyTemp?: boolean): Promise<void>;
72
- /**
73
- *
74
- * Deletes dir recursively & all contents inside
75
- *
76
- * @param path - dir to remove
77
- */
78
- rm(path: string): Promise<void>;
79
- /**
80
- *
81
- * Creates directory, recursively
82
- *
83
- * @param path - directory to create
84
- */
85
- mkdir(path: string): Promise<void>;
86
- /**
87
- * Returns file statistics, not all fields may be accesible
88
- */
89
- stat(path: string): Promise<IStat>;
90
- tmppath(): string;
91
- /**
92
- * List content of directory
93
- *
94
- * @param path - path to directory
95
- */
96
- list(path: string): Promise<string[]>;
97
- unzip(path: string, destPath: string): Promise<void>;
98
- zip(path: string, zName?: string): Promise<IZipResult>;
99
- resolvePath(path: string): string;
100
- }
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import { ReadStream } from 'fs';
5
+ import { fs, IFsLocalOptions, IStat, IZipResult } from './interfaces.js';
6
+ import { Log } from '@spinajs/log-common';
7
+ /**
8
+ * Abstract layer for file operations.
9
+ * Basic implementation is just wrapper for native node fs functions
10
+ *
11
+ * It allows to wrap other libs eg. aws s3, ftp
12
+ * and inject it into code without changing logic that use them.
13
+ *
14
+ * TODO: map errors to some kind of common errors shared with other implementations
15
+ */
16
+ export declare class fsNative<T extends IFsLocalOptions> extends fs {
17
+ Options: T;
18
+ protected Logger: Log;
19
+ /**
20
+ * Name of provider. We can have multiple providers of the same type but with different options.
21
+ * Also used in InjectService decorator for mapping
22
+ */
23
+ get Name(): string;
24
+ constructor(Options: T);
25
+ resolve(): Promise<void>;
26
+ /**
27
+ *
28
+ * Tries to download file to local filesystem, then returns local filesystem path.
29
+ * Native implementation simply returns local path and does nothing.
30
+ *
31
+ * @param path - file to download
32
+ */
33
+ download(path: string): Promise<string>;
34
+ upload(srcPath: string, destPath?: string): Promise<void>;
35
+ /**
36
+ * read all content of file
37
+ */
38
+ read(path: string, encoding?: BufferEncoding): Promise<string | Buffer>;
39
+ readStream(path: string, encoding?: BufferEncoding): Promise<ReadStream>;
40
+ /**
41
+ * Write to file string or buffer
42
+ */
43
+ write(path: string, data: string | Buffer, encoding: BufferEncoding): Promise<void>;
44
+ append(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
45
+ writeStream(path: string, rStream?: BufferEncoding | NodeJS.ReadStream, encoding?: BufferEncoding): Promise<import("fs").WriteStream>;
46
+ /**
47
+ * Checks if file existst
48
+ * @param path - path to check
49
+ */
50
+ exists(path: string): Promise<boolean>;
51
+ dirExists(path: string): Promise<boolean>;
52
+ /**
53
+ * Copy file or dir to another location
54
+ * @param path - src path
55
+ * @param dest - dest path
56
+ */
57
+ copy(path: string, dest: string, dstFs?: fs): Promise<void>;
58
+ /**
59
+ * Copy file to another location and deletes src file
60
+ */
61
+ move(oldPath: string, newPath: string, dstFs?: fs): Promise<void>;
62
+ /**
63
+ * Change name of a file
64
+ */
65
+ rename(oldPath: string, newPath: string): Promise<void>;
66
+ /**
67
+ *
68
+ * Deletes file OR
69
+ * Deletes dir recursively & all contents inside
70
+ *
71
+ * @param path - dir to remove
72
+ */
73
+ rm(path: string): Promise<void>;
74
+ /**
75
+ *
76
+ * Creates directory, recursively
77
+ *
78
+ * @param path - directory to create
79
+ */
80
+ mkdir(path: string): Promise<void>;
81
+ /**
82
+ * Returns file statistics, not all fields may be accesible
83
+ */
84
+ stat(path: string): Promise<IStat>;
85
+ tmppath(): string;
86
+ /**
87
+ * List content of directory
88
+ *
89
+ * @param path - path to directory
90
+ */
91
+ list(path: string): Promise<string[]>;
92
+ unzip(path: string, destPath?: string, dstFs?: fs): Promise<void>;
93
+ isDir(path: string): Promise<boolean>;
94
+ zip(path: string | string[], dstFs?: fs, dstFile?: string): Promise<IZipResult>;
95
+ resolvePath(path: string): string;
96
+ }
101
97
  //# sourceMappingURL=local-provider.d.ts.map