dsqlbase 0.0.1 → 0.1.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/CHANGELOG.md +19 -0
- package/README.md +86 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +8 -0
- package/dist/schema.js.map +1 -0
- package/package.json +8 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# dsqlbase
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 66d5d93: **Query client and schema migration runner:**
|
|
8
|
+
|
|
9
|
+
Added:
|
|
10
|
+
- schema objects definition support for `namespace`, `table`, `domain`, and `sequence`;
|
|
11
|
+
- schema migrations runner via introspection -> reconcile;
|
|
12
|
+
- model client with crud operations factories for `create`, `findOne`, `findMany`, `update`, `delete`;
|
|
13
|
+
- sql tag with filter expressions, `sql.in, sql.eq, ...`;
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- @dsqlbase/client@0.1.0
|
|
18
|
+
- @dsqlbase/core@0.1.0
|
|
19
|
+
- @dsqlbase/schema@0.1.0
|
package/README.md
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3><strong>dsqlbase</strong></h3>
|
|
3
|
+
<p>Schema, query, and migration toolkit for AWS Aurora DSQL.</p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
> [!CAUTION]
|
|
9
|
+
> dsqlbase is in early-stage development and not suited for production environments.
|
|
10
|
+
> Features may change at any time, without prior notice.
|
|
11
|
+
|
|
12
|
+
dsqlbase is an ORM and migration toolkit purpose-built for [Aurora DSQL](https://aws.amazon.com/rds/aurora/dsql/). It treats DSQL's distributed-database constraints (no foreign keys, no in-place column changes, async-only index builds, etc.) as first-class — refusing unsupported DDL up front and emitting DSQL-shaped SQL by default. See the [project README](https://github.com/slsdotdev/dsqlbase#readme) for the longer motivation.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install dsqlbase
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quickstart
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// schema.ts
|
|
24
|
+
import { table, uuid, text, datetime, relations, hasMany, belongsTo } from "dsqlbase/schema";
|
|
25
|
+
|
|
26
|
+
export const teams = table("teams", {
|
|
27
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
28
|
+
name: text("name").notNull(),
|
|
29
|
+
createdAt: datetime("created_at").notNull().defaultNow(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const projects = table("projects", {
|
|
33
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
34
|
+
teamId: uuid("team_id").notNull(),
|
|
35
|
+
name: text("name").notNull(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const teamRelations = relations(teams, {
|
|
39
|
+
projects: hasMany(projects, {
|
|
40
|
+
from: [teams.columns.id],
|
|
41
|
+
to: [projects.columns.teamId],
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const projectRelations = relations(projects, {
|
|
46
|
+
team: belongsTo(teams, {
|
|
47
|
+
from: [projects.columns.teamId],
|
|
48
|
+
to: [teams.columns.id],
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// client.ts
|
|
55
|
+
import { createClient, type Session, type SQLStatement } from "dsqlbase";
|
|
56
|
+
import * as schema from "./schema";
|
|
57
|
+
import { Pool } from "pg";
|
|
58
|
+
|
|
59
|
+
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
60
|
+
|
|
61
|
+
const session: Session = {
|
|
62
|
+
async execute<T = unknown>(query: SQLStatement): Promise<T[]> {
|
|
63
|
+
const result = await pool.query(query.text, [...query.params]);
|
|
64
|
+
return result.rows as T[];
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const dsql = createClient({ schema, session });
|
|
69
|
+
|
|
70
|
+
// Use it
|
|
71
|
+
const recent = await dsql.projects.findMany({
|
|
72
|
+
orderBy: { name: "asc" },
|
|
73
|
+
limit: 10,
|
|
74
|
+
join: { team: true },
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Links
|
|
79
|
+
|
|
80
|
+
- [Repository & full docs](https://github.com/slsdotdev/dsqlbase#readme)
|
|
81
|
+
- [Issues](https://github.com/slsdotdev/dsqlbase/issues)
|
|
82
|
+
- [Contributing](https://github.com/slsdotdev/dsqlbase/blob/main/CONTRIBUTING.md)
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT.
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAuC,MAAM,kBAAkB,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { array, bigint, bool, boolean, bytea, char, date, datetime, decimal, double, duration, float4, float8, identity, int, int2, int4, int8, interval, json, numeric, real, smallint, text, time, timestamp, uuid, varchar, domain, namespace, sequence, schema, table, relations, belongsTo, hasMany, hasOne, type DateColumnOptions, type DateTimeColumnOptions, type IdentityColumnOptions, type IntervalColumnOptions, type TimeColumnOptions, type DateValueType, type Duration, } from "@dsqlbase/schema/definition";
|
|
2
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,OAAO,EAEP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EAEL,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EAEN,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,6BAA6B,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export {
|
|
2
|
+
// Columns
|
|
3
|
+
array, bigint, bool, boolean, bytea, char, date, datetime, decimal, double, duration, float4, float8, identity, int, int2, int4, int8, interval, json, numeric, real, smallint, text, time, timestamp, uuid, varchar,
|
|
4
|
+
// Objects
|
|
5
|
+
domain, namespace, sequence, schema, table,
|
|
6
|
+
// Relations
|
|
7
|
+
relations, belongsTo, hasMany, hasOne, } from "@dsqlbase/schema/definition";
|
|
8
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO;AACL,UAAU;AACV,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,OAAO;AACP,UAAU;AACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK;AACL,YAAY;AACZ,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,GASP,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsqlbase",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Query client and schema definition for distributed SQL databases",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -39,16 +39,19 @@
|
|
|
39
39
|
".": {
|
|
40
40
|
"default": "./dist/index.js",
|
|
41
41
|
"types": "./dist/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./*": {
|
|
44
|
+
"default": "./dist/*.js",
|
|
45
|
+
"types": "./dist/*.d.ts"
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
"scripts": {
|
|
45
49
|
"build": "tsc -b",
|
|
46
|
-
"test": "vitest run",
|
|
47
50
|
"lint": "eslint src --ext .ts"
|
|
48
51
|
},
|
|
49
52
|
"dependencies": {
|
|
50
|
-
"@dsqlbase/core": "^0.0
|
|
51
|
-
"@dsqlbase/schema": "^0.0
|
|
52
|
-
"@dsqlbase/client": "^0.0
|
|
53
|
+
"@dsqlbase/core": "^0.1.0",
|
|
54
|
+
"@dsqlbase/schema": "^0.1.0",
|
|
55
|
+
"@dsqlbase/client": "^0.1.0"
|
|
53
56
|
}
|
|
54
57
|
}
|