@versori/run 0.1.0-alpha.9 → 0.2.0-alpha.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.
- package/esm/_dnt.shims.d.ts +1 -5
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -5
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/esm/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +6 -7
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts +1 -0
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/fs/1.0.16/exists.js +10 -12
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
- package/esm/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -2
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +6 -8
- package/esm/src/context/Context.d.ts +14 -4
- package/esm/src/context/Context.d.ts.map +1 -1
- package/esm/src/context/Context.js +16 -10
- package/esm/src/context/ContextProvider.d.ts +3 -4
- package/esm/src/context/ContextProvider.d.ts.map +1 -1
- package/esm/src/context/ContextProvider.js +5 -5
- package/esm/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/configloader.js +2 -3
- package/esm/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/internalauth.js +5 -6
- package/esm/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/platformapi.js +3 -4
- package/esm/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/esm/src/dsl/http/versori/roundtripper.js +5 -6
- package/esm/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/esm/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/esm/src/dsl/tasks/HttpTask.js +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/esm/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/esm/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/esm/src/interpreter/memory/MemoryInterpreter.js +79 -10
- package/esm/src/interpreter/memory/compilers/schedule.js +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/esm/src/interpreter/memory/compilers/webhook.js +132 -25
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/esm/src/kv/nats/NatsKeyValueProvider.js +7 -8
- package/package.json +3 -6
- package/script/_dnt.shims.d.ts +1 -5
- package/script/_dnt.shims.d.ts.map +1 -1
- package/script/_dnt.shims.js +2 -7
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts +1 -2
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.d.ts.map +1 -1
- package/script/deps/jsr.io/@nats-io/transport-deno/3.0.2/src/deno_transport.js +9 -33
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts +1 -0
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/fs/1.0.16/exists.js +10 -35
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts +0 -21
- package/script/deps/jsr.io/@std/log/0.224.14/base_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts +2 -3
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/file_handler.js +1 -25
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/log/0.224.14/rotating_file_handler.js +6 -31
- package/script/src/context/Context.d.ts +14 -4
- package/script/src/context/Context.d.ts.map +1 -1
- package/script/src/context/Context.js +16 -10
- package/script/src/context/ContextProvider.d.ts +3 -4
- package/script/src/context/ContextProvider.d.ts.map +1 -1
- package/script/src/context/ContextProvider.js +5 -5
- package/script/src/dsl/http/versori/configloader.d.ts.map +1 -1
- package/script/src/dsl/http/versori/configloader.js +2 -26
- package/script/src/dsl/http/versori/internalauth.d.ts.map +1 -1
- package/script/src/dsl/http/versori/internalauth.js +5 -29
- package/script/src/dsl/http/versori/platformapi.d.ts.map +1 -1
- package/script/src/dsl/http/versori/platformapi.js +3 -27
- package/script/src/dsl/http/versori/roundtripper.d.ts.map +1 -1
- package/script/src/dsl/http/versori/roundtripper.js +5 -29
- package/script/src/dsl/tasks/HttpTask.d.ts +1 -1
- package/script/src/dsl/tasks/HttpTask.d.ts.map +1 -1
- package/script/src/dsl/tasks/HttpTask.js +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.d.ts +45 -3
- package/script/src/dsl/triggers/WebhookTrigger.d.ts.map +1 -1
- package/script/src/dsl/triggers/WebhookTrigger.js +10 -6
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts +6 -1
- package/script/src/interpreter/memory/MemoryInterpreter.d.ts.map +1 -1
- package/script/src/interpreter/memory/MemoryInterpreter.js +79 -33
- package/script/src/interpreter/memory/compilers/schedule.js +1 -1
- package/script/src/interpreter/memory/compilers/webhook.d.ts.map +1 -1
- package/script/src/interpreter/memory/compilers/webhook.js +135 -25
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts +0 -1
- package/script/src/kv/nats/NatsKeyValueProvider.d.ts.map +1 -1
- package/script/src/kv/nats/NatsKeyValueProvider.js +7 -31
|
@@ -1,74 +1,175 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.webhookCompiler = void 0;
|
|
4
7
|
// In src/interpreter/memory/compilers/webhook.ts
|
|
8
|
+
const cors_1 = __importDefault(require("cors"));
|
|
5
9
|
const rxjs_1 = require("rxjs");
|
|
10
|
+
const promises_1 = require("node:stream/promises");
|
|
6
11
|
const WebhookTrigger_js_1 = require("../../../dsl/triggers/WebhookTrigger.js");
|
|
12
|
+
const DEFAULT_SYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify(ctx.data), {
|
|
13
|
+
status: 200,
|
|
14
|
+
headers: {
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
|
+
'X-Execution-Id': ctx.executionId,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
const DEFAULT_SYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({ message: 'Internal server error', error: ctx.data }), {
|
|
20
|
+
status: 500,
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
'X-Execution-Id': ctx.executionId,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const DEFAULT_ASYNC_ON_SUCCESS = (ctx) => new Response(JSON.stringify({
|
|
27
|
+
status: 'accepted',
|
|
28
|
+
executionId: ctx.executionId,
|
|
29
|
+
}), {
|
|
30
|
+
status: 202,
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
'X-Execution-Id': ctx.executionId,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const DEFAULT_ASYNC_ON_ERROR = (ctx) => new Response(JSON.stringify({
|
|
37
|
+
message: 'Internal server error',
|
|
38
|
+
executionId: ctx.executionId,
|
|
39
|
+
}), {
|
|
40
|
+
status: 500,
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
'X-Execution-Id': ctx.executionId,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
7
46
|
exports.webhookCompiler = {
|
|
8
47
|
ctor: WebhookTrigger_js_1.WebhookTrigger,
|
|
9
48
|
compile: (ctx, trigger, signal) => {
|
|
49
|
+
const { response: { mode = 'async', } = {}, cors: corsOptions, } = trigger.options;
|
|
50
|
+
const isSync = mode === 'sync';
|
|
51
|
+
const isAsync = mode === 'async';
|
|
52
|
+
if (!isSync && !isAsync) {
|
|
53
|
+
throw new Error('Invalid response mode, must be either "sync" or "async"');
|
|
54
|
+
}
|
|
55
|
+
let onSuccess = isSync ? DEFAULT_SYNC_ON_SUCCESS : DEFAULT_ASYNC_ON_SUCCESS;
|
|
56
|
+
let onError = isSync ? DEFAULT_SYNC_ON_ERROR : DEFAULT_ASYNC_ON_ERROR;
|
|
57
|
+
if (trigger.options.response?.onSuccess) {
|
|
58
|
+
onSuccess = trigger.options.response.onSuccess;
|
|
59
|
+
}
|
|
60
|
+
if (trigger.options.response?.onError) {
|
|
61
|
+
onError = trigger.options.response.onError;
|
|
62
|
+
}
|
|
63
|
+
const ctxOptionsFn = (res) => ({
|
|
64
|
+
onSuccess: (ctx) => {
|
|
65
|
+
if (isSync) {
|
|
66
|
+
sendResponse(res, onSuccess(ctx));
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onError: (ctx) => {
|
|
70
|
+
if (isSync) {
|
|
71
|
+
sendResponse(res, onError(ctx));
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
10
75
|
return new rxjs_1.Observable((subscriber) => {
|
|
11
76
|
if (!ctx.router) {
|
|
12
77
|
throw new Error('Router not available in compiler context');
|
|
13
78
|
}
|
|
14
79
|
// add the webhook endpoint to the router
|
|
15
80
|
ctx.log.info('webhook endpoint added:', { trigger });
|
|
81
|
+
if (corsOptions) {
|
|
82
|
+
if (typeof corsOptions === 'boolean') {
|
|
83
|
+
ctx.router.use((0, cors_1.default)());
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
ctx.router.use((0, cors_1.default)(corsOptions));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
16
89
|
// endpoint for sans user because I'm not quite sure how the dynamic routing works
|
|
17
90
|
ctx.router.post(`/${trigger.id}`, (req, res) => {
|
|
18
|
-
const executionCtx = ctx.contextProvider.create(req.body,
|
|
91
|
+
const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
|
|
19
92
|
try {
|
|
20
93
|
subscriber.next(executionCtx);
|
|
21
|
-
|
|
94
|
+
if (isAsync) {
|
|
95
|
+
sendResponse(res, onSuccess(executionCtx));
|
|
96
|
+
}
|
|
22
97
|
}
|
|
23
98
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
99
|
+
executionCtx.log.error('webhook execution error', {
|
|
100
|
+
error: JSON.stringify(error),
|
|
101
|
+
});
|
|
102
|
+
if (isAsync) {
|
|
103
|
+
sendResponse(res, onError(executionCtx.withData(error)));
|
|
104
|
+
}
|
|
27
105
|
}
|
|
28
106
|
});
|
|
29
107
|
// this endpoint will trigger the workflow for each activation given by the external user ID
|
|
30
108
|
ctx.router.post(`/${trigger.id}/users/:userId`, async (req, res) => {
|
|
31
|
-
const userId = req.params.userId
|
|
32
|
-
if (!userId) {
|
|
33
|
-
res.status(400).json({ status: 'error', message: 'User ID is required' });
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
109
|
+
const userId = req.params.userId;
|
|
36
110
|
const activations = await ctx.connectionProvider.getUserActivations(userId);
|
|
37
111
|
if (!activations || activations.length === 0) {
|
|
38
|
-
res.status(404).json({
|
|
112
|
+
res.status(404).json({
|
|
113
|
+
status: 'error',
|
|
114
|
+
message: `No activations found for user: ${userId}`,
|
|
115
|
+
});
|
|
39
116
|
return;
|
|
40
117
|
}
|
|
118
|
+
const executionCtx = ctx.contextProvider.create(req.body, ctxOptionsFn(res));
|
|
119
|
+
const errors = [];
|
|
41
120
|
activations.forEach((activation) => {
|
|
42
|
-
const
|
|
121
|
+
const activationCtx = executionCtx.withActivation(activation);
|
|
43
122
|
try {
|
|
44
|
-
subscriber.next(
|
|
123
|
+
subscriber.next(activationCtx);
|
|
45
124
|
}
|
|
46
125
|
catch (error) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
126
|
+
activationCtx.log.error('webhook execution error', {
|
|
127
|
+
error: JSON.stringify(error),
|
|
128
|
+
});
|
|
129
|
+
errors.push({
|
|
130
|
+
activationId: activation.id,
|
|
131
|
+
error,
|
|
132
|
+
});
|
|
50
133
|
}
|
|
51
134
|
});
|
|
52
|
-
|
|
135
|
+
if (isAsync) {
|
|
136
|
+
if (errors.length === 0) {
|
|
137
|
+
sendResponse(res, onSuccess(executionCtx));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
sendResponse(res, onError(executionCtx.withData(errors)));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
53
143
|
});
|
|
54
144
|
// this endpoint will trigger the workflow only for the activation given by its ID
|
|
55
145
|
ctx.router.post(`/${trigger.id}/activations/:activationId`, async (req, res) => {
|
|
56
|
-
const activationId = req.params.activationId
|
|
146
|
+
const activationId = req.params.activationId;
|
|
57
147
|
const activation = await ctx.connectionProvider.getActivation(activationId);
|
|
58
148
|
if (!activation) {
|
|
59
149
|
// TODO report back actual errors
|
|
60
|
-
res.status(404).json({
|
|
150
|
+
res.status(404).json({
|
|
151
|
+
status: 'error',
|
|
152
|
+
message: `No activation found for ID: ${activationId}`,
|
|
153
|
+
});
|
|
61
154
|
return;
|
|
62
155
|
}
|
|
63
|
-
const
|
|
156
|
+
const activationCtx = ctx.contextProvider.create(req.body, {
|
|
157
|
+
...ctxOptionsFn(res),
|
|
158
|
+
activation,
|
|
159
|
+
});
|
|
64
160
|
try {
|
|
65
|
-
subscriber.next(
|
|
66
|
-
|
|
161
|
+
subscriber.next(activationCtx);
|
|
162
|
+
if (isAsync) {
|
|
163
|
+
sendResponse(res, onSuccess(activationCtx));
|
|
164
|
+
}
|
|
67
165
|
}
|
|
68
166
|
catch (error) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
167
|
+
activationCtx.log.error('webhook execution error', {
|
|
168
|
+
error: JSON.stringify(error),
|
|
169
|
+
});
|
|
170
|
+
if (isAsync) {
|
|
171
|
+
sendResponse(res, onError(activationCtx.withData(error)));
|
|
172
|
+
}
|
|
72
173
|
}
|
|
73
174
|
});
|
|
74
175
|
function cleanup() {
|
|
@@ -83,3 +184,12 @@ exports.webhookCompiler = {
|
|
|
83
184
|
});
|
|
84
185
|
},
|
|
85
186
|
};
|
|
187
|
+
function sendResponse(res, response) {
|
|
188
|
+
res.status(response.status);
|
|
189
|
+
response.headers.forEach((value, key) => {
|
|
190
|
+
res.setHeader(key, value);
|
|
191
|
+
});
|
|
192
|
+
if (response.body) {
|
|
193
|
+
(0, promises_1.pipeline)(response.body, res);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -19,7 +19,6 @@ export declare class NatsKeyValueProvider implements KeyValueProvider, AsyncDisp
|
|
|
19
19
|
private constructor();
|
|
20
20
|
static newInstance(opts?: Partial<NatsKeyValueProviderOptions>): Promise<NatsKeyValueProvider>;
|
|
21
21
|
static fromEnv(): Promise<NatsKeyValueProvider>;
|
|
22
|
-
[Symbol.asyncDispose](): PromiseLike<void>;
|
|
23
22
|
kv(options: KVOptions): KeyValue;
|
|
24
23
|
destroy(options: DestroyOptions): Promise<void>;
|
|
25
24
|
private subjectPrefix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NatsKeyValueProvider.d.ts","sourceRoot":"","sources":["../../../../src/src/kv/nats/NatsKeyValueProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,UAAU,EAAE,MAAM,+DAA+D,CAAC;AACxH,OAAO,EACH,cAAc,EAEd,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACZ,MAAM,gBAAgB,CAAC;AA4CxB,MAAM,MAAM,2BAA2B,GAAG;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE;QACF,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,UAAU,CAAC;KACpB,CAAC;CACL,CAAC;AAuBF,qBAAa,oBAAqB,YAAW,gBAAgB,EAAE,eAAe;IAEtE,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI;IALzB,OAAO;WAQM,WAAW,CACpB,IAAI,GAAE,OAAO,CAAC,2BAA2B,CAAM,GAChD,OAAO,CAAC,oBAAoB,CAAC;IA0BhC,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAQ/C,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ;IAqB1B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBrD,OAAO,CAAC,aAAa;CAYxB"}
|
|
@@ -1,44 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.NatsKeyValueProvider = void 0;
|
|
27
|
-
const dntShim = __importStar(require("../../../_dnt.shims.js"));
|
|
28
4
|
const mod_js_1 = require("../../../deps/jsr.io/@nats-io/jetstream/3.0.2/src/mod.js");
|
|
29
5
|
const mod_js_2 = require("../../../deps/jsr.io/@nats-io/kv/3.0.2/src/mod.js");
|
|
30
6
|
const mod_js_3 = require("../../../deps/jsr.io/@nats-io/transport-deno/3.0.2/src/mod.js");
|
|
31
7
|
const KeyValue_js_1 = require("../KeyValue.js");
|
|
32
8
|
const NatsKeyValue_js_1 = require("./NatsKeyValue.js");
|
|
33
9
|
function getOptionsFromEnv() {
|
|
34
|
-
const natsTlsCaFile =
|
|
10
|
+
const natsTlsCaFile = Deno.env.get('RUN_NATS_TLS_CA_FILE');
|
|
35
11
|
return {
|
|
36
|
-
organizationId:
|
|
37
|
-
projectId:
|
|
38
|
-
environment:
|
|
12
|
+
organizationId: Deno.env.get('RUN_ORGANISATION_ID'),
|
|
13
|
+
projectId: Deno.env.get('RUN_SERVICE_ID'),
|
|
14
|
+
environment: Deno.env.get('RUN_ENVIRONMENT'),
|
|
39
15
|
nats: {
|
|
40
|
-
url:
|
|
41
|
-
credsFile:
|
|
16
|
+
url: Deno.env.get('RUN_NATS_URL') || 'nats://localhost:4222',
|
|
17
|
+
credsFile: Deno.env.get('RUN_NATS_CREDS_FILE'),
|
|
42
18
|
...(natsTlsCaFile && {
|
|
43
19
|
tls: {
|
|
44
20
|
caFile: natsTlsCaFile,
|
|
@@ -111,7 +87,7 @@ class NatsKeyValueProvider {
|
|
|
111
87
|
static async newInstance(opts = {}) {
|
|
112
88
|
const parsedOpts = mergeOptions(getOptionsFromEnv(), opts);
|
|
113
89
|
const credsFile = parsedOpts.nats.credsFile
|
|
114
|
-
? await
|
|
90
|
+
? await Deno.readFile(parsedOpts.nats.credsFile)
|
|
115
91
|
: undefined;
|
|
116
92
|
const conn = await (0, mod_js_3.connect)({
|
|
117
93
|
servers: [parsedOpts.nats.url],
|