javascript-solid-server 0.0.115 → 0.0.116

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "javascript-solid-server",
3
- "version": "0.0.115",
3
+ "version": "0.0.116",
4
4
  "description": "A minimal, fast Solid server",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -16,15 +16,20 @@ export function generateContainerJsonLd(containerUrl, entries) {
16
16
 
17
17
  const contains = entries.map(entry => {
18
18
  const childUrl = baseUrl + entry.name + (entry.isDirectory ? '/' : '');
19
- return {
19
+ const item = {
20
20
  '@id': childUrl,
21
21
  '@type': entry.isDirectory ? [`${LDP}Container`, `${LDP}BasicContainer`, `${LDP}Resource`] : [`${LDP}Resource`]
22
22
  };
23
+ if (entry.size != null) item['stat:size'] = entry.size;
24
+ if (entry.modified) item['dcterms:modified'] = entry.modified;
25
+ return item;
23
26
  });
24
27
 
25
28
  return {
26
29
  '@context': {
27
30
  'ldp': LDP,
31
+ 'stat': 'http://www.w3.org/ns/posix/stat#',
32
+ 'dcterms': 'http://purl.org/dc/terms/',
28
33
  'contains': { '@id': 'ldp:contains', '@type': '@id' }
29
34
  },
30
35
  '@id': baseUrl,
@@ -126,19 +126,28 @@ export async function createContainer(urlPath) {
126
126
  }
127
127
 
128
128
  /**
129
- * List container contents
129
+ * List container contents with stat metadata
130
130
  * @param {string} urlPath
131
- * @returns {Promise<Array<{name: string, isDirectory: boolean}> | null>}
131
+ * @returns {Promise<Array<{name: string, isDirectory: boolean, size?: number, modified?: string}> | null>}
132
132
  */
133
133
  export async function listContainer(urlPath) {
134
134
  const filePath = urlToPath(urlPath);
135
135
 
136
136
  try {
137
137
  const entries = await fs.readdir(filePath, { withFileTypes: true });
138
- return entries.map(entry => ({
139
- name: entry.name,
140
- isDirectory: entry.isDirectory()
138
+ const results = await Promise.all(entries.map(async (entry) => {
139
+ const result = {
140
+ name: entry.name,
141
+ isDirectory: entry.isDirectory()
142
+ };
143
+ try {
144
+ const stat = await fs.stat(path.join(filePath, entry.name));
145
+ result.size = stat.size;
146
+ result.modified = stat.mtime.toISOString();
147
+ } catch { /* stat failed, skip metadata */ }
148
+ return result;
141
149
  }));
150
+ return results;
142
151
  } catch {
143
152
  return null;
144
153
  }