@ductape/sdk 0.1.152 → 0.1.154

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.
@@ -562,6 +562,7 @@ export default class ProductsBuilderService implements IProductsBuilderService {
562
562
  fetchDatabaseAction(tag: string, throwErrorIfExists?: boolean): Promise<IProductDatabaseAction | null>;
563
563
  updateDatabaseAction(data: Partial<IProductDatabaseAction>): Promise<void>;
564
564
  fetchDatabaseActions(databaseTag: string): Promise<Array<IProductDatabaseAction>>;
565
+ private withDatabaseActionContracts;
565
566
  deleteDatabaseAction(tag: string): Promise<void>;
566
567
  createDatabaseMigration(data: Partial<IProductDatabaseMigration>, throwErrorIfExists?: boolean): Promise<void>;
567
568
  /**
@@ -28,6 +28,7 @@ const cloud_database_link_util_1 = require("../../cloud/cloud-database-link.util
28
28
  const cloud_graph_link_util_1 = require("../../cloud/cloud-graph-link.util");
29
29
  const cloud_vector_link_util_1 = require("../../cloud/cloud-vector-link.util");
30
30
  const cloud_materialize_util_1 = require("../../cloud/cloud-materialize.util");
31
+ const output_contract_1 = require("../../database/actions/output-contract");
31
32
  const productsBuilder_types_1 = require("../../types/productsBuilder.types");
32
33
  const validators_1 = require("../validators");
33
34
  const objects_utils_1 = require("../utils/objects.utils");
@@ -4766,7 +4767,7 @@ class ProductsBuilderService {
4766
4767
  //console.log(action.template)
4767
4768
  // action.template = JSON.parse(action.template);
4768
4769
  }
4769
- return action;
4770
+ return action ? this.withDatabaseActionContracts(database, action) : null;
4770
4771
  }
4771
4772
  async updateDatabaseAction(data) {
4772
4773
  try {
@@ -4822,7 +4823,25 @@ class ProductsBuilderService {
4822
4823
  return{ ...data,template: JSON.parse(String(data.template))}
4823
4824
  })*/
4824
4825
  }
4825
- return actions;
4826
+ return actions.map((action) => this.withDatabaseActionContracts(database, action));
4827
+ }
4828
+ withDatabaseActionContracts(database, action) {
4829
+ var _a, _b;
4830
+ const environments = (_a = database.envs) !== null && _a !== void 0 ? _a : [];
4831
+ const outputContractsByEnvironment = Object.fromEntries(environments.map((env) => {
4832
+ var _a, _b, _c;
4833
+ const tableSchema = (_a = env.table_schemas) === null || _a === void 0 ? void 0 : _a.find((schema) => schema.table === action.tableName);
4834
+ return [
4835
+ env.slug,
4836
+ (0, output_contract_1.deriveDatabaseActionOutputContract)(action, {
4837
+ adapter: database.type,
4838
+ adapterVersion: (_b = env.adapterVersion) !== null && _b !== void 0 ? _b : env.adapter_version,
4839
+ columns: (_c = tableSchema === null || tableSchema === void 0 ? void 0 : tableSchema.columns) !== null && _c !== void 0 ? _c : [],
4840
+ }),
4841
+ ];
4842
+ }));
4843
+ const firstContract = (_b = Object.values(outputContractsByEnvironment)[0]) !== null && _b !== void 0 ? _b : (0, output_contract_1.deriveDatabaseActionOutputContract)(action, { adapter: database.type, columns: [] });
4844
+ return Object.assign(Object.assign({}, action), { outputContract: firstContract, outputContractsByEnvironment });
4826
4845
  }
4827
4846
  async deleteDatabaseAction(tag) {
4828
4847
  try {