@nocobase/plugin-backup-restore 0.19.0-alpha.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 (158) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +118 -0
  3. package/README.zh-CN.md +118 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/Configuration.d.ts +2 -0
  7. package/dist/client/DuplicatorProvider.d.ts +2 -0
  8. package/dist/client/index.d.ts +5 -0
  9. package/dist/client/index.js +1 -0
  10. package/dist/client/locale/index.d.ts +4 -0
  11. package/dist/externalVersion.js +14 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +39 -0
  14. package/dist/locale/en-US.json +44 -0
  15. package/dist/locale/ja-JP.d.ts +25 -0
  16. package/dist/locale/ja-JP.js +46 -0
  17. package/dist/locale/pt-BR.d.ts +26 -0
  18. package/dist/locale/pt-BR.js +48 -0
  19. package/dist/locale/zh-CN.json +50 -0
  20. package/dist/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  21. package/dist/node_modules/@hapi/topo/lib/index.js +1 -0
  22. package/dist/node_modules/@hapi/topo/package.json +1 -0
  23. package/dist/node_modules/archiver/LICENSE +22 -0
  24. package/dist/node_modules/archiver/index.js +68 -0
  25. package/dist/node_modules/archiver/lib/core.js +974 -0
  26. package/dist/node_modules/archiver/lib/error.js +40 -0
  27. package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
  28. package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
  29. package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
  30. package/dist/node_modules/archiver/node_modules/readable-stream/errors-browser.js +127 -0
  31. package/dist/node_modules/archiver/node_modules/readable-stream/errors.js +116 -0
  32. package/dist/node_modules/archiver/node_modules/readable-stream/experimentalWarning.js +17 -0
  33. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
  34. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
  35. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
  36. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_transform.js +190 -0
  37. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_writable.js +641 -0
  38. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
  39. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
  40. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
  41. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
  42. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  43. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
  44. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
  45. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
  46. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  47. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  48. package/dist/node_modules/archiver/node_modules/readable-stream/package.json +68 -0
  49. package/dist/node_modules/archiver/node_modules/readable-stream/readable-browser.js +9 -0
  50. package/dist/node_modules/archiver/node_modules/readable-stream/readable.js +16 -0
  51. package/dist/node_modules/archiver/node_modules/string_decoder/lib/string_decoder.js +296 -0
  52. package/dist/node_modules/archiver/node_modules/string_decoder/package.json +34 -0
  53. package/dist/node_modules/archiver/node_modules/tar-stream/extract.js +257 -0
  54. package/dist/node_modules/archiver/node_modules/tar-stream/headers.js +295 -0
  55. package/dist/node_modules/archiver/node_modules/tar-stream/index.js +2 -0
  56. package/dist/node_modules/archiver/node_modules/tar-stream/pack.js +255 -0
  57. package/dist/node_modules/archiver/node_modules/tar-stream/package.json +58 -0
  58. package/dist/node_modules/archiver/node_modules/tar-stream/sandbox.js +11 -0
  59. package/dist/node_modules/archiver/package.json +1 -0
  60. package/dist/node_modules/decompress/index.js +16 -0
  61. package/dist/node_modules/decompress/license +9 -0
  62. package/dist/node_modules/decompress/node_modules/make-dir/index.js +85 -0
  63. package/dist/node_modules/decompress/node_modules/make-dir/license +9 -0
  64. package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/index.js +84 -0
  65. package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/license +9 -0
  66. package/dist/node_modules/decompress/node_modules/make-dir/node_modules/pify/package.json +51 -0
  67. package/dist/node_modules/decompress/node_modules/make-dir/package.json +54 -0
  68. package/dist/node_modules/decompress/package.json +1 -0
  69. package/dist/node_modules/mkdirp/LICENSE +21 -0
  70. package/dist/node_modules/mkdirp/bin/cmd.js +68 -0
  71. package/dist/node_modules/mkdirp/index.js +1 -0
  72. package/dist/node_modules/mkdirp/lib/find-made.js +29 -0
  73. package/dist/node_modules/mkdirp/lib/mkdirp-manual.js +64 -0
  74. package/dist/node_modules/mkdirp/lib/mkdirp-native.js +39 -0
  75. package/dist/node_modules/mkdirp/lib/opts-arg.js +23 -0
  76. package/dist/node_modules/mkdirp/lib/path-arg.js +29 -0
  77. package/dist/node_modules/mkdirp/lib/use-native.js +10 -0
  78. package/dist/node_modules/mkdirp/package.json +1 -0
  79. package/dist/node_modules/mkdirp/readme.markdown +266 -0
  80. package/dist/node_modules/semver/LICENSE +15 -0
  81. package/dist/node_modules/semver/bin/semver.js +197 -0
  82. package/dist/node_modules/semver/classes/comparator.js +141 -0
  83. package/dist/node_modules/semver/classes/index.js +5 -0
  84. package/dist/node_modules/semver/classes/range.js +539 -0
  85. package/dist/node_modules/semver/classes/semver.js +302 -0
  86. package/dist/node_modules/semver/functions/clean.js +6 -0
  87. package/dist/node_modules/semver/functions/cmp.js +52 -0
  88. package/dist/node_modules/semver/functions/coerce.js +52 -0
  89. package/dist/node_modules/semver/functions/compare-build.js +7 -0
  90. package/dist/node_modules/semver/functions/compare-loose.js +3 -0
  91. package/dist/node_modules/semver/functions/compare.js +5 -0
  92. package/dist/node_modules/semver/functions/diff.js +65 -0
  93. package/dist/node_modules/semver/functions/eq.js +3 -0
  94. package/dist/node_modules/semver/functions/gt.js +3 -0
  95. package/dist/node_modules/semver/functions/gte.js +3 -0
  96. package/dist/node_modules/semver/functions/inc.js +19 -0
  97. package/dist/node_modules/semver/functions/lt.js +3 -0
  98. package/dist/node_modules/semver/functions/lte.js +3 -0
  99. package/dist/node_modules/semver/functions/major.js +3 -0
  100. package/dist/node_modules/semver/functions/minor.js +3 -0
  101. package/dist/node_modules/semver/functions/neq.js +3 -0
  102. package/dist/node_modules/semver/functions/parse.js +16 -0
  103. package/dist/node_modules/semver/functions/patch.js +3 -0
  104. package/dist/node_modules/semver/functions/prerelease.js +6 -0
  105. package/dist/node_modules/semver/functions/rcompare.js +3 -0
  106. package/dist/node_modules/semver/functions/rsort.js +3 -0
  107. package/dist/node_modules/semver/functions/satisfies.js +10 -0
  108. package/dist/node_modules/semver/functions/sort.js +3 -0
  109. package/dist/node_modules/semver/functions/valid.js +6 -0
  110. package/dist/node_modules/semver/index.js +1 -0
  111. package/dist/node_modules/semver/internal/constants.js +35 -0
  112. package/dist/node_modules/semver/internal/debug.js +9 -0
  113. package/dist/node_modules/semver/internal/identifiers.js +23 -0
  114. package/dist/node_modules/semver/internal/parse-options.js +15 -0
  115. package/dist/node_modules/semver/internal/re.js +212 -0
  116. package/dist/node_modules/semver/package.json +1 -0
  117. package/dist/node_modules/semver/preload.js +2 -0
  118. package/dist/node_modules/semver/range.bnf +16 -0
  119. package/dist/node_modules/semver/ranges/gtr.js +4 -0
  120. package/dist/node_modules/semver/ranges/intersects.js +7 -0
  121. package/dist/node_modules/semver/ranges/ltr.js +4 -0
  122. package/dist/node_modules/semver/ranges/max-satisfying.js +25 -0
  123. package/dist/node_modules/semver/ranges/min-satisfying.js +24 -0
  124. package/dist/node_modules/semver/ranges/min-version.js +61 -0
  125. package/dist/node_modules/semver/ranges/outside.js +80 -0
  126. package/dist/node_modules/semver/ranges/simplify.js +47 -0
  127. package/dist/node_modules/semver/ranges/subset.js +247 -0
  128. package/dist/node_modules/semver/ranges/to-comparators.js +8 -0
  129. package/dist/node_modules/semver/ranges/valid.js +11 -0
  130. package/dist/server/app-migrator.d.ts +17 -0
  131. package/dist/server/app-migrator.js +61 -0
  132. package/dist/server/collection-group-manager.d.ts +4 -0
  133. package/dist/server/collection-group-manager.js +29 -0
  134. package/dist/server/commands/restore-command.d.ts +2 -0
  135. package/dist/server/commands/restore-command.js +67 -0
  136. package/dist/server/dumper.d.ts +71 -0
  137. package/dist/server/dumper.js +406 -0
  138. package/dist/server/errors/restore-check-error.d.ts +3 -0
  139. package/dist/server/errors/restore-check-error.js +32 -0
  140. package/dist/server/field-value-writer.d.ts +9 -0
  141. package/dist/server/field-value-writer.js +101 -0
  142. package/dist/server/index.d.ts +1 -0
  143. package/dist/server/index.js +33 -0
  144. package/dist/server/locale/zh-CN.d.ts +9 -0
  145. package/dist/server/locale/zh-CN.js +30 -0
  146. package/dist/server/resourcers/backup-files.d.ts +25 -0
  147. package/dist/server/resourcers/backup-files.js +193 -0
  148. package/dist/server/restorer.d.ts +36 -0
  149. package/dist/server/restorer.js +326 -0
  150. package/dist/server/server.d.ts +5 -0
  151. package/dist/server/server.js +41 -0
  152. package/dist/server/utils.d.ts +5 -0
  153. package/dist/server/utils.js +78 -0
  154. package/dist/swagger/index.d.ts +392 -0
  155. package/dist/swagger/index.js +447 -0
  156. package/package.json +40 -0
  157. package/server.d.ts +2 -0
  158. package/server.js +1 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Archiver Core
