@degenerate/generic 0.0.8 → 0.0.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 (127) hide show
  1. package/dist/_settings/cryptography-settings.d.ts +27 -0
  2. package/dist/_settings/cryptography-settings.d.ts.map +1 -0
  3. package/dist/_settings/cryptography-settings.js +27 -0
  4. package/dist/crypto/calculate-combined-hash.d.ts +13 -0
  5. package/dist/crypto/calculate-combined-hash.d.ts.map +1 -0
  6. package/dist/crypto/calculate-combined-hash.js +44 -0
  7. package/dist/crypto/calculate-hash.d.ts +7 -0
  8. package/dist/crypto/calculate-hash.d.ts.map +1 -0
  9. package/dist/crypto/calculate-hash.js +37 -0
  10. package/dist/crypto/index.d.ts +13 -0
  11. package/dist/crypto/index.d.ts.map +1 -0
  12. package/dist/crypto/index.js +34 -0
  13. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts +12 -0
  14. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +1 -0
  15. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.js +44 -0
  16. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts +11 -0
  17. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +1 -0
  18. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +40 -0
  19. package/dist/crypto/private-public-keys/generation/create-256-private-key-from-mnemonic.d.ts +11 -0
  20. package/dist/crypto/private-public-keys/generation/create-256-private-key-from-mnemonic.d.ts.map +1 -0
  21. package/dist/crypto/private-public-keys/generation/create-256-private-key-from-mnemonic.js +45 -0
  22. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts +10 -0
  23. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +1 -0
  24. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.js +40 -0
  25. package/dist/crypto/private-public-keys/generation/create-random-256-private-key.d.ts +8 -0
  26. package/dist/crypto/private-public-keys/generation/create-random-256-private-key.d.ts.map +1 -0
  27. package/dist/crypto/private-public-keys/generation/create-random-256-private-key.js +41 -0
  28. package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts +11 -0
  29. package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +1 -0
  30. package/dist/crypto/private-public-keys/generation/generate-key-pair.js +39 -0
  31. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts +15 -0
  32. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +1 -0
  33. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.js +21 -0
  34. package/dist/crypto/signature/create-crypto-signature.d.ts +9 -0
  35. package/dist/crypto/signature/create-crypto-signature.d.ts.map +1 -0
  36. package/dist/crypto/signature/create-crypto-signature.js +13 -0
  37. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +13 -0
  38. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +1 -0
  39. package/dist/crypto/signature/verify-crypto-signature-by-data.js +45 -0
  40. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +13 -0
  41. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +1 -0
  42. package/dist/crypto/signature/verify-crypto-signature-by-hash.js +42 -0
  43. package/dist/errors/base-error.d.ts +23 -0
  44. package/dist/errors/base-error.d.ts.map +1 -0
  45. package/dist/errors/base-error.js +34 -0
  46. package/dist/errors/generic/generic-errors.d.ts +35 -0
  47. package/dist/errors/generic/generic-errors.d.ts.map +1 -0
  48. package/dist/errors/generic/generic-errors.js +47 -0
  49. package/dist/errors/index.d.ts +6 -0
  50. package/dist/errors/index.d.ts.map +1 -0
  51. package/dist/errors/index.js +21 -0
  52. package/dist/errors/request/request-errors.d.ts +89 -0
  53. package/dist/errors/request/request-errors.d.ts.map +1 -0
  54. package/dist/errors/request/request-errors.js +120 -0
  55. package/dist/errors/scheduler/scheduler-errors.d.ts +8 -0
  56. package/dist/errors/scheduler/scheduler-errors.d.ts.map +1 -0
  57. package/dist/errors/scheduler/scheduler-errors.js +14 -0
  58. package/dist/errors/share-data/share-data-errors.d.ts +49 -0
  59. package/dist/errors/share-data/share-data-errors.d.ts.map +1 -0
  60. package/dist/errors/share-data/share-data-errors.js +66 -0
  61. package/dist/helpers/array/array-helpers.d.ts +8 -0
  62. package/dist/helpers/array/array-helpers.d.ts.map +1 -0
  63. package/dist/helpers/array/array-helpers.js +14 -0
  64. package/dist/helpers/data/data-helpers.d.ts +46 -0
  65. package/dist/helpers/data/data-helpers.d.ts.map +1 -0
  66. package/dist/helpers/data/data-helpers.js +106 -0
  67. package/dist/helpers/file/file-helpers.d.ts +12 -0
  68. package/dist/helpers/file/file-helpers.d.ts.map +1 -0
  69. package/dist/helpers/file/file-helpers.js +39 -0
  70. package/dist/helpers/id-helpers.d.ts +8 -0
  71. package/dist/helpers/id-helpers.d.ts.map +1 -0
  72. package/dist/helpers/id-helpers.js +19 -0
  73. package/dist/helpers/index.d.ts +11 -0
  74. package/dist/helpers/index.d.ts.map +1 -0
  75. package/dist/helpers/index.js +31 -0
  76. package/dist/helpers/lodash/lodash-helpers.d.ts +14 -0
  77. package/dist/helpers/lodash/lodash-helpers.d.ts.map +1 -0
  78. package/dist/helpers/lodash/lodash-helpers.js +28 -0
  79. package/dist/helpers/object-helpers.d.ts +23 -0
  80. package/dist/helpers/object-helpers.d.ts.map +1 -0
  81. package/dist/helpers/object-helpers.js +54 -0
  82. package/dist/helpers/object-validation-helpers.d.ts +59 -0
  83. package/dist/helpers/object-validation-helpers.d.ts.map +1 -0
  84. package/dist/helpers/object-validation-helpers.js +233 -0
  85. package/dist/helpers/request/params-object-helpers.d.ts +38 -0
  86. package/dist/helpers/request/params-object-helpers.d.ts.map +1 -0
  87. package/dist/helpers/request/params-object-helpers.js +54 -0
  88. package/dist/helpers/request/query-object-helpers.d.ts +12 -0
  89. package/dist/helpers/request/query-object-helpers.d.ts.map +1 -0
  90. package/dist/helpers/request/query-object-helpers.js +25 -0
  91. package/dist/helpers/request/request-object-helpers.d.ts +19 -0
  92. package/dist/helpers/request/request-object-helpers.d.ts.map +1 -0
  93. package/dist/helpers/request/request-object-helpers.js +28 -0
  94. package/dist/index.d.ts +2 -0
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +3 -0
  97. package/dist/models/data/data-models.d.ts +24 -0
  98. package/dist/models/data/data-models.d.ts.map +1 -0
  99. package/dist/models/data/data-models.js +3 -0
  100. package/dist/models/dynamic-execution/dynamic-execution-models.d.ts +9 -0
  101. package/dist/models/dynamic-execution/dynamic-execution-models.d.ts.map +1 -0
  102. package/dist/models/dynamic-execution/dynamic-execution-models.js +2 -0
  103. package/dist/models/events/share-event-models.d.ts +65 -0
  104. package/dist/models/events/share-event-models.d.ts.map +1 -0
  105. package/dist/models/events/share-event-models.js +70 -0
  106. package/dist/models/functions/share-data-function-models.d.ts +86 -0
  107. package/dist/models/functions/share-data-function-models.d.ts.map +1 -0
  108. package/dist/models/functions/share-data-function-models.js +17 -0
  109. package/dist/models/generic/__tests__/request-response-models.d.ts +2 -0
  110. package/dist/models/generic/__tests__/request-response-models.d.ts.map +1 -0
  111. package/dist/models/generic/__tests__/request-response-models.js +33 -0
  112. package/dist/models/generic/request-response-models.d.ts +8 -0
  113. package/dist/models/generic/request-response-models.d.ts.map +1 -0
  114. package/dist/models/generic/request-response-models.js +2 -0
  115. package/dist/models/index.d.ts +8 -0
  116. package/dist/models/index.d.ts.map +1 -0
  117. package/dist/models/index.js +24 -0
  118. package/dist/models/rules/share-rule-models.d.ts +277 -0
  119. package/dist/models/rules/share-rule-models.d.ts.map +1 -0
  120. package/dist/models/rules/share-rule-models.js +107 -0
  121. package/dist/models/share-data/share-data.d.ts +55 -0
  122. package/dist/models/share-data/share-data.d.ts.map +1 -0
  123. package/dist/models/share-data/share-data.js +19 -0
  124. package/dist/share-data/share-data.d.ts +1 -0
  125. package/dist/share-data/share-data.d.ts.map +1 -0
  126. package/dist/share-data/share-data.js +166 -0
  127. package/package.json +1 -1
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ // This file contains the validation functions for objects.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.validateUrl = exports.validateString = exports.validateNumber = exports.validateDate = exports.validateBoolean = exports.validateArray = void 0;
5
+ /**
6
+ * Checks that an object is an array and that it has the minimum number of items.
7
+ *
8
+ * @param incomingObject the object to check
9
+ * @param minimumLength the minimum number of objects to match (zero by default)
10
+ * @param maximumLength the maximum number of objects to match will default to the array length if not provided
11
+ *
12
+ * @returns whether the criteria matches.
13
+ */
14
+ const validateArray = (incomingObject, minimumLength = 0, maximumLength) => {
15
+ if (incomingObject && Array.isArray(incomingObject) && incomingObject.length >= minimumLength) {
16
+ if (!maximumLength) {
17
+ return true;
18
+ }
19
+ else {
20
+ if (incomingObject.length <= maximumLength) {
21
+ return true;
22
+ }
23
+ else {
24
+ return false;
25
+ }
26
+ }
27
+ }
28
+ else {
29
+ return false;
30
+ }
31
+ };
32
+ exports.validateArray = validateArray;
33
+ /**
34
+ * This validates an incoming shape of a boolean type data.
35
+ *
36
+ * @param incomingObject an object to validate as a boolean.
37
+ * @param undefinedValid whether the item can be undefined or not (false by default)
38
+ *
39
+ * @returns whether the shape is valid.
40
+ */
41
+ const validateBoolean = (incomingObject, undefinedValid = false) => {
42
+ if (undefinedValid && typeof incomingObject === 'undefined') { // if undefined is valid and it"s undefined
43
+ return true;
44
+ }
45
+ if (typeof incomingObject === 'boolean') {
46
+ return true;
47
+ }
48
+ else {
49
+ return false;
50
+ }
51
+ };
52
+ exports.validateBoolean = validateBoolean;
53
+ /**
54
+ * This validates a date object or a string that can be converted to a date object.
55
+ * @param dateToValidate the date to validate
56
+ * @param undefinedValid whether the item can be undefined or not (false by default)
57
+ * @param allowFutureDated the date can be in the future (false by default)
58
+ * @param ensureAtLeast18YearsAgo whether the date is at least 18 years ago (true by default)
59
+ *
60
+ * @returns
61
+ */
62
+ const validateDate = (dateToValidate, undefinedValid = false, allowFutureDated = false, ensureAtLeast18YearsAgo = false) => {
63
+ if (undefinedValid && (typeof dateToValidate === 'undefined' || dateToValidate === '' || dateToValidate === null)) {
64
+ return true;
65
+ }
66
+ let date; // a placeholder for the date object
67
+ if (typeof dateToValidate === 'string') {
68
+ date = new Date(dateToValidate); // try to parse the date
69
+ if (isNaN(date.getTime())) { // if it's not a valid date
70
+ return false; // return false
71
+ }
72
+ return true;
73
+ }
74
+ else {
75
+ if (!(typeof dateToValidate === 'object' && dateToValidate !== null)) {
76
+ return false; // the date isn't an object
77
+ }
78
+ if (Object.prototype.toString.call(dateToValidate) !== '[object Date]') {
79
+ return false; // the date isn't a date object
80
+ }
81
+ // Check if the date is in the future and this is not allowed
82
+ if (!allowFutureDated && dateToValidate > new Date()) {
83
+ return false;
84
+ }
85
+ // determine if the date is newer than 18 years in the past
86
+ if (ensureAtLeast18YearsAgo) {
87
+ const today = new Date();
88
+ const eighteenYearsAgo = new Date(today.getFullYear() - 18, today.getMonth(), today.getDate());
89
+ return dateToValidate <= eighteenYearsAgo;
90
+ }
91
+ // otherwise the date is valid.
92
+ return true;
93
+ }
94
+ };
95
+ exports.validateDate = validateDate;
96
+ /**
97
+ * This validates that the incoming Object is a number and that it is in the range (if provided)
98
+ *
99
+ * @param incomingObject object to validate to a number
100
+ * @param min (optional) minimum number
101
+ * @param max (optional) maximum number
102
+ * @returns
103
+ */
104
+ const validateNumber = (incomingObject, min, max) => {
105
+ if (typeof incomingObject === 'number') {
106
+ if (validateMin(incomingObject, min) && validateMax(incomingObject, max)) {
107
+ return true;
108
+ }
109
+ else {
110
+ return false;
111
+ }
112
+ }
113
+ else {
114
+ return false;
115
+ }
116
+ };
117
+ exports.validateNumber = validateNumber;
118
+ /**
119
+ * This validates an incoming shape of a set of files links to the data.
120
+ *
121
+ * @param incomingObject an object to validate as a string.
122
+ * @param hasNoSpaces whether the item should have no spaces in it (false by default)
123
+ * @param undefinedValid whether the item can be undefined or not (false by default)
124
+ * @param emptyStringValid whether the item can be an empty string or not (false by default)
125
+ *
126
+ * @returns whether the shape is valid.
127
+ */
128
+ const validateString = (incomingObject, hasNoSpaces = false, undefinedValid = false, emptyStringValid = false) => {
129
+ // if undefined is valid and check if it's undefined and if so, return true
130
+ if (undefinedValid) {
131
+ if (typeof incomingObject === 'undefined') { // if undefined is valid and it"s undefined
132
+ return true;
133
+ }
134
+ if (incomingObject === null) { // include null values.
135
+ return true;
136
+ }
137
+ }
138
+ // Check if the string is empty and if it's valid to be empty
139
+ if (emptyStringValid) {
140
+ if (typeof incomingObject === 'string' && incomingObject.length === 0) {
141
+ return true;
142
+ }
143
+ }
144
+ // if it's a string and it's not empty
145
+ if (typeof incomingObject === 'string') {
146
+ // check that it is a string and that it is not empty
147
+ if (incomingObject.length === 0) {
148
+ return false;
149
+ }
150
+ // check if it has no spaces
151
+ if (hasNoSpaces) {
152
+ return incomingObject.indexOf(' ') === -1;
153
+ }
154
+ // otherwise it's a valid string
155
+ return true;
156
+ }
157
+ else {
158
+ return false;
159
+ }
160
+ };
161
+ exports.validateString = validateString;
162
+ /**
163
+ * This validates that an incoming object is a valid URL.
164
+ *
165
+ * @param incomingUrl the URL to check
166
+ * @param undefinedValid whether the item can be undefined or not (false by default)
167
+ * @returns wether it is a valid URL or not
168
+ */
169
+ const validateUrl = (incomingUrl, undefinedValid = false) => {
170
+ if (undefinedValid && (typeof incomingUrl === 'undefined' || incomingUrl === '')) { // if undefined is valid and it"s undefined
171
+ return true;
172
+ }
173
+ if (typeof incomingUrl !== 'string') {
174
+ return false;
175
+ }
176
+ if (incomingUrl.indexOf(' ') !== -1) {
177
+ return false;
178
+ }
179
+ //Is it recognized as a valid URL?
180
+ let givenURL;
181
+ try {
182
+ givenURL = new URL(incomingUrl);
183
+ //Is the domain name a valid one with TLD and using HTTP or HTTPS?
184
+ const validDomainRegexp = /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/im;
185
+ return validDomainRegexp.test(givenURL.host) && (givenURL.protocol === 'http:' || givenURL.protocol === 'https:');
186
+ }
187
+ catch (error) {
188
+ return false;
189
+ }
190
+ };
191
+ exports.validateUrl = validateUrl;
192
+ //#endregion Public Functions
193
+ //#region Internal Functions
194
+ /**
195
+ * validates that an incoming number is greater than the minimum if it was provided.
196
+ *
197
+ * @param incomingNumber the number to check
198
+ * @param min the minimum value.
199
+ * @returns
200
+ */
201
+ const validateMin = (incomingNumber, min) => {
202
+ if (typeof min === 'number') {
203
+ if (incomingNumber >= min) {
204
+ return true;
205
+ }
206
+ else {
207
+ return false;
208
+ }
209
+ }
210
+ else {
211
+ return true;
212
+ }
213
+ };
214
+ /**
215
+ * validates that an incoming number is less than or equal to the mamimum if it was provided.
216
+ *
217
+ * @param incomingNumber the number to check
218
+ * @param max the maximum value.
219
+ * @returns
220
+ */
221
+ const validateMax = (incomingNumber, max) => {
222
+ if (typeof max === 'number') {
223
+ if (incomingNumber <= max) {
224
+ return true;
225
+ }
226
+ else {
227
+ return false;
228
+ }
229
+ }
230
+ else {
231
+ return true;
232
+ }
233
+ };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The pattern for this is:
3
+ * Parameters are always in the request object and lowercase.
4
+ *
5
+ * const getExampleParamId = (req: any): string => {
6
+ * return req.params.exampleid;
7
+ * };
8
+ */
9
+ /**
10
+ * The function gets the share data id from the restful parameter object
11
+ *
12
+ * @param req the incoming request
13
+ * @returns
14
+ */
15
+ declare const getParamShareDataId: (req: any) => string;
16
+ /**
17
+ * The function gets the function id from the restful parameter object
18
+ *
19
+ * @param req the incoming request
20
+ * @returns
21
+ */
22
+ declare const getParamFunctionId: (req: any) => string;
23
+ /**
24
+ * The function gets the rule id from the restful parameter object
25
+ *
26
+ * @param req the incoming request
27
+ * @returns
28
+ */
29
+ declare const getParamRulesId: (req: any) => string;
30
+ /**
31
+ * The function gets the event id from the restful parameter object
32
+ *
33
+ * @param req the incoming request
34
+ * @returns
35
+ */
36
+ declare const getParamEventId: (req: any) => string;
37
+ export { getParamShareDataId, getParamFunctionId, getParamRulesId, getParamEventId };
38
+ //# sourceMappingURL=params-object-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/params-object-helpers.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAIH;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,QAAS,GAAG,KAAG,MAEvC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,QAAS,GAAG,KAAG,MAEtC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,QAAS,GAAG,KAAG,MAEnC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,QAAS,GAAG,KAAG,MAEnC,CAAA;AAID,OAAO,EACH,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAClB,CAAA"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ // This file contains the functions to get the incoming params in the request object.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getParamEventId = exports.getParamRulesId = exports.getParamFunctionId = exports.getParamShareDataId = void 0;
6
+ /**
7
+ * The pattern for this is:
8
+ * Parameters are always in the request object and lowercase.
9
+ *
10
+ * const getExampleParamId = (req: any): string => {
11
+ * return req.params.exampleid;
12
+ * };
13
+ */
14
+ // #region Network Requests
15
+ /**
16
+ * The function gets the share data id from the restful parameter object
17
+ *
18
+ * @param req the incoming request
19
+ * @returns
20
+ */
21
+ const getParamShareDataId = (req) => {
22
+ return req.params.sharedataid;
23
+ };
24
+ exports.getParamShareDataId = getParamShareDataId;
25
+ /**
26
+ * The function gets the function id from the restful parameter object
27
+ *
28
+ * @param req the incoming request
29
+ * @returns
30
+ */
31
+ const getParamFunctionId = (req) => {
32
+ return req.params.functionid;
33
+ };
34
+ exports.getParamFunctionId = getParamFunctionId;
35
+ /**
36
+ * The function gets the rule id from the restful parameter object
37
+ *
38
+ * @param req the incoming request
39
+ * @returns
40
+ */
41
+ const getParamRulesId = (req) => {
42
+ return req.params.rulesid;
43
+ };
44
+ exports.getParamRulesId = getParamRulesId;
45
+ /**
46
+ * The function gets the event id from the restful parameter object
47
+ *
48
+ * @param req the incoming request
49
+ * @returns
50
+ */
51
+ const getParamEventId = (req) => {
52
+ return req.params.eventid;
53
+ };
54
+ exports.getParamEventId = getParamEventId;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file contains the functions to get the incoming query in the request object.
3
+ */
4
+ /**
5
+ * Get the lastId from the query object and throw an error if it is not a string or not present.
6
+ *
7
+ * @param req the incoming request object
8
+ * @returns
9
+ */
10
+ declare const getQueryLastId: (req: any) => string;
11
+ export { getQueryLastId };
12
+ //# sourceMappingURL=query-object-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/query-object-helpers.ts"],"names":[],"mappings":"AACA;;GAEG;AAKH;;;;;GAKG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,KAAG,MAQlC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ /**
4
+ * This file contains the functions to get the incoming query in the request object.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getQueryLastId = void 0;
8
+ const request_errors_1 = require("../../errors/request/request-errors");
9
+ const object_validation_helpers_1 = require("../object-validation-helpers");
10
+ /**
11
+ * Get the lastId from the query object and throw an error if it is not a string or not present.
12
+ *
13
+ * @param req the incoming request object
14
+ * @returns
15
+ */
16
+ const getQueryLastId = (req) => {
17
+ const lastId = req.query.lastId;
18
+ // check if this was included in the query and it is a type of string.
19
+ const isValid = (0, object_validation_helpers_1.validateString)(lastId, true, false, true);
20
+ if (!isValid) {
21
+ throw new request_errors_1.RequestQueryNotValidError('lastId', lastId, 'string');
22
+ }
23
+ return req.query.lastId;
24
+ };
25
+ exports.getQueryLastId = getQueryLastId;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file contains the helper functions for the incoming request objects.
3
+ * It is used to set and get the user object from the request object.
4
+ */
5
+ /**
6
+ * This function sets the IUserWithClaims object into the req.user object.
7
+ * @param req the incoming request object
8
+ * @param userObject the user object to set
9
+ * @returns
10
+ */
11
+ declare const setUserRequest: (req: any, userObject: any) => void;
12
+ /**
13
+ * This function gets the user object from the request object.
14
+ * @param req the incoming request object
15
+ * @returns
16
+ */
17
+ declare const getUserRequest: (req: any) => any;
18
+ export { setUserRequest, getUserRequest };
19
+ //# sourceMappingURL=request-object-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/request-object-helpers.ts"],"names":[],"mappings":"AACA;;;GAGG;AAIH;;;;;GAKG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,cAAc,GAAG,KAAG,IAEnD,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,KAAG,GAElC,CAAC;AAGF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ /**
4
+ * This file contains the helper functions for the incoming request objects.
5
+ * It is used to set and get the user object from the request object.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.getUserRequest = exports.setUserRequest = void 0;
9
+ const USER_REQUEST_KEY = 'user';
10
+ /**
11
+ * This function sets the IUserWithClaims object into the req.user object.
12
+ * @param req the incoming request object
13
+ * @param userObject the user object to set
14
+ * @returns
15
+ */
16
+ const setUserRequest = (req, userObject) => {
17
+ req[USER_REQUEST_KEY] = userObject;
18
+ };
19
+ exports.setUserRequest = setUserRequest;
20
+ /**
21
+ * This function gets the user object from the request object.
22
+ * @param req the incoming request object
23
+ * @returns
24
+ */
25
+ const getUserRequest = (req) => {
26
+ return req[USER_REQUEST_KEY];
27
+ };
28
+ exports.getUserRequest = getUserRequest;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './_settings/cryptography-settings';
2
2
  export * from './crypto';
