@plurnk/plurnk-schemes 0.32.10 → 0.32.13
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/SPEC.md
CHANGED
|
@@ -98,9 +98,9 @@ Behavior ships as `export default class` (one class per file, static methods)
|
|
|
98
98
|
|
|
99
99
|
### Mimetype classification — `MimetypeClassifier`
|
|
100
100
|
|
|
101
|
-
- `MimetypeClassifier.isBinary(mimetype)` — enforces 415 boundary on binary entries
|
|
102
|
-
- `MimetypeClassifier.isJson(mimetype)` — `application/json` plus `+json` variants. Used by `<L>` dispatch.
|
|
103
|
-
- `MimetypeClassifier.isLineNavigable(mimetype)` — render-layer decides whether to prefix lines with `N:\t`.
|
|
101
|
+
- `MimetypeClassifier.isBinary(mimetype)` — enforces 415 boundary on binary entries. Delegates to `classifyMimetype` from @plurnk/plurnk-mimetypes (the framework owns the text/binary taxonomy — mimetypes#43; the former local allowlists were absorbed upstream verbatim and retired).
|
|
102
|
+
- `MimetypeClassifier.isJson(mimetype)` — `application/json` plus `+json` variants. Used by `<L>` dispatch. Scheme semantics — stays local, not delegated.
|
|
103
|
+
- `MimetypeClassifier.isLineNavigable(mimetype)` — render-layer decides whether to prefix lines with `N:\t`. Delegates to `classifyMimetype`.
|
|
104
104
|
- `MimetypeClassifier.normalizeAutoText(mimetype)` — `text/plain` / null / undefined → `TEXT_PRIMITIVE_MIMETYPE` (`text/markdown`).
|
|
105
105
|
- `TEXT_PRIMITIVE_MIMETYPE` — `"text/markdown"` (named export from the same module).
|
|
106
106
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimetypeClassifier.d.ts","sourceRoot":"","sources":["../src/MimetypeClassifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MimetypeClassifier.d.ts","sourceRoot":"","sources":["../src/MimetypeClassifier.ts"],"names":[],"mappings":"AAuBA,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAEnC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQ1C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKxC,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQjD,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;CAMxE"}
|
|
@@ -1,41 +1,16 @@
|
|
|
1
1
|
// Mimetype classifiers used at op-handler boundaries.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// binary/line-navigable taxonomy DELEGATES to @plurnk/plurnk-mimetypes'
|
|
4
|
+
// `classifyMimetype` (mimetypes#43, delivered 0.18.0) — the framework is the
|
|
5
|
+
// single source of filetype truth, and our former local allowlists were a
|
|
6
|
+
// drift surface (schemes#28: NDJSON classified binary → READ 415). The 44-case
|
|
7
|
+
// truth table those tables encoded was absorbed upstream byte-for-byte; the
|
|
8
|
+
// unit suite here remains as the conformance guard on that absorption.
|
|
5
9
|
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
// the structural navigation those formats use (jsonpath, xpath).
|
|
11
|
-
//
|
|
12
|
-
// Local heuristic until @plurnk/plurnk-mimetypes exposes per-mimetype
|
|
13
|
-
// binary/text + line-navigable classification via its public API — at which
|
|
14
|
-
// point these tables retire and this delegates upstream. Requested in
|
|
15
|
-
// plurnk-mimetypes#43 (HandlerInfo flags exist at registry level but aren't
|
|
16
|
-
// queryable per-mimetype yet). The NDJSON drift (schemes#28) is the motivation.
|
|
17
|
-
const TEXT_APPLICATION_MIMETYPES = new Set([
|
|
18
|
-
"application/json",
|
|
19
|
-
"application/yaml",
|
|
20
|
-
"application/toml",
|
|
21
|
-
"application/xml",
|
|
22
|
-
"application/javascript",
|
|
23
|
-
"application/typescript",
|
|
24
|
-
"application/sql",
|
|
25
|
-
// NDJSON family — line-delimited JSON. Text, and MORE line-navigable than a
|
|
26
|
-
// single JSON doc (each line is a record); the `jsonl` suffix isn't `+json`,
|
|
27
|
-
// so without an explicit entry it falls through to binary → 415 on READ
|
|
28
|
-
// (schemes#28; surfaced via EXEC[jq] streams labelled application/jsonl).
|
|
29
|
-
"application/jsonl",
|
|
30
|
-
"application/x-ndjson",
|
|
31
|
-
]);
|
|
32
|
-
// Mimetypes that are structurally tree-navigated rather than line-
|
|
33
|
-
// navigated. READ output of these doesn't get `N:\t` prefixes.
|
|
34
|
-
const TREE_NAVIGABLE_MIMETYPES = new Set([
|
|
35
|
-
"application/json",
|
|
36
|
-
"application/xml",
|
|
37
|
-
"text/html",
|
|
38
|
-
]);
|
|
10
|
+
// What stays LOCAL is scheme semantics, not filetype fact (ruled in #43):
|
|
11
|
+
// isJson — `<L>` item-index dispatch (RFC 6839 + slicer semantics).
|
|
12
|
+
// normalizeAutoText — the text-primitive policy (auto-derived text is markdown).
|
|
13
|
+
import { classifyMimetype } from "@plurnk/plurnk-mimetypes";
|
|
39
14
|
// Text primitive for the agent contract: text/markdown is the default
|
|
40
15
|
// text mimetype anywhere plurnk-service auto-derives a text result.
|
|
41
16
|
// text/plain is reserved for explicit scheme-manifest declarations
|
|
@@ -46,40 +21,20 @@ const TREE_NAVIGABLE_MIMETYPES = new Set([
|
|
|
46
21
|
// markdown?"
|
|
47
22
|
export const TEXT_PRIMITIVE_MIMETYPE = "text/markdown";
|
|
48
23
|
export default class MimetypeClassifier {
|
|
24
|
+
// 415 boundary on binary entries (SPEC.md §3).
|
|
49
25
|
static isBinary(mimetype) {
|
|
50
|
-
|
|
51
|
-
return false;
|
|
52
|
-
const slash = mimetype.indexOf("/");
|
|
53
|
-
if (slash === -1)
|
|
54
|
-
return true;
|
|
55
|
-
const type = mimetype.slice(0, slash);
|
|
56
|
-
if (type === "text")
|
|
57
|
-
return false;
|
|
58
|
-
if (TEXT_APPLICATION_MIMETYPES.has(mimetype))
|
|
59
|
-
return false;
|
|
60
|
-
if (mimetype.endsWith("+json") || mimetype.endsWith("+xml") || mimetype.endsWith("+yaml"))
|
|
61
|
-
return false;
|
|
62
|
-
return true;
|
|
26
|
+
return classifyMimetype(mimetype).binary;
|
|
63
27
|
}
|
|
64
28
|
// JSON-family check — used by `<L>` dispatch to pick structural slicer
|
|
65
29
|
// (Slicer.jsonItems) over line slicer (Slicer.lines) for JSON sources.
|
|
66
30
|
// Matches application/json plus +json suffix variants per RFC 6839.
|
|
31
|
+
// Scheme semantics, deliberately NOT delegated (mimetypes#43).
|
|
67
32
|
static isJson(mimetype) {
|
|
68
33
|
return mimetype === "application/json" || mimetype.endsWith("+json");
|
|
69
34
|
}
|
|
35
|
+
// Render-layer `N:\t` prefix decision (SPEC.md §3).
|
|
70
36
|
static isLineNavigable(mimetype) {
|
|
71
|
-
|
|
72
|
-
return false;
|
|
73
|
-
if (MimetypeClassifier.isBinary(mimetype))
|
|
74
|
-
return false;
|
|
75
|
-
if (TREE_NAVIGABLE_MIMETYPES.has(mimetype))
|
|
76
|
-
return false;
|
|
77
|
-
if (mimetype.endsWith("+json") || mimetype.endsWith("+xml"))
|
|
78
|
-
return false;
|
|
79
|
-
// Everything text-ish that isn't tree-shaped is line-navigable.
|
|
80
|
-
// text/plain, text/markdown, text/csv, text/javascript, text/typescript,
|
|
81
|
-
// application/yaml, application/toml, application/javascript, etc.
|
|
82
|
-
return true;
|
|
37
|
+
return classifyMimetype(mimetype).lineNavigable;
|
|
83
38
|
}
|
|
84
39
|
// Normalize an auto-derived text mimetype to the text primitive.
|
|
85
40
|
// Use at any consumer-side auto-derivation point (file scheme
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimetypeClassifier.js","sourceRoot":"","sources":["../src/MimetypeClassifier.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"MimetypeClassifier.js","sourceR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|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-schemes",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.13",
|
|
4
4
|
"description": "Framework + contract for the @plurnk/plurnk-schemes-* URI handler family.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plurnk",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"prepare": "npm run build"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@plurnk/plurnk-grammar": "0.74.
|
|
49
|
-
"@plurnk/plurnk-mimetypes": "0.
|
|
48
|
+
"@plurnk/plurnk-grammar": "0.74.51",
|
|
49
|
+
"@plurnk/plurnk-mimetypes": "0.18.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@plurnk/plurnk-grammar": "0.74.
|
|
53
|
-
"@plurnk/plurnk-mimetypes": "0.
|
|
52
|
+
"@plurnk/plurnk-grammar": "0.74.51",
|
|
53
|
+
"@plurnk/plurnk-mimetypes": "0.18.0",
|
|
54
54
|
"@types/node": "26.0.1",
|
|
55
55
|
"typescript": "6.0.3"
|
|
56
56
|
}
|