@social-mail/social-mail-client 1.8.333 → 1.8.334

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-client",
3
- "version": "1.8.333",
3
+ "version": "1.8.334",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,32 @@
1
+ import DISingleton from "@web-atoms/core/dist/di/DISingleton";
2
+ import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder";
3
+ import IPagedList from "@web-atoms/entity/dist/models/IPagedList";
4
+
5
+ export interface ISiteTemplate {
6
+ id: any;
7
+ tags: string[];
8
+ name: string;
9
+ host: string;
10
+ preview: string;
11
+ previewMobile: string;
12
+ template: string;
13
+ url: string;
14
+ }
15
+
16
+ @DISingleton()
17
+ export default class ToolService {
18
+
19
+
20
+ designs({ search, tags, start = 0, size = 50, cancelToken }) {
21
+ return FetchBuilder.get(`https://tools.esocialmail.com/social-mail/site/list/designs`)
22
+ .queries({
23
+ search,
24
+ tags,
25
+ start,
26
+ size
27
+ })
28
+ .cancelToken(cancelToken)
29
+ .asJson<IPagedList<ISiteTemplate>>();
30
+ }
31
+
32
+ }
@@ -1,59 +1,33 @@
1
1
  import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder";
2
2
  import { CacheTTL } from "../../../common/cache/CacheTTL";
3
3
  import { packageVersion } from "../../../common/PackageInfo";
4
- import { Sql } from "../../../common/Sql";
5
- import { ChannelEmail, IChannelEmail } from "../../../model/model";
6
4
  import ToolSection, { IToolItem } from "../section/ToolSection";
5
+ import ToolService, { ISiteTemplate } from "../ToolService";
6
+ import InjectProperty from "@web-atoms/core/dist/core/InjectProperty";
7
7
 
8
8
  const cacheVersion = packageVersion;
9
9
  const cacheSeconds = CacheTTL.seconds.oneDay;
10
10
 
11
11
 
