dbm-graph-api 1.0.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm-graph-api",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,6 +13,7 @@
13
13
  "dependencies": {
14
14
  "@aws-sdk/client-s3": "^3.693.0",
15
15
  "@aws-sdk/s3-request-presigner": "^3.693.0",
16
+ "dbm": "^1.0.0",
16
17
  "ws": "^8.18.0"
17
18
  }
18
19
  }
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class SetUrl extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ performChange(aObject, aData, aRequest) {
10
+ aObject.setUrl(aData["value"]);
11
+ }
12
+ }
@@ -2,6 +2,7 @@ import DbmGraphApi from "../../../../index.js";
2
2
  export {default as EditBaseObject} from "./EditBaseObject.js";
3
3
 
4
4
  export {default as SetField} from "./SetField.js";
5
+ export {default as SetUrl} from "./SetUrl.js";
5
6
  export {default as AddIncomingRelation} from "./AddIncomingRelation.js";
6
7
  export {default as AddOutgoingRelation} from "./AddOutgoingRelation.js";
7
8
 
@@ -13,6 +14,12 @@ let fullSetup = function() {
13
14
  currentSelect.item.register(prefix + name);
14
15
  }
15
16
 
17
+ {
18
+ let name = "setUrl";
19
+ let currentSelect = new DbmGraphApi.admin.edit.SetUrl();
20
+ currentSelect.item.register(prefix + name);
21
+ }
22
+
16
23
  {
17
24
  let name = "addIncomingRelation";
18
25
  let currentSelect = new DbmGraphApi.admin.edit.AddIncomingRelation();
@@ -0,0 +1,34 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class Example extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async getData(aData, aEncodeSession) {
9
+ let returnObject = {};
10
+
11
+ let requestedUrl = aData["url"];
12
+ let returnUrl = requestedUrl;
13
+
14
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
15
+
16
+ let urlObject = await database.getObjectByUrl(requestedUrl + "/");
17
+
18
+ if(urlObject) {
19
+ let exisitingUrls = await database.getUrlsForNextId(requestedUrl);
20
+ let idsToTry = exisitingUrls.length + 1;
21
+ for(let i = 0; i < idsToTry; i++) {
22
+ let currentId = i+2;
23
+ let testUrl = requestedUrl + "-" + currentId;
24
+ if(exisitingUrls.indexOf(testUrl + "/") === -1) {
25
+ returnUrl = testUrl;
26
+ }
27
+ }
28
+ }
29
+
30
+ returnObject["url"] = returnUrl;
31
+
32
+ return returnObject;
33
+ }
34
+ }
@@ -1,5 +1,6 @@
1
1
  export {default as Example} from "./Example.js";
2
2
  export {default as UploadS3} from "./UploadS3.js";
3
+ export {default as FreeUrl} from "./FreeUrl.js";
3
4
 
4
5
  import UploadS3 from "./UploadS3.js";
5
6
 
@@ -58,6 +58,13 @@ let fullEncodeSetup = function() {
58
58
  currentEncode.item.setValue("encodingType", name);
59
59
  }
60
60
 
61
+ {
62
+ let name = "url";
63
+ let currentEncode = new DbmGraphApi.range.encode.Url();
64
+ currentEncode.item.register(encodePrefix + name);
65
+ currentEncode.item.setValue("encodingType", name);
66
+ }
67
+
61
68
  {
62
69
  let name = "urlRequest";
63
70
  let currentEncode = new DbmGraphApi.range.encode.UrlRequest();
@@ -78,6 +85,7 @@ export let registerDataFunction = function(aName, aDataFunction) {
78
85
 
79
86
  let fullDataSetup = function() {
80
87
  registerDataFunction("example", new DbmGraphApi.data.Example());
88
+ registerDataFunction("admin/freeUrl", new DbmGraphApi.data.FreeUrl());
81
89
  }
82
90
 
83
91
  export {fullDataSetup};
@@ -0,0 +1,20 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class Url extends EncodeBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async getEncodedData(aId, aEncodingSession) {
10
+
11
+ let returnObject = {};
12
+
13
+ let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
14
+
15
+ let url = await object.getUrl();
16
+ returnObject["url"] = url;
17
+
18
+ return returnObject;
19
+ }
20
+ }
@@ -15,6 +15,7 @@ export default class UrlRequest extends EncodeBaseObject {
15
15
 
16
16
  await aEncodingSession.encodeSingle(aId, "title");
17
17
  await aEncodingSession.encodeSingle(aId, "content");
18
+ await aEncodingSession.encodeSingle(aId, "url");
18
19
 
19
20
  let fields = await object.getFields();
20
21
  returnObject["meta/description"] = fields["meta/description"] ? fields["meta/description"] : null;
@@ -5,4 +5,5 @@ export {default as Identifier} from "./Identifier.js";
5
5
  export {default as Name} from "./Name.js";
6
6
  export {default as Content} from "./Content.js";
7
7
  export {default as Title} from "./Title.js";
8
- export {default as UrlRequest} from "./UrlRequest.js";
8
+ export {default as UrlRequest} from "./UrlRequest.js";
9
+ export {default as Url} from "./Url.js";