@atscript/db 0.1.117 → 0.1.118

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/plugin.cjs CHANGED
@@ -98,7 +98,8 @@ async function generateModelManifest(options, output, format, repo) {
98
98
  spaces.set(e.space, group);
99
99
  }
100
100
  const spaceKeys = [...spaces.keys()].toSorted((a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b));
101
- const list = (items) => items.length ? `[${items.join(", ")}] as const` : "[]";
101
+ const list = (items) => `[${items.join(", ")}] as const`;
102
+ const spaceGroups = spaceKeys.length === 1 ? [` ${JSON.stringify(spaceKeys[0])}: atscriptModels,`] : spaceKeys.map((key) => ` ${JSON.stringify(key)}: ${list(spaces.get(key))},`);
102
103
  const content = [
103
104
  "/* oxlint-disable */",
104
105
  "/* eslint-disable */",
@@ -113,10 +114,10 @@ async function generateModelManifest(options, output, format, repo) {
113
114
  `export const dbTables = ${list(tables)}`,
114
115
  `export const dbViews = ${list(views)}`,
115
116
  "/** Every @db.table / @db.view model in this project. */",
116
- `export const atscriptModels = ${list(entries.map((e) => e.alias))}`,
117
+ "export const atscriptModels = [...dbTables, ...dbViews] as const",
117
118
  "/** Models grouped by @db.space (absent annotation → \"default\"). */",
118
119
  "export const modelsBySpace = {",
119
- ...spaceKeys.map((key) => ` ${JSON.stringify(key)}: ${list(spaces.get(key))},`),
120
+ ...spaceGroups,
120
121
  "} as const",
121
122
  ""
122
123
  ].join("\n");
package/dist/plugin.d.cts CHANGED
@@ -3,7 +3,10 @@ import { TAtscriptPlugin } from "@atscript/core";
3
3
  //#region src/plugin/manifest.d.ts
4
4
  /** Options for the generated model manifest (see {@link dbPlugin}). */
5
5
  interface TDbManifestOptions {
6
- /** Output path for the generated module, relative to the project root. */
6
+ /**
7
+ * Output path for the generated module, relative to the config's `rootDir`
8
+ * (with `rootDir: "src"`, `"models.gen.ts"` emits `src/models.gen.ts`).
9
+ */
7
10
  path: string;
8
11
  }
9
12
  //#endregion
package/dist/plugin.d.mts CHANGED
@@ -3,7 +3,10 @@ import { TAtscriptPlugin } from "@atscript/core";
3
3
  //#region src/plugin/manifest.d.ts
4
4
  /** Options for the generated model manifest (see {@link dbPlugin}). */
5
5
  interface TDbManifestOptions {
6
- /** Output path for the generated module, relative to the project root. */
6
+ /**
7
+ * Output path for the generated module, relative to the config's `rootDir`
8
+ * (with `rootDir: "src"`, `"models.gen.ts"` emits `src/models.gen.ts`).
9
+ */
7
10
  path: string;
8
11
  }
9
12
  //#endregion
package/dist/plugin.mjs CHANGED
@@ -63,7 +63,8 @@ async function generateModelManifest(options, output, format, repo) {
63
63
  spaces.set(e.space, group);
64
64
  }
65
65
  const spaceKeys = [...spaces.keys()].toSorted((a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b));
66
- const list = (items) => items.length ? `[${items.join(", ")}] as const` : "[]";
66
+ const list = (items) => `[${items.join(", ")}] as const`;
67
+ const spaceGroups = spaceKeys.length === 1 ? [` ${JSON.stringify(spaceKeys[0])}: atscriptModels,`] : spaceKeys.map((key) => ` ${JSON.stringify(key)}: ${list(spaces.get(key))},`);
67
68
  const content = [
68
69
  "/* oxlint-disable */",
69
70
  "/* eslint-disable */",
@@ -78,10 +79,10 @@ async function generateModelManifest(options, output, format, repo) {
78
79
  `export const dbTables = ${list(tables)}`,
79
80
  `export const dbViews = ${list(views)}`,
80
81
  "/** Every @db.table / @db.view model in this project. */",
81
- `export const atscriptModels = ${list(entries.map((e) => e.alias))}`,
82
+ "export const atscriptModels = [...dbTables, ...dbViews] as const",
82
83
  "/** Models grouped by @db.space (absent annotation → \"default\"). */",
83
84
  "export const modelsBySpace = {",
84
- ...spaceKeys.map((key) => ` ${JSON.stringify(key)}: ${list(spaces.get(key))},`),
85
+ ...spaceGroups,
85
86
  "} as const",
86
87
  ""
87
88
  ].join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db",
3
- "version": "0.1.117",
3
+ "version": "0.1.118",
4
4
  "description": "Database adapter utilities for atscript.",
5
5
  "keywords": [
6
6
  "atscript",