dbm-graph-api 1.1.10 → 1.1.12

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.1.10",
3
+ "version": "1.1.12",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@aws-sdk/client-s3": "^3.741.0",
15
15
  "@aws-sdk/s3-request-presigner": "^3.741.0",
16
- "dbm": "^1.1.6",
16
+ "dbm": "^1.1.8",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -111,6 +111,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
111
111
  }
112
112
  catch(theError) {
113
113
  logs.push(theError.message);
114
+ console.error(theError);
114
115
  }
115
116
 
116
117
  this._webSocket.send(JSON.stringify({"type": "range/response", "ids": ids, "requestId": data["requestId"], "logs": logs}));
@@ -147,6 +148,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
147
148
  }
148
149
  catch(theError) {
149
150
  logs.push(theError.message);
151
+ console.error(theError);
150
152
  }
151
153
 
152
154
  this._webSocket.send(JSON.stringify({"type": "data/response", "data": returnData, "requestId": data["requestId"], "logs": logs}));
@@ -0,0 +1,52 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class AddAndProcessAction extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async performAction(aData, aEncodeSession) {
9
+ let returnObject = {};
10
+
11
+ let user = await aEncodeSession.outputController.getUser();
12
+
13
+ if(user) {
14
+ let type = aData["type"];
15
+
16
+ if(type) {
17
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
18
+ let action = await database.createObject("private", ["action"]);
19
+ returnObject["id"] = action.id;
20
+
21
+ let actionType = await database.getTypeObject("type/actionType", type);
22
+ await action.addIncomingRelation(actionType, "for");
23
+
24
+ if(aData["from"]) {
25
+ let fromItem = database.getItem(1*aData["from"]);
26
+ await action.addIncomingRelation(fromItem, "from");
27
+ }
28
+
29
+ let processingActionStatus = await database.getTypeObject("status/actionStatus", "processing");
30
+ await action.replaceIncomingRelation(processingActionStatus, "for", "status/actionStatus");
31
+
32
+ let processActionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/processAction/" + type);
33
+
34
+ if(processActionItem) {
35
+
36
+ await processActionItem.controller.process(action);
37
+
38
+ let doneActionStatus = await database.getTypeObject("status/actionStatus", "done");
39
+ await action.replaceIncomingRelation(doneActionStatus, "for", "status/actionStatus");
40
+ }
41
+ else {
42
+ let doneActionStatus = await database.getTypeObject("status/actionStatus", "noAction");
43
+ await action.replaceIncomingRelation(doneActionStatus, "for", "status/actionStatus");
44
+ }
45
+ }
46
+
47
+
48
+ }
49
+
50
+ return returnObject;
51
+ }
52
+ }
@@ -0,0 +1 @@
1
+ export {default as AddAndProcessAction} from "./AddAndProcessAction.js";
@@ -23,7 +23,7 @@ export default class ProcessActions extends Dbm.core.BaseObject {
23
23
  let actionType = await (await action.singleObjectRelationQuery("in:for:type/actionType")).getIdentifier();
24
24
  console.log(actionType);
25
25
 
26
- let processActionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/procesAction/" + actionType);
26
+ let processActionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/processAction/" + actionType);
27
27
 
28
28
  if(processActionItem) {
29
29
 
@@ -1,4 +1,5 @@
1
1
  export {default as Example} from "./Example.js";
2
2
  export {default as IncomingWebhook} from "./IncomingWebhook.js";
3
3
 
4
- export * as cron from "./cron/index.js";
4
+ export * as cron from "./cron/index.js";
5
+ export * as admin from "./admin/index.js";
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class ReplaceIncomigRelation extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.replaceIncomingRelation(aData["value"], aData["type"], aData["objectType"]);
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class ReplaceOutgoingRelation extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.replaceOutgoingRelation(aData["value"], aData["type"]), aData["objectType"];
11
+ }
12
+ }
@@ -8,6 +8,8 @@ export {default as SetVisibility} from "./SetVisibility.js";
8
8
  export {default as AddIncomingRelation} from "./AddIncomingRelation.js";
9
9
  export {default as AddOutgoingRelation} from "./AddOutgoingRelation.js";
10
10
  export {default as ClearCloudflareCache} from "./ClearCloudflareCache.js";
11
+ export {default as ReplaceIncomingRelation} from "./ReplaceIncomingRelation.js";
12
+ export {default as ReplaceOutgoingRelation} from "./ReplaceOutgoingRelation.js";
11
13
 
