@ductape/sdk 0.1.154 → 0.1.155
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/productsApi.service.d.ts +31 -0
- package/dist/api/services/productsApi.service.js +14 -0
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +1 -0
- package/dist/api/urls.js +5 -4
- package/dist/api/urls.js.map +1 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +152 -1
- package/dist/index.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +2 -2
- package/dist/products/bootstrap-cache.d.ts +8 -0
- package/dist/products/bootstrap-cache.js +27 -0
- package/dist/products/bootstrap-cache.js.map +1 -1
- package/dist/products/services/products.service.js +37 -7
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.types.d.ts +9 -0
- package/dist/types/index.types.js.map +1 -1
- package/package.json +1 -1
|
@@ -384,9 +384,9 @@ export default class ProcessorService implements IProcessorService {
|
|
|
384
384
|
runBrokerPublish(data: IStepEvent, additional_logs?: Partial<ILogData>): Promise<{
|
|
385
385
|
published: boolean;
|
|
386
386
|
}>;
|
|
387
|
-
processStorageRequest(data: IStepEvent, input: IStorageRequest, storageEnv: IProductStorageEnvs, additional_logs: Partial<ILogData>, decryptionKey?: string): Promise<
|
|
387
|
+
processStorageRequest(data: IStepEvent, input: IStorageRequest, storageEnv: IProductStorageEnvs, additional_logs: Partial<ILogData>, decryptionKey?: string): Promise<{
|
|
388
388
|
url: string;
|
|
389
|
-
}>;
|
|
389
|
+
} | IProcessingFailure>;
|
|
390
390
|
writeResult(status: LogEventStatus, retryable?: boolean): Promise<void>;
|
|
391
391
|
/**
|
|
392
392
|
* Separate credentials into prefixed (e.g., 'headers:Authorization') and non-prefixed (e.g., 'api_key').
|
|
@@ -4,8 +4,16 @@ import type { IBootstrapFeatureStep } from '../api/services/productsApi.service'
|
|
|
4
4
|
export declare const BOOTSTRAP_CACHE_TTL_MS: number;
|
|
5
5
|
export declare const BOOTSTRAP_REDIS_PREFIX = "ductape:bootstrap:";
|
|
6
6
|
export type BootstrapDomain = 'action' | 'notification' | 'storage' | 'session' | 'database' | 'broker' | 'graph' | 'vector' | 'resilience' | 'intelligence' | 'workflow';
|
|
7
|
+
export interface IRuntimeBootstrapEntry {
|
|
8
|
+
domain: BootstrapDomain;
|
|
9
|
+
parts: string[];
|
|
10
|
+
data: unknown;
|
|
11
|
+
}
|
|
7
12
|
export declare function buildBootstrapCacheKey(domain: BootstrapDomain, workspaceId: string, parts: Array<string | undefined | null>): string;
|
|
8
13
|
export declare function hashFeatureSteps(steps: IBootstrapFeatureStep[]): string;
|
|
14
|
+
/** Atomically prime all runtime entries into the process cache. */
|
|
15
|
+
export declare function primeRuntimeBootstrapCache(workspaceId: string, scope: string, entries: IRuntimeBootstrapEntry[]): void;
|
|
16
|
+
export declare function touchRuntimeBootstrapCache(scope: string): void;
|
|
9
17
|
/**
|
|
10
18
|
* Tiered bootstrap response cache: in-memory first, optional Redis (encrypted with workspace key).
|
|
11
19
|
* Keys: domain:workspaceId:product:env:tag…
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BootstrapCache = exports.BOOTSTRAP_REDIS_PREFIX = exports.BOOTSTRAP_CACHE_TTL_MS = void 0;
|
|
4
4
|
exports.buildBootstrapCacheKey = buildBootstrapCacheKey;
|
|
5
5
|
exports.hashFeatureSteps = hashFeatureSteps;
|
|
6
|
+
exports.primeRuntimeBootstrapCache = primeRuntimeBootstrapCache;
|
|
7
|
+
exports.touchRuntimeBootstrapCache = touchRuntimeBootstrapCache;
|
|
6
8
|
const crypto_1 = require("crypto");
|
|
7
9
|
const processor_utils_1 = require("../processor/utils/processor.utils");
|
|
8
10
|
/** TTL for bootstrap cache (same component version = same bootstrap). 5 minutes. */
|
|
@@ -23,6 +25,31 @@ function hashFeatureSteps(steps) {
|
|
|
23
25
|
// only caused duplicate calls when Features delegated to Database/Graph/etc.
|
|
24
26
|
const processBootstrapCache = new Map();
|
|
25
27
|
const processBootstrapInFlight = new Map();
|
|
28
|
+
const processRuntimeKeys = new Map();
|
|
29
|
+
/** Atomically prime all runtime entries into the process cache. */
|
|
30
|
+
function primeRuntimeBootstrapCache(workspaceId, scope, entries) {
|
|
31
|
+
const storedAt = Date.now();
|
|
32
|
+
const replacements = entries.map((entry) => ({
|
|
33
|
+
key: buildBootstrapCacheKey(entry.domain, workspaceId, entry.parts),
|
|
34
|
+
data: entry.data,
|
|
35
|
+
}));
|
|
36
|
+
const nextKeys = new Set(replacements.map((entry) => entry.key));
|
|
37
|
+
for (const previousKey of processRuntimeKeys.get(scope) || []) {
|
|
38
|
+
if (!nextKeys.has(previousKey))
|
|
39
|
+
processBootstrapCache.delete(previousKey);
|
|
40
|
+
}
|
|
41
|
+
for (const entry of replacements)
|
|
42
|
+
processBootstrapCache.set(entry.key, { data: entry.data, storedAt });
|
|
43
|
+
processRuntimeKeys.set(scope, nextKeys);
|
|
44
|
+
}
|
|
45
|
+
function touchRuntimeBootstrapCache(scope) {
|
|
46
|
+
const storedAt = Date.now();
|
|
47
|
+
for (const key of processRuntimeKeys.get(scope) || []) {
|
|
48
|
+
const entry = processBootstrapCache.get(key);
|
|
49
|
+
if (entry)
|
|
50
|
+
processBootstrapCache.set(key, Object.assign(Object.assign({}, entry), { storedAt }));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
26
53
|
/**
|
|
27
54
|
* Tiered bootstrap response cache: in-memory first, optional Redis (encrypted with workspace key).
|
|
28
55
|
* Keys: domain:workspaceId:product:env:tag…
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-cache.js","sourceRoot":"","sources":["../../src/products/bootstrap-cache.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bootstrap-cache.js","sourceRoot":"","sources":["../../src/products/bootstrap-cache.ts"],"names":[],"mappings":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MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;YAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,EAAE,CAAC;QACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,OAAO;gBAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AA/ED,wCA+EC"}
|
|
@@ -624,17 +624,15 @@ class ProductsBuilderService {
|
|
|
624
624
|
}
|
|
625
625
|
async bootstrapNotification(params) {
|
|
626
626
|
try {
|
|
627
|
-
|
|
628
|
-
const result = await this.productApi.bootstrapNotification(params, this.getUserAccess());
|
|
629
|
-
if (result.notification && result.private_key) {
|
|
630
|
-
result.notification = this.decryptNotificationChannelConfigs(result.notification, result.private_key);
|
|
631
|
-
}
|
|
632
|
-
return result;
|
|
633
|
-
}, (result) => {
|
|
627
|
+
const result = await this.cachedBootstrap('notification', [params.product_tag, params.env_slug, params.notification_tag, params.message_tag], () => this.productApi.bootstrapNotification(params, this.getUserAccess()), (result) => {
|
|
634
628
|
if (result.product_id) {
|
|
635
629
|
this.product_id = result.product_id;
|
|
636
630
|
}
|
|
637
631
|
});
|
|
632
|
+
if (result.notification && result.private_key) {
|
|
633
|
+
result.notification = this.decryptNotificationChannelConfigs(result.notification, result.private_key);
|
|
634
|
+
}
|
|
635
|
+
return result;
|
|
638
636
|
}
|
|
639
637
|
catch (e) {
|
|
640
638
|
throw e;
|
|
@@ -713,8 +711,40 @@ class ProductsBuilderService {
|
|
|
713
711
|
* Bootstrap feature - fetch all action/notification/storage data for multiple steps in one API call
|
|
714
712
|
*/
|
|
715
713
|
async bootstrapFeature(params) {
|
|
714
|
+
var _a;
|
|
716
715
|
try {
|
|
717
716
|
const auth = this.getUserAccess();
|
|
717
|
+
const cachedSteps = {};
|
|
718
|
+
for (const step of params.steps) {
|
|
719
|
+
const domain = step.type === 'quota' || step.type === 'fallback' ? 'resilience' : step.type;
|
|
720
|
+
const parts = step.type === 'action'
|
|
721
|
+
? [params.product_tag, step.access_tag, params.env_slug, step.action_tag]
|
|
722
|
+
: step.type === 'notification'
|
|
723
|
+
? [params.product_tag, params.env_slug, step.notification_tag, step.message_tag]
|
|
724
|
+
: step.type === 'storage'
|
|
725
|
+
? [params.product_tag, params.env_slug, step.storage_tag]
|
|
726
|
+
: step.type === 'database'
|
|
727
|
+
? [params.product_tag, params.env_slug, step.database_tag]
|
|
728
|
+
: step.type === 'broker'
|
|
729
|
+
? [params.product_tag, params.env_slug, step.broker_tag, (_a = step.topic_tag) !== null && _a !== void 0 ? _a : '']
|
|
730
|
+
: step.type === 'graph'
|
|
731
|
+
? [params.product_tag, params.env_slug, step.graph_tag]
|
|
732
|
+
: step.type === 'vector'
|
|
733
|
+
? [params.product_tag, params.env_slug, step.vector_tag]
|
|
734
|
+
: [params.product_tag, params.env_slug, step.type, step.component_tag];
|
|
735
|
+
const cached = await this.bootstrapCache.get((0, bootstrap_cache_1.buildBootstrapCacheKey)(domain, this.workspace_id, parts));
|
|
736
|
+
if (cached == null)
|
|
737
|
+
break;
|
|
738
|
+
const cachedData = cached;
|
|
739
|
+
cachedSteps[step.step_tag] = step.type === 'notification' && (cachedData === null || cachedData === void 0 ? void 0 : cachedData.notification) && (cachedData === null || cachedData === void 0 ? void 0 : cachedData.private_key)
|
|
740
|
+
? Object.assign(Object.assign({}, cachedData), { notification: this.decryptNotificationChannelConfigs(cachedData.notification, cachedData.private_key) }) : cached;
|
|
741
|
+
}
|
|
742
|
+
if (Object.keys(cachedSteps).length === params.steps.length) {
|
|
743
|
+
const first = Object.values(cachedSteps)[0];
|
|
744
|
+
if (first)
|
|
745
|
+
this.applyBootstrapProductContext(params.product_tag, first);
|
|
746
|
+
return cachedSteps;
|
|
747
|
+
}
|
|
718
748
|
return await this.cachedBootstrap('workflow', [params.product_tag, params.env_slug, (0, bootstrap_cache_1.hashFeatureSteps)(params.steps)], async () => {
|
|
719
749
|
var _a;
|
|
720
750
|
const result = await this.productApi.bootstrapFeature(Object.assign(Object.assign({}, params), { workspace_id: auth.workspace_id }), auth);
|