@live-change/url-service 0.3.9 → 0.3.10

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 (3) hide show
  1. package/index.js +55 -1
  2. package/model.js +26 -2
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -14,7 +14,7 @@ const {
14
14
  urlWriterRoles = ['writer']
15
15
  } = config
16
16
 
17
- const { Canonical, Redirect, UrlToTarget } = require("./model.js")
17
+ const { Canonical, Redirect, UrlToTarget, UrlToTargetWithoutDomain } = require("./model.js")
18
18
 
19
19
  definition.view({
20
20
  name: "urlsByTargetAndPath",
@@ -50,6 +50,60 @@ definition.view({
50
50
  }
51
51
  })
52
52
 
53
+ definition.view({
54
+ name: "urlsByTargetType",
55
+ properties: {
56
+ targetType: {
57
+ type: String,
58
+ validation: ['nonEmpty']
59
+ }
60
+ },
61
+ returns: {
62
+ type: Object,
63
+ properties: {
64
+ urlType: {
65
+ type: String,
66
+ },
67
+ target: {
68
+ type: String
69
+ }
70
+ }
71
+ },
72
+ daoPath(params, { client, service }, method) {
73
+ const { targetType } = params
74
+ const dp = UrlToTargetWithoutDomain.rangePath([ targetType ], App.extractRange(params))
75
+ //console.log("URLS PATH", params, '=>', dp)
76
+ return dp
77
+ }
78
+ })
79
+
80
+ definition.view({
81
+ name: "urlsByTargetTypeAndDomain",
82
+ properties: {
83
+ targetType: {
84
+ type: String,
85
+ validation: ['nonEmpty']
86
+ }
87
+ },
88
+ returns: {
89
+ type: Object,
90
+ properties: {
91
+ urlType: {
92
+ type: String,
93
+ },
94
+ target: {
95
+ type: String
96
+ }
97
+ }
98
+ },
99
+ daoPath(params, { client, service }, method) {
100
+ const { targetType, domain } = params
101
+ const dp = UrlToTarget.rangePath([ targetType, domain ], App.extractRange(params))
102
+ //console.log("URLS PATH", params, '=>', dp)
103
+ return dp
104
+ }
105
+ })
106
+
53
107
  const randomLettersBig = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
54
108
  const randomLettersSmall = 'abcdefghijklmnopqrstuvwxyz'
55
109
  const randomDigits = '0123456789'
package/model.js CHANGED
@@ -62,7 +62,11 @@ const UrlToTarget = definition.index({
62
62
  name: 'Urls',
63
63
  function: async function(input, output) {
64
64
  const urlMapper = urlType => ({targetType, domain, path, target}) =>
65
- ({ id: `"${targetType}":${JSON.stringify(domain)}:${JSON.stringify(path)}_"${target}"`, target, type: urlType })
65
+ ({
66
+ id: `"${targetType}":${JSON.stringify(domain)}:${JSON.stringify(path)}_"${target}"`,
67
+ target, domain, path,
68
+ type: urlType
69
+ })
66
70
  const redirectMapper = urlMapper('redirect')
67
71
  const canonicalMapper = urlMapper('canonical')
68
72
  await input.table('url_Redirect').onChange(
@@ -74,4 +78,24 @@ const UrlToTarget = definition.index({
74
78
  }
75
79
  })
76
80
 
77
- module.exports = { Canonical, Redirect, UrlToTarget }
81
+ const UrlToTargetWithoutDomain = definition.index({
82
+ name: 'UrlsWithoutDomain',
83
+ function: async function(input, output) {
84
+ const urlMapper = urlType => ({targetType, domain, path, target}) =>
85
+ ({
86
+ id: `"${targetType}":${JSON.stringify(path)}_"${target}"`,
87
+ target, domain, path,
88
+ type: urlType
89
+ })
90
+ const redirectMapper = urlMapper('redirect')
91
+ const canonicalMapper = urlMapper('canonical')
92
+ await input.table('url_Redirect').onChange(
93
+ (obj, oldObj) => output.change(obj && redirectMapper(obj), oldObj && redirectMapper(oldObj))
94
+ )
95
+ await input.table('url_Canonical').onChange(
96
+ (obj, oldObj) => output.change(obj && canonicalMapper(obj), oldObj && canonicalMapper(oldObj))
97
+ )
98
+ }
99
+ })
100
+
101
+ module.exports = { Canonical, Redirect, UrlToTarget, UrlToTargetWithoutDomain }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/url-service",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,12 +21,12 @@
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "0.7.6",
25
- "@live-change/relations-plugin": "0.7.6",
24
+ "@live-change/framework": "0.7.8",
25
+ "@live-change/relations-plugin": "0.7.8",
26
26
  "lru-cache": "^7.12.0",
27
27
  "pluralize": "8.0.0",
28
28
  "progress-stream": "^2.0.0",
29
29
  "prosemirror-model": "^1.18.1"
30
30
  },
31
- "gitHead": "5450bfda7a0eabc71152e8ebfc87d9e7ebf5448f"
31
+ "gitHead": "2517a729c452633bc3ce9725c05005a66b8f78ee"
32
32
  }