@ductape/sdk 0.1.97 → 0.1.99
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/agents/types/agents.types.d.ts +2 -2
- package/dist/clients/interceptors.js +22 -1
- package/dist/clients/interceptors.js.map +1 -1
- package/dist/clients/logs.client.js +6 -1
- package/dist/clients/logs.client.js.map +1 -1
- package/dist/features/feature-executor.d.ts +2 -2
- package/dist/features/feature-executor.js +2 -2
- package/dist/features/feature-executor.js.map +1 -1
- package/dist/features/index.d.ts +7 -2
- package/dist/features/index.js +7 -2
- package/dist/features/index.js.map +1 -1
- package/dist/features/types/features.types.d.ts +2 -2
- package/dist/logs/logs.service.d.ts +12 -0
- package/dist/logs/logs.service.js +106 -19
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +2 -2
- package/dist/products/services/products.service.d.ts +8 -0
- package/dist/products/services/products.service.js +20 -0
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/productsBuilder.types.d.ts +2 -2
- package/dist/types/productsBuilder.types.js +2 -2
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;;;;;AAEH,sBAAsB;AACtB,uDAAmG;AAA1F,kHAAA,cAAc,OAAA;AAAE,gHAAA,YAAY,OAAA;AAAE,kHAAA,cAAc,OAAA;AACrD,uDAAsE;AAA7D,0IAAA,OAAO,OAAyB;AAEzC,iBAAiB;AACjB,qDAAkE;AAAzD,iHAAA,cAAc,OAAA;AAAE,gHAAA,aAAa,OAAA;AACtC,qDAAqE;AAA5D,yIAAA,OAAO,OAAyB;AAEzC,uCAAuC;AACvC,uDAAqE;AAA5D,mHAAA,eAAe,OAAA;AACxB,uDAAuE;AAA9D,2IAAA,OAAO,OAA0B;AAE1C,eAAe;AACf,0CAAwB"}
|
|
@@ -248,7 +248,7 @@ export interface IFeatureStorageContext {
|
|
|
248
248
|
}
|
|
249
249
|
/**
|
|
250
250
|
* Messaging context for feature steps (Ductape primitive).
|
|
251
|
-
* Use ctx.
|
|
251
|
+
* Use ctx.events.produce() to publish to a message broker.
|
|
252
252
|
*/
|
|
253
253
|
export interface IFeatureMessagingContext {
|
|
254
254
|
/**
|
|
@@ -263,7 +263,7 @@ export interface IFeatureMessagingContext {
|
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
265
265
|
* Publish context for feature steps.
|
|
266
|
-
* @deprecated Prefer ctx.
|
|
266
|
+
* @deprecated Prefer ctx.events.produce() (Ductape primitive).
|
|
267
267
|
*/
|
|
268
268
|
export interface IFeaturePublishContext {
|
|
269
269
|
send(options: {
|
|
@@ -7,6 +7,9 @@ export interface ILogsService {
|
|
|
7
7
|
publish(): Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
export default class LogsService {
|
|
10
|
+
private static readonly DEFAULT_BATCH_BYTES;
|
|
11
|
+
private static readonly DEFAULT_ENTRY_DATA_BYTES;
|
|
12
|
+
private static readonly DEFAULT_MAX_RETRIES;
|
|
10
13
|
private eventLogs;
|
|
11
14
|
private user_id;
|
|
12
15
|
private workspace_id;
|
|
@@ -23,6 +26,15 @@ export default class LogsService {
|
|
|
23
26
|
constructor({ workspace_id, public_key, user_id, token, product_id, env_type, app_id, workspace_private_key, ip_address, language }: ILoggerInit);
|
|
24
27
|
add(item: ILogData): void;
|
|
25
28
|
fetchLogs(): ILogData[];
|
|
29
|
+
private configuredByteLimit;
|
|
30
|
+
private byteLength;
|
|
31
|
+
private truncateUtf8;
|
|
32
|
+
private delay;
|
|
33
|
+
private deliverBatch;
|
|
34
|
+
/**
|
|
35
|
+
* Flush telemetry without making application availability depend on the
|
|
36
|
+
* Logs API. Failed and unsent entries remain queued for a later flush.
|
|
37
|
+
*/
|
|
26
38
|
publish(): Promise<void>;
|
|
27
39
|
fetch(params: LogQueryParams): Promise<any>;
|
|
28
40
|
private getUserAccess;
|
|
@@ -30,23 +30,36 @@ class LogsService {
|
|
|
30
30
|
fetchLogs() {
|
|
31
31
|
return this.eventLogs;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
configuredByteLimit(name, fallback) {
|
|
34
|
+
const value = typeof process !== 'undefined' ? Number(process.env[name]) : NaN;
|
|
35
|
+
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
36
|
+
}
|
|
37
|
+
byteLength(value) {
|
|
38
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
39
|
+
}
|
|
40
|
+
truncateUtf8(value, maxBytes) {
|
|
41
|
+
if (new TextEncoder().encode(value).byteLength <= maxBytes)
|
|
42
|
+
return value;
|
|
43
|
+
const suffix = '...[truncated by Ductape Logs]';
|
|
44
|
+
const contentBudget = Math.max(0, maxBytes - new TextEncoder().encode(suffix).byteLength);
|
|
45
|
+
let low = 0;
|
|
46
|
+
let high = value.length;
|
|
47
|
+
while (low < high) {
|
|
48
|
+
const mid = Math.ceil((low + high) / 2);
|
|
49
|
+
if (new TextEncoder().encode(value.slice(0, mid)).byteLength <= contentBudget)
|
|
50
|
+
low = mid;
|
|
51
|
+
else
|
|
52
|
+
high = mid - 1;
|
|
53
|
+
}
|
|
54
|
+
return `${value.slice(0, low)}${suffix}`;
|
|
55
|
+
}
|
|
56
|
+
async delay(ms) {
|
|
57
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
58
|
+
}
|
|
59
|
+
async deliverBatch(batch, attempt = 0) {
|
|
60
|
+
var _a, _b, _c, _d, _e;
|
|
35
61
|
try {
|
|
36
|
-
|
|
37
|
-
? this.eventLogs.map((item) => {
|
|
38
|
-
var _a;
|
|
39
|
-
const dataStr = typeof item.data === 'string' ? item.data : JSON.stringify((_a = item.data) !== null && _a !== void 0 ? _a : {});
|
|
40
|
-
try {
|
|
41
|
-
const encrypted = (0, processor_utils_1.encrypt)(dataStr, this.workspace_private_key);
|
|
42
|
-
return Object.assign(Object.assign({}, item), { data: encrypted, data_encrypted: true });
|
|
43
|
-
}
|
|
44
|
-
catch (_b) {
|
|
45
|
-
return Object.assign(Object.assign({}, item), { data_encrypted: false });
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
: this.eventLogs;
|
|
49
|
-
await this.logsApi.logData(payload, {
|
|
62
|
+
await this.logsApi.logData(batch, {
|
|
50
63
|
user_id: this.user_id,
|
|
51
64
|
token: this.token,
|
|
52
65
|
workspace_id: this.workspace_id,
|
|
@@ -54,10 +67,81 @@ class LogsService {
|
|
|
54
67
|
ip_address: (_a = this.ip_address) !== null && _a !== void 0 ? _a : undefined,
|
|
55
68
|
language: (_b = this.language) !== null && _b !== void 0 ? _b : undefined,
|
|
56
69
|
});
|
|
57
|
-
this.eventLogs = [];
|
|
58
70
|
}
|
|
59
|
-
catch (
|
|
60
|
-
|
|
71
|
+
catch (error) {
|
|
72
|
+
const status = Number((_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.status);
|
|
73
|
+
if (status === 413 && batch.length > 1) {
|
|
74
|
+
const midpoint = Math.ceil(batch.length / 2);
|
|
75
|
+
await this.deliverBatch(batch.slice(0, midpoint), attempt);
|
|
76
|
+
await this.deliverBatch(batch.slice(midpoint), attempt);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const maxRetries = this.configuredByteLimit('DUCTAPE_LOG_MAX_RETRIES', LogsService.DEFAULT_MAX_RETRIES);
|
|
80
|
+
const transient = !status || status === 408 || status === 425 || status === 429 || status >= 500;
|
|
81
|
+
if (transient && attempt < maxRetries) {
|
|
82
|
+
const retryAfterSeconds = Number((_e = (_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.headers) === null || _e === void 0 ? void 0 : _e['retry-after']);
|
|
83
|
+
const exponentialMs = Math.min(30000, 250 * (2 ** attempt));
|
|
84
|
+
const jitterMs = Math.floor(Math.random() * Math.max(1, exponentialMs / 2));
|
|
85
|
+
const delayMs = Number.isFinite(retryAfterSeconds) && retryAfterSeconds >= 0
|
|
86
|
+
? retryAfterSeconds * 1000
|
|
87
|
+
: exponentialMs + jitterMs;
|
|
88
|
+
await this.delay(delayMs);
|
|
89
|
+
await this.deliverBatch(batch, attempt + 1);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Flush telemetry without making application availability depend on the
|
|
97
|
+
* Logs API. Failed and unsent entries remain queued for a later flush.
|
|
98
|
+
*/
|
|
99
|
+
async publish() {
|
|
100
|
+
if (!this.eventLogs.length)
|
|
101
|
+
return;
|
|
102
|
+
const pending = this.eventLogs.splice(0, this.eventLogs.length);
|
|
103
|
+
const maxBatchBytes = this.configuredByteLimit('DUCTAPE_LOG_MAX_BATCH_BYTES', LogsService.DEFAULT_BATCH_BYTES);
|
|
104
|
+
const maxEntryDataBytes = this.configuredByteLimit('DUCTAPE_LOG_MAX_ENTRY_DATA_BYTES', LogsService.DEFAULT_ENTRY_DATA_BYTES);
|
|
105
|
+
const payload = pending.map((item) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const rawData = typeof item.data === 'string' ? item.data : JSON.stringify((_a = item.data) !== null && _a !== void 0 ? _a : {});
|
|
108
|
+
const dataStr = this.truncateUtf8(rawData, maxEntryDataBytes);
|
|
109
|
+
if (!this.workspace_private_key)
|
|
110
|
+
return Object.assign(Object.assign({}, item), { data: dataStr });
|
|
111
|
+
try {
|
|
112
|
+
return Object.assign(Object.assign({}, item), { data: (0, processor_utils_1.encrypt)(dataStr, this.workspace_private_key), data_encrypted: true });
|
|
113
|
+
}
|
|
114
|
+
catch (_b) {
|
|
115
|
+
// Never fall back to sending plaintext when encryption was requested.
|
|
116
|
+
return Object.assign(Object.assign({}, item), { data: '[log encryption failed]', data_encrypted: false });
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
const batches = [];
|
|
120
|
+
let batch = [];
|
|
121
|
+
let batchBytes = 0;
|
|
122
|
+
for (const item of payload) {
|
|
123
|
+
const itemBytes = this.byteLength(item);
|
|
124
|
+
if (batch.length && batchBytes + itemBytes > maxBatchBytes) {
|
|
125
|
+
batches.push(batch);
|
|
126
|
+
batch = [];
|
|
127
|
+
batchBytes = 0;
|
|
128
|
+
}
|
|
129
|
+
batch.push(item);
|
|
130
|
+
batchBytes += itemBytes;
|
|
131
|
+
}
|
|
132
|
+
if (batch.length)
|
|
133
|
+
batches.push(batch);
|
|
134
|
+
for (let index = 0; index < batches.length; index += 1) {
|
|
135
|
+
try {
|
|
136
|
+
await this.deliverBatch(batches[index]);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
const unsent = batches.slice(index).flat();
|
|
140
|
+
this.eventLogs.unshift(...unsent);
|
|
141
|
+
console.warn(`[Ductape Logs] Flush failed; ${unsent.length} log entries retained for retry. ` +
|
|
142
|
+
'Request details were suppressed.');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
61
145
|
}
|
|
62
146
|
}
|
|
63
147
|
async fetch(params) {
|
|
@@ -92,5 +176,8 @@ class LogsService {
|
|
|
92
176
|
};
|
|
93
177
|
}
|
|
94
178
|
}
|
|
179
|
+
LogsService.DEFAULT_BATCH_BYTES = 128 * 1024;
|
|
180
|
+
LogsService.DEFAULT_ENTRY_DATA_BYTES = 64 * 1024;
|
|
181
|
+
LogsService.DEFAULT_MAX_RETRIES = 4;
|
|
95
182
|
exports.default = LogsService;
|
|
96
183
|
//# sourceMappingURL=logs.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.service.js","sourceRoot":"","sources":["../../src/logs/logs.service.ts"],"names":[],"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AC,UAAU,GAAmB,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;QAC1H,CAAC;IACL,CAAC;IAES,aAAa;;QACnB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,SAAS;YACxC,QAAQ,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,SAAS;SACrC,CAAC;IACJ,CAAC;;AA1NqB,+BAAmB,GAAG,GAAG,GAAG,IAAI,CAAC;AACjC,oCAAwB,GAAG,EAAE,GAAG,IAAI,CAAC;AACrC,+BAAmB,GAAG,CAAC,CAAC;kBAH/B,WAAW"}
|
|
@@ -372,9 +372,9 @@ export default class ProcessorService implements IProcessorService {
|
|
|
372
372
|
runBrokerPublish(data: IStepEvent, additional_logs?: Partial<ILogData>): Promise<{
|
|
373
373
|
published: boolean;
|
|
374
374
|
}>;
|
|
375
|
-
processStorageRequest(data: IStepEvent, input: IStorageRequest, storageEnv: IProductStorageEnvs, additional_logs: Partial<ILogData>, decryptionKey?: string): Promise<
|
|
375
|
+
processStorageRequest(data: IStepEvent, input: IStorageRequest, storageEnv: IProductStorageEnvs, additional_logs: Partial<ILogData>, decryptionKey?: string): Promise<{
|
|
376
376
|
url: string;
|
|
377
|
-
}>;
|
|
377
|
+
} | IProcessingFailure>;
|
|
378
378
|
writeResult(status: LogEventStatus, retryable?: boolean): Promise<void>;
|
|
379
379
|
/**
|
|
380
380
|
* Separate credentials into prefixed (e.g., 'headers:Authorization') and non-prefixed (e.g., 'api_key').
|
|
@@ -237,6 +237,14 @@ export default class ProductsBuilderService implements IProductsBuilderService {
|
|
|
237
237
|
getWorkspacePrivateKey(): string | null;
|
|
238
238
|
initializeProduct(product_id: string): Promise<void>;
|
|
239
239
|
initializeProductByTag(tag: string): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* Refresh product-backed component state after an administrative mutation.
|
|
242
|
+
*
|
|
243
|
+
* ProductBuilder instances are cached by the proxy, so clearing only the
|
|
244
|
+
* component caches is insufficient: fetchMessageBroker() would otherwise
|
|
245
|
+
* repopulate them from the pre-mutation product snapshot.
|
|
246
|
+
*/
|
|
247
|
+
private refreshProductState;
|
|
240
248
|
/**
|
|
241
249
|
* Bootstrap action - ultra-lightweight API call to fetch action data needed for processAction
|
|
242
250
|
* Replaces 5+ separate API calls: initializeProduct, fetchApp, fetchThirdPartyApp, fetchEnv, initializePricing
|
|
@@ -486,6 +486,24 @@ class ProductsBuilderService {
|
|
|
486
486
|
throw e;
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Refresh product-backed component state after an administrative mutation.
|
|
491
|
+
*
|
|
492
|
+
* ProductBuilder instances are cached by the proxy, so clearing only the
|
|
493
|
+
* component caches is insufficient: fetchMessageBroker() would otherwise
|
|
494
|
+
* repopulate them from the pre-mutation product snapshot.
|
|
495
|
+
*/
|
|
496
|
+
async refreshProductState() {
|
|
497
|
+
var _a;
|
|
498
|
+
const productReference = ((_a = this.product) === null || _a === void 0 ? void 0 : _a.tag) || this.product_id;
|
|
499
|
+
this.brokerCache.clear();
|
|
500
|
+
this.envCache.clear();
|
|
501
|
+
this.product = (await this.productApi.initProduct(productReference, this.getUserAccess()));
|
|
502
|
+
if (!this.product) {
|
|
503
|
+
throw new Error(`Product "${productReference}" could not be refreshed after update`);
|
|
504
|
+
}
|
|
505
|
+
this.product_id = this.product._id;
|
|
506
|
+
}
|
|
489
507
|
/**
|
|
490
508
|
* Bootstrap action - ultra-lightweight API call to fetch action data needed for processAction
|
|
491
509
|
* Replaces 5+ separate API calls: initializeProduct, fetchApp, fetchThirdPartyApp, fetchEnv, initializePricing
|
|
@@ -801,6 +819,7 @@ class ProductsBuilderService {
|
|
|
801
819
|
data.data = (await (0, string_utils_1.extractPlaceholders)(data.sample));
|
|
802
820
|
}
|
|
803
821
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_TOPIC, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
|
|
822
|
+
await this.refreshProductState();
|
|
804
823
|
}
|
|
805
824
|
else {
|
|
806
825
|
if (throwErrorIfExists)
|
|
@@ -837,6 +856,7 @@ class ProductsBuilderService {
|
|
|
837
856
|
data.data = (await (0, string_utils_1.extractPlaceholders)(data.sample));
|
|
838
857
|
}
|
|
839
858
|
await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { messageBrokerTag, component: enums_1.ProductComponents.MESSAGEBROKER_TOPIC, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
859
|
+
await this.refreshProductState();
|
|
840
860
|
}
|
|
841
861
|
else {
|
|
842
862
|
throw new Error(`Message Broker Topic ${data.tag} not found`);
|