@objectstack/runtime 1.0.7 → 1.0.9

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.js CHANGED
@@ -765,6 +765,25 @@ var DriverPlugin = class {
765
765
  });
766
766
  };
767
767
  this.start = async (ctx) => {
768
+ if (this.name.startsWith("com.objectstack.driver.")) {
769
+ }
770
+ try {
771
+ const metadata = ctx.getService("metadata");
772
+ if (metadata && metadata.addDatasource) {
773
+ const datasources = metadata.getDatasources ? metadata.getDatasources() : [];
774
+ const hasDefault = datasources.some((ds) => ds.name === "default");
775
+ if (!hasDefault) {
776
+ ctx.logger.info(`[DriverPlugin] No 'default' datasource found. Auto-configuring '${this.driver.name}' as default.`);
777
+ await metadata.addDatasource({
778
+ name: "default",
779
+ driver: this.driver.name
780
+ // The driver's internal name (e.g. com.objectstack.driver.memory)
781
+ });
782
+ }
783
+ }
784
+ } catch (e) {
785
+ ctx.logger.debug("[DriverPlugin] Failed to auto-configure default datasource (Metadata service missing?)", { error: e });
786
+ }
768
787
  ctx.logger.debug("Driver plugin started", { driverName: this.driver.name || "unknown" });
769
788
  };
770
789
  this.driver = driver;
@@ -825,6 +844,23 @@ var AppPlugin = class {
825
844
  } else {
826
845
  ctx.logger.debug("No runtime.onEnable function found", { appId });
827
846
  }
847
+ const manifest = this.bundle.manifest || this.bundle;
848
+ if (manifest && Array.isArray(manifest.data)) {
849
+ ctx.logger.info(`[AppPlugin] Found initial data for ${appId}`, { count: manifest.data.length });
850
+ for (const dataset of manifest.data) {
851
+ if (dataset.object && Array.isArray(dataset.records)) {
852
+ ctx.logger.info(`[Seeder] Seeding ${dataset.records.length} records for ${dataset.object}`);
853
+ for (const record of dataset.records) {
854
+ try {
855
+ await ql.insert(dataset.object, record);
856
+ } catch (err) {
857
+ ctx.logger.warn(`[Seeder] Failed to insert ${dataset.object} record:`, { error: err.message });
858
+ }
859
+ }
860
+ }
861
+ }
862
+ ctx.logger.info("[Seeder] Data seeding complete.");
863
+ }
828
864
  };
829
865
  this.bundle = bundle;
830
866
  const sys = bundle.manifest || bundle;