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 | Object.defineProperty(exports, "__esModule", { value: true });
|
26 | exports.EventingFunctionManager = exports.EventingState = exports.EventingFunctionState = exports.EventingFunction = exports.EventingFunctionSettings = exports.EventingFunctionConstantBinding = exports.EventingFunctionUrlBinding = exports.EventingFunctionUrlAuthBearer = exports.EventingFunctionUrlAuthDigest = exports.EventingFunctionUrlAuthBasic = exports.EventingFunctionBucketBinding = exports.EventingFunctionKeyspace = exports.EventingFunctionUrlAuthMethod = exports.EventingFunctionBucketAccess = exports.EventingFunctionLogLevel = exports.EventingFunctionLanguageCompatibility = exports.EventingFunctionStatus = exports.EventingFunctionProcessingStatus = exports.EventingFunctionDeploymentStatus = exports.EventingFunctionDcpBoundary = void 0;
|
27 | const utilities_1 = require("./utilities");
|
28 | const bindingutilities_1 = require("./bindingutilities");
|
29 | const errs = __importStar(require("./errors"));
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | var EventingFunctionDcpBoundary;
|
36 | (function (EventingFunctionDcpBoundary) {
|
37 | |
38 |
|
39 |
|
40 | EventingFunctionDcpBoundary["Everything"] = "everything";
|
41 | |
42 |
|
43 |
|
44 |
|
45 | EventingFunctionDcpBoundary["FromNow"] = "from_now";
|
46 | })(EventingFunctionDcpBoundary || (exports.EventingFunctionDcpBoundary = EventingFunctionDcpBoundary = {}));
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | var EventingFunctionDeploymentStatus;
|
53 | (function (EventingFunctionDeploymentStatus) {
|
54 | |
55 |
|
56 |
|
57 | EventingFunctionDeploymentStatus["Deployed"] = "deployed";
|
58 | |
59 |
|
60 |
|
61 | EventingFunctionDeploymentStatus["Undeployed"] = "undeployed";
|
62 | })(EventingFunctionDeploymentStatus || (exports.EventingFunctionDeploymentStatus = EventingFunctionDeploymentStatus = {}));
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | var EventingFunctionProcessingStatus;
|
69 | (function (EventingFunctionProcessingStatus) {
|
70 | |
71 |
|
72 |
|
73 | EventingFunctionProcessingStatus["Running"] = "running";
|
74 | |
75 |
|
76 |
|
77 | EventingFunctionProcessingStatus["Paused"] = "paused";
|
78 | })(EventingFunctionProcessingStatus || (exports.EventingFunctionProcessingStatus = EventingFunctionProcessingStatus = {}));
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | var EventingFunctionStatus;
|
85 | (function (EventingFunctionStatus) {
|
86 | |
87 |
|
88 |
|
89 | EventingFunctionStatus["Undeployed"] = "undeployed";
|
90 | |
91 |
|
92 |
|
93 | EventingFunctionStatus["Deploying"] = "deploying";
|
94 | |
95 |
|
96 |
|
97 | EventingFunctionStatus["Deployed"] = "deployed";
|
98 | |
99 |
|
100 |
|
101 | EventingFunctionStatus["Undeploying"] = "undeploying";
|
102 | |
103 |
|
104 |
|
105 | EventingFunctionStatus["Paused"] = "paused";
|
106 | |
107 |
|
108 |
|
109 | EventingFunctionStatus["Pausing"] = "pausing";
|
110 | })(EventingFunctionStatus || (exports.EventingFunctionStatus = EventingFunctionStatus = {}));
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | var EventingFunctionLanguageCompatibility;
|
117 | (function (EventingFunctionLanguageCompatibility) {
|
118 | |
119 |
|
120 |
|
121 |
|
122 | EventingFunctionLanguageCompatibility["Version_6_0_0"] = "6.0.0";
|
123 | |
124 |
|
125 |
|
126 |
|
127 | EventingFunctionLanguageCompatibility["Version_6_5_0"] = "6.5.0";
|
128 | |
129 |
|
130 |
|
131 |
|
132 | EventingFunctionLanguageCompatibility["Version_6_6_2"] = "6.6.2";
|
133 | |
134 |
|
135 |
|
136 |
|
137 | EventingFunctionLanguageCompatibility["Version_7_2_0"] = "7.2.0";
|
138 | })(EventingFunctionLanguageCompatibility || (exports.EventingFunctionLanguageCompatibility = EventingFunctionLanguageCompatibility = {}));
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | var EventingFunctionLogLevel;
|
145 | (function (EventingFunctionLogLevel) {
|
146 | |
147 |
|
148 |
|
149 | EventingFunctionLogLevel["Info"] = "INFO";
|
150 | |
151 |
|
152 |
|
153 | EventingFunctionLogLevel["Error"] = "ERROR";
|
154 | |
155 |
|
156 |
|
157 | EventingFunctionLogLevel["Warning"] = "WARNING";
|
158 | |
159 |
|
160 |
|
161 | EventingFunctionLogLevel["Debug"] = "DEBUG";
|
162 | |
163 |
|
164 |
|
165 | EventingFunctionLogLevel["Trace"] = "TRACE";
|
166 | })(EventingFunctionLogLevel || (exports.EventingFunctionLogLevel = EventingFunctionLogLevel = {}));
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 | var EventingFunctionBucketAccess;
|
173 | (function (EventingFunctionBucketAccess) {
|
174 | |
175 |
|
176 |
|
177 | EventingFunctionBucketAccess["ReadOnly"] = "r";
|
178 | |
179 |
|
180 |
|
181 | EventingFunctionBucketAccess["ReadWrite"] = "rw";
|
182 | })(EventingFunctionBucketAccess || (exports.EventingFunctionBucketAccess = EventingFunctionBucketAccess = {}));
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | var EventingFunctionUrlAuthMethod;
|
189 | (function (EventingFunctionUrlAuthMethod) {
|
190 | |
191 |
|
192 |
|
193 | EventingFunctionUrlAuthMethod["None"] = "no-auth";
|
194 | |
195 |
|
196 |
|
197 | EventingFunctionUrlAuthMethod["Basic"] = "basic";
|
198 | |
199 |
|
200 |
|
201 | EventingFunctionUrlAuthMethod["Digest"] = "digest";
|
202 | |
203 |
|
204 |
|
205 | EventingFunctionUrlAuthMethod["Bearer"] = "bearer";
|
206 | })(EventingFunctionUrlAuthMethod || (exports.EventingFunctionUrlAuthMethod = EventingFunctionUrlAuthMethod = {}));
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | class EventingFunctionKeyspace {
|
213 | constructor(v) {
|
214 | this.bucket = v.bucket;
|
215 | this.scope = v.scope;
|
216 | this.collection = v.collection;
|
217 | }
|
218 | }
|
219 | exports.EventingFunctionKeyspace = EventingFunctionKeyspace;
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 | class EventingFunctionBucketBinding {
|
226 | constructor(v) {
|
227 | this.alias = v.alias;
|
228 | this.name = v.name;
|
229 | this.access = v.access;
|
230 | }
|
231 | |
232 |
|
233 |
|
234 | static _fromCppData(data) {
|
235 | return new EventingFunctionBucketBinding({
|
236 | alias: data.alias,
|
237 | name: new EventingFunctionKeyspace({
|
238 | bucket: data.name.bucket,
|
239 | scope: data.name.scope,
|
240 | collection: data.name.collection,
|
241 | }),
|
242 | access: (0, bindingutilities_1.eventingBucketBindingAccessFromCpp)(data.access),
|
243 | });
|
244 | }
|
245 | |
246 |
|
247 |
|
248 | static _toCppData(data) {
|
249 | return {
|
250 | alias: data.alias,
|
251 | name: {
|
252 | bucket: data.name.bucket,
|
253 | scope: data.name.scope,
|
254 | collection: data.name.collection,
|
255 | },
|
256 | access: (0, bindingutilities_1.eventingBucketBindingAccessToCpp)(data.access),
|
257 | };
|
258 | }
|
259 | }
|
260 | exports.EventingFunctionBucketBinding = EventingFunctionBucketBinding;
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 | class EventingFunctionUrlAuthBasic {
|
267 | constructor(v) {
|
268 | |
269 |
|
270 |
|
271 | this.method = EventingFunctionUrlAuthMethod.Basic;
|
272 | this.username = v.username;
|
273 | this.password = v.password;
|
274 | }
|
275 | }
|
276 | exports.EventingFunctionUrlAuthBasic = EventingFunctionUrlAuthBasic;
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | class EventingFunctionUrlAuthDigest {
|
283 | constructor(v) {
|
284 | |
285 |
|
286 |
|
287 | this.method = EventingFunctionUrlAuthMethod.Digest;
|
288 | this.username = v.username;
|
289 | this.password = v.password;
|
290 | }
|
291 | }
|
292 | exports.EventingFunctionUrlAuthDigest = EventingFunctionUrlAuthDigest;
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 | class EventingFunctionUrlAuthBearer {
|
299 | constructor(v) {
|
300 | |
301 |
|
302 |
|
303 | this.method = EventingFunctionUrlAuthMethod.Bearer;
|
304 | this.key = v.key;
|
305 | }
|
306 | }
|
307 | exports.EventingFunctionUrlAuthBearer = EventingFunctionUrlAuthBearer;
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 | class EventingFunctionUrlBinding {
|
314 | constructor(v) {
|
315 | this.hostname = v.hostname;
|
316 | this.alias = v.alias;
|
317 | this.auth = v.auth;
|
318 | this.allowCookies = v.allowCookies;
|
319 | this.validateSslCertificate = v.validateSslCertificate;
|
320 | }
|
321 | |
322 |
|
323 |
|
324 | static _fromCppData(data) {
|
325 | let authObj;
|
326 | if (data.auth_name === 'function_url_no_auth') {
|
327 | authObj = undefined;
|
328 | }
|
329 | else if (data.auth_name === 'function_url_auth_basic') {
|
330 | authObj = new EventingFunctionUrlAuthBasic({
|
331 | username: data.auth_value
|
332 | .username,
|
333 | password: data.auth_value
|
334 | .password,
|
335 | });
|
336 | }
|
337 | else if (data.auth_name === 'function_url_auth_digest') {
|
338 | authObj = new EventingFunctionUrlAuthDigest({
|
339 | username: data.auth_value.username,
|
340 | password: data.auth_value.password,
|
341 | });
|
342 | }
|
343 | else if (data.auth_name === 'function_url_auth_bearer') {
|
344 | authObj = new EventingFunctionUrlAuthBearer({
|
345 | key: data.auth_value
|
346 | .key,
|
347 | });
|
348 | }
|
349 | else {
|
350 | throw new errs.InvalidArgumentError(new Error('Unrecognized EventingFunctionUrlBinding: ' + data.auth_name));
|
351 | }
|
352 | return {
|
353 | hostname: data.hostname,
|
354 | alias: data.alias,
|
355 | allowCookies: data.allow_cookies,
|
356 | validateSslCertificate: data.validate_ssl_certificate,
|
357 | auth: authObj,
|
358 | };
|
359 | }
|
360 | |
361 |
|
362 |
|
363 | static _toCppData(data) {
|
364 | let authObj;
|
365 | let auth_name;
|
366 | if (!data.auth || data.auth.method === EventingFunctionUrlAuthMethod.None) {
|
367 | authObj = {};
|
368 | auth_name = 'function_url_no_auth';
|
369 | }
|
370 | else if (data.auth.method === EventingFunctionUrlAuthMethod.Basic) {
|
371 | authObj = {
|
372 | username: data.auth.username,
|
373 | password: data.auth.password,
|
374 | };
|
375 | auth_name = 'function_url_auth_basic';
|
376 | }
|
377 | else if (data.auth.method === EventingFunctionUrlAuthMethod.Digest) {
|
378 | authObj = {
|
379 | username: data.auth.username,
|
380 | password: data.auth.password,
|
381 | };
|
382 | auth_name = 'function_url_auth_digest';
|
383 | }
|
384 | else if (data.auth.method === EventingFunctionUrlAuthMethod.Bearer) {
|
385 | authObj = {
|
386 | key: data.auth.key,
|
387 | };
|
388 | auth_name = 'function_url_auth_bearer';
|
389 | }
|
390 | else {
|
391 | throw new errs.InvalidArgumentError(new Error('Unrecognized EventingFunctionUrlBinding'));
|
392 | }
|
393 | return {
|
394 | alias: data.alias,
|
395 | hostname: data.hostname,
|
396 | allow_cookies: data.allowCookies,
|
397 | validate_ssl_certificate: data.validateSslCertificate,
|
398 | auth_name: auth_name,
|
399 | auth_value: authObj,
|
400 | };
|
401 | }
|
402 | }
|
403 | exports.EventingFunctionUrlBinding = EventingFunctionUrlBinding;
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 | class EventingFunctionConstantBinding {
|
410 | constructor(v) {
|
411 | this.alias = v.alias;
|
412 | this.literal = v.literal;
|
413 | }
|
414 | |
415 |
|
416 |
|
417 | static _fromCppData(data) {
|
418 | return new EventingFunctionConstantBinding({
|
419 | alias: data.alias,
|
420 | literal: data.literal,
|
421 | });
|
422 | }
|
423 | |
424 |
|
425 |
|
426 | static _toCppData(data) {
|
427 | return {
|
428 | alias: data.alias,
|
429 | literal: data.literal,
|
430 | };
|
431 | }
|
432 | }
|
433 | exports.EventingFunctionConstantBinding = EventingFunctionConstantBinding;
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | class EventingFunctionSettings {
|
441 | constructor(v) {
|
442 | this.cppWorkerThreadCount = v.cppWorkerThreadCount;
|
443 | this.dcpStreamBoundary = v.dcpStreamBoundary;
|
444 | this.description = v.description;
|
445 | this.deploymentStatus = v.deploymentStatus;
|
446 | this.processingStatus = v.processingStatus;
|
447 | this.languageCompatibility = v.languageCompatibility;
|
448 | this.logLevel = v.logLevel;
|
449 | this.executionTimeout = v.executionTimeout;
|
450 | this.lcbInstCapacity = v.lcbInstCapacity;
|
451 | this.lcbRetryCount = v.lcbRetryCount;
|
452 | this.lcbTimeout = v.lcbTimeout;
|
453 | this.queryConsistency = v.queryConsistency;
|
454 | this.numTimerPartitions = v.numTimerPartitions;
|
455 | this.sockBatchSize = v.sockBatchSize;
|
456 | this.tickDuration = v.tickDuration;
|
457 | this.timerContextSize = v.timerContextSize;
|
458 | this.userPrefix = v.userPrefix;
|
459 | this.bucketCacheSize = v.bucketCacheSize;
|
460 | this.bucketCacheAge = v.bucketCacheAge;
|
461 | this.curlMaxAllowedRespSize = v.curlMaxAllowedRespSize;
|
462 | this.queryPrepareAll = v.queryPrepareAll;
|
463 | this.workerCount = v.workerCount;
|
464 | this.handlerHeaders = v.handlerHeaders;
|
465 | this.handlerFooters = v.handlerFooters;
|
466 | this.enableAppLogRotation = v.enableAppLogRotation;
|
467 | this.appLogDir = v.appLogDir;
|
468 | this.appLogMaxSize = v.appLogMaxSize;
|
469 | this.appLogMaxFiles = v.appLogMaxFiles;
|
470 | this.checkpointInterval = v.checkpointInterval;
|
471 | }
|
472 | |
473 |
|
474 |
|
475 | static _fromCppData(data) {
|
476 | return new EventingFunctionSettings({
|
477 | cppWorkerThreadCount: data.cpp_worker_count,
|
478 | dcpStreamBoundary: (0, bindingutilities_1.eventingFunctionDcpBoundaryFromCpp)(data.dcp_stream_boundary),
|
479 | description: data.description,
|
480 | deploymentStatus: (0, bindingutilities_1.eventingFunctionDeploymentStatusFromCpp)(data.deployment_status),
|
481 | processingStatus: (0, bindingutilities_1.eventingFunctionProcessingStatusFromCpp)(data.processing_status),
|
482 | logLevel: (0, bindingutilities_1.eventingFunctionLogLevelFromCpp)(data.log_level),
|
483 | languageCompatibility: (0, bindingutilities_1.eventingFunctionLanguageCompatibilityFromCpp)(data.language_compatibility),
|
484 | executionTimeout: data.execution_timeout,
|
485 | lcbInstCapacity: data.lcb_inst_capacity,
|
486 | lcbRetryCount: data.lcb_retry_count,
|
487 | lcbTimeout: data.lcb_timeout,
|
488 | queryConsistency: (0, bindingutilities_1.queryScanConsistencyFromCpp)(data.query_consistency),
|
489 | numTimerPartitions: data.num_timer_partitions,
|
490 | sockBatchSize: data.sock_batch_size,
|
491 | tickDuration: data.tick_duration,
|
492 | timerContextSize: data.timer_context_size,
|
493 | userPrefix: data.user_prefix,
|
494 | bucketCacheSize: data.bucket_cache_size,
|
495 | bucketCacheAge: data.bucket_cache_age,
|
496 | curlMaxAllowedRespSize: data.curl_max_allowed_resp_size,
|
497 | queryPrepareAll: data.query_prepare_all,
|
498 | workerCount: data.worker_count,
|
499 | handlerHeaders: data.handler_headers,
|
500 | handlerFooters: data.handler_footers,
|
501 | enableAppLogRotation: data.enable_app_log_rotation,
|
502 | appLogDir: data.app_log_dir,
|
503 | appLogMaxSize: data.app_log_max_size,
|
504 | appLogMaxFiles: data.app_log_max_files,
|
505 | checkpointInterval: data.checkpoint_interval,
|
506 | });
|
507 | }
|
508 | |
509 |
|
510 |
|
511 | static _toCppData(data) {
|
512 | var _a, _b;
|
513 | if (!data) {
|
514 | return {
|
515 | handler_headers: [],
|
516 | handler_footers: [],
|
517 | };
|
518 | }
|
519 | return {
|
520 | cpp_worker_count: data.cppWorkerThreadCount,
|
521 | dcp_stream_boundary: (0, bindingutilities_1.eventingFunctionDcpBoundaryToCpp)(data.dcpStreamBoundary),
|
522 | description: data.description,
|
523 | deployment_status: (0, bindingutilities_1.eventingFunctionDeploymentStatusToCpp)(data.deploymentStatus),
|
524 | processing_status: (0, bindingutilities_1.eventingFunctionProcessingStatusToCpp)(data.processingStatus),
|
525 | log_level: (0, bindingutilities_1.eventingFunctionLogLevelToCpp)(data.logLevel),
|
526 | language_compatibility: (0, bindingutilities_1.eventingFunctionLanguageCompatibilityToCpp)(data.languageCompatibility),
|
527 | execution_timeout: data.executionTimeout,
|
528 | lcb_inst_capacity: data.lcbInstCapacity,
|
529 | lcb_retry_count: data.lcbRetryCount,
|
530 | lcb_timeout: data.lcbTimeout,
|
531 | query_consistency: (0, bindingutilities_1.queryScanConsistencyToCpp)(data.queryConsistency),
|
532 | num_timer_partitions: data.numTimerPartitions,
|
533 | sock_batch_size: data.sockBatchSize,
|
534 | tick_duration: data.tickDuration,
|
535 | timer_context_size: data.timerContextSize,
|
536 | user_prefix: data.userPrefix,
|
537 | bucket_cache_size: data.bucketCacheSize,
|
538 | bucket_cache_age: data.bucketCacheAge,
|
539 | curl_max_allowed_resp_size: data.curlMaxAllowedRespSize,
|
540 | query_prepare_all: data.queryPrepareAll,
|
541 | worker_count: data.workerCount,
|
542 | handler_headers: (_a = data.handlerHeaders) !== null && _a !== void 0 ? _a : [],
|
543 | handler_footers: (_b = data.handlerFooters) !== null && _b !== void 0 ? _b : [],
|
544 | enable_app_log_rotation: data.enableAppLogRotation,
|
545 | app_log_dir: data.appLogDir,
|
546 | app_log_max_size: data.appLogMaxSize,
|
547 | app_log_max_files: data.appLogMaxFiles,
|
548 | checkpoint_interval: data.checkpointInterval,
|
549 | };
|
550 | }
|
551 | }
|
552 | exports.EventingFunctionSettings = EventingFunctionSettings;
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 | class EventingFunction {
|
559 | constructor(v) {
|
560 | this.name = v.name;
|
561 | this.code = v.code;
|
562 | this.version = v.version;
|
563 | this.enforceSchema = v.enforceSchema;
|
564 | this.handlerUuid = v.handlerUuid;
|
565 | this.functionInstanceId = v.functionInstanceId;
|
566 | this.metadataKeyspace = v.metadataKeyspace;
|
567 | this.sourceKeyspace = v.sourceKeyspace;
|
568 | this.bucketBindings = v.bucketBindings;
|
569 | this.urlBindings = v.urlBindings;
|
570 | this.constantBindings = v.constantBindings;
|
571 | this.settings = v.settings;
|
572 | }
|
573 | |
574 |
|
575 |
|
576 | static _fromCppData(data) {
|
577 | return new EventingFunction({
|
578 | name: data.name,
|
579 | code: data.code,
|
580 | metadataKeyspace: new EventingFunctionKeyspace({
|
581 | bucket: data.metadata_keyspace.bucket,
|
582 | scope: data.metadata_keyspace.scope,
|
583 | collection: data.metadata_keyspace.collection,
|
584 | }),
|
585 | sourceKeyspace: new EventingFunctionKeyspace({
|
586 | bucket: data.source_keyspace.bucket,
|
587 | scope: data.source_keyspace.scope,
|
588 | collection: data.source_keyspace.collection,
|
589 | }),
|
590 | version: data.version,
|
591 | enforceSchema: data.enforce_schema,
|
592 | handlerUuid: data.handler_uuid,
|
593 | functionInstanceId: data.function_instance_id,
|
594 | bucketBindings: data.bucket_bindings.map((bindingData) => EventingFunctionBucketBinding._fromCppData(bindingData)),
|
595 | urlBindings: data.url_bindings.map((bindingData) => EventingFunctionUrlBinding._fromCppData(bindingData)),
|
596 | constantBindings: data.constant_bindings.map((bindingData) => EventingFunctionConstantBinding._fromCppData(bindingData)),
|
597 | settings: EventingFunctionSettings._fromCppData(data.settings),
|
598 | });
|
599 | }
|
600 | |
601 |
|
602 |
|
603 | static _toCppData(data) {
|
604 | return {
|
605 | name: data.name,
|
606 | code: data.code,
|
607 | metadata_keyspace: {
|
608 | bucket: data.metadataKeyspace.bucket,
|
609 | scope: data.metadataKeyspace.scope,
|
610 | collection: data.metadataKeyspace.collection,
|
611 | },
|
612 | source_keyspace: {
|
613 | bucket: data.sourceKeyspace.bucket,
|
614 | scope: data.sourceKeyspace.scope,
|
615 | collection: data.sourceKeyspace.collection,
|
616 | },
|
617 | version: data.version,
|
618 | enforce_schema: data.enforceSchema,
|
619 | handler_uuid: data.handlerUuid,
|
620 | function_instance_id: data.functionInstanceId,
|
621 | bucket_bindings: data.bucketBindings.map((binding) => EventingFunctionBucketBinding._toCppData(binding)),
|
622 | url_bindings: data.urlBindings.map((binding) => EventingFunctionUrlBinding._toCppData(binding)),
|
623 | constant_bindings: data.constantBindings.map((binding) => EventingFunctionConstantBinding._toCppData(binding)),
|
624 | settings: EventingFunctionSettings._toCppData(data.settings),
|
625 | };
|
626 | }
|
627 | }
|
628 | exports.EventingFunction = EventingFunction;
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 | class EventingFunctionState {
|
635 | constructor(v) {
|
636 | this.name = v.name;
|
637 | this.status = v.status;
|
638 | this.numBootstrappingNodes = v.numBootstrappingNodes;
|
639 | this.numDeployedNodes = v.numDeployedNodes;
|
640 | this.deploymentStatus = v.deploymentStatus;
|
641 | this.processingStatus = v.processingStatus;
|
642 | }
|
643 | |
644 |
|
645 |
|
646 | static _fromCppData(data) {
|
647 | return new EventingFunctionState({
|
648 | name: data.name,
|
649 | status: (0, bindingutilities_1.eventingFunctionStatusFromCpp)(data.status),
|
650 | numBootstrappingNodes: data.num_bootstrapping_nodes,
|
651 | numDeployedNodes: data.num_deployed_nodes,
|
652 |
|
653 | deploymentStatus: (0, bindingutilities_1.eventingFunctionDeploymentStatusFromCpp)(data.deployment_status),
|
654 | processingStatus: (0, bindingutilities_1.eventingFunctionProcessingStatusFromCpp)(data.processing_status),
|
655 | });
|
656 | }
|
657 | }
|
658 | exports.EventingFunctionState = EventingFunctionState;
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 | class EventingState {
|
665 | constructor(v) {
|
666 | this.numEventingNodes = v.numEventingNodes;
|
667 | this.functions = v.functions;
|
668 | }
|
669 | |
670 |
|
671 |
|
672 | static _fromCppData(data) {
|
673 | return new EventingState({
|
674 | numEventingNodes: data.num_eventing_nodes,
|
675 | functions: data.functions.map((functionData) => EventingFunctionState._fromCppData(functionData)),
|
676 | });
|
677 | }
|
678 | }
|
679 | exports.EventingState = EventingState;
|
680 |
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 | class EventingFunctionManager {
|
688 | |
689 |
|
690 |
|
691 | constructor(cluster) {
|
692 | this._cluster = cluster;
|
693 | }
|
694 | |
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 | async upsertFunction(functionDefinition, options, callback) {
|
702 | if (options instanceof Function) {
|
703 | callback = arguments[1];
|
704 | options = undefined;
|
705 | }
|
706 | if (!options) {
|
707 | options = {};
|
708 | }
|
709 | const timeout = options.timeout || this._cluster.managementTimeout;
|
710 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
711 | this._cluster.conn.managementEventingUpsertFunction({
|
712 | function: EventingFunction._toCppData(functionDefinition),
|
713 | timeout: timeout,
|
714 | }, (cppErr) => {
|
715 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
716 | if (err) {
|
717 | return wrapCallback(err, null);
|
718 | }
|
719 | wrapCallback(err);
|
720 | });
|
721 | }, callback);
|
722 | }
|
723 | |
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 | async dropFunction(name, options, callback) {
|
731 | if (options instanceof Function) {
|
732 | callback = arguments[1];
|
733 | options = undefined;
|
734 | }
|
735 | if (!options) {
|
736 | options = {};
|
737 | }
|
738 | const timeout = options.timeout || this._cluster.managementTimeout;
|
739 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
740 | this._cluster.conn.managementEventingDropFunction({
|
741 | name: name,
|
742 | timeout: timeout,
|
743 | }, (cppErr) => {
|
744 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
745 | if (err) {
|
746 | return wrapCallback(err, null);
|
747 | }
|
748 | wrapCallback(err);
|
749 | });
|
750 | }, callback);
|
751 | }
|
752 | |
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 | async getAllFunctions(options, callback) {
|
759 | if (options instanceof Function) {
|
760 | callback = arguments[0];
|
761 | options = undefined;
|
762 | }
|
763 | if (!options) {
|
764 | options = {};
|
765 | }
|
766 | const timeout = options.timeout || this._cluster.managementTimeout;
|
767 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
768 | this._cluster.conn.managementEventingGetAllFunctions({
|
769 | timeout: timeout,
|
770 | }, (cppErr, resp) => {
|
771 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
772 | if (err) {
|
773 | return wrapCallback(err, null);
|
774 | }
|
775 | const functions = resp.functions.map((functionData) => EventingFunction._fromCppData(functionData));
|
776 | wrapCallback(null, functions);
|
777 | });
|
778 | }, callback);
|
779 | }
|
780 | |
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 | async getFunction(name, options, callback) {
|
788 | if (options instanceof Function) {
|
789 | callback = arguments[1];
|
790 | options = undefined;
|
791 | }
|
792 | if (!options) {
|
793 | options = {};
|
794 | }
|
795 | const timeout = options.timeout || this._cluster.managementTimeout;
|
796 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
797 | this._cluster.conn.managementEventingGetFunction({
|
798 | name: name,
|
799 | timeout: timeout,
|
800 | }, (cppErr, resp) => {
|
801 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
802 | if (err) {
|
803 | return wrapCallback(err, null);
|
804 | }
|
805 | const eventingFunction = EventingFunction._fromCppData(resp.function);
|
806 | wrapCallback(null, eventingFunction);
|
807 | });
|
808 | }, callback);
|
809 | }
|
810 | |
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 |
|
817 | async deployFunction(name, options, callback) {
|
818 | if (options instanceof Function) {
|
819 | callback = arguments[1];
|
820 | options = undefined;
|
821 | }
|
822 | if (!options) {
|
823 | options = {};
|
824 | }
|
825 | const timeout = options.timeout || this._cluster.managementTimeout;
|
826 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
827 | this._cluster.conn.managementEventingDeployFunction({
|
828 | name: name,
|
829 | timeout: timeout,
|
830 | }, (cppErr) => {
|
831 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
832 | if (err) {
|
833 | return wrapCallback(err, null);
|
834 | }
|
835 | wrapCallback(err);
|
836 | });
|
837 | }, callback);
|
838 | }
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 | async undeployFunction(name, options, callback) {
|
847 | if (options instanceof Function) {
|
848 | callback = arguments[1];
|
849 | options = undefined;
|
850 | }
|
851 | if (!options) {
|
852 | options = {};
|
853 | }
|
854 | const timeout = options.timeout || this._cluster.managementTimeout;
|
855 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
856 | this._cluster.conn.managementEventingUndeployFunction({
|
857 | name: name,
|
858 | timeout: timeout,
|
859 | }, (cppErr) => {
|
860 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
861 | if (err) {
|
862 | return wrapCallback(err, null);
|
863 | }
|
864 | wrapCallback(err);
|
865 | });
|
866 | }, callback);
|
867 | }
|
868 | |
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 | async pauseFunction(name, options, callback) {
|
876 | if (options instanceof Function) {
|
877 | callback = arguments[1];
|
878 | options = undefined;
|
879 | }
|
880 | if (!options) {
|
881 | options = {};
|
882 | }
|
883 | const timeout = options.timeout || this._cluster.managementTimeout;
|
884 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
885 | this._cluster.conn.managementEventingPauseFunction({
|
886 | name: name,
|
887 | timeout: timeout,
|
888 | }, (cppErr) => {
|
889 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
890 | if (err) {
|
891 | return wrapCallback(err, null);
|
892 | }
|
893 | wrapCallback(err);
|
894 | });
|
895 | }, callback);
|
896 | }
|
897 | |
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 |
|
904 | async resumeFunction(name, options, callback) {
|
905 | if (options instanceof Function) {
|
906 | callback = arguments[1];
|
907 | options = undefined;
|
908 | }
|
909 | if (!options) {
|
910 | options = {};
|
911 | }
|
912 | const timeout = options.timeout || this._cluster.managementTimeout;
|
913 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
914 | this._cluster.conn.managementEventingResumeFunction({
|
915 | name: name,
|
916 | timeout: timeout,
|
917 | }, (cppErr) => {
|
918 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
919 | if (err) {
|
920 | return wrapCallback(err, null);
|
921 | }
|
922 | wrapCallback(err);
|
923 | });
|
924 | }, callback);
|
925 | }
|
926 | |
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 | async functionsStatus(options, callback) {
|
933 | if (options instanceof Function) {
|
934 | callback = arguments[0];
|
935 | options = undefined;
|
936 | }
|
937 | if (!options) {
|
938 | options = {};
|
939 | }
|
940 | const timeout = options.timeout || this._cluster.managementTimeout;
|
941 | return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
942 | this._cluster.conn.managementEventingGetStatus({
|
943 | timeout: timeout,
|
944 | }, (cppErr, resp) => {
|
945 | const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
946 | if (err) {
|
947 | return wrapCallback(err, null);
|
948 | }
|
949 | const state = EventingState._fromCppData(resp.status);
|
950 | wrapCallback(null, state);
|
951 | });
|
952 | }, callback);
|
953 | }
|
954 | }
|
955 | exports.EventingFunctionManager = EventingFunctionManager;
|