@granular-software/sdk 0.4.35 → 0.4.36

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/dist/index.mjs CHANGED
@@ -13864,13 +13864,27 @@ var Granular = class _Granular {
13864
13864
  registerEnvironmentImporter(ontologyNameOrId, handler) {
13865
13865
  this.ontologyImporters.set(ontologyNameOrId, handler);
13866
13866
  if (ontologyNameOrId.startsWith("sbx_")) {
13867
- this.sandboxImporters.set(ontologyNameOrId, handler);
13867
+ this.sandboxImporters.set(ontologyNameOrId, {
13868
+ handler,
13869
+ sourceOntology: ontologyNameOrId
13870
+ });
13871
+ return;
13872
+ }
13873
+ for (const [sandboxId, importer] of this.sandboxImporters.entries()) {
13874
+ if (importer.sourceOntology === ontologyNameOrId) {
13875
+ this.sandboxImporters.set(sandboxId, {
13876
+ handler,
13877
+ sourceOntology: ontologyNameOrId
13878
+ });
13879
+ }
13868
13880
  }
13869
13881
  }
13870
13882
  clearEnvironmentImporter(ontologyNameOrId) {
13871
13883
  this.ontologyImporters.delete(ontologyNameOrId);
13872
- if (ontologyNameOrId.startsWith("sbx_")) {
13873
- this.sandboxImporters.delete(ontologyNameOrId);
13884
+ for (const [sandboxId, importer] of this.sandboxImporters.entries()) {
13885
+ if (importer.sourceOntology === ontologyNameOrId) {
13886
+ this.sandboxImporters.delete(sandboxId);
13887
+ }
13874
13888
  }
13875
13889
  }
13876
13890
  /**
@@ -14231,11 +14245,25 @@ var Granular = class _Granular {
14231
14245
  return this.connectSession({ sessionId, clientId: options?.clientId });
14232
14246
  }
14233
14247
  resolveEnvironmentImporter(requestedOntology, sandboxId) {
14234
- const resolved = this.sandboxImporters.get(sandboxId) || this.ontologyImporters.get(requestedOntology);
14235
- if (resolved && !this.sandboxImporters.has(sandboxId) && this.ontologyImporters.get(requestedOntology) === resolved) {
14236
- this.sandboxImporters.set(sandboxId, resolved);
14248
+ const sandboxImporter = this.sandboxImporters.get(sandboxId);
14249
+ if (sandboxImporter) {
14250
+ const sourceImporter = this.ontologyImporters.get(
14251
+ sandboxImporter.sourceOntology
14252
+ );
14253
+ if (sourceImporter === sandboxImporter.handler) {
14254
+ return sandboxImporter.handler;
14255
+ }
14256
+ this.sandboxImporters.delete(sandboxId);
14237
14257
  }
14238
- return resolved;
14258
+ const ontologyImporter = this.ontologyImporters.get(requestedOntology);
14259
+ if (!ontologyImporter) {
14260
+ return void 0;
14261
+ }
14262
+ this.sandboxImporters.set(sandboxId, {
14263
+ handler: ontologyImporter,
14264
+ sourceOntology: requestedOntology
14265
+ });
14266
+ return ontologyImporter;
14239
14267
  }
14240
14268
  async maybeRunEnvironmentImporter(resolved, environment) {
14241
14269
  if (!resolved.setupTriggerReason) {