@dbos-inc/dbos-sdk 0.7.18-preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/dbos-config.schema.json +121 -0
  4. package/dbos-test-config.yaml +16 -0
  5. package/dist/schemas/system_db_schema.d.ts +34 -0
  6. package/dist/schemas/system_db_schema.d.ts.map +1 -0
  7. package/dist/schemas/system_db_schema.js +75 -0
  8. package/dist/schemas/system_db_schema.js.map +1 -0
  9. package/dist/schemas/user_db_schema.d.ts +11 -0
  10. package/dist/schemas/user_db_schema.d.ts.map +1 -0
  11. package/dist/schemas/user_db_schema.js +16 -0
  12. package/dist/schemas/user_db_schema.js.map +1 -0
  13. package/dist/src/cloud-cli/applications/configure.d.ts +2 -0
  14. package/dist/src/cloud-cli/applications/configure.d.ts.map +1 -0
  15. package/dist/src/cloud-cli/applications/configure.js +57 -0
  16. package/dist/src/cloud-cli/applications/configure.js.map +1 -0
  17. package/dist/src/cloud-cli/applications/delete-app.d.ts +2 -0
  18. package/dist/src/cloud-cli/applications/delete-app.d.ts.map +1 -0
  19. package/dist/src/cloud-cli/applications/delete-app.js +36 -0
  20. package/dist/src/cloud-cli/applications/delete-app.js.map +1 -0
  21. package/dist/src/cloud-cli/applications/deploy-app-code.d.ts +2 -0
  22. package/dist/src/cloud-cli/applications/deploy-app-code.d.ts.map +1 -0
  23. package/dist/src/cloud-cli/applications/deploy-app-code.js +64 -0
  24. package/dist/src/cloud-cli/applications/deploy-app-code.js.map +1 -0
  25. package/dist/src/cloud-cli/applications/get-app-logs.d.ts +2 -0
  26. package/dist/src/cloud-cli/applications/get-app-logs.d.ts.map +1 -0
  27. package/dist/src/cloud-cli/applications/get-app-logs.js +37 -0
  28. package/dist/src/cloud-cli/applications/get-app-logs.js.map +1 -0
  29. package/dist/src/cloud-cli/applications/index.d.ts +8 -0
  30. package/dist/src/cloud-cli/applications/index.d.ts.map +1 -0
  31. package/dist/src/cloud-cli/applications/index.js +18 -0
  32. package/dist/src/cloud-cli/applications/index.js.map +1 -0
  33. package/dist/src/cloud-cli/applications/list-apps.d.ts +2 -0
  34. package/dist/src/cloud-cli/applications/list-apps.d.ts.map +1 -0
  35. package/dist/src/cloud-cli/applications/list-apps.js +45 -0
  36. package/dist/src/cloud-cli/applications/list-apps.js.map +1 -0
  37. package/dist/src/cloud-cli/applications/register-app.d.ts +2 -0
  38. package/dist/src/cloud-cli/applications/register-app.d.ts.map +1 -0
  39. package/dist/src/cloud-cli/applications/register-app.js +41 -0
  40. package/dist/src/cloud-cli/applications/register-app.js.map +1 -0
  41. package/dist/src/cloud-cli/applications/types.d.ts +7 -0
  42. package/dist/src/cloud-cli/applications/types.d.ts.map +1 -0
  43. package/dist/src/cloud-cli/applications/types.js +3 -0
  44. package/dist/src/cloud-cli/applications/types.js.map +1 -0
  45. package/dist/src/cloud-cli/applications/update-app.d.ts +2 -0
  46. package/dist/src/cloud-cli/applications/update-app.d.ts.map +1 -0
  47. package/dist/src/cloud-cli/applications/update-app.js +42 -0
  48. package/dist/src/cloud-cli/applications/update-app.js.map +1 -0
  49. package/dist/src/cloud-cli/cli.d.ts +3 -0
  50. package/dist/src/cloud-cli/cli.d.ts.map +1 -0
  51. package/dist/src/cloud-cli/cli.js +148 -0
  52. package/dist/src/cloud-cli/cli.js.map +1 -0
  53. package/dist/src/cloud-cli/login.d.ts +7 -0
  54. package/dist/src/cloud-cli/login.d.ts.map +1 -0
  55. package/dist/src/cloud-cli/login.js +40 -0
  56. package/dist/src/cloud-cli/login.js.map +1 -0
  57. package/dist/src/cloud-cli/register.d.ts +2 -0
  58. package/dist/src/cloud-cli/register.d.ts.map +1 -0
  59. package/dist/src/cloud-cli/register.js +35 -0
  60. package/dist/src/cloud-cli/register.js.map +1 -0
  61. package/dist/src/cloud-cli/userdb.d.ts +4 -0
  62. package/dist/src/cloud-cli/userdb.d.ts.map +1 -0
  63. package/dist/src/cloud-cli/userdb.js +149 -0
  64. package/dist/src/cloud-cli/userdb.js.map +1 -0
  65. package/dist/src/cloud-cli/utils.d.ts +3 -0
  66. package/dist/src/cloud-cli/utils.d.ts.map +1 -0
  67. package/dist/src/cloud-cli/utils.js +17 -0
  68. package/dist/src/cloud-cli/utils.js.map +1 -0
  69. package/dist/src/communicator.d.ts +24 -0
  70. package/dist/src/communicator.d.ts.map +1 -0
  71. package/dist/src/communicator.js +26 -0
  72. package/dist/src/communicator.js.map +1 -0
  73. package/dist/src/context.d.ts +60 -0
  74. package/dist/src/context.d.ts.map +1 -0
  75. package/dist/src/context.js +94 -0
  76. package/dist/src/context.js.map +1 -0
  77. package/dist/src/data_validation.d.ts +3 -0
  78. package/dist/src/data_validation.d.ts.map +1 -0
  79. package/dist/src/data_validation.js +168 -0
  80. package/dist/src/data_validation.js.map +1 -0
  81. package/dist/src/dbos-executor.d.ts +79 -0
  82. package/dist/src/dbos-executor.d.ts.map +1 -0
  83. package/dist/src/dbos-executor.js +408 -0
  84. package/dist/src/dbos-executor.js.map +1 -0
  85. package/dist/src/dbos-runtime/TypeParser.d.ts +33 -0
  86. package/dist/src/dbos-runtime/TypeParser.d.ts.map +1 -0
  87. package/dist/src/dbos-runtime/TypeParser.js +104 -0
  88. package/dist/src/dbos-runtime/TypeParser.js.map +1 -0
  89. package/dist/src/dbos-runtime/applicationVersion.d.ts +3 -0
  90. package/dist/src/dbos-runtime/applicationVersion.d.ts.map +1 -0
  91. package/dist/src/dbos-runtime/applicationVersion.js +13 -0
  92. package/dist/src/dbos-runtime/applicationVersion.js.map +1 -0
  93. package/dist/src/dbos-runtime/cli.d.ts +8 -0
  94. package/dist/src/dbos-runtime/cli.d.ts.map +1 -0
  95. package/dist/src/dbos-runtime/cli.js +52 -0
  96. package/dist/src/dbos-runtime/cli.js.map +1 -0
  97. package/dist/src/dbos-runtime/config.d.ts +28 -0
  98. package/dist/src/dbos-runtime/config.d.ts.map +1 -0
  99. package/dist/src/dbos-runtime/config.js +111 -0
  100. package/dist/src/dbos-runtime/config.js.map +1 -0
  101. package/dist/src/dbos-runtime/init.d.ts +7 -0
  102. package/dist/src/dbos-runtime/init.d.ts.map +1 -0
  103. package/dist/src/dbos-runtime/init.js +51 -0
  104. package/dist/src/dbos-runtime/init.js.map +1 -0
  105. package/dist/src/dbos-runtime/openApi.d.ts +35 -0
  106. package/dist/src/dbos-runtime/openApi.d.ts.map +1 -0
  107. package/dist/src/dbos-runtime/openApi.js +595 -0
  108. package/dist/src/dbos-runtime/openApi.js.map +1 -0
  109. package/dist/src/dbos-runtime/runtime.d.ts +28 -0
  110. package/dist/src/dbos-runtime/runtime.d.ts.map +1 -0
  111. package/dist/src/dbos-runtime/runtime.js +96 -0
  112. package/dist/src/dbos-runtime/runtime.js.map +1 -0
  113. package/dist/src/dbos-runtime/tsDiagUtil.d.ts +16 -0
  114. package/dist/src/dbos-runtime/tsDiagUtil.d.ts.map +1 -0
  115. package/dist/src/dbos-runtime/tsDiagUtil.js +72 -0
  116. package/dist/src/dbos-runtime/tsDiagUtil.js.map +1 -0
  117. package/dist/src/decorators.d.ts +118 -0
  118. package/dist/src/decorators.d.ts.map +1 -0
  119. package/dist/src/decorators.js +467 -0
  120. package/dist/src/decorators.js.map +1 -0
  121. package/dist/src/error.d.ts +44 -0
  122. package/dist/src/error.d.ts.map +1 -0
  123. package/dist/src/error.js +164 -0
  124. package/dist/src/error.js.map +1 -0
  125. package/dist/src/httpServer/handler.d.ts +62 -0
  126. package/dist/src/httpServer/handler.d.ts.map +1 -0
  127. package/dist/src/httpServer/handler.js +168 -0
  128. package/dist/src/httpServer/handler.js.map +1 -0
  129. package/dist/src/httpServer/middleware.d.ts +56 -0
  130. package/dist/src/httpServer/middleware.d.ts.map +1 -0
  131. package/dist/src/httpServer/middleware.js +57 -0
  132. package/dist/src/httpServer/middleware.js.map +1 -0
  133. package/dist/src/httpServer/server.d.ts +40 -0
  134. package/dist/src/httpServer/server.d.ts.map +1 -0
  135. package/dist/src/httpServer/server.js +231 -0
  136. package/dist/src/httpServer/server.js.map +1 -0
  137. package/dist/src/index.d.ts +12 -0
  138. package/dist/src/index.d.ts.map +1 -0
  139. package/dist/src/index.js +75 -0
  140. package/dist/src/index.js.map +1 -0
  141. package/dist/src/provenance/provenance_daemon.d.ts +34 -0
  142. package/dist/src/provenance/provenance_daemon.d.ts.map +1 -0
  143. package/dist/src/provenance/provenance_daemon.js +86 -0
  144. package/dist/src/provenance/provenance_daemon.js.map +1 -0
  145. package/dist/src/system_database.d.ts +69 -0
  146. package/dist/src/system_database.d.ts.map +1 -0
  147. package/dist/src/system_database.js +384 -0
  148. package/dist/src/system_database.js.map +1 -0
  149. package/dist/src/telemetry/collector.d.ts +17 -0
  150. package/dist/src/telemetry/collector.d.ts.map +1 -0
  151. package/dist/src/telemetry/collector.js +77 -0
  152. package/dist/src/telemetry/collector.js.map +1 -0
  153. package/dist/src/telemetry/exporters.d.ts +29 -0
  154. package/dist/src/telemetry/exporters.d.ts.map +1 -0
  155. package/dist/src/telemetry/exporters.js +186 -0
  156. package/dist/src/telemetry/exporters.js.map +1 -0
  157. package/dist/src/telemetry/index.d.ts +7 -0
  158. package/dist/src/telemetry/index.d.ts.map +1 -0
  159. package/dist/src/telemetry/index.js +3 -0
  160. package/dist/src/telemetry/index.js.map +1 -0
  161. package/dist/src/telemetry/logs.d.ts +25 -0
  162. package/dist/src/telemetry/logs.d.ts.map +1 -0
  163. package/dist/src/telemetry/logs.js +91 -0
  164. package/dist/src/telemetry/logs.js.map +1 -0
  165. package/dist/src/telemetry/signals.d.ts +30 -0
  166. package/dist/src/telemetry/signals.d.ts.map +1 -0
  167. package/dist/src/telemetry/signals.js +11 -0
  168. package/dist/src/telemetry/signals.js.map +1 -0
  169. package/dist/src/telemetry/traces.d.ts +17 -0
  170. package/dist/src/telemetry/traces.d.ts.map +1 -0
  171. package/dist/src/telemetry/traces.js +76 -0
  172. package/dist/src/telemetry/traces.js.map +1 -0
  173. package/dist/src/testing/testing_runtime.d.ts +76 -0
  174. package/dist/src/testing/testing_runtime.d.ts.map +1 -0
  175. package/dist/src/testing/testing_runtime.js +147 -0
  176. package/dist/src/testing/testing_runtime.js.map +1 -0
  177. package/dist/src/transaction.d.ts +28 -0
  178. package/dist/src/transaction.d.ts.map +1 -0
  179. package/dist/src/transaction.js +27 -0
  180. package/dist/src/transaction.js.map +1 -0
  181. package/dist/src/user_database.d.ts +132 -0
  182. package/dist/src/user_database.d.ts.map +1 -0
  183. package/dist/src/user_database.js +324 -0
  184. package/dist/src/user_database.js.map +1 -0
  185. package/dist/src/utils.d.ts +6 -0
  186. package/dist/src/utils.d.ts.map +1 -0
  187. package/dist/src/utils.js +35 -0
  188. package/dist/src/utils.js.map +1 -0
  189. package/dist/src/workflow.d.ts +179 -0
  190. package/dist/src/workflow.d.ts.map +1 -0
  191. package/dist/src/workflow.js +446 -0
  192. package/dist/src/workflow.js.map +1 -0
  193. package/examples/hello/README.md +41 -0
  194. package/examples/hello/dbos-config.yaml +15 -0
  195. package/examples/hello/jest.config.js +8 -0
  196. package/examples/hello/knexfile.ts +23 -0
  197. package/examples/hello/migrations/create_dbos_hello_tables.ts +12 -0
  198. package/examples/hello/package.json +21 -0
  199. package/examples/hello/src/operations.test.ts +38 -0
  200. package/examples/hello/src/operations.ts +21 -0
  201. package/examples/hello/start_postgres_docker.sh +23 -0
  202. package/examples/hello/tsconfig.json +24 -0
  203. package/package.json +78 -0