12
14
  export const fullSetup = function() {
13
15
  let prefix = "graphApi/admin/edit/";
@@ -47,6 +49,18 @@ export const fullSetup = function() {
47
49
  currentSelect.item.register(prefix + name);
48
50
  }
49
51
 
52
+ {
53
+ let name = "replaceIncomingRelation";
54
+ let currentSelect = new DbmGraphApi.admin.edit.ReplaceIncomingRelation();
55
+ currentSelect.item.register(prefix + name);
56
+ }
57
+
58
+ {
59
+ let name = "replaceOutgoingRelation";
60
+ let currentSelect = new DbmGraphApi.admin.edit.ReplaceOutgoingRelation();
61
+ currentSelect.item.register(prefix + name);
62
+ }
63
+
50
64
  {
51
65
  let name = "clearCache";
52
66
  let currentSelect = new DbmGraphApi.admin.edit.ClearCloudflareCache();
@@ -0,0 +1,27 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class Breadcrumb extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async getData(aData, aEncodeSession) {
9
+ let returnObject = {};
10
+
11
+ let url = aData["path"];
12
+ if(url[url.length-1] !== "/") {
13
+ url += "/";
14
+ }
15
+
16
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
17
+ let urlObject = await database.getObjectByUrl(url);
18
+
19
+ if(urlObject) {
20
+
21
+ await aEncodeSession.encodeSingleWithTypes(urlObject.id, ["breadcrumb"]);
22
+ returnObject["id"] = urlObject.id;
23
+ }
24
+
25
+ return returnObject;
26
+ }
27
+ }
@@ -3,6 +3,7 @@ export {default as UploadS3} from "./UploadS3.js";
3
3
  export {default as FreeUrl} from "./FreeUrl.js";
4
4
  export {default as SeoSummary} from "./SeoSummary.js";
5
5
  export {default as AltText} from "./AltText.js";
6
+ export {default as Breadcrumb} from "./Breadcrumb.js";
6
7
 
7
8
  import UploadS3 from "./UploadS3.js";
8
9
 
@@ -44,6 +44,12 @@ let fullSelectSetup = function() {
44
44
  let currentSelect = new DbmGraphApi.range.select.IncludeDraft();
45
45
  currentSelect.item.register(selectPrefix + name);
46
46
  }
47
+
48
+ {
49
+ let name = "objectRelationQuery";
50
+ let currentSelect = new DbmGraphApi.range.select.ObjectRelationQuery();
51
+ currentSelect.item.register(selectPrefix + name);
52
+ }
47
53
  }
48
54
 
49
55
  export {fullSelectSetup};
@@ -133,6 +139,34 @@ let fullEncodeSetup = function() {
133
139
  currentEncode.item.register(encodePrefix + name);
134
140
  currentEncode.item.setValue("encodingType", name);
135
141
  }
142
+
143
+ {
144
+ let name = "relations";
145
+ let currentEncode = new DbmGraphApi.range.encode.Relations();
146
+ currentEncode.item.register(encodePrefix + name);
147
+ currentEncode.item.setValue("encodingType", name);
148
+ }
149
+
150
+ {
151
+ let name = "objectTypes";
152
+ let currentEncode = new DbmGraphApi.range.encode.ObjectTypes();
153
+ currentEncode.item.register(encodePrefix + name);
154
+ currentEncode.item.setValue("encodingType", name);
155
+ }
156
+
157
+ {
158
+ let name = "representingPage";
159
+ let currentEncode = new DbmGraphApi.range.encode.RepresentingPage();
160
+ currentEncode.item.register(encodePrefix + name);
161
+ currentEncode.item.setValue("encodingType", name);
162
+ }
163
+
164
+ {
165
+ let name = "pageRepresentation";
166
+ let currentEncode = new DbmGraphApi.range.encode.PageRepresentation();
167
+ currentEncode.item.register(encodePrefix + name);
168
+ currentEncode.item.setValue("encodingType", name);
169
+ }
136
170
  }
137
171
 
138
172
  export {fullEncodeSetup};
