@sasjs/api 0.32.0 → 0.35.0
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/build/browser.js +2274 -1
- package/build/cjs/corpus/viya/operations.js +647 -0
- package/build/cjs/index.js +65 -40
- package/build/cjs/viya/dispatch.js +141 -0
- package/build/cjs/viya/overlay.js +104 -0
- package/build/cjs/viya/service.js +317 -0
- package/build/cjs/viya/surface.js +326 -0
- package/build/cjs/viya/table.js +805 -0
- package/build/cjs/viya/unrecorded.js +58 -0
- package/build/cjs/viya/version.js +43 -0
- package/build/esm/corpus/viya/operations.d.ts +28 -0
- package/build/esm/corpus/viya/operations.d.ts.map +1 -0
- package/build/esm/corpus/viya/operations.js +644 -0
- package/build/esm/index.d.ts +14 -0
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +10 -0
- package/build/esm/viya/dispatch.d.ts +35 -0
- package/build/esm/viya/dispatch.d.ts.map +1 -0
- package/build/esm/viya/dispatch.js +136 -0
- package/build/esm/viya/overlay.d.ts +25 -0
- package/build/esm/viya/overlay.d.ts.map +1 -0
- package/build/esm/viya/overlay.js +100 -0
- package/build/esm/viya/service.d.ts +44 -0
- package/build/esm/viya/service.d.ts.map +1 -0
- package/build/esm/viya/service.js +313 -0
- package/build/esm/viya/surface.d.ts +26 -0
- package/build/esm/viya/surface.d.ts.map +1 -0
- package/build/esm/viya/surface.js +323 -0
- package/build/esm/viya/table.d.ts +39 -0
- package/build/esm/viya/table.d.ts.map +1 -0
- package/build/esm/viya/table.js +802 -0
- package/build/esm/viya/unrecorded.d.ts +24 -0
- package/build/esm/viya/unrecorded.d.ts.map +1 -0
- package/build/esm/viya/unrecorded.js +55 -0
- package/build/esm/viya/version.d.ts +37 -0
- package/build/esm/viya/version.d.ts.map +1 -0
- package/build/esm/viya/version.js +39 -0
- package/package.json +5 -1
package/build/esm/index.js
CHANGED
|
@@ -20,6 +20,16 @@ export { DEPLOY_LIMITS, DEPLOY_PAYLOAD_BYTES, DEPLOY_SUCCESS, checkDeployTree, d
|
|
|
20
20
|
export { MemoryDriveStore } from './drive/memory-store.js';
|
|
21
21
|
export { ROUTES, routeById, findRoute } from './routes/index.js';
|
|
22
22
|
export { OVERLAY, TAG_CAPABILITIES } from './routes/overlay.js';
|
|
23
|
+
// the client's call surface, and this package's decision about each entry: a
|
|
24
|
+
// host that refuses an out-of-scope path reads the same statement the guard does
|
|
25
|
+
export { SURFACE, SURFACE_ADAPTER_VERSION } from './viya/surface.js';
|
|
26
|
+
export { VIYA_TABLE } from './viya/table.js';
|
|
27
|
+
export { UNRECORDED } from './viya/unrecorded.js';
|
|
28
|
+
export { EMULATED_HEADER, EMULATED_HEADER_VALUE, VIYA_CAPTURED_AT, VIYA_TARGET_VERSION, emulatedHeaders } from './viya/version.js';
|
|
29
|
+
export { dispatchViya, findViyaOperation } from './viya/dispatch.js';
|
|
30
|
+
export { VIYA_OVERLAY } from './viya/overlay.js';
|
|
31
|
+
export { VIYA_HANDLERS } from './viya/service.js';
|
|
32
|
+
export { VIYA_CORPUS } from './corpus/viya/operations.js';
|
|
23
33
|
export { dispatch, HANDLED_ROUTES } from './host/dispatch.js';
|
|
24
34
|
// a host gating its own middleware reads the same decision the inventory reports
|
|
25
35
|
export * from './identity/routeAccess.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one entry point for a Viya-shaped request.
|
|
3
|
+
*
|
|
4
|
+
* A host owns its transport - express on one side, a service worker on the other
|
|
5
|
+
* - and this is where a Viya path becomes an answer. The table supplies the
|
|
6
|
+
* operations, the overlay supplies the decision, the handlers supply the body,
|
|
7
|
+
* and every answer leaves through one place so the emulated header cannot be
|
|
8
|
+
* forgotten on the paths that are easiest to forget it: a refusal and a 404.
|
|
9
|
+
*
|
|
10
|
+
* A request for a path the table does not have is a 404 that says so, and it
|
|
11
|
+
* carries the header like everything else - an emulated 404 must not be read as
|
|
12
|
+
* evidence about Viya.
|
|
13
|
+
*/
|
|
14
|
+
import type { ApiRequest, ApiResponse, Services } from '../host/dispatch.js';
|
|
15
|
+
import { type ViyaOperation } from './table.js';
|
|
16
|
+
/** An answer that states which contract produced it. */
|
|
17
|
+
export interface ViyaResponse extends ApiResponse {
|
|
18
|
+
/** Always carries `x-sasjs-emulated`, including on a 404 and a 501. */
|
|
19
|
+
headers: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export interface ViyaMatch {
|
|
22
|
+
operation: ViyaOperation;
|
|
23
|
+
/** The values the `{}` segments carried, in order. */
|
|
24
|
+
segments: string[];
|
|
25
|
+
}
|
|
26
|
+
/** The operation a request names, ignoring case in the static segments. */
|
|
27
|
+
export declare const findViyaOperation: (method: string, path: string) => ViyaMatch | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Answer a Viya request.
|
|
30
|
+
*
|
|
31
|
+
* `request` is the same shape the SASjs dispatch takes, so a host that already
|
|
32
|
+
* resolves a caller - a session cookie - passes `subject` rather than a token.
|
|
33
|
+
*/
|
|
34
|
+
export declare const dispatchViya: (services: Services, method: string, path: string, request?: ApiRequest) => Promise<ViyaResponse>;
|
|
35
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/viya/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE5E,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAK3D,wDAAwD;AACxD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,aAAa,CAAA;IACxB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AA4BD,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EACd,MAAM,MAAM,KACX,SAAS,GAAG,SA0Bd,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,QAAQ,EAClB,QAAQ,MAAM,EACd,MAAM,MAAM,EACZ,UAAS,UAAe,KACvB,OAAO,CAAC,YAAY,CAyFtB,CAAA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { isApiError } from '../types.js';
|
|
2
|
+
import { VIYA_TABLE } from './table.js';
|
|
3
|
+
import { VIYA_OVERLAY } from './overlay.js';
|
|
4
|
+
import { VIYA_HANDLERS } from './service.js';
|
|
5
|
+
import { emulatedHeaders } from './version.js';
|
|
6
|
+
const escape = (segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7
|
+
const compiled = VIYA_TABLE.filter((operation) => operation.path.includes('{}')).map((operation) => ({
|
|
8
|
+
operation,
|
|
9
|
+
pattern: new RegExp('^' +
|
|
10
|
+
operation.path
|
|
11
|
+
.split('/')
|
|
12
|
+
.map((segment) => (segment === '{}' ? '([^/]+)' : escape(segment)))
|
|
13
|
+
.join('/') +
|
|
14
|
+
'$',
|
|
15
|
+
// the static segments ignore case, as the hosts do
|
|
16
|
+
'i')
|
|
17
|
+
}));
|
|
18
|
+
const exact = new Map();
|
|
19
|
+
for (const operation of VIYA_TABLE)
|
|
20
|
+
if (!operation.path.includes('{}'))
|
|
21
|
+
// keyed in lower case, because the hosts are: express's `case sensitive
|
|
22
|
+
// routing` is off and the emulated estate has to match what they serve
|
|
23
|
+
exact.set(`${operation.method} ${operation.path}`.toLowerCase(), operation);
|
|
24
|
+
/** The operation a request names, ignoring case in the static segments. */
|
|
25
|
+
export const findViyaOperation = (method, path) => {
|
|
26
|
+
const verb = method.toUpperCase();
|
|
27
|
+
const clean = path.split('?')[0].replace(/\/+$/, '') || '/';
|
|
28
|
+
const staticHit = exact.get(`${verb} ${clean}`.toLowerCase());
|
|
29
|
+
if (staticHit)
|
|
30
|
+
return { operation: staticHit, segments: [] };
|
|
31
|
+
for (const candidate of compiled) {
|
|
32
|
+
if (candidate.operation.method !== verb)
|
|
33
|
+
continue;
|
|
34
|
+
const match = candidate.pattern.exec(clean);
|
|
35
|
+
if (match)
|
|
36
|
+
return {
|
|
37
|
+
operation: candidate.operation,
|
|
38
|
+
segments: match.slice(1).map((segment) => {
|
|
39
|
+
try {
|
|
40
|
+
return decodeURIComponent(segment);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return segment;
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Answer a Viya request.
|
|
52
|
+
*
|
|
53
|
+
* `request` is the same shape the SASjs dispatch takes, so a host that already
|
|
54
|
+
* resolves a caller - a session cookie - passes `subject` rather than a token.
|
|
55
|
+
*/
|
|
56
|
+
export const dispatchViya = async (services, method, path, request = {}) => {
|
|
57
|
+
const headers = emulatedHeaders();
|
|
58
|
+
const found = findViyaOperation(method, path);
|
|
59
|
+
if (!found)
|
|
60
|
+
return {
|
|
61
|
+
status: 404,
|
|
62
|
+
headers,
|
|
63
|
+
body: {
|
|
64
|
+
version: 2,
|
|
65
|
+
httpStatusCode: 404,
|
|
66
|
+
errorCode: 404,
|
|
67
|
+
message: `No operation is emulated at ${method.toUpperCase()} ${path}. The emulated estate answers the client's call surface and nothing else.`
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const entry = VIYA_OVERLAY[found.operation.id];
|
|
71
|
+
if (!entry)
|
|
72
|
+
// the overlay refuses to import unclassified rows, so reaching here is a
|
|
73
|
+
// change that bypassed that check
|
|
74
|
+
return {
|
|
75
|
+
status: 501,
|
|
76
|
+
headers,
|
|
77
|
+
body: { message: `${found.operation.id} has no decision in the overlay.` }
|
|
78
|
+
};
|
|
79
|
+
if (!entry.implemented)
|
|
80
|
+
return {
|
|
81
|
+
status: 501,
|
|
82
|
+
headers,
|
|
83
|
+
body: {
|
|
84
|
+
message: `${found.operation.id} is not emulated. ${entry.reason ?? ''}`.trim()
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const handler = VIYA_HANDLERS[found.operation.id];
|
|
88
|
+
if (!handler)
|
|
89
|
+
return {
|
|
90
|
+
status: 501,
|
|
91
|
+
headers,
|
|
92
|
+
body: {
|
|
93
|
+
message: `${found.operation.id} is marked implemented, but no handler answers it.`
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
const answer = await handler({
|
|
98
|
+
services,
|
|
99
|
+
request,
|
|
100
|
+
params: {
|
|
101
|
+
id: found.segments[0],
|
|
102
|
+
segments: found.segments
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
...answer,
|
|
107
|
+
// the emulated headers are spread LAST: they are the invariant this module
|
|
108
|
+
// exists to guarantee, so a handler cannot overwrite the stamp even by
|
|
109
|
+
// returning headers of its own
|
|
110
|
+
headers: { ...answer.headers, ...headers }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (isApiError(error))
|
|
115
|
+
return {
|
|
116
|
+
status: error.status,
|
|
117
|
+
headers,
|
|
118
|
+
body: error.body ?? {
|
|
119
|
+
version: 2,
|
|
120
|
+
httpStatusCode: error.status,
|
|
121
|
+
errorCode: error.status,
|
|
122
|
+
message: error.message
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
status: 500,
|
|
127
|
+
headers,
|
|
128
|
+
body: {
|
|
129
|
+
version: 2,
|
|
130
|
+
httpStatusCode: 500,
|
|
131
|
+
errorCode: 500,
|
|
132
|
+
message: String(error?.message ?? error)
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ViyaOverlayEntry {
|
|
2
|
+
implemented: boolean;
|
|
3
|
+
/** Present when declined: what a caller is told, and why. */
|
|
4
|
+
reason?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const VIYA_OVERLAY: Record<string, ViyaOverlayEntry>;
|
|
7
|
+
/**
|
|
8
|
+
* Refuse an overlay and a table that do not describe the same operations.
|
|
9
|
+
*
|
|
10
|
+
* Both directions, because each covers a different mistake:
|
|
11
|
+
*
|
|
12
|
+
* - an entry the table does not have is a claim about a call no client makes,
|
|
13
|
+
* which is what a stale entry becomes when an operation is retired;
|
|
14
|
+
* - a row with no entry is a capture that landed without a decision. One loop
|
|
15
|
+
* is not enough: a re-capture that adds an operation would import cleanly and
|
|
16
|
+
* answer 501 at run time, and `dispatch.ts` says the overlay refuses exactly
|
|
17
|
+
* that.
|
|
18
|
+
*
|
|
19
|
+
* Called at import, and exported so the refusals themselves can be tested: a
|
|
20
|
+
* check that only runs on import is a check nothing can pin.
|
|
21
|
+
*/
|
|
22
|
+
export declare const assertOverlayEntries: (overlay: Record<string, ViyaOverlayEntry>, operations?: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
}>) => void;
|
|
25
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/viya/overlay.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAsBD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CA8CzD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACzC,aAAY,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAc,KAC7C,IAcF,CAAA"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this package answers of the Viya table, and what it declines.
|
|
3
|
+
*
|
|
4
|
+
* `src/viya/table.ts` states what a capture observed. This file states the
|
|
5
|
+
* decision for each of those operations: a handler that answers it, or a reason
|
|
6
|
+
* that travels into the 501 body. Every row needs an entry, and importing this
|
|
7
|
+
* file throws if one is missing - the failure mode the route table already
|
|
8
|
+
* refuses, because a row with no decision reads exactly like a row that is about
|
|
9
|
+
* to be done.
|
|
10
|
+
*
|
|
11
|
+
* A declined row is not a TODO. The reason names what is missing, so a caller
|
|
12
|
+
* that reaches it learns why rather than that something is unimplemented.
|
|
13
|
+
*/
|
|
14
|
+
import { VIYA_TABLE } from './table.js';
|
|
15
|
+
/**
|
|
16
|
+
* The reason the session and file families carry.
|
|
17
|
+
*
|
|
18
|
+
* They need the session port and the file content routes, which this slice does
|
|
19
|
+
* not mount. Saying it once is better than saying it thirteen times in slightly
|
|
20
|
+
* different words.
|
|
21
|
+
*/
|
|
22
|
+
const NEEDS_RUNTIME = 'The emulated estate answers folders, identities and types today. This operation needs the session or file port, which the host mounting the emulator has not supplied.';
|
|
23
|
+
/**
|
|
24
|
+
* The token endpoint is the host's.
|
|
25
|
+
*
|
|
26
|
+
* A host that mounts the emulator owns the token port - it is the thing that
|
|
27
|
+
* issues what a client presents - so the emulator declines rather than inventing
|
|
28
|
+
* a second answer to the same question.
|
|
29
|
+
*/
|
|
30
|
+
const NEEDS_AUTH = 'The token endpoint is answered by the host that mounts the emulator, which owns the token port.';
|
|
31
|
+
export const VIYA_OVERLAY = {
|
|
32
|
+
// answered here
|
|
33
|
+
'POST /folders/folders': { implemented: true },
|
|
34
|
+
'GET /folders/folders/{}': { implemented: true },
|
|
35
|
+
'PATCH /folders/folders/{}': { implemented: true },
|
|
36
|
+
'GET /folders/folders/{}/members': { implemented: true },
|
|
37
|
+
'GET /folders/folders/@item': { implemented: true },
|
|
38
|
+
'GET /folders/folders/@myRecycleBin': { implemented: true },
|
|
39
|
+
'GET /identities/users/@currentUser': { implemented: true },
|
|
40
|
+
'GET /types/types': { implemented: true },
|
|
41
|
+
// declined: the session and file ports
|
|
42
|
+
'GET /compute/contexts': { implemented: false, reason: NEEDS_RUNTIME },
|
|
43
|
+
'POST /compute/contexts/{}/sessions': {
|
|
44
|
+
implemented: false,
|
|
45
|
+
reason: NEEDS_RUNTIME
|
|
46
|
+
},
|
|
47
|
+
'DELETE /compute/sessions/{}': { implemented: false, reason: NEEDS_RUNTIME },
|
|
48
|
+
'POST /compute/sessions/{}/jobs': {
|
|
49
|
+
implemented: false,
|
|
50
|
+
reason: NEEDS_RUNTIME
|
|
51
|
+
},
|
|
52
|
+
'GET /compute/sessions/{}/jobs/{}': {
|
|
53
|
+
implemented: false,
|
|
54
|
+
reason: NEEDS_RUNTIME
|
|
55
|
+
},
|
|
56
|
+
'GET /compute/sessions/{}/jobs/{}/log/content': {
|
|
57
|
+
implemented: false,
|
|
58
|
+
reason: NEEDS_RUNTIME
|
|
59
|
+
},
|
|
60
|
+
'GET /compute/sessions/{}/jobs/{}/state': {
|
|
61
|
+
implemented: false,
|
|
62
|
+
reason: NEEDS_RUNTIME
|
|
63
|
+
},
|
|
64
|
+
'GET /compute/sessions/{}/state': {
|
|
65
|
+
implemented: false,
|
|
66
|
+
reason: NEEDS_RUNTIME
|
|
67
|
+
},
|
|
68
|
+
'POST /files/files': { implemented: false, reason: NEEDS_RUNTIME },
|
|
69
|
+
'GET /files/files/{}': { implemented: false, reason: NEEDS_RUNTIME },
|
|
70
|
+
'PATCH /files/files/{}': { implemented: false, reason: NEEDS_RUNTIME },
|
|
71
|
+
'GET /files/files/{}/content': { implemented: false, reason: NEEDS_RUNTIME },
|
|
72
|
+
'PUT /files/files/{}/content': { implemented: false, reason: NEEDS_RUNTIME },
|
|
73
|
+
// declined: the host owns the token port
|
|
74
|
+
'POST /SASLogon/oauth/token': { implemented: false, reason: NEEDS_AUTH }
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Refuse an overlay and a table that do not describe the same operations.
|
|
78
|
+
*
|
|
79
|
+
* Both directions, because each covers a different mistake:
|
|
80
|
+
*
|
|
81
|
+
* - an entry the table does not have is a claim about a call no client makes,
|
|
82
|
+
* which is what a stale entry becomes when an operation is retired;
|
|
83
|
+
* - a row with no entry is a capture that landed without a decision. One loop
|
|
84
|
+
* is not enough: a re-capture that adds an operation would import cleanly and
|
|
85
|
+
* answer 501 at run time, and `dispatch.ts` says the overlay refuses exactly
|
|
86
|
+
* that.
|
|
87
|
+
*
|
|
88
|
+
* Called at import, and exported so the refusals themselves can be tested: a
|
|
89
|
+
* check that only runs on import is a check nothing can pin.
|
|
90
|
+
*/
|
|
91
|
+
export const assertOverlayEntries = (overlay, operations = VIYA_TABLE) => {
|
|
92
|
+
const known = new Set(operations.map((operation) => operation.id));
|
|
93
|
+
for (const id of Object.keys(overlay))
|
|
94
|
+
if (!known.has(id))
|
|
95
|
+
throw new Error(`src/viya/overlay.ts names an operation the table does not have: ${id}. The table is generated from a capture, so an entry for an operation nobody observed is a claim about a call no client makes.`);
|
|
96
|
+
for (const operation of operations)
|
|
97
|
+
if (!(operation.id in overlay))
|
|
98
|
+
throw new Error(`src/viya/overlay.ts has no decision for ${operation.id}. Every captured operation states whether this package implements it and, when it does not, the reason it does not: add \`{ implemented: false, reason: '...' }\` until a handler exists.`);
|
|
99
|
+
};
|
|
100
|
+
assertOverlayEntries(VIYA_OVERLAY);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Viya-shaped answers, built from the services the package already has.
|
|
3
|
+
*
|
|
4
|
+
* Each handler calls a port (`DriveService`, `IdentityService`) and returns the
|
|
5
|
+
* shape the capture recorded for that operation - the shape is in
|
|
6
|
+
* `src/viya/table.ts`, and the spec holds the two together. Nothing here
|
|
7
|
+
* re-implements a rule the SASjs API side already decides: a folder that does not
|
|
8
|
+
* exist is the drive's 404, and a path that climbs out of the root is the drive's
|
|
9
|
+
* refusal.
|
|
10
|
+
*
|
|
11
|
+
* Identifiers are derived from the path rather than minted, so the same folder is
|
|
12
|
+
* the same id on every host and every run. That is the seed rule applied to the
|
|
13
|
+
* one thing the emulator cannot invent per request: a client stores a folder id
|
|
14
|
+
* and asks for it later.
|
|
15
|
+
*/
|
|
16
|
+
import type { ApiResponse, Services } from '../host/dispatch.js';
|
|
17
|
+
/** The emulated clock: a fixed instant, so a body is reproducible. */
|
|
18
|
+
export declare const EMULATED_NOW = "2026-01-01T00:00:00.000Z";
|
|
19
|
+
/** The caller the emulated estate reports when a host does not name one. */
|
|
20
|
+
export declare const EMULATED_USER: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A uuid shape from a string, deterministically.
|
|
26
|
+
*
|
|
27
|
+
* Two 32-bit FNV-1a passes give enough of a hash to fill a uuid's fields, and the
|
|
28
|
+
* version/variant nibbles are set so the result is a well-formed v4-shaped id.
|
|
29
|
+
* Collisions are possible in principle and irrelevant here: the id is a handle
|
|
30
|
+
* the emulator hands back, not a uniqueness guarantee.
|
|
31
|
+
*/
|
|
32
|
+
export declare const idFor: (path: string, kind?: string) => string;
|
|
33
|
+
/** The handlers, keyed by the operation id the table states. */
|
|
34
|
+
export declare const VIYA_HANDLERS: Record<string, (context: {
|
|
35
|
+
services: Services;
|
|
36
|
+
request: {
|
|
37
|
+
query?: Record<string, string | undefined>;
|
|
38
|
+
body?: unknown;
|
|
39
|
+
token?: string;
|
|
40
|
+
subject?: unknown;
|
|
41
|
+
};
|
|
42
|
+
params: Record<string, string>;
|
|
43
|
+
}) => Promise<ApiResponse>>;
|
|
44
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/viya/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAIhE,sEAAsE;AACtE,eAAO,MAAM,YAAY,6BAA6B,CAAA;AAEtD,4EAA4E;AAC5E,eAAO,MAAM,aAAa;;;CAAiD,CAAA;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,aAAe,KAAG,MAyBrD,CAAA;AAsID,gEAAgE;AAChE,eAAO,MAAM,aAAa,EAAE,MAAM,CAChC,MAAM,EACN,CAAC,OAAO,EAAE;IACR,QAAQ,EAAE,QAAQ,CAAA;IAClB,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B,KAAK,OAAO,CAAC,WAAW,CAAC,CA4N3B,CAAA"}
|