@nocobase/plugin-backups 2.0.56
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.
- package/LICENSE +201 -0
- package/README.md +99 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/components/BackupSettings.d.ts +2 -0
- package/dist/client/components/BackupsManagement.d.ts +2 -0
- package/dist/client/components/BackupsTable.d.ts +16 -0
- package/dist/client/components/NewBackup.d.ts +10 -0
- package/dist/client/components/RefreshBackups.d.ts +10 -0
- package/dist/client/components/RestoreFromBackup.d.ts +5 -0
- package/dist/client/components/RestoreFromLocal.d.ts +2 -0
- package/dist/client/constants.d.ts +1 -0
- package/dist/client/contexts.d.ts +17 -0
- package/dist/client/hooks/useBackupAppInfo.d.ts +8 -0
- package/dist/client/hooks/useCheckBackupMessage.d.ts +4 -0
- package/dist/client/hooks/useRestoreTask.d.ts +2 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/externalVersion.js +32 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +48 -0
- package/dist/locale/de-DE.json +52 -0
- package/dist/locale/en-US.json +52 -0
- package/dist/locale/es-ES.json +52 -0
- package/dist/locale/fr-FR.json +52 -0
- package/dist/locale/hu-HU.json +52 -0
- package/dist/locale/id-ID.json +52 -0
- package/dist/locale/it-IT.json +52 -0
- package/dist/locale/ja-JP.json +52 -0
- package/dist/locale/ko-KR.json +52 -0
- package/dist/locale/nl-NL.json +52 -0
- package/dist/locale/pt-BR.json +52 -0
- package/dist/locale/ru-RU.json +52 -0
- package/dist/locale/tr-TR.json +52 -0
- package/dist/locale/uk-UA.json +52 -0
- package/dist/locale/vi-VN.json +52 -0
- package/dist/locale/zh-CN.json +52 -0
- package/dist/locale/zh-TW.json +52 -0
- package/dist/node_modules/archiver/LICENSE +22 -0
- package/dist/node_modules/archiver/index.js +68 -0
- package/dist/node_modules/archiver/lib/core.js +974 -0
- package/dist/node_modules/archiver/lib/error.js +40 -0
- package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
- package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
- package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/all.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/allLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/allSeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/any.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/anyLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/anySeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/apply.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/applyEach.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/applyEachSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/asyncify.js +118 -0
- package/dist/node_modules/archiver/node_modules/async/auto.js +333 -0
- package/dist/node_modules/archiver/node_modules/async/autoInject.js +182 -0
- package/dist/node_modules/archiver/node_modules/async/bower.json +17 -0
- package/dist/node_modules/archiver/node_modules/async/cargo.js +63 -0
- package/dist/node_modules/archiver/node_modules/async/cargoQueue.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/compose.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/concat.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/concatLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/concatSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/constant.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/detect.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/detectLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/detectSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/dir.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.js +6062 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.min.js +1 -0
- package/dist/node_modules/archiver/node_modules/async/doDuring.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/doUntil.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/doWhilst.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/during.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/each.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/eachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/eachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/eachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/ensureAsync.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/every.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/everyLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/everySeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filter.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/filterLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filterSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/find.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/findLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/findSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/flatMap.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/foldl.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/foldr.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/forEach.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/forEachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/forEachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/forever.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/groupBy.js +108 -0
- package/dist/node_modules/archiver/node_modules/async/groupByLimit.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/groupBySeries.js +36 -0
- package/dist/node_modules/archiver/node_modules/async/index.js +588 -0
- package/dist/node_modules/archiver/node_modules/async/inject.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/internal/DoublyLinkedList.js +92 -0
- package/dist/node_modules/archiver/node_modules/async/internal/Heap.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/internal/applyEach.js +29 -0
- package/dist/node_modules/archiver/node_modules/async/internal/asyncEachOfLimit.js +75 -0
- package/dist/node_modules/archiver/node_modules/async/internal/awaitify.js +28 -0
- package/dist/node_modules/archiver/node_modules/async/internal/breakLoop.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/consoleFunc.js +31 -0
- package/dist/node_modules/archiver/node_modules/async/internal/createTester.js +40 -0
- package/dist/node_modules/archiver/node_modules/async/internal/eachOfLimit.js +90 -0
- package/dist/node_modules/archiver/node_modules/async/internal/filter.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/internal/getIterator.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/internal/initialParams.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/isArrayLike.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/iterator.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/internal/map.js +30 -0
- package/dist/node_modules/archiver/node_modules/async/internal/once.js +17 -0
- package/dist/node_modules/archiver/node_modules/async/internal/onlyOnce.js +15 -0
- package/dist/node_modules/archiver/node_modules/async/internal/parallel.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/promiseCallback.js +23 -0
- package/dist/node_modules/archiver/node_modules/async/internal/queue.js +294 -0
- package/dist/node_modules/archiver/node_modules/async/internal/range.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/reject.js +26 -0
- package/dist/node_modules/archiver/node_modules/async/internal/setImmediate.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/withoutIndex.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/wrapAsync.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/log.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/map.js +142 -0
- package/dist/node_modules/archiver/node_modules/async/mapLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/mapSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/mapValues.js +152 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesLimit.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/memoize.js +91 -0
- package/dist/node_modules/archiver/node_modules/async/nextTick.js +52 -0
- package/dist/node_modules/archiver/node_modules/async/package.json +75 -0
- package/dist/node_modules/archiver/node_modules/async/parallel.js +180 -0
- package/dist/node_modules/archiver/node_modules/async/parallelLimit.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/priorityQueue.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/queue.js +24 -0
- package/dist/node_modules/archiver/node_modules/async/race.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/reduce.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/reduceRight.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/reflect.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/reflectAll.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/reject.js +87 -0
- package/dist/node_modules/archiver/node_modules/async/rejectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/rejectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/retry.js +159 -0
- package/dist/node_modules/archiver/node_modules/async/retryable.js +77 -0
- package/dist/node_modules/archiver/node_modules/async/select.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/selectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/selectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/seq.js +79 -0
- package/dist/node_modules/archiver/node_modules/async/series.js +186 -0
- package/dist/node_modules/archiver/node_modules/async/setImmediate.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/some.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/someLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/someSeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/sortBy.js +190 -0
- package/dist/node_modules/archiver/node_modules/async/timeout.js +89 -0
- package/dist/node_modules/archiver/node_modules/async/times.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/timesLimit.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/timesSeries.js +32 -0
- package/dist/node_modules/archiver/node_modules/async/transform.js +173 -0
- package/dist/node_modules/archiver/node_modules/async/tryEach.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/unmemoize.js +25 -0
- package/dist/node_modules/archiver/node_modules/async/until.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/waterfall.js +105 -0
- package/dist/node_modules/archiver/node_modules/async/whilst.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/wrapSync.js +118 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/errors-browser.js +127 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/errors.js +116 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_transform.js +190 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_writable.js +641 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/package.json +68 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/readable-browser.js +9 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/readable.js +16 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/extract.js +257 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/headers.js +295 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/index.js +2 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/pack.js +255 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/package.json +58 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/sandbox.js +11 -0
- package/dist/node_modules/archiver/package.json +1 -0
- package/dist/node_modules/cron-parser/.eslintrc.json +15 -0
- package/dist/node_modules/cron-parser/.travis.yml +7 -0
- package/dist/node_modules/cron-parser/LICENSE +21 -0
- package/dist/node_modules/cron-parser/component.json +11 -0
- package/dist/node_modules/cron-parser/index.d.ts +1 -0
- package/dist/node_modules/cron-parser/lib/date.js +252 -0
- package/dist/node_modules/cron-parser/lib/expression.js +983 -0
- package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
- package/dist/node_modules/cron-parser/lib/field_stringify.js +38 -0
- package/dist/node_modules/cron-parser/lib/parser.js +1 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +8489 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +8487 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +8490 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +1 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +7522 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/package.json +96 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +2169 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +880 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +61 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +157 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +80 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +76 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +233 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +191 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +386 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +14 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +482 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +335 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +424 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +292 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +36 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +193 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +602 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +26 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +13 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +137 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +88 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +191 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +94 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +53 -0
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +63 -0
- package/dist/node_modules/cron-parser/package.json +1 -0
- package/dist/node_modules/cron-parser/test/31_of_month.js +17 -0
- package/dist/node_modules/cron-parser/test/bug.js +29 -0
- package/dist/node_modules/cron-parser/test/crondate.js +16 -0
- package/dist/node_modules/cron-parser/test/crontab.example +7 -0
- package/dist/node_modules/cron-parser/test/empty_around_comma.js +22 -0
- package/dist/node_modules/cron-parser/test/expression.js +1489 -0
- package/dist/node_modules/cron-parser/test/field_compactor.js +250 -0
- package/dist/node_modules/cron-parser/test/field_stringify.js +84 -0
- package/dist/node_modules/cron-parser/test/fields.js +32 -0
- package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +22 -0
- package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +133 -0
- package/dist/node_modules/cron-parser/test/index.test-d.ts +138 -0
- package/dist/node_modules/cron-parser/test/leap_year.js +17 -0
- package/dist/node_modules/cron-parser/test/parser.js +46 -0
- package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +145 -0
- package/dist/node_modules/cron-parser/test/parser_day_of_month.js +169 -0
- package/dist/node_modules/cron-parser/test/prev_date.js +32 -0
- package/dist/node_modules/cron-parser/test/stringify.js +402 -0
- package/dist/node_modules/cron-parser/test/timezone.js +422 -0
- package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
- package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
- package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
- package/dist/node_modules/fs-extra/LICENSE +15 -0
- package/dist/node_modules/fs-extra/lib/copy/copy.js +232 -0
- package/dist/node_modules/fs-extra/lib/copy/index.js +6 -0
- package/dist/node_modules/fs-extra/lib/copy-sync/copy-sync.js +166 -0
- package/dist/node_modules/fs-extra/lib/copy-sync/index.js +5 -0
- package/dist/node_modules/fs-extra/lib/empty/index.js +48 -0
- package/dist/node_modules/fs-extra/lib/ensure/file.js +69 -0
- package/dist/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/dist/node_modules/fs-extra/lib/ensure/link.js +61 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink-paths.js +99 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink-type.js +31 -0
- package/dist/node_modules/fs-extra/lib/ensure/symlink.js +63 -0
- package/dist/node_modules/fs-extra/lib/fs/index.js +130 -0
- package/dist/node_modules/fs-extra/lib/index.js +1 -0
- package/dist/node_modules/fs-extra/lib/json/index.js +16 -0
- package/dist/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/dist/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/dist/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/dist/node_modules/fs-extra/lib/mkdirs/make-dir.js +141 -0
- package/dist/node_modules/fs-extra/lib/move/index.js +6 -0
- package/dist/node_modules/fs-extra/lib/move/move.js +65 -0
- package/dist/node_modules/fs-extra/lib/move-sync/index.js +5 -0
- package/dist/node_modules/fs-extra/lib/move-sync/move-sync.js +47 -0
- package/dist/node_modules/fs-extra/lib/output/index.js +40 -0
- package/dist/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/dist/node_modules/fs-extra/lib/remove/index.js +9 -0
- package/dist/node_modules/fs-extra/lib/remove/rimraf.js +302 -0
- package/dist/node_modules/fs-extra/lib/util/stat.js +139 -0
- package/dist/node_modules/fs-extra/lib/util/utimes.js +26 -0
- package/dist/node_modules/fs-extra/package.json +1 -0
- package/dist/node_modules/semver/LICENSE +15 -0
- package/dist/node_modules/semver/bin/semver.js +197 -0
- package/dist/node_modules/semver/classes/comparator.js +141 -0
- package/dist/node_modules/semver/classes/index.js +5 -0
- package/dist/node_modules/semver/classes/range.js +539 -0
- package/dist/node_modules/semver/classes/semver.js +302 -0
- package/dist/node_modules/semver/functions/clean.js +6 -0
- package/dist/node_modules/semver/functions/cmp.js +52 -0
- package/dist/node_modules/semver/functions/coerce.js +60 -0
- package/dist/node_modules/semver/functions/compare-build.js +7 -0
- package/dist/node_modules/semver/functions/compare-loose.js +3 -0
- package/dist/node_modules/semver/functions/compare.js +5 -0
- package/dist/node_modules/semver/functions/diff.js +65 -0
- package/dist/node_modules/semver/functions/eq.js +3 -0
- package/dist/node_modules/semver/functions/gt.js +3 -0
- package/dist/node_modules/semver/functions/gte.js +3 -0
- package/dist/node_modules/semver/functions/inc.js +19 -0
- package/dist/node_modules/semver/functions/lt.js +3 -0
- package/dist/node_modules/semver/functions/lte.js +3 -0
- package/dist/node_modules/semver/functions/major.js +3 -0
- package/dist/node_modules/semver/functions/minor.js +3 -0
- package/dist/node_modules/semver/functions/neq.js +3 -0
- package/dist/node_modules/semver/functions/parse.js +16 -0
- package/dist/node_modules/semver/functions/patch.js +3 -0
- package/dist/node_modules/semver/functions/prerelease.js +6 -0
- package/dist/node_modules/semver/functions/rcompare.js +3 -0
- package/dist/node_modules/semver/functions/rsort.js +3 -0
- package/dist/node_modules/semver/functions/satisfies.js +10 -0
- package/dist/node_modules/semver/functions/sort.js +3 -0
- package/dist/node_modules/semver/functions/valid.js +6 -0
- package/dist/node_modules/semver/index.js +1 -0
- package/dist/node_modules/semver/internal/constants.js +35 -0
- package/dist/node_modules/semver/internal/debug.js +9 -0
- package/dist/node_modules/semver/internal/identifiers.js +23 -0
- package/dist/node_modules/semver/internal/parse-options.js +15 -0
- package/dist/node_modules/semver/internal/re.js +217 -0
- package/dist/node_modules/semver/package.json +1 -0
- package/dist/node_modules/semver/preload.js +2 -0
- package/dist/node_modules/semver/range.bnf +16 -0
- package/dist/node_modules/semver/ranges/gtr.js +4 -0
- package/dist/node_modules/semver/ranges/intersects.js +7 -0
- package/dist/node_modules/semver/ranges/ltr.js +4 -0
- package/dist/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/dist/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/dist/node_modules/semver/ranges/min-version.js +61 -0
- package/dist/node_modules/semver/ranges/outside.js +80 -0
- package/dist/node_modules/semver/ranges/simplify.js +47 -0
- package/dist/node_modules/semver/ranges/subset.js +247 -0
- package/dist/node_modules/semver/ranges/to-comparators.js +8 -0
- package/dist/node_modules/semver/ranges/valid.js +11 -0
- package/dist/node_modules/yauzl/LICENSE +21 -0
- package/dist/node_modules/yauzl/fd-slicer.js +314 -0
- package/dist/node_modules/yauzl/index.js +1 -0
- package/dist/node_modules/yauzl/package.json +1 -0
- package/dist/server/adapters/database.d.ts +9 -0
- package/dist/server/adapters/database.js +486 -0
- package/dist/server/collections/backup-settings.d.ts +2 -0
- package/dist/server/collections/backup-settings.js +67 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +42 -0
- package/dist/server/managers/backup.d.ts +41 -0
- package/dist/server/managers/backup.js +448 -0
- package/dist/server/managers/restore.d.ts +24 -0
- package/dist/server/managers/restore.js +434 -0
- package/dist/server/plugin.d.ts +26 -0
- package/dist/server/plugin.js +251 -0
- package/dist/server/resourcers/backup-cli.d.ts +23 -0
- package/dist/server/resourcers/backup-cli.js +237 -0
- package/dist/server/resourcers/backups.d.ts +24 -0
- package/dist/server/resourcers/backups.js +192 -0
- package/dist/server/types.d.ts +12 -0
- package/dist/server/types.js +24 -0
- package/dist/server/utils.d.ts +48 -0
- package/dist/server/utils.js +323 -0
- package/dist/swagger/index.json +313 -0
- package/package.json +51 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// given a set of versions and a range, create a "simplified" range
|
|
2
|
+
// that includes the same versions that the original range does
|
|
3
|
+
// If the original range is shorter than the simplified one, return that.
|
|
4
|
+
const satisfies = require('../functions/satisfies.js')
|
|
5
|
+
const compare = require('../functions/compare.js')
|
|
6
|
+
module.exports = (versions, range, options) => {
|
|
7
|
+
const set = []
|
|
8
|
+
let first = null
|
|
9
|
+
let prev = null
|
|
10
|
+
const v = versions.sort((a, b) => compare(a, b, options))
|
|
11
|
+
for (const version of v) {
|
|
12
|
+
const included = satisfies(version, range, options)
|
|
13
|
+
if (included) {
|
|
14
|
+
prev = version
|
|
15
|
+
if (!first) {
|
|
16
|
+
first = version
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
if (prev) {
|
|
20
|
+
set.push([first, prev])
|
|
21
|
+
}
|
|
22
|
+
prev = null
|
|
23
|
+
first = null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (first) {
|
|
27
|
+
set.push([first, null])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const ranges = []
|
|
31
|
+
for (const [min, max] of set) {
|
|
32
|
+
if (min === max) {
|
|
33
|
+
ranges.push(min)
|
|
34
|
+
} else if (!max && min === v[0]) {
|
|
35
|
+
ranges.push('*')
|
|
36
|
+
} else if (!max) {
|
|
37
|
+
ranges.push(`>=${min}`)
|
|
38
|
+
} else if (min === v[0]) {
|
|
39
|
+
ranges.push(`<=${max}`)
|
|
40
|
+
} else {
|
|
41
|
+
ranges.push(`${min} - ${max}`)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const simplified = ranges.join(' || ')
|
|
45
|
+
const original = typeof range.raw === 'string' ? range.raw : String(range)
|
|
46
|
+
return simplified.length < original.length ? simplified : range
|
|
47
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
const Range = require('../classes/range.js')
|
|
2
|
+
const Comparator = require('../classes/comparator.js')
|
|
3
|
+
const { ANY } = Comparator
|
|
4
|
+
const satisfies = require('../functions/satisfies.js')
|
|
5
|
+
const compare = require('../functions/compare.js')
|
|
6
|
+
|
|
7
|
+
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
|
|
8
|
+
// - Every simple range `r1, r2, ...` is a null set, OR
|
|
9
|
+
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
|
|
10
|
+
// some `R1, R2, ...`
|
|
11
|
+
//
|
|
12
|
+
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
|
|
13
|
+
// - If c is only the ANY comparator
|
|
14
|
+
// - If C is only the ANY comparator, return true
|
|
15
|
+
// - Else if in prerelease mode, return false
|
|
16
|
+
// - else replace c with `[>=0.0.0]`
|
|
17
|
+
// - If C is only the ANY comparator
|
|
18
|
+
// - if in prerelease mode, return true
|
|
19
|
+
// - else replace C with `[>=0.0.0]`
|
|
20
|
+
// - Let EQ be the set of = comparators in c
|
|
21
|
+
// - If EQ is more than one, return true (null set)
|
|
22
|
+
// - Let GT be the highest > or >= comparator in c
|
|
23
|
+
// - Let LT be the lowest < or <= comparator in c
|
|
24
|
+
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
|
|
25
|
+
// - If any C is a = range, and GT or LT are set, return false
|
|
26
|
+
// - If EQ
|
|
27
|
+
// - If GT, and EQ does not satisfy GT, return true (null set)
|
|
28
|
+
// - If LT, and EQ does not satisfy LT, return true (null set)
|
|
29
|
+
// - If EQ satisfies every C, return true
|
|
30
|
+
// - Else return false
|
|
31
|
+
// - If GT
|
|
32
|
+
// - If GT.semver is lower than any > or >= comp in C, return false
|
|
33
|
+
// - If GT is >=, and GT.semver does not satisfy every C, return false
|
|
34
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
35
|
+
// - If no C has a prerelease and the GT.semver tuple, return false
|
|
36
|
+
// - If LT
|
|
37
|
+
// - If LT.semver is greater than any < or <= comp in C, return false
|
|
38
|
+
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
|
39
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
40
|
+
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
41
|
+
// - Else return true
|
|
42
|
+
|
|
43
|
+
const subset = (sub, dom, options = {}) => {
|
|
44
|
+
if (sub === dom) {
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
sub = new Range(sub, options)
|
|
49
|
+
dom = new Range(dom, options)
|
|
50
|
+
let sawNonNull = false
|
|
51
|
+
|
|
52
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
53
|
+
for (const simpleDom of dom.set) {
|
|
54
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options)
|
|
55
|
+
sawNonNull = sawNonNull || isSub !== null
|
|
56
|
+
if (isSub) {
|
|
57
|
+
continue OUTER
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// the null set is a subset of everything, but null simple ranges in
|
|
61
|
+
// a complex range should be ignored. so if we saw a non-null range,
|
|
62
|
+
// then we know this isn't a subset, but if EVERY simple range was null,
|
|
63
|
+
// then it is a subset.
|
|
64
|
+
if (sawNonNull) {
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
|
|
72
|
+
const minimumVersion = [new Comparator('>=0.0.0')]
|
|
73
|
+
|
|
74
|
+
const simpleSubset = (sub, dom, options) => {
|
|
75
|
+
if (sub === dom) {
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
80
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
81
|
+
return true
|
|
82
|
+
} else if (options.includePrerelease) {
|
|
83
|
+
sub = minimumVersionWithPreRelease
|
|
84
|
+
} else {
|
|
85
|
+
sub = minimumVersion
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
90
|
+
if (options.includePrerelease) {
|
|
91
|
+
return true
|
|
92
|
+
} else {
|
|
93
|
+
dom = minimumVersion
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const eqSet = new Set()
|
|
98
|
+
let gt, lt
|
|
99
|
+
for (const c of sub) {
|
|
100
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
101
|
+
gt = higherGT(gt, c, options)
|
|
102
|
+
} else if (c.operator === '<' || c.operator === '<=') {
|
|
103
|
+
lt = lowerLT(lt, c, options)
|
|
104
|
+
} else {
|
|
105
|
+
eqSet.add(c.semver)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (eqSet.size > 1) {
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let gtltComp
|
|
114
|
+
if (gt && lt) {
|
|
115
|
+
gtltComp = compare(gt.semver, lt.semver, options)
|
|
116
|
+
if (gtltComp > 0) {
|
|
117
|
+
return null
|
|
118
|
+
} else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
|
|
119
|
+
return null
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// will iterate one or zero times
|
|
124
|
+
for (const eq of eqSet) {
|
|
125
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
126
|
+
return null
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
130
|
+
return null
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (const c of dom) {
|
|
134
|
+
if (!satisfies(eq, String(c), options)) {
|
|
135
|
+
return false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return true
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let higher, lower
|
|
143
|
+
let hasDomLT, hasDomGT
|
|
144
|
+
// if the subset has a prerelease, we need a comparator in the superset
|
|
145
|
+
// with the same tuple and a prerelease, or it's not a subset
|
|
146
|
+
let needDomLTPre = lt &&
|
|
147
|
+
!options.includePrerelease &&
|
|
148
|
+
lt.semver.prerelease.length ? lt.semver : false
|
|
149
|
+
let needDomGTPre = gt &&
|
|
150
|
+
!options.includePrerelease &&
|
|
151
|
+
gt.semver.prerelease.length ? gt.semver : false
|
|
152
|
+
// exception: <1.2.3-0 is the same as <1.2.3
|
|
153
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
|
|
154
|
+
lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
|
|
155
|
+
needDomLTPre = false
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (const c of dom) {
|
|
159
|
+
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='
|
|
160
|
+
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='
|
|
161
|
+
if (gt) {
|
|
162
|
+
if (needDomGTPre) {
|
|
163
|
+
if (c.semver.prerelease && c.semver.prerelease.length &&
|
|
164
|
+
c.semver.major === needDomGTPre.major &&
|
|
165
|
+
c.semver.minor === needDomGTPre.minor &&
|
|
166
|
+
c.semver.patch === needDomGTPre.patch) {
|
|
167
|
+
needDomGTPre = false
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
171
|
+
higher = higherGT(gt, c, options)
|
|
172
|
+
if (higher === c && higher !== gt) {
|
|
173
|
+
return false
|
|
174
|
+
}
|
|
175
|
+
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
|
|
176
|
+
return false
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (lt) {
|
|
180
|
+
if (needDomLTPre) {
|
|
181
|
+
if (c.semver.prerelease && c.semver.prerelease.length &&
|
|
182
|
+
c.semver.major === needDomLTPre.major &&
|
|
183
|
+
c.semver.minor === needDomLTPre.minor &&
|
|
184
|
+
c.semver.patch === needDomLTPre.patch) {
|
|
185
|
+
needDomLTPre = false
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (c.operator === '<' || c.operator === '<=') {
|
|
189
|
+
lower = lowerLT(lt, c, options)
|
|
190
|
+
if (lower === c && lower !== lt) {
|
|
191
|
+
return false
|
|
192
|
+
}
|
|
193
|
+
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
|
|
194
|
+
return false
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
198
|
+
return false
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// if there was a < or >, and nothing in the dom, then must be false
|
|
203
|
+
// UNLESS it was limited by another range in the other direction.
|
|
204
|
+
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
|
|
205
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
206
|
+
return false
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
210
|
+
return false
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// we needed a prerelease range in a specific tuple, but didn't get one
|
|
214
|
+
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
|
|
215
|
+
// because it includes prereleases in the 1.2.3 tuple
|
|
216
|
+
if (needDomGTPre || needDomLTPre) {
|
|
217
|
+
return false
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return true
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// >=1.2.3 is lower than >1.2.3
|
|
224
|
+
const higherGT = (a, b, options) => {
|
|
225
|
+
if (!a) {
|
|
226
|
+
return b
|
|
227
|
+
}
|
|
228
|
+
const comp = compare(a.semver, b.semver, options)
|
|
229
|
+
return comp > 0 ? a
|
|
230
|
+
: comp < 0 ? b
|
|
231
|
+
: b.operator === '>' && a.operator === '>=' ? b
|
|
232
|
+
: a
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// <=1.2.3 is higher than <1.2.3
|
|
236
|
+
const lowerLT = (a, b, options) => {
|
|
237
|
+
if (!a) {
|
|
238
|
+
return b
|
|
239
|
+
}
|
|
240
|
+
const comp = compare(a.semver, b.semver, options)
|
|
241
|
+
return comp < 0 ? a
|
|
242
|
+
: comp > 0 ? b
|
|
243
|
+
: b.operator === '<' && a.operator === '<=' ? b
|
|
244
|
+
: a
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
module.exports = subset
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const Range = require('../classes/range')
|
|
2
|
+
|
|
3
|
+
// Mostly just for testing and legacy API reasons
|
|
4
|
+
const toComparators = (range, options) =>
|
|
5
|
+
new Range(range, options).set
|
|
6
|
+
.map(comp => comp.map(c => c.value).join(' ').trim().split(' '))
|
|
7
|
+
|
|
8
|
+
module.exports = toComparators
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const Range = require('../classes/range')
|
|
2
|
+
const validRange = (range, options) => {
|
|
3
|
+
try {
|
|
4
|
+
// Return '*' instead of '' so that truthiness works.
|
|
5
|
+
// This will throw if it's invalid anyway
|
|
6
|
+
return new Range(range, options).range || '*'
|
|
7
|
+
} catch (er) {
|
|
8
|
+
return null
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
module.exports = validRange
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Josh Wolfe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
// This was adapted from https://github.com/andrewrk/node-fd-slicer by Andrew Kelley under the MIT License.
|
|
2
|
+
var fs = require('fs');
|
|
3
|
+
var util = require('util');
|
|
4
|
+
var stream = require('stream');
|
|
5
|
+
var Readable = stream.Readable;
|
|
6
|
+
var Writable = stream.Writable;
|
|
7
|
+
var PassThrough = stream.PassThrough;
|
|
8
|
+
var Pend = require('pend');
|
|
9
|
+
var EventEmitter = require('events').EventEmitter;
|
|
10
|
+
|
|
11
|
+
exports.createFromBuffer = createFromBuffer;
|
|
12
|
+
exports.createFromFd = createFromFd;
|
|
13
|
+
exports.BufferSlicer = BufferSlicer;
|
|
14
|
+
exports.FdSlicer = FdSlicer;
|
|
15
|
+
|
|
16
|
+
util.inherits(FdSlicer, EventEmitter);
|
|
17
|
+
function FdSlicer(fd, options) {
|
|
18
|
+
options = options || {};
|
|
19
|
+
EventEmitter.call(this);
|
|
20
|
+
|
|
21
|
+
this.fd = fd;
|
|
22
|
+
this.pend = new Pend();
|
|
23
|
+
this.pend.max = 1;
|
|
24
|
+
this.refCount = 0;
|
|
25
|
+
this.autoClose = !!options.autoClose;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
29
|
+
var self = this;
|
|
30
|
+
self.pend.go(function(cb) {
|
|
31
|
+
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
|
|
32
|
+
cb();
|
|
33
|
+
callback(err, bytesRead, buffer);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
39
|
+
var self = this;
|
|
40
|
+
self.pend.go(function(cb) {
|
|
41
|
+
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
|
|
42
|
+
cb();
|
|
43
|
+
callback(err, written, buffer);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
FdSlicer.prototype.createReadStream = function(options) {
|
|
49
|
+
return new ReadStream(this, options);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
FdSlicer.prototype.createWriteStream = function(options) {
|
|
53
|
+
return new WriteStream(this, options);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
FdSlicer.prototype.ref = function() {
|
|
57
|
+
this.refCount += 1;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
FdSlicer.prototype.unref = function() {
|
|
61
|
+
var self = this;
|
|
62
|
+
self.refCount -= 1;
|
|
63
|
+
|
|
64
|
+
if (self.refCount > 0) return;
|
|
65
|
+
if (self.refCount < 0) throw new Error("invalid unref");
|
|
66
|
+
|
|
67
|
+
if (self.autoClose) {
|
|
68
|
+
fs.close(self.fd, onCloseDone);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onCloseDone(err) {
|
|
72
|
+
if (err) {
|
|
73
|
+
self.emit('error', err);
|
|
74
|
+
} else {
|
|
75
|
+
self.emit('close');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
util.inherits(ReadStream, Readable);
|
|
81
|
+
function ReadStream(context, options) {
|
|
82
|
+
options = options || {};
|
|
83
|
+
Readable.call(this, options);
|
|
84
|
+
|
|
85
|
+
this.context = context;
|
|
86
|
+
this.context.ref();
|
|
87
|
+
|
|
88
|
+
this.start = options.start || 0;
|
|
89
|
+
this.endOffset = options.end;
|
|
90
|
+
this.pos = this.start;
|
|
91
|
+
this.destroyed = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
ReadStream.prototype._read = function(n) {
|
|
95
|
+
var self = this;
|
|
96
|
+
if (self.destroyed) return;
|
|
97
|
+
|
|
98
|
+
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
99
|
+
if (self.endOffset != null) {
|
|
100
|
+
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
101
|
+
}
|
|
102
|
+
if (toRead <= 0) {
|
|
103
|
+
self.destroyed = true;
|
|
104
|
+
self.push(null);
|
|
105
|
+
self.context.unref();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
self.context.pend.go(function(cb) {
|
|
109
|
+
if (self.destroyed) return cb();
|
|
110
|
+
var buffer = Buffer.allocUnsafe(toRead);
|
|
111
|
+
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
112
|
+
if (err) {
|
|
113
|
+
self.destroy(err);
|
|
114
|
+
} else if (bytesRead === 0) {
|
|
115
|
+
self.destroyed = true;
|
|
116
|
+
self.push(null);
|
|
117
|
+
self.context.unref();
|
|
118
|
+
} else {
|
|
119
|
+
self.pos += bytesRead;
|
|
120
|
+
self.push(buffer.slice(0, bytesRead));
|
|
121
|
+
}
|
|
122
|
+
cb();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
ReadStream.prototype.destroy = function(err) {
|
|
128
|
+
if (this.destroyed) return;
|
|
129
|
+
err = err || new Error("stream destroyed");
|
|
130
|
+
this.destroyed = true;
|
|
131
|
+
this.emit('error', err);
|
|
132
|
+
this.context.unref();
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
util.inherits(WriteStream, Writable);
|
|
136
|
+
function WriteStream(context, options) {
|
|
137
|
+
options = options || {};
|
|
138
|
+
Writable.call(this, options);
|
|
139
|
+
|
|
140
|
+
this.context = context;
|
|
141
|
+
this.context.ref();
|
|
142
|
+
|
|
143
|
+
this.start = options.start || 0;
|
|
144
|
+
this.endOffset = (options.end == null) ? Infinity : +options.end;
|
|
145
|
+
this.bytesWritten = 0;
|
|
146
|
+
this.pos = this.start;
|
|
147
|
+
this.destroyed = false;
|
|
148
|
+
|
|
149
|
+
this.on('finish', this.destroy.bind(this));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
153
|
+
var self = this;
|
|
154
|
+
if (self.destroyed) return;
|
|
155
|
+
|
|
156
|
+
if (self.pos + buffer.length > self.endOffset) {
|
|
157
|
+
var err = new Error("maximum file length exceeded");
|
|
158
|
+
err.code = 'ETOOBIG';
|
|
159
|
+
self.destroy();
|
|
160
|
+
callback(err);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
self.context.pend.go(function(cb) {
|
|
164
|
+
if (self.destroyed) return cb();
|
|
165
|
+
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
|
|
166
|
+
if (err) {
|
|
167
|
+
self.destroy();
|
|
168
|
+
cb();
|
|
169
|
+
callback(err);
|
|
170
|
+
} else {
|
|
171
|
+
self.bytesWritten += bytes;
|
|
172
|
+
self.pos += bytes;
|
|
173
|
+
self.emit('progress');
|
|
174
|
+
cb();
|
|
175
|
+
callback();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
WriteStream.prototype.destroy = function() {
|
|
182
|
+
if (this.destroyed) return;
|
|
183
|
+
this.destroyed = true;
|
|
184
|
+
this.context.unref();
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
util.inherits(BufferSlicer, EventEmitter);
|
|
188
|
+
function BufferSlicer(buffer, options) {
|
|
189
|
+
EventEmitter.call(this);
|
|
190
|
+
|
|
191
|
+
options = options || {};
|
|
192
|
+
this.refCount = 0;
|
|
193
|
+
this.buffer = buffer;
|
|
194
|
+
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
198
|
+
if (!(0 <= offset && offset <= buffer.length)) throw new RangeError("offset outside buffer: 0 <= " + offset + " <= " + buffer.length);
|
|
199
|
+
if (position < 0) throw new RangeError("position is negative: " + position);
|
|
200
|
+
if (offset + length > buffer.length) {
|
|
201
|
+
// The caller's buffer can't hold all the bytes they're trying to read.
|
|
202
|
+
// Clamp the length instead of giving an error.
|
|
203
|
+
// The callback will be informed of fewer than expected bytes written.
|
|
204
|
+
length = buffer.length - offset;
|
|
205
|
+
}
|
|
206
|
+
if (position + length > this.buffer.length) {
|
|
207
|
+
// Clamp any attempt to read past the end of the source buffer.
|
|
208
|
+
length = this.buffer.length - position;
|
|
209
|
+
}
|
|
210
|
+
if (length <= 0) {
|
|
211
|
+
// After any clamping, we're fully out of bounds or otherwise have nothing to do.
|
|
212
|
+
// This isn't an error; it's just zero bytes written.
|
|
213
|
+
setImmediate(function() {
|
|
214
|
+
callback(null, 0);
|
|
215
|
+
});
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.buffer.copy(buffer, offset, position, position + length);
|
|
219
|
+
setImmediate(function() {
|
|
220
|
+
callback(null, length);
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
225
|
+
buffer.copy(this.buffer, position, offset, offset + length);
|
|
226
|
+
setImmediate(function() {
|
|
227
|
+
callback(null, length, buffer);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
BufferSlicer.prototype.createReadStream = function(options) {
|
|
232
|
+
options = options || {};
|
|
233
|
+
var readStream = new PassThrough(options);
|
|
234
|
+
readStream.destroyed = false;
|
|
235
|
+
readStream.start = options.start || 0;
|
|
236
|
+
readStream.endOffset = options.end;
|
|
237
|
+
// by the time this function returns, we'll be done.
|
|
238
|
+
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
239
|
+
|
|
240
|
+
// respect the maxChunkSize option to slice up the chunk into smaller pieces.
|
|
241
|
+
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
242
|
+
var offset = 0;
|
|
243
|
+
while (true) {
|
|
244
|
+
var nextOffset = offset + this.maxChunkSize;
|
|
245
|
+
if (nextOffset >= entireSlice.length) {
|
|
246
|
+
// last chunk
|
|
247
|
+
if (offset < entireSlice.length) {
|
|
248
|
+
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
253
|
+
offset = nextOffset;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
readStream.end();
|
|
257
|
+
readStream.destroy = function() {
|
|
258
|
+
readStream.destroyed = true;
|
|
259
|
+
};
|
|
260
|
+
return readStream;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
BufferSlicer.prototype.createWriteStream = function(options) {
|
|
264
|
+
var bufferSlicer = this;
|
|
265
|
+
options = options || {};
|
|
266
|
+
var writeStream = new Writable(options);
|
|
267
|
+
writeStream.start = options.start || 0;
|
|
268
|
+
writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
|
|
269
|
+
writeStream.bytesWritten = 0;
|
|
270
|
+
writeStream.pos = writeStream.start;
|
|
271
|
+
writeStream.destroyed = false;
|
|
272
|
+
writeStream._write = function(buffer, encoding, callback) {
|
|
273
|
+
if (writeStream.destroyed) return;
|
|
274
|
+
|
|
275
|
+
var end = writeStream.pos + buffer.length;
|
|
276
|
+
if (end > writeStream.endOffset) {
|
|
277
|
+
var err = new Error("maximum file length exceeded");
|
|
278
|
+
err.code = 'ETOOBIG';
|
|
279
|
+
writeStream.destroyed = true;
|
|
280
|
+
callback(err);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
284
|
+
|
|
285
|
+
writeStream.bytesWritten += buffer.length;
|
|
286
|
+
writeStream.pos = end;
|
|
287
|
+
writeStream.emit('progress');
|
|
288
|
+
callback();
|
|
289
|
+
};
|
|
290
|
+
writeStream.destroy = function() {
|
|
291
|
+
writeStream.destroyed = true;
|
|
292
|
+
};
|
|
293
|
+
return writeStream;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
BufferSlicer.prototype.ref = function() {
|
|
297
|
+
this.refCount += 1;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
BufferSlicer.prototype.unref = function() {
|
|
301
|
+
this.refCount -= 1;
|
|
302
|
+
|
|
303
|
+
if (this.refCount < 0) {
|
|
304
|
+
throw new Error("invalid unref");
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
function createFromBuffer(buffer, options) {
|
|
309
|
+
return new BufferSlicer(buffer, options);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function createFromFd(fd, options) {
|
|
313
|
+
return new FdSlicer(fd, options);
|
|
314
|
+
}
|