@@ -147,6 +181,9 @@ export let registerDataFunction = function(aName, aDataFunction) {
147
181
 
148
182
  let fullDataSetup = function() {
149
183
  registerDataFunction("example", new DbmGraphApi.data.Example());
184
+
185
+ registerDataFunction("breadcrumb", new DbmGraphApi.data.Breadcrumb());
186
+
150
187
  registerDataFunction("admin/freeUrl", new DbmGraphApi.data.FreeUrl());
151
188
  registerDataFunction("admin/seoSummary", new DbmGraphApi.data.SeoSummary());
152
189
  registerDataFunction("admin/altText", new DbmGraphApi.data.AltText());
@@ -166,6 +203,7 @@ let fullActionSetup = function() {
166
203
  registerActionFunction("example", new DbmGraphApi.action.Example());
167
204
  registerActionFunction("incomingWebhook", new DbmGraphApi.action.IncomingWebhook());
168
205
  registerActionFunction("cron/processActions", new DbmGraphApi.action.cron.ProcessActions());
206
+ registerActionFunction("admin/addAndProcessAction", new DbmGraphApi.action.admin.AddAndProcessAction());
169
207
  }
170
208
 
171
209
  export {fullActionSetup};
@@ -0,0 +1,19 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class ObjectTypes 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
+ returnObject["objectTypes"] = await object.getObjectTypes();
16
+
17
+ return returnObject;
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class PageRepresentation 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
+ returnObject["representing"] = await aEncodingSession.encodeObjectOrNull(await object.singleObjectRelationQuery("out:pageRepresentationFor:*"), "objectTypes");
16
+
17
+ return returnObject;
18
+ }
19
+ }
@@ -0,0 +1,23 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class Relations extends EncodeBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async getEncodedData(aId, aEncodingSession) {
10
+
11
+ let returnObject = {};
12
+
13
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
14
+
15
+ let object = database.getObject(aId);
16
+
17
+ let relations = await database.getAllRelations(aId);
18
+
19
+ returnObject["relations"] = relations;
20
+
21
+ return returnObject;
22
+ }
23
+ }
@@ -0,0 +1,22 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class RepresentingPage 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 representingPage = await object.singleObjectRelationQuery("in:pageRepresentationFor:*");
16
+
17
+ returnObject["representingPage"] = await aEncodingSession.encodeObjectOrNull(representingPage, "title");
18
+ await aEncodingSession.encodeObjectOrNull(representingPage, "url");
19
+
20
+ return returnObject;
21
+ }
22
+ }
@@ -17,6 +17,7 @@ export default class UrlRequest extends EncodeBaseObject {
17
17
  await aEncodingSession.encodeSingle(aId, "content");
18
18
  await aEncodingSession.encodeSingle(aId, "url");
19
19
  await aEncodingSession.encodeSingle(aId, "navigationName");
20
+ await aEncodingSession.encodeSingle(aId, "pageRepresentation");
20
21
 
21
22
  let fields = await object.getFields();
22
23
  returnObject["meta/description"] = fields["meta/description"] ? fields["meta/description"] : null;
@@ -11,4 +11,8 @@ export {default as Breadcrumb} from "./Breadcrumb.js";
11
11
  export {default as NavigationName} from "./NavigationName.js";
12
12
  export {default as Type} from "./Type.js";
13
13
  export {default as Image} from "./Image.js";
14
- export {default as Visibility} from "./Visibility.js";
14
+ export {default as Visibility} from "./Visibility.js";
15
+ export {default as Relations} from "./Relations.js";
16
+ export {default as ObjectTypes} from "./ObjectTypes.js";
17
+ export {default as RepresentingPage} from "./RepresentingPage.js";
18
+ export {default as PageRepresentation} from "./PageRepresentation.js";
@@ -0,0 +1,32 @@
1
+ import Dbm from "dbm";
2
+
3
+ import SelectBaseObject from "./SelectBaseObject.js";
4
+
5
+ export default class ObjectRelationQuery extends SelectBaseObject {
6
+ _construct() {
7
+ super._construct();
8
+ }
9
+
10
+ async select(aQuery, aData, aRequest) {
11
+ //console.log("ObjectRelationQuery::select");
12
+
13
+ if(!aData["path"]) {
14
+ throw("Parameter path not set");
15
+ }
16
+ if(!aData["fromIds"]) {
17
+ throw("Parameter fromIds not set");
18
+ }
19
+
20
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
21
+
22
+ let fromIds = Dbm.utils.ArrayFunctions.numericArrayOrSeparatedString(aData["fromIds"]);
23
+
24
+ let ids = await database.objectRelationQuery(fromIds, aData["path"]);
25
+
26
+ await aQuery.includeOnly(ids);
27
+ }
28
+
29
+ async filter(aIds, aData, aRequest) {
30
+ return aIds;
31
+ }
32
+ }
@@ -2,4 +2,5 @@ export {default as SelectBaseObject} from "./SelectBaseObject.js";
2
2
  export {default as IdSelection} from "./IdSelection.js";
3
3
  export {default as ByObjectType} from "./ByObjectType.js";
4
4
  export {default as IncludePrivate} from "./IncludePrivate.js";
5
- export {default as IncludeDraft} from "./IncludeDraft.js";
5
+ export {default as IncludeDraft} from "./IncludeDraft.js";
6
+ export {default as ObjectRelationQuery} from "./ObjectRelationQuery.js";