@ductape/sdk 0.2.9 → 0.2.11
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/dist/api/services/processorApi.service.d.ts +4 -0
- package/dist/api/services/processorApi.service.js +13 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +8 -0
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/features/feature-executor.js +3 -17
- package/dist/features/feature-executor.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/dist/logs/logs.service.d.ts +3 -0
- package/dist/logs/logs.service.js +21 -0
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +5 -0
- package/dist/processor/services/processor.service.js +58 -3
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/products/services/products.service.js +2 -2
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/resilience/fallback.service.d.ts +2 -4
- package/dist/resilience/fallback.service.js +56 -65
- package/dist/resilience/fallback.service.js.map +1 -1
- package/dist/resilience/health-status-cache.d.ts +11 -0
- package/dist/resilience/health-status-cache.js +46 -0
- package/dist/resilience/health-status-cache.js.map +1 -0
- package/dist/resilience/healthcheck.service.js +1 -1
- package/dist/resilience/healthcheck.service.js.map +1 -1
- package/dist/resilience/quota.service.d.ts +3 -5
- package/dist/resilience/quota.service.js +82 -62
- package/dist/resilience/quota.service.js.map +1 -1
- package/dist/resilience/resilience.service.js +6 -2
- package/dist/resilience/resilience.service.js.map +1 -1
- package/dist/resilience/types/index.d.ts +8 -0
- package/dist/runtime/resilient-write-queue.d.ts +18 -0
- package/dist/runtime/resilient-write-queue.js +74 -0
- package/dist/runtime/resilient-write-queue.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/productsBuilder.types.d.ts +2 -0
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,6 +24,8 @@ export default class LogsService {
|
|
|
24
24
|
private environment;
|
|
25
25
|
private ip_address;
|
|
26
26
|
private language;
|
|
27
|
+
private retryTimer?;
|
|
28
|
+
private retryAttempt;
|
|
27
29
|
constructor({ workspace_id, public_key, user_id, token, product_id, env_type, app_id, workspace_private_key, ip_address, language }: ILoggerInit);
|
|
28
30
|
add(item: ILogData): void;
|
|
29
31
|
fetchLogs(): ILogData[];
|
|
@@ -38,6 +40,7 @@ export default class LogsService {
|
|
|
38
40
|
* Logs API. Failed and unsent entries remain queued for a later flush.
|
|
39
41
|
*/
|
|
40
42
|
publish(): Promise<void>;
|
|
43
|
+
private scheduleRetry;
|
|
41
44
|
fetch(params: LogQueryParams): Promise<any>;
|
|
42
45
|
private getUserAccess;
|
|
43
46
|
}
|
|
@@ -4,6 +4,7 @@ const logsApi_service_1 = require("../api/services/logsApi.service");
|
|
|
4
4
|
const processor_utils_1 = require("../processor/utils/processor.utils");
|
|
5
5
|
class LogsService {
|
|
6
6
|
constructor({ workspace_id, public_key, user_id, token, product_id, env_type, app_id, workspace_private_key, ip_address, language }) {
|
|
7
|
+
this.retryAttempt = 0;
|
|
7
8
|
this.workspace_id = workspace_id;
|
|
8
9
|
this.public_key = public_key;
|
|
9
10
|
this.user_id = user_id;
|
|
@@ -111,6 +112,8 @@ class LogsService {
|
|
|
111
112
|
const maxEntryDataBytes = this.configuredByteLimit('DUCTAPE_LOG_MAX_ENTRY_DATA_BYTES', LogsService.DEFAULT_ENTRY_DATA_BYTES);
|
|
112
113
|
const payload = pending.map((item) => {
|
|
113
114
|
var _a;
|
|
115
|
+
if (item.data_encrypted)
|
|
116
|
+
return item;
|
|
114
117
|
const rawData = typeof item.data === 'string' ? item.data : JSON.stringify((_a = item.data) !== null && _a !== void 0 ? _a : {});
|
|
115
118
|
const dataStr = this.truncateUtf8(rawData, maxEntryDataBytes);
|
|
116
119
|
if (!this.workspace_private_key)
|
|
@@ -147,9 +150,27 @@ class LogsService {
|
|
|
147
150
|
this.eventLogs.unshift(...unsent);
|
|
148
151
|
console.warn(`[Ductape Logs] Flush failed; ${unsent.length} log entries retained for retry. ` +
|
|
149
152
|
'Request details were suppressed.');
|
|
153
|
+
this.scheduleRetry();
|
|
150
154
|
return;
|
|
151
155
|
}
|
|
152
156
|
}
|
|
157
|
+
this.retryAttempt = 0;
|
|
158
|
+
if (this.retryTimer)
|
|
159
|
+
clearTimeout(this.retryTimer);
|
|
160
|
+
this.retryTimer = undefined;
|
|
161
|
+
}
|
|
162
|
+
scheduleRetry() {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
if (this.retryTimer)
|
|
165
|
+
return;
|
|
166
|
+
this.retryAttempt += 1;
|
|
167
|
+
const exponential = Math.min(60000, 500 * (2 ** Math.min(this.retryAttempt, 7)));
|
|
168
|
+
const jitter = Math.floor(Math.random() * Math.max(1, exponential / 4));
|
|
169
|
+
this.retryTimer = setTimeout(() => {
|
|
170
|
+
this.retryTimer = undefined;
|
|
171
|
+
void this.publish();
|
|
172
|
+
}, exponential + jitter);
|
|
173
|
+
(_b = (_a = this.retryTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
153
174
|
}
|
|
154
175
|
async fetch(params) {
|
|
155
176
|
if (!params.component) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.service.js","sourceRoot":"","sources":["../../src/logs/logs.service.ts"],"names":[],"mappings":";;AAAA,qEAAgF;AAChF,wEAA6D;AAY7D,MAAqB,WAAW;
|
|
1
|
+
{"version":3,"file":"logs.service.js","sourceRoot":"","sources":["../../src/logs/logs.service.ts"],"names":[],"mappings":";;AAAA,qEAAgF;AAChF,wEAA6D;AAY7D,MAAqB,WAAW;IAqB5B,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,qBAAqB,EAAE,UAAU,EAAE,QAAQ,EAAe;QAFxI,iBAAY,GAAG,CAAC,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,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,SAAS;YACxC,QAAQ,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,SAAS;SACrC,CAAC;IACJ,CAAC;;AArPqB,+BAAmB,GAAG,GAAG,GAAG,IAAI,AAAb,CAAc;AACjC,oCAAwB,GAAG,EAAE,GAAG,IAAI,AAAZ,CAAa;AACrC,+BAAmB,GAAG,CAAC,AAAJ,CAAK;kBAH/B,WAAW"}
|
|
@@ -461,6 +461,11 @@ export default class ProcessorService implements IProcessorService {
|
|
|
461
461
|
* Fetches the latest healthcheck status for a product/env from Redis cache.
|
|
462
462
|
*/
|
|
463
463
|
getHealthcheckStatusFromCache(productTag: string, envSlug: string): Promise<any>;
|
|
464
|
+
/**
|
|
465
|
+
* Opens the provider circuit immediately after an operation failure. The
|
|
466
|
+
* interval monitor is deliberately the only path that closes it again.
|
|
467
|
+
*/
|
|
468
|
+
markHealthcheckUnavailable(productTag: string, healthcheckTag: string, envSlug: string, reason?: string): Promise<void>;
|
|
464
469
|
/**
|
|
465
470
|
* Updates the healthcheck in the remote DB for a product with all envs' results.
|
|
466
471
|
*/
|
|
@@ -49,6 +49,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
49
49
|
var _a, _b;
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
const products_service_1 = __importDefault(require("../../products/services/products.service"));
|
|
52
|
+
const health_status_cache_1 = require("../../resilience/health-status-cache");
|
|
52
53
|
const types_1 = require("../../types");
|
|
53
54
|
const logs_service_1 = __importDefault(require("../../logs/logs.service"));
|
|
54
55
|
const cloud_runtime_util_1 = require("../../cloud/cloud-runtime.util");
|
|
@@ -4684,7 +4685,7 @@ class ProcessorService {
|
|
|
4684
4685
|
async writeResult(status, retryable = true) {
|
|
4685
4686
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
4686
4687
|
const envSlug = (_f = (_d = (_b = (_a = this.processEnv) === null || _a === void 0 ? void 0 : _a.slug) !== null && _b !== void 0 ? _b : (_c = this.input) === null || _c === void 0 ? void 0 : _c.env) !== null && _d !== void 0 ? _d : (_e = this.baseLogs) === null || _e === void 0 ? void 0 : _e.env) !== null && _f !== void 0 ? _f : '';
|
|
4687
|
-
|
|
4688
|
+
this.processorApiService.enqueueResult(Object.assign(Object.assign({ status, component: this.component, start: this.start, end: this.end, retryable, result: (0, processor_utils_1.encrypt)(JSON.stringify(this.processingOutput), this.productBuilderService.fetchPrivateKey()), process_id: this.process_id, product_id: this.productId, product_tag: this.productTag ||
|
|
4688
4689
|
((_g = this.input) === null || _g === void 0 ? void 0 : _g.product) ||
|
|
4689
4690
|
((_h = this.baseLogs) === null || _h === void 0 ? void 0 : _h.product_tag), workspace_id: this.workspace_id }, ((_j = this.featureExecutionContext) !== null && _j !== void 0 ? _j : {})), { env: envSlug, input: (0, processor_utils_1.encrypt)(JSON.stringify(this.input), this.productBuilderService.fetchPrivateKey()) }), Object.assign(Object.assign({}, this.getUserAccess()), { access_key: this.accessKey }));
|
|
4690
4691
|
}
|
|
@@ -4802,7 +4803,7 @@ class ProcessorService {
|
|
|
4802
4803
|
}
|
|
4803
4804
|
}
|
|
4804
4805
|
async processAction(action) {
|
|
4805
|
-
var _a, _b, _c;
|
|
4806
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4806
4807
|
await create_productFeature_validator_1.ActionProcessorInputSchema.validateAsync(action, { abortEarly: true }).catch((err) => {
|
|
4807
4808
|
var _a, _b, _c, _d;
|
|
4808
4809
|
throw new Error((_d = (_c = (_b = (_a = err.details) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : err.message) !== null && _d !== void 0 ? _d : 'Invalid action input');
|
|
@@ -4899,7 +4900,7 @@ class ProcessorService {
|
|
|
4899
4900
|
try {
|
|
4900
4901
|
this.productBuilderService.fetchPrivateKey();
|
|
4901
4902
|
}
|
|
4902
|
-
catch (
|
|
4903
|
+
catch (_g) {
|
|
4903
4904
|
await this.productBuilderService.initializeProductByTag(product_tag);
|
|
4904
4905
|
}
|
|
4905
4906
|
}
|
|
@@ -4929,6 +4930,38 @@ class ProcessorService {
|
|
|
4929
4930
|
// Every action entry point (direct, Feature, Quota, Fallback, Healthcheck)
|
|
4930
4931
|
// converges here, so connection credentials are resolved once for all of them.
|
|
4931
4932
|
const allCredentials = {};
|
|
4933
|
+
const connectionMapping = bootstrapData.product_env_mapping;
|
|
4934
|
+
for (const variable of (_d = connectionMapping === null || connectionMapping === void 0 ? void 0 : connectionMapping.variables) !== null && _d !== void 0 ? _d : []) {
|
|
4935
|
+
if ((variable === null || variable === void 0 ? void 0 : variable.key) && variable.value !== undefined) {
|
|
4936
|
+
allCredentials[String(variable.key)] = variable.value;
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
if ((connectionMapping === null || connectionMapping === void 0 ? void 0 : connectionMapping.credentials) && typeof connectionMapping.credentials === 'object') {
|
|
4940
|
+
Object.assign(allCredentials, connectionMapping.credentials);
|
|
4941
|
+
}
|
|
4942
|
+
// Token-access auth is already the reusable request credential. Resolve it lazily just
|
|
4943
|
+
// like Workbench shared configuration; credential-access login secrets stay isolated.
|
|
4944
|
+
if (((_e = bootstrapData.app_auth) === null || _e === void 0 ? void 0 : _e.setup_type) === 'token_access' && ((_f = connectionMapping === null || connectionMapping === void 0 ? void 0 : connectionMapping.auth) === null || _f === void 0 ? void 0 : _f.data)) {
|
|
4945
|
+
let authData = connectionMapping.auth.data;
|
|
4946
|
+
if (typeof authData === 'string') {
|
|
4947
|
+
try {
|
|
4948
|
+
authData = JSON.parse((0, processor_utils_1.decrypt)(authData, String(bootstrapData.private_key)));
|
|
4949
|
+
}
|
|
4950
|
+
catch (_h) {
|
|
4951
|
+
authData = undefined;
|
|
4952
|
+
}
|
|
4953
|
+
}
|
|
4954
|
+
if (authData && typeof authData === 'object') {
|
|
4955
|
+
for (const location of ['headers', 'query', 'params', 'body']) {
|
|
4956
|
+
const values = authData[location];
|
|
4957
|
+
if (!values || typeof values !== 'object' || Array.isArray(values))
|
|
4958
|
+
continue;
|
|
4959
|
+
for (const [key, value] of Object.entries(values)) {
|
|
4960
|
+
allCredentials[`${location}:${key}`] = value;
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
}
|
|
4932
4965
|
const sharedCredentials = credential_manager_1.credentialManager.get({ product: product_tag, app, env });
|
|
4933
4966
|
if (sharedCredentials)
|
|
4934
4967
|
Object.assign(allCredentials, sharedCredentials);
|
|
@@ -5426,6 +5459,15 @@ class ProcessorService {
|
|
|
5426
5459
|
* Writes the healthcheck result to Redis cache for fast status retrieval.
|
|
5427
5460
|
*/
|
|
5428
5461
|
async writeHealthcheckResultToCache(data, result) {
|
|
5462
|
+
var _a, _b, _c;
|
|
5463
|
+
if ((data === null || data === void 0 ? void 0 : data.product) && (data === null || data === void 0 ? void 0 : data.healthcheck) && (data === null || data === void 0 ? void 0 : data.env)) {
|
|
5464
|
+
(0, health_status_cache_1.setRuntimeHealthState)(this.workspace_id, data.product, data.env, data.healthcheck, {
|
|
5465
|
+
status: (result === null || result === void 0 ? void 0 : result.status) === 'available' || (result === null || result === void 0 ? void 0 : result.status) === 'unavailable' ? result.status : 'unknown',
|
|
5466
|
+
lastChecked: (_b = (_a = result === null || result === void 0 ? void 0 : result.checkedAt) !== null && _a !== void 0 ? _a : result === null || result === void 0 ? void 0 : result.lastChecked) !== null && _b !== void 0 ? _b : new Date().toISOString(),
|
|
5467
|
+
latency: Number.isFinite(Number(result === null || result === void 0 ? void 0 : result.latency)) ? Number(result.latency) : undefined,
|
|
5468
|
+
statusSource: (_c = result === null || result === void 0 ? void 0 : result.status_source) !== null && _c !== void 0 ? _c : result === null || result === void 0 ? void 0 : result.statusSource,
|
|
5469
|
+
});
|
|
5470
|
+
}
|
|
5429
5471
|
if (!this.redisClient)
|
|
5430
5472
|
return;
|
|
5431
5473
|
const key = `healthcheck:${data.product}:${data.healthcheck}:${data.env}`;
|
|
@@ -5443,6 +5485,19 @@ class ProcessorService {
|
|
|
5443
5485
|
const cached = await this.redisClient.get(key);
|
|
5444
5486
|
return cached ? JSON.parse(cached) : null;
|
|
5445
5487
|
}
|
|
5488
|
+
/**
|
|
5489
|
+
* Opens the provider circuit immediately after an operation failure. The
|
|
5490
|
+
* interval monitor is deliberately the only path that closes it again.
|
|
5491
|
+
*/
|
|
5492
|
+
async markHealthcheckUnavailable(productTag, healthcheckTag, envSlug, reason) {
|
|
5493
|
+
const checkedAt = new Date().toISOString();
|
|
5494
|
+
const result = Object.assign({ status: 'unavailable', checkedAt, latency: 0, status_source: 'runtime_failure' }, (reason ? { reason: reason.slice(0, 500) } : {}));
|
|
5495
|
+
void this.writeHealthcheckResultToCache({ product: productTag, healthcheck: healthcheckTag, env: envSlug }, result).catch(() => undefined);
|
|
5496
|
+
void this.updateHealthcheckOnProcessor(productTag, [{
|
|
5497
|
+
tag: healthcheckTag,
|
|
5498
|
+
environments: [Object.assign({ slug: envSlug }, result)],
|
|
5499
|
+
}]).catch(() => undefined);
|
|
5500
|
+
}
|
|
5446
5501
|
/**
|
|
5447
5502
|
* Updates the healthcheck in the remote DB for a product with all envs' results.
|
|
5448
5503
|
*/
|