@ductape/sdk 0.1.95 → 0.1.98

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.
@@ -824,7 +824,7 @@ export interface IAgentStorageContext {
824
824
  }
825
825
  /**
826
826
  * Messaging context for agent tools (Ductape primitive).
827
- * Use ctx.messaging.produce() to publish to a message broker.
827
+ * Use ctx.events.produce() to publish to a message broker.
828
828
  */
829
829
  export interface IAgentMessagingContext {
830
830
  produce(options: {
@@ -834,7 +834,7 @@ export interface IAgentMessagingContext {
834
834
  }
835
835
  /**
836
836
  * Publish context for agent tools
837
- * @deprecated Prefer ctx.messaging.produce()
837
+ * @deprecated Prefer ctx.events.produce()
838
838
  */
839
839
  export interface IAgentPublishContext {
840
840
  send(options: {
@@ -248,7 +248,7 @@ export interface IFeatureStorageContext {
248
248
  }
249
249
  /**
250
250
  * Messaging context for feature steps (Ductape primitive).
251
- * Use ctx.messaging.produce() to publish to a message broker.
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.messaging.produce() (Ductape primitive).
266
+ * @deprecated Prefer ctx.events.produce() (Ductape primitive).
267
267
  */
268
268
  export interface IFeaturePublishContext {
269
269
  send(options: {
@@ -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<IProcessingFailure | {
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`);