@plurnk/plurnk-schemes 0.1.0 → 0.1.2
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/results.d.ts +42 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +46 -0
- package/dist/results.js.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export type { EditResult as LineEditResult, JsonSliceResult, SliceResult } from
|
|
|
7
7
|
export { resolveEntryMimetype } from "./path-mimetype.ts";
|
|
8
8
|
export { matchAgainstContent } from "./matcher.ts";
|
|
9
9
|
export type { MatchResult } from "./matcher.ts";
|
|
10
|
+
export { isEntryResult, isErrorStatus, isPassthroughResult, isProposalResult, logCoordinate, schemeError, } from "./results.ts";
|
|
11
|
+
export type { EntryResult, PassthroughResult, ProposalResult, SchemeResult, SchemeResultBase, TelemetryEvent, } from "./results.ts";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,UAAU,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,aAAa,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,UAAU,IAAI,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,UAAU,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,aAAa,GAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,UAAU,IAAI,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EACH,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,WAAW,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACjB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export { isBinaryMimetype, isJsonMimetype, isLineNavigableMimetype, normalizeAut
|
|
|
4
4
|
export { applyJsonItemEdit, applyLineMarkerEdit, sliceJsonItems, sliceLines, sliceLinesRaw, } from "./line-marker.js";
|
|
5
5
|
export { resolveEntryMimetype } from "./path-mimetype.js";
|
|
6
6
|
export { matchAgainstContent } from "./matcher.js";
|
|
7
|
+
export { isEntryResult, isErrorStatus, isPassthroughResult, isProposalResult, logCoordinate, schemeError, } from "./results.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,aAAa,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,aAAa,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EACH,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,WAAW,GACd,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { PlurnkParseError } from "@plurnk/plurnk-grammar";
|
|
2
|
+
type TelemetryEvent = ReturnType<PlurnkParseError["toTelemetryEvent"]>;
|
|
3
|
+
type LogCoordinate = Extract<NonNullable<TelemetryEvent["position"]>, {
|
|
4
|
+
type: "log-coordinate";
|
|
5
|
+
}>;
|
|
6
|
+
export type { TelemetryEvent };
|
|
7
|
+
export interface SchemeResultBase {
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly error?: TelemetryEvent;
|
|
10
|
+
}
|
|
11
|
+
export interface EntryResult extends SchemeResultBase {
|
|
12
|
+
readonly shape: "entry";
|
|
13
|
+
readonly entryId: number | null;
|
|
14
|
+
readonly channel: string | null;
|
|
15
|
+
readonly content?: string | null;
|
|
16
|
+
readonly mimetype?: string | null;
|
|
17
|
+
readonly startLine?: number | null;
|
|
18
|
+
readonly matches?: number | null;
|
|
19
|
+
readonly reason?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ProposalResult extends SchemeResultBase {
|
|
22
|
+
readonly shape: "proposal";
|
|
23
|
+
readonly body?: string;
|
|
24
|
+
readonly attrs?: object;
|
|
25
|
+
readonly diff?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PassthroughResult extends SchemeResultBase {
|
|
28
|
+
readonly shape: "passthrough";
|
|
29
|
+
readonly content?: string | null;
|
|
30
|
+
readonly mimetype?: string | null;
|
|
31
|
+
readonly startLine?: number | null;
|
|
32
|
+
readonly matches?: number | null;
|
|
33
|
+
readonly reason?: string;
|
|
34
|
+
}
|
|
35
|
+
export type SchemeResult = EntryResult | ProposalResult | PassthroughResult;
|
|
36
|
+
export declare const isEntryResult: (result: SchemeResult) => result is EntryResult;
|
|
37
|
+
export declare const isProposalResult: (result: SchemeResult) => result is ProposalResult;
|
|
38
|
+
export declare const isPassthroughResult: (result: SchemeResult) => result is PassthroughResult;
|
|
39
|
+
export declare const isErrorStatus: (status: number) => boolean;
|
|
40
|
+
export declare const schemeError: (scheme: string, kind: string, message?: string | null, position?: TelemetryEvent["position"]) => TelemetryEvent;
|
|
41
|
+
export declare const logCoordinate: (coordinate: string, op?: string) => LogCoordinate;
|
|
42
|
+
//# sourceMappingURL=results.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,KAAK,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAIvE,KAAK,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAAC;AAElG,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;CACnC;AAED,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACjD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAA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AAC,UAAU,CAAC,KACtC,cAKD,CAAC;AAMH,eAAO,MAAM,aAAa,GAAI,YAAY,MAAM,EAAE,KAAK,MAAM,KAAG,aAI9D,CAAC"}
|
package/dist/results.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Canonical op-result contract for `@plurnk/plurnk-schemes-*` siblings and
|
|
2
|
+
// their consumer (plurnk-service). Replaces the per-op result types that
|
|
3
|
+
// forked in-tree (plurnk-service `_entry-ops.ts` vs the local redefinitions
|
|
4
|
+
// in `File.ts` / `Exec.ts` / `Log.ts`).
|
|
5
|
+
//
|
|
6
|
+
// The shape keys on SCHEME-SHAPE, not op. EDIT against `known://` and EDIT
|
|
7
|
+
// against `file://` produce structurally different results because the
|
|
8
|
+
// schemes are differently shaped, not because EDIT is. So a family is the
|
|
9
|
+
// superset of fields its shape can return across every op (entry-shape READ
|
|
10
|
+
// returns content; entry-shape EDIT returns entryId) — fields optional per
|
|
11
|
+
// op, discriminated by `shape`.
|
|
12
|
+
//
|
|
13
|
+
// Three shapes cover the current set:
|
|
14
|
+
// entry — entries + entry_channels backed (known/unknown/skill/plurnk)
|
|
15
|
+
// proposal — propose-then-resolve with payload (file/exec)
|
|
16
|
+
// passthrough — read-only / coordinate-addressed / network (log, future http)
|
|
17
|
+
//
|
|
18
|
+
// Error surface: `error` is a grammar `TelemetryEvent` (not a bare string),
|
|
19
|
+
// present iff `status >= 400`. The consumer mirrors it into
|
|
20
|
+
// `packet.user.telemetry.errors[]` unchanged.
|
|
21
|
+
export const isEntryResult = (result) => result.shape === "entry";
|
|
22
|
+
export const isProposalResult = (result) => result.shape === "proposal";
|
|
23
|
+
export const isPassthroughResult = (result) => result.shape === "passthrough";
|
|
24
|
+
// A result is an error result iff its status is in the 4xx/5xx range. The
|
|
25
|
+
// `error` envelope is expected on those and absent otherwise.
|
|
26
|
+
export const isErrorStatus = (status) => status >= 400;
|
|
27
|
+
// Build a scheme-sourced TelemetryEvent. `source` is `scheme:<name>` per
|
|
28
|
+
// the envelope's producer-namespacing convention (grammar TelemetryEvent
|
|
29
|
+
// schema). Absent message/position are omitted rather than set to undefined
|
|
30
|
+
// so the emitted object matches the wire shape exactly.
|
|
31
|
+
export const schemeError = (scheme, kind, message, position) => ({
|
|
32
|
+
source: `scheme:${scheme}`,
|
|
33
|
+
kind,
|
|
34
|
+
...(message === undefined ? {} : { message }),
|
|
35
|
+
...(position === undefined ? {} : { position }),
|
|
36
|
+
});
|
|
37
|
+
// Build a LogCoordinate position pointing at an action's log row. The engine
|
|
38
|
+
// knows the coordinate at result-time, so schemes rarely construct this
|
|
39
|
+
// directly — it's here for the consumer-side mirror and for schemes that
|
|
40
|
+
// surface errors against a known prior coordinate.
|
|
41
|
+
export const logCoordinate = (coordinate, op) => ({
|
|
42
|
+
type: "log-coordinate",
|
|
43
|
+
coordinate,
|
|
44
|
+
...(op === undefined ? {} : { op }),
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=results.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../src/results.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,wCAAwC;AACxC,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,0EAA0E;AAC1E,4EAA4E;AAC5E,2EAA2E;AAC3E,gCAAgC;AAChC,EAAE;AACF,sCAAsC;AACtC,+EAA+E;AAC/E,gEAAgE;AAChE,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,4DAA4D;AAC5D,8CAA8C;AAoD9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAoB,EAAyB,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,OAAO,CAAC;AACvG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAoB,EAA4B,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC;AAChH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAoB,EAA+B,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC;AAEzH,0EAA0E;AAC1E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,IAAI,GAAG,CAAC;AAExE,yEAAyE;AACzE,yEAAyE;AACzE,4EAA4E;AAC5E,wDAAwD;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,MAAc,EACd,IAAY,EACZ,OAAuB,EACvB,QAAqC,EACvB,EAAE,CAAC,CAAC;IAClB,MAAM,EAAE,UAAU,MAAM,EAAE;IAC1B,IAAI;IACJ,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;IAC7C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;CAClD,CAAC,CAAC;AAEH,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,EAAW,EAAiB,EAAE,CAAC,CAAC;IAC9E,IAAI,EAAE,gBAAgB;IACtB,UAAU;IACV,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;CACtC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-schemes",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Framework + contract for the @plurnk/plurnk-schemes-* URI handler family.",
|
|
5
5
|
"keywords": ["plurnk", "scheme", "uri"],
|
|
6
6
|
"homepage": "https://github.com/plurnk/plurnk-schemes#readme",
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"prepare": "npm run build"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@plurnk/plurnk-grammar": "
|
|
45
|
-
"@plurnk/plurnk-mimetypes": "
|
|
44
|
+
"@plurnk/plurnk-grammar": "0.17.1",
|
|
45
|
+
"@plurnk/plurnk-mimetypes": "0.7.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@plurnk/plurnk-grammar": "
|
|
49
|
-
"@plurnk/plurnk-mimetypes": "
|
|
48
|
+
"@plurnk/plurnk-grammar": "0.17.1",
|
|
49
|
+
"@plurnk/plurnk-mimetypes": "0.7.1",
|
|
50
50
|
"@types/node": "^25.8.0",
|
|
51
51
|
"typescript": "^6.0.3"
|
|
52
52
|
}
|