@ductape/sdk 0.1.17 → 0.1.20

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.
Files changed (52) hide show
  1. package/dist/api/services/appApi.service.d.ts +6 -0
  2. package/dist/api/services/appApi.service.js +25 -0
  3. package/dist/api/services/appApi.service.js.map +1 -1
  4. package/dist/api/services/cloudApi.service.js +8 -4
  5. package/dist/api/services/cloudApi.service.js.map +1 -1
  6. package/dist/api/services/productsApi.service.d.ts +2 -0
  7. package/dist/api/services/productsApi.service.js +14 -0
  8. package/dist/api/services/productsApi.service.js.map +1 -1
  9. package/dist/api/utils/cache.utils.d.ts +1 -0
  10. package/dist/api/utils/cache.utils.js +5 -1
  11. package/dist/api/utils/cache.utils.js.map +1 -1
  12. package/dist/apps/services/app.service.js +20 -6
  13. package/dist/apps/services/app.service.js.map +1 -1
  14. package/dist/cloud/cloud-broker-link.util.d.ts +2 -6
  15. package/dist/cloud/cloud-broker-link.util.js +21 -35
  16. package/dist/cloud/cloud-broker-link.util.js.map +1 -1
  17. package/dist/cloud/cloud-database-link.util.d.ts +2 -6
  18. package/dist/cloud/cloud-database-link.util.js +17 -12
  19. package/dist/cloud/cloud-database-link.util.js.map +1 -1
  20. package/dist/cloud/cloud-graph-link.util.d.ts +2 -6
  21. package/dist/cloud/cloud-graph-link.util.js +18 -21
  22. package/dist/cloud/cloud-graph-link.util.js.map +1 -1
  23. package/dist/cloud/cloud-materialize.util.d.ts +22 -0
  24. package/dist/cloud/cloud-materialize.util.js +82 -0
  25. package/dist/cloud/cloud-materialize.util.js.map +1 -0
  26. package/dist/cloud/cloud-resource-body.util.d.ts +6 -0
  27. package/dist/cloud/cloud-resource-body.util.js +58 -0
  28. package/dist/cloud/cloud-resource-body.util.js.map +1 -0
  29. package/dist/cloud/cloud-runtime.util.js +1 -1
  30. package/dist/cloud/cloud-runtime.util.js.map +1 -1
  31. package/dist/cloud/cloud-service-map.util.js +17 -1
  32. package/dist/cloud/cloud-service-map.util.js.map +1 -1
  33. package/dist/cloud/cloud-vector-link.util.d.ts +2 -6
  34. package/dist/cloud/cloud-vector-link.util.js +22 -20
  35. package/dist/cloud/cloud-vector-link.util.js.map +1 -1
  36. package/dist/cloud/cloud.service.js +4 -4
  37. package/dist/cloud/cloud.service.js.map +1 -1
  38. package/dist/cloud/types/cloud.types.d.ts +24 -17
  39. package/dist/cloud/types/cloud.types.js +1 -1
  40. package/dist/index.d.ts +18 -4
  41. package/dist/index.js +62 -9
  42. package/dist/index.js.map +1 -1
  43. package/dist/products/services/products.service.d.ts +2 -2
  44. package/dist/products/services/products.service.js +10 -46
  45. package/dist/products/services/products.service.js.map +1 -1
  46. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +1 -1
  47. package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
  48. package/dist/storage/storage-cloud-link.util.d.ts +2 -6
  49. package/dist/storage/storage-cloud-link.util.js +23 -21
  50. package/dist/storage/storage-cloud-link.util.js.map +1 -1
  51. package/dist/types/appBuilder.types.d.ts +2 -0
  52. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -491,7 +491,7 @@ class Ductape {
491
491
  /**
492
492
  * Creates a new product.
493
493
  * @param {IProduct} data - The product data.
494
- * @returns {Promise<void>} Resolves when the product is created. Throws on error.
494
+ * @returns {Promise<IProduct>} The created (or existing) product document.
495
495
  */
496
496
  create: async (data) => {
497
497
  const builder = await this.initProductBuilder();
@@ -531,6 +531,22 @@ class Ductape {
531
531
  throw e;
532
532
  }
533
533
  },
534
+ /**
535
+ * Deletes a product by tag.
536
+ * @param {string} tag - The product tag.
537
+ * @returns {Promise<void>} Resolves when the product is deleted. Throws on error.
538
+ */
539
+ delete: async (tag) => {
540
+ const builder = await this.getProductBuilder(tag);
541
+ await this.productsApi.deleteProduct(builder.fetchProductId(), {
542
+ token: this.token,
543
+ public_key: this.public_key,
544
+ user_id: this.user_id,
545
+ workspace_id: this.workspace_id,
546
+ access_key: this.accessKey,
547
+ });
548
+ this.productBuilders.delete(tag);
549
+ },
534
550
  /**
535
551
  * Updates data validation for a product.
536
552
  * @param {string} product - The product tag.
@@ -4546,6 +4562,40 @@ class Ductape {
4546
4562
  console.log(`App initialized with tag: ${appTag}`);
4547
4563
  await this.getAppBuilder(appTag);
4548
4564
  },
4565
+ /**
4566
+ * Deletes an app by tag.
4567
+ * @param {string} tag - The app tag.
4568
+ * @returns {Promise<void>} Resolves when the app is deleted. Throws on error.
4569
+ */
4570
+ delete: async (tag) => {
4571
+ var _a, _b, _c;
4572
+ if (!this.token)
4573
+ await this.initUserAuth();
4574
+ const app = await this.appApi.fetchAppByTag(tag, {
4575
+ token: this.token,
4576
+ workspace_id: this.workspace_id,
4577
+ user_id: this.user_id,
4578
+ public_key: this.public_key,
4579
+ access_key: this.accessKey,
4580
+ });
4581
+ const appId = String((_b = (_a = app._id) !== null && _a !== void 0 ? _a : app.id) !== null && _b !== void 0 ? _b : '');
4582
+ if (!appId) {
4583
+ throw new Error(`App id missing for tag ${tag}`);
4584
+ }
4585
+ await this.appApi.deleteApp(appId, {
4586
+ token: this.token,
4587
+ workspace_id: this.workspace_id,
4588
+ user_id: this.user_id,
4589
+ public_key: this.public_key,
4590
+ access_key: this.accessKey,
4591
+ });
4592
+ const appName = String((_c = app.app_name) !== null && _c !== void 0 ? _c : '').trim();
4593
+ if (appName) {
4594
+ await this.appApi.invalidateAppNameLookupCache(appName, this.workspace_id);
4595
+ }
4596
+ await this.appApi.invalidateAppTagLookupCache(tag, this.workspace_id);
4597
+ this.appBuilders.delete(tag);
4598
+ },
4549
4599
  /**
4550
4600
  * Updates data validation for an app.
4551
4601
  * @param {string} appTag - The app tag.
@@ -4704,27 +4754,30 @@ class Ductape {
4704
4754
  * @param {boolean} [params.updateIfExists] - Whether to update if actions exist (optional).
4705
4755
  * @returns {Promise<void>} Resolves when the import is complete. Throws on error.
4706
4756
  */
4707
- import: async ({ file, type, version, appTag, updateIfExists, isAdminImport, }) => {
4708
- var _a;
4757
+ import: async ({ file, type, version, appTag, appId, updateIfExists, isAdminImport, }) => {
4758
+ var _a, _b;
4709
4759
  if (!this.token)
4710
4760
  await this.initUserAuth();
4711
4761
  this.importService = await this.createNewImporter();
4712
- let app_id = null;
4713
- if (appTag) {
4762
+ let resolvedAppId = appId !== null && appId !== void 0 ? appId : null;
4763
+ if (!resolvedAppId && appTag) {
4714
4764
  const builder = await this.getAppBuilder(appTag);
4715
4765
  const app = builder.fetchApp();
4716
- const latest = app.versions.find((v) => v.latest === true);
4717
4766
  if (!app) {
4718
4767
  throw new Error(`App ${appTag} not found`);
4719
4768
  }
4720
- if (latest && ((_a = latest === null || latest === void 0 ? void 0 : latest.actions) === null || _a === void 0 ? void 0 : _a.length) && !updateIfExists) {
4769
+ const latest = (_a = app.versions) === null || _a === void 0 ? void 0 : _a.find((v) => v.latest === true);
4770
+ if (((_b = latest === null || latest === void 0 ? void 0 : latest.actions) === null || _b === void 0 ? void 0 : _b.length) && !updateIfExists) {
4721
4771
  console.log(`App ${appTag} version ${version} already has actions, please set updateIfExists to true to overwrite existing action`);
4722
4772
  return;
4723
4773
  }
4724
- app_id = app._id;
4774
+ resolvedAppId = app._id;
4775
+ }
4776
+ if (!resolvedAppId) {
4777
+ throw new Error('appId or appTag is required for import');
4725
4778
  }
4726
4779
  console.log(`Importing actions from file, type: ${type}, version: ${version}`);
4727
- return this.importService.importApp(file, type, version, updateIfExists, app_id, isAdminImport);
4780
+ return this.importService.importApp(file, type, version, updateIfExists, resolvedAppId, isAdminImport);
4728
4781
  },
4729
4782
  /**
4730
4783
  * Updates an action by tag.