@sasjs/api 0.30.0 → 0.31.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 +534 -333
- package/build/cjs/corpus/app.js +55 -0
- package/build/cjs/corpus/runner.js +7 -6
- package/build/cjs/host/dispatch.js +71 -0
- package/build/cjs/index.js +9 -2
- package/build/cjs/routes/generated.js +34 -0
- package/build/cjs/routes/overlay.js +34 -1
- package/build/cjs/runtime/program.js +85 -0
- package/build/cjs/runtime/runTimes.js +13 -0
- package/build/cjs/runtime/service.js +11 -13
- package/build/esm/corpus/app.d.ts +17 -0
- package/build/esm/corpus/app.d.ts.map +1 -0
- package/build/esm/corpus/app.js +52 -0
- package/build/esm/corpus/runner.d.ts +13 -0
- package/build/esm/corpus/runner.d.ts.map +1 -1
- package/build/esm/corpus/runner.js +5 -4
- package/build/esm/host/dispatch.d.ts.map +1 -1
- package/build/esm/host/dispatch.js +72 -1
- package/build/esm/index.d.ts +5 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +4 -1
- package/build/esm/routes/generated.d.ts.map +1 -1
- package/build/esm/routes/generated.js +34 -0
- package/build/esm/routes/overlay.d.ts.map +1 -1
- package/build/esm/routes/overlay.js +34 -1
- package/build/esm/runtime/program.d.ts +56 -0
- package/build/esm/runtime/program.d.ts.map +1 -0
- package/build/esm/runtime/program.js +79 -0
- package/build/esm/runtime/runTimes.d.ts +11 -0
- package/build/esm/runtime/runTimes.d.ts.map +1 -0
- package/build/esm/runtime/runTimes.js +10 -0
- package/build/esm/runtime/service.d.ts +0 -2
- package/build/esm/runtime/service.d.ts.map +1 -1
- package/build/esm/runtime/service.js +9 -11
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { routeById } from '../routes/index.js';
|
|
2
2
|
import { appSummary, checkPublishRequest } from '../appstream/service.js';
|
|
3
3
|
import { publishRequestFor, splitAppBundle } from '../appstream/bundle.js';
|
|
4
|
-
import { ApiError } from '../types.js';
|
|
4
|
+
import { ApiError, isApiError } from '../types.js';
|
|
5
5
|
import { DEPLOY_SUCCESS } from '../drive/deploy.js';
|
|
6
6
|
/** The defaults sasjs/server's Client schema applies to an omitted lifetime. */
|
|
7
7
|
const SECONDS_IN_A_DAY = 86400;
|
|
@@ -68,6 +68,20 @@ const validate = (route, request) => {
|
|
|
68
68
|
throw new ApiError(400, `"${param.name}" is not allowed to be empty`);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
+
/** The file an app is served from for a directory request, as the surface serves it. */
|
|
72
|
+
const APP_ENTRY_FILE = 'index.html';
|
|
73
|
+
/**
|
|
74
|
+
* An app the index does not hold, in the wording the route answers with.
|
|
75
|
+
*
|
|
76
|
+
* The package's own message names the id ("No app is published with that id"); the
|
|
77
|
+
* route names the App Stream, and the corpus is what both hosts answer, so the
|
|
78
|
+
* wording is stated here rather than left to the service's.
|
|
79
|
+
*/
|
|
80
|
+
const APP_NOT_REGISTERED = 'No App Stream is registered with that id.';
|
|
81
|
+
const appNotRegistered = () => new ApiError(404, APP_NOT_REGISTERED, {
|
|
82
|
+
status: 'failure',
|
|
83
|
+
message: APP_NOT_REGISTERED
|
|
84
|
+
});
|
|
71
85
|
/** The drive path a write names: the query parameter wins over the form field. */
|
|
72
86
|
const targetPath = (request) => {
|
|
73
87
|
const fromQuery = request.query?._filePath;
|
|
@@ -354,6 +368,62 @@ export const dispatch = async (services, routeId, request = {}) => {
|
|
|
354
368
|
body: { status: 'success', app: appSummary(removed) }
|
|
355
369
|
};
|
|
356
370
|
}
|
|
371
|
+
// --------------------------------------------------- what an app *is*
|
|
372
|
+
//
|
|
373
|
+
// The surface serves an app's files; this describes the app itself - the entry
|
|
374
|
+
// as registered, and whether the file it is served from is there. Addressed by id,
|
|
375
|
+
// which is what a publish answers with and what the app's URL carries: a label is
|
|
376
|
+
// shared by design, so "the app with this name" is not one app.
|
|
377
|
+
case 'GET /SASjsApi/app/{id}': {
|
|
378
|
+
if (!services.appStream)
|
|
379
|
+
throw new ApiError(501, `This host has no app stream, so it cannot answer ${routeId}.`);
|
|
380
|
+
const entry = await services.appStream
|
|
381
|
+
.get(String(params.id ?? ''))
|
|
382
|
+
.catch((err) => {
|
|
383
|
+
if (isApiError(err) && err.status === 404)
|
|
384
|
+
throw appNotRegistered();
|
|
385
|
+
throw err;
|
|
386
|
+
});
|
|
387
|
+
const folder = `${entry.appLoc}/services/${entry.streamWebFolder}`;
|
|
388
|
+
// An index entry can outlive its deployment - the folder deleted from under
|
|
389
|
+
// the host - and reporting a file and a date that are not there would be worse
|
|
390
|
+
// than reporting none, so the listing decides both.
|
|
391
|
+
let entryFileExists = false;
|
|
392
|
+
let lastModified = null;
|
|
393
|
+
try {
|
|
394
|
+
const { tree } = await drive.tree(folder);
|
|
395
|
+
const file = tree.children.find((child) => child.name === APP_ENTRY_FILE && !child.isFolder);
|
|
396
|
+
entryFileExists = file !== undefined;
|
|
397
|
+
lastModified = file?.modified ?? null;
|
|
398
|
+
}
|
|
399
|
+
catch (err) {
|
|
400
|
+
// A folder that is gone is the ordinary case - an index entry that outlived
|
|
401
|
+
// its deployment - and the answer is "no entry file". Anything else is not
|
|
402
|
+
// that answer: a `streamWebFolder` that names a file, or a store that failed,
|
|
403
|
+
// would read as a deleted deployment, so it reaches the host's 500.
|
|
404
|
+
if (!isApiError(err) || err.status !== 404)
|
|
405
|
+
throw err;
|
|
406
|
+
entryFileExists = false;
|
|
407
|
+
}
|
|
408
|
+
const body = {
|
|
409
|
+
id: entry.id,
|
|
410
|
+
name: entry.name,
|
|
411
|
+
appLoc: entry.appLoc,
|
|
412
|
+
streamWebFolder: entry.streamWebFolder,
|
|
413
|
+
publishedAt: entry.publishedAt ?? null,
|
|
414
|
+
entryFile: APP_ENTRY_FILE,
|
|
415
|
+
entryFileExists,
|
|
416
|
+
lastModified,
|
|
417
|
+
url: `/app/${entry.id}/`
|
|
418
|
+
};
|
|
419
|
+
// the two the index may not carry are absent rather than undefined, which is
|
|
420
|
+
// how they reach a JSON client
|
|
421
|
+
if (entry.logo !== undefined)
|
|
422
|
+
body.logo = entry.logo;
|
|
423
|
+
if (entry.frameAncestors !== undefined)
|
|
424
|
+
body.frameAncestors = entry.frameAncestors;
|
|
425
|
+
return { status: 200, body };
|
|
426
|
+
}
|
|
357
427
|
case 'GET /SASjsApi/drive/filetree':
|
|
358
428
|
return { status: 200, body: await drive.tree(query._folderPath) };
|
|
359
429
|
// ------------------------------------------------------------- run times
|
|
@@ -663,6 +733,7 @@ export const HANDLED_ROUTES = [
|
|
|
663
733
|
'DELETE /SASjsApi/drive/folder',
|
|
664
734
|
'POST /SASjsApi/drive/rename',
|
|
665
735
|
'GET /SASjsApi/drive/filetree',
|
|
736
|
+
'GET /SASjsApi/app/{id}',
|
|
666
737
|
'POST /SASjsApi/drive/deploy',
|
|
667
738
|
'POST /SASjsApi/auth/token',
|
|
668
739
|
'POST /SASjsApi/auth/refresh',
|
package/build/esm/index.d.ts
CHANGED
|
@@ -54,12 +54,16 @@ export type { IdentityClient, IdentityClientRecord, IdentityGroupRecord, Identit
|
|
|
54
54
|
export { DRIVE_CORPUS } from './corpus/drive.js';
|
|
55
55
|
export { IDENTITY_CORPUS } from './corpus/identity.js';
|
|
56
56
|
export { DEPLOY_CORPUS } from './corpus/deploy.js';
|
|
57
|
+
export { APP_CORPUS } from './corpus/app.js';
|
|
57
58
|
export { SESSION_CORPUS } from './corpus/session.js';
|
|
58
59
|
export { createSessionService } from './session/service.js';
|
|
59
60
|
export type { CallerDirectory, HostSession, SessionArtifact, SessionHost, SessionService, SessionStateResponse, SessionStateValue, SessionSummary } from './session/service.js';
|
|
60
61
|
export { DEFAULT_SESSIONS, MemorySessionHost } from './session/memory-host.js';
|
|
61
|
-
export { CODE_DEBUG,
|
|
62
|
+
export { CODE_DEBUG, createRuntimeService } from './runtime/service.js';
|
|
63
|
+
export { DOCUMENTED_RUN_TIMES } from './runtime/runTimes.js';
|
|
62
64
|
export type { ProgramSource, RunOutcome, RunRequest, RunnerSession, RuntimeRequest, RuntimeService, RuntimeServiceOptions, SessionRunner, TriggerResponse } from './runtime/service.js';
|
|
65
|
+
export { programNotFound, resolveProgram, runTimeOfPath } from './runtime/program.js';
|
|
66
|
+
export type { ProgramDeps, ProgramResolution } from './runtime/program.js';
|
|
63
67
|
export { MemorySessionRunner } from './runtime/memory-runner.js';
|
|
64
68
|
export type { MemoryRunnerOptions } from './runtime/memory-runner.js';
|
|
65
69
|
export { RUNTIME_CORPUS } from './corpus/runtime.js';
|
package/build/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,cAAc,YAAY,CAAA;AAC1B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,OAAO,EACP,QAAQ,EACR,MAAM,EACP,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACX,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAChE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MA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,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACV,SAAS,EACT,WAAW,EACX,aAAa,EACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,UAAU,EACX,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA"}
|
package/build/esm/index.js
CHANGED
|
@@ -41,10 +41,13 @@ export { DEFAULT_IDENTITY, IDENTITY_FORMAT, parseIdentity } from './identity/fix
|
|
|
41
41
|
export { DRIVE_CORPUS } from './corpus/drive.js';
|
|
42
42
|
export { IDENTITY_CORPUS } from './corpus/identity.js';
|
|
43
43
|
export { DEPLOY_CORPUS } from './corpus/deploy.js';
|
|
44
|
+
export { APP_CORPUS } from './corpus/app.js';
|
|
44
45
|
export { SESSION_CORPUS } from './corpus/session.js';
|
|
45
46
|
export { createSessionService } from './session/service.js';
|
|
46
47
|
export { DEFAULT_SESSIONS, MemorySessionHost } from './session/memory-host.js';
|
|
47
|
-
export { CODE_DEBUG,
|
|
48
|
+
export { CODE_DEBUG, createRuntimeService } from './runtime/service.js';
|
|
49
|
+
export { DOCUMENTED_RUN_TIMES } from './runtime/runTimes.js';
|
|
50
|
+
export { programNotFound, resolveProgram, runTimeOfPath } from './runtime/program.js';
|
|
48
51
|
export { MemorySessionRunner } from './runtime/memory-runner.js';
|
|
49
52
|
export { RUNTIME_CORPUS } from './corpus/runtime.js';
|
|
50
53
|
export { RECORD_CORPUS, ADMIN_SIGNED_IN, PROVIDER_MANAGED } from './corpus/records.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../../src/routes/generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,gBAAgB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../../src/routes/generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAkmE5C,CAAA"}
|
|
@@ -104,6 +104,40 @@ export const GENERATED_ROUTES = [
|
|
|
104
104
|
}
|
|
105
105
|
]
|
|
106
106
|
},
|
|
107
|
+
{
|
|
108
|
+
id: 'GET /SASjsApi/app/{id}',
|
|
109
|
+
method: 'GET',
|
|
110
|
+
path: '/SASjsApi/app/{id}',
|
|
111
|
+
tag: 'App Stream',
|
|
112
|
+
summary: 'Get a published app by id',
|
|
113
|
+
params: [
|
|
114
|
+
{
|
|
115
|
+
name: 'id',
|
|
116
|
+
in: 'path',
|
|
117
|
+
required: true,
|
|
118
|
+
type: 'string'
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
requestBodies: [],
|
|
122
|
+
responses: [
|
|
123
|
+
{
|
|
124
|
+
status: 200,
|
|
125
|
+
description: 'Ok'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
status: 401,
|
|
129
|
+
description: 'Unauthorized'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
status: 404,
|
|
133
|
+
description: 'No App Stream is registered with that id.'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
status: 500,
|
|
137
|
+
description: 'Internal Server Error'
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
},
|
|
107
141
|
{
|
|
108
142
|
id: 'POST /SASjsApi/auth/logout',
|
|
109
143
|
method: 'POST',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/routes/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGzD,yDAAyD;AACzD,UAAU,aAAa;IACrB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAA;IAC3B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GACtC,CAAC;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElE,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/routes/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGzD,yDAAyD;AACzD,UAAU,aAAa;IACrB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAA;IAC3B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GACtC,CAAC;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElE,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAgBzD,CAAA;AAmBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAiWhD,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,OAAO,EAAE,UAAU,EAA8C,CAAA"}
|
|
@@ -13,7 +13,9 @@ export const TAG_CAPABILITIES = {
|
|
|
13
13
|
Group: ['identity'],
|
|
14
14
|
Permission: ['identity'],
|
|
15
15
|
Client: ['identity'],
|
|
16
|
-
Web: ['identity']
|
|
16
|
+
Web: ['identity'],
|
|
17
|
+
// an app's entry is indexed, and the file it is served from is read off the drive
|
|
18
|
+
'App Stream': ['storage']
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* Why a block of operations is not implemented here.
|
|
@@ -251,6 +253,37 @@ export const OVERLAY = {
|
|
|
251
253
|
// `404` is an id the index does not hold - the id is the app, and its label and
|
|
252
254
|
// folder are not handles - and the drive's content is deliberately left alone.
|
|
253
255
|
'DELETE /SASjsApi/drive/deploy': { implemented: true },
|
|
256
|
+
// App Stream - what is published under one app's id.
|
|
257
|
+
//
|
|
258
|
+
// Carried here: the answer is the app index plus the drive, and `APP_CORPUS` pins
|
|
259
|
+
// its shape. The mock build (`sasjs/cli`) still answers the App Stream surface by
|
|
260
|
+
// hand; consuming this operation from the table is its next step on
|
|
261
|
+
// sasjs/cli#1550, not this package's.
|
|
262
|
+
'GET /SASjsApi/app/{id}': {
|
|
263
|
+
implemented: true,
|
|
264
|
+
// the caller's token is the host's middleware, and a failure that is not the
|
|
265
|
+
// index refusing the id - a drive read that broke - is the host's to answer
|
|
266
|
+
hostResponses: [401, 500],
|
|
267
|
+
// the shape a client reads: the entry as registered, the file it is served from,
|
|
268
|
+
// and whether that file is there
|
|
269
|
+
responses: {
|
|
270
|
+
404: {
|
|
271
|
+
status: 'failure',
|
|
272
|
+
message: 'No App Stream is registered with that id.'
|
|
273
|
+
},
|
|
274
|
+
200: {
|
|
275
|
+
id: '',
|
|
276
|
+
name: '',
|
|
277
|
+
appLoc: '',
|
|
278
|
+
streamWebFolder: '',
|
|
279
|
+
publishedAt: null,
|
|
280
|
+
entryFile: 'index.html',
|
|
281
|
+
entryFileExists: false,
|
|
282
|
+
lastModified: null,
|
|
283
|
+
url: ''
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
},
|
|
254
287
|
// Group - members and the groups themselves
|
|
255
288
|
'GET /SASjsApi/group': { implemented: true },
|
|
256
289
|
'GET /SASjsApi/group/{uid}': { implemented: true },
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** The program the request named, and the run time its own name states. */
|
|
2
|
+
export interface ProgramResolution {
|
|
3
|
+
/** Where the program is, in the host's own addressing. */
|
|
4
|
+
path: string;
|
|
5
|
+
/** The run time the extension names, when it names one. */
|
|
6
|
+
runTime?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ProgramDeps {
|
|
9
|
+
/**
|
|
10
|
+
* The caller's path resolved against the host's drive, or `null` when it leaves it.
|
|
11
|
+
*
|
|
12
|
+
* A path that leaves the drive is refused the way a program that is not there is
|
|
13
|
+
* refused: saying "your path was rejected but existed" would say something about
|
|
14
|
+
* the host's filesystem.
|
|
15
|
+
*/
|
|
16
|
+
resolve: (given: string) => string | null;
|
|
17
|
+
/** Whether the host holds a file at that path. */
|
|
18
|
+
exists: (path: string) => Promise<boolean>;
|
|
19
|
+
/** The run times this host can offer, in the order it probes for one. */
|
|
20
|
+
runTimes: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The detail a refusal carries, naming the path the caller gave.
|
|
24
|
+
*
|
|
25
|
+
* Exported because the runtime service renders the same condition the same way, and
|
|
26
|
+
* two copies of the sentence is how the two drift: the service's envelope states it as
|
|
27
|
+
* `error`, and this module states it as the message a host sends when it does not
|
|
28
|
+
* render an envelope at all.
|
|
29
|
+
*/
|
|
30
|
+
export declare const programNotFound: (given: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* The run time a path's own name states, if it states one.
|
|
33
|
+
*
|
|
34
|
+
* The vocabulary is the document's (`DOCUMENTED_RUN_TIMES`), not a host's: a host
|
|
35
|
+
* that cannot run Python still reads `run.py` as Python and answers separately that
|
|
36
|
+
* it has no such run time. `run.sas7bdat` and `run.backup` name none, and are then
|
|
37
|
+
* probed like a path with no extension at all - which is what the server has always
|
|
38
|
+
* done.
|
|
39
|
+
*
|
|
40
|
+
* The extension is read below either separator, because the server runs on Windows
|
|
41
|
+
* too and resolves its paths with backslashes.
|
|
42
|
+
*/
|
|
43
|
+
export declare const runTimeOfPath: (path: string) => string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The program and run time a request's `_program` names.
|
|
46
|
+
*
|
|
47
|
+
* The refusal is decided here - `400`, and the detail that names the path the caller
|
|
48
|
+
* gave - and *rendered* by whoever called this, because that is where the two hosts
|
|
49
|
+
* already differ: this package's runtime routes wrap it in the failed-run envelope
|
|
50
|
+
* (`{ status, message, error }`, pinned in `spec/runtime.spec.ts`), and a host that
|
|
51
|
+
* sends the message as text keeps sending it as text. Deciding the rendering here
|
|
52
|
+
* would change one host's answer on the way to unifying the rule, which is not what
|
|
53
|
+
* the seam is for.
|
|
54
|
+
*/
|
|
55
|
+
export declare const resolveProgram: (given: string, deps: ProgramDeps) => Promise<ProgramResolution>;
|
|
56
|
+
//# sourceMappingURL=program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../src/runtime/program.ts"],"names":[],"mappings":"AAmBA,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IAEZ,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;IAEzC,kDAAkD;IAClD,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAE1C,yEAAyE;IACzE,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,KAAG,MACH,CAAA;AAK7C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAQrD,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,MAAM,EACb,MAAM,WAAW,KAChB,OAAO,CAAC,iBAAiB,CAqB3B,CAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding the program a request names, once, for every host.
|
|
3
|
+
*
|
|
4
|
+
* `_program` is a path the caller chose, so two things have to be decided the same
|
|
5
|
+
* way in every host that runs one: that the path stays inside the drive, and which
|
|
6
|
+
* file and run time it actually names. The first is the host's - only it knows where
|
|
7
|
+
* its drive starts - and the second is this module's, because "try the extension the
|
|
8
|
+
* name states, otherwise `<path>.<runTime>` for each runtime in turn, otherwise the
|
|
9
|
+
* program does not exist" is the API's rule and not a host's preference.
|
|
10
|
+
*
|
|
11
|
+
* The host supplies three things: how to resolve a caller's path against its drive
|
|
12
|
+
* (answering `null` for a path that leaves it), whether a resolved path exists, and
|
|
13
|
+
* the run times it can offer. The extension vocabulary is not one of them - that is
|
|
14
|
+
* the document's, and `runTimeOfPath` reads it here. Nothing here touches a filesystem, a drive or a clock,
|
|
15
|
+
* so the browser host can answer with the same function over its own store.
|
|
16
|
+
*/
|
|
17
|
+
import { ApiError } from '../types.js';
|
|
18
|
+
import { DOCUMENTED_RUN_TIMES } from './runTimes.js';
|
|
19
|
+
/**
|
|
20
|
+
* The detail a refusal carries, naming the path the caller gave.
|
|
21
|
+
*
|
|
22
|
+
* Exported because the runtime service renders the same condition the same way, and
|
|
23
|
+
* two copies of the sentence is how the two drift: the service's envelope states it as
|
|
24
|
+
* `error`, and this module states it as the message a host sends when it does not
|
|
25
|
+
* render an envelope at all.
|
|
26
|
+
*/
|
|
27
|
+
export const programNotFound = (given) => `The Program at (${given}) does not exist.`;
|
|
28
|
+
/** The refusal, as this module decides it: the status and that detail. */
|
|
29
|
+
const notThere = (given) => new ApiError(400, programNotFound(given));
|
|
30
|
+
/**
|
|
31
|
+
* The run time a path's own name states, if it states one.
|
|
32
|
+
*
|
|
33
|
+
* The vocabulary is the document's (`DOCUMENTED_RUN_TIMES`), not a host's: a host
|
|
34
|
+
* that cannot run Python still reads `run.py` as Python and answers separately that
|
|
35
|
+
* it has no such run time. `run.sas7bdat` and `run.backup` name none, and are then
|
|
36
|
+
* probed like a path with no extension at all - which is what the server has always
|
|
37
|
+
* done.
|
|
38
|
+
*
|
|
39
|
+
* The extension is read below either separator, because the server runs on Windows
|
|
40
|
+
* too and resolves its paths with backslashes.
|
|
41
|
+
*/
|
|
42
|
+
export const runTimeOfPath = (path) => {
|
|
43
|
+
const file = path.split(/[\\/]/).pop() || '';
|
|
44
|
+
const dot = file.lastIndexOf('.');
|
|
45
|
+
// a leading dot names no extension: `.sas` is a file, not a suffix
|
|
46
|
+
const extension = dot > 0 ? file.slice(dot + 1).toLowerCase() : '';
|
|
47
|
+
return DOCUMENTED_RUN_TIMES.includes(extension) ? extension : undefined;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The program and run time a request's `_program` names.
|
|
51
|
+
*
|
|
52
|
+
* The refusal is decided here - `400`, and the detail that names the path the caller
|
|
53
|
+
* gave - and *rendered* by whoever called this, because that is where the two hosts
|
|
54
|
+
* already differ: this package's runtime routes wrap it in the failed-run envelope
|
|
55
|
+
* (`{ status, message, error }`, pinned in `spec/runtime.spec.ts`), and a host that
|
|
56
|
+
* sends the message as text keeps sending it as text. Deciding the rendering here
|
|
57
|
+
* would change one host's answer on the way to unifying the rule, which is not what
|
|
58
|
+
* the seam is for.
|
|
59
|
+
*/
|
|
60
|
+
export const resolveProgram = async (given, deps) => {
|
|
61
|
+
const resolved = deps.resolve(given);
|
|
62
|
+
if (resolved === null)
|
|
63
|
+
throw notThere(given);
|
|
64
|
+
const extension = runTimeOfPath(resolved);
|
|
65
|
+
if (extension !== undefined) {
|
|
66
|
+
// the name states its run time: no probing, and a file that is not there is
|
|
67
|
+
// refused even if `<path>.sas` happens to exist
|
|
68
|
+
if (await deps.exists(resolved))
|
|
69
|
+
return { path: resolved, runTime: extension };
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
for (const runTime of deps.runTimes) {
|
|
73
|
+
const candidate = `${resolved}.${runTime}`;
|
|
74
|
+
if (await deps.exists(candidate))
|
|
75
|
+
return { path: candidate, runTime };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
throw notThere(given);
|
|
79
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run times the published document states.
|
|
3
|
+
*
|
|
4
|
+
* The vocabulary is the document's, not a host's: `_program=/app/run.py` names
|
|
5
|
+
* Python wherever it is read, and a host that cannot run Python says so when it is
|
|
6
|
+
* asked to - it does not get to say the name means something else. Kept in its own
|
|
7
|
+
* module so the runtime service and `resolveProgram` read one list rather than two
|
|
8
|
+
* copies of it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DOCUMENTED_RUN_TIMES: string[];
|
|
11
|
+
//# sourceMappingURL=runTimes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTimes.d.ts","sourceRoot":"","sources":["../../../src/runtime/runTimes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,UAAsC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run times the published document states.
|
|
3
|
+
*
|
|
4
|
+
* The vocabulary is the document's, not a host's: `_program=/app/run.py` names
|
|
5
|
+
* Python wherever it is read, and a host that cannot run Python says so when it is
|
|
6
|
+
* asked to - it does not get to say the name means something else. Kept in its own
|
|
7
|
+
* module so the runtime service and `resolveProgram` read one list rather than two
|
|
8
|
+
* copies of it.
|
|
9
|
+
*/
|
|
10
|
+
export const DOCUMENTED_RUN_TIMES = ['sas', 'js', 'py', 'r', 'sasviya'];
|
|
@@ -16,8 +16,6 @@ import type { CallerDirectory, SessionArtifact } from '../session/service.js';
|
|
|
16
16
|
* else.
|
|
17
17
|
*/
|
|
18
18
|
export declare const CODE_DEBUG = 131;
|
|
19
|
-
/** The run times the published document states, and a host may hold fewer. */
|
|
20
|
-
export declare const DOCUMENTED_RUN_TIMES: string[];
|
|
21
19
|
/**
|
|
22
20
|
* `_debug`, normalised the way sasjs/server's `parseDebugValue` normalises it.
|
|
23
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/runtime/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/runtime/service.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAG7E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,MAAM,CAAA;AAE7B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAUzD,CAAA;AAED;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AChB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,CAAA;IAC3C;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,OAAO,CACL,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAAA;IAC3B,uEAAuE;IACvE,OAAO,CACL,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,eAAe,CAAC,CAAA;CAC5B;AA0DD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,WAAW,eAAe,EAC1B,QAAQ,aAAa,EACrB,UAAS,qBAA0B,KAClC,cAqNF,CAAA"}
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* that would carry one carries it as optional.
|
|
17
17
|
*/
|
|
18
18
|
import { ApiError } from '../types.js';
|
|
19
|
+
import { DOCUMENTED_RUN_TIMES } from './runTimes.js';
|
|
20
|
+
import { programNotFound, runTimeOfPath } from './program.js';
|
|
19
21
|
import { normaliseDrivePath } from '../drive/paths.js';
|
|
20
22
|
/**
|
|
21
23
|
* The value that asks for the session log.
|
|
@@ -33,8 +35,6 @@ import { normaliseDrivePath } from '../drive/paths.js';
|
|
|
33
35
|
* else.
|
|
34
36
|
*/
|
|
35
37
|
export const CODE_DEBUG = 131;
|
|
36
|
-
/** The run times the published document states, and a host may hold fewer. */
|
|
37
|
-
export const DOCUMENTED_RUN_TIMES = ['sas', 'js', 'py', 'r', 'sasviya'];
|
|
38
38
|
/**
|
|
39
39
|
* `_debug`, normalised the way sasjs/server's `parseDebugValue` normalises it.
|
|
40
40
|
*
|
|
@@ -85,7 +85,9 @@ const timestamp = (now) => [
|
|
|
85
85
|
*/
|
|
86
86
|
const newSessionId = (now) => `${timestamp(now)}-${Math.round(Math.random() * 100000)}-${now.getTime()}`;
|
|
87
87
|
/** The refusal a program that cannot be found answers, as the server words it. */
|
|
88
|
-
|
|
88
|
+
// the wording is `resolveProgram`'s, so the module that decides the rule and the
|
|
89
|
+
// route that renders it cannot drift apart
|
|
90
|
+
const notThere = (programPath) => programNotFound(programPath);
|
|
89
91
|
/**
|
|
90
92
|
* The failure a run that could not be performed answers.
|
|
91
93
|
*
|
|
@@ -169,14 +171,10 @@ export const createRuntimeService = (directory, runner, options = {}) => {
|
|
|
169
171
|
* Only the extension vocabulary the document states is read, so `run.sas7bdat`
|
|
170
172
|
* or `run.backup` name no run time and are left to the host.
|
|
171
173
|
*/
|
|
172
|
-
const runTimeForPath = (path, request) =>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (DOCUMENTED_RUN_TIMES.includes(extension))
|
|
177
|
-
return extension;
|
|
178
|
-
return runTimeOf(request);
|
|
179
|
-
};
|
|
174
|
+
const runTimeForPath = (path, request) =>
|
|
175
|
+
// the extension rule is `resolveProgram`'s; this asks it and falls back to what
|
|
176
|
+
// the request stated, which is the part that is this route's
|
|
177
|
+
runTimeOfPath(path) ?? runTimeOf(request);
|
|
180
178
|
/** The run time, refused when it is absent where the document requires it, or unheld. */
|
|
181
179
|
const runTimeOf = (request) => {
|
|
182
180
|
if (request.runTime === undefined) {
|
package/package.json
CHANGED