@sasjs/api 0.39.0 → 0.40.1
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 +513 -234
- package/build/cjs/appstream/bundle.js +125 -54
- package/build/cjs/appstream/service.js +140 -65
- package/build/cjs/appstream/store.js +12 -5
- package/build/cjs/appstream/web.js +17 -4
- package/build/cjs/corpus/app.js +37 -0
- package/build/cjs/corpus/deploy.js +113 -0
- package/build/cjs/corpus/runner.js +1 -1
- package/build/cjs/host/dispatch.js +59 -11
- package/build/cjs/index.js +8 -2
- package/build/cjs/routes/generated.js +13 -1
- package/build/esm/appstream/bundle.d.ts +56 -12
- package/build/esm/appstream/bundle.d.ts.map +1 -1
- package/build/esm/appstream/bundle.js +124 -53
- package/build/esm/appstream/service.d.ts +51 -11
- package/build/esm/appstream/service.d.ts.map +1 -1
- package/build/esm/appstream/service.js +137 -64
- package/build/esm/appstream/store.d.ts.map +1 -1
- package/build/esm/appstream/store.js +12 -5
- package/build/esm/appstream/web.d.ts +11 -1
- package/build/esm/appstream/web.d.ts.map +1 -1
- package/build/esm/appstream/web.js +15 -3
- package/build/esm/corpus/app.d.ts.map +1 -1
- package/build/esm/corpus/app.js +37 -0
- package/build/esm/corpus/deploy.d.ts.map +1 -1
- package/build/esm/corpus/deploy.js +113 -0
- package/build/esm/corpus/drive.d.ts +9 -0
- package/build/esm/corpus/drive.d.ts.map +1 -1
- package/build/esm/corpus/runner.d.ts.map +1 -1
- package/build/esm/corpus/runner.js +1 -1
- package/build/esm/host/dispatch.d.ts.map +1 -1
- package/build/esm/host/dispatch.js +60 -12
- package/build/esm/index.d.ts +3 -3
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +3 -3
- package/build/esm/routes/generated.d.ts.map +1 -1
- package/build/esm/routes/generated.js +13 -1
- package/package.json +1 -1
package/build/cjs/corpus/app.js
CHANGED
|
@@ -3,6 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.APP_CORPUS = void 0;
|
|
4
4
|
const runner_js_1 = require("./runner.js");
|
|
5
5
|
const SUBJECT = { userId: 'user-admin', clientId: 'web_app' };
|
|
6
|
+
/**
|
|
7
|
+
* An app published as a frontend with no backend named.
|
|
8
|
+
*
|
|
9
|
+
* `streamWebFolder` is what tells the two shapes apart: an entry carrying it is
|
|
10
|
+
* served from `<appLoc>/services/<streamWebFolder>`, and every other entry from
|
|
11
|
+
* `apps/<name>`. `appLoc` is the backend a frontend calls, so it is absent here
|
|
12
|
+
* because this app calls none.
|
|
13
|
+
*/
|
|
14
|
+
const FRONTEND_APP = {
|
|
15
|
+
id: '9d8c7b6a-5f4e-4d3c-8b2a-1f0e9d8c7b6a',
|
|
16
|
+
name: 'frontend-only',
|
|
17
|
+
publishedAt: '2026-02-02T00:00:00.000Z'
|
|
18
|
+
};
|
|
19
|
+
/** Where that app's files are read from, which nothing on the entry records. */
|
|
20
|
+
const FRONTEND_ENTRY_FILE = `/apps/${FRONTEND_APP.name}/index.html`;
|
|
6
21
|
/** Where the app's streamed entry file sits inside its folder. */
|
|
7
22
|
const ENTRY_FILE_PATH = `${runner_js_1.CORPUS_APP.appLoc}/services/${runner_js_1.CORPUS_APP.streamWebFolder}/index.html`;
|
|
8
23
|
exports.APP_CORPUS = [
|
|
@@ -31,6 +46,28 @@ exports.APP_CORPUS = [
|
|
|
31
46
|
}
|
|
32
47
|
}
|
|
33
48
|
},
|
|
49
|
+
{
|
|
50
|
+
id: 'app-detail-frontend',
|
|
51
|
+
route: 'GET /SASjsApi/app/{id}',
|
|
52
|
+
description: 'describes an app published as a frontend, from the folder its name derives',
|
|
53
|
+
// the two shapes an index can hold, and the folder each is read from: this
|
|
54
|
+
// entry names no `appLoc` and no `streamWebFolder`, so the folder has to come
|
|
55
|
+
// from the name
|
|
56
|
+
appStream: [FRONTEND_APP],
|
|
57
|
+
seed: { [FRONTEND_ENTRY_FILE]: '<!doctype html><title>frontend</title>' },
|
|
58
|
+
request: { subject: SUBJECT, params: { id: FRONTEND_APP.id } },
|
|
59
|
+
expect: {
|
|
60
|
+
status: 200,
|
|
61
|
+
partial: {
|
|
62
|
+
id: FRONTEND_APP.id,
|
|
63
|
+
name: FRONTEND_APP.name,
|
|
64
|
+
frontendFolder: `/apps/${FRONTEND_APP.name}`,
|
|
65
|
+
entryFile: 'index.html',
|
|
66
|
+
entryFileExists: true,
|
|
67
|
+
url: `/app/${FRONTEND_APP.id}/`
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
34
71
|
{
|
|
35
72
|
id: 'app-detail-entry-file-missing',
|
|
36
73
|
route: 'GET /SASjsApi/app/{id}',
|
|
@@ -244,6 +244,119 @@ exports.DEPLOY_CORPUS = [
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
},
|
|
247
|
+
{
|
|
248
|
+
id: 'deploy-publishes-a-package',
|
|
249
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
250
|
+
description: 'publishes a frontend to apps/<name> and writes the backend it carries to appLoc',
|
|
251
|
+
request: {
|
|
252
|
+
subject: SUBJECT,
|
|
253
|
+
body: {
|
|
254
|
+
fileTree: {
|
|
255
|
+
members: [
|
|
256
|
+
{
|
|
257
|
+
name: 'sasjs.app.json',
|
|
258
|
+
type: 'file',
|
|
259
|
+
code: JSON.stringify({
|
|
260
|
+
name: 'macrodash',
|
|
261
|
+
appLoc: '/Public/app/md'
|
|
262
|
+
})
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'web',
|
|
266
|
+
type: 'folder',
|
|
267
|
+
members: [
|
|
268
|
+
{ name: 'index.html', type: 'file', code: '<h1>Dash</h1>' }
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: 'backend',
|
|
273
|
+
type: 'folder',
|
|
274
|
+
members: [
|
|
275
|
+
{
|
|
276
|
+
name: 'services',
|
|
277
|
+
type: 'folder',
|
|
278
|
+
members: [{ name: 'run', type: 'service', code: '%put hi;' }]
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
// the halves are named, so a host has to write them to two folders rather
|
|
287
|
+
// than deploy the container: a status alone cannot see that
|
|
288
|
+
expectDrive: {
|
|
289
|
+
present: ['/apps/macrodash/index.html', '/Public/app/md/services/run.sas']
|
|
290
|
+
},
|
|
291
|
+
expect: {
|
|
292
|
+
status: 200,
|
|
293
|
+
partial: {
|
|
294
|
+
status: 'success',
|
|
295
|
+
app: { name: 'macrodash' }
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: 'deploy-refuses-a-backend-with-no-apploc',
|
|
301
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
302
|
+
description: 'refuses a bundle carrying services that names no folder to deploy them to',
|
|
303
|
+
request: {
|
|
304
|
+
subject: SUBJECT,
|
|
305
|
+
body: {
|
|
306
|
+
fileTree: {
|
|
307
|
+
members: [
|
|
308
|
+
{
|
|
309
|
+
name: 'sasjs.app.json',
|
|
310
|
+
type: 'file',
|
|
311
|
+
code: JSON.stringify({ name: 'orphan-backend' })
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: 'web',
|
|
315
|
+
type: 'folder',
|
|
316
|
+
members: [
|
|
317
|
+
{ name: 'index.html', type: 'file', code: '<h1>orphan</h1>' }
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: 'backend',
|
|
322
|
+
type: 'folder',
|
|
323
|
+
members: [
|
|
324
|
+
{
|
|
325
|
+
name: 'services',
|
|
326
|
+
type: 'folder',
|
|
327
|
+
members: [{ name: 'run', type: 'service', code: '' }]
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
// both hosts refuse this the same way, and neither writes the frontend it
|
|
336
|
+
// could have deployed: half a deployment is worse than none
|
|
337
|
+
expectDrive: { missing: ['/apps/orphan-backend/index.html'] },
|
|
338
|
+
expect: {
|
|
339
|
+
status: 400,
|
|
340
|
+
error: 'This bundle carries a "backend" folder but names no "appLoc" for it: state the backend folder in sasjs.app.json, or in the request.'
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: 'deploy-refuses-a-bundle-that-names-no-folder',
|
|
345
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
346
|
+
description: 'refuses a tree with no app named and no folder to deploy to, naming the field',
|
|
347
|
+
request: {
|
|
348
|
+
subject: SUBJECT,
|
|
349
|
+
body: {
|
|
350
|
+
fileTree: {
|
|
351
|
+
members: [{ name: 'run', type: 'service', code: '%put hi;' }]
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
expect: {
|
|
356
|
+
status: 400,
|
|
357
|
+
error: '"appLoc" is required to deploy files that do not name an app.'
|
|
358
|
+
}
|
|
359
|
+
},
|
|
247
360
|
{
|
|
248
361
|
id: 'deploy-refuses-a-bad-manifest',
|
|
249
362
|
route: 'POST /SASjsApi/drive/deploy',
|
|
@@ -70,7 +70,7 @@ const servicesFor = (testCase) => {
|
|
|
70
70
|
directory: (0, service_js_9.createDirectoryService)(identity, directory_js_1.CORPUS_DIRECTORY),
|
|
71
71
|
identity: (0, service_js_3.createIdentityService)(identity),
|
|
72
72
|
records: (0, records_js_1.createRecordService)(identity),
|
|
73
|
-
appStream: (0, service_js_2.createAppStreamService)(new service_js_2.MemoryAppStreamStore([exports.CORPUS_APP])),
|
|
73
|
+
appStream: (0, service_js_2.createAppStreamService)(new service_js_2.MemoryAppStreamStore(testCase.appStream ?? [exports.CORPUS_APP])),
|
|
74
74
|
session: (0, service_js_4.createSessionService)(identity, runner),
|
|
75
75
|
// no `runTimes` option: the default is the five the document names, so a
|
|
76
76
|
// case is never refused for a reason that belongs to one host's install
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HANDLED_ROUTES = exports.noHandler = exports.dispatch = void 0;
|
|
4
4
|
const index_js_1 = require("../routes/index.js");
|
|
5
5
|
const service_js_1 = require("../appstream/service.js");
|
|
6
|
+
const web_js_1 = require("../appstream/web.js");
|
|
6
7
|
const bundle_js_1 = require("../appstream/bundle.js");
|
|
7
8
|
const types_js_1 = require("../types.js");
|
|
8
9
|
const deploy_js_1 = require("../drive/deploy.js");
|
|
@@ -313,10 +314,13 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
313
314
|
// expansion, which is why the two share this path rather than reading bytes.
|
|
314
315
|
case 'POST /SASjsApi/drive/deploy/upload':
|
|
315
316
|
case 'POST /SASjsApi/drive/deploy': {
|
|
316
|
-
// A bundle is one archive:
|
|
317
|
-
// statement that this
|
|
318
|
-
//
|
|
317
|
+
// A bundle is one archive: a deployment, and - when it carries one - the
|
|
318
|
+
// statement that this is an app. A current bundle names its halves, `web/`
|
|
319
|
+
// and `backend/`; the older shape is one tree with the web assets inside the
|
|
320
|
+
// backend's folder. The manifest is metadata either way, so it is taken out
|
|
321
|
+
// of the tree before anything is written.
|
|
319
322
|
const bundle = (0, bundle_js_1.splitAppBundle)(body.fileTree);
|
|
323
|
+
const packaged = bundle.frontend !== undefined;
|
|
320
324
|
const isUpload = routeId === 'POST /SASjsApi/drive/deploy/upload';
|
|
321
325
|
// The query is read on the upload route only: that is where the document
|
|
322
326
|
// states these, because the archive is the body. There the body is still the
|
|
@@ -324,20 +328,25 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
324
328
|
// JSON route the document states them in the body, and a stray `?appLoc=`
|
|
325
329
|
// beside a body that names one would silently deploy to another folder.
|
|
326
330
|
const setting = (name) => isUpload ? (given(query[name]) ?? body?.[name]) : body?.[name];
|
|
327
|
-
|
|
331
|
+
// a setting the caller omitted is ABSENT, not an empty string: `''` names no
|
|
332
|
+
// folder, and handing it on turns "not stated" into a refusal about how the
|
|
333
|
+
// folder is spelled
|
|
334
|
+
const statedAppLoc = given(setting('appLoc'));
|
|
335
|
+
const appLoc = typeof statedAppLoc === 'string' ? statedAppLoc : undefined;
|
|
328
336
|
const requested = services.appStream
|
|
329
337
|
? (0, bundle_js_1.publishRequestFor)({
|
|
338
|
+
name: given(setting('name')),
|
|
330
339
|
appLoc,
|
|
331
340
|
streamWebFolder: given(setting('streamWebFolder')),
|
|
332
341
|
streamServiceName: given(setting('streamServiceName')),
|
|
333
342
|
streamLogo: given(setting('streamLogo'))
|
|
334
|
-
}, bundle.manifest)
|
|
343
|
+
}, bundle.manifest, { packaged })
|
|
335
344
|
: undefined;
|
|
336
345
|
// the index's own checks run BEFORE the drive is written: a tree the index
|
|
337
346
|
// would refuse must not leave its files behind, which is what happened when
|
|
338
347
|
// the deploy came first - a request answered `400` had already deployed.
|
|
339
|
-
// The tree goes in, so a
|
|
340
|
-
//
|
|
348
|
+
// The tree goes in, so what a browser would open is judged: a package's
|
|
349
|
+
// frontend, or the whole tree of a legacy bundle.
|
|
341
350
|
// the folder the refusal should tell the caller to fix: the bundle's, when
|
|
342
351
|
// the request did not state one and the manifest did
|
|
343
352
|
const folderFromManifest = requested?.streamWebFolder !== undefined &&
|
|
@@ -345,11 +354,38 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
345
354
|
bundle.manifest?.streamWebFolder !== undefined;
|
|
346
355
|
const publish = requested === undefined
|
|
347
356
|
? undefined
|
|
348
|
-
: (0, service_js_1.checkPublishRequest)(requested, bundle.tree, { folderFromManifest });
|
|
357
|
+
: (0, service_js_1.checkPublishRequest)(requested, packaged ? bundle.frontend : bundle.tree, { folderFromManifest });
|
|
358
|
+
// a package has nowhere to go without an index: its frontend is `apps/<name>`,
|
|
359
|
+
// which only a published app has
|
|
360
|
+
if (packaged && publish === undefined)
|
|
361
|
+
throw new types_js_1.ApiError(501, `This host has no app stream, so it cannot publish the frontend this bundle carries.`);
|
|
362
|
+
if (publish !== undefined && publish.streamWebFolder === undefined) {
|
|
363
|
+
// a bundle that carries services has to say where they go: skipping the
|
|
364
|
+
// write would answer `200` for a deployment whose backend is missing, and
|
|
365
|
+
// the response is the only place a caller could have seen it
|
|
366
|
+
if (bundle.backend !== undefined && publish.appLoc === undefined)
|
|
367
|
+
throw new types_js_1.ApiError(400, 'This bundle carries a "backend" folder but names no "appLoc" for it: state the backend folder in sasjs.app.json, or in the request.');
|
|
368
|
+
// check, backend, frontend, index - the backend first so a frontend is
|
|
369
|
+
// never live against services that are not deployed yet, and additively
|
|
370
|
+
// because several frontends may name one backend
|
|
371
|
+
if (bundle.backend !== undefined)
|
|
372
|
+
await drive.deploy(publish.appLoc, bundle.backend, {
|
|
373
|
+
replace: false
|
|
374
|
+
});
|
|
375
|
+
// publishing a frontend means the folder is what this bundle says it is
|
|
376
|
+
await drive.deploy((0, service_js_1.frontendFolderOf)(publish.name), (packaged ? bundle.frontend : bundle.tree), { replace: true });
|
|
377
|
+
const entry = await services.appStream.publish(publish);
|
|
378
|
+
return {
|
|
379
|
+
status: 200,
|
|
380
|
+
body: { ...deploy_js_1.DEPLOY_SUCCESS, app: (0, service_js_1.appSummary)(entry) }
|
|
381
|
+
};
|
|
382
|
+
}
|
|
349
383
|
// an archive upload replaces by default - publishing a folder means the
|
|
350
384
|
// folder is what the archive says it is - while the JSON route writes over
|
|
351
385
|
// what is there unless it is told otherwise
|
|
352
386
|
const replace = replaceOf(setting('replace')) ?? isUpload;
|
|
387
|
+
if (appLoc === undefined)
|
|
388
|
+
throw new types_js_1.ApiError(400, '"appLoc" is required to deploy files that do not name an app.');
|
|
353
389
|
await drive.deploy(appLoc, bundle.tree, { replace });
|
|
354
390
|
// a deploy of something that is not an app writes files and says so; an app
|
|
355
391
|
// is indexed in the same request, so the two cannot disagree
|
|
@@ -387,7 +423,12 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
387
423
|
throw appNotRegistered();
|
|
388
424
|
throw err;
|
|
389
425
|
});
|
|
390
|
-
|
|
426
|
+
// the entry's own folder, whichever shape it was published in: `streamWebFolder`
|
|
427
|
+
// is the field that separates them - an entry carrying it is served from
|
|
428
|
+
// `<appLoc>/services/<streamWebFolder>`, every other entry from `apps/<name>` -
|
|
429
|
+
// so the folder is derived rather than reconstructed from fields an entry may
|
|
430
|
+
// not carry
|
|
431
|
+
const folder = (0, web_js_1.appRootOf)(entry);
|
|
391
432
|
// An index entry can outlive its deployment - the folder deleted from under
|
|
392
433
|
// the host - and reporting a file and a date that are not there would be worse
|
|
393
434
|
// than reporting none, so the listing decides both.
|
|
@@ -411,8 +452,15 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
411
452
|
const body = {
|
|
412
453
|
id: entry.id,
|
|
413
454
|
name: entry.name,
|
|
414
|
-
|
|
415
|
-
|
|
455
|
+
// the folder the entry is read from, which is what this route describes:
|
|
456
|
+
// `apps/<name>` for a frontend, and the legacy deployment's own folder for
|
|
457
|
+
// the older shape. A host that answered one and not the other would leave
|
|
458
|
+
// a client reading a path out of fields the entry may not carry.
|
|
459
|
+
frontendFolder: folder,
|
|
460
|
+
...(entry.appLoc === undefined ? {} : { appLoc: entry.appLoc }),
|
|
461
|
+
...(entry.streamWebFolder === undefined
|
|
462
|
+
? {}
|
|
463
|
+
: { streamWebFolder: entry.streamWebFolder }),
|
|
416
464
|
publishedAt: entry.publishedAt ?? null,
|
|
417
465
|
entryFile: APP_ENTRY_FILE,
|
|
418
466
|
entryFileExists,
|
package/build/cjs/index.js
CHANGED
|
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.BROWSER_INFO = exports.withBundleVersion = exports.createHomeService = exports.NO_WEB_BUILD = exports.BUNDLE_NAME = exports.HOME_CORPUS = exports.DIRECTORY_CORPUS = exports.AUTH_CONFIG_CORPUS = exports.ADMIN_CORPUS = exports.INFO_CORPUS = exports.CODE_CORPUS = exports.sanitiseDisplayName = exports.createRecordService = exports.createIdentityService = exports.HANDLED_ROUTES = exports.dispatch = exports.VIYA_CORPUS = exports.VIYA_HANDLERS = exports.VIYA_OVERLAY = exports.findViyaOperation = exports.dispatchViya = exports.emulatedHeaders = exports.VIYA_TARGET_VERSION = exports.VIYA_CAPTURED_AT = exports.EMULATED_HEADER_VALUE = exports.EMULATED_HEADER = exports.UNRECORDED = exports.VIYA_TABLE = exports.SURFACE_ADAPTER_VERSION = exports.SURFACE = exports.TAG_CAPABILITIES = exports.OVERLAY = exports.findRoute = exports.routeById = exports.ROUTES = exports.MemoryDriveStore = exports.measureDeployTree = exports.isDeployTree = exports.deployTree = exports.decodeBase64 = exports.checkDeployTree = exports.DEPLOY_SUCCESS = exports.DEPLOY_PAYLOAD_BYTES = exports.DEPLOY_LIMITS = exports.createDriveService = exports.isRoot = exports.basename = exports.dirname = exports.hasBlockedExtension = exports.normaliseDrivePath = void 0;
|
|
18
|
-
exports.
|
|
19
|
-
exports.normaliseAppLoc = exports.newAppId = exports.isAppId = exports.escapeHtml = exports.createAppStreamWebService = exports.contentTypeFor = exports.cacheControlFor = void 0;
|
|
18
|
+
exports.publishRequestFor = exports.parseAppManifest = exports.FRONTEND_FOLDER = exports.BACKEND_FOLDER = exports.APP_MANIFEST = exports.MemoryAppStreamStore = exports.hasFrontendRoot = exports.frontendFolderOf = exports.defaultAppName = exports.createAppStreamService = exports.checkPublishRequest = exports.appSummary = exports.APP_FOLDERS_ROOT = exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.runTimeOfPath = exports.resolveProgram = exports.programNotFound = exports.DOCUMENTED_RUN_TIMES = exports.createRuntimeService = exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.APP_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = exports.DEFAULT_IDENTITY = exports.MemoryIdentityStore = exports.createDirectoryService = exports.normaliseLogFiles = exports.normaliseDiagnostics = exports.logLines = exports.createAdminService = exports.checkLogFileName = exports.MAX_LOG_LINES = exports.DEFAULT_LOG_LINES = exports.normaliseAuthConfig = exports.createAuthConfigService = exports.normaliseInfo = exports.createInfoService = void 0;
|
|
19
|
+
exports.normaliseAppLoc = exports.newAppId = exports.isAppId = exports.escapeHtml = exports.createAppStreamWebService = exports.contentTypeFor = exports.cacheControlFor = exports.appRootOf = exports.NO_SUCH_APP = exports.DEFAULT_APP_PATH = exports.createDriveAppStreamStore = exports.APP_STREAM_INDEX = exports.splitAppBundle = void 0;
|
|
20
20
|
/**
|
|
21
21
|
* `@sasjs/api` - the SASjs Server API described once.
|
|
22
22
|
*
|
|
@@ -169,13 +169,18 @@ var runner_js_1 = require("./corpus/runner.js");
|
|
|
169
169
|
Object.defineProperty(exports, "runCase", { enumerable: true, get: function () { return runner_js_1.runCase; } });
|
|
170
170
|
Object.defineProperty(exports, "servicesFor", { enumerable: true, get: function () { return runner_js_1.servicesFor; } });
|
|
171
171
|
var service_js_11 = require("./appstream/service.js");
|
|
172
|
+
Object.defineProperty(exports, "APP_FOLDERS_ROOT", { enumerable: true, get: function () { return service_js_11.APP_FOLDERS_ROOT; } });
|
|
172
173
|
Object.defineProperty(exports, "appSummary", { enumerable: true, get: function () { return service_js_11.appSummary; } });
|
|
173
174
|
Object.defineProperty(exports, "checkPublishRequest", { enumerable: true, get: function () { return service_js_11.checkPublishRequest; } });
|
|
174
175
|
Object.defineProperty(exports, "createAppStreamService", { enumerable: true, get: function () { return service_js_11.createAppStreamService; } });
|
|
175
176
|
Object.defineProperty(exports, "defaultAppName", { enumerable: true, get: function () { return service_js_11.defaultAppName; } });
|
|
177
|
+
Object.defineProperty(exports, "frontendFolderOf", { enumerable: true, get: function () { return service_js_11.frontendFolderOf; } });
|
|
178
|
+
Object.defineProperty(exports, "hasFrontendRoot", { enumerable: true, get: function () { return service_js_11.hasFrontendRoot; } });
|
|
176
179
|
Object.defineProperty(exports, "MemoryAppStreamStore", { enumerable: true, get: function () { return service_js_11.MemoryAppStreamStore; } });
|
|
177
180
|
var bundle_js_1 = require("./appstream/bundle.js");
|
|
178
181
|
Object.defineProperty(exports, "APP_MANIFEST", { enumerable: true, get: function () { return bundle_js_1.APP_MANIFEST; } });
|
|
182
|
+
Object.defineProperty(exports, "BACKEND_FOLDER", { enumerable: true, get: function () { return bundle_js_1.BACKEND_FOLDER; } });
|
|
183
|
+
Object.defineProperty(exports, "FRONTEND_FOLDER", { enumerable: true, get: function () { return bundle_js_1.FRONTEND_FOLDER; } });
|
|
179
184
|
Object.defineProperty(exports, "parseAppManifest", { enumerable: true, get: function () { return bundle_js_1.parseAppManifest; } });
|
|
180
185
|
Object.defineProperty(exports, "publishRequestFor", { enumerable: true, get: function () { return bundle_js_1.publishRequestFor; } });
|
|
181
186
|
Object.defineProperty(exports, "splitAppBundle", { enumerable: true, get: function () { return bundle_js_1.splitAppBundle; } });
|
|
@@ -185,6 +190,7 @@ Object.defineProperty(exports, "createDriveAppStreamStore", { enumerable: true,
|
|
|
185
190
|
var web_js_1 = require("./appstream/web.js");
|
|
186
191
|
Object.defineProperty(exports, "DEFAULT_APP_PATH", { enumerable: true, get: function () { return web_js_1.DEFAULT_APP_PATH; } });
|
|
187
192
|
Object.defineProperty(exports, "NO_SUCH_APP", { enumerable: true, get: function () { return web_js_1.NO_SUCH_APP; } });
|
|
193
|
+
Object.defineProperty(exports, "appRootOf", { enumerable: true, get: function () { return web_js_1.appRootOf; } });
|
|
188
194
|
Object.defineProperty(exports, "cacheControlFor", { enumerable: true, get: function () { return web_js_1.cacheControlFor; } });
|
|
189
195
|
Object.defineProperty(exports, "contentTypeFor", { enumerable: true, get: function () { return web_js_1.contentTypeFor; } });
|
|
190
196
|
Object.defineProperty(exports, "createAppStreamWebService", { enumerable: true, get: function () { return web_js_1.createAppStreamWebService; } });
|
|
@@ -574,7 +574,13 @@ exports.GENERATED_ROUTES = [
|
|
|
574
574
|
{
|
|
575
575
|
name: 'appLoc',
|
|
576
576
|
in: 'body',
|
|
577
|
-
required:
|
|
577
|
+
required: false,
|
|
578
|
+
type: 'string'
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
name: 'name',
|
|
582
|
+
in: 'body',
|
|
583
|
+
required: false,
|
|
578
584
|
type: 'string'
|
|
579
585
|
},
|
|
580
586
|
{
|
|
@@ -635,6 +641,12 @@ exports.GENERATED_ROUTES = [
|
|
|
635
641
|
tag: 'Drive',
|
|
636
642
|
summary: 'Deploy an uploaded file to SASjs Drive',
|
|
637
643
|
params: [
|
|
644
|
+
{
|
|
645
|
+
name: 'name',
|
|
646
|
+
in: 'query',
|
|
647
|
+
required: false,
|
|
648
|
+
type: 'string'
|
|
649
|
+
},
|
|
638
650
|
{
|
|
639
651
|
name: 'appLoc',
|
|
640
652
|
in: 'query',
|
|
@@ -2,45 +2,89 @@ import type { DeployTree } from '../drive/deploy.js';
|
|
|
2
2
|
import type { PublishAppRequest } from './service.js';
|
|
3
3
|
/** The file, at the root of an app bundle, that says the bundle is an app. */
|
|
4
4
|
export declare const APP_MANIFEST = "sasjs.app.json";
|
|
5
|
+
/** The folder in a package holding the compiled frontend. */
|
|
6
|
+
export declare const FRONTEND_FOLDER = "web";
|
|
7
|
+
/** The folder in a package holding the services the frontend calls. */
|
|
8
|
+
export declare const BACKEND_FOLDER = "backend";
|
|
5
9
|
export interface AppManifest {
|
|
6
|
-
/** The
|
|
10
|
+
/** The app's name: its folder under `apps/`, and its address. */
|
|
7
11
|
name?: string;
|
|
8
|
-
/** The
|
|
9
|
-
|
|
12
|
+
/** The backend this frontend calls. Metadata, and optional. */
|
|
13
|
+
appLoc?: string;
|
|
14
|
+
/** Legacy only: the folder under `<appLoc>/services` holding the web assets. */
|
|
15
|
+
streamWebFolder?: string;
|
|
10
16
|
/** An asset inside the app, used as its tile image. */
|
|
11
17
|
logo?: string;
|
|
12
18
|
/** Origins allowed to frame the app, as CSP `frame-ancestors` sources. */
|
|
13
19
|
frameAncestors?: string | string[];
|
|
14
20
|
}
|
|
15
21
|
export interface AppBundle {
|
|
16
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The tree the bundle's body describes - what a legacy deploy writes to
|
|
24
|
+
* `appLoc`. When `frontend` is present this is the container of the two halves
|
|
25
|
+
* and is NOT deployed as it stands.
|
|
26
|
+
*/
|
|
17
27
|
tree: DeployTree;
|
|
28
|
+
/** The compiled frontend, when the bundle carries one at `web/`. */
|
|
29
|
+
frontend?: DeployTree;
|
|
30
|
+
/** The backend tree, when the bundle carries services at `backend/`. */
|
|
31
|
+
backend?: DeployTree;
|
|
18
32
|
manifest?: AppManifest;
|
|
19
33
|
}
|
|
20
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* A manifest, checked field by field, naming the field that is wrong.
|
|
36
|
+
*
|
|
37
|
+
* Nothing is required: a package states its name, a legacy bundle states its
|
|
38
|
+
* stream folder, and a deploy that states neither in the manifest states them in
|
|
39
|
+
* its payload. What the manifest states has to be usable, which is what is checked
|
|
40
|
+
* here; whether the request as a whole can publish is `checkPublishRequest`'s
|
|
41
|
+
* question, asked once against the request the two have been composed into.
|
|
42
|
+
*/
|
|
21
43
|
export declare const parseAppManifest: (value: unknown) => AppManifest;
|
|
22
44
|
/**
|
|
23
|
-
* The deploy tree split from its manifest.
|
|
45
|
+
* The deploy tree split from its manifest, and from the halves a package names.
|
|
24
46
|
*
|
|
25
47
|
* A tree that is not a tree is passed through untouched: the deploy is the thing
|
|
26
48
|
* that refuses a malformed tree, with the message its own cases pin, and saying
|
|
27
49
|
* it here as well would be two wordings of one refusal.
|
|
50
|
+
*
|
|
51
|
+
* A bundle is a package when it holds a `web/` folder or a manifest at its root.
|
|
52
|
+
* The frontend is then that folder's contents - which is why a compiled app is
|
|
53
|
+
* zipped as the folder's contents rather than the folder itself - and a `backend/`
|
|
54
|
+
* folder beside it is the tree to write to `appLoc`.
|
|
28
55
|
*/
|
|
29
56
|
export declare const splitAppBundle: (tree: unknown) => AppBundle;
|
|
30
57
|
/** What a deploy request says about the app it publishes. */
|
|
31
58
|
export interface DeployPublish {
|
|
32
|
-
|
|
59
|
+
/** The app's name, when the request states one. */
|
|
60
|
+
name?: string;
|
|
61
|
+
/** The backend folder. Metadata for a frontend publish. */
|
|
62
|
+
appLoc?: string;
|
|
63
|
+
/** Legacy: the folder under `<appLoc>/services` holding the web assets. */
|
|
33
64
|
streamWebFolder?: string;
|
|
65
|
+
/** The app's name, under the field name an older payload uses. */
|
|
34
66
|
streamServiceName?: string;
|
|
35
67
|
streamLogo?: string;
|
|
36
68
|
}
|
|
37
69
|
/**
|
|
38
70
|
* The publish a deploy asks for, or `undefined` when it publishes nothing.
|
|
39
71
|
*
|
|
40
|
-
* The request wins over the bundle where both speak - a caller naming a folder
|
|
41
|
-
* a label is correcting the archive, not repeating it - and the bundle
|
|
42
|
-
* the request leaves out
|
|
43
|
-
*
|
|
72
|
+
* The request wins over the bundle where both speak - a caller naming a folder, a
|
|
73
|
+
* name or a label is correcting the archive, not repeating it - and the bundle
|
|
74
|
+
* fills what the request leaves out.
|
|
75
|
+
*
|
|
76
|
+
* A bundle is published as a **legacy** app when either half states a
|
|
77
|
+
* `streamWebFolder`: that field is what puts the web assets inside the backend's
|
|
78
|
+
* folder, and a request that keeps it is asking for the shape it describes. A
|
|
79
|
+
* package publishes as a **frontend** instead, which needs only a name - the
|
|
80
|
+
* folder follows from it.
|
|
81
|
+
*
|
|
82
|
+
* `packaged` says the bundle carries a `web/` folder, so a request that names
|
|
83
|
+
* neither a stream folder nor a name is an app with nothing to call it: the
|
|
84
|
+
* request comes back without a name and `checkPublishRequest` refuses it by name,
|
|
85
|
+
* rather than the deploy writing the frontend nowhere.
|
|
44
86
|
*/
|
|
45
|
-
export declare const publishRequestFor: (deploy: DeployPublish, manifest?: AppManifest
|
|
87
|
+
export declare const publishRequestFor: (deploy: DeployPublish, manifest?: AppManifest, options?: {
|
|
88
|
+
packaged?: boolean;
|
|
89
|
+
}) => PublishAppRequest | undefined;
|
|
46
90
|
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/appstream/bundle.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/appstream/bundle.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,mBAAmB,CAAA;AAS5C,6DAA6D;AAC7D,eAAO,MAAM,eAAe,QAAQ,CAAA;AAEpC,uEAAuE;AACvE,eAAO,MAAM,cAAc,YAAY,CAAA;AAEvC,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CACnC;AAED,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,IAAI,EAAE,UAAU,CAAA;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAiBD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,KAAG,WA0CjD,CAAA;AAuBD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,OAAO,KAAG,SA0E9C,CAAA;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,aAAa,EACrB,WAAW,WAAW,EACtB,UAAS;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,KACnC,iBAAiB,GAAG,SAwBtB,CAAA"}
|