12
- export default class BasicShapes extends ToolSection<IChannelEmail> {
12
+ export default class BasicShapes extends ToolSection<ISiteTemplate> {
13
+
14
+ @InjectProperty
15
+ tools: ToolService;
13
16
 
14
17
  get headerName() {
15
18
  return "Shapes";
16
19
  }
17
20
 
18
21
  async searchItems({ start, search, cancelToken }) {
19
- const contentTypes = ["image/%", "text/html"];
20
- const shape = "shape";
21
- let q = this.entityService.query(ChannelEmail, "libraryEmails")
22
- .where({ contentTypes, shape }, (p) => (x) => x.email.attachments.some((e) =>
23
- Sql.text.iLikeAny(e.contentType, p.contentTypes)
24
- && e.email.emailTags.some((t) => t.tag.parent.lowerCaseName === p.shape)
25
- ))
26
- ;
27
- if(search) {
28
- search += "%";
29
- q = q.where({ search }, (p) => (x) => Sql.text.iLike(x.email.subject, p.search));
30
- }
31
- return q
32
- .include((x) => [x.email.attachments, x.email.emailTags.forEach((t) => t.tag)])
33
- .toPagedList({
34
- start,
35
- cancelToken,
36
- size: 25,
37
- cacheSeconds,
38
- cacheVersion
39
- });
22
+ return this.tools.designs({ search, tags: "Shape", start, cancelToken, size: 50 });
40
23
  }
41
24
 
42
- asToolItem(x: IChannelEmail): IToolItem {
43
-
44
- const { email, emailID: id } = x;
45
- const { attachments: files, subject: title } = email;
25
+ asToolItem(x: ISiteTemplate): IToolItem {
46
26
 
47
- const preview = this.getFileType("preview.", ... files);
48
- const { src, href } = this.getFileType("template.", ... files);
27
+ const { id, preview, name: title, template: templateUrl } = x;
49
28
 
50
29
  const template = async () => {
51
- if (src) {
52
- const img = document.createElement("img");
53
- img.src = src;
54
- return img;
55
- }
56
- const text = await FetchBuilder.get(href).asText();
30
+ const text = await FetchBuilder.get(templateUrl).asText();
57
31
  const parser = new DOMParser();
58
32
  const d = parser.parseFromString(text, "text/html");
59
33
  const t = d.body.querySelector("template");
@@ -64,10 +38,13 @@ export default class BasicShapes extends ToolSection<IChannelEmail> {
64
38
 
65
39
  return {
66
40
  title,
67
- files,
41
+ files: [],
68
42
  id,
69
43
  copyAssets: true,
70
- preview,
44
+ preview: {
45
+ src: preview,
46
+ href: void 0
47
+ },
71
48
  template
72
49
  };
73
50
  }
@@ -1,59 +1,33 @@
1
1
  import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder";
2
2
  import { CacheTTL } from "../../../common/cache/CacheTTL";
3
3
  import { packageVersion } from "../../../common/PackageInfo";
4
- import { Sql } from "../../../common/Sql";
5
- import { ChannelEmail, IChannelEmail } from "../../../model/model";
6
4
  import ToolSection, { IToolItem } from "../section/ToolSection";
5
+ import InjectProperty from "@web-atoms/core/dist/core/InjectProperty";
6
+ import ToolService, { ISiteTemplate } from "../ToolService";
7
7
 
8
8
  const cacheVersion = packageVersion;
9
9
  const cacheSeconds = CacheTTL.seconds.oneDay;
10
10
 
11
11
 
12
- export default class Designs extends ToolSection<IChannelEmail> {
12
+ export default class Designs extends ToolSection<ISiteTemplate> {
13
+
14
+ @InjectProperty
15
+ tools: ToolService;
13
16
 
14
17
  get headerName() {
15
18
  return "Designs";
16
19
  }
17
20
 
18
21
  async searchItems({ start, search, cancelToken }) {
19
- const contentTypes = ["image/%", "text/html"];
20
- const shape = "design";
21
- let q = this.entityService.query(ChannelEmail, "libraryEmails")
22
- .where({ contentTypes, shape }, (p) => (x) => x.email.attachments.some((e) =>
23
- Sql.text.iLikeAny(e.contentType, p.contentTypes)
24
- && e.email.emailTags.some((t) => t.tag.lowerCaseName === p.shape)
25
- ))
26
- ;
27
- if(search) {
28
- search += "%";
29
- q = q.where({ search }, (p) => (x) => Sql.text.iLike(x.email.subject, p.search));
30
- }
31
- return q
32
- .include((x) => [x.email.attachments, x.email.emailTags.forEach((t) => t.tag)])
33
- .toPagedList({
34
- start,
35
- cancelToken,
36
- size: 25,
37
- cacheSeconds,
38
- cacheVersion
39
- });
22
+ return this.tools.designs({ search, tags: "Shape", start, cancelToken, size: 50 });
40
23
  }
41
24
 
42
- asToolItem(x: IChannelEmail): IToolItem {
43
-
44
- const { email, emailID: id } = x;
45
- const { attachments: files, subject: title } = email;
25
+ asToolItem(x: ISiteTemplate): IToolItem {
46
26
 
47
- const preview = this.getFileType("preview.", ... files);
48
- const { src, href } = this.getFileType("template.", ... files);
27
+ const { id, preview, name: title, template: templateUrl } = x;
49
28
 
50
29
  const template = async () => {
51
- if (src) {
52
- const img = document.createElement("img");
53
- img.src = src;
54
- return img;
55
- }
56
- const text = await FetchBuilder.get(href).asText();
30
+ const text = await FetchBuilder.get(templateUrl).asText();
57
31
  const parser = new DOMParser();
58
32
  const d = parser.parseFromString(text, "text/html");
59
33
  const t = d.body.querySelector("template");
@@ -64,10 +38,13 @@ export default class Designs extends ToolSection<IChannelEmail> {
64
38
 
65
39
  return {
66
40
  title,
67
- files,
41
+ files: [],
68
42
  id,
69
43
  copyAssets: true,
70
- preview,
44
+ preview: {
45
+ src: preview,
46
+ href: void 0
47
+ },
71
48
  template
72
49
  };
73
50
  }