@ductape/sdk 0.1.25 → 0.1.27
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/README.md +83 -52
- package/dist/agents/agent-context.d.ts +1 -1
- package/dist/agents/agent-context.js +1 -1
- package/dist/agents/agent-context.js.map +1 -1
- package/dist/agents/agents.service.js +4 -4
- package/dist/agents/agents.service.js.map +1 -1
- package/dist/agents/types/agents.types.d.ts +6 -6
- package/dist/api/services/featureApi.service.d.ts +199 -0
- package/dist/api/services/featureApi.service.js +201 -0
- package/dist/api/services/featureApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +2 -2
- package/dist/api/services/processorApi.service.js +1 -1
- package/dist/api/services/productsApi.service.d.ts +6 -6
- package/dist/api/services/productsApi.service.js +3 -3
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +12 -12
- package/dist/api/urls.js +22 -22
- package/dist/api/urls.js.map +1 -1
- package/dist/apps/validators/index.d.ts +5 -1
- package/dist/apps/validators/index.js +9 -1
- package/dist/apps/validators/index.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.d.ts +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js +1 -0
- package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +1 -0
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +1 -0
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.d.ts +1 -0
- package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js +1 -0
- package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js.map +1 -1
- package/dist/brokers/brokers.service.d.ts +2 -2
- package/dist/brokers/brokers.service.js +2 -2
- package/dist/brokers/brokers.service.js.map +1 -1
- package/dist/brokers/types/index.d.ts +1 -1
- package/dist/cloud/cloud-database-link.util.js +22 -3
- package/dist/cloud/cloud-database-link.util.js.map +1 -1
- package/dist/cloud/cloud-service-map.util.js +6 -5
- package/dist/cloud/cloud-service-map.util.js.map +1 -1
- package/dist/cloud/index.d.ts +1 -1
- package/dist/cloud/index.js +3 -1
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/types/cloud.types.d.ts +1 -1
- package/dist/cloud/vpc-connector-connect.util.d.ts +11 -2
- package/dist/cloud/vpc-connector-connect.util.js +7 -0
- package/dist/cloud/vpc-connector-connect.util.js.map +1 -1
- package/dist/cloud/vpc-connector-tunnel.client.d.ts +26 -0
- package/dist/cloud/vpc-connector-tunnel.client.js +70 -0
- package/dist/cloud/vpc-connector-tunnel.client.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.js +15 -0
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.js +11 -55
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/databases.service.d.ts +3 -3
- package/dist/database/databases.service.js +18 -18
- package/dist/database/databases.service.js.map +1 -1
- package/dist/database/index.d.ts +1 -1
- package/dist/database/triggers/trigger-processor.d.ts +7 -7
- package/dist/database/triggers/trigger-processor.js +17 -17
- package/dist/database/triggers/trigger-processor.js.map +1 -1
- package/dist/database/types/connection.interface.d.ts +0 -2
- package/dist/database/types/index.d.ts +1 -1
- package/dist/database/types/trigger.interface.d.ts +9 -9
- package/dist/database/types/trigger.interface.js +3 -3
- package/dist/database/types/trigger.interface.js.map +1 -1
- package/dist/features/feature-builder.d.ts +70 -0
- package/dist/features/feature-builder.js +348 -0
- package/dist/features/feature-builder.js.map +1 -0
- package/dist/features/feature-executor.d.ts +289 -0
- package/dist/features/feature-executor.js +2444 -0
- package/dist/features/feature-executor.js.map +1 -0
- package/dist/features/features.service.d.ts +412 -0
- package/dist/features/features.service.js +2222 -0
- package/dist/features/features.service.js.map +1 -0
- package/dist/features/index.d.ts +30 -0
- package/dist/features/index.js +64 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/types/features.types.d.ts +1081 -0
- package/dist/features/types/features.types.js +13 -0
- package/dist/features/types/features.types.js.map +1 -0
- package/dist/features/types/index.d.ts +6 -0
- package/dist/features/types/index.js +23 -0
- package/dist/features/types/index.js.map +1 -0
- package/dist/index.d.ts +35 -48
- package/dist/index.js +48 -63
- package/dist/index.js.map +1 -1
- package/dist/init.interface.d.ts +1 -11
- package/dist/inputs/inputs.service.d.ts +4 -4
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/introspect/index.d.ts +31 -0
- package/dist/introspect/index.js +168 -0
- package/dist/introspect/index.js.map +1 -0
- package/dist/jobs/index.d.ts +1 -1
- package/dist/jobs/types.d.ts +3 -3
- package/dist/logs/logs.service.d.ts +0 -3
- package/dist/logs/logs.service.js +1 -4
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/logs/logs.types.d.ts +4 -7
- package/dist/logs/logs.types.js +2 -3
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +27 -26
- package/dist/processor/services/processor.service.js +71 -72
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.d.ts +2 -2
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/products/bootstrap-cache.d.ts +2 -2
- package/dist/products/bootstrap-cache.js +3 -3
- package/dist/products/bootstrap-cache.js.map +1 -1
- package/dist/products/services/products.service.d.ts +32 -57
- package/dist/products/services/products.service.js +44 -397
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/validators/index.d.ts +1 -3
- package/dist/products/validators/index.js +1 -5
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js +1 -1
- package/dist/products/validators/joi-validators/create.productDatabase.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productFeature.validator.d.ts +1 -7
- package/dist/products/validators/joi-validators/create.productFeature.validator.js +6 -61
- package/dist/products/validators/joi-validators/create.productFeature.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js +23 -27
- package/dist/products/validators/joi-validators/update.productDatabase.validator.js.map +1 -1
- package/dist/resilience/fallback.service.js +19 -41
- package/dist/resilience/fallback.service.js.map +1 -1
- package/dist/resilience/healthcheck.service.d.ts +5 -5
- package/dist/resilience/healthcheck.service.js +26 -26
- package/dist/resilience/healthcheck.service.js.map +1 -1
- package/dist/resilience/quota.service.js +17 -27
- package/dist/resilience/quota.service.js.map +1 -1
- package/dist/resilience/resilience-execution.utils.d.ts +2 -2
- package/dist/resilience/resilience-execution.utils.js +7 -7
- package/dist/resilience/resilience-execution.utils.js.map +1 -1
- package/dist/resilience/resilience.service.js +14 -30
- package/dist/resilience/resilience.service.js.map +1 -1
- package/dist/resilience/types/index.d.ts +20 -23
- package/dist/resilience/types/index.js +2 -3
- package/dist/resilience/types/index.js.map +1 -1
- package/dist/types/enums.d.ts +1 -2
- package/dist/types/enums.js +1 -2
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +3 -4
- package/dist/types/index.types.js +2 -2
- package/dist/types/index.types.js.map +1 -1
- package/dist/types/logs.types.d.ts +0 -1
- package/dist/types/logs.types.js.map +1 -1
- package/dist/types/processor.types.d.ts +11 -13
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +52 -58
- package/dist/types/productsBuilder.types.js +57 -55
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/package.json +5 -2
|
@@ -226,7 +226,7 @@ class ProcessorService {
|
|
|
226
226
|
return service;
|
|
227
227
|
}
|
|
228
228
|
/**
|
|
229
|
-
* Disconnect all pooled broker connections (e.g. at end of
|
|
229
|
+
* Disconnect all pooled broker connections (e.g. at end of feature run).
|
|
230
230
|
* Safe to call if pool is empty or a broker has no disconnect().
|
|
231
231
|
*/
|
|
232
232
|
async disconnectBrokerConnections() {
|
|
@@ -326,7 +326,7 @@ class ProcessorService {
|
|
|
326
326
|
return transporter;
|
|
327
327
|
}
|
|
328
328
|
/**
|
|
329
|
-
* Close all pooled mail transporters (e.g. at end of
|
|
329
|
+
* Close all pooled mail transporters (e.g. at end of feature run). Safe if pool is empty.
|
|
330
330
|
*/
|
|
331
331
|
async disconnectMailTransporters() {
|
|
332
332
|
for (const [key, transporter] of this.mailTransporterPool.entries()) {
|
|
@@ -434,7 +434,7 @@ class ProcessorService {
|
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
/**
|
|
437
|
-
* Close all pooled Firebase apps (e.g. at end of
|
|
437
|
+
* Close all pooled Firebase apps (e.g. at end of feature run). Safe if pool is empty.
|
|
438
438
|
*/
|
|
439
439
|
async disconnectFirebaseApps() {
|
|
440
440
|
for (const [projectId, app] of this.firebaseAppPool.entries()) {
|
|
@@ -522,7 +522,7 @@ class ProcessorService {
|
|
|
522
522
|
return client;
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
525
|
-
* Clear pooled SMS clients (e.g. at end of
|
|
525
|
+
* Clear pooled SMS clients (e.g. at end of feature run). Safe if pool is empty.
|
|
526
526
|
*/
|
|
527
527
|
async disconnectSmsClients() {
|
|
528
528
|
for (const [key] of this.smsClientPool.entries()) {
|
|
@@ -573,11 +573,11 @@ class ProcessorService {
|
|
|
573
573
|
}
|
|
574
574
|
/**
|
|
575
575
|
* Run a single healthcheck (one env) by dispatching to the correct processor based on probe type.
|
|
576
|
-
* Supports app, database,
|
|
576
|
+
* Supports app, database, feature, graph, storage, message_broker. Falls back to processAction when probe is missing (app/event only).
|
|
577
577
|
* Public so the SDK monitor worker can call it with full healthcheck (including probe).
|
|
578
578
|
*/
|
|
579
579
|
async runOneHealthcheck(healthcheck, envSlug, decryptedInput, productTag) {
|
|
580
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
580
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
581
581
|
const probe = healthcheck.probe;
|
|
582
582
|
const retries = (_a = healthcheck.retries) !== null && _a !== void 0 ? _a : 0;
|
|
583
583
|
const inferType = () => {
|
|
@@ -587,8 +587,8 @@ class ProcessorService {
|
|
|
587
587
|
return 'app';
|
|
588
588
|
if (probe === null || probe === void 0 ? void 0 : probe.database)
|
|
589
589
|
return 'database';
|
|
590
|
-
if (probe === null || probe === void 0 ? void 0 : probe.workflow)
|
|
591
|
-
return '
|
|
590
|
+
if ((probe === null || probe === void 0 ? void 0 : probe.feature) || (probe === null || probe === void 0 ? void 0 : probe.workflow))
|
|
591
|
+
return 'feature';
|
|
592
592
|
if (probe === null || probe === void 0 ? void 0 : probe.graph)
|
|
593
593
|
return 'graph';
|
|
594
594
|
if (probe === null || probe === void 0 ? void 0 : probe.storage)
|
|
@@ -622,11 +622,11 @@ class ProcessorService {
|
|
|
622
622
|
event: event !== null && event !== void 0 ? event : 'test_connection',
|
|
623
623
|
input: decryptedInput !== null && decryptedInput !== void 0 ? decryptedInput : {},
|
|
624
624
|
});
|
|
625
|
-
case '
|
|
626
|
-
return this.
|
|
625
|
+
case 'feature':
|
|
626
|
+
return this.processFeature({
|
|
627
627
|
env: envSlug,
|
|
628
628
|
product: productTag,
|
|
629
|
-
|
|
629
|
+
feature: (_g = probe.feature) !== null && _g !== void 0 ? _g : probe.workflow,
|
|
630
630
|
input: decryptedInput !== null && decryptedInput !== void 0 ? decryptedInput : {},
|
|
631
631
|
});
|
|
632
632
|
case 'graph':
|
|
@@ -662,8 +662,8 @@ class ProcessorService {
|
|
|
662
662
|
return this.processAction({
|
|
663
663
|
env: envSlug,
|
|
664
664
|
product: productTag,
|
|
665
|
-
app: (
|
|
666
|
-
action: (
|
|
665
|
+
app: (_h = healthcheck.app) !== null && _h !== void 0 ? _h : '',
|
|
666
|
+
action: (_k = (_j = healthcheck.event) !== null && _j !== void 0 ? _j : event) !== null && _k !== void 0 ? _k : '',
|
|
667
667
|
input: decryptedInput !== null && decryptedInput !== void 0 ? decryptedInput : {},
|
|
668
668
|
retries,
|
|
669
669
|
});
|
|
@@ -687,7 +687,7 @@ class ProcessorService {
|
|
|
687
687
|
/**
|
|
688
688
|
* Start healthcheck workers for all products/environments after Redis is connected.
|
|
689
689
|
* This is called automatically in the constructor if redisClient is present.
|
|
690
|
-
* Dispatches to app, database,
|
|
690
|
+
* Dispatches to app, database, feature, graph, storage, or message_broker processor based on probe type.
|
|
691
691
|
* Every HEALTHCHECK_REFRESH_MS we re-fetch the list and only clear/recreate workers when the fingerprint
|
|
692
692
|
* (tag:env:interval set) has changed, so existing timers are not reset when nothing changed.
|
|
693
693
|
*/
|
|
@@ -731,7 +731,7 @@ class ProcessorService {
|
|
|
731
731
|
}
|
|
732
732
|
/**
|
|
733
733
|
* Manually trigger healthcheck processing for all healthchecks (can be called externally if needed).
|
|
734
|
-
* Dispatches to app, database,
|
|
734
|
+
* Dispatches to app, database, feature, graph, storage, or message_broker processor based on probe type.
|
|
735
735
|
*/
|
|
736
736
|
async processAllHealthchecksForProduct(productTag) {
|
|
737
737
|
await this.productBuilderService.initializeProductByTag(productTag);
|
|
@@ -893,7 +893,7 @@ class ProcessorService {
|
|
|
893
893
|
app: access_tag,
|
|
894
894
|
event: '',
|
|
895
895
|
input: env.auth,
|
|
896
|
-
type: types_1.
|
|
896
|
+
type: types_1.StepEventTypes.ACTION,
|
|
897
897
|
retries: 0,
|
|
898
898
|
allow_fail: false,
|
|
899
899
|
}));
|
|
@@ -1699,7 +1699,7 @@ class ProcessorService {
|
|
|
1699
1699
|
if (success) {
|
|
1700
1700
|
return success.output;
|
|
1701
1701
|
}
|
|
1702
|
-
/*if(event.type ===
|
|
1702
|
+
/*if(event.type === StepEventTypes.QUOTA) {
|
|
1703
1703
|
this.logService.add({
|
|
1704
1704
|
...this.baseLogs,
|
|
1705
1705
|
child_tag: event.event,
|
|
@@ -1710,7 +1710,7 @@ class ProcessorService {
|
|
|
1710
1710
|
return this.runQuota(event as unknown as IQuotaEvent);
|
|
1711
1711
|
}
|
|
1712
1712
|
|
|
1713
|
-
if(event.type ===
|
|
1713
|
+
if(event.type === StepEventTypes.FALLBACK) {
|
|
1714
1714
|
this.logService.add({
|
|
1715
1715
|
...this.baseLogs,
|
|
1716
1716
|
child_tag: event.event,
|
|
@@ -1720,7 +1720,7 @@ class ProcessorService {
|
|
|
1720
1720
|
})
|
|
1721
1721
|
return this.runFallback(event as unknown as IFallbackEvent);
|
|
1722
1722
|
}*/
|
|
1723
|
-
if (event.type === types_1.
|
|
1723
|
+
if (event.type === types_1.StepEventTypes.ACTION) {
|
|
1724
1724
|
const additional_logs = {
|
|
1725
1725
|
parent_tag: event.app,
|
|
1726
1726
|
child_tag: event.event,
|
|
@@ -1729,7 +1729,7 @@ class ProcessorService {
|
|
|
1729
1729
|
};
|
|
1730
1730
|
return this.runAction(event, additional_logs);
|
|
1731
1731
|
}
|
|
1732
|
-
if (event.type === types_1.
|
|
1732
|
+
if (event.type === types_1.StepEventTypes.STORAGE) {
|
|
1733
1733
|
this.clone = (0, processor_utils_1.structuredClone)(event);
|
|
1734
1734
|
(0, processor_utils_1.cleanBlob)(this.clone);
|
|
1735
1735
|
const additional_logs = {
|
|
@@ -1739,7 +1739,7 @@ class ProcessorService {
|
|
|
1739
1739
|
};
|
|
1740
1740
|
return this.runStorage(event, additional_logs);
|
|
1741
1741
|
}
|
|
1742
|
-
if (event.type === types_1.
|
|
1742
|
+
if (event.type === types_1.StepEventTypes.NOTIFICATION) {
|
|
1743
1743
|
const [parent_tag, child_tag] = event.event.split(':');
|
|
1744
1744
|
const additional_logs = {
|
|
1745
1745
|
parent_tag,
|
|
@@ -1749,7 +1749,7 @@ class ProcessorService {
|
|
|
1749
1749
|
};
|
|
1750
1750
|
return this.runNotification(event, additional_logs);
|
|
1751
1751
|
}
|
|
1752
|
-
if (event.type === types_1.
|
|
1752
|
+
if (event.type === types_1.StepEventTypes.PUBLISH) {
|
|
1753
1753
|
const [parent_tag, child_tag] = event.event.split(':');
|
|
1754
1754
|
const additional_logs = {
|
|
1755
1755
|
parent_tag,
|
|
@@ -1762,7 +1762,7 @@ class ProcessorService {
|
|
|
1762
1762
|
}
|
|
1763
1763
|
catch (e) { }
|
|
1764
1764
|
}
|
|
1765
|
-
if (event.type === types_1.
|
|
1765
|
+
if (event.type === types_1.StepEventTypes.JOB) {
|
|
1766
1766
|
const additional_logs = {
|
|
1767
1767
|
type: types_1.LogEventTypes.JOB,
|
|
1768
1768
|
parent_tag: event.event,
|
|
@@ -1853,7 +1853,7 @@ class ProcessorService {
|
|
|
1853
1853
|
}
|
|
1854
1854
|
try {
|
|
1855
1855
|
let result;
|
|
1856
|
-
if (jobType === types_1.JobEventTypes.ACTION || jobType === types_1.
|
|
1856
|
+
if (jobType === types_1.JobEventTypes.ACTION || jobType === types_1.StepEventTypes.ACTION) {
|
|
1857
1857
|
result = await this.processAction(job.data);
|
|
1858
1858
|
}
|
|
1859
1859
|
else if (jobType === types_1.JobEventTypes.NOTIFICATION) {
|
|
@@ -1879,8 +1879,8 @@ class ProcessorService {
|
|
|
1879
1879
|
else if (jobType === types_1.JobEventTypes.GRAPH_OPERATION) {
|
|
1880
1880
|
result = await this.processGraphOperation(job.data);
|
|
1881
1881
|
}
|
|
1882
|
-
else if (jobType === types_1.JobEventTypes.
|
|
1883
|
-
result = await this.
|
|
1882
|
+
else if (jobType === types_1.JobEventTypes.FEATURE) {
|
|
1883
|
+
result = await this.processFeature(job.data);
|
|
1884
1884
|
}
|
|
1885
1885
|
else {
|
|
1886
1886
|
throw new Error(`Unknown job type: ${jobType}`);
|
|
@@ -2523,18 +2523,18 @@ class ProcessorService {
|
|
|
2523
2523
|
return { success: true, data: result };
|
|
2524
2524
|
}
|
|
2525
2525
|
/**
|
|
2526
|
-
* Process
|
|
2527
|
-
* Executes a
|
|
2526
|
+
* Process feature job
|
|
2527
|
+
* Executes a feature using the feature service
|
|
2528
2528
|
*/
|
|
2529
|
-
async
|
|
2530
|
-
const { env, product,
|
|
2529
|
+
async processFeature(data) {
|
|
2530
|
+
const { env, product, feature, input, idempotency_key } = data;
|
|
2531
2531
|
// Initialize product builder if not already done
|
|
2532
2532
|
if (product) {
|
|
2533
2533
|
await this.productBuilderService.initializeProductByTag(product);
|
|
2534
2534
|
}
|
|
2535
|
-
// Execute the
|
|
2536
|
-
const {
|
|
2537
|
-
const
|
|
2535
|
+
// Execute the feature using the feature service
|
|
2536
|
+
const { FeatureService } = await Promise.resolve().then(() => __importStar(require('../../features/features.service')));
|
|
2537
|
+
const featureService = new FeatureService({
|
|
2538
2538
|
workspace_id: this.workspace_id,
|
|
2539
2539
|
public_key: this.public_key,
|
|
2540
2540
|
user_id: this.user_id,
|
|
@@ -2543,18 +2543,18 @@ class ProcessorService {
|
|
|
2543
2543
|
private_key: this._privateKey,
|
|
2544
2544
|
access_key: this.accessKey,
|
|
2545
2545
|
});
|
|
2546
|
-
// Execute the
|
|
2547
|
-
const result = await
|
|
2546
|
+
// Execute the feature
|
|
2547
|
+
const result = await featureService.execute({
|
|
2548
2548
|
product,
|
|
2549
2549
|
env,
|
|
2550
|
-
tag:
|
|
2550
|
+
tag: feature,
|
|
2551
2551
|
input: input || {},
|
|
2552
2552
|
idempotency_key,
|
|
2553
2553
|
});
|
|
2554
2554
|
return {
|
|
2555
2555
|
success: result.status === 'completed',
|
|
2556
2556
|
data: result.output,
|
|
2557
|
-
|
|
2557
|
+
feature_id: result.feature_id,
|
|
2558
2558
|
status: result.status,
|
|
2559
2559
|
error: result.error,
|
|
2560
2560
|
};
|
|
@@ -2965,12 +2965,12 @@ class ProcessorService {
|
|
|
2965
2965
|
this.processingOutput.failure = this.processingOutput.failure.filter((data) => !(data.event.sequence_tag === event.sequence_tag && data.event.event === event.event));
|
|
2966
2966
|
this.processingOutput.skipped = this.processingOutput.skipped.filter((data) => !(data.event.sequence_tag === event.sequence_tag && data.event.event === event.event));
|
|
2967
2967
|
this.processingOutput.waiting = this.processingOutput.waiting.filter((data) => !(data.event.sequence_tag === event.sequence_tag && data.event.event === event.event));
|
|
2968
|
-
if (event.type === types_1.
|
|
2968
|
+
if (event.type === types_1.StepEventTypes.STORAGE) {
|
|
2969
2969
|
event = (0, processor_utils_1.cleanBlob)(event);
|
|
2970
2970
|
}
|
|
2971
2971
|
this.processingOutput.success.push({ event, output });
|
|
2972
2972
|
if (this.checkIsSuccessful() && this.doneWithProcessing) {
|
|
2973
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), {
|
|
2973
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Process event - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2974
2974
|
await this.logService.publish();
|
|
2975
2975
|
this.end = Date.now();
|
|
2976
2976
|
await this.writeResult(types_1.LogEventStatus.SUCCESS);
|
|
@@ -3002,7 +3002,7 @@ class ProcessorService {
|
|
|
3002
3002
|
let error_code = '1000';
|
|
3003
3003
|
let retry_at = 500;
|
|
3004
3004
|
let max = event.retries || 0;
|
|
3005
|
-
if (event.type === types_1.
|
|
3005
|
+
if (event.type === types_1.StepEventTypes.ACTION) {
|
|
3006
3006
|
e.response && e.response.status ? e.response.status : '500';
|
|
3007
3007
|
const metrices = this.generateRetryMetrices(String(error_code), policy);
|
|
3008
3008
|
retry_at = metrices.retry_at;
|
|
@@ -3010,7 +3010,7 @@ class ProcessorService {
|
|
|
3010
3010
|
}
|
|
3011
3011
|
const { allow_fail, retries } = event;
|
|
3012
3012
|
let retryable = true;
|
|
3013
|
-
if (event.type === types_1.
|
|
3013
|
+
if (event.type === types_1.StepEventTypes.STORAGE) {
|
|
3014
3014
|
event = (0, processor_utils_1.cleanBlob)(event);
|
|
3015
3015
|
if (!event.allow_fail)
|
|
3016
3016
|
retryable = false;
|
|
@@ -3021,7 +3021,7 @@ class ProcessorService {
|
|
|
3021
3021
|
this.processingOutput.failure.splice(exists, 1);
|
|
3022
3022
|
}
|
|
3023
3023
|
let reason = JSON.stringify((0, processor_utils_1.extractAxiosErrorDetails)(e));
|
|
3024
|
-
if (event.type === types_1.
|
|
3024
|
+
if (event.type === types_1.StepEventTypes.ACTION) {
|
|
3025
3025
|
reason = JSON.stringify((0, processor_utils_1.extractAxiosErrorDetails)(e));
|
|
3026
3026
|
}
|
|
3027
3027
|
const output = {
|
|
@@ -3042,10 +3042,10 @@ class ProcessorService {
|
|
|
3042
3042
|
if (retries_left > 0) {
|
|
3043
3043
|
setTimeout(() => {
|
|
3044
3044
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Retrying Request', data: Object.assign(Object.assign({}, output), { payload: output.payload }), status: types_1.LogEventStatus.PROCESSING }));
|
|
3045
|
-
if (event.type === types_1.
|
|
3045
|
+
if (event.type === types_1.StepEventTypes.ACTION) {
|
|
3046
3046
|
this.processRequest(payload, event, policy, additional_logs);
|
|
3047
3047
|
}
|
|
3048
|
-
if (event.type === types_1.
|
|
3048
|
+
if (event.type === types_1.StepEventTypes.STORAGE) {
|
|
3049
3049
|
this.processStorageRequest(event, event.input, payload.storageEnv, additional_logs);
|
|
3050
3050
|
}
|
|
3051
3051
|
}, retry_at);
|
|
@@ -3122,7 +3122,7 @@ class ProcessorService {
|
|
|
3122
3122
|
let sessionLogFields = {};
|
|
3123
3123
|
let resolvedInput = input;
|
|
3124
3124
|
try {
|
|
3125
|
-
await this.validateActionDataMappingInput(input, types_1.
|
|
3125
|
+
await this.validateActionDataMappingInput(input, types_1.StepEventTypes.STORAGE);
|
|
3126
3126
|
this.input = input;
|
|
3127
3127
|
this.start = Date.now();
|
|
3128
3128
|
this.component = types_1.LogEventTypes.STORAGE;
|
|
@@ -3133,7 +3133,7 @@ class ProcessorService {
|
|
|
3133
3133
|
const process_id = (0, uuid_1.v4)();
|
|
3134
3134
|
this.baseLogs = Object.assign({ product_tag: this.productTag, product_id: this.productId, workspace_id: this.workspace_id, env,
|
|
3135
3135
|
process_id, data: this.clone }, additional_logs);
|
|
3136
|
-
// Use preloaded bootstrap when provided (e.g.
|
|
3136
|
+
// Use preloaded bootstrap when provided (e.g. feature batch prefetch), otherwise fetch
|
|
3137
3137
|
const bootstrapData = preloadedBootstrap
|
|
3138
3138
|
? preloadedBootstrap
|
|
3139
3139
|
: await this.productBuilderService.bootstrapStorage({
|
|
@@ -3180,7 +3180,7 @@ class ProcessorService {
|
|
|
3180
3180
|
throw new Error(`Environment ${env} is not active`);
|
|
3181
3181
|
}
|
|
3182
3182
|
const payload = {
|
|
3183
|
-
type: types_1.
|
|
3183
|
+
type: types_1.StepEventTypes.STORAGE,
|
|
3184
3184
|
event,
|
|
3185
3185
|
cache: cache,
|
|
3186
3186
|
input: resolvedInput,
|
|
@@ -3213,7 +3213,7 @@ class ProcessorService {
|
|
|
3213
3213
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message, data: { e, reason }, status: types_1.LogEventStatus.FAIL }));
|
|
3214
3214
|
await this.logService.publish();
|
|
3215
3215
|
}
|
|
3216
|
-
// Rethrow so the
|
|
3216
|
+
// Rethrow so the feature step is marked failed and the executor can persist the error reason
|
|
3217
3217
|
throw e;
|
|
3218
3218
|
}
|
|
3219
3219
|
}
|
|
@@ -3229,7 +3229,7 @@ class ProcessorService {
|
|
|
3229
3229
|
name: `Subscribe to broker topic`,
|
|
3230
3230
|
};
|
|
3231
3231
|
try {
|
|
3232
|
-
await this.validateActionDataMappingInput(data.input, types_1.
|
|
3232
|
+
await this.validateActionDataMappingInput(data.input, types_1.StepEventTypes.STORAGE);
|
|
3233
3233
|
this.start = Date.now();
|
|
3234
3234
|
this.productTag = data.product;
|
|
3235
3235
|
const process_id = (0, uuid_1.v4)();
|
|
@@ -3245,7 +3245,7 @@ class ProcessorService {
|
|
|
3245
3245
|
}
|
|
3246
3246
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Subscribe to topic - initiated', status: types_1.LogEventStatus.PROCESSING }));
|
|
3247
3247
|
const payload = {
|
|
3248
|
-
type: types_1.
|
|
3248
|
+
type: types_1.StepEventTypes.SUBSCRIBE,
|
|
3249
3249
|
event: data.event,
|
|
3250
3250
|
input: data.input,
|
|
3251
3251
|
env: productEnv,
|
|
@@ -3282,7 +3282,7 @@ class ProcessorService {
|
|
|
3282
3282
|
let sessionLogFields = {};
|
|
3283
3283
|
let resolvedInput = data.input;
|
|
3284
3284
|
try {
|
|
3285
|
-
await this.validateActionDataMappingInput(data.input, types_1.
|
|
3285
|
+
await this.validateActionDataMappingInput(data.input, types_1.StepEventTypes.PUBLISH);
|
|
3286
3286
|
this.start = Date.now();
|
|
3287
3287
|
// clone
|
|
3288
3288
|
this.clone = (0, processor_utils_1.structuredClone)(data.input);
|
|
@@ -3329,7 +3329,7 @@ class ProcessorService {
|
|
|
3329
3329
|
throw new Error(`Environment ${data.env} is not active`);
|
|
3330
3330
|
}
|
|
3331
3331
|
const payload = {
|
|
3332
|
-
type: types_1.
|
|
3332
|
+
type: types_1.StepEventTypes.PUBLISH,
|
|
3333
3333
|
event: data.event,
|
|
3334
3334
|
cache: data.cache,
|
|
3335
3335
|
input: resolvedInput,
|
|
@@ -3353,7 +3353,7 @@ class ProcessorService {
|
|
|
3353
3353
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message, data: { e, reason }, status: types_1.LogEventStatus.FAIL }));
|
|
3354
3354
|
this.end = Date.now();
|
|
3355
3355
|
await this.logService.publish();
|
|
3356
|
-
// Rethrow so the
|
|
3356
|
+
// Rethrow so the feature step is marked failed and the executor can persist the error reason
|
|
3357
3357
|
throw e;
|
|
3358
3358
|
}
|
|
3359
3359
|
}
|
|
@@ -3495,18 +3495,18 @@ class ProcessorService {
|
|
|
3495
3495
|
jobInput = input;
|
|
3496
3496
|
namespace = 'graphs';
|
|
3497
3497
|
}
|
|
3498
|
-
else if (productJob.type === types_1.JobEventTypes.
|
|
3499
|
-
//
|
|
3498
|
+
else if (productJob.type === types_1.JobEventTypes.FEATURE) {
|
|
3499
|
+
// Feature job - execute a feature
|
|
3500
3500
|
const input = {
|
|
3501
3501
|
env: job.env,
|
|
3502
3502
|
product: job.product,
|
|
3503
|
-
|
|
3503
|
+
feature: productJob.app,
|
|
3504
3504
|
cache: job.cache,
|
|
3505
3505
|
session: job.session,
|
|
3506
3506
|
input: job.input,
|
|
3507
3507
|
};
|
|
3508
3508
|
jobInput = input;
|
|
3509
|
-
namespace = '
|
|
3509
|
+
namespace = 'features';
|
|
3510
3510
|
}
|
|
3511
3511
|
else {
|
|
3512
3512
|
throw new Error(`Job type ${productJob.type} not supported`);
|
|
@@ -4152,7 +4152,7 @@ class ProcessorService {
|
|
|
4152
4152
|
throw e;
|
|
4153
4153
|
}
|
|
4154
4154
|
}
|
|
4155
|
-
/*async runFunction(data:
|
|
4155
|
+
/*async runFunction(data: IStepEvent, additional_logs: Partial<ILogData>): Promise<any> {
|
|
4156
4156
|
const { product_id, env } = data;
|
|
4157
4157
|
const input = data.input as IFunctionRequest;
|
|
4158
4158
|
|
|
@@ -4386,7 +4386,7 @@ class ProcessorService {
|
|
|
4386
4386
|
const { env, event } = data;
|
|
4387
4387
|
const input = data.input;
|
|
4388
4388
|
try {
|
|
4389
|
-
// Skip redundant init when already initialized (e.g. same
|
|
4389
|
+
// Skip redundant init when already initialized (e.g. same feature run / same product)
|
|
4390
4390
|
if (!this.productId) {
|
|
4391
4391
|
await this.intializeProduct(additional_logs);
|
|
4392
4392
|
}
|
|
@@ -4467,7 +4467,7 @@ class ProcessorService {
|
|
|
4467
4467
|
this.getUserAccess(),
|
|
4468
4468
|
);*/
|
|
4469
4469
|
// Bootstrap returns raw storage_env; config may be encrypted - decrypt before use
|
|
4470
|
-
// Prefer decryptionKey from bootstrap (
|
|
4470
|
+
// Prefer decryptionKey from bootstrap (feature path) so we use the exact key the backend returned
|
|
4471
4471
|
let cloudConfig = storageEnv.config;
|
|
4472
4472
|
if (typeof cloudConfig === 'string') {
|
|
4473
4473
|
const privateKey = decryptionKey !== null && decryptionKey !== void 0 ? decryptionKey : this.productBuilderService.fetchPrivateKey();
|
|
@@ -4540,7 +4540,6 @@ class ProcessorService {
|
|
|
4540
4540
|
retryable,
|
|
4541
4541
|
result: (0, processor_utils_1.encrypt)(JSON.stringify(this.processingOutput), this.productBuilderService.fetchPrivateKey()),
|
|
4542
4542
|
process_id: this.process_id,
|
|
4543
|
-
feature_id: null,
|
|
4544
4543
|
product_id: this.productId,
|
|
4545
4544
|
env: envSlug,
|
|
4546
4545
|
input: (0, processor_utils_1.encrypt)(JSON.stringify(this.input), this.productBuilderService.fetchPrivateKey()),
|
|
@@ -4644,13 +4643,13 @@ class ProcessorService {
|
|
|
4644
4643
|
}
|
|
4645
4644
|
async validateActionDataMappingInput(input, type) {
|
|
4646
4645
|
try {
|
|
4647
|
-
if (type === types_1.
|
|
4646
|
+
if (type === types_1.StepEventTypes.ACTION || type === types_1.WebhookEventTypes.WEBHOOK_REGISTER) {
|
|
4648
4647
|
//await ActionInputSchema.validateAsync(input);
|
|
4649
4648
|
}
|
|
4650
|
-
if (type === types_1.
|
|
4649
|
+
if (type === types_1.StepEventTypes.DB_ACTION) {
|
|
4651
4650
|
await create_productFeature_validator_1.DBActionInputSchema.validateAsync(input);
|
|
4652
4651
|
}
|
|
4653
|
-
if (type === types_1.
|
|
4652
|
+
if (type === types_1.StepEventTypes.NOTIFICATION) {
|
|
4654
4653
|
await create_productFeature_validator_1.NotificationInputschema.validateAsync(input);
|
|
4655
4654
|
}
|
|
4656
4655
|
(0, processor_utils_1.validateStringsInObject)(input);
|
|
@@ -4709,7 +4708,7 @@ class ProcessorService {
|
|
|
4709
4708
|
workspace_private_key: (_a = this._privateKey) !== null && _a !== void 0 ? _a : undefined,
|
|
4710
4709
|
});
|
|
4711
4710
|
}
|
|
4712
|
-
// Use preloaded bootstrap when provided (e.g.
|
|
4711
|
+
// Use preloaded bootstrap when provided (e.g. feature batch prefetch), otherwise fetch or read from cache
|
|
4713
4712
|
let bootstrapData;
|
|
4714
4713
|
if (preloadedBootstrap) {
|
|
4715
4714
|
bootstrapData = preloadedBootstrap;
|
|
@@ -4826,12 +4825,12 @@ class ProcessorService {
|
|
|
4826
4825
|
}
|
|
4827
4826
|
else {
|
|
4828
4827
|
// Already structured - validate with existing schema
|
|
4829
|
-
await this.validateActionDataMappingInput(input, types_1.
|
|
4828
|
+
await this.validateActionDataMappingInput(input, types_1.StepEventTypes.ACTION);
|
|
4830
4829
|
}
|
|
4831
4830
|
}
|
|
4832
4831
|
else {
|
|
4833
4832
|
// Fallback: validate with existing schema if no action bootstrap data
|
|
4834
|
-
await this.validateActionDataMappingInput(input, types_1.
|
|
4833
|
+
await this.validateActionDataMappingInput(input, types_1.StepEventTypes.ACTION);
|
|
4835
4834
|
}
|
|
4836
4835
|
// Process session if provided - verify and resolve $Session{} references
|
|
4837
4836
|
if (session && bootstrapData.private_key) {
|
|
@@ -4854,7 +4853,7 @@ class ProcessorService {
|
|
|
4854
4853
|
this.baseLogs = Object.assign(Object.assign({}, this.baseLogs), sessionLogFields);
|
|
4855
4854
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Bootstrap action - success', data: { product_id: this.productId, env: env }, status: types_1.LogEventStatus.SUCCESS }));
|
|
4856
4855
|
const result = await this.runAction({
|
|
4857
|
-
type: types_1.
|
|
4856
|
+
type: types_1.StepEventTypes.ACTION,
|
|
4858
4857
|
event,
|
|
4859
4858
|
cache: cache,
|
|
4860
4859
|
skipCacheFetch: true, // Early cache check already done above, skip duplicate fetch
|
|
@@ -4922,7 +4921,7 @@ class ProcessorService {
|
|
|
4922
4921
|
await this.productBuilderService.initializeProductByTag(product_tag);
|
|
4923
4922
|
}
|
|
4924
4923
|
debugLog('[processNotification] Validating input');
|
|
4925
|
-
await this.validateActionDataMappingInput(input, types_1.
|
|
4924
|
+
await this.validateActionDataMappingInput(input, types_1.StepEventTypes.NOTIFICATION);
|
|
4926
4925
|
this.input = action;
|
|
4927
4926
|
this.start = Date.now();
|
|
4928
4927
|
const process_id = (0, uuid_1.v4)();
|
|
@@ -4930,7 +4929,7 @@ class ProcessorService {
|
|
|
4930
4929
|
this.baseLogs = Object.assign({ product_tag: this.productTag, workspace_id: this.workspace_id, env,
|
|
4931
4930
|
process_id, data: input }, additional_logs);
|
|
4932
4931
|
this.lastNotificationFailureType = undefined;
|
|
4933
|
-
// Use preloaded bootstrap when provided (e.g.
|
|
4932
|
+
// Use preloaded bootstrap when provided (e.g. feature batch prefetch), otherwise fetch
|
|
4934
4933
|
const bootstrapData = preloadedBootstrap
|
|
4935
4934
|
? preloadedBootstrap
|
|
4936
4935
|
: await this.productBuilderService.bootstrapNotification({
|
|
@@ -4984,7 +4983,7 @@ class ProcessorService {
|
|
|
4984
4983
|
throw new Error(`Environment ${env} is not active`);
|
|
4985
4984
|
}
|
|
4986
4985
|
const payload = {
|
|
4987
|
-
type: types_1.
|
|
4986
|
+
type: types_1.StepEventTypes.NOTIFICATION,
|
|
4988
4987
|
event,
|
|
4989
4988
|
input: resolvedInput,
|
|
4990
4989
|
cache: cache,
|
|
@@ -5076,7 +5075,7 @@ class ProcessorService {
|
|
|
5076
5075
|
error: e instanceof Error ? e.message : String(e),
|
|
5077
5076
|
});
|
|
5078
5077
|
}
|
|
5079
|
-
// Rethrow so
|
|
5078
|
+
// Rethrow so feature/callers see the step as failed (e.g. bootstrap "Notification not found" or runNotification failure)
|
|
5080
5079
|
throw e;
|
|
5081
5080
|
}
|
|
5082
5081
|
}
|