@social-mail/social-mail-web-server 1.16.415 → 1.16.418

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.
Files changed (41) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/server/services/files/web-content/WebUrl.d.ts +0 -5
  3. package/dist/server/services/files/web-content/WebUrl.d.ts.map +1 -1
  4. package/dist/server/services/files/web-content/WebUrl.js +0 -12
  5. package/dist/server/services/files/web-content/WebUrl.js.map +1 -1
  6. package/dist/server/services/puppeteer/PuppeteerService.d.ts +2 -1
  7. package/dist/server/services/puppeteer/PuppeteerService.d.ts.map +1 -1
  8. package/dist/server/services/puppeteer/PuppeteerService.js +3 -2
  9. package/dist/server/services/puppeteer/PuppeteerService.js.map +1 -1
  10. package/dist/server/services/site/SitePreviewGenerator.d.ts +10 -0
  11. package/dist/server/services/site/SitePreviewGenerator.d.ts.map +1 -0
  12. package/dist/server/services/site/SitePreviewGenerator.js +30 -0
  13. package/dist/server/services/site/SitePreviewGenerator.js.map +1 -0
  14. package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.d.ts +2 -1
  15. package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.d.ts.map +1 -1
  16. package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.js +6 -4
  17. package/dist/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.js.map +1 -1
  18. package/dist/wwwroot/routes/social-mail/site/list/templates/get.d.ts +2 -0
  19. package/dist/wwwroot/routes/social-mail/site/list/templates/get.d.ts.map +1 -1
  20. package/dist/wwwroot/routes/social-mail/site/list/templates/get.js +11 -6
  21. package/dist/wwwroot/routes/social-mail/site/list/templates/get.js.map +1 -1
  22. package/dist/wwwroot/routes/social-mail/site/preview/[host]/[type]/[cacheKey]/get.d.ts.map +1 -1
  23. package/dist/wwwroot/routes/social-mail/site/preview/[host]/[type]/[cacheKey]/get.js +2 -2
  24. package/dist/wwwroot/routes/social-mail/site/preview/[host]/[type]/[cacheKey]/get.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/server/services/files/web-content/WebUrl.ts +0 -17
  27. package/src/server/services/puppeteer/PuppeteerService.ts +3 -1
  28. package/src/server/services/site/SitePreviewGenerator.ts +23 -0
  29. package/src/server/workflows/site/generate-previews/GenerateTemplatePreviewWorkflow.ts +4 -3
  30. package/src/wwwroot/routes/social-mail/site/list/templates/get.tsx +18 -13
  31. package/src/wwwroot/routes/social-mail/site/preview/[host]/[type]/[cacheKey]/get.tsx +2 -3
  32. package/dist/wwwroot/routes/social-mail/site/list/[type]/get.d.ts +0 -18
  33. package/dist/wwwroot/routes/social-mail/site/list/[type]/get.d.ts.map +0 -1
  34. package/dist/wwwroot/routes/social-mail/site/list/[type]/get.js +0 -184
  35. package/dist/wwwroot/routes/social-mail/site/list/[type]/get.js.map +0 -1
  36. package/dist/wwwroot/routes/social-mail/site/list/[type]/options.d.ts +0 -3
  37. package/dist/wwwroot/routes/social-mail/site/list/[type]/options.d.ts.map +0 -1
  38. package/dist/wwwroot/routes/social-mail/site/list/[type]/options.js +0 -3
  39. package/dist/wwwroot/routes/social-mail/site/list/[type]/options.js.map +0 -1
  40. package/src/wwwroot/routes/social-mail/site/list/[type]/get.tsx +0 -184
  41. package/src/wwwroot/routes/social-mail/site/list/[type]/options.tsx +0 -2
