@social-mail/social-mail-web-server 1.7.366 → 1.7.368
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/model/entities/WebSiteVersion.d.ts +1 -0
- package/dist/server/model/entities/WebSiteVersion.d.ts.map +1 -1
- package/dist/server/model/entities/WebSiteVersion.js +4 -0
- package/dist/server/model/entities/WebSiteVersion.js.map +1 -1
- package/dist/server/model/events/WebSiteEvents.d.ts +1 -1
- package/dist/server/model/events/WebSiteEvents.d.ts.map +1 -1
- package/dist/server/model/events/WebSiteEvents.js +5 -4
- package/dist/server/model/events/WebSiteEvents.js.map +1 -1
- package/dist/server/model/events/WebSiteVersionEvents.d.ts.map +1 -1
- package/dist/server/model/events/WebSiteVersionEvents.js +7 -0
- package/dist/server/model/events/WebSiteVersionEvents.js.map +1 -1
- package/dist/server/seed/ui/seed-ui.js +1 -1
- package/dist/server/services/files/SnapshotService.d.ts.map +1 -1
- package/dist/server/services/files/SnapshotService.js +0 -323
- package/dist/server/services/files/SnapshotService.js.map +1 -1
- package/dist/server/services/files/WebSiteContentService.d.ts +1 -0
- package/dist/server/services/files/WebSiteContentService.d.ts.map +1 -1
- package/dist/server/services/files/WebSiteContentService.js +3 -0
- package/dist/server/services/files/WebSiteContentService.js.map +1 -1
- package/dist/server/services/files/WebSiteVersionService.d.ts +1 -1
- package/dist/server/services/files/WebSiteVersionService.d.ts.map +1 -1
- package/dist/server/services/files/WebSiteVersionService.js +6 -6
- package/dist/server/services/files/WebSiteVersionService.js.map +1 -1
- package/dist/server/workflows/SocialWorkflowContext.d.ts.map +1 -1
- package/dist/server/workflows/SocialWorkflowContext.js +2 -0
- package/dist/server/workflows/SocialWorkflowContext.js.map +1 -1
- package/dist/server/workflows/clean-up/CleanupDeletedFilesWorkflow.d.ts.map +1 -1
- package/dist/server/workflows/clean-up/CleanupDeletedFilesWorkflow.js +1 -3
- package/dist/server/workflows/clean-up/CleanupDeletedFilesWorkflow.js.map +1 -1
- package/dist/server/workflows/files/DeleteFileWorkflow.d.ts.map +1 -1
- package/dist/server/workflows/files/DeleteFileWorkflow.js +1 -0
- package/dist/server/workflows/files/DeleteFileWorkflow.js.map +1 -1
- package/dist/server/workflows/web-site/DeleteWebSiteVersionWorkflow.d.ts +11 -0
- package/dist/server/workflows/web-site/DeleteWebSiteVersionWorkflow.d.ts.map +1 -0
- package/dist/server/workflows/web-site/DeleteWebSiteVersionWorkflow.js +55 -0
- package/dist/server/workflows/web-site/DeleteWebSiteVersionWorkflow.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wwwroot/routes/social-mail/site/download/files/get.d.ts.map +1 -1
- package/dist/wwwroot/routes/social-mail/site/download/files/get.js +2 -25
- package/dist/wwwroot/routes/social-mail/site/download/files/get.js.map +1 -1
- package/package.json +1 -1
- package/src/server/model/entities/WebSiteVersion.ts +4 -0
- package/src/server/model/events/WebSiteEvents.ts +5 -4
- package/src/server/model/events/WebSiteVersionEvents.ts +8 -0
- package/src/server/seed/ui/seed-ui.ts +1 -1
- package/src/server/services/files/SnapshotService.ts +2 -384
- package/src/server/services/files/WebSiteContentService.ts +4 -0
- package/src/server/services/files/WebSiteVersionService.ts +8 -6
- package/src/server/workflows/SocialWorkflowContext.ts +2 -0
- package/src/server/workflows/clean-up/CleanupDeletedFilesWorkflow.ts +1 -3
- package/src/server/workflows/files/DeleteFileWorkflow.ts +1 -0
- package/src/server/workflows/web-site/DeleteWebSiteVersionWorkflow.ts +54 -0
- package/src/wwwroot/routes/social-mail/site/download/files/get.tsx +2 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/social-mail/site/download/files/get.tsx"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,qBAAqB,MAAM,kEAAkE,CAAC;AACrG,OAAO,iBAAiB,MAAM,qDAAqD,CAAC;AAEpF,OAAO,iBAAiB,MAAM,mEAAmE,CAAC;AAIlG,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,GAAG,EAAE,qBAAqB,CAAC;IAG3B,EAAE,EAAE,iBAAiB,CAAC;IAGtB,GAAG,EAAE,iBAAiB,CAAC;IAEjB,GAAG;
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/social-mail/site/download/files/get.tsx"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,qBAAqB,MAAM,kEAAkE,CAAC;AACrG,OAAO,iBAAiB,MAAM,qDAAqD,CAAC;AAEpF,OAAO,iBAAiB,MAAM,mEAAmE,CAAC;AAIlG,MAAM,CAAC,OAAO,MAAO,SAAQ,IAAI;IAG7B,GAAG,EAAE,qBAAqB,CAAC;IAG3B,EAAE,EAAE,iBAAiB,CAAC;IAGtB,GAAG,EAAE,iBAAiB,CAAC;IAEjB,GAAG;CA+CZ"}
|
|
@@ -19,30 +19,6 @@ export default class default_1 extends Page {
|
|
|
19
19
|
if (!snapshot.isTemplate) {
|
|
20
20
|
return this.notFound();
|
|
21
21
|
}
|
|
22
|
-
// this will be handled by the site route
|
|
23
|
-
// if (snapshot.remoteUrl) {
|
|
24
|
-
// // proxy remote url
|
|
25
|
-
// const url = snapshot.remoteUrl + this.request.URL.pathname + this.request.URL.search;
|
|
26
|
-
// const r = await fetch(url);
|
|
27
|
-
// if (r.status >= 400) {
|
|
28
|
-
// return this.content({
|
|
29
|
-
// body: await r.text(),
|
|
30
|
-
// contentType: "text/plain"
|
|
31
|
-
// });
|
|
32
|
-
// }
|
|
33
|
-
// const buffer = await r.arrayBuffer();
|
|
34
|
-
// const contentType = r.headers.get("content-type") || "text/plain";
|
|
35
|
-
// let compress = false;
|
|
36
|
-
// if (/text|json/i.test(contentType)) {
|
|
37
|
-
// compress = true;
|
|
38
|
-
// }
|
|
39
|
-
// return this.content({
|
|
40
|
-
// status: r.status,
|
|
41
|
-
// body: Buffer.from(buffer),
|
|
42
|
-
// compress,
|
|
43
|
-
// contentType
|
|
44
|
-
// });
|
|
45
|
-
// }
|
|
46
22
|
const path = this.childPath ?? [];
|
|
47
23
|
const file = path?.length
|
|
48
24
|
? await this.wcs.getFileInfo(snapshot.snapshotFolderID, ...path)
|
|
@@ -67,9 +43,10 @@ export default class default_1 extends Page {
|
|
|
67
43
|
"x-content-type": "folder"
|
|
68
44
|
});
|
|
69
45
|
}
|
|
70
|
-
const appFile = await this.wcs.
|
|
46
|
+
const appFile = await this.wcs.getFileFromInfo(file);
|
|
71
47
|
return new TempFileResult(appFile, {
|
|
72
48
|
contentDisposition: "inline",
|
|
49
|
+
contentType: file.contentType
|
|
73
50
|
});
|
|
74
51
|
}
|
|
75
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/social-mail/site/download/files/get.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,4CAA4C,CAAC;AAChE,OAAO,IAAI,MAAM,0CAA0C,CAAC;AAC5D,OAAO,qBAAqB,MAAM,kEAAkE,CAAC;AACrG,OAAO,iBAAiB,MAAM,qDAAqD,CAAC;AAEpF,OAAO,iBAAiB,MAAM,mEAAmE,CAAC;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAE7E,MAAM,CAAC,OAAO,gBAAO,SAAQ,IAAI;IAW7B,KAAK,CAAC,GAAG;QAEL,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEhF,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources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,MAAM;8BACF,iBAAiB;sCAAC"}
|
package/package.json
CHANGED
|
@@ -86,20 +86,21 @@ export default class WebSiteEvents extends AuthenticatedEvents<WebSite> {
|
|
|
86
86
|
}
|
|
87
87
|
if (entity.remoteUrl) {
|
|
88
88
|
// create an empty snapshot
|
|
89
|
-
await this.ensureSnapshot(
|
|
89
|
+
await this.ensureSnapshot(entry);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
async afterUpdate(entity: WebSite, entry: ChangeEntry<WebSite>) {
|
|
94
94
|
if (entity.remoteUrl) {
|
|
95
95
|
// create an empty snapshot
|
|
96
|
-
await this.ensureSnapshot(
|
|
96
|
+
await this.ensureSnapshot(entry);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
async ensureSnapshot(
|
|
100
|
+
async ensureSnapshot(entry: ChangeEntry<WebSite>) {
|
|
101
|
+
await entry.loadNavigationAsync((x) => x.folder);
|
|
101
102
|
const vs = ServiceProvider.resolve(this, WebSiteVersionService);
|
|
102
|
-
await vs.ensureNewVersion(entity);
|
|
103
|
+
await vs.ensureNewVersion(entry.entity);
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
async copyTemplate(entity: WebSite) {
|
|
@@ -11,6 +11,8 @@ import { ForeignKeyFilter } from "@entity-access/entity-access/dist/model/events
|
|
|
11
11
|
import FileDeleteService from "../../services/files/FileDeleteService.js";
|
|
12
12
|
import SnapshotService from "../../services/files/SnapshotService.js";
|
|
13
13
|
import WebSiteVersionService from "../../services/files/WebSiteVersionService.js";
|
|
14
|
+
import WorkflowContext from "@entity-access/entity-access/dist/workflows/WorkflowContext.js";
|
|
15
|
+
import DeleteWebSiteVersionWorkflow from "../../workflows/web-site/DeleteWebSiteVersionWorkflow.js";
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
|
|
@@ -94,6 +96,12 @@ export class WebSiteVersionEvents extends AuthenticatedEvents<WebSiteVersion> {
|
|
|
94
96
|
isModified: false
|
|
95
97
|
}));
|
|
96
98
|
}
|
|
99
|
+
|
|
100
|
+
if(entity.clearHistory) {
|
|
101
|
+
const context = ServiceProvider.resolve(this, WorkflowContext);
|
|
102
|
+
const { folderID, snapshotFolderID } = entity;
|
|
103
|
+
await context.queue(DeleteWebSiteVersionWorkflow, { folderID, snapshotFolderID });
|
|
104
|
+
}
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
onForeignKeyFilter(filter: ForeignKeyFilter<WebSiteVersion, any>): IEntityQuery<any> {
|
|
@@ -5,7 +5,7 @@ export default async function seedUI(config: DBConfig) {
|
|
|
5
5
|
await config.saveVersion(UIPackageConfig, {
|
|
6
6
|
package: "@social-mail/social-mail-client",
|
|
7
7
|
view: "dist/web/AppIndex",
|
|
8
|
-
version: "1.4.
|
|
8
|
+
version: "1.4.215"
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
await config.saveVersion(WebComponentsPackageConfig, {
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import Inject, {
|
|
3
|
-
import { JSDOM } from 'jsdom';
|
|
2
|
+
import Inject, { RegisterTransient } from "@entity-access/entity-access/dist/di/di.js";
|
|
4
3
|
import SocialMailContext from "../../model/SocialMailContext.js";
|
|
5
4
|
import DateTime from "@entity-access/entity-access/dist/types/DateTime.js";
|
|
6
5
|
import { SessionUser } from "@entity-access/server-pages/dist/core/SessionUser.js";
|
|
7
6
|
import AppFile from "../../model/entities/AppFile.js";
|
|
8
7
|
import BaseStorage from "../../storage/BaseStorage.js";
|
|
9
8
|
import TempFileService from "../../storage/TempFileService.js";
|
|
10
|
-
import {
|
|
11
|
-
import {ICacheContainer, ObjectCache, cacheFor } from "../../../common/cacheFor.js";
|
|
9
|
+
import {ICacheContainer, ObjectCache } from "../../../common/cacheFor.js";
|
|
12
10
|
import { globalEnv } from "../../../common/globalEnv.js";
|
|
13
11
|
import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
|
|
14
12
|
import EntityAccessError from "@entity-access/entity-access/dist/common/EntityAccessError.js";
|
|
15
|
-
import type { LocalFile } from "@entity-access/server-pages/dist/core/LocalFile.js";
|
|
16
|
-
import { tokenizeCssUrl } from "../../../protocols/core/tokenizer.js";
|
|
17
13
|
import MessagingService from "../message-events/MessagingService.js";
|
|
18
14
|
|
|
19
15
|
|
|
@@ -22,25 +18,6 @@ if (cdn) {
|
|
|
22
18
|
cdn = `//${cdn}`;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
const joinPath = (root: string, path: string) => {
|
|
26
|
-
const roots = root.split("/");
|
|
27
|
-
let paths = path.split("/");
|
|
28
|
-
|
|
29
|
-
for(;;) {
|
|
30
|
-
const [f, ... rest] = paths;
|
|
31
|
-
if (f === ".") {
|
|
32
|
-
return roots.join("/") + rest.join("/");
|
|
33
|
-
}
|
|
34
|
-
if (f === "..") {
|
|
35
|
-
roots.pop();
|
|
36
|
-
paths = rest;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
return roots.join("/") + "/" + paths.join("/");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
44
21
|
@RegisterTransient
|
|
45
22
|
export default class SnapshotService
|
|
46
23
|
implements Disposable, ICacheContainer<SnapshotService> {
|
|
@@ -61,17 +38,10 @@ export default class SnapshotService
|
|
|
61
38
|
|
|
62
39
|
root: AppFile;
|
|
63
40
|
|
|
64
|
-
// htmlFiles: { source: AppFile, dest: AppFile, siteRoot: string, filePromise: Promise<LocalFile> } [] = [];
|
|
65
|
-
|
|
66
|
-
// derivedFiles: { source: AppFile, dest: AppFile, siteRoot: string, html: string } [] = [];
|
|
67
|
-
|
|
68
|
-
// cssFiles: { source: AppFile, dest: AppFile, siteRoot: string, filePromise: Promise<LocalFile> } [] = [];
|
|
69
41
|
snapshotRoot: AppFile;
|
|
70
42
|
|
|
71
43
|
allFiles: AppFile[] = null;
|
|
72
44
|
|
|
73
|
-
// snapshotFiles: AppFile[] = [];
|
|
74
|
-
|
|
75
45
|
fileMap = new Map<number, any>();
|
|
76
46
|
|
|
77
47
|
snapshotSize: number = 0;
|
|
@@ -134,65 +104,6 @@ export default class SnapshotService
|
|
|
134
104
|
|
|
135
105
|
await this.copyChildren(db, folder, snapshotRoot);
|
|
136
106
|
|
|
137
|
-
// for (const { source, dest, siteRoot, filePromise } of this.cssFiles) {
|
|
138
|
-
// const file = await filePromise;
|
|
139
|
-
|
|
140
|
-
// let html = await file.readAsText();
|
|
141
|
-
|
|
142
|
-
// html = await this.updateCssContent(html, siteRoot);
|
|
143
|
-
|
|
144
|
-
// if (html) {
|
|
145
|
-
// const htmlFile = await this.tempFileService.createFrom(source.name, Buffer.from(html, "utf-8"), "text/html");
|
|
146
|
-
// await this.storage.updateFile(dest, htmlFile);
|
|
147
|
-
// await db.appFiles.statements.update({
|
|
148
|
-
// fileContentID: dest.fileContentID
|
|
149
|
-
// }, {
|
|
150
|
-
// appFileID: dest.appFileID
|
|
151
|
-
// });
|
|
152
|
-
// }
|
|
153
|
-
// }
|
|
154
|
-
|
|
155
|
-
// for (const { source, dest, siteRoot, filePromise } of this.htmlFiles) {
|
|
156
|
-
// const file = await filePromise;
|
|
157
|
-
|
|
158
|
-
// let html = await file.readAsText();
|
|
159
|
-
|
|
160
|
-
// if (/\<inject\s/i.test(html)) {
|
|
161
|
-
// // this is derived file..
|
|
162
|
-
// this.derivedFiles.push({ source, dest, siteRoot, html });
|
|
163
|
-
// continue;
|
|
164
|
-
// }
|
|
165
|
-
|
|
166
|
-
// html = await this.updateHtmlContent(html, siteRoot, file.fileName);
|
|
167
|
-
|
|
168
|
-
// if (html) {
|
|
169
|
-
// const htmlFile = await this.tempFileService.createFrom(source.name, Buffer.from(html, "utf-8"), "text/html");
|
|
170
|
-
// await this.storage.updateFile(dest, htmlFile);
|
|
171
|
-
// await db.appFiles.statements.update({
|
|
172
|
-
// fileContentID: dest.fileContentID
|
|
173
|
-
// }, {
|
|
174
|
-
// appFileID: dest.appFileID
|
|
175
|
-
// });
|
|
176
|
-
// }
|
|
177
|
-
// }
|
|
178
|
-
|
|
179
|
-
// for (const df of this.derivedFiles) {
|
|
180
|
-
// const { source, dest, siteRoot } = df;
|
|
181
|
-
// let { html } = df;
|
|
182
|
-
|
|
183
|
-
// html = await this.updateHtmlContent(html, siteRoot, source.name);
|
|
184
|
-
|
|
185
|
-
// if (html) {
|
|
186
|
-
// const htmlFile = await this.tempFileService.createFrom(source.name, Buffer.from(html, "utf-8"), "text/html");
|
|
187
|
-
// await this.storage.updateFile(dest, htmlFile);
|
|
188
|
-
// await db.appFiles.statements.update({
|
|
189
|
-
// fileContentID: dest.fileContentID
|
|
190
|
-
// }, {
|
|
191
|
-
// appFileID: dest.appFileID
|
|
192
|
-
// });
|
|
193
|
-
// }
|
|
194
|
-
// }
|
|
195
|
-
|
|
196
107
|
await db.saveChanges();
|
|
197
108
|
|
|
198
109
|
await this.db.appFiles.where(this.snapshotRoot, (p) => (x) => x.appFileID === p.appFileID)
|
|
@@ -243,7 +154,6 @@ export default class SnapshotService
|
|
|
243
154
|
});
|
|
244
155
|
|
|
245
156
|
dest.children.push(destChild);
|
|
246
|
-
// this.snapshotFiles.push(destChild);
|
|
247
157
|
|
|
248
158
|
const path = `${dest.path}${destChild.appFileID}/`;
|
|
249
159
|
destChild.path = path;
|
|
@@ -253,18 +163,6 @@ export default class SnapshotService
|
|
|
253
163
|
appFileID: destChild.appFileID
|
|
254
164
|
});
|
|
255
165
|
|
|
256
|
-
// if (/text\/css/i.test(srcChild.contentType) || /\.css$/i.test(srcChild.name)) {
|
|
257
|
-
// await db.changeSet.getEntry(srcChild).loadNavigationAsync((x) => x.fileContent);
|
|
258
|
-
// const filePromise = this.tempFileService.downloadAppFile(srcChild);
|
|
259
|
-
// this.cssFiles.push({ source: srcChild, dest: destChild, siteRoot, filePromise });
|
|
260
|
-
// }
|
|
261
|
-
|
|
262
|
-
// if (/text\/html/i.test(srcChild.contentType) || /\.html?$/i.test(srcChild.name)) {
|
|
263
|
-
// await db.changeSet.getEntry(srcChild).loadNavigationAsync((x) => x.fileContent);
|
|
264
|
-
// const filePromise = this.tempFileService.downloadAppFile(srcChild);
|
|
265
|
-
// this.htmlFiles.push({ source: srcChild, dest: destChild, siteRoot, filePromise });
|
|
266
|
-
// }
|
|
267
|
-
|
|
268
166
|
|
|
269
167
|
if (srcChild.isFolder) {
|
|
270
168
|
await this.copyChildren(db, srcChild, destChild, siteRoot + "/" + srcChild.name );
|
|
@@ -274,284 +172,4 @@ export default class SnapshotService
|
|
|
274
172
|
}
|
|
275
173
|
}
|
|
276
174
|
|
|
277
|
-
// async updateCssContent(css: string, parentPath: string) {
|
|
278
|
-
|
|
279
|
-
// let updated = false;
|
|
280
|
-
|
|
281
|
-
// for (const fg of tokenizeCssUrl(css)) {
|
|
282
|
-
// let link = fg;
|
|
283
|
-
// const first = link[0];
|
|
284
|
-
// const encoded = first === '"' || first === "'";
|
|
285
|
-
// if (encoded) {
|
|
286
|
-
// link = link.substring(1, link.length - 1);
|
|
287
|
-
// }
|
|
288
|
-
// link = await this.rewriteLink(link, parentPath);
|
|
289
|
-
// if (!link) {
|
|
290
|
-
// continue;
|
|
291
|
-
// }
|
|
292
|
-
// css = css.replaceAll(fg, link);
|
|
293
|
-
// updated = true;
|
|
294
|
-
// }
|
|
295
|
-
|
|
296
|
-
// if (updated) {
|
|
297
|
-
// return css;
|
|
298
|
-
// }
|
|
299
|
-
// }
|
|
300
|
-
|
|
301
|
-
// /**
|
|
302
|
-
// * This method cannot use local file cache as it may reference some different
|
|
303
|
-
// * snapshot or different website folder if user has copied and pasted content
|
|
304
|
-
// * from somewhere else
|
|
305
|
-
// * @param fileID
|
|
306
|
-
// * @returns
|
|
307
|
-
// */
|
|
308
|
-
// @cacheFor()
|
|
309
|
-
// async getRelativePath(fileID, link,fileName) {
|
|
310
|
-
// try {
|
|
311
|
-
// const file = await this.db.appFiles
|
|
312
|
-
// .where({ fileID }, (p) => (x) => x.appFileID === p.fileID)
|
|
313
|
-
// .first();
|
|
314
|
-
// if (!file) {
|
|
315
|
-
// console.warn(`File ${fileID} not found for ${link} in ${fileName}`);
|
|
316
|
-
// return;
|
|
317
|
-
// }
|
|
318
|
-
// const [ ignore , ... fileIDs] = file.path.split("/").filter((x) => x) as any[];
|
|
319
|
-
// const files = await this.db.appFiles
|
|
320
|
-
// .where({ fileIDs }, (p) => (x) => x.appFileID in p.fileIDs)
|
|
321
|
-
// .toArray();
|
|
322
|
-
// const pathFragments = [] as string[];
|
|
323
|
-
// for (const iterator of fileIDs) {
|
|
324
|
-
// const f = files.find((x) => BigInt(x.appFileID) === BigInt(iterator));
|
|
325
|
-
// if (!f) {
|
|
326
|
-
// console.log(`File not found for ${iterator} in ${fileIDs} for ${fileID}`);
|
|
327
|
-
// }
|
|
328
|
-
// pathFragments.push(f.name);
|
|
329
|
-
// }
|
|
330
|
-
// return pathFragments;
|
|
331
|
-
// } catch (error) {
|
|
332
|
-
// console.warn(error);
|
|
333
|
-
// }
|
|
334
|
-
// }
|
|
335
|
-
|
|
336
|
-
// parseLink(link: string) {
|
|
337
|
-
// let index = link.indexOf("#");
|
|
338
|
-
// if (index !== -1) {
|
|
339
|
-
// link = link.substring(0, index);
|
|
340
|
-
// }
|
|
341
|
-
// let query = "";
|
|
342
|
-
// index = link.indexOf("?");
|
|
343
|
-
// if (index !== -1) {
|
|
344
|
-
// query = link.substring(index);
|
|
345
|
-
// link = link.substring(0, index);
|
|
346
|
-
// }
|
|
347
|
-
// return { query, link };
|
|
348
|
-
// }
|
|
349
|
-
|
|
350
|
-
// async rewriteLink(link: string, parentPath: string, srcFileName?: string) {
|
|
351
|
-
// if (!link) {
|
|
352
|
-
// return;
|
|
353
|
-
// }
|
|
354
|
-
|
|
355
|
-
// if (/^((https?\:\/\/)|(data\:)|(\/\/))/i.test(link)) {
|
|
356
|
-
// return;
|
|
357
|
-
// }
|
|
358
|
-
|
|
359
|
-
// const originalLink = link;
|
|
360
|
-
|
|
361
|
-
// if (link.startsWith("/api/site/snapshot/")) {
|
|
362
|
-
// link = `${cdn}${link}`;
|
|
363
|
-
// return link;
|
|
364
|
-
// }
|
|
365
|
-
|
|
366
|
-
// let paths: string[];
|
|
367
|
-
// let transform = "download";
|
|
368
|
-
// let fileName: string;
|
|
369
|
-
// let query = "";
|
|
370
|
-
|
|
371
|
-
// if (!link.startsWith("/api/site/asset/")) {
|
|
372
|
-
// // we already have the path...
|
|
373
|
-
// link = joinPath(parentPath, link);
|
|
374
|
-
// if (link.startsWith("/")) {
|
|
375
|
-
// link = link.substring(1);
|
|
376
|
-
// }
|
|
377
|
-
// let index = link.indexOf("#");
|
|
378
|
-
// if (index !== -1) {
|
|
379
|
-
// link = link.substring(0, index);
|
|
380
|
-
// }
|
|
381
|
-
// index = link.indexOf("?");
|
|
382
|
-
// if (index !== -1) {
|
|
383
|
-
// query = link.substring(index);
|
|
384
|
-
// link = link.substring(0, index);
|
|
385
|
-
// }
|
|
386
|
-
// paths = link.split("/");
|
|
387
|
-
// } else {
|
|
388
|
-
// // find the path...
|
|
389
|
-
// // /api[0]/site[1]/asset[2]/transform[3]/siteID[4]/fileID[5]/fileContentID[6]/fileName[7]
|
|
390
|
-
// if (link.startsWith("/")) {
|
|
391
|
-
// link = link.substring(1);
|
|
392
|
-
// }
|
|
393
|
-
// const tokens = link.split("/");
|
|
394
|
-
// transform = tokens[3];
|
|
395
|
-
// paths = await this.getRelativePath(tokens[5], originalLink + "\n" + link, srcFileName);
|
|
396
|
-
// if (!paths) {
|
|
397
|
-
// return;
|
|
398
|
-
// }
|
|
399
|
-
// fileName = tokens[7];
|
|
400
|
-
// }
|
|
401
|
-
|
|
402
|
-
// const child = await this.findSnapshotChildren(paths);
|
|
403
|
-
// if (!child) {
|
|
404
|
-
// console.warn(`No link found for ${link} with path ${paths.join("/")} in ${this.root.appFileID}, original: ${originalLink}, ${parentPath}, ${srcFileName}`);
|
|
405
|
-
// return;
|
|
406
|
-
// }
|
|
407
|
-
|
|
408
|
-
// fileName ??= child.name;
|
|
409
|
-
// // we should not put snapshot id here
|
|
410
|
-
// // as snapshot id will be re-generated each time...
|
|
411
|
-
// link = `${cdn}/api/site/snapshot/${transform}/${this.root.appFileID}/${child.fileContentID}/${fileName}${query}`;
|
|
412
|
-
// return link;
|
|
413
|
-
|
|
414
|
-
// }
|
|
415
|
-
|
|
416
|
-
// async updateHtmlContent(html: string, parentPath: string,fileName: string) {
|
|
417
|
-
|
|
418
|
-
// const { root } = this;
|
|
419
|
-
|
|
420
|
-
// const dom = new JSDOM(html);
|
|
421
|
-
|
|
422
|
-
// const { window } = dom;
|
|
423
|
-
// const { document } = window;
|
|
424
|
-
|
|
425
|
-
// let updated = false;
|
|
426
|
-
|
|
427
|
-
// for (const e of Array.from(document.querySelectorAll("*"))) {
|
|
428
|
-
|
|
429
|
-
// let link: string;
|
|
430
|
-
// let attributeName: string;
|
|
431
|
-
// let attributeSet: string[];
|
|
432
|
-
|
|
433
|
-
// if(e.tagName === "STYLE") {
|
|
434
|
-
// const text = e.textContent;
|
|
435
|
-
// const modified = await this.updateCssContent(text, parentPath);
|
|
436
|
-
// if (modified) {
|
|
437
|
-
// e.textContent = modified;
|
|
438
|
-
// updated = true;
|
|
439
|
-
// }
|
|
440
|
-
// continue;
|
|
441
|
-
// }
|
|
442
|
-
|
|
443
|
-
// if (e.tagName === "INJECT") {
|
|
444
|
-
// link = e.getAttribute("src");
|
|
445
|
-
|
|
446
|
-
// link = await this.rewriteLink(link, parentPath, fileName);
|
|
447
|
-
// if (link) {
|
|
448
|
-
// // get file content...
|
|
449
|
-
// const url = new URL(link, "https://a");
|
|
450
|
-
// const tokens = url.pathname.substring(1).split("/");
|
|
451
|
-
// const fileContentID = tokens[5];
|
|
452
|
-
// const fileContent = await this.downloadSnapshotContent(fileContentID, link);
|
|
453
|
-
// const parent = e.parentElement;
|
|
454
|
-
// for (const iterator of fileContent) {
|
|
455
|
-
// parent.insertBefore(iterator, e);
|
|
456
|
-
// }
|
|
457
|
-
// e.remove();
|
|
458
|
-
// updated = true;
|
|
459
|
-
// }
|
|
460
|
-
|
|
461
|
-
// continue;
|
|
462
|
-
// }
|
|
463
|
-
|
|
464
|
-
// if (/^(VIDEO|PDF|IMG$|INLINE-SVG$|SOURCE)/.test(e.tagName)) {
|
|
465
|
-
// attributeName = "src";
|
|
466
|
-
// attributeSet = ["data-src-set", "srcset"];
|
|
467
|
-
// }
|
|
468
|
-
|
|
469
|
-
// if (/^LINK$/.test(e.tagName) && /^stylesheet$/i.test(e.getAttribute("rel"))) {
|
|
470
|
-
// attributeName = "href";
|
|
471
|
-
// }
|
|
472
|
-
// if (!attributeName) {
|
|
473
|
-
// continue;
|
|
474
|
-
// }
|
|
475
|
-
// link = e.getAttribute(attributeName);
|
|
476
|
-
// link = await this.rewriteLink(link, parentPath, fileName);
|
|
477
|
-
// if (link) {
|
|
478
|
-
// updated = true;
|
|
479
|
-
// e.setAttribute(attributeName, link);
|
|
480
|
-
// }
|
|
481
|
-
|
|
482
|
-
// if (attributeSet) {
|
|
483
|
-
// for (const setName of attributeSet) {
|
|
484
|
-
// const srcSet = e.getAttribute(setName);
|
|
485
|
-
// if (srcSet) {
|
|
486
|
-
// const changedSet = [];
|
|
487
|
-
// for (const url of srcSet.split(/\,\;/)) {
|
|
488
|
-
// const tokens = url?.split(" ");
|
|
489
|
-
// if (!(tokens?.length > 0)) {
|
|
490
|
-
// continue;
|
|
491
|
-
// }
|
|
492
|
-
// link = tokens[0];
|
|
493
|
-
// if (!link) {
|
|
494
|
-
// continue;
|
|
495
|
-
// }
|
|
496
|
-
// link = await this.rewriteLink(link, parentPath, fileName);
|
|
497
|
-
// if (link) {
|
|
498
|
-
// changedSet.push(`${link} ${tokens[1]}`);
|
|
499
|
-
// }
|
|
500
|
-
// }
|
|
501
|
-
// if (changedSet.length) {
|
|
502
|
-
// updated = true;
|
|
503
|
-
// e.setAttribute(setName, changedSet.join(","));
|
|
504
|
-
// }
|
|
505
|
-
// }
|
|
506
|
-
// }
|
|
507
|
-
// }
|
|
508
|
-
// }
|
|
509
|
-
|
|
510
|
-
// if (updated) {
|
|
511
|
-
// return document.documentElement.outerHTML;
|
|
512
|
-
// }
|
|
513
|
-
// }
|
|
514
|
-
|
|
515
|
-
// @cacheFor()
|
|
516
|
-
// async downloadSnapshotContent(fileContentID, link) {
|
|
517
|
-
// const file = await this.db.appFiles.where({ fileContentID }, (p) => (x) => x.fileContentID === p.fileContentID
|
|
518
|
-
// )
|
|
519
|
-
// .include((x) => x.fileContent)
|
|
520
|
-
// .first();
|
|
521
|
-
// if (!file?.fileContent) {
|
|
522
|
-
// console.error(`File ${fileContentID} not found for ${link}`);
|
|
523
|
-
// }
|
|
524
|
-
// const localFile = await this.tempFileService.downloadAppFile(file);
|
|
525
|
-
// const text = await localFile.readAsText();
|
|
526
|
-
// await localFile.delete();
|
|
527
|
-
// const dom = new JSDOM(text);
|
|
528
|
-
// return Array.from(dom.window.document.body.children) as HTMLElement[];
|
|
529
|
-
// }
|
|
530
|
-
|
|
531
|
-
// @cacheFor()
|
|
532
|
-
// async findSnapshotChildren(paths: string[], folderID = this.snapshotRoot.appFileID): Promise<AppFile> {
|
|
533
|
-
// const child = await this._findSnapshotChildren(paths, folderID);
|
|
534
|
-
// if (!child) {
|
|
535
|
-
// console.log(`File ${paths.join("/")} not found in folder ${folderID}\n${new Error().stack}`);
|
|
536
|
-
// }
|
|
537
|
-
// return child;
|
|
538
|
-
// }
|
|
539
|
-
|
|
540
|
-
// async _findSnapshotChildren(paths: string[], folderID): Promise<AppFile> {
|
|
541
|
-
// const [ first, ... rest ] = paths;
|
|
542
|
-
// if (!first) {
|
|
543
|
-
// if (rest.length) {
|
|
544
|
-
// return this.findSnapshotChildren(rest, folderID);
|
|
545
|
-
// }
|
|
546
|
-
// return null;
|
|
547
|
-
// }
|
|
548
|
-
// const child = this.snapshotFiles.find((x) => x.parentID === folderID && x.name === first);
|
|
549
|
-
// if (!child) {
|
|
550
|
-
// return null;
|
|
551
|
-
// }
|
|
552
|
-
// if (rest.length === 0) {
|
|
553
|
-
// return child;
|
|
554
|
-
// }
|
|
555
|
-
// return this.findSnapshotChildren(rest, child.appFileID);
|
|
556
|
-
// }
|
|
557
175
|
}
|
|
@@ -88,6 +88,10 @@ export default class WebSiteContentService
|
|
|
88
88
|
return this.tfs.downloadFileContent(fileInfo.fileContentID, fileInfo);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
getFileFromInfo(fileInfo: IFileInfo) {
|
|
92
|
+
return this.tfs.downloadFileContent(fileInfo.fileContentID, fileInfo);
|
|
93
|
+
}
|
|
94
|
+
|
|
91
95
|
@cacheFor()
|
|
92
96
|
async getFileInfo(folderID, ... segments: string[]): Promise<IFileInfo> {
|
|
93
97
|
const [top, ... paths] = segments;
|
|
@@ -13,15 +13,14 @@ export default class WebSiteVersionService {
|
|
|
13
13
|
|
|
14
14
|
@Inject user: SessionUser;
|
|
15
15
|
|
|
16
|
-
async getNewVersion(folderID, versionType: semver.ReleaseType = "patch") {
|
|
16
|
+
async getNewVersion(folderID: number, versionType: semver.ReleaseType = "patch") {
|
|
17
17
|
const previous = await this.db.websiteVersions.where({ folderID }, (p) => (x) => x.folderID === p.folderID)
|
|
18
18
|
.orderByDescending(void 0, (p) => (x) => x.dateCreated)
|
|
19
19
|
.first();
|
|
20
20
|
if (!previous) {
|
|
21
21
|
return "1.0.0";
|
|
22
|
-
} else {
|
|
23
|
-
return semver.inc(previous.name, versionType);
|
|
24
22
|
}
|
|
23
|
+
return semver.inc(previous.name, versionType);
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
async ensureNewVersionForRemote(folderID) {
|
|
@@ -40,12 +39,14 @@ export default class WebSiteVersionService {
|
|
|
40
39
|
|
|
41
40
|
const dateCreated = DateTime.now;
|
|
42
41
|
|
|
43
|
-
const { folderID } = site;
|
|
42
|
+
const { folderID, folder } = site;
|
|
44
43
|
|
|
45
44
|
const creatorID = this.user.userID;
|
|
46
45
|
|
|
46
|
+
const { name } = folder;
|
|
47
|
+
|
|
47
48
|
const snapshotRoot = await this.db.appFiles.statements.insert({
|
|
48
|
-
|
|
49
|
+
name,
|
|
49
50
|
contentType: "snapshot",
|
|
50
51
|
appFileID: void 0,
|
|
51
52
|
parentID: null,
|
|
@@ -70,7 +71,8 @@ export default class WebSiteVersionService {
|
|
|
70
71
|
authorID: creatorID,
|
|
71
72
|
dateCreated,
|
|
72
73
|
folderID,
|
|
73
|
-
snapshotFolderID: snapshotRoot.appFileID
|
|
74
|
+
snapshotFolderID: snapshotRoot.appFileID,
|
|
75
|
+
name: await this.getNewVersion(site.folderID)
|
|
74
76
|
});
|
|
75
77
|
|
|
76
78
|
// delete previous versions...
|
|
@@ -50,6 +50,7 @@ import DeleteHostedDomainWorkflow from "./hosted-domain/DeleteHostedDomainWorkfl
|
|
|
50
50
|
import DeleteMailboxContactWorkflow from "./mailbox/DeleteMailboxContactWorkflow.js";
|
|
51
51
|
import DownloadExternalAttachmentWorkflow from "./external-body/DownloadExternalAttachmentWorkflow.js";
|
|
52
52
|
import FetchCheckoutResultWorkflow from "./store/FetchCheckoutResultWorkflow.js";
|
|
53
|
+
import DeleteWebSiteVersionWorkflow from "./web-site/DeleteWebSiteVersionWorkflow.js";
|
|
53
54
|
|
|
54
55
|
@RegisterSingleton
|
|
55
56
|
export default class SocialWorkflowContext extends WorkflowContext {
|
|
@@ -102,6 +103,7 @@ export default class SocialWorkflowContext extends WorkflowContext {
|
|
|
102
103
|
this.register(CopyTemplateWorkflow);
|
|
103
104
|
|
|
104
105
|
this.register(DeleteWebsiteWorkflow);
|
|
106
|
+
this.register(DeleteWebSiteVersionWorkflow);
|
|
105
107
|
this.register(DeleteFileWorkflow);
|
|
106
108
|
|
|
107
109
|
this.register(DeleteMailboxWorkflow);
|
|
@@ -51,9 +51,7 @@ export default class CleanupDeletedFilesWorkflow extends Workflow {
|
|
|
51
51
|
x.tempFiles.some((tf) => tf.rootID === p.tempFileID)
|
|
52
52
|
)
|
|
53
53
|
.update(void 0, (p) => (x) => ({ deleted: true }));
|
|
54
|
-
await db.appTempFiles.
|
|
55
|
-
rootID: tmpFolder.rootID
|
|
56
|
-
});
|
|
54
|
+
await db.appTempFiles.asQuery().delete(tmpFolder, (p) => (x) => x.rootID === p.tempFileID);
|
|
57
55
|
await db.appTempFiles.statements.delete({
|
|
58
56
|
tempFileID: tmpFolder.tempFileID
|
|
59
57
|
});
|