terminusdb 12.0.2

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 (86) hide show
  1. package/Contributing.md +36 -0
  2. package/LICENSE +201 -0
  3. package/README.md +175 -0
  4. package/RELEASE_NOTES.md +462 -0
  5. package/dist/index.html +22 -0
  6. package/dist/terminusdb-client.min.js +3 -0
  7. package/dist/terminusdb-client.min.js.LICENSE.txt +188 -0
  8. package/dist/terminusdb-client.min.js.map +1 -0
  9. package/dist/typescript/index.d.ts +14 -0
  10. package/dist/typescript/lib/accessControl.d.ts +554 -0
  11. package/dist/typescript/lib/axiosInstance.d.ts +2 -0
  12. package/dist/typescript/lib/connectionConfig.d.ts +381 -0
  13. package/dist/typescript/lib/const.d.ts +54 -0
  14. package/dist/typescript/lib/dispatchRequest.d.ts +17 -0
  15. package/dist/typescript/lib/errorMessage.d.ts +25 -0
  16. package/dist/typescript/lib/query/woqlBuilder.d.ts +75 -0
  17. package/dist/typescript/lib/query/woqlCore.d.ts +341 -0
  18. package/dist/typescript/lib/query/woqlDoc.d.ts +63 -0
  19. package/dist/typescript/lib/query/woqlLibrary.d.ts +718 -0
  20. package/dist/typescript/lib/query/woqlPrinter.d.ts +71 -0
  21. package/dist/typescript/lib/query/woqlQuery.d.ts +833 -0
  22. package/dist/typescript/lib/typedef.d.ts +624 -0
  23. package/dist/typescript/lib/utils.d.ts +199 -0
  24. package/dist/typescript/lib/valueHash.d.ts +146 -0
  25. package/dist/typescript/lib/viewer/chartConfig.d.ts +62 -0
  26. package/dist/typescript/lib/viewer/chooserConfig.d.ts +38 -0
  27. package/dist/typescript/lib/viewer/documentFrame.d.ts +44 -0
  28. package/dist/typescript/lib/viewer/frameConfig.d.ts +74 -0
  29. package/dist/typescript/lib/viewer/frameRule.d.ts +145 -0
  30. package/dist/typescript/lib/viewer/graphConfig.d.ts +73 -0
  31. package/dist/typescript/lib/viewer/objectFrame.d.ts +212 -0
  32. package/dist/typescript/lib/viewer/streamConfig.d.ts +23 -0
  33. package/dist/typescript/lib/viewer/tableConfig.d.ts +66 -0
  34. package/dist/typescript/lib/viewer/terminusRule.d.ts +75 -0
  35. package/dist/typescript/lib/viewer/viewConfig.d.ts +47 -0
  36. package/dist/typescript/lib/viewer/woqlChart.d.ts +1 -0
  37. package/dist/typescript/lib/viewer/woqlChooser.d.ts +56 -0
  38. package/dist/typescript/lib/viewer/woqlGraph.d.ts +26 -0
  39. package/dist/typescript/lib/viewer/woqlPaging.d.ts +1 -0
  40. package/dist/typescript/lib/viewer/woqlResult.d.ts +128 -0
  41. package/dist/typescript/lib/viewer/woqlRule.d.ts +96 -0
  42. package/dist/typescript/lib/viewer/woqlStream.d.ts +31 -0
  43. package/dist/typescript/lib/viewer/woqlTable.d.ts +102 -0
  44. package/dist/typescript/lib/viewer/woqlView.d.ts +49 -0
  45. package/dist/typescript/lib/woql.d.ts +1267 -0
  46. package/dist/typescript/lib/woqlClient.d.ts +1216 -0
  47. package/index.js +28 -0
  48. package/lib/.eslintrc +1 -0
  49. package/lib/accessControl.js +988 -0
  50. package/lib/axiosInstance.js +5 -0
  51. package/lib/connectionConfig.js +765 -0
  52. package/lib/const.js +59 -0
  53. package/lib/dispatchRequest.js +236 -0
  54. package/lib/errorMessage.js +110 -0
  55. package/lib/query/woqlBuilder.js +234 -0
  56. package/lib/query/woqlCore.js +934 -0
  57. package/lib/query/woqlDoc.js +177 -0
  58. package/lib/query/woqlLibrary.js +1015 -0
  59. package/lib/query/woqlPrinter.js +476 -0
  60. package/lib/query/woqlQuery.js +1865 -0
  61. package/lib/typedef.js +248 -0
  62. package/lib/utils.js +817 -0
  63. package/lib/valueHash.js_old +581 -0
  64. package/lib/viewer/chartConfig.js +411 -0
  65. package/lib/viewer/chooserConfig.js +234 -0
  66. package/lib/viewer/documentFrame.js +206 -0
  67. package/lib/viewer/frameConfig.js +469 -0
  68. package/lib/viewer/frameRule.js +519 -0
  69. package/lib/viewer/graphConfig.js +345 -0
  70. package/lib/viewer/objectFrame.js +1550 -0
  71. package/lib/viewer/streamConfig.js +82 -0
  72. package/lib/viewer/tableConfig.js +310 -0
  73. package/lib/viewer/terminusRule.js +196 -0
  74. package/lib/viewer/viewConfig.js +219 -0
  75. package/lib/viewer/woqlChart.js +17 -0
  76. package/lib/viewer/woqlChooser.js +171 -0
  77. package/lib/viewer/woqlGraph.js +295 -0
  78. package/lib/viewer/woqlPaging.js +148 -0
  79. package/lib/viewer/woqlResult.js +258 -0
  80. package/lib/viewer/woqlRule.js +312 -0
  81. package/lib/viewer/woqlStream.js +27 -0
  82. package/lib/viewer/woqlTable.js +332 -0
  83. package/lib/viewer/woqlView.js +107 -0
  84. package/lib/woql.js +1693 -0
  85. package/lib/woqlClient.js +2091 -0
  86. package/package.json +110 -0
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Check if an object is already a converted WOQL Value structure
3
+ * @param {object} obj
4
+ * @returns {boolean}
5
+ */
6
+ function isAlreadyConverted(obj) {
7
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
8
+ return false;
9
+ }
10
+ // A converted Value has @type: 'Value' and one of: dictionary, list, data, node, variable
11
+ if (obj['@type'] === 'Value') {
12
+ return (
13
+ obj.dictionary !== undefined
14
+ || obj.list !== undefined
15
+ || obj.data !== undefined
16
+ || obj.node !== undefined
17
+ || obj.variable !== undefined
18
+ );
19
+ }
20
+ return false;
21
+ }
22
+
23
+ // eslint-disable-next-line consistent-return
24
+ function convert(obj) {
25
+ if (obj == null) {
26
+ return null;
27
+ } if (isAlreadyConverted(obj)) {
28
+ // Object is already a converted WOQL Value structure, return as-is
29
+ return obj;
30
+ } if (typeof (obj) === 'number') {
31
+ return {
32
+ '@type': 'Value',
33
+ data: {
34
+ '@type': 'xsd:decimal',
35
+ '@value': obj,
36
+ },
37
+ };
38
+ } if (typeof (obj) === 'boolean') {
39
+ return {
40
+ '@type': 'Value',
41
+ data: {
42
+ '@type': 'xsd:boolean',
43
+ '@value': obj,
44
+ },
45
+ };
46
+ } if (typeof (obj) === 'string') {
47
+ if (obj.indexOf('v:') === -1) {
48
+ return {
49
+ '@type': 'Value',
50
+ data: {
51
+ '@type': 'xsd:string',
52
+ '@value': obj,
53
+ },
54
+ };
55
+ }
56
+
57
+ return {
58
+ '@type': 'Value',
59
+ variable: obj.split(':')[1],
60
+ };
61
+
62
+ // eslint-disable-next-line no-use-before-define
63
+ } if (obj instanceof Var) {
64
+ return {
65
+ '@type': 'Value',
66
+ variable: obj.name,
67
+ };
68
+ } if (typeof (obj) === 'object' && !Array.isArray(obj)) {
69
+ const pairs = [];
70
+ // eslint-disable-next-line no-restricted-syntax
71
+ for (const [key, value] of Object.entries(obj)) {
72
+ pairs.push({
73
+ '@type': 'FieldValuePair',
74
+ field: key,
75
+ value: convert(value),
76
+ });
77
+ }
78
+ return {
79
+ '@type': 'Value',
80
+ dictionary: {
81
+ '@type': 'DictionaryTemplate',
82
+ data: pairs,
83
+ },
84
+ };
85
+ } if (typeof (obj) === 'object' && Array.isArray(obj)) {
86
+ const list = obj.map(convert);
87
+ return {
88
+ '@type': 'Value',
89
+ list,
90
+ };
91
+ }
92
+ }
93
+
94
+ /**
95
+ * @param {string} name The variable name
96
+ * @returns {Var}
97
+ */
98
+ function Var(name) {
99
+ this.name = name;
100
+ this.json = function () {
101
+ return {
102
+ '@type': 'Value',
103
+ variable: this.name,
104
+ };
105
+ };
106
+ }
107
+
108
+ let uniqueVarCounter = 0;
109
+ /**
110
+ * @param {string} name The variable name
111
+ * @returns {VarUnique}
112
+ */
113
+ function VarUnique(name) {
114
+ uniqueVarCounter += 1;
115
+ const localName = `${name}_${uniqueVarCounter}`;
116
+ this.name = localName;
117
+ this.json = function () {
118
+ return {
119
+ '@type': 'Value',
120
+ variable: this.name,
121
+ };
122
+ };
123
+ }
124
+ // Inherit Var prototype chain for VarUnique to pass instanceof check for Var (same)
125
+ VarUnique.prototype = Object.create(Var.prototype);
126
+
127
+ /**
128
+ * Reset the unique variable counter to a specific value
129
+ * @param {number} start - starting value
130
+ */
131
+ function SetVarsUniqueCounter(start) {
132
+ uniqueVarCounter = start;
133
+ }
134
+
135
+ /**
136
+ * @param {object} name
137
+ * @returns {object}
138
+ */
139
+ function Doc(obj) {
140
+ this.doc = obj;
141
+ this.encoded = convert(obj);
142
+ return this.encoded;
143
+ }
144
+
145
+ /**
146
+ * @param {...string} varNames
147
+ * @returns {object<Var>}
148
+ */
149
+ function Vars(...args) {
150
+ const varObj = {};
151
+ for (let i = 0, j = args.length; i < j; i += 1) {
152
+ const argumentName = args[i];
153
+
154
+ // this[argumentName] = new Var(argumentName);
155
+ varObj[argumentName] = new Var(argumentName);
156
+ }
157
+ return varObj;
158
+ }
159
+
160
+ /**
161
+ * @param {...string} varNames
162
+ * @returns {object<Var>}
163
+ */
164
+ function VarsUnique(...args) {
165
+ const varObj = {};
166
+ for (let i = 0, j = args.length; i < j; i += 1) {
167
+ const argumentName = args[i];
168
+
169
+ uniqueVarCounter += 1;
170
+ varObj[argumentName] = new Var(argumentName + (uniqueVarCounter ? `_${uniqueVarCounter}` : ''));
171
+ }
172
+ return varObj;
173
+ }
174
+
175
+ module.exports = {
176
+ Vars, VarsUnique, Var, VarUnique, Doc, SetVarsUniqueCounter,
177
+ };