@volter/world-core 2.0.12 → 2.0.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/dist/src/derived-core.d.ts +1 -2
- package/dist/src/derived.d.ts +2 -4
- package/dist/src/derived.js +2 -2
- package/package.json +1 -1
- package/src/derived-core.ts +1 -2
- package/src/derived.ts +4 -6
|
@@ -163,8 +163,7 @@ export type DerivedManifest = {
|
|
|
163
163
|
template: string;
|
|
164
164
|
acceptProvided?: boolean;
|
|
165
165
|
};
|
|
166
|
-
/** operations the derived core must not claim though their resource is declared:
|
|
167
|
-
* the pack's existing code, or a gap, until someone models them */
|
|
166
|
+
/** operations the derived core must not claim though their resource is declared: a gap until someone models them */
|
|
168
167
|
unmodeled?: string[];
|
|
169
168
|
/** operations that only read though nothing in the spec says so (a POST that returns data):
|
|
170
169
|
* a read-only twin answers them */
|
package/dist/src/derived.d.ts
CHANGED
|
@@ -54,10 +54,8 @@ export type DerivedFetchOptions = {
|
|
|
54
54
|
};
|
|
55
55
|
/** An RPC wire: every method is reached by any HTTP method (Slack's clients POST reads too). */
|
|
56
56
|
anyMethod?: boolean;
|
|
57
|
-
/** The pack's existing fetch while it moves: everything no handler or core owns, and what the core cannot model. */
|
|
58
|
-
legacy?: (request: Request) => Promise<Response>;
|
|
59
57
|
/** What every operation a handler or the core serves passes through (read-only refusal, version
|
|
60
|
-
* checks, idempotent replay)
|
|
58
|
+
* checks, idempotent replay). */
|
|
61
59
|
around?: (call: DerivedCall, next: () => Promise<Response>) => Promise<Response>;
|
|
62
60
|
/** The vendor's answer for an operation nothing models: the pack's gap. */
|
|
63
61
|
gap: (request: Request, operation: DerivedOperation | undefined, reason: string) => Response;
|
|
@@ -74,7 +72,7 @@ export declare function matchOperation(routes: Map<string, Route[]>, method: str
|
|
|
74
72
|
operation: DerivedOperation;
|
|
75
73
|
params: Record<string, string>;
|
|
76
74
|
} | undefined;
|
|
77
|
-
export type DerivedOwner = 'handler' | 'core' | '
|
|
75
|
+
export type DerivedOwner = 'handler' | 'core' | 'gap';
|
|
78
76
|
export type DerivedFetch = ((request: Request) => Promise<Response>) & {
|
|
79
77
|
/** Per operationId, who serves it: a semantics handler, the derived core, the pack's existing
|
|
80
78
|
* fetch while it moves, or nothing (the vendor's gap). */
|
package/dist/src/derived.js
CHANGED
|
@@ -85,7 +85,7 @@ export function createDerivedFetch(options) {
|
|
|
85
85
|
if (unknown.length)
|
|
86
86
|
throw new Error(`derived dispatch: handlers name operations the surface does not have: ${unknown.sort().join(', ')}`);
|
|
87
87
|
const routes = compileSurface(options.surface);
|
|
88
|
-
const fallback = (request, operation, reason) =>
|
|
88
|
+
const fallback = (request, operation, reason) => Promise.resolve(options.gap(request, operation, reason));
|
|
89
89
|
// a valid incoming W3C traceparent scopes the dispatch, so every entry it appends records it (trace-context.ts)
|
|
90
90
|
const fetch = ((request) => runWithRequestTrace(request, () => dispatch(request)));
|
|
91
91
|
const dispatch = async (request) => {
|
|
@@ -120,6 +120,6 @@ export function createDerivedFetch(options) {
|
|
|
120
120
|
}
|
|
121
121
|
return fallback(request, matched.operation, 'no handler');
|
|
122
122
|
};
|
|
123
|
-
fetch.owners = () => Object.fromEntries(options.surface.operations.map((o) => [o.id, handlers[o.id] ? 'handler' : options.core?.owns(o) ? 'core' :
|
|
123
|
+
fetch.owners = () => Object.fromEntries(options.surface.operations.map((o) => [o.id, handlers[o.id] ? 'handler' : options.core?.owns(o) ? 'core' : 'gap']));
|
|
124
124
|
return fetch;
|
|
125
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/world-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"description": "The kernel of Volter World: one log per twin, branches as pointers, checkpoints, the fold that keeps a twin current, the head that performs a write against the vendor, references, and the git plane. A twin package builds on it; the runtime serves it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"twin",
|
package/src/derived-core.ts
CHANGED
|
@@ -147,8 +147,7 @@ export type DerivedManifest = {
|
|
|
147
147
|
* (`{prefix}_{n}`), or is `{uuid}` for a vendor whose ids are UUIDs: the next is derived from the resource and its
|
|
148
148
|
* count, so a World mints the same ids every run */
|
|
149
149
|
ids: { template: string; acceptProvided?: boolean };
|
|
150
|
-
/** operations the derived core must not claim though their resource is declared:
|
|
151
|
-
* the pack's existing code, or a gap, until someone models them */
|
|
150
|
+
/** operations the derived core must not claim though their resource is declared: a gap until someone models them */
|
|
152
151
|
unmodeled?: string[];
|
|
153
152
|
/** operations that only read though nothing in the spec says so (a POST that returns data):
|
|
154
153
|
* a read-only twin answers them */
|
package/src/derived.ts
CHANGED
|
@@ -46,10 +46,8 @@ export type DerivedFetchOptions = {
|
|
|
46
46
|
core?: { owns: (operation: DerivedOperation) => boolean; serve: (call: DerivedCall) => Promise<DerivedCoreOutcome> };
|
|
47
47
|
/** An RPC wire: every method is reached by any HTTP method (Slack's clients POST reads too). */
|
|
48
48
|
anyMethod?: boolean;
|
|
49
|
-
/** The pack's existing fetch while it moves: everything no handler or core owns, and what the core cannot model. */
|
|
50
|
-
legacy?: (request: Request) => Promise<Response>;
|
|
51
49
|
/** What every operation a handler or the core serves passes through (read-only refusal, version
|
|
52
|
-
* checks, idempotent replay)
|
|
50
|
+
* checks, idempotent replay). */
|
|
53
51
|
around?: (call: DerivedCall, next: () => Promise<Response>) => Promise<Response>;
|
|
54
52
|
/** The vendor's answer for an operation nothing models: the pack's gap. */
|
|
55
53
|
gap: (request: Request, operation: DerivedOperation | undefined, reason: string) => Response;
|
|
@@ -126,7 +124,7 @@ export function matchOperation(routes: Map<string, Route[]>, method: string, pat
|
|
|
126
124
|
return undefined;
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
export type DerivedOwner = 'handler' | 'core' | '
|
|
127
|
+
export type DerivedOwner = 'handler' | 'core' | 'gap';
|
|
130
128
|
|
|
131
129
|
export type DerivedFetch = ((request: Request) => Promise<Response>) & {
|
|
132
130
|
/** Per operationId, who serves it: a semantics handler, the derived core, the pack's existing
|
|
@@ -141,7 +139,7 @@ export function createDerivedFetch(options: DerivedFetchOptions): DerivedFetch {
|
|
|
141
139
|
if (unknown.length) throw new Error(`derived dispatch: handlers name operations the surface does not have: ${unknown.sort().join(', ')}`);
|
|
142
140
|
const routes = compileSurface(options.surface);
|
|
143
141
|
const fallback = (request: Request, operation: DerivedOperation | undefined, reason: string): Promise<Response> =>
|
|
144
|
-
|
|
142
|
+
Promise.resolve(options.gap(request, operation, reason));
|
|
145
143
|
// a valid incoming W3C traceparent scopes the dispatch, so every entry it appends records it (trace-context.ts)
|
|
146
144
|
const fetch = ((request: Request): Promise<Response> => runWithRequestTrace(request, () => dispatch(request))) as DerivedFetch;
|
|
147
145
|
const dispatch = async (request: Request): Promise<Response> => {
|
|
@@ -173,7 +171,7 @@ export function createDerivedFetch(options: DerivedFetchOptions): DerivedFetch {
|
|
|
173
171
|
};
|
|
174
172
|
fetch.owners = () =>
|
|
175
173
|
Object.fromEntries(
|
|
176
|
-
options.surface.operations.map((o) => [o.id, handlers[o.id] ? 'handler' : options.core?.owns(o) ? 'core' :
|
|
174
|
+
options.surface.operations.map((o) => [o.id, handlers[o.id] ? 'handler' : options.core?.owns(o) ? 'core' : 'gap'] as const),
|
|
177
175
|
);
|
|
178
176
|
return fetch;
|
|
179
177
|
}
|