prismcast 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +1 -1
- package/dist/app.js +27 -9
- package/dist/app.js.map +1 -1
- package/dist/browser/cdp.js +7 -7
- package/dist/browser/cdp.js.map +1 -1
- package/dist/browser/channelSelection.d.ts +41 -11
- package/dist/browser/channelSelection.js +75 -24
- package/dist/browser/channelSelection.js.map +1 -1
- package/dist/browser/display.d.ts +1 -1
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/index.js +42 -43
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/login.d.ts +2 -2
- package/dist/browser/login.js +1 -1
- package/dist/browser/manifestInterceptor.d.ts +77 -0
- package/dist/browser/manifestInterceptor.js +323 -0
- package/dist/browser/manifestInterceptor.js.map +1 -0
- package/dist/browser/precaching.js +4 -4
- package/dist/browser/tuning/comcastPolymer.d.ts +1 -1
- package/dist/browser/tuning/cox.d.ts +1 -1
- package/dist/browser/tuning/directv.d.ts +1 -1
- package/dist/browser/tuning/directv.js +61 -62
- package/dist/browser/tuning/directv.js.map +1 -1
- package/dist/browser/tuning/fox.d.ts +1 -1
- package/dist/browser/tuning/fox.js +171 -14
- package/dist/browser/tuning/fox.js.map +1 -1
- package/dist/browser/tuning/hbo.d.ts +1 -1
- package/dist/browser/tuning/hbo.js +6 -6
- package/dist/browser/tuning/hbo.js.map +1 -1
- package/dist/browser/tuning/hulu.d.ts +1 -1
- package/dist/browser/tuning/hulu.js +117 -110
- package/dist/browser/tuning/hulu.js.map +1 -1
- package/dist/browser/tuning/shared.d.ts +3 -3
- package/dist/browser/tuning/shared.js +5 -5
- package/dist/browser/tuning/sling.d.ts +1 -1
- package/dist/browser/tuning/sling.js +28 -28
- package/dist/browser/tuning/sling.js.map +1 -1
- package/dist/browser/tuning/spectrum.d.ts +1 -1
- package/dist/browser/tuning/spectrum.js +21 -22
- package/dist/browser/tuning/spectrum.js.map +1 -1
- package/dist/browser/tuning/thumbnailRow.d.ts +1 -1
- package/dist/browser/tuning/thumbnailRow.js +1 -1
- package/dist/browser/tuning/tileClick.d.ts +1 -1
- package/dist/browser/tuning/tileClick.js +5 -5
- package/dist/browser/tuning/xfinity.d.ts +1 -1
- package/dist/browser/tuning/youtubeTv.d.ts +1 -1
- package/dist/browser/tuning/youtubeTv.js +17 -18
- package/dist/browser/tuning/youtubeTv.js.map +1 -1
- package/dist/browser/video.d.ts +20 -6
- package/dist/browser/video.js +30 -38
- package/dist/browser/video.js.map +1 -1
- package/dist/channels/index.d.ts +1 -2
- package/dist/channels/index.js +73 -40
- package/dist/channels/index.js.map +1 -1
- package/dist/config/channelForm.d.ts +58 -0
- package/dist/config/channelForm.js +129 -0
- package/dist/config/channelForm.js.map +1 -0
- package/dist/config/consistencyProbe.d.ts +7 -0
- package/dist/config/consistencyProbe.js +143 -0
- package/dist/config/consistencyProbe.js.map +1 -0
- package/dist/config/health.d.ts +4 -3
- package/dist/config/health.js +75 -62
- package/dist/config/health.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +19 -12
- package/dist/config/index.js.map +1 -1
- package/dist/config/paths.d.ts +9 -3
- package/dist/config/paths.js +12 -4
- package/dist/config/paths.js.map +1 -1
- package/dist/config/persistence.context.d.ts +8 -0
- package/dist/config/persistence.context.js +30 -0
- package/dist/config/persistence.context.js.map +1 -0
- package/dist/config/persistence.d.ts +110 -12
- package/dist/config/persistence.js +351 -32
- package/dist/config/persistence.js.map +1 -1
- package/dist/config/presets.d.ts +14 -4
- package/dist/config/presets.js +84 -75
- package/dist/config/presets.js.map +1 -1
- package/dist/config/profiles.d.ts +2 -2
- package/dist/config/profiles.js +7 -9
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/servicePacks.d.ts +2 -2
- package/dist/config/servicePacks.js +28 -28
- package/dist/config/servicePacks.js.map +1 -1
- package/dist/config/services.d.ts +62 -36
- package/dist/config/services.js +150 -136
- package/dist/config/services.js.map +1 -1
- package/dist/config/sites.d.ts +3 -3
- package/dist/config/sites.js +16 -16
- package/dist/config/sites.js.map +1 -1
- package/dist/config/userChannels.d.ts +500 -41
- package/dist/config/userChannels.js +1201 -312
- package/dist/config/userChannels.js.map +1 -1
- package/dist/config/userConfig.d.ts +103 -10
- package/dist/config/userConfig.js +277 -117
- package/dist/config/userConfig.js.map +1 -1
- package/dist/config/userProfiles.d.ts +4 -2
- package/dist/config/userProfiles.js +72 -26
- package/dist/config/userProfiles.js.map +1 -1
- package/dist/hdhr/channelMap.js +8 -11
- package/dist/hdhr/channelMap.js.map +1 -1
- package/dist/hdhr/deviceId.js +10 -9
- package/dist/hdhr/deviceId.js.map +1 -1
- package/dist/hdhr/discover.js +4 -5
- package/dist/hdhr/discover.js.map +1 -1
- package/dist/hdhr/index.js +6 -10
- package/dist/hdhr/index.js.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/native/codecInference.d.ts +44 -0
- package/dist/native/codecInference.js +327 -0
- package/dist/native/codecInference.js.map +1 -0
- package/dist/native/decrypt.d.ts +1 -1
- package/dist/native/index.d.ts +5 -5
- package/dist/native/index.js +42 -64
- package/dist/native/index.js.map +1 -1
- package/dist/native/probe.d.ts +27 -9
- package/dist/native/probe.js +158 -67
- package/dist/native/probe.js.map +1 -1
- package/dist/native/proxy.d.ts +4 -2
- package/dist/native/proxy.js +52 -49
- package/dist/native/proxy.js.map +1 -1
- package/dist/native/tokenExpiry.d.ts +22 -0
- package/dist/native/tokenExpiry.js +153 -0
- package/dist/native/tokenExpiry.js.map +1 -0
- package/dist/routes/auth.js +6 -10
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/components.js +2 -2
- package/dist/routes/components.js.map +1 -1
- package/dist/routes/config/channels/endpoints/browse.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/browse.js +195 -0
- package/dist/routes/config/channels/endpoints/browse.js.map +1 -0
- package/dist/routes/config/channels/endpoints/bulk.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/bulk.js +128 -0
- package/dist/routes/config/channels/endpoints/bulk.js.map +1 -0
- package/dist/routes/config/channels/endpoints/crud.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/crud.js +504 -0
- package/dist/routes/config/channels/endpoints/crud.js.map +1 -0
- package/dist/routes/config/channels/endpoints/importExport.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/importExport.js +131 -0
- package/dist/routes/config/channels/endpoints/importExport.js.map +1 -0
- package/dist/routes/config/channels/endpoints/predefined.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/predefined.js +78 -0
- package/dist/routes/config/channels/endpoints/predefined.js.map +1 -0
- package/dist/routes/config/channels/endpoints/prefs.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/prefs.js +58 -0
- package/dist/routes/config/channels/endpoints/prefs.js.map +1 -0
- package/dist/routes/config/channels/endpoints/service.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/service.js +149 -0
- package/dist/routes/config/channels/endpoints/service.js.map +1 -0
- package/dist/routes/config/channels/endpoints/tags.d.ts +6 -0
- package/dist/routes/config/channels/endpoints/tags.js +185 -0
- package/dist/routes/config/channels/endpoints/tags.js.map +1 -0
- package/dist/routes/config/channels/http/handler.d.ts +10 -0
- package/dist/routes/config/channels/http/handler.js +20 -0
- package/dist/routes/config/channels/http/handler.js.map +1 -0
- package/dist/routes/config/channels/http/playlistHint.d.ts +25 -0
- package/dist/routes/config/channels/http/playlistHint.js +40 -0
- package/dist/routes/config/channels/http/playlistHint.js.map +1 -0
- package/dist/routes/config/channels/http/serviceWarning.d.ts +10 -0
- package/dist/routes/config/channels/http/serviceWarning.js +28 -0
- package/dist/routes/config/channels/http/serviceWarning.js.map +1 -0
- package/dist/routes/config/channels/index.d.ts +3 -3
- package/dist/routes/config/channels/index.js +1 -1
- package/dist/routes/config/channels/index.js.map +1 -1
- package/dist/routes/config/channels/{routes.d.ts → setup.d.ts} +1 -1
- package/dist/routes/config/channels/setup.js +23 -0
- package/dist/routes/config/channels/setup.js.map +1 -0
- package/dist/routes/config/channels/table.d.ts +9 -9
- package/dist/routes/config/channels/table.js +124 -76
- package/dist/routes/config/channels/table.js.map +1 -1
- package/dist/routes/config/http/envelope.d.ts +111 -0
- package/dist/routes/config/http/envelope.js +103 -0
- package/dist/routes/config/http/envelope.js.map +1 -0
- package/dist/routes/config/index.d.ts +9 -9
- package/dist/routes/config/index.js +2 -2
- package/dist/routes/config/index.js.map +1 -1
- package/dist/routes/config/services.js +69 -68
- package/dist/routes/config/services.js.map +1 -1
- package/dist/routes/config/settings.d.ts +1 -1
- package/dist/routes/config/settings.js +45 -38
- package/dist/routes/config/settings.js.map +1 -1
- package/dist/routes/debug.js +12 -11
- package/dist/routes/debug.js.map +1 -1
- package/dist/routes/icons.js +2 -2
- package/dist/routes/icons.js.map +1 -1
- package/dist/routes/logs.js +19 -30
- package/dist/routes/logs.js.map +1 -1
- package/dist/routes/mpegts.js +1 -1
- package/dist/routes/playlist.d.ts +1 -1
- package/dist/routes/playlist.js +37 -26
- package/dist/routes/playlist.js.map +1 -1
- package/dist/routes/root/content.js +27 -6
- package/dist/routes/root/content.js.map +1 -1
- package/dist/routes/root/index.js +2 -5
- package/dist/routes/root/index.js.map +1 -1
- package/dist/routes/root/scripts/channels.js +16 -16
- package/dist/routes/root/scripts/channels.js.map +1 -1
- package/dist/routes/root/scripts/config.js +59 -59
- package/dist/routes/root/scripts/config.js.map +1 -1
- package/dist/routes/root/scripts/index.d.ts +4 -4
- package/dist/routes/root/scripts/shared.js +24 -10
- package/dist/routes/root/scripts/shared.js.map +1 -1
- package/dist/routes/root/scripts/status.d.ts +4 -0
- package/dist/routes/root/scripts/status.handlers.d.ts +182 -0
- package/dist/routes/root/scripts/status.handlers.js +713 -0
- package/dist/routes/root/scripts/status.handlers.js.map +1 -0
- package/dist/routes/root/scripts/status.js +86 -488
- package/dist/routes/root/scripts/status.js.map +1 -1
- package/dist/routes/root/styles.js +5 -5
- package/dist/routes/services.js +18 -15
- package/dist/routes/services.js.map +1 -1
- package/dist/routes/sse.d.ts +16 -0
- package/dist/routes/sse.js +29 -0
- package/dist/routes/sse.js.map +1 -0
- package/dist/routes/streams.js +10 -23
- package/dist/routes/streams.js.map +1 -1
- package/dist/routes/ui.d.ts +2 -2
- package/dist/routes/upgrade.js +6 -7
- package/dist/routes/upgrade.js.map +1 -1
- package/dist/service/commands.context.d.ts +6 -0
- package/dist/service/commands.context.js +47 -0
- package/dist/service/commands.context.js.map +1 -0
- package/dist/service/commands.d.ts +53 -8
- package/dist/service/commands.js +171 -188
- package/dist/service/commands.js.map +1 -1
- package/dist/service/generators.context.d.ts +6 -0
- package/dist/service/generators.context.js +45 -0
- package/dist/service/generators.context.js.map +1 -0
- package/dist/service/generators.d.ts +56 -16
- package/dist/service/generators.js +499 -383
- package/dist/service/generators.js.map +1 -1
- package/dist/service/index.d.ts +2 -2
- package/dist/streaming/clients.d.ts +2 -2
- package/dist/streaming/clients.js +2 -2
- package/dist/streaming/codec.d.ts +2 -2
- package/dist/streaming/codec.js +0 -1
- package/dist/streaming/codec.js.map +1 -1
- package/dist/streaming/fmp4Segmenter.d.ts +2 -2
- package/dist/streaming/fmp4Segmenter.js +12 -12
- package/dist/streaming/hls.d.ts +3 -3
- package/dist/streaming/hls.js +81 -70
- package/dist/streaming/hls.js.map +1 -1
- package/dist/streaming/hlsResume.d.ts +3 -3
- package/dist/streaming/hlsResume.js +5 -5
- package/dist/streaming/hlsSegments.d.ts +5 -2
- package/dist/streaming/hlsSegments.js +14 -9
- package/dist/streaming/hlsSegments.js.map +1 -1
- package/dist/streaming/monitor.d.ts +12 -12
- package/dist/streaming/monitor.js +80 -54
- package/dist/streaming/monitor.js.map +1 -1
- package/dist/streaming/mp4Parser.d.ts +34 -4
- package/dist/streaming/mp4Parser.js +111 -29
- package/dist/streaming/mp4Parser.js.map +1 -1
- package/dist/streaming/mpegts.d.ts +1 -1
- package/dist/streaming/mpegts.js +13 -10
- package/dist/streaming/mpegts.js.map +1 -1
- package/dist/streaming/playlistBuilder.d.ts +1 -1
- package/dist/streaming/playlistBuilder.js +2 -2
- package/dist/streaming/preroll.d.ts +9 -9
- package/dist/streaming/preroll.js +39 -41
- package/dist/streaming/preroll.js.map +1 -1
- package/dist/streaming/pretune.js +4 -4
- package/dist/streaming/pretune.js.map +1 -1
- package/dist/streaming/recovery.d.ts +3 -3
- package/dist/streaming/recovery.js +4 -4
- package/dist/streaming/registry.d.ts +6 -6
- package/dist/streaming/setup.d.ts +9 -8
- package/dist/streaming/setup.js +97 -49
- package/dist/streaming/setup.js.map +1 -1
- package/dist/streaming/showInfo.d.ts +9 -3
- package/dist/streaming/showInfo.js +26 -18
- package/dist/streaming/showInfo.js.map +1 -1
- package/dist/streaming/statusEmitter.d.ts +4 -4
- package/dist/streaming/statusEmitter.js +2 -2
- package/dist/types/channels.d.ts +133 -34
- package/dist/types/channels.js +39 -1
- package/dist/types/channels.js.map +1 -1
- package/dist/types/config.d.ts +20 -1
- package/dist/types/index.d.ts +9 -8
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/profiles.d.ts +5 -4
- package/dist/types/selection.d.ts +48 -4
- package/dist/types/streaming.d.ts +1 -1
- package/dist/upgrade/commands.context.d.ts +6 -0
- package/dist/upgrade/commands.context.js +29 -0
- package/dist/upgrade/commands.context.js.map +1 -0
- package/dist/upgrade/commands.d.ts +29 -2
- package/dist/upgrade/commands.js +87 -134
- package/dist/upgrade/commands.js.map +1 -1
- package/dist/upgrade/detection.context.d.ts +6 -0
- package/dist/upgrade/detection.context.js +24 -0
- package/dist/upgrade/detection.context.js.map +1 -0
- package/dist/upgrade/detection.d.ts +140 -10
- package/dist/upgrade/detection.js +153 -66
- package/dist/upgrade/detection.js.map +1 -1
- package/dist/upgrade/index.d.ts +2 -2
- package/dist/utils/chromeFetch.d.ts +1 -1
- package/dist/utils/chromeFetch.js +1 -1
- package/dist/utils/clock.d.ts +14 -0
- package/dist/utils/clock.js +28 -0
- package/dist/utils/clock.js.map +1 -0
- package/dist/utils/debugFilter.d.ts +1 -1
- package/dist/utils/debugFilter.js +6 -4
- package/dist/utils/debugFilter.js.map +1 -1
- package/dist/utils/delay.d.ts +2 -3
- package/dist/utils/delay.js +10 -16
- package/dist/utils/delay.js.map +1 -1
- package/dist/utils/evaluate.js +12 -14
- package/dist/utils/evaluate.js.map +1 -1
- package/dist/utils/ffmpeg.context.d.ts +6 -0
- package/dist/utils/ffmpeg.context.js +31 -0
- package/dist/utils/ffmpeg.context.js.map +1 -0
- package/dist/utils/ffmpeg.d.ts +85 -29
- package/dist/utils/ffmpeg.js +126 -129
- package/dist/utils/ffmpeg.js.map +1 -1
- package/dist/utils/fileLogger.d.ts +18 -2
- package/dist/utils/fileLogger.js +58 -30
- package/dist/utils/fileLogger.js.map +1 -1
- package/dist/utils/format.d.ts +1 -1
- package/dist/utils/format.js +2 -2
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/html.js +1 -3
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/index.d.ts +21 -20
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +16 -20
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/m3u.d.ts +18 -3
- package/dist/utils/m3u.js +28 -14
- package/dist/utils/m3u.js.map +1 -1
- package/dist/utils/memo.d.ts +19 -0
- package/dist/utils/memo.js +53 -0
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/morganStream.js +2 -2
- package/dist/utils/morganStream.js.map +1 -1
- package/dist/utils/pid.d.ts +2 -2
- package/dist/utils/pid.js +2 -2
- package/dist/utils/platform.d.ts +1 -1
- package/dist/utils/platform.js +3 -3
- package/dist/utils/platform.js.map +1 -1
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.js +9 -7
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/sanitize.d.ts +2 -2
- package/dist/utils/sanitize.js +4 -4
- package/dist/utils/timing.d.ts +6 -3
- package/dist/utils/timing.js +10 -6
- package/dist/utils/timing.js.map +1 -1
- package/dist/utils/version.d.ts +3 -2
- package/dist/utils/version.js +14 -27
- package/dist/utils/version.js.map +1 -1
- package/package.json +13 -7
- package/dist/native/intercept.d.ts +0 -35
- package/dist/native/intercept.js +0 -181
- package/dist/native/intercept.js.map +0 -1
- package/dist/routes/config/channels/routes.js +0 -1505
- package/dist/routes/config/channels/routes.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
const { promises: fsPromises } = fs;
|
|
3
|
+
/**
|
|
4
|
+
* Builds the default StorageBackend wired to node:fs/promises. The returned adapter is stateless - every call delegates to fsPromises with the framework's
|
|
5
|
+
* documented contract (UTF-8 encoding for text I/O, recursive mkdir, native error propagation including the ENOENT code that the framework's branch detection
|
|
6
|
+
* relies on). Sharing one default instance across every store in the process is safe and cheap; persistence.ts caches a single one at module load.
|
|
7
|
+
* @returns A StorageBackend implementation backed by the real filesystem via node:fs/promises.
|
|
8
|
+
*/
|
|
9
|
+
export function createDefaultStorageBackend() {
|
|
10
|
+
return {
|
|
11
|
+
access: async (path) => fsPromises.access(path),
|
|
12
|
+
copyFile: async (source, destination) => fsPromises.copyFile(source, destination),
|
|
13
|
+
mkdir: async (path) => {
|
|
14
|
+
// The framework only ever uses recursive mkdir, so the adapter bakes that in rather than exposing the options bag through the StorageBackend surface.
|
|
15
|
+
await fsPromises.mkdir(path, { recursive: true });
|
|
16
|
+
},
|
|
17
|
+
readFile: async (path) => fsPromises.readFile(path, "utf-8"),
|
|
18
|
+
readdir: async (path) => fsPromises.readdir(path),
|
|
19
|
+
rename: async (source, destination) => fsPromises.rename(source, destination),
|
|
20
|
+
stat: async (path) => {
|
|
21
|
+
// Project Stats down to the field the framework actually uses (mtimeMs for snapshot pruning). Hides the wider Stats surface so backend implementers do not
|
|
22
|
+
// have to fabricate fields that the framework would never read.
|
|
23
|
+
const result = await fsPromises.stat(path);
|
|
24
|
+
return { mtimeMs: result.mtimeMs };
|
|
25
|
+
},
|
|
26
|
+
unlink: async (path) => fsPromises.unlink(path),
|
|
27
|
+
writeFile: async (path, content) => fsPromises.writeFile(path, content, "utf-8")
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=persistence.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.context.js","sourceRoot":"","sources":["../../src/config/persistence.context.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B;IAEzC,OAAO;QAEL,MAAM,EAAE,KAAK,EAAE,IAAY,EAAiB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;QAEtE,QAAQ,EAAE,KAAK,EAAE,MAAc,EAAE,WAAmB,EAAiB,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;QAEhH,KAAK,EAAE,KAAK,EAAE,IAAY,EAAiB,EAAE;YAE3C,sJAAsJ;YACtJ,MAAM,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,QAAQ,EAAE,KAAK,EAAE,IAAY,EAAmB,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QAErF,OAAO,EAAE,KAAK,EAAE,IAAY,EAAqB,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;QAE5E,MAAM,EAAE,KAAK,EAAE,MAAc,EAAE,WAAmB,EAAiB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;QAE5G,IAAI,EAAE,KAAK,EAAE,IAAY,EAAgC,EAAE;YAEzD,2JAA2J;YAC3J,gEAAgE;YAChE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACrC,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,IAAY,EAAiB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC;QAEtE,SAAS,EAAE,KAAK,EAAE,IAAY,EAAE,OAAe,EAAiB,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;KAChH,CAAC;AACJ,CAAC"}
|
|
@@ -1,59 +1,157 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Storage backend abstraction. The framework operates on any durable store that exposes the operations below over a path namespace - the default backend lives
|
|
3
|
+
* in persistence.context.ts and wires real-filesystem I/O via node:fs/promises, but the surface is intentionally narrow so alternative backends (for example, an
|
|
4
|
+
* in-memory backend used during tests, or a future object-store backend) can plug in without modifying the framework.
|
|
5
|
+
*
|
|
6
|
+
* Error contract: when a path is missing, throw a NodeJS.ErrnoException with `code: "ENOENT"` so the framework's existing branch detection (the read() ENOENT
|
|
7
|
+
* fast path, the doMutate ENOENT-tolerant backup copy, the snapshot ENOENT-tolerant source) continues to behave identically. All other failures (permission
|
|
8
|
+
* denied, I/O error, etc.) propagate as Error or NodeJS.ErrnoException with their native code so the framework's error logging surfaces accurate diagnostics.
|
|
9
|
+
*
|
|
10
|
+
* Encoding: every text operation is UTF-8 by contract. Backends do not accept other encodings - JSON is what the framework writes, and JSON is text.
|
|
11
|
+
*/
|
|
12
|
+
export interface StorageBackend {
|
|
13
|
+
readonly access: (path: string) => Promise<void>;
|
|
14
|
+
readonly copyFile: (source: string, destination: string) => Promise<void>;
|
|
15
|
+
readonly mkdir: (path: string) => Promise<void>;
|
|
16
|
+
readonly readdir: (path: string) => Promise<string[]>;
|
|
17
|
+
readonly readFile: (path: string) => Promise<string>;
|
|
18
|
+
readonly rename: (source: string, destination: string) => Promise<void>;
|
|
19
|
+
readonly stat: (path: string) => Promise<{
|
|
20
|
+
mtimeMs: number;
|
|
21
|
+
}>;
|
|
22
|
+
readonly unlink: (path: string) => Promise<void>;
|
|
23
|
+
readonly writeFile: (path: string, content: string) => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error thrown by `mutate()` when the backing file contains invalid JSON and recovery from .bak also failed. Route handlers can catch this specifically to
|
|
27
|
+
* return 400 instead of 500. Background code paths that swallow errors via try/catch will handle it like any other Error.
|
|
4
28
|
*/
|
|
5
29
|
export declare class FileStoreParseError extends Error {
|
|
6
30
|
name: string;
|
|
7
31
|
constructor(label: string, filePath: string, parseMessage: string);
|
|
8
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* A single declarative schema migration. Migrations are keyed by their target schema version inside FileStoreOptions.migrations - the framework runs them in
|
|
35
|
+
* order from the file's current version up to the store's currentSchemaVersion, mutating the in-memory data in place and stamping the new version after each
|
|
36
|
+
* application.
|
|
37
|
+
*/
|
|
38
|
+
export interface Migration<T> {
|
|
39
|
+
description: string;
|
|
40
|
+
apply: (data: T) => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The result of running migrations during a read operation.
|
|
44
|
+
*/
|
|
45
|
+
export interface MigrationResult {
|
|
46
|
+
applied: string[];
|
|
47
|
+
fromVersion: number;
|
|
48
|
+
toVersion: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A single integrity issue detected by a store's validator. Surfaced via logging; the write proceeds regardless of severity.
|
|
52
|
+
*/
|
|
53
|
+
export interface ValidationIssue {
|
|
54
|
+
category: string;
|
|
55
|
+
description: string;
|
|
56
|
+
severity: "warning" | "error";
|
|
57
|
+
}
|
|
9
58
|
/**
|
|
10
59
|
* Result from a read-only file store access. Callers that only need data (export endpoints, API responses) use this without risking a save-back.
|
|
11
60
|
*/
|
|
12
61
|
export interface FileStoreReadResult<T> {
|
|
13
62
|
data: T;
|
|
63
|
+
migrationResult: MigrationResult;
|
|
14
64
|
parseError: boolean;
|
|
15
65
|
parseErrorMessage?: string;
|
|
66
|
+
recoveredFromBackup: boolean;
|
|
16
67
|
}
|
|
17
68
|
/**
|
|
18
|
-
* Options for creating a file store instance.
|
|
69
|
+
* Options for creating a file store instance. The first three fields (defaultValue, label, parse, path) are the minimum surface required for any store. The
|
|
70
|
+
* remaining fields opt in to schema versioning, migrations, and integrity validation - any store can adopt them as its data shape grows.
|
|
19
71
|
* @template T - The in-memory data type that callers mutate.
|
|
20
72
|
*/
|
|
21
73
|
export interface FileStoreOptions<T> {
|
|
74
|
+
backend?: StorageBackend;
|
|
22
75
|
beforeWrite?: (data: T) => unknown;
|
|
76
|
+
currentSchemaVersion?: number;
|
|
23
77
|
defaultValue: () => T;
|
|
78
|
+
getSchemaVersion?: (data: T) => number;
|
|
24
79
|
label: string;
|
|
80
|
+
migrations?: Record<number, Migration<T>>;
|
|
25
81
|
parse: (raw: string) => T;
|
|
26
82
|
path: () => string;
|
|
83
|
+
recordMigration?: (data: T, description: string) => void;
|
|
84
|
+
setSchemaVersion?: (data: T, version: number) => void;
|
|
85
|
+
validate?: (prev: T, next: T) => ValidationIssue[];
|
|
27
86
|
}
|
|
28
87
|
/**
|
|
29
|
-
* A transactional file store that provides atomic writes, serialized mutations, corruption
|
|
30
|
-
* `mutate()` (serialized read-modify-write) and `read()` (read-only access). Direct file I/O is never exposed.
|
|
88
|
+
* A transactional file store that provides atomic writes, serialized mutations, corruption recovery, snapshots, declarative migrations, and integrity
|
|
89
|
+
* validation. Callers interact with data through `mutate()` (serialized read-modify-write) and `read()` (read-only access). Direct file I/O is never exposed.
|
|
31
90
|
* @template T - The in-memory data type that callers mutate.
|
|
32
91
|
*/
|
|
33
92
|
export interface FileStore<T> {
|
|
34
93
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
94
|
+
* Verifies migrations are up-to-date and persists the upgrade if any were applied. Idempotent - when the file is already at the current schema version this
|
|
95
|
+
* is a single read with no write. Called once per store at startup by the release boot coordinator after snapshots have been captured.
|
|
96
|
+
* @returns The migration result so callers can log per-store outcomes.
|
|
97
|
+
*/
|
|
98
|
+
ensureMigrated(): Promise<MigrationResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Serialized read-modify-write operation. The mutation function receives the current data (already migrated to the latest schema version) and modifies it in
|
|
101
|
+
* place. The store handles atomicity, serialization, corruption guard, backup, validation, and beforeWrite transforms.
|
|
37
102
|
* @param fn - Mutation function. Receives current data. Modify in place; return value is ignored.
|
|
38
|
-
* @throws FileStoreParseError if the file contains invalid JSON (corruption guard).
|
|
103
|
+
* @throws FileStoreParseError if the file contains invalid JSON and no usable backup is available (corruption guard).
|
|
39
104
|
*/
|
|
40
105
|
mutate(fn: (current: T) => void): Promise<void>;
|
|
41
106
|
/**
|
|
42
|
-
* Read-only access to the current file contents. Returns the parsed data with parse status. Does not acquire the
|
|
107
|
+
* Read-only access to the current file contents. Returns the parsed data with parse status, recovery status, and migration result. Does not acquire the
|
|
108
|
+
* serialization lock - safe to call concurrently. Migrations run in-memory but are not persisted by read() alone; callers who need to persist an upgrade
|
|
109
|
+
* should use ensureMigrated() (or do so implicitly via mutate()).
|
|
43
110
|
*/
|
|
44
111
|
read(): Promise<FileStoreReadResult<T>>;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a labeled snapshot copy of the current file inside a `snapshots/` subdirectory next to the source file (named `<file>.<label>`). Idempotent on
|
|
114
|
+
* the label - if a snapshot with the same label already exists, this is a no-op. After a successful create, prunes older snapshots for the same file so at
|
|
115
|
+
* most SNAPSHOT_RETENTION remain (by mtime). Used to preserve a guaranteed restore point at release boundaries before any migrations can mutate the file.
|
|
116
|
+
* @param label - The filename suffix appended after the source file's basename and a dot. Typically a version string like `pre-v1.10.0`.
|
|
117
|
+
*/
|
|
118
|
+
snapshot(label: string): Promise<void>;
|
|
45
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Snapshots every registered store under the given label. Used at startup to capture a guaranteed restore point at release boundaries before any migrations
|
|
122
|
+
* can run. The label is typically `pre-v<package-version>` so each release boot leaves a snapshot named for the version that was running.
|
|
123
|
+
*
|
|
124
|
+
* Snapshots run in parallel since they are independent file copies. Failures within individual snapshots are logged by the snapshot helper itself and do not
|
|
125
|
+
* propagate; the coordinator always returns successfully so a single store's snapshot failure does not block startup.
|
|
126
|
+
* @param label - The snapshot label suffix.
|
|
127
|
+
*/
|
|
128
|
+
export declare function snapshotAllForRelease(label: string): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Runs ensureMigrated() on every registered store. Called once at startup after snapshotAllForRelease so that any pending migrations execute against a file
|
|
131
|
+
* that already has its pre-version snapshot captured. Idempotent within a release - subsequent boots see no pending migrations and skip the upgrade write.
|
|
132
|
+
*/
|
|
133
|
+
export declare function ensureAllMigrated(): Promise<void>;
|
|
46
134
|
/**
|
|
47
135
|
* Creates a transactional file store instance. Each instance owns a single JSON file and provides serialized, atomic access to it.
|
|
48
136
|
*
|
|
49
137
|
* Safety guarantees:
|
|
50
138
|
* - **Atomic writes:** data is written to a `.tmp` file and renamed over the original. `rename()` is atomic on POSIX and NTFS.
|
|
51
139
|
* - **Serialization:** a promise chain ensures only one `mutate()` runs at a time. Concurrent callers queue behind the active operation.
|
|
52
|
-
* - **Corruption guard:** `mutate()` throws `FileStoreParseError` if the file
|
|
53
|
-
* - **Backup rotation:** before each write, the current file is copied to `.bak`. One-deep rotation provides a recovery path.
|
|
140
|
+
* - **Corruption guard:** `mutate()` throws `FileStoreParseError` if both the main file and its `.bak` are unparseable, preventing save-over-corrupt cascades.
|
|
141
|
+
* - **Backup rotation:** before each write, the current file is copied to `.bak`. One-deep rotation provides a recovery path for the previous good version.
|
|
142
|
+
* - **Auto-recovery:** when the main file fails to parse, `read()` transparently restores from `.bak` (atomic temp+rename) and surfaces `recoveredFromBackup`
|
|
143
|
+
* on the result so callers can banner the event. Only when both files are unparseable does the result fall back to defaults with `parseError: true`.
|
|
144
|
+
* - **Versioned snapshots:** `snapshot(label)` writes a copy of the current file into a `snapshots/` subdirectory, named `<file>.<label>`, idempotent on the
|
|
145
|
+
* label. After each successful create the directory is pruned to at most SNAPSHOT_RETENTION entries per file (by mtime).
|
|
146
|
+
* - **Declarative migrations:** when `migrations` and `currentSchemaVersion` are provided, `read()` runs any pending migrations in memory and returns the
|
|
147
|
+
* upgraded data. `ensureMigrated()` persists the upgrade if any were applied. Migrations are version-keyed and idempotent across boots.
|
|
148
|
+
* - **Pre-write validation:** when `validate` is provided, `mutate()` invokes it with the pre-mutation snapshot and post-mutation state, surfacing integrity
|
|
149
|
+
* issues via the log.
|
|
150
|
+
* - **Post-write integrity check:** after every successful rename, the file is read back and byte-compared against what was written. On mismatch, the .bak is
|
|
151
|
+
* restored and the call throws - catches encoder bugs, partial writes, and any filesystem-level corruption that happened during the write.
|
|
54
152
|
*
|
|
55
153
|
* @template T - The in-memory data type that callers mutate.
|
|
56
154
|
* @param options - Store configuration.
|
|
57
|
-
* @returns A FileStore instance
|
|
155
|
+
* @returns A FileStore instance. Auto-registers in the global store registry so the release boot coordinator can snapshot it.
|
|
58
156
|
*/
|
|
59
157
|
export declare function createFileStore<T>(options: FileStoreOptions<T>): FileStore<T>;
|