3
3
  export * from './errors';
4
+ export * from './helpers';
5
+ export * from './models';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAElD,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAElD,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -18,3 +18,6 @@ __exportStar(require("./_settings/cryptography-settings"), exports);
18
18
  // import * as crypto from './crypto'; this would become crypto.calculateHash ...
19
19
  __exportStar(require("./crypto"), exports);
20
20
  __exportStar(require("./errors"), exports);
21
+ __exportStar(require("./helpers"), exports);
22
+ __exportStar(require("./models"), exports);
23
+ // export * from './share-data/share-data';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This contains the minimum information that is needed on a data record.
3
+ */
4
+ export interface IGenericData {
5
+ createdAt: number;
6
+ createdBy: string;
7
+ updatedAt: number;
8
+ updatedBy: string;
9
+ versionNumber: number;
10
+ }
11
+ /**
12
+ * This contains the data for an item with a searchable index.
13
+ * for the word 'found' this object would look like this:
14
+ * {
15
+ * f: true,
16
+ * fo: true,
17
+ * fou: true,
18
+ * foun: true,
19
+ * found: true,
20
+ */
21
+ export interface ISearchableIndex {
22
+ [key: string]: true;
23
+ }
24
+ //# sourceMappingURL=data-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-models.d.ts","sourceRoot":"","sources":["../../../src/models/data/data-models.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /// This contains the models for data in the degenerate package
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file contains all models for the dynamic eexecution fo functions.
3
+ */
4
+ export interface IDynamicExecutionOutput {
5
+ output: any;
6
+ executionTime: number;
7
+ timeoutStepsConsumed: number;
8
+ }
9
+ //# sourceMappingURL=dynamic-execution-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-execution-models.d.ts","sourceRoot":"","sources":["../../../src/models/dynamic-execution/dynamic-execution-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,GAAG,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;CAChC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This contains the interfaces for all event data types that can be run on the network.
3
+ */
4
+ /**
5
+ * This is the types of events that can be run on the network.
6
+ */
7
+ export declare enum ShareEventType {
8
+ Application = "Application",
9
+ DataChange = "DataChange",
10
+ Scheduled = "Scheduled"
11
+ }
12
+ /**
13
+ * All sources of event trusts
14
+ */
15
+ export declare enum EventSourceTruthType {
16
+ Crypto = "Crypto",
17
+ Oauth = "Oauth",
18
+ ShareBlock = "ShareBlock"
19
+ }
20
+ /**
21
+ * All the types of proofs that can be sent from the sources of event execution truths.
22
+ */
23
+ export declare enum EventSourceTruthProofType {
24
+ Hash = "Hash",
25
+ Signature = "Signature"
26
+ }
27
+ /**
28
+ * This is the type of processing that can be done on the share data event.
29
+ */
30
+ export declare enum ShareDataEventProcessingType {
31
+ Parallel = "parallel",
32
+ Linear = "linear"
33
+ }
34
+ /**
35
+ * This is the interface for the share data event.
36
+ */
37
+ export interface ShareDataEvent {
38
+ eventId: string;
39
+ locked: boolean;
40
+ eventType: ShareEventType;
41
+ eventSource: string;
42
+ eventSourceTruthType: EventSourceTruthType;
43
+ eventSourceTruthProofType: EventSourceTruthProofType;
44
+ eventSourceTruthProof: string | number | Buffer;
45
+ triggerCondition: (...args: any[]) => boolean;
46
+ shareDataEventInformation: IShareDataEvent[];
47
+ eventContext?: object;
48
+ }
49
+ /**
50
+ * This is the interface for the share data event.
51
+ */
52
+ export interface IShareDataEvent {
53
+ shareData: IShareDataAndFunctionEvent[];
54
+ processingType: ShareDataEventProcessingType;
55
+ }
56
+ /**
57
+ * This is all data that is required to find the sharedata and function to execute.
58
+ */
59
+ export interface IShareDataAndFunctionEvent {
60
+ shareDataId: string;
61
+ functionId: string;
62
+ shareDataInputs: string[];
63
+ inputs: any;
64
+ }
65
+ //# sourceMappingURL=share-event-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-event-models.d.ts","sourceRoot":"","sources":["../../../src/models/events/share-event-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,oBAAY,cAAc;IACtB,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,SAAS,cAAc;CAC1B;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC5B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,UAAU,eAAe;CAC5B;AAED;;GAEG;AACH,oBAAY,yBAAyB;IACjC,IAAI,SAAS;IACb,SAAS,cAAc;CAC1B;AAED;;GAEG;AACH,oBAAY,4BAA4B;IACpC,QAAQ,aAAa;IACrB,MAAM,WAAW;CACpB;AAKD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,qBAAqB,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChD,gBAAgB,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;IAE9C,yBAAyB,EAAE,eAAe,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,0BAA0B,EAAE,CAAC;IACxC,cAAc,EAAE,4BAA4B,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,EAAE,GAAG,CAAC;CACf"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * This contains the interfaces for all event data types that can be run on the network.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ShareDataEventProcessingType = exports.EventSourceTruthProofType = exports.EventSourceTruthType = exports.ShareEventType = void 0;
7
+ //#region Share Event Data Enums
8
+ /**
9
+ * This is the types of events that can be run on the network.
10
+ */
11
+ var ShareEventType;
12
+ (function (ShareEventType) {
13
+ ShareEventType["Application"] = "Application";
14
+ ShareEventType["DataChange"] = "DataChange";
15
+ ShareEventType["Scheduled"] = "Scheduled";
16
+ })(ShareEventType || (exports.ShareEventType = ShareEventType = {}));
17
+ /**
18
+ * All sources of event trusts
19
+ */
20
+ var EventSourceTruthType;
21
+ (function (EventSourceTruthType) {
22
+ EventSourceTruthType["Crypto"] = "Crypto";
23
+ EventSourceTruthType["Oauth"] = "Oauth";
24
+ EventSourceTruthType["ShareBlock"] = "ShareBlock";
25
+ })(EventSourceTruthType || (exports.EventSourceTruthType = EventSourceTruthType = {}));
26
+ /**
27
+ * All the types of proofs that can be sent from the sources of event execution truths.
28
+ */
29
+ var EventSourceTruthProofType;
30
+ (function (EventSourceTruthProofType) {
31
+ EventSourceTruthProofType["Hash"] = "Hash";
32
+ EventSourceTruthProofType["Signature"] = "Signature";
33
+ })(EventSourceTruthProofType || (exports.EventSourceTruthProofType = EventSourceTruthProofType = {}));
34
+ /**
35
+ * This is the type of processing that can be done on the share data event.
36
+ */
37
+ var ShareDataEventProcessingType;
38
+ (function (ShareDataEventProcessingType) {
39
+ ShareDataEventProcessingType["Parallel"] = "parallel";
40
+ ShareDataEventProcessingType["Linear"] = "linear";
41
+ })(ShareDataEventProcessingType || (exports.ShareDataEventProcessingType = ShareDataEventProcessingType = {}));
42
+ // const applicationEvent: ShareDataEvent = {
43
+ // eventId: 'appEvent123',
44
+ // eventType: 'Application',
45
+ // eventSource: 'API',
46
+ // triggerCondition: () => true, // Always triggers for demonstration purposes
47
+ // shareDataEventInformation: [
48
+ // {
49
+ // shareData: [
50
+ // { shareDataId: shareDataIds[0], functionId: 'funcA', shareDataInputs: ['financial.principal', 'financial.time'], inputs: { rate: 0.45 } },
51
+ // { shareDataId: 'data2', functionId: 'funcB', shareDataInputs: {}, inputs: { rate: 0.45 } },
52
+ // { shareDataId: 'data3', functionId: 'funcC' },
53
+ // ],
54
+ // processingType: 'parallel', // Process in parallel
55
+ // },
56
+ // {
57
+ // shareData: [
58
+ // { shareDataId: 'data3', functionId: 'funcC' },
59
+ // { shareDataId: 'data4', functionId: 'funcD' },
60
+ // { shareDataId: 'data3', functionId: 'funcE' },
61
+ // ],
62
+ // processingType: 'linear', // Process in linear order
63
+ // },
64
+ // ],
65
+ // eventContext: {
66
+ // user: 'john_doe',
67
+ // timestamp: new Date().toISOString(),
68
+ // },
69
+ // };
70
+ // shareDataIds[0],