@rpcbase/api 0.48.0 → 0.50.0

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
@@ -17,7 +17,7 @@ import require$$13 from "stream";
17
17
  import require$$14 from "util";
18
18
  import { initApiClient } from "@rpcbase/client";
19
19
  import mongoose from "mongoose";
20
- import * as frameworkSchemas from "@rpcbase/schema";
20
+ import * as frameworkSchemas from "@rpcbase/db";
21
21
  const MOCK_TYPE = "MOCK_TYPE";
22
22
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
23
23
  function getDefaultExportFromCjs(x) {
@@ -21163,21 +21163,23 @@ let cachedModels = null;
21163
21163
  const buildModels = () => {
21164
21164
  const externalModelModules = globalThis.__rb_model_modules;
21165
21165
  const modelModules = externalModelModules ?? /* @__PURE__ */ Object.assign({});
21166
- const appModels = Object.entries(modelModules).map(([key, exports$1]) => {
21166
+ const appModels = Object.entries(modelModules).flatMap(([key, exports$1]) => {
21167
21167
  const modelName = key.split("/").pop()?.replace(/\.(t|j)sx?$/, "");
21168
21168
  assert(modelName, "Model name not found");
21169
- const schema = Object.entries(exports$1).find(([key2]) => key2 === `${modelName}Schema`);
21170
- assert(schema, `Schema not found for model ${modelName}`);
21171
- return {
21169
+ const schemaEntry = Object.entries(exports$1).find(([key2]) => key2 === `${modelName}Schema`);
21170
+ if (!schemaEntry) return [];
21171
+ const schema = schemaEntry[1];
21172
+ if (!(schema instanceof mongoose.Schema)) return [];
21173
+ return [{
21172
21174
  name: modelName,
21173
- model: mongoose.model(modelName, schema[1])
21174
- };
21175
+ model: mongoose.models[modelName] ?? mongoose.model(modelName, schema)
21176
+ }];
21175
21177
  });
21176
- const frameworkModels = Object.entries(frameworkSchemas).filter(([key]) => key.endsWith("Schema")).map(([key, schema]) => {
21178
+ const frameworkModels = Object.entries(frameworkSchemas).filter(([_, schema]) => schema instanceof mongoose.Schema).map(([key, schema]) => {
21177
21179
  const name = key.replace(/Schema$/, "");
21178
21180
  return {
21179
21181
  name,
21180
- model: mongoose.model(name, schema)
21182
+ model: mongoose.models[name] ?? mongoose.model(name, schema)
21181
21183
  };
21182
21184
  });
21183
21185
  return [...frameworkModels, ...appModels].reduce((acc, { name, model }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"loadModel.d.ts","sourceRoot":"","sources":["../src/loadModel.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AA6C7B,eAAO,MAAM,SAAS,GAAU,WAAW,MAAM,EAAE,KAAK,GAAG,uDAmD1D,CAAA"}
1
+ {"version":3,"file":"loadModel.d.ts","sourceRoot":"","sources":["../src/loadModel.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAgD7B,eAAO,MAAM,SAAS,GAAU,WAAW,MAAM,EAAE,KAAK,GAAG,uDAmD1D,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/api",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -26,6 +26,13 @@
26
26
  "dist/"
27
27
  ]
28
28
  },
29
+ "build-watch": {
30
+ "command": "../../node_modules/.bin/vite build --watch",
31
+ "service": true,
32
+ "dependencies": [
33
+ "build"
34
+ ]
35
+ },
29
36
  "release": {
30
37
  "command": "../../scripts/publish.js",
31
38
  "dependencies": [