@@ -1,184 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import Inject from "@entity-access/entity-access/dist/di/di.js";
11
- import Page from "@entity-access/server-pages/dist/Page.js";
12
- import SocialMailContext from "../../../../../../server/model/SocialMailContext.js";
13
- import { Query } from "@entity-access/server-pages/dist/core/Query.js";
14
- import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
15
- import { CORS } from "../../../../../../common/CORS.js";
16
- import { globalEnv } from "../../../../../../common/globalEnv.js";
17
- import { Route } from "@entity-access/server-pages/dist/core/Route.js";
18
- import SessionSecurity from "@entity-access/server-pages/dist/services/SessionSecurity.js";
19
- import EncryptionService from "../../../../../../server/services/encryption/EncryptionService.js";
20
- import WebUrl from "../../../../../../server/services/files/web-content/WebUrl.js";
21
- export default class default_1 extends Page {
22
- constructor() {
23
- super(...arguments);
24
- this.start = 0;
25
- this.size = 50;
26
- }
27
- async run() {
28
- let q = this.db.websiteFolders.asQuery();
29
- let isWebSiteTemplate = false;
30
- switch (this.type?.toLowerCase()) {
31
- case "design":
32
- case "designs":
33
- q = q.where((x) => x.isDesign === true);
34
- break;
35
- default:
36
- q = q.where((x) => x.isTemplate === true);
37
- isWebSiteTemplate = true;
38
- break;
39
- }
40
- const { search = "" } = this;
41
- if (search) {
42
- const tokens = search.split(/[\,\s]+/g);
43
- const words = tokens.filter((t) => t?.length > 3)
44
- .map((t) => `%${t}%`);
45
- const ids = tokens.filter((t) => /^\d+$/i.test(t));
46
- if (ids.length) {
47
- q = q.where({ words, ids }, (x, p) => Sql.in(x.folderID, p.ids)
48
- || Sql.text.likeAny(x.folder.name, p.words));
49
- }
50
- else {
51
- q = q.where({ words }, (x, p) => Sql.text.likeAny(x.folder.name, p.words));
52
- }
53
- }
54
- if (this.tags) {
55
- const tags = this.tags.toLowerCase().split(/[\,\;\s]+/g).filter((x) => x);
56
- if (tags.length) {
57
- q = q.where({ tags }, (x, p) => x.webSiteTags.some((t) => Sql.in(t.tag.lowerCaseName, p.tags)));
58
- }
59
- }
60
- const start = Number(this.start) || 0;
61
- const size = Math.max(50, this.size ?? 20);
62
- // host must exist
63
- const list = await q
64
- .where((x) => x.currentVersionID !== null && x.hosts.some((h) => h.host !== null))
65
- .orderByDescending((x) => x.templateSites)
66
- .include((x) => [x.folder, x.currentVersion, x.hosts, x.webSiteTags.forEach((t) => t.tag)])
67
- .toPage(start, size);
68
- if (!isWebSiteTemplate) {
69
- const ids = [];
70
- for (const file of list.items) {
71
- ids.push(file.currentVersionID);
72
- }
73
- if (ids.length) {
74
- await this.db.appFiles.where({ ids }, (x, p) => Sql.in(x.parentID, p.ids)
75
- && x.isDeleted === false
76
- && (x.name === "preview.svg"
77
- || x.name === "preview.png"
78
- || x.name === "template.html")).toArray();
79
- }
80
- }
81
- const cdn = this.withoutCdn
82
- ? this.request.hostName
83
- : globalEnv.cdn ?? this.request.hostName;
84
- const items = isWebSiteTemplate
85
- ? list.items.map((x) => {
86
- const { host } = x.hosts[0];
87
- return {
88
- id: x.folderID,
89
- tags: x.webSiteTags?.map((t) => t.tag.name) ?? [],
90
- name: x.folder.name,
91
- title: x.title,
92
- host,
93
- ...WebUrl.templatePreviewUrls(x, this.withoutCdn ? this.request.hostName : void 0),
94
- url: `https://${host}`
95
- };
96
- })
97
- : list.items.map((x) => {
98
- const { host } = x.hosts[0];
99
- const { currentVersion } = x;
100
- let previewFile;
101
- let templateFile;
102
- for (const cf of currentVersion.children) {
103
- switch (cf.name) {
104
- case "template.html":
105
- templateFile = cf;
106
- break;
107
- case "preview.png":
108
- previewFile = cf;
109
- break;
110
- case "preview.svg":
111
- previewFile = previewFile ?? cf;
112
- break;
113
- }
114
- }
115
- this.sessionSecurity.injectPublicKey(previewFile);
116
- this.sessionSecurity.injectPublicKey(templateFile);
117
- const fd = (file) => {
118
- const { $key } = file;
119
- const eFileContentID = this.es.general.encrypt(file.fileContentID);
120
- return `https://${cdn}/social-mail/fd/view/${$key}/${eFileContentID}/${file.name}`;
121
- };
122
- return {
123
- id: x.folderID,
124
- tags: x.webSiteTags?.map((t) => t.tag.name) ?? [],
125
- name: x.folder.name,
126
- title: x.title,
127
- host,
128
- preview: fd(previewFile),
129
- template: fd(templateFile),
130
- url: `https://${host}`
131
- };
132
- });
133
- const headers = /^((www|tools)\.)?esocialmail.com$/i.test(this.request.hostName)
134
- ? CORS.allowAll
135
- : void 0;
136
- const cacheSeconds = this.cacheSeconds || 900;
137
- this.cacheControl = `public, max-age=${cacheSeconds}`;
138
- return this.json({
139
- items,
140
- hasMore: list.more
141
- }, void 0, headers);
142
- }
143
- }
144
- __decorate([
145
- Inject,
146
- __metadata("design:type", SocialMailContext)
147
- ], default_1.prototype, "db", void 0);
148
- __decorate([
149
- Query("tags"),
150
- __metadata("design:type", String)
151
- ], default_1.prototype, "tags", void 0);
152
- __decorate([
153
- Query.asNumber("start"),
154
- __metadata("design:type", Number)
155
- ], default_1.prototype, "start", void 0);
156
- __decorate([
157
- Query.asNumber("size"),
158
- __metadata("design:type", Number)
159
- ], default_1.prototype, "size", void 0);
160
- __decorate([
161
- Query("search"),
162
- __metadata("design:type", String)
163
- ], default_1.prototype, "search", void 0);
164
- __decorate([
165
- Route("type"),
166
- __metadata("design:type", String)
167
- ], default_1.prototype, "type", void 0);
168
- __decorate([
169
- Query.asNumber("cacheSeconds"),
170
- __metadata("design:type", Number)
171
- ], default_1.prototype, "cacheSeconds", void 0);
172
- __decorate([
173
- Query.caseInsensitiveAsBoolean,
174
- __metadata("design:type", String)
175
- ], default_1.prototype, "withoutCdn", void 0);
176
- __decorate([
177
- Inject,
178
- __metadata("design:type", SessionSecurity)
179
- ], default_1.prototype, "sessionSecurity", void 0);
180
- __decorate([
181
- Inject,
182
- __metadata("design:type", EncryptionService)
183
- ], default_1.prototype, "es", void 0);
184
- //# sourceMappingURL=get.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/social-mail/site/list/[type]/get.tsx"],"names":[],"mappings":";;;;;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AAGnB;IADC,MAAM;8BACU,eAAe;kDAAC;AAGjC;IADC,MAAM;8BACH,iBAAiB;qCAAC"}
@@ -1,3 +0,0 @@
1
- import CorsOptionsPage from "../../../../../../common/CorsOptionsPage.js";
2
- export default CorsOptionsPage;
3
- //# sourceMappingURL=options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/social-mail/site/list/[type]/options.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,6CAA6C,CAAC;eAC3D,eAAe"}
@@ -1,3 +0,0 @@
1
- import CorsOptionsPage from "../../../../../../common/CorsOptionsPage.js";
2
- export default CorsOptionsPage;
3
- //# sourceMappingURL=options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../../../../src/wwwroot/routes/social-mail/site/list/[type]/options.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,eAAe,eAAe,CAAC"}
@@ -1,184 +0,0 @@
1
- import Inject from "@entity-access/entity-access/dist/di/di.js";
2
- import Page from "@entity-access/server-pages/dist/Page.js";
3
- import SocialMailContext from "../../../../../../server/model/SocialMailContext.js";
4
- import { Query } from "@entity-access/server-pages/dist/core/Query.js";
5
- import Sql from "@entity-access/entity-access/dist/sql/Sql.js";
6
- import { CORS } from "../../../../../../common/CORS.js";
7
- import { globalEnv } from "../../../../../../common/globalEnv.js";
8
- import { Route } from "@entity-access/server-pages/dist/core/Route.js";
9
- import SessionSecurity from "@entity-access/server-pages/dist/services/SessionSecurity.js";
10
- import AppFile from "../../../../../../server/model/entities/AppFile.js";
11
- import EncryptionService from "../../../../../../server/services/encryption/EncryptionService.js";
12
- import WebUrl from "../../../../../../server/services/files/web-content/WebUrl.js";
13
-
14
- export default class extends Page {
15
-
16
- @Inject
17
- db: SocialMailContext;
18
-
19
- @Query("tags")
20
- tags: string;
21
-
22
- @Query.asNumber("start")
23
- start: number = 0;
24
-
25
- @Query.asNumber("size")
26
- size: number = 50;
27
-
28
- @Query("search")
29
- search: string;
30
-
31
- @Route("type")
32
- type: string;
33
-
34
- @Query.asNumber("cacheSeconds")
35
- cacheSeconds: number;
36
-
37
- @Query.caseInsensitiveAsBoolean
38
- withoutCdn: string;
39
-
40
- @Inject
41
- sessionSecurity: SessionSecurity;
42
-
43
- @Inject
44
- es: EncryptionService;
45
-
46
- async run() {
47
-
48
- let q = this.db.websiteFolders.asQuery();
49
-
50
- let isWebSiteTemplate = false;
51
-
52
- switch(this.type?.toLowerCase()) {
53
- case "design":
54
- case "designs":
55
- q = q.where((x) => x.isDesign === true);
56
- break;
57
- default:
58
- q = q.where((x) => x.isTemplate === true);
59
- isWebSiteTemplate = true;
60
- break;
61
- }
62
-
63
- const { search = "" } = this;
64
- if (search) {
65
- const tokens = search.split(/[\,\s]+/g);
66
- const words = tokens.filter((t) => t?.length > 3)
67
- .map((t) => `%${t}%`);
68
- const ids = tokens.filter((t) => /^\d+$/i.test(t)) as any[];
69
- if (ids.length) {
70
- q = q.where({ words, ids }, (x, p) =>
71
- Sql.in(x.folderID, p.ids)
72
- || Sql.text.likeAny(x.folder.name, p.words));
73
- } else {
74
- q = q.where({ words }, (x, p) => Sql.text.likeAny(x.folder.name, p.words));
75
- }
76
- }
77
-
78
- if (this.tags) {
79
- const tags = this.tags.toLowerCase().split(/[\,\;\s]+/g).filter((x) => x);
80
- if (tags.length) {
81
- q = q.where({ tags }, (x, p) => x.webSiteTags.some((t) => Sql.in(t.tag.lowerCaseName, p.tags)));
82
- }
83
- }
84
-
85
- const start = Number(this.start) || 0;
86
-
87
- const size = Math.max(50, this.size ?? 20);
88
-
89
- // host must exist
90
-
91
- const list = await q
92
- .where((x) => x.currentVersionID !== null && x.hosts.some((h) => h.host !== null))
93
- .orderByDescending((x) => x.templateSites)
94
- .include((x) => [x.folder, x.currentVersion, x.hosts, x.webSiteTags.forEach((t) => t.tag)])
95
- .toPage(start, size);
96
-
97
- if(!isWebSiteTemplate) {
98
- const ids = [];
99
- for (const file of list.items) {
100
- ids.push(file.currentVersionID);
101
- }
102
- if (ids.length) {
103
- await this.db.appFiles.where({ ids }, (x, p) => Sql.in(x.parentID, p.ids)
104
- && x.isDeleted === false
105
- && (
106
- x.name === "preview.svg"
107
- || x.name === "preview.png"
108
- || x.name === "template.html"
109
- ) ).toArray();
110
- }
111
- }
112
-
113
- const cdn = this.withoutCdn
114
- ? this.request.hostName
115
- : globalEnv.cdn ?? this.request.hostName;
116
-
117
- const items = isWebSiteTemplate
118
- ? list.items.map((x) => {
119
- const { host } = x.hosts[0];
120
- return {
121
- id: x.folderID,
122
- tags: x.webSiteTags?.map((t) => t.tag.name) ?? [],
123
- name: x.folder.name,
124
- title: x.title,
125
- host,
126
- ... WebUrl.templatePreviewUrls(x, this.withoutCdn ? this.request.hostName : void 0),
127
- url: `https://${host}`
128
- };
129
- })
130
- : list.items.map((x) => {
131
- const { host } = x.hosts[0];
132
- const { currentVersion } = x;
133
-
134
- let previewFile: AppFile;
135
- let templateFile: AppFile;
136
- for (const cf of currentVersion.children) {
137
- switch(cf.name) {
138
- case "template.html":
139
- templateFile = cf;
140
- break;
141
- case "preview.png":
142
- previewFile = cf;
143
- break;
144
- case "preview.svg":
145
- previewFile = previewFile ?? cf;
146
- break;
147
- }
148
- }
149
-
150
- this.sessionSecurity.injectPublicKey(previewFile);
151
- this.sessionSecurity.injectPublicKey(templateFile);
152
-
153
- const fd = (file: AppFile) => {
154
- const { $key } = file as any;
155
- const eFileContentID = this.es.general.encrypt(file.fileContentID as any);
156
- return `https://${cdn}/social-mail/fd/view/${$key}/${eFileContentID}/${file.name}`;
157
- };
158
-
159
- return {
160
- id: x.folderID,
161
- tags: x.webSiteTags?.map((t) => t.tag.name) ?? [],
162
- name: x.folder.name,
163
- title: x.title,
164
- host,
165
- preview: fd(previewFile),
166
- template: fd(templateFile),
167
- url: `https://${host}`
168
- };
169
- })
170
- ;
171
-
172
- const headers = /^((www|tools)\.)?esocialmail.com$/i.test(this.request.hostName)
173
- ? CORS.allowAll
174
- : void 0;
175
-
176
- const cacheSeconds = this.cacheSeconds || 900;
177
- this.cacheControl = `public, max-age=${cacheSeconds}`;
178
-
179
- return this.json({
180
- items,
181
- hasMore: list.more
182
- }, void 0, headers);
183
- }
184
- }
@@ -1,2 +0,0 @@
1
- import CorsOptionsPage from "../../../../../../common/CorsOptionsPage.js";
2
- export default CorsOptionsPage;