3
+ *
4
+ * @ignore
5
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
6
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
7
+ */
8
+
9
+ var util = require('util');
10
+
11
+ const ERROR_CODES = {
12
+ 'ABORTED': 'archive was aborted',
13
+ 'DIRECTORYDIRPATHREQUIRED': 'diretory dirpath argument must be a non-empty string value',
14
+ 'DIRECTORYFUNCTIONINVALIDDATA': 'invalid data returned by directory custom data function',
15
+ 'ENTRYNAMEREQUIRED': 'entry name must be a non-empty string value',
16
+ 'FILEFILEPATHREQUIRED': 'file filepath argument must be a non-empty string value',
17
+ 'FINALIZING': 'archive already finalizing',
18
+ 'QUEUECLOSED': 'queue closed',
19
+ 'NOENDMETHOD': 'no suitable finalize/end method defined by module',
20
+ 'DIRECTORYNOTSUPPORTED': 'support for directory entries not defined by module',
21
+ 'FORMATSET': 'archive format already set',
22
+ 'INPUTSTEAMBUFFERREQUIRED': 'input source must be valid Stream or Buffer instance',
23
+ 'MODULESET': 'module already set',
24
+ 'SYMLINKNOTSUPPORTED': 'support for symlink entries not defined by module',
25
+ 'SYMLINKFILEPATHREQUIRED': 'symlink filepath argument must be a non-empty string value',
26
+ 'SYMLINKTARGETREQUIRED': 'symlink target argument must be a non-empty string value',
27
+ 'ENTRYNOTSUPPORTED': 'entry not supported'
28
+ };
29
+
30
+ function ArchiverError(code, data) {
31
+ Error.captureStackTrace(this, this.constructor);
32
+ //this.name = this.constructor.name;
33
+ this.message = ERROR_CODES[code] || code;
34
+ this.code = code;
35
+ this.data = data;
36
+ }
37
+
38
+ util.inherits(ArchiverError, Error);
39
+
40
+ exports = module.exports = ArchiverError;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * JSON Format Plugin
3
+ *
4
+ * @module plugins/json
5
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
6
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
7
+ */
8
+ var inherits = require('util').inherits;
9
+ var Transform = require('readable-stream').Transform;
10
+
11
+ var crc32 = require('buffer-crc32');
12
+ var util = require('archiver-utils');
13
+
14
+ /**
15
+ * @constructor
16
+ * @param {(JsonOptions|TransformOptions)} options
17
+ */
18
+ var Json = function(options) {
19
+ if (!(this instanceof Json)) {
20
+ return new Json(options);
21
+ }
22
+
23
+ options = this.options = util.defaults(options, {});
24
+
25
+ Transform.call(this, options);
26
+
27
+ this.supports = {
28
+ directory: true,
29
+ symlink: true
30
+ };
31
+
32
+ this.files = [];
33
+ };
34
+
35
+ inherits(Json, Transform);
36
+
37
+ /**
38
+ * [_transform description]
39
+ *
40
+ * @private
41
+ * @param {Buffer} chunk
42
+ * @param {String} encoding
43
+ * @param {Function} callback
44
+ * @return void
45
+ */
46
+ Json.prototype._transform = function(chunk, encoding, callback) {
47
+ callback(null, chunk);
48
+ };
49
+
50
+ /**
51
+ * [_writeStringified description]
52
+ *
53
+ * @private
54
+ * @return void
55
+ */
56
+ Json.prototype._writeStringified = function() {
57
+ var fileString = JSON.stringify(this.files);
58
+ this.write(fileString);
59
+ };
60
+
61
+ /**
62
+ * [append description]
63
+ *
64
+ * @param {(Buffer|Stream)} source
65
+ * @param {EntryData} data
66
+ * @param {Function} callback
67
+ * @return void
68
+ */
69
+ Json.prototype.append = function(source, data, callback) {
70
+ var self = this;
71
+
72
+ data.crc32 = 0;
73
+
74
+ function onend(err, sourceBuffer) {
75
+ if (err) {
76
+ callback(err);
77
+ return;
78
+ }
79
+
80
+ data.size = sourceBuffer.length || 0;
81
+ data.crc32 = crc32.unsigned(sourceBuffer);
82
+
83
+ self.files.push(data);
84
+
85
+ callback(null, data);
86
+ }
87
+
88
+ if (data.sourceType === 'buffer') {
89
+ onend(null, source);
90
+ } else if (data.sourceType === 'stream') {
91
+ util.collectStream(source, onend);
92
+ }
93
+ };
94
+
95
+ /**
96
+ * [finalize description]
97
+ *
98
+ * @return void
99
+ */
100
+ Json.prototype.finalize = function() {
101
+ this._writeStringified();
102
+ this.end();
103
+ };
104
+
105
+ module.exports = Json;
106
+
107
+ /**
108
+ * @typedef {Object} JsonOptions
109
+ * @global
110
+ */
@@ -0,0 +1,167 @@
1
+ /**
2
+ * TAR Format Plugin
3
+ *
4
+ * @module plugins/tar
5
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
6
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
7
+ */
8
+ var zlib = require('zlib');
9
+
10
+ var engine = require('tar-stream');
11
+ var util = require('archiver-utils');
12
+
13
+ /**
14
+ * @constructor
15
+ * @param {TarOptions} options
16
+ */
17
+ var Tar = function(options) {
18
+ if (!(this instanceof Tar)) {
19
+ return new Tar(options);
20
+ }
21
+
22
+ options = this.options = util.defaults(options, {
23
+ gzip: false
24
+ });
25
+
26
+ if (typeof options.gzipOptions !== 'object') {
27
+ options.gzipOptions = {};
28
+ }
29
+
30
+ this.supports = {
31
+ directory: true,
32
+ symlink: true
33
+ };
34
+
35
+ this.engine = engine.pack(options);
36
+ this.compressor = false;
37
+
38
+ if (options.gzip) {
39
+ this.compressor = zlib.createGzip(options.gzipOptions);
40
+ this.compressor.on('error', this._onCompressorError.bind(this));
41
+ }
42
+ };
43
+
44
+ /**
45
+ * [_onCompressorError description]
46
+ *
47
+ * @private
48
+ * @param {Error} err
49
+ * @return void
50
+ */
51
+ Tar.prototype._onCompressorError = function(err) {
52
+ this.engine.emit('error', err);
53
+ };
54
+
55
+ /**
56
+ * [append description]
57
+ *
58
+ * @param {(Buffer|Stream)} source
59
+ * @param {TarEntryData} data
60
+ * @param {Function} callback
61
+ * @return void
62
+ */
63
+ Tar.prototype.append = function(source, data, callback) {
64
+ var self = this;
65
+
66
+ data.mtime = data.date;
67
+
68
+ function append(err, sourceBuffer) {
69
+ if (err) {
70
+ callback(err);
71
+ return;
72
+ }
73
+
74
+ self.engine.entry(data, sourceBuffer, function(err) {
75
+ callback(err, data);
76
+ });
77
+ }
78
+
79
+ if (data.sourceType === 'buffer') {
80
+ append(null, source);
81
+ } else if (data.sourceType === 'stream' && data.stats) {
82
+ data.size = data.stats.size;
83
+
84
+ var entry = self.engine.entry(data, function(err) {
85
+ callback(err, data);
86
+ });
87
+
88
+ source.pipe(entry);
89
+ } else if (data.sourceType === 'stream') {
90
+ util.collectStream(source, append);
91
+ }
92
+ };
93
+
94
+ /**
95
+ * [finalize description]
96
+ *
97
+ * @return void
98
+ */
99
+ Tar.prototype.finalize = function() {
100
+ this.engine.finalize();
101
+ };
102
+
103
+ /**
104
+ * [on description]
105
+ *
106
+ * @return this.engine
107
+ */
108
+ Tar.prototype.on = function() {
109
+ return this.engine.on.apply(this.engine, arguments);
110
+ };
111
+
112
+ /**
113
+ * [pipe description]
114
+ *
115
+ * @param {String} destination
116
+ * @param {Object} options
117
+ * @return this.engine
118
+ */
119
+ Tar.prototype.pipe = function(destination, options) {
120
+ if (this.compressor) {
121
+ return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
122
+ } else {
123
+ return this.engine.pipe.apply(this.engine, arguments);
124
+ }
125
+ };
126
+
127
+ /**
128
+ * [unpipe description]
129
+ *
130
+ * @return this.engine
131
+ */
132
+ Tar.prototype.unpipe = function() {
133
+ if (this.compressor) {
134
+ return this.compressor.unpipe.apply(this.compressor, arguments);
135
+ } else {
136
+ return this.engine.unpipe.apply(this.engine, arguments);
137
+ }
138
+ };
139
+
140
+ module.exports = Tar;
141
+
142
+ /**
143
+ * @typedef {Object} TarOptions
144
+ * @global
145
+ * @property {Boolean} [gzip=false] Compress the tar archive using gzip.
146
+ * @property {Object} [gzipOptions] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
147
+ * to control compression.
148
+ * @property {*} [*] See [tar-stream]{@link https://github.com/mafintosh/tar-stream} documentation for additional properties.
149
+ */
150
+
151
+ /**
152
+ * @typedef {Object} TarEntryData
153
+ * @global
154
+ * @property {String} name Sets the entry name including internal path.
155
+ * @property {(String|Date)} [date=NOW()] Sets the entry date.
156
+ * @property {Number} [mode=D:0755/F:0644] Sets the entry permissions.
157
+ * @property {String} [prefix] Sets a path prefix for the entry name. Useful
158
+ * when working with methods like `directory` or `glob`.
159
+ * @property {fs.Stats} [stats] Sets the fs stat data for this entry allowing
160
+ * for reduction of fs stat calls when stat data is already known.
161
+ */
162
+
163
+ /**
164
+ * TarStream Module
165
+ * @external TarStream
166
+ * @see {@link https://github.com/mafintosh/tar-stream}
167
+ */
@@ -0,0 +1,120 @@
1
+ /**
2
+ * ZIP Format Plugin
3
+ *
4
+ * @module plugins/zip
5
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
6
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
7
+ */
8
+ var engine = require('zip-stream');
9
+ var util = require('archiver-utils');
10
+
11
+ /**
12
+ * @constructor
13
+ * @param {ZipOptions} [options]
14
+ * @param {String} [options.comment] Sets the zip archive comment.
15
+ * @param {Boolean} [options.forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
16
+ * @param {Boolean} [options.forceZip64=false] Forces the archive to contain ZIP64 headers.
17
+ * @param {Boolean} [options.namePrependSlash=false] Prepends a forward slash to archive file paths.
18
+ * @param {Boolean} [options.store=false] Sets the compression method to STORE.
19
+ * @param {Object} [options.zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
20
+ */
21
+ var Zip = function(options) {
22
+ if (!(this instanceof Zip)) {
23
+ return new Zip(options);
24
+ }
25
+
26
+ options = this.options = util.defaults(options, {
27
+ comment: '',
28
+ forceUTC: false,
29
+ namePrependSlash: false,
30
+ store: false
31
+ });
32
+
33
+ this.supports = {
34
+ directory: true,
35
+ symlink: true
36
+ };
37
+
38
+ this.engine = new engine(options);
39
+ };
40
+
41
+ /**
42
+ * @param {(Buffer|Stream)} source
43
+ * @param {ZipEntryData} data
44
+ * @param {String} data.name Sets the entry name including internal path.
45
+ * @param {(String|Date)} [data.date=NOW()] Sets the entry date.
46
+ * @param {Number} [data.mode=D:0755/F:0644] Sets the entry permissions.
47
+ * @param {String} [data.prefix] Sets a path prefix for the entry name. Useful
48
+ * when working with methods like `directory` or `glob`.
49
+ * @param {fs.Stats} [data.stats] Sets the fs stat data for this entry allowing
50
+ * for reduction of fs stat calls when stat data is already known.
51
+ * @param {Boolean} [data.store=ZipOptions.store] Sets the compression method to STORE.
52
+ * @param {Function} callback
53
+ * @return void
54
+ */
55
+ Zip.prototype.append = function(source, data, callback) {
56
+ this.engine.entry(source, data, callback);
57
+ };
58
+
59
+ /**
60
+ * @return void
61
+ */
62
+ Zip.prototype.finalize = function() {
63
+ this.engine.finalize();
64
+ };
65
+
66
+ /**
67
+ * @return this.engine
68
+ */
69
+ Zip.prototype.on = function() {
70
+ return this.engine.on.apply(this.engine, arguments);
71
+ };
72
+
73
+ /**
74
+ * @return this.engine
75
+ */
76
+ Zip.prototype.pipe = function() {
77
+ return this.engine.pipe.apply(this.engine, arguments);
78
+ };
79
+
80
+ /**
81
+ * @return this.engine
82
+ */
83
+ Zip.prototype.unpipe = function() {
84
+ return this.engine.unpipe.apply(this.engine, arguments);
85
+ };
86
+
87
+ module.exports = Zip;
88
+
89
+ /**
90
+ * @typedef {Object} ZipOptions
91
+ * @global
92
+ * @property {String} [comment] Sets the zip archive comment.
93
+ * @property {Boolean} [forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
94
+ * @property {Boolean} [forceZip64=false] Forces the archive to contain ZIP64 headers.
95
+ * @prpperty {Boolean} [namePrependSlash=false] Prepends a forward slash to archive file paths.
96
+ * @property {Boolean} [store=false] Sets the compression method to STORE.
97
+ * @property {Object} [zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
98
+ * to control compression.
99
+ * @property {*} [*] See [zip-stream]{@link https://archiverjs.com/zip-stream/ZipStream.html} documentation for current list of properties.
100
+ */
101
+
102
+ /**
103
+ * @typedef {Object} ZipEntryData
104
+ * @global
105
+ * @property {String} name Sets the entry name including internal path.
106
+ * @property {(String|Date)} [date=NOW()] Sets the entry date.
107
+ * @property {Number} [mode=D:0755/F:0644] Sets the entry permissions.
108
+ * @property {Boolean} [namePrependSlash=ZipOptions.namePrependSlash] Prepends a forward slash to archive file paths.
109
+ * @property {String} [prefix] Sets a path prefix for the entry name. Useful
110
+ * when working with methods like `directory` or `glob`.
111
+ * @property {fs.Stats} [stats] Sets the fs stat data for this entry allowing
112
+ * for reduction of fs stat calls when stat data is already known.
113
+ * @property {Boolean} [store=ZipOptions.store] Sets the compression method to STORE.
114
+ */
115
+
116
+ /**
117
+ * ZipStream Module
118
+ * @external ZipStream
119
+ * @see {@link https://www.archiverjs.com/zip-stream/ZipStream.html}
120
+ */
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
4
+
5
+ var codes = {};
6
+
7
+ function createErrorType(code, message, Base) {
8
+ if (!Base) {
9
+ Base = Error;
10
+ }
11
+
12
+ function getMessage(arg1, arg2, arg3) {
13
+ if (typeof message === 'string') {
14
+ return message;
15
+ } else {
16
+ return message(arg1, arg2, arg3);
17
+ }
18
+ }
19
+
20
+ var NodeError =
21
+ /*#__PURE__*/
22
+ function (_Base) {
23
+ _inheritsLoose(NodeError, _Base);
24
+
25
+ function NodeError(arg1, arg2, arg3) {
26
+ return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
27
+ }
28
+
29
+ return NodeError;
30
+ }(Base);
31
+
32
+ NodeError.prototype.name = Base.name;
33
+ NodeError.prototype.code = code;
34
+ codes[code] = NodeError;
35
+ } // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
36
+
37
+
38
+ function oneOf(expected, thing) {
39
+ if (Array.isArray(expected)) {
40
+ var len = expected.length;
41
+ expected = expected.map(function (i) {
42
+ return String(i);
43
+ });
44
+
45
+ if (len > 2) {
46
+ return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
47
+ } else if (len === 2) {
48
+ return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
49
+ } else {
50
+ return "of ".concat(thing, " ").concat(expected[0]);
51
+ }
52
+ } else {
53
+ return "of ".concat(thing, " ").concat(String(expected));
54
+ }
55
+ } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
56
+
57
+
58
+ function startsWith(str, search, pos) {
59
+ return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
60
+ } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
61
+
62
+
63
+ function endsWith(str, search, this_len) {
64
+ if (this_len === undefined || this_len > str.length) {
65
+ this_len = str.length;
66
+ }
67
+
68
+ return str.substring(this_len - search.length, this_len) === search;
69
+ } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
70
+
71
+
72
+ function includes(str, search, start) {
73
+ if (typeof start !== 'number') {
74
+ start = 0;
75
+ }
76
+
77
+ if (start + search.length > str.length) {
78
+ return false;
79
+ } else {
80
+ return str.indexOf(search, start) !== -1;
81
+ }
82
+ }
83
+
84
+ createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
85
+ return 'The value "' + value + '" is invalid for option "' + name + '"';
86
+ }, TypeError);
87
+ createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
88
+ // determiner: 'must be' or 'must not be'
89
+ var determiner;
90
+
91
+ if (typeof expected === 'string' && startsWith(expected, 'not ')) {
92
+ determiner = 'must not be';
93
+ expected = expected.replace(/^not /, '');
94
+ } else {
95
+ determiner = 'must be';
96
+ }
97
+
98
+ var msg;
99
+
100
+ if (endsWith(name, ' argument')) {
101
+ // For cases like 'first argument'
102
+ msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
103
+ } else {
104
+ var type = includes(name, '.') ? 'property' : 'argument';
105
+ msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
106
+ }
107
+
108
+ msg += ". Received type ".concat(typeof actual);
109
+ return msg;
110
+ }, TypeError);
111
+ createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
112
+ createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
113
+ return 'The ' + name + ' method is not implemented';
114
+ });
115
+ createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
116
+ createErrorType('ERR_STREAM_DESTROYED', function (name) {
117
+ return 'Cannot call ' + name + ' after a stream was destroyed';
118
+ });
119
+ createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
120
+ createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
121
+ createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
122
+ createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
123
+ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
124
+ return 'Unknown encoding: ' + arg;
125
+ }, TypeError);
126
+ createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
127
+ module.exports.codes = codes;
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ const codes = {};
4
+
5
+ function createErrorType(code, message, Base) {
6
+ if (!Base) {
7
+ Base = Error
8
+ }
9
+
10
+ function getMessage (arg1, arg2, arg3) {
11
+ if (typeof message === 'string') {
12
+ return message
13
+ } else {
14
+ return message(arg1, arg2, arg3)
15
+ }
16
+ }
17
+
18
+ class NodeError extends Base {
19
+ constructor (arg1, arg2, arg3) {
20
+ super(getMessage(arg1, arg2, arg3));
21
+ }
22
+ }
23
+
24
+ NodeError.prototype.name = Base.name;
25
+ NodeError.prototype.code = code;
26
+
27
+ codes[code] = NodeError;
28
+ }
29
+
30
+ // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
31
+ function oneOf(expected, thing) {
32
+ if (Array.isArray(expected)) {
33
+ const len = expected.length;
34
+ expected = expected.map((i) => String(i));
35
+ if (len > 2) {
36
+ return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
37
+ expected[len - 1];
38
+ } else if (len === 2) {
39
+ return `one of ${thing} ${expected[0]} or ${expected[1]}`;
40
+ } else {
41
+ return `of ${thing} ${expected[0]}`;
42
+ }
43
+ } else {
44
+ return `of ${thing} ${String(expected)}`;
45
+ }
46
+ }
47
+
48
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
49
+ function startsWith(str, search, pos) {
50
+ return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
51
+ }
52
+
53
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
54
+ function endsWith(str, search, this_len) {
55
+ if (this_len === undefined || this_len > str.length) {
56
+ this_len = str.length;
57
+ }
58
+ return str.substring(this_len - search.length, this_len) === search;
59
+ }
60
+
61
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
62
+ function includes(str, search, start) {
63
+ if (typeof start !== 'number') {
64
+ start = 0;
65
+ }
66
+
67
+ if (start + search.length > str.length) {
68
+ return false;
69
+ } else {
70
+ return str.indexOf(search, start) !== -1;
71
+ }
72
+ }
73
+
74
+ createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
75
+ return 'The value "' + value + '" is invalid for option "' + name + '"'
76
+ }, TypeError);
77
+ createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
78
+ // determiner: 'must be' or 'must not be'
79
+ let determiner;
80
+ if (typeof expected === 'string' && startsWith(expected, 'not ')) {
81
+ determiner = 'must not be';
82
+ expected = expected.replace(/^not /, '');
83
+ } else {
84
+ determiner = 'must be';
85
+ }
86
+
87
+ let msg;
88
+ if (endsWith(name, ' argument')) {
89
+ // For cases like 'first argument'
90
+ msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
91
+ } else {
92
+ const type = includes(name, '.') ? 'property' : 'argument';
93
+ msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
94
+ }
95
+
96
+ msg += `. Received type ${typeof actual}`;
97
+ return msg;
98
+ }, TypeError);
99
+ createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
100
+ createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
101
+ return 'The ' + name + ' method is not implemented'
102
+ });
103
+ createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
104
+ createErrorType('ERR_STREAM_DESTROYED', function (name) {
105
+ return 'Cannot call ' + name + ' after a stream was destroyed';
106
+ });
107
+ createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
108
+ createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
109
+ createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
110
+ createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
111
+ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
112
+ return 'Unknown encoding: ' + arg
113
+ }, TypeError);
114
+ createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
115
+
116
+ module.exports.codes = codes;
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ var experimentalWarnings = new Set();
4
+
5
+ function emitExperimentalWarning(feature) {
6
+ if (experimentalWarnings.has(feature)) return;
7
+ var msg = feature + ' is an experimental feature. This feature could ' +
8
+ 'change at any time';
9
+ experimentalWarnings.add(feature);
10
+ process.emitWarning(msg, 'ExperimentalWarning');
11
+ }
12
+
13
+ function noop() {}
14
+
15
+ module.exports.emitExperimentalWarning = process.emitWarning
16
+ ? emitExperimentalWarning
17
+ : noop;