@camstack/addon-post-analysis 1.2.54 → 1.2.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.
@@ -1,151 +0,0 @@
1
- const require_dist = require("./dist-BJ65Xxa1.js");
2
- let node_fs = require("node:fs");
3
- node_fs = require_dist.__toESM(node_fs, 1);
4
- let node_path = require("node:path");
5
- node_path = require_dist.__toESM(node_path, 1);
6
- require("node:crypto");
7
- require("node:child_process");
8
- var STORAGE_LOCATION_TYPES = [
9
- "data",
10
- "media",
11
- "recordings",
12
- "recordings-high",
13
- "recordings-low",
14
- "recordings-clips",
15
- "event-images",
16
- "models",
17
- "addons-data",
18
- "cache",
19
- "logs",
20
- "backups"
21
- ];
22
- var DEFAULT_LOCATION_SUBDIRS = {
23
- data: "db",
24
- media: "media",
25
- recordings: "recordings",
26
- "recordings-high": "recordings-high",
27
- "recordings-low": "recordings-low",
28
- "recordings-clips": "recordings-clips",
29
- "event-images": "event-images",
30
- models: "models",
31
- "addons-data": "addons-data",
32
- cache: "/tmp/camstack-cache",
33
- logs: "logs",
34
- backups: "backups"
35
- };
36
- /**
37
- * Filesystem storage provider — serves all location types from a local directory tree.
38
- *
39
- * Default layout:
40
- * {rootPath}/recordings-high/
41
- * {rootPath}/recordings-low/
42
- * {rootPath}/recordings-clips/
43
- * {rootPath}/event-images/
44
- * {rootPath}/models/
45
- * {rootPath}/addons-data/
46
- * {rootPath}/logs/
47
- * /tmp/camstack-cache/ (cache is always local)
48
- *
49
- * Individual location paths can be overridden.
50
- */
51
- var FilesystemStorageProvider = class {
52
- id = "local";
53
- name = "Local Filesystem";
54
- supportedLocations = [...STORAGE_LOCATION_TYPES];
55
- rootPath;
56
- locationPaths;
57
- constructor(rootPath, overrides) {
58
- this.rootPath = node_path.resolve(rootPath);
59
- this.locationPaths = /* @__PURE__ */ new Map();
60
- for (const loc of STORAGE_LOCATION_TYPES) {
61
- const override = overrides?.[loc];
62
- if (override) this.locationPaths.set(loc, node_path.resolve(override));
63
- else {
64
- const subdir = DEFAULT_LOCATION_SUBDIRS[loc] ?? loc;
65
- this.locationPaths.set(loc, node_path.isAbsolute(subdir) ? subdir : node_path.join(this.rootPath, subdir));
66
- }
67
- }
68
- for (const [loc, override] of Object.entries(overrides ?? {})) if (typeof override === "string" && !this.locationPaths.has(loc)) this.locationPaths.set(loc, node_path.resolve(override));
69
- }
70
- async resolve({ location, relativePath }) {
71
- const base = this.locationPaths.get(location) ?? node_path.join(this.rootPath, location);
72
- return node_path.join(base, relativePath);
73
- }
74
- async write({ location, relativePath, data }) {
75
- const filePath = await this.resolve({
76
- location,
77
- relativePath
78
- });
79
- await node_fs.promises.mkdir(node_path.dirname(filePath), { recursive: true });
80
- if (Buffer.isBuffer(data)) await node_fs.promises.writeFile(filePath, data);
81
- else {
82
- const writeStream = node_fs.createWriteStream(filePath);
83
- await new Promise((resolve, reject) => {
84
- data.pipe(writeStream);
85
- writeStream.on("finish", resolve);
86
- writeStream.on("error", reject);
87
- });
88
- }
89
- }
90
- async read({ location, relativePath }) {
91
- return node_fs.promises.readFile(await this.resolve({
92
- location,
93
- relativePath
94
- }));
95
- }
96
- async exists({ location, relativePath }) {
97
- try {
98
- await node_fs.promises.access(await this.resolve({
99
- location,
100
- relativePath
101
- }));
102
- return true;
103
- } catch {
104
- return false;
105
- }
106
- }
107
- async list({ location, prefix }) {
108
- const base = this.locationPaths.get(location);
109
- if (!base) return [];
110
- const dir = prefix ? node_path.join(base, prefix) : base;
111
- try {
112
- return (await node_fs.promises.readdir(dir, { withFileTypes: true })).map((e) => prefix ? `${prefix}/${e.name}` : e.name);
113
- } catch {
114
- return [];
115
- }
116
- }
117
- async delete({ location, relativePath }) {
118
- const filePath = await this.resolve({
119
- location,
120
- relativePath
121
- });
122
- await node_fs.promises.rm(filePath, { force: true });
123
- }
124
- async getAvailableSpace({ location }) {
125
- const base = this.locationPaths.get(location);
126
- if (!base) return null;
127
- try {
128
- let target = base;
129
- while (!node_fs.existsSync(target)) {
130
- const parent = node_path.dirname(target);
131
- if (!parent || parent === target) return null;
132
- target = parent;
133
- }
134
- const stats = await node_fs.promises.statfs(target);
135
- return stats.bavail * stats.bsize;
136
- } catch {
137
- return null;
138
- }
139
- }
140
- /** Get the resolved path for a location type (addon-declared ids fall back
141
- * to `<rootPath>/<id>`). */
142
- getLocationPath(location) {
143
- return this.locationPaths.get(location) ?? node_path.join(this.rootPath, location);
144
- }
145
- /** Get the root path */
146
- getRootPath() {
147
- return this.rootPath;
148
- }
149
- };
150
- //#endregion
151
- exports.FilesystemStorageProvider = FilesystemStorageProvider;