@typesql/pg 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @typesql/pg
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Docs, package descriptions and error messages spell the project name TypeSQL.
8
+
9
+ - Updated dependencies:
10
+ - @typesql/core@0.1.1
11
+
3
12
  ## 0.1.0
4
13
 
5
14
  ### Minor Changes
package/dist/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /** `typesql`: `typesql introspect` writes the typesql schema of a live database. */
2
+ /** `typesql`: `typesql introspect` writes the TypeSQL schema of a live database. */
3
3
  import { main } from "./introspect/cli.js";
4
4
  process.exitCode = await main(process.argv.slice(2));
5
5
  //# sourceMappingURL=bin.js.map
@@ -6,7 +6,7 @@ import { generateSource } from "./emit.js";
6
6
  import { introspect } from "./introspect.js";
7
7
  const USAGE = `Usage: typesql introspect [options]
8
8
 
9
- Reads a live Postgres database and writes its typesql schema (tables, views, enums).
9
+ Reads a live Postgres database and writes its TypeSQL schema (tables, views, enums).
10
10
 
11
11
  Options:
12
12
  --url <url> connection string (default: $DATABASE_URL)
@@ -22,7 +22,7 @@ export interface GenerateOptions {
22
22
  readonly comments?: boolean;
23
23
  }
24
24
  /**
25
- * TypeScript source declaring the typesql schema of an introspected database: `public`
25
+ * TypeScript source declaring the TypeSQL schema of an introspected database: `public`
26
26
  * relations at the top level, other schemas nested (`DB["auth"]["sessions"]`), views and
27
27
  * materialized views as `View<…>`, enums under `$types`.
28
28
  */
@@ -25,7 +25,7 @@ function columnNotes(c) {
25
25
  return notes;
26
26
  }
27
27
  /**
28
- * TypeScript source declaring the typesql schema of an introspected database: `public`
28
+ * TypeScript source declaring the TypeSQL schema of an introspected database: `public`
29
29
  * relations at the top level, other schemas nested (`DB["auth"]["sessions"]`), views and
30
30
  * materialized views as `View<…>`, enums under `$types`.
31
31
  */
@@ -102,13 +102,13 @@ export function generateSource(db, options = {}) {
102
102
  }
103
103
  for (const [schema, rels] of namespaces) {
104
104
  if (topLevel.has(schema)) {
105
- throw new Error(`schema "${schema}" has the same name as the table "public.${schema}": typesql keeps public relations and schemas in one object`);
105
+ throw new Error(`schema "${schema}" has the same name as the table "public.${schema}": TypeSQL keeps public relations and schemas in one object`);
106
106
  }
107
107
  const body = rels.map((r) => `${relDoc(r, " ")} ${key(r.name)}: ${relation(r, " ")};`);
108
108
  lines.push(` ${key(schema)}: {\n${body.join("\n")}\n };`);
109
109
  }
110
110
  if (db.enums.length > 0) {
111
- // typesql's enum registry is flat (`Col<"mood">`, schema qualifiers are dropped), so enums
111
+ // TypeSQL's enum registry is flat (`Col<"mood">`, schema qualifiers are dropped), so enums
112
112
  // of the same name in different schemas share an entry.
113
113
  const byName = new Map();
114
114
  for (const e of db.enums) {
@@ -4,7 +4,7 @@ export type RelationKind = "table" | "partitioned table" | "view" | "materialize
4
4
  export interface IntrospectedColumn {
5
5
  readonly name: string;
6
6
  /**
7
- * Canonical Postgres type name as typesql spells it: `int4`, `timestamptz`, `varchar`, an enum
7
+ * Canonical Postgres type name as TypeSQL spells it: `int4`, `timestamptz`, `varchar`, an enum
8
8
  * name, `${T}[]` for arrays. Domains are replaced by their base type; `citext` is `text`.
9
9
  */
10
10
  readonly type: string;
@@ -7,7 +7,7 @@ const KINDS = {
7
7
  m: "materialized view",
8
8
  f: "foreign table",
9
9
  };
10
- /** Postgres type names typesql spells differently. */
10
+ /** Postgres type names TypeSQL spells differently. */
11
11
  const TYPE_ALIASES = { citext: "text" };
12
12
  function resolver(types) {
13
13
  const resolve = (oid) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@typesql/pg",
3
- "version": "0.1.0",
4
- "description": "node-postgres (pg) adapter for typesql, with `typesql introspect` to generate a schema from a live database.",
3
+ "version": "0.1.1",
4
+ "description": "node-postgres (pg) adapter for TypeSQL, with `typesql introspect` to generate a schema from a live database.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@typesql/core": "0.1.0"
38
+ "@typesql/core": "0.1.1"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "pg": ">=8"
package/src/bin.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /** `typesql`: `typesql introspect` writes the typesql schema of a live database. */
2
+ /** `typesql`: `typesql introspect` writes the TypeSQL schema of a live database. */
3
3
  import { main } from "./introspect/cli.js";
4
4
 
5
5
  process.exitCode = await main(process.argv.slice(2));
@@ -16,7 +16,7 @@ export interface IntrospectConfig extends GenerateOptions, IntrospectOptions {
16
16
 
17
17
  const USAGE = `Usage: typesql introspect [options]
