@sasjs/api 0.26.0 → 0.27.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 +226 -10
- package/build/cjs/appstream/service.js +37 -3
- package/build/cjs/corpus/deploy.js +116 -0
- package/build/cjs/corpus/runner.js +27 -0
- package/build/cjs/host/dispatch.js +45 -7
- package/build/cjs/index.js +2 -1
- package/build/cjs/routes/generated.js +49 -1
- package/build/esm/appstream/service.d.ts +15 -1
- package/build/esm/appstream/service.d.ts.map +1 -1
- package/build/esm/appstream/service.js +35 -2
- package/build/esm/corpus/deploy.d.ts.map +1 -1
- package/build/esm/corpus/deploy.js +116 -0
- package/build/esm/corpus/drive.d.ts +13 -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 +27 -0
- package/build/esm/host/dispatch.d.ts.map +1 -1
- package/build/esm/host/dispatch.js +45 -7
- package/build/esm/index.d.ts +2 -2
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/routes/generated.d.ts.map +1 -1
- package/build/esm/routes/generated.js +49 -1
- package/package.json +1 -1
package/build/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @sasjs/api 0.
|
|
1
|
+
/* @sasjs/api 0.27.1 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
|
|
2
2
|
"use strict";
|
|
3
3
|
var SASjsApi = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -72,6 +72,7 @@ var SASjsApi = (() => {
|
|
|
72
72
|
cacheControlFor: () => cacheControlFor,
|
|
73
73
|
checkDeployTree: () => checkDeployTree,
|
|
74
74
|
checkLogFileName: () => checkLogFileName,
|
|
75
|
+
checkPublishRequest: () => checkPublishRequest,
|
|
75
76
|
contentTypeFor: () => contentTypeFor,
|
|
76
77
|
createAdminService: () => createAdminService,
|
|
77
78
|
createAppStreamService: () => createAppStreamService,
|
|
@@ -1125,7 +1126,7 @@ var SASjsApi = (() => {
|
|
|
1125
1126
|
method: "DELETE",
|
|
1126
1127
|
path: "/SASjsApi/drive/deploy",
|
|
1127
1128
|
tag: "Drive",
|
|
1128
|
-
summary: "Remove an app
|
|
1129
|
+
summary: "Remove an app",
|
|
1129
1130
|
params: [
|
|
1130
1131
|
{
|
|
1131
1132
|
name: "id",
|
|
@@ -1169,6 +1170,24 @@ var SASjsApi = (() => {
|
|
|
1169
1170
|
required: false,
|
|
1170
1171
|
type: "string"
|
|
1171
1172
|
},
|
|
1173
|
+
{
|
|
1174
|
+
name: "streamServiceName",
|
|
1175
|
+
in: "body",
|
|
1176
|
+
required: false,
|
|
1177
|
+
type: "string"
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
name: "streamLogo",
|
|
1181
|
+
in: "body",
|
|
1182
|
+
required: false,
|
|
1183
|
+
type: "string"
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
name: "replace",
|
|
1187
|
+
in: "body",
|
|
1188
|
+
required: false,
|
|
1189
|
+
type: "boolean"
|
|
1190
|
+
},
|
|
1172
1191
|
{
|
|
1173
1192
|
name: "fileTree",
|
|
1174
1193
|
in: "body",
|
|
@@ -1203,6 +1222,36 @@ var SASjsApi = (() => {
|
|
|
1203
1222
|
tag: "Drive",
|
|
1204
1223
|
summary: "Deploy an uploaded file to SASjs Drive",
|
|
1205
1224
|
params: [
|
|
1225
|
+
{
|
|
1226
|
+
name: "appLoc",
|
|
1227
|
+
in: "query",
|
|
1228
|
+
required: false,
|
|
1229
|
+
type: "string"
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
name: "streamWebFolder",
|
|
1233
|
+
in: "query",
|
|
1234
|
+
required: false,
|
|
1235
|
+
type: "string"
|
|
1236
|
+
},
|
|
1237
|
+
{
|
|
1238
|
+
name: "streamServiceName",
|
|
1239
|
+
in: "query",
|
|
1240
|
+
required: false,
|
|
1241
|
+
type: "string"
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
name: "streamLogo",
|
|
1245
|
+
in: "query",
|
|
1246
|
+
required: false,
|
|
1247
|
+
type: "string"
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
name: "replace",
|
|
1251
|
+
in: "query",
|
|
1252
|
+
required: false,
|
|
1253
|
+
type: "boolean"
|
|
1254
|
+
},
|
|
1206
1255
|
{
|
|
1207
1256
|
name: "file",
|
|
1208
1257
|
in: "formData",
|
|
@@ -3146,15 +3195,32 @@ var SASjsApi = (() => {
|
|
|
3146
3195
|
throw new ApiError(400, error.message);
|
|
3147
3196
|
}
|
|
3148
3197
|
};
|
|
3149
|
-
var
|
|
3198
|
+
var hasStreamFolder = (tree, streamWebFolder) => {
|
|
3199
|
+
const members = tree?.members;
|
|
3200
|
+
if (!Array.isArray(members)) return false;
|
|
3201
|
+
const isFolder = (member, name) => {
|
|
3202
|
+
const entry = member;
|
|
3203
|
+
return entry?.type === "folder" && entry?.name === name;
|
|
3204
|
+
};
|
|
3205
|
+
const services = members.find((member) => isFolder(member, "services"));
|
|
3206
|
+
const children = services?.members;
|
|
3207
|
+
return Array.isArray(children) && children.some((member) => isFolder(member, streamWebFolder));
|
|
3208
|
+
};
|
|
3209
|
+
var checkPublishRequest = (request, tree, options = {}) => {
|
|
3150
3210
|
const appLoc = appLocOf(request.appLoc);
|
|
3151
3211
|
if (appLoc === "/")
|
|
3152
3212
|
throw new ApiError(400, "An app cannot be published at the drive root.");
|
|
3153
3213
|
const logo = logoOf(request.logo);
|
|
3154
3214
|
const frameAncestors = frameAncestorsOf(request.frameAncestors);
|
|
3215
|
+
const streamWebFolder = webFolderOf(request.streamWebFolder);
|
|
3216
|
+
if (tree !== void 0 && !hasStreamFolder(tree, streamWebFolder))
|
|
3217
|
+
throw new ApiError(
|
|
3218
|
+
400,
|
|
3219
|
+
`The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest ? "correct the folder sasjs.app.json names." : "omit streamWebFolder."}`
|
|
3220
|
+
);
|
|
3155
3221
|
return {
|
|
3156
3222
|
appLoc,
|
|
3157
|
-
streamWebFolder
|
|
3223
|
+
streamWebFolder,
|
|
3158
3224
|
...request.name === void 0 ? {} : { name: nameOf(request.name, appLoc) },
|
|
3159
3225
|
...logo === void 0 ? {} : { logo },
|
|
3160
3226
|
...frameAncestors === void 0 ? {} : { frameAncestors },
|
|
@@ -3360,6 +3426,14 @@ var SASjsApi = (() => {
|
|
|
3360
3426
|
"POST /SASjsApi/code/trigger"
|
|
3361
3427
|
];
|
|
3362
3428
|
var given = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
3429
|
+
var replaceOf = (value) => {
|
|
3430
|
+
if (value === void 0 || value === "") return void 0;
|
|
3431
|
+
if (typeof value === "boolean") return value;
|
|
3432
|
+
const text2 = String(value).trim().toLowerCase();
|
|
3433
|
+
if (text2 === "true") return true;
|
|
3434
|
+
if (text2 === "false") return false;
|
|
3435
|
+
throw new ApiError(400, '"replace" must be true or false.');
|
|
3436
|
+
};
|
|
3363
3437
|
var validate = (route, request) => {
|
|
3364
3438
|
for (const param of route.params) {
|
|
3365
3439
|
if (!param.required || param.in === "formData" || param.in === "header")
|
|
@@ -3601,18 +3675,22 @@ var SASjsApi = (() => {
|
|
|
3601
3675
|
case "POST /SASjsApi/drive/deploy/upload":
|
|
3602
3676
|
case "POST /SASjsApi/drive/deploy": {
|
|
3603
3677
|
const bundle = splitAppBundle(body.fileTree);
|
|
3604
|
-
const
|
|
3678
|
+
const isUpload = routeId === "POST /SASjsApi/drive/deploy/upload";
|
|
3679
|
+
const setting = (name) => isUpload ? given(query[name]) ?? body?.[name] : body?.[name];
|
|
3680
|
+
const appLoc = String(setting("appLoc") ?? "");
|
|
3605
3681
|
const requested = services.appStream ? publishRequestFor(
|
|
3606
3682
|
{
|
|
3607
3683
|
appLoc,
|
|
3608
|
-
streamWebFolder: given(
|
|
3609
|
-
streamServiceName: given(
|
|
3610
|
-
streamLogo: given(
|
|
3684
|
+
streamWebFolder: given(setting("streamWebFolder")),
|
|
3685
|
+
streamServiceName: given(setting("streamServiceName")),
|
|
3686
|
+
streamLogo: given(setting("streamLogo"))
|
|
3611
3687
|
},
|
|
3612
3688
|
bundle.manifest
|
|
3613
3689
|
) : void 0;
|
|
3614
|
-
const
|
|
3615
|
-
|
|
3690
|
+
const folderFromManifest = requested?.streamWebFolder !== void 0 && given(setting("streamWebFolder")) === void 0 && bundle.manifest?.streamWebFolder !== void 0;
|
|
3691
|
+
const publish = requested === void 0 ? void 0 : checkPublishRequest(requested, bundle.tree, { folderFromManifest });
|
|
3692
|
+
const replace = replaceOf(setting("replace")) ?? isUpload;
|
|
3693
|
+
await drive.deploy(appLoc, bundle.tree, { replace });
|
|
3616
3694
|
if (publish === void 0 || !services.appStream)
|
|
3617
3695
|
return { status: 200, body: DEPLOY_SUCCESS };
|
|
3618
3696
|
const entry = await services.appStream.publish(publish);
|
|
@@ -6510,6 +6588,62 @@ var SASjsApi = (() => {
|
|
|
6510
6588
|
}
|
|
6511
6589
|
}
|
|
6512
6590
|
},
|
|
6591
|
+
{
|
|
6592
|
+
id: "upload-query-fields",
|
|
6593
|
+
route: "POST /SASjsApi/drive/deploy/upload",
|
|
6594
|
+
description: "takes the folder and the stream from the query, where the document states them",
|
|
6595
|
+
request: {
|
|
6596
|
+
subject: SUBJECT,
|
|
6597
|
+
query: { appLoc: "/Public/apps/from-query", streamWebFolder: "web" },
|
|
6598
|
+
body: {
|
|
6599
|
+
fileTree: {
|
|
6600
|
+
members: [
|
|
6601
|
+
{
|
|
6602
|
+
name: "services",
|
|
6603
|
+
type: "folder",
|
|
6604
|
+
members: [
|
|
6605
|
+
{
|
|
6606
|
+
name: "web",
|
|
6607
|
+
type: "folder",
|
|
6608
|
+
members: [
|
|
6609
|
+
{ name: "index.html", type: "file", code: "<h1>Hello</h1>" }
|
|
6610
|
+
]
|
|
6611
|
+
}
|
|
6612
|
+
]
|
|
6613
|
+
}
|
|
6614
|
+
]
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
},
|
|
6618
|
+
expect: {
|
|
6619
|
+
status: 200,
|
|
6620
|
+
partial: {
|
|
6621
|
+
status: "success",
|
|
6622
|
+
app: { name: "from-query" }
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
},
|
|
6626
|
+
{
|
|
6627
|
+
id: "deploy-refuses-a-tree-without-its-web-folder",
|
|
6628
|
+
route: "POST /SASjsApi/drive/deploy",
|
|
6629
|
+
description: "refuses a stream the tree does not carry, rather than indexing an app that would answer 404",
|
|
6630
|
+
request: {
|
|
6631
|
+
subject: SUBJECT,
|
|
6632
|
+
body: {
|
|
6633
|
+
appLoc: "/Public/apps/no-web",
|
|
6634
|
+
streamWebFolder: "web",
|
|
6635
|
+
fileTree: {
|
|
6636
|
+
members: [
|
|
6637
|
+
{ name: "index.html", type: "file", code: "<h1>Hello</h1>" }
|
|
6638
|
+
]
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6641
|
+
},
|
|
6642
|
+
expect: {
|
|
6643
|
+
status: 400,
|
|
6644
|
+
error: 'The deployed tree has no "services/web" folder, so nothing would be published at /Public/apps/no-web. Deploy the web assets under services/web, or omit streamWebFolder.'
|
|
6645
|
+
}
|
|
6646
|
+
},
|
|
6513
6647
|
{
|
|
6514
6648
|
id: "upload-text-file",
|
|
6515
6649
|
route: "POST /SASjsApi/drive/deploy/upload",
|
|
@@ -6655,6 +6789,66 @@ var SASjsApi = (() => {
|
|
|
6655
6789
|
body: { status: "failure", message: "Deployment failed!" },
|
|
6656
6790
|
error: "Deployment failed!"
|
|
6657
6791
|
}
|
|
6792
|
+
},
|
|
6793
|
+
{
|
|
6794
|
+
id: "upload-replaces-the-folder",
|
|
6795
|
+
route: "POST /SASjsApi/drive/deploy/upload",
|
|
6796
|
+
description: "an archive upload is the folder's whole contents, so a file it drops is gone",
|
|
6797
|
+
seed: {
|
|
6798
|
+
"/Public/apps/replaced/services/web/old.html": "<h1>old</h1>"
|
|
6799
|
+
},
|
|
6800
|
+
request: {
|
|
6801
|
+
subject: SUBJECT,
|
|
6802
|
+
query: { appLoc: "/Public/apps/replaced", streamWebFolder: "web" },
|
|
6803
|
+
body: {
|
|
6804
|
+
fileTree: {
|
|
6805
|
+
members: [
|
|
6806
|
+
{
|
|
6807
|
+
name: "services",
|
|
6808
|
+
type: "folder",
|
|
6809
|
+
members: [
|
|
6810
|
+
{
|
|
6811
|
+
name: "web",
|
|
6812
|
+
type: "folder",
|
|
6813
|
+
members: [
|
|
6814
|
+
{ name: "index.html", type: "file", code: "<h1>new</h1>" }
|
|
6815
|
+
]
|
|
6816
|
+
}
|
|
6817
|
+
]
|
|
6818
|
+
}
|
|
6819
|
+
]
|
|
6820
|
+
}
|
|
6821
|
+
}
|
|
6822
|
+
},
|
|
6823
|
+
expect: {
|
|
6824
|
+
status: 200,
|
|
6825
|
+
partial: { status: "success", app: { name: "replaced" } }
|
|
6826
|
+
},
|
|
6827
|
+
expectDrive: {
|
|
6828
|
+
present: ["/Public/apps/replaced/services/web/index.html"],
|
|
6829
|
+
missing: ["/Public/apps/replaced/services/web/old.html"]
|
|
6830
|
+
}
|
|
6831
|
+
},
|
|
6832
|
+
{
|
|
6833
|
+
id: "deploy-keeps-what-is-there",
|
|
6834
|
+
route: "POST /SASjsApi/drive/deploy",
|
|
6835
|
+
description: "the JSON route writes over what is there unless it is told to replace",
|
|
6836
|
+
seed: {
|
|
6837
|
+
"/Public/apps/kept/old.html": "<h1>old</h1>"
|
|
6838
|
+
},
|
|
6839
|
+
request: {
|
|
6840
|
+
subject: SUBJECT,
|
|
6841
|
+
body: {
|
|
6842
|
+
appLoc: "/Public/apps/kept",
|
|
6843
|
+
fileTree: {
|
|
6844
|
+
members: [{ name: "a.html", type: "file", code: "<h1>a</h1>" }]
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6847
|
+
},
|
|
6848
|
+
expect: { status: 200 },
|
|
6849
|
+
expectDrive: {
|
|
6850
|
+
present: ["/Public/apps/kept/a.html", "/Public/apps/kept/old.html"]
|
|
6851
|
+
}
|
|
6658
6852
|
}
|
|
6659
6853
|
];
|
|
6660
6854
|
|
|
@@ -8640,9 +8834,31 @@ var SASjsApi = (() => {
|
|
|
8640
8834
|
throw new Error("the store refused the write");
|
|
8641
8835
|
}
|
|
8642
8836
|
};
|
|
8837
|
+
var checkDrive = async (testCase, services) => {
|
|
8838
|
+
if (!testCase.expectDrive || !services.drive) return;
|
|
8839
|
+
const holds = async (path) => {
|
|
8840
|
+
try {
|
|
8841
|
+
await services.drive.read(path);
|
|
8842
|
+
return true;
|
|
8843
|
+
} catch (e) {
|
|
8844
|
+
return false;
|
|
8845
|
+
}
|
|
8846
|
+
};
|
|
8847
|
+
for (const path of testCase.expectDrive.present || [])
|
|
8848
|
+
if (!await holds(path))
|
|
8849
|
+
throw new Error(
|
|
8850
|
+
`${testCase.id}: expected a file at ${path}, and the drive has none`
|
|
8851
|
+
);
|
|
8852
|
+
for (const path of testCase.expectDrive.missing || [])
|
|
8853
|
+
if (await holds(path))
|
|
8854
|
+
throw new Error(
|
|
8855
|
+
`${testCase.id}: expected no file at ${path}, and the drive still holds one`
|
|
8856
|
+
);
|
|
8857
|
+
};
|
|
8643
8858
|
var runCase = async (testCase, services = servicesFor(testCase)) => {
|
|
8644
8859
|
try {
|
|
8645
8860
|
const response = await dispatch(services, testCase.route, testCase.request);
|
|
8861
|
+
await checkDrive(testCase, services);
|
|
8646
8862
|
return {
|
|
8647
8863
|
status: response.status,
|
|
8648
8864
|
body: response.body,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryAppStreamStore = exports.createAppStreamService = exports.checkPublishRequest = exports.defaultAppName = exports.appSummary = void 0;
|
|
3
|
+
exports.MemoryAppStreamStore = exports.createAppStreamService = exports.checkPublishRequest = exports.hasStreamFolder = exports.defaultAppName = exports.appSummary = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* The app index: what has been published, keyed by a UUID.
|
|
6
6
|
*
|
|
@@ -71,6 +71,28 @@ const appLocOf = (value) => {
|
|
|
71
71
|
throw new types_js_1.ApiError(400, error.message);
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Whether a deploy tree carries the folder an app is served from.
|
|
76
|
+
*
|
|
77
|
+
* An app is served out of `<appLoc>/services/<streamWebFolder>`, so a tree
|
|
78
|
+
* without that folder would be indexed and then answer `404` to every request -
|
|
79
|
+
* a tile that opens nothing, which is worse than a refusal that names the missing
|
|
80
|
+
* folder.
|
|
81
|
+
*/
|
|
82
|
+
const hasStreamFolder = (tree, streamWebFolder) => {
|
|
83
|
+
const members = tree?.members;
|
|
84
|
+
if (!Array.isArray(members))
|
|
85
|
+
return false;
|
|
86
|
+
const isFolder = (member, name) => {
|
|
87
|
+
const entry = member;
|
|
88
|
+
return entry?.type === 'folder' && entry?.name === name;
|
|
89
|
+
};
|
|
90
|
+
const services = members.find((member) => isFolder(member, 'services'));
|
|
91
|
+
const children = services?.members;
|
|
92
|
+
return (Array.isArray(children) &&
|
|
93
|
+
children.some((member) => isFolder(member, streamWebFolder)));
|
|
94
|
+
};
|
|
95
|
+
exports.hasStreamFolder = hasStreamFolder;
|
|
74
96
|
/**
|
|
75
97
|
* A publish request, checked and normalised, with no default applied.
|
|
76
98
|
*
|
|
@@ -78,8 +100,11 @@ const appLocOf = (value) => {
|
|
|
78
100
|
* deployment: the drive and the index are two writes, and a request the index
|
|
79
101
|
* would refuse must not leave the files behind. `name` is left absent when the
|
|
80
102
|
* caller did not state one, because a redeploy inherits the label it had.
|
|
103
|
+
*
|
|
104
|
+
* The tree is optional so that a caller holding only the request can still check
|
|
105
|
+
* it; when it is stated, the folder the app would be served from has to be in it.
|
|
81
106
|
*/
|
|
82
|
-
const checkPublishRequest = (request) => {
|
|
107
|
+
const checkPublishRequest = (request, tree, options = {}) => {
|
|
83
108
|
const appLoc = appLocOf(request.appLoc);
|
|
84
109
|
// the drive root is not a folder an app can live in: a deploy to `/` writes
|
|
85
110
|
// `//index.html`, which nothing can read, so it is refused rather than indexed
|
|
@@ -87,9 +112,18 @@ const checkPublishRequest = (request) => {
|
|
|
87
112
|
throw new types_js_1.ApiError(400, 'An app cannot be published at the drive root.');
|
|
88
113
|
const logo = logoOf(request.logo);
|
|
89
114
|
const frameAncestors = frameAncestorsOf(request.frameAncestors);
|
|
115
|
+
const streamWebFolder = webFolderOf(request.streamWebFolder);
|
|
116
|
+
// the tree has to carry the folder the app is served from, or the publish
|
|
117
|
+
// advertises an app whose every request is a `404`. The advice names the source
|
|
118
|
+
// of the folder: a caller whose bundle stated it cannot omit the field, and the
|
|
119
|
+
// bundle is the thing to correct.
|
|
120
|
+
if (tree !== undefined && !(0, exports.hasStreamFolder)(tree, streamWebFolder))
|
|
121
|
+
throw new types_js_1.ApiError(400, `The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest
|
|
122
|
+
? 'correct the folder sasjs.app.json names.'
|
|
123
|
+
: 'omit streamWebFolder.'}`);
|
|
90
124
|
return {
|
|
91
125
|
appLoc,
|
|
92
|
-
streamWebFolder
|
|
126
|
+
streamWebFolder,
|
|
93
127
|
...(request.name === undefined
|
|
94
128
|
? {}
|
|
95
129
|
: { name: nameOf(request.name, appLoc) }),
|
|
@@ -73,6 +73,62 @@ exports.DEPLOY_CORPUS = [
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
+
{
|
|
77
|
+
id: 'upload-query-fields',
|
|
78
|
+
route: 'POST /SASjsApi/drive/deploy/upload',
|
|
79
|
+
description: 'takes the folder and the stream from the query, where the document states them',
|
|
80
|
+
request: {
|
|
81
|
+
subject: SUBJECT,
|
|
82
|
+
query: { appLoc: '/Public/apps/from-query', streamWebFolder: 'web' },
|
|
83
|
+
body: {
|
|
84
|
+
fileTree: {
|
|
85
|
+
members: [
|
|
86
|
+
{
|
|
87
|
+
name: 'services',
|
|
88
|
+
type: 'folder',
|
|
89
|
+
members: [
|
|
90
|
+
{
|
|
91
|
+
name: 'web',
|
|
92
|
+
type: 'folder',
|
|
93
|
+
members: [
|
|
94
|
+
{ name: 'index.html', type: 'file', code: '<h1>Hello</h1>' }
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
expect: {
|
|
104
|
+
status: 200,
|
|
105
|
+
partial: {
|
|
106
|
+
status: 'success',
|
|
107
|
+
app: { name: 'from-query' }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'deploy-refuses-a-tree-without-its-web-folder',
|
|
113
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
114
|
+
description: 'refuses a stream the tree does not carry, rather than indexing an app that would answer 404',
|
|
115
|
+
request: {
|
|
116
|
+
subject: SUBJECT,
|
|
117
|
+
body: {
|
|
118
|
+
appLoc: '/Public/apps/no-web',
|
|
119
|
+
streamWebFolder: 'web',
|
|
120
|
+
fileTree: {
|
|
121
|
+
members: [
|
|
122
|
+
{ name: 'index.html', type: 'file', code: '<h1>Hello</h1>' }
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
expect: {
|
|
128
|
+
status: 400,
|
|
129
|
+
error: 'The deployed tree has no "services/web" folder, so nothing would be published at /Public/apps/no-web. Deploy the web assets under services/web, or omit streamWebFolder.'
|
|
130
|
+
}
|
|
131
|
+
},
|
|
76
132
|
{
|
|
77
133
|
id: 'upload-text-file',
|
|
78
134
|
route: 'POST /SASjsApi/drive/deploy/upload',
|
|
@@ -218,5 +274,65 @@ exports.DEPLOY_CORPUS = [
|
|
|
218
274
|
body: { status: 'failure', message: 'Deployment failed!' },
|
|
219
275
|
error: 'Deployment failed!'
|
|
220
276
|
}
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
id: 'upload-replaces-the-folder',
|
|
280
|
+
route: 'POST /SASjsApi/drive/deploy/upload',
|
|
281
|
+
description: "an archive upload is the folder's whole contents, so a file it drops is gone",
|
|
282
|
+
seed: {
|
|
283
|
+
'/Public/apps/replaced/services/web/old.html': '<h1>old</h1>'
|
|
284
|
+
},
|
|
285
|
+
request: {
|
|
286
|
+
subject: SUBJECT,
|
|
287
|
+
query: { appLoc: '/Public/apps/replaced', streamWebFolder: 'web' },
|
|
288
|
+
body: {
|
|
289
|
+
fileTree: {
|
|
290
|
+
members: [
|
|
291
|
+
{
|
|
292
|
+
name: 'services',
|
|
293
|
+
type: 'folder',
|
|
294
|
+
members: [
|
|
295
|
+
{
|
|
296
|
+
name: 'web',
|
|
297
|
+
type: 'folder',
|
|
298
|
+
members: [
|
|
299
|
+
{ name: 'index.html', type: 'file', code: '<h1>new</h1>' }
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
expect: {
|
|
309
|
+
status: 200,
|
|
310
|
+
partial: { status: 'success', app: { name: 'replaced' } }
|
|
311
|
+
},
|
|
312
|
+
expectDrive: {
|
|
313
|
+
present: ['/Public/apps/replaced/services/web/index.html'],
|
|
314
|
+
missing: ['/Public/apps/replaced/services/web/old.html']
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
id: 'deploy-keeps-what-is-there',
|
|
319
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
320
|
+
description: 'the JSON route writes over what is there unless it is told to replace',
|
|
321
|
+
seed: {
|
|
322
|
+
'/Public/apps/kept/old.html': '<h1>old</h1>'
|
|
323
|
+
},
|
|
324
|
+
request: {
|
|
325
|
+
subject: SUBJECT,
|
|
326
|
+
body: {
|
|
327
|
+
appLoc: '/Public/apps/kept',
|
|
328
|
+
fileTree: {
|
|
329
|
+
members: [{ name: 'a.html', type: 'file', code: '<h1>a</h1>' }]
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
expect: { status: 200 },
|
|
334
|
+
expectDrive: {
|
|
335
|
+
present: ['/Public/apps/kept/a.html', '/Public/apps/kept/old.html']
|
|
336
|
+
}
|
|
221
337
|
}
|
|
222
338
|
];
|
|
@@ -96,6 +96,32 @@ class RefusingDriveStore extends memory_store_js_1.MemoryDriveStore {
|
|
|
96
96
|
throw new Error('the store refused the write');
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The drive state a case says it leaves, checked where the case states it.
|
|
101
|
+
*
|
|
102
|
+
* Reported as a thrown error naming the case rather than as a status mismatch: a
|
|
103
|
+
* host that dropped the deploy option answers `200` and fails here, which is the
|
|
104
|
+
* only place the difference between "replaced" and "kept" can be seen.
|
|
105
|
+
*/
|
|
106
|
+
const checkDrive = async (testCase, services) => {
|
|
107
|
+
if (!testCase.expectDrive || !services.drive)
|
|
108
|
+
return;
|
|
109
|
+
const holds = async (path) => {
|
|
110
|
+
try {
|
|
111
|
+
await services.drive.read(path);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
for (const path of testCase.expectDrive.present || [])
|
|
119
|
+
if (!(await holds(path)))
|
|
120
|
+
throw new Error(`${testCase.id}: expected a file at ${path}, and the drive has none`);
|
|
121
|
+
for (const path of testCase.expectDrive.missing || [])
|
|
122
|
+
if (await holds(path))
|
|
123
|
+
throw new Error(`${testCase.id}: expected no file at ${path}, and the drive still holds one`);
|
|
124
|
+
};
|
|
99
125
|
/**
|
|
100
126
|
* Runs a corpus case against the drive the case seeds itself, or against
|
|
101
127
|
* services a caller supplies - that is how a host (or a failing store) is put
|
|
@@ -104,6 +130,7 @@ class RefusingDriveStore extends memory_store_js_1.MemoryDriveStore {
|
|
|
104
130
|
const runCase = async (testCase, services = (0, exports.servicesFor)(testCase)) => {
|
|
105
131
|
try {
|
|
106
132
|
const response = await (0, dispatch_js_1.dispatch)(services, testCase.route, testCase.request);
|
|
133
|
+
await checkDrive(testCase, services);
|
|
107
134
|
return {
|
|
108
135
|
status: response.status,
|
|
109
136
|
body: response.body,
|
|
@@ -26,6 +26,24 @@ const RUN_ROUTES = [
|
|
|
26
26
|
];
|
|
27
27
|
/** A payload value, when the caller actually stated one. */
|
|
28
28
|
const given = (value) => typeof value === 'string' && value !== '' ? value : undefined;
|
|
29
|
+
/**
|
|
30
|
+
* `replace`, as the two deploy routes state it: a query string on the upload
|
|
31
|
+
* route, a boolean in the JSON one. Anything else is refused rather than guessed
|
|
32
|
+
* at, because guessing "keep" when the caller said nothing would leave a dropped
|
|
33
|
+
* file being served.
|
|
34
|
+
*/
|
|
35
|
+
const replaceOf = (value) => {
|
|
36
|
+
if (value === undefined || value === '')
|
|
37
|
+
return undefined;
|
|
38
|
+
if (typeof value === 'boolean')
|
|
39
|
+
return value;
|
|
40
|
+
const text = String(value).trim().toLowerCase();
|
|
41
|
+
if (text === 'true')
|
|
42
|
+
return true;
|
|
43
|
+
if (text === 'false')
|
|
44
|
+
return false;
|
|
45
|
+
throw new types_js_1.ApiError(400, '"replace" must be true or false.');
|
|
46
|
+
};
|
|
29
47
|
/**
|
|
30
48
|
* The parameters the table marks required, checked before the handler runs.
|
|
31
49
|
*
|
|
@@ -285,20 +303,40 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
285
303
|
// statement that this folder is an app. The manifest is metadata, so it is
|
|
286
304
|
// taken out of the tree before anything is written.
|
|
287
305
|
const bundle = (0, bundle_js_1.splitAppBundle)(body.fileTree);
|
|
288
|
-
const
|
|
306
|
+
const isUpload = routeId === 'POST /SASjsApi/drive/deploy/upload';
|
|
307
|
+
// The query is read on the upload route only: that is where the document
|
|
308
|
+
// states these, because the archive is the body. There the body is still the
|
|
309
|
+
// fallback, for a host that expands the archive before it dispatches. On the
|
|
310
|
+
// JSON route the document states them in the body, and a stray `?appLoc=`
|
|
311
|
+
// beside a body that names one would silently deploy to another folder.
|
|
312
|
+
const setting = (name) => isUpload ? (given(query[name]) ?? body?.[name]) : body?.[name];
|
|
313
|
+
const appLoc = String(setting('appLoc') ?? '');
|
|
289
314
|
const requested = services.appStream
|
|
290
315
|
? (0, bundle_js_1.publishRequestFor)({
|
|
291
316
|
appLoc,
|
|
292
|
-
streamWebFolder: given(
|
|
293
|
-
streamServiceName: given(
|
|
294
|
-
streamLogo: given(
|
|
317
|
+
streamWebFolder: given(setting('streamWebFolder')),
|
|
318
|
+
streamServiceName: given(setting('streamServiceName')),
|
|
319
|
+
streamLogo: given(setting('streamLogo'))
|
|
295
320
|
}, bundle.manifest)
|
|
296
321
|
: undefined;
|
|
297
322
|
// the index's own checks run BEFORE the drive is written: a tree the index
|
|
298
323
|
// would refuse must not leave its files behind, which is what happened when
|
|
299
|
-
// the deploy came first - a request answered `400` had already deployed
|
|
300
|
-
|
|
301
|
-
|
|
324
|
+
// the deploy came first - a request answered `400` had already deployed.
|
|
325
|
+
// The tree goes in, so a tree without the folder the app would be served
|
|
326
|
+
// from is refused rather than indexed as an app that 404s.
|
|
327
|
+
// the folder the refusal should tell the caller to fix: the bundle's, when
|
|
328
|
+
// the request did not state one and the manifest did
|
|
329
|
+
const folderFromManifest = requested?.streamWebFolder !== undefined &&
|
|
330
|
+
given(setting('streamWebFolder')) === undefined &&
|
|
331
|
+
bundle.manifest?.streamWebFolder !== undefined;
|
|
332
|
+
const publish = requested === undefined
|
|
333
|
+
? undefined
|
|
334
|
+
: (0, service_js_1.checkPublishRequest)(requested, bundle.tree, { folderFromManifest });
|
|
335
|
+
// an archive upload replaces by default - publishing a folder means the
|
|
336
|
+
// folder is what the archive says it is - while the JSON route writes over
|
|
337
|
+
// what is there unless it is told otherwise
|
|
338
|
+
const replace = replaceOf(setting('replace')) ?? isUpload;
|
|
339
|
+
await drive.deploy(appLoc, bundle.tree, { replace });
|
|
302
340
|
// a deploy of something that is not an app writes files and says so; an app
|
|
303
341
|
// is indexed in the same request, so the two cannot disagree
|
|
304
342
|
if (publish === undefined || !services.appStream)
|
package/build/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
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 = 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.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.normaliseAppLoc = exports.newAppId = exports.isAppId = exports.escapeHtml = exports.createAppStreamWebService = exports.contentTypeFor = exports.cacheControlFor = exports.NO_SUCH_APP = exports.DEFAULT_APP_PATH = exports.createDriveAppStreamStore = exports.APP_STREAM_INDEX = exports.splitAppBundle = exports.publishRequestFor = exports.parseAppManifest = exports.APP_MANIFEST = exports.MemoryAppStreamStore = exports.defaultAppName = exports.createAppStreamService = exports.appSummary = exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.createRuntimeService = exports.DOCUMENTED_RUN_TIMES = exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = void 0;
|
|
18
|
+
exports.normaliseAppLoc = exports.newAppId = exports.isAppId = exports.escapeHtml = exports.createAppStreamWebService = exports.contentTypeFor = exports.cacheControlFor = exports.NO_SUCH_APP = exports.DEFAULT_APP_PATH = exports.createDriveAppStreamStore = exports.APP_STREAM_INDEX = exports.splitAppBundle = exports.publishRequestFor = exports.parseAppManifest = exports.APP_MANIFEST = exports.MemoryAppStreamStore = exports.defaultAppName = exports.createAppStreamService = exports.checkPublishRequest = exports.appSummary = exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.createRuntimeService = exports.DOCUMENTED_RUN_TIMES = exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = void 0;
|
|
19
19
|
/**
|
|
20
20
|
* `@sasjs/api` - the SASjs Server API described once.
|
|
21
21
|
*
|
|
@@ -138,6 +138,7 @@ Object.defineProperty(exports, "runCase", { enumerable: true, get: function () {
|
|
|
138
138
|
Object.defineProperty(exports, "servicesFor", { enumerable: true, get: function () { return runner_js_1.servicesFor; } });
|
|
139
139
|
var service_js_10 = require("./appstream/service.js");
|
|
140
140
|
Object.defineProperty(exports, "appSummary", { enumerable: true, get: function () { return service_js_10.appSummary; } });
|
|
141
|
+
Object.defineProperty(exports, "checkPublishRequest", { enumerable: true, get: function () { return service_js_10.checkPublishRequest; } });
|
|
141
142
|
Object.defineProperty(exports, "createAppStreamService", { enumerable: true, get: function () { return service_js_10.createAppStreamService; } });
|
|
142
143
|
Object.defineProperty(exports, "defaultAppName", { enumerable: true, get: function () { return service_js_10.defaultAppName; } });
|
|
143
144
|
Object.defineProperty(exports, "MemoryAppStreamStore", { enumerable: true, get: function () { return service_js_10.MemoryAppStreamStore; } });
|
|
@@ -505,7 +505,7 @@ exports.GENERATED_ROUTES = [
|
|
|
505
505
|
method: 'DELETE',
|
|
506
506
|
path: '/SASjsApi/drive/deploy',
|
|
507
507
|
tag: 'Drive',
|
|
508
|
-
summary: 'Remove an app
|
|
508
|
+
summary: 'Remove an app',
|
|
509
509
|
params: [
|
|
510
510
|
{
|
|
511
511
|
name: 'id',
|
|
@@ -549,6 +549,24 @@ exports.GENERATED_ROUTES = [
|
|
|
549
549
|
required: false,
|
|
550
550
|
type: 'string'
|
|
551
551
|
},
|
|
552
|
+
{
|
|
553
|
+
name: 'streamServiceName',
|
|
554
|
+
in: 'body',
|
|
555
|
+
required: false,
|
|
556
|
+
type: 'string'
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
name: 'streamLogo',
|
|
560
|
+
in: 'body',
|
|
561
|
+
required: false,
|
|
562
|
+
type: 'string'
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
name: 'replace',
|
|
566
|
+
in: 'body',
|
|
567
|
+
required: false,
|
|
568
|
+
type: 'boolean'
|
|
569
|
+
},
|
|
552
570
|
{
|
|
553
571
|
name: 'fileTree',
|
|
554
572
|
in: 'body',
|
|
@@ -583,6 +601,36 @@ exports.GENERATED_ROUTES = [
|
|
|
583
601
|
tag: 'Drive',
|
|
584
602
|
summary: 'Deploy an uploaded file to SASjs Drive',
|
|
585
603
|
params: [
|
|
604
|
+
{
|
|
605
|
+
name: 'appLoc',
|
|
606
|
+
in: 'query',
|
|
607
|
+
required: false,
|
|
608
|
+
type: 'string'
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
name: 'streamWebFolder',
|
|
612
|
+
in: 'query',
|
|
613
|
+
required: false,
|
|
614
|
+
type: 'string'
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
name: 'streamServiceName',
|
|
618
|
+
in: 'query',
|
|
619
|
+
required: false,
|
|
620
|
+
type: 'string'
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: 'streamLogo',
|
|
624
|
+
in: 'query',
|
|
625
|
+
required: false,
|
|
626
|
+
type: 'string'
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
name: 'replace',
|
|
630
|
+
in: 'query',
|
|
631
|
+
required: false,
|
|
632
|
+
type: 'boolean'
|
|
633
|
+
},
|
|
586
634
|
{
|
|
587
635
|
name: 'file',
|
|
588
636
|
in: 'formData',
|
|
@@ -68,6 +68,15 @@ export declare const defaultAppName: (appLoc: string) => string;
|
|
|
68
68
|
export interface CheckedPublish extends Omit<PublishAppRequest, 'frameAncestors'> {
|
|
69
69
|
frameAncestors?: string[];
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether a deploy tree carries the folder an app is served from.
|
|
73
|
+
*
|
|
74
|
+
* An app is served out of `<appLoc>/services/<streamWebFolder>`, so a tree
|
|
75
|
+
* without that folder would be indexed and then answer `404` to every request -
|
|
76
|
+
* a tile that opens nothing, which is worse than a refusal that names the missing
|
|
77
|
+
* folder.
|
|
78
|
+
*/
|
|
79
|
+
export declare const hasStreamFolder: (tree: unknown, streamWebFolder: string) => boolean;
|
|
71
80
|
/**
|
|
72
81
|
* A publish request, checked and normalised, with no default applied.
|
|
73
82
|
*
|
|
@@ -75,8 +84,13 @@ export interface CheckedPublish extends Omit<PublishAppRequest, 'frameAncestors'
|
|
|
75
84
|
* deployment: the drive and the index are two writes, and a request the index
|
|
76
85
|
* would refuse must not leave the files behind. `name` is left absent when the
|
|
77
86
|
* caller did not state one, because a redeploy inherits the label it had.
|
|
87
|
+
*
|
|
88
|
+
* The tree is optional so that a caller holding only the request can still check
|
|
89
|
+
* it; when it is stated, the folder the app would be served from has to be in it.
|
|
78
90
|
*/
|
|
79
|
-
export declare const checkPublishRequest: (request: PublishAppRequest
|
|
91
|
+
export declare const checkPublishRequest: (request: PublishAppRequest, tree?: unknown, options?: {
|
|
92
|
+
folderFromManifest?: boolean;
|
|
93
|
+
}) => CheckedPublish;
|
|
80
94
|
/**
|
|
81
95
|
* The index, over a store.
|
|
82
96
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/appstream/service.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,cAAc;IAC7B,oFAAoF;IACpF,EAAE,EAAE,MAAM,CAAA;IACV,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAA;IACZ,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,eAAe,EAAE,MAAM,CAAA;IACvB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;IACjC,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChD;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MA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
67
|
}
|
|
68
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Whether a deploy tree carries the folder an app is served from.
|
|
71
|
+
*
|
|
72
|
+
* An app is served out of `<appLoc>/services/<streamWebFolder>`, so a tree
|
|
73
|
+
* without that folder would be indexed and then answer `404` to every request -
|
|
74
|
+
* a tile that opens nothing, which is worse than a refusal that names the missing
|
|
75
|
+
* folder.
|
|
76
|
+
*/
|
|
77
|
+
export const hasStreamFolder = (tree, streamWebFolder) => {
|
|
78
|
+
const members = tree?.members;
|
|
79
|
+
if (!Array.isArray(members))
|
|
80
|
+
return false;
|
|
81
|
+
const isFolder = (member, name) => {
|
|
82
|
+
const entry = member;
|
|
83
|
+
return entry?.type === 'folder' && entry?.name === name;
|
|
84
|
+
};
|
|
85
|
+
const services = members.find((member) => isFolder(member, 'services'));
|
|
86
|
+
const children = services?.members;
|
|
87
|
+
return (Array.isArray(children) &&
|
|
88
|
+
children.some((member) => isFolder(member, streamWebFolder)));
|
|
89
|
+
};
|
|
69
90
|
/**
|
|
70
91
|
* A publish request, checked and normalised, with no default applied.
|
|
71
92
|
*
|
|
@@ -73,8 +94,11 @@ const appLocOf = (value) => {
|
|
|
73
94
|
* deployment: the drive and the index are two writes, and a request the index
|
|
74
95
|
* would refuse must not leave the files behind. `name` is left absent when the
|
|
75
96
|
* caller did not state one, because a redeploy inherits the label it had.
|
|
97
|
+
*
|
|
98
|
+
* The tree is optional so that a caller holding only the request can still check
|
|
99
|
+
* it; when it is stated, the folder the app would be served from has to be in it.
|
|
76
100
|
*/
|
|
77
|
-
export const checkPublishRequest = (request) => {
|
|
101
|
+
export const checkPublishRequest = (request, tree, options = {}) => {
|
|
78
102
|
const appLoc = appLocOf(request.appLoc);
|
|
79
103
|
// the drive root is not a folder an app can live in: a deploy to `/` writes
|
|
80
104
|
// `//index.html`, which nothing can read, so it is refused rather than indexed
|
|
@@ -82,9 +106,18 @@ export const checkPublishRequest = (request) => {
|
|
|
82
106
|
throw new ApiError(400, 'An app cannot be published at the drive root.');
|
|
83
107
|
const logo = logoOf(request.logo);
|
|
84
108
|
const frameAncestors = frameAncestorsOf(request.frameAncestors);
|
|
109
|
+
const streamWebFolder = webFolderOf(request.streamWebFolder);
|
|
110
|
+
// the tree has to carry the folder the app is served from, or the publish
|
|
111
|
+
// advertises an app whose every request is a `404`. The advice names the source
|
|
112
|
+
// of the folder: a caller whose bundle stated it cannot omit the field, and the
|
|
113
|
+
// bundle is the thing to correct.
|
|
114
|
+
if (tree !== undefined && !hasStreamFolder(tree, streamWebFolder))
|
|
115
|
+
throw new ApiError(400, `The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest
|
|
116
|
+
? 'correct the folder sasjs.app.json names.'
|
|
117
|
+
: 'omit streamWebFolder.'}`);
|
|
85
118
|
return {
|
|
86
119
|
appLoc,
|
|
87
|
-
streamWebFolder
|
|
120
|
+
streamWebFolder,
|
|
88
121
|
...(request.name === undefined
|
|
89
122
|
? {}
|
|
90
123
|
: { name: nameOf(request.name, appLoc) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/corpus/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAW5C,eAAO,MAAM,aAAa,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../src/corpus/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAW5C,eAAO,MAAM,aAAa,EAAE,UAAU,EAkVrC,CAAA"}
|
|
@@ -70,6 +70,62 @@ export const DEPLOY_CORPUS = [
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
+
{
|
|
74
|
+
id: 'upload-query-fields',
|
|
75
|
+
route: 'POST /SASjsApi/drive/deploy/upload',
|
|
76
|
+
description: 'takes the folder and the stream from the query, where the document states them',
|
|
77
|
+
request: {
|
|
78
|
+
subject: SUBJECT,
|
|
79
|
+
query: { appLoc: '/Public/apps/from-query', streamWebFolder: 'web' },
|
|
80
|
+
body: {
|
|
81
|
+
fileTree: {
|
|
82
|
+
members: [
|
|
83
|
+
{
|
|
84
|
+
name: 'services',
|
|
85
|
+
type: 'folder',
|
|
86
|
+
members: [
|
|
87
|
+
{
|
|
88
|
+
name: 'web',
|
|
89
|
+
type: 'folder',
|
|
90
|
+
members: [
|
|
91
|
+
{ name: 'index.html', type: 'file', code: '<h1>Hello</h1>' }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
expect: {
|
|
101
|
+
status: 200,
|
|
102
|
+
partial: {
|
|
103
|
+
status: 'success',
|
|
104
|
+
app: { name: 'from-query' }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'deploy-refuses-a-tree-without-its-web-folder',
|
|
110
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
111
|
+
description: 'refuses a stream the tree does not carry, rather than indexing an app that would answer 404',
|
|
112
|
+
request: {
|
|
113
|
+
subject: SUBJECT,
|
|
114
|
+
body: {
|
|
115
|
+
appLoc: '/Public/apps/no-web',
|
|
116
|
+
streamWebFolder: 'web',
|
|
117
|
+
fileTree: {
|
|
118
|
+
members: [
|
|
119
|
+
{ name: 'index.html', type: 'file', code: '<h1>Hello</h1>' }
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
expect: {
|
|
125
|
+
status: 400,
|
|
126
|
+
error: 'The deployed tree has no "services/web" folder, so nothing would be published at /Public/apps/no-web. Deploy the web assets under services/web, or omit streamWebFolder.'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
73
129
|
{
|
|
74
130
|
id: 'upload-text-file',
|
|
75
131
|
route: 'POST /SASjsApi/drive/deploy/upload',
|
|
@@ -215,5 +271,65 @@ export const DEPLOY_CORPUS = [
|
|
|
215
271
|
body: { status: 'failure', message: 'Deployment failed!' },
|
|
216
272
|
error: 'Deployment failed!'
|
|
217
273
|
}
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: 'upload-replaces-the-folder',
|
|
277
|
+
route: 'POST /SASjsApi/drive/deploy/upload',
|
|
278
|
+
description: "an archive upload is the folder's whole contents, so a file it drops is gone",
|
|
279
|
+
seed: {
|
|
280
|
+
'/Public/apps/replaced/services/web/old.html': '<h1>old</h1>'
|
|
281
|
+
},
|
|
282
|
+
request: {
|
|
283
|
+
subject: SUBJECT,
|
|
284
|
+
query: { appLoc: '/Public/apps/replaced', streamWebFolder: 'web' },
|
|
285
|
+
body: {
|
|
286
|
+
fileTree: {
|
|
287
|
+
members: [
|
|
288
|
+
{
|
|
289
|
+
name: 'services',
|
|
290
|
+
type: 'folder',
|
|
291
|
+
members: [
|
|
292
|
+
{
|
|
293
|
+
name: 'web',
|
|
294
|
+
type: 'folder',
|
|
295
|
+
members: [
|
|
296
|
+
{ name: 'index.html', type: 'file', code: '<h1>new</h1>' }
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
expect: {
|
|
306
|
+
status: 200,
|
|
307
|
+
partial: { status: 'success', app: { name: 'replaced' } }
|
|
308
|
+
},
|
|
309
|
+
expectDrive: {
|
|
310
|
+
present: ['/Public/apps/replaced/services/web/index.html'],
|
|
311
|
+
missing: ['/Public/apps/replaced/services/web/old.html']
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
id: 'deploy-keeps-what-is-there',
|
|
316
|
+
route: 'POST /SASjsApi/drive/deploy',
|
|
317
|
+
description: 'the JSON route writes over what is there unless it is told to replace',
|
|
318
|
+
seed: {
|
|
319
|
+
'/Public/apps/kept/old.html': '<h1>old</h1>'
|
|
320
|
+
},
|
|
321
|
+
request: {
|
|
322
|
+
subject: SUBJECT,
|
|
323
|
+
body: {
|
|
324
|
+
appLoc: '/Public/apps/kept',
|
|
325
|
+
fileTree: {
|
|
326
|
+
members: [{ name: 'a.html', type: 'file', code: '<h1>a</h1>' }]
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
expect: { status: 200 },
|
|
331
|
+
expectDrive: {
|
|
332
|
+
present: ['/Public/apps/kept/a.html', '/Public/apps/kept/old.html']
|
|
333
|
+
}
|
|
218
334
|
}
|
|
219
335
|
];
|
|
@@ -42,6 +42,19 @@ export interface CorpusCase {
|
|
|
42
42
|
};
|
|
43
43
|
/** The run fails, so a case can pin the `400` a failed run answers. */
|
|
44
44
|
failingRun?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The state the case leaves in the drive, where a status cannot see it.
|
|
47
|
+
*
|
|
48
|
+
* The deploy routes' `replace` policy is exactly that: both answers are `200`
|
|
49
|
+
* and the difference is a file the drive does or does not still hold, so a case
|
|
50
|
+
* that pinned only the status would let a host drop the option.
|
|
51
|
+
*/
|
|
52
|
+
expectDrive?: {
|
|
53
|
+
/** Files the drive must hold once the case has run. */
|
|
54
|
+
present?: string[];
|
|
55
|
+
/** Files it must not: the ones a replacement removes, or never writes. */
|
|
56
|
+
missing?: string[];
|
|
57
|
+
};
|
|
45
58
|
request: ApiRequest;
|
|
46
59
|
expect: {
|
|
47
60
|
status: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drive.d.ts","sourceRoot":"","sources":["../../../src/corpus/drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBA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;QACf;;;;;;;;;WASG;QACH,KAAK,CAAC,EAAE;YACN,QAAQ,EAAE,MAAM,EAAE,CAAA;YAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;SACpB,CAAA;QACD;;;;;;;WAOG;QACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAC3B,CAAA;CACF;AAmBD,eAAO,MAAM,YAAY,EAAE,UAAU,EAwapC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/corpus/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAsCnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,UAAU,KAAG,QA0ClD,CAAA;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/corpus/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAsCnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,UAAU,KAAG,QA0ClD,CAAA;AA8DD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAClB,UAAU,UAAU,EACpB,WAAU,QAAgC,KACzC,OAAO,CAAC,UAAU,CAgBpB,CAAA"}
|
|
@@ -92,6 +92,32 @@ class RefusingDriveStore extends MemoryDriveStore {
|
|
|
92
92
|
throw new Error('the store refused the write');
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The drive state a case says it leaves, checked where the case states it.
|
|
97
|
+
*
|
|
98
|
+
* Reported as a thrown error naming the case rather than as a status mismatch: a
|
|
99
|
+
* host that dropped the deploy option answers `200` and fails here, which is the
|
|
100
|
+
* only place the difference between "replaced" and "kept" can be seen.
|
|
101
|
+
*/
|
|
102
|
+
const checkDrive = async (testCase, services) => {
|
|
103
|
+
if (!testCase.expectDrive || !services.drive)
|
|
104
|
+
return;
|
|
105
|
+
const holds = async (path) => {
|
|
106
|
+
try {
|
|
107
|
+
await services.drive.read(path);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
for (const path of testCase.expectDrive.present || [])
|
|
115
|
+
if (!(await holds(path)))
|
|
116
|
+
throw new Error(`${testCase.id}: expected a file at ${path}, and the drive has none`);
|
|
117
|
+
for (const path of testCase.expectDrive.missing || [])
|
|
118
|
+
if (await holds(path))
|
|
119
|
+
throw new Error(`${testCase.id}: expected no file at ${path}, and the drive still holds one`);
|
|
120
|
+
};
|
|
95
121
|
/**
|
|
96
122
|
* Runs a corpus case against the drive the case seeds itself, or against
|
|
97
123
|
* services a caller supplies - that is how a host (or a failing store) is put
|
|
@@ -100,6 +126,7 @@ class RefusingDriveStore extends MemoryDriveStore {
|
|
|
100
126
|
export const runCase = async (testCase, services = servicesFor(testCase)) => {
|
|
101
127
|
try {
|
|
102
128
|
const response = await dispatch(services, testCase.route, testCase.request);
|
|
129
|
+
await checkDrive(testCase, services);
|
|
103
130
|
return {
|
|
104
131
|
status: response.status,
|
|
105
132
|
body: response.body,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/host/dispatch.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAuBtC,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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0D;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,EA8DlC,CAAA"}
|
|
@@ -23,6 +23,24 @@ const RUN_ROUTES = [
|
|
|
23
23
|
];
|
|
24
24
|
/** A payload value, when the caller actually stated one. */
|
|
25
25
|
const given = (value) => typeof value === 'string' && value !== '' ? value : undefined;
|
|
26
|
+
/**
|
|
27
|
+
* `replace`, as the two deploy routes state it: a query string on the upload
|
|
28
|
+
* route, a boolean in the JSON one. Anything else is refused rather than guessed
|
|
29
|
+
* at, because guessing "keep" when the caller said nothing would leave a dropped
|
|
30
|
+
* file being served.
|
|
31
|
+
*/
|
|
32
|
+
const replaceOf = (value) => {
|
|
33
|
+
if (value === undefined || value === '')
|
|
34
|
+
return undefined;
|
|
35
|
+
if (typeof value === 'boolean')
|
|
36
|
+
return value;
|
|
37
|
+
const text = String(value).trim().toLowerCase();
|
|
38
|
+
if (text === 'true')
|
|
39
|
+
return true;
|
|
40
|
+
if (text === 'false')
|
|
41
|
+
return false;
|
|
42
|
+
throw new ApiError(400, '"replace" must be true or false.');
|
|
43
|
+
};
|
|
26
44
|
/**
|
|
27
45
|
* The parameters the table marks required, checked before the handler runs.
|
|
28
46
|
*
|
|
@@ -282,20 +300,40 @@ export const dispatch = async (services, routeId, request = {}) => {
|
|
|
282
300
|
// statement that this folder is an app. The manifest is metadata, so it is
|
|
283
301
|
// taken out of the tree before anything is written.
|
|
284
302
|
const bundle = splitAppBundle(body.fileTree);
|
|
285
|
-
const
|
|
303
|
+
const isUpload = routeId === 'POST /SASjsApi/drive/deploy/upload';
|
|
304
|
+
// The query is read on the upload route only: that is where the document
|
|
305
|
+
// states these, because the archive is the body. There the body is still the
|
|
306
|
+
// fallback, for a host that expands the archive before it dispatches. On the
|
|
307
|
+
// JSON route the document states them in the body, and a stray `?appLoc=`
|
|
308
|
+
// beside a body that names one would silently deploy to another folder.
|
|
309
|
+
const setting = (name) => isUpload ? (given(query[name]) ?? body?.[name]) : body?.[name];
|
|
310
|
+
const appLoc = String(setting('appLoc') ?? '');
|
|
286
311
|
const requested = services.appStream
|
|
287
312
|
? publishRequestFor({
|
|
288
313
|
appLoc,
|
|
289
|
-
streamWebFolder: given(
|
|
290
|
-
streamServiceName: given(
|
|
291
|
-
streamLogo: given(
|
|
314
|
+
streamWebFolder: given(setting('streamWebFolder')),
|
|
315
|
+
streamServiceName: given(setting('streamServiceName')),
|
|
316
|
+
streamLogo: given(setting('streamLogo'))
|
|
292
317
|
}, bundle.manifest)
|
|
293
318
|
: undefined;
|
|
294
319
|
// the index's own checks run BEFORE the drive is written: a tree the index
|
|
295
320
|
// would refuse must not leave its files behind, which is what happened when
|
|
296
|
-
// the deploy came first - a request answered `400` had already deployed
|
|
297
|
-
|
|
298
|
-
|
|
321
|
+
// the deploy came first - a request answered `400` had already deployed.
|
|
322
|
+
// The tree goes in, so a tree without the folder the app would be served
|
|
323
|
+
// from is refused rather than indexed as an app that 404s.
|
|
324
|
+
// the folder the refusal should tell the caller to fix: the bundle's, when
|
|
325
|
+
// the request did not state one and the manifest did
|
|
326
|
+
const folderFromManifest = requested?.streamWebFolder !== undefined &&
|
|
327
|
+
given(setting('streamWebFolder')) === undefined &&
|
|
328
|
+
bundle.manifest?.streamWebFolder !== undefined;
|
|
329
|
+
const publish = requested === undefined
|
|
330
|
+
? undefined
|
|
331
|
+
: checkPublishRequest(requested, bundle.tree, { folderFromManifest });
|
|
332
|
+
// an archive upload replaces by default - publishing a folder means the
|
|
333
|
+
// folder is what the archive says it is - while the JSON route writes over
|
|
334
|
+
// what is there unless it is told otherwise
|
|
335
|
+
const replace = replaceOf(setting('replace')) ?? isUpload;
|
|
336
|
+
await drive.deploy(appLoc, bundle.tree, { replace });
|
|
299
337
|
// a deploy of something that is not an app writes files and says so; an app
|
|
300
338
|
// is indexed in the same request, so the two cannot disagree
|
|
301
339
|
if (publish === undefined || !services.appStream)
|
package/build/esm/index.d.ts
CHANGED
|
@@ -67,8 +67,8 @@ export { RECORD_CORPUS, ADMIN_SIGNED_IN, PROVIDER_MANAGED } from './corpus/recor
|
|
|
67
67
|
export type { CorpusCase } from './corpus/drive.js';
|
|
68
68
|
export { runCase, servicesFor } from './corpus/runner.js';
|
|
69
69
|
export type { CaseResult } from './corpus/runner.js';
|
|
70
|
-
export { appSummary, createAppStreamService, defaultAppName, MemoryAppStreamStore } from './appstream/service.js';
|
|
71
|
-
export type { AppStreamEntry, AppStreamService, AppStreamStore, PublishAppRequest } from './appstream/service.js';
|
|
70
|
+
export { appSummary, checkPublishRequest, createAppStreamService, defaultAppName, MemoryAppStreamStore } from './appstream/service.js';
|
|
71
|
+
export type { AppStreamEntry, AppStreamService, AppStreamStore, CheckedPublish, PublishAppRequest } from './appstream/service.js';
|
|
72
72
|
export { APP_MANIFEST, parseAppManifest, publishRequestFor, splitAppBundle } from './appstream/bundle.js';
|
|
73
73
|
export type { AppBundle, AppManifest, DeployPublish } from './appstream/bundle.js';
|
|
74
74
|
export { APP_STREAM_INDEX, createDriveAppStreamStore } from './appstream/store.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,EAC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ACtB,cAAc,EACd,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAClB,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"}
|
|
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,YAA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mB,EACnB,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,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
|
@@ -49,7 +49,7 @@ export { MemorySessionRunner } from './runtime/memory-runner.js';
|
|
|
49
49
|
export { RUNTIME_CORPUS } from './corpus/runtime.js';
|
|
50
50
|
export { RECORD_CORPUS, ADMIN_SIGNED_IN, PROVIDER_MANAGED } from './corpus/records.js';
|
|
51
51
|
export { runCase, servicesFor } from './corpus/runner.js';
|
|
52
|
-
export { appSummary, createAppStreamService, defaultAppName, MemoryAppStreamStore } from './appstream/service.js';
|
|
52
|
+
export { appSummary, checkPublishRequest, createAppStreamService, defaultAppName, MemoryAppStreamStore } from './appstream/service.js';
|
|
53
53
|
export { APP_MANIFEST, parseAppManifest, publishRequestFor, splitAppBundle } from './appstream/bundle.js';
|
|
54
54
|
export { APP_STREAM_INDEX, createDriveAppStreamStore } from './appstream/store.js';
|
|
55
55
|
export { DEFAULT_APP_PATH, NO_SUCH_APP, cacheControlFor, contentTypeFor, createAppStreamWebService, escapeHtml } from './appstream/web.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,EAgkE5C,CAAA"}
|
|
@@ -502,7 +502,7 @@ export const GENERATED_ROUTES = [
|
|
|
502
502
|
method: 'DELETE',
|
|
503
503
|
path: '/SASjsApi/drive/deploy',
|
|
504
504
|
tag: 'Drive',
|
|
505
|
-
summary: 'Remove an app
|
|
505
|
+
summary: 'Remove an app',
|
|
506
506
|
params: [
|
|
507
507
|
{
|
|
508
508
|
name: 'id',
|
|
@@ -546,6 +546,24 @@ export const GENERATED_ROUTES = [
|
|
|
546
546
|
required: false,
|
|
547
547
|
type: 'string'
|
|
548
548
|
},
|
|
549
|
+
{
|
|
550
|
+
name: 'streamServiceName',
|
|
551
|
+
in: 'body',
|
|
552
|
+
required: false,
|
|
553
|
+
type: 'string'
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: 'streamLogo',
|
|
557
|
+
in: 'body',
|
|
558
|
+
required: false,
|
|
559
|
+
type: 'string'
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: 'replace',
|
|
563
|
+
in: 'body',
|
|
564
|
+
required: false,
|
|
565
|
+
type: 'boolean'
|
|
566
|
+
},
|
|
549
567
|
{
|
|
550
568
|
name: 'fileTree',
|
|
551
569
|
in: 'body',
|
|
@@ -580,6 +598,36 @@ export const GENERATED_ROUTES = [
|
|
|
580
598
|
tag: 'Drive',
|
|
581
599
|
summary: 'Deploy an uploaded file to SASjs Drive',
|
|
582
600
|
params: [
|
|
601
|
+
{
|
|
602
|
+
name: 'appLoc',
|
|
603
|
+
in: 'query',
|
|
604
|
+
required: false,
|
|
605
|
+
type: 'string'
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
name: 'streamWebFolder',
|
|
609
|
+
in: 'query',
|
|
610
|
+
required: false,
|
|
611
|
+
type: 'string'
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: 'streamServiceName',
|
|
615
|
+
in: 'query',
|
|
616
|
+
required: false,
|
|
617
|
+
type: 'string'
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
name: 'streamLogo',
|
|
621
|
+
in: 'query',
|
|
622
|
+
required: false,
|
|
623
|
+
type: 'string'
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
name: 'replace',
|
|
627
|
+
in: 'query',
|
|
628
|
+
required: false,
|
|
629
|
+
type: 'boolean'
|
|
630
|
+
},
|
|
583
631
|
{
|
|
584
632
|
name: 'file',
|
|
585
633
|
in: 'formData',
|
package/package.json
CHANGED