@@ -0,0 +1,467 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.DBOSDeploy = exports.DBOSInitializer = exports.OrmEntities = exports.Communicator = exports.Transaction = exports.Workflow = exports.RequiredRole = exports.Debug = exports.DefaultArgOptional = exports.DefaultArgRequired = exports.DefaultRequiredRole = exports.ArgVarchar = exports.ArgDate = exports.ArgName = exports.LogMask = exports.SkipLogging = exports.ArgOptional = exports.ArgRequired = exports.getOrCreateClassRegistration = exports.registerAndWrapFunction = exports.getOrCreateMethodArgsRegistration = exports.getRegisteredOperations = exports.ClassRegistration = exports.MethodRegistration = exports.MethodParameter = exports.ArgRequiredOptions = exports.LogMasks = exports.DBOSDataType = void 0;
28
+ require("reflect-metadata");
29
+ const crypto = __importStar(require("crypto"));
30
+ const error_1 = require("./error");
31
+ const data_validation_1 = require("./data_validation");
32
+ class DBOSDataType {
33
+ dataType = "text";
34
+ length = -1;
35
+ precision = -1;
36
+ scale = -1;
37
+ /** Varchar has length */
38
+ static varchar(length) {
39
+ const dt = new DBOSDataType();
40
+ dt.dataType = "varchar";
41
+ dt.length = length;
42
+ return dt;
43
+ }
44
+ /** Some decimal has precision / scale (as opposed to floating point decimal) */
45
+ static decimal(precision, scale) {
46
+ const dt = new DBOSDataType();
47
+ dt.dataType = "decimal";
48
+ dt.precision = precision;
49
+ dt.scale = scale;
50
+ return dt;
51
+ }
52
+ /** Take type from reflect metadata */
53
+ // eslint-disable-next-line @typescript-eslint/ban-types
54
+ static fromArg(arg) {
55
+ const dt = new DBOSDataType();
56
+ if (arg === String) {
57
+ dt.dataType = "text";
58
+ }
59
+ else if (arg === Date) {
60
+ dt.dataType = "timestamp";
61
+ }
62
+ else if (arg === Number) {
63
+ dt.dataType = "double";
64
+ }
65
+ else if (arg === Boolean) {
66
+ dt.dataType = "boolean";
67
+ }
68
+ else {
69
+ dt.dataType = "json";
70
+ }
71
+ return dt;
72
+ }
73
+ formatAsString() {
74
+ let rv = this.dataType;
75
+ if (this.dataType === "varchar" && this.length > 0) {
76
+ rv += `(${this.length})`;
77
+ }
78
+ if (this.dataType === "decimal" && this.precision > 0) {
79
+ if (this.scale > 0) {
80
+ rv += `(${this.precision},${this.scale})`;
81
+ }
82
+ else {
83
+ rv += `(${this.precision})`;
84
+ }
85
+ }
86
+ return rv;
87
+ }
88
+ }
89
+ exports.DBOSDataType = DBOSDataType;
90
+ const paramMetadataKey = Symbol("dbos:parameter");
91
+ const methodMetadataKey = Symbol("dbos:method");
92
+ const classMetadataKey = Symbol("dbos:class");
93
+ /* Arguments parsing heuristic:
94
+ * - Convert the function to a string
95
+ * - Minify the function
96
+ * - Remove everything before the first open parenthesis and after the first closed parenthesis
97
+ * This will obviously not work on code that has been obfuscated or optimized as the names get
98
+ * changed to be really small and useless.
99
+ **/
100
+ // eslint-disable-next-line @typescript-eslint/ban-types
101
+ function getArgNames(func) {
102
+ let fn = func.toString();
103
+ fn = fn.replace(/\s/g, "");
104
+ fn = fn.substring(fn.indexOf("(") + 1, fn.indexOf(")"));
105
+ return fn.split(",");
106
+ }
107
+ var LogMasks;
108
+ (function (LogMasks) {
109
+ LogMasks["NONE"] = "NONE";
110
+ LogMasks["HASH"] = "HASH";
111
+ LogMasks["SKIP"] = "SKIP";
112
+ })(LogMasks || (exports.LogMasks = LogMasks = {}));
113
+ var ArgRequiredOptions;
114
+ (function (ArgRequiredOptions) {
115
+ ArgRequiredOptions["REQUIRED"] = "REQUIRED";
116
+ ArgRequiredOptions["OPTIONAL"] = "OPTIONAL";
117
+ ArgRequiredOptions["DEFAULT"] = "DEFAULT";
118
+ })(ArgRequiredOptions || (exports.ArgRequiredOptions = ArgRequiredOptions = {}));
119
+ class MethodParameter {
120
+ name = "";
121
+ required = ArgRequiredOptions.DEFAULT;
122
+ validate = true;
123
+ logMask = LogMasks.NONE;
124
+ // eslint-disable-next-line @typescript-eslint/ban-types
125
+ argType = String;
126
+ dataType;
127
+ index = -1;
128
+ // eslint-disable-next-line @typescript-eslint/ban-types
129
+ constructor(idx, at) {
130
+ this.index = idx;
131
+ this.argType = at;
132
+ this.dataType = DBOSDataType.fromArg(at);
133
+ }
134
+ }
135
+ exports.MethodParameter = MethodParameter;
136
+ class MethodRegistration {
137
+ defaults;
138
+ name = "";
139
+ requiredRole = undefined;
140
+ args = [];
141
+ constructor(origFunc) {
142
+ this.origFunction = origFunc;
143
+ }
144
+ debug = false;
145
+ needInitialized = true;
146
+ origFunction;
147
+ registeredFunction;
148
+ workflowConfig;
149
+ txnConfig;
150
+ commConfig;
151
+ init = false;
152
+ invoke(pthis, args) {
153
+ return this.registeredFunction.call(pthis, ...args);
154
+ }
155
+ getRequiredRoles() {
156
+ if (this.requiredRole) {
157
+ return this.requiredRole;
158
+ }
159
+ return this.defaults?.requiredRole || [];
160
+ }
161
+ }
162
+ exports.MethodRegistration = MethodRegistration;
163
+ class ClassRegistration {
164
+ name = "";
165
+ requiredRole;
166
+ defaultArgRequired = ArgRequiredOptions.REQUIRED;
167
+ needsInitialized = true;
168
+ // eslint-disable-next-line @typescript-eslint/ban-types
169
+ ormEntities = [];
170
+ ctor;
171
+ constructor(ctor) {
172
+ this.ctor = ctor;
173
+ }
174
+ }
175
+ exports.ClassRegistration = ClassRegistration;
176
+ ////////////////////////////////////////////////////////////////////////////////
177
+ // DECORATOR REGISTRATION
178
+ // These manage registration objects, creating them at decorator evaluation time
179
+ // and making wrapped methods available for function registration at runtime
180
+ // initialization time.
181
+ ////////////////////////////////////////////////////////////////////////////////
182
+ function getRegisteredOperations(target) {
183
+ const registeredOperations = [];
184
+ for (const name of Object.getOwnPropertyNames(target)) {
185
+ const operation = Reflect.getOwnMetadata(methodMetadataKey, target, name);
186
+ if (operation) {
187
+ registeredOperations.push(operation);
188
+ }
189
+ }
190
+ return registeredOperations;
191
+ }
192
+ exports.getRegisteredOperations = getRegisteredOperations;
193
+ function getOrCreateMethodArgsRegistration(target, propertyKey) {
194
+ let mParameters = Reflect.getOwnMetadata(paramMetadataKey, target, propertyKey) || [];
195
+ if (!mParameters.length) {
196
+ // eslint-disable-next-line @typescript-eslint/ban-types
197
+ const designParamTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey);
198
+ mParameters = designParamTypes.map((value, index) => new MethodParameter(index, value));
199
+ Reflect.defineMetadata(paramMetadataKey, mParameters, target, propertyKey);
200
+ }
201
+ return mParameters;
202
+ }
203
+ exports.getOrCreateMethodArgsRegistration = getOrCreateMethodArgsRegistration;
204
+ function generateSaltedHash(data, salt) {
205
+ const hash = crypto.createHash("sha256"); // You can use other algorithms like 'md5', 'sha512', etc.
206
+ hash.update(data + salt);
207
+ return hash.digest("hex");
208
+ }
209
+ function getOrCreateMethodRegistration(target, propertyKey, descriptor) {
210
+ const methReg = Reflect.getOwnMetadata(methodMetadataKey, target, propertyKey) || new MethodRegistration(descriptor.value);
211
+ if (methReg.needInitialized) {
212
+ methReg.name = propertyKey.toString();
213
+ methReg.args = getOrCreateMethodArgsRegistration(target, propertyKey);
214
+ const argNames = getArgNames(descriptor.value);
215
+ methReg.args.forEach((e) => {
216
+ if (!e.name) {
217
+ if (e.index < argNames.length) {
218
+ e.name = argNames[e.index];
219
+ }
220
+ if (e.index === 0) { // The first argument is always the context.
221
+ e.logMask = LogMasks.SKIP;
222
+ }
223
+ // TODO else warn/log something
224
+ }
225
+ });
226
+ Reflect.defineMetadata(methodMetadataKey, methReg, target, propertyKey);
227
+ const wrappedMethod = async function (...rawArgs) {
228
+ let opCtx = undefined;
229
+ // Validate the user authentication and populate the role field
230
+ const requiredRoles = methReg.getRequiredRoles();
231
+ if (requiredRoles.length > 0) {
232
+ opCtx = rawArgs[0];
233
+ const curRoles = opCtx.authenticatedRoles;
234
+ let authorized = false;
235
+ const set = new Set(curRoles);
236
+ for (const role of requiredRoles) {
237
+ if (set.has(role)) {
238
+ authorized = true;
239
+ opCtx.assumedRole = role;
240
+ opCtx.span.setAttribute("assumedRole", role);
241
+ break;
242
+ }
243
+ }
244
+ if (!authorized) {
245
+ const err = new error_1.DBOSNotAuthorizedError(`User does not have a role with permission to call ${methReg.name}`, 403);
246
+ opCtx.span.addEvent("DBOSNotAuthorizedError", { message: err.message });
247
+ throw err;
248
+ }
249
+ }
250
+ const validatedArgs = (0, data_validation_1.validateMethodArgs)(methReg, rawArgs);
251
+ // Argument logging
252
+ validatedArgs.forEach((argValue, idx) => {
253
+ let isCtx = false;
254
+ // TODO: we assume the first argument is always a context, need a more robust way to test it.
255
+ if (idx === 0) {
256
+ // Context -- I suppose we could just instanceof
257
+ opCtx = validatedArgs[0];
258
+ isCtx = true;
259
+ }
260
+ let loggedArgValue = argValue;
261
+ if (isCtx || methReg.args[idx].logMask === LogMasks.SKIP) {
262
+ return;
263
+ }
264
+ else {
265
+ if (methReg.args[idx].logMask !== LogMasks.NONE) {
266
+ // For now this means hash
267
+ if (methReg.args[idx].dataType.dataType === "json") {
268
+ loggedArgValue = generateSaltedHash(JSON.stringify(argValue), "JSONSALT");
269
+ }
270
+ else {
271
+ // Yes, we are doing the same as above for now.
272
+ // It can be better if we have verified the type of the data
273
+ loggedArgValue = generateSaltedHash(JSON.stringify(argValue), "DBOSSALT");
274
+ }
275
+ }
276
+ opCtx?.span.setAttribute(methReg.args[idx].name, loggedArgValue);
277
+ }
278
+ });
279
+ return methReg.origFunction.call(this, ...validatedArgs);
280
+ };
281
+ Object.defineProperty(wrappedMethod, "name", {
282
+ value: methReg.name,
283
+ });
284
+ descriptor.value = wrappedMethod;
285
+ methReg.registeredFunction = wrappedMethod;
286
+ methReg.needInitialized = false;
287
+ }
288
+ return methReg;
289
+ }
290
+ function registerAndWrapFunction(target, propertyKey, descriptor) {
291
+ if (!descriptor.value) {
292
+ throw Error("Use of decorator when original method is undefined");
293
+ }
294
+ const registration = getOrCreateMethodRegistration(target, propertyKey, descriptor);
295
+ return { descriptor, registration };
296
+ }
297
+ exports.registerAndWrapFunction = registerAndWrapFunction;
298
+ function getOrCreateClassRegistration(ctor) {
299
+ const clsReg = Reflect.getOwnMetadata(classMetadataKey, ctor, "dbosclassreg") || new ClassRegistration(ctor);
300
+ if (clsReg.needsInitialized) {
301
+ clsReg.name = ctor.name;
302
+ Reflect.defineMetadata(classMetadataKey, clsReg, ctor, "dbosclassreg");
303
+ const ops = getRegisteredOperations(ctor);
304
+ ops.forEach((op) => {
305
+ op.defaults = clsReg;
306
+ });
307
+ }
308
+ return clsReg;
309
+ }
310
+ exports.getOrCreateClassRegistration = getOrCreateClassRegistration;
311
+ //////////////////////////
312
+ /* PARAMETER DECORATORS */
313
+ //////////////////////////
314
+ function ArgRequired(target, propertyKey, parameterIndex) {
315
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
316
+ const curParam = existingParameters[parameterIndex];
317
+ curParam.required = ArgRequiredOptions.REQUIRED;
318
+ }
319
+ exports.ArgRequired = ArgRequired;
320
+ function ArgOptional(target, propertyKey, parameterIndex) {
321
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
322
+ const curParam = existingParameters[parameterIndex];
323
+ curParam.required = ArgRequiredOptions.OPTIONAL;
324
+ }
325
+ exports.ArgOptional = ArgOptional;
326
+ function SkipLogging(target, propertyKey, parameterIndex) {
327
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
328
+ const curParam = existingParameters[parameterIndex];
329
+ curParam.logMask = LogMasks.SKIP;
330
+ }
331
+ exports.SkipLogging = SkipLogging;
332
+ function LogMask(mask) {
333
+ return function (target, propertyKey, parameterIndex) {
334
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
335
+ const curParam = existingParameters[parameterIndex];
336
+ curParam.logMask = mask;
337
+ };
338
+ }
339
+ exports.LogMask = LogMask;
340
+ function ArgName(name) {
341
+ return function (target, propertyKey, parameterIndex) {
342
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
343
+ const curParam = existingParameters[parameterIndex];
344
+ curParam.name = name;
345
+ };
346
+ }
347
+ exports.ArgName = ArgName;
348
+ function ArgDate() {
349
+ return function (target, propertyKey, parameterIndex) {
350
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
351
+ const curParam = existingParameters[parameterIndex];
352
+ curParam.dataType.dataType = 'timestamp';
353
+ };
354
+ }
355
+ exports.ArgDate = ArgDate;
356
+ function ArgVarchar(length) {
357
+ return function (target, propertyKey, parameterIndex) {
358
+ const existingParameters = getOrCreateMethodArgsRegistration(target, propertyKey);
359
+ const curParam = existingParameters[parameterIndex];
360
+ curParam.dataType = DBOSDataType.varchar(length);
361
+ };
362
+ }
363
+ exports.ArgVarchar = ArgVarchar;
364
+ ///////////////////////
365
+ /* CLASS DECORATORS */
366
+ ///////////////////////
367
+ function DefaultRequiredRole(anyOf) {
368
+ function clsdec(ctor) {
369
+ const clsreg = getOrCreateClassRegistration(ctor);
370
+ clsreg.requiredRole = anyOf;
371
+ }
372
+ return clsdec;
373
+ }
374
+ exports.DefaultRequiredRole = DefaultRequiredRole;
375
+ function DefaultArgRequired(ctor) {
376
+ const clsreg = getOrCreateClassRegistration(ctor);
377
+ clsreg.defaultArgRequired = ArgRequiredOptions.REQUIRED;
378
+ }
379
+ exports.DefaultArgRequired = DefaultArgRequired;
380
+ function DefaultArgOptional(ctor) {
381
+ const clsreg = getOrCreateClassRegistration(ctor);
382
+ clsreg.defaultArgRequired = ArgRequiredOptions.OPTIONAL;
383
+ }
384
+ exports.DefaultArgOptional = DefaultArgOptional;
385
+ ///////////////////////
386
+ /* METHOD DECORATORS */
387
+ ///////////////////////
388
+ function Debug() {
389
+ function logdec(target, propertyKey, inDescriptor) {
390
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
391
+ registration.debug = true;
392
+ return descriptor;
393
+ }
394
+ return logdec;
395
+ }
396
+ exports.Debug = Debug;
397
+ function RequiredRole(anyOf) {
398
+ function apidec(target, propertyKey, inDescriptor) {
399
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
400
+ registration.requiredRole = anyOf;
401
+ return descriptor;
402
+ }
403
+ return apidec;
404
+ }
405
+ exports.RequiredRole = RequiredRole;
406
+ function Workflow(config = {}) {
407
+ function decorator(target, propertyKey, inDescriptor) {
408
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
409
+ registration.workflowConfig = config;
410
+ return descriptor;
411
+ }
412
+ return decorator;
413
+ }
414
+ exports.Workflow = Workflow;
415
+ function Transaction(config = {}) {
416
+ function decorator(target, propertyKey,
417
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
418
+ inDescriptor) {
419
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
420
+ registration.txnConfig = config;
421
+ return descriptor;
422
+ }
423
+ return decorator;
424
+ }
425
+ exports.Transaction = Transaction;
426
+ function Communicator(config = {}) {
427
+ function decorator(target, propertyKey, inDescriptor) {
428
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
429
+ registration.commConfig = config;
430
+ return descriptor;
431
+ }
432
+ return decorator;
433
+ }
434
+ exports.Communicator = Communicator;
435
+ // eslint-disable-next-line @typescript-eslint/ban-types
436
+ function OrmEntities(entities) {
437
+ function clsdec(ctor) {
438
+ const clsreg = getOrCreateClassRegistration(ctor);
439
+ clsreg.ormEntities = entities;
440
+ }
441
+ return clsdec;
442
+ }
443
+ exports.OrmEntities = OrmEntities;
444
+ function DBOSInitializer() {
445
+ function decorator(target, propertyKey,
446
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
447
+ inDescriptor) {
448
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
449
+ registration.init = true;
450
+ return descriptor;
451
+ }
452
+ return decorator;
453
+ }
454
+ exports.DBOSInitializer = DBOSInitializer;
455
+ // For future use with Deploy
456
+ function DBOSDeploy() {
457
+ function decorator(target, propertyKey,
458
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
459
+ inDescriptor) {
460
+ const { descriptor, registration } = registerAndWrapFunction(target, propertyKey, inDescriptor);
461
+ registration.init = true;
462
+ return descriptor;
463
+ }
464
+ return decorator;
465
+ }
466
+ exports.DBOSDeploy = DBOSDeploy;
467
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":";AAAA,6DAA6D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7D,4BAA0B;AAE1B,+CAAiC;AAKjC,mCAAiD;AACjD,uDAAuD;AAOvD,MAAa,YAAY;IACvB,QAAQ,GAAkB,MAAM,CAAC;IACjC,MAAM,GAAW,CAAC,CAAC,CAAC;IACpB,SAAS,GAAW,CAAC,CAAC,CAAC;IACvB,KAAK,GAAW,CAAC,CAAC,CAAC;IAEnB,yBAAyB;IACzB,MAAM,CAAC,OAAO,CAAC,MAAc;QAC3B,MAAM,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC;QAC9B,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;QACxB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;QACnB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,OAAO,CAAC,SAAiB,EAAE,KAAa;QAC7C,MAAM,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC;QAC9B,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;QACxB,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC;QACzB,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC;QAEjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sCAAsC;IACtC,wDAA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AO;QAErE,MAAM,MAAM,GAAG,4BAA4B,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,kCAQC;AAED,SAAgB,eAAe;IAC7B,SAAS,SAAS,CAChB,MAAc,EACd,WAAmB;IACnB,8DAA8D;IAC9D,YAAuG;QAEvG,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;QAChG,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;QACzB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAZD,0CAYC;AAED,6BAA6B;AAC7B,SAAgB,UAAU;IACxB,SAAS,SAAS,CAChB,MAAc,EACd,WAAmB;IACnB,8DAA8D;IAC9D,YAAuG;QAEvG,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;QAChG,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;QACzB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAZD,gCAYC"}
@@ -0,0 +1,44 @@
1
+ export declare function isClientError(dbosErrorCode: number): boolean;
2
+ export declare class DBOSError extends Error {
3
+ readonly dbosErrorCode: number;
4
+ constructor(msg: string, dbosErrorCode?: number);
5
+ }
6
+ export declare class DBOSWorkflowPermissionDeniedError extends DBOSError {
7
+ constructor(runAs: string, workflowName: string);
8
+ }
9
+ export declare class DBOSInitializationError extends DBOSError {
10
+ constructor(msg: string);
11
+ }
12
+ export declare class DBOSTopicPermissionDeniedError extends DBOSError {
13
+ constructor(destinationUUID: string, workflowUUID: string, functionID: number, runAs: string);
14
+ }
15
+ export declare class DBOSWorkflowConflictUUIDError extends DBOSError {
16
+ constructor(workflowUUID: string);
17
+ }
18
+ export declare class DBOSNotRegisteredError extends DBOSError {
19
+ constructor(name: string);
20
+ }
21
+ export declare class DBOSPostgresExporterError extends DBOSError {
22
+ constructor(err: Error);
23
+ }
24
+ export declare class DBOSDataValidationError extends DBOSError {
25
+ constructor(msg: string);
26
+ }
27
+ export declare class DuplicateWorkflowEventError extends DBOSError {
28
+ constructor(workflowUUID: string, key: string);
29
+ }
30
+ export declare class DBOSResponseError extends DBOSError {
31
+ readonly status: number;
32
+ constructor(msg: string, status?: number);
33
+ }
34
+ export declare class DBOSNotAuthorizedError extends DBOSError {
35
+ readonly status: number;
36
+ constructor(msg: string, status?: number);
37
+ }
38
+ export declare class DBOSUndefinedDecoratorInputError extends DBOSError {
39
+ constructor(decoratorName: string);
40
+ }
41
+ export declare class DBOSConfigKeyTypeError extends DBOSError {
42
+ constructor(configKey: string, expectedType: string, actualType: string);
43
+ }
44
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAqDA,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,WAElD;AAED,qBAAa,SAAU,SAAQ,KAAK;IAET,QAAQ,CAAC,aAAa,EAAE,MAAM;gBAA3C,GAAG,EAAE,MAAM,EAAW,aAAa,GAAE,MAAU;CAG5D;AAGD,qBAAa,iCAAkC,SAAQ,SAAS;gBAClD,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAIhD;AAGD,qBAAa,uBAAwB,SAAQ,SAAS;gBACxC,GAAG,EAAE,MAAM;CAGxB;AAGD,qBAAa,8BAA+B,SAAQ,SAAS;gBAC/C,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAI7F;AAGD,qBAAa,6BAA8B,SAAQ,SAAS;gBAC9C,YAAY,EAAE,MAAM;CAGjC;AAGD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