18
18
 
19
- Reads a live Postgres database and writes its typesql schema (tables, views, enums).
19
+ Reads a live Postgres database and writes its TypeSQL schema (tables, views, enums).
20
20
 
21
21
  Options:
22
22
  --url <url> connection string (default: $DATABASE_URL)
@@ -51,7 +51,7 @@ function columnNotes(c: IntrospectedColumn): string[] {
51
51
  }
52
52
 
53
53
  /**
54
- * TypeScript source declaring the typesql schema of an introspected database: `public`
54
+ * TypeScript source declaring the TypeSQL schema of an introspected database: `public`
55
55
  * relations at the top level, other schemas nested (`DB["auth"]["sessions"]`), views and
56
56
  * materialized views as `View<…>`, enums under `$types`.
57
57
  */
@@ -126,14 +126,14 @@ export function generateSource(db: IntrospectedDatabase, options: GenerateOption
126
126
  }
127
127
  for (const [schema, rels] of namespaces) {
128
128
  if (topLevel.has(schema)) {
129
- throw new Error(`schema "${schema}" has the same name as the table "public.${schema}": typesql keeps public relations and schemas in one object`);
129
+ throw new Error(`schema "${schema}" has the same name as the table "public.${schema}": TypeSQL keeps public relations and schemas in one object`);
130
130
  }
131
131
  const body = rels.map((r) => `${relDoc(r, " ")} ${key(r.name)}: ${relation(r, " ")};`);
132
132
  lines.push(` ${key(schema)}: {\n${body.join("\n")}\n };`);
133
133
  }
134
134
 
135
135
  if (db.enums.length > 0) {
136
- // typesql's enum registry is flat (`Col<"mood">`, schema qualifiers are dropped), so enums
136
+ // TypeSQL's enum registry is flat (`Col<"mood">`, schema qualifiers are dropped), so enums
137
137
  // of the same name in different schemas share an entry.
138
138
  const byName = new Map<string, { values: Set<string>; schemas: string[] }>();
139
139
  for (const e of db.enums) {
@@ -6,7 +6,7 @@ export type RelationKind = "table" | "partitioned table" | "view" | "materialize
6
6
  export interface IntrospectedColumn {
7
7
  readonly name: string;
8
8
  /**
9
- * Canonical Postgres type name as typesql spells it: `int4`, `timestamptz`, `varchar`, an enum
9
+ * Canonical Postgres type name as TypeSQL spells it: `int4`, `timestamptz`, `varchar`, an enum
10
10
  * name, `${T}[]` for arrays. Domains are replaced by their base type; `citext` is `text`.
11
11
  */
12
12
  readonly type: string;
@@ -77,7 +77,7 @@ const KINDS: Readonly<Record<string, RelationKind>> = {
77
77
  f: "foreign table",
78
78
  };
79
79
 
80
- /** Postgres type names typesql spells differently. */
80
+ /** Postgres type names TypeSQL spells differently. */
81
81
  const TYPE_ALIASES: Readonly<Record<string, string>> = { citext: "text" };
82
82
 
83
83
  interface TypeRow {