@objectstack/runtime 1.0.6 → 1.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/runtime@1.0.6 build /home/runner/work/spec/spec/packages/runtime
2
+ > @objectstack/runtime@1.0.8 build /home/runner/work/spec/spec/packages/runtime
3
3
  > tsup --config ../../tsup.config.ts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- ESM dist/index.js 47.33 KB
14
- ESM dist/index.js.map 111.49 KB
15
- ESM ⚡️ Build success in 83ms
16
- CJS dist/index.cjs 49.07 KB
17
- CJS dist/index.cjs.map 111.59 KB
18
- CJS ⚡️ Build success in 84ms
13
+ ESM dist/index.js 49.57 KB
14
+ ESM dist/index.js.map 116.74 KB
15
+ ESM ⚡️ Build success in 147ms
16
+ CJS dist/index.cjs 51.31 KB
17
+ CJS dist/index.cjs.map 116.84 KB
18
+ CJS ⚡️ Build success in 150ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 10440ms
21
- DTS dist/index.d.ts 17.79 KB
22
- DTS dist/index.d.cts 17.79 KB
20
+ DTS ⚡️ Build success in 8394ms
21
+ DTS dist/index.d.ts 17.82 KB
22
+ DTS dist/index.d.cts 17.82 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @objectstack/runtime
2
2
 
3
+ ## 1.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - @objectstack/spec@1.0.8
8
+ - @objectstack/core@1.0.8
9
+ - @objectstack/types@1.0.8
10
+
11
+ ## 1.0.7
12
+
13
+ ### Patch Changes
14
+
15
+ - ebdf787: feat: implement standard service discovery via `/.well-known/objectstack`
16
+ - @objectstack/spec@1.0.7
17
+ - @objectstack/core@1.0.7
18
+ - @objectstack/types@1.0.7
19
+
3
20
  ## 1.0.6
4
21
 
5
22
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -354,6 +354,18 @@ var RestServer = class {
354
354
  handler: async (_req, res) => {
355
355
  try {
356
356
  const discovery = await this.protocol.getDiscovery({});
357
+ discovery.version = this.config.api.version;
358
+ if (discovery.endpoints) {
359
+ if (this.config.api.enableCrud) {
360
+ discovery.endpoints.data = `${basePath}${this.config.crud.dataPrefix}`;
361
+ }
362
+ if (this.config.api.enableMetadata) {
363
+ discovery.endpoints.metadata = `${basePath}${this.config.metadata.prefix}`;
364
+ }
365
+ if (discovery.endpoints.auth) {
366
+ discovery.endpoints.auth = `${basePath}/auth`;
367
+ }
368
+ }
357
369
  res.json(discovery);
358
370
  } catch (error) {
359
371
  res.status(500).json({ error: error.message });
@@ -776,6 +788,7 @@ var Runtime = class {
776
788
  // src/driver-plugin.ts
777
789
  var DriverPlugin = class {
778
790
  constructor(driver, driverName) {
791
+ this.type = "driver";
779
792
  this.version = "1.0.0";
780
793
  this.init = async (ctx) => {
781
794
  const serviceName = `driver.${this.driver.name || "unknown"}`;
@@ -787,6 +800,25 @@ var DriverPlugin = class {
787
800
  });
788
801
  };
789
802
  this.start = async (ctx) => {
803
+ if (this.name.startsWith("com.objectstack.driver.")) {
804
+ }
805
+ try {
806
+ const metadata = ctx.getService("metadata");
807
+ if (metadata && metadata.addDatasource) {
808
+ const datasources = metadata.getDatasources ? metadata.getDatasources() : [];
809
+ const hasDefault = datasources.some((ds) => ds.name === "default");
810
+ if (!hasDefault) {
811
+ ctx.logger.info(`[DriverPlugin] No 'default' datasource found. Auto-configuring '${this.driver.name}' as default.`);
812
+ await metadata.addDatasource({
813
+ name: "default",
814
+ driver: this.driver.name
815
+ // The driver's internal name (e.g. com.objectstack.driver.memory)
816
+ });
817
+ }
818
+ }
819
+ } catch (e) {
820
+ ctx.logger.debug("[DriverPlugin] Failed to auto-configure default datasource (Metadata service missing?)", { error: e });
821
+ }
790
822
  ctx.logger.debug("Driver plugin started", { driverName: this.driver.name || "unknown" });
791
823
  };
792
824
  this.driver = driver;
@@ -797,6 +829,7 @@ var DriverPlugin = class {
797
829
  // src/app-plugin.ts
798
830
  var AppPlugin = class {
799
831
  constructor(bundle) {
832
+ this.type = "app";
800
833
  this.init = async (ctx) => {
801
834
  const sys = this.bundle.manifest || this.bundle;
802
835
  const appId = sys.id || sys.name;
@@ -846,6 +879,23 @@ var AppPlugin = class {
846
879
  } else {
847
880
  ctx.logger.debug("No runtime.onEnable function found", { appId });
848
881
  }
882
+ const manifest = this.bundle.manifest || this.bundle;
883
+ if (manifest && Array.isArray(manifest.data)) {
884
+ ctx.logger.info(`[AppPlugin] Found initial data for ${appId}`, { count: manifest.data.length });
885
+ for (const dataset of manifest.data) {
886
+ if (dataset.object && Array.isArray(dataset.records)) {
887
+ ctx.logger.info(`[Seeder] Seeding ${dataset.records.length} records for ${dataset.object}`);
888
+ for (const record of dataset.records) {
889
+ try {
890
+ await ql.insert(dataset.object, record);
891
+ } catch (err) {
892
+ ctx.logger.warn(`[Seeder] Failed to insert ${dataset.object} record:`, { error: err.message });
893
+ }
894
+ }
895
+ }
896
+ }
897
+ ctx.logger.info("[Seeder] Data seeding complete.");
898
+ }
849
899
  };
850
900
  this.bundle = bundle;
851
901
  const sys = bundle.manifest || bundle;