@ductape/sdk 0.0.6 → 0.0.8

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 (39) hide show
  1. package/dist/apps/services/app.service.js +14 -5
  2. package/dist/apps/services/app.service.js.map +1 -1
  3. package/dist/apps/utils/string.utils.d.ts +7 -0
  4. package/dist/apps/utils/string.utils.js +33 -1
  5. package/dist/apps/utils/string.utils.js.map +1 -1
  6. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.js +2 -0
  7. package/dist/apps/validators/joi-validators/create.appActionResponse.validator.js.map +1 -1
  8. package/dist/apps/validators/joi-validators/create.appEnv.validator.js +1 -0
  9. package/dist/apps/validators/joi-validators/create.appEnv.validator.js.map +1 -1
  10. package/dist/apps/validators/joi-validators/update.appEnv.validator.js +1 -0
  11. package/dist/apps/validators/joi-validators/update.appEnv.validator.js.map +1 -1
  12. package/dist/brokers/brokers.service.d.ts +4 -1
  13. package/dist/brokers/brokers.service.js +104 -20
  14. package/dist/brokers/brokers.service.js.map +1 -1
  15. package/dist/database/databases.service.d.ts +15 -0
  16. package/dist/database/databases.service.js +183 -14
  17. package/dist/database/databases.service.js.map +1 -1
  18. package/dist/graph/graphs.service.d.ts +6 -0
  19. package/dist/graph/graphs.service.js +155 -35
  20. package/dist/graph/graphs.service.js.map +1 -1
  21. package/dist/index.d.ts +28 -10
  22. package/dist/index.js +88 -10
  23. package/dist/index.js.map +1 -1
  24. package/dist/inputs/validators/inputs.validator.parse.js +2 -2
  25. package/dist/inputs/validators/inputs.validator.parse.js.map +1 -1
  26. package/dist/processor/services/processor.service.d.ts +15 -2
  27. package/dist/processor/services/processor.service.js +260 -42
  28. package/dist/processor/services/processor.service.js.map +1 -1
  29. package/dist/products/services/products.service.js +36 -25
  30. package/dist/products/services/products.service.js.map +1 -1
  31. package/dist/types/appBuilder.types.d.ts +6 -0
  32. package/dist/vector/vector-database.service.d.ts +6 -0
  33. package/dist/vector/vector-database.service.js +138 -31
  34. package/dist/vector/vector-database.service.js.map +1 -1
  35. package/dist/workflows/workflow-executor.js +99 -44
  36. package/dist/workflows/workflow-executor.js.map +1 -1
  37. package/dist/workflows/workflows.service.js +63 -20
  38. package/dist/workflows/workflows.service.js.map +1 -1
  39. package/package.json +1 -1
@@ -76,6 +76,10 @@ class ProductsBuilderService {
76
76
  }
77
77
  }
78
78
  fetchPrivateKey() {
79
+ var _a;
80
+ if (!((_a = this.product) === null || _a === void 0 ? void 0 : _a.private_key)) {
81
+ throw new Error('Product not initialized or missing private_key (ensure bootstrap/init ran successfully)');
82
+ }
79
83
  return this.product.private_key;
80
84
  }
81
85
  fetchWorkspaceId() {
@@ -354,10 +358,18 @@ class ProductsBuilderService {
354
358
  async bootstrapAction(params) {
355
359
  try {
356
360
  const result = await this.productApi.bootstrapAction(params, this.getUserAccess());
357
- // Initialize minimal product data
361
+ // Initialize minimal product data so fetchPrivateKey/fetchProductId/fetchWorkspaceId work
358
362
  if (result.product_id) {
359
363
  this.product_id = result.product_id;
360
364
  }
365
+ if (result.private_key != null) {
366
+ this.product = {
367
+ _id: result.product_id,
368
+ workspace_id: result.workspace_id,
369
+ private_key: result.private_key,
370
+ tag: params.product_tag,
371
+ };
372
+ }
361
373
  return result;
362
374
  }
363
375
  catch (e) {
@@ -2287,32 +2299,31 @@ class ProductsBuilderService {
2287
2299
  // await this.validateAppAuth(auth, appData);
2288
2300
  return app;
2289
2301
  }
2290
- validateVariablesSchema(variables, appVariables) {
2291
- if (variables && variables.length) {
2292
- variables.map((data) => {
2293
- const appVar = appVariables.find((value) => value.key === data.key);
2294
- if (!appVar) {
2295
- throw new Error(`variable key: ${data.key} not found`);
2296
- }
2297
- // if()
2298
- });
2299
- }
2302
+ validateVariablesSchema(variables, appVariables, baseUrlVariableKeys) {
2303
+ if (!(variables === null || variables === void 0 ? void 0 : variables.length))
2304
+ return;
2305
+ const baseKeys = new Set((baseUrlVariableKeys !== null && baseUrlVariableKeys !== void 0 ? baseUrlVariableKeys : []).map((v) => v.key));
2306
+ variables.forEach((data) => {
2307
+ const appVar = appVariables === null || appVariables === void 0 ? void 0 : appVariables.find((value) => value.key === data.key);
2308
+ if (appVar)
2309
+ return;
2310
+ if (baseKeys.has(data.key))
2311
+ return; // base_url variable (e.g. {{prefix}})
2312
+ throw new Error(`variable key: ${data.key} not found`);
2313
+ });
2300
2314
  }
2301
2315
  validateVariablesValues(variables, appVariables) {
2302
- if (!variables) {
2303
- variables = [];
2304
- }
2305
- if (appVariables && appVariables.length) {
2306
- appVariables.map((data) => {
2307
- const find = variables.find((value) => value.key === data.key);
2308
- if (data.required) {
2309
- if (!find) {
2310
- throw new Error(`variable key: ${data.key} is required`);
2311
- }
2312
- }
2316
+ const vars = variables !== null && variables !== void 0 ? variables : [];
2317
+ if (!(appVariables === null || appVariables === void 0 ? void 0 : appVariables.length))
2318
+ return;
2319
+ appVariables.forEach((data) => {
2320
+ const find = vars.find((value) => value.key === data.key);
2321
+ if (data.required && !find) {
2322
+ throw new Error(`variable key: ${data.key} is required`);
2323
+ }
2324
+ if (find)
2313
2325
  this.inputsService.validateFeatureInputData(find, data);
2314
- });
2315
- }
2326
+ });
2316
2327
  }
2317
2328
  validateAppEnvs(envs, version) {
2318
2329
  const { envs: appEnvs } = version;
@@ -2324,7 +2335,7 @@ class ProductsBuilderService {
2324
2335
  throw new Error(`app_slug ${env.app_env_slug} not found`);
2325
2336
  }
2326
2337
  // const updates = this.validateAppAuth(auth, version);
2327
- this.validateVariablesSchema(env.variables, version.variables);
2338
+ this.validateVariablesSchema(env.variables, version.variables, appEnv.base_url_variables);
2328
2339
  this.validateVariablesValues(env.variables, version.variables);
2329
2340
  /*if (updates && updates.data) {
2330
2341
  env.auth.data = updates.data;