Skip to content

createPodStructure should write .jsonld (not .ttl) for prefs and TypeIndexes #282

Description

@melvincarvalho

Current behaviour

createPodStructure in `src/handlers/container.js` writes three RDF files when a pod is created:

```
settings/Preferences.ttl
settings/publicTypeIndex.ttl
settings/privateTypeIndex.ttl
```

The `.ttl` extension is chosen explicitly "for mashlib" (per the inline comment), but JSS is otherwise a JSON-LD-native server — Turtle support is opt-in via `--conneg`, while `.jsonld` / `application/ld+json` is the always-on default.

Proposal

Change the three artefacts to:

```
settings/prefs.jsonld
settings/publicTypeIndex.jsonld
settings/privateTypeIndex.jsonld
```

  • The `Preferences.ttl` → `prefs.jsonld` rename also aligns with the `pim:preferencesFile` predicate on the WebID; both mashlib and solid-client historically point at a variety of paths.
  • Serialize with the existing JSON-LD writer — no new dependency.
  • Keep `profile/card` as HTML (already the standard Solid profile-as-HTML pattern, unchanged).

Why it matters

Client apps that do "follow your nose" discovery and want to write to these files (add a TypeIndex registration, update a preference) have to pick one extension. Any mismatch between a pod's freshly-created `.ttl` and the client's assumed `.jsonld` produces two files with the same logical content and a broken chain — I hit exactly this when wiring up pilot's "Create prefs" / "Create TypeIndex" buttons against a JSS-created pod. Ended up renaming server-side files and updating WebID predicates to unblock.

`.jsonld` is also a lot easier to hand-edit (stable key order, no namespace dance), which matters when a user is curating a growing TypeIndex — `.ttl`'s shorthand looks great for reading but loses parity with how pilot / solid-panes / most new clients write.

Suggested changes

`createPodStructure` in `src/handlers/container.js`:

```diff

  • await storage.write(`${podPath}settings/Preferences.ttl`, serialize(prefs));
  • await storage.write(`${podPath}settings/prefs.jsonld`, JSON.stringify(prefs, null, 2));
  • const publicTypeIndex = generateTypeIndex(`${podUri}settings/publicTypeIndex.ttl`);
  • await storage.write(`${podPath}settings/publicTypeIndex.ttl`, serialize(publicTypeIndex));
  • const publicTypeIndex = generateTypeIndex(`${podUri}settings/publicTypeIndex.jsonld`);
  • await storage.write(`${podPath}settings/publicTypeIndex.jsonld`, JSON.stringify(publicTypeIndex, null, 2));
  • const privateTypeIndex = generateTypeIndex(`${podUri}settings/privateTypeIndex.ttl`);
  • await storage.write(`${podPath}settings/privateTypeIndex.ttl`, serialize(privateTypeIndex));
  • const privateTypeIndex = generateTypeIndex(`${podUri}settings/privateTypeIndex.jsonld`);
  • await storage.write(`${podPath}settings/privateTypeIndex.jsonld`, JSON.stringify(privateTypeIndex, null, 2));
    ```

Same for `createRootPodStructure` in `src/server.js` (single-user root-pod mode).

The WebID card keeps `pim:preferencesFile` / `solid:publicTypeIndex` pointing at the new paths so follow-your-nose continues to work.

Back-compat

Breaks pods that external clients assume are `.ttl`-shaped. Three options, in order of my preference:

  1. Just change it. JSS is `0.0.x`, moving fast, and the dominant consumers (mashlib + conneg clients) can already fetch `.jsonld` fine.
  2. Write both (`prefs.jsonld` AND `Preferences.ttl`) for a release or two, then drop `.ttl`. Ugly but safe.
  3. Add a flag like `--pod-format jsonld|ttl` defaulting to `jsonld` for new pods.

Happy to PR whichever direction you pick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions