@versori/run 0.7.0-alpha.7 → 0.7.0-alpha.8

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.
@@ -94,7 +94,7 @@ export type WebhookOptions = {
94
94
  */
95
95
  connection?: string;
96
96
  /**
97
- * The HTTP method(s) to accept. Defaults to 'all'.
97
+ * The HTTP method(s) to accept. Defaults to 'post'.
98
98
  */
99
99
  method?: 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
100
100
  /**
@@ -183,7 +183,7 @@ export class DurableInterpreter {
183
183
  }
184
184
  }
185
185
  static async newInstance(options = {}) {
186
- const log = options.logger || new ConsoleLogger('debug');
186
+ const log = options.logger || new ConsoleLogger();
187
187
  const compiler = options.compiler || new ObservableCompiler();
188
188
  const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
189
189
  const environmentID = Deno.env.get(envVarEnvId) || 'development';
@@ -45,7 +45,7 @@ export class QueueImpl {
45
45
  }
46
46
  static fromEnv(log) {
47
47
  const baseUrl = Deno.env.get(envVarSDKApiBaseURL);
48
- const _log = log || new ConsoleLogger('debug');
48
+ const _log = log || new ConsoleLogger();
49
49
  const projectId = Deno.env.get(envVarProjectId) || 'default-project';
50
50
  const environmentId = Deno.env.get(envVarEnvId) || 'default-environment';
51
51
  if (!baseUrl) {
@@ -68,7 +68,7 @@ export const webhookCompiler = {
68
68
  throw new Error('Invalid response mode, must be either "sync" or "async"');
69
69
  }
70
70
  const method = trigger.options.method || 'post';
71
- const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
71
+ const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'all'];
72
72
  if (method !== method.toLowerCase()) {
73
73
  throw new Error(`HTTP method must be in lowercase: ${method} on webhook ${trigger.id}`);
74
74
  }
@@ -167,7 +167,7 @@ export class MemoryInterpreter {
167
167
  }
168
168
  }
169
169
  static async newInstance(options = {}) {
170
- const log = options.logger || new ConsoleLogger('debug');
170
+ const log = options.logger || new ConsoleLogger();
171
171
  const compiler = options.compiler || new ObservableCompiler();
172
172
  const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
173
173
  const environmentID = Deno.env.get(envVarEnvId) || 'development';
@@ -68,7 +68,7 @@ export const webhookCompiler = {
68
68
  throw new Error('Invalid response mode, must be either "sync" or "async"');
69
69
  }
70
70
  const method = trigger.options.method || 'post';
71
- const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
71
+ const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'all'];
72
72
  if (method !== method.toLowerCase()) {
73
73
  throw new Error(`HTTP method must be in lowercase: ${method} on webhook ${trigger.id}`);
74
74
  }
@@ -166,7 +166,7 @@ export class VanillaInterpreter {
166
166
  }
167
167
  }
168
168
  static async newInstance(options = {}) {
169
- const log = options.logger || new ConsoleLogger('debug');
169
+ const log = options.logger || new ConsoleLogger();
170
170
  const compiler = options.compiler || new ObservableCompiler();
171
171
  const serviceName = Deno.env.get(envVarProjectId) || 'example-service';
172
172
  const environmentID = Deno.env.get(envVarEnvId) || 'development';
@@ -10,7 +10,7 @@ export declare class ConsoleLogger implements Logger {
10
10
  log: log.Logger;
11
11
  level: LogLevel;
12
12
  fields: Record<string, unknown>;
13
- constructor(level: LogLevel, fields?: Record<string, unknown>);
13
+ constructor(level?: LogLevel, fields?: Record<string, unknown>);
14
14
  debug(message: string, fields?: Record<string, unknown>): void;
15
15
  warn(message: string, fields?: Record<string, unknown>): void;
16
16
  info(message: string, fields?: Record<string, unknown>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsM/C;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,MA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,CAAC,MAAM,CAAC;IAEhB,KAAK,EAAE,QAAQ,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEpB,KAAK,GAAE,QAAqD,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAO9G,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAC3E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAsB9D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAOvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAIlC"}
@@ -11,9 +11,18 @@
11
11
  * use of this software will be governed by the Apache License, Version 2.0.
12
12
  */
13
13
  import * as log from '../../../deps/jsr.io/@std/log/0.224.14/mod.js';
14
+ const defaultLogLevel = 'info';
15
+ const validLogLevels = ['debug', 'warn', 'info', 'error'];
14
16
  function isObjectLiteral(obj) {
15
17
  return Object.getPrototypeOf(obj) === Object.prototype;
16
18
  }
19
+ function resolveLogLevel(level) {
20
+ const normalized = level?.toLowerCase();
21
+ if (normalized && validLogLevels.includes(normalized)) {
22
+ return normalized;
23
+ }
24
+ return defaultLogLevel;
25
+ }
17
26
  function formatError(err) {
18
27
  if (Symbol.toPrimitive in err) {
19
28
  const toPrimitive = err[Symbol.toPrimitive];
@@ -178,7 +187,7 @@ const levelMap = {
178
187
  * and proper error serialization.
179
188
  */
180
189
  export class ConsoleLogger {
181
- constructor(level, fields = {}) {
190
+ constructor(level = resolveLogLevel(Deno.env.get('LOG_LEVEL')), fields = {}) {
182
191
  Object.defineProperty(this, "log", {
183
192
  enumerable: true,
184
193
  configurable: true,
@@ -241,6 +250,7 @@ export class ConsoleLogger {
241
250
  });
242
251
  }
243
252
  setLevel(level) {
253
+ this.level = level;
244
254
  this.log.level = levelMap[level] ?? log.getLevelByName('INFO');
245
255
  }
246
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versori/run",
3
- "version": "0.7.0-alpha.7",
3
+ "version": "0.7.0-alpha.8",
4
4
  "description": "Versori Run",
5
5
  "homepage": "https://github.com/versori/versori-run#readme",
6
6
  "repository": {
@@ -94,7 +94,7 @@ export type WebhookOptions = {
94
94
  */
95
95
  connection?: string;
96
96
  /**
97
- * The HTTP method(s) to accept. Defaults to 'all'.
97
+ * The HTTP method(s) to accept. Defaults to 'post'.
98
98
  */
99
99
  method?: 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
100
100
  /**
@@ -189,7 +189,7 @@ class DurableInterpreter {
189
189
  }
190
190
  }
191
191
  static async newInstance(options = {}) {
192
- const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
192
+ const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger();
193
193
  const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
194
194
  const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
195
195
  const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
@@ -48,7 +48,7 @@ class QueueImpl {
48
48
  }
49
49
  static fromEnv(log) {
50
50
  const baseUrl = Deno.env.get(constants_js_1.envVarSDKApiBaseURL);
51
- const _log = log || new mod_js_1.ConsoleLogger('debug');
51
+ const _log = log || new mod_js_1.ConsoleLogger();
52
52
  const projectId = Deno.env.get(constants_js_1.envVarProjectId) || 'default-project';
53
53
  const environmentId = Deno.env.get(constants_js_1.envVarEnvId) || 'default-environment';
54
54
  if (!baseUrl) {
@@ -74,7 +74,7 @@ exports.webhookCompiler = {
74
74
  throw new Error('Invalid response mode, must be either "sync" or "async"');
75
75
  }
76
76
  const method = trigger.options.method || 'post';
77
- const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
77
+ const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'all'];
78
78
  if (method !== method.toLowerCase()) {
79
79
  throw new Error(`HTTP method must be in lowercase: ${method} on webhook ${trigger.id}`);
80
80
  }
@@ -173,7 +173,7 @@ class MemoryInterpreter {
173
173
  }
174
174
  }
175
175
  static async newInstance(options = {}) {
176
- const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
176
+ const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger();
177
177
  const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
178
178
  const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
179
179
  const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
@@ -74,7 +74,7 @@ exports.webhookCompiler = {
74
74
  throw new Error('Invalid response mode, must be either "sync" or "async"');
75
75
  }
76
76
  const method = trigger.options.method || 'post';
77
- const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
77
+ const validMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head', 'all'];
78
78
  if (method !== method.toLowerCase()) {
79
79
  throw new Error(`HTTP method must be in lowercase: ${method} on webhook ${trigger.id}`);
80
80
  }
@@ -172,7 +172,7 @@ class VanillaInterpreter {
172
172
  }
173
173
  }
174
174
  static async newInstance(options = {}) {
175
- const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger('debug');
175
+ const log = options.logger || new ConsoleLogger_js_1.ConsoleLogger();
176
176
  const compiler = options.compiler || new ObservableCompiler_js_1.ObservableCompiler();
177
177
  const serviceName = Deno.env.get(constants_js_1.envVarProjectId) || 'example-service';
178
178
  const environmentID = Deno.env.get(constants_js_1.envVarEnvId) || 'development';
@@ -10,7 +10,7 @@ export declare class ConsoleLogger implements Logger {
10
10
  log: log.Logger;
11
11
  level: LogLevel;
12
12
  fields: Record<string, unknown>;
13
- constructor(level: LogLevel, fields?: Record<string, unknown>);
13
+ constructor(level?: LogLevel, fields?: Record<string, unknown>);
14
14
  debug(message: string, fields?: Record<string, unknown>): void;
15
15
  warn(message: string, fields?: Record<string, unknown>): void;
16
16
  info(message: string, fields?: Record<string, unknown>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ConsoleLogger.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/logging/ConsoleLogger.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,GAAG,MAAM,+CAA+C,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsM/C;;;;;GAKG;AACH,qBAAa,aAAc,YAAW,MAAM;IACxC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IAEhB,KAAK,EAAE,QAAQ,CAAC;IAEhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEpB,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAOjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,IAAI,CAA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MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAO7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAC3E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAsB9D,KAAK,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,aAAa;IAOvD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;CAIlC"}
@@ -37,9 +37,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.ConsoleLogger = void 0;
39
39
  const log = __importStar(require("../../../deps/jsr.io/@std/log/0.224.14/mod.js"));
40
+ const defaultLogLevel = 'info';
41
+ const validLogLevels = ['debug', 'warn', 'info', 'error'];
40
42
  function isObjectLiteral(obj) {
41
43
  return Object.getPrototypeOf(obj) === Object.prototype;
42
44
  }
45
+ function resolveLogLevel(level) {
46
+ const normalized = level?.toLowerCase();
47
+ if (normalized && validLogLevels.includes(normalized)) {
48
+ return normalized;
49
+ }
50
+ return defaultLogLevel;
51
+ }
43
52
  function formatError(err) {
44
53
  if (Symbol.toPrimitive in err) {
45
54
  const toPrimitive = err[Symbol.toPrimitive];
@@ -204,7 +213,7 @@ const levelMap = {
204
213
  * and proper error serialization.
205
214
  */
206
215
  class ConsoleLogger {
207
- constructor(level, fields = {}) {
216
+ constructor(level = resolveLogLevel(Deno.env.get('LOG_LEVEL')), fields = {}) {
208
217
  Object.defineProperty(this, "log", {
209
218
  enumerable: true,
210
219
  configurable: true,
@@ -267,6 +276,7 @@ class ConsoleLogger {
267
276
  });
268
277
  }
269
278
  setLevel(level) {
279
+ this.level = level;
270
280
  this.log.level = levelMap[level] ?? log.getLevelByName('INFO');
271
281
  }
272
282
  }